@namzu/sdk 35.0.0 → 37.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 +218 -0
- package/README.md +68 -41
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +2 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +2 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/compaction/extractor.d.ts +1 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +15 -7
- package/dist/compaction/extractor.js.map +1 -1
- package/dist/compaction/manager.d.ts +2 -0
- package/dist/compaction/manager.d.ts.map +1 -1
- package/dist/compaction/manager.js +12 -1
- package/dist/compaction/manager.js.map +1 -1
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +82 -15
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/contracts/schemas.d.ts +10 -10
- package/dist/eval/harness-verification.d.ts +63 -0
- package/dist/eval/harness-verification.d.ts.map +1 -0
- package/dist/eval/harness-verification.js +165 -0
- package/dist/eval/harness-verification.js.map +1 -0
- package/dist/eval/index.d.ts +2 -0
- package/dist/eval/index.d.ts.map +1 -1
- package/dist/eval/index.js +1 -0
- package/dist/eval/index.js.map +1 -1
- package/dist/execution/code-runtime/json-value.d.ts +10 -0
- package/dist/execution/code-runtime/json-value.d.ts.map +1 -0
- package/dist/execution/code-runtime/json-value.js +89 -0
- package/dist/execution/code-runtime/json-value.js.map +1 -0
- package/dist/execution/code-runtime/worker-program.d.ts +8 -0
- package/dist/execution/code-runtime/worker-program.d.ts.map +1 -0
- package/dist/execution/code-runtime/worker-program.js +240 -0
- package/dist/execution/code-runtime/worker-program.js.map +1 -0
- package/dist/execution/code-runtime/worker.d.ts +22 -0
- package/dist/execution/code-runtime/worker.d.ts.map +1 -1
- package/dist/execution/code-runtime/worker.js +148 -111
- package/dist/execution/code-runtime/worker.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +12 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +306 -37
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +2 -0
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +6 -0
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/provider/capabilities.d.ts +3 -1
- package/dist/provider/capabilities.d.ts.map +1 -1
- package/dist/provider/capabilities.js +13 -0
- package/dist/provider/capabilities.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +2 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/token-budget.d.ts.map +1 -1
- package/dist/provider/token-budget.js +56 -8
- package/dist/provider/token-budget.js.map +1 -1
- package/dist/public-runtime.d.ts +5 -3
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +3 -2
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +1 -1
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +1 -1
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +1 -0
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/tool/execute.d.ts +3 -0
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +11 -80
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/run/command-gate.d.ts.map +1 -1
- package/dist/run/command-gate.js +65 -12
- package/dist/run/command-gate.js.map +1 -1
- package/dist/run/index.d.ts +2 -0
- package/dist/run/index.d.ts.map +1 -1
- package/dist/run/index.js +1 -0
- package/dist/run/index.js.map +1 -1
- package/dist/run/memory-promoter.d.ts +3 -35
- package/dist/run/memory-promoter.d.ts.map +1 -1
- package/dist/run/memory-promoter.js +32 -40
- package/dist/run/memory-promoter.js.map +1 -1
- package/dist/run/memory-recall.d.ts +25 -0
- package/dist/run/memory-recall.d.ts.map +1 -0
- package/dist/run/memory-recall.js +228 -0
- package/dist/run/memory-recall.js.map +1 -0
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +1 -0
- package/dist/run/reporter.js.map +1 -1
- package/dist/run/token-budget.d.ts +2 -0
- package/dist/run/token-budget.d.ts.map +1 -1
- package/dist/run/token-budget.js +4 -0
- package/dist/run/token-budget.js.map +1 -1
- package/dist/run/workspace-fingerprint.d.ts +10 -3
- package/dist/run/workspace-fingerprint.d.ts.map +1 -1
- package/dist/run/workspace-fingerprint.js +17 -8
- package/dist/run/workspace-fingerprint.js.map +1 -1
- package/dist/runtime/query/checkpoint.d.ts +14 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +82 -1
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +6 -0
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +120 -24
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +12 -8
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +55 -7
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +13 -3
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +356 -42
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/native-output.d.ts +10 -0
- package/dist/runtime/query/iteration/native-output.d.ts.map +1 -0
- package/dist/runtime/query/iteration/native-output.js +32 -0
- package/dist/runtime/query/iteration/native-output.js.map +1 -0
- package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +18 -13
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +32 -11
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +11 -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/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/working-memory.d.ts +1 -1
- package/dist/runtime/query/iteration/phases/working-memory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/working-memory.js +23 -6
- package/dist/runtime/query/iteration/phases/working-memory.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +12 -5
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +14 -4
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +6 -2
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +17 -2
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/runtime/query/tool-call-budget.d.ts +19 -0
- package/dist/runtime/query/tool-call-budget.d.ts.map +1 -0
- package/dist/runtime/query/tool-call-budget.js +110 -0
- package/dist/runtime/query/tool-call-budget.js.map +1 -0
- package/dist/runtime/query/tooling.d.ts +2 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +4 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/sandbox/file-walk-program.d.ts +3 -0
- package/dist/sandbox/file-walk-program.d.ts.map +1 -0
- package/dist/sandbox/file-walk-program.js +94 -0
- package/dist/sandbox/file-walk-program.js.map +1 -0
- package/dist/sandbox/file-walk.d.ts +12 -0
- package/dist/sandbox/file-walk.d.ts.map +1 -0
- package/dist/sandbox/file-walk.js +429 -0
- package/dist/sandbox/file-walk.js.map +1 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +1 -0
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +9 -0
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts +3 -2
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +29 -15
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +1 -0
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/handoff/capacity.d.ts +2 -2
- package/dist/session/handoff/capacity.d.ts.map +1 -1
- package/dist/session/handoff/capacity.js +3 -2
- package/dist/session/handoff/capacity.js.map +1 -1
- package/dist/store/memory/disk.d.ts +6 -2
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +42 -25
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/memory/index.d.ts +4 -0
- package/dist/store/memory/index.d.ts.map +1 -1
- package/dist/store/memory/index.js +55 -19
- package/dist/store/memory/index.js.map +1 -1
- package/dist/store/memory/memory.d.ts +3 -2
- package/dist/store/memory/memory.d.ts.map +1 -1
- package/dist/store/memory/memory.js +11 -2
- package/dist/store/memory/memory.js.map +1 -1
- package/dist/store/memory/operation-lock.d.ts +11 -0
- package/dist/store/memory/operation-lock.d.ts.map +1 -0
- package/dist/store/memory/operation-lock.js +94 -0
- package/dist/store/memory/operation-lock.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +215 -59
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +60 -10
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts +2 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +95 -103
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +155 -111
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/ls.js +2 -2
- package/dist/tools/builtins/ls.js.map +1 -1
- package/dist/tools/builtins/run-code.d.ts +6 -0
- package/dist/tools/builtins/run-code.d.ts.map +1 -1
- package/dist/tools/builtins/run-code.js +15 -4
- package/dist/tools/builtins/run-code.js.map +1 -1
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +14 -2
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/defineTool.d.ts +2 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +3 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/memory/delete.d.ts +4 -0
- package/dist/tools/memory/delete.d.ts.map +1 -0
- package/dist/tools/memory/delete.js +26 -0
- package/dist/tools/memory/delete.js.map +1 -0
- package/dist/tools/memory/index.d.ts +2 -0
- package/dist/tools/memory/index.d.ts.map +1 -1
- package/dist/tools/memory/index.js +6 -0
- package/dist/tools/memory/index.js.map +1 -1
- package/dist/tools/memory/save.d.ts.map +1 -1
- package/dist/tools/memory/save.js +3 -2
- package/dist/tools/memory/save.js.map +1 -1
- package/dist/tools/memory/search.d.ts.map +1 -1
- package/dist/tools/memory/search.js +12 -5
- package/dist/tools/memory/search.js.map +1 -1
- package/dist/tools/memory/update.d.ts +4 -0
- package/dist/tools/memory/update.d.ts.map +1 -0
- package/dist/tools/memory/update.js +47 -0
- package/dist/tools/memory/update.js.map +1 -0
- package/dist/types/agent/scheduler.d.ts +5 -0
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +10 -0
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +6 -0
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.js.map +1 -1
- package/dist/types/errors/catalog.js +1 -1
- package/dist/types/errors/catalog.js.map +1 -1
- package/dist/types/hitl/index.d.ts +11 -1
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/memory/index.d.ts +14 -1
- package/dist/types/memory/index.d.ts.map +1 -1
- package/dist/types/project/entity.d.ts +1 -0
- package/dist/types/project/entity.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +2 -0
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/model.d.ts +4 -0
- package/dist/types/provider/model.d.ts.map +1 -1
- package/dist/types/run/answer-review.d.ts +2 -0
- package/dist/types/run/answer-review.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +9 -0
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/run/prepare-step.d.ts +19 -1
- package/dist/types/run/prepare-step.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +20 -0
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/structured-output/index.d.ts +8 -2
- package/dist/types/structured-output/index.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +15 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/utils/json-snapshot.d.ts +3 -0
- package/dist/utils/json-snapshot.d.ts.map +1 -0
- package/dist/utils/json-snapshot.js +79 -0
- package/dist/utils/json-snapshot.js.map +1 -0
- package/package.json +8 -1
- package/src/bridge/a2a/mapper.ts +2 -0
- package/src/bridge/sse/mapper.ts +2 -0
- package/src/compaction/extractor.ts +21 -8
- package/src/compaction/manager.ts +11 -1
- package/src/compaction/verifier.ts +80 -18
- package/src/eval/harness-verification.ts +270 -0
- package/src/eval/index.ts +10 -0
- package/src/execution/code-runtime/json-value.ts +82 -0
- package/src/execution/code-runtime/worker-program.ts +239 -0
- package/src/execution/code-runtime/worker.ts +164 -111
- package/src/manager/agent/lifecycle.ts +340 -45
- package/src/manager/run/persistence.ts +7 -0
- package/src/provider/capabilities.ts +25 -1
- package/src/provider/fallback.ts +2 -0
- package/src/provider/token-budget.ts +52 -8
- package/src/public-runtime.ts +6 -1
- package/src/public-tools.ts +5 -1
- package/src/public-types.ts +1 -0
- package/src/registry/tool/execute.ts +17 -79
- package/src/run/command-gate.ts +61 -13
- package/src/run/index.ts +2 -0
- package/src/run/memory-promoter.ts +32 -40
- package/src/run/memory-recall.ts +254 -0
- package/src/run/reporter.ts +1 -0
- package/src/run/token-budget.ts +4 -0
- package/src/run/workspace-fingerprint.ts +17 -8
- package/src/runtime/query/checkpoint.ts +96 -2
- package/src/runtime/query/executor.ts +131 -28
- package/src/runtime/query/index.ts +81 -16
- package/src/runtime/query/iteration/index.ts +406 -53
- package/src/runtime/query/iteration/native-output.ts +35 -0
- package/src/runtime/query/iteration/phases/advisory.ts +21 -11
- package/src/runtime/query/iteration/phases/compaction.ts +36 -14
- package/src/runtime/query/iteration/phases/context.ts +11 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +5 -1
- package/src/runtime/query/iteration/phases/working-memory.ts +23 -5
- package/src/runtime/query/iteration/stream-turn.ts +11 -5
- package/src/runtime/query/prompt.ts +21 -4
- package/src/runtime/query/steering.ts +19 -2
- package/src/runtime/query/tool-call-budget.ts +115 -0
- package/src/runtime/query/tooling.ts +6 -0
- package/src/sandbox/file-walk-program.ts +93 -0
- package/src/sandbox/file-walk.ts +463 -0
- package/src/sandbox/index.ts +2 -0
- package/src/sandbox/provider/local.ts +13 -0
- package/src/scheduler/completion-inbox.ts +29 -19
- package/src/scheduler/local.ts +1 -0
- package/src/session/handoff/capacity.ts +7 -3
- package/src/store/memory/disk.ts +52 -30
- package/src/store/memory/index.ts +75 -27
- package/src/store/memory/memory.ts +18 -6
- package/src/store/memory/operation-lock.ts +99 -0
- package/src/tools/builtins/bash.ts +230 -58
- package/src/tools/builtins/computer-use.ts +61 -7
- package/src/tools/builtins/glob.ts +104 -122
- package/src/tools/builtins/grep.ts +166 -132
- package/src/tools/builtins/ls.ts +2 -2
- package/src/tools/builtins/run-code.ts +24 -5
- package/src/tools/builtins/search-tools.ts +18 -3
- package/src/tools/defineTool.ts +5 -0
- package/src/tools/memory/delete.ts +29 -0
- package/src/tools/memory/index.ts +6 -0
- package/src/tools/memory/save.ts +4 -2
- package/src/tools/memory/search.ts +12 -5
- package/src/tools/memory/update.ts +50 -0
- package/src/types/agent/scheduler.ts +6 -0
- package/src/types/agent/task.ts +13 -0
- package/src/types/computer-use/index.ts +6 -0
- package/src/types/errors/catalog.ts +1 -1
- package/src/types/hitl/index.ts +11 -1
- package/src/types/memory/index.ts +16 -1
- package/src/types/project/entity.ts +1 -0
- package/src/types/provider/config.ts +2 -0
- package/src/types/provider/model.ts +4 -0
- package/src/types/run/answer-review.ts +2 -0
- package/src/types/run/events.ts +10 -0
- package/src/types/run/prepare-step.ts +19 -1
- package/src/types/sandbox/index.ts +21 -0
- package/src/types/structured-output/index.ts +15 -2
- package/src/types/tool/index.ts +16 -0
- package/src/utils/json-snapshot.ts +76 -0
|
@@ -49,6 +49,12 @@ export interface RunCodeToolOptions {
|
|
|
49
49
|
readonly runtime?: CodeRuntime
|
|
50
50
|
readonly timeoutMs?: number
|
|
51
51
|
readonly maxOutputBytes?: number
|
|
52
|
+
/**
|
|
53
|
+
* What a successful `call()` resolves to. Default: `text` (ToolResult.output).
|
|
54
|
+
* `structured` returns `{ output, data? }`, preserving JSON tool data for
|
|
55
|
+
* local filtering. Failures still reject; authority and dispatch are unchanged.
|
|
56
|
+
*/
|
|
57
|
+
readonly toolResultMode?: 'text' | 'structured'
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
const DEFAULT_TIMEOUT_MS = 30_000
|
|
@@ -59,8 +65,11 @@ export function buildRunCodeTool(options: RunCodeToolOptions = {}) {
|
|
|
59
65
|
|
|
60
66
|
return defineTool({
|
|
61
67
|
name: RUN_CODE_TOOL_NAME,
|
|
62
|
-
description:
|
|
63
|
-
|
|
68
|
+
description: `Runs a short JavaScript program that can call this run's own tools in a loop. Use it when the same tool would otherwise be called many times in a row — filtering, retrying, fanning out — and not for a single call. ${
|
|
69
|
+
options.toolResultMode === 'structured'
|
|
70
|
+
? 'Each successful call() returns { output: string, data?: JSON value }. Filter data locally and return only the needed result. Failed calls reject.'
|
|
71
|
+
: 'Each successful call() returns the tool output string. Failed calls reject.'
|
|
72
|
+
}`,
|
|
64
73
|
inputSchema,
|
|
65
74
|
category: 'custom',
|
|
66
75
|
permissions: [],
|
|
@@ -108,9 +117,19 @@ export function buildRunCodeTool(options: RunCodeToolOptions = {}) {
|
|
|
108
117
|
signal: operation.signal,
|
|
109
118
|
runtimeToolCallId: operation.runtimeToolCallId,
|
|
110
119
|
})
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
if (!toolResult.success) {
|
|
121
|
+
return { ok: false, error: toolResult.error ?? 'the tool failed' }
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
ok: true,
|
|
125
|
+
value:
|
|
126
|
+
options.toolResultMode === 'structured'
|
|
127
|
+
? {
|
|
128
|
+
output: toolResult.output,
|
|
129
|
+
...(toolResult.data !== undefined ? { data: toolResult.data } : {}),
|
|
130
|
+
}
|
|
131
|
+
: toolResult.output,
|
|
132
|
+
}
|
|
114
133
|
} catch (err) {
|
|
115
134
|
return {
|
|
116
135
|
ok: false,
|
|
@@ -38,8 +38,7 @@ export const SearchToolsTool = defineTool({
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const allowed =
|
|
42
|
-
context.allowedTools && context.allowedTools.length > 0 ? new Set(context.allowedTools) : null
|
|
41
|
+
const allowed = context.allowedTools !== undefined ? new Set(context.allowedTools) : null
|
|
43
42
|
// `searchDeferred` returns a ranked list (score-descending), so slicing
|
|
44
43
|
// the head is a true top-k activation, not an arbitrary subset.
|
|
45
44
|
const ranked = context.toolRegistry
|
|
@@ -47,9 +46,25 @@ export const SearchToolsTool = defineTool({
|
|
|
47
46
|
.filter((tool) => !allowed || allowed.has(tool.name))
|
|
48
47
|
|
|
49
48
|
if (ranked.length === 0) {
|
|
49
|
+
const active = context.toolRegistry
|
|
50
|
+
.searchActive?.(input.query)
|
|
51
|
+
.filter(
|
|
52
|
+
(tool) =>
|
|
53
|
+
(!allowed || allowed.has(tool.name)) &&
|
|
54
|
+
context.toolRegistry?.getAvailability(tool.name) === 'active',
|
|
55
|
+
)
|
|
56
|
+
const activeReceipt =
|
|
57
|
+
active === undefined
|
|
58
|
+
? 'This registry cannot search active tools.'
|
|
59
|
+
: active.length === 0
|
|
60
|
+
? 'No matching active tools were found.'
|
|
61
|
+
: `Already active matching tools (up to ${ACTIVATION_TOP_K}):\n${active
|
|
62
|
+
.slice(0, ACTIVATION_TOP_K)
|
|
63
|
+
.map((tool) => `- ${tool.name}`)
|
|
64
|
+
.join('\n')}`
|
|
50
65
|
return {
|
|
51
66
|
success: true,
|
|
52
|
-
output: `No deferred tools matching "${input.query}".
|
|
67
|
+
output: `No deferred tools matching "${input.query}". ${activeReceipt}`,
|
|
53
68
|
}
|
|
54
69
|
}
|
|
55
70
|
|
package/src/tools/defineTool.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface DefineToolOptions<S extends z.ZodType> {
|
|
|
20
20
|
readOnly: boolean
|
|
21
21
|
destructive: boolean | ((input: z.infer<S>) => boolean)
|
|
22
22
|
concurrencySafe: boolean
|
|
23
|
+
/** Batch ordering boundary; see {@link ToolDefinition.executionBarrier}. */
|
|
24
|
+
executionBarrier?: boolean
|
|
23
25
|
tier?: string
|
|
24
26
|
/**
|
|
25
27
|
* How this tool's call and result should be shown; see
|
|
@@ -81,6 +83,9 @@ export function defineTool<S extends z.ZodType>(
|
|
|
81
83
|
...(options.presentResult ? { presentResult: options.presentResult } : {}),
|
|
82
84
|
...(options.outputSchema !== undefined ? { outputSchema: options.outputSchema } : {}),
|
|
83
85
|
...(options.terminal !== undefined ? { terminal: options.terminal } : {}),
|
|
86
|
+
...(options.executionBarrier !== undefined
|
|
87
|
+
? { executionBarrier: options.executionBarrier }
|
|
88
|
+
: {}),
|
|
84
89
|
category: options.category,
|
|
85
90
|
permissions: options.permissions,
|
|
86
91
|
isReadOnly: () => options.readOnly,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { MemoryStore } from '../../types/memory/index.js'
|
|
3
|
+
import type { ToolDefinition } from '../../types/tool/index.js'
|
|
4
|
+
import { asMemoryId } from '../../utils/id.js'
|
|
5
|
+
import { defineTool } from '../defineTool.js'
|
|
6
|
+
|
|
7
|
+
export function buildDeleteMemoryTool(store: MemoryStore): ToolDefinition {
|
|
8
|
+
return defineTool({
|
|
9
|
+
name: 'delete_memory',
|
|
10
|
+
description:
|
|
11
|
+
'Permanently delete a stored memory by ID. Use update_memory with status archived when the record should remain available for inspection. Deletion does not erase past conversation transcripts.',
|
|
12
|
+
inputSchema: z.object({
|
|
13
|
+
id: z.string().describe('Memory ID to permanently delete'),
|
|
14
|
+
}),
|
|
15
|
+
category: 'custom',
|
|
16
|
+
permissions: [],
|
|
17
|
+
readOnly: false,
|
|
18
|
+
destructive: true,
|
|
19
|
+
concurrencySafe: true,
|
|
20
|
+
async execute({ id }) {
|
|
21
|
+
const removed = await store.delete(asMemoryId(id))
|
|
22
|
+
return {
|
|
23
|
+
success: removed,
|
|
24
|
+
output: removed ? `Memory deleted: ${id}.` : `Memory ${id} not found.`,
|
|
25
|
+
...(removed ? {} : { error: 'Memory not found' }),
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { MemoryIndex, MemoryStore } from '../../types/memory/index.js'
|
|
2
2
|
import type { ToolDefinition } from '../../types/tool/index.js'
|
|
3
|
+
import { buildDeleteMemoryTool } from './delete.js'
|
|
3
4
|
import { buildReadMemoryTool } from './read.js'
|
|
4
5
|
import { buildSaveMemoryTool } from './save.js'
|
|
5
6
|
import { buildSearchMemoryTool, buildStoreSearchMemoryTool } from './search.js'
|
|
7
|
+
import { buildUpdateMemoryTool } from './update.js'
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Build memory tools over one authoritative store.
|
|
@@ -28,9 +30,13 @@ export function buildMemoryTools(store: MemoryStore, index?: MemoryIndex): ToolD
|
|
|
28
30
|
index ? buildSearchMemoryTool(index) : buildStoreSearchMemoryTool(store),
|
|
29
31
|
buildReadMemoryTool(store),
|
|
30
32
|
buildSaveMemoryTool(store),
|
|
33
|
+
buildUpdateMemoryTool(store),
|
|
34
|
+
buildDeleteMemoryTool(store),
|
|
31
35
|
]
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
export { buildSearchMemoryTool } from './search.js'
|
|
35
39
|
export { buildReadMemoryTool } from './read.js'
|
|
36
40
|
export { buildSaveMemoryTool } from './save.js'
|
|
41
|
+
export { buildUpdateMemoryTool } from './update.js'
|
|
42
|
+
export { buildDeleteMemoryTool } from './delete.js'
|
package/src/tools/memory/save.ts
CHANGED
|
@@ -6,7 +6,8 @@ import { defineTool } from '../defineTool.js'
|
|
|
6
6
|
export function buildSaveMemoryTool(store: MemoryStore): ToolDefinition {
|
|
7
7
|
return defineTool({
|
|
8
8
|
name: 'save_memory',
|
|
9
|
-
description:
|
|
9
|
+
description:
|
|
10
|
+
'Save a new historical claim for future reference. Include the actual useful fact and its evidence in the summary and content. For corrections to an existing record use update_memory instead of creating contradictory duplicates.',
|
|
10
11
|
inputSchema: z.object({
|
|
11
12
|
title: z.string().min(1).describe('Short descriptive title'),
|
|
12
13
|
summary: z.string().min(1).describe('Brief summary (1-2 sentences)'),
|
|
@@ -18,12 +19,13 @@ export function buildSaveMemoryTool(store: MemoryStore): ToolDefinition {
|
|
|
18
19
|
readOnly: false,
|
|
19
20
|
destructive: false,
|
|
20
21
|
concurrencySafe: true,
|
|
21
|
-
async execute({ title, summary, content, tags }) {
|
|
22
|
+
async execute({ title, summary, content, tags }, context) {
|
|
22
23
|
const { entry } = await store.create({
|
|
23
24
|
title,
|
|
24
25
|
summary,
|
|
25
26
|
content,
|
|
26
27
|
tags,
|
|
28
|
+
metadata: { source: 'agent-memory', runId: context.runId },
|
|
27
29
|
})
|
|
28
30
|
|
|
29
31
|
return {
|
|
@@ -14,19 +14,26 @@ function defineSearchMemoryTool(search: SearchMemory): ToolDefinition {
|
|
|
14
14
|
return defineTool({
|
|
15
15
|
name: 'search_memory',
|
|
16
16
|
description:
|
|
17
|
-
'Search stored memories by
|
|
17
|
+
'Search active stored memories by relevant words or tags. The built-in store ranks matches in titles, summaries and full content. Returns titles and summaries; use read_memory for evidence. Set status to archived to inspect obsolete records.',
|
|
18
18
|
inputSchema: z.object({
|
|
19
|
-
query: z.string().optional().describe('
|
|
19
|
+
query: z.string().optional().describe('Relevant words or identifiers to search'),
|
|
20
20
|
tags: z.array(z.string()).optional().describe('Filter by tags (all must match)'),
|
|
21
|
-
|
|
21
|
+
status: z.enum(['active', 'archived']).default('active'),
|
|
22
|
+
limit: z
|
|
23
|
+
.number()
|
|
24
|
+
.int()
|
|
25
|
+
.min(1)
|
|
26
|
+
.max(50)
|
|
27
|
+
.default(10)
|
|
28
|
+
.describe('Maximum results to return (1–50)'),
|
|
22
29
|
}),
|
|
23
30
|
category: 'analysis',
|
|
24
31
|
permissions: [],
|
|
25
32
|
readOnly: true,
|
|
26
33
|
destructive: false,
|
|
27
34
|
concurrencySafe: true,
|
|
28
|
-
async execute({ query, tags, limit }) {
|
|
29
|
-
const result = await search({ query, tags, limit })
|
|
35
|
+
async execute({ query, tags, status, limit }) {
|
|
36
|
+
const result = await search({ query, tags, status, limit })
|
|
30
37
|
|
|
31
38
|
if (result.entries.length === 0) {
|
|
32
39
|
return {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { MemoryStore } from '../../types/memory/index.js'
|
|
3
|
+
import type { ToolDefinition } from '../../types/tool/index.js'
|
|
4
|
+
import { asMemoryId } from '../../utils/id.js'
|
|
5
|
+
import { defineTool } from '../defineTool.js'
|
|
6
|
+
|
|
7
|
+
export function buildUpdateMemoryTool(store: MemoryStore): ToolDefinition {
|
|
8
|
+
return defineTool({
|
|
9
|
+
name: 'update_memory',
|
|
10
|
+
description:
|
|
11
|
+
'Correct an existing memory in place, or archive an obsolete claim so it is no longer recalled. Use the ID from search_memory; current evidence should determine corrections.',
|
|
12
|
+
inputSchema: z.object({
|
|
13
|
+
id: z.string().describe('Memory ID to correct or archive'),
|
|
14
|
+
title: z.string().min(1).optional(),
|
|
15
|
+
summary: z.string().min(1).optional(),
|
|
16
|
+
content: z.string().min(1).optional(),
|
|
17
|
+
tags: z.array(z.string()).optional(),
|
|
18
|
+
status: z.enum(['active', 'archived']).optional(),
|
|
19
|
+
}),
|
|
20
|
+
category: 'custom',
|
|
21
|
+
permissions: [],
|
|
22
|
+
readOnly: false,
|
|
23
|
+
destructive: false,
|
|
24
|
+
concurrencySafe: true,
|
|
25
|
+
async execute({ id, ...updates }) {
|
|
26
|
+
if (Object.values(updates).every((value) => value === undefined)) {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
output: 'Provide a correction or status to update.',
|
|
30
|
+
error: 'No memory update supplied',
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const memoryId = asMemoryId(id)
|
|
34
|
+
// Patch only requested fields in one store operation. A read/merge of
|
|
35
|
+
// provenance here would overwrite metadata from a concurrent writer.
|
|
36
|
+
const entry = await store.update(memoryId, updates)
|
|
37
|
+
if (!entry)
|
|
38
|
+
return {
|
|
39
|
+
success: false,
|
|
40
|
+
output: `Memory ${id} no longer exists.`,
|
|
41
|
+
error: 'Memory not found',
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
success: true,
|
|
45
|
+
output: `Memory updated: ${id} — ${entry.title} (${entry.status}).`,
|
|
46
|
+
data: { id, status: entry.status },
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
}
|
|
@@ -29,6 +29,12 @@ export interface TaskHandle {
|
|
|
29
29
|
export type SiblingFailurePolicy = 'continue' | 'cancel-siblings'
|
|
30
30
|
|
|
31
31
|
export interface CreateTaskOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Revalidate host authority at actual admission, including after a capacity wait.
|
|
34
|
+
* Queue retries may invoke this more than once; checks must tolerate repeated calls.
|
|
35
|
+
*/
|
|
36
|
+
readonly beforeStart?: () => Promise<void>
|
|
37
|
+
|
|
32
38
|
/**
|
|
33
39
|
* Observe events from this one delegated run when the scheduler can expose
|
|
34
40
|
* them.
|
package/src/types/agent/task.ts
CHANGED
|
@@ -122,6 +122,7 @@ export interface AgentTask {
|
|
|
122
122
|
agentId: string
|
|
123
123
|
agent: Agent<BaseAgentConfig, BaseAgentResult>
|
|
124
124
|
childAbortController: AbortController
|
|
125
|
+
/** While pending admission this is the submitting authority; admitted tasks receive child scope. */
|
|
125
126
|
context: AgentTaskContext
|
|
126
127
|
state: AgentTaskState
|
|
127
128
|
result?: BaseAgentResult
|
|
@@ -142,6 +143,12 @@ export interface AgentTask {
|
|
|
142
143
|
* WorkspaceRef triple atomically on every spawn.
|
|
143
144
|
*/
|
|
144
145
|
export interface SendMessageOptions {
|
|
146
|
+
/**
|
|
147
|
+
* Revalidate host authority before admission, including after a capacity wait.
|
|
148
|
+
* Queue retries may invoke this more than once; checks must tolerate repeated calls.
|
|
149
|
+
*/
|
|
150
|
+
readonly beforeStart?: () => Promise<void>
|
|
151
|
+
|
|
145
152
|
/** See {@link import('./scheduler.js').CreateTaskOptions.toolScope}. Deny-only. */
|
|
146
153
|
readonly toolScope?: { readonly deny: readonly string[] }
|
|
147
154
|
/** See {@link import('./scheduler.js').CreateTaskOptions.personaOverride}. */
|
|
@@ -179,6 +186,12 @@ export interface SendMessageOptions {
|
|
|
179
186
|
}
|
|
180
187
|
|
|
181
188
|
export interface AgentManagerConfig {
|
|
189
|
+
/** Reject a full parent immediately (default), or retain bounded pending task handles. */
|
|
190
|
+
capacityBehavior?: 'reject' | 'queue'
|
|
191
|
+
|
|
192
|
+
/** Maximum tasks awaiting admission across this manager. Defaults to 128. */
|
|
193
|
+
maxPendingTasks?: number
|
|
194
|
+
|
|
182
195
|
maxDepth: number
|
|
183
196
|
|
|
184
197
|
evictionMs: number
|
|
@@ -30,6 +30,12 @@ export interface ComputerUseCapabilities {
|
|
|
30
30
|
readonly keyboard: boolean
|
|
31
31
|
readonly cursorPosition: boolean
|
|
32
32
|
readonly clipboard: boolean
|
|
33
|
+
/** Exact action subset when known. Refines the broad flags; absent retains their legacy interpretation. */
|
|
34
|
+
readonly supportedActions?: readonly ComputerUseAction['type'][]
|
|
35
|
+
/** Supported click buttons; absent leaves button admission to the host. */
|
|
36
|
+
readonly mouseClickButtons?: readonly MouseButton[]
|
|
37
|
+
/** Supported drag buttons; absent leaves button admission to the host. */
|
|
38
|
+
readonly mouseDragButtons?: readonly MouseButton[]
|
|
33
39
|
/**
|
|
34
40
|
* Why every flag above is false, when a host loaded but the desktop did
|
|
35
41
|
* not answer — a WSL process with PowerShell and no interactive Windows
|
|
@@ -157,7 +157,7 @@ export const DEFAULT_ERROR_RULES: readonly ErrorCatalogRule[] = [
|
|
|
157
157
|
id: 'provider.rate_limit',
|
|
158
158
|
when: (facts) => facts.code === 'rate_limit' || facts.status === 429,
|
|
159
159
|
message: 'The provider is rate limiting this run.',
|
|
160
|
-
hint: '
|
|
160
|
+
hint: 'Respect the provider retry delay when reported. Lower concurrency, or wait for the quota window to reset before resuming.',
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
id: 'provider.context_overflow',
|
package/src/types/hitl/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { WorkingStateSnapshot } from '../../compaction/wire.js'
|
|
|
2
2
|
import type { SerializedSpanContext } from '../../telemetry/attributes.js'
|
|
3
3
|
import type { CostInfo, TokenUsage } from '../common/index.js'
|
|
4
4
|
import type { CheckpointId, PlanId, RunId } from '../ids/index.js'
|
|
5
|
-
import type { Message } from '../message/index.js'
|
|
5
|
+
import type { Message, UserMessage } from '../message/index.js'
|
|
6
6
|
import type { PlanStatus } from '../plan/index.js'
|
|
7
7
|
import type { TokenBudgetBinding } from '../run/token-budget-store.js'
|
|
8
8
|
|
|
@@ -212,6 +212,16 @@ export interface IterationCheckpoint {
|
|
|
212
212
|
runId: RunId
|
|
213
213
|
iteration: number
|
|
214
214
|
messages: Message[]
|
|
215
|
+
/**
|
|
216
|
+
* Current operator/goal/steering text and provenance, independent of
|
|
217
|
+
* compacted history. Attachments are not duplicated here. Older
|
|
218
|
+
* checkpoints omit this field and use surviving history on resume.
|
|
219
|
+
*/
|
|
220
|
+
latestUserMessage?: UserMessage
|
|
221
|
+
/** Structured host-review rejections consumed at this checkpoint, independent of compacted messages. */
|
|
222
|
+
structuredReviewAttempts?: number
|
|
223
|
+
/** Native structured-output corrections consumed independently of message history. */
|
|
224
|
+
nativeStructuredAttempts?: number
|
|
215
225
|
tokenUsage: TokenUsage
|
|
216
226
|
costInfo: CostInfo
|
|
217
227
|
/**
|
|
@@ -31,11 +31,19 @@ export interface MemoryContent {
|
|
|
31
31
|
readonly metadata?: Record<string, unknown>
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** Metadata and body observed together at one store read boundary. */
|
|
35
|
+
export interface MemoryRecord {
|
|
36
|
+
readonly entry: MemoryIndexEntry
|
|
37
|
+
readonly content: MemoryContent
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
export interface MemorySearchParams {
|
|
35
41
|
readonly query?: string
|
|
36
42
|
readonly tags?: string[]
|
|
37
43
|
readonly status?: MemoryStatus
|
|
38
44
|
readonly limit?: number
|
|
45
|
+
/** Match at least one exact normalized word token before limiting results. Empty means no constraint. */
|
|
46
|
+
readonly requiredIdentifiers?: readonly string[]
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
export interface MemorySearchResult {
|
|
@@ -52,10 +60,17 @@ export interface CreateMemoryParams {
|
|
|
52
60
|
readonly metadata?: Record<string, unknown>
|
|
53
61
|
}
|
|
54
62
|
|
|
63
|
+
/** Change a memory's content or explicitly archive/reactivate it. */
|
|
64
|
+
export interface UpdateMemoryParams extends Partial<CreateMemoryParams> {
|
|
65
|
+
readonly status?: MemoryStatus
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
export interface MemoryStore {
|
|
56
69
|
create(params: CreateMemoryParams): Promise<{ entry: MemoryIndexEntry; content: MemoryContent }>
|
|
57
70
|
get(id: MemoryId): Promise<MemoryContent | undefined>
|
|
58
|
-
|
|
71
|
+
/** Current metadata/body snapshot; supports rechecking status after search. */
|
|
72
|
+
getRecord?(id: MemoryId): Promise<MemoryRecord | undefined>
|
|
73
|
+
update(id: MemoryId, updates: UpdateMemoryParams): Promise<MemoryIndexEntry | undefined>
|
|
59
74
|
delete(id: MemoryId): Promise<boolean>
|
|
60
75
|
list(params?: MemorySearchParams): Promise<MemorySearchResult>
|
|
61
76
|
}
|
|
@@ -18,6 +18,7 @@ import type { ProjectId } from '../session/ids.js'
|
|
|
18
18
|
*/
|
|
19
19
|
export interface ProjectConfig {
|
|
20
20
|
maxDelegationDepth: number
|
|
21
|
+
/** Maximum pending or active direct delegations; completed history does not consume capacity. */
|
|
21
22
|
maxDelegationWidth: number
|
|
22
23
|
maxInterventionDepth: number
|
|
23
24
|
sharedMemoryStores?: readonly MemoryStoreRef[]
|
|
@@ -121,6 +121,8 @@ export interface MockProviderConfig extends MockScript {
|
|
|
121
121
|
* degradation is loud instead of silent.
|
|
122
122
|
*/
|
|
123
123
|
export interface ProviderCapabilities {
|
|
124
|
+
/** Native JSON Schema response-format mapping. Absent means unsupported. */
|
|
125
|
+
supportsNativeStructuredOutput?: boolean
|
|
124
126
|
supportsTools: boolean
|
|
125
127
|
supportsStreaming: boolean
|
|
126
128
|
supportsFunctionCalling: boolean
|
|
@@ -14,6 +14,10 @@ export interface ModelInfo {
|
|
|
14
14
|
* the answer; it must not be read as text-only.
|
|
15
15
|
*/
|
|
16
16
|
inputModalities?: readonly ModelInputModality[]
|
|
17
|
+
/** Exact selectable effort levels for this model and route. Absent means unknown; [] means unsupported. */
|
|
18
|
+
reasoningEffortLevels?: readonly import('./chat.js').ReasoningEffort[]
|
|
19
|
+
/** Published default, when established; must belong to reasoningEffortLevels when both are present. */
|
|
20
|
+
reasoningEffortDefault?: import('./chat.js').ReasoningEffort
|
|
17
21
|
/**
|
|
18
22
|
* Tokens the model's context holds, when the driver knows.
|
|
19
23
|
*
|
|
@@ -29,6 +29,8 @@ export type AnswerReview =
|
|
|
29
29
|
export interface AnswerReviewContext {
|
|
30
30
|
readonly runId: RunId
|
|
31
31
|
readonly iteration: number
|
|
32
|
+
/** Run cancellation; reviewers should forward it to verification operations. */
|
|
33
|
+
readonly signal?: AbortSignal
|
|
32
34
|
/** The full history, so a reviewer can see how the answer was reached. */
|
|
33
35
|
readonly messages: readonly Message[]
|
|
34
36
|
}
|
package/src/types/run/events.ts
CHANGED
|
@@ -101,6 +101,16 @@ interface RunEventEnvelope {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
type CoreRunEvent =
|
|
104
|
+
| {
|
|
105
|
+
type: 'tool_calls_admitted'
|
|
106
|
+
runId: RunId
|
|
107
|
+
kind: 'initialize' | 'batch' | 'nested' | 'retry'
|
|
108
|
+
/** Newly reserved attempts; zero only for ledger initialization. */
|
|
109
|
+
count: number
|
|
110
|
+
/** Cumulative reserved attempts, including abandoned reservations. */
|
|
111
|
+
used: number
|
|
112
|
+
limit: number
|
|
113
|
+
}
|
|
104
114
|
| { type: 'run_started'; runId: RunId; systemPrompt?: string }
|
|
105
115
|
| { type: 'iteration_started'; runId: RunId; iteration: number }
|
|
106
116
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RunId } from '../ids/index.js'
|
|
2
|
-
import type { Message } from '../message/index.js'
|
|
2
|
+
import type { Message, UserMessage } from '../message/index.js'
|
|
3
3
|
import type { ToolChoice } from '../provider/chat.js'
|
|
4
4
|
import type { Skill } from '../skills/index.js'
|
|
5
5
|
import type { StepResult } from './step.js'
|
|
@@ -21,6 +21,24 @@ export interface PrepareStepContext {
|
|
|
21
21
|
readonly stepNumber: number
|
|
22
22
|
/** Full history as it stands, so a decision can read what happened. */
|
|
23
23
|
readonly messages: readonly Message[]
|
|
24
|
+
/**
|
|
25
|
+
* Latest operator, goal-round, or steering input accepted by this run,
|
|
26
|
+
* retained even when compaction removes it from `messages`. Project
|
|
27
|
+
* instructions and task-completion context do not replace operator intent.
|
|
28
|
+
*/
|
|
29
|
+
readonly latestUserMessage?: UserMessage
|
|
30
|
+
/** The run's cancellation signal, for bounded asynchronous preparation. */
|
|
31
|
+
readonly signal?: AbortSignal
|
|
32
|
+
/**
|
|
33
|
+
* Estimated room for additional step context after existing messages,
|
|
34
|
+
* earlier stages' system/skills, and a response reserve. Recomputed for
|
|
35
|
+
* each stage and its selected model; not a billing limit or fit guarantee.
|
|
36
|
+
* `beforeStep` observes its existing boundary before compaction runs.
|
|
37
|
+
*/
|
|
38
|
+
readonly contextBudget?: {
|
|
39
|
+
readonly remainingTokens: number
|
|
40
|
+
readonly windowTokens: number
|
|
41
|
+
}
|
|
24
42
|
/** Every completed step, in order. */
|
|
25
43
|
readonly steps: readonly StepResult[]
|
|
26
44
|
|
|
@@ -181,6 +181,20 @@ export interface SandboxFileEntry {
|
|
|
181
181
|
readonly size: number
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/** A bounded search; patterns and depth are relative to the requested root. */
|
|
185
|
+
export interface SandboxWalkFilesOptions {
|
|
186
|
+
readonly pattern?: string
|
|
187
|
+
readonly signal?: AbortSignal
|
|
188
|
+
/** Direct children have depth 1. Omitted means no additional depth bound. */
|
|
189
|
+
readonly maxDepth?: number
|
|
190
|
+
/** Positive safe integer bounding emitted matching files. */
|
|
191
|
+
readonly maxEntries: number
|
|
192
|
+
/** Positive safe integer bounding examined directory entries; defaults to 20,000. */
|
|
193
|
+
readonly maxVisitedEntries?: number
|
|
194
|
+
/** Match hidden names through wildcards; explicit dotfile patterns always work. Defaults to false. */
|
|
195
|
+
readonly includeHidden?: boolean
|
|
196
|
+
}
|
|
197
|
+
|
|
184
198
|
// ---------------------------------------------------------------------------
|
|
185
199
|
// Sandbox interface — the core abstraction
|
|
186
200
|
// ---------------------------------------------------------------------------
|
|
@@ -294,6 +308,13 @@ export interface Sandbox {
|
|
|
294
308
|
* MAY throw for other I/O failures.
|
|
295
309
|
*/
|
|
296
310
|
listFiles(rootPath: string): Promise<readonly SandboxFileEntry[]>
|
|
311
|
+
/**
|
|
312
|
+
* Lazily enumerate regular files as absolute paths, without following symlinks.
|
|
313
|
+
* Cancellation and iterator return stop traversal. Exceeding the examined-entry
|
|
314
|
+
* budget throws an error with code `ERR_FILE_WALK_LIMIT`; it is not an empty or
|
|
315
|
+
* complete listing. Hosts requiring bounded search must refuse an absent method.
|
|
316
|
+
*/
|
|
317
|
+
walkFiles?(rootPath: string, options: SandboxWalkFilesOptions): AsyncIterable<SandboxFileEntry>
|
|
297
318
|
/**
|
|
298
319
|
* Release every resource owned by this sandbox.
|
|
299
320
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { z } from 'zod'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Configuration for
|
|
4
|
+
* Configuration for validated output via tool constraint or native JSON Schema.
|
|
5
5
|
*
|
|
6
6
|
* This configuration allows an agent to produce validated, typed output by
|
|
7
|
-
* presenting the output schema as a
|
|
7
|
+
* presenting the output schema as a tool by default, or as a native response format.
|
|
8
8
|
*/
|
|
9
9
|
export interface StructuredOutputConfig<TSchema extends z.ZodType = z.ZodType> {
|
|
10
10
|
/**
|
|
@@ -13,6 +13,9 @@ export interface StructuredOutputConfig<TSchema extends z.ZodType = z.ZodType> {
|
|
|
13
13
|
*/
|
|
14
14
|
schema: TSchema
|
|
15
15
|
|
|
16
|
+
/** Default tool constraint, or native JSON schema on an explicitly capable driver. */
|
|
17
|
+
mode?: 'tool' | 'native'
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Turns spent re-prompting when the model answers in prose or fails
|
|
18
21
|
* validation. Defaults to {@link DEFAULT_STRUCTURED_OUTPUT_RETRIES}.
|
|
@@ -21,6 +24,16 @@ export interface StructuredOutputConfig<TSchema extends z.ZodType = z.ZodType> {
|
|
|
21
24
|
* than iterating against `maxIterations`.
|
|
22
25
|
*/
|
|
23
26
|
maxRetries?: number
|
|
27
|
+
|
|
28
|
+
/** Review the JSON-decoded result before settlement. Narrow the value before use: serialization may change schema output types. Exceptions fail the run; cancellation is propagated. */
|
|
29
|
+
review?: (
|
|
30
|
+
output: unknown,
|
|
31
|
+
context: import('../run/answer-review.js').AnswerReviewContext,
|
|
32
|
+
) =>
|
|
33
|
+
| import('../run/answer-review.js').AnswerReview
|
|
34
|
+
| Promise<import('../run/answer-review.js').AnswerReview>
|
|
35
|
+
/** Corrections allowed after host rejection, separate from schema retries. Default 3; zero allows no correction. */
|
|
36
|
+
maxReviews?: number
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
/**
|
package/src/types/tool/index.ts
CHANGED
|
@@ -14,6 +14,8 @@ import type { ToolPresentation } from './presentation.js'
|
|
|
14
14
|
|
|
15
15
|
export interface ToolRegistryRef {
|
|
16
16
|
searchDeferred(query: string): ToolDefinition[]
|
|
17
|
+
/** Ranked active matches, when this registry supports active-tool discovery. */
|
|
18
|
+
searchActive?(query: string): ToolDefinition[]
|
|
17
19
|
activate(names: string[]): void
|
|
18
20
|
getAvailability(name: string): ToolAvailability
|
|
19
21
|
}
|
|
@@ -633,6 +635,18 @@ export interface ToolDefinition<TInput = unknown> extends ToolPresentation<TInpu
|
|
|
633
635
|
isDestructive?(input: TInput): boolean
|
|
634
636
|
isConcurrencySafe?(input: TInput): boolean
|
|
635
637
|
|
|
638
|
+
/**
|
|
639
|
+
* Opt-in ordering boundary in a direct model tool-call batch. Earlier
|
|
640
|
+
* calls settle before this call starts; later calls wait for this call
|
|
641
|
+
* to settle (including failed results). Defaults to false. Independent
|
|
642
|
+
* calls between barriers retain their existing concurrency-safe behavior.
|
|
643
|
+
* Nested dispatch is owned by its enclosing call, not separately queued;
|
|
644
|
+
* mark the enclosing tool as a barrier to isolate its nested operations.
|
|
645
|
+
* Deadlines still abandon uncooperative tools: settlement does not prove
|
|
646
|
+
* their external effects have stopped, and does not imply success.
|
|
647
|
+
*/
|
|
648
|
+
executionBarrier?: boolean
|
|
649
|
+
|
|
636
650
|
/**
|
|
637
651
|
* Where this tool came from, when it did not come from here.
|
|
638
652
|
*
|
|
@@ -763,6 +777,8 @@ export interface ToolRegistryContract {
|
|
|
763
777
|
suspendAll(): void
|
|
764
778
|
hasSuspended(): boolean
|
|
765
779
|
searchDeferred(query: string): ToolDefinition[]
|
|
780
|
+
/** Ranked active matches, when this registry supports active-tool discovery. */
|
|
781
|
+
searchActive?(query: string): ToolDefinition[]
|
|
766
782
|
getCallableTools(toolNames?: string[]): ToolDefinition[]
|
|
767
783
|
|
|
768
784
|
/**
|