@namzu/sdk 49.0.0 → 50.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 +541 -0
- package/README.md +137 -125
- 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/agents/examples/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/examples/SupervisorAgent.js +1 -0
- package/dist/agents/examples/SupervisorAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +2 -0
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +1 -0
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +16 -1
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +8 -2
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js +1 -0
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts +25 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +205 -21
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/bridge/acp/tasks.d.ts +5 -0
- package/dist/bridge/acp/tasks.d.ts.map +1 -0
- package/dist/bridge/acp/tasks.js +19 -0
- package/dist/bridge/acp/tasks.js.map +1 -0
- package/dist/bridge/acp/update.d.ts.map +1 -1
- package/dist/bridge/acp/update.js +148 -13
- package/dist/bridge/acp/update.js.map +1 -1
- package/dist/config/runtime.d.ts +31 -31
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +11 -4
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +6 -3
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/constants/acp/index.d.ts +3 -0
- package/dist/constants/acp/index.d.ts.map +1 -1
- package/dist/constants/acp/index.js +3 -0
- package/dist/constants/acp/index.js.map +1 -1
- package/dist/contracts/a2a.d.ts +80 -80
- package/dist/contracts/schemas.d.ts +2 -2
- package/dist/contracts/session/schemas.d.ts +10 -10
- package/dist/manager/agent/lifecycle.d.ts +11 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +178 -3
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/plan/lifecycle.d.ts +7 -8
- package/dist/manager/plan/lifecycle.d.ts.map +1 -1
- package/dist/manager/plan/lifecycle.js +7 -8
- package/dist/manager/plan/lifecycle.js.map +1 -1
- package/dist/manager/resident/consumption.d.ts +8 -8
- package/dist/manager/resident/learning-cycle.d.ts +2 -2
- package/dist/manager/resident/learning-observation.d.ts +12 -12
- package/dist/manager/resident/learning.d.ts +82 -82
- package/dist/manager/resident/outbox.d.ts +8 -8
- package/dist/manager/resident/proposal.d.ts +2 -2
- package/dist/manager/resident/store.d.ts +10 -10
- package/dist/manager/session/attribution.d.ts +1 -0
- package/dist/manager/session/attribution.d.ts.map +1 -1
- package/dist/manager/session/attribution.js +9 -1
- package/dist/manager/session/attribution.js.map +1 -1
- package/dist/manager/session/streamed-message-identity.d.ts +6 -0
- package/dist/manager/session/streamed-message-identity.d.ts.map +1 -0
- package/dist/manager/session/streamed-message-identity.js +14 -0
- package/dist/manager/session/streamed-message-identity.js.map +1 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +4 -3
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/pals/activity/causality.d.ts +23 -0
- package/dist/pals/activity/causality.d.ts.map +1 -0
- package/dist/pals/activity/causality.js +205 -0
- package/dist/pals/activity/causality.js.map +1 -0
- package/dist/pals/activity/projection.d.ts +5 -0
- package/dist/pals/activity/projection.d.ts.map +1 -0
- package/dist/pals/activity/projection.js +79 -0
- package/dist/pals/activity/projection.js.map +1 -0
- package/dist/pals/activity/source.d.ts +16 -0
- package/dist/pals/activity/source.d.ts.map +1 -0
- package/dist/pals/activity/source.js +235 -0
- package/dist/pals/activity/source.js.map +1 -0
- package/dist/pals/activity/subscription-policy.d.ts +38 -0
- package/dist/pals/activity/subscription-policy.d.ts.map +1 -0
- package/dist/pals/activity/subscription-policy.js +183 -0
- package/dist/pals/activity/subscription-policy.js.map +1 -0
- package/dist/pals/activity/subscription-schema.d.ts +353 -0
- package/dist/pals/activity/subscription-schema.d.ts.map +1 -0
- package/dist/pals/activity/subscription-schema.js +24 -0
- package/dist/pals/activity/subscription-schema.js.map +1 -0
- package/dist/pals/activity/subscription-store.d.ts +25 -0
- package/dist/pals/activity/subscription-store.d.ts.map +1 -0
- package/dist/pals/activity/subscription-store.js +152 -0
- package/dist/pals/activity/subscription-store.js.map +1 -0
- package/dist/pals/activity/subscription-types.d.ts +42 -0
- package/dist/pals/activity/subscription-types.d.ts.map +1 -0
- package/dist/pals/activity/subscription-types.js +2 -0
- package/dist/pals/activity/subscription-types.js.map +1 -0
- package/dist/pals/activity/subscriptions.d.ts +32 -0
- package/dist/pals/activity/subscriptions.d.ts.map +1 -0
- package/dist/pals/activity/subscriptions.js +151 -0
- package/dist/pals/activity/subscriptions.js.map +1 -0
- package/dist/pals/activity/types.d.ts +77 -0
- package/dist/pals/activity/types.d.ts.map +1 -0
- package/dist/pals/activity/types.js +2 -0
- package/dist/pals/activity/types.js.map +1 -0
- package/dist/pals/channels/ingress.d.ts +9 -0
- package/dist/pals/channels/ingress.d.ts.map +1 -0
- package/dist/pals/channels/ingress.js +131 -0
- package/dist/pals/channels/ingress.js.map +1 -0
- package/dist/pals/channels/routes.d.ts +20 -0
- package/dist/pals/channels/routes.d.ts.map +1 -0
- package/dist/pals/channels/routes.js +111 -0
- package/dist/pals/channels/routes.js.map +1 -0
- package/dist/pals/channels/routing.d.ts +37 -0
- package/dist/pals/channels/routing.d.ts.map +1 -0
- package/dist/pals/channels/routing.js +150 -0
- package/dist/pals/channels/routing.js.map +1 -0
- package/dist/pals/channels/schema.d.ts +234 -0
- package/dist/pals/channels/schema.d.ts.map +1 -0
- package/dist/pals/channels/schema.js +94 -0
- package/dist/pals/channels/schema.js.map +1 -0
- package/dist/pals/channels/types.d.ts +115 -0
- package/dist/pals/channels/types.d.ts.map +1 -0
- package/dist/pals/channels/types.js +2 -0
- package/dist/pals/channels/types.js.map +1 -0
- package/dist/pals/communication/broker.d.ts +8 -0
- package/dist/pals/communication/broker.d.ts.map +1 -0
- package/dist/pals/communication/broker.js +121 -0
- package/dist/pals/communication/broker.js.map +1 -0
- package/dist/pals/communication/dispatch.d.ts +4 -0
- package/dist/pals/communication/dispatch.d.ts.map +1 -0
- package/dist/pals/communication/dispatch.js +57 -0
- package/dist/pals/communication/dispatch.js.map +1 -0
- package/dist/pals/communication/inbound.d.ts +9 -0
- package/dist/pals/communication/inbound.d.ts.map +1 -0
- package/dist/pals/communication/inbound.js +155 -0
- package/dist/pals/communication/inbound.js.map +1 -0
- package/dist/pals/communication/ingress-dispatch.d.ts +5 -0
- package/dist/pals/communication/ingress-dispatch.d.ts.map +1 -0
- package/dist/pals/communication/ingress-dispatch.js +51 -0
- package/dist/pals/communication/ingress-dispatch.js.map +1 -0
- package/dist/pals/communication/ingress-inbound.d.ts +9 -0
- package/dist/pals/communication/ingress-inbound.d.ts.map +1 -0
- package/dist/pals/communication/ingress-inbound.js +222 -0
- package/dist/pals/communication/ingress-inbound.js.map +1 -0
- package/dist/pals/communication/ingress-schema.d.ts +7829 -0
- package/dist/pals/communication/ingress-schema.d.ts.map +1 -0
- package/dist/pals/communication/ingress-schema.js +479 -0
- package/dist/pals/communication/ingress-schema.js.map +1 -0
- package/dist/pals/communication/ingress-types.d.ts +187 -0
- package/dist/pals/communication/ingress-types.d.ts.map +1 -0
- package/dist/pals/communication/ingress-types.js +73 -0
- package/dist/pals/communication/ingress-types.js.map +1 -0
- package/dist/pals/communication/operator.d.ts +75 -0
- package/dist/pals/communication/operator.d.ts.map +1 -0
- package/dist/pals/communication/operator.js +217 -0
- package/dist/pals/communication/operator.js.map +1 -0
- package/dist/pals/communication/policy.d.ts +41 -0
- package/dist/pals/communication/policy.d.ts.map +1 -0
- package/dist/pals/communication/policy.js +138 -0
- package/dist/pals/communication/policy.js.map +1 -0
- package/dist/pals/communication/schema.d.ts +2000 -0
- package/dist/pals/communication/schema.d.ts.map +1 -0
- package/dist/pals/communication/schema.js +170 -0
- package/dist/pals/communication/schema.js.map +1 -0
- package/dist/pals/communication/store.d.ts +61 -0
- package/dist/pals/communication/store.d.ts.map +1 -0
- package/dist/pals/communication/store.js +450 -0
- package/dist/pals/communication/store.js.map +1 -0
- package/dist/pals/communication/tools.d.ts +23 -0
- package/dist/pals/communication/tools.d.ts.map +1 -0
- package/dist/pals/communication/tools.js +107 -0
- package/dist/pals/communication/tools.js.map +1 -0
- package/dist/pals/communication/types.d.ts +168 -0
- package/dist/pals/communication/types.d.ts.map +1 -0
- package/dist/pals/communication/types.js +24 -0
- package/dist/pals/communication/types.js.map +1 -0
- package/dist/pals/communication/verify.d.ts +22 -0
- package/dist/pals/communication/verify.d.ts.map +1 -0
- package/dist/pals/communication/verify.js +142 -0
- package/dist/pals/communication/verify.js.map +1 -0
- package/dist/pals/lifecycle.d.ts +37 -0
- package/dist/pals/lifecycle.d.ts.map +1 -0
- package/dist/pals/lifecycle.js +22 -0
- package/dist/pals/lifecycle.js.map +1 -0
- package/dist/pals/prompt.d.ts +30 -0
- package/dist/pals/prompt.d.ts.map +1 -0
- package/dist/pals/prompt.js +65 -0
- package/dist/pals/prompt.js.map +1 -0
- package/dist/pals/reference-images.d.ts +44 -0
- package/dist/pals/reference-images.d.ts.map +1 -0
- package/dist/pals/reference-images.js +248 -0
- package/dist/pals/reference-images.js.map +1 -0
- package/dist/pals/runtime.d.ts +46 -0
- package/dist/pals/runtime.d.ts.map +1 -0
- package/dist/pals/runtime.js +624 -0
- package/dist/pals/runtime.js.map +1 -0
- package/dist/pals/store.d.ts +26 -0
- package/dist/pals/store.d.ts.map +1 -0
- package/dist/pals/store.js +334 -0
- package/dist/pals/store.js.map +1 -0
- package/dist/pals/types.d.ts +145 -0
- package/dist/pals/types.d.ts.map +1 -0
- package/dist/pals/types.js +2 -0
- package/dist/pals/types.js.map +1 -0
- package/dist/peers/envelope.js +1 -1
- package/dist/peers/envelope.js.map +1 -1
- package/dist/peers/protocol.d.ts +83 -83
- package/dist/peers/record.d.ts +10 -10
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +7 -2
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/process/kill-tree.d.ts.map +1 -1
- package/dist/process/kill-tree.js +9 -1
- package/dist/process/kill-tree.js.map +1 -1
- package/dist/provider/errors.d.ts +19 -0
- package/dist/provider/errors.d.ts.map +1 -1
- package/dist/provider/errors.js +123 -2
- package/dist/provider/errors.js.map +1 -1
- package/dist/provider/strict-schema.d.ts +28 -0
- package/dist/provider/strict-schema.d.ts.map +1 -1
- package/dist/provider/strict-schema.js +86 -0
- package/dist/provider/strict-schema.js.map +1 -1
- package/dist/public-runtime.d.ts +42 -14
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +36 -8
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +8 -3
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +8 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +27 -7
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/tool/presentation.d.ts +1 -0
- package/dist/registry/tool/presentation.d.ts.map +1 -1
- package/dist/registry/tool/presentation.js +9 -7
- package/dist/registry/tool/presentation.js.map +1 -1
- package/dist/runtime/harness-session/index.d.ts +5 -0
- package/dist/runtime/harness-session/index.d.ts.map +1 -0
- package/dist/runtime/harness-session/index.js +928 -0
- package/dist/runtime/harness-session/index.js.map +1 -0
- package/dist/runtime/harness-session/journal.d.ts +37 -0
- package/dist/runtime/harness-session/journal.d.ts.map +1 -0
- package/dist/runtime/harness-session/journal.js +177 -0
- package/dist/runtime/harness-session/journal.js.map +1 -0
- package/dist/runtime/harness-session/saved-view.d.ts +8 -0
- package/dist/runtime/harness-session/saved-view.d.ts.map +1 -0
- package/dist/runtime/harness-session/saved-view.js +112 -0
- package/dist/runtime/harness-session/saved-view.js.map +1 -0
- package/dist/runtime/jobs/awaited-jobs.d.ts +2 -1
- package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.js +2 -1
- package/dist/runtime/jobs/awaited-jobs.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +56 -1
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +351 -34
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/abandon-turn.d.ts +12 -1
- package/dist/runtime/query/abandon-turn.d.ts.map +1 -1
- package/dist/runtime/query/abandon-turn.js +3 -1
- package/dist/runtime/query/abandon-turn.js.map +1 -1
- package/dist/runtime/query/checkpoint.d.ts +4 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +10 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/durable-inbound.d.ts +5 -0
- package/dist/runtime/query/durable-inbound.d.ts.map +1 -0
- package/dist/runtime/query/durable-inbound.js +89 -0
- package/dist/runtime/query/durable-inbound.js.map +1 -0
- package/dist/runtime/query/events.d.ts +4 -0
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +22 -5
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts +5 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +85 -13
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +41 -18
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +227 -114
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +3 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +21 -4
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +18 -6
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +144 -67
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.d.ts +9 -5
- package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.js +61 -6
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +4 -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 +99 -16
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/observation-context.d.ts +2 -2
- package/dist/runtime/query/observation-context.d.ts.map +1 -1
- package/dist/runtime/query/observation-context.js +20 -13
- package/dist/runtime/query/observation-context.js.map +1 -1
- package/dist/runtime/query/prepare-turn.js +2 -2
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/prompt-cache.d.ts +1 -0
- package/dist/runtime/query/prompt-cache.d.ts.map +1 -1
- package/dist/runtime/query/prompt-cache.js +2 -0
- package/dist/runtime/query/prompt-cache.js.map +1 -1
- package/dist/runtime/query/prompt.d.ts +2 -0
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +23 -1
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/repeat-call.d.ts +12 -3
- package/dist/runtime/query/repeat-call.d.ts.map +1 -1
- package/dist/runtime/query/repeat-call.js +33 -10
- package/dist/runtime/query/repeat-call.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +5 -6
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +30 -3
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/resume-session.js +1 -1
- package/dist/runtime/query/resume-session.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +8 -1
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +6 -0
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/saved-presentation.d.ts +13 -0
- package/dist/runtime/query/saved-presentation.d.ts.map +1 -0
- package/dist/runtime/query/saved-presentation.js +63 -0
- package/dist/runtime/query/saved-presentation.js.map +1 -0
- package/dist/runtime/query/steering.d.ts +6 -9
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/runtime/query/tool-executions.d.ts +7 -3
- package/dist/runtime/query/tool-executions.d.ts.map +1 -1
- package/dist/runtime/query/tool-executions.js +89 -9
- package/dist/runtime/query/tool-executions.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -1
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +3 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts +25 -1
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +102 -8
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +5 -0
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +2 -0
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/summary/materialize.d.ts +10 -6
- package/dist/session/summary/materialize.d.ts.map +1 -1
- package/dist/session/summary/materialize.js +41 -8
- package/dist/session/summary/materialize.js.map +1 -1
- package/dist/store/budget/ledger.d.ts +9 -0
- package/dist/store/budget/ledger.d.ts.map +1 -1
- package/dist/store/budget/ledger.js +58 -6
- package/dist/store/budget/ledger.js.map +1 -1
- package/dist/store/evidence/index-page.d.ts +12 -12
- package/dist/store/evidence/source-text.d.ts +4 -4
- package/dist/store/session/disk.d.ts +9 -4
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +57 -11
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/session/memory.d.ts +5 -3
- package/dist/store/session/memory.d.ts.map +1 -1
- package/dist/store/session/memory.js +24 -7
- package/dist/store/session/memory.js.map +1 -1
- package/dist/store/session-log/core.d.ts +26 -6
- package/dist/store/session-log/core.d.ts.map +1 -1
- package/dist/store/session-log/core.js +61 -8
- package/dist/store/session-log/core.js.map +1 -1
- package/dist/store/session-log/disk.d.ts +2 -2
- package/dist/store/session-log/disk.d.ts.map +1 -1
- package/dist/store/session-log/disk.js +1 -0
- package/dist/store/session-log/disk.js.map +1 -1
- package/dist/store/session-log/fold.d.ts +7 -0
- package/dist/store/session-log/fold.d.ts.map +1 -1
- package/dist/store/session-log/fold.js +21 -0
- package/dist/store/session-log/fold.js.map +1 -1
- package/dist/store/session-log/index.d.ts +5 -3
- package/dist/store/session-log/index.d.ts.map +1 -1
- package/dist/store/session-log/index.js +3 -1
- package/dist/store/session-log/index.js.map +1 -1
- package/dist/store/session-log/memory.d.ts +1 -1
- package/dist/store/session-log/memory.d.ts.map +1 -1
- package/dist/store/session-log/memory.js +1 -0
- package/dist/store/session-log/memory.js.map +1 -1
- package/dist/store/session-log/spill.d.ts +10 -3
- package/dist/store/session-log/spill.d.ts.map +1 -1
- package/dist/store/session-log/spill.js +70 -5
- package/dist/store/session-log/spill.js.map +1 -1
- package/dist/store/session-log/structured-result.d.ts +21 -0
- package/dist/store/session-log/structured-result.d.ts.map +1 -0
- package/dist/store/session-log/structured-result.js +67 -0
- package/dist/store/session-log/structured-result.js.map +1 -0
- package/dist/store/task/disk.d.ts +11 -0
- package/dist/store/task/disk.d.ts.map +1 -1
- package/dist/store/task/disk.js +41 -2
- package/dist/store/task/disk.js.map +1 -1
- package/dist/store/task/memory.d.ts.map +1 -1
- package/dist/store/task/memory.js +15 -3
- package/dist/store/task/memory.js.map +1 -1
- package/dist/tools/admit-facts.d.ts +13 -0
- package/dist/tools/admit-facts.d.ts.map +1 -0
- package/dist/tools/admit-facts.js +142 -0
- package/dist/tools/admit-facts.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts +4 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +108 -22
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser.d.ts +10 -10
- package/dist/tools/builtins/computer-use.d.ts +90 -90
- package/dist/tools/builtins/edit.d.ts +17 -0
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +46 -1
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
- package/dist/tools/builtins/file-write-result.js +13 -0
- package/dist/tools/builtins/file-write-result.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +12 -0
- 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 +14 -0
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +2 -0
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js +1 -0
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -1
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/lsp.d.ts +2 -2
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +49 -0
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/view-image.d.ts +24 -0
- package/dist/tools/builtins/view-image.d.ts.map +1 -0
- package/dist/tools/builtins/view-image.js +385 -0
- package/dist/tools/builtins/view-image.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 +1 -0
- package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts +2 -0
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +104 -6
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +1 -0
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +37 -2
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +100 -3
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts +9 -19
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +127 -67
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/coordinator/wait-with-idle-bound.d.ts +2 -0
- package/dist/tools/coordinator/wait-with-idle-bound.d.ts.map +1 -1
- package/dist/tools/coordinator/wait-with-idle-bound.js +1 -1
- package/dist/tools/coordinator/wait-with-idle-bound.js.map +1 -1
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +4 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/failure-facts.d.ts +8 -0
- package/dist/tools/failure-facts.d.ts.map +1 -0
- package/dist/tools/failure-facts.js +24 -0
- package/dist/tools/failure-facts.js.map +1 -0
- package/dist/tools/host-output.d.ts +24 -0
- package/dist/tools/host-output.d.ts.map +1 -0
- package/dist/tools/host-output.js +117 -0
- package/dist/tools/host-output.js.map +1 -0
- package/dist/tools/oem-code-pages.d.ts +8 -0
- package/dist/tools/oem-code-pages.d.ts.map +1 -0
- package/dist/tools/oem-code-pages.js +23 -0
- package/dist/tools/oem-code-pages.js.map +1 -0
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +35 -6
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +23 -3
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/task/list.d.ts.map +1 -1
- package/dist/tools/task/list.js +14 -6
- package/dist/tools/task/list.js.map +1 -1
- package/dist/tools/task/present.d.ts.map +1 -1
- package/dist/tools/task/present.js +26 -6
- package/dist/tools/task/present.js.map +1 -1
- package/dist/tools/task/update.d.ts.map +1 -1
- package/dist/tools/task/update.js +12 -5
- package/dist/tools/task/update.js.map +1 -1
- package/dist/tools/text-window.d.ts +19 -0
- package/dist/tools/text-window.d.ts.map +1 -0
- package/dist/tools/text-window.js +83 -0
- package/dist/tools/text-window.js.map +1 -0
- package/dist/toolsets/manager.d.ts +11 -0
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +45 -1
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/types/acp/index.d.ts +137 -1
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/agent/base.d.ts +3 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/manager.d.ts +8 -23
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +10 -1
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +4 -0
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +30 -30
- package/dist/types/connector/mcp.d.ts +7 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/errors/catalog.d.ts.map +1 -1
- package/dist/types/errors/catalog.js +4 -2
- package/dist/types/errors/catalog.js.map +1 -1
- package/dist/types/harness/schema.d.ts +354 -0
- package/dist/types/harness/schema.d.ts.map +1 -0
- package/dist/types/harness/schema.js +203 -0
- package/dist/types/harness/schema.js.map +1 -0
- package/dist/types/harness/session.d.ts +278 -0
- package/dist/types/harness/session.d.ts.map +1 -0
- package/dist/types/harness/session.js +2 -0
- package/dist/types/harness/session.js.map +1 -0
- package/dist/types/hitl/index.d.ts +12 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/job/index.d.ts +47 -0
- package/dist/types/job/index.d.ts.map +1 -0
- package/dist/types/job/index.js +2 -0
- package/dist/types/job/index.js.map +1 -0
- package/dist/types/message/inbound-delivery.d.ts +44 -0
- package/dist/types/message/inbound-delivery.d.ts.map +1 -0
- package/dist/types/message/inbound-delivery.js +14 -0
- package/dist/types/message/inbound-delivery.js.map +1 -0
- package/dist/types/message/index.d.ts +4 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +5 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +6 -6
- package/dist/types/sandbox/index.d.ts +39 -2
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/session/checkpoint.d.ts +24 -17
- package/dist/types/session/checkpoint.d.ts.map +1 -1
- package/dist/types/session/checkpoint.js +1 -0
- package/dist/types/session/checkpoint.js.map +1 -1
- package/dist/types/session/events.d.ts +23 -1
- 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 +1514 -565
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +89 -1
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/session/step.d.ts +2 -0
- package/dist/types/session/step.d.ts.map +1 -1
- package/dist/types/session/step.js.map +1 -1
- package/dist/types/session/store.d.ts +19 -10
- package/dist/types/session/store.d.ts.map +1 -1
- package/dist/types/session/tool-execution.d.ts +6 -0
- package/dist/types/session/tool-execution.d.ts.map +1 -1
- package/dist/types/structured-output/index.d.ts +12 -2
- package/dist/types/structured-output/index.d.ts.map +1 -1
- package/dist/types/summary/ref.d.ts +3 -1
- package/dist/types/summary/ref.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +32 -4
- 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 +106 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/json-snapshot.d.ts +6 -2
- package/dist/utils/json-snapshot.d.ts.map +1 -1
- package/dist/utils/json-snapshot.js +19 -9
- package/dist/utils/json-snapshot.js.map +1 -1
- package/dist/utils/structured-result-json.d.ts +5 -0
- package/dist/utils/structured-result-json.d.ts.map +1 -0
- package/dist/utils/structured-result-json.js +10 -0
- package/dist/utils/structured-result-json.js.map +1 -0
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +1 -0
- package/src/agents/examples/SupervisorAgent.ts +1 -0
- package/src/agents/runAgent.ts +3 -0
- package/src/authorization/shell-lexer.ts +16 -1
- package/src/bridge/acp/permission.ts +17 -3
- package/src/bridge/acp/server.ts +271 -25
- package/src/bridge/acp/tasks.ts +23 -0
- package/src/bridge/acp/update.ts +167 -13
- package/src/connector/mcp/adapter.ts +16 -4
- package/src/connector/mcp/client.ts +6 -2
- package/src/constants/acp/index.ts +4 -0
- package/src/manager/agent/lifecycle.ts +230 -3
- package/src/manager/plan/lifecycle.ts +11 -9
- package/src/manager/session/attribution.ts +12 -2
- package/src/manager/session/streamed-message-identity.ts +21 -0
- package/src/manager/session/turn-recorder.ts +4 -3
- package/src/pals/activity/causality.ts +261 -0
- package/src/pals/activity/projection.ts +89 -0
- package/src/pals/activity/source.ts +240 -0
- package/src/pals/activity/subscription-policy.ts +230 -0
- package/src/pals/activity/subscription-schema.ts +27 -0
- package/src/pals/activity/subscription-store.ts +172 -0
- package/src/pals/activity/subscription-types.ts +48 -0
- package/src/pals/activity/subscriptions.ts +209 -0
- package/src/pals/activity/types.ts +108 -0
- package/src/pals/channels/ingress.ts +153 -0
- package/src/pals/channels/routes.ts +118 -0
- package/src/pals/channels/routing.ts +197 -0
- package/src/pals/channels/schema.ts +108 -0
- package/src/pals/channels/types.ts +156 -0
- package/src/pals/communication/broker.ts +131 -0
- package/src/pals/communication/dispatch.ts +66 -0
- package/src/pals/communication/inbound.ts +193 -0
- package/src/pals/communication/ingress-dispatch.ts +63 -0
- package/src/pals/communication/ingress-inbound.ts +269 -0
- package/src/pals/communication/ingress-schema.ts +526 -0
- package/src/pals/communication/ingress-types.ts +336 -0
- package/src/pals/communication/operator.ts +315 -0
- package/src/pals/communication/policy.ts +174 -0
- package/src/pals/communication/schema.ts +173 -0
- package/src/pals/communication/store.ts +577 -0
- package/src/pals/communication/tools.ts +139 -0
- package/src/pals/communication/types.ts +227 -0
- package/src/pals/communication/verify.ts +220 -0
- package/src/pals/lifecycle.ts +54 -0
- package/src/pals/prompt.ts +101 -0
- package/src/pals/reference-images.ts +322 -0
- package/src/pals/runtime.ts +670 -0
- package/src/pals/store.ts +369 -0
- package/src/pals/types.ts +157 -0
- package/src/peers/envelope.ts +1 -1
- package/src/plugin/shell-hook.ts +8 -2
- package/src/process/kill-tree.ts +10 -1
- package/src/provider/errors.ts +135 -2
- package/src/provider/strict-schema.ts +90 -0
- package/src/public-runtime.ts +118 -12
- package/src/public-tools.ts +13 -1
- package/src/public-types.ts +69 -7
- package/src/registry/tool/presentation.ts +9 -4
- package/src/runtime/harness-session/index.ts +1125 -0
- package/src/runtime/harness-session/journal.ts +209 -0
- package/src/runtime/harness-session/saved-view.ts +122 -0
- package/src/runtime/jobs/awaited-jobs.ts +2 -1
- package/src/runtime/jobs/registry.ts +397 -41
- package/src/runtime/query/abandon-turn.ts +18 -2
- package/src/runtime/query/checkpoint.ts +11 -0
- package/src/runtime/query/durable-inbound.ts +101 -0
- package/src/runtime/query/events.ts +22 -5
- package/src/runtime/query/executor/tool-call-admission.ts +125 -32
- package/src/runtime/query/executor.ts +316 -130
- package/src/runtime/query/index.ts +24 -4
- package/src/runtime/query/iteration/index.ts +218 -104
- package/src/runtime/query/iteration/outstanding-work.ts +55 -7
- package/src/runtime/query/iteration/phases/context.ts +4 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +118 -21
- package/src/runtime/query/observation-context.ts +22 -16
- package/src/runtime/query/prepare-turn.ts +2 -2
- package/src/runtime/query/prompt-cache.ts +3 -0
- package/src/runtime/query/prompt.ts +32 -1
- package/src/runtime/query/repeat-call.ts +40 -10
- package/src/runtime/query/resume-pending.ts +60 -7
- package/src/runtime/query/resume-session.ts +1 -1
- package/src/runtime/query/review-policy.ts +23 -2
- package/src/runtime/query/saved-presentation.ts +70 -0
- package/src/runtime/query/steering.ts +6 -9
- package/src/runtime/query/tool-executions.ts +108 -9
- package/src/runtime/query/tooling.ts +6 -1
- package/src/scheduler/completion-inbox.ts +108 -7
- package/src/scheduler/delegating.ts +5 -0
- package/src/scheduler/local.ts +2 -0
- package/src/session/summary/materialize.ts +51 -9
- package/src/store/budget/ledger.ts +60 -5
- package/src/store/session/disk.ts +77 -10
- package/src/store/session/memory.ts +32 -7
- package/src/store/session-log/core.ts +118 -11
- package/src/store/session-log/disk.ts +9 -2
- package/src/store/session-log/fold.ts +22 -0
- package/src/store/session-log/index.ts +5 -0
- package/src/store/session-log/memory.ts +2 -1
- package/src/store/session-log/spill.ts +89 -6
- package/src/store/session-log/structured-result.ts +96 -0
- package/src/store/task/disk.ts +46 -2
- package/src/store/task/memory.ts +13 -3
- package/src/tools/admit-facts.ts +145 -0
- package/src/tools/builtins/bash.ts +132 -24
- package/src/tools/builtins/edit.ts +54 -1
- package/src/tools/builtins/file-write-result.ts +14 -0
- package/src/tools/builtins/glob.ts +12 -0
- package/src/tools/builtins/grep.ts +14 -0
- package/src/tools/builtins/index.ts +2 -0
- package/src/tools/builtins/job.ts +4 -1
- package/src/tools/builtins/read-file.ts +57 -0
- package/src/tools/builtins/view-image.ts +409 -0
- package/src/tools/builtins/wait-for-job-bounds.ts +3 -0
- package/src/tools/builtins/wait-for-job.ts +141 -32
- package/src/tools/builtins/write-file.ts +4 -2
- package/src/tools/command-shell.ts +132 -5
- package/src/tools/coordinator/agent.ts +9 -19
- package/src/tools/coordinator/index.ts +150 -75
- package/src/tools/coordinator/wait-with-idle-bound.ts +3 -1
- package/src/tools/defineTool.ts +4 -0
- package/src/tools/failure-facts.ts +24 -0
- package/src/tools/host-output.ts +136 -0
- package/src/tools/oem-code-pages.ts +22 -0
- package/src/tools/schedules/schedule-tool.ts +38 -5
- package/src/tools/schedules/types.ts +23 -3
- package/src/tools/task/list.ts +15 -7
- package/src/tools/task/present.ts +37 -7
- package/src/tools/task/update.ts +12 -5
- package/src/tools/text-window.ts +87 -0
- package/src/toolsets/manager.ts +58 -1
- package/src/types/acp/index.ts +150 -4
- package/src/types/agent/base.ts +3 -0
- package/src/types/agent/manager.ts +8 -23
- package/src/types/agent/scheduler.ts +10 -1
- package/src/types/agent/task.ts +4 -0
- package/src/types/connector/mcp.ts +7 -0
- package/src/types/errors/catalog.ts +4 -2
- package/src/types/harness/schema.ts +203 -0
- package/src/types/harness/session.ts +306 -0
- package/src/types/hitl/index.ts +17 -1
- package/src/types/job/index.ts +42 -0
- package/src/types/message/inbound-delivery.ts +63 -0
- package/src/types/message/index.ts +8 -1
- package/src/types/sandbox/index.ts +46 -0
- package/src/types/session/checkpoint.ts +4 -1
- package/src/types/session/events.ts +23 -1
- package/src/types/session/records.ts +114 -2
- package/src/types/session/step.ts +2 -0
- package/src/types/session/store.ts +23 -9
- package/src/types/session/tool-execution.ts +6 -0
- package/src/types/structured-output/index.ts +13 -2
- package/src/types/summary/ref.ts +3 -1
- package/src/types/tool/index.ts +39 -5
- package/src/types/tool/presentation.ts +121 -0
- package/src/utils/json-snapshot.ts +26 -9
- package/src/utils/structured-result-json.ts +10 -0
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
import type { CheckpointId, MessageId, SessionId, TenantId } from '../../types/ids/index.js'
|
|
60
60
|
import type { InvocationState } from '../../types/invocation/index.js'
|
|
61
61
|
import type { MemoryStore } from '../../types/memory/index.js'
|
|
62
|
+
import type { DurableInboundSource } from '../../types/message/inbound-delivery.js'
|
|
62
63
|
import {
|
|
63
64
|
type AssistantMessage,
|
|
64
65
|
type Message,
|
|
@@ -733,6 +734,9 @@ export interface QueryParams {
|
|
|
733
734
|
*/
|
|
734
735
|
waitForInbound?: (signal: AbortSignal) => Promise<void>
|
|
735
736
|
|
|
737
|
+
/** Durable host input: normal append, flush and exact acknowledgement before inference. Requires sessionLog. */
|
|
738
|
+
durableInbound?: DurableInboundSource
|
|
739
|
+
|
|
736
740
|
/**
|
|
737
741
|
* Live project policy for this turn. Unlike `inboundMessages`, snapshot
|
|
738
742
|
* replacement is durable state and never implies another model turn.
|
|
@@ -956,6 +960,9 @@ function withOwnedResumeOutcomes(
|
|
|
956
960
|
}
|
|
957
961
|
|
|
958
962
|
export async function* query(params: QueryParams): AsyncGenerator<SessionEvent, Turn> {
|
|
963
|
+
if (params.durableInbound && !params.sessionLog) {
|
|
964
|
+
throw new Error('durableInbound requires an explicit sessionLog and its active writer.')
|
|
965
|
+
}
|
|
959
966
|
const prepared = await prepareTurn(params)
|
|
960
967
|
const {
|
|
961
968
|
turnConfig,
|
|
@@ -1144,9 +1151,11 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1144
1151
|
// invalidate the whole prompt cache for the rest of the turn — the same
|
|
1145
1152
|
// reason the forced-final turn keeps its tools array and uses
|
|
1146
1153
|
// `toolChoice: 'none'` instead of dropping it.
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1154
|
+
const structuredOutputTool =
|
|
1155
|
+
params.structuredOutput && params.structuredOutput.mode !== 'native'
|
|
1156
|
+
? createStructuredOutputTool(params.structuredOutput.schema)
|
|
1157
|
+
: undefined
|
|
1158
|
+
if (structuredOutputTool) addRuntimeTool(structuredOutputTool, 'active')
|
|
1150
1159
|
|
|
1151
1160
|
for (const tool of advisoryToolDefs) addRuntimeTool(tool, 'active')
|
|
1152
1161
|
|
|
@@ -1356,6 +1365,9 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1356
1365
|
{
|
|
1357
1366
|
skillGrants,
|
|
1358
1367
|
tools: toolManager,
|
|
1368
|
+
...(params.structuredOutput?.toolResultRetention === 'durable' && structuredOutputTool
|
|
1369
|
+
? { durableStructuredOutputTool: structuredOutputTool }
|
|
1370
|
+
: {}),
|
|
1359
1371
|
sessionId: ctx.sessionId,
|
|
1360
1372
|
turnId: ctx.turnId,
|
|
1361
1373
|
workingDirectory: ctx.cwd,
|
|
@@ -1484,6 +1496,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1484
1496
|
basePrompt: params.basePrompt,
|
|
1485
1497
|
tools: toolManager,
|
|
1486
1498
|
allowedTools: effectiveAllowedTools,
|
|
1499
|
+
sandboxed: params.sandboxProvider !== undefined,
|
|
1487
1500
|
runtimeContext: params.runtimeContext,
|
|
1488
1501
|
contributions: promptContributions,
|
|
1489
1502
|
})
|
|
@@ -1595,6 +1608,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1595
1608
|
activityStore: ctx.activityStore,
|
|
1596
1609
|
emitEvent: eventTranslator.emitEvent,
|
|
1597
1610
|
drainPending: () => eventTranslator.drainPending(),
|
|
1611
|
+
onPendingEvents: (listener) => eventTranslator.onPendingEvents(listener),
|
|
1598
1612
|
abortController: ctx.abortController,
|
|
1599
1613
|
log: ctx.log,
|
|
1600
1614
|
// Read through the box on every call, so a swap lands on the next
|
|
@@ -1622,6 +1636,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1622
1636
|
...(params.repeatCallAdvisory === false ? {} : { repeatCalls: new RepeatCallTracker() }),
|
|
1623
1637
|
compactionConfig,
|
|
1624
1638
|
...(params.inboundMessages ? { inboundMessages: params.inboundMessages } : {}),
|
|
1639
|
+
...(params.durableInbound ? { durableInbound: params.durableInbound } : {}),
|
|
1625
1640
|
...(params.resumeFromCheckpoint ? { resumedInput: queuedForThisRun } : {}),
|
|
1626
1641
|
...(params.waitForInbound ? { waitForInbound: params.waitForInbound } : {}),
|
|
1627
1642
|
...(params.projectInstructionContext
|
|
@@ -1845,6 +1860,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1845
1860
|
basePrompt: contextLevel === 'full' ? params.basePrompt : undefined,
|
|
1846
1861
|
tools: toolManager,
|
|
1847
1862
|
allowedTools: effectiveAllowedTools,
|
|
1863
|
+
sandboxed: params.sandboxProvider !== undefined,
|
|
1848
1864
|
runtimeContext: params.runtimeContext,
|
|
1849
1865
|
contributions: promptContributions,
|
|
1850
1866
|
}
|
|
@@ -2148,6 +2164,9 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
2148
2164
|
// boundaries are not all cooperative and must not regain withdrawn
|
|
2149
2165
|
// authority merely because the turn record still had to be created.
|
|
2150
2166
|
ctx.abortController.signal.throwIfAborted()
|
|
2167
|
+
// A restored assistant/tool pair cannot be split by a user-role arrival.
|
|
2168
|
+
// Its pending results are applied below, before the loop drains input.
|
|
2169
|
+
if (!pendingResume) await iterationOrchestrator.deliverInitialDurable()
|
|
2151
2170
|
|
|
2152
2171
|
// Handed over here, and the position is load-bearing in three
|
|
2153
2172
|
// directions. It has to follow `wirePlanManager`, or a host that
|
|
@@ -2410,13 +2429,14 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
2410
2429
|
}
|
|
2411
2430
|
}
|
|
2412
2431
|
|
|
2413
|
-
await applyPendingResume(
|
|
2432
|
+
const resumedBatch = await applyPendingResume(
|
|
2414
2433
|
pendingResume,
|
|
2415
2434
|
ctx.recorder,
|
|
2416
2435
|
toolExecutor,
|
|
2417
2436
|
recoveredResults,
|
|
2418
2437
|
pendingResumeAssistantId,
|
|
2419
2438
|
)
|
|
2439
|
+
iterationOrchestrator.setResumedToolResults(resumedBatch.results)
|
|
2420
2440
|
yield* eventTranslator.drainPending()
|
|
2421
2441
|
}
|
|
2422
2442
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
DEFAULT_STRUCTURED_OUTPUT_RETRIES,
|
|
11
11
|
STRUCTURED_OUTPUT_REPROMPT,
|
|
12
12
|
} from '../../../constants/tools/index.js'
|
|
13
|
+
import { withStreamedMessageIdentity } from '../../../manager/session/streamed-message-identity.js'
|
|
13
14
|
import { renderSkillsSection } from '../../../persona/assembler.js'
|
|
14
15
|
import { resolveProviderCapabilities } from '../../../provider/capabilities.js'
|
|
15
16
|
import { collectChatCompletion } from '../../../provider/collect-chat-completion.js'
|
|
@@ -48,7 +49,9 @@ import type { LLMToolSchema } from '../../../types/tool/index.js'
|
|
|
48
49
|
import { toErrorMessage } from '../../../utils/error.js'
|
|
49
50
|
import { stableDigest } from '../../../utils/hash.js'
|
|
50
51
|
import { generateMessageId } from '../../../utils/id.js'
|
|
52
|
+
import { parseStructuredResultJson } from '../../../utils/structured-result-json.js'
|
|
51
53
|
import { createCallbackInference } from '../callback-inference.js'
|
|
54
|
+
import { deliverDurableInbound } from '../durable-inbound.js'
|
|
52
55
|
import type { ToolCallOutcome } from '../executor.js'
|
|
53
56
|
import { projectObservationContext } from '../observation-context.js'
|
|
54
57
|
import { applyLifecycleHookResults } from '../plugin-hooks.js'
|
|
@@ -65,7 +68,11 @@ import {
|
|
|
65
68
|
} from '../request-rich-content.js'
|
|
66
69
|
import { formatSteeringNote, isOperatorUserMessage } from '../steering.js'
|
|
67
70
|
import { parseNativeCandidate } from './native-output.js'
|
|
68
|
-
import {
|
|
71
|
+
import {
|
|
72
|
+
drainArrivedTaskCompletions,
|
|
73
|
+
holdForOutstandingWork,
|
|
74
|
+
settleOutstandingWork,
|
|
75
|
+
} from './outstanding-work.js'
|
|
69
76
|
import { runAdvisoryPhase } from './phases/advisory.js'
|
|
70
77
|
import { runIterationCheckpoint } from './phases/checkpoint.js'
|
|
71
78
|
import {
|
|
@@ -162,7 +169,12 @@ export class IterationOrchestrator {
|
|
|
162
169
|
private projectObservations(messages: Message[]): Message[] {
|
|
163
170
|
const config = this.ctx.compactionConfig
|
|
164
171
|
return config && config.strategy !== 'disabled' && config.deduplicateObservations !== false
|
|
165
|
-
? projectObservationContext(
|
|
172
|
+
? projectObservationContext(
|
|
173
|
+
messages,
|
|
174
|
+
this.ctx.tools,
|
|
175
|
+
config.preserveToolResultsFrom,
|
|
176
|
+
(call, message) => this.ctx.toolExecutor.recordedObservationKey(call, message),
|
|
177
|
+
)
|
|
166
178
|
: messages
|
|
167
179
|
}
|
|
168
180
|
/** Rich tool blocks already reported; durable history is scanned every turn. */
|
|
@@ -184,6 +196,9 @@ export class IterationOrchestrator {
|
|
|
184
196
|
private stopDeferredForOutstandingWork = false
|
|
185
197
|
/** One current input, independent of the compactable history array. */
|
|
186
198
|
private latestUserMessage: UserMessage | undefined
|
|
199
|
+
private initialDurableDelivered = false
|
|
200
|
+
private resumedToolResults: readonly ToolCallOutcome[] = []
|
|
201
|
+
private toolStructuredCounterHydrated = false
|
|
187
202
|
|
|
188
203
|
constructor(ctx: IterationContext) {
|
|
189
204
|
this.ctx = {
|
|
@@ -196,6 +211,11 @@ export class IterationOrchestrator {
|
|
|
196
211
|
ctx.checkpointMgr.setAnswerReviewAttemptsSource?.(() => this.answerReviewAttempts)
|
|
197
212
|
ctx.checkpointMgr.setStructuredReviewAttemptsSource?.(() => this.structuredReviewAttempts)
|
|
198
213
|
ctx.checkpointMgr.setNativeStructuredAttemptsSource?.(() => this.nativeStructuredAttempts)
|
|
214
|
+
ctx.checkpointMgr.setToolStructuredAttemptsSource?.(() =>
|
|
215
|
+
this.toolStructuredCounterHydrated
|
|
216
|
+
? this.toolStructuredAttempts
|
|
217
|
+
: (ctx.checkpointMgr.restoredToolStructuredAttempts ?? 0),
|
|
218
|
+
)
|
|
199
219
|
if (ctx.structuredOutput?.mode === 'native') {
|
|
200
220
|
const limit = ctx.structuredOutput.maxRetries
|
|
201
221
|
if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0))
|
|
@@ -209,6 +229,11 @@ export class IterationOrchestrator {
|
|
|
209
229
|
)
|
|
210
230
|
throw new RangeError('Unknown structuredOutput.mode')
|
|
211
231
|
const maxReviews = ctx.structuredOutput?.maxReviews
|
|
232
|
+
const retention = ctx.structuredOutput?.toolResultRetention
|
|
233
|
+
if (retention !== undefined && !['receipt', 'durable'].includes(retention))
|
|
234
|
+
throw new RangeError('Unknown structuredOutput.toolResultRetention')
|
|
235
|
+
if (retention === 'durable' && ctx.structuredOutput?.mode === 'native')
|
|
236
|
+
throw new RangeError('structuredOutput.toolResultRetention: durable requires tool mode')
|
|
212
237
|
if (maxReviews !== undefined && (!Number.isSafeInteger(maxReviews) || maxReviews < 0))
|
|
213
238
|
throw new RangeError('structuredOutput.maxReviews must be a nonnegative safe integer')
|
|
214
239
|
if (
|
|
@@ -293,15 +318,35 @@ export class IterationOrchestrator {
|
|
|
293
318
|
this.ctx = { ...this.ctx, rootSpan: span }
|
|
294
319
|
}
|
|
295
320
|
|
|
321
|
+
/** Fresh input is recorded before guards; restored tool batches must finish first. */
|
|
322
|
+
async deliverInitialDurable(): Promise<void> {
|
|
323
|
+
if (this.initialDurableDelivered) return
|
|
324
|
+
await deliverDurableInbound(
|
|
325
|
+
this.ctx.recorder,
|
|
326
|
+
this.ctx.durableInbound,
|
|
327
|
+
this.ctx.abortController.signal,
|
|
328
|
+
)
|
|
329
|
+
this.initialDurableDelivered = true
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** A restored pending batch must answer every owned call before consuming its correction. */
|
|
333
|
+
setResumedToolResults(results: readonly ToolCallOutcome[]): void {
|
|
334
|
+
this.resumedToolResults = results
|
|
335
|
+
}
|
|
336
|
+
|
|
296
337
|
async *runLoop(): AsyncGenerator<SessionEvent> {
|
|
297
338
|
const { turnConfig, recorder } = this.ctx
|
|
298
339
|
const { model } = turnConfig
|
|
299
340
|
const tracer = getTracer()
|
|
341
|
+
// Initial durable input arrives before checkpoints, plan gates or inference.
|
|
342
|
+
await this.deliverInitialDurable()
|
|
300
343
|
// Resume hydration happens after construction, before the loop starts.
|
|
301
344
|
this.latestUserMessage = this.ctx.checkpointMgr.restoredLatestUserMessage
|
|
302
345
|
this.answerReviewAttempts = this.ctx.checkpointMgr.restoredAnswerReviewAttempts ?? 0
|
|
303
346
|
this.structuredReviewAttempts = this.ctx.checkpointMgr.restoredStructuredReviewAttempts ?? 0
|
|
304
347
|
this.nativeStructuredAttempts = this.ctx.checkpointMgr.restoredNativeStructuredAttempts ?? 0
|
|
348
|
+
this.toolStructuredAttempts = this.ctx.checkpointMgr.restoredToolStructuredAttempts ?? 0
|
|
349
|
+
this.toolStructuredCounterHydrated = true
|
|
305
350
|
if (!this.latestUserMessage) {
|
|
306
351
|
for (const message of recorder.messages) this.rememberUserMessage(message, false)
|
|
307
352
|
}
|
|
@@ -309,6 +354,9 @@ export class IterationOrchestrator {
|
|
|
309
354
|
// Only known post-checkpoint arrivals may supersede it, never an old
|
|
310
355
|
// retained user turn encountered while scanning restored history.
|
|
311
356
|
for (const message of this.ctx.resumedInput ?? []) this.rememberUserMessage(message)
|
|
357
|
+
const resumedToolResults = this.resumedToolResults
|
|
358
|
+
this.resumedToolResults = []
|
|
359
|
+
await this.recordToolStructuredFailure(resumedToolResults, recorder.currentIteration)
|
|
312
360
|
|
|
313
361
|
// What a recoverable failure pauses on when it lands before this
|
|
314
362
|
// loop wrote a checkpoint of its own: without it a 429 on the first
|
|
@@ -328,9 +376,6 @@ export class IterationOrchestrator {
|
|
|
328
376
|
// succeeded, which is the evidence that the turn is no longer stuck.
|
|
329
377
|
let overflowRelieved = false
|
|
330
378
|
|
|
331
|
-
const planSignal = yield* runPlanGate(this.ctx)
|
|
332
|
-
if (planSignal === 'stop') return
|
|
333
|
-
|
|
334
379
|
// A `finally` rather than a line at each exit, for the reason written
|
|
335
380
|
// beside `iterSpan.end()` below: this loop leaves by eight `break`s,
|
|
336
381
|
// two `return`s and a `throw`, and a rule every future edit has to
|
|
@@ -341,19 +386,17 @@ export class IterationOrchestrator {
|
|
|
341
386
|
// A `finally` also covers a generator abandoned by its consumer, which
|
|
342
387
|
// no post-loop block reaches.
|
|
343
388
|
try {
|
|
389
|
+
// Restored exhaustion precedes plan gates and any auxiliary inference.
|
|
390
|
+
if (this.stopForStructuredRetryExhaustion()) return
|
|
391
|
+
const planSignal = yield* runPlanGate(this.ctx)
|
|
392
|
+
if (planSignal === 'stop') return
|
|
344
393
|
while (true) {
|
|
345
394
|
if (this.ctx.abortController.signal.aborted) {
|
|
346
395
|
recorder.setStopReason('cancelled')
|
|
347
396
|
recorder.markCancelled()
|
|
348
397
|
break
|
|
349
398
|
}
|
|
350
|
-
if (
|
|
351
|
-
this.ctx.structuredOutput?.mode === 'native' &&
|
|
352
|
-
this.nativeStructuredAttempts > this.structuredOutputRetryLimit()
|
|
353
|
-
) {
|
|
354
|
-
recorder.setStopReason('structured_output_failed')
|
|
355
|
-
break
|
|
356
|
-
}
|
|
399
|
+
if (this.stopForStructuredRetryExhaustion()) break
|
|
357
400
|
if (
|
|
358
401
|
this.ctx.reviewAnswer &&
|
|
359
402
|
this.answerReviewAttempts > (this.ctx.maxAnswerReviews ?? DEFAULT_ANSWER_REVIEW_LIMIT)
|
|
@@ -987,22 +1030,25 @@ export class IterationOrchestrator {
|
|
|
987
1030
|
// with the turn they belong to. Trimming therefore removes both;
|
|
988
1031
|
// retaining them gives the target adapter enough evidence to
|
|
989
1032
|
// validate native replay against the exact serving route.
|
|
990
|
-
const assistantMsg =
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1033
|
+
const assistantMsg = withStreamedMessageIdentity(
|
|
1034
|
+
createAssistantMessage(
|
|
1035
|
+
response.message.content,
|
|
1036
|
+
forceFinalize ? undefined : response.message.toolCalls,
|
|
1037
|
+
response.message.reasoning,
|
|
1038
|
+
// Rides with the turn it belongs to, like reasoning does, so
|
|
1039
|
+
// trimming or compacting the turn takes its evidence with it
|
|
1040
|
+
// rather than leaving citations pointing at prose that is gone.
|
|
1041
|
+
response.message.citations,
|
|
1042
|
+
{
|
|
1043
|
+
type: 'model',
|
|
1044
|
+
...servedBy,
|
|
1045
|
+
...(response.message.replayState !== undefined
|
|
1046
|
+
? { replayState: response.message.replayState }
|
|
1047
|
+
: {}),
|
|
1048
|
+
},
|
|
1049
|
+
response.message.textParts,
|
|
1050
|
+
),
|
|
1051
|
+
messageId,
|
|
1006
1052
|
)
|
|
1007
1053
|
recorder.pushMessage(assistantMsg)
|
|
1008
1054
|
if (this.ctx.advisoryCtx && requestMessages) {
|
|
@@ -1175,7 +1221,7 @@ export class IterationOrchestrator {
|
|
|
1175
1221
|
const changed = yield* holdForOutstandingWork(this.ctx, iterationNum, false, () =>
|
|
1176
1222
|
this.deliverInbound(),
|
|
1177
1223
|
)
|
|
1178
|
-
const inbound = this.deliverInbound()
|
|
1224
|
+
const inbound = await this.deliverInbound()
|
|
1179
1225
|
if (changed || inbound > 0) continue
|
|
1180
1226
|
}
|
|
1181
1227
|
if (this.ctx.abortController.signal.aborted) {
|
|
@@ -1196,6 +1242,21 @@ export class IterationOrchestrator {
|
|
|
1196
1242
|
continue
|
|
1197
1243
|
}
|
|
1198
1244
|
|
|
1245
|
+
// Missing output and rejected model arguments share one durable
|
|
1246
|
+
// correction allowance, including prose cut off by the output cap.
|
|
1247
|
+
if (!forceFinalize && this.needsStructuredOutput()) {
|
|
1248
|
+
await this.recordToolStructuredCorrection(iterationNum)
|
|
1249
|
+
await this.ctx.emitEvent({
|
|
1250
|
+
type: 'iteration_completed',
|
|
1251
|
+
turnId: recorder.turnId,
|
|
1252
|
+
iteration: iterationNum,
|
|
1253
|
+
hasToolCalls: false,
|
|
1254
|
+
})
|
|
1255
|
+
yield* this.ctx.drainPending()
|
|
1256
|
+
if (this.stopForStructuredRetryExhaustion()) break
|
|
1257
|
+
continue
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1199
1260
|
const hasContent =
|
|
1200
1261
|
response.message.content !== null && response.message.content.length > 0
|
|
1201
1262
|
|
|
@@ -1246,40 +1307,6 @@ export class IterationOrchestrator {
|
|
|
1246
1307
|
continue
|
|
1247
1308
|
}
|
|
1248
1309
|
|
|
1249
|
-
// The model tried to finish in prose while a structured
|
|
1250
|
-
// output was demanded. Send it back with the schema error
|
|
1251
|
-
// rather than returning an unusable result — this is the
|
|
1252
|
-
// re-prompt half, and it is bounded so a model that cannot
|
|
1253
|
-
// satisfy the schema fails loudly instead of looping.
|
|
1254
|
-
if (!forceFinalize && this.needsStructuredOutput()) {
|
|
1255
|
-
const attempt = ++this.structuredOutputAttempts
|
|
1256
|
-
const limit = this.structuredOutputRetryLimit()
|
|
1257
|
-
if (attempt > limit) {
|
|
1258
|
-
this.ctx.log.warn('Structured output not produced within its retries', {
|
|
1259
|
-
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1260
|
-
'namzu.runtime.attempts': attempt - 1,
|
|
1261
|
-
})
|
|
1262
|
-
recorder.setStopReason('structured_output_failed')
|
|
1263
|
-
break
|
|
1264
|
-
}
|
|
1265
|
-
this.ctx.log.info('Re-prompting for structured output', {
|
|
1266
|
-
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1267
|
-
'namzu.retry.attempt': attempt,
|
|
1268
|
-
'namzu.runtime.limit': limit,
|
|
1269
|
-
})
|
|
1270
|
-
recorder.pushMessage(
|
|
1271
|
-
createRuntimeContextMessage(STRUCTURED_OUTPUT_REPROMPT, 'structured-output'),
|
|
1272
|
-
)
|
|
1273
|
-
await this.ctx.emitEvent({
|
|
1274
|
-
type: 'iteration_completed',
|
|
1275
|
-
turnId: recorder.turnId,
|
|
1276
|
-
iteration: iterationNum,
|
|
1277
|
-
hasToolCalls: false,
|
|
1278
|
-
})
|
|
1279
|
-
yield* this.ctx.drainPending()
|
|
1280
|
-
continue
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
1310
|
// Let the host judge the ANSWER and hand back work.
|
|
1284
1311
|
//
|
|
1285
1312
|
// The stop predicate is only consulted after tools ran, so
|
|
@@ -1371,7 +1398,7 @@ export class IterationOrchestrator {
|
|
|
1371
1398
|
// After the outstanding-work hold above, so a delivery
|
|
1372
1399
|
// does not race a worker still finishing, and before the
|
|
1373
1400
|
// settle below, which is the last moment it can matter.
|
|
1374
|
-
if (!forceFinalize && this.deliverInbound() > 0) {
|
|
1401
|
+
if (!forceFinalize && (await this.deliverInbound()) > 0) {
|
|
1375
1402
|
await this.ctx.emitEvent({
|
|
1376
1403
|
type: 'iteration_completed',
|
|
1377
1404
|
turnId: recorder.turnId,
|
|
@@ -1456,6 +1483,10 @@ export class IterationOrchestrator {
|
|
|
1456
1483
|
if (reviewOutcome.decision === 'stop') {
|
|
1457
1484
|
return
|
|
1458
1485
|
}
|
|
1486
|
+
const needsCorrection = await this.recordToolStructuredFailure(
|
|
1487
|
+
reviewOutcome.results,
|
|
1488
|
+
iterationNum,
|
|
1489
|
+
)
|
|
1459
1490
|
|
|
1460
1491
|
// A tool asked for a person. The whole batch is committed; the
|
|
1461
1492
|
// turn parks here rather than asking the model what to do about
|
|
@@ -1467,6 +1498,17 @@ export class IterationOrchestrator {
|
|
|
1467
1498
|
if (reviewOutcome.decision === 'rejected') {
|
|
1468
1499
|
continue
|
|
1469
1500
|
}
|
|
1501
|
+
if (needsCorrection) {
|
|
1502
|
+
await this.ctx.emitEvent({
|
|
1503
|
+
type: 'iteration_completed',
|
|
1504
|
+
turnId: recorder.turnId,
|
|
1505
|
+
iteration: iterationNum,
|
|
1506
|
+
hasToolCalls: true,
|
|
1507
|
+
})
|
|
1508
|
+
yield* this.ctx.drainPending()
|
|
1509
|
+
if (this.stopForStructuredRetryExhaustion()) break
|
|
1510
|
+
continue
|
|
1511
|
+
}
|
|
1470
1512
|
|
|
1471
1513
|
// A successful `structured_output` call IS the answer, so the
|
|
1472
1514
|
// run ends here rather than paying for another turn whose only
|
|
@@ -1516,7 +1558,7 @@ export class IterationOrchestrator {
|
|
|
1516
1558
|
break
|
|
1517
1559
|
}
|
|
1518
1560
|
if (!forceFinalize) {
|
|
1519
|
-
const inbound = this.deliverInbound()
|
|
1561
|
+
const inbound = await this.deliverInbound()
|
|
1520
1562
|
// Tool-result steering may already have been delivered by
|
|
1521
1563
|
// runToolReview. Its candidate still answers the older input.
|
|
1522
1564
|
if (inbound > 0 || this.latestUserMessage !== operatorInputAtDispatch) continue
|
|
@@ -1642,7 +1684,7 @@ export class IterationOrchestrator {
|
|
|
1642
1684
|
// Placed beside the advisory phase deliberately: that is the
|
|
1643
1685
|
// established seam for putting a user message in after tool
|
|
1644
1686
|
// results and before the next turn.
|
|
1645
|
-
const unheard = this.ctx
|
|
1687
|
+
const unheard = await drainArrivedTaskCompletions(this.ctx)
|
|
1646
1688
|
if (unheard.length > 0) {
|
|
1647
1689
|
this.ctx.log.info('Delivering unawaited task completions', {
|
|
1648
1690
|
[NAMZU.TURN_ID]: recorder.turnId,
|
|
@@ -1658,7 +1700,7 @@ export class IterationOrchestrator {
|
|
|
1658
1700
|
// and never deliver it. Placed here rather than at the top of
|
|
1659
1701
|
// the next iteration so a message queued during THIS turn is
|
|
1660
1702
|
// in the history the next request is built from.
|
|
1661
|
-
this.deliverInbound()
|
|
1703
|
+
await this.deliverInbound()
|
|
1662
1704
|
|
|
1663
1705
|
await runAdvisoryPhase(this.ctx, iterationNum, response, this.getAdvisoryTurnContext())
|
|
1664
1706
|
|
|
@@ -1883,7 +1925,7 @@ export class IterationOrchestrator {
|
|
|
1883
1925
|
}
|
|
1884
1926
|
}
|
|
1885
1927
|
|
|
1886
|
-
private deliverInbound(): number {
|
|
1928
|
+
private async deliverInbound(): Promise<number> {
|
|
1887
1929
|
const queued = this.ctx.inboundMessages?.() ?? []
|
|
1888
1930
|
for (const message of queued) {
|
|
1889
1931
|
this.ctx.recorder.pushMessage(message)
|
|
@@ -1900,7 +1942,12 @@ export class IterationOrchestrator {
|
|
|
1900
1942
|
this.rememberUserMessage(createRuntimeContextMessage(stranded, 'steering'))
|
|
1901
1943
|
}
|
|
1902
1944
|
|
|
1903
|
-
|
|
1945
|
+
const durable = await deliverDurableInbound(
|
|
1946
|
+
this.ctx.recorder,
|
|
1947
|
+
this.ctx.durableInbound,
|
|
1948
|
+
this.ctx.abortController.signal,
|
|
1949
|
+
)
|
|
1950
|
+
return queued.length + (stranded ? 1 : 0) + durable
|
|
1904
1951
|
}
|
|
1905
1952
|
|
|
1906
1953
|
private recordStep(input: {
|
|
@@ -1958,6 +2005,7 @@ export class IterationOrchestrator {
|
|
|
1958
2005
|
toolName: tc.function.name,
|
|
1959
2006
|
output: outcome?.output ?? '',
|
|
1960
2007
|
isError: outcome?.isError ?? false,
|
|
2008
|
+
...(outcome?.skipped ? { skipped: true as const } : {}),
|
|
1961
2009
|
durationMs: 0,
|
|
1962
2010
|
},
|
|
1963
2011
|
]
|
|
@@ -2002,8 +2050,8 @@ export class IterationOrchestrator {
|
|
|
2002
2050
|
}
|
|
2003
2051
|
}
|
|
2004
2052
|
|
|
2005
|
-
/**
|
|
2006
|
-
private
|
|
2053
|
+
/** Model responses needing a tool-mode schema correction, separate from host reviews. */
|
|
2054
|
+
private toolStructuredAttempts = 0
|
|
2007
2055
|
private nativeStructuredAttempts = 0
|
|
2008
2056
|
private structuredOutputDone = false
|
|
2009
2057
|
private pendingStructuredOutput: unknown
|
|
@@ -2013,6 +2061,58 @@ export class IterationOrchestrator {
|
|
|
2013
2061
|
return this.ctx.structuredOutput?.maxRetries ?? DEFAULT_STRUCTURED_OUTPUT_RETRIES
|
|
2014
2062
|
}
|
|
2015
2063
|
|
|
2064
|
+
private stopForStructuredRetryExhaustion(): boolean {
|
|
2065
|
+
const { recorder, abortController } = this.ctx
|
|
2066
|
+
if (abortController.signal.aborted) {
|
|
2067
|
+
recorder.setStopReason('cancelled')
|
|
2068
|
+
recorder.markCancelled()
|
|
2069
|
+
return true
|
|
2070
|
+
}
|
|
2071
|
+
if (!this.needsStructuredOutput()) return false
|
|
2072
|
+
const attempts =
|
|
2073
|
+
this.ctx.structuredOutput?.mode === 'native'
|
|
2074
|
+
? this.nativeStructuredAttempts
|
|
2075
|
+
: this.toolStructuredAttempts
|
|
2076
|
+
if (attempts === 0 || !(attempts > this.structuredOutputRetryLimit())) return false
|
|
2077
|
+
recorder.setStopReason('structured_output_failed')
|
|
2078
|
+
return true
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
private async recordToolStructuredFailure(
|
|
2082
|
+
results: readonly ToolCallOutcome[],
|
|
2083
|
+
iteration: number,
|
|
2084
|
+
): Promise<boolean> {
|
|
2085
|
+
if (
|
|
2086
|
+
!this.needsStructuredOutput() ||
|
|
2087
|
+
this.ctx.structuredOutput?.mode === 'native' ||
|
|
2088
|
+
this.ctx.abortController.signal.aborted ||
|
|
2089
|
+
!results.some(
|
|
2090
|
+
(result) => result.toolName === STRUCTURED_OUTPUT_TOOL_NAME && result.inputFailure,
|
|
2091
|
+
)
|
|
2092
|
+
)
|
|
2093
|
+
return false
|
|
2094
|
+
// One model response consumes one correction, even with several invalid calls.
|
|
2095
|
+
await this.recordToolStructuredCorrection(iteration)
|
|
2096
|
+
return true
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
private async recordToolStructuredCorrection(iteration: number): Promise<void> {
|
|
2100
|
+
this.toolStructuredAttempts++
|
|
2101
|
+
const { recorder } = this.ctx
|
|
2102
|
+
recorder.pushMessage(
|
|
2103
|
+
createRuntimeContextMessage(STRUCTURED_OUTPUT_REPROMPT, 'structured-output'),
|
|
2104
|
+
)
|
|
2105
|
+
// Commit the full answered batch, feedback and allowance before another request
|
|
2106
|
+
// or handoff. A failed checkpoint must not buy another correction opportunity.
|
|
2107
|
+
const checkpoint = await this.ctx.checkpointMgr.create(recorder, iteration)
|
|
2108
|
+
await this.ctx.emitEvent({
|
|
2109
|
+
type: 'checkpoint_created',
|
|
2110
|
+
turnId: recorder.turnId,
|
|
2111
|
+
checkpointId: checkpoint.id,
|
|
2112
|
+
iteration,
|
|
2113
|
+
})
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2016
2116
|
/** True while a structured output was demanded and has not arrived. */
|
|
2017
2117
|
private needsStructuredOutput(): boolean {
|
|
2018
2118
|
return this.ctx.structuredOutput !== undefined && !this.structuredOutputDone
|
|
@@ -2024,9 +2124,9 @@ export class IterationOrchestrator {
|
|
|
2024
2124
|
* Deliberately narrow. A terminal call decides the turn only when it is
|
|
2025
2125
|
* the ONLY call the model made in that turn: a model that asked for
|
|
2026
2126
|
* other work meant to see those results, and settling here would throw
|
|
2027
|
-
* away answers it requested.
|
|
2028
|
-
*
|
|
2029
|
-
*
|
|
2127
|
+
* away answers it requested. A failed or skipped terminal call also
|
|
2128
|
+
* needs another model turn: its receipt is not an executed answer.
|
|
2129
|
+
* These cases fall through to the ordinary path, and each says so in
|
|
2030
2130
|
* the log rather than quietly costing the relay the flag was set to
|
|
2031
2131
|
* avoid.
|
|
2032
2132
|
*/
|
|
@@ -2049,11 +2149,16 @@ export class IterationOrchestrator {
|
|
|
2049
2149
|
}
|
|
2050
2150
|
|
|
2051
2151
|
const hit = terminal[0]
|
|
2052
|
-
if (!hit || hit.isError) {
|
|
2053
|
-
this.ctx.log.info(
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2152
|
+
if (!hit || hit.isError || hit.skipped) {
|
|
2153
|
+
this.ctx.log.info(
|
|
2154
|
+
hit?.skipped
|
|
2155
|
+
? 'Terminal tool was skipped — returning its receipt to the model'
|
|
2156
|
+
: 'Terminal tool failed — returning the error to the model',
|
|
2157
|
+
{
|
|
2158
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
2159
|
+
[GENAI.TOOL_NAME]: hit?.toolName,
|
|
2160
|
+
},
|
|
2161
|
+
)
|
|
2057
2162
|
return undefined
|
|
2058
2163
|
}
|
|
2059
2164
|
return hit
|
|
@@ -2065,7 +2170,8 @@ export class IterationOrchestrator {
|
|
|
2065
2170
|
* The tool validates against the Zod schema before its `execute` runs,
|
|
2066
2171
|
* so reaching here successfully means the value is already valid — a
|
|
2067
2172
|
* failed parse comes back as an error result and simply does not
|
|
2068
|
-
* satisfy the demand, which sends the loop round again.
|
|
2173
|
+
* satisfy the demand, which sends the loop round again. A hook-skipped
|
|
2174
|
+
* receipt did not execute the tool and is not a candidate either.
|
|
2069
2175
|
*
|
|
2070
2176
|
* Narrow in the same way {@link terminalToolOutput} is, for its stated
|
|
2071
2177
|
* reason and one that is sharper here. The neighbour refuses a shared
|
|
@@ -2111,7 +2217,9 @@ export class IterationOrchestrator {
|
|
|
2111
2217
|
): Promise<'absent' | 'accepted' | 'retry' | 'exhausted' | 'cancelled'> {
|
|
2112
2218
|
if (!this.needsStructuredOutput() || this.ctx.structuredOutput?.mode === 'native')
|
|
2113
2219
|
return 'absent'
|
|
2114
|
-
const hit = results.find(
|
|
2220
|
+
const hit = results.find(
|
|
2221
|
+
(r) => r.toolName === STRUCTURED_OUTPUT_TOOL_NAME && !r.isError && !r.skipped,
|
|
2222
|
+
)
|
|
2115
2223
|
if (!hit) return 'absent'
|
|
2116
2224
|
|
|
2117
2225
|
const callCount = response.message.toolCalls?.length ?? 0
|
|
@@ -2125,15 +2233,19 @@ export class IterationOrchestrator {
|
|
|
2125
2233
|
|
|
2126
2234
|
let parsed: unknown
|
|
2127
2235
|
try {
|
|
2128
|
-
parsed =
|
|
2236
|
+
parsed =
|
|
2237
|
+
this.ctx.structuredOutput?.toolResultRetention === 'durable'
|
|
2238
|
+
? parseStructuredResultJson(
|
|
2239
|
+
hit.structuredResultJson === undefined ? hit.output : hit.structuredResultJson,
|
|
2240
|
+
)
|
|
2241
|
+
: JSON.parse(hit.output)
|
|
2129
2242
|
} catch {
|
|
2130
|
-
//
|
|
2131
|
-
//
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
parsed = hit.output
|
|
2243
|
+
// Screening, hooks or output budgeting can change the validated
|
|
2244
|
+
// tool's receipt. A raw-text fallback is not a structured result;
|
|
2245
|
+
// do not recover input/data that bypasses those boundaries either.
|
|
2246
|
+
throw new Error(
|
|
2247
|
+
'Structured output requires an intact JSON tool result; check result transformations, increase maxToolOutputChars to fit the result, or use native mode with a capable provider',
|
|
2248
|
+
)
|
|
2137
2249
|
}
|
|
2138
2250
|
return this.reviewStructuredOutput(parsed, reviewRequest, model)
|
|
2139
2251
|
}
|
|
@@ -2411,23 +2523,25 @@ export class IterationOrchestrator {
|
|
|
2411
2523
|
model: servedBy.model,
|
|
2412
2524
|
})
|
|
2413
2525
|
|
|
2414
|
-
const
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2526
|
+
const finalMessageId = generateMessageId()
|
|
2527
|
+
const assistantMsg = withStreamedMessageIdentity(
|
|
2528
|
+
createAssistantMessage(
|
|
2529
|
+
response.message.content,
|
|
2530
|
+
undefined,
|
|
2531
|
+
response.message.reasoning,
|
|
2532
|
+
response.message.citations,
|
|
2533
|
+
{
|
|
2534
|
+
type: 'model',
|
|
2535
|
+
...servedBy,
|
|
2536
|
+
...(response.message.replayState !== undefined
|
|
2537
|
+
? { replayState: response.message.replayState }
|
|
2538
|
+
: {}),
|
|
2539
|
+
},
|
|
2540
|
+
response.message.textParts,
|
|
2541
|
+
),
|
|
2542
|
+
finalMessageId,
|
|
2427
2543
|
)
|
|
2428
2544
|
this.ctx.recorder.pushMessage(assistantMsg)
|
|
2429
|
-
|
|
2430
|
-
const finalMessageId = generateMessageId()
|
|
2431
2545
|
await this.ctx.emitEvent({
|
|
2432
2546
|
type: 'message_started',
|
|
2433
2547
|
turnId: this.ctx.recorder.turnId,
|