@caupulican/pi-adaptative 0.85.0 → 0.85.4
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 +54 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/arithmetic.py +364 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +2 -1
- package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +16 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +137 -14
- package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +23 -2
- package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +134 -6
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +25 -2
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -5
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +84 -87
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js +3 -0
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +2 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +4 -3
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +4 -0
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +2 -0
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +12 -7
- package/dist/core/background-tool-task-controller.d.ts.map +1 -1
- package/dist/core/background-tool-task-controller.js +55 -19
- package/dist/core/background-tool-task-controller.js.map +1 -1
- package/dist/core/bedrock-scope.d.ts +26 -0
- package/dist/core/bedrock-scope.d.ts.map +1 -0
- package/dist/core/bedrock-scope.js +178 -0
- package/dist/core/bedrock-scope.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +2 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +35 -13
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +6 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +26 -1
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +17 -0
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +25 -2
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +111 -2
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.d.ts +27 -0
- package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -0
- package/dist/core/foreground-terminal-handoff-controller.js +56 -0
- package/dist/core/foreground-terminal-handoff-controller.js.map +1 -0
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +5 -0
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts +3 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +28 -7
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/human-input-controller.d.ts +9 -0
- package/dist/core/human-input-controller.d.ts.map +1 -1
- package/dist/core/human-input-controller.js +60 -5
- package/dist/core/human-input-controller.js.map +1 -1
- package/dist/core/human-input.d.ts +12 -0
- package/dist/core/human-input.d.ts.map +1 -1
- package/dist/core/human-input.js +59 -12
- package/dist/core/human-input.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +15 -9
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +1 -0
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +252 -125
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/model-capability.d.ts +15 -1
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +24 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +18 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +6 -6
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +5 -5
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +3 -2
- package/dist/core/model-tool-protocol.d.ts.map +1 -1
- package/dist/core/model-tool-protocol.js +5 -1
- package/dist/core/model-tool-protocol.js.map +1 -1
- package/dist/core/models/context-sizing.d.ts +1 -0
- package/dist/core/models/context-sizing.d.ts.map +1 -1
- package/dist/core/models/context-sizing.js +4 -1
- package/dist/core/models/context-sizing.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js +20 -10
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +32 -11
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
- package/dist/core/models/llamacpp-runtime.js +79 -28
- package/dist/core/models/llamacpp-runtime.js.map +1 -1
- package/dist/core/models/local-execution-planner.d.ts +24 -0
- package/dist/core/models/local-execution-planner.d.ts.map +1 -0
- package/dist/core/models/local-execution-planner.js +119 -0
- package/dist/core/models/local-execution-planner.js.map +1 -0
- package/dist/core/models/local-inference-profile.d.ts +34 -0
- package/dist/core/models/local-inference-profile.d.ts.map +1 -0
- package/dist/core/models/local-inference-profile.js +74 -0
- package/dist/core/models/local-inference-profile.js.map +1 -0
- package/dist/core/models/local-runtime.d.ts +23 -4
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +11 -8
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/managed-ollama-model.d.ts +26 -0
- package/dist/core/models/managed-ollama-model.d.ts.map +1 -0
- package/dist/core/models/managed-ollama-model.js +59 -0
- package/dist/core/models/managed-ollama-model.js.map +1 -0
- package/dist/core/models/model-ref.js +11 -11
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts +10 -20
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.js +11 -31
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
- package/dist/core/models/prism-llamacpp-server-probe.d.ts +10 -0
- package/dist/core/models/prism-llamacpp-server-probe.d.ts.map +1 -0
- package/dist/core/models/prism-llamacpp-server-probe.js +36 -0
- package/dist/core/models/prism-llamacpp-server-probe.js.map +1 -0
- package/dist/core/models/runtime-arbiter.d.ts +3 -0
- package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
- package/dist/core/models/runtime-arbiter.js +2 -1
- package/dist/core/models/runtime-arbiter.js.map +1 -1
- package/dist/core/models/runtime-process.d.ts +7 -1
- package/dist/core/models/runtime-process.d.ts.map +1 -1
- package/dist/core/models/runtime-process.js +4 -2
- package/dist/core/models/runtime-process.js.map +1 -1
- package/dist/core/process-matrix/runtime.js +43 -11
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts.map +1 -1
- package/dist/core/research/research-lane-controller.js +14 -5
- package/dist/core/research/research-lane-controller.js.map +1 -1
- package/dist/core/resource-loader.d.ts +2 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +18 -6
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +5 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +37 -4
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +3 -2
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +1 -0
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +10 -8
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +13 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +59 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +5 -2
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +22 -10
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +181 -55
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts.map +1 -1
- package/dist/core/tool-protocol-controller.js +5 -3
- package/dist/core/tool-protocol-controller.js.map +1 -1
- package/dist/core/tool-recovery-log-records.d.ts +33 -1
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +59 -12
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-logger.d.ts +12 -1
- package/dist/core/tool-recovery-logger.d.ts.map +1 -1
- package/dist/core/tool-recovery-logger.js +24 -1
- package/dist/core/tool-recovery-logger.js.map +1 -1
- package/dist/core/tool-repair-health.d.ts.map +1 -1
- package/dist/core/tool-repair-health.js +6 -0
- package/dist/core/tool-repair-health.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -2
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +2 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +9 -1
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +5 -8
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +88 -55
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-intent.d.ts +42 -15
- package/dist/core/tools/file-mutation-intent.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-intent.js +271 -77
- package/dist/core/tools/file-mutation-intent.js.map +1 -1
- package/dist/core/tools/find.d.ts +2 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +2 -6
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +2 -6
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/managed-search-tool.d.ts +8 -0
- package/dist/core/tools/managed-search-tool.d.ts.map +1 -0
- package/dist/core/tools/managed-search-tool.js +10 -0
- package/dist/core/tools/managed-search-tool.js.map +1 -0
- package/dist/core/tools/shell-command-parser.d.ts +4 -3
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
- package/dist/core/tools/shell-command-parser.js +32 -7
- package/dist/core/tools/shell-command-parser.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +23 -1
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +1 -1
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/tools/write.d.ts +5 -10
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +92 -73
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +6 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +59 -12
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +51 -8
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/utils/paths.js +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +18 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +73 -43
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/models.md +1 -1
- package/docs/providers.md +34 -10
- package/docs/settings.md +1 -1
- package/docs/tool-boundary-performance-roadmap-2026-08-02.md +21 -18
- package/docs/tool-repair.md +3 -3
- package/docs/windows.md +7 -5
- package/examples/extensions/built-in-tool-renderer.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/minimal-mode.ts +1 -1
- package/examples/extensions/prompt-customizer.ts +2 -2
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/ssh.ts +17 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +240 -260
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-shell-engine.js","sourceR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ine sessions.\n *\n * One coordinator process is keyed to each agent session. Requests are serialized as JSON lines;\n * Node remains the sole owner of cwd/environment state and derives each request only after the\n * preceding terminal frame has been applied. Command bytes stream on stdout, followed by a\n * request-specific output barrier. A correlated control frame arrives on stderr. Requiring both\n * channels before settlement prevents cross-pipe tail loss and stale-frame reuse.\n *\n * Timeout, abort, protocol failure, or coordinator death resets the whole process tree. The next\n * request starts a clean coordinator from the last state Node actually acknowledged.\n */\n\nimport type { ChildProcess, SpawnOptions } from \"node:child_process\";\nimport { randomBytes } from \"node:crypto\";\nimport { dirname, join } from \"node:path\";\nimport { getBundledResourcesDir } from \"../../config.ts\";\nimport { spawnProcess } from \"../../utils/child-process.ts\";\nimport { getShellConfig, getShellEnv } from \"../../utils/shell.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"../python-runtime.ts\";\nimport { isRecordObject } from \"../util/value-guards.ts\";\nimport type { BashOperations } from \"./bash.ts\";\nimport { PersistentProcessCoordinator } from \"./persistent-process-coordinator.ts\";\nimport { tokenizeShellCommand } from \"./shell-command-parser.ts\";\nimport {\n\tapplyEngineFrame,\n\tgetOrCreateWindowsShellState,\n\tmergeEffectiveEnv,\n\tresolveEffectiveCwd,\n\ttype WindowsShellState,\n} from \"./windows-shell-state.ts\";\n\nconst ENGINE_FRAME_SENTINEL = 0x1e;\nconst MAX_CONTROL_FRAME_BYTES = 64 * 1024;\nconst SOFT_DEADLINE_HEADSTART_MS = 100;\n\n/** State/result fields returned for every completed engine command. */\nexport interface WindowsShellEngineFrame {\n\texitCode: number;\n\tcwd: string;\n\tenvDelta: Record<string, string | null>;\n\tunsupported: { code: \"unsupported\"; construct: string; message: string } | null;\n}\n\ninterface WindowsShellEngineControlFrame extends WindowsShellEngineFrame {\n\trequestId: string;\n}\n\ninterface WindowsShellEngineRequest {\n\trequestId: string;\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n\tpowershellPath?: string;\n\ttimeoutMs?: number;\n}\n\ninterface ParsedControlFrame {\n\tkind: \"frame\";\n\tframe: WindowsShellEngineControlFrame;\n\tframeStart: number;\n\tframeEnd: number;\n}\n\ninterface InvalidControlFrame {\n\tkind: \"invalid\";\n}\n\ninterface ActiveEngineExec {\n\tonStdout(data: Buffer): void;\n\tonStderr(data: Buffer): void;\n\tonChildClose(code: number | null): void;\n\tfail(error: Error): void;\n}\n\nexport class WindowsShellEngineFailure extends Error {\n\treadonly capturedOutput: string;\n\n\tconstructor(message: string, capturedOutput: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WindowsShellEngineFailure\";\n\t\tthis.capturedOutput = capturedOutput;\n\t}\n}\n\nfunction resolveEngineScriptPath(): string {\n\treturn join(getBundledResourcesDir(), \"runtimes\", \"pi-shell-engine\", \"main.py\");\n}\n\nfunction invokesPowerShellScript(command: string): boolean {\n\tconst tokens = tokenizeShellCommand(command);\n\t// An unparseable command is already heading to the authoritative Python parser;\n\t// resolve conservatively so script adaptation cannot lose an explicit host choice.\n\tif (!tokens) return /\\.ps1\\b/iu.test(command);\n\n\tlet atCommandStart = true;\n\tlet skipRedirectTarget = false;\n\tfor (const token of tokens) {\n\t\tif (token.kind === \"operator\" || token.kind === \"pipe\") {\n\t\t\tatCommandStart = true;\n\t\t\tskipRedirectTarget = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (token.kind === \"redirect\") {\n\t\t\tskipRedirectTarget = !/^\\d*[<>]&[\\d-]+$/u.test(token.value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (skipRedirectTarget) {\n\t\t\tskipRedirectTarget = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!atCommandStart || /^[A-Za-z_][A-Za-z0-9_]*=/u.test(token.value)) continue;\n\t\tif (token.value.toLowerCase().endsWith(\".ps1\")) return true;\n\t\tatCommandStart = false;\n\t}\n\treturn false;\n}\n\nfunction parseControlFrame(buffer: Buffer): ParsedControlFrame | InvalidControlFrame | undefined {\n\tconst frameStart = buffer.indexOf(ENGINE_FRAME_SENTINEL);\n\tif (frameStart === -1) return undefined;\n\tconst closeIndex = buffer.indexOf(ENGINE_FRAME_SENTINEL, frameStart + 1);\n\tif (closeIndex === -1) return undefined;\n\ttry {\n\t\tconst raw: unknown = JSON.parse(buffer.subarray(frameStart + 1, closeIndex).toString(\"utf8\"));\n\t\tif (\n\t\t\tisRecordObject(raw) &&\n\t\t\ttypeof raw.requestId === \"string\" &&\n\t\t\t/^[0-9a-f]{16}$/u.test(raw.requestId) &&\n\t\t\ttypeof raw.exitCode === \"number\" &&\n\t\t\tNumber.isInteger(raw.exitCode) &&\n\t\t\ttypeof raw.cwd === \"string\" &&\n\t\t\tisRecordObject(raw.envDelta) &&\n\t\t\t(raw.unsupported === null || isRecordObject(raw.unsupported)) &&\n\t\t\t(raw.unsupported === null ||\n\t\t\t\t(raw.unsupported.code === \"unsupported\" &&\n\t\t\t\t\ttypeof raw.unsupported.construct === \"string\" &&\n\t\t\t\t\ttypeof raw.unsupported.message === \"string\")) &&\n\t\t\tObject.values(raw.envDelta).every((value) => value === null || typeof value === \"string\")\n\t\t) {\n\t\t\treturn {\n\t\t\t\tkind: \"frame\",\n\t\t\t\tframe: raw as unknown as WindowsShellEngineControlFrame,\n\t\t\t\tframeStart,\n\t\t\t\tframeEnd: closeIndex + 1,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// A complete delimited record that is not JSON is a terminal protocol fault.\n\t}\n\treturn { kind: \"invalid\" };\n}\n\nexport interface WindowsShellEngineOptions {\n\t/** Override for tests: resolves the Python runtime outcome. Default: `ensurePythonRuntime`. */\n\tresolveRuntime?: () => Promise<PythonRuntimeOutcome>;\n\t/** Override for tests: absolute path to the engine's `main.py`. Default: the bundled runtime. */\n\tengineScriptPath?: string;\n\t/** Override for tests: the per-session state store lookup. Default: the shared module store. */\n\tgetState?: (sessionKey: string) => WindowsShellState;\n\t/** Override for tests: spawns the persistent coordinator. Default: `spawnProcess`. */\n\tspawn?: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\t/** Override for tests: selected PowerShell host used to adapt `.ps1` external commands. */\n\tresolvePowerShellPath?: () => string;\n}\n\nfunction degradationError(\n\toutcome: Extract<PythonRuntimeOutcome, { status: \"offline\" | \"uv-unavailable\" | \"python-unavailable\" }>,\n): Error {\n\treturn new Error(\n\t\t`The Windows shell engine (Python) is unavailable: ${outcome.reason} The simple-command PowerShell floor still works; fix the Python runtime (uv/network) to restore pipelines, redirection, expansion, and chaining.`,\n\t);\n}\n\nclass PersistentWindowsShellEngineSession {\n\tprivate readonly key: string;\n\tprivate readonly resolveRuntime: () => Promise<PythonRuntimeOutcome>;\n\tprivate readonly engineScriptPath: string;\n\tprivate readonly getState: (sessionKey: string) => WindowsShellState;\n\tprivate readonly spawn: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\tprivate readonly resolvePowerShellPath: () => string;\n\tprivate readonly coordinator = new PersistentProcessCoordinator();\n\tprivate activeExec: ActiveEngineExec | null = null;\n\tprivate disposed = false;\n\n\tconstructor(key: string, options: WindowsShellEngineOptions) {\n\t\tthis.key = key;\n\t\tthis.resolveRuntime = options.resolveRuntime ?? (() => ensurePythonRuntime({ silent: true }));\n\t\tthis.engineScriptPath = options.engineScriptPath ?? resolveEngineScriptPath();\n\t\tthis.getState = options.getState ?? getOrCreateWindowsShellState;\n\t\tthis.spawn = options.spawn ?? spawnProcess;\n\t\tthis.resolvePowerShellPath =\n\t\t\toptions.resolvePowerShellPath ??\n\t\t\t(() => (process.platform === \"win32\" ? getShellConfig(undefined, \"powershell\").shell : \"powershell\"));\n\t}\n\n\texec(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: Parameters<BashOperations[\"exec\"]>[2],\n\t): Promise<{ exitCode: number | null }> {\n\t\treturn this.coordinator.runSerialized(() => this.execNow(command, cwd, options));\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tconst active = this.activeExec;\n\t\tthis.coordinator.dispose();\n\t\tactive?.fail(new Error(`Windows shell engine session \"${this.key}\" is disposed`));\n\t}\n\n\tprivate async execNow(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\t{ onData, signal, timeout, env }: Parameters<BashOperations[\"exec\"]>[2],\n\t): Promise<{ exitCode: number | null }> {\n\t\tif (this.disposed) throw new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\n\t\tconst state = this.getState(this.key);\n\t\tconst effectiveCwd = resolveEffectiveCwd(state, cwd);\n\t\tconst effectiveEnv = mergeEffectiveEnv(state, env ?? getShellEnv());\n\t\tconst child = await this.ensureChild(effectiveEnv);\n\t\tif (this.disposed) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\t\t}\n\t\tif (signal?.aborted) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(\"aborted\");\n\t\t}\n\t\tif (!child.stdin || !child.stdout || !child.stderr || child !== this.coordinator.child) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(\"Failed to start Windows shell engine coordinator\");\n\t\t}\n\n\t\tconst timeoutMs = timeout !== undefined && timeout > 0 ? timeout * 1000 : undefined;\n\t\tconst requestTimeoutMs =\n\t\t\ttimeoutMs !== undefined ? Math.max(timeoutMs - SOFT_DEADLINE_HEADSTART_MS, 1) : undefined;\n\t\tconst requestId = randomBytes(8).toString(\"hex\");\n\t\tconst request: WindowsShellEngineRequest = {\n\t\t\trequestId,\n\t\t\tcommand,\n\t\t\tcwd: effectiveCwd,\n\t\t\tenv: effectiveEnv,\n\t\t\t...(invokesPowerShellScript(command) ? { powershellPath: this.resolvePowerShellPath() } : {}),\n\t\t\t...(requestTimeoutMs !== undefined ? { timeoutMs: requestTimeoutMs } : {}),\n\t\t};\n\t\tconst outputBarrier = Buffer.from(`\\x1e${requestId}\\x1e`, \"latin1\");\n\n\t\tthis.coordinator.setLoopRef(true);\n\t\ttry {\n\t\t\treturn await new Promise<{ exitCode: number | null }>((resolve, reject) => {\n\t\t\t\tlet settled = false;\n\t\t\t\tlet pendingOutput: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n\t\t\t\tlet controlBuffer: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n\t\t\t\tlet controlOverflow = false;\n\t\t\t\tlet sawOutputBarrier = false;\n\t\t\t\tlet controlFrame: WindowsShellEngineControlFrame | undefined;\n\t\t\t\tlet completionScheduled = false;\n\t\t\t\tlet timeoutTimer: NodeJS.Timeout | undefined;\n\n\t\t\t\tconst settle = (finish: () => void): void => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tif (this.activeExec === active) this.activeExec = null;\n\t\t\t\t\tfinish();\n\t\t\t\t};\n\n\t\t\t\tconst emitPending = (upTo: number): void => {\n\t\t\t\t\tif (upTo <= 0) return;\n\t\t\t\t\tonData(pendingOutput.subarray(0, upTo));\n\t\t\t\t\tpendingOutput = pendingOutput.subarray(upTo);\n\t\t\t\t};\n\n\t\t\t\tconst capturedControl = (): string =>\n\t\t\t\t\tcontrolOverflow\n\t\t\t\t\t\t? `control frame exceeded ${MAX_CONTROL_FRAME_BYTES} bytes`\n\t\t\t\t\t\t: controlBuffer.toString(\"utf8\");\n\n\t\t\t\tconst failAndReset = (error: Error): void => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\temitPending(pendingOutput.length);\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tsettle(() => reject(error));\n\t\t\t\t};\n\n\t\t\t\tconst protocolFailure = (message: string): WindowsShellEngineFailure => {\n\t\t\t\t\tconst capturedOutput = capturedControl();\n\t\t\t\t\treturn new WindowsShellEngineFailure(`${message}\\n${capturedOutput}`, capturedOutput);\n\t\t\t\t};\n\n\t\t\t\tconst maybeComplete = (): void => {\n\t\t\t\t\tif (!sawOutputBarrier || !controlFrame || settled || completionScheduled) return;\n\t\t\t\t\tcompletionScheduled = true;\n\t\t\t\t\t// stdout and stderr are independent pipes. Keep this request active through the\n\t\t\t\t\t// next check phase so already-delivered post-barrier bytes are rejected here,\n\t\t\t\t\t// never forwarded into a queued request that starts in a promise microtask.\n\t\t\t\t\tsetImmediate(() => {\n\t\t\t\t\t\tif (settled || this.activeExec !== active || !controlFrame) return;\n\t\t\t\t\t\tapplyEngineFrame(state, controlFrame);\n\t\t\t\t\t\tif (controlFrame.unsupported) {\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\treject(new Error(controlFrame?.unsupported?.message ?? \"Unsupported shell construct\")),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsettle(() => resolve({ exitCode: controlFrame?.exitCode ?? null }));\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tconst onAbort = (): void => failAndReset(new Error(\"aborted\"));\n\n\t\t\t\tconst active: ActiveEngineExec = {\n\t\t\t\t\tonStdout: (data) => {\n\t\t\t\t\t\tif (sawOutputBarrier) {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted output after its terminal barrier.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpendingOutput = pendingOutput.length === 0 ? data : Buffer.concat([pendingOutput, data]);\n\t\t\t\t\t\tconst barrierIndex = pendingOutput.indexOf(outputBarrier);\n\t\t\t\t\t\tif (barrierIndex !== -1) {\n\t\t\t\t\t\t\temitPending(barrierIndex);\n\t\t\t\t\t\t\tpendingOutput = pendingOutput.subarray(outputBarrier.length);\n\t\t\t\t\t\t\tif (pendingOutput.length > 0) {\n\t\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted bytes after its terminal barrier.\"));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsawOutputBarrier = true;\n\t\t\t\t\t\t\tmaybeComplete();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\temitPending(pendingOutput.length - (outputBarrier.length - 1));\n\t\t\t\t\t},\n\t\t\t\t\tonStderr: (data) => {\n\t\t\t\t\t\tif (controlOverflow) return;\n\t\t\t\t\t\tif (controlBuffer.length + data.length > MAX_CONTROL_FRAME_BYTES) {\n\t\t\t\t\t\t\tcontrolOverflow = true;\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine control frame overflowed.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrolBuffer = controlBuffer.length === 0 ? data : Buffer.concat([controlBuffer, data]);\n\t\t\t\t\t\tconst parsed = parseControlFrame(controlBuffer);\n\t\t\t\t\t\tif (!parsed) return;\n\t\t\t\t\t\tif (parsed.kind === \"invalid\") {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine returned a malformed control frame.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parsed.frame.requestId !== requestId) {\n\t\t\t\t\t\t\tfailAndReset(\n\t\t\t\t\t\t\t\tprotocolFailure(\n\t\t\t\t\t\t\t\t\t`Windows shell engine returned stale control frame ${parsed.frame.requestId}; expected ${requestId}.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (controlBuffer.subarray(parsed.frameEnd).toString(\"utf8\").trim().length > 0) {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted trailing control bytes.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrolFrame = parsed.frame;\n\t\t\t\t\t\tmaybeComplete();\n\t\t\t\t\t},\n\t\t\t\t\tonChildClose: (code) => {\n\t\t\t\t\t\tconst capturedOutput = capturedControl();\n\t\t\t\t\t\temitPending(pendingOutput.length);\n\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew WindowsShellEngineFailure(\n\t\t\t\t\t\t\t\t\t`Windows shell engine coordinator exited (${code ?? \"null\"}) before a complete terminal handoff.\\n${capturedOutput}`,\n\t\t\t\t\t\t\t\t\tcapturedOutput,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tfail: (error) => failAndReset(error),\n\t\t\t\t};\n\n\t\t\t\tthis.activeExec = active;\n\t\t\t\tif (signal) signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutTimer = setTimeout(() => failAndReset(new Error(`timeout:${timeout}`)), timeoutMs);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tchild.stdin?.write(`${JSON.stringify(request)}\\n`, \"utf8\", (error) => {\n\t\t\t\t\t\tif (!error) return;\n\t\t\t\t\t\tfailAndReset(new Error(`Failed to write to Windows shell engine coordinator: ${error.message}`));\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tfailAndReset(new Error(`Failed to write to Windows shell engine coordinator: ${message}`));\n\t\t\t\t}\n\t\t\t});\n\t\t} finally {\n\t\t\tthis.coordinator.setLoopRef(false);\n\t\t}\n\t}\n\n\tprivate async ensureChild(env: NodeJS.ProcessEnv): Promise<ChildProcess> {\n\t\tif (this.coordinator.child) return this.coordinator.child;\n\t\tconst runtime = await this.resolveRuntime();\n\t\tif (runtime.status !== \"ready\") throw degradationError(runtime);\n\t\tif (this.disposed) throw new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\n\t\tconst child = this.spawn(runtime.pythonPath, [\"-B\", this.engineScriptPath, \"--server\"], {\n\t\t\tcwd: dirname(this.engineScriptPath),\n\t\t\tenv: {\n\t\t\t\t...env,\n\t\t\t\tPYTHONDONTWRITEBYTECODE: \"1\",\n\t\t\t\tPYTHONIOENCODING: \"utf-8\",\n\t\t\t\tPYTHONUNBUFFERED: \"1\",\n\t\t\t\tPYTHONUTF8: \"1\",\n\t\t\t},\n\t\t\tdetached: process.platform !== \"win32\",\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\twindowsHide: true,\n\t\t});\n\t\tthis.coordinator.attach(child, {\n\t\t\tonStdout: (data) => {\n\t\t\t\tconst active = this.activeExec;\n\t\t\t\tif (active) active.onStdout(data);\n\t\t\t\telse if (data.length > 0) this.killChild();\n\t\t\t},\n\t\t\tonStderr: (data) => {\n\t\t\t\tconst active = this.activeExec;\n\t\t\t\tif (active) active.onStderr(data);\n\t\t\t\telse if (data.length > 0) this.killChild();\n\t\t\t},\n\t\t\tonError: (error) => this.activeExec?.fail(error),\n\t\t\tonClose: (code) => this.activeExec?.onChildClose(code),\n\t\t});\n\t\treturn child;\n\t}\n\n\tprivate killChild(): void {\n\t\tthis.coordinator.kill();\n\t}\n}\n\nconst engineSessions = new Map<string, PersistentWindowsShellEngineSession>();\n\nfunction acquireWindowsShellEngineSession(\n\tkey: string,\n\toptions: WindowsShellEngineOptions,\n): PersistentWindowsShellEngineSession {\n\tconst existing = engineSessions.get(key);\n\tif (existing) return existing;\n\tconst session = new PersistentWindowsShellEngineSession(key, options);\n\tengineSessions.set(key, session);\n\treturn session;\n}\n\n/** Kill and forget a Python coordinator. The next call for this key starts a clean process. */\nexport function disposeWindowsShellEngineSession(key: string): void {\n\tconst session = engineSessions.get(key);\n\tif (!session) return;\n\tengineSessions.delete(key);\n\tsession.dispose();\n}\n\n/** Create the Python-engine tier for one bash-tool session. */\nexport function createWindowsShellEngineOperations(\n\tsessionKey: string,\n\toptions: WindowsShellEngineOptions = {},\n): BashOperations {\n\treturn {\n\t\t// Resolve through the registry for every command. Session teardown (for example after\n\t\t// credential/environment changes) deletes only this tenant's entry; an already-built tool\n\t\t// then lazily acquires a fresh coordinator instead of retaining the disposed instance.\n\t\texec: (command, cwd, execOptions) =>\n\t\t\tacquireWindowsShellEngineSession(sessionKey, options).exec(command, cwd, execOptions),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"windows-shell-engine.js","sourceRoot":"","sources":["../../../src/core/tools/windows-shell-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAA6B,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,gBAAgB,EAChB,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,GAEnB,MAAM,0BAA0B,CAAC;AAElC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC1C,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAyCvC,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAGnD,YAAY,OAAe,EAAE,cAAsB;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACtC,CAAC;CACD;AAED,SAAS,uBAAuB;IAC/B,OAAO,IAAI,C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AAE,GAAG,EAAE,WAAW,EAAE,EAAE,CACnC,gCAAgC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC;KACtF,CAAC;AACH,CAAC","sourcesContent":["/**\n * Persistent Windows Python shell-engine sessions.\n *\n * One coordinator process is keyed to each agent session. Requests are serialized as JSON lines;\n * Node remains the sole owner of cwd/environment state and derives each request only after the\n * preceding terminal frame has been applied. Command bytes stream on stdout, followed by a\n * request-specific output barrier. A correlated control frame arrives on stderr. Requiring both\n * channels before settlement prevents cross-pipe tail loss and stale-frame reuse.\n *\n * Timeout, abort, protocol failure, or coordinator death resets the whole process tree. The next\n * request starts a clean coordinator from the last state Node actually acknowledged.\n */\n\nimport type { ChildProcess, SpawnOptions } from \"node:child_process\";\nimport { randomBytes } from \"node:crypto\";\nimport { dirname, join } from \"node:path\";\nimport { getBundledResourcesDir } from \"../../config.ts\";\nimport { spawnProcess } from \"../../utils/child-process.ts\";\nimport { getShellConfig, getShellEnv } from \"../../utils/shell.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"../python-runtime.ts\";\nimport { isRecordObject } from \"../util/value-guards.ts\";\nimport type { BashOperations } from \"./bash.ts\";\nimport { PersistentProcessCoordinator } from \"./persistent-process-coordinator.ts\";\nimport { tokenizeShellCommand } from \"./shell-command-parser.ts\";\nimport {\n\tapplyEngineFrame,\n\tgetOrCreateWindowsShellState,\n\tmergeEffectiveEnv,\n\tresolveEffectiveCwd,\n\ttype WindowsShellState,\n} from \"./windows-shell-state.ts\";\n\nconst ENGINE_FRAME_SENTINEL = 0x1e;\nconst MAX_CONTROL_FRAME_BYTES = 64 * 1024;\nconst SOFT_DEADLINE_HEADSTART_MS = 100;\n\n/** State/result fields returned for every completed engine command. */\nexport interface WindowsShellEngineFrame {\n\texitCode: number;\n\tcwd: string;\n\tenvDelta: Record<string, string | null>;\n\tunsupported: { code: \"unsupported\"; construct: string; message: string } | null;\n}\n\ninterface WindowsShellEngineControlFrame extends WindowsShellEngineFrame {\n\trequestId: string;\n}\n\ninterface WindowsShellEngineRequest {\n\trequestId: string;\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n\tpowershellPath?: string;\n\ttimeoutMs?: number;\n}\n\ninterface ParsedControlFrame {\n\tkind: \"frame\";\n\tframe: WindowsShellEngineControlFrame;\n\tframeStart: number;\n\tframeEnd: number;\n}\n\ninterface InvalidControlFrame {\n\tkind: \"invalid\";\n}\n\ninterface ActiveEngineExec {\n\tonStdout(data: Buffer): void;\n\tonStderr(data: Buffer): void;\n\tonChildClose(code: number | null): void;\n\tfail(error: Error): void;\n}\n\nexport class WindowsShellEngineFailure extends Error {\n\treadonly capturedOutput: string;\n\n\tconstructor(message: string, capturedOutput: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WindowsShellEngineFailure\";\n\t\tthis.capturedOutput = capturedOutput;\n\t}\n}\n\nfunction resolveEngineScriptPath(): string {\n\treturn join(getBundledResourcesDir(), \"runtimes\", \"pi-shell-engine\", \"main.py\");\n}\n\nfunction invokesPowerShellScript(command: string): boolean {\n\tconst tokens = tokenizeShellCommand(command);\n\t// An unparseable command is already heading to the authoritative Python parser;\n\t// resolve conservatively so script adaptation cannot lose an explicit host choice.\n\tif (!tokens) return /\\.ps1\\b/iu.test(command);\n\n\tlet atCommandStart = true;\n\tlet skipRedirectTarget = false;\n\tfor (const token of tokens) {\n\t\tif (token.kind === \"operator\" || token.kind === \"pipe\") {\n\t\t\tatCommandStart = true;\n\t\t\tskipRedirectTarget = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (token.kind === \"redirect\") {\n\t\t\tskipRedirectTarget = !/^\\d*[<>]&[\\d-]+$/u.test(token.value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (skipRedirectTarget) {\n\t\t\tskipRedirectTarget = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!atCommandStart || /^[A-Za-z_][A-Za-z0-9_]*=/u.test(token.value)) continue;\n\t\tif (token.value.toLowerCase().endsWith(\".ps1\")) return true;\n\t\tatCommandStart = false;\n\t}\n\treturn false;\n}\n\nfunction parseControlFrame(buffer: Buffer): ParsedControlFrame | InvalidControlFrame | undefined {\n\tconst frameStart = buffer.indexOf(ENGINE_FRAME_SENTINEL);\n\tif (frameStart === -1) return undefined;\n\tconst closeIndex = buffer.indexOf(ENGINE_FRAME_SENTINEL, frameStart + 1);\n\tif (closeIndex === -1) return undefined;\n\ttry {\n\t\tconst raw: unknown = JSON.parse(buffer.subarray(frameStart + 1, closeIndex).toString(\"utf8\"));\n\t\tif (\n\t\t\tisRecordObject(raw) &&\n\t\t\ttypeof raw.requestId === \"string\" &&\n\t\t\t/^[0-9a-f]{16}$/u.test(raw.requestId) &&\n\t\t\ttypeof raw.exitCode === \"number\" &&\n\t\t\tNumber.isInteger(raw.exitCode) &&\n\t\t\ttypeof raw.cwd === \"string\" &&\n\t\t\tisRecordObject(raw.envDelta) &&\n\t\t\t(raw.unsupported === null || isRecordObject(raw.unsupported)) &&\n\t\t\t(raw.unsupported === null ||\n\t\t\t\t(raw.unsupported.code === \"unsupported\" &&\n\t\t\t\t\ttypeof raw.unsupported.construct === \"string\" &&\n\t\t\t\t\ttypeof raw.unsupported.message === \"string\")) &&\n\t\t\tObject.values(raw.envDelta).every((value) => value === null || typeof value === \"string\")\n\t\t) {\n\t\t\treturn {\n\t\t\t\tkind: \"frame\",\n\t\t\t\tframe: raw as unknown as WindowsShellEngineControlFrame,\n\t\t\t\tframeStart,\n\t\t\t\tframeEnd: closeIndex + 1,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// A complete delimited record that is not JSON is a terminal protocol fault.\n\t}\n\treturn { kind: \"invalid\" };\n}\n\nexport interface WindowsShellEngineOptions {\n\t/** Override for tests: resolves the Python runtime outcome. Default: `ensurePythonRuntime`. */\n\tresolveRuntime?: () => Promise<PythonRuntimeOutcome>;\n\t/** Override for tests: absolute path to the engine's `main.py`. Default: the bundled runtime. */\n\tengineScriptPath?: string;\n\t/** Override for tests: the per-session state store lookup. Default: the shared module store. */\n\tgetState?: (sessionKey: string) => WindowsShellState;\n\t/** Override for tests: spawns the persistent coordinator. Default: `spawnProcess`. */\n\tspawn?: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\t/** Override for tests: selected PowerShell host used to adapt `.ps1` external commands. */\n\tresolvePowerShellPath?: () => string;\n}\n\nfunction degradationError(\n\toutcome: Extract<PythonRuntimeOutcome, { status: \"offline\" | \"uv-unavailable\" | \"python-unavailable\" }>,\n): Error {\n\treturn new Error(\n\t\t`The Windows shell engine (Python) is unavailable: ${outcome.reason} The simple-command PowerShell floor still works; fix the Python runtime (uv/network) to restore for loops, portable builtins such as printf, pipelines, redirection, expansion, and chaining.`,\n\t);\n}\n\nclass PersistentWindowsShellEngineSession {\n\tprivate readonly key: string;\n\tprivate readonly resolveRuntime: () => Promise<PythonRuntimeOutcome>;\n\tprivate readonly engineScriptPath: string;\n\tprivate readonly getState: (sessionKey: string) => WindowsShellState;\n\tprivate readonly spawn: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\tprivate readonly resolvePowerShellPath: () => string;\n\tprivate readonly coordinator = new PersistentProcessCoordinator();\n\tprivate activeExec: ActiveEngineExec | null = null;\n\tprivate disposed = false;\n\n\tconstructor(key: string, options: WindowsShellEngineOptions) {\n\t\tthis.key = key;\n\t\tthis.resolveRuntime = options.resolveRuntime ?? (() => ensurePythonRuntime({ silent: true }));\n\t\tthis.engineScriptPath = options.engineScriptPath ?? resolveEngineScriptPath();\n\t\tthis.getState = options.getState ?? getOrCreateWindowsShellState;\n\t\tthis.spawn = options.spawn ?? spawnProcess;\n\t\tthis.resolvePowerShellPath =\n\t\t\toptions.resolvePowerShellPath ??\n\t\t\t(() => (process.platform === \"win32\" ? getShellConfig(undefined, \"powershell\").shell : \"powershell\"));\n\t}\n\n\texec(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: Parameters<BashOperations[\"exec\"]>[2],\n\t): Promise<{ exitCode: number | null }> {\n\t\treturn this.coordinator.runSerialized(() => this.execNow(command, cwd, options));\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tconst active = this.activeExec;\n\t\tthis.coordinator.dispose();\n\t\tactive?.fail(new Error(`Windows shell engine session \"${this.key}\" is disposed`));\n\t}\n\n\tprivate async execNow(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\t{ onData, signal, timeout, env }: Parameters<BashOperations[\"exec\"]>[2],\n\t): Promise<{ exitCode: number | null }> {\n\t\tif (this.disposed) throw new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\n\t\tconst state = this.getState(this.key);\n\t\tconst effectiveCwd = resolveEffectiveCwd(state, cwd);\n\t\tconst effectiveEnv = mergeEffectiveEnv(state, env ?? getShellEnv());\n\t\tconst child = await this.ensureChild(effectiveEnv);\n\t\tif (this.disposed) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\t\t}\n\t\tif (signal?.aborted) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(\"aborted\");\n\t\t}\n\t\tif (!child.stdin || !child.stdout || !child.stderr || child !== this.coordinator.child) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(\"Failed to start Windows shell engine coordinator\");\n\t\t}\n\n\t\tconst timeoutMs = timeout !== undefined && timeout > 0 ? timeout * 1000 : undefined;\n\t\tconst requestTimeoutMs =\n\t\t\ttimeoutMs !== undefined ? Math.max(timeoutMs - SOFT_DEADLINE_HEADSTART_MS, 1) : undefined;\n\t\tconst requestId = randomBytes(8).toString(\"hex\");\n\t\tconst request: WindowsShellEngineRequest = {\n\t\t\trequestId,\n\t\t\tcommand,\n\t\t\tcwd: effectiveCwd,\n\t\t\tenv: effectiveEnv,\n\t\t\t...(invokesPowerShellScript(command) ? { powershellPath: this.resolvePowerShellPath() } : {}),\n\t\t\t...(requestTimeoutMs !== undefined ? { timeoutMs: requestTimeoutMs } : {}),\n\t\t};\n\t\tconst outputBarrier = Buffer.from(`\\x1e${requestId}\\x1e`, \"latin1\");\n\n\t\tthis.coordinator.setLoopRef(true);\n\t\ttry {\n\t\t\treturn await new Promise<{ exitCode: number | null }>((resolve, reject) => {\n\t\t\t\tlet settled = false;\n\t\t\t\tlet pendingOutput: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n\t\t\t\tlet controlBuffer: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n\t\t\t\tlet controlOverflow = false;\n\t\t\t\tlet sawOutputBarrier = false;\n\t\t\t\tlet controlFrame: WindowsShellEngineControlFrame | undefined;\n\t\t\t\tlet completionScheduled = false;\n\t\t\t\tlet timeoutTimer: NodeJS.Timeout | undefined;\n\n\t\t\t\tconst settle = (finish: () => void): void => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tif (this.activeExec === active) this.activeExec = null;\n\t\t\t\t\tfinish();\n\t\t\t\t};\n\n\t\t\t\tconst emitPending = (upTo: number): void => {\n\t\t\t\t\tif (upTo <= 0) return;\n\t\t\t\t\tonData(pendingOutput.subarray(0, upTo));\n\t\t\t\t\tpendingOutput = pendingOutput.subarray(upTo);\n\t\t\t\t};\n\n\t\t\t\tconst capturedControl = (): string =>\n\t\t\t\t\tcontrolOverflow\n\t\t\t\t\t\t? `control frame exceeded ${MAX_CONTROL_FRAME_BYTES} bytes`\n\t\t\t\t\t\t: controlBuffer.toString(\"utf8\");\n\n\t\t\t\tconst failAndReset = (error: Error): void => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\temitPending(pendingOutput.length);\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tsettle(() => reject(error));\n\t\t\t\t};\n\n\t\t\t\tconst protocolFailure = (message: string): WindowsShellEngineFailure => {\n\t\t\t\t\tconst capturedOutput = capturedControl();\n\t\t\t\t\treturn new WindowsShellEngineFailure(`${message}\\n${capturedOutput}`, capturedOutput);\n\t\t\t\t};\n\n\t\t\t\tconst maybeComplete = (): void => {\n\t\t\t\t\tif (!sawOutputBarrier || !controlFrame || settled || completionScheduled) return;\n\t\t\t\t\tcompletionScheduled = true;\n\t\t\t\t\t// stdout and stderr are independent pipes. Keep this request active through the\n\t\t\t\t\t// next check phase so already-delivered post-barrier bytes are rejected here,\n\t\t\t\t\t// never forwarded into a queued request that starts in a promise microtask.\n\t\t\t\t\tsetImmediate(() => {\n\t\t\t\t\t\tif (settled || this.activeExec !== active || !controlFrame) return;\n\t\t\t\t\t\tapplyEngineFrame(state, controlFrame);\n\t\t\t\t\t\tif (controlFrame.unsupported) {\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\treject(new Error(controlFrame?.unsupported?.message ?? \"Unsupported shell construct\")),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsettle(() => resolve({ exitCode: controlFrame?.exitCode ?? null }));\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tconst onAbort = (): void => failAndReset(new Error(\"aborted\"));\n\n\t\t\t\tconst active: ActiveEngineExec = {\n\t\t\t\t\tonStdout: (data) => {\n\t\t\t\t\t\tif (sawOutputBarrier) {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted output after its terminal barrier.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpendingOutput = pendingOutput.length === 0 ? data : Buffer.concat([pendingOutput, data]);\n\t\t\t\t\t\tconst barrierIndex = pendingOutput.indexOf(outputBarrier);\n\t\t\t\t\t\tif (barrierIndex !== -1) {\n\t\t\t\t\t\t\temitPending(barrierIndex);\n\t\t\t\t\t\t\tpendingOutput = pendingOutput.subarray(outputBarrier.length);\n\t\t\t\t\t\t\tif (pendingOutput.length > 0) {\n\t\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted bytes after its terminal barrier.\"));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsawOutputBarrier = true;\n\t\t\t\t\t\t\tmaybeComplete();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\temitPending(pendingOutput.length - (outputBarrier.length - 1));\n\t\t\t\t\t},\n\t\t\t\t\tonStderr: (data) => {\n\t\t\t\t\t\tif (controlOverflow) return;\n\t\t\t\t\t\tif (controlBuffer.length + data.length > MAX_CONTROL_FRAME_BYTES) {\n\t\t\t\t\t\t\tcontrolOverflow = true;\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine control frame overflowed.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrolBuffer = controlBuffer.length === 0 ? data : Buffer.concat([controlBuffer, data]);\n\t\t\t\t\t\tconst parsed = parseControlFrame(controlBuffer);\n\t\t\t\t\t\tif (!parsed) return;\n\t\t\t\t\t\tif (parsed.kind === \"invalid\") {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine returned a malformed control frame.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parsed.frame.requestId !== requestId) {\n\t\t\t\t\t\t\tfailAndReset(\n\t\t\t\t\t\t\t\tprotocolFailure(\n\t\t\t\t\t\t\t\t\t`Windows shell engine returned stale control frame ${parsed.frame.requestId}; expected ${requestId}.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (controlBuffer.subarray(parsed.frameEnd).toString(\"utf8\").trim().length > 0) {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted trailing control bytes.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrolFrame = parsed.frame;\n\t\t\t\t\t\tmaybeComplete();\n\t\t\t\t\t},\n\t\t\t\t\tonChildClose: (code) => {\n\t\t\t\t\t\tconst capturedOutput = capturedControl();\n\t\t\t\t\t\temitPending(pendingOutput.length);\n\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew WindowsShellEngineFailure(\n\t\t\t\t\t\t\t\t\t`Windows shell engine coordinator exited (${code ?? \"null\"}) before a complete terminal handoff.\\n${capturedOutput}`,\n\t\t\t\t\t\t\t\t\tcapturedOutput,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tfail: (error) => failAndReset(error),\n\t\t\t\t};\n\n\t\t\t\tthis.activeExec = active;\n\t\t\t\tif (signal) signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutTimer = setTimeout(() => failAndReset(new Error(`timeout:${timeout}`)), timeoutMs);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tchild.stdin?.write(`${JSON.stringify(request)}\\n`, \"utf8\", (error) => {\n\t\t\t\t\t\tif (!error) return;\n\t\t\t\t\t\tfailAndReset(new Error(`Failed to write to Windows shell engine coordinator: ${error.message}`));\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tfailAndReset(new Error(`Failed to write to Windows shell engine coordinator: ${message}`));\n\t\t\t\t}\n\t\t\t});\n\t\t} finally {\n\t\t\tthis.coordinator.setLoopRef(false);\n\t\t}\n\t}\n\n\tprivate async ensureChild(env: NodeJS.ProcessEnv): Promise<ChildProcess> {\n\t\tif (this.coordinator.child) return this.coordinator.child;\n\t\tconst runtime = await this.resolveRuntime();\n\t\tif (runtime.status !== \"ready\") throw degradationError(runtime);\n\t\tif (this.disposed) throw new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\n\t\tconst child = this.spawn(runtime.pythonPath, [\"-B\", this.engineScriptPath, \"--server\"], {\n\t\t\tcwd: dirname(this.engineScriptPath),\n\t\t\tenv: {\n\t\t\t\t...env,\n\t\t\t\tPYTHONDONTWRITEBYTECODE: \"1\",\n\t\t\t\tPYTHONIOENCODING: \"utf-8\",\n\t\t\t\tPYTHONUNBUFFERED: \"1\",\n\t\t\t\tPYTHONUTF8: \"1\",\n\t\t\t},\n\t\t\tdetached: process.platform !== \"win32\",\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\twindowsHide: true,\n\t\t});\n\t\tthis.coordinator.attach(child, {\n\t\t\tonStdout: (data) => {\n\t\t\t\tconst active = this.activeExec;\n\t\t\t\tif (active) active.onStdout(data);\n\t\t\t\telse if (data.length > 0) this.killChild();\n\t\t\t},\n\t\t\tonStderr: (data) => {\n\t\t\t\tconst active = this.activeExec;\n\t\t\t\tif (active) active.onStderr(data);\n\t\t\t\telse if (data.length > 0) this.killChild();\n\t\t\t},\n\t\t\tonError: (error) => this.activeExec?.fail(error),\n\t\t\tonClose: (code) => this.activeExec?.onChildClose(code),\n\t\t});\n\t\treturn child;\n\t}\n\n\tprivate killChild(): void {\n\t\tthis.coordinator.kill();\n\t}\n}\n\nconst engineSessions = new Map<string, PersistentWindowsShellEngineSession>();\n\nfunction acquireWindowsShellEngineSession(\n\tkey: string,\n\toptions: WindowsShellEngineOptions,\n): PersistentWindowsShellEngineSession {\n\tconst existing = engineSessions.get(key);\n\tif (existing) return existing;\n\tconst session = new PersistentWindowsShellEngineSession(key, options);\n\tengineSessions.set(key, session);\n\treturn session;\n}\n\n/** Kill and forget a Python coordinator. The next call for this key starts a clean process. */\nexport function disposeWindowsShellEngineSession(key: string): void {\n\tconst session = engineSessions.get(key);\n\tif (!session) return;\n\tengineSessions.delete(key);\n\tsession.dispose();\n}\n\n/** Create the Python-engine tier for one bash-tool session. */\nexport function createWindowsShellEngineOperations(\n\tsessionKey: string,\n\toptions: WindowsShellEngineOptions = {},\n): BashOperations {\n\treturn {\n\t\t// Resolve through the registry for every command. Session teardown (for example after\n\t\t// credential/environment changes) deletes only this tenant's entry; an already-built tool\n\t\t// then lazily acquires a fresh coordinator instead of retaining the disposed instance.\n\t\texec: (command, cwd, execOptions) =>\n\t\t\tacquireWindowsShellEngineSession(sessionKey, options).exec(command, cwd, execOptions),\n\t};\n}\n"]}
|
|
@@ -3,18 +3,14 @@ import { type Static, Type } from "typebox";
|
|
|
3
3
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
4
4
|
import { FileMutationIntentController } from "./file-mutation-intent.ts";
|
|
5
5
|
declare const writeSchema: Type.TUnion<[Type.TObject<{
|
|
6
|
-
action: Type.TLiteral<"prepare">;
|
|
7
6
|
path: Type.TString;
|
|
8
|
-
}>, Type.TObject<{
|
|
9
|
-
action: Type.TLiteral<"commit">;
|
|
10
|
-
path: Type.TString;
|
|
11
|
-
intentId: Type.TString;
|
|
12
7
|
content: Type.TString;
|
|
13
8
|
}>, Type.TObject<{
|
|
14
|
-
action: Type.TLiteral<"commit">;
|
|
15
9
|
path: Type.TString;
|
|
16
|
-
intentId: Type.TString;
|
|
17
10
|
contentRef: Type.TString;
|
|
11
|
+
}>, Type.TObject<{
|
|
12
|
+
path: Type.TString;
|
|
13
|
+
payloadRef: Type.TString;
|
|
18
14
|
}>]>;
|
|
19
15
|
export type WriteToolInput = Static<typeof writeSchema>;
|
|
20
16
|
/**
|
|
@@ -30,12 +26,11 @@ export interface WriteOperations {
|
|
|
30
26
|
export interface WriteToolOptions {
|
|
31
27
|
/** Custom operations for file writing. Default: local filesystem */
|
|
32
28
|
operations?: WriteOperations;
|
|
33
|
-
/** Session-owned
|
|
29
|
+
/** Session-owned harness preflight and exact-content-reference authority. */
|
|
34
30
|
intentController?: FileMutationIntentController;
|
|
35
31
|
}
|
|
36
32
|
export interface WriteToolDetails {
|
|
37
|
-
phase: "
|
|
38
|
-
intentId?: string;
|
|
33
|
+
phase: "written";
|
|
39
34
|
contentRef?: string;
|
|
40
35
|
byteCount?: number;
|
|
41
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAEN,4BAA4B,EAE5B,MAAM,2BAA2B,CAAC;AAOnC,QAAA,MAAM,WAAW;;;;;;;;;IAsBf,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,oFAAoF;IACpF,UAAU,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,mCAAmC;IACnC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAOD,MAAM,WAAW,gBAAgB;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,4BAA4B,CAAC;CAChD;AAED,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA6ND,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,gBAAgB,GACxB,cAAc,CAAC,OAAO,WAAW,EAAE,gBAAgB,CAAC,CAoItD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,OAAO,WAAW,CAAC,CAEtG"}
|
package/dist/core/tools/write.js
CHANGED
|
@@ -4,30 +4,25 @@ import { Container, Text } from "@caupulican/pi-tui";
|
|
|
4
4
|
import { Type } from "typebox";
|
|
5
5
|
import { keyHint } from "../../modes/interactive/components/keybinding-hints.js";
|
|
6
6
|
import { getLanguageFromPath, highlightCode } from "../../modes/interactive/theme/theme.js";
|
|
7
|
-
import { FileMutationIntentController } from "./file-mutation-intent.js";
|
|
7
|
+
import { FileMutationIntentController, FileMutationPreflightError, } from "./file-mutation-intent.js";
|
|
8
8
|
import { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
9
9
|
import { resolveToCwd } from "./path-utils.js";
|
|
10
10
|
import { normalizeDisplayText, renderToolPath, replaceTabs, str } from "./render-utils.js";
|
|
11
11
|
import { wrapToolDefinition } from "./tool-definition-wrapper.js";
|
|
12
12
|
const writePathSchema = Type.String({ minLength: 1 });
|
|
13
|
-
const writeCommitProperties = {
|
|
14
|
-
action: Type.Literal("commit"),
|
|
15
|
-
path: writePathSchema,
|
|
16
|
-
intentId: Type.String({ minLength: 1 }),
|
|
17
|
-
};
|
|
18
13
|
const writeSchema = Type.Union([
|
|
19
14
|
Type.Object({
|
|
20
|
-
action: Type.Literal("prepare"),
|
|
21
15
|
path: writePathSchema,
|
|
22
|
-
}, { additionalProperties: false }),
|
|
23
|
-
Type.Object({
|
|
24
|
-
...writeCommitProperties,
|
|
25
16
|
content: Type.String(),
|
|
26
17
|
}, { additionalProperties: false }),
|
|
27
18
|
Type.Object({
|
|
28
|
-
|
|
19
|
+
path: writePathSchema,
|
|
29
20
|
contentRef: Type.String({ minLength: 1 }),
|
|
30
21
|
}, { additionalProperties: false }),
|
|
22
|
+
Type.Object({
|
|
23
|
+
path: writePathSchema,
|
|
24
|
+
payloadRef: Type.String({ minLength: 1 }),
|
|
25
|
+
}, { additionalProperties: false }),
|
|
31
26
|
]);
|
|
32
27
|
const defaultWriteOperations = {
|
|
33
28
|
createFile: (path, content) => fsWriteFile(path, content, { encoding: "utf-8", flag: "wx" }),
|
|
@@ -129,9 +124,8 @@ function formatWriteCall(args, options, theme, cache, cwd) {
|
|
|
129
124
|
const fileContent = str(args?.content);
|
|
130
125
|
const hasContent = typeof args?.content === "string";
|
|
131
126
|
const pathDisplay = renderToolPath(rawPath, theme, cwd);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (args?.action === "commit" && !hasContent && typeof args.contentRef !== "string") {
|
|
127
|
+
let text = `${theme.fg("toolTitle", theme.bold("write"))} ${pathDisplay}`;
|
|
128
|
+
if (!hasContent && typeof args?.contentRef !== "string" && typeof args?.payloadRef !== "string") {
|
|
135
129
|
text += `\n\n${theme.fg("error", "[invalid content arg - expected string]")}`;
|
|
136
130
|
}
|
|
137
131
|
else if (hasContent && fileContent) {
|
|
@@ -158,8 +152,32 @@ function formatWriteCall(args, options, theme, cache, cwd) {
|
|
|
158
152
|
else if (args?.contentRef) {
|
|
159
153
|
text += `\n\n${theme.fg("muted", `reuse ${args.contentRef}`)}`;
|
|
160
154
|
}
|
|
155
|
+
else if (args?.payloadRef) {
|
|
156
|
+
text += `\n\n${theme.fg("muted", `retarget ${args.payloadRef}`)}`;
|
|
157
|
+
}
|
|
161
158
|
return text;
|
|
162
159
|
}
|
|
160
|
+
async function writeCollisionWithRetainedPayload(error, input, intentController, signal) {
|
|
161
|
+
const retargetError = (reference) => new Error(`PI_FILE_MUTATION_RETARGET write_collision: ${reference}. Choose only a corrected path; the exact valid write payload is retained.`);
|
|
162
|
+
if ("contentRef" in input) {
|
|
163
|
+
await intentController.assertContentReference(input.contentRef, signal);
|
|
164
|
+
return retargetError(`contentRef ${input.contentRef}`);
|
|
165
|
+
}
|
|
166
|
+
if ("payloadRef" in input) {
|
|
167
|
+
await intentController.assertMutationPayload(input.payloadRef, "write", signal);
|
|
168
|
+
return retargetError(`payloadRef ${input.payloadRef}`);
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
const retained = await intentController.retainMutationPayload("write", input.content);
|
|
172
|
+
if (retained) {
|
|
173
|
+
return retargetError(`payloadRef ${retained.payloadRef}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
// The collision remains authoritative when the bounded retry cache is unavailable.
|
|
178
|
+
}
|
|
179
|
+
return new Error(`${error.message} The payload could not be retained within the secure retry-cache bound.`);
|
|
180
|
+
}
|
|
163
181
|
function formatWriteResult(result, theme) {
|
|
164
182
|
if (!result.isError) {
|
|
165
183
|
return undefined;
|
|
@@ -182,81 +200,82 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
182
200
|
return {
|
|
183
201
|
name: "write",
|
|
184
202
|
label: "write",
|
|
185
|
-
description: "Create a file without overwriting
|
|
203
|
+
description: "Create a new file without overwriting. Send path and exactly one of content or contentRef. After a path-only collision, use the returned payloadRef with only a corrected path. The harness owns preflight, bounded payload retention, and atomic rechecks.",
|
|
186
204
|
promptSnippet: "Preflight new paths; never overwrite",
|
|
187
205
|
promptGuidelines: [
|
|
188
|
-
"
|
|
206
|
+
"Call write once with path and exactly one of content or contentRef; preparation and collision checks are harness-owned.",
|
|
207
|
+
"If a collision result returns payloadRef, choose a new path and reuse that reference instead of regenerating content.",
|
|
189
208
|
"Write is create-only; edit existing files. Reuse contentRef for exact copies.",
|
|
190
209
|
],
|
|
191
210
|
parameters: writeSchema,
|
|
192
211
|
async execute(_toolCallId, input, signal, _onUpdate, _ctx) {
|
|
193
212
|
const { path } = input;
|
|
194
213
|
const absolutePath = resolveToCwd(path, cwd);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
214
|
+
const content = "content" in input && typeof input.content === "string" ? input.content : undefined;
|
|
215
|
+
const contentRef = "contentRef" in input && typeof input.contentRef === "string" ? input.contentRef : undefined;
|
|
216
|
+
const payloadRef = "payloadRef" in input && typeof input.payloadRef === "string" ? input.payloadRef : undefined;
|
|
217
|
+
if ([content, contentRef, payloadRef].filter((value) => value !== undefined).length !== 1) {
|
|
218
|
+
throw new Error("Write requires exactly one of content, contentRef, or payloadRef.");
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
const lease = await intentController.prepare("write", absolutePath, signal, path);
|
|
222
|
+
return await withFileMutationQueue(absolutePath, async () => {
|
|
223
|
+
// Do not reject from an abort event listener here: that would release the
|
|
224
|
+
// mutation queue while an in-flight filesystem operation may still finish.
|
|
225
|
+
// Checking signal.aborted after each await observes the same aborts while
|
|
226
|
+
// keeping the queue locked until the current operation has settled.
|
|
227
|
+
const throwIfAborted = () => {
|
|
228
|
+
if (signal?.aborted)
|
|
229
|
+
throw new Error("Operation aborted");
|
|
230
|
+
};
|
|
231
|
+
throwIfAborted();
|
|
232
|
+
await intentController.assertCurrent(lease, signal);
|
|
233
|
+
await ops.mkdir(dirname(absolutePath));
|
|
234
|
+
throwIfAborted();
|
|
235
|
+
let contentReference;
|
|
236
|
+
try {
|
|
237
|
+
if (content !== undefined) {
|
|
238
|
+
await ops.createFile(absolutePath, content);
|
|
239
|
+
contentReference = intentController.rememberContent(absolutePath, content);
|
|
240
|
+
}
|
|
241
|
+
else if (contentRef !== undefined) {
|
|
242
|
+
contentReference = await intentController.copyReferencedContent(contentRef, absolutePath, signal);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
if (payloadRef === undefined)
|
|
246
|
+
throw new Error("Write requires a payload reference.");
|
|
247
|
+
contentReference = await intentController.copyMutationPayload(payloadRef, absolutePath, signal);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST") {
|
|
252
|
+
throw new FileMutationPreflightError("write_collision", `Write collision: ${path} already exists; no content was overwritten.`);
|
|
253
|
+
}
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
throwIfAborted();
|
|
257
|
+
const byteCount = contentReference.byteLength;
|
|
207
258
|
return {
|
|
208
259
|
content: [
|
|
209
260
|
{
|
|
210
261
|
type: "text",
|
|
211
|
-
text: `
|
|
262
|
+
text: `Successfully wrote ${byteCount} bytes to ${path}; this write is complete, so do not call write again for this path. To copy these exact bytes to a different new path, call write once for that path with contentRef ${contentReference.contentRef}.`,
|
|
212
263
|
},
|
|
213
264
|
],
|
|
214
|
-
details: {
|
|
265
|
+
details: {
|
|
266
|
+
phase: "written",
|
|
267
|
+
contentRef: contentReference.contentRef,
|
|
268
|
+
byteCount,
|
|
269
|
+
},
|
|
215
270
|
};
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
if (error instanceof FileMutationPreflightError && error.reason === "write_collision") {
|
|
275
|
+
throw await writeCollisionWithRetainedPayload(error, input, intentController, signal);
|
|
216
276
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if ((content === undefined) === (contentRef === undefined)) {
|
|
220
|
-
throw new Error("Write commit requires exactly one of content or contentRef.");
|
|
221
|
-
}
|
|
222
|
-
const lease = intentController.consume(input.intentId, "write", absolutePath);
|
|
223
|
-
await intentController.assertCurrent(lease, signal);
|
|
224
|
-
await ops.mkdir(dirname(absolutePath));
|
|
225
|
-
throwIfAborted();
|
|
226
|
-
let contentReference;
|
|
227
|
-
try {
|
|
228
|
-
if (content !== undefined) {
|
|
229
|
-
await ops.createFile(absolutePath, content);
|
|
230
|
-
contentReference = intentController.rememberContent(absolutePath, content);
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
if (contentRef === undefined)
|
|
234
|
-
throw new Error("Write commit requires content or contentRef.");
|
|
235
|
-
contentReference = await intentController.copyReferencedContent(contentRef, absolutePath, signal);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
catch (error) {
|
|
239
|
-
if (typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST") {
|
|
240
|
-
throw new Error(`Write collision: ${path} already exists; no content was overwritten.`);
|
|
241
|
-
}
|
|
242
|
-
throw error;
|
|
243
|
-
}
|
|
244
|
-
throwIfAborted();
|
|
245
|
-
const byteCount = contentReference.byteLength;
|
|
246
|
-
return {
|
|
247
|
-
content: [
|
|
248
|
-
{
|
|
249
|
-
type: "text",
|
|
250
|
-
text: `Successfully wrote ${byteCount} bytes to ${path}. Reuse exact bytes with contentRef ${contentReference.contentRef}.`,
|
|
251
|
-
},
|
|
252
|
-
],
|
|
253
|
-
details: {
|
|
254
|
-
phase: "committed",
|
|
255
|
-
contentRef: contentReference.contentRef,
|
|
256
|
-
byteCount,
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
});
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
260
279
|
},
|
|
261
280
|
renderCall(args, theme, context) {
|
|
262
281
|
const renderArgs = args;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAA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P,WAAW,EACX,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,gBAAgB,EACjD,OAAO,CAAC,QAAQ,CAChB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC;YAC7B,CAAC;YACD,SAAS,CAAC,OAAO,CAChB,eAAe,CACd,UAAU,EACV,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,EAC5D,KAAK,EACL,SAAS,CAAC,KAAK,EACf,OAAO,CAAC,GAAG,CACX,CACD,CAAC;YACF,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO;YAC5C,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;YACjF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;gBACtF,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA0B;IACtE,OAAO,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { mkdir as fsMkdir, writeFile as fsWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { Container, Text } from \"@caupulican/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { type FileContentReference, FileMutationIntentController } from \"./file-mutation-intent.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { normalizeDisplayText, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst writePathSchema = Type.String({ minLength: 1 });\nconst writeCommitProperties = {\n\taction: Type.Literal(\"commit\"),\n\tpath: writePathSchema,\n\tintentId: Type.String({ minLength: 1 }),\n};\nconst writeSchema = Type.Union([\n\tType.Object(\n\t\t{\n\t\t\taction: Type.Literal(\"prepare\"),\n\t\t\tpath: writePathSchema,\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\t...writeCommitProperties,\n\t\t\tcontent: Type.String(),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\t...writeCommitProperties,\n\t\t\tcontentRef: Type.String({ minLength: 1 }),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n]);\n\nexport type WriteToolInput = Static<typeof writeSchema>;\n\n/**\n * Pluggable operations for the write tool.\n * Override these to delegate file writing to remote systems (for example SSH).\n */\nexport interface WriteOperations {\n\t/** Atomically create a new file and fail if any entry already occupies the path. */\n\tcreateFile: (absolutePath: string, content: string) => Promise<void>;\n\t/** Create directory recursively */\n\tmkdir: (dir: string) => Promise<void>;\n}\n\nconst defaultWriteOperations: WriteOperations = {\n\tcreateFile: (path, content) => fsWriteFile(path, content, { encoding: \"utf-8\", flag: \"wx\" }),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\n\t/** Session-owned two-phase intent and exact-content-reference authority. */\n\tintentController?: FileMutationIntentController;\n}\n\nexport interface WriteToolDetails {\n\tphase: \"prepared\" | \"committed\";\n\tintentId?: string;\n\tcontentRef?: string;\n\tbyteCount?: number;\n}\n\ntype WriteHighlightCache = {\n\targsRef: unknown;\n\trawPath: string | null;\n\tcountCompleteLines: boolean;\n\texpanded: boolean;\n\trenderedLines: string[];\n\ttotalLines?: number;\n\tcappedByCharacters: boolean;\n\tcappedByLines: boolean;\n};\n\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n}\n\nconst WRITE_COLLAPSED_PREVIEW_LINES = 10;\nconst WRITE_COLLAPSED_PREVIEW_CHARS = 8_192;\n\nfunction countWriteDisplayLines(fileContent: string): number {\n\tlet lastContentIndex = fileContent.length - 1;\n\twhile (lastContentIndex >= 0) {\n\t\tconst code = fileContent.charCodeAt(lastContentIndex);\n\t\tif (code !== 10 && code !== 13) break;\n\t\tlastContentIndex--;\n\t}\n\tif (lastContentIndex < 0) return 0;\n\n\tlet lines = 1;\n\tfor (let i = 0; i <= lastContentIndex; i++) {\n\t\tif (fileContent.charCodeAt(i) === 10) lines++;\n\t}\n\treturn lines;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction buildCollapsedWriteSource(fileContent: string): {\n\tsource: string;\n\tcappedByCharacters: boolean;\n\tcappedByLines: boolean;\n} {\n\tconst rawPrefix = fileContent.slice(0, WRITE_COLLAPSED_PREVIEW_CHARS);\n\tconst normalizedPrefix = replaceTabs(normalizeDisplayText(rawPrefix));\n\tlet end = normalizedPrefix.length;\n\tlet newlineCount = 0;\n\tfor (let i = 0; i < normalizedPrefix.length; i++) {\n\t\tif (normalizedPrefix.charCodeAt(i) !== 10) continue;\n\t\tnewlineCount++;\n\t\tif (newlineCount === WRITE_COLLAPSED_PREVIEW_LINES) {\n\t\t\tend = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tconst cappedByLines = end < normalizedPrefix.length;\n\treturn {\n\t\tsource: normalizedPrefix.slice(0, end),\n\t\tcappedByCharacters: !cappedByLines && rawPrefix.length < fileContent.length,\n\t\tcappedByLines,\n\t};\n}\n\nfunction buildWriteHighlightCache(\n\targsRef: unknown,\n\trawPath: string | null,\n\tfileContent: string,\n\tcountCompleteLines: boolean,\n\texpanded: boolean,\n): WriteHighlightCache {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (expanded) {\n\t\tconst source = replaceTabs(normalizeDisplayText(fileContent));\n\t\tconst renderedLines = trimTrailingEmptyLines(lang ? highlightCode(source, lang) : source.split(\"\\n\"));\n\t\treturn {\n\t\t\targsRef,\n\t\t\trawPath,\n\t\t\tcountCompleteLines,\n\t\t\texpanded,\n\t\t\trenderedLines,\n\t\t\ttotalLines: renderedLines.length,\n\t\t\tcappedByCharacters: false,\n\t\t\tcappedByLines: false,\n\t\t};\n\t}\n\n\tconst preview = buildCollapsedWriteSource(fileContent);\n\tconst renderedLines = trimTrailingEmptyLines(\n\t\tlang ? highlightCode(preview.source, lang) : preview.source.split(\"\\n\"),\n\t);\n\treturn {\n\t\targsRef,\n\t\trawPath,\n\t\tcountCompleteLines,\n\t\texpanded,\n\t\trenderedLines,\n\t\ttotalLines: countCompleteLines ? countWriteDisplayLines(fileContent) : undefined,\n\t\tcappedByCharacters: preview.cappedByCharacters,\n\t\tcappedByLines: preview.cappedByLines,\n\t};\n}\n\nfunction getWriteHighlightCache(\n\tcache: WriteHighlightCache | undefined,\n\targsRef: unknown,\n\trawPath: string | null,\n\tfileContent: string,\n\tcountCompleteLines: boolean,\n\texpanded: boolean,\n): WriteHighlightCache {\n\tif (\n\t\tcache &&\n\t\tcache.argsRef === argsRef &&\n\t\tcache.rawPath === rawPath &&\n\t\tcache.countCompleteLines === countCompleteLines &&\n\t\tcache.expanded === expanded\n\t) {\n\t\treturn cache;\n\t}\n\treturn buildWriteHighlightCache(argsRef, rawPath, fileContent, countCompleteLines, expanded);\n}\n\nfunction formatWriteCall(\n\targs: { action?: string; path?: string; file_path?: string; content?: string; contentRef?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcache: WriteHighlightCache | undefined,\n\tcwd: string,\n): string {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst fileContent = str(args?.content);\n\tconst hasContent = typeof args?.content === \"string\";\n\tconst pathDisplay = renderToolPath(rawPath, theme, cwd);\n\tconst action = args?.action === \"prepare\" ? \"prepare\" : args?.action === \"commit\" ? \"commit\" : undefined;\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))}${action ? ` ${theme.fg(\"muted\", action)}` : \"\"} ${pathDisplay}`;\n\n\tif (args?.action === \"commit\" && !hasContent && typeof args.contentRef !== \"string\") {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (hasContent && fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tconst displayLines = cache?.renderedLines ?? [];\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (!options.expanded && cache && (cache.cappedByCharacters || cache.cappedByLines)) {\n\t\t\tconst total = cache.totalLines;\n\t\t\tif (cache.cappedByCharacters) {\n\t\t\t\tconst totalSuffix = total === undefined ? \"\" : `; ${total} total line${total === 1 ? \"\" : \"s\"}`;\n\t\t\t\ttext += `${theme.fg(\"muted\", `\\n... (preview capped at ${WRITE_COLLAPSED_PREVIEW_CHARS} characters${totalSuffix},`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t} else if (total === undefined) {\n\t\t\t\ttext += `${theme.fg(\"muted\", \"\\n... (preview capped,\")} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t} else {\n\t\t\t\tconst remaining = Math.max(0, total - displayLines.length);\n\t\t\t\tif (remaining > 0) {\n\t\t\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines, ${total} total,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (args?.contentRef) {\n\t\ttext += `\\n\\n${theme.fg(\"muted\", `reuse ${args.contentRef}`)}`;\n\t}\n\n\treturn text;\n}\n\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: Theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport function createWriteToolDefinition(\n\tcwd: string,\n\toptions?: WriteToolOptions,\n): ToolDefinition<typeof writeSchema, WriteToolDetails> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\tif (options?.operations && !options.intentController) {\n\t\tthrow new Error(\"Custom write operations require a matching file mutation intent controller.\");\n\t}\n\tconst intentController = options?.intentController ?? new FileMutationIntentController();\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Create a file without overwriting: prepare(path), then commit(path,intentId,content|contentRef). Prepare rejects collisions before content generation; commit rechecks atomically.\",\n\t\tpromptSnippet: \"Preflight new paths; never overwrite\",\n\t\tpromptGuidelines: [\n\t\t\t\"Before content generation, prepare(path); then commit with intentId and one of content or contentRef.\",\n\t\t\t\"Write is create-only; edit existing files. Reuse contentRef for exact copies.\",\n\t\t],\n\t\tparameters: writeSchema,\n\t\tasync execute(_toolCallId, input: WriteToolInput, signal?: AbortSignal, _onUpdate?, _ctx?) {\n\t\t\tconst { path } = input;\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\n\t\t\treturn withFileMutationQueue(absolutePath, async () => {\n\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\t\t\t\tif (input.action === \"prepare\") {\n\t\t\t\t\tconst prepared = await intentController.prepare(\"write\", absolutePath, signal, path);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\t\ttext: `Write path accepted. Commit ${path} with intentId ${prepared.intentId}.`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: { phase: \"prepared\" as const, intentId: prepared.intentId },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst content = \"content\" in input && typeof input.content === \"string\" ? input.content : undefined;\n\t\t\t\tconst contentRef =\n\t\t\t\t\t\"contentRef\" in input && typeof input.contentRef === \"string\" ? input.contentRef : undefined;\n\t\t\t\tif ((content === undefined) === (contentRef === undefined)) {\n\t\t\t\t\tthrow new Error(\"Write commit requires exactly one of content or contentRef.\");\n\t\t\t\t}\n\t\t\t\tconst lease = intentController.consume(input.intentId, \"write\", absolutePath);\n\t\t\t\tawait intentController.assertCurrent(lease, signal);\n\t\t\t\tawait ops.mkdir(dirname(absolutePath));\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tlet contentReference: FileContentReference;\n\t\t\t\ttry {\n\t\t\t\t\tif (content !== undefined) {\n\t\t\t\t\t\tawait ops.createFile(absolutePath, content);\n\t\t\t\t\t\tcontentReference = intentController.rememberContent(absolutePath, content);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (contentRef === undefined) throw new Error(\"Write commit requires content or contentRef.\");\n\t\t\t\t\t\tcontentReference = await intentController.copyReferencedContent(contentRef, absolutePath, signal);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"EEXIST\") {\n\t\t\t\t\t\tthrow new Error(`Write collision: ${path} already exists; no content was overwritten.`);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst byteCount = contentReference.byteLength;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `Successfully wrote ${byteCount} bytes to ${path}. Reuse exact bytes with contentRef ${contentReference.contentRef}.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tphase: \"committed\" as const,\n\t\t\t\t\t\tcontentRef: contentReference.contentRef,\n\t\t\t\t\t\tbyteCount,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst renderArgs = args as\n\t\t\t\t| { action?: string; path?: string; file_path?: string; content?: string; contentRef?: string }\n\t\t\t\t| undefined;\n\t\t\tconst rawPath = str(renderArgs?.file_path ?? renderArgs?.path);\n\t\t\tconst fileContent = str(renderArgs?.content);\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\t\tif (fileContent !== null) {\n\t\t\t\tcomponent.cache = getWriteHighlightCache(\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\targs,\n\t\t\t\t\trawPath,\n\t\t\t\t\tfileContent,\n\t\t\t\t\tcontext.argsComplete && !context.toolGroupSummary,\n\t\t\t\t\tcontext.expanded,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcomponent.cache = undefined;\n\t\t\t}\n\t\t\tcomponent.setText(\n\t\t\t\tformatWriteCall(\n\t\t\t\t\trenderArgs,\n\t\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\t\tif (!output) {\n\t\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\t\tcomponent.clear();\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(output);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema> {\n\treturn wrapToolDefinition(createWriteToolDefinition(cwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAc,MAAM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AY,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO;YAC5C,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;YACjF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;gBACtF,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA0B;IACtE,OAAO,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { mkdir as fsMkdir, writeFile as fsWriteFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport { Container, Text } from \"@caupulican/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport {\n\ttype FileContentReference,\n\tFileMutationIntentController,\n\tFileMutationPreflightError,\n} from \"./file-mutation-intent.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { normalizeDisplayText, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst writePathSchema = Type.String({ minLength: 1 });\nconst writeSchema = Type.Union([\n\tType.Object(\n\t\t{\n\t\t\tpath: writePathSchema,\n\t\t\tcontent: Type.String(),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\tpath: writePathSchema,\n\t\t\tcontentRef: Type.String({ minLength: 1 }),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n\tType.Object(\n\t\t{\n\t\t\tpath: writePathSchema,\n\t\t\tpayloadRef: Type.String({ minLength: 1 }),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n]);\n\nexport type WriteToolInput = Static<typeof writeSchema>;\n\n/**\n * Pluggable operations for the write tool.\n * Override these to delegate file writing to remote systems (for example SSH).\n */\nexport interface WriteOperations {\n\t/** Atomically create a new file and fail if any entry already occupies the path. */\n\tcreateFile: (absolutePath: string, content: string) => Promise<void>;\n\t/** Create directory recursively */\n\tmkdir: (dir: string) => Promise<void>;\n}\n\nconst defaultWriteOperations: WriteOperations = {\n\tcreateFile: (path, content) => fsWriteFile(path, content, { encoding: \"utf-8\", flag: \"wx\" }),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\n\t/** Session-owned harness preflight and exact-content-reference authority. */\n\tintentController?: FileMutationIntentController;\n}\n\nexport interface WriteToolDetails {\n\tphase: \"written\";\n\tcontentRef?: string;\n\tbyteCount?: number;\n}\n\ntype WriteHighlightCache = {\n\targsRef: unknown;\n\trawPath: string | null;\n\tcountCompleteLines: boolean;\n\texpanded: boolean;\n\trenderedLines: string[];\n\ttotalLines?: number;\n\tcappedByCharacters: boolean;\n\tcappedByLines: boolean;\n};\n\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n}\n\nconst WRITE_COLLAPSED_PREVIEW_LINES = 10;\nconst WRITE_COLLAPSED_PREVIEW_CHARS = 8_192;\n\nfunction countWriteDisplayLines(fileContent: string): number {\n\tlet lastContentIndex = fileContent.length - 1;\n\twhile (lastContentIndex >= 0) {\n\t\tconst code = fileContent.charCodeAt(lastContentIndex);\n\t\tif (code !== 10 && code !== 13) break;\n\t\tlastContentIndex--;\n\t}\n\tif (lastContentIndex < 0) return 0;\n\n\tlet lines = 1;\n\tfor (let i = 0; i <= lastContentIndex; i++) {\n\t\tif (fileContent.charCodeAt(i) === 10) lines++;\n\t}\n\treturn lines;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction buildCollapsedWriteSource(fileContent: string): {\n\tsource: string;\n\tcappedByCharacters: boolean;\n\tcappedByLines: boolean;\n} {\n\tconst rawPrefix = fileContent.slice(0, WRITE_COLLAPSED_PREVIEW_CHARS);\n\tconst normalizedPrefix = replaceTabs(normalizeDisplayText(rawPrefix));\n\tlet end = normalizedPrefix.length;\n\tlet newlineCount = 0;\n\tfor (let i = 0; i < normalizedPrefix.length; i++) {\n\t\tif (normalizedPrefix.charCodeAt(i) !== 10) continue;\n\t\tnewlineCount++;\n\t\tif (newlineCount === WRITE_COLLAPSED_PREVIEW_LINES) {\n\t\t\tend = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tconst cappedByLines = end < normalizedPrefix.length;\n\treturn {\n\t\tsource: normalizedPrefix.slice(0, end),\n\t\tcappedByCharacters: !cappedByLines && rawPrefix.length < fileContent.length,\n\t\tcappedByLines,\n\t};\n}\n\nfunction buildWriteHighlightCache(\n\targsRef: unknown,\n\trawPath: string | null,\n\tfileContent: string,\n\tcountCompleteLines: boolean,\n\texpanded: boolean,\n): WriteHighlightCache {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (expanded) {\n\t\tconst source = replaceTabs(normalizeDisplayText(fileContent));\n\t\tconst renderedLines = trimTrailingEmptyLines(lang ? highlightCode(source, lang) : source.split(\"\\n\"));\n\t\treturn {\n\t\t\targsRef,\n\t\t\trawPath,\n\t\t\tcountCompleteLines,\n\t\t\texpanded,\n\t\t\trenderedLines,\n\t\t\ttotalLines: renderedLines.length,\n\t\t\tcappedByCharacters: false,\n\t\t\tcappedByLines: false,\n\t\t};\n\t}\n\n\tconst preview = buildCollapsedWriteSource(fileContent);\n\tconst renderedLines = trimTrailingEmptyLines(\n\t\tlang ? highlightCode(preview.source, lang) : preview.source.split(\"\\n\"),\n\t);\n\treturn {\n\t\targsRef,\n\t\trawPath,\n\t\tcountCompleteLines,\n\t\texpanded,\n\t\trenderedLines,\n\t\ttotalLines: countCompleteLines ? countWriteDisplayLines(fileContent) : undefined,\n\t\tcappedByCharacters: preview.cappedByCharacters,\n\t\tcappedByLines: preview.cappedByLines,\n\t};\n}\n\nfunction getWriteHighlightCache(\n\tcache: WriteHighlightCache | undefined,\n\targsRef: unknown,\n\trawPath: string | null,\n\tfileContent: string,\n\tcountCompleteLines: boolean,\n\texpanded: boolean,\n): WriteHighlightCache {\n\tif (\n\t\tcache &&\n\t\tcache.argsRef === argsRef &&\n\t\tcache.rawPath === rawPath &&\n\t\tcache.countCompleteLines === countCompleteLines &&\n\t\tcache.expanded === expanded\n\t) {\n\t\treturn cache;\n\t}\n\treturn buildWriteHighlightCache(argsRef, rawPath, fileContent, countCompleteLines, expanded);\n}\n\nfunction formatWriteCall(\n\targs: { path?: string; file_path?: string; content?: string; contentRef?: string; payloadRef?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcache: WriteHighlightCache | undefined,\n\tcwd: string,\n): string {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst fileContent = str(args?.content);\n\tconst hasContent = typeof args?.content === \"string\";\n\tconst pathDisplay = renderToolPath(rawPath, theme, cwd);\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))} ${pathDisplay}`;\n\n\tif (!hasContent && typeof args?.contentRef !== \"string\" && typeof args?.payloadRef !== \"string\") {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (hasContent && fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tconst displayLines = cache?.renderedLines ?? [];\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (!options.expanded && cache && (cache.cappedByCharacters || cache.cappedByLines)) {\n\t\t\tconst total = cache.totalLines;\n\t\t\tif (cache.cappedByCharacters) {\n\t\t\t\tconst totalSuffix = total === undefined ? \"\" : `; ${total} total line${total === 1 ? \"\" : \"s\"}`;\n\t\t\t\ttext += `${theme.fg(\"muted\", `\\n... (preview capped at ${WRITE_COLLAPSED_PREVIEW_CHARS} characters${totalSuffix},`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t} else if (total === undefined) {\n\t\t\t\ttext += `${theme.fg(\"muted\", \"\\n... (preview capped,\")} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t} else {\n\t\t\t\tconst remaining = Math.max(0, total - displayLines.length);\n\t\t\t\tif (remaining > 0) {\n\t\t\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines, ${total} total,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (args?.contentRef) {\n\t\ttext += `\\n\\n${theme.fg(\"muted\", `reuse ${args.contentRef}`)}`;\n\t} else if (args?.payloadRef) {\n\t\ttext += `\\n\\n${theme.fg(\"muted\", `retarget ${args.payloadRef}`)}`;\n\t}\n\n\treturn text;\n}\n\nasync function writeCollisionWithRetainedPayload(\n\terror: FileMutationPreflightError,\n\tinput: WriteToolInput,\n\tintentController: FileMutationIntentController,\n\tsignal?: AbortSignal,\n): Promise<Error> {\n\tconst retargetError = (reference: string): Error =>\n\t\tnew Error(\n\t\t\t`PI_FILE_MUTATION_RETARGET write_collision: ${reference}. Choose only a corrected path; the exact valid write payload is retained.`,\n\t\t);\n\tif (\"contentRef\" in input) {\n\t\tawait intentController.assertContentReference(input.contentRef, signal);\n\t\treturn retargetError(`contentRef ${input.contentRef}`);\n\t}\n\tif (\"payloadRef\" in input) {\n\t\tawait intentController.assertMutationPayload(input.payloadRef, \"write\", signal);\n\t\treturn retargetError(`payloadRef ${input.payloadRef}`);\n\t}\n\n\ttry {\n\t\tconst retained = await intentController.retainMutationPayload(\"write\", input.content);\n\t\tif (retained) {\n\t\t\treturn retargetError(`payloadRef ${retained.payloadRef}`);\n\t\t}\n\t} catch {\n\t\t// The collision remains authoritative when the bounded retry cache is unavailable.\n\t}\n\treturn new Error(`${error.message} The payload could not be retained within the secure retry-cache bound.`);\n}\n\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: Theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport function createWriteToolDefinition(\n\tcwd: string,\n\toptions?: WriteToolOptions,\n): ToolDefinition<typeof writeSchema, WriteToolDetails> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\tif (options?.operations && !options.intentController) {\n\t\tthrow new Error(\"Custom write operations require a matching file mutation intent controller.\");\n\t}\n\tconst intentController = options?.intentController ?? new FileMutationIntentController();\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Create a new file without overwriting. Send path and exactly one of content or contentRef. After a path-only collision, use the returned payloadRef with only a corrected path. The harness owns preflight, bounded payload retention, and atomic rechecks.\",\n\t\tpromptSnippet: \"Preflight new paths; never overwrite\",\n\t\tpromptGuidelines: [\n\t\t\t\"Call write once with path and exactly one of content or contentRef; preparation and collision checks are harness-owned.\",\n\t\t\t\"If a collision result returns payloadRef, choose a new path and reuse that reference instead of regenerating content.\",\n\t\t\t\"Write is create-only; edit existing files. Reuse contentRef for exact copies.\",\n\t\t],\n\t\tparameters: writeSchema,\n\t\tasync execute(_toolCallId, input: WriteToolInput, signal?: AbortSignal, _onUpdate?, _ctx?) {\n\t\t\tconst { path } = input;\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\n\t\t\tconst content = \"content\" in input && typeof input.content === \"string\" ? input.content : undefined;\n\t\t\tconst contentRef =\n\t\t\t\t\"contentRef\" in input && typeof input.contentRef === \"string\" ? input.contentRef : undefined;\n\t\t\tconst payloadRef =\n\t\t\t\t\"payloadRef\" in input && typeof input.payloadRef === \"string\" ? input.payloadRef : undefined;\n\t\t\tif ([content, contentRef, payloadRef].filter((value) => value !== undefined).length !== 1) {\n\t\t\t\tthrow new Error(\"Write requires exactly one of content, contentRef, or payloadRef.\");\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst lease = await intentController.prepare(\"write\", absolutePath, signal, path);\n\t\t\t\treturn await withFileMutationQueue(absolutePath, async () => {\n\t\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t\t};\n\n\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\tawait intentController.assertCurrent(lease, signal);\n\t\t\t\t\tawait ops.mkdir(dirname(absolutePath));\n\t\t\t\t\tthrowIfAborted();\n\n\t\t\t\t\tlet contentReference: FileContentReference;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (content !== undefined) {\n\t\t\t\t\t\t\tawait ops.createFile(absolutePath, content);\n\t\t\t\t\t\t\tcontentReference = intentController.rememberContent(absolutePath, content);\n\t\t\t\t\t\t} else if (contentRef !== undefined) {\n\t\t\t\t\t\t\tcontentReference = await intentController.copyReferencedContent(contentRef, absolutePath, signal);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (payloadRef === undefined) throw new Error(\"Write requires a payload reference.\");\n\t\t\t\t\t\t\tcontentReference = await intentController.copyMutationPayload(payloadRef, absolutePath, signal);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"EEXIST\") {\n\t\t\t\t\t\t\tthrow new FileMutationPreflightError(\n\t\t\t\t\t\t\t\t\"write_collision\",\n\t\t\t\t\t\t\t\t`Write collision: ${path} already exists; no content was overwritten.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t\tthrowIfAborted();\n\n\t\t\t\t\tconst byteCount = contentReference.byteLength;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\t\ttext: `Successfully wrote ${byteCount} bytes to ${path}; this write is complete, so do not call write again for this path. To copy these exact bytes to a different new path, call write once for that path with contentRef ${contentReference.contentRef}.`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\tphase: \"written\" as const,\n\t\t\t\t\t\t\tcontentRef: contentReference.contentRef,\n\t\t\t\t\t\t\tbyteCount,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof FileMutationPreflightError && error.reason === \"write_collision\") {\n\t\t\t\t\tthrow await writeCollisionWithRetainedPayload(error, input, intentController, signal);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst renderArgs = args as\n\t\t\t\t| { path?: string; file_path?: string; content?: string; contentRef?: string; payloadRef?: string }\n\t\t\t\t| undefined;\n\t\t\tconst rawPath = str(renderArgs?.file_path ?? renderArgs?.path);\n\t\t\tconst fileContent = str(renderArgs?.content);\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\t\tif (fileContent !== null) {\n\t\t\t\tcomponent.cache = getWriteHighlightCache(\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\targs,\n\t\t\t\t\trawPath,\n\t\t\t\t\tfileContent,\n\t\t\t\t\tcontext.argsComplete && !context.toolGroupSummary,\n\t\t\t\t\tcontext.expanded,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcomponent.cache = undefined;\n\t\t\t}\n\t\t\tcomponent.setText(\n\t\t\t\tformatWriteCall(\n\t\t\t\t\trenderArgs,\n\t\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\t\tif (!output) {\n\t\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\t\tcomponent.clear();\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(output);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema> {\n\treturn wrapToolDefinition(createWriteToolDefinition(cwd, options));\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export { type CompactionSettings, type DirectoryResourceProfileInfo, getDirector
|
|
|
31
31
|
export { formatSkillsForPrompt, type LoadSkillsFromDirOptions, type LoadSkillsResult, loadSkills, loadSkillsFromDir, type Skill, type SkillFrontmatter, } from "./core/skills.ts";
|
|
32
32
|
export { createSyntheticSourceInfo } from "./core/source-info.ts";
|
|
33
33
|
export { type AskQuestion, type AskQuestionAnswer, AskQuestionDialog, type AskQuestionStopReason, type AskQuestionToolDetails, type AskQuestionToolInput, type AskQuestionToolOptions, createAskQuestionToolDefinition, } from "./core/tools/ask-question.ts";
|
|
34
|
-
export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashToolDefinition, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createReadToolDefinition, createSecretStoreToolDefinition, createWriteToolDefinition, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, type FileContentReference, FileMutationIntentController, type FileMutationIntentControllerOptions, type FileMutationIntentOperations, type FileMutationKind, type FileMutationLease, type FilePathIdentity, type FilePathInspection, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, formatSize, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, type SecretStoreStatus, type SecretStoreToolDetails, type SecretStoreToolInput, type SecretStoreToolOptions, type ToolsOptions, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, type WriteOperations, type WriteToolDetails, type WriteToolInput, type WriteToolOptions, withFileMutationQueue, } from "./core/tools/index.ts";
|
|
34
|
+
export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashToolDefinition, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createReadToolDefinition, createSecretStoreToolDefinition, createWriteToolDefinition, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, type FileContentReference, FileMutationIntentController, type FileMutationIntentControllerOptions, type FileMutationIntentOperations, type FileMutationKind, type FileMutationLease, type FileMutationPayloadReference, FileMutationPreflightError, type FileMutationPreflightFailureReason, type FilePathIdentity, type FilePathInspection, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, formatSize, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, type SecretStoreStatus, type SecretStoreToolDetails, type SecretStoreToolInput, type SecretStoreToolOptions, type ToolsOptions, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, type WriteOperations, type WriteToolDetails, type WriteToolInput, type WriteToolOptions, withFileMutationQueue, } from "./core/tools/index.ts";
|
|
35
35
|
export { jaccard, runSkillAudit, type SkillAuditReport, type SkillSummary, tokenize, } from "./core/tools/skill-audit.ts";
|
|
36
36
|
export { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from "./core/trust-manager.ts";
|
|
37
37
|
export { type MainOptions, main } from "./main.ts";
|