@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,726 @@
1
+ # Native harness
2
+
3
+ One agent entity, with a stable identity, talking on many channels. Consumers
4
+ configure its instructions, tools and policy. This directory lives inside acp-client but
5
+ is intended to become a separate package: it must not import acp-client modules.
6
+
7
+ ## Current state
8
+
9
+ The harness runs one agent session with a shared timeline and concurrent
10
+ channels. Each channel runs one turn at a time. Use memory for a temporary
11
+ session or SQLite for durable receipt, restart recovery, and session files.
12
+ The public client supports stdio and in-process transports. Development chat
13
+ uses HTTP over a Unix socket and has a separate inspector.
14
+
15
+ The current harness supports channel and session controls, managed
16
+ configuration, tool policies and approvals, and streamed model calls with
17
+ recorded attempts and usage. Models can use OpenRouter or an offline script.
18
+ The [detailed architecture](.res/architecture/README.md) explains how these
19
+ parts fit together. The [work index](.res/docs/WORK.md) tracks remaining v1
20
+ work. Experiments live in [.res/sandbox/](.res/sandbox/).
21
+
22
+ ## Development
23
+
24
+ This directory is an independent TypeScript and Bun project (Bun >= 1.3.5), with
25
+ its own package manifest, lockfile and TypeScript configuration. It does not
26
+ depend on the parent acp-client package. Development dependencies are TypeScript
27
+ and Bun types; there are no runtime dependencies.
28
+
29
+ From this directory:
30
+
31
+ ```sh
32
+ bun install
33
+ bun run typecheck
34
+ bun run test
35
+ OPENROUTER_API_KEY=your-key bun run start
36
+ ```
37
+
38
+ Each plain `bun run start` creates a new durable session under
39
+ `~/.harness/sessions/<session-id>/session.sqlite`. Startup prints its ID and
40
+ database path. To reopen it, use the ID or the path. Use `--create` when you want
41
+ to choose the ID or file for a new session.
42
+
43
+ ```sh
44
+ bun run start --session <session-id> # reopen a saved session
45
+ bun run start --session project-a --create # create with a chosen ID
46
+ bun run start --db ./dev.sqlite --create # first run: the file must not exist
47
+ bun run start --db ./dev.sqlite # later runs: the file must exist
48
+ bun run start --db ./dev.sqlite --resume # also resume a suspended session
49
+ bun run status # lifecycle, active turns, pending input
50
+ bun run suspend # pause cleanly; waits for running tools
51
+ bun run resume # continue a suspended session
52
+ ```
53
+
54
+ Opening a database restores its timeline. The development command starts
55
+ eligible work when the session is running and preserves a committed suspension.
56
+ Turns a previous process left unfinished are marked interrupted and are not
57
+ retried; input that was accepted but never taken runs. A suspended session
58
+ stays paused, and refuses new messages, until `bun run resume` or `--resume`.
59
+ Ctrl+C stops at once: running turns are recorded as interrupted, so run
60
+ `bun run suspend` first to pause without losing work in progress. `status`,
61
+ `suspend` and `resume` talk to the running agent over its Unix socket; they are
62
+ not available from the LAN chat. `--script <file>` replaces the provider with
63
+ a scripted model for offline runs without a key; the file is one script, or
64
+ `{ "channels": { "<id>": script }, "default": script }`.
65
+
66
+ Leave the agent running. In separate terminals, from this directory:
67
+
68
+ ```sh
69
+ bun run chat channel1 alice
70
+ bun run chat channel2 bob
71
+ ```
72
+
73
+ `bun run start` also starts a browser chat on port 3001, bound to the LAN. Open
74
+ one of the printed Web chat pairing links on a phone connected to the same Wi-Fi
75
+ (choose the computer's LAN address, not `127.0.0.1`). Select a channel and name,
76
+ press Connect and send a message. It uses the same agent as the terminal clients
77
+ and receives notice-triggered replies through the same output subscriptions.
78
+ The pairing link changes on restart; it grants access to this development chat,
79
+ not a verified participant identity. No provider key is sent to the browser.
80
+
81
+ The CLI recovers a stale Unix socket owned by the current user. If a server
82
+ is listening there, connect with `bun run chat` or use a different
83
+ `HARNESS_SOCKET`. Unavailable default browser ports fall back to available
84
+ ports. Explicit port settings are honored, and 0 requests an available port.
85
+ Use the URLs printed at startup. The
86
+ phone needs network access to that port. The inspector stays local-only on port
87
+ 3000. Its Live Context tab shows a bounded preview across the session. Timeline
88
+ pages older events on request, and Channels shows recent captured requests
89
+ and can load recent durable model-call summaries. For an offline capture run,
90
+ use `HARNESS_CAPTURE_SCRIPT_REQUESTS=1 bun run start --script ./test-script.jsonl`.
91
+ New messages and notices have an 8 KiB UTF-8 text limit. Web chat currently shows future
92
+ replies, without replay or persistent browser history. Browser connections do not
93
+ automatically reconnect after a network loss; press Connect again.
94
+
95
+ Open the printed URL for the read-only context inspector. It starts with
96
+ the agent and opens on Live context, showing the rendered shared base and tool
97
+ definitions in one plain-text container. The system prompt and tools are visible
98
+ immediately, before any inference. Shared history updates as events are recorded;
99
+ the view excludes channel routing and active-turn additions. The same shared-base
100
+ builder is used to construct inference contexts.
101
+ Timeline is an empty placeholder. Channels shows participants, pending turns,
102
+ execution status and turns separated by their IDs. Each turn groups inference
103
+ iterations into an orange context card (with the initiating prompt highlighted)
104
+ and a blue result card, including tool calls and results. Expand Inference request
105
+ under its context for the exact JSON sent, or Provider response under its result
106
+ for the original assistant message. Authorization headers are not captured.
107
+ Snapshots remain unchanged as later turns run. Each channel also shows durable
108
+ model-call outcomes, attempts and provider-reported usage, including after reopen.
109
+
110
+ The page receives live updates over Server-Sent Events and reconnects with a
111
+ fresh snapshot. Set `HARNESS_INSPECTOR_PORT` on the agent to override port 3000
112
+ (use 0 to choose an available port); the actual URL is printed at startup.
113
+ The inspector binds only to `127.0.0.1` and stops with the agent. Its header
114
+ shows the session's lifecycle and storage, and each channel shows whether a
115
+ turn is running or checkpointed, its pending input, and a latest turn that
116
+ ended failed or interrupted with any tool calls left uncertain. With a
117
+ database, the shared timeline, Live context and channel messages are restored
118
+ at startup, before any new message. Captured inference requests are in memory,
119
+ grow during the run, and are lost on restart. It is a local
120
+ development view, without participant access controls or editing capabilities.
121
+
122
+ The chat clients do not need provider credentials. Type `/exit` to disconnect,
123
+ or `/clear` to clear the terminal screen and scrollback without resetting history.
124
+ Clients subscribe to future channel replies before accepting input, so turns
125
+ started by notices also reach connected terminals. Each answer prints once,
126
+ independently of the HTTP response. You can type while work runs; incoming replies
127
+ redraw the prompt and preserve your draft. A lost subscription closes the chat
128
+ with a reconnect instruction. Subscriptions do not replay old answers.
129
+ An animated spinner appears beside the terminal prompt while a submitted request
130
+ is pending. It clears on completion or error and does not print animation frames
131
+ to non-interactive output.
132
+ Replies render common Markdown as terminal emphasis, readable bullets and code
133
+ blocks, rather than printing prose delimiters. Non-TTY output and `NO_COLOR`
134
+ disable ANSI styling; code contents retain their literal Markdown symbols.
135
+ Reconnecting to the same channel continues its history while the agent is alive.
136
+ Messages sent to a channel while it is working join the turn in progress, and
137
+ their requests all complete with that turn's last reply.
138
+ A request still waiting when its turn is checkpointed by suspension is answered
139
+ with an explanation; the reply arrives through the subscription after resume.
140
+ Ctrl+C in the agent terminal stops it. Reopen the session to continue its history. Ask for the current
141
+ time to exercise tool use. Tools and results are logged in the agent terminal;
142
+ chat clients receive the final answer.
143
+
144
+ `src/interfaces/cli/main.ts` dispatches commands; `start.ts` beside it assembles
145
+ the agent and servers, and `chat.ts` owns terminal interaction. Development
146
+ defaults, including `systemPrompt`, live in `src/runtime/config/development.ts`.
147
+ The default model is `deepseek/deepseek-v4.1-flash`; override it with
148
+ `OPENROUTER_MODEL` on the agent process. Each input includes a participant ID,
149
+ which is labeled in model context. This is caller-supplied identity, not
150
+ authentication or a participant policy system.
151
+
152
+ The default socket is `native-harness-<uid>/agent.sock` under the OS temporary
153
+ directory. Its directory and socket are restricted to the current user. Set
154
+ `HARNESS_SOCKET` to an absolute socket path on both server and clients to override
155
+ it; the parent directory must exist. A second agent cannot use an occupied socket.
156
+ The Unix socket transport targets Linux/macOS. Its `/messages` endpoint is an
157
+ experimental local interface, not the eventual host protocol.
158
+
159
+ `src/kernel/channels.ts` owns channels and queues; `src/kernel/loop.ts` coordinates
160
+ turns; `src/capabilities/model/openrouter.ts` translates provider messages. The
161
+ time tool owns its definition, validation and execution in
162
+ `src/capabilities/tools/builtin/current-time.ts`. The startup command selects the
163
+ development tools in `src/capabilities/tools/scenario.ts`. Transport code lives in
164
+ `src/interfaces/protocol/local.ts`. Inspection wrappers live in
165
+ `src/interfaces/inspector/observe.ts`, keeping observation out of the kernel.
166
+
167
+ Execution runs on the storage contract in `src/contracts/storage.ts`
168
+ ([decision 0013](.res/decisions/0013-durable-delivery-contract.md)).
169
+ `src/state/storage/engine.ts` implements it once, over row access provided by
170
+ `memory.ts` (maps) and `sqlite.ts` (`bun:sqlite`, one file per session,
171
+ exclusive ownership through SQLite's file lock, `synchronous=FULL`).
172
+ `archive.ts` validates and restores logical session archives. Both adapters
173
+ pass the shared suite:
174
+
175
+ ```sh
176
+ bun test test/storage-memory.test.ts test/storage-sqlite.test.ts
177
+ ```
178
+
179
+ An accepted message or notice is first committed to a pending inbox and
180
+ acknowledged (`send` returns synchronously; it never waits for a reply). The
181
+ channel takes pending items into its timeline when it can: an active turn takes
182
+ them before its next inference, otherwise they start the channel's next turn.
183
+ One turn can hold several inputs. Assistant responses and tool results are
184
+ recorded with channel, turn and sender attribution before their events are
185
+ published. `createSession` uses memory storage unless given a storage handle,
186
+ and runs nothing until `start()`. `bun run start --db <file>` and the scripted
187
+ stdio server (`serve --stdio --home <directory>`) both use the SQLite adapter.
188
+
189
+ Before every inference, `src/capabilities/context/build.ts` renders a fresh store
190
+ snapshot with the unchanged system prompt. Other turns are attributed JSON
191
+ history; the active turn preserves native assistant/tool exchanges. Opaque
192
+ provider state is not exposed in shared text. Tools remain a separate request
193
+ field. All channels currently see all shared events; there is no scope filtering,
194
+ summary, compaction or context budget. Rebuilding shared history also changes the
195
+ request prefix; caching optimization is deferred.
196
+
197
+ Live context shows the current shared base; Channels provides per-channel
198
+ projections and exact inference snapshots. Those requests show how `context.build()`
199
+ rendered a store snapshot for a particular turn. The live view is not a currently
200
+ running model's hidden state.
201
+
202
+ Offline tests cover loop continuation, provider request mapping, channel
203
+ concurrency and ordering, history separation, failure isolation and Unix HTTP
204
+ requests, immutable inspection snapshots and SSE updates/reconnection. Socket
205
+ and inspector tests require permission to open local listeners. No runtime
206
+ dependencies were added.
207
+
208
+ A model call has a 120-second deadline, including streaming and one eligible
209
+ retry; tool execution and approval waits have separate limits. A model or unexpected
210
+ execution failure ends that turn as failed; its channel accepts and runs new
211
+ work, as do other channels. Tool calls of a failed or interrupted turn that
212
+ have no recorded result are listed as uncertain, described to the model in later
213
+ context, and never executed again by the harness. Tool errors are returned to
214
+ the model. Disconnecting a client does not
215
+ cancel an accepted turn. New shared events are visible at the next ordinary
216
+ inference; ordinary shared events do not wake idle channels or extend a turn.
217
+ Explicit notices do. The development CLI saves the session across restarts.
218
+
219
+ ## Development instructions and notices
220
+
221
+ Live development defaults to the general-purpose [agent instructions](src/capabilities/context/instructions/agent.md)
222
+ and offers `current_time` and `notify_channel`. The harness rules and scripted
223
+ agent demo each have their own Markdown file in the same directory. To
224
+ override the agent instructions with your own Markdown, run
225
+ `bun run start --instructions ./my-instructions.md`. For a saved session, add
226
+ `--db <path>`. The explicit file replaces the selected config's `system` text
227
+ for that open. SQLite saves the resolved text with the session, and a present
228
+ `config.json` still supplies the configuration on subsequent opens without the
229
+ flag. Restart the harness to load edits. A changed prompt or tool list can make
230
+ a suspended turn incompatible with the new configuration.
231
+
232
+ Scripted development uses the generic test-agent instructions. A fixture
233
+ defines the model responses for a particular check.
234
+
235
+ `notify_channel({ channelId, text })` requests attention from an existing channel.
236
+ The source channel is supplied by the executor. Notices and messages share one
237
+ delivery rule: a busy turn takes them before its next inference, and if the
238
+ model returns no tools while items are pending, the loop continues. Otherwise
239
+ they start the channel's next turn. The pending check and the turn's completion
240
+ are one storage transaction, so an item arriving as a turn finishes joins that
241
+ turn or starts the next one, exactly once. There is no notice-pass limit.
242
+
243
+ The receipt acknowledges acceptance, not completed action.
244
+ Notices have a distinct `channel_notice` kind and source channel in the shared
245
+ store. Busy and idle delivery use the same internal-notice renderer; neither
246
+ impersonates a human participant. The API role remains `user`. In channel context
247
+ cards, notices are highlighted violet and participant prompts orange. Tool
248
+ definitions are collapsed under Tools in both Live context and Channels.
249
+ Notice-generated idle responses appear in the inspector and in subscribed
250
+ terminal clients for the target channel.
251
+ A notice to a channel that has never received a message is refused with an actionable tool result.
252
+
253
+ ## Tool layout
254
+
255
+ - `tools/builtin/` contains standard tools for time and channel notices.
256
+ - `tools/debug/` contains the opt-in tools for interactive debugging.
257
+ - `tools/testing/` contains offline fixture tools such as echo, record and hold.
258
+ - `tools/runtime/` contains catalog validation and availability, execution of
259
+ host callbacks, and invocation inspection. It also implements
260
+ `read_tool_result` for paged reads of a host tool's stored result.
261
+
262
+ ## Debug tools
263
+
264
+ Run `bun run start --debug` to use the bundled test-agent prompt and expose
265
+ three development tools. The prompt override applies only to the running
266
+ process. Use `--debug-tools` to keep your usual prompt with the same tools,
267
+ or `--debug --instructions <path>` to select custom instructions. Ask the
268
+ agent to call `test_echo` with short text, `test_wait` to hold a turn for up to
269
+ 30 seconds, or `test_fail` to return a deliberate failure and observe how the
270
+ agent continues. Tool policies still apply. Pass the flag again when reopening
271
+ a session to enable the tools for that process.
272
+
273
+ In the inspector’s Channels tab, expand **Request evidence** to see included
274
+ timeline positions, trimmed candidates, offered tools and the model-call ID.
275
+ Use **Load recent model calls** to see that request’s outcome and attempts.
276
+
277
+ ## Offline scripted model
278
+
279
+ Run the real in-memory store, context builder, scheduler and tool loop without a
280
+ model provider or API key:
281
+
282
+ ```sh
283
+ bun run test:scenario test/fixtures/echo-scenario.jsonl "Echo hello"
284
+ ```
285
+
286
+ The command prints the answer, committed entries and unused response count.
287
+ Set `HARNESS_CAPTURE_SCRIPT_REQUESTS=1` to include the full requests in this
288
+ command or the scripted development inspector.
289
+
290
+ Script files use JSONL. The first record names and versions the scenario.
291
+ Model records can specify a channel and one of a response, provider failure,
292
+ or cancellation wait. With no channel record, a channel uses its own
293
+ position in the default sequence.
294
+
295
+ ```jsonl
296
+ {"type":"scenario","version":1,"name":"echo"}
297
+ {"type":"model","content":"I'll echo that.","calls":[{"id":"echo-1","name":"echo","arguments":{"text":"hello"}}]}
298
+ {"type":"model","content":"The tool returned hello."}
299
+ ```
300
+
301
+ Records can include an initial delay, timed text chunks and synthetic usage.
302
+ A malformed line fails before execution with its line number. Each attempt
303
+ consumes one durable position, including retries and crash-abandoned attempts.
304
+ Reopen checks the model sequence digest before recovering the session.
305
+ Old scripted stores without a digest need a fresh test session. See
306
+ [the scenario contract](.res/decisions/0023-long-running-mock.md).
307
+
308
+ ## Experimental protocol and in-process client
309
+
310
+ Run the acceptance scenarios with `bun test test/protocol.test.ts`. They use the
311
+ real session assembly with one independent scripted model per channel and no API
312
+ keys. A host can drive the same setup through public entry points:
313
+
314
+ ```ts
315
+ import { createInProcessHarness } from "./src/testing.ts";
316
+
317
+ const harness = createInProcessHarness();
318
+ const { client } = harness;
319
+ try {
320
+ await client.initialize();
321
+ await client.createSession({
322
+ sessionId: "example",
323
+ config: {
324
+ version: 1,
325
+ system: "You are a test assistant.",
326
+ model: { protocol: "scripted", script: "test/fixtures/echo-scenario.jsonl" },
327
+ defaultPolicy: "default",
328
+ policies: { default: { fallback: "allow", tools: {} } },
329
+ },
330
+ participants: [{ id: "alice", kind: "person" }],
331
+ channels: {},
332
+ });
333
+ const done = new Promise<void>(resolve => {
334
+ client.onChannelEvent(({ channel, event }) => {
335
+ console.log(channel, event);
336
+ if (event.type === "turn_ended") resolve();
337
+ });
338
+ });
339
+ await client.push({ channel: "channel1", item: {
340
+ id: "message-1", kind: "user_message", sender: "alice",
341
+ content: [{ type: "text", text: "Echo hello" }],
342
+ } });
343
+ await done;
344
+ console.log(await client.idle());
345
+ } finally { harness.close(); }
346
+ ```
347
+
348
+ `src/client.ts` exports `HarnessClient`, `HarnessClientError`, the in-process
349
+ transport factory and host types. `src/index.ts` exports host-independent
350
+ `createSession`, with injected model/tool implementations. Development startup
351
+ uses the same session assembly with OpenRouter, its tools and inspector wrappers.
352
+
353
+ The protocol carries JSON-RPC-shaped values with a JSON copy boundary. Supported
354
+ requests are `initialize`, `config/validate`, `session/create`, `session/open` (durable servers
355
+ only), `channel/observe`, `channel/reconcile`, `channel/messages`, `session/timeline`, `session/message/read`, `session/model-calls`, `session/status`, `session/suspend`,
356
+ `session/resume`, `session/stop`, `channel/push`, `channel/notify` and `session/idle`, plus
357
+ `channel/create`, `channel/edit`, `channel/suspend`, `channel/resume`,
358
+ `channel/delete`, `channel/withdraw`, `channel/interrupt` and
359
+ `approval/respond`, plus
360
+ `session/export`, `session/import` and `transfer/{open,write,read,close}` on
361
+ durable servers.
362
+ Initialize reports an experimental subset and whether this server's acceptance
363
+ is `memory` or `durable`. It supports `final` or `stream` text and
364
+ none/summary/full tool events;
365
+ the `callbacks` list must be empty. Full tool events retain JSON argument
366
+ and result strings; a completed tool event means execution returned, which can
367
+ include an actionable `{ ok: false }` result. Thrown execution errors emit failed.
368
+
369
+ Text defaults to `final`, which delivers one `message_completed` for each
370
+ committed response containing text. With `stream`, `text_delta` events carry a
371
+ stable `messageId`; completion uses the same ID. `text_incomplete` ends an
372
+ uncommitted draft, and `text_gap` signals dropped deltas when a consumer falls
373
+ behind. Drafts are not durable: after reconnect, reconcile the ID against
374
+ committed messages. Large completions carry `reference: true` instead of parts;
375
+ use `client.readMessage({ messageId, offset })` to read base64 UTF-8 byte pages
376
+ of up to 524288 bytes, concatenating bytes before decoding. `client.modelCalls()`
377
+ returns paged durable call summaries and per-attempt provider usage;
378
+ `aggregateUsage` sums reported fields without inventing missing counts.
379
+
380
+ A transient failure may retry the identical request once after one second,
381
+ within the original 120-second deadline. The first accepted nonempty text delta
382
+ closes retry in both subscription modes. Timeout or output limit fails the turn;
383
+ partial text is not added to the timeline and tools from an incomplete response
384
+ are not dispatched. Interrupt and stop fence late output; suspension lets the
385
+ current call and iteration finish within the same deadline. Both transports
386
+ bound live delivery; a fully blocked connection closes and stops the session,
387
+ while already committed records remain recoverable.
388
+
389
+ Configuration contains `version: 1`, `system`, `model`, `defaultPolicy` and a
390
+ `policies` map. A model is `{ protocol: "scripted", script }` or
391
+ `{ protocol: "openrouter", model, apiKeyEnv }`. The default OpenRouter model is
392
+ `deepseek/deepseek-v4.1-flash` and its default credential reference is
393
+ `OPENROUTER_API_KEY`. `apiKeyEnv` names a variable in the destination process;
394
+ its value is resolved on open and never saved. OpenRouter runs require that
395
+ variable; a custom name does not fall back to `OPENROUTER_API_KEY`. The
396
+ `OPENROUTER_MODEL` environment variable selects a development model only when
397
+ there is no saved model; it does not override saved configuration. Scripted
398
+ runs need no provider key. Ports and the socket remain
399
+ process settings. `client.validateConfig(config)` checks the structure without
400
+ opening a session or starting inference.
401
+
402
+ Each named policy has a `fallback` of `allow`, `ask` or `deny` and exact tool
403
+ name overrides in `tools`; the default must name a defined policy. A trusted
404
+ consumer can set a policy on a channel or a message. The message policy wins,
405
+ then the channel policy, then the default. The resolved name is saved at
406
+ acceptance, so a retry keeps it after a channel edit. Reusing an ID with a
407
+ different explicit policy fails with `item_conflict`. When a turn takes inputs,
408
+ their policies combine for each tool: deny wins over ask, which wins over allow.
409
+ Notices carry the source turn's restrictions, including inherited restrictions.
410
+ This governs tool execution, not access to shared history.
411
+
412
+ To handle `ask`, initialize with `approval: true`, listen for the always-on
413
+ `approval_requested` channel event, and pass its `requestId` to
414
+ `client.respondApproval(requestId, "allow_once" | "deny")` after the consumer
415
+ decides. A grant covers only that exact call. Without a declared consumer, or
416
+ after denial, timeout (ten minutes by default) or disconnect, the call is
417
+ skipped with a paired tool result. Suspension closes an undispatched request
418
+ with `approval_cancelled_by_suspension`; interrupt and stop use
419
+ `approval_cancelled_by_interrupt` and `approval_cancelled_by_stop`. A late or
420
+ duplicate answer fails `not_found`. A `tool_call` started event means dispatch
421
+ occurred; it is not emitted for a skipped call. An unanswered request or grant
422
+ cannot be reused after restart.
423
+
424
+ Participants support IDs and kinds, without labels. Initial `channels`
425
+ must be empty; channels are created on push. Push supports text-only user messages
426
+ with queue delivery and wake=true. Unsupported fields, configurations and methods
427
+ fail explicitly. The push response is sent after the item is committed to the
428
+ inbox and reports it as `received`; it never carries a reply. Storage
429
+ deduplicates item IDs, across restarts on a durable server: the same ID and
430
+ content returns the original item's current milestone and turn, and different
431
+ content fails with `item_conflict`. Unknown senders are recorded as IDs.
432
+
433
+ The owning host can submit `channel/notify` with a stable notice ID, text,
434
+ optional source label, and an explicit inherited policy-name array. New
435
+ notices require an existing open channel and a running session. An identical
436
+ retry returns the original receipt even during suspension or an incompatible
437
+ inspection open. Accepted notices appear in the timeline and enter the
438
+ receiving turn as attributed external input. Conversation pages count only
439
+ participant and assistant messages.
440
+
441
+ `session/open` opens an existing session and returns its lifecycle, revision,
442
+ and any startup channel-change results. Opening recovers unfinished turns
443
+ without replaying them. Pending input becomes eligible after the open response.
444
+
445
+ Use `channel/observe` for revisioned channel state, the session blocker, and
446
+ pending approvals visible to the approval consumer. Use `channel/reconcile`
447
+ for outcomes and committed reply identities tied to outstanding item or turn
448
+ IDs. `channel/messages` pages participant and assistant messages, and
449
+ `session/timeline` pages activity, including notices and tool results. Live
450
+ message IDs and channel positions match the paged records. A large assistant
451
+ message is returned by reference and can be read with `session/message/read`.
452
+ A large timeline record keeps its attribution and position.
453
+
454
+ `session/create` and `session/open` accept `channelChanges`
455
+ ([decision 0020](.res/decisions/0020-startup-channel-changes.md)): the newest
456
+ name, policy, suspension, resume or deletion a host decided for each channel
457
+ while the harness was stopped. The batch is validated as a whole, applied
458
+ after recovery and before any pending or recovered work can run, and answered
459
+ with one `applied` or `blocked` result per entry. A deletion that finds pending
460
+ input or a checkpoint suspends that channel instead and reports `channel_busy`.
461
+ A repeated open on the same connection reports the recorded results without
462
+ applying anything; a new connection can resend the same desired state safely.
463
+ Servers advertise this as `capabilities.startupChannelChanges`.
464
+
465
+ `session/suspend` refuses new messages at once, lets each active turn finish
466
+ its current inference and the tools it requested, then completes turns that are
467
+ naturally finished and checkpoints the rest. It responds when the session is
468
+ `suspended`, which can take as long as a running tool. Notices from finishing
469
+ work are still accepted and wait. A suspended session, including one loaded in
470
+ a new process, runs nothing until `session/resume`; resumed turns take their
471
+ pending input and continue at the next inference without repeating recorded
472
+ tool calls. Resume fails with `incompatible`, changing nothing, if a checkpoint
473
+ was saved under incompatible execution settings or contributing policy rules.
474
+ An individually suspended channel is checked only when it is resumed.
475
+ `session/stop` is
476
+ immediate: it cancels inference and tools, reports active turns `interrupted`,
477
+ leaves pending input pending, and makes this process refuse further work with
478
+ `stopped`. Lifecycle changes arrive as `session/event` notifications
479
+ (`HarnessClient.onSessionEvent`).
480
+
481
+ `session/export` writes a binary `.harness` file: a versioned `HARNSESS`
482
+ header and CBOR payload containing the logical session (metadata, channels,
483
+ turns, timeline, pending input, deduplication records, checkpoints and ID
484
+ counters) and the exact active portable configuration. Its version is separate
485
+ from the SQLite schema. Old standalone JSON exports are not accepted. The
486
+ scripted model path is preserved as a reference; the destination must supply
487
+ the script at that path when opening the session. OpenRouter credentials must
488
+ likewise be supplied through the named destination environment variable. Import
489
+ stores the config with the snapshot; a managed session can reopen from that
490
+ saved config without an inline config or sidecar. It is allowed only when the
491
+ session is cleanly suspended, or running with no active or checkpointed turn,
492
+ no pending input, and no channel suspending; otherwise it fails `busy`. The
493
+ reported length and SHA-256 are those of the
494
+ file bytes. `session/import` validates the whole document and then publishes
495
+ it atomically as a new session, optionally under a new session ID, without
496
+ opening or resuming it; an existing destination or an invalid archive leaves
497
+ nothing behind. Both take a file path when host and harness share a
498
+ filesystem, or a transfer when they do not: `HarnessClient.exportArchive()`
499
+ and `importArchive(bytes)` move the bytes in 512 KiB chunks, so an archive can
500
+ exceed the 1 MiB frame. One transfer may be open per connection, archives are
501
+ limited to 256 MiB, and a transfer's temporary file is removed when it is
502
+ closed, imported, idle for 60 seconds, or its connection ends. To relocate a
503
+ session, stop the source before resuming the copy: import makes a copy, and
504
+ both would otherwise run the same pending work.
505
+
506
+ Events are `turn_started`, `turn_took`, `items_receipt`, `tool_call`,
507
+ `message_completed`, `turn_suspended`, `turn_resumed`, `channel_state`,
508
+ `item_withdrawn`, `approval_requested` and `turn_ended`. Channel controls are available as
509
+ `createChannel`, `editChannel`, `suspendChannel`, `resumeChannel`,
510
+ `deleteChannel`, `withdrawItem` and `interruptTurn` on `HarnessClient`. Channel
511
+ suspension closes admission and waits for the current iteration; resume preserves
512
+ its checkpoint. Interrupt targets a turn and does not wait for a tool. Withdrawal
513
+ is durable and reports the owning turn if the input was already taken. Deletion
514
+ requires no pending input or unfinished turn and permanently reserves the ID.
515
+ Status reports channel lifecycle, pending input and `waitingForResume` separately.
516
+ `turn_started` and `turn_took` list the
517
+ item IDs that turn took, which is how an accepted input is matched to its
518
+ outcome. `turn_ended` reports `completed`, `failed` or `interrupted`. Completed assistant text is published immediately after recording,
519
+ including text before tool calls, even if notices extend the turn. Each message
520
+ has an ID and is delivered once; clients no longer republish the final return.
521
+ Only turn lifecycle IDs are strings at the protocol boundary; the experimental
522
+ store still uses numeric turn IDs internally. Per-channel order is guaranteed,
523
+ not ordering across channels. Subscriptions deliver future events, without replay.
524
+
525
+ Client requests time out after 30 seconds by default (configurable in its
526
+ constructor); closing a client rejects pending requests, removes subscriptions,
527
+ and closes that consumer's outstanding approvals. Accepted input remains durable.
528
+ Model exhaustion produces a failed turn
529
+ event after acceptance, not a failed push. Idle includes pending and running work.
530
+
531
+ This is not full protocol v1 conformance: broader permission features and
532
+ progress heartbeats remain unimplemented. Protocol version 1
533
+ identifies these experimental message shapes, not a full compatibility claim.
534
+
535
+ ## Stdio server and client transport
536
+
537
+ Start the protocol-only process with:
538
+
539
+ ```sh
540
+ bun run serve --stdio
541
+ ```
542
+
543
+ It waits for JSON-RPC requests, one UTF-8 JSON message per line. It starts no web
544
+ servers or REPL. Select the scripted model in `session/create`, exactly as in
545
+ the in-process example above, to run without a provider key; OpenRouter sessions
546
+ use the configured credential environment variable. Relative script
547
+ paths resolve against the child process's working directory. Stdout contains
548
+ only protocol responses/events; diagnostics go to stderr.
549
+
550
+ The consumer owns launching and terminating the child. From this package's working
551
+ directory, connect the same public client like this, then use the initialize,
552
+ createSession, push and event methods in the preceding example:
553
+
554
+ ```ts
555
+ import { HarnessClient, createStdioTransport } from "./src/client.ts";
556
+
557
+ const child = Bun.spawn([
558
+ process.execPath, "src/interfaces/cli/main.ts", "serve", "--stdio",
559
+ ], { stdin: "pipe", stdout: "pipe", stderr: "inherit" });
560
+
561
+ const client = new HarnessClient(createStdioTransport({
562
+ readable: child.stdout,
563
+ exited: child.exited,
564
+ async write(bytes) {
565
+ child.stdin.write(bytes);
566
+ await child.stdin.flush();
567
+ },
568
+ async end() { await child.stdin.end(); },
569
+ }));
570
+
571
+ // Drive client.initialize(), createSession(), push(), and onChannelEvent().
572
+ // When done:
573
+ client.close(); // rejects pending calls, flushes queued writes, closes stdin
574
+ const deadline = setTimeout(() => child.kill("SIGKILL"), 6000);
575
+ try { await child.exited; } finally { clearTimeout(deadline); }
576
+ ```
577
+
578
+ Unexpected EOF, malformed server messages, write failure or nonzero process exit
579
+ close the connection and reject pending/future calls with `transport_closed`,
580
+ rather than waiting for the normal request timeout. Explicit client close uses
581
+ `closed`. Both transports expose closure notifications. The transport does not
582
+ restart or kill the process, capture stderr, or retry accepted requests.
583
+
584
+ Frames are limited to 1 MiB and queued writes to 4 MiB. UTF-8 characters and JSON
585
+ lines may span chunks. Blank lines are ignored; a partial line at EOF is an error.
586
+ Malformed client JSON produces a parse-error response and later valid lines still
587
+ work. Malformed server output is fatal to its client connection.
588
+
589
+ Stdin EOF is stop: the server cancels inference and tools, records active turns
590
+ as interrupted, leaves pending input pending, flushes protocol output and exits.
591
+ It does not wait for work to finish. A host that needs completed work waits for
592
+ idle, or suspends, before closing. The five-second grace period only bounds
593
+ requests already read and the final flush; exceeding it exits nonzero with
594
+ stderr diagnostics. The default managed home is `~/.harness`; `--home <directory>`
595
+ overrides it. Each session uses `<home>/<sessionId>/session.sqlite` and an
596
+ optional `config.json` beside it. At creation an inline config wins over the
597
+ sidecar. On open, a present sidecar wins over inline config; otherwise the
598
+ saved config is used when inline config is absent. File edits apply at the next
599
+ open, and an invalid file does not replace the saved config. The old flat
600
+ managed database layout is not migrated; the explicit development `--db` path
601
+ remains supported. Work the process did not finish is reported
602
+ as interrupted when the session is next loaded. Hosts retain a process termination deadline.
603
+
604
+ Run `bun test test/protocol.test.ts test/stdio.test.ts` for transport parity and
605
+ framing/process lifecycle checks. Child stdin in Bun uses IPC and may require
606
+ local IPC permissions in sandboxed environments. All scenarios are offline.
607
+
608
+ ## Consumer tools and host callbacks
609
+
610
+ A host can register functions for the model to call
611
+ ([decision 0021](.res/decisions/0021-tools-and-host-callbacks.md),
612
+ [spec](.res/docs/tools-and-callbacks/0001-DESIGN/SPEC.md)). A server that
613
+ supports this advertises `capabilities.functions`.
614
+
615
+ ```ts
616
+ client.serveFunctions(
617
+ async (call, signal) => ({ output: await lookup(call.arguments, signal) }),
618
+ read => readStoredResult(read), // only if handlers return references
619
+ );
620
+ await client.initialize({ protocolVersion: 1, host: { name: "app", version: "1" },
621
+ callbacks: ["functions/call"], functions: ["lookup_handler"],
622
+ approval: true, subscription: { text: "final", tools: "full" } });
623
+ await client.openSession({ sessionId, tools: { catalog: [
624
+ { name: "lookup", description: "...", parameters: { type: "object" },
625
+ handler: "lookup_handler", group: "fixed" } ] } });
626
+ ```
627
+
628
+ - **Catalog.** `tools` goes on every `session/create` and `session/open`.
629
+ Definitions are not stored. `group` is `fixed`, `revocable` (`tool/revoke`
630
+ and `tool/restore`, stored with the session and its archives) or `runtime`
631
+ (`tool/enable` and `tool/remove`, in memory, listed in `tools.enabled`).
632
+ An invalid catalog, a duplicate name or a clash with a built-in rejects the
633
+ open and opens nothing.
634
+ - **Availability.** `session/tools` lists each tool with `available` and a
635
+ reason: `revoked`, `not_enabled` or `handler_missing` (the connection did not
636
+ name its handler at `initialize`). Policy is reported separately.
637
+ - **What the model sees.** Each inference offers the built-ins, then fixed
638
+ entries, then `read_tool_result`, then changeable entries, each group by
639
+ name. Unavailable tools and tools the turn's policy denies are left out. A
640
+ retry of the same model call offers the same list.
641
+ - **Dispatch.** The existing permission gate decides. A catalog call must have
642
+ been offered by its request, be available, and have arguments that match its
643
+ schema; otherwise it is skipped with a paired result (`tool_unavailable`,
644
+ `invalid_arguments`). Availability is checked again after an approval, and
645
+ revoking a tool closes its pending approval.
646
+ - **Callback.** After dispatch evidence commits, the harness sends
647
+ `functions/call` with an invocation ID (`<turnId>:<toolCallId>`). The answer
648
+ is `{ output }`, `{ preview, reference }` or an error with a code. Answers
649
+ are matched by request ID, so concurrent callbacks cannot be mixed up.
650
+ `functions/cancel` tells the host the harness stopped waiting.
651
+ - **Deadlines.** `deadlineMs` per tool, else `tools.defaultDeadlineMs`, else
652
+ none. On expiry the turn continues with one paired `tool_timeout` result
653
+ whose effect is unknown. A late answer is ignored.
654
+ - **Records.** `session/tool-invocation` and `session/tool-invocations` return
655
+ calls with their state: `requested`, `waiting_for_approval`, `started`,
656
+ `succeeded`, `failed`, `skipped`, `interrupted`. A dispatched call with no
657
+ committed result is `interrupted` with `effect: "unknown"` and is never
658
+ repeated. `tool_call` events carry `invocationId`.
659
+ - **Phase.** `session/status` reports `activeTurn.phase`: `model`, `approval`
660
+ or `tool`, since when, and the model call, approval request or invocation ID.
661
+ - **Large results.** Above 16384 bytes the handler stores the result itself
662
+ and returns a preview and a reference. The model reads parts with
663
+ `read_tool_result`; the harness accepts only IDs recorded for the requesting
664
+ channel and forwards the read to the host as `results/read`.
665
+
666
+ Adjustable defaults are in
667
+ [BUSINESS_RULES.md](.res/docs/BUSINESS_RULES.md). The work log is
668
+ [here](.res/docs/tools-and-callbacks/0001-DESIGN/LOG.md).
669
+
670
+ ## acp-client integration
671
+
672
+ On the `acp-client-integration` review branch, acp-client hosts one harness
673
+ process per agent, with each native conversation as a channel of one durable
674
+ session. The host and its controller
675
+ live in acp-client's `src/native/` and use only `src/client.ts` (the typed
676
+ client and stdio transport) and the `serve --stdio` command; they import no
677
+ harness internals. The contract is the
678
+ [integration spec](.res/docs/acp-client-integration/0001-DESIGN/SPEC.md) and its
679
+ [protocol profile](.res/docs/acp-client-integration/0001-DESIGN/PROTOCOL.md);
680
+ the work and its test evidence are in the
681
+ [log](.res/docs/acp-client-integration/0001-DESIGN/11-20-LOG.md). The harness
682
+ side of that contract is the startup channel-change batch described above
683
+ (decision 0020). From the repository root, `bun test ./test/native` runs the
684
+ host, controller, conformance and real-stdio checkpoint tests offline.
685
+
686
+ ## Documents
687
+
688
+ - [Architecture](ARCHITECTURE.md): boundaries, extension points and intended layout.
689
+ - [Contribution rules](AGENTS.md): instructions for implementing and reviewing changes.
690
+ - Decision records belong in `.res/decisions/` within this directory; create them
691
+ as decisions are made. Other working notes and experiments also belong in `.res/`.
692
+
693
+ The detailed design references remain in the repository's research directory:
694
+
695
+ - [Design and rationale](../../.res/somelogs.md/11-11+/harness/11-11-SPEC-harness-design.md)
696
+ - [Project organization](../../.res/somelogs.md/11-11+/harness/11-11-SPEC-harness-project.md)
697
+ - [V1 scope and acceptance](../../.res/somelogs.md/11-11+/harness/11-11-SPEC-harness-v1.md)
698
+ - [Host protocol](../../.res/somelogs.md/11-11+/11-12-SPEC-harness-protocol.md)
699
+ - [Library integration](../../.res/somelogs.md/11-11+/library/11-11-SPEC-native-harness-integration.md)
700
+
701
+ These references describe the intended system, not implemented behavior. The
702
+ owner's later instruction places decision records in `.res/decisions/` rather
703
+ than the top-level `decisions/` shown in the original project spec.
704
+
705
+ ### Try timeline retrieval
706
+
707
+ Set `"timelineTools": true` in the managed session config, or use
708
+ `bun run start --script <scenario.jsonl> --timeline-tools` in development
709
+ chat. Tool policy still controls `search_timeline` and `read_message`.
710
+ Search can span native channels in one session. Open a hit using its
711
+ `message_id`, and repeat that ID with the returned cursor to continue
712
+ a split message or fixed neighbor window. To run the cumulative offline
713
+ stdio fixture, from the acp-lib root run
714
+ `bun test test/native/rehearsal.test.ts -t "cumulative real stdio"`.
715
+
716
+ ### One-off reminders
717
+
718
+ The native tools `schedule_reminder`, `list_reminders` and
719
+ `cancel_reminder` use the current channel and its tool policies. Schedule
720
+ with a UTC `at` or a relative `in` such as `5m`. Hosts can apply versioned
721
+ changes at startup or through `reminder/change`, and read current state with
722
+ `reminder/get` and `reminder/list`. A live session arms its own timer.
723
+ A stopped harness needs a host to reopen it before any due work can run.
724
+
725
+ Run `bun test test/reminder-stdio.test.ts` from this package to verify cold
726
+ open, replay, process death and the idle-stop fence with a scripted model.