@bastani/atomic 0.9.19-alpha.2 → 0.9.19-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +7 -0
  3. package/dist/builtin/intercom/broker/broker.ts +8 -0
  4. package/dist/builtin/intercom/broker/client.ts +18 -0
  5. package/dist/builtin/intercom/broker/send-handler.ts +9 -0
  6. package/dist/builtin/intercom/index.bundle.mjs +44 -4
  7. package/dist/builtin/intercom/package.json +1 -1
  8. package/dist/builtin/intercom/types.ts +2 -1
  9. package/dist/builtin/mcp/package.json +1 -1
  10. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  11. package/dist/builtin/subagents/README.md +2 -2
  12. package/dist/builtin/subagents/package.json +1 -1
  13. package/dist/builtin/subagents/src/extension/index.bundle.mjs +2 -2
  14. package/dist/builtin/web-access/package.json +1 -1
  15. package/dist/builtin/workflows/CHANGELOG.md +13 -0
  16. package/dist/builtin/workflows/package.json +1 -1
  17. package/dist/builtin/workflows/src/extension/index.bundle.mjs +56 -33
  18. package/dist/builtin/workflows/src/index.js +14 -4
  19. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  20. package/dist/core/agent-session-message-queue.js +2 -2
  21. package/dist/core/agent-session-message-queue.js.map +1 -1
  22. package/dist/core/agent-session-methods.d.ts +3 -0
  23. package/dist/core/agent-session-methods.d.ts.map +1 -1
  24. package/dist/core/agent-session-methods.js.map +1 -1
  25. package/dist/core/agent-session-tasks.d.ts +5 -0
  26. package/dist/core/agent-session-tasks.d.ts.map +1 -1
  27. package/dist/core/agent-session-tasks.js +8 -1
  28. package/dist/core/agent-session-tasks.js.map +1 -1
  29. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  30. package/dist/core/extensions/loader-api.js +3 -0
  31. package/dist/core/extensions/loader-api.js.map +1 -1
  32. package/dist/core/extensions/loader-host-modules.d.ts +1 -1
  33. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  34. package/dist/core/extensions/loader-host-modules.js +2 -1
  35. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  36. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  37. package/dist/core/extensions/loader-virtual-modules.js +4 -1
  38. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  39. package/dist/core/retry-policy.d.ts +1 -0
  40. package/dist/core/retry-policy.d.ts.map +1 -1
  41. package/dist/core/retry-policy.js +2 -1
  42. package/dist/core/retry-policy.js.map +1 -1
  43. package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
  44. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  45. package/dist/core/settings-manager-basic-accessors.js +2 -0
  46. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  47. package/dist/core/settings-types.d.ts +1 -0
  48. package/dist/core/settings-types.d.ts.map +1 -1
  49. package/dist/core/settings-types.js.map +1 -1
  50. package/dist/core/tasks/agent-adapter.d.ts +9 -0
  51. package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
  52. package/dist/core/tasks/agent-adapter.js +36 -2
  53. package/dist/core/tasks/agent-adapter.js.map +1 -1
  54. package/dist/core/tasks/pause.d.ts +4 -0
  55. package/dist/core/tasks/pause.d.ts.map +1 -0
  56. package/dist/core/tasks/pause.js +49 -0
  57. package/dist/core/tasks/pause.js.map +1 -0
  58. package/dist/core/tasks/supervisor.d.ts +3 -1
  59. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  60. package/dist/core/tasks/supervisor.js +48 -22
  61. package/dist/core/tasks/supervisor.js.map +1 -1
  62. package/dist/core/tools/bash.d.ts +2 -0
  63. package/dist/core/tools/bash.d.ts.map +1 -1
  64. package/dist/core/tools/bash.js +1 -1
  65. package/dist/core/tools/bash.js.map +1 -1
  66. package/dist/core/tools/powershell.d.ts.map +1 -1
  67. package/dist/core/tools/powershell.js +1 -0
  68. package/dist/core/tools/powershell.js.map +1 -1
  69. package/dist/core/tools/resource-selectors.d.ts +1 -1
  70. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  71. package/dist/core/tools/resource-selectors.js +7 -4
  72. package/dist/core/tools/resource-selectors.js.map +1 -1
  73. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  74. package/dist/modes/interactive/components/chat-session-host.js +3 -2
  75. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  76. package/docs/background-tasks.md +7 -1
  77. package/docs/development.md +23 -74
  78. package/docs/extensions.md +4 -0
  79. package/docs/herdr.md +25 -78
  80. package/docs/intercom.md +4 -0
  81. package/docs/models/evals.md +2 -0
  82. package/docs/models/model-selection.md +10 -7
  83. package/docs/settings.md +4 -0
  84. package/docs/subagents.md +3 -1
  85. package/docs/tools.md +4 -0
  86. package/docs/workflows/api-reference.md +1 -1
  87. package/docs/workflows/operations.md +8 -3
  88. package/npm-shrinkwrap.json +59 -59
  89. package/package.json +3 -3
