@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/project.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// The model's view of a transcript: the items a request carries, made from
|
|
2
|
+
// entries. A step projects the whole transcript it sends, so this runs once
|
|
3
|
+
// per request over every line a long session holds; it is linear in the
|
|
4
|
+
// transcript, never a pass over it per ask or per result.
|
|
5
|
+
import { message } from "@yaks/model";
|
|
6
|
+
import { source } from "./source.js";
|
|
7
|
+
import { ASK, CALL, OUTPUT, RESULT } from "./native.js";
|
|
8
|
+
import { kindOf, ordered, seqOf, textOf } from "./state.js";
|
|
9
|
+
import { items as taskItems } from "./task-context.js";
|
|
10
|
+
import { took } from "./timing.js";
|
|
11
|
+
let comp = (b, name)=>b?.[name];
|
|
12
|
+
/** What a background call (`tool_async`) answers while it runs: its interim
|
|
13
|
+
* result, paired with the call like any other, and saying what it means where
|
|
14
|
+
* the model reads it. A request derives it from the call; a call that outlasts
|
|
15
|
+
* its patience is also given it as an entry (`tool_progress`, ./react.ts), the
|
|
16
|
+
* new line that lets the model take a turn while it runs. The final arrives
|
|
17
|
+
* later, naming its call ({@link project}). */ export let PENDING = 'Pending; its result will follow.';
|
|
18
|
+
/** What closes a request whose conversation ends on the agent's own words,
|
|
19
|
+
* such as a voice's on a call said outside a model turn (`notice.own`):
|
|
20
|
+
* asked to go on from its own words, a model would finish them, and some
|
|
21
|
+
* refuse to (Anthropic's "must end with a user message"). */ export let TURN = 'Nothing has been said since your words above; this is ' + 'your turn.';
|
|
22
|
+
/// let said = { kind: 'assistant' as const, text: 'One moment.' }
|
|
23
|
+
/// let asked = { kind: 'user' as const, text: 'Add a recipe.' }
|
|
24
|
+
/// closed([asked, said]) -> [asked, said, { kind: 'instruction', text: 'From the system:\n' + TURN }]
|
|
25
|
+
/// closed([said, asked]) -> [said, asked]
|
|
26
|
+
/** A request's items as a turn the model takes: ending on its own words, they
|
|
27
|
+
* are closed by {@link TURN}, so every line stays where it was said and the
|
|
28
|
+
* model answers rather than continues. */ export let closed = (items)=>items.at(-1)?.kind == 'assistant' ? [
|
|
29
|
+
...items,
|
|
30
|
+
message({
|
|
31
|
+
kind: 'instruction',
|
|
32
|
+
text: TURN
|
|
33
|
+
}, 'the system')
|
|
34
|
+
] : items;
|
|
35
|
+
// The call an entry answers: a final's or a Pending's.
|
|
36
|
+
let answers = (b)=>comp(b, RESULT)?.call ?? comp(b, 'tool_progress')?.call;
|
|
37
|
+
let clip = (text, max = 120)=>text.length > max ? text.slice(0, max) + '…' : text;
|
|
38
|
+
// The ask an entry answers: an output's or a call's source, or for a call's
|
|
39
|
+
// progress, the source of that call.
|
|
40
|
+
let sourceOf = (b, byId)=>comp(b, OUTPUT)?.source ?? comp(b, CALL)?.source ?? comp(byId.get(String(comp(b, 'tool_progress')?.call)), CALL)?.source;
|
|
41
|
+
// The index of the first of ascending `seqs` at or past `seq`.
|
|
42
|
+
let reaching = (seqs, seq)=>{
|
|
43
|
+
let lo = 0, hi = seqs.length;
|
|
44
|
+
while(lo < hi){
|
|
45
|
+
let mid = lo + hi >> 1;
|
|
46
|
+
if (seqs[mid] < seq) lo = mid + 1;
|
|
47
|
+
else hi = mid;
|
|
48
|
+
}
|
|
49
|
+
return lo;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Each reply moved to just after the line its ask was sent through
|
|
53
|
+
* (`ask.through`), asks taken oldest first; a reply whose boundary is not
|
|
54
|
+
* among `lines` stays where it is. A reply is its entries in their order in
|
|
55
|
+
* `lines`. The list is linked by index, so every move costs the reply's own
|
|
56
|
+
* length.
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { replied } from './project.ts'
|
|
60
|
+
* let e = (eid: string, more = {}) => ({ entity: { eid }, ...more })
|
|
61
|
+
* let lines = [
|
|
62
|
+
* e('in'),
|
|
63
|
+
* e('late'), // landed while the ask was answered
|
|
64
|
+
* e('out', { output: { source: 'ask' } }),
|
|
65
|
+
* ]
|
|
66
|
+
* let asks = [e('ask', { ask: { through: 'in' } })]
|
|
67
|
+
* replied(asks, lines, new Map()).map((b) => b.entity.eid)
|
|
68
|
+
* // -> ['in', 'out', 'late']
|
|
69
|
+
* ```
|
|
70
|
+
*/ export let replied = (asks, lines, byId)=>{
|
|
71
|
+
let n = lines.length;
|
|
72
|
+
// Node n is the head; next and prev make a ring through it.
|
|
73
|
+
let next = new Int32Array(n + 1), prev = new Int32Array(n + 1);
|
|
74
|
+
for(let i = 0; i <= n; i++){
|
|
75
|
+
next[i] = (i + 1) % (n + 1);
|
|
76
|
+
prev[i] = (i + n) % (n + 1);
|
|
77
|
+
}
|
|
78
|
+
let at = new Map();
|
|
79
|
+
let replies = new Map();
|
|
80
|
+
lines.forEach((b, i)=>{
|
|
81
|
+
if (!at.has(b.entity.eid)) at.set(b.entity.eid, i);
|
|
82
|
+
let source = sourceOf(b, byId);
|
|
83
|
+
if (source == null) return;
|
|
84
|
+
let reply = replies.get(String(source));
|
|
85
|
+
if (reply) reply.push(i);
|
|
86
|
+
else replies.set(String(source), [
|
|
87
|
+
i
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
for (let ask of asks){
|
|
91
|
+
let reply = replies.get(ask.entity.eid);
|
|
92
|
+
let boundary = at.get(String(comp(ask, ASK)?.through));
|
|
93
|
+
if (!reply || boundary == null || reply.includes(boundary)) continue;
|
|
94
|
+
for (let i of reply){
|
|
95
|
+
next[prev[i]] = next[i];
|
|
96
|
+
prev[next[i]] = prev[i];
|
|
97
|
+
}
|
|
98
|
+
let cursor = boundary;
|
|
99
|
+
for (let i of reply){
|
|
100
|
+
next[i] = next[cursor];
|
|
101
|
+
prev[i] = cursor;
|
|
102
|
+
prev[next[cursor]] = i;
|
|
103
|
+
next[cursor] = i;
|
|
104
|
+
cursor = i;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
let out = [];
|
|
108
|
+
for(let i = next[n]; i != n; i = next[i])out.push(lines[i]);
|
|
109
|
+
return out;
|
|
110
|
+
};
|
|
111
|
+
/** The model's view of a window of the transcript: inputs as user turns, what
|
|
112
|
+
* the model returned as assistant turns, tool calls and results as the pair a
|
|
113
|
+
* model expects. The full transcript resolves a result's call even when that
|
|
114
|
+
* call is outside the window. Ask entries are our record, not the model's;
|
|
115
|
+
* what the anchored reply itself said and the tool calls it asked for are
|
|
116
|
+
* already in the provider's state, so only the calls' results travel.
|
|
117
|
+
*
|
|
118
|
+
* Each call's answer (its Pending where a request sent one, else its final)
|
|
119
|
+
* follows the reply's last call, in the order of the calls, whatever order
|
|
120
|
+
* they landed in: many models pair a result with its call by position, never
|
|
121
|
+
* by id (GLM's chat template renders `<tool_response>` blocks in order and
|
|
122
|
+
* no ids). A final whose Pending a request already sent stays where it
|
|
123
|
+
* landed, and names its call by tool, id and arguments.
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* import { project } from './project.ts'
|
|
127
|
+
* let n = 0
|
|
128
|
+
* let e = (comps: Record<string, unknown>) =>
|
|
129
|
+
* ({ entity: { eid: `e${++n}` }, entry: { session: 's', seq: n }, ...comps })
|
|
130
|
+
* let ask = (through: string) => e({ ask: { through } })
|
|
131
|
+
* let call = (id: string) =>
|
|
132
|
+
* e({ call: { to: 'echo', id, args: { id }, source: 'e2' }, tool_async: {} })
|
|
133
|
+
* let tools = new Map([
|
|
134
|
+
* ['echo', { name: 'echo', description: 'Echoes its id.', parameters: {} }],
|
|
135
|
+
* ])
|
|
136
|
+
* let entries = [
|
|
137
|
+
* e({ content: { body: 'go' } }), ask('e1'), call('a'), call('b'),
|
|
138
|
+
* e({ result: { call: 'e4' }, content: { body: 'B' } }), // landed first
|
|
139
|
+
* ask('e5'), // sent b's final and a's Pending
|
|
140
|
+
* e({ result: { call: 'e3' }, content: { body: 'A' } }),
|
|
141
|
+
* ]
|
|
142
|
+
* project(entries, entries, tools).map((i) =>
|
|
143
|
+
* i.kind == 'call'
|
|
144
|
+
* ? i.id
|
|
145
|
+
* : i.kind == 'result'
|
|
146
|
+
* ? i.output
|
|
147
|
+
* : 'text' in i
|
|
148
|
+
* ? i.text
|
|
149
|
+
* : i.label
|
|
150
|
+
* )
|
|
151
|
+
* // -> ['From an unknown sender:\ngo', 'a', 'b', 'From the system:\nPending; its result will follow.', 'From the echo tool:\nB',
|
|
152
|
+
* // 'From the echo tool:\nThe pending echo call a {"id":"a"} finished:\nA']
|
|
153
|
+
* ```
|
|
154
|
+
*/ export let project = (transcript, window, tools, opts = {})=>{
|
|
155
|
+
let out = [];
|
|
156
|
+
let receiver = opts.session ?? comp(window.at(-1), 'entry')?.session;
|
|
157
|
+
let inherited = (b)=>{
|
|
158
|
+
let author = comp(b, 'entry')?.session;
|
|
159
|
+
return receiver && author && receiver != author ? 'your parent session' : undefined;
|
|
160
|
+
};
|
|
161
|
+
let byId = new Map(transcript.map((b)=>[
|
|
162
|
+
b.entity.eid,
|
|
163
|
+
b
|
|
164
|
+
]));
|
|
165
|
+
let asks = ordered(transcript).filter((b)=>b.ask);
|
|
166
|
+
// A tool can finish (or a person steer) while the provider is answering.
|
|
167
|
+
// Those entries were not in that request. Keep its response immediately
|
|
168
|
+
// after its frozen boundary, then append the unsent updates. Never move or
|
|
169
|
+
// replace a previously submitted running result: the next full-context
|
|
170
|
+
// request must extend the previous request + response byte-for-byte.
|
|
171
|
+
let bounds = asks.map((ask)=>seqOf(byId.get(String(comp(ask, ASK)?.through)) ?? ask)).sort((a, b)=>a - b);
|
|
172
|
+
let finals = new Set(window.flatMap((b)=>b.result ? [
|
|
173
|
+
String(comp(b, RESULT)?.call)
|
|
174
|
+
] : []));
|
|
175
|
+
// Each call's final, and the seqs of its Pending entries: one written when
|
|
176
|
+
// it outlasted its patience, or, in older transcripts, beside every
|
|
177
|
+
// background call.
|
|
178
|
+
let landed = new Map();
|
|
179
|
+
let progress = new Map();
|
|
180
|
+
for (let b of transcript){
|
|
181
|
+
if (b.result) landed.set(String(comp(b, RESULT)?.call), seqOf(b));
|
|
182
|
+
let call = comp(b, 'tool_progress')?.call;
|
|
183
|
+
if (call == null) continue;
|
|
184
|
+
let seqs = progress.get(String(call));
|
|
185
|
+
if (seqs) seqs.push(seqOf(b));
|
|
186
|
+
else progress.set(String(call), [
|
|
187
|
+
seqOf(b)
|
|
188
|
+
]);
|
|
189
|
+
}
|
|
190
|
+
// A fast tool needs only its final answer. A request sent a Pending when its
|
|
191
|
+
// boundary reached the Pending but not yet its final; one that reached both
|
|
192
|
+
// sent the final alone. Keep a sent Pending: that immutable prefix cannot be
|
|
193
|
+
// rewritten afterwards, and a Pending no request sent is never sent late.
|
|
194
|
+
// The first boundary at or past the Pending decides it. A background call's
|
|
195
|
+
// Pending stands at the call, and at each Pending entry it has.
|
|
196
|
+
let sent = (call, seq)=>(bounds[reaching(bounds, seq)] ?? Infinity) < (landed.get(call) ?? Infinity);
|
|
197
|
+
let pendings = (call)=>{
|
|
198
|
+
let b = byId.get(call);
|
|
199
|
+
return [
|
|
200
|
+
...progress.get(call) ?? [],
|
|
201
|
+
...b?.tool_async ? [
|
|
202
|
+
seqOf(b)
|
|
203
|
+
] : []
|
|
204
|
+
];
|
|
205
|
+
};
|
|
206
|
+
let logical = replied(asks, window.filter((b)=>{
|
|
207
|
+
let call = comp(b, 'tool_progress')?.call;
|
|
208
|
+
return call == null || sent(String(call), seqOf(b)) || !finals.has(String(call));
|
|
209
|
+
}), byId);
|
|
210
|
+
let recaps = logical.filter((b)=>comp(b, 'prompt')?.scope == 'recap');
|
|
211
|
+
if (recaps.length) {
|
|
212
|
+
logical = logical.filter((b)=>!recaps.includes(b));
|
|
213
|
+
let at = logical.findIndex((b)=>!b.prompt && !b.checkpoint && !b.task_context);
|
|
214
|
+
logical.splice(at < 0 ? logical.length : at, 0, ...recaps);
|
|
215
|
+
}
|
|
216
|
+
// A final that follows a Pending some request sent: the call was answered.
|
|
217
|
+
let late = (b, call)=>!!b.result && pendings(call).some((seq)=>seq < seqOf(b) && sent(call, seq));
|
|
218
|
+
// A background call nothing in the window answers: its derived Pending
|
|
219
|
+
// travels where a request sent it, or while its final has not landed.
|
|
220
|
+
let pending = (call)=>!!call.tool_async && (sent(call.entity.eid, seqOf(call)) || !finals.has(call.entity.eid));
|
|
221
|
+
let spelled = (call)=>{
|
|
222
|
+
let c = comp(call, CALL);
|
|
223
|
+
return {
|
|
224
|
+
id: String(c.id ?? ''),
|
|
225
|
+
name: tools.get(String(c.to))?.name ?? String(c.name ?? 'tool'),
|
|
226
|
+
args: c.args == null ? textOf(call) || '{}' : JSON.stringify(c.args)
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
// Each call's answer, and the calls of each reply, in order: an anchored
|
|
230
|
+
// reply's calls are the provider's already, yet their answers travel.
|
|
231
|
+
let answer = new Map();
|
|
232
|
+
let replies = new Map();
|
|
233
|
+
for (let b of logical){
|
|
234
|
+
let call = answers(b);
|
|
235
|
+
if (call != null && !late(b, String(call)) && !answer.has(String(call))) {
|
|
236
|
+
answer.set(String(call), b);
|
|
237
|
+
}
|
|
238
|
+
let c = comp(b, CALL);
|
|
239
|
+
if (kindOf(b) != 'call') continue;
|
|
240
|
+
let reply = replies.get(String(c?.source));
|
|
241
|
+
if (reply) reply.push(b);
|
|
242
|
+
else replies.set(String(c?.source), [
|
|
243
|
+
b
|
|
244
|
+
]);
|
|
245
|
+
}
|
|
246
|
+
let index = new Map(logical.map((b, at)=>[
|
|
247
|
+
b,
|
|
248
|
+
at
|
|
249
|
+
]));
|
|
250
|
+
let taken = new Set();
|
|
251
|
+
let emit = (b)=>{
|
|
252
|
+
taken.add(b);
|
|
253
|
+
let kind = kindOf(b);
|
|
254
|
+
let c = comp(b, CALL);
|
|
255
|
+
if (b.prompt || b.checkpoint || b.task_context) {
|
|
256
|
+
if (b.checkpoint && !opts.history) {
|
|
257
|
+
out.push(...taskItems(b.checkpoint.tasks ?? {}));
|
|
258
|
+
}
|
|
259
|
+
let scope = comp(b, 'prompt')?.scope;
|
|
260
|
+
if (scope == 'recap') {
|
|
261
|
+
out.push(message({
|
|
262
|
+
kind: 'user',
|
|
263
|
+
text: textOf(b)
|
|
264
|
+
}, 'earlier in this conversation'));
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
let items = scope == 'turn' && opts.turnItems ? opts.turnItems : out;
|
|
268
|
+
items.push(message({
|
|
269
|
+
kind: 'instruction',
|
|
270
|
+
text: textOf(b)
|
|
271
|
+
}, source(b)));
|
|
272
|
+
} else if (kind == 'input') {
|
|
273
|
+
let input = opts.inputText?.(b) ?? textOf(b);
|
|
274
|
+
out.push(message({
|
|
275
|
+
kind: 'user',
|
|
276
|
+
text: typeof input == 'string' ? input : input.text
|
|
277
|
+
}, (typeof input == 'string' ? undefined : input.from) ?? source(b)));
|
|
278
|
+
} else if (kind == 'output') {
|
|
279
|
+
if (opts.anchor && comp(b, 'output')?.source == opts.anchor) return;
|
|
280
|
+
out.push(message({
|
|
281
|
+
kind: 'assistant',
|
|
282
|
+
text: textOf(b)
|
|
283
|
+
}, comp(b, 'entry')?.from ?? inherited(b)));
|
|
284
|
+
} else if (kind == 'call' && (!opts.anchor || c?.source != opts.anchor)) {
|
|
285
|
+
if (inherited(b) && replies.get(String(c?.source))?.[0] == b) {
|
|
286
|
+
out.push(message({
|
|
287
|
+
kind: 'instruction',
|
|
288
|
+
text: 'The following tool calls were made by your parent session in the inherited conversation.'
|
|
289
|
+
}, 'the system'));
|
|
290
|
+
}
|
|
291
|
+
out.push({
|
|
292
|
+
kind: 'call',
|
|
293
|
+
...spelled(b)
|
|
294
|
+
});
|
|
295
|
+
} else if (kind == 'result') {
|
|
296
|
+
let eid = String(answers(b));
|
|
297
|
+
let call = byId.get(eid);
|
|
298
|
+
if (!call?.call) {
|
|
299
|
+
throw new Error(`Result ${b.entity.eid} references missing call ${eid}`);
|
|
300
|
+
}
|
|
301
|
+
let text = opts.results?.get(b.entity.eid) ?? textOf(b);
|
|
302
|
+
let ms = comp(b, RESULT)?.ms;
|
|
303
|
+
let output = typeof ms == 'number' ? took(text, ms) : text;
|
|
304
|
+
let from = source(b) ?? (spelled(call).name == 'tool' ? 'the tool' : `the ${spelled(call).name} tool`);
|
|
305
|
+
let { id, name, args } = spelled(call);
|
|
306
|
+
if (late(b, eid)) {
|
|
307
|
+
// Strict routes take one tool output per call; the rest take it again.
|
|
308
|
+
let named = `The pending ${name} call ${id} ${clip(args)} finished:\n` + output;
|
|
309
|
+
out.push(opts.resultUpdatesAsUser ? message({
|
|
310
|
+
kind: 'user',
|
|
311
|
+
text: named
|
|
312
|
+
}, from) : message({
|
|
313
|
+
kind: 'result',
|
|
314
|
+
id,
|
|
315
|
+
output: named
|
|
316
|
+
}, from));
|
|
317
|
+
} else out.push(message({
|
|
318
|
+
kind: 'result',
|
|
319
|
+
id,
|
|
320
|
+
output
|
|
321
|
+
}, from));
|
|
322
|
+
}
|
|
323
|
+
out.push(...(opts.media?.get(b.entity.eid) ?? []).map((item)=>message(item, item.from ?? 'the attached document')));
|
|
324
|
+
};
|
|
325
|
+
let emitting = (b)=>{
|
|
326
|
+
let start = out.length;
|
|
327
|
+
emit(b);
|
|
328
|
+
opts.projected?.(b, out.slice(start));
|
|
329
|
+
};
|
|
330
|
+
logical.forEach((b, at)=>{
|
|
331
|
+
if (taken.has(b)) return;
|
|
332
|
+
emitting(b);
|
|
333
|
+
let reply = replies.get(String(comp(b, CALL)?.source));
|
|
334
|
+
if (reply?.at(-1) != b) return;
|
|
335
|
+
for (let call of reply){
|
|
336
|
+
let a = answer.get(call.entity.eid);
|
|
337
|
+
if (a) {
|
|
338
|
+
if (!taken.has(a) && index.get(a) > at) emitting(a);
|
|
339
|
+
} else if (pending(call)) {
|
|
340
|
+
let item = message({
|
|
341
|
+
kind: 'result',
|
|
342
|
+
id: spelled(call).id,
|
|
343
|
+
output: PENDING
|
|
344
|
+
}, 'the system');
|
|
345
|
+
out.push(item);
|
|
346
|
+
opts.projected?.(call, [
|
|
347
|
+
item
|
|
348
|
+
]);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
return out;
|
|
353
|
+
};
|
|
354
|
+
//# sourceMappingURL=project.js.map
|
package/project.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sources":["./project.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,0DAA0D;AAG1D,SAAoB,OAAO,2BAAuD;AAClF,SAAyB,MAAM,sBAAqB;AACpD,SAAS,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,sBAAqB;AACvD,SAAS,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAoB;AAC3D,SAAS,SAAS,SAAS,4BAAuC;AAClE,SAAS,IAAI,sBAAqB;AAElC,IAAI,OAAO,CAAC,GAAuB,OACjC,GAAG,CAAC,KAAK;AAEX;;;;;6CAK6C,GAC7C,OAAO,IAAI,UAAU,mCAAkC;AAEvD;;;2DAG2D,GAC3D,OAAO,IAAI,OAAO,2DAChB,aAAY;AAEd,kEAAkE;AAClE,gEAAgE;AAChE,sGAAsG;AACtG,0CAA0C;AAC1C;;wCAEwC,GACxC,OAAO,IAAI,SAAS,CAAC,QACnB,MAAM,EAAE,CAAC,CAAC,IAAI,QAAQ,cAClB;OAAI;IAAO,QAAQ;MAAE,MAAM;MAAe,MAAM;IAAK,GAAG;GAAc,GACtE,MAAK;AAEX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