@chipschat/protocol 0.0.0-stage → 1.0.0

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 (423) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +56 -2
  3. package/dist/envelope.d.ts +54 -0
  4. package/dist/envelope.d.ts.map +1 -0
  5. package/dist/envelope.js +48 -0
  6. package/dist/envelope.js.map +1 -0
  7. package/dist/events/agent-to-chips.d.ts +27 -0
  8. package/dist/events/agent-to-chips.d.ts.map +1 -0
  9. package/dist/events/agent-to-chips.js +392 -0
  10. package/dist/events/agent-to-chips.js.map +1 -0
  11. package/dist/events/catalogue.d.ts +48 -0
  12. package/dist/events/catalogue.d.ts.map +1 -0
  13. package/dist/events/catalogue.js +67 -0
  14. package/dist/events/catalogue.js.map +1 -0
  15. package/dist/events/chips-to-agent.d.ts +24 -0
  16. package/dist/events/chips-to-agent.d.ts.map +1 -0
  17. package/dist/events/chips-to-agent.js +324 -0
  18. package/dist/events/chips-to-agent.js.map +1 -0
  19. package/dist/events/chips-to-harness.d.ts +24 -0
  20. package/dist/events/chips-to-harness.d.ts.map +1 -0
  21. package/dist/events/chips-to-harness.js +324 -0
  22. package/dist/events/chips-to-harness.js.map +1 -0
  23. package/dist/events/harness-to-chips.d.ts +27 -0
  24. package/dist/events/harness-to-chips.d.ts.map +1 -0
  25. package/dist/events/harness-to-chips.js +390 -0
  26. package/dist/events/harness-to-chips.js.map +1 -0
  27. package/dist/events/index.d.ts +6 -0
  28. package/dist/events/index.d.ts.map +1 -0
  29. package/dist/events/index.js +5 -0
  30. package/dist/events/index.js.map +1 -0
  31. package/dist/events/workspace.d.ts +19 -0
  32. package/dist/events/workspace.d.ts.map +1 -0
  33. package/dist/events/workspace.js +79 -0
  34. package/dist/events/workspace.js.map +1 -0
  35. package/dist/frames.d.ts +175 -0
  36. package/dist/frames.d.ts.map +1 -0
  37. package/dist/frames.js +161 -0
  38. package/dist/frames.js.map +1 -0
  39. package/dist/generated/types.d.ts +4052 -0
  40. package/dist/generated/types.d.ts.map +1 -0
  41. package/dist/generated/types.js +7 -0
  42. package/dist/generated/types.js.map +1 -0
  43. package/dist/ids/index.d.ts +3 -0
  44. package/dist/ids/index.d.ts.map +1 -0
  45. package/dist/ids/index.js +2 -0
  46. package/dist/ids/index.js.map +1 -0
  47. package/dist/ids/ulid.d.ts +83 -0
  48. package/dist/ids/ulid.d.ts.map +1 -0
  49. package/dist/ids/ulid.js +199 -0
  50. package/dist/ids/ulid.js.map +1 -0
  51. package/dist/index.d.ts +18 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +13 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/primitives.d.ts +194 -0
  56. package/dist/primitives.d.ts.map +1 -0
  57. package/dist/primitives.js +193 -0
  58. package/dist/primitives.js.map +1 -0
  59. package/dist/src/address.d.ts +106 -0
  60. package/dist/src/address.d.ts.map +1 -0
  61. package/dist/src/address.js +141 -0
  62. package/dist/src/address.js.map +1 -0
  63. package/dist/src/agent-context-windows.d.ts +235 -0
  64. package/dist/src/agent-context-windows.d.ts.map +1 -0
  65. package/dist/src/agent-context-windows.js +213 -0
  66. package/dist/src/agent-context-windows.js.map +1 -0
  67. package/dist/src/agent-heartbeats.d.ts +106 -0
  68. package/dist/src/agent-heartbeats.d.ts.map +1 -0
  69. package/dist/src/agent-heartbeats.js +111 -0
  70. package/dist/src/agent-heartbeats.js.map +1 -0
  71. package/dist/src/agent-models.d.ts +158 -0
  72. package/dist/src/agent-models.d.ts.map +1 -0
  73. package/dist/src/agent-models.js +171 -0
  74. package/dist/src/agent-models.js.map +1 -0
  75. package/dist/src/agent-place.d.ts +76 -0
  76. package/dist/src/agent-place.d.ts.map +1 -0
  77. package/dist/src/agent-place.js +80 -0
  78. package/dist/src/agent-place.js.map +1 -0
  79. package/dist/src/agents.d.ts +24 -0
  80. package/dist/src/agents.d.ts.map +1 -0
  81. package/dist/src/agents.js +58 -0
  82. package/dist/src/agents.js.map +1 -0
  83. package/dist/src/capabilities.d.ts +121 -0
  84. package/dist/src/capabilities.d.ts.map +1 -0
  85. package/dist/src/capabilities.js +120 -0
  86. package/dist/src/capabilities.js.map +1 -0
  87. package/dist/src/checklist.d.ts +19 -0
  88. package/dist/src/checklist.d.ts.map +1 -0
  89. package/dist/src/checklist.js +22 -0
  90. package/dist/src/checklist.js.map +1 -0
  91. package/dist/src/commands.d.ts +50 -0
  92. package/dist/src/commands.d.ts.map +1 -0
  93. package/dist/src/commands.js +274 -0
  94. package/dist/src/commands.js.map +1 -0
  95. package/dist/src/connectors.d.ts +90 -0
  96. package/dist/src/connectors.d.ts.map +1 -0
  97. package/dist/src/connectors.js +119 -0
  98. package/dist/src/connectors.js.map +1 -0
  99. package/dist/src/context-files.d.ts +304 -0
  100. package/dist/src/context-files.d.ts.map +1 -0
  101. package/dist/src/context-files.js +247 -0
  102. package/dist/src/context-files.js.map +1 -0
  103. package/dist/src/context.d.ts +369 -0
  104. package/dist/src/context.d.ts.map +1 -0
  105. package/dist/src/context.js +526 -0
  106. package/dist/src/context.js.map +1 -0
  107. package/dist/src/direct-asks.d.ts +36 -0
  108. package/dist/src/direct-asks.d.ts.map +1 -0
  109. package/dist/src/direct-asks.js +43 -0
  110. package/dist/src/direct-asks.js.map +1 -0
  111. package/dist/src/envelope.d.ts +70 -0
  112. package/dist/src/envelope.d.ts.map +1 -0
  113. package/dist/src/envelope.js +46 -0
  114. package/dist/src/envelope.js.map +1 -0
  115. package/dist/src/events/catalogue.d.ts +50 -0
  116. package/dist/src/events/catalogue.d.ts.map +1 -0
  117. package/dist/src/events/catalogue.js +70 -0
  118. package/dist/src/events/catalogue.js.map +1 -0
  119. package/dist/src/events/chips-to-harness.d.ts +37 -0
  120. package/dist/src/events/chips-to-harness.d.ts.map +1 -0
  121. package/dist/src/events/chips-to-harness.js +511 -0
  122. package/dist/src/events/chips-to-harness.js.map +1 -0
  123. package/dist/src/events/harness-to-chips.d.ts +38 -0
  124. package/dist/src/events/harness-to-chips.d.ts.map +1 -0
  125. package/dist/src/events/harness-to-chips.js +593 -0
  126. package/dist/src/events/harness-to-chips.js.map +1 -0
  127. package/dist/src/events/index.d.ts +6 -0
  128. package/dist/src/events/index.d.ts.map +1 -0
  129. package/dist/src/events/index.js +5 -0
  130. package/dist/src/events/index.js.map +1 -0
  131. package/dist/src/events/workspace.d.ts +222 -0
  132. package/dist/src/events/workspace.d.ts.map +1 -0
  133. package/dist/src/events/workspace.js +1039 -0
  134. package/dist/src/events/workspace.js.map +1 -0
  135. package/dist/src/exchange.d.ts +262 -0
  136. package/dist/src/exchange.d.ts.map +1 -0
  137. package/dist/src/exchange.js +413 -0
  138. package/dist/src/exchange.js.map +1 -0
  139. package/dist/src/first-names.d.ts +29 -0
  140. package/dist/src/first-names.d.ts.map +1 -0
  141. package/dist/src/first-names.js +80 -0
  142. package/dist/src/first-names.js.map +1 -0
  143. package/dist/src/frames.d.ts +526 -0
  144. package/dist/src/frames.d.ts.map +1 -0
  145. package/dist/src/frames.js +346 -0
  146. package/dist/src/frames.js.map +1 -0
  147. package/dist/src/harness-jobs.d.ts +313 -0
  148. package/dist/src/harness-jobs.d.ts.map +1 -0
  149. package/dist/src/harness-jobs.js +210 -0
  150. package/dist/src/harness-jobs.js.map +1 -0
  151. package/dist/src/ids/index.d.ts +3 -0
  152. package/dist/src/ids/index.d.ts.map +1 -0
  153. package/dist/src/ids/index.js +2 -0
  154. package/dist/src/ids/index.js.map +1 -0
  155. package/dist/src/ids/ulid.d.ts +96 -0
  156. package/dist/src/ids/ulid.d.ts.map +1 -0
  157. package/dist/src/ids/ulid.js +212 -0
  158. package/dist/src/ids/ulid.js.map +1 -0
  159. package/dist/src/index.d.ts +81 -0
  160. package/dist/src/index.d.ts.map +1 -0
  161. package/dist/src/index.js +47 -0
  162. package/dist/src/index.js.map +1 -0
  163. package/dist/src/invite-link.d.ts +64 -0
  164. package/dist/src/invite-link.d.ts.map +1 -0
  165. package/dist/src/invite-link.js +99 -0
  166. package/dist/src/invite-link.js.map +1 -0
  167. package/dist/src/join.d.ts +188 -0
  168. package/dist/src/join.d.ts.map +1 -0
  169. package/dist/src/join.js +190 -0
  170. package/dist/src/join.js.map +1 -0
  171. package/dist/src/limits.d.ts +50 -0
  172. package/dist/src/limits.d.ts.map +1 -0
  173. package/dist/src/limits.js +106 -0
  174. package/dist/src/limits.js.map +1 -0
  175. package/dist/src/matters.d.ts +22 -0
  176. package/dist/src/matters.d.ts.map +1 -0
  177. package/dist/src/matters.js +26 -0
  178. package/dist/src/matters.js.map +1 -0
  179. package/dist/src/mentions.d.ts +63 -0
  180. package/dist/src/mentions.d.ts.map +1 -0
  181. package/dist/src/mentions.js +129 -0
  182. package/dist/src/mentions.js.map +1 -0
  183. package/dist/src/names.d.ts +58 -0
  184. package/dist/src/names.d.ts.map +1 -0
  185. package/dist/src/names.js +192 -0
  186. package/dist/src/names.js.map +1 -0
  187. package/dist/src/no-reply.d.ts +17 -0
  188. package/dist/src/no-reply.d.ts.map +1 -0
  189. package/dist/src/no-reply.js +48 -0
  190. package/dist/src/no-reply.js.map +1 -0
  191. package/dist/src/notifications.d.ts +81 -0
  192. package/dist/src/notifications.d.ts.map +1 -0
  193. package/dist/src/notifications.js +65 -0
  194. package/dist/src/notifications.js.map +1 -0
  195. package/dist/src/pages.d.ts +32 -0
  196. package/dist/src/pages.d.ts.map +1 -0
  197. package/dist/src/pages.js +32 -0
  198. package/dist/src/pages.js.map +1 -0
  199. package/dist/src/pairing.d.ts +99 -0
  200. package/dist/src/pairing.d.ts.map +1 -0
  201. package/dist/src/pairing.js +163 -0
  202. package/dist/src/pairing.js.map +1 -0
  203. package/dist/src/primitives.d.ts +267 -0
  204. package/dist/src/primitives.d.ts.map +1 -0
  205. package/dist/src/primitives.js +279 -0
  206. package/dist/src/primitives.js.map +1 -0
  207. package/dist/src/project.d.ts +335 -0
  208. package/dist/src/project.d.ts.map +1 -0
  209. package/dist/src/project.js +499 -0
  210. package/dist/src/project.js.map +1 -0
  211. package/dist/src/ranges.d.ts +31 -0
  212. package/dist/src/ranges.d.ts.map +1 -0
  213. package/dist/src/ranges.js +51 -0
  214. package/dist/src/ranges.js.map +1 -0
  215. package/dist/src/relay.d.ts +177 -0
  216. package/dist/src/relay.d.ts.map +1 -0
  217. package/dist/src/relay.js +147 -0
  218. package/dist/src/relay.js.map +1 -0
  219. package/dist/src/room-files.d.ts +146 -0
  220. package/dist/src/room-files.d.ts.map +1 -0
  221. package/dist/src/room-files.js +135 -0
  222. package/dist/src/room-files.js.map +1 -0
  223. package/dist/src/room-note.d.ts +213 -0
  224. package/dist/src/room-note.d.ts.map +1 -0
  225. package/dist/src/room-note.js +457 -0
  226. package/dist/src/room-note.js.map +1 -0
  227. package/dist/src/space-icons.d.ts +68 -0
  228. package/dist/src/space-icons.d.ts.map +1 -0
  229. package/dist/src/space-icons.js +142 -0
  230. package/dist/src/space-icons.js.map +1 -0
  231. package/dist/src/spend.d.ts +57 -0
  232. package/dist/src/spend.d.ts.map +1 -0
  233. package/dist/src/spend.js +94 -0
  234. package/dist/src/spend.js.map +1 -0
  235. package/dist/src/visibility.d.ts +170 -0
  236. package/dist/src/visibility.d.ts.map +1 -0
  237. package/dist/src/visibility.js +218 -0
  238. package/dist/src/visibility.js.map +1 -0
  239. package/fixtures/agent.asked.json +15 -0
  240. package/fixtures/agent.attached.json +15 -0
  241. package/fixtures/agent.deleted.json +16 -0
  242. package/fixtures/agent.fork.json +14 -0
  243. package/fixtures/agent.lock_set.json +13 -0
  244. package/fixtures/agent.registered.json +17 -0
  245. package/fixtures/agent.released.json +16 -0
  246. package/fixtures/agent.updated.json +14 -0
  247. package/fixtures/approval.executed.json +16 -0
  248. package/fixtures/approval.request.json +45 -0
  249. package/fixtures/approval.resolved.json +20 -0
  250. package/fixtures/approval.routed.json +20 -0
  251. package/fixtures/artifact.create.json +18 -0
  252. package/fixtures/attachment.fetched.json +15 -0
  253. package/fixtures/attachment.limits_set.json +15 -0
  254. package/fixtures/budget.warning.json +20 -0
  255. package/fixtures/checkpoint.json +16 -0
  256. package/fixtures/context.compacted.json +16 -0
  257. package/fixtures/context.usage.json +17 -0
  258. package/fixtures/exchange.limits_set.json +15 -0
  259. package/fixtures/exchange.set.json +13 -0
  260. package/fixtures/feedback.json +21 -0
  261. package/fixtures/frames/ack.json +6 -0
  262. package/fixtures/frames/context.edit.json +11 -0
  263. package/fixtures/frames/context_window.change.json +9 -0
  264. package/fixtures/frames/context_window.compact.json +8 -0
  265. package/fixtures/frames/error.json +6 -0
  266. package/fixtures/frames/event.json +20 -0
  267. package/fixtures/frames/events.json +39 -0
  268. package/fixtures/frames/folder.open.json +6 -0
  269. package/fixtures/frames/folder.open.page.json +7 -0
  270. package/fixtures/frames/folder.run.json +8 -0
  271. package/fixtures/frames/folder.run_state.json +12 -0
  272. package/fixtures/frames/heartbeat.change.json +10 -0
  273. package/fixtures/frames/hello.json +18 -0
  274. package/fixtures/frames/job.change.json +9 -0
  275. package/fixtures/frames/join.json +19 -0
  276. package/fixtures/frames/model.change.json +10 -0
  277. package/fixtures/frames/ping.json +4 -0
  278. package/fixtures/frames/pong.json +4 -0
  279. package/fixtures/frames/presence.json +12 -0
  280. package/fixtures/frames/receipt.json +5 -0
  281. package/fixtures/frames/restart.json +5 -0
  282. package/fixtures/frames/subscribe.json +6 -0
  283. package/fixtures/handoff.json +20 -0
  284. package/fixtures/harness.removed.json +15 -0
  285. package/fixtures/harness.transferred.json +15 -0
  286. package/fixtures/hello.json +61 -0
  287. package/fixtures/join.allowed.json +20 -0
  288. package/fixtures/join.denied.json +17 -0
  289. package/fixtures/lane.updated.json +17 -0
  290. package/fixtures/membership.added.json +16 -0
  291. package/fixtures/membership.removed.json +14 -0
  292. package/fixtures/membership.replaced.json +15 -0
  293. package/fixtures/message.deleted.json +15 -0
  294. package/fixtures/message.edited.json +15 -0
  295. package/fixtures/message.handed.json +14 -0
  296. package/fixtures/message.heard.json +14 -0
  297. package/fixtures/message.held.json +14 -0
  298. package/fixtures/message.hidden.json +14 -0
  299. package/fixtures/message.new.json +96 -0
  300. package/fixtures/message.overheard.json +22 -0
  301. package/fixtures/message.pinned.json +14 -0
  302. package/fixtures/message.post.json +14 -0
  303. package/fixtures/message.shown.json +14 -0
  304. package/fixtures/message.unpinned.json +14 -0
  305. package/fixtures/person.face_set.json +17 -0
  306. package/fixtures/person.joined.json +16 -0
  307. package/fixtures/person.removed.json +16 -0
  308. package/fixtures/person.renamed.json +14 -0
  309. package/fixtures/policy.updated.json +30 -0
  310. package/fixtures/project.changed.json +21 -0
  311. package/fixtures/question.answered.json +23 -0
  312. package/fixtures/question.ask.json +37 -0
  313. package/fixtures/receipt.json +15 -0
  314. package/fixtures/relay.set.json +12 -0
  315. package/fixtures/role.changed.json +15 -0
  316. package/fixtures/run.cancel.json +15 -0
  317. package/fixtures/run.completed.json +20 -0
  318. package/fixtures/run.failed.json +20 -0
  319. package/fixtures/run.pause.json +15 -0
  320. package/fixtures/run.plan.json +24 -0
  321. package/fixtures/run.requested.json +34 -0
  322. package/fixtures/run.resume.json +15 -0
  323. package/fixtures/run.started.json +33 -0
  324. package/fixtures/run.status.json +17 -0
  325. package/fixtures/run.steer.json +21 -0
  326. package/fixtures/session.ended.json +15 -0
  327. package/fixtures/session.renamed.json +15 -0
  328. package/fixtures/session.started.json +17 -0
  329. package/fixtures/space.claimed.json +15 -0
  330. package/fixtures/space.created.json +14 -0
  331. package/fixtures/space.erased.json +13 -0
  332. package/fixtures/space.lead_set.json +13 -0
  333. package/fixtures/space.lock_set.json +13 -0
  334. package/fixtures/space.spend_ceiling_set.json +13 -0
  335. package/fixtures/space.updated.json +14 -0
  336. package/fixtures/step.log.json +26 -0
  337. package/fixtures/task.json +22 -0
  338. package/fixtures/turn.passed.json +14 -0
  339. package/fixtures/usage.json +21 -0
  340. package/fixtures/workspace.renamed.json +13 -0
  341. package/generated/agent-connect.json +13966 -0
  342. package/generated/schema/agent.asked.json +114 -0
  343. package/generated/schema/agent.attached.json +465 -0
  344. package/generated/schema/agent.deleted.json +127 -0
  345. package/generated/schema/agent.fork.json +107 -0
  346. package/generated/schema/agent.lock_set.json +105 -0
  347. package/generated/schema/agent.registered.json +130 -0
  348. package/generated/schema/agent.released.json +129 -0
  349. package/generated/schema/agent.updated.json +151 -0
  350. package/generated/schema/approval.executed.json +125 -0
  351. package/generated/schema/approval.request.json +279 -0
  352. package/generated/schema/approval.resolved.json +162 -0
  353. package/generated/schema/approval.routed.json +185 -0
  354. package/generated/schema/artifact.create.json +206 -0
  355. package/generated/schema/attachment.fetched.json +114 -0
  356. package/generated/schema/attachment.limits_set.json +136 -0
  357. package/generated/schema/budget.warning.json +152 -0
  358. package/generated/schema/checkpoint.json +111 -0
  359. package/generated/schema/context.compacted.json +124 -0
  360. package/generated/schema/context.usage.json +120 -0
  361. package/generated/schema/exchange.limits_set.json +127 -0
  362. package/generated/schema/exchange.set.json +144 -0
  363. package/generated/schema/feedback.json +173 -0
  364. package/generated/schema/handoff.json +122 -0
  365. package/generated/schema/harness.removed.json +122 -0
  366. package/generated/schema/harness.transferred.json +117 -0
  367. package/generated/schema/hello.json +509 -0
  368. package/generated/schema/join.allowed.json +176 -0
  369. package/generated/schema/join.denied.json +150 -0
  370. package/generated/schema/lane.updated.json +223 -0
  371. package/generated/schema/membership.added.json +153 -0
  372. package/generated/schema/membership.removed.json +126 -0
  373. package/generated/schema/membership.replaced.json +106 -0
  374. package/generated/schema/message.deleted.json +105 -0
  375. package/generated/schema/message.edited.json +107 -0
  376. package/generated/schema/message.handed.json +111 -0
  377. package/generated/schema/message.heard.json +100 -0
  378. package/generated/schema/message.held.json +181 -0
  379. package/generated/schema/message.hidden.json +100 -0
  380. package/generated/schema/message.new.json +1369 -0
  381. package/generated/schema/message.overheard.json +701 -0
  382. package/generated/schema/message.pinned.json +100 -0
  383. package/generated/schema/message.post.json +290 -0
  384. package/generated/schema/message.shown.json +100 -0
  385. package/generated/schema/message.unpinned.json +100 -0
  386. package/generated/schema/person.face_set.json +134 -0
  387. package/generated/schema/person.joined.json +128 -0
  388. package/generated/schema/person.removed.json +133 -0
  389. package/generated/schema/person.renamed.json +114 -0
  390. package/generated/schema/policy.updated.json +277 -0
  391. package/generated/schema/project.changed.json +199 -0
  392. package/generated/schema/question.answered.json +154 -0
  393. package/generated/schema/question.ask.json +194 -0
  394. package/generated/schema/receipt.json +109 -0
  395. package/generated/schema/relay.set.json +99 -0
  396. package/generated/schema/role.changed.json +116 -0
  397. package/generated/schema/run.cancel.json +106 -0
  398. package/generated/schema/run.completed.json +139 -0
  399. package/generated/schema/run.failed.json +135 -0
  400. package/generated/schema/run.pause.json +106 -0
  401. package/generated/schema/run.plan.json +128 -0
  402. package/generated/schema/run.requested.json +309 -0
  403. package/generated/schema/run.resume.json +106 -0
  404. package/generated/schema/run.started.json +142 -0
  405. package/generated/schema/run.status.json +120 -0
  406. package/generated/schema/run.steer.json +163 -0
  407. package/generated/schema/session.ended.json +106 -0
  408. package/generated/schema/session.renamed.json +108 -0
  409. package/generated/schema/session.started.json +116 -0
  410. package/generated/schema/space.claimed.json +107 -0
  411. package/generated/schema/space.created.json +148 -0
  412. package/generated/schema/space.erased.json +129 -0
  413. package/generated/schema/space.lead_set.json +108 -0
  414. package/generated/schema/space.lock_set.json +99 -0
  415. package/generated/schema/space.spend_ceiling_set.json +102 -0
  416. package/generated/schema/space.updated.json +112 -0
  417. package/generated/schema/step.log.json +187 -0
  418. package/generated/schema/task.json +268 -0
  419. package/generated/schema/turn.passed.json +99 -0
  420. package/generated/schema/usage.json +155 -0
  421. package/generated/schema/workspace.renamed.json +107 -0
  422. package/generated/types.ts +4178 -0
  423. package/package.json +37 -3
