@agentshouse/mdruntime 0.1.0-cec6690d5712e → 0.1.0-cedd665dffa4c

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 (392) hide show
  1. package/README.md +24 -19
  2. package/dist/acceptance.d.ts +3 -0
  3. package/dist/acceptance.d.ts.map +1 -0
  4. package/dist/acceptance.js +299 -0
  5. package/dist/act-lanes.d.ts +30 -0
  6. package/dist/act-lanes.d.ts.map +1 -0
  7. package/dist/act-lanes.js +225 -0
  8. package/dist/actions.d.ts +26 -0
  9. package/dist/actions.d.ts.map +1 -0
  10. package/dist/actions.js +302 -0
  11. package/dist/adapter.d.ts +207 -94
  12. package/dist/adapter.d.ts.map +1 -1
  13. package/dist/attached-model.d.ts +6 -10
  14. package/dist/attached-model.d.ts.map +1 -1
  15. package/dist/attached-model.js +35 -41
  16. package/dist/binary.d.ts +18 -0
  17. package/dist/binary.d.ts.map +1 -0
  18. package/dist/binary.js +8 -0
  19. package/dist/bootstrap.d.ts +31 -11
  20. package/dist/bootstrap.d.ts.map +1 -1
  21. package/dist/bootstrap.js +311 -92
  22. package/dist/cell.d.ts +6 -0
  23. package/dist/cell.d.ts.map +1 -0
  24. package/dist/cell.js +9 -0
  25. package/dist/chain.d.ts +12 -0
  26. package/dist/chain.d.ts.map +1 -0
  27. package/dist/chain.js +64 -0
  28. package/dist/change-set.d.ts +13 -14
  29. package/dist/change-set.d.ts.map +1 -1
  30. package/dist/change-set.js +17 -62
  31. package/dist/change.d.ts +46 -0
  32. package/dist/change.d.ts.map +1 -1
  33. package/dist/change.js +39 -0
  34. package/dist/chat-types.d.ts +3 -0
  35. package/dist/chat-types.d.ts.map +1 -0
  36. package/dist/chat-types.js +11 -0
  37. package/dist/client.d.ts +51 -27
  38. package/dist/client.d.ts.map +1 -1
  39. package/dist/client.js +133 -26
  40. package/dist/collection.d.ts +34 -9
  41. package/dist/collection.d.ts.map +1 -1
  42. package/dist/collection.js +55 -79
  43. package/dist/compile.d.ts +18 -0
  44. package/dist/compile.d.ts.map +1 -0
  45. package/dist/compile.js +723 -0
  46. package/dist/connection.d.ts +8 -111
  47. package/dist/connection.d.ts.map +1 -1
  48. package/dist/connection.js +113 -2221
  49. package/dist/context.d.ts +2 -0
  50. package/dist/context.d.ts.map +1 -0
  51. package/dist/{chat/context.js → context.js} +2 -5
  52. package/dist/conversation-live.d.ts +150 -0
  53. package/dist/conversation-live.d.ts.map +1 -0
  54. package/dist/conversation-live.js +259 -0
  55. package/dist/conversation-row.d.ts +40 -0
  56. package/dist/conversation-row.d.ts.map +1 -0
  57. package/dist/conversation-row.js +66 -0
  58. package/dist/conversation.d.ts +84 -45
  59. package/dist/conversation.d.ts.map +1 -1
  60. package/dist/conversation.js +1118 -584
  61. package/dist/declaration.d.ts +10 -0
  62. package/dist/declaration.d.ts.map +1 -0
  63. package/dist/declaration.js +24 -0
  64. package/dist/digest.d.ts +7 -0
  65. package/dist/digest.d.ts.map +1 -0
  66. package/dist/digest.js +113 -0
  67. package/dist/discovery.d.ts +10 -0
  68. package/dist/discovery.d.ts.map +1 -0
  69. package/dist/discovery.js +150 -0
  70. package/dist/durability.d.ts +23 -1
  71. package/dist/durability.d.ts.map +1 -1
  72. package/dist/durability.js +9 -0
  73. package/dist/entry.d.ts +20 -0
  74. package/dist/entry.d.ts.map +1 -0
  75. package/dist/entry.js +161 -0
  76. package/dist/expectation.d.ts +26 -13
  77. package/dist/expectation.d.ts.map +1 -1
  78. package/dist/expectation.js +72 -19
  79. package/dist/failure.d.ts +3 -0
  80. package/dist/failure.d.ts.map +1 -1
  81. package/dist/failure.js +6 -0
  82. package/dist/figures.d.ts +49 -0
  83. package/dist/figures.d.ts.map +1 -0
  84. package/dist/figures.js +199 -0
  85. package/dist/file.d.ts +2 -19
  86. package/dist/file.d.ts.map +1 -1
  87. package/dist/file.js +8 -122
  88. package/dist/holdings.d.ts +29 -0
  89. package/dist/holdings.d.ts.map +1 -0
  90. package/dist/holdings.js +95 -0
  91. package/dist/host.d.ts +29 -4
  92. package/dist/host.d.ts.map +1 -1
  93. package/dist/host.js +179 -25
  94. package/dist/identity.d.ts +1 -0
  95. package/dist/identity.d.ts.map +1 -1
  96. package/dist/identity.js +3 -0
  97. package/dist/index.d.ts +42 -12
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +20 -2
  100. package/dist/install.d.ts +60 -0
  101. package/dist/install.d.ts.map +1 -0
  102. package/dist/install.js +537 -0
  103. package/dist/lifecycle.d.ts +7 -0
  104. package/dist/lifecycle.d.ts.map +1 -0
  105. package/dist/lifecycle.js +278 -0
  106. package/dist/listing.d.ts +52 -0
  107. package/dist/listing.d.ts.map +1 -0
  108. package/dist/listing.js +152 -0
  109. package/dist/live.d.ts +25 -0
  110. package/dist/live.d.ts.map +1 -0
  111. package/dist/live.js +206 -0
  112. package/dist/loaded.d.ts +5 -0
  113. package/dist/loaded.d.ts.map +1 -0
  114. package/dist/loaded.js +40 -0
  115. package/dist/locks.d.ts +7 -0
  116. package/dist/locks.d.ts.map +1 -0
  117. package/dist/locks.js +32 -0
  118. package/dist/lost.d.ts +5 -0
  119. package/dist/lost.d.ts.map +1 -0
  120. package/dist/lost.js +49 -0
  121. package/dist/media.d.ts +13 -0
  122. package/dist/media.d.ts.map +1 -0
  123. package/dist/media.js +269 -0
  124. package/dist/memory.d.ts +26 -8
  125. package/dist/memory.d.ts.map +1 -1
  126. package/dist/memory.js +307 -97
  127. package/dist/messages.d.ts +58 -0
  128. package/dist/messages.d.ts.map +1 -0
  129. package/dist/messages.js +162 -0
  130. package/dist/model.d.ts +11 -12
  131. package/dist/model.d.ts.map +1 -1
  132. package/dist/model.js +7 -15
  133. package/dist/models.d.ts +10 -0
  134. package/dist/models.d.ts.map +1 -0
  135. package/dist/models.js +153 -0
  136. package/dist/name.d.ts +4 -0
  137. package/dist/name.d.ts.map +1 -0
  138. package/dist/name.js +122 -0
  139. package/dist/observation.d.ts +42 -9
  140. package/dist/observation.d.ts.map +1 -1
  141. package/dist/observation.js +238 -33
  142. package/dist/opened.d.ts +22 -0
  143. package/dist/opened.d.ts.map +1 -0
  144. package/dist/opened.js +107 -0
  145. package/dist/opening.d.ts +4 -0
  146. package/dist/opening.d.ts.map +1 -0
  147. package/dist/opening.js +53 -0
  148. package/dist/outcome.d.ts +63 -5
  149. package/dist/outcome.d.ts.map +1 -1
  150. package/dist/outcome.js +70 -0
  151. package/dist/overlay.d.ts +21 -6
  152. package/dist/overlay.d.ts.map +1 -1
  153. package/dist/overlay.js +163 -187
  154. package/dist/page-metadata.d.ts +8 -0
  155. package/dist/page-metadata.d.ts.map +1 -0
  156. package/dist/page-metadata.js +19 -0
  157. package/dist/parts.d.ts +4 -0
  158. package/dist/parts.d.ts.map +1 -0
  159. package/dist/parts.js +13 -0
  160. package/dist/paths.d.ts +2 -0
  161. package/dist/paths.d.ts.map +1 -1
  162. package/dist/paths.js +26 -0
  163. package/dist/preparation.d.ts +41 -0
  164. package/dist/preparation.d.ts.map +1 -0
  165. package/dist/preparation.js +314 -0
  166. package/dist/presence.d.ts +58 -0
  167. package/dist/presence.d.ts.map +1 -0
  168. package/dist/presence.js +231 -0
  169. package/dist/queries.d.ts +16 -0
  170. package/dist/queries.d.ts.map +1 -0
  171. package/dist/queries.js +308 -0
  172. package/dist/query.d.ts +51 -183
  173. package/dist/query.d.ts.map +1 -1
  174. package/dist/query.js +3 -464
  175. package/dist/{chat/questions.d.ts → questions.d.ts} +5 -7
  176. package/dist/questions.d.ts.map +1 -0
  177. package/dist/{chat/questions.js → questions.js} +11 -7
  178. package/dist/queue.d.ts +40 -0
  179. package/dist/queue.d.ts.map +1 -0
  180. package/dist/queue.js +480 -0
  181. package/dist/reach.d.ts +20 -5
  182. package/dist/reach.d.ts.map +1 -1
  183. package/dist/reach.js +357 -80
  184. package/dist/react.d.ts +23 -7
  185. package/dist/react.d.ts.map +1 -1
  186. package/dist/react.js +40 -18
  187. package/dist/{chat/read.d.ts → read.d.ts} +2 -0
  188. package/dist/read.d.ts.map +1 -0
  189. package/dist/{chat/read.js → read.js} +4 -0
  190. package/dist/readiness.d.ts +55 -0
  191. package/dist/readiness.d.ts.map +1 -0
  192. package/dist/readiness.js +25 -0
  193. package/dist/reads.d.ts +39 -0
  194. package/dist/reads.d.ts.map +1 -0
  195. package/dist/reads.js +178 -0
  196. package/dist/recovery.d.ts +28 -0
  197. package/dist/recovery.d.ts.map +1 -0
  198. package/dist/recovery.js +254 -0
  199. package/dist/refresh.d.ts +17 -14
  200. package/dist/refresh.d.ts.map +1 -1
  201. package/dist/refresh.js +145 -58
  202. package/dist/refusal.d.ts +5 -0
  203. package/dist/refusal.d.ts.map +1 -0
  204. package/dist/refusal.js +55 -0
  205. package/dist/replica.d.ts +53 -33
  206. package/dist/replica.d.ts.map +1 -1
  207. package/dist/replica.js +349 -167
  208. package/dist/retried.d.ts +30 -0
  209. package/dist/retried.d.ts.map +1 -0
  210. package/dist/retried.js +72 -0
  211. package/dist/room-draft.d.ts +82 -11
  212. package/dist/room-draft.d.ts.map +1 -1
  213. package/dist/room-draft.js +490 -78
  214. package/dist/room-drafts.d.ts +24 -0
  215. package/dist/room-drafts.d.ts.map +1 -0
  216. package/dist/room-drafts.js +220 -0
  217. package/dist/rows.d.ts +31 -35
  218. package/dist/rows.d.ts.map +1 -1
  219. package/dist/rows.js +60 -126
  220. package/dist/runtime.d.ts +34 -0
  221. package/dist/runtime.d.ts.map +1 -0
  222. package/dist/runtime.js +1 -0
  223. package/dist/save.d.ts +45 -22
  224. package/dist/save.d.ts.map +1 -1
  225. package/dist/save.js +977 -215
  226. package/dist/saves.d.ts +32 -0
  227. package/dist/saves.d.ts.map +1 -0
  228. package/dist/saves.js +426 -0
  229. package/dist/search.d.ts +15 -55
  230. package/dist/search.d.ts.map +1 -1
  231. package/dist/search.js +10 -121
  232. package/dist/seed.d.ts +25 -0
  233. package/dist/seed.d.ts.map +1 -0
  234. package/dist/seed.js +145 -0
  235. package/dist/shared.d.ts +10 -0
  236. package/dist/shared.d.ts.map +1 -0
  237. package/dist/shared.js +339 -0
  238. package/dist/shown.d.ts +33 -0
  239. package/dist/shown.d.ts.map +1 -0
  240. package/dist/shown.js +309 -0
  241. package/dist/socket/admission.d.ts +7 -0
  242. package/dist/socket/admission.d.ts.map +1 -0
  243. package/dist/socket/admission.js +39 -0
  244. package/dist/socket/answers.d.ts +6 -0
  245. package/dist/socket/answers.d.ts.map +1 -0
  246. package/dist/socket/answers.js +20 -0
  247. package/dist/socket/lanes.d.ts +28 -0
  248. package/dist/socket/lanes.d.ts.map +1 -0
  249. package/dist/socket/lanes.js +103 -0
  250. package/dist/socket/reads.d.ts +10 -0
  251. package/dist/socket/reads.d.ts.map +1 -0
  252. package/dist/socket/reads.js +31 -0
  253. package/dist/socket/session.d.ts +38 -0
  254. package/dist/socket/session.d.ts.map +1 -0
  255. package/dist/socket/session.js +23 -0
  256. package/dist/socket.d.ts +67 -0
  257. package/dist/socket.d.ts.map +1 -0
  258. package/dist/socket.js +164 -0
  259. package/dist/source.d.ts +59 -0
  260. package/dist/source.d.ts.map +1 -0
  261. package/dist/source.js +93 -0
  262. package/dist/status.d.ts +5 -2
  263. package/dist/status.d.ts.map +1 -1
  264. package/dist/status.js +3 -7
  265. package/dist/store/installs.d.ts +30 -0
  266. package/dist/store/installs.d.ts.map +1 -0
  267. package/dist/store/installs.js +40 -0
  268. package/dist/store/readiness.d.ts +11 -0
  269. package/dist/store/readiness.d.ts.map +1 -0
  270. package/dist/store/readiness.js +68 -0
  271. package/dist/store/records.d.ts +217 -0
  272. package/dist/store/records.d.ts.map +1 -0
  273. package/dist/store/records.js +464 -0
  274. package/dist/store/room-held.d.ts +8 -0
  275. package/dist/store/room-held.d.ts.map +1 -0
  276. package/dist/store/room-held.js +17 -0
  277. package/dist/store/rooms-shown.d.ts +8 -0
  278. package/dist/store/rooms-shown.d.ts.map +1 -0
  279. package/dist/store/rooms-shown.js +13 -0
  280. package/dist/store/space.d.ts +11 -0
  281. package/dist/store/space.d.ts.map +1 -0
  282. package/dist/store/space.js +41 -0
  283. package/dist/store/watchers.d.ts +17 -0
  284. package/dist/store/watchers.d.ts.map +1 -0
  285. package/dist/store/watchers.js +56 -0
  286. package/dist/store/writes.d.ts +24 -0
  287. package/dist/store/writes.d.ts.map +1 -0
  288. package/dist/store/writes.js +125 -0
  289. package/dist/store.d.ts +114 -116
  290. package/dist/store.d.ts.map +1 -1
  291. package/dist/store.js +164 -494
  292. package/dist/stored.d.ts +167 -0
  293. package/dist/stored.d.ts.map +1 -0
  294. package/dist/stored.js +703 -0
  295. package/dist/surface.d.ts +89 -0
  296. package/dist/surface.d.ts.map +1 -0
  297. package/dist/surface.js +222 -0
  298. package/dist/sync.d.ts +19 -0
  299. package/dist/sync.d.ts.map +1 -0
  300. package/dist/sync.js +535 -0
  301. package/dist/tables.d.ts +419 -0
  302. package/dist/tables.d.ts.map +1 -0
  303. package/dist/tables.js +758 -0
  304. package/dist/tallies.d.ts +18 -0
  305. package/dist/tallies.d.ts.map +1 -0
  306. package/dist/tallies.js +128 -0
  307. package/dist/transfer.d.ts +0 -5
  308. package/dist/transfer.d.ts.map +1 -1
  309. package/dist/turn.d.ts +9 -0
  310. package/dist/turn.d.ts.map +1 -0
  311. package/dist/turn.js +75 -0
  312. package/dist/validation.d.ts +29 -0
  313. package/dist/validation.d.ts.map +1 -0
  314. package/dist/validation.js +98 -0
  315. package/dist/windows.d.ts +11 -0
  316. package/dist/windows.d.ts.map +1 -0
  317. package/dist/windows.js +16 -0
  318. package/dist/wire.d.ts +221 -34
  319. package/dist/wire.d.ts.map +1 -1
  320. package/dist/wire.js +74 -31
  321. package/package.json +28 -24
  322. package/AGENTS.md +0 -299
  323. package/dist/attachment.d.ts +0 -3
  324. package/dist/attachment.d.ts.map +0 -1
  325. package/dist/attachment.js +0 -8
  326. package/dist/attempt.d.ts +0 -16
  327. package/dist/attempt.d.ts.map +0 -1
  328. package/dist/attempt.js +0 -57
  329. package/dist/chat/acts.d.ts +0 -34
  330. package/dist/chat/acts.d.ts.map +0 -1
  331. package/dist/chat/acts.js +0 -36
  332. package/dist/chat/context.d.ts +0 -3
  333. package/dist/chat/context.d.ts.map +0 -1
  334. package/dist/chat/input.d.ts +0 -9
  335. package/dist/chat/input.d.ts.map +0 -1
  336. package/dist/chat/input.js +0 -99
  337. package/dist/chat/kit.d.ts +0 -60
  338. package/dist/chat/kit.d.ts.map +0 -1
  339. package/dist/chat/kit.js +0 -123
  340. package/dist/chat/lasting.d.ts +0 -6
  341. package/dist/chat/lasting.d.ts.map +0 -1
  342. package/dist/chat/lasting.js +0 -19
  343. package/dist/chat/list.d.ts +0 -20
  344. package/dist/chat/list.d.ts.map +0 -1
  345. package/dist/chat/list.js +0 -59
  346. package/dist/chat/markdown.d.ts +0 -19
  347. package/dist/chat/markdown.d.ts.map +0 -1
  348. package/dist/chat/markdown.js +0 -187
  349. package/dist/chat/message.d.ts +0 -6
  350. package/dist/chat/message.d.ts.map +0 -1
  351. package/dist/chat/message.js +0 -192
  352. package/dist/chat/messages.d.ts +0 -21
  353. package/dist/chat/messages.d.ts.map +0 -1
  354. package/dist/chat/messages.js +0 -151
  355. package/dist/chat/name.d.ts +0 -6
  356. package/dist/chat/name.d.ts.map +0 -1
  357. package/dist/chat/name.js +0 -37
  358. package/dist/chat/opened.d.ts +0 -11
  359. package/dist/chat/opened.d.ts.map +0 -1
  360. package/dist/chat/opened.js +0 -17
  361. package/dist/chat/overlay.d.ts +0 -31
  362. package/dist/chat/overlay.d.ts.map +0 -1
  363. package/dist/chat/overlay.js +0 -97
  364. package/dist/chat/parts.d.ts +0 -57
  365. package/dist/chat/parts.d.ts.map +0 -1
  366. package/dist/chat/parts.js +0 -119
  367. package/dist/chat/process.d.ts +0 -20
  368. package/dist/chat/process.d.ts.map +0 -1
  369. package/dist/chat/process.js +0 -32
  370. package/dist/chat/provider.d.ts +0 -63
  371. package/dist/chat/provider.d.ts.map +0 -1
  372. package/dist/chat/provider.js +0 -645
  373. package/dist/chat/question.d.ts +0 -9
  374. package/dist/chat/question.d.ts.map +0 -1
  375. package/dist/chat/question.js +0 -80
  376. package/dist/chat/questions.d.ts.map +0 -1
  377. package/dist/chat/read.d.ts.map +0 -1
  378. package/dist/chat/ready.d.ts +0 -33
  379. package/dist/chat/ready.d.ts.map +0 -1
  380. package/dist/chat/ready.js +0 -91
  381. package/dist/chat/style.d.ts +0 -4
  382. package/dist/chat/style.d.ts.map +0 -1
  383. package/dist/chat/style.js +0 -302
  384. package/dist/chat.d.ts +0 -14
  385. package/dist/chat.d.ts.map +0 -1
  386. package/dist/chat.js +0 -8
  387. package/dist/log.d.ts +0 -5
  388. package/dist/log.d.ts.map +0 -1
  389. package/dist/log.js +0 -14
  390. package/dist/read-side.d.ts +0 -18
  391. package/dist/read-side.d.ts.map +0 -1
  392. package/dist/read-side.js +0 -433
