@bastani/atomic 0.9.19-alpha.5 → 0.9.19-alpha.6
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 +26 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/client.ts +19 -1
- package/dist/builtin/intercom/index.bundle.mjs +8 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/README.md +3 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +7 -7
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +2 -1
- package/dist/builtin/web-access/CHANGELOG.md +7 -0
- package/dist/builtin/web-access/README.md +31 -24
- package/dist/builtin/web-access/index.bundle.mjs +16099 -77
- package/dist/builtin/web-access/package.json +2 -1
- package/dist/builtin/workflows/CHANGELOG.md +6 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +31 -2
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +10 -0
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -2
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +91 -12
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.d.ts +255 -0
- package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-coordinator.js +300 -0
- package/dist/core/tools/file-mutation-coordinator.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +14 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +15 -3
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/hashline.d.ts +9 -0
- package/dist/core/tools/hashline.d.ts.map +1 -1
- package/dist/core/tools/hashline.js +12 -1
- package/dist/core/tools/hashline.js.map +1 -1
- package/dist/core/tools/index.d.ts +9 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +67 -12
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/non-minting-snapshot-store.d.ts +49 -0
- package/dist/core/tools/non-minting-snapshot-store.d.ts.map +1 -0
- package/dist/core/tools/non-minting-snapshot-store.js +64 -0
- package/dist/core/tools/non-minting-snapshot-store.js.map +1 -0
- package/dist/core/tools/powershell.d.ts +2 -2
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +2 -5
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/read-document-extract.js.map +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/write.d.ts +30 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +97 -8
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +3 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +28 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +3 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +2 -2
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts +3 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.js +11 -0
- package/dist/modes/interactive-engine/engine-diagnostic-view.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +2 -1
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +2 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +23 -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 +20 -3
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/utils/markit.d.ts +2 -0
- package/dist/utils/markit.d.ts.map +1 -1
- package/dist/utils/markit.js +65 -5
- package/dist/utils/markit.js.map +1 -1
- package/docs/background-tasks.md +14 -10
- package/docs/containerization.md +7 -5
- package/docs/development.md +11 -0
- package/docs/docs.json +1 -0
- package/docs/subagents.md +3 -1
- package/docs/tools.md +26 -0
- package/docs/web-access.md +38 -0
- package/examples/extensions/gondolin/index.ts +116 -148
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/ssh.ts +56 -34
- package/npm-shrinkwrap.json +33 -33
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/web-access",
|
|
3
|
-
"version": "0.9.19-alpha.
|
|
3
|
+
"version": "0.9.19-alpha.6",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
|
|
6
6
|
"contributors": [
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
45
46
|
"@mozilla/readability": "^0.6.0",
|
|
46
47
|
"linkedom": "^0.18.13",
|
|
47
48
|
"p-limit": "^7.3.1",
|
|
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.9.19-alpha.6] - 2026-09-11
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Workflow stage routes are no longer republished to the broker when nothing about the route changed. Every store invalidation — including tool events, attachment changes, and notices that leave the route projection identical — previously re-announced every run, so a burst of unrelated activity could produce a thousand redundant broker round trips and surface as `Intercom event relay failed (atomic:workflow-pending-stage-route): List sessions timeout`. Genuine changes still publish immediately and are never debounced, and an announcement that is rejected or that no consumer acknowledges is retried on the next invalidation.
|
|
14
|
+
|
|
9
15
|
## [0.9.19-alpha.5] - 2026-09-11
|
|
10
16
|
|
|
11
17
|
### Changed
|
|
@@ -112462,21 +112462,24 @@ function registerPendingStageIntercomBridge(pi, activeStore) {
|
|
|
112462
112462
|
pi.events?.emit?.(PENDING_STAGE_UNDELIVERABLE_EVENT, payload);
|
|
112463
112463
|
return payload.handled && await payload.completion === true;
|
|
112464
112464
|
};
|
|
112465
|
+
const announcedRoutes = new Map;
|
|
112465
112466
|
const announceRoutes = () => {
|
|
112466
112467
|
if (disposed)
|
|
112467
112468
|
return;
|
|
112469
|
+
const ownedRunIds = new Set;
|
|
112468
112470
|
const runs = activeStore.runs();
|
|
112469
112471
|
for (const run of runs) {
|
|
112470
112472
|
const rootRunId = durableRootRunIdForRun(runs, run.id);
|
|
112471
112473
|
if (rootRunId === undefined)
|
|
112472
112474
|
continue;
|
|
112475
|
+
ownedRunIds.add(run.id);
|
|
112473
112476
|
const parentRun = runs.find((candidate) => candidate.id === run.parentRunId);
|
|
112474
112477
|
const boundary = parentRun?.stages.find((stage) => stage.id === run.parentStageId);
|
|
112475
112478
|
const parent = parentRun === undefined || boundary === undefined ? undefined : {
|
|
112476
112479
|
runId: parentRun.id,
|
|
112477
112480
|
stageKeys: [boundary.id, boundary.name].filter((key) => resolveChildRun(runs, parentRun, key)?.id === run.id)
|
|
112478
112481
|
};
|
|
112479
|
-
|
|
112482
|
+
const announcement = {
|
|
112480
112483
|
runId: run.id,
|
|
112481
112484
|
group: workflowInvocationIntercomGroup(rootRunId),
|
|
112482
112485
|
capability: workflowPendingStageRouteCapability(activeStore, run.id),
|
|
@@ -112501,7 +112504,32 @@ function registerPendingStageIntercomBridge(pi, activeStore) {
|
|
|
112501
112504
|
}))
|
|
112502
112505
|
],
|
|
112503
112506
|
...run.id === rootRunId ? { possibleStages: possibleStageRows(runs, rootRunId, run) } : {}
|
|
112504
|
-
}
|
|
112507
|
+
};
|
|
112508
|
+
const signature = JSON.stringify(announcement);
|
|
112509
|
+
if (announcedRoutes.get(run.id)?.signature === signature)
|
|
112510
|
+
continue;
|
|
112511
|
+
const entry = { signature };
|
|
112512
|
+
announcedRoutes.set(run.id, entry);
|
|
112513
|
+
try {
|
|
112514
|
+
pi.events?.emit?.(PENDING_STAGE_ROUTE_EVENT, announcement);
|
|
112515
|
+
} catch (error) {
|
|
112516
|
+
if (announcedRoutes.get(run.id) === entry)
|
|
112517
|
+
announcedRoutes.delete(run.id);
|
|
112518
|
+
throw error;
|
|
112519
|
+
}
|
|
112520
|
+
const completion = announcement.completion;
|
|
112521
|
+
if (completion === undefined) {
|
|
112522
|
+
announcedRoutes.delete(run.id);
|
|
112523
|
+
} else {
|
|
112524
|
+
completion.catch(() => {
|
|
112525
|
+
if (announcedRoutes.get(run.id) === entry)
|
|
112526
|
+
announcedRoutes.delete(run.id);
|
|
112527
|
+
});
|
|
112528
|
+
}
|
|
112529
|
+
}
|
|
112530
|
+
for (const runId of announcedRoutes.keys()) {
|
|
112531
|
+
if (!ownedRunIds.has(runId))
|
|
112532
|
+
announcedRoutes.delete(runId);
|
|
112505
112533
|
}
|
|
112506
112534
|
sweepPromise = sweepPromise.then(() => settleUndeliverablePendingStageMessages(activeStore, notifyUndeliverable)).then(() => {
|
|
112507
112535
|
return;
|
|
@@ -112586,6 +112614,7 @@ function registerPendingStageIntercomBridge(pi, activeStore) {
|
|
|
112586
112614
|
subscription();
|
|
112587
112615
|
if (typeof stickySubscription === "function")
|
|
112588
112616
|
stickySubscription();
|
|
112617
|
+
announcedRoutes.clear();
|
|
112589
112618
|
};
|
|
112590
112619
|
pi.on?.("session_shutdown", dispose);
|
|
112591
112620
|
return dispose;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-tool-registry.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-tool-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-session-tool-registry.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-tool-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAa9F,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,wBAAwB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1E,IAAI,CAuGN;AAED,wBAAgB,aAAa,CAC5B,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE;IACR,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;IAC3C,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GACC,IAAI,CA+HN;AAED,eAAO,MAAM,+BAA+B;;;CAG3C,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { isMandatoryRuntimeTool, isTrustedMandatoryRuntimeTool } from "./mandato
|
|
|
3
3
|
import { ModelRegistry } from "./model-registry.js";
|
|
4
4
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
5
5
|
import { createLocalBashOperations } from "./tools/bash.js";
|
|
6
|
+
import { buildMutationRequester } from "./tools/file-mutation-coordinator.js";
|
|
6
7
|
import { createAllToolDefinitions, getDefaultToolNames } from "./tools/index.js";
|
|
7
8
|
import { createLocalPowerShellOperations } from "./tools/powershell.js";
|
|
8
9
|
import { resolveSessionTempDirPath } from "./tools/session-temp-dir.js";
|
|
@@ -119,6 +120,15 @@ export function _buildRuntime(options) {
|
|
|
119
120
|
createToolDefinitionFromAgentTool(tool),
|
|
120
121
|
]))
|
|
121
122
|
: createAllToolDefinitions(this._cwd, {
|
|
123
|
+
// Resolved per execution for the same reason as `sessionTempDir` below: a
|
|
124
|
+
// requester captured at construction would keep a stale session id across
|
|
125
|
+
// fork/branch/resume, which is exactly the relaunch this makes legible.
|
|
126
|
+
resolveMutationRequester: (toolCallId) => buildMutationRequester({
|
|
127
|
+
sessionId: this.sessionManager.getSessionId(),
|
|
128
|
+
...(this._orchestrationContext ? { orchestration: this._orchestrationContext } : {}),
|
|
129
|
+
...(this._subagentPolicy?.intercom ? { intercom: this._subagentPolicy.intercom } : {}),
|
|
130
|
+
toolCallId,
|
|
131
|
+
}),
|
|
122
132
|
read: { autoResizeImages },
|
|
123
133
|
bash: {
|
|
124
134
|
commandPrefix: shellCommandPrefix,
|
|
@@ -1 +1 @@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AC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB;QACrD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC;QACtC,CAAC,CAAC,CAAC,GAAG,mBAAmB,EAAE,CAAC,CAAC;IAC9B,MAAM,mBAAmB,GAAG,OAAO,CAAC,eAAe,IAAI,sBAAsB,CAAC;IAC9E,IAAI,CAAC,oBAAoB,CAAC;QACzB,eAAe,EAAE,mBAAmB;QACpC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;KAC1D,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,oBAAoB;IACpB,aAAa;CACb,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { ToolDefinitionEntry } from \"./agent-session-types.ts\";\nimport { ExtensionRunner, type ToolDefinition, wrapRegisteredTools } from \"./extensions/index.js\";\nimport { isMandatoryRuntimeTool, isTrustedMandatoryRuntimeTool } from \"./mandatory-runtime-tools.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { createSyntheticSourceInfo } from \"./source-info.ts\";\nimport { createLocalBashOperations } from \"./tools/bash.js\";\nimport { createAllToolDefinitions, getDefaultToolNames } from \"./tools/index.ts\";\nimport { createLocalPowerShellOperations } from \"./tools/powershell.ts\";\nimport { resolveSessionTempDirPath } from \"./tools/session-temp-dir.ts\";\nimport { createToolDefinitionFromAgentTool } from \"./tools/tool-definition-wrapper.ts\";\n\nexport function _refreshToolRegistry(\n\tthis: AgentSession,\n\toptions?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean },\n): void {\n\tconst previousRegistryNames = new Set(this._toolRegistry.keys());\n\tconst previousActiveToolNames = this.getActiveToolNames();\n\tconst allowedToolNames = this._allowedToolNames;\n\tconst excludedToolNames = this._excludedToolNames;\n\tconst isExposedTool = (name: string): boolean => {\n\t\tif (isMandatoryRuntimeTool(name)) return true;\n\t\tif (allowedToolNames && !allowedToolNames.has(name)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (excludedToolNames?.has(name)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t};\n\n\tconst registeredTools = this._extensionRunner\n\t\t.getAllRegisteredTools()\n\t\t.filter((tool) => !isMandatoryRuntimeTool(tool.definition.name) || isTrustedMandatoryRuntimeTool(tool));\n\tconst allCustomTools = [\n\t\t...registeredTools,\n\t\t...this._customTools\n\t\t\t.filter((definition) => !isMandatoryRuntimeTool(definition.name))\n\t\t\t.map((definition) => ({\n\t\t\t\tdefinition,\n\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: \"sdk\" }),\n\t\t\t})),\n\t].filter((tool) => isExposedTool(tool.definition.name));\n\tconst definitionRegistry = new Map<string, ToolDefinitionEntry>(\n\t\tArray.from(this._baseToolDefinitions.entries())\n\t\t\t.filter(([name]) => isExposedTool(name))\n\t\t\t.map(([name, definition]) => [\n\t\t\t\tname,\n\t\t\t\t{\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${name}>`, { source: \"builtin\" }),\n\t\t\t\t},\n\t\t\t]),\n\t);\n\tfor (const tool of allCustomTools) {\n\t\tdefinitionRegistry.set(tool.definition.name, {\n\t\t\tdefinition: tool.definition,\n\t\t\tsourceInfo: tool.sourceInfo,\n\t\t});\n\t}\n\tthis._toolDefinitions = definitionRegistry;\n\tthis._toolPromptSnippets = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst snippet = this._normalizePromptSnippet(definition.promptSnippet);\n\t\t\t\treturn snippet ? ([definition.name, snippet] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string] => entry !== undefined),\n\t);\n\tthis._toolPromptGuidelines = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst guidelines = this._normalizePromptGuidelines(definition.promptGuidelines);\n\t\t\t\treturn guidelines.length > 0 ? ([definition.name, guidelines] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string[]] => entry !== undefined),\n\t);\n\tconst runner = this._extensionRunner;\n\tconst wrappedExtensionTools = wrapRegisteredTools(allCustomTools, runner);\n\tconst wrappedBuiltInTools = wrapRegisteredTools(\n\t\tArray.from(this._baseToolDefinitions.values())\n\t\t\t.filter((definition) => isExposedTool(definition.name))\n\t\t\t.map((definition) => ({\n\t\t\t\tdefinition,\n\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${definition.name}>`, { source: \"builtin\" }),\n\t\t\t})),\n\t\trunner,\n\t);\n\n\tconst toolRegistry = new Map(wrappedBuiltInTools.map((tool) => [tool.name, tool]));\n\tfor (const tool of wrappedExtensionTools as AgentTool[]) {\n\t\ttoolRegistry.set(tool.name, tool);\n\t}\n\tthis._toolRegistry = toolRegistry;\n\n\tconst nextActiveToolNames = (\n\t\toptions?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]\n\t).filter((name) => isExposedTool(name));\n\n\tif (allowedToolNames) {\n\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\tif (allowedToolNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t} else if (options?.includeAllExtensionTools) {\n\t\tfor (const tool of wrappedExtensionTools) {\n\t\t\tnextActiveToolNames.push(tool.name);\n\t\t}\n\t} else if (!options?.activeToolNames) {\n\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\tif (!previousRegistryNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t}\n\n\tthis.setActiveToolsByName([...new Set(nextActiveToolNames)]);\n}\n\nexport function _buildRuntime(\n\tthis: AgentSession,\n\toptions: {\n\t\tactiveToolNames?: string[];\n\t\tflagValues?: Map<string, boolean | string>;\n\t\tincludeAllExtensionTools?: boolean;\n\t\tpreserveRunner?: boolean;\n\t},\n): void {\n\tconst autoResizeImages = this.settingsManager.getImageAutoResize();\n\tconst shellCommandPrefix = this.settingsManager.getShellCommandPrefix();\n\tconst shellPath = this.settingsManager.getShellPath();\n\tconst isAllowedBuiltinTool = (name: string): boolean => {\n\t\tif (this._allowedToolNames && !this._allowedToolNames.has(name)) return false;\n\t\tif (this._excludedToolNames?.has(name)) return false;\n\t\treturn true;\n\t};\n\tconst activeBuiltinTools = (options.activeToolNames ?? [...getDefaultToolNames()]).filter(isAllowedBuiltinTool);\n\t// Resolve ownership per call, just like command execution. Each wait receives\n\t// a stable binding so observation cleanup can finish after session disposal.\n\tconst getTaskOwner = () =>\n\t\tthis._subagentPolicy?.depth && this._subagentPolicy.depth >= 1 ? undefined : this.getAgentTaskHost().ownerBinding;\n\tconst baseToolDefinitions = this._baseToolsOverride\n\t\t? Object.fromEntries(\n\t\t\t\tObject.entries(this._baseToolsOverride).map(([name, tool]) => [\n\t\t\t\t\tname,\n\t\t\t\t\tcreateToolDefinitionFromAgentTool(tool),\n\t\t\t\t]),\n\t\t\t)\n\t\t: createAllToolDefinitions(this._cwd, {\n\t\t\t\tread: { autoResizeImages },\n\t\t\t\tbash: {\n\t\t\t\t\tcommandPrefix: shellCommandPrefix,\n\t\t\t\t\tshellPath,\n\t\t\t\t\tget taskOwner() {\n\t\t\t\t\t\treturn getTaskOwner();\n\t\t\t\t\t},\n\t\t\t\t\t...(!(this._subagentPolicy?.depth && this._subagentPolicy.depth >= 1)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\toperations: {\n\t\t\t\t\t\t\t\t\texec: (command, cwd, options) =>\n\t\t\t\t\t\t\t\t\t\tcreateLocalBashOperations({\n\t\t\t\t\t\t\t\t\t\t\tshellPath,\n\t\t\t\t\t\t\t\t\t\t\ttaskOwner: this.getAgentTaskHost().ownerBinding,\n\t\t\t\t\t\t\t\t\t\t}).exec(command, cwd, options),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tinterceptorEnabled: () => this.settingsManager.getBashInterceptorEnabled(),\n\t\t\t\t\tavailableTools: activeBuiltinTools,\n\t\t\t\t\t// Resolved per execution so bash spill files follow the live\n\t\t\t\t\t// transcript session across fork/branch/resume.\n\t\t\t\t\tsessionTempDir: () => resolveSessionTempDirPath(this.sessionManager.getSessionId()),\n\t\t\t\t\tinterceptor: async (context) => {\n\t\t\t\t\t\tconst result = await this._extensionRunner.emitUserBash({\n\t\t\t\t\t\t\ttype: \"user_bash\",\n\t\t\t\t\t\t\tcommand: context.command,\n\t\t\t\t\t\t\texcludeFromContext: false,\n\t\t\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tpowershell: {\n\t\t\t\t\tget taskOwner() {\n\t\t\t\t\t\treturn getTaskOwner();\n\t\t\t\t\t},\n\t\t\t\t\t...(!(this._subagentPolicy?.depth && this._subagentPolicy.depth >= 1)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\toperations: {\n\t\t\t\t\t\t\t\t\texec: (command, cwd, options) =>\n\t\t\t\t\t\t\t\t\t\tcreateLocalPowerShellOperations({\n\t\t\t\t\t\t\t\t\t\t\ttaskOwner: this.getAgentTaskHost().ownerBinding,\n\t\t\t\t\t\t\t\t\t\t}).exec(command, cwd, options),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t},\n\t\t\t\tkill: {\n\t\t\t\t\ttaskOwner: () => this.getAgentTaskHost().ownerBinding,\n\t\t\t\t},\n\t\t\t\tsearch: {\n\t\t\t\t\tcontextBefore: this.settingsManager.getSearchContextBefore(),\n\t\t\t\t\tcontextAfter: this.settingsManager.getSearchContextAfter(),\n\t\t\t\t},\n\t\t\t});\n\n\tthis._baseToolDefinitions = new Map(\n\t\tObject.entries(baseToolDefinitions).map(([name, tool]) => [name, tool as ToolDefinition]),\n\t);\n\n\tconst extensionsResult = this._resourceLoader.getExtensions();\n\tif (options.flagValues) {\n\t\tfor (const [name, value] of options.flagValues) {\n\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\textensionsResult.runtime.explicitFlagNames ??= new Set();\n\t\t\textensionsResult.runtime.explicitFlagNames.add(name);\n\t\t}\n\t}\n\n\tif (!options.preserveRunner) {\n\t\tthis._extensionRunner = new ExtensionRunner(\n\t\t\textensionsResult.extensions,\n\t\t\textensionsResult.runtime,\n\t\t\tthis._cwd,\n\t\t\tthis.sessionManager,\n\t\t\tnew ModelRegistry(this._modelRuntime),\n\t\t\tthis._orchestrationContext,\n\t\t\tthis._subagentPolicy,\n\t\t);\n\t\tif (this._extensionRunnerRef) {\n\t\t\tthis._extensionRunnerRef.current = this._extensionRunner;\n\t\t}\n\t\tthis._bindExtensionCore(this._extensionRunner);\n\t\tthis._applyExtensionBindings(this._extensionRunner);\n\t}\n\n\tconst defaultActiveToolNames = this._baseToolsOverride\n\t\t? Object.keys(this._baseToolsOverride)\n\t\t: [...getDefaultToolNames()];\n\tconst baseActiveToolNames = options.activeToolNames ?? defaultActiveToolNames;\n\tthis._refreshToolRegistry({\n\t\tactiveToolNames: baseActiveToolNames,\n\t\tincludeAllExtensionTools: options.includeAllExtensionTools,\n\t});\n}\n\nexport const agentSessionToolRegistryMethods = {\n\t_refreshToolRegistry,\n\t_buildRuntime,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-tool-registry.js","sourceRoot":"","sources":["../../src/core/agent-session-tool-registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAuB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAA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AAC,aAAa,CAAC,EACrC,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,eAAe,CACpB,CAAC;QACF,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC9B,IAAI,CAAC,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC/C,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB;QACrD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC;QACtC,CAAC,CAAC,CAAC,GAAG,mBAAmB,EAAE,CAAC,CAAC;IAC9B,MAAM,mBAAmB,GAAG,OAAO,CAAC,eAAe,IAAI,sBAAsB,CAAC;IAC9E,IAAI,CAAC,oBAAoB,CAAC;QACzB,eAAe,EAAE,mBAAmB;QACpC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;KAC1D,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,oBAAoB;IACpB,aAAa;CACb,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { ToolDefinitionEntry } from \"./agent-session-types.ts\";\nimport { ExtensionRunner, type ToolDefinition, wrapRegisteredTools } from \"./extensions/index.js\";\nimport { isMandatoryRuntimeTool, isTrustedMandatoryRuntimeTool } from \"./mandatory-runtime-tools.ts\";\nimport { ModelRegistry } from \"./model-registry.ts\";\nimport { createSyntheticSourceInfo } from \"./source-info.ts\";\nimport { createLocalBashOperations } from \"./tools/bash.js\";\nimport { buildMutationRequester } from \"./tools/file-mutation-coordinator.ts\";\nimport { createAllToolDefinitions, getDefaultToolNames } from \"./tools/index.ts\";\nimport { createLocalPowerShellOperations } from \"./tools/powershell.ts\";\nimport { resolveSessionTempDirPath } from \"./tools/session-temp-dir.ts\";\nimport { createToolDefinitionFromAgentTool } from \"./tools/tool-definition-wrapper.ts\";\n\nexport function _refreshToolRegistry(\n\tthis: AgentSession,\n\toptions?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean },\n): void {\n\tconst previousRegistryNames = new Set(this._toolRegistry.keys());\n\tconst previousActiveToolNames = this.getActiveToolNames();\n\tconst allowedToolNames = this._allowedToolNames;\n\tconst excludedToolNames = this._excludedToolNames;\n\tconst isExposedTool = (name: string): boolean => {\n\t\tif (isMandatoryRuntimeTool(name)) return true;\n\t\tif (allowedToolNames && !allowedToolNames.has(name)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (excludedToolNames?.has(name)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t};\n\n\tconst registeredTools = this._extensionRunner\n\t\t.getAllRegisteredTools()\n\t\t.filter((tool) => !isMandatoryRuntimeTool(tool.definition.name) || isTrustedMandatoryRuntimeTool(tool));\n\tconst allCustomTools = [\n\t\t...registeredTools,\n\t\t...this._customTools\n\t\t\t.filter((definition) => !isMandatoryRuntimeTool(definition.name))\n\t\t\t.map((definition) => ({\n\t\t\t\tdefinition,\n\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: \"sdk\" }),\n\t\t\t})),\n\t].filter((tool) => isExposedTool(tool.definition.name));\n\tconst definitionRegistry = new Map<string, ToolDefinitionEntry>(\n\t\tArray.from(this._baseToolDefinitions.entries())\n\t\t\t.filter(([name]) => isExposedTool(name))\n\t\t\t.map(([name, definition]) => [\n\t\t\t\tname,\n\t\t\t\t{\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${name}>`, { source: \"builtin\" }),\n\t\t\t\t},\n\t\t\t]),\n\t);\n\tfor (const tool of allCustomTools) {\n\t\tdefinitionRegistry.set(tool.definition.name, {\n\t\t\tdefinition: tool.definition,\n\t\t\tsourceInfo: tool.sourceInfo,\n\t\t});\n\t}\n\tthis._toolDefinitions = definitionRegistry;\n\tthis._toolPromptSnippets = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst snippet = this._normalizePromptSnippet(definition.promptSnippet);\n\t\t\t\treturn snippet ? ([definition.name, snippet] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string] => entry !== undefined),\n\t);\n\tthis._toolPromptGuidelines = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst guidelines = this._normalizePromptGuidelines(definition.promptGuidelines);\n\t\t\t\treturn guidelines.length > 0 ? ([definition.name, guidelines] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string[]] => entry !== undefined),\n\t);\n\tconst runner = this._extensionRunner;\n\tconst wrappedExtensionTools = wrapRegisteredTools(allCustomTools, runner);\n\tconst wrappedBuiltInTools = wrapRegisteredTools(\n\t\tArray.from(this._baseToolDefinitions.values())\n\t\t\t.filter((definition) => isExposedTool(definition.name))\n\t\t\t.map((definition) => ({\n\t\t\t\tdefinition,\n\t\t\t\tsourceInfo: createSyntheticSourceInfo(`<builtin:${definition.name}>`, { source: \"builtin\" }),\n\t\t\t})),\n\t\trunner,\n\t);\n\n\tconst toolRegistry = new Map(wrappedBuiltInTools.map((tool) => [tool.name, tool]));\n\tfor (const tool of wrappedExtensionTools as AgentTool[]) {\n\t\ttoolRegistry.set(tool.name, tool);\n\t}\n\tthis._toolRegistry = toolRegistry;\n\n\tconst nextActiveToolNames = (\n\t\toptions?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]\n\t).filter((name) => isExposedTool(name));\n\n\tif (allowedToolNames) {\n\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\tif (allowedToolNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t} else if (options?.includeAllExtensionTools) {\n\t\tfor (const tool of wrappedExtensionTools) {\n\t\t\tnextActiveToolNames.push(tool.name);\n\t\t}\n\t} else if (!options?.activeToolNames) {\n\t\tfor (const toolName of this._toolRegistry.keys()) {\n\t\t\tif (!previousRegistryNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t}\n\n\tthis.setActiveToolsByName([...new Set(nextActiveToolNames)]);\n}\n\nexport function _buildRuntime(\n\tthis: AgentSession,\n\toptions: {\n\t\tactiveToolNames?: string[];\n\t\tflagValues?: Map<string, boolean | string>;\n\t\tincludeAllExtensionTools?: boolean;\n\t\tpreserveRunner?: boolean;\n\t},\n): void {\n\tconst autoResizeImages = this.settingsManager.getImageAutoResize();\n\tconst shellCommandPrefix = this.settingsManager.getShellCommandPrefix();\n\tconst shellPath = this.settingsManager.getShellPath();\n\tconst isAllowedBuiltinTool = (name: string): boolean => {\n\t\tif (this._allowedToolNames && !this._allowedToolNames.has(name)) return false;\n\t\tif (this._excludedToolNames?.has(name)) return false;\n\t\treturn true;\n\t};\n\tconst activeBuiltinTools = (options.activeToolNames ?? [...getDefaultToolNames()]).filter(isAllowedBuiltinTool);\n\t// Resolve ownership per call, just like command execution. Each wait receives\n\t// a stable binding so observation cleanup can finish after session disposal.\n\tconst getTaskOwner = () =>\n\t\tthis._subagentPolicy?.depth && this._subagentPolicy.depth >= 1 ? undefined : this.getAgentTaskHost().ownerBinding;\n\tconst baseToolDefinitions = this._baseToolsOverride\n\t\t? Object.fromEntries(\n\t\t\t\tObject.entries(this._baseToolsOverride).map(([name, tool]) => [\n\t\t\t\t\tname,\n\t\t\t\t\tcreateToolDefinitionFromAgentTool(tool),\n\t\t\t\t]),\n\t\t\t)\n\t\t: createAllToolDefinitions(this._cwd, {\n\t\t\t\t// Resolved per execution for the same reason as `sessionTempDir` below: a\n\t\t\t\t// requester captured at construction would keep a stale session id across\n\t\t\t\t// fork/branch/resume, which is exactly the relaunch this makes legible.\n\t\t\t\tresolveMutationRequester: (toolCallId) =>\n\t\t\t\t\tbuildMutationRequester({\n\t\t\t\t\t\tsessionId: this.sessionManager.getSessionId(),\n\t\t\t\t\t\t...(this._orchestrationContext ? { orchestration: this._orchestrationContext } : {}),\n\t\t\t\t\t\t...(this._subagentPolicy?.intercom ? { intercom: this._subagentPolicy.intercom } : {}),\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t}),\n\t\t\t\tread: { autoResizeImages },\n\t\t\t\tbash: {\n\t\t\t\t\tcommandPrefix: shellCommandPrefix,\n\t\t\t\t\tshellPath,\n\t\t\t\t\tget taskOwner() {\n\t\t\t\t\t\treturn getTaskOwner();\n\t\t\t\t\t},\n\t\t\t\t\t...(!(this._subagentPolicy?.depth && this._subagentPolicy.depth >= 1)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\toperations: {\n\t\t\t\t\t\t\t\t\texec: (command, cwd, options) =>\n\t\t\t\t\t\t\t\t\t\tcreateLocalBashOperations({\n\t\t\t\t\t\t\t\t\t\t\tshellPath,\n\t\t\t\t\t\t\t\t\t\t\ttaskOwner: this.getAgentTaskHost().ownerBinding,\n\t\t\t\t\t\t\t\t\t\t}).exec(command, cwd, options),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t\tinterceptorEnabled: () => this.settingsManager.getBashInterceptorEnabled(),\n\t\t\t\t\tavailableTools: activeBuiltinTools,\n\t\t\t\t\t// Resolved per execution so bash spill files follow the live\n\t\t\t\t\t// transcript session across fork/branch/resume.\n\t\t\t\t\tsessionTempDir: () => resolveSessionTempDirPath(this.sessionManager.getSessionId()),\n\t\t\t\t\tinterceptor: async (context) => {\n\t\t\t\t\t\tconst result = await this._extensionRunner.emitUserBash({\n\t\t\t\t\t\t\ttype: \"user_bash\",\n\t\t\t\t\t\t\tcommand: context.command,\n\t\t\t\t\t\t\texcludeFromContext: false,\n\t\t\t\t\t\t\tcwd: context.cwd,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tpowershell: {\n\t\t\t\t\tget taskOwner() {\n\t\t\t\t\t\treturn getTaskOwner();\n\t\t\t\t\t},\n\t\t\t\t\t...(!(this._subagentPolicy?.depth && this._subagentPolicy.depth >= 1)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\toperations: {\n\t\t\t\t\t\t\t\t\texec: (command, cwd, options) =>\n\t\t\t\t\t\t\t\t\t\tcreateLocalPowerShellOperations({\n\t\t\t\t\t\t\t\t\t\t\ttaskOwner: this.getAgentTaskHost().ownerBinding,\n\t\t\t\t\t\t\t\t\t\t}).exec(command, cwd, options),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t},\n\t\t\t\tkill: {\n\t\t\t\t\ttaskOwner: () => this.getAgentTaskHost().ownerBinding,\n\t\t\t\t},\n\t\t\t\tsearch: {\n\t\t\t\t\tcontextBefore: this.settingsManager.getSearchContextBefore(),\n\t\t\t\t\tcontextAfter: this.settingsManager.getSearchContextAfter(),\n\t\t\t\t},\n\t\t\t});\n\n\tthis._baseToolDefinitions = new Map(\n\t\tObject.entries(baseToolDefinitions).map(([name, tool]) => [name, tool as ToolDefinition]),\n\t);\n\n\tconst extensionsResult = this._resourceLoader.getExtensions();\n\tif (options.flagValues) {\n\t\tfor (const [name, value] of options.flagValues) {\n\t\t\textensionsResult.runtime.flagValues.set(name, value);\n\t\t\textensionsResult.runtime.explicitFlagNames ??= new Set();\n\t\t\textensionsResult.runtime.explicitFlagNames.add(name);\n\t\t}\n\t}\n\n\tif (!options.preserveRunner) {\n\t\tthis._extensionRunner = new ExtensionRunner(\n\t\t\textensionsResult.extensions,\n\t\t\textensionsResult.runtime,\n\t\t\tthis._cwd,\n\t\t\tthis.sessionManager,\n\t\t\tnew ModelRegistry(this._modelRuntime),\n\t\t\tthis._orchestrationContext,\n\t\t\tthis._subagentPolicy,\n\t\t);\n\t\tif (this._extensionRunnerRef) {\n\t\t\tthis._extensionRunnerRef.current = this._extensionRunner;\n\t\t}\n\t\tthis._bindExtensionCore(this._extensionRunner);\n\t\tthis._applyExtensionBindings(this._extensionRunner);\n\t}\n\n\tconst defaultActiveToolNames = this._baseToolsOverride\n\t\t? Object.keys(this._baseToolsOverride)\n\t\t: [...getDefaultToolNames()];\n\tconst baseActiveToolNames = options.activeToolNames ?? defaultActiveToolNames;\n\tthis._refreshToolRegistry({\n\t\tactiveToolNames: baseActiveToolNames,\n\t\tincludeAllExtensionTools: options.includeAllExtensionTools,\n\t});\n}\n\nexport const agentSessionToolRegistryMethods = {\n\t_refreshToolRegistry,\n\t_buildRuntime,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-executor.js","sourceRoot":"","sources":["../../src/core/bash-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAmCtE,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,OAAe,EACf,GAAW,EACX,UAA0B,EAC1B,OAA6B;IAE7B,MAAM,YAAY,GAAa,EAA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AE,IAAI;gBACf,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,cAAc,EAAE,YAAY;aAC5B,CAAC;QACH,CAAC;QAED,MAAM,cAAc,EAAE,CAAC;QAEvB,MAAM,GAAG,CAAC;IACX,CAAC;AACF,CAAC","sourcesContent":["/**\n * Bash command execution with streaming support and cancellation.\n *\n * This module provides a unified bash execution implementation used by:\n * - AgentSession.executeBash() for interactive and RPC modes\n * - Direct calls from modes that need bash execution\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport { APP_NAME } from \"../config.js\";\nimport { stripAnsi } from \"../utils/ansi.ts\";\nimport { sanitizeBinaryOutput } from \"../utils/shell.ts\";\nimport type { BashOperations, BashOutputChannel } from \"./tools/bash.js\";\nimport { PersistedOutputFile } from \"./tools/persisted-output-file.ts\";\nimport { ensureSessionTempDir } from \"./tools/session-temp-dir.ts\";\nimport { DEFAULT_MAX_BYTES, truncateTail } from \"./tools/truncate.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BashExecutorOptions {\n\t/** Callback for streaming output chunks (already sanitized), preserving the source channel. */\n\tonChunk?: (chunk: string, channel: BashOutputChannel) => void;\n\t/** AbortSignal for cancellation */\n\tsignal?: AbortSignal;\n\t/** Complete environment for the execution backend. */\n\tenv?: NodeJS.ProcessEnv;\n\t/** Run with PTY handling when supported by the operations backend */\n\tpty?: boolean;\n\t/**\n\t * Session-scoped directory for the overflow log. Defaults to the active\n\t * session's temp directory so the log is reaped with that session.\n\t */\n\tsessionTempDir?: string;\n}\n\nexport interface BashResult {\n\t/** Combined stdout + stderr output (sanitized, possibly truncated) */\n\toutput: string;\n\t/** Process exit code (undefined if killed/cancelled) */\n\texitCode: number | undefined;\n\t/** Whether the command was cancelled via signal */\n\tcancelled: boolean;\n\t/** Whether the output was truncated */\n\ttruncated: boolean;\n\t/** Path to temp file containing full output (if output exceeded truncation threshold) */\n\tfullOutputPath?: string;\n}\n\n// ============================================================================\n// Implementation\n// ============================================================================\n\n/**\n * Execute a bash command using custom BashOperations.\n * Used for remote execution (SSH, containers, etc.).\n */\nexport async function executeBashWithOperations(\n\tcommand: string,\n\tcwd: string,\n\toperations: BashOperations,\n\toptions?: BashExecutorOptions,\n): Promise<BashResult> {\n\tconst outputChunks: string[] = [];\n\tlet outputBytes = 0;\n\tconst maxOutputBytes = DEFAULT_MAX_BYTES * 2;\n\n\tlet tempFilePath: string | undefined;\n\tlet tempFile: PersistedOutputFile | undefined;\n\tlet totalBytes = 0;\n\n\tlet tempFileUnavailable = false;\n\n\tconst ensureTempFile = () => {\n\t\tif (tempFilePath || tempFileUnavailable) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst dir = ensureSessionTempDir(options?.sessionTempDir);\n\t\t\tconst id = randomBytes(8).toString(\"hex\");\n\t\t\ttempFilePath = join(dir, `${APP_NAME}-bash-${id}.log`);\n\t\t\ttempFile = new PersistedOutputFile(tempFilePath);\n\t\t} catch {\n\t\t\t// The session temp directory was refused (see ensureTempDir). Run without\n\t\t\t// an overflow log rather than advertising a path outside the owned tree.\n\t\t\ttempFileUnavailable = true;\n\t\t\ttempFilePath = undefined;\n\t\t\ttempFile = undefined;\n\t\t\treturn;\n\t\t}\n\t\tfor (const chunk of outputChunks) {\n\t\t\ttempFile.write(chunk);\n\t\t}\n\t};\n\n\t/**\n\t * Close the overflow log and confirm it landed. A spill file that failed to\n\t * write must not be advertised: `fullOutputPath` is dropped instead, so the\n\t * `Full output:` contract never points at a file that is not there.\n\t */\n\tconst finishTempFile = async () => {\n\t\tconst file = tempFile;\n\t\tif (!file) {\n\t\t\treturn;\n\t\t}\n\t\ttempFile = undefined;\n\t\ttry {\n\t\t\tawait file.close();\n\t\t} catch {\n\t\t\ttempFilePath = undefined;\n\t\t}\n\t};\n\n\tconst decoders: Record<BashOutputChannel, TextDecoder> = { stdout: new TextDecoder(), stderr: new TextDecoder() };\n\tconst onData = (data: Buffer, channel: BashOutputChannel = \"stdout\") => {\n\t\ttotalBytes += data.length;\n\n\t\t// Sanitize: strip ANSI, replace binary garbage, normalize newlines\n\t\tconst text = sanitizeBinaryOutput(stripAnsi(decoders[channel].decode(data, { stream: true }))).replace(/\\r/g, \"\");\n\n\t\t// Start writing to temp file if exceeds threshold\n\t\tif (totalBytes > DEFAULT_MAX_BYTES) {\n\t\t\tensureTempFile();\n\t\t}\n\n\t\tif (tempFile) {\n\t\t\ttempFile.write(text);\n\t\t}\n\n\t\t// Keep rolling buffer\n\t\toutputChunks.push(text);\n\t\toutputBytes += text.length;\n\t\twhile (outputBytes > maxOutputBytes && outputChunks.length > 1) {\n\t\t\tconst removed = outputChunks.shift()!;\n\t\t\toutputBytes -= removed.length;\n\t\t}\n\n\t\t// Stream to callback\n\t\tif (options?.onChunk) {\n\t\t\toptions.onChunk(text, channel);\n\t\t}\n\t};\n\n\ttry {\n\t\tconst result = await operations.exec(command, cwd, {\n\t\t\tonData,\n\t\t\tsignal: options?.signal,\n\t\t\tenv: options?.env,\n\t\t\tpty: options?.pty,\n\t\t});\n\n\t\tconst fullOutput = outputChunks.join(\"\");\n\t\tconst truncationResult = truncateTail(fullOutput);\n\t\tif (truncationResult.truncated) {\n\t\t\tensureTempFile();\n\t\t}\n\t\tawait finishTempFile();\n\t\tconst cancelled = options?.signal?.aborted ?? false;\n\n\t\treturn {\n\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\texitCode: cancelled ? undefined : (result.exitCode ?? undefined),\n\t\t\tcancelled,\n\t\t\ttruncated: truncationResult.truncated,\n\t\t\tfullOutputPath: tempFilePath,\n\t\t};\n\t} catch (err) {\n\t\t// Check if it was an abort\n\t\tif (options?.signal?.aborted) {\n\t\t\tconst fullOutput = outputChunks.join(\"\");\n\t\t\tconst truncationResult = truncateTail(fullOutput);\n\t\t\tif (truncationResult.truncated) {\n\t\t\t\tensureTempFile();\n\t\t\t}\n\t\t\tawait finishTempFile();\n\t\t\treturn {\n\t\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\t\texitCode: undefined,\n\t\t\t\tcancelled: true,\n\t\t\t\ttruncated: truncationResult.truncated,\n\t\t\t\tfullOutputPath: tempFilePath,\n\t\t\t};\n\t\t}\n\n\t\tawait finishTempFile();\n\n\t\tthrow err;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bash-executor.js","sourceRoot":"","sources":["../../src/core/bash-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAmCtE,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,OAAe,EACf,GAAW,EACX,UAA0B,EAC1B,OAA6B;IAE7B,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,MAAM,cAAc,GAAG,iBAAiB,GAAG,CAAC,CAAC;IAE7C,IAAI,YAAgC,CAAC;IACrC,IAAI,QAAyC,CAAC;IAC9C,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,IAAI,mBAAmB,GAAG,KAAK,CAAC;IAEhC,MAAM,cAAc,GAAG,GAAG,EAAE;QAC3B,IAAI,YAAY,IAAI,mBAAmB,EAAE,CAAC;YACzC,OAAO;QACR,CAAC;QACD,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,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,KAAK,CAAC;QAEpD,OAAO;YACN,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU;YAC1E,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,SAAS,CAAC;YAChE,SAAS;YACT,SAAS,EAAE,gBAAgB,CAAC,SAAS;YACrC,cAAc,EAAE,YAAY;SAC5B,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,2BAA2B;QAC3B,IAAI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACzC,MAAM,gBAAgB,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;YAClD,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;gBAChC,cAAc,EAAE,CAAC;YAClB,CAAC;YACD,MAAM,cAAc,EAAE,CAAC;YACvB,OAAO;gBACN,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU;gBAC1E,QAAQ,EAAE,SAAS;gBACnB,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,cAAc,EAAE,YAAY;aAC5B,CAAC;QACH,CAAC;QAED,MAAM,cAAc,EAAE,CAAC;QAEvB,MAAM,GAAG,CAAC;IACX,CAAC;AACF,CAAC","sourcesContent":["/**\n * Bash command execution with streaming support and cancellation.\n *\n * This module provides a unified bash execution implementation used by:\n * - AgentSession.executeBash() for interactive and RPC modes\n * - Direct calls from modes that need bash execution\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport { APP_NAME } from \"../config.js\";\nimport { stripAnsi } from \"../utils/ansi.js\";\nimport { sanitizeBinaryOutput } from \"../utils/shell.ts\";\nimport type { BashOperations, BashOutputChannel } from \"./tools/bash.js\";\nimport { PersistedOutputFile } from \"./tools/persisted-output-file.ts\";\nimport { ensureSessionTempDir } from \"./tools/session-temp-dir.ts\";\nimport { DEFAULT_MAX_BYTES, truncateTail } from \"./tools/truncate.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BashExecutorOptions {\n\t/** Callback for streaming output chunks (already sanitized), preserving the source channel. */\n\tonChunk?: (chunk: string, channel: BashOutputChannel) => void;\n\t/** AbortSignal for cancellation */\n\tsignal?: AbortSignal;\n\t/** Complete environment for the execution backend. */\n\tenv?: NodeJS.ProcessEnv;\n\t/** Run with PTY handling when supported by the operations backend */\n\tpty?: boolean;\n\t/**\n\t * Session-scoped directory for the overflow log. Defaults to the active\n\t * session's temp directory so the log is reaped with that session.\n\t */\n\tsessionTempDir?: string;\n}\n\nexport interface BashResult {\n\t/** Combined stdout + stderr output (sanitized, possibly truncated) */\n\toutput: string;\n\t/** Process exit code (undefined if killed/cancelled) */\n\texitCode: number | undefined;\n\t/** Whether the command was cancelled via signal */\n\tcancelled: boolean;\n\t/** Whether the output was truncated */\n\ttruncated: boolean;\n\t/** Path to temp file containing full output (if output exceeded truncation threshold) */\n\tfullOutputPath?: string;\n}\n\n// ============================================================================\n// Implementation\n// ============================================================================\n\n/**\n * Execute a bash command using custom BashOperations.\n * Used for remote execution (SSH, containers, etc.).\n */\nexport async function executeBashWithOperations(\n\tcommand: string,\n\tcwd: string,\n\toperations: BashOperations,\n\toptions?: BashExecutorOptions,\n): Promise<BashResult> {\n\tconst outputChunks: string[] = [];\n\tlet outputBytes = 0;\n\tconst maxOutputBytes = DEFAULT_MAX_BYTES * 2;\n\n\tlet tempFilePath: string | undefined;\n\tlet tempFile: PersistedOutputFile | undefined;\n\tlet totalBytes = 0;\n\n\tlet tempFileUnavailable = false;\n\n\tconst ensureTempFile = () => {\n\t\tif (tempFilePath || tempFileUnavailable) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst dir = ensureSessionTempDir(options?.sessionTempDir);\n\t\t\tconst id = randomBytes(8).toString(\"hex\");\n\t\t\ttempFilePath = join(dir, `${APP_NAME}-bash-${id}.log`);\n\t\t\ttempFile = new PersistedOutputFile(tempFilePath);\n\t\t} catch {\n\t\t\t// The session temp directory was refused (see ensureTempDir). Run without\n\t\t\t// an overflow log rather than advertising a path outside the owned tree.\n\t\t\ttempFileUnavailable = true;\n\t\t\ttempFilePath = undefined;\n\t\t\ttempFile = undefined;\n\t\t\treturn;\n\t\t}\n\t\tfor (const chunk of outputChunks) {\n\t\t\ttempFile.write(chunk);\n\t\t}\n\t};\n\n\t/**\n\t * Close the overflow log and confirm it landed. A spill file that failed to\n\t * write must not be advertised: `fullOutputPath` is dropped instead, so the\n\t * `Full output:` contract never points at a file that is not there.\n\t */\n\tconst finishTempFile = async () => {\n\t\tconst file = tempFile;\n\t\tif (!file) {\n\t\t\treturn;\n\t\t}\n\t\ttempFile = undefined;\n\t\ttry {\n\t\t\tawait file.close();\n\t\t} catch {\n\t\t\ttempFilePath = undefined;\n\t\t}\n\t};\n\n\tconst decoders: Record<BashOutputChannel, TextDecoder> = { stdout: new TextDecoder(), stderr: new TextDecoder() };\n\tconst onData = (data: Buffer, channel: BashOutputChannel = \"stdout\") => {\n\t\ttotalBytes += data.length;\n\n\t\t// Sanitize: strip ANSI, replace binary garbage, normalize newlines\n\t\tconst text = sanitizeBinaryOutput(stripAnsi(decoders[channel].decode(data, { stream: true }))).replace(/\\r/g, \"\");\n\n\t\t// Start writing to temp file if exceeds threshold\n\t\tif (totalBytes > DEFAULT_MAX_BYTES) {\n\t\t\tensureTempFile();\n\t\t}\n\n\t\tif (tempFile) {\n\t\t\ttempFile.write(text);\n\t\t}\n\n\t\t// Keep rolling buffer\n\t\toutputChunks.push(text);\n\t\toutputBytes += text.length;\n\t\twhile (outputBytes > maxOutputBytes && outputChunks.length > 1) {\n\t\t\tconst removed = outputChunks.shift()!;\n\t\t\toutputBytes -= removed.length;\n\t\t}\n\n\t\t// Stream to callback\n\t\tif (options?.onChunk) {\n\t\t\toptions.onChunk(text, channel);\n\t\t}\n\t};\n\n\ttry {\n\t\tconst result = await operations.exec(command, cwd, {\n\t\t\tonData,\n\t\t\tsignal: options?.signal,\n\t\t\tenv: options?.env,\n\t\t\tpty: options?.pty,\n\t\t});\n\n\t\tconst fullOutput = outputChunks.join(\"\");\n\t\tconst truncationResult = truncateTail(fullOutput);\n\t\tif (truncationResult.truncated) {\n\t\t\tensureTempFile();\n\t\t}\n\t\tawait finishTempFile();\n\t\tconst cancelled = options?.signal?.aborted ?? false;\n\n\t\treturn {\n\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\texitCode: cancelled ? undefined : (result.exitCode ?? undefined),\n\t\t\tcancelled,\n\t\t\ttruncated: truncationResult.truncated,\n\t\t\tfullOutputPath: tempFilePath,\n\t\t};\n\t} catch (err) {\n\t\t// Check if it was an abort\n\t\tif (options?.signal?.aborted) {\n\t\t\tconst fullOutput = outputChunks.join(\"\");\n\t\t\tconst truncationResult = truncateTail(fullOutput);\n\t\t\tif (truncationResult.truncated) {\n\t\t\t\tensureTempFile();\n\t\t\t}\n\t\t\tawait finishTempFile();\n\t\t\treturn {\n\t\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\t\texitCode: undefined,\n\t\t\t\tcancelled: true,\n\t\t\t\ttruncated: truncationResult.truncated,\n\t\t\t\tfullOutputPath: tempFilePath,\n\t\t\t};\n\t\t}\n\n\t\tawait finishTempFile();\n\n\t\tthrow err;\n\t}\n}\n"]}
|
|
@@ -27,7 +27,7 @@ type ShellWaitInput = {
|
|
|
27
27
|
declare const bashSchema: Type.TUnsafe<ShellCommandInput | ShellWaitInput>;
|
|
28
28
|
export declare const bashToolSystemPromptContribution: Readonly<{
|
|
29
29
|
readonly snippet: "Execute a shell command.";
|
|
30
|
-
readonly guidelines: readonly ["You can inspect ATOMIC_* or PI_* environment variables for current model and session details.", "Use { action: \"wait\", id: taskId
|
|
30
|
+
readonly guidelines: readonly ["You can inspect ATOMIC_* or PI_* environment variables for current model and session details.", "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.", "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.", "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."];
|
|
31
31
|
}>;
|
|
32
32
|
export type BashToolInput = Static<typeof bashSchema>;
|
|
33
33
|
export interface BashToolDetails {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAa5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAoB,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AACxG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAGN,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAG5B,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EA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AC9B,kBAAkB,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;IAC/C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,gBAAgB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACzC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;CACrD;AACD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;CACvB;AACD,eAAO,MAAM,uBAAuB,EAAE,qBAGrC,CAAC;AAkBF,KAAK,eAAe,GAAG;IACtB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;CACrC,CAAC;AA0HF,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,EACzB,YAAY,GAAE,qBAA+C,GAC3D,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,EAAE,eAAe,CAAC,CAmTjF;AACD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG"}
|
package/dist/core/tools/bash.js
CHANGED
|
@@ -76,8 +76,9 @@ export const bashToolSystemPromptContribution = Object.freeze({
|
|
|
76
76
|
snippet: "Execute a shell command.",
|
|
77
77
|
guidelines: Object.freeze([
|
|
78
78
|
"You can inspect ATOMIC_* or PI_* environment variables for current model and session details.",
|
|
79
|
-
'Use { action: "wait", id: taskId
|
|
80
|
-
"
|
|
79
|
+
'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.',
|
|
80
|
+
"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.",
|
|
81
|
+
"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.",
|
|
81
82
|
]),
|
|
82
83
|
});
|
|
83
84
|
const DEFAULT_TIMEOUT_SECONDS = 300, MAX_TIMEOUT_SECONDS = 3600;
|