@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,5 +1,8 @@
|
|
|
1
1
|
# Migrating from 0.10.2 to 0.12.0
|
|
2
2
|
|
|
3
|
+
This is the historical 0.12 guide. For the next upgrade from published 0.12.1,
|
|
4
|
+
see [Migrating from 0.12.1 to 0.13](MIGRATION-0.12-to-0.13.md).
|
|
5
|
+
|
|
3
6
|
For agents-core and the webapp, which pin `@qlairoslabs/acp-client` `0.10.2`. This covers everything
|
|
4
7
|
since: `0.11.0`, the operation lifecycle (`0.11.2`), and the work done for the 2026-10-13
|
|
5
8
|
requirements list. `CONSUMER_GUIDE.md` is the full reference; this file says what changed and what to do
|
|
@@ -25,7 +28,7 @@ Each item says what changed and what agents-core has to do.
|
|
|
25
28
|
| # | change | what to do |
|
|
26
29
|
|---|---|---|
|
|
27
30
|
| 1 | **A prompt sent while a turn runs is steered by default** (`busyDelivery: "steer"`, was `"queue"`). | agents-core already passes `delivery: "steer"` when a turn runs. Elsewhere, set `busyDelivery: "queue"` to keep the old behavior. |
|
|
28
|
-
| 2 | **Silent turns now fail as stalled.** No output for
|
|
31
|
+
| 2 | **Silent turns now fail as stalled.** No output for 600 s (10 min) after the request, or 900 s (15 min) between outputs (tools and permissions pause the clock; the defaults were 120 s and 180 s before 0.12.1), fails the operation with `OperationStalledError` (`code: "stalled"`). Agent-owned conversations record an error record and mark the partial reply failed. | Handle `stalled` like other turn failures. Raise or disable limits with `operationLifecycle: { turns: { firstOutputMs, nextOutputMs } }` (`false` disables one). |
|
|
29
32
|
| 3 | **The conversation reconnects by itself** after the provider process exits or is force-stopped, on the next operation (`provider_reconnected`, `via: loaded \| recovered \| fresh`). | If agents-core retires a conversation whose provider died, it can keep it instead and prompt again. |
|
|
30
33
|
| 4 | **Queued messages are held after a failed turn** the provider received. Pending steers run after recovery; the next consumer turn that completes releases the hold. | Show `state.pendingHold` and `pendingMessages[].heldBy` if the UI lists pending messages. With `busyDelivery: "queue"`, send one prompt with `delivery: "steer"` to release. |
|
|
31
34
|
| 5 | **Cancelled results say how the cancel ended:** `cancel: "acknowledged" \| "forced"`. Pending permissions are answered as cancelled, and the permission handler gets an optional `AbortSignal`. | Nothing required. Use the `AbortSignal` to close a permission dialog. |
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# Migrating from 0.12.1 to 0.13
|
|
2
|
+
|
|
3
|
+
For consumers of the published `@qlairoslabs/acp-client` 0.12.1, including
|
|
4
|
+
`~agents` (`libs/agents/agents-core`). See the [consumer guide](CONSUMER_GUIDE.md)
|
|
5
|
+
for complete examples.
|
|
6
|
+
|
|
7
|
+
**Status.** These changes are on `alpha`. The package version remains 0.12.1
|
|
8
|
+
and 0.13 is unpublished. For a local trial, point a disposable
|
|
9
|
+
consumer checkout at a local archive of the target code and use a copy of the
|
|
10
|
+
database. For example, use a `file:/absolute/path/to/acp-client-archive`
|
|
11
|
+
dependency in the trial checkout or replace its local package link. Make the
|
|
12
|
+
archive's dependencies available before starting the consumer.
|
|
13
|
+
|
|
14
|
+
## Before you upgrade
|
|
15
|
+
|
|
16
|
+
- **Back up the SQLite Agent databases before opening them with the new code.**
|
|
17
|
+
A 0.12.1 schema-16 database opens at schema 22 on the reminders build.
|
|
18
|
+
The migration is one way. Older code refuses a migrated database. To roll back, restore the old database
|
|
19
|
+
backup with the matching library version.
|
|
20
|
+
- The upgrade adds the schema-17 durable channel intents and nullable
|
|
21
|
+
`controller_kind`, schema-18 worker assignment and delivery storage, schema-19
|
|
22
|
+
worker records, schema-20 assignment and delivery columns, schema-21
|
|
23
|
+
native metering proof on the operation index, and schema-22 reminder intents,
|
|
24
|
+
cache and wake state. The upgrade also adds the worker
|
|
25
|
+
`role` to conversation rows where it is absent.
|
|
26
|
+
- Separate persisted native harness data from the Agent database. If using
|
|
27
|
+
native conversations, retain the harness home across restarts. The harness
|
|
28
|
+
has its own storage version. Its first durable reminder write activates
|
|
29
|
+
format 7, which older harness binaries refuse.
|
|
30
|
+
|
|
31
|
+
## Breaking changes for 0.12.1 consumers
|
|
32
|
+
|
|
33
|
+
The package entry at `510e2a7` retained all 828 exports from 0.12.1 and
|
|
34
|
+
had 913 exports. At `fb20ed6` it has 915, including the new
|
|
35
|
+
`MessageStatus` and `MessageStatusEvent` types. The package exports map and
|
|
36
|
+
dependencies are unchanged through `fb20ed6`. With one-off reminders, the package
|
|
37
|
+
entry has 924 exports, including nine new reminder names.
|
|
38
|
+
`AgentController` remains a deprecated value and type alias of
|
|
39
|
+
`HarnessController`.
|
|
40
|
+
|
|
41
|
+
| What changed | What to do |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `defaultPermission` was removed. | Replace `"approve"` with `permissions: { default: "allow" }` and `"cancel"` with `permissions: { default: "ask" }`. Omitting the setting means ask. |
|
|
44
|
+
| Permission defaults and rules can settle requests before the prompt handler. | Install a handler or declare a consumer for asks. Update ACP refusal handling for `reject_once` where offered and cancellation otherwise. |
|
|
45
|
+
| `AgentController` and `AgentControllerStartEvent` have new names. | Use `HarnessController` and `ControllerStartEvent`. The deprecated aliases still work. |
|
|
46
|
+
| `conversation.connection` is a `ConversationController`. | Use the shared interface where possible and use `conversation.harnessConnection()` for ACP-specific members. Handle its null return. |
|
|
47
|
+
| Launcher kind includes `"native-harness"`. | Handle the new kind in custom launcher unions and switches. Route it explicitly or reject it if unsupported. |
|
|
48
|
+
| Custom persistence backends must supply `capabilities.channels: boolean`. | Use `channels: false` without a durable channel repository. The repository itself is optional. |
|
|
49
|
+
| Adapter registration now accepts `AgentAdapter` (`Adapter \| NativeAdapter`). | Narrow `AgentAdapterRegistration.adapter`, entries in `AgentConfig.adapters`, and arguments to `AgentAdapterRegistry.register` before reading ACP fields such as `command`. `list()` still returns entries with an `Adapter`. |
|
|
50
|
+
| `PromptHandle` gains required `withdrawAsync(): Promise<boolean>` and `readonly status: MessageStatus`. | Add both members to test doubles and other implementations of `PromptHandle`. |
|
|
51
|
+
| ACP startup can be deferred or cancelled. | Handle `"deferred"` in reopen status switches and distinguish `ConnectionCancelledError` from an ordinary connection failure. |
|
|
52
|
+
| `AgentConversationEvent` and `AgentSessionEvent` add permission events and `items_receipt`. `turn_started` now requires `cause`. | Update exhaustive switches and mocks that construct a turn-start event. |
|
|
53
|
+
| `AgentSessionEvent` and `AgentConversationEvent` gain `message_status`; `ActivityEvent` gains `provider_notice`. | Update exhaustive event and activity switches. |
|
|
54
|
+
| The reminders build adds local and wire reminder events to `AgentSessionEvent` and `AgentConversationEvent`. | Extend exhaustive switches even if reminders are disabled in your application. |
|
|
55
|
+
| `AgentEvent` includes `WorkerEvent`. `AgentEventBus` gains required `subscribeWorkers`. | Update exhaustive switches and bus doubles. `AgentEventNotification` still defaults to committed-record notifications, so ordinary `subscribe` listeners retain their type. |
|
|
56
|
+
| `MeteringProvenance.source` gains `"native_ledger"`. | Extend exhaustive provenance switches, even if the application currently uses ACP only. |
|
|
57
|
+
|
|
58
|
+
## New behavior when you enable native conversations or orchestration
|
|
59
|
+
|
|
60
|
+
| What changed | What to do |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| Native channels and workers can use new persistence repositories. | Enable each capability only with its repository. Configure both worker repositories and message content capture for orchestration. |
|
|
63
|
+
| Persistence resolvers can see the optional worker role. | Use `ConversationPersistenceContext.role` to set worker-specific retention if needed. |
|
|
64
|
+
| Native stop, close, suspension and resume have backend-specific behavior. | Await channel operations, read typed error codes, and handle `NativeInputStoppedError` for submitted, untaken prompts on shutdown. |
|
|
65
|
+
| Native turns produce metering evidence. | Read `nativeUsage` and partial coverage fields. Treat missing usage and pricing as unknown. |
|
|
66
|
+
| Worker results have durable assignment and delivery state. | Read outcomes through the worker API and retry blocked native notices explicitly. |
|
|
67
|
+
|
|
68
|
+
## Message status and provider notices
|
|
69
|
+
|
|
70
|
+
Read `handle.status` for the latest state of an individual prompt and handle
|
|
71
|
+
`message_status { id, status, turnId? }` for live updates. `turnId` is optional.
|
|
72
|
+
Status is live only and history reads after a restart do not restore it.
|
|
73
|
+
Native conversations use harness milestones. ACP approximates delivery at
|
|
74
|
+
dispatch and marks a message seen at the first provider output. Use the
|
|
75
|
+
prompt result to determine how its turn ended. Existing message events still
|
|
76
|
+
work. See [Message status](CONSUMER_GUIDE.md#message-status).
|
|
77
|
+
|
|
78
|
+
If you render activities, handle `provider_notice` for provider retries,
|
|
79
|
+
warnings and reported failures. ACP clients now advertise version 1 of the
|
|
80
|
+
JetBrains AIR `sessionFailure` extension in `clientCapabilities._meta`.
|
|
81
|
+
Agents may send AIR notices in response to this advertisement. acp-client
|
|
82
|
+
also recognizes the Codex ACP fallback shape. Raw activity callbacks can
|
|
83
|
+
read optional `meta` on `session_info` and `usage` for unmodeled update
|
|
84
|
+
metadata. Narrow the value before reading adapter-specific fields. See
|
|
85
|
+
[Provider notices](CONSUMER_GUIDE.md#provider-notices-retries-warnings-and-failures).
|
|
86
|
+
|
|
87
|
+
## Native reminders
|
|
88
|
+
|
|
89
|
+
Use `conversation.reminders` on Agent-owned native conversations and page
|
|
90
|
+
all reminder views through `agent.reminders.list({ after, limit })`.
|
|
91
|
+
Check `conversationCapabilities.reminders`. Native support is provisional
|
|
92
|
+
until negotiation. A compatible harness advertises `capabilities.reminders`
|
|
93
|
+
and `reminderLimits`. ACP has no reminder support. For repeating schedules,
|
|
94
|
+
check `conversationCapabilities.routines` after executable open. A
|
|
95
|
+
0032-compatible harness must advertise both routine and unattended guard
|
|
96
|
+
support. Set `harness.config.limits.unattendedTurns` when enabling the guard.
|
|
97
|
+
The setting accepts a positive safe integer or `"unlimited"`. The latter
|
|
98
|
+
binds `Number.MAX_SAFE_INTEGER` and keeps the guard counting while effectively
|
|
99
|
+
leaving unattended paid turns uncapped. A spending cap remains a TODO.
|
|
100
|
+
The harness persists the numeric value and refuses later attempts to change
|
|
101
|
+
it. `"unlimited"` and the numeric maximum are equivalent.
|
|
102
|
+
|
|
103
|
+
Custom backends can optionally expose a `reminders` repository and the
|
|
104
|
+
`capabilities.reminders` flag. SQLite supplies the repository. Without
|
|
105
|
+
durable storage, stopped mutations that need to write reject with `reminders_unavailable`
|
|
106
|
+
as the `ReminderError.code`. SQLite journals
|
|
107
|
+
offline changes for the next executable open. The library keeps SQLite schema
|
|
108
|
+
22 and accepts existing one-off journal rows. Routine and retry metadata fit
|
|
109
|
+
in the existing JSON values. A 0032 harness binds its unattended-turn guard
|
|
110
|
+
using its own session format 8. Reads while stopped show
|
|
111
|
+
last-confirmed cached rows and local intents. A refused intent stays visible
|
|
112
|
+
as blocked. Use `discardBlocked` to remove it locally and create a new ID
|
|
113
|
+
when correcting a blocked create. The harness remains authoritative.
|
|
114
|
+
|
|
115
|
+
The local `reminder_intent_recorded`, `reminder_intent_confirmed`,
|
|
116
|
+
`reminder_intent_blocked` and `reminder_intent_discarded` events track
|
|
117
|
+
writes. The harness separately reports `reminder_changed`, `reminder_fired`,
|
|
118
|
+
`reminder_cancelled` and `reminder_expired`. A fired event means a notice
|
|
119
|
+
was queued. Routine consumers can also receive `routine_disposition` and
|
|
120
|
+
`routine_migration_blocked`. Extend exhaustive event switches and handle
|
|
121
|
+
routine rows, which can be active after a fire and may carry remaining count,
|
|
122
|
+
timezone data and migration status. Historical events are not replayed.
|
|
123
|
+
See [Reminder routines](CONSUMER_GUIDE.md#reminder-routines).
|
|
124
|
+
|
|
125
|
+
Only the file-backed SQLite owner schedules a cold wake, while the Agent
|
|
126
|
+
is running. Explicit harness stop retains the wake. Closing the Agent
|
|
127
|
+
clears the timer and the next Agent open rearms from storage. Idle stop
|
|
128
|
+
is opt-in through `harness.idleStopMs`. See the
|
|
129
|
+
[one-off reminders guide](CONSUMER_GUIDE.md#one-off-reminders-experimental)
|
|
130
|
+
for scheduling, expiry, cache freshness, tools, wake limitations and
|
|
131
|
+
configuration.
|
|
132
|
+
|
|
133
|
+
## Permissions
|
|
134
|
+
|
|
135
|
+
The replacement applies to raw ACP clients, direct and managed sessions, Agent
|
|
136
|
+
configuration, conversation defaults and conversation runtime settings. For an
|
|
137
|
+
Agent-owned conversation, each more specific `permissions` object replaces the
|
|
138
|
+
whole inherited object, including its rules. The order is Agent,
|
|
139
|
+
`conversationDefaults`, conversation settings, then `runtime`.
|
|
140
|
+
|
|
141
|
+
`permissionRule(request)` can override the decision before ACP rule matching.
|
|
142
|
+
Rules use `kind:` and exact `command:` keys. The stricter match wins. Native asks
|
|
143
|
+
use the callback and default, while the harness itself grants or denies tools
|
|
144
|
+
by name. Allow and deny are final. In particular, default allow can skip a
|
|
145
|
+
prompt handler that previously ran. An ask with no handler and no eligible
|
|
146
|
+
consumer is refused. Use `answersPermissions`, `permissionTimeoutMs` and
|
|
147
|
+
`answerPermission` to implement a conversation approval UI. See
|
|
148
|
+
[permission configuration and events](CONSUMER_GUIDE.md#permissions-and-approval-ui).
|
|
149
|
+
|
|
150
|
+
## Controllers, launchers and persistence
|
|
151
|
+
|
|
152
|
+
Use `conversationCapabilities` for backend-neutral capability checks.
|
|
153
|
+
For raw ACP access, narrow with `harnessConnection()`. Raw ACP capabilities
|
|
154
|
+
still require a connected ACP harness. `AgentControllerConfig` keeps its name.
|
|
155
|
+
The package exports `ConversationController`, `TurnRun`, `TurnContent`,
|
|
156
|
+
`PreparedTurn`, `TurnStarted`, `TurnTook`, `TurnEvent`, `TurnCause`, `ItemRef`,
|
|
157
|
+
`StartResult`, `UsageListener`, `ConversationCapabilities`, `BackendCapabilities`,
|
|
158
|
+
`UnsupportedError`, `ItemsReceipt`, `NativeInputStoppedError` and
|
|
159
|
+
`ConnectionCancelledError`. Permission, orchestrator and worker types include
|
|
160
|
+
`PermissionSettings`, `PermissionLevel`, `WorkerPermissionSource`,
|
|
161
|
+
`OrchestratorConfig`, `WorkerConsumerApi` and `WorkerEvent`.
|
|
162
|
+
For the full list and behavioral details, see the
|
|
163
|
+
[controller changelog](CHANGELOG-controller-interface.md).
|
|
164
|
+
|
|
165
|
+
An `AcpLauncher.prepare()` implementation now receives `"acp"`, `"pty"`, or
|
|
166
|
+
`"native-harness"`. The latter launches the configured native host command.
|
|
167
|
+
A persistence resolver gets the conversation ID, participants, optional title
|
|
168
|
+
and metadata, `adopted` and optional `role: "worker"`. Existing resolvers can
|
|
169
|
+
ignore role if they do not distinguish worker retention. Owned turn finalization
|
|
170
|
+
also receives `messageIds` on successful, cancelled and failed operations.
|
|
171
|
+
|
|
172
|
+
For a custom Agent persistence backend, the optional repositories are
|
|
173
|
+
`channels`, `workers` and `workerDelivery`, with matching
|
|
174
|
+
`capabilities.channels`, `capabilities.workers` and
|
|
175
|
+
`capabilities.workerDelivery`. The only newly required member of an existing
|
|
176
|
+
persistence backend or configuration interface is
|
|
177
|
+
`PersistenceCapabilities.channels: boolean`. Use `false` without a channel
|
|
178
|
+
repository. `capabilities.workers` and `capabilities.workerDelivery` are optional
|
|
179
|
+
booleans. Native operation can fall back to host channel
|
|
180
|
+
records if there is no durable channel repository. Orchestration requires
|
|
181
|
+
both worker repositories and message content capture. Where channels are
|
|
182
|
+
durable, reading the channel portion of `host.records` throws. Use
|
|
183
|
+
`await host.pendingChannelChanges()`. Submission records still belong to the
|
|
184
|
+
configured host records.
|
|
185
|
+
|
|
186
|
+
Structural test doubles of the concrete classes can also need new members.
|
|
187
|
+
`Agent` now exposes `nativeHarness` (null when no native harness is configured).
|
|
188
|
+
`AgentAdapterRegistry` adds `native(id)`.
|
|
189
|
+
`SqliteAgentPersistence` exposes required `channels` and `workers` repositories.
|
|
190
|
+
`HarnessController` and its deprecated alias gain `conversationCapabilities`,
|
|
191
|
+
`send`, `subscribeTurns`, `prepareTurn`, `prepareInternalPrompt` and
|
|
192
|
+
`abandonTurn`. `AgentConversation` and its `AgentSession` alias gain
|
|
193
|
+
`conversationCapabilities`, `harnessConnection`, `answerPermission`,
|
|
194
|
+
`withdrawAsync` and `attachObservation`.
|
|
195
|
+
|
|
196
|
+
## Startup and native shutdown
|
|
197
|
+
|
|
198
|
+
Agent-owned ACP defaults to `providerStart: "on_open"`. Set
|
|
199
|
+
`conversationDefaults.providerStart` or the conversation's
|
|
200
|
+
`runtime.providerStart` to `"on_first_use"` for lazy startup. A deferred reopen
|
|
201
|
+
can report `providerSession: "deferred"`. Direct factories accept a startup
|
|
202
|
+
signal. An explicitly stopped or superseded connection rejects with
|
|
203
|
+
`ConnectionCancelledError` and code `connection_cancelled`.
|
|
204
|
+
|
|
205
|
+
`await host.suspendChannel(id)` and `await host.resumeChannel(id)` can reject.
|
|
206
|
+
`HarnessUnavailableError.code` distinguishes `not_running`, `failed`,
|
|
207
|
+
`stopped`, `open_timeout`, `start_failed` and `reopen_failed`. Resume can
|
|
208
|
+
also reject with `channel_retired` while retirement is pending.
|
|
209
|
+
|
|
210
|
+
Local withdrawal is synchronous. Use `withdrawAsync` for a submitted native
|
|
211
|
+
input. During stop and close, the library gives submitted unclaimed inputs a
|
|
212
|
+
bounded withdrawal attempt before interrupting. Submitted inputs never taken
|
|
213
|
+
by a turn reject with `NativeInputStoppedError`. A taken prompt resolves as
|
|
214
|
+
cancelled and includes any completed reply text and its metering record.
|
|
215
|
+
Stopping before the first message completes returns empty text. The Agent
|
|
216
|
+
attempts to recover committed replies for persistence.
|
|
217
|
+
|
|
218
|
+
## Native metering and delivery
|
|
219
|
+
|
|
220
|
+
Native metering uses the harness call ledger with `best_effort` by default.
|
|
221
|
+
It retains per-attempt evidence, uncertainty and partial coverage. Native
|
|
222
|
+
metering ignores consumer pricing policies and inference sources. Known
|
|
223
|
+
usage of earlier turns can be recorded separately in `unallocatedUsage`.
|
|
224
|
+
The current native wire cannot satisfy `billing_required`. See
|
|
225
|
+
[Native turn metering](CONSUMER_GUIDE.md#native-turn-metering) and the
|
|
226
|
+
[metering changelog](CHANGELOG-metering.md).
|
|
227
|
+
|
|
228
|
+
Worker delivery stores the assignment identity and its outcome. An ACP
|
|
229
|
+
destination receives an out-of-band message. A native destination receives a
|
|
230
|
+
durable notice. Eligible notices can be retried without redispatching worker
|
|
231
|
+
work. See the [orchestrator guide](CONSUMER_GUIDE.md#orchestrator-and-worker-delivery-experimental).
|
|
232
|
+
|
|
233
|
+
## Other native harness changes
|
|
234
|
+
|
|
235
|
+
The standalone native harness managed session config can opt into `timelineTools: true` to make
|
|
236
|
+
`search_timeline` and `read_message` available under tool policy. Search can
|
|
237
|
+
span channels in the same session. Model-call pagination now uses bounded
|
|
238
|
+
page reads without loading full session history. The standalone development
|
|
239
|
+
CLI also has new controls for instructions and debug tools. See the
|
|
240
|
+
[native harness guide](src/native-harness/README.md).
|
|
241
|
+
|
|
242
|
+
## agents-core specifically
|
|
243
|
+
|
|
244
|
+
A scratch type-check compared the current agents-core checkout against its
|
|
245
|
+
installed 0.12.1 and the `510e2a7` archive. The baseline already has type
|
|
246
|
+
errors. The archive adds 13 diagnostics across the following four groups.
|
|
247
|
+
|
|
248
|
+
| Location under `src/` | Exact edit |
|
|
249
|
+
| --- | --- |
|
|
250
|
+
| `agent/chat/session.ts` | Keep the app's `default_permission` and CLI option names. Import `PermissionSettings` from the package and make it the return type of `libraryPermission`, returning `{ default: policy === "approve" ? "allow" : "ask" }`. Set `permissions: libraryPermission(defaultPermission ?? agentCfg.default_permission)` on the session config. Pass `permissions: config.permissions` to both `loadAgentSession` and `createAgentSession`. |
|
|
251
|
+
| `agent/chat/sqlite-session.ts` | In `conversationDefaults` set `permissions: { default: (canonical ? canonical.input.permission.policy : opts.defaultPermission ?? agentCfg!.default_permission) === "approve" ? "allow" : "ask" }`. Update the comment in `hub/index.ts` about the prompt handler. It runs for ask only, and an unattended ask fails closed. |
|
|
252
|
+
| `__tests__/integration/docker-image-candidate-acp.test.ts`, `__tests__/integration/opencode-model-catalog.test.ts`, `gateway/docker-delivery.test.ts` | Replace the library-level `defaultPermission: "cancel"` with `permissions: { default: "ask" }`. |
|
|
253
|
+
| `agent/chat/launcher.ts` | For the current ACP-only launcher add `if (kind === "native-harness") throw new Error("Native harness launch is unsupported by this runtime");` before passing `kind` to `prepareProcessLaunch`. To enable native launches later, extend `RuntimeProcessKind` and its runtime handlers to route the new kind explicitly. |
|
|
254
|
+
| `hub/index.ts` | Keep the degraded PTY special case. Replace `session.connection.currentClient.isConnected` with `session.harnessConnection()?.currentClient.isConnected ?? false` inside the existing try/catch. Update session test doubles used by that branch to supply `harnessConnection()` with the expected client state. |
|
|
255
|
+
| `configuration/recording/acp-contract.test.ts` | Remove the public-package import of `ConversationPersistenceContext` from this fixture. Type `context` as `Parameters<ConversationSettingsResolver["settingsFor"]>[0]` using the fixture's existing resolver import. The error in the linked archive is a split branded type identity from mixing relative package internals with a public package type. The resolver contract test can stay on its test-only internal import path. |
|
|
256
|
+
|
|
257
|
+
Update the loose session doubles as well. Add
|
|
258
|
+
`harnessConnection() { return this.connection; },` next to the existing
|
|
259
|
+
`connection` property in these files under `src/`:
|
|
260
|
+
|
|
261
|
+
- `__tests__/integration/steer-delivery.test.ts:35`
|
|
262
|
+
- `__tests__/integration/user-chat-acceptance.test.ts:36`
|
|
263
|
+
- `__tests__/kit/harness.ts:17`
|
|
264
|
+
- `__tests__/unit/hub.test.ts:752`. Keep the connection mutations on lines
|
|
265
|
+
624 and 660. The method must return the same mutable object.
|
|
266
|
+
|
|
267
|
+
The type-check alone cannot detect these doubles. The two integration files
|
|
268
|
+
pass all 9 and 11 tests respectively with the method in place. The unit
|
|
269
|
+
`hub.test.ts` could not be run in the scratch layout because of a macro
|
|
270
|
+
import.
|
|
271
|
+
|
|
272
|
+
If an app-level `cancel` policy must refuse even when an app handler is
|
|
273
|
+
accidentally attached, use `default: "deny"` for that explicit app policy and
|
|
274
|
+
reserve `default: "ask"` for the app's approval workflow. That is an app policy
|
|
275
|
+
choice separate from the library's 0.12.1 mapping above.
|
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@ agents (Codex, Claude, Kimi, Pi, Gemini, Copilot, OpenCode, …) over JSON-RPC 2
|
|
|
5
5
|
**degraded PTY fallback** for agents that don't speak ACP.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
import {
|
|
8
|
+
import { HarnessController, ADAPTERS } from "@qlairoslabs/acp-client";
|
|
9
9
|
|
|
10
|
-
const agent = new
|
|
10
|
+
const agent = new HarnessController({ adapter: ADAPTERS.codex, adapterId: "codex" });
|
|
11
11
|
await agent.start();
|
|
12
12
|
const { text } = await agent.prompt("Say hello in one sentence.");
|
|
13
13
|
console.log(text);
|
|
@@ -58,8 +58,8 @@ bun add -g @qlairoslabs/acp-client
|
|
|
58
58
|
|
|
59
59
|
| Abstraction | What it is |
|
|
60
60
|
|---|---|
|
|
61
|
-
| **`
|
|
62
|
-
| **`AgentSession`** | A **durable conversation** with a stable identity that survives reconnects and mode-swaps. Wraps
|
|
61
|
+
| **`HarnessController`** | The control plane for **one** agent process: start/stop, prompt, interrupt, switch sessions, swap mode (normal ⇄ degraded), introspect capabilities & config. |
|
|
62
|
+
| **`AgentSession`** | A **durable conversation** with a stable identity that survives reconnects and mode-swaps. Wraps a `ConversationController` and (optionally) records itself to a catalog. The front face for consumers that want persistence. |
|
|
63
63
|
| **`SessionManager` + `SessionStore`** | The session **catalog**: routing metadata (which adapter/mode/cwd a session belongs to), *not* conversation content. Merges your catalog with the agent's live `session/list`. Ships a `FileSessionStore`; inject your own (e.g. a database) for custom backends. |
|
|
64
64
|
| **Adapter** | Just how to *launch* an agent: the spawn command. `ADAPTERS` has convenience presets (`codex`, `claude`, `kimi`, `pi`, `gemini`, `copilot`, `opencode`); you can also pass a raw `{ command: [...] }`. Capabilities and commands are discovered after ACP initialization. |
|
|
65
65
|
| **Mode** | `"normal"` (real ACP over JSON-RPC) or `"degraded"` (drive the native CLI through a PTY and parse it). Both implement the same `AgentClient` output contract. |
|
|
@@ -76,17 +76,17 @@ see the [consumer guide](./CONSUMER_GUIDE.md).
|
|
|
76
76
|
|
|
77
77
|
```ts
|
|
78
78
|
import {
|
|
79
|
-
|
|
79
|
+
HarnessController,
|
|
80
80
|
ADAPTERS,
|
|
81
81
|
createConsoleLogger,
|
|
82
82
|
formatResponseMessages,
|
|
83
83
|
} from "@qlairoslabs/acp-client";
|
|
84
84
|
|
|
85
|
-
const agent = new
|
|
85
|
+
const agent = new HarnessController({
|
|
86
86
|
adapter: ADAPTERS.codex,
|
|
87
87
|
adapterId: "codex",
|
|
88
88
|
cwd: process.cwd(),
|
|
89
|
-
|
|
89
|
+
permissions: { default: "ask" }, // "allow" to auto-accept tool permissions
|
|
90
90
|
logger: createConsoleLogger({ minLevel: "info" }),
|
|
91
91
|
});
|
|
92
92
|
|
|
@@ -123,15 +123,16 @@ first — and `name` is prose meant for a human. The four kinds are `allow_once`
|
|
|
123
123
|
`allow_always`, `reject_once`, `reject_always`; treat the `_always` pair as policy, since
|
|
124
124
|
they persist into the agent's settings and outlive the session.
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
Set `permissions: { default: "ask" | "allow" | "deny", rules? }` on the controller.
|
|
127
|
+
The default is `ask`. Allow and deny are final. The prompt handler answers only
|
|
128
|
+
an ask. Without a handler or an eligible conversation consumer, an ask is refused.
|
|
129
|
+
ACP refusal selects `reject_once` where offered and cancels otherwise.
|
|
130
|
+
See [permission configuration and events](./CONSUMER_GUIDE.md#permissions-and-approval-ui).
|
|
130
131
|
|
|
131
132
|
Every session update except the response text reaches `onActivity`, discriminated by
|
|
132
133
|
`kind`: `thinking`, `user_message`, `tool`, `tool_update`, `plan`, `plan_update`,
|
|
133
|
-
`plan_removed`, `commands`, `mode`, `usage`, `session_info`, `config`,
|
|
134
|
-
anything the protocol adds later (the raw payload rides along on `raw`).
|
|
134
|
+
`plan_removed`, `commands`, `mode`, `usage`, `session_info`, `config`, `provider_notice`,
|
|
135
|
+
and `unknown` for anything the protocol adds later (the raw payload rides along on `raw`).
|
|
135
136
|
|
|
136
137
|
**Tool calls arrive incrementally.** Agents announce a call before they know much about it
|
|
137
138
|
and fill it in afterwards, so the command, the diff and the output usually land on a later
|
|
@@ -475,7 +476,7 @@ try {
|
|
|
475
476
|
|
|
476
477
|
The older low-level controller REPL remains available as `runRepl()` plus
|
|
477
478
|
`createControllerCommands()`. Its `/new`, `/load`, `/resume`, and `/fork` commands replace
|
|
478
|
-
the `
|
|
479
|
+
the `HarnessController`'s ACP provider session directly; they do not manage multiple stable
|
|
479
480
|
`AgentSession` objects. A consumer-owned managed CLI belongs above both command sets.
|
|
480
481
|
|
|
481
482
|
### CLI
|
|
@@ -518,7 +519,7 @@ then `~/.acp-client`. A recorded built-in adapter is resolved automatically on o
|
|
|
518
519
|
restore. Supply `--adapter-command` again for a custom adapter. Use `--no-repl` when a
|
|
519
520
|
create/open/restore command should only acquire, report, checkpoint, and stop the session.
|
|
520
521
|
|
|
521
|
-
The older `chat` command remains the direct `
|
|
522
|
+
The older `chat` command remains the direct `HarnessController` CLI for compatibility. It
|
|
522
523
|
manipulates one provider thread and is deliberately separate from the managed catalog.
|
|
523
524
|
|
|
524
525
|
Activity markers (thinking/tool) show by default; `--no-activity` disables them.
|
|
@@ -550,7 +551,7 @@ opt-in subpaths.
|
|
|
550
551
|
|
|
551
552
|
| Import | Contents |
|
|
552
553
|
|---|---|
|
|
553
|
-
| `@qlairoslabs/acp-client` | Core: `
|
|
554
|
+
| `@qlairoslabs/acp-client` | Core: `HarnessController`, `AgentSession`, `AcpClient`, `SessionManager`, `FileSessionStore`, `ADAPTERS`, loggers, types. |
|
|
554
555
|
| `@qlairoslabs/acp-client/activity` | `ActivityAggregator`, `foldRecords`, `foldFrame`, `wireFrames` — the delta→full-state fold. No runtime imports, so it is safe to compile for a browser. |
|
|
555
556
|
| `@qlairoslabs/acp-client/repl` | `runAgentSessionRepl`, `createAgentSessionCommands`, plus low-level `runRepl` and `createControllerCommands`. |
|
|
556
557
|
| `@qlairoslabs/acp-client/degraded` | The PTY fallback transport (`Bun.spawn({ terminal })` + xterm parsing). |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlairoslabs/acp-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0-alpha.1",
|
|
4
4
|
"description": "Embeddable Agent Client Protocol (ACP) client library with degraded PTY fallback.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
"CHANGELOG-metering.md",
|
|
39
39
|
"CHANGELOG-operation-lifecycle.md",
|
|
40
40
|
"CHANGELOG-consumer-fixes.md",
|
|
41
|
-
"
|
|
41
|
+
"CHANGELOG-controller-interface.md",
|
|
42
|
+
"MIGRATION-0.10-to-0.12.md",
|
|
43
|
+
"MIGRATION-0.12-to-0.13.md"
|
|
42
44
|
],
|
|
43
45
|
"exports": {
|
|
44
46
|
".": "./src/index.ts",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type * as schema from "@agentclientprotocol/sdk";
|
|
2
|
+
import type { TerminalHandlers } from "./transport/acp-transport.ts";
|
|
3
|
+
import type { ClientCapabilityConfig } from "./capabilities.ts";
|
|
4
|
+
|
|
5
|
+
export interface FilesystemHandlers {
|
|
6
|
+
readTextFile?: (
|
|
7
|
+
params: schema.ReadTextFileRequest,
|
|
8
|
+
) => Promise<schema.ReadTextFileResponse>;
|
|
9
|
+
writeTextFile?: (
|
|
10
|
+
params: schema.WriteTextFileRequest,
|
|
11
|
+
) => Promise<schema.WriteTextFileResponse>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AcpClientHandlers {
|
|
15
|
+
terminal?: TerminalHandlers | false;
|
|
16
|
+
filesystem?: FilesystemHandlers | false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ResolvedClientHandlers {
|
|
20
|
+
terminal: "builtin" | TerminalHandlers | false;
|
|
21
|
+
readTextFile: "builtin" | NonNullable<FilesystemHandlers["readTextFile"]> | false;
|
|
22
|
+
writeTextFile: "builtin" | NonNullable<FilesystemHandlers["writeTextFile"]> | false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function resolveClientHandlers(
|
|
26
|
+
handlers: AcpClientHandlers | undefined,
|
|
27
|
+
legacy: ClientCapabilityConfig | undefined,
|
|
28
|
+
): ResolvedClientHandlers {
|
|
29
|
+
const terminal = handlers?.terminal !== undefined
|
|
30
|
+
? handlers.terminal
|
|
31
|
+
: legacy?.terminal === false ? false : "builtin";
|
|
32
|
+
|
|
33
|
+
if (handlers?.filesystem === false) {
|
|
34
|
+
return { terminal, readTextFile: false, writeTextFile: false };
|
|
35
|
+
}
|
|
36
|
+
if (handlers?.filesystem) {
|
|
37
|
+
return {
|
|
38
|
+
terminal,
|
|
39
|
+
readTextFile: handlers.filesystem.readTextFile ?? false,
|
|
40
|
+
writeTextFile: handlers.filesystem.writeTextFile ?? false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
terminal,
|
|
45
|
+
readTextFile: legacy?.fs?.readTextFile === false ? false : "builtin",
|
|
46
|
+
writeTextFile: legacy?.fs?.writeTextFile === false ? false : "builtin",
|
|
47
|
+
};
|
|
48
|
+
}
|
package/src/activity.ts
CHANGED
|
@@ -464,6 +464,9 @@ export class ActivityAggregator {
|
|
|
464
464
|
case "config":
|
|
465
465
|
case "session_info":
|
|
466
466
|
return this.minted(event.kind);
|
|
467
|
+
case "provider_notice":
|
|
468
|
+
// Revisions of one notice share an id, so they update one activity.
|
|
469
|
+
return this.minted(`notice-${event.noticeId}`);
|
|
467
470
|
default:
|
|
468
471
|
return this.minted(`${event.kind}-${this.nextCount(event.kind)}`);
|
|
469
472
|
}
|
package/src/adapters.ts
CHANGED
|
@@ -17,6 +17,31 @@ export interface Adapter {
|
|
|
17
17
|
displayName?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* A conversation on a native adapter is a channel of the Agent's own harness session, not a process of
|
|
22
|
+
* its own. The harness itself is configured once on the Agent (`AgentConfig.harness`): two native
|
|
23
|
+
* adapters differ only in channel defaults.
|
|
24
|
+
*/
|
|
25
|
+
export interface NativeAdapter {
|
|
26
|
+
kind: "native";
|
|
27
|
+
/** Seeds a new channel's policy when the conversation sets none. */
|
|
28
|
+
defaultPolicy?: string;
|
|
29
|
+
displayName?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** What an Agent's adapter directory takes. */
|
|
33
|
+
export type AgentAdapter = Adapter | NativeAdapter;
|
|
34
|
+
|
|
35
|
+
export function isNativeAdapter(adapter: AgentAdapter): adapter is NativeAdapter {
|
|
36
|
+
return (adapter as NativeAdapter).kind === "native";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The command a native adapter shows where an `Adapter` is expected (catalogs, display). It is never
|
|
41
|
+
* spawned for a native conversation: the controller factory selects the native controller first.
|
|
42
|
+
*/
|
|
43
|
+
export const NATIVE_ADAPTER_COMMAND = Object.freeze(["native-harness"]) as readonly string[];
|
|
44
|
+
|
|
20
45
|
/**
|
|
21
46
|
* Convenient presets. NOT exhaustive and NOT authoritative — a caller can always pass
|
|
22
47
|
* a raw `{ command: [...] }`. These only encode how to start the binary; they say
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import type { AgentConversationId } from "../../agent-ids.ts";
|
|
3
|
+
import type { PersistenceBackend } from "../../persistence/backend.ts";
|
|
4
|
+
import type { ProviderAttachmentState } from "../../persistence/provider-attachment.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Write the provider-session row of a loaded session that no conversation had recorded yet (an adoption). A
|
|
8
|
+
* loaded thread is "recorded" in memory already, so this is the one write that makes it durable; the
|
|
9
|
+
* identity delivery cursors restart, as for any new provider context.
|
|
10
|
+
*/
|
|
11
|
+
export async function recordAdoptedProviderSession(
|
|
12
|
+
persistenceBackend: PersistenceBackend,
|
|
13
|
+
attachment: ProviderAttachmentState,
|
|
14
|
+
id: AgentConversationId,
|
|
15
|
+
transitionId: string,
|
|
16
|
+
): Promise<void> {
|
|
17
|
+
if (attachment.kind === "absent") throw new Error("the adopted provider session is not attached");
|
|
18
|
+
const descriptor = attachment.descriptor;
|
|
19
|
+
await persistenceBackend.transaction(async (persistence) => {
|
|
20
|
+
await persistence.identityDelivery?.reset(id, descriptor.internalSessionId);
|
|
21
|
+
await persistence.providerSessions.append({
|
|
22
|
+
providerSessionRecordId: `provider-${randomUUID()}`,
|
|
23
|
+
agentConversationId: id,
|
|
24
|
+
internalSessionId: descriptor.internalSessionId,
|
|
25
|
+
adapterId: descriptor.adapterId,
|
|
26
|
+
mode: descriptor.mode,
|
|
27
|
+
...(descriptor.model ? { model: descriptor.model } : {}),
|
|
28
|
+
activatedAt: descriptor.acquiredAt,
|
|
29
|
+
transitionId,
|
|
30
|
+
metadata: JSON.stringify({ adopted: true }),
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -13,7 +13,7 @@ export async function deleteProviderSession(
|
|
|
13
13
|
access: Omit<ProviderSessionListing, "owners">,
|
|
14
14
|
providerSessionId: string,
|
|
15
15
|
): Promise<true | false | "unsupported"> {
|
|
16
|
-
const client = new AcpClient({ adapter: access.adapter, ...access.client,
|
|
16
|
+
const client = new AcpClient({ adapter: access.adapter, ...access.client, permissions: { default: "ask" } });
|
|
17
17
|
try {
|
|
18
18
|
await client.connect();
|
|
19
19
|
if (!client.capabilities.agent.sessionCapabilities.delete) return "unsupported";
|
|
@@ -2,6 +2,7 @@ import type { Adapter } from "../../adapters.ts";
|
|
|
2
2
|
import type { AgentConversationId } from "../../agent-ids.ts";
|
|
3
3
|
import { ProviderSessionListUnsupportedError } from "../../agent-conversation-errors.ts";
|
|
4
4
|
import { AcpClient, type AcpClientConfig } from "../../client.ts";
|
|
5
|
+
import { fromAcp } from "../../conversation-controller/capabilities.ts";
|
|
5
6
|
|
|
6
7
|
/** A session the provider holds, as `session/list` reports it, and the conversation that owns it, if any. */
|
|
7
8
|
export interface ProviderSessionSummary {
|
|
@@ -43,11 +44,11 @@ export async function listProviderSessions(
|
|
|
43
44
|
const limit = options.limit ?? DEFAULT_PROVIDER_SESSION_LIMIT;
|
|
44
45
|
if (!Number.isInteger(limit) || limit < 1) throw new Error("limit must be a positive integer");
|
|
45
46
|
const cwd = options.cwd ?? listing.client.cwd;
|
|
46
|
-
const client = new AcpClient({ adapter: listing.adapter, ...listing.client, ...(cwd ? { cwd } : {}),
|
|
47
|
+
const client = new AcpClient({ adapter: listing.adapter, ...listing.client, ...(cwd ? { cwd } : {}), permissions: { default: "ask" } });
|
|
47
48
|
const sessions: ProviderSessionSummary[] = [];
|
|
48
49
|
try {
|
|
49
50
|
await client.connect();
|
|
50
|
-
if (!client.capabilities.
|
|
51
|
+
if (!fromAcp(client.capabilities).listSessions) {
|
|
51
52
|
throw new ProviderSessionListUnsupportedError(listing.adapterId);
|
|
52
53
|
}
|
|
53
54
|
let cursor: string | undefined;
|