@qlairoslabs/acp-client 0.13.0-alpha.1 → 0.13.2-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 (343) hide show
  1. package/CONSUMER_GUIDE.md +181 -8
  2. package/MIGRATION-0.12-to-0.13.md +20 -7
  3. package/package.json +13 -2
  4. package/src/agent/config.ts +2 -0
  5. package/src/agent/conversation-manager.ts +1 -0
  6. package/src/agent/native-operations.ts +40 -0
  7. package/src/agent-session-config.ts +2 -0
  8. package/src/agent-session.ts +12 -2
  9. package/src/agent.ts +100 -2
  10. package/src/client.ts +5 -3
  11. package/src/controller-connection.ts +1 -0
  12. package/src/controller.ts +2 -0
  13. package/src/index.ts +3 -0
  14. package/src/launcher.ts +2 -0
  15. package/src/native/approvals.ts +20 -3
  16. package/src/native/capabilities.ts +2 -2
  17. package/src/native/connection.ts +1 -1
  18. package/src/native/controller.ts +5 -3
  19. package/src/native/host-config.ts +2 -0
  20. package/src/native/host.ts +83 -4
  21. package/src/native/mcp.ts +47 -0
  22. package/src/native/recovery.ts +8 -7
  23. package/src/native/reminders/routine-guard.ts +4 -3
  24. package/src/native/reminders/routine-wire.ts +1 -1
  25. package/src/native-harness/README.md +58 -1
  26. package/src/native-harness/package.json +4 -0
  27. package/src/native-harness/scripts/build-routine-zones.py +47 -0
  28. package/src/native-harness/src/capabilities/attachments/admission.ts +42 -0
  29. package/src/native-harness/src/capabilities/attachments/image-validation.ts +98 -0
  30. package/src/native-harness/src/capabilities/attachments/input.ts +1 -0
  31. package/src/native-harness/src/capabilities/attachments/read.ts +76 -0
  32. package/src/native-harness/src/capabilities/attachments/recovery.ts +26 -0
  33. package/src/native-harness/src/capabilities/attachments/selection.ts +37 -0
  34. package/src/native-harness/src/capabilities/attachments/service.ts +75 -0
  35. package/src/native-harness/src/capabilities/attachments/upload.ts +164 -0
  36. package/src/native-harness/src/capabilities/attachments/vision.ts +45 -0
  37. package/src/native-harness/src/capabilities/context/build.ts +5 -0
  38. package/src/native-harness/src/capabilities/context/session.ts +2 -1
  39. package/src/native-harness/src/capabilities/model/openrouter-stream.ts +80 -17
  40. package/src/native-harness/src/capabilities/model/runner.ts +6 -3
  41. package/src/native-harness/src/capabilities/reminders/cron-calendar.ts +50 -0
  42. package/src/native-harness/src/capabilities/reminders/cron-fields.ts +46 -0
  43. package/src/native-harness/src/capabilities/reminders/cron-proof.ts +32 -0
  44. package/src/native-harness/src/capabilities/reminders/cron-zone.ts +53 -0
  45. package/src/native-harness/src/capabilities/reminders/iana-zones.json.gz +0 -0
  46. package/src/native-harness/src/capabilities/reminders/iana-zones.ts +34 -0
  47. package/src/native-harness/src/capabilities/reminders/interval.ts +30 -0
  48. package/src/native-harness/src/capabilities/reminders/routine-advance.ts +47 -0
  49. package/src/native-harness/src/capabilities/reminders/routine-backlog.ts +47 -0
  50. package/src/native-harness/src/capabilities/reminders/routine-expiry.ts +15 -0
  51. package/src/native-harness/src/capabilities/reminders/routine-occurrence.ts +65 -0
  52. package/src/native-harness/src/capabilities/reminders/routine-schedule.ts +70 -0
  53. package/src/native-harness/src/capabilities/reminders/unattended.ts +8 -0
  54. package/src/native-harness/src/capabilities/tools/mcp/client.ts +97 -0
  55. package/src/native-harness/src/capabilities/tools/mcp/http.ts +183 -0
  56. package/src/native-harness/src/capabilities/tools/mcp/registry.ts +62 -0
  57. package/src/native-harness/src/capabilities/tools/mcp/result.ts +33 -0
  58. package/src/native-harness/src/capabilities/tools/mcp/schema.ts +77 -0
  59. package/src/native-harness/src/capabilities/tools/mcp/secrets.ts +28 -0
  60. package/src/native-harness/src/capabilities/tools/mcp/stdio.ts +105 -0
  61. package/src/native-harness/src/capabilities/tools/reminders/index.ts +27 -5
  62. package/src/native-harness/src/capabilities/tools/runtime/invocations.ts +4 -1
  63. package/src/native-harness/src/capabilities/tools/web/config.ts +1 -0
  64. package/src/native-harness/src/capabilities/tools/web/definitions.ts +18 -0
  65. package/src/native-harness/src/capabilities/tools/web/direct-address.ts +56 -0
  66. package/src/native-harness/src/capabilities/tools/web/direct-transport.ts +235 -0
  67. package/src/native-harness/src/capabilities/tools/web/direct.ts +149 -0
  68. package/src/native-harness/src/capabilities/tools/web/exa-transport.ts +41 -0
  69. package/src/native-harness/src/capabilities/tools/web/exa.ts +71 -0
  70. package/src/native-harness/src/capabilities/tools/web/preview.ts +44 -0
  71. package/src/native-harness/src/capabilities/tools/web/registry.ts +47 -0
  72. package/src/native-harness/src/capabilities/tools/web/usage.ts +1 -0
  73. package/src/native-harness/src/contracts/agent.ts +3 -1
  74. package/src/native-harness/src/contracts/attachments.ts +62 -0
  75. package/src/native-harness/src/contracts/config-permissions.ts +14 -3
  76. package/src/native-harness/src/contracts/context.ts +1 -1
  77. package/src/native-harness/src/contracts/events.ts +2 -2
  78. package/src/native-harness/src/contracts/loop.ts +3 -3
  79. package/src/native-harness/src/contracts/mcp.ts +22 -0
  80. package/src/native-harness/src/contracts/model-execution.ts +2 -1
  81. package/src/native-harness/src/contracts/operator-controls.ts +8 -1
  82. package/src/native-harness/src/contracts/protocol.ts +21 -5
  83. package/src/native-harness/src/contracts/reminders.ts +4 -2
  84. package/src/native-harness/src/contracts/routines.ts +20 -0
  85. package/src/native-harness/src/contracts/session-file.ts +2 -0
  86. package/src/native-harness/src/contracts/session.ts +8 -3
  87. package/src/native-harness/src/contracts/storage.ts +32 -13
  88. package/src/native-harness/src/contracts/tools.ts +2 -0
  89. package/src/native-harness/src/contracts/web.ts +16 -0
  90. package/src/native-harness/src/governance/permissions/gate.ts +9 -2
  91. package/src/native-harness/src/governance/policy/resolve.ts +6 -1
  92. package/src/native-harness/src/index.ts +48 -12
  93. package/src/native-harness/src/interfaces/cli/development.ts +108 -53
  94. package/src/native-harness/src/interfaces/cli/serve.ts +2 -2
  95. package/src/native-harness/src/interfaces/cli/start.ts +22 -13
  96. package/src/native-harness/src/interfaces/client.ts +8 -2
  97. package/src/native-harness/src/interfaces/inspector/index.html +7 -1
  98. package/src/native-harness/src/interfaces/inspector/state.ts +6 -2
  99. package/src/native-harness/src/interfaces/protocol/load.ts +3 -1
  100. package/src/native-harness/src/interfaces/protocol/local.ts +13 -4
  101. package/src/native-harness/src/interfaces/protocol/operator.ts +8 -2
  102. package/src/native-harness/src/interfaces/protocol/server.ts +102 -36
  103. package/src/native-harness/src/interfaces/protocol/stdio-client.ts +8 -0
  104. package/src/native-harness/src/interfaces/web-chat/index.html +65 -12
  105. package/src/native-harness/src/interfaces/web-chat/server.ts +30 -3
  106. package/src/native-harness/src/kernel/channels.ts +27 -15
  107. package/src/native-harness/src/kernel/loop.ts +1 -1
  108. package/src/native-harness/src/runtime/config/inference-key.ts +7 -0
  109. package/src/native-harness/src/runtime/config/managed.ts +1 -1
  110. package/src/native-harness/src/runtime/config/paths.ts +8 -1
  111. package/src/native-harness/src/runtime/execution/mcp-stdio.ts +31 -0
  112. package/src/native-harness/src/runtime/reminder-validation.ts +31 -10
  113. package/src/native-harness/src/runtime/reminders.ts +2 -2
  114. package/src/native-harness/src/state/storage/archive.ts +113 -12
  115. package/src/native-harness/src/state/storage/attachment-files.ts +58 -0
  116. package/src/native-harness/src/state/storage/attachment-import.ts +106 -0
  117. package/src/native-harness/src/state/storage/attachment-tables.ts +123 -0
  118. package/src/native-harness/src/state/storage/engine.ts +396 -45
  119. package/src/native-harness/src/state/storage/inference.ts +30 -2
  120. package/src/native-harness/src/state/storage/memory-attachments.ts +56 -0
  121. package/src/native-harness/src/state/storage/memory-reminders.ts +31 -6
  122. package/src/native-harness/src/state/storage/memory.ts +32 -4
  123. package/src/native-harness/src/state/storage/reminder-archive.ts +53 -12
  124. package/src/native-harness/src/state/storage/reminder-change.ts +60 -14
  125. package/src/native-harness/src/state/storage/reminder-tables.ts +11 -3
  126. package/src/native-harness/src/state/storage/routine-row.ts +25 -0
  127. package/src/native-harness/src/state/storage/session-file.ts +22 -9
  128. package/src/native-harness/src/state/storage/sqlite-reminders.ts +48 -8
  129. package/src/native-harness/src/state/storage/sqlite.ts +59 -11
  130. package/src/native-harness/src/state/storage/web-tables.ts +47 -0
  131. package/src/native-harness/src/testing.ts +151 -56
  132. package/src/native-harness/src/util/attachment-input.ts +42 -0
  133. package/src/native-harness/src/util/config.ts +64 -9
  134. package/src/native-harness/src/util/intake.ts +7 -0
  135. package/src/native-harness/src/util/mcp-config.ts +102 -0
  136. package/src/native-harness/src/util/web-config.ts +34 -0
  137. package/src/native-harness/src/util/web-usage.ts +33 -0
  138. package/src/orchestrator/permissions.ts +6 -3
  139. package/src/permissions/conversation.ts +13 -5
  140. package/src/permissions/matcher.ts +2 -0
  141. package/src/permissions/outcome.ts +12 -1
  142. package/src/permissions/policy.ts +13 -8
  143. package/src/steering/combine.ts +1 -0
  144. package/src/steering/contracts.ts +3 -0
  145. package/src/terminals.ts +9 -6
  146. package/src/native/reminders/reminders.test.ts +0 -553
  147. package/src/native/reminders/routine-config.typecheck.ts +0 -13
  148. package/src/native/reminders/wire.typecheck.ts +0 -13
  149. package/src/native-harness/.res/README.md +0 -1
  150. package/src/native-harness/.res/architecture/README.md +0 -21
  151. package/src/native-harness/.res/architecture/context-and-data.md +0 -31
  152. package/src/native-harness/.res/architecture/execution.md +0 -42
  153. package/src/native-harness/.res/architecture/overview.md +0 -44
  154. package/src/native-harness/.res/architecture/persistence.md +0 -56
  155. package/src/native-harness/.res/architecture/suspend-and-resume.md +0 -45
  156. package/src/native-harness/.res/architecture/technical-architecture.md +0 -50
  157. package/src/native-harness/.res/decisions/0001-basic-loop.md +0 -11
  158. package/src/native-harness/.res/decisions/0002-channel-input.md +0 -17
  159. package/src/native-harness/.res/decisions/0003-inference-inspection.md +0 -14
  160. package/src/native-harness/.res/decisions/0004-shared-context.md +0 -21
  161. package/src/native-harness/.res/decisions/0005-notice-inbox.md +0 -20
  162. package/src/native-harness/.res/decisions/0006-explicit-notices.md +0 -12
  163. package/src/native-harness/.res/decisions/0007-channel-output.md +0 -12
  164. package/src/native-harness/.res/decisions/0008-browser-client.md +0 -16
  165. package/src/native-harness/.res/decisions/0009-scripted-model.md +0 -18
  166. package/src/native-harness/.res/decisions/0010-inprocess-protocol.md +0 -19
  167. package/src/native-harness/.res/decisions/0011-stdio-transport.md +0 -21
  168. package/src/native-harness/.res/decisions/0012-session-storage-contract.md +0 -37
  169. package/src/native-harness/.res/decisions/0013-durable-delivery-contract.md +0 -64
  170. package/src/native-harness/.res/decisions/0014-channel-controls-contract.md +0 -73
  171. package/src/native-harness/.res/decisions/0015-session-file-contract.md +0 -72
  172. package/src/native-harness/.res/decisions/0016-configuration-permissions.md +0 -159
  173. package/src/native-harness/.res/decisions/0017-openrouter-managed-config.md +0 -69
  174. package/src/native-harness/.res/decisions/0018-tool-dispatch-evidence.md +0 -78
  175. package/src/native-harness/.res/decisions/0019-model-execution.md +0 -188
  176. package/src/native-harness/.res/decisions/0020-startup-channel-changes.md +0 -71
  177. package/src/native-harness/.res/decisions/0021-tools-and-host-callbacks.md +0 -100
  178. package/src/native-harness/.res/decisions/0022-operator-controls.md +0 -115
  179. package/src/native-harness/.res/decisions/0023-long-running-mock.md +0 -82
  180. package/src/native-harness/.res/decisions/0024-callback-policy-names.md +0 -46
  181. package/src/native-harness/.res/decisions/0025-external-notices.md +0 -364
  182. package/src/native-harness/.res/decisions/0026-bounded-context.md +0 -81
  183. package/src/native-harness/.res/decisions/0027-development-instructions.md +0 -22
  184. package/src/native-harness/.res/decisions/0028-debug-tools.md +0 -16
  185. package/src/native-harness/.res/decisions/0029-bounded-model-call-pages.md +0 -37
  186. package/src/native-harness/.res/decisions/0030-timeline-retrieval.md +0 -145
  187. package/src/native-harness/.res/decisions/0031-one-off-reminders.md +0 -173
  188. package/src/native-harness/.res/docs/11-15.md +0 -148
  189. package/src/native-harness/.res/docs/BUSINESS_RULES.md +0 -111
  190. package/src/native-harness/.res/docs/WORK.md +0 -65
  191. package/src/native-harness/.res/docs/_/11-16-persistence/LOG.md +0 -312
  192. package/src/native-harness/.res/docs/_/11-16-persistence/PLAN.md +0 -77
  193. package/src/native-harness/.res/docs/_/11-16-persistence/SPEC.md +0 -313
  194. package/src/native-harness/.res/docs/_/11-19-channel-controls/LOG.md +0 -160
  195. package/src/native-harness/.res/docs/_/11-19-channel-controls/PLAN.md +0 -89
  196. package/src/native-harness/.res/docs/_/11-19-channel-controls/SPEC.md +0 -135
  197. package/src/native-harness/.res/docs/_/11-19-config-permissions/LOG.md +0 -143
  198. package/src/native-harness/.res/docs/_/11-19-config-permissions/PLAN.md +0 -93
  199. package/src/native-harness/.res/docs/_/11-19-config-permissions/SPEC.md +0 -181
  200. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/11-20-LOG.md +0 -433
  201. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PLAN.md +0 -60
  202. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PROTOCOL.md +0 -141
  203. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/SPEC.md +0 -168
  204. package/src/native-harness/.res/docs/attachments/0001-DESIGN/SPEC.md +0 -111
  205. package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/PLAN.md +0 -129
  206. package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/SPEC.md +0 -135
  207. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/LOG.md +0 -437
  208. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/PLAN.md +0 -127
  209. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/SPEC.md +0 -203
  210. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/LOG.md +0 -292
  211. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/PLAN.md +0 -91
  212. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/SPEC.md +0 -187
  213. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/LOG.md +0 -148
  214. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/PLAN.md +0 -95
  215. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/SPEC.md +0 -200
  216. package/src/native-harness/.res/docs/model-execution/0002-AMENDMENT-accounting/SPEC.md +0 -80
  217. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/LOG.md +0 -206
  218. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/PLAN.md +0 -106
  219. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/SPEC.md +0 -297
  220. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/LOG.md +0 -41
  221. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/PLAN.md +0 -36
  222. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/SPEC.md +0 -84
  223. package/src/native-harness/.res/docs/shell-execution/0001-DESIGN/SPEC.md +0 -147
  224. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/LOG.md +0 -15
  225. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/PLAN.md +0 -107
  226. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/SPEC.md +0 -114
  227. package/src/native-harness/.res/docs/todos/11-19-TODO-auto_review-approve.md +0 -24
  228. package/src/native-harness/.res/docs/todos/11-20-TODO-user-entered-tool-code.md +0 -23
  229. package/src/native-harness/.res/docs/todos/11-21-TODO-node-resource-coordination.md +0 -103
  230. package/src/native-harness/.res/docs/todos/11-22-TODO-harness-m1-sequence.md +0 -50
  231. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/LOG.md +0 -337
  232. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/PLAN.md +0 -76
  233. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/SPEC.md +0 -204
  234. package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/LOG.md +0 -73
  235. package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/SPEC.md +0 -64
  236. package/src/native-harness/.res/docs/tools-and-callbacks/0003-DESIGN-attachment-tools/SPEC.md +0 -58
  237. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/LOG.md +0 -45
  238. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/PLAN.md +0 -108
  239. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/SPEC.md +0 -169
  240. package/src/native-harness/.res/docs/web-tools/0001-DESIGN/SPEC.md +0 -128
  241. package/src/native-harness/.res/marketing-draft.md +0 -22
  242. package/src/native-harness/.res/sandbox/1-simple-harness/README.md +0 -285
  243. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-1.md +0 -19
  244. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-10.md +0 -138
  245. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-11.md +0 -148
  246. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-12.md +0 -172
  247. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-13.md +0 -194
  248. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-14.md +0 -233
  249. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-15.md +0 -249
  250. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-16.md +0 -265
  251. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-17.md +0 -279
  252. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-18.md +0 -293
  253. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-19.md +0 -307
  254. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-2.md +0 -29
  255. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-20.md +0 -317
  256. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-21.md +0 -327
  257. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-3.md +0 -40
  258. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-4.md +0 -59
  259. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-5.md +0 -69
  260. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-6.md +0 -79
  261. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-7.md +0 -89
  262. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-8.md +0 -102
  263. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-9.md +0 -116
  264. package/src/native-harness/.res/sandbox/1-simple-harness/conversation.jsonl +0 -49
  265. package/src/native-harness/.res/sandbox/1-simple-harness/doc.md +0 -87
  266. package/src/native-harness/.res/sandbox/1-simple-harness/harness.py +0 -289
  267. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 2.py +0 -221
  268. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 3.py +0 -287
  269. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy.py +0 -165
  270. package/src/native-harness/.res/sandbox/1-simple-harness/state.json +0 -22
  271. package/src/native-harness/.res/sandbox/1-simple-harness/system-prompt.md +0 -2
  272. package/src/native-harness/AGENTS.md +0 -70
  273. package/src/native-harness/ARCHITECTURE.md +0 -249
  274. package/src/native-harness/bun.lock +0 -26
  275. package/src/native-harness/test/agent.test.ts +0 -130
  276. package/src/native-harness/test/approval-gate.test.ts +0 -255
  277. package/src/native-harness/test/approval-protocol.test.ts +0 -94
  278. package/src/native-harness/test/boundaries.test.ts +0 -18
  279. package/src/native-harness/test/channel-controls.test.ts +0 -322
  280. package/src/native-harness/test/client-abort.test.ts +0 -136
  281. package/src/native-harness/test/config-policy.test.ts +0 -301
  282. package/src/native-harness/test/conformance/storage.ts +0 -1141
  283. package/src/native-harness/test/context.test.ts +0 -177
  284. package/src/native-harness/test/crash.test.ts +0 -187
  285. package/src/native-harness/test/debug-tools.test.ts +0 -67
  286. package/src/native-harness/test/development-cli.test.ts +0 -67
  287. package/src/native-harness/test/development.test.ts +0 -171
  288. package/src/native-harness/test/dispatch-evidence.test.ts +0 -58
  289. package/src/native-harness/test/e2e.test.ts +0 -186
  290. package/src/native-harness/test/external-notices.test.ts +0 -101
  291. package/src/native-harness/test/fixtures/approval-e2e.jsonl +0 -4
  292. package/src/native-harness/test/fixtures/crash-scenario.jsonl +0 -5
  293. package/src/native-harness/test/fixtures/development-lifecycle.jsonl +0 -10
  294. package/src/native-harness/test/fixtures/echo-scenario.jsonl +0 -3
  295. package/src/native-harness/test/fixtures/format2-schema.ts +0 -27
  296. package/src/native-harness/test/fixtures/format3-schema.ts +0 -16
  297. package/src/native-harness/test/fixtures/hold-scenario.jsonl +0 -4
  298. package/src/native-harness/test/fixtures/model-e2e.jsonl +0 -3
  299. package/src/native-harness/test/fixtures/storage-owner.ts +0 -20
  300. package/src/native-harness/test/format-reply.test.ts +0 -10
  301. package/src/native-harness/test/helpers/operator-view.ts +0 -41
  302. package/src/native-harness/test/helpers/scenario.ts +0 -9
  303. package/src/native-harness/test/helpers/session.ts +0 -38
  304. package/src/native-harness/test/helpers/stdio.ts +0 -46
  305. package/src/native-harness/test/inspector.test.ts +0 -77
  306. package/src/native-harness/test/listeners.test.ts +0 -49
  307. package/src/native-harness/test/loop.test.ts +0 -88
  308. package/src/native-harness/test/model-channel-double.test.ts +0 -87
  309. package/src/native-harness/test/model-crash.test.ts +0 -62
  310. package/src/native-harness/test/model-delivery-regressions.test.ts +0 -55
  311. package/src/native-harness/test/model-e2e.test.ts +0 -71
  312. package/src/native-harness/test/model-final-filter.test.ts +0 -30
  313. package/src/native-harness/test/model-large-reply.test.ts +0 -28
  314. package/src/native-harness/test/model-live-queue.test.ts +0 -33
  315. package/src/native-harness/test/model-runner.test.ts +0 -117
  316. package/src/native-harness/test/model-storage.test.ts +0 -99
  317. package/src/native-harness/test/model-stream-adapter.test.ts +0 -26
  318. package/src/native-harness/test/model-stream-public.test.ts +0 -77
  319. package/src/native-harness/test/notices.test.ts +0 -64
  320. package/src/native-harness/test/openrouter-config.test.ts +0 -218
  321. package/src/native-harness/test/operator-controls.test.ts +0 -132
  322. package/src/native-harness/test/output.test.ts +0 -44
  323. package/src/native-harness/test/owner-config.test.ts +0 -64
  324. package/src/native-harness/test/permissions-e2e.test.ts +0 -68
  325. package/src/native-harness/test/persistence.test.ts +0 -236
  326. package/src/native-harness/test/portability.test.ts +0 -337
  327. package/src/native-harness/test/protocol.test.ts +0 -160
  328. package/src/native-harness/test/reminder-clock.test.ts +0 -61
  329. package/src/native-harness/test/reminder-stdio.test.ts +0 -140
  330. package/src/native-harness/test/reminder-storage.test.ts +0 -124
  331. package/src/native-harness/test/scenario-jsonl.test.ts +0 -112
  332. package/src/native-harness/test/scripted.test.ts +0 -92
  333. package/src/native-harness/test/session-file.test.ts +0 -51
  334. package/src/native-harness/test/startup-channel-changes.test.ts +0 -256
  335. package/src/native-harness/test/stdio.test.ts +0 -132
  336. package/src/native-harness/test/storage-memory.test.ts +0 -4
  337. package/src/native-harness/test/storage-sqlite.test.ts +0 -420
  338. package/src/native-harness/test/suspension.test.ts +0 -430
  339. package/src/native-harness/test/timeline-retrieval.test.ts +0 -211
  340. package/src/native-harness/test/tools-catalog.test.ts +0 -468
  341. package/src/native-harness/test/tools-protocol.test.ts +0 -418
  342. package/src/native-harness/test/transfers.test.ts +0 -94
  343. package/src/native-harness/test/web-chat.test.ts +0 -35
