@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
package/src/toolsets/manager.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ToolResultHalted, screenToolResult } from '../registry/tool/screen.js'
|
|
|
8
8
|
import { GENAI, NAMZU, toolSpanName } from '../telemetry/attributes.js'
|
|
9
9
|
import { recordToolCall } from '../telemetry/metrics.js'
|
|
10
10
|
import { getTracer } from '../telemetry/runtime-accessors.js'
|
|
11
|
+
import { failureFactsFromError } from '../tools/failure-facts.js'
|
|
11
12
|
import { isTrustedReadOnly } from '../tools/trusted-read-only.js'
|
|
12
13
|
import { wrapUntrusted } from '../tools/untrusted-envelope.js'
|
|
13
14
|
import type { ToolResultGuardrailSpec } from '../types/guardrail/index.js'
|
|
@@ -25,6 +26,8 @@ import type {
|
|
|
25
26
|
ToolTierConfig,
|
|
26
27
|
ToolsView,
|
|
27
28
|
} from '../types/tool/index.js'
|
|
29
|
+
import type { ToolFacts } from '../types/tool/presentation.js'
|
|
30
|
+
import { awaitWithAbort } from '../utils/await-with-abort.js'
|
|
28
31
|
import { toErrorMessage } from '../utils/error.js'
|
|
29
32
|
import { cloneJsonValue as clonePreparedInput } from '../utils/json-snapshot.js'
|
|
30
33
|
import { SCOPE_ATTRIBUTE } from '../utils/log/types.js'
|
|
@@ -670,10 +673,55 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
670
673
|
prepareExecution(toolName: string, rawInput: unknown): ToolPreparationResult {
|
|
671
674
|
const tool = this.getOrThrow(toolName)
|
|
672
675
|
const parseResult = tool.inputSchema.safeParse(rawInput)
|
|
676
|
+
return this.finalizePreparation(tool, rawInput, parseResult)
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Decode an input once, including asynchronous schema refinements and transforms.
|
|
681
|
+
* JSON-compatible raw values are detached synchronously before validation can
|
|
682
|
+
* yield. Non-JSON host values retain the schema's input semantics; callers must
|
|
683
|
+
* not mutate them while preparation is pending. The prepared output must still
|
|
684
|
+
* be immutable JSON, as with `prepareExecution`.
|
|
685
|
+
* Cancellation stops waiting and prevents publication, but cannot stop schema
|
|
686
|
+
* work that does not cooperate with cancellation.
|
|
687
|
+
*/
|
|
688
|
+
async prepareExecutionAsync(
|
|
689
|
+
toolName: string,
|
|
690
|
+
rawInput: unknown,
|
|
691
|
+
signal?: AbortSignal,
|
|
692
|
+
): Promise<ToolPreparationResult> {
|
|
693
|
+
signal?.throwIfAborted()
|
|
694
|
+
const tool = this.getOrThrow(toolName)
|
|
695
|
+
let validationInput = rawInput
|
|
696
|
+
try {
|
|
697
|
+
validationInput = clonePreparedInput(rawInput, false, '$', true)
|
|
698
|
+
} catch {
|
|
699
|
+
// A schema may normalize a Date or another host value into JSON.
|
|
700
|
+
// Raw input safety must not narrow that existing normalization domain.
|
|
701
|
+
}
|
|
702
|
+
signal?.throwIfAborted()
|
|
703
|
+
const asyncParse = tool.inputSchema.safeParseAsync
|
|
704
|
+
const operation =
|
|
705
|
+
typeof asyncParse === 'function'
|
|
706
|
+
? asyncParse.call(tool.inputSchema, validationInput)
|
|
707
|
+
: Promise.resolve(tool.inputSchema.safeParse(validationInput))
|
|
708
|
+
const parseResult = await awaitWithAbort(operation, signal)
|
|
709
|
+
signal?.throwIfAborted()
|
|
710
|
+
return this.finalizePreparation(tool, validationInput, parseResult, signal)
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
private finalizePreparation(
|
|
714
|
+
tool: ToolDefinition,
|
|
715
|
+
rawInput: unknown,
|
|
716
|
+
parseResult: ReturnType<ToolDefinition['inputSchema']['safeParse']>,
|
|
717
|
+
signal?: AbortSignal,
|
|
718
|
+
): ToolPreparationResult {
|
|
719
|
+
const toolName = tool.name
|
|
673
720
|
if (!parseResult.success) {
|
|
674
721
|
return {
|
|
675
722
|
success: false,
|
|
676
723
|
result: this.validationFailure(tool, rawInput, parseResult.error),
|
|
724
|
+
inputFailure: 'schema_validation',
|
|
677
725
|
}
|
|
678
726
|
}
|
|
679
727
|
|
|
@@ -683,6 +731,7 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
683
731
|
retainedInput = clonePreparedInput(parseResult.data, false)
|
|
684
732
|
reviewInput = clonePreparedInput(retainedInput, true)
|
|
685
733
|
} catch (err) {
|
|
734
|
+
signal?.throwIfAborted()
|
|
686
735
|
const message = `Tool "${toolName}" produced an input that cannot be safely prepared for review and execution: ${toErrorMessage(err)}`
|
|
687
736
|
this.log.error('Prepared tool input could not be detached for review and execution', {
|
|
688
737
|
'namzu.tool.name': toolName,
|
|
@@ -694,6 +743,7 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
694
743
|
}
|
|
695
744
|
}
|
|
696
745
|
|
|
746
|
+
signal?.throwIfAborted()
|
|
697
747
|
const prepared = Object.freeze({ toolName, input: reviewInput })
|
|
698
748
|
this.preparations.set(prepared, { tool, input: retainedInput })
|
|
699
749
|
return { success: true, prepared }
|
|
@@ -728,7 +778,8 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
728
778
|
): Promise<ToolExecutionResult> {
|
|
729
779
|
let preparation: ToolPreparationResult
|
|
730
780
|
try {
|
|
731
|
-
preparation = this.
|
|
781
|
+
preparation = await this.prepareExecutionAsync(toolName, rawInput, context.abortSignal)
|
|
782
|
+
context.abortSignal?.throwIfAborted()
|
|
732
783
|
} catch (err) {
|
|
733
784
|
return this.rejectPreparationWithClosedSpan(toolName, context, err)
|
|
734
785
|
}
|
|
@@ -921,6 +972,7 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
921
972
|
success: false,
|
|
922
973
|
output: '',
|
|
923
974
|
error: `Tool "${toolName}" execution failed: ${errorMessage}`,
|
|
975
|
+
...failureFactsField(err),
|
|
924
976
|
}
|
|
925
977
|
}
|
|
926
978
|
} finally {
|
|
@@ -1067,3 +1119,8 @@ function describeRequiredInput(schema: { _def?: unknown }): string {
|
|
|
1067
1119
|
return 'Could not introspect required parameters.'
|
|
1068
1120
|
}
|
|
1069
1121
|
}
|
|
1122
|
+
|
|
1123
|
+
function failureFactsField(err: unknown): { facts?: ToolFacts } {
|
|
1124
|
+
const facts = failureFactsFromError(err)
|
|
1125
|
+
return facts ? { facts } : {}
|
|
1126
|
+
}
|
package/src/types/acp/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { ReviewMode } from '../../runtime/query/review-policy.js'
|
|
1
2
|
import type { SerializableHostCommand } from '../command/index.js'
|
|
2
|
-
import type {
|
|
3
|
+
import type { AssistantTextPart, DocumentAttachment, ImageAttachment } from '../message/index.js'
|
|
4
|
+
import type { ReasoningEffort } from '../provider/chat.js'
|
|
5
|
+
import type { MessageStopReason } from '../session/stop-reason.js'
|
|
6
|
+
import type { TaskStatus } from '../task/index.js'
|
|
7
|
+
import type { ToolCallView, ToolFacts } from '../tool/presentation.js'
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* The wire shapes an editor or an orchestrator sees.
|
|
@@ -34,6 +39,12 @@ export interface AcpInitializeParams extends AcpClientCapabilities {
|
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
export interface AcpInitializeResult {
|
|
42
|
+
/** True only when the host gateway opts into inline user attachment delivery. */
|
|
43
|
+
readonly promptAttachments?: boolean
|
|
44
|
+
/** True only when this host applies captured effort and review settings per prompt. */
|
|
45
|
+
readonly promptOptions?: boolean
|
|
46
|
+
/** Optional, explicitly installed Namzu host methods; core ACP peers can ignore them. */
|
|
47
|
+
readonly extensions?: readonly string[]
|
|
37
48
|
readonly protocolVersion: number
|
|
38
49
|
readonly agentInfo: { readonly name: string; readonly version: string }
|
|
39
50
|
/**
|
|
@@ -71,6 +82,25 @@ export interface AcpSessionLoadParams {
|
|
|
71
82
|
readonly cwd?: string
|
|
72
83
|
}
|
|
73
84
|
|
|
85
|
+
/**
|
|
86
|
+
* The file change a pending `edit` or `write` call would make, computed by the
|
|
87
|
+
* agent with the tool's own apply code against the file as it is now.
|
|
88
|
+
*
|
|
89
|
+
* Optional on the wire: an older client ignores it, and an agent that cannot
|
|
90
|
+
* establish it (a binary or oversized file, a path outside the turn's roots, a
|
|
91
|
+
* call the tool would refuse) simply omits it.
|
|
92
|
+
*/
|
|
93
|
+
export interface AcpFileChangePreview {
|
|
94
|
+
/** The absolute path the tool resolves the call's `path` to. */
|
|
95
|
+
readonly path: string
|
|
96
|
+
/** The current body, or `null` when the call would create the file. */
|
|
97
|
+
readonly before: string | null
|
|
98
|
+
/** The body after the call. */
|
|
99
|
+
readonly after: string
|
|
100
|
+
/** True when `before` and `after` were cut to a bounded size. */
|
|
101
|
+
readonly truncated?: boolean
|
|
102
|
+
}
|
|
103
|
+
|
|
74
104
|
/** What the agent asks the client before running a tool batch. */
|
|
75
105
|
export interface AcpRequestPermissionParams {
|
|
76
106
|
readonly sessionId: string
|
|
@@ -79,6 +109,8 @@ export interface AcpRequestPermissionParams {
|
|
|
79
109
|
readonly name: string
|
|
80
110
|
readonly input: unknown
|
|
81
111
|
readonly isDestructive: boolean
|
|
112
|
+
/** For `edit` and `write` calls, when the agent could compute it. */
|
|
113
|
+
readonly preview?: AcpFileChangePreview
|
|
82
114
|
}[]
|
|
83
115
|
}
|
|
84
116
|
|
|
@@ -93,6 +125,14 @@ export interface AcpRequestPermissionResult {
|
|
|
93
125
|
readonly outcome: 'approve' | 'approve_all' | 'reject'
|
|
94
126
|
/** Why, for a rejection. Reaches the MODEL, so it is worth writing. */
|
|
95
127
|
readonly feedback?: string
|
|
128
|
+
/**
|
|
129
|
+
* For a rejection: set by a client that is reporting a person's No, so
|
|
130
|
+
* the session record can say the call was declined by them rather than
|
|
131
|
+
* refused by policy. `note` is what they said, without any wrapper the
|
|
132
|
+
* client put around it in `feedback`, which is for the model. A bare
|
|
133
|
+
* `reject` without this is recorded as it always was.
|
|
134
|
+
*/
|
|
135
|
+
readonly declined?: { readonly note?: string }
|
|
96
136
|
}
|
|
97
137
|
|
|
98
138
|
export interface AcpFsReadParams {
|
|
@@ -110,10 +150,17 @@ export interface AcpFsWriteParams {
|
|
|
110
150
|
readonly content: string
|
|
111
151
|
}
|
|
112
152
|
|
|
153
|
+
export interface AcpPromptOptions {
|
|
154
|
+
readonly effort?: ReasoningEffort
|
|
155
|
+
readonly permissionMode?: ReviewMode
|
|
156
|
+
}
|
|
113
157
|
export interface AcpSessionPromptParams {
|
|
114
158
|
readonly sessionId: string
|
|
115
159
|
/** The operator's message, already plain text. */
|
|
116
160
|
readonly prompt: string
|
|
161
|
+
/** Inline user-owned bytes; store references are not admitted across this boundary. */
|
|
162
|
+
readonly attachments?: readonly (ImageAttachment | DocumentAttachment)[]
|
|
163
|
+
readonly options?: AcpPromptOptions
|
|
117
164
|
}
|
|
118
165
|
|
|
119
166
|
/** Why a prompt stopped, in the peer's vocabulary. */
|
|
@@ -121,6 +168,8 @@ export type AcpStopReason = 'end_turn' | 'cancelled' | 'refused' | 'error' | 'ma
|
|
|
121
168
|
|
|
122
169
|
export interface AcpSessionPromptResult {
|
|
123
170
|
readonly stopReason: AcpStopReason
|
|
171
|
+
/** Exact runtime reason, when available; a cancelled preparation also names cancellation. */
|
|
172
|
+
readonly reason?: string
|
|
124
173
|
}
|
|
125
174
|
|
|
126
175
|
export interface AcpSessionCancelParams {
|
|
@@ -136,9 +185,45 @@ export interface AcpSessionCancelParams {
|
|
|
136
185
|
*/
|
|
137
186
|
export type AcpSessionUpdate =
|
|
138
187
|
/** A fragment of the assistant's answer. */
|
|
139
|
-
| {
|
|
188
|
+
| {
|
|
189
|
+
readonly kind: 'agent_message_chunk'
|
|
190
|
+
readonly text: string
|
|
191
|
+
readonly messageId?: string
|
|
192
|
+
readonly turnId?: string
|
|
193
|
+
readonly iteration?: number
|
|
194
|
+
/** Public provider phase only; absent means the provider did not name one. */
|
|
195
|
+
readonly phase?: AssistantTextPart['phase']
|
|
196
|
+
readonly textPart?: Omit<AssistantTextPart, 'text'>
|
|
197
|
+
}
|
|
198
|
+
/** A completed message; content selects the provider's explicit final-answer parts. */
|
|
199
|
+
| {
|
|
200
|
+
readonly kind: 'agent_message'
|
|
201
|
+
readonly status: 'completed'
|
|
202
|
+
readonly messageId?: string
|
|
203
|
+
readonly turnId?: string
|
|
204
|
+
readonly iteration?: number
|
|
205
|
+
readonly content?: string
|
|
206
|
+
readonly textParts?: readonly AssistantTextPart[]
|
|
207
|
+
readonly stopReason: MessageStopReason
|
|
208
|
+
}
|
|
140
209
|
/** A fragment of the assistant's reasoning, when the model emits any. */
|
|
141
|
-
| {
|
|
210
|
+
| {
|
|
211
|
+
readonly kind: 'agent_thought_chunk'
|
|
212
|
+
readonly text: string
|
|
213
|
+
readonly messageId?: string
|
|
214
|
+
readonly turnId?: string
|
|
215
|
+
readonly iteration?: number
|
|
216
|
+
readonly blockId?: string
|
|
217
|
+
}
|
|
218
|
+
/** Reasoning boundaries also represent redacted blocks, without exposing their payload. */
|
|
219
|
+
| {
|
|
220
|
+
readonly kind: 'agent_thought'
|
|
221
|
+
readonly status: 'pending' | 'completed'
|
|
222
|
+
readonly messageId?: string
|
|
223
|
+
readonly turnId?: string
|
|
224
|
+
readonly iteration?: number
|
|
225
|
+
readonly blockId?: string
|
|
226
|
+
}
|
|
142
227
|
/**
|
|
143
228
|
* A tool call, rendered by the TOOL rather than by this bridge.
|
|
144
229
|
*
|
|
@@ -153,11 +238,72 @@ export type AcpSessionUpdate =
|
|
|
153
238
|
readonly title: string
|
|
154
239
|
readonly status: 'pending' | 'completed' | 'failed'
|
|
155
240
|
readonly view: ToolCallView
|
|
241
|
+
/**
|
|
242
|
+
* What a finished call did, as typed fields (`ToolResult.facts`): the
|
|
243
|
+
* exit code and streams of a command, the path of a read. A host builds
|
|
244
|
+
* the person's view from these and not from the text in `view`.
|
|
245
|
+
*/
|
|
246
|
+
readonly facts?: ToolFacts
|
|
247
|
+
/** Runtime-measured execution duration, present on completed calls when known. */
|
|
248
|
+
readonly durationMs?: number
|
|
249
|
+
/** Live progress for this call; preserve its prior presentation while updating. */
|
|
250
|
+
readonly progress?: {
|
|
251
|
+
readonly message: string
|
|
252
|
+
readonly fraction?: number
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* A model call failed transiently and will be tried again after `delayMs`.
|
|
257
|
+
* Lets a client say "waiting, retrying in N seconds" instead of a silent spinner.
|
|
258
|
+
* Carries no provider body, header or credential.
|
|
259
|
+
*/
|
|
260
|
+
| {
|
|
261
|
+
readonly kind: 'provider_retry'
|
|
262
|
+
/** 1-based attempt that just failed. */
|
|
263
|
+
readonly attempt: number
|
|
264
|
+
readonly maxRetries: number
|
|
265
|
+
readonly delayMs: number
|
|
266
|
+
/** The HTTP status of the failed attempt, when there was one. */
|
|
267
|
+
readonly status?: number
|
|
268
|
+
/** The provider asked for this delay itself (for example `Retry-After`). */
|
|
269
|
+
readonly serverDirected: boolean
|
|
270
|
+
readonly turnId?: string
|
|
156
271
|
}
|
|
157
272
|
/** The turn is over. Carries the same reason the prompt result will. */
|
|
158
|
-
| {
|
|
273
|
+
| {
|
|
274
|
+
readonly kind: 'turn_ended'
|
|
275
|
+
readonly stopReason: AcpStopReason
|
|
276
|
+
readonly error?: string
|
|
277
|
+
readonly turnId?: string
|
|
278
|
+
/** The settled answer's actual message identity, when the runtime recorded one. */
|
|
279
|
+
readonly messageId?: string
|
|
280
|
+
/** Exact runtime reason; for example, paused remains distinct from cancelled. */
|
|
281
|
+
readonly reason?: string
|
|
282
|
+
/** Authoritative settled answer. An empty string deliberately clears rejected output. */
|
|
283
|
+
readonly result?: string
|
|
284
|
+
}
|
|
159
285
|
|
|
160
286
|
export interface AcpSessionUpdateNotification {
|
|
161
287
|
readonly sessionId: string
|
|
162
288
|
readonly update: AcpSessionUpdate
|
|
163
289
|
}
|
|
290
|
+
|
|
291
|
+
/** A full replacement row from the existing session planning-task store. */
|
|
292
|
+
export interface AcpTask {
|
|
293
|
+
readonly taskId: string
|
|
294
|
+
readonly subject: string
|
|
295
|
+
readonly status: TaskStatus
|
|
296
|
+
/** An explicit empty list clears prior dependencies. */
|
|
297
|
+
readonly blockedBy: readonly string[]
|
|
298
|
+
/** Absence clears any previously displayed owner. */
|
|
299
|
+
readonly owner?: string
|
|
300
|
+
/** What the task reads as while it is being worked on, such as "Running the tests". */
|
|
301
|
+
readonly activeForm?: string
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Optional Namzu planning notification; distinct from delegated worker state. */
|
|
305
|
+
export interface AcpTaskUpdate {
|
|
306
|
+
readonly sessionId: string
|
|
307
|
+
readonly task: AcpTask
|
|
308
|
+
readonly deleted?: true
|
|
309
|
+
}
|
package/src/types/agent/base.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { CostInfo, TokenUsage } from '../common/index.js'
|
|
|
8
8
|
import type { ResumeHandler } from '../hitl/index.js'
|
|
9
9
|
import type { SessionId, TenantId, TurnId } from '../ids/index.js'
|
|
10
10
|
import type { InvocationState } from '../invocation/index.js'
|
|
11
|
+
import type { DurableInboundSource } from '../message/inbound-delivery.js'
|
|
11
12
|
import type { Message } from '../message/index.js'
|
|
12
13
|
import type { PermissionMode } from '../permission/index.js'
|
|
13
14
|
import type { ProjectId, TopicId } from '../session/ids.js'
|
|
@@ -111,6 +112,8 @@ export interface BaseAgentConfig {
|
|
|
111
112
|
* until the turn ended.
|
|
112
113
|
*/
|
|
113
114
|
inboundMessages?: () => import('../message/index.js').Message[]
|
|
115
|
+
/** Requires an explicit sessionLog; acknowledgement precedes inference. */
|
|
116
|
+
durableInbound?: DurableInboundSource
|
|
114
117
|
|
|
115
118
|
/** Live project policy, flushed independently of human continuation text. */
|
|
116
119
|
projectInstructionContext?: ProjectInstructionContext
|
|
@@ -25,33 +25,18 @@ export interface AgentManagerContract {
|
|
|
25
25
|
cancelAll(parentSessionId: SessionId, cause?: CancelCause): void
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Queue
|
|
28
|
+
* Queue guidance for a nonterminal task. Acceptance is not delivery.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* that
|
|
34
|
-
*
|
|
35
|
-
* only {@link drainMessages} empties.
|
|
36
|
-
*
|
|
37
|
-
* Kept, and documented rather than deleted, because `drainMessages` is
|
|
38
|
-
* the only way a host can pick these up at all — removing it would take
|
|
39
|
-
* away the escape hatch and leave the trap.
|
|
40
|
-
*
|
|
41
|
-
* **For mid-run guidance, use `SteeringChannel` instead.** That is the
|
|
42
|
-
* delivery handshake this queue was missing: text queued on it is
|
|
43
|
-
* appended to the running batch's last `tool_result`, which is the only
|
|
44
|
-
* slot a provider accepts mid-batch, and the loop drains it. Pass one as
|
|
45
|
-
* `steering` on `drainQuery` params or on `SupervisorAgentConfig`.
|
|
46
|
-
*
|
|
47
|
-
* Two other routes also work: reject/modify feedback rides inside a tool
|
|
48
|
-
* result, and `prepareStep`'s `system` string is appended to the next
|
|
49
|
-
* model call from a hook that sees live history.
|
|
30
|
+
* The manager supplies `AgentConfig.inboundMessages`, which query-backed
|
|
31
|
+
* agents drain at provider-valid request boundaries, including completion.
|
|
32
|
+
* It does not interrupt an in-flight tool or model request. Custom agents
|
|
33
|
+
* must consume that callback; an agent that ignores it will not receive mail.
|
|
34
|
+
* Terminal tasks reject new input and cannot be restarted by this operation.
|
|
50
35
|
*/
|
|
51
36
|
continueTask(taskId: TaskId, message: string): Promise<void>
|
|
52
|
-
/**
|
|
37
|
+
/** Queue a structured message under the same acceptance contract. */
|
|
53
38
|
queueMessage(taskId: TaskId, message: Message): void
|
|
54
|
-
/**
|
|
39
|
+
/** Destructive drain used by the manager's injected inbound callback. */
|
|
55
40
|
drainMessages(taskId: TaskId): Message[]
|
|
56
41
|
|
|
57
42
|
waitForCompletion(taskId: TaskId): Promise<void>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SessionTokenBudget } from '../../store/budget/index.js'
|
|
2
|
-
import type { TaskId } from '../ids/index.js'
|
|
2
|
+
import type { SessionId, TaskId } from '../ids/index.js'
|
|
3
3
|
import type { AgentPersona } from '../persona/index.js'
|
|
4
4
|
import type { CancelCause } from '../session/cancel-cause.js'
|
|
5
5
|
import type { ChildSessionLifecycleEvent, SessionEventListener } from '../session/events.js'
|
|
@@ -14,6 +14,8 @@ export interface TaskHandle {
|
|
|
14
14
|
readonly result?: BaseAgentResult
|
|
15
15
|
readonly createdAt: number
|
|
16
16
|
readonly completedAt?: number
|
|
17
|
+
/** Authoritative conversation id, available once the child is admitted. */
|
|
18
|
+
readonly childSessionId?: SessionId
|
|
17
19
|
/** The workspace assigned to an explicitly isolated child, when admitted. */
|
|
18
20
|
readonly workspace?: WorkspaceRef
|
|
19
21
|
}
|
|
@@ -32,6 +34,13 @@ export interface TaskHandle {
|
|
|
32
34
|
export type SiblingFailurePolicy = 'continue' | 'cancel-siblings'
|
|
33
35
|
|
|
34
36
|
export interface CreateTaskOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Continue a child conversation under a NEW task, with this invocation's
|
|
39
|
+
* parent authority, budget and configuration. Local managers accept only
|
|
40
|
+
* their own retained, settled shared-workspace children of the same parent
|
|
41
|
+
* and unchanged agent definition. A saved log alone grants no authority.
|
|
42
|
+
*/
|
|
43
|
+
readonly resumeSessionId?: SessionId
|
|
35
44
|
/** Per-task filesystem choice, forwarded to the local manager at admission. */
|
|
36
45
|
readonly workspace?: ChildWorkspaceRequest
|
|
37
46
|
/**
|
package/src/types/agent/task.ts
CHANGED
|
@@ -219,6 +219,8 @@ export interface AgentTask {
|
|
|
219
219
|
pendingMessages: Message[]
|
|
220
220
|
createdAt: number
|
|
221
221
|
completedAt?: number
|
|
222
|
+
/** Populated at admission; never inferred from a custom agent's result. */
|
|
223
|
+
readonly childSessionId?: SessionId
|
|
222
224
|
/** Populated after an explicitly isolated spawn is admitted. */
|
|
223
225
|
workspace?: WorkspaceRef
|
|
224
226
|
|
|
@@ -234,6 +236,8 @@ export interface AgentTask {
|
|
|
234
236
|
* WorkspaceRef triple atomically on every spawn.
|
|
235
237
|
*/
|
|
236
238
|
export interface SendMessageOptions {
|
|
239
|
+
/** See {@link import('./scheduler.js').CreateTaskOptions.resumeSessionId}. */
|
|
240
|
+
readonly resumeSessionId?: SessionId
|
|
237
241
|
/** Explicit child filesystem policy; omitted preserves legacy backend behavior. */
|
|
238
242
|
readonly workspace?: ChildWorkspaceRequest
|
|
239
243
|
/**
|
|
@@ -457,6 +457,13 @@ export interface MCPClientConfig {
|
|
|
457
457
|
id?: MCPClientId
|
|
458
458
|
serverName: string
|
|
459
459
|
transport: MCPTransportUnion
|
|
460
|
+
/**
|
|
461
|
+
* Construct a host-owned transport instead of spawning/fetching from `transport`.
|
|
462
|
+
* The config still supplies protocol/cache metadata; no built-in transport work
|
|
463
|
+
* is started. The factory runs once per client; its transport owns reconnects.
|
|
464
|
+
* Custom clients get an isolated era cache unless `eraCache` is supplied.
|
|
465
|
+
*/
|
|
466
|
+
transportFactory?: () => MCPTransport
|
|
460
467
|
capabilities?: MCPClientCapabilities
|
|
461
468
|
clientInfo?: { name: string; version: string }
|
|
462
469
|
/**
|
|
@@ -144,8 +144,10 @@ export const DEFAULT_ERROR_RULES: readonly ErrorCatalogRule[] = [
|
|
|
144
144
|
// separates them when the provider sent it.
|
|
145
145
|
id: 'provider.permission',
|
|
146
146
|
when: (facts) => facts.status === 403,
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
// A 403 says the request was refused, not that a key was accepted: some providers answer
|
|
148
|
+
// a request that carried no key at all (a keyless free tier) with the same status.
|
|
149
|
+
message: 'The provider refused this request.',
|
|
150
|
+
hint: 'Check the model name and whether the account behind your key has access to it. If no key was sent, add one or choose another provider.',
|
|
149
151
|
},
|
|
150
152
|
{
|
|
151
153
|
id: 'provider.auth',
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { isEntityId } from '../../utils/id.js'
|
|
3
|
+
import type { MessageId, TurnId } from '../ids/index.js'
|
|
4
|
+
import type { HarnessEvent, HarnessJson } from './session.js'
|
|
5
|
+
|
|
6
|
+
const opaque = z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(4096)
|
|
10
|
+
.refine((v) => !Array.from(v).some((c) => c.charCodeAt(0) < 32))
|
|
11
|
+
const text = z.string().max(1024 * 1024)
|
|
12
|
+
const digest = z.string().regex(/^[a-f0-9]{64}$/)
|
|
13
|
+
const turnId = z.custom<TurnId>((v) => isEntityId(v, 'turn'))
|
|
14
|
+
const messageId = z.custom<MessageId>((v) => isEntityId(v, 'message'))
|
|
15
|
+
|
|
16
|
+
function validJson(value: unknown, depth = 0, budget = { nodes: 0 }): boolean {
|
|
17
|
+
if (depth > 32 || ++budget.nodes > 50000) return false
|
|
18
|
+
if (value === null || typeof value === 'boolean') return true
|
|
19
|
+
if (typeof value === 'number') return Number.isFinite(value)
|
|
20
|
+
if (typeof value === 'string') return value.length <= 1024 * 1024
|
|
21
|
+
if (Array.isArray(value)) return value.every((v) => validJson(v, depth + 1, budget))
|
|
22
|
+
if (typeof value !== 'object' || Object.getPrototypeOf(value) !== Object.prototype) return false
|
|
23
|
+
return Object.entries(value).every(
|
|
24
|
+
([k, v]) => k.length <= 4096 && validJson(v, depth + 1, budget),
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
const json = z
|
|
28
|
+
.custom<HarnessJson>((v) => validJson(v))
|
|
29
|
+
.refine((v) => JSON.stringify(v).length <= 1024 * 1024)
|
|
30
|
+
|
|
31
|
+
export const HarnessBindingSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
v: z.literal(1),
|
|
34
|
+
engineId: opaque,
|
|
35
|
+
profileRef: opaque,
|
|
36
|
+
nativeSessionId: opaque,
|
|
37
|
+
cwd: opaque,
|
|
38
|
+
initialModel: opaque,
|
|
39
|
+
})
|
|
40
|
+
.strict()
|
|
41
|
+
const nativeTurn = {
|
|
42
|
+
nativeSessionId: opaque,
|
|
43
|
+
nativeTurnId: opaque,
|
|
44
|
+
turnIdSource: z.enum(['engine', 'operation']).optional(),
|
|
45
|
+
}
|
|
46
|
+
const nativeItem = { ...nativeTurn, nativeItemId: opaque }
|
|
47
|
+
export const HarnessNativeTurnSchema = z.object(nativeTurn).strict()
|
|
48
|
+
export const HarnessReviewRequestSchema = z
|
|
49
|
+
.object({
|
|
50
|
+
...nativeTurn,
|
|
51
|
+
requestId: opaque,
|
|
52
|
+
nativeItemId: opaque.optional(),
|
|
53
|
+
kind: z.enum(['command', 'file-change', 'tool']),
|
|
54
|
+
title: opaque,
|
|
55
|
+
input: json,
|
|
56
|
+
decisions: z
|
|
57
|
+
.array(z.enum(['approve-once', 'reject', 'cancel']))
|
|
58
|
+
.min(1)
|
|
59
|
+
.max(3),
|
|
60
|
+
})
|
|
61
|
+
.strict()
|
|
62
|
+
export const HarnessDecisionSchema = z.discriminatedUnion('kind', [
|
|
63
|
+
z.object({ kind: z.literal('approve-once'), updatedInput: json.optional() }).strict(),
|
|
64
|
+
z.object({ kind: z.literal('reject'), feedback: text.optional() }).strict(),
|
|
65
|
+
z.object({ kind: z.literal('cancel') }).strict(),
|
|
66
|
+
])
|
|
67
|
+
const part = z
|
|
68
|
+
.object({ id: opaque, text, phase: z.enum(['commentary', 'final_answer']).optional() })
|
|
69
|
+
.strict()
|
|
70
|
+
export const HarnessEventSchema: z.ZodType<HarnessEvent> = z.discriminatedUnion('kind', [
|
|
71
|
+
z.object({ kind: z.literal('turn-started'), ...nativeTurn, model: opaque.optional() }).strict(),
|
|
72
|
+
z.object({ kind: z.literal('message-started'), ...nativeItem }).strict(),
|
|
73
|
+
z
|
|
74
|
+
.object({
|
|
75
|
+
kind: z.literal('text-delta'),
|
|
76
|
+
...nativeItem,
|
|
77
|
+
text,
|
|
78
|
+
part: part.omit({ text: true }).optional(),
|
|
79
|
+
})
|
|
80
|
+
.strict(),
|
|
81
|
+
z
|
|
82
|
+
.object({
|
|
83
|
+
kind: z.literal('message-completed'),
|
|
84
|
+
...nativeItem,
|
|
85
|
+
content: text,
|
|
86
|
+
parts: z.array(part).max(10000).optional(),
|
|
87
|
+
stopReason: z.enum([
|
|
88
|
+
'end_turn',
|
|
89
|
+
'tool_use',
|
|
90
|
+
'max_tokens',
|
|
91
|
+
'stop_sequence',
|
|
92
|
+
'pause_turn',
|
|
93
|
+
'refusal',
|
|
94
|
+
'forced_finalize',
|
|
95
|
+
'cancelled',
|
|
96
|
+
]),
|
|
97
|
+
})
|
|
98
|
+
.strict(),
|
|
99
|
+
z
|
|
100
|
+
.object({
|
|
101
|
+
kind: z.literal('reasoning'),
|
|
102
|
+
...nativeItem,
|
|
103
|
+
blockId: opaque,
|
|
104
|
+
status: z.enum(['pending', 'completed']),
|
|
105
|
+
text: text.optional(),
|
|
106
|
+
})
|
|
107
|
+
.strict(),
|
|
108
|
+
z.object({ kind: z.literal('tool-started'), ...nativeItem, name: opaque, input: json }).strict(),
|
|
109
|
+
z.object({ kind: z.literal('tool-output'), ...nativeItem, text }).strict(),
|
|
110
|
+
z
|
|
111
|
+
.object({
|
|
112
|
+
kind: z.literal('tool-completed'),
|
|
113
|
+
...nativeItem,
|
|
114
|
+
name: opaque,
|
|
115
|
+
result: text,
|
|
116
|
+
status: z.enum(['completed', 'failed', 'declined', 'cancelled']),
|
|
117
|
+
durationMs: z.number().int().nonnegative().safe().optional(),
|
|
118
|
+
})
|
|
119
|
+
.strict(),
|
|
120
|
+
z.object({ kind: z.literal('review-requested'), request: HarnessReviewRequestSchema }).strict(),
|
|
121
|
+
z.object({ kind: z.literal('review-resolved'), ...nativeTurn, requestId: opaque }).strict(),
|
|
122
|
+
z
|
|
123
|
+
.object({
|
|
124
|
+
kind: z.literal('turn-completed'),
|
|
125
|
+
...nativeTurn,
|
|
126
|
+
status: z.enum(['completed', 'failed', 'cancelled']),
|
|
127
|
+
finalItemId: opaque.optional(),
|
|
128
|
+
result: text.optional(),
|
|
129
|
+
error: z.object({ code: opaque, message: text }).strict().optional(),
|
|
130
|
+
})
|
|
131
|
+
.strict(),
|
|
132
|
+
z
|
|
133
|
+
.object({ kind: z.literal('connection-lost'), code: opaque, mayBeRunning: z.boolean() })
|
|
134
|
+
.strict(),
|
|
135
|
+
])
|
|
136
|
+
|
|
137
|
+
export const HarnessJournalTransitionSchema = z.discriminatedUnion('kind', [
|
|
138
|
+
z
|
|
139
|
+
.object({
|
|
140
|
+
kind: z.literal('dispatch-prepared'),
|
|
141
|
+
model: opaque.optional(),
|
|
142
|
+
effort: z
|
|
143
|
+
.enum(['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'])
|
|
144
|
+
.optional(),
|
|
145
|
+
permissionMode: z.enum(['prompt', 'auto', 'accept-edits', 'plan', 'strict']).optional(),
|
|
146
|
+
operationId: opaque,
|
|
147
|
+
turnId,
|
|
148
|
+
promptId: messageId,
|
|
149
|
+
digest,
|
|
150
|
+
})
|
|
151
|
+
.strict(),
|
|
152
|
+
z
|
|
153
|
+
.object({
|
|
154
|
+
kind: z.literal('dispatch-accepted'),
|
|
155
|
+
operationId: opaque,
|
|
156
|
+
turnId,
|
|
157
|
+
nativeTurn: HarnessNativeTurnSchema,
|
|
158
|
+
})
|
|
159
|
+
.strict(),
|
|
160
|
+
z
|
|
161
|
+
.object({
|
|
162
|
+
kind: z.literal('item-bound'),
|
|
163
|
+
turnId,
|
|
164
|
+
nativeItem: z.object(nativeItem).strict(),
|
|
165
|
+
messageId: messageId.optional(),
|
|
166
|
+
toolUseId: opaque.optional(),
|
|
167
|
+
})
|
|
168
|
+
.strict(),
|
|
169
|
+
z
|
|
170
|
+
.object({
|
|
171
|
+
kind: z.literal('review-requested'),
|
|
172
|
+
turnId,
|
|
173
|
+
request: HarnessReviewRequestSchema,
|
|
174
|
+
digest,
|
|
175
|
+
})
|
|
176
|
+
.strict(),
|
|
177
|
+
z
|
|
178
|
+
.object({
|
|
179
|
+
kind: z.literal('review-decided'),
|
|
180
|
+
turnId,
|
|
181
|
+
requestId: opaque,
|
|
182
|
+
requestDigest: digest,
|
|
183
|
+
decisionDigest: digest,
|
|
184
|
+
decision: HarnessDecisionSchema,
|
|
185
|
+
})
|
|
186
|
+
.strict(),
|
|
187
|
+
z.object({ kind: z.literal('review-resolved'), turnId, requestId: opaque }).strict(),
|
|
188
|
+
z
|
|
189
|
+
.object({ kind: z.literal('connection-lost'), turnId: turnId.optional(), code: opaque })
|
|
190
|
+
.strict(),
|
|
191
|
+
])
|
|
192
|
+
|
|
193
|
+
/** Clone at ingress, before any host callback can suspend, and freeze every nested value. */
|
|
194
|
+
export function harnessSnapshot<T>(value: T): T {
|
|
195
|
+
const copy = structuredClone(value)
|
|
196
|
+
const freeze = (v: unknown): void => {
|
|
197
|
+
if (!v || typeof v !== 'object') return
|
|
198
|
+
for (const entry of Object.values(v)) freeze(entry)
|
|
199
|
+
Object.freeze(v)
|
|
200
|
+
}
|
|
201
|
+
freeze(copy)
|
|
202
|
+
return copy
|
|
203
|
+
}
|