@agentshouse/mdruntime 0.1.0-c94cfdbdb6f68 → 0.1.0-c94da29691059

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 (410) hide show
  1. package/README.md +24 -19
  2. package/dist/acceptance.d.ts +3 -0
  3. package/dist/acceptance.d.ts.map +1 -0
  4. package/dist/acceptance.js +299 -0
  5. package/dist/act-lanes.d.ts +30 -0
  6. package/dist/act-lanes.d.ts.map +1 -0
  7. package/dist/act-lanes.js +225 -0
  8. package/dist/actions.d.ts +26 -0
  9. package/dist/actions.d.ts.map +1 -0
  10. package/dist/actions.js +302 -0
  11. package/dist/adapter.d.ts +215 -123
  12. package/dist/adapter.d.ts.map +1 -1
  13. package/dist/attached-model.d.ts +6 -10
  14. package/dist/attached-model.d.ts.map +1 -1
  15. package/dist/attached-model.js +35 -41
  16. package/dist/authored.d.ts +88 -0
  17. package/dist/authored.d.ts.map +1 -0
  18. package/dist/authored.js +345 -0
  19. package/dist/binary.d.ts +0 -5
  20. package/dist/binary.d.ts.map +1 -1
  21. package/dist/binary.js +1 -1
  22. package/dist/bootstrap.d.ts +30 -11
  23. package/dist/bootstrap.d.ts.map +1 -1
  24. package/dist/bootstrap.js +309 -113
  25. package/dist/cell.d.ts +6 -0
  26. package/dist/cell.d.ts.map +1 -0
  27. package/dist/cell.js +9 -0
  28. package/dist/chain.d.ts +12 -0
  29. package/dist/chain.d.ts.map +1 -0
  30. package/dist/chain.js +64 -0
  31. package/dist/change-set.d.ts +13 -16
  32. package/dist/change-set.d.ts.map +1 -1
  33. package/dist/change-set.js +17 -89
  34. package/dist/change.d.ts +36 -1
  35. package/dist/change.d.ts.map +1 -1
  36. package/dist/change.js +17 -3
  37. package/dist/chat-types.d.ts +3 -0
  38. package/dist/chat-types.d.ts.map +1 -0
  39. package/dist/chat-types.js +11 -0
  40. package/dist/client.d.ts +41 -26
  41. package/dist/client.d.ts.map +1 -1
  42. package/dist/client.js +86 -24
  43. package/dist/collection.d.ts +32 -21
  44. package/dist/collection.d.ts.map +1 -1
  45. package/dist/collection.js +53 -318
  46. package/dist/column.d.ts +5 -0
  47. package/dist/column.d.ts.map +1 -0
  48. package/dist/column.js +9 -0
  49. package/dist/compile.d.ts +18 -0
  50. package/dist/compile.d.ts.map +1 -0
  51. package/dist/compile.js +723 -0
  52. package/dist/connection.d.ts +7 -137
  53. package/dist/connection.d.ts.map +1 -1
  54. package/dist/connection.js +110 -3602
  55. package/dist/context.d.ts +2 -0
  56. package/dist/context.d.ts.map +1 -0
  57. package/dist/{chat/context.js → context.js} +2 -5
  58. package/dist/conversation-live.d.ts +150 -0
  59. package/dist/conversation-live.d.ts.map +1 -0
  60. package/dist/conversation-live.js +259 -0
  61. package/dist/conversation-row.d.ts +40 -0
  62. package/dist/conversation-row.d.ts.map +1 -0
  63. package/dist/conversation-row.js +66 -0
  64. package/dist/conversation.d.ts +79 -50
  65. package/dist/conversation.d.ts.map +1 -1
  66. package/dist/conversation.js +1031 -807
  67. package/dist/declaration.d.ts +10 -0
  68. package/dist/declaration.d.ts.map +1 -0
  69. package/dist/declaration.js +24 -0
  70. package/dist/digest.d.ts +7 -0
  71. package/dist/digest.d.ts.map +1 -0
  72. package/dist/digest.js +113 -0
  73. package/dist/discovery.d.ts +11 -0
  74. package/dist/discovery.d.ts.map +1 -0
  75. package/dist/discovery.js +157 -0
  76. package/dist/download.d.ts +6 -0
  77. package/dist/download.d.ts.map +1 -0
  78. package/dist/download.js +42 -0
  79. package/dist/durability.d.ts +21 -4
  80. package/dist/durability.d.ts.map +1 -1
  81. package/dist/durability.js +12 -0
  82. package/dist/entry.d.ts +5 -2
  83. package/dist/entry.d.ts.map +1 -1
  84. package/dist/entry.js +33 -29
  85. package/dist/expectation.d.ts +26 -13
  86. package/dist/expectation.d.ts.map +1 -1
  87. package/dist/expectation.js +72 -19
  88. package/dist/failure.d.ts +3 -0
  89. package/dist/failure.d.ts.map +1 -1
  90. package/dist/failure.js +8 -0
  91. package/dist/figures.d.ts +49 -0
  92. package/dist/figures.d.ts.map +1 -0
  93. package/dist/figures.js +199 -0
  94. package/dist/file.d.ts +2 -19
  95. package/dist/file.d.ts.map +1 -1
  96. package/dist/file.js +8 -122
  97. package/dist/holdings.d.ts +29 -0
  98. package/dist/holdings.d.ts.map +1 -0
  99. package/dist/holdings.js +95 -0
  100. package/dist/host.d.ts +21 -8
  101. package/dist/host.d.ts.map +1 -1
  102. package/dist/host.js +125 -51
  103. package/dist/identity.d.ts +0 -2
  104. package/dist/identity.d.ts.map +1 -1
  105. package/dist/identity.js +0 -6
  106. package/dist/index.d.ts +42 -16
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +20 -4
  109. package/dist/install.d.ts +60 -0
  110. package/dist/install.d.ts.map +1 -0
  111. package/dist/install.js +537 -0
  112. package/dist/lifecycle.d.ts +7 -0
  113. package/dist/lifecycle.d.ts.map +1 -0
  114. package/dist/lifecycle.js +282 -0
  115. package/dist/listing.d.ts +52 -0
  116. package/dist/listing.d.ts.map +1 -0
  117. package/dist/listing.js +152 -0
  118. package/dist/live.d.ts +25 -0
  119. package/dist/live.d.ts.map +1 -0
  120. package/dist/live.js +206 -0
  121. package/dist/loaded.d.ts +5 -0
  122. package/dist/loaded.d.ts.map +1 -0
  123. package/dist/loaded.js +40 -0
  124. package/dist/locks.d.ts +7 -0
  125. package/dist/locks.d.ts.map +1 -0
  126. package/dist/locks.js +32 -0
  127. package/dist/lost.d.ts +5 -0
  128. package/dist/lost.d.ts.map +1 -0
  129. package/dist/lost.js +49 -0
  130. package/dist/media.d.ts +25 -0
  131. package/dist/media.d.ts.map +1 -0
  132. package/dist/media.js +296 -0
  133. package/dist/memory.d.ts +21 -7
  134. package/dist/memory.d.ts.map +1 -1
  135. package/dist/memory.js +312 -118
  136. package/dist/messages.d.ts +58 -0
  137. package/dist/messages.d.ts.map +1 -0
  138. package/dist/messages.js +160 -0
  139. package/dist/modal.d.ts +2 -0
  140. package/dist/modal.d.ts.map +1 -0
  141. package/dist/modal.js +11 -0
  142. package/dist/model.d.ts +8 -11
  143. package/dist/model.d.ts.map +1 -1
  144. package/dist/model.js +6 -23
  145. package/dist/models.d.ts +10 -0
  146. package/dist/models.d.ts.map +1 -0
  147. package/dist/models.js +153 -0
  148. package/dist/name.d.ts +4 -0
  149. package/dist/name.d.ts.map +1 -0
  150. package/dist/name.js +122 -0
  151. package/dist/observation.d.ts +38 -10
  152. package/dist/observation.d.ts.map +1 -1
  153. package/dist/observation.js +232 -44
  154. package/dist/opened.d.ts +22 -0
  155. package/dist/opened.d.ts.map +1 -0
  156. package/dist/opened.js +107 -0
  157. package/dist/opening.d.ts +4 -0
  158. package/dist/opening.d.ts.map +1 -0
  159. package/dist/opening.js +53 -0
  160. package/dist/outcome.d.ts +57 -10
  161. package/dist/outcome.d.ts.map +1 -1
  162. package/dist/outcome.js +71 -2
  163. package/dist/overlay.d.ts +8 -6
  164. package/dist/overlay.d.ts.map +1 -1
  165. package/dist/overlay.js +121 -182
  166. package/dist/page-metadata.d.ts +8 -0
  167. package/dist/page-metadata.d.ts.map +1 -0
  168. package/dist/page-metadata.js +19 -0
  169. package/dist/parts.d.ts +4 -0
  170. package/dist/parts.d.ts.map +1 -0
  171. package/dist/parts.js +13 -0
  172. package/dist/paths.d.ts +2 -0
  173. package/dist/paths.d.ts.map +1 -1
  174. package/dist/paths.js +26 -0
  175. package/dist/preparation.d.ts +41 -0
  176. package/dist/preparation.d.ts.map +1 -0
  177. package/dist/preparation.js +314 -0
  178. package/dist/presence.d.ts +58 -0
  179. package/dist/presence.d.ts.map +1 -0
  180. package/dist/presence.js +231 -0
  181. package/dist/queries.d.ts +16 -0
  182. package/dist/queries.d.ts.map +1 -0
  183. package/dist/queries.js +308 -0
  184. package/dist/query.d.ts +21 -207
  185. package/dist/query.d.ts.map +1 -1
  186. package/dist/query.js +3 -493
  187. package/dist/{chat/questions.d.ts → questions.d.ts} +6 -7
  188. package/dist/questions.d.ts.map +1 -0
  189. package/dist/{chat/questions.js → questions.js} +12 -7
  190. package/dist/queue.d.ts +40 -0
  191. package/dist/queue.d.ts.map +1 -0
  192. package/dist/queue.js +480 -0
  193. package/dist/reach.d.ts +21 -11
  194. package/dist/reach.d.ts.map +1 -1
  195. package/dist/reach.js +350 -112
  196. package/dist/react.d.ts +19 -3
  197. package/dist/react.d.ts.map +1 -1
  198. package/dist/react.js +33 -1
  199. package/dist/{chat/read.d.ts → read.d.ts} +2 -0
  200. package/dist/read.d.ts.map +1 -0
  201. package/dist/{chat/read.js → read.js} +4 -0
  202. package/dist/readiness.d.ts +22 -20
  203. package/dist/readiness.d.ts.map +1 -1
  204. package/dist/readiness.js +5 -13
  205. package/dist/reads.d.ts +38 -10
  206. package/dist/reads.d.ts.map +1 -1
  207. package/dist/reads.js +163 -83
  208. package/dist/recovery.d.ts +5 -2
  209. package/dist/recovery.d.ts.map +1 -1
  210. package/dist/recovery.js +65 -8
  211. package/dist/refresh.d.ts +18 -15
  212. package/dist/refresh.d.ts.map +1 -1
  213. package/dist/refresh.js +145 -60
  214. package/dist/refusal.d.ts +5 -0
  215. package/dist/refusal.d.ts.map +1 -0
  216. package/dist/refusal.js +55 -0
  217. package/dist/replica.d.ts +49 -36
  218. package/dist/replica.d.ts.map +1 -1
  219. package/dist/replica.js +322 -198
  220. package/dist/retried.d.ts +30 -0
  221. package/dist/retried.d.ts.map +1 -0
  222. package/dist/retried.js +72 -0
  223. package/dist/room-draft.d.ts +55 -13
  224. package/dist/room-draft.d.ts.map +1 -1
  225. package/dist/room-draft.js +416 -122
  226. package/dist/room-drafts.d.ts +24 -0
  227. package/dist/room-drafts.d.ts.map +1 -0
  228. package/dist/room-drafts.js +220 -0
  229. package/dist/room-list.d.ts +10 -0
  230. package/dist/room-list.d.ts.map +1 -0
  231. package/dist/room-list.js +45 -0
  232. package/dist/rows.d.ts +32 -31
  233. package/dist/rows.d.ts.map +1 -1
  234. package/dist/rows.js +59 -124
  235. package/dist/runtime.d.ts +34 -0
  236. package/dist/runtime.d.ts.map +1 -0
  237. package/dist/runtime.js +1 -0
  238. package/dist/save.d.ts +43 -49
  239. package/dist/save.d.ts.map +1 -1
  240. package/dist/save.js +736 -302
  241. package/dist/saves.d.ts +34 -0
  242. package/dist/saves.d.ts.map +1 -0
  243. package/dist/saves.js +437 -0
  244. package/dist/search.d.ts +12 -95
  245. package/dist/search.d.ts.map +1 -1
  246. package/dist/search.js +10 -266
  247. package/dist/seed.d.ts +11 -2
  248. package/dist/seed.d.ts.map +1 -1
  249. package/dist/seed.js +71 -1
  250. package/dist/shared.d.ts +6 -7
  251. package/dist/shared.d.ts.map +1 -1
  252. package/dist/shared.js +75 -104
  253. package/dist/shown.d.ts +35 -0
  254. package/dist/shown.d.ts.map +1 -0
  255. package/dist/shown.js +313 -0
  256. package/dist/socket/admission.d.ts +7 -0
  257. package/dist/socket/admission.d.ts.map +1 -0
  258. package/dist/socket/admission.js +39 -0
  259. package/dist/socket/answers.d.ts +6 -0
  260. package/dist/socket/answers.d.ts.map +1 -0
  261. package/dist/socket/answers.js +20 -0
  262. package/dist/socket/lanes.d.ts +28 -0
  263. package/dist/socket/lanes.d.ts.map +1 -0
  264. package/dist/socket/lanes.js +103 -0
  265. package/dist/socket/reads.d.ts +10 -0
  266. package/dist/socket/reads.d.ts.map +1 -0
  267. package/dist/socket/reads.js +31 -0
  268. package/dist/socket/session.d.ts +38 -0
  269. package/dist/socket/session.d.ts.map +1 -0
  270. package/dist/socket/session.js +23 -0
  271. package/dist/socket.d.ts +67 -0
  272. package/dist/socket.d.ts.map +1 -0
  273. package/dist/socket.js +164 -0
  274. package/dist/source.d.ts +59 -0
  275. package/dist/source.d.ts.map +1 -0
  276. package/dist/source.js +93 -0
  277. package/dist/status.d.ts +4 -5
  278. package/dist/status.d.ts.map +1 -1
  279. package/dist/status.js +3 -7
  280. package/dist/store/installs.d.ts +30 -0
  281. package/dist/store/installs.d.ts.map +1 -0
  282. package/dist/store/installs.js +40 -0
  283. package/dist/store/readiness.d.ts +11 -0
  284. package/dist/store/readiness.d.ts.map +1 -0
  285. package/dist/store/readiness.js +68 -0
  286. package/dist/store/records.d.ts +224 -0
  287. package/dist/store/records.d.ts.map +1 -0
  288. package/dist/store/records.js +466 -0
  289. package/dist/store/room-held.d.ts +8 -0
  290. package/dist/store/room-held.d.ts.map +1 -0
  291. package/dist/store/room-held.js +17 -0
  292. package/dist/store/rooms-shown.d.ts +8 -0
  293. package/dist/store/rooms-shown.d.ts.map +1 -0
  294. package/dist/store/rooms-shown.js +13 -0
  295. package/dist/store/space.d.ts +11 -0
  296. package/dist/store/space.d.ts.map +1 -0
  297. package/dist/store/space.js +41 -0
  298. package/dist/store/watchers.d.ts +17 -0
  299. package/dist/store/watchers.d.ts.map +1 -0
  300. package/dist/store/watchers.js +56 -0
  301. package/dist/store/writes.d.ts +24 -0
  302. package/dist/store/writes.d.ts.map +1 -0
  303. package/dist/store/writes.js +125 -0
  304. package/dist/store.d.ts +114 -163
  305. package/dist/store.d.ts.map +1 -1
  306. package/dist/store.js +163 -750
  307. package/dist/stored.d.ts +167 -0
  308. package/dist/stored.d.ts.map +1 -0
  309. package/dist/stored.js +700 -0
  310. package/dist/surface.d.ts +92 -0
  311. package/dist/surface.d.ts.map +1 -0
  312. package/dist/surface.js +251 -0
  313. package/dist/sync.d.ts +19 -0
  314. package/dist/sync.d.ts.map +1 -0
  315. package/dist/sync.js +538 -0
  316. package/dist/tables.d.ts +376 -0
  317. package/dist/tables.d.ts.map +1 -0
  318. package/dist/tables.js +499 -0
  319. package/dist/tallies.d.ts +18 -0
  320. package/dist/tallies.d.ts.map +1 -0
  321. package/dist/tallies.js +128 -0
  322. package/dist/transfer.d.ts +0 -5
  323. package/dist/transfer.d.ts.map +1 -1
  324. package/dist/turn.d.ts +4 -2
  325. package/dist/turn.d.ts.map +1 -1
  326. package/dist/turn.js +46 -22
  327. package/dist/validation.d.ts +29 -0
  328. package/dist/validation.d.ts.map +1 -0
  329. package/dist/validation.js +98 -0
  330. package/dist/windows.d.ts +1 -16
  331. package/dist/windows.d.ts.map +1 -1
  332. package/dist/windows.js +2 -79
  333. package/dist/wire.d.ts +88 -9
  334. package/dist/wire.d.ts.map +1 -1
  335. package/dist/wire.js +31 -6
  336. package/package.json +19 -19
  337. package/AGENTS.md +0 -299
  338. package/dist/attempt.d.ts +0 -16
  339. package/dist/attempt.d.ts.map +0 -1
  340. package/dist/attempt.js +0 -70
  341. package/dist/chat/acts.d.ts +0 -33
  342. package/dist/chat/acts.d.ts.map +0 -1
  343. package/dist/chat/acts.js +0 -36
  344. package/dist/chat/context.d.ts +0 -3
  345. package/dist/chat/context.d.ts.map +0 -1
  346. package/dist/chat/earlier.d.ts +0 -10
  347. package/dist/chat/earlier.d.ts.map +0 -1
  348. package/dist/chat/earlier.js +0 -54
  349. package/dist/chat/input.d.ts +0 -9
  350. package/dist/chat/input.d.ts.map +0 -1
  351. package/dist/chat/input.js +0 -99
  352. package/dist/chat/kit.d.ts +0 -61
  353. package/dist/chat/kit.d.ts.map +0 -1
  354. package/dist/chat/kit.js +0 -123
  355. package/dist/chat/lasting.d.ts +0 -6
  356. package/dist/chat/lasting.d.ts.map +0 -1
  357. package/dist/chat/lasting.js +0 -19
  358. package/dist/chat/list.d.ts +0 -27
  359. package/dist/chat/list.d.ts.map +0 -1
  360. package/dist/chat/list.js +0 -99
  361. package/dist/chat/markdown.d.ts +0 -20
  362. package/dist/chat/markdown.d.ts.map +0 -1
  363. package/dist/chat/markdown.js +0 -188
  364. package/dist/chat/message.d.ts +0 -6
  365. package/dist/chat/message.d.ts.map +0 -1
  366. package/dist/chat/message.js +0 -192
  367. package/dist/chat/messages.d.ts +0 -22
  368. package/dist/chat/messages.d.ts.map +0 -1
  369. package/dist/chat/messages.js +0 -155
  370. package/dist/chat/name.d.ts +0 -6
  371. package/dist/chat/name.d.ts.map +0 -1
  372. package/dist/chat/name.js +0 -37
  373. package/dist/chat/opened.d.ts +0 -11
  374. package/dist/chat/opened.d.ts.map +0 -1
  375. package/dist/chat/opened.js +0 -17
  376. package/dist/chat/overlay.d.ts +0 -31
  377. package/dist/chat/overlay.d.ts.map +0 -1
  378. package/dist/chat/overlay.js +0 -97
  379. package/dist/chat/parts.d.ts +0 -57
  380. package/dist/chat/parts.d.ts.map +0 -1
  381. package/dist/chat/parts.js +0 -119
  382. package/dist/chat/process.d.ts +0 -20
  383. package/dist/chat/process.d.ts.map +0 -1
  384. package/dist/chat/process.js +0 -32
  385. package/dist/chat/provider.d.ts +0 -63
  386. package/dist/chat/provider.d.ts.map +0 -1
  387. package/dist/chat/provider.js +0 -628
  388. package/dist/chat/question.d.ts +0 -9
  389. package/dist/chat/question.d.ts.map +0 -1
  390. package/dist/chat/question.js +0 -69
  391. package/dist/chat/questions.d.ts.map +0 -1
  392. package/dist/chat/read.d.ts.map +0 -1
  393. package/dist/chat/ready.d.ts +0 -34
  394. package/dist/chat/ready.d.ts.map +0 -1
  395. package/dist/chat/ready.js +0 -91
  396. package/dist/chat/style.d.ts +0 -4
  397. package/dist/chat/style.d.ts.map +0 -1
  398. package/dist/chat/style.js +0 -302
  399. package/dist/chat.d.ts +0 -14
  400. package/dist/chat.d.ts.map +0 -1
  401. package/dist/chat.js +0 -8
  402. package/dist/fence.d.ts +0 -6
  403. package/dist/fence.d.ts.map +0 -1
  404. package/dist/fence.js +0 -10
  405. package/dist/log.d.ts +0 -5
  406. package/dist/log.d.ts.map +0 -1
  407. package/dist/log.js +0 -14
  408. package/dist/read-side.d.ts +0 -27
  409. package/dist/read-side.d.ts.map +0 -1
  410. package/dist/read-side.js +0 -824
