From c9a160556aff61005b7f6ff62662c5a971ad6d43 Mon Sep 17 00:00:00 2001 From: bincxz <16399091+binaricat@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:25:06 +0800 Subject: [PATCH] Fix directory tracking setup flow --- application/i18n/locales/en/terminal.ts | 3 + application/i18n/locales/ru/terminal.ts | 3 + .../i18n/locales/terminalOsc7Locales.test.ts | 3 + application/i18n/locales/zh-CN/terminal.ts | 3 + application/state/useTerminalBackend.ts | 10 + components/Terminal.tsx | 47 +++- components/terminal/TerminalView.tsx | 14 +- components/terminal/osc7Setup.test.ts | 113 +++++++- components/terminal/osc7Setup.ts | 260 +++++++++++++++++- electron/bridges/systemManagerBridge.cjs | 31 ++- .../systemManagerBridge.processes.test.cjs | 53 +++- electron/preload/api.cjs | 3 + package-lock.json | 93 +++++-- types/global/netcatty-bridge-system.d.ts | 8 + 14 files changed, 588 insertions(+), 56 deletions(-) diff --git a/application/i18n/locales/en/terminal.ts b/application/i18n/locales/en/terminal.ts index 6cb226d52..f9573b299 100644 --- a/application/i18n/locales/en/terminal.ts +++ b/application/i18n/locales/en/terminal.ts @@ -127,6 +127,9 @@ export const enTerminalMessages: Messages = { 'terminal.osc7Setup.targets': 'Possible files to update', 'terminal.osc7Setup.command': 'Command to run', 'terminal.osc7Setup.run': 'Run setup', + 'terminal.osc7Setup.running': 'Configuring...', + 'terminal.osc7Setup.configured': 'Directory tracking configured', + 'terminal.osc7Setup.failed': 'Directory tracking setup failed', 'terminal.osc7Setup.sent': 'Directory tracking setup sent to terminal', 'terminal.ymodem.selectFile': 'Select file to send', 'terminal.ymodem.allFiles': 'All files', diff --git a/application/i18n/locales/ru/terminal.ts b/application/i18n/locales/ru/terminal.ts index ebe135afd..9458b61bc 100644 --- a/application/i18n/locales/ru/terminal.ts +++ b/application/i18n/locales/ru/terminal.ts @@ -145,6 +145,9 @@ export const ruTerminalMessages: Messages = { 'terminal.osc7Setup.targets': 'Возможные файлы для обновления', 'terminal.osc7Setup.command': 'Команда для запуска', 'terminal.osc7Setup.run': 'Запустить настройку', + 'terminal.osc7Setup.running': 'Настройка...', + 'terminal.osc7Setup.configured': 'Отслеживание каталога настроено', + 'terminal.osc7Setup.failed': 'Не удалось настроить отслеживание каталога', 'terminal.osc7Setup.sent': 'Настройка отслеживания каталога отправлена в терминал', 'terminal.ymodem.selectFile': 'Выберите файл для отправки', 'terminal.ymodem.allFiles': 'Все файлы', diff --git a/application/i18n/locales/terminalOsc7Locales.test.ts b/application/i18n/locales/terminalOsc7Locales.test.ts index 940b82609..839073eeb 100644 --- a/application/i18n/locales/terminalOsc7Locales.test.ts +++ b/application/i18n/locales/terminalOsc7Locales.test.ts @@ -12,6 +12,9 @@ const osc7Keys = [ "terminal.osc7Setup.targets", "terminal.osc7Setup.command", "terminal.osc7Setup.run", + "terminal.osc7Setup.running", + "terminal.osc7Setup.configured", + "terminal.osc7Setup.failed", "terminal.osc7Setup.sent", ] as const; diff --git a/application/i18n/locales/zh-CN/terminal.ts b/application/i18n/locales/zh-CN/terminal.ts index ef15853f5..6675657b5 100644 --- a/application/i18n/locales/zh-CN/terminal.ts +++ b/application/i18n/locales/zh-CN/terminal.ts @@ -14,6 +14,9 @@ export const zhCNTerminalMessages: Messages = { 'terminal.osc7Setup.targets': '可能写入的文件', 'terminal.osc7Setup.command': '将执行的命令', 'terminal.osc7Setup.run': '执行配置', + 'terminal.osc7Setup.running': '正在配置...', + 'terminal.osc7Setup.configured': '目录追踪已配置', + 'terminal.osc7Setup.failed': '目录追踪配置失败', 'terminal.osc7Setup.sent': '目录追踪配置已发送到终端', 'terminal.toolbar.timestampsEnable': '显示时间戳', 'terminal.toolbar.timestampsDisable': '隐藏时间戳', diff --git a/application/state/useTerminalBackend.ts b/application/state/useTerminalBackend.ts index d890e95ef..6d0c534f7 100644 --- a/application/state/useTerminalBackend.ts +++ b/application/state/useTerminalBackend.ts @@ -74,6 +74,14 @@ export const useTerminalBackend = () => { return bridge.execCommand(options); }, []); + const setupOsc7Tracking = useCallback(async (sessionId: string, command: string) => { + const bridge = netcattyBridge.get(); + if (!bridge?.setupOsc7Tracking) { + return { success: false, error: "setupOsc7Tracking unavailable" }; + } + return bridge.setupOsc7Tracking(sessionId, command); + }, []); + const writeToSession = useCallback((sessionId: string, data: string, options?: Parameters>[2]) => { const bridge = netcattyBridge.get(); bridge?.writeToSession?.(sessionId, data, options); @@ -328,6 +336,7 @@ export const useTerminalBackend = () => { cancelZmodem, onZmodemEvent, execCommand, + setupOsc7Tracking, getSessionPwd, getSessionRemoteInfo, getSessionDistroInfo, @@ -377,6 +386,7 @@ export const useTerminalBackend = () => { cancelZmodem, onZmodemEvent, execCommand, + setupOsc7Tracking, getSessionPwd, getSessionRemoteInfo, getSessionDistroInfo, diff --git a/components/Terminal.tsx b/components/Terminal.tsx index ac7b5cb17..935c7cbbc 100644 --- a/components/Terminal.tsx +++ b/components/Terminal.tsx @@ -88,7 +88,7 @@ import { useTerminalAuthState } from "./terminal/hooks/useTerminalAuthState"; import { useTerminalDragDrop } from "./terminal/hooks/useTerminalDragDrop"; import { useTerminalFilePaste } from "./terminal/hooks/useTerminalFilePaste"; import { TerminalAutocomplete } from "./terminal/TerminalAutocomplete"; -import { buildOsc7SetupCommand, shouldOfferOsc7SetupAction } from "./terminal/osc7Setup"; +import { buildOsc7SetupExecCommand, runOsc7SetupAction, shouldOfferOsc7SetupAction } from "./terminal/osc7Setup"; import { getRemoteClipboardImageUploadErrorMessageKey, type RemoteClipboardImageUploadResult, @@ -746,7 +746,7 @@ const TerminalComponent: React.FC = ({ const [osc52ReadPromptVisible, setOsc52ReadPromptVisible] = useState(false); const osc52ReadResolverRef = useRef<((allowed: boolean) => void) | null>(null); const [osc7SetupOpen, setOsc7SetupOpen] = useState(false); - const osc7SetupCommand = useMemo(() => buildOsc7SetupCommand(), []); + const [osc7SetupRunning, setOsc7SetupRunning] = useState(false); const handleOsc52ReadRequest = useCallback((): Promise => { // Reject if terminal is not visible (background tab) — user can't see the prompt if (!isVisibleRef.current) return Promise.resolve(false); @@ -777,10 +777,43 @@ const TerminalComponent: React.FC = ({ handleOsc7SetupOpenChange(false); return; } - terminalBackend.writeToSession(sessionId, osc7SetupCommand, { automated: true }); - handleOsc7SetupOpenChange(false); - toast.success(t("terminal.osc7Setup.sent")); - }, [handleOsc7SetupOpenChange, osc7SetupCommand, sessionId, status, t, terminalBackend]); + if (osc7SetupRunning) return; + const currentCwd = terminalCwdTracker.getRendererCwd() ?? knownCwdRef.current; + if (!currentCwd) { + toast.error(t("terminal.osc7Setup.failed")); + return; + } + setOsc7SetupRunning(true); + void runOsc7SetupAction({ + status, + sessionId, + setupCommand: buildOsc7SetupExecCommand(currentCwd), + setupOsc7Tracking: terminalBackend.setupOsc7Tracking, + writeToSession: terminalBackend.writeToSession, + writeLocalTerminalData, + }).then((result) => { + handleOsc7SetupOpenChange(false); + if (result.success) { + toast.success(t("terminal.osc7Setup.configured")); + return; + } + toast.error(result.error || t("terminal.osc7Setup.failed")); + }).catch((error) => { + toast.error(error instanceof Error ? error.message : t("terminal.osc7Setup.failed")); + }).finally(() => { + setOsc7SetupRunning(false); + }); + }, [ + handleOsc7SetupOpenChange, + osc7SetupRunning, + sessionId, + status, + t, + terminalCwdTracker, + terminalBackend.setupOsc7Tracking, + terminalBackend.writeToSession, + writeLocalTerminalData, + ]); const handleTopOverlayMouseDownCapture = useCallback((e: React.MouseEvent) => { if (e.button !== 0) return; @@ -1995,7 +2028,7 @@ const TerminalComponent: React.FC = ({ useTerminalEffects({ CONNECTION_TIMEOUT, Error, XTERM_PERFORMANCE_CONFIG, applyUserCursorPreference, auth, autocompleteCloseRef, autocompleteInputRef, autocompleteKeyEventRef, captureTerminalLogData, clearTerminalCwd, commandBufferRef, connectionLogBufferRef, containerRef, createPromptLineBreakState, createReplaySafeTerminalLogSanitizer, createXTermRuntime, deferTerminalResizeRef, disableTerminalFontZoomRef, effectiveFontSize, effectiveFontWeight, effectiveTheme, error, executeSnippetCommand, fitAddonRef, fontFamilyId, fontSize, fontWeightFixupDoneRef, forceCloseHibernatedSession, forceSyncRenderAfterResize, handleOsc52ReadRequest, handleTerminalDataCaptureOnce, hasConnectedRef, hasRuntimeRef, host, hotkeySchemeRef, hibernatedRef, identities, inWorkspace, isBootActiveRef, isBroadcastEnabledRef, isComposeBarOpen: effectiveComposeBarOpen, isFocusMode, isFocused, isLocalConnection, isNetworkDevice, isResizing: deferTerminalResize, isRestoringSelectionRef, isSearchOpen, isSerialConnection, isVisible, isVisibleRef, keyBindingsRef, keys, knownCwdRef, lastFittedSizeRef, lastToastedErrorRef, logger, mouseTrackingRef, onBroadcastInputRef, onCommandExecuted, onCommandSubmitted, onHotkeyActionRef, onSnippetShortkeyRef, onSnippetExecutorChange, onTerminalCwdChange, onTerminalTitleChange, onTerminalBell, onTerminalFontSizeChange, paneLayoutKey, pendingAuthRef, pendingOutputScrollRef, prepareRestoredReconnect, prevIsResizingRef, promptLineBreakStateRef, resizeSession, resolveHostAuth, resolvedFontFamily, safeFit, searchAddonRef, serialConfig, serialLineBufferRef, serializeAddonRef, sessionId, sessionRef, sessionStarters, setError, setHasMouseTracking, setHasSelection, setIsCancelling, setIsDisconnectedDialogDismissed, setIsSearchOpen, setNeedsHostKeyVerification, setPendingHostKeyInfo, setPendingHostKeyRequestId, setProgressLogs, setProgressValue, setSelectionOverlayPosition, setShowLogs, setStatus, setTimeLeft, shouldEnableNativeUserInputAutoScroll, shouldProbeSessionCwd, shouldStartTerminalBackend, snippetsRef, status, statusRef, sudoAutofillRef, t, teardown, telnetLocalEchoRef, termRef, terminalAltKeyOptions, terminalBackend, terminalContextActionsRef, terminalCwdTracker, terminalDataCapturedRef, terminalLogSanitizerRef, terminalSettings, terminalSettingsRef, toHostKeyInfo, toast, updateStatus, useEffect, useLayoutEffect, xtermRuntimeRef, zmodem, zmodemToastedRef, restoreState }); - return ; + return ; }; const Terminal = memo(TerminalComponent, terminalPropsAreEqual); diff --git a/components/terminal/TerminalView.tsx b/components/terminal/TerminalView.tsx index 80096e01a..2bd6c1b32 100644 --- a/components/terminal/TerminalView.tsx +++ b/components/terminal/TerminalView.tsx @@ -97,7 +97,7 @@ function terminalViewCtxEqual( } function TerminalViewInner({ ctx }: { ctx: TerminalViewContext }) { - const { Activity, Button, Clock3, Copy, Maximize2, Radio, Sparkles, SquareArrowOutUpRight, TerminalAutocomplete, TerminalComposeBar, TerminalConnectionDialog, TerminalContextMenu, TerminalSearchBar, Tooltip, TooltipContent, TooltipTrigger, ZmodemOverwriteDialog, ZmodemProgressIndicator, auth, autocompleteAcceptTextRef, autocompleteCloseRef, autocompleteHostOs, autocompleteInputRef, autocompleteKeyEventRef, autocompleteRepositionRef, autocompleteSettings, chainProgress, cn, compactToolbar, lineTimestampsAvailable, containerRef, effectiveFontSize, effectiveFontWeight, effectiveTheme, error, executeSnippet, executeSnippetCommand, handleAddSelectionToAI, handleCancelConnect, handleCloseDisconnectedSession, handleCloseSearch, handleDismissDisconnectedDialog, handleDragEnter, handleDragLeave, handleDragOver, handleDrop, handleFindNext, handleFindPrevious, handleHostKeyAddAndContinue, handleHostKeyClose, handleHostKeyContinue, handleOsc52ReadResponse, handleOsc7SetupConfirm, handleOsc7SetupOpenChange, handleReceiveYmodem, handleRetry, handleSearch, handleSendYmodem, handleTopOverlayMouseDownCapture, hasMouseTracking, hasSelection, host, hotkeyScheme, inWorkspace, isBroadcastEnabled, isCancelling, isComposeBarOpen, isDraggingOver, isFocusMode, isLocalConnection, remoteDragDropUsesZmodem, isSerialConnection, isSearchOpen, isSupportedOs, isSystemSidebarEligible, isVisible, keyBindings, keys, knownCwdRef, needsHostKeyVerification, onCloseSession, onDetach, onDetachPointerDown, onExpandToFocus, onOpenSystem, onRename, onSplitHorizontal, onSplitVertical, onToggleBroadcast, onUpdateHost, osc52ReadPromptVisible, osc7SetupCommand, osc7SetupOpen, pendingHostKeyInfo, progressLogs, progressValue, renderControls, resolvedFontFamily, restoreState, searchMatchCount, selectionOverlayPosition, sessionDisplayName, sessionId, sessionRef, setIsComposeBarOpen, setShowLogs, shouldShowConnectionDialog, showLogs, showSelectionAIAction, snippets, status, statusDotTone, sudoHintRef, sudoHintText, t, termRef, terminalContextActions, terminalCwdTracker, terminalPreviewVars, terminalSettings, timeLeft, toast, zmodem } = ctx; + const { Activity, Button, Clock3, Copy, Maximize2, Radio, Sparkles, SquareArrowOutUpRight, TerminalAutocomplete, TerminalComposeBar, TerminalConnectionDialog, TerminalContextMenu, TerminalSearchBar, Tooltip, TooltipContent, TooltipTrigger, ZmodemOverwriteDialog, ZmodemProgressIndicator, auth, autocompleteAcceptTextRef, autocompleteCloseRef, autocompleteHostOs, autocompleteInputRef, autocompleteKeyEventRef, autocompleteRepositionRef, autocompleteSettings, chainProgress, cn, compactToolbar, lineTimestampsAvailable, containerRef, effectiveFontSize, effectiveFontWeight, effectiveTheme, error, executeSnippet, executeSnippetCommand, handleAddSelectionToAI, handleCancelConnect, handleCloseDisconnectedSession, handleCloseSearch, handleDismissDisconnectedDialog, handleDragEnter, handleDragLeave, handleDragOver, handleDrop, handleFindNext, handleFindPrevious, handleHostKeyAddAndContinue, handleHostKeyClose, handleHostKeyContinue, handleOsc52ReadResponse, handleOsc7SetupConfirm, handleOsc7SetupOpenChange, handleReceiveYmodem, handleRetry, handleSearch, handleSendYmodem, handleTopOverlayMouseDownCapture, hasMouseTracking, hasSelection, host, hotkeyScheme, inWorkspace, isBroadcastEnabled, isCancelling, isComposeBarOpen, isDraggingOver, isFocusMode, isLocalConnection, remoteDragDropUsesZmodem, isSerialConnection, isSearchOpen, isSupportedOs, isSystemSidebarEligible, isVisible, keyBindings, keys, knownCwdRef, needsHostKeyVerification, onCloseSession, onDetach, onDetachPointerDown, onExpandToFocus, onOpenSystem, onRename, onSplitHorizontal, onSplitVertical, onToggleBroadcast, onUpdateHost, osc52ReadPromptVisible, osc7SetupOpen, osc7SetupRunning, pendingHostKeyInfo, progressLogs, progressValue, renderControls, resolvedFontFamily, restoreState, searchMatchCount, selectionOverlayPosition, sessionDisplayName, sessionId, sessionRef, setIsComposeBarOpen, setShowLogs, shouldShowConnectionDialog, showLogs, showSelectionAIAction, snippets, status, statusDotTone, sudoHintRef, sudoHintText, t, termRef, terminalContextActions, terminalCwdTracker, terminalPreviewVars, terminalSettings, timeLeft, toast, zmodem } = ctx; const ymodemActionEnabled = shouldEnableYmodemAction({ isSerialConnection, status, @@ -516,21 +516,13 @@ function TerminalViewInner({ ctx }: { ctx: TerminalViewContext }) { ))} -
-

- {t("terminal.osc7Setup.command")} -

-
-                    {osc7SetupCommand}
-                  
-
- diff --git a/components/terminal/osc7Setup.test.ts b/components/terminal/osc7Setup.test.ts index 9434ab4de..81dc01aac 100644 --- a/components/terminal/osc7Setup.test.ts +++ b/components/terminal/osc7Setup.test.ts @@ -5,7 +5,13 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync import { tmpdir } from "node:os"; import { basename, join } from "node:path"; -import { OSC7_MARKER, buildOsc7SetupCommand, shouldOfferOsc7SetupAction } from "./osc7Setup"; +import { + OSC7_MARKER, + buildOsc7SetupCommand, + buildOsc7SetupExecCommand, + runOsc7SetupAction, + shouldOfferOsc7SetupAction, +} from "./osc7Setup"; const runSetup = (env: NodeJS.ProcessEnv) => { execFileSync("/bin/sh", ["-c", buildOsc7SetupCommand()], { @@ -54,6 +60,70 @@ test("shouldOfferOsc7SetupAction only allows remote shell-style sessions", () => assert.equal(shouldOfferOsc7SetupAction({ protocol: "serial", isSerialConnection: true }), false); }); +test("runOsc7SetupAction configures in the background and only sends a small reload command", async () => { + const writes: Array<{ sessionId: string; data: string; automated?: boolean }> = []; + const localData: string[] = []; + let setupArgs: { sessionId: string; command: string } | null = null; + + const result = await runOsc7SetupAction({ + status: "connected", + sessionId: "session-1", + setupCommand: "printf setup-script", + setupOsc7Tracking: async (sessionId, command) => { + setupArgs = { sessionId, command }; + return { + success: true, + stdout: "__NETCATTY_OSC7_SETUP_SHELL__=bash\n__NETCATTY_OSC7_SETUP_CONFIG__=/home/me/.bashrc\n\u001b]7;file://host/home/me\u0007", + stderr: "", + code: 0, + }; + }, + writeToSession: (sessionId, data, options) => { + writes.push({ sessionId, data, automated: options?.automated }); + }, + writeLocalTerminalData: (data) => { + localData.push(data); + }, + }); + + assert.equal(result.success, true); + assert.deepEqual(setupArgs, { sessionId: "session-1", command: "printf setup-script" }); + assert.equal(writes.length, 1); + assert.equal(writes[0].sessionId, "session-1"); + assert.equal(writes[0].automated, true); + assert.match(writes[0].data, /source '\/home\/me\/\.bashrc'/); + assert.doesNotMatch(writes[0].data, /setup-script/); + assert.deepEqual(localData, ["\u001b]7;file://host/home/me\u0007"]); +}); + +test("runOsc7SetupAction fails without reload metadata instead of reporting a partial setup", async () => { + const writes: string[] = []; + const localData: string[] = []; + + const result = await runOsc7SetupAction({ + status: "connected", + sessionId: "session-1", + setupCommand: "printf setup-script", + setupOsc7Tracking: async () => ({ + success: true, + stdout: "\u001b]7;file://host/home/me\u0007", + stderr: "", + code: 0, + }), + writeToSession: (_sessionId, data) => { + writes.push(data); + }, + writeLocalTerminalData: (data) => { + localData.push(data); + }, + }); + + assert.equal(result.success, false); + assert.match(result.error || "", /reload metadata/); + assert.deepEqual(writes, []); + assert.deepEqual(localData, []); +}); + test("buildOsc7SetupCommand configures bash once and prompt loading stays idempotent", () => { withTempHome("netcatty-osc7-bash-", (home) => { runSetup({ HOME: home, SHELL: "/bin/bash" }); @@ -77,6 +147,47 @@ test("buildOsc7SetupCommand configures bash once and prompt loading stays idempo }); }); +test("buildOsc7SetupExecCommand configures bash through a background exec shell", () => { + withTempHome("netcatty-osc7-exec-bash-", (home) => { + const output = execFileSync("/bin/sh", ["-c", buildOsc7SetupExecCommand()], { + env: { ...process.env, HOME: home, SHELL: "/bin/bash" }, + stdio: "pipe", + }).toString("utf8"); + + assert.match(output, /__NETCATTY_OSC7_SETUP_SHELL__=bash/); + assert.match(output, new RegExp(`__NETCATTY_OSC7_SETUP_CONFIG__=${home.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/\\.bashrc`)); + const bashrc = readFileSync(join(home, ".bashrc"), "utf8"); + assert.equal(markerCount(bashrc), 2); + }); +}); + +test("buildOsc7SetupExecCommand carries the expected cwd for current-tab matching", () => { + const command = buildOsc7SetupExecCommand("/srv/app's cwd"); + + assert.match(command, /NETCATTY_OSC7_EXPECTED_CWD='\/srv\/app'\\''s cwd'/); +}); + +test("buildOsc7SetupExecCommand honors exported zsh ZDOTDIR fallback", (t) => { + const zshPath = existingShells(["/bin/zsh", "/usr/bin/zsh"])[0]; + if (!zshPath) { + t.skip("zsh is not installed on this runner"); + return; + } + + withTempHome("netcatty-osc7-exec-zsh-", (home) => { + const zdotdir = join(home, ".config", "zsh"); + const output = execFileSync("/bin/sh", ["-c", buildOsc7SetupExecCommand()], { + env: { ...process.env, HOME: home, SHELL: zshPath, ZDOTDIR: zdotdir }, + stdio: "pipe", + }).toString("utf8"); + + const zshrcPath = join(zdotdir, ".zshrc"); + assert.match(output, /__NETCATTY_OSC7_SETUP_SHELL__=zsh/); + assert.match(output, new RegExp(`__NETCATTY_OSC7_SETUP_CONFIG__=${zshrcPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`)); + assert.equal(markerCount(readFileSync(zshrcPath, "utf8")), 2); + }); +}); + test("buildOsc7SetupCommand honors zsh ZDOTDIR captured from the current shell", (t) => { const zshPath = existingShells(["/bin/zsh", "/usr/bin/zsh"])[0]; if (!zshPath) { diff --git a/components/terminal/osc7Setup.ts b/components/terminal/osc7Setup.ts index e45292d53..3cf06cbec 100644 --- a/components/terminal/osc7Setup.ts +++ b/components/terminal/osc7Setup.ts @@ -6,6 +6,9 @@ export const OSC7_SETUP_TARGETS = [ "~/.config/fish/config.fish", ] as const; +export const OSC7_SETUP_SHELL_MARKER = "__NETCATTY_OSC7_SETUP_SHELL__="; +export const OSC7_SETUP_CONFIG_MARKER = "__NETCATTY_OSC7_SETUP_CONFIG__="; + export type Osc7SetupActionContext = { protocol?: string; isLocalConnection?: boolean; @@ -13,6 +16,42 @@ export type Osc7SetupActionContext = { isNetworkDevice?: boolean; }; +export type Osc7SetupShell = "bash" | "zsh" | "fish"; + +export type Osc7SetupMetadata = { + shell: Osc7SetupShell; + configPath: string; +}; + +export type Osc7SetupRunResult = { + success: boolean; + pending?: boolean; + stdout?: string; + stderr?: string; + code?: number | null; + error?: string; + reloadCommand?: string; +}; + +export type RunOsc7SetupActionOptions = { + status: string; + sessionId: string; + setupCommand: string; + setupOsc7Tracking?: ( + sessionId: string, + command: string, + ) => Promise; + writeToSession: ( + sessionId: string, + data: string, + options?: { + automated?: boolean; + logRewrite?: { sentCommand: string; displayCommand: string }; + }, + ) => void; + writeLocalTerminalData?: (data: string) => void; +}; + export const shouldOfferOsc7SetupAction = ({ protocol, isLocalConnection, @@ -54,17 +93,126 @@ const URL_PATH_AWK_SCRIPT_QUOTED = quoteForSingleQuotedShellString(URL_PATH_AWK_ const POSIX_SETUP_SCRIPT = String.raw`set -eu marker="# >>> Netcatty OSC 7 cwd tracking >>>" +SELF=$$ +expected_cwd="${DOLLAR}{NETCATTY_OSC7_EXPECTED_CWD:-}" + +find_login_shell() { + _shell=$(ps -e -o pid=,ppid=,tty=,comm= 2>/dev/null | awk -v pp="$1" -v self="$SELF" ' + $1 != self && $2 == pp && $4 ~ /^-?(ba|z|fi|k|da|a)?sh$/ { + if ($3 != "?") { print $1; found=1; exit } + if (any == "") any=$1 + } + END { if (!found && any != "") print any } + ') + [ -n "$_shell" ] && { echo "$_shell"; return; } + [ -r "/proc/$SELF/environ" ] || return + _conn=$(tr '\0' '\n' < "/proc/$SELF/environ" 2>/dev/null | sed -n 's/^SSH_CONNECTION=//p' | head -n1) + [ -z "$_conn" ] && return + _any="" + for _d in /proc/[0-9]*; do + _pid=$(basename "$_d") + [ "$_pid" = "$SELF" ] && continue + [ -r "$_d/environ" ] || continue + _conn2=$(tr '\0' '\n' < "$_d/environ" 2>/dev/null | sed -n 's/^SSH_CONNECTION=//p' | head -n1) + [ "$_conn2" = "$_conn" ] || continue + _comm=$(cat "$_d/comm" 2>/dev/null) + case "$_comm" in + sh|bash|zsh|fish|ksh|dash|ash) ;; + *) continue ;; + esac + _tty=$(ps -p "$_pid" -o tty= 2>/dev/null | tr -d '[:space:]') + if [ "$_tty" != "?" ] && [ -n "$_tty" ]; then + echo "$_pid" + return + fi + [ -z "$_any" ] && _any="$_pid" + done + [ -n "$_any" ] && echo "$_any" +} + +find_active_shell() { + ps -e -o pid=,ppid=,stat=,comm= 2>/dev/null | awk -v start="$1" ' + { pp[$1]=$2; st[$1]=$3; cm[$1]=$4; ord[NR]=$1 } + function isshell(c) { return c ~ /^-?(ba|z|fi|k|da|a)?sh$/ } + function depth(p, d) { d=0; while (p != "" && d < 64) { if (p == start) return d; p=pp[p]; d++ } return -1 } + END { + best=-1; bp=""; + for (i=1; i<=NR; i++) { + p=ord[i]; + if (!isshell(cm[p])) continue; + if (index(st[p], "+") == 0) continue; + d=depth(p); if (d < 0) continue; + if (d > best) { best=d; bp=p } + } + print (bp != "" ? bp : start) + } + ' +} + +read_proc_env_value() { + [ -r "$1" ] || return 1 + tr '\0' '\n' < "$1" 2>/dev/null | sed -n "s/^$2=//p" | head -n1 +} + +active_shell_pid="" +login_shell_pid="" +if [ -d /proc ]; then + login_shell_pid=$(find_login_shell "$PPID" || true) + if [ -n "$login_shell_pid" ]; then + active_shell_pid=$(find_active_shell "$login_shell_pid" || true) + [ -n "$active_shell_pid" ] || active_shell_pid="$login_shell_pid" + fi +fi + +if [ -d /proc ] && [ -n "$expected_cwd" ]; then + if [ -z "$active_shell_pid" ]; then + printf "Netcatty OSC 7 setup: could not identify the active terminal shell\n" >&2 + exit 4 + fi + active_cwd=$(readlink "/proc/$active_shell_pid/cwd" 2>/dev/null || true) + if [ "$active_cwd" != "$expected_cwd" ]; then + printf "Netcatty OSC 7 setup: active terminal shell did not match the current tab\n" >&2 + exit 4 + fi +fi + +active_comm="" +active_home="" +active_shell_env="" +active_zdotdir="" +active_xdg_config_home="" +if [ -n "$active_shell_pid" ]; then + active_comm=$(cat "/proc/$active_shell_pid/comm" 2>/dev/null | sed "s/^-//" | tr -d "[:space:]") + active_env_file="/proc/$active_shell_pid/environ" + if [ -r "$active_env_file" ]; then + active_home=$(read_proc_env_value "$active_env_file" HOME || true) + active_shell_env=$(read_proc_env_value "$active_env_file" SHELL || true) + active_zdotdir=$(read_proc_env_value "$active_env_file" ZDOTDIR || true) + active_xdg_config_home=$(read_proc_env_value "$active_env_file" XDG_CONFIG_HOME || true) + elif [ "$active_shell_pid" != "$login_shell_pid" ]; then + printf "Netcatty OSC 7 setup: cannot silently configure an active shell owned by another user\n" >&2 + exit 3 + fi +fi + parent_shell=$(ps -p "$PPID" -o comm= 2>/dev/null | sed "s/^-//" | tr -d "[:space:]") -login_shell=$(basename "${DOLLAR}{SHELL:-sh}" | sed "s/^-//") +login_shell=$(basename "${DOLLAR}{active_shell_env:-${DOLLAR}{SHELL:-sh}}" | sed "s/^-//") shell_name="$login_shell" case "$parent_shell" in bash|zsh|fish) shell_name="$parent_shell" ;; esac +case "$active_comm" in + bash|zsh|fish) shell_name="$active_comm" ;; +esac + +home_dir="${DOLLAR}{active_home:-$HOME}" +zdotdir="${DOLLAR}{active_zdotdir:-${DOLLAR}{NETCATTY_ZDOTDIR:-${DOLLAR}{ZDOTDIR:-$home_dir}}}" +xdg_config_home="${DOLLAR}{active_xdg_config_home:-${DOLLAR}{NETCATTY_XDG_CONFIG_HOME:-${DOLLAR}{XDG_CONFIG_HOME:-$home_dir/.config}}}" case "$shell_name" in - bash) config="$HOME/.bashrc" ;; - zsh) config="${DOLLAR}{NETCATTY_ZDOTDIR:-$HOME}/.zshrc" ;; - fish) config="${DOLLAR}{NETCATTY_XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish" ;; + bash) config="$home_dir/.bashrc" ;; + zsh) config="$zdotdir/.zshrc" ;; + fish) config="$xdg_config_home/fish/config.fish" ;; *) printf "Netcatty OSC 7 setup: unsupported shell %s\n" "$shell_name" >&2 printf "Supported shells: bash, zsh, fish\n" >&2 @@ -143,8 +291,112 @@ NETCATTY_OSC7_FISH esac fi +printf '%s%s\n' '${OSC7_SETUP_SHELL_MARKER}' "$shell_name" +printf '%s%s\n' '${OSC7_SETUP_CONFIG_MARKER}' "$config" host=$(hostname 2>/dev/null || printf localhost) printf '\033]7;file://%s%s\a' "$host" "$(__netcatty_osc7_url_path "$PWD")"`; export const buildOsc7SetupCommand = (): string => `set +u 2>/dev/null || true; printf "%s\\n" ${quoteForSingleQuotedShellString(POSIX_SETUP_SCRIPT)} | env NETCATTY_ZDOTDIR="$ZDOTDIR" NETCATTY_XDG_CONFIG_HOME="$XDG_CONFIG_HOME" sh\n`; + +export const buildOsc7SetupExecCommand = (expectedCwd?: string): string => { + const envPrefix = expectedCwd + ? `env NETCATTY_OSC7_EXPECTED_CWD=${quoteForSingleQuotedShellString(expectedCwd)} ` + : ""; + return `exec ${envPrefix}sh -c ${quoteForSingleQuotedShellString(POSIX_SETUP_SCRIPT)}\n`; +}; + +const isOsc7SetupShell = (value: string): value is Osc7SetupShell => + value === "bash" || value === "zsh" || value === "fish"; + +const readMarkerLine = (stdout: string, marker: string): string | null => { + const line = stdout.split(/\r?\n/).find((entry) => entry.startsWith(marker)); + return line ? line.slice(marker.length).trim() : null; +}; + +export const parseOsc7SetupMetadata = (stdout: string): Osc7SetupMetadata | null => { + const shell = readMarkerLine(stdout, OSC7_SETUP_SHELL_MARKER); + const configPath = readMarkerLine(stdout, OSC7_SETUP_CONFIG_MARKER); + if (!shell || !isOsc7SetupShell(shell) || !configPath) return null; + return { shell, configPath }; +}; + +export const extractOsc7SetupTerminalData = (stdout: string): string => { + const escape = String.fromCharCode(0x1b); + const bell = String.fromCharCode(0x07); + const prefix = `${escape}]7;`; + let offset = 0; + let output = ""; + + while (offset < stdout.length) { + const start = stdout.indexOf(prefix, offset); + if (start < 0) break; + const bodyStart = start + prefix.length; + const bellEnd = stdout.indexOf(bell, bodyStart); + const stEnd = stdout.indexOf(`${escape}\\`, bodyStart); + const hasBellEnd = bellEnd >= 0; + const hasStEnd = stEnd >= 0; + if (!hasBellEnd && !hasStEnd) break; + + const useBell = hasBellEnd && (!hasStEnd || bellEnd < stEnd); + const end = useBell ? bellEnd : stEnd; + const terminatorLength = useBell ? 1 : 2; + output += stdout.slice(start, end + terminatorLength); + offset = end + terminatorLength; + } + + return output; +}; + +export const buildOsc7ReloadCommand = (metadata: Osc7SetupMetadata | null): string | null => { + if (!metadata) return null; + const sourceCommand = `source ${quoteForSingleQuotedShellString(metadata.configPath)} >/dev/null 2>&1`; + const emitCommand = metadata.shell === "fish" ? "__netcatty_osc7_cwd" : "osc7_cwd"; + return ` ${sourceCommand}; ${emitCommand} 2>/dev/null; true\r`; +}; + +export const runOsc7SetupAction = async ({ + status, + sessionId, + setupCommand, + setupOsc7Tracking, + writeToSession, + writeLocalTerminalData, +}: RunOsc7SetupActionOptions): Promise => { + if (status !== "connected") { + return { success: false, error: "Terminal is not connected" }; + } + if (!setupOsc7Tracking) { + return { success: false, error: "Directory tracking setup is unavailable" }; + } + + const result = await setupOsc7Tracking(sessionId, setupCommand); + if (!result.success || (typeof result.code === "number" && result.code !== 0)) { + return { + ...result, + success: false, + error: result.error || result.stderr?.trim() || "Directory tracking setup failed", + }; + } + + const metadata = parseOsc7SetupMetadata(result.stdout || ""); + const reloadCommand = buildOsc7ReloadCommand(metadata); + if (!reloadCommand) { + return { + ...result, + success: false, + error: "Directory tracking setup did not return reload metadata", + }; + } + + const terminalData = extractOsc7SetupTerminalData(result.stdout || ""); + if (terminalData) { + writeLocalTerminalData?.(terminalData); + } + writeToSession(sessionId, reloadCommand, { + automated: true, + logRewrite: { sentCommand: reloadCommand, displayCommand: "" }, + }); + + return { ...result, success: true, reloadCommand }; +}; diff --git a/electron/bridges/systemManagerBridge.cjs b/electron/bridges/systemManagerBridge.cjs index 03fb85e40..5d3fd0cac 100644 --- a/electron/bridges/systemManagerBridge.cjs +++ b/electron/bridges/systemManagerBridge.cjs @@ -210,6 +210,34 @@ function createSystemManagerBridge(deps) { return { success: true, code: result.code }; } + async function setupOsc7Tracking(event, payload) { + const sessionId = payload?.sessionId; + const command = payload?.command; + if (!sessionId || typeof command !== "string" || !command.trim()) { + return { success: false, error: "Missing sessionId or command" }; + } + + const result = await execOnSession(event, sessionId, command, 10000); + if (result.pending) return { success: false, pending: true, error: result.error }; + if (!result.success) return { success: false, error: result.error || "Directory tracking setup failed" }; + if (typeof result.code === "number" && result.code !== 0) { + const error = String(result.stderr || result.error || `Directory tracking setup failed with exit code ${result.code}`).trim(); + return { + success: false, + stdout: result.stdout || "", + stderr: result.stderr || "", + code: result.code, + error, + }; + } + return { + success: true, + stdout: result.stdout || "", + stderr: result.stderr || "", + code: result.code ?? 0, + }; + } + async function listTmuxSessions(event, payload) { const sessionId = typeof payload === "string" ? payload : payload?.sessionId; if (!sessionId) return { success: false, error: "Missing sessionId" }; @@ -287,6 +315,7 @@ function createSystemManagerBridge(deps) { ipcMain.handle("netcatty:system:probeCapabilities", probeCapabilities); ipcMain.handle("netcatty:system:listProcesses", listProcesses); ipcMain.handle("netcatty:system:signalProcess", signalProcess); + ipcMain.handle("netcatty:system:setupOsc7Tracking", setupOsc7Tracking); ipcMain.handle("netcatty:system:listTmuxSessions", listTmuxSessions); ipcMain.handle("netcatty:system:createTmuxSession", createTmuxSession); ipcMain.handle("netcatty:system:listTmuxWindows", listTmuxWindows); @@ -302,7 +331,7 @@ function createSystemManagerBridge(deps) { ipcMain.handle("netcatty:system:dockerImageAction", dockerImageAction); } - return { registerHandlers, probeCapabilities, listProcesses }; + return { registerHandlers, probeCapabilities, listProcesses, setupOsc7Tracking }; } module.exports = { createSystemManagerBridge }; diff --git a/electron/bridges/systemManagerBridge.processes.test.cjs b/electron/bridges/systemManagerBridge.processes.test.cjs index 82e6c6398..71730b49d 100644 --- a/electron/bridges/systemManagerBridge.processes.test.cjs +++ b/electron/bridges/systemManagerBridge.processes.test.cjs @@ -5,12 +5,13 @@ const assert = require("node:assert/strict"); const { EventEmitter } = require("node:events"); const { createSystemManagerBridge } = require("./systemManagerBridge.cjs"); -function createFakeExecStream(stdout) { +function createFakeExecStream(stdout, options = {}) { const stream = new EventEmitter(); stream.stderr = new EventEmitter(); process.nextTick(() => { - stream.emit("data", stdout); - stream.emit("close", 0); + if (stdout) stream.emit("data", stdout); + if (options.stderr) stream.stderr.emit("data", options.stderr); + stream.emit("close", options.code ?? 0); }); return stream; } @@ -67,3 +68,49 @@ test("probeCapabilities reports Docker when docker is installed even if plain do assert.equal(result.success, true); assert.equal(result.capabilities.hasDocker, true); }); + +test("setupOsc7Tracking runs the setup command through the active session executor", async () => { + let seenCommand = ""; + const conn = { + exec(command, callback) { + seenCommand = command; + callback(null, createFakeExecStream("__NETCATTY_OSC7_SETUP_SHELL__=bash\n")); + }, + }; + const sessions = new Map([["s1", { conn, type: "ssh" }]]); + const bridge = createSystemManagerBridge({ + getSessions: () => sessions, + process, + }); + + const result = await bridge.setupOsc7Tracking(null, { + sessionId: "s1", + command: "printf setup-script", + }); + + assert.equal(result.success, true); + assert.equal(result.stdout, "__NETCATTY_OSC7_SETUP_SHELL__=bash\n"); + assert.equal(seenCommand, "printf setup-script"); +}); + +test("setupOsc7Tracking reports non-zero setup exits as failures", async () => { + const conn = { + exec(_command, callback) { + callback(null, createFakeExecStream("", { code: 2, stderr: "unsupported shell\n" })); + }, + }; + const sessions = new Map([["s1", { conn, type: "ssh" }]]); + const bridge = createSystemManagerBridge({ + getSessions: () => sessions, + process, + }); + + const result = await bridge.setupOsc7Tracking(null, { + sessionId: "s1", + command: "printf setup-script", + }); + + assert.equal(result.success, false); + assert.equal(result.code, 2); + assert.match(result.error, /unsupported shell/); +}); diff --git a/electron/preload/api.cjs b/electron/preload/api.cjs index d3c02cacf..d1a3532ef 100644 --- a/electron/preload/api.cjs +++ b/electron/preload/api.cjs @@ -99,6 +99,9 @@ function createPreloadApi(ctx) { signalSystemProcess: async (options) => { return ipcRenderer.invoke("netcatty:system:signalProcess", options); }, + setupOsc7Tracking: async (sessionId, command) => { + return ipcRenderer.invoke("netcatty:system:setupOsc7Tracking", { sessionId, command }); + }, listTmuxSessions: async (sessionId) => { return ipcRenderer.invoke("netcatty:system:listTmuxSessions", { sessionId }); }, diff --git a/package-lock.json b/package-lock.json index 0348616f4..bfd0e599d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -330,6 +330,29 @@ "win32" ] }, + "node_modules/@anthropic-ai/sdk": { + "version": "0.106.0", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.106.0.tgz", + "integrity": "sha512-ufwVvYNDBj2dzOGupBCTaNzBLxqcTnGOzI4z8Wouxlt+mT3J3HuOmatgCy1VmwCHOUueqZ41ERhm0O99OUcbWA==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "json-schema-to-ts": "^3.1.1", + "standardwebhooks": "^1.0.0" + }, + "bin": { + "anthropic-ai-sdk": "bin/cli" + }, + "peerDependencies": { + "zod": "^3.25.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "zod": { + "optional": true + } + } + }, "node_modules/@aws-crypto/crc32": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@aws-crypto/crc32/-/crc32-5.2.0.tgz", @@ -1259,7 +1282,6 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -1540,6 +1562,14 @@ "node": ">=6.9.0" } }, + "node_modules/@bufbuild/protobuf": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.10.1.tgz", + "integrity": "sha512-wJ8ReQbHxsAfXhrf9ixl0aYbZorRuOWpBNzm8pL8ftmSxQx/wnJD5Eg861NwJU/czy2VXFIebCeZnZrI9rktIQ==", + "license": "(Apache-2.0 AND BSD-3-Clause)", + "optional": true, + "peer": true + }, "node_modules/@buttercup/fetch": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/@buttercup/fetch/-/fetch-0.2.1.tgz", @@ -1858,7 +1888,6 @@ "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.3.tgz", "integrity": "sha512-QwCZW6Tt1siP37Jet9Tb02Zs81TQt6qQrZR2H+eGMcFsL1zMrk2/b9CLC7/9ieP1fjIUMgviLWMmgiHoJrj+ZA==", "license": "MIT", - "peer": true, "dependencies": { "@codemirror/state": "^6.0.0", "@codemirror/view": "^6.23.0", @@ -1948,7 +1977,6 @@ "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.6.0.tgz", "integrity": "sha512-4nbvra5R5EtiCzr9BTHiTLc+MLXK2QGiAVYMyi8PkQd3SR+6ixar/Q/01Fa21TBIDOZXgeWV4WppsQolSreAPQ==", "license": "MIT", - "peer": true, "dependencies": { "@marijn/find-cluster-break": "^1.0.0" } @@ -1958,7 +1986,6 @@ "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.1.tgz", "integrity": "sha512-+BIjw/AG3tDQ4pJgTLPYdAW25eDE66YsvM4LKyVPgGzVgZ4a9Wj1SRX8kPVKgBDdPt8oHtZ15F0qx7p0oOHdHw==", "license": "MIT", - "peer": true, "dependencies": { "@codemirror/state": "^6.6.0", "crelt": "^1.0.6", @@ -1966,6 +1993,16 @@ "w3c-keyname": "^2.2.4" } }, + "node_modules/@connectrpc/connect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@connectrpc/connect/-/connect-1.7.0.tgz", + "integrity": "sha512-iNKdJRi69YP3mq6AePRT8F/HrxWCewrhxnLMNm0vpqXAR8biwzRtO6Hjx80C6UvtKJ5sFmffQT7I4Baecz389w==", + "license": "Apache-2.0", + "optional": true, + "peerDependencies": { + "@bufbuild/protobuf": "^1.10.0" + } + }, "node_modules/@connectrpc/connect-node": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@connectrpc/connect-node/-/connect-node-1.7.0.tgz", @@ -2413,6 +2450,7 @@ "dev": true, "license": "BSD-2-Clause", "optional": true, + "peer": true, "dependencies": { "cross-dirname": "^0.1.0", "debug": "^4.3.4", @@ -2434,6 +2472,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", @@ -3843,7 +3882,6 @@ "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz", "integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==", "license": "MIT", - "peer": true, "dependencies": { "@lezer/common": "^1.3.0" } @@ -4126,7 +4164,6 @@ "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.29.0.tgz", "integrity": "sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==", "license": "MIT", - "peer": true, "dependencies": { "@hono/node-server": "^1.19.9", "ajv": "^8.17.1", @@ -7540,7 +7577,8 @@ "resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-1.0.1.tgz", "integrity": "sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==", "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/@standard-schema/spec": { "version": "1.1.0", @@ -8150,7 +8188,6 @@ "integrity": "sha512-hAAP5io/7csFStuOmR782YmTthKBJ9ND3WVL60hcOjvtGFb+HJxH4O5huAcmcZ9v9G8P+JETiZ/G1B8MALnWZQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.54.0", @@ -8180,7 +8217,6 @@ "integrity": "sha512-BtE0k6cjwjLZoZixN0t5AKP0kSzlGu7FctRXYuPAm//aaiZhmfq1JwdYpYr1brzEspYyFeF+8XF5j2VK6oalrA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.54.0", "@typescript-eslint/types": "8.54.0", @@ -8540,7 +8576,6 @@ "resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-6.1.0-beta.220.tgz", "integrity": "sha512-rwEKE75wfwfNWeGnjl0iQRA1W50HigKoGcGMeF3o5CqDSdI9IjmwzpV9xHXqLH6CYj6s9N1g6bbKFVDou9dJ/A==", "license": "MIT", - "peer": true, "workspaces": [ "addons/*" ] @@ -8605,7 +8640,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -9306,7 +9340,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -10132,7 +10165,8 @@ "integrity": "sha512-+R08/oI0nl3vfPcqftZRpytksBXDzOUveBq/NBVx0sUp1axwzPQrKinNx5yd5sxPu8j1wIy8AfnVQ+5eFdha6Q==", "dev": true, "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/cross-env": { "version": "10.1.0", @@ -10429,7 +10463,6 @@ "integrity": "sha512-fMkjRqKyPtsz4Kzu/qGP0BGjqzMCIgp+/7kw/u6YH6lvn/8hvL3c0TXhoFayBoYdpPCnEinnCHztd4bW7/jetA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "app-builder-lib": "26.15.2", "builder-util": "26.15.0", @@ -10711,6 +10744,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "@electron/asar": "^3.2.1", "debug": "^4.1.1", @@ -10731,6 +10765,7 @@ "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", @@ -10746,6 +10781,7 @@ "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", "dev": true, "license": "MIT", + "peer": true, "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -10756,6 +10792,7 @@ "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">= 4.0.0" } @@ -10980,7 +11017,6 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -11434,7 +11470,8 @@ "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==", "license": "Unlicense", - "optional": true + "optional": true, + "peer": true }, "node_modules/fast-uri": { "version": "3.1.0", @@ -12371,7 +12408,6 @@ "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.14.tgz", "integrity": "sha512-am5zfg3yu6sqn5yjKBNqhnTX7Cv+m00ox+7jbaKkrLMRJ4rAdldd1xPd/JzbBWspqaQv6RSTrgFN95EsfhC+7w==", "license": "MIT", - "peer": true, "engines": { "node": ">=16.9.0" } @@ -12828,6 +12864,7 @@ "resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.5.tgz", "integrity": "sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==", "license": "MIT", + "peer": true, "funding": { "type": "GitHub Sponsors ❤", "url": "https://github.com/sponsors/dmonad" @@ -12949,6 +12986,7 @@ "integrity": "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==", "license": "MIT", "optional": true, + "peer": true, "dependencies": { "@babel/runtime": "^7.18.3", "ts-algebra": "^2.0.0" @@ -13106,6 +13144,7 @@ "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.117.tgz", "integrity": "sha512-DeXj9X5xDCjgKLU/7RR+/HQEVzuuEUiwldwOGsHK/sfAfELGWEyTcf0x+uOvCvK3O2zPmZePXWL85vtia6GyZw==", "license": "MIT", + "peer": true, "dependencies": { "isomorphic.js": "^0.2.4" }, @@ -14051,7 +14090,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@types/debug": "^4.0.0", "debug": "^4.0.0", @@ -15172,6 +15210,7 @@ "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "minimist": "^1.2.6" }, @@ -15191,7 +15230,6 @@ "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz", "integrity": "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==", "license": "MIT", - "peer": true, "dependencies": { "dompurify": "3.2.7", "marked": "14.0.0" @@ -15942,6 +15980,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "dependencies": { "commander": "^9.4.0" }, @@ -15959,6 +15998,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "engines": { "node": "^12.20.0 || >=14" } @@ -16263,7 +16303,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz", "integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -16273,7 +16312,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz", "integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -17611,6 +17649,7 @@ "integrity": "sha512-BbHGOQK9olHPMvQNHWul6MYlrRTAOKn03rOe4A8O3CLWhNf4YHBqq2HJKKC+sfqpxiBY52pNeesD6jIiLDz8jg==", "license": "MIT", "optional": true, + "peer": true, "dependencies": { "@stablelib/base64": "^1.0.0", "fast-sha256": "^1.3.0" @@ -17916,6 +17955,7 @@ "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "mkdirp": "^0.5.1", "rimraf": "~2.6.2" @@ -17942,6 +17982,7 @@ "deprecated": "Rimraf versions prior to v4 are no longer supported", "dev": true, "license": "ISC", + "peer": true, "dependencies": { "glob": "^7.1.3" }, @@ -18016,7 +18057,6 @@ "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -18111,7 +18151,8 @@ "resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz", "integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==", "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/ts-api-utils": { "version": "2.4.0", @@ -18138,7 +18179,6 @@ "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" @@ -18250,7 +18290,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -18291,7 +18330,6 @@ "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==", "license": "MIT", - "peer": true, "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", @@ -18667,7 +18705,6 @@ "integrity": "sha512-Bby3NOsna2jsjfLVOHKes8sGwgl4TT0E6vvpYgnAYDIF/tie7MRaFthmKuHx1NSXjiTueXH3do80FMQgvEktRg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -18761,7 +18798,6 @@ "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -19049,7 +19085,6 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/types/global/netcatty-bridge-system.d.ts b/types/global/netcatty-bridge-system.d.ts index b91ef2df0..0d5d2917d 100644 --- a/types/global/netcatty-bridge-system.d.ts +++ b/types/global/netcatty-bridge-system.d.ts @@ -19,6 +19,14 @@ declare global { signal?: string; nice?: number; }): Promise<{ success: boolean; error?: string; code?: number }>; + setupOsc7Tracking?(sessionId: string, command: string): Promise<{ + success: boolean; + pending?: boolean; + stdout?: string; + stderr?: string; + code?: number | null; + error?: string; + }>; listTmuxSessions?(sessionId: string): Promise<{ success: boolean; error?: string;