@@ -0,0 +1,71 @@
1
+ import { ExaResponseLimit } from "./exa-transport.ts";
2
+ import { directUrl } from "./direct-address.ts";
3
+ import { fetchPreview, searchPreview, type WebHit } from "./preview.ts";
4
+
5
+ import type { WebToolError as WebError, WebResultUsage as WebUsage, WebToolResponse as WebResponse } from "../../../contracts/web.ts";
6
+ export type { WebToolError as WebError, WebResultUsage as WebUsage, WebToolResponse as WebResponse } from "../../../contracts/web.ts";
7
+ /** Transport must reject redirects, enforce raw/decoded 2 MiB caps and abort. */
8
+ export type ExaTransport = (request: { path: "/search" | "/contents"; key: string; body: object; signal: AbortSignal }) => Promise<{ status: number; body: unknown }>;
9
+ const failed = (code: WebError, usage: WebUsage = {}): WebResponse => ({ ok: false, code, message: ({ blocked_destination: "Web destination is blocked", unsupported_content: "Unsupported page content", invalid_arguments: "Invalid web tool arguments", rate_limited: "Web provider rate limit reached", provider_error: "Web provider request failed", tool_timeout: "Web request timed out", page_unavailable: "Page content is unavailable", result_too_large: "Page metadata exceeds the result limit", tool_interrupted: "Web request was interrupted", response_too_large: "Web provider response exceeds the limit" })[code], usage });
10
+ const record = (v: unknown): Record<string, unknown> | undefined => v && typeof v === "object" && !Array.isArray(v) ? v as Record<string, unknown> : undefined;
11
+ const usageOf = (value: Record<string, unknown> | undefined): WebUsage => {
12
+ const usage: WebUsage = {}, id = value?.requestId, cost = record(value?.costDollars)?.total;
13
+ if (typeof id === "string" && Buffer.byteLength(id) <= 256 && id.trim() && !/[\u0000-\u001f\u007f]/u.test(id)) usage.requestId = id;
14
+ if (typeof cost === "number" && Number.isFinite(cost) && cost >= 0) usage.usd = cost;
15
+ return usage;
16
+ };
17
+ /** Share strict public URL syntax and literal checks with the direct adapter;
18
+ * actual DNS binding remains the direct transport's responsibility. */
19
+ export function normalizedWebUrl(value: unknown): string | undefined {
20
+ if (typeof value !== "string") return;
21
+ try { const result = directUrl(value).href; return Buffer.byteLength(result) <= 2048 ? result : undefined; } catch { return; }
22
+ }
23
+ export function webArgumentsProblem(name: "web_search" | "web_fetch", value: unknown): string | undefined {
24
+ const input = record(value), field = name === "web_search" ? "query" : "url";
25
+ if (!input || Object.keys(input).length !== 1 || !(field in input)) return "Expected exactly one argument";
26
+ if (field === "query") return typeof input.query === "string" && !!input.query.trim() && Buffer.byteLength(input.query) <= 1024 ? undefined : "Invalid query";
27
+ return normalizedWebUrl(input.url) ? undefined : "Invalid URL";
28
+ }
29
+ export async function runExa(input: { operation: "web_search" | "web_fetch"; args: { query: string } | { url: string }; key: string; transport: ExaTransport; maxResults?: number; excerptBytes?: number; deadlineMs?: number; signal?: AbortSignal }): Promise<WebResponse> {
30
+ if (input.signal?.aborted) return failed("tool_interrupted");
31
+ const args = input.args, search = input.operation === "web_search";
32
+ if (webArgumentsProblem(input.operation, args)) return failed("invalid_arguments");
33
+ const url = !search && "url" in args ? normalizedWebUrl(args.url)! : undefined;
34
+ const body = search && "query" in args ? { query: args.query, type: "auto", numResults: input.maxResults ?? 5, contents: { highlights: { maxCharacters: 512 } } }
35
+ : { urls: [url], text: { maxCharacters: 16000 }, maxAgeHours: 24, livecrawlTimeout: 10000, subpages: 0 };
36
+ const controller = new AbortController(); let cause: "tool_timeout" | "tool_interrupted" | undefined;
37
+ const abort = () => { cause ??= "tool_interrupted"; controller.abort(); };
38
+ input.signal?.addEventListener("abort", abort, { once: true });
39
+ if (input.signal?.aborted) abort();
40
+ const timeout = setTimeout(() => { cause ??= "tool_timeout"; controller.abort(); }, input.deadlineMs ?? 15000);
41
+ try {
42
+ if (cause) return failed(cause);
43
+ const response = await input.transport({ path: search ? "/search" : "/contents", key: input.key, body, signal: controller.signal });
44
+ if (cause) return failed(cause);
45
+ const json = record(response.body), usage = usageOf(json);
46
+ // Provider output is untrusted and may echo request headers. Do not allow
47
+ // the resolved credential to escape via content or request metadata.
48
+ if (input.key && usage.requestId?.includes(input.key)) delete usage.requestId;
49
+ const redact = (value: string) => input.key ? value.replaceAll(input.key, "[redacted]") : value;
50
+ if (response.status === 429) return failed("rate_limited", usage);
51
+ if (response.status < 200 || response.status >= 300 || !json) return failed("provider_error", usage);
52
+ if (search) {
53
+ if (!Array.isArray(json.results)) return failed("provider_error", usage);
54
+ const hits: WebHit[] = [];
55
+ for (const value of json.results) {
56
+ const item = record(value), hitUrl = normalizedWebUrl(item?.url); if (!hitUrl || (input.key && hitUrl.includes(input.key))) continue;
57
+ const highlights = item?.highlights;
58
+ hits.push({ title: typeof item?.title === "string" ? redact(item.title) : null, url: hitUrl,
59
+ excerpt: Array.isArray(highlights) ? highlights.filter((part): part is string => typeof part === "string").map(redact).join(" ") || null : null });
60
+ }
61
+ return { ok: true, content: searchPreview(hits, input.maxResults ?? 5, input.excerptBytes ?? 512), usage };
62
+ }
63
+ const statuses = Array.isArray(json.statuses) ? json.statuses.map(record).filter(entry => entry?.id === url) : [];
64
+ const results = Array.isArray(json.results) ? json.results.map(record).filter(entry => normalizedWebUrl(entry?.url) === url) : [];
65
+ if (statuses.length !== 1 || statuses[0]?.status !== "success" || results.length !== 1 || typeof results[0]?.text !== "string" || !results[0].text.trim()) return failed("page_unavailable", usage);
66
+ if (input.key && url!.includes(input.key)) return failed("page_unavailable", usage);
67
+ const content = fetchPreview({ url: url!, title: typeof results[0].title === "string" ? redact(results[0].title) : null, text: redact(results[0].text), truncated: false, coverage: "unknown" });
68
+ return content === undefined ? failed("result_too_large", usage) : { ok: true, content, usage };
69
+ } catch (error) { return failed(cause ?? (error instanceof ExaResponseLimit ? "response_too_large" : "provider_error")); }
70
+ finally { clearTimeout(timeout); input.signal?.removeEventListener("abort", abort); }
71
+ }
@@ -0,0 +1,44 @@
1
+ /** Provider-neutral model-facing data. All limits include serialized JSON. */
2
+ export interface WebHit { title: string | null; url: string; excerpt: string | null }
3
+ export interface WebPage { url: string; title: string | null; text: string; truncated: boolean; coverage: "full" | "partial" | "unknown" }
4
+ export const WEB_PREVIEW_BYTES = 2048;
5
+ const size = (value: unknown) => Buffer.byteLength(JSON.stringify(value), "utf8");
6
+
7
+ /** Longest scalar-aligned prefix which makes the complete object fit. */
8
+ function fitText(value: string, fits: (prefix: string) => boolean): string | undefined {
9
+ const scalars = Array.from(value); let low = 0, high = scalars.length;
10
+ if (!fits("")) return undefined;
11
+ while (low < high) { const mid = Math.ceil((low + high) / 2); if (fits(scalars.slice(0, mid).join(""))) low = mid; else high = mid - 1; }
12
+ return scalars.slice(0, low).join("");
13
+ }
14
+ export function truncateUtf8(value: string, max: number): string {
15
+ return fitText(value, prefix => Buffer.byteLength(prefix) <= max) ?? "";
16
+ }
17
+ export function searchPreview(hits: readonly WebHit[], maxHits = 5, excerptBytes = 512): string {
18
+ const results: WebHit[] = [];
19
+ for (const original of hits.slice(0, maxHits)) {
20
+ const hit = { ...original, excerpt: original.excerpt === null ? null : truncateUtf8(original.excerpt, excerptBytes) };
21
+ const candidate = () => ({ results: [...results, hit] });
22
+ if (size(candidate()) > WEB_PREVIEW_BYTES && hit.excerpt !== null)
23
+ hit.excerpt = fitText(hit.excerpt, prefix => size({ results: [...results, { ...hit, excerpt: prefix }] }) <= WEB_PREVIEW_BYTES) ?? null;
24
+ if (size(candidate()) > WEB_PREVIEW_BYTES && hit.title !== null)
25
+ hit.title = fitText(hit.title, prefix => size({ results: [...results, { ...hit, title: prefix }] }) <= WEB_PREVIEW_BYTES) ?? null;
26
+ if (size(candidate()) > WEB_PREVIEW_BYTES) break;
27
+ results.push(hit);
28
+ }
29
+ return JSON.stringify({ results });
30
+ }
31
+ export function fetchPreview(input: WebPage): string | undefined {
32
+ const page = { ...input }; const fits = () => size(page) <= WEB_PREVIEW_BYTES;
33
+ if (fits()) return JSON.stringify(page);
34
+ page.truncated = true;
35
+ if (page.title !== null) {
36
+ const original = page.title;
37
+ page.title = fitText(original, prefix => size({ ...page, title: prefix, text: "" }) <= WEB_PREVIEW_BYTES) ?? null;
38
+ }
39
+ const original = page.text;
40
+ const text = fitText(original, prefix => size({ ...page, text: prefix }) <= WEB_PREVIEW_BYTES);
41
+ if (text === undefined) return undefined;
42
+ page.text = text;
43
+ return JSON.stringify(page);
44
+ }
@@ -0,0 +1,47 @@
1
+ import { fetchDirect } from "./direct.ts";
2
+ import { DirectHttpError } from "./direct-address.ts";
3
+ import type { CheckedWebRegistration } from "../../../contracts/web.ts";
4
+ export type { CheckedWebRegistration } from "../../../contracts/web.ts";
5
+ import { resolveWebCredentials, type Validated, type WebConfig } from "./config.ts";
6
+ import { WEB_FETCH, WEB_SEARCH, webDefinitions, webProblem } from "./definitions.ts";
7
+ import { runExa, type ExaTransport, type WebResponse } from "./exa.ts";
8
+
9
+ /** Adapter implementations are supplied by the trusted assembly, never config. */
10
+ export type DirectFetch = (url: string, signal: AbortSignal, deadlineMs: number) => Promise<WebResponse>;
11
+ /** Build once per executable open; credentials remain inside executor closures. */
12
+ export function createWebRegistry(config: WebConfig, env: Readonly<Record<string, string | undefined>>,
13
+ providers: { exa: ExaTransport; http?: DirectFetch }): Validated<readonly CheckedWebRegistration[]> {
14
+ const credentials = resolveWebCredentials(config, env);
15
+ if (!credentials.ok) return credentials;
16
+ if (config.webFetch?.backend === "http" && !providers.http) return { ok: false, error: { code: "invalid_config", message: "HTTP fetch adapter is unavailable" } };
17
+ const registrations: CheckedWebRegistration[] = [];
18
+ if (config.webSearch) {
19
+ const options = structuredClone(config.webSearch), key = credentials.value.searchKey!;
20
+ registrations.push({ definition: webDefinitions.find(value => value.name === WEB_SEARCH)!, validate: args => webProblem(WEB_SEARCH, args),
21
+ dispatch: { backend: "exa", operation: "web_search", paid: true },
22
+ execute: (args, signal) => runExa({ operation: "web_search", args: args as { query: string }, key, transport: providers.exa,
23
+ maxResults: options.maxResults, excerptBytes: options.excerptBytes, deadlineMs: options.deadlineMs, signal }) });
24
+ }
25
+ if (config.webFetch) {
26
+ const options = structuredClone(config.webFetch);
27
+ registrations.push({ definition: webDefinitions.find(value => value.name === WEB_FETCH)!, validate: args => webProblem(WEB_FETCH, args),
28
+ dispatch: options.backend === "exa" ? { backend: "exa", operation: "web_fetch", paid: true } : { backend: "http", operation: "web_fetch", paid: false },
29
+ execute: (args, signal) => {
30
+ const problem = webProblem(WEB_FETCH, args);
31
+ if (problem) return Promise.resolve({ ok: false, code: "invalid_arguments", message: "Invalid web tool arguments", usage: {} });
32
+ return options.backend === "exa"
33
+ ? runExa({ operation: "web_fetch", args: args as { url: string }, key: credentials.value.fetchKey!, transport: providers.exa, deadlineMs: options.deadlineMs, signal })
34
+ : providers.http!((args as { url: string }).url, signal, options.deadlineMs ?? 15000).then(result => ({ ...result, usage: {} }));
35
+ } });
36
+ }
37
+ return { ok: true, value: registrations };
38
+ }
39
+
40
+ /** Production adapter; fixture transports remain assembly-only. */
41
+ export const directWebFetch: DirectFetch = async (url, signal, deadlineMs) => {
42
+ try { return { ok: true, content: await fetchDirect(url, deadlineMs, signal), usage: {} }; }
43
+ catch (error) {
44
+ const known = error instanceof DirectHttpError;
45
+ return { ok: false, code: known ? error.code : "page_unavailable", message: known ? error.message : "Web destination could not be read.", usage: {} };
46
+ }
47
+ };
@@ -0,0 +1 @@
1
+ export * from "../../../util/web-usage.ts";
@@ -4,6 +4,8 @@ export interface ChannelInput {
4
4
  channelId: string;
5
5
  participantId: string;
6
6
  text: string;
7
+ /** Ordered mixed parts; callers supply a matching newline-joined text projection. */
8
+ parts?: readonly import("./attachments.ts").InputPart[];
7
9
  itemId?: string;
8
10
  policy?: string | null;
9
11
  }
