@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
1
2
|
import { createRuntimeContextMessage } from '../../types/message/index.js'
|
|
2
3
|
import type { Message } from '../../types/message/index.js'
|
|
3
4
|
import { stableStringify } from './tool-grants.js'
|
|
@@ -66,8 +67,8 @@ export class RepeatCallTracker {
|
|
|
66
67
|
/** Which keys have already been reported at which level, so one repeat
|
|
67
68
|
* does not produce the same sentence on every subsequent turn. */
|
|
68
69
|
private readonly announced = new Map<string, 'notice' | 'escalated'>()
|
|
69
|
-
/**
|
|
70
|
-
private readonly failures = new Map<string, number>()
|
|
70
|
+
/** Identical actual results since the last successful possible mutation. */
|
|
71
|
+
private readonly failures = new Map<string, { fingerprint: string; count: number }>()
|
|
71
72
|
|
|
72
73
|
constructor(private readonly thresholds: RepeatCallThresholds = DEFAULT_REPEAT_THRESHOLDS) {}
|
|
73
74
|
|
|
@@ -80,13 +81,12 @@ export class RepeatCallTracker {
|
|
|
80
81
|
record(
|
|
81
82
|
toolName: string,
|
|
82
83
|
input: unknown,
|
|
83
|
-
outcome?: { readonly failed: boolean },
|
|
84
|
+
outcome?: { readonly failed: boolean; readonly result?: unknown },
|
|
84
85
|
): RepeatCallNotice | undefined {
|
|
85
86
|
const key = keyFor(toolName, input)
|
|
86
87
|
const count = (this.counts.get(key) ?? 0) + 1
|
|
87
88
|
this.counts.set(key, count)
|
|
88
|
-
if (outcome
|
|
89
|
-
else if (outcome?.failed === false) this.failures.delete(key)
|
|
89
|
+
if (outcome) this.recordOutcome(toolName, input, outcome)
|
|
90
90
|
|
|
91
91
|
const already = this.announced.get(key)
|
|
92
92
|
if (count >= this.thresholds.escalateAfter && already !== 'escalated') {
|
|
@@ -95,7 +95,7 @@ export class RepeatCallTracker {
|
|
|
95
95
|
toolName,
|
|
96
96
|
count,
|
|
97
97
|
level: 'escalated',
|
|
98
|
-
text: `You have now called \`${toolName}\` with identical arguments ${count} times in this turn.
|
|
98
|
+
text: `You have now called \`${toolName}\` with identical arguments ${count} times in this turn. Check whether the results or the state have changed. If there is no progress, change the approach or tell the user what is blocking you.`,
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
if (count >= this.thresholds.notifyAfter && already === undefined) {
|
|
@@ -110,6 +110,33 @@ export class RepeatCallTracker {
|
|
|
110
110
|
return undefined
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/** Only actual executions count. Denials and recovered receipts do not. */
|
|
114
|
+
recordOutcome(
|
|
115
|
+
toolName: string,
|
|
116
|
+
input: unknown,
|
|
117
|
+
outcome: { readonly failed: boolean; readonly result?: unknown },
|
|
118
|
+
): void {
|
|
119
|
+
const key = keyFor(toolName, input)
|
|
120
|
+
if (!outcome.failed) {
|
|
121
|
+
this.failures.delete(key)
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
const fingerprint = createHash('sha256')
|
|
125
|
+
.update(stableStringify(outcome.result ?? null))
|
|
126
|
+
.digest('hex')
|
|
127
|
+
const previous = this.failures.get(key)
|
|
128
|
+
this.failures.set(key, {
|
|
129
|
+
fingerprint,
|
|
130
|
+
count: previous?.fingerprint === fingerprint ? previous.count + 1 : 1,
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** A successful potentially mutating execution permits a new experiment.
|
|
135
|
+
* This does not prove progress; the turn's existing budgets still apply. */
|
|
136
|
+
stateMayHaveChanged(): void {
|
|
137
|
+
this.failures.clear()
|
|
138
|
+
}
|
|
139
|
+
|
|
113
140
|
/** Repeats seen for one call, for a host that wants to render it. */
|
|
114
141
|
countOf(toolName: string, input: unknown): number {
|
|
115
142
|
return this.counts.get(keyFor(toolName, input)) ?? 0
|
|
@@ -118,11 +145,11 @@ export class RepeatCallTracker {
|
|
|
118
145
|
/**
|
|
119
146
|
* The refusal for a call that has failed identically too many times in
|
|
120
147
|
* a row, or `undefined` when the call may run. Asked BEFORE execution;
|
|
121
|
-
*
|
|
122
|
-
* refusal holds until
|
|
148
|
+
* a synthetic refusal is not an execution and does not replace its result
|
|
149
|
+
* fingerprint. The refusal holds until a real state change or new outcome.
|
|
123
150
|
*/
|
|
124
151
|
refusal(toolName: string, input: unknown): string | undefined {
|
|
125
|
-
const failed = this.failures.get(keyFor(toolName, input)) ?? 0
|
|
152
|
+
const failed = this.failures.get(keyFor(toolName, input))?.count ?? 0
|
|
126
153
|
if (failed < this.thresholds.refuseFailedAfter) return undefined
|
|
127
154
|
return `Refused: \`${toolName}\` with these exact arguments has failed ${failed} times in a row in this turn, with the same result each time. It will not be run again with these arguments. Change the arguments, use a different tool, or tell the user what is blocking you and stop.`
|
|
128
155
|
}
|
|
@@ -167,7 +194,10 @@ export function attachRepeatNotice(
|
|
|
167
194
|
|
|
168
195
|
if (target && typeof target.content === 'string') {
|
|
169
196
|
const next = [...messages]
|
|
170
|
-
next[lastToolIndex] = {
|
|
197
|
+
next[lastToolIndex] = {
|
|
198
|
+
...target,
|
|
199
|
+
content: `${target.content}\n\n${noticeText}`,
|
|
200
|
+
}
|
|
171
201
|
return next
|
|
172
202
|
}
|
|
173
203
|
|
|
@@ -15,7 +15,14 @@ import type { ToolExecutionSnapshot } from '../../types/session/tool-execution.j
|
|
|
15
15
|
import type { Logger } from '../../utils/logger.js'
|
|
16
16
|
import type { RestoredCheckpoint } from './checkpoint.js'
|
|
17
17
|
import { DECLINED_TOOL_CALL_FEEDBACK } from './declined.js'
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
PriorToolResult,
|
|
20
|
+
PriorToolResults,
|
|
21
|
+
ToolCallDeclines,
|
|
22
|
+
ToolCallDenials,
|
|
23
|
+
ToolExecutionBatch,
|
|
24
|
+
ToolExecutor,
|
|
25
|
+
} from './executor.js'
|
|
19
26
|
import { PendingAnswers } from './question-park.js'
|
|
20
27
|
import { readToolExecutions } from './tool-executions.js'
|
|
21
28
|
import { isPauseForCall } from './tool-pause.js'
|
|
@@ -60,6 +67,8 @@ export interface PendingResumePlan {
|
|
|
60
67
|
readonly response: ChatCompletionResponse
|
|
61
68
|
/** Per-call refusals derived from the decision. */
|
|
62
69
|
readonly denials: ToolCallDenials
|
|
70
|
+
/** The denials a person gave; see {@link ToolCallDeclines}. Absent for every other refusal. */
|
|
71
|
+
readonly declines?: ToolCallDeclines
|
|
63
72
|
/** Exact projections and gate decisions persisted with a tool review. */
|
|
64
73
|
readonly reviewedCalls?: readonly ToolCallSummary[]
|
|
65
74
|
/** Calls whose raw input the human replaced in the durable decision. */
|
|
@@ -139,6 +148,7 @@ export function planPendingResume(
|
|
|
139
148
|
|
|
140
149
|
const denials = derriveDenials(assistant.toolCalls, decision)
|
|
141
150
|
if (!denials) return null
|
|
151
|
+
const declines = derriveDeclines(assistant.toolCalls, decision, pending.request.toolCalls)
|
|
142
152
|
|
|
143
153
|
return {
|
|
144
154
|
source: 'decision',
|
|
@@ -146,6 +156,7 @@ export function planPendingResume(
|
|
|
146
156
|
assistant,
|
|
147
157
|
response: synthesizeResponse(assistant),
|
|
148
158
|
denials,
|
|
159
|
+
...(declines ? { declines } : {}),
|
|
149
160
|
reviewedCalls: pending.request.toolCalls,
|
|
150
161
|
modifiedCallIds: modifiedCallIds(decision),
|
|
151
162
|
...((decision.action === 'approve_tools' || decision.action === 'modify_tools') &&
|
|
@@ -417,7 +428,7 @@ export async function applyPendingResume(
|
|
|
417
428
|
executor: ToolExecutor,
|
|
418
429
|
prior?: PriorToolResults,
|
|
419
430
|
assistantMessageId?: MessageId,
|
|
420
|
-
): Promise<
|
|
431
|
+
): Promise<ToolExecutionBatch> {
|
|
421
432
|
const denials = new Map(plan.denials)
|
|
422
433
|
const reviewedById = new Map(plan.reviewedCalls?.map((call) => [call.id, call]))
|
|
423
434
|
|
|
@@ -439,7 +450,10 @@ export async function applyPendingResume(
|
|
|
439
450
|
...plan.response,
|
|
440
451
|
message: { ...plan.response.message, toolCalls: callsToPrepare },
|
|
441
452
|
}
|
|
442
|
-
const preparedBatch = await executor.prepareBatchForReview(
|
|
453
|
+
const preparedBatch = await executor.prepareBatchForReview(
|
|
454
|
+
responseToPrepare,
|
|
455
|
+
plan.modifiedCallIds,
|
|
456
|
+
)
|
|
443
457
|
|
|
444
458
|
for (const call of preparedBatch.reviewCalls) {
|
|
445
459
|
const reviewed = reviewedById.get(call.id)
|
|
@@ -508,10 +522,17 @@ export async function applyPendingResume(
|
|
|
508
522
|
// The parked assistant message is already in the log: it goes back into
|
|
509
523
|
// the context under its own record id, never as a second copy.
|
|
510
524
|
recorder.pushMessage(plan.assistant, assistantMessageId ? { messageId: assistantMessageId } : {})
|
|
511
|
-
const batch = await executor.executeBatch(
|
|
525
|
+
const batch = await executor.executeBatch(
|
|
526
|
+
plan.response,
|
|
527
|
+
denials,
|
|
528
|
+
prior,
|
|
529
|
+
preparedBatch,
|
|
530
|
+
plan.declines,
|
|
531
|
+
)
|
|
512
532
|
for (const msg of batch.messages) {
|
|
513
533
|
recorder.pushMessage(msg)
|
|
514
534
|
}
|
|
535
|
+
return batch
|
|
515
536
|
}
|
|
516
537
|
|
|
517
538
|
/**
|
|
@@ -567,8 +588,8 @@ export async function recoverCompletedCalls(
|
|
|
567
588
|
toolCalls: readonly ToolCall[],
|
|
568
589
|
log: Logger,
|
|
569
590
|
options: { answers?: PendingAnswers; signal?: AbortSignal } = {},
|
|
570
|
-
): Promise<Map<string,
|
|
571
|
-
const recovered = new Map<string,
|
|
591
|
+
): Promise<Map<string, PriorToolResult>> {
|
|
592
|
+
const recovered = new Map<string, PriorToolResult>()
|
|
572
593
|
let snapshot: ToolExecutionSnapshot | undefined
|
|
573
594
|
try {
|
|
574
595
|
await recorder.flush()
|
|
@@ -592,7 +613,15 @@ export async function recoverCompletedCalls(
|
|
|
592
613
|
) {
|
|
593
614
|
if (!record) continue // Complete evidence proves this call has no recorded start.
|
|
594
615
|
if (record.status === 'completed') {
|
|
595
|
-
recovered.set(call.id, {
|
|
616
|
+
recovered.set(call.id, {
|
|
617
|
+
result: record.result,
|
|
618
|
+
isError: record.isError,
|
|
619
|
+
...(record.inputFailure ? { inputFailure: record.inputFailure } : {}),
|
|
620
|
+
...(record.skipped ? { skipped: true as const } : {}),
|
|
621
|
+
...(record.structuredResultJson !== undefined
|
|
622
|
+
? { structuredResultJson: record.structuredResultJson }
|
|
623
|
+
: {}),
|
|
624
|
+
})
|
|
596
625
|
continue
|
|
597
626
|
}
|
|
598
627
|
}
|
|
@@ -615,6 +644,30 @@ export async function recoverCompletedCalls(
|
|
|
615
644
|
return recovered
|
|
616
645
|
}
|
|
617
646
|
|
|
647
|
+
/** The calls a person refused in `decision`, for the record; `undefined` when none. */
|
|
648
|
+
function derriveDeclines(
|
|
649
|
+
toolCalls: readonly ToolCall[],
|
|
650
|
+
decision: HITLResumeDecision,
|
|
651
|
+
reviewed: readonly ToolCallSummary[] = [],
|
|
652
|
+
): ToolCallDeclines | undefined {
|
|
653
|
+
// A call the gate refused was never the person's to decline.
|
|
654
|
+
const gateDenied = new Set(
|
|
655
|
+
reviewed.filter((call) => call.authorization?.decision === 'deny').map((call) => call.id),
|
|
656
|
+
)
|
|
657
|
+
if (decision.action === 'reject_tools' && decision.declined) {
|
|
658
|
+
const declined = decision.declined
|
|
659
|
+
const calls = toolCalls.filter((tc) => !gateDenied.has(tc.id))
|
|
660
|
+
return calls.length > 0 ? new Map(calls.map((tc) => [tc.id, declined])) : undefined
|
|
661
|
+
}
|
|
662
|
+
if (decision.action === 'modify_tools') {
|
|
663
|
+
const denied = decision.modifications.filter(
|
|
664
|
+
(mod) => mod.action === 'deny' && !gateDenied.has(mod.toolCallId),
|
|
665
|
+
)
|
|
666
|
+
if (denied.length > 0) return new Map(denied.map((mod) => [mod.toolCallId, {}]))
|
|
667
|
+
}
|
|
668
|
+
return undefined
|
|
669
|
+
}
|
|
670
|
+
|
|
618
671
|
/**
|
|
619
672
|
* Turn a decision into per-call refusals, or `null` when the decision does
|
|
620
673
|
* not resolve the park at all.
|
|
@@ -79,7 +79,7 @@ export async function resumeSession(params: ResumeSessionParams): Promise<Resume
|
|
|
79
79
|
// A caller-chosen checkpoint scope is not proof that the source log belongs
|
|
80
80
|
// to it. Refuse foreign attribution before reading any checkpoint or park.
|
|
81
81
|
assertResumeRequestAttribution(params, scope)
|
|
82
|
-
if (!(await assertSessionLogAttribution(sessionLog, scope))) {
|
|
82
|
+
if (!(await assertSessionLogAttribution(sessionLog, scope, { execution: 'kernel' }))) {
|
|
83
83
|
return { resumed: false, reason: 'no-checkpoint' }
|
|
84
84
|
}
|
|
85
85
|
const checkpointStore =
|
|
@@ -23,7 +23,12 @@
|
|
|
23
23
|
|
|
24
24
|
import { isTrustedReadOnly } from '../../tools/trusted-read-only.js'
|
|
25
25
|
import type { ToolManager } from '../../toolsets/manager.js'
|
|
26
|
-
import type {
|
|
26
|
+
import type {
|
|
27
|
+
HITLResumeDecision,
|
|
28
|
+
ResumeHandler,
|
|
29
|
+
ToolCallDeclined,
|
|
30
|
+
ToolCallSummary,
|
|
31
|
+
} from '../../types/hitl/index.js'
|
|
27
32
|
import type { ApprovalPolicy } from '../../types/hitl/policy.js'
|
|
28
33
|
import type { SessionId, TurnId } from '../../types/ids/index.js'
|
|
29
34
|
import { PLAN_MODE_REFUSAL } from '../../types/permission/index.js'
|
|
@@ -266,7 +271,17 @@ export type ToolReviewAnswer =
|
|
|
266
271
|
| { readonly kind: 'approve' }
|
|
267
272
|
/** Approve, and stop asking for the rest of the turn. */
|
|
268
273
|
| { readonly kind: 'approve-all' }
|
|
269
|
-
| {
|
|
274
|
+
| {
|
|
275
|
+
readonly kind: 'reject'
|
|
276
|
+
readonly feedback?: string
|
|
277
|
+
/**
|
|
278
|
+
* Set by a host when a person said No, so the refusal is recorded as
|
|
279
|
+
* theirs. `feedback` is what the model is told and a host may fill it
|
|
280
|
+
* for its own reasons (a closed screen, an interrupted turn), so it
|
|
281
|
+
* cannot carry this. `note` is the person's own words.
|
|
282
|
+
*/
|
|
283
|
+
readonly declined?: ToolCallDeclined
|
|
284
|
+
}
|
|
270
285
|
|
|
271
286
|
/** How a host asks a person. The one thing the kernel cannot supply. */
|
|
272
287
|
export type ToolReviewPrompt = (request: ToolReviewRequest) => Promise<ToolReviewAnswer>
|
|
@@ -400,6 +415,7 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
400
415
|
return {
|
|
401
416
|
action: 'reject_tools',
|
|
402
417
|
feedback: answer.feedback ?? SCREEN_CONSENT_DECLINED_FEEDBACK,
|
|
418
|
+
...(answer.declined ? { declined: answer.declined } : {}),
|
|
403
419
|
}
|
|
404
420
|
}
|
|
405
421
|
consent.sessions.add(sessionKey)
|
|
@@ -471,6 +487,7 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
471
487
|
return {
|
|
472
488
|
action: 'reject_tools',
|
|
473
489
|
feedback: answer.feedback ?? DECLINED_TOOL_CALL_FEEDBACK,
|
|
490
|
+
...(answer.declined ? { declined: answer.declined } : {}),
|
|
474
491
|
}
|
|
475
492
|
}
|
|
476
493
|
// "Approve all" still latches for the calls that follow; it never
|
|
@@ -489,6 +506,7 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
489
506
|
return {
|
|
490
507
|
action: 'reject_tools',
|
|
491
508
|
feedback: answer.feedback ?? DECLINED_TOOL_CALL_FEEDBACK,
|
|
509
|
+
...(answer.declined ? { declined: answer.declined } : {}),
|
|
492
510
|
}
|
|
493
511
|
}
|
|
494
512
|
// Latches for the ordinary calls that follow, never for the next path.
|
|
@@ -508,6 +526,7 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
508
526
|
return {
|
|
509
527
|
action: 'reject_tools',
|
|
510
528
|
feedback: answer.feedback ?? DECLINED_TOOL_CALL_FEEDBACK,
|
|
529
|
+
...(answer.declined ? { declined: answer.declined } : {}),
|
|
511
530
|
}
|
|
512
531
|
}
|
|
513
532
|
if (answer.kind === 'approve-all') remembered.all = true
|
|
@@ -527,6 +546,7 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
527
546
|
return {
|
|
528
547
|
action: 'reject_tools',
|
|
529
548
|
feedback: answer.feedback ?? DECLINED_TOOL_CALL_FEEDBACK,
|
|
549
|
+
...(answer.declined ? { declined: answer.declined } : {}),
|
|
530
550
|
}
|
|
531
551
|
}
|
|
532
552
|
if (answer.kind === 'approve-all') remembered.all = true
|
|
@@ -573,6 +593,7 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
573
593
|
return {
|
|
574
594
|
action: 'reject_tools',
|
|
575
595
|
feedback: answer.feedback ?? DECLINED_TOOL_CALL_FEEDBACK,
|
|
596
|
+
...(answer.declined ? { declined: answer.declined } : {}),
|
|
576
597
|
}
|
|
577
598
|
}
|
|
578
599
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { genericPrimary } from '../../registry/tool/presentation.js'
|
|
2
|
+
import type { ToolCallView, ToolResultView } from '../../types/tool/presentation.js'
|
|
3
|
+
|
|
4
|
+
/** One line is all a saved row needs; the output is not kept. */
|
|
5
|
+
export const SAVED_LABEL_MAX = 200
|
|
6
|
+
|
|
7
|
+
function firstLine(text: string | undefined): string | undefined {
|
|
8
|
+
const line = text
|
|
9
|
+
?.split(/\r?\n/)
|
|
10
|
+
.find((candidate) => candidate.trim())
|
|
11
|
+
?.trim()
|
|
12
|
+
if (!line) return undefined
|
|
13
|
+
// By code point so a surrogate pair is never split.
|
|
14
|
+
const points = Array.from(line)
|
|
15
|
+
return points.length > SAVED_LABEL_MAX
|
|
16
|
+
? `${points.slice(0, SAVED_LABEL_MAX - 1).join('')}…`
|
|
17
|
+
: line
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* What the journal keeps of a successful call that has no diff: the label the
|
|
22
|
+
* live row already showed, never the output. A host that replays history then
|
|
23
|
+
* names the action instead of calling it a saved one.
|
|
24
|
+
*
|
|
25
|
+
* `undefined` means there is nothing worth saving (no label, no command), so
|
|
26
|
+
* the host falls back to the tool's name.
|
|
27
|
+
*/
|
|
28
|
+
export function savedPresentation(
|
|
29
|
+
input: unknown,
|
|
30
|
+
callView: ToolCallView | undefined,
|
|
31
|
+
resultView: ToolResultView | undefined,
|
|
32
|
+
): ToolResultView | undefined {
|
|
33
|
+
if (resultView?.kind === 'diff') return undefined
|
|
34
|
+
const callLabel = callView?.kind === 'generic' ? firstLine(callView.label) : undefined
|
|
35
|
+
const commandInput =
|
|
36
|
+
input &&
|
|
37
|
+
typeof input === 'object' &&
|
|
38
|
+
typeof (input as { command?: unknown }).command === 'string'
|
|
39
|
+
? (input as { command: string }).command
|
|
40
|
+
: undefined
|
|
41
|
+
// A tool with no view of its own is drawn as a terminal, so a command input is a command.
|
|
42
|
+
const command =
|
|
43
|
+
resultView?.kind === 'terminal' || callView?.kind === 'terminal'
|
|
44
|
+
? ((resultView?.kind === 'terminal' ? resultView.command : undefined) ??
|
|
45
|
+
(callView?.kind === 'terminal' ? callView.command : undefined) ??
|
|
46
|
+
commandInput ??
|
|
47
|
+
callLabel ??
|
|
48
|
+
'')
|
|
49
|
+
: !resultView && !callView && commandInput !== undefined
|
|
50
|
+
? commandInput
|
|
51
|
+
: undefined
|
|
52
|
+
if (command !== undefined) {
|
|
53
|
+
const line = firstLine(command)
|
|
54
|
+
return line ? { kind: 'terminal', command: line, output: '' } : undefined
|
|
55
|
+
}
|
|
56
|
+
const label =
|
|
57
|
+
callLabel ??
|
|
58
|
+
(resultView?.kind === 'generic' ? firstLine(resultView.label) : undefined) ??
|
|
59
|
+
(callView || resultView ? undefined : firstLine(genericPrimary(input)))
|
|
60
|
+
if (!label) return undefined
|
|
61
|
+
const own = callView?.kind === 'generic' ? callView : undefined
|
|
62
|
+
const hidden = resultView?.kind === 'generic' && resultView.visibility === 'hidden'
|
|
63
|
+
return {
|
|
64
|
+
kind: 'generic',
|
|
65
|
+
label,
|
|
66
|
+
...(own?.presentation === 'activity' ? { presentation: 'activity' as const } : {}),
|
|
67
|
+
...(own?.activity === 'exploration' ? { activity: 'exploration' as const } : {}),
|
|
68
|
+
...(hidden ? { visibility: 'hidden' as const } : {}),
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -14,14 +14,11 @@ export function isOperatorUserMessage(message: Message): message is UserMessage
|
|
|
14
14
|
/**
|
|
15
15
|
* Guidance a host hands to a turn that is already running.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* result the turn had already paid for. Reject through the review gate only
|
|
23
|
-
* works if a tool call happens to be pending approval, and it says "no" when
|
|
24
|
-
* the host wanted to say "yes, but look at this first".
|
|
17
|
+
* This tool-result channel is distinct from `inboundMessages`. The manager
|
|
18
|
+
* injects its mailbox through that callback, and query-backed agents consume
|
|
19
|
+
* it at provider-valid message boundaries. Custom agents must consume their
|
|
20
|
+
* injected callback themselves. This channel instead lets a host attach
|
|
21
|
+
* guidance to a completed tool batch without adding another user message.
|
|
25
22
|
*
|
|
26
23
|
* **Why the text rides on a tool result rather than arriving as a user
|
|
27
24
|
* message.** A `tool_use` block must be answered by a `tool_result` with the
|
|
@@ -34,7 +31,7 @@ export function isOperatorUserMessage(message: Message): message is UserMessage
|
|
|
34
31
|
* attends to for tool outcomes. Steering is the same delivery with the
|
|
35
32
|
* refusal removed.
|
|
36
33
|
*
|
|
37
|
-
*
|
|
34
|
+
* It does not interrupt. The batch in flight
|
|
38
35
|
* finishes, and the guidance lands where the model looks next. A host that
|
|
39
36
|
* wants the current work stopped wants `AbortSignal`, which is a different
|
|
40
37
|
* question with a different answer — and conflating the two is how "please
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import type { SessionLog } from '../../store/session-log/index.js'
|
|
2
|
+
import type { SpillRef } from '../../store/session-log/spill.js'
|
|
3
|
+
import { readStructuredResultSpill } from '../../store/session-log/structured-result.js'
|
|
4
|
+
import { STRUCTURED_OUTPUT_TOOL_NAME } from '../../tools/builtins/structuredOutput.js'
|
|
2
5
|
import type { TurnId } from '../../types/ids/index.js'
|
|
3
|
-
import type
|
|
6
|
+
import { type SessionRecord, SessionRecordSchema } from '../../types/session/records.js'
|
|
4
7
|
import type {
|
|
8
|
+
CompletedToolRecord,
|
|
5
9
|
ToolExecutionRecord,
|
|
6
10
|
ToolExecutionSnapshot,
|
|
7
11
|
} from '../../types/session/tool-execution.js'
|
|
12
|
+
import { parseStructuredResultJson } from '../../utils/structured-result-json.js'
|
|
13
|
+
|
|
14
|
+
/** Full JSON retained across one recovery snapshot, after superseded calls are removed. */
|
|
15
|
+
const STRUCTURED_RECOVERY_MAX_BYTES = 64 * 1024 * 1024
|
|
8
16
|
|
|
9
17
|
/**
|
|
10
18
|
* Collects the latest execution boundary of selected tool calls from one
|
|
11
|
-
* turn's records
|
|
12
|
-
*
|
|
19
|
+
* turn's records, including bounded receipts and optional runtime-owned JSON
|
|
20
|
+
* candidates. Structured spill bodies are hydrated separately, after the
|
|
21
|
+
* whole log has verified; ordinary output spills remain bounded receipts.
|
|
13
22
|
*/
|
|
14
23
|
export class ToolExecutionCollector {
|
|
15
24
|
private started = false
|
|
16
25
|
private readonly wanted: Set<string>
|
|
17
26
|
private readonly records = new Map<string, ToolExecutionRecord>()
|
|
27
|
+
private readonly structuredSpills = new Map<string, SpillRef>()
|
|
18
28
|
|
|
19
29
|
constructor(
|
|
20
30
|
private readonly turnId: TurnId,
|
|
@@ -36,21 +46,101 @@ export class ToolExecutionCollector {
|
|
|
36
46
|
if (record.type === 'tool_executing') {
|
|
37
47
|
// A later start invalidates an earlier completion, including retries.
|
|
38
48
|
this.records.set(event.toolUseId, { ...identity, status: 'started' })
|
|
49
|
+
this.structuredSpills.delete(event.toolUseId)
|
|
39
50
|
return
|
|
40
51
|
}
|
|
41
52
|
if (typeof event.result !== 'string' || typeof event.isError !== 'boolean')
|
|
42
53
|
throw new Error('Tool recovery found an invalid completion.')
|
|
54
|
+
const inputFailure = event.inputFailure
|
|
55
|
+
if (
|
|
56
|
+
inputFailure !== undefined &&
|
|
57
|
+
(typeof inputFailure !== 'string' ||
|
|
58
|
+
!['invalid_json', 'schema_validation', 'input_truncated'].includes(inputFailure) ||
|
|
59
|
+
event.isError !== true)
|
|
60
|
+
)
|
|
61
|
+
throw new Error('Tool recovery found an invalid input failure classification.')
|
|
62
|
+
const skipped = event.skipped
|
|
63
|
+
if (
|
|
64
|
+
skipped !== undefined &&
|
|
65
|
+
(skipped !== true || event.isError !== false || inputFailure !== undefined)
|
|
66
|
+
)
|
|
67
|
+
throw new Error('Tool recovery found an invalid skipped completion classification.')
|
|
68
|
+
const structuredResultJson = event.structuredResultJson
|
|
69
|
+
const structuredResultSpill = event.structuredResultSpill
|
|
70
|
+
if (structuredResultJson !== undefined || structuredResultSpill !== undefined) {
|
|
71
|
+
if (
|
|
72
|
+
event.toolName !== STRUCTURED_OUTPUT_TOOL_NAME ||
|
|
73
|
+
event.isError !== false ||
|
|
74
|
+
skipped !== undefined ||
|
|
75
|
+
inputFailure !== undefined ||
|
|
76
|
+
event.via !== undefined
|
|
77
|
+
)
|
|
78
|
+
throw new Error(
|
|
79
|
+
'Tool recovery found an invalid durable structured completion classification.',
|
|
80
|
+
)
|
|
81
|
+
if (structuredResultSpill !== undefined) {
|
|
82
|
+
// Also refuse malformed references and contradictory inline evidence
|
|
83
|
+
// when the collector is driven outside the strict log reader.
|
|
84
|
+
SessionRecordSchema.parse(record)
|
|
85
|
+
} else {
|
|
86
|
+
parseStructuredResultJson(structuredResultJson)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
this.structuredSpills.delete(event.toolUseId)
|
|
90
|
+
if (structuredResultSpill !== undefined)
|
|
91
|
+
this.structuredSpills.set(event.toolUseId, structuredResultSpill as SpillRef)
|
|
43
92
|
this.records.set(event.toolUseId, {
|
|
44
93
|
...identity,
|
|
45
94
|
status: 'completed',
|
|
46
95
|
result: event.result,
|
|
47
96
|
isError: event.isError,
|
|
97
|
+
...(inputFailure !== undefined
|
|
98
|
+
? { inputFailure: inputFailure as CompletedToolRecord['inputFailure'] }
|
|
99
|
+
: {}),
|
|
100
|
+
...(skipped ? { skipped: true as const } : {}),
|
|
101
|
+
...(structuredResultJson !== undefined
|
|
102
|
+
? { structuredResultJson: structuredResultJson as string }
|
|
103
|
+
: {}),
|
|
48
104
|
})
|
|
49
105
|
}
|
|
50
106
|
|
|
51
107
|
/** Complete only when the turn's beginning was seen and the whole log verified. */
|
|
52
108
|
finish(complete = true): ToolExecutionSnapshot {
|
|
53
|
-
|
|
109
|
+
// A synchronous fold cannot establish spilled structured evidence.
|
|
110
|
+
// Its snapshot is incomplete until checked hydration finishes.
|
|
111
|
+
return {
|
|
112
|
+
complete: complete && this.started && this.structuredSpills.size === 0,
|
|
113
|
+
records: this.records,
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Hydrate only the latest selected completion; overwritten retry bodies are irrelevant. */
|
|
118
|
+
async finishWithSpills(
|
|
119
|
+
log: SessionLog,
|
|
120
|
+
complete = true,
|
|
121
|
+
signal?: AbortSignal,
|
|
122
|
+
): Promise<ToolExecutionSnapshot> {
|
|
123
|
+
signal?.throwIfAborted()
|
|
124
|
+
if (!complete || !this.started) return this.finish(false)
|
|
125
|
+
let totalBytes = 0
|
|
126
|
+
for (const ref of this.structuredSpills.values()) {
|
|
127
|
+
totalBytes += ref.bytes
|
|
128
|
+
if (totalBytes > STRUCTURED_RECOVERY_MAX_BYTES) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`Structured recovery exceeds the ${STRUCTURED_RECOVERY_MAX_BYTES}-byte aggregate limit.`,
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const records = new Map(this.records)
|
|
135
|
+
for (const [id, ref] of this.structuredSpills) {
|
|
136
|
+
const record = records.get(id)
|
|
137
|
+
if (!record || record.status !== 'completed')
|
|
138
|
+
throw new Error('Structured spill lacks a completed call.')
|
|
139
|
+
const { json: structuredResultJson } = await readStructuredResultSpill(log, ref, signal)
|
|
140
|
+
records.set(id, { ...record, structuredResultJson })
|
|
141
|
+
}
|
|
142
|
+
signal?.throwIfAborted()
|
|
143
|
+
return { complete: true, records }
|
|
54
144
|
}
|
|
55
145
|
}
|
|
56
146
|
|
|
@@ -68,10 +158,19 @@ export async function readToolExecutions(
|
|
|
68
158
|
signal?.throwIfAborted()
|
|
69
159
|
const collector = new ToolExecutionCollector(turnId, ids)
|
|
70
160
|
const walk = log.read({ mode: 'strict' })
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
161
|
+
try {
|
|
162
|
+
for (;;) {
|
|
163
|
+
signal?.throwIfAborted()
|
|
164
|
+
const step = await walk.next()
|
|
165
|
+
if (step.done)
|
|
166
|
+
return collector.finishWithSpills(
|
|
167
|
+
log,
|
|
168
|
+
step.value.intact && step.value.tornBytes === 0,
|
|
169
|
+
signal,
|
|
170
|
+
)
|
|
171
|
+
collector.accept(step.value.record)
|
|
172
|
+
}
|
|
173
|
+
} finally {
|
|
174
|
+
await walk.return({ intact: false, throughSeq: 0, head: null, tornBytes: 0 })
|
|
76
175
|
}
|
|
77
176
|
}
|
|
@@ -8,7 +8,7 @@ import type { InvocationState } from '../../types/invocation/index.js'
|
|
|
8
8
|
import type { PermissionMode } from '../../types/permission/index.js'
|
|
9
9
|
import type { AuditEventInput } from '../../types/session/audit.js'
|
|
10
10
|
import type { SessionRecord } from '../../types/session/records.js'
|
|
11
|
-
import type { RequestToolPause, SkillRegistryRef } from '../../types/tool/index.js'
|
|
11
|
+
import type { RequestToolPause, SkillRegistryRef, ToolDefinition } from '../../types/tool/index.js'
|
|
12
12
|
import type { RepairToolCall } from '../../types/tool/repair.js'
|
|
13
13
|
import type { BackoffPolicy } from '../../utils/backoff.js'
|
|
14
14
|
import type { Logger } from '../../utils/logger.js'
|
|
@@ -20,6 +20,8 @@ import type { EmitEvent } from './events.js'
|
|
|
20
20
|
export interface ToolingBootstrapConfig {
|
|
21
21
|
fileReadTracker?: import('../../types/tool/index.js').FileReadTracker
|
|
22
22
|
tools: ToolManager
|
|
23
|
+
/** Exact runtime output-tool owner for opt-in JSON retention; see ToolExecutorConfig. */
|
|
24
|
+
durableStructuredOutputTool?: ToolDefinition
|
|
23
25
|
sessionId: SessionId
|
|
24
26
|
turnId: TurnId
|
|
25
27
|
workingDirectory: string
|
|
@@ -79,6 +81,9 @@ export class ToolingBootstrap {
|
|
|
79
81
|
return new ToolExecutor(
|
|
80
82
|
{
|
|
81
83
|
tools: config.tools,
|
|
84
|
+
...(config.durableStructuredOutputTool
|
|
85
|
+
? { durableStructuredOutputTool: config.durableStructuredOutputTool }
|
|
86
|
+
: {}),
|
|
82
87
|
...(config.fileReadTracker ? { fileReadTracker: config.fileReadTracker } : {}),
|
|
83
88
|
sessionId: config.sessionId,
|
|
84
89
|
turnId: config.turnId,
|