@bastani/atomic 0.9.45 → 0.9.46-alpha.1
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 +34 -0
- package/dist/builtin/intercom/CHANGELOG.md +11 -0
- package/dist/builtin/intercom/broker/broker.ts +124 -10
- package/dist/builtin/intercom/broker/client.ts +177 -25
- package/dist/builtin/intercom/broker/multinode-router.ts +228 -27
- package/dist/builtin/intercom/broker/multinode-state-store.ts +10 -0
- package/dist/builtin/intercom/broker/recipient-receipts.ts +38 -4
- package/dist/builtin/intercom/broker/send-handler.ts +9 -2
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +29 -4
- package/dist/builtin/intercom/group.ts +25 -0
- package/dist/builtin/intercom/index.bundle.mjs +177 -35
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/retry-policy.ts +7 -0
- package/dist/builtin/intercom/types.ts +21 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +10 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +150 -54
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +39 -0
- package/dist/builtin/workflows/builtin/{chunk-6901nsd6.js → chunk-6jpwc09k.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-vwx023ge.js → chunk-qhm35ntx.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-jvna28mq.js → chunk-zhyqnf5g.js} +331 -68
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +1 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +77 -0
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/durable/journal/internal.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +7076 -3386
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +11075 -7261
- package/dist/builtin/workflows/src/index.js +6768 -3605
- package/dist/builtin/workflows/src/local-worker-entry.mjs +11075 -7261
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +19 -0
- package/dist/core/agent-session-boundaries.d.ts.map +1 -1
- package/dist/core/agent-session-boundaries.js +1 -0
- package/dist/core/agent-session-boundaries.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +15 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +3 -2
- 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-prompt.d.ts +4 -2
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +13 -8
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-recovery.d.ts.map +1 -1
- package/dist/core/agent-session-recovery.js +92 -1
- package/dist/core/agent-session-recovery.js.map +1 -1
- package/dist/core/agent-session-transfer.d.ts.map +1 -1
- package/dist/core/agent-session-transfer.js +5 -0
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -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/copilot-errors.d.ts +6 -0
- package/dist/core/copilot-errors.d.ts.map +1 -0
- package/dist/core/copilot-errors.js +17 -0
- package/dist/core/copilot-errors.js.map +1 -0
- package/dist/core/execution-model-router.d.ts.map +1 -1
- package/dist/core/execution-model-router.js +12 -2
- package/dist/core/execution-model-router.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +7 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +6 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.d.ts +4 -0
- package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.js +26 -5
- package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
- package/dist/core/extensions/workflow-events.d.ts +5 -0
- package/dist/core/extensions/workflow-events.d.ts.map +1 -1
- package/dist/core/extensions/workflow-events.js.map +1 -1
- package/dist/core/messages.d.ts +5 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +37 -3
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-runtime-streaming.js +2 -2
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +19 -11
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/provider-rate-limits.d.ts +55 -6
- package/dist/core/provider-rate-limits.d.ts.map +1 -1
- package/dist/core/provider-rate-limits.js +182 -29
- package/dist/core/provider-rate-limits.js.map +1 -1
- package/dist/core/provider-request-admission.d.ts.map +1 -1
- package/dist/core/provider-request-admission.js +42 -18
- package/dist/core/provider-request-admission.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +176 -19
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/provider.d.ts +4 -2
- package/dist/core/storage/provider.d.ts.map +1 -1
- package/dist/core/storage/provider.js +94 -5
- package/dist/core/storage/provider.js.map +1 -1
- package/dist/core/structured-output/index.d.ts.map +1 -1
- package/dist/core/structured-output/index.js +15 -8
- package/dist/core/structured-output/index.js.map +1 -1
- package/dist/core/structured-output/provider-failure.d.ts +17 -0
- package/dist/core/structured-output/provider-failure.d.ts.map +1 -0
- package/dist/core/structured-output/provider-failure.js +28 -0
- package/dist/core/structured-output/provider-failure.js.map +1 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +13 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/shell-task-render.d.ts +1 -0
- package/dist/core/tools/shell-task-render.d.ts.map +1 -1
- package/dist/core/tools/shell-task-render.js +7 -2
- package/dist/core/tools/shell-task-render.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +5 -0
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +38 -5
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +3 -2
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +42 -14
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +2 -1
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +5 -6
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +8 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +5 -0
- package/dist/utils/ansi.js.map +1 -1
- package/docs/codemode.md +1 -1
- package/docs/intercom/reference.md +3 -3
- package/docs/models/evals.md +31 -12
- package/docs/models/reference.md +23 -51
- package/docs/models.md +3 -4
- package/docs/providers.md +5 -15
- package/docs/settings.md +1 -1
- package/docs/storage.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/workflows/api-reference.md +20 -1
- package/docs/workflows/operations.md +17 -4
- package/npm-shrinkwrap.json +64 -44
- package/package.json +4 -4
package/dist/core/tools/bash.js
CHANGED
|
@@ -14,7 +14,7 @@ import { stripLeadingCdCommand } from "./bash-leading-cd.js";
|
|
|
14
14
|
import { executeNativePty, executeSupervisedCommand, validateBashWait, waitForSupervisedCommand, } from "./bash-pty-native.js";
|
|
15
15
|
import { applyBashSessionEnvironment, snapshotBashSessionEnvironment } from "./bash-session-environment.js";
|
|
16
16
|
import { OutputAccumulator } from "./output-accumulator.js";
|
|
17
|
-
import { getTextOutput, invalidArgText, startToolTimer, str, toolTimerText, } from "./render-utils.js";
|
|
17
|
+
import { getTextOutput, invalidArgText, linkPath, startToolTimer, str, toolTimerText, } from "./render-utils.js";
|
|
18
18
|
import { expandShellInternalUrls } from "./resource-selectors.js";
|
|
19
19
|
import { invalidateNativeSearchCache } from "./search-native.js";
|
|
20
20
|
import { addShellOutputPreview, formatTruncationNotice, rebuildShellWaitResult } from "./shell-task-render.js";
|
|
@@ -238,7 +238,7 @@ function formatBashCall(args, prompt) {
|
|
|
238
238
|
const commandDisplay = command === null ? invalidArgText(theme) : command ? command : theme.fg("toolOutput", "...");
|
|
239
239
|
return theme.fg("toolTitle", theme.bold(`${prompt} ${commandDisplay}`)) + timeoutSuffix;
|
|
240
240
|
}
|
|
241
|
-
function rebuildBashResultRenderComponent(component, result, options, showImages, timerText) {
|
|
241
|
+
function rebuildBashResultRenderComponent(component, result, options, showImages, timerText, cwd) {
|
|
242
242
|
component.clear();
|
|
243
243
|
let output = getTextOutput(result, showImages).trim();
|
|
244
244
|
const observation = result.details?.observation;
|
|
@@ -261,12 +261,16 @@ function rebuildBashResultRenderComponent(component, result, options, showImages
|
|
|
261
261
|
addShellOutputPreview(component, output, options.expanded);
|
|
262
262
|
if (truncation?.truncated || fullOutputPath) {
|
|
263
263
|
const warnings = [];
|
|
264
|
-
if (fullOutputPath) {
|
|
265
|
-
warnings.push(`Full output: ${fullOutputPath}`);
|
|
266
|
-
}
|
|
267
264
|
if (truncation?.truncated)
|
|
268
265
|
warnings.push(formatTruncationNotice(truncation));
|
|
266
|
+
if (fullOutputPath)
|
|
267
|
+
warnings.push("Full output:");
|
|
269
268
|
component.addChild(new Text(`\n${theme.fg("warning", `[${warnings.join(". ")}]`)}`, 0, 0));
|
|
269
|
+
// 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
|
|
270
|
+
// path wider than the terminal still opens (and copies) whole.
|
|
271
|
+
if (fullOutputPath) {
|
|
272
|
+
component.addChild(new Text(theme.fg("warning", linkPath(fullOutputPath, fullOutputPath, cwd)), 0, 0));
|
|
273
|
+
}
|
|
270
274
|
}
|
|
271
275
|
if (timerText)
|
|
272
276
|
component.addChild(new Text(`\n${theme.fg("muted", timerText)}`, 0, 0));
|
|
@@ -560,9 +564,11 @@ export function createBashToolDefinition(cwd, options, presentation = BASH_SHELL
|
|
|
560
564
|
isError: context.isError,
|
|
561
565
|
taskId: context.args.id,
|
|
562
566
|
timerText,
|
|
567
|
+
cwd: context.cwd,
|
|
563
568
|
});
|
|
564
|
-
if (!waited)
|
|
565
|
-
rebuildBashResultRenderComponent(component, result, options, context.showImages, timerText);
|
|
569
|
+
if (!waited) {
|
|
570
|
+
rebuildBashResultRenderComponent(component, result, options, context.showImages, timerText, context.cwd);
|
|
571
|
+
}
|
|
566
572
|
component.invalidate();
|
|
567
573
|
return component;
|
|
568
574
|
},
|
|
@@ -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,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;AAI9B,OAAO,EAEN,+BAA+B,EAC/B,8BAA8B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EAGxB,gBAAgB,EAChB,wBAAwB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EAAE,iB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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 { 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\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\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 { 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},\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},\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\tconst signalCode = child.signalCode;\n\t\t\t\treturn { exitCode: exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1) };\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_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}\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): 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 (fullOutputPath) {\n\t\t\twarnings.push(`Full output: ${fullOutputPath}`);\n\t\t}\n\t\tif (truncation?.truncated) warnings.push(formatTruncationNotice(truncation));\n\t\tcomponent.addChild(new Text(`\\n${theme.fg(\"warning\", `[${warnings.join(\". \")}]`)}`, 0, 0));\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 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\tconcurrency: (args) => (args.pty === true ? \"exclusive\" : \"shared\"),\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\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 === 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});\n\t\t\tif (!waited) rebuildBashResultRenderComponent(component, result, options, context.showImages, timerText);\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;AAI9B,OAAO,EAEN,+BAA+B,EAC/B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,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 { 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\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 { 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},\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},\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\tconst signalCode = child.signalCode;\n\t\t\t\treturn { exitCode: exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1) };\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_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}\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 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\tconcurrency: (args) => (args.pty === true ? \"exclusive\" : \"shared\"),\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\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 === 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"]}
|
|
@@ -39,6 +39,7 @@ export declare function rebuildShellWaitResult(component: Container, result: She
|
|
|
39
39
|
isError: boolean;
|
|
40
40
|
taskId: string | undefined;
|
|
41
41
|
timerText: string | undefined;
|
|
42
|
+
cwd: string;
|
|
42
43
|
}): boolean;
|
|
43
44
|
export declare function formatKillCall(args: {
|
|
44
45
|
id?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-task-render.d.ts","sourceRoot":"","sources":["../../../src/core/tools/shell-task-render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,SAAS,EAAgB,MAAM,wBAAwB,CAAC;AAItE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAWxE,OAAO,EAAiC,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAErF,iFAAiF;AACjF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,KAAK,aAAa,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAiB9F,qHAAqH;AACrH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAmBnG;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAI3E;AAMD,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,CAAC,EAAE;QACT,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,UAAU,CAAC,EAAE,gBAAg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C;CACF;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,EAClD,IAAI,EAAE;IACL,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,GAAG,EAAE,MAAM,CAAC;CACZ,GACC,OAAO,CAiCT;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE;IAAE,EAAE,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAAG,MAAM,CAIzE;AAED,gHAAgH;AAChH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,OAAO,CAAC,EAAE,aAAa,CAAA;CAAE,EAC3D,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACpD,IAAI,CAoBN"}
|
|
@@ -10,7 +10,7 @@ import { Spacer, Text } from "@earendil-works/pi-tui";
|
|
|
10
10
|
import { parenthesizedKeyHint } from "../../modes/interactive/components/keybinding-hints.js";
|
|
11
11
|
import { VisualLinePreview } from "../../modes/interactive/components/visual-truncate.js";
|
|
12
12
|
import { theme } from "../../modes/interactive/theme/theme.js";
|
|
13
|
-
import { getTextOutput, invalidArgText, str } from "./render-utils.js";
|
|
13
|
+
import { getTextOutput, invalidArgText, linkPath, str } from "./render-utils.js";
|
|
14
14
|
import { cancelReceiptStatus, cleanupFailureSummary, EMPTY_OUTPUT_TEXT, presentTaskError, waitResultTail, waitStatus, } from "./shell-task-status.js";
|
|
15
15
|
import { DEFAULT_MAX_BYTES, formatSize } from "./truncate.js";
|
|
16
16
|
/** Output lines shown before a shell result collapses behind the expand hint. */
|
|
@@ -88,10 +88,15 @@ export function rebuildShellWaitResult(component, result, options, view) {
|
|
|
88
88
|
component.addChild(new Text(theme.fg("dim", EMPTY_OUTPUT_TEXT), 0, 0));
|
|
89
89
|
const notes = [
|
|
90
90
|
truncation?.truncated ? formatTruncationNotice(truncation) : undefined,
|
|
91
|
-
fullOutputPath ?
|
|
91
|
+
fullOutputPath ? "Full output:" : undefined,
|
|
92
92
|
].filter((note) => note !== undefined);
|
|
93
93
|
if (notes.length > 0)
|
|
94
94
|
component.addChild(new Text(theme.fg("dim", notes.join(" · ")), 0, 0));
|
|
95
|
+
// 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
|
|
96
|
+
// path wider than the terminal still opens (and copies) whole.
|
|
97
|
+
if (fullOutputPath) {
|
|
98
|
+
component.addChild(new Text(theme.fg("dim", linkPath(fullOutputPath, fullOutputPath, view.cwd)), 0, 0));
|
|
99
|
+
}
|
|
95
100
|
addTimer(component, view.timerText);
|
|
96
101
|
return true;
|
|
97
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-task-render.js","sourceRoot":"","sources":["../../../src/core/tools/shell-task-render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAkB,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EACN,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAEhB,cAAc,EACd,UAAU,GACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,U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AAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,OAAO;QACV,SAAS,CAAC,QAAQ,CACjB,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CACnG,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Transcript presentation for shell task results: a `wait` observation and a `kill` receipt each become one status\n * line, with the task's output (when it has any) below it. Raw observation envelopes and internal ids never appear.\n *\n * Roles follow DESIGN.md: success, error, warning and dim carry the state, `·` separates facts, and only the glyphs\n * `✓ ✗ ● ○` are used. The status reads the same without color; with `NO_COLOR` set it drops foreground color and\n * keeps the weight.\n */\nimport { type Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { VisualLinePreview } from \"../../modes/interactive/components/visual-truncate.ts\";\nimport { theme } from \"../../modes/interactive/theme/theme.js\";\nimport type { ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport type { CancelReceipt, WaitOutcome } from \"../tasks/contracts.js\";\nimport { getTextOutput, invalidArgText, str } from \"./render-utils.ts\";\nimport {\n\tcancelReceiptStatus,\n\tcleanupFailureSummary,\n\tEMPTY_OUTPUT_TEXT,\n\tpresentTaskError,\n\ttype TaskStatus,\n\twaitResultTail,\n\twaitStatus,\n} from \"./shell-task-status.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult } from \"./truncate.ts\";\n\n/** Output lines shown before a shell result collapses behind the expand hint. */\nexport const SHELL_OUTPUT_PREVIEW_LINES = 5;\n\ntype ResultContent = Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\nconst noColor = (): boolean => process.env.NO_COLOR !== undefined;\n\nfunction statusLine(status: TaskStatus): string {\n\tconst head = `${status.glyph} ${status.label}`;\n\tif (noColor()) return theme.bold(head) + (status.detail ? ` · ${status.detail}` : \"\");\n\tconst detail = status.detail ? theme.fg(\"dim\", \" · \") + theme.fg(\"muted\", status.detail) : \"\";\n\treturn theme.fg(status.tone, head) + detail;\n}\n\nfunction addErrorLines(component: Container, headline: string, hint: string | undefined): void {\n\tconst heading = `✗ ${headline}`;\n\tcomponent.addChild(new Text(noColor() ? theme.bold(heading) : theme.fg(\"error\", heading), 0, 0));\n\tif (hint) component.addChild(new Text(noColor() ? hint : theme.fg(\"dim\", hint), 0, 0));\n}\n\n/** The output block of a shell result: everything when expanded, otherwise the last few lines and an expand hint. */\nexport function addShellOutputPreview(component: Container, output: string, expanded: boolean): void {\n\tconst styledOutput = output\n\t\t.split(\"\\n\")\n\t\t.map((line) => theme.fg(\"toolOutput\", line))\n\t\t.join(\"\\n\");\n\tif (expanded) {\n\t\tcomponent.addChild(new Text(`\\n${styledOutput}`, 0, 0));\n\t\treturn;\n\t}\n\tcomponent.addChild(new Spacer(1));\n\tcomponent.addChild(\n\t\tnew VisualLinePreview({\n\t\t\ttext: styledOutput,\n\t\t\tmaxVisualLines: SHELL_OUTPUT_PREVIEW_LINES,\n\t\t\tkeep: \"end\",\n\t\t\tformatHint: (hidden) =>\n\t\t\t\ttheme.fg(\"muted\", \"... \") + parenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${hidden} earlier lines`),\n\t\t}),\n\t);\n}\n\nexport function formatTruncationNotice(truncation: TruncationResult): string {\n\treturn truncation.truncatedBy === \"lines\"\n\t\t? `Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines`\n\t\t: `Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)`;\n}\n\nfunction addTimer(component: Container, timerText: string | undefined): void {\n\tif (timerText) component.addChild(new Text(`\\n${theme.fg(\"muted\", timerText)}`, 0, 0));\n}\n\nexport interface ShellWaitResultView {\n\tcontent: ResultContent;\n\tdetails?: {\n\t\tobservation?: WaitOutcome;\n\t\ttruncation?: TruncationResult;\n\t\tfullOutputPath?: string;\n\t};\n}\n\n/**\n * Rebuild the row of a `wait` result: status line, output, a dim note when the output was cut short, then the timer.\n * An error that is not a task failure, or a result without an observation, is left to the generic shell renderer;\n * the return value says whether this renderer handled the result.\n */\nexport function rebuildShellWaitResult(\n\tcomponent: Container,\n\tresult: ShellWaitResultView,\n\toptions: Pick<ToolRenderResultOptions, \"expanded\">,\n\tview: { showImages: boolean; isError: boolean; taskId: string | undefined; timerText: string | undefined },\n): boolean {\n\tconst text = getTextOutput(result, view.showImages).trim();\n\tif (view.isError) {\n\t\tconst error = presentTaskError(text, view.taskId);\n\t\tif (!error) return false;\n\t\tcomponent.clear();\n\t\taddErrorLines(component, error.headline, error.hint);\n\t\taddTimer(component, view.timerText);\n\t\treturn true;\n\t}\n\tconst observation = result.details?.observation;\n\tif (!observation) return false;\n\tconst truncation = result.details?.truncation;\n\tconst fullOutputPath = result.details?.fullOutputPath;\n\tconst tail = waitResultTail({ observation, truncated: truncation?.truncated === true, fullOutputPath });\n\tconst output = (text.endsWith(tail) ? text.slice(0, -tail.length) : text).trim();\n\tconst hasOutput = output !== \"\" && output !== EMPTY_OUTPUT_TEXT;\n\tcomponent.clear();\n\tcomponent.addChild(new Text(statusLine(waitStatus(observation, hasOutput)), 0, 0));\n\tif (hasOutput) addShellOutputPreview(component, output, options.expanded);\n\telse component.addChild(new Text(theme.fg(\"dim\", EMPTY_OUTPUT_TEXT), 0, 0));\n\tconst notes = [\n\t\ttruncation?.truncated ? formatTruncationNotice(truncation) : undefined,\n\t\tfullOutputPath ? `Full output: ${fullOutputPath}` : undefined,\n\t].filter((note) => note !== undefined);\n\tif (notes.length > 0) component.addChild(new Text(theme.fg(\"dim\", notes.join(\" · \")), 0, 0));\n\taddTimer(component, view.timerText);\n\treturn true;\n}\n\nexport function formatKillCall(args: { id?: unknown } | undefined): string {\n\tconst id = str(args?.id);\n\tconst target = id === null ? invalidArgText(theme) : id || theme.fg(\"toolOutput\", \"...\");\n\treturn theme.fg(\"toolTitle\", theme.bold(`kill ${target}`));\n}\n\n/** Rebuild the row of a `kill` result from its receipt, or from the failure text when the call was rejected. */\nexport function rebuildKillResult(\n\tcomponent: Container,\n\tresult: { content: ResultContent; details?: CancelReceipt },\n\tview: { isError: boolean; taskId: string | undefined },\n): void {\n\tcomponent.clear();\n\tconst text = getTextOutput(result, false).trim();\n\tconst error = view.isError ? presentTaskError(text, view.taskId) : undefined;\n\tif (error) {\n\t\taddErrorLines(component, error.headline, error.hint);\n\t\treturn;\n\t}\n\tconst receipt = result.details;\n\t// A rejected call carries empty details, so only a real receipt has an execution to describe.\n\tif (!receipt?.execution) {\n\t\tcomponent.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\t\treturn;\n\t}\n\tcomponent.addChild(new Text(statusLine(cancelReceiptStatus(receipt)), 0, 0));\n\tconst failure = cleanupFailureSummary(receipt.cleanup);\n\tif (failure)\n\t\tcomponent.addChild(\n\t\t\tnew Text(statusLine({ glyph: \"✗\", tone: \"error\", label: \"cleanup failed\", detail: failure }), 0, 0),\n\t\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shell-task-render.js","sourceRoot":"","sources":["../../../src/core/tools/shell-task-render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAkB,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EACN,mBAAm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ACrD,OAAO;IACR,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,8FAA8F;IAC9F,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC;QACzB,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACjE,OAAO;IACR,CAAC;IACD,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,OAAO;QACV,SAAS,CAAC,QAAQ,CACjB,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CACnG,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Transcript presentation for shell task results: a `wait` observation and a `kill` receipt each become one status\n * line, with the task's output (when it has any) below it. Raw observation envelopes and internal ids never appear.\n *\n * Roles follow DESIGN.md: success, error, warning and dim carry the state, `·` separates facts, and only the glyphs\n * `✓ ✗ ● ○` are used. The status reads the same without color; with `NO_COLOR` set it drops foreground color and\n * keeps the weight.\n */\nimport { type Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { VisualLinePreview } from \"../../modes/interactive/components/visual-truncate.ts\";\nimport { theme } from \"../../modes/interactive/theme/theme.js\";\nimport type { ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport type { CancelReceipt, WaitOutcome } from \"../tasks/contracts.js\";\nimport { getTextOutput, invalidArgText, linkPath, str } from \"./render-utils.ts\";\nimport {\n\tcancelReceiptStatus,\n\tcleanupFailureSummary,\n\tEMPTY_OUTPUT_TEXT,\n\tpresentTaskError,\n\ttype TaskStatus,\n\twaitResultTail,\n\twaitStatus,\n} from \"./shell-task-status.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult } from \"./truncate.ts\";\n\n/** Output lines shown before a shell result collapses behind the expand hint. */\nexport const SHELL_OUTPUT_PREVIEW_LINES = 5;\n\ntype ResultContent = Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\nconst noColor = (): boolean => process.env.NO_COLOR !== undefined;\n\nfunction statusLine(status: TaskStatus): string {\n\tconst head = `${status.glyph} ${status.label}`;\n\tif (noColor()) return theme.bold(head) + (status.detail ? ` · ${status.detail}` : \"\");\n\tconst detail = status.detail ? theme.fg(\"dim\", \" · \") + theme.fg(\"muted\", status.detail) : \"\";\n\treturn theme.fg(status.tone, head) + detail;\n}\n\nfunction addErrorLines(component: Container, headline: string, hint: string | undefined): void {\n\tconst heading = `✗ ${headline}`;\n\tcomponent.addChild(new Text(noColor() ? theme.bold(heading) : theme.fg(\"error\", heading), 0, 0));\n\tif (hint) component.addChild(new Text(noColor() ? hint : theme.fg(\"dim\", hint), 0, 0));\n}\n\n/** The output block of a shell result: everything when expanded, otherwise the last few lines and an expand hint. */\nexport function addShellOutputPreview(component: Container, output: string, expanded: boolean): void {\n\tconst styledOutput = output\n\t\t.split(\"\\n\")\n\t\t.map((line) => theme.fg(\"toolOutput\", line))\n\t\t.join(\"\\n\");\n\tif (expanded) {\n\t\tcomponent.addChild(new Text(`\\n${styledOutput}`, 0, 0));\n\t\treturn;\n\t}\n\tcomponent.addChild(new Spacer(1));\n\tcomponent.addChild(\n\t\tnew VisualLinePreview({\n\t\t\ttext: styledOutput,\n\t\t\tmaxVisualLines: SHELL_OUTPUT_PREVIEW_LINES,\n\t\t\tkeep: \"end\",\n\t\t\tformatHint: (hidden) =>\n\t\t\t\ttheme.fg(\"muted\", \"... \") + parenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${hidden} earlier lines`),\n\t\t}),\n\t);\n}\n\nexport function formatTruncationNotice(truncation: TruncationResult): string {\n\treturn truncation.truncatedBy === \"lines\"\n\t\t? `Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines`\n\t\t: `Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)`;\n}\n\nfunction addTimer(component: Container, timerText: string | undefined): void {\n\tif (timerText) component.addChild(new Text(`\\n${theme.fg(\"muted\", timerText)}`, 0, 0));\n}\n\nexport interface ShellWaitResultView {\n\tcontent: ResultContent;\n\tdetails?: {\n\t\tobservation?: WaitOutcome;\n\t\ttruncation?: TruncationResult;\n\t\tfullOutputPath?: string;\n\t};\n}\n\n/**\n * Rebuild the row of a `wait` result: status line, output, a dim note when the output was cut short, then the timer.\n * An error that is not a task failure, or a result without an observation, is left to the generic shell renderer;\n * the return value says whether this renderer handled the result.\n */\nexport function rebuildShellWaitResult(\n\tcomponent: Container,\n\tresult: ShellWaitResultView,\n\toptions: Pick<ToolRenderResultOptions, \"expanded\">,\n\tview: {\n\t\tshowImages: boolean;\n\t\tisError: boolean;\n\t\ttaskId: string | undefined;\n\t\ttimerText: string | undefined;\n\t\tcwd: string;\n\t},\n): boolean {\n\tconst text = getTextOutput(result, view.showImages).trim();\n\tif (view.isError) {\n\t\tconst error = presentTaskError(text, view.taskId);\n\t\tif (!error) return false;\n\t\tcomponent.clear();\n\t\taddErrorLines(component, error.headline, error.hint);\n\t\taddTimer(component, view.timerText);\n\t\treturn true;\n\t}\n\tconst observation = result.details?.observation;\n\tif (!observation) return false;\n\tconst truncation = result.details?.truncation;\n\tconst fullOutputPath = result.details?.fullOutputPath;\n\tconst tail = waitResultTail({ observation, truncated: truncation?.truncated === true, fullOutputPath });\n\tconst output = (text.endsWith(tail) ? text.slice(0, -tail.length) : text).trim();\n\tconst hasOutput = output !== \"\" && output !== EMPTY_OUTPUT_TEXT;\n\tcomponent.clear();\n\tcomponent.addChild(new Text(statusLine(waitStatus(observation, hasOutput)), 0, 0));\n\tif (hasOutput) addShellOutputPreview(component, output, options.expanded);\n\telse component.addChild(new Text(theme.fg(\"dim\", EMPTY_OUTPUT_TEXT), 0, 0));\n\tconst notes = [\n\t\ttruncation?.truncated ? formatTruncationNotice(truncation) : undefined,\n\t\tfullOutputPath ? \"Full output:\" : undefined,\n\t].filter((note) => note !== undefined);\n\tif (notes.length > 0) component.addChild(new Text(theme.fg(\"dim\", notes.join(\" · \")), 0, 0));\n\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// path wider than the terminal still opens (and copies) whole.\n\tif (fullOutputPath) {\n\t\tcomponent.addChild(new Text(theme.fg(\"dim\", linkPath(fullOutputPath, fullOutputPath, view.cwd)), 0, 0));\n\t}\n\taddTimer(component, view.timerText);\n\treturn true;\n}\n\nexport function formatKillCall(args: { id?: unknown } | undefined): string {\n\tconst id = str(args?.id);\n\tconst target = id === null ? invalidArgText(theme) : id || theme.fg(\"toolOutput\", \"...\");\n\treturn theme.fg(\"toolTitle\", theme.bold(`kill ${target}`));\n}\n\n/** Rebuild the row of a `kill` result from its receipt, or from the failure text when the call was rejected. */\nexport function rebuildKillResult(\n\tcomponent: Container,\n\tresult: { content: ResultContent; details?: CancelReceipt },\n\tview: { isError: boolean; taskId: string | undefined },\n): void {\n\tcomponent.clear();\n\tconst text = getTextOutput(result, false).trim();\n\tconst error = view.isError ? presentTaskError(text, view.taskId) : undefined;\n\tif (error) {\n\t\taddErrorLines(component, error.headline, error.hint);\n\t\treturn;\n\t}\n\tconst receipt = result.details;\n\t// A rejected call carries empty details, so only a real receipt has an execution to describe.\n\tif (!receipt?.execution) {\n\t\tcomponent.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\t\treturn;\n\t}\n\tcomponent.addChild(new Text(statusLine(cancelReceiptStatus(receipt)), 0, 0));\n\tconst failure = cleanupFailureSummary(receipt.cleanup);\n\tif (failure)\n\t\tcomponent.addChild(\n\t\t\tnew Text(statusLine({ glyph: \"✗\", tone: \"error\", label: \"cleanup failed\", detail: failure }), 0, 0),\n\t\t);\n}\n"]}
|
|
@@ -15,6 +15,11 @@ export interface ToolRanker {
|
|
|
15
15
|
}
|
|
16
16
|
export declare function tokenize(text: string): string[];
|
|
17
17
|
export declare function createToolSearchDocument(tool: Pick<ToolInfo, "name" | "description" | "parameters">, namespace?: ToolNamespace): ToolSearchDocument;
|
|
18
|
+
/**
|
|
19
|
+
* Okapi BM25 with the usual parameters. A query that names a tool ranks that tool first, because
|
|
20
|
+
* length normalization can otherwise rank a short description sharing the name's words above it.
|
|
21
|
+
* Ties keep document order.
|
|
22
|
+
*/
|
|
18
23
|
export declare class Bm25Ranker implements ToolRanker {
|
|
19
24
|
private readonly k1;
|
|
20
25
|
private readonly b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/extensions/tool-search/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE5G,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AACnD,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AACD,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,UAAU;IAC1B,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,kBAAkB,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,eA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AS;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAS;IAC3B,YAAY,OAAO,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAA;KAAO,EAGpD;IACD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,kBAAkB,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE,CA0C9F;CACD;AACD,eAAO,MAAM,gBAAgB;;;EAA6E,CAAC;AAC3G,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC9D,MAAM,WAAW,qBAAqB;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AACD,MAAM,WAAW,qBAAqB;IACrC,KAAK,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC,CAAC;CAChF;AACD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAAC,GAAG,OAAO,CAErF;AACD,wBAAgB,2BAA2B,CAAC,QAAQ,GAAE,SAAS,aAAa,EAAO,GAAG,MAAM,CAE3F;AACD,wBAAgB,8BAA8B,CAC7C,OAAO,GAAE,qBAA0B,GACjC,cAAc,CAAC,OAAO,gBAAgB,EAAE,qBAAqB,CAAC,CAsChE"}
|
|
@@ -68,6 +68,26 @@ export function createToolSearchDocument(tool, namespace) {
|
|
|
68
68
|
parts.push(namespace.name, namespace.description ?? "", namespace.instructions ?? "");
|
|
69
69
|
return { name: tool.name, text: parts.filter((part) => part.trim()).join(" ") };
|
|
70
70
|
}
|
|
71
|
+
/** Lowercase with characters invalid in script identifiers as `_`, so `dev-radius` matches `dev_radius`. */
|
|
72
|
+
function normalizeName(name) {
|
|
73
|
+
return name
|
|
74
|
+
.trim()
|
|
75
|
+
.toLowerCase()
|
|
76
|
+
.replace(/[^a-z0-9_$]/g, "_");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether `query` names the tool: its full name or a suffix after a `__` separator, so `thread_read`
|
|
80
|
+
* and `app__thread_read` both name `mcp__app__thread_read`.
|
|
81
|
+
*/
|
|
82
|
+
function isNameQuery(query, name) {
|
|
83
|
+
const normalized = normalizeName(name);
|
|
84
|
+
return normalized === query || normalized.endsWith(`__${query}`);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Okapi BM25 with the usual parameters. A query that names a tool ranks that tool first, because
|
|
88
|
+
* length normalization can otherwise rank a short description sharing the name's words above it.
|
|
89
|
+
* Ties keep document order.
|
|
90
|
+
*/
|
|
71
91
|
export class Bm25Ranker {
|
|
72
92
|
k1;
|
|
73
93
|
b;
|
|
@@ -76,9 +96,17 @@ export class Bm25Ranker {
|
|
|
76
96
|
this.b = options.b ?? 0.75;
|
|
77
97
|
}
|
|
78
98
|
rank(query, documents, limit) {
|
|
79
|
-
|
|
80
|
-
if (!terms.length || !documents.length || limit <= 0)
|
|
99
|
+
if (!documents.length || limit <= 0)
|
|
81
100
|
return [];
|
|
101
|
+
const terms = [...new Set(tokenize(query))];
|
|
102
|
+
// A query made only of stop words has no BM25 terms, but can still name a tool exactly (`is`).
|
|
103
|
+
if (!terms.length) {
|
|
104
|
+
const nameQuery = normalizeName(query);
|
|
105
|
+
return documents
|
|
106
|
+
.filter((document) => isNameQuery(nameQuery, document.name))
|
|
107
|
+
.slice(0, limit)
|
|
108
|
+
.map((document) => ({ name: document.name, score: 0 }));
|
|
109
|
+
}
|
|
82
110
|
const counts = documents.map((document) => {
|
|
83
111
|
const result = new Map();
|
|
84
112
|
for (const term of tokenize(document.text))
|
|
@@ -91,6 +119,7 @@ export class Bm25Ranker {
|
|
|
91
119
|
const frequency = counts.filter((count) => count.has(term)).length;
|
|
92
120
|
return [term, Math.log(1 + (documents.length - frequency + 0.5) / (frequency + 0.5))];
|
|
93
121
|
}));
|
|
122
|
+
const nameQuery = normalizeName(query);
|
|
94
123
|
return documents
|
|
95
124
|
.flatMap((document, index) => {
|
|
96
125
|
let score = 0;
|
|
@@ -101,10 +130,14 @@ export class Bm25Ranker {
|
|
|
101
130
|
const norm = this.k1 * (1 - this.b + (this.b * lengths[index]) / average);
|
|
102
131
|
score += ((idf.get(term) ?? 0) * count * (this.k1 + 1)) / (count + norm);
|
|
103
132
|
}
|
|
104
|
-
|
|
133
|
+
// A query naming the tool keeps it even when tokenization shares no term with it (`readthread`
|
|
134
|
+
// for `readThread`).
|
|
135
|
+
const named = isNameQuery(nameQuery, document.name);
|
|
136
|
+
return score > 0 || named ? [{ name: document.name, score, named }] : [];
|
|
105
137
|
})
|
|
106
|
-
.sort((a, b) => b.score - a.score)
|
|
107
|
-
.slice(0, limit)
|
|
138
|
+
.sort((a, b) => Number(b.named) - Number(a.named) || b.score - a.score)
|
|
139
|
+
.slice(0, limit)
|
|
140
|
+
.map(({ name, score }) => ({ name, score }));
|
|
108
141
|
}
|
|
109
142
|
}
|
|
110
143
|
export const toolSearchSchema = Type.Object({ query: Type.String(), limit: Type.Optional(Type.Number()) });
|