@namzu/sdk 49.0.0 → 50.0.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 +507 -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/public-runtime.d.ts +41 -13
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +35 -7
- 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 +34 -0
- 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/public-runtime.ts +117 -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 +42 -0
- 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/bridge/acp/update.ts
CHANGED
|
@@ -34,13 +34,21 @@ const STOP_REASONS: Readonly<Record<string, AcpStopReason>> = {
|
|
|
34
34
|
stop_condition: 'end_turn',
|
|
35
35
|
max_iterations: 'max_turns',
|
|
36
36
|
max_tokens: 'max_turns',
|
|
37
|
+
token_budget: 'max_turns',
|
|
38
|
+
cost_limit: 'max_turns',
|
|
39
|
+
cost_unmeasurable: 'error',
|
|
40
|
+
timeout: 'error',
|
|
37
41
|
cancelled: 'cancelled',
|
|
38
42
|
canceled: 'cancelled',
|
|
39
43
|
aborted: 'cancelled',
|
|
40
44
|
paused: 'cancelled',
|
|
41
45
|
guardrail_blocked: 'refused',
|
|
46
|
+
input_guardrail: 'refused',
|
|
47
|
+
output_guardrail: 'refused',
|
|
48
|
+
step_refused: 'refused',
|
|
42
49
|
plan_rejected: 'refused',
|
|
43
50
|
answer_rejected: 'refused',
|
|
51
|
+
structured_output_failed: 'error',
|
|
44
52
|
error: 'error',
|
|
45
53
|
provider_error: 'error',
|
|
46
54
|
}
|
|
@@ -50,6 +58,28 @@ export function toAcpStopReason(reason: StopReason | string | undefined): AcpSto
|
|
|
50
58
|
return STOP_REASONS[reason] ?? 'error'
|
|
51
59
|
}
|
|
52
60
|
|
|
61
|
+
function messageIdentity(event: { messageId?: string; turnId?: string; iteration?: number }) {
|
|
62
|
+
return {
|
|
63
|
+
...(event.messageId === undefined ? {} : { messageId: event.messageId }),
|
|
64
|
+
...(event.turnId === undefined ? {} : { turnId: event.turnId }),
|
|
65
|
+
...(event.iteration === undefined ? {} : { iteration: event.iteration }),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function thoughtIdentity(event: {
|
|
70
|
+
messageId?: string
|
|
71
|
+
turnId?: string
|
|
72
|
+
iteration?: number
|
|
73
|
+
blockIndex?: number
|
|
74
|
+
}) {
|
|
75
|
+
return {
|
|
76
|
+
...messageIdentity(event),
|
|
77
|
+
...(event.messageId === undefined || event.blockIndex === undefined
|
|
78
|
+
? {}
|
|
79
|
+
: { blockId: `${event.messageId}:${event.blockIndex}` }),
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
53
83
|
/**
|
|
54
84
|
* One session event as a session update, or `null`.
|
|
55
85
|
*
|
|
@@ -62,10 +92,48 @@ export function toAcpSessionUpdate(
|
|
|
62
92
|
): AcpSessionUpdate | null {
|
|
63
93
|
switch (event.type) {
|
|
64
94
|
case 'text_delta':
|
|
65
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
kind: 'agent_message_chunk',
|
|
97
|
+
text: event.text,
|
|
98
|
+
...messageIdentity(event),
|
|
99
|
+
...(event.textPart
|
|
100
|
+
? {
|
|
101
|
+
textPart: {
|
|
102
|
+
id: event.textPart.id,
|
|
103
|
+
...(event.textPart.phase === undefined ? {} : { phase: event.textPart.phase }),
|
|
104
|
+
},
|
|
105
|
+
...(event.textPart.phase === undefined ? {} : { phase: event.textPart.phase }),
|
|
106
|
+
}
|
|
107
|
+
: {}),
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
case 'message_completed':
|
|
111
|
+
return {
|
|
112
|
+
kind: 'agent_message',
|
|
113
|
+
status: 'completed',
|
|
114
|
+
...messageIdentity(event),
|
|
115
|
+
stopReason: event.stopReason,
|
|
116
|
+
...(event.content === undefined ? {} : { content: event.content }),
|
|
117
|
+
...(event.textParts
|
|
118
|
+
? {
|
|
119
|
+
textParts: event.textParts.map((part) => ({
|
|
120
|
+
id: part.id,
|
|
121
|
+
text: part.text,
|
|
122
|
+
...(part.phase === undefined ? {} : { phase: part.phase }),
|
|
123
|
+
})),
|
|
124
|
+
}
|
|
125
|
+
: {}),
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
case 'reasoning_started':
|
|
129
|
+
return { kind: 'agent_thought', status: 'pending', ...thoughtIdentity(event) }
|
|
66
130
|
|
|
67
131
|
case 'reasoning_delta':
|
|
68
|
-
return { kind: 'agent_thought_chunk', text: event.text }
|
|
132
|
+
return { kind: 'agent_thought_chunk', text: event.text, ...thoughtIdentity(event) }
|
|
133
|
+
|
|
134
|
+
case 'reasoning_completed':
|
|
135
|
+
// Readable text arrived as deltas. Never copy signed or opaque replay material.
|
|
136
|
+
return { kind: 'agent_thought', status: 'completed', ...thoughtIdentity(event) }
|
|
69
137
|
|
|
70
138
|
case 'tool_executing':
|
|
71
139
|
return {
|
|
@@ -76,28 +144,114 @@ export function toAcpSessionUpdate(
|
|
|
76
144
|
view: presenter.presentCall(event.toolName, event.input),
|
|
77
145
|
}
|
|
78
146
|
|
|
147
|
+
case 'tool_progress':
|
|
148
|
+
return {
|
|
149
|
+
kind: 'tool_call',
|
|
150
|
+
toolCallId: event.toolUseId,
|
|
151
|
+
title: event.toolName,
|
|
152
|
+
status: 'pending',
|
|
153
|
+
view: { kind: 'generic', label: event.toolName },
|
|
154
|
+
progress: {
|
|
155
|
+
message: event.message,
|
|
156
|
+
...(event.fraction === undefined ? {} : { fraction: event.fraction }),
|
|
157
|
+
},
|
|
158
|
+
}
|
|
159
|
+
|
|
79
160
|
case 'tool_completed':
|
|
80
161
|
return {
|
|
81
162
|
kind: 'tool_call',
|
|
82
163
|
toolCallId: event.toolUseId,
|
|
83
164
|
title: event.toolName,
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
// asked with `undefined`, and a tool whose `presentResult` needs
|
|
87
|
-
// its input falls back to the generic view rather than being
|
|
88
|
-
// handed a guess at what it was called with.
|
|
165
|
+
// The runtime already presented the result with its real input and
|
|
166
|
+
// data. Older producers may only carry text; keep that fallback.
|
|
89
167
|
status: event.isError === true ? 'failed' : 'completed',
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
168
|
+
...(event.durationMs === undefined ? {} : { durationMs: event.durationMs }),
|
|
169
|
+
...(event.facts === undefined ? {} : { facts: event.facts }),
|
|
170
|
+
view:
|
|
171
|
+
event.presentation ??
|
|
172
|
+
presenter.presentResult(event.toolName, undefined, {
|
|
173
|
+
success: event.isError !== true,
|
|
174
|
+
output: typeof event.result === 'string' ? event.result : String(event.result ?? ''),
|
|
175
|
+
}),
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
case 'hosted_tool': {
|
|
179
|
+
// This is provider-executed activity, not a local tool request. Reuse
|
|
180
|
+
// the peer's existing display-only tool row without exposing a raw
|
|
181
|
+
// provider item or asking the host to execute or approve anything.
|
|
182
|
+
const page = Boolean(event.tool.url && !event.tool.query)
|
|
183
|
+
const title = page ? 'Web fetch' : 'Web search'
|
|
184
|
+
const target = (page ? event.tool.url : event.tool.query)?.replace(/\s+/g, ' ').trim()
|
|
185
|
+
const label =
|
|
186
|
+
event.tool.status === 'running'
|
|
187
|
+
? ''
|
|
188
|
+
: `${title}${target ? `: ${target.slice(0, 200)}` : ''}${
|
|
189
|
+
event.tool.status === 'failed'
|
|
190
|
+
? ' failed'
|
|
191
|
+
: !page &&
|
|
192
|
+
Number.isSafeInteger(event.tool.results) &&
|
|
193
|
+
(event.tool.results ?? -1) >= 0
|
|
194
|
+
? ` · ${event.tool.results} ${event.tool.results === 1 ? 'source' : 'sources'}`
|
|
195
|
+
: ''
|
|
196
|
+
}`
|
|
197
|
+
return {
|
|
198
|
+
kind: 'tool_call',
|
|
199
|
+
toolCallId: `provider-hosted-web-search:${event.iteration}:${event.tool.id}`,
|
|
200
|
+
title,
|
|
201
|
+
status:
|
|
202
|
+
event.tool.status === 'running'
|
|
203
|
+
? 'pending'
|
|
204
|
+
: event.tool.status === 'completed'
|
|
205
|
+
? 'completed'
|
|
206
|
+
: 'failed',
|
|
207
|
+
view: { kind: 'generic', label, presentation: 'activity' },
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
case 'provider_retry':
|
|
212
|
+
return {
|
|
213
|
+
kind: 'provider_retry',
|
|
214
|
+
attempt: event.attempt,
|
|
215
|
+
maxRetries: event.maxRetries,
|
|
216
|
+
delayMs: event.delayMs,
|
|
217
|
+
...(event.status === undefined ? {} : { status: event.status }),
|
|
218
|
+
serverDirected: event.serverDirected,
|
|
219
|
+
...(event.turnId === undefined ? {} : { turnId: event.turnId }),
|
|
94
220
|
}
|
|
95
221
|
|
|
96
222
|
case 'turn_completed':
|
|
97
|
-
return {
|
|
223
|
+
return {
|
|
224
|
+
kind: 'turn_ended',
|
|
225
|
+
stopReason: toAcpStopReason(event.stopReason),
|
|
226
|
+
...(event.turnId === undefined ? {} : { turnId: event.turnId }),
|
|
227
|
+
...(event.settlement?.resultMessageId === undefined
|
|
228
|
+
? {}
|
|
229
|
+
: { messageId: event.settlement.resultMessageId }),
|
|
230
|
+
...(event.stopReason === undefined ? {} : { reason: event.stopReason }),
|
|
231
|
+
...(event.result === undefined ? {} : { result: event.result }),
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
case 'turn_paused':
|
|
235
|
+
return {
|
|
236
|
+
kind: 'turn_ended',
|
|
237
|
+
stopReason: 'cancelled',
|
|
238
|
+
reason: 'paused',
|
|
239
|
+
// A checkpointed provider fault is still a failure the operator
|
|
240
|
+
// needs to see. Ordinary review/handoff pauses remain non-errors.
|
|
241
|
+
...(event.failure || event.providerError
|
|
242
|
+
? { error: event.failure?.message || event.reason }
|
|
243
|
+
: {}),
|
|
244
|
+
...(event.turnId === undefined ? {} : { turnId: event.turnId }),
|
|
245
|
+
}
|
|
98
246
|
|
|
99
247
|
case 'turn_failed':
|
|
100
|
-
return {
|
|
248
|
+
return {
|
|
249
|
+
kind: 'turn_ended',
|
|
250
|
+
stopReason: 'error',
|
|
251
|
+
reason: 'error',
|
|
252
|
+
error: event.error,
|
|
253
|
+
...(event.turnId === undefined ? {} : { turnId: event.turnId }),
|
|
254
|
+
}
|
|
101
255
|
|
|
102
256
|
default:
|
|
103
257
|
// Everything else: iteration boundaries, token accounting, plan and
|
|
@@ -81,7 +81,7 @@ function objectToZod(rawSchema: Record<string, unknown>, depth: number): z.ZodTy
|
|
|
81
81
|
|
|
82
82
|
const properties = schema.properties as Record<string, unknown> | undefined
|
|
83
83
|
if (!properties || Object.keys(properties).length === 0) {
|
|
84
|
-
return closeOrOpen(z.object({}), schema)
|
|
84
|
+
return closeOrOpen(z.object({}), schema, depth)
|
|
85
85
|
}
|
|
86
86
|
if (depth >= MAX_CONVERSION_DEPTH) return z.record(z.unknown())
|
|
87
87
|
|
|
@@ -93,7 +93,7 @@ function objectToZod(rawSchema: Record<string, unknown>, depth: number): z.ZodTy
|
|
|
93
93
|
shape[key] = required.has(key) ? field : field.optional()
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
return closeOrOpen(z.object(shape), schema)
|
|
96
|
+
return closeOrOpen(z.object(shape), schema, depth)
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
@@ -105,9 +105,21 @@ function objectToZod(rawSchema: Record<string, unknown>, depth: number): z.ZodTy
|
|
|
105
105
|
* silently drops undeclared keys rather than rejecting them, so the
|
|
106
106
|
* contract shown to the model tightens without turning a server's
|
|
107
107
|
* incomplete schema into a hard validation failure.
|
|
108
|
+
* A schema-valued additionalProperties explicitly declares a dictionary:
|
|
109
|
+
* preserve those keys and validate each value through the same converter.
|
|
108
110
|
*/
|
|
109
|
-
function closeOrOpen(
|
|
110
|
-
|
|
111
|
+
function closeOrOpen(
|
|
112
|
+
obj: z.ZodObject<z.ZodRawShape>,
|
|
113
|
+
schema: Record<string, unknown>,
|
|
114
|
+
depth: number,
|
|
115
|
+
): z.ZodType {
|
|
116
|
+
const additional = schema.additionalProperties
|
|
117
|
+
if (additional === true) return obj.passthrough()
|
|
118
|
+
if (additional !== null && typeof additional === 'object' && !Array.isArray(additional))
|
|
119
|
+
return obj.catchall(
|
|
120
|
+
depth >= MAX_CONVERSION_DEPTH ? z.unknown() : jsonSchemaPropertyToZod(additional, depth + 1),
|
|
121
|
+
)
|
|
122
|
+
return obj
|
|
111
123
|
}
|
|
112
124
|
|
|
113
125
|
function jsonSchemaPropertyToZod(prop: unknown, depth = 0): z.ZodType {
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
type McpEraProbeAnswer,
|
|
39
39
|
type McpEraResolution,
|
|
40
40
|
classifyModernHttpFailure,
|
|
41
|
+
createMcpEraCache,
|
|
41
42
|
defaultMcpEraCache,
|
|
42
43
|
mcpEraCacheKey,
|
|
43
44
|
resolveMcpEra,
|
|
@@ -275,7 +276,8 @@ export class MCPClient {
|
|
|
275
276
|
),
|
|
276
277
|
this.requestTimeoutMs,
|
|
277
278
|
)
|
|
278
|
-
this.eraCache =
|
|
279
|
+
this.eraCache =
|
|
280
|
+
config.eraCache ?? (config.transportFactory ? createMcpEraCache() : defaultMcpEraCache)
|
|
279
281
|
this.eraCacheKey = mcpEraCacheKey(config.transport)
|
|
280
282
|
this.id = config.id ?? generateMCPClientId()
|
|
281
283
|
// Built BEFORE the transport, not after: `createTransport` threads
|
|
@@ -285,7 +287,9 @@ export class MCPClient {
|
|
|
285
287
|
[SCOPE_ATTRIBUTE]: 'connector/mcp',
|
|
286
288
|
[NAMZU.SERVER_ID]: config.serverName,
|
|
287
289
|
})
|
|
288
|
-
this.transport =
|
|
290
|
+
this.transport = config.transportFactory
|
|
291
|
+
? config.transportFactory()
|
|
292
|
+
: this.createTransport(config.transport)
|
|
289
293
|
}
|
|
290
294
|
|
|
291
295
|
async connect(): Promise<MCPInitializeResult> {
|
|
@@ -49,6 +49,7 @@ export type AcpMethod = (typeof ACP_METHODS)[keyof typeof ACP_METHODS]
|
|
|
49
49
|
*/
|
|
50
50
|
export const ACP_CLIENT_NOTIFICATIONS = {
|
|
51
51
|
SESSION_UPDATE: 'session/update',
|
|
52
|
+
TASK_UPDATE: 'namzu/tasks/update',
|
|
52
53
|
} as const
|
|
53
54
|
|
|
54
55
|
/**
|
|
@@ -102,3 +103,6 @@ export const ACP_PERMISSION_CAPABILITY = 'permission'
|
|
|
102
103
|
* nobody is looking at.
|
|
103
104
|
*/
|
|
104
105
|
export const ACP_FILESYSTEM_CAPABILITY = 'fs'
|
|
106
|
+
|
|
107
|
+
/** Optional Namzu planning notifications, negotiated separately from core ACP. */
|
|
108
|
+
export const ACP_TASK_CAPABILITY = 'namzu/tasks'
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type SessionLog,
|
|
19
19
|
} from '../../store/session-log/index.js'
|
|
20
20
|
import type { BaseAgentConfig, BaseAgentResult } from '../../types/agent/base.js'
|
|
21
|
+
import type { AgentDefinition } from '../../types/agent/factory.js'
|
|
21
22
|
import type {
|
|
22
23
|
AgentLifecycleEvent,
|
|
23
24
|
AgentLifecycleListener,
|
|
@@ -134,10 +135,15 @@ interface ChildSpawnRecord {
|
|
|
134
135
|
parentSessionId: SessionId
|
|
135
136
|
/** The parent turn whose tool call spawned the child. */
|
|
136
137
|
parentTurnId: TurnId
|
|
138
|
+
/** A follow-up has a new invoking turn; the conversation's origin stays immutable. */
|
|
139
|
+
originParentTurnId?: TurnId
|
|
140
|
+
/** Rollback must never delete a conversation that existed before this invocation. */
|
|
141
|
+
resumed?: boolean
|
|
137
142
|
rootSessionId: SessionId
|
|
138
143
|
/** The parent's ancestors and the parent itself, root first: the child's `SessionLocator.ancestors`. */
|
|
139
144
|
ancestry: readonly SessionId[]
|
|
140
145
|
childDepth: number
|
|
146
|
+
childOwnerVersion: number
|
|
141
147
|
/**
|
|
142
148
|
* Where the child's log and meta document were placed, when this manager
|
|
143
149
|
* placed them (a layout was known and the child named no storage).
|
|
@@ -164,6 +170,19 @@ interface ChildSpawnRecord {
|
|
|
164
170
|
resolvedToolDenies?: readonly string[]
|
|
165
171
|
}
|
|
166
172
|
|
|
173
|
+
/** In-process admission capability, separate from replayable history and terminal task handles. */
|
|
174
|
+
interface RetainedChildConversation {
|
|
175
|
+
readonly definition: AgentDefinition
|
|
176
|
+
readonly origin: ChildSpawnRecord
|
|
177
|
+
readonly topicId: AgentTaskContext['topicId']
|
|
178
|
+
readonly projectId: AgentTaskContext['projectId']
|
|
179
|
+
readonly cwd: string
|
|
180
|
+
readonly log: SessionLog
|
|
181
|
+
activeSubSessionId?: SubSessionId
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const RETAINED_CHILD_CONVERSATION_CAP = 1_000
|
|
185
|
+
|
|
167
186
|
/**
|
|
168
187
|
* Combine a child's own environment with what its parent passed down.
|
|
169
188
|
*
|
|
@@ -282,6 +301,7 @@ export class AgentManager {
|
|
|
282
301
|
private registry: AgentRegistry
|
|
283
302
|
private instances: Map<TaskId, AgentTask> = new Map()
|
|
284
303
|
private spawnRecords: Map<TaskId, ChildSpawnRecord> = new Map()
|
|
304
|
+
private readonly childConversations = new Map<SessionId, RetainedChildConversation>()
|
|
285
305
|
private completionCallbacks: Map<TaskId, Array<() => void>> = new Map()
|
|
286
306
|
private listeners: AgentLifecycleListener[] = []
|
|
287
307
|
private log: Logger
|
|
@@ -695,6 +715,7 @@ export class AgentManager {
|
|
|
695
715
|
state: 'pending',
|
|
696
716
|
pendingMessages: queuedTask?.pendingMessages ?? [],
|
|
697
717
|
createdAt: queuedTask?.createdAt ?? Date.now(),
|
|
718
|
+
childSessionId: spawnRecord.childSessionId,
|
|
698
719
|
workspace: options.workspace?.mode === 'isolated' ? spawnRecord.workspaceRef : undefined,
|
|
699
720
|
sessionEventListener: listener,
|
|
700
721
|
} satisfies AgentTask)
|
|
@@ -761,6 +782,11 @@ export class AgentManager {
|
|
|
761
782
|
})
|
|
762
783
|
|
|
763
784
|
const definition = this.registry.getOrThrow(options.agentId)
|
|
785
|
+
if (
|
|
786
|
+
spawnRecord.resumed &&
|
|
787
|
+
definition !== this.childConversations.get(spawnRecord.childSessionId)?.definition
|
|
788
|
+
)
|
|
789
|
+
throw new Error('Child continuation requires its unchanged agent definition')
|
|
764
790
|
let childConfig: BaseAgentConfig
|
|
765
791
|
if (definition.configBuilder) {
|
|
766
792
|
// Call the configBuilder regardless of whether factoryOptions were
|
|
@@ -981,6 +1007,9 @@ export class AgentManager {
|
|
|
981
1007
|
childConfig.sessionLog = childLog
|
|
982
1008
|
spawnRecord.releaseLog = registerChildSessionLog(childLog)
|
|
983
1009
|
}
|
|
1010
|
+
if (!spawnRecord.resumed && childConfig.sessionLog) {
|
|
1011
|
+
this.retainChildConversation(spawnRecord, context, childOptions, childConfig.sessionLog)
|
|
1012
|
+
}
|
|
984
1013
|
|
|
985
1014
|
// Outside the branch, like the scope above it and for the same reason:
|
|
986
1015
|
// a `configBuilder` cannot forward a field it was never told about.
|
|
@@ -999,6 +1028,10 @@ export class AgentManager {
|
|
|
999
1028
|
|
|
1000
1029
|
await childBudget.flush()
|
|
1001
1030
|
childAbortController.signal.throwIfAborted()
|
|
1031
|
+
if (spawnRecord.resumed && this.registry.getOrThrow(options.agentId) !== definition)
|
|
1032
|
+
throw new Error('Child continuation agent definition changed during admission')
|
|
1033
|
+
if (spawnRecord.resumed) await this.assertContinuationOwnership(spawnRecord, options.agentId)
|
|
1034
|
+
childAbortController.signal.throwIfAborted()
|
|
1002
1035
|
this.executingTasks.add(taskId)
|
|
1003
1036
|
const runningTask = agentTask
|
|
1004
1037
|
this.runChild(runningTask, childOptions, childConfig, listener)
|
|
@@ -1021,9 +1054,13 @@ export class AgentManager {
|
|
|
1021
1054
|
// invocation has only NOW stopped; release the persisted edge here.
|
|
1022
1055
|
if (!this.instances.has(taskId) || isTerminalAgentTaskState(runningTask.state)) {
|
|
1023
1056
|
await this.failSubSession(spawnRecord)
|
|
1024
|
-
} else
|
|
1057
|
+
} else {
|
|
1058
|
+
this.releaseChildConversation(spawnRecord)
|
|
1059
|
+
this.markFailed(taskId, toErrorMessage(failure))
|
|
1060
|
+
}
|
|
1025
1061
|
})
|
|
1026
1062
|
.finally(() => {
|
|
1063
|
+
this.releaseChildConversation(spawnRecord)
|
|
1027
1064
|
this.executingTasks.delete(taskId)
|
|
1028
1065
|
if (!this.instances.has(taskId)) this.dropSpawnRecord(taskId)
|
|
1029
1066
|
this.pumpAdmissions(options.parentSessionId)
|
|
@@ -1106,6 +1143,33 @@ export class AgentManager {
|
|
|
1106
1143
|
|
|
1107
1144
|
private async rollbackSpawnResources(spawnRecord: ChildSpawnRecord): Promise<void> {
|
|
1108
1145
|
spawnRecord.releaseLog?.()
|
|
1146
|
+
if (spawnRecord.resumed) {
|
|
1147
|
+
try {
|
|
1148
|
+
await this.deps.sessionStore.deleteSubSession(
|
|
1149
|
+
spawnRecord.subSessionId,
|
|
1150
|
+
spawnRecord.tenantId,
|
|
1151
|
+
)
|
|
1152
|
+
const session = await this.deps.sessionStore.getSession(
|
|
1153
|
+
spawnRecord.childSessionId,
|
|
1154
|
+
spawnRecord.tenantId,
|
|
1155
|
+
)
|
|
1156
|
+
if (
|
|
1157
|
+
session &&
|
|
1158
|
+
session.status === 'active' &&
|
|
1159
|
+
session.ownerVersion === spawnRecord.childOwnerVersion
|
|
1160
|
+
) {
|
|
1161
|
+
await this.deps.sessionStore.updateSession(
|
|
1162
|
+
{ ...session, status: 'idle' },
|
|
1163
|
+
spawnRecord.tenantId,
|
|
1164
|
+
spawnRecord.childOwnerVersion,
|
|
1165
|
+
)
|
|
1166
|
+
}
|
|
1167
|
+
} finally {
|
|
1168
|
+
this.releaseChildConversation(spawnRecord)
|
|
1169
|
+
}
|
|
1170
|
+
return
|
|
1171
|
+
}
|
|
1172
|
+
this.childConversations.delete(spawnRecord.childSessionId)
|
|
1109
1173
|
// A child that never started leaves no meta document naming it: the
|
|
1110
1174
|
// session it describes is being deleted below.
|
|
1111
1175
|
if (spawnRecord.placement) {
|
|
@@ -1116,7 +1180,10 @@ export class AgentManager {
|
|
|
1116
1180
|
}),
|
|
1117
1181
|
)
|
|
1118
1182
|
}
|
|
1119
|
-
await this.disposeChildWorkspace({
|
|
1183
|
+
await this.disposeChildWorkspace({
|
|
1184
|
+
...spawnRecord,
|
|
1185
|
+
workspaceRetention: undefined,
|
|
1186
|
+
})
|
|
1120
1187
|
try {
|
|
1121
1188
|
// The edge must be removed before its child: stores reject deletion
|
|
1122
1189
|
// of a session that still has a subsession reference.
|
|
@@ -1153,7 +1220,7 @@ export class AgentManager {
|
|
|
1153
1220
|
kind: 'child-session',
|
|
1154
1221
|
sessionId: spawnRecord.childSessionId,
|
|
1155
1222
|
parentSessionId: spawnRecord.parentSessionId,
|
|
1156
|
-
parentTurnId: spawnRecord.parentTurnId,
|
|
1223
|
+
parentTurnId: spawnRecord.originParentTurnId ?? spawnRecord.parentTurnId,
|
|
1157
1224
|
rootSessionId: spawnRecord.rootSessionId,
|
|
1158
1225
|
depth: spawnRecord.childDepth,
|
|
1159
1226
|
toolCallId: placement.toolCallId,
|
|
@@ -1186,6 +1253,17 @@ export class AgentManager {
|
|
|
1186
1253
|
options: SendMessageOptions,
|
|
1187
1254
|
taskId: TaskId,
|
|
1188
1255
|
): Promise<SessionLog | undefined> {
|
|
1256
|
+
if (spawnRecord.resumed) {
|
|
1257
|
+
const conversation = this.childConversations.get(spawnRecord.childSessionId)
|
|
1258
|
+
if (!conversation) throw new Error('Child conversation continuation authority is unavailable')
|
|
1259
|
+
if (childConfig.sessionLog && childConfig.sessionLog !== conversation.log)
|
|
1260
|
+
throw new Error('Child continuation cannot replace its conversation log')
|
|
1261
|
+
if (conversation.origin.placement) {
|
|
1262
|
+
childConfig.paths = conversation.origin.placement.paths
|
|
1263
|
+
spawnRecord.placement = conversation.origin.placement
|
|
1264
|
+
}
|
|
1265
|
+
return conversation.log
|
|
1266
|
+
}
|
|
1189
1267
|
if (childConfig.sessionLog !== undefined) return undefined
|
|
1190
1268
|
const inherited = context.childStorage
|
|
1191
1269
|
if (inherited?.kind === 'memory' && childConfig.paths === undefined) {
|
|
@@ -1407,6 +1485,7 @@ export class AgentManager {
|
|
|
1407
1485
|
this.cancel(taskId)
|
|
1408
1486
|
}
|
|
1409
1487
|
this.instances.clear()
|
|
1488
|
+
this.childConversations.clear()
|
|
1410
1489
|
for (const taskId of this.spawnRecords.keys())
|
|
1411
1490
|
if (!this.executingTasks.has(taskId)) this.dropSpawnRecord(taskId)
|
|
1412
1491
|
this.listeners.length = 0
|
|
@@ -1527,6 +1606,7 @@ export class AgentManager {
|
|
|
1527
1606
|
await this.validateSpawn(options, context)
|
|
1528
1607
|
context.parentAbortController.signal.throwIfAborted()
|
|
1529
1608
|
const store = this.deps.sessionStore
|
|
1609
|
+
if (options.resumeSessionId) return this.provisionContinuation(options, context)
|
|
1530
1610
|
|
|
1531
1611
|
// Ancestry walk gives both the child depth and the root session id
|
|
1532
1612
|
// attached to every sub-session event from here down.
|
|
@@ -1671,6 +1751,7 @@ export class AgentManager {
|
|
|
1671
1751
|
rootSessionId,
|
|
1672
1752
|
ancestry: parentAncestry,
|
|
1673
1753
|
childDepth,
|
|
1754
|
+
childOwnerVersion: childSession.ownerVersion,
|
|
1674
1755
|
workspaceRef,
|
|
1675
1756
|
...(options.workspace?.mode === 'isolated' && options.workspace.retention === 'retain'
|
|
1676
1757
|
? { workspaceRetention: 'retain' as const }
|
|
@@ -1678,6 +1759,146 @@ export class AgentManager {
|
|
|
1678
1759
|
}
|
|
1679
1760
|
}
|
|
1680
1761
|
|
|
1762
|
+
private retainChildConversation(
|
|
1763
|
+
origin: ChildSpawnRecord,
|
|
1764
|
+
context: AgentTaskContext,
|
|
1765
|
+
options: SendMessageOptions,
|
|
1766
|
+
log: SessionLog,
|
|
1767
|
+
): void {
|
|
1768
|
+
// Existing builders may supply an application-managed log addressed to
|
|
1769
|
+
// another session. Preserve that first invocation, but never turn its
|
|
1770
|
+
// history into authority for this admitted child's conversation.
|
|
1771
|
+
if (log.sessionId !== origin.childSessionId) return
|
|
1772
|
+
// Conversation authority is bounded independently of the heavy task
|
|
1773
|
+
// eviction. Losing a retained entry makes continuation unavailable; it
|
|
1774
|
+
// never reconstructs execution authority from a history file.
|
|
1775
|
+
if (this.childConversations.size >= RETAINED_CHILD_CONVERSATION_CAP) {
|
|
1776
|
+
const oldest = [...this.childConversations].find(([, value]) => !value.activeSubSessionId)
|
|
1777
|
+
if (oldest) this.childConversations.delete(oldest[0])
|
|
1778
|
+
else return
|
|
1779
|
+
}
|
|
1780
|
+
this.childConversations.set(origin.childSessionId, {
|
|
1781
|
+
definition: this.registry.getOrThrow(options.agentId),
|
|
1782
|
+
origin,
|
|
1783
|
+
topicId: context.topicId,
|
|
1784
|
+
projectId: context.projectId,
|
|
1785
|
+
cwd: resolve(options.input.workingDirectory ?? process.cwd()),
|
|
1786
|
+
log,
|
|
1787
|
+
activeSubSessionId: origin.subSessionId,
|
|
1788
|
+
})
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
private releaseChildConversation(record: ChildSpawnRecord): void {
|
|
1792
|
+
const conversation = this.childConversations.get(record.childSessionId)
|
|
1793
|
+
if (conversation?.activeSubSessionId !== record.subSessionId) return
|
|
1794
|
+
conversation.activeSubSessionId = undefined
|
|
1795
|
+
// An old task's eviction must not unregister the next invocation's log.
|
|
1796
|
+
record.releaseLog?.()
|
|
1797
|
+
record.releaseLog = undefined
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
/** Called under the same parent provisioning lock as ordinary admission. */
|
|
1801
|
+
private async provisionContinuation(
|
|
1802
|
+
options: SendMessageOptions,
|
|
1803
|
+
context: AgentTaskContext,
|
|
1804
|
+
): Promise<ChildSpawnRecord> {
|
|
1805
|
+
const id = options.resumeSessionId
|
|
1806
|
+
const conversation = id ? this.childConversations.get(id) : undefined
|
|
1807
|
+
if (!id || !conversation)
|
|
1808
|
+
throw new Error('Child conversation continuation authority is unavailable')
|
|
1809
|
+
const origin = conversation.origin
|
|
1810
|
+
if (
|
|
1811
|
+
origin.parentSessionId !== options.parentSessionId ||
|
|
1812
|
+
options.parentSessionId !== context.sessionId ||
|
|
1813
|
+
origin.tenantId !== context.tenantId ||
|
|
1814
|
+
conversation.projectId !== context.projectId ||
|
|
1815
|
+
options.projectId !== context.projectId ||
|
|
1816
|
+
conversation.topicId !== context.topicId
|
|
1817
|
+
)
|
|
1818
|
+
throw new Error('Child continuation scope does not match its owning parent')
|
|
1819
|
+
if (conversation.definition !== this.registry.getOrThrow(options.agentId))
|
|
1820
|
+
throw new Error('Child continuation requires its unchanged agent definition')
|
|
1821
|
+
if (conversation.activeSubSessionId)
|
|
1822
|
+
throw new Error('Child conversation is still running or settling')
|
|
1823
|
+
if (origin.workspaceRef || options.workspace?.mode === 'isolated' || options.workspaceBackend)
|
|
1824
|
+
throw new Error(
|
|
1825
|
+
'Child continuation requires a shared workspace; isolated leases cannot be resumed',
|
|
1826
|
+
)
|
|
1827
|
+
if (resolve(options.input.workingDirectory ?? process.cwd()) !== conversation.cwd)
|
|
1828
|
+
throw new Error('Child continuation cannot change its working directory')
|
|
1829
|
+
const store = this.deps.sessionStore
|
|
1830
|
+
if (store.supportsInvocationSummaries !== true || store.supportsOwnerVersionCas !== true)
|
|
1831
|
+
throw new Error('Session store does not support child conversation continuation')
|
|
1832
|
+
const child = await store.getSession(id, context.tenantId)
|
|
1833
|
+
if (
|
|
1834
|
+
!child ||
|
|
1835
|
+
child.status === 'archived' ||
|
|
1836
|
+
child.status === 'locked' ||
|
|
1837
|
+
child.ownerVersion !== origin.childOwnerVersion ||
|
|
1838
|
+
child.projectId !== context.projectId ||
|
|
1839
|
+
child.topicId !== context.topicId ||
|
|
1840
|
+
child.currentActor?.kind !== 'agent' ||
|
|
1841
|
+
child.currentActor.agentId !== options.agentId
|
|
1842
|
+
)
|
|
1843
|
+
throw new Error('Child conversation ownership is no longer valid')
|
|
1844
|
+
const edges = await store.getChildren(options.parentSessionId, context.tenantId)
|
|
1845
|
+
if (!edges.some((edge) => edge.id === origin.subSessionId && edge.childSessionId === id))
|
|
1846
|
+
throw new Error('Child conversation origin is no longer attached to this parent')
|
|
1847
|
+
const edge = await store.createSubSession(
|
|
1848
|
+
{
|
|
1849
|
+
parentSessionId: options.parentSessionId,
|
|
1850
|
+
childSessionId: id,
|
|
1851
|
+
kind: 'agent_spawn',
|
|
1852
|
+
spawnedBy: context.parentActor,
|
|
1853
|
+
failureMode: 'delegate',
|
|
1854
|
+
completionMode: 'summary_ref',
|
|
1855
|
+
},
|
|
1856
|
+
context.tenantId,
|
|
1857
|
+
)
|
|
1858
|
+
try {
|
|
1859
|
+
context.parentAbortController.signal.throwIfAborted()
|
|
1860
|
+
await store.updateSession(
|
|
1861
|
+
{ ...child, status: 'active' },
|
|
1862
|
+
context.tenantId,
|
|
1863
|
+
origin.childOwnerVersion,
|
|
1864
|
+
)
|
|
1865
|
+
} catch (error) {
|
|
1866
|
+
await store.deleteSubSession(edge.id, context.tenantId)
|
|
1867
|
+
throw error
|
|
1868
|
+
}
|
|
1869
|
+
conversation.activeSubSessionId = edge.id
|
|
1870
|
+
return {
|
|
1871
|
+
subSessionId: edge.id,
|
|
1872
|
+
childSessionId: id,
|
|
1873
|
+
tenantId: context.tenantId,
|
|
1874
|
+
parentSessionId: origin.parentSessionId,
|
|
1875
|
+
parentTurnId: context.parentTurnId,
|
|
1876
|
+
originParentTurnId: origin.parentTurnId,
|
|
1877
|
+
rootSessionId: origin.rootSessionId,
|
|
1878
|
+
ancestry: origin.ancestry,
|
|
1879
|
+
childDepth: origin.childDepth,
|
|
1880
|
+
childOwnerVersion: origin.childOwnerVersion,
|
|
1881
|
+
...(origin.placement ? { placement: origin.placement } : {}),
|
|
1882
|
+
resumed: true,
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
private async assertContinuationOwnership(
|
|
1887
|
+
record: ChildSpawnRecord,
|
|
1888
|
+
agentId: string,
|
|
1889
|
+
): Promise<void> {
|
|
1890
|
+
const child = await this.deps.sessionStore.getSession(record.childSessionId, record.tenantId)
|
|
1891
|
+
if (
|
|
1892
|
+
!child ||
|
|
1893
|
+
child.ownerVersion !== record.childOwnerVersion ||
|
|
1894
|
+
child.status === 'archived' ||
|
|
1895
|
+
child.status === 'locked' ||
|
|
1896
|
+
child.currentActor?.kind !== 'agent' ||
|
|
1897
|
+
child.currentActor.agentId !== agentId
|
|
1898
|
+
)
|
|
1899
|
+
throw new Error('Child conversation ownership changed during admission')
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1681
1902
|
private async runChild(
|
|
1682
1903
|
agentTask: AgentTask,
|
|
1683
1904
|
options: SendMessageOptions,
|
|
@@ -1753,6 +1974,8 @@ export class AgentManager {
|
|
|
1753
1974
|
const agentSummary = deriveAgentSummary(result)
|
|
1754
1975
|
const summary = await this.deps.summaryMaterializer.materialize({
|
|
1755
1976
|
sessionId: spawnRecord.childSessionId,
|
|
1977
|
+
...(spawnRecord.resumed ? { expectedOwnerVersion: spawnRecord.childOwnerVersion } : {}),
|
|
1978
|
+
...(spawnRecord.resumed ? { turnId: result.turnId } : {}),
|
|
1756
1979
|
tenantId: spawnRecord.tenantId,
|
|
1757
1980
|
finalOutcome: outcome,
|
|
1758
1981
|
agentSummary,
|
|
@@ -1805,10 +2028,14 @@ export class AgentManager {
|
|
|
1805
2028
|
'namzu.task.id': agentTask.taskId,
|
|
1806
2029
|
'exception.message': toErrorMessage(err),
|
|
1807
2030
|
})
|
|
2031
|
+
// A follow-up must never advertise its original conversation's
|
|
2032
|
+
// stale summary as the completion of this new invocation.
|
|
2033
|
+
if (spawnRecord.resumed) throw err
|
|
1808
2034
|
}
|
|
1809
2035
|
}
|
|
1810
2036
|
|
|
1811
2037
|
if (spawnRecord) await this.settleChildSession(agentTask, spawnRecord, result.status)
|
|
2038
|
+
if (spawnRecord) this.releaseChildConversation(spawnRecord)
|
|
1812
2039
|
|
|
1813
2040
|
this.markCompleted(agentTask.taskId, result)
|
|
1814
2041
|
}
|