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