@qlairoslabs/acp-client 0.12.0 → 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 -3
- package/CHANGELOG-controller-interface.md +258 -0
- package/CHANGELOG-metering.md +29 -0
- package/CHANGELOG-operation-lifecycle.md +15 -1
- package/CONSUMER_GUIDE.md +847 -7
- 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 +30 -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 +10 -0
- package/src/cli/index.ts +3 -3
- package/src/cli/managed.ts +2 -2
- package/src/client.ts +68 -98
- 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
package/src/errors.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
// Library error types. Kept minimal — surface protocol facts, don't over-classify.
|
|
2
2
|
|
|
3
|
+
/** An ACP connection attempt was stopped or superseded. */
|
|
4
|
+
export class ConnectionCancelledError extends Error {
|
|
5
|
+
readonly code = "connection_cancelled";
|
|
6
|
+
|
|
7
|
+
constructor(message = "ACP connection was cancelled") {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "ConnectionCancelledError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
/** The agent process exited unexpectedly (not via stop()). */
|
|
4
14
|
export class ProcessCrashError extends Error {
|
|
5
15
|
constructor(
|
|
@@ -26,3 +36,34 @@ export class TimeoutError extends Error {
|
|
|
26
36
|
this.name = "TimeoutError";
|
|
27
37
|
}
|
|
28
38
|
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A controller was asked for something it can't do (an optional member it doesn't have, or a feature
|
|
42
|
+
* its backend doesn't offer). Callers guard first (the controller's optional methods, the backend's
|
|
43
|
+
* capabilities), so this signals a bug.
|
|
44
|
+
*/
|
|
45
|
+
export class UnsupportedError extends Error {
|
|
46
|
+
constructor(message: string) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = "UnsupportedError";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The controller has no way to reload a provider session (it has no `reconnect`). Recovery treats it as a
|
|
54
|
+
* session the provider no longer has, so the conversation's continuation rule applies (never a raw failure).
|
|
55
|
+
*/
|
|
56
|
+
export class ProviderSessionReloadUnsupportedError extends UnsupportedError {
|
|
57
|
+
constructor() {
|
|
58
|
+
super("this conversation's controller cannot reload a provider session");
|
|
59
|
+
this.name = "ProviderSessionReloadUnsupportedError";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The governing conversation policy refused a worker operation. */
|
|
64
|
+
export class WorkerPolicyError extends Error {
|
|
65
|
+
constructor(readonly rule: "use" | "scope" | "redirect" | "maxOpen") {
|
|
66
|
+
super(`worker operation refused by ${rule} policy`);
|
|
67
|
+
this.name = "WorkerPolicyError";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { HANDOFF_SUMMARY_PROMPT } from "./agent-conversation-continuation.ts";
|
|
2
|
+
import type { HandoffOptions } from "./agent-conversation-contracts.ts";
|
|
3
|
+
|
|
4
|
+
/** Capture handoff options when the operation enters the queue. */
|
|
5
|
+
export function ownHandoffOptions(options: HandoffOptions): HandoffOptions {
|
|
6
|
+
return Object.freeze({
|
|
7
|
+
...(options.summary === undefined ? {} : { summary: options.summary }),
|
|
8
|
+
...(options.target === undefined
|
|
9
|
+
? {}
|
|
10
|
+
: {
|
|
11
|
+
target: Object.freeze({
|
|
12
|
+
adapterId: options.target.adapterId,
|
|
13
|
+
...(options.target.mode === undefined ? {} : { mode: options.target.mode }),
|
|
14
|
+
...(options.target.adapter === undefined
|
|
15
|
+
? {}
|
|
16
|
+
: {
|
|
17
|
+
adapter: Object.freeze({
|
|
18
|
+
...(options.target.adapter.cancelGraceMs === undefined
|
|
19
|
+
? {}
|
|
20
|
+
: { cancelGraceMs: options.target.adapter.cancelGraceMs }),
|
|
21
|
+
...options.target.adapter,
|
|
22
|
+
command: Object.freeze([...options.target.adapter.command]) as unknown as string[],
|
|
23
|
+
...(options.target.adapter.ptyCommand
|
|
24
|
+
? {
|
|
25
|
+
ptyCommand: Object.freeze([
|
|
26
|
+
...options.target.adapter.ptyCommand,
|
|
27
|
+
]) as unknown as string[],
|
|
28
|
+
}
|
|
29
|
+
: {}),
|
|
30
|
+
}),
|
|
31
|
+
}),
|
|
32
|
+
...(options.target.config === undefined
|
|
33
|
+
? {}
|
|
34
|
+
: { config: Object.freeze({ ...options.target.config }) }),
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
37
|
+
...(options.continuation === undefined
|
|
38
|
+
? {}
|
|
39
|
+
: { continuation: Object.freeze({ ...options.continuation }) }),
|
|
40
|
+
...(options.targetPrompt === undefined ? {} : { targetPrompt: options.targetPrompt }),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function normalizeHandoffContinuation(options: HandoffOptions):
|
|
45
|
+
| { readonly kind: "generated"; readonly summaryPrompt: string }
|
|
46
|
+
| { readonly kind: "provided"; readonly content: string }
|
|
47
|
+
| { readonly kind: "none" } {
|
|
48
|
+
if (options.summary !== undefined && options.continuation !== undefined) {
|
|
49
|
+
throw new Error("handoff cannot combine deprecated summary with continuation");
|
|
50
|
+
}
|
|
51
|
+
if (options.target && !options.target.adapterId.trim()) {
|
|
52
|
+
throw new Error("handoff target adapter id cannot be blank");
|
|
53
|
+
}
|
|
54
|
+
if (options.targetPrompt !== undefined && !options.targetPrompt.trim()) {
|
|
55
|
+
throw new Error("handoff target prompt cannot be blank");
|
|
56
|
+
}
|
|
57
|
+
if (options.summary !== undefined) {
|
|
58
|
+
if (!options.summary.trim()) throw new Error("handoff summary cannot be blank");
|
|
59
|
+
return Object.freeze({ kind: "provided", content: options.summary });
|
|
60
|
+
}
|
|
61
|
+
const continuation = options.continuation ?? { kind: "generated" as const };
|
|
62
|
+
if (continuation.kind === "provided") {
|
|
63
|
+
if (!continuation.content.trim()) throw new Error("handoff continuation cannot be blank");
|
|
64
|
+
return Object.freeze({ kind: "provided", content: continuation.content });
|
|
65
|
+
}
|
|
66
|
+
if (continuation.kind === "none") return Object.freeze({ kind: "none" });
|
|
67
|
+
if (continuation.summaryPrompt !== undefined && continuation.summaryInstructions !== undefined) {
|
|
68
|
+
throw new Error("handoff generated continuation cannot combine summaryPrompt and summaryInstructions");
|
|
69
|
+
}
|
|
70
|
+
if (continuation.summaryPrompt !== undefined && !continuation.summaryPrompt.trim()) {
|
|
71
|
+
throw new Error("handoff summary prompt cannot be blank");
|
|
72
|
+
}
|
|
73
|
+
if (continuation.summaryInstructions !== undefined && !continuation.summaryInstructions.trim()) {
|
|
74
|
+
throw new Error("handoff summary instructions cannot be blank");
|
|
75
|
+
}
|
|
76
|
+
const base = continuation.summaryPrompt ?? HANDOFF_SUMMARY_PROMPT;
|
|
77
|
+
const summaryPrompt = continuation.summaryInstructions === undefined
|
|
78
|
+
? base
|
|
79
|
+
: `${base}\n\nAdditional summary instructions:\n${continuation.summaryInstructions}`;
|
|
80
|
+
return Object.freeze({ kind: "generated", summaryPrompt });
|
|
81
|
+
}
|
|
@@ -136,7 +136,7 @@ export class CheckpointBackedIdentityRuntime implements AgentIdentityRuntime {
|
|
|
136
136
|
...(pageCursor ? { cursor: pageCursor } : {}),
|
|
137
137
|
});
|
|
138
138
|
for (const conversation of page.conversations) {
|
|
139
|
-
if (conversation.agentConversationId === targetConversationId || conversation.deletedAt) continue;
|
|
139
|
+
if (conversation.agentConversationId === targetConversationId || conversation.deletedAt || conversation.role === "worker") continue;
|
|
140
140
|
const [cursor, checkpoint, latestMessageSequence] = await Promise.all([
|
|
141
141
|
this.persistence.identityDelivery!.get(
|
|
142
142
|
targetConversationId,
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
export { WorkerPolicyError } from "./errors.ts";
|
|
2
|
+
export type { WorkerConsumerApi } from "./orchestrator/consumer-api.ts";
|
|
3
|
+
export type { DelegationPolicy, WorkerEvent, WorkerSummary } from "./orchestrator/contracts.ts";
|
|
1
4
|
// PUBLIC SURFACE of the core ACP library — re-exports only.
|
|
2
5
|
// NOTE: this barrel must NOT reference ./degraded or ./parser. Those are separate
|
|
3
6
|
// subpath exports (acp-lib/degraded, acp-lib/parser) so importing the core never pulls
|
|
4
7
|
// in node-pty / ollama. See SPEC.md "opt-in by design".
|
|
5
8
|
|
|
9
|
+
export type { OrchestratorConfig } from "./orchestrator/config.ts";
|
|
10
|
+
export type { WorkerPersistence, WorkerRow } from "./persistence/workers.ts";
|
|
6
11
|
export { AcpClient } from "./client.ts";
|
|
7
12
|
export type {
|
|
8
13
|
AcpClientConfig,
|
|
@@ -44,6 +49,7 @@ export type {
|
|
|
44
49
|
CreateAgentConversationConfig,
|
|
45
50
|
OpenAgentConversationConfig,
|
|
46
51
|
OpenOwnedAgentConversationResult,
|
|
52
|
+
ProviderStart,
|
|
47
53
|
AdoptProviderSessionConfig,
|
|
48
54
|
ClearTranscriptOptions,
|
|
49
55
|
ClearTranscriptResult,
|
|
@@ -141,6 +147,7 @@ export type {
|
|
|
141
147
|
MessageRecord,
|
|
142
148
|
AgentMeteringCommitInput,
|
|
143
149
|
MeteringCommitInput,
|
|
150
|
+
MeteringOperationIdentity,
|
|
144
151
|
MeteringPersistence,
|
|
145
152
|
MeteringRecordListOptions,
|
|
146
153
|
MeteringRecordPage,
|
|
@@ -173,6 +180,8 @@ export type {
|
|
|
173
180
|
} from "./persistence/backend.ts";
|
|
174
181
|
|
|
175
182
|
export {
|
|
183
|
+
HarnessController,
|
|
184
|
+
/** @deprecated Renamed `HarnessController`. */
|
|
176
185
|
AgentController,
|
|
177
186
|
parseConfigValue,
|
|
178
187
|
parseBoolean,
|
|
@@ -182,8 +191,11 @@ export {
|
|
|
182
191
|
export type { CommandArgumentDescriptor, CommandDescriptor } from "./command-descriptors.ts";
|
|
183
192
|
export type {
|
|
184
193
|
AgentControllerConfig,
|
|
194
|
+
/** @deprecated Renamed `ControllerStartEvent`. */
|
|
195
|
+
AgentControllerStartEvent,
|
|
185
196
|
AgentMode,
|
|
186
197
|
ControllerCommand,
|
|
198
|
+
ControllerStartEvent,
|
|
187
199
|
ControllerCommandId,
|
|
188
200
|
ConfigValueParseResult,
|
|
189
201
|
SetConfigFromStringResult,
|
|
@@ -252,8 +264,19 @@ export type {
|
|
|
252
264
|
BridgeOptions,
|
|
253
265
|
} from "./agent-client.ts";
|
|
254
266
|
|
|
255
|
-
export { ADAPTERS, buildSpawnCommand } from "./adapters.ts";
|
|
256
|
-
export type { Adapter, AdapterPreset } from "./adapters.ts";
|
|
267
|
+
export { ADAPTERS, buildSpawnCommand, isNativeAdapter } from "./adapters.ts";
|
|
268
|
+
export type { Adapter, AdapterPreset, AgentAdapter, NativeAdapter } from "./adapters.ts";
|
|
269
|
+
export { HarnessIncompatibleError, HarnessUnavailableError, NativeHarnessHost } from "./native/host.ts";
|
|
270
|
+
export type { HarnessUnavailableCode } from "./native/errors.ts";
|
|
271
|
+
export type { ChannelChangeOutcome, NativeApprovalRequest, NativeApprovalResponder, NativeHarnessHostConfig, NativeHostState } from "./native/host.ts";
|
|
272
|
+
export { NativeTurnError } from "./native/controller.ts";
|
|
273
|
+
export { FunctionError, NATIVE_FUNCTION_DEFAULTS } from "./native/functions.ts";
|
|
274
|
+
export type { NativeFunction, NativeFunctionContext, NativeFunctionsConfig } from "./native/functions.ts";
|
|
275
|
+
export type { ToolAvailability, ToolInvocation, ToolInvocationState, ResultReference, TurnPhase } from "./native-harness/src/client.ts";
|
|
276
|
+
export { createFileHostRecords, createMemoryHostRecords } from "./native/records.ts";
|
|
277
|
+
export type { ChannelDesire, NativeHostRecords, PendingChange, Submission } from "./native/records.ts";
|
|
278
|
+
export type { ChannelPersistence } from "./persistence/channels.ts";
|
|
279
|
+
export type { AgentHarnessConfig } from "./agent/config.ts";
|
|
257
280
|
|
|
258
281
|
export { buildClientCapabilities, CLIENT_CAPABILITIES } from "./capabilities.ts";
|
|
259
282
|
export type {
|
|
@@ -285,6 +308,7 @@ export type {
|
|
|
285
308
|
CombinedMessage,
|
|
286
309
|
PromptPart,
|
|
287
310
|
} from "./steering/index.ts";
|
|
311
|
+
export type { MessageStatus, MessageStatusEvent } from "./message-status.ts";
|
|
288
312
|
|
|
289
313
|
export {
|
|
290
314
|
ActivityAggregator,
|
|
@@ -591,6 +615,9 @@ export type {
|
|
|
591
615
|
MeteringEnforcement,
|
|
592
616
|
MeteringPricingStatus,
|
|
593
617
|
MeteringProvenance,
|
|
618
|
+
NativeOperationUsage,
|
|
619
|
+
NativeEarlierCallEvidence,
|
|
620
|
+
NativeEarlierCallSummary,
|
|
594
621
|
MeteringReconciliation,
|
|
595
622
|
CostReconciliation,
|
|
596
623
|
MeteringUsageResult,
|
|
@@ -705,7 +732,24 @@ export type {
|
|
|
705
732
|
} from "./metering/catalog/index.ts";
|
|
706
733
|
export type { UsageNormalization } from "./metering/usage.ts";
|
|
707
734
|
|
|
708
|
-
export { ProcessCrashError, NotConnectedError, TimeoutError } from "./errors.ts";
|
|
735
|
+
export { ConnectionCancelledError, ProcessCrashError, NotConnectedError, TimeoutError, UnsupportedError } from "./errors.ts";
|
|
736
|
+
export { restartConversation } from "./conversation-controller/index.ts";
|
|
737
|
+
export type {
|
|
738
|
+
BackendCapabilities,
|
|
739
|
+
ConversationCapabilities,
|
|
740
|
+
ConversationController,
|
|
741
|
+
PreparedTurn,
|
|
742
|
+
StartResult,
|
|
743
|
+
ItemRef,
|
|
744
|
+
ItemsReceipt,
|
|
745
|
+
TurnCause,
|
|
746
|
+
TurnContent,
|
|
747
|
+
TurnEvent,
|
|
748
|
+
TurnRun,
|
|
749
|
+
TurnStarted,
|
|
750
|
+
TurnTook,
|
|
751
|
+
UsageListener,
|
|
752
|
+
} from "./conversation-controller/index.ts";
|
|
709
753
|
|
|
710
754
|
export { createWireLog } from "./wire-log.ts";
|
|
711
755
|
export type { WireLogOptions } from "./wire-log.ts";
|
|
@@ -749,3 +793,14 @@ export type { MediaStore, MediaInfo, StoredMedia, MediaConfig } from "./media/st
|
|
|
749
793
|
export type { MediaCaptureLevel } from "./media/capture.ts";
|
|
750
794
|
|
|
751
795
|
export type { SharedFile, SharedFilePage, SharedFileQuery, SharedFilesPersistence } from "./media/files.ts";
|
|
796
|
+
|
|
797
|
+
export type * from "./persistence/worker-delivery-contract.ts";
|
|
798
|
+
export type { PermissionLevel, PermissionSettings } from "./permissions/matcher.ts";
|
|
799
|
+
export { NativeInputStoppedError } from "./agent-conversation-errors.ts";
|
|
800
|
+
export type { ConversationPermissionEvent, PermissionResolutionSource, WorkerPermissionSource } from "./permissions/conversation.ts";
|
|
801
|
+
export type { PermissionConsumerConfig } from "./permissions/consumer-config.ts";
|
|
802
|
+
export type { PermissionPolicyConfig } from "./permissions/policy.ts";
|
|
803
|
+
export { ReminderError } from "./native/reminders/schedule.ts";
|
|
804
|
+
export type { ReminderErrorCode, ReminderSchedule, ReminderScheduleInput } from "./native/reminders/schedule.ts";
|
|
805
|
+
export type { Reminder } from "./persistence/reminders.ts";
|
|
806
|
+
export type { ReminderCreate, ReminderEdit, ReminderView, ReminderEvent } from "./native/reminders/service.ts";
|
|
@@ -75,6 +75,8 @@ export class DefaultInternalInferenceManager implements InternalInferenceManager
|
|
|
75
75
|
leaseToken: string;
|
|
76
76
|
attempt: InternalInferenceAttemptRecord;
|
|
77
77
|
metering: InternalInferenceMeteringOperation | null;
|
|
78
|
+
/** Set by `execute`; cleared there, or by `close` when it fences an execution that never ends. */
|
|
79
|
+
heartbeat?: ReturnType<typeof setInterval>;
|
|
78
80
|
}>();
|
|
79
81
|
private readonly fenced = new Set<InternalInferenceId>();
|
|
80
82
|
private readonly pollIntervalMs: number;
|
|
@@ -165,6 +167,9 @@ export class DefaultInternalInferenceManager implements InternalInferenceManager
|
|
|
165
167
|
}
|
|
166
168
|
for (const [id, execution] of this.active) {
|
|
167
169
|
this.fenced.add(id);
|
|
170
|
+
// A fenced execution may never reach its own `finally` (a runtime that ignores abort), so
|
|
171
|
+
// its heartbeat must stop here: persistence closes after this and a later beat would fail.
|
|
172
|
+
if (execution.heartbeat) clearInterval(execution.heartbeat);
|
|
168
173
|
execution.metering?.settled();
|
|
169
174
|
const canRetry = execution.attempt.attemptNumber < this.config.settings.retry.maxAttempts;
|
|
170
175
|
await this.config.repository.fail({
|
|
@@ -238,6 +243,10 @@ export class DefaultInternalInferenceManager implements InternalInferenceManager
|
|
|
238
243
|
let meteringRecord: OperationMeteringRecord | null = null;
|
|
239
244
|
let writes: import("../contracts.ts").ConversationWritePolicy | undefined;
|
|
240
245
|
const heartbeat = setInterval(() => {
|
|
246
|
+
if (this.fenced.has(attempt.internalInferenceId)) {
|
|
247
|
+
clearInterval(heartbeat);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
241
250
|
void this.config.repository.heartbeat(
|
|
242
251
|
attempt.internalInferenceId,
|
|
243
252
|
this.workerId,
|
|
@@ -245,6 +254,8 @@ export class DefaultInternalInferenceManager implements InternalInferenceManager
|
|
|
245
254
|
this.config.settings.leaseDurationMs,
|
|
246
255
|
);
|
|
247
256
|
}, this.config.settings.heartbeatIntervalMs);
|
|
257
|
+
const active = this.active.get(attempt.internalInferenceId);
|
|
258
|
+
if (active) active.heartbeat = heartbeat;
|
|
248
259
|
try {
|
|
249
260
|
const strategy = this.registry.require(
|
|
250
261
|
attempt.purpose,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OperationSupervisor } from "../../operations/supervisor.ts";
|
|
2
2
|
import type { OutputListener } from "../../operations/contracts.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { HarnessController, type AgentControllerConfig } from "../../controller.ts";
|
|
4
4
|
import type { PromptResult } from "../../types.ts";
|
|
5
5
|
import type {
|
|
6
6
|
InternalInferenceRequest,
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
|
|
12
12
|
export interface HarnessInternalInferenceRuntimeConfig {
|
|
13
13
|
controllerConfig(request: InternalInferenceRequest): AgentControllerConfig;
|
|
14
|
-
/** Test/custom seam; production defaults to
|
|
14
|
+
/** Test/custom seam; production defaults to HarnessController. */
|
|
15
15
|
createController?(config: AgentControllerConfig): InternalInferenceController;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -41,11 +41,11 @@ export class HarnessInternalInferenceRuntime implements InternalInferenceRuntime
|
|
|
41
41
|
cwd: request.cwd ?? inherited.cwd,
|
|
42
42
|
mode: "normal",
|
|
43
43
|
mcpServers: [],
|
|
44
|
-
|
|
44
|
+
permissions: { default: "ask" },
|
|
45
45
|
clientHandlers: {},
|
|
46
46
|
};
|
|
47
47
|
const controller = this.config.createController?.(controllerConfig)
|
|
48
|
-
?? new
|
|
48
|
+
?? new HarnessController(controllerConfig);
|
|
49
49
|
let supervisor: OperationSupervisor | undefined;
|
|
50
50
|
const abort = () => supervisor ? supervisor.cancel("abort") : controller.interrupt();
|
|
51
51
|
signal?.addEventListener("abort", abort, { once: true });
|
package/src/launcher.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { Adapter } from "./adapters.ts";
|
|
2
2
|
import { buildPtyCommand, buildSpawnCommand } from "./adapters.ts";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* `native-harness`: the Agent's own harness process (`serve --stdio`), one per Agent. A launcher that
|
|
6
|
+
* wraps commands for an environment (a container, say) wraps this one the same way.
|
|
7
|
+
*/
|
|
8
|
+
export type LaunchKind = "acp" | "pty" | "native-harness";
|
|
5
9
|
|
|
6
10
|
/** A fully resolved host process launch. The environment is exact, not an overlay. */
|
|
7
11
|
export interface PreparedLaunch {
|
|
@@ -33,7 +37,7 @@ export interface LegacyLaunchOptions {
|
|
|
33
37
|
* behavior for callers that have not migrated yet.
|
|
34
38
|
*/
|
|
35
39
|
export async function prepareLaunch(
|
|
36
|
-
kind: LaunchKind,
|
|
40
|
+
kind: Exclude<LaunchKind, "native-harness">,
|
|
37
41
|
launcher: AcpLauncher | undefined,
|
|
38
42
|
legacy: LegacyLaunchOptions,
|
|
39
43
|
): Promise<PreparedLaunch> {
|
|
@@ -74,6 +78,35 @@ export async function prepareLaunch(
|
|
|
74
78
|
};
|
|
75
79
|
}
|
|
76
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the launch of the native harness process. It has no adapter: the command is the harness's own
|
|
83
|
+
* server mode. With a launcher the environment is the launcher's, exactly; without one the process inherits
|
|
84
|
+
* this process's environment plus `env`.
|
|
85
|
+
*/
|
|
86
|
+
export async function prepareNativeLaunch(
|
|
87
|
+
launcher: AcpLauncher | undefined,
|
|
88
|
+
options: { command: readonly string[]; env?: Record<string, string>; cwd?: string },
|
|
89
|
+
): Promise<PreparedLaunch> {
|
|
90
|
+
if (!options.command.length) throw new Error("native harness command cannot be empty");
|
|
91
|
+
if (launcher) {
|
|
92
|
+
const prepared = await launcher.prepare({ kind: "native-harness", targetCommand: [...options.command] });
|
|
93
|
+
if (!prepared.command.length) {
|
|
94
|
+
await prepared.dispose?.();
|
|
95
|
+
throw new Error("launcher returned an empty command");
|
|
96
|
+
}
|
|
97
|
+
if (prepared.spawnEnv == null) {
|
|
98
|
+
await prepared.dispose?.();
|
|
99
|
+
throw new Error("launcher must return a complete spawnEnv");
|
|
100
|
+
}
|
|
101
|
+
return prepared;
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
command: [...options.command],
|
|
105
|
+
spawnCwd: options.cwd,
|
|
106
|
+
spawnEnv: { ...(process.env as Record<string, string>), ...(options.env ?? {}) },
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
77
110
|
/** Wrap a prepared launch's cleanup in an exactly-once async operation. */
|
|
78
111
|
export function onceDispose(dispose?: PreparedLaunch["dispose"]): () => Promise<void> {
|
|
79
112
|
let result: Promise<void> | null = null;
|
package/src/media/parts.ts
CHANGED
|
@@ -96,6 +96,11 @@ export function normalizeParts(parts: readonly MessagePart[]): readonly MessageP
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/** The text of an object-form prompt: its leading text plus its text parts. */
|
|
100
|
+
export function promptInputText(input: { readonly text?: string; readonly parts?: readonly MessagePart[] }): string {
|
|
101
|
+
return partsText(promptParts(input) ?? [{ kind: "text", text: input.text ?? "" }]);
|
|
102
|
+
}
|
|
103
|
+
|
|
99
104
|
/**
|
|
100
105
|
* The text parts, concatenated as they are sent: text parts are segments of one text (separators
|
|
101
106
|
* between combined messages are their own text parts), so nothing is inserted between them.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// One status per user message, the same for every conversation: how far a message has got, from
|
|
2
|
+
// accepted to seen by the model. Built from events the session already has (spec:
|
|
3
|
+
// .res/somelogs.md/11-11+/11-24-SPEC-message-status.md); it adds no new evidence.
|
|
4
|
+
//
|
|
5
|
+
// Native conversations read the harness's milestones (push accepted, turn take, `items_receipt`).
|
|
6
|
+
// ACP conversations approximate: `taken` and `delivered` when the prompt is sent, `seen` at the
|
|
7
|
+
// provider's first output.
|
|
8
|
+
|
|
9
|
+
/** Forward steps, in order, then the two end states. */
|
|
10
|
+
export type MessageStatus = "queued" | "received" | "taken" | "delivered" | "seen" | "withdrawn" | "failed";
|
|
11
|
+
|
|
12
|
+
/** The conversation event reporting a message's new status. */
|
|
13
|
+
export interface MessageStatusEvent {
|
|
14
|
+
readonly kind: "message_status";
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly status: MessageStatus;
|
|
17
|
+
readonly turnId?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const FORWARD: readonly MessageStatus[] = ["queued", "received", "taken", "delivered", "seen"];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Tracks the conversation's own messages. Statuses only move forward; skipped steps are reported in
|
|
24
|
+
* order, so every backend shows the same sequence. Ids it never tracked (external notices in a native
|
|
25
|
+
* receipt) are ignored. Entries outlive the prompt's settlement, so a handle can still be read.
|
|
26
|
+
*/
|
|
27
|
+
export class MessageStatusTracker {
|
|
28
|
+
readonly #status = new Map<string, MessageStatus>();
|
|
29
|
+
readonly #turnOf = new Map<string, string>();
|
|
30
|
+
readonly #idsOfTurn = new Map<string, Set<string>>();
|
|
31
|
+
|
|
32
|
+
constructor(private readonly emit: (event: MessageStatusEvent) => void) {}
|
|
33
|
+
|
|
34
|
+
statusOf(id: string): MessageStatus | undefined {
|
|
35
|
+
return this.#status.get(id);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A message the conversation accepted. */
|
|
39
|
+
accept(id: string): void {
|
|
40
|
+
if (this.#status.has(id)) return;
|
|
41
|
+
this.#status.set(id, "queued");
|
|
42
|
+
this.emit({ kind: "message_status", id, status: "queued" });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The ids a turn carries, so a later turn-level signal (ACP first output) reaches each of them. */
|
|
46
|
+
link(turnId: string, ids: readonly string[]): void {
|
|
47
|
+
for (const id of ids) {
|
|
48
|
+
if (!this.#status.has(id)) continue;
|
|
49
|
+
this.#turnOf.set(id, turnId);
|
|
50
|
+
let set = this.#idsOfTurn.get(turnId);
|
|
51
|
+
if (!set) this.#idsOfTurn.set(turnId, set = new Set());
|
|
52
|
+
set.add(id);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
idsOfTurn(turnId: string): readonly string[] {
|
|
57
|
+
return [...(this.#idsOfTurn.get(turnId) ?? [])];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Move forward to `status`, reporting each skipped step. No effect backwards or after an end state. */
|
|
61
|
+
advance(id: string, status: Exclude<MessageStatus, "withdrawn" | "failed">): void {
|
|
62
|
+
const current = this.#status.get(id);
|
|
63
|
+
if (current === undefined || current === "withdrawn" || current === "failed") return;
|
|
64
|
+
const from = FORWARD.indexOf(current);
|
|
65
|
+
const to = FORWARD.indexOf(status);
|
|
66
|
+
for (let step = from + 1; step <= to; step++) this.#set(id, FORWARD[step]!);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** End states. `failed` only before `seen`: once seen, the prompt's result says how the turn ended. */
|
|
70
|
+
end(id: string, status: "withdrawn" | "failed"): void {
|
|
71
|
+
const current = this.#status.get(id);
|
|
72
|
+
if (current === undefined || current === "withdrawn" || current === "failed" || current === "seen") return;
|
|
73
|
+
// Withdrawal is possible only before a turn took the message.
|
|
74
|
+
if (status === "withdrawn" && FORWARD.indexOf(current) >= FORWARD.indexOf("taken")) return;
|
|
75
|
+
this.#set(id, status);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#set(id: string, status: MessageStatus): void {
|
|
79
|
+
this.#status.set(id, status);
|
|
80
|
+
const turnId = this.#turnOf.get(id);
|
|
81
|
+
this.emit({ kind: "message_status", id, status, ...(turnId ? { turnId } : {}) });
|
|
82
|
+
}
|
|
83
|
+
}
|