@qlairoslabs/acp-client 0.12.1 → 0.13.0-alpha.1
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-consumer-fixes.md +17 -10
- package/CHANGELOG-controller-interface.md +258 -0
- package/CHANGELOG-metering.md +29 -0
- package/CHANGELOG-operation-lifecycle.md +15 -1
- package/CONSUMER_GUIDE.md +845 -6
- package/MIGRATION-0.10-to-0.12.md +4 -1
- package/MIGRATION-0.12-to-0.13.md +275 -0
- package/README.md +17 -16
- package/package.json +4 -2
- package/src/acp-client-handlers.ts +48 -0
- package/src/activity.ts +3 -0
- package/src/adapters.ts +25 -0
- package/src/agent/adoption/provider-attachment.ts +33 -0
- package/src/agent/adoption/provider-session-delete.ts +1 -1
- package/src/agent/adoption/provider-sessions.ts +3 -2
- package/src/agent/append-assistant-message.ts +91 -0
- package/src/agent/config.ts +54 -6
- package/src/agent/conversation-manager.ts +94 -158
- package/src/agent/manager-settings.ts +1 -0
- package/src/agent/native-channel-lifecycle.ts +111 -0
- package/src/agent/persisted-lifecycle.ts +44 -4
- package/src/agent/persistence-policy/context.ts +13 -0
- package/src/agent/persistence-policy/resolver.ts +7 -0
- package/src/agent/persistence-policy/types.ts +1 -0
- package/src/agent/record-capture.ts +1 -0
- package/src/agent-adapter-registry.ts +33 -7
- package/src/agent-conversation-contracts.ts +14 -1
- package/src/agent-conversation-errors.ts +8 -0
- package/src/agent-conversation-owner.ts +9 -4
- package/src/agent-session-config.ts +135 -0
- package/src/agent-session.ts +439 -934
- package/src/agent.ts +73 -0
- package/src/capabilities.ts +2 -0
- package/src/checkpointing/recovery.ts +3 -0
- package/src/cli/index.ts +3 -3
- package/src/cli/managed.ts +2 -2
- package/src/client.ts +52 -94
- package/src/connection-attempt.ts +95 -0
- package/src/controller-connection.ts +114 -0
- package/src/controller.ts +156 -148
- package/src/conversation-controller/capabilities.ts +88 -0
- package/src/conversation-controller/contracts.ts +208 -0
- package/src/conversation-controller/factory.ts +39 -0
- package/src/conversation-controller/guards.ts +98 -0
- package/src/conversation-controller/index.ts +20 -0
- package/src/conversation-startup.ts +35 -0
- package/src/conversation-turns/backend-turns.ts +373 -0
- package/src/conversation-turns/clear-operations.ts +37 -0
- package/src/conversation-turns/context.ts +135 -0
- package/src/conversation-turns/index.ts +4 -0
- package/src/conversation-turns/record-helpers.ts +75 -0
- package/src/conversation-turns/recording.ts +235 -0
- package/src/conversation-turns/run-turn.ts +367 -0
- package/src/conversation-turns/turn-run.ts +57 -0
- package/src/errors.ts +41 -0
- package/src/handoff-options.ts +81 -0
- package/src/identity/checkpoint-backed.ts +1 -1
- package/src/index.ts +58 -3
- package/src/internal-inference/coordination/manager.ts +11 -0
- package/src/internal-inference/runtime/harness-runtime.ts +4 -4
- package/src/launcher.ts +35 -2
- package/src/media/parts.ts +5 -0
- package/src/message-status.ts +83 -0
- package/src/metering/engine.ts +39 -64
- package/src/metering/measurement-provenance.ts +36 -0
- package/src/metering/native/durability.ts +115 -0
- package/src/metering/native/ledger.ts +104 -0
- package/src/metering/native/operation.ts +85 -0
- package/src/metering/native/projection.ts +114 -0
- package/src/metering/native/proof.ts +51 -0
- package/src/metering/native/requirements.ts +10 -0
- package/src/metering/native/retirement.ts +92 -0
- package/src/metering/native/source.ts +90 -0
- package/src/metering/record.ts +38 -1
- package/src/metering/state.ts +13 -3
- package/src/native/approvals.ts +169 -0
- package/src/native/capabilities.ts +17 -0
- package/src/native/channel-changes.ts +211 -0
- package/src/native/connection.ts +56 -0
- package/src/native/controller.ts +591 -0
- package/src/native/delegation-sender.ts +26 -0
- package/src/native/errors.ts +35 -0
- package/src/native/functions.ts +156 -0
- package/src/native/host-config.ts +59 -0
- package/src/native/host.ts +909 -0
- package/src/native/item-receipts.ts +15 -0
- package/src/native/metering.ts +12 -0
- package/src/native/records.ts +166 -0
- package/src/native/recovery.ts +186 -0
- package/src/native/reminders/fixtures/schema21.sqlite.gz +0 -0
- package/src/native/reminders/idle.ts +70 -0
- package/src/native/reminders/limits.ts +19 -0
- package/src/native/reminders/notifications.ts +29 -0
- package/src/native/reminders/reminders.test.ts +553 -0
- package/src/native/reminders/routine-config.typecheck.ts +13 -0
- package/src/native/reminders/routine-guard.ts +66 -0
- package/src/native/reminders/routine-schedule.ts +25 -0
- package/src/native/reminders/routine-wire.ts +21 -0
- package/src/native/reminders/schedule.ts +97 -0
- package/src/native/reminders/service.ts +280 -0
- package/src/native/reminders/supervisor.ts +91 -0
- package/src/native/reminders/sync.ts +301 -0
- package/src/native/reminders/wire.ts +197 -0
- package/src/native/reminders/wire.typecheck.ts +13 -0
- package/src/native/submission-withdrawal.ts +65 -0
- package/src/native/usage.ts +15 -0
- package/src/native/worker-delivery.ts +61 -0
- package/src/native-harness/.res/README.md +1 -0
- package/src/native-harness/.res/architecture/README.md +21 -0
- package/src/native-harness/.res/architecture/context-and-data.md +31 -0
- package/src/native-harness/.res/architecture/execution.md +42 -0
- package/src/native-harness/.res/architecture/overview.md +44 -0
- package/src/native-harness/.res/architecture/persistence.md +56 -0
- package/src/native-harness/.res/architecture/suspend-and-resume.md +45 -0
- package/src/native-harness/.res/architecture/technical-architecture.md +50 -0
- package/src/native-harness/.res/decisions/0001-basic-loop.md +11 -0
- package/src/native-harness/.res/decisions/0002-channel-input.md +17 -0
- package/src/native-harness/.res/decisions/0003-inference-inspection.md +14 -0
- package/src/native-harness/.res/decisions/0004-shared-context.md +21 -0
- package/src/native-harness/.res/decisions/0005-notice-inbox.md +20 -0
- package/src/native-harness/.res/decisions/0006-explicit-notices.md +12 -0
- package/src/native-harness/.res/decisions/0007-channel-output.md +12 -0
- package/src/native-harness/.res/decisions/0008-browser-client.md +16 -0
- package/src/native-harness/.res/decisions/0009-scripted-model.md +18 -0
- package/src/native-harness/.res/decisions/0010-inprocess-protocol.md +19 -0
- package/src/native-harness/.res/decisions/0011-stdio-transport.md +21 -0
- package/src/native-harness/.res/decisions/0012-session-storage-contract.md +37 -0
- package/src/native-harness/.res/decisions/0013-durable-delivery-contract.md +64 -0
- package/src/native-harness/.res/decisions/0014-channel-controls-contract.md +73 -0
- package/src/native-harness/.res/decisions/0015-session-file-contract.md +72 -0
- package/src/native-harness/.res/decisions/0016-configuration-permissions.md +159 -0
- package/src/native-harness/.res/decisions/0017-openrouter-managed-config.md +69 -0
- package/src/native-harness/.res/decisions/0018-tool-dispatch-evidence.md +78 -0
- package/src/native-harness/.res/decisions/0019-model-execution.md +188 -0
- package/src/native-harness/.res/decisions/0020-startup-channel-changes.md +71 -0
- package/src/native-harness/.res/decisions/0021-tools-and-host-callbacks.md +100 -0
- package/src/native-harness/.res/decisions/0022-operator-controls.md +115 -0
- package/src/native-harness/.res/decisions/0023-long-running-mock.md +82 -0
- package/src/native-harness/.res/decisions/0024-callback-policy-names.md +46 -0
- package/src/native-harness/.res/decisions/0025-external-notices.md +364 -0
- package/src/native-harness/.res/decisions/0026-bounded-context.md +81 -0
- package/src/native-harness/.res/decisions/0027-development-instructions.md +22 -0
- package/src/native-harness/.res/decisions/0028-debug-tools.md +16 -0
- package/src/native-harness/.res/decisions/0029-bounded-model-call-pages.md +37 -0
- package/src/native-harness/.res/decisions/0030-timeline-retrieval.md +145 -0
- package/src/native-harness/.res/decisions/0031-one-off-reminders.md +173 -0
- package/src/native-harness/.res/docs/11-15.md +148 -0
- package/src/native-harness/.res/docs/BUSINESS_RULES.md +111 -0
- package/src/native-harness/.res/docs/WORK.md +65 -0
- package/src/native-harness/.res/docs/_/11-16-persistence/LOG.md +312 -0
- package/src/native-harness/.res/docs/_/11-16-persistence/PLAN.md +77 -0
- package/src/native-harness/.res/docs/_/11-16-persistence/SPEC.md +313 -0
- package/src/native-harness/.res/docs/_/11-19-channel-controls/LOG.md +160 -0
- package/src/native-harness/.res/docs/_/11-19-channel-controls/PLAN.md +89 -0
- package/src/native-harness/.res/docs/_/11-19-channel-controls/SPEC.md +135 -0
- package/src/native-harness/.res/docs/_/11-19-config-permissions/LOG.md +143 -0
- package/src/native-harness/.res/docs/_/11-19-config-permissions/PLAN.md +93 -0
- package/src/native-harness/.res/docs/_/11-19-config-permissions/SPEC.md +181 -0
- package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/11-20-LOG.md +433 -0
- package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PLAN.md +60 -0
- package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PROTOCOL.md +141 -0
- package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/SPEC.md +168 -0
- package/src/native-harness/.res/docs/attachments/0001-DESIGN/SPEC.md +111 -0
- package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/PLAN.md +129 -0
- package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/SPEC.md +135 -0
- package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/LOG.md +437 -0
- package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/PLAN.md +127 -0
- package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/SPEC.md +203 -0
- package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/LOG.md +292 -0
- package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/PLAN.md +91 -0
- package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/SPEC.md +187 -0
- package/src/native-harness/.res/docs/model-execution/0001-DESIGN/LOG.md +148 -0
- package/src/native-harness/.res/docs/model-execution/0001-DESIGN/PLAN.md +95 -0
- package/src/native-harness/.res/docs/model-execution/0001-DESIGN/SPEC.md +200 -0
- package/src/native-harness/.res/docs/model-execution/0002-AMENDMENT-accounting/SPEC.md +80 -0
- package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/LOG.md +206 -0
- package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/PLAN.md +106 -0
- package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/SPEC.md +297 -0
- package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/LOG.md +41 -0
- package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/PLAN.md +36 -0
- package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/SPEC.md +84 -0
- package/src/native-harness/.res/docs/shell-execution/0001-DESIGN/SPEC.md +147 -0
- package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/LOG.md +15 -0
- package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/PLAN.md +107 -0
- package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/SPEC.md +114 -0
- package/src/native-harness/.res/docs/todos/11-19-TODO-auto_review-approve.md +24 -0
- package/src/native-harness/.res/docs/todos/11-20-TODO-user-entered-tool-code.md +23 -0
- package/src/native-harness/.res/docs/todos/11-21-TODO-node-resource-coordination.md +103 -0
- package/src/native-harness/.res/docs/todos/11-22-TODO-harness-m1-sequence.md +50 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/LOG.md +337 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/PLAN.md +76 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/SPEC.md +204 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/LOG.md +73 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/SPEC.md +64 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0003-DESIGN-attachment-tools/SPEC.md +58 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/LOG.md +45 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/PLAN.md +108 -0
- package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/SPEC.md +169 -0
- package/src/native-harness/.res/docs/web-tools/0001-DESIGN/SPEC.md +128 -0
- package/src/native-harness/.res/marketing-draft.md +22 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/README.md +285 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-1.md +19 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-10.md +138 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-11.md +148 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-12.md +172 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-13.md +194 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-14.md +233 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-15.md +249 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-16.md +265 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-17.md +279 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-18.md +293 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-19.md +307 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-2.md +29 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-20.md +317 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-21.md +327 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-3.md +40 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-4.md +59 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-5.md +69 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-6.md +79 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-7.md +89 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-8.md +102 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-9.md +116 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/conversation.jsonl +49 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/doc.md +87 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/harness.py +289 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 2.py +221 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 3.py +287 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy.py +165 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/state.json +22 -0
- package/src/native-harness/.res/sandbox/1-simple-harness/system-prompt.md +2 -0
- package/src/native-harness/AGENTS.md +70 -0
- package/src/native-harness/ARCHITECTURE.md +249 -0
- package/src/native-harness/README.md +726 -0
- package/src/native-harness/bun.lock +26 -0
- package/src/native-harness/package.json +24 -0
- package/src/native-harness/src/capabilities/context/build.ts +59 -0
- package/src/native-harness/src/capabilities/context/instructions/agent-demo.md +11 -0
- package/src/native-harness/src/capabilities/context/instructions/agent.md +5 -0
- package/src/native-harness/src/capabilities/context/instructions/harness.md +7 -0
- package/src/native-harness/src/capabilities/context/load-instructions.ts +22 -0
- package/src/native-harness/src/capabilities/context/session.ts +92 -0
- package/src/native-harness/src/capabilities/model/attempt.ts +27 -0
- package/src/native-harness/src/capabilities/model/openrouter-stream.ts +72 -0
- package/src/native-harness/src/capabilities/model/openrouter.ts +62 -0
- package/src/native-harness/src/capabilities/model/runner.ts +116 -0
- package/src/native-harness/src/capabilities/model/scenario-attempt.ts +50 -0
- package/src/native-harness/src/capabilities/model/scenario-file.ts +125 -0
- package/src/native-harness/src/capabilities/model/scripted-error.ts +6 -0
- package/src/native-harness/src/capabilities/model/scripted.ts +81 -0
- package/src/native-harness/src/capabilities/model/usage.ts +15 -0
- package/src/native-harness/src/capabilities/tools/builtin/current-time.ts +28 -0
- package/src/native-harness/src/capabilities/tools/builtin/notify-channel.ts +17 -0
- package/src/native-harness/src/capabilities/tools/debug/index.ts +13 -0
- package/src/native-harness/src/capabilities/tools/debug/result.ts +12 -0
- package/src/native-harness/src/capabilities/tools/debug/test-echo.ts +16 -0
- package/src/native-harness/src/capabilities/tools/debug/test-fail.ts +14 -0
- package/src/native-harness/src/capabilities/tools/debug/test-wait.ts +19 -0
- package/src/native-harness/src/capabilities/tools/reminders/index.ts +75 -0
- package/src/native-harness/src/capabilities/tools/runtime/catalog.ts +103 -0
- package/src/native-harness/src/capabilities/tools/runtime/functions.ts +130 -0
- package/src/native-harness/src/capabilities/tools/runtime/invocations.ts +48 -0
- package/src/native-harness/src/capabilities/tools/testing/echo.ts +18 -0
- package/src/native-harness/src/capabilities/tools/testing/record.ts +47 -0
- package/src/native-harness/src/capabilities/tools/timeline/index.ts +41 -0
- package/src/native-harness/src/client.ts +18 -0
- package/src/native-harness/src/contracts/agent.ts +105 -0
- package/src/native-harness/src/contracts/config-permissions.ts +47 -0
- package/src/native-harness/src/contracts/context.ts +112 -0
- package/src/native-harness/src/contracts/events.ts +47 -0
- package/src/native-harness/src/contracts/input-limits.ts +7 -0
- package/src/native-harness/src/contracts/inspection.ts +22 -0
- package/src/native-harness/src/contracts/loop.ts +31 -0
- package/src/native-harness/src/contracts/model-execution.ts +83 -0
- package/src/native-harness/src/contracts/operator-controls.ts +106 -0
- package/src/native-harness/src/contracts/output.ts +13 -0
- package/src/native-harness/src/contracts/protocol.ts +320 -0
- package/src/native-harness/src/contracts/reminders.ts +132 -0
- package/src/native-harness/src/contracts/scenario.ts +42 -0
- package/src/native-harness/src/contracts/session-file.ts +19 -0
- package/src/native-harness/src/contracts/session.ts +184 -0
- package/src/native-harness/src/contracts/storage.ts +596 -0
- package/src/native-harness/src/contracts/timeline-retrieval.ts +40 -0
- package/src/native-harness/src/contracts/tools.ts +133 -0
- package/src/native-harness/src/governance/permissions/gate.ts +129 -0
- package/src/native-harness/src/governance/policy/resolve.ts +32 -0
- package/src/native-harness/src/index.ts +318 -0
- package/src/native-harness/src/interfaces/cli/chat.ts +83 -0
- package/src/native-harness/src/interfaces/cli/development.ts +145 -0
- package/src/native-harness/src/interfaces/cli/format-reply.ts +27 -0
- package/src/native-harness/src/interfaces/cli/listeners.ts +74 -0
- package/src/native-harness/src/interfaces/cli/main.ts +47 -0
- package/src/native-harness/src/interfaces/cli/scenario.ts +37 -0
- package/src/native-harness/src/interfaces/cli/serve.ts +21 -0
- package/src/native-harness/src/interfaces/cli/start.ts +106 -0
- package/src/native-harness/src/interfaces/client.ts +225 -0
- package/src/native-harness/src/interfaces/inspector/index.html +283 -0
- package/src/native-harness/src/interfaces/inspector/observe.ts +35 -0
- package/src/native-harness/src/interfaces/inspector/server.ts +56 -0
- package/src/native-harness/src/interfaces/inspector/state.ts +92 -0
- package/src/native-harness/src/interfaces/protocol/channel-changes.ts +153 -0
- package/src/native-harness/src/interfaces/protocol/framing.ts +47 -0
- package/src/native-harness/src/interfaces/protocol/functions.ts +87 -0
- package/src/native-harness/src/interfaces/protocol/in-process.ts +67 -0
- package/src/native-harness/src/interfaces/protocol/live-queue.ts +55 -0
- package/src/native-harness/src/interfaces/protocol/load.ts +60 -0
- package/src/native-harness/src/interfaces/protocol/local.ts +120 -0
- package/src/native-harness/src/interfaces/protocol/operator.ts +120 -0
- package/src/native-harness/src/interfaces/protocol/output.ts +59 -0
- package/src/native-harness/src/interfaces/protocol/server.ts +517 -0
- package/src/native-harness/src/interfaces/protocol/stdio-client.ts +119 -0
- package/src/native-harness/src/interfaces/protocol/stdio-server.ts +82 -0
- package/src/native-harness/src/interfaces/protocol/subscribe.ts +41 -0
- package/src/native-harness/src/interfaces/protocol/transfers.ts +146 -0
- package/src/native-harness/src/interfaces/web-chat/index.html +94 -0
- package/src/native-harness/src/interfaces/web-chat/server.ts +34 -0
- package/src/native-harness/src/kernel/channels.ts +405 -0
- package/src/native-harness/src/kernel/loop.ts +45 -0
- package/src/native-harness/src/runtime/config/development.ts +23 -0
- package/src/native-harness/src/runtime/config/managed.ts +2 -0
- package/src/native-harness/src/runtime/config/paths.ts +27 -0
- package/src/native-harness/src/runtime/reminder-timer.ts +42 -0
- package/src/native-harness/src/runtime/reminder-validation.ts +104 -0
- package/src/native-harness/src/runtime/reminders.ts +66 -0
- package/src/native-harness/src/state/storage/archive.ts +239 -0
- package/src/native-harness/src/state/storage/engine.ts +1013 -0
- package/src/native-harness/src/state/storage/inference.ts +124 -0
- package/src/native-harness/src/state/storage/memory-reminders.ts +78 -0
- package/src/native-harness/src/state/storage/memory.ts +341 -0
- package/src/native-harness/src/state/storage/policy-metadata.ts +32 -0
- package/src/native-harness/src/state/storage/reminder-archive.ts +63 -0
- package/src/native-harness/src/state/storage/reminder-change.ts +92 -0
- package/src/native-harness/src/state/storage/reminder-tables.ts +27 -0
- package/src/native-harness/src/state/storage/retrieval.ts +122 -0
- package/src/native-harness/src/state/storage/script-identity.ts +7 -0
- package/src/native-harness/src/state/storage/session-file.ts +85 -0
- package/src/native-harness/src/state/storage/sqlite-reminders.ts +134 -0
- package/src/native-harness/src/state/storage/sqlite.ts +625 -0
- package/src/native-harness/src/testing.ts +190 -0
- package/src/native-harness/src/util/config.ts +58 -0
- package/src/native-harness/src/util/json.ts +41 -0
- package/src/native-harness/src/util/message-position.ts +3 -0
- package/src/native-harness/src/util/reminder-schedule.ts +44 -0
- package/src/native-harness/src/util/schema.ts +40 -0
- package/src/native-harness/src/util/timeline-text.ts +72 -0
- package/src/native-harness/src/util/timeline-tool-names.ts +3 -0
- package/src/native-harness/test/agent.test.ts +130 -0
- package/src/native-harness/test/approval-gate.test.ts +255 -0
- package/src/native-harness/test/approval-protocol.test.ts +94 -0
- package/src/native-harness/test/boundaries.test.ts +18 -0
- package/src/native-harness/test/channel-controls.test.ts +322 -0
- package/src/native-harness/test/client-abort.test.ts +136 -0
- package/src/native-harness/test/config-policy.test.ts +301 -0
- package/src/native-harness/test/conformance/storage.ts +1141 -0
- package/src/native-harness/test/context.test.ts +177 -0
- package/src/native-harness/test/crash.test.ts +187 -0
- package/src/native-harness/test/debug-tools.test.ts +67 -0
- package/src/native-harness/test/development-cli.test.ts +67 -0
- package/src/native-harness/test/development.test.ts +171 -0
- package/src/native-harness/test/dispatch-evidence.test.ts +58 -0
- package/src/native-harness/test/e2e.test.ts +186 -0
- package/src/native-harness/test/external-notices.test.ts +101 -0
- package/src/native-harness/test/fixtures/approval-e2e.jsonl +4 -0
- package/src/native-harness/test/fixtures/crash-scenario.jsonl +5 -0
- package/src/native-harness/test/fixtures/development-lifecycle.jsonl +10 -0
- package/src/native-harness/test/fixtures/echo-scenario.jsonl +3 -0
- package/src/native-harness/test/fixtures/format2-schema.ts +27 -0
- package/src/native-harness/test/fixtures/format3-schema.ts +16 -0
- package/src/native-harness/test/fixtures/hold-scenario.jsonl +4 -0
- package/src/native-harness/test/fixtures/model-e2e.jsonl +3 -0
- package/src/native-harness/test/fixtures/storage-owner.ts +20 -0
- package/src/native-harness/test/format-reply.test.ts +10 -0
- package/src/native-harness/test/helpers/operator-view.ts +41 -0
- package/src/native-harness/test/helpers/scenario.ts +9 -0
- package/src/native-harness/test/helpers/session.ts +38 -0
- package/src/native-harness/test/helpers/stdio.ts +46 -0
- package/src/native-harness/test/inspector.test.ts +77 -0
- package/src/native-harness/test/listeners.test.ts +49 -0
- package/src/native-harness/test/loop.test.ts +88 -0
- package/src/native-harness/test/model-channel-double.test.ts +87 -0
- package/src/native-harness/test/model-crash.test.ts +62 -0
- package/src/native-harness/test/model-delivery-regressions.test.ts +55 -0
- package/src/native-harness/test/model-e2e.test.ts +71 -0
- package/src/native-harness/test/model-final-filter.test.ts +30 -0
- package/src/native-harness/test/model-large-reply.test.ts +28 -0
- package/src/native-harness/test/model-live-queue.test.ts +33 -0
- package/src/native-harness/test/model-runner.test.ts +117 -0
- package/src/native-harness/test/model-storage.test.ts +99 -0
- package/src/native-harness/test/model-stream-adapter.test.ts +26 -0
- package/src/native-harness/test/model-stream-public.test.ts +77 -0
- package/src/native-harness/test/notices.test.ts +64 -0
- package/src/native-harness/test/openrouter-config.test.ts +218 -0
- package/src/native-harness/test/operator-controls.test.ts +132 -0
- package/src/native-harness/test/output.test.ts +44 -0
- package/src/native-harness/test/owner-config.test.ts +64 -0
- package/src/native-harness/test/permissions-e2e.test.ts +68 -0
- package/src/native-harness/test/persistence.test.ts +236 -0
- package/src/native-harness/test/portability.test.ts +337 -0
- package/src/native-harness/test/protocol.test.ts +160 -0
- package/src/native-harness/test/reminder-clock.test.ts +61 -0
- package/src/native-harness/test/reminder-stdio.test.ts +140 -0
- package/src/native-harness/test/reminder-storage.test.ts +124 -0
- package/src/native-harness/test/scenario-jsonl.test.ts +112 -0
- package/src/native-harness/test/scripted.test.ts +92 -0
- package/src/native-harness/test/session-file.test.ts +51 -0
- package/src/native-harness/test/startup-channel-changes.test.ts +256 -0
- package/src/native-harness/test/stdio.test.ts +132 -0
- package/src/native-harness/test/storage-memory.test.ts +4 -0
- package/src/native-harness/test/storage-sqlite.test.ts +420 -0
- package/src/native-harness/test/suspension.test.ts +430 -0
- package/src/native-harness/test/timeline-retrieval.test.ts +211 -0
- package/src/native-harness/test/tools-catalog.test.ts +468 -0
- package/src/native-harness/test/tools-protocol.test.ts +418 -0
- package/src/native-harness/test/transfers.test.ts +94 -0
- package/src/native-harness/test/web-chat.test.ts +35 -0
- package/src/native-harness/tsconfig.json +20 -0
- package/src/observation/agent-event-bus.ts +44 -18
- package/src/observation/index.ts +1 -0
- package/src/operations/contracts.ts +11 -3
- package/src/operations/errors.ts +5 -0
- package/src/operations/stale-policy.ts +1 -1
- package/src/operations/supervisor.ts +34 -10
- package/src/orchestrator/acp-delivery.ts +68 -0
- package/src/orchestrator/assignments.ts +27 -0
- package/src/orchestrator/busy.ts +15 -0
- package/src/orchestrator/config.ts +41 -0
- package/src/orchestrator/consumer-api.ts +24 -0
- package/src/orchestrator/contracts.ts +71 -0
- package/src/orchestrator/durable-assignments.ts +111 -0
- package/src/orchestrator/native-delegation.ts +103 -0
- package/src/orchestrator/orchestrator.ts +318 -0
- package/src/orchestrator/permissions.ts +25 -0
- package/src/orchestrator/policy.ts +44 -0
- package/src/orchestrator/pool.ts +123 -0
- package/src/orchestrator/tool-descriptions.ts +11 -0
- package/src/permissions/acp.ts +18 -0
- package/src/permissions/arrival.ts +13 -0
- package/src/permissions/consumer-config.ts +19 -0
- package/src/permissions/conversation.ts +280 -0
- package/src/permissions/matcher.ts +85 -0
- package/src/permissions/outcome.ts +15 -0
- package/src/permissions/policy.ts +81 -0
- package/src/permissions/request.ts +26 -0
- package/src/persistence/activity-projection.ts +1 -0
- package/src/persistence/backend.ts +34 -1
- package/src/persistence/channels.ts +23 -0
- package/src/persistence/index.ts +4 -0
- package/src/persistence/protocol-method.ts +5 -0
- package/src/persistence/reminder-wake.ts +49 -0
- package/src/persistence/reminders.ts +385 -0
- package/src/persistence/sqlite-backend.ts +84 -6
- package/src/persistence/sqlite-channels.ts +65 -0
- package/src/persistence/sqlite-reminders.ts +85 -0
- package/src/persistence/sqlite-schema.ts +108 -3
- package/src/persistence/sqlite-worker-delivery.ts +374 -0
- package/src/persistence/sqlite-workers.ts +59 -0
- package/src/persistence/worker-delivery-contract.ts +104 -0
- package/src/persistence/worker-terminal-reason.ts +29 -0
- package/src/persistence/workers.ts +19 -0
- package/src/provider-notices.ts +137 -0
- package/src/repl/commands.ts +2 -2
- package/src/steering/combine.ts +3 -1
- package/src/steering/contracts.ts +11 -2
- package/src/steering/controller.ts +3 -2
- package/src/transport/acp-transport.ts +24 -14
- package/src/types.ts +15 -12
- package/src/updates.ts +14 -2
- package/src/wire-log.ts +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DurableNativeMetering } from "../metering/native/durability.ts";
|
|
2
|
+
import { workerTerminalFailure } from "../persistence/worker-terminal-reason.ts";
|
|
1
3
|
import { writeConversationError } from "./error-record-writer.ts";
|
|
2
4
|
import type { OperationStalledError } from "../operations/errors.ts";
|
|
3
5
|
import { randomUUID } from "node:crypto";
|
|
@@ -31,6 +33,7 @@ import type {
|
|
|
31
33
|
} from "../persistence/provider-attachment.ts";
|
|
32
34
|
|
|
33
35
|
import type { ManagerSettings } from "./manager-settings.ts";
|
|
36
|
+
import { sanitizeConversationErrorMessage } from "../persistence/error-records.ts";
|
|
34
37
|
import {
|
|
35
38
|
updateConversationIdentity,
|
|
36
39
|
persistConversationObservations,
|
|
@@ -50,19 +53,31 @@ import type { MediaStore } from "../media/store.ts";
|
|
|
50
53
|
export class PersistedConversationLifecycle implements AgentConversationOwnerLifecycle {
|
|
51
54
|
private readonly outputMedia = new WeakMap<object, string>();
|
|
52
55
|
private readonly deliveredMessages = new Map<string, { ids: readonly string[]; throughSequence: number }>();
|
|
56
|
+
get reminders() { return this.agent.reminders; }
|
|
57
|
+
readonly nativeMetering: DurableNativeMetering;
|
|
58
|
+
|
|
53
59
|
constructor(
|
|
54
60
|
private readonly agent: Agent,
|
|
55
61
|
private readonly conversationId: AgentConversationId,
|
|
56
62
|
private readonly initialParticipants: readonly ParticipantRef[],
|
|
57
63
|
private readonly settings: ManagerSettings,
|
|
58
64
|
readonly recoverInPlace?: (error: unknown) => Promise<void>,
|
|
59
|
-
) {
|
|
65
|
+
) {
|
|
66
|
+
this.nativeMetering = new DurableNativeMetering(agent.persistence, conversationId, agent.id,
|
|
67
|
+
(record) => this.writeMeteringRecord(record));
|
|
68
|
+
}
|
|
60
69
|
|
|
61
70
|
async operationFailed(input: { operationId: string; error: OperationStalledError }): Promise<void> {
|
|
62
71
|
const written = await writeConversationError(this.agent, this.settings, {
|
|
63
72
|
agentConversationId: this.conversationId, attemptId: input.operationId,
|
|
64
73
|
operationId: input.operationId, source: "operation", code: "stalled", recoverability: "retryable",
|
|
65
|
-
message:
|
|
74
|
+
message: input.error.notice
|
|
75
|
+
? sanitizeConversationErrorMessage(`The provider stopped producing output while retrying: ${input.error.notice.title}`)
|
|
76
|
+
: "The provider stopped producing output.",
|
|
77
|
+
details: {
|
|
78
|
+
phase: input.error.phase,
|
|
79
|
+
...(input.error.notice ? { providerCode: input.error.notice.code ?? input.error.notice.category } : {}),
|
|
80
|
+
},
|
|
66
81
|
});
|
|
67
82
|
if (written.recordingError) throw written.recordingError;
|
|
68
83
|
}
|
|
@@ -93,7 +108,7 @@ export class PersistedConversationLifecycle implements AgentConversationOwnerLif
|
|
|
93
108
|
const participants: ParticipantRef[] = [];
|
|
94
109
|
for (const part of parts) participants.push(await this.resolveParticipant(part.participantId));
|
|
95
110
|
const participant = participants[0]!;
|
|
96
|
-
const identity = await this.agent.identity.load({
|
|
111
|
+
const identity = this.settings.role === "worker" ? {} : await this.agent.identity.load({
|
|
97
112
|
agentSessionId: this.agent.id,
|
|
98
113
|
agentConversationId: this.conversationId,
|
|
99
114
|
targetProviderContextId: input.targetProviderContextId,
|
|
@@ -182,6 +197,17 @@ export class PersistedConversationLifecycle implements AgentConversationOwnerLif
|
|
|
182
197
|
const prepared = await this.withStoredParts(
|
|
183
198
|
persistence, records, input.result.messages.map((message) => message.parts), pending);
|
|
184
199
|
await this.persistObservationsInTransaction(persistence, prepared, true, persisted);
|
|
200
|
+
if (status === "completed") {
|
|
201
|
+
await persistence.workerDelivery?.recordFinal(
|
|
202
|
+
this.conversationId, input.operationId, input.messageIds,
|
|
203
|
+
);
|
|
204
|
+
} else if (status === "cancelled" && input.result.endedBy === "steer") {
|
|
205
|
+
await persistence.workerDelivery?.markSteered(this.conversationId, input.messageIds);
|
|
206
|
+
} else {
|
|
207
|
+
await persistence.workerDelivery?.recordFailure(
|
|
208
|
+
this.conversationId, input.operationId, input.messageIds, workerTerminalFailure(status === "cancelled", undefined, input.result.endedBy),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
185
211
|
// Delivery is tracked per provider context, so it holds when no user or assistant text is captured.
|
|
186
212
|
const delivered = this.deliveredMessages.get(input.operationId);
|
|
187
213
|
if (status === "completed" && delivered) {
|
|
@@ -213,6 +239,7 @@ export class PersistedConversationLifecycle implements AgentConversationOwnerLif
|
|
|
213
239
|
});
|
|
214
240
|
}
|
|
215
241
|
});
|
|
242
|
+
void this.agent.nativeHarness?.flushWorkerDelivery();
|
|
216
243
|
const deliveredIds = this.deliveredMessages.get(input.operationId)?.ids ?? [];
|
|
217
244
|
if (status === "completed") for (const id of deliveredIds) pendingOutOfBandParts(this.agent).delete(id);
|
|
218
245
|
this.deliveredMessages.delete(input.operationId);
|
|
@@ -258,7 +285,12 @@ export class PersistedConversationLifecycle implements AgentConversationOwnerLif
|
|
|
258
285
|
}),
|
|
259
286
|
}));
|
|
260
287
|
const parts = input.messages.map((message) => message.parts);
|
|
261
|
-
await this.updateIdentity(await this.persistMessagesWithParts(records, parts
|
|
288
|
+
await this.updateIdentity(await this.persistMessagesWithParts(records, parts, true, async scope => {
|
|
289
|
+
await scope.workerDelivery?.recordFailure(
|
|
290
|
+
this.conversationId, input.operationId, input.messageIds, workerTerminalFailure(false, input.error),
|
|
291
|
+
);
|
|
292
|
+
}));
|
|
293
|
+
void this.agent.nativeHarness?.flushWorkerDelivery();
|
|
262
294
|
}
|
|
263
295
|
|
|
264
296
|
resolveAdapter(adapterId: string) {
|
|
@@ -329,12 +361,14 @@ export class PersistedConversationLifecycle implements AgentConversationOwnerLif
|
|
|
329
361
|
records: readonly NewConversationRecord[],
|
|
330
362
|
parts: readonly (readonly ResolvedPart[] | undefined)[],
|
|
331
363
|
audit = true,
|
|
364
|
+
terminal?: (scope: PersistenceScope) => Promise<void>,
|
|
332
365
|
): Promise<readonly ConversationRecord[]> {
|
|
333
366
|
const persisted: ConversationRecord[] = [];
|
|
334
367
|
const pending: Array<readonly [object, string]> = [];
|
|
335
368
|
await this.agent.persistence.transaction(async (scope) => {
|
|
336
369
|
const prepared = await this.withStoredParts(scope, records, parts, pending);
|
|
337
370
|
await this.persistObservationsInTransaction(scope, prepared, audit, persisted);
|
|
371
|
+
await terminal?.(scope);
|
|
338
372
|
});
|
|
339
373
|
for (const [part, ref] of pending) this.outputMedia.set(part, ref);
|
|
340
374
|
this.agent.publishCommittedRecords(persisted);
|
|
@@ -343,6 +377,11 @@ export class PersistedConversationLifecycle implements AgentConversationOwnerLif
|
|
|
343
377
|
}
|
|
344
378
|
|
|
345
379
|
async meteringRecorded(record: OperationMeteringRecord): Promise<void> {
|
|
380
|
+
if (record.nativeUsage) return this.nativeMetering.record(record);
|
|
381
|
+
return this.writeMeteringRecord(record);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
private async writeMeteringRecord(record: OperationMeteringRecord): Promise<void> {
|
|
346
385
|
const level = this.settings.capture.metering;
|
|
347
386
|
let reference: ConversationRecord | undefined;
|
|
348
387
|
await this.agent.persistence.transaction(async (persistence) => {
|
|
@@ -407,6 +446,7 @@ export class PersistedConversationLifecycle implements AgentConversationOwnerLif
|
|
|
407
446
|
private async persistObservations(
|
|
408
447
|
records: readonly NewConversationRecord[],
|
|
409
448
|
audit = true,
|
|
449
|
+
terminal?: (scope: PersistenceScope) => Promise<void>,
|
|
410
450
|
): Promise<readonly ConversationRecord[]> {
|
|
411
451
|
return await persistConversationObservations(this.agent, this.settings, records, audit);
|
|
412
452
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentConversationSummary } from "../../persistence/backend.ts";
|
|
2
|
+
import type { ConversationPersistenceContext } from "./types.ts";
|
|
3
|
+
|
|
4
|
+
export function conversationPersistenceContext(summary: AgentConversationSummary): ConversationPersistenceContext {
|
|
5
|
+
return {
|
|
6
|
+
agentConversationId: summary.agentConversationId,
|
|
7
|
+
participants: summary.participants,
|
|
8
|
+
...(summary.title !== undefined && summary.title !== null ? { title: summary.title } : {}),
|
|
9
|
+
...(summary.metadata !== undefined && summary.metadata !== null ? { metadata: summary.metadata } : {}),
|
|
10
|
+
adopted: summary.adopted === true,
|
|
11
|
+
...(summary.role ? { role: summary.role } : {}),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -49,6 +49,13 @@ export class ConversationSettingsResolver {
|
|
|
49
49
|
) {}
|
|
50
50
|
|
|
51
51
|
settingsFor(context: ConversationPersistenceContext): ManagerSettings {
|
|
52
|
+
const settings = this.#resolve(context);
|
|
53
|
+
if (context.role !== "worker") return settings;
|
|
54
|
+
if (settings.capture.message !== "content") throw new Error('worker conversations require message capture "content"');
|
|
55
|
+
return { ...settings, role: "worker" };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#resolve(context: ConversationPersistenceContext): ManagerSettings {
|
|
52
59
|
if (!this.resolver) return this.base;
|
|
53
60
|
const override = this.resolver(context);
|
|
54
61
|
if (override === undefined) return this.base;
|
|
@@ -41,6 +41,7 @@ export async function updateConversationIdentity(
|
|
|
41
41
|
conversationId: AgentConversationId,
|
|
42
42
|
records: readonly ConversationRecord[],
|
|
43
43
|
): Promise<void> {
|
|
44
|
+
if (settings.role === "worker") return;
|
|
44
45
|
await agent.identity.update({
|
|
45
46
|
agentSessionId: agent.id,
|
|
46
47
|
agentConversationId: conversationId,
|
|
@@ -1,32 +1,58 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { NATIVE_ADAPTER_COMMAND, isNativeAdapter, type Adapter, type AgentAdapter, type NativeAdapter } from "./adapters.ts";
|
|
2
2
|
|
|
3
3
|
export interface AgentAdapterRegistration {
|
|
4
4
|
readonly id: string;
|
|
5
|
-
readonly adapter:
|
|
5
|
+
readonly adapter: AgentAdapter;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
/** Mutable agent-scoped adapter directory. IDs are routing names, not trust assertions. */
|
|
9
9
|
export class AgentAdapterRegistry {
|
|
10
10
|
private readonly values = new Map<string, Adapter>();
|
|
11
|
+
/**
|
|
12
|
+
* Native adapters, by id. Each also has an `Adapter`-shaped entry in `values` (a placeholder command
|
|
13
|
+
* that is never spawned), so everything that lists or resolves adapters keeps one shape.
|
|
14
|
+
*/
|
|
15
|
+
private readonly natives = new Map<string, NativeAdapter>();
|
|
11
16
|
|
|
12
17
|
constructor(registrations: readonly AgentAdapterRegistration[] = []) {
|
|
13
18
|
for (const registration of registrations) this.register(registration.id, registration.adapter);
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
register(id: string, adapter:
|
|
21
|
+
register(id: string, adapter: AgentAdapter): void {
|
|
17
22
|
const normalized = normalizeAdapterId(id);
|
|
18
23
|
if (this.values.has(normalized)) throw new Error(`adapter is already registered: ${normalized}`);
|
|
19
|
-
this.
|
|
24
|
+
this.store(normalized, adapter);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
replace(id: string, adapter:
|
|
23
|
-
this.
|
|
27
|
+
replace(id: string, adapter: AgentAdapter): void {
|
|
28
|
+
this.store(normalizeAdapterId(id), adapter);
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
remove(id: string): boolean {
|
|
32
|
+
this.natives.delete(normalizeAdapterId(id));
|
|
27
33
|
return this.values.delete(normalizeAdapterId(id));
|
|
28
34
|
}
|
|
29
35
|
|
|
36
|
+
/** The native adapter registered under `id`, or null when the id names an external harness (or nothing). */
|
|
37
|
+
native(id: string): NativeAdapter | null {
|
|
38
|
+
return this.natives.get(normalizeAdapterId(id)) ?? null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private store(id: string, adapter: AgentAdapter): void {
|
|
42
|
+
if (!isNativeAdapter(adapter)) {
|
|
43
|
+
this.natives.delete(id);
|
|
44
|
+
this.values.set(id, ownAdapter(adapter));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (adapter.defaultPolicy !== undefined && !adapter.defaultPolicy.trim()) throw new Error("defaultPolicy cannot be blank");
|
|
48
|
+
this.natives.set(id, Object.freeze({
|
|
49
|
+
kind: "native" as const,
|
|
50
|
+
...(adapter.defaultPolicy ? { defaultPolicy: adapter.defaultPolicy } : {}),
|
|
51
|
+
...(adapter.displayName ? { displayName: adapter.displayName } : {}),
|
|
52
|
+
}));
|
|
53
|
+
this.values.set(id, ownAdapter({ command: [...NATIVE_ADAPTER_COMMAND], ...(adapter.displayName ? { displayName: adapter.displayName } : {}) }));
|
|
54
|
+
}
|
|
55
|
+
|
|
30
56
|
get(id: string): Adapter | null {
|
|
31
57
|
const adapter = this.values.get(normalizeAdapterId(id));
|
|
32
58
|
return adapter ? ownAdapter(adapter) : null;
|
|
@@ -38,7 +64,7 @@ export class AgentAdapterRegistry {
|
|
|
38
64
|
return adapter;
|
|
39
65
|
}
|
|
40
66
|
|
|
41
|
-
list(): readonly AgentAdapterRegistration[] {
|
|
67
|
+
list(): readonly (AgentAdapterRegistration & { readonly adapter: Adapter })[] {
|
|
42
68
|
return Object.freeze([...this.values].map(([id, adapter]) => Object.freeze({
|
|
43
69
|
id,
|
|
44
70
|
adapter: ownAdapter(adapter),
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import type { ConsumerReminderEvent } from "./native/reminders/wire.ts";
|
|
2
|
+
import type { ReminderEvent } from "./native/reminders/service.ts";
|
|
3
|
+
import type { ConversationPermissionEvent } from "./permissions/conversation.ts";
|
|
1
4
|
import type { OperationActivity } from "./operations/contracts.ts";
|
|
5
|
+
import type { ItemsReceipt, TurnCause } from "./conversation-controller/contracts.ts";
|
|
2
6
|
import type { AgentMode } from "./controller.ts";
|
|
3
7
|
import type { MessageEvent, PendingMessageId, PromptEndedBy } from "./steering/contracts.ts";
|
|
4
8
|
import type { Adapter } from "./adapters.ts";
|
|
@@ -205,13 +209,22 @@ export interface HandoffResult {
|
|
|
205
209
|
|
|
206
210
|
/** Conversation-owned lifecycle events. Harness activity remains in PromptHandlers.onActivity. */
|
|
207
211
|
export type AgentSessionEvent =
|
|
212
|
+
| ReminderEvent
|
|
213
|
+
| ConsumerReminderEvent
|
|
214
|
+
| ConversationPermissionEvent
|
|
208
215
|
| { kind: "provider_reconnected"; via: "loaded" | "recovered" | "fresh"; internalSessionId: string }
|
|
209
216
|
| { kind: "operation_stage_changed"; activity: OperationActivity }
|
|
210
217
|
| { kind: "state_changed"; state: AgentSessionState }
|
|
211
|
-
| {
|
|
218
|
+
| {
|
|
219
|
+
kind: "turn_started";
|
|
220
|
+
turnId: string;
|
|
221
|
+
/** Why the turn started: the messages it carries (every message of a combined steer run). */
|
|
222
|
+
cause: TurnCause;
|
|
223
|
+
}
|
|
212
224
|
| { kind: "turn_completed"; turnId: string; result: PromptResult }
|
|
213
225
|
| { kind: "turn_failed"; turnId: string; error: string }
|
|
214
226
|
| MessageEvent
|
|
227
|
+
| ItemsReceipt
|
|
215
228
|
| { kind: "presentation_recorded"; item: TranscriptPresentationItem }
|
|
216
229
|
| { kind: "internal_session_commands_changed"; commands: readonly InternalSessionCommand[] }
|
|
217
230
|
| { kind: "handoff_started"; handoffId: string; fromInternalSessionId: string | null }
|
|
@@ -12,6 +12,14 @@ export class AgentSessionPromptBlockedError extends Error {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/** The conversation stopped observing a native input before a turn took it. */
|
|
16
|
+
export class NativeInputStoppedError extends Error {
|
|
17
|
+
constructor(readonly messageId: string) {
|
|
18
|
+
super("the conversation stopped observing this native input");
|
|
19
|
+
this.name = "NativeInputStoppedError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
export class ContinuationUnavailableError extends Error {
|
|
16
24
|
constructor(readonly continuation: ContinuationReport, options?: ErrorOptions) {
|
|
17
25
|
super("recorded internal session could not be loaded", options);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ReminderService } from "./native/reminders/service.ts";
|
|
2
|
+
import type { NativeMeteringRecovery } from "./metering/native/durability.ts";
|
|
1
3
|
import type { AgentConversationId, AgentSessionId } from "./agent-ids.ts";
|
|
2
4
|
import type { Adapter } from "./adapters.ts";
|
|
3
5
|
import type { AgentMode } from "./controller.ts";
|
|
@@ -37,8 +39,9 @@ export interface OwnedPromptInput {
|
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
interface OwnedPromptTurnMessages {
|
|
43
|
+
/** The turn's input message IDs in cause order, including messages taken after it began. */
|
|
44
|
+
readonly messageIds: readonly string[];
|
|
42
45
|
/**
|
|
43
46
|
* When each message that ended before the turn did (the next message or a tool call began)
|
|
44
47
|
* received its last text, in order. Those messages are completed at these times; the rest take
|
|
@@ -56,7 +59,7 @@ export interface OwnedPromptPreparation {
|
|
|
56
59
|
readonly identityDeliveryReceipt?: IdentityDeliveryReceipt;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
export interface OwnedPromptCompleted extends OwnedPromptInput,
|
|
62
|
+
export interface OwnedPromptCompleted extends OwnedPromptInput, OwnedPromptTurnMessages {
|
|
60
63
|
readonly result: AgentSessionPromptResult;
|
|
61
64
|
readonly identityDeliveryReceipt?: IdentityDeliveryReceipt;
|
|
62
65
|
readonly providerAttachment: ProviderAttachmentState;
|
|
@@ -77,13 +80,15 @@ export class OwnedPromptPostCommitError extends Error {
|
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
export interface OwnedPromptFailed extends OwnedPromptInput,
|
|
83
|
+
export interface OwnedPromptFailed extends OwnedPromptInput, OwnedPromptTurnMessages {
|
|
81
84
|
readonly messages: readonly ResponseMessage[];
|
|
82
85
|
readonly error: unknown;
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
/** @internal Agent-owned persistence and identity boundary for a conversation turn. */
|
|
86
89
|
export interface AgentConversationOwnerLifecycle {
|
|
90
|
+
readonly reminders?: ReminderService;
|
|
91
|
+
readonly nativeMetering?: NativeMeteringRecovery;
|
|
87
92
|
operationFailed?(input: { readonly operationId: string; readonly error: OperationStalledError }): Promise<void>;
|
|
88
93
|
recoverInPlace?(error: unknown): Promise<void>;
|
|
89
94
|
beforePrompt(input: OwnedPromptInput): Promise<OwnedPromptPreparation>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type * as schema from "@agentclientprotocol/sdk";
|
|
2
|
+
import type { Adapter } from "./adapters.ts";
|
|
3
|
+
import type { AgentConversationId, AgentSessionId } from "./agent-ids.ts";
|
|
4
|
+
import type { NativeControllerBinding } from "./conversation-controller/index.ts";
|
|
5
|
+
import type { AgentControllerConfig, AgentMode } from "./controller.ts";
|
|
6
|
+
import type { Logger } from "./logger.ts";
|
|
7
|
+
import type { MeteringConfig } from "./metering/record.ts";
|
|
8
|
+
import type { OperationLifecycleConfig } from "./operations/contracts.ts";
|
|
9
|
+
import type { ConversationPermissionConfig } from "./permissions/policy.ts";
|
|
10
|
+
import type { AgentSessionCheckpoint } from "./persistence/checkpoint.ts";
|
|
11
|
+
import type { AgentSessionPersistenceOptions } from "./persistence/config.ts";
|
|
12
|
+
import type { ParticipantRef } from "./persistence/backend.ts";
|
|
13
|
+
import type { SessionManager } from "./session-manager.ts";
|
|
14
|
+
import type { PromptDelivery } from "./steering/index.ts";
|
|
15
|
+
import type { WireEntry } from "./types.ts";
|
|
16
|
+
import type { AgentConversationOwnerLifecycle } from "./agent-conversation-owner.ts";
|
|
17
|
+
import type { OpenContinuationOptions, ProviderSession, TranscriptActivityConfig } from "./agent-conversation-contracts.ts";
|
|
18
|
+
|
|
19
|
+
export interface AgentSessionConfig extends ConversationPermissionConfig {
|
|
20
|
+
/** Cancels the factory's startup before it returns the conversation. */
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
/** @internal Agent-owned ACP startup policy. */
|
|
23
|
+
deferProviderStart?: boolean;
|
|
24
|
+
/** The resolved adapter this conversation talks to. */
|
|
25
|
+
adapter: Adapter;
|
|
26
|
+
/** Stable adapter id for the catalog/display (e.g. "codex"). */
|
|
27
|
+
adapterId: string;
|
|
28
|
+
/** Talk over ACP ("normal") or scrape a pty ("degraded"). Default "normal". */
|
|
29
|
+
mode?: AgentMode;
|
|
30
|
+
/** Runtime-specific launcher shared by normal ACP and degraded PTY modes. */
|
|
31
|
+
launcher?: AgentControllerConfig["launcher"];
|
|
32
|
+
/**
|
|
33
|
+
* Binds this conversation to a channel of a shared native harness instead of an external harness
|
|
34
|
+
* process. Opt-in: absent for every ACP conversation. `adapter` is then display only.
|
|
35
|
+
*/
|
|
36
|
+
native?: NativeControllerBinding;
|
|
37
|
+
/** Override the owning Agent’s idle stop window for this conversation. */
|
|
38
|
+
idleStopWindowMs?: number;
|
|
39
|
+
/** @internal Resolves native routes in the owning Agent. */
|
|
40
|
+
isNativeAdapter?: (adapterId: string) => boolean;
|
|
41
|
+
/** @deprecated Use launcher. */
|
|
42
|
+
execPrefix?: string[];
|
|
43
|
+
/** @deprecated Use launcher and its exact spawnEnv. */
|
|
44
|
+
env?: Record<string, string>;
|
|
45
|
+
cwd?: string;
|
|
46
|
+
/** Additional absolute directories declared to the provider. */
|
|
47
|
+
additionalDirectories?: string[];
|
|
48
|
+
/** Default MCP servers bound at session creation/switch, unless a call overrides them. */
|
|
49
|
+
mcpServers?: schema.McpServer[];
|
|
50
|
+
/**
|
|
51
|
+
* How a prompt sent while a turn is running waits when the prompt does not say. `queue` runs it after
|
|
52
|
+
* the turn ends; `steer` delivers it at the next tool boundary. Default `steer`.
|
|
53
|
+
*/
|
|
54
|
+
busyDelivery?: PromptDelivery;
|
|
55
|
+
clientInfo?: { name: string; title?: string; version?: string };
|
|
56
|
+
/** What we let the agent do through us (terminals, filesystem). All on by default. */
|
|
57
|
+
clientCapabilities?: AgentControllerConfig["clientCapabilities"];
|
|
58
|
+
/** Client-side ACP implementations; their presence determines advertisement. */
|
|
59
|
+
clientHandlers?: AgentControllerConfig["clientHandlers"];
|
|
60
|
+
logger?: Logger;
|
|
61
|
+
/** Raw protocol traffic for debugging — see `AcpClientConfig.wire`. */
|
|
62
|
+
wire?: (entry: WireEntry) => void;
|
|
63
|
+
/** Optional catalog. When present, the session records itself here. */
|
|
64
|
+
sessions?: SessionManager;
|
|
65
|
+
/** New v2 persistence. Direct sessions remain persistence-free when omitted. */
|
|
66
|
+
persistence?: false | AgentSessionPersistenceOptions;
|
|
67
|
+
/** Stable creation transaction/incarnation ID; required by direct v2 persistence. */
|
|
68
|
+
creationId?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Absolute path to an append-only transcript file. This selects history storage only;
|
|
71
|
+
* file existence never selects the provider thread. Omitted means no transcript.
|
|
72
|
+
*/
|
|
73
|
+
transcriptPath?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Directory for `<encoded-agentSessionId>.jsonl`. This selects history storage only;
|
|
76
|
+
* the directory is not a session catalog and is not scanned during creation.
|
|
77
|
+
*/
|
|
78
|
+
transcriptDir?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Also record activity (thinking, tool calls and their output, plans) as `t:"activity"`
|
|
81
|
+
* lines. Off by default — it makes transcripts larger, and `readTranscript()` ignores
|
|
82
|
+
* them either way; read them with `readTranscriptLines()`.
|
|
83
|
+
*
|
|
84
|
+
* Lines are SETTLED records, not raw deltas: the session folds the delta stream and
|
|
85
|
+
* writes checkpoints (announced → input → settled), typically 2–3 lines per tool call
|
|
86
|
+
* instead of one per notification. Fold them back with `foldRecords()`, last-wins on
|
|
87
|
+
* `recordId`. `true` selects the defaults below.
|
|
88
|
+
*/
|
|
89
|
+
transcriptActivity?: boolean | TranscriptActivityConfig;
|
|
90
|
+
/** Stable logical identity. Minted if omitted; always available on the created object. */
|
|
91
|
+
agentSessionId?: string;
|
|
92
|
+
/** Provider-thread startup intent. Default `{ kind: "new" }`. */
|
|
93
|
+
providerSession?: ProviderSession;
|
|
94
|
+
/** Stale limits per operation kind (turns, internal inference, recap). */
|
|
95
|
+
operationLifecycle?: OperationLifecycleConfig;
|
|
96
|
+
/**
|
|
97
|
+
* Token/cost metering policy. Optional: omitting it selects best-effort enforcement
|
|
98
|
+
* with the pinned models.dev catalog and no restored state. Metering is not something a
|
|
99
|
+
* consumer must turn on merely to see protocol facts.
|
|
100
|
+
*/
|
|
101
|
+
metering?: MeteringConfig;
|
|
102
|
+
/**
|
|
103
|
+
* @deprecated Use `providerSession: { kind: "load", internalSessionId, onFailure }`.
|
|
104
|
+
* Retains the historical fallback-to-new behavior for compatibility.
|
|
105
|
+
*/
|
|
106
|
+
internalSessionId?: string;
|
|
107
|
+
title?: string;
|
|
108
|
+
/** Stable conversation identity when this runtime is owned by an Agent. */
|
|
109
|
+
agentConversationId?: AgentConversationId;
|
|
110
|
+
/** Stable owning agent identity. Omitted for detached compatibility conversations. */
|
|
111
|
+
ownerAgentSessionId?: AgentSessionId;
|
|
112
|
+
/** Other sides of this conversation. The owning agent is implied. */
|
|
113
|
+
participants?: readonly ParticipantRef[];
|
|
114
|
+
/** @internal Installed by AgentConversationManager. */
|
|
115
|
+
ownerLifecycle?: AgentConversationOwnerLifecycle;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Direct restoration input. Phase 5A intentionally supports the safe recorded-thread path. */
|
|
119
|
+
export interface AgentSessionOpenConfig extends Omit<
|
|
120
|
+
AgentSessionConfig,
|
|
121
|
+
| "agentSessionId"
|
|
122
|
+
| "creationId"
|
|
123
|
+
| "providerSession"
|
|
124
|
+
| "internalSessionId"
|
|
125
|
+
| "mode"
|
|
126
|
+
| "persistence"
|
|
127
|
+
| "sessions"
|
|
128
|
+
> {
|
|
129
|
+
/** Required for directory/default path resolution; exact-file inference is a later slice. */
|
|
130
|
+
agentSessionId: string;
|
|
131
|
+
persistence: AgentSessionPersistenceOptions;
|
|
132
|
+
/** Optional consumer copy must exactly match transcript authority in this first slice. */
|
|
133
|
+
checkpoint?: AgentSessionCheckpoint;
|
|
134
|
+
continuation?: OpenContinuationOptions;
|
|
135
|
+
}
|