@namzu/sdk 0.5.0 → 1.0.0
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 +393 -0
- package/dist/advisory/executor.d.ts.map +1 -1
- package/dist/advisory/executor.js +9 -2
- package/dist/advisory/executor.js.map +1 -1
- package/dist/advisory/executor.test.d.ts +2 -1
- package/dist/advisory/executor.test.d.ts.map +1 -1
- package/dist/advisory/executor.test.js +7 -4
- package/dist/advisory/executor.test.js.map +1 -1
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +2 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +13 -0
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/bridge/sse/mapper.test.js +2 -2
- package/dist/constants/compaction/index.d.ts.map +1 -1
- package/dist/constants/compaction/index.js +8 -3
- package/dist/constants/compaction/index.js.map +1 -1
- package/dist/constants/sandbox/index.d.ts +21 -0
- package/dist/constants/sandbox/index.d.ts.map +1 -1
- package/dist/constants/sandbox/index.js +30 -0
- package/dist/constants/sandbox/index.js.map +1 -1
- package/dist/constants/tools/index.d.ts.map +1 -1
- package/dist/constants/tools/index.js +33 -2
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +35 -5
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/persona/assembler.d.ts +1 -0
- package/dist/persona/assembler.d.ts.map +1 -1
- package/dist/persona/assembler.js +28 -6
- package/dist/persona/assembler.js.map +1 -1
- package/dist/provider/collect.test.js +2 -2
- package/dist/public-runtime.d.ts +5 -4
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +5 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +2 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +2 -0
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +3 -0
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -0
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +87 -5
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/execute.test.d.ts +4 -2
- package/dist/registry/tool/execute.test.d.ts.map +1 -1
- package/dist/registry/tool/execute.test.js +112 -3
- package/dist/registry/tool/execute.test.js.map +1 -1
- package/dist/registry/toolset/catalog.d.ts +42 -0
- package/dist/registry/toolset/catalog.d.ts.map +1 -0
- package/dist/registry/toolset/catalog.js +217 -0
- package/dist/registry/toolset/catalog.js.map +1 -0
- package/dist/registry/toolset/catalog.test.d.ts +2 -0
- package/dist/registry/toolset/catalog.test.d.ts.map +1 -0
- package/dist/registry/toolset/catalog.test.js +85 -0
- package/dist/registry/toolset/catalog.test.js.map +1 -0
- package/dist/runtime/query/__tests__/deferred-tools.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/deferred-tools.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/deferred-tools.test.js +147 -0
- package/dist/runtime/query/__tests__/deferred-tools.test.js.map +1 -0
- package/dist/runtime/query/__tests__/executor-concurrency.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/executor-concurrency.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/executor-concurrency.test.js +98 -0
- package/dist/runtime/query/__tests__/executor-concurrency.test.js.map +1 -0
- package/dist/runtime/query/__tests__/executor-plugin-hooks.test.js +38 -3
- package/dist/runtime/query/__tests__/executor-plugin-hooks.test.js.map +1 -1
- package/dist/runtime/query/__tests__/prompt.test.js +47 -2
- package/dist/runtime/query/__tests__/prompt.test.js.map +1 -1
- package/dist/runtime/query/__tests__/stream-recovery.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/stream-recovery.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/stream-recovery.test.js +126 -0
- package/dist/runtime/query/__tests__/stream-recovery.test.js.map +1 -0
- package/dist/runtime/query/continuation.d.ts +16 -0
- package/dist/runtime/query/continuation.d.ts.map +1 -0
- package/dist/runtime/query/continuation.js +16 -0
- package/dist/runtime/query/continuation.js.map +1 -0
- package/dist/runtime/query/executor.d.ts +3 -0
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +71 -3
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +19 -3
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +22 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +227 -60
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +10 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +21 -1
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +1 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +1 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +32 -1
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/session/workspace/__tests__/shared-run.test.d.ts +2 -0
- package/dist/session/workspace/__tests__/shared-run.test.d.ts.map +1 -0
- package/dist/session/workspace/__tests__/shared-run.test.js +147 -0
- package/dist/session/workspace/__tests__/shared-run.test.js.map +1 -0
- package/dist/session/workspace/index.d.ts +2 -0
- package/dist/session/workspace/index.d.ts.map +1 -1
- package/dist/session/workspace/index.js +1 -0
- package/dist/session/workspace/index.js.map +1 -1
- package/dist/session/workspace/shared-run.d.ts +81 -0
- package/dist/session/workspace/shared-run.d.ts.map +1 -0
- package/dist/session/workspace/shared-run.js +251 -0
- package/dist/session/workspace/shared-run.js.map +1 -0
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +36 -6
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/loader.test.d.ts +2 -0
- package/dist/skills/loader.test.d.ts.map +1 -0
- package/dist/skills/loader.test.js +65 -0
- package/dist/skills/loader.test.js.map +1 -0
- package/dist/streaming/coalesce.test.js +1 -1
- package/dist/tools/builtins/__tests__/edit.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/edit.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/edit.test.js +38 -0
- package/dist/tools/builtins/__tests__/edit.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/payload-budget.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/payload-budget.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/payload-budget.test.js +22 -0
- package/dist/tools/builtins/__tests__/payload-budget.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/read-file.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/read-file.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/read-file.test.js +24 -0
- package/dist/tools/builtins/__tests__/read-file.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/verify-outputs.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/verify-outputs.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/verify-outputs.test.js +52 -0
- package/dist/tools/builtins/__tests__/verify-outputs.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/write-file.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/write-file.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/write-file.test.js +74 -0
- package/dist/tools/builtins/__tests__/write-file.test.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +40 -7
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts +5 -2
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +114 -18
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +1 -0
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js +13 -13
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/read-file.d.ts +1 -0
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +23 -8
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +4 -1
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/verify-outputs.d.ts +5 -0
- package/dist/tools/builtins/verify-outputs.d.ts.map +1 -0
- package/dist/tools/builtins/verify-outputs.js +103 -0
- package/dist/tools/builtins/verify-outputs.js.map +1 -0
- package/dist/tools/builtins/write-file.d.ts +3 -2
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +72 -12
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/__tests__/agent.test.d.ts +15 -0
- package/dist/tools/coordinator/__tests__/agent.test.d.ts.map +1 -0
- package/dist/tools/coordinator/__tests__/agent.test.js +142 -0
- package/dist/tools/coordinator/__tests__/agent.test.js.map +1 -0
- package/dist/tools/coordinator/__tests__/task-list.test.d.ts +13 -0
- package/dist/tools/coordinator/__tests__/task-list.test.d.ts.map +1 -0
- package/dist/tools/coordinator/__tests__/task-list.test.js +162 -0
- package/dist/tools/coordinator/__tests__/task-list.test.js.map +1 -0
- package/dist/tools/coordinator/agent.d.ts +34 -0
- package/dist/tools/coordinator/agent.d.ts.map +1 -0
- package/dist/tools/coordinator/agent.js +107 -0
- package/dist/tools/coordinator/agent.js.map +1 -0
- package/dist/tools/coordinator/index.d.ts +7 -0
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +111 -21
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/types/agent/base.d.ts +8 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/reactive.d.ts +23 -0
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +41 -0
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/message/index.d.ts +22 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +7 -2
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +2 -9
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +6 -0
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/sandbox/index.d.ts +193 -0
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/skills/index.d.ts +2 -0
- package/dist/types/skills/index.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +22 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/toolset/index.d.ts +71 -0
- package/dist/types/toolset/index.d.ts.map +1 -0
- package/dist/types/toolset/index.js +2 -0
- package/dist/types/toolset/index.js.map +1 -0
- package/dist/types/workspace/index.d.ts +1 -0
- package/dist/types/workspace/index.d.ts.map +1 -1
- package/dist/types/workspace/shared-run.d.ts +61 -0
- package/dist/types/workspace/shared-run.d.ts.map +1 -0
- package/dist/types/workspace/shared-run.js +2 -0
- package/dist/types/workspace/shared-run.js.map +1 -0
- package/dist/verification/index.d.ts +1 -0
- package/dist/verification/index.d.ts.map +1 -1
- package/dist/verification/index.js +1 -0
- package/dist/verification/index.js.map +1 -1
- package/dist/verification/presets.d.ts +53 -0
- package/dist/verification/presets.d.ts.map +1 -0
- package/dist/verification/presets.js +70 -0
- package/dist/verification/presets.js.map +1 -0
- package/dist/verification/presets.test.d.ts +16 -0
- package/dist/verification/presets.test.d.ts.map +1 -0
- package/dist/verification/presets.test.js +79 -0
- package/dist/verification/presets.test.js.map +1 -0
- package/package.json +3 -2
- package/src/advisory/executor.test.ts +7 -4
- package/src/advisory/executor.ts +11 -2
- package/src/agents/ReactiveAgent.ts +2 -0
- package/src/agents/SupervisorAgent.ts +13 -0
- package/src/bridge/sse/mapper.test.ts +2 -2
- package/src/constants/compaction/index.ts +8 -3
- package/src/constants/sandbox/index.ts +37 -0
- package/src/constants/tools/index.ts +33 -2
- package/src/manager/run/persistence.ts +34 -6
- package/src/persona/assembler.ts +31 -8
- package/src/provider/collect.test.ts +2 -2
- package/src/public-runtime.ts +14 -1
- package/src/public-tools.ts +2 -0
- package/src/public-types.ts +7 -0
- package/src/registry/index.ts +7 -0
- package/src/registry/tool/execute.test.ts +132 -3
- package/src/registry/tool/execute.ts +94 -9
- package/src/registry/toolset/catalog.test.ts +97 -0
- package/src/registry/toolset/catalog.ts +283 -0
- package/src/runtime/query/__tests__/deferred-tools.test.ts +183 -0
- package/src/runtime/query/__tests__/executor-concurrency.test.ts +122 -0
- package/src/runtime/query/__tests__/executor-plugin-hooks.test.ts +48 -3
- package/src/runtime/query/__tests__/prompt.test.ts +51 -2
- package/src/runtime/query/__tests__/stream-recovery.test.ts +156 -0
- package/src/runtime/query/continuation.ts +16 -0
- package/src/runtime/query/executor.ts +82 -13
- package/src/runtime/query/index.ts +24 -3
- package/src/runtime/query/iteration/index.ts +263 -68
- package/src/runtime/query/iteration/phases/context.ts +10 -0
- package/src/runtime/query/prompt.ts +17 -1
- package/src/runtime/query/tooling.ts +2 -0
- package/src/sandbox/provider/local.ts +33 -0
- package/src/session/workspace/__tests__/shared-run.test.ts +181 -0
- package/src/session/workspace/index.ts +6 -0
- package/src/session/workspace/shared-run.ts +316 -0
- package/src/skills/loader.test.ts +89 -0
- package/src/skills/loader.ts +37 -6
- package/src/streaming/coalesce.test.ts +1 -1
- package/src/tools/builtins/__tests__/edit.test.ts +57 -0
- package/src/tools/builtins/__tests__/payload-budget.test.ts +29 -0
- package/src/tools/builtins/__tests__/read-file.test.ts +31 -0
- package/src/tools/builtins/__tests__/verify-outputs.test.ts +71 -0
- package/src/tools/builtins/__tests__/write-file.test.ts +97 -0
- package/src/tools/builtins/bash.ts +48 -7
- package/src/tools/builtins/edit.ts +162 -27
- package/src/tools/builtins/index.ts +13 -13
- package/src/tools/builtins/read-file.ts +31 -8
- package/src/tools/builtins/search-tools.ts +5 -1
- package/src/tools/builtins/verify-outputs.ts +126 -0
- package/src/tools/builtins/write-file.ts +83 -14
- package/src/tools/coordinator/__tests__/agent.test.ts +172 -0
- package/src/tools/coordinator/__tests__/task-list.test.ts +182 -0
- package/src/tools/coordinator/agent.ts +157 -0
- package/src/tools/coordinator/index.ts +128 -22
- package/src/types/agent/base.ts +8 -0
- package/src/types/agent/reactive.ts +25 -0
- package/src/types/agent/supervisor.ts +45 -0
- package/src/types/message/index.ts +32 -2
- package/src/types/provider/chat.ts +2 -9
- package/src/types/run/events.ts +6 -0
- package/src/types/sandbox/index.ts +219 -0
- package/src/types/skills/index.ts +4 -0
- package/src/types/tool/index.ts +24 -0
- package/src/types/toolset/index.ts +86 -0
- package/src/types/workspace/index.ts +9 -0
- package/src/types/workspace/shared-run.ts +65 -0
- package/src/verification/index.ts +1 -0
- package/src/verification/presets.test.ts +112 -0
- package/src/verification/presets.ts +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload-budget.test.js","sourceRoot":"","sources":["../../../../src/tools/builtins/__tests__/payload-budget.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAClD,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAChF,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAEpC,MAAM,CAAC,GAAG,EAAE,CACX,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAChF,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;QACf,MAAM,CAAC,GAAG,EAAE,CACX,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC;YAC1B,IAAI,EAAE,iBAAiB;YACvB,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,SAAS;YACjB,WAAW,EAAE,KAAK;SAClB,CAAC,CACF,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;IAChB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QAC1D,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAExD,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAC/B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IACtC,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.test.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtins/__tests__/read-file.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mkdtempSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { ReadFileTool } from '../read-file.js';
|
|
6
|
+
function makeContext(workingDirectory) {
|
|
7
|
+
return {
|
|
8
|
+
runId: 'run_test',
|
|
9
|
+
workingDirectory,
|
|
10
|
+
abortSignal: new AbortController().signal,
|
|
11
|
+
env: {},
|
|
12
|
+
log: () => { },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
describe('ReadFileTool', () => {
|
|
16
|
+
it('accepts readRange as a 1-indexed inclusive line range', async () => {
|
|
17
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-read-'));
|
|
18
|
+
writeFileSync(join(dir, 'doc.md'), ['one', 'two', 'three', 'four'].join('\n'));
|
|
19
|
+
const result = await ReadFileTool.execute({ path: 'doc.md', readRange: [2, 3] }, makeContext(dir));
|
|
20
|
+
expect(result.success).toBe(true);
|
|
21
|
+
expect(result.output).toBe('2\ttwo\n3\tthree');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=read-file.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.test.js","sourceRoot":"","sources":["../../../../src/tools/builtins/__tests__/read-file.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,SAAS,WAAW,CAAC,gBAAwB;IAC5C,OAAO;QACN,KAAK,EAAE,UAAkC;QACzC,gBAAgB;QAChB,WAAW,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACzC,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;KACb,CAAA;AACF,CAAC;AAED,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC,CAAA;QACtD,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAE9E,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CACxC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EACrC,WAAW,CAAC,GAAG,CAAC,CAChB,CAAA;QAED,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-outputs.test.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtins/__tests__/verify-outputs.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { mkdtempSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { VerifyOutputsTool } from '../verify-outputs.js';
|
|
6
|
+
function makeContext(workingDirectory) {
|
|
7
|
+
return {
|
|
8
|
+
runId: 'run_test',
|
|
9
|
+
workingDirectory,
|
|
10
|
+
abortSignal: new AbortController().signal,
|
|
11
|
+
env: {},
|
|
12
|
+
log: () => { },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
describe('VerifyOutputsTool', () => {
|
|
16
|
+
it('reports OK for every existing non-empty file', async () => {
|
|
17
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-verify-'));
|
|
18
|
+
writeFileSync(join(dir, 'a.md'), 'hello world');
|
|
19
|
+
writeFileSync(join(dir, 'b.txt'), 'x'.repeat(500));
|
|
20
|
+
const result = await VerifyOutputsTool.execute({ paths: ['a.md', 'b.txt'] }, makeContext(dir));
|
|
21
|
+
expect(result.success).toBe(true);
|
|
22
|
+
expect(result.output).toMatch(/2\/2 passed/);
|
|
23
|
+
expect(result.output).toMatch(/OK {3}a\.md/);
|
|
24
|
+
expect(result.output).toMatch(/OK {3}b\.txt/);
|
|
25
|
+
});
|
|
26
|
+
it('flags missing files as FAIL with summary', async () => {
|
|
27
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-verify-'));
|
|
28
|
+
writeFileSync(join(dir, 'present.md'), 'data');
|
|
29
|
+
const result = await VerifyOutputsTool.execute({ paths: ['present.md', 'missing.md', 'also-missing.md'] }, makeContext(dir));
|
|
30
|
+
expect(result.success).toBe(false);
|
|
31
|
+
expect(result.error).toMatch(/2 of 3 expected outputs failed/);
|
|
32
|
+
expect(result.output).toMatch(/1\/3 passed/);
|
|
33
|
+
expect(result.output).toMatch(/FAIL missing\.md — missing/);
|
|
34
|
+
});
|
|
35
|
+
it('treats files smaller than min_bytes as FAIL', async () => {
|
|
36
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-verify-'));
|
|
37
|
+
writeFileSync(join(dir, 'tiny.md'), 'x'); // 1 byte
|
|
38
|
+
writeFileSync(join(dir, 'big.md'), 'y'.repeat(2000));
|
|
39
|
+
const result = await VerifyOutputsTool.execute({ paths: ['tiny.md', 'big.md'], min_bytes: 1000 }, makeContext(dir));
|
|
40
|
+
expect(result.success).toBe(false);
|
|
41
|
+
expect(result.output).toMatch(/FAIL tiny\.md — size 1B < min 1000B/);
|
|
42
|
+
expect(result.output).toMatch(/OK {3}big\.md/);
|
|
43
|
+
});
|
|
44
|
+
it('rejects directories that match a path', async () => {
|
|
45
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-verify-'));
|
|
46
|
+
const result = await VerifyOutputsTool.execute({ paths: ['.'] }, // working directory itself
|
|
47
|
+
makeContext(dir));
|
|
48
|
+
expect(result.success).toBe(false);
|
|
49
|
+
expect(result.output).toMatch(/FAIL \. — not a regular file/);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=verify-outputs.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-outputs.test.js","sourceRoot":"","sources":["../../../../src/tools/builtins/__tests__/verify-outputs.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,SAAS,WAAW,CAAC,gBAAwB;IAC5C,OAAO;QACN,KAAK,EAAE,UAAkC;QACzC,gBAAgB;QAChB,WAAW,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACzC,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;KACb,CAAA;AACF,CAAC;AAED,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,eAA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E,2BAA2B;QAC7C,WAAW,CAAC,GAAG,CAAC,CAChB,CAAA;QACD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAClC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-file.test.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtins/__tests__/write-file.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { WriteFileTool } from '../write-file.js';
|
|
6
|
+
function makeTracker() {
|
|
7
|
+
const set = new Set();
|
|
8
|
+
return {
|
|
9
|
+
recordRead: (k) => {
|
|
10
|
+
set.add(k);
|
|
11
|
+
},
|
|
12
|
+
hasRead: (k) => set.has(k),
|
|
13
|
+
keys: () => Array.from(set),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function makeContext(workingDirectory, tracker) {
|
|
17
|
+
return {
|
|
18
|
+
runId: 'run_test',
|
|
19
|
+
workingDirectory,
|
|
20
|
+
abortSignal: new AbortController().signal,
|
|
21
|
+
env: {},
|
|
22
|
+
log: () => { },
|
|
23
|
+
fileReadTracker: tracker,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
describe('WriteFileTool — read-before-overwrite invariant', () => {
|
|
27
|
+
it('writes a new file without requiring a prior read', async () => {
|
|
28
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-write-'));
|
|
29
|
+
const tracker = makeTracker();
|
|
30
|
+
const ctx = makeContext(dir, tracker);
|
|
31
|
+
const result = await WriteFileTool.execute({ path: 'fresh.txt', content: 'hello' }, ctx);
|
|
32
|
+
expect(result.success).toBe(true);
|
|
33
|
+
expect(readFileSync(join(dir, 'fresh.txt'), 'utf-8')).toBe('hello');
|
|
34
|
+
expect(tracker.hasRead(join(dir, 'fresh.txt'))).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
it('accepts newStr as the canonical create/write content alias', async () => {
|
|
37
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-write-'));
|
|
38
|
+
const tracker = makeTracker();
|
|
39
|
+
const ctx = makeContext(dir, tracker);
|
|
40
|
+
const result = await WriteFileTool.execute({ path: 'fresh.txt', newStr: 'hello' }, ctx);
|
|
41
|
+
expect(result.success).toBe(true);
|
|
42
|
+
expect(readFileSync(join(dir, 'fresh.txt'), 'utf-8')).toBe('hello');
|
|
43
|
+
});
|
|
44
|
+
it('refuses to overwrite an existing file the agent has not read', async () => {
|
|
45
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-write-'));
|
|
46
|
+
writeFileSync(join(dir, 'pre-existing.txt'), 'original');
|
|
47
|
+
const tracker = makeTracker();
|
|
48
|
+
const ctx = makeContext(dir, tracker);
|
|
49
|
+
const result = await WriteFileTool.execute({ path: 'pre-existing.txt', content: 'replaced' }, ctx);
|
|
50
|
+
expect(result.success).toBe(false);
|
|
51
|
+
expect(result.error).toMatch(/already exists.*read/i);
|
|
52
|
+
expect(readFileSync(join(dir, 'pre-existing.txt'), 'utf-8')).toBe('original');
|
|
53
|
+
});
|
|
54
|
+
it('allows overwrite once the file has been read in the same context', async () => {
|
|
55
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-write-'));
|
|
56
|
+
const filePath = join(dir, 'pre-existing.txt');
|
|
57
|
+
writeFileSync(filePath, 'original');
|
|
58
|
+
const tracker = makeTracker();
|
|
59
|
+
tracker.recordRead(filePath);
|
|
60
|
+
const ctx = makeContext(dir, tracker);
|
|
61
|
+
const result = await WriteFileTool.execute({ path: 'pre-existing.txt', content: 'replaced' }, ctx);
|
|
62
|
+
expect(result.success).toBe(true);
|
|
63
|
+
expect(readFileSync(filePath, 'utf-8')).toBe('replaced');
|
|
64
|
+
});
|
|
65
|
+
it('falls back to legacy behaviour when no fileReadTracker is provided (back-compat)', async () => {
|
|
66
|
+
const dir = mkdtempSync(join(tmpdir(), 'namzu-write-'));
|
|
67
|
+
writeFileSync(join(dir, 'legacy.txt'), 'before');
|
|
68
|
+
const ctx = makeContext(dir);
|
|
69
|
+
const result = await WriteFileTool.execute({ path: 'legacy.txt', content: 'after' }, ctx);
|
|
70
|
+
expect(result.success).toBe(true);
|
|
71
|
+
expect(readFileSync(join(dir, 'legacy.txt'), 'utf-8')).toBe('after');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=write-file.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-file.test.js","sourceRoot":"","sources":["../../../../src/tools/builtins/__tests__/write-file.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,SAAS,WAAW;IACnB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAA;IAC7B,OAAO;QACN,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE;YACjB,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACX,CAAC;QACD,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1B,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,I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,IAAI,CAAC,CAAA;QACjC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACrE,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/bash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/bash.ts"],"names":[],"mappings":"AAwCA,eAAO,MAAM,QAAQ;;;EAmFnB,CAAA"}
|
|
@@ -4,18 +4,29 @@ import { z } from 'zod';
|
|
|
4
4
|
import { DANGEROUS_PATTERNS } from '../../constants/tools/index.js';
|
|
5
5
|
import { defineTool } from '../defineTool.js';
|
|
6
6
|
const execAsync = promisify(exec);
|
|
7
|
+
// Namzu owns its own bash timeout knob — `NAMZU_BASH_TIMEOUT_MS`.
|
|
8
|
+
// The Vandal fallback (`VANDAL_NAMZU_TIMEOUT_MS`) lived here as a
|
|
9
|
+
// historical bridge while Namzu was carved out of the Vandal repo,
|
|
10
|
+
// but Namzu shouldn't read a consumer's env name. Consumers can
|
|
11
|
+
// still alias their own var to `NAMZU_BASH_TIMEOUT_MS` at deploy
|
|
12
|
+
// time if they want a unified knob.
|
|
13
|
+
const DEFAULT_BASH_TIMEOUT_MS = readPositiveIntEnv('NAMZU_BASH_TIMEOUT_MS', 60 * 60 * 1000);
|
|
14
|
+
const DEFAULT_BASH_MAX_BUFFER_BYTES = readPositiveIntEnv('NAMZU_BASH_MAX_BUFFER_BYTES', 100 * 1024 * 1024);
|
|
7
15
|
const inputSchema = z.object({
|
|
8
|
-
command: z
|
|
16
|
+
command: z
|
|
17
|
+
.string()
|
|
18
|
+
.min(1)
|
|
19
|
+
.describe('The bash command to execute. Required, non-empty. Single command per call (use `&&` / `;` chaining for compound commands). Avoid heredocs that span more than a few hundred bytes — large content should be created with `write`, then extended with `edit` insertLine: "end", not piped into bash.'),
|
|
9
20
|
timeout: z
|
|
10
|
-
.preprocess((v) => (typeof v === 'string' ? Number(v) : v), z.number().default(
|
|
11
|
-
.describe(
|
|
21
|
+
.preprocess((v) => (typeof v === 'string' ? Number(v) : v), z.number().default(DEFAULT_BASH_TIMEOUT_MS))
|
|
22
|
+
.describe(`Command timeout in milliseconds. Default: ${DEFAULT_BASH_TIMEOUT_MS}`),
|
|
12
23
|
});
|
|
13
24
|
function isDangerousCommand(command) {
|
|
14
25
|
return DANGEROUS_PATTERNS.some((pattern) => pattern.test(command));
|
|
15
26
|
}
|
|
16
27
|
export const BashTool = defineTool({
|
|
17
28
|
name: 'bash',
|
|
18
|
-
description: 'Executes a bash command and returns stdout/stderr output. Command timeout is configurable.',
|
|
29
|
+
description: 'Executes a bash command and returns stdout/stderr output. Command timeout is configurable. The `command` parameter is required — never call this tool with empty arguments. For very long content (e.g. building a large file), prefer `write` for the opening and `edit` with insertLine: "end" for follow-up chunks over a heredoc to avoid hitting the output token limit mid-stream.',
|
|
19
30
|
inputSchema,
|
|
20
31
|
category: 'shell',
|
|
21
32
|
permissions: ['shell_execute'],
|
|
@@ -30,11 +41,26 @@ export const BashTool = defineTool({
|
|
|
30
41
|
error: `Dangerous command blocked: "${input.command}"`,
|
|
31
42
|
};
|
|
32
43
|
}
|
|
33
|
-
// Sandbox-aware: route through sandbox.exec() when available
|
|
44
|
+
// Sandbox-aware: route through sandbox.exec() when available.
|
|
45
|
+
//
|
|
46
|
+
// `context.workingDirectory` is the HOST-side workspace path the
|
|
47
|
+
// SDK consumer chose for the run (Vandal: `/var/lib/vandal/sessions/<task>`),
|
|
48
|
+
// which is meaningless inside the sandbox container. Forwarding
|
|
49
|
+
// it as `cwd` would either land on a path that doesn't exist
|
|
50
|
+
// (and the worker would `mkdir -p` it inside the container,
|
|
51
|
+
// silently divorcing the model's filesystem view from where its
|
|
52
|
+
// deliverables actually need to land) or, in the case of the
|
|
53
|
+
// `container:docker` worker, fail the workspace-confinement
|
|
54
|
+
// guard outright. The right behaviour is to let the worker
|
|
55
|
+
// fall through to its own default (`NAMZU_SANDBOX_WORKSPACE`
|
|
56
|
+
// → the per-task mount root the host configured at provider
|
|
57
|
+
// construction time). Tools that need a sub-cwd inside the
|
|
58
|
+
// sandbox can be added later as an explicit
|
|
59
|
+
// `SandboxExecOptions.workspaceRelativeCwd` field; the bash
|
|
60
|
+
// builtin doesn't have that requirement today.
|
|
34
61
|
if (context.sandbox) {
|
|
35
62
|
const result = await context.sandbox.exec('/bin/sh', ['-c', input.command], {
|
|
36
63
|
timeout: input.timeout,
|
|
37
|
-
cwd: context.workingDirectory,
|
|
38
64
|
env: context.env,
|
|
39
65
|
});
|
|
40
66
|
if (result.timedOut) {
|
|
@@ -61,7 +87,7 @@ export const BashTool = defineTool({
|
|
|
61
87
|
cwd: context.workingDirectory,
|
|
62
88
|
timeout: input.timeout,
|
|
63
89
|
env: { ...process.env, ...context.env },
|
|
64
|
-
maxBuffer:
|
|
90
|
+
maxBuffer: DEFAULT_BASH_MAX_BUFFER_BYTES,
|
|
65
91
|
});
|
|
66
92
|
const output = [stdout ? `STDOUT:\n${stdout}` : '', stderr ? `STDERR:\n${stderr}` : '']
|
|
67
93
|
.filter(Boolean)
|
|
@@ -73,4 +99,11 @@ export const BashTool = defineTool({
|
|
|
73
99
|
};
|
|
74
100
|
},
|
|
75
101
|
});
|
|
102
|
+
function readPositiveIntEnv(key, fallback) {
|
|
103
|
+
const value = process.env[key]?.trim();
|
|
104
|
+
if (!value)
|
|
105
|
+
return fallback;
|
|
106
|
+
const parsed = Number(value);
|
|
107
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : fallback;
|
|
108
|
+
}
|
|
76
109
|
//# sourceMappingURL=bash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.js","sourceRoot":"","sources":["../../../src/tools/builtins/bash.ts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AC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;YACvC,SAAS,EAAE,6BAA6B;SACxC,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACrF,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,MAAM,CAAC,CAAA;QAEd,OAAO;YACN,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,MAAM,IAAI,aAAa;YAC/B,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE;SACrB,CAAA;IACF,CAAC;CACD,CAAC,CAAA;AAEF,SAAS,kBAAkB,CAAC,GAAW,EAAE,QAAgB;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAA;IACtC,IAAI,CAAC,KAAK;QAAE,OAAO,QAAQ,CAAA;IAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC5B,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACtE,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export declare const EditTool: import("../../public-types.js").ToolDefinition<{
|
|
2
2
|
path: string;
|
|
3
|
-
old_string: string;
|
|
4
|
-
new_string: string;
|
|
5
3
|
replace_all: boolean;
|
|
4
|
+
newStr?: string | undefined;
|
|
5
|
+
old_string?: string | undefined;
|
|
6
|
+
oldStr?: string | undefined;
|
|
7
|
+
new_string?: string | undefined;
|
|
8
|
+
insertLine?: string | number | undefined;
|
|
6
9
|
}>;
|
|
7
10
|
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/edit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/edit.ts"],"names":[],"mappings":"AAoEA,eAAO,MAAM,QAAQ;;;;;;;;EA4DnB,CAAA"}
|
|
@@ -2,20 +2,43 @@ import { readFile, writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { defineTool } from '../defineTool.js';
|
|
5
|
-
const inputSchema = z
|
|
5
|
+
const inputSchema = z
|
|
6
|
+
.object({
|
|
6
7
|
path: z.string().describe('Path to the file to edit'),
|
|
7
8
|
old_string: z
|
|
8
9
|
.string()
|
|
10
|
+
.optional()
|
|
9
11
|
.describe('The exact string to find and replace. Must be unique in the file.'),
|
|
10
|
-
|
|
12
|
+
oldStr: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('Alias for old_string. Used by hosts that expose text replacement as oldStr/newStr.'),
|
|
16
|
+
new_string: z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('The replacement string. Self-budget this payload under 12000 characters before calling.'),
|
|
20
|
+
newStr: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Alias for new_string. Also used as inserted content when insertLine is provided. Self-budget this payload under 12000 characters before calling.'),
|
|
24
|
+
insertLine: z
|
|
25
|
+
.union([z.coerce.number().int().min(0), z.string().min(1)])
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Optional line insertion target. Inserts the replacement after this 1-indexed line; 0 inserts before the first line; "end" appends to the file.'),
|
|
11
28
|
replace_all: z
|
|
12
29
|
.boolean()
|
|
13
30
|
.default(false)
|
|
14
31
|
.describe('Replace all occurrences instead of just the first unique match'),
|
|
15
|
-
})
|
|
32
|
+
})
|
|
33
|
+
.refine((value) => typeof value.new_string === 'string' || typeof value.newStr === 'string', {
|
|
34
|
+
message: 'Either new_string or newStr is required.',
|
|
35
|
+
})
|
|
36
|
+
.refine((value) => value.insertLine !== undefined ||
|
|
37
|
+
typeof value.old_string === 'string' ||
|
|
38
|
+
typeof value.oldStr === 'string', { message: 'Either old_string/oldStr or insertLine is required.' });
|
|
16
39
|
export const EditTool = defineTool({
|
|
17
40
|
name: 'edit',
|
|
18
|
-
description: 'Makes targeted edits to a file using exact string find-and-replace. The old_string must be unique in the file unless replace_all is true. Preserves file formatting and indentation.',
|
|
41
|
+
description: 'Makes targeted edits to a file using exact string find-and-replace or line insertion. THIS IS THE PREFERRED WAY TO MODIFY AN EXISTING FILE — never reach for `write` to change a file that already exists, because `write` overwrites the whole body and discards earlier work on partial failure. `edit` keeps the rest of the file byte-for-byte intact and is recoverable: if a single edit fails (old_string/oldStr ambiguous, broader restructuring needed), follow up with another `edit` instead of re-emitting the entire file via `write`. The old_string/oldStr must be unique in the file unless replace_all is true. For insertions, pass insertLine plus new_string/newStr; use insertLine: "end" to extend a file at the end. Self-budget new_string/newStr under 12000 characters before emitting the tool call; use repeated bounded edits for long sections. Preserves file formatting and indentation.',
|
|
19
42
|
inputSchema,
|
|
20
43
|
category: 'filesystem',
|
|
21
44
|
permissions: ['file_write'],
|
|
@@ -23,18 +46,23 @@ export const EditTool = defineTool({
|
|
|
23
46
|
destructive: false,
|
|
24
47
|
concurrencySafe: false,
|
|
25
48
|
async execute(input, context) {
|
|
26
|
-
|
|
49
|
+
const normalized = normalizeEditInput(input);
|
|
50
|
+
if (!normalized.success) {
|
|
51
|
+
return { success: false, output: '', error: normalized.error };
|
|
52
|
+
}
|
|
53
|
+
if (normalized.operation.operation === 'replace' &&
|
|
54
|
+
normalized.operation.oldString === normalized.operation.newString) {
|
|
27
55
|
return {
|
|
28
56
|
success: false,
|
|
29
57
|
output: '',
|
|
30
|
-
error: 'old_string and new_string are identical — no change needed',
|
|
58
|
+
error: 'old_string/oldStr and new_string/newStr are identical — no change needed',
|
|
31
59
|
};
|
|
32
60
|
}
|
|
33
61
|
// Sandbox-aware: route through sandbox when available
|
|
34
62
|
if (context.sandbox) {
|
|
35
63
|
const buffer = await context.sandbox.readFile(input.path);
|
|
36
64
|
const content = buffer.toString('utf-8');
|
|
37
|
-
const result = applyEdit(content,
|
|
65
|
+
const result = applyEdit(content, normalized.operation);
|
|
38
66
|
if (!result.success) {
|
|
39
67
|
return { success: false, output: '', error: result.error };
|
|
40
68
|
}
|
|
@@ -47,7 +75,7 @@ export const EditTool = defineTool({
|
|
|
47
75
|
}
|
|
48
76
|
const filePath = resolve(context.workingDirectory, input.path);
|
|
49
77
|
const content = await readFile(filePath, 'utf-8');
|
|
50
|
-
const result = applyEdit(content,
|
|
78
|
+
const result = applyEdit(content, normalized.operation);
|
|
51
79
|
if (!result.success) {
|
|
52
80
|
return { success: false, output: '', error: result.error };
|
|
53
81
|
}
|
|
@@ -59,38 +87,106 @@ export const EditTool = defineTool({
|
|
|
59
87
|
};
|
|
60
88
|
},
|
|
61
89
|
});
|
|
90
|
+
function normalizeEditInput(input) {
|
|
91
|
+
const newString = input.new_string ?? input.newStr;
|
|
92
|
+
if (typeof newString !== 'string') {
|
|
93
|
+
return { success: false, error: 'Either new_string or newStr is required.' };
|
|
94
|
+
}
|
|
95
|
+
if (input.insertLine !== undefined) {
|
|
96
|
+
const insertLine = normalizeInsertLine(input.insertLine);
|
|
97
|
+
if (!insertLine.success)
|
|
98
|
+
return insertLine;
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
operation: {
|
|
102
|
+
operation: 'insert',
|
|
103
|
+
insertLine: insertLine.value,
|
|
104
|
+
newString,
|
|
105
|
+
replace_all: input.replace_all,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const oldString = input.old_string ?? input.oldStr;
|
|
110
|
+
if (typeof oldString !== 'string') {
|
|
111
|
+
return { success: false, error: 'Either old_string/oldStr or insertLine is required.' };
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
success: true,
|
|
115
|
+
operation: {
|
|
116
|
+
operation: 'replace',
|
|
117
|
+
oldString,
|
|
118
|
+
newString,
|
|
119
|
+
replace_all: input.replace_all,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function normalizeInsertLine(value) {
|
|
124
|
+
if (typeof value === 'string') {
|
|
125
|
+
if (value.trim().toLowerCase() === 'end')
|
|
126
|
+
return { success: true, value: 'end' };
|
|
127
|
+
const parsed = Number(value);
|
|
128
|
+
if (Number.isInteger(parsed) && parsed >= 0)
|
|
129
|
+
return { success: true, value: parsed };
|
|
130
|
+
return {
|
|
131
|
+
success: false,
|
|
132
|
+
error: 'insertLine must be a non-negative line number or "end".',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return { success: true, value };
|
|
136
|
+
}
|
|
62
137
|
function applyEdit(content, input) {
|
|
63
|
-
if (
|
|
138
|
+
if (input.operation === 'insert') {
|
|
139
|
+
return applyLineInsert(content, input);
|
|
140
|
+
}
|
|
141
|
+
if (!content.includes(input.oldString)) {
|
|
64
142
|
return {
|
|
65
143
|
success: false,
|
|
66
|
-
error: 'old_string not found in file. Make sure the string matches exactly, including whitespace and indentation.',
|
|
144
|
+
error: 'old_string/oldStr not found in file. Make sure the string matches exactly, including whitespace and indentation.',
|
|
67
145
|
};
|
|
68
146
|
}
|
|
69
147
|
if (input.replace_all) {
|
|
70
|
-
const parts = content.split(input.
|
|
148
|
+
const parts = content.split(input.oldString);
|
|
71
149
|
const replacements = parts.length - 1;
|
|
72
150
|
return {
|
|
73
151
|
success: true,
|
|
74
|
-
content: parts.join(input.
|
|
152
|
+
content: parts.join(input.newString),
|
|
75
153
|
replacements,
|
|
76
154
|
};
|
|
77
155
|
}
|
|
78
|
-
// Uniqueness check: old_string must appear exactly once
|
|
79
|
-
const firstIndex = content.indexOf(input.
|
|
80
|
-
const secondIndex = content.indexOf(input.
|
|
156
|
+
// Uniqueness check: old_string/oldStr must appear exactly once
|
|
157
|
+
const firstIndex = content.indexOf(input.oldString);
|
|
158
|
+
const secondIndex = content.indexOf(input.oldString, firstIndex + 1);
|
|
81
159
|
if (secondIndex !== -1) {
|
|
82
160
|
const lineNumber = content.slice(0, firstIndex).split('\n').length;
|
|
83
161
|
const secondLine = content.slice(0, secondIndex).split('\n').length;
|
|
84
162
|
return {
|
|
85
163
|
success: false,
|
|
86
|
-
error: `old_string is not unique — found at lines ${lineNumber} and ${secondLine}. Provide more surrounding context to make it unique, or use replace_all: true.`,
|
|
164
|
+
error: `old_string/oldStr is not unique — found at lines ${lineNumber} and ${secondLine}. Provide more surrounding context to make it unique, or use replace_all: true.`,
|
|
87
165
|
};
|
|
88
166
|
}
|
|
89
167
|
return {
|
|
90
168
|
success: true,
|
|
91
169
|
content: content.slice(0, firstIndex) +
|
|
92
|
-
input.
|
|
93
|
-
content.slice(firstIndex + input.
|
|
170
|
+
input.newString +
|
|
171
|
+
content.slice(firstIndex + input.oldString.length),
|
|
172
|
+
replacements: 1,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function applyLineInsert(content, input) {
|
|
176
|
+
const hasTrailingNewline = content.endsWith('\n');
|
|
177
|
+
const lines = content.split('\n');
|
|
178
|
+
if (hasTrailingNewline)
|
|
179
|
+
lines.pop();
|
|
180
|
+
const line = input.insertLine === 'end'
|
|
181
|
+
? lines.length
|
|
182
|
+
: Math.min(Math.max(input.insertLine, 0), lines.length);
|
|
183
|
+
const inserted = input.newString.endsWith('\n')
|
|
184
|
+
? input.newString.slice(0, -1).split('\n')
|
|
185
|
+
: input.newString.split('\n');
|
|
186
|
+
lines.splice(line, 0, ...inserted);
|
|
187
|
+
return {
|
|
188
|
+
success: true,
|
|
189
|
+
content: `${lines.join('\n')}${hasTrailingNewline ? '\n' : ''}`,
|
|
94
190
|
replacements: 1,
|
|
95
191
|
};
|
|
96
192
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/tools/builtins/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,WAAW,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/tools/builtins/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,WAAW,GAAG,CAAC;KACnB,MAAM,CAAC;IACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IACrD,UAAU,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,mEAAmE,CAAC;IAC/E,MAAM,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACR,oFAAoF,CACpF;IACF,UAAU,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACR,yFAAyF,CACzF;IACF,MAAM,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACR,kJAAkJ,CAClJ;IACF,UAAU,EAAE,CAAC;SACX,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC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IACjC,IAAI,kBAAkB;QAAE,KAAK,CAAC,GAAG,EAAE,CAAA;IAEnC,MAAM,IAAI,GACT,KAAK,CAAC,UAAU,KAAK,KAAK;QACzB,CAAC,CAAC,KAAK,CAAC,MAAM;QACd,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACzD,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC9C,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAC1C,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC9B,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAA;IAClC,OAAO;QACN,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/D,YAAY,EAAE,CAAC;KACf,CAAA;AACF,CAAC"}
|
|
@@ -6,6 +6,7 @@ export { GlobTool } from './glob.js';
|
|
|
6
6
|
export { GrepTool } from './grep.js';
|
|
7
7
|
export { LsTool } from './ls.js';
|
|
8
8
|
export { SearchToolsTool } from './search-tools.js';
|
|
9
|
+
export { VerifyOutputsTool } from './verify-outputs.js';
|
|
9
10
|
export { createStructuredOutputTool, STRUCTURED_OUTPUT_TOOL_NAME } from './structuredOutput.js';
|
|
10
11
|
export { createComputerUseTool, COMPUTER_USE_TOOL_NAME } from './computer-use.js';
|
|
11
12
|
import type { ToolDefinition } from '../../types/tool/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAC/F,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAEjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAC/F,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAEjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAoB/D,wBAAgB,eAAe,IAAI,cAAc,EAAE,CAElD"}
|
|
@@ -6,28 +6,28 @@ export { GlobTool } from './glob.js';
|
|
|
6
6
|
export { GrepTool } from './grep.js';
|
|
7
7
|
export { LsTool } from './ls.js';
|
|
8
8
|
export { SearchToolsTool } from './search-tools.js';
|
|
9
|
+
export { VerifyOutputsTool } from './verify-outputs.js';
|
|
9
10
|
export { createStructuredOutputTool, STRUCTURED_OUTPUT_TOOL_NAME } from './structuredOutput.js';
|
|
10
11
|
export { createComputerUseTool, COMPUTER_USE_TOOL_NAME } from './computer-use.js';
|
|
11
12
|
import { BashTool } from './bash.js';
|
|
12
13
|
import { EditTool } from './edit.js';
|
|
13
14
|
import { GlobTool } from './glob.js';
|
|
14
15
|
import { GrepTool } from './grep.js';
|
|
15
|
-
import { LsTool } from './ls.js';
|
|
16
16
|
import { ReadFileTool } from './read-file.js';
|
|
17
|
-
import {
|
|
17
|
+
import { VerifyOutputsTool } from './verify-outputs.js';
|
|
18
18
|
import { WriteFileTool } from './write-file.js';
|
|
19
19
|
// Note: createStructuredOutputTool is not included in getBuiltinTools()
|
|
20
|
-
// because it requires a schema parameter and is created per-use case
|
|
20
|
+
// because it requires a schema parameter and is created per-use case.
|
|
21
|
+
//
|
|
22
|
+
// `LsTool` and `SearchToolsTool` are still exported for direct use but are
|
|
23
|
+
// NOT in the default builtin set. Claude Code's training distribution (per
|
|
24
|
+
// `code.claude.com/docs/en/tools-reference`) does NOT include `LS` —
|
|
25
|
+
// directory listing is canonical `Bash` + `Glob`. `search_tools` has no
|
|
26
|
+
// Claude analogue at all. Including these in the defaults gives the model
|
|
27
|
+
// tools that look right but degrade alignment. File extension is canonical
|
|
28
|
+
// `edit` with `insertLine: "end"` — the legacy `Append` tool is gone.
|
|
29
|
+
// Hosts that genuinely want LS/search can still register them explicitly.
|
|
21
30
|
export function getBuiltinTools() {
|
|
22
|
-
return [
|
|
23
|
-
ReadFileTool,
|
|
24
|
-
WriteFileTool,
|
|
25
|
-
EditTool,
|
|
26
|
-
BashTool,
|
|
27
|
-
GlobTool,
|
|
28
|
-
GrepTool,
|
|
29
|
-
LsTool,
|
|
30
|
-
SearchToolsTool,
|
|
31
|
-
];
|
|
31
|
+
return [BashTool, EditTool, GlobTool, GrepTool, ReadFileTool, VerifyOutputsTool, WriteFileTool];
|
|
32
32
|
}
|
|
33
33
|
//# sourceMappingURL=index.js.map
|