@yaks/code-mode 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 +86 -2
- package/_dist/files.d.ts +7 -0
- package/_dist/files.d.ts.map +1 -0
- package/_dist/mod.d.ts +107 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/repl.d.ts +25 -0
- package/_dist/repl.d.ts.map +1 -0
- package/_dist/scan.d.ts +5 -0
- package/_dist/scan.d.ts.map +1 -0
- package/_dist/source.d.ts +25 -0
- package/_dist/source.d.ts.map +1 -0
- package/_dist/types.d.ts +8 -0
- package/_dist/types.d.ts.map +1 -0
- package/_dist/vocab.d.ts +5 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/deno.json +1 -0
- package/files.js +88 -0
- package/files.js.map +1 -0
- package/files.ts +92 -0
- package/mod.js +432 -0
- package/mod.js.map +1 -0
- package/mod.ts +576 -0
- package/package.json +31 -4
- package/repl.js +85 -0
- package/repl.js.map +1 -0
- package/repl.ts +112 -0
- package/scan.js +246 -0
- package/scan.js.map +1 -0
- package/scan.ts +257 -0
- package/source.js +111 -0
- package/source.js.map +1 -0
- package/source.ts +180 -0
- package/types.js +62 -0
- package/types.js.map +1 -0
- package/types.ts +85 -0
- package/vocab.js +14 -0
- package/vocab.js.map +1 -0
- package/vocab.json +80 -0
- package/vocab.ts +14 -0
package/files.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// The script's two mounts, and its browser. Workerd owns the request-local
|
|
2
|
+
// /tmp filesystem; the app mount sees its draft through the caller's recorded
|
|
3
|
+
// tool calls.
|
|
4
|
+
export const FILE_BYTES = 1024 * 1024
|
|
5
|
+
|
|
6
|
+
export type FileScope = { space?: string; app?: string; draft?: string }
|
|
7
|
+
|
|
8
|
+
export let fileDeclarations = `
|
|
9
|
+
declare const fs: {
|
|
10
|
+
readFile(path: string): Promise<Uint8Array>
|
|
11
|
+
readFile(path: string, encoding: 'utf8' | { encoding: 'utf8' }): Promise<string>
|
|
12
|
+
writeFile(path: string, data: string | Uint8Array): Promise<void>
|
|
13
|
+
readdir(path: string): Promise<string[]>
|
|
14
|
+
unlink(path: string): Promise<void>
|
|
15
|
+
mkdir(path: string, options?: { recursive?: boolean }): Promise<void>
|
|
16
|
+
}`
|
|
17
|
+
|
|
18
|
+
export let browserDeclarations = `
|
|
19
|
+
/** A puppeteer Browser (@cloudflare/puppeteer) on Cloudflare's headless Chrome. */
|
|
20
|
+
declare const browser: {
|
|
21
|
+
launch(options?: { keep_alive?: number }): Promise<import('@cloudflare/puppeteer').Browser>
|
|
22
|
+
}`
|
|
23
|
+
|
|
24
|
+
export let fileModule = `import * as tmp from 'node:fs/promises';
|
|
25
|
+
import { Buffer } from 'node:buffer';
|
|
26
|
+
|
|
27
|
+
function locate(path) {
|
|
28
|
+
if (typeof path !== 'string' || path.includes('\\0') || path.includes('\\\\')) {
|
|
29
|
+
throw new TypeError('fs takes an absolute /tmp or /apps/<app> path');
|
|
30
|
+
}
|
|
31
|
+
let parts = path.split('/');
|
|
32
|
+
let [, mount, app, ...file] = parts;
|
|
33
|
+
if (parts[0] || !['tmp', 'apps'].includes(mount) || parts.includes('..') ||
|
|
34
|
+
(mount === 'apps' && !/^[a-z0-9][a-z0-9-]*$/.test(app ?? ''))) {
|
|
35
|
+
throw new TypeError('fs takes an absolute /tmp or /apps/<app> path without ..');
|
|
36
|
+
}
|
|
37
|
+
return mount === 'tmp' ? null : {app, path: file.filter(p => p && p !== '.').join('/')};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function filesystem(call) {
|
|
41
|
+
async function appFile(at, op, args) {
|
|
42
|
+
let result = await call(at.app, JSON.stringify({op, path: at.path || undefined, ...args}));
|
|
43
|
+
if (result.isError) throw new Error(result.content.map(c => c.text).join('\\n'));
|
|
44
|
+
return result.structuredContent;
|
|
45
|
+
}
|
|
46
|
+
function file(at, path) {
|
|
47
|
+
if (!at.path) throw new Error('EISDIR: ' + path);
|
|
48
|
+
return at;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
async readFile(path, options) {
|
|
52
|
+
let at = locate(path);
|
|
53
|
+
if (!at) return tmp.readFile(path, options);
|
|
54
|
+
let encoding = typeof options === 'string' ? options : options?.encoding;
|
|
55
|
+
let result = await appFile(file(at, path), 'read', {encoding: 'base64'});
|
|
56
|
+
let data = Buffer.from(result.base64, 'base64');
|
|
57
|
+
return encoding == null ? data : data.toString(encoding);
|
|
58
|
+
},
|
|
59
|
+
async writeFile(path, data) {
|
|
60
|
+
let at = locate(path);
|
|
61
|
+
if (!at) return tmp.writeFile(path, data);
|
|
62
|
+
if (typeof data !== 'string' && !ArrayBuffer.isView(data)) {
|
|
63
|
+
throw new TypeError('fs.writeFile takes a string or bytes');
|
|
64
|
+
}
|
|
65
|
+
let bytes = Buffer.from(data);
|
|
66
|
+
if (bytes.length > ${FILE_BYTES}) throw new Error('app files are limited to 1 MiB per fs write');
|
|
67
|
+
await appFile(file(at, path), 'write', {base64: bytes.toString('base64')});
|
|
68
|
+
},
|
|
69
|
+
async readdir(path) {
|
|
70
|
+
let at = locate(path);
|
|
71
|
+
if (!at) return tmp.readdir(path);
|
|
72
|
+
let {files} = await appFile(at, 'list', {path: undefined});
|
|
73
|
+
let prefix = at.path ? at.path + '/' : '';
|
|
74
|
+
let entries = files.filter(f => f.path.startsWith(prefix))
|
|
75
|
+
.map(f => f.path.slice(prefix.length).split('/')[0]);
|
|
76
|
+
if (at.path && !entries.length) {
|
|
77
|
+
let code = files.some(f => f.path === at.path) ? 'ENOTDIR' : 'ENOENT';
|
|
78
|
+
throw new Error(code + ': ' + path);
|
|
79
|
+
}
|
|
80
|
+
return [...new Set(entries)].sort();
|
|
81
|
+
},
|
|
82
|
+
async unlink(path) {
|
|
83
|
+
let at = locate(path);
|
|
84
|
+
if (!at) return tmp.unlink(path);
|
|
85
|
+
await appFile(file(at, path), 'delete');
|
|
86
|
+
},
|
|
87
|
+
async mkdir(path, options) {
|
|
88
|
+
if (locate(path)) throw new Error('app directories are created by writing a file in them');
|
|
89
|
+
return tmp.mkdir(path, options);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}`
|
package/mod.js
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/** Short, isolated code executions over a caller's scoped registry. The host
|
|
2
|
+
* supplies an evaluator and reads a script's TypeScript as JavaScript; this
|
|
3
|
+
* package owns discovery, limits and the bridge. */ import { argsOf, mint, who } from "@yaks/graph";
|
|
4
|
+
import { toolName } from "@yaks/graph/call";
|
|
5
|
+
import { system } from "@yaks/fp";
|
|
6
|
+
import { answerOf, CallError, faulted, heard, refusalOf, structured, texts, toolEid, valueIn } from "@yaks/tools";
|
|
7
|
+
import { catalog, declarations } from "./types.js";
|
|
8
|
+
import { described } from "./repl.js";
|
|
9
|
+
import { source, timedOut, TOO } from "./source.js";
|
|
10
|
+
import { browserDeclarations, FILE_BYTES, fileDeclarations } from "./files.js";
|
|
11
|
+
export { catalog, declarations } from "./types.js";
|
|
12
|
+
export { TOO } from "./source.js";
|
|
13
|
+
export { FILE_BYTES } from "./files.js";
|
|
14
|
+
export let LIMITS = {
|
|
15
|
+
wallMs: 30_000,
|
|
16
|
+
cpuMs: 100,
|
|
17
|
+
memoryMiB: 128,
|
|
18
|
+
calls: 16,
|
|
19
|
+
systemBytes: 33_554_432,
|
|
20
|
+
scriptBytes: 65_536
|
|
21
|
+
};
|
|
22
|
+
export let HOSTED_LIMITS = {
|
|
23
|
+
...LIMITS,
|
|
24
|
+
wallMs: 120_000,
|
|
25
|
+
cpuMs: 30_000,
|
|
26
|
+
calls: 64
|
|
27
|
+
};
|
|
28
|
+
let bytes = (v)=>new TextEncoder().encode(JSON.stringify(v)).length;
|
|
29
|
+
let message = (e)=>(e instanceof Error ? e.message : String(e)).slice(0, 1024);
|
|
30
|
+
let finished = (value, calls, error, more = {})=>{
|
|
31
|
+
if (bytes(value) > LIMITS.systemBytes) {
|
|
32
|
+
throw new CallError('limit', TOO.system);
|
|
33
|
+
}
|
|
34
|
+
let out = {
|
|
35
|
+
value,
|
|
36
|
+
calls: structuredClone(calls),
|
|
37
|
+
...error ? {
|
|
38
|
+
error
|
|
39
|
+
} : {},
|
|
40
|
+
...more
|
|
41
|
+
};
|
|
42
|
+
return out;
|
|
43
|
+
};
|
|
44
|
+
let said = (r)=>r.content.map((c)=>c.text).join('\n').slice(0, 1024);
|
|
45
|
+
/** All nested calls use admitted registry implementations, the outer caller's
|
|
46
|
+
* stamps and the ordinary runner. Arguments cannot select an actor or session. */ export let execute = async (script, registry, run, asked, evaluate, strip, opts = {})=>{
|
|
47
|
+
let { clock = system, current = ()=>Promise.resolve(run), kept, limits = LIMITS, files } = opts;
|
|
48
|
+
let repl = opts.repl ? {
|
|
49
|
+
repl: opts.repl
|
|
50
|
+
} : {};
|
|
51
|
+
let now = ()=>clock.now();
|
|
52
|
+
// The time spent finding nested calls' runners, and the time any nested
|
|
53
|
+
// call was running: parallel calls overlap, so it is the span they cover.
|
|
54
|
+
let reaching = 0, running = 0, busy = 0, since = 0;
|
|
55
|
+
// The runner by file app, kept until a call that may write ends.
|
|
56
|
+
let runners = new Map();
|
|
57
|
+
let runnerFor = (app)=>{
|
|
58
|
+
let live = runners.get(app);
|
|
59
|
+
if (live) return live;
|
|
60
|
+
live = current(app);
|
|
61
|
+
runners.set(app, live);
|
|
62
|
+
live.catch(()=>runners.get(app) == live && runners.delete(app));
|
|
63
|
+
return live;
|
|
64
|
+
};
|
|
65
|
+
let timedRun = async (id, name, work)=>{
|
|
66
|
+
let at = now();
|
|
67
|
+
if (!busy++) since = at;
|
|
68
|
+
try {
|
|
69
|
+
return await work();
|
|
70
|
+
} finally{
|
|
71
|
+
let end = now();
|
|
72
|
+
if (!--busy) running += end - since;
|
|
73
|
+
opts.timed?.call({
|
|
74
|
+
id,
|
|
75
|
+
name,
|
|
76
|
+
at,
|
|
77
|
+
ms: end - at
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
if (script.length > LIMITS.scriptBytes || bytes(script) > LIMITS.scriptBytes) {
|
|
82
|
+
throw new CallError('limit', TOO.script);
|
|
83
|
+
}
|
|
84
|
+
let entries = catalog(registry).filter((e)=>e.name != 'code_mode');
|
|
85
|
+
let allowed = new Map(entries.map((e)=>[
|
|
86
|
+
JSON.stringify(e.path),
|
|
87
|
+
e
|
|
88
|
+
]));
|
|
89
|
+
let calls = [];
|
|
90
|
+
let pending = new Set();
|
|
91
|
+
let controller = new AbortController();
|
|
92
|
+
let active = true;
|
|
93
|
+
let actor = who(asked);
|
|
94
|
+
// A nested call as the runner records it. Its id is minted before the
|
|
95
|
+
// bridge's first check, so whether the bridge refuses it or the runner
|
|
96
|
+
// does, it is heard under the one id the call keeps throughout.
|
|
97
|
+
let nested = (id, name, args)=>({
|
|
98
|
+
entity: {
|
|
99
|
+
eid: id
|
|
100
|
+
},
|
|
101
|
+
call: {
|
|
102
|
+
...name ? {
|
|
103
|
+
to: toolEid(name)
|
|
104
|
+
} : {},
|
|
105
|
+
...args === undefined ? {} : {
|
|
106
|
+
args
|
|
107
|
+
},
|
|
108
|
+
source: asked.entity.eid
|
|
109
|
+
},
|
|
110
|
+
...actor ? {
|
|
111
|
+
$actor: actor
|
|
112
|
+
} : {}
|
|
113
|
+
});
|
|
114
|
+
let hear = async (e, call, tool)=>{
|
|
115
|
+
let refusal = refusalOf(e);
|
|
116
|
+
if (refusal) await heard(opts, refusal, call, tool);
|
|
117
|
+
};
|
|
118
|
+
let read = async (id)=>{
|
|
119
|
+
try {
|
|
120
|
+
if (!active) throw new CallError('expired', 'execution has ended');
|
|
121
|
+
if (typeof id != 'string' || !id || id.length > 256) {
|
|
122
|
+
throw new CallError('args', 'results.read takes a result id');
|
|
123
|
+
}
|
|
124
|
+
if (!kept) throw new CallError('result', 'kept results are unavailable');
|
|
125
|
+
let value = await kept.read(id);
|
|
126
|
+
if (bytes(value) > LIMITS.systemBytes) {
|
|
127
|
+
throw new CallError('limit', TOO.system);
|
|
128
|
+
}
|
|
129
|
+
if (!active) throw new CallError('expired', 'execution has ended');
|
|
130
|
+
return value;
|
|
131
|
+
} catch (e) {
|
|
132
|
+
await hear(e, nested(mint()), 'results.read');
|
|
133
|
+
throw e;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
let call = async (set, name, args, app)=>{
|
|
137
|
+
let id = mint();
|
|
138
|
+
let named = typeof name == 'string' ? name : undefined;
|
|
139
|
+
let input;
|
|
140
|
+
let receipt;
|
|
141
|
+
let work;
|
|
142
|
+
try {
|
|
143
|
+
if (!active) throw new CallError('expired', 'execution has ended');
|
|
144
|
+
if (typeof set != 'string' || typeof name != 'string' || typeof args != 'string') throw new CallError('args', 'bridge takes JSON text');
|
|
145
|
+
let most = app === undefined ? LIMITS.scriptBytes : Math.ceil(FILE_BYTES / 3) * 4 + LIMITS.scriptBytes;
|
|
146
|
+
if (args.length > most || new TextEncoder().encode(args).length > most) {
|
|
147
|
+
throw new CallError('limit', app === undefined ? TOO.args : 'app files are limited to 1 MiB per fs write');
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
input = JSON.parse(args);
|
|
151
|
+
} catch {
|
|
152
|
+
throw new CallError('args', 'tool arguments must be JSON');
|
|
153
|
+
}
|
|
154
|
+
// A refusal names the tool the script asked for, as `tools[set][name]`
|
|
155
|
+
// spells it, so its words say which call was refused.
|
|
156
|
+
let path = `${set}.${name}`;
|
|
157
|
+
if (!allowed.has(JSON.stringify([
|
|
158
|
+
set,
|
|
159
|
+
name
|
|
160
|
+
]))) {
|
|
161
|
+
throw new CallError('tool', `tool ${path} is outside this execution scope`);
|
|
162
|
+
}
|
|
163
|
+
if (calls.length >= limits.calls) {
|
|
164
|
+
throw new CallError('limit', TOO.calls.replace('16', String(limits.calls)));
|
|
165
|
+
}
|
|
166
|
+
if (!input || typeof input != 'object' || Array.isArray(input)) {
|
|
167
|
+
throw new CallError('args', 'tool arguments must be an object');
|
|
168
|
+
}
|
|
169
|
+
if (app !== undefined) {
|
|
170
|
+
let { op, path, base64, encoding } = input;
|
|
171
|
+
input = {
|
|
172
|
+
op,
|
|
173
|
+
...path === undefined ? {} : {
|
|
174
|
+
path
|
|
175
|
+
},
|
|
176
|
+
...base64 === undefined ? {} : {
|
|
177
|
+
base64
|
|
178
|
+
},
|
|
179
|
+
...encoding === undefined ? {} : {
|
|
180
|
+
encoding
|
|
181
|
+
},
|
|
182
|
+
app,
|
|
183
|
+
...files?.space ? {
|
|
184
|
+
space: files.space
|
|
185
|
+
} : {},
|
|
186
|
+
...files?.app == app && files?.draft ? {
|
|
187
|
+
draft: files.draft
|
|
188
|
+
} : {}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
let made = {
|
|
192
|
+
id,
|
|
193
|
+
path: [
|
|
194
|
+
set,
|
|
195
|
+
name
|
|
196
|
+
],
|
|
197
|
+
pending: true
|
|
198
|
+
};
|
|
199
|
+
receipt = made;
|
|
200
|
+
calls.push(made);
|
|
201
|
+
work = (async ()=>{
|
|
202
|
+
let reached = now();
|
|
203
|
+
let live = await runnerFor(app);
|
|
204
|
+
reaching += now() - reached;
|
|
205
|
+
if (!active) throw new CallError('expired', 'execution has ended');
|
|
206
|
+
let admitted = live.admit(nested(id, name, input));
|
|
207
|
+
if (!admitted || admitted.tool.name != name) {
|
|
208
|
+
throw new CallError('tool', `tool ${path} is no longer available`);
|
|
209
|
+
}
|
|
210
|
+
await admitted.ensure();
|
|
211
|
+
await opts.beforeCall?.(set, admitted.tool);
|
|
212
|
+
if (!active) throw new CallError('expired', 'execution has ended');
|
|
213
|
+
let landed = await timedRun(id, name, ()=>admitted.call()).finally(()=>admitted.tool.readOnly || runners.clear());
|
|
214
|
+
let answer = answerOf(landed, id);
|
|
215
|
+
let failed = faulted(landed, id);
|
|
216
|
+
let result = {
|
|
217
|
+
content: texts(answer, Infinity).map((text)=>({
|
|
218
|
+
type: 'text',
|
|
219
|
+
text
|
|
220
|
+
})),
|
|
221
|
+
...!failed || !admitted.tool.outputSchema ? {
|
|
222
|
+
structuredContent: app !== undefined ? valueIn(answer) : structured(admitted.tool, answer)
|
|
223
|
+
} : {},
|
|
224
|
+
...failed ? {
|
|
225
|
+
isError: true
|
|
226
|
+
} : {}
|
|
227
|
+
};
|
|
228
|
+
if (bytes(result) > LIMITS.systemBytes) {
|
|
229
|
+
throw new CallError('limit', TOO.system);
|
|
230
|
+
}
|
|
231
|
+
if (answer.some((b)=>b.heard) || !failed && await opts.hears?.(admitted.tool, answer)) {
|
|
232
|
+
made.heard = true;
|
|
233
|
+
}
|
|
234
|
+
if (failed) Object.assign(made, {
|
|
235
|
+
isError: true,
|
|
236
|
+
error: said(result)
|
|
237
|
+
});
|
|
238
|
+
return result;
|
|
239
|
+
})();
|
|
240
|
+
pending.add(work);
|
|
241
|
+
return await work;
|
|
242
|
+
} catch (e) {
|
|
243
|
+
if (receipt) receipt.error = message(e);
|
|
244
|
+
await hear(e, nested(id, named, input), named);
|
|
245
|
+
throw e;
|
|
246
|
+
} finally{
|
|
247
|
+
if (receipt) delete receipt.pending;
|
|
248
|
+
if (work) pending.delete(work);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
let cancel = ()=>{};
|
|
252
|
+
let timeout = new Promise((_, reject)=>{
|
|
253
|
+
cancel = clock.after(limits.wallMs, ()=>{
|
|
254
|
+
active = false;
|
|
255
|
+
controller.abort();
|
|
256
|
+
reject(new CallError('timeout', timedOut(limits.wallMs)));
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
let compiling = now();
|
|
260
|
+
let browses = false, evaluating = 0, evaluated = 0;
|
|
261
|
+
try {
|
|
262
|
+
let text = await Promise.race([
|
|
263
|
+
(async ()=>source(script, entries, LIMITS.systemBytes, strip, {
|
|
264
|
+
wallMs: limits.wallMs,
|
|
265
|
+
files: !!files,
|
|
266
|
+
browser: opts.browser && /\bbrowser\b/.test(script) ? await opts.browser() : undefined,
|
|
267
|
+
cell: !!opts.repl
|
|
268
|
+
}))().then((modules)=>opts.repl ? described(modules) : modules).then((modules)=>{
|
|
269
|
+
opts.timed?.stage('compile', now() - compiling);
|
|
270
|
+
controller.signal.throwIfAborted();
|
|
271
|
+
browses = 'puppeteer.js' in modules;
|
|
272
|
+
evaluating = now();
|
|
273
|
+
return evaluate(modules, {
|
|
274
|
+
call: (set, name, args)=>call(set, name, args),
|
|
275
|
+
read,
|
|
276
|
+
...files ? {
|
|
277
|
+
file: (app, args)=>call('yaks', 'app_files', args, app)
|
|
278
|
+
} : {}
|
|
279
|
+
}, controller.signal).finally(()=>evaluated = now());
|
|
280
|
+
}),
|
|
281
|
+
timeout
|
|
282
|
+
]);
|
|
283
|
+
active = false;
|
|
284
|
+
await Promise.race([
|
|
285
|
+
Promise.allSettled([
|
|
286
|
+
...pending
|
|
287
|
+
]),
|
|
288
|
+
timeout
|
|
289
|
+
]);
|
|
290
|
+
if (typeof text != 'string' || text.length > LIMITS.systemBytes || new TextEncoder().encode(text).length > LIMITS.systemBytes) throw new CallError('limit', TOO.system);
|
|
291
|
+
let answer = JSON.parse(text);
|
|
292
|
+
let error = typeof answer.unkept == 'string' ? `the cell's values could not be kept: ${answer.unkept}` : answer.error;
|
|
293
|
+
return await finished(answer.value ?? null, calls, typeof error == 'string' ? error.slice(0, 1024) : undefined, {
|
|
294
|
+
...repl,
|
|
295
|
+
...Array.isArray(answer.dropped) && answer.dropped.length ? {
|
|
296
|
+
dropped: answer.dropped.map(String)
|
|
297
|
+
} : {}
|
|
298
|
+
});
|
|
299
|
+
} catch (e) {
|
|
300
|
+
return await finished(null, calls, message(e), repl);
|
|
301
|
+
} finally{
|
|
302
|
+
active = false;
|
|
303
|
+
controller.abort();
|
|
304
|
+
cancel();
|
|
305
|
+
if (busy) running += now() - since;
|
|
306
|
+
opts.timed?.stage('reach', reaching);
|
|
307
|
+
opts.timed?.stage('calls', running);
|
|
308
|
+
if (browses) {
|
|
309
|
+
let ran = (evaluated || now()) - evaluating;
|
|
310
|
+
opts.timed?.stage('browser', Math.max(0, ran - running));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
let pathsOf = (providers)=>{
|
|
315
|
+
let names = providers.filter(({ tools })=>tools.some((t)=>toolName(t) != 'code_mode')).map(({ name })=>name);
|
|
316
|
+
return names.length ? names.map((n)=>`tools.${n}.<name>(args)`).join(' or ') + ' (the set each tool is in, never another name)' : 'tools[set][name](args)';
|
|
317
|
+
};
|
|
318
|
+
/** How a script names a tool, by the sets it will see. */ export let sets = (registry)=>pathsOf(registry.providers());
|
|
319
|
+
let fields = {
|
|
320
|
+
name: 'code_mode',
|
|
321
|
+
title: 'Run code',
|
|
322
|
+
step: {
|
|
323
|
+
doing: 'Working through several steps…',
|
|
324
|
+
done: 'Worked through several steps'
|
|
325
|
+
},
|
|
326
|
+
inputSchema: {
|
|
327
|
+
type: 'object',
|
|
328
|
+
properties: {
|
|
329
|
+
script: {
|
|
330
|
+
type: 'string'
|
|
331
|
+
},
|
|
332
|
+
search: {
|
|
333
|
+
type: 'string'
|
|
334
|
+
},
|
|
335
|
+
offset: {
|
|
336
|
+
type: 'integer',
|
|
337
|
+
minimum: 0
|
|
338
|
+
},
|
|
339
|
+
limit: {
|
|
340
|
+
type: 'integer',
|
|
341
|
+
minimum: 1,
|
|
342
|
+
maximum: 20
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
additionalProperties: false
|
|
346
|
+
},
|
|
347
|
+
outputSchema: {
|
|
348
|
+
type: 'object',
|
|
349
|
+
properties: {
|
|
350
|
+
value: {},
|
|
351
|
+
calls: {
|
|
352
|
+
type: 'array',
|
|
353
|
+
items: {
|
|
354
|
+
type: 'object'
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
error: {
|
|
358
|
+
type: 'string'
|
|
359
|
+
},
|
|
360
|
+
declarations: {
|
|
361
|
+
type: 'string'
|
|
362
|
+
},
|
|
363
|
+
tools: {
|
|
364
|
+
type: 'array',
|
|
365
|
+
items: {
|
|
366
|
+
type: 'object'
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
limits: {
|
|
370
|
+
type: 'object'
|
|
371
|
+
},
|
|
372
|
+
next: {
|
|
373
|
+
type: [
|
|
374
|
+
'integer',
|
|
375
|
+
'null'
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
result_handle: {
|
|
379
|
+
type: 'string'
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
applied: true,
|
|
384
|
+
destructive: true,
|
|
385
|
+
openWorld: true
|
|
386
|
+
};
|
|
387
|
+
/** The code tool's public declaration from its providers, without building
|
|
388
|
+
* their registry or publishing any of the nested tools' schemas. */ export let definition = (providers, opts = {})=>({
|
|
389
|
+
...fields,
|
|
390
|
+
description: (opts.files ? 'Run JavaScript or TypeScript here. Use an async function body with return and await. Use fs for temporary files under /tmp and app draft files under /apps/<app>. Use fetch for HTTP requests. ' + (opts.browser ? "Use await browser.launch() for a puppeteer Browser on Cloudflare's headless Chrome; it closes when the run ends. " : '') : 'Use this for bulk reads, imports, reconciles and writes: keep source data and whole tool results inside a short JS/TS function body with return and await. ') + pathsOf(providers) + ' calls the same scoped tools, returning MCP content and structuredContent. Check isError before using a result. The answer is your return value plus a receipt per call. Large return values and tool results are kept in the graph; the answer gives their id, size, shape and preview. Use await results.read(id) to load a kept result. Omit script to read generated TypeScript declarations, with search, offset and limit for discovery. ' + `${(opts.limits ?? LIMITS).wallMs / 1000}s wall, ${(opts.limits ?? LIMITS).cpuMs}ms CPU, 128MiB isolate, ${(opts.limits ?? LIMITS).calls} calls, 64KiB script and tool arguments. ` + 'Started writes may complete after a script fails or times out; pending receipts mean the outcome is still unknown.'
|
|
391
|
+
});
|
|
392
|
+
/** One connector tool: omit script to discover generated declarations; supply
|
|
393
|
+
* a JS/TS function body to execute it with the same tool objects. */ export let tool = (registry, run, evaluate, strip, opts = {})=>({
|
|
394
|
+
...definition(registry.providers(), opts),
|
|
395
|
+
run: async (asked)=>{
|
|
396
|
+
let { script, search, offset = 0, limit = 20 } = argsOf(asked);
|
|
397
|
+
// A search lists what it finds the most fitting first.
|
|
398
|
+
let all = catalog(registry).filter((e)=>e.name != 'code_mode');
|
|
399
|
+
let matches = search ? registry.search(String(search)).flatMap((t)=>all.filter((e)=>e.name == t.name)) : all;
|
|
400
|
+
let start = Number(offset), end = start + Number(limit);
|
|
401
|
+
let value = script === undefined ? {
|
|
402
|
+
declarations: declarations(matches.slice(start, end)) + '\ndeclare const results: { read(id: string): Promise<any> }' + (opts.files ? fileDeclarations : '') + (opts.browser ? browserDeclarations : ''),
|
|
403
|
+
tools: matches.slice(start, end).map(({ path, description, inputSchema, outputSchema })=>({
|
|
404
|
+
path,
|
|
405
|
+
description,
|
|
406
|
+
inputSchema,
|
|
407
|
+
outputSchema
|
|
408
|
+
})),
|
|
409
|
+
next: end < matches.length ? end : null,
|
|
410
|
+
limits: opts.limits ?? LIMITS
|
|
411
|
+
} : await execute(String(script), registry, run, asked, evaluate, strip, opts);
|
|
412
|
+
if (bytes(value) > LIMITS.systemBytes) {
|
|
413
|
+
throw new CallError('limit', TOO.system);
|
|
414
|
+
}
|
|
415
|
+
let heard = 'calls' in value && value.calls.some((c)=>c.heard);
|
|
416
|
+
return [
|
|
417
|
+
{
|
|
418
|
+
entity: {
|
|
419
|
+
eid: mint()
|
|
420
|
+
},
|
|
421
|
+
output: {
|
|
422
|
+
source: asked.entity.eid,
|
|
423
|
+
value
|
|
424
|
+
},
|
|
425
|
+
...heard ? {
|
|
426
|
+
heard: {}
|
|
427
|
+
} : {}
|
|
428
|
+
}
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
//# sourceMappingURL=mod.js.map
|
package/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA;;kDAEkD,GAClD,SAAS,MAAM,EAAe,IAA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