@brian-agent/codemode 0.0.0-stage → 0.1.0
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/README.md +373 -2
- package/dist/cloudflare.d.ts +53 -0
- package/dist/cloudflare.d.ts.map +1 -0
- package/dist/cloudflare.js +64 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/declarations.d.ts +43 -0
- package/dist/declarations.d.ts.map +1 -0
- package/dist/declarations.js +320 -0
- package/dist/declarations.js.map +1 -0
- package/dist/identifier.d.ts +6 -0
- package/dist/identifier.d.ts.map +1 -0
- package/dist/identifier.js +13 -0
- package/dist/identifier.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/portable.d.ts +15 -0
- package/dist/portable.d.ts.map +1 -0
- package/dist/portable.js +12 -0
- package/dist/portable.js.map +1 -0
- package/dist/runtime/execution.d.ts +66 -0
- package/dist/runtime/execution.d.ts.map +1 -0
- package/dist/runtime/execution.js +494 -0
- package/dist/runtime/execution.js.map +1 -0
- package/dist/runtime/host.d.ts +13 -0
- package/dist/runtime/host.d.ts.map +1 -0
- package/dist/runtime/host.js +86 -0
- package/dist/runtime/host.js.map +1 -0
- package/dist/runtime/inline.d.ts +63 -0
- package/dist/runtime/inline.d.ts.map +1 -0
- package/dist/runtime/inline.js +80 -0
- package/dist/runtime/inline.js.map +1 -0
- package/dist/runtime/prelude-source.d.ts +45 -0
- package/dist/runtime/prelude-source.d.ts.map +1 -0
- package/dist/runtime/prelude-source.js +520 -0
- package/dist/runtime/prelude-source.js.map +1 -0
- package/dist/runtime/protocol.d.ts +110 -0
- package/dist/runtime/protocol.d.ts.map +1 -0
- package/dist/runtime/protocol.js +15 -0
- package/dist/runtime/protocol.js.map +1 -0
- package/dist/runtime/remote.d.ts +102 -0
- package/dist/runtime/remote.d.ts.map +1 -0
- package/dist/runtime/remote.js +175 -0
- package/dist/runtime/remote.js.map +1 -0
- package/dist/runtime/vm.d.ts +24 -0
- package/dist/runtime/vm.d.ts.map +1 -0
- package/dist/runtime/vm.js +293 -0
- package/dist/runtime/vm.js.map +1 -0
- package/dist/runtime/worker.d.ts +2 -0
- package/dist/runtime/worker.d.ts.map +1 -0
- package/dist/runtime/worker.js +38 -0
- package/dist/runtime/worker.js.map +1 -0
- package/dist/source.d.ts +36 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +98 -0
- package/dist/source.js.map +1 -0
- package/dist/types.d.ts +246 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/wasm.d.ts +12 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +24 -0
- package/dist/wasm.js.map +1 -0
- package/package.json +75 -5
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import type { CodemodeWasmModule } from "./wasm.ts";
|
|
2
|
+
export interface CodemodeToolContext {
|
|
3
|
+
/**
|
|
4
|
+
* Aborted when the script finishes (including unawaited calls), the
|
|
5
|
+
* execution times out, the caller aborts, or the sandbox is closed.
|
|
6
|
+
*/
|
|
7
|
+
signal: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
/** A JSON Schema document. Only used to render declarations; values are not validated against it. */
|
|
10
|
+
export type CodemodeJsonSchema = {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
} | boolean;
|
|
13
|
+
export interface CodemodeTool {
|
|
14
|
+
/**
|
|
15
|
+
* The script calls tools as `tools.<id>(args)`, where `<id>` is the name with characters that
|
|
16
|
+
* are not valid in identifiers replaced by `_` (see `toCodemodeIdentifier`), and also as
|
|
17
|
+
* `tools["<name>"](args)`. Globals are called as `<name>(args)` and must be identifiers, or
|
|
18
|
+
* `<namespace>.<member>`, which groups them into a frozen namespace object.
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
/** Shown as a doc comment in {@link renderDeclarations}, and listed in `ALL_TOOLS` for tools. */
|
|
22
|
+
description?: string;
|
|
23
|
+
/** Schema of the single argument. Rendered as the parameter type; `unknown` when omitted. */
|
|
24
|
+
inputSchema?: CodemodeJsonSchema;
|
|
25
|
+
/** Schema of the resolved value. Rendered as the promise type; `unknown` when omitted. */
|
|
26
|
+
outputSchema?: CodemodeJsonSchema;
|
|
27
|
+
/** Globals only: `execute` receives all call arguments as an array instead of the first one. */
|
|
28
|
+
spread?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Globals only: TypeScript parameter list and return type for {@link renderDeclarations}, for
|
|
31
|
+
* example `(type: string, id?: string): Promise<Model[]>`. Replaces the rendering from the schemas.
|
|
32
|
+
*/
|
|
33
|
+
signature?: string;
|
|
34
|
+
/**
|
|
35
|
+
* `args` is whatever the script passed, after a JSON round trip. The return
|
|
36
|
+
* value must be JSON-serializable; a thrown error surfaces in the script as
|
|
37
|
+
* an `Error` with the same message.
|
|
38
|
+
*/
|
|
39
|
+
execute(args: unknown, context: CodemodeToolContext): Promise<unknown> | unknown;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* One item of the script's output, in the order the script produced it: `text()` and `console.*`
|
|
43
|
+
* produce text items, with `console: true` for `console.*`, and `image()` image items. `data` is base64.
|
|
44
|
+
*/
|
|
45
|
+
export type CodemodeOutputItem = {
|
|
46
|
+
type: "text";
|
|
47
|
+
text: string;
|
|
48
|
+
console?: true;
|
|
49
|
+
} | {
|
|
50
|
+
type: "image";
|
|
51
|
+
data: string;
|
|
52
|
+
mimeType: string;
|
|
53
|
+
};
|
|
54
|
+
export type CodemodeCallStatus = "ok" | "error" | "cancelled";
|
|
55
|
+
export interface CodemodeCall {
|
|
56
|
+
name: string;
|
|
57
|
+
status: CodemodeCallStatus;
|
|
58
|
+
durationMs: number;
|
|
59
|
+
}
|
|
60
|
+
export type CodemodeErrorKind =
|
|
61
|
+
/** The script threw or failed to parse. `name` and `stack` come from the script's error. */
|
|
62
|
+
"script"
|
|
63
|
+
/**
|
|
64
|
+
* The overall deadline expired, or a VM on the calling thread used up its interrupt budget.
|
|
65
|
+
* The execution ended and the VM was asked to stop; a worker or remote VM may still be computing.
|
|
66
|
+
*/
|
|
67
|
+
| "timeout"
|
|
68
|
+
/** The caller's signal fired or the sandbox was closed. The execution ended and the VM was asked to stop. */
|
|
69
|
+
| "aborted"
|
|
70
|
+
/**
|
|
71
|
+
* The VM or its transport failed outside the script's control (for example a wasm trap, a missing
|
|
72
|
+
* worker file, or a remote sandbox that failed).
|
|
73
|
+
*/
|
|
74
|
+
| "sandbox";
|
|
75
|
+
export interface CodemodeError {
|
|
76
|
+
kind: CodemodeErrorKind;
|
|
77
|
+
name?: string;
|
|
78
|
+
message: string;
|
|
79
|
+
stack?: string;
|
|
80
|
+
}
|
|
81
|
+
/** Keys the script changed with `store()`. Only successful executions report writes. */
|
|
82
|
+
export interface CodemodeStoreWrites {
|
|
83
|
+
set: Record<string, unknown>;
|
|
84
|
+
/** Keys stored as `undefined`. */
|
|
85
|
+
delete: string[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* `output` is kept for failed executions too, up to the failure. `exit()` completes with `value: undefined`.
|
|
89
|
+
* `during`: in a {@link CodemodeSandboxBase.start} run that the script itself ended (it returned, threw, or exited),
|
|
90
|
+
* the result being processed when it did.
|
|
91
|
+
*/
|
|
92
|
+
export type CodemodeResult = {
|
|
93
|
+
ok: true;
|
|
94
|
+
value: unknown;
|
|
95
|
+
output: CodemodeOutputItem[];
|
|
96
|
+
calls: CodemodeCall[];
|
|
97
|
+
storeWrites: CodemodeStoreWrites;
|
|
98
|
+
during?: CodemodeDuring;
|
|
99
|
+
} | {
|
|
100
|
+
ok: false;
|
|
101
|
+
error: CodemodeError;
|
|
102
|
+
output: CodemodeOutputItem[];
|
|
103
|
+
calls: CodemodeCall[];
|
|
104
|
+
during?: CodemodeDuring;
|
|
105
|
+
};
|
|
106
|
+
/** Options every sandbox accepts, wherever its VM runs. */
|
|
107
|
+
export interface CodemodeSandboxBaseOptions {
|
|
108
|
+
tools?: CodemodeTool[];
|
|
109
|
+
/**
|
|
110
|
+
* Functions exposed as top-level identifiers instead of on `tools`, for host helpers such as
|
|
111
|
+
* attaching an image to the result. They behave like tools (JSON round trip, promise result)
|
|
112
|
+
* but are not recorded in `result.calls`. Names must be identifiers and may not shadow the
|
|
113
|
+
* built-in globals (`tools`, `ALL_TOOLS`, `console`, `text`, `image`, `exit`, `store`, `load`).
|
|
114
|
+
*/
|
|
115
|
+
globals?: CodemodeTool[];
|
|
116
|
+
/**
|
|
117
|
+
* Overall deadline per execution, including time spent in tools. `Infinity` disables the
|
|
118
|
+
* deadline; the execution then only ends when the script settles or is aborted.
|
|
119
|
+
* Default: 300000.
|
|
120
|
+
*/
|
|
121
|
+
timeoutMs?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Maximum memory the QuickJS VM may allocate. Allocations beyond it fail inside the script as
|
|
124
|
+
* `InternalError: out of memory`. Default: no limit beyond wasm32's 4 GiB address space.
|
|
125
|
+
*/
|
|
126
|
+
memoryLimitBytes?: number;
|
|
127
|
+
}
|
|
128
|
+
/** Options of `CodemodeSandbox`, which runs each VM in a Node or Bun worker thread. */
|
|
129
|
+
export interface CodemodeSandboxOptions extends CodemodeSandboxBaseOptions {
|
|
130
|
+
/**
|
|
131
|
+
* Compiled `quickjs-wasi/quickjs.wasm`, usually from {@link loadQuickJSWasm}. Default:
|
|
132
|
+
* `loadQuickJSWasm()`, the file in the installed `quickjs-wasi` package. Pass it when that file
|
|
133
|
+
* is not on disk, for example in a Bun compiled executable.
|
|
134
|
+
*/
|
|
135
|
+
wasm?: CodemodeWasmModule | Promise<CodemodeWasmModule>;
|
|
136
|
+
/**
|
|
137
|
+
* Worker entry that imports `@brian-agent/codemode/worker`. Default: this package's own
|
|
138
|
+
* worker file. Pass it when this package is bundled, since the default is resolved relative to
|
|
139
|
+
* the module that creates the sandbox. Bun compiled executables require the relative string
|
|
140
|
+
* specifier of an embedded build entrypoint; other hosts usually use a URL.
|
|
141
|
+
*/
|
|
142
|
+
workerUrl?: string | URL;
|
|
143
|
+
/**
|
|
144
|
+
* Synchronously reserves capacity immediately before creating each worker, after loading wasm.
|
|
145
|
+
* Throw to deny admission without starting a worker. Return a release callback, called once if
|
|
146
|
+
* worker construction fails or when the worker actually exits, not when the result settles.
|
|
147
|
+
* The release callback must not throw. Reservations can be shared across sandbox instances.
|
|
148
|
+
*/
|
|
149
|
+
acquireWorker?(): () => void;
|
|
150
|
+
/**
|
|
151
|
+
* Called once for each worker started by execute() or start(). `exited` resolves when that worker
|
|
152
|
+
* actually exits, which may be after the result and close() settle: on Bun a non-interruptible
|
|
153
|
+
* built-in can delay termination. Use it to keep the worker counted against host concurrency
|
|
154
|
+
* limits until it exits. A thrown callback error fails the execution and requests worker termination.
|
|
155
|
+
*/
|
|
156
|
+
onWorkerStarted?(exited: Promise<void>): void;
|
|
157
|
+
}
|
|
158
|
+
/** A call the script made in a {@link CodemodeSandboxBase.start} run, answered with `CodemodeRun.deliver()`. */
|
|
159
|
+
export interface CodemodeHostCall {
|
|
160
|
+
/** The VM's own number for the call, `1`, `2`, ... in the order the script made its calls (tools and globals). */
|
|
161
|
+
id: number;
|
|
162
|
+
target: "tool" | "global";
|
|
163
|
+
name: string;
|
|
164
|
+
/** What the script passed, after a JSON round trip; for spread globals the argument list. */
|
|
165
|
+
args: unknown;
|
|
166
|
+
}
|
|
167
|
+
/** A tool as a {@link CodemodeSandboxBase.start} run's script sees it: `tools.<name>` and its `ALL_TOOLS` entry. */
|
|
168
|
+
export interface CodemodeDeclaredTool {
|
|
169
|
+
name: string;
|
|
170
|
+
/**
|
|
171
|
+
* The identifier the script uses, `tools.<jsName>`. Default: `toCodemodeIdentifier(name)`. A host that replays a run
|
|
172
|
+
* passes the one the run started with, so a changed mapping cannot rename a tool under a resumed script.
|
|
173
|
+
*/
|
|
174
|
+
jsName?: string;
|
|
175
|
+
description?: string;
|
|
176
|
+
}
|
|
177
|
+
/** A global as a {@link CodemodeSandboxBase.start} run's script sees it; the same names as `globals` allow. */
|
|
178
|
+
export interface CodemodeDeclaredGlobal {
|
|
179
|
+
name: string;
|
|
180
|
+
spread?: boolean;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A call's answer. A rejection becomes an `Error` with `message` in the script, carrying the own properties of
|
|
184
|
+
* `properties` (JSON values; `name`, `message`, and `stack` are ignored), for example `{ structuredOutput }`.
|
|
185
|
+
*/
|
|
186
|
+
export type CodemodeOutcome = {
|
|
187
|
+
ok: true;
|
|
188
|
+
value: unknown;
|
|
189
|
+
} | {
|
|
190
|
+
ok: false;
|
|
191
|
+
message: string;
|
|
192
|
+
properties?: Record<string, unknown>;
|
|
193
|
+
};
|
|
194
|
+
/** In a {@link CodemodeSandboxBase.start} run: the result the VM was processing when the script finished, 0 for its first run, and the calls issued by then. */
|
|
195
|
+
export interface CodemodeDuring {
|
|
196
|
+
seq: number;
|
|
197
|
+
issued: number;
|
|
198
|
+
}
|
|
199
|
+
export interface CodemodeRunOptions {
|
|
200
|
+
/** The VM clock's start, in ms since the epoch: `Date.now()` until the first result arrives. */
|
|
201
|
+
startedAt: number;
|
|
202
|
+
/** Seeds `Math.random()` and the VM's other randomness. A 32-bit unsigned integer. */
|
|
203
|
+
seed: number;
|
|
204
|
+
tools?: CodemodeDeclaredTool[];
|
|
205
|
+
globals?: CodemodeDeclaredGlobal[];
|
|
206
|
+
store?: Readonly<Record<string, unknown>>;
|
|
207
|
+
signal?: AbortSignal;
|
|
208
|
+
/** Deadline of this run in ms. Default: none (not the sandbox's default). */
|
|
209
|
+
timeoutMs?: number;
|
|
210
|
+
/** The VM's fingerprint, before the script runs and before any of its calls. */
|
|
211
|
+
onStarted?(fingerprint: string): void;
|
|
212
|
+
/** The script made a call. Answer it with `CodemodeRun.deliver()`, now or later. */
|
|
213
|
+
onCall(call: CodemodeHostCall): void;
|
|
214
|
+
/**
|
|
215
|
+
* The VM processed result `seq` (`0`: the script's first run, before any result) and waits again, having issued
|
|
216
|
+
* `issued` calls in total.
|
|
217
|
+
*/
|
|
218
|
+
onIdle?(seq: number, issued: number): void;
|
|
219
|
+
}
|
|
220
|
+
/** A running {@link CodemodeSandboxBase.start} execution. */
|
|
221
|
+
export interface CodemodeRun {
|
|
222
|
+
readonly result: Promise<CodemodeResult>;
|
|
223
|
+
/**
|
|
224
|
+
* Whether the run has its outcome: the script ended, timed out, or failed, or the run was aborted. Set when that is
|
|
225
|
+
* decided, before `result` settles; calls can no longer be answered. It does not mean the VM has exited.
|
|
226
|
+
*/
|
|
227
|
+
readonly finished: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Answer call `id` as result number `seq`. Results are numbered 1, 2, ... without gaps, and the VM applies them
|
|
230
|
+
* strictly in that order, whatever order they arrive in: after a gap it waits for the missing number. While it
|
|
231
|
+
* processes this one, its clock reads `now` (ms since the epoch), or the previous value if `now` is earlier.
|
|
232
|
+
* Throws for a call that is not waiting for an answer, a `seq` used before, or a `now` that is not finite.
|
|
233
|
+
*/
|
|
234
|
+
deliver(seq: number, now: number, id: number, outcome: CodemodeOutcome): void;
|
|
235
|
+
}
|
|
236
|
+
export interface CodemodeExecuteOptions {
|
|
237
|
+
signal?: AbortSignal;
|
|
238
|
+
/** Overrides the sandbox default for this execution. */
|
|
239
|
+
timeoutMs?: number;
|
|
240
|
+
/**
|
|
241
|
+
* Values the script reads with `load(key)`. Must be JSON-serializable. The script's own
|
|
242
|
+
* `store()` calls come back as `result.storeWrites`; persisting them is up to the caller.
|
|
243
|
+
*/
|
|
244
|
+
store?: Readonly<Record<string, unknown>>;
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,WAAW,mBAAmB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AAO,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,SAAS,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,oFAAoF;IACpF,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC;;;OAGG;IACH,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CAC9E;AAED,MAAM,WAAW,sBAAsB;IACtC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC1C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CodemodeWasmModule } from \"./wasm.ts\";\n\nexport interface CodemodeToolContext {\n\t/**\n\t * Aborted when the script finishes (including unawaited calls), the\n\t * execution times out, the caller aborts, or the sandbox is closed.\n\t */\n\tsignal: AbortSignal;\n}\n\n/** A JSON Schema document. Only used to render declarations; values are not validated against it. */\nexport type CodemodeJsonSchema = { [key: string]: unknown } | boolean;\n\nexport interface CodemodeTool {\n\t/**\n\t * The script calls tools as `tools.<id>(args)`, where `<id>` is the name with characters that\n\t * are not valid in identifiers replaced by `_` (see `toCodemodeIdentifier`), and also as\n\t * `tools[\"<name>\"](args)`. Globals are called as `<name>(args)` and must be identifiers, or\n\t * `<namespace>.<member>`, which groups them into a frozen namespace object.\n\t */\n\tname: string;\n\t/** Shown as a doc comment in {@link renderDeclarations}, and listed in `ALL_TOOLS` for tools. */\n\tdescription?: string;\n\t/** Schema of the single argument. Rendered as the parameter type; `unknown` when omitted. */\n\tinputSchema?: CodemodeJsonSchema;\n\t/** Schema of the resolved value. Rendered as the promise type; `unknown` when omitted. */\n\toutputSchema?: CodemodeJsonSchema;\n\t/** Globals only: `execute` receives all call arguments as an array instead of the first one. */\n\tspread?: boolean;\n\t/**\n\t * Globals only: TypeScript parameter list and return type for {@link renderDeclarations}, for\n\t * example `(type: string, id?: string): Promise<Model[]>`. Replaces the rendering from the schemas.\n\t */\n\tsignature?: string;\n\t/**\n\t * `args` is whatever the script passed, after a JSON round trip. The return\n\t * value must be JSON-serializable; a thrown error surfaces in the script as\n\t * an `Error` with the same message.\n\t */\n\texecute(args: unknown, context: CodemodeToolContext): Promise<unknown> | unknown;\n}\n\n/**\n * One item of the script's output, in the order the script produced it: `text()` and `console.*`\n * produce text items, with `console: true` for `console.*`, and `image()` image items. `data` is base64.\n */\nexport type CodemodeOutputItem =\n\t| { type: \"text\"; text: string; console?: true }\n\t| { type: \"image\"; data: string; mimeType: string };\n\nexport type CodemodeCallStatus = \"ok\" | \"error\" | \"cancelled\";\n\nexport interface CodemodeCall {\n\tname: string;\n\tstatus: CodemodeCallStatus;\n\tdurationMs: number;\n}\n\nexport type CodemodeErrorKind =\n\t/** The script threw or failed to parse. `name` and `stack` come from the script's error. */\n\t| \"script\"\n\t/**\n\t * The overall deadline expired, or a VM on the calling thread used up its interrupt budget.\n\t * The execution ended and the VM was asked to stop; a worker or remote VM may still be computing.\n\t */\n\t| \"timeout\"\n\t/** The caller's signal fired or the sandbox was closed. The execution ended and the VM was asked to stop. */\n\t| \"aborted\"\n\t/**\n\t * The VM or its transport failed outside the script's control (for example a wasm trap, a missing\n\t * worker file, or a remote sandbox that failed).\n\t */\n\t| \"sandbox\";\n\nexport interface CodemodeError {\n\tkind: CodemodeErrorKind;\n\tname?: string;\n\tmessage: string;\n\tstack?: string;\n}\n\n/** Keys the script changed with `store()`. Only successful executions report writes. */\nexport interface CodemodeStoreWrites {\n\tset: Record<string, unknown>;\n\t/** Keys stored as `undefined`. */\n\tdelete: string[];\n}\n\n/**\n * `output` is kept for failed executions too, up to the failure. `exit()` completes with `value: undefined`.\n * `during`: in a {@link CodemodeSandboxBase.start} run that the script itself ended (it returned, threw, or exited),\n * the result being processed when it did.\n */\nexport type CodemodeResult =\n\t| {\n\t\t\tok: true;\n\t\t\tvalue: unknown;\n\t\t\toutput: CodemodeOutputItem[];\n\t\t\tcalls: CodemodeCall[];\n\t\t\tstoreWrites: CodemodeStoreWrites;\n\t\t\tduring?: CodemodeDuring;\n\t }\n\t| {\n\t\t\tok: false;\n\t\t\terror: CodemodeError;\n\t\t\toutput: CodemodeOutputItem[];\n\t\t\tcalls: CodemodeCall[];\n\t\t\tduring?: CodemodeDuring;\n\t };\n\n/** Options every sandbox accepts, wherever its VM runs. */\nexport interface CodemodeSandboxBaseOptions {\n\ttools?: CodemodeTool[];\n\t/**\n\t * Functions exposed as top-level identifiers instead of on `tools`, for host helpers such as\n\t * attaching an image to the result. They behave like tools (JSON round trip, promise result)\n\t * but are not recorded in `result.calls`. Names must be identifiers and may not shadow the\n\t * built-in globals (`tools`, `ALL_TOOLS`, `console`, `text`, `image`, `exit`, `store`, `load`).\n\t */\n\tglobals?: CodemodeTool[];\n\t/**\n\t * Overall deadline per execution, including time spent in tools. `Infinity` disables the\n\t * deadline; the execution then only ends when the script settles or is aborted.\n\t * Default: 300000.\n\t */\n\ttimeoutMs?: number;\n\t/**\n\t * Maximum memory the QuickJS VM may allocate. Allocations beyond it fail inside the script as\n\t * `InternalError: out of memory`. Default: no limit beyond wasm32's 4 GiB address space.\n\t */\n\tmemoryLimitBytes?: number;\n}\n\n/** Options of `CodemodeSandbox`, which runs each VM in a Node or Bun worker thread. */\nexport interface CodemodeSandboxOptions extends CodemodeSandboxBaseOptions {\n\t/**\n\t * Compiled `quickjs-wasi/quickjs.wasm`, usually from {@link loadQuickJSWasm}. Default:\n\t * `loadQuickJSWasm()`, the file in the installed `quickjs-wasi` package. Pass it when that file\n\t * is not on disk, for example in a Bun compiled executable.\n\t */\n\twasm?: CodemodeWasmModule | Promise<CodemodeWasmModule>;\n\t/**\n\t * Worker entry that imports `@brian-agent/codemode/worker`. Default: this package's own\n\t * worker file. Pass it when this package is bundled, since the default is resolved relative to\n\t * the module that creates the sandbox. Bun compiled executables require the relative string\n\t * specifier of an embedded build entrypoint; other hosts usually use a URL.\n\t */\n\tworkerUrl?: string | URL;\n\t/**\n\t * Synchronously reserves capacity immediately before creating each worker, after loading wasm.\n\t * Throw to deny admission without starting a worker. Return a release callback, called once if\n\t * worker construction fails or when the worker actually exits, not when the result settles.\n\t * The release callback must not throw. Reservations can be shared across sandbox instances.\n\t */\n\tacquireWorker?(): () => void;\n\t/**\n\t * Called once for each worker started by execute() or start(). `exited` resolves when that worker\n\t * actually exits, which may be after the result and close() settle: on Bun a non-interruptible\n\t * built-in can delay termination. Use it to keep the worker counted against host concurrency\n\t * limits until it exits. A thrown callback error fails the execution and requests worker termination.\n\t */\n\tonWorkerStarted?(exited: Promise<void>): void;\n}\n\n/** A call the script made in a {@link CodemodeSandboxBase.start} run, answered with `CodemodeRun.deliver()`. */\nexport interface CodemodeHostCall {\n\t/** The VM's own number for the call, `1`, `2`, ... in the order the script made its calls (tools and globals). */\n\tid: number;\n\ttarget: \"tool\" | \"global\";\n\tname: string;\n\t/** What the script passed, after a JSON round trip; for spread globals the argument list. */\n\targs: unknown;\n}\n\n/** A tool as a {@link CodemodeSandboxBase.start} run's script sees it: `tools.<name>` and its `ALL_TOOLS` entry. */\nexport interface CodemodeDeclaredTool {\n\tname: string;\n\t/**\n\t * The identifier the script uses, `tools.<jsName>`. Default: `toCodemodeIdentifier(name)`. A host that replays a run\n\t * passes the one the run started with, so a changed mapping cannot rename a tool under a resumed script.\n\t */\n\tjsName?: string;\n\tdescription?: string;\n}\n\n/** A global as a {@link CodemodeSandboxBase.start} run's script sees it; the same names as `globals` allow. */\nexport interface CodemodeDeclaredGlobal {\n\tname: string;\n\tspread?: boolean;\n}\n\n/**\n * A call's answer. A rejection becomes an `Error` with `message` in the script, carrying the own properties of\n * `properties` (JSON values; `name`, `message`, and `stack` are ignored), for example `{ structuredOutput }`.\n */\nexport type CodemodeOutcome =\n\t| { ok: true; value: unknown }\n\t| { ok: false; message: string; properties?: Record<string, unknown> };\n\n/** In a {@link CodemodeSandboxBase.start} run: the result the VM was processing when the script finished, 0 for its first run, and the calls issued by then. */\nexport interface CodemodeDuring {\n\tseq: number;\n\tissued: number;\n}\n\nexport interface CodemodeRunOptions {\n\t/** The VM clock's start, in ms since the epoch: `Date.now()` until the first result arrives. */\n\tstartedAt: number;\n\t/** Seeds `Math.random()` and the VM's other randomness. A 32-bit unsigned integer. */\n\tseed: number;\n\ttools?: CodemodeDeclaredTool[];\n\tglobals?: CodemodeDeclaredGlobal[];\n\tstore?: Readonly<Record<string, unknown>>;\n\tsignal?: AbortSignal;\n\t/** Deadline of this run in ms. Default: none (not the sandbox's default). */\n\ttimeoutMs?: number;\n\t/** The VM's fingerprint, before the script runs and before any of its calls. */\n\tonStarted?(fingerprint: string): void;\n\t/** The script made a call. Answer it with `CodemodeRun.deliver()`, now or later. */\n\tonCall(call: CodemodeHostCall): void;\n\t/**\n\t * The VM processed result `seq` (`0`: the script's first run, before any result) and waits again, having issued\n\t * `issued` calls in total.\n\t */\n\tonIdle?(seq: number, issued: number): void;\n}\n\n/** A running {@link CodemodeSandboxBase.start} execution. */\nexport interface CodemodeRun {\n\treadonly result: Promise<CodemodeResult>;\n\t/**\n\t * Whether the run has its outcome: the script ended, timed out, or failed, or the run was aborted. Set when that is\n\t * decided, before `result` settles; calls can no longer be answered. It does not mean the VM has exited.\n\t */\n\treadonly finished: boolean;\n\t/**\n\t * Answer call `id` as result number `seq`. Results are numbered 1, 2, ... without gaps, and the VM applies them\n\t * strictly in that order, whatever order they arrive in: after a gap it waits for the missing number. While it\n\t * processes this one, its clock reads `now` (ms since the epoch), or the previous value if `now` is earlier.\n\t * Throws for a call that is not waiting for an answer, a `seq` used before, or a `now` that is not finite.\n\t */\n\tdeliver(seq: number, now: number, id: number, outcome: CodemodeOutcome): void;\n}\n\nexport interface CodemodeExecuteOptions {\n\tsignal?: AbortSignal;\n\t/** Overrides the sandbox default for this execution. */\n\ttimeoutMs?: number;\n\t/**\n\t * Values the script reads with `load(key)`. Must be JSON-serializable. The script's own\n\t * `store()` calls come back as `result.storeWrites`; persisting them is up to the caller.\n\t */\n\tstore?: Readonly<Record<string, unknown>>;\n}\n"]}
|
package/dist/wasm.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A compiled `WebAssembly.Module` of `quickjs-wasi/quickjs.wasm`. Typed opaquely because the Node
|
|
3
|
+
* type definitions do not declare the WebAssembly globals (they live in the DOM lib).
|
|
4
|
+
*/
|
|
5
|
+
export type CodemodeWasmModule = object;
|
|
6
|
+
/**
|
|
7
|
+
* Read and compile the QuickJS wasm once per path. `path` defaults to the file in the installed
|
|
8
|
+
* `quickjs-wasi` package; pass it when that file lives elsewhere, for example embedded in a Bun
|
|
9
|
+
* compiled executable. A failed load is retried on the next call.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadQuickJSWasm(path?: string): Promise<CodemodeWasmModule>;
|
|
12
|
+
//# sourceMappingURL=wasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAQxC;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAc1E"}
|
package/dist/wasm.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
const modules = new Map();
|
|
4
|
+
/**
|
|
5
|
+
* Read and compile the QuickJS wasm once per path. `path` defaults to the file in the installed
|
|
6
|
+
* `quickjs-wasi` package; pass it when that file lives elsewhere, for example embedded in a Bun
|
|
7
|
+
* compiled executable. A failed load is retried on the next call.
|
|
8
|
+
*/
|
|
9
|
+
export function loadQuickJSWasm(path) {
|
|
10
|
+
const resolved = path ?? createRequire(import.meta.url).resolve("quickjs-wasi/quickjs.wasm");
|
|
11
|
+
let module = modules.get(resolved);
|
|
12
|
+
if (!module) {
|
|
13
|
+
const { WebAssembly } = globalThis;
|
|
14
|
+
module = readFile(resolved)
|
|
15
|
+
.then((bytes) => WebAssembly.compile(bytes))
|
|
16
|
+
.catch((error) => {
|
|
17
|
+
modules.delete(resolved);
|
|
18
|
+
throw error;
|
|
19
|
+
});
|
|
20
|
+
modules.set(resolved, module);
|
|
21
|
+
}
|
|
22
|
+
return module;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=wasm.js.map
|
package/dist/wasm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAY5C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC5C,MAAM,QAAQ,GAAG,IAAI,IAAI,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC7F,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,EAAE,WAAW,EAAE,GAAG,UAA2D,CAAC;QACpF,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC;aACzB,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aAC3C,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACzB,MAAM,KAAK,CAAC;QACb,CAAC,CAAC,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\n\n/**\n * A compiled `WebAssembly.Module` of `quickjs-wasi/quickjs.wasm`. Typed opaquely because the Node\n * type definitions do not declare the WebAssembly globals (they live in the DOM lib).\n */\nexport type CodemodeWasmModule = object;\n\ninterface WebAssemblyGlobal {\n\tcompile(bytes: Uint8Array): Promise<CodemodeWasmModule>;\n}\n\nconst modules = new Map<string, Promise<CodemodeWasmModule>>();\n\n/**\n * Read and compile the QuickJS wasm once per path. `path` defaults to the file in the installed\n * `quickjs-wasi` package; pass it when that file lives elsewhere, for example embedded in a Bun\n * compiled executable. A failed load is retried on the next call.\n */\nexport function loadQuickJSWasm(path?: string): Promise<CodemodeWasmModule> {\n\tconst resolved = path ?? createRequire(import.meta.url).resolve(\"quickjs-wasi/quickjs.wasm\");\n\tlet module = modules.get(resolved);\n\tif (!module) {\n\t\tconst { WebAssembly } = globalThis as unknown as { WebAssembly: WebAssemblyGlobal };\n\t\tmodule = readFile(resolved)\n\t\t\t.then((bytes) => WebAssembly.compile(bytes))\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tmodules.delete(resolved);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tmodules.set(resolved, module);\n\t}\n\treturn module;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@brian-agent/codemode",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Sandboxed JavaScript execution where the only capability is calling injected tools",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./declarations": {
|
|
15
|
+
"source": "./src/declarations.ts",
|
|
16
|
+
"types": "./dist/declarations.d.ts",
|
|
17
|
+
"import": "./dist/declarations.js"
|
|
18
|
+
},
|
|
19
|
+
"./source": {
|
|
20
|
+
"source": "./src/source.ts",
|
|
21
|
+
"types": "./dist/source.d.ts",
|
|
22
|
+
"import": "./dist/source.js"
|
|
23
|
+
},
|
|
24
|
+
"./portable": {
|
|
25
|
+
"source": "./src/portable.ts",
|
|
26
|
+
"types": "./dist/portable.d.ts",
|
|
27
|
+
"import": "./dist/portable.js"
|
|
28
|
+
},
|
|
29
|
+
"./cloudflare": {
|
|
30
|
+
"source": "./src/cloudflare.ts",
|
|
31
|
+
"types": "./dist/cloudflare.d.ts",
|
|
32
|
+
"import": "./dist/cloudflare.js"
|
|
33
|
+
},
|
|
34
|
+
"./worker": {
|
|
35
|
+
"source": "./src/runtime/worker.ts",
|
|
36
|
+
"types": "./dist/runtime/worker.d.ts",
|
|
37
|
+
"import": "./dist/runtime/worker.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"README.md"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"clean": "shx rm -rf dist",
|
|
46
|
+
"build": "tsc -p tsconfig.build.json",
|
|
47
|
+
"test": "vitest --run",
|
|
48
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"brian",
|
|
52
|
+
"codemode",
|
|
53
|
+
"sandbox",
|
|
54
|
+
"quickjs",
|
|
55
|
+
"wasm",
|
|
56
|
+
"cloudflare",
|
|
57
|
+
"durable-objects"
|
|
58
|
+
],
|
|
59
|
+
"author": "Earendil Works",
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "git+https://github.com/embeputer/brian.git",
|
|
64
|
+
"directory": "packages/codemode"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=22.19.0"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"quickjs-wasi": "3.6.2"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"shx": "0.3.4",
|
|
74
|
+
"vitest": "5.0.0"
|
|
75
|
+
}
|
|
76
|
+
}
|