@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/deno.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"publish":{"exclude":["**/*_test.ts"]},"name":"@yaks/tools","version":"0.2.36","license":"Apache-2.0","description":"Provides a shared tool registry and schemas, executes recorded graph tool calls, and keeps their answers, duration, and execution state; parses app-declared commands and provides their HTTP route and answer rendering.","exports":{".":"./mod.ts","./access":"./access.ts","./app-view":"./app-view.ts","./declared":"./declared.ts","./errors":"./errors.ts","./routes":"./routes.ts","./vocab":"./vocab.ts","./value":"./value.ts","./views":"./views.ts","./read":"./read.ts","./result":"./result.ts","./outlast":"./outlast.ts","./persist":"./persist.ts","./fault":"./fault.ts","./check":"./check.ts","./state":"./state.ts","./display":"./display.ts","./schema":"./schema.ts","./registry":"./registry.ts","./title":"./title.ts","./readable":"./readable.ts","./watch":"./watch.ts"},"imports":{"@yaks/tools":"./mod.ts","@yaks/tools/access":"./access.ts","@yaks/tools/app-view":"./app-view.ts","@yaks/tools/declared":"./declared.ts","@yaks/tools/errors":"./errors.ts","@yaks/tools/routes":"./routes.ts","@yaks/tools/vocab":"./vocab.ts","@yaks/tools/value":"./value.ts","@yaks/tools/views":"./views.ts","@yaks/tools/read":"./read.ts","@yaks/tools/result":"./result.ts","@yaks/tools/outlast":"./outlast.ts","@yaks/tools/persist":"./persist.ts","@yaks/tools/fault":"./fault.ts","@yaks/tools/check":"./check.ts","@yaks/tools/state":"./state.ts","@yaks/tools/display":"./display.ts","@yaks/tools/schema":"./schema.ts","@yaks/tools/registry":"./registry.ts","@yaks/tools/title":"./title.ts","@yaks/tools/readable":"./readable.ts","@yaks/tools/watch":"./watch.ts"}}
|
package/display.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// A command's structured answer as readable Markdown. The answer remains data
|
|
2
|
+
// for clients that parse it; this is only its written face for people.
|
|
3
|
+
import { h, markdown } from "@yaks/text";
|
|
4
|
+
let object = (value)=>!!value && typeof value == 'object' && !Array.isArray(value);
|
|
5
|
+
let fields = (value, path = '')=>Object.entries(value).flatMap(([name, entry])=>{
|
|
6
|
+
let key = path ? `${path}.${name}` : name;
|
|
7
|
+
return object(entry) && Object.keys(entry).length ? fields(entry, key) : [
|
|
8
|
+
[
|
|
9
|
+
key,
|
|
10
|
+
entry
|
|
11
|
+
]
|
|
12
|
+
];
|
|
13
|
+
});
|
|
14
|
+
let value = (entry)=>h('code', null, JSON.stringify(entry) ?? 'undefined');
|
|
15
|
+
let row = (entry, number)=>{
|
|
16
|
+
let title = number == null ? null : h('h4', null, `Result ${number}`);
|
|
17
|
+
let body = object(entry) ? h('ul', null, ...fields(entry).map(([key, cell])=>h('li', null, h('strong', null, key), ': ', value(cell)))) : h('p', null, value(entry));
|
|
18
|
+
return h('div', null, title, body);
|
|
19
|
+
};
|
|
20
|
+
/** Show JSON-shaped values as fields, one section per result. */ export let display = (answer)=>Array.isArray(answer) ? answer.length ? answer.map((entry, i)=>markdown(row(entry, i + 1))).join('\n\n') : 'No rows.' : markdown(row(answer));
|
|
21
|
+
//# sourceMappingURL=display.js.map
|
package/display.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sources":["./display.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,uEAAuE;AACvE,SAAS,CAAC,EAAE,QAAQ,0BAA+B;AAEnD,IAAI,SAAS,CAAC,QACZ,CAAC,CAAC,SAAS,OAAO,SAAS,YAAY,CAAC,MAAM,OAAO,CAAC;AAExD,IAAI,SAAS,CAAC,OAAgC,OAAO,EAAE,GACrD,OAAO,OAAO,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM;IAC1C,IAAI,MAAM,OAAO,GAAG,KAAK,CAAC,EAAE,MAAM,GAAG;IACrC,OAAO,OAAO,UAAU,OAAO,IAAI,CAAC,OAAO,MAAM,GAC7C,OAAO,OAAO,OACd;MAAC;QAAC;QAAK;OAAM;KAAC;EACpB;AAEF,IAAI,QAAQ,CAAC,QACX,EAAE,QAAQ,MAAM,KAAK,SAAS,CAAC,UAAU;AAE3C,IAAI,MAAM,CAAC,OAAgB;EACzB,IAAI,QAAQ,UAAU,OAAO,OAAO,EAAE,MAAM,MAAM,CAAC,OAAO,EAAE,QAAQ;EACpE,IAAI,OAAO,OAAO,SACd,EACA,MACA,SACG,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,GAC/B,EAAE,MAAM,MAAM,EAAE,UAAU,MAAM,MAAM,MAAM,MAAM,WAGpD,EAAE,KAAK,MAAM,MAAM;EACvB,OAAO,EAAE,OAAO,MAAM,OAAO;AAC/B;AAEA,+DAA+D,GAC/D,OAAO,IAAI,UAAU,CAAC,SACpB,MAAM,OAAO,CAAC,UACV,OAAO,MAAM,GACX,OAAO,GAAG,CAAC,CAAC,OAAO,IAAM,SAAS,IAAI,OAAO,IAAI,KAAK,IAAI,CAAC,UAC3D,aACF,SAAS,IAAI,SAAQ"}
|
package/display.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// A command's structured answer as readable Markdown. The answer remains data
|
|
2
|
+
// for clients that parse it; this is only its written face for people.
|
|
3
|
+
import { h, markdown } from '@yaks/text'
|
|
4
|
+
|
|
5
|
+
let object = (value: unknown): value is Record<string, unknown> =>
|
|
6
|
+
!!value && typeof value == 'object' && !Array.isArray(value)
|
|
7
|
+
|
|
8
|
+
let fields = (value: Record<string, unknown>, path = ''): [string, unknown][] =>
|
|
9
|
+
Object.entries(value).flatMap(([name, entry]) => {
|
|
10
|
+
let key = path ? `${path}.${name}` : name
|
|
11
|
+
return object(entry) && Object.keys(entry).length
|
|
12
|
+
? fields(entry, key)
|
|
13
|
+
: [[key, entry]]
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
let value = (entry: unknown) =>
|
|
17
|
+
h('code', null, JSON.stringify(entry) ?? 'undefined')
|
|
18
|
+
|
|
19
|
+
let row = (entry: unknown, number?: number) => {
|
|
20
|
+
let title = number == null ? null : h('h4', null, `Result ${number}`)
|
|
21
|
+
let body = object(entry)
|
|
22
|
+
? h(
|
|
23
|
+
'ul',
|
|
24
|
+
null,
|
|
25
|
+
...fields(entry).map(([key, cell]) =>
|
|
26
|
+
h('li', null, h('strong', null, key), ': ', value(cell))
|
|
27
|
+
),
|
|
28
|
+
)
|
|
29
|
+
: h('p', null, value(entry))
|
|
30
|
+
return h('div', null, title, body)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Show JSON-shaped values as fields, one section per result. */
|
|
34
|
+
export let display = (answer: unknown): string =>
|
|
35
|
+
Array.isArray(answer)
|
|
36
|
+
? answer.length
|
|
37
|
+
? answer.map((entry, i) => markdown(row(entry, i + 1))).join('\n\n')
|
|
38
|
+
: 'No rows.'
|
|
39
|
+
: markdown(row(answer))
|
package/errors.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Expected invocation failures, shared by argument parsers and callers without
|
|
2
|
+
// loading the graph or the tool runner.
|
|
3
|
+
var _computedKey;
|
|
4
|
+
import { status, unheard } from "@yaks/graph/errors";
|
|
5
|
+
/** The refusal code on a tool result's transport metadata. */ export let REFUSAL_CODE = 'yak.sh/refusalCode';
|
|
6
|
+
// Each page script bundles its own copy of this module, so a refusal thrown by
|
|
7
|
+
// one script reaches another as some other copy's CallError. The mark is the
|
|
8
|
+
// same in every copy, and `instanceof CallError` reads it.
|
|
9
|
+
const REFUSAL = Symbol.for('yak.sh/CallError');
|
|
10
|
+
_computedKey = Symbol.hasInstance;
|
|
11
|
+
export class CallError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
summary;
|
|
14
|
+
detail;
|
|
15
|
+
[_REFUSAL = REFUSAL];
|
|
16
|
+
/** What the caller can give for the call to go through, by name (`email`):
|
|
17
|
+
* an agent reads the message, and a page a person reads asks them for it
|
|
18
|
+
* in their own words, with a field. */ ask;
|
|
19
|
+
/** Any copy's CallError is one; a subclass still checks its own chain. */ static [_computedKey](value) {
|
|
20
|
+
return this == CallError ? value?.[REFUSAL] == true : Function.prototype[Symbol.hasInstance].call(this, value);
|
|
21
|
+
}
|
|
22
|
+
constructor(code, summary, detail){
|
|
23
|
+
super(detail ? `${summary}\n${detail}` : summary), this.code = code, this.summary = summary, this.detail = detail, this[_REFUSAL] = true;
|
|
24
|
+
this.name = 'CallError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** An operation was declined before it started and can be tried again. */ export class Busy extends Error {
|
|
28
|
+
after;
|
|
29
|
+
name;
|
|
30
|
+
constructor(message, after){
|
|
31
|
+
super(message), this.after = after, this.name = 'Busy';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Recovery for a failed precondition on a recorded invocation's claim. */ export let claimConflict = (error)=>{
|
|
35
|
+
let { eid, comp, prop, current } = error;
|
|
36
|
+
if (error.name != 'Stale' || comp != 'execution' || prop != 'by' || typeof eid != 'string') return;
|
|
37
|
+
let holder = typeof current == 'string' ? `The execution claim for call ${eid} belongs to runner ${current}.` : `Call ${eid} no longer has an execution claim.`;
|
|
38
|
+
return `${holder} Read the call with graph_show. If it is running, wait for its result. ` + `Read any recorded result with graph_query using .result.call=${eid}. ` + 'If you are updating pending calls, re-query with .call !execution !interrupted ' + 'and your original filters, then retry with only the calls that still match.';
|
|
39
|
+
};
|
|
40
|
+
/** A stored claim exists but no result does. The caller must reconcile it:
|
|
41
|
+
* running the tool again could repeat an effect the outside world already
|
|
42
|
+
* saw. */ export class UnfinishedCall extends Error {
|
|
43
|
+
call;
|
|
44
|
+
constructor(call){
|
|
45
|
+
super('Call execution was started without a recorded result: ' + call), this.call = call;
|
|
46
|
+
this.name = 'UnfinishedCall';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Work cut off deliberately, not a refusal or a defect. */ export class Interrupted extends Error {
|
|
50
|
+
code;
|
|
51
|
+
constructor(message, code = 'aborted'){
|
|
52
|
+
super(message);
|
|
53
|
+
this.name = 'Interrupted';
|
|
54
|
+
this.code = code;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Say a refusal once when its message already starts with its code. */ export let refusalText = (code, message)=>{
|
|
58
|
+
let first = /^\w+/.exec(message)?.[0];
|
|
59
|
+
return first && first.toLowerCase() == code.toLowerCase() ? message : [
|
|
60
|
+
code,
|
|
61
|
+
message
|
|
62
|
+
].filter(Boolean).join(': ');
|
|
63
|
+
};
|
|
64
|
+
let codes = {
|
|
65
|
+
access: 403,
|
|
66
|
+
arguments: 400,
|
|
67
|
+
conflict: 409,
|
|
68
|
+
limit: 429,
|
|
69
|
+
missing: 404,
|
|
70
|
+
unavailable: 503
|
|
71
|
+
};
|
|
72
|
+
/** The HTTP status a failure answers with: a refusal's, by its code, else
|
|
73
|
+
* the graph's table (@yaks/graph `status`, 500 for a defect).
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { assertEquals } from '@std/assert'
|
|
77
|
+
* import { CallError, statusOf } from './errors.ts'
|
|
78
|
+
*
|
|
79
|
+
* assertEquals(statusOf(new CallError('missing', 'no app a/b')), 404)
|
|
80
|
+
* assertEquals(statusOf(new Error('boom')), 500)
|
|
81
|
+
* ```
|
|
82
|
+
*/ export let statusOf = (e)=>e instanceof CallError ? codes[e.code] ?? 400 : status(e);
|
|
83
|
+
/** A thrown invocation refusal as its JSON HTTP answer, and a service that
|
|
84
|
+
* did not answer for now (@yaks/graph `unheard`) as `unavailable`. Defects
|
|
85
|
+
* are thrown through so the host's failure boundary can report them. */ export let refused = (e)=>{
|
|
86
|
+
let code = e instanceof CallError ? e.code : unheard(e) ? 'unavailable' : e instanceof Error ? e.name.toLowerCase() : 'refused';
|
|
87
|
+
let statusCode = statusOf(e);
|
|
88
|
+
if (statusCode >= 500 && !(e instanceof CallError) && !unheard(e)) throw e;
|
|
89
|
+
return Response.json({
|
|
90
|
+
error: {
|
|
91
|
+
code,
|
|
92
|
+
message: e instanceof Error ? e.message : String(e)
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
status: statusCode
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
var _REFUSAL;
|
|
99
|
+
//# sourceMappingURL=errors.js.map
|
package/errors.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["./errors.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wCAAwC;;AAExC,SAAqB,MAAM,EAAE,OAAO,kCAAuC;AAE3E,4DAA4D,GAC5D,OAAO,IAAI,eAAuB,qBAAoB;AAEtD,+EAA+E;AAC/E,6EAA6E;AAC7E,2DAA2D;AAC3D,MAAM,UAAyB,OAAO,GAAG,CAAC;eASvB,OAAO,WAAW;AAPrC,OAAO,MAAM,kBAAkB;;;;EACpB,CAAC,WAAA,QAAQ,CAAO;EACzB;;uCAEqC,GACrC,IAAY;EACZ,wEAAwE,GACxE,sBAAqC,KAAc,EAAW;IAC5D,OAAO,IAAI,IAAI,YACX,AAAC,OAAuC,CAAC,QAAQ,IAAI,OACrD,SAAS,SAAS,CAAC,OAAO,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE;EACxD;EACA,YACE,AAAO,IAAY,EACnB,AAAO,OAAe,EACtB,AAAO,MAAe,CACtB;IACA,KAAK,CAAC,SAAS,GAAG,QAAQ,EAAE,EAAE,QAAQ,GAAG,eAJlC,OAAA,WACA,UAAA,cACA,SAAA,YAdA,CAAC,SAAQ,GAAG;IAiBnB,IAAI,CAAC,IAAI,GAAG;EAC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AO;EACP,SAAS;EACT,aAAa;AACf;AAEA;;;;;;;;;;CAUC,GACD,OAAO,IAAI,WAAW,CAAC,IACrB,aAAa,YAAY,KAAK,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,OAAO,GAAE;AAE3D;;sEAEsE,GACtE,OAAO,IAAI,UAAU,CAAC;EACpB,IAAI,OAAO,aAAa,YACpB,EAAE,IAAI,GACN,QAAQ,KACR,gBACA,aAAa,QACb,EAAE,IAAI,CAAC,WAAW,KAClB;EACJ,IAAI,aAAa,SAAS;EAC1B,IAAI,cAAc,OAAO,CAAC,CAAC,aAAa,SAAS,KAAK,CAAC,QAAQ,IAAI,MAAM;EACzE,OAAO,SAAS,IAAI,CAAC;IACnB,OAAO;MAAE;MAAM,SAAS,aAAa,QAAQ,EAAE,OAAO,GAAG,OAAO;IAAG;EACrE,GAAG;IAAE,QAAQ;EAAW;AAC1B,EAAC"}
|
package/errors.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Expected invocation failures, shared by argument parsers and callers without
|
|
2
|
+
// loading the graph or the tool runner.
|
|
3
|
+
import type { Eid } from 'jsr:@yaks/graph@0.2.36/bundle'
|
|
4
|
+
import { type Stale, status, unheard } from '@yaks/graph/errors'
|
|
5
|
+
|
|
6
|
+
/** The refusal code on a tool result's transport metadata. */
|
|
7
|
+
export let REFUSAL_CODE: string = 'yak.sh/refusalCode'
|
|
8
|
+
|
|
9
|
+
// Each page script bundles its own copy of this module, so a refusal thrown by
|
|
10
|
+
// one script reaches another as some other copy's CallError. The mark is the
|
|
11
|
+
// same in every copy, and `instanceof CallError` reads it.
|
|
12
|
+
const REFUSAL: unique symbol = Symbol.for('yak.sh/CallError')
|
|
13
|
+
|
|
14
|
+
export class CallError extends Error {
|
|
15
|
+
readonly [REFUSAL] = true
|
|
16
|
+
/** What the caller can give for the call to go through, by name (`email`):
|
|
17
|
+
* an agent reads the message, and a page a person reads asks them for it
|
|
18
|
+
* in their own words, with a field. */
|
|
19
|
+
ask?: string
|
|
20
|
+
/** Any copy's CallError is one; a subclass still checks its own chain. */
|
|
21
|
+
static override [Symbol.hasInstance](value: unknown): boolean {
|
|
22
|
+
return this == CallError
|
|
23
|
+
? (value as { [REFUSAL]?: true } | null)?.[REFUSAL] == true
|
|
24
|
+
: Function.prototype[Symbol.hasInstance].call(this, value)
|
|
25
|
+
}
|
|
26
|
+
constructor(
|
|
27
|
+
public code: string,
|
|
28
|
+
public summary: string,
|
|
29
|
+
public detail?: string,
|
|
30
|
+
) {
|
|
31
|
+
super(detail ? `${summary}\n${detail}` : summary)
|
|
32
|
+
this.name = 'CallError'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** An operation was declined before it started and can be tried again. */
|
|
37
|
+
export class Busy extends Error {
|
|
38
|
+
override name = 'Busy'
|
|
39
|
+
constructor(message: string, public after: number) {
|
|
40
|
+
super(message)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Recovery for a failed precondition on a recorded invocation's claim. */
|
|
45
|
+
export let claimConflict = (error: Error): string | undefined => {
|
|
46
|
+
let { eid, comp, prop, current } = error as Partial<Stale>
|
|
47
|
+
if (
|
|
48
|
+
error.name != 'Stale' || comp != 'execution' || prop != 'by' ||
|
|
49
|
+
typeof eid != 'string'
|
|
50
|
+
) return
|
|
51
|
+
let holder = typeof current == 'string'
|
|
52
|
+
? `The execution claim for call ${eid} belongs to runner ${current}.`
|
|
53
|
+
: `Call ${eid} no longer has an execution claim.`
|
|
54
|
+
return `${holder} Read the call with graph_show. If it is running, wait for its result. ` +
|
|
55
|
+
`Read any recorded result with graph_query using .result.call=${eid}. ` +
|
|
56
|
+
'If you are updating pending calls, re-query with .call !execution !interrupted ' +
|
|
57
|
+
'and your original filters, then retry with only the calls that still match.'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A stored claim exists but no result does. The caller must reconcile it:
|
|
61
|
+
* running the tool again could repeat an effect the outside world already
|
|
62
|
+
* saw. */
|
|
63
|
+
export class UnfinishedCall extends Error {
|
|
64
|
+
constructor(public call: Eid) {
|
|
65
|
+
super('Call execution was started without a recorded result: ' + call)
|
|
66
|
+
this.name = 'UnfinishedCall'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Work cut off deliberately, not a refusal or a defect. */
|
|
71
|
+
export class Interrupted extends Error {
|
|
72
|
+
code: string
|
|
73
|
+
constructor(message: string, code = 'aborted') {
|
|
74
|
+
super(message)
|
|
75
|
+
this.name = 'Interrupted'
|
|
76
|
+
this.code = code
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Say a refusal once when its message already starts with its code. */
|
|
81
|
+
export let refusalText = (code: string, message: string): string => {
|
|
82
|
+
let first = /^\w+/.exec(message)?.[0]
|
|
83
|
+
return first && first.toLowerCase() == code.toLowerCase()
|
|
84
|
+
? message
|
|
85
|
+
: [code, message].filter(Boolean).join(': ')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let codes: Record<string, number> = {
|
|
89
|
+
access: 403,
|
|
90
|
+
arguments: 400,
|
|
91
|
+
conflict: 409,
|
|
92
|
+
limit: 429,
|
|
93
|
+
missing: 404,
|
|
94
|
+
unavailable: 503,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The HTTP status a failure answers with: a refusal's, by its code, else
|
|
98
|
+
* the graph's table (@yaks/graph `status`, 500 for a defect).
|
|
99
|
+
*
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { assertEquals } from '@std/assert'
|
|
102
|
+
* import { CallError, statusOf } from './errors.ts'
|
|
103
|
+
*
|
|
104
|
+
* assertEquals(statusOf(new CallError('missing', 'no app a/b')), 404)
|
|
105
|
+
* assertEquals(statusOf(new Error('boom')), 500)
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export let statusOf = (e: unknown): number =>
|
|
109
|
+
e instanceof CallError ? codes[e.code] ?? 400 : status(e)
|
|
110
|
+
|
|
111
|
+
/** A thrown invocation refusal as its JSON HTTP answer, and a service that
|
|
112
|
+
* did not answer for now (@yaks/graph `unheard`) as `unavailable`. Defects
|
|
113
|
+
* are thrown through so the host's failure boundary can report them. */
|
|
114
|
+
export let refused = (e: unknown): Response => {
|
|
115
|
+
let code = e instanceof CallError
|
|
116
|
+
? e.code
|
|
117
|
+
: unheard(e)
|
|
118
|
+
? 'unavailable'
|
|
119
|
+
: e instanceof Error
|
|
120
|
+
? e.name.toLowerCase()
|
|
121
|
+
: 'refused'
|
|
122
|
+
let statusCode = statusOf(e)
|
|
123
|
+
if (statusCode >= 500 && !(e instanceof CallError) && !unheard(e)) throw e
|
|
124
|
+
return Response.json({
|
|
125
|
+
error: { code, message: e instanceof Error ? e.message : String(e) },
|
|
126
|
+
}, { status: statusCode })
|
|
127
|
+
}
|
package/fault.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// An exception keeps what the runtime caught; reporting skips failures that
|
|
2
|
+
// clear on their own, whether the exception was recorded or storage failed.
|
|
3
|
+
let transient = [
|
|
4
|
+
/timed? ?out|timeout/i,
|
|
5
|
+
/temporarily unavailable|try again|rate limit/i,
|
|
6
|
+
/econnreset|econnrefused|socket hang up|network/i,
|
|
7
|
+
/\bhttp 5\d\d\b/i,
|
|
8
|
+
/responses: transport failed/i
|
|
9
|
+
];
|
|
10
|
+
/** Whether a failure is worth reporting: anything but a known transient. */ export let actionable = (message)=>!transient.some((re)=>re.test(message));
|
|
11
|
+
/** What was thrown, for an answer or transcript entry. */ export let exceptionOf = (error)=>error instanceof Error ? {
|
|
12
|
+
type: error.name,
|
|
13
|
+
value: error.message
|
|
14
|
+
} : {
|
|
15
|
+
value: String(error)
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=fault.js.map
|
package/fault.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fault.js","sources":["./fault.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAG5E,IAAI,YAAY;EACd;EACA;EACA;EACA;EACA;CACD;AAED,0EAA0E,GAC1E,OAAO,IAAI,aAAa,CAAC,UACvB,CAAC,UAAU,IAAI,CAAC,CAAC,KAAO,GAAG,IAAI,CAAC,UAAS;AAE3C,wDAAwD,GACxD,OAAO,IAAI,cAAc,CAAC,QACxB,iBAAiB,QACb;IACA,MAAM,MAAM,IAAI;IAChB,OAAO,MAAM,OAAO;EACtB,IACE;IAAE,OAAO,OAAO;EAAO,EAAC"}
|
package/fault.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// An exception keeps what the runtime caught; reporting skips failures that
|
|
2
|
+
// clear on their own, whether the exception was recorded or storage failed.
|
|
3
|
+
import type { Comp } from 'jsr:@yaks/graph@0.2.36'
|
|
4
|
+
|
|
5
|
+
let transient = [
|
|
6
|
+
/timed? ?out|timeout/i,
|
|
7
|
+
/temporarily unavailable|try again|rate limit/i,
|
|
8
|
+
/econnreset|econnrefused|socket hang up|network/i,
|
|
9
|
+
/\bhttp 5\d\d\b/i,
|
|
10
|
+
/responses: transport failed/i,
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
/** Whether a failure is worth reporting: anything but a known transient. */
|
|
14
|
+
export let actionable = (message: string): boolean =>
|
|
15
|
+
!transient.some((re) => re.test(message))
|
|
16
|
+
|
|
17
|
+
/** What was thrown, for an answer or transcript entry. */
|
|
18
|
+
export let exceptionOf = (error: unknown): Comp =>
|
|
19
|
+
error instanceof Error
|
|
20
|
+
? {
|
|
21
|
+
type: error.name,
|
|
22
|
+
value: error.message,
|
|
23
|
+
}
|
|
24
|
+
: { value: String(error) }
|
package/invoke.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// A tool's validation, caller identity, answer and fault, independent of persistence.
|
|
2
|
+
import { who } from "@yaks/graph/call";
|
|
3
|
+
import { signed } from "@yaks/graph/provenance";
|
|
4
|
+
import { Refused, status, unheard } from "@yaks/graph/errors";
|
|
5
|
+
import { QuerySyntax } from "@yaks/query/core";
|
|
6
|
+
import { asking } from "@yaks/graph/asker";
|
|
7
|
+
import { CallError, parsed, resolved, validated } from "./args.js";
|
|
8
|
+
import { Busy, Interrupted } from "./errors.js";
|
|
9
|
+
import { actionable, exceptionOf } from "./fault.js";
|
|
10
|
+
import { MOST } from "./result.js";
|
|
11
|
+
import { said } from "./said.js";
|
|
12
|
+
/** What a call cut off before its arguments were finished (`cut`) is
|
|
13
|
+
* answered: nothing ran, and how its writer, a model, fits it in a reply. */ export let CUT = 'This call was cut off: your reply reached its output limit ' + 'while writing it, so its arguments were incomplete and nothing ran. Make ' + 'it again with less in one reply: think less before it, and split a long ' + 'script or file across several smaller calls.';
|
|
14
|
+
/** What a rehearsal says after the batch it answers. */ let CHECKED = 'Checked: nothing was written. Its eids were made for ' + 'this check alone; the same call without check writes it, under eids of ' + 'its own.';
|
|
15
|
+
// An answer too long to send whole is refused, and so never reaches a door
|
|
16
|
+
// that would build its JSON in one string. It is measured one bundle at a
|
|
17
|
+
// time, stopping once past `most`, so measuring any answer costs at most that.
|
|
18
|
+
let measured = (answer, most)=>{
|
|
19
|
+
let size = 0;
|
|
20
|
+
for (let b of answer){
|
|
21
|
+
size += JSON.stringify(b).length;
|
|
22
|
+
if (size > most) {
|
|
23
|
+
throw new CallError('too_large', `the answer is ${answer.length} entities, past the ${most} ` + 'characters of JSON a call answers in: ask for fewer');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/** What an error refuses, when it is a refusal: a `CallError` with its code,
|
|
28
|
+
* or an error the graph's `status` puts below 500 (a `Refused` write, an
|
|
29
|
+
* `Unknown` name) with its name, each in its own words. Anything else is a
|
|
30
|
+
* defect, and refuses nothing. */ export let refusalOf = (error)=>{
|
|
31
|
+
let code = error instanceof CallError ? error.code : status(error) < 500 ? error.name : undefined;
|
|
32
|
+
if (code == undefined) return undefined;
|
|
33
|
+
let said = error.message || String(error);
|
|
34
|
+
return error instanceof QuerySyntax || error instanceof Refused && error.summary !== undefined || error instanceof CallError && error.detail ? {
|
|
35
|
+
code,
|
|
36
|
+
said,
|
|
37
|
+
summary: error.summary
|
|
38
|
+
} : {
|
|
39
|
+
code,
|
|
40
|
+
said
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/** Tell whoever hears refusals of one, reporting a hearer that fails rather
|
|
44
|
+
* than letting it change the call's answer. */ export let heard = async (opts, refusal, call, tool)=>{
|
|
45
|
+
try {
|
|
46
|
+
await opts.refused?.(refusal, call, tool);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
await opts.report?.(e, call, tool);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/** Invoke once, letting the owner retain the answer or return it in memory. */ export let invoke = async (call, tool, g, opts, land, defer = false)=>{
|
|
52
|
+
let id = call.entity.eid;
|
|
53
|
+
let host = opts.host ?? g;
|
|
54
|
+
let c = call.call;
|
|
55
|
+
// The tool the call asked for: the name its caller wrote, where it kept
|
|
56
|
+
// one, since a tool answering a name nobody serves (`otherwise`) is not it.
|
|
57
|
+
let asked = typeof c.name == 'string' && c.name ? c.name : tool.name;
|
|
58
|
+
// What a thrown error becomes: the fault as its own entity, recording
|
|
59
|
+
// which call it came from. An expected refusal ({@link refusalOf}) gets
|
|
60
|
+
// `refusal{code}` and is told to whoever hears refusals. Anything else is
|
|
61
|
+
// a defect, reported with its original thrown value.
|
|
62
|
+
let faulted = async (error)=>{
|
|
63
|
+
if (error instanceof Interrupted) {
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
entity: {
|
|
67
|
+
eid: '$fault'
|
|
68
|
+
},
|
|
69
|
+
content: {
|
|
70
|
+
body: String(error)
|
|
71
|
+
},
|
|
72
|
+
output: {
|
|
73
|
+
source: id
|
|
74
|
+
},
|
|
75
|
+
...g.vocab.comp('notice') ? {
|
|
76
|
+
notice: {}
|
|
77
|
+
} : {}
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
// A service that did not answer for now is said plainly, as
|
|
82
|
+
// `unavailable`: neither a defect nor a refusal of the tool's, so it is
|
|
83
|
+
// neither reported nor told to whoever hears refusals.
|
|
84
|
+
if (unheard(error)) {
|
|
85
|
+
return [
|
|
86
|
+
{
|
|
87
|
+
entity: {
|
|
88
|
+
eid: '$fault'
|
|
89
|
+
},
|
|
90
|
+
content: {
|
|
91
|
+
body: error.message
|
|
92
|
+
},
|
|
93
|
+
output: {
|
|
94
|
+
source: id
|
|
95
|
+
},
|
|
96
|
+
refusal: {
|
|
97
|
+
code: 'unavailable'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
let refusal = refusalOf(error);
|
|
103
|
+
if (!refusal && actionable(String(exceptionOf(error).value))) {
|
|
104
|
+
await opts.report?.(error, call, asked);
|
|
105
|
+
}
|
|
106
|
+
if (refusal) await heard(opts, refusal, call, asked);
|
|
107
|
+
// A refusal is said in its own words, which its code already classes;
|
|
108
|
+
// a defect keeps the name of what was thrown.
|
|
109
|
+
return [
|
|
110
|
+
{
|
|
111
|
+
entity: {
|
|
112
|
+
eid: '$fault'
|
|
113
|
+
},
|
|
114
|
+
content: {
|
|
115
|
+
body: refusal?.said ?? String(error)
|
|
116
|
+
},
|
|
117
|
+
output: {
|
|
118
|
+
source: id
|
|
119
|
+
},
|
|
120
|
+
...refusal ? {
|
|
121
|
+
refusal: {
|
|
122
|
+
code: refusal.code
|
|
123
|
+
}
|
|
124
|
+
} : {
|
|
125
|
+
exception: exceptionOf(error)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
];
|
|
129
|
+
};
|
|
130
|
+
let answered;
|
|
131
|
+
try {
|
|
132
|
+
// An unfinished call's arguments are not what its writer meant: whatever
|
|
133
|
+
// they spell, it is refused for what it is.
|
|
134
|
+
if (call.cut) throw new CallError('cut', CUT);
|
|
135
|
+
let args = await resolved(tool, validated(tool, parsed(c.args)), host);
|
|
136
|
+
let actor = who(call);
|
|
137
|
+
let called = {
|
|
138
|
+
...call,
|
|
139
|
+
call: {
|
|
140
|
+
...c,
|
|
141
|
+
args
|
|
142
|
+
},
|
|
143
|
+
...!call.created && actor ? {
|
|
144
|
+
created: {
|
|
145
|
+
...actor
|
|
146
|
+
}
|
|
147
|
+
} : {},
|
|
148
|
+
...opts.process ? {
|
|
149
|
+
process: opts.process
|
|
150
|
+
} : {}
|
|
151
|
+
};
|
|
152
|
+
// What the tool starts answers it, and the session that called it.
|
|
153
|
+
let made = await asking({
|
|
154
|
+
door: tool.name,
|
|
155
|
+
...actor?.via && {
|
|
156
|
+
session: actor.via
|
|
157
|
+
}
|
|
158
|
+
}, ()=>tool.run(called, host));
|
|
159
|
+
if (!tool.applied) made = signed(made, actor);
|
|
160
|
+
measured(made, opts.most ?? MOST);
|
|
161
|
+
// A rehearsal: `check: true` to a tool that writes runs the write's
|
|
162
|
+
// every phase and rolls it back, so the answer is the batch as a kept
|
|
163
|
+
// write would have returned it, or the refusal it would have met. It
|
|
164
|
+
// says so after the batch, since otherwise it reads as the write itself,
|
|
165
|
+
// eids and stamps and all: a caller that took one for the other wrote
|
|
166
|
+
// twice, or never. A tool that answers only its own words about the call
|
|
167
|
+
// has those words to say instead: it handled `check` itself (a session's
|
|
168
|
+
// tool, whose graph call ran a rehearsal of its own and said so).
|
|
169
|
+
// A write on a branch lands there, through the branch's graph, and the
|
|
170
|
+
// call's record stays on main with the rest of its caller's: the answer
|
|
171
|
+
// is the batch as the branch applied it, kept nowhere else.
|
|
172
|
+
let branch = typeof args.branch == 'number' && !tool.readOnly && !tool.applied ? args.branch : undefined;
|
|
173
|
+
if (branch !== undefined) {
|
|
174
|
+
let check = args.check === true;
|
|
175
|
+
let wrote = await host.apply(made, {
|
|
176
|
+
branch,
|
|
177
|
+
...check ? {
|
|
178
|
+
check
|
|
179
|
+
} : {}
|
|
180
|
+
});
|
|
181
|
+
answered = await land(check ? [
|
|
182
|
+
...wrote,
|
|
183
|
+
said(call, CHECKED)
|
|
184
|
+
] : wrote, 'done', false);
|
|
185
|
+
} else if (!tool.readOnly && !tool.applied && args.check === true) {
|
|
186
|
+
let rehearsed = await g.apply(made, {
|
|
187
|
+
check: true
|
|
188
|
+
});
|
|
189
|
+
let reported = made.length > 0 && made.every((b)=>b.entity.eid[0] == '$' && b.output?.source == id);
|
|
190
|
+
answered = await land(reported ? rehearsed : [
|
|
191
|
+
...rehearsed,
|
|
192
|
+
said(call, CHECKED)
|
|
193
|
+
], 'done', false);
|
|
194
|
+
} else {
|
|
195
|
+
answered = await land(made, 'done');
|
|
196
|
+
}
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (defer && error instanceof Busy) throw error;
|
|
199
|
+
// This catches both the tool's own throw and a rejection of what it
|
|
200
|
+
// returned: a transaction the graph refuses is this call's failure,
|
|
201
|
+
// rather than a call left claimed with nothing recorded about it.
|
|
202
|
+
let made = await faulted(error);
|
|
203
|
+
answered = await land(made, error instanceof Interrupted ? 'interrupted' : 'failed', undefined, error instanceof Interrupted ? error.code : undefined);
|
|
204
|
+
}
|
|
205
|
+
return answered;
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=invoke.js.map
|
package/invoke.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.js","sources":["./invoke.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,SAAS,GAAG,gCAAqC;AACjD,SAAS,MAAM,sCAA2C;AAC1D,SAAS,OAAO,EAAE,MAAM,EAAE,OAAO,kCAAuC;AACxE,SAAS,WAAW,gCAAqC;AACzD,SAAS,MAAM,iCAAsC;AAErD,SAAS,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,oBAAmB;AAClE,SAAS,IAAI,EAAE,WAAW,sBAAqB;AAC/C,SAAS,UAAU,EAAE,WAAW,qBAAoB;AACpD,SAAS,IAAI,sBAAqB;AAClC,SAAS,IAAI,oBAAmB;AAEhC;2EAC2E,GAC3E,OAAO,IA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