@@ -0,0 +1,194 @@
1
+ /**
2
+ * The sub-schemas events are built from. Each one exists because more than one event needs
3
+ * it, and each carries a description, because those descriptions become the documentation
4
+ * reference (technical-plan decision 13).
5
+ */
6
+ import { z } from "zod";
7
+ import { type IdKind } from "./ids/index.js";
8
+ /** A schema for one kind of prefixed ULID, for example `run_01K4...` (decision 11). */
9
+ export declare function id<K extends IdKind>(kind: K): z.ZodString;
10
+ export declare const isoTimestamp: z.ZodISODateTime;
11
+ /** Who caused an event. Every envelope says so; the audit log is a read of this field. */
12
+ export declare const actor: z.ZodObject<{
13
+ kind: z.ZodEnum<{
14
+ person: "person";
15
+ agent: "agent";
16
+ system: "system";
17
+ }>;
18
+ id: z.ZodString;
19
+ }, z.core.$strip>;
20
+ export type Actor = z.infer<typeof actor>;
21
+ /** A person or agent as another party sees them, with the role Chips assigns. */
22
+ export declare const participantRef: z.ZodObject<{
23
+ participant_id: z.ZodString;
24
+ kind: z.ZodEnum<{
25
+ person: "person";
26
+ agent: "agent";
27
+ }>;
28
+ display_name: z.ZodString;
29
+ role: z.ZodEnum<{
30
+ owner: "owner";
31
+ member: "member";
32
+ guest: "guest";
33
+ }>;
34
+ }, z.core.$strip>;
35
+ export type ParticipantRef = z.infer<typeof participantRef>;
36
+ /**
37
+ * An attachment. Anything you can send a person you can send an agent, so this shape carries
38
+ * files, images, video and voice notes alike (decision 10).
39
+ */
40
+ export declare const attachment: z.ZodObject<{
41
+ attachment_id: z.ZodString;
42
+ filename: z.ZodString;
43
+ mime_type: z.ZodString;
44
+ byte_size: z.ZodInt;
45
+ sha256: z.ZodString;
46
+ width: z.ZodOptional<z.ZodInt>;
47
+ height: z.ZodOptional<z.ZodInt>;
48
+ duration_ms: z.ZodOptional<z.ZodInt>;
49
+ }, z.core.$strip>;
50
+ export type Attachment = z.infer<typeof attachment>;
51
+ /** An attachment as it reaches an agent: with a URL it can actually fetch. */
52
+ export declare const signedAttachment: z.ZodObject<{
53
+ attachment_id: z.ZodString;
54
+ filename: z.ZodString;
55
+ mime_type: z.ZodString;
56
+ byte_size: z.ZodInt;
57
+ sha256: z.ZodString;
58
+ width: z.ZodOptional<z.ZodInt>;
59
+ height: z.ZodOptional<z.ZodInt>;
60
+ duration_ms: z.ZodOptional<z.ZodInt>;
61
+ url: z.ZodURL;
62
+ url_expires_at: z.ZodISODateTime;
63
+ }, z.core.$strip>;
64
+ export type SignedAttachment = z.infer<typeof signedAttachment>;
65
+ /** Where a claim came from. External sources are what make an action risky. */
66
+ export declare const source: z.ZodObject<{
67
+ kind: z.ZodEnum<{
68
+ external: "external";
69
+ internal: "internal";
70
+ }>;
71
+ label: z.ZodString;
72
+ url: z.ZodOptional<z.ZodURL>;
73
+ }, z.core.$strip>;
74
+ export type Source = z.infer<typeof source>;
75
+ /**
76
+ * Risk classes. These are the flags the policy engine matches on (decision 8), so the list is
77
+ * closed: a new class is a protocol change, not a free-text string an agent invents.
78
+ */
79
+ export declare const riskClass: z.ZodEnum<{
80
+ external: "external";
81
+ external_communication: "external_communication";
82
+ irreversible: "irreversible";
83
+ destructive: "destructive";
84
+ financial: "financial";
85
+ credential: "credential";
86
+ privacy: "privacy";
87
+ legal: "legal";
88
+ }>;
89
+ export type RiskClass = z.infer<typeof riskClass>;
90
+ /** The action an agent wants to take. `kind` is what policy rules glob against. */
91
+ export declare const action: z.ZodObject<{
92
+ kind: z.ZodString;
93
+ input: z.ZodOptional<z.ZodUnknown>;
94
+ external: z.ZodOptional<z.ZodBoolean>;
95
+ irreversible: z.ZodOptional<z.ZodBoolean>;
96
+ money_usd: z.ZodOptional<z.ZodNumber>;
97
+ }, z.core.$strip>;
98
+ export type Action = z.infer<typeof action>;
99
+ /** What a person is shown before they decide. A diff for a change, prose for a message. */
100
+ export declare const preview: z.ZodObject<{
101
+ format: z.ZodEnum<{
102
+ markdown: "markdown";
103
+ plain: "plain";
104
+ diff: "diff";
105
+ json: "json";
106
+ table: "table";
107
+ }>;
108
+ body: z.ZodString;
109
+ title: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$strip>;
111
+ export type Preview = z.infer<typeof preview>;
112
+ /**
113
+ * Who may answer an approval. `owner` and `role:<name>` are resolved by Chips, so a harness
114
+ * never needs to know who is on shift.
115
+ */
116
+ export declare const approverRef: z.ZodString;
117
+ /** Autonomy levels L0 to L3 (blueprint: trust is a dial, not a switch). */
118
+ export declare const autonomyLevel: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
119
+ export type AutonomyLevel = z.infer<typeof autonomyLevel>;
120
+ /** One policy rule. Rules read like sentences: `email.send to an external domain -> ask the owner`. */
121
+ export declare const policyRule: z.ZodObject<{
122
+ match: z.ZodString;
123
+ when: z.ZodOptional<z.ZodObject<{
124
+ external: z.ZodOptional<z.ZodBoolean>;
125
+ irreversible: z.ZodOptional<z.ZodBoolean>;
126
+ money_usd_over: z.ZodOptional<z.ZodNumber>;
127
+ risk: z.ZodOptional<z.ZodArray<z.ZodEnum<{
128
+ external: "external";
129
+ external_communication: "external_communication";
130
+ irreversible: "irreversible";
131
+ destructive: "destructive";
132
+ financial: "financial";
133
+ credential: "credential";
134
+ privacy: "privacy";
135
+ legal: "legal";
136
+ }>>>;
137
+ }, z.core.$strip>>;
138
+ decision: z.ZodEnum<{
139
+ allow: "allow";
140
+ ask: "ask";
141
+ deny: "deny";
142
+ }>;
143
+ approvers: z.ZodOptional<z.ZodArray<z.ZodString>>;
144
+ reason: z.ZodOptional<z.ZodString>;
145
+ }, z.core.$strip>;
146
+ export type PolicyRule = z.infer<typeof policyRule>;
147
+ export declare const policy: z.ZodObject<{
148
+ autonomy: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
149
+ rules: z.ZodArray<z.ZodObject<{
150
+ match: z.ZodString;
151
+ when: z.ZodOptional<z.ZodObject<{
152
+ external: z.ZodOptional<z.ZodBoolean>;
153
+ irreversible: z.ZodOptional<z.ZodBoolean>;
154
+ money_usd_over: z.ZodOptional<z.ZodNumber>;
155
+ risk: z.ZodOptional<z.ZodArray<z.ZodEnum<{
156
+ external: "external";
157
+ external_communication: "external_communication";
158
+ irreversible: "irreversible";
159
+ destructive: "destructive";
160
+ financial: "financial";
161
+ credential: "credential";
162
+ privacy: "privacy";
163
+ legal: "legal";
164
+ }>>>;
165
+ }, z.core.$strip>>;
166
+ decision: z.ZodEnum<{
167
+ allow: "allow";
168
+ ask: "ask";
169
+ deny: "deny";
170
+ }>;
171
+ approvers: z.ZodOptional<z.ZodArray<z.ZodString>>;
172
+ reason: z.ZodOptional<z.ZodString>;
173
+ }, z.core.$strip>>;
174
+ }, z.core.$strip>;
175
+ export type Policy = z.infer<typeof policy>;
176
+ /** Money is always an estimate and always labelled as one (blueprint: cost rolls up the trail). */
177
+ export declare const cost: z.ZodObject<{
178
+ usd: z.ZodNumber;
179
+ estimated: z.ZodLiteral<true>;
180
+ }, z.core.$strip>;
181
+ export type Cost = z.infer<typeof cost>;
182
+ export declare const budget: z.ZodObject<{
183
+ limit_usd: z.ZodNumber;
184
+ spent_usd: z.ZodNumber;
185
+ }, z.core.$strip>;
186
+ export type Budget = z.infer<typeof budget>;
187
+ /** How work travelled to get here, so a lane can be traced back to the message that caused it. */
188
+ export declare const trailEntry: z.ZodObject<{
189
+ participant_id: z.ZodString;
190
+ run_id: z.ZodOptional<z.ZodString>;
191
+ goal: z.ZodOptional<z.ZodString>;
192
+ }, z.core.$strip>;
193
+ export type TrailEntry = z.infer<typeof trailEntry>;
194
+ //# sourceMappingURL=primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAe,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI1D,uFAAuF;AACvF,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,eAK3C;AAED,eAAO,MAAM,YAAY,kBAEoD,CAAC;AAE9E,0FAA0F;AAC1F,eAAO,MAAM,KAAK;;;;;;;iBAOuC,CAAC;AAC1D,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,O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G,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;iBA4B2B,CAAC;AACnD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ6D,CAAC;AACjF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC;AAE5C,mGAAmG;AACnG,eAAO,MAAM,IAAI;;;iBAKgB,CAAC;AAClC,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,MAAM;;;iBAK0D,CAAC;AAC9E,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC;AAE5C,kGAAkG;AAClG,eAAO,MAAM,UAAU;;;;iBAMmC,CAAC;AAC3D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -0,0 +1,193 @@
1
+ /**
2
+ * The sub-schemas events are built from. Each one exists because more than one event needs
3
+ * it, and each carries a description, because those descriptions become the documentation
4
+ * reference (technical-plan decision 13).
5
+ */
6
+ import { z } from "zod";
7
+ import { ID_PREFIXES } from "./ids/index.js";
8
+ const ULID = "[0-7][0-9A-HJKMNP-TV-Z]{25}";
9
+ /** A schema for one kind of prefixed ULID, for example `run_01K4...` (decision 11). */
10
+ export function id(kind) {
11
+ return z
12
+ .string()
13
+ .regex(new RegExp(`^${ID_PREFIXES[kind]}_${ULID}$`), `expected a ${kind} id`)
14
+ .describe(`A ${kind} identifier: \`${ID_PREFIXES[kind]}_\` followed by a ULID.`);
15
+ }
16
+ export const isoTimestamp = z.iso
17
+ .datetime({ offset: true })
18
+ .describe("An ISO 8601 timestamp, for example `2026-09-02T14:22:31.004Z`.");
19
+ /** Who caused an event. Every envelope says so; the audit log is a read of this field. */
20
+ export const actor = z
21
+ .object({
22
+ kind: z
23
+ .enum(["person", "agent", "system"])
24
+ .describe("Whether a person, an agent or Chips itself acted."),
25
+ id: z.string().min(1).describe("The participant id, or `system` for Chips."),
26
+ })
27
+ .describe("The participant an event is attributed to.");
28
+ /** A person or agent as another party sees them, with the role Chips assigns. */
29
+ export const participantRef = z
30
+ .object({
31
+ participant_id: z.string().min(1).describe("The stable id of the sender."),
32
+ kind: z.enum(["person", "agent"]).describe("Whether the sender is a person or an agent."),
33
+ display_name: z.string().min(1).max(120).describe("The name to show."),
34
+ role: z
35
+ .enum(["owner", "member", "guest"])
36
+ .describe("The sender's standing in this conversation. Multi-user is Chips' job, not the harness's."),
37
+ })
38
+ .describe("A sender, as the receiving side sees them.");
39
+ /**
40
+ * An attachment. Anything you can send a person you can send an agent, so this shape carries
41
+ * files, images, video and voice notes alike (decision 10).
42
+ */
43
+ export const attachment = z
44
+ .object({
45
+ attachment_id: id("attachment"),
46
+ filename: z.string().min(1).max(255).describe("The name to show. Never trusted for its type."),
47
+ mime_type: z
48
+ .string()
49
+ .min(1)
50
+ .max(255)
51
+ .describe("Sniffed from the bytes on upload, not taken from the client."),
52
+ byte_size: z.int().nonnegative().describe("Size in bytes."),
53
+ sha256: z
54
+ .string()
55
+ .regex(/^[a-f0-9]{64}$/)
56
+ .describe("Lowercase hex digest. The store is content-addressed."),
57
+ width: z.int().positive().optional().describe("Pixels, for images and video."),
58
+ height: z.int().positive().optional().describe("Pixels, for images and video."),
59
+ duration_ms: z.int().nonnegative().optional().describe("Milliseconds, for audio and video."),
60
+ })
61
+ .describe("A file carried by a message.");
62
+ /** An attachment as it reaches an agent: with a URL it can actually fetch. */
63
+ export const signedAttachment = attachment
64
+ .extend({
65
+ url: z.url().describe("A signed URL, bound to the requesting token."),
66
+ url_expires_at: isoTimestamp.describe("Ten minutes from issue, by default (decision 10)."),
67
+ })
68
+ .describe("An attachment with a short-lived, token-bound URL.");
69
+ /** Where a claim came from. External sources are what make an action risky. */
70
+ export const source = z
71
+ .object({
72
+ kind: z.enum(["external", "internal"]).describe("Whether the source is outside the workspace."),
73
+ label: z
74
+ .string()
75
+ .min(1)
76
+ .max(200)
77
+ .describe("What to show in the receipt, for example `vendor website`."),
78
+ url: z.url().optional().describe("Where to look, when there is somewhere to look."),
79
+ })
80
+ .describe("A source an agent used, shown in the receipt and on approval cards.");
81
+ /**
82
+ * Risk classes. These are the flags the policy engine matches on (decision 8), so the list is
83
+ * closed: a new class is a protocol change, not a free-text string an agent invents.
84
+ */
85
+ export const riskClass = z
86
+ .enum([
87
+ "external",
88
+ "external_communication",
89
+ "irreversible",
90
+ "destructive",
91
+ "financial",
92
+ "credential",
93
+ "privacy",
94
+ "legal",
95
+ ])
96
+ .describe("A risk class the policy engine can match a rule against.");
97
+ /** The action an agent wants to take. `kind` is what policy rules glob against. */
98
+ export const action = z
99
+ .object({
100
+ kind: z
101
+ .string()
102
+ .regex(/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/)
103
+ .max(120)
104
+ .describe("A dotted verb, for example `email.send` or `payment.transfer`. Policy rules glob on it."),
105
+ input: z.unknown().optional().describe("The arguments, shaped by the tool being called."),
106
+ external: z.boolean().optional().describe("True when the action leaves the workspace."),
107
+ irreversible: z.boolean().optional().describe("True when the action cannot be undone."),
108
+ money_usd: z.number().nonnegative().optional().describe("Amount at stake, in US dollars."),
109
+ })
110
+ .describe("An action an agent proposes to take.");
111
+ /** What a person is shown before they decide. A diff for a change, prose for a message. */
112
+ export const preview = z
113
+ .object({
114
+ format: z
115
+ .enum(["markdown", "plain", "diff", "json", "table"])
116
+ .describe("How to render the body."),
117
+ body: z.string().max(200_000).describe("The rendered preview."),
118
+ title: z.string().max(200).optional().describe("A heading for the card."),
119
+ })
120
+ .describe("What the approver sees before deciding.");
121
+ /**
122
+ * Who may answer an approval. `owner` and `role:<name>` are resolved by Chips, so a harness
123
+ * never needs to know who is on shift.
124
+ */
125
+ export const approverRef = z
126
+ .string()
127
+ .regex(/^(owner|any|role:[a-z][a-z0-9_]*|usr_[0-9A-HJKMNP-TV-Z]{26})$/)
128
+ .describe("`owner`, `any`, `role:<name>`, or a specific person id.");
129
+ /** Autonomy levels L0 to L3 (blueprint: trust is a dial, not a switch). */
130
+ export const autonomyLevel = z
131
+ .union([z.literal(0), z.literal(1), z.literal(2), z.literal(3)])
132
+ .describe("0 observe, 1 ask first, 2 ask when it matters, 3 autonomous and report back. Presets that expand to rules.");
133
+ /** One policy rule. Rules read like sentences: `email.send to an external domain -> ask the owner`. */
134
+ export const policyRule = z
135
+ .object({
136
+ match: z
137
+ .string()
138
+ .min(1)
139
+ .max(120)
140
+ .describe("A glob over action kinds, for example `payment.*`."),
141
+ when: z
142
+ .object({
143
+ external: z.boolean().optional(),
144
+ irreversible: z.boolean().optional(),
145
+ money_usd_over: z.number().nonnegative().optional(),
146
+ risk: z.array(riskClass).max(8).optional(),
147
+ })
148
+ .optional()
149
+ .describe("Extra conditions on the action's flags."),
150
+ decision: z.enum(["allow", "ask", "deny"]).describe("What to do when the rule matches."),
151
+ approvers: z
152
+ .array(approverRef)
153
+ .max(16)
154
+ .optional()
155
+ .describe("Who may answer, when the decision is `ask`."),
156
+ reason: z
157
+ .string()
158
+ .max(400)
159
+ .optional()
160
+ .describe("Shown to the agent, and recorded in the audit log."),
161
+ })
162
+ .describe("A rule the policy engine evaluates.");
163
+ export const policy = z
164
+ .object({
165
+ autonomy: autonomyLevel,
166
+ rules: z
167
+ .array(policyRule)
168
+ .max(200)
169
+ .describe("Evaluated in order; the workspace cap always wins."),
170
+ })
171
+ .describe("An agent's autonomy level and the rules that fill in the details.");
172
+ /** Money is always an estimate and always labelled as one (blueprint: cost rolls up the trail). */
173
+ export const cost = z
174
+ .object({
175
+ usd: z.number().nonnegative().describe("An estimate, in US dollars."),
176
+ estimated: z.literal(true).describe("Always true. Cost is never presented as exact."),
177
+ })
178
+ .describe("An estimated cost.");
179
+ export const budget = z
180
+ .object({
181
+ limit_usd: z.number().nonnegative().describe("The ceiling for this agent."),
182
+ spent_usd: z.number().nonnegative().describe("Spent so far, estimated."),
183
+ })
184
+ .describe("An agent's budget. Warns at 80 percent, pauses the run at 100.");
185
+ /** How work travelled to get here, so a lane can be traced back to the message that caused it. */
186
+ export const trailEntry = z
187
+ .object({
188
+ participant_id: z.string().min(1).describe("Who handled this hop."),
189
+ run_id: id("run").optional().describe("The run this hop belongs to."),
190
+ goal: z.string().max(2000).optional().describe("What was asked at this hop."),
191
+ })
192
+ .describe("One hop in the chain that led to this work.");
193
+ //# sourceMappingURL=primitives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAE1D,MAAM,IAAI,GAAG,6BAA6B,CAAC;AAE3C,uFAAuF;AACvF,MAAM,UAAU,EAAE,CAAmB,IAAO;IAC1C,OAAO,CAAC;SACL,MAAM,EAAE;SACR,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,cAAc,IAAI,KAAK,CAAC;SAC5E,QAAQ,CAAC,KAAK,IAAI,kBAAkB,WAAW,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,GAAG;KAC9B,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;KAC1B,QAAQ,CAAC,gEAAgE,CAAC,CAAC;AAE9E,0FAA0F;AAC1F,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC;KACnB,MAAM,CAAC;IACN,IAAI,EAAE,CAAC;SACJ,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CA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,WAAW,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;CACzE,CAAC;KACD,QAAQ,CAAC,gEAAgE,CAAC,CAAC;AAG9E,kGAAkG;AAClG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACnE,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IACrE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;CAC9E,CAAC;KACD,QAAQ,CAAC,6CAA6C,CAAC,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Who a message is for (ADR 0081).
3
+ *
4
+ * Chips decides, once, at ingest, which agents in a space a message is for, and only they take
5
+ * a turn on it; the others overhear it. The server that decides, the conformance fake that plays
6
+ * the server, and the clients that show the answer before a send have to agree, so the rule lives
7
+ * here, with the schemas, as `mentions.ts` does.
8
+ *
9
+ * Who takes a turn is agents only: people read every message. An agent is a harness's (ADR 0087);
10
+ * a harness still in a room from before agents counts as one until the upgrade gives it one. A
11
+ * message can be for a person too (ADR 0204): one the sender @s, or picks in the field's list. No
12
+ * agent takes a turn for them; they are told, as an @ tells them. Natalie's "How's it going?" in
13
+ * Foodie on 19 October 2026 had no way to be for Arjun, and went to the room's agent.
14
+ *
15
+ * An agent's message to agents is held only past the referee's ceiling, or while a person has
16
+ * paused the agents (ADR 0097, which replaced ADR 0081's hold after four).
17
+ */
18
+ import { type ExchangeLimits } from "./exchange.js";
19
+ /**
20
+ * Whether a participant of this kind takes part in rooms as an agent: an agent (ADR 0087), or a
21
+ * harness in a room from before agents. Anything that is not a person or Chips itself.
22
+ */
23
+ export declare function isAgentKind(kind: string): boolean;
24
+ export interface AddressInput {
25
+ /** Who sent it. */
26
+ readonly sender: {
27
+ readonly id: string;
28
+ readonly kind: string;
29
+ };
30
+ /** The participants the text's @handles name, as ids, people included. */
31
+ readonly mentioned: readonly string[];
32
+ /** Whether the text says `@all`. */
33
+ readonly everyone: boolean;
34
+ /** What the sender chose without typing an @: agent ids and people's, or every agent. */
35
+ readonly to?: readonly string[] | "all" | undefined;
36
+ /** The author of the message this one answers, when it is a reply. */
37
+ readonly replyAuthor?: {
38
+ readonly id: string;
39
+ readonly kind: string;
40
+ } | undefined;
41
+ /** The space's agents that have not been removed, in the order they joined. */
42
+ readonly agents: readonly string[];
43
+ /**
44
+ * The space's people that have not been removed (ADR 0204): who besides its agents an @ or a `to`
45
+ * can make a message for. Absent, a `to` names agents only, as before.
46
+ */
47
+ readonly people?: readonly string[] | undefined;
48
+ /**
49
+ * What the sender's previous message in the space was for: its agents, or `all` when it was for
50
+ * every agent there was. Absent before their first.
51
+ */
52
+ readonly last?: readonly string[] | "all" | undefined;
53
+ /**
54
+ * How the agents' talk in the space stands (ADR 0097): the messages agents have sent agents
55
+ * since the last reset, whether a person paused them, and the workspace's limits (ADR 0187),
56
+ * the defaults where absent. Absent, nothing is held.
57
+ */
58
+ readonly exchange?: {
59
+ readonly count: number;
60
+ readonly paused: boolean;
61
+ readonly limits?: ExchangeLimits | undefined;
62
+ } | undefined;
63
+ }
64
+ export interface Address {
65
+ /** The agents the message is for. */
66
+ readonly addressed_to: string[];
67
+ /**
68
+ * Set when the message is for every agent in the space, whoever is there: `@all`, a `to` of
69
+ * `all`, or a person's default of everyone. That person's next message that names nobody goes
70
+ * to every agent there is then, one added since included.
71
+ */
72
+ readonly addressed_to_all?: true;
73
+ /** Set when Chips held an agent's message (ADR 0097): it is shown, and for nobody. */
74
+ readonly held?: true;
75
+ /**
76
+ * The people a person's message is for (ADR 0204): those its @s name, or else those the sender
77
+ * picked in `to`. They are told as an @ tells them; no agent takes a turn for them. Absent for
78
+ * none, and on an agent's message.
79
+ */
80
+ readonly addressed_people?: string[];
81
+ }
82
+ /**
83
+ * The agents a message is for. For a person the first rule that applies decides: an @, the
84
+ * composer's choice, a reply to an agent, the only agent, then where their last message here
85
+ * went (every agent before their first). An agent reaches only the agents it names, chose or
86
+ * answers, and its words are otherwise for the people; past the workspace's hold, or while the
87
+ * agents are paused, it reaches nobody until a person acts.
88
+ */
89
+ export declare function resolveAddress(input: AddressInput): Address;
90
+ /**
91
+ * Who of one connection takes a turn on a message (ADR 0081, ADR 0087): what `message.new`
92
+ * carries as `for`. The ids the connection answers to among those the message is for: its
93
+ * agents, and the harness itself where the harness is the member addressed, which it is in a
94
+ * room asked of it from the + until it claims the room. On a message from before Chips said who
95
+ * a message is for, every one of the connection's own in the room.
96
+ *
97
+ * The harness's own id used to be left out, so the first words in a room asked of a harness
98
+ * arrived for nobody (`for: []`) and an adapter that read the list as final took no turn (agents
99
+ * review, finding 31). A `message.new` now always names somebody.
100
+ *
101
+ * Never the one who said it (`saidBy`): one of the connection's agents is a turn for another of
102
+ * them it is for, but not for itself (ADR 0101). Its own words from before Chips said who a
103
+ * message is for are nobody's turn, as all its own words were before that ADR.
104
+ */
105
+ export declare function takersOf(addressedTo: readonly string[] | undefined, selves: ReadonlySet<string>, ownInRoom: readonly string[], saidBy?: string): string[];
106
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAS,MAAM,eAAe,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,MAAM,WAAW,YAAY;IAC3B,mBAAmB;IACnB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,C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ACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAS3D;AAkFD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CACtB,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,EAC3B,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,EAAE,CAIV"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Who a message is for (ADR 0081).
3
+ *
4
+ * Chips decides, once, at ingest, which agents in a space a message is for, and only they take
5
+ * a turn on it; the others overhear it. The server that decides, the conformance fake that plays
6
+ * the server, and the clients that show the answer before a send have to agree, so the rule lives
7
+ * here, with the schemas, as `mentions.ts` does.
8
+ *
9
+ * Who takes a turn is agents only: people read every message. An agent is a harness's (ADR 0087);
10
+ * a harness still in a room from before agents counts as one until the upgrade gives it one. A
11
+ * message can be for a person too (ADR 0204): one the sender @s, or picks in the field's list. No
12
+ * agent takes a turn for them; they are told, as an @ tells them. Natalie's "How's it going?" in
13
+ * Foodie on 19 October 2026 had no way to be for Arjun, and went to the room's agent.
14
+ *
15
+ * An agent's message to agents is held only past the referee's ceiling, or while a person has
16
+ * paused the agents (ADR 0097, which replaced ADR 0081's hold after four).
17
+ */
18
+ import { holds } from "./exchange.js";
19
+ /**
20
+ * Whether a participant of this kind takes part in rooms as an agent: an agent (ADR 0087), or a
21
+ * harness in a room from before agents. Anything that is not a person or Chips itself.
22
+ */
23
+ export function isAgentKind(kind) {
24
+ return kind !== "person" && kind !== "system";
25
+ }
26
+ /**
27
+ * The agents a message is for. For a person the first rule that applies decides: an @, the
28
+ * composer's choice, a reply to an agent, the only agent, then where their last message here
29
+ * went (every agent before their first). An agent reaches only the agents it names, chose or
30
+ * answers, and its words are otherwise for the people; past the workspace's hold, or while the
31
+ * agents are paused, it reaches nobody until a person acts.
32
+ */
33
+ export function resolveAddress(input) {
34
+ const members = input.agents.filter((id) => id !== input.sender.id);
35
+ if (isAgentKind(input.sender.kind)) {
36
+ const picked = named(input, members) ?? aimed(input, members) ?? answered(input, members);
37
+ const address = addressOf(picked ?? [], members);
38
+ const held = input.exchange !== undefined && holds(input.exchange);
39
+ return address.addressed_to.length > 0 && held ? { addressed_to: [], held: true } : address;
40
+ }
41
+ return personAddress(input, members);
42
+ }
43
+ /**
44
+ * A person's message: an @, the composer's choice, people chosen (who give no agent a turn, ADR
45
+ * 0204), a reply to an agent, the only agent, then where their last message here went.
46
+ */
47
+ function personAddress(input, members) {
48
+ const people = (input.people ?? []).filter((id) => id !== input.sender.id);
49
+ const chosen = chosenPeople(input, people);
50
+ const picked = named(input, members) ??
51
+ aimed(input, members) ??
52
+ (chosen.length > 0 ? [] : undefined) ??
53
+ answered(input, members);
54
+ if (picked !== undefined)
55
+ return withPeople(addressOf(picked, members), chosen);
56
+ // A room with no agent yet: the message is for whoever comes, so their next goes to everyone.
57
+ if (members.length === 0)
58
+ return addressOf("all", members);
59
+ if (members.length === 1)
60
+ return { addressed_to: [...members] };
61
+ return addressOf(lastOrEveryone(input.last, members), members);
62
+ }
63
+ /**
64
+ * The people a person's message is for (ADR 0204): those an @ names, when an @ decides, as it
65
+ * decides for agents; else those the sender picked in `to`. Never the sender.
66
+ */
67
+ function chosenPeople(input, people) {
68
+ if (input.everyone)
69
+ return [];
70
+ if (input.mentioned.length > 0)
71
+ return kept(input.mentioned, people);
72
+ return Array.isArray(input.to) ? kept(input.to, people) : [];
73
+ }
74
+ function withPeople(address, people) {
75
+ return people.length === 0 ? address : { ...address, addressed_people: [...people] };
76
+ }
77
+ function addressOf(aimed, members) {
78
+ return aimed === "all"
79
+ ? { addressed_to: [...members], addressed_to_all: true }
80
+ : { addressed_to: aimed };
81
+ }
82
+ /** Rule 1: an @ decides, even when it names only people. */
83
+ function named(input, members) {
84
+ if (input.everyone)
85
+ return "all";
86
+ return input.mentioned.length > 0 ? kept(input.mentioned, members) : undefined;
87
+ }
88
+ /** Rule 2: the composer's choice, when it names a member. */
89
+ function aimed(input, members) {
90
+ if (input.to === undefined)
91
+ return undefined;
92
+ if (input.to === "all")
93
+ return members.length > 0 ? "all" : undefined;
94
+ const to = kept(input.to, members);
95
+ return to.length > 0 ? to : undefined;
96
+ }
97
+ /** Rule 3: a reply to an agent that is still here. */
98
+ function answered(input, members) {
99
+ if (input.replyAuthor === undefined || !isAgentKind(input.replyAuthor.kind))
100
+ return undefined;
101
+ const author = kept([input.replyAuthor.id], members);
102
+ return author.length > 0 ? author : undefined;
103
+ }
104
+ /**
105
+ * Rule 5: where the sender's last message went. Everyone stays everyone, an agent added since
106
+ * included. Agents are kept to those still here, and it is everyone before their first message
107
+ * and when none of those they addressed is left. A last message for no agent (it named only
108
+ * people) keeps the next one for nobody.
109
+ */
110
+ function lastOrEveryone(last, members) {
111
+ if (last === undefined || last === "all")
112
+ return "all";
113
+ const still = kept(last, members);
114
+ return last.length > 0 && still.length === 0 ? "all" : still;
115
+ }
116
+ /** The ids that are members, each once, in the order given. */
117
+ function kept(ids, members) {
118
+ return [...new Set(ids)].filter((id) => members.includes(id));
119
+ }
120
+ /**
121
+ * Who of one connection takes a turn on a message (ADR 0081, ADR 0087): what `message.new`
122
+ * carries as `for`. The ids the connection answers to among those the message is for: its
123
+ * agents, and the harness itself where the harness is the member addressed, which it is in a
124
+ * room asked of it from the + until it claims the room. On a message from before Chips said who
125
+ * a message is for, every one of the connection's own in the room.
126
+ *
127
+ * The harness's own id used to be left out, so the first words in a room asked of a harness
128
+ * arrived for nobody (`for: []`) and an adapter that read the list as final took no turn (agents
129
+ * review, finding 31). A `message.new` now always names somebody.
130
+ *
131
+ * Never the one who said it (`saidBy`): one of the connection's agents is a turn for another of
132
+ * them it is for, but not for itself (ADR 0101). Its own words from before Chips said who a
133
+ * message is for are nobody's turn, as all its own words were before that ADR.
134
+ */
135
+ export function takersOf(addressedTo, selves, ownInRoom, saidBy) {
136
+ const own = saidBy !== undefined && selves.has(saidBy);
137
+ if (addressedTo === undefined)
138
+ return own ? [] : [...ownInRoom];
139
+ return addressedTo.filter((id) => selves.has(id) && id !== saidBy);
140
+ }
141
+ //# sourceMappingURL=address.js.map