package/AGENTS.md DELETED
@@ -1,299 +0,0 @@
1
- # Instructions for the App Creator's agent
2
-
3
- These instructions address an agent in an environment with Git. Obtain the
4
- App Repository, change it, build, and push. They are documentation, not enforcement.
5
-
6
- ## The MD Runtime API
7
-
8
- App code reaches the MD Runtime through the remote client. The surfaces are
9
- Rooms, Query, Search, Observe, Types, Room Draft, Save, History, Call, Reached, Log,
10
- the reported persistence answer, reauthorization, conversation, the chat draft,
11
- and Presentation State. Sync Status, the Service Mode, the storage-loss
12
- statement, the deployment facts and the signed-in member are observations only.
13
-
14
- The host attaches each port with its reach, and every member and observation
15
- answers within it: a Room outside it answers as one the replica does not hold,
16
- Rooms lists only the Rooms reached whole, a Room reached for single Documents
17
- shows only those Documents and the Types of the models that govern them, and
18
- without conversations the conversation members, the chat draft and the
19
- conversation observation hold none.
20
- A change of the reach reaches every open observation as its new value, a query
21
- keeping every unchanged Document the same object.
22
-
23
- Every `observe` resolves, once its first value has arrived, to a handle:
24
- `current()` is the latest complete value, `subscribe(listener)` hears each later
25
- value whole and returns its unsubscribe, and `close()` ends the observation.
26
- Closing the port ends every handle and rejects every pending call and
27
- observation; a client that reconnects observes again.
28
-
29
- `observe('agents')` answers every Agent a new conversation can go to, each
30
- `{ identity, name }`, whether or not it has a conversation yet.
31
- Each conversation the Provider's conversation list names is held complete in the
32
- browser. `conversation.list()` and `observe('conversations')` answer each with its
33
- Agent's identity and name, its name, created and finished times, last outcome and live
34
- `state`: `asking` while a question waits, `working` while a turn runs, else `idle`,
35
- and `started`, when the running turn began, or `null`.
36
- Observe one with `observe('conversation', id, { limit })`: the view
37
- holds its latest `limit` messages, or all of them, oldest first, its chat
38
- draft, and what the Provider streams for it whether or not anything views it:
39
- the running `turn` with its message parts and its context in use and window, the
40
- open questions, the process state, and the CLI's commands and options. These live
41
- only in memory: the message accepted under the turn's id replaces the running turn,
42
- and none of them is stored or searchable.
43
- `chatDraft.write` and `chatDraft.discard` keep what the App Creator composes;
44
- sending it is a Provider Action that needs the Provider reachable and is never
45
- queued.
46
-
47
- Each Room in Rooms lists its `attachments`, the files the Provider holds for it
48
- that its Documents link by the Provider's reference, ordered by `reference`,
49
- each with `name`, `byteLength`, `mediaType` and the Provider's own entry as
50
- `entry`. They are as the Provider last declared them and hold no bytes;
51
- open one through the Provider Action that serves it.
52
-
53
- Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never
54
- touch the network.
55
- History and Call go to the Provider through the Adapter. Call takes the Action names
56
- the Adapter declares; any other name answers `undeclared` without reaching the
57
- Provider. A Call result whose
58
- effect the Provider places in a Room carries `at`, that Room and Room Version;
59
- `reached(room, roomVersion)` answers whether the Room's confirmed state has
60
- reached it, and the MD Runtime keeps refreshing that Room until it has;
61
- `reached(room, roomVersion, path)` answers whether the held confirmed copy of
62
- that document was written at a later Room Version. Each History revision
63
- names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`.
64
- History of a Path no current document holds answers the removed document's
65
- revisions with `deleted: true`, newest first; that revision is what a link to
66
- the Path opens. Every
67
- member of the
68
- client is asynchronous. Results are detached snapshots. Nothing in this
69
- surface returns the authorization, performs a request the App's code
70
- composes, or exposes the browser store.
71
-
72
- Every refusal and failure carries `code` and `retryable`: each Call and History answer
73
- other than its result, a refused Save or Room Draft write, a returned Room Draft's
74
- reason, a Room's refusal and the Connection Refusal, and every error a member rejects
75
- with, beside its message. A Provider refusal carries the Provider's own `retryable`.
76
- Every code and every value the API answers is open: handle one you do not know by its
77
- `code` and `retryable`.
78
-
79
- Read the deployment facts with `observe('deployment-facts')`. Interpret the
80
- opaque value using the host's contract.
81
-
82
- `observe('member')` answers who uses the App: the User the Provider signed in,
83
- `{ kind: 'user', id, name }` in the shape of a change's `author`, so a Document
84
- whose `change.author.id` equals its `id` is that User's own. It is `null` until
85
- the Provider first names one, and where it names none, such as a Site. The
86
- MD Runtime keeps it with the Local Replicas, so it answers offline once known,
87
- and every port hears the next member the Provider names; signing out answers
88
- `null`, then ends the observation with the authorization. It is the only way App code learns who
89
- uses it.
90
-
91
- The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
92
- ships in no bundle.
93
-
94
- ## Local Query rules
95
-
96
- `query(q)` answers once from local state; `observe('query', q)` holds the whole
97
- result and hears it again only when it changes, keeping every unchanged Document
98
- the same object, so a component can tell what changed by identity. A query is
99
- data:
100
-
101
- - **Filter.** `rooms` names Room locators and defaults to every Room. `types`
102
- names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
103
- directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
104
- - **Fields.** Every frontmatter value is named by JSON Pointer: `/status`,
105
- `/shipping/city`, `~1` for a `/` and `~0` for a `~` in a key. A segment that
106
- meets a list applies to every item and a number names one item. `where` names
107
- pointers, ANDs them, and nests `$and` and `$or`; a pointer through a list holds
108
- when any item satisfies it. A bare value is equality; the operators are `$eq`,
109
- `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and
110
- `$exists`. Equality on a list asks whether it contains the value. Missing, null and empty differ:
111
- `$exists: false` keeps a missing field, `null` an explicit null, `''` empty
112
- text and `$size: 0` an empty list. A date compares in calendar order and never
113
- with a date-time. A reference compares by the Room Path it resolves to.
114
- Untyped frontmatter, and a value under `oneOf` or a conditional, is plain
115
- values. There is no text containment or regular
116
- expression.
117
- - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
118
- reference at pointer `field`, at any depth, points to a matching Document of the
119
- same Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
120
- matching Document of the same Room references. Each keeps a Document once.
121
- - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
122
- `preamble`, `markdown`, `backlinks` and `change`, where `fields` is `'all'` or a
123
- list of pointers and `sections` `'all'` or a list of names. Selected pointers
124
- return the frontmatter holding only them, nested as written. A backlink names
125
- the referring Path, MD Type and the pointer it came from as `field`. Room and Path always return; a Markdown
126
- Document also returns its MD Type. A non-Markdown Document or binary link
127
- target returns only Room and Path. An unselected part is absent. Select only
128
- what a screen shows: a list that selects the Markdown hears every edit of it.
129
- - **Change.** `change` is `{ author, time }` of the Document's head revision as
130
- the Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }`
131
- or `null` for a write the Provider made itself, and `time` is the Provider's
132
- ISO 8601 change time. It is `null` where the Provider delivered no time, as at
133
- a Site. An unsent edit or move keeps it, an unsent creation has none, and a
134
- saved write takes the Provider's own once it is Accepted. A
135
- Room's last change is its Document with the latest `time`.
136
- - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
137
- with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
138
- `room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
139
- over every match and ordered by `count` or a key. A sort or group takes only a
140
- pointer that holds one value. `limit` bounds the Documents or the groups.
141
- - **Results and errors.** A result carries no Room Version: read freshness from
142
- Rooms and Sync Status. An invalid query fails with the `code`
143
- `invalid-query`, `unknown-type`, `unknown-field` or `wrong-kind`, naming where,
144
- and never answers an empty result in its place.
145
-
146
- ## Local Search rules
147
-
148
- `search({ text, documents, conversations, limit })` answers once, by words, from
149
- local state, with MiniSearch at its default configuration. There is no observed
150
- search.
151
-
152
- - **What is found.** A Document by its field values, its sections' headings and
153
- text, its preamble and its Path; a message by its text. Frontmatter keys, Room
154
- Drafts, chat drafts and a running turn's parts are never found. There are no phrases,
155
- word forms, typo tolerance or prefix matching.
156
- - **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
157
- `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
158
- apply before `limit`, which bounds each list; without it every hit returns.
159
- - **Results.** `{ documents, messages }`, each ranked by `score`, which compares
160
- hits of one list of one search. A Document hit names its `room`, `path` and
161
- `type`, a message hit its `conversation` and `identity`, and `matches` maps each
162
- matched word to the parts it matched in: `fields`, `sections`, `preamble` or
163
- `path`, or `text`. A hit carries no position; mark the words in the text you
164
- show. An invalid filter fails with its Local Query error.
165
-
166
- ## Room Draft, Save, and outcome rules
167
-
168
- The MD Runtime owns one Room Draft per Room and Path, shared by every App and
169
- tab. It is durable: it survives reload and navigation. A Room that Discovery
170
- stops listing takes its Room Drafts and its queue with it.
171
- Write a Room Draft with `roomDraft.write(room, path, revision, parts)`, naming
172
- the revision you read, or `null` when there was none, and every part it should
173
- now change: fields, sections and the preamble, or the whole Markdown, a
174
- creation, a move, or a removal. A part new to the Room Draft names its base,
175
- the value you showed when it was opened; the MD Runtime keeps a part's first
176
- base. A binary link target has a Room Draft too, for a move or a removal, with
177
- `null` as its base. A write or a discard from an older revision is refused as `stale` with
178
- the current Room Draft; read it and write again.
179
-
180
- Save takes one Room and the Room Drafts of it to save, each with its revision,
181
- validates locally, and on success appends one Change Batch to that Room's
182
- queue and removes those Room Drafts. It is refused with the `code` `stale`,
183
- `changed-underneath` naming each part whose base no longer matches the visible
184
- state, or a local validation rule, and then creates nothing and leaves every
185
- Room Draft in place. A directory move or removal is a move or removal part on
186
- each Document and binary link target beneath it, saved together.
187
-
188
- Outcomes follow the Provider's answer. An Accepted Change Batch stays in the
189
- queue, drawn over the confirmed layer, until the confirmed layer reaches the
190
- Room Version it was accepted at, and then leaves it. Conflicted and Rejected, an expired operation, and a change that no
191
- longer applies over the Room each leave the queue and return as Room Drafts on
192
- the Documents they changed, marked with why: the Provider's structured refusal
193
- code and fields as returned, not known to have applied, or withdrawn locally.
194
- The rest of the queue keeps synchronizing, and Sync Status requires attention
195
- until each returned Room Draft is saved again or discarded. A Change Batch
196
- keeps no outcome once it leaves the queue; `observe('queue', room)` shows each
197
- Pending one, and a returned Room Draft says why it returned. Transport
198
- failure and Provider unavailability keep work Pending and do not infer a
199
- rejection. A refusal the Provider marks retryable stays Pending until the reset
200
- it names; the MD Runtime retries the same Change Batch identity and payload and
201
- never infers an outcome from transport uncertainty. The MD Runtime never
202
- combines, reorders, or rebases.
203
-
204
- On a Site, every Save stays in the visitor's browser. Write grants and
205
- revisions do not refuse it, and its Pending Change shows in every query and
206
- across reloads until the browser's storage is cleared. It is never sent:
207
- `observe('queue', room)` shows it `local`, and Sync Status never waits on it.
208
- Once the Room changes so that it no longer applies, it leaves the queue and
209
- returns no Room Draft.
210
-
211
- `observe('service-mode')` answers the Provider's Service
212
- Mode, `open` or `write-halted`. While writes are halted, Save still succeeds,
213
- its Change Batch waits unsent, and the queue is submitted in order once the
214
- Provider reopens writes. An Action is never held: a write the Provider refuses
215
- for the halt returns that refusal to its caller. Show the Provider as read-only
216
- instead of retrying.
217
-
218
- ## The neutrality rule
219
-
220
- No module outside an Adapter package imports, names, or special-cases a
221
- Provider. MD UI and every App reach data only through the client entry.
222
-
223
- ## Content-safety rules
224
-
225
- The Provider authorization belongs to the Runtime host and is never readable
226
- by the App's code. The App's code reaches the network only at the external
227
- origins its manifest declares, empty by default, and the Provider enforces
228
- that set. Every request to the Provider itself goes through the MD Runtime.
229
- Rendered Markdown never executes scripts, renders raw HTML only for the
230
- details and summary elements, and loads images and other resources only from
231
- origins the Provider's policy allows.
232
-
233
- ## Launch promises MD UI keeps
234
-
235
- MD UI uses semantic HTML, is fully operable from a keyboard with visible
236
- focus and labelled controls, and lays out from a 360 pixel wide viewport to
237
- a desktop. Its strings are English only, dates and numbers follow the
238
- browser locale, and content is never translated. Light and dark themes come
239
- from CSS custom properties with the browser's preference as the default and
240
- an App's override respected. What an App Creator's agent adds carries none
241
- of these promises by itself. Reading, querying and searching never wait for
242
- the network. Data lives only in the App Creator's browser and with the Provider.
243
-
244
- ## App code takes the client its host hands it and never constructs a Runtime
245
-
246
- App code takes the client its host hands it: in House, `houseBridge().runtime`
247
- from `@agentshouse/app-bridge` resolves to the client House built into the page.
248
- It never constructs a Runtime or a client. It imports only types from
249
- `@agentshouse/mdruntime/client`, does not call `connectMdRuntime` or
250
- `serveMdRuntime`, and does not import the package main, the host entry, or the
251
- Adapter package. Hosts and tests use those entries; the served App does not.
252
-
253
- A React App may observe and save through `@agentshouse/mdruntime/react`, which
254
- names React as a peer dependency. `useObserve(client, topic, ...input)` takes
255
- the arguments of `observe` and returns `{ state: 'loading' }` until the topic's
256
- first value arrives, then `{ state: 'ready', value }`, re-rendering on each
257
- change; a `null` client observes nothing and stays loading. `useSave(client)`
258
- returns `busy`, the last `outcome` or `failure`, and `save(room, roomDrafts)`,
259
- which writes each Path's parts onto the Room Draft already there, keeping the
260
- bases its parts have, or onto a new one, and saves them together. A refused
261
- Save leaves the Room Drafts for the App to save again or discard; a failure is
262
- recorded and rejects. `saveRoomDrafts(client, room, roomDrafts)` is that save
263
- outside a component. A react-admin or Refine App reads and writes its Rooms
264
- through the data providers of `@agentshouse/mdruntime-families`.
265
-
266
- ## The Chat
267
-
268
- `@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App.
269
- Its required peers are React, React DOM and `@assistant-ui/react`: add React as
270
- a dependency, also in an App not written in React.
271
-
272
- Place the ready chat with `<Chat client={runtime} conversation={id}
273
- agent={agent} width="1/3" showChats />`: `conversation` opens one, `null` for a
274
- new chat, `agent` is the Agent a new chat goes to, `onOpen` hears each one it
275
- opens, and `width` is `full` (the place you give it), or `3/4`, `1/2` or `1/3`
276
- of the window docked at its right edge, whole on a narrow window. `showChats`
277
- adds its conversation list; or draw your own inside a `ChatProvider` around a
278
- `<Chat />` with no `client`. It carries its own styles; theme it with CSS custom
279
- properties on it or an ancestor: `--chat-background`, `--chat-surface`,
280
- `--chat-text`, `--chat-text-muted`, `--chat-accent`, `--chat-line`,
281
- `--chat-attention`, `--chat-danger`, `--chat-font`, `--chat-font-mono`,
282
- `--chat-font-size`, `--chat-radius` and `--chat-density` (a factor for spacing);
283
- an unset one keeps House's light or dark look. `mountChat(element, { client })`
284
- places it outside React and returns `update(props)` and `unmount()`.
285
-
286
- Mix `ChatMessageList` (`components` takes your `UserMessage` and
287
- `AssistantMessage`), `ChatInput` and `ChatQuestionCard` with your own design
288
- inside a `ChatProvider`, or compose assistant-ui's primitives there; `useChat()`
289
- gives `send`, the conversations, the Agents, questions to `answer`, `options`
290
- to `choose`, `commands`, the queue to `edit` or `unqueue`, `stop`, `kill` and
291
- outcomes; never replace its messages, sending or store. A secret question is
292
- never answered here; typed answers live in Presentation State's `typed` key:
293
- keep it, and change Presentation State only inside `inTurn(client, work)` from
294
- `@agentshouse/mdruntime/client`. `Markdown` draws Markdown safely.
295
-
296
- ## What an agent must never do
297
-
298
- An agent must never read the authorization, load code from a Room, call the
299
- Provider directly, or rebase a refused Change Batch.
@@ -1,3 +0,0 @@
1
- import type { RoomAttachment } from './adapter.js';
2
- export declare function declaredAttachments(pages: readonly (readonly RoomAttachment[])[]): readonly RoomAttachment[];
3
- //# sourceMappingURL=attachment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,GAC5C,SAAS,cAAc,EAAE,CAQ3B"}
@@ -1,8 +0,0 @@
1
- export function declaredAttachments(pages) {
2
- const byReference = new Map();
3
- for (const page of pages) {
4
- for (const attachment of page)
5
- byReference.set(attachment.reference, attachment);
6
- }
7
- return [...byReference.values()].sort((left, right) => left.reference < right.reference ? -1 : left.reference > right.reference ? 1 : 0);
8
- }
package/dist/attempt.d.ts DELETED
@@ -1,16 +0,0 @@
1
- export type Answered = 'accepted' | 'refused' | 'unanswered' | 'offline';
2
- export type Identities = {
3
- of(intent: string): string;
4
- settle(answered: Answered): void;
5
- };
6
- export declare function identities(mint?: () => string): Identities;
7
- export declare function intentOf(name: string, about: unknown): string;
8
- export type Attempt = {
9
- identity(intent: string): string;
10
- settle(answered: Answered, drop: (act: number) => void): void;
11
- };
12
- export type Attempts = {
13
- begin(act: number): Attempt;
14
- };
15
- export declare function attempts(mint?: () => string): Attempts;
16
- //# sourceMappingURL=attempt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../src/attempt.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AAEzE,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,GAAE,MAAM,MAAoC,GAAG,UAAU,CAmBvF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAE7D;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B,CAAC;AAEF,wBAAgB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,MAAM,GAAG,QAAQ,CAyBtD"}
package/dist/attempt.js DELETED
@@ -1,57 +0,0 @@
1
- import { changeBatchIdentity } from './identity.js';
2
- export function identities(mint = () => changeBatchIdentity()) {
3
- const kept = new Map();
4
- let used = new Map();
5
- return {
6
- of(intent) {
7
- const one = used.get(intent) ?? kept.get(intent) ?? mint();
8
- used.set(intent, one);
9
- return one;
10
- },
11
- settle(answered) {
12
- if (answered !== 'offline') {
13
- for (const [intent, one] of used) {
14
- if (answered === 'unanswered')
15
- kept.set(intent, one);
16
- else
17
- kept.delete(intent);
18
- }
19
- }
20
- used = new Map();
21
- },
22
- };
23
- }
24
- export function intentOf(name, about) {
25
- return `${name}\u0000${JSON.stringify(about)}`;
26
- }
27
- export function attempts(mint) {
28
- const numbers = identities(mint);
29
- const waiting = new Map();
30
- return {
31
- begin(act) {
32
- const intents = [];
33
- return {
34
- identity(intent) {
35
- intents.push(intent);
36
- return numbers.of(intent);
37
- },
38
- settle(answered, drop) {
39
- numbers.settle(answered);
40
- if (answered === 'refused' || answered === 'offline')
41
- drop(act);
42
- if (answered === 'offline')
43
- return;
44
- for (const intent of intents) {
45
- const earlier = waiting.get(intent);
46
- if (earlier !== undefined && earlier !== act)
47
- drop(earlier);
48
- if (answered === 'unanswered')
49
- waiting.set(intent, act);
50
- else
51
- waiting.delete(intent);
52
- }
53
- },
54
- };
55
- },
56
- };
57
- }
@@ -1,34 +0,0 @@
1
- import { type Answered } from '../attempt.js';
2
- import { type CallResult } from '../outcome.js';
3
- import type { Expected } from './overlay.js';
4
- export type ChatResult = CallResult | {
5
- readonly kind: 'offline';
6
- };
7
- export type ChatOutcome = {
8
- readonly state: 'sending';
9
- } | {
10
- readonly state: 'offline';
11
- } | {
12
- readonly state: 'failed';
13
- readonly result: CallResult;
14
- };
15
- export declare function accepted(result: ChatResult): result is Extract<CallResult, {
16
- readonly kind: 'action';
17
- }>;
18
- export declare function unanswered(result: ChatResult): boolean;
19
- export declare function outcomeOf(result: ChatResult): ChatOutcome | null;
20
- export declare function answeredOf(result: ChatResult): Answered;
21
- export type Sender = {
22
- carried(name: string, about: unknown, sending: (operation: string) => Promise<CallResult>): Promise<ChatResult>;
23
- expect(expected: Expected): void;
24
- draw(expected: Expected): void;
25
- };
26
- type Senders = {
27
- readonly online: boolean;
28
- identity(intent: string): string;
29
- expect(expected: Expected): void;
30
- draw(expected: Expected): void;
31
- };
32
- export declare function sender({ online, identity, expect, draw }: Senders): Sender;
33
- export {};
34
- //# sourceMappingURL=acts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acts.d.ts","sourceRoot":"","sources":["../../src/chat/acts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAE9D,wBAAgB,QAAQ,CACtB,MAAM,EAAE,UAAU,GACjB,MAAM,IAAI,OAAO,CAAC,UAAU,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAE5D;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAEtD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAGhE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,CAIvD;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,GAClD,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,OAAO,GAAG,MAAM,CAa1E"}
package/dist/chat/acts.js DELETED
@@ -1,36 +0,0 @@
1
- import { intentOf } from '../attempt.js';
2
- import { UNCERTAIN } from '../outcome.js';
3
- export function accepted(result) {
4
- return result.kind === 'action';
5
- }
6
- export function unanswered(result) {
7
- return result.kind === 'transport-uncertainty';
8
- }
9
- export function outcomeOf(result) {
10
- if (accepted(result))
11
- return null;
12
- return result.kind === 'offline' ? { state: 'offline' } : { state: 'failed', result };
13
- }
14
- export function answeredOf(result) {
15
- if (accepted(result))
16
- return 'accepted';
17
- if (result.kind === 'offline')
18
- return 'offline';
19
- return unanswered(result) ? 'unanswered' : 'refused';
20
- }
21
- export function sender({ online, identity, expect, draw }) {
22
- return {
23
- async carried(name, about, sending) {
24
- if (!online)
25
- return { kind: 'offline' };
26
- try {
27
- return await sending(identity(intentOf(name, about)));
28
- }
29
- catch {
30
- return UNCERTAIN;
31
- }
32
- },
33
- expect,
34
- draw,
35
- };
36
- }
@@ -1,3 +0,0 @@
1
- import type { TurnContext } from '../adapter.js';
2
- export declare function contextText(context: TurnContext): string;
3
- //# sourceMappingURL=context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/chat/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQjD,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAExD"}
@@ -1,9 +0,0 @@
1
- import { type ReactElement, type ReactNode } from 'react';
2
- import { type ChatNoteProps } from './kit.js';
3
- export type ChatInputProps = {
4
- readonly messageLength?: number;
5
- readonly note?: (note: ChatNoteProps) => ReactNode;
6
- readonly autoFocus?: boolean;
7
- };
8
- export declare function ChatInput({ messageLength, note, autoFocus, }: ChatInputProps): ReactElement;
9
- //# sourceMappingURL=input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/chat/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAqBlG,OAAO,EAAsD,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAMlG,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,SAAS,CAAC;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAiGF,wBAAgB,SAAS,CAAC,EACxB,aAAa,EACb,IAAY,EACZ,SAAiB,GAClB,EAAE,cAAc,GAAG,YAAY,CA+K/B"}
@@ -1,99 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useContext, useEffect, useMemo, useRef } from 'react';
3
- import { ComposerPrimitive, useAui, useAuiState, } from '@assistant-ui/react';
4
- import { DropdownMenu } from 'radix-ui';
5
- import ArrowUp from 'lucide-react/dist/esm/icons/arrow-up.mjs';
6
- import Check from 'lucide-react/dist/esm/icons/check.mjs';
7
- import ChevronDown from 'lucide-react/dist/esm/icons/chevron-down.mjs';
8
- import CornerDownRight from 'lucide-react/dist/esm/icons/corner-down-right.mjs';
9
- import ListEnd from 'lucide-react/dist/esm/icons/list-end.mjs';
10
- import Paperclip from 'lucide-react/dist/esm/icons/paperclip.mjs';
11
- import Pencil from 'lucide-react/dist/esm/icons/pencil.mjs';
12
- import Plus from 'lucide-react/dist/esm/icons/plus.mjs';
13
- import Square from 'lucide-react/dist/esm/icons/square.mjs';
14
- import X from 'lucide-react/dist/esm/icons/x.mjs';
15
- import { contextText } from './context.js';
16
- import { Button, ChatNote, IconButton, Name, Portal, Scoped } from './kit.js';
17
- import { COMMAND } from './process.js';
18
- import { useChat, useChatScope } from './provider.js';
19
- import { forgetAnswers } from './question.js';
20
- import { useOpened } from './opened.js';
21
- const commanded = {
22
- serialize: (item) => `${COMMAND}${item.id}`,
23
- parse: (said) => [{ kind: 'text', text: said }],
24
- };
25
- const atStart = (said, char, cursor) => {
26
- const typed = said.slice(0, cursor);
27
- return typed.startsWith(char) && !/\s/.test(typed)
28
- ? { query: typed.slice(char.length), offset: 0, endOffset: cursor }
29
- : null;
30
- };
31
- function commandItem(command) {
32
- return {
33
- id: command.name,
34
- type: 'command',
35
- label: `${COMMAND}${command.name}`,
36
- description: command.description,
37
- };
38
- }
39
- function commandsFound(commands, query) {
40
- const asked = query.toLowerCase();
41
- const named = commands.filter((one) => one.name.toLowerCase().startsWith(asked));
42
- const within = commands.filter((one) => !named.includes(one) && one.name.toLowerCase().includes(asked));
43
- return [...named, ...within].map(commandItem);
44
- }
45
- function Attached({ id, name }) {
46
- const aui = useAui();
47
- return (_jsxs("span", { className: "ahc-chip ahc-chip--removable", children: [_jsx(Paperclip, { "aria-hidden": "true" }), _jsx(Name, { text: name }), _jsx(IconButton, { label: `Remove ${name}`, compact: true, onClick: () => void aui.composer().attachment({ id }).remove(), children: _jsx(X, { "aria-hidden": "true" }) })] }));
48
- }
49
- function Picker({ option, choose, }) {
50
- const container = useContext(Portal);
51
- return (_jsxs(DropdownMenu.Root, { modal: false, children: [_jsxs(DropdownMenu.Trigger, { className: "ahc-btn ahc-picker", "aria-label": option.name, title: option.name, children: [_jsx(Name, { text: option.values.find((one) => one.value === option.value)?.name ?? option.value }), _jsx(ChevronDown, { "aria-hidden": "true" })] }), _jsx(DropdownMenu.Portal, { container: container, children: _jsxs(DropdownMenu.Content, { className: "ahc-menu", side: "top", align: "start", children: [_jsx(DropdownMenu.Label, { className: "ahc-menu__heading", children: option.name }), _jsx(DropdownMenu.RadioGroup, { value: option.value, onValueChange: (value) => {
52
- if (value !== option.value)
53
- void choose(option.id, value);
54
- }, children: option.values.map((one) => (_jsxs(DropdownMenu.RadioItem, { value: one.value, className: "ahc-row", children: [_jsx("span", { className: "ahc-row__label", children: one.name }), _jsx(DropdownMenu.ItemIndicator, { asChild: true, children: _jsx(Check, { "aria-hidden": "true" }) })] }, one.value))) })] }) })] }));
55
- }
56
- function noted(note) {
57
- return _jsx(ChatNote, { ...note });
58
- }
59
- export function ChatInput({ messageLength, note = noted, autoFocus = false, }) {
60
- const chat = useChat();
61
- const { client } = useChatScope();
62
- const aui = useAui();
63
- const opened = useOpened();
64
- const { lone, commands, context, queued, running } = opened;
65
- const conversation = chat.conversation ?? '';
66
- const input = useRef(null);
67
- const picker = useRef(null);
68
- const thread = chat.conversation ?? `new:${chat.agent ?? ''}`;
69
- useEffect(() => {
70
- if (autoFocus)
71
- input.current?.focus();
72
- }, [autoFocus, thread]);
73
- const typed = useAuiState((s) => s.composer.text);
74
- const attached = useAuiState((s) => s.composer.attachments.length > 0);
75
- const fault = messageLength !== undefined && typed.length > messageLength
76
- ? `Keep it to ${messageLength} characters.`
77
- : null;
78
- const listed = useMemo(() => ({
79
- categories: () => [],
80
- categoryItems: () => [],
81
- search: (query) => commandsFound(commands, query),
82
- }), [commands]);
83
- const interrupt = () => void chat.stop().then((stopped) => {
84
- if (stopped)
85
- void forgetAnswers(client, conversation);
86
- });
87
- const edit = (id) => {
88
- chat.edit(id);
89
- input.current?.focus();
90
- };
91
- const drafted = typed.trim() !== '' || attached;
92
- const readOnly = opened.deleted;
93
- return (_jsx(Scoped, { children: _jsxs("div", { className: "ahc-input-area", children: [readOnly || queued.length === 0 ? null : (_jsxs("div", { role: "group", "aria-label": "Queued messages", className: "ahc-queue", children: [_jsxs("div", { className: "ahc-queue__head", children: [_jsx(ListEnd, { "aria-hidden": "true" }), _jsx("span", { className: "ahc-queue__said", children: `${queued.length} ${queued.length === 1 ? 'message waits' : 'messages wait'} for ${opened.name} to finish` }), running ? (_jsx(Button, { variant: "outline", compact: true, onClick: interrupt, children: "Send now" })) : null] }), queued.map((item) => (_jsxs("div", { className: "ahc-queue-row", children: [_jsx(CornerDownRight, { "aria-hidden": "true", className: "ahc-muted" }), _jsx("span", { className: "ahc-queue-row__text", children: item.text }), _jsx(IconButton, { label: "Edit queued message", compact: true, onClick: () => edit(item.id), children: _jsx(Pencil, { "aria-hidden": "true" }) }), _jsx(IconButton, { label: "Remove queued message", compact: true, onClick: () => chat.unqueue(item.id), children: _jsx(X, { "aria-hidden": "true" }) })] }, item.id)))] })), readOnly ? null : (_jsx(ComposerPrimitive.Root, { className: "ahc-composer", children: _jsxs(ComposerPrimitive.Unstable_TriggerPopoverRoot, { children: [commands.length === 0 ? null : (_jsxs(ComposerPrimitive.Unstable_TriggerPopover, { char: COMMAND, matcher: atStart, adapter: listed, "aria-label": "Commands", className: "ahc-menu ahc-commands", children: [_jsx(ComposerPrimitive.Unstable_TriggerPopover.Directive, { formatter: commanded }), _jsx(ComposerPrimitive.Unstable_TriggerPopoverItems, { children: (items) => items.map((item, index) => (_jsx(ComposerPrimitive.Unstable_TriggerPopoverItem, { item: item, index: index, className: "ahc-row ahc-row--two", children: _jsxs("span", { className: "ahc-row__label", children: [_jsx("span", { className: "ahc-row__title ahc-mono", children: item.label }), _jsx("span", { className: "ahc-row__sub", children: item.description })] }) }, item.id))) })] })), attached ? (_jsx("div", { className: "ahc-chips", children: _jsx(ComposerPrimitive.Attachments, { children: ({ attachment }) => _jsx(Attached, { id: attachment.id, name: attachment.name }) }) })) : null, _jsx(ComposerPrimitive.Input, { asChild: true, "aria-label": "Message", placeholder: lone === null ? `Message ${opened.name}` : lone.field.prompt, submitMode: fault === null ? 'enter' : 'none', children: _jsx("textarea", { ref: input, className: "ahc-composer__input", rows: 1 }) }), _jsxs("div", { className: "ahc-composer__bar", children: [_jsx(IconButton, { label: "Add files", onClick: () => picker.current?.click(), children: _jsx(Plus, { size: 20, "aria-hidden": "true" }) }), _jsx("input", { ref: picker, type: "file", multiple: true, hidden: true, onChange: (event) => {
94
- const chosen = [...(event.target.files ?? [])];
95
- event.target.value = '';
96
- for (const file of chosen)
97
- void aui.composer().addAttachment(file);
98
- } }), opened.options.map((option) => (_jsx(Picker, { option: option, choose: chat.choose }, option.id))), _jsx("span", { className: "ahc-spacer" }), context === null ? null : (_jsx("span", { title: "Context in use", className: "ahc-meta", children: contextText(context) })), running ? (_jsx("button", { type: "button", className: `ahc-btn ahc-btn--icon ${drafted ? 'ahc-btn--outline' : 'ahc-btn--ink'}`, "aria-label": "Stop", title: "Stop", onClick: interrupt, children: _jsx(Square, { "aria-hidden": "true" }) })) : null, running && !drafted ? null : (_jsx(ComposerPrimitive.Send, { className: "ahc-btn ahc-btn--icon ahc-btn--ink", "aria-label": running ? 'Queue message' : 'Send', disabled: fault !== null, children: _jsx(ArrowUp, { size: 20, "aria-hidden": "true" }) }))] })] }) })), fault === null ? null : (_jsx("p", { className: "ahc-note", role: "status", "data-state": "refused", children: fault })), note({ outcome: chat.acting.outcome }), note({ outcome: chat.sending.outcome, again: chat.sending.again ?? undefined })] }) }));
99
- }