@yaks/session 0.0.0-stage → 0.2.36

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 (393) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1392 -2
  3. package/_dist/admission.d.ts +15 -0
  4. package/_dist/admission.d.ts.map +1 -0
  5. package/_dist/announce.d.ts +17 -0
  6. package/_dist/announce.d.ts.map +1 -0
  7. package/_dist/answer.d.ts +200 -0
  8. package/_dist/answer.d.ts.map +1 -0
  9. package/_dist/append.d.ts +10 -0
  10. package/_dist/append.d.ts.map +1 -0
  11. package/_dist/archive.d.ts +6 -0
  12. package/_dist/archive.d.ts.map +1 -0
  13. package/_dist/asks.d.ts +11 -0
  14. package/_dist/asks.d.ts.map +1 -0
  15. package/_dist/audit.d.ts +15 -0
  16. package/_dist/audit.d.ts.map +1 -0
  17. package/_dist/bounce.d.ts +19 -0
  18. package/_dist/bounce.d.ts.map +1 -0
  19. package/_dist/bus.d.ts +8 -0
  20. package/_dist/bus.d.ts.map +1 -0
  21. package/_dist/cache.d.ts +45 -0
  22. package/_dist/cache.d.ts.map +1 -0
  23. package/_dist/child-notice.d.ts +6 -0
  24. package/_dist/child-notice.d.ts.map +1 -0
  25. package/_dist/children.d.ts +59 -0
  26. package/_dist/children.d.ts.map +1 -0
  27. package/_dist/cli.d.ts +8 -0
  28. package/_dist/cli.d.ts.map +1 -0
  29. package/_dist/comp.d.ts +9 -0
  30. package/_dist/comp.d.ts.map +1 -0
  31. package/_dist/compact.d.ts +19 -0
  32. package/_dist/compact.d.ts.map +1 -0
  33. package/_dist/conversation.d.ts +158 -0
  34. package/_dist/conversation.d.ts.map +1 -0
  35. package/_dist/cost.d.ts +13 -0
  36. package/_dist/cost.d.ts.map +1 -0
  37. package/_dist/deferred.d.ts +79 -0
  38. package/_dist/deferred.d.ts.map +1 -0
  39. package/_dist/ended.d.ts +27 -0
  40. package/_dist/ended.d.ts.map +1 -0
  41. package/_dist/files.d.ts +73 -0
  42. package/_dist/files.d.ts.map +1 -0
  43. package/_dist/fork.d.ts +23 -0
  44. package/_dist/fork.d.ts.map +1 -0
  45. package/_dist/graft.d.ts +33 -0
  46. package/_dist/graft.d.ts.map +1 -0
  47. package/_dist/graph.d.ts +14 -0
  48. package/_dist/graph.d.ts.map +1 -0
  49. package/_dist/handoff.d.ts +29 -0
  50. package/_dist/handoff.d.ts.map +1 -0
  51. package/_dist/imported.d.ts +63 -0
  52. package/_dist/imported.d.ts.map +1 -0
  53. package/_dist/intake.d.ts +43 -0
  54. package/_dist/intake.d.ts.map +1 -0
  55. package/_dist/joined.d.ts +35 -0
  56. package/_dist/joined.d.ts.map +1 -0
  57. package/_dist/lease.d.ts +21 -0
  58. package/_dist/lease.d.ts.map +1 -0
  59. package/_dist/lines.d.ts +13 -0
  60. package/_dist/lines.d.ts.map +1 -0
  61. package/_dist/mod.d.ts +107 -0
  62. package/_dist/mod.d.ts.map +1 -0
  63. package/_dist/naming.d.ts +10 -0
  64. package/_dist/naming.d.ts.map +1 -0
  65. package/_dist/native.d.ts +13 -0
  66. package/_dist/native.d.ts.map +1 -0
  67. package/_dist/parts.d.ts +145 -0
  68. package/_dist/parts.d.ts.map +1 -0
  69. package/_dist/plugin.d.ts +33 -0
  70. package/_dist/plugin.d.ts.map +1 -0
  71. package/_dist/project.d.ts +67 -0
  72. package/_dist/project.d.ts.map +1 -0
  73. package/_dist/prose.d.ts +7 -0
  74. package/_dist/prose.d.ts.map +1 -0
  75. package/_dist/providers.d.ts +36 -0
  76. package/_dist/providers.d.ts.map +1 -0
  77. package/_dist/reach.d.ts +39 -0
  78. package/_dist/reach.d.ts.map +1 -0
  79. package/_dist/react.d.ts +236 -0
  80. package/_dist/react.d.ts.map +1 -0
  81. package/_dist/readers.d.ts +221 -0
  82. package/_dist/readers.d.ts.map +1 -0
  83. package/_dist/reap.d.ts +21 -0
  84. package/_dist/reap.d.ts.map +1 -0
  85. package/_dist/recall.d.ts +32 -0
  86. package/_dist/recall.d.ts.map +1 -0
  87. package/_dist/routes.d.ts +15 -0
  88. package/_dist/routes.d.ts.map +1 -0
  89. package/_dist/run.d.ts +81 -0
  90. package/_dist/run.d.ts.map +1 -0
  91. package/_dist/service.d.ts +131 -0
  92. package/_dist/service.d.ts.map +1 -0
  93. package/_dist/source.d.ts +9 -0
  94. package/_dist/source.d.ts.map +1 -0
  95. package/_dist/start.d.ts +29 -0
  96. package/_dist/start.d.ts.map +1 -0
  97. package/_dist/state.d.ts +75 -0
  98. package/_dist/state.d.ts.map +1 -0
  99. package/_dist/status.d.ts +38 -0
  100. package/_dist/status.d.ts.map +1 -0
  101. package/_dist/tail.d.ts +121 -0
  102. package/_dist/tail.d.ts.map +1 -0
  103. package/_dist/timing.d.ts +9 -0
  104. package/_dist/timing.d.ts.map +1 -0
  105. package/_dist/told.d.ts +17 -0
  106. package/_dist/told.d.ts.map +1 -0
  107. package/_dist/tools.d.ts +41 -0
  108. package/_dist/tools.d.ts.map +1 -0
  109. package/_dist/transcript.d.ts +5 -0
  110. package/_dist/transcript.d.ts.map +1 -0
  111. package/_dist/turn.d.ts +49 -0
  112. package/_dist/turn.d.ts.map +1 -0
  113. package/_dist/unknown.d.ts +6 -0
  114. package/_dist/unknown.d.ts.map +1 -0
  115. package/_dist/views.d.ts +9 -0
  116. package/_dist/views.d.ts.map +1 -0
  117. package/_dist/vocab.d.ts +9 -0
  118. package/_dist/vocab.d.ts.map +1 -0
  119. package/_dist/wait.d.ts +15 -0
  120. package/_dist/wait.d.ts.map +1 -0
  121. package/_dist/wake.d.ts +116 -0
  122. package/_dist/wake.d.ts.map +1 -0
  123. package/_dist/watch.d.ts +52 -0
  124. package/_dist/watch.d.ts.map +1 -0
  125. package/_dist/who.d.ts +84 -0
  126. package/_dist/who.d.ts.map +1 -0
  127. package/_dist/window.d.ts +43 -0
  128. package/_dist/window.d.ts.map +1 -0
  129. package/admission.js +137 -0
  130. package/admission.js.map +1 -0
  131. package/admission.ts +164 -0
  132. package/announce.js +123 -0
  133. package/announce.js.map +1 -0
  134. package/announce.ts +126 -0
  135. package/answer.js +372 -0
  136. package/answer.js.map +1 -0
  137. package/answer.ts +426 -0
  138. package/append.js +125 -0
  139. package/append.js.map +1 -0
  140. package/append.ts +205 -0
  141. package/archive.js +62 -0
  142. package/archive.js.map +1 -0
  143. package/archive.ts +62 -0
  144. package/asks.js +80 -0
  145. package/asks.js.map +1 -0
  146. package/asks.ts +106 -0
  147. package/attempt.js +46 -0
  148. package/attempt.js.map +1 -0
  149. package/attempt.ts +60 -0
  150. package/audit.js +57 -0
  151. package/audit.js.map +1 -0
  152. package/audit.ts +65 -0
  153. package/bounce.js +29 -0
  154. package/bounce.js.map +1 -0
  155. package/bounce.ts +34 -0
  156. package/bus.js +568 -0
  157. package/bus.js.map +1 -0
  158. package/bus.ts +683 -0
  159. package/cache.js +169 -0
  160. package/cache.js.map +1 -0
  161. package/cache.ts +230 -0
  162. package/child-notice.js +128 -0
  163. package/child-notice.js.map +1 -0
  164. package/child-notice.ts +136 -0
  165. package/children.js +937 -0
  166. package/children.js.map +1 -0
  167. package/children.ts +925 -0
  168. package/claude-control.js +8 -0
  169. package/claude-control.js.map +1 -0
  170. package/claude-control.ts +12 -0
  171. package/cli.js +23 -0
  172. package/cli.js.map +1 -0
  173. package/cli.ts +28 -0
  174. package/comp.js +76 -0
  175. package/comp.js.map +1 -0
  176. package/comp.ts +78 -0
  177. package/compact.js +157 -0
  178. package/compact.js.map +1 -0
  179. package/compact.ts +209 -0
  180. package/compact_ask.js +280 -0
  181. package/compact_ask.js.map +1 -0
  182. package/compact_ask.ts +199 -0
  183. package/continue.js +131 -0
  184. package/continue.js.map +1 -0
  185. package/continue.ts +143 -0
  186. package/conversation.js +337 -0
  187. package/conversation.js.map +1 -0
  188. package/conversation.ts +593 -0
  189. package/cost.js +111 -0
  190. package/cost.js.map +1 -0
  191. package/cost.ts +93 -0
  192. package/deferred.js +207 -0
  193. package/deferred.js.map +1 -0
  194. package/deferred.ts +219 -0
  195. package/deno.json +1 -0
  196. package/dependencies.js +114 -0
  197. package/dependencies.js.map +1 -0
  198. package/dependencies.ts +110 -0
  199. package/draining.js +20 -0
  200. package/draining.js.map +1 -0
  201. package/draining.ts +26 -0
  202. package/ended.js +210 -0
  203. package/ended.js.map +1 -0
  204. package/ended.ts +225 -0
  205. package/files.js +285 -0
  206. package/files.js.map +1 -0
  207. package/files.ts +318 -0
  208. package/fork.js +96 -0
  209. package/fork.js.map +1 -0
  210. package/fork.ts +124 -0
  211. package/graft.js +97 -0
  212. package/graft.js.map +1 -0
  213. package/graft.ts +88 -0
  214. package/graph.js +49 -0
  215. package/graph.js.map +1 -0
  216. package/graph.ts +61 -0
  217. package/handoff.js +111 -0
  218. package/handoff.js.map +1 -0
  219. package/handoff.ts +147 -0
  220. package/help.js +432 -0
  221. package/help.js.map +1 -0
  222. package/help.ts +431 -0
  223. package/hooks.js +253 -0
  224. package/hooks.js.map +1 -0
  225. package/hooks.ts +333 -0
  226. package/imported.js +259 -0
  227. package/imported.js.map +1 -0
  228. package/imported.ts +201 -0
  229. package/inspect.js +353 -0
  230. package/inspect.js.map +1 -0
  231. package/inspect.ts +378 -0
  232. package/intake.js +115 -0
  233. package/intake.js.map +1 -0
  234. package/intake.ts +124 -0
  235. package/joined.js +67 -0
  236. package/joined.js.map +1 -0
  237. package/joined.ts +69 -0
  238. package/lease.js +146 -0
  239. package/lease.js.map +1 -0
  240. package/lease.ts +151 -0
  241. package/lifecycle.js +49 -0
  242. package/lifecycle.js.map +1 -0
  243. package/lifecycle.ts +46 -0
  244. package/lines.js +171 -0
  245. package/lines.js.map +1 -0
  246. package/lines.ts +177 -0
  247. package/listen.js +604 -0
  248. package/listen.js.map +1 -0
  249. package/listen.ts +976 -0
  250. package/log.js +78 -0
  251. package/log.js.map +1 -0
  252. package/log.ts +88 -0
  253. package/mod.js +107 -0
  254. package/mod.js.map +1 -0
  255. package/mod.ts +113 -0
  256. package/name.js +51 -0
  257. package/name.js.map +1 -0
  258. package/name.ts +84 -0
  259. package/naming.js +96 -0
  260. package/naming.js.map +1 -0
  261. package/naming.ts +102 -0
  262. package/native.js +17 -0
  263. package/native.js.map +1 -0
  264. package/native.ts +17 -0
  265. package/package.json +133 -4
  266. package/parts.js +334 -0
  267. package/parts.js.map +1 -0
  268. package/parts.ts +383 -0
  269. package/plugin.js +77 -0
  270. package/plugin.js.map +1 -0
  271. package/plugin.ts +98 -0
  272. package/project.js +354 -0
  273. package/project.js.map +1 -0
  274. package/project.ts +407 -0
  275. package/prompt.js +57 -0
  276. package/prompt.js.map +1 -0
  277. package/prompt.ts +92 -0
  278. package/prose.js +43 -0
  279. package/prose.js.map +1 -0
  280. package/prose.ts +63 -0
  281. package/providers.js +279 -0
  282. package/providers.js.map +1 -0
  283. package/providers.ts +306 -0
  284. package/pruning.js +80 -0
  285. package/pruning.js.map +1 -0
  286. package/pruning.ts +147 -0
  287. package/reach.js +923 -0
  288. package/reach.js.map +1 -0
  289. package/reach.ts +1107 -0
  290. package/react.js +2259 -0
  291. package/react.js.map +1 -0
  292. package/react.ts +2864 -0
  293. package/readers.js +956 -0
  294. package/readers.js.map +1 -0
  295. package/readers.ts +1017 -0
  296. package/reap.js +60 -0
  297. package/reap.js.map +1 -0
  298. package/reap.ts +65 -0
  299. package/recall.js +67 -0
  300. package/recall.js.map +1 -0
  301. package/recall.ts +114 -0
  302. package/reopen.js +45 -0
  303. package/reopen.js.map +1 -0
  304. package/reopen.ts +44 -0
  305. package/result-entry.js +32 -0
  306. package/result-entry.js.map +1 -0
  307. package/result-entry.ts +34 -0
  308. package/resume.js +266 -0
  309. package/resume.js.map +1 -0
  310. package/resume.ts +283 -0
  311. package/routes.js +129 -0
  312. package/routes.js.map +1 -0
  313. package/routes.ts +147 -0
  314. package/routine.js +179 -0
  315. package/routine.js.map +1 -0
  316. package/routine.ts +191 -0
  317. package/run.js +932 -0
  318. package/run.js.map +1 -0
  319. package/run.ts +999 -0
  320. package/service.js +806 -0
  321. package/service.js.map +1 -0
  322. package/service.ts +911 -0
  323. package/source.js +26 -0
  324. package/source.js.map +1 -0
  325. package/source.ts +40 -0
  326. package/start.js +197 -0
  327. package/start.js.map +1 -0
  328. package/start.ts +214 -0
  329. package/state.js +247 -0
  330. package/state.js.map +1 -0
  331. package/state.ts +404 -0
  332. package/status.js +1222 -0
  333. package/status.js.map +1 -0
  334. package/status.ts +1555 -0
  335. package/status_bench.ts +50 -0
  336. package/statusline.js +187 -0
  337. package/statusline.js.map +1 -0
  338. package/statusline.ts +232 -0
  339. package/tail.js +748 -0
  340. package/tail.js.map +1 -0
  341. package/tail.ts +815 -0
  342. package/talk.js +58 -0
  343. package/talk.js.map +1 -0
  344. package/talk.ts +51 -0
  345. package/task-context.js +41 -0
  346. package/task-context.js.map +1 -0
  347. package/task-context.ts +53 -0
  348. package/texted.js +65 -0
  349. package/texted.js.map +1 -0
  350. package/texted.ts +65 -0
  351. package/timing.js +37 -0
  352. package/timing.js.map +1 -0
  353. package/timing.ts +52 -0
  354. package/told.js +56 -0
  355. package/told.js.map +1 -0
  356. package/told.ts +54 -0
  357. package/tools.js +595 -0
  358. package/tools.js.map +1 -0
  359. package/tools.ts +633 -0
  360. package/transcript.js +34 -0
  361. package/transcript.js.map +1 -0
  362. package/transcript.ts +41 -0
  363. package/turn.js +47 -0
  364. package/turn.js.map +1 -0
  365. package/turn.ts +68 -0
  366. package/unknown.js +8 -0
  367. package/unknown.js.map +1 -0
  368. package/unknown.ts +9 -0
  369. package/views.js +15 -0
  370. package/views.js.map +1 -0
  371. package/views.ts +21 -0
  372. package/vocab.js +24 -0
  373. package/vocab.js.map +1 -0
  374. package/vocab.json +1573 -0
  375. package/vocab.ts +30 -0
  376. package/wait.js +30 -0
  377. package/wait.js.map +1 -0
  378. package/wait.ts +45 -0
  379. package/wake.js +552 -0
  380. package/wake.js.map +1 -0
  381. package/wake.ts +597 -0
  382. package/watch.js +520 -0
  383. package/watch.js.map +1 -0
  384. package/watch.ts +596 -0
  385. package/who.js +309 -0
  386. package/who.js.map +1 -0
  387. package/who.ts +347 -0
  388. package/window.js +179 -0
  389. package/window.js.map +1 -0
  390. package/window.ts +268 -0
  391. package/woken.js +129 -0
  392. package/woken.js.map +1 -0
  393. package/woken.ts +127 -0