@@ -52,7 +54,7 @@ export type SendResult =
52
54
  * an already accepted input never gets this; it returns its recorded outcome. */
53
55
  | "channel_suspended"
54
56
  /** Decision 0014: the channel ID was deleted and is reserved. */
55
- | "channel_retired" };
57
+ | "channel_retired" | "unsupported_image" | "transfer_limit" };
56
58
 
57
59
  /** Shared entity with one delivery behavior for messages and notices: accept
58
60
  * durably, then the channel takes the item as soon as it can. An active turn
@@ -0,0 +1,62 @@
1
+ /** An immutable harness-owned attachment reference, never a filesystem path. */
2
+ export type InputPart =
3
+ | { readonly type: "text"; readonly text: string }
4
+ | { readonly type: "attachment"; readonly id: string };
5
+
6
+ /** Metadata describes committed bytes. It does not grant access to them. */
7
+ export interface AttachmentMetadata {
8
+ readonly id: string;
9
+ readonly channel: string;
10
+ readonly filename: string;
11
+ readonly mediaType: string;
12
+ readonly bytes: number;
13
+ readonly sha256: string;
14
+ }
15
+
16
+ /** Metadata-only presentation of a submitted part. */
17
+ export type AttachmentViewPart = { type: "text"; text: string } |
18
+ { type: "attachment"; id: string; text?: never; metadata?: AttachmentMetadata; unavailable?: true };
19
+
20
+ /** A provider boundary refused an image request without sending a partial one. */
21
+ export interface AttachmentFailure {
22
+ code: "unsupported_image" | "attachment_unavailable" | "transfer_limit";
23
+ attachmentIds: string[];
24
+ }
25
+
26
+ /** Limits apply to decoded bytes, not base64 or transport frames. */
27
+ export const ATTACHMENT_LIMITS = {
28
+ fileBytes: 20 * 1024 * 1024,
29
+ imageBytesPerTurn: 40 * 1024 * 1024,
30
+ parts: 32,
31
+ references: 8,
32
+ inputBytes: 8 * 1024,
33
+ chunkBytes: 512 * 1024,
34
+ openUploads: 4,
35
+ uploadIdleMs: 60_000,
36
+ imageSide: 8192,
37
+ imagePixels: 20_000_000,
38
+ } as const;
39
+
40
+ /** Project only metadata allowed by the current owner or shared timeline. */
41
+ export function attachmentView(parts: readonly InputPart[], read: ((id: string) => { ok: true; value: { metadata: AttachmentMetadata; timelineVisible: boolean } | undefined } | { ok: false }) | undefined,
42
+ scope: { ownerChannel?: string; timeline?: boolean }): AttachmentViewPart[] {
43
+ return parts.map(part => {
44
+ if (part.type === "text") return { ...part };
45
+ const result = read?.(part.id), found = result?.ok ? result.value : undefined;
46
+ const visible = found && (scope.timeline ? found.timelineVisible : found.metadata.channel === scope.ownerChannel);
47
+ return visible ? { ...part, metadata: found!.metadata } : { ...part, unavailable: true };
48
+ });
49
+ }
50
+
51
+ /** Durable reason representation allows typed recovery after process restart. */
52
+ export function attachmentFailureReason(failure: AttachmentFailure): string {
53
+ return JSON.stringify({ attachmentFailure: failure });
54
+ }
55
+ export function parseAttachmentFailure(reason: string): AttachmentFailure | undefined {
56
+ try {
57
+ const value = JSON.parse(reason)?.attachmentFailure;
58
+ if (!value || !["unsupported_image", "attachment_unavailable", "transfer_limit"].includes(value.code)
59
+ || !Array.isArray(value.attachmentIds) || !value.attachmentIds.every((id: unknown) => typeof id === "string")) return undefined;
60
+ return { code: value.code, attachmentIds: [...value.attachmentIds] };
61
+ } catch { return undefined; }
62
+ }
@@ -1,15 +1,26 @@
1
+ import type { McpServer } from "./mcp.ts";
2
+
1
3
  /** Decisions 0016 and 0017: a validated portable session configuration.
2
4
  * Script files and credential environment variables are destination resources. */
