@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,6 +1,7 @@
|
|
|
1
1
|
import { NAMZU } from '../../../constants/telemetry/index.js'
|
|
2
2
|
import { formatCompletionNotification } from '../../../scheduler/completion-inbox.js'
|
|
3
3
|
import { DELEGATION_TIMEOUT_MS } from '../../../tools/coordinator/index.js'
|
|
4
|
+
import type { TaskHandle } from '../../../types/agent/scheduler.js'
|
|
4
5
|
import { createRuntimeContextMessage } from '../../../types/message/index.js'
|
|
5
6
|
import type { SessionEvent } from '../../../types/session/index.js'
|
|
6
7
|
import { readPositiveIntEnv } from '../../../utils/env.js'
|
|
@@ -160,7 +161,7 @@ export async function* holdForOutstandingWork(
|
|
|
160
161
|
ctx: IterationContext,
|
|
161
162
|
iterationNum: number,
|
|
162
163
|
hasToolCalls: boolean,
|
|
163
|
-
deliverInbound: () => number
|
|
164
|
+
deliverInbound: () => number | Promise<number>,
|
|
164
165
|
): AsyncGenerator<SessionEvent, boolean> {
|
|
165
166
|
const inbox = ctx.completionInbox?.hasPendingWork ? ctx.completionInbox : undefined
|
|
166
167
|
const jobs = ctx.awaitedJobs?.hasPendingWork ? ctx.awaitedJobs : undefined
|
|
@@ -197,6 +198,7 @@ export async function* holdForOutstandingWork(
|
|
|
197
198
|
...(inbox ? [inbox.waitForArrival(graceMs, waiting.signal)] : []),
|
|
198
199
|
...(jobs ? [jobs.waitForArrival(graceMs, waiting.signal)] : []),
|
|
199
200
|
...(ctx.waitForInbound ? [ctx.waitForInbound(waiting.signal)] : []),
|
|
201
|
+
...(ctx.durableInbound?.wait ? [ctx.durableInbound.wait(waiting.signal)] : []),
|
|
200
202
|
])
|
|
201
203
|
} catch (error) {
|
|
202
204
|
if (!runSignal.aborted) throw error
|
|
@@ -206,6 +208,8 @@ export async function* holdForOutstandingWork(
|
|
|
206
208
|
}
|
|
207
209
|
runSignal.throwIfAborted()
|
|
208
210
|
|
|
211
|
+
// The arrival/inbound/grace race already decided how long this hold may
|
|
212
|
+
// wait. Pending tracking is not a reason to extend it or delay steering.
|
|
209
213
|
const arrived = ctx.completionInbox?.drain() ?? []
|
|
210
214
|
if (arrived.length > 0) {
|
|
211
215
|
ctx.recorder.pushMessage(
|
|
@@ -213,7 +217,7 @@ export async function* holdForOutstandingWork(
|
|
|
213
217
|
)
|
|
214
218
|
}
|
|
215
219
|
const exited = deliverAwaitedJobExits(ctx)
|
|
216
|
-
const inbound = deliverInbound()
|
|
220
|
+
const inbound = await deliverInbound()
|
|
217
221
|
if (arrived.length === 0 && !exited && inbound === 0) return false
|
|
218
222
|
await ctx.emitEvent({
|
|
219
223
|
type: 'iteration_completed',
|
|
@@ -264,6 +268,37 @@ export function deliverAwaitedJobExits(ctx: IterationContext): boolean {
|
|
|
264
268
|
return true
|
|
265
269
|
}
|
|
266
270
|
|
|
271
|
+
/** Await arrived tracking writes within the caller's existing turn deadline. */
|
|
272
|
+
export async function drainArrivedTaskCompletions(ctx: IterationContext): Promise<TaskHandle[]> {
|
|
273
|
+
const inbox = ctx.completionInbox
|
|
274
|
+
if (!inbox) return []
|
|
275
|
+
const runSignal = ctx.abortController.signal
|
|
276
|
+
if (runSignal.aborted) return []
|
|
277
|
+
const remainingMs = ctx.guard.remainingUntilTimeoutMs()
|
|
278
|
+
if (remainingMs <= 0) return inbox.drain()
|
|
279
|
+
const waiting = new AbortController()
|
|
280
|
+
const abort = (): void => waiting.abort(runSignal.reason)
|
|
281
|
+
runSignal.addEventListener('abort', abort, { once: true })
|
|
282
|
+
if (runSignal.aborted) abort()
|
|
283
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
284
|
+
const armDeadline = (): void => {
|
|
285
|
+
const remaining = ctx.guard.remainingUntilTimeoutMs()
|
|
286
|
+
if (remaining <= 0) waiting.abort()
|
|
287
|
+
else if (Number.isFinite(remaining)) {
|
|
288
|
+
// Node timers cannot represent more than a signed 32-bit delay.
|
|
289
|
+
// Recheck long deadlines instead of truncating the turn's timeout.
|
|
290
|
+
timer = setTimeout(armDeadline, Math.min(remaining, 2_147_483_647))
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
armDeadline()
|
|
294
|
+
try {
|
|
295
|
+
return await inbox.drainAsync(waiting.signal)
|
|
296
|
+
} finally {
|
|
297
|
+
if (timer !== undefined) clearTimeout(timer)
|
|
298
|
+
runSignal.removeEventListener('abort', abort)
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
267
302
|
/**
|
|
268
303
|
* Account for outstanding work on the way out: deliver what arrived, and
|
|
269
304
|
* say what did not.
|
|
@@ -275,10 +310,11 @@ export function deliverAwaitedJobExits(ctx: IterationContext): boolean {
|
|
|
275
310
|
* - **What has already arrived is delivered.** It makes no false claim,
|
|
276
311
|
* and dropping it is pure loss — the message rides out on
|
|
277
312
|
* `Turn.messages`, so a host reads it and the next turn of a continued
|
|
278
|
-
* thread starts with it.
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
313
|
+
* thread starts with it. A hold buys the model a turn in which to USE a
|
|
314
|
+
* result; an exit whose answer is already decided has no such turn.
|
|
315
|
+
* Pending tracking writes remain queued. The exit delivers only ready
|
|
316
|
+
* completions, so it never delays a settled answer to append text this
|
|
317
|
+
* turn will not read. The bounded hold stays where it
|
|
282
318
|
* was, on the exits that do have a turn left.
|
|
283
319
|
* - **What is still running is NAMED, not cancelled.** Giving up on a wait
|
|
284
320
|
* is a statement about the waiter, not about the work — the rule
|
|
@@ -320,7 +356,19 @@ export function recordAbandonedWork(ctx: IterationContext): void {
|
|
|
320
356
|
}
|
|
321
357
|
|
|
322
358
|
export function deliverArrivedCompletions(ctx: IterationContext): void {
|
|
323
|
-
|
|
359
|
+
let unheard: TaskHandle[]
|
|
360
|
+
try {
|
|
361
|
+
// No finalizer waits for persistence that may ignore cancellation.
|
|
362
|
+
// Pending gates stay queued and their tracking writes keep running.
|
|
363
|
+
unheard = ctx.completionInbox?.drain() ?? []
|
|
364
|
+
} catch (error) {
|
|
365
|
+
if (!ctx.abortController.signal.aborted) throw error
|
|
366
|
+
ctx.log.warn('Task tracking failed while the turn was cancelled; its result remains queued', {
|
|
367
|
+
[NAMZU.TURN_ID]: ctx.recorder.turnId,
|
|
368
|
+
'exception.message': error instanceof Error ? error.message : String(error),
|
|
369
|
+
})
|
|
370
|
+
return
|
|
371
|
+
}
|
|
324
372
|
if (unheard.length === 0) return
|
|
325
373
|
|
|
326
374
|
// Fix the turn's answer BEFORE appending anything after it.
|
|
@@ -17,6 +17,7 @@ import type { TaskScheduler } from '../../../../types/agent/scheduler.js'
|
|
|
17
17
|
import type { WorkingMemoryProvider } from '../../../../types/agent/working-memory.js'
|
|
18
18
|
import type { HITLResumeDecision, ResumeHandler } from '../../../../types/hitl/index.js'
|
|
19
19
|
import type { CheckpointId } from '../../../../types/ids/index.js'
|
|
20
|
+
import type { DurableInboundSource } from '../../../../types/message/inbound-delivery.js'
|
|
20
21
|
import type { LLMProvider } from '../../../../types/provider/index.js'
|
|
21
22
|
import type { TaskRouterConfig } from '../../../../types/router/index.js'
|
|
22
23
|
import type { ReviewAnswer } from '../../../../types/session/answer-review.js'
|
|
@@ -106,6 +107,8 @@ export interface IterationContext {
|
|
|
106
107
|
readonly activityStore: ActivityStore
|
|
107
108
|
readonly emitEvent: EmitEvent
|
|
108
109
|
readonly drainPending: () => Generator<SessionEvent>
|
|
110
|
+
/** Internal live-event wake; omitted only by legacy phase fixtures. */
|
|
111
|
+
readonly onPendingEvents?: (listener: () => void) => () => void
|
|
109
112
|
readonly abortController: AbortController
|
|
110
113
|
readonly log: Logger
|
|
111
114
|
readonly resumeHandler: ResumeHandler
|
|
@@ -226,6 +229,7 @@ export interface IterationContext {
|
|
|
226
229
|
readonly resumedInput?: readonly import('../../../../types/message/index.js').Message[]
|
|
227
230
|
/** Observes pending input without draining it; abort releases the waiter. */
|
|
228
231
|
readonly waitForInbound?: (signal: AbortSignal) => Promise<void>
|
|
232
|
+
readonly durableInbound?: DurableInboundSource
|
|
229
233
|
|
|
230
234
|
/** Live project policy; separate from human inbound continuation. */
|
|
231
235
|
readonly projectInstructionContext?: ProjectInstructionContext
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AuthorizationGate } from '../../../../authorization/index.js'
|
|
2
|
+
import { isTrustedReadOnly } from '../../../../tools/trusted-read-only.js'
|
|
2
3
|
import type { ToolSourceRef } from '../../../../toolsets/types.js'
|
|
3
|
-
import type { ToolCallSummary } from '../../../../types/hitl/index.js'
|
|
4
|
+
import type { ToolCallDeclined, ToolCallSummary } from '../../../../types/hitl/index.js'
|
|
4
5
|
import type { ChatCompletionResponse } from '../../../../types/provider/index.js'
|
|
5
6
|
import type { SessionEvent } from '../../../../types/session/index.js'
|
|
6
7
|
import type { ShellDialect } from '../../../../types/tool/index.js'
|
|
7
8
|
import { DECLINED_TOOL_CALL_FEEDBACK } from '../../declined.js'
|
|
8
|
-
import type { PreparedToolBatch, ToolCallDenials } from '../../executor.js'
|
|
9
|
+
import type { PreparedToolBatch, ToolCallDeclines, ToolCallDenials } from '../../executor.js'
|
|
9
10
|
import {
|
|
10
11
|
awaitProjectInstructionCallback,
|
|
11
12
|
replaceProjectInstructionSnapshot,
|
|
@@ -97,9 +98,13 @@ export async function* runToolReview(
|
|
|
97
98
|
return finish('executed')
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
const prepareForReview = async (
|
|
101
|
+
const prepareForReview = async (
|
|
102
|
+
hostModifiedCallIds?: ReadonlySet<string>,
|
|
103
|
+
): Promise<PreparedToolBatch | undefined> => {
|
|
101
104
|
const prepare = ctx.toolExecutor.prepareBatchForReview
|
|
102
|
-
return typeof prepare === 'function'
|
|
105
|
+
return typeof prepare === 'function'
|
|
106
|
+
? prepare.call(ctx.toolExecutor, response, hostModifiedCallIds)
|
|
107
|
+
: undefined
|
|
103
108
|
}
|
|
104
109
|
let preparedBatch = await prepareForReview()
|
|
105
110
|
const summariesFor = (prepared: PreparedToolBatch | undefined): ToolCallSummary[] => {
|
|
@@ -157,28 +162,51 @@ export async function* runToolReview(
|
|
|
157
162
|
return merged ?? denials
|
|
158
163
|
}
|
|
159
164
|
|
|
165
|
+
/** Set only where a person's No is known, so a policy refusal never lands in it. */
|
|
166
|
+
let declines: ToolCallDeclines | undefined
|
|
167
|
+
|
|
160
168
|
/** Executes the batch, answering every call, and appends the results. */
|
|
161
|
-
const
|
|
169
|
+
const settleBatch = async (denials?: ToolCallDenials): Promise<void> => {
|
|
162
170
|
const startedAt = Date.now()
|
|
163
171
|
const batch = await ctx.toolExecutor.executeBatch(
|
|
164
172
|
response,
|
|
165
173
|
withRepeatRefusals(denials),
|
|
166
174
|
undefined,
|
|
167
175
|
preparedBatch,
|
|
176
|
+
declines,
|
|
168
177
|
)
|
|
169
178
|
toolMs += Date.now() - startedAt
|
|
170
179
|
executed = batch.results
|
|
180
|
+
// Registry receipts are ordered by actual completion, include nested
|
|
181
|
+
// dispatches, and exclude denials/recovered results. A successful possible
|
|
182
|
+
// mutation permits another experiment; unrelated reads cannot do so.
|
|
183
|
+
for (const observation of batch.observations) {
|
|
184
|
+
const tracker = ctx.repeatCalls
|
|
185
|
+
if (!tracker) break
|
|
186
|
+
if (
|
|
187
|
+
observation.result.success &&
|
|
188
|
+
!isTrustedReadOnly(
|
|
189
|
+
ctx.tools.get(observation.toolName),
|
|
190
|
+
observation.input,
|
|
191
|
+
ctx.toolExecutor.toolSource(observation.toolName),
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
tracker.stateMayHaveChanged()
|
|
195
|
+
tracker.recordOutcome(observation.toolName, observation.input, {
|
|
196
|
+
failed: !observation.result.success,
|
|
197
|
+
result: {
|
|
198
|
+
output: observation.result.output,
|
|
199
|
+
error: observation.result.error,
|
|
200
|
+
content: observation.result.content,
|
|
201
|
+
},
|
|
202
|
+
})
|
|
203
|
+
}
|
|
171
204
|
// Recorded AFTER execution, with the real result: the notice advises
|
|
172
205
|
// on the call that already ran, and the failure count is what the
|
|
173
206
|
// refusal above reads on the NEXT identical call.
|
|
174
207
|
const notices = []
|
|
175
208
|
for (const summary of toolCallSummaries) {
|
|
176
|
-
const
|
|
177
|
-
const notice = ctx.repeatCalls?.record(
|
|
178
|
-
summary.name,
|
|
179
|
-
summary.input,
|
|
180
|
-
outcome ? { failed: outcome.isError === true } : undefined,
|
|
181
|
-
)
|
|
209
|
+
const notice = ctx.repeatCalls?.record(summary.name, summary.input)
|
|
182
210
|
if (notice) notices.push(notice)
|
|
183
211
|
}
|
|
184
212
|
// Guidance the host queued while this batch was running rides out on
|
|
@@ -231,8 +259,62 @@ export async function* runToolReview(
|
|
|
231
259
|
}
|
|
232
260
|
}
|
|
233
261
|
|
|
262
|
+
/** Stream recorded starts and progress while execution itself remains pending. */
|
|
263
|
+
const settle = async function* (
|
|
264
|
+
denials?: ToolCallDenials,
|
|
265
|
+
): AsyncGenerator<SessionEvent, void, unknown> {
|
|
266
|
+
if (!ctx.onPendingEvents) {
|
|
267
|
+
await settleBatch(denials)
|
|
268
|
+
return
|
|
269
|
+
}
|
|
270
|
+
const wakeup = () => {
|
|
271
|
+
let notify!: () => void
|
|
272
|
+
const promise = new Promise<void>((resolve) => {
|
|
273
|
+
notify = resolve
|
|
274
|
+
})
|
|
275
|
+
return { promise, notify }
|
|
276
|
+
}
|
|
277
|
+
let wake = wakeup()
|
|
278
|
+
let settled: { ok: true } | { ok: false; error: unknown } | undefined
|
|
279
|
+
const unsubscribe = ctx.onPendingEvents(() => wake.notify())
|
|
280
|
+
// Start the captured batch before yielding. Live observation must not
|
|
281
|
+
// create a new mutation window before execution validates its payload.
|
|
282
|
+
const execution = settleBatch(denials).then(
|
|
283
|
+
() => {
|
|
284
|
+
settled = { ok: true }
|
|
285
|
+
wake.notify()
|
|
286
|
+
},
|
|
287
|
+
(error) => {
|
|
288
|
+
settled = { ok: false, error }
|
|
289
|
+
wake.notify()
|
|
290
|
+
},
|
|
291
|
+
)
|
|
292
|
+
try {
|
|
293
|
+
while (true) {
|
|
294
|
+
yield* ctx.drainPending()
|
|
295
|
+
if (settled) break
|
|
296
|
+
await wake.promise
|
|
297
|
+
wake = wakeup()
|
|
298
|
+
}
|
|
299
|
+
if (!settled.ok) throw settled.error
|
|
300
|
+
} finally {
|
|
301
|
+
unsubscribe()
|
|
302
|
+
if (!settled) {
|
|
303
|
+
ctx.abortController.abort(
|
|
304
|
+
new DOMException(
|
|
305
|
+
'The query consumer stopped reading during tool execution.',
|
|
306
|
+
'AbortError',
|
|
307
|
+
),
|
|
308
|
+
)
|
|
309
|
+
// Tool cancellation and its receipts settle before the query can
|
|
310
|
+
// release the recorder, sandbox or other borrowed turn resources.
|
|
311
|
+
await execution
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
234
316
|
if (toolCallSummaries.length === 0) {
|
|
235
|
-
|
|
317
|
+
yield* settle()
|
|
236
318
|
yield* ctx.drainPending()
|
|
237
319
|
return finish('executed')
|
|
238
320
|
}
|
|
@@ -264,7 +346,11 @@ export async function* runToolReview(
|
|
|
264
346
|
}
|
|
265
347
|
if (tc.escalation?.unknownProgram !== undefined) {
|
|
266
348
|
await ctx.recorder.recordAudit({
|
|
267
|
-
what: {
|
|
349
|
+
what: {
|
|
350
|
+
action: 'unknown_program',
|
|
351
|
+
tool: tc.name,
|
|
352
|
+
resource: tc.escalation.unknownProgram,
|
|
353
|
+
},
|
|
268
354
|
outcome: 'refused',
|
|
269
355
|
reason,
|
|
270
356
|
})
|
|
@@ -366,7 +452,7 @@ export async function* runToolReview(
|
|
|
366
452
|
ctx.log.debug('Authorization gate: all tool calls pre-approved', {
|
|
367
453
|
'namzu.tool.names': gateResults.map((gr) => gr.toolCall.name),
|
|
368
454
|
})
|
|
369
|
-
|
|
455
|
+
yield* settle()
|
|
370
456
|
yield* ctx.drainPending()
|
|
371
457
|
return finish('executed')
|
|
372
458
|
}
|
|
@@ -381,7 +467,7 @@ export async function* runToolReview(
|
|
|
381
467
|
const reason = gateDenied.get(tc.id)
|
|
382
468
|
if (reason !== undefined) await recordRefusedEscalation(tc, reason)
|
|
383
469
|
}
|
|
384
|
-
|
|
470
|
+
yield* settle(gateDenied)
|
|
385
471
|
yield* ctx.drainPending()
|
|
386
472
|
return finish('rejected')
|
|
387
473
|
}
|
|
@@ -434,7 +520,7 @@ export async function* runToolReview(
|
|
|
434
520
|
ctx.log.debug('Every tool call is covered by an approval already granted', {
|
|
435
521
|
'namzu.tool.names': toolCallSummaries.map((tc) => tc.name),
|
|
436
522
|
})
|
|
437
|
-
|
|
523
|
+
yield* settle()
|
|
438
524
|
yield* ctx.drainPending()
|
|
439
525
|
return finish('executed')
|
|
440
526
|
}
|
|
@@ -535,8 +621,15 @@ export async function* runToolReview(
|
|
|
535
621
|
|
|
536
622
|
const feedback = reviewDecision.feedback || DECLINED_TOOL_CALL_FEEDBACK
|
|
537
623
|
const denials = new Map(denyAll(feedback))
|
|
624
|
+
if (reviewDecision.declined) {
|
|
625
|
+
const declined: ToolCallDeclined = reviewDecision.declined
|
|
626
|
+
// A call the gate already refused was never the person's to decline.
|
|
627
|
+
declines = new Map(
|
|
628
|
+
toolCalls.filter((tc) => !gateDenied.has(tc.id)).map((tc) => [tc.id, declined]),
|
|
629
|
+
)
|
|
630
|
+
}
|
|
538
631
|
await settleEscalations(denials, undefined)
|
|
539
|
-
|
|
632
|
+
yield* settle(denials)
|
|
540
633
|
yield* ctx.drainPending()
|
|
541
634
|
return finish('rejected')
|
|
542
635
|
}
|
|
@@ -552,6 +645,7 @@ export async function* runToolReview(
|
|
|
552
645
|
// Gate denials are the floor; per-call human denials add to them.
|
|
553
646
|
const denials = new Map(gateDenied)
|
|
554
647
|
const modifiedCallIds = new Set<string>()
|
|
648
|
+
const humanDenied = new Map<string, ToolCallDeclined>()
|
|
555
649
|
|
|
556
650
|
for (const mod of reviewDecision.modifications) {
|
|
557
651
|
if (mod.action === 'modify' && mod.modifiedInput !== undefined) {
|
|
@@ -564,6 +658,8 @@ export async function* runToolReview(
|
|
|
564
658
|
}
|
|
565
659
|
if (mod.action === 'deny' && !denials.has(mod.toolCallId)) {
|
|
566
660
|
denials.set(mod.toolCallId, DECLINED_TOOL_CALL_FEEDBACK)
|
|
661
|
+
// A per-call deny is the person's own answer; gate denials above are not.
|
|
662
|
+
humanDenied.set(mod.toolCallId, {})
|
|
567
663
|
}
|
|
568
664
|
}
|
|
569
665
|
|
|
@@ -576,7 +672,7 @@ export async function* runToolReview(
|
|
|
576
672
|
preparedBatch =
|
|
577
673
|
preparedBatch && typeof reprepare === 'function'
|
|
578
674
|
? await reprepare.call(ctx.toolExecutor, response, preparedBatch, modifiedCallIds)
|
|
579
|
-
: await prepareForReview()
|
|
675
|
+
: await prepareForReview(modifiedCallIds)
|
|
580
676
|
toolCallSummaries = summariesFor(preparedBatch)
|
|
581
677
|
}
|
|
582
678
|
if (ctx.verificationGate && modifiedCallIds.size > 0) {
|
|
@@ -606,7 +702,8 @@ export async function* runToolReview(
|
|
|
606
702
|
|
|
607
703
|
await settleEscalations(denials, reviewDecision.confirmedEscalations)
|
|
608
704
|
const everythingDenied = denials.size === toolCalls.length
|
|
609
|
-
|
|
705
|
+
if (humanDenied.size > 0) declines = humanDenied
|
|
706
|
+
yield* settle(denials)
|
|
610
707
|
yield* ctx.drainPending()
|
|
611
708
|
return finish(everythingDenied ? 'rejected' : 'executed')
|
|
612
709
|
}
|
|
@@ -680,7 +777,7 @@ export async function* runToolReview(
|
|
|
680
777
|
denials,
|
|
681
778
|
reviewDecision.action === 'approve_tools' ? reviewDecision.confirmedEscalations : undefined,
|
|
682
779
|
)
|
|
683
|
-
|
|
780
|
+
yield* settle(denials)
|
|
684
781
|
yield* ctx.drainPending()
|
|
685
782
|
return finish(denials.size === toolCalls.length ? 'rejected' : 'executed')
|
|
686
783
|
}
|
|
@@ -696,7 +793,7 @@ export async function* runToolReview(
|
|
|
696
793
|
})
|
|
697
794
|
const denials = new Map(gateDenied)
|
|
698
795
|
await settleEscalations(denials, undefined)
|
|
699
|
-
|
|
796
|
+
yield* settle(denials)
|
|
700
797
|
yield* ctx.drainPending()
|
|
701
798
|
return finish('executed')
|
|
702
799
|
}
|
|
@@ -3,7 +3,7 @@ import { findRetainedIndices } from '../../compaction/retention.js'
|
|
|
3
3
|
import { estimateMessageTokens } from '../../compaction/token-estimate.js'
|
|
4
4
|
import { isClearedToolResult } from '../../compaction/tool-result-editing.js'
|
|
5
5
|
import type { ToolManager } from '../../toolsets/manager.js'
|
|
6
|
-
import type { Message, ToolMessage } from '../../types/message/index.js'
|
|
6
|
+
import type { Message, ToolCall, ToolMessage } from '../../types/message/index.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Request-only exact observation masking. Every reference targets a full result
|
|
@@ -15,14 +15,19 @@ export function projectObservationContext(
|
|
|
15
15
|
messages: Message[],
|
|
16
16
|
tools: Pick<ToolManager, 'get'>,
|
|
17
17
|
preserveToolResultsFrom: readonly string[] = [],
|
|
18
|
+
observationKey?: (call: ToolCall, message: ToolMessage) => string | undefined,
|
|
18
19
|
): Message[] {
|
|
19
|
-
|
|
20
|
+
// Historical model input is not a new tool invocation. Its schema may contain
|
|
21
|
+
// refinements, transforms or defaults with effects, so only an executor-owned
|
|
22
|
+
// record of an actual observation may authorize request-only masking.
|
|
23
|
+
if (!observationKey) return messages
|
|
24
|
+
const calls = new Map<string, ToolCall | null>()
|
|
20
25
|
for (const message of messages) {
|
|
21
26
|
if (message.role !== 'assistant') continue
|
|
22
27
|
for (const call of message.toolCalls ?? []) {
|
|
23
28
|
// Ambiguous IDs cannot prove which observation belongs to which call.
|
|
24
29
|
if (calls.has(call.id)) calls.set(call.id, null)
|
|
25
|
-
else calls.set(call.id, call.metadata?.inputTruncated ? null : call
|
|
30
|
+
else calls.set(call.id, call.metadata?.inputTruncated ? null : call)
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
const resultCounts = new Map<string, number>()
|
|
@@ -47,26 +52,27 @@ export function projectObservationContext(
|
|
|
47
52
|
)
|
|
48
53
|
continue
|
|
49
54
|
const call = calls.get(message.toolCallId)
|
|
50
|
-
if (!call || preserveToolResultsFrom.includes(call.name)) continue
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
if (!call || preserveToolResultsFrom.includes(call.function.name)) continue
|
|
56
|
+
if (!tools.get(call.function.name)) continue
|
|
57
|
+
let executionKey: string | undefined
|
|
53
58
|
try {
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
!input.success ||
|
|
57
|
-
definition.isReadOnly?.(input.data) !== true ||
|
|
58
|
-
definition.isDestructive?.(input.data) === true
|
|
59
|
-
)
|
|
60
|
-
continue
|
|
59
|
+
executionKey = observationKey(call, message)
|
|
61
60
|
} catch {
|
|
62
|
-
//
|
|
63
|
-
// must leave evidence intact, not abort the request.
|
|
61
|
+
// Missing or broken trusted classification leaves the full result intact.
|
|
64
62
|
continue
|
|
65
63
|
}
|
|
64
|
+
if (executionKey === undefined) continue
|
|
66
65
|
// Exact arguments intentionally: equivalent JSON with different formatting
|
|
67
66
|
// is a missed optimization, not permission to merge different file ranges.
|
|
68
67
|
const key = createHash('sha256')
|
|
69
|
-
.update(
|
|
68
|
+
.update(
|
|
69
|
+
JSON.stringify([
|
|
70
|
+
call.function.name,
|
|
71
|
+
call.function.arguments,
|
|
72
|
+
message.content,
|
|
73
|
+
executionKey,
|
|
74
|
+
]),
|
|
75
|
+
)
|
|
70
76
|
.digest('hex')
|
|
71
77
|
const representative = representatives.get(key)
|
|
72
78
|
if (!representative) {
|
|
@@ -371,7 +371,7 @@ export async function prepareTurn(params: QueryParams): Promise<PreparedTurn> {
|
|
|
371
371
|
// The preflight refuses an already foreign log before opening a budget or
|
|
372
372
|
// draining queued topic messages. Repeat after claiming the writer lease:
|
|
373
373
|
// another process may have opened a log that was empty at preflight time.
|
|
374
|
-
await assertSessionLogAttribution(storage.log, params)
|
|
374
|
+
await assertSessionLogAttribution(storage.log, params, { execution: 'kernel' })
|
|
375
375
|
const preludeLease = await PreludeSessionLease.acquire(
|
|
376
376
|
storage.log,
|
|
377
377
|
params.sessionId,
|
|
@@ -381,7 +381,7 @@ export async function prepareTurn(params: QueryParams): Promise<PreparedTurn> {
|
|
|
381
381
|
let releaseOwnedLease = () => preludeLease.release()
|
|
382
382
|
try {
|
|
383
383
|
await preludeLease.assertCurrent()
|
|
384
|
-
await assertSessionLogAttribution(storage.log, params)
|
|
384
|
+
await assertSessionLogAttribution(storage.log, params, { execution: 'kernel' })
|
|
385
385
|
const savedBudget = await savedBudgetReference(params, turnId, storage, selectedResumeState)
|
|
386
386
|
const budget = await resolveQueryBudget(params, turnId, storage.tokenBudget, savedBudget)
|
|
387
387
|
const log = TurnContextFactory.buildLogger({
|
|
@@ -20,6 +20,7 @@ export interface PromptCacheInput {
|
|
|
20
20
|
basePrompt?: string
|
|
21
21
|
tools: ToolManager
|
|
22
22
|
allowedTools?: string[]
|
|
23
|
+
sandboxed?: boolean
|
|
23
24
|
runtimeContext?: AgentRuntimeContext
|
|
24
25
|
contributions?: PromptContributionRegistry
|
|
25
26
|
}
|
|
@@ -46,6 +47,7 @@ export class PromptCache {
|
|
|
46
47
|
basePrompt: input.basePrompt,
|
|
47
48
|
tools: input.tools,
|
|
48
49
|
allowedTools: input.allowedTools,
|
|
50
|
+
sandboxed: input.sandboxed,
|
|
49
51
|
runtimeContext: input.runtimeContext,
|
|
50
52
|
...(input.contributions ? { contributions: input.contributions } : {}),
|
|
51
53
|
})
|
|
@@ -83,6 +85,7 @@ export class PromptCache {
|
|
|
83
85
|
basePrompt: input.basePrompt,
|
|
84
86
|
tools: input.tools,
|
|
85
87
|
allowedTools: input.allowedTools,
|
|
88
|
+
sandboxed: input.sandboxed,
|
|
86
89
|
runtimeContext: input.runtimeContext,
|
|
87
90
|
...(input.contributions ? { contributions: input.contributions } : {}),
|
|
88
91
|
})
|
|
@@ -29,6 +29,8 @@ export interface PromptBuilderConfig {
|
|
|
29
29
|
|
|
30
30
|
tools: ToolManager
|
|
31
31
|
allowedTools?: string[]
|
|
32
|
+
/** Command-tool dialects describe guest tools when a sandbox is supplied. */
|
|
33
|
+
sandboxed?: boolean
|
|
32
34
|
runtimeContext?: AgentRuntimeContext
|
|
33
35
|
/**
|
|
34
36
|
* What else goes in the prompt, beyond what this builder knows about.
|
|
@@ -46,7 +48,7 @@ function buildEnvContext(workingDirectory: string, config: PromptBuilderConfig):
|
|
|
46
48
|
const lines = [
|
|
47
49
|
`<env>
|
|
48
50
|
Working directory: ${workingDirectory}
|
|
49
|
-
Platform: ${process.platform}`,
|
|
51
|
+
${config.sandboxed ? 'Host platform' : 'Platform'}: ${process.platform}`,
|
|
50
52
|
]
|
|
51
53
|
|
|
52
54
|
if (runtimeContext?.label) {
|
|
@@ -121,6 +123,29 @@ function hasFilesystemTools(tools: ToolManager, allowedTools?: string[]): boolea
|
|
|
121
123
|
})
|
|
122
124
|
}
|
|
123
125
|
|
|
126
|
+
/** The actual execution dialect, independent of the host operating system. */
|
|
127
|
+
function buildShellContext(config: PromptBuilderConfig): string | undefined {
|
|
128
|
+
const lines: string[] = []
|
|
129
|
+
for (const name of config.allowedTools ?? config.tools.listNames()) {
|
|
130
|
+
const tool = config.tools.get(name)
|
|
131
|
+
if (
|
|
132
|
+
!tool?.commandArgument ||
|
|
133
|
+
!tool.commandDialect ||
|
|
134
|
+
config.tools.availability(name) !== 'active'
|
|
135
|
+
)
|
|
136
|
+
continue
|
|
137
|
+
const dialect = tool.commandDialect({ sandboxed: config.sandboxed === true })
|
|
138
|
+
lines.push(
|
|
139
|
+
`Execution shell for ${name}: ${dialect}${config.sandboxed ? ' (sandbox guest)' : ' (host)'}.`,
|
|
140
|
+
)
|
|
141
|
+
if (dialect === 'cmd')
|
|
142
|
+
lines.push(
|
|
143
|
+
'Use native Windows CMD command syntax. Single quotes do not quote arguments; backslashes do not escape shell operators. PowerShell syntax requires explicitly invoking PowerShell. Command-specific automatic permission grants are unavailable; an exact-call review may be required.',
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
return lines.length > 0 ? lines.join('\n') : undefined
|
|
147
|
+
}
|
|
148
|
+
|
|
124
149
|
export class PromptBuilder {
|
|
125
150
|
private config: PromptBuilderConfig
|
|
126
151
|
|
|
@@ -250,6 +275,9 @@ export class PromptBuilder {
|
|
|
250
275
|
// `${static}\n\n---\n\n${dynamic}`. The two methods produce the same
|
|
251
276
|
// prompt for the same input, and a turn that hits the prompt cache
|
|
252
277
|
// must not be asking a different question from one that misses it.
|
|
278
|
+
const shellContext = buildShellContext(this.config)
|
|
279
|
+
if (shellContext) parts.push(shellContext)
|
|
280
|
+
|
|
253
281
|
parts.push(...this.renderContributions('static', workingDirectory))
|
|
254
282
|
parts.push(...this.renderContributions('dynamic', workingDirectory))
|
|
255
283
|
|
|
@@ -311,6 +339,9 @@ export class PromptBuilder {
|
|
|
311
339
|
}
|
|
312
340
|
}
|
|
313
341
|
|
|
342
|
+
const shellContext = buildShellContext(this.config)
|
|
343
|
+
if (shellContext) dynamicParts.push(shellContext)
|
|
344
|
+
|
|
314
345
|
staticParts.push(...this.renderContributions('static', workingDirectory))
|
|
315
346
|
dynamicParts.push(...this.renderContributions('dynamic', workingDirectory))
|
|
316
347
|
|