@agentshouse/mdruntime 0.1.0-cdb8840578a20 → 0.1.0-cdded6c080913

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 (365) 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 +389 -0
  5. package/dist/actions.d.ts +20 -0
  6. package/dist/actions.d.ts.map +1 -0
  7. package/dist/actions.js +250 -0
  8. package/dist/adapter.d.ts +151 -79
  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 +319 -107
  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 -16
  26. package/dist/change-set.d.ts.map +1 -1
  27. package/dist/change-set.js +11 -88
  28. package/dist/change.d.ts +32 -1
  29. package/dist/change.d.ts.map +1 -1
  30. package/dist/change.js +10 -1
  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 +33 -10
  35. package/dist/client.d.ts.map +1 -1
  36. package/dist/client.js +98 -11
  37. package/dist/collection.d.ts +11 -21
  38. package/dist/collection.d.ts.map +1 -1
  39. package/dist/collection.js +39 -291
  40. package/dist/compile.d.ts +16 -0
  41. package/dist/compile.d.ts.map +1 -0
  42. package/dist/compile.js +717 -0
  43. package/dist/connection.d.ts +7 -129
  44. package/dist/connection.d.ts.map +1 -1
  45. package/dist/connection.js +97 -3359
  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-row.d.ts +33 -0
  50. package/dist/conversation-row.d.ts.map +1 -0
  51. package/dist/conversation-row.js +53 -0
  52. package/dist/conversation.d.ts +43 -18
  53. package/dist/conversation.d.ts.map +1 -1
  54. package/dist/conversation.js +718 -312
  55. package/dist/digest.d.ts +7 -0
  56. package/dist/digest.d.ts.map +1 -0
  57. package/dist/digest.js +113 -0
  58. package/dist/discovery.d.ts +10 -0
  59. package/dist/discovery.d.ts.map +1 -0
  60. package/dist/discovery.js +175 -0
  61. package/dist/durability.d.ts +16 -4
  62. package/dist/durability.d.ts.map +1 -1
  63. package/dist/durability.js +5 -0
  64. package/dist/entry.d.ts +5 -2
  65. package/dist/entry.d.ts.map +1 -1
  66. package/dist/entry.js +33 -28
  67. package/dist/figures.d.ts +48 -0
  68. package/dist/figures.d.ts.map +1 -0
  69. package/dist/figures.js +197 -0
  70. package/dist/file.d.ts +2 -19
  71. package/dist/file.d.ts.map +1 -1
  72. package/dist/file.js +7 -122
  73. package/dist/holdings.d.ts +29 -0
  74. package/dist/holdings.d.ts.map +1 -0
  75. package/dist/holdings.js +95 -0
  76. package/dist/host.d.ts +7 -8
  77. package/dist/host.d.ts.map +1 -1
  78. package/dist/host.js +101 -24
  79. package/dist/identity.d.ts +0 -2
  80. package/dist/identity.d.ts.map +1 -1
  81. package/dist/identity.js +0 -6
  82. package/dist/index.d.ts +32 -13
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +10 -1
  85. package/dist/install.d.ts +56 -0
  86. package/dist/install.d.ts.map +1 -0
  87. package/dist/install.js +560 -0
  88. package/dist/job.d.ts +33 -0
  89. package/dist/job.d.ts.map +1 -0
  90. package/dist/job.js +54 -0
  91. package/dist/lifecycle.d.ts +7 -0
  92. package/dist/lifecycle.d.ts.map +1 -0
  93. package/dist/lifecycle.js +267 -0
  94. package/dist/listing.d.ts +53 -0
  95. package/dist/listing.d.ts.map +1 -0
  96. package/dist/listing.js +175 -0
  97. package/dist/live.d.ts +23 -0
  98. package/dist/live.d.ts.map +1 -0
  99. package/dist/live.js +165 -0
  100. package/dist/locks.d.ts +9 -0
  101. package/dist/locks.d.ts.map +1 -0
  102. package/dist/locks.js +61 -0
  103. package/dist/log.d.ts +1 -0
  104. package/dist/log.d.ts.map +1 -1
  105. package/dist/lost.d.ts +5 -0
  106. package/dist/lost.d.ts.map +1 -0
  107. package/dist/lost.js +61 -0
  108. package/dist/media.d.ts +8 -0
  109. package/dist/media.d.ts.map +1 -0
  110. package/dist/media.js +218 -0
  111. package/dist/memory.d.ts +19 -7
  112. package/dist/memory.d.ts.map +1 -1
  113. package/dist/memory.js +248 -103
  114. package/dist/messages.d.ts +52 -0
  115. package/dist/messages.d.ts.map +1 -0
  116. package/dist/messages.js +168 -0
  117. package/dist/model.d.ts +8 -10
  118. package/dist/model.d.ts.map +1 -1
  119. package/dist/model.js +6 -18
  120. package/dist/models.d.ts +14 -0
  121. package/dist/models.d.ts.map +1 -0
  122. package/dist/models.js +193 -0
  123. package/dist/name.d.ts +4 -0
  124. package/dist/name.d.ts.map +1 -0
  125. package/dist/name.js +122 -0
  126. package/dist/observation.d.ts +17 -2
  127. package/dist/observation.d.ts.map +1 -1
  128. package/dist/observation.js +100 -5
  129. package/dist/opened.d.ts +22 -0
  130. package/dist/opened.d.ts.map +1 -0
  131. package/dist/opened.js +107 -0
  132. package/dist/opening.d.ts +4 -0
  133. package/dist/opening.d.ts.map +1 -0
  134. package/dist/opening.js +56 -0
  135. package/dist/outcome.d.ts +49 -8
  136. package/dist/outcome.d.ts.map +1 -1
  137. package/dist/outcome.js +42 -0
  138. package/dist/overlay.d.ts +4 -5
  139. package/dist/overlay.d.ts.map +1 -1
  140. package/dist/overlay.js +106 -156
  141. package/dist/{chat/parts.d.ts → parts.d.ts} +11 -9
  142. package/dist/parts.d.ts.map +1 -0
  143. package/dist/{chat/parts.js → parts.js} +45 -46
  144. package/dist/paths.d.ts +1 -0
  145. package/dist/paths.d.ts.map +1 -1
  146. package/dist/paths.js +4 -0
  147. package/dist/preparation.d.ts +20 -0
  148. package/dist/preparation.d.ts.map +1 -0
  149. package/dist/preparation.js +226 -0
  150. package/dist/queries.d.ts +16 -0
  151. package/dist/queries.d.ts.map +1 -0
  152. package/dist/queries.js +272 -0
  153. package/dist/query.d.ts +26 -185
  154. package/dist/query.d.ts.map +1 -1
  155. package/dist/query.js +3 -464
  156. package/dist/{chat/questions.d.ts → questions.d.ts} +5 -2
  157. package/dist/questions.d.ts.map +1 -0
  158. package/dist/{chat/questions.js → questions.js} +12 -1
  159. package/dist/reach.d.ts +19 -9
  160. package/dist/reach.d.ts.map +1 -1
  161. package/dist/reach.js +287 -99
  162. package/dist/react.d.ts +12 -4
  163. package/dist/react.d.ts.map +1 -1
  164. package/dist/react.js +7 -17
  165. package/dist/{chat/read.d.ts → read.d.ts} +2 -0
  166. package/dist/read.d.ts.map +1 -0
  167. package/dist/{chat/read.js → read.js} +4 -0
  168. package/dist/readiness.d.ts +14 -17
  169. package/dist/readiness.d.ts.map +1 -1
  170. package/dist/readiness.js +2 -8
  171. package/dist/reads.d.ts +36 -0
  172. package/dist/reads.d.ts.map +1 -0
  173. package/dist/reads.js +150 -0
  174. package/dist/recovery.d.ts +3 -2
  175. package/dist/recovery.d.ts.map +1 -1
  176. package/dist/recovery.js +43 -8
  177. package/dist/refresh.d.ts +17 -14
  178. package/dist/refresh.d.ts.map +1 -1
  179. package/dist/refresh.js +143 -52
  180. package/dist/refusal.d.ts +5 -0
  181. package/dist/refusal.d.ts.map +1 -0
  182. package/dist/refusal.js +56 -0
  183. package/dist/replica.d.ts +55 -33
  184. package/dist/replica.d.ts.map +1 -1
  185. package/dist/replica.js +331 -181
  186. package/dist/room-draft.d.ts +37 -6
  187. package/dist/room-draft.d.ts.map +1 -1
  188. package/dist/room-draft.js +161 -74
  189. package/dist/room-drafts.d.ts +24 -0
  190. package/dist/room-drafts.d.ts.map +1 -0
  191. package/dist/room-drafts.js +216 -0
  192. package/dist/rows.d.ts +31 -29
  193. package/dist/rows.d.ts.map +1 -1
  194. package/dist/rows.js +59 -116
  195. package/dist/runtime.d.ts +42 -0
  196. package/dist/runtime.d.ts.map +1 -0
  197. package/dist/runtime.js +1 -0
  198. package/dist/save.d.ts +53 -14
  199. package/dist/save.d.ts.map +1 -1
  200. package/dist/save.js +534 -187
  201. package/dist/saves.d.ts +70 -0
  202. package/dist/saves.d.ts.map +1 -0
  203. package/dist/saves.js +1004 -0
  204. package/dist/search.d.ts +15 -78
  205. package/dist/search.d.ts.map +1 -1
  206. package/dist/search.js +10 -184
  207. package/dist/seed.d.ts +25 -0
  208. package/dist/seed.d.ts.map +1 -0
  209. package/dist/seed.js +146 -0
  210. package/dist/shared.d.ts +7 -3
  211. package/dist/shared.d.ts.map +1 -1
  212. package/dist/shared.js +119 -66
  213. package/dist/shown.d.ts +31 -0
  214. package/dist/shown.d.ts.map +1 -0
  215. package/dist/shown.js +294 -0
  216. package/dist/socket/admission.d.ts +7 -0
  217. package/dist/socket/admission.d.ts.map +1 -0
  218. package/dist/socket/admission.js +39 -0
  219. package/dist/socket/answers.d.ts +6 -0
  220. package/dist/socket/answers.d.ts.map +1 -0
  221. package/dist/socket/answers.js +20 -0
  222. package/dist/socket/lanes.d.ts +20 -0
  223. package/dist/socket/lanes.d.ts.map +1 -0
  224. package/dist/socket/lanes.js +77 -0
  225. package/dist/socket/reads.d.ts +10 -0
  226. package/dist/socket/reads.d.ts.map +1 -0
  227. package/dist/socket/reads.js +31 -0
  228. package/dist/socket/rooms.d.ts +43 -0
  229. package/dist/socket/rooms.d.ts.map +1 -0
  230. package/dist/socket/rooms.js +90 -0
  231. package/dist/socket/session.d.ts +39 -0
  232. package/dist/socket/session.d.ts.map +1 -0
  233. package/dist/socket/session.js +23 -0
  234. package/dist/socket.d.ts +70 -0
  235. package/dist/socket.d.ts.map +1 -0
  236. package/dist/socket.js +175 -0
  237. package/dist/source.d.ts +61 -0
  238. package/dist/source.d.ts.map +1 -0
  239. package/dist/source.js +81 -0
  240. package/dist/status.d.ts +4 -5
  241. package/dist/status.d.ts.map +1 -1
  242. package/dist/status.js +3 -7
  243. package/dist/store/fences.d.ts +16 -0
  244. package/dist/store/fences.d.ts.map +1 -0
  245. package/dist/store/fences.js +26 -0
  246. package/dist/store/installs.d.ts +30 -0
  247. package/dist/store/installs.d.ts.map +1 -0
  248. package/dist/store/installs.js +34 -0
  249. package/dist/store/readiness.d.ts +10 -0
  250. package/dist/store/readiness.d.ts.map +1 -0
  251. package/dist/store/readiness.js +52 -0
  252. package/dist/store/records.d.ts +212 -0
  253. package/dist/store/records.d.ts.map +1 -0
  254. package/dist/store/records.js +408 -0
  255. package/dist/store/room-held.d.ts +8 -0
  256. package/dist/store/room-held.d.ts.map +1 -0
  257. package/dist/store/room-held.js +17 -0
  258. package/dist/store/space.d.ts +11 -0
  259. package/dist/store/space.d.ts.map +1 -0
  260. package/dist/store/space.js +43 -0
  261. package/dist/store/watchers.d.ts +17 -0
  262. package/dist/store/watchers.d.ts.map +1 -0
  263. package/dist/store/watchers.js +57 -0
  264. package/dist/store/writes.d.ts +24 -0
  265. package/dist/store/writes.d.ts.map +1 -0
  266. package/dist/store/writes.js +125 -0
  267. package/dist/store.d.ts +106 -150
  268. package/dist/store.d.ts.map +1 -1
  269. package/dist/store.js +136 -713
  270. package/dist/stored.d.ts +156 -0
  271. package/dist/stored.d.ts.map +1 -0
  272. package/dist/stored.js +637 -0
  273. package/dist/surface.d.ts +88 -0
  274. package/dist/surface.d.ts.map +1 -0
  275. package/dist/surface.js +222 -0
  276. package/dist/sync.d.ts +20 -0
  277. package/dist/sync.d.ts.map +1 -0
  278. package/dist/sync.js +531 -0
  279. package/dist/tables.d.ts +415 -0
  280. package/dist/tables.d.ts.map +1 -0
  281. package/dist/tables.js +740 -0
  282. package/dist/tallies.d.ts +18 -0
  283. package/dist/tallies.d.ts.map +1 -0
  284. package/dist/tallies.js +129 -0
  285. package/dist/transfer.d.ts +0 -5
  286. package/dist/transfer.d.ts.map +1 -1
  287. package/dist/turn.d.ts +5 -3
  288. package/dist/turn.d.ts.map +1 -1
  289. package/dist/turn.js +51 -21
  290. package/dist/validation.d.ts +29 -0
  291. package/dist/validation.d.ts.map +1 -0
  292. package/dist/validation.js +104 -0
  293. package/dist/windows.d.ts +11 -0
  294. package/dist/windows.d.ts.map +1 -0
  295. package/dist/windows.js +16 -0
  296. package/dist/wire.d.ts +50 -6
  297. package/dist/wire.d.ts.map +1 -1
  298. package/dist/wire.js +16 -2
  299. package/package.json +18 -19
  300. package/AGENTS.md +0 -300
  301. package/dist/acquisition.d.ts +0 -14
  302. package/dist/acquisition.d.ts.map +0 -1
  303. package/dist/acquisition.js +0 -24
  304. package/dist/chat/acts.d.ts +0 -33
  305. package/dist/chat/acts.d.ts.map +0 -1
  306. package/dist/chat/acts.js +0 -36
  307. package/dist/chat/context.d.ts +0 -3
  308. package/dist/chat/context.d.ts.map +0 -1
  309. package/dist/chat/input.d.ts +0 -9
  310. package/dist/chat/input.d.ts.map +0 -1
  311. package/dist/chat/input.js +0 -99
  312. package/dist/chat/kit.d.ts +0 -61
  313. package/dist/chat/kit.d.ts.map +0 -1
  314. package/dist/chat/kit.js +0 -123
  315. package/dist/chat/lasting.d.ts +0 -6
  316. package/dist/chat/lasting.d.ts.map +0 -1
  317. package/dist/chat/lasting.js +0 -19
  318. package/dist/chat/list.d.ts +0 -27
  319. package/dist/chat/list.d.ts.map +0 -1
  320. package/dist/chat/list.js +0 -63
  321. package/dist/chat/markdown.d.ts +0 -20
  322. package/dist/chat/markdown.d.ts.map +0 -1
  323. package/dist/chat/markdown.js +0 -188
  324. package/dist/chat/message.d.ts +0 -6
  325. package/dist/chat/message.d.ts.map +0 -1
  326. package/dist/chat/message.js +0 -192
  327. package/dist/chat/messages.d.ts +0 -22
  328. package/dist/chat/messages.d.ts.map +0 -1
  329. package/dist/chat/messages.js +0 -155
  330. package/dist/chat/name.d.ts +0 -6
  331. package/dist/chat/name.d.ts.map +0 -1
  332. package/dist/chat/name.js +0 -37
  333. package/dist/chat/opened.d.ts +0 -11
  334. package/dist/chat/opened.d.ts.map +0 -1
  335. package/dist/chat/opened.js +0 -17
  336. package/dist/chat/overlay.d.ts +0 -31
  337. package/dist/chat/overlay.d.ts.map +0 -1
  338. package/dist/chat/overlay.js +0 -97
  339. package/dist/chat/parts.d.ts.map +0 -1
  340. package/dist/chat/process.d.ts +0 -20
  341. package/dist/chat/process.d.ts.map +0 -1
  342. package/dist/chat/process.js +0 -32
  343. package/dist/chat/provider.d.ts +0 -63
  344. package/dist/chat/provider.d.ts.map +0 -1
  345. package/dist/chat/provider.js +0 -629
  346. package/dist/chat/question.d.ts +0 -9
  347. package/dist/chat/question.d.ts.map +0 -1
  348. package/dist/chat/question.js +0 -80
  349. package/dist/chat/questions.d.ts.map +0 -1
  350. package/dist/chat/read.d.ts.map +0 -1
  351. package/dist/chat/ready.d.ts +0 -34
  352. package/dist/chat/ready.d.ts.map +0 -1
  353. package/dist/chat/ready.js +0 -91
  354. package/dist/chat/style.d.ts +0 -4
  355. package/dist/chat/style.d.ts.map +0 -1
  356. package/dist/chat/style.js +0 -302
  357. package/dist/chat.d.ts +0 -14
  358. package/dist/chat.d.ts.map +0 -1
  359. package/dist/chat.js +0 -8
  360. package/dist/fence.d.ts +0 -6
  361. package/dist/fence.d.ts.map +0 -1
  362. package/dist/fence.js +0 -10
  363. package/dist/read-side.d.ts +0 -25
  364. package/dist/read-side.d.ts.map +0 -1
  365. package/dist/read-side.js +0 -639
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime",
3
- "version": "0.1.0-cdb8840578a20",
3
+ "version": "0.1.0-cdded6c080913",
4
4
  "description": "The headless core of MD App",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "access": "public"