package/tools.ts ADDED
@@ -0,0 +1,633 @@
1
+ // What anybody may ask of a transcript: the tool implementations exported as
2
+ // `@yaks/session/tools` — the code behind the `tool: true` declarations in
3
+ // ./vocab.json.
4
+ //
5
+ // Two things live here. The lease is the pair every worker calls: take the lock
6
+ // on the thing you are about to work on, release it when you are done. The
7
+ // injection loop is the other, and it is the same idea one level up — a session
8
+ // starts by reading back what it was in the middle of, and ends by recording
9
+ // what it did and releasing what it held. `hooks install` is what makes a
10
+ // harness run those two at the right moments (./hooks.ts); the turns in
11
+ // between, the package's duty reads from the harness's own transcript file
12
+ // (./service.ts).
13
+ //
14
+ // What a session is told is computed rows, never prose and never recalled
15
+ // memories (D-155194). `session_context` returns what a hook needs: the
16
+ // transcript becomes an entity under the harness's own id for it, and what
17
+ // comes back is that entity's id, the work it holds a lock on, and the rows of
18
+ // each saved query its persona contains, run at the moment they are said. The
19
+ // hook runs at a session's start and again after each compaction, which is
20
+ // when a summary may have kept an id and dropped what became of it. There was
21
+ // a composed digest here — the owner's turns, a handoff, recalled memories,
22
+ // the standing goals — and it is gone (T-37707).
23
+ //
24
+ // A harness hands its event over as JSON on stdin, which reaches a tool as the
25
+ // `hook` argument (`yak session context --hook -`). Parsing it here is what
26
+ // keeps the harness's own JSON format out of everything else: one field is read
27
+ // from it, the session's own id, and a payload that is not JSON at all is no
28
+ // reason to fail — a hook that fails is a session that will not start.
29
+ //
30
+ // The third thing here is the two checks — tools whose verb is `check`, which
31
+ // is all a "doctor" command is (@yaks/tools ./check.ts).
32
+ //
33
+ // A lock outlives its holder. The duty (./service.ts) frees the locks whose
34
+ // holder is not a session in this graph, at the one moment there is a reliable
35
+ // answer — its process starting — so any lock the check finds appeared since then, and the
36
+ // board is misreporting who is working. The other half is the lock held by a
37
+ // transcript that ENDED: `stopped` or `failed` is a run nothing will resume,
38
+ // and its lock is a document nobody is editing that nobody else may edit.
39
+ // Neither is corruption, so both are `warn`; and a `settled` transcript is NOT
40
+ // one of them — a run between turns still holds what it holds (./reap.ts).
41
+ //
42
+ // A transcript stalls. `pending` means the model owes a turn and `running`
43
+ // means a model or a tool owes an answer; both are moments, not states to live
44
+ // in. One that has been waiting for hours means the runner died mid-turn, or
45
+ // the answer came back to a process that was gone — the transcript just stops,
46
+ // and nothing anywhere reports it. Both checks read the same rule everything
47
+ // else reads, ./status.ts, rather than a second copy of it, and neither reads a
48
+ // transcript whole: a status reads its newest part (./reach.ts), and a stall
49
+ // the newest line of each transcript owing something.
50
+
51
+ import type { Bundle, Comp, Graph } from 'jsr:@yaks/graph@0.2.36'
52
+ import { argsOf, who } from '@yaks/graph/call'
53
+ import { Refused } from '@yaks/graph/errors'
54
+ import { TOMBSTONE } from '@yaks/graph/bundle'
55
+ import { identityEid } from '@yaks/graph/identity'
56
+ import { tailTextSync } from '@yaks/file/io'
57
+ import * as systemProcess from '@yaks/process/system'
58
+ import type { Runs } from 'jsr:@yaks/graph@0.2.36/tools'
59
+ import { human } from '@yaks/id'
60
+ import { and, every, line as query, present, whole } from '@yaks/query'
61
+ import type { Finding } from 'jsr:@yaks/tools@0.2.36'
62
+ import { checked } from '@yaks/tools/check'
63
+ import { valued } from '@yaks/tools/value'
64
+ import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
65
+ import { CLAIM, SESSION } from './comp.js'
66
+ import { sessionFor, spawning } from './who.js'
67
+ import { marksOf } from './state.js'
68
+ import { entryStatus, newestOf } from './reach.js'
69
+ import { promptContext, promptHook } from './prompt.js'
70
+ import type { Options as Reading } from './service.ts'
71
+ import { listen, QUIET } from './listen.js'
72
+ import { asksOn, asksSaid } from './asks.js'
73
+
74
+ /** What a config file can set for this package: the checks' patience, and how
75
+ * the duty reads transcripts (./service.ts). */
76
+ export type Options = Reading & {
77
+ /** how long a transcript may be waiting on a turn or an answer before that
78
+ * counts as a stall rather than work in progress (default 2 hours) */
79
+ hours?: number
80
+ }
81
+
82
+ let HOURS = 2
83
+ // What a transcript owes while it stalls: a turn, or an answer.
84
+ let OWING = ['pending', 'running']
85
+
86
+ // A run nothing will resume. `settled` is left out on purpose: it means
87
+ // nothing is outstanding, not that the session is over.
88
+ let ENDED = ['stopped', 'failed']
89
+
90
+ // What only some of these tools run is imported by the tool that runs it: a
91
+ // session's hooks start and end every Claude Code session on the box, and
92
+ // none of them reads the transcript cache, writes a harness's settings or asks
93
+ // whether a managed run waits on a task. The workspace's lazy-dynamic-imports
94
+ // (deno.json) is what keeps an import written here from loading at start.
95
+ let wake = () => import('./wake.js')
96
+ let hooks = () => import('./hooks.js')
97
+ let resume = () => import('./resume.js')
98
+ let cache = () => import('./cache.js')
99
+ let personas = () => import('@yaks/persona')
100
+ let help = () => import('./help.js')
101
+
102
+ let str = (v: unknown): string => v == null ? '' : String(v)
103
+
104
+ /** What a hook payload says, where the command line did not: the session's
105
+ * own id, the directory it started in, and the subagent the event is about,
106
+ * when it is about one (Claude Code's `agent_id`). A payload that will not
107
+ * parse says nothing, and does so quietly. */
108
+ export let hooked = (
109
+ hook: unknown,
110
+ ): { session: string; cwd: string; agent: string } => {
111
+ try {
112
+ let said = JSON.parse(str(hook)) as {
113
+ session_id?: unknown
114
+ cwd?: unknown
115
+ agent_id?: unknown
116
+ }
117
+ return {
118
+ session: str(said.session_id),
119
+ cwd: str(said.cwd),
120
+ agent: str(said.agent_id),
121
+ }
122
+ } catch {
123
+ return { session: '', cwd: '', agent: '' }
124
+ }
125
+ }
126
+
127
+ // The session this call is about, exactly as the caller wrote it: the command
128
+ // line's argument, else the one in the hook payload. Resolving it is ./who.ts's
129
+ // job — an eid, a human-readable id, or the harness's own id for the run, which
130
+ // is the only one of the three that may not exist yet.
131
+ let idIn = (args: Record<string, unknown>): string =>
132
+ str(args.session) || hooked(args.hook).session
133
+
134
+ let comp = (b: Bundle | undefined, name: string): Comp =>
135
+ (b?.[name] ?? {}) as Comp
136
+
137
+ /** What an operator session is told so its owner's mail and knocks wake it. */
138
+ export let wakes = (id: string): string =>
139
+ `Keep \`yak session listen --session ${id} --once\` running as a ` +
140
+ `background command, and start it again each time it ends, so your ` +
141
+ `owner's mail and knocks wake you. When it ends, its output is everything ` +
142
+ `that was waiting, each item whole on one line: read all of the output, ` +
143
+ `and no item needs a second command to read.`
144
+
145
+ /** One entity as a person reads it: its id, its title where it has one, and
146
+ * the answer where it is a decided question (@yaks/kernel `decided.choice`,
147
+ * the chosen label or the words of a custom answer). */
148
+ export let line = (vocab: Vocab, b: Bundle): string => {
149
+ let id = human(vocab)(b)
150
+ let title = str(comp(b, 'doc').title)
151
+ let choice = str(comp(b, 'decided').choice)
152
+ return [id, title, choice && `answered: ${choice}`].filter(Boolean)
153
+ .join(' — ')
154
+ }
155
+
156
+ /** One heading over the rows under it, each a {@link line} with the lines
157
+ * `under` keeps for it beneath. */
158
+ let section = (
159
+ vocab: Vocab,
160
+ title: string,
161
+ rows: Bundle[],
162
+ under = new Map<string, string[]>(),
163
+ ): string[] => [
164
+ `## ${title}`,
165
+ ...rows.length
166
+ ? rows.flatMap((b) => [
167
+ `- ${line(vocab, b)}`,
168
+ ...under.get(b.entity.eid) ?? [],
169
+ ])
170
+ : ['nothing'],
171
+ ]
172
+
173
+ // Under each held task, every ask on it so far (./asks.ts): a run resumed or
174
+ // compacted on it reads them again, not only the newest it heard.
175
+ let asksUnder = async (graph: Graph, held: Bundle[]) => {
176
+ let on = await asksOn(graph, held.map((b) => b.entity.eid))
177
+ return new Map(
178
+ await Promise.all(
179
+ [...on].map(async ([task, rows]) =>
180
+ [task, [
181
+ ' asked so far, oldest first:',
182
+ ...await asksSaid(graph, rows, ' '),
183
+ ]] as [string, string[]]
184
+ ),
185
+ ),
186
+ )
187
+ }
188
+
189
+ /**
190
+ * The saved queries a session is told the rows of, each as its title and its
191
+ * rows: those its persona contains (@yaks/persona `queries`) and, for an
192
+ * operator, those of the persona its project's operator wears
193
+ * (`helper{persona}`, ./routine.ts), since an operator session wears its
194
+ * checkout's common persona. Each query is run now, at delivery (M-4063), so
195
+ * a compaction summary that kept an id as open is answered by what is.
196
+ */
197
+ export let asked = async (
198
+ graph: Graph,
199
+ persona: string | undefined,
200
+ operator: boolean,
201
+ ): Promise<[string, Bundle[]][]> => {
202
+ if (!persona || !graph.vocab.comp('board')) return []
203
+ let { wearing, fold } = await personas()
204
+ let wear = (eid: string) => wearing(graph, '', { persona: eid })
205
+ let own = await wear(persona)
206
+ let lead = operator && own
207
+ ? str(
208
+ comp(
209
+ (await graph.get([str(comp(own.persona, 'persona').home)]))[0],
210
+ 'helper',
211
+ ).persona,
212
+ )
213
+ : ''
214
+ let theirs = lead && lead != persona ? await wear(lead) : undefined
215
+ let worn = own && theirs ? fold(own, theirs) : own ?? theirs
216
+ return await Promise.all((worn?.queries ?? []).map(async (b) => {
217
+ let query = str(comp(b, 'board').query)
218
+ let rows = query ? await graph.read(whole(query)) : []
219
+ let title = str(comp(b, 'doc').title) || query
220
+ return [title, await graph.get(rows.map((r) => r.entity.eid))] as [
221
+ string,
222
+ Bundle[],
223
+ ]
224
+ }))
225
+ }
226
+
227
+ // An eid a query may name: a `$alias` is a bundle the batch has yet to mint,
228
+ // and nothing in the graph refers to it.
229
+ let minted = (eid: string) => !eid.startsWith('$')
230
+
231
+ // A session's own account of itself, as the patch that records it.
232
+ let briefed = (eid: string, text: unknown): Bundle => ({
233
+ entity: { eid },
234
+ brief: { text: str(text) },
235
+ })
236
+
237
+ /** The session a lock names. */
238
+ let holderOf = (b: Bundle): string => str(comp(b, CLAIM).session)
239
+
240
+ // When an entry was written, as the kernel stamps it. A graph that stamps
241
+ // nothing has no timestamp to judge a stall by, which the check reports rather
242
+ // than passing silently.
243
+ let writtenAt = (b: Bundle): number => Date.parse(str(comp(b, 'created').at))
244
+
245
+ // The session a call speaks for: the one `--session` names, else whoever is
246
+ // asking — the actor the caller was authenticated as records which run the
247
+ // call came through.
248
+ let asking = async (call: Bundle, graph: Graph): Promise<string> => {
249
+ let said = str(argsOf(call).session)
250
+ let session = said
251
+ ? (await sessionFor(graph, said, ['session.id']))?.entity.eid
252
+ : str(who(call)?.via || who(call)?.by)
253
+ if (!session) {
254
+ throw new Refused(
255
+ said
256
+ ? `no session answers to ${said}`
257
+ : 'nobody is asking — say --session',
258
+ )
259
+ }
260
+ return session
261
+ }
262
+
263
+ /** The implementations behind the tools ./vocab.json declares. The calling
264
+ * application's vocabulary is what the checks name an entity with, and its
265
+ * options are what they judge a stall by. */
266
+ export let runs = (
267
+ host: {
268
+ vocab: Vocab
269
+ stopping?: AbortSignal
270
+ config?: { db?: string; port?: number; hostname?: string }
271
+ },
272
+ options: Options = {},
273
+ ): Runs => ({
274
+ session_cache: async (call, graph): Promise<Bundle[]> => {
275
+ let args = argsOf(call)
276
+ let value = await (await cache()).cacheRead(graph, {
277
+ from: typeof args.from == 'string' ? args.from : undefined,
278
+ until: typeof args.until == 'string' ? args.until : undefined,
279
+ session: typeof args.session == 'string' ? args.session : undefined,
280
+ requests: args.requests == true,
281
+ })
282
+ return [valued(call, value)]
283
+ },
284
+
285
+ claim_take: async (call, graph): Promise<Bundle[]> => {
286
+ let args = argsOf(call)
287
+ return [{
288
+ entity: { eid: str(args.target) },
289
+ [CLAIM]: { session: await asking(call, graph) },
290
+ }]
291
+ },
292
+
293
+ // Stays up until its process stops, or with `once` until it has said
294
+ // something and a quiet window passed with nothing new, so the call is
295
+ // `running` for as long as somebody is listening — the way `serve` is while
296
+ // it answers.
297
+ session_listen: async (call, graph): Promise<Bundle[]> => {
298
+ let args = argsOf(call)
299
+ // A command run in-process writes as its process, not as the transcript
300
+ // that ran it, so "whoever is asking" may be no session at all — and a
301
+ // listener for nobody is silent, which reads as nothing to hear.
302
+ let session = await asking(call, graph)
303
+ let [row] = await graph.get([session])
304
+ if (!row?.[SESSION]) {
305
+ throw new Refused(
306
+ 'no session is asking — say --session, for example ' +
307
+ '--session "$CLAUDE_CODE_SESSION_ID"',
308
+ )
309
+ }
310
+ await listen(graph, who(call), session, {
311
+ out: (line) => console.log(line),
312
+ every: 1000 * (Number(args.every) || 2),
313
+ once: args.once == true,
314
+ quiet: args.quiet == null ? QUIET : 1000 * (Number(args.quiet) || 0),
315
+ stop: host.stopping,
316
+ })
317
+ return []
318
+ },
319
+
320
+ claim_release: (call): Bundle[] => [{
321
+ entity: { eid: str(argsOf(call).target) },
322
+ [CLAIM]: null,
323
+ }],
324
+
325
+ session_brief: async (call, graph): Promise<Bundle[]> => {
326
+ let args = argsOf(call)
327
+ let id = idIn(args)
328
+ if (!id) return [briefed(await asking(call, graph), args.text)]
329
+ let s = await sessionFor(graph, id, ['session.id'])
330
+ // A transcript nobody has created yet is created here, carrying its own
331
+ // name, the way `session_context` reifies one. Never on the word the
332
+ // caller typed: `--session S-37703` is a human id, not an eid, and taking
333
+ // it for one mints an entity whose eid is `S-37703` (./who.ts is what
334
+ // tells the two apart).
335
+ return [
336
+ s ? briefed(s.entity.eid, args.text) : {
337
+ ...briefed('$session', args.text),
338
+ [SESSION]: { id },
339
+ },
340
+ ]
341
+ },
342
+
343
+ // A hand-up is the caller's own knock: the door writes what this returns
344
+ // through the session that asked, and that is what makes it one
345
+ // (./routine.ts).
346
+ session_handup: async (call, graph): Promise<Bundle[]> => {
347
+ let args = argsOf(call)
348
+ let session = str(who(call)?.via)
349
+ let knock = session
350
+ ? await (await help()).handed(
351
+ graph,
352
+ session,
353
+ str(args.about),
354
+ str(args.text),
355
+ )
356
+ : undefined
357
+ if (!knock) {
358
+ throw new Refused(
359
+ 'a hand-up goes to the operator of the project a session works ' +
360
+ 'for, and this call came through no session that works for one',
361
+ )
362
+ }
363
+ return [knock]
364
+ },
365
+
366
+ // The start of the loop: the transcript becomes an entity, and what it
367
+ // holds comes back as the prose the harness injects. Its own id and its
368
+ // locks, and deliberately nothing else — see the head of this file. The id
369
+ // is the transcript's own line in the answer (./views.ts `tile`), drawn
370
+ // from what the write landed, so a transcript created here reads as the
371
+ // number it was just given; the locks are said beneath it.
372
+ session_context: async (call, graph): Promise<Bundle[]> => {
373
+ let args = argsOf(call)
374
+ let prompt = promptHook(args.hook)
375
+ if (prompt) {
376
+ let body = promptContext(prompt, tailTextSync)
377
+ return body
378
+ ? [{
379
+ entity: { eid: '$said' },
380
+ content: { body },
381
+ output: { source: call.entity.eid },
382
+ }]
383
+ : []
384
+ }
385
+ let id = idIn(args)
386
+ if (!id) return []
387
+ // A subagent starting is a session of its own, spawned by the one the
388
+ // hook names, and written now, before its first command: a command it
389
+ // runs in its worktree speaks for it (@yaks/cli `via`), and a call it
390
+ // makes through the MCP tools is heard as its own (./announce.ts).
391
+ let agent = hooked(args.hook).agent
392
+ if (agent) return (await spawning(graph, id, agent)).rows
393
+ let found = await sessionFor(graph, id, [
394
+ 'session.id',
395
+ 'session.operator',
396
+ 'session.persona',
397
+ ])
398
+ let actor = str(args.actor)
399
+ let eid = found?.entity.eid ?? '$session'
400
+ // A session wearing no persona wears the one its checkout carries, which
401
+ // is the one its instruction files say: that is the project it works for
402
+ // (./listen.ts).
403
+ let worn = !str(comp(found, SESSION).persona) &&
404
+ graph.vocab.prop(SESSION, 'persona') &&
405
+ await (await personas()).carried(graph, hooked(args.hook).cwd)
406
+ let persona = worn ? worn.persona.entity.eid : undefined
407
+ // A fresh transcript holds nothing: it has no entity yet, so nothing in
408
+ // the graph can name it as a holder.
409
+ let held = minted(eid)
410
+ ? await graph.read(query`.${CLAIM}.session=${eid}&*`)
411
+ : []
412
+ let operator = comp(found, SESSION).operator == true
413
+ let told = await asked(
414
+ graph,
415
+ str(comp(found, SESSION).persona) || persona,
416
+ operator,
417
+ )
418
+ return [
419
+ // Only the difference is written back — a transcript's own properties are
420
+ // not this tool's to restate.
421
+ {
422
+ entity: { eid },
423
+ [SESSION]: {
424
+ // The id the caller typed names the transcript; it is written only
425
+ // where the transcript has none. An MCP connection is found by its
426
+ // own id (@yaks/mcp), which an eid typed here must not replace.
427
+ ...(str(comp(found, SESSION).id) ? {} : { id }),
428
+ ended: null,
429
+ ...(actor ? { actor } : {}),
430
+ ...(persona ? { persona } : {}),
431
+ },
432
+ },
433
+ {
434
+ entity: { eid: '$said' },
435
+ content: {
436
+ body: [
437
+ ...section(
438
+ host.vocab,
439
+ 'claimed',
440
+ held,
441
+ await asksUnder(graph, held),
442
+ ),
443
+ ...told.flatMap(([title, rows]) => [
444
+ '',
445
+ ...section(host.vocab, title, rows),
446
+ ]),
447
+ ...operator ? [wakes(id)] : [],
448
+ ].join('\n'),
449
+ },
450
+ output: { source: call.entity.eid },
451
+ },
452
+ ]
453
+ },
454
+
455
+ // The end of it: what the session did, and everything it was holding let go.
456
+ session_wrap: async (call, graph): Promise<Bundle[]> => {
457
+ let args = argsOf(call)
458
+ let id = idIn(args)
459
+ let s = id
460
+ ? await sessionFor(graph, id, ['session.id', 'process.pid'])
461
+ : undefined
462
+ if (!s) return []
463
+ let eid = s.entity.eid
464
+ let held = await graph.read(query`.${CLAIM}.session=${eid}`)
465
+ // A managed run keeps the task it is parked on: a dependency finishing
466
+ // runs it again, and its ending lets go of the rest (./wake.ts).
467
+ let kept = new Set<string>()
468
+ let { waits } = s.process && held.length ? await wake() : {}
469
+ for (let b of waits ? held : []) {
470
+ if (await waits!(graph, eid, b.entity.eid)) kept.add(b.entity.eid)
471
+ }
472
+ return [
473
+ { entity: { eid }, [SESSION]: { ended: true } },
474
+ ...(args.brief == null ? [] : [briefed(eid, args.brief)]),
475
+ ...held.filter((b) => !kept.has(b.entity.eid)).map((b): Bundle => ({
476
+ entity: { eid: b.entity.eid },
477
+ [CLAIM]: null,
478
+ })),
479
+ ]
480
+ },
481
+
482
+ session_open: async (call, graph): Promise<Bundle[]> => {
483
+ let args = argsOf(call)
484
+ let { openInClaude } = await resume()
485
+ let home = systemProcess.env.get('HOME') ?? '~'
486
+ let account = (str(args.account) ||
487
+ (await import('@yaks/model')).accountHome(
488
+ 'claude',
489
+ (name) => systemProcess.env.get(name),
490
+ ) || `${home}/.claude`).replace(/^~(?=\/|$)/, home)
491
+ let session = str(args.session)
492
+ let opened = await openInClaude(graph, session, {
493
+ account,
494
+ cwd: str(args.cwd) || undefined,
495
+ })
496
+ return [{
497
+ entity: { eid: '$said' },
498
+ content: {
499
+ body: [
500
+ opened.written
501
+ ? `wrote ${opened.written} lines of it into ${opened.path}`
502
+ : `${opened.path} holds all of it already`,
503
+ `resume it in Claude Code with /resume ${session}, or from a ` +
504
+ `shell: cd ${opened.cwd} && claude --resume ${session}`,
505
+ ].join('\n'),
506
+ },
507
+ output: { source: call.entity.eid },
508
+ }]
509
+ },
510
+
511
+ hooks_install: async (call, graph): Promise<Bundle[]> => {
512
+ let args = argsOf(call)
513
+ let { install, settingsPath, installed, connect, configPath } =
514
+ await hooks()
515
+ // The `yak serve` of this graph's config, where it would listen.
516
+ let server = str(args.server) ||
517
+ (await import('@yaks/api/address')).served(host.config ?? {})
518
+ let remove = !!args.remove
519
+ let yak = str(args.yak) || undefined
520
+ // Into the account named, else into every Claude Code account the graph
521
+ // knows, or this process's own where it knows none.
522
+ let claude = identityEid('provider', ['claude'])
523
+ let known = (await graph.read('.account *'))
524
+ .map((b) => b.account as { home?: string; provider?: string })
525
+ .filter((a) => a.provider == claude && a.home).map((a) => a.home!)
526
+ let home = systemProcess.env.get('HOME') ?? '~'
527
+ let accounts = args.account
528
+ ? [str(args.account).replace(/^~(?=\/|$)/, home)]
529
+ : args.path || args.config || !known.length
530
+ ? [undefined]
531
+ : known
532
+ let said = accounts.map((account) => {
533
+ let done = install(str(args.path) || settingsPath(account), {
534
+ server,
535
+ yak,
536
+ remove,
537
+ })
538
+ // The plugin carries the MCP connection where the account runs it.
539
+ let config = str(args.config) || configPath(account)
540
+ let name = connect(config, {
541
+ server,
542
+ yak,
543
+ name: str(args.name) || undefined,
544
+ remove: remove || done.plugin,
545
+ })
546
+ return installed(done, server, remove, { path: config, name })
547
+ })
548
+ return [{
549
+ entity: { eid: '$said' },
550
+ content: { body: said.join('\n\n') },
551
+ output: { source: call.entity.eid },
552
+ }]
553
+ },
554
+
555
+ claim_check: async (call, graph) => {
556
+ let id = human(host.vocab)
557
+ // Whole, since a lock is shown by the id its entity's kind gives it.
558
+ let locks = await graph.read(and(present(`${CLAIM}.session`), every()))
559
+ let holders = [...new Set(locks.map(holderOf))]
560
+ let rows = holders.length ? await graph.get(holders) : []
561
+ // A tombstoned holder is a holder that is gone: `claim.session` is declared
562
+ // `death: 'release'`, so a lock still naming one is the same leak.
563
+ let held = new Map(
564
+ rows.filter((b) => b[TOMBSTONE] == null && b[SESSION] != null)
565
+ .map((b) => [b.entity.eid, b]),
566
+ )
567
+ let over = new Map<string, string>()
568
+ for (let eid of held.keys()) {
569
+ let mark = marksOf(held.get(eid)).ended
570
+ let state = await entryStatus(graph, eid)
571
+ if (ENDED.includes(state)) over.set(eid, state)
572
+ else if (mark) over.set(eid, 'ended')
573
+ }
574
+ let found = locks.flatMap((b): Finding[] => {
575
+ let eid = holderOf(b)
576
+ let holder = held.get(eid)
577
+ if (!holder) {
578
+ return [{
579
+ level: 'warn',
580
+ text: `${id(b)} is locked by ${eid}, which this graph has no ` +
581
+ `session for — start-up frees these, so this one went since`,
582
+ }]
583
+ }
584
+ let state = over.get(eid)
585
+ return state
586
+ ? [{
587
+ level: 'warn',
588
+ text: `${id(b)} is locked by ${id(holder)}, whose transcript ` +
589
+ `${state} — nothing will resume it, and nobody else may write`,
590
+ }]
591
+ : []
592
+ })
593
+ return checked(
594
+ call.entity.eid,
595
+ 'no entity is locked by a session that is over',
596
+ found,
597
+ )
598
+ },
599
+
600
+ session_check: async (call, graph) => {
601
+ let id = human(host.vocab)
602
+ let hours = options.hours ?? HOURS
603
+ let cutoff = Date.now() - hours * 3_600_000
604
+ // The transcripts owing something, by their status (./status.ts, the
605
+ // rule everything reads), and the newest line of each alone: when it was
606
+ // written.
607
+ let owing = await graph.read(query`.${SESSION}.status=${OWING}&*`)
608
+ let newest = await Promise.all(
609
+ owing.map((s) => newestOf(graph, s.entity.eid)),
610
+ )
611
+ if (owing.length && newest.every((b) => !b || isNaN(writtenAt(b)))) {
612
+ return checked(call.entity.eid, 'no transcript has stalled', [{
613
+ level: 'warn',
614
+ text: 'this graph stamps no time on an entry, so a transcript that ' +
615
+ 'stalled cannot be told from one that is merely quiet — UNVERIFIED',
616
+ }])
617
+ }
618
+ let found = owing.flatMap((s, i): Finding[] => {
619
+ let state = str(comp(s, SESSION).status)
620
+ let at = newest[i] ? writtenAt(newest[i]) : NaN
621
+ if (isNaN(at) || at > cutoff) return []
622
+ return [{
623
+ level: 'warn',
624
+ text: `${id(s)} has been ${state} since ${
625
+ new Date(at).toISOString()
626
+ } — over ${hours}h owed ${
627
+ state == 'pending' ? 'a turn' : 'an answer'
628
+ }, with nothing appended since`,
629
+ }]
630
+ })
631
+ return checked(call.entity.eid, 'no transcript has stalled', found)
632
+ },
633
+ })
package/transcript.js ADDED
@@ -0,0 +1,34 @@
1
+ // A transcript's entries, read: what a page or a door showing a session reads,
2
+ // apart from the loop that runs one (./react.ts).
3
+ import { line, sub } from "@yaks/query";
4
+ import { ENTRY, FORK } from "./native.js";
5
+ import { ordered, seqOf } from "./state.js";
6
+ import { UnknownSession } from "./unknown.js";
7
+ let comp = (b, name)=>b[name];
8
+ /** A transcript's entries: a fork's prefix from its parent up to the anchor,
9
+ * then its own, in order. With `since`, read entries created at or after that
10
+ * instant. */ export let transcript = async (g, session, since)=>{
11
+ let [self] = await g.read(line`.entity.eid=${session}&.session&.fields=${[
12
+ 'entity.eid',
13
+ ...g.vocab.comp(FORK) ? [
14
+ `${FORK}.from`
15
+ ] : []
16
+ ]}`);
17
+ if (!self) throw new UnknownSession(session);
18
+ let own = await g.read(line`.${ENTRY}.session=${session}${sub(since == null ? line`` : line`&.created.at>=${since}`)}&*`);
19
+ let from = comp(self, FORK)?.from;
20
+ if (!from) return ordered(own);
21
+ let [anchor] = await g.get([
22
+ String(from)
23
+ ], [
24
+ ENTRY
25
+ ]);
26
+ let parent = anchor && comp(anchor, ENTRY);
27
+ if (!parent) return ordered(own);
28
+ let inherited = await transcript(g, String(parent.session), since);
29
+ return [
30
+ ...inherited.filter((b)=>seqOf(b) <= seqOf(anchor)),
31
+ ...ordered(own)
32
+ ];
33
+ };
34
+ //# sourceMappingURL=transcript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript.js","sources":["./transcript.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,kDAAkD;AAClD,SAAS,IAAI,EAAE,GAAG,2BAAgC;AAElD,SAAS,KAAK,EAAE,IAAI,sBAAqB;AACzC,SAAS,OAAO,EAAE,KAAK,qBAAoB;AAC3C,SAAS,cAAc,uBAAsB;AAE7C,IAAI,OAAO,CAAC,GAAW,OAAiB,CAAC,CAAC,KAAK;AAE/C;;YAEY,GACZ,OAAO,IAAI,aAAa,OACtB,GACA,SACA;EAEA,IAAI,CAAC,KAAK,GAAG,MAAM,EAAE,IAAI,CACvB,IAAI,CAAC,YAAY,EAAE,QAAQ,kBAAkB,EAAE;IAC7C;OACG,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ;MAAC,GAAG,KAAK,KAAK,CAAC;KAAC,GAAG,EAAE;GAC9C,CAAC,CAAC;EAEL,IAAI,CAAC,MAAM,MAAM,IAAI,eAAe;EACpC,IAAI,MAAM,MAAM,EAAE,IAAI,CACpB,IAAI,CAAC,CAAC,EAAE,MAAM,SAAS,EAAE,QAAQ,EAC/B,IAAI,SAAS,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAC1D,EAAE,CAAC;EAEN,IAAI,OAAO,KAAK,MAAM,OAAO;EAC7B,IAAI,CAAC,MAAM,OAAO,QAAQ;EAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO;GAAM,EAAE;IAAC;GAAM;EAClD,IAAI,SAAS,UAAU,KAAK,QAAQ;EACpC,IAAI,CAAC,QAAQ,OAAO,QAAQ;EAC5B,IAAI,YAAY,MAAM,WAAW,GAAG,OAAO,OAAO,OAAO,GAAG;EAC5D,OAAO;OACF,UAAU,MAAM,CAAC,CAAC,IAAM,MAAM,MAAM,MAAM;OAC1C,QAAQ;GACZ;AACH,EAAC"}