@agentshouse/mdruntime 0.1.0-caee7332d2235 → 0.1.0-caf080a9a9c60

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 (394) hide show
  1. package/README.md +19 -16
  2. package/dist/acceptance.d.ts +3 -0
  3. package/dist/acceptance.d.ts.map +1 -0
  4. package/dist/acceptance.js +318 -0
  5. package/dist/act-lanes.d.ts +29 -0
  6. package/dist/act-lanes.d.ts.map +1 -0
  7. package/dist/act-lanes.js +177 -0
  8. package/dist/actions.d.ts +25 -0
  9. package/dist/actions.d.ts.map +1 -0
  10. package/dist/actions.js +261 -0
  11. package/dist/adapter.d.ts +162 -122
  12. package/dist/adapter.d.ts.map +1 -1
  13. package/dist/attached-model.d.ts +7 -10
  14. package/dist/attached-model.d.ts.map +1 -1
  15. package/dist/attached-model.js +40 -41
  16. package/dist/binary.d.ts +0 -5
  17. package/dist/binary.d.ts.map +1 -1
  18. package/dist/binary.js +1 -1
  19. package/dist/bootstrap.d.ts +30 -11
  20. package/dist/bootstrap.d.ts.map +1 -1
  21. package/dist/bootstrap.js +309 -113
  22. package/dist/cell.d.ts +6 -0
  23. package/dist/cell.d.ts.map +1 -0
  24. package/dist/cell.js +9 -0
  25. package/dist/chain.d.ts +12 -0
  26. package/dist/chain.d.ts.map +1 -0
  27. package/dist/chain.js +64 -0
  28. package/dist/change-set.d.ts +10 -16
  29. package/dist/change-set.d.ts.map +1 -1
  30. package/dist/change-set.js +17 -94
  31. package/dist/change.d.ts +32 -1
  32. package/dist/change.d.ts.map +1 -1
  33. package/dist/change.js +14 -3
  34. package/dist/chat-types.d.ts +5 -0
  35. package/dist/chat-types.d.ts.map +1 -0
  36. package/dist/chat-types.js +13 -0
  37. package/dist/client.d.ts +33 -19
  38. package/dist/client.d.ts.map +1 -1
  39. package/dist/client.js +112 -21
  40. package/dist/collection.d.ts +29 -22
  41. package/dist/collection.d.ts.map +1 -1
  42. package/dist/collection.js +47 -354
  43. package/dist/compile.d.ts +18 -0
  44. package/dist/compile.d.ts.map +1 -0
  45. package/dist/compile.js +724 -0
  46. package/dist/connection.d.ts +7 -137
  47. package/dist/connection.d.ts.map +1 -1
  48. package/dist/connection.js +111 -3623
  49. package/dist/context.d.ts +2 -0
  50. package/dist/context.d.ts.map +1 -0
  51. package/dist/{chat/context.js → context.js} +1 -4
  52. package/dist/conversation-live.d.ts +138 -0
  53. package/dist/conversation-live.d.ts.map +1 -0
  54. package/dist/conversation-live.js +249 -0
  55. package/dist/conversation-row.d.ts +33 -0
  56. package/dist/conversation-row.d.ts.map +1 -0
  57. package/dist/conversation-row.js +53 -0
  58. package/dist/conversation.d.ts +66 -49
  59. package/dist/conversation.d.ts.map +1 -1
  60. package/dist/conversation.js +962 -799
  61. package/dist/declaration.d.ts +10 -0
  62. package/dist/declaration.d.ts.map +1 -0
  63. package/dist/declaration.js +24 -0
  64. package/dist/digest.d.ts +7 -0
  65. package/dist/digest.d.ts.map +1 -0
  66. package/dist/digest.js +113 -0
  67. package/dist/discovery.d.ts +10 -0
  68. package/dist/discovery.d.ts.map +1 -0
  69. package/dist/discovery.js +153 -0
  70. package/dist/durability.d.ts +19 -4
  71. package/dist/durability.d.ts.map +1 -1
  72. package/dist/durability.js +5 -0
  73. package/dist/entry.d.ts +5 -2
  74. package/dist/entry.d.ts.map +1 -1
  75. package/dist/entry.js +33 -29
  76. package/dist/expectation.d.ts +26 -13
  77. package/dist/expectation.d.ts.map +1 -1
  78. package/dist/expectation.js +72 -19
  79. package/dist/failure.d.ts +3 -0
  80. package/dist/failure.d.ts.map +1 -1
  81. package/dist/failure.js +6 -0
  82. package/dist/figures.d.ts +49 -0
  83. package/dist/figures.d.ts.map +1 -0
  84. package/dist/figures.js +197 -0
  85. package/dist/file.d.ts +2 -19
  86. package/dist/file.d.ts.map +1 -1
  87. package/dist/file.js +7 -122
  88. package/dist/holdings.d.ts +29 -0
  89. package/dist/holdings.d.ts.map +1 -0
  90. package/dist/holdings.js +95 -0
  91. package/dist/host.d.ts +20 -8
  92. package/dist/host.d.ts.map +1 -1
  93. package/dist/host.js +103 -45
  94. package/dist/identity.d.ts +0 -2
  95. package/dist/identity.d.ts.map +1 -1
  96. package/dist/identity.js +0 -6
  97. package/dist/index.d.ts +39 -15
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +18 -4
  100. package/dist/install.d.ts +54 -0
  101. package/dist/install.d.ts.map +1 -0
  102. package/dist/install.js +539 -0
  103. package/dist/lifecycle.d.ts +7 -0
  104. package/dist/lifecycle.d.ts.map +1 -0
  105. package/dist/lifecycle.js +279 -0
  106. package/dist/listing.d.ts +48 -0
  107. package/dist/listing.d.ts.map +1 -0
  108. package/dist/listing.js +139 -0
  109. package/dist/live.d.ts +23 -0
  110. package/dist/live.d.ts.map +1 -0
  111. package/dist/live.js +165 -0
  112. package/dist/locks.d.ts +7 -0
  113. package/dist/locks.d.ts.map +1 -0
  114. package/dist/locks.js +33 -0
  115. package/dist/log.d.ts +1 -0
  116. package/dist/log.d.ts.map +1 -1
  117. package/dist/lost.d.ts +5 -0
  118. package/dist/lost.d.ts.map +1 -0
  119. package/dist/lost.js +50 -0
  120. package/dist/media.d.ts +8 -0
  121. package/dist/media.d.ts.map +1 -0
  122. package/dist/media.js +218 -0
  123. package/dist/memory.d.ts +17 -7
  124. package/dist/memory.d.ts.map +1 -1
  125. package/dist/memory.js +272 -118
  126. package/dist/messages.d.ts +49 -0
  127. package/dist/messages.d.ts.map +1 -0
  128. package/dist/messages.js +150 -0
  129. package/dist/model.d.ts +8 -11
  130. package/dist/model.d.ts.map +1 -1
  131. package/dist/model.js +6 -23
  132. package/dist/models.d.ts +10 -0
  133. package/dist/models.d.ts.map +1 -0
  134. package/dist/models.js +156 -0
  135. package/dist/name.d.ts +4 -0
  136. package/dist/name.d.ts.map +1 -0
  137. package/dist/name.js +122 -0
  138. package/dist/observation.d.ts +15 -2
  139. package/dist/observation.d.ts.map +1 -1
  140. package/dist/observation.js +98 -14
  141. package/dist/opened.d.ts +22 -0
  142. package/dist/opened.d.ts.map +1 -0
  143. package/dist/opened.js +107 -0
  144. package/dist/opening.d.ts +4 -0
  145. package/dist/opening.d.ts.map +1 -0
  146. package/dist/opening.js +59 -0
  147. package/dist/outcome.d.ts +47 -9
  148. package/dist/outcome.d.ts.map +1 -1
  149. package/dist/outcome.js +56 -2
  150. package/dist/overlay.d.ts +7 -5
  151. package/dist/overlay.d.ts.map +1 -1
  152. package/dist/overlay.js +69 -169
  153. package/dist/page-metadata.d.ts +8 -0
  154. package/dist/page-metadata.d.ts.map +1 -0
  155. package/dist/page-metadata.js +19 -0
  156. package/dist/parts.d.ts +3 -0
  157. package/dist/parts.d.ts.map +1 -0
  158. package/dist/parts.js +10 -0
  159. package/dist/paths.d.ts +2 -0
  160. package/dist/paths.d.ts.map +1 -1
  161. package/dist/paths.js +26 -0
  162. package/dist/preparation.d.ts +20 -0
  163. package/dist/preparation.d.ts.map +1 -0
  164. package/dist/preparation.js +233 -0
  165. package/dist/presence.d.ts +52 -0
  166. package/dist/presence.d.ts.map +1 -0
  167. package/dist/presence.js +220 -0
  168. package/dist/queries.d.ts +16 -0
  169. package/dist/queries.d.ts.map +1 -0
  170. package/dist/queries.js +285 -0
  171. package/dist/query.d.ts +21 -207
  172. package/dist/query.d.ts.map +1 -1
  173. package/dist/query.js +3 -493
  174. package/dist/{chat/questions.d.ts → questions.d.ts} +5 -7
  175. package/dist/questions.d.ts.map +1 -0
  176. package/dist/{chat/questions.js → questions.js} +11 -7
  177. package/dist/queue.d.ts +40 -0
  178. package/dist/queue.d.ts.map +1 -0
  179. package/dist/queue.js +465 -0
  180. package/dist/reach.d.ts +20 -9
  181. package/dist/reach.d.ts.map +1 -1
  182. package/dist/reach.js +306 -111
  183. package/dist/react.d.ts +15 -2
  184. package/dist/react.d.ts.map +1 -1
  185. package/dist/react.js +33 -1
  186. package/dist/{chat/read.d.ts → read.d.ts} +2 -0
  187. package/dist/read.d.ts.map +1 -0
  188. package/dist/{chat/read.js → read.js} +4 -0
  189. package/dist/readiness.d.ts +13 -17
  190. package/dist/readiness.d.ts.map +1 -1
  191. package/dist/readiness.js +2 -8
  192. package/dist/reads.d.ts +38 -10
  193. package/dist/reads.d.ts.map +1 -1
  194. package/dist/reads.js +163 -83
  195. package/dist/recovery.d.ts +5 -2
  196. package/dist/recovery.d.ts.map +1 -1
  197. package/dist/recovery.js +65 -8
  198. package/dist/refresh.d.ts +18 -15
  199. package/dist/refresh.d.ts.map +1 -1
  200. package/dist/refresh.js +145 -79
  201. package/dist/refusal.d.ts +5 -0
  202. package/dist/refusal.d.ts.map +1 -0
  203. package/dist/refusal.js +57 -0
  204. package/dist/replica.d.ts +50 -39
  205. package/dist/replica.d.ts.map +1 -1
  206. package/dist/replica.js +319 -208
  207. package/dist/retried.d.ts +30 -0
  208. package/dist/retried.d.ts.map +1 -0
  209. package/dist/retried.js +72 -0
  210. package/dist/room-draft.d.ts +28 -11
  211. package/dist/room-draft.d.ts.map +1 -1
  212. package/dist/room-draft.js +194 -117
  213. package/dist/room-drafts.d.ts +24 -0
  214. package/dist/room-drafts.d.ts.map +1 -0
  215. package/dist/room-drafts.js +217 -0
  216. package/dist/rows.d.ts +31 -31
  217. package/dist/rows.d.ts.map +1 -1
  218. package/dist/rows.js +60 -125
  219. package/dist/runtime.d.ts +36 -0
  220. package/dist/runtime.d.ts.map +1 -0
  221. package/dist/runtime.js +1 -0
  222. package/dist/save.d.ts +43 -50
  223. package/dist/save.d.ts.map +1 -1
  224. package/dist/save.js +661 -228
  225. package/dist/saves.d.ts +32 -0
  226. package/dist/saves.d.ts.map +1 -0
  227. package/dist/saves.js +413 -0
  228. package/dist/search.d.ts +12 -95
  229. package/dist/search.d.ts.map +1 -1
  230. package/dist/search.js +10 -266
  231. package/dist/seed.d.ts +11 -2
  232. package/dist/seed.d.ts.map +1 -1
  233. package/dist/seed.js +71 -1
  234. package/dist/shared.d.ts +4 -9
  235. package/dist/shared.d.ts.map +1 -1
  236. package/dist/shared.js +61 -120
  237. package/dist/shown.d.ts +32 -0
  238. package/dist/shown.d.ts.map +1 -0
  239. package/dist/shown.js +290 -0
  240. package/dist/socket/admission.d.ts +7 -0
  241. package/dist/socket/admission.d.ts.map +1 -0
  242. package/dist/socket/admission.js +39 -0
  243. package/dist/socket/answers.d.ts +6 -0
  244. package/dist/socket/answers.d.ts.map +1 -0
  245. package/dist/socket/answers.js +20 -0
  246. package/dist/socket/lanes.d.ts +21 -0
  247. package/dist/socket/lanes.d.ts.map +1 -0
  248. package/dist/socket/lanes.js +80 -0
  249. package/dist/socket/reads.d.ts +10 -0
  250. package/dist/socket/reads.d.ts.map +1 -0
  251. package/dist/socket/reads.js +31 -0
  252. package/dist/socket/session.d.ts +38 -0
  253. package/dist/socket/session.d.ts.map +1 -0
  254. package/dist/socket/session.js +23 -0
  255. package/dist/socket.d.ts +68 -0
  256. package/dist/socket.d.ts.map +1 -0
  257. package/dist/socket.js +171 -0
  258. package/dist/source.d.ts +54 -0
  259. package/dist/source.d.ts.map +1 -0
  260. package/dist/source.js +82 -0
  261. package/dist/status.d.ts +4 -5
  262. package/dist/status.d.ts.map +1 -1
  263. package/dist/status.js +3 -7
  264. package/dist/store/installs.d.ts +30 -0
  265. package/dist/store/installs.d.ts.map +1 -0
  266. package/dist/store/installs.js +34 -0
  267. package/dist/store/readiness.d.ts +10 -0
  268. package/dist/store/readiness.d.ts.map +1 -0
  269. package/dist/store/readiness.js +52 -0
  270. package/dist/store/records.d.ts +212 -0
  271. package/dist/store/records.d.ts.map +1 -0
  272. package/dist/store/records.js +430 -0
  273. package/dist/store/room-held.d.ts +8 -0
  274. package/dist/store/room-held.d.ts.map +1 -0
  275. package/dist/store/room-held.js +17 -0
  276. package/dist/store/space.d.ts +11 -0
  277. package/dist/store/space.d.ts.map +1 -0
  278. package/dist/store/space.js +41 -0
  279. package/dist/store/watchers.d.ts +17 -0
  280. package/dist/store/watchers.d.ts.map +1 -0
  281. package/dist/store/watchers.js +56 -0
  282. package/dist/store/writes.d.ts +24 -0
  283. package/dist/store/writes.d.ts.map +1 -0
  284. package/dist/store/writes.js +125 -0
  285. package/dist/store.d.ts +111 -166
  286. package/dist/store.d.ts.map +1 -1
  287. package/dist/store.js +158 -797
  288. package/dist/stored.d.ts +156 -0
  289. package/dist/stored.d.ts.map +1 -0
  290. package/dist/stored.js +649 -0
  291. package/dist/surface.d.ts +88 -0
  292. package/dist/surface.d.ts.map +1 -0
  293. package/dist/surface.js +223 -0
  294. package/dist/sync.d.ts +19 -0
  295. package/dist/sync.d.ts.map +1 -0
  296. package/dist/sync.js +540 -0
  297. package/dist/tables.d.ts +412 -0
  298. package/dist/tables.d.ts.map +1 -0
  299. package/dist/tables.js +737 -0
  300. package/dist/tallies.d.ts +18 -0
  301. package/dist/tallies.d.ts.map +1 -0
  302. package/dist/tallies.js +129 -0
  303. package/dist/transfer.d.ts +0 -5
  304. package/dist/transfer.d.ts.map +1 -1
  305. package/dist/turn.d.ts +1 -1
  306. package/dist/turn.d.ts.map +1 -1
  307. package/dist/turn.js +31 -20
  308. package/dist/validation.d.ts +29 -0
  309. package/dist/validation.d.ts.map +1 -0
  310. package/dist/validation.js +104 -0
  311. package/dist/windows.d.ts +1 -16
  312. package/dist/windows.d.ts.map +1 -1
  313. package/dist/windows.js +2 -79
  314. package/dist/wire.d.ts +72 -8
  315. package/dist/wire.d.ts.map +1 -1
  316. package/dist/wire.js +24 -5
  317. package/package.json +19 -19
  318. package/AGENTS.md +0 -299
  319. package/dist/attempt.d.ts +0 -16
  320. package/dist/attempt.d.ts.map +0 -1
  321. package/dist/attempt.js +0 -70
  322. package/dist/chat/acts.d.ts +0 -33
  323. package/dist/chat/acts.d.ts.map +0 -1
  324. package/dist/chat/acts.js +0 -36
  325. package/dist/chat/context.d.ts +0 -3
  326. package/dist/chat/context.d.ts.map +0 -1
  327. package/dist/chat/earlier.d.ts +0 -10
  328. package/dist/chat/earlier.d.ts.map +0 -1
  329. package/dist/chat/earlier.js +0 -54
  330. package/dist/chat/input.d.ts +0 -9
  331. package/dist/chat/input.d.ts.map +0 -1
  332. package/dist/chat/input.js +0 -99
  333. package/dist/chat/kit.d.ts +0 -61
  334. package/dist/chat/kit.d.ts.map +0 -1
  335. package/dist/chat/kit.js +0 -123
  336. package/dist/chat/lasting.d.ts +0 -6
  337. package/dist/chat/lasting.d.ts.map +0 -1
  338. package/dist/chat/lasting.js +0 -19
  339. package/dist/chat/list.d.ts +0 -27
  340. package/dist/chat/list.d.ts.map +0 -1
  341. package/dist/chat/list.js +0 -99
  342. package/dist/chat/markdown.d.ts +0 -21
  343. package/dist/chat/markdown.d.ts.map +0 -1
  344. package/dist/chat/markdown.js +0 -246
  345. package/dist/chat/message.d.ts +0 -6
  346. package/dist/chat/message.d.ts.map +0 -1
  347. package/dist/chat/message.js +0 -192
  348. package/dist/chat/messages.d.ts +0 -22
  349. package/dist/chat/messages.d.ts.map +0 -1
  350. package/dist/chat/messages.js +0 -171
  351. package/dist/chat/name.d.ts +0 -6
  352. package/dist/chat/name.d.ts.map +0 -1
  353. package/dist/chat/name.js +0 -37
  354. package/dist/chat/opened.d.ts +0 -11
  355. package/dist/chat/opened.d.ts.map +0 -1
  356. package/dist/chat/opened.js +0 -17
  357. package/dist/chat/overlay.d.ts +0 -31
  358. package/dist/chat/overlay.d.ts.map +0 -1
  359. package/dist/chat/overlay.js +0 -97
  360. package/dist/chat/parts.d.ts +0 -57
  361. package/dist/chat/parts.d.ts.map +0 -1
  362. package/dist/chat/parts.js +0 -119
  363. package/dist/chat/pieces.d.ts +0 -62
  364. package/dist/chat/pieces.d.ts.map +0 -1
  365. package/dist/chat/pieces.js +0 -1110
  366. package/dist/chat/process.d.ts +0 -20
  367. package/dist/chat/process.d.ts.map +0 -1
  368. package/dist/chat/process.js +0 -32
  369. package/dist/chat/provider.d.ts +0 -63
  370. package/dist/chat/provider.d.ts.map +0 -1
  371. package/dist/chat/provider.js +0 -630
  372. package/dist/chat/question.d.ts +0 -9
  373. package/dist/chat/question.d.ts.map +0 -1
  374. package/dist/chat/question.js +0 -69
  375. package/dist/chat/questions.d.ts.map +0 -1
  376. package/dist/chat/read.d.ts.map +0 -1
  377. package/dist/chat/ready.d.ts +0 -34
  378. package/dist/chat/ready.d.ts.map +0 -1
  379. package/dist/chat/ready.js +0 -91
  380. package/dist/chat/steady.d.ts +0 -3
  381. package/dist/chat/steady.d.ts.map +0 -1
  382. package/dist/chat/steady.js +0 -26
  383. package/dist/chat/style.d.ts +0 -4
  384. package/dist/chat/style.d.ts.map +0 -1
  385. package/dist/chat/style.js +0 -302
  386. package/dist/chat.d.ts +0 -14
  387. package/dist/chat.d.ts.map +0 -1
  388. package/dist/chat.js +0 -8
  389. package/dist/fence.d.ts +0 -6
  390. package/dist/fence.d.ts.map +0 -1
  391. package/dist/fence.js +0 -10
  392. package/dist/read-side.d.ts +0 -27
  393. package/dist/read-side.d.ts.map +0 -1
  394. package/dist/read-side.js +0 -826