10
10
  },
11
11
  "engines": {
12
- "node": ">=24.21.0"
12
+ "node": ">=24.22.1"
13
13
  },
14
14
  "exports": {
15
15
  ".": {
@@ -32,37 +32,36 @@
32
32
  "types": "./dist/memory.d.ts",
33
33
  "default": "./dist/memory.js"
34
34
  },
35
+ "./tables": {
36
+ "types": "./dist/tables.d.ts",
37
+ "default": "./dist/tables.js"
38
+ },
35
39
  "./react": {
36
40
  "types": "./dist/react.d.ts",
37
41
  "default": "./dist/react.js"
38
42
  },
39
- "./chat": {
40
- "types": "./dist/chat.d.ts",
41
- "default": "./dist/chat.js"
43
+ "./digest": {
44
+ "types": "./dist/digest.d.ts",
45
+ "default": "./dist/digest.js"
42
46
  },
43
47
  "./package.json": "./package.json"
44
48
  },
45
49
  "files": [
46
50
  "dist",
47
- "AGENTS.md",
51
+ "!dist/chat.*",
52
+ "!dist/chat/",
48
53
  "README.md",
49
54
  "LICENSE"
50
55
  ],
51
56
  "dependencies": {
52
- "@agentshouse/mdmodel": "0.1.0-cad192ab63d5f",
53
- "@assistant-ui/react-markdown": "0.14.20",
54
- "@tanstack/db": "0.9.2",
55
- "lucide-react": "1.47.0",
56
- "mdast-util-from-markdown": "2.0.3",
57
- "mdast-util-gfm": "3.1.0",
58
- "micromark-extension-gfm": "3.0.0",
59
- "minisearch": "7.2.0",
60
- "radix-ui": "1.8.0",
61
- "remark-gfm": "4.0.1"
57
+ "@agentshouse/mdmodel": "0.1.0-c36da0b08f3db"
62
58
  },
63
59
  "peerDependencies": {
64
- "@assistant-ui/react": "^0.15.22",
65
- "react": ">=18",
66
- "react-dom": ">=18"
60
+ "react": ">=18"
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/agentshouse/core.git",
65
+ "directory": "mdruntime/packages/mdruntime"
67
66
  }
68
67
  }
