@caupulican/pi-adaptative 0.93.3 → 0.93.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 +16 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +15 -9
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +1 -0
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +4 -1
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/composite-tool-gate.d.ts +13 -0
- package/dist/core/autonomy/composite-tool-gate.d.ts.map +1 -0
- package/dist/core/autonomy/composite-tool-gate.js +44 -0
- package/dist/core/autonomy/composite-tool-gate.js.map +1 -0
- package/dist/core/autonomy/envelope-enforcement.d.ts +2 -0
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js +48 -7
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +48 -76
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/path-scope.d.ts.map +1 -1
- package/dist/core/autonomy/path-scope.js +7 -7
- package/dist/core/autonomy/path-scope.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +2 -0
- package/dist/core/background-tool-task-controller.d.ts.map +1 -1
- package/dist/core/background-tool-task-controller.js +13 -5
- package/dist/core/background-tool-task-controller.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +3 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +132 -97
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/delegation/session-root-mailbox.d.ts.map +1 -1
- package/dist/core/delegation/session-root-mailbox.js +14 -1
- package/dist/core/delegation/session-root-mailbox.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +6 -9
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +3 -2
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +10 -8
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +2 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +18 -9
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +3 -5
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +6 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +1 -0
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +2 -0
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +1 -1
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +32 -9
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js +5 -5
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
- package/dist/core/orchestration/policy-compiler.js +7 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/profile-registry.js +2 -2
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/pipelines/active-context.d.ts +16 -0
- package/dist/core/pipelines/active-context.d.ts.map +1 -0
- package/dist/core/pipelines/active-context.js +29 -0
- package/dist/core/pipelines/active-context.js.map +1 -0
- package/dist/core/pipelines/context.d.ts +1 -1
- package/dist/core/pipelines/context.d.ts.map +1 -1
- package/dist/core/pipelines/context.js +40 -31
- package/dist/core/pipelines/context.js.map +1 -1
- package/dist/core/pipelines/discover.d.ts +5 -1
- package/dist/core/pipelines/discover.d.ts.map +1 -1
- package/dist/core/pipelines/discover.js +91 -33
- package/dist/core/pipelines/discover.js.map +1 -1
- package/dist/core/pipelines/increment.d.ts +0 -2
- package/dist/core/pipelines/increment.d.ts.map +1 -1
- package/dist/core/pipelines/increment.js +35 -13
- package/dist/core/pipelines/increment.js.map +1 -1
- package/dist/core/pipelines/index.d.ts +4 -3
- package/dist/core/pipelines/index.d.ts.map +1 -1
- package/dist/core/pipelines/index.js +4 -3
- package/dist/core/pipelines/index.js.map +1 -1
- package/dist/core/pipelines/run-state.d.ts +8 -0
- package/dist/core/pipelines/run-state.d.ts.map +1 -1
- package/dist/core/pipelines/run-state.js +172 -38
- package/dist/core/pipelines/run-state.js.map +1 -1
- package/dist/core/pipelines/types.d.ts +2 -0
- package/dist/core/pipelines/types.d.ts.map +1 -1
- package/dist/core/pipelines/types.js +21 -4
- package/dist/core/pipelines/types.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +2 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +46 -10
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +1 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +25 -1
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +6 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts +2 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -1
- package/dist/core/tasks/task-projection.js +2 -0
- package/dist/core/tasks/task-projection.js.map +1 -1
- package/dist/core/tasks/task-state.d.ts +10 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +43 -2
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -3
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js +136 -28
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +45 -7
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +4 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +17 -1
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +1 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -1
- package/dist/core/tools/persistent-process-coordinator.js +12 -7
- package/dist/core/tools/persistent-process-coordinator.js.map +1 -1
- package/dist/core/tools/pipeline.d.ts +1 -0
- package/dist/core/tools/pipeline.d.ts.map +1 -1
- package/dist/core/tools/pipeline.js +95 -44
- package/dist/core/tools/pipeline.js.map +1 -1
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js +2 -1
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts.map +1 -1
- package/dist/core/tools/shell-session.js +6 -1
- package/dist/core/tools/shell-session.js.map +1 -1
- package/dist/core/tools/task-steps.d.ts +10 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +70 -29
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +6 -1
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/util/bounded-file.d.ts +8 -0
- package/dist/core/util/bounded-file.d.ts.map +1 -1
- package/dist/core/util/bounded-file.js +81 -16
- package/dist/core/util/bounded-file.js.map +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/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-session.js","sourceRoot":"","sources":["../../../src/core/tools/shell-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAwC,KAAK,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EACN,+BAA+B,EAC/B,eAAe,EACf,oBAAoB,EACpB,+BAA+B,EAC/B,sCAAsC,EACtC,+BAA+B,GAC/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACN,6BAA6B,EAC7B,cAAc,EACd,WAAW,EAEX,mCAAmC,GAEnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAEnF,OAAO,EACN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,EAAE,CAAC;QACxB,IAAI,CAAC,eAAe,EAAE,CAAC;IACxB,CAAC;CACD;AAED,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkC,CAAC;AAEhE,iGAAiG;AACjG,MAAM,UAAU,6BAA6B,CAAC,GAAW,EAAE,IAA2B;IACrF,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IAC/D,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACtD,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,6BAA6B,CAAC,GAAW;IACxD,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,OAAO,EAAE,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Persistent shell sessions for the bash tool.\n *\n * One long-lived shell process per agent (keyed registry) replaces process-per-command spawning.\n * On Windows every command previously paid a full PowerShell boot; a persistent session pays it\n * once. Shell state (current directory, environment variables) persists across an agent's\n * commands; each key gets an isolated session so concurrently running agents never share state.\n *\n * Protocol: commands stream to the session over stdin and are terminated by a per-command\n * sentinel carrying a random nonce and the exit code. Bash wraps commands in an eval of a quoted\n * heredoc (arbitrary content stays data; syntax errors stay contained in eval); PowerShell runs a\n * ReadLine loop decoding base64 lines (no external binaries involved). On bash, command stderr is\n * merged into stdout at the shell so sentinel ordering is guaranteed on one pipe.\n *\n * PowerShell runs each command as a bare `Invoke-Expression`, NOT piped into `Out-Default`: piping\n * a native command's output into another pipeline stage forces PowerShell's NativeCommandProcessor\n * to capture that child's stdout/stderr into an internal pipe and read it to EOF before the\n * pipeline completes. A detached grandchild that inherited those handles (e.g. `start /b` holding\n * stdio open) then keeps that internal pipe's write end open, so the sentinel — written after the\n * pipeline \"completes\" — waits for the grandchild to die instead of the direct child. The bare\n * invocation lets a native command's stdout/stderr handles be inherited directly by the child\n * process; the direct child's own exit is what unblocks the sentinel line, exactly like the\n * per-command backend and like bash's stdio inheritance above. The bounded consequence: a native\n * command's stderr no longer merges into the session's stdout pipe (there is no capturing pipeline\n * stage to merge it) — it arrives on the session's own stderr pipe instead. A nonce-bearing barrier\n * on that pipe joins it deterministically with the stdout completion frame before the command\n * resolves. PowerShell 5.1's habit of wrapping redirected stderr text in a `NativeCommandError`\n * record also disappears, which is an accuracy improvement (the raw stderr bytes are reported,\n * not a wrapped/duplicated rendering of them).\n *\n * Kill semantics: timeout/abort/silence kill the WHOLE session process tree (a hung foreground\n * command cannot be killed individually without job control) and the next exec respawns a fresh\n * session, losing accumulated shell state by design. A command that exits the shell itself\n * (`exit 3`) reports the shell's exit code and also respawns lazily afterwards.\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { basename } from \"node:path\";\nimport { createSilenceWatchdog } from \"@caupulican/pi-agent-core/reliability\";\nimport { type ChildProcess, type SpawnOptions, spawn } from \"child_process\";\nimport {\n\tcreatePowerShellHostEnvironment,\n\tPOWERSHELL_ARGS,\n\tPOWERSHELL_BOOTSTRAP,\n\tPOWERSHELL_SESSION_READY_MARKER,\n\tPOWERSHELL_SESSION_STDERR_READY_MARKER,\n\tPOWERSHELL_STDERR_BARRIER_LABEL,\n} from \"../../utils/powershell-session-protocol.ts\";\nimport {\n\tgetPowerShellCandidateConfigs,\n\tgetShellConfig,\n\tgetShellEnv,\n\ttype PlatformShellToolName,\n\tPOWERSHELL_STARTUP_PROBE_TIMEOUT_MS,\n\ttype ShellConfig,\n} from \"../../utils/shell.ts\";\nimport { claimCliPowerShellWarmStart } from \"./early-powershell-session.ts\";\nimport { PersistentProcessCoordinator } from \"./persistent-process-coordinator.ts\";\n\nexport {\n\tPOWERSHELL_SESSION_READY_MARKER,\n\tPOWERSHELL_SESSION_STDERR_READY_MARKER,\n} from \"../../utils/powershell-session-protocol.ts\";\n\nconst SENTINEL_BYTE = 0x1e;\n/** Longest possible sentinel: \"\\n\" + 0x1e + 16-hex nonce + \":\" + exit code digits + 0x1e. */\nconst SENTINEL_HOLDBACK_BYTES = 64;\nconst MAX_STARTUP_DIAGNOSTIC_BYTES = 16 * 1024;\nconst POWERSHELL_SESSION_READY_BYTES = Buffer.from(POWERSHELL_SESSION_READY_MARKER, \"latin1\");\nconst POWERSHELL_SESSION_STDERR_READY_BYTES = Buffer.from(POWERSHELL_SESSION_STDERR_READY_MARKER, \"latin1\");\n\nexport interface ShellSessionExecOptions {\n\tonData: (data: Buffer) => void;\n\tsignal?: AbortSignal;\n\t/** Wall-clock bound in seconds; when set, a breach kills the session and throws `timeout:<s>`. */\n\ttimeoutSeconds?: number;\n\t/** Output-silence bound in ms; when set, silence kills the session and throws `silence:<s>`. */\n\tsilenceMs?: number;\n\tenv?: NodeJS.ProcessEnv;\n}\n\nexport interface PersistentShellSessionOptions {\n\tresolvePowerShellCandidates?: () => ShellConfig[];\n\tspawn?: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\tstartupTimeoutMs?: number;\n}\n\nfunction escapeSingleQuotesPosix(value: string): string {\n\treturn value.replace(/'/g, \"'\\\\''\");\n}\n\nfunction escapeSingleQuotesPowerShell(value: string): string {\n\treturn value.replace(/'/g, \"''\");\n}\n\n/**\n * The whole command is heredoc-quoted data: eval keeps syntax errors contained (a raw syntax\n * error on the session's stdin would abort the shell), and the random delimiter makes content\n * collisions with agent output practically impossible. `< /dev/null` gives commands the same\n * EOF-stdin the per-command backend's `stdio: [\"ignore\", ...]` provided.\n */\nexport function buildBashWire(command: string, nonce: string, cdTo: string | null): string {\n\tconst body = cdTo ? `command cd -- '${escapeSingleQuotesPosix(cdTo)}' && {\\n${command}\\n}` : command;\n\treturn [\n\t\t`{ eval \"$(cat <<'PI_EOF_${nonce}'`,\n\t\tbody,\n\t\t`PI_EOF_${nonce}`,\n\t\t`)\"; } < /dev/null 2>&1`,\n\t\t`printf '\\\\n\\\\036%s:%s\\\\036' '${nonce}' \"$?\"`,\n\t\t\"\",\n\t].join(\"\\n\");\n}\n\n/** One protocol line: `<nonce> <base64(utf8 command)>`. Base64 keeps arbitrary multi-line commands line-safe. */\nexport function buildPowerShellWire(command: string, nonce: string, cdTo: string | null): string {\n\tconst body = cdTo\n\t\t? `Set-Location -LiteralPath '${escapeSingleQuotesPowerShell(cdTo)}' -ErrorAction Stop\\n${command}`\n\t\t: command;\n\treturn `${nonce} ${Buffer.from(body, \"utf8\").toString(\"base64\")}\\n`;\n}\n\nfunction shallowEnvEquals(a: NodeJS.ProcessEnv, b: NodeJS.ProcessEnv): boolean {\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\tif (aKeys.length !== bKeys.length) return false;\n\tfor (const key of aKeys) {\n\t\tif (a[key] !== b[key]) return false;\n\t}\n\treturn true;\n}\n\nfunction buildPowerShellEnvironmentPrelude(current: NodeJS.ProcessEnv, desired: NodeJS.ProcessEnv): string | null {\n\tconst currentByName = new Map(\n\t\tObject.entries(current)\n\t\t\t.filter((entry): entry is [string, string] => entry[1] !== undefined)\n\t\t\t.map(([name, value]) => [name.toLowerCase(), { name, value }]),\n\t);\n\tconst desiredByName = new Map(\n\t\tObject.entries(desired)\n\t\t\t.filter((entry): entry is [string, string] => entry[1] !== undefined)\n\t\t\t.map(([name, value]) => [name.toLowerCase(), { name, value }]),\n\t);\n\tconst setValues = [...desiredByName.entries()].flatMap(([identity, entry]) =>\n\t\tcurrentByName.get(identity)?.value === entry.value ? [] : [entry],\n\t);\n\tconst removeNames = [...currentByName.entries()].flatMap(([identity, entry]) =>\n\t\tdesiredByName.has(identity) ? [] : [entry.name],\n\t);\n\tif (setValues.length === 0 && removeNames.length === 0) return null;\n\tconst encoded = Buffer.from(JSON.stringify({ setValues, removeNames }), \"utf8\").toString(\"base64\");\n\treturn [\n\t\t`$__pi_env_delta = ConvertFrom-Json ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${encoded}')))`,\n\t\t\"foreach ($__pi_env_item in @($__pi_env_delta.setValues)) { [System.Environment]::SetEnvironmentVariable([string]$__pi_env_item.name, [string]$__pi_env_item.value, 'Process') }\",\n\t\t\"foreach ($__pi_env_name in @($__pi_env_delta.removeNames)) { [System.Environment]::SetEnvironmentVariable([string]$__pi_env_name, $null, 'Process') }\",\n\t\t\"Remove-Variable -Name __pi_env_delta,__pi_env_item,__pi_env_name -ErrorAction SilentlyContinue\",\n\t].join(\"\\n\");\n}\n\ninterface ActiveExec {\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 PersistentShellSession {\n\tprivate readonly key: string;\n\tprivate readonly kind: PlatformShellToolName;\n\tprivate readonly resolvePowerShellCandidates: () => ShellConfig[];\n\tprivate readonly spawnProcess: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\tprivate readonly startupTimeoutMs: number;\n\tprivate readonly coordinator = new PersistentProcessCoordinator();\n\tprivate childEnv: NodeJS.ProcessEnv | null = null;\n\tprivate lastRequestedCwd: string | null = null;\n\tprivate activeExec: ActiveExec | null = null;\n\tprivate rejectStartup: ((error: Error) => void) | null = null;\n\tprivate disposed = false;\n\n\tconstructor(key: string, kind: PlatformShellToolName, options: PersistentShellSessionOptions = {}) {\n\t\tthis.key = key;\n\t\tthis.kind = kind;\n\t\tthis.resolvePowerShellCandidates = options.resolvePowerShellCandidates ?? getPowerShellCandidateConfigs;\n\t\tthis.spawnProcess = options.spawn ?? spawn;\n\t\tthis.startupTimeoutMs = options.startupTimeoutMs ?? POWERSHELL_STARTUP_PROBE_TIMEOUT_MS;\n\t}\n\n\tget sessionKind(): PlatformShellToolName {\n\t\treturn this.kind;\n\t}\n\n\t/** Serialized: one command at a time per session, later calls queue behind earlier ones. */\n\texec(command: string, cwd: string, options: ShellSessionExecOptions): Promise<{ exitCode: number | null }> {\n\t\treturn this.coordinator.runSerialized(() => this.execNow(command, cwd, options));\n\t}\n\n\t/** Start and validate the long-lived shell before the first user command. Idempotent per session. */\n\tprewarm(cwd: string, env: NodeJS.ProcessEnv = getShellEnv()): Promise<void> {\n\t\treturn this.coordinator.runSerialized(async () => {\n\t\t\tif (this.disposed) throw new Error(`Shell session \"${this.key}\" is disposed`);\n\t\t\tconst resolvedEnv = this.kind === \"powershell\" ? createPowerShellHostEnvironment(env) : env;\n\t\t\tif (\n\t\t\t\tthis.kind !== \"powershell\" &&\n\t\t\t\tthis.coordinator.child &&\n\t\t\t\tthis.childEnv &&\n\t\t\t\t!shallowEnvEquals(this.childEnv, resolvedEnv)\n\t\t\t) {\n\t\t\t\tthis.killChild();\n\t\t\t}\n\t\t\tif (!this.coordinator.child) await this.spawnChild(cwd, resolvedEnv);\n\t\t\tif (\n\t\t\t\tthis.kind === \"powershell\" &&\n\t\t\t\tthis.childEnv &&\n\t\t\t\t(!shallowEnvEquals(this.childEnv, resolvedEnv) || this.lastRequestedCwd !== cwd)\n\t\t\t) {\n\t\t\t\tconst result = await this.execNow(\"\", cwd, { onData: () => {}, env: resolvedEnv });\n\t\t\t\tif (result.exitCode !== 0) {\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tthrow new Error(`PowerShell session reconciliation failed with exit code ${result.exitCode ?? \"null\"}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.coordinator.setLoopRef(false);\n\t\t});\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.rejectStartup?.(new Error(`Shell session \"${this.key}\" is disposed`));\n\t\tthis.activeExec?.fail(new Error(`Shell session \"${this.key}\" is disposed`));\n\t\tthis.coordinator.dispose();\n\t\tthis.resetChildState();\n\t}\n\n\tprivate async execNow(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\t{ onData, signal, timeoutSeconds, silenceMs, env }: ShellSessionExecOptions,\n\t): Promise<{ exitCode: number | null }> {\n\t\tif (this.disposed) throw new Error(`Shell session \"${this.key}\" is disposed`);\n\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\n\t\tconst requestedEnv = env ?? getShellEnv();\n\t\tconst resolvedEnv = this.kind === \"powershell\" ? createPowerShellHostEnvironment(requestedEnv) : requestedEnv;\n\t\t// The environment is spawn-time shell config: an env that differs from the running\n\t\t// session's (e.g. a spawn hook rewriting it per command) requires a fresh shell.\n\t\tif (\n\t\t\tthis.kind !== \"powershell\" &&\n\t\t\tthis.coordinator.child &&\n\t\t\tthis.childEnv &&\n\t\t\t!shallowEnvEquals(this.childEnv, resolvedEnv)\n\t\t) {\n\t\t\tthis.killChild();\n\t\t}\n\n\t\t// Re-enter the host-requested cwd only when it CHANGES between calls; an unchanged\n\t\t// request preserves the agent's own in-session `cd` (that persistence is the feature).\n\t\tlet cdTo: string | null = null;\n\t\tif (!this.coordinator.child) await this.spawnChild(cwd, resolvedEnv);\n\t\tif (this.lastRequestedCwd !== cwd) cdTo = cwd;\n\t\tthis.lastRequestedCwd = cwd;\n\t\tlet resolvedCommand = command;\n\t\tif (this.kind === \"powershell\" && this.childEnv && !shallowEnvEquals(this.childEnv, resolvedEnv)) {\n\t\t\tconst environmentPrelude = buildPowerShellEnvironmentPrelude(this.childEnv, resolvedEnv);\n\t\t\tif (environmentPrelude) resolvedCommand = `${environmentPrelude}\\n${command}`;\n\t\t\tthis.childEnv = { ...resolvedEnv };\n\t\t}\n\n\t\tconst child = this.coordinator.child;\n\t\tif (!child?.stdin || !child.stdout || !child.stderr) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(`Failed to start ${this.kind} session`);\n\t\t}\n\n\t\tconst nonce = randomBytes(8).toString(\"hex\");\n\t\tconst wire =\n\t\t\tthis.kind === \"powershell\"\n\t\t\t\t? buildPowerShellWire(resolvedCommand, nonce, cdTo)\n\t\t\t\t: buildBashWire(resolvedCommand, nonce, cdTo);\n\t\tconst sentinelPrefix = Buffer.from(`\\n\\x1e${nonce}:`, \"latin1\");\n\t\tconst stderrBarrier = Buffer.from(`\\x1e${nonce}:${POWERSHELL_STDERR_BARRIER_LABEL}\\x1e\\n`, \"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 stdoutPending: Buffer = Buffer.alloc(0);\n\t\t\t\tlet stderrPending: Buffer = Buffer.alloc(0);\n\t\t\t\tlet commandExitCode: number | null | undefined;\n\t\t\t\tlet stderrBarrierSeen = this.kind !== \"powershell\";\n\t\t\t\tlet timeoutTimer: NodeJS.Timeout | undefined;\n\n\t\t\t\tconst silenceWatchdog =\n\t\t\t\t\ttimeoutSeconds === undefined && silenceMs !== undefined && silenceMs > 0\n\t\t\t\t\t\t? createSilenceWatchdog({\n\t\t\t\t\t\t\t\tsilenceMs,\n\t\t\t\t\t\t\t\tonSilence: () => {\n\t\t\t\t\t\t\t\t\tthis.killChild();\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(`silence:${silenceMs / 1000}`)));\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tconst settle = (finish: () => 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\tsilenceWatchdog?.disarm();\n\t\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tthis.activeExec = null;\n\t\t\t\t\tfinish();\n\t\t\t\t};\n\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tsettle(() => reject(new Error(\"aborted\")));\n\t\t\t\t};\n\n\t\t\t\tconst emitStdoutPending = (upTo: number) => {\n\t\t\t\t\tif (upTo <= 0) return;\n\t\t\t\t\tonData(stdoutPending.subarray(0, upTo));\n\t\t\t\t\tstdoutPending = stdoutPending.subarray(upTo);\n\t\t\t\t};\n\t\t\t\tconst emitStderrPending = (upTo: number) => {\n\t\t\t\t\tif (upTo <= 0) return;\n\t\t\t\t\tonData(stderrPending.subarray(0, upTo));\n\t\t\t\t\tstderrPending = stderrPending.subarray(upTo);\n\t\t\t\t};\n\t\t\t\tconst resolveWhenComplete = () => {\n\t\t\t\t\tconst exitCode = commandExitCode;\n\t\t\t\t\tif (exitCode === undefined || !stderrBarrierSeen) return;\n\t\t\t\t\tsettle(() => resolve({ exitCode }));\n\t\t\t\t};\n\n\t\t\t\tthis.activeExec = {\n\t\t\t\t\tonStdout: (data) => {\n\t\t\t\t\t\tsilenceWatchdog?.touch();\n\t\t\t\t\t\tif (commandExitCode !== undefined) {\n\t\t\t\t\t\t\tonData(data);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstdoutPending = stdoutPending.length === 0 ? data : Buffer.concat([stdoutPending, data]);\n\t\t\t\t\t\tconst prefixIndex = stdoutPending.indexOf(sentinelPrefix);\n\t\t\t\t\t\tif (prefixIndex !== -1) {\n\t\t\t\t\t\t\tconst closeIndex = stdoutPending.indexOf(SENTINEL_BYTE, prefixIndex + sentinelPrefix.length);\n\t\t\t\t\t\t\tif (closeIndex !== -1) {\n\t\t\t\t\t\t\t\tconst codeText = stdoutPending\n\t\t\t\t\t\t\t\t\t.subarray(prefixIndex + sentinelPrefix.length, closeIndex)\n\t\t\t\t\t\t\t\t\t.toString(\"latin1\");\n\t\t\t\t\t\t\t\temitStdoutPending(prefixIndex);\n\t\t\t\t\t\t\t\tstdoutPending = stdoutPending.subarray(closeIndex - prefixIndex + 1);\n\t\t\t\t\t\t\t\temitStdoutPending(stdoutPending.length);\n\t\t\t\t\t\t\t\tconst parsed = Number.parseInt(codeText, 10);\n\t\t\t\t\t\t\t\tcommandExitCode = Number.isNaN(parsed) ? null : parsed;\n\t\t\t\t\t\t\t\tresolveWhenComplete();\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Stream promptly but retain a tail large enough to hold any split sentinel.\n\t\t\t\t\t\temitStdoutPending(stdoutPending.length - SENTINEL_HOLDBACK_BYTES);\n\t\t\t\t\t},\n\t\t\t\t\tonStderr: (data) => {\n\t\t\t\t\t\tsilenceWatchdog?.touch();\n\t\t\t\t\t\tif (this.kind !== \"powershell\" || stderrBarrierSeen) {\n\t\t\t\t\t\t\tonData(data);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstderrPending = stderrPending.length === 0 ? data : Buffer.concat([stderrPending, data]);\n\t\t\t\t\t\tconst barrierIndex = stderrPending.indexOf(stderrBarrier);\n\t\t\t\t\t\tif (barrierIndex !== -1) {\n\t\t\t\t\t\t\temitStderrPending(barrierIndex);\n\t\t\t\t\t\t\tstderrPending = stderrPending.subarray(stderrBarrier.length);\n\t\t\t\t\t\t\temitStderrPending(stderrPending.length);\n\t\t\t\t\t\t\tstderrBarrierSeen = true;\n\t\t\t\t\t\t\tresolveWhenComplete();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Preserve enough bytes to recognize a barrier split across chunks.\n\t\t\t\t\t\temitStderrPending(stderrPending.length - stderrBarrier.length + 1);\n\t\t\t\t\t},\n\t\t\t\t\tonChildClose: (code) => {\n\t\t\t\t\t\t// The command terminated the shell itself (e.g. `exit 3`) or the shell\n\t\t\t\t\t\t// crashed: report its exit code like the per-command backend would.\n\t\t\t\t\t\temitStdoutPending(stdoutPending.length);\n\t\t\t\t\t\temitStderrPending(stderrPending.length);\n\t\t\t\t\t\tsettle(() => resolve({ exitCode: code }));\n\t\t\t\t\t},\n\t\t\t\t\tfail: (error) => {\n\t\t\t\t\t\tthis.killChild();\n\t\t\t\t\t\tsettle(() => reject(error));\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tif (signal) signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tif (timeoutSeconds !== undefined && timeoutSeconds > 0) {\n\t\t\t\t\ttimeoutTimer = setTimeout(() => {\n\t\t\t\t\t\tthis.killChild();\n\t\t\t\t\t\tsettle(() => reject(new Error(`timeout:${timeoutSeconds}`)));\n\t\t\t\t\t}, timeoutSeconds * 1000);\n\t\t\t\t}\n\n\t\t\t\tchild.stdin?.write(wire, (error) => {\n\t\t\t\t\tif (!error) return;\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tsettle(() => reject(new Error(`Failed to write to ${this.kind} session: ${error.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 spawnChild(cwd: string, env: NodeJS.ProcessEnv): Promise<void> {\n\t\tlet spawnedCwd = cwd;\n\t\tlet spawnedEnv = env;\n\t\tif (this.kind === \"powershell\") {\n\t\t\t({ cwd: spawnedCwd, env: spawnedEnv } = await this.spawnPowerShellChild(cwd, env));\n\t\t} else {\n\t\t\tconst { shell } = getShellConfig(undefined, this.kind);\n\t\t\tconst args = basename(shell).toLowerCase().includes(\"bash\") ? [\"--noprofile\", \"--norc\"] : [];\n\t\t\tconst child = this.spawnProcess(shell, args, {\n\t\t\t\tcwd,\n\t\t\t\tenv,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tthis.attachReadyChild(child);\n\t\t}\n\t\tthis.childEnv = { ...spawnedEnv };\n\t\tthis.lastRequestedCwd = spawnedCwd;\n\t}\n\n\tprivate async spawnPowerShellChild(\n\t\tcwd: string,\n\t\tenv: NodeJS.ProcessEnv,\n\t): Promise<{ cwd: string; env: NodeJS.ProcessEnv }> {\n\t\tconst warmStart = await claimCliPowerShellWarmStart();\n\t\tif (warmStart) {\n\t\t\ttry {\n\t\t\t\tthis.attachReadyChild(warmStart.child);\n\t\t\t} finally {\n\t\t\t\twarmStart.releaseStartupListeners();\n\t\t\t}\n\t\t\treturn { cwd: warmStart.cwd, env: warmStart.env };\n\t\t}\n\t\tconst failures: string[] = [];\n\t\tfor (const candidate of this.resolvePowerShellCandidates()) {\n\t\t\ttry {\n\t\t\t\tawait this.spawnPowerShellCandidate(candidate.shell, cwd, env);\n\t\t\t\treturn { cwd, env };\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tfailures.push(`${candidate.shell}: ${message}`);\n\t\t\t}\n\t\t}\n\t\tconst detail = failures.length > 0 ? ` Candidate failures: ${failures.join(\"; \")}` : \"\";\n\t\tthrow new Error(`PowerShell 7 (pwsh) was not found. Install pwsh before using the Windows shell.${detail}`);\n\t}\n\n\tprivate spawnPowerShellCandidate(shell: string, cwd: string, env: NodeJS.ProcessEnv): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\tlet startupSettled = false;\n\t\t\tlet startupStdout: Buffer = Buffer.alloc(0);\n\t\t\tlet startupStderr: Buffer = Buffer.alloc(0);\n\t\t\tlet stdoutReady = false;\n\t\t\tlet stderrReady = false;\n\t\t\tlet timeoutTimer: NodeJS.Timeout | undefined;\n\n\t\t\tconst settleStartup = (finish: () => void): void => {\n\t\t\t\tif (startupSettled) return;\n\t\t\t\tstartupSettled = true;\n\t\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\t\tif (this.rejectStartup === rejectStartup) this.rejectStartup = null;\n\t\t\t\tfinish();\n\t\t\t};\n\t\t\tconst startupDiagnostic = (): string => {\n\t\t\t\tconst combined = Buffer.concat([startupStdout, startupStderr]).toString(\"utf8\").trim();\n\t\t\t\treturn combined ? `: ${combined}` : \"\";\n\t\t\t};\n\t\t\tconst rejectStartup = (error: Error): void => {\n\t\t\t\tsettleStartup(() => reject(error));\n\t\t\t};\n\t\t\tconst resolveWhenReady = (): void => {\n\t\t\t\tif (!stdoutReady || !stderrReady) return;\n\t\t\t\tsettleStartup(resolve);\n\t\t\t};\n\n\t\t\tlet child: ChildProcess;\n\t\t\ttry {\n\t\t\t\tchild = this.spawnProcess(shell, [...POWERSHELL_ARGS, POWERSHELL_BOOTSTRAP], {\n\t\t\t\t\tcwd,\n\t\t\t\t\tenv,\n\t\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t\t\twindowsHide: true,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\trejectStartup(new Error(`spawn failed: ${message}`));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.rejectStartup = rejectStartup;\n\t\t\tthis.coordinator.attach(child, {\n\t\t\t\tonStdout: (data) => {\n\t\t\t\t\tif (startupSettled) {\n\t\t\t\t\t\tthis.activeExec?.onStdout(data);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tstartupStdout =\n\t\t\t\t\t\tstartupStdout.length === 0\n\t\t\t\t\t\t\t? data\n\t\t\t\t\t\t\t: Buffer.concat([startupStdout, data]).subarray(-MAX_STARTUP_DIAGNOSTIC_BYTES);\n\t\t\t\t\tstdoutReady ||= startupStdout.indexOf(POWERSHELL_SESSION_READY_BYTES) !== -1;\n\t\t\t\t\tresolveWhenReady();\n\t\t\t\t},\n\t\t\t\tonStderr: (data) => {\n\t\t\t\t\tif (startupSettled) {\n\t\t\t\t\t\tthis.activeExec?.onStderr(data);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tstartupStderr =\n\t\t\t\t\t\tstartupStderr.length === 0\n\t\t\t\t\t\t\t? data\n\t\t\t\t\t\t\t: Buffer.concat([startupStderr, data]).subarray(-MAX_STARTUP_DIAGNOSTIC_BYTES);\n\t\t\t\t\tstderrReady ||= startupStderr.indexOf(POWERSHELL_SESSION_STDERR_READY_BYTES) !== -1;\n\t\t\t\t\tresolveWhenReady();\n\t\t\t\t},\n\t\t\t\tonError: (error) => {\n\t\t\t\t\tthis.resetChildState();\n\t\t\t\t\tif (!startupSettled) rejectStartup(new Error(`${error.message}${startupDiagnostic()}`));\n\t\t\t\t\telse this.activeExec?.fail(error);\n\t\t\t\t},\n\t\t\t\tonClose: (code) => {\n\t\t\t\t\tthis.resetChildState();\n\t\t\t\t\tif (!startupSettled) {\n\t\t\t\t\t\trejectStartup(new Error(`exited with code ${code ?? \"null\"} before readiness${startupDiagnostic()}`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.activeExec?.onChildClose(code);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t\ttimeoutTimer = setTimeout(() => {\n\t\t\t\tthis.coordinator.kill();\n\t\t\t\tthis.resetChildState();\n\t\t\t\trejectStartup(new Error(`startup timed out after ${this.startupTimeoutMs}ms${startupDiagnostic()}`));\n\t\t\t}, this.startupTimeoutMs);\n\t\t});\n\t}\n\n\tprivate attachReadyChild(child: ChildProcess): void {\n\t\tthis.coordinator.attach(child, {\n\t\t\tonStdout: (data) => this.activeExec?.onStdout(data),\n\t\t\tonStderr: (data) => this.activeExec?.onStderr(data),\n\t\t\tonError: (error) => {\n\t\t\t\tthis.resetChildState();\n\t\t\t\tthis.activeExec?.fail(error);\n\t\t\t},\n\t\t\tonClose: (code) => {\n\t\t\t\tthis.resetChildState();\n\t\t\t\tthis.activeExec?.onChildClose(code);\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate resetChildState(): void {\n\t\tthis.childEnv = null;\n\t\tthis.lastRequestedCwd = null;\n\t}\n\n\tprivate killChild(): void {\n\t\tthis.coordinator.kill();\n\t\tthis.resetChildState();\n\t}\n}\n\nconst shellSessions = new Map<string, PersistentShellSession>();\n\n/** Get or lazily create the persistent session for a key. A kind change replaces the session. */\nexport function acquirePersistentShellSession(key: string, kind: PlatformShellToolName): PersistentShellSession {\n\tconst existing = shellSessions.get(key);\n\tif (existing && existing.sessionKind === kind) return existing;\n\texisting?.dispose();\n\tconst session = new PersistentShellSession(key, kind);\n\tshellSessions.set(key, session);\n\treturn session;\n}\n\n/** Kill and forget a session (agent teardown). Safe to call for keys that never spawned. */\nexport function disposePersistentShellSession(key: string): void {\n\tconst session = shellSessions.get(key);\n\tif (!session) return;\n\tshellSessions.delete(key);\n\tsession.dispose();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shell-session.js","sourceRoot":"","sources":["../../../src/core/tools/shell-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAwC,KAAK,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EACN,+BAA+B,EAC/B,eAAe,EACf,oBAAoB,EACpB,+BAA+B,EAC/B,sCAAsC,EACtC,+BAA+B,GAC/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACN,6BAA6B,EAC7B,cAAc,EACd,WAAW,EAEX,mCAAmC,GAEnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAEnF,OAAO,EACN,+BAA+B,EAC/B,sCAAsC,GACtC,MAAM,4CAA4C,CAAC;AAEpD,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,6FAA6F;AAC7F,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,4BAA4B,GAAG,EAAE,GAAG,IA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ED,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkC,CAAC;AAEhE,iGAAiG;AACjG,MAAM,UAAU,6BAA6B,CAAC,GAAW,EAAE,IAA2B;IACrF,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IAC/D,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACtD,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,6BAA6B,CAAC,GAAW;IACxD,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,OAAO,EAAE,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Persistent shell sessions for the bash tool.\n *\n * One long-lived shell process per agent (keyed registry) replaces process-per-command spawning.\n * On Windows every command previously paid a full PowerShell boot; a persistent session pays it\n * once. Shell state (current directory, environment variables) persists across an agent's\n * commands; each key gets an isolated session so concurrently running agents never share state.\n *\n * Protocol: commands stream to the session over stdin and are terminated by a per-command\n * sentinel carrying a random nonce and the exit code. Bash wraps commands in an eval of a quoted\n * heredoc (arbitrary content stays data; syntax errors stay contained in eval); PowerShell runs a\n * ReadLine loop decoding base64 lines (no external binaries involved). On bash, command stderr is\n * merged into stdout at the shell so sentinel ordering is guaranteed on one pipe.\n *\n * PowerShell runs each command as a bare `Invoke-Expression`, NOT piped into `Out-Default`: piping\n * a native command's output into another pipeline stage forces PowerShell's NativeCommandProcessor\n * to capture that child's stdout/stderr into an internal pipe and read it to EOF before the\n * pipeline completes. A detached grandchild that inherited those handles (e.g. `start /b` holding\n * stdio open) then keeps that internal pipe's write end open, so the sentinel — written after the\n * pipeline \"completes\" — waits for the grandchild to die instead of the direct child. The bare\n * invocation lets a native command's stdout/stderr handles be inherited directly by the child\n * process; the direct child's own exit is what unblocks the sentinel line, exactly like the\n * per-command backend and like bash's stdio inheritance above. The bounded consequence: a native\n * command's stderr no longer merges into the session's stdout pipe (there is no capturing pipeline\n * stage to merge it) — it arrives on the session's own stderr pipe instead. A nonce-bearing barrier\n * on that pipe joins it deterministically with the stdout completion frame before the command\n * resolves. PowerShell 5.1's habit of wrapping redirected stderr text in a `NativeCommandError`\n * record also disappears, which is an accuracy improvement (the raw stderr bytes are reported,\n * not a wrapped/duplicated rendering of them).\n *\n * Kill semantics: timeout/abort/silence kill the WHOLE session process tree (a hung foreground\n * command cannot be killed individually without job control) and the next exec respawns a fresh\n * session, losing accumulated shell state by design. A command that exits the shell itself\n * (`exit 3`) reports the shell's exit code and also respawns lazily afterwards.\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { basename } from \"node:path\";\nimport { createSilenceWatchdog } from \"@caupulican/pi-agent-core/reliability\";\nimport { type ChildProcess, type SpawnOptions, spawn } from \"child_process\";\nimport {\n\tcreatePowerShellHostEnvironment,\n\tPOWERSHELL_ARGS,\n\tPOWERSHELL_BOOTSTRAP,\n\tPOWERSHELL_SESSION_READY_MARKER,\n\tPOWERSHELL_SESSION_STDERR_READY_MARKER,\n\tPOWERSHELL_STDERR_BARRIER_LABEL,\n} from \"../../utils/powershell-session-protocol.ts\";\nimport {\n\tgetPowerShellCandidateConfigs,\n\tgetShellConfig,\n\tgetShellEnv,\n\ttype PlatformShellToolName,\n\tPOWERSHELL_STARTUP_PROBE_TIMEOUT_MS,\n\ttype ShellConfig,\n} from \"../../utils/shell.ts\";\nimport { claimCliPowerShellWarmStart } from \"./early-powershell-session.ts\";\nimport { PersistentProcessCoordinator } from \"./persistent-process-coordinator.ts\";\n\nexport {\n\tPOWERSHELL_SESSION_READY_MARKER,\n\tPOWERSHELL_SESSION_STDERR_READY_MARKER,\n} from \"../../utils/powershell-session-protocol.ts\";\n\nconst SENTINEL_BYTE = 0x1e;\n/** Longest possible sentinel: \"\\n\" + 0x1e + 16-hex nonce + \":\" + exit code digits + 0x1e. */\nconst SENTINEL_HOLDBACK_BYTES = 64;\nconst MAX_STARTUP_DIAGNOSTIC_BYTES = 16 * 1024;\nconst POWERSHELL_SESSION_READY_BYTES = Buffer.from(POWERSHELL_SESSION_READY_MARKER, \"latin1\");\nconst POWERSHELL_SESSION_STDERR_READY_BYTES = Buffer.from(POWERSHELL_SESSION_STDERR_READY_MARKER, \"latin1\");\n\nexport interface ShellSessionExecOptions {\n\tonData: (data: Buffer) => void;\n\tsignal?: AbortSignal;\n\t/** Wall-clock bound in seconds; when set, a breach kills the session and throws `timeout:<s>`. */\n\ttimeoutSeconds?: number;\n\t/** Output-silence bound in ms; when set, silence kills the session and throws `silence:<s>`. */\n\tsilenceMs?: number;\n\tenv?: NodeJS.ProcessEnv;\n}\n\nexport interface PersistentShellSessionOptions {\n\tresolvePowerShellCandidates?: () => ShellConfig[];\n\tspawn?: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\tstartupTimeoutMs?: number;\n}\n\nfunction escapeSingleQuotesPosix(value: string): string {\n\treturn value.replace(/'/g, \"'\\\\''\");\n}\n\nfunction escapeSingleQuotesPowerShell(value: string): string {\n\treturn value.replace(/'/g, \"''\");\n}\n\n/**\n * The whole command is heredoc-quoted data: eval keeps syntax errors contained (a raw syntax\n * error on the session's stdin would abort the shell), and the random delimiter makes content\n * collisions with agent output practically impossible. `< /dev/null` gives commands the same\n * EOF-stdin the per-command backend's `stdio: [\"ignore\", ...]` provided.\n */\nexport function buildBashWire(command: string, nonce: string, cdTo: string | null): string {\n\tconst body = cdTo ? `command cd -- '${escapeSingleQuotesPosix(cdTo)}' && {\\n${command}\\n}` : command;\n\treturn [\n\t\t`{ eval \"$(cat <<'PI_EOF_${nonce}'`,\n\t\tbody,\n\t\t`PI_EOF_${nonce}`,\n\t\t`)\"; } < /dev/null 2>&1`,\n\t\t`printf '\\\\n\\\\036%s:%s\\\\036' '${nonce}' \"$?\"`,\n\t\t\"\",\n\t].join(\"\\n\");\n}\n\n/** One protocol line: `<nonce> <base64(utf8 command)>`. Base64 keeps arbitrary multi-line commands line-safe. */\nexport function buildPowerShellWire(command: string, nonce: string, cdTo: string | null): string {\n\tconst body = cdTo\n\t\t? `Set-Location -LiteralPath '${escapeSingleQuotesPowerShell(cdTo)}' -ErrorAction Stop\\n${command}`\n\t\t: command;\n\treturn `${nonce} ${Buffer.from(body, \"utf8\").toString(\"base64\")}\\n`;\n}\n\nfunction shallowEnvEquals(a: NodeJS.ProcessEnv, b: NodeJS.ProcessEnv): boolean {\n\tconst aKeys = Object.keys(a);\n\tconst bKeys = Object.keys(b);\n\tif (aKeys.length !== bKeys.length) return false;\n\tfor (const key of aKeys) {\n\t\tif (a[key] !== b[key]) return false;\n\t}\n\treturn true;\n}\n\nfunction buildPowerShellEnvironmentPrelude(current: NodeJS.ProcessEnv, desired: NodeJS.ProcessEnv): string | null {\n\tconst currentByName = new Map(\n\t\tObject.entries(current)\n\t\t\t.filter((entry): entry is [string, string] => entry[1] !== undefined)\n\t\t\t.map(([name, value]) => [name.toLowerCase(), { name, value }]),\n\t);\n\tconst desiredByName = new Map(\n\t\tObject.entries(desired)\n\t\t\t.filter((entry): entry is [string, string] => entry[1] !== undefined)\n\t\t\t.map(([name, value]) => [name.toLowerCase(), { name, value }]),\n\t);\n\tconst setValues = [...desiredByName.entries()].flatMap(([identity, entry]) =>\n\t\tcurrentByName.get(identity)?.value === entry.value ? [] : [entry],\n\t);\n\tconst removeNames = [...currentByName.entries()].flatMap(([identity, entry]) =>\n\t\tdesiredByName.has(identity) ? [] : [entry.name],\n\t);\n\tif (setValues.length === 0 && removeNames.length === 0) return null;\n\tconst encoded = Buffer.from(JSON.stringify({ setValues, removeNames }), \"utf8\").toString(\"base64\");\n\treturn [\n\t\t`$__pi_env_delta = ConvertFrom-Json ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${encoded}')))`,\n\t\t\"foreach ($__pi_env_item in @($__pi_env_delta.setValues)) { [System.Environment]::SetEnvironmentVariable([string]$__pi_env_item.name, [string]$__pi_env_item.value, 'Process') }\",\n\t\t\"foreach ($__pi_env_name in @($__pi_env_delta.removeNames)) { [System.Environment]::SetEnvironmentVariable([string]$__pi_env_name, $null, 'Process') }\",\n\t\t\"Remove-Variable -Name __pi_env_delta,__pi_env_item,__pi_env_name -ErrorAction SilentlyContinue\",\n\t].join(\"\\n\");\n}\n\ninterface ActiveExec {\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 PersistentShellSession {\n\tprivate readonly key: string;\n\tprivate readonly kind: PlatformShellToolName;\n\tprivate readonly resolvePowerShellCandidates: () => ShellConfig[];\n\tprivate readonly spawnProcess: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\tprivate readonly startupTimeoutMs: number;\n\tprivate readonly coordinator = new PersistentProcessCoordinator();\n\tprivate childEnv: NodeJS.ProcessEnv | null = null;\n\tprivate lastRequestedCwd: string | null = null;\n\tprivate activeExec: ActiveExec | null = null;\n\tprivate rejectStartup: ((error: Error) => void) | null = null;\n\tprivate disposed = false;\n\n\tconstructor(key: string, kind: PlatformShellToolName, options: PersistentShellSessionOptions = {}) {\n\t\tthis.key = key;\n\t\tthis.kind = kind;\n\t\tthis.resolvePowerShellCandidates = options.resolvePowerShellCandidates ?? getPowerShellCandidateConfigs;\n\t\tthis.spawnProcess = options.spawn ?? spawn;\n\t\tthis.startupTimeoutMs = options.startupTimeoutMs ?? POWERSHELL_STARTUP_PROBE_TIMEOUT_MS;\n\t}\n\n\tget sessionKind(): PlatformShellToolName {\n\t\treturn this.kind;\n\t}\n\n\t/** Serialized: one command at a time per session, later calls queue behind earlier ones. */\n\texec(command: string, cwd: string, options: ShellSessionExecOptions): Promise<{ exitCode: number | null }> {\n\t\treturn this.coordinator.runSerialized(() => this.execNow(command, cwd, options));\n\t}\n\n\t/** Start and validate the long-lived shell before the first user command. Idempotent per session. */\n\tprewarm(cwd: string, env: NodeJS.ProcessEnv = getShellEnv()): Promise<void> {\n\t\treturn this.coordinator.runSerialized(async () => {\n\t\t\tif (this.disposed) throw new Error(`Shell session \"${this.key}\" is disposed`);\n\t\t\tconst resolvedEnv = this.kind === \"powershell\" ? createPowerShellHostEnvironment(env) : env;\n\t\t\tif (\n\t\t\t\tthis.kind !== \"powershell\" &&\n\t\t\t\tthis.coordinator.child &&\n\t\t\t\tthis.childEnv &&\n\t\t\t\t!shallowEnvEquals(this.childEnv, resolvedEnv)\n\t\t\t) {\n\t\t\t\tthis.killChild();\n\t\t\t}\n\t\t\tif (!this.coordinator.child) await this.spawnChild(cwd, resolvedEnv);\n\t\t\tif (\n\t\t\t\tthis.kind === \"powershell\" &&\n\t\t\t\tthis.childEnv &&\n\t\t\t\t(!shallowEnvEquals(this.childEnv, resolvedEnv) || this.lastRequestedCwd !== cwd)\n\t\t\t) {\n\t\t\t\tconst result = await this.execNow(\"\", cwd, { onData: () => {}, env: resolvedEnv });\n\t\t\t\tif (result.exitCode !== 0) {\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tthrow new Error(`PowerShell session reconciliation failed with exit code ${result.exitCode ?? \"null\"}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.coordinator.setLoopRef(false);\n\t\t});\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.rejectStartup?.(new Error(`Shell session \"${this.key}\" is disposed`));\n\t\tthis.activeExec?.fail(new Error(`Shell session \"${this.key}\" is disposed`));\n\t\tthis.coordinator.dispose();\n\t\tthis.resetChildState();\n\t}\n\n\tprivate async execNow(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\t{ onData, signal, timeoutSeconds, silenceMs, env }: ShellSessionExecOptions,\n\t): Promise<{ exitCode: number | null }> {\n\t\tif (this.disposed) throw new Error(`Shell session \"${this.key}\" is disposed`);\n\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\n\t\tconst requestedEnv = env ?? getShellEnv();\n\t\tconst resolvedEnv = this.kind === \"powershell\" ? createPowerShellHostEnvironment(requestedEnv) : requestedEnv;\n\t\t// The environment is spawn-time shell config: an env that differs from the running\n\t\t// session's (e.g. a spawn hook rewriting it per command) requires a fresh shell.\n\t\tif (\n\t\t\tthis.kind !== \"powershell\" &&\n\t\t\tthis.coordinator.child &&\n\t\t\tthis.childEnv &&\n\t\t\t!shallowEnvEquals(this.childEnv, resolvedEnv)\n\t\t) {\n\t\t\tthis.killChild();\n\t\t}\n\n\t\t// Re-enter the host-requested cwd only when it CHANGES between calls; an unchanged\n\t\t// request preserves the agent's own in-session `cd` (that persistence is the feature).\n\t\tlet cdTo: string | null = null;\n\t\tif (!this.coordinator.child) await this.spawnChild(cwd, resolvedEnv);\n\t\tif (this.lastRequestedCwd !== cwd) cdTo = cwd;\n\t\tthis.lastRequestedCwd = cwd;\n\t\tlet resolvedCommand = command;\n\t\tif (this.kind === \"powershell\" && this.childEnv && !shallowEnvEquals(this.childEnv, resolvedEnv)) {\n\t\t\tconst environmentPrelude = buildPowerShellEnvironmentPrelude(this.childEnv, resolvedEnv);\n\t\t\tif (environmentPrelude) resolvedCommand = `${environmentPrelude}\\n${command}`;\n\t\t\tthis.childEnv = { ...resolvedEnv };\n\t\t}\n\n\t\tconst child = this.coordinator.child;\n\t\tif (!child?.stdin || !child.stdout || !child.stderr) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(`Failed to start ${this.kind} session`);\n\t\t}\n\n\t\tconst nonce = randomBytes(8).toString(\"hex\");\n\t\tconst wire =\n\t\t\tthis.kind === \"powershell\"\n\t\t\t\t? buildPowerShellWire(resolvedCommand, nonce, cdTo)\n\t\t\t\t: buildBashWire(resolvedCommand, nonce, cdTo);\n\t\tconst sentinelPrefix = Buffer.from(`\\n\\x1e${nonce}:`, \"latin1\");\n\t\tconst stderrBarrier = Buffer.from(`\\x1e${nonce}:${POWERSHELL_STDERR_BARRIER_LABEL}\\x1e\\n`, \"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 stdoutPending: Buffer = Buffer.alloc(0);\n\t\t\t\tlet stderrPending: Buffer = Buffer.alloc(0);\n\t\t\t\tlet commandExitCode: number | null | undefined;\n\t\t\t\tlet stderrBarrierSeen = this.kind !== \"powershell\";\n\t\t\t\tlet timeoutTimer: NodeJS.Timeout | undefined;\n\n\t\t\t\tconst silenceWatchdog =\n\t\t\t\t\ttimeoutSeconds === undefined && silenceMs !== undefined && silenceMs > 0\n\t\t\t\t\t\t? createSilenceWatchdog({\n\t\t\t\t\t\t\t\tsilenceMs,\n\t\t\t\t\t\t\t\tonSilence: () => {\n\t\t\t\t\t\t\t\t\tthis.killChild();\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(`silence:${silenceMs / 1000}`)));\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tconst settle = (finish: () => 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\tsilenceWatchdog?.disarm();\n\t\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tthis.activeExec = null;\n\t\t\t\t\tfinish();\n\t\t\t\t};\n\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tsettle(() => reject(new Error(\"aborted\")));\n\t\t\t\t};\n\n\t\t\t\tconst emitStdoutPending = (upTo: number) => {\n\t\t\t\t\tif (upTo <= 0) return;\n\t\t\t\t\tonData(stdoutPending.subarray(0, upTo));\n\t\t\t\t\tstdoutPending = stdoutPending.subarray(upTo);\n\t\t\t\t};\n\t\t\t\tconst emitStderrPending = (upTo: number) => {\n\t\t\t\t\tif (upTo <= 0) return;\n\t\t\t\t\tonData(stderrPending.subarray(0, upTo));\n\t\t\t\t\tstderrPending = stderrPending.subarray(upTo);\n\t\t\t\t};\n\t\t\t\tconst resolveWhenComplete = () => {\n\t\t\t\t\tconst exitCode = commandExitCode;\n\t\t\t\t\tif (exitCode === undefined || !stderrBarrierSeen) return;\n\t\t\t\t\tsettle(() => resolve({ exitCode }));\n\t\t\t\t};\n\n\t\t\t\tthis.activeExec = {\n\t\t\t\t\tonStdout: (data) => {\n\t\t\t\t\t\tsilenceWatchdog?.touch();\n\t\t\t\t\t\tif (commandExitCode !== undefined) {\n\t\t\t\t\t\t\tonData(data);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstdoutPending = stdoutPending.length === 0 ? data : Buffer.concat([stdoutPending, data]);\n\t\t\t\t\t\tconst prefixIndex = stdoutPending.indexOf(sentinelPrefix);\n\t\t\t\t\t\tif (prefixIndex !== -1) {\n\t\t\t\t\t\t\tconst closeIndex = stdoutPending.indexOf(SENTINEL_BYTE, prefixIndex + sentinelPrefix.length);\n\t\t\t\t\t\t\tif (closeIndex !== -1) {\n\t\t\t\t\t\t\t\tconst codeText = stdoutPending\n\t\t\t\t\t\t\t\t\t.subarray(prefixIndex + sentinelPrefix.length, closeIndex)\n\t\t\t\t\t\t\t\t\t.toString(\"latin1\");\n\t\t\t\t\t\t\t\temitStdoutPending(prefixIndex);\n\t\t\t\t\t\t\t\tstdoutPending = stdoutPending.subarray(closeIndex - prefixIndex + 1);\n\t\t\t\t\t\t\t\temitStdoutPending(stdoutPending.length);\n\t\t\t\t\t\t\t\tconst parsed = Number.parseInt(codeText, 10);\n\t\t\t\t\t\t\t\tcommandExitCode = Number.isNaN(parsed) ? null : parsed;\n\t\t\t\t\t\t\t\tresolveWhenComplete();\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Stream promptly but retain a tail large enough to hold any split sentinel.\n\t\t\t\t\t\temitStdoutPending(stdoutPending.length - SENTINEL_HOLDBACK_BYTES);\n\t\t\t\t\t},\n\t\t\t\t\tonStderr: (data) => {\n\t\t\t\t\t\tsilenceWatchdog?.touch();\n\t\t\t\t\t\tif (this.kind !== \"powershell\" || stderrBarrierSeen) {\n\t\t\t\t\t\t\tonData(data);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstderrPending = stderrPending.length === 0 ? data : Buffer.concat([stderrPending, data]);\n\t\t\t\t\t\tconst barrierIndex = stderrPending.indexOf(stderrBarrier);\n\t\t\t\t\t\tif (barrierIndex !== -1) {\n\t\t\t\t\t\t\temitStderrPending(barrierIndex);\n\t\t\t\t\t\t\tstderrPending = stderrPending.subarray(stderrBarrier.length);\n\t\t\t\t\t\t\temitStderrPending(stderrPending.length);\n\t\t\t\t\t\t\tstderrBarrierSeen = true;\n\t\t\t\t\t\t\tresolveWhenComplete();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Preserve enough bytes to recognize a barrier split across chunks.\n\t\t\t\t\t\temitStderrPending(stderrPending.length - stderrBarrier.length + 1);\n\t\t\t\t\t},\n\t\t\t\t\tonChildClose: (code) => {\n\t\t\t\t\t\t// The command terminated the shell itself (e.g. `exit 3`) or the shell\n\t\t\t\t\t\t// crashed: report its exit code like the per-command backend would.\n\t\t\t\t\t\temitStdoutPending(stdoutPending.length);\n\t\t\t\t\t\temitStderrPending(stderrPending.length);\n\t\t\t\t\t\tsettle(() => resolve({ exitCode: code }));\n\t\t\t\t\t},\n\t\t\t\t\tfail: (error) => {\n\t\t\t\t\t\tthis.killChild();\n\t\t\t\t\t\tsettle(() => reject(error));\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tif (signal) {\n\t\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (timeoutSeconds !== undefined && timeoutSeconds > 0) {\n\t\t\t\t\ttimeoutTimer = setTimeout(() => {\n\t\t\t\t\t\tthis.killChild();\n\t\t\t\t\t\tsettle(() => reject(new Error(`timeout:${timeoutSeconds}`)));\n\t\t\t\t\t}, timeoutSeconds * 1000);\n\t\t\t\t}\n\n\t\t\t\tchild.stdin?.write(wire, (error) => {\n\t\t\t\t\tif (!error) return;\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tsettle(() => reject(new Error(`Failed to write to ${this.kind} session: ${error.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 spawnChild(cwd: string, env: NodeJS.ProcessEnv): Promise<void> {\n\t\tlet spawnedCwd = cwd;\n\t\tlet spawnedEnv = env;\n\t\tif (this.kind === \"powershell\") {\n\t\t\t({ cwd: spawnedCwd, env: spawnedEnv } = await this.spawnPowerShellChild(cwd, env));\n\t\t} else {\n\t\t\tconst { shell } = getShellConfig(undefined, this.kind);\n\t\t\tconst args = basename(shell).toLowerCase().includes(\"bash\") ? [\"--noprofile\", \"--norc\"] : [];\n\t\t\tconst child = this.spawnProcess(shell, args, {\n\t\t\t\tcwd,\n\t\t\t\tenv,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tthis.attachReadyChild(child);\n\t\t}\n\t\tthis.childEnv = { ...spawnedEnv };\n\t\tthis.lastRequestedCwd = spawnedCwd;\n\t}\n\n\tprivate async spawnPowerShellChild(\n\t\tcwd: string,\n\t\tenv: NodeJS.ProcessEnv,\n\t): Promise<{ cwd: string; env: NodeJS.ProcessEnv }> {\n\t\tconst warmStart = await claimCliPowerShellWarmStart();\n\t\tif (warmStart) {\n\t\t\ttry {\n\t\t\t\tthis.attachReadyChild(warmStart.child);\n\t\t\t} finally {\n\t\t\t\twarmStart.releaseStartupListeners();\n\t\t\t}\n\t\t\treturn { cwd: warmStart.cwd, env: warmStart.env };\n\t\t}\n\t\tconst failures: string[] = [];\n\t\tfor (const candidate of this.resolvePowerShellCandidates()) {\n\t\t\ttry {\n\t\t\t\tawait this.spawnPowerShellCandidate(candidate.shell, cwd, env);\n\t\t\t\treturn { cwd, env };\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tfailures.push(`${candidate.shell}: ${message}`);\n\t\t\t}\n\t\t}\n\t\tconst detail = failures.length > 0 ? ` Candidate failures: ${failures.join(\"; \")}` : \"\";\n\t\tthrow new Error(`PowerShell 7 (pwsh) was not found. Install pwsh before using the Windows shell.${detail}`);\n\t}\n\n\tprivate spawnPowerShellCandidate(shell: string, cwd: string, env: NodeJS.ProcessEnv): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\tlet startupSettled = false;\n\t\t\tlet startupStdout: Buffer = Buffer.alloc(0);\n\t\t\tlet startupStderr: Buffer = Buffer.alloc(0);\n\t\t\tlet stdoutReady = false;\n\t\t\tlet stderrReady = false;\n\t\t\tlet timeoutTimer: NodeJS.Timeout | undefined;\n\n\t\t\tconst settleStartup = (finish: () => void): void => {\n\t\t\t\tif (startupSettled) return;\n\t\t\t\tstartupSettled = true;\n\t\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\t\tif (this.rejectStartup === rejectStartup) this.rejectStartup = null;\n\t\t\t\tfinish();\n\t\t\t};\n\t\t\tconst startupDiagnostic = (): string => {\n\t\t\t\tconst combined = Buffer.concat([startupStdout, startupStderr]).toString(\"utf8\").trim();\n\t\t\t\treturn combined ? `: ${combined}` : \"\";\n\t\t\t};\n\t\t\tconst rejectStartup = (error: Error): void => {\n\t\t\t\tsettleStartup(() => reject(error));\n\t\t\t};\n\t\t\tconst resolveWhenReady = (): void => {\n\t\t\t\tif (!stdoutReady || !stderrReady) return;\n\t\t\t\tsettleStartup(resolve);\n\t\t\t};\n\n\t\t\tlet child: ChildProcess;\n\t\t\ttry {\n\t\t\t\tchild = this.spawnProcess(shell, [...POWERSHELL_ARGS, POWERSHELL_BOOTSTRAP], {\n\t\t\t\t\tcwd,\n\t\t\t\t\tenv,\n\t\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t\t\twindowsHide: true,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\trejectStartup(new Error(`spawn failed: ${message}`));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.rejectStartup = rejectStartup;\n\t\t\tthis.coordinator.attach(child, {\n\t\t\t\tonStdout: (data) => {\n\t\t\t\t\tif (startupSettled) {\n\t\t\t\t\t\tthis.activeExec?.onStdout(data);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tstartupStdout =\n\t\t\t\t\t\tstartupStdout.length === 0\n\t\t\t\t\t\t\t? data\n\t\t\t\t\t\t\t: Buffer.concat([startupStdout, data]).subarray(-MAX_STARTUP_DIAGNOSTIC_BYTES);\n\t\t\t\t\tstdoutReady ||= startupStdout.indexOf(POWERSHELL_SESSION_READY_BYTES) !== -1;\n\t\t\t\t\tresolveWhenReady();\n\t\t\t\t},\n\t\t\t\tonStderr: (data) => {\n\t\t\t\t\tif (startupSettled) {\n\t\t\t\t\t\tthis.activeExec?.onStderr(data);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tstartupStderr =\n\t\t\t\t\t\tstartupStderr.length === 0\n\t\t\t\t\t\t\t? data\n\t\t\t\t\t\t\t: Buffer.concat([startupStderr, data]).subarray(-MAX_STARTUP_DIAGNOSTIC_BYTES);\n\t\t\t\t\tstderrReady ||= startupStderr.indexOf(POWERSHELL_SESSION_STDERR_READY_BYTES) !== -1;\n\t\t\t\t\tresolveWhenReady();\n\t\t\t\t},\n\t\t\t\tonError: (error) => {\n\t\t\t\t\tthis.resetChildState();\n\t\t\t\t\tif (!startupSettled) rejectStartup(new Error(`${error.message}${startupDiagnostic()}`));\n\t\t\t\t\telse this.activeExec?.fail(error);\n\t\t\t\t},\n\t\t\t\tonClose: (code) => {\n\t\t\t\t\tthis.resetChildState();\n\t\t\t\t\tif (!startupSettled) {\n\t\t\t\t\t\trejectStartup(new Error(`exited with code ${code ?? \"null\"} before readiness${startupDiagnostic()}`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.activeExec?.onChildClose(code);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t\ttimeoutTimer = setTimeout(() => {\n\t\t\t\tthis.coordinator.kill();\n\t\t\t\tthis.resetChildState();\n\t\t\t\trejectStartup(new Error(`startup timed out after ${this.startupTimeoutMs}ms${startupDiagnostic()}`));\n\t\t\t}, this.startupTimeoutMs);\n\t\t});\n\t}\n\n\tprivate attachReadyChild(child: ChildProcess): void {\n\t\tthis.coordinator.attach(child, {\n\t\t\tonStdout: (data) => this.activeExec?.onStdout(data),\n\t\t\tonStderr: (data) => this.activeExec?.onStderr(data),\n\t\t\tonError: (error) => {\n\t\t\t\tthis.resetChildState();\n\t\t\t\tthis.activeExec?.fail(error);\n\t\t\t},\n\t\t\tonClose: (code) => {\n\t\t\t\tthis.resetChildState();\n\t\t\t\tthis.activeExec?.onChildClose(code);\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate resetChildState(): void {\n\t\tthis.childEnv = null;\n\t\tthis.lastRequestedCwd = null;\n\t}\n\n\tprivate killChild(): void {\n\t\tthis.coordinator.kill();\n\t\tthis.resetChildState();\n\t}\n}\n\nconst shellSessions = new Map<string, PersistentShellSession>();\n\n/** Get or lazily create the persistent session for a key. A kind change replaces the session. */\nexport function acquirePersistentShellSession(key: string, kind: PlatformShellToolName): PersistentShellSession {\n\tconst existing = shellSessions.get(key);\n\tif (existing && existing.sessionKind === kind) return existing;\n\texisting?.dispose();\n\tconst session = new PersistentShellSession(key, kind);\n\tshellSessions.set(key, session);\n\treturn session;\n}\n\n/** Kill and forget a session (agent teardown). Safe to call for keys that never spawned. */\nexport function disposePersistentShellSession(key: string): void {\n\tconst session = shellSessions.get(key);\n\tif (!session) return;\n\tshellSessions.delete(key);\n\tsession.dispose();\n}\n"]}
|
|
@@ -6,6 +6,9 @@ declare const taskStepsSchema: Type.TObject<{
|
|
|
6
6
|
priority: Type.TOptional<Type.TUnion<[Type.TLiteral<"low">, Type.TLiteral<"normal">, Type.TLiteral<"high">]>>;
|
|
7
7
|
owner: Type.TOptional<Type.TString>;
|
|
8
8
|
requirementIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
9
|
+
pipelineRunId: Type.TOptional<Type.TString>;
|
|
10
|
+
pipelineStageId: Type.TOptional<Type.TString>;
|
|
11
|
+
clearPipelineLink: Type.TOptional<Type.TBoolean>;
|
|
9
12
|
note: Type.TOptional<Type.TString>;
|
|
10
13
|
evidence: Type.TOptional<Type.TArray<Type.TString>>;
|
|
11
14
|
action: Type.TUnion<[Type.TLiteral<"set">, Type.TLiteral<"add">, Type.TLiteral<"update">, Type.TLiteral<"list">, Type.TLiteral<"clear">, Type.TLiteral<"compact">, Type.TLiteral<"intake">, Type.TLiteral<"advance">]>;
|
|
@@ -14,6 +17,9 @@ declare const taskStepsSchema: Type.TObject<{
|
|
|
14
17
|
priority: Type.TOptional<Type.TUnion<[Type.TLiteral<"low">, Type.TLiteral<"normal">, Type.TLiteral<"high">]>>;
|
|
15
18
|
owner: Type.TOptional<Type.TString>;
|
|
16
19
|
requirementIds: Type.TOptional<Type.TArray<Type.TString>>;
|
|
20
|
+
pipelineRunId: Type.TOptional<Type.TString>;
|
|
21
|
+
pipelineStageId: Type.TOptional<Type.TString>;
|
|
22
|
+
clearPipelineLink: Type.TOptional<Type.TBoolean>;
|
|
17
23
|
note: Type.TOptional<Type.TString>;
|
|
18
24
|
evidence: Type.TOptional<Type.TArray<Type.TString>>;
|
|
19
25
|
content: Type.TString;
|
|
@@ -45,6 +51,10 @@ export interface TaskStepsToolDetails {
|
|
|
45
51
|
export interface TaskStepsToolDependencies {
|
|
46
52
|
getTaskStepsState: () => TaskStepsState | undefined;
|
|
47
53
|
saveTaskStepsState: (state: TaskStepsState) => void;
|
|
54
|
+
getActivePipelineScope?: () => {
|
|
55
|
+
runId: string;
|
|
56
|
+
stageIds: readonly string[];
|
|
57
|
+
} | undefined;
|
|
48
58
|
now?: () => string;
|
|
49
59
|
}
|
|
50
60
|
export declare function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-steps.d.ts","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"task-steps.d.ts","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAgBN,KAAK,cAAc,EAGnB,MAAM,wBAAwB,CAAC;AAgEhC,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAE3D,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4FAA4F;IAC5F,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,yBAAyB;IACzC,iBAAiB,EAAE,MAAM,cAAc,GAAG,SAAS,CAAC;IACpD,kBAAkB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,sBAAsB,CAAC,EAAE,MAAM;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC;IAC1F,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACnB;AAuKD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,yBAAyB,GAAG,cAAc,CA6J7F"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import { advanceTaskSteps } from "../pipelines/increment.js";
|
|
3
|
-
import {
|
|
3
|
+
import { MAX_PIPELINE_STAGE_ID_LENGTH } from "../pipelines/types.js";
|
|
4
|
+
import { addTaskStep, clearTaskSteps, compactTaskSteps, createTaskStepsState, findOpenDuplicateStep, formatTaskSteps, hasUnverifiedCompletedStep, MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH, MAX_TASK_STEPS, normalizeTaskStepPipelineLink, resolveTaskStepSelector, setTaskSteps, TaskStepsError, updateTaskStep, } from "../tasks/task-state.js";
|
|
4
5
|
import { emptyOrchestrationCall, OrchestrationPanelComponent, taskStepPanelRow, } from "./orchestration-panel.js";
|
|
5
6
|
const statusSchema = Type.Union([
|
|
6
7
|
Type.Literal("pending"),
|
|
@@ -19,6 +20,19 @@ function optionalTaskStepFields(requirementIdsDescription) {
|
|
|
19
20
|
maxItems: 32,
|
|
20
21
|
description: requirementIdsDescription,
|
|
21
22
|
})),
|
|
23
|
+
pipelineRunId: Type.Optional(Type.String({
|
|
24
|
+
minLength: 1,
|
|
25
|
+
maxLength: MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,
|
|
26
|
+
description: "Active pipeline run id this step advances. Supply together with pipelineStageId.",
|
|
27
|
+
})),
|
|
28
|
+
pipelineStageId: Type.Optional(Type.String({
|
|
29
|
+
minLength: 1,
|
|
30
|
+
maxLength: MAX_PIPELINE_STAGE_ID_LENGTH,
|
|
31
|
+
description: "Stage id in pipelineRunId this step advances. Supply both ids together.",
|
|
32
|
+
})),
|
|
33
|
+
clearPipelineLink: Type.Optional(Type.Boolean({
|
|
34
|
+
description: "Remove both pipeline ids. Cannot be combined with pipelineRunId/pipelineStageId.",
|
|
35
|
+
})),
|
|
22
36
|
note: Type.Optional(Type.String({ maxLength: 4_000 })),
|
|
23
37
|
evidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),
|
|
24
38
|
};
|
|
@@ -53,18 +67,43 @@ const taskStepsSchema = Type.Object({
|
|
|
53
67
|
showCompleted: Type.Optional(Type.Boolean({ description: "Include completed and cancelled steps in output." })),
|
|
54
68
|
maxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),
|
|
55
69
|
}, { additionalProperties: false });
|
|
56
|
-
function
|
|
70
|
+
function toTaskStepUpdate(input) {
|
|
57
71
|
return {
|
|
58
|
-
content: input.content
|
|
72
|
+
content: input.content,
|
|
59
73
|
activeForm: input.activeForm,
|
|
60
74
|
status: input.status,
|
|
61
75
|
priority: input.priority,
|
|
62
76
|
owner: input.owner,
|
|
63
77
|
requirementIds: input.requirementIds,
|
|
78
|
+
pipelineRunId: input.pipelineRunId,
|
|
79
|
+
pipelineStageId: input.pipelineStageId,
|
|
80
|
+
clearPipelineLink: input.clearPipelineLink,
|
|
64
81
|
note: input.note,
|
|
65
82
|
evidence: input.evidence,
|
|
66
83
|
};
|
|
67
84
|
}
|
|
85
|
+
function toTaskStepInput(input) {
|
|
86
|
+
return { ...toTaskStepUpdate(input), content: input.content ?? "" };
|
|
87
|
+
}
|
|
88
|
+
function validatePipelineLink(deps, pipelineRunId, pipelineStageId, clearPipelineLink = false) {
|
|
89
|
+
const { pipelineRunId: runId, pipelineStageId: stageId } = normalizeTaskStepPipelineLink(pipelineRunId, pipelineStageId, clearPipelineLink);
|
|
90
|
+
if (!runId || !stageId)
|
|
91
|
+
return;
|
|
92
|
+
const active = deps.getActivePipelineScope?.();
|
|
93
|
+
if (!active)
|
|
94
|
+
throw new TaskStepsError("Task step pipeline linkage requires an active pipeline run.");
|
|
95
|
+
if (runId !== active.runId) {
|
|
96
|
+
throw new TaskStepsError(`Task step pipelineRunId must match active run '${active.runId}'.`);
|
|
97
|
+
}
|
|
98
|
+
if (!active.stageIds.includes(stageId)) {
|
|
99
|
+
throw new TaskStepsError(`Task step pipelineStageId '${stageId}' is not in active run '${active.runId}'.`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function validatePipelineInputs(deps, inputs) {
|
|
103
|
+
for (const input of inputs) {
|
|
104
|
+
validatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
68
107
|
function counts(state) {
|
|
69
108
|
const openStepCount = state.steps.filter((step) => step.status !== "completed" && step.status !== "cancelled").length;
|
|
70
109
|
return {
|
|
@@ -99,6 +138,7 @@ function errorResult(action, error, state) {
|
|
|
99
138
|
return {
|
|
100
139
|
content: [{ type: "text", text: `task_steps ${action} failed: ${error}` }],
|
|
101
140
|
details: { action, applied: false, error, state, ...(state ? counts(state) : {}) },
|
|
141
|
+
isError: true,
|
|
102
142
|
};
|
|
103
143
|
}
|
|
104
144
|
function taskStepsPanelModel(details, expanded) {
|
|
@@ -177,14 +217,15 @@ export function createTaskStepsToolDefinition(deps) {
|
|
|
177
217
|
description: "Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.",
|
|
178
218
|
promptSnippet: "Track multi-step session work.",
|
|
179
219
|
promptGuidelines: [
|
|
180
|
-
"Use for
|
|
181
|
-
"Batch transitions
|
|
182
|
-
"intake
|
|
183
|
-
"advance completes
|
|
184
|
-
"Attach completed tool_task
|
|
185
|
-
"Before final
|
|
220
|
+
"Use for multi-step work; keep one in_progress step.",
|
|
221
|
+
"Batch transitions; work the first open step; record evidence/blockers; skip unchanged narration.",
|
|
222
|
+
"intake keeps every item; link goal requirementIds.",
|
|
223
|
+
"advance completes current, then starts next pending.",
|
|
224
|
+
"Attach completed tool_task IDs as evidence; goal completion rejects open linked steps.",
|
|
225
|
+
"Before final, resolve or defer open work. goal owns outcomes; delegate owns workers.",
|
|
186
226
|
],
|
|
187
227
|
parameters: taskStepsSchema,
|
|
228
|
+
executionMode: "sequential",
|
|
188
229
|
renderShell: "self",
|
|
189
230
|
renderCall() {
|
|
190
231
|
return emptyOrchestrationCall();
|
|
@@ -214,18 +255,19 @@ export function createTaskStepsToolDefinition(deps) {
|
|
|
214
255
|
try {
|
|
215
256
|
switch (input.action) {
|
|
216
257
|
case "set":
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
demotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(input.steps, state.steps));
|
|
258
|
+
case "intake": {
|
|
259
|
+
const steps = input.steps;
|
|
260
|
+
if (!steps) {
|
|
261
|
+
const error = input.action === "set" ? "set requires steps[]." : "intake requires a complete steps[] list.";
|
|
262
|
+
return errorResult(input.action, error, current);
|
|
263
|
+
}
|
|
264
|
+
validatePipelineInputs(deps, steps);
|
|
265
|
+
state = setTaskSteps(state, steps, timestamp);
|
|
266
|
+
demotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(steps, state.steps));
|
|
227
267
|
break;
|
|
268
|
+
}
|
|
228
269
|
case "add":
|
|
270
|
+
validatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);
|
|
229
271
|
state = addTaskStep(state, toTaskStepInput(input), timestamp);
|
|
230
272
|
if (state === before) {
|
|
231
273
|
// The reducer returned the unchanged state: an open step already carries this
|
|
@@ -237,16 +279,15 @@ export function createTaskStepsToolDefinition(deps) {
|
|
|
237
279
|
if (!input.id?.trim())
|
|
238
280
|
return errorResult(input.action, "update requires id or a unique selector.", current);
|
|
239
281
|
const selected = resolveTaskStepSelector(before.steps, input.id);
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}, timestamp);
|
|
282
|
+
if (input.pipelineRunId !== undefined ||
|
|
283
|
+
input.pipelineStageId !== undefined ||
|
|
284
|
+
input.clearPipelineLink === true) {
|
|
285
|
+
const clearingPipelineLink = input.clearPipelineLink === true;
|
|
286
|
+
validatePipelineLink(deps, clearingPipelineLink ? input.pipelineRunId : (input.pipelineRunId ?? selected.pipelineRunId), clearingPipelineLink
|
|
287
|
+
? input.pipelineStageId
|
|
288
|
+
: (input.pipelineStageId ?? selected.pipelineStageId), clearingPipelineLink);
|
|
289
|
+
}
|
|
290
|
+
state = updateTaskStep(state, input.id, toTaskStepUpdate(input), timestamp);
|
|
250
291
|
// Exclude the explicitly targeted step: its own status change was requested by
|
|
251
292
|
// the caller, so it is never a "silent" demotion even if it moved to pending.
|
|
252
293
|
demotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-steps.js","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,YAAY,EAIZ,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,sBAAsB,EACtB,2BAA2B,EAE3B,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACzB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEvG,SAAS,sBAAsB,CAAC,yBAAiC;IAChE,OAAO;QACN,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QACvC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAA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;gCAC9C,eAAe,EAAE,KAAK,CAAC,aAAa;gCACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;6BACxB,CAAC,GAAG,OAAO,EAAE;yBACd;qBACD;oBACD,OAAO,EAAE;wBACR,MAAM,EAAE,KAAK,CAAC,MAAM;wBACpB,OAAO,EAAE,IAAI;wBACb,KAAK;wBACL,GAAG,WAAW;wBACd,aAAa,EAAE,KAAK,CAAC,aAAa;wBAClC,iBAAiB,EAAE,eAAe;wBAClC,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;qBACvC;iBAChC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { advanceTaskSteps } from \"../pipelines/increment.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tfindOpenDuplicateStep,\n\tformatTaskSteps,\n\thasUnverifiedCompletedStep,\n\tMAX_TASK_STEPS,\n\tresolveTaskStepSelector,\n\tsetTaskSteps,\n\ttype TaskStep,\n\ttype TaskStepInput,\n\ttype TaskStepsState,\n\tupdateTaskStep,\n} from \"../tasks/task-state.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttaskStepPanelRow,\n} from \"./orchestration-panel.ts\";\n\nconst statusSchema = Type.Union([\n\tType.Literal(\"pending\"),\n\tType.Literal(\"in_progress\"),\n\tType.Literal(\"completed\"),\n\tType.Literal(\"blocked\"),\n\tType.Literal(\"cancelled\"),\n]);\n\nconst prioritySchema = Type.Union([Type.Literal(\"low\"), Type.Literal(\"normal\"), Type.Literal(\"high\")]);\n\nfunction optionalTaskStepFields(requirementIdsDescription: string) {\n\treturn {\n\t\tstatus: Type.Optional(statusSchema),\n\t\tpriority: Type.Optional(prioritySchema),\n\t\towner: Type.Optional(Type.String({ maxLength: 200 })),\n\t\trequirementIds: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: 200 }), {\n\t\t\t\tmaxItems: 32,\n\t\t\t\tdescription: requirementIdsDescription,\n\t\t\t}),\n\t\t),\n\t\tnote: Type.Optional(Type.String({ maxLength: 4_000 })),\n\t\tevidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),\n\t};\n}\n\nconst stepInputSchema = Type.Object(\n\t{\n\t\tcontent: Type.String({ minLength: 1, maxLength: 2_000, description: \"Imperative task step text.\" }),\n\t\tactiveForm: Type.Optional(\n\t\t\tType.String({ minLength: 1, maxLength: 2_000, description: \"Short present-progress label for active UI.\" }),\n\t\t),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances.\"),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst taskStepsSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"add\"),\n\t\t\t\tType.Literal(\"update\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"clear\"),\n\t\t\t\tType.Literal(\"compact\"),\n\t\t\t\tType.Literal(\"intake\"),\n\t\t\t\tType.Literal(\"advance\"),\n\t\t\t],\n\t\t\t{ description: \"Checklist action. Use list to read without mutation.\" },\n\t\t),\n\t\tsteps: Type.Optional(\n\t\t\tType.Array(stepInputSchema, {\n\t\t\t\tmaxItems: MAX_TASK_STEPS,\n\t\t\t\tdescription: \"Complete replacement list for set/intake. Intake preserves every supplied item in order.\",\n\t\t\t}),\n\t\t),\n\t\tid: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"For update: current/active, exact step id, unique id prefix, or unique content selector.\",\n\t\t\t}),\n\t\t),\n\t\tcontent: Type.Optional(Type.String({ minLength: 1, maxLength: 2_000 })),\n\t\tactiveForm: Type.Optional(Type.String({ maxLength: 2_000 })),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances; [] clears existing links.\"),\n\t\tclearCompleted: Type.Optional(\n\t\t\tType.Boolean({ description: \"For list: compact completed and cancelled steps before rendering.\" }),\n\t\t),\n\t\tshowCompleted: Type.Optional(Type.Boolean({ description: \"Include completed and cancelled steps in output.\" })),\n\t\tmaxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TaskStepsToolInput = Static<typeof taskStepsSchema>;\nexport type TaskStepsAction = TaskStepsToolInput[\"action\"];\n\nexport interface TaskStepsToolDetails {\n\taction: TaskStepsAction;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: TaskStepsState;\n\tstepCount?: number;\n\topenStepCount?: number;\n\tverificationNudgeNeeded?: boolean;\n\tshowCompleted?: boolean;\n\t/** Set when `add` was a no-op because an open step already carries this content. */\n\tduplicateOfStepId?: string;\n\t/** Step ids silently demoted to pending because another step became active in this call. */\n\tdemotedStepIds?: readonly string[];\n}\n\nexport interface TaskStepsToolDependencies {\n\tgetTaskStepsState: () => TaskStepsState | undefined;\n\tsaveTaskStepsState: (state: TaskStepsState) => void;\n\tnow?: () => string;\n}\n\nfunction toTaskStepInput(input: TaskStepsToolInput): TaskStepInput {\n\treturn {\n\t\tcontent: input.content ?? \"\",\n\t\tactiveForm: input.activeForm,\n\t\tstatus: input.status,\n\t\tpriority: input.priority,\n\t\towner: input.owner,\n\t\trequirementIds: input.requirementIds,\n\t\tnote: input.note,\n\t\tevidence: input.evidence,\n\t};\n}\n\nfunction counts(\n\tstate: TaskStepsState,\n): Pick<TaskStepsToolDetails, \"stepCount\" | \"openStepCount\" | \"verificationNudgeNeeded\"> {\n\tconst openStepCount = state.steps.filter(\n\t\t(step) => step.status !== \"completed\" && step.status !== \"cancelled\",\n\t).length;\n\treturn {\n\t\tstepCount: state.steps.length,\n\t\topenStepCount,\n\t\tverificationNudgeNeeded: hasUnverifiedCompletedStep(state),\n\t};\n}\n\n/** Ids (from `resultSteps`, index-aligned with `inputs`) whose status was set explicitly by the caller. */\nfunction explicitStatusStepIds(inputs: readonly TaskStepInput[], resultSteps: readonly TaskStep[]): Set<string> {\n\tconst ids = new Set<string>();\n\tinputs.forEach((stepInput, index) => {\n\t\tif (stepInput.status !== undefined) {\n\t\t\tconst id = resultSteps[index]?.id;\n\t\t\tif (id) ids.add(id);\n\t\t}\n\t});\n\treturn ids;\n}\n\n/**\n * Steps that were in_progress before this call and are pending after, excluding any step whose\n * new status was set explicitly by the caller (an explicit change is not a \"silent\" demotion).\n */\nfunction computeDemotedStepIds(\n\tbefore: TaskStepsState,\n\tafter: TaskStepsState,\n\texcludeIds: ReadonlySet<string>,\n): string[] {\n\tconst beforeActiveIds = new Set(before.steps.filter((step) => step.status === \"in_progress\").map((step) => step.id));\n\treturn after.steps\n\t\t.filter((step) => beforeActiveIds.has(step.id) && step.status === \"pending\" && !excludeIds.has(step.id))\n\t\t.map((step) => step.id);\n}\n\nfunction errorResult(action: TaskStepsAction, error: string, state?: TaskStepsState) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: `task_steps ${action} failed: ${error}` }],\n\t\tdetails: { action, applied: false, error, state, ...(state ? counts(state) : {}) } satisfies TaskStepsToolDetails,\n\t};\n}\n\nfunction taskStepsPanelModel(details: TaskStepsToolDetails, expanded: boolean): OrchestrationPanelModel {\n\tconst state = details.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"task steps\",\n\t\t\taction: details.action,\n\t\t\tstatus: details.error ? \"error\" : \"idle\",\n\t\t\temptyText: details.error ?? \"No checklist state.\",\n\t\t};\n\t}\n\tconst active = state.steps.filter((step) => step.status === \"in_progress\");\n\tconst blocked = state.steps.filter((step) => step.status === \"blocked\");\n\tconst pending = state.steps.filter((step) => step.status === \"pending\");\n\tconst completed = state.steps.filter((step) => step.status === \"completed\");\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\");\n\tconst open = [...active, ...blocked, ...pending];\n\tconst terminal = details.showCompleted ? [...completed, ...cancelled] : [];\n\tconst candidates = [...open, ...terminal];\n\tconst limit = expanded ? 24 : 8;\n\tconst rows = candidates.slice(0, limit).map(taskStepPanelRow);\n\tconst archivedDone = state.archive.completed + state.archive.cancelled;\n\tconst done = completed.length + state.archive.completed;\n\tconst summary = [\n\t\tactive.length ? `${active.length} working` : undefined,\n\t\t`${open.length} open`,\n\t\t`${done} done`,\n\t\tblocked.length ? `${blocked.length} blocked` : undefined,\n\t\tarchivedDone ? `${archivedDone} archived` : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst notices = [];\n\tif (!details.showCompleted && completed.length + cancelled.length > 0) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${completed.length + cancelled.length} finished step${completed.length + cancelled.length === 1 ? \"\" : \"s\"} hidden`,\n\t\t});\n\t}\n\tif (details.duplicateOfStepId) {\n\t\tnotices.push({ status: \"info\" as const, text: \"Duplicate open step ignored.\" });\n\t}\n\tif (details.demotedStepIds?.length) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${details.demotedStepIds.length} previous working step${details.demotedStepIds.length === 1 ? \"\" : \"s\"} returned to pending.`,\n\t\t});\n\t}\n\tif (details.verificationNudgeNeeded) {\n\t\tnotices.push({ status: \"warning\" as const, text: \"Completed work still needs attached evidence.\" });\n\t}\n\tconst status = details.error\n\t\t? \"error\"\n\t\t: blocked.length > 0\n\t\t\t? \"warning\"\n\t\t\t: active.length > 0\n\t\t\t\t? \"running\"\n\t\t\t\t: open.length === 0 && state.steps.length > 0\n\t\t\t\t\t? \"success\"\n\t\t\t\t\t: \"idle\";\n\treturn {\n\t\tlabel: \"task steps\",\n\t\taction: details.action,\n\t\tstatus,\n\t\tsummary,\n\t\trows,\n\t\tnotices,\n\t\temptyText: state.steps.length === 0 ? \"No tracked steps.\" : \"All open steps are done.\",\n\t\thiddenRowCount: Math.max(0, candidates.length - rows.length),\n\t};\n}\n\nexport function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"task_steps\",\n\t\tlabel: \"Task Steps\",\n\t\tdescription:\n\t\t\t\"Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.\",\n\t\tpromptSnippet: \"Track multi-step session work.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use for complex/explicitly tracked work, not one-step work. Keep one in_progress step.\",\n\t\t\t\"Batch transitions. Address first open step; record evidence/blocker. Never call only to narrate unchanged state.\",\n\t\t\t\"intake preserves every supplied item; link steps to active goal requirementIds.\",\n\t\t\t\"advance completes the current step then starts the next pending step.\",\n\t\t\t\"Attach completed tool_task taskIds as evidence. Goal complete refuses while linked steps stay open.\",\n\t\t\t\"Before final: clear stale in_progress, discuss/defer remainder. Goal owns outcomes; delegate owns workers.\",\n\t\t],\n\t\tparameters: taskStepsSchema,\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return emptyOrchestrationCall();\n\t\t\tconst details = result.details as TaskStepsToolDetails | undefined;\n\t\t\tif (!details) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"task steps\",\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\temptyText: \"No task-step details were returned.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!expanded && details.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, taskStepsPanelModel(details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input: TaskStepsToolInput) {\n\t\t\tconst timestamp = now();\n\t\t\tconst current = deps.getTaskStepsState();\n\t\t\tconst before = current ?? createTaskStepsState(timestamp);\n\t\t\tlet state = before;\n\t\t\tlet duplicateStepId: string | undefined;\n\t\t\tlet demotedStepIds: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"set\":\n\t\t\t\t\t\tif (!input.steps) return errorResult(input.action, \"set requires steps[].\", current);\n\t\t\t\t\t\tstate = setTaskSteps(state, input.steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(\n\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\texplicitStatusStepIds(input.steps, state.steps),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"intake\":\n\t\t\t\t\t\tif (!input.steps)\n\t\t\t\t\t\t\treturn errorResult(input.action, \"intake requires a complete steps[] list.\", current);\n\t\t\t\t\t\tstate = setTaskSteps(state, input.steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(\n\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\texplicitStatusStepIds(input.steps, state.steps),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"add\":\n\t\t\t\t\t\tstate = addTaskStep(state, toTaskStepInput(input), timestamp);\n\t\t\t\t\t\tif (state === before) {\n\t\t\t\t\t\t\t// The reducer returned the unchanged state: an open step already carries this\n\t\t\t\t\t\t\t// content, so nothing was created. Name the existing step in the response.\n\t\t\t\t\t\t\tduplicateStepId = findOpenDuplicateStep(before.steps, input.content ?? \"\")?.id;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\tif (!input.id?.trim())\n\t\t\t\t\t\t\treturn errorResult(input.action, \"update requires id or a unique selector.\", current);\n\t\t\t\t\t\tconst selected = resolveTaskStepSelector(before.steps, input.id);\n\t\t\t\t\t\tstate = updateTaskStep(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tinput.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: input.content,\n\t\t\t\t\t\t\t\tactiveForm: input.activeForm,\n\t\t\t\t\t\t\t\tstatus: input.status,\n\t\t\t\t\t\t\t\tpriority: input.priority,\n\t\t\t\t\t\t\t\towner: input.owner,\n\t\t\t\t\t\t\t\trequirementIds: input.requirementIds,\n\t\t\t\t\t\t\t\tnote: input.note,\n\t\t\t\t\t\t\t\tevidence: input.evidence,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// Exclude the explicitly targeted step: its own status change was requested by\n\t\t\t\t\t\t// the caller, so it is never a \"silent\" demotion even if it moved to pending.\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"clear\":\n\t\t\t\t\t\tstate = clearTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"compact\":\n\t\t\t\t\t\tstate = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"advance\": {\n\t\t\t\t\t\tconst advanced = advanceTaskSteps(before, timestamp);\n\t\t\t\t\t\tstate = advanced.state;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\tif (input.clearCompleted) state = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst isNoopDuplicateAdd = input.action === \"add\" && state === before;\n\t\t\t\tconst mutated = (input.action !== \"list\" || input.clearCompleted === true) && !isNoopDuplicateAdd;\n\t\t\t\tif (mutated) deps.saveTaskStepsState(state);\n\n\t\t\t\tconst stateCounts = counts(state);\n\t\t\t\tconst noticeLines: string[] = [];\n\t\t\t\tif (duplicateStepId) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t`Duplicate open step ignored; existing ${duplicateStepId} already tracks this content.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (demotedStepIds.length > 0) {\n\t\t\t\t\tnoticeLines.push(`Demoted to pending because another step became active: ${demotedStepIds.join(\", \")}.`);\n\t\t\t\t}\n\t\t\t\tif (stateCounts.verificationNudgeNeeded) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t\"Reminder: a completed step has no evidence attached; attach evidence via update before treating it as verified.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst notices = noticeLines.length > 0 ? `\\n${noticeLines.join(\"\\n\")}` : \"\";\n\n\t\t\t\tconst headerAction =\n\t\t\t\t\tinput.action === \"list\"\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `task_steps ${input.action} ${duplicateStepId ? \"ignored (duplicate)\" : \"recorded\"}.\\n`;\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: `${headerAction}${formatTaskSteps(state, {\n\t\t\t\t\t\t\t\tincludeTerminal: input.showCompleted,\n\t\t\t\t\t\t\t\tmaxItems: input.maxItems,\n\t\t\t\t\t\t\t})}${notices}`,\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\taction: input.action,\n\t\t\t\t\t\tapplied: true,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t...stateCounts,\n\t\t\t\t\t\tshowCompleted: input.showCompleted,\n\t\t\t\t\t\tduplicateOfStepId: duplicateStepId,\n\t\t\t\t\t\tdemotedStepIds: demotedStepIds.length > 0 ? demotedStepIds : undefined,\n\t\t\t\t\t} satisfies TaskStepsToolDetails,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn errorResult(input.action, error instanceof Error ? error.message : String(error), current);\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"task-steps.js","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,oCAAoC,EACpC,cAAc,EACd,6BAA6B,EAC7B,uBAAuB,EACvB,YAAY,EAGZ,cAAc,EAGd,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,sBAAsB,EACtB,2BAA2B,EAE3B,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACzB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEvG,SAA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C,iBAAiB,EAAE,eAAe;wBAClC,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;qBACvC;iBAChC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { advanceTaskSteps } from \"../pipelines/increment.ts\";\nimport { MAX_PIPELINE_STAGE_ID_LENGTH } from \"../pipelines/types.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tfindOpenDuplicateStep,\n\tformatTaskSteps,\n\thasUnverifiedCompletedStep,\n\tMAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,\n\tMAX_TASK_STEPS,\n\tnormalizeTaskStepPipelineLink,\n\tresolveTaskStepSelector,\n\tsetTaskSteps,\n\ttype TaskStep,\n\ttype TaskStepInput,\n\tTaskStepsError,\n\ttype TaskStepsState,\n\ttype TaskStepUpdate,\n\tupdateTaskStep,\n} from \"../tasks/task-state.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttaskStepPanelRow,\n} from \"./orchestration-panel.ts\";\n\nconst statusSchema = Type.Union([\n\tType.Literal(\"pending\"),\n\tType.Literal(\"in_progress\"),\n\tType.Literal(\"completed\"),\n\tType.Literal(\"blocked\"),\n\tType.Literal(\"cancelled\"),\n]);\n\nconst prioritySchema = Type.Union([Type.Literal(\"low\"), Type.Literal(\"normal\"), Type.Literal(\"high\")]);\n\nfunction optionalTaskStepFields(requirementIdsDescription: string) {\n\treturn {\n\t\tstatus: Type.Optional(statusSchema),\n\t\tpriority: Type.Optional(prioritySchema),\n\t\towner: Type.Optional(Type.String({ maxLength: 200 })),\n\t\trequirementIds: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: 200 }), {\n\t\t\t\tmaxItems: 32,\n\t\t\t\tdescription: requirementIdsDescription,\n\t\t\t}),\n\t\t),\n\t\tpipelineRunId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,\n\t\t\t\tdescription: \"Active pipeline run id this step advances. Supply together with pipelineStageId.\",\n\t\t\t}),\n\t\t),\n\t\tpipelineStageId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_PIPELINE_STAGE_ID_LENGTH,\n\t\t\t\tdescription: \"Stage id in pipelineRunId this step advances. Supply both ids together.\",\n\t\t\t}),\n\t\t),\n\t\tclearPipelineLink: Type.Optional(\n\t\t\tType.Boolean({\n\t\t\t\tdescription: \"Remove both pipeline ids. Cannot be combined with pipelineRunId/pipelineStageId.\",\n\t\t\t}),\n\t\t),\n\t\tnote: Type.Optional(Type.String({ maxLength: 4_000 })),\n\t\tevidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),\n\t};\n}\n\nconst stepInputSchema = Type.Object(\n\t{\n\t\tcontent: Type.String({ minLength: 1, maxLength: 2_000, description: \"Imperative task step text.\" }),\n\t\tactiveForm: Type.Optional(\n\t\t\tType.String({ minLength: 1, maxLength: 2_000, description: \"Short present-progress label for active UI.\" }),\n\t\t),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances.\"),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst taskStepsSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"add\"),\n\t\t\t\tType.Literal(\"update\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"clear\"),\n\t\t\t\tType.Literal(\"compact\"),\n\t\t\t\tType.Literal(\"intake\"),\n\t\t\t\tType.Literal(\"advance\"),\n\t\t\t],\n\t\t\t{ description: \"Checklist action. Use list to read without mutation.\" },\n\t\t),\n\t\tsteps: Type.Optional(\n\t\t\tType.Array(stepInputSchema, {\n\t\t\t\tmaxItems: MAX_TASK_STEPS,\n\t\t\t\tdescription: \"Complete replacement list for set/intake. Intake preserves every supplied item in order.\",\n\t\t\t}),\n\t\t),\n\t\tid: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"For update: current/active, exact step id, unique id prefix, or unique content selector.\",\n\t\t\t}),\n\t\t),\n\t\tcontent: Type.Optional(Type.String({ minLength: 1, maxLength: 2_000 })),\n\t\tactiveForm: Type.Optional(Type.String({ maxLength: 2_000 })),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances; [] clears existing links.\"),\n\t\tclearCompleted: Type.Optional(\n\t\t\tType.Boolean({ description: \"For list: compact completed and cancelled steps before rendering.\" }),\n\t\t),\n\t\tshowCompleted: Type.Optional(Type.Boolean({ description: \"Include completed and cancelled steps in output.\" })),\n\t\tmaxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TaskStepsToolInput = Static<typeof taskStepsSchema>;\nexport type TaskStepsAction = TaskStepsToolInput[\"action\"];\n\nexport interface TaskStepsToolDetails {\n\taction: TaskStepsAction;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: TaskStepsState;\n\tstepCount?: number;\n\topenStepCount?: number;\n\tverificationNudgeNeeded?: boolean;\n\tshowCompleted?: boolean;\n\t/** Set when `add` was a no-op because an open step already carries this content. */\n\tduplicateOfStepId?: string;\n\t/** Step ids silently demoted to pending because another step became active in this call. */\n\tdemotedStepIds?: readonly string[];\n}\n\nexport interface TaskStepsToolDependencies {\n\tgetTaskStepsState: () => TaskStepsState | undefined;\n\tsaveTaskStepsState: (state: TaskStepsState) => void;\n\tgetActivePipelineScope?: () => { runId: string; stageIds: readonly string[] } | undefined;\n\tnow?: () => string;\n}\n\nfunction toTaskStepUpdate(input: TaskStepsToolInput): TaskStepUpdate {\n\treturn {\n\t\tcontent: input.content,\n\t\tactiveForm: input.activeForm,\n\t\tstatus: input.status,\n\t\tpriority: input.priority,\n\t\towner: input.owner,\n\t\trequirementIds: input.requirementIds,\n\t\tpipelineRunId: input.pipelineRunId,\n\t\tpipelineStageId: input.pipelineStageId,\n\t\tclearPipelineLink: input.clearPipelineLink,\n\t\tnote: input.note,\n\t\tevidence: input.evidence,\n\t};\n}\n\nfunction toTaskStepInput(input: TaskStepsToolInput): TaskStepInput {\n\treturn { ...toTaskStepUpdate(input), content: input.content ?? \"\" };\n}\n\nfunction validatePipelineLink(\n\tdeps: TaskStepsToolDependencies,\n\tpipelineRunId: string | undefined,\n\tpipelineStageId: string | undefined,\n\tclearPipelineLink = false,\n): void {\n\tconst { pipelineRunId: runId, pipelineStageId: stageId } = normalizeTaskStepPipelineLink(\n\t\tpipelineRunId,\n\t\tpipelineStageId,\n\t\tclearPipelineLink,\n\t);\n\tif (!runId || !stageId) return;\n\tconst active = deps.getActivePipelineScope?.();\n\tif (!active) throw new TaskStepsError(\"Task step pipeline linkage requires an active pipeline run.\");\n\tif (runId !== active.runId) {\n\t\tthrow new TaskStepsError(`Task step pipelineRunId must match active run '${active.runId}'.`);\n\t}\n\tif (!active.stageIds.includes(stageId)) {\n\t\tthrow new TaskStepsError(`Task step pipelineStageId '${stageId}' is not in active run '${active.runId}'.`);\n\t}\n}\n\nfunction validatePipelineInputs(deps: TaskStepsToolDependencies, inputs: readonly TaskStepInput[]): void {\n\tfor (const input of inputs) {\n\t\tvalidatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);\n\t}\n}\n\nfunction counts(\n\tstate: TaskStepsState,\n): Pick<TaskStepsToolDetails, \"stepCount\" | \"openStepCount\" | \"verificationNudgeNeeded\"> {\n\tconst openStepCount = state.steps.filter(\n\t\t(step) => step.status !== \"completed\" && step.status !== \"cancelled\",\n\t).length;\n\treturn {\n\t\tstepCount: state.steps.length,\n\t\topenStepCount,\n\t\tverificationNudgeNeeded: hasUnverifiedCompletedStep(state),\n\t};\n}\n\n/** Ids (from `resultSteps`, index-aligned with `inputs`) whose status was set explicitly by the caller. */\nfunction explicitStatusStepIds(inputs: readonly TaskStepInput[], resultSteps: readonly TaskStep[]): Set<string> {\n\tconst ids = new Set<string>();\n\tinputs.forEach((stepInput, index) => {\n\t\tif (stepInput.status !== undefined) {\n\t\t\tconst id = resultSteps[index]?.id;\n\t\t\tif (id) ids.add(id);\n\t\t}\n\t});\n\treturn ids;\n}\n\n/**\n * Steps that were in_progress before this call and are pending after, excluding any step whose\n * new status was set explicitly by the caller (an explicit change is not a \"silent\" demotion).\n */\nfunction computeDemotedStepIds(\n\tbefore: TaskStepsState,\n\tafter: TaskStepsState,\n\texcludeIds: ReadonlySet<string>,\n): string[] {\n\tconst beforeActiveIds = new Set(before.steps.filter((step) => step.status === \"in_progress\").map((step) => step.id));\n\treturn after.steps\n\t\t.filter((step) => beforeActiveIds.has(step.id) && step.status === \"pending\" && !excludeIds.has(step.id))\n\t\t.map((step) => step.id);\n}\n\nfunction errorResult(action: TaskStepsAction, error: string, state?: TaskStepsState) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: `task_steps ${action} failed: ${error}` }],\n\t\tdetails: { action, applied: false, error, state, ...(state ? counts(state) : {}) } satisfies TaskStepsToolDetails,\n\t\tisError: true as const,\n\t};\n}\n\nfunction taskStepsPanelModel(details: TaskStepsToolDetails, expanded: boolean): OrchestrationPanelModel {\n\tconst state = details.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"task steps\",\n\t\t\taction: details.action,\n\t\t\tstatus: details.error ? \"error\" : \"idle\",\n\t\t\temptyText: details.error ?? \"No checklist state.\",\n\t\t};\n\t}\n\tconst active = state.steps.filter((step) => step.status === \"in_progress\");\n\tconst blocked = state.steps.filter((step) => step.status === \"blocked\");\n\tconst pending = state.steps.filter((step) => step.status === \"pending\");\n\tconst completed = state.steps.filter((step) => step.status === \"completed\");\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\");\n\tconst open = [...active, ...blocked, ...pending];\n\tconst terminal = details.showCompleted ? [...completed, ...cancelled] : [];\n\tconst candidates = [...open, ...terminal];\n\tconst limit = expanded ? 24 : 8;\n\tconst rows = candidates.slice(0, limit).map(taskStepPanelRow);\n\tconst archivedDone = state.archive.completed + state.archive.cancelled;\n\tconst done = completed.length + state.archive.completed;\n\tconst summary = [\n\t\tactive.length ? `${active.length} working` : undefined,\n\t\t`${open.length} open`,\n\t\t`${done} done`,\n\t\tblocked.length ? `${blocked.length} blocked` : undefined,\n\t\tarchivedDone ? `${archivedDone} archived` : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst notices = [];\n\tif (!details.showCompleted && completed.length + cancelled.length > 0) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${completed.length + cancelled.length} finished step${completed.length + cancelled.length === 1 ? \"\" : \"s\"} hidden`,\n\t\t});\n\t}\n\tif (details.duplicateOfStepId) {\n\t\tnotices.push({ status: \"info\" as const, text: \"Duplicate open step ignored.\" });\n\t}\n\tif (details.demotedStepIds?.length) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${details.demotedStepIds.length} previous working step${details.demotedStepIds.length === 1 ? \"\" : \"s\"} returned to pending.`,\n\t\t});\n\t}\n\tif (details.verificationNudgeNeeded) {\n\t\tnotices.push({ status: \"warning\" as const, text: \"Completed work still needs attached evidence.\" });\n\t}\n\tconst status = details.error\n\t\t? \"error\"\n\t\t: blocked.length > 0\n\t\t\t? \"warning\"\n\t\t\t: active.length > 0\n\t\t\t\t? \"running\"\n\t\t\t\t: open.length === 0 && state.steps.length > 0\n\t\t\t\t\t? \"success\"\n\t\t\t\t\t: \"idle\";\n\treturn {\n\t\tlabel: \"task steps\",\n\t\taction: details.action,\n\t\tstatus,\n\t\tsummary,\n\t\trows,\n\t\tnotices,\n\t\temptyText: state.steps.length === 0 ? \"No tracked steps.\" : \"All open steps are done.\",\n\t\thiddenRowCount: Math.max(0, candidates.length - rows.length),\n\t};\n}\n\nexport function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"task_steps\",\n\t\tlabel: \"Task Steps\",\n\t\tdescription:\n\t\t\t\"Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.\",\n\t\tpromptSnippet: \"Track multi-step session work.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use for multi-step work; keep one in_progress step.\",\n\t\t\t\"Batch transitions; work the first open step; record evidence/blockers; skip unchanged narration.\",\n\t\t\t\"intake keeps every item; link goal requirementIds.\",\n\t\t\t\"advance completes current, then starts next pending.\",\n\t\t\t\"Attach completed tool_task IDs as evidence; goal completion rejects open linked steps.\",\n\t\t\t\"Before final, resolve or defer open work. goal owns outcomes; delegate owns workers.\",\n\t\t],\n\t\tparameters: taskStepsSchema,\n\t\texecutionMode: \"sequential\",\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return emptyOrchestrationCall();\n\t\t\tconst details = result.details as TaskStepsToolDetails | undefined;\n\t\t\tif (!details) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"task steps\",\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\temptyText: \"No task-step details were returned.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!expanded && details.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, taskStepsPanelModel(details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input: TaskStepsToolInput) {\n\t\t\tconst timestamp = now();\n\t\t\tconst current = deps.getTaskStepsState();\n\t\t\tconst before = current ?? createTaskStepsState(timestamp);\n\t\t\tlet state = before;\n\t\t\tlet duplicateStepId: string | undefined;\n\t\t\tlet demotedStepIds: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"set\":\n\t\t\t\t\tcase \"intake\": {\n\t\t\t\t\t\tconst steps = input.steps;\n\t\t\t\t\t\tif (!steps) {\n\t\t\t\t\t\t\tconst error =\n\t\t\t\t\t\t\t\tinput.action === \"set\" ? \"set requires steps[].\" : \"intake requires a complete steps[] list.\";\n\t\t\t\t\t\t\treturn errorResult(input.action, error, current);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalidatePipelineInputs(deps, steps);\n\t\t\t\t\t\tstate = setTaskSteps(state, steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(steps, state.steps));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"add\":\n\t\t\t\t\t\tvalidatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);\n\t\t\t\t\t\tstate = addTaskStep(state, toTaskStepInput(input), timestamp);\n\t\t\t\t\t\tif (state === before) {\n\t\t\t\t\t\t\t// The reducer returned the unchanged state: an open step already carries this\n\t\t\t\t\t\t\t// content, so nothing was created. Name the existing step in the response.\n\t\t\t\t\t\t\tduplicateStepId = findOpenDuplicateStep(before.steps, input.content ?? \"\")?.id;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\tif (!input.id?.trim())\n\t\t\t\t\t\t\treturn errorResult(input.action, \"update requires id or a unique selector.\", current);\n\t\t\t\t\t\tconst selected = resolveTaskStepSelector(before.steps, input.id);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tinput.pipelineRunId !== undefined ||\n\t\t\t\t\t\t\tinput.pipelineStageId !== undefined ||\n\t\t\t\t\t\t\tinput.clearPipelineLink === true\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst clearingPipelineLink = input.clearPipelineLink === true;\n\t\t\t\t\t\t\tvalidatePipelineLink(\n\t\t\t\t\t\t\t\tdeps,\n\t\t\t\t\t\t\t\tclearingPipelineLink ? input.pipelineRunId : (input.pipelineRunId ?? selected.pipelineRunId),\n\t\t\t\t\t\t\t\tclearingPipelineLink\n\t\t\t\t\t\t\t\t\t? input.pipelineStageId\n\t\t\t\t\t\t\t\t\t: (input.pipelineStageId ?? selected.pipelineStageId),\n\t\t\t\t\t\t\t\tclearingPipelineLink,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate = updateTaskStep(state, input.id, toTaskStepUpdate(input), timestamp);\n\t\t\t\t\t\t// Exclude the explicitly targeted step: its own status change was requested by\n\t\t\t\t\t\t// the caller, so it is never a \"silent\" demotion even if it moved to pending.\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"clear\":\n\t\t\t\t\t\tstate = clearTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"compact\":\n\t\t\t\t\t\tstate = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"advance\": {\n\t\t\t\t\t\tconst advanced = advanceTaskSteps(before, timestamp);\n\t\t\t\t\t\tstate = advanced.state;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\tif (input.clearCompleted) state = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst isNoopDuplicateAdd = input.action === \"add\" && state === before;\n\t\t\t\tconst mutated = (input.action !== \"list\" || input.clearCompleted === true) && !isNoopDuplicateAdd;\n\t\t\t\tif (mutated) deps.saveTaskStepsState(state);\n\n\t\t\t\tconst stateCounts = counts(state);\n\t\t\t\tconst noticeLines: string[] = [];\n\t\t\t\tif (duplicateStepId) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t`Duplicate open step ignored; existing ${duplicateStepId} already tracks this content.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (demotedStepIds.length > 0) {\n\t\t\t\t\tnoticeLines.push(`Demoted to pending because another step became active: ${demotedStepIds.join(\", \")}.`);\n\t\t\t\t}\n\t\t\t\tif (stateCounts.verificationNudgeNeeded) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t\"Reminder: a completed step has no evidence attached; attach evidence via update before treating it as verified.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst notices = noticeLines.length > 0 ? `\\n${noticeLines.join(\"\\n\")}` : \"\";\n\n\t\t\t\tconst headerAction =\n\t\t\t\t\tinput.action === \"list\"\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `task_steps ${input.action} ${duplicateStepId ? \"ignored (duplicate)\" : \"recorded\"}.\\n`;\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: `${headerAction}${formatTaskSteps(state, {\n\t\t\t\t\t\t\t\tincludeTerminal: input.showCompleted,\n\t\t\t\t\t\t\t\tmaxItems: input.maxItems,\n\t\t\t\t\t\t\t})}${notices}`,\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\taction: input.action,\n\t\t\t\t\t\tapplied: true,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t...stateCounts,\n\t\t\t\t\t\tshowCompleted: input.showCompleted,\n\t\t\t\t\t\tduplicateOfStepId: duplicateStepId,\n\t\t\t\t\t\tdemotedStepIds: demotedStepIds.length > 0 ? demotedStepIds : undefined,\n\t\t\t\t\t} satisfies TaskStepsToolDetails,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn errorResult(input.action, error instanceof Error ? error.message : String(error), current);\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-shell-engine.d.ts","sourceRoot":"","sources":["../../../src/core/tools/windows-shell-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMrE,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGhD,OAAO,EAKN,KAAK,iBAAiB,EACtB,MAAM,0BAA0B,CAAC;AAMlC,uEAAuE;AACvE,MAAM,WAAW,uBAAuB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACxC,WAAW,EAAE;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAChF;AAiCD,qBAAa,yBAA0B,SAAQ,KAAK;IACnD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,YAAY,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAIlD;CACD;AAsED,MAAM,WAAW,yBAAyB;IACzC,+FAA+F;IAC/F,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC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AAC,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACrD,iGAAiG;IACjG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gGAAgG;IAChG,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,iBAAiB,CAAC;IACrD,sFAAsF;IACtF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,KAAK,YAAY,CAAC;IACjF,2FAA2F;IAC3F,qBAAqB,CAAC,EAAE,MAAM,MAAM,CAAC;CACrC;AA0SD,+FAA+F;AAC/F,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKlE;AAED,+DAA+D;AAC/D,wBAAgB,kCAAkC,CACjD,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,yBAA8B,GACrC,cAAc,CAQhB"}
|
|
@@ -277,8 +277,13 @@ class PersistentWindowsShellEngineSession {
|
|
|
277
277
|
fail: (error) => failAndReset(error),
|
|
278
278
|
};
|
|
279
279
|
this.activeExec = active;
|
|
280
|
-
if (signal)
|
|
280
|
+
if (signal) {
|
|
281
281
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
282
|
+
if (signal.aborted) {
|
|
283
|
+
onAbort();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
282
287
|
if (timeoutMs !== undefined) {
|
|
283
288
|
timeoutTimer = setTimeout(() => failAndReset(new Error(`timeout:${timeout}`)), timeoutMs);
|
|
284
289
|
}
|