@bastani/atomic 0.9.76 → 0.9.77
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 +46 -0
- package/dist/builtin/intercom/CHANGELOG.md +26 -0
- package/dist/builtin/intercom/broker/broker.ts +153 -6
- package/dist/builtin/intercom/broker/client.ts +85 -3
- package/dist/builtin/intercom/broker/departed-children.ts +471 -0
- package/dist/builtin/intercom/broker/recipient-gone-errors.ts +280 -0
- package/dist/builtin/intercom/broker/restoring-recipients.ts +108 -7
- package/dist/builtin/intercom/broker/send-handler.ts +42 -0
- package/dist/builtin/intercom/broker/workflow-stage-aliases.ts +69 -0
- package/dist/builtin/intercom/index.bundle.mjs +374 -129
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/types.ts +30 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +30 -0
- package/dist/builtin/subagents/README.md +1 -1
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +64 -4
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +28 -0
- package/dist/builtin/workflows/README.md +1 -1
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +5 -5
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +71 -56
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +315 -112
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +168 -9
- package/dist/builtin/workflows/src/index.js +168 -9
- package/dist/builtin/workflows/src/local-worker-entry.mjs +168 -9
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +2 -1
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +2 -0
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +7 -2
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tasks.d.ts +6 -0
- package/dist/core/agent-session-tasks.d.ts.map +1 -1
- package/dist/core/agent-session-tasks.js +13 -25
- package/dist/core/agent-session-tasks.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
- package/dist/core/extensions/loader-rollback.js +1 -0
- package/dist/core/extensions/loader-rollback.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +3 -3
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +2 -1
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +9 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +16 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/sdk-types.d.ts +5 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +26 -18
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/agent-adapter.js +2 -2
- package/dist/core/tasks/agent-adapter.js.map +1 -1
- package/dist/core/tasks/cancel-reason.d.ts +20 -0
- package/dist/core/tasks/cancel-reason.d.ts.map +1 -0
- package/dist/core/tasks/cancel-reason.js +47 -0
- package/dist/core/tasks/cancel-reason.js.map +1 -0
- package/dist/core/tasks/child-command-owner.d.ts +1 -1
- package/dist/core/tasks/child-command-owner.d.ts.map +1 -1
- package/dist/core/tasks/child-command-owner.js +22 -0
- package/dist/core/tasks/child-command-owner.js.map +1 -1
- package/dist/core/tasks/completion-message.d.ts +11 -0
- package/dist/core/tasks/completion-message.d.ts.map +1 -0
- package/dist/core/tasks/completion-message.js +30 -0
- package/dist/core/tasks/completion-message.js.map +1 -0
- package/dist/core/tasks/completion.d.ts +2 -0
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +30 -14
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/contracts.d.ts +4 -0
- package/dist/core/tasks/contracts.d.ts.map +1 -1
- package/dist/core/tasks/contracts.js.map +1 -1
- package/dist/core/tasks/supervisor.d.ts +29 -3
- package/dist/core/tasks/supervisor.d.ts.map +1 -1
- package/dist/core/tasks/supervisor.js +48 -25
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/core/tasks/task-view-source.d.ts +6 -0
- package/dist/core/tasks/task-view-source.d.ts.map +1 -1
- package/dist/core/tasks/task-view-source.js +49 -0
- package/dist/core/tasks/task-view-source.js.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts +6 -1
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.js +5 -1
- package/dist/core/tools/bash-pty-native.js.map +1 -1
- package/dist/core/tools/bash.d.ts +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +14 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/history-protocol.d.ts +15 -1
- package/dist/core/tools/history-protocol.d.ts.map +1 -1
- package/dist/core/tools/history-protocol.js +9 -7
- package/dist/core/tools/history-protocol.js.map +1 -1
- package/dist/core/tools/shell-task-status.d.ts.map +1 -1
- package/dist/core/tools/shell-task-status.js +3 -13
- package/dist/core/tools/shell-task-status.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +2 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +36 -6
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +12 -8
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +6 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +5 -2
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +8 -5
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +5 -2
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/input-label.d.ts +29 -0
- package/dist/modes/interactive/components/input-label.d.ts.map +1 -0
- package/dist/modes/interactive/components/input-label.js +75 -0
- package/dist/modes/interactive/components/input-label.js.map +1 -0
- package/dist/modes/interactive/components/task-inspector.d.ts +4 -1
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-inspector.js +6 -2
- package/dist/modes/interactive/components/task-inspector.js.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.d.ts +12 -1
- package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.js +63 -6
- package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +1 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +1 -0
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/engine-session-stats.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-session-stats.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-session-stats.js.map +1 -1
- package/dist/modes/rpc/task-ui-bridge.d.ts +2 -2
- package/dist/modes/rpc/task-ui-bridge.d.ts.map +1 -1
- package/dist/modes/rpc/task-ui-bridge.js +2 -0
- package/dist/modes/rpc/task-ui-bridge.js.map +1 -1
- package/docs/background-tasks.md +14 -1
- package/docs/getting-started/first-session.md +1 -1
- package/docs/intercom/operations.md +4 -2
- package/docs/intercom/reference.md +18 -1
- package/docs/llama-cpp.md +1 -1
- package/docs/sessions.md +1 -1
- package/docs/subagents.md +5 -1
- package/docs/tools.md +1 -1
- package/docs/usage.md +1 -12
- package/docs/workflows/operations.md +3 -1
- package/docs/workflows/verification.md +1 -8
- package/npm-shrinkwrap.json +83 -98
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/core/tools/bash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E,WAAW,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC;YAC7F,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YACxE,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;YACtF,MAAM,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM;gBAC9B,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;oBAClD,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE;oBACvB,SAAS;oBACT,GAAG,EAAE,OAAO,CAAC,GAAG;iBAChB,CAAC,CAAC;YACJ,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,gCAAgC,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1G,CAAC;YACD,SAAS,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { constants } from \"node:fs\";\nimport { access as fsAccess, stat as fsStat } from \"node:fs/promises\";\nimport { constants as osConstants } from \"node:os\";\nimport { resolve as resolvePath } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { APP_NAME } from \"../../config.js\";\nimport { theme } from \"../../modes/interactive/theme/theme.js\";\nimport { createChildProcessEnvironment, waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetShellConfig,\n\tgetShellEnv,\n\tkillProcessTree,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport type { WaitPolicy } from \"../tasks/contracts.js\";\nimport { validateTaskHeartbeatMs } from \"../tasks/heartbeat-notice.js\";\nimport { stripLeadingCdCommand } from \"./bash-leading-cd.ts\";\nimport {\n\texecuteNativePty,\n\texecuteSupervisedCommand,\n\ttype SupervisedCommandOwner,\n\ttype SupervisedCommandResult,\n\tvalidateBashWait,\n\twaitForSupervisedCommand,\n} from \"./bash-pty-native.js\";\nimport { applyBashSessionEnvironment, snapshotBashSessionEnvironment } from \"./bash-session-environment.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport {\n\tgetTextOutput,\n\tinvalidArgText,\n\tlinkPath,\n\tstartToolTimer,\n\tstr,\n\ttype ToolTimerState,\n\ttoolTimerText,\n} from \"./render-utils.ts\";\nimport { expandShellInternalUrls, type InternalResourceContext } from \"./resource-selectors.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { ShellTimeoutError } from \"./shell-errors.ts\";\nimport { addShellOutputPreview, formatTruncationNotice, rebuildShellWaitResult } from \"./shell-task-render.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult } from \"./truncate.ts\";\n\nconst STRUCTURED_OUTPUT_MAX_BYTES = 1024 * 1024;\nconst bashOutputSchema = Type.Object({\n\toutput: Type.String({\n\t\tdescription: \"Combined stdout and stderr, up to 1 MiB, keeping the first and last 512 KiB when longer.\",\n\t}),\n\ttruncated: Type.Boolean(),\n\tfull_output_path: Type.Optional(Type.String()),\n\texit_code: Type.Number(),\n\twall_time_seconds: Type.Number(),\n});\n\nconst envSchema = Type.Unsafe<Record<string, string>>({\n\ttype: \"object\",\n\tdescription: \"Environment variables to add or override.\",\n\tadditionalProperties: { type: \"string\" },\n\tpropertyNames: { pattern: \"^[A-Za-z_][A-Za-z0-9_]*$\" },\n});\nconst bashBaseSchema = Type.Object(\n\t{\n\t\tcommand: Type.String({ description: \"Shell command to execute.\" }),\n\t\tenv: Type.Optional(envSchema),\n\t\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds.\" })),\n\t\twait: Type.Optional(\n\t\t\tType.Unsafe<WaitPolicy>({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tkind: { type: \"string\", enum: [\"background\", \"foreground\"] },\n\t\t\t\t\tbudgetMs: {\n\t\t\t\t\t\ttype: \"number\",\n\t\t\t\t\t\tminimum: 0,\n\t\t\t\t\t\tdescription: \"Foreground observation budget in milliseconds; only valid with foreground.\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"kind\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Observation policy, independent of execution timeout. Omit for owner-configured automatic yield (default 10s).\",\n\t\t\t}),\n\t\t),\n\t\tcwd: Type.Optional(Type.String({ description: \"Working directory for the command.\" })),\n\t\tpty: Type.Optional(Type.Boolean({ description: \"Run with PTY handling.\" })),\n\t\theartbeatMs: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: \"Heartbeat cadence in ms while this runs as a task (default 15 min; 0 disables; min 60000).\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\ntype ShellCommandInput = Static<typeof bashBaseSchema> & { action?: never; id?: never; budgetMs?: never };\ntype ShellWaitInput = { action: \"wait\"; id: string; budgetMs?: number } & Partial<\n\tRecord<keyof Static<typeof bashBaseSchema>, never>\n>;\nconst bashSchema = Type.Unsafe<ShellCommandInput | ShellWaitInput>({\n\t...bashBaseSchema,\n\tproperties: {\n\t\t...bashBaseSchema.properties,\n\t\taction: {\n\t\t\ttype: \"string\",\n\t\t\tenum: [\"wait\"],\n\t\t\tdescription: \"Observe an existing asynchronous task without executing a command.\",\n\t\t},\n\t\tid: { type: \"string\", description: \"Existing task ID owned by this session.\" },\n\t\tbudgetMs: {\n\t\t\ttype: \"number\",\n\t\t\tminimum: 0,\n\t\t\tdescription: \"Observation budget in milliseconds; omitted uses owner policy.\",\n\t\t},\n\t},\n\trequired: [],\n});\nconst shellCommandKeys = Object.keys(bashBaseSchema.properties);\n\nfunction prepareShellInput(args: unknown): BashToolInput {\n\tif (typeof args !== \"object\" || args === null || Array.isArray(args)) return args as BashToolInput;\n\tconst has = (key: string) => Object.hasOwn(args, key);\n\tif (has(\"action\")) {\n\t\tif (!has(\"id\") || shellCommandKeys.some(has))\n\t\t\tthrow new Error(\"Invalid shell wait: expected action wait, id, and optional finite non-negative budgetMs\");\n\t} else if (!has(\"command\") || has(\"id\") || has(\"budgetMs\")) {\n\t\tthrow new Error(\"Invalid shell command: command is required; id and budgetMs require action wait\");\n\t}\n\treturn args as BashToolInput;\n}\nexport const bashToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Execute a shell command.\",\n\tguidelines: Object.freeze([\n\t\t\"You can inspect ATOMIC_* or PI_* environment variables for current model and session details.\",\n\t\t'Use { action: \"wait\", id: taskId } to observe an existing shell task with the owner policy. Avoid repeated short polls; await completion notifications when no dependent work is blocked. Never relaunch a yielded command. Waiting does not extend execution timeout or owner lifetime.',\n\t\t\"For ordinary commands, omit wait to use the owner's observation policy (normally 10s). Do not routinely request one-second waits: premature yields add tool calls without making the command faster. Use a short budget only for a concrete responsiveness need, or explicit background observation when you have independent work to do. Explicit budgets, including zero for polling, remain available.\",\n\t\t\"Choose foreground or background shell observation as needed without asking the user each time. Background yields after admission; foreground waits for its optional budget then the same command continues in background. Omitted wait uses owner-configured automatic background yield (default 10s). Observation never changes the execution timeout, which stops the command. Background requires a supported task owner; unbound foreground waits until completion regardless of budget.\",\n\t] as const),\n} as const);\nexport type BashToolInput = Static<typeof bashSchema>;\nexport interface BashToolDetails {\n\ttruncation?: TruncationResult;\n\tfullOutputPath?: string;\n\texitCode?: number | null;\n\tobservation?: import(\"../tasks/contracts.js\").WaitOutcome;\n\ttimeoutSeconds?: number;\n\trequestedTimeoutSeconds?: number;\n\twallTimeMs?: number;\n}\nconst DEFAULT_TIMEOUT_SECONDS = 300,\n\tMAX_TIMEOUT_SECONDS = 3600;\nexport function validateExplicitTimeoutSeconds(timeout: number): void {\n\tif (!Number.isFinite(timeout) || timeout <= 0 || timeout > MAX_TIMEOUT_SECONDS)\n\t\tthrow new Error(\n\t\t\t`Invalid timeout ${String(timeout)}: timeout must be a finite number greater than 0 and no more than ${MAX_TIMEOUT_SECONDS} seconds`,\n\t\t);\n}\nfunction normalizeTimeoutSeconds(timeout: number | undefined): number {\n\tif (timeout === undefined) return DEFAULT_TIMEOUT_SECONDS;\n\tvalidateExplicitTimeoutSeconds(timeout);\n\treturn Math.max(1, Math.floor(timeout));\n}\nexport type BashOutputChannel = \"stdout\" | \"stderr\";\nexport interface BashOperations {\n\texec: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tonData: (data: Buffer, channel?: BashOutputChannel) => void;\n\t\t\tsignal?: AbortSignal;\n\t\t\ttimeout?: number;\n\t\t\twait?: WaitPolicy;\n\t\t\tenv?: NodeJS.ProcessEnv;\n\t\t\tpty?: boolean;\n\t\t\t/** Task heartbeat cadence for a supervised command; `0` disables. Omitted uses the owner default. */\n\t\t\theartbeatMs?: number;\n\t\t},\n\t) => Promise<SupervisedCommandResult>;\n}\nexport function createLocalBashOperations(options?: {\n\tshellPath?: string;\n\ttaskOwner?: SupervisedCommandOwner;\n}): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, { onData, signal, timeout, wait, env, pty, heartbeatMs }) => {\n\t\t\tvalidateBashWait(wait, !!options?.taskOwner);\n\t\t\tif (timeout !== undefined) validateExplicitTimeoutSeconds(timeout);\n\t\t\tif (pty && process.env.PI_NO_PTY !== \"1\" && process.env.ATOMIC_NO_PTY !== \"1\") {\n\t\t\t\ttry {\n\t\t\t\t\treturn await executeNativePty(command, cwd, {\n\t\t\t\t\t\tonData: (data) => onData(data, \"stdout\"),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\twait,\n\t\t\t\t\t\tenv,\n\t\t\t\t\t\theartbeatMs,\n\t\t\t\t\t\tshellPath: options?.shellPath,\n\t\t\t\t\t\ttaskOwner: options?.taskOwner,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options?.taskOwner) throw error;\n\t\t\t\t\tconst message = String(error instanceof Error ? error.message : error);\n\t\t\t\t\tif (!message.includes(\"Native PTY\") && !message.includes(\"PtySession\")) throw error;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst shellConfig = getShellConfig(options?.shellPath);\n\t\t\ttry {\n\t\t\t\tconst cwdStat = await fsStat(cwd);\n\t\t\t\tif (!cwdStat.isDirectory()) throw new Error(`Working directory is not a directory: ${cwd}`);\n\t\t\t\tawait fsAccess(cwd, constants.F_OK);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error && error.message.startsWith(\"Working directory is not a directory\")) throw error;\n\t\t\t\tthrow new Error(`Working directory does not exist: ${cwd}\\nCannot execute bash commands.`);\n\t\t\t}\n\t\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\t\t\tif (options?.taskOwner)\n\t\t\t\treturn executeSupervisedCommand(\n\t\t\t\t\tcommand,\n\t\t\t\t\tcwd,\n\t\t\t\t\t{\n\t\t\t\t\t\tonData,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\twait,\n\t\t\t\t\t\tenv,\n\t\t\t\t\t\theartbeatMs,\n\t\t\t\t\t\tshellPath: options.shellPath,\n\t\t\t\t\t\ttaskOwner: options.taskOwner,\n\t\t\t\t\t},\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\tconst commandFromStdin = shellConfig.commandTransport === \"stdin\";\n\t\t\tconst child = spawn(shellConfig.shell, commandFromStdin ? shellConfig.args : [...shellConfig.args, command], {\n\t\t\t\tcwd,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tenv: createChildProcessEnvironment(undefined, env ?? getShellEnv()),\n\t\t\t\tstdio: [commandFromStdin ? \"pipe\" : \"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (commandFromStdin) {\n\t\t\t\tchild.stdin?.on(\"error\", () => {});\n\t\t\t\tchild.stdin?.end(command);\n\t\t\t}\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tconst startedAt = performance.now();\n\t\t\tlet shellExitedAfterMs: number | undefined;\n\t\t\tchild.once(\"exit\", () => {\n\t\t\t\tshellExitedAfterMs = performance.now() - startedAt;\n\t\t\t});\n\t\t\t// Set when the deadline fires, with the shell's exit time if it had already exited.\n\t\t\tlet deadline: { timeoutSeconds: number; elapsedMs: number; shellExitedAfterMs?: number } | undefined;\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tif (timeout !== undefined && timeout > 0) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\tdeadline = {\n\t\t\t\t\t\t\ttimeoutSeconds: timeout,\n\t\t\t\t\t\t\telapsedMs: Math.round(performance.now() - startedAt),\n\t\t\t\t\t\t\tshellExitedAfterMs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\t// Also when the shell already exited: on Unix the group kill still reaches background\n\t\t\t\t\t\t// processes holding the pipes. Windows cannot find them once the shell pid is gone.\n\t\t\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\t\t}, timeout * 1000);\n\t\t\t\t}\n\t\t\t\tchild.stdout?.on(\"data\", (data: Buffer) => onData(data, \"stdout\"));\n\t\t\t\tchild.stderr?.on(\"data\", (data: Buffer) => onData(data, \"stderr\"));\n\t\t\t\tif (signal) {\n\t\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t\t\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\tconst exitCode = await waitForChildProcess(child);\n\t\t\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\t\t\t\t// A signal-killed shell has no exit code. Use the standard shell convention so\n\t\t\t\t// callers do not mistake the termination for a successful command.\n\t\t\t\tconst signalCode = child.signalCode;\n\t\t\t\tconst resolvedExitCode = exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1);\n\t\t\t\tif (deadline) {\n\t\t\t\t\tconst { timeoutSeconds, elapsedMs, shellExitedAfterMs: exitedAfterMs } = deadline;\n\t\t\t\t\tthrow new ShellTimeoutError({\n\t\t\t\t\t\ttimeoutSeconds,\n\t\t\t\t\t\telapsedMs,\n\t\t\t\t\t\t...(exitedAfterMs === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tshellExit: {\n\t\t\t\t\t\t\t\t\t\texitCode: resolvedExitCode,\n\t\t\t\t\t\t\t\t\t\tafterSeconds: Math.round(exitedAfterMs / 100) / 10,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn { exitCode: resolvedExitCode };\n\t\t\t} finally {\n\t\t\t\tif (child.pid) untrackDetachedChildPid(child.pid);\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\nexport interface BashSpawnContext {\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n}\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\nfunction resolveSpawnContext(\n\tcommand: string,\n\tcwd: string,\n\tsessionEnvironment: NodeJS.ProcessEnv,\n\tspawnHook?: BashSpawnHook,\n): BashSpawnContext {\n\tconst baseContext: BashSpawnContext = { command, cwd, env: { ...getShellEnv() } };\n\tapplyBashSessionEnvironment(baseContext.env, sessionEnvironment);\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\n}\nexport interface BashToolOptions {\n\toperations?: BashOperations;\n\t/** Trusted host ownership; never supplied by model arguments. */\n\ttaskOwner?: SupervisedCommandOwner;\n\t/** Expose the execution-time Atomic session snapshot and PI compatibility aliases. Default: true. */\n\texposeSessionEnvironment?: boolean;\n\t/** Prefix prepended to every shell command before execution. */\n\tcommandPrefix?: string;\n\t/** Override shell executable resolution for local bash operations. */\n\tshellPath?: string;\n\t/** Dialect for generated internal-URL path literals. Defaults to POSIX; does not select the executable. */\n\tshellDialect?: \"posix\" | \"powershell\";\n\t/** Last-mile hook for rewriting the command/cwd/env spawn context. */\n\tspawnHook?: BashSpawnHook;\n\t/**\n\t * Session-scoped directory for overflow logs, resolved per execution so a\n\t * session switch (fork, branch, resume) follows the live transcript session.\n\t */\n\tsessionTempDir?: string | (() => string | undefined);\n}\n/**\n * Presentation identity for a shell-backed built-in tool. Atomic runs PowerShell\n * through the same execution pipeline as bash, so the transcript prompt and the\n * overflow temp-file prefix are the only shell-specific display values.\n */\nexport interface ShellToolPresentation {\n\t/** Transcript prompt prefix: `$` for bash, `PS>` for PowerShell. */\n\tprompt: string;\n\t/** Prefix for the temp file that holds truncated output. */\n\ttempFilePrefix: string;\n}\nexport const BASH_SHELL_PRESENTATION: ShellToolPresentation = {\n\tprompt: \"$\",\n\ttempFilePrefix: `${APP_NAME}-bash`,\n};\nconst BASH_UPDATE_THROTTLE_MS = 100;\nfunction formatBashCall(\n\targs: { command?: string; timeout?: number; action?: string; id?: string } | undefined,\n\tprompt: string,\n): string {\n\tif (args?.action === \"wait\") return theme.fg(\"toolTitle\", theme.bold(`${prompt} wait ${str(args.id) ?? \"...\"}`));\n\tconst command = str(args?.command);\n\tconst timeout = args?.timeout as number | undefined;\n\tconst timeoutSuffix = timeout ? theme.fg(\"muted\", ` (timeout ${timeout}s)`) : \"\";\n\tconst commandDisplay = command === null ? invalidArgText(theme) : command ? command : theme.fg(\"toolOutput\", \"...\");\n\treturn theme.fg(\"toolTitle\", theme.bold(`${prompt} ${commandDisplay}`)) + timeoutSuffix;\n}\nfunction rebuildBashResultRenderComponent(\n\tcomponent: Container,\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: BashToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\tshowImages: boolean,\n\ttimerText: string | undefined,\n\tcwd: string,\n): void {\n\tcomponent.clear();\n\tlet output = getTextOutput(result, showImages).trim();\n\tconst observation = result.details?.observation;\n\tif (observation?.kind === \"yielded\") {\n\t\tconst receipt = `Command is still running (task ${observation.taskId}).`;\n\t\tif (output.endsWith(receipt)) output = output.slice(0, -receipt.length).trimEnd();\n\t\tcomponent.addChild(new Text(theme.fg(\"accent\", \"∀ Continued in background\"), 0, 0));\n\t\tcomponent.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\"dim\", `/tasks to inspect output or stop${options.expanded ? ` · ${observation.taskId}` : \"\"}`),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t}\n\tconst truncation = result.details?.truncation;\n\tconst fullOutputPath = result.details?.fullOutputPath;\n\tif (!options.isPartial && truncation?.truncated && fullOutputPath && output.endsWith(\"]\")) {\n\t\tconst footerStart = output.lastIndexOf(\"\\n\\n[\");\n\t\tif (footerStart !== -1 && output.slice(footerStart).includes(fullOutputPath)) {\n\t\t\toutput = output.slice(0, footerStart).trimEnd();\n\t\t}\n\t}\n\tif (output) addShellOutputPreview(component, output, options.expanded);\n\tif (truncation?.truncated || fullOutputPath) {\n\t\tconst warnings: string[] = [];\n\t\tif (truncation?.truncated) warnings.push(formatTruncationNotice(truncation));\n\t\tif (fullOutputPath) warnings.push(\"Full output:\");\n\t\tcomponent.addChild(new Text(`\\n${theme.fg(\"warning\", `[${warnings.join(\". \")}]`)}`, 0, 0));\n\t\t// The path gets a line of its own so word wrap never splits it at a space beside its label, and a link so a\n\t\t// path wider than the terminal still opens (and copies) whole.\n\t\tif (fullOutputPath) {\n\t\t\tcomponent.addChild(new Text(theme.fg(\"warning\", linkPath(fullOutputPath, fullOutputPath, cwd)), 0, 0));\n\t\t}\n\t}\n\tif (timerText) component.addChild(new Text(`\\n${theme.fg(\"muted\", timerText)}`, 0, 0));\n}\nexport function createBashToolDefinition(\n\tcwd: string,\n\toptions?: BashToolOptions,\n\tpresentation: ShellToolPresentation = BASH_SHELL_PRESENTATION,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, ToolTimerState> {\n\tconst defaultOps =\n\t\toptions?.operations ??\n\t\tcreateLocalBashOperations({ shellPath: options?.shellPath, taskOwner: options?.taskOwner });\n\tconst commandPrefix = options?.commandPrefix,\n\t\texposeSessionEnvironment = options?.exposeSessionEnvironment ?? true;\n\tconst spawnHook = options?.spawnHook;\n\tconst sessionTempDirOption = options?.sessionTempDir;\n\tconst resolveSessionTempDir = (): string | undefined =>\n\t\ttypeof sessionTempDirOption === \"function\" ? sessionTempDirOption() : sessionTempDirOption;\n\treturn {\n\t\tname: \"bash\",\n\t\tconcurrency: (args) => (args.pty === true ? \"exclusive\" : \"shared\"),\n\t\tdetachable: (args) => args.action === \"wait\" && args.budgetMs === undefined,\n\t\tlabel: \"bash\",\n\t\tdescription:\n\t\t\t'Execute a shell command with optional PTY handling and foreground/background observation, or observe an existing task with action: \"wait\", id, and optional budgetMs. Omitted command wait uses owner policy (default 10s). Observation never changes execution timeout. Background and existing-task waits require a supported task owner; unbound foreground execution waits until completion.',\n\t\tpromptSnippet: bashToolSystemPromptContribution.snippet,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tpromptGuidelines: exposeSessionEnvironment ? [...bashToolSystemPromptContribution.guidelines] : undefined,\n\t\tprepareArguments: prepareShellInput,\n\t\tparameters: bashSchema,\n\t\toutputSchema: bashOutputSchema,\n\t\tmaxResultSizeChars: Infinity,\n\t\tasync execute(_toolCallId, bashCommand: BashToolInput, signal?: AbortSignal, onUpdate?, ctx?: ExtensionContext) {\n\t\t\tif (bashCommand.action !== undefined) {\n\t\t\t\tif (\n\t\t\t\t\tbashCommand.action !== \"wait\" ||\n\t\t\t\t\ttypeof bashCommand.id !== \"string\" ||\n\t\t\t\t\tObject.keys(bashCommand).some((key) => ![\"action\", \"id\", \"budgetMs\"].includes(key)) ||\n\t\t\t\t\t(bashCommand.budgetMs !== undefined &&\n\t\t\t\t\t\t(typeof bashCommand.budgetMs !== \"number\" ||\n\t\t\t\t\t\t\t!Number.isFinite(bashCommand.budgetMs) ||\n\t\t\t\t\t\t\tbashCommand.budgetMs < 0))\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Invalid shell wait: expected action wait, id, and optional finite non-negative budgetMs\",\n\t\t\t\t\t);\n\t\t\t\treturn waitForSupervisedCommand(options?.taskOwner, bashCommand.id, bashCommand.budgetMs, signal, {\n\t\t\t\t\ttempFilePrefix: presentation.tempFilePrefix,\n\t\t\t\t\ttempDir: resolveSessionTempDir(),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (\n\t\t\t\tbashCommand.id !== undefined ||\n\t\t\t\tbashCommand.budgetMs !== undefined ||\n\t\t\t\ttypeof bashCommand.command !== \"string\"\n\t\t\t)\n\t\t\t\tthrow new Error(\"Invalid shell command: command is required; id and budgetMs require action wait\");\n\t\t\tconst { command } = bashCommand;\n\t\t\tconst timeout = normalizeTimeoutSeconds(bashCommand.timeout);\n\t\t\tvalidateBashWait(bashCommand.wait, !!options?.operations || !!options?.taskOwner);\n\t\t\tif (bashCommand.heartbeatMs !== undefined) validateTaskHeartbeatMs(bashCommand.heartbeatMs);\n\t\t\tconst sessionEnvironment = snapshotBashSessionEnvironment(ctx, exposeSessionEnvironment);\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst hasExplicitCwd = typeof bashCommand.cwd === \"string\";\n\t\t\tconst cwdInput = hasExplicitCwd\n\t\t\t\t\t? await expandShellInternalUrls(bashCommand.cwd!, executionCwd, resourceCtx)\n\t\t\t\t\t: executionCwd,\n\t\t\t\trequestedCwd = resolvePath(executionCwd, cwdInput);\n\t\t\tconst expandedCommand = await expandShellInternalUrls(\n\t\t\t\tcommand,\n\t\t\t\texecutionCwd,\n\t\t\t\tresourceCtx,\n\t\t\t\ttrue,\n\t\t\t\toptions?.shellDialect,\n\t\t\t);\n\t\t\tconst strippedExpandedContext = hasExplicitCwd\n\t\t\t\t? undefined\n\t\t\t\t: stripLeadingCdCommand(expandedCommand, requestedCwd);\n\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${expandedCommand}` : expandedCommand;\n\t\t\tconst spawnContext = resolveSpawnContext(resolvedCommand, requestedCwd, sessionEnvironment, spawnHook);\n\t\t\tconst strippedCdContext = strippedExpandedContext\n\t\t\t\t? resolveSpawnContext(\n\t\t\t\t\t\tcommandPrefix\n\t\t\t\t\t\t\t? `${commandPrefix}\\n${strippedExpandedContext.command}`\n\t\t\t\t\t\t\t: strippedExpandedContext.command,\n\t\t\t\t\t\tstrippedExpandedContext.cwd,\n\t\t\t\t\t\tsessionEnvironment,\n\t\t\t\t\t\tspawnHook,\n\t\t\t\t\t)\n\t\t\t\t: undefined;\n\t\t\tlet expandedEnv: NodeJS.ProcessEnv | undefined;\n\t\t\tif (bashCommand.env) {\n\t\t\t\texpandedEnv = {};\n\t\t\t\tfor (const [key, value] of Object.entries(bashCommand.env)) {\n\t\t\t\t\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) throw new Error(`Invalid bash env name: ${key}`);\n\t\t\t\t\texpandedEnv[key] = await expandShellInternalUrls(value, executionCwd, resourceCtx);\n\t\t\t\t}\n\t\t\t\tspawnContext.env = { ...spawnContext.env, ...expandedEnv };\n\t\t\t}\n\t\t\tif (strippedCdContext && expandedEnv) strippedCdContext.env = { ...strippedCdContext.env, ...expandedEnv };\n\t\t\tapplyBashSessionEnvironment(spawnContext.env, sessionEnvironment);\n\t\t\tif (strippedCdContext) applyBashSessionEnvironment(strippedCdContext.env, sessionEnvironment);\n\t\t\tconst executionContext = strippedCdContext ?? spawnContext;\n\t\t\tconst output = new OutputAccumulator({\n\t\t\t\ttempFilePrefix: presentation.tempFilePrefix,\n\t\t\t\ttempDir: resolveSessionTempDir(),\n\t\t\t});\n\t\t\tlet acceptingOutput = true;\n\t\t\tlet updateTimer: NodeJS.Timeout | undefined;\n\t\t\tlet updateDirty = false;\n\t\t\tlet lastUpdateAt = 0;\n\t\t\tconst emitOutputUpdate = () => {\n\t\t\t\tif (!onUpdate || !updateDirty) return;\n\t\t\t\tupdateDirty = false;\n\t\t\t\tlastUpdateAt = Date.now();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\tonUpdate({\n\t\t\t\t\tcontent: [{ type: \"text\", text: snapshot.content || \"\" }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\ttruncation: snapshot.truncation.truncated ? snapshot.truncation : undefined,\n\t\t\t\t\t\tfullOutputPath: snapshot.fullOutputPath,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t};\n\t\t\tconst clearUpdateTimer = () => {\n\t\t\t\tif (updateTimer) {\n\t\t\t\t\tclearTimeout(updateTimer);\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst scheduleOutputUpdate = () => {\n\t\t\t\tif (!onUpdate) return;\n\t\t\t\tupdateDirty = true;\n\t\t\t\tconst delay = BASH_UPDATE_THROTTLE_MS - (Date.now() - lastUpdateAt);\n\t\t\t\tif (delay <= 0) {\n\t\t\t\t\tclearUpdateTimer();\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tupdateTimer ??= setTimeout(() => {\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t}, delay);\n\t\t\t};\n\t\t\tif (onUpdate) {\n\t\t\t\tonUpdate({ content: [], details: undefined });\n\t\t\t}\n\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\tif (!acceptingOutput) return;\n\t\t\t\toutput.append(data);\n\t\t\t\tscheduleOutputUpdate();\n\t\t\t};\n\t\t\tconst finishOutput = async () => {\n\t\t\t\tacceptingOutput = false;\n\t\t\t\toutput.finish();\n\t\t\t\tclearUpdateTimer();\n\t\t\t\temitOutputUpdate();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\ttry {\n\t\t\t\t\tawait output.closeTempFile();\n\t\t\t\t} catch {\n\t\t\t\t\t// The spill file could not be flushed. Keep the truncated result, but\n\t\t\t\t\t// re-read the snapshot so the now-cleared path is not advertised.\n\t\t\t\t\treturn output.snapshot();\n\t\t\t\t}\n\t\t\t\treturn snapshot;\n\t\t\t};\n\t\t\tconst formatOutput = (snapshot: Awaited<ReturnType<typeof finishOutput>>, emptyText = \"(no output)\") => {\n\t\t\t\tconst truncation = snapshot.truncation;\n\t\t\t\tlet text = snapshot.content || emptyText;\n\t\t\t\tlet details: BashToolDetails | undefined;\n\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\tdetails = { truncation, fullOutputPath: snapshot.fullOutputPath };\n\t\t\t\t\tconst startLine = truncation.totalLines - truncation.outputLines + 1;\n\t\t\t\t\tconst endLine = truncation.totalLines;\n\t\t\t\t\t// Persistence can be refused (a temp directory we will not write\n\t\t\t\t\t// through, a full or read-only disk), and then there is no path to\n\t\t\t\t\t// name. Every other renderer already omits the clause; this one must\n\t\t\t\t\t// too, rather than handing the model the string \"undefined\".\n\t\t\t\t\tconst fullOutputNote = snapshot.fullOutputPath ? ` Full output: ${snapshot.fullOutputPath}` : \"\";\n\t\t\t\t\tif (truncation.lastLinePartial) {\n\t\t\t\t\t\tconst lastLineSize = formatSize(output.getLastLineBytes());\n\t\t\t\t\t\ttext += `\\n\\n[Showing last ${formatSize(truncation.outputBytes)} of line ${endLine} (line is ${lastLineSize}).${fullOutputNote}]`;\n\t\t\t\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines}.${fullOutputNote}]`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(DEFAULT_MAX_BYTES)} limit).${fullOutputNote}]`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { text, details };\n\t\t\t};\n\t\t\tconst startedAt = Date.now();\n\t\t\tconst withTiming = (details: BashToolDetails | undefined): BashToolDetails => ({\n\t\t\t\t...details,\n\t\t\t\ttimeoutSeconds: timeout,\n\t\t\t\t...(bashCommand.timeout !== undefined && bashCommand.timeout !== timeout\n\t\t\t\t\t? { requestedTimeoutSeconds: bashCommand.timeout }\n\t\t\t\t\t: {}),\n\t\t\t\twallTimeMs: Date.now() - startedAt,\n\t\t\t});\n\t\t\tconst appendStatus = (text: string, status: string) => `${text ? `${text}\\n\\n` : \"\"}${status}`;\n\t\t\ttry {\n\t\t\t\tlet exitCode: number | null;\n\t\t\t\tlet observation: SupervisedCommandResult[\"observation\"];\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await defaultOps.exec(executionContext.command, executionContext.cwd, {\n\t\t\t\t\t\tonData: handleData,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\twait: bashCommand.wait,\n\t\t\t\t\t\tenv: executionContext.env,\n\t\t\t\t\t\tpty: bashCommand.pty,\n\t\t\t\t\t\t...(bashCommand.heartbeatMs === undefined ? {} : { heartbeatMs: bashCommand.heartbeatMs }),\n\t\t\t\t\t});\n\t\t\t\t\texitCode = result.exitCode;\n\t\t\t\t\tobservation = result.observation;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\t\tconst { text } = formatOutput(snapshot, \"\");\n\t\t\t\t\tif (err instanceof Error && err.message === \"aborted\") {\n\t\t\t\t\t\tthrow new Error(appendStatus(text, \"Command aborted\"));\n\t\t\t\t\t}\n\t\t\t\t\tif (err instanceof ShellTimeoutError) {\n\t\t\t\t\t\tthrow new Error(appendStatus(text, err.describe()), { cause: err });\n\t\t\t\t\t}\n\t\t\t\t\t// Custom BashOperations, the PTY and the PowerShell backends report a timeout as `timeout:<seconds>`.\n\t\t\t\t\tif (err instanceof Error && err.message.startsWith(\"timeout:\")) {\n\t\t\t\t\t\tconst timeoutSecs = err.message.split(\":\")[1];\n\t\t\t\t\t\tthrow new Error(appendStatus(text, `Command timed out after ${timeoutSecs} seconds`), { cause: err });\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\tconst { text: outputText, details } = formatOutput(snapshot);\n\t\t\t\tif (observation?.kind === \"yielded\")\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: appendStatus(outputText, `Command is still running (task ${observation.taskId}).`),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: { ...withTiming(details), observation },\n\t\t\t\t\t};\n\t\t\t\tif (exitCode === null) {\n\t\t\t\t\tthrow new Error(appendStatus(outputText, \"Command terminated without an exit code\"));\n\t\t\t\t}\n\t\t\t\tconst fullOutput = await output.readFullOutput(STRUCTURED_OUTPUT_MAX_BYTES);\n\t\t\t\tconst structuredContent = {\n\t\t\t\t\toutput: fullOutput.content,\n\t\t\t\t\ttruncated: fullOutput.truncated,\n\t\t\t\t\t...(fullOutput.truncated && snapshot.fullOutputPath\n\t\t\t\t\t\t? { full_output_path: snapshot.fullOutputPath }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\texit_code: exitCode,\n\t\t\t\t\twall_time_seconds: Math.round((Date.now() - startedAt) / 100) / 10,\n\t\t\t\t};\n\t\t\t\tif (exitCode !== 0) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: appendStatus(outputText, `Command exited with code ${exitCode}`) }],\n\t\t\t\t\t\tdetails: { ...withTiming(details), exitCode },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\tstructuredContent,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: outputText }], details: withTiming(details), structuredContent };\n\t\t\t} finally {\n\t\t\t\tinvalidateNativeSearchCache();\n\t\t\t\tclearUpdateTimer();\n\t\t\t}\n\t\t},\n\t\trenderCall(args, _theme, context) {\n\t\t\tstartToolTimer(context);\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatBashCall(args, presentation.prompt));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, _theme, context) {\n\t\t\t// A command yielded to the background is still running, so its row reports how long it was observed.\n\t\t\tconst finalLabel = result.details?.observation?.kind === \"yielded\" ? \"Observed for\" : \"Took\";\n\t\t\tconst timerText = toolTimerText(context, options.isPartial, finalLabel);\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tconst waited =\n\t\t\t\tcontext.args.action === \"wait\" &&\n\t\t\t\trebuildShellWaitResult(component, result, options, {\n\t\t\t\t\tshowImages: context.showImages,\n\t\t\t\t\tisError: context.isError,\n\t\t\t\t\ttaskId: context.args.id,\n\t\t\t\t\ttimerText,\n\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t});\n\t\t\tif (!waited) {\n\t\t\t\trebuildBashResultRenderComponent(component, result, options, context.showImages, timerText, context.cwd);\n\t\t\t}\n\t\t\tcomponent.invalidate();\n\t\t\treturn component;\n\t\t},\n\t};\n}\nexport function createBashTool(cwd: string, options?: BashToolOptions): AgentTool<typeof bashSchema> {\n\treturn wrapToolDefinition(createBashToolDefinition(cwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EACN,cAAc,EACd,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAE/G,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EAGxB,gBAAgB,EAChB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AAG;iBAChB,CAAC,CAAC;YACJ,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,gCAAgC,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1G,CAAC;YACD,SAAS,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { constants } from \"node:fs\";\nimport { access as fsAccess, stat as fsStat } from \"node:fs/promises\";\nimport { constants as osConstants } from \"node:os\";\nimport { resolve as resolvePath } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { APP_NAME } from \"../../config.js\";\nimport { theme } from \"../../modes/interactive/theme/theme.js\";\nimport { createChildProcessEnvironment, waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetShellConfig,\n\tgetShellEnv,\n\tkillProcessTree,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { formatTimeoutSeconds, longerRunAdvice, MAX_COMMAND_TIMEOUT_SECONDS } from \"../tasks/cancel-reason.js\";\nimport type { WaitPolicy } from \"../tasks/contracts.js\";\nimport { validateTaskHeartbeatMs } from \"../tasks/heartbeat-notice.js\";\nimport { stripLeadingCdCommand } from \"./bash-leading-cd.ts\";\nimport {\n\texecuteNativePty,\n\texecuteSupervisedCommand,\n\ttype SupervisedCommandOwner,\n\ttype SupervisedCommandResult,\n\tvalidateBashWait,\n\twaitForSupervisedCommand,\n} from \"./bash-pty-native.js\";\nimport { applyBashSessionEnvironment, snapshotBashSessionEnvironment } from \"./bash-session-environment.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport {\n\tgetTextOutput,\n\tinvalidArgText,\n\tlinkPath,\n\tstartToolTimer,\n\tstr,\n\ttype ToolTimerState,\n\ttoolTimerText,\n} from \"./render-utils.ts\";\nimport { expandShellInternalUrls, type InternalResourceContext } from \"./resource-selectors.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { ShellTimeoutError } from \"./shell-errors.ts\";\nimport { addShellOutputPreview, formatTruncationNotice, rebuildShellWaitResult } from \"./shell-task-render.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult } from \"./truncate.ts\";\n\nconst STRUCTURED_OUTPUT_MAX_BYTES = 1024 * 1024;\nconst bashOutputSchema = Type.Object({\n\toutput: Type.String({\n\t\tdescription: \"Combined stdout and stderr, up to 1 MiB, keeping the first and last 512 KiB when longer.\",\n\t}),\n\ttruncated: Type.Boolean(),\n\tfull_output_path: Type.Optional(Type.String()),\n\texit_code: Type.Number(),\n\twall_time_seconds: Type.Number(),\n});\n\nconst envSchema = Type.Unsafe<Record<string, string>>({\n\ttype: \"object\",\n\tdescription: \"Environment variables to add or override.\",\n\tadditionalProperties: { type: \"string\" },\n\tpropertyNames: { pattern: \"^[A-Za-z_][A-Za-z0-9_]*$\" },\n});\nconst bashBaseSchema = Type.Object(\n\t{\n\t\tcommand: Type.String({ description: \"Shell command to execute.\" }),\n\t\tenv: Type.Optional(envSchema),\n\t\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds.\" })),\n\t\twait: Type.Optional(\n\t\t\tType.Unsafe<WaitPolicy>({\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tkind: { type: \"string\", enum: [\"background\", \"foreground\"] },\n\t\t\t\t\tbudgetMs: {\n\t\t\t\t\t\ttype: \"number\",\n\t\t\t\t\t\tminimum: 0,\n\t\t\t\t\t\tdescription: \"Foreground observation budget in milliseconds; only valid with foreground.\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"kind\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Observation policy, independent of execution timeout. Omit for owner-configured automatic yield (default 10s).\",\n\t\t\t}),\n\t\t),\n\t\tcwd: Type.Optional(Type.String({ description: \"Working directory for the command.\" })),\n\t\tpty: Type.Optional(Type.Boolean({ description: \"Run with PTY handling.\" })),\n\t\theartbeatMs: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: \"Heartbeat cadence in ms while this runs as a task (default 15 min; 0 disables; min 60000).\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\ntype ShellCommandInput = Static<typeof bashBaseSchema> & { action?: never; id?: never; budgetMs?: never };\ntype ShellWaitInput = { action: \"wait\"; id: string; budgetMs?: number } & Partial<\n\tRecord<keyof Static<typeof bashBaseSchema>, never>\n>;\nconst bashSchema = Type.Unsafe<ShellCommandInput | ShellWaitInput>({\n\t...bashBaseSchema,\n\tproperties: {\n\t\t...bashBaseSchema.properties,\n\t\taction: {\n\t\t\ttype: \"string\",\n\t\t\tenum: [\"wait\"],\n\t\t\tdescription: \"Observe an existing asynchronous task without executing a command.\",\n\t\t},\n\t\tid: { type: \"string\", description: \"Existing task ID owned by this session.\" },\n\t\tbudgetMs: {\n\t\t\ttype: \"number\",\n\t\t\tminimum: 0,\n\t\t\tdescription: \"Observation budget in milliseconds; omitted uses owner policy.\",\n\t\t},\n\t},\n\trequired: [],\n});\nconst shellCommandKeys = Object.keys(bashBaseSchema.properties);\n\nfunction prepareShellInput(args: unknown): BashToolInput {\n\tif (typeof args !== \"object\" || args === null || Array.isArray(args)) return args as BashToolInput;\n\tconst has = (key: string) => Object.hasOwn(args, key);\n\tif (has(\"action\")) {\n\t\tif (!has(\"id\") || shellCommandKeys.some(has))\n\t\t\tthrow new Error(\"Invalid shell wait: expected action wait, id, and optional finite non-negative budgetMs\");\n\t} else if (!has(\"command\") || has(\"id\") || has(\"budgetMs\")) {\n\t\tthrow new Error(\"Invalid shell command: command is required; id and budgetMs require action wait\");\n\t}\n\treturn args as BashToolInput;\n}\nexport const bashToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Execute a shell command.\",\n\tguidelines: Object.freeze([\n\t\t\"You can inspect ATOMIC_* or PI_* environment variables for current model and session details.\",\n\t\t'Use { action: \"wait\", id: taskId } to observe an existing shell task with the owner policy. Avoid repeated short polls; await completion notifications when no dependent work is blocked. Never relaunch a yielded command. Waiting does not extend execution timeout or owner lifetime.',\n\t\t\"For ordinary commands, omit wait to use the owner's observation policy (normally 10s). Do not routinely request one-second waits: premature yields add tool calls without making the command faster. Use a short budget only for a concrete responsiveness need, or explicit background observation when you have independent work to do. Explicit budgets, including zero for polling, remain available.\",\n\t\t\"Choose foreground or background shell observation as needed without asking the user each time. Background yields after admission; foreground waits for its optional budget then the same command continues in background. Omitted wait uses owner-configured automatic background yield (default 10s). Observation never changes the execution timeout, which stops the command. Background requires a supported task owner; unbound foreground waits until completion regardless of budget.\",\n\t] as const),\n} as const);\nexport type BashToolInput = Static<typeof bashSchema>;\nexport interface BashToolDetails {\n\ttruncation?: TruncationResult;\n\tfullOutputPath?: string;\n\texitCode?: number | null;\n\tobservation?: import(\"../tasks/contracts.js\").WaitOutcome;\n\ttimeoutSeconds?: number;\n\trequestedTimeoutSeconds?: number;\n\twallTimeMs?: number;\n}\nconst DEFAULT_TIMEOUT_SECONDS = 300,\n\tMAX_TIMEOUT_SECONDS = MAX_COMMAND_TIMEOUT_SECONDS;\nexport function validateExplicitTimeoutSeconds(timeout: number): void {\n\tif (!Number.isFinite(timeout) || timeout <= 0 || timeout > MAX_TIMEOUT_SECONDS)\n\t\tthrow new Error(\n\t\t\t`Invalid timeout ${String(timeout)}: timeout must be a finite number greater than 0 and no more than ${MAX_TIMEOUT_SECONDS} seconds`,\n\t\t);\n}\nconst STILL_RUNNING = (taskId: string) => `Command is still running (task ${taskId}).`;\n\n/**\n * The text a launch that continues in the background ends with: its task, and the execution timeout that stops it\n * whether or not anyone waits on it, so a long run is not stopped by a default nobody saw (#4639).\n */\nexport function stillRunningReceipt(taskId: string, timeoutSeconds: number): string {\n\treturn `${STILL_RUNNING(taskId)} Its execution timeout stops it after ${formatTimeoutSeconds(timeoutSeconds * 1000)}; ${longerRunAdvice(timeoutSeconds * 1000, \"launch\")}`;\n}\n\nfunction normalizeTimeoutSeconds(timeout: number | undefined): number {\n\tif (timeout === undefined) return DEFAULT_TIMEOUT_SECONDS;\n\tvalidateExplicitTimeoutSeconds(timeout);\n\treturn Math.max(1, Math.floor(timeout));\n}\nexport type BashOutputChannel = \"stdout\" | \"stderr\";\nexport interface BashOperations {\n\texec: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tonData: (data: Buffer, channel?: BashOutputChannel) => void;\n\t\t\tsignal?: AbortSignal;\n\t\t\ttimeout?: number;\n\t\t\twait?: WaitPolicy;\n\t\t\tenv?: NodeJS.ProcessEnv;\n\t\t\tpty?: boolean;\n\t\t\t/** Task heartbeat cadence for a supervised command; `0` disables. Omitted uses the owner default. */\n\t\t\theartbeatMs?: number;\n\t\t},\n\t) => Promise<SupervisedCommandResult>;\n}\nexport function createLocalBashOperations(options?: {\n\tshellPath?: string;\n\ttaskOwner?: SupervisedCommandOwner;\n}): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, { onData, signal, timeout, wait, env, pty, heartbeatMs }) => {\n\t\t\tvalidateBashWait(wait, !!options?.taskOwner);\n\t\t\tif (timeout !== undefined) validateExplicitTimeoutSeconds(timeout);\n\t\t\tif (pty && process.env.PI_NO_PTY !== \"1\" && process.env.ATOMIC_NO_PTY !== \"1\") {\n\t\t\t\ttry {\n\t\t\t\t\treturn await executeNativePty(command, cwd, {\n\t\t\t\t\t\tonData: (data) => onData(data, \"stdout\"),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\twait,\n\t\t\t\t\t\tenv,\n\t\t\t\t\t\theartbeatMs,\n\t\t\t\t\t\tshellPath: options?.shellPath,\n\t\t\t\t\t\ttaskOwner: options?.taskOwner,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options?.taskOwner) throw error;\n\t\t\t\t\tconst message = String(error instanceof Error ? error.message : error);\n\t\t\t\t\tif (!message.includes(\"Native PTY\") && !message.includes(\"PtySession\")) throw error;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst shellConfig = getShellConfig(options?.shellPath);\n\t\t\ttry {\n\t\t\t\tconst cwdStat = await fsStat(cwd);\n\t\t\t\tif (!cwdStat.isDirectory()) throw new Error(`Working directory is not a directory: ${cwd}`);\n\t\t\t\tawait fsAccess(cwd, constants.F_OK);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error && error.message.startsWith(\"Working directory is not a directory\")) throw error;\n\t\t\t\tthrow new Error(`Working directory does not exist: ${cwd}\\nCannot execute bash commands.`);\n\t\t\t}\n\t\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\t\t\tif (options?.taskOwner)\n\t\t\t\treturn executeSupervisedCommand(\n\t\t\t\t\tcommand,\n\t\t\t\t\tcwd,\n\t\t\t\t\t{\n\t\t\t\t\t\tonData,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\twait,\n\t\t\t\t\t\tenv,\n\t\t\t\t\t\theartbeatMs,\n\t\t\t\t\t\tshellPath: options.shellPath,\n\t\t\t\t\t\ttaskOwner: options.taskOwner,\n\t\t\t\t\t},\n\t\t\t\t\tfalse,\n\t\t\t\t);\n\t\t\tconst commandFromStdin = shellConfig.commandTransport === \"stdin\";\n\t\t\tconst child = spawn(shellConfig.shell, commandFromStdin ? shellConfig.args : [...shellConfig.args, command], {\n\t\t\t\tcwd,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tenv: createChildProcessEnvironment(undefined, env ?? getShellEnv()),\n\t\t\t\tstdio: [commandFromStdin ? \"pipe\" : \"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (commandFromStdin) {\n\t\t\t\tchild.stdin?.on(\"error\", () => {});\n\t\t\t\tchild.stdin?.end(command);\n\t\t\t}\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tconst startedAt = performance.now();\n\t\t\tlet shellExitedAfterMs: number | undefined;\n\t\t\tchild.once(\"exit\", () => {\n\t\t\t\tshellExitedAfterMs = performance.now() - startedAt;\n\t\t\t});\n\t\t\t// Set when the deadline fires, with the shell's exit time if it had already exited.\n\t\t\tlet deadline: { timeoutSeconds: number; elapsedMs: number; shellExitedAfterMs?: number } | undefined;\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tif (timeout !== undefined && timeout > 0) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\tdeadline = {\n\t\t\t\t\t\t\ttimeoutSeconds: timeout,\n\t\t\t\t\t\t\telapsedMs: Math.round(performance.now() - startedAt),\n\t\t\t\t\t\t\tshellExitedAfterMs,\n\t\t\t\t\t\t};\n\t\t\t\t\t\t// Also when the shell already exited: on Unix the group kill still reaches background\n\t\t\t\t\t\t// processes holding the pipes. Windows cannot find them once the shell pid is gone.\n\t\t\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\t\t}, timeout * 1000);\n\t\t\t\t}\n\t\t\t\tchild.stdout?.on(\"data\", (data: Buffer) => onData(data, \"stdout\"));\n\t\t\t\tchild.stderr?.on(\"data\", (data: Buffer) => onData(data, \"stderr\"));\n\t\t\t\tif (signal) {\n\t\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t\t\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\tconst exitCode = await waitForChildProcess(child);\n\t\t\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\t\t\t\t// A signal-killed shell has no exit code. Use the standard shell convention so\n\t\t\t\t// callers do not mistake the termination for a successful command.\n\t\t\t\tconst signalCode = child.signalCode;\n\t\t\t\tconst resolvedExitCode = exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1);\n\t\t\t\tif (deadline) {\n\t\t\t\t\tconst { timeoutSeconds, elapsedMs, shellExitedAfterMs: exitedAfterMs } = deadline;\n\t\t\t\t\tthrow new ShellTimeoutError({\n\t\t\t\t\t\ttimeoutSeconds,\n\t\t\t\t\t\telapsedMs,\n\t\t\t\t\t\t...(exitedAfterMs === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tshellExit: {\n\t\t\t\t\t\t\t\t\t\texitCode: resolvedExitCode,\n\t\t\t\t\t\t\t\t\t\tafterSeconds: Math.round(exitedAfterMs / 100) / 10,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn { exitCode: resolvedExitCode };\n\t\t\t} finally {\n\t\t\t\tif (child.pid) untrackDetachedChildPid(child.pid);\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\nexport interface BashSpawnContext {\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n}\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\nfunction resolveSpawnContext(\n\tcommand: string,\n\tcwd: string,\n\tsessionEnvironment: NodeJS.ProcessEnv,\n\tspawnHook?: BashSpawnHook,\n): BashSpawnContext {\n\tconst baseContext: BashSpawnContext = { command, cwd, env: { ...getShellEnv() } };\n\tapplyBashSessionEnvironment(baseContext.env, sessionEnvironment);\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\n}\nexport interface BashToolOptions {\n\toperations?: BashOperations;\n\t/** Trusted host ownership; never supplied by model arguments. */\n\ttaskOwner?: SupervisedCommandOwner;\n\t/** Expose the execution-time Atomic session snapshot and PI compatibility aliases. Default: true. */\n\texposeSessionEnvironment?: boolean;\n\t/** Prefix prepended to every shell command before execution. */\n\tcommandPrefix?: string;\n\t/** Override shell executable resolution for local bash operations. */\n\tshellPath?: string;\n\t/** Dialect for generated internal-URL path literals. Defaults to POSIX; does not select the executable. */\n\tshellDialect?: \"posix\" | \"powershell\";\n\t/** Last-mile hook for rewriting the command/cwd/env spawn context. */\n\tspawnHook?: BashSpawnHook;\n\t/**\n\t * Session-scoped directory for overflow logs, resolved per execution so a\n\t * session switch (fork, branch, resume) follows the live transcript session.\n\t */\n\tsessionTempDir?: string | (() => string | undefined);\n}\n/**\n * Presentation identity for a shell-backed built-in tool. Atomic runs PowerShell\n * through the same execution pipeline as bash, so the transcript prompt and the\n * overflow temp-file prefix are the only shell-specific display values.\n */\nexport interface ShellToolPresentation {\n\t/** Transcript prompt prefix: `$` for bash, `PS>` for PowerShell. */\n\tprompt: string;\n\t/** Prefix for the temp file that holds truncated output. */\n\ttempFilePrefix: string;\n}\nexport const BASH_SHELL_PRESENTATION: ShellToolPresentation = {\n\tprompt: \"$\",\n\ttempFilePrefix: `${APP_NAME}-bash`,\n};\nconst BASH_UPDATE_THROTTLE_MS = 100;\nfunction formatBashCall(\n\targs: { command?: string; timeout?: number; action?: string; id?: string } | undefined,\n\tprompt: string,\n): string {\n\tif (args?.action === \"wait\") return theme.fg(\"toolTitle\", theme.bold(`${prompt} wait ${str(args.id) ?? \"...\"}`));\n\tconst command = str(args?.command);\n\tconst timeout = args?.timeout as number | undefined;\n\tconst timeoutSuffix = timeout ? theme.fg(\"muted\", ` (timeout ${timeout}s)`) : \"\";\n\tconst commandDisplay = command === null ? invalidArgText(theme) : command ? command : theme.fg(\"toolOutput\", \"...\");\n\treturn theme.fg(\"toolTitle\", theme.bold(`${prompt} ${commandDisplay}`)) + timeoutSuffix;\n}\nfunction rebuildBashResultRenderComponent(\n\tcomponent: Container,\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: BashToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\tshowImages: boolean,\n\ttimerText: string | undefined,\n\tcwd: string,\n): void {\n\tcomponent.clear();\n\tlet output = getTextOutput(result, showImages).trim();\n\tconst observation = result.details?.observation;\n\tif (observation?.kind === \"yielded\") {\n\t\tconst receiptAt = output.lastIndexOf(STILL_RUNNING(observation.taskId));\n\t\tif (receiptAt >= 0) output = output.slice(0, receiptAt).trimEnd();\n\t\tcomponent.addChild(new Text(theme.fg(\"accent\", \"∀ Continued in background\"), 0, 0));\n\t\tcomponent.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\"dim\", `/tasks to inspect output or stop${options.expanded ? ` · ${observation.taskId}` : \"\"}`),\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t}\n\tconst truncation = result.details?.truncation;\n\tconst fullOutputPath = result.details?.fullOutputPath;\n\tif (!options.isPartial && truncation?.truncated && fullOutputPath && output.endsWith(\"]\")) {\n\t\tconst footerStart = output.lastIndexOf(\"\\n\\n[\");\n\t\tif (footerStart !== -1 && output.slice(footerStart).includes(fullOutputPath)) {\n\t\t\toutput = output.slice(0, footerStart).trimEnd();\n\t\t}\n\t}\n\tif (output) addShellOutputPreview(component, output, options.expanded);\n\tif (truncation?.truncated || fullOutputPath) {\n\t\tconst warnings: string[] = [];\n\t\tif (truncation?.truncated) warnings.push(formatTruncationNotice(truncation));\n\t\tif (fullOutputPath) warnings.push(\"Full output:\");\n\t\tcomponent.addChild(new Text(`\\n${theme.fg(\"warning\", `[${warnings.join(\". \")}]`)}`, 0, 0));\n\t\t// The path gets a line of its own so word wrap never splits it at a space beside its label, and a link so a\n\t\t// path wider than the terminal still opens (and copies) whole.\n\t\tif (fullOutputPath) {\n\t\t\tcomponent.addChild(new Text(theme.fg(\"warning\", linkPath(fullOutputPath, fullOutputPath, cwd)), 0, 0));\n\t\t}\n\t}\n\tif (timerText) component.addChild(new Text(`\\n${theme.fg(\"muted\", timerText)}`, 0, 0));\n}\nexport function createBashToolDefinition(\n\tcwd: string,\n\toptions?: BashToolOptions,\n\tpresentation: ShellToolPresentation = BASH_SHELL_PRESENTATION,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, ToolTimerState> {\n\tconst defaultOps =\n\t\toptions?.operations ??\n\t\tcreateLocalBashOperations({ shellPath: options?.shellPath, taskOwner: options?.taskOwner });\n\tconst commandPrefix = options?.commandPrefix,\n\t\texposeSessionEnvironment = options?.exposeSessionEnvironment ?? true;\n\tconst spawnHook = options?.spawnHook;\n\tconst sessionTempDirOption = options?.sessionTempDir;\n\tconst resolveSessionTempDir = (): string | undefined =>\n\t\ttypeof sessionTempDirOption === \"function\" ? sessionTempDirOption() : sessionTempDirOption;\n\treturn {\n\t\tname: \"bash\",\n\t\tconcurrency: (args) => (args.pty === true ? \"exclusive\" : \"shared\"),\n\t\tdetachable: (args) => args.action === \"wait\" && args.budgetMs === undefined,\n\t\tlabel: \"bash\",\n\t\tdescription:\n\t\t\t'Execute a shell command with optional PTY handling and foreground/background observation, or observe an existing task with action: \"wait\", id, and optional budgetMs. Omitted command wait uses owner policy (default 10s). Observation never changes execution timeout. Background and existing-task waits require a supported task owner; unbound foreground execution waits until completion.',\n\t\tpromptSnippet: bashToolSystemPromptContribution.snippet,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tpromptGuidelines: exposeSessionEnvironment ? [...bashToolSystemPromptContribution.guidelines] : undefined,\n\t\tprepareArguments: prepareShellInput,\n\t\tparameters: bashSchema,\n\t\toutputSchema: bashOutputSchema,\n\t\tmaxResultSizeChars: Infinity,\n\t\tasync execute(_toolCallId, bashCommand: BashToolInput, signal?: AbortSignal, onUpdate?, ctx?: ExtensionContext) {\n\t\t\tif (bashCommand.action !== undefined) {\n\t\t\t\tif (\n\t\t\t\t\tbashCommand.action !== \"wait\" ||\n\t\t\t\t\ttypeof bashCommand.id !== \"string\" ||\n\t\t\t\t\tObject.keys(bashCommand).some((key) => ![\"action\", \"id\", \"budgetMs\"].includes(key)) ||\n\t\t\t\t\t(bashCommand.budgetMs !== undefined &&\n\t\t\t\t\t\t(typeof bashCommand.budgetMs !== \"number\" ||\n\t\t\t\t\t\t\t!Number.isFinite(bashCommand.budgetMs) ||\n\t\t\t\t\t\t\tbashCommand.budgetMs < 0))\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Invalid shell wait: expected action wait, id, and optional finite non-negative budgetMs\",\n\t\t\t\t\t);\n\t\t\t\treturn waitForSupervisedCommand(options?.taskOwner, bashCommand.id, bashCommand.budgetMs, signal, {\n\t\t\t\t\ttempFilePrefix: presentation.tempFilePrefix,\n\t\t\t\t\ttempDir: resolveSessionTempDir(),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (\n\t\t\t\tbashCommand.id !== undefined ||\n\t\t\t\tbashCommand.budgetMs !== undefined ||\n\t\t\t\ttypeof bashCommand.command !== \"string\"\n\t\t\t)\n\t\t\t\tthrow new Error(\"Invalid shell command: command is required; id and budgetMs require action wait\");\n\t\t\tconst { command } = bashCommand;\n\t\t\tconst timeout = normalizeTimeoutSeconds(bashCommand.timeout);\n\t\t\tvalidateBashWait(bashCommand.wait, !!options?.operations || !!options?.taskOwner);\n\t\t\tif (bashCommand.heartbeatMs !== undefined) validateTaskHeartbeatMs(bashCommand.heartbeatMs);\n\t\t\tconst sessionEnvironment = snapshotBashSessionEnvironment(ctx, exposeSessionEnvironment);\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst hasExplicitCwd = typeof bashCommand.cwd === \"string\";\n\t\t\tconst cwdInput = hasExplicitCwd\n\t\t\t\t\t? await expandShellInternalUrls(bashCommand.cwd!, executionCwd, resourceCtx)\n\t\t\t\t\t: executionCwd,\n\t\t\t\trequestedCwd = resolvePath(executionCwd, cwdInput);\n\t\t\tconst expandedCommand = await expandShellInternalUrls(\n\t\t\t\tcommand,\n\t\t\t\texecutionCwd,\n\t\t\t\tresourceCtx,\n\t\t\t\ttrue,\n\t\t\t\toptions?.shellDialect,\n\t\t\t);\n\t\t\tconst strippedExpandedContext = hasExplicitCwd\n\t\t\t\t? undefined\n\t\t\t\t: stripLeadingCdCommand(expandedCommand, requestedCwd);\n\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${expandedCommand}` : expandedCommand;\n\t\t\tconst spawnContext = resolveSpawnContext(resolvedCommand, requestedCwd, sessionEnvironment, spawnHook);\n\t\t\tconst strippedCdContext = strippedExpandedContext\n\t\t\t\t? resolveSpawnContext(\n\t\t\t\t\t\tcommandPrefix\n\t\t\t\t\t\t\t? `${commandPrefix}\\n${strippedExpandedContext.command}`\n\t\t\t\t\t\t\t: strippedExpandedContext.command,\n\t\t\t\t\t\tstrippedExpandedContext.cwd,\n\t\t\t\t\t\tsessionEnvironment,\n\t\t\t\t\t\tspawnHook,\n\t\t\t\t\t)\n\t\t\t\t: undefined;\n\t\t\tlet expandedEnv: NodeJS.ProcessEnv | undefined;\n\t\t\tif (bashCommand.env) {\n\t\t\t\texpandedEnv = {};\n\t\t\t\tfor (const [key, value] of Object.entries(bashCommand.env)) {\n\t\t\t\t\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) throw new Error(`Invalid bash env name: ${key}`);\n\t\t\t\t\texpandedEnv[key] = await expandShellInternalUrls(value, executionCwd, resourceCtx);\n\t\t\t\t}\n\t\t\t\tspawnContext.env = { ...spawnContext.env, ...expandedEnv };\n\t\t\t}\n\t\t\tif (strippedCdContext && expandedEnv) strippedCdContext.env = { ...strippedCdContext.env, ...expandedEnv };\n\t\t\tapplyBashSessionEnvironment(spawnContext.env, sessionEnvironment);\n\t\t\tif (strippedCdContext) applyBashSessionEnvironment(strippedCdContext.env, sessionEnvironment);\n\t\t\tconst executionContext = strippedCdContext ?? spawnContext;\n\t\t\tconst output = new OutputAccumulator({\n\t\t\t\ttempFilePrefix: presentation.tempFilePrefix,\n\t\t\t\ttempDir: resolveSessionTempDir(),\n\t\t\t});\n\t\t\tlet acceptingOutput = true;\n\t\t\tlet updateTimer: NodeJS.Timeout | undefined;\n\t\t\tlet updateDirty = false;\n\t\t\tlet lastUpdateAt = 0;\n\t\t\tconst emitOutputUpdate = () => {\n\t\t\t\tif (!onUpdate || !updateDirty) return;\n\t\t\t\tupdateDirty = false;\n\t\t\t\tlastUpdateAt = Date.now();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\tonUpdate({\n\t\t\t\t\tcontent: [{ type: \"text\", text: snapshot.content || \"\" }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\ttruncation: snapshot.truncation.truncated ? snapshot.truncation : undefined,\n\t\t\t\t\t\tfullOutputPath: snapshot.fullOutputPath,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t};\n\t\t\tconst clearUpdateTimer = () => {\n\t\t\t\tif (updateTimer) {\n\t\t\t\t\tclearTimeout(updateTimer);\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst scheduleOutputUpdate = () => {\n\t\t\t\tif (!onUpdate) return;\n\t\t\t\tupdateDirty = true;\n\t\t\t\tconst delay = BASH_UPDATE_THROTTLE_MS - (Date.now() - lastUpdateAt);\n\t\t\t\tif (delay <= 0) {\n\t\t\t\t\tclearUpdateTimer();\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tupdateTimer ??= setTimeout(() => {\n\t\t\t\t\tupdateTimer = undefined;\n\t\t\t\t\temitOutputUpdate();\n\t\t\t\t}, delay);\n\t\t\t};\n\t\t\tif (onUpdate) {\n\t\t\t\tonUpdate({ content: [], details: undefined });\n\t\t\t}\n\t\t\tconst handleData = (data: Buffer) => {\n\t\t\t\tif (!acceptingOutput) return;\n\t\t\t\toutput.append(data);\n\t\t\t\tscheduleOutputUpdate();\n\t\t\t};\n\t\t\tconst finishOutput = async () => {\n\t\t\t\tacceptingOutput = false;\n\t\t\t\toutput.finish();\n\t\t\t\tclearUpdateTimer();\n\t\t\t\temitOutputUpdate();\n\t\t\t\tconst snapshot = output.snapshot({ persistIfTruncated: true });\n\t\t\t\ttry {\n\t\t\t\t\tawait output.closeTempFile();\n\t\t\t\t} catch {\n\t\t\t\t\t// The spill file could not be flushed. Keep the truncated result, but\n\t\t\t\t\t// re-read the snapshot so the now-cleared path is not advertised.\n\t\t\t\t\treturn output.snapshot();\n\t\t\t\t}\n\t\t\t\treturn snapshot;\n\t\t\t};\n\t\t\tconst formatOutput = (snapshot: Awaited<ReturnType<typeof finishOutput>>, emptyText = \"(no output)\") => {\n\t\t\t\tconst truncation = snapshot.truncation;\n\t\t\t\tlet text = snapshot.content || emptyText;\n\t\t\t\tlet details: BashToolDetails | undefined;\n\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\tdetails = { truncation, fullOutputPath: snapshot.fullOutputPath };\n\t\t\t\t\tconst startLine = truncation.totalLines - truncation.outputLines + 1;\n\t\t\t\t\tconst endLine = truncation.totalLines;\n\t\t\t\t\t// Persistence can be refused (a temp directory we will not write\n\t\t\t\t\t// through, a full or read-only disk), and then there is no path to\n\t\t\t\t\t// name. Every other renderer already omits the clause; this one must\n\t\t\t\t\t// too, rather than handing the model the string \"undefined\".\n\t\t\t\t\tconst fullOutputNote = snapshot.fullOutputPath ? ` Full output: ${snapshot.fullOutputPath}` : \"\";\n\t\t\t\t\tif (truncation.lastLinePartial) {\n\t\t\t\t\t\tconst lastLineSize = formatSize(output.getLastLineBytes());\n\t\t\t\t\t\ttext += `\\n\\n[Showing last ${formatSize(truncation.outputBytes)} of line ${endLine} (line is ${lastLineSize}).${fullOutputNote}]`;\n\t\t\t\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines}.${fullOutputNote}]`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttext += `\\n\\n[Showing lines ${startLine}-${endLine} of ${truncation.totalLines} (${formatSize(DEFAULT_MAX_BYTES)} limit).${fullOutputNote}]`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn { text, details };\n\t\t\t};\n\t\t\tconst startedAt = Date.now();\n\t\t\tconst withTiming = (details: BashToolDetails | undefined): BashToolDetails => ({\n\t\t\t\t...details,\n\t\t\t\ttimeoutSeconds: timeout,\n\t\t\t\t...(bashCommand.timeout !== undefined && bashCommand.timeout !== timeout\n\t\t\t\t\t? { requestedTimeoutSeconds: bashCommand.timeout }\n\t\t\t\t\t: {}),\n\t\t\t\twallTimeMs: Date.now() - startedAt,\n\t\t\t});\n\t\t\tconst appendStatus = (text: string, status: string) => `${text ? `${text}\\n\\n` : \"\"}${status}`;\n\t\t\ttry {\n\t\t\t\tlet exitCode: number | null;\n\t\t\t\tlet observation: SupervisedCommandResult[\"observation\"];\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await defaultOps.exec(executionContext.command, executionContext.cwd, {\n\t\t\t\t\t\tonData: handleData,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\twait: bashCommand.wait,\n\t\t\t\t\t\tenv: executionContext.env,\n\t\t\t\t\t\tpty: bashCommand.pty,\n\t\t\t\t\t\t...(bashCommand.heartbeatMs === undefined ? {} : { heartbeatMs: bashCommand.heartbeatMs }),\n\t\t\t\t\t});\n\t\t\t\t\texitCode = result.exitCode;\n\t\t\t\t\tobservation = result.observation;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\t\tconst { text } = formatOutput(snapshot, \"\");\n\t\t\t\t\tif (err instanceof Error && err.message === \"aborted\") {\n\t\t\t\t\t\tthrow new Error(appendStatus(text, \"Command aborted\"));\n\t\t\t\t\t}\n\t\t\t\t\tif (err instanceof ShellTimeoutError) {\n\t\t\t\t\t\tthrow new Error(appendStatus(text, err.describe()), { cause: err });\n\t\t\t\t\t}\n\t\t\t\t\t// Custom BashOperations, the PTY and the PowerShell backends report a timeout as `timeout:<seconds>`.\n\t\t\t\t\tif (err instanceof Error && err.message.startsWith(\"timeout:\")) {\n\t\t\t\t\t\tconst timeoutSecs = err.message.split(\":\")[1];\n\t\t\t\t\t\tthrow new Error(appendStatus(text, `Command timed out after ${timeoutSecs} seconds`), { cause: err });\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\tconst snapshot = await finishOutput();\n\t\t\t\tconst { text: outputText, details } = formatOutput(snapshot);\n\t\t\t\tif (observation?.kind === \"yielded\")\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: appendStatus(outputText, stillRunningReceipt(observation.taskId, timeout)),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: { ...withTiming(details), observation },\n\t\t\t\t\t};\n\t\t\t\tif (exitCode === null) {\n\t\t\t\t\tthrow new Error(appendStatus(outputText, \"Command terminated without an exit code\"));\n\t\t\t\t}\n\t\t\t\tconst fullOutput = await output.readFullOutput(STRUCTURED_OUTPUT_MAX_BYTES);\n\t\t\t\tconst structuredContent = {\n\t\t\t\t\toutput: fullOutput.content,\n\t\t\t\t\ttruncated: fullOutput.truncated,\n\t\t\t\t\t...(fullOutput.truncated && snapshot.fullOutputPath\n\t\t\t\t\t\t? { full_output_path: snapshot.fullOutputPath }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\texit_code: exitCode,\n\t\t\t\t\twall_time_seconds: Math.round((Date.now() - startedAt) / 100) / 10,\n\t\t\t\t};\n\t\t\t\tif (exitCode !== 0) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: appendStatus(outputText, `Command exited with code ${exitCode}`) }],\n\t\t\t\t\t\tdetails: { ...withTiming(details), exitCode },\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t\tstructuredContent,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: outputText }], details: withTiming(details), structuredContent };\n\t\t\t} finally {\n\t\t\t\tinvalidateNativeSearchCache();\n\t\t\t\tclearUpdateTimer();\n\t\t\t}\n\t\t},\n\t\trenderCall(args, _theme, context) {\n\t\t\tstartToolTimer(context);\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatBashCall(args, presentation.prompt));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, _theme, context) {\n\t\t\t// A command yielded to the background is still running, so its row reports how long it was observed.\n\t\t\tconst finalLabel = result.details?.observation?.kind === \"yielded\" ? \"Observed for\" : \"Took\";\n\t\t\tconst timerText = toolTimerText(context, options.isPartial, finalLabel);\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tconst waited =\n\t\t\t\tcontext.args.action === \"wait\" &&\n\t\t\t\trebuildShellWaitResult(component, result, options, {\n\t\t\t\t\tshowImages: context.showImages,\n\t\t\t\t\tisError: context.isError,\n\t\t\t\t\ttaskId: context.args.id,\n\t\t\t\t\ttimerText,\n\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t});\n\t\t\tif (!waited) {\n\t\t\t\trebuildBashResultRenderComponent(component, result, options, context.showImages, timerText, context.cwd);\n\t\t\t}\n\t\t\tcomponent.invalidate();\n\t\t\treturn component;\n\t\t},\n\t};\n}\nexport function createBashTool(cwd: string, options?: BashToolOptions): AgentTool<typeof bashSchema> {\n\treturn wrapToolDefinition(createBashToolDefinition(cwd, options));\n}\n"]}
|
|
@@ -18,12 +18,26 @@ import type { WorkflowRunControl } from "../extensions/workflow-run-control.js";
|
|
|
18
18
|
import type { SessionEntry } from "../session-manager-types.ts";
|
|
19
19
|
import type { SessionStore } from "../storage/session/types.js";
|
|
20
20
|
import { type InternalResourceRouter } from "./resource-selectors.ts";
|
|
21
|
+
/** The part of a workflow run control that history:// reads; it can list and read runs, never manage them. */
|
|
22
|
+
export type WorkflowRunHistory = Pick<WorkflowRunControl, "listRuns" | "listProjectRuns" | "getRun">;
|
|
23
|
+
/**
|
|
24
|
+
* Where a session reads its project's history: the project's sessions and its workflow runs. A workflow stage or a
|
|
25
|
+
* subagent gets the history of the session that launched it, since neither holds the project's run control and a
|
|
26
|
+
* subagent keeps its own transcript apart from the project's sessions.
|
|
27
|
+
*/
|
|
28
|
+
export interface ProjectHistory {
|
|
29
|
+
readonly sessionStore: () => SessionStore | undefined;
|
|
30
|
+
readonly workflows: () => WorkflowRunHistory | undefined;
|
|
31
|
+
}
|
|
21
32
|
export interface HistorySources {
|
|
22
33
|
/** The project whose history is visible by default. */
|
|
23
34
|
readonly cwd: string;
|
|
24
35
|
readonly currentSessionId?: string;
|
|
36
|
+
/** The store that holds the current session. */
|
|
25
37
|
readonly sessionStore: () => SessionStore | undefined;
|
|
26
|
-
|
|
38
|
+
/** The store that holds the project's other sessions, when it is not the current session's. */
|
|
39
|
+
readonly projectSessionStore?: () => SessionStore | undefined;
|
|
40
|
+
readonly workflows: () => WorkflowRunHistory | undefined;
|
|
27
41
|
}
|
|
28
42
|
export declare const HISTORY_HELP: string;
|
|
29
43
|
/** The lines `history://sessions/<id>` shows for `entries`, in the form a transcript search returns them. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-protocol.d.ts","sourceRoot":"","sources":["../../../src/core/tools/history-protocol.ts"],"names":[],"mappings":"AAAA;;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,cAAc;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,YAAY,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,SAAS,EAAE,MAAM,kBAAkB,GAAG,SAAS,CAAC;CACzD;AAED,MAAM,WAAW,cAAc;IAC9B,uDAAuD;IACvD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,gDAAgD;IAChD,QAAQ,CAAC,YAAY,EAAE,MAAM,YAAY,GAAG,SAAS,CAAC;IACtD,+FAA+F;IAC/F,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,YAAY,GAAG,SAAS,CAAC;IAC9D,QAAQ,CAAC,SAAS,EAAE,MAAM,kBAAkB,GAAG,SAAS,CAAC;CACzD;AAuBD,eAAO,MAAM,YAAY,QAWb,CAAC;AAuCb,6GAA6G;AAC7G,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,EAAE,CAE/E;AA+BD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,sBAAsB,CAyRnF"}
|
|
@@ -113,8 +113,10 @@ export function createHistoryRouter(sources) {
|
|
|
113
113
|
const projectScope = (target) => target.project === "all"
|
|
114
114
|
? {}
|
|
115
115
|
: { cwd: target.project === undefined ? sources.cwd : resolvePath(target.project, sources.cwd) };
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
const projectStore = () => sources.projectSessionStore?.() ?? sources.sessionStore();
|
|
117
|
+
/** The store that holds session `id`, or the project's sessions without one. */
|
|
118
|
+
const requireStore = (id) => {
|
|
119
|
+
const store = id !== undefined && id === sources.currentSessionId ? sources.sessionStore() : projectStore();
|
|
118
120
|
if (!store)
|
|
119
121
|
throw new Error("Session history is unavailable: this session has no session store.");
|
|
120
122
|
return store;
|
|
@@ -146,7 +148,7 @@ export function createHistoryRouter(sources) {
|
|
|
146
148
|
}
|
|
147
149
|
async function authorizedSessionId(target) {
|
|
148
150
|
const id = target.id ?? "";
|
|
149
|
-
const header = await requireStore().readHeader(id);
|
|
151
|
+
const header = await requireStore(id).readHeader(id);
|
|
150
152
|
if (!header)
|
|
151
153
|
throw new Error(`Session not found: ${id}`);
|
|
152
154
|
if (id === sources.currentSessionId)
|
|
@@ -243,12 +245,12 @@ export function createHistoryRouter(sources) {
|
|
|
243
245
|
}
|
|
244
246
|
const searchLines = (label, lines, request) => searchTextSelectorLines(label, lines.join("\n"), request.pattern, request.ignoreCase, request.literal, request.contextBefore, request.contextAfter);
|
|
245
247
|
async function searchSessions(target, request) {
|
|
246
|
-
const store = requireStore();
|
|
247
248
|
const linkRun = target.project === undefined;
|
|
248
249
|
if (target.id !== undefined) {
|
|
249
250
|
const id = await authorizedSessionId(target);
|
|
250
|
-
return searchLines(sessionUrl(id, target), await loadTranscript(
|
|
251
|
+
return searchLines(sessionUrl(id, target), await loadTranscript(requireStore(id), id, linkRun), request);
|
|
251
252
|
}
|
|
253
|
+
const store = requireStore();
|
|
252
254
|
const candidates = (await recentSessions(target)).filter((summary) => summary.id !== sources.currentSessionId);
|
|
253
255
|
const window = candidates.slice(target.offset, target.offset + target.limit);
|
|
254
256
|
const out = [];
|
|
@@ -270,7 +272,7 @@ export function createHistoryRouter(sources) {
|
|
|
270
272
|
async function searchRun(runId, request) {
|
|
271
273
|
const detail = await requireWorkflows().getRun(runId);
|
|
272
274
|
const lines = searchLines(`history://workflows/${runId}`, runLines(detail), request);
|
|
273
|
-
const store =
|
|
275
|
+
const store = projectStore();
|
|
274
276
|
let unreadable = 0;
|
|
275
277
|
for (const stage of detail.stages) {
|
|
276
278
|
if (!store || !stage.sessionId)
|
|
@@ -324,7 +326,7 @@ export function createHistoryRouter(sources) {
|
|
|
324
326
|
if (target.id === undefined)
|
|
325
327
|
return listSessions(target);
|
|
326
328
|
const id = await authorizedSessionId(target);
|
|
327
|
-
return (await loadTranscript(requireStore(), id, target.project === undefined)).join("\n");
|
|
329
|
+
return (await loadTranscript(requireStore(id), id, target.project === undefined)).join("\n");
|
|
328
330
|
}
|
|
329
331
|
return target.id === undefined ? listWorkflows(target) : (await readRun(target.id)).join("\n");
|
|
330
332
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-protocol.js","sourceRoot":"","sources":["../../../src/core/tools/history-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC9G,OAAO,EAGN,uBAAuB,GACvB,MAAM,yBAAyB,CAAC;AAUjC,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,UAAU,GAA2E;IAC1F,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;IACxC,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC9B,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;CACpC,CAAC;AAYF,MAAM,WAAW,GAAG,sDAAsD,CAAC;AAE3E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,4GAA4G;IAC5G,6GAA6G;IAC7G,gEAAgE;IAChE,gGAAgG;IAChG,2FAA2F;IAC3F,8GAA8G;IAC9G,8GAA8G;IAC9G,kHAAkH;IAClH,0CAA0C;IAC1C,+GAA+G;CAC/G,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAS,WAAW,CAAC,GAAW;IAC/B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,C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sourcesContent":["/**\n * history:// resolution: the session and workflow history of the current project, read through the configured\n * `SessionStore` and the registered workflow run control rather than through any backend's own files.\n *\n * history:// what is available\n * history://sessions recent sessions, newest first\n * history://sessions/<id> one session's transcript, one line per text line\n * history://workflows recent workflow runs, newest first\n * history://workflows/<runId> one run: inputs, stages with their sessions, result\n *\n * Query parameters: `limit=N` (at most 200) and `offset=N` page a listing or a multi-record search, so every record is\n * reachable; `project=all|<path>` on sessions widens the scope beyond the current project.\n *\n * Transcripts are never shortened: a long text line is split into parts of at most `LINE_WIDTH` characters, so every\n * part can be read with a `:N-M` range.\n */\n\nimport { createSessionCwdMatcher } from \"../../utils/canonical-path.ts\";\nimport { resolvePath } from \"../../utils/paths.ts\";\nimport type { WorkflowRunControl, WorkflowRunDetail, WorkflowRunSummary } from \"../extensions/workflow-run-control.js\";\nimport type { SessionEntry } from \"../session-manager-types.ts\";\nimport type { SessionStore, SessionSummary } from \"../storage/session/types.js\";\nimport { entryLines, renderHistoryTranscript, textLines, timestamp, wrapLine } from \"./history-transcript.ts\";\nimport {\n\ttype InternalResourceRouter,\n\ttype InternalSearchRequest,\n\tsearchTextSelectorLines,\n} from \"./resource-selectors.ts\";\n\nexport interface HistorySources {\n\t/** The project whose history is visible by default. */\n\treadonly cwd: string;\n\treadonly currentSessionId?: string;\n\treadonly sessionStore: () => SessionStore | undefined;\n\treadonly workflows: () => WorkflowRunControl | undefined;\n}\n\nconst DEFAULT_LIMIT = 25;\nconst MAX_LIMIT = 200;\nconst LABEL_LIMIT = 120;\nconst QUERY_KEYS: Readonly<Record<\"sessions\" | \"workflows\" | \"root\", readonly string[]>> = {\n\tsessions: [\"limit\", \"offset\", \"project\"],\n\tworkflows: [\"limit\", \"offset\"],\n\troot: [\"limit\", \"offset\", \"project\"],\n};\n\ntype Domain = \"sessions\" | \"workflows\";\ninterface HistoryTarget {\n\treadonly domain?: Domain;\n\treadonly id?: string;\n\treadonly limit: number;\n\treadonly offset: number;\n\t/** `undefined` selects the current project, `\"all\"` every project, anything else is a project directory. */\n\treadonly project?: string;\n}\n\nconst HISTORY_URL = /^history:\\/\\/([^/?#]*)(?:\\/([^?#]*))?(?:\\?([^#]*))?$/;\n\nexport const HISTORY_HELP = [\n\t\"history:// reads and searches this project's past sessions and workflow runs, whatever storage backs them.\",\n\t\" history://sessions recent sessions, newest first (?limit=N up to 200, ?offset=N to page)\",\n\t\" history://sessions/<id>[:N-M] one session's transcript\",\n\t\" history://workflows recent workflow runs, newest first (?limit=N, ?offset=N)\",\n\t\" history://workflows/<runId>[:N-M] one run: inputs, stages with their sessions, result\",\n\t'Search any of them with the search tool, e.g. paths \"history://sessions\" or \"history://\" (both); matches are',\n\t\"labelled with a URL and line number to read with :N-M. A search of workflow runs also searches their stages'\",\n\t\"transcripts. A search covers one page of records (25 by default); its first result says which records it covered\",\n\t\"and the ?offset=N URL that continues it.\",\n\t\"Sessions of other projects appear only with ?project=all or ?project=<dir>; use that only when the user asks.\",\n].join(\"\\n\");\n\nfunction parseTarget(url: string): HistoryTarget {\n\tconst match = HISTORY_URL.exec(url);\n\tif (!match) throw new Error(`Invalid history URL: ${url}`);\n\tconst [, domainText = \"\", idText, queryText] = match;\n\tif (domainText !== \"\" && domainText !== \"sessions\" && domainText !== \"workflows\")\n\t\tthrow new Error(`Unknown history resource: ${domainText}; use history://sessions or history://workflows`);\n\tconst domain: Domain | undefined = domainText === \"\" ? undefined : domainText;\n\tif (domain === undefined && idText) throw new Error(`Unknown history resource: ${idText}`);\n\tconst params = new URLSearchParams(queryText ?? \"\");\n\tconst allowed = QUERY_KEYS[domain ?? \"root\"];\n\tfor (const key of params.keys())\n\t\tif (!allowed.includes(key))\n\t\t\tthrow new Error(`Unsupported history query parameter: ${key}; supported: ${allowed.join(\", \")}`);\n\tconst limitText = params.get(\"limit\");\n\tconst limit = limitText === null ? DEFAULT_LIMIT : Number.parseInt(limitText, 10);\n\tif (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT)\n\t\tthrow new Error(`history limit must be between 1 and ${MAX_LIMIT}: ${limitText}; page further with ?offset=N`);\n\tconst offsetText = params.get(\"offset\");\n\tconst offset = offsetText === null ? 0 : Number.parseInt(offsetText, 10);\n\tif (!Number.isInteger(offset) || offset < 0) throw new Error(`history offset must be 0 or more: ${offsetText}`);\n\tconst project = params.get(\"project\") ?? undefined;\n\tif (project === \"\") throw new Error(\"history project must be 'all' or a directory\");\n\treturn {\n\t\tdomain,\n\t\t...(idText ? { id: decodeURIComponent(idText) } : {}),\n\t\tlimit,\n\t\toffset,\n\t\t...(project === undefined ? {} : { project }),\n\t};\n}\n\n/** A preview for a listing row, which links to the full record. */\nfunction oneLine(text: string, limit: number): string {\n\tconst flat = text.replace(/\\s+/g, \" \").trim();\n\treturn flat.length > limit ? `${flat.slice(0, limit)}…` : flat;\n}\n\n/** The lines `history://sessions/<id>` shows for `entries`, in the form a transcript search returns them. */\nexport function transcriptEntryLines(entries: readonly SessionEntry[]): string[] {\n\treturn entries.flatMap(entryLines);\n}\n\n/** `linkRun` is false for a cross-project view, whose workflow history is not reachable from here. */\nasync function loadTranscript(store: SessionStore, sessionId: string, linkRun: boolean): Promise<string[]> {\n\tconst { header, entries } = await store.load(sessionId);\n\treturn renderHistoryTranscript(header, entries, linkRun).lines;\n}\n\nfunction sessionLabel(summary: SessionSummary): string {\n\treturn summary.name ? oneLine(summary.name, LABEL_LIMIT) : oneLine(summary.firstMessage, LABEL_LIMIT);\n}\n\n/** A link that reads back in the same scope as the view it came from. */\nfunction sessionUrl(id: string, target: HistoryTarget): string {\n\tconst query = target.project === undefined ? \"\" : `?project=${encodeURIComponent(target.project)}`;\n\treturn `history://sessions/${id}${query}`;\n}\n\nfunction pageUrl(domain: Domain, target: HistoryTarget, offset: number): string {\n\tconst params = new URLSearchParams();\n\tif (offset > 0) params.set(\"offset\", String(offset));\n\tif (target.limit !== DEFAULT_LIMIT) params.set(\"limit\", String(target.limit));\n\tif (domain === \"sessions\" && target.project !== undefined) params.set(\"project\", target.project);\n\tconst query = params.toString();\n\treturn `history://${domain}${query ? `?${query}` : \"\"}`;\n}\n\nfunction windowText(total: number, offset: number, shown: number): string {\n\treturn shown === 0 ? `none of ${total}` : `${offset + 1}-${offset + shown} of ${total}`;\n}\n\nexport function createHistoryRouter(sources: HistorySources): InternalResourceRouter {\n\tconst projectScope = (target: HistoryTarget): { cwd?: string } =>\n\t\ttarget.project === \"all\"\n\t\t\t? {}\n\t\t\t: { cwd: target.project === undefined ? sources.cwd : resolvePath(target.project, sources.cwd) };\n\n\tconst requireStore = (): SessionStore => {\n\t\tconst store = sources.sessionStore();\n\t\tif (!store) throw new Error(\"Session history is unavailable: this session has no session store.\");\n\t\treturn store;\n\t};\n\n\tconst requireWorkflows = (): WorkflowRunControl => {\n\t\tconst control = sources.workflows();\n\t\tif (!control)\n\t\t\tthrow new Error(\"Workflow history is unavailable: no workflow run control is registered for this session.\");\n\t\treturn control;\n\t};\n\n\tasync function recentSessions(target: HistoryTarget): Promise<SessionSummary[]> {\n\t\tconst found: SessionSummary[] = [];\n\t\tfor await (const summary of requireStore().list(projectScope(target))) found.push(summary);\n\t\treturn found.sort(\n\t\t\t(a, b) => Date.parse(b.modifiedAt) - Date.parse(a.modifiedAt) || b.createdAt.localeCompare(a.createdAt),\n\t\t);\n\t}\n\n\tasync function recentRuns(): Promise<WorkflowRunSummary[]> {\n\t\tconst control = requireWorkflows();\n\t\tconst runs = await (control.listProjectRuns?.() ?? control.listRuns({ includeDurable: true }));\n\t\treturn [...runs].sort((a, b) => b.startedAt - a.startedAt);\n\t}\n\n\tasync function belongsToProjectRun(runId: string): Promise<boolean> {\n\t\ttry {\n\t\t\treturn (await recentRuns()).some((run) => run.runId === runId);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync function authorizedSessionId(target: HistoryTarget): Promise<string> {\n\t\tconst id = target.id ?? \"\";\n\t\tconst header = await requireStore().readHeader(id);\n\t\tif (!header) throw new Error(`Session not found: ${id}`);\n\t\tif (id === sources.currentSessionId) return id;\n\t\tconst { cwd } = projectScope(target);\n\t\tif (cwd === undefined || createSessionCwdMatcher(cwd)(header.cwd)) return id;\n\t\t// A stage session can run in its own directory or worktree; the project's run vouches for it.\n\t\tif (target.project === undefined && header.workflow && (await belongsToProjectRun(header.workflow.runId)))\n\t\t\treturn id;\n\t\tthrow new Error(\n\t\t\t`Session ${id} belongs to another project. History is limited to the current project unless the user asks for other projects.`,\n\t\t);\n\t}\n\n\tasync function listSessions(target: HistoryTarget): Promise<string> {\n\t\tconst sessions = await recentSessions(target);\n\t\tconst shown = sessions.slice(target.offset, target.offset + target.limit);\n\t\tconst scope =\n\t\t\ttarget.project === \"all\" ? \"all projects\" : target.project === undefined ? \"this project\" : target.project;\n\t\tconst next = target.offset + shown.length;\n\t\treturn [\n\t\t\t`# sessions ${windowText(sessions.length, target.offset, shown.length)} in ${scope}, newest first${next < sessions.length ? `; next page: ${pageUrl(\"sessions\", target, next)}` : \"\"}`,\n\t\t\t...shown.map((summary) =>\n\t\t\t\t[\n\t\t\t\t\tsessionUrl(summary.id, target),\n\t\t\t\t\ttimestamp(summary.modifiedAt),\n\t\t\t\t\t`${summary.messageCount} messages`,\n\t\t\t\t\t...(summary.id === sources.currentSessionId ? [\"current session\"] : []),\n\t\t\t\t\t...(summary.workflow\n\t\t\t\t\t\t? [`workflow stage ${summary.workflow.stageName} (run ${summary.workflow.runId})`]\n\t\t\t\t\t\t: []),\n\t\t\t\t\t...(target.project === undefined ? [] : [summary.cwd]),\n\t\t\t\t\tsessionLabel(summary),\n\t\t\t\t].join(\" | \"),\n\t\t\t),\n\t\t].join(\"\\n\");\n\t}\n\n\tasync function listWorkflows(target: HistoryTarget): Promise<string> {\n\t\tconst runs = await recentRuns();\n\t\tconst shown = runs.slice(target.offset, target.offset + target.limit);\n\t\tconst next = target.offset + shown.length;\n\t\treturn [\n\t\t\t`# workflow runs ${windowText(runs.length, target.offset, shown.length)} in this project, newest first${next < runs.length ? `; next page: ${pageUrl(\"workflows\", target, next)}` : \"\"}`,\n\t\t\t...shown.map((run) =>\n\t\t\t\t[\n\t\t\t\t\t`history://workflows/${run.runId}`,\n\t\t\t\t\ttimestamp(run.startedAt),\n\t\t\t\t\trun.status,\n\t\t\t\t\trun.name,\n\t\t\t\t\t...(run.identity && run.identity !== run.name ? [oneLine(run.identity, LABEL_LIMIT)] : []),\n\t\t\t\t\t...(run.summary ? [oneLine(run.summary, LABEL_LIMIT)] : []),\n\t\t\t\t].join(\" | \"),\n\t\t\t),\n\t\t].join(\"\\n\");\n\t}\n\n\tfunction runLines(detail: WorkflowRunDetail): string[] {\n\t\treturn [\n\t\t\t`# workflow run ${detail.runId}`,\n\t\t\t`name: ${detail.name}`,\n\t\t\t`status: ${detail.status}`,\n\t\t\t`started: ${timestamp(detail.startedAt)}`,\n\t\t\t...(detail.endedAt === undefined ? [] : [`ended: ${timestamp(detail.endedAt)}`]),\n\t\t\t...(detail.identity ? textLines(`label: ${detail.identity}`) : []),\n\t\t\t...(detail.summary ? textLines(`summary: ${detail.summary}`) : []),\n\t\t\t...wrapLine(`inputs: ${JSON.stringify(detail.inputs)}`),\n\t\t\t\"stages:\",\n\t\t\t...detail.stages.flatMap((stage) => [\n\t\t\t\t[\n\t\t\t\t\t`- ${stage.name} [${stage.status}]`,\n\t\t\t\t\t...(stage.sessionId ? [`transcript history://sessions/${stage.sessionId}`] : []),\n\t\t\t\t].join(\" \"),\n\t\t\t\t...(stage.error ? textLines(` error: ${stage.error}`) : []),\n\t\t\t]),\n\t\t\t...(detail.result === undefined ? [] : wrapLine(`result: ${JSON.stringify(detail.result)}`)),\n\t\t\t...(detail.error ? textLines(`error: ${detail.error}`) : []),\n\t\t];\n\t}\n\n\tasync function authorizedRunId(id: string): Promise<string> {\n\t\tconst runs = await recentRuns();\n\t\tconst exact = runs.find((run) => run.runId === id);\n\t\tif (exact) return exact.runId;\n\t\tconst prefixed = runs.filter((run) => run.runId.startsWith(id));\n\t\tif (prefixed.length === 1) return prefixed[0]!.runId;\n\t\tthrow new Error(\n\t\t\tprefixed.length > 1\n\t\t\t\t? `Workflow run id is ambiguous: ${id}`\n\t\t\t\t: `Workflow run not found in this project's history: ${id}`,\n\t\t);\n\t}\n\n\tasync function readRun(id: string): Promise<string[]> {\n\t\treturn runLines(await requireWorkflows().getRun(await authorizedRunId(id)));\n\t}\n\n\t/** The first line of a windowed search, labelled so the search tool keeps it beside matches. */\n\tfunction coverage(\n\t\tdomain: Domain,\n\t\ttarget: HistoryTarget,\n\t\ttotal: number,\n\t\tshown: number,\n\t\tunreadable: number,\n\t): string[] {\n\t\tconst end = target.offset + shown;\n\t\tif (target.offset === 0 && end >= total && unreadable === 0) return [];\n\t\treturn [\n\t\t\t`${pageUrl(domain, target, target.offset)}:0: [searched ${domain} ${windowText(total, target.offset, shown)}${unreadable > 0 ? `, ${unreadable} unreadable` : \"\"}${end < total ? `; continue with ${pageUrl(domain, target, end)}` : \"\"}]`,\n\t\t];\n\t}\n\n\tconst searchLines = (label: string, lines: string[], request: InternalSearchRequest): string[] =>\n\t\tsearchTextSelectorLines(\n\t\t\tlabel,\n\t\t\tlines.join(\"\\n\"),\n\t\t\trequest.pattern,\n\t\t\trequest.ignoreCase,\n\t\t\trequest.literal,\n\t\t\trequest.contextBefore,\n\t\t\trequest.contextAfter,\n\t\t);\n\n\tasync function searchSessions(target: HistoryTarget, request: InternalSearchRequest): Promise<string[]> {\n\t\tconst store = requireStore();\n\t\tconst linkRun = target.project === undefined;\n\t\tif (target.id !== undefined) {\n\t\t\tconst id = await authorizedSessionId(target);\n\t\t\treturn searchLines(sessionUrl(id, target), await loadTranscript(store, id, linkRun), request);\n\t\t}\n\t\tconst candidates = (await recentSessions(target)).filter((summary) => summary.id !== sources.currentSessionId);\n\t\tconst window = candidates.slice(target.offset, target.offset + target.limit);\n\t\tconst out: string[] = [];\n\t\tlet unreadable = 0;\n\t\tfor (const summary of window) {\n\t\t\ttry {\n\t\t\t\tout.push(\n\t\t\t\t\t...searchLines(\n\t\t\t\t\t\tsessionUrl(summary.id, target),\n\t\t\t\t\t\tawait loadTranscript(store, summary.id, linkRun),\n\t\t\t\t\t\trequest,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\tunreadable++;\n\t\t\t}\n\t\t}\n\t\treturn [...coverage(\"sessions\", target, candidates.length, window.length, unreadable), ...out];\n\t}\n\n\t/**\n\t * Matches in one run and in its stages' transcripts. Stage sessions are internal, so session listings and session\n\t * searches leave them out; the run reaches them. A stage that never saved a session has nothing to search.\n\t */\n\tasync function searchRun(\n\t\trunId: string,\n\t\trequest: InternalSearchRequest,\n\t): Promise<{ readonly lines: string[]; readonly unreadable: number }> {\n\t\tconst detail = await requireWorkflows().getRun(runId);\n\t\tconst lines = searchLines(`history://workflows/${runId}`, runLines(detail), request);\n\t\tconst store = sources.sessionStore();\n\t\tlet unreadable = 0;\n\t\tfor (const stage of detail.stages) {\n\t\t\tif (!store || !stage.sessionId) continue;\n\t\t\ttry {\n\t\t\t\tif (!(await store.readHeader(stage.sessionId))) continue;\n\t\t\t\tconst transcript = await loadTranscript(store, stage.sessionId, true);\n\t\t\t\tlines.push(...searchLines(`history://sessions/${stage.sessionId}`, transcript, request));\n\t\t\t} catch {\n\t\t\t\tunreadable++;\n\t\t\t}\n\t\t}\n\t\treturn { lines, unreadable };\n\t}\n\n\tasync function searchWorkflows(target: HistoryTarget, request: InternalSearchRequest): Promise<string[]> {\n\t\trequireWorkflows();\n\t\tif (target.id !== undefined) {\n\t\t\tconst runId = await authorizedRunId(target.id);\n\t\t\tconst { lines, unreadable } = await searchRun(runId, request);\n\t\t\treturn [\n\t\t\t\t...(unreadable > 0 ? [`history://workflows/${runId}:0: [${unreadable} stage transcripts unreadable]`] : []),\n\t\t\t\t...lines,\n\t\t\t];\n\t\t}\n\t\tconst runs = await recentRuns();\n\t\tconst window = runs.slice(target.offset, target.offset + target.limit);\n\t\tconst out: string[] = [];\n\t\tlet unreadable = 0;\n\t\tfor (const run of window) {\n\t\t\ttry {\n\t\t\t\tconst found = await searchRun(run.runId, request);\n\t\t\t\tout.push(...found.lines);\n\t\t\t\tunreadable += found.unreadable;\n\t\t\t} catch {\n\t\t\t\tunreadable++;\n\t\t\t}\n\t\t}\n\t\treturn [...coverage(\"workflows\", target, runs.length, window.length, unreadable), ...out];\n\t}\n\n\treturn {\n\t\tread: async (url) => {\n\t\t\tif (!url.startsWith(\"history://\")) return undefined;\n\t\t\tconst target = parseTarget(url);\n\t\t\tif (target.domain === undefined) return HISTORY_HELP;\n\t\t\tif (target.domain === \"sessions\") {\n\t\t\t\tif (target.id === undefined) return listSessions(target);\n\t\t\t\tconst id = await authorizedSessionId(target);\n\t\t\t\treturn (await loadTranscript(requireStore(), id, target.project === undefined)).join(\"\\n\");\n\t\t\t}\n\t\t\treturn target.id === undefined ? listWorkflows(target) : (await readRun(target.id)).join(\"\\n\");\n\t\t},\n\t\tsearch: async (url, request) => {\n\t\t\tif (!url.startsWith(\"history://\")) return undefined;\n\t\t\tconst target = parseTarget(url);\n\t\t\tif (target.domain === \"sessions\") return (await searchSessions(target, request)).join(\"\\n\");\n\t\t\tif (target.domain === \"workflows\") return (await searchWorkflows(target, request)).join(\"\\n\");\n\t\t\tconst [sessions, workflows] = await Promise.allSettled([\n\t\t\t\tsearchSessions(target, request),\n\t\t\t\tsearchWorkflows(target, request),\n\t\t\t]);\n\t\t\tif (sessions.status === \"rejected\" && workflows.status === \"rejected\") throw sessions.reason;\n\t\t\t// Line 0 carries notes about the search itself, so a source that failed is named even beside matches.\n\t\t\tconst results = (domain: Domain, label: string, settled: PromiseSettledResult<string[]>): string[] =>\n\t\t\t\tsettled.status === \"fulfilled\"\n\t\t\t\t\t? settled.value\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t`history://${domain}:0: [${label} not searched: ${settled.reason instanceof Error ? settled.reason.message : String(settled.reason)}]`,\n\t\t\t\t\t\t];\n\t\t\treturn [\n\t\t\t\t...results(\"sessions\", \"sessions\", sessions),\n\t\t\t\t...results(\"workflows\", \"workflow runs\", workflows),\n\t\t\t].join(\"\\n\");\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"history-protocol.js","sourceRoot":"","sources":["../../../src/core/tools/history-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC9G,OAAO,EAGN,uBAAuB,GACvB,MAAM,yBAAyB,CAAC;AA0BjC,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,UAAU,GAA2E;IAC1F,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;IACxC,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC9B,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;CACpC,CAAC;AAYF,MAAM,WAAW,GAAG,sDAAsD,CAAC;AAE3E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,4GAA4G;IAC5G,6GAA6G;IAC7G,gEAAgE;IAChE,gGAAgG;IAChG,2FAA2F;IAC3F,8GAA8G;IAC9G,8GAA8G;IAC9G,kHAAkH;IAClH,0CAA0C;IAC1C,+GAA+G;CAC/G,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAS,WAAW,CAAC,GAAW;IAC/B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAC;I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AO;gBACN,GAAG,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC;gBAC5C,GAAG,OAAO,CAAC,WAAW,EAAE,eAAe,EAAE,SAAS,CAAC;aACnD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * history:// resolution: the session and workflow history of the current project, read through the configured\n * `SessionStore` and the registered workflow run control rather than through any backend's own files.\n *\n * history:// what is available\n * history://sessions recent sessions, newest first\n * history://sessions/<id> one session's transcript, one line per text line\n * history://workflows recent workflow runs, newest first\n * history://workflows/<runId> one run: inputs, stages with their sessions, result\n *\n * Query parameters: `limit=N` (at most 200) and `offset=N` page a listing or a multi-record search, so every record is\n * reachable; `project=all|<path>` on sessions widens the scope beyond the current project.\n *\n * Transcripts are never shortened: a long text line is split into parts of at most `LINE_WIDTH` characters, so every\n * part can be read with a `:N-M` range.\n */\n\nimport { createSessionCwdMatcher } from \"../../utils/canonical-path.ts\";\nimport { resolvePath } from \"../../utils/paths.ts\";\nimport type { WorkflowRunControl, WorkflowRunDetail, WorkflowRunSummary } from \"../extensions/workflow-run-control.js\";\nimport type { SessionEntry } from \"../session-manager-types.ts\";\nimport type { SessionStore, SessionSummary } from \"../storage/session/types.js\";\nimport { entryLines, renderHistoryTranscript, textLines, timestamp, wrapLine } from \"./history-transcript.ts\";\nimport {\n\ttype InternalResourceRouter,\n\ttype InternalSearchRequest,\n\tsearchTextSelectorLines,\n} from \"./resource-selectors.ts\";\n\n/** The part of a workflow run control that history:// reads; it can list and read runs, never manage them. */\nexport type WorkflowRunHistory = Pick<WorkflowRunControl, \"listRuns\" | \"listProjectRuns\" | \"getRun\">;\n\n/**\n * Where a session reads its project's history: the project's sessions and its workflow runs. A workflow stage or a\n * subagent gets the history of the session that launched it, since neither holds the project's run control and a\n * subagent keeps its own transcript apart from the project's sessions.\n */\nexport interface ProjectHistory {\n\treadonly sessionStore: () => SessionStore | undefined;\n\treadonly workflows: () => WorkflowRunHistory | undefined;\n}\n\nexport interface HistorySources {\n\t/** The project whose history is visible by default. */\n\treadonly cwd: string;\n\treadonly currentSessionId?: string;\n\t/** The store that holds the current session. */\n\treadonly sessionStore: () => SessionStore | undefined;\n\t/** The store that holds the project's other sessions, when it is not the current session's. */\n\treadonly projectSessionStore?: () => SessionStore | undefined;\n\treadonly workflows: () => WorkflowRunHistory | undefined;\n}\n\nconst DEFAULT_LIMIT = 25;\nconst MAX_LIMIT = 200;\nconst LABEL_LIMIT = 120;\nconst QUERY_KEYS: Readonly<Record<\"sessions\" | \"workflows\" | \"root\", readonly string[]>> = {\n\tsessions: [\"limit\", \"offset\", \"project\"],\n\tworkflows: [\"limit\", \"offset\"],\n\troot: [\"limit\", \"offset\", \"project\"],\n};\n\ntype Domain = \"sessions\" | \"workflows\";\ninterface HistoryTarget {\n\treadonly domain?: Domain;\n\treadonly id?: string;\n\treadonly limit: number;\n\treadonly offset: number;\n\t/** `undefined` selects the current project, `\"all\"` every project, anything else is a project directory. */\n\treadonly project?: string;\n}\n\nconst HISTORY_URL = /^history:\\/\\/([^/?#]*)(?:\\/([^?#]*))?(?:\\?([^#]*))?$/;\n\nexport const HISTORY_HELP = [\n\t\"history:// reads and searches this project's past sessions and workflow runs, whatever storage backs them.\",\n\t\" history://sessions recent sessions, newest first (?limit=N up to 200, ?offset=N to page)\",\n\t\" history://sessions/<id>[:N-M] one session's transcript\",\n\t\" history://workflows recent workflow runs, newest first (?limit=N, ?offset=N)\",\n\t\" history://workflows/<runId>[:N-M] one run: inputs, stages with their sessions, result\",\n\t'Search any of them with the search tool, e.g. paths \"history://sessions\" or \"history://\" (both); matches are',\n\t\"labelled with a URL and line number to read with :N-M. A search of workflow runs also searches their stages'\",\n\t\"transcripts. A search covers one page of records (25 by default); its first result says which records it covered\",\n\t\"and the ?offset=N URL that continues it.\",\n\t\"Sessions of other projects appear only with ?project=all or ?project=<dir>; use that only when the user asks.\",\n].join(\"\\n\");\n\nfunction parseTarget(url: string): HistoryTarget {\n\tconst match = HISTORY_URL.exec(url);\n\tif (!match) throw new Error(`Invalid history URL: ${url}`);\n\tconst [, domainText = \"\", idText, queryText] = match;\n\tif (domainText !== \"\" && domainText !== \"sessions\" && domainText !== \"workflows\")\n\t\tthrow new Error(`Unknown history resource: ${domainText}; use history://sessions or history://workflows`);\n\tconst domain: Domain | undefined = domainText === \"\" ? undefined : domainText;\n\tif (domain === undefined && idText) throw new Error(`Unknown history resource: ${idText}`);\n\tconst params = new URLSearchParams(queryText ?? \"\");\n\tconst allowed = QUERY_KEYS[domain ?? \"root\"];\n\tfor (const key of params.keys())\n\t\tif (!allowed.includes(key))\n\t\t\tthrow new Error(`Unsupported history query parameter: ${key}; supported: ${allowed.join(\", \")}`);\n\tconst limitText = params.get(\"limit\");\n\tconst limit = limitText === null ? DEFAULT_LIMIT : Number.parseInt(limitText, 10);\n\tif (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT)\n\t\tthrow new Error(`history limit must be between 1 and ${MAX_LIMIT}: ${limitText}; page further with ?offset=N`);\n\tconst offsetText = params.get(\"offset\");\n\tconst offset = offsetText === null ? 0 : Number.parseInt(offsetText, 10);\n\tif (!Number.isInteger(offset) || offset < 0) throw new Error(`history offset must be 0 or more: ${offsetText}`);\n\tconst project = params.get(\"project\") ?? undefined;\n\tif (project === \"\") throw new Error(\"history project must be 'all' or a directory\");\n\treturn {\n\t\tdomain,\n\t\t...(idText ? { id: decodeURIComponent(idText) } : {}),\n\t\tlimit,\n\t\toffset,\n\t\t...(project === undefined ? {} : { project }),\n\t};\n}\n\n/** A preview for a listing row, which links to the full record. */\nfunction oneLine(text: string, limit: number): string {\n\tconst flat = text.replace(/\\s+/g, \" \").trim();\n\treturn flat.length > limit ? `${flat.slice(0, limit)}…` : flat;\n}\n\n/** The lines `history://sessions/<id>` shows for `entries`, in the form a transcript search returns them. */\nexport function transcriptEntryLines(entries: readonly SessionEntry[]): string[] {\n\treturn entries.flatMap(entryLines);\n}\n\n/** `linkRun` is false for a cross-project view, whose workflow history is not reachable from here. */\nasync function loadTranscript(store: SessionStore, sessionId: string, linkRun: boolean): Promise<string[]> {\n\tconst { header, entries } = await store.load(sessionId);\n\treturn renderHistoryTranscript(header, entries, linkRun).lines;\n}\n\nfunction sessionLabel(summary: SessionSummary): string {\n\treturn summary.name ? oneLine(summary.name, LABEL_LIMIT) : oneLine(summary.firstMessage, LABEL_LIMIT);\n}\n\n/** A link that reads back in the same scope as the view it came from. */\nfunction sessionUrl(id: string, target: HistoryTarget): string {\n\tconst query = target.project === undefined ? \"\" : `?project=${encodeURIComponent(target.project)}`;\n\treturn `history://sessions/${id}${query}`;\n}\n\nfunction pageUrl(domain: Domain, target: HistoryTarget, offset: number): string {\n\tconst params = new URLSearchParams();\n\tif (offset > 0) params.set(\"offset\", String(offset));\n\tif (target.limit !== DEFAULT_LIMIT) params.set(\"limit\", String(target.limit));\n\tif (domain === \"sessions\" && target.project !== undefined) params.set(\"project\", target.project);\n\tconst query = params.toString();\n\treturn `history://${domain}${query ? `?${query}` : \"\"}`;\n}\n\nfunction windowText(total: number, offset: number, shown: number): string {\n\treturn shown === 0 ? `none of ${total}` : `${offset + 1}-${offset + shown} of ${total}`;\n}\n\nexport function createHistoryRouter(sources: HistorySources): InternalResourceRouter {\n\tconst projectScope = (target: HistoryTarget): { cwd?: string } =>\n\t\ttarget.project === \"all\"\n\t\t\t? {}\n\t\t\t: { cwd: target.project === undefined ? sources.cwd : resolvePath(target.project, sources.cwd) };\n\n\tconst projectStore = (): SessionStore | undefined => sources.projectSessionStore?.() ?? sources.sessionStore();\n\n\t/** The store that holds session `id`, or the project's sessions without one. */\n\tconst requireStore = (id?: string): SessionStore => {\n\t\tconst store = id !== undefined && id === sources.currentSessionId ? sources.sessionStore() : projectStore();\n\t\tif (!store) throw new Error(\"Session history is unavailable: this session has no session store.\");\n\t\treturn store;\n\t};\n\n\tconst requireWorkflows = (): WorkflowRunHistory => {\n\t\tconst control = sources.workflows();\n\t\tif (!control)\n\t\t\tthrow new Error(\"Workflow history is unavailable: no workflow run control is registered for this session.\");\n\t\treturn control;\n\t};\n\n\tasync function recentSessions(target: HistoryTarget): Promise<SessionSummary[]> {\n\t\tconst found: SessionSummary[] = [];\n\t\tfor await (const summary of requireStore().list(projectScope(target))) found.push(summary);\n\t\treturn found.sort(\n\t\t\t(a, b) => Date.parse(b.modifiedAt) - Date.parse(a.modifiedAt) || b.createdAt.localeCompare(a.createdAt),\n\t\t);\n\t}\n\n\tasync function recentRuns(): Promise<WorkflowRunSummary[]> {\n\t\tconst control = requireWorkflows();\n\t\tconst runs = await (control.listProjectRuns?.() ?? control.listRuns({ includeDurable: true }));\n\t\treturn [...runs].sort((a, b) => b.startedAt - a.startedAt);\n\t}\n\n\tasync function belongsToProjectRun(runId: string): Promise<boolean> {\n\t\ttry {\n\t\t\treturn (await recentRuns()).some((run) => run.runId === runId);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync function authorizedSessionId(target: HistoryTarget): Promise<string> {\n\t\tconst id = target.id ?? \"\";\n\t\tconst header = await requireStore(id).readHeader(id);\n\t\tif (!header) throw new Error(`Session not found: ${id}`);\n\t\tif (id === sources.currentSessionId) return id;\n\t\tconst { cwd } = projectScope(target);\n\t\tif (cwd === undefined || createSessionCwdMatcher(cwd)(header.cwd)) return id;\n\t\t// A stage session can run in its own directory or worktree; the project's run vouches for it.\n\t\tif (target.project === undefined && header.workflow && (await belongsToProjectRun(header.workflow.runId)))\n\t\t\treturn id;\n\t\tthrow new Error(\n\t\t\t`Session ${id} belongs to another project. History is limited to the current project unless the user asks for other projects.`,\n\t\t);\n\t}\n\n\tasync function listSessions(target: HistoryTarget): Promise<string> {\n\t\tconst sessions = await recentSessions(target);\n\t\tconst shown = sessions.slice(target.offset, target.offset + target.limit);\n\t\tconst scope =\n\t\t\ttarget.project === \"all\" ? \"all projects\" : target.project === undefined ? \"this project\" : target.project;\n\t\tconst next = target.offset + shown.length;\n\t\treturn [\n\t\t\t`# sessions ${windowText(sessions.length, target.offset, shown.length)} in ${scope}, newest first${next < sessions.length ? `; next page: ${pageUrl(\"sessions\", target, next)}` : \"\"}`,\n\t\t\t...shown.map((summary) =>\n\t\t\t\t[\n\t\t\t\t\tsessionUrl(summary.id, target),\n\t\t\t\t\ttimestamp(summary.modifiedAt),\n\t\t\t\t\t`${summary.messageCount} messages`,\n\t\t\t\t\t...(summary.id === sources.currentSessionId ? [\"current session\"] : []),\n\t\t\t\t\t...(summary.workflow\n\t\t\t\t\t\t? [`workflow stage ${summary.workflow.stageName} (run ${summary.workflow.runId})`]\n\t\t\t\t\t\t: []),\n\t\t\t\t\t...(target.project === undefined ? [] : [summary.cwd]),\n\t\t\t\t\tsessionLabel(summary),\n\t\t\t\t].join(\" | \"),\n\t\t\t),\n\t\t].join(\"\\n\");\n\t}\n\n\tasync function listWorkflows(target: HistoryTarget): Promise<string> {\n\t\tconst runs = await recentRuns();\n\t\tconst shown = runs.slice(target.offset, target.offset + target.limit);\n\t\tconst next = target.offset + shown.length;\n\t\treturn [\n\t\t\t`# workflow runs ${windowText(runs.length, target.offset, shown.length)} in this project, newest first${next < runs.length ? `; next page: ${pageUrl(\"workflows\", target, next)}` : \"\"}`,\n\t\t\t...shown.map((run) =>\n\t\t\t\t[\n\t\t\t\t\t`history://workflows/${run.runId}`,\n\t\t\t\t\ttimestamp(run.startedAt),\n\t\t\t\t\trun.status,\n\t\t\t\t\trun.name,\n\t\t\t\t\t...(run.identity && run.identity !== run.name ? [oneLine(run.identity, LABEL_LIMIT)] : []),\n\t\t\t\t\t...(run.summary ? [oneLine(run.summary, LABEL_LIMIT)] : []),\n\t\t\t\t].join(\" | \"),\n\t\t\t),\n\t\t].join(\"\\n\");\n\t}\n\n\tfunction runLines(detail: WorkflowRunDetail): string[] {\n\t\treturn [\n\t\t\t`# workflow run ${detail.runId}`,\n\t\t\t`name: ${detail.name}`,\n\t\t\t`status: ${detail.status}`,\n\t\t\t`started: ${timestamp(detail.startedAt)}`,\n\t\t\t...(detail.endedAt === undefined ? [] : [`ended: ${timestamp(detail.endedAt)}`]),\n\t\t\t...(detail.identity ? textLines(`label: ${detail.identity}`) : []),\n\t\t\t...(detail.summary ? textLines(`summary: ${detail.summary}`) : []),\n\t\t\t...wrapLine(`inputs: ${JSON.stringify(detail.inputs)}`),\n\t\t\t\"stages:\",\n\t\t\t...detail.stages.flatMap((stage) => [\n\t\t\t\t[\n\t\t\t\t\t`- ${stage.name} [${stage.status}]`,\n\t\t\t\t\t...(stage.sessionId ? [`transcript history://sessions/${stage.sessionId}`] : []),\n\t\t\t\t].join(\" \"),\n\t\t\t\t...(stage.error ? textLines(` error: ${stage.error}`) : []),\n\t\t\t]),\n\t\t\t...(detail.result === undefined ? [] : wrapLine(`result: ${JSON.stringify(detail.result)}`)),\n\t\t\t...(detail.error ? textLines(`error: ${detail.error}`) : []),\n\t\t];\n\t}\n\n\tasync function authorizedRunId(id: string): Promise<string> {\n\t\tconst runs = await recentRuns();\n\t\tconst exact = runs.find((run) => run.runId === id);\n\t\tif (exact) return exact.runId;\n\t\tconst prefixed = runs.filter((run) => run.runId.startsWith(id));\n\t\tif (prefixed.length === 1) return prefixed[0]!.runId;\n\t\tthrow new Error(\n\t\t\tprefixed.length > 1\n\t\t\t\t? `Workflow run id is ambiguous: ${id}`\n\t\t\t\t: `Workflow run not found in this project's history: ${id}`,\n\t\t);\n\t}\n\n\tasync function readRun(id: string): Promise<string[]> {\n\t\treturn runLines(await requireWorkflows().getRun(await authorizedRunId(id)));\n\t}\n\n\t/** The first line of a windowed search, labelled so the search tool keeps it beside matches. */\n\tfunction coverage(\n\t\tdomain: Domain,\n\t\ttarget: HistoryTarget,\n\t\ttotal: number,\n\t\tshown: number,\n\t\tunreadable: number,\n\t): string[] {\n\t\tconst end = target.offset + shown;\n\t\tif (target.offset === 0 && end >= total && unreadable === 0) return [];\n\t\treturn [\n\t\t\t`${pageUrl(domain, target, target.offset)}:0: [searched ${domain} ${windowText(total, target.offset, shown)}${unreadable > 0 ? `, ${unreadable} unreadable` : \"\"}${end < total ? `; continue with ${pageUrl(domain, target, end)}` : \"\"}]`,\n\t\t];\n\t}\n\n\tconst searchLines = (label: string, lines: string[], request: InternalSearchRequest): string[] =>\n\t\tsearchTextSelectorLines(\n\t\t\tlabel,\n\t\t\tlines.join(\"\\n\"),\n\t\t\trequest.pattern,\n\t\t\trequest.ignoreCase,\n\t\t\trequest.literal,\n\t\t\trequest.contextBefore,\n\t\t\trequest.contextAfter,\n\t\t);\n\n\tasync function searchSessions(target: HistoryTarget, request: InternalSearchRequest): Promise<string[]> {\n\t\tconst linkRun = target.project === undefined;\n\t\tif (target.id !== undefined) {\n\t\t\tconst id = await authorizedSessionId(target);\n\t\t\treturn searchLines(sessionUrl(id, target), await loadTranscript(requireStore(id), id, linkRun), request);\n\t\t}\n\t\tconst store = requireStore();\n\t\tconst candidates = (await recentSessions(target)).filter((summary) => summary.id !== sources.currentSessionId);\n\t\tconst window = candidates.slice(target.offset, target.offset + target.limit);\n\t\tconst out: string[] = [];\n\t\tlet unreadable = 0;\n\t\tfor (const summary of window) {\n\t\t\ttry {\n\t\t\t\tout.push(\n\t\t\t\t\t...searchLines(\n\t\t\t\t\t\tsessionUrl(summary.id, target),\n\t\t\t\t\t\tawait loadTranscript(store, summary.id, linkRun),\n\t\t\t\t\t\trequest,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\tunreadable++;\n\t\t\t}\n\t\t}\n\t\treturn [...coverage(\"sessions\", target, candidates.length, window.length, unreadable), ...out];\n\t}\n\n\t/**\n\t * Matches in one run and in its stages' transcripts. Stage sessions are internal, so session listings and session\n\t * searches leave them out; the run reaches them. A stage that never saved a session has nothing to search.\n\t */\n\tasync function searchRun(\n\t\trunId: string,\n\t\trequest: InternalSearchRequest,\n\t): Promise<{ readonly lines: string[]; readonly unreadable: number }> {\n\t\tconst detail = await requireWorkflows().getRun(runId);\n\t\tconst lines = searchLines(`history://workflows/${runId}`, runLines(detail), request);\n\t\tconst store = projectStore();\n\t\tlet unreadable = 0;\n\t\tfor (const stage of detail.stages) {\n\t\t\tif (!store || !stage.sessionId) continue;\n\t\t\ttry {\n\t\t\t\tif (!(await store.readHeader(stage.sessionId))) continue;\n\t\t\t\tconst transcript = await loadTranscript(store, stage.sessionId, true);\n\t\t\t\tlines.push(...searchLines(`history://sessions/${stage.sessionId}`, transcript, request));\n\t\t\t} catch {\n\t\t\t\tunreadable++;\n\t\t\t}\n\t\t}\n\t\treturn { lines, unreadable };\n\t}\n\n\tasync function searchWorkflows(target: HistoryTarget, request: InternalSearchRequest): Promise<string[]> {\n\t\trequireWorkflows();\n\t\tif (target.id !== undefined) {\n\t\t\tconst runId = await authorizedRunId(target.id);\n\t\t\tconst { lines, unreadable } = await searchRun(runId, request);\n\t\t\treturn [\n\t\t\t\t...(unreadable > 0 ? [`history://workflows/${runId}:0: [${unreadable} stage transcripts unreadable]`] : []),\n\t\t\t\t...lines,\n\t\t\t];\n\t\t}\n\t\tconst runs = await recentRuns();\n\t\tconst window = runs.slice(target.offset, target.offset + target.limit);\n\t\tconst out: string[] = [];\n\t\tlet unreadable = 0;\n\t\tfor (const run of window) {\n\t\t\ttry {\n\t\t\t\tconst found = await searchRun(run.runId, request);\n\t\t\t\tout.push(...found.lines);\n\t\t\t\tunreadable += found.unreadable;\n\t\t\t} catch {\n\t\t\t\tunreadable++;\n\t\t\t}\n\t\t}\n\t\treturn [...coverage(\"workflows\", target, runs.length, window.length, unreadable), ...out];\n\t}\n\n\treturn {\n\t\tread: async (url) => {\n\t\t\tif (!url.startsWith(\"history://\")) return undefined;\n\t\t\tconst target = parseTarget(url);\n\t\t\tif (target.domain === undefined) return HISTORY_HELP;\n\t\t\tif (target.domain === \"sessions\") {\n\t\t\t\tif (target.id === undefined) return listSessions(target);\n\t\t\t\tconst id = await authorizedSessionId(target);\n\t\t\t\treturn (await loadTranscript(requireStore(id), id, target.project === undefined)).join(\"\\n\");\n\t\t\t}\n\t\t\treturn target.id === undefined ? listWorkflows(target) : (await readRun(target.id)).join(\"\\n\");\n\t\t},\n\t\tsearch: async (url, request) => {\n\t\t\tif (!url.startsWith(\"history://\")) return undefined;\n\t\t\tconst target = parseTarget(url);\n\t\t\tif (target.domain === \"sessions\") return (await searchSessions(target, request)).join(\"\\n\");\n\t\t\tif (target.domain === \"workflows\") return (await searchWorkflows(target, request)).join(\"\\n\");\n\t\t\tconst [sessions, workflows] = await Promise.allSettled([\n\t\t\t\tsearchSessions(target, request),\n\t\t\t\tsearchWorkflows(target, request),\n\t\t\t]);\n\t\t\tif (sessions.status === \"rejected\" && workflows.status === \"rejected\") throw sessions.reason;\n\t\t\t// Line 0 carries notes about the search itself, so a source that failed is named even beside matches.\n\t\t\tconst results = (domain: Domain, label: string, settled: PromiseSettledResult<string[]>): string[] =>\n\t\t\t\tsettled.status === \"fulfilled\"\n\t\t\t\t\t? settled.value\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t`history://${domain}:0: [${label} not searched: ${settled.reason instanceof Error ? settled.reason.message : String(settled.reason)}]`,\n\t\t\t\t\t\t];\n\t\t\treturn [\n\t\t\t\t...results(\"sessions\", \"sessions\", sessions),\n\t\t\t\t...results(\"workflows\", \"workflow runs\", workflows),\n\t\t\t].join(\"\\n\");\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-task-status.d.ts","sourceRoot":"","sources":["../../../src/core/tools/shell-task-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoB,KAAK,oBAAoB,EAAuB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"shell-task-status.d.ts","sourceRoot":"","sources":["../../../src/core/tools/shell-task-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoB,KAAK,oBAAoB,EAAuB,MAAM,sBAAsB,CAAC;AAExG,OAAO,KAAK,EACX,WAAW,EACX,aAAa,EACb,OAA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