@@ -1,188 +0,0 @@
1
- import { createElement, Fragment } from 'react';
2
- import { fromMarkdown } from 'mdast-util-from-markdown';
3
- import { gfmFromMarkdown } from 'mdast-util-gfm';
4
- import { gfm } from 'micromark-extension-gfm';
5
- function unfiled(options) {
6
- const { definitions, slugs, onLink } = options;
7
- return onLink === undefined ? { definitions, slugs } : { definitions, slugs, onLink };
8
- }
9
- export function slugOf(text) {
10
- return text
11
- .trim()
12
- .toLowerCase()
13
- .replace(/[^\p{L}\p{M}\p{N}\s_-]/gu, '')
14
- .replace(/\s/g, '-');
15
- }
16
- export function anchorOf(fragment) {
17
- return `md-${slugOf(fragment)}`;
18
- }
19
- function headingId(slugs, text) {
20
- const slug = slugOf(text);
21
- const seen = slugs.get(slug) ?? 0;
22
- slugs.set(slug, seen + 1);
23
- return anchorOf(seen === 0 ? slug : `${slug}-${seen}`);
24
- }
25
- function whole(file, text) {
26
- return (file !== undefined &&
27
- ([...text.matchAll(file.pattern)].some((one) => one[0] === text) || file.names?.(text) === true));
28
- }
29
- function referenced(file, text, key) {
30
- const parts = [];
31
- let from = 0;
32
- for (const found of text.matchAll(file.pattern)) {
33
- const at = found.index;
34
- if (at > from)
35
- parts.push(text.slice(from, at));
36
- parts.push(createElement(Fragment, { key: at }, file.draw(found[0], found[0], false)));
37
- from = at + found[0].length;
38
- }
39
- if (from === 0)
40
- return text;
41
- if (from < text.length)
42
- parts.push(text.slice(from));
43
- return createElement(Fragment, { key }, ...parts);
44
- }
45
- function parseMarkdown(text) {
46
- return fromMarkdown(text, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] });
47
- }
48
- function safeHref(url) {
49
- const href = url.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, '');
50
- if (href === '' || /^[\\/]{2}/.test(href))
51
- return null;
52
- if (/^(?:https?:|mailto:)/i.test(href))
53
- return href;
54
- if (/^[a-z][a-z0-9+.-]*:/i.test(href))
55
- return null;
56
- return href;
57
- }
58
- function external(href) {
59
- return /^(?:https?:|mailto:)/i.test(href);
60
- }
61
- function textOf(node) {
62
- if ('value' in node && typeof node.value === 'string')
63
- return node.value;
64
- if ('children' in node)
65
- return node.children.map(textOf).join('');
66
- return '';
67
- }
68
- function definitionsOf(node, found = new Map()) {
69
- if (node.type === 'definition' && !found.has(node.identifier))
70
- found.set(node.identifier, node.url);
71
- if ('children' in node)
72
- for (const child of node.children)
73
- definitionsOf(child, found);
74
- return found;
75
- }
76
- function link(url, node, key, options) {
77
- if (whole(options.file, url)) {
78
- return createElement(Fragment, { key }, options.file.draw(url, textOf(node) || url, false));
79
- }
80
- const inside = node.children.map((child, at) => render(child, at, unfiled(options)));
81
- const href = safeHref(url);
82
- if (href === null)
83
- return createElement(Fragment, { key }, ...inside);
84
- const onLink = options.onLink;
85
- if (external(href) || onLink === undefined) {
86
- return createElement('a', { key, href, rel: 'noreferrer' }, ...inside);
87
- }
88
- return createElement('a', {
89
- key,
90
- href,
91
- onClick: (event) => {
92
- event.preventDefault();
93
- onLink(href);
94
- },
95
- }, ...inside);
96
- }
97
- function render(node, key, options, header = false) {
98
- const children = () => 'children' in node
99
- ? node.children.map((child, at) => render(child, at, options))
100
- : [];
101
- switch (node.type) {
102
- case 'root':
103
- return createElement(Fragment, { key }, ...children());
104
- case 'paragraph':
105
- return createElement('p', { key }, ...children());
106
- case 'heading':
107
- return createElement(`h${node.depth}`, { key, id: headingId(options.slugs, textOf(node)) }, ...children());
108
- case 'text':
109
- return options.file === undefined ? node.value : referenced(options.file, node.value, key);
110
- case 'emphasis':
111
- return createElement('em', { key }, ...children());
112
- case 'strong':
113
- return createElement('strong', { key }, ...children());
114
- case 'delete':
115
- return createElement('del', { key }, ...children());
116
- case 'inlineCode':
117
- return createElement('code', { key }, node.value);
118
- case 'code':
119
- return createElement('pre', { key }, createElement('code', null, node.value));
120
- case 'blockquote':
121
- return createElement('blockquote', { key }, ...children());
122
- case 'list':
123
- return node.ordered === true
124
- ? createElement('ol', { key, start: node.start ?? undefined }, ...children())
125
- : createElement('ul', { key }, ...children());
126
- case 'listItem': {
127
- const items = node.children.flatMap((child, at) => child.type === 'paragraph' && node.spread !== true
128
- ? child.children.map((inline, place) => render(inline, at * 1000 + place, options))
129
- : [render(child, at, options)]);
130
- return createElement('li', { key }, node.checked == null
131
- ? null
132
- : createElement('input', { type: 'checkbox', checked: node.checked, disabled: true }), ...items);
133
- }
134
- case 'thematicBreak':
135
- return createElement('hr', { key });
136
- case 'break':
137
- return createElement('br', { key });
138
- case 'link':
139
- return link(node.url, node, key, options);
140
- case 'linkReference':
141
- return link(options.definitions.get(node.identifier) ?? '', node, key, options);
142
- case 'image':
143
- return whole(options.file, node.url)
144
- ? createElement(Fragment, { key }, options.file.draw(node.url, node.alt || node.url, true))
145
- : (node.alt ?? '');
146
- case 'html':
147
- return node.value;
148
- case 'table':
149
- return createElement('table', { key }, createElement('thead', null, ...node.children.slice(0, 1).map((row, at) => render(row, at, options, true))), createElement('tbody', null, ...node.children.slice(1).map((row, at) => render(row, at, options))));
150
- case 'tableRow':
151
- return createElement('tr', { key }, ...node.children.map((cell, at) => createElement(header ? 'th' : 'td', { key: at }, ...cell.children.map((inline, place) => render(inline, place, options)))));
152
- case 'footnoteReference':
153
- return createElement('sup', { key }, node.label ?? node.identifier);
154
- case 'definition':
155
- case 'yaml':
156
- return null;
157
- default:
158
- return textOf(node);
159
- }
160
- }
161
- const INLINE = new Set([
162
- 'paragraph',
163
- 'heading',
164
- 'emphasis',
165
- 'strong',
166
- 'delete',
167
- 'link',
168
- 'linkReference',
169
- 'tableCell',
170
- ]);
171
- function spokenOf(node) {
172
- if (node.type === 'yaml')
173
- return '';
174
- if (node.type === 'image')
175
- return node.alt ?? '';
176
- if ('value' in node && typeof node.value === 'string')
177
- return node.value;
178
- if (!('children' in node))
179
- return node.type === 'break' ? ' ' : '';
180
- return node.children.map(spokenOf).join(INLINE.has(node.type) ? '' : ' ');
181
- }
182
- export function plainText(text) {
183
- return spokenOf(parseMarkdown(text)).replace(/\s+/g, ' ').trim();
184
- }
185
- export function Markdown({ text, className, ...options }) {
186
- const root = parseMarkdown(text);
187
- return createElement('div', { className }, render(root, 0, { ...options, definitions: definitionsOf(root), slugs: new Map() }));
188
- }
@@ -1,6 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- export declare const Linked: import("react").Context<((href: string) => void) | null>;
3
- export declare function UserMessage(): ReactElement;
4
- export declare function Undelivered(): ReactElement;
5
- export declare function AssistantMessage(): ReactElement;
6
- //# sourceMappingURL=message.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/chat/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AAmCf,eAAO,MAAM,MAAM,kCAAyB,MAAM,KAAK,IAAI,SAAe,CAAC;AA0O3E,wBAAgB,WAAW,IAAI,YAAY,CA4B1C;AAED,wBAAgB,WAAW,IAAI,YAAY,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,YAAY,CA0F/C"}
@@ -1,192 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createContext, useContext, } from 'react';
3
- import { ActionBarPrimitive, AuiIf, ErrorPrimitive, MessagePartPrimitive, MessagePrimitive, groupPartByType, useAuiState, } from '@assistant-ui/react';
4
- import { MarkdownTextPrimitive } from '@assistant-ui/react-markdown';
5
- import { Collapsible } from 'radix-ui';
6
- import remarkGfm from 'remark-gfm';
7
- import Bot from 'lucide-react/dist/esm/icons/bot.mjs';
8
- import Brain from 'lucide-react/dist/esm/icons/brain.mjs';
9
- import CalendarClock from 'lucide-react/dist/esm/icons/calendar-clock.mjs';
10
- import Check from 'lucide-react/dist/esm/icons/check.mjs';
11
- import ChevronRight from 'lucide-react/dist/esm/icons/chevron-right.mjs';
12
- import Copy from 'lucide-react/dist/esm/icons/copy.mjs';
13
- import Cpu from 'lucide-react/dist/esm/icons/cpu.mjs';
14
- import ImageGlyph from 'lucide-react/dist/esm/icons/image.mjs';
15
- import Layers from 'lucide-react/dist/esm/icons/layers.mjs';
16
- import ListChecks from 'lucide-react/dist/esm/icons/list-checks.mjs';
17
- import ListTodo from 'lucide-react/dist/esm/icons/list-todo.mjs';
18
- import Paperclip from 'lucide-react/dist/esm/icons/paperclip.mjs';
19
- import RotateCw from 'lucide-react/dist/esm/icons/rotate-cw.mjs';
20
- import Send from 'lucide-react/dist/esm/icons/send.mjs';
21
- import SlidersHorizontal from 'lucide-react/dist/esm/icons/sliders-horizontal.mjs';
22
- import Terminal from 'lucide-react/dist/esm/icons/terminal.mjs';
23
- import { SESSION_STARTED } from '../conversation.js';
24
- import { buttonClass, Name, Working } from './kit.js';
25
- import { StillRunning } from './lasting.js';
26
- import { list, record, text } from './read.js';
27
- export const Linked = createContext(null);
28
- const groupBy = groupPartByType({
29
- reasoning: ['group-thought', 'group-reasoning'],
30
- 'tool-call': ['group-thought'],
31
- });
32
- const GFM = [remarkGfm];
33
- const SENT = {
34
- send_routine_request: 'Sent a request',
35
- cancel_routine_request: 'Cancelled a request',
36
- };
37
- const MARKED = {
38
- mode: { title: 'Mode', Icon: SlidersHorizontal },
39
- compaction: { title: 'Context compacted', Icon: Layers },
40
- retry: { title: 'Retrying', Icon: RotateCw },
41
- model: { title: 'Model', Icon: Cpu },
42
- };
43
- const STEP = { completed: '✓', in_progress: '→' };
44
- function counted(count) {
45
- return count === 1 ? '1 command' : `${count} commands`;
46
- }
47
- function jobShown(said) {
48
- const icon = _jsx(CalendarClock, { "aria-hidden": "true" });
49
- const shown = { icon, input: '', output: '' };
50
- const label = said('label');
51
- const state = said('state');
52
- if (said('job') === 'started') {
53
- return { ...shown, title: 'Background job started', detail: label };
54
- }
55
- if (said('job') === 'scheduled') {
56
- const detail = said('next') === '' ? label : `${label} · ${state}`;
57
- return { ...shown, title: 'Schedule set', detail };
58
- }
59
- const detail = state === '' ? label : `${label} · ${state}`;
60
- return { ...shown, title: 'Background job ended', detail };
61
- }
62
- function shownOf({ toolName, args, result }) {
63
- const said = (key) => text(args, key) ?? '';
64
- const plain = { detail: '', input: '', output: '' };
65
- switch (toolName) {
66
- case 'subagent':
67
- return {
68
- icon: _jsx(Bot, { "aria-hidden": "true" }),
69
- title: 'Sub-agent',
70
- detail: said('description'),
71
- input: said('description'),
72
- output: typeof result === 'string' ? result : '',
73
- };
74
- case 'message':
75
- return {
76
- ...plain,
77
- icon: _jsx(Send, { "aria-hidden": "true" }),
78
- title: SENT[said('command')] ?? said('command'),
79
- detail: said('target'),
80
- };
81
- case 'plan': {
82
- const steps = list(args, 'steps').map(record);
83
- return {
84
- ...plain,
85
- icon: _jsx(ListTodo, { "aria-hidden": "true" }),
86
- title: 'Plan',
87
- detail: text(steps.find((one) => one.status === 'in_progress') ?? {}, 'content') ?? '',
88
- input: steps
89
- .map((one) => `${STEP[text(one, 'status') ?? ''] ?? '○'} ${text(one, 'content') ?? ''}`)
90
- .join('\n'),
91
- };
92
- }
93
- case 'marker': {
94
- const marked = MARKED[said('marker')];
95
- if (marked === undefined)
96
- return jobShown(said);
97
- return {
98
- ...plain,
99
- icon: _jsx(marked.Icon, { "aria-hidden": "true" }),
100
- title: marked.title,
101
- detail: said('text'),
102
- };
103
- }
104
- default:
105
- return {
106
- ...plain,
107
- icon: _jsx(Terminal, { "aria-hidden": "true" }),
108
- title: counted(Number(args.count)),
109
- };
110
- }
111
- }
112
- function workedOf(calls) {
113
- const commands = calls.reduce((sum, one) => (one.toolName === 'commands' ? sum + Number(one.args.count) : sum), 0);
114
- return commands === 0 ? 'Worked' : `Worked · ${counted(commands)}`;
115
- }
116
- function Toggle({ icon, label, detail = '', active, children, }) {
117
- return (_jsxs(Collapsible.Root, { children: [_jsxs(Collapsible.Trigger, { className: "ahc-row ahc-toggle", children: [icon, _jsx("span", { className: active ? 'ahc-clipped ahc-shimmer' : 'ahc-clipped', children: label }), detail === '' ? null : _jsx("span", { className: "ahc-clipped", children: detail }), _jsx("span", { className: "ahc-chevron", children: _jsx(ChevronRight, { "aria-hidden": "true" }) })] }), _jsx(Collapsible.Content, { children: children })] }));
118
- }
119
- function ToolCall({ call, active }) {
120
- const shown = shownOf(call);
121
- if (shown.input === '' && shown.output === '') {
122
- return (_jsxs("div", { className: "ahc-toolline ahc-quiet", children: [shown.icon, _jsx("span", { className: active ? 'ahc-shimmer' : undefined, children: shown.title }), shown.detail === '' ? null : _jsx("span", { className: "ahc-clipped", children: shown.detail })] }));
123
- }
124
- return (_jsx(Toggle, { icon: shown.icon, label: shown.title, detail: shown.detail, active: active, children: _jsxs("div", { className: "ahc-quiet ahc-wells", children: [shown.input === '' ? null : _jsx("div", { className: "ahc-well", children: shown.input }), shown.output === '' ? null : _jsx("div", { className: "ahc-well", children: shown.output })] }) }));
125
- }
126
- function Thought({ indices, active, children, }) {
127
- const parts = useAuiState((s) => s.message.parts);
128
- const held = indices.flatMap((at) => parts[at] ?? []);
129
- const calls = held.flatMap((part) => (part.type === 'tool-call' ? [part] : []));
130
- if (calls.length === 0 || held.length === 1)
131
- return _jsx(_Fragment, { children: children });
132
- const last = held.at(-1);
133
- const now = last?.type === 'tool-call'
134
- ? shownOf(last)
135
- : { icon: _jsx(Brain, { "aria-hidden": "true" }), title: 'Thinking', detail: '' };
136
- return (_jsx(Toggle, { icon: active ? now.icon : _jsx(ListChecks, { "aria-hidden": "true" }), label: active ? now.title : workedOf(calls), detail: active ? now.detail : '', active: active, children: children }));
137
- }
138
- const SCHEME = /^[a-z][a-z0-9+.-]*:/i;
139
- function Anchor({ node: _node, href = '', ...rest }) {
140
- const onLink = useContext(Linked);
141
- if (SCHEME.test(href) || onLink === null)
142
- return _jsx("a", { ...rest, href: href, rel: "noreferrer" });
143
- return (_jsx("a", { ...rest, href: href, onClick: (event) => {
144
- event.preventDefault();
145
- onLink(href);
146
- } }));
147
- }
148
- const LINKED = { a: Anchor };
149
- const THOUGHT = { className: 'ahc-thought' };
150
- function Said({ thought = false }) {
151
- return (_jsx(MarkdownTextPrimitive, { className: "ahc-text ahc-markdown", containerProps: thought ? THOUGHT : undefined, remarkPlugins: GFM, components: LINKED }));
152
- }
153
- function UserText() {
154
- return _jsx(MessagePartPrimitive.Text, { className: "ahc-said" });
155
- }
156
- export function UserMessage() {
157
- const said = useAuiState((s) => s.message.parts.some((one) => one.type === 'text' && one.text !== ''));
158
- const attached = useAuiState((s) => (s.message.attachments?.length ?? 0) > 0);
159
- const undelivered = useAuiState((s) => s.message.metadata.custom.undelivered === true);
160
- return (_jsxs(MessagePrimitive.Root, { role: "group", "aria-label": "You", className: "ahc-you", children: [said ? (_jsx("div", { className: "ahc-bubble", children: _jsx(MessagePrimitive.Parts, { components: { Text: UserText } }) })) : null, attached ? (_jsx("div", { className: "ahc-chips", children: _jsx(MessagePrimitive.Attachments, { children: ({ attachment }) => (_jsxs("span", { className: "ahc-chip", children: [_jsx(Paperclip, { "aria-hidden": "true" }), _jsx(Name, { text: attachment.name })] })) }) })) : null, undelivered ? _jsx(Undelivered, {}) : null] }));
161
- }
162
- export function Undelivered() {
163
- return _jsx("span", { className: "ahc-meta", children: "Telegram didn't receive this" });
164
- }
165
- export function AssistantMessage() {
166
- const running = useAuiState((s) => s.message.status?.type === 'running');
167
- const started = useAuiState((s) => s.message.metadata.isOptimistic !== true);
168
- const said = useAuiState((s) => s.message.parts.some((one) => one.type === 'text'));
169
- const last = useAuiState((s) => s.message.isLast);
170
- const custom = useAuiState((s) => s.message.metadata.custom);
171
- const lasting = Array.isArray(custom.lasting) ? custom.lasting : [];
172
- return (_jsxs(MessagePrimitive.Root, { role: "group", "aria-label": running ? 'Turn, running' : 'Turn', className: "ahc-turn", children: [_jsx(MessagePrimitive.GroupedParts, { groupBy: groupBy, indicator: "empty", children: ({ part, children }) => {
173
- switch (part.type) {
174
- case 'group-thought':
175
- return (_jsx(Thought, { indices: part.indices, active: part.status.type === 'running', children: children }));
176
- case 'group-reasoning':
177
- return (_jsx(Toggle, { icon: _jsx(Brain, { "aria-hidden": "true" }), label: "Thinking", active: part.status.type === 'running', children: children }));
178
- case 'text':
179
- return _jsx(Said, {});
180
- case 'reasoning':
181
- return _jsx(Said, { thought: true });
182
- case 'tool-call':
183
- return _jsx(ToolCall, { call: part, active: part.status.type === 'running' });
184
- case 'file':
185
- return (_jsxs("div", { className: "ahc-toolline ahc-quiet", children: [_jsx(ImageGlyph, { "aria-hidden": "true" }), _jsx("span", { className: "ahc-clipped", children: part.filename })] }));
186
- case 'indicator':
187
- return _jsx(Working, { step: started ? SESSION_STARTED : undefined });
188
- default:
189
- return null;
190
- }
191
- } }), _jsx(MessagePrimitive.Error, { children: _jsxs(ErrorPrimitive.Root, { className: "ahc-failure", children: [_jsx(ErrorPrimitive.Message, {}), _jsx(AuiIf, { condition: (s) => s.thread.capabilities.reload && s.message.metadata.custom.again === true, children: _jsx(ActionBarPrimitive.Reload, { className: buttonClass('outline', true, false), children: "Try again" }) })] }) }), custom.undelivered === true ? _jsx(Undelivered, {}) : null, said ? (_jsx(ActionBarPrimitive.Root, { hideWhenRunning: true, autohide: "not-last", autohideFloat: "always", className: last ? 'ahc-actions' : 'ahc-actions ahc-actions--floating', children: _jsxs(ActionBarPrimitive.Copy, { className: `${buttonClass('quiet', true, true)} ahc-secondary`, "aria-label": "Copy", children: [_jsx(AuiIf, { condition: (s) => s.message.isCopied, children: _jsx(Check, { "aria-hidden": "true" }) }), _jsx(AuiIf, { condition: (s) => !s.message.isCopied, children: _jsx(Copy, { "aria-hidden": "true" }) })] }) })) : null, lasting.length === 0 ? null : _jsx(StillRunning, { lasting: lasting })] }));
192
- }
@@ -1,22 +0,0 @@
1
- import type { ThreadMessageLike } from '@assistant-ui/react';
2
- import type { TurnContext } from '../adapter.js';
3
- import type { ConversationView } from '../conversation.js';
4
- import { type Part } from './parts.js';
5
- type Entry = ConversationView['messages'][number];
6
- export type Said = {
7
- readonly turn: string;
8
- readonly user: boolean;
9
- readonly text: string;
10
- readonly parts: readonly Part[];
11
- readonly context: TurnContext | null;
12
- readonly failure: string | null;
13
- readonly undelivered: boolean;
14
- readonly files: readonly string[];
15
- };
16
- export declare function saidOf(entry: Entry): Said;
17
- export declare function awaitsTurn(view: ConversationView | null): boolean;
18
- export declare function askedBefore(view: ConversationView | null, id: string | null): string | null;
19
- export declare function chatMessages(view: ConversationView | null): ThreadMessageLike[];
20
- export declare function contextOf(view: ConversationView | null): TurnContext | null;
21
- export {};
22
- //# sourceMappingURL=messages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/chat/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAA0D,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAO/F,KAAK,KAAK,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAYzC;AAkED,wBAAgB,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAGjE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAO3F;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,EAAE,CAsD/E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAS3E"}
@@ -1,155 +0,0 @@
1
- import { contextIn, jobOf, partsOf, stillRunning } from './parts.js';
2
- import { list, record, text } from './read.js';
3
- export function saidOf(entry) {
4
- const message = record(entry.message);
5
- return {
6
- turn: text(message, 'turn_id') ?? entry.turn,
7
- user: text(message, 'role') === 'user',
8
- text: text(message, 'text') ?? '',
9
- parts: partsOf(list(message, 'parts')),
10
- context: contextIn(message.context),
11
- failure: text(message, 'failure'),
12
- undelivered: message.telegram_undelivered === true,
13
- files: list(message, 'files').flatMap((one) => text(record(one), 'name') ?? []),
14
- };
15
- }
16
- function markerArgs(part) {
17
- if (part.marker !== 'job')
18
- return { marker: part.marker, text: part.text };
19
- const job = jobOf(part.text);
20
- return {
21
- marker: part.marker,
22
- text: part.text,
23
- job: job.kind,
24
- label: job.label,
25
- state: job.state,
26
- next: job.next ?? '',
27
- };
28
- }
29
- function contentOf(id, parts, live) {
30
- return parts.map((part, at) => {
31
- const done = !live || at < parts.length - 1;
32
- const call = (toolName, args) => ({
33
- type: 'tool-call',
34
- toolCallId: `${id}:${at}`,
35
- toolName,
36
- args,
37
- result: done ? null : undefined,
38
- });
39
- switch (part.type) {
40
- case 'text':
41
- return { type: 'text', text: part.text };
42
- case 'reasoning':
43
- return { type: 'reasoning', text: part.text };
44
- case 'commands':
45
- return call('commands', { count: part.count });
46
- case 'subagent':
47
- return {
48
- ...call('subagent', { description: part.description }),
49
- result: part.done ? part.result : undefined,
50
- };
51
- case 'message':
52
- return call('message', { command: part.command, target: part.target ?? '' });
53
- case 'marker':
54
- return call('marker', markerArgs(part));
55
- case 'plan':
56
- return {
57
- ...call('plan', {}),
58
- args: { steps: part.steps.map((step) => ({ ...step })) },
59
- };
60
- case 'image':
61
- return { type: 'file', filename: part.name, mimeType: part.mediaType, data: '' };
62
- }
63
- });
64
- }
65
- function leftRunning(view) {
66
- if (view.process?.running === false)
67
- return new Map();
68
- const turns = view.messages.flatMap((entry) => {
69
- const one = saidOf(entry);
70
- return one.user ? [] : [{ turn: one.turn, parts: one.parts, ended: true }];
71
- });
72
- return stillRunning(view.turn === null
73
- ? turns
74
- : [...turns, { turn: view.turn.turn, parts: partsOf(view.turn.parts), ended: false }]);
75
- }
76
- export function awaitsTurn(view) {
77
- const newest = view?.messages.at(-1);
78
- return view?.turn === null && newest !== undefined && saidOf(newest).user;
79
- }
80
- export function askedBefore(view, id) {
81
- const said = (view?.messages ?? []).map((entry) => ({ ...saidOf(entry), id: entry.identity }));
82
- const asked = said
83
- .slice(0, said.findIndex((one) => one.id === id) + 1)
84
- .reverse()
85
- .find((one) => one.user);
86
- return asked === undefined || asked.text === '' ? null : asked.text;
87
- }
88
- export function chatMessages(view) {
89
- if (view === null)
90
- return [];
91
- const lasting = leftRunning(view);
92
- const said = view.messages.map((entry, at) => {
93
- const one = saidOf(entry);
94
- const custom = { undelivered: one.undelivered };
95
- if (one.user) {
96
- return {
97
- id: entry.identity,
98
- role: 'user',
99
- content: [{ type: 'text', text: one.text }],
100
- attachments: one.files.map((name, at) => ({
101
- id: `${entry.identity}:${at}`,
102
- type: 'file',
103
- name,
104
- status: { type: 'complete' },
105
- content: [],
106
- })),
107
- metadata: { custom },
108
- };
109
- }
110
- const failed = one.failure === null
111
- ? undefined
112
- : { type: 'incomplete', reason: 'error', error: one.failure };
113
- return {
114
- id: entry.identity,
115
- role: 'assistant',
116
- content: contentOf(entry.identity, one.parts, false),
117
- status: failed,
118
- metadata: {
119
- custom: {
120
- ...custom,
121
- lasting: lasting.get(one.turn) ?? [],
122
- again: failed !== undefined &&
123
- view.turn === null &&
124
- at === view.messages.length - 1 &&
125
- askedBefore(view, view.messages[at - 1]?.identity ?? null) !== null,
126
- },
127
- },
128
- };
129
- });
130
- if (view.turn === null)
131
- return said;
132
- const running = `running:${view.turn.turn}`;
133
- return [
134
- ...said,
135
- {
136
- id: running,
137
- role: 'assistant',
138
- content: contentOf(running, partsOf(view.turn.parts), true),
139
- status: { type: 'running' },
140
- },
141
- ];
142
- }
143
- export function contextOf(view) {
144
- if (view === null)
145
- return null;
146
- const running = view.turn === null ? null : contextIn(view.turn.context);
147
- if (running !== null)
148
- return running;
149
- for (const entry of [...view.messages].reverse()) {
150
- const held = contextIn(record(entry.message).context);
151
- if (held !== null)
152
- return held;
153
- }
154
- return null;
155
- }
@@ -1,6 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- export declare function readable(name: string): string;
3
- export declare function ChatName({ name }: {
4
- readonly name: string;
5
- }): ReactElement;
6
- //# sourceMappingURL=name.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/chat/name.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAgC1C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAc1E"}
package/dist/chat/name.js DELETED
@@ -1,37 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- const INSTANT = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})/g;
3
- function stamp(at) {
4
- const time = new Date(at);
5
- return Number.isNaN(time.getTime())
6
- ? ''
7
- : time.toLocaleString('en-US', {
8
- month: 'short',
9
- day: 'numeric',
10
- hour: '2-digit',
11
- minute: '2-digit',
12
- });
13
- }
14
- function partsOf(name) {
15
- const parts = [];
16
- let from = 0;
17
- for (const found of name.matchAll(INSTANT)) {
18
- const shown = stamp(found[0]);
19
- if (shown === '')
20
- continue;
21
- if (found.index > from)
22
- parts.push({ text: name.slice(from, found.index), at: null });
23
- parts.push({ text: shown, at: found[0] });
24
- from = found.index + found[0].length;
25
- }
26
- if (from < name.length)
27
- parts.push({ text: name.slice(from), at: null });
28
- return parts;
29
- }
30
- export function readable(name) {
31
- return partsOf(name)
32
- .map((part) => part.text)
33
- .join('');
34
- }
35
- export function ChatName({ name }) {
36
- return (_jsx(_Fragment, { children: partsOf(name).map((part, at) => part.at === null ? (part.text) : (_jsx("time", { dateTime: part.at, children: part.text }, at))) }));
37
- }
@@ -1,11 +0,0 @@
1
- import type { ConversationEntry } from '../conversation.js';
2
- import { type ChatState } from './provider.js';
3
- export type Opened = ChatState & {
4
- readonly entry: ConversationEntry | undefined;
5
- readonly by: string | null;
6
- readonly name: string;
7
- readonly deleted: boolean;
8
- readonly busy: boolean;
9
- };
10
- export declare function useOpened(): Opened;
11
- //# sourceMappingURL=opened.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../../src/chat/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG;IAC/B,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,SAAS,IAAI,MAAM,CAelC"}
@@ -1,17 +0,0 @@
1
- import { useChat, useChatScope } from './provider.js';
2
- export function useOpened() {
3
- const chat = useChat();
4
- const { known } = useChatScope();
5
- const entry = chat.conversations.find((one) => one.conversation === chat.conversation);
6
- const by = entry?.agent.identity ?? chat.agent;
7
- const live = chat.agents.find((one) => one.identity === by);
8
- const asks = chat.view?.process?.running === true && chat.questions.length > 0;
9
- return {
10
- ...chat,
11
- entry,
12
- by,
13
- name: live?.name ?? entry?.agent.name ?? '',
14
- deleted: known && chat.conversation !== null && by !== null && live === undefined,
15
- busy: chat.running || asks,
16
- };
17
- }