@@ -1,171 +0,0 @@
1
- import { contextIn, jobOf, partsOf, stillRunning } from './parts.js';
2
- import { list, record, text } from './read.js';
3
- const SAID = new WeakMap();
4
- const CONVERTED = new WeakMap();
5
- export function saidOf(entry) {
6
- const held = SAID.get(entry);
7
- if (held !== undefined)
8
- return held;
9
- const message = record(entry.message);
10
- const said = {
11
- turn: text(message, 'turn_id') ?? entry.turn,
12
- user: text(message, 'role') === 'user',
13
- text: text(message, 'text') ?? '',
14
- parts: partsOf(list(message, 'parts')),
15
- context: contextIn(message.context),
16
- failure: text(message, 'failure'),
17
- undelivered: message.telegram_undelivered === true,
18
- files: list(message, 'files').flatMap((one) => text(record(one), 'name') ?? []),
19
- };
20
- SAID.set(entry, said);
21
- return said;
22
- }
23
- function sameWork(held, now) {
24
- return (held.length === now.length &&
25
- held.every((one, at) => one.kind === now[at].kind && one.title === now[at].title && one.next === now[at].next));
26
- }
27
- function converted(entry, lasting, again, convert) {
28
- const held = CONVERTED.get(entry);
29
- if (held !== undefined && held.again === again && sameWork(held.lasting, lasting)) {
30
- return held.message;
31
- }
32
- const message = convert();
33
- CONVERTED.set(entry, { lasting, again, message });
34
- return message;
35
- }
36
- function markerArgs(part) {
37
- if (part.marker !== 'job')
38
- return { marker: part.marker, text: part.text };
39
- const job = jobOf(part.text);
40
- return {
41
- marker: part.marker,
42
- text: part.text,
43
- job: job.kind,
44
- label: job.label,
45
- state: job.state,
46
- next: job.next ?? '',
47
- };
48
- }
49
- function contentOf(id, parts, live) {
50
- return parts.map((part, at) => {
51
- const done = !live || at < parts.length - 1;
52
- const call = (toolName, args) => ({
53
- type: 'tool-call',
54
- toolCallId: `${id}:${at}`,
55
- toolName,
56
- args,
57
- result: done ? null : undefined,
58
- });
59
- switch (part.type) {
60
- case 'text':
61
- return { type: 'text', text: part.text };
62
- case 'reasoning':
63
- return { type: 'reasoning', text: part.text };
64
- case 'commands':
65
- return call('commands', { count: part.count });
66
- case 'subagent':
67
- return {
68
- ...call('subagent', { description: part.description }),
69
- result: part.done ? part.result : undefined,
70
- };
71
- case 'message':
72
- return call('message', { command: part.command, target: part.target ?? '' });
73
- case 'marker':
74
- return call('marker', markerArgs(part));
75
- case 'plan':
76
- return {
77
- ...call('plan', {}),
78
- args: { steps: part.steps.map((step) => ({ ...step })) },
79
- };
80
- case 'image':
81
- return { type: 'file', filename: part.name, mimeType: part.mediaType, data: '' };
82
- }
83
- });
84
- }
85
- function leftRunning(view) {
86
- if (view.process?.running === false)
87
- return new Map();
88
- const turns = view.messages.flatMap((entry) => {
89
- const one = saidOf(entry);
90
- return one.user ? [] : [{ turn: one.turn, parts: one.parts, ended: true }];
91
- });
92
- return stillRunning(view.turn === null
93
- ? turns
94
- : [...turns, { turn: view.turn.turn, parts: partsOf(view.turn.parts), ended: false }]);
95
- }
96
- export function awaitsTurn(view) {
97
- const newest = view?.messages.at(-1);
98
- return view?.turn === null && newest !== undefined && saidOf(newest).user;
99
- }
100
- export function askedBefore(view, id) {
101
- const said = (view?.messages ?? []).map((entry) => ({ ...saidOf(entry), id: entry.identity }));
102
- const asked = said
103
- .slice(0, said.findIndex((one) => one.id === id) + 1)
104
- .reverse()
105
- .find((one) => one.user);
106
- return asked === undefined || asked.text === '' ? null : asked.text;
107
- }
108
- export function chatMessages(view) {
109
- if (view === null)
110
- return [];
111
- const lasting = leftRunning(view);
112
- const said = view.messages.map((entry, at) => {
113
- const one = saidOf(entry);
114
- const custom = { undelivered: one.undelivered };
115
- if (one.user) {
116
- return converted(entry, [], false, () => ({
117
- id: entry.identity,
118
- role: 'user',
119
- content: [{ type: 'text', text: one.text }],
120
- attachments: one.files.map((name, at) => ({
121
- id: `${entry.identity}:${at}`,
122
- type: 'file',
123
- name,
124
- status: { type: 'complete' },
125
- content: [],
126
- })),
127
- metadata: { custom },
128
- }));
129
- }
130
- const failed = one.failure === null
131
- ? undefined
132
- : { type: 'incomplete', reason: 'error', error: one.failure };
133
- const working = lasting.get(one.turn) ?? [];
134
- const again = failed !== undefined &&
135
- view.turn === null &&
136
- at === view.messages.length - 1 &&
137
- askedBefore(view, view.messages[at - 1]?.identity ?? null) !== null;
138
- return converted(entry, working, again, () => ({
139
- id: entry.identity,
140
- role: 'assistant',
141
- content: contentOf(entry.identity, one.parts, false),
142
- status: failed,
143
- metadata: { custom: { ...custom, lasting: working, again } },
144
- }));
145
- });
146
- if (view.turn === null)
147
- return said;
148
- const running = `running:${view.turn.turn}`;
149
- return [
150
- ...said,
151
- {
152
- id: running,
153
- role: 'assistant',
154
- content: contentOf(running, partsOf(view.turn.parts), true),
155
- status: { type: 'running' },
156
- },
157
- ];
158
- }
159
- export function contextOf(view) {
160
- if (view === null)
161
- return null;
162
- const running = view.turn === null ? null : contextIn(view.turn.context);
163
- if (running !== null)
164
- return running;
165
- for (const entry of [...view.messages].reverse()) {
166
- const held = contextIn(record(entry.message).context);
167
- if (held !== null)
168
- return held;
169
- }
170
- return null;
171
- }
@@ -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
- }
@@ -1,31 +0,0 @@
1
- import type { ChatDraft, ConversationEntry, ConversationView } from '../conversation.js';
2
- import { type ExpectedOf, type Expecting } from '../expectation.js';
3
- type Entries = readonly ConversationEntry[];
4
- export type Expectation = {
5
- readonly key: string;
6
- readonly view: 'conversation';
7
- draw(held: ConversationView): ConversationView;
8
- shown(held: ConversationView): boolean;
9
- } | {
10
- readonly key: string;
11
- readonly view: 'conversations';
12
- draw(held: Entries): Entries;
13
- shown(held: Entries): boolean;
14
- };
15
- export type Expected = ExpectedOf<Expectation>;
16
- export type Overlay = Omit<Expecting<Expectation>, 'expect' | 'heard' | 'drawn'> & {
17
- expect(act: number, expected: Expected): void;
18
- heard(held: ConversationView): void;
19
- heardList(held: Entries): void;
20
- conversation(held: ConversationView): ConversationView;
21
- conversations(held: Entries): Entries;
22
- };
23
- export declare function overlay(): Overlay;
24
- export declare function sentMessage(key: string, into: readonly string[], said: ChatDraft, turn: string | null): Expectation;
25
- export declare function optionChosen(conversation: string, option: string, value: string): Expectation;
26
- export declare function questionAnswered(conversation: string, interaction: string): Expectation;
27
- export declare function conversationListed(entry: ConversationEntry): Expectation;
28
- export declare function conversationChanged(conversation: string, changes: Partial<Pick<ConversationEntry, 'name' | 'finished'>>, shown: (entry: ConversationEntry) => boolean): Expectation;
29
- export declare function conversationGone(conversation: string): Expectation;
30
- export {};
31
- //# sourceMappingURL=overlay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/chat/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAa,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG/E,KAAK,OAAO,GAAG,SAAS,iBAAiB,EAAE,CAAC;AAE5C,MAAM,MAAM,WAAW,GACnB;IACE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,IAAI,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC/C,KAAK,CAAC,IAAI,EAAE,gBAA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,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,EAC9D,KAAK,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,GAC3C,WAAW,CAQb;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,CAQlE"}
@@ -1,97 +0,0 @@
1
- import { expecting } from '../expectation.js';
2
- import { record, text } from './read.js';
3
- export function overlay() {
4
- const held = expecting();
5
- return {
6
- subscribe: held.subscribe,
7
- version: held.version,
8
- begin: held.begin,
9
- drop: held.drop,
10
- expect: (act, expected) => held.expect(act, expected),
11
- heard: (view) => held.heard((one) => one.view === 'conversation' && one.shown(view)),
12
- heardList: (entries) => held.heard((one) => one.view === 'conversations' && one.shown(entries)),
13
- conversation: (view) => held.drawn().reduce((now, one) => (one.view === 'conversation' ? one.draw(now) : now), view),
14
- conversations: (entries) => held
15
- .drawn()
16
- .reduce((now, one) => (one.view === 'conversations' ? one.draw(now) : now), entries),
17
- };
18
- }
19
- export function sentMessage(key, into, said, turn) {
20
- const sealed = (held) => turn !== null && held.messages.some((one) => one.turn === turn);
21
- return {
22
- key,
23
- view: 'conversation',
24
- draw: (held) => !into.includes(held.conversation) || sealed(held)
25
- ? held
26
- : {
27
- ...held,
28
- messages: [
29
- ...held.messages,
30
- {
31
- identity: key,
32
- turn: turn ?? key,
33
- text: said.text,
34
- message: {
35
- role: 'user',
36
- text: said.text,
37
- files: said.files.map((file) => ({ name: file.name })),
38
- },
39
- },
40
- ],
41
- },
42
- shown: sealed,
43
- };
44
- }
45
- export function optionChosen(conversation, option, value) {
46
- const ours = (entry) => text(record(entry), 'id') === option;
47
- return {
48
- key: `option ${conversation} ${option}`,
49
- view: 'conversation',
50
- draw: (held) => held.conversation !== conversation
51
- ? held
52
- : {
53
- ...held,
54
- options: held.options.map((entry) => ours(entry) && entry.type === 'select' ? { ...entry, currentValue: value } : entry),
55
- },
56
- shown: (held) => held.conversation === conversation &&
57
- held.options.some((entry) => ours(entry) && text(record(entry), 'currentValue') === value),
58
- };
59
- }
60
- export function questionAnswered(conversation, interaction) {
61
- const ours = (entry) => text(record(entry), 'interaction_id') === interaction;
62
- return {
63
- key: `answer ${conversation} ${interaction}`,
64
- view: 'conversation',
65
- draw: (held) => held.conversation !== conversation
66
- ? held
67
- : { ...held, questions: held.questions.filter((entry) => !ours(entry)) },
68
- shown: (held) => held.conversation === conversation && !held.questions.some(ours),
69
- };
70
- }
71
- export function conversationListed(entry) {
72
- const ours = (one) => one.conversation === entry.conversation;
73
- return {
74
- key: `conversation ${entry.conversation}`,
75
- view: 'conversations',
76
- draw: (held) => (held.some(ours) ? held : [...held, entry]),
77
- shown: (held) => held.some(ours),
78
- };
79
- }
80
- export function conversationChanged(conversation, changes, shown) {
81
- const ours = (one) => one.conversation === conversation;
82
- return {
83
- key: `conversation ${conversation} ${Object.keys(changes).sort().join(' ')}`,
84
- view: 'conversations',
85
- draw: (held) => held.map((one) => (ours(one) ? { ...one, ...changes } : one)),
86
- shown: (held) => held.some((one) => ours(one) && shown(one)),
87
- };
88
- }
89
- export function conversationGone(conversation) {
90
- const ours = (one) => one.conversation === conversation;
91
- return {
92
- key: `conversation ${conversation}`,
93
- view: 'conversations',
94
- draw: (held) => held.filter((one) => !ours(one)),
95
- shown: (held) => !held.some(ours),
96
- };
97
- }
@@ -1,57 +0,0 @@
1
- import type { TurnContext } from '../adapter.js';
2
- export type PlanStep = {
3
- readonly content: string;
4
- readonly status: string;
5
- };
6
- export type Marker = 'mode' | 'compaction' | 'retry' | 'model' | 'job';
7
- export type Part = {
8
- readonly type: 'text';
9
- readonly text: string;
10
- } | {
11
- readonly type: 'reasoning';
12
- readonly text: string;
13
- } | {
14
- readonly type: 'commands';
15
- readonly count: number;
16
- } | {
17
- readonly type: 'subagent';
18
- readonly description: string;
19
- readonly done: boolean;
20
- readonly result: string | null;
21
- } | {
22
- readonly type: 'message';
23
- readonly command: string;
24
- readonly target: string | null;
25
- } | {
26
- readonly type: 'image';
27
- readonly name: string;
28
- readonly mediaType: string;
29
- } | {
30
- readonly type: 'marker';
31
- readonly marker: Marker;
32
- readonly text: string;
33
- } | {
34
- readonly type: 'plan';
35
- readonly steps: readonly PlanStep[];
36
- };
37
- export declare function partsOf(raw: readonly unknown[]): readonly Part[];
38
- export declare function contextIn(raw: unknown): TurnContext | null;
39
- export type Turn = {
40
- readonly turn: string;
41
- readonly parts: readonly Part[];
42
- readonly ended: boolean;
43
- };
44
- export type ChatWork = {
45
- readonly kind: 'job' | 'schedule' | 'subagent';
46
- readonly title: string;
47
- readonly next: string | null;
48
- };
49
- export type Job = {
50
- readonly label: string;
51
- readonly kind: 'started' | 'scheduled' | 'ended';
52
- readonly state: string;
53
- readonly next: string | null;
54
- };
55
- export declare function jobOf(said: string): Job;
56
- export declare function stillRunning(turns: readonly Turn[]): ReadonlyMap<string, readonly ChatWork[]>;
57
- //# sourceMappingURL=parts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/chat/parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvE,MAAM,MAAM,IAAI,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ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AAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG;IAChB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAIF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CASvC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC,CA0C7F"}
@@ -1,119 +0,0 @@
1
- import { list, record, text } from './read.js';
2
- const MARKERS = ['mode', 'compaction', 'retry', 'model', 'job'];
3
- function partOf(raw) {
4
- const part = record(raw);
5
- switch (text(part, 'type')) {
6
- case 'text':
7
- case 'reasoning': {
8
- const said = text(part, 'text');
9
- return said === null ? null : { type: part.type, text: said };
10
- }
11
- case 'commands':
12
- return typeof part.count === 'number' ? { type: 'commands', count: part.count } : null;
13
- case 'subagent':
14
- return {
15
- type: 'subagent',
16
- description: text(part, 'description') ?? '',
17
- done: part.status === 'done',
18
- result: text(part, 'result'),
19
- };
20
- case 'message': {
21
- const command = text(part, 'command');
22
- return command === null ? null : { type: 'message', command, target: text(part, 'target') };
23
- }
24
- case 'image': {
25
- const name = text(part, 'name');
26
- return name === null
27
- ? null
28
- : { type: 'image', name, mediaType: text(part, 'media_type') ?? '' };
29
- }
30
- case 'marker': {
31
- const marker = text(part, 'marker');
32
- return marker === null || !MARKERS.includes(marker)
33
- ? null
34
- : { type: 'marker', marker: marker, text: text(part, 'text') ?? '' };
35
- }
36
- case 'plan':
37
- return {
38
- type: 'plan',
39
- steps: list(part, 'entries').flatMap((entry) => {
40
- const step = record(entry);
41
- const content = text(step, 'content');
42
- return content === null ? [] : [{ content, status: text(step, 'status') ?? '' }];
43
- }),
44
- };
45
- default:
46
- return null;
47
- }
48
- }
49
- export function partsOf(raw) {
50
- return raw.flatMap((one) => partOf(one) ?? []);
51
- }
52
- export function contextIn(raw) {
53
- const held = record(raw);
54
- return typeof held.used === 'number' && typeof held.window === 'number' && held.window > 0
55
- ? { used: held.used, window: held.window }
56
- : null;
57
- }
58
- const NEXT_RUN = 'next run ';
59
- export function jobOf(said) {
60
- const at = said.lastIndexOf(': ');
61
- const label = at === -1 ? said : said.slice(0, at);
62
- const state = at === -1 ? '' : said.slice(at + 2);
63
- if (state === 'running')
64
- return { label, kind: 'started', state, next: null };
65
- if (state === 'scheduled')
66
- return { label, kind: 'scheduled', state, next: null };
67
- return state.startsWith(NEXT_RUN)
68
- ? { label, kind: 'scheduled', state, next: state.slice(NEXT_RUN.length) }
69
- : { label, kind: 'ended', state, next: null };
70
- }
71
- export function stillRunning(turns) {
72
- const open = [];
73
- const close = (key) => {
74
- const at = open.map((one) => one.key).lastIndexOf(key);
75
- if (at !== -1)
76
- open.splice(at, 1);
77
- };
78
- for (const { turn, parts, ended } of turns) {
79
- for (const part of parts) {
80
- if (part.type === 'subagent') {
81
- const key = `subagent\u0000${part.description}`;
82
- if (part.done)
83
- close(key);
84
- else if (ended) {
85
- open.push({ turn, key, work: { kind: 'subagent', title: part.description, next: null } });
86
- }
87
- continue;
88
- }
89
- if (part.type !== 'marker' || part.marker !== 'job')
90
- continue;
91
- const job = jobOf(part.text);
92
- const started = `job\u0000${job.label}`;
93
- const schedule = `schedule\u0000${job.label}`;
94
- if (job.kind === 'scheduled') {
95
- close(schedule);
96
- if (ended) {
97
- open.push({
98
- turn,
99
- key: schedule,
100
- work: { kind: 'schedule', title: job.label, next: job.next },
101
- });
102
- }
103
- }
104
- else if (job.kind === 'started') {
105
- if (ended) {
106
- open.push({ turn, key: started, work: { kind: 'job', title: job.label, next: null } });
107
- }
108
- }
109
- else {
110
- close(started);
111
- close(schedule);
112
- }
113
- }
114
- }
115
- const under = new Map();
116
- for (const one of open)
117
- under.set(one.turn, [...(under.get(one.turn) ?? []), one.work]);
118
- return under;
119
- }
@@ -1,62 +0,0 @@
1
- import { fromMarkdown } from 'mdast-util-from-markdown';
2
- export type Root = ReturnType<typeof fromMarkdown>;
3
- export type Block = Root['children'][number];
4
- export declare function parseMarkdown(text: string): Root;
5
- export type Step = 'list' | 'item' | 'footnote' | 'table' | 'blockquote' | 'paragraph';
6
- export interface Piece {
7
- readonly nodes: readonly Block[];
8
- readonly path: readonly Step[];
9
- readonly join: string;
10
- }
11
- interface Level {
12
- readonly kind: 'quote' | 'item' | 'note';
13
- readonly line: number;
14
- readonly column: number;
15
- readonly size: number;
16
- readonly carry: string;
17
- readonly spread: boolean;
18
- }
19
- interface Next {
20
- readonly start: number;
21
- readonly path: readonly Step[];
22
- readonly join: string;
23
- readonly carry: string;
24
- readonly levels: readonly Level[];
25
- }
26
- interface Found {
27
- readonly key: string;
28
- readonly at: number;
29
- readonly url: string;
30
- }
31
- interface Region {
32
- readonly from: number;
33
- readonly looks: readonly number[];
34
- readonly last: ReadonlyMap<string, number>;
35
- readonly runs: ReadonlyMap<number, number>;
36
- }
37
- interface Discovery {
38
- readonly found: Found[];
39
- next: Next | null;
40
- }
41
- export interface Long {
42
- readonly text: string;
43
- readonly starts: Int32Array;
44
- readonly breaks: Int32Array;
45
- readonly quoteBreaks: Int32Array;
46
- readonly anchors: readonly number[];
47
- readonly candidates: ReadonlyMap<string, readonly number[]>;
48
- readonly pieces: Piece[];
49
- next: Next | null;
50
- readonly urls: Map<string, string>;
51
- readonly spans: Map<string, readonly Found[]>;
52
- readonly discoveries: Map<number, Discovery>;
53
- readonly regions: Map<string, Region>;
54
- readonly spreads: Map<number, boolean | null>;
55
- }
56
- export declare function identifierOf(label: string): string;
57
- export declare function longOf(text: string): Long;
58
- export declare function pieceAt(long: Long, index: number): Piece | null;
59
- export declare function drawn(long: Long, count: number): Block[];
60
- export declare function remaining(long: Long, count: number): boolean;
61
- export {};
62
- //# sourceMappingURL=pieces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pieces.d.ts","sourceRoot":"","sources":["../../src/chat/pieces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxD,MAAM,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACnD,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAI7C,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEhD;AAsED,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,YAAY,GAAG,WAAW,CAAC;AAIvF,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,KAAK;IACb,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,IAAI;IACZ,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,IAAI,EAA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