@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/react.d.ts
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { InputText } from "./source.js";
|
|
2
|
+
import type { Steps } from "@yaks/tools/title";
|
|
3
|
+
import type { Refusal } from "@yaks/tools";
|
|
4
|
+
export { CallError as ToolError } from "@yaks/tools/errors";
|
|
5
|
+
import { type Clock } from "@yaks/fp";
|
|
6
|
+
import type { Bundle, Comp, Eid, Graph } from "@yaks/graph";
|
|
7
|
+
import { type Executor, type Item, type Model, ModelError, type Request, type Tool as Declared } from "@yaks/model";
|
|
8
|
+
import { type TranscriptStatus } from "./state.js";
|
|
9
|
+
export { lines, recent } from "./compact.js";
|
|
10
|
+
import type { Attempt } from "@yaks/effects";
|
|
11
|
+
/** The caller, supplied by react rather than by model arguments, and a
|
|
12
|
+
* signal that aborts when the process running the transcript is leaving: a
|
|
13
|
+
* tool waiting on something stops waiting (./children.ts `wait`). */ export type ToolContext = {
|
|
14
|
+
session: Eid;
|
|
15
|
+
call: Bundle;
|
|
16
|
+
entries: Bundle[];
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
/** This call can yield its claim and check for its durable answer later. */ deferred?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** A refused tool invocation: expected, recorded as its result carrying
|
|
21
|
+
* `refusal{code}`. */ export { UnknownSession } from "./unknown.js";
|
|
22
|
+
export { transcript } from "./transcript.js";
|
|
23
|
+
export { PENDING, project } from "./project.js";
|
|
24
|
+
/** What a tool answers: its words, or its words `with` components its result
|
|
25
|
+
* entry carries beside them (an image the host shows the model beside the
|
|
26
|
+
* result). */ export type Told = string | {
|
|
27
|
+
text: string;
|
|
28
|
+
with: Record<string, Comp>;
|
|
29
|
+
};
|
|
30
|
+
/** The words a tool's answer says. */ export declare let wordsOf: (said: Told) => string;
|
|
31
|
+
/** A tool the model may call: its declaration, and how to run it. */ export type Tool = Declared & {
|
|
32
|
+
/** What a person reads in place of its name: an imperative phrase
|
|
33
|
+
* (@yaks/tools `titleOf`). It is never sent to the model. */ title?: string;
|
|
34
|
+
/** How a call reads to a person, while it runs and once it answered
|
|
35
|
+
* (@yaks/tools `Steps`). It is never sent to the model. */ step?: Steps;
|
|
36
|
+
run: (args: Record<string, unknown>, ctx?: ToolContext) => Promise<Told> | Told;
|
|
37
|
+
/** Recover an invocation whose process ended before it recorded a result.
|
|
38
|
+
* Return its known outcome, or nothing when its effects are uncertain. */ recover?: (args: Record<string, unknown>, ctx: ToolContext) => Promise<Told | undefined> | Told | undefined;
|
|
39
|
+
/** A call to it is the model waiting (on a process, a child, a task): it
|
|
40
|
+
* never outlasts its patience, however long it runs, so only its result or
|
|
41
|
+
* something else new starts the model's next turn ({@link PATIENCE}). */ waits?: boolean;
|
|
42
|
+
/** This invocation can be taken up again after yielding for its own result. */ defers?: (call: Bundle) => boolean | Promise<boolean>;
|
|
43
|
+
/** It only reads, as the graph tool it serves declares (`readOnly`): an id
|
|
44
|
+
* it is handed that names nothing is its own to answer about rather than a
|
|
45
|
+
* refusal of the call, and its answer is the result's words, not an entity
|
|
46
|
+
* of their own (@yaks/tools `keeps`). */ readOnly?: boolean;
|
|
47
|
+
/** The query whose rows are its answer to these arguments, where its answer
|
|
48
|
+
* is one (@yaks/tools `watched`), and whether that query reads the runner's
|
|
49
|
+
* own store rather than the graph its calls reach (`local`), or another
|
|
50
|
+
* graph its host names (`over`): a subscription to the tool watches the
|
|
51
|
+
* query live. It throws a refusal for arguments the query cannot follow. */ watch?: (args: Record<string, unknown>) => {
|
|
52
|
+
query: string;
|
|
53
|
+
local?: boolean;
|
|
54
|
+
over?: string;
|
|
55
|
+
};
|
|
56
|
+
/** Its schema is sent only once a `tool_load` call names it; until then
|
|
57
|
+
* that tool lists it by name and title (./deferred.ts). */ deferred?: boolean;
|
|
58
|
+
/** Omit this tool from new model requests in a forked transcript. */ excludeFromForks?: boolean;
|
|
59
|
+
/** The runner holds it, but this turn does not, for this reason: it is
|
|
60
|
+
* neither listed, sent nor run, and a `tool_load` naming it is told the
|
|
61
|
+
* reason (./deferred.ts). */ withheld?: string;
|
|
62
|
+
};
|
|
63
|
+
/** How long a background call (`tool_async`) runs before it is given a
|
|
64
|
+
* Pending entry (`tool_progress`), in milliseconds. A model turn starts when
|
|
65
|
+
* there is something new to read: an input, a result, or that Pending, which
|
|
66
|
+
* says a call has run long enough that other work is worth doing. A call that
|
|
67
|
+
* answers sooner costs no turn of its own, and a tool that `waits` never gets
|
|
68
|
+
* one. */ export declare let PATIENCE: number;
|
|
69
|
+
/** How long a call's answer waits for its Pending entry's write, in
|
|
70
|
+
* milliseconds. A write that has not landed by then is reported, never
|
|
71
|
+
* written after the answer, and the answer lands without it. */ export declare let HELD: number;
|
|
72
|
+
/** A model as one provider serves it: the adapter that asks, and the name
|
|
73
|
+
* that provider knows the model by (`serves.name`). */ export type Served = {
|
|
74
|
+
model: Model;
|
|
75
|
+
name: string;
|
|
76
|
+
provider?: Eid;
|
|
77
|
+
executor?: Executor;
|
|
78
|
+
};
|
|
79
|
+
/** The measured work a transcript's host can associate with its inputs. */ export type WorkTiming = {
|
|
80
|
+
session: Eid;
|
|
81
|
+
inputs: Bundle[];
|
|
82
|
+
at: number;
|
|
83
|
+
} & ({
|
|
84
|
+
phase: 'context';
|
|
85
|
+
ms: number;
|
|
86
|
+
ask: Eid;
|
|
87
|
+
} | {
|
|
88
|
+
phase: 'tool';
|
|
89
|
+
ms: number;
|
|
90
|
+
call: Eid;
|
|
91
|
+
name: string;
|
|
92
|
+
});
|
|
93
|
+
/** What `react` is handed beside the graph. */ export type Deps = {
|
|
94
|
+
/** Experimental durable request admission with transient text. */ owner?: Eid;
|
|
95
|
+
/** Whether a holder of a call's claim ended without writing its `exit`, so
|
|
96
|
+
* the call it held is recovered now (@yaks/tools `RunnerOpts.gone`). */ gone?: (holder: Eid) => boolean | Promise<boolean>;
|
|
97
|
+
/** Dispatch native calls through independent durable effects. */ asyncTools?: boolean;
|
|
98
|
+
/** Internal effect execution of one recorded call (never a model request). */ runCall?: Eid;
|
|
99
|
+
/** Deliver one saved request result without starting another model/tool step. */ resultCall?: Eid;
|
|
100
|
+
/** How long a background call runs before it is given a Pending entry
|
|
101
|
+
* ({@link PATIENCE} where absent). */ patience?: number;
|
|
102
|
+
/** How long a call's answer waits for its Pending entry's write
|
|
103
|
+
* ({@link HELD} where absent). */ held?: number;
|
|
104
|
+
observe?: (timing: WorkTiming) => void;
|
|
105
|
+
clock?: Clock;
|
|
106
|
+
streaming?: boolean;
|
|
107
|
+
/** How long streamed text may stand unstored ({@link CHECKPOINT} where
|
|
108
|
+
* absent); zero stores it only when the reply ends. */ checkpointMs?: number;
|
|
109
|
+
/** Each piece of streamed text, once it is stored: what a page shows of a
|
|
110
|
+
* reply being written is never more than what survives the process. */ typed?: (session: Eid, text: string, inputs?: Bundle[]) => void;
|
|
111
|
+
/** The pooled run taking this step (@yaks/effects): a model request the
|
|
112
|
+
* provider failed but may yet answer is recorded and thrown, for the pool to
|
|
113
|
+
* ask again after its backoff, unless this attempt is the run's last. A step
|
|
114
|
+
* taken outside the pool has nobody to ask again, so such a failure stands. */ attempt?: Attempt;
|
|
115
|
+
/** Classify a transient host failure before a tool or model was dispatched.
|
|
116
|
+
* The pool keeps the step pending and retries it with its usual backoff. */ retry?: (error: unknown, session: Eid, phase: string) => ModelError | undefined;
|
|
117
|
+
/** The share of its model's context window a transcript fills before it
|
|
118
|
+
* is compacted, the same for every model (./compact.ts `SHARE` where
|
|
119
|
+
* absent). The window is the model row's `model.context`, else its
|
|
120
|
+
* provider's `provider.context`, else `CONTEXT` (@yaks/model). */ compactAt?: number;
|
|
121
|
+
/** A share of the window selected for one route, including cold turns. */ compactShare?: (using: Comp | undefined, model: string) => number | undefined;
|
|
122
|
+
/** A text-capable model for checkpoints, independent of the transcript model.
|
|
123
|
+
* Without one, leave the history intact instead of sending a summary to an
|
|
124
|
+
* arbitrary (possibly media-only) model. */ compactModel?: Served;
|
|
125
|
+
/** Use the session's selected model for compaction when its route requires it. */ compactWithCurrent?: (using: Comp | undefined) => boolean;
|
|
126
|
+
/** Project old turn context out of a cold request without archiving it. */ elideCold?: boolean;
|
|
127
|
+
/** Project a background turn from its first unanswered input. A mixed
|
|
128
|
+
* turn that also answers a foreground input keeps its ordinary context. */ background?: (entry: Bundle) => boolean;
|
|
129
|
+
model: Model;
|
|
130
|
+
/** Hosted execution persists an ask and yields while its receipt is pending. */ executor?: Executor;
|
|
131
|
+
/** Choose the provider that serves the model, and what it calls the model. */ resolveModel?: (using: Comp | undefined, model: Bundle) => Promise<Served>;
|
|
132
|
+
/** Where a conversation goes on once the plan of the model it asked
|
|
133
|
+
* (`using`) is spent (@yaks/model `spent`): the `using{provider, model,
|
|
134
|
+
* why}` to ask instead, or nothing to let it wait for the plan to reset. */ onward?: (using: Comp | undefined, error: ModelError, passed: ReadonlySet<Eid>) => Promise<Comp | undefined>;
|
|
135
|
+
tools: Tool[];
|
|
136
|
+
/** Resolve a stable tool registry for one execution step. `open` is every
|
|
137
|
+
* call of the transcript no result answers yet, as the step read it. */ toolSnapshot?: (phase: 'ask' | 'call', session: Eid, boundary: Eid | undefined, open: Bundle[]) => Promise<Tool[]>;
|
|
138
|
+
/** Tools offered only to a turn whose `sending.tools` names them, beside the
|
|
139
|
+
* runner's own: the ones a host can run that every transcript need not
|
|
140
|
+
* carry. Asked for only when a turn names some. */ named?: () => Tool[];
|
|
141
|
+
/** aborts the step in flight: its model request and its tool calls */ signal?: AbortSignal;
|
|
142
|
+
/** aborts when the process running the transcript is leaving: no step
|
|
143
|
+
* starts after it, and a tool waiting on something stops waiting, while the
|
|
144
|
+
* step in flight is let finish */ stopping?: AbortSignal;
|
|
145
|
+
instructions?: string;
|
|
146
|
+
/** Resolve instruction layers with an explicit shared prefix. */ requestInstructions?: (session: Eid) => Promise<Pick<Request, 'instructions' | 'cachePrefix'>>;
|
|
147
|
+
/** The host authority or context whose cached instructions may be reused. */ instructionScope?: (session: Eid) => string | Promise<string>;
|
|
148
|
+
/** Resolve inherited base instructions for future asks without rewriting
|
|
149
|
+
* history; a host whose instructions differ by transcript reads its own. */ resolveInstructions?: (inherited: string | undefined, session: Eid) => string | undefined | Promise<string | undefined>;
|
|
150
|
+
/** The names of the tools a transcript is offered where no line of it
|
|
151
|
+
* selected any (`sending.tools` on an input): its persona's, for a host
|
|
152
|
+
* that wears one. Read with the instructions, once the prefix its last ask
|
|
153
|
+
* cached has expired, and recorded on the ask as its `sending.tools`, so a
|
|
154
|
+
* tool the persona gains reaches a transcript that runs for weeks. Nothing
|
|
155
|
+
* leaves the runner's own set. */ resolveTools?: (session: Eid) => string[] | undefined | Promise<string[] | undefined>;
|
|
156
|
+
/** Which of a transcript's lines the turn may read, for whom it acts: a
|
|
157
|
+
* host whose conversations change hands between turns keeps some from a
|
|
158
|
+
* turn acting for someone else. Every line, where absent or undefined.
|
|
159
|
+
* Only what the model is handed is narrowed; summaries weigh every line. */ readable?: (session: Eid) => Promise<((line: Bundle) => boolean) | undefined>;
|
|
160
|
+
/** Host rendering of each input's prose in a transcript, resolved once per
|
|
161
|
+
* step (it may read the graph, to name who sent each input); stored
|
|
162
|
+
* content stays unchanged. */ inputText?: (transcript: Bundle[]) => Promise<(entry: Bundle) => InputText>;
|
|
163
|
+
/** Optional bounded model-facing tool-result projection; storage stays unchanged. */ resultText?: (entry: Bundle) => Promise<string>;
|
|
164
|
+
/** Resolve explicitly admitted multimodal context without storing bytes in entries. */ contextItems?: (window: Bundle[], entries: Bundle[], current: {
|
|
165
|
+
session: Eid;
|
|
166
|
+
model: Model;
|
|
167
|
+
name: string;
|
|
168
|
+
}) => Promise<Map<Eid, Item[]>>;
|
|
169
|
+
/** Dynamic provider-neutral context after the exact tool offer is resolved.
|
|
170
|
+
* Set Item.from when their writer is known; otherwise assembly labels
|
|
171
|
+
* them as system context. */ requestItems?: (window: Bundle[], entries: Bundle[], current: {
|
|
172
|
+
session: Eid;
|
|
173
|
+
tools: readonly Tool[];
|
|
174
|
+
}) => Promise<Item[]>;
|
|
175
|
+
/** Current context, read again for each request and kept beside the
|
|
176
|
+
* transcript, so changes reach the model without breaking the cached prefix.
|
|
177
|
+
* An anchored request compares these items with the preceding ask. */ turnItems?: (window: Bundle[], entries: Bundle[], current: {
|
|
178
|
+
session: Eid;
|
|
179
|
+
background?: boolean;
|
|
180
|
+
}) => Promise<Item[]>;
|
|
181
|
+
/** Unexpected model/tool defects, separate from expected refusals. */ report?: (error: unknown, session: Eid, phase: string) => void;
|
|
182
|
+
/** Each refusal a tool call met, apart from defects (@yaks/tools
|
|
183
|
+
* `Opts.refused`): the call names its session. */ refused?: (refusal: Refusal, call: Bundle, tool?: string) => unknown;
|
|
184
|
+
mint?: () => Eid;
|
|
185
|
+
};
|
|
186
|
+
/** How long streamed text stands unstored, at most: a process reset under a
|
|
187
|
+
* reply (a deploy) loses no more than this of it. */ export declare let CHECKPOINT: number;
|
|
188
|
+
/** What one step did. */ export type Step = {
|
|
189
|
+
did: 'asked' | 'ran' | 'nothing';
|
|
190
|
+
status: TranscriptStatus;
|
|
191
|
+
/** A hosted receipt this step checked, for a wake racing lease release. */ waiting?: {
|
|
192
|
+
call: Eid;
|
|
193
|
+
receipt?: string;
|
|
194
|
+
};
|
|
195
|
+
/** the entries appended, in order */ added: Bundle[];
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* The tools a turn is offered: the runner's own, or, where the turn's
|
|
199
|
+
* `sending.tools` names some, exactly those, each found among the runner's own
|
|
200
|
+
* and then among the ones it runs only by name, which are asked for only
|
|
201
|
+
* then. A name nothing answers to is left out.
|
|
202
|
+
*
|
|
203
|
+
* ```ts
|
|
204
|
+
* let tool = (name: string) =>
|
|
205
|
+
* ({ name, description: name, parameters: {}, run: () => name })
|
|
206
|
+
* offered([tool('shell')], () => [tool('memory_around')], ['memory_around'])
|
|
207
|
+
* .map((t) => t.name)
|
|
208
|
+
* // ['memory_around']
|
|
209
|
+
* ```
|
|
210
|
+
*/ export declare let offered: (own: Tool[], named: () => Tool[], names: unknown) => Tool[];
|
|
211
|
+
export declare let currentStatus: (g: Graph, session: Eid) => Promise<TranscriptStatus>;
|
|
212
|
+
/** What a step reads of its transcript and acts on: the newest entries and
|
|
213
|
+
* what they name (./reach.ts), a model turn's context and the window it sends,
|
|
214
|
+
* or for a step running one call (`Deps.runCall`) what its tool reads of the
|
|
215
|
+
* turn, never a window it does not send; and whether it was ended from outside
|
|
216
|
+
* (`session.ended`). Prose comes with every entry when the host reads entries
|
|
217
|
+
* of its own (`bodies`), and is loaded for the lines a turn sends alone
|
|
218
|
+
* otherwise. A model turn whose model continues from the newest answered ask
|
|
219
|
+
* reads from that ask on (`anchored` names it), and is read whole (`whole`)
|
|
220
|
+
* where the turn cannot continue from it after all. */ export type Reading = {
|
|
221
|
+
entries: Bundle[];
|
|
222
|
+
bodies: boolean;
|
|
223
|
+
ended: boolean;
|
|
224
|
+
forked?: boolean;
|
|
225
|
+
inheritedElision?: number;
|
|
226
|
+
session?: Eid;
|
|
227
|
+
anchored?: Eid;
|
|
228
|
+
began?: number;
|
|
229
|
+
};
|
|
230
|
+
/** A step's {@link Reading}, which a runner judges before handing it to
|
|
231
|
+
* {@link react}, so a pass reads its transcript once. The step acts on it
|
|
232
|
+
* while it stands: once a line has landed or the transcript has ended since
|
|
233
|
+
* (`moved`), the step reads again. */ export declare let reading: (g: Graph, session: Eid, deps: Deps, whole?: boolean) => Promise<Reading>;
|
|
234
|
+
export declare let retryingStep: (deps: Deps, error: unknown, session: Eid, phase: string) => ModelError | undefined;
|
|
235
|
+
export declare let react: (g: Graph, session: Eid, deps: Deps, read?: Reading, dropped?: boolean) => Promise<Step>;
|
|
236
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sources":["../react.ts"],"names":[],"mappings":"AAqBA,cAAc,SAAS,sBAAqB;AAC5C,cAAc,KAAK,iCAAsC;AACzD,cAAc,OAAO,2BAAgC;AACrD,SAAS,aAAa,SAAS,kCAAuC;AAGtE,SAAS,KAAK,KAAK,wBAAoC;AA8BvD,cAEE,MAAM,EACN,IAAI,EACJ,GAAG,EACH,KAAK,2BAEwB;AAC/B,SAGE,KAAK,QAAQ,EACb,KAAK,IAAI,EAMT,KAAK,KAAK,EACV,UAAU,EAOV,KAAK,OAAO,EAIZ,KAAK,QAAQ,QAAQ,2BAGQ;AAY/B,SAYE,KAAK,gBAAgB,qBAEJ;AAiBnB,SAAS,KAAK,EAAE,MAAM,uBAAsB;AAW5C,cAAc,OAAO,6BAAkC;AAGvD;;mEAEmE,GACnE,YAAY;EACV,SAAS;EACT,MAAM;EACN,SAAS;EACT,SAAS;EACT,0EAA0E,GAC1E,WAAW,OAAO;;AAmBpB;oBACoB,GACpB,SAAS,cAAc,uBAAsB;AAC7C,SAAS,UAAU,0BAAyB;AAG5C,SAAS,OAAO,EAAE,OAAO,uBAAsB;AAS/C;;YAEY,GACZ,YAAY,OAAO,MAAM;EAAK,MAAM,MAAM;EAAE,MAAM,OAAO,MAAM,EAAE;;AAMjE,oCAAoC,GACpC,OAAO,YAAI,UAAW,MAAM,SAAO,MAAM,CAAqB;AAY9D,mEAAmE,GACnE,YAAY,OAAO;EACjB;6DAC2D,GAC3D,QAAQ,MAAM;EACd;2DACyD,GACzD,OAAO;EACP,MACE,MAAM,OAAO,MAAM,EAAE,OAAO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AAI,eACT,MAAM,MACN,OAAO,OAAO,EACd,SAAS,KACT,OAAO,MAAM,KACZ,aAAa,SAAS,CAGV;AAwSf,OAAO,YAAI,QACT,GAAG,OACH,SAAS,KACT,MAAM,MACN,OAAO,SAEP,sBACC,QAAQ,MAwvDV"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { Limit } from "@yaks/model";
|
|
2
|
+
export type { Limit };
|
|
3
|
+
import { type Fixed } from "./parts.js";
|
|
4
|
+
/** One parsed line of a harness's log. */ export type Event = Record<string, unknown>;
|
|
5
|
+
/** The components of one entry, as a reader reports them. */ export type Comps = Record<string, Record<string, unknown>>;
|
|
6
|
+
/** What one line says. */ export type Said = {
|
|
7
|
+
/** the entries it becomes, in order */ entries: Comps[];
|
|
8
|
+
/** what it says about the session itself: the harness's own id for it */ about?: Comps;
|
|
9
|
+
/** when the harness wrote it, where the line says */ at?: string;
|
|
10
|
+
/** what it says about the fixed part every request carries (./parts.ts) */ fixed?: Fixed[];
|
|
11
|
+
/** what it says about the provider's plan limits */ limits?: Limit[];
|
|
12
|
+
/** the model it says answers the lines after it, by the model's own name */ model?: string;
|
|
13
|
+
/** a fragment of an entry the lines after it carry on, where a stream
|
|
14
|
+
* prints a reply in pieces: a run of parts of one `key` is one entry, at
|
|
15
|
+
* the line of its first, and any other line ends the run (./tail.ts) */ part?: {
|
|
16
|
+
key: string;
|
|
17
|
+
entry: Comps;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/** A harness's line format. */ export type Reader = (e: Event) => Said;
|
|
21
|
+
/**
|
|
22
|
+
* A reader whose plan limits are one account's: the account that keeps the
|
|
23
|
+
* transcript, or the one a run signs in with. A reading that names no account
|
|
24
|
+
* is a different row from the same plan's reading that names one.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { accounted, claude } from '@yaks/session'
|
|
28
|
+
* import { assertEquals } from '@std/assert'
|
|
29
|
+
*
|
|
30
|
+
* let week = { utilization: 0.25, resetsAt: 1794913200 }
|
|
31
|
+
* let line = { type: 'rate_limit_event', rate_limit_info: { unifiedWindows: { seven_day: week } } }
|
|
32
|
+
* assertEquals(accounted(claude, 'a')(line).limits?.[0].account, 'a')
|
|
33
|
+
* ```
|
|
34
|
+
*/ export declare let accounted: (read: Reader, account?: string) => Reader;
|
|
35
|
+
/**
|
|
36
|
+
* A credential's shape, redacted: a bearer or basic header, a vendor key, a
|
|
37
|
+
* JWT, an AWS key id, or a `key: value` assignment naming a secret. Ordinary
|
|
38
|
+
* output, code and prose pass through.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { scrub } from '@yaks/session'
|
|
42
|
+
* import { assertEquals } from '@std/assert'
|
|
43
|
+
*
|
|
44
|
+
* assertEquals(scrub('curl -H "Authorization: Bearer abc.def"'), 'curl -H "Authorization: [redacted]"')
|
|
45
|
+
* assertEquals(scrub('token=ghp_0123456789abcdef'), 'token=[redacted]')
|
|
46
|
+
* assertEquals(scrub('ls -la'), 'ls -la')
|
|
47
|
+
* assertEquals(scrub('value: yak_secret_example'), 'value: [set]')
|
|
48
|
+
* ```
|
|
49
|
+
*/ export declare let scrub: (s: string) => string;
|
|
50
|
+
/**
|
|
51
|
+
* Claude Code: the transcript it keeps of an interactive session
|
|
52
|
+
* (`~/.claude/projects/<project>/<session>.jsonl`), and the stream
|
|
53
|
+
* `claude -p --output-format stream-json` prints. The two share their message
|
|
54
|
+
* lines; the file adds the queue and the harness's own notes, and the stream
|
|
55
|
+
* adds the line that opens a run and the one that closes each turn. A side
|
|
56
|
+
* conversation, which older files keep inline and the stream marks with the
|
|
57
|
+
* call that started it, is a subagent's, read from its own transcript, not
|
|
58
|
+
* this session's. The stream also says how much of the plan's limits is used
|
|
59
|
+
* (`rate_limit_event`), whenever a window's percentage moves; an interactive
|
|
60
|
+
* session's file does not, and its status line is read instead
|
|
61
|
+
* (@yaks/spend). A line written from the graph to open a session in Claude
|
|
62
|
+
* Code names the entry it came from (`yak.entry`, ./resume.ts) and is read as
|
|
63
|
+
* nothing: it is that entry already.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { claude } from '@yaks/session'
|
|
67
|
+
* import { assertEquals } from '@std/assert'
|
|
68
|
+
*
|
|
69
|
+
* let typed = { type: 'user', origin: { kind: 'human' }, message: { content: 'hi' } }
|
|
70
|
+
* assertEquals(claude(typed).entries, [{ content: { body: 'hi' } }])
|
|
71
|
+
* let aside = { type: 'assistant', parent_tool_use_id: 'toolu_1', message: { content: 'done' } }
|
|
72
|
+
* assertEquals(claude(aside).entries, [])
|
|
73
|
+
* let ours = { ...typed, yak: { entry: 'e' } }
|
|
74
|
+
* assertEquals(claude(ours).entries, [])
|
|
75
|
+
* let week = { utilization: 0.25, resetsAt: 1794913200, status: 'allowed' }
|
|
76
|
+
* let metered = { type: 'rate_limit_event', rate_limit_info: { status: 'allowed', unifiedWindows: { seven_day: week } } }
|
|
77
|
+
* assertEquals(claude(metered).limits, [
|
|
78
|
+
* { provider: 'claude', window: 10080, used: 25, resets: '2026-11-17T11:00:00.000Z' },
|
|
79
|
+
* ])
|
|
80
|
+
* ```
|
|
81
|
+
*/ export declare let claude: Reader;
|
|
82
|
+
/**
|
|
83
|
+
* A Claude Code subagent's own transcript
|
|
84
|
+
* (`<project>/<session>/subagents/agent-<id>.jsonl`), every line of which is
|
|
85
|
+
* a side conversation of the session that started it.
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { subagent } from '@yaks/session'
|
|
89
|
+
* import { assertEquals } from '@std/assert'
|
|
90
|
+
*
|
|
91
|
+
* let said = { type: 'assistant', isSidechain: true, message: { content: 'done' } }
|
|
92
|
+
* assertEquals(subagent(said).entries, [{ content: { body: 'done' }, output: {} }])
|
|
93
|
+
* ```
|
|
94
|
+
*/ export declare let subagent: Reader;
|
|
95
|
+
/**
|
|
96
|
+
* Codex: the stream `codex exec --json` prints.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* import { codex } from '@yaks/session'
|
|
100
|
+
* import { assertEquals } from '@std/assert'
|
|
101
|
+
*
|
|
102
|
+
* let done = { type: 'item.completed', item: { type: 'agent_message', text: 'hi' } }
|
|
103
|
+
* assertEquals(codex(done).entries, [{ content: { body: 'hi' }, output: {} }])
|
|
104
|
+
* ```
|
|
105
|
+
*/ export declare let codex: Reader;
|
|
106
|
+
/**
|
|
107
|
+
* Grok Build's stream, `grok -p --output-format streaming-messages-json`:
|
|
108
|
+
* Claude Code's stream-json, read as {@link claude} reads it, except that a
|
|
109
|
+
* tool's result is the tool's own JSON. A shell call's and a search's are
|
|
110
|
+
* read as the text the model was shown (`output_for_prompt`, `stdout`); its
|
|
111
|
+
* history file (`grok`) keeps only that text.
|
|
112
|
+
*
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { grokStream } from '@yaks/session'
|
|
115
|
+
* import { assertEquals } from '@std/assert'
|
|
116
|
+
*
|
|
117
|
+
* let ran = JSON.stringify({ type: 'Bash', output: [104, 105], output_for_prompt: 'exit: 0\nhi' })
|
|
118
|
+
* let answer = { type: 'user', message: { content: [{ type: 'tool_result', tool_use_id: 'c1', content: ran }] } }
|
|
119
|
+
* assertEquals(grokStream(answer).entries, [
|
|
120
|
+
* { result: { call: 'c1' }, content: { body: 'exit: 0\nhi' }, execution: {} },
|
|
121
|
+
* ])
|
|
122
|
+
* let found = JSON.stringify({ type: 'GrepSearch', stdout: [70, 111, 117, 110, 100] })
|
|
123
|
+
* assertEquals(grokStream({ ...answer, message: { content: [{ type: 'tool_result', tool_use_id: 'c2', content: found }] } }).entries, [
|
|
124
|
+
* { result: { call: 'c2' }, content: { body: 'Found' }, execution: {} },
|
|
125
|
+
* ])
|
|
126
|
+
* ```
|
|
127
|
+
*/ export declare let grokStream: Reader;
|
|
128
|
+
/**
|
|
129
|
+
* Gemini CLI: the stream `gemini -p --output-format stream-json` prints. Its
|
|
130
|
+
* reply comes in fragments (`message` with `delta`), each a part of the entry
|
|
131
|
+
* the next tool call or the turn's end closes. The prompt it echoes is the
|
|
132
|
+
* session's own request already, and is read as nothing.
|
|
133
|
+
*
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { gemini } from '@yaks/session'
|
|
136
|
+
* import { assertEquals } from '@std/assert'
|
|
137
|
+
*
|
|
138
|
+
* let piece = { type: 'message', role: 'assistant', content: 'Hel', delta: true }
|
|
139
|
+
* assertEquals(gemini(piece).part, { key: 'reply', entry: { content: { body: 'Hel' }, output: {} } })
|
|
140
|
+
* let used = { type: 'tool_use', tool_name: 'read_file', tool_id: 't1', parameters: { file_path: 'a.ts' } }
|
|
141
|
+
* assertEquals(gemini(used).entries, [{ call: { to: 'read_file', id: 't1', args: { file_path: 'a.ts' } } }])
|
|
142
|
+
* let spent = { type: 'result', status: 'error', error: { message: 'You exceeded your current quota' } }
|
|
143
|
+
* assertEquals(gemini(spent).entries[0].refusal, { code: 'rate_limit' })
|
|
144
|
+
* ```
|
|
145
|
+
*/ export declare let gemini: Reader;
|
|
146
|
+
/**
|
|
147
|
+
* Antigravity CLI: the stream `agy --print --output-format stream-json`
|
|
148
|
+
* prints (antigravity.google/docs/cli/headless), an `init`, then a
|
|
149
|
+
* `step_update` per step as it runs and finishes, then the `result`. What
|
|
150
|
+
* the model says arrives as `text_delta` fragments of its `agent_response`
|
|
151
|
+
* step, each a part of that step's entry; a `tool` step finished carries
|
|
152
|
+
* its call and what it answered (`tool_info`). The result repeats the last
|
|
153
|
+
* reply whole (`response`), which its parts already said.
|
|
154
|
+
*
|
|
155
|
+
* ```ts
|
|
156
|
+
* import { antigravityStream } from '@yaks/session'
|
|
157
|
+
* import { assertEquals } from '@std/assert'
|
|
158
|
+
*
|
|
159
|
+
* let ran = { event: 'step_update', step_update: { step_index: 4, state: 'DONE', step_type: 'tool',
|
|
160
|
+
* tool_info: { name: 'run_command', parameters: { CommandLine: 'ls' }, output: 'a.ts' } } }
|
|
161
|
+
* assertEquals(antigravityStream(ran).entries.map((c) => c.call ?? c.result), [
|
|
162
|
+
* { to: 'run_command', id: 'step-4', args: { CommandLine: 'ls' } },
|
|
163
|
+
* { call: 'step-4' },
|
|
164
|
+
* ])
|
|
165
|
+
* ```
|
|
166
|
+
*/ export declare let antigravityStream: Reader;
|
|
167
|
+
/** The readers this package ships for the stream each harness prints when
|
|
168
|
+
* a run is managed (@yaks/spawn), by the harness's name. */ export declare let readers: Record<string, Reader>;
|
|
169
|
+
/** Codex's on-disk rollout format. Read messages from response_item so the
|
|
170
|
+
* event_msg mirrors never duplicate them. A using names the CLI runner and
|
|
171
|
+
* model; the importer resolves those names into graph identities. */ export declare let codexRollout: Reader;
|
|
172
|
+
/**
|
|
173
|
+
* Grok Build: the model's history it keeps of a session,
|
|
174
|
+
* `$GROK_HOME/sessions/<percent-encoded cwd>/<session>/chat_history.jsonl`,
|
|
175
|
+
* one `{type, content}` row per line. An assistant row names its model
|
|
176
|
+
* (`model_id`) and the calls it made (`tool_calls`: `{id, name, arguments}`,
|
|
177
|
+
* the arguments a JSON string), and a `tool_result` names the call it answers
|
|
178
|
+
* (`tool_call_id`). Reasoning that is only `encrypted_content` says nothing
|
|
179
|
+
* readable, and the rows carry no time. The session's `updates.jsonl` streams
|
|
180
|
+
* the same turns as Agent Client Protocol chunks; the history holds each
|
|
181
|
+
* message whole.
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* import { grok } from '@yaks/session'
|
|
185
|
+
* import { assertEquals } from '@std/assert'
|
|
186
|
+
*
|
|
187
|
+
* let asked = { type: 'assistant', content: 'Looking.', model_id: 'grok-4.6-build',
|
|
188
|
+
* tool_calls: [{ id: 'c1', name: 'read_file', arguments: '{"path":"a.ts"}' }] }
|
|
189
|
+
* assertEquals(grok(asked).entries, [
|
|
190
|
+
* { content: { body: 'Looking.' }, output: {} },
|
|
191
|
+
* { call: { to: 'read_file', id: 'c1', args: { path: 'a.ts' } } },
|
|
192
|
+
* ])
|
|
193
|
+
* assertEquals(grok(asked).model, 'grok-4.6-build')
|
|
194
|
+
* ```
|
|
195
|
+
*/ export declare let grok: Reader;
|
|
196
|
+
/**
|
|
197
|
+
* Antigravity CLI (`agy`): the steps of a conversation,
|
|
198
|
+
* `~/.gemini/antigravity-cli/brain/<conversation>/.system_generated/logs/transcript_full.jsonl`,
|
|
199
|
+
* one `{step_index, source, type, status, created_at, content}` per line. A
|
|
200
|
+
* `PLANNER_RESPONSE` carries what the model said, its `thinking` and the
|
|
201
|
+
* calls it made (`tool_calls`: `{name, args}`, with no id), and each call's
|
|
202
|
+
* outcome is the `GENERIC` step after it, in the order of the calls, its
|
|
203
|
+
* `status` `DONE`, `ERROR`, `INVALID` or `RUNNING`. A call is named by the
|
|
204
|
+
* step that answers it, and that step names its call too, so a call whose
|
|
205
|
+
* planner line was never read still has the call its result answers.
|
|
206
|
+
*
|
|
207
|
+
* ```ts
|
|
208
|
+
* import { antigravity } from '@yaks/session'
|
|
209
|
+
* import { assertEquals } from '@std/assert'
|
|
210
|
+
*
|
|
211
|
+
* let planned = { step_index: 3, type: 'PLANNER_RESPONSE', content: 'Reading it.',
|
|
212
|
+
* tool_calls: [{ name: 'view_file', args: { AbsolutePath: '/w/a.ts' } }] }
|
|
213
|
+
* assertEquals(antigravity(planned).entries, [
|
|
214
|
+
* { content: { body: 'Reading it.' }, output: {} },
|
|
215
|
+
* { call: { to: 'view_file', id: 'step-4', args: { AbsolutePath: '/w/a.ts' } } },
|
|
216
|
+
* ])
|
|
217
|
+
* let done = { step_index: 4, type: 'GENERIC', status: 'DONE', content: 'export {}' }
|
|
218
|
+
* assertEquals(antigravity(done).entries[1].result, { call: 'step-4' })
|
|
219
|
+
* ```
|
|
220
|
+
*/ export declare let antigravity: Reader;
|
|
221
|
+
//# sourceMappingURL=readers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readers.d.ts","sources":["../readers.ts"],"names":[],"mappings":"AAkCA,cAAc,KAAK,2BAAgC;AAEnD,cAAc,KAAK,GAAE;AACrB,SAAS,KAAK,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;;;CAwBC,GACD,OAAO,YAAI,aAAa,OAwCvB"}
|
package/_dist/reap.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Bundle, ReadTx, Storage } from "@yaks/graph";
|
|
2
|
+
/**
|
|
3
|
+
* The releases a graph needs: one `claim: null` bundle per lock whose holder
|
|
4
|
+
* is not a session in this graph. Reads only — hand the result to `apply()` if
|
|
5
|
+
* you want the release journaled and its effects fired.
|
|
6
|
+
*/ export declare let staleLeases: (tx: ReadTx) => Bundle[] | Promise<Bundle[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Free every lock whose holder is gone, and answer with what was freed. Call
|
|
9
|
+
* it once at start-up, before serving:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { reapLeases } from '@yaks/session'
|
|
13
|
+
* // let freed = reapLeases(storage)
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* The releases are written straight through storage, each its own unit of
|
|
17
|
+
* work, so a reap of fifty stale locks is not one transaction that must all
|
|
18
|
+
* land. A caller who wants them journaled instead can apply
|
|
19
|
+
* {@link staleLeases} through a graph.
|
|
20
|
+
*/ export declare let reapLeases: (storage: Storage) => Bundle[] | Promise<Bundle[]>;
|
|
21
|
+
//# sourceMappingURL=reap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reap.d.ts","sources":["../reap.ts"],"names":[],"mappings":"AAsBA,cAAc,MAAM,EAAO,MAAM,EAAE,OAAO,2BAAgC;AAK1E;;;;CAIC,GACD,OAAO,YAAI,cAAe,IAAI,WAAS,WAAW,QAAQ,UAUtD;AAEJ;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,aAAc,SAAS,YAAU,WAAW,QAAQ,UAM9D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Bundle, Eid, Graph } from "@yaks/graph";
|
|
2
|
+
import type { Host, Meaning } from "@yaks/host";
|
|
3
|
+
import type { Floors } from "@yaks/memory/earlier";
|
|
4
|
+
/** How long words wait for what was said before, before going without it. */ export declare let RECALL: number;
|
|
5
|
+
/** What a host recalls with: its person, and its ranking by meaning. */ export type Recalling = {
|
|
6
|
+
graph: Graph;
|
|
7
|
+
config?: {
|
|
8
|
+
person?: string;
|
|
9
|
+
};
|
|
10
|
+
meaning?: Meaning;
|
|
11
|
+
/** how near its meaning's model puts what is recalled, where it is not the
|
|
12
|
+
* model @yaks/memory's floors were measured on */ floors?: Floors;
|
|
13
|
+
report?: Host['report'];
|
|
14
|
+
};
|
|
15
|
+
/** What sets beside a person's words what they said before. */ export type Beside = <T extends {
|
|
16
|
+
item: Bundle;
|
|
17
|
+
line: string;
|
|
18
|
+
}>(owed: T[]) => Promise<T[]>;
|
|
19
|
+
/** Whose words a recall answers, and for which session's model. */ export type Saying = {
|
|
20
|
+
/** who said them, where not the host's person */ by?: string;
|
|
21
|
+
/** the session whose model is given what is recalled: what it still has in
|
|
22
|
+
* front of it (its own lines since its newest checkpoint) is left out */ session?: Eid;
|
|
23
|
+
};
|
|
24
|
+
/** A host's recall. */ export type Recall = {
|
|
25
|
+
/** what the host's person (or `by`) said before `before` on the subject of
|
|
26
|
+
* `words`, beyond what `session` already holds */ said: (words: string, before: string, o?: Saying) => Promise<string>;
|
|
27
|
+
/** these items, with it under the line of each one the person wrote where
|
|
28
|
+
* there is any */ beside: Beside;
|
|
29
|
+
};
|
|
30
|
+
/** A host's recall, each given `wait` ms; a null `wait` waits as long as it
|
|
31
|
+
* takes. */ export declare let recall: (host: Recalling, wait?: number | null) => Recall;
|
|
32
|
+
//# sourceMappingURL=recall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.d.ts","sources":["../recall.ts"],"names":[],"mappings":"AAUA,cAAc,MAAM,EAAQ,GAAG,EAAE,KAAK,2BAAgC;AACtE,cAAc,IAAI,EAAE,OAAO,0BAA+B;AAC1D,cAAc,MAAM,oCAAyC;AAG7D,2EAA2E,GAC3E,OAAO,YAAI,eAAY;AAEvB,sEAAsE,GACtE,YAAY;EACV,OAAO;EACP;IAAW,SAAS,MAAM;;EAC1B,UAAU;EACV;kDACgD,GAChD,SAAS;EACT,SAAS,KAAK;;AAKhB,6DAA6D,GAC7D,YAAY,UAAU;EAAY,MAAM;EAAQ,MAAM,MAAM;GAC1D,MAAM,QACH,QAAQ;AAEb,iEAAiE,GACjE,YAAY;EACV,+CAA+C,GAC/C,KAAK,MAAM;EACX;yEACuE,GACvE,UAAU;;AAGZ,qBAAqB,GACrB,YAAY;EACV;kDACgD,GAChD,OAAO,OAAO,MAAM,EAAE,QAAQ,MAAM,EAAE,IAAI,WAAW,QAAQ,MAAM;EACnE;kBACgB,GAChB,QAAQ;;AAiBV;UACU,GACV,OAAO,YAAI,SACT,MAAM,WACN,OAAM,MAAM,GAAG,IAAI,KAClB,OAuCF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Host } from "@yaks/host";
|
|
2
|
+
import type { Authenticate, Route } from "@yaks/api";
|
|
3
|
+
import { type Door } from "./bus.js";
|
|
4
|
+
import type { Runner } from "@yaks/tools";
|
|
5
|
+
import { RECALL, type Recalling } from "./recall.js";
|
|
6
|
+
export { RECALL };
|
|
7
|
+
/** Where the harness posts its hook events. */ export declare let PATH: string;
|
|
8
|
+
/** Where Claude Code's status line posts what it was handed. */ export declare let STATUS: string;
|
|
9
|
+
/** `POST /session/hook`: one hook event in, the context it adds out. */ export declare let routes: (host: Door & Recalling & {
|
|
10
|
+
who?: Authenticate;
|
|
11
|
+
runner?: Runner;
|
|
12
|
+
text?: Host['text'];
|
|
13
|
+
tailText?: Host['tailText'];
|
|
14
|
+
}, _dts_1: never) => Route[];
|
|
15
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sources":["../routes.ts"],"names":[],"mappings":"AAuBA,cAAc,IAAI,0BAA+B;AACjD,cAAc,YAAY,EAAE,KAAK,yBAA8B;AAC/D,SAAS,KAAK,IAAI,mBAAoC;AAEtD,cAAc,MAAM,2BAAgC;AAGpD,SAAS,MAAM,EAAU,KAAK,SAAS,sBAAqB;AAI5D,SAAS,MAAM,GAAE;AAEjB,6CAA6C,GAC7C,OAAO,YAAI,aAAsB;AAEjC,8DAA8D,GAC9D,OAAO,YAAI,eAA0B;AAarC,sEAAsE,GACtE,OAAO,YAAI,SACT,MAAM,OAAO;EACX,MAAM;EACN,SAAS;EACT,OAAO,KAAK;EACZ,WAAW,KAAK;GAElB,kBACC,QAoFF"}
|
package/_dist/run.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Handlers } from "@yaks/effects";
|
|
2
|
+
import type { Bundle, Comp, Eid, Graph } from "@yaks/graph";
|
|
3
|
+
import { type ChildLimits } from "./children.js";
|
|
4
|
+
import { type Deps, type Step } from "./react.js";
|
|
5
|
+
/** What a host lends the runner: how a step is taken (./react.ts `Deps`), the
|
|
6
|
+
* bound on children, and who is running it. */ export type Runner = Deps & ChildLimits & {
|
|
7
|
+
/** the process running it: what a transcript's lease names as its holder,
|
|
8
|
+
* so it must be an entity in the graph */ holder: Eid;
|
|
9
|
+
/** whether this host answers a transcript asking with this `using`
|
|
10
|
+
* (./providers.ts `answers`); one it does not is left to whoever does */ answers?: (using: Comp | undefined, session?: Eid) => boolean | Promise<boolean>;
|
|
11
|
+
/** how long a transcript this host does not answer yet waits before
|
|
12
|
+
* `answers` is asked again (ms, a second where absent) */ waiting?: number;
|
|
13
|
+
/** each step, as it lands */ each?: (step: Step, session?: string) => void | Promise<void>;
|
|
14
|
+
/** Reconcile a settled reply before terminal delivery. True when it
|
|
15
|
+
* queued another turn. Replayed along with terminal delivery. */ recoverSettled?: (session: Eid) => Promise<boolean>;
|
|
16
|
+
/** a transcript that ended (settled, failed or stopped), however it did: a
|
|
17
|
+
* step's end, or a stop written while it rested. Told again on a later pass
|
|
18
|
+
* that finds it ended, so what it does is idempotent (./answer.ts
|
|
19
|
+
* `answerOf` reads its answer). */ ended?: (session: Eid) => Promise<void>;
|
|
20
|
+
/** a reply said while newer words wait, so the turn carries on to them:
|
|
21
|
+
* what the reply answers goes back now, read as `ended`'s is (./answer.ts
|
|
22
|
+
* `answerOf`), and the newer words are the next reply's */ replied?: (session: Eid) => Promise<void>;
|
|
23
|
+
/** reconcile borrowed resources after this pass releases its lease */ idle?: (session: Eid) => Promise<void>;
|
|
24
|
+
/** how long a transcript's lease stands between renewals (ms) */ hold?: number;
|
|
25
|
+
/** whether a holder of a transcript's lease is known to have ended without
|
|
26
|
+
* letting go, so its run is had now (@yaks/effects `HoldOpts.gone`) */ gone?: (holder: Eid) => boolean | Promise<boolean>;
|
|
27
|
+
/** how often a running step looks for a withdrawal of its request (ms) */ look?: number;
|
|
28
|
+
};
|
|
29
|
+
/** What a transcript's lease is named under: `@yaks/session/run/<eid>`. */ export declare let RUN: string;
|
|
30
|
+
/**
|
|
31
|
+
* Run a transcript until it has nothing more to do: every step it is owed,
|
|
32
|
+
* under its lease. Where this process is already running it, the pass going
|
|
33
|
+
* looks again when it is done, and this answers when that pass does; where
|
|
34
|
+
* another process holds it, this answers at once.
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { settle } from '@yaks/session'
|
|
38
|
+
*
|
|
39
|
+
* // await settle(graph, session, { holder: me, model, tools })
|
|
40
|
+
* ```
|
|
41
|
+
*/ export declare let settle: (g: Graph, session: Eid, r: Runner) => Promise<void>;
|
|
42
|
+
/** Whether a transcript is being run by this process right now. */ export declare let runningHere: (g: Graph, session: Eid) => boolean;
|
|
43
|
+
/** Whether a native pass still owns work, here or in another process. */ export declare let runningAt: (g: Graph, session: Eid) => Promise<boolean>;
|
|
44
|
+
/** The pass this process is running over a transcript, to wait on, if any. */ export declare let passing: (g: Graph, session: Eid) => Promise<void> | undefined;
|
|
45
|
+
/** Whether this runner answers a transcript: it asked for turns (a `using` or
|
|
46
|
+
* an `ask` on an entry), and its `using` in force names a provider the runner
|
|
47
|
+
* was lent a model for. */ export declare let answering: (g: Graph, session: Eid, r: Runner) => Promise<boolean>;
|
|
48
|
+
/** Answer a transcript's request for a turn here, where this host answers the
|
|
49
|
+
* provider it asks for: {@link settle} it, or, where this process is already
|
|
50
|
+
* running it, have that pass look again (without waiting on it, since the
|
|
51
|
+
* pass may be what is asking; whoever started the pass hears how it ends). */ export declare let answer: (g: Graph, session: Eid, r: Runner) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Let go of the claims a transcript whose run is over holds, except those a
|
|
54
|
+
* managed run that ended cleanly (`row`, its process, exit and stop) is parked
|
|
55
|
+
* on: a task still waiting on a dependency, or every one while a request
|
|
56
|
+
* waits for its next run. What `session_release` does once a transcript
|
|
57
|
+
* stops, for a host that runs no effects of this package's (@yaks/spawn
|
|
58
|
+
* ./machines.ts, ending a run a developer's machine handed back).
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { letGo } from '@yaks/session'
|
|
62
|
+
*
|
|
63
|
+
* // await letGo(graph, session, row)
|
|
64
|
+
* ```
|
|
65
|
+
*/ export declare let letGo: (g: Graph, session: Eid, row?: Bundle) => Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* The code behind `session_run`, for a host's `./effects` facet: every
|
|
68
|
+
* transcript write owes one leased step, where this host answers its provider.
|
|
69
|
+
* The runner may still be on its way (a harness loading the providers its
|
|
70
|
+
* config names); each run waits for it. `scope` gives the runner one
|
|
71
|
+
* transcript is answered with, for its steps, its background calls and its
|
|
72
|
+
* results alike (the harness's isolation of sessions outside words started).
|
|
73
|
+
* Without a durable pool, a standalone consumer uses {@link settle}.
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { answers, running } from '@yaks/session'
|
|
77
|
+
*
|
|
78
|
+
* // export let effects = (host) => running(host.graph, { holder: host.me, … })
|
|
79
|
+
* ```
|
|
80
|
+
*/ export declare let running: (g: Graph, runner: Runner | Promise<Runner>, scope?: (session: Eid, runner: Runner) => Runner | Promise<Runner>) => Handlers;
|
|
81
|
+
//# sourceMappingURL=run.d.ts.map
|