@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 { join } from 'node:path'
|
|
2
3
|
import type { Span } from '@opentelemetry/api'
|
|
3
4
|
import type { AuthorizationGate } from '../../authorization/gate.js'
|
|
@@ -19,12 +20,13 @@ import { pathOutsideRoots, toolRoots } from '../../tools/paths.js'
|
|
|
19
20
|
import type { ToolManager } from '../../toolsets/manager.js'
|
|
20
21
|
import type { ToolSourceRef } from '../../toolsets/types.js'
|
|
21
22
|
import type { ToolResultGuardrailSpec } from '../../types/guardrail/index.js'
|
|
22
|
-
import type { ToolCallEscalation } from '../../types/hitl/index.js'
|
|
23
|
+
import type { ToolCallDeclined, ToolCallEscalation } from '../../types/hitl/index.js'
|
|
23
24
|
import type { SessionId, ToolUseId, TurnId } from '../../types/ids/index.js'
|
|
24
25
|
import type { InvocationState } from '../../types/invocation/index.js'
|
|
25
26
|
import {
|
|
26
27
|
type Message,
|
|
27
28
|
type ToolCall,
|
|
29
|
+
type ToolMessage,
|
|
28
30
|
type ToolResultContent,
|
|
29
31
|
type ToolRevealReceipt,
|
|
30
32
|
createToolMessage,
|
|
@@ -35,15 +37,18 @@ import type { ChatCompletionResponse } from '../../types/provider/index.js'
|
|
|
35
37
|
import type { Sandbox } from '../../types/sandbox/index.js'
|
|
36
38
|
import type { AuditEventInput } from '../../types/session/audit.js'
|
|
37
39
|
import type { SessionRecord } from '../../types/session/records.js'
|
|
40
|
+
import type { CompletedToolRecord } from '../../types/session/tool-execution.js'
|
|
38
41
|
import type {
|
|
39
42
|
FileReadTracker,
|
|
40
43
|
PreparedToolExecution,
|
|
41
44
|
RequestToolPause,
|
|
42
45
|
ShellDialect,
|
|
43
46
|
SkillRegistryRef,
|
|
47
|
+
ToolCallView,
|
|
44
48
|
ToolContext,
|
|
45
49
|
ToolDefinition,
|
|
46
50
|
ToolDispatchOptions,
|
|
51
|
+
ToolFacts,
|
|
47
52
|
ToolHandoff,
|
|
48
53
|
ToolResult,
|
|
49
54
|
} from '../../types/tool/index.js'
|
|
@@ -55,22 +60,21 @@ import { toErrorMessage } from '../../utils/error.js'
|
|
|
55
60
|
import { generateToolCallId } from '../../utils/id.js'
|
|
56
61
|
import type { Logger } from '../../utils/logger.js'
|
|
57
62
|
import { compressShellOutput } from '../../utils/shell-compress.js'
|
|
63
|
+
import { parseStructuredResultJson } from '../../utils/structured-result-json.js'
|
|
58
64
|
import { type BackgroundJobRegistry, type JobProcess, bindOwner } from '../jobs/registry.js'
|
|
59
65
|
import {
|
|
60
66
|
type ToolAdmissionHost,
|
|
61
67
|
formatFailedToolOutput,
|
|
62
68
|
isUnregistered,
|
|
63
69
|
prepareDirectCall,
|
|
64
|
-
repairTruncatedCall,
|
|
65
|
-
resolveCall,
|
|
66
70
|
runPreToolHook,
|
|
67
71
|
unknownToolMessage,
|
|
68
|
-
unreadableToolCallMessage,
|
|
69
72
|
} from './executor/tool-call-admission.js'
|
|
70
73
|
import { describeVisibleFileEvidence } from './file-evidence-context.js'
|
|
71
74
|
import { seedObservationLedger } from './file-evidence-seed.js'
|
|
72
75
|
import { DEFAULT_TOOL_RESULT_GUARDRAILS } from './guardrail-presets.js'
|
|
73
76
|
import type { ToolResultObservation } from './project-instructions.js'
|
|
77
|
+
import { savedPresentation } from './saved-presentation.js'
|
|
74
78
|
import { ToolCallBudget, assertMaxToolCalls } from './tool-call-budget.js'
|
|
75
79
|
import {
|
|
76
80
|
DEFAULT_MAX_TOOL_OUTPUT_CHARS,
|
|
@@ -96,6 +100,7 @@ export type PreparedDirectCall =
|
|
|
96
100
|
readonly toolCall: ToolCall
|
|
97
101
|
readonly toolName: string
|
|
98
102
|
readonly input: unknown
|
|
103
|
+
readonly inputFailure?: CompletedToolRecord['inputFailure']
|
|
99
104
|
}
|
|
100
105
|
| {
|
|
101
106
|
readonly kind: 'synthetic'
|
|
@@ -104,6 +109,10 @@ export type PreparedDirectCall =
|
|
|
104
109
|
readonly input: unknown
|
|
105
110
|
readonly message: string
|
|
106
111
|
readonly isError: boolean
|
|
112
|
+
readonly inputFailure?: CompletedToolRecord['inputFailure']
|
|
113
|
+
readonly skipped?: true
|
|
114
|
+
/** Why it never ran, as a kind; see `ToolFacts`. */
|
|
115
|
+
readonly facts?: ToolFacts
|
|
107
116
|
}
|
|
108
117
|
|
|
109
118
|
/**
|
|
@@ -152,6 +161,7 @@ type PreparedNestedCall =
|
|
|
152
161
|
readonly input: unknown
|
|
153
162
|
readonly message: string
|
|
154
163
|
readonly isError: boolean
|
|
164
|
+
readonly skipped?: true
|
|
155
165
|
}
|
|
156
166
|
|
|
157
167
|
/**
|
|
@@ -309,6 +319,8 @@ export const DEFAULT_TOOL_RETRY_BACKOFF: BackoffPolicy = {
|
|
|
309
319
|
export interface ToolExecutorConfig {
|
|
310
320
|
fileReadTracker?: FileReadTracker
|
|
311
321
|
tools: ToolManager
|
|
322
|
+
/** Exact runtime output-tool owner allowed to retain post-screen, post-hook JSON before preview capping. */
|
|
323
|
+
durableStructuredOutputTool?: ToolDefinition
|
|
312
324
|
sessionId: SessionId
|
|
313
325
|
turnId: TurnId
|
|
314
326
|
workingDirectory: string
|
|
@@ -496,6 +508,12 @@ export interface ToolCallOutcome {
|
|
|
496
508
|
/** Rich form for the model, when the tool supplied one. */
|
|
497
509
|
content?: ToolResultContent
|
|
498
510
|
isError?: boolean
|
|
511
|
+
/** Provider argument admission failure, never inferred from receipt text. */
|
|
512
|
+
inputFailure?: CompletedToolRecord['inputFailure']
|
|
513
|
+
/** A pre-tool hook deliberately skipped execution; its receipt is not an output candidate. */
|
|
514
|
+
skipped?: true
|
|
515
|
+
/** Opt-in execution evidence, never provider content or accepted output. */
|
|
516
|
+
structuredResultJson?: string
|
|
499
517
|
/** The tool asked for a person; see `ToolResult.handoff`. */
|
|
500
518
|
handoff?: ToolHandoff
|
|
501
519
|
/**
|
|
@@ -523,6 +541,16 @@ export interface ToolExecutionBatch {
|
|
|
523
541
|
*/
|
|
524
542
|
export type ToolCallDenials = ReadonlyMap<string, string>
|
|
525
543
|
|
|
544
|
+
/**
|
|
545
|
+
* The subset of {@link ToolCallDenials} a person refused, keyed by the same
|
|
546
|
+
* ids. Only the review answer fills it, so a call listed here was declined
|
|
547
|
+
* by someone and a policy refusal is never in it.
|
|
548
|
+
*/
|
|
549
|
+
export type ToolCallDeclines = ReadonlyMap<string, ToolCallDeclined>
|
|
550
|
+
|
|
551
|
+
/** A person's note is kept whole up to this many characters. */
|
|
552
|
+
export const DECLINED_NOTE_MAX_CHARS = 4_000
|
|
553
|
+
|
|
526
554
|
/**
|
|
527
555
|
* Results for calls that already ran, keyed by `toolUseId`.
|
|
528
556
|
*
|
|
@@ -533,7 +561,11 @@ export type ToolCallDenials = ReadonlyMap<string, string>
|
|
|
533
561
|
* again — which for a payment or an email is the difference between
|
|
534
562
|
* resuming and repeating.
|
|
535
563
|
*/
|
|
536
|
-
export type
|
|
564
|
+
export type PriorToolResult = Pick<
|
|
565
|
+
CompletedToolRecord,
|
|
566
|
+
'result' | 'isError' | 'inputFailure' | 'skipped' | 'structuredResultJson'
|
|
567
|
+
>
|
|
568
|
+
export type PriorToolResults = ReadonlyMap<string, PriorToolResult>
|
|
537
569
|
|
|
538
570
|
/**
|
|
539
571
|
* Model-visible text for a tool call that was never executed.
|
|
@@ -544,6 +576,22 @@ export type PriorToolResults = ReadonlyMap<string, { result: string; isError: bo
|
|
|
544
576
|
* the reason here is also what makes rejection *steer* — the model reads
|
|
545
577
|
* it in the slot it already attends to for tool outcomes.
|
|
546
578
|
*/
|
|
579
|
+
/**
|
|
580
|
+
* The kind of refusal a call met, for the person's view. A command that asks
|
|
581
|
+
* for administrator rights is named as that; everything else is a plain block.
|
|
582
|
+
* Read from the call's own argument, never from the refusal's wording.
|
|
583
|
+
*/
|
|
584
|
+
function refusalFacts(toolName: string, input: unknown): ToolFacts {
|
|
585
|
+
const command =
|
|
586
|
+
input && typeof input === 'object' ? (input as { command?: unknown }).command : undefined
|
|
587
|
+
const elevated = typeof command === 'string' && /(^|[\s;&|(])(sudo|doas)\b/.test(command)
|
|
588
|
+
return {
|
|
589
|
+
kind: 'failure',
|
|
590
|
+
reason: elevated ? 'needs_administrator' : 'blocked',
|
|
591
|
+
subject: toolName,
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
547
595
|
export function deniedToolOutput(toolName: string, reason: string): string {
|
|
548
596
|
return `Error: Tool "${toolName}" was not executed. ${reason}`
|
|
549
597
|
}
|
|
@@ -564,6 +612,16 @@ export class ToolExecutor {
|
|
|
564
612
|
private parentSpan?: Span
|
|
565
613
|
private readonly toolCallBudget?: ToolCallBudget
|
|
566
614
|
private readonly preparedBatches = new WeakSet<PreparedToolBatch>()
|
|
615
|
+
/** Ephemeral proof of actual execution; restored messages do not acquire it. */
|
|
616
|
+
private readonly recordedObservations = new Map<
|
|
617
|
+
string,
|
|
618
|
+
{
|
|
619
|
+
readonly toolName: string
|
|
620
|
+
readonly definition: ToolDefinition
|
|
621
|
+
readonly fingerprint: string
|
|
622
|
+
readonly inputFingerprint: string
|
|
623
|
+
}
|
|
624
|
+
>()
|
|
567
625
|
/** Set per turn by the orchestrator; see {@link setStepAllowedTools}. */
|
|
568
626
|
private stepAllowedTools?: readonly string[]
|
|
569
627
|
private readonly fileReadTracker: FileReadTracker
|
|
@@ -602,6 +660,50 @@ export class ToolExecutor {
|
|
|
602
660
|
this.config = { ...this.config, sandbox }
|
|
603
661
|
}
|
|
604
662
|
|
|
663
|
+
/** Classify only the exact successful result executed by this executor. */
|
|
664
|
+
recordedObservationKey(call: ToolCall, message: ToolMessage): string | undefined {
|
|
665
|
+
const recorded = this.recordedObservations.get(call.id)
|
|
666
|
+
return recorded !== undefined &&
|
|
667
|
+
message.toolCallId === call.id &&
|
|
668
|
+
!message.isError &&
|
|
669
|
+
typeof message.content === 'string' &&
|
|
670
|
+
this.config.tools.get(recorded.toolName) === recorded.definition &&
|
|
671
|
+
recorded.fingerprint === this.observationFingerprint(call, message.content)
|
|
672
|
+
? recorded.inputFingerprint
|
|
673
|
+
: undefined
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
private observationFingerprint(call: ToolCall, content: string): string {
|
|
677
|
+
return createHash('sha256')
|
|
678
|
+
.update(JSON.stringify([call.function.name, call.function.arguments, content]))
|
|
679
|
+
.digest('hex')
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
private recordExecutedObservation(
|
|
683
|
+
call: ToolCall,
|
|
684
|
+
toolName: string,
|
|
685
|
+
definition: ToolDefinition,
|
|
686
|
+
input: unknown,
|
|
687
|
+
content: ToolResultContent,
|
|
688
|
+
): void {
|
|
689
|
+
if (typeof content !== 'string' || this.config.tools.get(toolName) !== definition) return
|
|
690
|
+
try {
|
|
691
|
+
if (definition.isReadOnly?.(input) !== true || definition.isDestructive?.(input) === true)
|
|
692
|
+
return
|
|
693
|
+
this.recordedObservations.set(call.id, {
|
|
694
|
+
toolName,
|
|
695
|
+
definition,
|
|
696
|
+
fingerprint: this.observationFingerprint(call, content),
|
|
697
|
+
inputFingerprint: createHash('sha256')
|
|
698
|
+
.update(JSON.stringify([toolName, input]))
|
|
699
|
+
.digest('hex'),
|
|
700
|
+
})
|
|
701
|
+
} catch {
|
|
702
|
+
// Classification is advisory. A broken predicate preserves the
|
|
703
|
+
// full evidence instead of failing an already completed call.
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
605
707
|
/**
|
|
606
708
|
* Rebuild this turn's observation ledger from history a resume restored.
|
|
607
709
|
*
|
|
@@ -844,16 +946,24 @@ export class ToolExecutor {
|
|
|
844
946
|
* The returned projection is what policy and a human review; execution later
|
|
845
947
|
* consumes the registry-owned preparations rather than parsing again.
|
|
846
948
|
*/
|
|
847
|
-
async prepareBatchForReview(
|
|
949
|
+
async prepareBatchForReview(
|
|
950
|
+
response: ChatCompletionResponse,
|
|
951
|
+
hostModifiedCallIds?: ReadonlySet<string>,
|
|
952
|
+
): Promise<PreparedToolBatch> {
|
|
848
953
|
assertUniqueToolCallIds(response.message.toolCalls ?? [])
|
|
849
954
|
const calls = new Map<string, PreparedDirectCall>()
|
|
850
955
|
const escalations = new Map<string, ToolCallEscalation>()
|
|
851
956
|
for (const toolCall of response.message.toolCalls ?? []) {
|
|
852
|
-
const call = await prepareDirectCall(
|
|
957
|
+
const call = await prepareDirectCall(
|
|
958
|
+
this.admissionHost(),
|
|
959
|
+
toolCall,
|
|
960
|
+
!hostModifiedCallIds?.has(toolCall.id),
|
|
961
|
+
)
|
|
853
962
|
calls.set(toolCall.id, call)
|
|
854
963
|
const escalation = await this.escalationOf(call)
|
|
855
964
|
if (escalation) escalations.set(toolCall.id, escalation)
|
|
856
965
|
}
|
|
966
|
+
this.config.abortSignal.throwIfAborted()
|
|
857
967
|
return this.publishPreparedBatch(calls, escalations)
|
|
858
968
|
}
|
|
859
969
|
|
|
@@ -937,13 +1047,14 @@ export class ToolExecutor {
|
|
|
937
1047
|
const escalations = new Map((previous as OwnedPreparedToolBatch).escalations)
|
|
938
1048
|
for (const toolCall of response.message.toolCalls ?? []) {
|
|
939
1049
|
if (changedCallIds.has(toolCall.id)) {
|
|
940
|
-
const call = await prepareDirectCall(this.admissionHost(), toolCall)
|
|
1050
|
+
const call = await prepareDirectCall(this.admissionHost(), toolCall, false)
|
|
941
1051
|
calls.set(toolCall.id, call)
|
|
942
1052
|
const escalation = await this.escalationOf(call)
|
|
943
1053
|
if (escalation) escalations.set(toolCall.id, escalation)
|
|
944
1054
|
else escalations.delete(toolCall.id)
|
|
945
1055
|
}
|
|
946
1056
|
}
|
|
1057
|
+
this.config.abortSignal.throwIfAborted()
|
|
947
1058
|
return this.publishPreparedBatch(calls, escalations)
|
|
948
1059
|
}
|
|
949
1060
|
|
|
@@ -979,6 +1090,7 @@ export class ToolExecutor {
|
|
|
979
1090
|
denials?: ToolCallDenials,
|
|
980
1091
|
prior?: PriorToolResults,
|
|
981
1092
|
preparedBatch?: PreparedToolBatch,
|
|
1093
|
+
declines?: ToolCallDeclines,
|
|
982
1094
|
): Promise<ToolExecutionBatch> {
|
|
983
1095
|
const toolCalls = response.message.toolCalls
|
|
984
1096
|
if (!toolCalls) {
|
|
@@ -1004,9 +1116,9 @@ export class ToolExecutor {
|
|
|
1004
1116
|
if (refusal) {
|
|
1005
1117
|
const refused = new Map(denials)
|
|
1006
1118
|
for (const call of toolCalls) if (!refused.has(call.id)) refused.set(call.id, refusal)
|
|
1007
|
-
return await this.runBatch(toolCalls, refused, prior, owned)
|
|
1119
|
+
return await this.runBatch(toolCalls, refused, prior, owned, declines)
|
|
1008
1120
|
}
|
|
1009
|
-
return await this.runBatch(toolCalls, denials, prior, owned)
|
|
1121
|
+
return await this.runBatch(toolCalls, denials, prior, owned, declines)
|
|
1010
1122
|
} finally {
|
|
1011
1123
|
// Cleared so a later single execution outside a batch resolves
|
|
1012
1124
|
// live rather than inheriting the last batch's sample.
|
|
@@ -1019,6 +1131,7 @@ export class ToolExecutor {
|
|
|
1019
1131
|
denials?: ToolCallDenials,
|
|
1020
1132
|
prior?: PriorToolResults,
|
|
1021
1133
|
preparedBatch?: OwnedPreparedToolBatch,
|
|
1134
|
+
declines?: ToolCallDeclines,
|
|
1022
1135
|
): Promise<ToolExecutionBatch> {
|
|
1023
1136
|
this.log.debug('Executing tool batch', {
|
|
1024
1137
|
[NAMZU.TURN_ID]: this.config.turnId,
|
|
@@ -1031,6 +1144,7 @@ export class ToolExecutor {
|
|
|
1031
1144
|
// One context per call so each execution can see its own
|
|
1032
1145
|
// `toolUseId`. The base context is built once; we spread + add
|
|
1033
1146
|
// per-call to keep allocations cheap.
|
|
1147
|
+
for (const call of toolCalls) this.recordedObservations.delete(call.id)
|
|
1034
1148
|
const observations: ToolResultObservation[] = []
|
|
1035
1149
|
const recordObservation = (observation: ToolResultObservation): void => {
|
|
1036
1150
|
observations.push(observation)
|
|
@@ -1093,6 +1207,11 @@ export class ToolExecutor {
|
|
|
1093
1207
|
toolName: toolCall.function.name,
|
|
1094
1208
|
output: recovered.result,
|
|
1095
1209
|
isError: recovered.isError,
|
|
1210
|
+
...(recovered.inputFailure ? { inputFailure: recovered.inputFailure } : {}),
|
|
1211
|
+
...(recovered.skipped ? { skipped: true as const } : {}),
|
|
1212
|
+
...(recovered.structuredResultJson !== undefined
|
|
1213
|
+
? { structuredResultJson: recovered.structuredResultJson }
|
|
1214
|
+
: {}),
|
|
1096
1215
|
}
|
|
1097
1216
|
if (isBarrier) schedule(async () => {}, true, true)
|
|
1098
1217
|
return
|
|
@@ -1105,7 +1224,12 @@ export class ToolExecutor {
|
|
|
1105
1224
|
// overlap other calls within a segment, respecting its barriers.
|
|
1106
1225
|
schedule(
|
|
1107
1226
|
async () => {
|
|
1108
|
-
results[i] = await this.recordDenial(
|
|
1227
|
+
results[i] = await this.recordDenial(
|
|
1228
|
+
toolCall,
|
|
1229
|
+
denialReason,
|
|
1230
|
+
preparedCall,
|
|
1231
|
+
declines?.get(toolCall.id),
|
|
1232
|
+
)
|
|
1109
1233
|
},
|
|
1110
1234
|
true,
|
|
1111
1235
|
isBarrier,
|
|
@@ -1300,6 +1424,7 @@ export class ToolExecutor {
|
|
|
1300
1424
|
toolName: name,
|
|
1301
1425
|
result: preparedCall.message,
|
|
1302
1426
|
isError: preparedCall.isError,
|
|
1427
|
+
...(preparedCall.skipped ? { skipped: true as const } : {}),
|
|
1303
1428
|
durationMs: Date.now() - startedAt,
|
|
1304
1429
|
outputLength: preparedCall.message.length,
|
|
1305
1430
|
...(via ? { via } : {}),
|
|
@@ -1316,11 +1441,23 @@ export class ToolExecutor {
|
|
|
1316
1441
|
commandDialect: this.commandDialect(name),
|
|
1317
1442
|
toolSource: this.toolSource(name),
|
|
1318
1443
|
})
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1444
|
+
// A tool that declares `requiresApproval` for this input needs a person's
|
|
1445
|
+
// yes for every call, and no rule outranks that. An operator review cannot
|
|
1446
|
+
// be opened from inside another tool, so a nested call to it is refused
|
|
1447
|
+
// even when a rule allows it (the direct path turns that allow into a review).
|
|
1448
|
+
const nestedTool = this.config.tools.get(name)
|
|
1449
|
+
let needsApproval = false
|
|
1450
|
+
try {
|
|
1451
|
+
needsApproval = nestedTool?.requiresApproval?.(preparedInput as never) === true
|
|
1452
|
+
} catch {
|
|
1453
|
+
needsApproval = true
|
|
1454
|
+
}
|
|
1455
|
+
if (needsApproval || (gateResult && gateResult.decision !== 'allow')) {
|
|
1456
|
+
const reason = needsApproval
|
|
1457
|
+
? `Blocked: "${name}" requires the person's approval for every call, and an approval cannot be requested from inside another tool. Call it directly.`
|
|
1458
|
+
: gateResult?.decision === 'deny'
|
|
1322
1459
|
? `Blocked by the authorization gate: ${gateResult.reason}`
|
|
1323
|
-
: `Blocked by the authorization gate: this nested call requires an explicit allow rule because an operator review cannot be opened from inside another tool. ${gateResult
|
|
1460
|
+
: `Blocked by the authorization gate: this nested call requires an explicit allow rule because an operator review cannot be opened from inside another tool. ${gateResult?.reason}`
|
|
1324
1461
|
const output = deniedToolOutput(name, reason)
|
|
1325
1462
|
// Same fail-closed durability rule as a direct gate denial: if the
|
|
1326
1463
|
// configured session log cannot record the refusal, do not quietly carry
|
|
@@ -1485,7 +1622,8 @@ export class ToolExecutor {
|
|
|
1485
1622
|
toolUseId: nestedId,
|
|
1486
1623
|
toolName: name,
|
|
1487
1624
|
result: budgeted.output,
|
|
1488
|
-
...
|
|
1625
|
+
...this.resultPresentation(name, preparedInput, result, budgeted.truncated),
|
|
1626
|
+
...(result.facts !== undefined ? { facts: result.facts } : {}),
|
|
1489
1627
|
isError: !result.success,
|
|
1490
1628
|
durationMs: Date.now() - startedAt,
|
|
1491
1629
|
outputLength: budgeted.originalLength,
|
|
@@ -1507,24 +1645,34 @@ export class ToolExecutor {
|
|
|
1507
1645
|
return visibleResult
|
|
1508
1646
|
}
|
|
1509
1647
|
|
|
1510
|
-
private resultPresentation(name: string, input: unknown, result: ToolResult) {
|
|
1648
|
+
private resultPresentation(name: string, input: unknown, result: ToolResult, savedOnly = false) {
|
|
1511
1649
|
try {
|
|
1512
1650
|
const view = this.config.tools.get(name)?.presentResult?.(input, result)
|
|
1513
1651
|
// A failed call carries one view only: the person's No on the tool's
|
|
1514
1652
|
// own screen, which a host draws as cancelled rather than failed and
|
|
1515
1653
|
// cannot tell apart from the result text alone.
|
|
1516
1654
|
if (!result.success) {
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1655
|
+
if (!savedOnly && view?.kind === 'generic' && view.outcome === 'cancelled')
|
|
1656
|
+
return {
|
|
1657
|
+
presentation: {
|
|
1658
|
+
kind: 'generic',
|
|
1659
|
+
label: view.label,
|
|
1660
|
+
outcome: 'cancelled',
|
|
1661
|
+
} as const,
|
|
1662
|
+
}
|
|
1663
|
+
const saved = savedPresentation(
|
|
1664
|
+
input,
|
|
1665
|
+
this.config.tools.get(name)?.presentCall?.(input),
|
|
1666
|
+
undefined,
|
|
1667
|
+
)
|
|
1668
|
+
return saved ? { savedPresentation: saved } : {}
|
|
1669
|
+
}
|
|
1670
|
+
if (savedOnly || view?.kind !== 'diff') {
|
|
1671
|
+
// Journal-only: the live event keeps drawing the real result.
|
|
1672
|
+
const tool = this.config.tools.get(name)
|
|
1673
|
+
const saved = savedPresentation(input, tool?.presentCall?.(input), view)
|
|
1674
|
+
return saved ? { savedPresentation: saved } : {}
|
|
1526
1675
|
}
|
|
1527
|
-
if (view?.kind !== 'diff') return {}
|
|
1528
1676
|
const serialized = JSON.stringify(view)
|
|
1529
1677
|
if (serialized.length > (this.config.maxToolOutputChars ?? DEFAULT_MAX_TOOL_OUTPUT_CHARS))
|
|
1530
1678
|
return {}
|
|
@@ -1653,111 +1801,33 @@ export class ToolExecutor {
|
|
|
1653
1801
|
let toolName = preparedCall?.toolName ?? toolCall.function.name
|
|
1654
1802
|
let input: unknown
|
|
1655
1803
|
let prepared: PreparedToolExecution | undefined
|
|
1804
|
+
let inputFailure: ToolCallOutcome['inputFailure']
|
|
1656
1805
|
|
|
1657
1806
|
if (preparedCall?.kind === 'ready' || preparedCall?.kind === 'legacy') {
|
|
1658
1807
|
input = preparedCall.input
|
|
1659
1808
|
prepared = preparedCall.kind === 'ready' ? preparedCall.prepared : undefined
|
|
1809
|
+
if (preparedCall.kind === 'legacy') inputFailure = preparedCall.inputFailure
|
|
1660
1810
|
} else {
|
|
1661
|
-
//
|
|
1662
|
-
//
|
|
1663
|
-
//
|
|
1664
|
-
|
|
1665
|
-
// unused. Offer it the partial buffer first.
|
|
1666
|
-
const truncationRepair =
|
|
1667
|
-
toolCall.metadata?.inputTruncated === true
|
|
1668
|
-
? await repairTruncatedCall(this.admissionHost(), toolCall, toolName)
|
|
1669
|
-
: null
|
|
1670
|
-
|
|
1671
|
-
if (toolCall.metadata?.inputTruncated === true && !truncationRepair) {
|
|
1672
|
-
const message = unreadableToolCallMessage(this.admissionHost(), toolCall, toolName)
|
|
1673
|
-
await this.emitEvent({
|
|
1674
|
-
type: 'tool_executing',
|
|
1675
|
-
turnId: this.config.turnId,
|
|
1676
|
-
toolUseId: toolCall.id,
|
|
1677
|
-
toolName,
|
|
1678
|
-
input: {},
|
|
1679
|
-
})
|
|
1680
|
-
await this.emitEvent({
|
|
1681
|
-
type: 'tool_completed',
|
|
1682
|
-
turnId: this.config.turnId,
|
|
1683
|
-
toolUseId: toolCall.id,
|
|
1684
|
-
toolName,
|
|
1685
|
-
result: message,
|
|
1686
|
-
isError: true,
|
|
1687
|
-
})
|
|
1688
|
-
return {
|
|
1689
|
-
toolCallId: toolCall.id,
|
|
1690
|
-
toolName,
|
|
1691
|
-
output: message,
|
|
1692
|
-
isError: true,
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
// A malformed call used to cost a full model round trip to fix: the
|
|
1697
|
-
// error went back as a `tool_result`, the model re-read the whole
|
|
1698
|
-
// context and tried again. A host that can repair it locally turns
|
|
1699
|
-
// that into nothing. No-op when no repairer is configured.
|
|
1700
|
-
const resolved = await resolveCall(
|
|
1701
|
-
this.admissionHost(),
|
|
1702
|
-
truncationRepair
|
|
1703
|
-
? {
|
|
1704
|
-
...toolCall,
|
|
1705
|
-
function: {
|
|
1706
|
-
...toolCall.function,
|
|
1707
|
-
name: truncationRepair.toolName ?? toolName,
|
|
1708
|
-
arguments: truncationRepair.arguments,
|
|
1709
|
-
},
|
|
1710
|
-
metadata: {},
|
|
1711
|
-
}
|
|
1712
|
-
: toolCall,
|
|
1713
|
-
)
|
|
1714
|
-
toolName = resolved.toolName
|
|
1715
|
-
|
|
1716
|
-
if (!resolved.ok) {
|
|
1717
|
-
// malformed JSON args used to return without ever
|
|
1718
|
-
// emitting tool_executing or tool_completed, leaving UI cards
|
|
1719
|
-
// orphaned in `streaming_input`. Emit the executing→completed
|
|
1720
|
-
// terminal pair so the card lifecycle closes.
|
|
1721
|
-
const message = resolved.message
|
|
1722
|
-
await this.emitEvent({
|
|
1723
|
-
type: 'tool_executing',
|
|
1724
|
-
turnId: this.config.turnId,
|
|
1725
|
-
toolUseId: toolCall.id,
|
|
1726
|
-
toolName,
|
|
1727
|
-
input: {},
|
|
1728
|
-
})
|
|
1729
|
-
await this.emitEvent({
|
|
1730
|
-
type: 'tool_completed',
|
|
1731
|
-
turnId: this.config.turnId,
|
|
1732
|
-
toolUseId: toolCall.id,
|
|
1733
|
-
toolName,
|
|
1734
|
-
result: message,
|
|
1735
|
-
isError: true,
|
|
1736
|
-
})
|
|
1737
|
-
return {
|
|
1738
|
-
toolCallId: toolCall.id,
|
|
1739
|
-
toolName,
|
|
1740
|
-
output: message,
|
|
1741
|
-
isError: true,
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
input = resolved.input
|
|
1746
|
-
|
|
1747
|
-
let preOutcome: PreToolHookOutcome
|
|
1811
|
+
// The unreviewed executor path uses the same preparation as a
|
|
1812
|
+
// reviewed call. Parsing here and again in the registry would run
|
|
1813
|
+
// transforms twice and reject asynchronous schemas.
|
|
1814
|
+
let admitted: PreparedDirectCall
|
|
1748
1815
|
try {
|
|
1749
|
-
|
|
1816
|
+
admitted = await prepareDirectCall(this.admissionHost(), toolCall)
|
|
1817
|
+
this.config.abortSignal.throwIfAborted()
|
|
1750
1818
|
} catch (error) {
|
|
1751
1819
|
if (!this.config.abortSignal.aborted) throw error
|
|
1752
|
-
//
|
|
1753
|
-
//
|
|
1754
|
-
return this.recordCancelledBeforeExecution(toolCall.id, toolName,
|
|
1820
|
+
// Keep earlier settled siblings' receipts when a later
|
|
1821
|
+
// preparation is interrupted.
|
|
1822
|
+
return this.recordCancelledBeforeExecution(toolCall.id, toolName, {})
|
|
1755
1823
|
}
|
|
1756
|
-
if (
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1824
|
+
if (admitted.kind === 'synthetic') return this.recordSyntheticPreparation(admitted)
|
|
1825
|
+
toolName = admitted.toolName
|
|
1826
|
+
input = admitted.input
|
|
1827
|
+
prepared = admitted.kind === 'ready' ? admitted.prepared : undefined
|
|
1828
|
+
if (admitted.kind === 'legacy') inputFailure = admitted.inputFailure
|
|
1760
1829
|
}
|
|
1830
|
+
const executedDefinition = this.config.tools.get(toolName)
|
|
1761
1831
|
|
|
1762
1832
|
const activity = this.activityStore.create({
|
|
1763
1833
|
type: 'tool_call',
|
|
@@ -1961,6 +2031,28 @@ export class ToolExecutor {
|
|
|
1961
2031
|
}
|
|
1962
2032
|
const maxToolOutputChars = this.config.maxToolOutputChars ?? DEFAULT_MAX_TOOL_OUTPUT_CHARS
|
|
1963
2033
|
const sourceOutput = output
|
|
2034
|
+
// This owner-bound channel follows the selected receipt after both result
|
|
2035
|
+
// screening and post-tool replacement. ToolResult.data and raw input can
|
|
2036
|
+
// still carry pre-redaction values and must never be promoted here.
|
|
2037
|
+
let structuredResultJson: string | undefined
|
|
2038
|
+
if (
|
|
2039
|
+
prepared &&
|
|
2040
|
+
executedDefinition !== undefined &&
|
|
2041
|
+
executedDefinition === this.config.durableStructuredOutputTool &&
|
|
2042
|
+
toolName === 'structured_output' &&
|
|
2043
|
+
toolCall.function.name === 'structured_output' &&
|
|
2044
|
+
result.success &&
|
|
2045
|
+
!postOverride?.isError &&
|
|
2046
|
+
!this.config.abortSignal.aborted
|
|
2047
|
+
) {
|
|
2048
|
+
try {
|
|
2049
|
+
parseStructuredResultJson(sourceOutput)
|
|
2050
|
+
structuredResultJson = sourceOutput
|
|
2051
|
+
} catch {
|
|
2052
|
+
// Keep the completion receipt: malformed host output fails at the
|
|
2053
|
+
// normal candidate-integrity boundary, never as a schema correction.
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
1964
2056
|
|
|
1965
2057
|
// Compression is opportunistic and shell-only; the budget is the
|
|
1966
2058
|
// hard bound that applies to every final tool result, including a
|
|
@@ -2006,6 +2098,10 @@ export class ToolExecutor {
|
|
|
2006
2098
|
// unusable: the model was told a successful call had gone wrong, and
|
|
2007
2099
|
// routed around it.
|
|
2008
2100
|
const effectiveIsError = !result.success || (postOverride?.isError ?? false)
|
|
2101
|
+
const visibleInputFailure =
|
|
2102
|
+
!result.success && !postOverride && !this.config.abortSignal.aborted
|
|
2103
|
+
? inputFailure
|
|
2104
|
+
: undefined
|
|
2009
2105
|
|
|
2010
2106
|
if (this.workingStateManager) {
|
|
2011
2107
|
extractFromToolResult(this.workingStateManager, toolName, output, effectiveIsError)
|
|
@@ -2067,16 +2163,27 @@ export class ToolExecutor {
|
|
|
2067
2163
|
// call it has already removed. Detached work reporting after a timeout is
|
|
2068
2164
|
// ignored because close() also revokes the publisher.
|
|
2069
2165
|
await settleProgress()
|
|
2166
|
+
if (this.config.abortSignal.aborted) structuredResultJson = undefined
|
|
2070
2167
|
await this.emitEvent({
|
|
2071
2168
|
type: 'tool_completed',
|
|
2072
2169
|
turnId: this.config.turnId,
|
|
2073
2170
|
toolUseId: toolCall.id,
|
|
2074
2171
|
toolName,
|
|
2075
2172
|
result: output,
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2173
|
+
// The result view only describes an output the host will show as is; the
|
|
2174
|
+
// saved label never depended on the output, so it is kept regardless.
|
|
2175
|
+
...this.resultPresentation(
|
|
2176
|
+
toolName,
|
|
2177
|
+
input,
|
|
2178
|
+
result,
|
|
2179
|
+
Boolean(postOverride) || budgeted.truncated || rawOutput !== output,
|
|
2180
|
+
),
|
|
2181
|
+
// Typed fields for the person's view. A replaced output is a redaction
|
|
2182
|
+
// the host chose, and a structured copy of the original would undo it.
|
|
2183
|
+
...(result.facts !== undefined && !postOverride ? { facts: result.facts } : {}),
|
|
2079
2184
|
isError: effectiveIsError,
|
|
2185
|
+
...(visibleInputFailure ? { inputFailure: visibleInputFailure } : {}),
|
|
2186
|
+
...(structuredResultJson !== undefined ? { structuredResultJson } : {}),
|
|
2080
2187
|
durationMs,
|
|
2081
2188
|
// Pre-truncation size, so a host can show "returned 2.1 MB" even
|
|
2082
2189
|
// though the model only ever saw a preview.
|
|
@@ -2094,11 +2201,23 @@ export class ToolExecutor {
|
|
|
2094
2201
|
result,
|
|
2095
2202
|
})
|
|
2096
2203
|
|
|
2204
|
+
if (prepared && executedDefinition && !effectiveIsError && !this.config.abortSignal.aborted) {
|
|
2205
|
+
this.recordExecutedObservation(
|
|
2206
|
+
toolCall,
|
|
2207
|
+
toolName,
|
|
2208
|
+
executedDefinition,
|
|
2209
|
+
input,
|
|
2210
|
+
modelContent ?? output,
|
|
2211
|
+
)
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2097
2214
|
return {
|
|
2098
2215
|
toolCallId: toolCall.id,
|
|
2099
2216
|
toolName,
|
|
2100
2217
|
output,
|
|
2101
2218
|
isError: effectiveIsError,
|
|
2219
|
+
...(visibleInputFailure ? { inputFailure: visibleInputFailure } : {}),
|
|
2220
|
+
...(structuredResultJson !== undefined ? { structuredResultJson } : {}),
|
|
2102
2221
|
// Rich content follows the override's own decision.
|
|
2103
2222
|
//
|
|
2104
2223
|
// An ERROR override drops it: the payload is no longer the tool's,
|
|
@@ -2327,7 +2446,8 @@ export class ToolExecutor {
|
|
|
2327
2446
|
input: unknown,
|
|
2328
2447
|
signal: AbortSignal,
|
|
2329
2448
|
): Promise<PreparedNestedCall> {
|
|
2330
|
-
|
|
2449
|
+
signal.throwIfAborted()
|
|
2450
|
+
const prepare = this.config.tools.prepareExecutionAsync ?? this.config.tools.prepareExecution
|
|
2331
2451
|
const executePrepared = this.config.tools.executePrepared
|
|
2332
2452
|
if (typeof prepare !== 'function' || typeof executePrepared !== 'function') {
|
|
2333
2453
|
if (this.config.authorizationGate) {
|
|
@@ -2345,15 +2465,18 @@ export class ToolExecutor {
|
|
|
2345
2465
|
input: preOutcome.input,
|
|
2346
2466
|
message: preOutcome.output,
|
|
2347
2467
|
isError: preOutcome.kind === 'error',
|
|
2468
|
+
...(preOutcome.kind === 'skip' ? { skipped: true as const } : {}),
|
|
2348
2469
|
}
|
|
2349
2470
|
}
|
|
2350
2471
|
return { kind: 'legacy', input: preOutcome.input }
|
|
2351
2472
|
}
|
|
2352
2473
|
|
|
2353
|
-
let preparation: ReturnType<typeof prepare
|
|
2474
|
+
let preparation: Awaited<ReturnType<typeof prepare>>
|
|
2354
2475
|
try {
|
|
2355
|
-
preparation = prepare.call(this.config.tools, toolName, input)
|
|
2476
|
+
preparation = await prepare.call(this.config.tools, toolName, input, signal)
|
|
2477
|
+
signal.throwIfAborted()
|
|
2356
2478
|
} catch (err) {
|
|
2479
|
+
signal.throwIfAborted()
|
|
2357
2480
|
// A name the registry does not hold is answered with what this step
|
|
2358
2481
|
// can call, as a model's own call is; the registry's "Not found"
|
|
2359
2482
|
// lists everything it holds.
|
|
@@ -2387,6 +2510,7 @@ export class ToolExecutor {
|
|
|
2387
2510
|
input: preOutcome.input,
|
|
2388
2511
|
message: preOutcome.output,
|
|
2389
2512
|
isError: preOutcome.kind === 'error',
|
|
2513
|
+
...(preOutcome.kind === 'skip' ? { skipped: true as const } : {}),
|
|
2390
2514
|
}
|
|
2391
2515
|
}
|
|
2392
2516
|
if (!preOutcome.modified) {
|
|
@@ -2396,7 +2520,8 @@ export class ToolExecutor {
|
|
|
2396
2520
|
prepared: preparation.prepared,
|
|
2397
2521
|
}
|
|
2398
2522
|
}
|
|
2399
|
-
const modified = prepare.call(this.config.tools, toolName, preOutcome.input)
|
|
2523
|
+
const modified = await prepare.call(this.config.tools, toolName, preOutcome.input, signal)
|
|
2524
|
+
signal.throwIfAborted()
|
|
2400
2525
|
if (!modified.success) {
|
|
2401
2526
|
return {
|
|
2402
2527
|
kind: 'synthetic',
|
|
@@ -2534,6 +2659,7 @@ export class ToolExecutor {
|
|
|
2534
2659
|
toolCall: ToolCall,
|
|
2535
2660
|
reason: string,
|
|
2536
2661
|
preparedCall?: PreparedDirectCall,
|
|
2662
|
+
declined?: ToolCallDeclined,
|
|
2537
2663
|
): Promise<ToolCallOutcome> {
|
|
2538
2664
|
const toolName = preparedCall?.toolName ?? toolCall.function.name
|
|
2539
2665
|
let input: unknown = preparedCall?.input ?? {}
|
|
@@ -2579,12 +2705,58 @@ export class ToolExecutor {
|
|
|
2579
2705
|
toolUseId: toolCall.id,
|
|
2580
2706
|
toolName,
|
|
2581
2707
|
result: output,
|
|
2708
|
+
// Recorded only for a person's No. Every other refusal keeps the
|
|
2709
|
+
// shape it always had: no presentation at all.
|
|
2710
|
+
...(declined ? { presentation: this.declinedPresentation(toolName, input, declined) } : {}),
|
|
2711
|
+
// A refusal by policy says what kind it was; the person's own No is
|
|
2712
|
+
// already carried by the presentation above.
|
|
2713
|
+
...(declined ? {} : { facts: refusalFacts(toolName, input) }),
|
|
2582
2714
|
isError: true,
|
|
2583
2715
|
})
|
|
2584
2716
|
|
|
2585
2717
|
return { toolCallId: toolCall.id, toolName, output, isError: true }
|
|
2586
2718
|
}
|
|
2587
2719
|
|
|
2720
|
+
/**
|
|
2721
|
+
* What a host replays for a call the person declined. The label names the
|
|
2722
|
+
* target of the call (a path, a command) and nothing is inferred from the
|
|
2723
|
+
* refusal text: the note comes from the review answer.
|
|
2724
|
+
*/
|
|
2725
|
+
private declinedPresentation(
|
|
2726
|
+
toolName: string,
|
|
2727
|
+
input: unknown,
|
|
2728
|
+
declined: ToolCallDeclined,
|
|
2729
|
+
): ToolCallView {
|
|
2730
|
+
let target: string | undefined
|
|
2731
|
+
try {
|
|
2732
|
+
const view = this.config.tools.get(toolName)?.presentCall?.(input)
|
|
2733
|
+
const text =
|
|
2734
|
+
view?.kind === 'generic'
|
|
2735
|
+
? view.label
|
|
2736
|
+
: view?.kind === 'diff'
|
|
2737
|
+
? view.path || view.label
|
|
2738
|
+
: view?.kind === 'terminal'
|
|
2739
|
+
? view.command
|
|
2740
|
+
: undefined
|
|
2741
|
+
target = text
|
|
2742
|
+
?.split(/\r?\n/)
|
|
2743
|
+
.find((line) => line.trim())
|
|
2744
|
+
?.trim()
|
|
2745
|
+
.slice(0, 200)
|
|
2746
|
+
} catch {
|
|
2747
|
+
// A presentation hook must not turn a refusal into a failure.
|
|
2748
|
+
}
|
|
2749
|
+
// Cut by code point so a surrogate pair is never split.
|
|
2750
|
+
const note = Array.from(declined.note?.trim() ?? '')
|
|
2751
|
+
.slice(0, DECLINED_NOTE_MAX_CHARS)
|
|
2752
|
+
.join('')
|
|
2753
|
+
return {
|
|
2754
|
+
kind: 'generic',
|
|
2755
|
+
label: target || toolName,
|
|
2756
|
+
declined: note ? { note } : {},
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2588
2760
|
private recordCancelledBeforeExecution(
|
|
2589
2761
|
toolCallId: string,
|
|
2590
2762
|
toolName: string,
|
|
@@ -2601,7 +2773,13 @@ export class ToolExecutor {
|
|
|
2601
2773
|
toolCallId: string,
|
|
2602
2774
|
toolName: string,
|
|
2603
2775
|
input: unknown,
|
|
2604
|
-
outcome: {
|
|
2776
|
+
outcome: {
|
|
2777
|
+
kind: 'skip' | 'error'
|
|
2778
|
+
output: string
|
|
2779
|
+
inputFailure?: ToolCallOutcome['inputFailure']
|
|
2780
|
+
skipped?: true
|
|
2781
|
+
facts?: ToolFacts
|
|
2782
|
+
},
|
|
2605
2783
|
): Promise<ToolCallOutcome> {
|
|
2606
2784
|
const activity = this.activityStore.create({
|
|
2607
2785
|
type: 'tool_call',
|
|
@@ -2632,12 +2810,17 @@ export class ToolExecutor {
|
|
|
2632
2810
|
toolName,
|
|
2633
2811
|
result: outcome.output,
|
|
2634
2812
|
isError: outcome.kind === 'error',
|
|
2813
|
+
...(outcome.facts ? { facts: outcome.facts } : {}),
|
|
2814
|
+
...(outcome.inputFailure ? { inputFailure: outcome.inputFailure } : {}),
|
|
2815
|
+
...(outcome.skipped ? { skipped: true as const } : {}),
|
|
2635
2816
|
})
|
|
2636
2817
|
return {
|
|
2637
2818
|
toolCallId,
|
|
2638
2819
|
toolName,
|
|
2639
2820
|
output: outcome.output,
|
|
2640
2821
|
isError: outcome.kind === 'error',
|
|
2822
|
+
...(outcome.inputFailure ? { inputFailure: outcome.inputFailure } : {}),
|
|
2823
|
+
...(outcome.skipped ? { skipped: true as const } : {}),
|
|
2641
2824
|
}
|
|
2642
2825
|
}
|
|
2643
2826
|
|
|
@@ -2645,6 +2828,9 @@ export class ToolExecutor {
|
|
|
2645
2828
|
return this.recordSyntheticHookOutcome(call.toolCall.id, call.toolName, call.input, {
|
|
2646
2829
|
kind: call.isError ? 'error' : 'skip',
|
|
2647
2830
|
output: call.message,
|
|
2831
|
+
...(call.facts ? { facts: call.facts } : {}),
|
|
2832
|
+
...(call.inputFailure ? { inputFailure: call.inputFailure } : {}),
|
|
2833
|
+
...(call.skipped ? { skipped: true as const } : {}),
|
|
2648
2834
|
})
|
|
2649
2835
|
}
|
|
2650
2836
|
|