@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.
- package/LICENSE +202 -0
- package/README.md +1392 -2
- package/_dist/admission.d.ts +15 -0
- package/_dist/admission.d.ts.map +1 -0
- package/_dist/announce.d.ts +17 -0
- package/_dist/announce.d.ts.map +1 -0
- package/_dist/answer.d.ts +200 -0
- package/_dist/answer.d.ts.map +1 -0
- package/_dist/append.d.ts +10 -0
- package/_dist/append.d.ts.map +1 -0
- package/_dist/archive.d.ts +6 -0
- package/_dist/archive.d.ts.map +1 -0
- package/_dist/asks.d.ts +11 -0
- package/_dist/asks.d.ts.map +1 -0
- package/_dist/audit.d.ts +15 -0
- package/_dist/audit.d.ts.map +1 -0
- package/_dist/bounce.d.ts +19 -0
- package/_dist/bounce.d.ts.map +1 -0
- package/_dist/bus.d.ts +8 -0
- package/_dist/bus.d.ts.map +1 -0
- package/_dist/cache.d.ts +45 -0
- package/_dist/cache.d.ts.map +1 -0
- package/_dist/child-notice.d.ts +6 -0
- package/_dist/child-notice.d.ts.map +1 -0
- package/_dist/children.d.ts +59 -0
- package/_dist/children.d.ts.map +1 -0
- package/_dist/cli.d.ts +8 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/comp.d.ts +9 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/compact.d.ts +19 -0
- package/_dist/compact.d.ts.map +1 -0
- package/_dist/conversation.d.ts +158 -0
- package/_dist/conversation.d.ts.map +1 -0
- package/_dist/cost.d.ts +13 -0
- package/_dist/cost.d.ts.map +1 -0
- package/_dist/deferred.d.ts +79 -0
- package/_dist/deferred.d.ts.map +1 -0
- package/_dist/ended.d.ts +27 -0
- package/_dist/ended.d.ts.map +1 -0
- package/_dist/files.d.ts +73 -0
- package/_dist/files.d.ts.map +1 -0
- package/_dist/fork.d.ts +23 -0
- package/_dist/fork.d.ts.map +1 -0
- package/_dist/graft.d.ts +33 -0
- package/_dist/graft.d.ts.map +1 -0
- package/_dist/graph.d.ts +14 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/handoff.d.ts +29 -0
- package/_dist/handoff.d.ts.map +1 -0
- package/_dist/imported.d.ts +63 -0
- package/_dist/imported.d.ts.map +1 -0
- package/_dist/intake.d.ts +43 -0
- package/_dist/intake.d.ts.map +1 -0
- package/_dist/joined.d.ts +35 -0
- package/_dist/joined.d.ts.map +1 -0
- package/_dist/lease.d.ts +21 -0
- package/_dist/lease.d.ts.map +1 -0
- package/_dist/lines.d.ts +13 -0
- package/_dist/lines.d.ts.map +1 -0
- package/_dist/mod.d.ts +107 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/naming.d.ts +10 -0
- package/_dist/naming.d.ts.map +1 -0
- package/_dist/native.d.ts +13 -0
- package/_dist/native.d.ts.map +1 -0
- package/_dist/parts.d.ts +145 -0
- package/_dist/parts.d.ts.map +1 -0
- package/_dist/plugin.d.ts +33 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/project.d.ts +67 -0
- package/_dist/project.d.ts.map +1 -0
- package/_dist/prose.d.ts +7 -0
- package/_dist/prose.d.ts.map +1 -0
- package/_dist/providers.d.ts +36 -0
- package/_dist/providers.d.ts.map +1 -0
- package/_dist/reach.d.ts +39 -0
- package/_dist/reach.d.ts.map +1 -0
- package/_dist/react.d.ts +236 -0
- package/_dist/react.d.ts.map +1 -0
- package/_dist/readers.d.ts +221 -0
- package/_dist/readers.d.ts.map +1 -0
- package/_dist/reap.d.ts +21 -0
- package/_dist/reap.d.ts.map +1 -0
- package/_dist/recall.d.ts +32 -0
- package/_dist/recall.d.ts.map +1 -0
- package/_dist/routes.d.ts +15 -0
- package/_dist/routes.d.ts.map +1 -0
- package/_dist/run.d.ts +81 -0
- package/_dist/run.d.ts.map +1 -0
- package/_dist/service.d.ts +131 -0
- package/_dist/service.d.ts.map +1 -0
- package/_dist/source.d.ts +9 -0
- package/_dist/source.d.ts.map +1 -0
- package/_dist/start.d.ts +29 -0
- package/_dist/start.d.ts.map +1 -0
- package/_dist/state.d.ts +75 -0
- package/_dist/state.d.ts.map +1 -0
- package/_dist/status.d.ts +38 -0
- package/_dist/status.d.ts.map +1 -0
- package/_dist/tail.d.ts +121 -0
- package/_dist/tail.d.ts.map +1 -0
- package/_dist/timing.d.ts +9 -0
- package/_dist/timing.d.ts.map +1 -0
- package/_dist/told.d.ts +17 -0
- package/_dist/told.d.ts.map +1 -0
- package/_dist/tools.d.ts +41 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/transcript.d.ts +5 -0
- package/_dist/transcript.d.ts.map +1 -0
- package/_dist/turn.d.ts +49 -0
- package/_dist/turn.d.ts.map +1 -0
- package/_dist/unknown.d.ts +6 -0
- package/_dist/unknown.d.ts.map +1 -0
- package/_dist/views.d.ts +9 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +9 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/wait.d.ts +15 -0
- package/_dist/wait.d.ts.map +1 -0
- package/_dist/wake.d.ts +116 -0
- package/_dist/wake.d.ts.map +1 -0
- package/_dist/watch.d.ts +52 -0
- package/_dist/watch.d.ts.map +1 -0
- package/_dist/who.d.ts +84 -0
- package/_dist/who.d.ts.map +1 -0
- package/_dist/window.d.ts +43 -0
- package/_dist/window.d.ts.map +1 -0
- package/admission.js +137 -0
- package/admission.js.map +1 -0
- package/admission.ts +164 -0
- package/announce.js +123 -0
- package/announce.js.map +1 -0
- package/announce.ts +126 -0
- package/answer.js +372 -0
- package/answer.js.map +1 -0
- package/answer.ts +426 -0
- package/append.js +125 -0
- package/append.js.map +1 -0
- package/append.ts +205 -0
- package/archive.js +62 -0
- package/archive.js.map +1 -0
- package/archive.ts +62 -0
- package/asks.js +80 -0
- package/asks.js.map +1 -0
- package/asks.ts +106 -0
- package/attempt.js +46 -0
- package/attempt.js.map +1 -0
- package/attempt.ts +60 -0
- package/audit.js +57 -0
- package/audit.js.map +1 -0
- package/audit.ts +65 -0
- package/bounce.js +29 -0
- package/bounce.js.map +1 -0
- package/bounce.ts +34 -0
- package/bus.js +568 -0
- package/bus.js.map +1 -0
- package/bus.ts +683 -0
- package/cache.js +169 -0
- package/cache.js.map +1 -0
- package/cache.ts +230 -0
- package/child-notice.js +128 -0
- package/child-notice.js.map +1 -0
- package/child-notice.ts +136 -0
- package/children.js +937 -0
- package/children.js.map +1 -0
- package/children.ts +925 -0
- package/claude-control.js +8 -0
- package/claude-control.js.map +1 -0
- package/claude-control.ts +12 -0
- package/cli.js +23 -0
- package/cli.js.map +1 -0
- package/cli.ts +28 -0
- package/comp.js +76 -0
- package/comp.js.map +1 -0
- package/comp.ts +78 -0
- package/compact.js +157 -0
- package/compact.js.map +1 -0
- package/compact.ts +209 -0
- package/compact_ask.js +280 -0
- package/compact_ask.js.map +1 -0
- package/compact_ask.ts +199 -0
- package/continue.js +131 -0
- package/continue.js.map +1 -0
- package/continue.ts +143 -0
- package/conversation.js +337 -0
- package/conversation.js.map +1 -0
- package/conversation.ts +593 -0
- package/cost.js +111 -0
- package/cost.js.map +1 -0
- package/cost.ts +93 -0
- package/deferred.js +207 -0
- package/deferred.js.map +1 -0
- package/deferred.ts +219 -0
- package/deno.json +1 -0
- package/dependencies.js +114 -0
- package/dependencies.js.map +1 -0
- package/dependencies.ts +110 -0
- package/draining.js +20 -0
- package/draining.js.map +1 -0
- package/draining.ts +26 -0
- package/ended.js +210 -0
- package/ended.js.map +1 -0
- package/ended.ts +225 -0
- package/files.js +285 -0
- package/files.js.map +1 -0
- package/files.ts +318 -0
- package/fork.js +96 -0
- package/fork.js.map +1 -0
- package/fork.ts +124 -0
- package/graft.js +97 -0
- package/graft.js.map +1 -0
- package/graft.ts +88 -0
- package/graph.js +49 -0
- package/graph.js.map +1 -0
- package/graph.ts +61 -0
- package/handoff.js +111 -0
- package/handoff.js.map +1 -0
- package/handoff.ts +147 -0
- package/help.js +432 -0
- package/help.js.map +1 -0
- package/help.ts +431 -0
- package/hooks.js +253 -0
- package/hooks.js.map +1 -0
- package/hooks.ts +333 -0
- package/imported.js +259 -0
- package/imported.js.map +1 -0
- package/imported.ts +201 -0
- package/inspect.js +353 -0
- package/inspect.js.map +1 -0
- package/inspect.ts +378 -0
- package/intake.js +115 -0
- package/intake.js.map +1 -0
- package/intake.ts +124 -0
- package/joined.js +67 -0
- package/joined.js.map +1 -0
- package/joined.ts +69 -0
- package/lease.js +146 -0
- package/lease.js.map +1 -0
- package/lease.ts +151 -0
- package/lifecycle.js +49 -0
- package/lifecycle.js.map +1 -0
- package/lifecycle.ts +46 -0
- package/lines.js +171 -0
- package/lines.js.map +1 -0
- package/lines.ts +177 -0
- package/listen.js +604 -0
- package/listen.js.map +1 -0
- package/listen.ts +976 -0
- package/log.js +78 -0
- package/log.js.map +1 -0
- package/log.ts +88 -0
- package/mod.js +107 -0
- package/mod.js.map +1 -0
- package/mod.ts +113 -0
- package/name.js +51 -0
- package/name.js.map +1 -0
- package/name.ts +84 -0
- package/naming.js +96 -0
- package/naming.js.map +1 -0
- package/naming.ts +102 -0
- package/native.js +17 -0
- package/native.js.map +1 -0
- package/native.ts +17 -0
- package/package.json +133 -4
- package/parts.js +334 -0
- package/parts.js.map +1 -0
- package/parts.ts +383 -0
- package/plugin.js +77 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +98 -0
- package/project.js +354 -0
- package/project.js.map +1 -0
- package/project.ts +407 -0
- package/prompt.js +57 -0
- package/prompt.js.map +1 -0
- package/prompt.ts +92 -0
- package/prose.js +43 -0
- package/prose.js.map +1 -0
- package/prose.ts +63 -0
- package/providers.js +279 -0
- package/providers.js.map +1 -0
- package/providers.ts +306 -0
- package/pruning.js +80 -0
- package/pruning.js.map +1 -0
- package/pruning.ts +147 -0
- package/reach.js +923 -0
- package/reach.js.map +1 -0
- package/reach.ts +1107 -0
- package/react.js +2259 -0
- package/react.js.map +1 -0
- package/react.ts +2864 -0
- package/readers.js +956 -0
- package/readers.js.map +1 -0
- package/readers.ts +1017 -0
- package/reap.js +60 -0
- package/reap.js.map +1 -0
- package/reap.ts +65 -0
- package/recall.js +67 -0
- package/recall.js.map +1 -0
- package/recall.ts +114 -0
- package/reopen.js +45 -0
- package/reopen.js.map +1 -0
- package/reopen.ts +44 -0
- package/result-entry.js +32 -0
- package/result-entry.js.map +1 -0
- package/result-entry.ts +34 -0
- package/resume.js +266 -0
- package/resume.js.map +1 -0
- package/resume.ts +283 -0
- package/routes.js +129 -0
- package/routes.js.map +1 -0
- package/routes.ts +147 -0
- package/routine.js +179 -0
- package/routine.js.map +1 -0
- package/routine.ts +191 -0
- package/run.js +932 -0
- package/run.js.map +1 -0
- package/run.ts +999 -0
- package/service.js +806 -0
- package/service.js.map +1 -0
- package/service.ts +911 -0
- package/source.js +26 -0
- package/source.js.map +1 -0
- package/source.ts +40 -0
- package/start.js +197 -0
- package/start.js.map +1 -0
- package/start.ts +214 -0
- package/state.js +247 -0
- package/state.js.map +1 -0
- package/state.ts +404 -0
- package/status.js +1222 -0
- package/status.js.map +1 -0
- package/status.ts +1555 -0
- package/status_bench.ts +50 -0
- package/statusline.js +187 -0
- package/statusline.js.map +1 -0
- package/statusline.ts +232 -0
- package/tail.js +748 -0
- package/tail.js.map +1 -0
- package/tail.ts +815 -0
- package/talk.js +58 -0
- package/talk.js.map +1 -0
- package/talk.ts +51 -0
- package/task-context.js +41 -0
- package/task-context.js.map +1 -0
- package/task-context.ts +53 -0
- package/texted.js +65 -0
- package/texted.js.map +1 -0
- package/texted.ts +65 -0
- package/timing.js +37 -0
- package/timing.js.map +1 -0
- package/timing.ts +52 -0
- package/told.js +56 -0
- package/told.js.map +1 -0
- package/told.ts +54 -0
- package/tools.js +595 -0
- package/tools.js.map +1 -0
- package/tools.ts +633 -0
- package/transcript.js +34 -0
- package/transcript.js.map +1 -0
- package/transcript.ts +41 -0
- package/turn.js +47 -0
- package/turn.js.map +1 -0
- package/turn.ts +68 -0
- package/unknown.js +8 -0
- package/unknown.js.map +1 -0
- package/unknown.ts +9 -0
- package/views.js +15 -0
- package/views.js.map +1 -0
- package/views.ts +21 -0
- package/vocab.js +24 -0
- package/vocab.js.map +1 -0
- package/vocab.json +1573 -0
- package/vocab.ts +30 -0
- package/wait.js +30 -0
- package/wait.js.map +1 -0
- package/wait.ts +45 -0
- package/wake.js +552 -0
- package/wake.js.map +1 -0
- package/wake.ts +597 -0
- package/watch.js +520 -0
- package/watch.js.map +1 -0
- package/watch.ts +596 -0
- package/who.js +309 -0
- package/who.js.map +1 -0
- package/who.ts +347 -0
- package/window.js +179 -0
- package/window.js.map +1 -0
- package/window.ts +268 -0
- package/woken.js +129 -0
- package/woken.js.map +1 -0
- 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"}
|
package/_dist/lease.d.ts
ADDED
|
@@ -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"}
|
package/_dist/lines.d.ts
ADDED
|
@@ -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"}
|
package/_dist/parts.d.ts
ADDED
|
@@ -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"}
|
package/_dist/prose.d.ts
ADDED
|
@@ -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"}
|
package/_dist/reach.d.ts
ADDED
|
@@ -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"}
|