@@ -1 +1 @@
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,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,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,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAC9F,OAAO,EA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,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 { resolve as resolvePath } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { APP_NAME } from \"../../config.js\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { truncateToVisualLines } from \"../../modes/interactive/components/visual-truncate.ts\";\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 { BashResult } from \"../bash-executor.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport type { WaitPolicy } from \"../tasks/contracts.js\";\nimport {\n\ttype BashInterceptorRule,\n\tcheckBashInterceptionCandidates,\n\tDEFAULT_BASH_INTERCEPTOR_RULES,\n} from \"./bash-interceptor.ts\";\nimport { stripLeadingCdCommand } from \"./bash-leading-cd.ts\";\nimport {\n\texecuteNativePty,\n\texecuteSupervisedCommand,\n\ttype SupervisedCommandOwner,\n\ttype SupervisedCommandResult,\n\tvalidateBashWait,\n} from \"./bash-pty-native.js\";\nimport { applyBashSessionEnvironment, snapshotBashSessionEnvironment } from \"./bash-session-environment.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport { getTextOutput, invalidArgText, str } from \"./render-utils.ts\";\nimport { expandShellInternalUrls, type InternalResourceContext } from \"./resource-selectors.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult } from \"./truncate.ts\";\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},\n\t{ additionalProperties: false },\n);\nconst bashSchema = bashBaseSchema;\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\"Choose foreground or background bash 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},\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 }) => {\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\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{ onData, signal, timeout, wait, env, shellPath: options.shellPath, taskOwner: options.taskOwner },\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\tlet timedOut = false;\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\ttimedOut = true;\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\tif (timedOut) {\n\t\t\t\t\tthrow new Error(`timeout:${timeout}`);\n\t\t\t\t}\n\t\t\t\treturn { exitCode };\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 BashInterceptorResult {\n\toperations?: BashOperations;\n\tresult?: BashResult;\n}\nexport type BashInterceptor = (\n\tcontext: BashSpawnContext,\n) => Promise<BashInterceptorResult | undefined> | BashInterceptorResult | undefined;\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/** Last-mile hook for rewriting the command/cwd/env spawn context. */\n\tspawnHook?: BashSpawnHook;\n\t/** Optional command interceptor used by extensions and parity tests. */\n\tinterceptor?: BashInterceptor;\n\tinterceptorEnabled?: boolean | (() => boolean);\n\tavailableTools?: string[];\n\tinterceptorRules?: BashInterceptorRule[];\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_PREVIEW_LINES = 5,\n\tBASH_UPDATE_THROTTLE_MS = 100;\nfunction bashResultToToolResult(result: BashResult): {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: BashToolDetails | undefined;\n} {\n\tconst details: BashToolDetails | undefined = result.truncated\n\t\t? { fullOutputPath: result.fullOutputPath }\n\t\t: undefined;\n\tconst status = result.cancelled\n\t\t? \"Command aborted\"\n\t\t: result.exitCode && result.exitCode !== 0\n\t\t\t? `Command exited with code ${result.exitCode}`\n\t\t\t: undefined;\n\tconst text = `${result.output || \"(no output)\"}${status ? `\\n\\n${status}` : \"\"}`;\n\treturn { content: [{ type: \"text\", text }], details };\n}\ntype BashRenderState = {\n\tstartedAt: number | undefined;\n\tendedAt: number | undefined;\n\tinterval: NodeJS.Timeout | undefined;\n};\ntype BashResultRenderState = {\n\tcachedWidth: number | undefined;\n\tcachedLines: string[] | undefined;\n\tcachedSkipped: number | undefined;\n};\nclass BashResultRenderComponent extends Container {\n\tstate: BashResultRenderState = {\n\t\tcachedWidth: undefined,\n\t\tcachedLines: undefined,\n\t\tcachedSkipped: undefined,\n\t};\n}\nfunction formatDuration(ms: number): string {\n\tconst totalSeconds = Math.floor(Math.max(0, ms) / 1000);\n\tconst hours = Math.floor(totalSeconds / 3600);\n\tconst minutes = Math.floor((totalSeconds % 3600) / 60);\n\tconst seconds = totalSeconds % 60;\n\tif (hours > 0) return minutes > 0 ? `${hours}h ${minutes}m` : `${hours}h`;\n\tif (minutes > 0) return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n\treturn `${seconds}s`;\n}\nfunction formatBashCall(args: { command?: string; timeout?: number } | undefined, prompt: string): string {\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: BashResultRenderComponent,\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\tstartedAt: number | undefined,\n\tendedAt: number | undefined,\n): void {\n\tconst state = component.state;\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) {\n\t\tconst styledOutput = output\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => theme.fg(\"toolOutput\", line))\n\t\t\t.join(\"\\n\");\n\t\tif (options.expanded) {\n\t\t\tcomponent.addChild(new Text(`\\n${styledOutput}`, 0, 0));\n\t\t} else {\n\t\t\tcomponent.addChild({\n\t\t\t\trender: (width: number) => {\n\t\t\t\t\tif (state.cachedLines === undefined || state.cachedWidth !== width) {\n\t\t\t\t\t\tconst preview = truncateToVisualLines(styledOutput, BASH_PREVIEW_LINES, width);\n\t\t\t\t\t\tstate.cachedLines = preview.visualLines;\n\t\t\t\t\t\tstate.cachedSkipped = preview.skippedCount;\n\t\t\t\t\t\tstate.cachedWidth = width;\n\t\t\t\t\t}\n\t\t\t\t\tif (state.cachedSkipped && state.cachedSkipped > 0) {\n\t\t\t\t\t\tconst hint =\n\t\t\t\t\t\t\ttheme.fg(\"muted\", \"... \") +\n\t\t\t\t\t\t\tparenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${state.cachedSkipped} earlier lines`);\n\t\t\t\t\t\treturn [\"\", truncateToWidth(hint, width, \"...\"), ...(state.cachedLines ?? [])];\n\t\t\t\t\t}\n\t\t\t\t\treturn [\"\", ...(state.cachedLines ?? [])];\n\t\t\t\t},\n\t\t\t\tinvalidate: () => {\n\t\t\t\t\tstate.cachedWidth = undefined;\n\t\t\t\t\tstate.cachedLines = undefined;\n\t\t\t\t\tstate.cachedSkipped = undefined;\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\tif (truncation?.truncated || fullOutputPath) {\n\t\tconst warnings: string[] = [];\n\t\tif (fullOutputPath) {\n\t\t\twarnings.push(`Full output: ${fullOutputPath}`);\n\t\t}\n\t\tif (truncation?.truncated) {\n\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\twarnings.push(`Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines`);\n\t\t\t} else {\n\t\t\t\twarnings.push(\n\t\t\t\t\t`Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tcomponent.addChild(new Text(`\\n${theme.fg(\"warning\", `[${warnings.join(\". \")}]`)}`, 0, 0));\n\t}\n\tif (startedAt !== undefined) {\n\t\tconst label = options.isPartial ? \"Elapsed\" : observation?.kind === \"yielded\" ? \"Observed for\" : \"Took\";\n\t\tconst endTime = endedAt ?? Date.now();\n\t\tcomponent.addChild(new Text(`\\n${theme.fg(\"muted\", `${label} ${formatDuration(endTime - startedAt)}`)}`, 0, 0));\n\t}\n}\nexport function createBashToolDefinition(\n\tcwd: string,\n\toptions?: BashToolOptions,\n\tpresentation: ShellToolPresentation = BASH_SHELL_PRESENTATION,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\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 interceptor = options?.interceptor;\n\tconst isInterceptorEnabled = (): boolean =>\n\t\ttypeof options?.interceptorEnabled === \"function\"\n\t\t\t? options.interceptorEnabled()\n\t\t\t: (options?.interceptorEnabled ?? !!interceptor);\n\tconst availableTools = options?.availableTools ?? [\"read\", \"search\", \"find\", \"edit\", \"write\"];\n\tconst interceptorRules = options?.interceptorRules ?? DEFAULT_BASH_INTERCEPTOR_RULES;\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\tlabel: \"bash\",\n\t\tdescription:\n\t\t\t\"Execute a shell command with optional PTY handling and foreground/background observation. Choose the observation mode without asking the user; omitted wait auto-yields per owner configuration (default 10s). Observation does not change execution timeout. Background requires a supported task owner; unbound foreground 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\tparameters: bashSchema,\n\t\tmaxResultSizeChars: Infinity,\n\t\tasync execute(_toolCallId, bashCommand: BashToolInput, signal?: AbortSignal, onUpdate?, ctx?: ExtensionContext) {\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\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 rawStrippedContext = hasExplicitCwd ? undefined : stripLeadingCdCommand(command, executionCwd);\n\t\t\tconst interceptorEnabled = isInterceptorEnabled();\n\t\t\tif (interceptorEnabled)\n\t\t\t\tcheckBashInterceptionCandidates([command, rawStrippedContext?.command], availableTools, interceptorRules);\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(command, executionCwd, resourceCtx, true);\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\tif (interceptorEnabled)\n\t\t\t\tcheckBashInterceptionCandidates(\n\t\t\t\t\t[\n\t\t\t\t\t\texpandedCommand,\n\t\t\t\t\t\tstrippedExpandedContext?.command,\n\t\t\t\t\t\tresolvedCommand,\n\t\t\t\t\t\tspawnContext.command,\n\t\t\t\t\t\tstrippedCdContext?.command,\n\t\t\t\t\t],\n\t\t\t\t\tavailableTools,\n\t\t\t\t\tinterceptorRules,\n\t\t\t\t);\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 primaryInterception = interceptorEnabled && interceptor ? await interceptor(spawnContext) : undefined;\n\t\t\tconst fallbackInterception =\n\t\t\t\t!primaryInterception && strippedCdContext && interceptorEnabled && interceptor\n\t\t\t\t\t? await interceptor(strippedCdContext)\n\t\t\t\t\t: undefined;\n\t\t\tconst intercepted = primaryInterception ?? fallbackInterception;\n\t\t\tif (intercepted?.result) return bashResultToToolResult(intercepted.result);\n\t\t\tconst ops = intercepted?.operations ?? defaultOps;\n\t\t\tconst executionContext = primaryInterception ? spawnContext : (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 ops.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});\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 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`));\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 !== 0 && exitCode !== null) {\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};\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: outputText }], details: withTiming(details) };\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\tconst state = context.state;\n\t\t\tif (context.executionStarted && state.startedAt === undefined) {\n\t\t\t\tstate.startedAt = Date.now();\n\t\t\t\tstate.endedAt = undefined;\n\t\t\t}\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\tconst state = context.state;\n\t\t\tif (state.startedAt !== undefined && options.isPartial && !state.interval) {\n\t\t\t\tstate.interval = setInterval(() => context.invalidate(), 1000);\n\t\t\t}\n\t\t\tif (!options.isPartial || context.isError) {\n\t\t\t\tstate.endedAt ??= Date.now();\n\t\t\t\tif (state.interval) {\n\t\t\t\t\tclearInterval(state.interval);\n\t\t\t\t\tstate.interval = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as BashResultRenderComponent | undefined) ?? new BashResultRenderComponent();\n\t\t\trebuildBashResultRenderComponent(\n\t\t\t\tcomponent,\n\t\t\t\tresult,\n\t\t\t\toptions,\n\t\t\t\tcontext.showImages,\n\t\t\t\tstate.startedAt,\n\t\t\t\tstate.endedAt,\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,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,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,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAC9F,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,sBAAs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,IAAI,CAAC;QACb,CAAC;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO;YAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YAC5B,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;gBAC3E,KAAK,CAAC,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;YAChE,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBAC3C,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC7B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACpB,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBAC9B,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC;gBAC5B,CAAC;YACF,CAAC;YACD,MAAM,SAAS,GACb,OAAO,CAAC,aAAuD,IAAI,IAAI,yBAAyB,EAAE,CAAC;YACrG,gCAAgC,CAC/B,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,CAAC,UAAU,EAClB,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,OAAO,CACb,CAAC;YACF,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 { resolve as resolvePath } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { APP_NAME } from \"../../config.js\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { truncateToVisualLines } from \"../../modes/interactive/components/visual-truncate.ts\";\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 { BashResult } from \"../bash-executor.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport type { WaitPolicy } from \"../tasks/contracts.js\";\nimport {\n\ttype BashInterceptorRule,\n\tcheckBashInterceptionCandidates,\n\tDEFAULT_BASH_INTERCEPTOR_RULES,\n} from \"./bash-interceptor.ts\";\nimport { stripLeadingCdCommand } from \"./bash-leading-cd.ts\";\nimport {\n\texecuteNativePty,\n\texecuteSupervisedCommand,\n\ttype SupervisedCommandOwner,\n\ttype SupervisedCommandResult,\n\tvalidateBashWait,\n} from \"./bash-pty-native.js\";\nimport { applyBashSessionEnvironment, snapshotBashSessionEnvironment } from \"./bash-session-environment.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport { getTextOutput, invalidArgText, str } from \"./render-utils.ts\";\nimport { expandShellInternalUrls, type InternalResourceContext } from \"./resource-selectors.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult } from \"./truncate.ts\";\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},\n\t{ additionalProperties: false },\n);\nconst bashSchema = bashBaseSchema;\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\"Choose foreground or background bash 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},\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 }) => {\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\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{ onData, signal, timeout, wait, env, shellPath: options.shellPath, taskOwner: options.taskOwner },\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\tlet timedOut = false;\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\ttimedOut = true;\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\tif (timedOut) {\n\t\t\t\t\tthrow new Error(`timeout:${timeout}`);\n\t\t\t\t}\n\t\t\t\treturn { exitCode };\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 BashInterceptorResult {\n\toperations?: BashOperations;\n\tresult?: BashResult;\n}\nexport type BashInterceptor = (\n\tcontext: BashSpawnContext,\n) => Promise<BashInterceptorResult | undefined> | BashInterceptorResult | undefined;\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/** Optional command interceptor used by extensions and parity tests. */\n\tinterceptor?: BashInterceptor;\n\tinterceptorEnabled?: boolean | (() => boolean);\n\tavailableTools?: string[];\n\tinterceptorRules?: BashInterceptorRule[];\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_PREVIEW_LINES = 5,\n\tBASH_UPDATE_THROTTLE_MS = 100;\nfunction bashResultToToolResult(result: BashResult): {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: BashToolDetails | undefined;\n} {\n\tconst details: BashToolDetails | undefined = result.truncated\n\t\t? { fullOutputPath: result.fullOutputPath }\n\t\t: undefined;\n\tconst status = result.cancelled\n\t\t? \"Command aborted\"\n\t\t: result.exitCode && result.exitCode !== 0\n\t\t\t? `Command exited with code ${result.exitCode}`\n\t\t\t: undefined;\n\tconst text = `${result.output || \"(no output)\"}${status ? `\\n\\n${status}` : \"\"}`;\n\treturn { content: [{ type: \"text\", text }], details };\n}\ntype BashRenderState = {\n\tstartedAt: number | undefined;\n\tendedAt: number | undefined;\n\tinterval: NodeJS.Timeout | undefined;\n};\ntype BashResultRenderState = {\n\tcachedWidth: number | undefined;\n\tcachedLines: string[] | undefined;\n\tcachedSkipped: number | undefined;\n};\nclass BashResultRenderComponent extends Container {\n\tstate: BashResultRenderState = {\n\t\tcachedWidth: undefined,\n\t\tcachedLines: undefined,\n\t\tcachedSkipped: undefined,\n\t};\n}\nfunction formatDuration(ms: number): string {\n\tconst totalSeconds = Math.floor(Math.max(0, ms) / 1000);\n\tconst hours = Math.floor(totalSeconds / 3600);\n\tconst minutes = Math.floor((totalSeconds % 3600) / 60);\n\tconst seconds = totalSeconds % 60;\n\tif (hours > 0) return minutes > 0 ? `${hours}h ${minutes}m` : `${hours}h`;\n\tif (minutes > 0) return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n\treturn `${seconds}s`;\n}\nfunction formatBashCall(args: { command?: string; timeout?: number } | undefined, prompt: string): string {\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: BashResultRenderComponent,\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\tstartedAt: number | undefined,\n\tendedAt: number | undefined,\n): void {\n\tconst state = component.state;\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) {\n\t\tconst styledOutput = output\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => theme.fg(\"toolOutput\", line))\n\t\t\t.join(\"\\n\");\n\t\tif (options.expanded) {\n\t\t\tcomponent.addChild(new Text(`\\n${styledOutput}`, 0, 0));\n\t\t} else {\n\t\t\tcomponent.addChild({\n\t\t\t\trender: (width: number) => {\n\t\t\t\t\tif (state.cachedLines === undefined || state.cachedWidth !== width) {\n\t\t\t\t\t\tconst preview = truncateToVisualLines(styledOutput, BASH_PREVIEW_LINES, width);\n\t\t\t\t\t\tstate.cachedLines = preview.visualLines;\n\t\t\t\t\t\tstate.cachedSkipped = preview.skippedCount;\n\t\t\t\t\t\tstate.cachedWidth = width;\n\t\t\t\t\t}\n\t\t\t\t\tif (state.cachedSkipped && state.cachedSkipped > 0) {\n\t\t\t\t\t\tconst hint =\n\t\t\t\t\t\t\ttheme.fg(\"muted\", \"... \") +\n\t\t\t\t\t\t\tparenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${state.cachedSkipped} earlier lines`);\n\t\t\t\t\t\treturn [\"\", truncateToWidth(hint, width, \"...\"), ...(state.cachedLines ?? [])];\n\t\t\t\t\t}\n\t\t\t\t\treturn [\"\", ...(state.cachedLines ?? [])];\n\t\t\t\t},\n\t\t\t\tinvalidate: () => {\n\t\t\t\t\tstate.cachedWidth = undefined;\n\t\t\t\t\tstate.cachedLines = undefined;\n\t\t\t\t\tstate.cachedSkipped = undefined;\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\tif (truncation?.truncated || fullOutputPath) {\n\t\tconst warnings: string[] = [];\n\t\tif (fullOutputPath) {\n\t\t\twarnings.push(`Full output: ${fullOutputPath}`);\n\t\t}\n\t\tif (truncation?.truncated) {\n\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\twarnings.push(`Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines`);\n\t\t\t} else {\n\t\t\t\twarnings.push(\n\t\t\t\t\t`Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tcomponent.addChild(new Text(`\\n${theme.fg(\"warning\", `[${warnings.join(\". \")}]`)}`, 0, 0));\n\t}\n\tif (startedAt !== undefined) {\n\t\tconst label = options.isPartial ? \"Elapsed\" : observation?.kind === \"yielded\" ? \"Observed for\" : \"Took\";\n\t\tconst endTime = endedAt ?? Date.now();\n\t\tcomponent.addChild(new Text(`\\n${theme.fg(\"muted\", `${label} ${formatDuration(endTime - startedAt)}`)}`, 0, 0));\n\t}\n}\nexport function createBashToolDefinition(\n\tcwd: string,\n\toptions?: BashToolOptions,\n\tpresentation: ShellToolPresentation = BASH_SHELL_PRESENTATION,\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\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 interceptor = options?.interceptor;\n\tconst isInterceptorEnabled = (): boolean =>\n\t\ttypeof options?.interceptorEnabled === \"function\"\n\t\t\t? options.interceptorEnabled()\n\t\t\t: (options?.interceptorEnabled ?? !!interceptor);\n\tconst availableTools = options?.availableTools ?? [\"read\", \"search\", \"find\", \"edit\", \"write\"];\n\tconst interceptorRules = options?.interceptorRules ?? DEFAULT_BASH_INTERCEPTOR_RULES;\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\tlabel: \"bash\",\n\t\tdescription:\n\t\t\t\"Execute a shell command with optional PTY handling and foreground/background observation. Choose the observation mode without asking the user; omitted wait auto-yields per owner configuration (default 10s). Observation does not change execution timeout. Background requires a supported task owner; unbound foreground 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\tparameters: bashSchema,\n\t\tmaxResultSizeChars: Infinity,\n\t\tasync execute(_toolCallId, bashCommand: BashToolInput, signal?: AbortSignal, onUpdate?, ctx?: ExtensionContext) {\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\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 rawStrippedContext = hasExplicitCwd ? undefined : stripLeadingCdCommand(command, executionCwd);\n\t\t\tconst interceptorEnabled = isInterceptorEnabled();\n\t\t\tif (interceptorEnabled)\n\t\t\t\tcheckBashInterceptionCandidates([command, rawStrippedContext?.command], availableTools, interceptorRules);\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\tif (interceptorEnabled)\n\t\t\t\tcheckBashInterceptionCandidates(\n\t\t\t\t\t[\n\t\t\t\t\t\texpandedCommand,\n\t\t\t\t\t\tstrippedExpandedContext?.command,\n\t\t\t\t\t\tresolvedCommand,\n\t\t\t\t\t\tspawnContext.command,\n\t\t\t\t\t\tstrippedCdContext?.command,\n\t\t\t\t\t],\n\t\t\t\t\tavailableTools,\n\t\t\t\t\tinterceptorRules,\n\t\t\t\t);\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 primaryInterception = interceptorEnabled && interceptor ? await interceptor(spawnContext) : undefined;\n\t\t\tconst fallbackInterception =\n\t\t\t\t!primaryInterception && strippedCdContext && interceptorEnabled && interceptor\n\t\t\t\t\t? await interceptor(strippedCdContext)\n\t\t\t\t\t: undefined;\n\t\t\tconst intercepted = primaryInterception ?? fallbackInterception;\n\t\t\tif (intercepted?.result) return bashResultToToolResult(intercepted.result);\n\t\t\tconst ops = intercepted?.operations ?? defaultOps;\n\t\t\tconst executionContext = primaryInterception ? spawnContext : (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 ops.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});\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 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`));\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 !== 0 && exitCode !== null) {\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};\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: outputText }], details: withTiming(details) };\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\tconst state = context.state;\n\t\t\tif (context.executionStarted && state.startedAt === undefined) {\n\t\t\t\tstate.startedAt = Date.now();\n\t\t\t\tstate.endedAt = undefined;\n\t\t\t}\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\tconst state = context.state;\n\t\t\tif (state.startedAt !== undefined && options.isPartial && !state.interval) {\n\t\t\t\tstate.interval = setInterval(() => context.invalidate(), 1000);\n\t\t\t}\n\t\t\tif (!options.isPartial || context.isError) {\n\t\t\t\tstate.endedAt ??= Date.now();\n\t\t\t\tif (state.interval) {\n\t\t\t\t\tclearInterval(state.interval);\n\t\t\t\t\tstate.interval = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as BashResultRenderComponent | undefined) ?? new BashResultRenderComponent();\n\t\t\trebuildBashResultRenderComponent(\n\t\t\t\tcomponent,\n\t\t\t\tresult,\n\t\t\t\toptions,\n\t\t\t\tcontext.showImages,\n\t\t\t\tstate.startedAt,\n\t\t\t\tstate.endedAt,\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 +1 @@
1
- {"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../../src/core/tools/powershell.ts"],"names":[],"mappings":"AASA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EAIpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAGN,KAAK,sBAAsB,EAE3B,MAAM,sBAAsB,CAAC;AAS9B,eAAO,MAAM,sCAAsC;sBACzC,8BAA8B;;EAI7B,CAAC;AACZ,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAClD,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC;AACpD,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAChD,MAAM,WAAW,qBAChB,SAAQ,IAAI,CAAC,eAAe,EAAE,0BAA0B,GAAG,WAAW,GAAG,WAAW,CAAC;IACrF,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AACD,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE;IACzD,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACnC,GAAG,oBAAoB,CA0DvB;AACD,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B;;;;;;;;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;;;iCAEhF;AACD,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACtD,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC"}
@@ -90,6 +90,7 @@ export function createLocalPowerShellOperations(binding) {
90
90
  export function createPowerShellToolDefinition(cwd, options = {}) {
91
91
  const definition = createBashToolDefinition(cwd, {
92
92
  ...options,
93
+ shellDialect: "powershell",
93
94
  operations: options.operations ?? createLocalPowerShellOperations({ taskOwner: options.taskOwner }),
94
95
  }, POWERSHELL_PRESENTATION);
95
96
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"powershell.js","sourceRoot":"","sources":["../../../src/core/tools/powershell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EACN,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAON,wBAAwB,EAExB,8BAA8B,GAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EAExB,gBAAgB,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,uBAAuB,GAA0B;IACtD,MAAM,EAAE,KAAK;IACb,cAAc,EAAE,GAAG,QAAQ,aAAa;CACxC,CAAC;AAEF,MAAM,kBAAkB,GAAG,2EAA2E,CAAC;AACvG,MAAM,CAAC,MAAM,sCAAsC,GAAG,MAAM,CAAC,MAAM,CAAC;IACnE,OAAO,EAAE,8BAA8B;IACvC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC;QACzB,+FAA+F;KACtF,CAAC;CACF,CAAC,CAAC;AAQZ,MAAM,UAAU,+BAA+B,CAAC,OAE/C;IACA,OAAO;QACN,IAAI,EAA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AAE,YAAY;QAClB,KAAK,EAAE,YAAY;QACnB,KAAK,CAAC,OAAO,CAAC,GAAG,IAA2C;YAC3D,mEAAmE;YACnE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC5E,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,WAAW,EACV,mPAAmP;QACpP,aAAa,EAAE,sCAAsC,CAAC,OAAO;QAC7D,gBAAgB,EACf,OAAO,CAAC,wBAAwB,KAAK,KAAK;YACzC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,GAAG,sCAAsC,CAAC,UAAU,CAAC;KAC1D,CAAC;AACH,CAAC;AACD,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,OAA+B;IAChF,OAAO,kBAAkB,CAAC,8BAA8B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { APP_NAME } from \"../../config.js\";\nimport { createChildProcessEnvironment, waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetPowerShellConfig,\n\tgetShellEnv,\n\tkillProcessTree,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\ttype ShellToolPresentation,\n\tvalidateExplicitTimeoutSeconds,\n} from \"./bash.js\";\nimport {\n\texecuteNativePty,\n\texecuteSupervisedCommand,\n\ttype SupervisedCommandOwner,\n\tvalidateBashWait,\n} from \"./bash-pty-native.js\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst POWERSHELL_PRESENTATION: ShellToolPresentation = {\n\tprompt: \"PS>\",\n\ttempFilePrefix: `${APP_NAME}-powershell`,\n};\n\nconst UTF8_OUTPUT_PREFIX = \"try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}\\n\";\nexport const powershellToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Execute PowerShell commands.\",\n\tguidelines: Object.freeze([\n\t\t\"You can inspect ATOMIC_* or PI_* environment variables for current model and session details.\",\n\t] as const),\n} as const);\nexport type PowerShellOperations = BashOperations;\nexport type PowerShellToolDetails = BashToolDetails;\nexport type PowerShellToolInput = BashToolInput;\nexport interface PowerShellToolOptions\n\textends Pick<BashToolOptions, \"exposeSessionEnvironment\" | \"spawnHook\" | \"taskOwner\"> {\n\toperations?: BashOperations;\n}\nexport function createLocalPowerShellOperations(binding?: {\n\ttaskOwner?: SupervisedCommandOwner;\n}): PowerShellOperations {\n\treturn {\n\t\texec: async (command, cwd, options) => {\n\t\t\tvalidateBashWait(options.wait, !!binding?.taskOwner);\n\t\t\tif (options.timeout !== undefined) validateExplicitTimeoutSeconds(options.timeout);\n\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst { shell, args } = getPowerShellConfig();\n\t\t\tconst pty = !!options.pty && process.env.PI_NO_PTY !== \"1\" && process.env.ATOMIC_NO_PTY !== \"1\";\n\t\t\tif (binding?.taskOwner || pty) {\n\t\t\t\t// EncodedCommand avoids native argument parsing differences between PowerShell 5 and 7.\n\t\t\t\tconst encoded = Buffer.from(`${UTF8_OUTPUT_PREFIX}${command}`, \"utf16le\").toString(\"base64\");\n\t\t\t\tconst execution = {\n\t\t\t\t\t...options,\n\t\t\t\t\tshellConfig: { shell, args: [...args.slice(0, -1), \"-EncodedCommand\"] },\n\t\t\t\t\tcommandDescription: command,\n\t\t\t\t\ttaskOwner: binding?.taskOwner,\n\t\t\t\t};\n\t\t\t\treturn binding?.taskOwner\n\t\t\t\t\t? executeSupervisedCommand(encoded, cwd, execution, pty)\n\t\t\t\t\t: executeNativePty(encoded, cwd, execution);\n\t\t\t}\n\t\t\tconst { spawn } = await import(\"node:child_process\");\n\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst child = spawn(shell, [...args, `${UTF8_OUTPUT_PREFIX}${command}`], {\n\t\t\t\tcwd,\n\t\t\t\tenv: createChildProcessEnvironment(undefined, options.env ?? getShellEnv()),\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: ReturnType<typeof setTimeout> | 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 (options.timeout !== undefined && options.timeout > 0) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\t\t}, options.timeout * 1000);\n\t\t\t\t}\n\t\t\t\tchild.stdout?.on(\"data\", (data: Buffer) => options.onData(data, \"stdout\"));\n\t\t\t\tchild.stderr?.on(\"data\", (data: Buffer) => options.onData(data, \"stderr\"));\n\t\t\t\tif (options.signal) {\n\t\t\t\t\tif (options.signal.aborted) onAbort();\n\t\t\t\t\telse options.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 (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\t\tif (timedOut) throw new Error(`timeout:${options.timeout}`);\n\t\t\t\treturn { exitCode };\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\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\nexport function createPowerShellToolDefinition(cwd: string, options: PowerShellToolOptions = {}) {\n\tconst definition = createBashToolDefinition(\n\t\tcwd,\n\t\t{\n\t\t\t...options,\n\t\t\toperations: options.operations ?? createLocalPowerShellOperations({ taskOwner: options.taskOwner }),\n\t\t},\n\t\tPOWERSHELL_PRESENTATION,\n\t);\n\treturn {\n\t\t...definition,\n\t\tname: \"powershell\",\n\t\tlabel: \"powershell\",\n\t\tasync execute(...args: Parameters<typeof definition.execute>) {\n\t\t\t// The internal local adapter is not evidence of a supported owner.\n\t\t\tvalidateBashWait(args[1].wait, !!options.operations || !!options.taskOwner);\n\t\t\treturn definition.execute(...args);\n\t\t},\n\t\tdescription:\n\t\t\t\"Execute a PowerShell command with optional PTY and foreground/background observation. Owner-bound calls automatically yield after 10s by default without stopping execution. Unbound calls wait for completion; background requires a task owner.\",\n\t\tpromptSnippet: powershellToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines:\n\t\t\toptions.exposeSessionEnvironment === false\n\t\t\t\t? undefined\n\t\t\t\t: [...powershellToolSystemPromptContribution.guidelines],\n\t};\n}\nexport function createPowerShellTool(cwd: string, options?: PowerShellToolOptions) {\n\treturn wrapToolDefinition(createPowerShellToolDefinition(cwd, options));\n}\nexport type PowerShellSpawnContext = BashSpawnContext;\nexport type PowerShellSpawnHook = BashSpawnHook;\n"]}
1
+ {"version":3,"file":"powershell.js","sourceRoot":"","sources":["../../../src/core/tools/powershell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EACN,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAON,wBAAwB,EAExB,8BAA8B,GAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EAExB,gBAAgB,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OA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BAC/C,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACvD,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC;AACD,MAAM,UAAU,8BAA8B,CAAC,GAAW,EAAE,OAAO,GAA0B,EAAE;IAC9F,MAAM,UAAU,GAAG,wBAAwB,CAC1C,GAAG,EACH;QACC,GAAG,OAAO;QACV,YAAY,EAAE,YAAY;QAC1B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,+BAA+B,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;KACnG,EACD,uBAAuB,CACvB,CAAC;IACF,OAAO;QACN,GAAG,UAAU;QACb,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,YAAY;QACnB,KAAK,CAAC,OAAO,CAAC,GAAG,IAA2C;YAC3D,mEAAmE;YACnE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC5E,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,WAAW,EACV,mPAAmP;QACpP,aAAa,EAAE,sCAAsC,CAAC,OAAO;QAC7D,gBAAgB,EACf,OAAO,CAAC,wBAAwB,KAAK,KAAK;YACzC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,GAAG,sCAAsC,CAAC,UAAU,CAAC;KAC1D,CAAC;AACH,CAAC;AACD,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,OAA+B;IAChF,OAAO,kBAAkB,CAAC,8BAA8B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { APP_NAME } from \"../../config.js\";\nimport { createChildProcessEnvironment, waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetPowerShellConfig,\n\tgetShellEnv,\n\tkillProcessTree,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\ttype ShellToolPresentation,\n\tvalidateExplicitTimeoutSeconds,\n} from \"./bash.js\";\nimport {\n\texecuteNativePty,\n\texecuteSupervisedCommand,\n\ttype SupervisedCommandOwner,\n\tvalidateBashWait,\n} from \"./bash-pty-native.js\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst POWERSHELL_PRESENTATION: ShellToolPresentation = {\n\tprompt: \"PS>\",\n\ttempFilePrefix: `${APP_NAME}-powershell`,\n};\n\nconst UTF8_OUTPUT_PREFIX = \"try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}\\n\";\nexport const powershellToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Execute PowerShell commands.\",\n\tguidelines: Object.freeze([\n\t\t\"You can inspect ATOMIC_* or PI_* environment variables for current model and session details.\",\n\t] as const),\n} as const);\nexport type PowerShellOperations = BashOperations;\nexport type PowerShellToolDetails = BashToolDetails;\nexport type PowerShellToolInput = BashToolInput;\nexport interface PowerShellToolOptions\n\textends Pick<BashToolOptions, \"exposeSessionEnvironment\" | \"spawnHook\" | \"taskOwner\"> {\n\toperations?: BashOperations;\n}\nexport function createLocalPowerShellOperations(binding?: {\n\ttaskOwner?: SupervisedCommandOwner;\n}): PowerShellOperations {\n\treturn {\n\t\texec: async (command, cwd, options) => {\n\t\t\tvalidateBashWait(options.wait, !!binding?.taskOwner);\n\t\t\tif (options.timeout !== undefined) validateExplicitTimeoutSeconds(options.timeout);\n\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst { shell, args } = getPowerShellConfig();\n\t\t\tconst pty = !!options.pty && process.env.PI_NO_PTY !== \"1\" && process.env.ATOMIC_NO_PTY !== \"1\";\n\t\t\tif (binding?.taskOwner || pty) {\n\t\t\t\t// EncodedCommand avoids native argument parsing differences between PowerShell 5 and 7.\n\t\t\t\tconst encoded = Buffer.from(`${UTF8_OUTPUT_PREFIX}${command}`, \"utf16le\").toString(\"base64\");\n\t\t\t\tconst execution = {\n\t\t\t\t\t...options,\n\t\t\t\t\tshellConfig: { shell, args: [...args.slice(0, -1), \"-EncodedCommand\"] },\n\t\t\t\t\tcommandDescription: command,\n\t\t\t\t\ttaskOwner: binding?.taskOwner,\n\t\t\t\t};\n\t\t\t\treturn binding?.taskOwner\n\t\t\t\t\t? executeSupervisedCommand(encoded, cwd, execution, pty)\n\t\t\t\t\t: executeNativePty(encoded, cwd, execution);\n\t\t\t}\n\t\t\tconst { spawn } = await import(\"node:child_process\");\n\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst child = spawn(shell, [...args, `${UTF8_OUTPUT_PREFIX}${command}`], {\n\t\t\t\tcwd,\n\t\t\t\tenv: createChildProcessEnvironment(undefined, options.env ?? getShellEnv()),\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: ReturnType<typeof setTimeout> | 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 (options.timeout !== undefined && options.timeout > 0) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\t\t}, options.timeout * 1000);\n\t\t\t\t}\n\t\t\t\tchild.stdout?.on(\"data\", (data: Buffer) => options.onData(data, \"stdout\"));\n\t\t\t\tchild.stderr?.on(\"data\", (data: Buffer) => options.onData(data, \"stderr\"));\n\t\t\t\tif (options.signal) {\n\t\t\t\t\tif (options.signal.aborted) onAbort();\n\t\t\t\t\telse options.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 (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\t\tif (timedOut) throw new Error(`timeout:${options.timeout}`);\n\t\t\t\treturn { exitCode };\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\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\nexport function createPowerShellToolDefinition(cwd: string, options: PowerShellToolOptions = {}) {\n\tconst definition = createBashToolDefinition(\n\t\tcwd,\n\t\t{\n\t\t\t...options,\n\t\t\tshellDialect: \"powershell\",\n\t\t\toperations: options.operations ?? createLocalPowerShellOperations({ taskOwner: options.taskOwner }),\n\t\t},\n\t\tPOWERSHELL_PRESENTATION,\n\t);\n\treturn {\n\t\t...definition,\n\t\tname: \"powershell\",\n\t\tlabel: \"powershell\",\n\t\tasync execute(...args: Parameters<typeof definition.execute>) {\n\t\t\t// The internal local adapter is not evidence of a supported owner.\n\t\t\tvalidateBashWait(args[1].wait, !!options.operations || !!options.taskOwner);\n\t\t\treturn definition.execute(...args);\n\t\t},\n\t\tdescription:\n\t\t\t\"Execute a PowerShell command with optional PTY and foreground/background observation. Owner-bound calls automatically yield after 10s by default without stopping execution. Unbound calls wait for completion; background requires a task owner.\",\n\t\tpromptSnippet: powershellToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines:\n\t\t\toptions.exposeSessionEnvironment === false\n\t\t\t\t? undefined\n\t\t\t\t: [...powershellToolSystemPromptContribution.guidelines],\n\t};\n}\nexport function createPowerShellTool(cwd: string, options?: PowerShellToolOptions) {\n\treturn wrapToolDefinition(createPowerShellToolDefinition(cwd, options));\n}\nexport type PowerShellSpawnContext = BashSpawnContext;\nexport type PowerShellSpawnHook = BashSpawnHook;\n"]}
@@ -40,7 +40,7 @@ export declare function resolveInternalSelector(value: string, cwd: string): str
40
40
  export declare function readInternalSelector(value: string, cwd: string, context?: InternalResourceContext): Promise<string>;
41
41
  export declare function writeInternalSelector(value: string, cwd: string, content: string, context?: InternalResourceContext): Promise<void>;
42
42
  export declare function searchInternalSelector(value: string, cwd: string, pattern: string, ignoreCase?: boolean, literal?: boolean, context?: InternalResourceContext, contextBefore?: number, contextAfter?: number): Promise<string>;
43
- export declare function expandShellInternalUrls(text: string, cwd: string, context?: InternalResourceContext, quote?: boolean): Promise<string>;
43
+ export declare function expandShellInternalUrls(text: string, cwd: string, context?: InternalResourceContext, quote?: boolean, dialect?: "posix" | "powershell"): Promise<string>;
44
44
  export declare function readSqliteSelector(selector: SqliteSelector): string;
45
45
  export declare function writeSqliteSelector(selector: SqliteSelector, content: string): string;
46
46
  export declare function searchSqliteSelector(selector: SqliteSelector, pattern: string, ignoreCase?: boolean, contextBefore?: number, contextAfter?: number): string;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-selectors.d.ts","sourceRoot":"","sources":["../../../src/core/tools/resource-selectors.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,cAAc;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,sBAAsB;IACtC,IAAI,CA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AI,GACd,MAAM,CAgDR"}
@@ -615,10 +615,13 @@ export async function writeInternalSelector(value, cwd, content, context) {
615
615
  export async function searchInternalSelector(value, cwd, pattern, ignoreCase = false, literal = false, context, contextBefore = 1, contextAfter = 3) {
616
616
  return searchTextSelectorLines(value, await readInternalSelector(value, cwd, context), pattern, ignoreCase, literal, contextBefore, contextAfter).join("\n");
617
617
  }
618
- function shellQuote(value) {
619
- return `'${value.replace(/'/g, `'\\''`)}'`;
618
+ function shellQuote(value, dialect) {
619
+ // PowerShell also treats U+2018–U+201B as single-quote delimiters.
620
+ return dialect === "powershell"
621
+ ? `'${value.replace(/['\u2018-\u201b]/g, "$&$&")}'`
622
+ : `'${value.replace(/'/g, `'\\''`)}'`;
620
623
  }
621
- export async function expandShellInternalUrls(text, cwd, context, quote = false) {
624
+ export async function expandShellInternalUrls(text, cwd, context, quote = false, dialect = "posix") {
622
625
  const pattern = /(?<![a-z0-9+.-])[a-z][a-z0-9+.-]*:\/\/[^\s'"`$)]+/gi;
623
626
  const replacements = new Map();
624
627
  for (const match of new Set(text.match(pattern) ?? [])) {
@@ -631,7 +634,7 @@ export async function expandShellInternalUrls(text, cwd, context, quote = false)
631
634
  if (quote && !/^[a-zA-Z0-9_ ./:%+=,@~;|&\t-]*$/.test(text)) {
632
635
  throw new Error("Internal URL shell expansion requires plain unquoted words; use a filesystem path for quotes, substitutions, escapes or heredocs.");
633
636
  }
634
- replacements.set(match, quote ? shellQuote(resolved) : resolved);
637
+ replacements.set(match, quote ? shellQuote(resolved, dialect) : resolved);
635
638
  }
636
639
  // Replace original occurrences only; never reinterpret a router's result.
637
640
  return text.replace(pattern, (match) => replacements.get(match) ?? match);