package/AGENTS.md DELETED
@@ -1,300 +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 Rooms,
9
- Query, Search, Observe, Types, Room Draft, Save, History, the binary file reads, Call,
10
- Reached, Log, the reported persistence answer, reauthorization, conversation, the chat
11
- draft, and Presentation State. Sync Status, readiness, 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 answers
15
- within it: a Room outside it answers as one the replica does not hold, Rooms lists only
16
- the Rooms reached whole, a Room reached for single Documents shows only those Documents
17
- and the Types of the models that govern them, and without conversations the conversation
18
- members, the chat draft and the conversation observation hold none. A change of the
19
- reach reaches every open observation as its new value, a query keeping unchanged
20
- Documents the same objects.
21
-
22
- Every `observe` resolves, once its first value has arrived, to a handle: `current()` is
23
- the latest complete value, `subscribe(listener)` hears each later value whole and returns
24
- its unsubscribe, and `close()` ends the observation. Closing the port ends every handle
25
- and rejects every pending call and observation; a client that reconnects observes again.
26
-
27
- `observe('agents')` answers every Agent a new conversation can go to, each `{ identity,
28
- name }`, whether or not it has a conversation yet. Each conversation the Provider's
29
- conversation list names is held complete in the browser. `conversation.list()` and
30
- `observe('conversations')` answer each with its Agent's identity and name, its name,
31
- created and finished times, last outcome and live `state`: `asking` while a question
32
- waits, `working` while a turn runs, else `idle`, and `started`, when the running turn
33
- began, or `null`. Observe one with `observe('conversation', id, { limit })`: the view
34
- holds a window of its latest `limit` messages, or all of them, oldest first, its chat
35
- draft, and what the Provider streams for it whether or not anything views it: the
36
- running `turn` with its message parts and its context in use and window, the open
37
- questions, the process state, and the CLI's commands and options. These live only in
38
- memory: the message accepted under the turn's id replaces the running turn, and none of
39
- them is stored or searchable. `chatDraft.write` and `chatDraft.discard` keep what the
40
- App Creator composes; sending it is a Provider Action that needs the Provider reachable
41
- and is never queued. A new conversation's chat draft is the one keyed `new:<Agent
42
- identity>`: no conversation list removes it, a retired Agent's goes, and the first answer
43
- to `conversation.create({ agent_id, operation_id })` moves it to the created conversation,
44
- where `conversation.send(conversation)` sends it; a replay of that create moves nothing.
45
-
46
- A binary file at a Path is a binary Path entry. Query lists it by `path`, and History
47
- each of its revisions, with its `binaryFile` record and never its bytes: `{ state:
48
- 'accepted', revision, path, fileRef, byteLength, mediaType, sha256 }`, or, from a Save
49
- until the Provider accepts it, `{ state: 'pending', localId, path, byteLength,
50
- mediaType, sha256 }`. Write one with a Room Draft whose only part is `file: { blob }`,
51
- the `Blob`'s `type` its media type: Save keeps the bytes in its Pending Change, offline
52
- too, and acceptance gives the record the Provider's revision. Move or remove one as a
53
- Document, a pending one before or after Save too, its bytes following; once its Pending
54
- Change has gone to the Provider, Save refuses that as `unknown-revision` until it is
55
- accepted. `binaryFile.read(room, path, revision?)` answers a pending record's saved
56
- bytes, or asks the Provider again on every read of an accepted one or of a History
57
- revision, a removed file's last included, keeping nothing. Text, a Record attachment or
58
- a conversation message may name a file by its `fileRef`; read it with
59
- `binaryFile.readReference({ fileRef, referrer })`, the referrer being the `referrer` the
60
- Provider gave beside it, or `{ room, path }` of the document whose text names it. Both
61
- answer `{ kind: 'binary', blob }` or a refusal or failure.
62
-
63
- Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never touch the
64
- network. History, the binary file reads and Call go to the Provider through the Adapter.
65
- Call takes the Action names the Adapter declares; any other name answers `undeclared`
66
- without reaching the Provider. A Call result whose effect the Provider places in a Room
67
- carries `at`, that Room and Room Version; `reached(room, roomVersion)` answers whether
68
- the Room's confirmed state has reached it, and the MD Runtime keeps refreshing that Room
69
- until it has; `reached(room, roomVersion, path)` answers whether the held confirmed copy
70
- of that document was written at a later Room Version. Each History revision names its
71
- author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`. History of a Path no
72
- current document holds answers the removed document's revisions with `deleted: true`,
73
- newest first; that revision is what a link to the Path opens. Every member of the client
74
- is asynchronous. Results are detached snapshots. Nothing in this surface returns the
75
- authorization, performs a request the App's code composes, or exposes the browser store.
76
-
77
- Every refusal and failure carries `code` and `retryable`: each Call and History answer
78
- other than its result, a refused Save or Room Draft write, a returned Room Draft's
79
- reason, a Room's refusal and the Connection Refusal, and every error a member rejects
80
- with, beside its message. A Provider refusal carries the Provider's own `retryable`.
81
- Every code and every value the API answers is open: handle one you do not know by its
82
- `code` and `retryable`. Only a tag telling which fields a value carries, such as an
83
- answer's `kind`, is closed so it narrows: keep a branch for a tag you do not know. A
84
- model with no usable types answers `types: null`, whatever its `status`.
85
-
86
- Read the deployment facts with `observe('deployment-facts')`, an opaque value the host's
87
- contract interprets. `observe('member')` answers who uses the App: the User the Provider
88
- signed in, `{ kind: 'user', id, name }` in the shape of a change's `author`, so a
89
- Document whose `change.author.id` equals its `id` is that User's own. It is `null` until
90
- the Provider first names one, and where it names none, such as a Site. The MD Runtime
91
- keeps it with the Local Replicas, so it answers offline once known, and every port hears
92
- the next member the Provider names; signing out answers `null`, then ends the
93
- observation with the authorization. It is the only way App code learns who uses it.
94
-
95
- ## Local Query rules
96
-
97
- `query(q)` answers once from local state; `observe('query', q)` holds the whole result
98
- and hears it again only when it changes, keeping every unchanged Document the same
99
- object, so a component can tell what changed by identity. An answer is complete or
100
- pending: `{ documents, coverage }` or `{ groups, coverage }` is complete for the Rooms
101
- its `coverage` names, and `{ pending }` names each Room not yet acquired or prepared,
102
- `[{ room, awaits }]`. Never read a pending answer as empty: draw it as loading, and
103
- observe the query to hear the complete one. A query is data:
104
-
105
- - **Filter.** `rooms` names Room locators and defaults to every Room. `types` names MD
106
- Types, and `any` names untyped Markdown Documents. `pathPrefix` is a directory:
107
- `notes` keeps `notes/a.md` and not `notes2/a.md`.
108
- - **Fields.** Every frontmatter value is named by JSON Pointer: `/status`,
109
- `/shipping/city`, `~1` for a `/` and `~0` for a `~` in a key. A segment that meets a
110
- list applies to every item and a number names one item. `where` names pointers, ANDs
111
- them, and nests `$and` and `$or`; a pointer through a list holds if any item satisfies
112
- it. A bare value is equality; the operators are `$eq`, `$ne`, `$in`, `$nin`, `$gt`,
113
- `$gte`, `$lt`, `$lte`, `$all`, `$size` and `$exists`. Equality on a list asks if it
114
- contains the value. Missing, null and empty differ: `$exists: false` keeps a missing
115
- field, `null` an explicit null, `''` empty text and `$size: 0` an empty list. A date
116
- compares in calendar order and never with a date-time. A reference compares by the
117
- Room 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 same
121
- Room. `backlinks: { field, types, where, pathPrefix }` keeps Documents that a matching
122
- 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 list
125
- of pointers and `sections` `'all'` or a list of names. Selected pointers return the
126
- frontmatter holding only them, nested as written. A backlink names the referring Path,
127
- MD Type and the pointer it came from as `field`. Room and Path always return; a
128
- Markdown 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, whatever is
130
- selected. An unselected part is absent. Select only what a screen shows: a list that
131
- selects the Markdown hears every edit of it.
132
- - **Change.** `change` is `{ author, time }` of the Document's head revision as the
133
- Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }` or `null`
134
- for a write the Provider made itself, and `time` is the Provider's ISO 8601 change
135
- time. It is `null` where the Provider delivered no time, as at a Site. An unsent edit
136
- or move keeps it, an unsent creation has none, and a saved write takes the Provider's
137
- own once it is Accepted. A Room's last change is its Document with the latest `time`.
138
- - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }` with
139
- TanStack DB's own options, and ties end with Room, then Path. `groupBy` by `room`,
140
- `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted over every match
141
- and ordered by `count` or a key. A sort or group takes only a pointer that holds one
142
- value. `limit` bounds the Documents or the groups.
143
- - **Results and errors.** A result carries no Room Version: read freshness from Rooms
144
- and Sync Status. `coverage` names each Room read as `{ room, generation, current }`,
145
- `current` false while a newer copy of that Room is being fetched, and the queued
146
- changes it includes as `overlay`; a Save in a Room changes the `overlay` of every
147
- query over it. An invalid query fails with the `code` `invalid-query`, `unknown-type`,
148
- `unknown-field` or `wrong-kind`, naming where, and never answers empty in its place.
149
-
150
- ## Local Search rules
151
-
152
- `search({ text, documents, conversations, limit })` answers once, by words, from local
153
- state, with MiniSearch's defaults. There is no observed search.
154
-
155
- - **What is found.** A Document by its field values, its sections' headings and text,
156
- its preamble and its Path; a message by its text. Frontmatter keys, Room Drafts, chat
157
- drafts and a running turn's parts are never found. There are no phrases, word forms,
158
- typo tolerance or prefix matching.
159
- - **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
160
- `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both apply
161
- before `limit`, which bounds each list; without it every hit returns.
162
- - **Results.** `{ documents, messages, coverage }`, or the same with `pending` naming
163
- each Room or conversation the search waits for while its index is prepared: show its
164
- hits, ask again, and never read pending as no hits. `coverage` names the Rooms and
165
- conversations searched. Each
166
- list is ranked by `score`, which compares hits of one list of one search. A Document
167
- hit names its `room`, `path` and `type`, a message hit its `conversation` and
168
- `identity`, and `matches` maps each matched word to the parts it matched in: `fields`,
169
- `sections`, `preamble` or `path`, or `text`. A hit carries no position; mark the words
170
- in the text you show. An invalid filter fails with its Local Query error.
171
-
172
- ## Room Draft, Save, and outcome rules
173
-
174
- The MD Runtime owns one Room Draft per Room and Path, shared by every App and tab. It is
175
- durable: it survives reload and navigation. A Room that Discovery stops listing takes its
176
- Room Drafts and its queue with it. Write a Room Draft with `roomDraft.write(room, path,
177
- revision, parts)`, naming the revision you read, or `null` when there was none, and every
178
- part it should now change: fields, sections and the preamble, or the whole Markdown, a
179
- creation, a move, or a removal. A part new to the Room Draft names its base, the value
180
- you showed when it was opened; the MD Runtime keeps a part's first base; a binary Path
181
- entry's move or removal takes `null` as its base. A write or a discard from an older
182
- revision is refused as `stale` with the current Room Draft; read it and write again.
183
-
184
- Save takes one Room and the Room Drafts of it to save, each with its revision, validates
185
- locally, and on success appends one Change Batch to that Room's queue and removes those
186
- Room Drafts. It is refused with the `code` `stale`, `changed-underneath` naming each
187
- part whose base no longer matches the visible state, or a local validation rule, and
188
- then creates nothing and leaves every Room Draft in place. A directory move or removal
189
- is that part on each Document and binary Path entry beneath it, saved together.
190
-
191
- Outcomes follow the Provider's answer. An Accepted Change Batch stays in the queue,
192
- drawn over the confirmed layer, until the confirmed layer reaches the Room Version it
193
- was accepted at, and then leaves it. Conflicted and Rejected, an expired operation, and
194
- a change that no longer applies over the Room each leave the queue and return as Room
195
- Drafts on the Documents they changed, marked with why: the Provider's structured refusal
196
- code and fields as returned, not known to have applied, or withdrawn locally. The rest
197
- of the queue keeps synchronizing, and Sync Status requires attention until each returned
198
- Room Draft is saved again or discarded. A Change Batch keeps no outcome once it leaves
199
- the queue; `observe('queue', room)` shows each Pending one, and a returned Room Draft
200
- says why it returned. Transport failure and Provider unavailability keep work Pending
201
- and do not infer a rejection. A refusal the Provider marks retryable stays Pending until
202
- the reset it names; the MD Runtime retries the same Change Batch identity and payload
203
- and never infers an outcome from transport uncertainty. The MD Runtime never combines,
204
- reorders, or rebases.
205
-
206
- On a Site, every Save stays in the visitor's browser. Write grants and revisions do not
207
- refuse it, and its Pending Change shows in every query and across reloads until the
208
- browser's storage is cleared. It is never sent: `observe('queue', room)` shows it
209
- `local`, and Sync Status never waits on it. Once the Room changes so that it no longer
210
- applies, it leaves the queue and returns no Room Draft.
211
-
212
- `observe('service-mode')` answers the Provider's Service Mode, `open` or `write-halted`.
213
- While writes are halted, Save still succeeds, its Change Batch waits unsent, and the
214
- queue is submitted in order once the Provider reopens writes. An Action is never held: a
215
- write the Provider refuses for the halt returns that refusal to its caller. Show the
216
- Provider as read-only instead of retrying.
217
-
218
- `observe('readiness')` tells whether the App's code and bound Rooms are held locally
219
- (`ready`), each Room's state, each refused Room's file and rule, the persistence answer
220
- and a paused preparation's `capacity` cause; `retry()` resumes a paused preparation.
221
-
222
- ## The neutrality rule
223
-
224
- No module outside an Adapter package imports, names, or special-cases a Provider. MD UI
225
- and every App reach data only through the client entry.
226
-
227
- ## Content-safety rules
228
-
229
- The Provider authorization belongs to the Runtime host and is never readable by the
230
- App's code. The App's code reaches the network only at the external origins its manifest
231
- declares, empty by default, and the Provider enforces that set. Every request to the
232
- Provider itself goes through the MD Runtime. Rendered Markdown never executes scripts,
233
- renders raw HTML only for the details and summary elements, and loads images and other
234
- resources only from origins the Provider's policy allows.
235
-
236
- ## Launch promises MD UI keeps
237
-
238
- MD UI uses semantic HTML, is fully operable from a keyboard with visible focus and
239
- labelled controls, and lays out from a 360 pixel wide viewport to a desktop. Its strings
240
- are English only, dates and numbers follow the browser locale, and content is never
241
- translated. Light and dark themes come from CSS custom properties with the browser's
242
- preference as the default and an App's override respected. What an App Creator's agent
243
- adds carries none of these promises by itself. Reading, querying and searching never
244
- wait for the network. Data lives only in the App Creator's browser and with the
245
- Provider.
246
-
247
- ## App code takes the client its host hands it and never constructs a Runtime
248
-
249
- App code takes the client its host hands it: in House, `houseBridge().runtime` from
250
- `@agentshouse/app-bridge` resolves to the client House built into the page. It imports
251
- only types from `@agentshouse/mdruntime/client`, never calls `connectMdRuntime` or
252
- `serveMdRuntime`, and never imports the package main, the host entry or the Adapter
253
- package, which hosts and tests use. The in-memory Adapter at
254
- `@agentshouse/mdruntime/memory` is for tests and ships in no bundle. A Site's page fills
255
- its Entry Data Contract's `{"$param": name}` arguments with `boundQuery` from
256
- `@agentshouse/mdruntime/entry`, as House did for its HTML.
257
-
258
- A React App may observe and save through `@agentshouse/mdruntime/react`, which names
259
- React as a peer dependency. `useObserve(client, topic, ...input)` takes the arguments of
260
- `observe` and returns `{ state: 'loading' }` until the topic's first value arrives, then
261
- `{ state: 'ready', value }`, re-rendering on each change; a `null` client observes
262
- nothing and stays loading. `useSave(client)` returns `busy`, the last `outcome` or
263
- `failure`, and `save(room, roomDrafts)`, which writes each Path's parts onto the Room
264
- Draft already there, keeping the bases its parts have, or onto a new one, and saves them
265
- together. A refused Save leaves the Room Drafts for the App to save again or discard; a
266
- failure is recorded and rejects. `saveRoomDrafts(client, room, roomDrafts)` is that save
267
- outside a component. A react-admin or Refine App reads and writes its Rooms through the
268
- data providers of `@agentshouse/mdruntime-families`.
269
-
270
- ## The Chat
271
-
272
- `@agentshouse/mdruntime/chat` holds the Chat, one data layer for every App; add React as
273
- a dependency in any App, with React DOM and `@assistant-ui/react`.
274
-
275
- Place the ready chat with `<Chat client={runtime} conversation={id} agent={agent}
276
- width="1/3" showChats />`: `conversation` opens one, `null` for a new chat, `agent` is
277
- the Agent a new chat goes to, `onOpen` hears each one it opens, and `width` is `full`
278
- (the place you give it), or `3/4`, `1/2` or `1/3` of the window docked at its right
279
- edge, whole on a narrow window. `showChats` adds its conversation list; or draw your own
280
- inside a `ChatProvider` around a `<Chat />` with no `client`. It carries its own styles;
281
- theme it with CSS custom properties on it or an ancestor: `--chat-background`,
282
- `--chat-surface`, `--chat-text`, `--chat-text-muted`, `--chat-accent`, `--chat-line`,
283
- `--chat-attention`, `--chat-danger`, `--chat-font`, `--chat-font-mono`,
284
- `--chat-font-size`, `--chat-radius` and `--chat-density` (a factor for spacing); an
285
- unset one keeps House's light or dark look. `mountChat(element, { client })` places it
286
- outside React and returns `update(props)` and `unmount()`.
287
-
288
- Mix `ChatMessageList` (`components` takes your `UserMessage` and `AssistantMessage`),
289
- `ChatInput` and `ChatQuestionCard` with your own design inside a `ChatProvider`, or
290
- compose assistant-ui's primitives there; `useChat()` gives `send`, the conversations,
291
- the Agents, questions to `answer`, `options` to `choose`, `commands`, the queue to
292
- `edit` or `unqueue`, `stop`, `kill` and outcomes; never replace its messages, sending or
293
- store. A secret question is never answered here; typed answers live in Presentation
294
- State's `typed` key: keep it, and change Presentation State only inside `inTurn(client,
295
- work)` from `@agentshouse/mdruntime/client`. `Markdown` draws Markdown safely.
296
-
297
- ## What an agent must never do
298
-
299
- An agent must never read the authorization, load code from a Room, call the Provider
300
- directly, or rebase a refused Change Batch.
@@ -1,14 +0,0 @@
1
- export type RuntimeDemand = {
2
- readonly whole: boolean;
3
- readonly rooms: readonly string[];
4
- readonly handles: readonly string[];
5
- readonly conversations: boolean;
6
- };
7
- export declare const WHOLE_DEMAND: RuntimeDemand;
8
- export declare function demanded(demand: RuntimeDemand, room: {
9
- readonly locator: string;
10
- readonly handle: string;
11
- }): boolean;
12
- export declare function wider(next: RuntimeDemand, current: RuntimeDemand): boolean;
13
- export declare function narrower(next: RuntimeDemand, current: RuntimeDemand): boolean;
14
- //# sourceMappingURL=acquisition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acquisition.d.ts","sourceRoot":"","sources":["../src/acquisition.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,aAK1B,CAAC;AAEF,wBAAgB,QAAQ,CACtB,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1D,OAAO,CAIT;AAYD,wBAAgB,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAE1E;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAE7E"}
@@ -1,24 +0,0 @@
1
- export const WHOLE_DEMAND = {
2
- whole: true,
3
- rooms: [],
4
- handles: [],
5
- conversations: true,
6
- };
7
- export function demanded(demand, room) {
8
- return (demand.whole || demand.rooms.includes(room.locator) || demand.handles.includes(room.handle));
9
- }
10
- function adds(next, current) {
11
- if (current.whole)
12
- return false;
13
- if (next.whole)
14
- return true;
15
- return ((next.conversations && !current.conversations) ||
16
- next.rooms.some((room) => !current.rooms.includes(room)) ||
17
- next.handles.some((handle) => !current.handles.includes(handle)));
18
- }
19
- export function wider(next, current) {
20
- return adds(next, current);
21
- }
22
- export function narrower(next, current) {
23
- return adds(current, next);
24
- }
@@ -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
- }