copilotz 1.0.0-rc.20 → 1.0.0-rc.21

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 (340) hide show
  1. package/CHANGELOG.md +417 -0
  2. package/README.md +295 -19
  3. package/hosts/orgs/mod.d.ts +4 -1
  4. package/hosts/orgs/mod.js +2 -2
  5. package/hosts/web/files.d.ts +6 -2
  6. package/hosts/web/files.js +36 -3
  7. package/hosts/web/node/mod.d.ts +1 -1
  8. package/hosts/web/node/mod.js +1 -1
  9. package/hosts/web/node/serve.d.ts +26 -0
  10. package/hosts/web/node/serve.js +23 -1
  11. package/hosts/web/routes.d.ts +28 -1
  12. package/hosts/web/routes.js +65 -10
  13. package/hosts/web/server.d.ts +5 -4
  14. package/hosts/web/server.js +1 -1
  15. package/package.json +2 -2
  16. package/plugins/access/accounts/collections/account.d.ts +2 -2
  17. package/plugins/access/contacts/actions/chat.d.ts +1 -0
  18. package/plugins/access/contacts/actions/chat.js +45 -0
  19. package/plugins/access/contacts/actions/forget.d.ts +1 -0
  20. package/plugins/access/contacts/actions/forget.js +56 -0
  21. package/plugins/access/contacts/actions/start.d.ts +1 -0
  22. package/plugins/access/contacts/actions/start.js +50 -0
  23. package/plugins/access/contacts/collections/contact.d.ts +81 -0
  24. package/plugins/access/contacts/collections/contact.js +58 -0
  25. package/plugins/access/contacts/contract.d.ts +10 -0
  26. package/plugins/access/contacts/contract.js +10 -0
  27. package/plugins/access/contacts/mod.d.ts +27 -0
  28. package/plugins/access/contacts/mod.js +49 -0
  29. package/plugins/access/contacts/views/contact.d.ts +8 -0
  30. package/plugins/access/contacts/views/contact.js +25 -0
  31. package/plugins/access/contacts/web.d.ts +7 -0
  32. package/plugins/access/contacts/web.js +11 -0
  33. package/plugins/access/directory/collections/credit-code.d.ts +1 -1
  34. package/plugins/access/directory/collections/invite.d.ts +1 -1
  35. package/plugins/access/identity/mod.js +8 -6
  36. package/plugins/access/mod.d.ts +7 -1
  37. package/plugins/access/mod.js +7 -2
  38. package/plugins/access/spaces/actions/agents.js +12 -6
  39. package/plugins/access/spaces/actions/create.js +10 -1
  40. package/plugins/access/spaces/actions/invitation.js +5 -2
  41. package/plugins/access/spaces/actions/keep.d.ts +1 -0
  42. package/plugins/access/spaces/actions/keep.js +55 -0
  43. package/plugins/access/spaces/actions/member.js +17 -4
  44. package/plugins/access/spaces/actions/rename.js +4 -0
  45. package/plugins/access/spaces/collections/member.d.ts +1 -1
  46. package/plugins/access/spaces/collections/request.d.ts +1 -1
  47. package/plugins/access/spaces/collections/space.d.ts +9 -0
  48. package/plugins/access/spaces/collections/space.js +2 -0
  49. package/plugins/access/spaces/contract.d.ts +4 -3
  50. package/plugins/access/spaces/contract.js +1 -1
  51. package/plugins/access/spaces/mod.d.ts +7 -1
  52. package/plugins/access/spaces/mod.js +8 -1
  53. package/plugins/access/spaces/resources/tools.d.ts +0 -5
  54. package/plugins/access/spaces/resources/tools.js +11 -1
  55. package/plugins/access/spaces/shared/agents.js +2 -2
  56. package/plugins/access/spaces/shared/can.d.ts +18 -3
  57. package/plugins/access/spaces/shared/can.js +32 -5
  58. package/plugins/access/spaces/shared/declared.d.ts +21 -0
  59. package/plugins/access/spaces/shared/declared.js +8 -0
  60. package/plugins/access/spaces/shared/labels.d.ts +7 -1
  61. package/plugins/access/spaces/shared/labels.js +56 -8
  62. package/plugins/access/spaces/shared/managers.js +2 -2
  63. package/plugins/access/spaces/shared/names.d.ts +9 -5
  64. package/plugins/access/spaces/shared/names.js +36 -19
  65. package/plugins/access/spaces/shared/reach.d.ts +20 -6
  66. package/plugins/access/spaces/shared/reach.js +62 -20
  67. package/plugins/access/spaces/shared/rules.d.ts +10 -5
  68. package/plugins/access/spaces/shared/rules.js +35 -10
  69. package/plugins/access/spaces/shared/seat.d.ts +3 -2
  70. package/plugins/access/spaces/shared/seat.js +9 -2
  71. package/plugins/access/spaces/views/where.d.ts +4 -2
  72. package/plugins/access/spaces/views/where.js +9 -0
  73. package/plugins/access/spaces/web.js +1 -1
  74. package/plugins/access/web.d.ts +1 -0
  75. package/plugins/access/web.js +1 -0
  76. package/plugins/agents/chat/actions/erase.d.ts +1 -0
  77. package/plugins/agents/chat/actions/erase.js +51 -0
  78. package/plugins/agents/chat/actions/open.d.ts +1 -0
  79. package/plugins/agents/chat/actions/open.js +49 -0
  80. package/plugins/agents/chat/actions/quiet.d.ts +1 -0
  81. package/plugins/agents/chat/actions/quiet.js +33 -0
  82. package/plugins/agents/chat/actions/say.d.ts +1 -0
  83. package/plugins/agents/chat/actions/say.js +82 -0
  84. package/plugins/agents/chat/actions/send.js +57 -19
  85. package/plugins/agents/chat/actions/shown.d.ts +1 -0
  86. package/plugins/agents/chat/actions/shown.js +35 -0
  87. package/plugins/agents/chat/collections/intent.d.ts +124 -0
  88. package/plugins/agents/chat/collections/intent.js +52 -0
  89. package/plugins/agents/chat/collections/message.d.ts +74 -1
  90. package/plugins/agents/chat/collections/message.js +23 -1
  91. package/plugins/agents/chat/collections/shown.d.ts +105 -0
  92. package/plugins/agents/chat/collections/shown.js +34 -0
  93. package/plugins/agents/chat/contract.d.ts +15 -7
  94. package/plugins/agents/chat/contract.js +7 -1
  95. package/plugins/agents/chat/mod.d.ts +20 -2
  96. package/plugins/agents/chat/mod.js +43 -4
  97. package/plugins/agents/chat/processors/failed.js +15 -5
  98. package/plugins/agents/chat/processors/turn.d.ts +1 -1
  99. package/plugins/agents/chat/processors/turn.js +95 -35
  100. package/plugins/agents/chat/shared/delivery.d.ts +16 -2
  101. package/plugins/agents/chat/shared/delivery.js +62 -7
  102. package/plugins/agents/chat/shared/send.d.ts +1 -3
  103. package/plugins/agents/chat/shared/send.js +2 -9
  104. package/plugins/agents/chat/shared/tools.d.ts +33 -0
  105. package/plugins/agents/chat/shared/tools.js +28 -0
  106. package/plugins/agents/chat/shared/types.d.ts +59 -1
  107. package/plugins/agents/chat/views/message.d.ts +4 -2
  108. package/plugins/agents/chat/views/message.js +22 -4
  109. package/plugins/agents/chat/views/prompt.js +38 -4
  110. package/plugins/agents/history/collections/outline.d.ts +1 -1
  111. package/plugins/agents/history/collections/summary.d.ts +1 -1
  112. package/plugins/agents/history/mod.js +2 -1
  113. package/plugins/agents/history/processors/erase.d.ts +3 -0
  114. package/plugins/agents/history/processors/erase.js +11 -0
  115. package/plugins/agents/memory/mod.js +2 -1
  116. package/plugins/agents/memory/processors/extract.d.ts +1 -1
  117. package/plugins/agents/memory/processors/extract.js +5 -0
  118. package/plugins/agents/memory/resources/tools.js +1 -1
  119. package/plugins/agents/memory/shared/settings.d.ts +7 -2
  120. package/plugins/agents/memory/shared/settings.js +9 -1
  121. package/plugins/agents/routines/collections/routine.d.ts +1 -1
  122. package/plugins/agents/routines/collections/run.d.ts +1 -1
  123. package/plugins/compute/apps/collections/app.d.ts +2 -2
  124. package/plugins/compute/cloud/resources/tools.js +3 -3
  125. package/plugins/compute/computers/collections/approval.d.ts +2 -2
  126. package/plugins/compute/computers/collections/grant.d.ts +1 -1
  127. package/plugins/compute/computers/collections/preview.d.ts +2 -2
  128. package/plugins/compute/computers/program/version.d.ts +1 -1
  129. package/plugins/compute/computers/program/version.js +1 -1
  130. package/plugins/compute/computers/resources/downloads.js +1 -1
  131. package/plugins/compute/computers/shared/wake.d.ts +1 -1
  132. package/plugins/compute/computers/shared/wake.js +17 -0
  133. package/plugins/interfaces/api/collections/key.d.ts +1 -1
  134. package/plugins/interfaces/api/shared/events.js +5 -4
  135. package/plugins/interfaces/maintenance/actions/read.d.ts +4 -0
  136. package/plugins/interfaces/maintenance/actions/read.js +76 -0
  137. package/plugins/interfaces/maintenance/actions/write.d.ts +4 -0
  138. package/plugins/interfaces/maintenance/actions/write.js +64 -0
  139. package/plugins/interfaces/maintenance/contract.d.ts +60 -0
  140. package/plugins/interfaces/maintenance/contract.js +2 -0
  141. package/plugins/interfaces/maintenance/mod.d.ts +52 -0
  142. package/plugins/interfaces/maintenance/mod.js +66 -0
  143. package/plugins/interfaces/maintenance/resources/routes.d.ts +71 -0
  144. package/plugins/interfaces/maintenance/resources/routes.js +457 -0
  145. package/plugins/interfaces/maintenance/shared/ops.d.ts +4 -0
  146. package/plugins/interfaces/maintenance/shared/ops.js +19 -0
  147. package/plugins/interfaces/mcp/actions/call.d.ts +11 -0
  148. package/plugins/interfaces/mcp/actions/call.js +304 -0
  149. package/plugins/interfaces/mcp/actions/prune.d.ts +1 -0
  150. package/plugins/interfaces/mcp/actions/prune.js +18 -0
  151. package/plugins/interfaces/mcp/collections/closed.d.ts +23 -0
  152. package/plugins/interfaces/mcp/collections/closed.js +17 -0
  153. package/plugins/interfaces/mcp/collections/rate.d.ts +27 -0
  154. package/plugins/interfaces/mcp/collections/rate.js +18 -0
  155. package/plugins/interfaces/mcp/collections/receipt.d.ts +46 -0
  156. package/plugins/interfaces/mcp/collections/receipt.js +46 -0
  157. package/plugins/interfaces/mcp/contract.d.ts +9 -0
  158. package/plugins/interfaces/mcp/contract.js +9 -0
  159. package/plugins/interfaces/mcp/mod.d.ts +84 -0
  160. package/plugins/interfaces/mcp/mod.js +122 -0
  161. package/plugins/interfaces/mcp/processors/closed.d.ts +13 -0
  162. package/plugins/interfaces/mcp/processors/closed.js +16 -0
  163. package/plugins/interfaces/mcp/resources/running.d.ts +21 -0
  164. package/plugins/interfaces/mcp/resources/running.js +36 -0
  165. package/plugins/interfaces/mcp/resources/server.d.ts +54 -0
  166. package/plugins/interfaces/mcp/resources/server.js +423 -0
  167. package/plugins/interfaces/mcp/resources/tools.d.ts +114 -0
  168. package/plugins/interfaces/mcp/resources/tools.js +324 -0
  169. package/plugins/interfaces/mcp/shared/caller.d.ts +45 -0
  170. package/plugins/interfaces/mcp/shared/caller.js +99 -0
  171. package/plugins/interfaces/mcp/shared/keys.d.ts +50 -0
  172. package/plugins/interfaces/mcp/shared/keys.js +53 -0
  173. package/plugins/interfaces/mcp/shared/settings.d.ts +187 -0
  174. package/plugins/interfaces/mcp/shared/settings.js +176 -0
  175. package/plugins/interfaces/mcp/views/offered.d.ts +20 -0
  176. package/plugins/interfaces/mcp/views/offered.js +20 -0
  177. package/plugins/interfaces/mod.d.ts +5 -1
  178. package/plugins/interfaces/mod.js +5 -1
  179. package/plugins/interfaces/terminal/actions/print.js +1 -1
  180. package/plugins/interfaces/terminal/actions/set.js +1 -1
  181. package/plugins/interfaces/terminal/collections/output.d.ts +1 -1
  182. package/plugins/interfaces/terminal/collections/shell.js +1 -1
  183. package/plugins/interfaces/voice/actions/block.d.ts +2 -0
  184. package/plugins/interfaces/voice/actions/block.js +74 -0
  185. package/plugins/interfaces/voice/actions/call.d.ts +19 -0
  186. package/plugins/interfaces/voice/actions/call.js +253 -0
  187. package/plugins/interfaces/voice/actions/hook.d.ts +5 -0
  188. package/plugins/interfaces/voice/actions/hook.js +225 -0
  189. package/plugins/interfaces/voice/actions/prune.d.ts +1 -0
  190. package/plugins/interfaces/voice/actions/prune.js +35 -0
  191. package/plugins/interfaces/voice/collections/blocked.d.ts +87 -0
  192. package/plugins/interfaces/voice/collections/blocked.js +34 -0
  193. package/plugins/interfaces/voice/collections/call.d.ts +279 -0
  194. package/plugins/interfaces/voice/collections/call.js +77 -0
  195. package/plugins/interfaces/voice/collections/phone.d.ts +74 -0
  196. package/plugins/interfaces/voice/collections/phone.js +26 -0
  197. package/plugins/interfaces/voice/contract.d.ts +14 -0
  198. package/plugins/interfaces/voice/contract.js +2 -0
  199. package/plugins/interfaces/voice/mod.d.ts +57 -0
  200. package/plugins/interfaces/voice/mod.js +118 -0
  201. package/plugins/interfaces/voice/processors/forget.d.ts +13 -0
  202. package/plugins/interfaces/voice/processors/forget.js +27 -0
  203. package/plugins/interfaces/voice/resources/relay.d.ts +77 -0
  204. package/plugins/interfaces/voice/resources/relay.js +428 -0
  205. package/plugins/interfaces/voice/resources/tools.d.ts +1 -0
  206. package/plugins/interfaces/voice/resources/tools.js +25 -0
  207. package/plugins/interfaces/voice/shared/caller.d.ts +27 -0
  208. package/plugins/interfaces/voice/shared/caller.js +38 -0
  209. package/plugins/interfaces/voice/shared/settings.d.ts +136 -0
  210. package/plugins/interfaces/voice/shared/settings.js +121 -0
  211. package/plugins/interfaces/voice/shared/signature.d.ts +11 -0
  212. package/plugins/interfaces/voice/shared/signature.js +34 -0
  213. package/plugins/interfaces/voice/views/call.d.ts +41 -0
  214. package/plugins/interfaces/voice/views/call.js +30 -0
  215. package/plugins/interfaces/voice/views/context.d.ts +9 -0
  216. package/plugins/interfaces/voice/views/context.js +14 -0
  217. package/plugins/interfaces/voice/views/message.d.ts +17 -0
  218. package/plugins/interfaces/voice/views/message.js +41 -0
  219. package/plugins/interfaces/whatsapp/actions/connect.js +3 -0
  220. package/plugins/interfaces/whatsapp/actions/disconnect.js +4 -1
  221. package/plugins/interfaces/whatsapp/actions/hook.js +27 -11
  222. package/plugins/interfaces/whatsapp/actions/set.d.ts +8 -0
  223. package/plugins/interfaces/whatsapp/actions/set.js +121 -0
  224. package/plugins/interfaces/whatsapp/collections/blocked.d.ts +29 -0
  225. package/plugins/interfaces/whatsapp/collections/blocked.js +22 -0
  226. package/plugins/interfaces/whatsapp/collections/code.d.ts +1 -1
  227. package/plugins/interfaces/whatsapp/collections/number.d.ts +90 -4
  228. package/plugins/interfaces/whatsapp/collections/number.js +36 -4
  229. package/plugins/interfaces/whatsapp/collections/phone.d.ts +13 -3
  230. package/plugins/interfaces/whatsapp/collections/phone.js +9 -3
  231. package/plugins/interfaces/whatsapp/collections/rate.d.ts +27 -0
  232. package/plugins/interfaces/whatsapp/collections/rate.js +13 -0
  233. package/plugins/interfaces/whatsapp/collections/sent.d.ts +24 -12
  234. package/plugins/interfaces/whatsapp/collections/sent.js +11 -7
  235. package/plugins/interfaces/whatsapp/collections/thread.d.ts +14 -6
  236. package/plugins/interfaces/whatsapp/collections/thread.js +7 -5
  237. package/plugins/interfaces/whatsapp/collections/typing.d.ts +70 -0
  238. package/plugins/interfaces/whatsapp/collections/typing.js +21 -0
  239. package/plugins/interfaces/whatsapp/contract.d.ts +27 -4
  240. package/plugins/interfaces/whatsapp/contract.js +34 -1
  241. package/plugins/interfaces/whatsapp/events/undelivered.d.ts +8 -0
  242. package/plugins/interfaces/whatsapp/events/undelivered.js +17 -0
  243. package/plugins/interfaces/whatsapp/mod.d.ts +28 -2
  244. package/plugins/interfaces/whatsapp/mod.js +65 -6
  245. package/plugins/interfaces/whatsapp/processors/forget.d.ts +6 -0
  246. package/plugins/interfaces/whatsapp/processors/forget.js +11 -0
  247. package/plugins/interfaces/whatsapp/processors/receive.d.ts +17 -3
  248. package/plugins/interfaces/whatsapp/processors/receive.js +264 -81
  249. package/plugins/interfaces/whatsapp/processors/reply.d.ts +25 -5
  250. package/plugins/interfaces/whatsapp/processors/reply.js +216 -20
  251. package/plugins/interfaces/whatsapp/processors/typing.d.ts +8 -0
  252. package/plugins/interfaces/whatsapp/processors/typing.js +25 -0
  253. package/plugins/interfaces/whatsapp/shared/customers.d.ts +13 -0
  254. package/plugins/interfaces/whatsapp/shared/customers.js +16 -0
  255. package/plugins/interfaces/whatsapp/shared/graph.d.ts +31 -6
  256. package/plugins/interfaces/whatsapp/shared/graph.js +117 -10
  257. package/plugins/interfaces/whatsapp/shared/media.d.ts +23 -0
  258. package/plugins/interfaces/whatsapp/shared/media.js +46 -0
  259. package/plugins/interfaces/whatsapp/shared/number.d.ts +19 -8
  260. package/plugins/interfaces/whatsapp/shared/number.js +64 -7
  261. package/plugins/interfaces/whatsapp/shared/parts.d.ts +94 -0
  262. package/plugins/interfaces/whatsapp/shared/parts.js +184 -0
  263. package/plugins/interfaces/whatsapp/shared/payload.d.ts +27 -1
  264. package/plugins/interfaces/whatsapp/shared/payload.js +36 -1
  265. package/plugins/interfaces/whatsapp/shared/settings.d.ts +49 -1
  266. package/plugins/interfaces/whatsapp/shared/settings.js +11 -0
  267. package/plugins/interfaces/whatsapp/views/message.d.ts +13 -0
  268. package/plugins/interfaces/whatsapp/views/message.js +13 -0
  269. package/plugins/interfaces/whatsapp/views/web/line.d.ts +24 -0
  270. package/plugins/interfaces/whatsapp/views/web/line.js +44 -0
  271. package/plugins/interfaces/whatsapp/views/web/space.d.ts +7 -5
  272. package/plugins/interfaces/whatsapp/views/web/space.js +17 -10
  273. package/plugins/interfaces/whatsapp/views/web/style.d.ts +1 -1
  274. package/plugins/interfaces/whatsapp/views/web/style.js +8 -0
  275. package/plugins/models/adapters/llm/anthropic.d.ts +1 -1
  276. package/plugins/models/adapters/llm/anthropic.js +28 -15
  277. package/plugins/models/adapters/llm/gemini.d.ts +1 -1
  278. package/plugins/models/adapters/llm/gemini.js +2 -1
  279. package/plugins/models/adapters/llm/openai-compatible.d.ts +1 -1
  280. package/plugins/models/adapters/llm/openai-compatible.js +2 -1
  281. package/plugins/models/adapters/llm/openai.d.ts +1 -1
  282. package/plugins/models/adapters/llm/openai.js +16 -4
  283. package/plugins/models/shared/types.d.ts +8 -0
  284. package/plugins/models/shared/types.js +10 -0
  285. package/runtime/actor.d.ts +6 -0
  286. package/runtime/actor.js +9 -4
  287. package/runtime/aggregate.js +8 -2
  288. package/runtime/blobs.d.ts +15 -12
  289. package/runtime/blobs.js +58 -11
  290. package/runtime/cache.d.ts +6 -0
  291. package/runtime/cache.js +19 -1
  292. package/runtime/define.d.ts +10 -0
  293. package/runtime/errors.d.ts +20 -2
  294. package/runtime/errors.js +7 -1
  295. package/runtime/executor.js +27 -11
  296. package/runtime/links.d.ts +31 -0
  297. package/runtime/links.js +60 -0
  298. package/runtime/maintain.d.ts +88 -0
  299. package/runtime/maintain.js +120 -0
  300. package/runtime/memory.js +7 -4
  301. package/runtime/mod.d.ts +6 -4
  302. package/runtime/mod.js +5 -2
  303. package/runtime/mongo.d.ts +13 -0
  304. package/runtime/mongo.js +39 -8
  305. package/runtime/observe.d.ts +2 -0
  306. package/runtime/observe.js +14 -10
  307. package/runtime/ops.d.ts +5 -0
  308. package/runtime/ops.js +10 -1
  309. package/runtime/owner.d.ts +18 -1
  310. package/runtime/owner.js +127 -61
  311. package/runtime/presence.d.ts +18 -0
  312. package/runtime/presence.js +25 -0
  313. package/runtime/registry.d.ts +5 -0
  314. package/runtime/registry.js +18 -0
  315. package/runtime/runtime.js +9 -3
  316. package/runtime/store.d.ts +48 -1
  317. package/runtime/wire.d.ts +1 -0
  318. package/runtime/wire.js +3 -1
  319. package/stores/blobs/files/mod.js +4 -2
  320. package/stores/blobs/gcs/mod.d.ts +3 -0
  321. package/stores/blobs/gcs/mod.js +6 -5
  322. package/stores/blobs/http/mod.d.ts +1 -1
  323. package/stores/blobs/http/mod.js +2 -1
  324. package/stores/latency/mod.js +5 -1
  325. package/stores/sql/postgres/maintenance.d.ts +24 -0
  326. package/stores/sql/postgres/maintenance.js +258 -0
  327. package/stores/sql/postgres/mod.d.ts +20 -4
  328. package/stores/sql/postgres/mod.js +363 -96
  329. package/stores/sql/postgres/update.js +3 -1
  330. package/stores/sql/shared/capped.d.ts +2 -0
  331. package/stores/sql/shared/capped.js +22 -0
  332. package/stores/sql/shared/rows.d.ts +14 -0
  333. package/stores/sql/shared/rows.js +29 -0
  334. package/stores/sql/shared/statement.d.ts +12 -0
  335. package/stores/sql/shared/statement.js +244 -0
  336. package/stores/sql/sqlite/apart.d.ts +11 -0
  337. package/stores/sql/sqlite/apart.js +219 -0
  338. package/stores/sql/sqlite/mod.d.ts +16 -2
  339. package/stores/sql/sqlite/mod.js +246 -51
  340. package/testing/mod.js +1 -1
