@code-yeongyu/senpi 2026.9.2-4 → 2026.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/build.js +2 -5
- package/dist/core/dynamic-prompt/build.js.map +1 -1
- package/dist/core/dynamic-prompt/index.d.ts +1 -2
- package/dist/core/dynamic-prompt/index.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/index.js +1 -2
- package/dist/core/dynamic-prompt/index.js.map +1 -1
- package/dist/core/dynamic-prompt/intent-gate.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/intent-gate.js +9 -24
- package/dist/core/dynamic-prompt/intent-gate.js.map +1 -1
- package/dist/core/dynamic-prompt/policies.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/policies.js +3 -7
- package/dist/core/dynamic-prompt/policies.js.map +1 -1
- package/dist/core/dynamic-prompt/style.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/style.js +6 -8
- package/dist/core/dynamic-prompt/style.js.map +1 -1
- package/dist/core/dynamic-prompt/verification.js +1 -1
- package/dist/core/dynamic-prompt/verification.js.map +1 -1
- package/dist/core/dynamic-prompt/working-task.d.ts +2 -0
- package/dist/core/dynamic-prompt/working-task.d.ts.map +1 -0
- package/dist/core/dynamic-prompt/working-task.js +10 -0
- package/dist/core/dynamic-prompt/working-task.js.map +1 -0
- package/dist/core/extensions/builtin/config-reload/watch-event-source.d.ts +1 -1
- package/dist/core/extensions/builtin/config-reload/watch-event-source.d.ts.map +1 -1
- package/dist/core/extensions/builtin/config-reload/watch-event-source.js +27 -9
- package/dist/core/extensions/builtin/config-reload/watch-event-source.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.js +8 -3
- package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts +4 -3
- package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.js +18 -18
- package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +7 -0
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.js +37 -8
- package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-status.js +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-status.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/prompt.d.ts +1 -1
- package/dist/core/extensions/builtin/terminal/prompt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/prompt.js +17 -13
- package/dist/core/extensions/builtin/terminal/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js +14 -2
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts +2 -0
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.js +27 -10
- package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
- package/dist/modes/rpc/host-ensure.d.ts +6 -0
- package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
- package/dist/modes/rpc/host-ensure.js +15 -4
- package/dist/modes/rpc/host-ensure.js.map +1 -1
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
- package/dist/modes/rpc/host-lifecycle.js +16 -4
- package/dist/modes/rpc/host-lifecycle.js.map +1 -1
- package/dist/modes/rpc/multi-session-host.d.ts +3 -0
- package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
- package/dist/modes/rpc/multi-session-host.js +3 -0
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/session-command-router.d.ts +22 -0
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +132 -94
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-event-fanout.d.ts +3 -1
- package/dist/modes/rpc/session-event-fanout.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-fanout.js +14 -1
- package/dist/modes/rpc/session-event-fanout.js.map +1 -1
- package/dist/modes/rpc/session-event-writer.d.ts +2 -0
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-writer.js +16 -2
- package/dist/modes/rpc/session-event-writer.js.map +1 -1
- package/dist/modes/rpc/session-registry.d.ts +9 -8
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +14 -42
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/dist/modes/rpc/session-teardown.d.ts +12 -0
- package/dist/modes/rpc/session-teardown.d.ts.map +1 -0
- package/dist/modes/rpc/session-teardown.js +117 -0
- package/dist/modes/rpc/session-teardown.js.map +1 -0
- package/docs/rpc.md +7 -5
- package/docs/terminal-tools.md +26 -6
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
- package/dist/core/dynamic-prompt/exploration.d.ts +0 -2
- package/dist/core/dynamic-prompt/exploration.d.ts.map +0 -1
- package/dist/core/dynamic-prompt/exploration.js +0 -6
- package/dist/core/dynamic-prompt/exploration.js.map +0 -1
- package/dist/core/dynamic-prompt/parallel-tools.d.ts +0 -2
- package/dist/core/dynamic-prompt/parallel-tools.d.ts.map +0 -1
- package/dist/core/dynamic-prompt/parallel-tools.js +0 -8
- package/dist/core/dynamic-prompt/parallel-tools.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor-registry.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/monitor-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAkB,KAAK,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,MAAM,EAAmB,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,kB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WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,OAAO,EAAE,WAAW,MAAM,GAAG,QAAQ,EAAE;SACvC,CAAC,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,MAAqB;QACnC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,iBAAiB,EAAE,EAAE,CAAC;QAC7B,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC;IAC5B,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { type FSWatcher, watch } from \"node:fs\";\nimport { access, type FileHandle, lstat, open, realpath, stat } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport type { TerminalRuntimeSession } from \"./runtime-session.ts\";\nimport { describeExit } from \"./tools/spawn.ts\";\n\nexport interface MonitorLineEvent {\n\treadonly type: \"line\";\n\treadonly id: string;\n\treadonly description: string;\n\treadonly line: string;\n}\n\nexport interface MonitorSummaryEvent {\n\treadonly type: \"summary\";\n\treadonly id: string;\n\treadonly description: string;\n\treadonly summary: string;\n}\n\nexport type MonitorEvent = MonitorLineEvent | MonitorSummaryEvent;\n\nexport type MonitorRearmResult = \"rearmed\" | \"not_paused\" | \"not_found\";\n\nexport interface MonitorSnapshotEntry {\n\treadonly id: string;\n\treadonly description: string;\n\treadonly paused: boolean;\n\t/** Epoch milliseconds when the watch registered; feeds the footer's live elapsed label. */\n\treadonly startedAtMs: number;\n}\n\nexport interface MonitorRegistryOptions {\n\t/** Observes every registry transition (register/pause/rearm/settle/dispose) with the live snapshot. */\n\treadonly onChange?: (snapshot: readonly MonitorSnapshotEntry[]) => void;\n\t/** Reserves one shared terminal capacity slot for a native watch. */\n\treadonly reserve?: () => (() => void) | null;\n}\n\nexport interface RegisterFileMonitorOptions {\n\treadonly description: string;\n\treadonly path: string;\n\treadonly event: \"create\" | \"modify\";\n\treadonly timeoutMs: number;\n\treadonly cwd: string;\n\treadonly approvedParent?: string;\n}\n\nexport interface RegisterMonitorOptions {\n\treadonly id: string;\n\treadonly description: string;\n\treadonly runtime: TerminalRuntimeSession;\n\treadonly filter?: RegExp;\n}\n\ninterface PendingFileRegistration {\n\trelease: (() => void) | undefined;\n\treadonly abort: AbortController;\n\treadonly deadline: ReturnType<typeof setTimeout>;\n\tsettled: boolean;\n}\n\ninterface FileMonitorRecord {\n\treadonly id: string;\n\treadonly description: string;\n\treadonly startedAtMs: number;\n\treadonly path: string;\n\treadonly canonicalPath: string;\n\treadonly canonicalParent: string;\n\treadonly event: \"create\" | \"modify\";\n\treadonly watcher: FSWatcher;\n\treadonly release: () => void;\n\treadonly poll: ReturnType<typeof setInterval>;\n\tpaused: boolean;\n\tsettled: boolean;\n\tpresent: boolean;\n\tmtimeMs: number;\n\tsize: number;\n\tdigest: string;\n\tdevice: number;\n\tinode: number;\n\tpendingChange: boolean;\n\tdirty: boolean;\n\tdirtyPasses: number;\n\tdirtyWindowStartedAt: number;\n\tchecking: Promise<void> | undefined;\n\treadonly deadline: ReturnType<typeof setTimeout>;\n}\n\ninterface MonitorRecord {\n\treadonly id: string;\n\treadonly description: string;\n\treadonly startedAtMs: number;\n\treadonly runtime: TerminalRuntimeSession;\n\treadonly filter: RegExp | undefined;\n\tlineBuffer: string;\n\tpaused: boolean;\n\tsettled: boolean;\n\tunsubscribeOutput: (() => void) | undefined;\n\tunsubscribeExit: (() => void) | undefined;\n}\n\n/**\n * Tracks active monitor sessions alongside the terminal manager's existing bash-id registry.\n * Output is deliberately retained only by TerminalRuntimeSession's bounded history; this\n * registry holds at most one unfinished line for each live monitor.\n */\nexport class MonitorRegistry {\n\treadonly #records = new Map<string, MonitorRecord>();\n\treadonly #emit: (event: MonitorEvent) => void;\n\treadonly #onChange: ((snapshot: readonly MonitorSnapshotEntry[]) => void) | undefined;\n\treadonly #reserve: (() => (() => void) | null) | undefined;\n\treadonly #files = new Map<string, FileMonitorRecord>();\n\t#nextFileId = 1;\n\t#disposed = false;\n\t#pendingRegistrations = 0;\n\treadonly #pending = new Set<PendingFileRegistration>();\n\t#lifecycle = 0;\n\n\tconstructor(emit: (event: MonitorEvent) => void, options?: MonitorRegistryOptions) {\n\t\tthis.#emit = emit;\n\t\tthis.#onChange = options?.onChange;\n\t\tthis.#reserve = options?.reserve;\n\t}\n\n\tsnapshot(): readonly MonitorSnapshotEntry[] {\n\t\treturn [...this.#records.values(), ...this.#files.values()].map((record) => ({\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tpaused: record.paused,\n\t\t\tstartedAtMs: record.startedAtMs,\n\t\t}));\n\t}\n\n\tasync registerFile(options: RegisterFileMonitorOptions): Promise<string> {\n\t\tif (this.#disposed) throw new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\tthis.#pendingRegistrations += 1;\n\t\tconst lifecycle = this.#lifecycle;\n\t\tconst release = this.#reserve?.();\n\t\tif (this.#reserve && !release) {\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(\"Cannot create file monitor: terminal capacity is already in use.\");\n\t\t}\n\t\tconst pending: PendingFileRegistration = {\n\t\t\trelease: release ?? undefined,\n\t\t\tabort: new AbortController(),\n\t\t\tdeadline: setTimeout(() => pending.abort.abort(), options.timeoutMs),\n\t\t\tsettled: false,\n\t\t};\n\t\tthis.#pending.add(pending);\n\t\tconst path = resolve(options.cwd, options.path);\n\t\tconst parent = dirname(path);\n\t\tlet approvedParent: string;\n\t\ttry {\n\t\t\tawait this.#registrationAwait(pending, access(parent));\n\t\t\tapprovedParent = await this.#registrationAwait(pending, realpath(parent));\n\t\t\tconst approvedParentAtPermission = options.approvedParent;\n\t\t\tif (approvedParentAtPermission !== undefined && approvedParent !== approvedParentAtPermission) {\n\t\t\t\tthrow new Error(`Cannot watch file: parent directory changed during permission approval: ${parent}`);\n\t\t\t}\n\t\t\tif (this.#disposed) throw new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t} catch (error) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tif (error instanceof Error && error.message.includes(\"disposed\")) throw error;\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot access parent directory ${parent}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(`Cannot watch file: parent directory does not exist: ${parent}`);\n\t\t}\n\t\tlet initial: Awaited<ReturnType<typeof stat>> | null = null;\n\t\tlet initialHandle: FileHandle | undefined;\n\t\ttry {\n\t\t\tconst target = await this.#registrationAwait(pending, lstat(path));\n\t\t\tif (target.isSymbolicLink()) throw new Error(`Cannot watch file: target is a symbolic link: ${path}`);\n\t\t\tinitialHandle = await this.#registrationAwait(pending, open(path, \"r\"), async (handle) => {\n\t\t\t\tawait handle.close();\n\t\t\t});\n\t\t\tinitial = await this.#registrationAwait(pending, initialHandle.stat());\n\t\t\tif (!initial.isFile()) throw new Error(`Cannot watch file: target is not a regular file: ${path}`);\n\t\t\tconst resolvedTarget = await this.#registrationAwait(pending, realpath(path));\n\t\t\tif (resolvedTarget !== join(approvedParent, basename(path)))\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t\tconst rebound = await this.#registrationAwait(pending, lstat(path));\n\t\t\tif (rebound.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t\tconst reboundStat = await this.#registrationAwait(pending, stat(path));\n\t\t\tif (!reboundStat.isFile() || reboundStat.dev !== initial.dev || reboundStat.ino !== initial.ino)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t} catch (error) {\n\t\t\tawait initialHandle?.close();\n\t\t\tinitialHandle = undefined;\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthis.#finishPending(pending);\n\t\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle || this.#pendingRegistrations < 1) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst id = `watch_${this.#nextFileId++}`;\n\t\tlet watcher: FSWatcher;\n\t\ttry {\n\t\t\tconst activationParent = await this.#registrationAwait(pending, realpath(parent));\n\t\t\tif (activationParent !== approvedParent) {\n\t\t\t\tthrow new Error(`Cannot watch file: parent directory changed during registration: ${parent}`);\n\t\t\t}\n\t\t\twatcher = watch(activationParent, (_kind, name) => {\n\t\t\t\tif (!name || basename(String(name)) === basename(path)) void this.#checkFile(id);\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(`Cannot watch file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t\tlet registrationError: string | undefined;\n\t\twatcher.on(\"error\", (error) => {\n\t\t\tregistrationError = `watcher error: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\tconst record = this.#files.get(id);\n\t\t\tif (record) this.#settleFile(record, registrationError);\n\t\t});\n\t\tlet registrationCleaned = false;\n\t\tconst finishRegistration = () => {\n\t\t\tif (registrationCleaned) return;\n\t\t\tregistrationCleaned = true;\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t};\n\t\tconst cleanupRegistration = () => {\n\t\t\tif (registrationCleaned) return;\n\t\t\twatcher.close();\n\t\t\tfinishRegistration();\n\t\t\tthis.#finishPending(pending);\n\t\t};\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tcleanupRegistration();\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst canonicalPath = join(approvedParent, basename(path));\n\t\tlet digest: string;\n\t\ttry {\n\t\t\tdigest =\n\t\t\t\tinitial && initialHandle\n\t\t\t\t\t? await this.#registrationAwait(pending, this.#digestHandle(initialHandle, pending.abort.signal))\n\t\t\t\t\t: \"\";\n\t\t} catch (error) {\n\t\t\tcleanupRegistration();\n\t\t\tawait initialHandle?.close();\n\t\t\tinitialHandle = undefined;\n\t\t\tif (registrationError) {\n\t\t\t\tthis.#emit({ type: \"summary\", id, description: options.description, summary: registrationError });\n\t\t\t\tthrow new Error(registrationError);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tawait initialHandle?.close();\n\t\tinitialHandle = undefined;\n\t\tif (registrationError) {\n\t\t\tcleanupRegistration();\n\t\t\tthis.#emit({ type: \"summary\", id, description: options.description, summary: registrationError });\n\t\t\tthrow new Error(registrationError);\n\t\t}\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tcleanupRegistration();\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst record: FileMonitorRecord = {\n\t\t\tid,\n\t\t\tdescription: options.description,\n\t\t\tstartedAtMs: Date.now(),\n\t\t\tpath,\n\t\t\tcanonicalPath,\n\t\t\tcanonicalParent: approvedParent,\n\t\t\tevent: options.event,\n\t\t\twatcher,\n\t\t\trelease: release ?? (() => {}),\n\t\t\tpoll: setInterval(() => void this.#checkFile(id), 250),\n\t\t\tpaused: false,\n\t\t\tsettled: false,\n\t\t\tpresent: initial !== null,\n\t\t\tmtimeMs: initial?.mtimeMs ?? 0,\n\t\t\tsize: initial?.size ?? 0,\n\t\t\tdigest,\n\t\t\tdevice: initial?.dev ?? 0,\n\t\t\tinode: initial?.ino ?? 0,\n\t\t\tpendingChange: false,\n\t\t\tdirty: false,\n\t\t\tdirtyPasses: 0,\n\t\t\tdirtyWindowStartedAt: 0,\n\t\t\tchecking: undefined,\n\t\t\tdeadline: setTimeout(() => {\n\t\t\t\tconst current = this.#files.get(id);\n\t\t\t\tif (current) this.#settleFile(current, \"watcher timed_out\");\n\t\t\t}, options.timeoutMs),\n\t\t};\n\t\tthis.#files.set(id, record);\n\t\tfinishRegistration();\n\t\tthis.#finishPending(pending, true);\n\t\tif (registrationError || this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tthis.#settleFile(record, registrationError ?? \"watcher killed\");\n\t\t\tthrow new Error(registrationError ?? \"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tthis.#notifyChange();\n\t\treturn id;\n\t}\n\n\tasync stopFile(id: string): Promise<boolean> {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record) return false;\n\t\tthis.#settleFile(record, \"watcher killed\");\n\t\treturn true;\n\t}\n\n\tasync stopAllFiles(): Promise<number> {\n\t\tthis.#lifecycle += 1;\n\t\tconst records = [...this.#files.values()];\n\t\tfor (const record of records) this.#settleFile(record, \"watcher killed\");\n\t\tfor (const pending of [...this.#pending]) this.#finishPending(pending);\n\t\treturn records.length;\n\t}\n\n\t#settleFile(record: FileMonitorRecord, summary: string): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\tclearInterval(record.poll);\n\t\tclearTimeout(record.deadline);\n\t\trecord.watcher.close();\n\t\trecord.release();\n\t\tthis.#files.delete(record.id);\n\t\tthis.#notifyChange();\n\t\tthis.#emit({ type: \"summary\", id: record.id, description: record.description, summary });\n\t}\n\n\tasync #checkFile(id: string): Promise<void> {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record || record.settled) return;\n\t\tif (record.checking) {\n\t\t\trecord.dirty = true;\n\t\t\treturn;\n\t\t}\n\t\trecord.checking = this.#checkFileImpl(record)\n\t\t\t.catch((error) => {\n\t\t\t\tif (!record.settled)\n\t\t\t\t\tthis.#settleFile(record, `watcher error: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\trecord.checking = undefined;\n\t\t\t\tconst now = Date.now();\n\t\t\t\tif (now - record.dirtyWindowStartedAt >= 1_000) {\n\t\t\t\t\trecord.dirtyWindowStartedAt = now;\n\t\t\t\t\trecord.dirtyPasses = 0;\n\t\t\t\t}\n\t\t\t\tif (record.dirty && !record.settled && record.dirtyPasses < 1) {\n\t\t\t\t\trecord.dirty = false;\n\t\t\t\t\trecord.dirtyPasses += 1;\n\t\t\t\t\tvoid this.#checkFile(id);\n\t\t\t\t} else {\n\t\t\t\t\trecord.dirty = false;\n\t\t\t\t}\n\t\t\t});\n\t\treturn record.checking;\n\t}\n\n\tasync #checkFileImpl(record: FileMonitorRecord): Promise<void> {\n\t\tif (record.settled) return;\n\t\tlet current: Awaited<ReturnType<typeof stat>> | null = null;\n\t\tlet handle: FileHandle | undefined;\n\t\ttry {\n\t\t\tconst currentParent = await realpath(dirname(record.path));\n\t\t\tif (currentParent !== record.canonicalParent) {\n\t\t\t\tthis.#settleFile(record, `watcher error: monitored parent changed: ${dirname(record.path)}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst target = await lstat(record.canonicalPath);\n\t\t\tif (target.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tconst resolvedTarget = await realpath(record.canonicalPath);\n\t\t\tif (resolvedTarget !== record.canonicalPath)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\thandle = await open(record.canonicalPath, \"r\");\n\t\t\tconst opened = await handle.stat();\n\t\t\tif (!opened.isFile()) throw new Error(`Cannot watch file: target is not a regular file: ${record.path}`);\n\t\t\tif ((opened.dev !== record.device || opened.ino !== record.inode) && opened.nlink > 1)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tcurrent = opened;\n\t\t\tconst rebound = await lstat(record.canonicalPath);\n\t\t\tif (rebound.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tconst reboundPath = await stat(record.canonicalPath);\n\t\t\tif (!reboundPath.isFile() || reboundPath.dev !== opened.dev || reboundPath.ino !== opened.ino)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t} catch (error) {\n\t\t\tawait handle?.close();\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthis.#settleFile(record, `watcher error: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst present = current !== null;\n\t\tlet digest = \"\";\n\t\ttry {\n\t\t\tdigest = present && handle ? await this.#digestHandle(handle) : \"\";\n\t\t\tif (present && handle) {\n\t\t\t\tconst afterDigest = await stat(record.canonicalPath);\n\t\t\t\tconst opened = await handle.stat();\n\t\t\t\tif (afterDigest.dev !== opened.dev || afterDigest.ino !== opened.ino)\n\t\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\t}\n\t\t} finally {\n\t\t\tawait handle?.close();\n\t\t}\n\t\tconst changed =\n\t\t\trecord.event === \"create\"\n\t\t\t\t? !record.present && present\n\t\t\t\t: record.present &&\n\t\t\t\t\tpresent &&\n\t\t\t\t\t(current!.mtimeMs !== record.mtimeMs || current!.size !== record.size || digest !== record.digest);\n\t\trecord.pendingChange ||= changed;\n\t\tif (!record.present && current) {\n\t\t\trecord.device = current.dev;\n\t\t\trecord.inode = current.ino;\n\t\t}\n\t\trecord.present = present;\n\t\trecord.mtimeMs = current?.mtimeMs ?? 0;\n\t\trecord.size = current?.size ?? 0;\n\t\trecord.digest = digest;\n\t\tif (!record.pendingChange || record.paused || record.settled) return;\n\t\trecord.pendingChange = false;\n\t\tif (record.settled) return;\n\t\tthis.#emit({\n\t\t\ttype: \"line\",\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tline: `${record.event} ${record.path}`,\n\t\t});\n\t\tthis.#settleFile(record, \"watcher completed\");\n\t}\n\n\tregister(options: RegisterMonitorOptions): void {\n\t\tconst record: MonitorRecord = {\n\t\t\tid: options.id,\n\t\t\tdescription: options.description,\n\t\t\tstartedAtMs: Date.now(),\n\t\t\truntime: options.runtime,\n\t\t\tfilter: options.filter,\n\t\t\tlineBuffer: \"\",\n\t\t\tpaused: false,\n\t\t\tsettled: false,\n\t\t\tunsubscribeOutput: undefined,\n\t\t\tunsubscribeExit: undefined,\n\t\t};\n\t\tthis.#records.set(record.id, record);\n\t\tthis.#notifyChange();\n\n\t\t// Runtime output is already bounded. Read what was produced before monitor registration,\n\t\t// then subscribe synchronously so a fast watcher cannot lose its first line.\n\t\tthis.#consume(record, record.runtime.fullOutput());\n\t\trecord.unsubscribeOutput = record.runtime.onOutput((chunk) => this.#consume(record, chunk));\n\t\trecord.unsubscribeExit = record.runtime.session.onExit(() => this.#settle(record));\n\t\tif (record.runtime.exited) this.#settle(record);\n\t}\n\n\tpauseAll(): string[] {\n\t\tconst paused: string[] = [];\n\t\tfor (const record of [...this.#records.values(), ...this.#files.values()]) {\n\t\t\tif (record.paused) continue;\n\t\t\trecord.paused = true;\n\t\t\tpaused.push(record.id);\n\t\t}\n\t\tif (paused.length > 0) this.#notifyChange();\n\t\treturn paused;\n\t}\n\n\trearm(id: string): MonitorRearmResult {\n\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\tif (!record) return \"not_found\";\n\t\tif (!record.paused) return \"not_paused\";\n\t\trecord.paused = false;\n\t\tthis.#notifyChange();\n\t\tif (\"pendingChange\" in record && record.pendingChange) void this.#checkFile(record.id);\n\t\treturn \"rearmed\";\n\t}\n\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\t\tthis.#lifecycle += 1;\n\t\tfor (const record of this.#records.values()) this.#disposeRecord(record);\n\t\tfor (const record of this.#files.values()) this.#settleFile(record, \"watcher disposed\");\n\t\tfor (const pending of this.#pending) this.#finishPending(pending);\n\t\tthis.#records.clear();\n\t\tthis.#notifyChange();\n\t}\n\n\t#finishPending(pending: PendingFileRegistration, transfer = false): void {\n\t\tif (pending.settled) return;\n\t\tpending.settled = true;\n\t\tclearTimeout(pending.deadline);\n\t\tthis.#pending.delete(pending);\n\t\tif (transfer) pending.release = undefined;\n\t\telse {\n\t\t\tpending.abort.abort();\n\t\t\tpending.release?.();\n\t\t}\n\t}\n\n\tasync #registrationAwait<T>(\n\t\tpending: PendingFileRegistration,\n\t\toperation: Promise<T>,\n\t\tlateCleanup?: (value: T) => Promise<void>,\n\t): Promise<T> {\n\t\tif (pending.abort.signal.aborted) {\n\t\t\tvoid operation.then(\n\t\t\t\t(value) => lateCleanup?.(value),\n\t\t\t\t() => undefined,\n\t\t\t);\n\t\t\tthrow new Error(\"Cannot create file monitor: registration timed out or was disposed.\");\n\t\t}\n\t\tlet aborted = false;\n\t\tconst abort = new Promise<never>((_, reject) =>\n\t\t\tpending.abort.signal.addEventListener(\n\t\t\t\t\"abort\",\n\t\t\t\t() => {\n\t\t\t\t\taborted = true;\n\t\t\t\t\treject(new Error(\"Cannot create file monitor: registration timed out or was disposed.\"));\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t),\n\t\t);\n\t\tconst guarded = operation.then(\n\t\t\t(value) => {\n\t\t\t\tif (aborted) void lateCleanup?.(value);\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tif (aborted) return undefined as T;\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\treturn Promise.race([guarded, abort]);\n\t}\n\n\tasync #digestHandle(handle: FileHandle, signal?: AbortSignal): Promise<string> {\n\t\tconst SAMPLE_SIZE = 64 * 1024;\n\t\tif (signal?.aborted) throw new Error(\"file monitor registration cancelled\");\n\t\tconst metadata = await handle.stat();\n\t\tconst hash = createHash(\"sha256\");\n\t\tconst first = Buffer.alloc(Math.min(SAMPLE_SIZE, metadata.size));\n\t\tif (first.length > 0) {\n\t\t\tawait handle.read(first, 0, first.length, 0);\n\t\t\thash.update(first);\n\t\t}\n\t\tif (metadata.size > SAMPLE_SIZE) {\n\t\t\tconst middle = Buffer.alloc(SAMPLE_SIZE);\n\t\t\tawait handle.read(middle, 0, middle.length, Math.floor((metadata.size - middle.length) / 2));\n\t\t\thash.update(middle);\n\t\t\tconst last = Buffer.alloc(SAMPLE_SIZE);\n\t\t\tawait handle.read(last, 0, last.length, metadata.size - last.length);\n\t\t\thash.update(last);\n\t\t}\n\t\treturn `${metadata.size}:${hash.digest(\"hex\")}`;\n\t}\n\n\t#notifyChange(): void {\n\t\tthis.#onChange?.(this.snapshot());\n\t}\n\n\t#consume(record: MonitorRecord, chunk: string): void {\n\t\tif (record.settled || chunk.length === 0) return;\n\t\tlet remaining = record.lineBuffer + chunk;\n\t\tfor (;;) {\n\t\t\tconst newline = remaining.indexOf(\"\\n\");\n\t\t\tif (newline < 0) break;\n\t\t\tconst rawLine = remaining.slice(0, newline);\n\t\t\tremaining = remaining.slice(newline + 1);\n\t\t\tconst line = rawLine.endsWith(\"\\r\") ? rawLine.slice(0, -1) : rawLine;\n\t\t\tif (record.paused || (record.filter && !record.filter.test(line))) continue;\n\t\t\tthis.#emit({ type: \"line\", id: record.id, description: record.description, line });\n\t\t}\n\t\trecord.lineBuffer = remaining;\n\t}\n\n\t#settle(record: MonitorRecord): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\trecord.unsubscribeOutput?.();\n\t\trecord.unsubscribeExit?.();\n\t\tthis.#records.delete(record.id);\n\t\tthis.#notifyChange();\n\t\tconst status = describeExit(record.runtime) ?? \"exited\";\n\t\tconst code = record.runtime.exitResult?.exitCode;\n\t\tconst codeText = code === null || code === undefined ? \"\" : ` (exit code ${code})`;\n\t\tthis.#emit({\n\t\t\ttype: \"summary\",\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tsummary: `watcher ${status}${codeText}`,\n\t\t});\n\t}\n\n\t#disposeRecord(record: MonitorRecord): void {\n\t\trecord.settled = true;\n\t\trecord.unsubscribeOutput?.();\n\t\trecord.unsubscribeExit?.();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"monitor-registry.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/monitor-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAkB,K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,CAAC,aAAa,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC;QACxD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC;QACjD,MAAM,QAAQ,GAAG,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,IAAI,GAAG,CAAC;QACnF,IAAI,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,SAAS;YACf,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,OAAO,EAAE,WAAW,MAAM,GAAG,QAAQ,EAAE;SACvC,CAAC,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,MAAqB;QACnC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,iBAAiB,EAAE,EAAE,CAAC;QAC7B,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC;IAC5B,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { type FSWatcher, watch } from \"node:fs\";\nimport { access, type FileHandle, lstat, open, realpath, stat } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport type { TerminalRuntimeSession } from \"./runtime-session.ts\";\nimport { describeExit } from \"./tools/spawn.ts\";\n\nexport interface MonitorLineEvent {\n\treadonly type: \"line\";\n\treadonly id: string;\n\treadonly description: string;\n\treadonly line: string;\n}\n\nexport interface MonitorSummaryEvent {\n\treadonly type: \"summary\";\n\treadonly id: string;\n\treadonly description: string;\n\treadonly summary: string;\n}\n\nexport type MonitorEvent = MonitorLineEvent | MonitorSummaryEvent;\n\nexport type MonitorRearmResult = \"rearmed\" | \"not_paused\" | \"not_found\";\n\nexport interface MonitorResumeResult {\n\treadonly id: string;\n\treadonly mutedDropped: number;\n}\n\nexport interface MonitorSnapshotEntry {\n\treadonly id: string;\n\treadonly description: string;\n\treadonly paused: boolean;\n\t/** Epoch milliseconds when the watch registered; feeds the footer's live elapsed label. */\n\treadonly startedAtMs: number;\n}\n\nexport interface MonitorRegistryOptions {\n\t/** Observes every registry transition (register/pause/rearm/settle/dispose) with the live snapshot. */\n\treadonly onChange?: (snapshot: readonly MonitorSnapshotEntry[]) => void;\n\t/** Reserves one shared terminal capacity slot for a native watch. */\n\treadonly reserve?: () => (() => void) | null;\n}\n\nexport interface RegisterFileMonitorOptions {\n\treadonly description: string;\n\treadonly path: string;\n\treadonly event: \"create\" | \"modify\";\n\treadonly timeoutMs: number;\n\treadonly cwd: string;\n\treadonly approvedParent?: string;\n}\n\nexport interface RegisterMonitorOptions {\n\treadonly id: string;\n\treadonly description: string;\n\treadonly runtime: TerminalRuntimeSession;\n\treadonly filter?: RegExp;\n}\n\ninterface PendingFileRegistration {\n\trelease: (() => void) | undefined;\n\treadonly abort: AbortController;\n\treadonly deadline: ReturnType<typeof setTimeout>;\n\tsettled: boolean;\n}\n\ninterface FileMonitorRecord {\n\treadonly id: string;\n\treadonly description: string;\n\treadonly startedAtMs: number;\n\treadonly path: string;\n\treadonly canonicalPath: string;\n\treadonly canonicalParent: string;\n\treadonly event: \"create\" | \"modify\";\n\treadonly watcher: FSWatcher;\n\treadonly release: () => void;\n\treadonly poll: ReturnType<typeof setInterval>;\n\tpaused: boolean;\n\tsettled: boolean;\n\tpresent: boolean;\n\tmtimeMs: number;\n\tsize: number;\n\tdigest: string;\n\tdevice: number;\n\tinode: number;\n\tpendingChange: boolean;\n\tdirty: boolean;\n\tdirtyPasses: number;\n\tdirtyWindowStartedAt: number;\n\tchecking: Promise<void> | undefined;\n\treadonly deadline: ReturnType<typeof setTimeout>;\n}\n\ninterface MonitorRecord {\n\treadonly id: string;\n\treadonly description: string;\n\treadonly startedAtMs: number;\n\treadonly runtime: TerminalRuntimeSession;\n\treadonly filter: RegExp | undefined;\n\tlineBuffer: string;\n\tmutedDropped: number;\n\tpaused: boolean;\n\tsettled: boolean;\n\tunsubscribeOutput: (() => void) | undefined;\n\tunsubscribeExit: (() => void) | undefined;\n}\n\n/**\n * Tracks active monitor sessions alongside the terminal manager's existing bash-id registry.\n * Output is deliberately retained only by TerminalRuntimeSession's bounded history; this\n * registry holds at most one unfinished line for each live monitor.\n */\nexport class MonitorRegistry {\n\treadonly #records = new Map<string, MonitorRecord>();\n\treadonly #emit: (event: MonitorEvent) => void;\n\treadonly #onChange: ((snapshot: readonly MonitorSnapshotEntry[]) => void) | undefined;\n\treadonly #reserve: (() => (() => void) | null) | undefined;\n\treadonly #files = new Map<string, FileMonitorRecord>();\n\t#nextFileId = 1;\n\t#disposed = false;\n\t#pendingRegistrations = 0;\n\treadonly #pending = new Set<PendingFileRegistration>();\n\t#lifecycle = 0;\n\n\tconstructor(emit: (event: MonitorEvent) => void, options?: MonitorRegistryOptions) {\n\t\tthis.#emit = emit;\n\t\tthis.#onChange = options?.onChange;\n\t\tthis.#reserve = options?.reserve;\n\t}\n\n\tsnapshot(): readonly MonitorSnapshotEntry[] {\n\t\treturn [...this.#records.values(), ...this.#files.values()].map((record) => ({\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tpaused: record.paused,\n\t\t\tstartedAtMs: record.startedAtMs,\n\t\t}));\n\t}\n\n\tasync registerFile(options: RegisterFileMonitorOptions): Promise<string> {\n\t\tif (this.#disposed) throw new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\tthis.#pendingRegistrations += 1;\n\t\tconst lifecycle = this.#lifecycle;\n\t\tconst release = this.#reserve?.();\n\t\tif (this.#reserve && !release) {\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(\"Cannot create file monitor: terminal capacity is already in use.\");\n\t\t}\n\t\tconst pending: PendingFileRegistration = {\n\t\t\trelease: release ?? undefined,\n\t\t\tabort: new AbortController(),\n\t\t\tdeadline: setTimeout(() => pending.abort.abort(), options.timeoutMs),\n\t\t\tsettled: false,\n\t\t};\n\t\tthis.#pending.add(pending);\n\t\tconst path = resolve(options.cwd, options.path);\n\t\tconst parent = dirname(path);\n\t\tlet approvedParent: string;\n\t\ttry {\n\t\t\tawait this.#registrationAwait(pending, access(parent));\n\t\t\tapprovedParent = await this.#registrationAwait(pending, realpath(parent));\n\t\t\tconst approvedParentAtPermission = options.approvedParent;\n\t\t\tif (approvedParentAtPermission !== undefined && approvedParent !== approvedParentAtPermission) {\n\t\t\t\tthrow new Error(`Cannot watch file: parent directory changed during permission approval: ${parent}`);\n\t\t\t}\n\t\t\tif (this.#disposed) throw new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t} catch (error) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tif (error instanceof Error && error.message.includes(\"disposed\")) throw error;\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot access parent directory ${parent}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(`Cannot watch file: parent directory does not exist: ${parent}`);\n\t\t}\n\t\tlet initial: Awaited<ReturnType<typeof stat>> | null = null;\n\t\tlet initialHandle: FileHandle | undefined;\n\t\ttry {\n\t\t\tconst target = await this.#registrationAwait(pending, lstat(path));\n\t\t\tif (target.isSymbolicLink()) throw new Error(`Cannot watch file: target is a symbolic link: ${path}`);\n\t\t\tinitialHandle = await this.#registrationAwait(pending, open(path, \"r\"), async (handle) => {\n\t\t\t\tawait handle.close();\n\t\t\t});\n\t\t\tinitial = await this.#registrationAwait(pending, initialHandle.stat());\n\t\t\tif (!initial.isFile()) throw new Error(`Cannot watch file: target is not a regular file: ${path}`);\n\t\t\tconst resolvedTarget = await this.#registrationAwait(pending, realpath(path));\n\t\t\tif (resolvedTarget !== join(approvedParent, basename(path)))\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t\tconst rebound = await this.#registrationAwait(pending, lstat(path));\n\t\t\tif (rebound.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t\tconst reboundStat = await this.#registrationAwait(pending, stat(path));\n\t\t\tif (!reboundStat.isFile() || reboundStat.dev !== initial.dev || reboundStat.ino !== initial.ino)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t} catch (error) {\n\t\t\tawait initialHandle?.close();\n\t\t\tinitialHandle = undefined;\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthis.#finishPending(pending);\n\t\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle || this.#pendingRegistrations < 1) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst id = `watch_${this.#nextFileId++}`;\n\t\tlet watcher: FSWatcher;\n\t\ttry {\n\t\t\tconst activationParent = await this.#registrationAwait(pending, realpath(parent));\n\t\t\tif (activationParent !== approvedParent) {\n\t\t\t\tthrow new Error(`Cannot watch file: parent directory changed during registration: ${parent}`);\n\t\t\t}\n\t\t\twatcher = watch(activationParent, (_kind, name) => {\n\t\t\t\tif (!name || basename(String(name)) === basename(path)) void this.#checkFile(id);\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(`Cannot watch file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t\tlet registrationError: string | undefined;\n\t\twatcher.on(\"error\", (error) => {\n\t\t\tregistrationError = `watcher error: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\tconst record = this.#files.get(id);\n\t\t\tif (record) this.#settleFile(record, registrationError);\n\t\t});\n\t\tlet registrationCleaned = false;\n\t\tconst finishRegistration = () => {\n\t\t\tif (registrationCleaned) return;\n\t\t\tregistrationCleaned = true;\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t};\n\t\tconst cleanupRegistration = () => {\n\t\t\tif (registrationCleaned) return;\n\t\t\twatcher.close();\n\t\t\tfinishRegistration();\n\t\t\tthis.#finishPending(pending);\n\t\t};\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tcleanupRegistration();\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst canonicalPath = join(approvedParent, basename(path));\n\t\tlet digest: string;\n\t\ttry {\n\t\t\tdigest =\n\t\t\t\tinitial && initialHandle\n\t\t\t\t\t? await this.#registrationAwait(pending, this.#digestHandle(initialHandle, pending.abort.signal))\n\t\t\t\t\t: \"\";\n\t\t} catch (error) {\n\t\t\tcleanupRegistration();\n\t\t\tawait initialHandle?.close();\n\t\t\tinitialHandle = undefined;\n\t\t\tif (registrationError) {\n\t\t\t\tthis.#emit({ type: \"summary\", id, description: options.description, summary: registrationError });\n\t\t\t\tthrow new Error(registrationError);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tawait initialHandle?.close();\n\t\tinitialHandle = undefined;\n\t\tif (registrationError) {\n\t\t\tcleanupRegistration();\n\t\t\tthis.#emit({ type: \"summary\", id, description: options.description, summary: registrationError });\n\t\t\tthrow new Error(registrationError);\n\t\t}\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tcleanupRegistration();\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst record: FileMonitorRecord = {\n\t\t\tid,\n\t\t\tdescription: options.description,\n\t\t\tstartedAtMs: Date.now(),\n\t\t\tpath,\n\t\t\tcanonicalPath,\n\t\t\tcanonicalParent: approvedParent,\n\t\t\tevent: options.event,\n\t\t\twatcher,\n\t\t\trelease: release ?? (() => {}),\n\t\t\tpoll: setInterval(() => void this.#checkFile(id), 250),\n\t\t\tpaused: false,\n\t\t\tsettled: false,\n\t\t\tpresent: initial !== null,\n\t\t\tmtimeMs: initial?.mtimeMs ?? 0,\n\t\t\tsize: initial?.size ?? 0,\n\t\t\tdigest,\n\t\t\tdevice: initial?.dev ?? 0,\n\t\t\tinode: initial?.ino ?? 0,\n\t\t\tpendingChange: false,\n\t\t\tdirty: false,\n\t\t\tdirtyPasses: 0,\n\t\t\tdirtyWindowStartedAt: 0,\n\t\t\tchecking: undefined,\n\t\t\tdeadline: setTimeout(() => {\n\t\t\t\tconst current = this.#files.get(id);\n\t\t\t\tif (current) this.#settleFile(current, \"watcher timed_out\");\n\t\t\t}, options.timeoutMs),\n\t\t};\n\t\tthis.#files.set(id, record);\n\t\tfinishRegistration();\n\t\tthis.#finishPending(pending, true);\n\t\tif (registrationError || this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tthis.#settleFile(record, registrationError ?? \"watcher killed\");\n\t\t\tthrow new Error(registrationError ?? \"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tthis.#notifyChange();\n\t\treturn id;\n\t}\n\n\tasync stopFile(id: string): Promise<boolean> {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record) return false;\n\t\tthis.#settleFile(record, \"watcher killed\");\n\t\treturn true;\n\t}\n\n\tasync stopAllFiles(): Promise<number> {\n\t\tthis.#lifecycle += 1;\n\t\tconst records = [...this.#files.values()];\n\t\tfor (const record of records) this.#settleFile(record, \"watcher killed\");\n\t\tfor (const pending of [...this.#pending]) this.#finishPending(pending);\n\t\treturn records.length;\n\t}\n\n\t#settleFile(record: FileMonitorRecord, summary: string): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\tclearInterval(record.poll);\n\t\tclearTimeout(record.deadline);\n\t\trecord.watcher.close();\n\t\trecord.release();\n\t\tthis.#files.delete(record.id);\n\t\tthis.#notifyChange();\n\t\tthis.#emit({ type: \"summary\", id: record.id, description: record.description, summary });\n\t}\n\n\tasync #checkFile(id: string): Promise<void> {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record || record.settled) return;\n\t\tif (record.checking) {\n\t\t\trecord.dirty = true;\n\t\t\treturn;\n\t\t}\n\t\trecord.checking = this.#checkFileImpl(record)\n\t\t\t.catch((error) => {\n\t\t\t\tif (!record.settled)\n\t\t\t\t\tthis.#settleFile(record, `watcher error: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\trecord.checking = undefined;\n\t\t\t\tconst now = Date.now();\n\t\t\t\tif (now - record.dirtyWindowStartedAt >= 1_000) {\n\t\t\t\t\trecord.dirtyWindowStartedAt = now;\n\t\t\t\t\trecord.dirtyPasses = 0;\n\t\t\t\t}\n\t\t\t\tif (record.dirty && !record.settled && record.dirtyPasses < 1) {\n\t\t\t\t\trecord.dirty = false;\n\t\t\t\t\trecord.dirtyPasses += 1;\n\t\t\t\t\tvoid this.#checkFile(id);\n\t\t\t\t} else {\n\t\t\t\t\trecord.dirty = false;\n\t\t\t\t}\n\t\t\t});\n\t\treturn record.checking;\n\t}\n\n\tasync #checkFileImpl(record: FileMonitorRecord): Promise<void> {\n\t\tif (record.settled) return;\n\t\tlet current: Awaited<ReturnType<typeof stat>> | null = null;\n\t\tlet handle: FileHandle | undefined;\n\t\ttry {\n\t\t\tconst currentParent = await realpath(dirname(record.path));\n\t\t\tif (currentParent !== record.canonicalParent) {\n\t\t\t\tthis.#settleFile(record, `watcher error: monitored parent changed: ${dirname(record.path)}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst target = await lstat(record.canonicalPath);\n\t\t\tif (target.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tconst resolvedTarget = await realpath(record.canonicalPath);\n\t\t\tif (resolvedTarget !== record.canonicalPath)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\thandle = await open(record.canonicalPath, \"r\");\n\t\t\tconst opened = await handle.stat();\n\t\t\tif (!opened.isFile()) throw new Error(`Cannot watch file: target is not a regular file: ${record.path}`);\n\t\t\tif ((opened.dev !== record.device || opened.ino !== record.inode) && opened.nlink > 1)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tcurrent = opened;\n\t\t\tconst rebound = await lstat(record.canonicalPath);\n\t\t\tif (rebound.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tconst reboundPath = await stat(record.canonicalPath);\n\t\t\tif (!reboundPath.isFile() || reboundPath.dev !== opened.dev || reboundPath.ino !== opened.ino)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t} catch (error) {\n\t\t\tawait handle?.close();\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthis.#settleFile(record, `watcher error: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst present = current !== null;\n\t\tlet digest = \"\";\n\t\ttry {\n\t\t\tdigest = present && handle ? await this.#digestHandle(handle) : \"\";\n\t\t\tif (present && handle) {\n\t\t\t\tconst afterDigest = await stat(record.canonicalPath);\n\t\t\t\tconst opened = await handle.stat();\n\t\t\t\tif (afterDigest.dev !== opened.dev || afterDigest.ino !== opened.ino)\n\t\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\t}\n\t\t} finally {\n\t\t\tawait handle?.close();\n\t\t}\n\t\tconst changed =\n\t\t\trecord.event === \"create\"\n\t\t\t\t? !record.present && present\n\t\t\t\t: record.present &&\n\t\t\t\t\tpresent &&\n\t\t\t\t\t(current!.mtimeMs !== record.mtimeMs || current!.size !== record.size || digest !== record.digest);\n\t\trecord.pendingChange ||= changed;\n\t\tif (!record.present && current) {\n\t\t\trecord.device = current.dev;\n\t\t\trecord.inode = current.ino;\n\t\t}\n\t\trecord.present = present;\n\t\trecord.mtimeMs = current?.mtimeMs ?? 0;\n\t\trecord.size = current?.size ?? 0;\n\t\trecord.digest = digest;\n\t\tif (!record.pendingChange || record.paused || record.settled) return;\n\t\trecord.pendingChange = false;\n\t\tif (record.settled) return;\n\t\tthis.#emit({\n\t\t\ttype: \"line\",\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tline: `${record.event} ${record.path}`,\n\t\t});\n\t\tthis.#settleFile(record, \"watcher completed\");\n\t}\n\n\tregister(options: RegisterMonitorOptions): void {\n\t\tconst record: MonitorRecord = {\n\t\t\tid: options.id,\n\t\t\tdescription: options.description,\n\t\t\tstartedAtMs: Date.now(),\n\t\t\truntime: options.runtime,\n\t\t\tfilter: options.filter,\n\t\t\tlineBuffer: \"\",\n\t\t\tmutedDropped: 0,\n\t\t\tpaused: false,\n\t\t\tsettled: false,\n\t\t\tunsubscribeOutput: undefined,\n\t\t\tunsubscribeExit: undefined,\n\t\t};\n\t\tthis.#records.set(record.id, record);\n\t\tthis.#notifyChange();\n\n\t\t// Runtime output is already bounded. Read what was produced before monitor registration,\n\t\t// then subscribe synchronously so a fast watcher cannot lose its first line.\n\t\tthis.#consume(record, record.runtime.fullOutput());\n\t\trecord.unsubscribeOutput = record.runtime.onOutput((chunk) => this.#consume(record, chunk));\n\t\trecord.unsubscribeExit = record.runtime.session.onExit(() => this.#settle(record));\n\t\tif (record.runtime.exited) this.#settle(record);\n\t}\n\n\tpause(ids: readonly string[]): string[] {\n\t\tconst paused: string[] = [];\n\t\tfor (const id of ids) {\n\t\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\t\tif (!record || record.paused) continue;\n\t\t\trecord.paused = true;\n\t\t\tpaused.push(record.id);\n\t\t}\n\t\tif (paused.length > 0) this.#notifyChange();\n\t\treturn paused;\n\t}\n\n\tpauseAll(): string[] {\n\t\treturn this.pause([...this.#records.keys(), ...this.#files.keys()]);\n\t}\n\n\tresume(ids?: readonly string[]): MonitorResumeResult[] {\n\t\tconst candidates = ids ?? [...this.#records.keys(), ...this.#files.keys()];\n\t\tconst resumed: MonitorResumeResult[] = [];\n\t\tfor (const id of candidates) {\n\t\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\t\tif (!record?.paused) continue;\n\t\t\trecord.paused = false;\n\t\t\tconst mutedDropped = \"mutedDropped\" in record ? record.mutedDropped : 0;\n\t\t\tif (\"mutedDropped\" in record) record.mutedDropped = 0;\n\t\t\tresumed.push({ id: record.id, mutedDropped });\n\t\t\tif (\"pendingChange\" in record && record.pendingChange) void this.#checkFile(record.id);\n\t\t}\n\t\tif (resumed.length > 0) this.#notifyChange();\n\t\treturn resumed;\n\t}\n\n\tmutedDropped(id: string): number {\n\t\treturn this.#records.get(id)?.mutedDropped ?? 0;\n\t}\n\n\trearm(id: string): MonitorRearmResult {\n\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\tif (!record) return \"not_found\";\n\t\tif (!record.paused) return \"not_paused\";\n\t\tthis.resume([id]);\n\t\treturn \"rearmed\";\n\t}\n\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\t\tthis.#lifecycle += 1;\n\t\tfor (const record of this.#records.values()) this.#disposeRecord(record);\n\t\tfor (const record of this.#files.values()) this.#settleFile(record, \"watcher disposed\");\n\t\tfor (const pending of this.#pending) this.#finishPending(pending);\n\t\tthis.#records.clear();\n\t\tthis.#notifyChange();\n\t}\n\n\t#finishPending(pending: PendingFileRegistration, transfer = false): void {\n\t\tif (pending.settled) return;\n\t\tpending.settled = true;\n\t\tclearTimeout(pending.deadline);\n\t\tthis.#pending.delete(pending);\n\t\tif (transfer) pending.release = undefined;\n\t\telse {\n\t\t\tpending.abort.abort();\n\t\t\tpending.release?.();\n\t\t}\n\t}\n\n\tasync #registrationAwait<T>(\n\t\tpending: PendingFileRegistration,\n\t\toperation: Promise<T>,\n\t\tlateCleanup?: (value: T) => Promise<void>,\n\t): Promise<T> {\n\t\tif (pending.abort.signal.aborted) {\n\t\t\tvoid operation.then(\n\t\t\t\t(value) => lateCleanup?.(value),\n\t\t\t\t() => undefined,\n\t\t\t);\n\t\t\tthrow new Error(\"Cannot create file monitor: registration timed out or was disposed.\");\n\t\t}\n\t\tlet aborted = false;\n\t\tconst abort = new Promise<never>((_, reject) =>\n\t\t\tpending.abort.signal.addEventListener(\n\t\t\t\t\"abort\",\n\t\t\t\t() => {\n\t\t\t\t\taborted = true;\n\t\t\t\t\treject(new Error(\"Cannot create file monitor: registration timed out or was disposed.\"));\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t),\n\t\t);\n\t\tconst guarded = operation.then(\n\t\t\t(value) => {\n\t\t\t\tif (aborted) void lateCleanup?.(value);\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tif (aborted) return undefined as T;\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\treturn Promise.race([guarded, abort]);\n\t}\n\n\tasync #digestHandle(handle: FileHandle, signal?: AbortSignal): Promise<string> {\n\t\tconst SAMPLE_SIZE = 64 * 1024;\n\t\tif (signal?.aborted) throw new Error(\"file monitor registration cancelled\");\n\t\tconst metadata = await handle.stat();\n\t\tconst hash = createHash(\"sha256\");\n\t\tconst first = Buffer.alloc(Math.min(SAMPLE_SIZE, metadata.size));\n\t\tif (first.length > 0) {\n\t\t\tawait handle.read(first, 0, first.length, 0);\n\t\t\thash.update(first);\n\t\t}\n\t\tif (metadata.size > SAMPLE_SIZE) {\n\t\t\tconst middle = Buffer.alloc(SAMPLE_SIZE);\n\t\t\tawait handle.read(middle, 0, middle.length, Math.floor((metadata.size - middle.length) / 2));\n\t\t\thash.update(middle);\n\t\t\tconst last = Buffer.alloc(SAMPLE_SIZE);\n\t\t\tawait handle.read(last, 0, last.length, metadata.size - last.length);\n\t\t\thash.update(last);\n\t\t}\n\t\treturn `${metadata.size}:${hash.digest(\"hex\")}`;\n\t}\n\n\t#notifyChange(): void {\n\t\tthis.#onChange?.(this.snapshot());\n\t}\n\n\t#consume(record: MonitorRecord, chunk: string): void {\n\t\tif (record.settled || chunk.length === 0) return;\n\t\tlet remaining = record.lineBuffer + chunk;\n\t\tfor (;;) {\n\t\t\tconst newline = remaining.indexOf(\"\\n\");\n\t\t\tif (newline < 0) break;\n\t\t\tconst rawLine = remaining.slice(0, newline);\n\t\t\tremaining = remaining.slice(newline + 1);\n\t\t\tconst line = rawLine.endsWith(\"\\r\") ? rawLine.slice(0, -1) : rawLine;\n\t\t\tconst matchesFilter = !record.filter || record.filter.test(line);\n\t\t\tif (!matchesFilter) continue;\n\t\t\tif (record.paused) {\n\t\t\t\trecord.mutedDropped += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.#emit({ type: \"line\", id: record.id, description: record.description, line });\n\t\t}\n\t\trecord.lineBuffer = remaining;\n\t}\n\n\t#settle(record: MonitorRecord): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\trecord.unsubscribeOutput?.();\n\t\trecord.unsubscribeExit?.();\n\t\tthis.#records.delete(record.id);\n\t\tthis.#notifyChange();\n\t\tconst status = describeExit(record.runtime) ?? \"exited\";\n\t\tconst code = record.runtime.exitResult?.exitCode;\n\t\tconst codeText = code === null || code === undefined ? \"\" : ` (exit code ${code})`;\n\t\tthis.#emit({\n\t\t\ttype: \"summary\",\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tsummary: `watcher ${status}${codeText}`,\n\t\t});\n\t}\n\n\t#disposeRecord(record: MonitorRecord): void {\n\t\trecord.settled = true;\n\t\trecord.unsubscribeOutput?.();\n\t\trecord.unsubscribeExit?.();\n\t}\n}\n"]}
|
|
@@ -60,7 +60,7 @@ export function formatMonitorStatus(snapshot, nowMs) {
|
|
|
60
60
|
if (snapshot.length === 0)
|
|
61
61
|
return undefined;
|
|
62
62
|
const pausedCount = snapshot.filter((entry) => entry.paused).length;
|
|
63
|
-
const pausedPart = pausedCount === 0 ? "" : pausedCount === snapshot.length ? ",
|
|
63
|
+
const pausedPart = pausedCount === 0 ? "" : pausedCount === snapshot.length ? ", muted" : `, ${pausedCount} muted`;
|
|
64
64
|
const suffix = ` (${formatElapsedSeconds(monitorElapsedSeconds(snapshot, nowMs))}${pausedPart})`;
|
|
65
65
|
if (snapshot.length === 1) {
|
|
66
66
|
const head = `${WATCH_GLYPH} watching `;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor-status.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/monitor-status.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAE7C,gFAAgF;AAChF,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,gGAAgG;AAChG,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,SAAS,WAAW,CAAC,IAAY,EAAE,GAAW;IAC7C,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,KAAwB,EAAE,MAAc;IACjE,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QACjD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;QACxC,MAAM,IAAI,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,WAAW,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM;YAAE,OAAO,MAAM,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S,CAAC;IAC5C,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IACpE,MAAM,UAAU,GAAG,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,WAAW,QAAQ,CAAC;IACnH,MAAM,MAAM,GAAG,KAAK,oBAAoB,CAAC,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC;IACjG,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,GAAG,WAAW,YAAY,CAAC;QACxC,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,IAAI,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACjH,OAAO,IAAI,GAAG,WAAW,GAAG,MAAM,CAAC;IACpC,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,WAAW,aAAa,QAAQ,CAAC,MAAM,IAAI,CAAC;IAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACzD,OAAO,IAAI,GAAG,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACjG,CAAC","sourcesContent":["import type { MonitorSnapshotEntry } from \"./monitor-registry.ts\";\n\nexport const MONITOR_STATUS_KEY = \"monitors\";\n\n/** The footer shares one status line with other extensions; keep this brief. */\nconst MAX_STATUS_LENGTH = 48;\n/** Marks the status as a live watch at a glance (same glyph family as the session selector). */\nconst WATCH_GLYPH = \"◉\";\n\nfunction truncateEnd(text: string, max: number): string {\n\tif (text.length <= max) return text;\n\treturn `${text.slice(0, Math.max(0, max - 1))}…`;\n}\n\n/**\n * Fits as many whole descriptions as possible into the budget, folding the rest\n * into a `+N more` counter so the monitor count is never truncated away.\n */\nfunction packDescriptions(names: readonly string[], budget: number): string {\n\tfor (let kept = names.length; kept >= 1; kept--) {\n\t\tconst hiddenCount = names.length - kept;\n\t\tconst tail = hiddenCount > 0 ? ` +${hiddenCount} more` : \"\";\n\t\tconst joined = names.slice(0, kept).join(\", \");\n\t\tif (joined.length + tail.length <= budget) return joined + tail;\n\t}\n\tconst tail = names.length > 1 ? ` +${names.length - 1} more` : \"\";\n\treturn truncateEnd(names[0] ?? \"\", Math.max(1, budget - tail.length)) + tail;\n}\n\n/**\n * Goal-style compact elapsed label (`5s`, `3m`, `2h 30m`, `1d 2h 3m`). Mirrors\n * `formatGoalElapsedSeconds` in the goal builtin; kept local so this builtin stays\n * self-contained, matching the existing monitor/eval status-file duplication.\n */\nexport function formatElapsedSeconds(value: number): string {\n\tconst seconds = Math.max(0, Math.trunc(value));\n\tif (seconds < 60) return `${seconds}s`;\n\tconst minutes = Math.trunc(seconds / 60);\n\tif (minutes < 60) return `${minutes}m`;\n\tconst hours = Math.trunc(minutes / 60);\n\tconst remainingMinutes = minutes % 60;\n\tif (hours >= 24) {\n\t\tconst days = Math.trunc(hours / 24);\n\t\tconst remainingHours = hours % 24;\n\t\treturn `${days}d ${remainingHours}h ${remainingMinutes}m`;\n\t}\n\tif (remainingMinutes === 0) return `${hours}h`;\n\treturn `${hours}h ${remainingMinutes}m`;\n}\n\n/** Whole seconds since the oldest watch registered; never negative when the clock moves backwards. */\nexport function monitorElapsedSeconds(snapshot: readonly MonitorSnapshotEntry[], nowMs: number): number {\n\tlet oldest = Number.POSITIVE_INFINITY;\n\tfor (const entry of snapshot) oldest = Math.min(oldest, entry.startedAtMs);\n\tif (!Number.isFinite(oldest)) return 0;\n\treturn Math.max(0, Math.round((nowMs - oldest) / 1000));\n}\n\n/** Brief footer text for the active monitors; undefined clears the status. */\nexport function formatMonitorStatus(snapshot: readonly MonitorSnapshotEntry[], nowMs: number): string | undefined {\n\tif (snapshot.length === 0) return undefined;\n\tconst pausedCount = snapshot.filter((entry) => entry.paused).length;\n\tconst pausedPart = pausedCount === 0 ? \"\" : pausedCount === snapshot.length ? \", muted\" : `, ${pausedCount} muted`;\n\tconst suffix = ` (${formatElapsedSeconds(monitorElapsedSeconds(snapshot, nowMs))}${pausedPart})`;\n\tif (snapshot.length === 1) {\n\t\tconst head = `${WATCH_GLYPH} watching `;\n\t\tconst description = truncateEnd(snapshot[0]?.description ?? \"\", MAX_STATUS_LENGTH - head.length - suffix.length);\n\t\treturn head + description + suffix;\n\t}\n\tconst head = `${WATCH_GLYPH} watching ${snapshot.length}: `;\n\tconst names = snapshot.map((entry) => entry.description);\n\treturn head + packDescriptions(names, MAX_STATUS_LENGTH - head.length - suffix.length) + suffix;\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** System-prompt guidance for the persistent-terminal tool suite (CC-close, snake_case). */
|
|
2
|
-
export declare const TERMINAL_PROMPT_SECTION = "\n## Persistent terminal sessions\n\nThe `bash` tool is PTY-backed. For long-running or interactive work, do NOT use tmux or\nmanual `&` backgrounding \u2014 use the built-in session tools:\n\n- `bash({ command, run_in_background: true })` starts a persistent session and returns a\n `bash_id` immediately. Foreground calls still block and return output; their `timeout`\n (seconds) is a kill deadline. Background sessions ignore `timeout` and live until they\n exit or you call `kill_bash`.\n- `bash_output({ bash_id, filter, view })` peeks at a session without blocking: new output\n since the last read, the status line, or a rendered full-screen snapshot of TUIs via\n `view: \"screen\"`. Completion arrives as a notification carrying the exit code and output\n tail \u2014 peeking is for steering, never for waiting.\n- `monitor({ description, command, filter?, timeout_ms?, persistent? })`
|
|
2
|
+
export declare const TERMINAL_PROMPT_SECTION = "\n## Persistent terminal sessions\n\nThe `bash` tool is PTY-backed. For long-running or interactive work, do NOT use tmux or\nmanual `&` backgrounding \u2014 use the built-in session tools:\n\n- `bash({ command, run_in_background: true })` starts a persistent session and returns a\n `bash_id` immediately. Foreground calls still block and return output; their `timeout`\n (seconds) is a kill deadline. Background sessions ignore `timeout` and live until they\n exit or you call `kill_bash`.\n- `bash_output({ bash_id, filter, view })` peeks at a session without blocking: new output\n since the last read, the status line, or a rendered full-screen snapshot of TUIs via\n `view: \"screen\"`. Completion arrives as a notification carrying the exit code and output\n tail \u2014 peeking is for steering, never for waiting.\n- `monitor` subscribes you to a change. Pass `command` XOR `path` \u2014 one branch per call,\n never both:\n - `monitor({ description, command, filter?, timeout_ms?, persistent? })` watches a command:\n newline-terminated PTY output lines (stderr included) matching `filter` arrive as injected\n events while you keep working; command exit always delivers a summary. One-shot gate: wait\n inside the command and print one sentinel (`until <cond>; do sleep 1; done;\n printf 'READY\\n'`). Stream: `tail -n 0 -F | grep --line-buffered`. Filter noise at the\n source and stop with `kill_bash`.\n - `monitor({ description, path, event? })` natively watches one regular file and fires once \u2014\n prefer it over a shell poll loop. `\"create\"` (the default) fires only when the file appears\n after registration, so watch an already-existing file with `\"modify\"`; registration needs the\n parent directory to exist already, so poll with a `command` when the run creates that\n directory too. This branch takes no `filter` and no `persistent`.\n Identical updates are deduped; repeated monitor-only wakes pause the noisy monitor(s) that\n caused them, not all monitors. Completion still wakes the session, and\n `monitor({ action: \"rearm\", bash_id })` resumes one while `monitor({ action: \"rearm\" })`\n resumes all paused monitors; real user input also resumes paused monitors.\n- `bash_input({ bash_id, input, keys, submit })` sends stdin or named keys (e.g.\n `[\"ctrl+c\"]`, `[\"enter\"]`) to steer a REPL or interrupt a process.\n- `bash_resize({ bash_id, cols, rows })` resizes the PTY so full-screen programs reflow.\n- `kill_bash({ bash_id })` (or `{ all: true }`) tears the session tree down with no orphans.\n";
|
|
3
3
|
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/prompt.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/prompt.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,8hFAmCnC,CAAC"}
|
|
@@ -13,22 +13,26 @@ manual \`&\` backgrounding — use the built-in session tools:
|
|
|
13
13
|
since the last read, the status line, or a rendered full-screen snapshot of TUIs via
|
|
14
14
|
\`view: "screen"\`. Completion arrives as a notification carrying the exit code and output
|
|
15
15
|
tail — peeking is for steering, never for waiting.
|
|
16
|
-
- \`monitor
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
- \`monitor\` subscribes you to a change. Pass \`command\` XOR \`path\` — one branch per call,
|
|
17
|
+
never both:
|
|
18
|
+
- \`monitor({ description, command, filter?, timeout_ms?, persistent? })\` watches a command:
|
|
19
|
+
newline-terminated PTY output lines (stderr included) matching \`filter\` arrive as injected
|
|
20
|
+
events while you keep working; command exit always delivers a summary. One-shot gate: wait
|
|
21
|
+
inside the command and print one sentinel (\`until <cond>; do sleep 1; done;
|
|
22
|
+
printf 'READY\\n'\`). Stream: \`tail -n 0 -F | grep --line-buffered\`. Filter noise at the
|
|
23
|
+
source and stop with \`kill_bash\`.
|
|
24
|
+
- \`monitor({ description, path, event? })\` natively watches one regular file and fires once —
|
|
25
|
+
prefer it over a shell poll loop. \`"create"\` (the default) fires only when the file appears
|
|
26
|
+
after registration, so watch an already-existing file with \`"modify"\`; registration needs the
|
|
27
|
+
parent directory to exist already, so poll with a \`command\` when the run creates that
|
|
28
|
+
directory too. This branch takes no \`filter\` and no \`persistent\`.
|
|
29
|
+
Identical updates are deduped; repeated monitor-only wakes pause the noisy monitor(s) that
|
|
30
|
+
caused them, not all monitors. Completion still wakes the session, and
|
|
31
|
+
\`monitor({ action: "rearm", bash_id })\` resumes one while \`monitor({ action: "rearm" })\`
|
|
32
|
+
resumes all paused monitors; real user input also resumes paused monitors.
|
|
24
33
|
- \`bash_input({ bash_id, input, keys, submit })\` sends stdin or named keys (e.g.
|
|
25
34
|
\`["ctrl+c"]\`, \`["enter"]\`) to steer a REPL or interrupt a process.
|
|
26
35
|
- \`bash_resize({ bash_id, cols, rows })\` resizes the PTY so full-screen programs reflow.
|
|
27
36
|
- \`kill_bash({ bash_id })\` (or \`{ all: true }\`) tears the session tree down with no orphans.
|
|
28
|
-
|
|
29
|
-
Typical flow: start with \`run_in_background: true\`, watch for patterns with
|
|
30
|
-
\`monitor({ command, filter })\`, peek with \`bash_output\`, steer with \`bash_input\`, then
|
|
31
|
-
\`kill_bash\` when done. Completion notifications carry the exit code and output tail, so a
|
|
32
|
-
follow-up read is only needed when the tail is not enough.
|
|
33
37
|
`;
|
|
34
38
|
//# sourceMappingURL=prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/prompt.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,MAAM,CAAC,MAAM,uBAAuB,GAAG
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/prompt.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCtC,CAAC","sourcesContent":["/** System-prompt guidance for the persistent-terminal tool suite (CC-close, snake_case). */\nexport const TERMINAL_PROMPT_SECTION = `\n## Persistent terminal sessions\n\nThe \\`bash\\` tool is PTY-backed. For long-running or interactive work, do NOT use tmux or\nmanual \\`&\\` backgrounding — use the built-in session tools:\n\n- \\`bash({ command, run_in_background: true })\\` starts a persistent session and returns a\n \\`bash_id\\` immediately. Foreground calls still block and return output; their \\`timeout\\`\n (seconds) is a kill deadline. Background sessions ignore \\`timeout\\` and live until they\n exit or you call \\`kill_bash\\`.\n- \\`bash_output({ bash_id, filter, view })\\` peeks at a session without blocking: new output\n since the last read, the status line, or a rendered full-screen snapshot of TUIs via\n \\`view: \"screen\"\\`. Completion arrives as a notification carrying the exit code and output\n tail — peeking is for steering, never for waiting.\n- \\`monitor\\` subscribes you to a change. Pass \\`command\\` XOR \\`path\\` — one branch per call,\n never both:\n - \\`monitor({ description, command, filter?, timeout_ms?, persistent? })\\` watches a command:\n newline-terminated PTY output lines (stderr included) matching \\`filter\\` arrive as injected\n events while you keep working; command exit always delivers a summary. One-shot gate: wait\n inside the command and print one sentinel (\\`until <cond>; do sleep 1; done;\n printf 'READY\\\\n'\\`). Stream: \\`tail -n 0 -F | grep --line-buffered\\`. Filter noise at the\n source and stop with \\`kill_bash\\`.\n - \\`monitor({ description, path, event? })\\` natively watches one regular file and fires once —\n prefer it over a shell poll loop. \\`\"create\"\\` (the default) fires only when the file appears\n after registration, so watch an already-existing file with \\`\"modify\"\\`; registration needs the\n parent directory to exist already, so poll with a \\`command\\` when the run creates that\n directory too. This branch takes no \\`filter\\` and no \\`persistent\\`.\n Identical updates are deduped; repeated monitor-only wakes pause the noisy monitor(s) that\n caused them, not all monitors. Completion still wakes the session, and\n \\`monitor({ action: \"rearm\", bash_id })\\` resumes one while \\`monitor({ action: \"rearm\" })\\`\n resumes all paused monitors; real user input also resumes paused monitors.\n- \\`bash_input({ bash_id, input, keys, submit })\\` sends stdin or named keys (e.g.\n \\`[\"ctrl+c\"]\\`, \\`[\"enter\"]\\`) to steer a REPL or interrupt a process.\n- \\`bash_resize({ bash_id, cols, rows })\\` resizes the PTY so full-screen programs reflow.\n- \\`kill_bash({ bash_id })\\` (or \\`{ all: true }\\`) tears the session tree down with no orphans.\n`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-output.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/bash-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG3E,eAAO,MAAM,gBAAgB;;;;EAQ3B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAwB9D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;;yBAShC,MAAM,SAAS,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;;;
|
|
1
|
+
{"version":3,"file":"bash-output.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/bash-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG3E,eAAO,MAAM,gBAAgB;;;;EAQ3B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAwB9D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;;yBAShC,MAAM,SAAS,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;;;EA6BxF"}
|
|
@@ -44,13 +44,25 @@ export function createBashOutputTool(ctx) {
|
|
|
44
44
|
const runtime = ctx.manager.get(input.bash_id);
|
|
45
45
|
if (!runtime)
|
|
46
46
|
return errorResult(`No terminal session found with id: ${input.bash_id}`);
|
|
47
|
+
const monitorEntry = ctx.monitorRegistry?.snapshot().find((entry) => entry.id === input.bash_id);
|
|
48
|
+
const muted = monitorEntry?.paused === true;
|
|
49
|
+
const mutedDropped = muted ? (ctx.monitorRegistry?.mutedDropped(input.bash_id) ?? 0) : 0;
|
|
50
|
+
let mutedNote = "";
|
|
51
|
+
if (muted) {
|
|
52
|
+
mutedNote =
|
|
53
|
+
mutedDropped > 0
|
|
54
|
+
? `monitor muted — ${mutedDropped} line(s) dropped while muted; run monitor({ action: "rearm", bash_id: "${input.bash_id}" }) to resume.`
|
|
55
|
+
: `monitor muted; run monitor({ action: "rearm", bash_id: "${input.bash_id}" }) to resume.`;
|
|
56
|
+
}
|
|
57
|
+
const extra = monitorEntry ? { details: { monitorMuted: muted, mutedDropped } } : undefined;
|
|
58
|
+
const prefix = mutedNote.length > 0 ? `${mutedNote}\n` : "";
|
|
47
59
|
if (input.view === "screen") {
|
|
48
|
-
return textResult(`${statusLine(runtime)}\n${screenView(runtime)}
|
|
60
|
+
return textResult(`${prefix}${statusLine(runtime)}\n${screenView(runtime)}`, extra);
|
|
49
61
|
}
|
|
50
62
|
const delta = runtime.readDelta();
|
|
51
63
|
const formatted = formatTerminalToolOutput(applyFilter(delta.text, input.filter));
|
|
52
64
|
const dropped = delta.droppedChars > 0 ? `[${delta.droppedChars} earlier chars dropped]\n` : "";
|
|
53
|
-
return textResult(`${statusLine(runtime)}\n${dropped}${formatted.text || "(no new output)"}
|
|
65
|
+
return textResult(`${prefix}${statusLine(runtime)}\n${dropped}${formatted.text || "(no new output)"}`, extra);
|
|
54
66
|
},
|
|
55
67
|
renderCall: renderBashOutputCall,
|
|
56
68
|
renderResult: renderBashOutputResult,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-output.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/bash-output.ts"],"names":[],"mappings":"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KAAK,OAAO,GAAG,SAAS,CAAC,IAAI,IAAI,iBAAiB,EAAE,EAAE,KAAK,CAAC,CAAC;QAC/G,CAAC;QACD,UAAU,EAAE,oBAAoB;QAChC,YAAY,EAAE,sBAAsB;KACpC,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { formatTerminalToolOutput } from \"../output-format.ts\";\nimport type { TerminalRuntimeSession } from \"../runtime-session.ts\";\nimport { safeRegExp, TERMINAL_OUTPUT_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\nimport { renderBashOutputCall, renderBashOutputResult } from \"./render.ts\";\nimport { describeExit } from \"./spawn.ts\";\n\nexport const bashOutputSchema = Type.Object({\n\tbash_id: Type.String({ description: \"Session id returned by a run_in_background bash call.\" }),\n\tfilter: Type.Optional(Type.String({ description: \"Only return output lines matching this regex.\" })),\n\tview: Type.Optional(\n\t\tType.Union([Type.Literal(\"log\"), Type.Literal(\"screen\")], {\n\t\t\tdescription: \"'log' returns new raw output (default); 'screen' returns the rendered xterm grid.\",\n\t\t}),\n\t),\n});\n\nexport type BashOutputInput = Static<typeof bashOutputSchema>;\n\nfunction statusLine(runtime: TerminalRuntimeSession): string {\n\tif (!runtime.exited) return \"status: running\";\n\tconst status = describeExit(runtime) ?? \"exited\";\n\tconst code = runtime.exitResult?.exitCode;\n\treturn code === null || code === undefined ? `status: ${status}` : `status: ${status} exit_code: ${code}`;\n}\n\nfunction applyFilter(text: string, filter: string | undefined): string {\n\tif (!filter) return text;\n\tconst regex = safeRegExp(filter);\n\tif (regex === null) return text;\n\treturn text\n\t\t.split(\"\\n\")\n\t\t.filter((line) => regex.test(line))\n\t\t.join(\"\\n\");\n}\n\nfunction screenView(runtime: TerminalRuntimeSession): string {\n\tconst snapshot = runtime.snapshot();\n\treturn snapshot.visibleGrid.join(\"\\n\").replace(/\\s+$/, \"\");\n}\n\nexport function createBashOutputTool(ctx: TerminalToolContext) {\n\treturn {\n\t\tname: TERMINAL_OUTPUT_TOOL,\n\t\tlabel: \"bash_output\",\n\t\tdescription:\n\t\t\t\"Read output from a background bash session without blocking: new output since the last read, the status line, or a rendered full-screen snapshot via view:'screen'. Pattern watches run through monitor; completion arrives as a notification carrying the exit code and output tail.\",\n\t\tpromptSnippet:\n\t\t\t\"Peek at background bash session output (filter, screen view, status); watch patterns with monitor, completion arrives as a notification\",\n\t\tparameters: bashOutputSchema,\n\t\tasync execute(_toolCallId: string, input: BashOutputInput): Promise<TerminalToolResult> {\n\t\t\tconst runtime = ctx.manager.get(input.bash_id);\n\t\t\tif (!runtime) return errorResult(`No terminal session found with id: ${input.bash_id}`);\n\n\t\t\tconst monitorEntry = ctx.monitorRegistry?.snapshot().find((entry) => entry.id === input.bash_id);\n\t\t\tconst muted = monitorEntry?.paused === true;\n\t\t\tconst mutedDropped = muted ? (ctx.monitorRegistry?.mutedDropped(input.bash_id) ?? 0) : 0;\n\t\t\tlet mutedNote = \"\";\n\t\t\tif (muted) {\n\t\t\t\tmutedNote =\n\t\t\t\t\tmutedDropped > 0\n\t\t\t\t\t\t? `monitor muted — ${mutedDropped} line(s) dropped while muted; run monitor({ action: \"rearm\", bash_id: \"${input.bash_id}\" }) to resume.`\n\t\t\t\t\t\t: `monitor muted; run monitor({ action: \"rearm\", bash_id: \"${input.bash_id}\" }) to resume.`;\n\t\t\t}\n\t\t\tconst extra = monitorEntry ? { details: { monitorMuted: muted, mutedDropped } } : undefined;\n\t\t\tconst prefix = mutedNote.length > 0 ? `${mutedNote}\\n` : \"\";\n\n\t\t\tif (input.view === \"screen\") {\n\t\t\t\treturn textResult(`${prefix}${statusLine(runtime)}\\n${screenView(runtime)}`, extra);\n\t\t\t}\n\n\t\t\tconst delta = runtime.readDelta();\n\t\t\tconst formatted = formatTerminalToolOutput(applyFilter(delta.text, input.filter));\n\t\t\tconst dropped = delta.droppedChars > 0 ? `[${delta.droppedChars} earlier chars dropped]\\n` : \"\";\n\t\t\treturn textResult(`${prefix}${statusLine(runtime)}\\n${dropped}${formatted.text || \"(no new output)\"}`, extra);\n\t\t},\n\t\trenderCall: renderBashOutputCall,\n\t\trenderResult: renderBashOutputResult,\n\t};\n}\n"]}
|
|
@@ -29,6 +29,8 @@ export interface TerminalToolContext {
|
|
|
29
29
|
readonly onMonitorEvent?: (event: MonitorEvent) => void;
|
|
30
30
|
/** Resets session-global wake-budget delivery for a fresh or explicitly rearmed monitor. */
|
|
31
31
|
readonly onMonitorRearmed?: (id: string) => void;
|
|
32
|
+
/** Clears notifier bookkeeping when multiple paused monitors are resumed. */
|
|
33
|
+
readonly onMonitorsResumed?: (ids: readonly string[]) => void;
|
|
32
34
|
}
|
|
33
35
|
/** Minimal tool-result shape returned by the terminal tools. */
|
|
34
36
|
export interface TerminalToolResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,iEAAiE;AACjE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8FAA8F;IAC9F,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,sFAAsF;IACtF,QAAQ,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AgB,UAAU,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,kBAAkB,CAEpB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAE5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/context.ts"],"names":[],"mappings":"AA2CA,MAAM,UAAU,UAAU,CACzB,IAAY,EACZ,KAAgE;IAEhE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC","sourcesContent":["import type { TerminalManager } from \"../manager.ts\";\nimport type { MonitorEvent, MonitorRegistry } from \"../monitor-registry.ts\";\nimport type { TerminalRuntimeSession } from \"../runtime-session.ts\";\nimport type { TimeoutAction } from \"../settings.ts\";\n\n/** Shared dependencies handed to every terminal tool factory. */\nexport interface TerminalToolContext {\n\treadonly manager: TerminalManager;\n\treadonly cwd: string;\n\t/** Explicit shell path from settings (settings-manager `shellPath`), if any. */\n\treadonly shellPath?: string;\n\treadonly defaultCols: number;\n\treadonly defaultRows: number;\n\t/** Configured foreground deadline behavior; omitted direct contexts default to background. */\n\treadonly timeoutAction?: TimeoutAction;\n\t/** Resolve the environment for spawned sessions (mirrors core bash `getShellEnv`). */\n\treadonly getEnv: () => NodeJS.ProcessEnv;\n\t/**\n\t * Current extension session context (set on session_start/model_select), used to\n\t * expose PI_* session metadata to spawned commands like the core bash tool does.\n\t */\n\treadonly getSessionContext?: () => import(\"../../../types.ts\").ExtensionContext | undefined;\n\t/** Registers a session when it transitions to background liveness. */\n\treadonly onBackgroundStart?: (id: string, description: string, startedAtMs: number) => void;\n\t/** Notified when a background session exits, so the notify layer can wake the agent. */\n\treadonly onBackgroundExit?: (id: string, runtime: TerminalRuntimeSession) => void;\n\t/** Session-scoped monitor state, sharing the terminal manager's bash-id namespace. */\n\treadonly monitorRegistry?: MonitorRegistry;\n\t/** Receives filtered monitor line and terminal-summary events. */\n\treadonly onMonitorEvent?: (event: MonitorEvent) => void;\n\t/** Resets session-global wake-budget delivery for a fresh or explicitly rearmed monitor. */\n\treadonly onMonitorRearmed?: (id: string) => void;\n\t/** Clears notifier bookkeeping when multiple paused monitors are resumed. */\n\treadonly onMonitorsResumed?: (ids: readonly string[]) => void;\n}\n\n/** Minimal tool-result shape returned by the terminal tools. */\nexport interface TerminalToolResult {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: Record<string, unknown> | undefined;\n\tisError?: boolean;\n}\n\nexport function textResult(\n\ttext: string,\n\textra?: { details?: Record<string, unknown>; isError?: boolean },\n): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: extra?.details, isError: extra?.isError };\n}\n\nexport function errorResult(text: string): TerminalToolResult {\n\treturn { content: [{ type: \"text\", text }], details: undefined, isError: true };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAAe,KAAK,mBAAmB,EAAE,KAAK,kBAAkB,EAAc,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;EA+CxB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AA+DxD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;yBAwB1C,MAAM,SACZ,YAAY,YACT,WAAW,cACT,SAAS,YACX;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,kBAAkB,CAAC;EA4D/B"}
|
|
@@ -24,10 +24,15 @@ export const monitorSchema = Type.Object({
|
|
|
24
24
|
description: "Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.",
|
|
25
25
|
})),
|
|
26
26
|
command: Type.Optional(Type.String({
|
|
27
|
-
description: "Create (
|
|
27
|
+
description: "Create, command branch (XOR path): shell command to run and watch in a PTY-backed monitor session.",
|
|
28
|
+
})),
|
|
29
|
+
path: Type.Optional(Type.String({
|
|
30
|
+
minLength: 1,
|
|
31
|
+
description: "Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter and no persistent.",
|
|
32
|
+
})),
|
|
33
|
+
event: Type.Optional(StringEnum(["create", "modify"], {
|
|
34
|
+
description: "File branch only: which file event fires the watch (defaults to create).",
|
|
28
35
|
})),
|
|
29
|
-
path: Type.Optional(Type.String({ minLength: 1, description: "File path to watch for a native event." })),
|
|
30
|
-
event: Type.Optional(StringEnum(["create", "modify"], { description: "Native file event (defaults to create)." })),
|
|
31
36
|
filter: Type.Optional(Type.String({ description: "Only PTY output lines matching this regex become monitor events." })),
|
|
32
37
|
timeout_ms: Type.Optional(Type.Number({
|
|
33
38
|
minimum: 1,
|
|
@@ -35,7 +40,7 @@ export const monitorSchema = Type.Object({
|
|
|
35
40
|
description: "Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).",
|
|
36
41
|
})),
|
|
37
42
|
persistent: Type.Optional(Type.Boolean({ description: "Keep watching until the command exits or kill_bash stops its bash_id." })),
|
|
38
|
-
bash_id: Type.Optional(Type.String({ description: "Rearm
|
|
43
|
+
bash_id: Type.Optional(Type.String({ description: "Rearm: paused monitor bash_id to resume; omit to resume all paused monitors." })),
|
|
39
44
|
});
|
|
40
45
|
function isFileCreateInput(input) {
|
|
41
46
|
return (typeof input.description === "string" &&
|
|
@@ -95,10 +100,11 @@ export function createMonitorTool(ctx) {
|
|
|
95
100
|
return {
|
|
96
101
|
name: TERMINAL_MONITOR_TOOL,
|
|
97
102
|
label: "monitor",
|
|
98
|
-
description: "Subscribe to a
|
|
99
|
-
promptSnippet: "Subscribe to a command's
|
|
103
|
+
description: "Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session, where newline-terminated output lines (stderr merged) that match filter arrive as injected events while you keep working and command exit always delivers a summary event; path natively watches one file and fires once: create (the default) fires only when the file appears after registration, so watch a file that already exists with event modify. The path branch takes no filter and no persistent. Identical consecutive line-only update batches are deduped, so a watcher reprinting unchanged status does not re-wake the session. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.",
|
|
104
|
+
promptSnippet: "Subscribe to a command's output or a file's create/modify event as injected events instead of polling",
|
|
100
105
|
promptGuidelines: [
|
|
101
|
-
"Waiting on observable state (CI checks, builds, log patterns, deploys) means a monitor, never a foreground sleep/poll loop.",
|
|
106
|
+
"Waiting on observable state (CI checks, builds, log patterns, deploys, a file landing) means a monitor, never a foreground sleep/poll loop.",
|
|
107
|
+
'Waiting for one file to appear or change is the path branch: `monitor({ description, path, event? })` beats wrapping `test -f` in a shell poll loop; a file that already exists needs `event: "modify"`, since `create` only fires on appearance, and registration needs the parent directory to exist already — when the run creates that directory too, use the `command` branch instead.',
|
|
102
108
|
"Shape the command for the events you need: one-shot gate = `until <cond>; do sleep 1; done; printf 'READY\\n'` with filter ^READY$; stream = `tail -n 0 -F <log> | grep --line-buffered <pat>` with persistent: true, then kill_bash.",
|
|
103
109
|
"Sleep loops belong INSIDE the monitor command, never in your turn: about to sleep, re-poll bash_output, or foreground-block on a long command means register a monitor and keep working.",
|
|
104
110
|
],
|
|
@@ -108,15 +114,26 @@ export function createMonitorTool(ctx) {
|
|
|
108
114
|
const registry = getRegistry();
|
|
109
115
|
if (input.action === "rearm") {
|
|
110
116
|
const bashId = input.bash_id;
|
|
111
|
-
if (bashId === undefined || bashId.length === 0)
|
|
112
|
-
|
|
117
|
+
if (bashId === undefined || bashId.length === 0) {
|
|
118
|
+
const resumed = registry.resume();
|
|
119
|
+
if (resumed.length === 0)
|
|
120
|
+
return textResult("No paused monitors to re-arm.");
|
|
121
|
+
ctx.onMonitorsResumed?.(resumed.map((monitor) => monitor.id));
|
|
122
|
+
const total = resumed.reduce((sum, monitor) => sum + monitor.mutedDropped, 0);
|
|
123
|
+
return textResult(total > 0
|
|
124
|
+
? `Re-armed ${resumed.length} paused monitor(s) (${total} line(s) dropped while muted).`
|
|
125
|
+
: `Re-armed ${resumed.length} paused monitor(s).`);
|
|
126
|
+
}
|
|
127
|
+
const dropped = registry.mutedDropped(bashId);
|
|
113
128
|
const outcome = registry.rearm(bashId);
|
|
114
129
|
if (outcome === "not_found")
|
|
115
130
|
return errorResult(`No active monitor found with id: ${bashId}`);
|
|
116
131
|
if (outcome === "not_paused")
|
|
117
132
|
return textResult(`Monitor ${bashId} is not paused; no action taken.`);
|
|
118
133
|
ctx.onMonitorRearmed?.(bashId);
|
|
119
|
-
return textResult(
|
|
134
|
+
return textResult(dropped > 0
|
|
135
|
+
? `Monitor ${bashId} re-armed (${dropped} line(s) dropped while muted).`
|
|
136
|
+
: `Monitor ${bashId} re-armed.`);
|
|
120
137
|
}
|
|
121
138
|
const fileInput = isFileCreateInput(input);
|
|
122
139
|
const commandInput = isCreateInput(input);
|