@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.
Files changed (467) 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 +845 -6
  6. package/MIGRATION-0.10-to-0.12.md +4 -1
  7. package/MIGRATION-0.12-to-0.13.md +275 -0
  8. package/README.md +17 -16
  9. package/package.json +4 -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 +94 -158
  19. package/src/agent/manager-settings.ts +1 -0
  20. package/src/agent/native-channel-lifecycle.ts +111 -0
  21. package/src/agent/persisted-lifecycle.ts +44 -4
  22. package/src/agent/persistence-policy/context.ts +13 -0
  23. package/src/agent/persistence-policy/resolver.ts +7 -0
  24. package/src/agent/persistence-policy/types.ts +1 -0
  25. package/src/agent/record-capture.ts +1 -0
  26. package/src/agent-adapter-registry.ts +33 -7
  27. package/src/agent-conversation-contracts.ts +14 -1
  28. package/src/agent-conversation-errors.ts +8 -0
  29. package/src/agent-conversation-owner.ts +9 -4
  30. package/src/agent-session-config.ts +135 -0
  31. package/src/agent-session.ts +439 -934
  32. package/src/agent.ts +73 -0
  33. package/src/capabilities.ts +2 -0
  34. package/src/checkpointing/recovery.ts +3 -0
  35. package/src/cli/index.ts +3 -3
  36. package/src/cli/managed.ts +2 -2
  37. package/src/client.ts +52 -94
  38. package/src/connection-attempt.ts +95 -0
  39. package/src/controller-connection.ts +114 -0
  40. package/src/controller.ts +156 -148
  41. package/src/conversation-controller/capabilities.ts +88 -0
  42. package/src/conversation-controller/contracts.ts +208 -0
  43. package/src/conversation-controller/factory.ts +39 -0
  44. package/src/conversation-controller/guards.ts +98 -0
  45. package/src/conversation-controller/index.ts +20 -0
  46. package/src/conversation-startup.ts +35 -0
  47. package/src/conversation-turns/backend-turns.ts +373 -0
  48. package/src/conversation-turns/clear-operations.ts +37 -0
  49. package/src/conversation-turns/context.ts +135 -0
  50. package/src/conversation-turns/index.ts +4 -0
  51. package/src/conversation-turns/record-helpers.ts +75 -0
  52. package/src/conversation-turns/recording.ts +235 -0
  53. package/src/conversation-turns/run-turn.ts +367 -0
  54. package/src/conversation-turns/turn-run.ts +57 -0
  55. package/src/errors.ts +41 -0
  56. package/src/handoff-options.ts +81 -0
  57. package/src/identity/checkpoint-backed.ts +1 -1
  58. package/src/index.ts +58 -3
  59. package/src/internal-inference/coordination/manager.ts +11 -0
  60. package/src/internal-inference/runtime/harness-runtime.ts +4 -4
  61. package/src/launcher.ts +35 -2
  62. package/src/media/parts.ts +5 -0
  63. package/src/message-status.ts +83 -0
  64. package/src/metering/engine.ts +39 -64
  65. package/src/metering/measurement-provenance.ts +36 -0
  66. package/src/metering/native/durability.ts +115 -0
  67. package/src/metering/native/ledger.ts +104 -0
  68. package/src/metering/native/operation.ts +85 -0
  69. package/src/metering/native/projection.ts +114 -0
  70. package/src/metering/native/proof.ts +51 -0
  71. package/src/metering/native/requirements.ts +10 -0
  72. package/src/metering/native/retirement.ts +92 -0
  73. package/src/metering/native/source.ts +90 -0
  74. package/src/metering/record.ts +38 -1
  75. package/src/metering/state.ts +13 -3
  76. package/src/native/approvals.ts +169 -0
  77. package/src/native/capabilities.ts +17 -0
  78. package/src/native/channel-changes.ts +211 -0
  79. package/src/native/connection.ts +56 -0
  80. package/src/native/controller.ts +591 -0
  81. package/src/native/delegation-sender.ts +26 -0
  82. package/src/native/errors.ts +35 -0
  83. package/src/native/functions.ts +156 -0
  84. package/src/native/host-config.ts +59 -0
  85. package/src/native/host.ts +909 -0
  86. package/src/native/item-receipts.ts +15 -0
  87. package/src/native/metering.ts +12 -0
  88. package/src/native/records.ts +166 -0
  89. package/src/native/recovery.ts +186 -0
  90. package/src/native/reminders/fixtures/schema21.sqlite.gz +0 -0
  91. package/src/native/reminders/idle.ts +70 -0
  92. package/src/native/reminders/limits.ts +19 -0
  93. package/src/native/reminders/notifications.ts +29 -0
  94. package/src/native/reminders/reminders.test.ts +553 -0
  95. package/src/native/reminders/routine-config.typecheck.ts +13 -0
  96. package/src/native/reminders/routine-guard.ts +66 -0
  97. package/src/native/reminders/routine-schedule.ts +25 -0
  98. package/src/native/reminders/routine-wire.ts +21 -0
  99. package/src/native/reminders/schedule.ts +97 -0
  100. package/src/native/reminders/service.ts +280 -0
  101. package/src/native/reminders/supervisor.ts +91 -0
  102. package/src/native/reminders/sync.ts +301 -0
  103. package/src/native/reminders/wire.ts +197 -0
  104. package/src/native/reminders/wire.typecheck.ts +13 -0
  105. package/src/native/submission-withdrawal.ts +65 -0
  106. package/src/native/usage.ts +15 -0
  107. package/src/native/worker-delivery.ts +61 -0
  108. package/src/native-harness/.res/README.md +1 -0
  109. package/src/native-harness/.res/architecture/README.md +21 -0
  110. package/src/native-harness/.res/architecture/context-and-data.md +31 -0
  111. package/src/native-harness/.res/architecture/execution.md +42 -0
  112. package/src/native-harness/.res/architecture/overview.md +44 -0
  113. package/src/native-harness/.res/architecture/persistence.md +56 -0
  114. package/src/native-harness/.res/architecture/suspend-and-resume.md +45 -0
  115. package/src/native-harness/.res/architecture/technical-architecture.md +50 -0
  116. package/src/native-harness/.res/decisions/0001-basic-loop.md +11 -0
  117. package/src/native-harness/.res/decisions/0002-channel-input.md +17 -0
  118. package/src/native-harness/.res/decisions/0003-inference-inspection.md +14 -0
  119. package/src/native-harness/.res/decisions/0004-shared-context.md +21 -0
  120. package/src/native-harness/.res/decisions/0005-notice-inbox.md +20 -0
  121. package/src/native-harness/.res/decisions/0006-explicit-notices.md +12 -0
  122. package/src/native-harness/.res/decisions/0007-channel-output.md +12 -0
  123. package/src/native-harness/.res/decisions/0008-browser-client.md +16 -0
  124. package/src/native-harness/.res/decisions/0009-scripted-model.md +18 -0
  125. package/src/native-harness/.res/decisions/0010-inprocess-protocol.md +19 -0
  126. package/src/native-harness/.res/decisions/0011-stdio-transport.md +21 -0
  127. package/src/native-harness/.res/decisions/0012-session-storage-contract.md +37 -0
  128. package/src/native-harness/.res/decisions/0013-durable-delivery-contract.md +64 -0
  129. package/src/native-harness/.res/decisions/0014-channel-controls-contract.md +73 -0
  130. package/src/native-harness/.res/decisions/0015-session-file-contract.md +72 -0
  131. package/src/native-harness/.res/decisions/0016-configuration-permissions.md +159 -0
  132. package/src/native-harness/.res/decisions/0017-openrouter-managed-config.md +69 -0
  133. package/src/native-harness/.res/decisions/0018-tool-dispatch-evidence.md +78 -0
  134. package/src/native-harness/.res/decisions/0019-model-execution.md +188 -0
  135. package/src/native-harness/.res/decisions/0020-startup-channel-changes.md +71 -0
  136. package/src/native-harness/.res/decisions/0021-tools-and-host-callbacks.md +100 -0
  137. package/src/native-harness/.res/decisions/0022-operator-controls.md +115 -0
  138. package/src/native-harness/.res/decisions/0023-long-running-mock.md +82 -0
  139. package/src/native-harness/.res/decisions/0024-callback-policy-names.md +46 -0
  140. package/src/native-harness/.res/decisions/0025-external-notices.md +364 -0
  141. package/src/native-harness/.res/decisions/0026-bounded-context.md +81 -0
  142. package/src/native-harness/.res/decisions/0027-development-instructions.md +22 -0
  143. package/src/native-harness/.res/decisions/0028-debug-tools.md +16 -0
  144. package/src/native-harness/.res/decisions/0029-bounded-model-call-pages.md +37 -0
  145. package/src/native-harness/.res/decisions/0030-timeline-retrieval.md +145 -0
  146. package/src/native-harness/.res/decisions/0031-one-off-reminders.md +173 -0
  147. package/src/native-harness/.res/docs/11-15.md +148 -0
  148. package/src/native-harness/.res/docs/BUSINESS_RULES.md +111 -0
  149. package/src/native-harness/.res/docs/WORK.md +65 -0
  150. package/src/native-harness/.res/docs/_/11-16-persistence/LOG.md +312 -0
  151. package/src/native-harness/.res/docs/_/11-16-persistence/PLAN.md +77 -0
  152. package/src/native-harness/.res/docs/_/11-16-persistence/SPEC.md +313 -0
  153. package/src/native-harness/.res/docs/_/11-19-channel-controls/LOG.md +160 -0
  154. package/src/native-harness/.res/docs/_/11-19-channel-controls/PLAN.md +89 -0
  155. package/src/native-harness/.res/docs/_/11-19-channel-controls/SPEC.md +135 -0
  156. package/src/native-harness/.res/docs/_/11-19-config-permissions/LOG.md +143 -0
  157. package/src/native-harness/.res/docs/_/11-19-config-permissions/PLAN.md +93 -0
  158. package/src/native-harness/.res/docs/_/11-19-config-permissions/SPEC.md +181 -0
  159. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/11-20-LOG.md +433 -0
  160. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PLAN.md +60 -0
  161. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PROTOCOL.md +141 -0
  162. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/SPEC.md +168 -0
  163. package/src/native-harness/.res/docs/attachments/0001-DESIGN/SPEC.md +111 -0
  164. package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/PLAN.md +129 -0
  165. package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/SPEC.md +135 -0
  166. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/LOG.md +437 -0
  167. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/PLAN.md +127 -0
  168. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/SPEC.md +203 -0
  169. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/LOG.md +292 -0
  170. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/PLAN.md +91 -0
  171. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/SPEC.md +187 -0
  172. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/LOG.md +148 -0
  173. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/PLAN.md +95 -0
  174. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/SPEC.md +200 -0
  175. package/src/native-harness/.res/docs/model-execution/0002-AMENDMENT-accounting/SPEC.md +80 -0
  176. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/LOG.md +206 -0
  177. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/PLAN.md +106 -0
  178. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/SPEC.md +297 -0
  179. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/LOG.md +41 -0
  180. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/PLAN.md +36 -0
  181. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/SPEC.md +84 -0
  182. package/src/native-harness/.res/docs/shell-execution/0001-DESIGN/SPEC.md +147 -0
  183. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/LOG.md +15 -0
  184. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/PLAN.md +107 -0
  185. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/SPEC.md +114 -0
  186. package/src/native-harness/.res/docs/todos/11-19-TODO-auto_review-approve.md +24 -0
  187. package/src/native-harness/.res/docs/todos/11-20-TODO-user-entered-tool-code.md +23 -0
  188. package/src/native-harness/.res/docs/todos/11-21-TODO-node-resource-coordination.md +103 -0
  189. package/src/native-harness/.res/docs/todos/11-22-TODO-harness-m1-sequence.md +50 -0
  190. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/LOG.md +337 -0
  191. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/PLAN.md +76 -0
  192. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/SPEC.md +204 -0
  193. package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/LOG.md +73 -0
  194. package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/SPEC.md +64 -0
  195. package/src/native-harness/.res/docs/tools-and-callbacks/0003-DESIGN-attachment-tools/SPEC.md +58 -0
  196. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/LOG.md +45 -0
  197. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/PLAN.md +108 -0
  198. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/SPEC.md +169 -0
  199. package/src/native-harness/.res/docs/web-tools/0001-DESIGN/SPEC.md +128 -0
  200. package/src/native-harness/.res/marketing-draft.md +22 -0
  201. package/src/native-harness/.res/sandbox/1-simple-harness/README.md +285 -0
  202. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-1.md +19 -0
  203. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-10.md +138 -0
  204. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-11.md +148 -0
  205. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-12.md +172 -0
  206. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-13.md +194 -0
  207. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-14.md +233 -0
  208. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-15.md +249 -0
  209. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-16.md +265 -0
  210. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-17.md +279 -0
  211. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-18.md +293 -0
  212. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-19.md +307 -0
  213. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-2.md +29 -0
  214. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-20.md +317 -0
  215. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-21.md +327 -0
  216. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-3.md +40 -0
  217. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-4.md +59 -0
  218. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-5.md +69 -0
  219. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-6.md +79 -0
  220. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-7.md +89 -0
  221. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-8.md +102 -0
  222. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-9.md +116 -0
  223. package/src/native-harness/.res/sandbox/1-simple-harness/conversation.jsonl +49 -0
  224. package/src/native-harness/.res/sandbox/1-simple-harness/doc.md +87 -0
  225. package/src/native-harness/.res/sandbox/1-simple-harness/harness.py +289 -0
  226. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 2.py +221 -0
  227. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 3.py +287 -0
  228. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy.py +165 -0
  229. package/src/native-harness/.res/sandbox/1-simple-harness/state.json +22 -0
  230. package/src/native-harness/.res/sandbox/1-simple-harness/system-prompt.md +2 -0
  231. package/src/native-harness/AGENTS.md +70 -0
  232. package/src/native-harness/ARCHITECTURE.md +249 -0
  233. package/src/native-harness/README.md +726 -0
  234. package/src/native-harness/bun.lock +26 -0
  235. package/src/native-harness/package.json +24 -0
  236. package/src/native-harness/src/capabilities/context/build.ts +59 -0
  237. package/src/native-harness/src/capabilities/context/instructions/agent-demo.md +11 -0
  238. package/src/native-harness/src/capabilities/context/instructions/agent.md +5 -0
  239. package/src/native-harness/src/capabilities/context/instructions/harness.md +7 -0
  240. package/src/native-harness/src/capabilities/context/load-instructions.ts +22 -0
  241. package/src/native-harness/src/capabilities/context/session.ts +92 -0
  242. package/src/native-harness/src/capabilities/model/attempt.ts +27 -0
  243. package/src/native-harness/src/capabilities/model/openrouter-stream.ts +72 -0
  244. package/src/native-harness/src/capabilities/model/openrouter.ts +62 -0
  245. package/src/native-harness/src/capabilities/model/runner.ts +116 -0
  246. package/src/native-harness/src/capabilities/model/scenario-attempt.ts +50 -0
  247. package/src/native-harness/src/capabilities/model/scenario-file.ts +125 -0
  248. package/src/native-harness/src/capabilities/model/scripted-error.ts +6 -0
  249. package/src/native-harness/src/capabilities/model/scripted.ts +81 -0
  250. package/src/native-harness/src/capabilities/model/usage.ts +15 -0
  251. package/src/native-harness/src/capabilities/tools/builtin/current-time.ts +28 -0
  252. package/src/native-harness/src/capabilities/tools/builtin/notify-channel.ts +17 -0
  253. package/src/native-harness/src/capabilities/tools/debug/index.ts +13 -0
  254. package/src/native-harness/src/capabilities/tools/debug/result.ts +12 -0
  255. package/src/native-harness/src/capabilities/tools/debug/test-echo.ts +16 -0
  256. package/src/native-harness/src/capabilities/tools/debug/test-fail.ts +14 -0
  257. package/src/native-harness/src/capabilities/tools/debug/test-wait.ts +19 -0
  258. package/src/native-harness/src/capabilities/tools/reminders/index.ts +75 -0
  259. package/src/native-harness/src/capabilities/tools/runtime/catalog.ts +103 -0
  260. package/src/native-harness/src/capabilities/tools/runtime/functions.ts +130 -0
  261. package/src/native-harness/src/capabilities/tools/runtime/invocations.ts +48 -0
  262. package/src/native-harness/src/capabilities/tools/testing/echo.ts +18 -0
  263. package/src/native-harness/src/capabilities/tools/testing/record.ts +47 -0
  264. package/src/native-harness/src/capabilities/tools/timeline/index.ts +41 -0
  265. package/src/native-harness/src/client.ts +18 -0
  266. package/src/native-harness/src/contracts/agent.ts +105 -0
  267. package/src/native-harness/src/contracts/config-permissions.ts +47 -0
  268. package/src/native-harness/src/contracts/context.ts +112 -0
  269. package/src/native-harness/src/contracts/events.ts +47 -0
  270. package/src/native-harness/src/contracts/input-limits.ts +7 -0
  271. package/src/native-harness/src/contracts/inspection.ts +22 -0
  272. package/src/native-harness/src/contracts/loop.ts +31 -0
  273. package/src/native-harness/src/contracts/model-execution.ts +83 -0
  274. package/src/native-harness/src/contracts/operator-controls.ts +106 -0
  275. package/src/native-harness/src/contracts/output.ts +13 -0
  276. package/src/native-harness/src/contracts/protocol.ts +320 -0
  277. package/src/native-harness/src/contracts/reminders.ts +132 -0
  278. package/src/native-harness/src/contracts/scenario.ts +42 -0
  279. package/src/native-harness/src/contracts/session-file.ts +19 -0
  280. package/src/native-harness/src/contracts/session.ts +184 -0
  281. package/src/native-harness/src/contracts/storage.ts +596 -0
  282. package/src/native-harness/src/contracts/timeline-retrieval.ts +40 -0
  283. package/src/native-harness/src/contracts/tools.ts +133 -0
  284. package/src/native-harness/src/governance/permissions/gate.ts +129 -0
  285. package/src/native-harness/src/governance/policy/resolve.ts +32 -0
  286. package/src/native-harness/src/index.ts +318 -0
  287. package/src/native-harness/src/interfaces/cli/chat.ts +83 -0
  288. package/src/native-harness/src/interfaces/cli/development.ts +145 -0
  289. package/src/native-harness/src/interfaces/cli/format-reply.ts +27 -0
  290. package/src/native-harness/src/interfaces/cli/listeners.ts +74 -0
  291. package/src/native-harness/src/interfaces/cli/main.ts +47 -0
  292. package/src/native-harness/src/interfaces/cli/scenario.ts +37 -0
  293. package/src/native-harness/src/interfaces/cli/serve.ts +21 -0
  294. package/src/native-harness/src/interfaces/cli/start.ts +106 -0
  295. package/src/native-harness/src/interfaces/client.ts +225 -0
  296. package/src/native-harness/src/interfaces/inspector/index.html +283 -0
  297. package/src/native-harness/src/interfaces/inspector/observe.ts +35 -0
  298. package/src/native-harness/src/interfaces/inspector/server.ts +56 -0
  299. package/src/native-harness/src/interfaces/inspector/state.ts +92 -0
  300. package/src/native-harness/src/interfaces/protocol/channel-changes.ts +153 -0
  301. package/src/native-harness/src/interfaces/protocol/framing.ts +47 -0
  302. package/src/native-harness/src/interfaces/protocol/functions.ts +87 -0
  303. package/src/native-harness/src/interfaces/protocol/in-process.ts +67 -0
  304. package/src/native-harness/src/interfaces/protocol/live-queue.ts +55 -0
  305. package/src/native-harness/src/interfaces/protocol/load.ts +60 -0
  306. package/src/native-harness/src/interfaces/protocol/local.ts +120 -0
  307. package/src/native-harness/src/interfaces/protocol/operator.ts +120 -0
  308. package/src/native-harness/src/interfaces/protocol/output.ts +59 -0
  309. package/src/native-harness/src/interfaces/protocol/server.ts +517 -0
  310. package/src/native-harness/src/interfaces/protocol/stdio-client.ts +119 -0
  311. package/src/native-harness/src/interfaces/protocol/stdio-server.ts +82 -0
  312. package/src/native-harness/src/interfaces/protocol/subscribe.ts +41 -0
  313. package/src/native-harness/src/interfaces/protocol/transfers.ts +146 -0
  314. package/src/native-harness/src/interfaces/web-chat/index.html +94 -0
  315. package/src/native-harness/src/interfaces/web-chat/server.ts +34 -0
  316. package/src/native-harness/src/kernel/channels.ts +405 -0
  317. package/src/native-harness/src/kernel/loop.ts +45 -0
  318. package/src/native-harness/src/runtime/config/development.ts +23 -0
  319. package/src/native-harness/src/runtime/config/managed.ts +2 -0
  320. package/src/native-harness/src/runtime/config/paths.ts +27 -0
  321. package/src/native-harness/src/runtime/reminder-timer.ts +42 -0
  322. package/src/native-harness/src/runtime/reminder-validation.ts +104 -0
  323. package/src/native-harness/src/runtime/reminders.ts +66 -0
  324. package/src/native-harness/src/state/storage/archive.ts +239 -0
  325. package/src/native-harness/src/state/storage/engine.ts +1013 -0
  326. package/src/native-harness/src/state/storage/inference.ts +124 -0
  327. package/src/native-harness/src/state/storage/memory-reminders.ts +78 -0
  328. package/src/native-harness/src/state/storage/memory.ts +341 -0
  329. package/src/native-harness/src/state/storage/policy-metadata.ts +32 -0
  330. package/src/native-harness/src/state/storage/reminder-archive.ts +63 -0
  331. package/src/native-harness/src/state/storage/reminder-change.ts +92 -0
  332. package/src/native-harness/src/state/storage/reminder-tables.ts +27 -0
  333. package/src/native-harness/src/state/storage/retrieval.ts +122 -0
  334. package/src/native-harness/src/state/storage/script-identity.ts +7 -0
  335. package/src/native-harness/src/state/storage/session-file.ts +85 -0
  336. package/src/native-harness/src/state/storage/sqlite-reminders.ts +134 -0
  337. package/src/native-harness/src/state/storage/sqlite.ts +625 -0
  338. package/src/native-harness/src/testing.ts +190 -0
  339. package/src/native-harness/src/util/config.ts +58 -0
  340. package/src/native-harness/src/util/json.ts +41 -0
  341. package/src/native-harness/src/util/message-position.ts +3 -0
  342. package/src/native-harness/src/util/reminder-schedule.ts +44 -0
  343. package/src/native-harness/src/util/schema.ts +40 -0
  344. package/src/native-harness/src/util/timeline-text.ts +72 -0
  345. package/src/native-harness/src/util/timeline-tool-names.ts +3 -0
  346. package/src/native-harness/test/agent.test.ts +130 -0
  347. package/src/native-harness/test/approval-gate.test.ts +255 -0
  348. package/src/native-harness/test/approval-protocol.test.ts +94 -0
  349. package/src/native-harness/test/boundaries.test.ts +18 -0
  350. package/src/native-harness/test/channel-controls.test.ts +322 -0
  351. package/src/native-harness/test/client-abort.test.ts +136 -0
  352. package/src/native-harness/test/config-policy.test.ts +301 -0
  353. package/src/native-harness/test/conformance/storage.ts +1141 -0
  354. package/src/native-harness/test/context.test.ts +177 -0
  355. package/src/native-harness/test/crash.test.ts +187 -0
  356. package/src/native-harness/test/debug-tools.test.ts +67 -0
  357. package/src/native-harness/test/development-cli.test.ts +67 -0
  358. package/src/native-harness/test/development.test.ts +171 -0
  359. package/src/native-harness/test/dispatch-evidence.test.ts +58 -0
  360. package/src/native-harness/test/e2e.test.ts +186 -0
  361. package/src/native-harness/test/external-notices.test.ts +101 -0
  362. package/src/native-harness/test/fixtures/approval-e2e.jsonl +4 -0
  363. package/src/native-harness/test/fixtures/crash-scenario.jsonl +5 -0
  364. package/src/native-harness/test/fixtures/development-lifecycle.jsonl +10 -0
  365. package/src/native-harness/test/fixtures/echo-scenario.jsonl +3 -0
  366. package/src/native-harness/test/fixtures/format2-schema.ts +27 -0
  367. package/src/native-harness/test/fixtures/format3-schema.ts +16 -0
  368. package/src/native-harness/test/fixtures/hold-scenario.jsonl +4 -0
  369. package/src/native-harness/test/fixtures/model-e2e.jsonl +3 -0
  370. package/src/native-harness/test/fixtures/storage-owner.ts +20 -0
  371. package/src/native-harness/test/format-reply.test.ts +10 -0
  372. package/src/native-harness/test/helpers/operator-view.ts +41 -0
  373. package/src/native-harness/test/helpers/scenario.ts +9 -0
  374. package/src/native-harness/test/helpers/session.ts +38 -0
  375. package/src/native-harness/test/helpers/stdio.ts +46 -0
  376. package/src/native-harness/test/inspector.test.ts +77 -0
  377. package/src/native-harness/test/listeners.test.ts +49 -0
  378. package/src/native-harness/test/loop.test.ts +88 -0
  379. package/src/native-harness/test/model-channel-double.test.ts +87 -0
  380. package/src/native-harness/test/model-crash.test.ts +62 -0
  381. package/src/native-harness/test/model-delivery-regressions.test.ts +55 -0
  382. package/src/native-harness/test/model-e2e.test.ts +71 -0
  383. package/src/native-harness/test/model-final-filter.test.ts +30 -0
  384. package/src/native-harness/test/model-large-reply.test.ts +28 -0
  385. package/src/native-harness/test/model-live-queue.test.ts +33 -0
  386. package/src/native-harness/test/model-runner.test.ts +117 -0
  387. package/src/native-harness/test/model-storage.test.ts +99 -0
  388. package/src/native-harness/test/model-stream-adapter.test.ts +26 -0
  389. package/src/native-harness/test/model-stream-public.test.ts +77 -0
  390. package/src/native-harness/test/notices.test.ts +64 -0
  391. package/src/native-harness/test/openrouter-config.test.ts +218 -0
  392. package/src/native-harness/test/operator-controls.test.ts +132 -0
  393. package/src/native-harness/test/output.test.ts +44 -0
  394. package/src/native-harness/test/owner-config.test.ts +64 -0
  395. package/src/native-harness/test/permissions-e2e.test.ts +68 -0
  396. package/src/native-harness/test/persistence.test.ts +236 -0
  397. package/src/native-harness/test/portability.test.ts +337 -0
  398. package/src/native-harness/test/protocol.test.ts +160 -0
  399. package/src/native-harness/test/reminder-clock.test.ts +61 -0
  400. package/src/native-harness/test/reminder-stdio.test.ts +140 -0
  401. package/src/native-harness/test/reminder-storage.test.ts +124 -0
  402. package/src/native-harness/test/scenario-jsonl.test.ts +112 -0
  403. package/src/native-harness/test/scripted.test.ts +92 -0
  404. package/src/native-harness/test/session-file.test.ts +51 -0
  405. package/src/native-harness/test/startup-channel-changes.test.ts +256 -0
  406. package/src/native-harness/test/stdio.test.ts +132 -0
  407. package/src/native-harness/test/storage-memory.test.ts +4 -0
  408. package/src/native-harness/test/storage-sqlite.test.ts +420 -0
  409. package/src/native-harness/test/suspension.test.ts +430 -0
  410. package/src/native-harness/test/timeline-retrieval.test.ts +211 -0
  411. package/src/native-harness/test/tools-catalog.test.ts +468 -0
  412. package/src/native-harness/test/tools-protocol.test.ts +418 -0
  413. package/src/native-harness/test/transfers.test.ts +94 -0
  414. package/src/native-harness/test/web-chat.test.ts +35 -0
  415. package/src/native-harness/tsconfig.json +20 -0
  416. package/src/observation/agent-event-bus.ts +44 -18
  417. package/src/observation/index.ts +1 -0
  418. package/src/operations/contracts.ts +11 -3
  419. package/src/operations/errors.ts +5 -0
  420. package/src/operations/stale-policy.ts +1 -1
  421. package/src/operations/supervisor.ts +34 -10
  422. package/src/orchestrator/acp-delivery.ts +68 -0
  423. package/src/orchestrator/assignments.ts +27 -0
  424. package/src/orchestrator/busy.ts +15 -0
  425. package/src/orchestrator/config.ts +41 -0
  426. package/src/orchestrator/consumer-api.ts +24 -0
  427. package/src/orchestrator/contracts.ts +71 -0
  428. package/src/orchestrator/durable-assignments.ts +111 -0
  429. package/src/orchestrator/native-delegation.ts +103 -0
  430. package/src/orchestrator/orchestrator.ts +318 -0
  431. package/src/orchestrator/permissions.ts +25 -0
  432. package/src/orchestrator/policy.ts +44 -0
  433. package/src/orchestrator/pool.ts +123 -0
  434. package/src/orchestrator/tool-descriptions.ts +11 -0
  435. package/src/permissions/acp.ts +18 -0
  436. package/src/permissions/arrival.ts +13 -0
  437. package/src/permissions/consumer-config.ts +19 -0
  438. package/src/permissions/conversation.ts +280 -0
  439. package/src/permissions/matcher.ts +85 -0
  440. package/src/permissions/outcome.ts +15 -0
  441. package/src/permissions/policy.ts +81 -0
  442. package/src/permissions/request.ts +26 -0
  443. package/src/persistence/activity-projection.ts +1 -0
  444. package/src/persistence/backend.ts +34 -1
  445. package/src/persistence/channels.ts +23 -0
  446. package/src/persistence/index.ts +4 -0
  447. package/src/persistence/protocol-method.ts +5 -0
  448. package/src/persistence/reminder-wake.ts +49 -0
  449. package/src/persistence/reminders.ts +385 -0
  450. package/src/persistence/sqlite-backend.ts +84 -6
  451. package/src/persistence/sqlite-channels.ts +65 -0
  452. package/src/persistence/sqlite-reminders.ts +85 -0
  453. package/src/persistence/sqlite-schema.ts +108 -3
  454. package/src/persistence/sqlite-worker-delivery.ts +374 -0
  455. package/src/persistence/sqlite-workers.ts +59 -0
  456. package/src/persistence/worker-delivery-contract.ts +104 -0
  457. package/src/persistence/worker-terminal-reason.ts +29 -0
  458. package/src/persistence/workers.ts +19 -0
  459. package/src/provider-notices.ts +137 -0
  460. package/src/repl/commands.ts +2 -2
  461. package/src/steering/combine.ts +3 -1
  462. package/src/steering/contracts.ts +11 -2
  463. package/src/steering/controller.ts +3 -2
  464. package/src/transport/acp-transport.ts +24 -14
  465. package/src/types.ts +15 -12
  466. package/src/updates.ts +14 -2
  467. package/src/wire-log.ts +1 -1
