@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
@@ -0,0 +1,35 @@
1
+ import type { Bundle } from "@yaks/render";
2
+ /** A line of a conversation: the entry it is drawn at, the result that
3
+ * answered it when that entry is a call, and how many entries in a row it
4
+ * stands for (`n`), where it stands for more than its own. */ export type Joined = {
5
+ entry: Bundle;
6
+ result?: Bundle;
7
+ n?: number;
8
+ };
9
+ /**
10
+ * Which entries make the lines of a conversation, in its order: each entry is
11
+ * a line, except a result whose call is among them, which joins that call's
12
+ * line, so an answer settles in its call's place however many calls ran
13
+ * beside it. A result whose call is not among them is a line of its own.
14
+ * Where `same` says an entry repeats the one before it (a stream telling one
15
+ * fact frame by frame), the run is one line: its last entry, counting the
16
+ * run.
17
+ *
18
+ * ```ts
19
+ * import { joined } from './joined.ts'
20
+ * import { equal } from '@yaks/testing'
21
+ * let e = (eid: string, comps = {}) => ({ entity: { eid }, entry: {}, ...comps })
22
+ * let lines = joined([
23
+ * e('c', { call: { to: 't' } }),
24
+ * e('w', { content: { body: 'Hi' } }),
25
+ * e('r', { result: { call: 'c' } }),
26
+ * e('lone', { result: { call: 'gone' } }),
27
+ * ])
28
+ * equal(lines.map((l) => [l.entry.entity.eid, l.result?.entity.eid]), [
29
+ * ['c', 'r'],
30
+ * ['w', undefined],
31
+ * ['lone', undefined],
32
+ * ])
33
+ * ```
34
+ */ export declare let joined: (entries: Bundle[], same?: (a: Bundle, b: Bundle) => boolean) => Joined[];
35
+ //# sourceMappingURL=joined.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joined.d.ts","sources":["../joined.ts"],"names":[],"mappings":"AAIA,cAAc,MAAM,4BAAiC;AAMrD;;4DAE4D,GAC5D,YAAY;EAAW,OAAO;EAAQ,SAAS;EAAQ,IAAI,MAAM;;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,YAAI,SACT,SAAS,UACT,QAAQ,GAAG,QAAQ,GAAG,WAAW,OAAO,KACvC,SAwBF"}
@@ -0,0 +1,21 @@
1
+ import type { Bundle, Eid, Graph, Hook } from "@yaks/graph";
2
+ /** What the hook needs from the application: a clock, so a test can stamp a
3
+ * fixed moment and a graph can stamp the moment it committed. */ export type LeaseOpts = {
4
+ /** the moment a new lock is stamped with (default: now, ISO-8601) */ now?: () => string;
5
+ };
6
+ /** The locks a batch takes: the entity, and the session it hands the lock to.
7
+ * A bundle that drops a lock states no take and is not here. */ export declare let takes: (bundles: Bundle[]) => [Eid, Eid][];
8
+ /** Transfer a lease in the same batch that gives its new holder work. */ export declare let handoffClaim: (on: Eid, from: Eid, to: Eid) => Bundle;
9
+ /** The relation a take leaves from its session to what it took. */ export declare let WORKED: string;
10
+ /** What `session` took, whether or not it still holds it. */ export declare let workedOn: (g: Graph, session: Eid) => Promise<Eid[]>;
11
+ /** The sessions that took any of `on`, whether or not they still hold it. */ export declare let takers: (g: Graph, on: Eid[]) => Promise<Eid[]>;
12
+ /**
13
+ * The `precondition` hook: refuse a take of a held lock without a trusted,
14
+ * guarded handoff ({@link Bounced}),
15
+ * stamp `at` on every lock the batch newly takes, and link its session
16
+ * `worked` to what it took.
17
+ *
18
+ * Registered by {@link https://jsr.io/@yaks/session/doc/~/sessions | sessions};
19
+ * exported on its own for a graph that wants the rule without the vocabulary.
20
+ */ export declare let leasing: (opts?: LeaseOpts) => Hook;
21
+ //# sourceMappingURL=lease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lease.d.ts","sources":["../lease.ts"],"names":[],"mappings":"AA6BA,cAAc,MAAM,EAAQ,GAAG,EAAE,KAAK,EAAE,IAAI,2BAAgC;AAQ5E;+DAC+D,GAC/D,YAAY;EACV,mEAAmE,GACnE,YAAY,MAAM;;AAQpB;8DAC8D,GAC9D,OAAO,YAAI,QAAS,SAAS,cAAY,KAAK,OAI1C;AAEJ,uEAAuE,GACvE,OAAO,YAAI,eAAgB,IAAI,KAAK,MAAM,KAAK,IAAI,QAAM,OAIvD;AAEF,iEAAiE,GACjE,OAAO,YAAI,eAAiB;AAkB5B,2DAA2D,GAC3D,OAAO,YAAI,WAAY,GAAG,OAAO,SAAS,QAAM,QAAQ,OAC1B;AAE9B,2EAA2E,GAC3E,OAAO,YAAI,SAAU,GAAG,OAAO,IAAI,UAAQ,QAAQ,OAA6B;AAEhF;;;;;;;;CAQC,GACD,OAAO,YAAI,UAAW,OAAM,cAAiB,KAmD5C"}
@@ -0,0 +1,13 @@
1
+ import { type Registry, type Rendering } from "@yaks/render";
2
+ /** Shared prose tree; renderers keep metadata structural rather than stripping
3
+ * text. */ export declare let entryBody: Rendering;
4
+ /** The transcript views: `Line` for an entry, `Status` for a transcript. The
5
+ * context may carry `names` (model or tool eid → name), `anchor` (reads a
6
+ * provider's anchor off an ask entry), and `entries` (the transcript, for
7
+ * `Status`), `full` (entry prose), `maxLines` and `maxChars` (bounds on that
8
+ * prose's preview). In a list
9
+ * of answers, words someone said in a transcript are a passage (`words`, the
10
+ * words sought, marks them), any other entry's `Tile` is its line, and a
11
+ * transcript's is its status as the store computed it. A transcript's `Title`
12
+ * is its name (./name.ts), read through the host's `query`. */ export declare let sessionViews: Registry;
13
+ //# sourceMappingURL=lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines.d.ts","sources":["../lines.ts"],"names":[],"mappings":"AASA,SAGE,KAAK,QAAQ,EACb,KAAK,SAAS,4BACgB;AAyChC;SACS,GACT,OAAO,YAAI,WAAW,UAqBrB;AAoED;;;;;;;;6DAQ6D,GAC7D,OAAO,YAAI,cAAc,SAqBvB"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @yaks/session — a session is a transcript: the entries that make it up, the
3
+ * lock it holds, and the runner that reacts to its newest entry. The session
4
+ * component vocabulary for a {@link https://jsr.io/@yaks/graph | @yaks/graph}.
5
+ *
6
+ * No running process is implied. A `session` is identity only; what it is doing
7
+ * is read off its entries ({@link statusOf}, and the same rule expressed in SQL
8
+ * for the derived property, {@link sessionDerived}) and never stored. An
9
+ * `entry` is one line of the transcript, `{session, seq}`, and the component
10
+ * beside it is what makes it one kind rather than another:
11
+ *
12
+ * - `content{body}` — prose. Alone it is an input, an instruction from a
13
+ * person or a system; with an `output{source}` beside it (the ask it answers)
14
+ * it is what a model returned. A `result`, `refusal` or `exception` carries its
15
+ * prose the same way.
16
+ * - `ask{to, served, through}` — the runner asked a model, from the prefix
17
+ * ending at `through`; `served` is the model that answered, where the reply
18
+ * names another (an alias answered by a release). What the provider keeps about it is the provider's own component
19
+ * on the same entry (`@yaks/openai` declares `openai{response_id}`).
20
+ * - `call{to, id, args, source}` — a tool the model asked for, from that ask;
21
+ * `result{call}` is what the tool returned.
22
+ * - `using{provider, model, effort}` — set or switched on an input, recorded
23
+ * as served on an ask.
24
+ * - `stop`, `refusal{code}`, `exception` — a stop marker; a
25
+ * deliberate no; what was thrown while producing the entry.
26
+ *
27
+ * `fork{from}` on a session continues another transcript from one of its
28
+ * entries: the parent's entries up to it are the fork's prefix.
29
+ * `spawned{parent, call}` records delegation independently of that prefix.
30
+ * {@link sessionTools} exposes fork/spawn/wait; the runner delivers a child's
31
+ * final output to its parent's queue, idempotently.
32
+ *
33
+ * ## The runner
34
+ * {@link react} is one step: read the newest entry, do the one thing it calls
35
+ * for, append what happened. {@link settle} loops it under the transcript's
36
+ * lease, and {@link running} is the `session_run` handler any @yaks/effects
37
+ * worker runs it by. It is handed a @yaks/model `Model` and a table of tools
38
+ * and imports no platform API.
39
+ *
40
+ * ## A lock is a lease, not a patch
41
+ * A `claim{session}` is a session's lock, stored on the entity it locks.
42
+ * Writing one over somebody else's fails the whole batch loudly
43
+ * ({@link Bounced}) unless the host uses a guarded {@link handoffClaim}.
44
+ * The same session re-claiming is a
45
+ * no-op refresh, and a release is unguarded, because releasing is how a lock is
46
+ * handed over. The collision is recorded as a `conflict` row on the `audit`
47
+ * phase, after the rollback. `claim.session` is declared `death: 'release'`:
48
+ * delete a session's entity and its locks go while the documents live —
49
+ * declared in {@link sessionDoc}, carried out by @yaks/graph's cascade.
50
+ * {@link reapLeases} frees every lock whose holder is not a session in the
51
+ * graph; the `@yaks/session/service` duty runs it when it starts.
52
+ *
53
+ * ```ts
54
+ * import { loadVocab } from '@yaks/vocab'
55
+ * import { graph } from '@yaks/graph'
56
+ * import { ram } from '@yaks/ram'
57
+ * import { contextDoc } from '@yaks/context'
58
+ * import { modelDoc } from '@yaks/model'
59
+ * import { toolsDoc } from '@yaks/tools'
60
+ * import { sessionDoc, sessions } from '@yaks/session'
61
+ *
62
+ * // a transcript uses four packages' components, each declared once
63
+ * let vocab = loadVocab([sessionDoc, toolsDoc, contextDoc, modelDoc])
64
+ * let g = graph({ storage: ram(vocab), vocab, plugins: [sessions()] })
65
+ * ```
66
+ *
67
+ * @module
68
+ */ export * from "./comp.js";
69
+ export * from "./bounce.js";
70
+ export * from "./lease.js";
71
+ export * from "./audit.js";
72
+ export * from "./reap.js";
73
+ export * from "./plugin.js";
74
+ export * from "./native.js";
75
+ export * from "./status.js";
76
+ export * from "./told.js";
77
+ export * from "./cost.js";
78
+ export * from "./who.js";
79
+ export * from "./naming.js";
80
+ export * from "./react.js";
81
+ export * from "./run.js";
82
+ export * from "./wake.js";
83
+ export { knocks, operatorOf, reported, watchers, writers } from "./watch.js";
84
+ export { type Opening, start, type Starting, starting } from "./start.js";
85
+ export { type Beside, RECALL, recall, type Recalling } from "./recall.js";
86
+ export { inputOf, type Intake, intake, take, taskSession } from "./intake.js";
87
+ export { admitNext } from "./admission.js";
88
+ export { kindOf, seqOf } from "./state.js";
89
+ export * from "./providers.js";
90
+ export * from "./lines.js";
91
+ export * from "./readers.js";
92
+ export * from "./children.js";
93
+ export { forkAnswer, forkProgress, forkReceipt } from "./fork.js";
94
+ export { CONTEXT, tokens as estimateTokens } from "./compact.js";
95
+ export * from "./answer.js";
96
+ export { calledIn, noticeParent, raiseNotice } from "./child-notice.js";
97
+ export { appendEntry } from "./append.js";
98
+ export { imported, type Open, pieced } from "./imported.js";
99
+ export { grafted } from "./graft.js";
100
+ export { handoff, handoffOf, touched } from "./handoff.js";
101
+ export * from "./timing.js";
102
+ export * from "./window.js";
103
+ export * from "./reach.js";
104
+ export * from "./cache.js";
105
+ export { type InputText, source } from "./source.js";
106
+ export * from "./asks.js";
107
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEC,GAED,0BAAyB;AACzB,4BAA2B;AAC3B,2BAA0B;AAC1B,2BAA0B;AAC1B,0BAAyB;AACzB,4BAA2B;AAC3B,4BAA2B;AAC3B,4BAA2B;AAC3B,0BAAyB;AACzB,0BAAyB;AACzB,yBAAwB;AACxB,4BAA2B;AAC3B,2BAA0B;AAC1B,yBAAwB;AACxB,0BAAyB;AACzB,SAAS,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,qBAAoB;AAC5E,SAAS,KAAK,OAAO,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,QAAQ,qBAAoB;AACzE,SAAS,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,SAAS,sBAAqB;AACzE,SAAS,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,sBAAqB;AAC7E,SAAS,SAAS,yBAAwB;AAC1C,SAAS,MAAM,EAAE,KAAK,qBAAoB;AAC1C,+BAA8B;AAC9B,2BAA0B;AAC1B,6BAA4B;AAE5B,8BAA6B;AAC7B,SAAS,UAAU,EAAE,YAAY,EAAE,WAAW,oBAAmB;AACjE,SAAS,OAAO,EAAE,UAAU,cAAc,uBAAsB;AAChE,4BAA2B;AAC3B,SAAS,QAAQ,EAAE,YAAY,EAAE,WAAW,4BAA2B;AAEvE,SAAS,WAAW,sBAAqB;AACzC,SAAS,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,wBAAuB;AAC3D,SAAS,OAAO,qBAAoB;AACpC,SAAS,OAAO,EAAE,SAAS,EAAE,OAAO,uBAAsB;AAC1D,4BAA2B;AAE3B,4BAA2B;AAC3B,2BAA0B;AAE1B,2BAA0B;AAE1B,SAAS,KAAK,SAAS,EAAE,MAAM,sBAAqB;AACpD,0BAAyB"}
@@ -0,0 +1,10 @@
1
+ import type { Hook } from "@yaks/graph";
2
+ /** A reference in one of this package's components named an entity of the
3
+ * wrong kind. */ export declare class Unnamed extends Error {
4
+ comp: string;
5
+ prop: string;
6
+ eid: string;
7
+ constructor(comp: string, prop: string, eid: string);
8
+ }
9
+ /** Fork boundaries cannot include mutable, unfinished provider output. */ export declare const naming: Hook;
10
+ //# sourceMappingURL=naming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"naming.d.ts","sources":["../naming.ts"],"names":[],"mappings":"AAWA,cAA4B,IAAI,2BAAgC;AAOhE;eACe,GACf,OAAO,cAAM,gBAAgB;EACR,MAAM,MAAM;EAAS,MAAM,MAAM;EAAS,KAAK,MAAM;EAAxE,YAAY,AAAO,MAAM,MAAM,EAAE,AAAO,MAAM,MAAM,EAAE,AAAO,KAAK,MAAM;AAI1E;AA8CA,wEAAwE,GACxE,OAAO,cAAM,QAAQ,KA6BlB"}
@@ -0,0 +1,13 @@
1
+ export declare let FORK: string;
2
+ export declare let ENTRY: string;
3
+ export declare let CONTENT: string;
4
+ export declare let OUTPUT: string;
5
+ export declare let USING: string;
6
+ export declare let SENDING: string;
7
+ export declare let ASK: string;
8
+ export declare let CALL: string;
9
+ export declare let RESULT: string;
10
+ export declare let STOP_ENTRY: string;
11
+ export declare let REFUSAL: string;
12
+ export declare let EXCEPTION: string;
13
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sources":["../native.ts"],"names":[],"mappings":"AAKA,OAAO,YAAI,aAAa;AACxB,OAAO,YAAI,cAAe;AAC1B,OAAO,YAAI,gBAAmB;AAC9B,OAAO,YAAI,eAAiB;AAC5B,OAAO,YAAI,cAAe;AAC1B,OAAO,YAAI,gBAAmB;AAC9B,OAAO,YAAI,YAAW;AACtB,OAAO,YAAI,aAAa;AACxB,OAAO,YAAI,eAAiB;AAC5B,OAAO,YAAI,mBAAmB;AAC9B,OAAO,YAAI,gBAAmB;AAC9B,OAAO,YAAI,kBAAuB"}
@@ -0,0 +1,145 @@
1
+ import type { Bundle, Eid } from "@yaks/graph";
2
+ import { type Clause } from "@yaks/query/core";
3
+ import { type Item, type Paid, type Part, type Tool, type Usage } from "@yaks/model";
4
+ /** What a harness's log says about the fixed part: the parts one source of it
5
+ * holds now, or, with `add`, more of them. */ export type Fixed = {
6
+ source: string;
7
+ parts: Part[];
8
+ add?: boolean;
9
+ };
10
+ /** A transcript followed so far. */ export type Walk = {
11
+ /** the fixed part, by the source each piece came from, in first-seen order */ fixed: Map<string, Part[]>;
12
+ /** whether the fixed part changed since the session last recorded it */ changed: boolean;
13
+ /** the conversation since the last checkpoint: key, size, entry */ lines: Line[];
14
+ /** where this request's own output can begin in `lines` */ own: number;
15
+ /** tool names by tool entity, and calls by entity */ names: Map<Eid, string>;
16
+ calls: Map<Eid, string>;
17
+ /** the model the transcript last asked for */ model?: string;
18
+ /** the previous request, whose later lines name it again */ last?: Eid;
19
+ /** whether part of the fixed part is yet to be sized from a request */ unseen: boolean;
20
+ /** characters per token, to size what a log never showed */ ratio: number;
21
+ };
22
+ /** A line this large, in tokens, is named on its own as well as by its kind. */ export declare let BIG: number;
23
+ /** A new walk. `unseen` (default true) sizes what the log never shows from the
24
+ * first request; a log that shows a whole fixed part says so itself. */ export declare let walker: (o?: {
25
+ unseen?: boolean;
26
+ ratio?: number;
27
+ names?: Map<Eid, string>;
28
+ }) => Walk;
29
+ /** The fixed part's pieces, in order, pieces with one key added together. */ export declare let fixedParts: (w: Walk) => Part[];
30
+ /**
31
+ * Follow what a log says about the fixed part.
32
+ *
33
+ * ```ts
34
+ * import { fix, fixedParts, walker } from '@yaks/session/parts'
35
+ * import { equal } from '@yaks/testing'
36
+ *
37
+ * let w = walker()
38
+ * fix(w, { source: 'tools', parts: [['tool Read', 10]] })
39
+ * fix(w, { source: 'skills', parts: [['skills', 5]] })
40
+ * fix(w, { source: 'skills', parts: [['skills', 2]], add: true })
41
+ * fix(w, { source: 'tools', parts: [['tool Bash', 7]] })
42
+ * equal(fixedParts(w), [['tool Bash', 7], ['skills', 7]])
43
+ * ```
44
+ */ export declare let fix: (w: Walk, f: Fixed) => void;
45
+ /**
46
+ * The entries a part is made of, as a query, where one names them: a
47
+ * `call <tool>` part is the calls to that tool and a `result <tool>` part
48
+ * their results. Every other part is no set of entries a query names, so it
49
+ * has none.
50
+ *
51
+ * ```ts
52
+ * import { partQuery } from './parts.ts'
53
+ * import { stringify } from '@yaks/query'
54
+ * import { equal } from '@yaks/testing'
55
+ *
56
+ * equal(stringify(partQuery('result Bash')!),
57
+ * '.result&.result.call.call.to.tool.name=Bash')
58
+ * equal(stringify(partQuery('call mcp__tasks__task_new')!),
59
+ * '.call&.call.to.tool.name=mcp__tasks__task_new')
60
+ * equal(partQuery('input'), undefined)
61
+ * equal(partQuery('tool Bash'), undefined)
62
+ * ```
63
+ */ export declare let partQuery: (key: string) => Clause | undefined;
64
+ /** A line of the conversation as a request carried it: its key, its size,
65
+ * and the entry it is, where it is one. */ export type Line = [key: string, size: number, eid?: Eid];
66
+ /**
67
+ * One request's `context_parts`: the fixed part laid out first as one part,
68
+ * then the conversation's lines, the reported input split across them by
69
+ * where each sits; a line of `BIG` tokens or more is also named on its own.
70
+ * What the request generated is reasoning, as far as the provider counted it,
71
+ * and output.
72
+ *
73
+ * ```ts
74
+ * import { contextParts } from '@yaks/session/parts'
75
+ * import { equal } from '@yaks/testing'
76
+ *
77
+ * let usage = { input_tokens: 20000, cached_tokens: 10000, output_tokens: 9, reasoning_tokens: 4 }
78
+ * equal(contextParts([['tool Read', 50]], [['result Read', 150, 'e1']], usage), {
79
+ * parts: {
80
+ * fixed: [5000, 0, 0, 0],
81
+ * 'result Read': [5000, 0, 10000, 0],
82
+ * output: [0, 0, 0, 5],
83
+ * reasoning: [0, 0, 0, 4],
84
+ * },
85
+ * entries: { e1: [5000, 0, 10000, 0] },
86
+ * })
87
+ * ```
88
+ */ export declare let contextParts: (fixed: Part[], lines: Line[], u: Usage) => {
89
+ parts: Record<string, Paid>;
90
+ entries?: Record<string, Paid>;
91
+ };
92
+ /**
93
+ * Follow one entry, in transcript order, and answer what it owes: for a
94
+ * request (an entry carrying `usage`), its `context_parts`, the model where
95
+ * the request did not name one, and the session's `fixed` where the fixed
96
+ * part changed. A request named again (Claude Code writes a reply over several
97
+ * lines, each naming it) owes nothing more.
98
+ *
99
+ * ```ts
100
+ * import { fix, step, walker } from '@yaks/session/parts'
101
+ * import { equal } from '@yaks/testing'
102
+ *
103
+ * let w = walker()
104
+ * fix(w, { source: 'tools', parts: [['tool Read', 40]] })
105
+ * let e = (eid: string, c: object) => ({ entity: { eid }, entry: { session: 's' }, ...c })
106
+ * step(w, e('i', { content: { body: 'x'.repeat(40) } }))
107
+ * let [ask, session] = step(w, e('a', { ask: {}, usage: { input_tokens: 80, cached_tokens: 40, output_tokens: 3 } }))
108
+ * equal(ask.context_parts, { parts: { fixed: [40, 0, 0, 0], input: [0, 0, 40, 0], output: [0, 0, 0, 3] } })
109
+ * equal(session.fixed, { parts: { 'tool Read': 40 } })
110
+ * equal(step(w, e('a', { ask: {}, usage: { input_tokens: 80 } })), [])
111
+ * ```
112
+ */ export declare let step: (w: Walk, b: Bundle) => Bundle[];
113
+ /**
114
+ * Pieces of instruction text: a persona the graph projects is cut at each
115
+ * part it holds (`persona N-…`, `persona M-…`, `persona reads`), and the rest
116
+ * is the one piece `name`.
117
+ *
118
+ * ```ts
119
+ * import { instructionParts } from '@yaks/session/parts'
120
+ * import { equal } from '@yaks/testing'
121
+ *
122
+ * 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'
123
+ * equal(instructionParts(persona).map(([k]) => k), ['persona N-1', 'persona M-2', 'persona reads'])
124
+ * equal(instructionParts('## Core\n\nbe kind'), [['instructions', 16]])
125
+ * ```
126
+ */ export declare let instructionParts: (body: string, name?: string) => Part[];
127
+ /** A tool as a piece of the fixed part, sized by what declares it. */ export declare let toolPart: (tool: Tool | {
128
+ name?: unknown;
129
+ }) => Part;
130
+ /**
131
+ * A model request's items as the lines of its conversation: what was typed,
132
+ * said, called and returned, each result named by the tool its call named.
133
+ *
134
+ * ```ts
135
+ * import { itemLines } from '@yaks/session/parts'
136
+ * import { equal } from '@yaks/testing'
137
+ *
138
+ * equal(itemLines([
139
+ * { kind: 'user', text: 'hi' },
140
+ * { kind: 'call', id: 'c', name: 'Read', args: '{}' },
141
+ * { kind: 'result', id: 'c', output: 'abc' },
142
+ * ]), [['input', 2], ['call Read', 2], ['result Read', 3]])
143
+ * ```
144
+ */ export declare let itemLines: (items: Item[]) => Line[];
145
+ //# sourceMappingURL=parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parts.d.ts","sources":["../parts.ts"],"names":[],"mappings":"AAyBA,cAAc,MAAM,EAAQ,GAAG,2BAAgC;AAE/D,SAAc,KAAK,MAAM,gCAAkD;AAC3E,SAEE,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,KAAK,2BACmB;AAE/B;4CAC4C,GAC5C,YAAY;EAAU,QAAQ,MAAM;EAAE,OAAO;EAAQ,MAAM,OAAO;;AAElE,kCAAkC,GAClC,YAAY;EACV,4EAA4E,GAC5E,OAAO,IAAI,MAAM,EAAE;EACnB,sEAAsE,GACtE,SAAS,OAAO;EAChB,iEAAiE,GACjE,OAAO;EACP,yDAAyD,GACzD,KAAK,MAAM;EACX,mDAAmD,GACnD,OAAO,IAAI,KAAK,MAAM;EACtB,OAAO,IAAI,KAAK,MAAM;EACtB,4CAA4C,GAC5C,QAAQ,MAAM;EACd,0DAA0D,GAC1D,OAAO;EACP,qEAAqE,GACrE,QAAQ,OAAO;EACf,0DAA0D,GAC1D,OAAO,MAAM;;AAGf,8EAA8E,GAC9E,OAAO,YAAI,YAAU;AAErB;sEACsE,GACtE,OAAO,YAAI,SACT;EAAK,SAAS,OAAO;EAAE,QAAQ,MAAM;EAAE,QAAQ,IAAI,KAAK,MAAM;MAC7D,KASD;AAEF,2EAA2E,GAC3E,OAAO,YAAI,aAAc,GAAG,SAAO,OAMlC;AAED;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,MAAO,GAAG,MAAM,GAAG,UAAQ,IAAI,CAWzC;AAyBD;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,YAAI,YAAa,KAAK,MAAM,KAAG,SAAS,SAAS,CAOvD;AAaD;yCACyC,GACzC,YAAY,QAAQ,KAAK,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM;AAKrD;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,YAAI,eACT,OAAO,QACP,OAAO,QACP,GAAG;EACA,OAAO,OAAO,MAAM,EAAE;EAAO,UAAU,OAAO,MAAM,EAAE;EA4B1D;AAiBD;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,YAAI,OAAQ,GAAG,MAAM,GAAG,WAAS,SAmCvC;AAED;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,mBAAoB,MAAM,MAAM,EAAE,kBAAwB,OAYpE;AAED,oEAAoE,GACpE,OAAO,YAAI,WAAY,MAAM;EAAS,OAAO,OAAO;MAAK,KAGxD;AAED;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,YAAa,OAAO,WAAS,OAevC"}
@@ -0,0 +1,33 @@
1
+ import type { Plugin } from "@yaks/graph";
2
+ import { type AuditOpts } from "./audit.js";
3
+ /** The plugin's two injection points: a clock for both stamps, and the eid a
4
+ * conflict row is minted under. */ export type SessionOpts = AuditOpts;
5
+ /**
6
+ * The session plugin: the vocabulary ({@link sessionDoc}), a `precondition`
7
+ * hook that refuses a take of a held lock, refuses a component of this
8
+ * package's that names the wrong kind of entity, and weighs a request's `cost`
9
+ * at its model's price where the provider reported none ({@link weighing}),
10
+ * and marks a knock that is a helper's to take (./routine.ts);
11
+ * an `authorize` hook that holds a write through a door's session to its own
12
+ * writer ({@link attributing});
13
+ * and an `audit` hook that records a collision after the rollback.
14
+ *
15
+ * ```ts
16
+ * import { loadVocab } from '@yaks/vocab'
17
+ * import { graph } from '@yaks/graph'
18
+ * import { ram } from '@yaks/ram'
19
+ * import { contextDoc } from '@yaks/context'
20
+ * import { modelDoc } from '@yaks/model'
21
+ * import { toolsDoc } from '@yaks/tools'
22
+ * import { sessionDoc, sessions } from '@yaks/session'
23
+ *
24
+ * // a transcript uses four packages' components, each declared once
25
+ * let vocab = loadVocab([sessionDoc, toolsDoc, contextDoc, modelDoc])
26
+ * let g = graph({ storage: ram(vocab), vocab, plugins: [sessions()] })
27
+ * ```
28
+ *
29
+ * The plugin runs nothing: it is the model and the rules. Entries appear, and
30
+ * what reacts to them is {@link react}, taken as pool work by
31
+ * {@link running} or looped by {@link settle}.
32
+ */ export declare let sessions: (opts?: SessionOpts) => Plugin;
33
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sources":["../plugin.ts"],"names":[],"mappings":"AAgBA,cAAoB,MAAM,2BAAgC;AAE1D,SAAmB,KAAK,SAAS,qBAAoB;AAOrD;iCACiC,GACjC,YAAY,cAAc;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,OAAO,YAAI,WAAY,OAAM,gBAAmB,OAwC/C"}
@@ -0,0 +1,67 @@
1
+ import type { Bundle, Eid } from "@yaks/graph";
2
+ import { type Item, type Tool as Declared } from "@yaks/model";
3
+ import { type InputText } from "./source.js";
4
+ /** What a background call (`tool_async`) answers while it runs: its interim
5
+ * result, paired with the call like any other, and saying what it means where
6
+ * the model reads it. A request derives it from the call; a call that outlasts
7
+ * its patience is also given it as an entry (`tool_progress`, ./react.ts), the
8
+ * new line that lets the model take a turn while it runs. The final arrives
9
+ * later, naming its call ({@link project}). */ export declare let PENDING: string;
10
+ /** The model's view of a window of the transcript: inputs as user turns, what
11
+ * the model returned as assistant turns, tool calls and results as the pair a
12
+ * model expects. The full transcript resolves a result's call even when that
13
+ * call is outside the window. Ask entries are our record, not the model's;
14
+ * what the anchored reply itself said and the tool calls it asked for are
15
+ * already in the provider's state, so only the calls' results travel.
16
+ *
17
+ * Each call's answer (its Pending where a request sent one, else its final)
18
+ * follows the reply's last call, in the order of the calls, whatever order
19
+ * they landed in: many models pair a result with its call by position, never
20
+ * by id (GLM's chat template renders `<tool_response>` blocks in order and
21
+ * no ids). A final whose Pending a request already sent stays where it
22
+ * landed, and names its call by tool, id and arguments.
23
+ *
24
+ * ```ts
25
+ * import { project } from './project.ts'
26
+ * let n = 0
27
+ * let e = (comps: Record<string, unknown>) =>
28
+ * ({ entity: { eid: `e${++n}` }, entry: { session: 's', seq: n }, ...comps })
29
+ * let ask = (through: string) => e({ ask: { through } })
30
+ * let call = (id: string) =>
31
+ * e({ call: { to: 'echo', id, args: { id }, source: 'e2' }, tool_async: {} })
32
+ * let tools = new Map([
33
+ * ['echo', { name: 'echo', description: 'Echoes its id.', parameters: {} }],
34
+ * ])
35
+ * let entries = [
36
+ * e({ content: { body: 'go' } }), ask('e1'), call('a'), call('b'),
37
+ * e({ result: { call: 'e4' }, content: { body: 'B' } }), // landed first
38
+ * ask('e5'), // sent b's final and a's Pending
39
+ * e({ result: { call: 'e3' }, content: { body: 'A' } }),
40
+ * ]
41
+ * project(entries, entries, tools).map((i) =>
42
+ * i.kind == 'call'
43
+ * ? i.id
44
+ * : i.kind == 'result'
45
+ * ? i.output
46
+ * : 'text' in i
47
+ * ? i.text
48
+ * : i.label
49
+ * )
50
+ * // -> ['From an unknown sender:\ngo', 'a', 'b', 'From the system:\nPending; its result will follow.', 'From the echo tool:\nB',
51
+ * // 'From the echo tool:\nThe pending echo call a {"id":"a"} finished:\nA']
52
+ * ```
53
+ */ export declare let project: (transcript: Bundle[], window: Bundle[], tools: Map<Eid, Declared>, opts?: {
54
+ anchor?: Eid;
55
+ /** The model receiving this history; inherited assistant messages name
56
+ * their original session rather than posing as this model's output. */ session?: Eid;
57
+ results?: Map<Eid, string>;
58
+ media?: Map<Eid, Item[]>;
59
+ history?: boolean;
60
+ /** Each input's prose as the model reads it, rendered for this
61
+ * transcript (react's `Deps.inputText`). */ inputText?: (entry: Bundle) => InputText;
62
+ /** The model takes one output per tool call (@yaks/model `lateResults`
63
+ * unset): a later update is told as user text. */ resultUpdatesAsUser?: boolean;
64
+ /** Collect transient prompt entries at the request tail. */ turnItems?: Item[];
65
+ /** Observe the projected items associated with a transcript entry. */ projected?: (entry: Bundle, items: Item[]) => void;
66
+ }) => Item[];
67
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sources":["../project.ts"],"names":[],"mappings":"AAKA,cAAc,MAAM,EAAQ,GAAG,2BAAgC;AAC/D,SAAS,KAAK,IAAI,EAAW,KAAK,QAAQ,QAAQ,2BAAgC;AAClF,SAAS,KAAK,SAAS,sBAA6B;AASpD;;;;;6CAK6C,GAC7C,OAAO,YAAI,gBAA4C;AA6GvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GACD,OAAO,YAAI,UACT,YAAY,UACZ,QAAQ,UACR,OAAO,IAAI,KAAK,WAChB;EACE,SAAS;EACT;yEACqE,GACrE,UAAU;EACV,UAAU,IAAI,KAAK,MAAM;EACzB,QAAQ,IAAI,KAAK;EACjB,UAAU,OAAO;EACjB;8CAC0C,GAC1C,aAAa,OAAO,WAAW;EAC/B;oDACgD,GAChD,sBAAsB,OAAO;EAC7B,0DAA0D,GAC1D,YAAY;EACZ,oEAAoE,GACpE,aAAa,OAAO,QAAQ,OAAO,WAAW,IAAI;MAEnD,OAgNF"}
@@ -0,0 +1,7 @@
1
+ /** Formatted prose for conversation replies and cards. @module */ import { type ReactElement } from "@types/react";
2
+ /** Draw Markdown in the kit's Body, with entity links supplied by the page's
3
+ * `Host` from @yaks/markdown, and a link off the page's site opening in a new
4
+ * tab (@yaks/markdown/away). A link whose address `action` picks is an act,
5
+ * such as an approval's: the kit's `Button` that does it, in a tab of its
6
+ * own. */ export declare let markdown: (text: string, _dts_1: never) => ReactElement;
7
+ //# sourceMappingURL=prose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prose.d.ts","sources":["../prose.ts"],"names":[],"mappings":"AAAA,gEAAgE,GACtB,SAGxC,KAAK,YAAY,uBAEM;AAgDzB;;;;QAIQ,GACR,OAAO,YAAI,WACT,MAAM,MAAM,EACZ,kBACC,aAAoE"}
@@ -0,0 +1,36 @@
1
+ import { type Clock } from "@yaks/fp";
2
+ import { type Bundle, type Comp, type Eid, type Graph } from "@yaks/graph";
3
+ import { type Executor, type Model } from "@yaks/model";
4
+ import type { Served } from "./react.js";
5
+ /** The resolver a runner asks with (./react.ts `Deps.resolveModel`). One
6
+ * `override` for every provider (a test's, an embedder's) still asks by the
7
+ * provider's name for the model, and still refuses a provider that does not
8
+ * serve it; a model nobody serves is asked by its own name. `clock` is the
9
+ * time its metadata cache expires by and its asks are stamped with. */ export declare let providerResolver: (g: Graph, implementations: Readonly<Record<string, Model>>, override?: Model, executorFor?: (provider: string) => Promise<Executor | undefined>, report?: (error: unknown) => void, clock?: Clock) => (using: Comp | undefined, model: Bundle) => Promise<Served>;
10
+ /** Whether this host answers a transcript asking with `using`: the provider
11
+ * it names is one this host has an implementation for, or it names none and
12
+ * the model is one a provider this host reaches serves. An `override` answers
13
+ * every provider but a command line (`transport: process`), which is
14
+ * @yaks/spawn's to launch, and a `using` naming nothing at all. A session a
15
+ * command line runs (it has a `process`) goes on there whatever a follow-up
16
+ * names, so no host answers it here; a command line's provider this host has
17
+ * an implementation for (@yaks/claude) answers a `native` session alone.
18
+ * Asked of no session, as a native call's own effect asks (./run.ts
19
+ * `session_tool`), the answer is whether this host has the provider at all.
20
+ *
21
+ * ```ts
22
+ * import { answers } from '@yaks/session'
23
+ *
24
+ * // if (await answers(graph, { openai })(using)) …
25
+ * ```
26
+ */ export declare let answers: (g: Graph, implementations: Readonly<Record<string, Model>>, override?: Model) => any;
27
+ /** Whether a managed command line owns the session's turns. This holds as
28
+ * soon as it selects a process provider and while its process is running.
29
+ *
30
+ * ```ts
31
+ * import { outside } from '@yaks/session'
32
+ *
33
+ * // if (await outside(graph, session)) return
34
+ * ```
35
+ */ export declare let outside: (g: Graph, session: Eid, using?: Comp) => Promise<boolean>;
36
+ //# sourceMappingURL=providers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.d.ts","sources":["../providers.ts"],"names":[],"mappings":"AASA,SAAS,KAAK,KAAK,wBAAqC;AAExD,SACE,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,GAAG,EACR,KAAK,KAAK,2BAEmB;AAC/B,SAEE,KAAK,QAAQ,EAEb,KAAK,KAAK,2BAKmB;AAC/B,cAAc,MAAM,qBAAoB;AAExC;;;;qEAIqE,GACrE,OAAO,YAAI,mBACT,GAAG,OACH,iBAAiB,SAAS,OAAO,MAAM,EAAE,SACzC,WAAW,OACX,eAAe,UAAU,MAAM,KAAK,QAAQ,WAAW,SAAS,GAChE,UAAU,OAAO,OAAO,KAAK,IAAI,EACjC,QAAO,WACL,OAAO,OAAO,SAAS,EAAE,OAAO,WAAW,QAAQ,QAkMtD;AAED;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,UACT,GAAG,OACH,iBAAiB,SAAS,OAAO,MAAM,EAAE,SACzC,WAAW,cAqBZ;AAMD;;;;;;;;CAQC,GACD,OAAO,YAAI,UACT,GAAG,OACH,SAAS,KACT,QAAQ,SACP,QAAQ,OAAO,EAOjB"}
@@ -0,0 +1,39 @@
1
+ import type { Bundle, Comp, Eid, Graph } from "@yaks/graph";
2
+ import { type TranscriptStatus } from "./state.js";
3
+ export type Reach = {
4
+ /** read prose too: the lines a model is sent, their bodies in hand */ bodies?: boolean;
5
+ /** a model turn: its context (checkpoint, prompts, window) is reached too,
6
+ * where the transcript owes one (it is pending); elsewhere what `call`
7
+ * reaches */ turn?: boolean;
8
+ /** a tool call: what a tool reads of the turn it came from (the prompts,
9
+ * the model selection and `sending` in force), but not the window that
10
+ * turn sent */ call?: boolean;
11
+ /** the components to read of each entry; every one but prose by default */ comps?: string[];
12
+ /** whether the model that answered an ask can continue from it
13
+ * (@yaks/model `Model.anchor`): a model turn after such an ask is sent only
14
+ * what followed it, so its reading stops there */ anchored?: (ask: Bundle) => boolean | Promise<boolean>;
15
+ };
16
+ /** What a transcript is doing, read off the entries a status looks at. The
17
+ * adapter's derived `session.status` is this rule too, but it computes it over
18
+ * every entry each time it is asked, so the cost of asking grows with the
19
+ * transcript; this reads the newest part. Besides entries, only the marks its
20
+ * row wears ({@link Marks}) bear on it: a stop observed from outside
21
+ * (`session.ended`), and a process of its own still running it. */ export declare let entryStatus: (g: Graph, session: Eid) => Promise<TranscriptStatus>;
22
+ /** The model selection in force on a transcript, as the whole of it would say. */ export declare let usingOf: (g: Graph, session: Eid) => Promise<Comp | undefined>;
23
+ /** The newest entry of a transcript, prose and all. */ export declare let newestOf: (g: Graph, session: Eid) => Promise<Bundle | undefined>;
24
+ /** Whether a transcript holds an ask. */ export declare let hasAsk: (g: Graph, session: Eid) => Promise<boolean>;
25
+ /** The first request of a transcript, prose and all: what a run was started
26
+ * with. */ export declare let firstRequest: (g: Graph, session: Eid) => Promise<Bundle | undefined>;
27
+ /** The newest request of a transcript: the one a run going on answers. */ export declare let latestRequest: (g: Graph, session: Eid) => Promise<Bundle | undefined>;
28
+ /** The first input of a transcript, prose and all: what it was first told. */ export declare let firstInput: (g: Graph, session: Eid) => Promise<Bundle | undefined>;
29
+ /** The newest receipt of a transcript: the stop that says a run ended, naming
30
+ * the request it answered (`ask.through`), or the one answering `through`. */ export declare let receiptOf: (g: Graph, session: Eid, through?: Eid) => Promise<Bundle | undefined>;
31
+ /** What a transcript said last, prose and all: its newest spoken output (not a
32
+ * call, a result, reasoning or an ending), else the newest ending that says
33
+ * why. */ export declare let saidOf: (g: Graph, session: Eid) => Promise<Bundle | undefined>;
34
+ /** The calls of a transcript no result answers. */ export declare let openOf: (g: Graph, session: Eid) => Promise<Bundle[]>;
35
+ /**
36
+ * The entries of a transcript a status or a model turn reads, in order: the
37
+ * newest ones down to where they stop mattering, and the older ones they name.
38
+ */ export declare let reach: (g: Graph, session: Eid, o?: Reach) => Promise<Bundle[]>;
39
+ //# sourceMappingURL=reach.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reach.d.ts","sources":["../reach.ts"],"names":[],"mappings":"AAqEA,cAAc,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,2BAAqC;AAO3E,SAaE,KAAK,gBAAgB,qBAEJ;AAenB,YAAY;EACV,oEAAoE,GACpE,SAAS,OAAO;EAChB;;aAEW,GACX,OAAO,OAAO;EACd;;eAEa,GACb,OAAO,OAAO;EACd,yEAAyE,GACzE,QAAQ,MAAM;EACd;;kDAEgD,GAChD,YAAY,KAAK,WAAW,OAAO,GAAG,QAAQ,OAAO;;AA6cvD;;;;;iEAKiE,GACjE,OAAO,YAAI,cACT,GAAG,OACH,SAAS,QACR,QAAQ,kBAaV;AAED,gFAAgF,GAChF,OAAO,YAAI,UACT,GAAG,OACH,SAAS,QACR,QAAQ,OAAO,SAAS,EAMxB;AAEH,qDAAqD,GACrD,OAAO,YAAI,WACT,GAAG,OACH,SAAS,QACR,QAAQ,SAAS,SAAS,EAC8B;AAE3D,uCAAuC,GACvC,OAAO,YAAI,SAAgB,GAAG,OAAO,SAAS,QAAM,QAAQ,OAAO,EACU;AA2B7E;SACS,GACT,OAAO,YAAI,eACT,GAAG,OACH,SAAS,QACR,QAAQ,SAAS,SAAS,EACkC;AAE/D,wEAAwE,GACxE,OAAO,YAAI,gBACT,GAAG,OACH,SAAS,QACR,QAAQ,SAAS,SAAS,EAC2C;AAExE,4EAA4E,GAC5E,OAAO,YAAI,aACT,GAAG,OACH,SAAS,QACR,QAAQ,SAAS,SAAS,EAI1B;AAEH;4EAC4E,GAC5E,OAAO,YAAI,YACT,GAAG,OACH,SAAS,KACT,UAAU,QACT,QAAQ,SAAS,SAAS,EAM1B;AAEH;;QAEQ,GACR,OAAO,YAAI,SACT,GAAG,OACH,SAAS,QACR,QAAQ,SAAS,SAAS,EAQ5B;AAsCD,iDAAiD,GACjD,OAAO,YAAI,SAAgB,GAAG,OAAO,SAAS,QAAM,QAAQ,UAElC;AAqV1B;;;CAGC,GACD,OAAO,YAAI,QACT,GAAG,OACH,SAAS,KACT,IAAG,UACF,QAAQ,UAQV"}