@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
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** Decision 0032, approved wire pin c8facc2. */
|
|
2
|
+
export type RoutineEnd = { count: number; until?: never } | { until: string; count?: never }
|
|
3
|
+
| { count?: never; until?: never };
|
|
4
|
+
export type IntervalRoutineSchedule = { every: number; startAt?: string; at?: never; cron?: never } & RoutineEnd;
|
|
5
|
+
export type CalendarRoutineSchedule = { cron: string; timezone: string; at?: never; every?: never } & RoutineEnd;
|
|
6
|
+
export type RoutineSchedule = IntervalRoutineSchedule | CalendarRoutineSchedule;
|
|
7
|
+
export interface RoutineDeliveryOptions {
|
|
8
|
+
missedRuns?: "coalesce" | "skip" | "each";
|
|
9
|
+
overlap?: "skip" | "queue";
|
|
10
|
+
}
|
|
11
|
+
export interface RoutineTimezoneMigration {
|
|
12
|
+
fromVersion: string;
|
|
13
|
+
targetVersion: string;
|
|
14
|
+
cause: "invalid_schedule" | "proof_budget";
|
|
15
|
+
}
|
|
16
|
+
export type ReminderSchedule = OneOffSchedule | RoutineSchedule;
|
|
17
|
+
|
|
18
|
+
/** Decision 0031. All persisted instants are canonical millisecond UTC ISO strings. */
|
|
19
|
+
export interface OneOffSchedule { at: string }
|
|
20
|
+
export type AgentReminderSchedule = OneOffSchedule | { in: string };
|
|
21
|
+
export type ReminderState = "active" | "paused" | "blocked" | "done" | "cancelled" | "expired";
|
|
22
|
+
export type ReminderBlockReason = "invalid_policy" | "channel_missing" | "channel_retired"
|
|
23
|
+
| "invalid_schedule" | "limit_exceeded" | "conflict" | "not_found" | "stale" | "invalid_state" | "unattended_guard_required";
|
|
24
|
+
|
|
25
|
+
interface ReminderFields {
|
|
26
|
+
id: string;
|
|
27
|
+
channel: string;
|
|
28
|
+
createdBy: "agent" | "host";
|
|
29
|
+
creatorId?: string;
|
|
30
|
+
policyNames: string[];
|
|
31
|
+
text: string;
|
|
32
|
+
state: ReminderState;
|
|
33
|
+
nextRunAt: string | null;
|
|
34
|
+
acceptedAt: string;
|
|
35
|
+
expiresAfter: number | null;
|
|
36
|
+
expiresAt: string | null;
|
|
37
|
+
lastRunAt?: string;
|
|
38
|
+
lastOccurrenceId?: string;
|
|
39
|
+
noticeId?: string;
|
|
40
|
+
blockedReason?: ReminderBlockReason;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Returned interval routines always carry their resolved startAt. */
|
|
44
|
+
export type OneOffReminder = ReminderFields & { schedule: OneOffSchedule; missedRuns?: never; overlap?: never;
|
|
45
|
+
remainingCount?: never; timezoneVersion?: never; timezoneMigration?: never };
|
|
46
|
+
export type Reminder = OneOffReminder | (ReminderFields & Required<RoutineDeliveryOptions> & { remainingCount?: number } & (
|
|
47
|
+
| { schedule: IntervalRoutineSchedule & { startAt: string }; timezoneVersion?: never; timezoneMigration?: never }
|
|
48
|
+
| { schedule: CalendarRoutineSchedule; timezoneVersion: string; timezoneMigration?: RoutineTimezoneMigration }
|
|
49
|
+
));
|
|
50
|
+
|
|
51
|
+
type ReminderEdit = RoutineDeliveryOptions & {
|
|
52
|
+
text?: string;
|
|
53
|
+
state?: "active" | "paused";
|
|
54
|
+
expiresAfter?: number | null;
|
|
55
|
+
} & ({ schedule: ReminderSchedule; acceptedAt: string } | { schedule?: never; acceptedAt?: never });
|
|
56
|
+
|
|
57
|
+
type ChangeIdentity = { reminderId: string; changeId: number };
|
|
58
|
+
|
|
59
|
+
/** Versioned host commands. Agent mutations derive their ownership from the turn. */
|
|
60
|
+
export type ReminderChange = ChangeIdentity & (
|
|
61
|
+
| { op: "create"; payload: RoutineDeliveryOptions & { channel: string; schedule: ReminderSchedule; text: string;
|
|
62
|
+
acceptedAt: string; policyNames?: string[]; expiresAfter?: number | null } }
|
|
63
|
+
| { op: "update"; payload: ReminderEdit }
|
|
64
|
+
| { op: "cancel"; payload: Record<string, never> }
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
/** Internal 0031 parser and storage view until recurrence is enabled. */
|
|
68
|
+
export type OneOffReminderChange = (ChangeIdentity & (
|
|
69
|
+
| { op: "create"; payload: Omit<Extract<ReminderChange, { op: "create" }>["payload"], "schedule"> & { schedule: OneOffSchedule } }
|
|
70
|
+
| { op: "update"; payload: Omit<ReminderEdit, "schedule" | "acceptedAt"> &
|
|
71
|
+
({ schedule: OneOffSchedule; acceptedAt: string } | { schedule?: never; acceptedAt?: never }) }
|
|
72
|
+
| { op: "cancel"; payload: Record<string, never> }
|
|
73
|
+
));
|
|
74
|
+
export type OneOffReminderChangeResult = Exclude<ReminderChangeResult, { outcome: "applied" }>
|
|
75
|
+
| (ChangeIdentity & { outcome: "applied"; reminder: OneOffReminder; alreadyQueued?: boolean });
|
|
76
|
+
|
|
77
|
+
export type ReminderChangeResult = ChangeIdentity & (
|
|
78
|
+
| { outcome: "applied"; reminder: Reminder; alreadyQueued?: boolean }
|
|
79
|
+
| { outcome: "blocked"; reason: ReminderBlockReason }
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
export interface ReminderListParams { channel?: string; after?: string; limit?: number }
|
|
83
|
+
export interface ReminderList { reminders: Reminder[]; next?: string }
|
|
84
|
+
export interface ReminderWake { nextDueAt: string | null; reminderRevision: number }
|
|
85
|
+
export type ReminderOpen = {
|
|
86
|
+
reminderChanges: ReminderChangeResult[];
|
|
87
|
+
reminders: Reminder[];
|
|
88
|
+
remindersNext?: string;
|
|
89
|
+
} & (ReminderWake | { nextDueAt?: never; reminderRevision?: never });
|
|
90
|
+
|
|
91
|
+
export interface ReminderLimits {
|
|
92
|
+
minLeadMs: number;
|
|
93
|
+
minIntervalMs: number;
|
|
94
|
+
maxActiveRoutinesPerChannel: number;
|
|
95
|
+
maxRoutineCatchUp?: number;
|
|
96
|
+
minExpiryGraceMs: number;
|
|
97
|
+
maxExpiryGraceMs: number;
|
|
98
|
+
expiryMultiplier: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type ReminderSessionEvent = { type: "reminders_due"; nextDueAt: string | null; revision: number };
|
|
102
|
+
export type ReminderChannelEvent =
|
|
103
|
+
| { type: "routine_disposition"; reminderId: string; firstScheduledAt: string; lastScheduledAt: string; count: number;
|
|
104
|
+
reason: "missed" | "catch_up_limit" | "overlap" | "expired" | "coalesced" }
|
|
105
|
+
| ({ type: "routine_migration_blocked"; reminderId: string } & RoutineTimezoneMigration)
|
|
106
|
+
| { type: "reminder_changed"; reminder: Reminder }
|
|
107
|
+
| { type: "reminder_fired"; reminderId: string; occurrenceId: string; scheduledAt: string; firedAt: string; noticeId: string }
|
|
108
|
+
| { type: "reminder_cancelled"; reminderId: string; by: "host" | "agent" | "channel_retired" }
|
|
109
|
+
| { type: "reminder_expired"; reminderId: string; occurrenceId: string; scheduledAt: string; expiredAt: string };
|
|
110
|
+
|
|
111
|
+
export interface ConditionalStopParams { ifIdle: true; unlessDueWithinMs?: number }
|
|
112
|
+
export type ConditionalStopResult = { stopped: true } | { stopped: false; reason: "busy" | "next_due_soon" };
|
|
113
|
+
|
|
114
|
+
export interface ReminderMethods {
|
|
115
|
+
"reminder/change": { params: ReminderChange; result: ReminderChangeResult };
|
|
116
|
+
"reminder/get": { params: { id: string }; result: { reminder: Reminder } };
|
|
117
|
+
"reminder/list": { params: ReminderListParams; result: ReminderList };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Wall time drives eligibility. A timer only requests an eligibility recheck. */
|
|
121
|
+
export interface ReminderClock {
|
|
122
|
+
now(): number;
|
|
123
|
+
setTimer(callback: () => void, delayMs: number): () => void;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Portable reminder state in logical archive 6. High water is derived from retained receipts. */
|
|
127
|
+
export interface ReminderArchiveState {
|
|
128
|
+
rows: Array<{ sequence: number; reminder: OneOffReminder; original?: string; defaultedExpiry: boolean }>;
|
|
129
|
+
receipts: Array<{ fingerprint: string; result: OneOffReminderChangeResult }>;
|
|
130
|
+
listingRevision: number;
|
|
131
|
+
wake: ReminderWake;
|
|
132
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Version and human-readable label for the first JSONL record. */
|
|
2
|
+
export interface ScenarioHeader { type: "scenario"; version: 1; name: string }
|
|
3
|
+
|
|
4
|
+
/** A delay relative to the preceding chunk, or to the initial delay for the
|
|
5
|
+
* first chunk. The final text must equal the concatenated chunks. */
|
|
6
|
+
export interface ScenarioChunk { afterMs: number; text: string }
|
|
7
|
+
|
|
8
|
+
export interface ScenarioCall { id: string; name: string; arguments: Record<string, unknown> }
|
|
9
|
+
|
|
10
|
+
/** One durable script position and one provider-neutral attempt. */
|
|
11
|
+
export type ScenarioModelRecord = {
|
|
12
|
+
type: "model";
|
|
13
|
+
channelId?: string;
|
|
14
|
+
delayMs?: number;
|
|
15
|
+
chunks?: ScenarioChunk[];
|
|
16
|
+
usage?: import("./model-execution.ts").ModelUsage;
|
|
17
|
+
} & (
|
|
18
|
+
| { content: string | null; calls?: ScenarioCall[]; failure?: never; wait?: never }
|
|
19
|
+
| { content?: never; calls?: never; failure: {
|
|
20
|
+
kind: Extract<import("./model-execution.ts").ModelAttemptEvent, { type: "failure" }>["kind"];
|
|
21
|
+
message: string;
|
|
22
|
+
}; wait?: never }
|
|
23
|
+
| { content?: never; calls?: never; failure?: never; wait: "cancel" }
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
/** A scheduled send's stable identity and its offset on the monotonic run clock. */
|
|
27
|
+
export interface ScenarioSend {
|
|
28
|
+
type: "send"; atMs: number; channelId: string; participantId: string; inputId: string; text: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type ScenarioRecord = ScenarioHeader | ScenarioModelRecord | ScenarioSend;
|
|
32
|
+
|
|
33
|
+
/** Validated local script. Each open shares the same immutable sequences.
|
|
34
|
+
* Position belongs to the requesting channel, even for a default sequence. */
|
|
35
|
+
export interface LoadedScenario {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly modelDigest: string;
|
|
38
|
+
readonly fileDigest: string;
|
|
39
|
+
readonly defaultModels: readonly ScenarioModelRecord[];
|
|
40
|
+
readonly channelModels: ReadonlyMap<string, readonly ScenarioModelRecord[]>;
|
|
41
|
+
readonly sends: readonly ScenarioSend[];
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Portable configuration understood by the scripted protocol server. The
|
|
2
|
+
* script is a destination-side file reference, retained verbatim; it is not
|
|
3
|
+
* embedded or required to exist during import. */
|
|
4
|
+
export interface PortableSessionConfig {
|
|
5
|
+
version: 1;
|
|
6
|
+
system: string;
|
|
7
|
+
model: import("./config-permissions.ts").ManagedModel;
|
|
8
|
+
/** Present on session files produced after decision 0016. */
|
|
9
|
+
defaultPolicy?: string;
|
|
10
|
+
policies?: Record<string, import("./config-permissions.ts").ToolPolicy>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** File version 1 CBOR payload. `archive` is a supported logical archive;
|
|
14
|
+
* defined here generically so this contract module imports nothing. Both fields
|
|
15
|
+
* are validated before atomic publication (decision 0015). */
|
|
16
|
+
export interface SessionFilePayload<Archive> {
|
|
17
|
+
archive: Archive;
|
|
18
|
+
config: PortableSessionConfig;
|
|
19
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { SessionAgent, ActiveTurn, TurnExecutor } from "./agent.ts";
|
|
2
|
+
import type { Model, ExecuteTurnTool, ToolDefinition } from "./loop.ts";
|
|
3
|
+
import type { SharedContextStore } from "./context.ts";
|
|
4
|
+
import type { EventSink, SessionEventSink } from "./events.ts";
|
|
5
|
+
import type {
|
|
6
|
+
ChannelLifecycle, InterruptOutcome, SessionLifecycle, SessionStorage, StorageError, StorageSnapshot, WithdrawOutcome,
|
|
7
|
+
} from "./storage.ts";
|
|
8
|
+
|
|
9
|
+
export interface TurnServices { model: Model; tools: readonly ToolDefinition[]; executeTool: ExecuteTurnTool }
|
|
10
|
+
/** Derived from one storage snapshot. The session lifecycle, each channel's
|
|
11
|
+
* lifecycle, each turn status and the pending input are reported independently
|
|
12
|
+
* (decision 0014). `working`: a running turn exists, or an item is pending on a
|
|
13
|
+
* channel that may run (session `running`, channel `open`). `idle`: lifecycle
|
|
14
|
+
* running and neither. Input pending on a suspended channel, or while the
|
|
15
|
+
* session is not running, never makes `execution` report `working`; it shows as
|
|
16
|
+
* `waitingForResume` instead. `unresolvedInterruption` marks a channel whose
|
|
17
|
+
* most recent turn was interrupted (or failed) and has not been followed by
|
|
18
|
+
* another turn; it reports, and never blocks, new work on that channel. */
|
|
19
|
+
export interface SessionStatus {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
revision: number;
|
|
22
|
+
lifecycle: SessionLifecycle;
|
|
23
|
+
/** `stopped`: this process has closed admission and will start no more work. */
|
|
24
|
+
execution: "idle" | "working" | "suspending" | "suspended" | "stopped" | "incompatible";
|
|
25
|
+
channels: ChannelStatus[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ChannelStatus {
|
|
29
|
+
channelId: string;
|
|
30
|
+
policy?: string;
|
|
31
|
+
displayName?: string;
|
|
32
|
+
lifecycle: ChannelLifecycle;
|
|
33
|
+
/** A running turn, or a checkpointed one (`suspended`). `phase` (decision
|
|
34
|
+
* 0021) is this process's view of what a running turn is doing. */
|
|
35
|
+
activeTurn?: { turnId: number; status: "running" | "suspended"; phase?: import("./tools.ts").TurnPhase };
|
|
36
|
+
/** Pending (never taken, not withdrawn) items in acceptance order. */
|
|
37
|
+
pendingItemIds: string[];
|
|
38
|
+
/** True when pending items or a checkpointed turn exist that cannot run until
|
|
39
|
+
* a resume: the channel is `suspending`/`suspended`, or the session is not
|
|
40
|
+
* `running`. Clearing one lifecycle does not clear it while the other holds. */
|
|
41
|
+
waitingForResume: boolean;
|
|
42
|
+
unresolvedInterruption?: { turnId: number; status: "failed" | "interrupted"; reason: string; uncertainCallIds: string[] };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** `stopped`: stop ended the operation; nothing was suspended or resumed. */
|
|
46
|
+
export type LifecycleResult = { ok: true; status: SessionStatus }
|
|
47
|
+
| { ok: false; error: StorageError | { code: "stopped"; message: string } };
|
|
48
|
+
|
|
49
|
+
/** Outcome of a channel control. `revision` is the storage revision that
|
|
50
|
+
* includes it. `stopped`: this process stopped before the control committed. */
|
|
51
|
+
export type ControlResult<T> = { ok: true; value: T; revision: number }
|
|
52
|
+
| { ok: false; error: StorageError | { code: "stopped"; message: string } };
|
|
53
|
+
|
|
54
|
+
/** Per-channel controls (decision 0014), each atomic in storage and independent
|
|
55
|
+
* of the session lifecycle and of other channels. Failures use the storage error
|
|
56
|
+
* codes of the matching `SessionStorage` method. */
|
|
57
|
+
export interface ChannelControls {
|
|
58
|
+
/** Explicit creation; starts no turn. Repeating the same request returns
|
|
59
|
+
* `created: false`. A different name for an existing channel is `already_exists`;
|
|
60
|
+
* a retired ID is `channel_retired`. */
|
|
61
|
+
create(input: { channelId: string; displayName?: string; policy?: string }): ControlResult<{ channel: ChannelStatus; created: boolean }>;
|
|
62
|
+
/** Display name only (null clears). */
|
|
63
|
+
edit(channelId: string, displayName: string | null, policy?: string | null): ControlResult<ChannelStatus>;
|
|
64
|
+
/** Close the channel to input at once, let its active iteration finish, then
|
|
65
|
+
* resolve once `suspended` is committed: with a checkpoint if the turn needs
|
|
66
|
+
* another inference, with a completed turn if it can finish, or with no
|
|
67
|
+
* checkpoint if the turn was interrupted meanwhile. Pending input is kept.
|
|
68
|
+
* Concurrent and repeated calls observe the same transition. Resolves
|
|
69
|
+
* `stopped` if stop arrives first; the unfinished suspension never commits. */
|
|
70
|
+
suspend(channelId: string): Promise<ControlResult<ChannelStatus>>;
|
|
71
|
+
/** Clear the channel's suspension. Continues a checkpoint under its original
|
|
72
|
+
* turn ID and starts pending input only when the session is `running`; during a
|
|
73
|
+
* session suspension only the channel suspension is cleared and nothing runs.
|
|
74
|
+
* `incompatible` leaves the channel suspended and its checkpoint intact. */
|
|
75
|
+
resume(channelId: string): ControlResult<ChannelStatus>;
|
|
76
|
+
/** Retire the channel when it has no active or checkpointed turn and nothing
|
|
77
|
+
* pending (`channel_busy` otherwise). The ID is reserved; history is kept. */
|
|
78
|
+
delete(channelId: string): ControlResult<ChannelStatus>;
|
|
79
|
+
/** Withdraw an untaken message or notice. `taken` names the owning turn when take won. */
|
|
80
|
+
withdraw(channelId: string, itemId: string): ControlResult<WithdrawOutcome>;
|
|
81
|
+
/** Interrupt exactly this turn, aborting its signal and ending it without
|
|
82
|
+
* waiting for its inference or tools; late results are fenced. `interrupted:
|
|
83
|
+
* false` for a checkpointed or ended turn, which is left untouched. When
|
|
84
|
+
* `reason` is omitted the stored reason is exactly `"interrupted by request"`. */
|
|
85
|
+
interrupt(channelId: string, turnId: number, reason?: string): ControlResult<InterruptOutcome>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface PersistentSessionOptions {
|
|
89
|
+
reminderClock?: import("./reminders.ts").ReminderClock;
|
|
90
|
+
/** Local opt-in when there is no managed configuration. */
|
|
91
|
+
timelineTools?: boolean;
|
|
92
|
+
systemPrompt: string;
|
|
93
|
+
/** Optional assertion of the storage owner's validated config. Omission uses
|
|
94
|
+
* the owner snapshot; legacy allow applies only when that snapshot is absent. */
|
|
95
|
+
config?: import("./config-permissions.ts").ManagedConfig;
|
|
96
|
+
/** Default 600000 ms. An optional barrier resolves before the final check of
|
|
97
|
+
* both lifecycle signals, allowing deterministic gate tests. */
|
|
98
|
+
approvalTimeoutMs?: number;
|
|
99
|
+
beforeToolDispatch?: () => Promise<void>;
|
|
100
|
+
/** Opened and later closed by the caller. Recovery already ran in open. */
|
|
101
|
+
storage: SessionStorage;
|
|
102
|
+
configureTurn(turn: ActiveTurn, notify: SessionAgent["notify"]): TurnServices;
|
|
103
|
+
/** Decision 0021: consumer functions, validated by the caller. Their names
|
|
104
|
+
* must not collide with the tools `configureTurn` returns. */
|
|
105
|
+
catalog?: import("./tools.ts").ToolCatalogInput;
|
|
106
|
+
toolLimits?: Partial<import("./tools.ts").ToolLimits>;
|
|
107
|
+
/** Development-only, detached observation of the assembled model request. */
|
|
108
|
+
observeModelCall?: (channelId: string, turnId: number, callId: string) => void;
|
|
109
|
+
captureContext?: (value: import("./context.ts").ContextCapture) => void;
|
|
110
|
+
wrapTurn?: (run: TurnExecutor) => TurnExecutor;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Creating the session executes nothing: it can be inspected, loaded and
|
|
114
|
+
* exported first. Opening, starting and resuming are separate actions. */
|
|
115
|
+
export interface PersistentSession {
|
|
116
|
+
reminders?: Pick<SessionStorage, "readReminder" | "listReminders" | "reminderWake"> & {
|
|
117
|
+
change(change: import("./reminders.ts").OneOffReminderChange): ReturnType<SessionStorage["changeReminder"]>;
|
|
118
|
+
processStartup(): void;
|
|
119
|
+
releaseTimer(): void;
|
|
120
|
+
executable(): boolean;
|
|
121
|
+
conditionalStop(windowMs: number): import("./reminders.ts").ConditionalStopResult;
|
|
122
|
+
subscribeWake(listener: (event: import("./reminders.ts").ReminderSessionEvent) => void): () => void;
|
|
123
|
+
};
|
|
124
|
+
/** Read an oldest-first page of complete model-call summaries. */
|
|
125
|
+
readModelCalls: SessionStorage["readCalls"];
|
|
126
|
+
operatorReads?: Pick<SessionStorage, "readSession" | "readExecution" | "readChannel" | "readTracked" | "readTimeline">;
|
|
127
|
+
turnPhase?(turnId: number): import("./tools.ts").TurnPhase | undefined;
|
|
128
|
+
/** Approval requests belong to this connection; disconnect closes them. */
|
|
129
|
+
approvals: {
|
|
130
|
+
waiting?(): import("./config-permissions.ts").ApprovalRequest[];
|
|
131
|
+
setConsumer(enabled: boolean): void;
|
|
132
|
+
respond(requestId: string, answer: import("./config-permissions.ts").ApprovalAnswer): boolean;
|
|
133
|
+
disconnect(): void;
|
|
134
|
+
};
|
|
135
|
+
agent: SessionAgent;
|
|
136
|
+
/** Channel controls (decision 0014). */
|
|
137
|
+
channels: ChannelControls;
|
|
138
|
+
/** Read-only timeline projection for the context builder and inspector. */
|
|
139
|
+
store: Pick<SharedContextStore, "snapshot" | "subscribe">;
|
|
140
|
+
snapshot(): StorageSnapshot;
|
|
141
|
+
status(): SessionStatus;
|
|
142
|
+
/** Make pending items eligible: begin turns for channels with pending input
|
|
143
|
+
* when the lifecycle is running and the channel is `open`. Does not resume a
|
|
144
|
+
* suspended session or channel. Callers
|
|
145
|
+
* that owe a load response deliver it before calling start. Idempotent. */
|
|
146
|
+
start(): void;
|
|
147
|
+
/** Resolves when `suspended` is committed, after in-flight iterations settle.
|
|
148
|
+
* Concurrent and repeated calls observe the same transition. If stop arrives
|
|
149
|
+
* first, resolves `stopped` and `suspended` is never committed. */
|
|
150
|
+
suspend(): Promise<LifecycleResult>;
|
|
151
|
+
/** Explicit resume: continues checkpointed turns of channels that are not
|
|
152
|
+
* individually suspended, then starts pending input of those channels. An
|
|
153
|
+
* individually suspended channel stays suspended (and its checkpoint, even an
|
|
154
|
+
* incompatible one, does not block this call). */
|
|
155
|
+
resume(): LifecycleResult;
|
|
156
|
+
/** Immediate: close admission in this process, abort inference and tools,
|
|
157
|
+
* and commit storage `interruptActive`. While running that interrupts every
|
|
158
|
+
* running turn; while suspending it also interrupts turns checkpointed in
|
|
159
|
+
* this attempt and returns the lifecycle to running; a suspended session keeps
|
|
160
|
+
* its checkpoints. Checkpoints committed by an individual channel suspension
|
|
161
|
+
* are always kept and a channel still `suspending` returns to `open`. Pending
|
|
162
|
+
* items stay pending. Does not wait for the
|
|
163
|
+
* iteration and is not suspension. Late results are fenced by storage. */
|
|
164
|
+
stop(reason: string): SessionStatus;
|
|
165
|
+
subscribe(listener: EventSink): () => void;
|
|
166
|
+
subscribeSession(listener: SessionEventSink): () => void;
|
|
167
|
+
/** Decision 0021. Absent on a session assembled without a catalog. */
|
|
168
|
+
tools?: ToolControls;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The session's tool catalog (decision 0021). Definitions come from the open;
|
|
172
|
+
* only revocations are stored. Failures use storage error codes plus
|
|
173
|
+
* `not_found` (unknown name) and `invalid_state` (wrong group for the operation). */
|
|
174
|
+
export interface ToolControls {
|
|
175
|
+
list(): import("./tools.ts").ToolAvailability[];
|
|
176
|
+
/** The handler names the current connection serves; an empty list on disconnect. */
|
|
177
|
+
serve(handlers: readonly string[], executor?: import("./tools.ts").FunctionExecutor): void;
|
|
178
|
+
revoke(name: string): ControlResult<import("./tools.ts").ToolAvailability>;
|
|
179
|
+
restore(name: string): ControlResult<import("./tools.ts").ToolAvailability>;
|
|
180
|
+
enable(name: string): ControlResult<import("./tools.ts").ToolAvailability>;
|
|
181
|
+
remove(name: string): ControlResult<import("./tools.ts").ToolAvailability>;
|
|
182
|
+
invocation(invocationId: string): import("./tools.ts").ToolInvocation | undefined;
|
|
183
|
+
invocations(turnId: number): import("./tools.ts").ToolInvocation[];
|
|
184
|
+
}
|