@bastani/atomic 0.9.19-alpha.4 → 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 +33 -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 +12 -0
- package/dist/builtin/subagents/README.md +6 -4
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +7 -7
- package/dist/builtin/subagents/agents/debugger.md +2 -2
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +16 -14
- 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 +13 -0
- package/dist/builtin/workflows/builtin/{chunk-9k3ywfgd.js → chunk-1nbq96fh.js} +18 -18
- package/dist/builtin/workflows/builtin/{chunk-ahbntmx2.js → chunk-vhmnzdj9.js} +36 -36
- package/dist/builtin/workflows/builtin/{chunk-62v3gg9f.js → chunk-yeee2jrc.js} +11 -11
- package/dist/builtin/workflows/builtin/goal.js +1 -1
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +96 -67
- 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/providers.md +1 -1
- package/docs/subagents.md +4 -2
- package/docs/tools.md +26 -0
- package/docs/web-access.md +38 -0
- package/docs/workflows/builtins.md +9 -6
- 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,7 @@
|
|
|
1
1
|
export { createAskUserQuestionToolDefinition } from "./ask-user-question/index.ts";
|
|
2
2
|
export { BASH_SHELL_PRESENTATION, type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, bashToolSystemPromptContribution, createBashTool, createBashToolDefinition, createLocalBashOperations, type ShellToolPresentation, } from "./bash.js";
|
|
3
3
|
export { createEditTool, createEditToolDefinition, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, editToolSystemPromptContribution, } from "./edit.ts";
|
|
4
|
+
export { FILE_MUTATION_CONFLICT_CODE, FileMutationConflict, type FileMutationConflictDetails, type FileMutationConflictEvidence, type FileMutationConflictReason, type FileMutationLiveState, type MutationRequester, type MutationRequesterResolver, } from "./file-mutation-coordinator.ts";
|
|
4
5
|
export { withFileMutationQueue } from "./file-mutation-queue.ts";
|
|
5
6
|
export { createFindTool, createFindToolDefinition, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, findToolSystemPromptContribution, } from "./find.ts";
|
|
6
7
|
export { createKillTool, createKillToolDefinition, type KillToolOptions } from "./kill.ts";
|
|
@@ -11,12 +12,13 @@ export { createSearchTool, createSearchToolDefinition, type SearchToolDetails, t
|
|
|
11
12
|
export { createStructuredOutputCapture, createStructuredOutputTool, type JsonObject, type JsonPrimitive, type JsonValue, STRUCTURED_OUTPUT_TOOL_NAME, type StructuredOutputCapture, type StructuredOutputFileCapture, type StructuredOutputToolOptions, } from "./structured-output.ts";
|
|
12
13
|
export { createTodoToolDefinition } from "./todos.ts";
|
|
13
14
|
export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, } from "./truncate.ts";
|
|
14
|
-
export { createWriteTool, createWriteToolDefinition, type WriteOperations, type WriteToolInput, type WriteToolOptions, writeToolSystemPromptContribution, } from "./write.ts";
|
|
15
|
+
export { createWriteTool, createWriteToolDefinition, type WriteFileOptions, type WriteOperations, type WriteToolInput, type WriteToolOptions, writeToolSystemPromptContribution, } from "./write.ts";
|
|
15
16
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
16
17
|
import type { TSchema } from "typebox";
|
|
17
18
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
18
19
|
import { type BashToolOptions } from "./bash.js";
|
|
19
20
|
import { type EditToolOptions } from "./edit.ts";
|
|
21
|
+
import type { MutationRequesterResolver } from "./file-mutation-coordinator.ts";
|
|
20
22
|
import { type FindToolOptions } from "./find.ts";
|
|
21
23
|
import { type HashlineSnapshotStore } from "./hashline.ts";
|
|
22
24
|
import { type KillToolOptions } from "./kill.ts";
|
|
@@ -54,6 +56,12 @@ export interface ToolsOptions {
|
|
|
54
56
|
search?: SearchToolOptions;
|
|
55
57
|
ls?: LsToolOptions;
|
|
56
58
|
hashlineStore?: HashlineSnapshotStore;
|
|
59
|
+
/**
|
|
60
|
+
* Session-scoped identity for whichever mutation gets rejected, forwarded to the two tools
|
|
61
|
+
* that can raise a conflict. Deliberately not defaulted the way `hashlineStore` is: absence
|
|
62
|
+
* means no identity is available, which the conflict path already handles.
|
|
63
|
+
*/
|
|
64
|
+
resolveMutationRequester?: MutationRequesterResolver;
|
|
57
65
|
}
|
|
58
66
|
export declare function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef;
|
|
59
67
|
export declare function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EACN,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gCAAgC,EAChC,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,qBAAqB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,8BAA8B,GAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,+BAA+B,EAC/B,oBAAoB,EACpB,8BAA8B,EAC9B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK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CAAC;IACvB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,EAAE,CAAC,EAAE,aAAa,CAAC;IACnB,aAAa,CAAC,EAAE,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EACN,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gCAAgC,EAChC,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,qBAAqB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,GAC9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,8BA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,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAQ/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,CA2BxF"}
|
package/dist/core/tools/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createAskUserQuestionToolDefinition } from "./ask-user-question/index.js";
|
|
2
2
|
export { BASH_SHELL_PRESENTATION, bashToolSystemPromptContribution, createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.js";
|
|
3
3
|
export { createEditTool, createEditToolDefinition, editToolSystemPromptContribution, } from "./edit.js";
|
|
4
|
+
export { FILE_MUTATION_CONFLICT_CODE, FileMutationConflict, } from "./file-mutation-coordinator.js";
|
|
4
5
|
export { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
5
6
|
export { createFindTool, createFindToolDefinition, findToolSystemPromptContribution, } from "./find.js";
|
|
6
7
|
export { createKillTool, createKillToolDefinition } from "./kill.js";
|
|
@@ -70,6 +71,7 @@ export function createToolDefinition(toolName, cwd, options) {
|
|
|
70
71
|
// Default a shared store so the singular factories don't hand read/edit/
|
|
71
72
|
// write/search isolated stores (which silently degrades drift recovery).
|
|
72
73
|
const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
|
|
74
|
+
const resolveMutationRequester = options?.resolveMutationRequester;
|
|
73
75
|
switch (toolName) {
|
|
74
76
|
case "read":
|
|
75
77
|
return createReadToolDefinition(cwd, { ...options?.read, hashlineStore });
|
|
@@ -80,9 +82,17 @@ export function createToolDefinition(toolName, cwd, options) {
|
|
|
80
82
|
case "kill":
|
|
81
83
|
return createKillToolDefinition(options?.kill);
|
|
82
84
|
case "edit":
|
|
83
|
-
return createEditToolDefinition(cwd, {
|
|
85
|
+
return createEditToolDefinition(cwd, {
|
|
86
|
+
...options?.edit,
|
|
87
|
+
hashlineStore,
|
|
88
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
89
|
+
});
|
|
84
90
|
case "write":
|
|
85
|
-
return createWriteToolDefinition(cwd, {
|
|
91
|
+
return createWriteToolDefinition(cwd, {
|
|
92
|
+
...options?.write,
|
|
93
|
+
hashlineStore,
|
|
94
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
95
|
+
});
|
|
86
96
|
case "find":
|
|
87
97
|
return createFindToolDefinition(cwd, options?.find);
|
|
88
98
|
case "search":
|
|
@@ -99,6 +109,7 @@ export function createToolDefinition(toolName, cwd, options) {
|
|
|
99
109
|
}
|
|
100
110
|
export function createTool(toolName, cwd, options) {
|
|
101
111
|
const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
|
|
112
|
+
const resolveMutationRequester = options?.resolveMutationRequester;
|
|
102
113
|
switch (toolName) {
|
|
103
114
|
case "read":
|
|
104
115
|
return createReadTool(cwd, { ...options?.read, hashlineStore });
|
|
@@ -109,9 +120,17 @@ export function createTool(toolName, cwd, options) {
|
|
|
109
120
|
case "kill":
|
|
110
121
|
return createKillTool(options?.kill);
|
|
111
122
|
case "edit":
|
|
112
|
-
return createEditTool(cwd, {
|
|
123
|
+
return createEditTool(cwd, {
|
|
124
|
+
...options?.edit,
|
|
125
|
+
hashlineStore,
|
|
126
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
127
|
+
});
|
|
113
128
|
case "write":
|
|
114
|
-
return createWriteTool(cwd, {
|
|
129
|
+
return createWriteTool(cwd, {
|
|
130
|
+
...options?.write,
|
|
131
|
+
hashlineStore,
|
|
132
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
133
|
+
});
|
|
115
134
|
case "find":
|
|
116
135
|
return createFindTool(cwd, options?.find);
|
|
117
136
|
case "search":
|
|
@@ -128,12 +147,21 @@ export function createTool(toolName, cwd, options) {
|
|
|
128
147
|
}
|
|
129
148
|
export function createCodingToolDefinitions(cwd, options) {
|
|
130
149
|
const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
|
|
150
|
+
const resolveMutationRequester = options?.resolveMutationRequester;
|
|
131
151
|
return [
|
|
132
152
|
createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),
|
|
133
153
|
createBashToolDefinition(cwd, options?.bash),
|
|
134
154
|
createKillToolDefinition(options?.kill),
|
|
135
|
-
createEditToolDefinition(cwd, {
|
|
136
|
-
|
|
155
|
+
createEditToolDefinition(cwd, {
|
|
156
|
+
...options?.edit,
|
|
157
|
+
hashlineStore,
|
|
158
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
159
|
+
}),
|
|
160
|
+
createWriteToolDefinition(cwd, {
|
|
161
|
+
...options?.write,
|
|
162
|
+
hashlineStore,
|
|
163
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
164
|
+
}),
|
|
137
165
|
createFindToolDefinition(cwd, options?.find),
|
|
138
166
|
createSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),
|
|
139
167
|
];
|
|
@@ -149,12 +177,21 @@ export function createReadOnlyToolDefinitions(cwd, options) {
|
|
|
149
177
|
}
|
|
150
178
|
export function createAllToolDefinitions(cwd, options) {
|
|
151
179
|
const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
|
|
180
|
+
const resolveMutationRequester = options?.resolveMutationRequester;
|
|
152
181
|
const definitions = {
|
|
153
182
|
read: createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),
|
|
154
183
|
bash: createBashToolDefinition(cwd, options?.bash),
|
|
155
184
|
kill: createKillToolDefinition(options?.kill),
|
|
156
|
-
edit: createEditToolDefinition(cwd, {
|
|
157
|
-
|
|
185
|
+
edit: createEditToolDefinition(cwd, {
|
|
186
|
+
...options?.edit,
|
|
187
|
+
hashlineStore,
|
|
188
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
189
|
+
}),
|
|
190
|
+
write: createWriteToolDefinition(cwd, {
|
|
191
|
+
...options?.write,
|
|
192
|
+
hashlineStore,
|
|
193
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
194
|
+
}),
|
|
158
195
|
find: createFindToolDefinition(cwd, options?.find),
|
|
159
196
|
search: createSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),
|
|
160
197
|
ls: createLsToolDefinition(cwd, options?.ls),
|
|
@@ -168,12 +205,21 @@ export function createAllToolDefinitions(cwd, options) {
|
|
|
168
205
|
}
|
|
169
206
|
export function createCodingTools(cwd, options) {
|
|
170
207
|
const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
|
|
208
|
+
const resolveMutationRequester = options?.resolveMutationRequester;
|
|
171
209
|
return [
|
|
172
210
|
createReadTool(cwd, { ...options?.read, hashlineStore }),
|
|
173
211
|
createBashTool(cwd, options?.bash),
|
|
174
212
|
createKillTool(options?.kill),
|
|
175
|
-
createEditTool(cwd, {
|
|
176
|
-
|
|
213
|
+
createEditTool(cwd, {
|
|
214
|
+
...options?.edit,
|
|
215
|
+
hashlineStore,
|
|
216
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
217
|
+
}),
|
|
218
|
+
createWriteTool(cwd, {
|
|
219
|
+
...options?.write,
|
|
220
|
+
hashlineStore,
|
|
221
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
222
|
+
}),
|
|
177
223
|
createFindTool(cwd, options?.find),
|
|
178
224
|
createSearchTool(cwd, { ...options?.search, hashlineStore }),
|
|
179
225
|
];
|
|
@@ -189,12 +235,21 @@ export function createReadOnlyTools(cwd, options) {
|
|
|
189
235
|
}
|
|
190
236
|
export function createAllTools(cwd, options) {
|
|
191
237
|
const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
|
|
238
|
+
const resolveMutationRequester = options?.resolveMutationRequester;
|
|
192
239
|
const tools = {
|
|
193
240
|
read: createReadTool(cwd, { ...options?.read, hashlineStore }),
|
|
194
241
|
bash: createBashTool(cwd, options?.bash),
|
|
195
242
|
kill: createKillTool(options?.kill),
|
|
196
|
-
edit: createEditTool(cwd, {
|
|
197
|
-
|
|
243
|
+
edit: createEditTool(cwd, {
|
|
244
|
+
...options?.edit,
|
|
245
|
+
hashlineStore,
|
|
246
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
247
|
+
}),
|
|
248
|
+
write: createWriteTool(cwd, {
|
|
249
|
+
...options?.write,
|
|
250
|
+
hashlineStore,
|
|
251
|
+
...(resolveMutationRequester ? { resolveMutationRequester } : {}),
|
|
252
|
+
}),
|
|
198
253
|
find: createFindTool(cwd, options?.find),
|
|
199
254
|
search: createSearchTool(cwd, { ...options?.search, hashlineStore }),
|
|
200
255
|
ls: createLsTool(cwd, options?.ls),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EACN,uBAAuB,EAOvB,gCAAgC,EAChC,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GAEzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EAKxB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EAKxB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,OAAO,EACN,YAAY,EACZ,sBAAsB,EAKtB,8BAA8B,GAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,+BAA+B,EAC/B,oBAAoB,EACpB,8BAA8B,GAO9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,cAAc,EACd,wBAAwB,EAKxB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EAC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EAAE,EAAE,CAAC;QAC7B,KAAK,CAAC,UAAU,GAAG,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["export { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashToolSystemPromptContribution,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n\ttype ShellToolPresentation,\n} from \"./bash.js\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\teditToolSystemPromptContribution,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tfindToolSystemPromptContribution,\n} from \"./find.ts\";\nexport { createKillTool, createKillToolDefinition, type KillToolOptions } from \"./kill.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\tlsToolSystemPromptContribution,\n} from \"./ls.ts\";\nexport {\n\tcreateLocalPowerShellOperations,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\ttype PowerShellOperations,\n\ttype PowerShellSpawnContext,\n\ttype PowerShellSpawnHook,\n\ttype PowerShellToolDetails,\n\ttype PowerShellToolInput,\n\ttype PowerShellToolOptions,\n} from \"./powershell.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\treadToolSystemPromptContribution,\n} from \"./read.ts\";\nexport {\n\tcreateSearchTool,\n\tcreateSearchToolDefinition,\n\ttype SearchToolDetails,\n\ttype SearchToolInput,\n\ttype SearchToolOptions,\n\tsearchToolSystemPromptContribution,\n} from \"./search.ts\";\nexport {\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\ttype JsonObject,\n\ttype JsonPrimitive,\n\ttype JsonValue,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\ttype StructuredOutputCapture,\n\ttype StructuredOutputFileCapture,\n\ttype StructuredOutputToolOptions,\n} from \"./structured-output.ts\";\nexport { createTodoToolDefinition } from \"./todos.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twriteToolSystemPromptContribution,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { TSchema } from \"typebox\";\nimport { isPowerShellAvailable } from \"../../utils/shell.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.js\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createHashlineSnapshotStore, type HashlineSnapshotStore } from \"./hashline.ts\";\nimport { createKillTool, createKillToolDefinition, type KillToolOptions } from \"./kill.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPowerShellTool, createPowerShellToolDefinition, type PowerShellToolOptions } from \"./powershell.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSearchTool, createSearchToolDefinition, type SearchToolOptions } from \"./search.ts\";\nimport { createTodoToolDefinition } from \"./todos.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<TSchema, unknown>;\nexport type ToolDef = ToolDefinition<TSchema, unknown>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"powershell\"\n\t| \"kill\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"find\"\n\t| \"search\"\n\t| \"ls\"\n\t| \"ask_user_question\"\n\t| \"todo\";\nexport type BuiltinToolMap<T> = Omit<Record<ToolName, T>, \"powershell\"> & { powershell?: T };\n// The universe of built-in tool names, matching the `ToolName` union exactly.\n// Availability is decided per platform in `getDefaultToolNames()` and\n// `createAllToolDefinitions()`; this set stays static so a name is never\n// \"unknown\" merely because the host cannot run it.\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"powershell\",\n\t\"kill\",\n\t\"edit\",\n\t\"write\",\n\t\"find\",\n\t\"search\",\n\t\"ls\",\n\t\"ask_user_question\",\n\t\"todo\",\n]);\n\n/**\n * Built-in tools enabled at startup.\n *\n * `powershell` is conditional: it is Windows-only and additionally needs a\n * resolvable `pwsh.exe`/`powershell.exe`. That probe reads PATH, so it runs per\n * call rather than at module load, and callers can decide it explicitly through\n * `powerShellAvailable` instead of depending on the host running the process.\n */\nexport function getDefaultToolNames(options?: { powerShellAvailable?: boolean }): readonly ToolName[] {\n\tconst powerShell = options?.powerShellAvailable ?? isPowerShellAvailable();\n\treturn [\n\t\t\"read\",\n\t\t\"bash\",\n\t\t...(powerShell ? ([\"powershell\"] as const satisfies readonly ToolName[]) : []),\n\t\t\"kill\",\n\t\t\"edit\",\n\t\t\"write\",\n\t\t\"find\",\n\t\t\"search\",\n\t\t\"ask_user_question\",\n\t\t\"todo\",\n\t];\n}\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\tpowershell?: PowerShellToolOptions;\n\tkill?: KillToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tfind?: FindToolOptions;\n\tsearch?: SearchToolOptions;\n\tls?: LsToolOptions;\n\thashlineStore?: HashlineSnapshotStore;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\t// Default a shared store so the singular factories don't hand read/edit/\n\t// write/search isolated stores (which silently degrades drift recovery).\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, { ...options?.read, hashlineStore });\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"powershell\":\n\t\t\treturn createPowerShellToolDefinition(cwd, options?.powershell);\n\t\tcase \"kill\":\n\t\t\treturn createKillToolDefinition(options?.kill);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, { ...options?.edit, hashlineStore });\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, { ...options?.write, hashlineStore });\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"search\":\n\t\t\treturn createSearchToolDefinition(cwd, { ...options?.search, hashlineStore });\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"ask_user_question\":\n\t\t\treturn createAskUserQuestionToolDefinition();\n\t\tcase \"todo\":\n\t\t\treturn createTodoToolDefinition(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, { ...options?.read, hashlineStore });\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"powershell\":\n\t\t\treturn createPowerShellTool(cwd, options?.powershell);\n\t\tcase \"kill\":\n\t\t\treturn createKillTool(options?.kill);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, { ...options?.edit, hashlineStore });\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, { ...options?.write, hashlineStore });\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"search\":\n\t\t\treturn createSearchTool(cwd, { ...options?.search, hashlineStore });\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"ask_user_question\":\n\t\t\treturn wrapToolDefinition(createAskUserQuestionToolDefinition());\n\t\tcase \"todo\":\n\t\t\treturn wrapToolDefinition(createTodoToolDefinition(cwd));\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateKillToolDefinition(options?.kill),\n\t\tcreateEditToolDefinition(cwd, { ...options?.edit, hashlineStore }),\n\t\tcreateWriteToolDefinition(cwd, { ...options?.write, hashlineStore }),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): BuiltinToolMap<ToolDef> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst definitions: BuiltinToolMap<ToolDef> = {\n\t\tread: createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tkill: createKillToolDefinition(options?.kill),\n\t\tedit: createEditToolDefinition(cwd, { ...options?.edit, hashlineStore }),\n\t\twrite: createWriteToolDefinition(cwd, { ...options?.write, hashlineStore }),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tsearch: createSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\task_user_question: createAskUserQuestionToolDefinition(),\n\t\ttodo: createTodoToolDefinition(cwd),\n\t};\n\tif (isPowerShellAvailable()) {\n\t\tdefinitions.powershell = createPowerShellToolDefinition(cwd, options?.powershell);\n\t}\n\treturn definitions;\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateKillTool(options?.kill),\n\t\tcreateEditTool(cwd, { ...options?.edit, hashlineStore }),\n\t\tcreateWriteTool(cwd, { ...options?.write, hashlineStore }),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): BuiltinToolMap<Tool> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst tools: BuiltinToolMap<Tool> = {\n\t\tread: createReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tkill: createKillTool(options?.kill),\n\t\tedit: createEditTool(cwd, { ...options?.edit, hashlineStore }),\n\t\twrite: createWriteTool(cwd, { ...options?.write, hashlineStore }),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tsearch: createSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\task_user_question: wrapToolDefinition(createAskUserQuestionToolDefinition()),\n\t\ttodo: wrapToolDefinition(createTodoToolDefinition(cwd)),\n\t};\n\tif (isPowerShellAvailable()) {\n\t\ttools.powershell = createPowerShellTool(cwd, options?.powershell);\n\t}\n\treturn tools;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EACN,uBAAuB,EAOvB,gCAAgC,EAChC,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GAEzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EAKxB,gCAAgC,GAChC,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,GAOpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB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C;QACF,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE;YAC3B,GAAG,OAAO,EAAE,KAAK;YACjB,aAAa;YACb,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjE,CAAC;QACF,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,MAAM,EAAE,gBAAgB,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACpE,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,iBAAiB,EAAE,kBAAkB,CAAC,mCAAmC,EAAE,CAAC;QAC5E,IAAI,EAAE,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;KACvD,CAAC;IACF,IAAI,qBAAqB,EAAE,EAAE,CAAC;QAC7B,KAAK,CAAC,UAAU,GAAG,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["export { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashToolSystemPromptContribution,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n\ttype ShellToolPresentation,\n} from \"./bash.js\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\teditToolSystemPromptContribution,\n} from \"./edit.ts\";\nexport {\n\tFILE_MUTATION_CONFLICT_CODE,\n\tFileMutationConflict,\n\ttype FileMutationConflictDetails,\n\ttype FileMutationConflictEvidence,\n\ttype FileMutationConflictReason,\n\ttype FileMutationLiveState,\n\ttype MutationRequester,\n\ttype MutationRequesterResolver,\n} from \"./file-mutation-coordinator.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tfindToolSystemPromptContribution,\n} from \"./find.ts\";\nexport { createKillTool, createKillToolDefinition, type KillToolOptions } from \"./kill.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\tlsToolSystemPromptContribution,\n} from \"./ls.ts\";\nexport {\n\tcreateLocalPowerShellOperations,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\ttype PowerShellOperations,\n\ttype PowerShellSpawnContext,\n\ttype PowerShellSpawnHook,\n\ttype PowerShellToolDetails,\n\ttype PowerShellToolInput,\n\ttype PowerShellToolOptions,\n} from \"./powershell.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\treadToolSystemPromptContribution,\n} from \"./read.ts\";\nexport {\n\tcreateSearchTool,\n\tcreateSearchToolDefinition,\n\ttype SearchToolDetails,\n\ttype SearchToolInput,\n\ttype SearchToolOptions,\n\tsearchToolSystemPromptContribution,\n} from \"./search.ts\";\nexport {\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\ttype JsonObject,\n\ttype JsonPrimitive,\n\ttype JsonValue,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\ttype StructuredOutputCapture,\n\ttype StructuredOutputFileCapture,\n\ttype StructuredOutputToolOptions,\n} from \"./structured-output.ts\";\nexport { createTodoToolDefinition } from \"./todos.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteFileOptions,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twriteToolSystemPromptContribution,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { TSchema } from \"typebox\";\nimport { isPowerShellAvailable } from \"../../utils/shell.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { createAskUserQuestionToolDefinition } from \"./ask-user-question/index.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.js\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport type { MutationRequesterResolver } from \"./file-mutation-coordinator.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createHashlineSnapshotStore, type HashlineSnapshotStore } from \"./hashline.ts\";\nimport { createKillTool, createKillToolDefinition, type KillToolOptions } from \"./kill.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPowerShellTool, createPowerShellToolDefinition, type PowerShellToolOptions } from \"./powershell.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSearchTool, createSearchToolDefinition, type SearchToolOptions } from \"./search.ts\";\nimport { createTodoToolDefinition } from \"./todos.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<TSchema, unknown>;\nexport type ToolDef = ToolDefinition<TSchema, unknown>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"powershell\"\n\t| \"kill\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"find\"\n\t| \"search\"\n\t| \"ls\"\n\t| \"ask_user_question\"\n\t| \"todo\";\nexport type BuiltinToolMap<T> = Omit<Record<ToolName, T>, \"powershell\"> & { powershell?: T };\n// The universe of built-in tool names, matching the `ToolName` union exactly.\n// Availability is decided per platform in `getDefaultToolNames()` and\n// `createAllToolDefinitions()`; this set stays static so a name is never\n// \"unknown\" merely because the host cannot run it.\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"powershell\",\n\t\"kill\",\n\t\"edit\",\n\t\"write\",\n\t\"find\",\n\t\"search\",\n\t\"ls\",\n\t\"ask_user_question\",\n\t\"todo\",\n]);\n\n/**\n * Built-in tools enabled at startup.\n *\n * `powershell` is conditional: it is Windows-only and additionally needs a\n * resolvable `pwsh.exe`/`powershell.exe`. That probe reads PATH, so it runs per\n * call rather than at module load, and callers can decide it explicitly through\n * `powerShellAvailable` instead of depending on the host running the process.\n */\nexport function getDefaultToolNames(options?: { powerShellAvailable?: boolean }): readonly ToolName[] {\n\tconst powerShell = options?.powerShellAvailable ?? isPowerShellAvailable();\n\treturn [\n\t\t\"read\",\n\t\t\"bash\",\n\t\t...(powerShell ? ([\"powershell\"] as const satisfies readonly ToolName[]) : []),\n\t\t\"kill\",\n\t\t\"edit\",\n\t\t\"write\",\n\t\t\"find\",\n\t\t\"search\",\n\t\t\"ask_user_question\",\n\t\t\"todo\",\n\t];\n}\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\tpowershell?: PowerShellToolOptions;\n\tkill?: KillToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tfind?: FindToolOptions;\n\tsearch?: SearchToolOptions;\n\tls?: LsToolOptions;\n\thashlineStore?: HashlineSnapshotStore;\n\t/**\n\t * Session-scoped identity for whichever mutation gets rejected, forwarded to the two tools\n\t * that can raise a conflict. Deliberately not defaulted the way `hashlineStore` is: absence\n\t * means no identity is available, which the conflict path already handles.\n\t */\n\tresolveMutationRequester?: MutationRequesterResolver;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\t// Default a shared store so the singular factories don't hand read/edit/\n\t// write/search isolated stores (which silently degrades drift recovery).\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, { ...options?.read, hashlineStore });\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"powershell\":\n\t\t\treturn createPowerShellToolDefinition(cwd, options?.powershell);\n\t\tcase \"kill\":\n\t\t\treturn createKillToolDefinition(options?.kill);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, {\n\t\t\t\t...options?.edit,\n\t\t\t\thashlineStore,\n\t\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t\t});\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, {\n\t\t\t\t...options?.write,\n\t\t\t\thashlineStore,\n\t\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t\t});\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"search\":\n\t\t\treturn createSearchToolDefinition(cwd, { ...options?.search, hashlineStore });\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"ask_user_question\":\n\t\t\treturn createAskUserQuestionToolDefinition();\n\t\tcase \"todo\":\n\t\t\treturn createTodoToolDefinition(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, { ...options?.read, hashlineStore });\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"powershell\":\n\t\t\treturn createPowerShellTool(cwd, options?.powershell);\n\t\tcase \"kill\":\n\t\t\treturn createKillTool(options?.kill);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, {\n\t\t\t\t...options?.edit,\n\t\t\t\thashlineStore,\n\t\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t\t});\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, {\n\t\t\t\t...options?.write,\n\t\t\t\thashlineStore,\n\t\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t\t});\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"search\":\n\t\t\treturn createSearchTool(cwd, { ...options?.search, hashlineStore });\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"ask_user_question\":\n\t\t\treturn wrapToolDefinition(createAskUserQuestionToolDefinition());\n\t\tcase \"todo\":\n\t\t\treturn wrapToolDefinition(createTodoToolDefinition(cwd));\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\treturn [\n\t\tcreateReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateKillToolDefinition(options?.kill),\n\t\tcreateEditToolDefinition(cwd, {\n\t\t\t...options?.edit,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\tcreateWriteToolDefinition(cwd, {\n\t\t\t...options?.write,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): BuiltinToolMap<ToolDef> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\tconst definitions: BuiltinToolMap<ToolDef> = {\n\t\tread: createReadToolDefinition(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tkill: createKillToolDefinition(options?.kill),\n\t\tedit: createEditToolDefinition(cwd, {\n\t\t\t...options?.edit,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\twrite: createWriteToolDefinition(cwd, {\n\t\t\t...options?.write,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tsearch: createSearchToolDefinition(cwd, { ...options?.search, hashlineStore }),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\task_user_question: createAskUserQuestionToolDefinition(),\n\t\ttodo: createTodoToolDefinition(cwd),\n\t};\n\tif (isPowerShellAvailable()) {\n\t\tdefinitions.powershell = createPowerShellToolDefinition(cwd, options?.powershell);\n\t}\n\treturn definitions;\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\treturn [\n\t\tcreateReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateKillTool(options?.kill),\n\t\tcreateEditTool(cwd, {\n\t\t\t...options?.edit,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\tcreateWriteTool(cwd, {\n\t\t\t...options?.write,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn [\n\t\tcreateReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): BuiltinToolMap<Tool> {\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\tconst tools: BuiltinToolMap<Tool> = {\n\t\tread: createReadTool(cwd, { ...options?.read, hashlineStore }),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tkill: createKillTool(options?.kill),\n\t\tedit: createEditTool(cwd, {\n\t\t\t...options?.edit,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\twrite: createWriteTool(cwd, {\n\t\t\t...options?.write,\n\t\t\thashlineStore,\n\t\t\t...(resolveMutationRequester ? { resolveMutationRequester } : {}),\n\t\t}),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tsearch: createSearchTool(cwd, { ...options?.search, hashlineStore }),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\task_user_question: wrapToolDefinition(createAskUserQuestionToolDefinition()),\n\t\ttodo: wrapToolDefinition(createTodoToolDefinition(cwd)),\n\t};\n\tif (isPowerShellAvailable()) {\n\t\ttools.powershell = createPowerShellTool(cwd, options?.powershell);\n\t}\n\treturn tools;\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Snapshot, SnapshotStore } from "./hashline-engine/index.ts";
|
|
2
|
+
/**
|
|
3
|
+
* {@link SnapshotStore} decorator that answers every read from the session's real store but
|
|
4
|
+
* never persists anything through {@link NonMintingSnapshotStore.record}.
|
|
5
|
+
*
|
|
6
|
+
* It exists because building a hashline rejection mints provenance. `Patcher`'s mismatch path
|
|
7
|
+
* records the live file into the snapshot store before constructing the error, then hands the
|
|
8
|
+
* model that tag as `actualFileHash`. An identical retry quoting that tag validates, because
|
|
9
|
+
* the tag now names content the store has seen, even though the model never re-read the file.
|
|
10
|
+
* The rejection issues the credential that defeats it.
|
|
11
|
+
*
|
|
12
|
+
* The engine is vendored and must not be edited, so the fix is injected at the single
|
|
13
|
+
* `new Patcher(...)` construction site instead. That is safe because every record the patcher
|
|
14
|
+
* would make is either unreachable or redundant when it is driven by the edit tool:
|
|
15
|
+
*
|
|
16
|
+
* - `commit()`'s no-op branch never runs. `edit.ts` filters no-op sections and returns before
|
|
17
|
+
* `apply` is ever called.
|
|
18
|
+
* - `commit()`'s post-write record is duplicated by `recordHashlineSnapshot` in `edit.ts`,
|
|
19
|
+
* which is also what populates the display-header map the patcher bypasses. That call stays
|
|
20
|
+
* the single writer of provenance.
|
|
21
|
+
* - The mismatch record is the bug.
|
|
22
|
+
*
|
|
23
|
+
* Reads delegate, so `Recovery` still resolves stale tags against the real per-session history
|
|
24
|
+
* and in-session drift recovery is unchanged.
|
|
25
|
+
*
|
|
26
|
+
* @see https://github.com/bastani-inc/atomic/issues/2329
|
|
27
|
+
*/
|
|
28
|
+
export declare class NonMintingSnapshotStore extends SnapshotStore {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(inner: SnapshotStore);
|
|
31
|
+
head(path: string): Snapshot | null;
|
|
32
|
+
byHash(path: string, hash: string): Snapshot | null;
|
|
33
|
+
/**
|
|
34
|
+
* Delegated rather than inherited. The base implementation is derived from
|
|
35
|
+
* {@link SnapshotStore.byHash}, but `InMemorySnapshotStore` overrides it with different
|
|
36
|
+
* hash-collision semantics, and a decorator must present whichever the wrapped store
|
|
37
|
+
* actually implements.
|
|
38
|
+
*/
|
|
39
|
+
byHashAndText(path: string, hash: string, text: string): Snapshot | null;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the tag the content would receive without retaining it, so a tag quoted back in
|
|
42
|
+
* an error never becomes valid provenance. Callers that legitimately need to record a
|
|
43
|
+
* snapshot do so against the session store directly.
|
|
44
|
+
*/
|
|
45
|
+
record(_path: string, fullText: string): string;
|
|
46
|
+
invalidate(path: string): void;
|
|
47
|
+
clear(): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=non-minting-snapshot-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-minting-snapshot-store.d.ts","sourceRoot":"","sources":["../../../src/core/tools/non-minting-snapshot-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,QAAQ,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,uBAAwB,SAAQ,aAAa;;IAGzD,YAAY,KAAK,EAAE,aAAa,EAG/B;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAElC;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAElD;IAED;;;;;OAKG;IACM,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAEhF;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9C;IAED,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE7B;IAED,KAAK,IAAI,IAAI,CAEZ;CACD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { computeFileHash, SnapshotStore } from "./hashline-engine/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* {@link SnapshotStore} decorator that answers every read from the session's real store but
|
|
4
|
+
* never persists anything through {@link NonMintingSnapshotStore.record}.
|
|
5
|
+
*
|
|
6
|
+
* It exists because building a hashline rejection mints provenance. `Patcher`'s mismatch path
|
|
7
|
+
* records the live file into the snapshot store before constructing the error, then hands the
|
|
8
|
+
* model that tag as `actualFileHash`. An identical retry quoting that tag validates, because
|
|
9
|
+
* the tag now names content the store has seen, even though the model never re-read the file.
|
|
10
|
+
* The rejection issues the credential that defeats it.
|
|
11
|
+
*
|
|
12
|
+
* The engine is vendored and must not be edited, so the fix is injected at the single
|
|
13
|
+
* `new Patcher(...)` construction site instead. That is safe because every record the patcher
|
|
14
|
+
* would make is either unreachable or redundant when it is driven by the edit tool:
|
|
15
|
+
*
|
|
16
|
+
* - `commit()`'s no-op branch never runs. `edit.ts` filters no-op sections and returns before
|
|
17
|
+
* `apply` is ever called.
|
|
18
|
+
* - `commit()`'s post-write record is duplicated by `recordHashlineSnapshot` in `edit.ts`,
|
|
19
|
+
* which is also what populates the display-header map the patcher bypasses. That call stays
|
|
20
|
+
* the single writer of provenance.
|
|
21
|
+
* - The mismatch record is the bug.
|
|
22
|
+
*
|
|
23
|
+
* Reads delegate, so `Recovery` still resolves stale tags against the real per-session history
|
|
24
|
+
* and in-session drift recovery is unchanged.
|
|
25
|
+
*
|
|
26
|
+
* @see https://github.com/bastani-inc/atomic/issues/2329
|
|
27
|
+
*/
|
|
28
|
+
export class NonMintingSnapshotStore extends SnapshotStore {
|
|
29
|
+
#inner;
|
|
30
|
+
constructor(inner) {
|
|
31
|
+
super();
|
|
32
|
+
this.#inner = inner;
|
|
33
|
+
}
|
|
34
|
+
head(path) {
|
|
35
|
+
return this.#inner.head(path);
|
|
36
|
+
}
|
|
37
|
+
byHash(path, hash) {
|
|
38
|
+
return this.#inner.byHash(path, hash);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Delegated rather than inherited. The base implementation is derived from
|
|
42
|
+
* {@link SnapshotStore.byHash}, but `InMemorySnapshotStore` overrides it with different
|
|
43
|
+
* hash-collision semantics, and a decorator must present whichever the wrapped store
|
|
44
|
+
* actually implements.
|
|
45
|
+
*/
|
|
46
|
+
byHashAndText(path, hash, text) {
|
|
47
|
+
return this.#inner.byHashAndText(path, hash, text);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the tag the content would receive without retaining it, so a tag quoted back in
|
|
51
|
+
* an error never becomes valid provenance. Callers that legitimately need to record a
|
|
52
|
+
* snapshot do so against the session store directly.
|
|
53
|
+
*/
|
|
54
|
+
record(_path, fullText) {
|
|
55
|
+
return computeFileHash(fullText);
|
|
56
|
+
}
|
|
57
|
+
invalidate(path) {
|
|
58
|
+
this.#inner.invalidate(path);
|
|
59
|
+
}
|
|
60
|
+
clear() {
|
|
61
|
+
this.#inner.clear();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=non-minting-snapshot-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-minting-snapshot-store.js","sourceRoot":"","sources":["../../../src/core/tools/non-minting-snapshot-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAiB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,uBAAwB,SAAQ,aAAa;IAChD,MAAM,CAAgB;IAE/B,YAAY,KAAoB;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,IAAY,EAAE,IAAY;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACM,aAAa,CAAC,IAAY,EAAE,IAAY,EAAE,IAAY;QAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAa,EAAE,QAAgB;QACrC,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,UAAU,CAAC,IAAY;QACtB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACD","sourcesContent":["import { computeFileHash, type Snapshot, SnapshotStore } from \"./hashline-engine/index.ts\";\n\n/**\n * {@link SnapshotStore} decorator that answers every read from the session's real store but\n * never persists anything through {@link NonMintingSnapshotStore.record}.\n *\n * It exists because building a hashline rejection mints provenance. `Patcher`'s mismatch path\n * records the live file into the snapshot store before constructing the error, then hands the\n * model that tag as `actualFileHash`. An identical retry quoting that tag validates, because\n * the tag now names content the store has seen, even though the model never re-read the file.\n * The rejection issues the credential that defeats it.\n *\n * The engine is vendored and must not be edited, so the fix is injected at the single\n * `new Patcher(...)` construction site instead. That is safe because every record the patcher\n * would make is either unreachable or redundant when it is driven by the edit tool:\n *\n * - `commit()`'s no-op branch never runs. `edit.ts` filters no-op sections and returns before\n * `apply` is ever called.\n * - `commit()`'s post-write record is duplicated by `recordHashlineSnapshot` in `edit.ts`,\n * which is also what populates the display-header map the patcher bypasses. That call stays\n * the single writer of provenance.\n * - The mismatch record is the bug.\n *\n * Reads delegate, so `Recovery` still resolves stale tags against the real per-session history\n * and in-session drift recovery is unchanged.\n *\n * @see https://github.com/bastani-inc/atomic/issues/2329\n */\nexport class NonMintingSnapshotStore extends SnapshotStore {\n\treadonly #inner: SnapshotStore;\n\n\tconstructor(inner: SnapshotStore) {\n\t\tsuper();\n\t\tthis.#inner = inner;\n\t}\n\n\thead(path: string): Snapshot | null {\n\t\treturn this.#inner.head(path);\n\t}\n\n\tbyHash(path: string, hash: string): Snapshot | null {\n\t\treturn this.#inner.byHash(path, hash);\n\t}\n\n\t/**\n\t * Delegated rather than inherited. The base implementation is derived from\n\t * {@link SnapshotStore.byHash}, but `InMemorySnapshotStore` overrides it with different\n\t * hash-collision semantics, and a decorator must present whichever the wrapped store\n\t * actually implements.\n\t */\n\toverride byHashAndText(path: string, hash: string, text: string): Snapshot | null {\n\t\treturn this.#inner.byHashAndText(path, hash, text);\n\t}\n\n\t/**\n\t * Returns the tag the content would receive without retaining it, so a tag quoted back in\n\t * an error never becomes valid provenance. Callers that legitimately need to record a\n\t * snapshot do so against the session store directly.\n\t */\n\trecord(_path: string, fullText: string): string {\n\t\treturn computeFileHash(fullText);\n\t}\n\n\tinvalidate(path: string): void {\n\t\tthis.#inner.invalidate(path);\n\t}\n\n\tclear(): void {\n\t\tthis.#inner.clear();\n\t}\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { type BashOperations, type BashSpawnContext, type BashSpawnHook, type Ba
|
|
|
2
2
|
import { type SupervisedCommandOwner } from "./bash-pty-native.js";
|
|
3
3
|
export declare const powershellToolSystemPromptContribution: Readonly<{
|
|
4
4
|
readonly snippet: "Execute PowerShell commands.";
|
|
5
|
-
readonly guidelines: readonly ["You can inspect ATOMIC_* or PI_* environment variables for current model and session details.", "Use { action: \"wait\", id: taskId
|
|
5
|
+
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."];
|
|
6
6
|
}>;
|
|
7
7
|
export type PowerShellOperations = BashOperations;
|
|
8
8
|
export type PowerShellToolDetails = BashToolDetails;
|
|
@@ -126,7 +126,7 @@ export declare function createPowerShellToolDefinition(cwd: string, options?: Po
|
|
|
126
126
|
} & Partial<Record<"command" | "cwd" | "env" | "pty" | "timeout" | "wait", never>>), signal: AbortSignal | undefined, onUpdate: import("@earendil-works/pi-agent-core").AgentToolUpdateCallback<BashToolDetails | undefined> | undefined, ctx: import("../sdk-exports.ts").ExtensionContext): Promise<import("@earendil-works/pi-agent-core").AgentToolResult<BashToolDetails | undefined>>;
|
|
127
127
|
description: string;
|
|
128
128
|
promptSnippet: "Execute PowerShell commands.";
|
|
129
|
-
promptGuidelines: ("Use { action: \"wait\", id: taskId
|
|
129
|
+
promptGuidelines: ("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." | "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." | "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." | "You can inspect ATOMIC_* or PI_* environment variables for current model and session details.")[] | undefined;
|
|
130
130
|
};
|
|
131
131
|
export declare function createPowerShellTool(cwd: string, options?: PowerShellToolOptions): import("@earendil-works/pi-agent-core").AgentTool<import("typebox").TUnsafe<({
|
|
132
132
|
command: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../../src/core/tools/powershell.ts"],"names":[],"mappings":"AASA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../../src/core/tools/powershell.ts"],"names":[],"mappings":"AASA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EAKpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAGN,KAAK,sBAAsB,EAE3B,MAAM,sBAAsB,CAAC;AAS9B,eAAO,MAAM,sCAAsC;sBACzC,8BAA8B;;EAE7B,CAAC;AACZ,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAClD,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC;AACpD,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAChD,MAAM,WAAW,qBAChB,SAAQ,IAAI,CAAC,eAAe,EAAE,0BAA0B,GAAG,WAAW,GAAG,WAAW,CAAC;IACrF,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AACD,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE;IACzD,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACnC,GAAG,oBAAoB,CA0DvB;AACD,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgC9F;AACD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;;;;;;;;;;;;;;;mHAEhF;AACD,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACtD,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APP_NAME } from "../../config.js";
|
|
2
2
|
import { createChildProcessEnvironment, waitForChildProcess } from "../../utils/child-process.js";
|
|
3
3
|
import { getPowerShellConfig, getShellEnv, killProcessTree, trackDetachedChildPid, untrackDetachedChildPid, } from "../../utils/shell.js";
|
|
4
|
-
import { createBashToolDefinition, validateExplicitTimeoutSeconds, } from "./bash.js";
|
|
4
|
+
import { bashToolSystemPromptContribution, createBashToolDefinition, validateExplicitTimeoutSeconds, } from "./bash.js";
|
|
5
5
|
import { executeNativePty, executeSupervisedCommand, validateBashWait, } from "./bash-pty-native.js";
|
|
6
6
|
import { wrapToolDefinition } from "./tool-definition-wrapper.js";
|
|
7
7
|
const POWERSHELL_PRESENTATION = {
|
|
@@ -11,10 +11,7 @@ const POWERSHELL_PRESENTATION = {
|
|
|
11
11
|
const UTF8_OUTPUT_PREFIX = "try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}\n";
|
|
12
12
|
export const powershellToolSystemPromptContribution = Object.freeze({
|
|
13
13
|
snippet: "Execute PowerShell commands.",
|
|
14
|
-
guidelines:
|
|
15
|
-
"You can inspect ATOMIC_* or PI_* environment variables for current model and session details.",
|
|
16
|
-
'Use { action: "wait", id: taskId, budgetMs: 1000 } to observe an existing shell task without executing another command. Omit budgetMs for owner policy; zero polls. Waiting does not extend execution timeout or owner lifetime.',
|
|
17
|
-
]),
|
|
14
|
+
guidelines: bashToolSystemPromptContribution.guidelines,
|
|
18
15
|
});
|
|
19
16
|
export function createLocalPowerShellOperations(binding) {
|
|
20
17
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powershell.js","sourceRoot":"","sources":["../../../src/core/tools/powershell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EACN,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAON,wBAAwB,EAExB,8BAA8B,GAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EAExB,gBAAgB,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,uBAAuB,GAA0B;IACtD,MAAM,EAAE,KAAK;IACb,cAAc,EAAE,GAAG,QAAQ,aAAa;CACxC,CAAC;AAEF,MAAM,kBAAkB,GAAG,2EAA2E,CAAC;AACvG,MAAM,CAAC,MAAM,sCAAsC,GAAG,MAAM,CAAC,MAAM,CAAC;IACnE,OAAO,EAAE,8BAA8B;IACvC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC;QACzB,+FAA+F;QAC/F,kOAAkO;KACzN,CAAC;CACF,CAAC,CAAC;AAQZ,MAAM,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S,CAAC;QAC1B,CAAC;QACD,YAAY,EAAE,YAAY;QAC1B,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,+BAA+B,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;KACnG,EACD,uBAAuB,CACvB,CAAC;IACF,OAAO;QACN,GAAG,UAAU;QACb,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,YAAY;QACnB,KAAK,CAAC,OAAO,CAAC,GAAG,IAA2C;YAC3D,mEAAmE;YACnE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS;gBAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC9G,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,WAAW,EACV,mSAAmS;QACpS,aAAa,EAAE,sCAAsC,CAAC,OAAO;QAC7D,gBAAgB,EACf,OAAO,CAAC,wBAAwB,KAAK,KAAK;YACzC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,GAAG,sCAAsC,CAAC,UAAU,CAAC;KAC1D,CAAC;AACH,CAAC;AACD,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,OAA+B;IAChF,OAAO,kBAAkB,CAAC,8BAA8B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { APP_NAME } from \"../../config.js\";\nimport { createChildProcessEnvironment, waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetPowerShellConfig,\n\tgetShellEnv,\n\tkillProcessTree,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\ttype ShellToolPresentation,\n\tvalidateExplicitTimeoutSeconds,\n} from \"./bash.js\";\nimport {\n\texecuteNativePty,\n\texecuteSupervisedCommand,\n\ttype SupervisedCommandOwner,\n\tvalidateBashWait,\n} from \"./bash-pty-native.js\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst POWERSHELL_PRESENTATION: ShellToolPresentation = {\n\tprompt: \"PS>\",\n\ttempFilePrefix: `${APP_NAME}-powershell`,\n};\n\nconst UTF8_OUTPUT_PREFIX = \"try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}\\n\";\nexport const powershellToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Execute PowerShell commands.\",\n\tguidelines: Object.freeze([\n\t\t\"You can inspect ATOMIC_* or PI_* environment variables for current model and session details.\",\n\t\t'Use { action: \"wait\", id: taskId, budgetMs: 1000 } to observe an existing shell task without executing another command. Omit budgetMs for owner policy; zero polls. Waiting does not extend execution timeout or owner lifetime.',\n\t] as const),\n} as const);\nexport type PowerShellOperations = BashOperations;\nexport type PowerShellToolDetails = BashToolDetails;\nexport type PowerShellToolInput = BashToolInput;\nexport interface PowerShellToolOptions\n\textends Pick<BashToolOptions, \"exposeSessionEnvironment\" | \"spawnHook\" | \"taskOwner\"> {\n\toperations?: BashOperations;\n}\nexport function createLocalPowerShellOperations(binding?: {\n\ttaskOwner?: SupervisedCommandOwner;\n}): PowerShellOperations {\n\treturn {\n\t\texec: async (command, cwd, options) => {\n\t\t\tvalidateBashWait(options.wait, !!binding?.taskOwner);\n\t\t\tif (options.timeout !== undefined) validateExplicitTimeoutSeconds(options.timeout);\n\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst { shell, args } = getPowerShellConfig();\n\t\t\tconst pty = !!options.pty && process.env.PI_NO_PTY !== \"1\" && process.env.ATOMIC_NO_PTY !== \"1\";\n\t\t\tif (binding?.taskOwner || pty) {\n\t\t\t\t// EncodedCommand avoids native argument parsing differences between PowerShell 5 and 7.\n\t\t\t\tconst encoded = Buffer.from(`${UTF8_OUTPUT_PREFIX}${command}`, \"utf16le\").toString(\"base64\");\n\t\t\t\tconst execution = {\n\t\t\t\t\t...options,\n\t\t\t\t\tshellConfig: { shell, args: [...args.slice(0, -1), \"-EncodedCommand\"] },\n\t\t\t\t\tcommandDescription: command,\n\t\t\t\t\ttaskOwner: binding?.taskOwner,\n\t\t\t\t};\n\t\t\t\treturn binding?.taskOwner\n\t\t\t\t\t? executeSupervisedCommand(encoded, cwd, execution, pty)\n\t\t\t\t\t: executeNativePty(encoded, cwd, execution);\n\t\t\t}\n\t\t\tconst { spawn } = await import(\"node:child_process\");\n\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst child = spawn(shell, [...args, `${UTF8_OUTPUT_PREFIX}${command}`], {\n\t\t\t\tcwd,\n\t\t\t\tenv: createChildProcessEnvironment(undefined, options.env ?? getShellEnv()),\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: ReturnType<typeof setTimeout> | undefined;\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tif (options.timeout !== undefined && options.timeout > 0) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\t\t}, options.timeout * 1000);\n\t\t\t\t}\n\t\t\t\tchild.stdout?.on(\"data\", (data: Buffer) => options.onData(data, \"stdout\"));\n\t\t\t\tchild.stderr?.on(\"data\", (data: Buffer) => options.onData(data, \"stderr\"));\n\t\t\t\tif (options.signal) {\n\t\t\t\t\tif (options.signal.aborted) onAbort();\n\t\t\t\t\telse options.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\tconst exitCode = await waitForChildProcess(child);\n\t\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\t\tif (timedOut) throw new Error(`timeout:${options.timeout}`);\n\t\t\t\treturn { exitCode };\n\t\t\t} finally {\n\t\t\t\tif (child.pid) untrackDetachedChildPid(child.pid);\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\nexport function createPowerShellToolDefinition(cwd: string, options: PowerShellToolOptions = {}) {\n\tconst definition = createBashToolDefinition(\n\t\tcwd,\n\t\t{\n\t\t\texposeSessionEnvironment: options.exposeSessionEnvironment,\n\t\t\tspawnHook: options.spawnHook,\n\t\t\t// Preserve lazy session ownership instead of reading an accessor at registration.\n\t\t\tget taskOwner() {\n\t\t\t\treturn options.taskOwner;\n\t\t\t},\n\t\t\tshellDialect: \"powershell\",\n\t\t\toperations: options.operations ?? createLocalPowerShellOperations({ taskOwner: options.taskOwner }),\n\t\t},\n\t\tPOWERSHELL_PRESENTATION,\n\t);\n\treturn {\n\t\t...definition,\n\t\tname: \"powershell\",\n\t\tlabel: \"powershell\",\n\t\tasync execute(...args: Parameters<typeof definition.execute>) {\n\t\t\t// The internal local adapter is not evidence of a supported owner.\n\t\t\tif (args[1].action === undefined) validateBashWait(args[1].wait, !!options.operations || !!options.taskOwner);\n\t\t\treturn definition.execute(...args);\n\t\t},\n\t\tdescription:\n\t\t\t'Execute a PowerShell command or observe an existing task with action: \"wait\", id, and optional budgetMs. Owner-bound commands automatically yield after 10s by default without stopping execution. Unbound commands wait for completion; background and existing-task waits require a task owner.',\n\t\tpromptSnippet: powershellToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines:\n\t\t\toptions.exposeSessionEnvironment === false\n\t\t\t\t? undefined\n\t\t\t\t: [...powershellToolSystemPromptContribution.guidelines],\n\t};\n}\nexport function createPowerShellTool(cwd: string, options?: PowerShellToolOptions) {\n\treturn wrapToolDefinition(createPowerShellToolDefinition(cwd, options));\n}\nexport type PowerShellSpawnContext = BashSpawnContext;\nexport type PowerShellSpawnHook = BashSpawnHook;\n"]}
|
|
1
|
+
{"version":3,"file":"powershell.js","sourceRoot":"","sources":["../../../src/core/tools/powershell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EACN,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAON,gCAAgC,EAChC,wBAAwB,EAExB,8BAA8B,GAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EAExB,gBAAgB,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,uBAAuB,GAA0B;IACtD,MAAM,EAAE,KAAK;IACb,cAAc,EAAE,GAAG,QAAQ,aAAa;CACxC,CAAC;AAEF,MAAM,kBAAkB,GAAG,2EAA2E,CAAC;AACvG,MAAM,CAAC,MAAM,sCAAsC,GAAG,MAAM,CAAC,MAAM,CAAC;IACnE,OAAO,EAAE,8BAA8B;IACvC,UAAU,EAAE,gCAAgC,CAAC,UAAU;CAC9C,CAAC,CAAC;AAQZ,MAAM,UAAU,+BAA+B,CAAC,OAE/C;IACA,OAAO;QACN,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;YACrC,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACrD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;gBAAE,8BAA8B,CAAC,OAAO,CAA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AAC,OAAO,CAAC,GAAG,IAA2C;YAC3D,mEAAmE;YACnE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS;gBAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC9G,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,WAAW,EACV,mSAAmS;QACpS,aAAa,EAAE,sCAAsC,CAAC,OAAO;QAC7D,gBAAgB,EACf,OAAO,CAAC,wBAAwB,KAAK,KAAK;YACzC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,GAAG,sCAAsC,CAAC,UAAU,CAAC;KAC1D,CAAC;AACH,CAAC;AACD,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,OAA+B;IAChF,OAAO,kBAAkB,CAAC,8BAA8B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { APP_NAME } from \"../../config.js\";\nimport { createChildProcessEnvironment, waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetPowerShellConfig,\n\tgetShellEnv,\n\tkillProcessTree,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tbashToolSystemPromptContribution,\n\tcreateBashToolDefinition,\n\ttype ShellToolPresentation,\n\tvalidateExplicitTimeoutSeconds,\n} from \"./bash.js\";\nimport {\n\texecuteNativePty,\n\texecuteSupervisedCommand,\n\ttype SupervisedCommandOwner,\n\tvalidateBashWait,\n} from \"./bash-pty-native.js\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst POWERSHELL_PRESENTATION: ShellToolPresentation = {\n\tprompt: \"PS>\",\n\ttempFilePrefix: `${APP_NAME}-powershell`,\n};\n\nconst UTF8_OUTPUT_PREFIX = \"try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}\\n\";\nexport const powershellToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Execute PowerShell commands.\",\n\tguidelines: bashToolSystemPromptContribution.guidelines,\n} as const);\nexport type PowerShellOperations = BashOperations;\nexport type PowerShellToolDetails = BashToolDetails;\nexport type PowerShellToolInput = BashToolInput;\nexport interface PowerShellToolOptions\n\textends Pick<BashToolOptions, \"exposeSessionEnvironment\" | \"spawnHook\" | \"taskOwner\"> {\n\toperations?: BashOperations;\n}\nexport function createLocalPowerShellOperations(binding?: {\n\ttaskOwner?: SupervisedCommandOwner;\n}): PowerShellOperations {\n\treturn {\n\t\texec: async (command, cwd, options) => {\n\t\t\tvalidateBashWait(options.wait, !!binding?.taskOwner);\n\t\t\tif (options.timeout !== undefined) validateExplicitTimeoutSeconds(options.timeout);\n\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst { shell, args } = getPowerShellConfig();\n\t\t\tconst pty = !!options.pty && process.env.PI_NO_PTY !== \"1\" && process.env.ATOMIC_NO_PTY !== \"1\";\n\t\t\tif (binding?.taskOwner || pty) {\n\t\t\t\t// EncodedCommand avoids native argument parsing differences between PowerShell 5 and 7.\n\t\t\t\tconst encoded = Buffer.from(`${UTF8_OUTPUT_PREFIX}${command}`, \"utf16le\").toString(\"base64\");\n\t\t\t\tconst execution = {\n\t\t\t\t\t...options,\n\t\t\t\t\tshellConfig: { shell, args: [...args.slice(0, -1), \"-EncodedCommand\"] },\n\t\t\t\t\tcommandDescription: command,\n\t\t\t\t\ttaskOwner: binding?.taskOwner,\n\t\t\t\t};\n\t\t\t\treturn binding?.taskOwner\n\t\t\t\t\t? executeSupervisedCommand(encoded, cwd, execution, pty)\n\t\t\t\t\t: executeNativePty(encoded, cwd, execution);\n\t\t\t}\n\t\t\tconst { spawn } = await import(\"node:child_process\");\n\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst child = spawn(shell, [...args, `${UTF8_OUTPUT_PREFIX}${command}`], {\n\t\t\t\tcwd,\n\t\t\t\tenv: createChildProcessEnvironment(undefined, options.env ?? getShellEnv()),\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: ReturnType<typeof setTimeout> | undefined;\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tif (options.timeout !== undefined && options.timeout > 0) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\t\t}, options.timeout * 1000);\n\t\t\t\t}\n\t\t\t\tchild.stdout?.on(\"data\", (data: Buffer) => options.onData(data, \"stdout\"));\n\t\t\t\tchild.stderr?.on(\"data\", (data: Buffer) => options.onData(data, \"stderr\"));\n\t\t\t\tif (options.signal) {\n\t\t\t\t\tif (options.signal.aborted) onAbort();\n\t\t\t\t\telse options.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\tconst exitCode = await waitForChildProcess(child);\n\t\t\t\tif (options.signal?.aborted) throw new Error(\"aborted\");\n\t\t\t\tif (timedOut) throw new Error(`timeout:${options.timeout}`);\n\t\t\t\treturn { exitCode };\n\t\t\t} finally {\n\t\t\t\tif (child.pid) untrackDetachedChildPid(child.pid);\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\nexport function createPowerShellToolDefinition(cwd: string, options: PowerShellToolOptions = {}) {\n\tconst definition = createBashToolDefinition(\n\t\tcwd,\n\t\t{\n\t\t\texposeSessionEnvironment: options.exposeSessionEnvironment,\n\t\t\tspawnHook: options.spawnHook,\n\t\t\t// Preserve lazy session ownership instead of reading an accessor at registration.\n\t\t\tget taskOwner() {\n\t\t\t\treturn options.taskOwner;\n\t\t\t},\n\t\t\tshellDialect: \"powershell\",\n\t\t\toperations: options.operations ?? createLocalPowerShellOperations({ taskOwner: options.taskOwner }),\n\t\t},\n\t\tPOWERSHELL_PRESENTATION,\n\t);\n\treturn {\n\t\t...definition,\n\t\tname: \"powershell\",\n\t\tlabel: \"powershell\",\n\t\tasync execute(...args: Parameters<typeof definition.execute>) {\n\t\t\t// The internal local adapter is not evidence of a supported owner.\n\t\t\tif (args[1].action === undefined) validateBashWait(args[1].wait, !!options.operations || !!options.taskOwner);\n\t\t\treturn definition.execute(...args);\n\t\t},\n\t\tdescription:\n\t\t\t'Execute a PowerShell command or observe an existing task with action: \"wait\", id, and optional budgetMs. Owner-bound commands automatically yield after 10s by default without stopping execution. Unbound commands wait for completion; background and existing-task waits require a task owner.',\n\t\tpromptSnippet: powershellToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines:\n\t\t\toptions.exposeSessionEnvironment === false\n\t\t\t\t? undefined\n\t\t\t\t: [...powershellToolSystemPromptContribution.guidelines],\n\t};\n}\nexport function createPowerShellTool(cwd: string, options?: PowerShellToolOptions) {\n\treturn wrapToolDefinition(createPowerShellToolDefinition(cwd, options));\n}\nexport type PowerShellSpawnContext = BashSpawnContext;\nexport type PowerShellSpawnHook = BashSpawnHook;\n"]}
|