3
5
  export type ToolDecision = "allow" | "ask" | "deny";
4
- export interface ToolPolicy { fallback: ToolDecision; tools: Record<string, ToolDecision> }
5
- export type ManagedModel = { protocol: "scripted"; script: string }
6
- | { protocol: "openrouter"; model: string; apiKeyEnv: string };
6
+ export interface ToolPolicy { fallback: ToolDecision; mcp?: "allow" | "deny"; tools: Record<string, ToolDecision> }
7
+ export type ManagedModel = { protocol: "scripted"; script: string; imageInput?: boolean }
8
+ | { protocol: "openrouter"; model: string; apiKeyEnv: string; imageInput?: boolean }
9
+ | { protocol: "openai-compatible"; providerId: string; model: string; baseUrl: string; apiKeyEnv?: string };
10
+ /** Decision 0035: independent portable web backends, with credential names only. */
11
+ export interface ExaSearchConfig { backend: "exa"; apiKeyEnv?: string; maxResults?: number; excerptBytes?: number; deadlineMs?: number }
12
+ export type WebFetchConfig = { backend: "exa"; apiKeyEnv?: string; deadlineMs?: number } | { backend: "http"; deadlineMs?: number };
13
+ export interface WebConfig { webSearch?: ExaSearchConfig; webFetch?: WebFetchConfig }
7
14
  export interface ManagedConfig {
8
15
  version: 1;
16
+ limits?: { unattendedTurns?: number; mcpCallTimeoutMs?: number };
17
+ mcpServers?: Record<string, McpServer>;
9
18
  system: string;
10
19
  model: ManagedModel;
11
20
  defaultPolicy: string;
12
21
  timelineTools?: boolean;
22
+ webSearch?: ExaSearchConfig;
23
+ webFetch?: WebFetchConfig;
13
24
  policies: Record<string, ToolPolicy>;
14
25
  }
