@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 { unknownProgramInLine } from '../../authorization/program.js';
|
|
3
4
|
import { compileSkillGrant } from '../../authorization/skill-grant.js';
|
|
@@ -17,11 +18,13 @@ import { backoffWithJitter, sleep } from '../../utils/backoff.js';
|
|
|
17
18
|
import { toErrorMessage } from '../../utils/error.js';
|
|
18
19
|
import { generateToolCallId } from '../../utils/id.js';
|
|
19
20
|
import { compressShellOutput } from '../../utils/shell-compress.js';
|
|
21
|
+
import { parseStructuredResultJson } from '../../utils/structured-result-json.js';
|
|
20
22
|
import { bindOwner } from '../jobs/registry.js';
|
|
21
|
-
import { formatFailedToolOutput, isUnregistered, prepareDirectCall,
|
|
23
|
+
import { formatFailedToolOutput, isUnregistered, prepareDirectCall, runPreToolHook, unknownToolMessage, } from './executor/tool-call-admission.js';
|
|
22
24
|
import { describeVisibleFileEvidence } from './file-evidence-context.js';
|
|
23
25
|
import { seedObservationLedger } from './file-evidence-seed.js';
|
|
24
26
|
import { DEFAULT_TOOL_RESULT_GUARDRAILS } from './guardrail-presets.js';
|
|
27
|
+
import { savedPresentation } from './saved-presentation.js';
|
|
25
28
|
import { ToolCallBudget, assertMaxToolCalls } from './tool-call-budget.js';
|
|
26
29
|
import { DEFAULT_MAX_TOOL_OUTPUT_CHARS, applyToolOutputBudget, describeDroppedContent, measureContentBytes, } from './tool-output-budget.js';
|
|
27
30
|
function assertUniqueToolCallIds(toolCalls) {
|
|
@@ -175,6 +178,8 @@ export const DEFAULT_TOOL_RETRY_BACKOFF = {
|
|
|
175
178
|
initialDelayMs: 500,
|
|
176
179
|
maxDelayMs: 16_000,
|
|
177
180
|
};
|
|
181
|
+
/** A person's note is kept whole up to this many characters. */
|
|
182
|
+
export const DECLINED_NOTE_MAX_CHARS = 4_000;
|
|
178
183
|
/**
|
|
179
184
|
* Model-visible text for a tool call that was never executed.
|
|
180
185
|
*
|
|
@@ -184,6 +189,20 @@ export const DEFAULT_TOOL_RETRY_BACKOFF = {
|
|
|
184
189
|
* the reason here is also what makes rejection *steer* — the model reads
|
|
185
190
|
* it in the slot it already attends to for tool outcomes.
|
|
186
191
|
*/
|
|
192
|
+
/**
|
|
193
|
+
* The kind of refusal a call met, for the person's view. A command that asks
|
|
194
|
+
* for administrator rights is named as that; everything else is a plain block.
|
|
195
|
+
* Read from the call's own argument, never from the refusal's wording.
|
|
196
|
+
*/
|
|
197
|
+
function refusalFacts(toolName, input) {
|
|
198
|
+
const command = input && typeof input === 'object' ? input.command : undefined;
|
|
199
|
+
const elevated = typeof command === 'string' && /(^|[\s;&|(])(sudo|doas)\b/.test(command);
|
|
200
|
+
return {
|
|
201
|
+
kind: 'failure',
|
|
202
|
+
reason: elevated ? 'needs_administrator' : 'blocked',
|
|
203
|
+
subject: toolName,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
187
206
|
export function deniedToolOutput(toolName, reason) {
|
|
188
207
|
return `Error: Tool "${toolName}" was not executed. ${reason}`;
|
|
189
208
|
}
|
|
@@ -202,6 +221,8 @@ export class ToolExecutor {
|
|
|
202
221
|
parentSpan;
|
|
203
222
|
toolCallBudget;
|
|
204
223
|
preparedBatches = new WeakSet();
|
|
224
|
+
/** Ephemeral proof of actual execution; restored messages do not acquire it. */
|
|
225
|
+
recordedObservations = new Map();
|
|
205
226
|
/** Set per turn by the orchestrator; see {@link setStepAllowedTools}. */
|
|
206
227
|
stepAllowedTools;
|
|
207
228
|
fileReadTracker;
|
|
@@ -225,6 +246,43 @@ export class ToolExecutor {
|
|
|
225
246
|
setSandbox(sandbox) {
|
|
226
247
|
this.config = { ...this.config, sandbox };
|
|
227
248
|
}
|
|
249
|
+
/** Classify only the exact successful result executed by this executor. */
|
|
250
|
+
recordedObservationKey(call, message) {
|
|
251
|
+
const recorded = this.recordedObservations.get(call.id);
|
|
252
|
+
return recorded !== undefined &&
|
|
253
|
+
message.toolCallId === call.id &&
|
|
254
|
+
!message.isError &&
|
|
255
|
+
typeof message.content === 'string' &&
|
|
256
|
+
this.config.tools.get(recorded.toolName) === recorded.definition &&
|
|
257
|
+
recorded.fingerprint === this.observationFingerprint(call, message.content)
|
|
258
|
+
? recorded.inputFingerprint
|
|
259
|
+
: undefined;
|
|
260
|
+
}
|
|
261
|
+
observationFingerprint(call, content) {
|
|
262
|
+
return createHash('sha256')
|
|
263
|
+
.update(JSON.stringify([call.function.name, call.function.arguments, content]))
|
|
264
|
+
.digest('hex');
|
|
265
|
+
}
|
|
266
|
+
recordExecutedObservation(call, toolName, definition, input, content) {
|
|
267
|
+
if (typeof content !== 'string' || this.config.tools.get(toolName) !== definition)
|
|
268
|
+
return;
|
|
269
|
+
try {
|
|
270
|
+
if (definition.isReadOnly?.(input) !== true || definition.isDestructive?.(input) === true)
|
|
271
|
+
return;
|
|
272
|
+
this.recordedObservations.set(call.id, {
|
|
273
|
+
toolName,
|
|
274
|
+
definition,
|
|
275
|
+
fingerprint: this.observationFingerprint(call, content),
|
|
276
|
+
inputFingerprint: createHash('sha256')
|
|
277
|
+
.update(JSON.stringify([toolName, input]))
|
|
278
|
+
.digest('hex'),
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
// Classification is advisory. A broken predicate preserves the
|
|
283
|
+
// full evidence instead of failing an already completed call.
|
|
284
|
+
}
|
|
285
|
+
}
|
|
228
286
|
/**
|
|
229
287
|
* Rebuild this turn's observation ledger from history a resume restored.
|
|
230
288
|
*
|
|
@@ -440,17 +498,18 @@ export class ToolExecutor {
|
|
|
440
498
|
* The returned projection is what policy and a human review; execution later
|
|
441
499
|
* consumes the registry-owned preparations rather than parsing again.
|
|
442
500
|
*/
|
|
443
|
-
async prepareBatchForReview(response) {
|
|
501
|
+
async prepareBatchForReview(response, hostModifiedCallIds) {
|
|
444
502
|
assertUniqueToolCallIds(response.message.toolCalls ?? []);
|
|
445
503
|
const calls = new Map();
|
|
446
504
|
const escalations = new Map();
|
|
447
505
|
for (const toolCall of response.message.toolCalls ?? []) {
|
|
448
|
-
const call = await prepareDirectCall(this.admissionHost(), toolCall);
|
|
506
|
+
const call = await prepareDirectCall(this.admissionHost(), toolCall, !hostModifiedCallIds?.has(toolCall.id));
|
|
449
507
|
calls.set(toolCall.id, call);
|
|
450
508
|
const escalation = await this.escalationOf(call);
|
|
451
509
|
if (escalation)
|
|
452
510
|
escalations.set(toolCall.id, escalation);
|
|
453
511
|
}
|
|
512
|
+
this.config.abortSignal.throwIfAborted();
|
|
454
513
|
return this.publishPreparedBatch(calls, escalations);
|
|
455
514
|
}
|
|
456
515
|
/**
|
|
@@ -526,7 +585,7 @@ export class ToolExecutor {
|
|
|
526
585
|
const escalations = new Map(previous.escalations);
|
|
527
586
|
for (const toolCall of response.message.toolCalls ?? []) {
|
|
528
587
|
if (changedCallIds.has(toolCall.id)) {
|
|
529
|
-
const call = await prepareDirectCall(this.admissionHost(), toolCall);
|
|
588
|
+
const call = await prepareDirectCall(this.admissionHost(), toolCall, false);
|
|
530
589
|
calls.set(toolCall.id, call);
|
|
531
590
|
const escalation = await this.escalationOf(call);
|
|
532
591
|
if (escalation)
|
|
@@ -535,6 +594,7 @@ export class ToolExecutor {
|
|
|
535
594
|
escalations.delete(toolCall.id);
|
|
536
595
|
}
|
|
537
596
|
}
|
|
597
|
+
this.config.abortSignal.throwIfAborted();
|
|
538
598
|
return this.publishPreparedBatch(calls, escalations);
|
|
539
599
|
}
|
|
540
600
|
publishPreparedBatch(calls, escalations) {
|
|
@@ -557,7 +617,7 @@ export class ToolExecutor {
|
|
|
557
617
|
this.preparedBatches.add(batch);
|
|
558
618
|
return batch;
|
|
559
619
|
}
|
|
560
|
-
async executeBatch(response, denials, prior, preparedBatch) {
|
|
620
|
+
async executeBatch(response, denials, prior, preparedBatch, declines) {
|
|
561
621
|
const toolCalls = response.message.toolCalls;
|
|
562
622
|
if (!toolCalls) {
|
|
563
623
|
return { messages: [], results: [], observations: [] };
|
|
@@ -579,9 +639,9 @@ export class ToolExecutor {
|
|
|
579
639
|
for (const call of toolCalls)
|
|
580
640
|
if (!refused.has(call.id))
|
|
581
641
|
refused.set(call.id, refusal);
|
|
582
|
-
return await this.runBatch(toolCalls, refused, prior, owned);
|
|
642
|
+
return await this.runBatch(toolCalls, refused, prior, owned, declines);
|
|
583
643
|
}
|
|
584
|
-
return await this.runBatch(toolCalls, denials, prior, owned);
|
|
644
|
+
return await this.runBatch(toolCalls, denials, prior, owned, declines);
|
|
585
645
|
}
|
|
586
646
|
finally {
|
|
587
647
|
// Cleared so a later single execution outside a batch resolves
|
|
@@ -589,7 +649,7 @@ export class ToolExecutor {
|
|
|
589
649
|
this.batchMode = undefined;
|
|
590
650
|
}
|
|
591
651
|
}
|
|
592
|
-
async runBatch(toolCalls, denials, prior, preparedBatch) {
|
|
652
|
+
async runBatch(toolCalls, denials, prior, preparedBatch, declines) {
|
|
593
653
|
this.log.debug('Executing tool batch', {
|
|
594
654
|
[NAMZU.TURN_ID]: this.config.turnId,
|
|
595
655
|
'namzu.runtime.tool_count': toolCalls.length,
|
|
@@ -600,6 +660,8 @@ export class ToolExecutor {
|
|
|
600
660
|
// One context per call so each execution can see its own
|
|
601
661
|
// `toolUseId`. The base context is built once; we spread + add
|
|
602
662
|
// per-call to keep allocations cheap.
|
|
663
|
+
for (const call of toolCalls)
|
|
664
|
+
this.recordedObservations.delete(call.id);
|
|
603
665
|
const observations = [];
|
|
604
666
|
const recordObservation = (observation) => {
|
|
605
667
|
observations.push(observation);
|
|
@@ -664,6 +726,11 @@ export class ToolExecutor {
|
|
|
664
726
|
toolName: toolCall.function.name,
|
|
665
727
|
output: recovered.result,
|
|
666
728
|
isError: recovered.isError,
|
|
729
|
+
...(recovered.inputFailure ? { inputFailure: recovered.inputFailure } : {}),
|
|
730
|
+
...(recovered.skipped ? { skipped: true } : {}),
|
|
731
|
+
...(recovered.structuredResultJson !== undefined
|
|
732
|
+
? { structuredResultJson: recovered.structuredResultJson }
|
|
733
|
+
: {}),
|
|
667
734
|
};
|
|
668
735
|
if (isBarrier)
|
|
669
736
|
schedule(async () => { }, true, true);
|
|
@@ -675,7 +742,7 @@ export class ToolExecutor {
|
|
|
675
742
|
// message so the assistant turn stays fully answered. They can
|
|
676
743
|
// overlap other calls within a segment, respecting its barriers.
|
|
677
744
|
schedule(async () => {
|
|
678
|
-
results[i] = await this.recordDenial(toolCall, denialReason, preparedCall);
|
|
745
|
+
results[i] = await this.recordDenial(toolCall, denialReason, preparedCall, declines?.get(toolCall.id));
|
|
679
746
|
}, true, isBarrier);
|
|
680
747
|
return;
|
|
681
748
|
}
|
|
@@ -850,6 +917,7 @@ export class ToolExecutor {
|
|
|
850
917
|
toolName: name,
|
|
851
918
|
result: preparedCall.message,
|
|
852
919
|
isError: preparedCall.isError,
|
|
920
|
+
...(preparedCall.skipped ? { skipped: true } : {}),
|
|
853
921
|
durationMs: Date.now() - startedAt,
|
|
854
922
|
outputLength: preparedCall.message.length,
|
|
855
923
|
...(via ? { via } : {}),
|
|
@@ -865,10 +933,24 @@ export class ToolExecutor {
|
|
|
865
933
|
commandDialect: this.commandDialect(name),
|
|
866
934
|
toolSource: this.toolSource(name),
|
|
867
935
|
});
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
936
|
+
// A tool that declares `requiresApproval` for this input needs a person's
|
|
937
|
+
// yes for every call, and no rule outranks that. An operator review cannot
|
|
938
|
+
// be opened from inside another tool, so a nested call to it is refused
|
|
939
|
+
// even when a rule allows it (the direct path turns that allow into a review).
|
|
940
|
+
const nestedTool = this.config.tools.get(name);
|
|
941
|
+
let needsApproval = false;
|
|
942
|
+
try {
|
|
943
|
+
needsApproval = nestedTool?.requiresApproval?.(preparedInput) === true;
|
|
944
|
+
}
|
|
945
|
+
catch {
|
|
946
|
+
needsApproval = true;
|
|
947
|
+
}
|
|
948
|
+
if (needsApproval || (gateResult && gateResult.decision !== 'allow')) {
|
|
949
|
+
const reason = needsApproval
|
|
950
|
+
? `Blocked: "${name}" requires the person's approval for every call, and an approval cannot be requested from inside another tool. Call it directly.`
|
|
951
|
+
: gateResult?.decision === 'deny'
|
|
952
|
+
? `Blocked by the authorization gate: ${gateResult.reason}`
|
|
953
|
+
: `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}`;
|
|
872
954
|
const output = deniedToolOutput(name, reason);
|
|
873
955
|
// Same fail-closed durability rule as a direct gate denial: if the
|
|
874
956
|
// configured session log cannot record the refusal, do not quietly carry
|
|
@@ -1004,7 +1086,8 @@ export class ToolExecutor {
|
|
|
1004
1086
|
toolUseId: nestedId,
|
|
1005
1087
|
toolName: name,
|
|
1006
1088
|
result: budgeted.output,
|
|
1007
|
-
...
|
|
1089
|
+
...this.resultPresentation(name, preparedInput, result, budgeted.truncated),
|
|
1090
|
+
...(result.facts !== undefined ? { facts: result.facts } : {}),
|
|
1008
1091
|
isError: !result.success,
|
|
1009
1092
|
durationMs: Date.now() - startedAt,
|
|
1010
1093
|
outputLength: budgeted.originalLength,
|
|
@@ -1024,25 +1107,30 @@ export class ToolExecutor {
|
|
|
1024
1107
|
});
|
|
1025
1108
|
return visibleResult;
|
|
1026
1109
|
}
|
|
1027
|
-
resultPresentation(name, input, result) {
|
|
1110
|
+
resultPresentation(name, input, result, savedOnly = false) {
|
|
1028
1111
|
try {
|
|
1029
1112
|
const view = this.config.tools.get(name)?.presentResult?.(input, result);
|
|
1030
1113
|
// A failed call carries one view only: the person's No on the tool's
|
|
1031
1114
|
// own screen, which a host draws as cancelled rather than failed and
|
|
1032
1115
|
// cannot tell apart from the result text alone.
|
|
1033
1116
|
if (!result.success) {
|
|
1034
|
-
|
|
1035
|
-
|
|
1117
|
+
if (!savedOnly && view?.kind === 'generic' && view.outcome === 'cancelled')
|
|
1118
|
+
return {
|
|
1036
1119
|
presentation: {
|
|
1037
1120
|
kind: 'generic',
|
|
1038
1121
|
label: view.label,
|
|
1039
1122
|
outcome: 'cancelled',
|
|
1040
1123
|
},
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1124
|
+
};
|
|
1125
|
+
const saved = savedPresentation(input, this.config.tools.get(name)?.presentCall?.(input), undefined);
|
|
1126
|
+
return saved ? { savedPresentation: saved } : {};
|
|
1127
|
+
}
|
|
1128
|
+
if (savedOnly || view?.kind !== 'diff') {
|
|
1129
|
+
// Journal-only: the live event keeps drawing the real result.
|
|
1130
|
+
const tool = this.config.tools.get(name);
|
|
1131
|
+
const saved = savedPresentation(input, tool?.presentCall?.(input), view);
|
|
1132
|
+
return saved ? { savedPresentation: saved } : {};
|
|
1043
1133
|
}
|
|
1044
|
-
if (view?.kind !== 'diff')
|
|
1045
|
-
return {};
|
|
1046
1134
|
const serialized = JSON.stringify(view);
|
|
1047
1135
|
if (serialized.length > (this.config.maxToolOutputChars ?? DEFAULT_MAX_TOOL_OUTPUT_CHARS))
|
|
1048
1136
|
return {};
|
|
@@ -1147,104 +1235,38 @@ export class ToolExecutor {
|
|
|
1147
1235
|
let toolName = preparedCall?.toolName ?? toolCall.function.name;
|
|
1148
1236
|
let input;
|
|
1149
1237
|
let prepared;
|
|
1238
|
+
let inputFailure;
|
|
1150
1239
|
if (preparedCall?.kind === 'ready' || preparedCall?.kind === 'legacy') {
|
|
1151
1240
|
input = preparedCall.input;
|
|
1152
1241
|
prepared = preparedCall.kind === 'ready' ? preparedCall.prepared : undefined;
|
|
1242
|
+
if (preparedCall.kind === 'legacy')
|
|
1243
|
+
inputFailure = preparedCall.inputFailure;
|
|
1153
1244
|
}
|
|
1154
1245
|
else {
|
|
1155
|
-
//
|
|
1156
|
-
//
|
|
1157
|
-
//
|
|
1158
|
-
|
|
1159
|
-
// unused. Offer it the partial buffer first.
|
|
1160
|
-
const truncationRepair = toolCall.metadata?.inputTruncated === true
|
|
1161
|
-
? await repairTruncatedCall(this.admissionHost(), toolCall, toolName)
|
|
1162
|
-
: null;
|
|
1163
|
-
if (toolCall.metadata?.inputTruncated === true && !truncationRepair) {
|
|
1164
|
-
const message = unreadableToolCallMessage(this.admissionHost(), toolCall, toolName);
|
|
1165
|
-
await this.emitEvent({
|
|
1166
|
-
type: 'tool_executing',
|
|
1167
|
-
turnId: this.config.turnId,
|
|
1168
|
-
toolUseId: toolCall.id,
|
|
1169
|
-
toolName,
|
|
1170
|
-
input: {},
|
|
1171
|
-
});
|
|
1172
|
-
await this.emitEvent({
|
|
1173
|
-
type: 'tool_completed',
|
|
1174
|
-
turnId: this.config.turnId,
|
|
1175
|
-
toolUseId: toolCall.id,
|
|
1176
|
-
toolName,
|
|
1177
|
-
result: message,
|
|
1178
|
-
isError: true,
|
|
1179
|
-
});
|
|
1180
|
-
return {
|
|
1181
|
-
toolCallId: toolCall.id,
|
|
1182
|
-
toolName,
|
|
1183
|
-
output: message,
|
|
1184
|
-
isError: true,
|
|
1185
|
-
};
|
|
1186
|
-
}
|
|
1187
|
-
// A malformed call used to cost a full model round trip to fix: the
|
|
1188
|
-
// error went back as a `tool_result`, the model re-read the whole
|
|
1189
|
-
// context and tried again. A host that can repair it locally turns
|
|
1190
|
-
// that into nothing. No-op when no repairer is configured.
|
|
1191
|
-
const resolved = await resolveCall(this.admissionHost(), truncationRepair
|
|
1192
|
-
? {
|
|
1193
|
-
...toolCall,
|
|
1194
|
-
function: {
|
|
1195
|
-
...toolCall.function,
|
|
1196
|
-
name: truncationRepair.toolName ?? toolName,
|
|
1197
|
-
arguments: truncationRepair.arguments,
|
|
1198
|
-
},
|
|
1199
|
-
metadata: {},
|
|
1200
|
-
}
|
|
1201
|
-
: toolCall);
|
|
1202
|
-
toolName = resolved.toolName;
|
|
1203
|
-
if (!resolved.ok) {
|
|
1204
|
-
// malformed JSON args used to return without ever
|
|
1205
|
-
// emitting tool_executing or tool_completed, leaving UI cards
|
|
1206
|
-
// orphaned in `streaming_input`. Emit the executing→completed
|
|
1207
|
-
// terminal pair so the card lifecycle closes.
|
|
1208
|
-
const message = resolved.message;
|
|
1209
|
-
await this.emitEvent({
|
|
1210
|
-
type: 'tool_executing',
|
|
1211
|
-
turnId: this.config.turnId,
|
|
1212
|
-
toolUseId: toolCall.id,
|
|
1213
|
-
toolName,
|
|
1214
|
-
input: {},
|
|
1215
|
-
});
|
|
1216
|
-
await this.emitEvent({
|
|
1217
|
-
type: 'tool_completed',
|
|
1218
|
-
turnId: this.config.turnId,
|
|
1219
|
-
toolUseId: toolCall.id,
|
|
1220
|
-
toolName,
|
|
1221
|
-
result: message,
|
|
1222
|
-
isError: true,
|
|
1223
|
-
});
|
|
1224
|
-
return {
|
|
1225
|
-
toolCallId: toolCall.id,
|
|
1226
|
-
toolName,
|
|
1227
|
-
output: message,
|
|
1228
|
-
isError: true,
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
input = resolved.input;
|
|
1232
|
-
let preOutcome;
|
|
1246
|
+
// The unreviewed executor path uses the same preparation as a
|
|
1247
|
+
// reviewed call. Parsing here and again in the registry would run
|
|
1248
|
+
// transforms twice and reject asynchronous schemas.
|
|
1249
|
+
let admitted;
|
|
1233
1250
|
try {
|
|
1234
|
-
|
|
1251
|
+
admitted = await prepareDirectCall(this.admissionHost(), toolCall);
|
|
1252
|
+
this.config.abortSignal.throwIfAborted();
|
|
1235
1253
|
}
|
|
1236
1254
|
catch (error) {
|
|
1237
1255
|
if (!this.config.abortSignal.aborted)
|
|
1238
1256
|
throw error;
|
|
1239
|
-
//
|
|
1240
|
-
//
|
|
1241
|
-
return this.recordCancelledBeforeExecution(toolCall.id, toolName,
|
|
1242
|
-
}
|
|
1243
|
-
if (preOutcome.kind === 'skip' || preOutcome.kind === 'error') {
|
|
1244
|
-
return this.recordSyntheticHookOutcome(toolCall.id, toolName, preOutcome.input, preOutcome);
|
|
1257
|
+
// Keep earlier settled siblings' receipts when a later
|
|
1258
|
+
// preparation is interrupted.
|
|
1259
|
+
return this.recordCancelledBeforeExecution(toolCall.id, toolName, {});
|
|
1245
1260
|
}
|
|
1246
|
-
|
|
1261
|
+
if (admitted.kind === 'synthetic')
|
|
1262
|
+
return this.recordSyntheticPreparation(admitted);
|
|
1263
|
+
toolName = admitted.toolName;
|
|
1264
|
+
input = admitted.input;
|
|
1265
|
+
prepared = admitted.kind === 'ready' ? admitted.prepared : undefined;
|
|
1266
|
+
if (admitted.kind === 'legacy')
|
|
1267
|
+
inputFailure = admitted.inputFailure;
|
|
1247
1268
|
}
|
|
1269
|
+
const executedDefinition = this.config.tools.get(toolName);
|
|
1248
1270
|
const activity = this.activityStore.create({
|
|
1249
1271
|
type: 'tool_call',
|
|
1250
1272
|
description: toolName,
|
|
@@ -1440,6 +1462,27 @@ export class ToolExecutor {
|
|
|
1440
1462
|
}
|
|
1441
1463
|
const maxToolOutputChars = this.config.maxToolOutputChars ?? DEFAULT_MAX_TOOL_OUTPUT_CHARS;
|
|
1442
1464
|
const sourceOutput = output;
|
|
1465
|
+
// This owner-bound channel follows the selected receipt after both result
|
|
1466
|
+
// screening and post-tool replacement. ToolResult.data and raw input can
|
|
1467
|
+
// still carry pre-redaction values and must never be promoted here.
|
|
1468
|
+
let structuredResultJson;
|
|
1469
|
+
if (prepared &&
|
|
1470
|
+
executedDefinition !== undefined &&
|
|
1471
|
+
executedDefinition === this.config.durableStructuredOutputTool &&
|
|
1472
|
+
toolName === 'structured_output' &&
|
|
1473
|
+
toolCall.function.name === 'structured_output' &&
|
|
1474
|
+
result.success &&
|
|
1475
|
+
!postOverride?.isError &&
|
|
1476
|
+
!this.config.abortSignal.aborted) {
|
|
1477
|
+
try {
|
|
1478
|
+
parseStructuredResultJson(sourceOutput);
|
|
1479
|
+
structuredResultJson = sourceOutput;
|
|
1480
|
+
}
|
|
1481
|
+
catch {
|
|
1482
|
+
// Keep the completion receipt: malformed host output fails at the
|
|
1483
|
+
// normal candidate-integrity boundary, never as a schema correction.
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1443
1486
|
// Compression is opportunistic and shell-only; the budget is the
|
|
1444
1487
|
// hard bound that applies to every final tool result, including a
|
|
1445
1488
|
// post-tool hook's replacement and the rich-content omission notice.
|
|
@@ -1479,6 +1522,9 @@ export class ToolExecutor {
|
|
|
1479
1522
|
// unusable: the model was told a successful call had gone wrong, and
|
|
1480
1523
|
// routed around it.
|
|
1481
1524
|
const effectiveIsError = !result.success || (postOverride?.isError ?? false);
|
|
1525
|
+
const visibleInputFailure = !result.success && !postOverride && !this.config.abortSignal.aborted
|
|
1526
|
+
? inputFailure
|
|
1527
|
+
: undefined;
|
|
1482
1528
|
if (this.workingStateManager) {
|
|
1483
1529
|
extractFromToolResult(this.workingStateManager, toolName, output, effectiveIsError);
|
|
1484
1530
|
for (const pin of this.config.abortSignal.aborted ? [] : (result.workingState ?? [])) {
|
|
@@ -1534,16 +1580,23 @@ export class ToolExecutor {
|
|
|
1534
1580
|
// call it has already removed. Detached work reporting after a timeout is
|
|
1535
1581
|
// ignored because close() also revokes the publisher.
|
|
1536
1582
|
await settleProgress();
|
|
1583
|
+
if (this.config.abortSignal.aborted)
|
|
1584
|
+
structuredResultJson = undefined;
|
|
1537
1585
|
await this.emitEvent({
|
|
1538
1586
|
type: 'tool_completed',
|
|
1539
1587
|
turnId: this.config.turnId,
|
|
1540
1588
|
toolUseId: toolCall.id,
|
|
1541
1589
|
toolName,
|
|
1542
1590
|
result: output,
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1591
|
+
// The result view only describes an output the host will show as is; the
|
|
1592
|
+
// saved label never depended on the output, so it is kept regardless.
|
|
1593
|
+
...this.resultPresentation(toolName, input, result, Boolean(postOverride) || budgeted.truncated || rawOutput !== output),
|
|
1594
|
+
// Typed fields for the person's view. A replaced output is a redaction
|
|
1595
|
+
// the host chose, and a structured copy of the original would undo it.
|
|
1596
|
+
...(result.facts !== undefined && !postOverride ? { facts: result.facts } : {}),
|
|
1546
1597
|
isError: effectiveIsError,
|
|
1598
|
+
...(visibleInputFailure ? { inputFailure: visibleInputFailure } : {}),
|
|
1599
|
+
...(structuredResultJson !== undefined ? { structuredResultJson } : {}),
|
|
1547
1600
|
durationMs,
|
|
1548
1601
|
// Pre-truncation size, so a host can show "returned 2.1 MB" even
|
|
1549
1602
|
// though the model only ever saw a preview.
|
|
@@ -1560,11 +1613,16 @@ export class ToolExecutor {
|
|
|
1560
1613
|
input,
|
|
1561
1614
|
result,
|
|
1562
1615
|
});
|
|
1616
|
+
if (prepared && executedDefinition && !effectiveIsError && !this.config.abortSignal.aborted) {
|
|
1617
|
+
this.recordExecutedObservation(toolCall, toolName, executedDefinition, input, modelContent ?? output);
|
|
1618
|
+
}
|
|
1563
1619
|
return {
|
|
1564
1620
|
toolCallId: toolCall.id,
|
|
1565
1621
|
toolName,
|
|
1566
1622
|
output,
|
|
1567
1623
|
isError: effectiveIsError,
|
|
1624
|
+
...(visibleInputFailure ? { inputFailure: visibleInputFailure } : {}),
|
|
1625
|
+
...(structuredResultJson !== undefined ? { structuredResultJson } : {}),
|
|
1568
1626
|
// Rich content follows the override's own decision.
|
|
1569
1627
|
//
|
|
1570
1628
|
// An ERROR override drops it: the payload is no longer the tool's,
|
|
@@ -1765,7 +1823,8 @@ export class ToolExecutor {
|
|
|
1765
1823
|
};
|
|
1766
1824
|
}
|
|
1767
1825
|
async prepareNestedCall(toolName, input, signal) {
|
|
1768
|
-
|
|
1826
|
+
signal.throwIfAborted();
|
|
1827
|
+
const prepare = this.config.tools.prepareExecutionAsync ?? this.config.tools.prepareExecution;
|
|
1769
1828
|
const executePrepared = this.config.tools.executePrepared;
|
|
1770
1829
|
if (typeof prepare !== 'function' || typeof executePrepared !== 'function') {
|
|
1771
1830
|
if (this.config.authorizationGate) {
|
|
@@ -1783,15 +1842,18 @@ export class ToolExecutor {
|
|
|
1783
1842
|
input: preOutcome.input,
|
|
1784
1843
|
message: preOutcome.output,
|
|
1785
1844
|
isError: preOutcome.kind === 'error',
|
|
1845
|
+
...(preOutcome.kind === 'skip' ? { skipped: true } : {}),
|
|
1786
1846
|
};
|
|
1787
1847
|
}
|
|
1788
1848
|
return { kind: 'legacy', input: preOutcome.input };
|
|
1789
1849
|
}
|
|
1790
1850
|
let preparation;
|
|
1791
1851
|
try {
|
|
1792
|
-
preparation = prepare.call(this.config.tools, toolName, input);
|
|
1852
|
+
preparation = await prepare.call(this.config.tools, toolName, input, signal);
|
|
1853
|
+
signal.throwIfAborted();
|
|
1793
1854
|
}
|
|
1794
1855
|
catch (err) {
|
|
1856
|
+
signal.throwIfAborted();
|
|
1795
1857
|
// A name the registry does not hold is answered with what this step
|
|
1796
1858
|
// can call, as a model's own call is; the registry's "Not found"
|
|
1797
1859
|
// lists everything it holds.
|
|
@@ -1820,6 +1882,7 @@ export class ToolExecutor {
|
|
|
1820
1882
|
input: preOutcome.input,
|
|
1821
1883
|
message: preOutcome.output,
|
|
1822
1884
|
isError: preOutcome.kind === 'error',
|
|
1885
|
+
...(preOutcome.kind === 'skip' ? { skipped: true } : {}),
|
|
1823
1886
|
};
|
|
1824
1887
|
}
|
|
1825
1888
|
if (!preOutcome.modified) {
|
|
@@ -1829,7 +1892,8 @@ export class ToolExecutor {
|
|
|
1829
1892
|
prepared: preparation.prepared,
|
|
1830
1893
|
};
|
|
1831
1894
|
}
|
|
1832
|
-
const modified = prepare.call(this.config.tools, toolName, preOutcome.input);
|
|
1895
|
+
const modified = await prepare.call(this.config.tools, toolName, preOutcome.input, signal);
|
|
1896
|
+
signal.throwIfAborted();
|
|
1833
1897
|
if (!modified.success) {
|
|
1834
1898
|
return {
|
|
1835
1899
|
kind: 'synthetic',
|
|
@@ -1949,7 +2013,7 @@ export class ToolExecutor {
|
|
|
1949
2013
|
* execution so UI cards reach a terminal state instead of hanging in
|
|
1950
2014
|
* `executing`, and records a failed activity for the trace.
|
|
1951
2015
|
*/
|
|
1952
|
-
async recordDenial(toolCall, reason, preparedCall) {
|
|
2016
|
+
async recordDenial(toolCall, reason, preparedCall, declined) {
|
|
1953
2017
|
const toolName = preparedCall?.toolName ?? toolCall.function.name;
|
|
1954
2018
|
let input = preparedCall?.input ?? {};
|
|
1955
2019
|
if (!preparedCall) {
|
|
@@ -1991,10 +2055,51 @@ export class ToolExecutor {
|
|
|
1991
2055
|
toolUseId: toolCall.id,
|
|
1992
2056
|
toolName,
|
|
1993
2057
|
result: output,
|
|
2058
|
+
// Recorded only for a person's No. Every other refusal keeps the
|
|
2059
|
+
// shape it always had: no presentation at all.
|
|
2060
|
+
...(declined ? { presentation: this.declinedPresentation(toolName, input, declined) } : {}),
|
|
2061
|
+
// A refusal by policy says what kind it was; the person's own No is
|
|
2062
|
+
// already carried by the presentation above.
|
|
2063
|
+
...(declined ? {} : { facts: refusalFacts(toolName, input) }),
|
|
1994
2064
|
isError: true,
|
|
1995
2065
|
});
|
|
1996
2066
|
return { toolCallId: toolCall.id, toolName, output, isError: true };
|
|
1997
2067
|
}
|
|
2068
|
+
/**
|
|
2069
|
+
* What a host replays for a call the person declined. The label names the
|
|
2070
|
+
* target of the call (a path, a command) and nothing is inferred from the
|
|
2071
|
+
* refusal text: the note comes from the review answer.
|
|
2072
|
+
*/
|
|
2073
|
+
declinedPresentation(toolName, input, declined) {
|
|
2074
|
+
let target;
|
|
2075
|
+
try {
|
|
2076
|
+
const view = this.config.tools.get(toolName)?.presentCall?.(input);
|
|
2077
|
+
const text = view?.kind === 'generic'
|
|
2078
|
+
? view.label
|
|
2079
|
+
: view?.kind === 'diff'
|
|
2080
|
+
? view.path || view.label
|
|
2081
|
+
: view?.kind === 'terminal'
|
|
2082
|
+
? view.command
|
|
2083
|
+
: undefined;
|
|
2084
|
+
target = text
|
|
2085
|
+
?.split(/\r?\n/)
|
|
2086
|
+
.find((line) => line.trim())
|
|
2087
|
+
?.trim()
|
|
2088
|
+
.slice(0, 200);
|
|
2089
|
+
}
|
|
2090
|
+
catch {
|
|
2091
|
+
// A presentation hook must not turn a refusal into a failure.
|
|
2092
|
+
}
|
|
2093
|
+
// Cut by code point so a surrogate pair is never split.
|
|
2094
|
+
const note = Array.from(declined.note?.trim() ?? '')
|
|
2095
|
+
.slice(0, DECLINED_NOTE_MAX_CHARS)
|
|
2096
|
+
.join('');
|
|
2097
|
+
return {
|
|
2098
|
+
kind: 'generic',
|
|
2099
|
+
label: target || toolName,
|
|
2100
|
+
declined: note ? { note } : {},
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
1998
2103
|
recordCancelledBeforeExecution(toolCallId, toolName, input) {
|
|
1999
2104
|
const reason = abortReasonText(this.config.abortSignal.reason);
|
|
2000
2105
|
return this.recordSyntheticHookOutcome(toolCallId, toolName, input, {
|
|
@@ -2033,18 +2138,26 @@ export class ToolExecutor {
|
|
|
2033
2138
|
toolName,
|
|
2034
2139
|
result: outcome.output,
|
|
2035
2140
|
isError: outcome.kind === 'error',
|
|
2141
|
+
...(outcome.facts ? { facts: outcome.facts } : {}),
|
|
2142
|
+
...(outcome.inputFailure ? { inputFailure: outcome.inputFailure } : {}),
|
|
2143
|
+
...(outcome.skipped ? { skipped: true } : {}),
|
|
2036
2144
|
});
|
|
2037
2145
|
return {
|
|
2038
2146
|
toolCallId,
|
|
2039
2147
|
toolName,
|
|
2040
2148
|
output: outcome.output,
|
|
2041
2149
|
isError: outcome.kind === 'error',
|
|
2150
|
+
...(outcome.inputFailure ? { inputFailure: outcome.inputFailure } : {}),
|
|
2151
|
+
...(outcome.skipped ? { skipped: true } : {}),
|
|
2042
2152
|
};
|
|
2043
2153
|
}
|
|
2044
2154
|
recordSyntheticPreparation(call) {
|
|
2045
2155
|
return this.recordSyntheticHookOutcome(call.toolCall.id, call.toolName, call.input, {
|
|
2046
2156
|
kind: call.isError ? 'error' : 'skip',
|
|
2047
2157
|
output: call.message,
|
|
2158
|
+
...(call.facts ? { facts: call.facts } : {}),
|
|
2159
|
+
...(call.inputFailure ? { inputFailure: call.inputFailure } : {}),
|
|
2160
|
+
...(call.skipped ? { skipped: true } : {}),
|
|
2048
2161
|
});
|
|
2049
2162
|
}
|
|
2050
2163
|
/**
|