@namzu/sdk 59.0.0 → 60.1.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 +120 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +1 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +16 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/acp/update.d.ts.map +1 -1
- package/dist/bridge/acp/update.js +1 -0
- package/dist/bridge/acp/update.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +12 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/compaction/context-window.d.ts +53 -0
- package/dist/compaction/context-window.d.ts.map +1 -1
- package/dist/compaction/context-window.js +141 -2
- package/dist/compaction/context-window.js.map +1 -1
- package/dist/constants/continuation.d.ts +9 -0
- package/dist/constants/continuation.d.ts.map +1 -1
- package/dist/constants/continuation.js +9 -0
- package/dist/constants/continuation.js.map +1 -1
- package/dist/contracts/session/api.d.ts +7 -1
- package/dist/contracts/session/api.d.ts.map +1 -1
- package/dist/execution/workflow/index.d.ts +3 -1
- package/dist/execution/workflow/index.d.ts.map +1 -1
- package/dist/execution/workflow/index.js +2 -1
- package/dist/execution/workflow/index.js.map +1 -1
- package/dist/execution/workflow/journal.d.ts +24 -4
- package/dist/execution/workflow/journal.d.ts.map +1 -1
- package/dist/execution/workflow/journal.js +131 -9
- package/dist/execution/workflow/journal.js.map +1 -1
- package/dist/execution/workflow/prelude.d.ts +2 -0
- package/dist/execution/workflow/prelude.d.ts.map +1 -1
- package/dist/execution/workflow/prelude.js +49 -8
- package/dist/execution/workflow/prelude.js.map +1 -1
- package/dist/execution/workflow/resume.d.ts +59 -0
- package/dist/execution/workflow/resume.d.ts.map +1 -0
- package/dist/execution/workflow/resume.js +273 -0
- package/dist/execution/workflow/resume.js.map +1 -0
- package/dist/execution/workflow/runtime.d.ts.map +1 -1
- package/dist/execution/workflow/runtime.js +112 -8
- package/dist/execution/workflow/runtime.js.map +1 -1
- package/dist/execution/workflow/types.d.ts +105 -1
- package/dist/execution/workflow/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +1 -0
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/plugin/compat.d.ts +24 -0
- package/dist/plugin/compat.d.ts.map +1 -0
- package/dist/plugin/compat.js +149 -0
- package/dist/plugin/compat.js.map +1 -0
- package/dist/plugin/loader.d.ts +2 -1
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +6 -0
- package/dist/plugin/loader.js.map +1 -1
- package/dist/pricing/index.d.ts.map +1 -1
- package/dist/pricing/index.js +2 -1
- package/dist/pricing/index.js.map +1 -1
- package/dist/process/kill-tree.d.ts +44 -0
- package/dist/process/kill-tree.d.ts.map +1 -1
- package/dist/process/kill-tree.js +102 -4
- package/dist/process/kill-tree.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +9 -1
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts.map +1 -1
- package/dist/provider/collect-chat-completion.js +4 -0
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +11 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +5 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/mock.d.ts +2 -0
- package/dist/provider/mock.d.ts.map +1 -1
- package/dist/provider/mock.js +16 -8
- package/dist/provider/mock.js.map +1 -1
- package/dist/provider/model-window-suffix.d.ts +18 -0
- package/dist/provider/model-window-suffix.d.ts.map +1 -0
- package/dist/provider/model-window-suffix.js +78 -0
- package/dist/provider/model-window-suffix.js.map +1 -0
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +5 -0
- package/dist/provider/retry.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 +5 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +1 -0
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts +1 -4
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +0 -28
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.d.ts +6 -0
- package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.js +11 -0
- package/dist/runtime/jobs/awaited-jobs.js.map +1 -1
- package/dist/runtime/jobs/host-exit-finalizer.d.ts +20 -0
- package/dist/runtime/jobs/host-exit-finalizer.d.ts.map +1 -0
- package/dist/runtime/jobs/host-exit-finalizer.js +57 -0
- package/dist/runtime/jobs/host-exit-finalizer.js.map +1 -0
- package/dist/runtime/jobs/liveness.d.ts +67 -0
- package/dist/runtime/jobs/liveness.d.ts.map +1 -0
- package/dist/runtime/jobs/liveness.js +94 -0
- package/dist/runtime/jobs/liveness.js.map +1 -0
- package/dist/runtime/jobs/registry.d.ts +21 -0
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +104 -2
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/jobs/wake-budget.d.ts +35 -0
- package/dist/runtime/jobs/wake-budget.d.ts.map +1 -0
- package/dist/runtime/jobs/wake-budget.js +48 -0
- package/dist/runtime/jobs/wake-budget.js.map +1 -0
- package/dist/runtime/query/detached-calls.d.ts +65 -0
- package/dist/runtime/query/detached-calls.d.ts.map +1 -0
- package/dist/runtime/query/detached-calls.js +116 -0
- package/dist/runtime/query/detached-calls.js.map +1 -0
- package/dist/runtime/query/executor.d.ts +4 -1
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +90 -6
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +34 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +32 -5
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/effort-clamp.d.ts +13 -0
- package/dist/runtime/query/iteration/effort-clamp.d.ts.map +1 -0
- package/dist/runtime/query/iteration/effort-clamp.js +42 -0
- package/dist/runtime/query/iteration/effort-clamp.js.map +1 -0
- package/dist/runtime/query/iteration/index.d.ts +34 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +199 -6
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.js +11 -3
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +9 -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 +63 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +6 -0
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/session-storage.d.ts.map +1 -1
- package/dist/runtime/query/session-storage.js +8 -3
- package/dist/runtime/query/session-storage.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +29 -3
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +58 -3
- package/dist/runtime/query/steering.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/runtime/system-events.d.ts +5 -0
- package/dist/runtime/system-events.d.ts.map +1 -1
- package/dist/runtime/system-events.js +7 -1
- package/dist/runtime/system-events.js.map +1 -1
- package/dist/sandbox/denial.d.ts +11 -0
- package/dist/sandbox/denial.d.ts.map +1 -0
- package/dist/sandbox/denial.js +61 -0
- package/dist/sandbox/denial.js.map +1 -0
- package/dist/sandbox/file-walk-program.d.ts.map +1 -1
- package/dist/sandbox/file-walk-program.js +31 -13
- package/dist/sandbox/file-walk-program.js.map +1 -1
- package/dist/sandbox/file-walk.d.ts +2 -0
- package/dist/sandbox/file-walk.d.ts.map +1 -1
- package/dist/sandbox/file-walk.js +64 -13
- package/dist/sandbox/file-walk.js.map +1 -1
- package/dist/sandbox/ignore-matcher.d.ts +30 -0
- package/dist/sandbox/ignore-matcher.d.ts.map +1 -0
- package/dist/sandbox/ignore-matcher.js +11 -0
- package/dist/sandbox/ignore-matcher.js.map +1 -0
- package/dist/sandbox/ignore-source.d.ts +26 -0
- package/dist/sandbox/ignore-source.d.ts.map +1 -0
- package/dist/sandbox/ignore-source.js +221 -0
- package/dist/sandbox/ignore-source.js.map +1 -0
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +11 -1
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +1 -0
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/session/log-hash.d.ts.map +1 -1
- package/dist/session/log-hash.js +18 -1
- package/dist/session/log-hash.js.map +1 -1
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +1 -1
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/memory/markdown.d.ts.map +1 -1
- package/dist/store/memory/markdown.js +1 -1
- package/dist/store/memory/markdown.js.map +1 -1
- package/dist/store/memory/operation-lock.d.ts +20 -4
- package/dist/store/memory/operation-lock.d.ts.map +1 -1
- package/dist/store/memory/operation-lock.js +235 -58
- package/dist/store/memory/operation-lock.js.map +1 -1
- package/dist/store/session-index/sqlite.d.ts.map +1 -1
- package/dist/store/session-index/sqlite.js +169 -16
- package/dist/store/session-index/sqlite.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +10 -4
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +35 -0
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +512 -67
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts +1 -0
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +65 -28
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts +2 -0
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +94 -40
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/job.d.ts +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +34 -7
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/search-support.d.ts +44 -0
- package/dist/tools/builtins/search-support.d.ts.map +1 -0
- package/dist/tools/builtins/search-support.js +89 -0
- package/dist/tools/builtins/search-support.js.map +1 -0
- package/dist/tools/builtins/wait-for-job-bounds.d.ts +2 -0
- package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job-bounds.js +3 -1
- package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +13 -2
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +14 -5
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/turn/reporter.d.ts.map +1 -1
- package/dist/turn/reporter.js +11 -0
- package/dist/turn/reporter.js.map +1 -1
- package/dist/types/agent/query.d.ts +2 -0
- package/dist/types/agent/query.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +129 -13
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.js.map +1 -1
- package/dist/types/message/index.d.ts +1 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +1 -0
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +24 -0
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +4 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +19 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +7 -0
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/index.d.ts +1 -1
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +15 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +6 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +38 -1
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/session/events.d.ts +34 -0
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/records.d.ts +298 -34
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +35 -1
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/session/stop-reason.d.ts +11 -0
- package/dist/types/session/stop-reason.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +30 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +8 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +1 -0
- package/src/bridge/a2a/mapper.ts +19 -0
- package/src/bridge/acp/update.ts +6 -1
- package/src/bridge/sse/mapper.ts +13 -0
- package/src/compaction/context-window.ts +163 -2
- package/src/constants/continuation.ts +13 -0
- package/src/contracts/session/api.ts +6 -0
- package/src/execution/workflow/index.ts +14 -1
- package/src/execution/workflow/journal.ts +161 -11
- package/src/execution/workflow/prelude.ts +51 -8
- package/src/execution/workflow/resume.ts +313 -0
- package/src/execution/workflow/runtime.ts +127 -9
- package/src/execution/workflow/types.ts +109 -1
- package/src/index.ts +17 -0
- package/src/manager/session/turn-recorder.ts +1 -0
- package/src/plugin/compat.ts +173 -0
- package/src/plugin/loader.ts +7 -1
- package/src/pricing/index.ts +2 -1
- package/src/process/kill-tree.ts +106 -4
- package/src/prompt/coding-agent-doctrine.ts +9 -1
- package/src/provider/collect-chat-completion.ts +3 -0
- package/src/provider/fallback.ts +17 -0
- package/src/provider/idle-timeout.ts +9 -0
- package/src/provider/mock.ts +19 -9
- package/src/provider/model-window-suffix.ts +85 -0
- package/src/provider/retry.ts +9 -0
- package/src/public-runtime.ts +21 -2
- package/src/public-types.ts +1 -0
- package/src/registry/command/kernel-commands.ts +1 -32
- package/src/runtime/jobs/awaited-jobs.ts +11 -0
- package/src/runtime/jobs/host-exit-finalizer.ts +67 -0
- package/src/runtime/jobs/liveness.ts +144 -0
- package/src/runtime/jobs/registry.ts +114 -2
- package/src/runtime/jobs/wake-budget.ts +55 -0
- package/src/runtime/query/detached-calls.ts +135 -0
- package/src/runtime/query/executor.ts +92 -10
- package/src/runtime/query/index.ts +65 -7
- package/src/runtime/query/iteration/effort-clamp.ts +46 -0
- package/src/runtime/query/iteration/index.ts +260 -6
- package/src/runtime/query/iteration/outstanding-work.ts +12 -3
- package/src/runtime/query/iteration/phases/context.ts +9 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +73 -8
- package/src/runtime/query/iteration/stream-turn.ts +5 -0
- package/src/runtime/query/session-storage.ts +8 -3
- package/src/runtime/query/steering.ts +77 -6
- package/src/runtime/query/tooling.ts +2 -0
- package/src/runtime/system-events.ts +12 -1
- package/src/sandbox/denial.ts +79 -0
- package/src/sandbox/file-walk-program.ts +32 -13
- package/src/sandbox/file-walk.ts +75 -12
- package/src/sandbox/ignore-matcher.ts +46 -0
- package/src/sandbox/ignore-source.ts +220 -0
- package/src/sandbox/provider/local.ts +11 -1
- package/src/scheduler/completion-inbox.ts +1 -0
- package/src/session/log-hash.ts +21 -0
- package/src/store/memory/disk.ts +1 -0
- package/src/store/memory/markdown.ts +1 -0
- package/src/store/memory/operation-lock.ts +288 -57
- package/src/store/session-index/sqlite.ts +171 -16
- package/src/tools/builtins/bash.ts +11 -4
- package/src/tools/builtins/computer-use.ts +593 -68
- package/src/tools/builtins/glob.ts +79 -32
- package/src/tools/builtins/grep.ts +107 -43
- package/src/tools/builtins/job.ts +42 -12
- package/src/tools/builtins/search-support.ts +107 -0
- package/src/tools/builtins/wait-for-job-bounds.ts +5 -1
- package/src/tools/builtins/wait-for-job.ts +14 -2
- package/src/tools/command-shell.ts +13 -5
- package/src/turn/reporter.ts +12 -0
- package/src/types/agent/query.ts +2 -0
- package/src/types/computer-use/index.ts +157 -15
- package/src/types/message/index.ts +5 -3
- package/src/types/plugin/index.ts +8 -0
- package/src/types/provider/chat.ts +20 -0
- package/src/types/provider/config.ts +7 -0
- package/src/types/provider/index.ts +1 -0
- package/src/types/provider/interface.ts +20 -0
- package/src/types/provider/stream.ts +6 -0
- package/src/types/sandbox/index.ts +40 -1
- package/src/types/session/events.ts +65 -5
- package/src/types/session/records.ts +39 -2
- package/src/types/session/stop-reason.ts +11 -0
- package/src/types/tool/index.ts +30 -0
- package/src/types/tool/presentation.ts +8 -0
|
@@ -60,6 +60,8 @@ export type JobWaitOutcome =
|
|
|
60
60
|
/** Which clock ran out. */
|
|
61
61
|
readonly cause: 'idle' | 'wall'
|
|
62
62
|
readonly elapsedMs: number
|
|
63
|
+
/** How long the job had been silent when the wait gave up. */
|
|
64
|
+
readonly quietForMs: number
|
|
63
65
|
} & JobWaitProgress)
|
|
64
66
|
|
|
65
67
|
/**
|
|
@@ -167,6 +169,7 @@ export async function waitForJobWithBounds(
|
|
|
167
169
|
kind: 'timeout',
|
|
168
170
|
cause: 'wall',
|
|
169
171
|
elapsedMs: elapsed,
|
|
172
|
+
quietForMs: now() - lastProgressAt,
|
|
170
173
|
output,
|
|
171
174
|
nextOffset: cursor,
|
|
172
175
|
droppedBytes,
|
|
@@ -182,6 +185,7 @@ export async function waitForJobWithBounds(
|
|
|
182
185
|
kind: 'timeout',
|
|
183
186
|
cause: 'idle',
|
|
184
187
|
elapsedMs: elapsed,
|
|
188
|
+
quietForMs: quietFor,
|
|
185
189
|
output,
|
|
186
190
|
nextOffset: cursor,
|
|
187
191
|
droppedBytes,
|
|
@@ -214,7 +218,7 @@ export function describeJobWaitTimeout(
|
|
|
214
218
|
const seconds = Math.round(outcome.elapsedMs / 1000)
|
|
215
219
|
const resume = `call wait_for_job or job read with from_offset ${outcome.nextOffset} to see only what comes next`
|
|
216
220
|
if (outcome.cause === 'idle') {
|
|
217
|
-
return `Job ${id} went quiet: no new output for
|
|
221
|
+
return `Job ${id} went quiet: no new output for ${Math.round(outcome.quietForMs / 1000)}s (waited ${seconds}s). It has not been stopped and may still be working — ${resume}.`
|
|
218
222
|
}
|
|
219
223
|
return `Job ${id} has been running for ${seconds}s without finishing. It has not been stopped — ${resume}.`
|
|
220
224
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
|
|
3
3
|
import { invalidBackgroundJobIdInput } from '../../runtime/jobs/job-id.js'
|
|
4
|
+
import { LIVENESS_STALLED_MS } from '../../runtime/jobs/liveness.js'
|
|
4
5
|
import { readPositiveIntEnv } from '../../utils/env.js'
|
|
5
6
|
import { defineTool } from '../defineTool.js'
|
|
6
7
|
import { describeJobWaitTimeout, waitForJobWithBounds } from './wait-for-job-bounds.js'
|
|
@@ -20,7 +21,7 @@ import { describeJobWaitTimeout, waitForJobWithBounds } from './wait-for-job-bou
|
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
const DEFAULT_TIMEOUT_MS = readPositiveIntEnv('NAMZU_JOB_WAIT_TIMEOUT_MS', 5 * 60 * 1000)
|
|
23
|
-
const DEFAULT_IDLE_TIMEOUT_MS = readPositiveIntEnv('NAMZU_JOB_WAIT_IDLE_MS',
|
|
24
|
+
const DEFAULT_IDLE_TIMEOUT_MS = readPositiveIntEnv('NAMZU_JOB_WAIT_IDLE_MS', LIVENESS_STALLED_MS)
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* The longest either bound will accept from the model.
|
|
@@ -146,7 +147,11 @@ export const WaitForJobTool = defineTool({
|
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
if (input.output_stream !== undefined && input.output_contains === undefined) {
|
|
149
|
-
return {
|
|
150
|
+
return {
|
|
151
|
+
success: false,
|
|
152
|
+
output: '',
|
|
153
|
+
error: 'output_stream requires output_contains.',
|
|
154
|
+
}
|
|
150
155
|
}
|
|
151
156
|
if (input.output_contains !== undefined) {
|
|
152
157
|
if (!jobs.waitForOutput) {
|
|
@@ -261,6 +266,13 @@ export const WaitForJobTool = defineTool({
|
|
|
261
266
|
}
|
|
262
267
|
}
|
|
263
268
|
|
|
269
|
+
// The exit and its output are in this result, so the notice that would
|
|
270
|
+
// announce the same exit is withdrawn rather than repeated. Only when
|
|
271
|
+
// the model was given all of it: output the retention cap dropped, or
|
|
272
|
+
// that this bounded result omitted, leaves the notice in place.
|
|
273
|
+
if (outcome.kind === 'exited' && outcome.droppedBytes === 0 && outcome.omittedOutputBytes === 0)
|
|
274
|
+
jobs.markCollected?.(input.id)
|
|
275
|
+
|
|
264
276
|
const notices = [
|
|
265
277
|
...(outcome.droppedBytes > 0
|
|
266
278
|
? [`[${outcome.droppedBytes} bytes were dropped by the job's output retention cap]`]
|
|
@@ -55,7 +55,7 @@ import { randomUUID } from 'node:crypto'
|
|
|
55
55
|
import { constants, accessSync, existsSync } from 'node:fs'
|
|
56
56
|
import { delimiter, isAbsolute, join, win32 } from 'node:path'
|
|
57
57
|
|
|
58
|
-
import { MSYS_TAG_VARIABLE, registerMsysShell } from '../process/kill-tree.js'
|
|
58
|
+
import { MSYS_TAG_VARIABLE, registerMsysShell, registerProcessTag } from '../process/kill-tree.js'
|
|
59
59
|
import type { ShellDialect } from '../types/tool/index.js'
|
|
60
60
|
|
|
61
61
|
/** The shell a host-side command runs in. */
|
|
@@ -452,8 +452,14 @@ export function spawnHostShell(
|
|
|
452
452
|
const spawnFn = options.spawnImpl ?? nodeSpawn
|
|
453
453
|
const shell = options.shell ?? hostCommandShell()
|
|
454
454
|
const spawned = hostShellSpawn(command, options.env, shell)
|
|
455
|
-
//
|
|
456
|
-
|
|
455
|
+
// Tag the shell so a kill can find what a forked command left: under Git
|
|
456
|
+
// Bash, the processes its runtime forked out of the Windows tree's reach; on
|
|
457
|
+
// Linux, the ones that started their own session and so left the process
|
|
458
|
+
// group. Other platforms have neither a bash runtime nor `/proc` to look in.
|
|
459
|
+
const platform = options.platform ?? process.platform
|
|
460
|
+
const windowsBash = shell.windows === true && shell.path !== undefined
|
|
461
|
+
const tag =
|
|
462
|
+
windowsBash || (shell.windows !== true && platform === 'linux') ? randomUUID() : undefined
|
|
457
463
|
const resolved =
|
|
458
464
|
tag === undefined ? spawned : { ...spawned, env: { ...spawned.env, [MSYS_TAG_VARIABLE]: tag } }
|
|
459
465
|
const common: SpawnOptions = {
|
|
@@ -471,8 +477,10 @@ export function spawnHostShell(
|
|
|
471
477
|
}
|
|
472
478
|
if (resolved.file !== undefined) {
|
|
473
479
|
const child = spawnFn(resolved.file, [...resolved.args], common)
|
|
474
|
-
if (tag !== undefined && child !== null && typeof child === 'object')
|
|
475
|
-
registerMsysShell(child, { bash: resolved.file, tag })
|
|
480
|
+
if (tag !== undefined && child !== null && typeof child === 'object') {
|
|
481
|
+
if (windowsBash) registerMsysShell(child, { bash: resolved.file, tag })
|
|
482
|
+
else registerProcessTag(child, tag)
|
|
483
|
+
}
|
|
476
484
|
return child
|
|
477
485
|
}
|
|
478
486
|
const windows = windowsCmdSpawn(command, resolved.env)
|
package/src/turn/reporter.ts
CHANGED
|
@@ -422,6 +422,18 @@ export function createTurnReporter(parentLogger?: Logger): TurnReporter {
|
|
|
422
422
|
})
|
|
423
423
|
break
|
|
424
424
|
|
|
425
|
+
case 'model_refusal':
|
|
426
|
+
log.warn('Model declined to answer', {
|
|
427
|
+
[NAMZU.TURN_ID]: event.turnId,
|
|
428
|
+
[NAMZU.ITERATION]: event.iteration,
|
|
429
|
+
'namzu.turn.from_model': event.model,
|
|
430
|
+
'namzu.turn.from_provider_id': event.providerId,
|
|
431
|
+
'namzu.turn.outcome': event.outcome,
|
|
432
|
+
'namzu.turn.to_model': event.fallbackModel,
|
|
433
|
+
'namzu.turn.category': event.category,
|
|
434
|
+
})
|
|
435
|
+
break
|
|
436
|
+
|
|
425
437
|
case 'provider_fallback':
|
|
426
438
|
// `warn` for the same reason as a retry, and one stronger: the rest
|
|
427
439
|
// of this turn is being served by a provider the caller did not pick.
|
package/src/types/agent/query.ts
CHANGED
|
@@ -98,6 +98,8 @@ export interface QueryAgentConfig extends BaseAgentConfig {
|
|
|
98
98
|
maxToolConcurrency?: number
|
|
99
99
|
/** See {@link QueryParams.maxOutputContinuations}. */
|
|
100
100
|
maxOutputContinuations?: QueryParams['maxOutputContinuations']
|
|
101
|
+
/** See {@link QueryParams.refusalFallback}. */
|
|
102
|
+
refusalFallback?: QueryParams['refusalFallback']
|
|
101
103
|
maxToolOutputChars?: number
|
|
102
104
|
maxToolOutputCharsPerMessage?: number
|
|
103
105
|
retainedToolPreviewChars?: QueryParams['retainedToolPreviewChars']
|
|
@@ -207,6 +207,15 @@ export interface FocusWindowResult {
|
|
|
207
207
|
readonly ok: boolean
|
|
208
208
|
/** The window in front after the attempt, or null when none could be read. */
|
|
209
209
|
readonly focusedId: string | null
|
|
210
|
+
/**
|
|
211
|
+
* Set with `detail` when the host did not try at all (the screen was in
|
|
212
|
+
* use, a prompt had it, the user said no). `not_delivered` / `safe` means
|
|
213
|
+
* nothing was done and asking again later is fine.
|
|
214
|
+
*/
|
|
215
|
+
readonly delivery?: ActionDelivery
|
|
216
|
+
readonly retrySafety?: ActionRetrySafety
|
|
217
|
+
/** Why, in words the model can act on. */
|
|
218
|
+
readonly detail?: string
|
|
210
219
|
}
|
|
211
220
|
|
|
212
221
|
/**
|
|
@@ -231,9 +240,13 @@ export type UiElementAction =
|
|
|
231
240
|
*/
|
|
232
241
|
export interface UiElement {
|
|
233
242
|
/**
|
|
234
|
-
* Opaque reference for {@link ComputerUseHost.uiAct}
|
|
235
|
-
*
|
|
236
|
-
*
|
|
243
|
+
* Opaque reference for {@link ComputerUseHost.uiAct}. It names the control,
|
|
244
|
+
* not one reading of it: a host that can find the control again keeps the
|
|
245
|
+
* ref usable across snapshots, and fails with a {@link UiActFailureCode}
|
|
246
|
+
* when it cannot. Empty for an element the host cannot act on (a label, a
|
|
247
|
+
* group), which is in the tree for what it says. A host may also give a
|
|
248
|
+
* ref to a region it left unexpanded (see {@link UiElement.hiddenChildren});
|
|
249
|
+
* that ref is the `root` of a drill-down snapshot, not a target for `uiAct`.
|
|
237
250
|
*/
|
|
238
251
|
readonly ref: string
|
|
239
252
|
/** Platform role, e.g. `Button`, `Edit`, `ListItem` (UIA ControlType) or `AXButton`. */
|
|
@@ -248,6 +261,12 @@ export interface UiElement {
|
|
|
248
261
|
readonly states?: readonly string[]
|
|
249
262
|
readonly actions?: readonly UiElementAction[]
|
|
250
263
|
readonly children?: readonly UiElement[]
|
|
264
|
+
/**
|
|
265
|
+
* How many children of this element the host left out of the snapshot to
|
|
266
|
+
* keep it short. Read them with a snapshot whose {@link UiSnapshotOptions.root}
|
|
267
|
+
* is this element's ref.
|
|
268
|
+
*/
|
|
269
|
+
readonly hiddenChildren?: number
|
|
251
270
|
}
|
|
252
271
|
|
|
253
272
|
/**
|
|
@@ -264,8 +283,41 @@ export interface UiSnapshot {
|
|
|
264
283
|
readonly root: UiElement
|
|
265
284
|
/** True when the host stopped walking the tree before it ended (a size or time bound). */
|
|
266
285
|
readonly truncated?: boolean
|
|
286
|
+
/**
|
|
287
|
+
* True when the tree is an outline of a larger one: regions carry
|
|
288
|
+
* {@link UiElement.hiddenChildren} and can be opened with
|
|
289
|
+
* {@link UiSnapshotOptions.root}.
|
|
290
|
+
*/
|
|
291
|
+
readonly outline?: boolean
|
|
292
|
+
/** How many controls the whole window holds, when the host knows. */
|
|
293
|
+
readonly total?: number
|
|
294
|
+
/** True when this snapshot is one region of the window (it was asked for with `root`). */
|
|
295
|
+
readonly region?: boolean
|
|
296
|
+
/** For a region listed in pages: the `offset` that reads the page after this one. */
|
|
297
|
+
readonly next?: number
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* What a snapshot is asked to read.
|
|
302
|
+
*
|
|
303
|
+
* @experimental See {@link ComputerUseCapabilities.uiTree}.
|
|
304
|
+
*/
|
|
305
|
+
export interface UiSnapshotOptions {
|
|
306
|
+
/** A ref from an earlier snapshot: read only that element's subtree. Refs outside it stay valid. */
|
|
307
|
+
readonly root?: string
|
|
308
|
+
/** With `root`: skip this many of the region's children (the page a snapshot reported as `next`). */
|
|
309
|
+
readonly offset?: number
|
|
310
|
+
/** Only controls whose text contains this (case-insensitive), with the elements above them. */
|
|
311
|
+
readonly query?: string
|
|
267
312
|
}
|
|
268
313
|
|
|
314
|
+
/** Why a ref could not be acted on, as a typed failure. */
|
|
315
|
+
export type UiActFailureCode =
|
|
316
|
+
/** The control the ref named is gone, or no longer something that can be acted on. */
|
|
317
|
+
| 'STALE_REF'
|
|
318
|
+
/** Several controls fit what the ref named; the host did not guess. */
|
|
319
|
+
| 'AMBIGUOUS_TARGET'
|
|
320
|
+
|
|
269
321
|
/**
|
|
270
322
|
* What {@link ComputerUseHost.uiAct} did.
|
|
271
323
|
*
|
|
@@ -275,6 +327,51 @@ export interface UiActResult {
|
|
|
275
327
|
readonly ok: boolean
|
|
276
328
|
/** Why it did not, in words the model can act on (a stale ref, a disabled element). */
|
|
277
329
|
readonly detail?: string
|
|
330
|
+
/** Set when the ref could not be resolved to one control; nothing was sent. */
|
|
331
|
+
readonly code?: UiActFailureCode
|
|
332
|
+
/** What is known about the effect. Absent from a host that does not classify. */
|
|
333
|
+
readonly delivery?: ActionDelivery
|
|
334
|
+
/** Whether repeating the action blindly is safe. Set together with `delivery`. */
|
|
335
|
+
readonly retrySafety?: ActionRetrySafety
|
|
336
|
+
/** The state read back after a stateful action, when the host could read it. */
|
|
337
|
+
readonly readBack?: {
|
|
338
|
+
readonly expected?: string
|
|
339
|
+
readonly observed?: string
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* How far an action is known to have taken effect.
|
|
345
|
+
*
|
|
346
|
+
* - `delivered_verified`: the host read the state back and it matches.
|
|
347
|
+
* - `delivered_unverified`: the input was sent (or may have been) and no
|
|
348
|
+
* read-back confirmed it. A failed or impossible read-back lands here, never
|
|
349
|
+
* in `not_delivered`.
|
|
350
|
+
* - `not_delivered`: the action was refused before any input, or a read-back
|
|
351
|
+
* proved the state did not change.
|
|
352
|
+
*/
|
|
353
|
+
export type ActionDelivery = 'delivered_verified' | 'delivered_unverified' | 'not_delivered'
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* `safe`: nothing reached the target, so the same action may be repeated.
|
|
357
|
+
* `unsafe`: the action may have taken effect; inspect before repeating it.
|
|
358
|
+
*/
|
|
359
|
+
export type ActionRetrySafety = 'safe' | 'unsafe'
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* What a window-scoped input action learned about its own delivery.
|
|
363
|
+
*
|
|
364
|
+
* @experimental See {@link ComputerUseHost.executeWindow}.
|
|
365
|
+
*/
|
|
366
|
+
export interface WindowInputResult {
|
|
367
|
+
readonly delivery: ActionDelivery
|
|
368
|
+
readonly retrySafety: ActionRetrySafety
|
|
369
|
+
readonly detail?: string
|
|
370
|
+
/** What the window read afterwards, when the host verified the input by reading it. */
|
|
371
|
+
readonly readBack?: {
|
|
372
|
+
readonly expected?: string
|
|
373
|
+
readonly observed?: string
|
|
374
|
+
}
|
|
278
375
|
}
|
|
279
376
|
|
|
280
377
|
export interface Point {
|
|
@@ -294,7 +391,11 @@ export type ComputerUseAction =
|
|
|
294
391
|
| { readonly type: 'screenshot' }
|
|
295
392
|
| { readonly type: 'cursor_position' }
|
|
296
393
|
| { readonly type: 'mouse_move'; readonly to: Point }
|
|
297
|
-
| {
|
|
394
|
+
| {
|
|
395
|
+
readonly type: 'mouse_click'
|
|
396
|
+
readonly at: Point
|
|
397
|
+
readonly button: MouseButton
|
|
398
|
+
}
|
|
298
399
|
| {
|
|
299
400
|
readonly type: 'mouse_drag'
|
|
300
401
|
readonly from: Point
|
|
@@ -335,7 +436,13 @@ export function assertComputerUseActionType(type: ComputerUseAction['type']): vo
|
|
|
335
436
|
export type ComputerUseResult =
|
|
336
437
|
| { readonly type: 'screenshot'; readonly result: ScreenshotResult }
|
|
337
438
|
| { readonly type: 'cursor_position'; readonly point: Point }
|
|
338
|
-
| {
|
|
439
|
+
| {
|
|
440
|
+
readonly type: 'ok'
|
|
441
|
+
/** Set by a host that can tell more than "the call returned". */
|
|
442
|
+
readonly delivery?: ActionDelivery
|
|
443
|
+
readonly retrySafety?: ActionRetrySafety
|
|
444
|
+
readonly detail?: string
|
|
445
|
+
}
|
|
339
446
|
|
|
340
447
|
/**
|
|
341
448
|
* A state-changing desktop action started, but its subprocess did not report
|
|
@@ -370,49 +477,84 @@ export interface ComputerUseHost {
|
|
|
370
477
|
* Points in `action` are physical pixels relative to the display of the
|
|
371
478
|
* most recent capture; a `screenshot` result carries that display in
|
|
372
479
|
* {@link ScreenshotResult.display}.
|
|
480
|
+
*
|
|
481
|
+
* Every method that reaches the desktop takes a trailing `signal`: the
|
|
482
|
+
* tool call's cancellation (the user interrupted the turn). On abort a host
|
|
483
|
+
* stops waiting for the desktop and answers at once. An action that may
|
|
484
|
+
* already have been sent answers `delivered_unverified` with `retrySafety:
|
|
485
|
+
* 'unsafe'`; one that provably was not answers `not_delivered` with
|
|
486
|
+
* `'safe'`. A read throws.
|
|
373
487
|
*/
|
|
374
|
-
execute(action: ComputerUseAction): Promise<ComputerUseResult>
|
|
488
|
+
execute(action: ComputerUseAction, signal?: AbortSignal): Promise<ComputerUseResult>
|
|
375
489
|
|
|
376
490
|
/**
|
|
377
491
|
* The visible, titled top-level windows, front to back where the platform
|
|
378
492
|
* knows the order. Offered to the model only with
|
|
379
493
|
* {@link ComputerUseCapabilities.windows}.
|
|
380
494
|
*/
|
|
381
|
-
listWindows?(): Promise<readonly WindowInfo[]>
|
|
495
|
+
listWindows?(signal?: AbortSignal): Promise<readonly WindowInfo[]>
|
|
382
496
|
/**
|
|
383
497
|
* Bring a window to the front, restoring it when minimized. Offered only
|
|
384
498
|
* with {@link ComputerUseCapabilities.windows}.
|
|
385
499
|
*/
|
|
386
|
-
focusWindow?(id: string): Promise<FocusWindowResult>
|
|
500
|
+
focusWindow?(id: string, signal?: AbortSignal): Promise<FocusWindowResult>
|
|
501
|
+
/**
|
|
502
|
+
* The model's turn `turnId` is making a tool call. A host that keeps state
|
|
503
|
+
* per turn (an Escape stop, refused permissions) starts a new one when the
|
|
504
|
+
* id changes.
|
|
505
|
+
*/
|
|
506
|
+
beginTurn?(turnId: string): void
|
|
507
|
+
/**
|
|
508
|
+
* The model's turn ended or was interrupted. A host releases anything it
|
|
509
|
+
* holds for the turn: a lease on the screen, an input monitor, a window it
|
|
510
|
+
* moved forward.
|
|
511
|
+
*/
|
|
512
|
+
endTurn?(): void | Promise<void>
|
|
387
513
|
/** Capture a named window. Never silently replace a failed capture with the desktop. */
|
|
388
|
-
captureWindow?(id: string): Promise<WindowScreenshotResult>
|
|
514
|
+
captureWindow?(id: string, signal?: AbortSignal): Promise<WindowScreenshotResult>
|
|
389
515
|
/**
|
|
390
516
|
* Act in the PNG pixel space of `captureId`. The host must verify the
|
|
391
517
|
* capture is current and still belongs to the same process/window before
|
|
392
518
|
* dispatching input. No implicit fallback to display input is permitted.
|
|
393
519
|
*/
|
|
394
|
-
|
|
520
|
+
// `void` stays in the union: a host that returns nothing (`Promise<void>`) must keep compiling.
|
|
521
|
+
executeWindow?(
|
|
522
|
+
captureId: string,
|
|
523
|
+
action: WindowInputAction,
|
|
524
|
+
signal?: AbortSignal,
|
|
525
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: widening an existing `Promise<void>` return
|
|
526
|
+
): Promise<void | WindowInputResult>
|
|
395
527
|
/**
|
|
396
528
|
* Capture one region of the current display at full physical resolution.
|
|
397
529
|
* `rect` is display-relative physical pixels; the result's `width` and
|
|
398
530
|
* `height` are the region's. Used by `zoom` when
|
|
399
531
|
* {@link ComputerUseCapabilities.regionCapture} is set.
|
|
400
532
|
*/
|
|
401
|
-
captureRegion?(rect: Rect): Promise<ScreenshotResult>
|
|
533
|
+
captureRegion?(rect: Rect, signal?: AbortSignal): Promise<ScreenshotResult>
|
|
402
534
|
/**
|
|
403
535
|
* The accessibility tree of one window, or of the focused window when
|
|
404
|
-
* `windowId` is omitted.
|
|
536
|
+
* `windowId` is omitted. With `options.root` only that element's subtree is
|
|
537
|
+
* read. Offered only with {@link ComputerUseCapabilities.uiTree}.
|
|
405
538
|
*
|
|
406
539
|
* @experimental
|
|
407
540
|
*/
|
|
408
|
-
uiSnapshot?(
|
|
541
|
+
uiSnapshot?(
|
|
542
|
+
windowId?: string,
|
|
543
|
+
options?: UiSnapshotOptions,
|
|
544
|
+
signal?: AbortSignal,
|
|
545
|
+
): Promise<UiSnapshot>
|
|
409
546
|
/**
|
|
410
|
-
* Act on an element from
|
|
547
|
+
* Act on an element from an earlier {@link uiSnapshot}. `value` is the text
|
|
411
548
|
* for `set_value`. Offered only with {@link ComputerUseCapabilities.uiTree}.
|
|
412
549
|
*
|
|
413
550
|
* @experimental
|
|
414
551
|
*/
|
|
415
|
-
uiAct?(
|
|
552
|
+
uiAct?(
|
|
553
|
+
ref: string,
|
|
554
|
+
action: UiElementAction,
|
|
555
|
+
value?: string,
|
|
556
|
+
signal?: AbortSignal,
|
|
557
|
+
): Promise<UiActResult>
|
|
416
558
|
|
|
417
559
|
initialize?(): Promise<void>
|
|
418
560
|
dispose?(): Promise<void>
|
|
@@ -367,6 +367,7 @@ export const RUNTIME_CONTEXT_MESSAGE_KINDS = [
|
|
|
367
367
|
'peer-notice',
|
|
368
368
|
'reminder',
|
|
369
369
|
'repeat-call',
|
|
370
|
+
'refusal-retry',
|
|
370
371
|
'steering',
|
|
371
372
|
'step-context',
|
|
372
373
|
'structured-output',
|
|
@@ -695,9 +696,10 @@ export function createTurnContextEntry(
|
|
|
695
696
|
}
|
|
696
697
|
|
|
697
698
|
/** The key a recorded context entry is filed under, or undefined for any other message. */
|
|
698
|
-
export function turnContextKey(message: {
|
|
699
|
-
|
|
700
|
-
|
|
699
|
+
export function turnContextKey(message: {
|
|
700
|
+
readonly role: string
|
|
701
|
+
readonly source?: unknown
|
|
702
|
+
}): string | undefined {
|
|
701
703
|
if (message.role !== 'user') return undefined
|
|
702
704
|
const source = message.source as RuntimeContextMessageSource | undefined
|
|
703
705
|
return source?.type === 'runtime-context' && source.kind === 'turn-context'
|
|
@@ -549,6 +549,10 @@ export interface PluginManifest {
|
|
|
549
549
|
* owns delegation, not by the runtime.
|
|
550
550
|
*/
|
|
551
551
|
readonly agents?: readonly string[]
|
|
552
|
+
/** Operating systems the plugin supports, as `process.platform` names them. Absent means all. */
|
|
553
|
+
readonly platforms?: readonly string[]
|
|
554
|
+
/** Runtime versions the plugin supports. Absent means any. */
|
|
555
|
+
readonly engines?: { readonly namzu?: string }
|
|
552
556
|
}
|
|
553
557
|
|
|
554
558
|
export const PluginMCPServerConfigSchema = z
|
|
@@ -589,6 +593,10 @@ export const PluginManifestSchema = z.object({
|
|
|
589
593
|
personas: z.array(z.string()).max(MAX_PERSONAS_PER_PLUGIN).optional(),
|
|
590
594
|
commands: z.array(PluginRelativeDirSchema).max(MAX_COMMAND_DIRS_PER_PLUGIN).optional(),
|
|
591
595
|
agents: z.array(PluginRelativeDirSchema).max(MAX_AGENT_DIRS_PER_PLUGIN).optional(),
|
|
596
|
+
/** Operating systems the plugin supports, as `process.platform` names them. Absent means all. */
|
|
597
|
+
platforms: z.array(z.string().min(1)).max(16).optional(),
|
|
598
|
+
/** Runtime versions the plugin supports. Absent means any. */
|
|
599
|
+
engines: z.object({ namzu: z.string().min(1).max(200).optional() }).optional(),
|
|
592
600
|
})
|
|
593
601
|
|
|
594
602
|
// ---------------------------------------------------------------------------
|
|
@@ -184,6 +184,24 @@ export type ReasoningEffort =
|
|
|
184
184
|
| 'max'
|
|
185
185
|
| 'ultra'
|
|
186
186
|
|
|
187
|
+
/**
|
|
188
|
+
* What a provider says about a reply it declined to give.
|
|
189
|
+
*
|
|
190
|
+
* Carried beside `finishReason: 'content_filter'` and set whenever the finish
|
|
191
|
+
* was a refusal or a safety block, so a host can tell a model that declined
|
|
192
|
+
* from a reply that was merely empty. Every field is optional because
|
|
193
|
+
* providers differ in what they report and several report a refusal with no
|
|
194
|
+
* detail at all: an empty object means "refused, nothing more is known".
|
|
195
|
+
*/
|
|
196
|
+
export interface ProviderRefusal {
|
|
197
|
+
/** The provider's own classification of why, when it gives one (for example `cyber`). */
|
|
198
|
+
category?: string
|
|
199
|
+
/** The provider's own sentence about the refusal. Show it; do not parse it. */
|
|
200
|
+
explanation?: string
|
|
201
|
+
/** A model the provider says can usually serve the request instead. */
|
|
202
|
+
recommendedModel?: string
|
|
203
|
+
}
|
|
204
|
+
|
|
187
205
|
export interface ChatCompletionResponse {
|
|
188
206
|
id: string
|
|
189
207
|
model: string
|
|
@@ -206,5 +224,7 @@ export interface ChatCompletionResponse {
|
|
|
206
224
|
* window rather than the output token limit; see `StreamChunk.finishDetail`.
|
|
207
225
|
*/
|
|
208
226
|
finishDetail?: 'context_window'
|
|
227
|
+
/** Set with `finishReason: 'content_filter'` when the provider declined to answer. */
|
|
228
|
+
refusal?: ProviderRefusal
|
|
209
229
|
usage: TokenUsage
|
|
210
230
|
}
|
|
@@ -72,6 +72,8 @@ export interface MockTurn {
|
|
|
72
72
|
/** Passages this scripted turn cites, emitted before its text. */
|
|
73
73
|
citations?: import('../message/index.js').Citation[]
|
|
74
74
|
finishReason?: 'stop' | 'tool_calls' | 'length' | 'content_filter'
|
|
75
|
+
/** What the provider says about a `'content_filter'` finish. Defaults to `{}`. */
|
|
76
|
+
refusal?: import('./chat.js').ProviderRefusal
|
|
75
77
|
usage?: Partial<import('../common/index.js').TokenUsage>
|
|
76
78
|
/** Text fragment size. */
|
|
77
79
|
chunkSize?: number
|
|
@@ -106,6 +108,11 @@ export interface MockScript {
|
|
|
106
108
|
* registry-level declaration cannot express "a driver with no vision".
|
|
107
109
|
*/
|
|
108
110
|
capabilities?: ProviderCapabilities
|
|
111
|
+
/**
|
|
112
|
+
* The model this provider names when asked where to re-run a refused
|
|
113
|
+
* request (`LLMProvider.refusalFallbackFor`). Absent means it names none.
|
|
114
|
+
*/
|
|
115
|
+
refusalFallbackModel?: string
|
|
109
116
|
/** Observe every request (assert on tools, toolChoice, cacheControl…). */
|
|
110
117
|
onRequest?: (params: import('./chat.js').ChatCompletionParams) => void
|
|
111
118
|
}
|
|
@@ -236,4 +236,24 @@ export interface LLMProvider {
|
|
|
236
236
|
* run that would otherwise work.
|
|
237
237
|
*/
|
|
238
238
|
resolveContextWindow?(model: string, signal?: AbortSignal): Promise<number | undefined>
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The model to re-run a refused request on, when this provider has one.
|
|
242
|
+
*
|
|
243
|
+
* Called after `model` declined to answer (`finishReason: 'content_filter'`),
|
|
244
|
+
* with whatever the provider said about it. Answer with a different model
|
|
245
|
+
* this provider and this credential can actually use, or `undefined` when
|
|
246
|
+
* there is none: the turn then does not change model. A driver whose
|
|
247
|
+
* service names a recommended model in `refusal.recommendedModel` should
|
|
248
|
+
* use it only after checking it is one this account can serve, and falls
|
|
249
|
+
* back to its own declared order otherwise.
|
|
250
|
+
*
|
|
251
|
+
* Optional. A provider without it never has its model swapped on a
|
|
252
|
+
* refusal. A request that failed for any other reason does not call this.
|
|
253
|
+
*/
|
|
254
|
+
refusalFallbackFor?(
|
|
255
|
+
model: string,
|
|
256
|
+
refusal: import('./chat.js').ProviderRefusal,
|
|
257
|
+
signal?: AbortSignal,
|
|
258
|
+
): Promise<string | undefined>
|
|
239
259
|
}
|
|
@@ -132,6 +132,12 @@ export interface StreamChunk {
|
|
|
132
132
|
* room to continue into. Set only with `finishReason: 'length'`.
|
|
133
133
|
*/
|
|
134
134
|
finishDetail?: 'context_window'
|
|
135
|
+
/**
|
|
136
|
+
* The provider declined to answer. Set with `finishReason: 'content_filter'`
|
|
137
|
+
* by every driver whose finish was a refusal or a safety block; an empty
|
|
138
|
+
* object when the provider gave no detail.
|
|
139
|
+
*/
|
|
140
|
+
refusal?: import('./chat.js').ProviderRefusal
|
|
135
141
|
usage?: TokenUsage
|
|
136
142
|
error?: string
|
|
137
143
|
|
|
@@ -89,6 +89,18 @@ export function assertSandboxEnvironment(env: SandboxEnvironment): void {
|
|
|
89
89
|
// Exec result
|
|
90
90
|
// ---------------------------------------------------------------------------
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* A backend's reading of why a non-zero result is not simply "the command
|
|
94
|
+
* failed". Inference from the error text, never proof.
|
|
95
|
+
*
|
|
96
|
+
* - `denial`: the sandbox appears to have refused a file access.
|
|
97
|
+
* - `runner-failure`: the launcher failed before the command ran.
|
|
98
|
+
*/
|
|
99
|
+
export interface SandboxExecAttribution {
|
|
100
|
+
readonly kind: 'denial' | 'runner-failure'
|
|
101
|
+
readonly message: string
|
|
102
|
+
}
|
|
103
|
+
|
|
92
104
|
export interface SandboxExecResult {
|
|
93
105
|
readonly exitCode: number
|
|
94
106
|
readonly stdout: string
|
|
@@ -107,6 +119,8 @@ export interface SandboxExecResult {
|
|
|
107
119
|
*/
|
|
108
120
|
readonly stdoutTruncated?: boolean
|
|
109
121
|
readonly stderrTruncated?: boolean
|
|
122
|
+
/** Set when a non-zero exit looks like a sandbox denial or a launcher failure. */
|
|
123
|
+
readonly attribution?: SandboxExecAttribution
|
|
110
124
|
}
|
|
111
125
|
|
|
112
126
|
// ---------------------------------------------------------------------------
|
|
@@ -189,10 +203,35 @@ export interface SandboxWalkFilesOptions {
|
|
|
189
203
|
readonly maxDepth?: number
|
|
190
204
|
/** Positive safe integer bounding emitted matching files. */
|
|
191
205
|
readonly maxEntries: number
|
|
192
|
-
/**
|
|
206
|
+
/**
|
|
207
|
+
* Positive safe integer bounding examined directory entries; defaults to
|
|
208
|
+
* 500,000. Reaching it ends the walk with the entries found so far (see
|
|
209
|
+
* {@link SandboxWalkSummary.stopped}) unless `failOnLimit` is set.
|
|
210
|
+
*/
|
|
193
211
|
readonly maxVisitedEntries?: number
|
|
194
212
|
/** Match hidden names through wildcards; explicit dotfile patterns always work. Defaults to false. */
|
|
195
213
|
readonly includeHidden?: boolean
|
|
214
|
+
/**
|
|
215
|
+
* Skip files and directories matched by `.gitignore`, `.ignore` and
|
|
216
|
+
* `.git/info/exclude` (the first only inside a git repository), and never
|
|
217
|
+
* descend into version-control directories. The root itself is never
|
|
218
|
+
* skipped. Defaults to true; pass false to walk ignored trees too.
|
|
219
|
+
*/
|
|
220
|
+
readonly respectIgnore?: boolean
|
|
221
|
+
/** Throw an error with code `ERR_FILE_WALK_LIMIT` at `maxVisitedEntries` instead of ending. Defaults to false. */
|
|
222
|
+
readonly failOnLimit?: boolean
|
|
223
|
+
/** Called once when the walk ends, with how it ended. A walker that cannot report omits the call. */
|
|
224
|
+
readonly onSummary?: (summary: SandboxWalkSummary) => void
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** How a bounded walk ended. */
|
|
228
|
+
export interface SandboxWalkSummary {
|
|
229
|
+
/** Directory entries examined. */
|
|
230
|
+
readonly visited: number
|
|
231
|
+
/** Directories skipped because an ignore rule matched them. */
|
|
232
|
+
readonly ignoredDirectories: number
|
|
233
|
+
/** Present when the walk ended at its entry bound, so the entries are not the whole tree. */
|
|
234
|
+
readonly stopped?: 'entry-limit'
|
|
196
235
|
}
|
|
197
236
|
|
|
198
237
|
// ---------------------------------------------------------------------------
|