@@ -0,0 +1,21 @@
1
+ # Architecture documentation
2
+
3
+ Updated: 2026-11-20.
4
+
5
+ These pages describe the implemented harness. The reviewed foundation is on
6
+ `alpha`. The acp-client adapter and startup channel changes are implemented on
7
+ `acp-client-integration` and awaiting independent review. The
8
+ [work index](../docs/WORK.md) tracks proposed slices and review status.
9
+
10
+ | Document | Purpose |
11
+ | --- | --- |
12
+ | [Overview](overview.md) | Agent, channels, owners, and entry points |
13
+ | [Technical architecture](technical-architecture.md) | Runtime composition and the path from input to reply |
14
+ | [Execution](execution.md) | Scheduling, steering, model calls, permissions, and tool dispatch |
15
+ | [Context and data](context-and-data.md) | Shared timeline, derived requests, and inspection |
16
+ | [Persistence](persistence.md) | Storage adapters, recovery, and session files |
17
+ | [Suspend, stop, and resume](suspend-and-resume.md) | Session and channel lifecycle, interruption, and process replacement |
18
+
19
+ The root [ARCHITECTURE.md](../../ARCHITECTURE.md) defines dependency boundaries
20
+ and target layout. [Decision records](../decisions/) and the linked specs define
21
+ the exact contracts. Update these pages when implemented behavior changes.
@@ -0,0 +1,31 @@
1
+ # Context and data
2
+
3
+ | Layer | Responsibility |
4
+ | --- | --- |
5
+ | Storage | Commit inbox items, timeline entries, turn and channel state, and model-call records. |
6
+ | Queries | Read neutral storage snapshots. The protocol projects revisioned status and load views, message pages, and model-call records. |
7
+ | Context builder | Render a fresh inference request for the active turn from the stored timeline and system prompt. |
8
+
9
+ The timeline is the common record for all channels. It orders events and
10
+ attributes them to a sender, channel, and turn. A pending input lives in the
11
+ inbox and joins the timeline when taken. The agent can have several inference
12
+ requests in flight, each built from the timeline as it existed when that
13
+ iteration started. Later entries are available at a later inference boundary.
14
+
15
+ The [context builder](../../src/capabilities/context/build.ts) combines the
16
+ system prompt, channel and participant labels, attributed shared history,
17
+ and the active turn's native messages. The active turn is excluded from the
18
+ shared-history block so its tool calls and results appear once as paired
19
+ messages. Notices carry source attribution. Opaque provider state stays out of
20
+ shared text. Tool definitions are a separate model-request field.
21
+
22
+ The current builder includes other channels' history and tool result content.
23
+ Bounded recall, compaction, and history access rules remain open. The tool
24
+ permission gate governs execution; shared history has its own visibility
25
+ design to complete. See the [work index](../docs/WORK.md).
26
+
27
+ The development inspector's **Live context** tab shows a rendering of the
28
+ current shared base. **Channels** shows captured inference requests and
29
+ results for individual turns. These are distinct data sources. A current
30
+ rendering can change while an older captured inference request stays fixed.
31
+ The inspector also reads stored model-call records after SQLite reopen.
@@ -0,0 +1,42 @@
1
+ # Execution
2
+
3
+ ## Admission and scheduling
4
+
5
+ Messages and channel notices enter a committed inbox before acknowledgment.
6
+ A channel takes pending items before its next inference, or starts a turn if
7
+ it is idle. Several inputs can share one turn and its outcome. Scheduling is
8
+ serial within one channel and concurrent across channels.
9
+
10
+ In the development scenario, `notify_channel` submits an attributed internal
11
+ notice to an existing target channel. It can steer a running turn or wake an
12
+ idle channel. Ordinary shared timeline entries become visible at the next
13
+ inference without starting work. The pending-input check and the transaction
14
+ that finishes a turn determine whether a racing input extends that turn or
15
+ starts the next one.
16
+
17
+ ## Inference and tool execution
18
+
19
+ Each iteration checks for suspension, takes eligible input, renders context,
20
+ and asks the model for a response. The model runner owns attempts and usage.
21
+ Its ordinary 120-second deadline includes streaming, any retry delay, and one
22
+ eligible retry. The retry window closes when the runner accepts the first
23
+ nonempty text delta for publication or commits a response. Draft text can be
24
+ delivered as deltas or buffered for clients that want complete messages.
25
+
26
+ The assistant response commits before tool dispatch. Tool calls run in order
27
+ within an iteration. The permission gate evaluates the policies contributing
28
+ to the turn, handles approval when required, and records dispatch evidence
29
+ before an executor can have an external effect. A result is paired with the
30
+ model's call ID. Approval waits and model deadlines are separate. Tool
31
+ approval identifiers and one-time grants are scoped to the live service.
32
+
33
+ When no tool calls or pending inbox items require another iteration, the turn
34
+ finishes. A failed or interrupted turn leaves the channel usable. The harness
35
+ fences late results from an interrupted turn. Recorded dispatch without a
36
+ committed result is reported as uncertain and is never automatically replayed.
37
+
38
+ See [model execution](../docs/model-execution/0001-DESIGN/SPEC.md) for attempts,
39
+ delivery, and usage, and [configuration and permissions](../docs/11-19-config-permissions/SPEC.md)
40
+ for policy composition and approval. The [callbacks proposal](../docs/tools-and-callbacks/0001-DESIGN/SPEC.md)
41
+ extends this dispatch path with host functions, invocation status, and scoped
42
+ result references.
@@ -0,0 +1,44 @@
1
+ # Overview
2
+
3
+ A native harness session represents one agent with a shared identity, system
4
+ prompt, configuration, and timeline. The harness owns its channels. Each
5
+ channel has its own inputs, participants, policy, and turns. At most one turn
6
+ executes at a time on a channel. Different channels can await models and tools
7
+ concurrently.
8
+
9
+ ## Ownership
10
+
11
+ | Component | What it owns |
12
+ | --- | --- |
13
+ | Harness session | Configuration, approval handling, shared timeline, session lifecycle, and storage ownership |
14
+ | Channel scheduler | Admission, turn scheduling, and channel lifecycle |
15
+ | Turn | Inferences and tool invocations, with their results attributed to the turn and channel |
16
+ | Model adapter | Translating neutral requests and provider responses |
17
+ | Consumer host | Process launch, transport, conversation-to-channel mapping, and application records |
18
+ | Client attachment | Observing a channel and delivering its updates to a participant |
19
+
20
+ A turn can run without anyone observing its channel. A participant closing a
21
+ development chat subscription leaves accepted work in the harness. On the
22
+ integration branch, native controller shutdown currently requests a targeted
23
+ interrupt before detaching. The [operator controls proposal](../docs/operator-controls/0001-DESIGN/SPEC.md)
24
+ defines attachment disposal independently of channel and agent controls.
25
+
26
+ The host can provide policy and respond to approvals. Consumer-registered
27
+ tool callbacks are [proposed](../docs/tools-and-callbacks/0001-DESIGN/SPEC.md).
28
+ Coding workers and their orchestration belong to the consumer.
29
+
30
+ ## Entry points
31
+
32
+ Paths are relative to the harness package.
33
+
34
+ | Entry point | Role |
35
+ | --- | --- |
36
+ | [`src/index.ts`](../../src/index.ts) | Assemble a session with its configured services and storage |
37
+ | [`src/client.ts`](../../src/client.ts) | Typed public client and in-process and stdio transports |
38
+ | [`src/testing.ts`](../../src/testing.ts) | Scripted model helpers for offline tests |
39
+ | `bun run serve --stdio` | Newline-delimited JSON-RPC endpoint. Use `--home` for managed SQLite sessions. |
40
+ | `bun run start` and `bun run chat` | Development runtime and terminal chat over Unix-socket HTTP, with an inspector and optional web chat |
41
+
42
+ Development HTTP and stdio are separate interfaces over the same session
43
+ assembly. The stdio host launches the child and holds the connection. See the
44
+ [package README](../../README.md) for commands and supported operations.
@@ -0,0 +1,56 @@
1
+ # Persistence
2
+
3
+ The [storage contract](../../src/contracts/storage.ts) has two adapters over
4
+ one [transaction engine](../../src/state/storage/engine.ts). Memory uses maps
5
+ and lasts for the process. SQLite uses `bun:sqlite`, `synchronous=FULL`, and
6
+ an exclusive owner for each session file. Model inference, tool execution,
7
+ and network waits happen outside storage transactions.
8
+
9
+ ## Durable boundaries
10
+
11
+ 1. Receipt commits the accepted input to the inbox, keyed by its stable ID.
12
+ 2. Take associates it with a turn and appends its timeline entry.
13
+ 3. A model response commits its assistant message and recorded calls.
14
+ The model runner also records attempts and provider-reported usage.
15
+ 4. Tool dispatch evidence precedes possible external effects. The paired tool
16
+ result commits separately.
17
+ 5. Turn outcome and suspension checkpoints commit before they are reported.
18
+
19
+ The storage snapshot includes configuration and policy metadata, channel
20
+ lifecycle and identities, pending and taken input, timeline entries, turns,
21
+ checkpoints, and model-call records. SQLite format 5 is the current on-disk
22
+ schema. Storage and context rendering have separate contracts.
23
+
24
+ ## Recovery
25
+
26
+ Opening storage runs recovery before execution. Clean suspension preserves
27
+ checkpoints. Abrupt loss interrupts unfinished turns outside a clean
28
+ suspension, while committed individual channel suspensions and their
29
+ checkpoints survive. Untaken inputs stay pending. An interrupted turn retains
30
+ committed output and reports tool calls whose effects are uncertain. The
31
+ harness never automatically repeats those calls.
32
+
33
+ Transport events are live. Use `session/load` and its message pages to recover
34
+ committed replies or outcomes after a disconnect. The protocol writes the
35
+ initial load response before starting recovered work. On the integration
36
+ branch, startup channel changes are applied before pending input becomes
37
+ eligible. See [the integration log](../docs/acp-client-integration/0001-DESIGN/11-20-LOG.md)
38
+ for the acceptance status and the current startup batch limitations.
39
+
40
+ ## Session files
41
+
42
+ Export writes a binary `.harness` envelope, version 1, containing the logical
43
+ archive (currently version 4) and active portable configuration. Use a path
44
+ when the host and harness share a filesystem, or the protocol's bounded
45
+ transfer otherwise. Export requires clean suspension or a running session
46
+ without active or checkpointed turns, pending input, or a suspending channel.
47
+
48
+ Import validates the file and creates a new stored session without starting
49
+ it. A managed reopen can use the saved configuration. Credentials remain
50
+ environment references and script paths still require the destination's
51
+ script. Tool-owned external state stays with its owner. To relocate an agent,
52
+ stop the source before resuming the imported copy.
53
+
54
+ See [persistence](../docs/11-16-persistence/SPEC.md),
55
+ [the session-file amendment](../docs/persistence/0002-AMENDMENT-session-file/SPEC.md),
56
+ and [the lifecycle guide](suspend-and-resume.md).
@@ -0,0 +1,45 @@
1
+ # Suspend, stop, and resume
2
+
3
+ The harness owns lifecycle transitions and checkpoints. The host owns launch,
4
+ shutdown, updates, and relocation.
5
+
6
+ | Scope | Operation | Outcome |
7
+ | --- | --- | --- |
8
+ | Session | Suspend | Block new external work, reach resumable boundaries, and acknowledge once suspension commits. |
9
+ | Session | Resume | Check compatibility and make eligible channels runnable. Individually suspended channels stay suspended. |
10
+ | Session | Stop | Interrupt running work immediately and refuse further work in this runtime. Stdio EOF has stop semantics. |
11
+ | Channel | Suspend | Close that channel's admission and wait for its execution boundary. Other channels can continue. |
12
+ | Channel | Resume | Clear that channel's suspension. Execution also requires an eligible session. |
13
+ | Turn | Interrupt | End the exact running turn and fence its late results. The channel can run other eligible work. |
14
+
15
+ ## What suspension saves
16
+
17
+ The running model request can finish. Already dispatched tools can settle.
18
+ Pending approvals affected by suspension close through the existing permission
19
+ gate. The turn can complete naturally or checkpoint before its next inference.
20
+ Accepted input stays durable. During session suspension, valid notices from
21
+ finishing work can be accepted for open target channels and wait for resume.
22
+ An individually suspending or suspended target refuses new work.
23
+
24
+ A checkpoint preserves the turn ID, messages, paired tool results, and pending
25
+ work. Resume continues the same turn without repeating recorded calls. A
26
+ suspension may wait as long as a running tool. Interrupting the turn can end
27
+ that wait; already performed tool effects can remain uncertain.
28
+
29
+ ## Process replacement and recovery
30
+
31
+ For a planned update, wait for suspend to confirm, then close the process to
32
+ release storage ownership. Reopen the same session with the replacement.
33
+ Loading a suspended session preserves its suspension. Explicit resume
34
+ checks compatibility before making work eligible.
35
+
36
+ If the process dies while still suspending, recovery interrupts unfinished
37
+ work outside previously committed individual channel suspensions. It preserves
38
+ untaken input, committed output, and uncertainty records. For relocation
39
+ between homes, use the [session file](persistence.md).
40
+
41
+ A client attachment and the host's stdio connection have distinct lifetimes.
42
+ Closing the stdio connection stops execution. The proposed operator view
43
+ models client connection, channel lifecycle, and agent lifecycle independently.
44
+ See [operator and consumer controls](../docs/operator-controls/0001-DESIGN/SPEC.md)
45
+ and [the accepted channel controls](../docs/11-19-channel-controls/SPEC.md).
@@ -0,0 +1,50 @@
1
+ # Technical architecture
2
+
3
+ ## Runtime composition
4
+
5
+ | Component | Code | Role |
6
+ | --- | --- | --- |
7
+ | Public client and protocol endpoint | [Client](../../src/interfaces/client.ts), [endpoint](../../src/interfaces/protocol/server.ts) | Validate wire requests, call session operations, and publish responses and events |
8
+ | Session assembly | [createSession](../../src/index.ts) | Wire storage, turn services, context, approvals, and observation |
9
+ | Channel scheduler | [channels.ts](../../src/kernel/channels.ts) | Schedule channels, own cancellation signals, and commit lifecycle transitions through storage |
10
+ | Turn loop | [loop.ts](../../src/kernel/loop.ts) | Coordinate repeated inference, paired tool results, completion, and checkpoint boundaries |
11
+ | Context builder | [build.ts](../../src/capabilities/context/build.ts) | Create model messages from a fresh timeline snapshot |
12
+ | Model runner | [runner.ts](../../src/capabilities/model/runner.ts) | Run attempts, enforce deadlines and retries, commit responses, and record usage |
13
+ | Policy and approval | [resolve.ts](../../src/governance/policy/resolve.ts), [gate.ts](../../src/governance/permissions/gate.ts) | Resolve policy and authorize each tool dispatch |
14
+ | Storage | [contract](../../src/contracts/storage.ts), [engine](../../src/state/storage/engine.ts) | Own transactional state changes over the memory and SQLite adapters |
15
+
16
+ The kernel uses contracts for I/O. The entry point composes the implementations.
17
+ The protocol adapts session operations to the wire and owns delivery concerns
18
+ such as framing and buffering. It delegates lifecycle and admission to the
19
+ session. The host uses public exports.
20
+
21
+ ## One message through stdio
22
+
23
+ 1. The client initializes, negotiates delivery, and creates or loads the
24
+ session. A durable load returns a revisioned view before recovered work
25
+ starts publishing live events.
26
+ 2. `channel/push` commits the input to the inbox. Its reply acknowledges
27
+ receipt. The same input ID and payload can be retried without accepting
28
+ it twice.
29
+ 3. The scheduler starts the channel's next turn or takes the input into the
30
+ running turn at the next inference boundary. Taking creates the attributed
31
+ timeline entry and associates the input with the turn.
32
+ 4. The context builder renders the current snapshot. The model runner executes
33
+ the request, optionally emits draft text, and commits the completed model
34
+ response. A committed assistant message has a stable message ID.
35
+ 5. Each requested tool passes through the same permission gate. The harness
36
+ records dispatch evidence before execution and pairs any usable result
37
+ with the request. The next iteration builds context again.
38
+ 6. The turn finishes, fails, is interrupted, or reaches a suspension checkpoint.
39
+ Conversation output and turn outcome are separate events. After a missed
40
+ reply, the client can load its committed message and turn state.
41
+
42
+ ## acp-client integration
43
+
44
+ On the integration branch, [NativeHarnessHost](../../../../src/native/host.ts)
45
+ owns the stdio child for an agent. [NativeController](../../../../src/native/controller.ts)
46
+ maps one conversation to one channel and adapts harness events to the existing
47
+ conversation supervisor. The host reconciles the load view with live events
48
+ and keeps submission IDs for safe retry. It can pass pending channel changes
49
+ with startup. The [integration log](../docs/acp-client-integration/0001-DESIGN/11-20-LOG.md)
50
+ records the implemented checkpoint, review status, and recovery gaps.
@@ -0,0 +1,11 @@
1
+ # Basic loop contracts
2
+
3
+ The first runnable slice needs a model boundary without making the loop depend
4
+ on OpenRouter. Use neutral messages, tool definitions, and an injected model
5
+ function. Tool calls carry IDs and raw JSON arguments; each receives one result.
6
+ Opaque provider state travels on assistant messages and is interpreted only by
7
+ the originating adapter. Tool execution is injected by the entry point.
8
+
9
+ This is an initial, non-streaming contract, not the complete v1 API. Streaming,
10
+ cancellation and richer outcomes will require a later contract decision. There
11
+ are no existing API consumers to migrate.
@@ -0,0 +1,17 @@
1
+ # Channel input and execution
2
+
3
+ One agent owns shared configuration and a map of channels. Inputs contain a
4
+ channel ID, participant ID and text. Each channel owns its history and a promise
5
+ queue; different channels execute concurrently. Participant identity is supplied
6
+ by the client and labeled in context, not authenticated in this increment.
7
+
8
+ The transport calls a small Agent interface and does not own history. The kernel
9
+ receives an injected turn runner so it depends only on contracts. HTTP over a
10
+ Unix socket connects separate local CLI processes. This experimental endpoint is
11
+ not the eventual host protocol.
12
+
13
+ An execution failure blocks that channel until process restart, avoiding reuse
14
+ of incomplete tool exchanges or automatic replay of side effects. Disconnects
15
+ do not delete channels or cancel accepted turns. All state is in memory.
16
+
17
+ This adds an initial channel API; the existing loop contract is unchanged.
@@ -0,0 +1,14 @@
1
+ # Inference inspection
2
+
3
+ The development inspector needs immutable snapshots of actual inference requests,
4
+ not reconstructed history. Add an optional OpenRouter request observer called
5
+ with the serialized request body before fetch. It receives no authorization
6
+ headers. The model and turn contracts stay unchanged.
7
+
8
+ Composition at the CLI observes channel submissions, turns, model responses and
9
+ tool results. Inspection state and the read-only HTTP/SSE UI live under
10
+ `src/interfaces/inspector/`, outside the kernel and model context. SSE sends full
11
+ snapshots on connection and updates, allowing refresh and reconnect without event
12
+ replay. Inspection data is in memory for this learning increment.
13
+
14
+ The observer is optional and existing adapter callers remain compatible.
@@ -0,0 +1,21 @@
1
+ # Shared context foundation
2
+
3
+ One agent-owned append-only store replaces independent channel histories as the
4
+ source of truth. Entries carry sequence, timestamp, channel, turn and sender.
5
+ Incoming messages are recorded on acceptance; responses and tool results are
6
+ recorded as they occur. Append and snapshot deep-copy values.
7
+
8
+ Before each inference a pure builder renders a store snapshot, the unchanged
9
+ system prompt and current channel/turn. Other turns are attributed JSON data;
10
+ the active turn keeps native assistant/tool exchanges together. Opaque provider
11
+ state is retained only for the active turn, never copied into shared text.
12
+ Tool definitions continue through the separate model argument.
13
+
14
+ Agent runners receive turn identity instead of a private messages array. The
15
+ loop receives append/build operations instead of mutating history. Composition
16
+ wires these contracts; kernel modules do not import storage or rendering.
17
+
18
+ This initial internal contract change updates existing callers and offline tests.
19
+ It deliberately includes all shared events without summaries or scope filtering.
20
+ Channel queues remain independent. Notices, wake behavior, persistence and the
21
+ inspector tab redesign are later work.
@@ -0,0 +1,20 @@
1
+ # Notices and simulated work
2
+
3
+ `Agent.notify` accepts a directed notice for an existing channel. An accepting
4
+ active turn queues it; otherwise it schedules a new turn without awaiting its
5
+ completion. Receipts distinguish inbox delivery from a new turn and expose an
6
+ internal completion promise for observation, not model serialization.
7
+
8
+ Each runner receives a mailbox: drain appends notices as attributed user messages
9
+ before inference, and finish synchronously closes admission only when empty.
10
+ The loop ends only on no tool calls and a successful finish. This removes the
11
+ busy-to-idle delivery gap without additional validation calls or a notice-pass
12
+ limit. Tool results are paired before queued notices are appended.
13
+
14
+ The development tools share one five-step dashboard job. Each step takes five
15
+ seconds; duplicate dashboard calls in one inference are rejected by the tool
16
+ executor. Concurrent attempts return busy. The model decides whether changed
17
+ instructions warrant stopping; no background job runs between steps.
18
+
19
+ The new contracts extend internal APIs; existing callers are updated. General
20
+ policy, cancellation, persistence and cross-process notice APIs are deferred.
@@ -0,0 +1,12 @@
1
+ # Explicit notice representation
2
+
3
+ Context entries and accepted turn inputs distinguish participant messages from
4
+ channel notices, recording a notice's source channel. Both idle and busy delivery
5
+ use the same entry shape; idle notices no longer pass through participant-message
6
+ formatting. A context renderer presents notices as user-role internal inputs from
7
+ another execution of the same agent. Provider roles and tool exchanges are unchanged.
8
+
9
+ The inspector uses typed notice entries to highlight their rendered messages in
10
+ violet, independently of the initiating participant prompt. Existing in-memory
11
+ data without kind metadata remains readable; new inputs always carry a kind.
12
+ No persisted data or public protocol migration is required.
@@ -0,0 +1,12 @@
1
+ # Terminal channel subscriptions
2
+
3
+ Completed turns publish channel-scoped reply/error events through a host-owned
4
+ output port. The Unix HTTP adapter exposes read-only SSE subscriptions. Chat
5
+ clients subscribe before accepting input and render replies only from that stream,
6
+ avoiding duplicates with the existing POST response. Notice-triggered turns use
7
+ the same completion path. No kernel or inference behavior changes.
8
+
9
+ Subscriptions deliver future events, not transcript replay. A lost subscription
10
+ closes the chat with a visible reconnect instruction rather than silently dropping
11
+ answers. Disconnecting a client does not cancel accepted agent work. `/clear`
12
+ only clears the local terminal, preserving both channel state and subscription.
@@ -0,0 +1,16 @@
1
+ # Local LAN browser client
2
+
3
+ A separate LAN HTTP listener serves a mobile-friendly chat and delegates channel
4
+ requests to the same handler as the Unix transport. It shares the running agent
5
+ and output port, without changing kernel execution or model context. The inspector
6
+ remains loopback-only and its routes are not exposed by the chat listener.
7
+
8
+ Startup prints pairing URLs for local interfaces with a fresh random token. The
9
+ token is required for message and subscription requests; the page keeps it in
10
+ session storage and removes it from the address bar. This is a development access
11
+ mechanism, not participant authentication or a replacement for future policy.
12
+ Same-origin requests are enforced when an Origin header is present.
13
+
14
+ The buildless browser UI joins one channel, sends messages and displays future
15
+ replies, including notice-triggered output. History replay, rich Markdown,
16
+ automatic reconnection and remote hosting are outside this increment.
@@ -0,0 +1,18 @@
1
+ # Scripted model for offline execution
2
+
3
+ Use the existing Model contract with a sequential, instance-local JSON script.
4
+ Version 1 contains responses with content and optional tool calls. Script call
5
+ arguments are JSON objects and are serialized to the neutral contract's string
6
+ arguments. Validate the complete script before execution, reject unknown fields,
7
+ and fail explicitly on malformed files or exhaustion.
8
+
9
+ Capture each invocation's messages and tool definitions by value, including an
10
+ exhausted invocation, and return copies for inspection. No API request or inference
11
+ occurs. The script's final text is predetermined; tests separately verify actual
12
+ tool execution and the request that follows it.
13
+
14
+ A dedicated scenario CLI composes the real store, builder, scheduler and loop
15
+ with the scripted model and echo tool. Echo is registered only there and in tests,
16
+ never in normal startup. Instances consume responses in call order; callers needing
17
+ independent concurrent scripts must use separate instances. No kernel contracts,
18
+ stdio transport, normal launch behavior or persistence change in this increment.
@@ -0,0 +1,19 @@
1
+ # Experimental in-process protocol
2
+
3
+ Implement initialize, session/create, channel/push and session/idle with the spec's
4
+ JSON-RPC-shaped envelopes and channel/event notifications. Version 1 here is an
5
+ explicit experimental subset, not full protocol conformance. Initialize reports
6
+ supported methods and memory-only acceptance. Reject unsupported options rather
7
+ than silently pretending to implement them. No stdio or durable acceptance yet.
8
+
9
+ Execution emits completed textual messages independently of turn completion,
10
+ including tool preludes. Clients consume these events once, without republishing
11
+ the loop's final return. Channel lifecycle and notice admission emit ordered events.
12
+ The public client correlates requests and bounds waits; in-process transport JSON
13
+ copies envelopes. Per-session item IDs deduplicate accepted inputs; conflicting
14
+ reuse fails. Scripted models are injected per channel, not globally shared.
15
+
16
+ Extract a host-independent session composition entry point with injected models,
17
+ tools and optional inspector wrappers. Existing development hosts use it too.
18
+ Storage remains in memory. Unsupported lifecycle/settings/subscription features
19
+ fail explicitly. Persistence, rich subscriptions and stdio are subsequent work.
@@ -0,0 +1,21 @@
1
+ # Stdio transport and connection lifecycle
2
+
3
+ Carry the existing experimental protocol as newline-delimited UTF-8 JSON. Reuse
4
+ one scripted server factory for in-process and stdio. Only protocol goes to stdout;
5
+ diagnostics go to stderr. No HTTP listeners or credentials are required.
6
+
7
+ Client transports report closure/errors, rejecting pending and future calls
8
+ immediately. The stdio transport accepts host-owned byte streams/write/end
9
+ operations and optional process-exit promise; it never launches or kills processes.
10
+ Frames are bounded at 1 MiB and queued writes at 4 MiB, with serialized async writes.
11
+ Malformed client JSON returns a parse error; malformed server output terminates
12
+ the connection. An unfinished frame at EOF is a framing failure.
13
+
14
+ EOF stops request admission, drains accepted work and writes within a five-second
15
+ deadline, then exits. Timeout is a nonzero failure, not interrupted-and-persisted
16
+ shutdown. No persistence, replay, cancellation or restart guarantees are added.
17
+
18
+ Superseded in part by [0013](0013-durable-delivery-contract.md): once persistent
19
+ stop is wired, EOF is an immediate stop that interrupts active turns, with no
20
+ drain. That is now the server's behavior; the five-second deadline remains only
21
+ as a bound on settling requests already read and flushing output.
@@ -0,0 +1,37 @@
1
+ # Session storage contract, revision 1
2
+
3
+ ## Problem and options
4
+
5
+ Persisting only `SharedContextStore` would retain messages while resetting turn
6
+ IDs, channel status and knowledge of unfinished work. Options are to extend that
7
+ context-only interface, expose general database transactions to the kernel, or
8
+ introduce a session-storage contract with atomic domain operations.
9
+
10
+ ## Choice
11
+
12
+ Add the type-only `contracts/storage.ts` for history restoration. A single owner
13
+ opens one session, explicitly creating or reopening it. Storage atomically accepts
14
+ input, allocates IDs, records execution and returns neutral snapshots. Expected
15
+ failures are typed results; synchronous operations preserve the scheduler's local
16
+ admission boundaries. No transaction spans inference or tool execution.
17
+
18
+ Open checks format/configuration compatibility and exclusive ownership. Reopen
19
+ marks leftover queued/running turns interrupted atomically. Failure and
20
+ interruption are terminal outcomes for a turn. The channel remains available
21
+ for new work even if an input went unanswered. Nothing executes on open.
22
+ Configuration identity is an explicit
23
+ caller-supplied compatibility key, not inferred from tool names or credentials.
24
+
25
+ Suspend/resume requires a subsequent contract revision for durable notices,
26
+ deduplication, lifecycle transitions and checkpoints. Keep input and turn identity
27
+ explicit now so that revision can preserve queued work from clean suspension.
28
+ Revision 1 must not claim durable inboxes or resumable shutdown.
29
+
30
+ ## Compatibility and verification
31
+
32
+ This is an additive, unconnected contract. Existing session/store APIs, kernel,
33
+ protocol and behavior remain unchanged. Adapter implementations and runtime wiring
34
+ follow in a separately approved increment. Both memory and SQLite adapters must
35
+ pass the conformance checklist in the persistence document before integration.
36
+ This increment verifies type correctness and dependency boundaries only; no
37
+ storage behavior is claimed without an implementation.
@@ -0,0 +1,64 @@
1
+ # Durable delivery, lifecycle and load contract (storage revision 2)
2
+
3
+ ## Problem and options
4
+
5
+ Revision 1 (0012) saves one queued turn per input, cannot deduplicate, loses
6
+ notices and has no suspension. `Agent.send` resolves with the reply, so
7
+ acceptance and completion are one promise. Options: (a) keep one turn per input
8
+ and add a separate notice table; (b) keep send-awaits-reply and add an ack
9
+ callback; (c) one durable inbox for messages and notices, turns created at take.
10
+
11
+ ## Choice
12
+
13
+ (c). `contracts/storage.ts` is rewritten as format 2; nothing implemented it.
14
+
15
+ - **Acceptance.** `acceptItem` commits a pending item (Received). `send`/`notify`
16
+ on the new `SessionAgent` return a synchronous `SendResult` after that commit.
17
+ Same ID and payload returns the original in every lifecycle state; a different
18
+ payload is `item_conflict`.
19
+ - **Take and correlation.** `beginTurn`/`takePending` move pending items into the
20
+ timeline and link them to the turn in one transaction. `turn_started`/`turn_took`
21
+ list the item IDs; `message_completed` and `turn_ended` report the outcome
22
+ separately. Several IDs may share a turn. No public wait-for-reply helper. The
23
+ local chat adapter follows these events privately to hold its HTTP request
24
+ until the turn that took its item ends.
25
+ - **Finish.** `finishTurn(completed)` checks the pending inbox in its own
26
+ transaction and returns `finished: false` if items arrived first. Running:
27
+ take and infer again. Suspending: checkpoint; the resumed turn takes them.
28
+ - **Failure.** Failed and interrupted turns are terminal; the channel stays
29
+ usable. Calls without a recorded result become `uncertainCallIds` and are never
30
+ re-executed. `appendMessage` on an ended turn is refused, fencing late results.
31
+ - **Lifecycle.** `beginSuspend`, `checkpointTurn`, `completeSuspend`, `resume`.
32
+ A naturally finished turn completes and cannot be checkpointed. Only committed
33
+ `suspended` preserves checkpoints across reopen; any other reopen interrupts
34
+ unfinished turns. Open never writes the compatibility key; a mismatch fails
35
+ only `resume`, which then writes nothing.
36
+ - **Load.** `session/load` returns one view at a storage revision. Events carry
37
+ `revision`. Events included in the view precede the response or are dropped;
38
+ pending input becomes eligible only after the response is written.
39
+ - **Receipts.** `confirmReceipts` records Delivered/Seen for the items of the
40
+ turn whose model call resolved; `items_receipt` follows the commit.
41
+ - **Stop.** `interruptActive` interrupts running turns; while suspending it also
42
+ interrupts checkpointed turns and returns the lifecycle to running. `Model` and
43
+ `ExecuteTool` accept an optional abort signal. Stdin EOF becomes stop,
44
+ replacing 0011's five-second drain when wired.
45
+ - **Archive.** `exportArchive`/`importArchive` use a logical `SessionArchive`
46
+ (version 1, independent of the storage format). Wire transfer: 512 KiB chunks,
47
+ 256 MiB maximum, one transfer per connection, temporary file removed on close,
48
+ import, 60 s idle or connection end.
49
+ - **Wire names.** `session/{load,messages,status,suspend,resume,stop,export,import}`,
50
+ `transfer/{open,write,read,close}`, notification `session/event` through
51
+ `subscribeSession`. Error codes: `DurableErrorCode` in `contracts/protocol.ts`.
52
+ Oversized load views and archives fail `transfer_limit` with nothing partial.
53
+ - **Identity.** Signatures are SHA-256 of a fixed JSON array; omitted item IDs
54
+ are `auto:<n>` from a durable counter.
55
+
56
+ ## Compatibility and verification
57
+
58
+ Additive for running code: the memory `Agent`, `TurnRunner` and `HarnessSession`
59
+ remain until Stage 3 replaces them with `SessionAgent`, `TurnExecutor` and
60
+ `PersistentSession`. Capabilities still report memory acceptance. A new turn now
61
+ takes every pending item on its channel, so queued messages can share one reply.
62
+ Item signatures cover joined text, not part boundaries. `channel/push`
63
+ `delivery` and `wake` are ignored. Load pages messages only. Verified by typecheck only; no storage
64
+ behavior is claimed before the adapters pass conformance.