@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/naming.ts ADDED
@@ -0,0 +1,102 @@
1
+ // The native rules: what a batch may say about a transcript, checked inside the
2
+ // transaction before anything moves.
3
+ //
4
+ // A `fork.from` names an entry that exists. A `using` names a provider and a
5
+ // model that exist. Both are references, so the vocabulary already rejects a
6
+ // dangling id at the engine on SQLite; this hook explains why in the error
7
+ // message, and works on a store with no foreign keys (@yaks/ram, a browser
8
+ // tab). A target minted in the same batch counts: the check is against the
9
+ // graph as the batch will leave it.
10
+
11
+ import { line } from '@yaks/query'
12
+ import type { Bundle, Comp, Hook } from 'jsr:@yaks/graph@0.2.36'
13
+ import { attemptState } from './attempt.js'
14
+
15
+ import { after, over } from '@yaks/fp'
16
+ import { MODEL, PROVIDER } from '@yaks/model/vocab'
17
+ import { ENTRY, FORK, USING } from './native.js'
18
+
19
+ /** A reference in one of this package's components named an entity of the
20
+ * wrong kind. */
21
+ export class Unnamed extends Error {
22
+ constructor(public comp: string, public prop: string, public eid: string) {
23
+ super(`${comp}.${prop} names ${eid}, which is not a ${prop}`)
24
+ this.name = 'Unnamed'
25
+ }
26
+ }
27
+
28
+ let ref = (b: Bundle, comp: string, prop: string) => {
29
+ let v = (b[comp] as Comp | null | undefined)?.[prop]
30
+ return v == null ? undefined : String(v)
31
+ }
32
+
33
+ // [comp, prop, eid, the component the target must have]
34
+ type Check = [string, string, string, string]
35
+
36
+ let checks = (b: Bundle): Check[] => {
37
+ let out: Check[] = []
38
+ let from = ref(b, FORK, 'from')
39
+ if (from) out.push([FORK, 'from', from, ENTRY])
40
+ let parent = ref(b, 'spawned', 'parent')
41
+ if (parent) out.push(['spawned', 'parent', parent, 'session'])
42
+ let call = ref(b, 'spawned', 'call')
43
+ if (call) out.push(['spawned', 'call', call, ENTRY])
44
+ let provider = ref(b, USING, PROVIDER)
45
+ if (provider) out.push([USING, PROVIDER, provider, PROVIDER])
46
+ let model = ref(b, USING, MODEL)
47
+ if (model) out.push([USING, MODEL, model, MODEL])
48
+ return out
49
+ }
50
+
51
+ /** The precondition: every `fork.from` is an entry; every `using.provider` is a
52
+ * provider and `using.model` a model — in the graph, or in this batch. */
53
+ const names: Hook = (bundles, tx) => {
54
+ let all = bundles.flatMap(checks)
55
+ if (!all.length) return bundles
56
+ let inBatch = (eid: string, comp: string) =>
57
+ bundles.some((b) => b.entity.eid == eid && comp in b)
58
+ let asked = all.filter(([, , eid, comp]) => !inBatch(eid, comp))
59
+ if (!asked.length) return bundles
60
+ return after(
61
+ over(asked, ([comp, prop, eid, must]) =>
62
+ after(
63
+ tx.read(line`.entity.eid=${eid}&.${must}&.fields=entity.eid`),
64
+ (found) => {
65
+ if (!found.length) throw new Unnamed(comp, prop, eid)
66
+ },
67
+ )),
68
+ () => bundles,
69
+ )
70
+ }
71
+
72
+ /** Fork boundaries cannot include mutable, unfinished provider output. */
73
+ export const naming: Hook = (bundles, tx, err) =>
74
+ after(
75
+ over(bundles.filter((b) => ref(b, FORK, 'from')), (b) => {
76
+ const from = ref(b, FORK, 'from')!
77
+ return after(tx.get([from], [ENTRY]), (rows) => {
78
+ const anchor = bundles.find((v) => v.entity.eid == from && v.entry) ??
79
+ rows[0]
80
+ const entry = anchor?.entry as Comp | undefined
81
+ if (!entry) return
82
+ return after(
83
+ tx.read(
84
+ line`.entry.session=${String(entry.session)}&.attempt&?interrupted`,
85
+ ),
86
+ (entries) => {
87
+ if (
88
+ entries.some((v) =>
89
+ attemptState(v) == 'inflight' &&
90
+ Number((v.entry as Comp)?.seq) <= Number(entry.seq)
91
+ )
92
+ ) {
93
+ throw new Error(
94
+ 'Cannot fork through an in-flight provider attempt',
95
+ )
96
+ }
97
+ },
98
+ )
99
+ })
100
+ }),
101
+ () => names(bundles, tx, err),
102
+ )
package/native.js ADDED
@@ -0,0 +1,17 @@
1
+ // The names of the transcript components (./comp.ts holds the prose and the
2
+ // document). Every kind of entry is a component stored beside `entry`: prose is
3
+ // `content{body}`, and an `output{source}` beside it records what produced it.
4
+ // `kindOf` (./status.ts) reads the kind off whichever is present.
5
+ export let FORK = 'fork';
6
+ export let ENTRY = 'entry';
7
+ export let CONTENT = 'content';
8
+ export let OUTPUT = 'output';
9
+ export let USING = 'using';
10
+ export let SENDING = 'sending';
11
+ export let ASK = 'ask';
12
+ export let CALL = 'call';
13
+ export let RESULT = 'result';
14
+ export let STOP_ENTRY = 'stop';
15
+ export let REFUSAL = 'refusal';
16
+ export let EXCEPTION = 'exception';
17
+ //# sourceMappingURL=native.js.map
package/native.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.js","sources":["./native.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,gFAAgF;AAChF,+EAA+E;AAC/E,kEAAkE;AAElE,OAAO,IAAI,OAAO,OAAM;AACxB,OAAO,IAAI,QAAQ,QAAO;AAC1B,OAAO,IAAI,UAAU,UAAS;AAC9B,OAAO,IAAI,SAAS,SAAQ;AAC5B,OAAO,IAAI,QAAQ,QAAO;AAC1B,OAAO,IAAI,UAAU,UAAS;AAC9B,OAAO,IAAI,MAAM,MAAK;AACtB,OAAO,IAAI,OAAO,OAAM;AACxB,OAAO,IAAI,SAAS,SAAQ;AAC5B,OAAO,IAAI,aAAa,OAAM;AAC9B,OAAO,IAAI,UAAU,UAAS;AAC9B,OAAO,IAAI,YAAY,YAAW"}
package/native.ts ADDED
@@ -0,0 +1,17 @@
1
+ // The names of the transcript components (./comp.ts holds the prose and the
2
+ // document). Every kind of entry is a component stored beside `entry`: prose is
3
+ // `content{body}`, and an `output{source}` beside it records what produced it.
4
+ // `kindOf` (./status.ts) reads the kind off whichever is present.
5
+
6
+ export let FORK = 'fork'
7
+ export let ENTRY = 'entry'
8
+ export let CONTENT = 'content'
9
+ export let OUTPUT = 'output'
10
+ export let USING = 'using'
11
+ export let SENDING = 'sending'
12
+ export let ASK = 'ask'
13
+ export let CALL = 'call'
14
+ export let RESULT = 'result'
15
+ export let STOP_ENTRY = 'stop'
16
+ export let REFUSAL = 'refusal'
17
+ export let EXCEPTION = 'exception'
package/package.json CHANGED
@@ -1,6 +1,135 @@
1
1
  {
2
2
  "name": "@yaks/session",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.36",
4
+ "homepage": "https://jsr.io/@yaks/session",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./_dist/mod.d.ts",
9
+ "default": "./mod.js"
10
+ },
11
+ "./vocab": {
12
+ "types": "./_dist/vocab.d.ts",
13
+ "default": "./vocab.js"
14
+ },
15
+ "./graph": {
16
+ "types": "./_dist/graph.d.ts",
17
+ "default": "./graph.js"
18
+ },
19
+ "./who": {
20
+ "types": "./_dist/who.d.ts",
21
+ "default": "./who.js"
22
+ },
23
+ "./tools": {
24
+ "types": "./_dist/tools.d.ts",
25
+ "default": "./tools.js"
26
+ },
27
+ "./views": {
28
+ "types": "./_dist/views.d.ts",
29
+ "default": "./views.js"
30
+ },
31
+ "./conversation": {
32
+ "types": "./_dist/conversation.d.ts",
33
+ "default": "./conversation.js"
34
+ },
35
+ "./prose": {
36
+ "types": "./_dist/prose.d.ts",
37
+ "default": "./prose.js"
38
+ },
39
+ "./intake": {
40
+ "types": "./_dist/intake.d.ts",
41
+ "default": "./intake.js"
42
+ },
43
+ "./service": {
44
+ "types": "./_dist/service.d.ts",
45
+ "default": "./service.js"
46
+ },
47
+ "./routes": {
48
+ "types": "./_dist/routes.d.ts",
49
+ "default": "./routes.js"
50
+ },
51
+ "./parts": {
52
+ "types": "./_dist/parts.d.ts",
53
+ "default": "./parts.js"
54
+ },
55
+ "./files": {
56
+ "types": "./_dist/files.d.ts",
57
+ "default": "./files.js"
58
+ },
59
+ "./tail": {
60
+ "types": "./_dist/tail.d.ts",
61
+ "default": "./tail.js"
62
+ },
63
+ "./status": {
64
+ "types": "./_dist/status.d.ts",
65
+ "default": "./status.js"
66
+ },
67
+ "./wait": {
68
+ "types": "./_dist/wait.d.ts",
69
+ "default": "./wait.js"
70
+ },
71
+ "./admission": {
72
+ "types": "./_dist/admission.d.ts",
73
+ "default": "./admission.js"
74
+ },
75
+ "./deferred": {
76
+ "types": "./_dist/deferred.d.ts",
77
+ "default": "./deferred.js"
78
+ },
79
+ "./cli": {
80
+ "types": "./_dist/cli.d.ts",
81
+ "default": "./cli.js"
82
+ },
83
+ "./ended": {
84
+ "types": "./_dist/ended.d.ts",
85
+ "default": "./ended.js"
86
+ },
87
+ "./transcript": {
88
+ "types": "./_dist/transcript.d.ts",
89
+ "default": "./transcript.js"
90
+ },
91
+ "./told": {
92
+ "types": "./_dist/told.d.ts",
93
+ "default": "./told.js"
94
+ },
95
+ "./turn": {
96
+ "types": "./_dist/turn.d.ts",
97
+ "default": "./turn.js"
98
+ }
99
+ },
100
+ "license": "Apache-2.0",
101
+ "dependencies": {
102
+ "@yaks/api": "0.2.36",
103
+ "@yaks/archetype": "0.2.36",
104
+ "@yaks/blob": "0.2.36",
105
+ "@yaks/claude": "0.2.36",
106
+ "@yaks/edge": "0.2.36",
107
+ "@yaks/effects": "0.2.36",
108
+ "@yaks/file": "0.2.36",
109
+ "@yaks/fp": "0.2.36",
110
+ "@yaks/graph": "0.2.36",
111
+ "@yaks/host": "0.2.36",
112
+ "@yaks/id": "0.2.36",
113
+ "@yaks/inspect": "0.2.36",
114
+ "@yaks/markdown": "0.2.36",
115
+ "@yaks/match": "0.2.36",
116
+ "@yaks/memory": "0.2.36",
117
+ "@yaks/model": "0.2.36",
118
+ "@yaks/persona": "0.2.36",
119
+ "@yaks/process": "0.2.36",
120
+ "@yaks/query": "0.2.36",
121
+ "@yaks/render": "0.2.36",
122
+ "@yaks/sql": "0.2.36",
123
+ "@yaks/task": "0.2.36",
124
+ "@yaks/text": "0.2.36",
125
+ "@yaks/tools": "0.2.36",
126
+ "@yaks/ui": "0.2.36",
127
+ "@yaks/ux": "0.2.36",
128
+ "@yaks/vocab": "0.2.36",
129
+ "@yaks/wake": "0.2.36",
130
+ "@types/react": "19.3.0",
131
+ "react": "19.3.0"
132
+ },
133
+ "description": "Represents sessions as graph transcripts, derives status from their entries, manages claims, and runs a transcript wherever its effects are worked.",
134
+ "repository": "https://github.com/yak-sh/yak.git"
135
+ }
package/parts.js ADDED
@@ -0,0 +1,334 @@
1
+ // What each model request carried, part by part. A request is sent as a fixed
2
+ // part every request of a session carries (the harness's system prompt, the
3
+ // instructions and persona, the listings of skills, tools and agents, each
4
+ // tool's schema), then the conversation since the last checkpoint. A walk
5
+ // follows a transcript in order, as the importer reads it (./tail.ts) or as
6
+ // the graph holds it, keeping both; at each request it lays them out in prompt
7
+ // order and splits the usage the provider reported across them with
8
+ // @yaks/model's `attribute`. The split goes on the request's entry as
9
+ // `context_parts{parts, entries}`. There the fixed part is one key, `fixed`;
10
+ // what it is made of is the session's `fixed{parts}`, kept once rather than
11
+ // on every request.
12
+ //
13
+ // Sizes are characters. They only weigh parts against each other: each split
14
+ // is scaled to the input the provider reported, so a request's totals are
15
+ // measured and the split across its parts is estimated. Where a log never
16
+ // shows part of what was sent (Codex's tool schemas, a native transcript read
17
+ // back from the graph), the first request's reported input says how much is
18
+ // missing, and that becomes the fixed part `unseen`.
19
+ //
20
+ // The entries a request generated are its own output, not its input: the
21
+ // output lines (what the model said, thought and called) since the last line
22
+ // that came from elsewhere (an input, a result, a notice) or the last request.
23
+ // That holds whether a log writes the request before its output (Claude Code,
24
+ // the native runner) or after it (Codex).
25
+ import { HUMAN, SHORT } from "@yaks/id";
26
+ import { and, eq, present } from "@yaks/query/core";
27
+ import { attribute } from "@yaks/model";
28
+ /** A line this large, in tokens, is named on its own as well as by its kind. */ export let BIG = 5000;
29
+ /** A new walk. `unseen` (default true) sizes what the log never shows from the
30
+ * first request; a log that shows a whole fixed part says so itself. */ export let walker = (o = {})=>({
31
+ fixed: new Map(),
32
+ changed: false,
33
+ lines: [],
34
+ own: 0,
35
+ names: o.names ?? new Map(),
36
+ calls: new Map(),
37
+ unseen: o.unseen ?? true,
38
+ ratio: o.ratio ?? 3.5
39
+ });
40
+ /** The fixed part's pieces, in order, pieces with one key added together. */ export let fixedParts = (w)=>{
41
+ let out = new Map();
42
+ for (let parts of w.fixed.values()){
43
+ for (let [k, n] of parts)out.set(k, (out.get(k) ?? 0) + n);
44
+ }
45
+ return [
46
+ ...out
47
+ ];
48
+ };
49
+ /**
50
+ * Follow what a log says about the fixed part.
51
+ *
52
+ * ```ts
53
+ * import { fix, fixedParts, walker } from '@yaks/session/parts'
54
+ * import { equal } from '@yaks/testing'
55
+ *
56
+ * let w = walker()
57
+ * fix(w, { source: 'tools', parts: [['tool Read', 10]] })
58
+ * fix(w, { source: 'skills', parts: [['skills', 5]] })
59
+ * fix(w, { source: 'skills', parts: [['skills', 2]], add: true })
60
+ * fix(w, { source: 'tools', parts: [['tool Bash', 7]] })
61
+ * equal(fixedParts(w), [['tool Bash', 7], ['skills', 7]])
62
+ * ```
63
+ */ export let fix = (w, f)=>{
64
+ w.fixed.set(f.source, [
65
+ ...f.add ? w.fixed.get(f.source) ?? [] : [],
66
+ ...f.parts
67
+ ]);
68
+ // Once a log shows the tools, nothing the fixed part holds is unseen.
69
+ if (f.source == 'tools' && !f.add && f.parts.length) {
70
+ w.unseen = false;
71
+ w.fixed.delete('unseen');
72
+ }
73
+ w.changed = true;
74
+ };
75
+ let comp = (b, name)=>b[name];
76
+ let text = (b)=>String(comp(b, 'content')?.body ?? '');
77
+ let named = (w, eid)=>w.names.get(String(eid)) ?? 'tool';
78
+ // What a line is, as a key, or nothing for an entry that is no line.
79
+ let kind = (w, b)=>b.checkpoint ? 'checkpoint' : b.call ? `call ${named(w, comp(b, 'call').to)}` : b.result ? `result ${w.calls.get(String(comp(b, 'result').call)) ?? 'tool'}` : !b.content || !text(b) ? undefined : b.reasoning ? 'reasoning' : b.output ? 'output' : b.notice ? text(b).startsWith('# AGENTS.md') ? 'instructions AGENTS.md' : 'notice' : 'input';
80
+ /**
81
+ * The entries a part is made of, as a query, where one names them: a
82
+ * `call <tool>` part is the calls to that tool and a `result <tool>` part
83
+ * their results. Every other part is no set of entries a query names, so it
84
+ * has none.
85
+ *
86
+ * ```ts
87
+ * import { partQuery } from './parts.ts'
88
+ * import { stringify } from '@yaks/query'
89
+ * import { equal } from '@yaks/testing'
90
+ *
91
+ * equal(stringify(partQuery('result Bash')!),
92
+ * '.result&.result.call.call.to.tool.name=Bash')
93
+ * equal(stringify(partQuery('call mcp__tasks__task_new')!),
94
+ * '.call&.call.to.tool.name=mcp__tasks__task_new')
95
+ * equal(partQuery('input'), undefined)
96
+ * equal(partQuery('tool Bash'), undefined)
97
+ * ```
98
+ */ export let partQuery = (key)=>{
99
+ let [, line, tool] = key.match(/^(call|result) (.+)$/) ?? [];
100
+ return line == 'call' ? and(present('call'), eq('call.to.tool.name', tool)) : line == 'result' ? and(present('result'), eq('result.call.call.to.tool.name', tool)) : undefined;
101
+ };
102
+ let generating = (key)=>key == 'output' || key == 'reasoning' || key.startsWith('call ');
103
+ let size = (b)=>text(b).length + (b.call && comp(b, 'call').args ? JSON.stringify(comp(b, 'call').args).length : 0);
104
+ let round = (p)=>p.map(Math.round);
105
+ let sum = (ps)=>ps.reduce((n, [, s])=>n + s, 0);
106
+ /**
107
+ * One request's `context_parts`: the fixed part laid out first as one part,
108
+ * then the conversation's lines, the reported input split across them by
109
+ * where each sits; a line of `BIG` tokens or more is also named on its own.
110
+ * What the request generated is reasoning, as far as the provider counted it,
111
+ * and output.
112
+ *
113
+ * ```ts
114
+ * import { contextParts } from '@yaks/session/parts'
115
+ * import { equal } from '@yaks/testing'
116
+ *
117
+ * let usage = { input_tokens: 20000, cached_tokens: 10000, output_tokens: 9, reasoning_tokens: 4 }
118
+ * equal(contextParts([['tool Read', 50]], [['result Read', 150, 'e1']], usage), {
119
+ * parts: {
120
+ * fixed: [5000, 0, 0, 0],
121
+ * 'result Read': [5000, 0, 10000, 0],
122
+ * output: [0, 0, 0, 5],
123
+ * reasoning: [0, 0, 0, 4],
124
+ * },
125
+ * entries: { e1: [5000, 0, 10000, 0] },
126
+ * })
127
+ * ```
128
+ */ export let contextParts = (fixed, lines, u)=>{
129
+ let input = u.input_tokens ?? 0;
130
+ let whole = sum(fixed) + sum(lines);
131
+ let scale = whole ? input / whole : 0;
132
+ let parts = [
133
+ [
134
+ 'fixed',
135
+ sum(fixed)
136
+ ],
137
+ ...lines.map(([k, n, eid])=>eid && n * scale >= BIG ? [
138
+ `${k}\n${eid}`,
139
+ n
140
+ ] : [
141
+ k,
142
+ n
143
+ ])
144
+ ];
145
+ let out = {};
146
+ let entries = {};
147
+ for (let [key, p] of Object.entries(attribute(u, parts))){
148
+ let [k, eid] = key.split('\n');
149
+ let at = out[k] ??= [
150
+ 0,
151
+ 0,
152
+ 0,
153
+ 0
154
+ ];
155
+ p.forEach((n, i)=>at[i] += n);
156
+ if (eid) entries[eid] = round(p);
157
+ }
158
+ let made = u.output_tokens ?? 0;
159
+ let thought = Math.min(u.reasoning_tokens ?? 0, made);
160
+ if (made - thought) (out.output ??= [
161
+ 0,
162
+ 0,
163
+ 0,
164
+ 0
165
+ ])[3] += made - thought;
166
+ if (thought) (out.reasoning ??= [
167
+ 0,
168
+ 0,
169
+ 0,
170
+ 0
171
+ ])[3] += thought;
172
+ return {
173
+ parts: Object.fromEntries(Object.entries(out).map(([k, p])=>[
174
+ k,
175
+ round(p)
176
+ ])),
177
+ ...Object.keys(entries).length ? {
178
+ entries
179
+ } : {}
180
+ };
181
+ };
182
+ // One request of a walk. What its log never showed is sized from the first.
183
+ let split = (w, u)=>{
184
+ let lines = w.lines.slice(0, w.own);
185
+ if (w.unseen) {
186
+ let missing = (u.input_tokens ?? 0) * w.ratio - sum(fixedParts(w)) - sum(lines);
187
+ if (missing > 0) {
188
+ w.fixed.set('unseen', [
189
+ [
190
+ 'unseen',
191
+ Math.round(missing)
192
+ ]
193
+ ]);
194
+ w.changed = true;
195
+ }
196
+ w.unseen = false;
197
+ }
198
+ return contextParts(fixedParts(w), lines, u);
199
+ };
200
+ /**
201
+ * Follow one entry, in transcript order, and answer what it owes: for a
202
+ * request (an entry carrying `usage`), its `context_parts`, the model where
203
+ * the request did not name one, and the session's `fixed` where the fixed
204
+ * part changed. A request named again (Claude Code writes a reply over several
205
+ * lines, each naming it) owes nothing more.
206
+ *
207
+ * ```ts
208
+ * import { fix, step, walker } from '@yaks/session/parts'
209
+ * import { equal } from '@yaks/testing'
210
+ *
211
+ * let w = walker()
212
+ * fix(w, { source: 'tools', parts: [['tool Read', 40]] })
213
+ * let e = (eid: string, c: object) => ({ entity: { eid }, entry: { session: 's' }, ...c })
214
+ * step(w, e('i', { content: { body: 'x'.repeat(40) } }))
215
+ * let [ask, session] = step(w, e('a', { ask: {}, usage: { input_tokens: 80, cached_tokens: 40, output_tokens: 3 } }))
216
+ * equal(ask.context_parts, { parts: { fixed: [40, 0, 0, 0], input: [0, 0, 40, 0], output: [0, 0, 0, 3] } })
217
+ * equal(session.fixed, { parts: { 'tool Read': 40 } })
218
+ * equal(step(w, e('a', { ask: {}, usage: { input_tokens: 80 } })), [])
219
+ * ```
220
+ */ export let step = (w, b)=>{
221
+ let eid = b.entity.eid;
222
+ if (b.tool && comp(b, 'tool')?.name) {
223
+ w.names.set(eid, String(comp(b, 'tool').name));
224
+ }
225
+ let model = comp(b, 'using')?.model ?? comp(b, 'ask')?.to;
226
+ if (model) w.model = String(model);
227
+ if (b.usage) {
228
+ if (eid == w.last) return [];
229
+ w.last = eid;
230
+ let owed = [
231
+ {
232
+ entity: {
233
+ eid
234
+ },
235
+ context_parts: split(w, b.usage),
236
+ ...b.ask && !comp(b, 'ask').to && w.model ? {
237
+ ask: {
238
+ to: w.model
239
+ }
240
+ } : {}
241
+ }
242
+ ];
243
+ let session = comp(b, 'entry')?.session;
244
+ if (w.changed && session) {
245
+ owed.push({
246
+ entity: {
247
+ eid: String(session)
248
+ },
249
+ fixed: {
250
+ parts: Object.fromEntries(fixedParts(w))
251
+ }
252
+ });
253
+ w.changed = false;
254
+ }
255
+ w.own = w.lines.length;
256
+ return owed;
257
+ }
258
+ let key = kind(w, b);
259
+ if (!key) return [];
260
+ if (b.call) w.calls.set(eid, named(w, comp(b, 'call').to));
261
+ if (b.checkpoint) w.lines = [];
262
+ w.lines.push([
263
+ key,
264
+ size(b),
265
+ eid
266
+ ]);
267
+ if (!generating(key)) w.own = w.lines.length;
268
+ return [];
269
+ };
270
+ /**
271
+ * Pieces of instruction text: a persona the graph projects is cut at each
272
+ * part it holds (`persona N-…`, `persona M-…`, `persona reads`), and the rest
273
+ * is the one piece `name`.
274
+ *
275
+ * ```ts
276
+ * import { instructionParts } from '@yaks/session/parts'
277
+ * import { equal } from '@yaks/testing'
278
+ *
279
+ * let persona = '# N-1 common\n\nhi\n\n---\n\n# M-2 a rule\n\nbe\n\n---\n\n## Reads\n\n- M-3'
280
+ * equal(instructionParts(persona).map(([k]) => k), ['persona N-1', 'persona M-2', 'persona reads'])
281
+ * equal(instructionParts('## Core\n\nbe kind'), [['instructions', 16]])
282
+ * ```
283
+ */ export let instructionParts = (body, name = 'instructions')=>{
284
+ let out = new Map();
285
+ for (let s of body.split(/\n-{3,}\n+(?=#{1,2} )/)){
286
+ let head = s.match(/^#{1,2} (\S+)/m)?.[1] ?? '';
287
+ let key = head == 'Reads' ? 'persona reads' : HUMAN.test(head) || SHORT.test(head) ? `persona ${head}` : name;
288
+ out.set(key, (out.get(key) ?? 0) + s.length);
289
+ }
290
+ return [
291
+ ...out
292
+ ];
293
+ };
294
+ /** A tool as a piece of the fixed part, sized by what declares it. */ export let toolPart = (tool)=>[
295
+ `tool ${String(tool.name ?? 'tool')}`,
296
+ JSON.stringify(tool).length
297
+ ];
298
+ /**
299
+ * A model request's items as the lines of its conversation: what was typed,
300
+ * said, called and returned, each result named by the tool its call named.
301
+ *
302
+ * ```ts
303
+ * import { itemLines } from '@yaks/session/parts'
304
+ * import { equal } from '@yaks/testing'
305
+ *
306
+ * equal(itemLines([
307
+ * { kind: 'user', text: 'hi' },
308
+ * { kind: 'call', id: 'c', name: 'Read', args: '{}' },
309
+ * { kind: 'result', id: 'c', output: 'abc' },
310
+ * ]), [['input', 2], ['call Read', 2], ['result Read', 3]])
311
+ * ```
312
+ */ export let itemLines = (items)=>{
313
+ let calls = new Map();
314
+ return items.map((i)=>i.kind == 'user' ? [
315
+ 'input',
316
+ i.text.length
317
+ ] : i.kind == 'assistant' ? [
318
+ 'output',
319
+ i.text.length
320
+ ] : i.kind == 'instruction' ? [
321
+ 'notice',
322
+ i.text.length
323
+ ] : i.kind == 'call' ? (calls.set(i.id, i.name), [
324
+ `call ${i.name}`,
325
+ i.args.length
326
+ ]) : i.kind == 'result' ? [
327
+ `result ${calls.get(i.id) ?? 'tool'}`,
328
+ i.output.length
329
+ ] : [
330
+ i.kind,
331
+ i.bytes.length
332
+ ]);
333
+ };
334
+ //# sourceMappingURL=parts.js.map
package/parts.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parts.js","sources":["./parts.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,+EAA+E;AAC/E,oEAAoE;AACpE,sEAAsE;AACtE,6EAA6E;AAC7E,4EAA4E;AAC5E,oBAAoB;AACpB,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,0EAA0E;AAC1E,8EAA8E;AAC9E,4EAA4E;AAC5E,qDAAqD;AACrD,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,0CAA0C;AAG1C,SAAS,KAAK,EAAE,KAAK,wBAA6B;AAClD,SAAS,GAAG,EAAe,EAAE,EAAE,OAAO,gCAAqC;AAC3E,SACE,SAAS,2BAMoB;AA6B/B,8EAA8E,GAC9E,OAAO,IAAI,MAAM,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