@yaks/tools 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 +870 -2
- package/_dist/access.d.ts +3 -0
- package/_dist/access.d.ts.map +1 -0
- package/_dist/app-view.d.ts +27 -0
- package/_dist/app-view.d.ts.map +1 -0
- package/_dist/args.d.ts +23 -0
- package/_dist/args.d.ts.map +1 -0
- package/_dist/check.d.ts +32 -0
- package/_dist/check.d.ts.map +1 -0
- package/_dist/declared.d.ts +66 -0
- package/_dist/declared.d.ts.map +1 -0
- package/_dist/display.d.ts +2 -0
- package/_dist/display.d.ts.map +1 -0
- package/_dist/errors.d.ts +46 -0
- package/_dist/errors.d.ts.map +1 -0
- package/_dist/fault.d.ts +4 -0
- package/_dist/fault.d.ts.map +1 -0
- package/_dist/invoke.d.ts +13 -0
- package/_dist/invoke.d.ts.map +1 -0
- package/_dist/mod.d.ts +31 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/outlast.d.ts +89 -0
- package/_dist/outlast.d.ts.map +1 -0
- package/_dist/persist.d.ts +5 -0
- package/_dist/persist.d.ts.map +1 -0
- package/_dist/read.d.ts +4 -0
- package/_dist/read.d.ts.map +1 -0
- package/_dist/readable.d.ts +59 -0
- package/_dist/readable.d.ts.map +1 -0
- package/_dist/registry.d.ts +53 -0
- package/_dist/registry.d.ts.map +1 -0
- package/_dist/result.d.ts +154 -0
- package/_dist/result.d.ts.map +1 -0
- package/_dist/routes.d.ts +11 -0
- package/_dist/routes.d.ts.map +1 -0
- package/_dist/runner.d.ts +161 -0
- package/_dist/runner.d.ts.map +1 -0
- package/_dist/said.d.ts +4 -0
- package/_dist/said.d.ts.map +1 -0
- package/_dist/schema.d.ts +76 -0
- package/_dist/schema.d.ts.map +1 -0
- package/_dist/state.d.ts +9 -0
- package/_dist/state.d.ts.map +1 -0
- package/_dist/title.d.ts +20 -0
- package/_dist/title.d.ts.map +1 -0
- package/_dist/value.d.ts +43 -0
- package/_dist/value.d.ts.map +1 -0
- package/_dist/views.d.ts +5 -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/watch.d.ts +28 -0
- package/_dist/watch.d.ts.map +1 -0
- package/access.js +3 -0
- package/access.js.map +1 -0
- package/access.ts +11 -0
- package/app-view.js +26 -0
- package/app-view.js.map +1 -0
- package/app-view.ts +41 -0
- package/args.js +136 -0
- package/args.js.map +1 -0
- package/args.ts +187 -0
- package/body.js +14 -0
- package/body.js.map +1 -0
- package/body.ts +15 -0
- package/check.js +67 -0
- package/check.js.map +1 -0
- package/check.ts +92 -0
- package/declared.js +529 -0
- package/declared.js.map +1 -0
- package/declared.ts +719 -0
- package/deno.json +1 -0
- package/display.js +21 -0
- package/display.js.map +1 -0
- package/display.ts +39 -0
- package/errors.js +99 -0
- package/errors.js.map +1 -0
- package/errors.ts +127 -0
- package/fault.js +17 -0
- package/fault.js.map +1 -0
- package/fault.ts +24 -0
- package/invoke.js +207 -0
- package/invoke.js.map +1 -0
- package/invoke.ts +210 -0
- package/mod.js +31 -0
- package/mod.js.map +1 -0
- package/mod.ts +78 -0
- package/outlast.js +416 -0
- package/outlast.js.map +1 -0
- package/outlast.ts +551 -0
- package/package.json +109 -4
- package/persist.js +18 -0
- package/persist.js.map +1 -0
- package/persist.ts +26 -0
- package/read.js +50 -0
- package/read.js.map +1 -0
- package/read.ts +58 -0
- package/readable.js +118 -0
- package/readable.js.map +1 -0
- package/readable.ts +134 -0
- package/registry.js +162 -0
- package/registry.js.map +1 -0
- package/registry.ts +207 -0
- package/result.js +497 -0
- package/result.js.map +1 -0
- package/result.ts +540 -0
- package/routes.js +46 -0
- package/routes.js.map +1 -0
- package/routes.ts +50 -0
- package/runner.js +748 -0
- package/runner.js.map +1 -0
- package/runner.ts +910 -0
- package/said.js +15 -0
- package/said.js.map +1 -0
- package/said.ts +12 -0
- package/schema.js +137 -0
- package/schema.js.map +1 -0
- package/schema.ts +134 -0
- package/state.js +69 -0
- package/state.js.map +1 -0
- package/state.ts +108 -0
- package/title.js +222 -0
- package/title.js.map +1 -0
- package/title.ts +257 -0
- package/value.js +57 -0
- package/value.js.map +1 -0
- package/value.ts +74 -0
- package/views.js +131 -0
- package/views.js.map +1 -0
- package/views.ts +125 -0
- package/vocab.js +22 -0
- package/vocab.js.map +1 -0
- package/vocab.json +268 -0
- package/vocab.ts +22 -0
- package/watch.js +64 -0
- package/watch.js.map +1 -0
- package/watch.ts +74 -0
package/result.js
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
// Tool identities and invocation receipts, shared by recorded work and reads.
|
|
2
|
+
import { identityEid } from "@yaks/graph/identity";
|
|
3
|
+
import { namedTool } from "@yaks/graph/call";
|
|
4
|
+
import { asked, emitted, ready } from "@yaks/graph/declared";
|
|
5
|
+
import { token } from "@yaks/graph/sha256";
|
|
6
|
+
import { PROVENANCE } from "@yaks/graph/provenance";
|
|
7
|
+
import { effectsIn } from "@yaks/vocab";
|
|
8
|
+
import { toolsDoc } from "./vocab.js";
|
|
9
|
+
import { executionState } from "./state.js";
|
|
10
|
+
import { json, valueIn } from "./value.js";
|
|
11
|
+
import { system } from "@yaks/fp";
|
|
12
|
+
/** A runner's clock unless it is given one: the runtime's timers, and
|
|
13
|
+
* `performance.now`, which the wall clock's adjustments never move, for how
|
|
14
|
+
* long a call took. */ export let measuring = {
|
|
15
|
+
...system,
|
|
16
|
+
now: ()=>performance.now()
|
|
17
|
+
};
|
|
18
|
+
/** The two effects this package declares, as written in the vocabulary: the
|
|
19
|
+
* call that is due now, and the one that is due once its wake has fired —
|
|
20
|
+
* each a query the runner also asks on its own, for what a crash left. */ export let RULES = effectsIn(toolsDoc).flatMap((e)=>e.match ? [
|
|
21
|
+
{
|
|
22
|
+
name: e.name,
|
|
23
|
+
match: e.match
|
|
24
|
+
}
|
|
25
|
+
] : []);
|
|
26
|
+
/** Every call claimed and not yet answered: the identities explicit recovery
|
|
27
|
+
* asks for beside the rules, which owe nothing for a claimed call. A call its
|
|
28
|
+
* writer runs by an effect of its own (`tool_async`, @yaks/session) is that
|
|
29
|
+
* effect's to recover, as it is that effect's to run (`call_ready`). */ export let HELD = '$call .call, .execution, !results, !tool_async';
|
|
30
|
+
/** The rule that selects a call due now — the one whose emit names the result
|
|
31
|
+
* entity. */ export let READY = 'call_ready';
|
|
32
|
+
/** The rule that selects a deferred call once its wake has fired. */ export let WOKEN = 'call_woken';
|
|
33
|
+
// Each name's id, derived once: it is a hash, and a server that builds a
|
|
34
|
+
// runner per request names every tool it has each time.
|
|
35
|
+
let eids = new Map();
|
|
36
|
+
let names = new Map();
|
|
37
|
+
/** The entity id a call points at for a tool of this name: the id the
|
|
38
|
+
* vocabulary's `identity` on `tool.name` derives, so a graph's tool rows are
|
|
39
|
+
* the same rows every time a runner is built. */ export let toolEid = (name)=>{
|
|
40
|
+
let eid = eids.get(name);
|
|
41
|
+
if (!eid) {
|
|
42
|
+
eids.set(name, eid = identityEid('tool', [
|
|
43
|
+
name
|
|
44
|
+
]));
|
|
45
|
+
names.set(eid, name);
|
|
46
|
+
}
|
|
47
|
+
return eid;
|
|
48
|
+
};
|
|
49
|
+
// An id already derived in this process needs no walk through a catalog.
|
|
50
|
+
export let toolNameAt = (eid)=>names.get(eid);
|
|
51
|
+
/** The row a registered tool advertises to stored calls and builders. */ export let toolRow = (tool)=>{
|
|
52
|
+
let named = namedTool(tool);
|
|
53
|
+
return {
|
|
54
|
+
entity: {
|
|
55
|
+
eid: toolEid(named.name)
|
|
56
|
+
},
|
|
57
|
+
tool: {
|
|
58
|
+
name: named.name,
|
|
59
|
+
description: named.description,
|
|
60
|
+
revision: named.revision ?? null
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/** The most characters of an answer's text {@link worded} says: the copy on
|
|
65
|
+
* the result entity, what a model reads over MCP, a transcript's line. What
|
|
66
|
+
* lies past it is counted, not said — the answer itself is the bundles. */ export let WORDS = 256 * 1024;
|
|
67
|
+
/** The most characters an answer may take as JSON before the runner refuses
|
|
68
|
+
* it as `too_large`: far below the longest string a JavaScript engine can
|
|
69
|
+
* build, so a door that sends an answer whole (MCP, `/apply`, `--json`) never
|
|
70
|
+
* fails to. */ export let MOST = 64 * 1024 * 1024;
|
|
71
|
+
// JSON.stringify(answer, null, 2), said one bundle at a time.
|
|
72
|
+
let inset = (b)=>' ' + JSON.stringify(b, null, 2).replaceAll('\n', '\n ');
|
|
73
|
+
// The most characters a text property is said in its JSON string: one that
|
|
74
|
+
// runs longer, or breaks lines, is prose, and `worded` says it as plain text
|
|
75
|
+
// beside its bundle.
|
|
76
|
+
let PROSE = 200;
|
|
77
|
+
// A component's string a model reads better as plain text than escaped inside
|
|
78
|
+
// a JSON string: one that breaks lines or runs long, holding no control
|
|
79
|
+
// character but its line breaks and tabs, since a result must not command a
|
|
80
|
+
// terminal.
|
|
81
|
+
let prose = (v)=>typeof v == 'string' && (v.includes('\n') || v.length > PROSE) && // deno-lint-ignore no-control-regex -- control characters stay escaped
|
|
82
|
+
!/[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(v);
|
|
83
|
+
// A data bundle with its prose held out: each such property says, in its
|
|
84
|
+
// JSON string, the tag its block opens with, and the blocks follow, one per
|
|
85
|
+
// property, so the JSON still parses and the prose reads as written.
|
|
86
|
+
let heldOut = (b)=>{
|
|
87
|
+
let blocks = [];
|
|
88
|
+
let json = {
|
|
89
|
+
...b
|
|
90
|
+
};
|
|
91
|
+
for (let [k, c] of Object.entries(b)){
|
|
92
|
+
if (k == 'entity' || k[0] == '$' || !c || typeof c != 'object') continue;
|
|
93
|
+
let long = Object.entries(c).filter(([, v])=>prose(v));
|
|
94
|
+
if (!long.length || Array.isArray(c)) continue;
|
|
95
|
+
let comp = {
|
|
96
|
+
...c
|
|
97
|
+
};
|
|
98
|
+
for (let [p, v] of long){
|
|
99
|
+
let tag = `${k}.${p} ${b.entity.eid}`;
|
|
100
|
+
comp[p] = `<${tag}>`;
|
|
101
|
+
blocks.push(`<${tag}>\n${v}${v.endsWith('\n') ? '' : '\n'}</${k}.${p}>`);
|
|
102
|
+
}
|
|
103
|
+
json[k] = comp;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
json: json,
|
|
107
|
+
blocks
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
// Pieces said in turn while they fit in `most` characters, and how many of
|
|
111
|
+
// the `n` are past them counted: a piece is made only once it is reached, so
|
|
112
|
+
// an answer of any size words in bounded time and space.
|
|
113
|
+
let capped = (pieces, n, most)=>{
|
|
114
|
+
let text = '';
|
|
115
|
+
let i = 0;
|
|
116
|
+
for (let s of pieces){
|
|
117
|
+
if (text.length + s.length > most) {
|
|
118
|
+
return {
|
|
119
|
+
cut: true,
|
|
120
|
+
text: `${text}${s.slice(0, most - text.length)}\n… ${n - i} of ${n} ` + `not said: an answer is worded in ${most} characters`
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
text += s;
|
|
124
|
+
i++;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
cut: false,
|
|
128
|
+
text
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
// A search answer carries a query-only hit, not the entity's whole body: the
|
|
132
|
+
// id it is called by (its human id where it has one, @yaks/graph/hit), the
|
|
133
|
+
// kind, title and words that found it, and, for a neighbour of something a
|
|
134
|
+
// call just made, the entity it is `near` (a possible twin), `related` to (a
|
|
135
|
+
// resource of another kind or further off) or was `said` before on (a
|
|
136
|
+
// person's earlier words or answered decision, with `by` naming them), its
|
|
137
|
+
// `status`, and for a comment the `target` it is on. Say that hit as one
|
|
138
|
+
// line for an MCP reader; structuredContent keeps its fields.
|
|
139
|
+
let hitOf = (b)=>{
|
|
140
|
+
let hit = b.hit;
|
|
141
|
+
return hit && typeof hit == 'object' && typeof hit.kind == 'string' && typeof hit.snippet == 'string' ? hit : null;
|
|
142
|
+
};
|
|
143
|
+
let hitLine = (b, hit)=>{
|
|
144
|
+
// deno-lint-ignore no-control-regex -- the search markers are intentional
|
|
145
|
+
let mark = /\x01([^\x02]*)\x02/g;
|
|
146
|
+
// deno-lint-ignore no-control-regex -- a result must not command a terminal
|
|
147
|
+
let ctrl = /[\x00-\x1f\x7f-\x9f]/g;
|
|
148
|
+
let clean = (s)=>s.replace(/\s+/g, ' ').replace(ctrl, '').trim();
|
|
149
|
+
let said = (k)=>typeof hit[k] == 'string' ? clean(hit[k]) : '';
|
|
150
|
+
let id = said('id') || b.entity.eid;
|
|
151
|
+
let title = said('title');
|
|
152
|
+
let status = said('status');
|
|
153
|
+
let target = said('target');
|
|
154
|
+
let near = said('near');
|
|
155
|
+
let related = said('related');
|
|
156
|
+
let source = hit.source == 'meaning' ? ' (meaning)' : '';
|
|
157
|
+
let snippet = clean(String(hit.snippet).replace(mark, '*$1*'));
|
|
158
|
+
let before = said('said');
|
|
159
|
+
let of = near ? `near ${near}: ` : related ? `related to ${related}: ` : before ? `${said('by') || 'said'} earlier, on ${before}: ` : '';
|
|
160
|
+
return `${of}${id}${title ? ` ${title}` : ''} · ${clean(String(hit.kind))}${status ? ` ${status}` : ''}${target ? ` on ${target}` : ''}${source}${snippet ? ` — ${snippet}` : ''}`;
|
|
161
|
+
};
|
|
162
|
+
// The spine every written row has: its entity and the provenance the graph
|
|
163
|
+
// keeps about its writes.
|
|
164
|
+
let SPINE = new Set([
|
|
165
|
+
'entity',
|
|
166
|
+
...PROVENANCE
|
|
167
|
+
]);
|
|
168
|
+
// What a tool's text answer carries: the spine, its words, the call it
|
|
169
|
+
// answers, and a fault's `refusal` or `exception`. An entity carrying more (a
|
|
170
|
+
// transcript entry, a comment, a memory, a row a tool made) is data, and its
|
|
171
|
+
// words alone would drop which one it is and who wrote it.
|
|
172
|
+
let SPOKEN = new Set([
|
|
173
|
+
...SPINE,
|
|
174
|
+
'content',
|
|
175
|
+
'output',
|
|
176
|
+
'refusal',
|
|
177
|
+
'exception',
|
|
178
|
+
'heard'
|
|
179
|
+
]);
|
|
180
|
+
// A bundle said as a line of its own: the words a call said, its value, or a
|
|
181
|
+
// hit. Words are what a tool answered under a name of its own (`$said`) or
|
|
182
|
+
// aimed at the call (`output{source}`, which a text answer keeps once it is
|
|
183
|
+
// written): a row the answer read or wrote is data even when words are all it
|
|
184
|
+
// holds, since its words alone would drop which entity it is. A value
|
|
185
|
+
// answered without words (./value.ts `valued`) is said as its JSON:
|
|
186
|
+
// the value travels once, and a door that sends text writes it. Null for
|
|
187
|
+
// data, said whole.
|
|
188
|
+
let line = (b)=>{
|
|
189
|
+
let body = b.content?.body;
|
|
190
|
+
let value = b.output?.value;
|
|
191
|
+
if ((b.entity.eid[0] == '$' || !!b.output) && Object.keys(b).every((k)=>k[0] == '$' || SPOKEN.has(k))) {
|
|
192
|
+
if (typeof body == 'string') return body;
|
|
193
|
+
if (value !== undefined && !b.content) {
|
|
194
|
+
return json(value);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
let hit = hitOf(b);
|
|
198
|
+
return hit ? hitLine(b, hit) : null;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* A tool's answer as text: each bundle as a line where it is one — a text
|
|
202
|
+
* answer's `content{body}`, or a compact `hit` line for a search result — and
|
|
203
|
+
* the rest as JSON, each run of data bundles one JSON array, so the data in an
|
|
204
|
+
* answer always parses and the lines between read as lines. An answer of data
|
|
205
|
+
* alone is one array, `JSON.stringify(answer, null, 2)`. A component's prose
|
|
206
|
+
* (a string that breaks lines or runs past 200 characters, such as a
|
|
207
|
+
* `doc.body`) is said as plain text: its JSON string holds the tag of a block
|
|
208
|
+
* that follows the bundle, which ends the array. An entity that carries words
|
|
209
|
+
* among other components (a transcript entry, a comment) is data: said whole,
|
|
210
|
+
* its eid and its writer with its words. It is copied onto the result entity
|
|
211
|
+
* as `content{body}` so a model, a terminal and a transcript all read the
|
|
212
|
+
* answer the same way. It says at most `most` characters, each bundle only
|
|
213
|
+
* once it is reached, and counts the rest, so an answer of any size words in
|
|
214
|
+
* bounded time and space.
|
|
215
|
+
*
|
|
216
|
+
* ```ts
|
|
217
|
+
* import { assertEquals } from '@std/assert'
|
|
218
|
+
* let said = (body: string) => ({
|
|
219
|
+
* entity: { eid: '$said' },
|
|
220
|
+
* content: { body },
|
|
221
|
+
* output: { source: 'c1' },
|
|
222
|
+
* })
|
|
223
|
+
* assertEquals(worded([said('one'), said('two')]), 'one\ntwo')
|
|
224
|
+
* let value = { entity: { eid: '$said' }, output: { value: { n: 1 } } }
|
|
225
|
+
* assertEquals(worded([value]), '{"n":1}')
|
|
226
|
+
* let entry = { ...said('hi'), entry: { session: 's', seq: 2 } }
|
|
227
|
+
* assertEquals(
|
|
228
|
+
* worded([said('one'), entry, said('two')]),
|
|
229
|
+
* 'one\n' + JSON.stringify([entry], null, 2) + '\ntwo',
|
|
230
|
+
* )
|
|
231
|
+
* let task = { entity: { eid: 't1' }, doc: { body: 'Two\n"lines"' } }
|
|
232
|
+
* assertEquals(
|
|
233
|
+
* worded([task]),
|
|
234
|
+
* JSON.stringify([{ ...task, doc: { body: '<doc.body t1>' } }], null, 2) +
|
|
235
|
+
* '\n<doc.body t1>\nTwo\n"lines"\n</doc.body>',
|
|
236
|
+
* )
|
|
237
|
+
* assertEquals(
|
|
238
|
+
* worded([said('one'), said('two'), said('three')], 5),
|
|
239
|
+
* 'one\nt\n… 2 of 3 not said: an answer is worded in 5 characters',
|
|
240
|
+
* )
|
|
241
|
+
* ```
|
|
242
|
+
*/ export let worded = (answer, most = WORDS)=>{
|
|
243
|
+
if (!answer.length) return '[]';
|
|
244
|
+
// A leading run's `[` is outside the budget, as the closing line is: the
|
|
245
|
+
// budget is the answer's own characters.
|
|
246
|
+
let open = '';
|
|
247
|
+
let run = false;
|
|
248
|
+
let pieces = function*() {
|
|
249
|
+
for (let [i, b] of answer.entries()){
|
|
250
|
+
let words = line(b);
|
|
251
|
+
if (words != null) {
|
|
252
|
+
yield (run ? '\n]' : '') + (i ? '\n' : '') + words;
|
|
253
|
+
run = false;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
let { json, blocks } = heldOut(b);
|
|
257
|
+
if (!i) open = '[\n';
|
|
258
|
+
let s = (run ? ',\n' : i ? '\n[\n' : '') + inset(json);
|
|
259
|
+
run = !blocks.length;
|
|
260
|
+
yield run ? s : `${s}\n]\n${blocks.join('\n')}`;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
let { cut, text } = capped(pieces(), answer.length, most);
|
|
264
|
+
return open + text + (!cut && run ? '\n]' : '');
|
|
265
|
+
};
|
|
266
|
+
let pendingResult = (answer)=>{
|
|
267
|
+
let value = valueIn(answer);
|
|
268
|
+
if (value?.running !== true || typeof value.result_handle != 'string') return;
|
|
269
|
+
let spoken = answer.some((b)=>b.output?.value === value && line(b) != null);
|
|
270
|
+
if (spoken) return {
|
|
271
|
+
running: true,
|
|
272
|
+
result_handle: value.result_handle
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* A tool's answer as the texts a door that sends several sends (MCP's content
|
|
277
|
+
* blocks): its data first, as JSON, then the prose held out of it, then the
|
|
278
|
+
* lines said beside it, so a reader that parses the first text finds the data
|
|
279
|
+
* and nothing glued onto it. An answer of one kind without prose is one text,
|
|
280
|
+
* {@link worded}.
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* import { assertEquals } from '@std/assert'
|
|
284
|
+
* let row = { entity: { eid: 't1' }, doc: { title: 'Mossvale' } }
|
|
285
|
+
* let note = { entity: { eid: '$said' }, content: { body: 'Checked.' } }
|
|
286
|
+
* assertEquals(texts([row, note]), [JSON.stringify([row], null, 2), 'Checked.'])
|
|
287
|
+
* assertEquals(texts([row]), [worded([row])])
|
|
288
|
+
* let task = { entity: { eid: 't2' }, doc: { body: 'One\ntwo' } }
|
|
289
|
+
* assertEquals(texts([task]), [
|
|
290
|
+
* JSON.stringify([{ ...task, doc: { body: '<doc.body t2>' } }], null, 2),
|
|
291
|
+
* '<doc.body t2>\nOne\ntwo\n</doc.body>',
|
|
292
|
+
* ])
|
|
293
|
+
* ```
|
|
294
|
+
*/ export let texts = (answer, most = WORDS)=>{
|
|
295
|
+
let pending = pendingResult(answer);
|
|
296
|
+
return pending ? [
|
|
297
|
+
json(pending),
|
|
298
|
+
...bundleTexts(answer, most)
|
|
299
|
+
] : bundleTexts(answer, most);
|
|
300
|
+
};
|
|
301
|
+
let bundleTexts = (answer, most)=>{
|
|
302
|
+
let words = answer.filter((b)=>line(b) != null);
|
|
303
|
+
let data = answer.filter((b)=>line(b) == null).map(heldOut);
|
|
304
|
+
let long = data.filter((d)=>d.blocks.length);
|
|
305
|
+
if (!data.length || !words.length && !long.length) {
|
|
306
|
+
return [
|
|
307
|
+
worded(answer, most)
|
|
308
|
+
];
|
|
309
|
+
}
|
|
310
|
+
let blocks = long.map((d, i)=>(i ? '\n' : '') + d.blocks.join('\n'));
|
|
311
|
+
return [
|
|
312
|
+
worded(data.map((d)=>d.json), most),
|
|
313
|
+
...long.length ? [
|
|
314
|
+
capped(blocks, long.length, most).text
|
|
315
|
+
] : [],
|
|
316
|
+
...words.length ? [
|
|
317
|
+
worded(words, most)
|
|
318
|
+
] : []
|
|
319
|
+
];
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* A tool's answer as data, for a reader that parses rather than reads: the
|
|
323
|
+
* bundles under `result`, or, from a tool that declares an `outputSchema`
|
|
324
|
+
* because its answer is not entities, the {@link valueIn} it answered in that
|
|
325
|
+
* shape. A refusal carries no such value, and is its bundles like any other.
|
|
326
|
+
* MCP sends this as `structuredContent`; `yak … --json` prints it.
|
|
327
|
+
*/ export let structured = (tool, answer)=>(tool.outputSchema ? valueIn(answer) : undefined) ?? {
|
|
328
|
+
result: answer,
|
|
329
|
+
...pendingResult(answer)
|
|
330
|
+
};
|
|
331
|
+
// A bundle that says nothing once its value and images are taken out: the
|
|
332
|
+
// spine, and the call it was aimed at.
|
|
333
|
+
let bare = (b)=>Object.entries(b).every(([k, c])=>SPINE.has(k) || k[0] == '$' || c === undefined || k == 'output' && Object.keys(c ?? {}).every((p)=>p == 'source'));
|
|
334
|
+
/**
|
|
335
|
+
* What a tool's {@link texts} say that its {@link structured} answer does not
|
|
336
|
+
* hold, worded, for a door that sends both to a reader that reads only the
|
|
337
|
+
* data. An answer of entities holds every bundle under `result`, so nothing;
|
|
338
|
+
* a value holds only itself, so the words beside it and every other bundle
|
|
339
|
+
* are said here. Images are sent as images, not words.
|
|
340
|
+
*
|
|
341
|
+
* ```ts
|
|
342
|
+
* import { assertEquals } from '@std/assert'
|
|
343
|
+
* let schema = { outputSchema: { type: 'object' } }
|
|
344
|
+
* let said = {
|
|
345
|
+
* entity: { eid: '$said' },
|
|
346
|
+
* content: { body: 'Two components.' },
|
|
347
|
+
* output: { source: 'c1', value: { n: 2 } },
|
|
348
|
+
* }
|
|
349
|
+
* assertEquals(aside(schema, [said]), 'Two components.')
|
|
350
|
+
* assertEquals(aside(schema, [{ ...said, content: undefined }]), undefined)
|
|
351
|
+
* assertEquals(aside({}, [said]), undefined)
|
|
352
|
+
* ```
|
|
353
|
+
*/ export let aside = (tool, answer, most = WORDS)=>{
|
|
354
|
+
let value = tool.outputSchema ? valueIn(answer) : undefined;
|
|
355
|
+
if (value === undefined) return undefined;
|
|
356
|
+
let rest = answer.flatMap((b)=>{
|
|
357
|
+
if (!b.output) return [
|
|
358
|
+
b
|
|
359
|
+
];
|
|
360
|
+
let { value: v, images: _, ...output } = b.output;
|
|
361
|
+
let left = {
|
|
362
|
+
...b,
|
|
363
|
+
output: v === value || v === undefined ? output : {
|
|
364
|
+
...output,
|
|
365
|
+
value: v
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
return bare(left) ? [] : [
|
|
369
|
+
left
|
|
370
|
+
];
|
|
371
|
+
});
|
|
372
|
+
return rest.length ? bundleTexts(rest, most).join('\n') : undefined;
|
|
373
|
+
};
|
|
374
|
+
// The runner's own record of one call, told apart from the answer by identity,
|
|
375
|
+
// never by shape: a tool that reads transcripts answers other calls and their
|
|
376
|
+
// results, and those are the answer.
|
|
377
|
+
let owned = (call)=>(b)=>b.entity.eid == call || b.result?.call == call;
|
|
378
|
+
/**
|
|
379
|
+
* Did this call fail? Read from the runner's own record — `execution{state}`
|
|
380
|
+
* on the call — rather than guessed from the shape of the answer: a tool that
|
|
381
|
+
* queries for broken rows (or failed calls) returns entities carrying `error`,
|
|
382
|
+
* `exception` and `execution`, and reporting faults is not itself a fault.
|
|
383
|
+
*/ export let faulted = (landed, call)=>{
|
|
384
|
+
let row = landed.find((b)=>b.entity.eid == call);
|
|
385
|
+
return !!row && [
|
|
386
|
+
'failed',
|
|
387
|
+
'interrupted'
|
|
388
|
+
].includes(executionState(row, landed) ?? '');
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Is the call still running in what came back? A stopping server answers a
|
|
392
|
+
* call whose tool has not returned with the call as it stands, claimed and
|
|
393
|
+
* unanswered, and where its answer will be kept (@yaks/tools
|
|
394
|
+
* `Invocation.call`). Read from the runner's own record, as {@link faulted}.
|
|
395
|
+
*/ export let pending = (landed, call)=>{
|
|
396
|
+
let row = landed.find((b)=>b.entity.eid == call);
|
|
397
|
+
return !!row && executionState(row, landed) == 'running';
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* The fault a failed call left, aimed at it: its `refusal{code}`, its
|
|
401
|
+
* `exception` or its interruption's `notice`, beside the words it said. None
|
|
402
|
+
* for a call that answered, however its answer is shaped ({@link faulted}).
|
|
403
|
+
*/ export let faultOf = (landed, call)=>faulted(landed, call) ? landed.find((b)=>b.output?.source == call && !!(b.refusal || b.exception || b.notice)) : undefined;
|
|
404
|
+
/**
|
|
405
|
+
* What a call answered, for display: the tool's own bundles, without the
|
|
406
|
+
* runner's record of this call — the call itself and its result, which
|
|
407
|
+
* carries a copy of the answer's text so a transcript can show one line per
|
|
408
|
+
* result; a caller rendering the answer itself would otherwise show it twice.
|
|
409
|
+
*/ export let answerOf = (landed, call)=>landed.filter((b)=>!owned(call)(b));
|
|
410
|
+
/** Plan invocation receipts from the declared rules, including their stable IDs. */ export let results = (vocab, now)=>{
|
|
411
|
+
// The rules as this graph can query them (@yaks/graph `asked`). A graph that
|
|
412
|
+
// schedules nothing never loaded the wake components: there `!wake` matches
|
|
413
|
+
// everything and drops out, and `call_woken`, which requires them, never
|
|
414
|
+
// matches — one rule text, correct in both graphs.
|
|
415
|
+
let plans = ready(RULES).map((p)=>({
|
|
416
|
+
...p,
|
|
417
|
+
plan: asked(p.plan, vocab)
|
|
418
|
+
})).filter((p)=>!!p.plan);
|
|
419
|
+
let answering = plans.find((p)=>p.rule.name == READY);
|
|
420
|
+
let woken = plans.find((p)=>p.rule.name == WOKEN);
|
|
421
|
+
// HELD as this graph can query it, the way the rules are asked.
|
|
422
|
+
// A graph that records no claims (no `execution`) holds none.
|
|
423
|
+
let held = asked(ready([
|
|
424
|
+
{
|
|
425
|
+
name: 'held',
|
|
426
|
+
match: HELD
|
|
427
|
+
}
|
|
428
|
+
])[0].plan, vocab)?.patterns[0].filter;
|
|
429
|
+
// The result entity, built the way the rule would write it: one match of
|
|
430
|
+
// `call_ready`, emitted. Its id is derived from that match, so it is the
|
|
431
|
+
// same entity however many times a call is run.
|
|
432
|
+
let attached = (id, ms, sleeps = false)=>{
|
|
433
|
+
let rule = sleeps && woken ? woken : answering;
|
|
434
|
+
let name = rule.plan.patterns[0].entity;
|
|
435
|
+
let [made] = emitted(rule, {
|
|
436
|
+
entities: [
|
|
437
|
+
id,
|
|
438
|
+
null
|
|
439
|
+
],
|
|
440
|
+
vars: {
|
|
441
|
+
[name]: id
|
|
442
|
+
}
|
|
443
|
+
}, vocab);
|
|
444
|
+
return {
|
|
445
|
+
...made,
|
|
446
|
+
result: {
|
|
447
|
+
...made.result,
|
|
448
|
+
...ms == null ? {} : {
|
|
449
|
+
ms
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
// What ends a claimed call: the result the rule names, worded from what it
|
|
455
|
+
// said, and the claim moved on from `running`, refused if another hand
|
|
456
|
+
// moved it first.
|
|
457
|
+
// How long it ran is left out where nobody saw it start.
|
|
458
|
+
let ending = (call, started, state, said, before = 'running')=>[
|
|
459
|
+
{
|
|
460
|
+
...attached(call.entity.eid, started == null ? undefined : Math.round(now() - started), !!call.wake),
|
|
461
|
+
content: {
|
|
462
|
+
body: worded(said)
|
|
463
|
+
},
|
|
464
|
+
$was: {
|
|
465
|
+
result: {
|
|
466
|
+
call: null
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
entity: {
|
|
472
|
+
eid: call.entity.eid
|
|
473
|
+
},
|
|
474
|
+
execution: {
|
|
475
|
+
by: call.execution?.by ?? null
|
|
476
|
+
},
|
|
477
|
+
...state == 'interrupted' ? {
|
|
478
|
+
interrupted: {
|
|
479
|
+
code: 'transport'
|
|
480
|
+
}
|
|
481
|
+
} : {},
|
|
482
|
+
$was: {
|
|
483
|
+
execution: {
|
|
484
|
+
by: before == null ? null : token(call.execution?.by)
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
];
|
|
489
|
+
return {
|
|
490
|
+
rules: plans,
|
|
491
|
+
held,
|
|
492
|
+
ending
|
|
493
|
+
};
|
|
494
|
+
};
|
|
495
|
+
export { said } from "./said.js";
|
|
496
|
+
export { display } from "./display.js";
|
|
497
|
+
//# sourceMappingURL=result.js.map
|
package/result.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sources":["./result.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,SAAS,WAAW,oCAAyC;AAC7D,SAAS,SAAS,gCAAqC;AACvD,SAAS,KAAK,EAAE,OAAO,EAAE,KAAK,oCAAyC;AACvE,SAAS,KAAK,kCAAuC;AACrD,SAAS,UAAU,sCAA2C;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