@qlairoslabs/acp-client 0.12.0 → 0.13.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (467) hide show
  1. package/CHANGELOG-consumer-fixes.md +17 -3
  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 +847 -7
  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 +30 -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 +10 -0
  35. package/src/cli/index.ts +3 -3
  36. package/src/cli/managed.ts +2 -2
  37. package/src/client.ts +68 -98
  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,73 @@
1
+ # Callback policy names work log
2
+
3
+ Implementation branch `aiagent/cod1a-callback-policy` starts from
4
+ `2b5dea11749dbc1f3968c323093d87e92d5f4930`, which includes long-running
5
+ mock closure `448521f`. Clad owns independent review.
6
+
7
+ The contract gate is decision 0024 plus the required wire and handler
8
+ types. Runtime wiring and fixture changes await approval. The subsequent
9
+ implementation gate covers both transports, an approval wait, denial,
10
+ inherited notice policies, pending inputs, and the legacy empty list.
11
+ Orchestrator worker-rule acceptance is a separate workstream.
12
+
13
+ Contract-only verification ran both package typechecks. The harness reports
14
+ two errors at callback producers and fixtures that still omit the required
15
+ field. Root reports those two and one at native handler context assembly.
16
+ These are pending implementation. Independent contract review is pending.
17
+
18
+ Clad approved the contract at `cc1105a4591dee18d200c488e4a822bf3246dbda`.
19
+ The implementation sorts exact names lexically. The gate reads the
20
+ contributors once after checking tool structure. It retains policy denial
21
+ precedence and rechecks tool availability before dispatch as before. The
22
+ executor uses the same snapshot, with the legacy fallback omitted, and
23
+ the handler gets its own copy. Invalid metadata returns invalid_params
24
+ from the common callback client boundary. The harness records this as one
25
+ paired failed tool result and does not retry the callback.
26
+
27
+ Both package typechecks passed after implementation. The broad harness run
28
+ passed 346 tests and reported five stdio failures in the unchanged suspension,
29
+ large-reply, and relocation cases. The errors were session/create or channel/push
30
+ timeouts and exit 137 after the stdio helper's cleanup timer. A serial rerun of
31
+ those suites and the callback protocol suite passed all 37 tests. Existing
32
+ transport and cleanup deadlines were kept. The callback protocol cases reuse the
33
+ shared client and stdio fixtures in the existing protocol test file.
34
+
35
+ Both transports cover single policy, empty legacy metadata, a guest notice
36
+ in an owner turn, forged argument metadata, and a blocked input excluded during
37
+ approval but applied once taken. They also exercise approval denial and check
38
+ that malformed or absent callback metadata is refused before the handler.
39
+ Consumer invalid_params is paired once as a failed tool result. Native handler
40
+ context has separate in-process and real-stdio coverage. Worker rule composition
41
+ and assignment policy retention remain orchestrator acceptance dependencies.
42
+
43
+ Final root `bun test ./test` passed 1422 tests with no failures, 12113
44
+ assertions, and 35 snapshots. Both typechecks passed on the final tree.
45
+ Independent implementation review is pending.
46
+
47
+ ## Closure and retrospective
48
+
49
+ Clad approved implementation `aca1fe5e524181b2e9c72023b8a6c7d62a9c2a34`
50
+ on contract `cc1105a4591dee18d200c488e4a822bf3246dbda`, from base
51
+ `2b5dea11749dbc1f3968c323093d87e92d5f4930`. Both independent package
52
+ typechecks passed. The independent full harness suite passed 351 tests
53
+ with zero failures, including the five tests that failed under load in
54
+ the implementer's broad run and passed on isolated rerun.
55
+
56
+ The independent full root run passed 1421 tests with one load-sensitive
57
+ failure in the unchanged operator 10,000-record stdio checkpoint. Its
58
+ two-second wait for held inference expired. Two isolated reruns passed.
59
+ The implementer's full root run passed all 1422 tests. Test deadlines were
60
+ kept as configured.
61
+
62
+ Capturing contributors at authorization kept approval and dispatch tied to
63
+ the same policy evidence even when a pending input arrived. The mixed
64
+ notice test verified both sides of that boundary: the authorized callback
65
+ received guest and owner, then the pending input's deny applied after take.
66
+ Shared client validation gave both transports the same typed failure path.
67
+ Malformed metadata reaches no handler, and a consumer rejection is paired
68
+ once without retry.
69
+
70
+ Orchestrator acceptance remains separately owned, including worker-rule
71
+ composition, empty-list defaults, unknown-name refusal, session-bound
72
+ mappings, and retaining each assignment's resolved rules. This closure
73
+ covers the harness wire and acp-client handler context.
@@ -0,0 +1,64 @@
1
+ # Callback policy names
2
+
3
+ Date: 2026-11-21.
4
+ Status: proposed for contract review.
5
+
6
+ Amends the [`functions/call` contract](../0001-DESIGN/SPEC.md#host-callback).
7
+ The acp-client orchestrator needs to know which policies contributed to a call
8
+ so it can apply its own worker rules. For example, the harness may allow a tool
9
+ that sends work to a worker, while the orchestrator must inspect the worker's
10
+ current assignment to decide whether the operation would take over busy work.
11
+
12
+ ## Wire and handler contract
13
+
14
+ Add required `policyNames: string[]` to `functions/call`. It is a deduplicated
15
+ list of the configured policy names used in the harness's authorization of
16
+ that invocation. It includes the resolved policy of each input already taken
17
+ into the turn and any policies inherited from notices. Pending inputs start
18
+ contributing when the turn takes them. The list's order grants no precedence.
19
+ The harness omits its internal `__legacy_allow` fallback from the field. An
20
+ empty list explicitly means that no configured policy contributed.
21
+
22
+ Collect the names once for the dispatch authorization and use the same list to
23
+ evaluate the tool decision and build the callback. If the call waits on approval,
24
+ keep that list with the invocation. The harness sets the field independently of
25
+ the model's tool arguments. Existing denial, approval, and dispatch behavior
26
+ continues to apply.
27
+
28
+ Carry the field through stdio and in-process callbacks. Validate its shape at
29
+ the protocol boundary and expose it in acp-client's `NativeFunctionContext`.
30
+ Reuse the policy metadata on taken inputs. This amendment requires no storage
31
+ schema change. Update the harness and acp-client together in the same slice.
32
+ The contract gate records the wire and handler types before implementation.
33
+
34
+ ## Responsibility in the orchestrator
35
+
36
+ When opening the harness session, acp-client binds the worker-rule mapping
37
+ that corresponds to its active policy configuration. The orchestrator resolves
38
+ names against that mapping and applies the most restrictive applicable worker
39
+ rules. An empty list selects the orchestrator's configured default worker
40
+ rules. This default is also available to other harness integrations that
41
+ explicitly indicate they have no policy context. A missing field on a native
42
+ callback or an unknown name is invalid. Decline delegation in either case.
43
+ When an assignment starts, retain its resolved rules for later worker
44
+ permission requests. The
45
+ [orchestrator spec](../../../../../../.res/somelogs.md/11-11+/library/11-11-SPEC-orchestrator.md#policy-limits)
46
+ owns those worker rules and their composition.
47
+
48
+ ## Acceptance
49
+
50
+ 1. An authorized callback from a single-policy turn exposes that policy name
51
+ in the host handler.
52
+ 2. A notice sent by a `guest` turn to an `owner` channel contributes both names.
53
+ Verify the host receives both once, and that a pending input contributes
54
+ only after it is taken. Check that model arguments cannot set the metadata.
55
+ 3. Exercise `ask` over real stdio. Verify approval dispatches one callback with
56
+ the same policy names used for the tool decision. A denied call produces no
57
+ callback. Verify the in-process transport exposes the same handler context.
58
+ 4. In the orchestrator's tests, show that `owner` plus `guest` can send work to
59
+ an idle worker when both policies allow it, and that guest restrictions
60
+ prevent takeover of a busy worker. Verify matching names in different
61
+ sessions use the mappings bound at their respective opens. Verify later
62
+ worker permission requests use the assignment's resolved rules.
63
+ 5. A policy-free native session sends an empty list and uses the configured
64
+ default worker rules. Missing native metadata and unknown names are refused.
@@ -0,0 +1,58 @@
1
+ # Attachment tools
2
+
3
+ Date: 2026-11-22
4
+
5
+ Status: Proposed for v1.
6
+
7
+ Build on [attachments](../../attachments/0001-DESIGN/SPEC.md), the
8
+ [shell runner](../../shell-execution/0001-DESIGN/SPEC.md), and the existing
9
+ [tool lifecycle and permission gate](../0001-DESIGN/SPEC.md). Both tools use
10
+ the same contract with managed files and a consumer-managed attachment store.
11
+
12
+ ## `copy_attachment`
13
+
14
+ `copy_attachment({ id, destination? })` checks read access using the calling
15
+ channel and streams the attachment into the same runner environment used by
16
+ `shell`. Return the actual runner path once the copy is complete and verified.
17
+ Remove incomplete copies on failure or cancellation.
18
+
19
+ The default destination is under `/tmp/.harness/<session-id>/<channel-id>/`
20
+ in the runner. Use safe path components and keep same-name attachments distinct.
21
+ Later commands and turns can reuse the copy while the runner retains it. A
22
+ workspace copy requires an explicit destination within the permitted filesystem.
23
+ Refuse an existing destination unless it already holds the same verified copy.
24
+ The original remains in the attachment store independently of the runner copy.
25
+
26
+ ## `share_attachment`
27
+
28
+ `share_attachment({ source, filename?, caption? })` publishes a downloadable
29
+ attachment to the current channel. `source` is either `{ path }` in the shell
30
+ runner or `{ id }` for an existing attachment.
31
+
32
+ - For `{ path }`, check access and stream the file from the runner to the
33
+ attachment store. The retained copy remains downloadable after runner cleanup.
34
+ - For `{ id }`, check that the caller may share it into the current channel.
35
+ Reuse the bytes and add the new message association.
36
+
37
+ The optional `filename` controls the displayed name. Once the attachment is
38
+ durable, the harness commits the outgoing message with the attachment and
39
+ optional caption, then emits the normal channel event. Return the message ID
40
+ and attachment ID. Repeating a committed invocation returns the same message
41
+ ID. History can recover a missed event. A consumer-managed store can use a
42
+ callback to transfer or resolve bytes. The harness owns publication.
43
+
44
+ ## Runner lifecycle and acceptance
45
+
46
+ The runner owns staging and temporary cleanup. Use bounded streaming and reuse
47
+ tool cancellation and deadlines. Coordinate cleanup with active commands and
48
+ define retention and runner-replacement behavior in the implementation plan.
49
+ File previews and a separate `read_file` tool are follow-up work.
50
+
51
+ 1. Copy a CSV into the default temporary directory, reuse it in two shell calls,
52
+ and share an output. Verify the shared file survives runner cleanup.
53
+ 2. Exercise an explicit workspace destination and transfer between separate
54
+ filesystems. Verify channel isolation, same-name files, destination collisions,
55
+ and incomplete transfer cleanup.
56
+ 3. Share a runner file and an existing attachment. Verify access checks, one
57
+ durable message per invocation, and recovery of a missed event. Exercise
58
+ the same publication path with the consumer-managed adapter when available.
@@ -0,0 +1,45 @@
1
+ # Reminder tools implementation log
2
+
3
+ ## R-H1
4
+
5
+ The canonical wire and commit decision is 0031 at
6
+ `34969fd99e865794495813837880142fc2b22e1e`, approved by Clad on the
7
+ `723d438` design handoff. R8 consumes that wire contract. The subsequent
8
+ coordination notes in 0031 pin expiry provenance, frozen intent receipts,
9
+ blocked-create correction, and the session identity fence.
10
+
11
+ ## R-H2
12
+
13
+ The harness owns a single timer per live session. SQLite activates reminder
14
+ tables and format 7 only with the first committed reminder row or receipt.
15
+ An untouched format-6 session still exports archive 5. Format-7 sessions
16
+ export archive 6. The wake range uses a partial index over runnable deadlines.
17
+ Channel lifecycle commits update that projection in the same transaction.
18
+ Held reminders do not contribute a wake, and an expired held occurrence is
19
+ resolved without a notice when eligibility returns.
20
+
21
+ The real-stdio tests use the scripted model and an injected wall instant.
22
+ They exercise a cold open with a delayed intent and an unchanged replay
23
+ receipt, process death on both sides of the atomic occurrence commit,
24
+ checked agent scheduling, approval, and the idle-stop fence. Storage tests
25
+ cover format activation, grace provenance after archive import, cursor
26
+ invalidation and a 100-row due batch with a remaining deadline.
27
+
28
+ Receipts are retained for the session lifetime and exported. Storage grows
29
+ with durable host changes, including blocked changes. An identical replay
30
+ adds no receipt. Listing cursors intentionally invalidate on any row change
31
+ and return invalid_cursor so callers can start a fresh listing. Resuming a
32
+ channel can recheck its policy-blocked rows.
33
+
34
+ The root conversation controller ignores reminder events without a turn ID.
35
+ The acp-client supervisor, R8 consumer integration, and recurrence have
36
+ separate gates.
37
+
38
+ Clad's independent review of a55f107 found three deterministic failures
39
+ (399 passed) because the startup fence also deferred direct checkpoint
40
+ resumes. The fix restores immediate checkpoint execution under 0014,
41
+ holds its open notifications at the protocol boundary, and keeps other
42
+ channels and the live reminder timer behind the open response. The archive
43
+ validator checks the stored default grace, and the conditional-stop test
44
+ covers runnable input even before the scheduler starts. A grace-only edit
45
+ uses the saved anchor even if the wall clock has moved back.
@@ -0,0 +1,108 @@
1
+ # Harness reminder implementation plan
2
+
3
+ Date: 2026-11-24
4
+
5
+ Status: Proposed. Reminders are the next harness implementation after timeline
6
+ retrieval. Start from the reviewed `aiagent/haurness-l` base at `f0eb7d8`.
7
+
8
+ Deliver one-off reminders first. A standalone harness can schedule a check,
9
+ wake the original channel while running and catch up after restart. acp-client
10
+ then supplies the supervisor that wakes a stopped harness. A later gate adds
11
+ routines and their unattended execution guard. [Reminder tools spec](SPEC.md)
12
+
13
+ ## R-H1 · Review the one-off contract
14
+
15
+ - Freeze the requests, tool arguments, wire fields, and advertised capability.
16
+ Put `reminderChanges` on executable `session/create` and `session/open`,
17
+ alongside the existing channel batch. Validate both batch shapes before
18
+ mutation. Apply channel changes, then reminder changes in submitted order,
19
+ then queue eligible due notices, before normal scheduling can begin. An
20
+ inspection fence permits neither reminder mutations nor firing.
21
+ - Define the lookup for `(reminderId, changeId)` before the high-water check.
22
+ Exact replay returns the recorded outcome. Changed arguments conflict.
23
+ An older version with no receipt is stale. Pin retention, blocked reasons,
24
+ pause and resume update shapes, and bounded list pages with explicit
25
+ invalidation. Keep stored outcomes for the session lifetime in this version.
26
+ - Define the authorized host's original acceptance timestamp for queued offline
27
+ writes, including validation of unreasonable future timestamps and clock
28
+ skew. The two-minute lead check and default expiry use that stable anchor.
29
+ Opening after the deadline must not invalidate an otherwise eligible intent.
30
+ Live agent creates use the harness clock. Pin expiry status and events and
31
+ distinguish expiry from a notice already accepted by the inbox.
32
+ - Freeze the wake deadline response and event. Within one session identity a
33
+ revision maps to one value, including null, across reconnect and reopen.
34
+ Define atomic conditional stop, including its response when busy or near a
35
+ deadline. The stop decision must fence new work under the same owner as
36
+ admission. Pin the standalone behavior and backward compatibility for
37
+ callers that use existing unconditional stop.
38
+ - Pin the persistence and archive changes, including opening existing databases
39
+ and transferring reminder records with portable sessions. Land the numbered
40
+ contract decision before runtime work. Give core-p the approved revision
41
+ for R8a. The acp-client R7 repository and library groundwork can proceed
42
+ against its separate plan.
43
+
44
+ ## R-H2 · One-off reminders in the harness
45
+
46
+ | Area | Proposed code ownership |
47
+ | --- | --- |
48
+ | Contracts | Add a focused reminder contract under `src/contracts/` and extend the tool, storage, event and protocol references there. |
49
+ | Records and deadlines | Put memory and SQLite persistence under `src/state/storage/`. Index eligible due records. Commit reminder advancement and inbox acceptance together. Keep edit receipts and the wake revision in durable state. |
50
+ | Runtime scheduling | Add a small reminder scheduler outside the kernel, under `src/runtime/`. Inject the clock and timer for tests. Wire it through session assembly in `src/index.ts` and the existing lifecycle hooks. The kernel continues to take inbox notices through its normal scheduling path. |
51
+ | Native tools | Add `schedule_reminder`, `list_reminders` and `cancel_reminder` under `src/capabilities/tools/`. Use checked native dispatch from timeline retrieval and derive channel and policy from the calling turn. |
52
+ | Host boundary | Extend `src/interfaces/protocol/server.ts`, startup batch handling and `src/interfaces/client.ts`. Use the same assembly for stdio, in-process and standalone configured sessions. |
53
+
54
+ Use one timer per open session, armed for the earliest eligible deadline.
55
+ Re-arm on committed changes, resume or reopen. Closing the session releases
56
+ the timer. Use bounded due reads, stable occurrence and notice IDs, and no
57
+ whole-session snapshot on the timer path. The wake index excludes paused,
58
+ blocked, retired, suspended and suspending work. Recheck lifecycle and policy
59
+ at delivery. Failure to publish a wake update leaves the durable reminder
60
+ recoverable on a later eligible open, subject to its expiry.
61
+
62
+ Acceptance uses the same cases in memory and SQLite where applicable:
63
+
64
+ 1. Schedule through a real tool call and verify one attributed notice on the
65
+ original detached channel. Verify the busy-channel path at the next
66
+ inference boundary. Check policy denial and malformed calls before effects.
67
+ 2. Exercise pause, channel and session suspension, resume, retirement and a
68
+ cancel racing a due occurrence. Test expiry bounds and explicit no-expiry.
69
+ 3. Crash before and after the atomic notice commit. Reopen and retry, checking
70
+ the notice ID and count. Verify migrated and imported sessions and bounded
71
+ reads on a large reminder set.
72
+ 4. Verify executable startup ordering, lost-response intent replay, conflict
73
+ and stale versions, bounded listing and cursor invalidation. Exercise the
74
+ deadline revision across reopen and concurrent event delivery.
75
+ 5. Race conditional idle stop against an inbox admission and a due reminder.
76
+ Verify busy and next-due-soon refusals, then verify a successful idle stop
77
+ with a later reminder still persisted.
78
+
79
+ ## R-H3 · Joint wake acceptance with acp-client
80
+
81
+ Supply the reviewed one-off implementation SHA to core-p for R8a. Extend the
82
+ existing cumulative real-stdio fixture in `test/native/fixtures/`. The scripted
83
+ model calls the real reminder tool. Use a controlled clock or scheduler seam
84
+ with normal scheduling bounds. Assert the persisted reminder, the attributed
85
+ notice and the resulting turn. Keep the timeline phase and exact script
86
+ consumption checks.
87
+
88
+ Use the real supervisor for separate stopped-session cases. Verify exactly
89
+ one lazy start and one notice when due, an offline cancellation before open
90
+ that queues no notice, recovery after a lost open response, and authoritative
91
+ wake reconciliation after a missed event. Test the accepted window where a
92
+ persisted reminder can run late if the host never stored its deadline. Verify
93
+ that the original acceptance anchor and expiry survive this path and that
94
+ an already expired occurrence queues no notice.
95
+
96
+ ## R-H4 · Routines
97
+
98
+ Review the routine contract separately before R9. Freeze DST gaps and folds,
99
+ variable cron intervals, the ten-minute minimum, defaults for missed runs and
100
+ overlap, bounded catch-up, occurrence identity across restart and the unattended
101
+ guard capability. Add recurrence to the same stores, timer and notice path.
102
+ Exercise guard and limit behavior before enabling routines. Add a cumulative
103
+ rehearsal phase that proves two distinct occurrences and one recovery or
104
+ overlap case.
105
+
106
+ For each runtime gate, submit the exact revision with both typechecks, focused
107
+ conformance, applicable real-stdio acceptance, and full harness and root
108
+ results. Integrate the reviewed work into `aiagent/haurness-l`.
@@ -0,0 +1,169 @@
1
+ # Reminder and routine tools
2
+
3
+ Date: 2026-11-24
4
+
5
+ Status: Proposed for v1.
6
+
7
+ A reminder schedules agent work on a native channel. A routine repeats it. The
8
+ harness owns the schedule and queues due work through the durable inbox notice
9
+ path. An optional host, initially acp-client, can start a stopped harness at the
10
+ next deadline. Standalone sessions can schedule, cancel and run reminders
11
+ while open, and catch up when reopened.
12
+
13
+ ## Agent tools and host controls
14
+
15
+ | Agent tool | Behavior |
16
+ | --- | --- |
17
+ | `schedule_reminder({ schedule, text, ...routineOptions })` | Store the instruction and schedule for the current channel. Return the reminder ID and next run time after the commit. |
18
+ | `list_reminders({ after?, limit? })` | Return a bounded page of reminders for the current channel, including their state and next run time. |
19
+ | `cancel_reminder({ id })` | Cancel future occurrences. Report whether an occurrence was already queued. A queued occurrence follows the normal inbox lifecycle. |
20
+
21
+ The harness derives the channel, creator and policy names from the calling turn.
22
+ The tool arguments carry no channel or policy override. The tools use the normal
23
+ tool catalog, permission gate and typed results. Store the ID of the creating
24
+ tool invocation with the reminder so retrying a committed call returns its
25
+ original receipt. Listings use an opaque cursor and stable ordering.
26
+
27
+ The owning host can create, get, list, update, pause, resume and cancel reminders
28
+ through the same harness operations. A host write names the destination channel.
29
+ A host list can cover one channel or the whole session. The host supplies any
30
+ additional policy names, which the harness validates at creation. acp-client
31
+ maps these operations to `conversation.reminders` and an Agent-wide list.
32
+ The consumer capability applies to native conversations.
33
+
34
+ ## Stored state and delivery
35
+
36
+ Store each reminder in session storage with its ID, channel, creator, policy
37
+ names, schedule, text, state and next occurrence. Use the existing persistence
38
+ extension for durable sessions and equivalent in-process behavior for memory.
39
+ Store absolute UTC instants. Convert a relative input such as
40
+ `{ in: "30m" }` once, when accepted. acp-client resolves it before persisting a
41
+ stopped-session intent. Replaying an intent preserves its original due time.
42
+
43
+ The harness owns an index of eligible deadlines and arms one timer for the
44
+ earliest deadline in the session. Recalculate after a committed reminder or
45
+ lifecycle change. On timer expiry, read the due records and recheck eligibility
46
+ under the session owner. After a restart, rebuild the timer from committed state.
47
+ A suspended or suspending channel or session holds due work and contributes no
48
+ wake deadline. Resume makes held work eligible. Retirement cancels future work.
49
+ A paused reminder also contributes no wake deadline.
50
+
51
+ Use a stable notice ID derived from the reminder ID and the scheduled instant.
52
+ Commit notice acceptance and occurrence advancement together, including the
53
+ terminal state of a one-off reminder. Retries use the same occurrence and notice
54
+ IDs. Cancellation and acceptance are ordered by their commits. The existing
55
+ notice path wakes an idle channel or steers a running turn at its next inference
56
+ boundary. A fired event means that the notice was queued. The eventual turn
57
+ outcome follows the existing channel events.
58
+ [External notices](../../channel-messaging/0001-DESIGN-external-notices/SPEC.md)
59
+
60
+ A reminder keeps its originating policy names. At firing, the destination policy
61
+ and inherited names resolve against the active configuration. Record and report
62
+ an invalid-policy block and remove it from the wake calculation until corrected.
63
+ Channel and reminder attribution travel with the notice.
64
+
65
+ ## Shared wake contract
66
+
67
+ On an executable session open, before enabling the timer or handing work to the
68
+ turn scheduler:
69
+
70
+ 1. Recover committed session state.
71
+ 2. Apply pending channel changes in their existing startup order. Apply pending
72
+ reminder intents in their submitted order against the resulting channel state.
73
+ 3. Process eligible due reminders using the resulting state. Return the intent
74
+ outcomes and the next eligible due time, or null when none exists. Release
75
+ eligible work to the normal scheduler once the open fence is complete.
76
+
77
+ An offline cancellation or pause accepted in step 2 therefore wins over an
78
+ overdue occurrence that has yet to be queued. A committed notice is already
79
+ owned by the inbox. Inspection-only opens perform no reminder writes or firing.
80
+ An open retry with the same intent IDs returns their recorded outcomes without
81
+ reapplying edits or queuing duplicate notices. Each mutation intent has an ID
82
+ distinct from its target reminder ID. Reusing that intent ID with changed
83
+ arguments is a conflict. A state-dependent rejection is reported as blocked with
84
+ a reason. acp-client keeps it visible until corrected or removed.
85
+
86
+ Return `nextDueAt` and its revision on executable open and publish the same data
87
+ when the earliest eligible deadline changes. Persist the revision so it never
88
+ decreases on reopen of the same session. For that session, one revision always
89
+ identifies one deadline value, including null. The host applies the same
90
+ comparison to open responses and events: ignore older revisions, accept newer
91
+ ones, and flag a conflicting value at the same revision without replacing the
92
+ stored value. An executable open repairs a missed update when it returns a newer
93
+ revision. Only a separately established replacement session starts a new fence.
94
+ Report firing with the
95
+ reminder ID, occurrence time and notice ID, and cancellation with the reminder
96
+ ID. The open response is authoritative for reconciling a missed update.
97
+
98
+ acp-client persists one next reported deadline per Agent alongside pending
99
+ reminder intents. Its effective deadline is the minimum of that value and any
100
+ eligible deadline supplied by a pending create or edit. At the deadline,
101
+ acp-client uses lazy start. A running harness already has its own timer. A
102
+ stopped harness processes due work on open. This requires no wake RPC and no
103
+ periodic container starts. The consumer can list cached records plus pending
104
+ intents without opening a stopped harness. The cache is last-confirmed state.
105
+
106
+ Offline timing depends on a running acp-client supervisor. If the harness
107
+ commits a reminder or advances a deadline before acp-client persists the new
108
+ wake time, a crash can leave the host with a stale deadline. This is an accepted
109
+ v1 window. The saved reminder is recovered at the next eligible open and can
110
+ run late. The harness may acknowledge its local commit before the host
111
+ persists the wake. A wake can also start a cold container, which adds startup
112
+ time before the turn runs.
113
+
114
+ ## Routines
115
+
116
+ One-offs use `{ at }`. Routines add `{ every, startAt? }` and
117
+ `{ cron, timezone }`, with optional `until` or `count`. Calendar schedules use
118
+ the specified timezone. Each concrete occurrence has its own scheduled UTC
119
+ instant and stable ID. The routine contract decision must define daylight-saving
120
+ gaps and folds and how skipped occurrences interact with `count`.
121
+
122
+ On reopen or resume, the proposed default is to coalesce elapsed occurrences into
123
+ one notice with the number missed and the last scheduled time. The routine can
124
+ also skip elapsed occurrences or request each occurrence. Processing and
125
+ catch-up must be bounded so a long outage cannot monopolize open. The proposed
126
+ overlap default skips a due occurrence while a prior occurrence of that routine
127
+ is waiting or running. The queue alternative follows ordinary channel
128
+ scheduling. The routine contract must define how the prior occurrence remains
129
+ identifiable through inbox take, turn completion and restart.
130
+
131
+ Apply the same scheduling minimums to agent tools and host requests. A one-off
132
+ must be due at least two minutes after acceptance. Repeating schedules must
133
+ leave at least ten minutes between consecutive occurrences. The harness checks
134
+ this for both intervals and cron and refuses an invalid schedule. The contract
135
+ decision defines how cron validation establishes the minimum across calendar
136
+ and timezone transitions. Advertise both minimums, the active routine cap per
137
+ channel, and the expiry defaults, including the grace floor and ceiling, during
138
+ initialization so consumers can validate locally. The harness remains
139
+ authoritative when it accepts a schedule.
140
+
141
+ The default expiry grace starts at the scheduled occurrence. For a one-off,
142
+ use twice the lead time from acceptance to that instant. For a routine, use
143
+ twice the interval for the occurrence. Clamp the resulting grace to at least
144
+ five minutes and at most 24 hours. A two-minute lead gets five minutes of grace.
145
+ Keep the one-off expiry stable across retries. The contract review must settle
146
+ the interval used for calendar schedules and how to report expired occurrences.
147
+ An explicit `expiresAfter: null` permits late delivery. The catch-up and overlap
148
+ defaults remain subject to contract review.
149
+
150
+ Scheduled turns use ordinary usage accounting. The planned unattended-turn
151
+ guard is a prerequisite for enabling unattended routines.
152
+
153
+ ## Implementation and acceptance
154
+
155
+ 1. Land the harness contract decision first. Implement one-offs, the tools,
156
+ durable notice enqueue and open catch-up behind the tools, storage and
157
+ scheduling contracts. Use a controlled clock to test detached wake,
158
+ suspension, retirement, cancellation around the deadline, and restart on
159
+ either side of notice acceptance. Cover memory and SQLite.
160
+ 2. Add the startup intent and deadline contract with in-process and real stdio
161
+ conformance. In the joint acp-client gate, stop a harness with a saved reminder
162
+ and verify one lazy start and one notice to the original channel. Cancel an
163
+ overdue reminder while stopped and verify zero notices on open. Exercise
164
+ replay after a lost open response, a missed deadline event, and the accepted
165
+ crash window. acp-client owns pending intent persistence, cache, capability
166
+ wiring and idle-stop policy.
167
+ 3. Add routines on the same contract after the routine decisions. Test calendar
168
+ and interval schedules, missed runs, overlap, limits, and replay of a committed
169
+ occurrence.
@@ -0,0 +1,128 @@
1
+ # Web search and page fetching
2
+
3
+ Date: 2026-11-22
4
+
5
+ Status: Proposed for M2. Define the rest of the initial tool set before starting implementation.
6
+
7
+ ## Scope
8
+
9
+ Give the agent two tools for public web research. Exa is the first backend for
10
+ both tools. The harness process calls Exa over HTTPS through its existing tool
11
+ execution path. Standalone chat and acp-client use the same implementation.
12
+ The tool contracts expose web results independently of the backend.
13
+
14
+ ## Tool contracts
15
+
16
+ | Tool | Arguments | Successful result |
17
+ | --- | --- | --- |
18
+ | `web_search` | `query`, a non-empty string | A ranked list of results with title, URL, and short excerpt when available. An empty list is a valid result. |
19
+ | `web_fetch` | `url`, a single public HTTP(S) URL | The source URL, title when available, readable text, `truncated`, and `coverage`. |
20
+
21
+ The adapter calls Exa `/search` with highlights and `/contents` with bounded text
22
+ for a single URL. Keep the number of search results and the amount of text
23
+ bounded before handing the result to the model. The operator controls these
24
+ limits and the request deadline. Record initial defaults in
25
+ [Business rules](../../BUSINESS_RULES.md) when implementation is planned. The
26
+ fetch tool can open a URL supplied by the user or returned by search. Returned
27
+ page text and excerpts are external data, with source URLs retained for citations.
28
+ `truncated` indicates known clipping, whether at the backend or in the harness.
29
+ `coverage` describes the extraction before clipping. It is `full` when evidence
30
+ supports that the backend extracted the full readable page, `partial` when the
31
+ extraction is known to be incomplete, and `unknown` when the backend gives
32
+ insufficient evidence. Reaching a backend cap without a reliable clipping signal
33
+ does not establish full coverage.
34
+ [Exa Search API](https://exa.ai/docs/reference/search) ·
35
+ [Exa Contents API](https://exa.ai/docs/contents/quickstart)
36
+
37
+ ## Independent HTTP fetching
38
+
39
+ When implementation starts, assign a separate agent to build a direct HTTP
40
+ backend for `web_fetch` in parallel with the Exa adapter. Select the fetch
41
+ backend independently of search. Both backends use the same tool contract,
42
+ permission checks, cancellation, and result limits. Keep Exa as the initial
43
+ default and comparison backend while the direct fetcher is evaluated.
44
+
45
+ Start with public HTML and plain text. Bound response size, redirect count,
46
+ and request time. For each connection, including every redirect, the direct
47
+ transport must connect only to a validated public address. Keep provider
48
+ credentials out of requests to source sites. With Exa the harness connects to
49
+ Exa's API and Exa performs the fetch. Report unsupported pages explicitly. Include
50
+ JavaScript-heavy pages and PDFs in the comparison to see where a hosted fetcher
51
+ still adds value.
52
+
53
+ Maintain a repeatable set of URLs and compare usable text, source attribution,
54
+ failures, latency, and paid requests. Turn extraction failures into offline
55
+ regression fixtures and rerun a small live comparison after meaningful changes.
56
+ Use the results to decide when direct HTTP can become the default. Automatic
57
+ paid fallback requires a separate decision so it is visible in policy and cost.
58
+
59
+ ## Configuration and credentials
60
+
61
+ Managed session configuration has independent optional entries for search and
62
+ fetch. Each enabled entry selects a backend. Omit an entry to disable its tool.
63
+ Exa uses an environment variable reference, `EXA_API_KEY` by default. Direct
64
+ HTTP fetch can be enabled on its own and requires no provider credential. Reuse
65
+ the pattern in [configuration and permissions](../../11-19-config-permissions/SPEC.md).
66
+ Validate and resolve only credential references for selected backends when
67
+ opening the session. For a missing or empty required key, report the variable
68
+ name in the configuration error.
69
+
70
+ For standalone use, the launching shell or service supplies the environment.
71
+ For acp-client, the launcher supplies the environment to the native subprocess,
72
+ including when it runs in a container. The saved configuration and session
73
+ export carry backend choices and credential references. Authorization headers
74
+ and secret values stay out of tool results, inspector output, and logs. An imported session
75
+ uses the credential available in its destination process.
76
+
77
+ ## Execution and metering
78
+
79
+ Keep the Exa adapter in `capabilities/tools/`. Standalone and stdio compose
80
+ the same harness-owned registrations, each with a definition, validator, and
81
+ executor. Both tools use the existing permission gate, turn and channel
82
+ ownership, dispatch record, cancellation, and paired results. Apply the existing
83
+ availability and argument checks to these registrations before asking for
84
+ approval and recheck at dispatch. Calls to disabled tools and invalid arguments
85
+ receive a paired rejection without a provider request. Report actionable errors
86
+ for rate limits, provider errors, deadlines, and unavailable page content. Pass interruption through to
87
+ the request. The initial adapter makes one provider request per invocation,
88
+ with no automatic retries. An operator or model can decide whether another
89
+ explicit call is worthwhile.
90
+
91
+ Extend the shared execution result with optional usage metadata. Commit known
92
+ metadata in the same transaction as the paired result, keyed by the existing
93
+ invocation ID. Record the provider, operation, provider request ID when supplied,
94
+ and reported USD cost when supplied. Store Exa's `costDollars.total` as a
95
+ provider-reported estimate, including when the response yields a paired tool
96
+ failure such as unavailable page content.
97
+
98
+ Distinguish no paid request, provider-reported estimate, and unknown cost from
99
+ a dispatched paid invocation. Permission denial and argument rejection happen
100
+ before dispatch. Direct HTTP has no paid provider charge. When a crash or
101
+ interruption wins before the result and metadata commit, use the durable dispatch
102
+ record to report unknown cost for the paid invocation. A timeout without cost
103
+ evidence is also unknown. Keep one meter entry per invocation across restart.
104
+
105
+ Expose metering as inspection metadata for the channel and turn. Keep it out of
106
+ the text returned to the model. Model token accounting remains in the model-call
107
+ records. OpenRouter cost capture, spend budgets, and invoice reconciliation are
108
+ follow-up work. Pin any new public metering or storage fields in a contract
109
+ decision before implementing them.
110
+
111
+ ## Acceptance
112
+
113
+ 1. An offline fake API verifies both tool calls, normalized results, bounded
114
+ output, clipping and extraction coverage, and paired errors. Disabled tools
115
+ are absent from the offered set. Attempt a disabled or malformed call under
116
+ `ask` on standalone and stdio and check that neither prompts nor dispatches.
117
+ 2. Verify policy denial, cancellation, unknown cost on deadline, and retained
118
+ cost for failed extraction. Reopen SQLite after a committed result and after
119
+ process loss between dispatch and result commit. Verify attribution, one
120
+ meter entry per invocation, and unknown cost in the latter case.
121
+ 3. Enable HTTP fetch alone with no Exa key. Verify backend choices through
122
+ export and reopen. Verify that the saved config, session file, and inspector
123
+ omit credential values. For direct HTTP, test public and blocked destinations,
124
+ including a redirect to a blocked address. A blocked destination receives no
125
+ request.
126
+ 4. Run a live search and then open a selected result through the existing web
127
+ chat. Verify source links, tool lifecycle, and reported costs in the inspector.
128
+ Keep the live check outside the automated suite.