@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/continue.ts ADDED
@@ -0,0 +1,143 @@
1
+ // `/yak:continue`, the Claude Code plugin's command (plugins/yak), answered at
2
+ // the prompt hook (./routes.ts) before Claude Code asks its model anything:
3
+ // the hand-off is wanted most when that model's plan is spent. The hook
4
+ // blocks the prompt, and Claude Code shows the person the reason it gives,
5
+ // which is the answer.
6
+ //
7
+ // - `/yak:continue [provider/]model [words]` hands this conversation to that
8
+ // model in place (@yaks/harness `session_send`), which takes it over here
9
+ // and goes on from the words, or from "Continue.".
10
+ // - `/yak:continue S-12` writes another session into this Claude Code
11
+ // account (`session_open`, ./resume.ts), for `/resume` to continue here.
12
+ // - `/yak:continue` alone says how, and how much room each plan has left.
13
+
14
+ import type { Bundle, Comp, Graph } from 'jsr:@yaks/graph@0.2.36'
15
+ import type { Authenticate } from 'jsr:@yaks/api@0.2.36'
16
+ import type { Runner } from 'jsr:@yaks/tools@0.2.36'
17
+ import type { Host } from 'jsr:@yaks/host@0.2.36'
18
+ import { answerOf, faultOf, toolEid } from '@yaks/tools/result'
19
+ import { accountOf, statusLine } from './statusline.js'
20
+
21
+ /** The command, as the person types it. */
22
+ export let COMMAND = '/yak:continue'
23
+
24
+ /** What `/yak:continue` asks. */
25
+ export type Asked =
26
+ | { open: string }
27
+ | { provider?: string; model: string; text: string }
28
+ | { how: true }
29
+
30
+ /**
31
+ * What a prompt asks of `/yak:continue`, or nothing for any other prompt.
32
+ *
33
+ * ```ts
34
+ * import { continued } from './continue.ts'
35
+ * import { equal } from '@yaks/testing'
36
+ *
37
+ * equal(continued('/yak:continue codex/gpt-5.5 fix the test'),
38
+ * { provider: 'codex', model: 'gpt-5.5', text: 'fix the test' })
39
+ * equal(continued('/yak:continue gpt-5.5'), { model: 'gpt-5.5', text: 'Continue.' })
40
+ * equal(continued('/yak:continue S-12'), { open: 'S-12' })
41
+ * equal(continued('/yak:continue'), { how: true })
42
+ * equal(continued('/yak:continued'), undefined)
43
+ * ```
44
+ */
45
+ export let continued = (prompt: string): Asked | undefined => {
46
+ let said = prompt.trim()
47
+ if (said != COMMAND && !said.startsWith(COMMAND + ' ')) return undefined
48
+ let [first, ...rest] = said.slice(COMMAND.length).trim().split(/\s+/)
49
+ if (!first) return { how: true }
50
+ if (/^[A-Z]+-\d+$|^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(first)) {
51
+ return { open: first }
52
+ }
53
+ let slash = first.indexOf('/')
54
+ return {
55
+ ...slash > 0 ? { provider: first.slice(0, slash) } : {},
56
+ model: slash > 0 ? first.slice(slash + 1) : first,
57
+ text: rest.join(' ') || 'Continue.',
58
+ }
59
+ }
60
+
61
+ let HOW = `${COMMAND} [provider/]model [words] hands this conversation to ` +
62
+ `that model in yak; ${COMMAND} S-<n> brings a session here.`
63
+
64
+ type Door = {
65
+ graph: Graph
66
+ runner?: Runner
67
+ who?: Authenticate
68
+ text?: Host['text']
69
+ }
70
+
71
+ // Run a tool as the hook's caller would, and say what it answered.
72
+ let run = async (
73
+ host: Door,
74
+ request: Request,
75
+ tool: string,
76
+ args: Record<string, unknown>,
77
+ ): Promise<{ said: string; failed: boolean }> => {
78
+ if (!host.runner || !host.text) {
79
+ throw new Error(`${COMMAND} needs a tool runner and a text renderer`)
80
+ }
81
+ await host.runner.ensure([tool])
82
+ let id = crypto.randomUUID()
83
+ let actor = await host.who?.(request)
84
+ let landed = await host.runner.call({
85
+ entity: { eid: id },
86
+ call: { to: toolEid(tool), args },
87
+ ...actor ? { $actor: actor } : {},
88
+ })
89
+ let fault = faultOf(landed, id)
90
+ if (fault) {
91
+ let body = (fault.content ?? fault.doc) as Comp | undefined
92
+ return { said: String(body?.body ?? `${tool} failed`), failed: true }
93
+ }
94
+ return {
95
+ said: await host.text(answerOf(landed, id), { readOnly: false }),
96
+ failed: false,
97
+ }
98
+ }
99
+
100
+ let human = (b: Bundle | undefined) =>
101
+ b?.entity.prefix && b.entity.num
102
+ ? `${b.entity.prefix}-${b.entity.num}`
103
+ : b?.entity.eid
104
+
105
+ /** The answer to `/yak:continue` from the Claude Code session that sent
106
+ * `event`: what was done, or why not. */
107
+ export let carryOn = async (
108
+ host: Door,
109
+ request: Request,
110
+ event: Record<string, unknown>,
111
+ asked: Asked,
112
+ ): Promise<string> => {
113
+ let session = String(event.session_id ?? '')
114
+ if ('how' in asked) {
115
+ let room = await statusLine(host.graph, {
116
+ transcript_path: String(event.transcript_path ?? ''),
117
+ })
118
+ return [HOW, room].filter(Boolean).join('\n')
119
+ }
120
+ if ('open' in asked) {
121
+ let { said } = await run(host, request, 'session_open', {
122
+ session: asked.open,
123
+ in: 'claude',
124
+ ...accountOf(String(event.transcript_path ?? ''))
125
+ ? { account: accountOf(String(event.transcript_path)) }
126
+ : {},
127
+ ...typeof event.cwd == 'string' ? { cwd: event.cwd } : {},
128
+ })
129
+ return said
130
+ }
131
+ let { said, failed } = await run(host, request, 'session_send', {
132
+ session,
133
+ text: asked.text,
134
+ model: asked.model,
135
+ ...asked.provider ? { provider: asked.provider } : {},
136
+ wait: false,
137
+ })
138
+ if (failed) return said
139
+ let [row] = await host.graph.get([session])
140
+ let id = human(row)
141
+ return `${id} goes on with ${asked.model} in yak. Follow it in ` +
142
+ `\`yak session tui\`; to bring it back here, \`${COMMAND} ${id}\`.`
143
+ }
@@ -0,0 +1,337 @@
1
+ /**
2
+ * How a conversation draws its lines, wherever one is shown: a person's words
3
+ * as a bubble on their side, a reply as formatted text, each tool call as one
4
+ * short line in plain words that opens on what it asked for and what came
5
+ * back, a failure said in words with what went wrong inside a closed
6
+ * "Details", a stop, and the files that came with a line ({@link files}).
7
+ * Drawn with @yaks/ui's `Transcript`, `More`, `Pairs`, `Notice` and
8
+ * `Attachments`, so it bundles for a server, a browser and the iOS shell
9
+ * alike.
10
+ *
11
+ * Each kind of line is a {@link Kind}: a `Conversation.Line` registration
12
+ * (@yaks/render) that matches on the components an entry wears, and draws it.
13
+ * A host with words of its own (a channel's mark, a helper) puts its kinds
14
+ * ahead of {@link kinds} in its own registry; the most specific match draws
15
+ * the entry, and {@link draw} gives it to the next best when a kind passes.
16
+ * What a view draws beside a line, outside its reading column, is a kind
17
+ * registered under `Conversation.Margin` ({@link margin}): a view that loads
18
+ * none draws its lines without one. Which renderers a view loads is the list
19
+ * its registry is defined from. Which entries make a line is `joined`
20
+ * (./lines.ts), which reads no kit.
21
+ *
22
+ * @module
23
+ */ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, useContext } from "react";
24
+ import { Host } from "@yaks/markdown";
25
+ import { Attachments, Body, Logo, More, Notice, Pairs, StepLabel, Transcript } from "@yaks/ui/parts";
26
+ import { Fold } from "@yaks/ux/conversation";
27
+ import { define, resolve } from "@yaks/render";
28
+ import { parse as query } from "@yaks/query/core";
29
+ import { loadVocab } from "@yaks/vocab/runtime";
30
+ import { stepOf } from "@yaks/tools/title";
31
+ import { markdown } from "./prose.js";
32
+ export { joined } from "./joined.js";
33
+ export { markdown } from "./prose.js";
34
+ let comp = (b, name)=>b?.[name];
35
+ let body = (b)=>String(comp(b, 'content')?.body ?? '');
36
+ let cut = (text, most)=>text.length > most ? text.slice(0, most) + '…' : text;
37
+ /** What a call's arguments name an integration by: its `integration`, or the
38
+ * `connection` it attaches. */ export let integrationNamed = (args)=>[
39
+ args?.integration,
40
+ args?.connection
41
+ ].find((v)=>typeof v == 'string' && !!v);
42
+ /** How the calls read, from what names them. */ export let namer = ({ tools = {}, person, logos = {} })=>(tool, args)=>{
43
+ let step = stepOf(tools[tool] ?? {
44
+ title: 'Use a tool'
45
+ }, args, person ? {
46
+ person
47
+ } : undefined);
48
+ let named = integrationNamed(args);
49
+ return named != null && named in logos ? {
50
+ ...step,
51
+ logo: logos[named]
52
+ } : step;
53
+ };
54
+ /** The view every kind of line is registered under. */ export let LINE = 'Conversation.Line';
55
+ /** The view what a line has beside it is registered under: drawn outside
56
+ * its reading column, of the entry the line is put by (an admin's sequence
57
+ * and cost). */ export let MARGIN = 'Conversation.Margin';
58
+ // Every kind matches on which components an entry wears and on nothing they
59
+ // hold, and a vocabulary reads an undeclared name in a presence test as a
60
+ // component: kinds select the same under any vocabulary, so they need none.
61
+ let NONE = loadVocab([]);
62
+ // An entry drawn in a view by the most specific kind registered under it
63
+ // that draws it.
64
+ let drawn = (view, registry, b, beside)=>{
65
+ let pool = registry;
66
+ for(;;){
67
+ let kind = resolve(pool, b, view, NONE);
68
+ if (!kind) return null;
69
+ let said = kind.draw(b, beside);
70
+ if (said !== undefined) return said;
71
+ pool = {
72
+ ...pool,
73
+ renderers: pool.renderers.filter((k)=>k != kind)
74
+ };
75
+ }
76
+ };
77
+ /** An entry drawn as its line, by the most specific kind that draws it. */ export let draw = (registry, b, beside)=>drawn(LINE, registry, b, beside);
78
+ /** What the line an entry is put by has beside it, by the most specific
79
+ * margin kind that draws it; nothing where the registry loads none. */ export let margin = (registry, b, beside)=>drawn(MARGIN, registry, b, beside)?.node ?? null;
80
+ /** Where the ids in a reader's Markdown open (@yaks/markdown `Host`): `url`,
81
+ * with `{id}` where the id goes, as the reader's own server says; none, and
82
+ * ids stay words. */ export let opening = (url)=>url ? {
83
+ refs: (id)=>url.replaceAll('{id}', encodeURIComponent(id))
84
+ } : {};
85
+ /** Lines drawn with each eid their prose holds called as `ids` calls it,
86
+ * else as the page's own Host does, else as its short handle; where the page
87
+ * opens an id is the page's. */ export let called = (ids, node)=>ids && Object.keys(ids).length ? /*#__PURE__*/ h(Called, {
88
+ ids
89
+ }, node) : node;
90
+ let Called = ({ ids, children })=>{
91
+ let host = useContext(Host);
92
+ let value = {
93
+ ...host,
94
+ ids: (eid)=>ids[eid] ?? host.ids?.(eid)
95
+ };
96
+ return /*#__PURE__*/ h(Host.Provider, {
97
+ value
98
+ }, children);
99
+ };
100
+ /** A reply as it was written, in Markdown. */ export let reply = (text)=>/*#__PURE__*/ h(Transcript.Reply, {}, markdown(text));
101
+ /** A person's words, on their side, in Markdown as a reply is. `mark` sits
102
+ * before them: how they came. */ export let yours = (text, mark)=>/*#__PURE__*/ h(Transcript.Bubble, {}, mark ?? null, markdown(text));
103
+ /** What a person said who sent files and no words. */ export let unsaid = (files)=>'Attached: ' + files.map((f)=>f.name).join(', ');
104
+ /** The kinds a browser draws as a picture, never a drawing that runs (SVG). */ export let PICTURES = [
105
+ 'image/png',
106
+ 'image/jpeg',
107
+ 'image/gif',
108
+ 'image/webp'
109
+ ];
110
+ /** Whether a file is words a browser shows as they are: text, and JSON,
111
+ * XML and YAML. */ export let textual = (mime = '')=>/^text\/|^application\/(json|xml|yaml|x-yaml)$|\+(json|xml)$/.test(mime);
112
+ /** A file's kind as a person names it: its extension, else "File". */ export let fileKind = (name)=>name.match(/\.([a-z0-9]{1,5})$/i)?.[1].toUpperCase() ?? 'File';
113
+ /** A size in bytes as a person reads it. */ export let fileSize = (n)=>n < 1000 ? `${n} B` : n < 1e6 ? `${Math.round(n / 1e3)} KB` : `${(n / 1e6).toFixed(n < 1e7 ? 1 : 0)} MB`;
114
+ /** One file, as `Filed` says. */ export let Filed = ({ name, mime, href, src, width, height, size, note, remove })=>{
115
+ let away = remove ? /*#__PURE__*/ h(Attachments.Remove, {
116
+ label: `Remove ${name}`,
117
+ ...remove
118
+ }) : null;
119
+ return PICTURES.includes(mime ?? '') ? /*#__PURE__*/ h(Attachments.Picture, {
120
+ href,
121
+ target: href ? '_blank' : undefined
122
+ }, /*#__PURE__*/ h(Attachments.Image, {
123
+ src: src ?? href,
124
+ alt: name,
125
+ loading: 'lazy',
126
+ width,
127
+ height
128
+ }), away) : /*#__PURE__*/ h(Attachments.File, {
129
+ href
130
+ }, /*#__PURE__*/ h(Attachments.Kind, null, fileKind(name)), /*#__PURE__*/ h(Attachments.Name, null, name), size == null ? null : /*#__PURE__*/ h(Attachments.Size, null, fileSize(size)), note ? /*#__PURE__*/ h(Attachments.Note, null, note) : null, away);
131
+ };
132
+ /** A file opened where it is named, showing what it holds: a picture as
133
+ * itself, words in a frame of their own that loads once it is seen (from its
134
+ * `src`, a page of them, else its `href`), and any
135
+ * other file as itself, which opens it. */ export let Shown = (file)=>textual(file.mime) && file.href ? /*#__PURE__*/ h(Attachments.Frame, {
136
+ src: file.src ?? file.href,
137
+ title: file.name,
138
+ loading: 'lazy',
139
+ sandbox: ''
140
+ }) : /*#__PURE__*/ h(Attachments, null, /*#__PURE__*/ h(Filed, file));
141
+ /** A file a step read or made, named in a quiet line that opens to what it
142
+ * holds (`Shown`): "Read notes.txt". */ export let opened = (doing, file)=>step(`${doing} ${file.name}`, '', /*#__PURE__*/ h(Shown, file));
143
+ /** The files that came with a line, under it as a chat app shows them: a
144
+ * person's sit at the `end`, on their side. None draws nothing. */ export let files = (sent, mod)=>sent.length ? /*#__PURE__*/ h(Attachments, {
145
+ mod
146
+ }, sent.map((f)=>/*#__PURE__*/ h(Filed, f))) : null;
147
+ /** The one way a conversation draws anything that opens: a step, by what it
148
+ * did, opening on what it holds; `on` while it runs, `no` once it did not
149
+ * work. A fold in a fold is the same fold. Whether it is open is its line's
150
+ * fold state (@yaks/ux `Fold`), which a redrawn line keeps. */ export let step = (name, mod, ...inside)=>/*#__PURE__*/ h(Fold, {
151
+ mod: [
152
+ 'quiet',
153
+ 'step',
154
+ mod
155
+ ],
156
+ summary: /*#__PURE__*/ h(StepLabel, {}, name)
157
+ }, ...inside);
158
+ /** A {@link step} whose inside is drawn only once it is opened (@yaks/ux
159
+ * `Disclosure` `lazy`): what a model was told, say, which runs to tens of
160
+ * kilobytes a step and is rarely opened. */ export let lazyStep = (name, mod, ...inside)=>/*#__PURE__*/ h(Fold, {
161
+ mod: [
162
+ 'quiet',
163
+ 'step',
164
+ mod
165
+ ],
166
+ summary: /*#__PURE__*/ h(StepLabel, {}, name),
167
+ lazy: true
168
+ }, ...inside);
169
+ /** A value a tool was given or gave back, the way a person reads it: a list
170
+ * of what it holds under names in words, never its JSON. Bounded in depth,
171
+ * length and count, since a tool can answer with a whole file. */ export let readable = (value, depth = 0)=>{
172
+ if (typeof value == 'string' && /^\s*[[{]/.test(value)) {
173
+ try {
174
+ return readable(JSON.parse(value), depth);
175
+ } catch {
176
+ // Words that happen to start with a bracket.
177
+ }
178
+ }
179
+ if (value == null || value === '') {
180
+ return /*#__PURE__*/ h(More.Value, {}, 'Nothing');
181
+ }
182
+ if (typeof value != 'object') {
183
+ return /*#__PURE__*/ h(More.Value, {}, cut(String(value), 600));
184
+ }
185
+ if (depth > 2) return /*#__PURE__*/ h(More.Value, {}, '…');
186
+ let list = Array.isArray(value) ? value.map((v, i)=>[
187
+ String(i + 1),
188
+ v
189
+ ]) : Object.entries(value);
190
+ if (!list.length) return /*#__PURE__*/ h(More.Value, {}, 'Nothing');
191
+ let more = list.length - 12;
192
+ return /*#__PURE__*/ h(Pairs, {
193
+ mod: 'nested'
194
+ }, list.slice(0, 12).map(([k, v])=>/*#__PURE__*/ h(Pairs.Row, {}, /*#__PURE__*/ h(Pairs.Key, {}, Array.isArray(value) ? k : k.replace(/[_-]+/g, ' ').replace(/^./, (c)=>c.toUpperCase())), /*#__PURE__*/ h(Pairs.Value, {}, readable(v, depth + 1)))), more > 0 ? /*#__PURE__*/ h(Pairs.Row, {}, /*#__PURE__*/ h(Pairs.Value, {}, `and ${more} more`)) : null);
195
+ };
196
+ // An error's own words, laid out to read: JSON indented, after the status a
197
+ // provider puts before it ("400 {…}").
198
+ let laid = (detail)=>{
199
+ if (typeof detail != 'string') return JSON.stringify(detail, null, 2);
200
+ let [, head, rest] = detail.match(/^(\d{3} )?\s*([[{][\s\S]*)$/) ?? [];
201
+ if (rest == null) return detail;
202
+ try {
203
+ return (head ?? '') + JSON.stringify(JSON.parse(rest), null, 2);
204
+ } catch {
205
+ return detail;
206
+ }
207
+ };
208
+ /** The one way a conversation draws an error: what happened and what to do,
209
+ * in words, with what the error said only inside a closed "Details". */ export let trouble = (said, detail)=>/*#__PURE__*/ h(Transcript.Error, {}, /*#__PURE__*/ h(Notice, {
210
+ mod: 'negative'
211
+ }, said), detail == null || detail === '' || typeof detail == 'object' && !Object.keys(detail).length ? null : step('Details', '', /*#__PURE__*/ h(Body.Source, {
212
+ mod: 'detail'
213
+ }, laid(detail))));
214
+ // Who works the conversation, partway through a sentence and at its start.
215
+ let who = (beside)=>beside.who ?? 'the agent';
216
+ let Who = (beside)=>who(beside).replace(/^./, (c)=>c.toUpperCase());
217
+ // A step that did not work: "Tried texting Jeff".
218
+ let tried = (doing)=>'Tried ' + doing.replace(/…$/, '').replace(/^./, (c)=>c.toLowerCase());
219
+ // A tool call and, once it came back, its answer, which takes the call's
220
+ // place: what it asked for, what came back, and what `under` adds between.
221
+ let tool = (call, beside)=>{
222
+ let { result, names, under = [], came } = beside;
223
+ let c = comp(call, 'call');
224
+ let said = names(String(c.to), c.args);
225
+ let ok = result ? !comp(result, 'refusal') && !result.exception : null;
226
+ let words = ok == null ? said.doing : ok ? said.done : tried(said.doing);
227
+ let name = said.logo === undefined ? words : /*#__PURE__*/ h(Logo, {
228
+ src: said.logo ?? undefined
229
+ }, words);
230
+ let problem = `This step did not work, so ${who(beside)} went on without it.`;
231
+ return {
232
+ node: step(name, ok == null ? 'on' : ok ? '' : 'no', /*#__PURE__*/ h(More.Label, {}, 'What it asked for'), readable(c.args ?? {}), ...under, ok == null ? came ?? null : ok ? came ?? [
233
+ /*#__PURE__*/ h(More.Label, {}, 'What came back'),
234
+ readable(body(result))
235
+ ] : trouble(problem, comp(result, 'content')?.body ?? result.exception ?? comp(result, 'refusal'))),
236
+ text: ok === false ? `${words}\n\n${problem}` : undefined,
237
+ is: 'step',
238
+ ...ok ? {} : {
239
+ tone: ok == null ? 'on' : 'no'
240
+ }
241
+ };
242
+ };
243
+ // Words said in plain words. What a provider or the host said of a failure
244
+ // is never a person's to read: it is the host's tracker's (./answer.ts
245
+ // `replyOf` says it as `fault`), and the transcript keeps it for agents.
246
+ let failure = (said)=>({
247
+ node: trouble(said),
248
+ text: said
249
+ });
250
+ // A ceiling met (./state.ts `LIMIT`): said in the host's own sentence, which
251
+ // is the line's words.
252
+ let LIMIT = 'limit';
253
+ // What comes of a stop: the conversation is taken up again once its fault
254
+ // is fixed where it stalled, else the person sends again.
255
+ let after = (beside)=>beside.stalled ? 'It will be taken up again once the problem is fixed.' : 'Send your message again to try once more.';
256
+ // A provider's refusal, or the host's own ceiling in its words.
257
+ let refused = (b, beside)=>comp(b, 'refusal')?.code == LIMIT && body(b) ? {
258
+ node: reply(body(b))
259
+ } : failure(`${Who(beside)} could not get an answer from its model, so it stopped before replying. ${after(beside)}`);
260
+ let failed = (beside)=>failure(`Something went wrong, and ${who(beside)} stopped before it finished. ${after(beside)}`);
261
+ // A model's answer cut off on the way (the provider dropped it, or no longer
262
+ // held what it continued from): the turn goes on, or ends on its own line.
263
+ let interrupted = (beside)=>({
264
+ node: /*#__PURE__*/ h(Notice, {}, `${Who(beside)}'s answer was interrupted.`)
265
+ });
266
+ let stopped = ()=>({
267
+ node: /*#__PURE__*/ h(Notice, {}, 'Stopped.')
268
+ });
269
+ /** What a model said of its reasoning: a quiet step among its tool calls,
270
+ * opening on its words, so an answer never appears from nowhere. */ export let thought = (b)=>body(b).trim() ? {
271
+ node: step('Thought it through', '', markdown(body(b))),
272
+ is: 'step'
273
+ } : undefined;
274
+ /** What a transcript's kinds are that are none of the person's words. */ export let NOT_INPUT = [
275
+ 'operator_stopped',
276
+ 'output',
277
+ 'result',
278
+ 'refusal',
279
+ 'exception',
280
+ 'notice',
281
+ 'task_context',
282
+ 'failed',
283
+ 'stop',
284
+ 'interrupted',
285
+ 'call',
286
+ 'reasoning',
287
+ 'ask',
288
+ 'prompt',
289
+ 'tool_progress'
290
+ ];
291
+ /** A person's own words: an entry with words that is none of the other
292
+ * kinds. */ export let theirs = (b)=>!!comp(b, 'content')?.body && !NOT_INPUT.some((c)=>b[c]);
293
+ /** What a person wrote. A task's first input is the task itself as JSON (its
294
+ * row, and on older sessions its comments): its body is what they wrote. */ export let words = (said)=>{
295
+ if (said.startsWith('{')) {
296
+ try {
297
+ let task = JSON.parse(said).task;
298
+ let doc = task?.doc ?? task;
299
+ if (typeof doc?.body == 'string') return doc.body;
300
+ } catch {
301
+ // Not the task: words that happen to start with a brace.
302
+ }
303
+ }
304
+ return said;
305
+ };
306
+ /** A kind drawn by `draw`, matching `match` (a query of which components
307
+ * an entry wears), or any entry where it is empty: a kind of line, or under
308
+ * `view` another place a line is drawn ({@link MARGIN}). */ export let kind = (match, draw, view = LINE)=>({
309
+ view,
310
+ match: match ? query(match) : true,
311
+ draw
312
+ });
313
+ /** The kinds of line any transcript has: a tool call, a thought, a refusal,
314
+ * a reply, a failure, a stop, and a person's words, which is any entry no
315
+ * other kind draws. A model call cut off on the way (`interrupted`) draws no
316
+ * line of its own: the turn goes on from it, or a line after it says why it
317
+ * ended. */ export let kinds = define([
318
+ kind('.call', tool),
319
+ kind('.reasoning', thought),
320
+ kind('.refusal&!result', refused),
321
+ kind('.output&.notice', (_, beside)=>interrupted(beside)),
322
+ kind('.output&.exception', (_, beside)=>failed(beside)),
323
+ // Words that are only blank space (a model's break between its tool calls)
324
+ // draw nothing: no empty line with a menu between real ones.
325
+ kind('.output', (b)=>body(b).trim() ? {
326
+ node: reply(body(b))
327
+ } : undefined),
328
+ kind('.failed', (_, beside)=>failed(beside)),
329
+ kind('.exception', (_, beside)=>failed(beside)),
330
+ kind('.stop', stopped),
331
+ kind('.cancel', stopped),
332
+ kind('', (b)=>theirs(b) ? {
333
+ node: yours(words(body(b))),
334
+ is: 'theirs'
335
+ } : null)
336
+ ]);
337
+ //# sourceMappingURL=conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.js","sources":["./conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;CAsBC,GAED,uCAAuC,GAAG,SACxC,iBAAiB,CAAC,EAGlB,UAAU,gBACa;AACzB,SAAS,IAAI,8BAAiD;AAC9D,SACE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