@agentshouse/mdruntime 0.1.0-c698c0ebd65bd → 0.1.0-c6b1e70f2da66

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 (370) hide show
  1. package/README.md +19 -16
  2. package/dist/acceptance.d.ts +6 -0
  3. package/dist/acceptance.d.ts.map +1 -0
  4. package/dist/acceptance.js +387 -0
  5. package/dist/actions.d.ts +20 -0
  6. package/dist/actions.d.ts.map +1 -0
  7. package/dist/actions.js +251 -0
  8. package/dist/adapter.d.ts +155 -86
  9. package/dist/adapter.d.ts.map +1 -1
  10. package/dist/attached-model.d.ts +7 -10
  11. package/dist/attached-model.d.ts.map +1 -1
  12. package/dist/attached-model.js +40 -41
  13. package/dist/binary.d.ts +0 -5
  14. package/dist/binary.d.ts.map +1 -1
  15. package/dist/binary.js +1 -1
  16. package/dist/bootstrap.d.ts +31 -11
  17. package/dist/bootstrap.d.ts.map +1 -1
  18. package/dist/bootstrap.js +324 -93
  19. package/dist/cell.d.ts +6 -0
  20. package/dist/cell.d.ts.map +1 -0
  21. package/dist/cell.js +9 -0
  22. package/dist/chain.d.ts +12 -0
  23. package/dist/chain.d.ts.map +1 -0
  24. package/dist/chain.js +64 -0
  25. package/dist/change-set.d.ts +9 -14
  26. package/dist/change-set.d.ts.map +1 -1
  27. package/dist/change-set.js +11 -63
  28. package/dist/change.d.ts +32 -1
  29. package/dist/change.d.ts.map +1 -1
  30. package/dist/change.js +14 -3
  31. package/dist/chat-types.d.ts +5 -0
  32. package/dist/chat-types.d.ts.map +1 -0
  33. package/dist/chat-types.js +13 -0
  34. package/dist/client.d.ts +45 -16
  35. package/dist/client.d.ts.map +1 -1
  36. package/dist/client.js +104 -13
  37. package/dist/collection.d.ts +31 -9
  38. package/dist/collection.d.ts.map +1 -1
  39. package/dist/collection.js +49 -80
  40. package/dist/compile.d.ts +16 -0
  41. package/dist/compile.d.ts.map +1 -0
  42. package/dist/compile.js +711 -0
  43. package/dist/connection.d.ts +8 -117
  44. package/dist/connection.d.ts.map +1 -1
  45. package/dist/connection.js +106 -2486
  46. package/dist/context.d.ts +2 -0
  47. package/dist/context.d.ts.map +1 -0
  48. package/dist/{chat/context.js → context.js} +1 -4
  49. package/dist/conversation-live.d.ts +135 -0
  50. package/dist/conversation-live.d.ts.map +1 -0
  51. package/dist/conversation-live.js +247 -0
  52. package/dist/conversation-row.d.ts +33 -0
  53. package/dist/conversation-row.d.ts.map +1 -0
  54. package/dist/conversation-row.js +53 -0
  55. package/dist/conversation.d.ts +55 -42
  56. package/dist/conversation.d.ts.map +1 -1
  57. package/dist/conversation.js +985 -649
  58. package/dist/digest.d.ts +7 -0
  59. package/dist/digest.d.ts.map +1 -0
  60. package/dist/digest.js +113 -0
  61. package/dist/discovery.d.ts +10 -0
  62. package/dist/discovery.d.ts.map +1 -0
  63. package/dist/discovery.js +175 -0
  64. package/dist/durability.d.ts +19 -1
  65. package/dist/durability.d.ts.map +1 -1
  66. package/dist/durability.js +5 -0
  67. package/dist/entry.d.ts +7 -4
  68. package/dist/entry.d.ts.map +1 -1
  69. package/dist/entry.js +33 -28
  70. package/dist/expectation.d.ts +4 -2
  71. package/dist/expectation.d.ts.map +1 -1
  72. package/dist/expectation.js +33 -11
  73. package/dist/failure.d.ts +1 -0
  74. package/dist/failure.d.ts.map +1 -1
  75. package/dist/failure.js +3 -0
  76. package/dist/figures.d.ts +49 -0
  77. package/dist/figures.d.ts.map +1 -0
  78. package/dist/figures.js +197 -0
  79. package/dist/file.d.ts +2 -19
  80. package/dist/file.d.ts.map +1 -1
  81. package/dist/file.js +7 -122
  82. package/dist/holdings.d.ts +29 -0
  83. package/dist/holdings.d.ts.map +1 -0
  84. package/dist/holdings.js +95 -0
  85. package/dist/host.d.ts +11 -3
  86. package/dist/host.d.ts.map +1 -1
  87. package/dist/host.js +127 -20
  88. package/dist/index.d.ts +35 -11
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +13 -0
  91. package/dist/install.d.ts +56 -0
  92. package/dist/install.d.ts.map +1 -0
  93. package/dist/install.js +556 -0
  94. package/dist/job.d.ts +5 -0
  95. package/dist/job.d.ts.map +1 -0
  96. package/dist/job.js +7 -0
  97. package/dist/lifecycle.d.ts +7 -0
  98. package/dist/lifecycle.d.ts.map +1 -0
  99. package/dist/lifecycle.js +270 -0
  100. package/dist/listing.d.ts +53 -0
  101. package/dist/listing.d.ts.map +1 -0
  102. package/dist/listing.js +176 -0
  103. package/dist/live.d.ts +23 -0
  104. package/dist/live.d.ts.map +1 -0
  105. package/dist/live.js +165 -0
  106. package/dist/locks.d.ts +9 -0
  107. package/dist/locks.d.ts.map +1 -0
  108. package/dist/locks.js +62 -0
  109. package/dist/log.d.ts +1 -0
  110. package/dist/log.d.ts.map +1 -1
  111. package/dist/lost.d.ts +5 -0
  112. package/dist/lost.d.ts.map +1 -0
  113. package/dist/lost.js +61 -0
  114. package/dist/media.d.ts +8 -0
  115. package/dist/media.d.ts.map +1 -0
  116. package/dist/media.js +218 -0
  117. package/dist/memory.d.ts +19 -6
  118. package/dist/memory.d.ts.map +1 -1
  119. package/dist/memory.js +251 -97
  120. package/dist/messages.d.ts +49 -0
  121. package/dist/messages.d.ts.map +1 -0
  122. package/dist/messages.js +148 -0
  123. package/dist/model.d.ts +11 -12
  124. package/dist/model.d.ts.map +1 -1
  125. package/dist/model.js +7 -15
  126. package/dist/models.d.ts +14 -0
  127. package/dist/models.d.ts.map +1 -0
  128. package/dist/models.js +197 -0
  129. package/dist/name.d.ts +4 -0
  130. package/dist/name.d.ts.map +1 -0
  131. package/dist/name.js +122 -0
  132. package/dist/observation.d.ts +22 -4
  133. package/dist/observation.d.ts.map +1 -1
  134. package/dist/observation.js +127 -26
  135. package/dist/opened.d.ts +22 -0
  136. package/dist/opened.d.ts.map +1 -0
  137. package/dist/opened.js +107 -0
  138. package/dist/opening.d.ts +4 -0
  139. package/dist/opening.d.ts.map +1 -0
  140. package/dist/opening.js +60 -0
  141. package/dist/outcome.d.ts +49 -8
  142. package/dist/outcome.d.ts.map +1 -1
  143. package/dist/outcome.js +42 -0
  144. package/dist/overlay.d.ts +5 -4
  145. package/dist/overlay.d.ts.map +1 -1
  146. package/dist/overlay.js +132 -192
  147. package/dist/parts.d.ts +11 -0
  148. package/dist/parts.d.ts.map +1 -0
  149. package/dist/parts.js +21 -0
  150. package/dist/paths.d.ts +2 -0
  151. package/dist/paths.d.ts.map +1 -1
  152. package/dist/paths.js +26 -0
  153. package/dist/preparation.d.ts +20 -0
  154. package/dist/preparation.d.ts.map +1 -0
  155. package/dist/preparation.js +233 -0
  156. package/dist/queries.d.ts +16 -0
  157. package/dist/queries.d.ts.map +1 -0
  158. package/dist/queries.js +272 -0
  159. package/dist/query.d.ts +49 -183
  160. package/dist/query.d.ts.map +1 -1
  161. package/dist/query.js +3 -464
  162. package/dist/{chat/questions.d.ts → questions.d.ts} +5 -2
  163. package/dist/questions.d.ts.map +1 -0
  164. package/dist/{chat/questions.js → questions.js} +13 -2
  165. package/dist/reach.d.ts +21 -7
  166. package/dist/reach.d.ts.map +1 -1
  167. package/dist/reach.js +292 -91
  168. package/dist/react.d.ts +20 -6
  169. package/dist/react.d.ts.map +1 -1
  170. package/dist/react.js +17 -18
  171. package/dist/{chat/read.d.ts → read.d.ts} +2 -0
  172. package/dist/read.d.ts.map +1 -0
  173. package/dist/{chat/read.js → read.js} +4 -0
  174. package/dist/readiness.d.ts +49 -0
  175. package/dist/readiness.d.ts.map +1 -0
  176. package/dist/readiness.js +27 -0
  177. package/dist/reads.d.ts +37 -0
  178. package/dist/reads.d.ts.map +1 -0
  179. package/dist/reads.js +174 -0
  180. package/dist/recovery.d.ts +26 -0
  181. package/dist/recovery.d.ts.map +1 -0
  182. package/dist/recovery.js +232 -0
  183. package/dist/refresh.d.ts +17 -14
  184. package/dist/refresh.d.ts.map +1 -1
  185. package/dist/refresh.js +143 -51
  186. package/dist/refusal.d.ts +5 -0
  187. package/dist/refusal.d.ts.map +1 -0
  188. package/dist/refusal.js +57 -0
  189. package/dist/replica.d.ts +56 -33
  190. package/dist/replica.d.ts.map +1 -1
  191. package/dist/replica.js +338 -159
  192. package/dist/room-draft.d.ts +39 -9
  193. package/dist/room-draft.d.ts.map +1 -1
  194. package/dist/room-draft.js +186 -86
  195. package/dist/room-drafts.d.ts +24 -0
  196. package/dist/room-drafts.d.ts.map +1 -0
  197. package/dist/room-drafts.js +217 -0
  198. package/dist/rows.d.ts +30 -37
  199. package/dist/rows.d.ts.map +1 -1
  200. package/dist/rows.js +60 -128
  201. package/dist/runtime.d.ts +43 -0
  202. package/dist/runtime.d.ts.map +1 -0
  203. package/dist/runtime.js +1 -0
  204. package/dist/save.d.ts +58 -10
  205. package/dist/save.d.ts.map +1 -1
  206. package/dist/save.js +569 -189
  207. package/dist/saves.d.ts +70 -0
  208. package/dist/saves.d.ts.map +1 -0
  209. package/dist/saves.js +1008 -0
  210. package/dist/search.d.ts +15 -55
  211. package/dist/search.d.ts.map +1 -1
  212. package/dist/search.js +10 -121
  213. package/dist/seed.d.ts +25 -0
  214. package/dist/seed.d.ts.map +1 -0
  215. package/dist/seed.js +145 -0
  216. package/dist/shared.d.ts +10 -0
  217. package/dist/shared.d.ts.map +1 -0
  218. package/dist/shared.js +339 -0
  219. package/dist/shown.d.ts +31 -0
  220. package/dist/shown.d.ts.map +1 -0
  221. package/dist/shown.js +290 -0
  222. package/dist/socket/admission.d.ts +7 -0
  223. package/dist/socket/admission.d.ts.map +1 -0
  224. package/dist/socket/admission.js +39 -0
  225. package/dist/socket/answers.d.ts +6 -0
  226. package/dist/socket/answers.d.ts.map +1 -0
  227. package/dist/socket/answers.js +20 -0
  228. package/dist/socket/lanes.d.ts +20 -0
  229. package/dist/socket/lanes.d.ts.map +1 -0
  230. package/dist/socket/lanes.js +77 -0
  231. package/dist/socket/reads.d.ts +10 -0
  232. package/dist/socket/reads.d.ts.map +1 -0
  233. package/dist/socket/reads.js +31 -0
  234. package/dist/socket/rooms.d.ts +44 -0
  235. package/dist/socket/rooms.d.ts.map +1 -0
  236. package/dist/socket/rooms.js +90 -0
  237. package/dist/socket/session.d.ts +38 -0
  238. package/dist/socket/session.d.ts.map +1 -0
  239. package/dist/socket/session.js +23 -0
  240. package/dist/socket.d.ts +70 -0
  241. package/dist/socket.d.ts.map +1 -0
  242. package/dist/socket.js +175 -0
  243. package/dist/source.d.ts +61 -0
  244. package/dist/source.d.ts.map +1 -0
  245. package/dist/source.js +82 -0
  246. package/dist/status.d.ts +5 -2
  247. package/dist/status.d.ts.map +1 -1
  248. package/dist/status.js +3 -7
  249. package/dist/store/fences.d.ts +16 -0
  250. package/dist/store/fences.d.ts.map +1 -0
  251. package/dist/store/fences.js +26 -0
  252. package/dist/store/installs.d.ts +30 -0
  253. package/dist/store/installs.d.ts.map +1 -0
  254. package/dist/store/installs.js +34 -0
  255. package/dist/store/readiness.d.ts +10 -0
  256. package/dist/store/readiness.d.ts.map +1 -0
  257. package/dist/store/readiness.js +52 -0
  258. package/dist/store/records.d.ts +210 -0
  259. package/dist/store/records.d.ts.map +1 -0
  260. package/dist/store/records.js +428 -0
  261. package/dist/store/room-held.d.ts +8 -0
  262. package/dist/store/room-held.d.ts.map +1 -0
  263. package/dist/store/room-held.js +17 -0
  264. package/dist/store/space.d.ts +11 -0
  265. package/dist/store/space.d.ts.map +1 -0
  266. package/dist/store/space.js +41 -0
  267. package/dist/store/watchers.d.ts +17 -0
  268. package/dist/store/watchers.d.ts.map +1 -0
  269. package/dist/store/watchers.js +56 -0
  270. package/dist/store/writes.d.ts +24 -0
  271. package/dist/store/writes.d.ts.map +1 -0
  272. package/dist/store/writes.js +125 -0
  273. package/dist/store.d.ts +106 -127
  274. package/dist/store.d.ts.map +1 -1
  275. package/dist/store.js +136 -575
  276. package/dist/stored.d.ts +156 -0
  277. package/dist/stored.d.ts.map +1 -0
  278. package/dist/stored.js +649 -0
  279. package/dist/surface.d.ts +88 -0
  280. package/dist/surface.d.ts.map +1 -0
  281. package/dist/surface.js +224 -0
  282. package/dist/sync.d.ts +19 -0
  283. package/dist/sync.d.ts.map +1 -0
  284. package/dist/sync.js +532 -0
  285. package/dist/tables.d.ts +412 -0
  286. package/dist/tables.d.ts.map +1 -0
  287. package/dist/tables.js +737 -0
  288. package/dist/tallies.d.ts +18 -0
  289. package/dist/tallies.d.ts.map +1 -0
  290. package/dist/tallies.js +129 -0
  291. package/dist/transfer.d.ts +0 -5
  292. package/dist/transfer.d.ts.map +1 -1
  293. package/dist/turn.d.ts +9 -0
  294. package/dist/turn.d.ts.map +1 -0
  295. package/dist/turn.js +75 -0
  296. package/dist/validation.d.ts +29 -0
  297. package/dist/validation.d.ts.map +1 -0
  298. package/dist/validation.js +104 -0
  299. package/dist/windows.d.ts +11 -0
  300. package/dist/windows.d.ts.map +1 -0
  301. package/dist/windows.js +16 -0
  302. package/dist/wire.d.ts +181 -33
  303. package/dist/wire.d.ts.map +1 -1
  304. package/dist/wire.js +62 -31
  305. package/package.json +19 -19
  306. package/AGENTS.md +0 -299
  307. package/dist/chat/acts.d.ts +0 -33
  308. package/dist/chat/acts.d.ts.map +0 -1
  309. package/dist/chat/acts.js +0 -36
  310. package/dist/chat/context.d.ts +0 -3
  311. package/dist/chat/context.d.ts.map +0 -1
  312. package/dist/chat/input.d.ts +0 -9
  313. package/dist/chat/input.d.ts.map +0 -1
  314. package/dist/chat/input.js +0 -99
  315. package/dist/chat/kit.d.ts +0 -60
  316. package/dist/chat/kit.d.ts.map +0 -1
  317. package/dist/chat/kit.js +0 -123
  318. package/dist/chat/lasting.d.ts +0 -6
  319. package/dist/chat/lasting.d.ts.map +0 -1
  320. package/dist/chat/lasting.js +0 -19
  321. package/dist/chat/list.d.ts +0 -26
  322. package/dist/chat/list.d.ts.map +0 -1
  323. package/dist/chat/list.js +0 -62
  324. package/dist/chat/markdown.d.ts +0 -20
  325. package/dist/chat/markdown.d.ts.map +0 -1
  326. package/dist/chat/markdown.js +0 -188
  327. package/dist/chat/message.d.ts +0 -6
  328. package/dist/chat/message.d.ts.map +0 -1
  329. package/dist/chat/message.js +0 -192
  330. package/dist/chat/messages.d.ts +0 -21
  331. package/dist/chat/messages.d.ts.map +0 -1
  332. package/dist/chat/messages.js +0 -151
  333. package/dist/chat/name.d.ts +0 -6
  334. package/dist/chat/name.d.ts.map +0 -1
  335. package/dist/chat/name.js +0 -37
  336. package/dist/chat/opened.d.ts +0 -11
  337. package/dist/chat/opened.d.ts.map +0 -1
  338. package/dist/chat/opened.js +0 -17
  339. package/dist/chat/overlay.d.ts +0 -31
  340. package/dist/chat/overlay.d.ts.map +0 -1
  341. package/dist/chat/overlay.js +0 -97
  342. package/dist/chat/parts.d.ts +0 -57
  343. package/dist/chat/parts.d.ts.map +0 -1
  344. package/dist/chat/parts.js +0 -119
  345. package/dist/chat/process.d.ts +0 -20
  346. package/dist/chat/process.d.ts.map +0 -1
  347. package/dist/chat/process.js +0 -32
  348. package/dist/chat/provider.d.ts +0 -63
  349. package/dist/chat/provider.d.ts.map +0 -1
  350. package/dist/chat/provider.js +0 -620
  351. package/dist/chat/question.d.ts +0 -9
  352. package/dist/chat/question.d.ts.map +0 -1
  353. package/dist/chat/question.js +0 -80
  354. package/dist/chat/questions.d.ts.map +0 -1
  355. package/dist/chat/read.d.ts.map +0 -1
  356. package/dist/chat/ready.d.ts +0 -33
  357. package/dist/chat/ready.d.ts.map +0 -1
  358. package/dist/chat/ready.js +0 -91
  359. package/dist/chat/style.d.ts +0 -4
  360. package/dist/chat/style.d.ts.map +0 -1
  361. package/dist/chat/style.js +0 -302
  362. package/dist/chat.d.ts +0 -14
  363. package/dist/chat.d.ts.map +0 -1
  364. package/dist/chat.js +0 -8
  365. package/dist/fence.d.ts +0 -6
  366. package/dist/fence.d.ts.map +0 -1
  367. package/dist/fence.js +0 -10
  368. package/dist/read-side.d.ts +0 -18
  369. package/dist/read-side.d.ts.map +0 -1
  370. package/dist/read-side.js +0 -440
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 App
4
- 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, the binary file
10
- reads, Call, Reached, Log, the reported persistence answer, reauthorization,
11
- conversation, the chat draft, and Presentation State. Sync Status, the Service
12
- Mode, the storage-loss statement, the deployment facts and the signed-in member
13
- are observations only.
14
-
15
- The host attaches each port with its reach, and every member and observation
16
- answers within it: a Room outside it answers as one the replica does not hold,
17
- Rooms lists only the Rooms reached whole, a Room reached for single Documents
18
- shows only those Documents and the Types of the models that govern them, and
19
- without conversations the conversation members, the chat draft and the
20
- conversation observation hold none. A change of the reach reaches every open
21
- observation as its new value, a query keeping unchanged Documents the same objects.
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. Each conversation
31
- the Provider's conversation list names is held complete in the browser.
32
- `conversation.list()` and `observe('conversations')` answer each with its Agent's
33
- 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
35
- `idle`, and `started`, when the running turn began, or `null`. Observe one with
36
- `observe('conversation', id, { limit })`: the view holds its latest `limit`
37
- messages, or all of them, oldest first, its chat draft, and what the Provider
38
- streams for it whether or not anything views it: the running `turn` with its
39
- message parts and its context in use and window, the open questions, the process
40
- state, and the CLI's commands and options. These live only in memory: the
41
- message accepted under the turn's id replaces the running turn, and none of them
42
- is stored or searchable. `chatDraft.write` and `chatDraft.discard` keep what the
43
- App Creator composes; sending it is a Provider Action that needs the Provider
44
- reachable and is never queued.
45
-
46
- A binary file at a Path is a binary Path entry. Query lists it by `path`, and
47
- History each of its revisions, with its `binaryFile` record and never its bytes:
48
- `{ state: 'accepted', revision, path, fileRef, byteLength, mediaType, sha256 }`,
49
- or, from a Save until the Provider accepts it, `{ state: 'pending', localId,
50
- path, byteLength, mediaType, sha256 }`. Write one with a Room Draft whose only
51
- part is `file: { blob }`, the `Blob`'s `type` its media type: Save keeps the
52
- bytes in its Pending Change, offline too, and acceptance gives the record the
53
- Provider's revision. Move or remove one as a Document, a pending one before or
54
- after Save too, its bytes following; once its Pending Change has gone to the
55
- Provider, Save refuses that as `unknown-revision` until it is accepted.
56
- `binaryFile.read(room, path, revision?)` answers a pending record's saved bytes,
57
- or asks the Provider again on every read of an accepted one or of a History
58
- revision, a removed file's last included, keeping nothing. Text, a Record
59
- attachment or a conversation message may name a file by its `fileRef`; read it
60
- with `binaryFile.readReference({ fileRef, referrer })`, the referrer being the
61
- `referrer` the Provider gave beside it, or `{ room, path }` of the document whose
62
- text names it. Both answer `{ kind: 'binary', blob }` or a refusal or failure.
63
-
64
- Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never
65
- touch the network. History, the binary file reads and Call go to the Provider
66
- through the Adapter. Call takes the Action names the Adapter declares; any other
67
- name answers `undeclared` without reaching the Provider. A Call result whose
68
- effect the Provider places in a Room carries `at`, that Room and Room Version;
69
- `reached(room, roomVersion)` answers whether the Room's confirmed state has
70
- reached it, and the MD Runtime keeps refreshing that Room until it has;
71
- `reached(room, roomVersion, path)` answers whether the held confirmed copy of
72
- that document was written at a later Room Version. Each History revision
73
- names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`.
74
- History of a Path no current document holds answers the removed document's
75
- revisions with `deleted: true`, newest first; that revision is what a link to
76
- the Path opens. Every member of the client is asynchronous. Results are
77
- detached snapshots. Nothing in this surface returns the authorization, performs
78
- a request the App's code composes, or exposes the browser store.
79
-
80
- Every refusal and failure carries `code` and `retryable`: each Call and History
81
- answer other than its result, a refused Save or Room Draft write, a returned Room
82
- Draft's reason, a Room's refusal and the Connection Refusal, and every error a
83
- member rejects with, beside its message. A Provider refusal carries the
84
- Provider's own `retryable`. Every code and every value the API answers is open:
85
- handle one you do not know by its `code` and `retryable`.
86
-
87
- Read the deployment facts with `observe('deployment-facts')`, an opaque value
88
- the host's contract interprets. `observe('member')` answers who uses the App:
89
- the User the Provider signed in, `{ kind: 'user', id, name }` in the shape of a
90
- change's `author`, so a Document whose `change.author.id` equals its `id` is that
91
- User's own. It is `null` until the Provider first names one, and where it names
92
- none, such as a Site. The MD Runtime keeps it with the Local Replicas, so it
93
- answers offline once known, and every port hears the next member the Provider
94
- names; signing out answers `null`, then ends the observation with the
95
- authorization. It is the only way App code learns who uses it.
96
-
97
- ## Local Query rules
98
-
99
- `query(q)` answers once from local state; `observe('query', q)` holds the whole
100
- result and hears it again only when it changes, keeping every unchanged Document
101
- the same object, so a component can tell what changed by identity. A query is
102
- data:
103
-
104
- - **Filter.** `rooms` names Room locators and defaults to every Room. `types`
105
- names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
106
- directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
107
- - **Fields.** Every frontmatter value is named by JSON Pointer: `/status`,
108
- `/shipping/city`, `~1` for a `/` and `~0` for a `~` in a key. A segment that
109
- meets a list applies to every item and a number names one item. `where` names
110
- pointers, ANDs them, and nests `$and` and `$or`; a pointer through a list holds
111
- when any item satisfies it. A bare value is equality; the operators are `$eq`,
112
- `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and
113
- `$exists`. Equality on a list asks whether it contains the value. Missing,
114
- null and empty differ: `$exists: false` keeps a missing field, `null` an
115
- explicit null, `''` empty text and `$size: 0` an empty list. A date compares
116
- in calendar order and never with a date-time. A reference compares by the Room
117
- Path it resolves to. Untyped frontmatter, and a value under `oneOf` or a
118
- conditional, is plain values. There is no text containment or regular expression.
119
- - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
120
- reference at pointer `field`, at any depth, points to a matching Document of the
121
- same Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
122
- matching Document of the same Room references. Each keeps a Document once.
123
- - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
124
- `preamble`, `markdown`, `backlinks` and `change`, where `fields` is `'all'` or a
125
- list of pointers and `sections` `'all'` or a list of names. Selected pointers
126
- return the frontmatter holding only them, nested as written. A backlink names
127
- the referring Path, MD Type and the pointer it came from as `field`. Room and Path always return; a Markdown
128
- Document also returns its MD Type. A non-Markdown Document returns only Room
129
- and Path, and a binary Path entry Room, Path and its `binaryFile` record,
130
- whatever is selected. An unselected part is absent. Select only
131
- what a screen shows: a list that selects the Markdown hears every edit of it.
132
- - **Change.** `change` is `{ author, time }` of the Document's head revision as
133
- the Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }`
134
- or `null` for a write the Provider made itself, and `time` is the Provider's
135
- ISO 8601 change time. It is `null` where the Provider delivered no time, as at
136
- a Site. An unsent edit or move keeps it, an unsent creation has none, and a
137
- saved write takes the Provider's own once it is Accepted. A
138
- Room's last change is its Document with the latest `time`.
139
- - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
140
- with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
141
- `room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
142
- over every match and ordered by `count` or a key. A sort or group takes only a
143
- pointer that holds one value. `limit` bounds the Documents or the groups.
144
- - **Results and errors.** A result carries no Room Version: read freshness from
145
- Rooms and Sync Status. An invalid query fails with the `code`
146
- `invalid-query`, `unknown-type`, `unknown-field` or `wrong-kind`, naming where,
147
- and never answers an empty result in its place.
148
-
149
- ## Local Search rules
150
-
151
- `search({ text, documents, conversations, limit })` answers once, by words, from
152
- local state, with MiniSearch's defaults. There is no observed search.
153
-
154
- - **What is found.** A Document by its field values, its sections' headings and
155
- text, its preamble and its Path; a message by its text. Frontmatter keys, Room
156
- Drafts, chat drafts and a running turn's parts are never found. There are no phrases,
157
- word forms, typo tolerance or prefix matching.
158
- - **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
159
- `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
160
- apply before `limit`, which bounds each list; without it every hit returns.
161
- - **Results.** `{ documents, messages }`, each ranked by `score`, which compares
162
- hits of one list of one search. A Document hit names its `room`, `path` and
163
- `type`, a message hit its `conversation` and `identity`, and `matches` maps each
164
- matched word to the parts it matched in: `fields`, `sections`, `preamble` or
165
- `path`, or `text`. A hit carries no position; mark the words in the text you
166
- show. An invalid filter fails with its Local Query error.
167
-
168
- ## Room Draft, Save, and outcome rules
169
-
170
- The MD Runtime owns one Room Draft per Room and Path, shared by every App and tab.
171
- It is durable: it survives reload and navigation. A Room that Discovery stops
172
- listing takes its Room Drafts and its queue with it. Write a Room Draft with
173
- `roomDraft.write(room, path, revision, parts)`, naming the revision you read, or
174
- `null` when there was none, and every part it should now change: fields, sections
175
- and the preamble, or the whole Markdown, a creation, a move, or a removal. A part
176
- new to the Room Draft names its base, the value you showed when it was opened; the
177
- MD Runtime keeps a part's first base; a binary Path entry's move or removal takes
178
- `null` as its base. A write or a discard from an older revision is refused as
179
- `stale` with the current Room Draft; read it and write again.
180
-
181
- Save takes one Room and the Room Drafts of it to save, each with its revision,
182
- validates locally, and on success appends one Change Batch to that Room's
183
- queue and removes those Room Drafts. It is refused with the `code` `stale`,
184
- `changed-underneath` naming each part whose base no longer matches the visible
185
- state, or a local validation rule, and then creates nothing and leaves every
186
- Room Draft in place. A directory move or removal is a move or removal part on
187
- each Document and binary Path entry beneath it, saved together.
188
-
189
- Outcomes follow the Provider's answer. An Accepted Change Batch stays in the
190
- queue, drawn over the confirmed layer, until the confirmed layer reaches the
191
- Room Version it was accepted at, and then leaves it. Conflicted and Rejected, an expired operation, and a change that no
192
- longer applies over the Room each leave the queue and return as Room Drafts on
193
- the Documents they changed, marked with why: the Provider's structured refusal
194
- code and fields as returned, not known to have applied, or withdrawn locally.
195
- The rest of the queue keeps synchronizing, and Sync Status requires attention
196
- until each returned Room Draft is saved again or discarded. A Change Batch
197
- keeps no outcome once it leaves the queue; `observe('queue', room)` shows each
198
- Pending one, and a returned Room Draft says why it returned. Transport
199
- failure and Provider unavailability keep work Pending and do not infer a
200
- rejection. A refusal the Provider marks retryable stays Pending until the reset
201
- it names; the MD Runtime retries the same Change Batch identity and payload and
202
- never infers an outcome from transport uncertainty. The MD Runtime never
203
- combines, reorders, or rebases.
204
-
205
- On a Site, every Save stays in the visitor's browser. Write grants and revisions
206
- do not refuse it, and its Pending Change shows in every query and across reloads
207
- until the browser's storage is cleared. It is never sent: `observe('queue', room)`
208
- shows it `local`, and Sync Status never waits on it. Once the Room changes so that
209
- it no longer applies, it leaves the queue and returns no Room Draft.
210
-
211
- `observe('service-mode')` answers the Provider's Service Mode, `open` or
212
- `write-halted`. While writes are halted, Save still succeeds, its Change Batch
213
- waits unsent, and the queue is submitted in order once the Provider reopens
214
- writes. An Action is never held: a write the Provider refuses for the halt returns
215
- that refusal to its caller. Show the Provider as read-only instead of retrying.
216
-
217
- ## The neutrality rule
218
-
219
- No module outside an Adapter package imports, names, or special-cases a
220
- Provider. MD UI and every App reach data only through the client entry.
221
-
222
- ## Content-safety rules
223
-
224
- The Provider authorization belongs to the Runtime host and is never readable
225
- by the App's code. The App's code reaches the network only at the external
226
- origins its manifest declares, empty by default, and the Provider enforces
227
- that set. Every request to the Provider itself goes through the MD Runtime.
228
- Rendered Markdown never executes scripts, renders raw HTML only for the
229
- details and summary elements, and loads images and other resources only from
230
- origins the Provider's policy allows.
231
-
232
- ## Launch promises MD UI keeps
233
-
234
- MD UI uses semantic HTML, is fully operable from a keyboard with visible
235
- focus and labelled controls, and lays out from a 360 pixel wide viewport to
236
- a desktop. Its strings are English only, dates and numbers follow the
237
- browser locale, and content is never translated. Light and dark themes come
238
- from CSS custom properties with the browser's preference as the default and
239
- an App's override respected. What an App Creator's agent adds carries none
240
- of these promises by itself. Reading, querying and searching never wait for
241
- the network. Data lives only in the App Creator's browser and with the Provider.
242
-
243
- ## App code takes the client its host hands it and never constructs a Runtime
244
-
245
- App code takes the client its host hands it: in House, `houseBridge().runtime`
246
- from `@agentshouse/app-bridge` resolves to the client House built into the page.
247
- It imports only types from `@agentshouse/mdruntime/client`, never calls
248
- `connectMdRuntime` or `serveMdRuntime`, and never imports the package main, the
249
- host entry or the Adapter package, which hosts and tests use. The in-memory
250
- Adapter at `@agentshouse/mdruntime/memory` is for tests and ships in no bundle.
251
- A Site's page fills its Entry Data Contract's `{"$param": name}` arguments with
252
- `boundQuery` from `@agentshouse/mdruntime/entry`, as House did for its HTML.
253
-
254
- A React App may observe and save through `@agentshouse/mdruntime/react`, which
255
- names React as a peer dependency. `useObserve(client, topic, ...input)` takes
256
- the arguments of `observe` and returns `{ state: 'loading' }` until the topic's
257
- first value arrives, then `{ state: 'ready', value }`, re-rendering on each
258
- change; a `null` client observes nothing and stays loading. `useSave(client)`
259
- returns `busy`, the last `outcome` or `failure`, and `save(room, roomDrafts)`,
260
- which writes each Path's parts onto the Room Draft already there, keeping the
261
- bases its parts have, or onto a new one, and saves them together. A refused
262
- Save leaves the Room Drafts for the App to save again or discard; a failure is
263
- recorded and rejects. `saveRoomDrafts(client, room, roomDrafts)` is that save
264
- outside a component. A react-admin or Refine App reads and writes its Rooms
265
- through the data providers of `@agentshouse/mdruntime-families`.
266
-
267
- ## The Chat
268
-
269
- `@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App; add
270
- React as a dependency in any App, with React DOM and `@assistant-ui/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,33 +0,0 @@
1
- import { type Answered } from '../attempt.js';
2
- import { type CallResult, type Offline } from '../outcome.js';
3
- import type { Expected } from './overlay.js';
4
- export type ChatResult = CallResult | Offline;
5
- export type ChatOutcome = {
6
- readonly state: 'sending';
7
- } | {
8
- readonly state: 'offline';
9
- } | {
10
- readonly state: 'failed';
11
- readonly result: CallResult;
12
- };
13
- export declare function accepted(result: ChatResult): result is Extract<CallResult, {
14
- readonly kind: 'action';
15
- }>;
16
- export declare function unanswered(result: ChatResult): boolean;
17
- export declare function outcomeOf(result: ChatResult): ChatOutcome | null;
18
- export declare function answeredOf(result: ChatResult): Answered;
19
- export type Sender = {
20
- carried(name: string, about: unknown, sending: (operation: string) => Promise<CallResult>): Promise<ChatResult>;
21
- numbered(name: string, about: unknown, sending: (operation: string) => Promise<ChatResult>): Promise<ChatResult>;
22
- expect(expected: Expected): void;
23
- draw(expected: Expected): void;
24
- };
25
- type Senders = {
26
- readonly online: boolean;
27
- identity(intent: string): string;
28
- expect(expected: Expected): void;
29
- draw(expected: Expected): void;
30
- };
31
- export declare function sender({ online, identity, expect, draw }: Senders): Sender;
32
- export {};
33
- //# 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,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9C,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,QAAQ,CACN,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,CAe1E"}
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
- const numbered = async (name, about, sending) => {
23
- try {
24
- return await sending(identity(intentOf(name, about)));
25
- }
26
- catch {
27
- return UNCERTAIN;
28
- }
29
- };
30
- return {
31
- carried: (name, about, sending) => online ? numbered(name, about, sending) : Promise.resolve({ kind: 'offline' }),
32
- numbered,
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
- }
@@ -1,60 +0,0 @@
1
- import { type ComponentPropsWithRef, type ReactElement, type ReactNode } from 'react';
2
- import type { ChatOutcome } from './acts.js';
3
- export type Variant = 'quiet' | 'ink' | 'outline' | 'danger' | 'danger-outline';
4
- export declare const Portal: import("react").Context<HTMLElement | null>;
5
- export declare function Within({ root, children, }: {
6
- root: HTMLElement;
7
- children: ReactNode;
8
- }): ReactElement;
9
- export declare function Scoped({ children }: {
10
- children: ReactNode;
11
- }): ReactElement;
12
- export declare function buttonClass(variant: Variant, compact: boolean, icon: boolean): string;
13
- type Native = Omit<ComponentPropsWithRef<'button'>, 'className'>;
14
- export declare function Button({ variant, compact, type, children, ...rest }: Native & {
15
- variant?: Variant;
16
- compact?: boolean;
17
- }): ReactElement;
18
- export declare function IconButton({ label, variant, compact, type, ...rest }: Native & {
19
- label: string;
20
- variant?: Variant;
21
- compact?: boolean;
22
- }): ReactElement;
23
- export declare function Name({ text, className }: {
24
- text: string;
25
- className?: string;
26
- }): ReactElement;
27
- export declare function Menu({ trigger, children, }: {
28
- trigger: ReactElement;
29
- children: ReactNode;
30
- }): ReactElement;
31
- export declare function MenuGap(): ReactElement;
32
- export declare function MenuItem({ icon, danger, onSelect, children, }: {
33
- icon: ReactNode;
34
- danger?: boolean;
35
- onSelect: () => void;
36
- children: ReactNode;
37
- }): ReactElement;
38
- export declare function Confirm({ title, text, action, onConfirm, onClose, }: {
39
- title: string;
40
- text: string;
41
- action: string;
42
- onConfirm: () => void;
43
- onClose: () => void;
44
- }): ReactElement;
45
- export declare function ItemRow({ lead, title, sub, trailing, }: {
46
- lead: ReactNode;
47
- title: ReactNode;
48
- sub: ReactNode;
49
- trailing: ReactNode;
50
- }): ReactElement;
51
- export declare function Working({ step }: {
52
- step?: string | undefined;
53
- }): ReactElement;
54
- export type ChatNoteProps = {
55
- readonly outcome: ChatOutcome | null;
56
- readonly again?: (() => void) | undefined;
57
- };
58
- export declare function ChatNote({ outcome, again }: ChatNoteProps): ReactElement | null;
59
- export {};
60
- //# sourceMappingURL=kit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../../src/chat/kit.tsx"],"names":[],"mappings":"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"}