@@ -109,6 +109,29 @@ declare const messageSchema: {
109
109
  readonly stopped: {
110
110
  readonly type: "boolean";
111
111
  };
112
+ /**
113
+ * What it answers by a tap, not typed: the choice tapped (`id`: what it
114
+ * means, as the app gave it; its text is the `title`, what was read), and
115
+ * the addition it was in (`key`). A choice, not a permission: anyone can
116
+ * send any id, and agents read it as it came (`[tapped: <id>]`), so a
117
+ * tool acting on one checks it against what was shown there (`shown`, or
118
+ * the app's own record of what it offered).
119
+ */
120
+ readonly tap: {
121
+ readonly type: "object";
122
+ readonly properties: {
123
+ readonly id: {
124
+ readonly type: "string";
125
+ };
126
+ readonly title: {
127
+ readonly type: "string";
128
+ };
129
+ readonly key: {
130
+ readonly type: "string";
131
+ };
132
+ };
133
+ readonly required: readonly ["id"];
134
+ };
112
135
  /**
113
136
  * How a person's message came, when not typed there: sent for them by what
114
137
  * they set up (a routine). It's still theirs; people and agents are told.
@@ -178,6 +201,15 @@ declare const messageSchema: {
178
201
  readonly required: readonly ["name", "text"];
179
202
  };
180
203
  };
204
+ /**
205
+ * An agent's answer: how far its turn had read its thread (the `at` of the
206
+ * newest message there then). What others said there after that, while it
207
+ * wrote, it reads after the answer; a person's message it had read is
208
+ * answered by it.
209
+ */
210
+ readonly knew: {
211
+ readonly type: "string";
212
+ };
181
213
  readonly at: {
182
214
  readonly type: "string";
183
215
  };
@@ -294,6 +326,29 @@ export declare const message: {
294
326
  readonly stopped: {
295
327
  readonly type: "boolean";
296
328
  };
329
+ /**
330
+ * What it answers by a tap, not typed: the choice tapped (`id`: what it
331
+ * means, as the app gave it; its text is the `title`, what was read), and
332
+ * the addition it was in (`key`). A choice, not a permission: anyone can
333
+ * send any id, and agents read it as it came (`[tapped: <id>]`), so a
334
+ * tool acting on one checks it against what was shown there (`shown`, or
335
+ * the app's own record of what it offered).
336
+ */
337
+ readonly tap: {
338
+ readonly type: "object";
339
+ readonly properties: {
340
+ readonly id: {
341
+ readonly type: "string";
342
+ };
343
+ readonly title: {
344
+ readonly type: "string";
345
+ };
346
+ readonly key: {
347
+ readonly type: "string";
348
+ };
349
+ };
350
+ readonly required: readonly ["id"];
351
+ };
297
352
  /**
298
353
  * How a person's message came, when not typed there: sent for them by what
299
354
  * they set up (a routine). It's still theirs; people and agents are told.
@@ -363,6 +418,15 @@ export declare const message: {
363
418
  readonly required: readonly ["name", "text"];
364
419
  };
365
420
  };
421
+ /**
422
+ * An agent's answer: how far its turn had read its thread (the `at` of the
423
+ * newest message there then). What others said there after that, while it
424
+ * wrote, it reads after the answer; a person's message it had read is
425
+ * answered by it.
426
+ */
427
+ readonly knew: {
428
+ readonly type: "string";
429
+ };
366
430
  readonly at: {
367
431
  readonly type: "string";
368
432
  };
@@ -376,6 +440,7 @@ export declare const message: {
376
440
  private?: string[];
377
441
  queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
378
442
  [x: string]: unknown;
443
+ private?: boolean | undefined;
379
444
  failed?: boolean | undefined;
380
445
  via?: {
381
446
  [x: string]: unknown;
@@ -401,7 +466,6 @@ export declare const message: {
401
466
  size: number;
402
467
  }[] | undefined;
403
468
  toolCalls?: unknown[] | undefined;
404
- private?: boolean | undefined;
405
469
  replyTo?: string | undefined;
406
470
  expectReply?: boolean | undefined;
407
471
  subthread?: string | undefined;
@@ -410,6 +474,12 @@ export declare const message: {
410
474
  in?: string | undefined;
411
475
  sources?: string[] | undefined;
412
476
  stopped?: boolean | undefined;
477
+ tap?: {
478
+ [x: string]: unknown;
479
+ key?: string | undefined;
480
+ title?: string | undefined;
481
+ id: string;
482
+ } | undefined;
413
483
  back?: {
414
484
  [x: string]: unknown;
415
485
  from?: string | undefined;
@@ -421,6 +491,7 @@ export declare const message: {
421
491
  name: string;
422
492
  text: string;
423
493
  }[] | undefined;
494
+ knew?: string | undefined;
424
495
  from: string;
425
496
  to: string[];
426
497
  at: string;
@@ -433,4 +504,6 @@ export declare const message: {
433
504
  export type Message = Infer<typeof messageSchema> & {
434
505
  _id: string;
435
506
  };
507
+ /** Whether a message is an agent's final answer in its turn (`<run>:reply`), one that didn't fail. */
508
+ export declare const isAnswer: (m: Pick<Message, "_id" | "turn" | "failed" | "stopped">) => boolean;
436
509
  export {};
@@ -59,6 +59,19 @@ const messageSchema = {
59
59
  sources: { type: "array", items: { type: "string" } },
60
60
  /** Its turn was stopped (`chat.stop`): what it had written so far. */
61
61
  stopped: { type: "boolean" },
62
+ /**
63
+ * What it answers by a tap, not typed: the choice tapped (`id`: what it
64
+ * means, as the app gave it; its text is the `title`, what was read), and
65
+ * the addition it was in (`key`). A choice, not a permission: anyone can
66
+ * send any id, and agents read it as it came (`[tapped: <id>]`), so a
67
+ * tool acting on one checks it against what was shown there (`shown`, or
68
+ * the app's own record of what it offered).
69
+ */
70
+ tap: {
71
+ type: "object",
72
+ properties: { id: { type: "string" }, title: { type: "string" }, key: { type: "string" } },
73
+ required: ["id"],
74
+ },
62
75
  /**
63
76
  * How a person's message came, when not typed there: sent for them by what
64
77
  * they set up (a routine). It's still theirs; people and agents are told.
@@ -103,6 +116,13 @@ const messageSchema = {
103
116
  required: ["name", "text"],
104
117
  },
105
118
  },
119
+ /**
120
+ * An agent's answer: how far its turn had read its thread (the `at` of the
121
+ * newest message there then). What others said there after that, while it
122
+ * wrote, it reads after the answer; a person's message it had read is
123
+ * answered by it.
124
+ */
125
+ knew: { type: "string" },
106
126
  at: { type: "string" },
107
127
  },
108
128
  required: ["thread", "from", "to", "at"],
@@ -167,7 +187,7 @@ export const message = defineCollection({
167
187
  },
168
188
  /** Questions to `person` that an agent is still waiting on, newest first. */
169
189
  questions: {
170
- allow: (actor, params) => actor.id === params.person,
190
+ allow: (actor, params) => actor.kind === "person" && actor.id === params.person,
171
191
  run: async (messages, params, ctx) => {
172
192
  const asked = await messages.find({ to: params.person, replyTo: { $exists: false }, expectReply: { $ne: false } }, { sort: { at: -1 }, limit: 20 });
173
193
  const waits = ctx.db.collection("wait");
@@ -177,3 +197,5 @@ export const message = defineCollection({
177
197
  },
178
198
  },
179
199
  });
200
+ /** Whether a message is an agent's final answer in its turn (`<run>:reply`), one that didn't fail. */
201
+ export const isAnswer = (m) => !!m.turn && m._id === `${m.turn}:reply` && !m.failed && !m.stopped;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * What went out after agents' answers, beyond what they wrote (additions: a
3
+ * carousel of trips, buttons to pay): each addition once per chat per key
4
+ * (`<thread>:<key>`), with the answer it followed, the medium it went by, a
5
+ * line for the model (`note`), and whether its fallback went instead
6
+ * (`fallback`: Meta refused the carousel, its text list went). A ledger: no
7
+ * events, and writing one again changes nothing, so a retried delivery
8
+ * shows nothing twice. Part of its chat: who reaches the chat reads it.
9
+ */
10
+ import { type Infer } from "../../../../runtime/mod.js";
11
+ declare const shownSchema: {
12
+ readonly type: "object";
13
+ readonly properties: {
14
+ readonly thread: {
15
+ readonly type: "string";
16
+ };
17
+ /** The chat's space. */
18
+ readonly in: {
19
+ readonly type: "string";
20
+ };
21
+ /** The addition's key: `trips:9f2a`. */
22
+ readonly key: {
23
+ readonly type: "string";
24
+ };
25
+ /** The answer it went after. */
26
+ readonly after: {
27
+ readonly type: "string";
28
+ };
29
+ /** How it went: `whatsapp`. */
30
+ readonly medium: {
31
+ readonly type: "string";
32
+ };
33
+ readonly fallback: {
34
+ readonly type: "boolean";
35
+ };
36
+ /** What the model is told it was: "6 trips as a carousel". */
37
+ readonly note: {
38
+ readonly type: "string";
39
+ };
40
+ readonly at: {
41
+ readonly type: "string";
42
+ };
43
+ };
44
+ readonly required: readonly ["thread", "key", "after", "medium", "at"];
45
+ };
46
+ export declare const shown: {
47
+ schema: {
48
+ readonly type: "object";
49
+ readonly properties: {
50
+ readonly thread: {
51
+ readonly type: "string";
52
+ };
53
+ /** The chat's space. */
54
+ readonly in: {
55
+ readonly type: "string";
56
+ };
57
+ /** The addition's key: `trips:9f2a`. */
58
+ readonly key: {
59
+ readonly type: "string";
60
+ };
61
+ /** The answer it went after. */
62
+ readonly after: {
63
+ readonly type: "string";
64
+ };
65
+ /** How it went: `whatsapp`. */
66
+ readonly medium: {
67
+ readonly type: "string";
68
+ };
69
+ readonly fallback: {
70
+ readonly type: "boolean";
71
+ };
72
+ /** What the model is told it was: "6 trips as a carousel". */
73
+ readonly note: {
74
+ readonly type: "string";
75
+ };
76
+ readonly at: {
77
+ readonly type: "string";
78
+ };
79
+ };
80
+ readonly required: readonly ["thread", "key", "after", "medium", "at"];
81
+ };
82
+ events?: boolean;
83
+ records?: boolean;
84
+ durable?: false;
85
+ indexes?: string[][];
86
+ private?: string[];
87
+ queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
88
+ [x: string]: unknown;
89
+ fallback?: boolean | undefined;
90
+ note?: string | undefined;
91
+ in?: string | undefined;
92
+ at: string;
93
+ key: string;
94
+ after: string;
95
+ medium: string;
96
+ thread: string;
97
+ } & {
98
+ _id: string;
99
+ }>> | undefined;
100
+ vectors?: string[];
101
+ };
102
+ export type AdditionShown = Infer<typeof shownSchema> & {
103
+ _id: string;
104
+ };
105
+ export {};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * What went out after agents' answers, beyond what they wrote (additions: a
3
+ * carousel of trips, buttons to pay): each addition once per chat per key
4
+ * (`<thread>:<key>`), with the answer it followed, the medium it went by, a
5
+ * line for the model (`note`), and whether its fallback went instead
6
+ * (`fallback`: Meta refused the carousel, its text list went). A ledger: no
7
+ * events, and writing one again changes nothing, so a retried delivery
8
+ * shows nothing twice. Part of its chat: who reaches the chat reads it.
9
+ */
10
+ import { defineCollection } from "../../../../runtime/mod.js";
11
+ const shownSchema = {
12
+ type: "object",
13
+ properties: {
14
+ thread: { type: "string" },
15
+ /** The chat's space. */
16
+ in: { type: "string" },
17
+ /** The addition's key: `trips:9f2a`. */
18
+ key: { type: "string" },
19
+ /** The answer it went after. */
20
+ after: { type: "string" },
21
+ /** How it went: `whatsapp`. */
22
+ medium: { type: "string" },
23
+ fallback: { type: "boolean" },
24
+ /** What the model is told it was: "6 trips as a carousel". */
25
+ note: { type: "string" },
26
+ at: { type: "string" },
27
+ },
28
+ required: ["thread", "key", "after", "medium", "at"],
29
+ };
30
+ export const shown = defineCollection({
31
+ schema: shownSchema,
32
+ records: true,
33
+ indexes: [["thread"]],
34
+ });
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * The chat plugin's contract: what plugins built on chat (memory, history,
3
3
  * spaces, computers) may import from it: the shapes of its documents and of
4
- * the resource kinds it reads (`agents`, `tools`, `context`, `roster`,
5
- * `agentSources`, `agentModel`; on the web, `conversation`, `home`, `toolViews`,
4
+ * the resource kinds it reads (`agents`, `tools`, `context`, `additions`,
5
+ * `roster`, `agentSources`, `agentModel`; on the web, `conversation`, `home`, `toolViews`,
6
6
  * `refusals` and `composerNotes`),
7
- * `tool()` to declare a tool, and what knowing agents takes (`agentsOf`,
8
- * `defaults`, `modelOf`, `agentsNamed`, `agentsShown`, `SEND`).
7
+ * `tool()` to declare a tool, its runner (`runTool`, `toolText`: how a turn
8
+ * runs one, for interfaces that run them for a model outside), and what
9
+ * knowing agents takes (`agentsOf`, `defaults`, `modelOf`, `agentsNamed`,
10
+ * `agentsShown`, `SEND`).
9
11
  * Everything else they reach through the runtime: its collections by name
10
12
  * (`message`, `thread`…), its queries (`thread.agents`: who answers in a
11
13
  * space, and what each agent is), its events (`message.created`,
@@ -14,12 +16,18 @@
14
16
  export type { File } from "./collections/file.js";
15
17
  export { FILE_CHARS, textual } from "./collections/file.js";
16
18
  export type { Live, LiveCall } from "./collections/live.js";
17
- export type { Message } from "./collections/message.js";
19
+ export { isAnswer, type Message } from "./collections/message.js";
20
+ export type { AdditionShown } from "./collections/shown.js";
18
21
  export type { Thread } from "./collections/thread.js";
19
22
  export type { Wait } from "./collections/wait.js";
20
- export type { Agent, ChatSettings, ComposerNote, ContextEntry, ConversationView, HomeView, Offer, Prompt, RefusalView, ShownCall, Step, Tool, ToolContext, ToolViews, Turn, } from "./shared/types.js";
23
+ export type { Addition, AdditionEntry, Agent, ChatSettings, ComposerNote, ContextEntry, ConversationView, HomeView, Offer, Prompt, RefusalView, ShownCall, Step, Tool, ToolAnnotations, ToolContext, ToolViews, Turn, } from "./shared/types.js";
21
24
  export { tool } from "./shared/types.js";
22
- export { principalOf } from "./shared/send.js";
25
+ /**
26
+ * Chat's tool runner, for whoever else runs the app's tools (a model
27
+ * outside, over MCP): a tool's input checked, run, and its result read as
28
+ * agents read it, exactly as a turn does (`runTool`, `toolText`).
29
+ */
30
+ export { runTool, type ToolAt, type ToolRun, toolText } from "./shared/tools.js";
23
31
  export { type Origin, originKey, originOf } from "./shared/origin.js";
24
32
  export type { AgentModel, AgentSource, Roster, RosterSource, Team } from "./shared/agents.js";
25
33
  /**
@@ -1,6 +1,12 @@
1
1
  export { FILE_CHARS, textual } from "./collections/file.js";
2
+ export { isAnswer } from "./collections/message.js";
2
3
  export { tool } from "./shared/types.js";
3
- export { principalOf } from "./shared/send.js";
4
+ /**
5
+ * Chat's tool runner, for whoever else runs the app's tools (a model
6
+ * outside, over MCP): a tool's input checked, run, and its result read as
7
+ * agents read it, exactly as a turn does (`runTool`, `toolText`).
8
+ */
9
+ export { runTool, toolText } from "./shared/tools.js";
4
10
  export { originKey, originOf } from "./shared/origin.js";
5
11
  /**
6
12
  * The app's agents (`agentsOf`), who of them answer new conversations
@@ -5,7 +5,9 @@
5
5
  *
6
6
  * How a conversation moves:
7
7
  * - A message addressed to agents records one `turn.requested` per agent, in
8
- * the message's own commit. Turns run keyed by thread and agent, so
8
+ * the message's own commit; or, sent with `quiet` (a customer writing in
9
+ * bursts), once its sender has been quiet that long (`chat.quiet`, by a
10
+ * timer each message sets again), answering them all at once. Turns run keyed by thread and agent, so
9
11
  * different agents work in parallel and each agent's turns stay in order.
10
12
  * - An agent's final answer goes back to whoever addressed it, as a reply.
11
13
  * - An agent that sent messages expecting replies stops, leaving a `wait`
@@ -15,8 +17,22 @@
15
17
  * reply to it.
16
18
  * - What an agent is writing shows as it comes: a `live` document per running
17
19
  * turn, kept in memory, swapped for the step or reply it became in one commit.
20
+ * - A step's tool calls are written (an `intent`) before any of them runs, and
21
+ * what each returns as it does: a retried turn goes on with those calls
22
+ * instead of asking its model again, so a call that returned never runs
23
+ * twice, and one cut short runs again as itself (`ctx.callId`, the key for
24
+ * what it does outside).
18
25
  * - A person moves a conversation to another space (`chat.move`), with
19
26
  * everything in it; not while an agent is writing in it.
27
+ * - A chat can be opened empty (`chat.open`), to share it with a contact
28
+ * (someone outside the org, who then writes there with `chat.send` and
29
+ * reaches only it); trusted code has an agent say a fixed message in one
30
+ * without a turn (`chat.say`: a payment confirmed), and erases one with
31
+ * everything in it (`chat.erase`: someone's data, gone).
32
+ * - After an agent's answer, a medium may show more (additions: a carousel
33
+ * of trips after the answer that found them), each once per chat per key,
34
+ * recorded in `shown` (`chat.shown`), and told to the model after that
35
+ * answer (`[then shown: …]`). A choice tapped comes with its id (`tap`).
20
36
  * - Threads record where they came from (`parent`). A fork (a subthread) sees
21
37
  * its parent's conversation up to the message it started at, through every
22
38
  * level, without copying it; a new thread starts from its first message.
@@ -41,7 +57,9 @@
41
57
  * - `tools`: { description, input?, run(input) };
42
58
  * - `agentSources`: { action }: `{ names }` in, the definitions of those the asker meets out;
43
59
  * - `roster`: { action }: `{ space }` in, `{ agents, default? }` out;
44
- * - `agentModel`: { action }: `{ agent, space? }` in, a model or null out.
60
+ * - `agentModel`: { action }: `{ agent, space? }` in, a model or null out;
61
+ * - `additions`: { order?, agents? }, each with an `addition:<name>` View in
62
+ * the medium that shows it, given `{ thread, answer }` (see `Addition`).
45
63
  */
46
64
  import { type Plugin } from "../../../runtime/mod.js";
47
65
  export * from "./contract.js";
@@ -5,7 +5,9 @@
5
5
  *
6
6
  * How a conversation moves:
7
7
  * - A message addressed to agents records one `turn.requested` per agent, in
8
- * the message's own commit. Turns run keyed by thread and agent, so
8
+ * the message's own commit; or, sent with `quiet` (a customer writing in
9
+ * bursts), once its sender has been quiet that long (`chat.quiet`, by a
10
+ * timer each message sets again), answering them all at once. Turns run keyed by thread and agent, so
9
11
  * different agents work in parallel and each agent's turns stay in order.
10
12
  * - An agent's final answer goes back to whoever addressed it, as a reply.
11
13
  * - An agent that sent messages expecting replies stops, leaving a `wait`
@@ -15,8 +17,22 @@
15
17
  * reply to it.
16
18
  * - What an agent is writing shows as it comes: a `live` document per running
17
19
  * turn, kept in memory, swapped for the step or reply it became in one commit.
20
+ * - A step's tool calls are written (an `intent`) before any of them runs, and
21
+ * what each returns as it does: a retried turn goes on with those calls
22
+ * instead of asking its model again, so a call that returned never runs
23
+ * twice, and one cut short runs again as itself (`ctx.callId`, the key for
24
+ * what it does outside).
18
25
  * - A person moves a conversation to another space (`chat.move`), with
19
26
  * everything in it; not while an agent is writing in it.
27
+ * - A chat can be opened empty (`chat.open`), to share it with a contact
28
+ * (someone outside the org, who then writes there with `chat.send` and
29
+ * reaches only it); trusted code has an agent say a fixed message in one
30
+ * without a turn (`chat.say`: a payment confirmed), and erases one with
31
+ * everything in it (`chat.erase`: someone's data, gone).
32
+ * - After an agent's answer, a medium may show more (additions: a carousel
33
+ * of trips after the answer that found them), each once per chat per key,
34
+ * recorded in `shown` (`chat.shown`), and told to the model after that
35
+ * answer (`[then shown: …]`). A choice tapped comes with its id (`tap`).
20
36
  * - Threads record where they came from (`parent`). A fork (a subthread) sees
21
37
  * its parent's conversation up to the message it started at, through every
22
38
  * level, without copying it; a new thread starts from its first message.
@@ -41,16 +57,25 @@
41
57
  * - `tools`: { description, input?, run(input) };
42
58
  * - `agentSources`: { action }: `{ names }` in, the definitions of those the asker meets out;
43
59
  * - `roster`: { action }: `{ space }` in, `{ agents, default? }` out;
44
- * - `agentModel`: { action }: `{ agent, space? }` in, a model or null out.
60
+ * - `agentModel`: { action }: `{ agent, space? }` in, a model or null out;
61
+ * - `additions`: { order?, agents? }, each with an `addition:<name>` View in
62
+ * the medium that shows it, given `{ thread, answer }` (see `Addition`).
45
63
  */
46
64
  import { definePlugin } from "../../../runtime/mod.js";
65
+ import { eraseAction } from "./actions/erase.js";
47
66
  import { forkAction } from "./actions/fork.js";
48
67
  import { moveAction } from "./actions/move.js";
68
+ import { openAction } from "./actions/open.js";
69
+ import { quietAction } from "./actions/quiet.js";
70
+ import { sayAction } from "./actions/say.js";
49
71
  import { sendAction } from "./actions/send.js";
72
+ import { shownAction } from "./actions/shown.js";
50
73
  import { stopAction } from "./actions/stop.js";
51
74
  import { file } from "./collections/file.js";
75
+ import { intent } from "./collections/intent.js";
52
76
  import { live } from "./collections/live.js";
53
77
  import { message } from "./collections/message.js";
78
+ import { shown } from "./collections/shown.js";
54
79
  import { thread } from "./collections/thread.js";
55
80
  import { wait } from "./collections/wait.js";
56
81
  import { turnRequested } from "./events/turn-requested.js";
@@ -67,7 +92,7 @@ export { lineage } from "./shared/lineage.js";
67
92
  export const chat = definePlugin({
68
93
  name: "chat",
69
94
  requires: ["models"],
70
- collections: { thread, message, wait, live, file },
95
+ collections: { thread, message, wait, live, file, intent, shown },
71
96
  views: {
72
97
  thread: { llm: prompt },
73
98
  participants: { llm: participants },
@@ -95,14 +120,28 @@ export const chat = definePlugin({
95
120
  },
96
121
  actions: {
97
122
  "chat.send": sendAction,
123
+ "chat.open": openAction,
124
+ "chat.say": sayAction,
125
+ "chat.quiet": quietAction,
126
+ "chat.shown": shownAction,
127
+ "chat.erase": eraseAction,
98
128
  "chat.fork": forkAction,
99
129
  "chat.stop": stopAction,
100
130
  "chat.move": moveAction,
101
131
  },
102
132
  events: { "turn.requested": turnRequested },
103
- // Conversations by title on Usage.
104
133
  resources: {
134
+ // Conversations by title on Usage.
105
135
  usageNames: { thread: { tag: "tags.thread", collection: "thread", field: "title" } },
136
+ // With the access plugin, chats live in spaces, and what's in a chat comes with it when it's
137
+ // shared on its own (with a contact): its messages, files and what's being written.
138
+ shared: {
139
+ thread: {},
140
+ message: { labels: true, part: "thread" },
141
+ file: { part: "thread" },
142
+ live: { part: "thread" },
143
+ shown: { part: "thread" },
144
+ },
106
145
  },
107
146
  processors: {
108
147
  "chat.turn": turnProcessor,
@@ -16,8 +16,12 @@ const failed = async (ctx, event) => {
16
16
  if (await messages.findOne({ _id: `${run}:reply` }))
17
17
  return;
18
18
  if (error.code === "cancelled") {
19
- const written = await ctx.db.collection("live").findOne({ _id: run });
20
- const text = written?.text ? `${written.text} (stopped)` : "(stopped)";
19
+ const [written, taking] = await Promise.all([
20
+ ctx.db.collection("live").findOne({ _id: run }),
21
+ ctx.db.collection("intent").findOne({ _id: run }),
22
+ ]);
23
+ // Text of a step it was taking stays that step's (the answer keeps it).
24
+ const text = written?.text && !taking ? `${written.text} (stopped)` : "(stopped)";
21
25
  return await answer(ctx, t, run, text, { stopped: true });
22
26
  }
23
27
  // The org's limit isn't the agent failing: it says what happened, and who can change it.
@@ -26,7 +30,13 @@ const failed = async (ctx, event) => {
26
30
  failed: true,
27
31
  });
28
32
  }
29
- await answer(ctx, t, run, `${t.agent} failed: ${error.message ?? "unknown error"}`, {
30
- failed: true,
31
- });
33
+ await answer(ctx, t, run, `${t.agent} failed: ${toldOf(error)}`, { failed: true });
32
34
  };
35
+ /** What anyone in the chat reads of a failure, a customer too. */
36
+ const FAILED = "something went wrong, so it couldn't answer. Try again in a moment.";
37
+ /**
38
+ * What went wrong, as people are told it: a missing key says who can add one;
39
+ * anything else (a provider's refusal and its body, a network error) is for
40
+ * whoever runs the app, and stays in the `processor.failed` event.
41
+ */
42
+ const toldOf = (error) => error.code === "key_missing" && error.message ? error.message : FAILED;
@@ -1,3 +1,3 @@
1
1
  /** An agent's turn: model calls and tool steps until it answers, or waits for replies. */
2
- import type { ProcessorDef } from "../../../../runtime/mod.js";
2
+ import { type ProcessorDef } from "../../../../runtime/mod.js";
3
3
  export declare const turnProcessor: ProcessorDef;