@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
|
@@ -71,6 +71,7 @@ import type { Logger } from '../../utils/logger.js'
|
|
|
71
71
|
import { compressShellOutput } from '../../utils/shell-compress.js'
|
|
72
72
|
import { parseStructuredResultJson } from '../../utils/structured-result-json.js'
|
|
73
73
|
import { type BackgroundJobRegistry, type JobProcess, bindOwner } from '../jobs/registry.js'
|
|
74
|
+
import { type BatchDetach, stillRunningResult } from './detached-calls.js'
|
|
74
75
|
import {
|
|
75
76
|
type ToolAdmissionHost,
|
|
76
77
|
formatFailedToolOutput,
|
|
@@ -412,6 +413,8 @@ export interface ToolExecutorConfig {
|
|
|
412
413
|
* recorder gets no hold rather than a marking call that goes nowhere.
|
|
413
414
|
*/
|
|
414
415
|
onJobAwaited?: (id: string) => void
|
|
416
|
+
/** Where a tool result that handed the model a job's exit says so; see `ToolContext.backgroundJobs.markCollected`. */
|
|
417
|
+
onJobCollected?: (id: string) => void
|
|
415
418
|
/** The longest a monitor may live in this turn; see `QueryParams.monitorTimeoutCapMs`. */
|
|
416
419
|
monitorTimeoutCapMs?: number
|
|
417
420
|
/**
|
|
@@ -1429,6 +1432,7 @@ export class ToolExecutor {
|
|
|
1429
1432
|
preparedBatch?: PreparedToolBatch,
|
|
1430
1433
|
declines?: ToolCallDeclines,
|
|
1431
1434
|
review?: ReviewedExecution,
|
|
1435
|
+
detach?: BatchDetach,
|
|
1432
1436
|
): Promise<ToolExecutionBatch> {
|
|
1433
1437
|
const toolCalls = response.message.toolCalls
|
|
1434
1438
|
if (!toolCalls) {
|
|
@@ -1455,9 +1459,9 @@ export class ToolExecutor {
|
|
|
1455
1459
|
if (refusal) {
|
|
1456
1460
|
const refused = new Map(denials)
|
|
1457
1461
|
for (const call of toolCalls) if (!refused.has(call.id)) refused.set(call.id, refusal)
|
|
1458
|
-
return await this.runBatch(toolCalls, refused, prior, owned, declines, review)
|
|
1462
|
+
return await this.runBatch(toolCalls, refused, prior, owned, declines, review, detach)
|
|
1459
1463
|
}
|
|
1460
|
-
return await this.runBatch(toolCalls, denials, prior, owned, declines, review)
|
|
1464
|
+
return await this.runBatch(toolCalls, denials, prior, owned, declines, review, detach)
|
|
1461
1465
|
} finally {
|
|
1462
1466
|
// Cleared so a later single execution outside a batch resolves
|
|
1463
1467
|
// live rather than inheriting the last batch's sample.
|
|
@@ -1472,6 +1476,7 @@ export class ToolExecutor {
|
|
|
1472
1476
|
preparedBatch?: OwnedPreparedToolBatch,
|
|
1473
1477
|
declines?: ToolCallDeclines,
|
|
1474
1478
|
review?: ReviewedExecution,
|
|
1479
|
+
detach?: BatchDetach,
|
|
1475
1480
|
): Promise<ToolExecutionBatch> {
|
|
1476
1481
|
this.log.debug('Executing tool batch', {
|
|
1477
1482
|
[NAMZU.TURN_ID]: this.config.turnId,
|
|
@@ -1507,6 +1512,17 @@ export class ToolExecutor {
|
|
|
1507
1512
|
// (which let the last writer clobber the rest). Results are written by
|
|
1508
1513
|
// index to preserve the original tool-call order.
|
|
1509
1514
|
const results: ToolCallOutcome[] = new Array(toolCalls.length)
|
|
1515
|
+
// Calls handed back to the model as still running (see `detach`), and the
|
|
1516
|
+
// ones among them whose real outcome has been reported.
|
|
1517
|
+
const handedBack = new Set<string>()
|
|
1518
|
+
const reported = new Set<string>()
|
|
1519
|
+
// Calls that have begun; one queued behind a serial or barrier call has not.
|
|
1520
|
+
const started = new Set<string>()
|
|
1521
|
+
const reportLate = (outcome: ToolCallOutcome): void => {
|
|
1522
|
+
if (reported.has(outcome.toolCallId)) return
|
|
1523
|
+
reported.add(outcome.toolCallId)
|
|
1524
|
+
detach?.calls.settle(outcome)
|
|
1525
|
+
}
|
|
1510
1526
|
const parallel: Promise<void>[] = []
|
|
1511
1527
|
let serial: Promise<void> = Promise.resolve()
|
|
1512
1528
|
let barrier: Promise<void> | undefined
|
|
@@ -1623,13 +1639,32 @@ export class ToolExecutor {
|
|
|
1623
1639
|
}
|
|
1624
1640
|
const run = async () => {
|
|
1625
1641
|
try {
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1642
|
+
let outcome: ToolCallOutcome
|
|
1643
|
+
started.add(toolCall.id)
|
|
1644
|
+
try {
|
|
1645
|
+
outcome = await this.executeSingle(
|
|
1646
|
+
toolCall,
|
|
1647
|
+
ctx,
|
|
1648
|
+
recordObservation,
|
|
1649
|
+
() => progress.close(),
|
|
1650
|
+
preparedCall,
|
|
1651
|
+
)
|
|
1652
|
+
} catch (error) {
|
|
1653
|
+
// A call already answered with the placeholder has no batch
|
|
1654
|
+
// left to fail; its failure is its outcome.
|
|
1655
|
+
if (!handedBack.has(toolCall.id)) throw error
|
|
1656
|
+
reportLate({
|
|
1657
|
+
toolCallId: toolCall.id,
|
|
1658
|
+
toolName: toolCall.function.name,
|
|
1659
|
+
output: `Error: Tool "${toolCall.function.name}" did not complete — ${
|
|
1660
|
+
error instanceof Error ? error.message : String(error)
|
|
1661
|
+
}`,
|
|
1662
|
+
isError: true,
|
|
1663
|
+
})
|
|
1664
|
+
return
|
|
1665
|
+
}
|
|
1666
|
+
if (handedBack.has(toolCall.id)) reportLate(outcome)
|
|
1667
|
+
else results[i] = outcome
|
|
1633
1668
|
} finally {
|
|
1634
1669
|
await progress.close()
|
|
1635
1670
|
}
|
|
@@ -1664,7 +1699,46 @@ export class ToolExecutor {
|
|
|
1664
1699
|
schedule(safe ? gated : run, safe, isBarrier)
|
|
1665
1700
|
})
|
|
1666
1701
|
if (review) await this.walkReviewed(reviewUnits, results, review)
|
|
1667
|
-
|
|
1702
|
+
const completion = Promise.all([...parallel, serial])
|
|
1703
|
+
if (detach && !review) {
|
|
1704
|
+
const first = await Promise.race([
|
|
1705
|
+
completion.then(() => 'finished' as const),
|
|
1706
|
+
detach.requested.then(() => 'requested' as const),
|
|
1707
|
+
])
|
|
1708
|
+
if (first === 'requested' && toolCalls.some((_, i) => results[i] === undefined)) {
|
|
1709
|
+
// The operator wrote while calls were still running. Answer each
|
|
1710
|
+
// unfinished call with the placeholder so the model can read the
|
|
1711
|
+
// message now; the calls keep running and report themselves.
|
|
1712
|
+
toolCalls.forEach((toolCall, i) => {
|
|
1713
|
+
if (results[i]) return
|
|
1714
|
+
handedBack.add(toolCall.id)
|
|
1715
|
+
detach.calls.begin(toolCall.id, toolCall.function.name)
|
|
1716
|
+
results[i] = {
|
|
1717
|
+
toolCallId: toolCall.id,
|
|
1718
|
+
toolName: toolCall.function.name,
|
|
1719
|
+
output: stillRunningResult(toolCall.function.name, started.has(toolCall.id)),
|
|
1720
|
+
isError: false,
|
|
1721
|
+
}
|
|
1722
|
+
})
|
|
1723
|
+
const settleRest = (): void => {
|
|
1724
|
+
for (const id of handedBack) {
|
|
1725
|
+
if (reported.has(id)) continue
|
|
1726
|
+
const name = toolCalls.find((call) => call.id === id)?.function.name ?? 'tool'
|
|
1727
|
+
reportLate({
|
|
1728
|
+
toolCallId: id,
|
|
1729
|
+
toolName: name,
|
|
1730
|
+
output: `Error: Tool "${name}" did not complete — the batch failed before it produced a result.`,
|
|
1731
|
+
isError: true,
|
|
1732
|
+
})
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
completion.then(settleRest, settleRest)
|
|
1736
|
+
} else {
|
|
1737
|
+
await completion
|
|
1738
|
+
}
|
|
1739
|
+
} else {
|
|
1740
|
+
await completion
|
|
1741
|
+
}
|
|
1668
1742
|
|
|
1669
1743
|
// Whatever failed above left a hole in `results`; fill every one, so
|
|
1670
1744
|
// the invariant holds by construction rather than by everything having
|
|
@@ -2205,6 +2279,13 @@ export class ToolExecutor {
|
|
|
2205
2279
|
...(this.config.additionalDirectories?.length
|
|
2206
2280
|
? { additionalDirectories: this.config.additionalDirectories }
|
|
2207
2281
|
: {}),
|
|
2282
|
+
...(this.config.authorizationGate
|
|
2283
|
+
? {
|
|
2284
|
+
readDenied: (absolutePath: string) =>
|
|
2285
|
+
this.evaluatePreparedAuthorization('read', { path: absolutePath })?.decision ===
|
|
2286
|
+
'deny',
|
|
2287
|
+
}
|
|
2288
|
+
: {}),
|
|
2208
2289
|
...(this.outputDirectory()
|
|
2209
2290
|
? { retainedOutputDirectory: this.outputDirectory() as string }
|
|
2210
2291
|
: {}),
|
|
@@ -2300,6 +2381,7 @@ export class ToolExecutor {
|
|
|
2300
2381
|
}
|
|
2301
2382
|
: {}),
|
|
2302
2383
|
...(this.config.onJobAwaited ? { onAwaited: this.config.onJobAwaited } : {}),
|
|
2384
|
+
...(this.config.onJobCollected ? { onCollected: this.config.onJobCollected } : {}),
|
|
2303
2385
|
...(this.config.monitorTimeoutCapMs !== undefined
|
|
2304
2386
|
? { monitorTimeoutCapMs: this.config.monitorTimeoutCapMs }
|
|
2305
2387
|
: {}),
|
|
@@ -113,6 +113,7 @@ import {
|
|
|
113
113
|
SandboxAcquisitionStopped,
|
|
114
114
|
createDeferredSandbox,
|
|
115
115
|
} from './deferred-sandbox.js'
|
|
116
|
+
import { DetachedCalls } from './detached-calls.js'
|
|
116
117
|
import type { EventTranslator } from './events.js'
|
|
117
118
|
import { finalizeTurn } from './finalize-turn.js'
|
|
118
119
|
import { GuardCoordinator } from './guard.js'
|
|
@@ -150,6 +151,7 @@ import { acquireSandbox } from './sandbox-lifecycle.js'
|
|
|
150
151
|
import {
|
|
151
152
|
SteeringBinding,
|
|
152
153
|
type SteeringChannel,
|
|
154
|
+
formatJobExitNotice,
|
|
153
155
|
formatMonitorEnd,
|
|
154
156
|
formatMonitorEvent,
|
|
155
157
|
isOperatorUserMessage,
|
|
@@ -375,6 +377,20 @@ export interface QueryParams {
|
|
|
375
377
|
* before; `0` stops at the first cut-off.
|
|
376
378
|
*/
|
|
377
379
|
maxOutputContinuations?: number
|
|
380
|
+
/**
|
|
381
|
+
* What the turn does when the model declines to answer (its provider
|
|
382
|
+
* finished the reply as a refusal or a safety block).
|
|
383
|
+
*
|
|
384
|
+
* `'auto'` (the default) re-runs the refused request once on another model
|
|
385
|
+
* of the same provider (the one the provider recommends, or the one its
|
|
386
|
+
* own fallback order names) and keeps that model for the rest of the turn;
|
|
387
|
+
* a `model_refusal` event names the swap so a host can keep it for later
|
|
388
|
+
* turns. `'off'` never changes the model: the turn tries once more on the
|
|
389
|
+
* same model only when the refused reply had partial output, and otherwise
|
|
390
|
+
* settles with stop reason `'refused'`. A refused reply is never added to
|
|
391
|
+
* the history sent next.
|
|
392
|
+
*/
|
|
393
|
+
refusalFallback?: 'auto' | 'off'
|
|
378
394
|
|
|
379
395
|
/**
|
|
380
396
|
* Model-visible size cap for a single tool result. Over-budget output is
|
|
@@ -808,6 +824,28 @@ export interface QueryParams {
|
|
|
808
824
|
*/
|
|
809
825
|
waitForInbound?: (signal: AbortSignal) => Promise<void>
|
|
810
826
|
|
|
827
|
+
/**
|
|
828
|
+
* Answer the operator while a long tool call is still running.
|
|
829
|
+
*
|
|
830
|
+
* Default off. When on, and `waitForOperator` reports the operator wrote while
|
|
831
|
+
* a batch had been running for two seconds, each call not yet finished is answered with a "still running"
|
|
832
|
+
* placeholder so the model can read the message and reply at once. The
|
|
833
|
+
* calls are not interrupted and not repeated: their real results reach the
|
|
834
|
+
* model later in a message that names each call, and the turn is held open
|
|
835
|
+
* for them like any outstanding work. The host's wake is then also consulted
|
|
836
|
+
* during tool batches, not only when the turn would otherwise end. Ignored
|
|
837
|
+
* under per-call review, where the batch is waiting on a person.
|
|
838
|
+
*/
|
|
839
|
+
answerWhileCallsRun?: boolean
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Resolve when the operator wrote, and for no other reason. It is what
|
|
843
|
+
* `answerWhileCallsRun` listens to: a notice from a child agent or mail from
|
|
844
|
+
* a peer also wakes `waitForInbound`, but must not hand a running call back.
|
|
845
|
+
* Abort removes the waiter, as for `waitForInbound`.
|
|
846
|
+
*/
|
|
847
|
+
waitForOperator?: (signal: AbortSignal) => Promise<void>
|
|
848
|
+
|
|
811
849
|
/** Durable host input: normal append, flush and exact acknowledgement before inference. Requires sessionLog. */
|
|
812
850
|
durableInbound?: DurableInboundSource
|
|
813
851
|
|
|
@@ -1484,6 +1522,21 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1484
1522
|
)
|
|
1485
1523
|
: undefined
|
|
1486
1524
|
awaitedJobs?.attach()
|
|
1525
|
+
// A tool result has handed the model this job's exit: the notice that
|
|
1526
|
+
// would announce the same exit is taken back, and the host is told it was
|
|
1527
|
+
// delivered so the session does not wake the model for it either.
|
|
1528
|
+
const collectJob = (id: string): void => {
|
|
1529
|
+
const withdrawn = jobNotices?.withdraw(id) ?? false
|
|
1530
|
+
awaitedJobs?.collected(id)
|
|
1531
|
+
if (!pendingJobNoticeIds.delete(id) && !withdrawn) return
|
|
1532
|
+
try {
|
|
1533
|
+
params.onJobNoticeDelivered?.([id])
|
|
1534
|
+
} catch (error) {
|
|
1535
|
+
ctx.log.warn('A background job notice observer failed', {
|
|
1536
|
+
'exception.message': error instanceof Error ? error.message : String(error),
|
|
1537
|
+
})
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1487
1540
|
|
|
1488
1541
|
// Turn-scoped, like `toolGrants` below: what a skill loaded in this turn
|
|
1489
1542
|
// pre-approves ends with the turn. Shared by the executor, where the
|
|
@@ -1513,6 +1566,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1513
1566
|
...(params.backgroundJobs ? { backgroundJobs: params.backgroundJobs } : {}),
|
|
1514
1567
|
...(params.backgroundJobOwner ? { backgroundJobOwner: params.backgroundJobOwner } : {}),
|
|
1515
1568
|
...(awaitedJobs ? { onJobAwaited: (id: string) => awaitedJobs.expect(id) } : {}),
|
|
1569
|
+
...(awaitedJobs ? { onJobCollected: collectJob } : {}),
|
|
1516
1570
|
...(awaitedJobs ? { onMonitorStarted: (id: string) => awaitedJobs.expectMonitor(id) } : {}),
|
|
1517
1571
|
...(params.monitorTimeoutCapMs !== undefined
|
|
1518
1572
|
? { monitorTimeoutCapMs: params.monitorTimeoutCapMs }
|
|
@@ -1611,13 +1665,13 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1611
1665
|
.catch(() => {})
|
|
1612
1666
|
return
|
|
1613
1667
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
)
|
|
1668
|
+
let inlineOutput: ReturnType<NonNullable<typeof params.backgroundJobs>['read']> | undefined
|
|
1669
|
+
try {
|
|
1670
|
+
inlineOutput = params.backgroundJobs?.read(job.id)
|
|
1671
|
+
} catch {
|
|
1672
|
+
// The record is gone; the notice still stands without its output.
|
|
1673
|
+
}
|
|
1674
|
+
jobNotices?.steer(formatJobExitNotice(job, inlineOutput), job.id)
|
|
1621
1675
|
pendingJobNoticeIds.add(job.id)
|
|
1622
1676
|
void eventTranslator
|
|
1623
1677
|
.emitEvent({
|
|
@@ -1821,6 +1875,9 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1821
1875
|
...(monitorNotices ? { monitorNotices } : {}),
|
|
1822
1876
|
...(monitorNotices ? { onMonitorNoticeDelivered: acknowledgeMonitorNotices } : {}),
|
|
1823
1877
|
...(awaitedJobs ? { awaitedJobs } : {}),
|
|
1878
|
+
...(params.answerWhileCallsRun && params.waitForOperator
|
|
1879
|
+
? { detachedCalls: new DetachedCalls(params.waitForOperator) }
|
|
1880
|
+
: {}),
|
|
1824
1881
|
checkpointMgr,
|
|
1825
1882
|
planManager: ctx.planManager,
|
|
1826
1883
|
taskGateway: taskScheduler,
|
|
@@ -1840,6 +1897,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1840
1897
|
...(params.maxOutputContinuations !== undefined
|
|
1841
1898
|
? { maxOutputContinuations: params.maxOutputContinuations }
|
|
1842
1899
|
: {}),
|
|
1900
|
+
...(params.refusalFallback !== undefined ? { refusalFallback: params.refusalFallback } : {}),
|
|
1843
1901
|
...(params.inboundMessages ? { inboundMessages: params.inboundMessages } : {}),
|
|
1844
1902
|
...(params.reminders ? { reminders: params.reminders } : {}),
|
|
1845
1903
|
...(params.durableInbound ? { durableInbound: params.durableInbound } : {}),
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LLMProvider, ReasoningEffort, ThinkingConfig } from '../../../types/provider/index.js'
|
|
2
|
+
|
|
3
|
+
/** Lowest to highest, the order the effort menus are drawn in. */
|
|
4
|
+
const EFFORT_ORDER: readonly ReasoningEffort[] = [
|
|
5
|
+
'none',
|
|
6
|
+
'minimal',
|
|
7
|
+
'low',
|
|
8
|
+
'medium',
|
|
9
|
+
'high',
|
|
10
|
+
'xhigh',
|
|
11
|
+
'max',
|
|
12
|
+
'ultra',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The effort to send to `model` when the turn was configured for another one.
|
|
17
|
+
*
|
|
18
|
+
* A level the model does not offer is rejected by some drivers, so a request
|
|
19
|
+
* moved to a different model (a refusal fallback, a live model pick) carries
|
|
20
|
+
* the nearest level that model supports: the next one down when there is one,
|
|
21
|
+
* otherwise the lowest one above. The menu comes from the provider, never from
|
|
22
|
+
* a copy here. A provider that cannot say what the model offers, or a level
|
|
23
|
+
* the model already offers, leaves the effort exactly as configured.
|
|
24
|
+
*/
|
|
25
|
+
export function effortForModel(
|
|
26
|
+
provider: LLMProvider,
|
|
27
|
+
model: string,
|
|
28
|
+
effort: ReasoningEffort,
|
|
29
|
+
thinking?: ThinkingConfig,
|
|
30
|
+
): ReasoningEffort {
|
|
31
|
+
let menu: readonly ReasoningEffort[] | undefined
|
|
32
|
+
try {
|
|
33
|
+
menu = provider.reasoningEffortLevelsFor
|
|
34
|
+
? provider.reasoningEffortLevelsFor(model, thinking)
|
|
35
|
+
: provider.effortLevelsFor?.(model, thinking)
|
|
36
|
+
} catch {
|
|
37
|
+
return effort
|
|
38
|
+
}
|
|
39
|
+
if (!menu || menu.length === 0 || menu.includes(effort)) return effort
|
|
40
|
+
const rank = (level: ReasoningEffort) => EFFORT_ORDER.indexOf(level)
|
|
41
|
+
const wanted = rank(effort)
|
|
42
|
+
if (wanted < 0) return effort
|
|
43
|
+
const ranked = menu.filter((level) => rank(level) >= 0).sort((a, b) => rank(a) - rank(b))
|
|
44
|
+
const below = ranked.filter((level) => rank(level) < wanted)
|
|
45
|
+
return below[below.length - 1] ?? ranked[0] ?? effort
|
|
46
|
+
}
|