15
26
 
@@ -99,7 +99,7 @@ export interface TurnContext {
99
99
  * barrier resolves before the last cancellation check. */
100
100
  dispatchTool(call: ToolCall, execute: ExecuteTurnTool): Promise<{ content: string; dispatched: boolean;
101
101
  /** Decision 0021: recorded with the paired result of a dispatched call. */
102
- outcome?: import("./tools.ts").ToolOutcome }>;
102
+ outcome?: import("./tools.ts").ToolOutcome; usage?: import("./web.ts").WebResultUsage }>;
103
103
  /** Take pending inbox items (messages and notices) into this turn. */
104
104
  drainNotices?(): void;
105
105
  finish?(): boolean;
@@ -30,7 +30,7 @@ export interface ChannelEvent {
30
30
  revision?: number;
31
31
  event: (LoopEvent & { turnId: string; messageId?: string })
32
32
  | import("./model-execution.ts").ModelTextEvent
33
- | { type: "turn_started" | "turn_took"; turnId: string; items: string[]; messages?: { itemId: string; messageId: string; position: import("./operator-controls.ts").MessagePosition }[] }
33
+ | { type: "turn_started" | "turn_took"; turnId: string; items: string[]; messages?: { itemId: string; messageId: string; position: import("./operator-controls.ts").MessagePosition; parts?: import("./attachments.ts").AttachmentViewPart[] }[] }
34
34
  | { type: "items_receipt"; turnId: string; items: string[]; milestone: "delivered" | "seen" }
35
35
  | { type: "turn_suspended" | "turn_resumed"; turnId: string }
36
36
  | { type: "channel_state"; lifecycle: "open" | "suspending" | "suspended" | "retired"; displayName?: string; policy?: string }
@@ -38,7 +38,7 @@ export interface ChannelEvent {
38
38
  | (import("./reminders.ts").ReminderChannelEvent & { turnId?: never })
39
39
  | import("./operator-controls.ts").ApprovalClosedEvent
40
40
  | ({ type: "approval_requested" } & import("./config-permissions.ts").ApprovalRequest)
41
- | { type: "turn_ended"; turnId: string; outcome: "completed" | "failed" | "interrupted"; error?: string; uncertainCalls?: string[] };
41
+ | { type: "turn_ended"; turnId: string; outcome: "completed" | "failed" | "interrupted"; error?: string; uncertainCalls?: string[]; attachmentFailure?: import("./attachments.ts").AttachmentFailure };
42
42
  }
43
43
  export type EventSink = (event: ChannelEvent) => void;
44
44
 
@@ -7,9 +7,9 @@ export interface ToolCall {
7
7
 
8
8
  /** Neutral history. Provider state is opaque to the loop. */
9
9
  export type Message =
10
- | { role: "system" | "user"; content: string }
10
+ | { role: "system" | "user"; content: string; parts?: readonly import("./attachments.ts").InputPart[] }
11
11
  | { role: "assistant"; content: string | null; calls: ToolCall[]; providerState?: unknown }
12
- | { role: "tool"; content: string; callId: string; /** Decision 0021; absent means a legacy success. */ outcome?: import("./tools.ts").ToolOutcome };
12
+ | { role: "tool"; content: string; callId: string; /** Decision 0021; absent means a legacy success. */ outcome?: import("./tools.ts").ToolOutcome; usage?: import("./web.ts").WebResultUsage; webNoDispatch?: true };
13
13
 
14
14
  /** JSON schema describing the arguments accepted by a configured tool. */
15
15
  export interface ToolDefinition {
@@ -26,6 +26,6 @@ export type Model = (
26
26
 
27
27
  /** Executes only permitted tools; returns serialized successes or errors. Stop
28
28
  * aborts `signal`; a call already in flight may still have had its effect. */
29
- export interface ToolExecutionResult { content: string; outcome: import("./tools.ts").ToolOutcome }
29
+ export interface ToolExecutionResult { content: string; outcome: import("./tools.ts").ToolOutcome; usage?: import("./web.ts").WebResultUsage }
30
30
  export type ExecuteTool<Result = string> = (call: ToolCall, signal?: AbortSignal) => Promise<Result>;
31
31
  export type ExecuteTurnTool = ExecuteTool<string | ToolExecutionResult>;
@@ -0,0 +1,22 @@
1
+ /** Portable header declaration. Resolved material belongs to an executable open. */
2
+ export type McpHeader = { literal: string } | { env: string } | { runtime: true };
3
+ /** Trusted session configuration, validated without spawning or connecting. */
4
+ export type McpServer = { enabled?: boolean } & (
5
+ { transport: "stdio"; command: string; args: string[]; cwd?: string; env?: Record<string, { env: string }> }
6
+ | { transport: "http"; endpoint: string; headers?: Record<string, McpHeader> }
7
+ );
8
+ export type McpRuntimeHeaders = Record<string, Record<string, string>>;
9
+
10
+ export interface McpTool {
11
+ readonly definition: import("./loop.ts").ToolDefinition;
12
+ available(): boolean;
13
+ accepts(args: unknown): boolean;
14
+ call(args: Record<string, unknown>, signal: AbortSignal): Promise<{ content: string; code?: string }>;
15
+ }
16
+
17
+ /** Runtime-only observation. No transport diagnostics or credential values. */
18
+ export interface McpServerStatus {
19
+ transport: "stdio" | "http";
20
+ state: "ready" | "disabled" | "unavailable";
21
+ reason?: "config" | "spawn" | "connect" | "discovery" | "limit" | "closed";
22
+ }
@@ -29,7 +29,8 @@ export type ModelAttemptEvent =
29
29
  | { type: "text_delta"; text: string }
30
30
  | { type: "usage"; usage: ModelUsage }
31
31
  | { type: "response"; response: ModelResponse; providerRequestId?: string }
32
- | { type: "failure"; kind: "transient" | "invalid_request" | "invalid_config" | "provider"; message: string; providerRequestId?: string };
32
+ | { type: "failure"; kind: "transient" | "invalid_request" | "invalid_config" | "provider"; message: string; providerRequestId?: string;
33
+ code?: "unsupported_image" | "attachment_unavailable" | "transfer_limit"; attachmentIds?: readonly string[] };
33
34
  /** One attempt emits exactly one terminal response or failure unless aborted;
34
35
  * EOF without a terminal is incomplete. A consumer ignores events after the
35
36
  * first terminal, timeout or abort. The adapter assembles and validates tools. */
@@ -2,6 +2,7 @@ import type { ApprovalCloseReason, ApprovalRequest } from "./config-permissions.
2
2
  import type { ChannelChangeResult, ChannelStatusResult, ItemStatus, StoredMessage, PendingChannelChange, ProtocolConfig, TurnStatus } from "./protocol.ts";
3
3
 
4
4
  export interface OpenResult {
5
+ mcpServers?: Record<string, import("./mcp.ts").McpServerStatus>;
5
6
  sessionId: string;
6
7
  lifecycle: import("./storage.ts").SessionLifecycle;
7
8
  revision: number;
@@ -12,6 +13,8 @@ export interface OpenResult {
12
13
  nextDueAt?: string | null;
13
14
  reminderRevision?: number;
14
15
  unattendedTurnGuard?: { maxConsecutiveTurns: number } | null;
16
+ imageInput?: true;
17
+ imageLimits?: { formats: string[]; fileBytes: number; turnBytes: number; maxImages: number; maxSide: number; maxPixels: number };
15
18
  }
16
19
 
17
20
  export interface ChannelObservation {
@@ -23,7 +26,8 @@ export interface ChannelObservation {
23
26
 
24
27
  /** Ordered storage position scoped to a session and channel, distinct from message identity. */
25
28
  export type MessagePosition = string;
26
- export type ConversationMessage = (StoredMessage | {
29
+ type ParticipantMessage = { messageId: string; channel: string; turnId: string; parts: import("./attachments.ts").AttachmentViewPart[] };
30
+ export type ConversationMessage = (ParticipantMessage | {
27
31
  messageId: string; channel: string; turnId: string; omitted: true;
28
32
  }) & { position: MessagePosition; actor: { kind: "participant"; id: string }; itemId: string } |
29
33
  ((StoredMessage | { messageId: string; channel: string; turnId: string; omitted: true }) &
@@ -66,6 +70,8 @@ export interface OperatorMethods {
66
70
  }
67
71
 
68
72
  export interface LoadResultOpenParams {
73
+ /** Executable owning launcher material, never saved. */
74
+ mcpRuntimeHeaders?: import("./mcp.ts").McpRuntimeHeaders;
69
75
  sessionId: string;
70
76
  config?: ProtocolConfig;
71
77
  channelChanges?: PendingChannelChange[];
@@ -77,6 +83,7 @@ export interface LoadResultOpenParams {
77
83
  * Store adapters use the numeric bounds internally. Wire cursors are decoded
78
84
  * and checked by the protocol before invoking this port. */
79
85
  export interface OperatorStorageReads {
86
+ readManagedAttachment?(id: string): import("./storage.ts").StorageResult<{ metadata: import("./attachments.ts").AttachmentMetadata; timelineVisible: boolean } | undefined>;
80
87
  readChannel(channel: string): import("./storage.ts").StorageResult<{
81
88
  channel: Omit<import("./storage.ts").StoredChannel, "participantIds">;
82
89
  pendingCount: number;
@@ -18,13 +18,18 @@ export interface InitializeParams {
18
18
  }
19
19
  export interface ProtocolConfig {
20
20
  version: 1;
21
- limits?: { unattendedTurns: number };
21
+ limits?: import("./config-permissions.ts").ManagedConfig["limits"];
22
+ mcpServers?: Record<string, import("./mcp.ts").McpServer>;
22
23
  system: string;
23
24
  model: import("./config-permissions.ts").ManagedModel;
25
+ webSearch?: import("./config-permissions.ts").ExaSearchConfig;
26
+ webFetch?: import("./config-permissions.ts").WebFetchConfig;
24
27
  defaultPolicy?: string;
25
28
  policies?: Record<string, import("./config-permissions.ts").ToolPolicy>;
26
29
  }
27
30
  export interface CreateParams {
31
+ /** Executable owning launcher material, never saved. */
32
+ mcpRuntimeHeaders?: import("./mcp.ts").McpRuntimeHeaders;
28
33
  sessionId: string;
29
34
  config?: ProtocolConfig;
30
35
  reminderChanges?: import("./reminders.ts").ReminderChange[];
@@ -42,7 +47,7 @@ export interface NotifyParams {
42
47
  }
43
48
  export interface PushParams {
44
49
  channel: string;
45
- item: { id: string; kind: "user_message"; sender: string; content: { type: "text"; text: string }[]; policy?: string | null; delivery?: "queue"; wake?: true };
50
+ item: { id: string; kind: "user_message"; sender: string; content: import("./attachments.ts").InputPart[]; policy?: string | null; delivery?: "queue"; wake?: true };
46
51
  }
47
52
  export interface InitializeResult {
48
53
  protocolVersion: 1;
@@ -52,6 +57,7 @@ export interface InitializeResult {
52
57
 
53
58
  export interface Description {
54
59
  reminderLimits?: import("./reminders.ts").ReminderLimits;
60
+ attachmentLimits?: { fileBytes: number; chunkBytes: number; openUploads: number; uploadIdleMs: number };
55
61
  configOptions: unknown[]; commands: unknown[]; policies: string[];
56
62
  /** Advertise only implemented guarantees: `durable`/`true` are reported by a
57
63
  * server only once its acceptance commits to storage before acknowledging. */
@@ -61,7 +67,8 @@ export interface Description {
61
67
  * reject the field. */
62
68
  startupChannelChanges?: true;
63
69
  /** Decision 0021: tool catalogs, `functions/call` callbacks and invocation records. */
64
- functions?: true; reminders?: true; routines?: true; unattendedTurnGuard?: true };
70
+ mcpServers?: { stdio: boolean; http: boolean; sse: false };
71
+ functions?: true; reminders?: true; routines?: true; unattendedTurnGuard?: true; managedAttachments?: true; orderedParts?: true };
65
72
  }
66
73
 
67
74
  // ---- Channel changes applied at open, decision 0020.
@@ -101,7 +108,7 @@ export interface ChannelChangeResult {
101
108
  export type DurableErrorCode =
102
109
  | "item_conflict" | "not_running" | "stopped" | "invalid_state" | "incompatible"
103
110
  | "owner_conflict" | "not_found" | "already_exists" | "busy"
104
- | "invalid_archive" | "invalid_policy" | "transfer_limit" | "serialization_error" | "storage_failure"
111
+ | "invalid_archive" | "invalid_config" | "invalid_policy" | "transfer_limit" | "serialization_error" | "storage_failure"
105
112
  /** Decision 0014. The channel is suspending or suspended; a retry of accepted input still returns its recorded outcome. */
106
113
  | "channel_suspended"
107
114
  /** The channel ID was deleted; it is reserved for good. */
@@ -116,17 +123,20 @@ export interface ItemStatus {
116
123
  milestone: ItemMilestone; turnId?: string;
117
124
  policy?: import("./config-permissions.ts").ItemPolicy;
118
125
  externalSource?: string;
126
+ parts?: import("./attachments.ts").AttachmentViewPart[];
119
127
  }
120
128
  export interface TurnStatus {
121
129
  turnId: string; channel: string; items: string[];
122
130
  state: "running" | "suspended" | "completed" | "failed" | "interrupted";
123
131
  reason?: string;
132
+ attachmentFailure?: import("./attachments.ts").AttachmentFailure;
124
133
  /** Recorded calls with no recorded result; never replayed by the harness. */
125
134
  uncertainCalls?: string[];
126
135
  }
127
136
  /** `idle`, `suspended` and unresolved interrupted work are distinguishable:
128
137
  * see SessionStatus in the session contract for the exact derivation. */
129
138
  export interface StatusResult {
139
+ mcpServers?: Record<string, import("./mcp.ts").McpServerStatus>;
130
140
  sessionId: string; revision: number;
131
141
  lifecycle: "running" | "suspending" | "suspended";
132
142
  execution: "idle" | "working" | "suspending" | "suspended" | "stopped" | "incompatible";
@@ -171,6 +181,12 @@ export interface TransferLimits { chunkBytes: 524288; maxBytes: 268435456; idleM
171
181
  export type ArchiveLocation = { type: "path"; path: string } | { type: "transfer" };
172
182
 
173
183
  export interface DurableMethods extends ModelExecutionMethods, ReminderMethods, Omit<OperatorMethods, "session/create"> {
184
+ "attachment/begin": { params: { channel: string; filename: string; mediaType: string; bytes: number; sha256: string }; result: { uploadId: string; attachmentId: string; offset: number } };
185
+ "attachment/status": { params: { channel: string; uploadId: string }; result: { offset: number } };
186
+ "attachment/write": { params: { channel: string; uploadId: string; offset: number; data: string }; result: { offset: number } };
187
+ "attachment/finalize": { params: { channel: string; uploadId: string }; result: import("./attachments.ts").AttachmentMetadata };
188
+ "attachment/abort": { params: { channel: string; uploadId: string }; result: Record<string, never> };
189
+ "attachment/read": { params: { channel: string; id: string; offset: number }; result: { metadata: import("./attachments.ts").AttachmentMetadata; data: string; nextOffset?: number } };
174
190
  /** Open an existing session with runtime configuration. Returns the load
175
191
  * view; a second load on the same endpoint returns a fresh view only.
176
192
  * `channelChanges` (decision 0020) is validated as a whole, then applied
@@ -269,7 +285,7 @@ export interface Methods {
269
285
  }
270
286
  export interface RpcRequest { jsonrpc: "2.0"; id: number; method: string; params: unknown }
271
287
  export type RpcResponse = { jsonrpc: "2.0"; id: number; result: unknown } |
272
- { jsonrpc: "2.0"; id: number | null; error: { code: number; message: string; data: { code: string } } };
288
+ { jsonrpc: "2.0"; id: number | null; error: { code: number; message: string; data: { code: string; expectedOffset?: number } } };
273
289
  export interface RpcNotification { jsonrpc: "2.0"; method: "channel/event"; params: ChannelEvent }
274
290
  // ---- Requests from the harness to the host, decision 0021. IDs are numeric,
275
291
  // per connection, and separate from the IDs of host requests: direction tells
@@ -125,8 +125,10 @@ export interface ReminderClock {
125
125
 
126
126
  /** Portable reminder state in logical archive 6. High water is derived from retained receipts. */
127
127
  export interface ReminderArchiveState {
128
- rows: Array<{ sequence: number; reminder: OneOffReminder; original?: string; defaultedExpiry: boolean }>;
129
- receipts: Array<{ fingerprint: string; result: OneOffReminderChangeResult }>;
128
+ dispositions?: Array<Extract<ReminderChannelEvent, { type: "routine_disposition" | "routine_migration_blocked" }>>;
129
+ guard?: { limit: number; counters: Array<{ channel: string; spent: number }> };
130
+ rows: Array<{ sequence: number; reminder: Reminder; processedThrough?: number; episodeCutoff?: number; coalescedPending?: number; original?: string; defaultedExpiry: boolean }>;
131
+ receipts: Array<{ fingerprint: string; result: ReminderChangeResult }>;
130
132
  listingRevision: number;
131
133
  wake: ReminderWake;
132
134
  }
@@ -0,0 +1,20 @@
1
+ /** Decision 0032. Interval durations are integer milliseconds. */
2
+ export type RoutineEnd = { count: number; until?: never } | { until: string; count?: never }
3
+ | { until?: never; count?: never };
4
+ export type IntervalRoutineSchedule = { every: number; startAt?: string } & RoutineEnd;
5
+ export type CalendarRoutineSchedule = { cron: string; timezone: string } & RoutineEnd;
6
+ export type RoutineSchedule = IntervalRoutineSchedule | CalendarRoutineSchedule;
7
+
8
+ export interface RoutineDeliveryOptions {
9
+ missedRuns?: "coalesce" | "skip" | "each";
10
+ overlap?: "skip" | "queue";
11
+ }
12
+
13
+ /** Rank and selection over concrete UTC instants, after applying the
14
+ * schedule's anchor and end. An ordinal is zero-based. A rank is inclusive. */
15
+ export interface RoutineCalendar {
16
+ at(ordinal: number): number | undefined;
17
+ rank(through: number): number;
18
+ /** Successor from the same schedule, ignoring count and until. */
19
+ nextCalendarMatch(instant: number): number | undefined;
20
+ }
@@ -3,6 +3,8 @@
3
3
  * embedded or required to exist during import. */
4
4
  export interface PortableSessionConfig {
5
5
  version: 1;
6
+ limits?: import("./config-permissions.ts").ManagedConfig["limits"];
7
+ mcpServers?: Record<string, import("./mcp.ts").McpServer>;
6
8
  system: string;
7
9
  model: import("./config-permissions.ts").ManagedModel;
8
10
  /** Present on session files produced after decision 0016. */
@@ -89,6 +89,11 @@ export interface PersistentSessionOptions {
89
89
  reminderClock?: import("./reminders.ts").ReminderClock;
90
90
  /** Local opt-in when there is no managed configuration. */
91
91
  timelineTools?: boolean;
92
+ /** Trusted assembly has verified the opted-in model and image validator. */
93
+ imageInput?: boolean;
94
+ /** Local web implementations created by trusted session assembly. */
95
+ mcpTools?: ReadonlyMap<string, import("./mcp.ts").McpTool>;
96
+ webTools?: readonly import("./web.ts").CheckedWebRegistration[];
92
97
  systemPrompt: string;
93
98
  /** Optional assertion of the storage owner's validated config. Omission uses
94
99
  * the owner snapshot; legacy allow applies only when that snapshot is absent. */
@@ -113,8 +118,8 @@ export interface PersistentSessionOptions {
113
118
  /** Creating the session executes nothing: it can be inspected, loaded and
114
119
  * exported first. Opening, starting and resuming are separate actions. */
115
120
  export interface PersistentSession {
116
- reminders?: Pick<SessionStorage, "readReminder" | "listReminders" | "reminderWake"> & {
117
- change(change: import("./reminders.ts").OneOffReminderChange): ReturnType<SessionStorage["changeReminder"]>;
121
+ reminders?: Pick<SessionStorage, "readReminder" | "listReminders" | "reminderWake" | "unattendedGuard"> & {
122
+ change(change: import("./reminders.ts").ReminderChange): ReturnType<SessionStorage["changeReminder"]>;
118
123
  processStartup(): void;
119
124
  releaseTimer(): void;
120
125
  executable(): boolean;
@@ -123,7 +128,7 @@ export interface PersistentSession {
123
128
  };
124
129
  /** Read an oldest-first page of complete model-call summaries. */
125
130
  readModelCalls: SessionStorage["readCalls"];
126
- operatorReads?: Pick<SessionStorage, "readSession" | "readExecution" | "readChannel" | "readTracked" | "readTimeline">;
131
+ operatorReads?: Pick<SessionStorage, "readSession" | "readExecution" | "readChannel" | "readTracked" | "readTimeline"> & Partial<Pick<SessionStorage, "readManagedAttachment">>;
127
132
  turnPhase?(turnId: number): import("./tools.ts").TurnPhase | undefined;
128
133
  /** Approval requests belong to this connection; disconnect closes them. */
129
134
  approvals: {