@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
package/_dist/vocab.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Vocab, VocabDoc } from "@yaks/vocab";
|
|
2
|
+
import type { Derived } from "@yaks/sql";
|
|
3
|
+
import { sessionDoc } from "./comp.js";
|
|
4
|
+
export { sessionDoc };
|
|
5
|
+
/** What this package is: its manifest's description, the one place it is
|
|
6
|
+
* written, which a host stamps on each document here. */ export declare let description: string;
|
|
7
|
+
/** Every document this plugin declares. */ export declare let docs: VocabDoc[];
|
|
8
|
+
/** A transcript's status and cost. */ export declare let derived: (vocab: Vocab) => Derived;
|
|
9
|
+
//# sourceMappingURL=vocab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.d.ts","sources":["../vocab.ts"],"names":[],"mappings":"AAWA,cAAc,KAAK,EAAE,QAAQ,2BAAgC;AAC7D,cAAc,OAAO,yBAA8B;AACnD,SAAS,UAAU,oBAAmB;AAKtC,SAAS,UAAU,GAAE;AAErB;uDACuD,GACvD,OAAO,YAAI,aAAa,MAAM,CAAuB;AAErD,yCAAyC,GACzC,OAAO,YAAI,MAAM,WAAyB;AAE1C,oCAAoC,GACpC,OAAO,YAAI,UAAW,OAAO,UAAQ,QACG"}
|
package/_dist/wait.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Clock } from "@yaks/fp";
|
|
2
|
+
import type { Graph } from "@yaks/graph";
|
|
3
|
+
/** Read initially and after committed changes, on a beat that starts at 25 ms
|
|
4
|
+
* and doubles until it is `every` (a second by default). Always yield once
|
|
5
|
+
* more on timeout or abort. Stores without revision support are read on each
|
|
6
|
+
* beat. The revision is sampled before the caller's read, so a write during
|
|
7
|
+
* that read cannot be missed. */ export declare function changes(graph: {
|
|
8
|
+
storage: Pick<Graph['storage'], 'revision'>;
|
|
9
|
+
}, options?: {
|
|
10
|
+
every?: number;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
clock?: Clock;
|
|
14
|
+
}): AsyncGenerator<boolean>;
|
|
15
|
+
//# sourceMappingURL=wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sources":["../wait.ts"],"names":[],"mappings":"AAEA,SAAS,KAAK,KAAK,wBAA4C;AAC/D,cAAc,KAAK,2BAAgC;AAMnD;;;;+BAI+B,GAC/B,OAAO,iBAAgB,QACrB;EAAS,SAAS,KAAK,MAAM,YAAY;CAAa,EACtD;EACE,QAAQ,MAAM;EACd,UAAU,MAAM;EAChB,SAAS;EACT,QAAQ;CACJ,GACL,eAAe,OAAO"}
|
package/_dist/wake.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Bundle, Eid, Graph } from "@yaks/graph";
|
|
2
|
+
/** Whether a managed run is over and was let be: its process exited cleanly
|
|
3
|
+
* and nobody asked it to stop. */ export declare let cleanEnd: (row: Bundle | undefined) => boolean;
|
|
4
|
+
/** Whether a transcript's run is over, so that a request starts its next: a
|
|
5
|
+
* native transcript has settled, and a managed one ended cleanly
|
|
6
|
+
* ({@link cleanEnd}) with its ending read in, every request it had answered;
|
|
7
|
+
* one a harness runs from its file never is. `seen` is the session's row, where the caller has read it already. */ export declare let resting: (g: Graph, session: Eid, seen?: Bundle) => Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* What a transcript was told that its last turn or run was not given: the
|
|
10
|
+
* inputs written after the entry its newest ask read through, and after its
|
|
11
|
+
* newest stop, in order. A managed run's next run is given these.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { unanswered } from '@yaks/session'
|
|
15
|
+
*
|
|
16
|
+
* // let said = await unanswered(graph, session)
|
|
17
|
+
* ```
|
|
18
|
+
*/ export declare let unanswered: (g: Graph, session: Eid) => Promise<Bundle[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Everything a transcript was told, in order: what a run that never began is
|
|
21
|
+
* given when it does.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { told } from '@yaks/session'
|
|
25
|
+
*
|
|
26
|
+
* // let said = await told(graph, session)
|
|
27
|
+
* ```
|
|
28
|
+
*/ export declare let told: (g: Graph, session: Eid) => Promise<Bundle[]>;
|
|
29
|
+
/** Whether a request waits in a transcript for its next turn or run: an input
|
|
30
|
+
* asking for one that its newest ask was not given. */ export declare let requested: (g: Graph, session: Eid) => Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Whether a task a transcript holds waits on something the transcript is to be
|
|
33
|
+
* woken for: the task is open, and a dependency of it is open or finished
|
|
34
|
+
* without the transcript having been told. A managed run that ends keeps such
|
|
35
|
+
* a claim: it is parked there.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { waits } from '@yaks/session'
|
|
39
|
+
*
|
|
40
|
+
* // if (!await waits(graph, session, task)) release it
|
|
41
|
+
* ```
|
|
42
|
+
*/ export declare let waits: (g: Graph, session: Eid, task: Eid) => Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Whether a transcript whose run is over is parked: a request waits for its
|
|
45
|
+
* next run, or a task it holds {@link waits}.
|
|
46
|
+
*/ export declare let parked: (g: Graph, session: Eid) => Promise<boolean>;
|
|
47
|
+
/** The tasks a transcript holds that {@link waits} says it is parked on. */ export declare let parkedOn: (g: Graph, session: Eid) => Promise<Bundle[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Where a transcript whose run is over stands, for a person: the tasks it is
|
|
50
|
+
* parked on and what each still waits on, or that its next run is asked for.
|
|
51
|
+
* Nothing where its run is not over or it is not parked.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { parkedLine } from '@yaks/session'
|
|
55
|
+
*
|
|
56
|
+
* // await parkedLine(graph, session) // 'parked on T-2, waiting on T-1'
|
|
57
|
+
* ```
|
|
58
|
+
*/ export declare let parkedLine: (g: Graph, session: Eid, seen?: Bundle) => Promise<string | undefined>;
|
|
59
|
+
/**
|
|
60
|
+
* The transcript already on `task`, where a new run would be a second writer:
|
|
61
|
+
* its holder where that {@link onward stands to carry on}, or, its claim let
|
|
62
|
+
* go, a transcript still running the wake it was given for the task. Nothing
|
|
63
|
+
* where it can be given no next turn, having asked for none.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { carrying } from '@yaks/session'
|
|
67
|
+
*
|
|
68
|
+
* // let run = await carrying(graph, task) // give it the work, not a new run
|
|
69
|
+
* ```
|
|
70
|
+
*/ export declare let carrying: (g: Graph, task: Eid) => Promise<Eid | undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* The writes that give a transcript {@link carrying} a task an instruction: an
|
|
73
|
+
* input carrying the `using` in force, so its next run or turn goes on the
|
|
74
|
+
* provider, model and account it ran on, the claim where it was let go, and,
|
|
75
|
+
* while its run is over, the precondition that it still is. A run starting
|
|
76
|
+
* under them refuses the write with `Stale`, and asking again answers. A
|
|
77
|
+
* transcript no request ever named a `using` for cannot be carried on, and
|
|
78
|
+
* gets none. `eid` names the input, for a writer whose input is its receipt.
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { handing } from '@yaks/session'
|
|
82
|
+
*
|
|
83
|
+
* // await graph.apply(await handing(graph, session, task, 'also do this'))
|
|
84
|
+
* ```
|
|
85
|
+
*/ export declare let handing: (g: Graph, session: Eid, task: Eid, body: string, _dts_1: never) => Promise<Bundle[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Wake a transcript for news of the tasks it holds: where its run is over,
|
|
88
|
+
* append an input carrying the `using` in force for each held task with a
|
|
89
|
+
* dependency finished that it was not told of, or one in `gone` (by held
|
|
90
|
+
* task) whose link went away. Whoever answers that provider runs the turn. A
|
|
91
|
+
* transcript still running is left alone; a managed run calls this as it ends.
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { rouse } from '@yaks/session'
|
|
95
|
+
*
|
|
96
|
+
* // await rouse(graph, session)
|
|
97
|
+
* ```
|
|
98
|
+
*/ export declare let rouse: (g: Graph, session: Eid, gone?: Record<Eid, Bundle[]>) => Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* The code behind `session_wake`: a task finished, so every transcript
|
|
101
|
+
* parked on a task that waits on it is {@link rouse}d.
|
|
102
|
+
*/ export declare let wake: (g: Graph, task: Eid) => Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* The code behind `session_wake` for a dependency link that went away: the
|
|
105
|
+
* transcript parked on `task`, the end it led from, is {@link rouse}d and told
|
|
106
|
+
* `task` waits on `dep` no more, where `dep` had not finished. A dependency
|
|
107
|
+
* deleted with its link is told too, since whether it had finished went with
|
|
108
|
+
* it.
|
|
109
|
+
*
|
|
110
|
+
* ```ts
|
|
111
|
+
* import { unlinked } from '@yaks/session'
|
|
112
|
+
*
|
|
113
|
+
* // await unlinked(graph, 'y', 'x') // y requires x no more
|
|
114
|
+
* ```
|
|
115
|
+
*/ export declare let unlinked: (g: Graph, task: Eid, dep: Eid) => Promise<void>;
|
|
116
|
+
//# sourceMappingURL=wake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wake.d.ts","sources":["../wake.ts"],"names":[],"mappings":"AAsBA,cAAc,MAAM,EAAQ,GAAG,EAAE,KAAK,2BAAgC;AA4B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AAI,WACT,GAAG,OACH,MAAM,KACN,KAAK,QACJ,QAAQ,IAAI,EAMd"}
|
package/_dist/watch.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Bundle, Eid, Graph } from "@yaks/graph";
|
|
2
|
+
type G = Pick<Graph, 'vocab' | 'read' | 'get' | 'apply'>;
|
|
3
|
+
type Addressing = G & Pick<Graph, 'address'>;
|
|
4
|
+
/** Everyone watching `task`, as sessions or actors, and those muting it. */ export declare let watchers: (g: G, task: Bundle) => Promise<{
|
|
5
|
+
watching: Eid[];
|
|
6
|
+
muting: Set<Eid>;
|
|
7
|
+
}>;
|
|
8
|
+
/** The operator of a project still able to hear: a session a person opened
|
|
9
|
+
* wearing a persona homed there or at a project it is filed under (the
|
|
10
|
+
* projects ./listen.ts gives such a session what is held for), not over, the
|
|
11
|
+
* one that spoke last. */ export declare let operatorOf: (g: G, project: Eid) => Promise<Eid | undefined>;
|
|
12
|
+
/** The sessions a write through `via` is the own write of: that session, and
|
|
13
|
+
* while it is a subagent (a transcript its harness keeps in a file and runs
|
|
14
|
+
* inside its parent's process, as a Claude Code subagent is), each session up
|
|
15
|
+
* its line. A managed run or a native child is a line of work of its own. */ export declare let writers: (g: G, via: Eid) => Promise<Set<Eid>>;
|
|
16
|
+
/**
|
|
17
|
+
* Where a managed run's ending is reported: the task its spawn call names,
|
|
18
|
+
* else the tasks it holds, and the session to knock, which is the one that
|
|
19
|
+
* started it or, that one being over, the nearest up its own line that can
|
|
20
|
+
* still hear. @yaks/spawn's completion writes its receipt by this, and
|
|
21
|
+
* {@link knocks} leaves that receipt to be the one knock. A helper's own
|
|
22
|
+
* ending (./help.ts) knocks nobody: what it did is in the graph, and what
|
|
23
|
+
* needs its operator it handed up itself.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { reported } from '@yaks/session'
|
|
27
|
+
*
|
|
28
|
+
* // let { tasks, to } = await reported(graph, run)
|
|
29
|
+
* ```
|
|
30
|
+
*/ export declare let reported: (g: Addressing, run: Eid) => Promise<{
|
|
31
|
+
tasks: Eid[];
|
|
32
|
+
to?: Eid;
|
|
33
|
+
}>;
|
|
34
|
+
/** The change a run of `session_watch` is for: the component that moved
|
|
35
|
+
* (`filed` for an assignment) and when its commit owed the run. */ export type Moved = {
|
|
36
|
+
name?: string;
|
|
37
|
+
at?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The knocks a change to a task owes its watchers: the task itself (a mark)
|
|
41
|
+
* or a comment on it. None where `eid` is neither, the change is not one a
|
|
42
|
+
* watcher hears, or every watcher wrote it or was told already. Where what
|
|
43
|
+
* `moved` is the task's `filed`, the change is its assignment, owed to the
|
|
44
|
+
* person it names alone.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { knocks } from '@yaks/session'
|
|
48
|
+
*
|
|
49
|
+
* // await graph.apply(await knocks(graph, task), { trusted: true })
|
|
50
|
+
* ```
|
|
51
|
+
*/ export declare let knocks: (g: Addressing, eid: Eid, moved?: Moved) => Promise<Bundle[]>;
|
|
52
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sources":["../watch.ts"],"names":[],"mappings":"AA2DA,cAAc,MAAM,EAAQ,GAAG,EAAE,KAAK,2BAAgC;KASjE,IAAI,KAAK,OAAO,UAAU,SAAS,QAAQ;KAE3C,aAAa,IAAI,KAAK,OAAO;AAmFlC,0EAA0E,GAC1E,OAAO,YAAI,WACT,GAAG,GACH,MAAM,WACL;EAAU,UAAU;EAAO,QAAQ,IAAI;GAazC;AAqBD;;;wBAGwB,GACxB,OAAO,YAAI,aACT,GAAG,GACH,SAAS,QACR,QAAQ,MAAM,SAAS,EAgBzB;AAkFD;;;2EAG2E,GAC3E,OAAO,YAAI,UAAiB,GAAG,GAAG,KAAK,QAAM,QAAQ,IAAI,MAYxD;AA2BD;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,WACT,GAAG,YACH,KAAK,QACJ;EAAU,OAAO;EAAO,KAAK;GA2B/B;AA+FD;iEACiE,GACjE,YAAY;EAAU,OAAO,MAAM;EAAE,KAAK,MAAM;;AAEhD;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,SACT,GAAG,YACH,KAAK,KACL,QAAO,UACN,QAAQ,UAoFV"}
|
package/_dist/who.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Actor, Bundle, Eid, Graph, Hook, Tx } from "@yaks/graph";
|
|
2
|
+
/** Whether a request came from a person or their command, rather than an
|
|
3
|
+
* agent or automation. An agent may speak for an identity, so both the author
|
|
4
|
+
* and the instrument matter. A transcript's own stamp is not its parent. */ export declare let humanCaller: (g: Pick<Graph, 'read' | 'vocab'>, actor: Actor | null, self?: Eid) => Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* The eid of the session a harness knows by `id`: the id itself where it is a
|
|
7
|
+
* uuid, and otherwise one derived from it. A subagent's, whose id names it
|
|
8
|
+
* within its `parent`, derives from both.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { sessionEid } from '@yaks/session'
|
|
12
|
+
* import { assertEquals } from '@std/assert'
|
|
13
|
+
*
|
|
14
|
+
* let id = '49805559-ca98-4c0a-873e-45c19ec7316c'
|
|
15
|
+
* assertEquals(sessionEid(id), id)
|
|
16
|
+
* ```
|
|
17
|
+
*/ export declare let sessionEid: (id: string, parent?: string) => Eid;
|
|
18
|
+
/** A command speaks for its own transcript, never its launcher's. Clearing
|
|
19
|
+
* the other harness IDs also matters when `yak` chooses the first one it sees. */ export declare let sessionEnv: (session: string, env: Record<string, string>) => Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* The transcripts these ids are the runner's own ids of (`session.id`), each
|
|
22
|
+
* to its eid: the key only a session has, which is how an id meant to name a
|
|
23
|
+
* session resolves where no plugin knows it as an eid or a name (the
|
|
24
|
+
* plugin's `address`, asked with the kind `session`).
|
|
25
|
+
*/ export declare let runners: (tx: Pick<Tx, 'read'>, ids: string[]) => Map<string, Eid> | Promise<Map<string, Eid>>;
|
|
26
|
+
/**
|
|
27
|
+
* The transcript an id names: the entity it addresses, else the one carrying it
|
|
28
|
+
* as its runner's own id. Nothing is minted here — resolution only reads, and a
|
|
29
|
+
* tool that wants a transcript created does that itself. `{ id }` selects only
|
|
30
|
+
* the runner's own session id, without trying entity addresses. `fields` selects only
|
|
31
|
+
* the properties the caller reads, avoiding derived transcript history.
|
|
32
|
+
*/ export declare let sessionFor: (g: Pick<Graph, 'address' | 'get' | 'read'>, said: string | {
|
|
33
|
+
id: string;
|
|
34
|
+
}, fields?: string[]) => Promise<Bundle | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* The actor a session works as: its persona, else the actor it names
|
|
37
|
+
* (`session.actor`), else the project it is filed in (`filed.project`), else
|
|
38
|
+
* whatever the session that spawned it works as, so a subagent works as the
|
|
39
|
+
* persona it runs under. Never a session; `undefined` where nothing names one.
|
|
40
|
+
* A session with no persona anywhere up its line should be rare, and a door
|
|
41
|
+
* that starts one is worth fixing rather than falling back for. Each session
|
|
42
|
+
* is read for those properties alone: the rest of `session` (its computed
|
|
43
|
+
* `status` above all) costs a command its compile and answers nothing here.
|
|
44
|
+
*/ export declare let actorOf: (g: Pick<Graph, 'read' | 'vocab'>, session: Eid) => Promise<Eid | undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* The actor a transcript writes as: `by` the actor it works as
|
|
47
|
+
* ({@link actorOf}), the identity that survives a `/clear`, and `via` the run
|
|
48
|
+
* itself. A session that works as nobody leaves `by` unsaid rather than
|
|
49
|
+
* standing in it.
|
|
50
|
+
*/ export declare let speaking: (g: Pick<Graph, 'read' | 'vocab'>, s: Bundle) => Promise<Actor>;
|
|
51
|
+
/**
|
|
52
|
+
* The session standing in this graph for a conversation held in another
|
|
53
|
+
* store and reached through `door` (a tunnel), written where it is new, and
|
|
54
|
+
* the actor a request from it writes as: `by` the `persona` such a caller
|
|
55
|
+
* works as here, `via` that session. Its eid derives from the door and the
|
|
56
|
+
* conversation's id, as a subagent's does from its parent and its own, so
|
|
57
|
+
* every request from one conversation speaks through one session and no id a
|
|
58
|
+
* request sends names one of this graph's own runs. Where the id is an eid,
|
|
59
|
+
* `session.source` keeps it: the conversation is an entity, in its own store.
|
|
60
|
+
* A request naming no conversation speaks through the door's one session.
|
|
61
|
+
* `session.door` says the session is the door's, which is what holds a write
|
|
62
|
+
* through it to its own writer ({@link attributing}). Where the door says
|
|
63
|
+
* whose conversation it is, and that is a person here, `session.person`
|
|
64
|
+
* keeps them: what is news to them is told to it (./watch.ts).
|
|
65
|
+
*/ export declare let standIn: (g: Pick<Graph, 'get' | 'apply'>, door: string, conversation?: string, persona?: Eid, person?: Eid) => Promise<Actor>;
|
|
66
|
+
/**
|
|
67
|
+
* Who a write through a session standing at a door is by is the door's word,
|
|
68
|
+
* and nothing the write says: a request naming somebody else as the one a mark
|
|
69
|
+
* is by (`$decider`, @yaks/kernel) is dropped from it, so the mark is its
|
|
70
|
+
* writer's. A hosted assistant answering a decision through a tunnel answers
|
|
71
|
+
* as itself, whoever it names; the person's own answer arrives as the person
|
|
72
|
+
* (@yaks/tunnel `x-yak-by`), through no session.
|
|
73
|
+
*/ export declare let attributing: Hook;
|
|
74
|
+
/**
|
|
75
|
+
* The session of a subagent its harness knows by `id` within the session it
|
|
76
|
+
* knows by `parent`: its eid, and the rows that write it where the graph has
|
|
77
|
+
* not met it yet (with the parent, where that is new too), else none.
|
|
78
|
+
*/ export declare let spawning: (g: Pick<Graph, 'get' | 'read' | 'address'>, parent: string, id: string) => Promise<{
|
|
79
|
+
eid: Eid;
|
|
80
|
+
rows: Bundle[];
|
|
81
|
+
}>;
|
|
82
|
+
/** The session of a subagent ({@link spawning}), written where it is new.
|
|
83
|
+
* Answers its eid, or nothing where either id is empty. */ export declare let subagentSession: (g: Pick<Graph, 'get' | 'read' | 'address' | 'apply'>, parent: string, id: string) => Promise<E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,KAkBtB;AAEF;;;;CAIC,GACD,OAAO,YAAI,WACT,GAAG,KAAK,OAAO,QAAQ,SAAS,YAChC,QAAQ,MAAM,EACd,IAAI,MAAM,KACT;EAAU,KAAK;EAAK,MAAM;GAgB5B;AAED;yDACyD,GACzD,OAAO,YAAI,kBACT,GAAG,KAAK,OAAO,QAAQ,SAAS,YAAY,UAC5C,QAAQ,MAAM,EACd,IAAI,MAAM,KACT,QAAQ,MAAM,SAAS,EAKzB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Bounded, fork-aware transcript queries. This does not change model history. */ import type { Bundle, Eid, Graph } from "@yaks/graph";
|
|
2
|
+
import { type Built } from "@yaks/query";
|
|
3
|
+
export type TranscriptWindow = {
|
|
4
|
+
/** Entry identity, not a global entity number. Absent means the newest page. */ anchor?: Eid;
|
|
5
|
+
edge?: 'start' | 'end';
|
|
6
|
+
/** The page that ends just before this entry, to read back a page at a
|
|
7
|
+
* time: pass a page's first entry for the one before it. */ before?: Eid;
|
|
8
|
+
/** Number of entry bodies to load, clamped to 1..256. */ limit?: number;
|
|
9
|
+
};
|
|
10
|
+
export type TranscriptPage = {
|
|
11
|
+
entries: Bundle[];
|
|
12
|
+
before: boolean;
|
|
13
|
+
after: boolean;
|
|
14
|
+
/** Logical entry counts, including unloaded fork ancestors. */ total?: number;
|
|
15
|
+
/** Zero-based index of the first entry in this page. */ offset?: number;
|
|
16
|
+
};
|
|
17
|
+
export type TranscriptPlan = Omit<TranscriptPage, 'entries'> & {
|
|
18
|
+
queries: Built[];
|
|
19
|
+
};
|
|
20
|
+
export type Segment = {
|
|
21
|
+
session: Eid;
|
|
22
|
+
through: number;
|
|
23
|
+
};
|
|
24
|
+
/** A fork contributes a bounded prefix of each ancestor, followed by local rows. */ export declare let transcriptSegments: (g: Graph, session: Eid) => Promise<Segment[]>;
|
|
25
|
+
/** The query for one segment of a transcript: its session's entries, up to
|
|
26
|
+
* where a fork left it. */ export declare let within: (s: Segment) => Built;
|
|
27
|
+
/** A page's start past `eid`, in segment `s` read in seq's order. Every
|
|
28
|
+
* entry holds its seq, and saying so where {@link within} does not lets the
|
|
29
|
+
* page start at the anchor's seq (@yaks/sql `seekOf`), where it walked the
|
|
30
|
+
* session from its newest line on every page. Said here rather than in
|
|
31
|
+
* `within`: a test beside every query of a segment is paid on each row they
|
|
32
|
+
* read. */ export declare let past: (s: Segment, eid: Eid) => Built;
|
|
33
|
+
/** A transcript's newest entries, oldest first, read back through its
|
|
34
|
+
* segments a page at a time until `enough` holds of what was read, or to its
|
|
35
|
+
* start (`whole`): what a turn reads costs the turn, not every line the
|
|
36
|
+
* transcript ever held. */ export declare let transcriptBack: (g: Graph, session: Eid, enough: (entries: Bundle[]) => boolean | Promise<boolean>) => Promise<{
|
|
37
|
+
entries: Bundle[];
|
|
38
|
+
whole: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
/** Only positions are read while locating a page: no old content/blob bodies. */ export declare let transcriptPlan: (g: Graph, session: Eid, request?: TranscriptWindow) => Promise<TranscriptPlan>;
|
|
41
|
+
export declare let transcriptWindow: (g: Graph, session: Eid, request?: TranscriptWindow) => Promise<TranscriptPage>;
|
|
42
|
+
/** Latest reported usage in a logical fork transcript, without reading prose. */ export declare let transcriptUsage: (g: Graph, session: Eid) => Promise<Bundle[]>;
|
|
43
|
+
//# sourceMappingURL=window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window.d.ts","sources":["../window.ts"],"names":[],"mappings":"AAAA,gFAAgF,GAChF,cAAc,MAAM,EAAQ,GAAG,EAAE,KAAK,2BAAgC;AACtE,SAAS,KAAK,KAAK,2BAA2C;AAG9D,YAAY;EACV,8EAA8E,GAC9E,SAAS;EACT,OAAO,UAAU;EACjB;4DAC0D,GAC1D,SAAS;EACT,uDAAuD,GACvD,QAAQ,MAAM;;AAEhB,YAAY;EACV,SAAS;EACT,QAAQ,OAAO;EACf,OAAO,OAAO;EACd,6DAA6D,GAC7D,QAAQ,MAAM;EACd,sDAAsD,GACtD,SAAS,MAAM;;AAEjB,YAAY,iBAAiB,KAAK,gBAAgB;EAChD,SAAS;;AAEX,YAAY;EAAY,SAAS;EAAK,SAAS,MAAM;;AAGrD,kFAAkF,GAClF,OAAO,YAAI,qBACT,GAAG,OACH,SAAS,QACR,QAAQ,WAqBV;AACD;yBACyB,GACzB,OAAO,YAAI,SAAU,GAAG,YAAU,MAGK;AAEvC;;;;;SAKS,GACT,OAAO,YAAI,OAAQ,GAAG,SAAS,KAAK,QAAM,MAGL;AAErC;;;yBAGyB,GACzB,OAAO,YAAI,iBACT,GAAG,OACH,SAAS,KACT,SAAS,SAAS,aAAa,OAAO,GAAG,QAAQ,OAAO,MACvD;EAAU,SAAS;EAAU,OAAO,OAAO;GAoB7C;AAED,+EAA+E,GAC/E,OAAO,YAAI,iBACT,GAAG,OACH,SAAS,KACT,UAAS,qBACR,QAAQ,gBA+HV;AAED,OAAO,YAAI,mBACT,GAAG,OACH,SAAS,KACT,UAAU,qBACT,QAAQ,gBASV;AAED,+EAA+E,GAC/E,OAAO,YAAI,kBACT,GAAG,OACH,SAAS,QACR,QAAQ,UAUV"}
|
package/admission.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// The bound on children, kept in the graph. A spawned transcript waits
|
|
2
|
+
// `queued` until fewer than `maxChildren` are `active`; admission is a guarded
|
|
3
|
+
// write to its `dispatch`, so two workers admitting one child settle it in the
|
|
4
|
+
// transaction, and the write owes the child a run (./run.ts). A child waiting
|
|
5
|
+
// on its own children steps aside (`waiting`) so they can be admitted, and
|
|
6
|
+
// queues again for its place when the wait is over.
|
|
7
|
+
import { Stale } from "@yaks/graph/errors";
|
|
8
|
+
import { token } from "@yaks/graph/sha256";
|
|
9
|
+
import { absent, and, eq, list, or, present, want } from "@yaks/query";
|
|
10
|
+
import { changes } from "./wait.js";
|
|
11
|
+
let dispatch = (b)=>b?.dispatch;
|
|
12
|
+
/** During expansion the old server's value wins. After conversion only marks
|
|
13
|
+
* remain; no dispatch means no place, not a queued root. */ export let dispatchStatus = (b)=>{
|
|
14
|
+
let d = dispatch(b);
|
|
15
|
+
if (!d) return null;
|
|
16
|
+
return d.state ?? (b?.waiting ? 'waiting' : b?.admitted ? 'active' : 'queued');
|
|
17
|
+
};
|
|
18
|
+
// What admission reads of a transcript: its place and the marks naming it,
|
|
19
|
+
// never the rest it wears (a session's computed status reads every entry).
|
|
20
|
+
// A narrow consumer's vocabulary may lack the marks.
|
|
21
|
+
let marks = (g)=>[
|
|
22
|
+
'admitted',
|
|
23
|
+
'waiting'
|
|
24
|
+
].filter((name)=>g.vocab.comp(name));
|
|
25
|
+
let place = async (g, eid)=>(await g.get([
|
|
26
|
+
eid
|
|
27
|
+
], [
|
|
28
|
+
'dispatch',
|
|
29
|
+
...marks(g)
|
|
30
|
+
]))[0];
|
|
31
|
+
// The children holding a place. A legacy row keeps its dispatch once settled,
|
|
32
|
+
// and those outnumber the rest many times over: the index on `dispatch.state`
|
|
33
|
+
// seeks past them, which a `!= 'settled'` would scan to the last.
|
|
34
|
+
let holders = async (g)=>await g.read(and(present('dispatch'), or(absent('dispatch.state'), eq('dispatch.state', list('queued', 'active', 'waiting'))), ...marks(g).map(want)));
|
|
35
|
+
// The children in `status`.
|
|
36
|
+
let placed = async (g, status)=>(await holders(g)).filter((b)=>dispatchStatus(b) == status);
|
|
37
|
+
let state = async (g, eid)=>dispatchStatus(await place(g, eid));
|
|
38
|
+
/** Patch a transcript's `dispatch` only if its state is still `was`. */ export let swap = async (g, eid, was, patch, together = [])=>{
|
|
39
|
+
let b = await place(g, eid);
|
|
40
|
+
if (dispatchStatus(b) != was || !b?.dispatch) return false;
|
|
41
|
+
let d = dispatch(b);
|
|
42
|
+
let next = patch.state;
|
|
43
|
+
// Narrow consumers may still load only the old session vocabulary. They
|
|
44
|
+
// keep writing the legacy shape; marks-only rows require both core marks.
|
|
45
|
+
let marks = g.vocab.comps.includes('admitted') && g.vocab.comps.includes('waiting');
|
|
46
|
+
try {
|
|
47
|
+
await g.apply([
|
|
48
|
+
{
|
|
49
|
+
entity: {
|
|
50
|
+
eid
|
|
51
|
+
},
|
|
52
|
+
dispatch: next == 'settled' && d.state == null ? null : {
|
|
53
|
+
...patch,
|
|
54
|
+
...d.state == null ? {
|
|
55
|
+
state: null
|
|
56
|
+
} : {}
|
|
57
|
+
},
|
|
58
|
+
...marks ? next == 'active' ? {
|
|
59
|
+
admitted: {},
|
|
60
|
+
waiting: null
|
|
61
|
+
} : next == 'waiting' ? {
|
|
62
|
+
admitted: null,
|
|
63
|
+
waiting: {}
|
|
64
|
+
} : next == 'queued' || next == 'settled' ? {
|
|
65
|
+
admitted: null,
|
|
66
|
+
waiting: null
|
|
67
|
+
} : {} : {},
|
|
68
|
+
$was: {
|
|
69
|
+
dispatch: {
|
|
70
|
+
state: token(d.state ?? null),
|
|
71
|
+
order: token(d.order ?? null),
|
|
72
|
+
args: token(d.args ?? null)
|
|
73
|
+
},
|
|
74
|
+
...marks ? {
|
|
75
|
+
...Object.fromEntries([
|
|
76
|
+
'admitted',
|
|
77
|
+
'waiting'
|
|
78
|
+
].map((name)=>[
|
|
79
|
+
name,
|
|
80
|
+
Object.fromEntries([
|
|
81
|
+
'at',
|
|
82
|
+
'by',
|
|
83
|
+
'via'
|
|
84
|
+
].map((prop)=>[
|
|
85
|
+
prop,
|
|
86
|
+
token(b[name]?.[prop])
|
|
87
|
+
]))
|
|
88
|
+
]))
|
|
89
|
+
} : {}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
...together
|
|
93
|
+
], {
|
|
94
|
+
trusted: true
|
|
95
|
+
});
|
|
96
|
+
return true;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (error instanceof Stale) return false;
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
/** The children waiting for a place, oldest first. */ export let queue = async (g)=>(await placed(g, 'queued')).toSorted((a, b)=>Number(dispatch(a)?.order ?? 0) - Number(dispatch(b)?.order ?? 0));
|
|
103
|
+
/** The children holding a place. Their transcript may have just ended. */ export let activeChildren = (g)=>placed(g, 'active');
|
|
104
|
+
/** How many children hold a place. */ export let active = async (g)=>(await activeChildren(g)).length;
|
|
105
|
+
/** The order a child joining the queue takes: behind every other holding a
|
|
106
|
+
* place. A settled child's order no longer places anyone. */ export let tail = async (g)=>Math.max(0, ...(await holders(g)).map((b)=>Number(dispatch(b)?.order ?? 0))) + 1;
|
|
107
|
+
/** Admit the oldest queued children while fewer than the bound are active. */ export let admitNext = async (g, limits = {})=>{
|
|
108
|
+
let free = (limits.maxChildren ?? 32) - await active(g);
|
|
109
|
+
for (let b of (await queue(g)).slice(0, Math.max(0, free))){
|
|
110
|
+
await swap(g, b.entity.eid, 'queued', {
|
|
111
|
+
state: 'active'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
/** Give up a child's place while it waits, and answer how to take one back:
|
|
116
|
+
* queue again and return once admitted, or once `signal` aborts. A transcript
|
|
117
|
+
* holding no place (a root) has nothing to give up. */ export let aside = async (g, session, limits, signal)=>{
|
|
118
|
+
if (!await swap(g, session, 'active', {
|
|
119
|
+
state: 'waiting'
|
|
120
|
+
})) {
|
|
121
|
+
return ()=>Promise.resolve();
|
|
122
|
+
}
|
|
123
|
+
await admitNext(g, limits);
|
|
124
|
+
return async ()=>{
|
|
125
|
+
await swap(g, session, 'waiting', {
|
|
126
|
+
state: 'queued'
|
|
127
|
+
});
|
|
128
|
+
await admitNext(g, limits);
|
|
129
|
+
for await (let over of changes(g, {
|
|
130
|
+
signal,
|
|
131
|
+
clock: limits.clock
|
|
132
|
+
})){
|
|
133
|
+
if (over || await state(g, session) != 'queued') return;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=admission.js.map
|
package/admission.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admission.js","sources":["./admission.ts"],"names":[],"mappings":"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