@vvedantb/server 0.4.1 → 0.6.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/CHANGELOG.md +34 -0
- package/README.md +12 -5
- package/dist/artifacts/debounce.d.ts +16 -0
- package/dist/artifacts/debounce.js +49 -0
- package/dist/artifacts/document.d.ts +26 -0
- package/dist/artifacts/document.js +61 -0
- package/dist/artifacts/index.d.ts +8 -0
- package/dist/artifacts/index.js +8 -0
- package/dist/artifacts/limits.d.ts +21 -0
- package/dist/artifacts/limits.js +23 -0
- package/dist/artifacts/protocol.d.ts +45 -0
- package/dist/artifacts/protocol.js +243 -0
- package/dist/artifacts/schemas.d.ts +80 -0
- package/dist/artifacts/schemas.js +103 -0
- package/dist/artifacts/stateOps.d.ts +39 -0
- package/dist/artifacts/stateOps.js +92 -0
- package/dist/artifacts/storageShim.d.ts +9 -0
- package/dist/artifacts/storageShim.js +32 -0
- package/dist/artifacts/templates.d.ts +33 -0
- package/dist/artifacts/templates.js +496 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.js +2 -0
- package/dist/sandbox/runtime.d.ts +80 -0
- package/dist/sandbox/runtime.js +289 -0
- package/dist/sandbox/serialize.d.ts +10 -0
- package/dist/sandbox/serialize.js +21 -0
- package/docs/artifacts.md +116 -0
- package/docs/sandbox.md +140 -0
- package/package.json +18 -2
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { isJsonObject } from "../mcp/json.js";
|
|
2
|
+
export const DEFAULT_EXECUTE_LIMITS = {
|
|
3
|
+
deadlineMs: 60_000,
|
|
4
|
+
memoryBytes: 64 * 1024 * 1024,
|
|
5
|
+
stackBytes: 1024 * 1024,
|
|
6
|
+
maxCalls: 50,
|
|
7
|
+
maxMutatingCalls: 10,
|
|
8
|
+
maxLogLines: 200,
|
|
9
|
+
maxLogLineChars: 2_000,
|
|
10
|
+
};
|
|
11
|
+
const QUICKJS_MISSING = "The code sandbox needs the quickjs-emscripten-core and @jitl/quickjs-singlefile-cjs-release-sync packages, in a Node runtime";
|
|
12
|
+
let modulePromise;
|
|
13
|
+
// QuickJS is an optional peer, imported on first use and never at module load, so the package root stays loadable
|
|
14
|
+
// without it and V8 bundles of the root carry no WASM. Each import() is awaited directly in a try block, as in
|
|
15
|
+
// mcp-oauth-client/oauth.ts. The "browser" field in package.json maps both packages to empty modules for browser-platform
|
|
16
|
+
// bundles (Convex V8), whose bundler would otherwise follow the import into the variant's Node built-ins.
|
|
17
|
+
// tests-node/bundle.mjs checks both.
|
|
18
|
+
async function importQuickJs() {
|
|
19
|
+
try {
|
|
20
|
+
const core = await import("quickjs-emscripten-core");
|
|
21
|
+
const variant = await import("@jitl/quickjs-singlefile-cjs-release-sync");
|
|
22
|
+
if (typeof core.newQuickJSWASMModuleFromVariant !== "function")
|
|
23
|
+
throw new Error("QuickJS mapped to an empty module");
|
|
24
|
+
return { core, variant };
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new Error(QUICKJS_MISSING, { cause: error });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function importModule() {
|
|
31
|
+
const { core, variant } = await importQuickJs();
|
|
32
|
+
// The variant is CommonJS: Node and bundlers nest its default export differently, which the core unwraps.
|
|
33
|
+
return core.newQuickJSWASMModuleFromVariant(Promise.resolve(variant));
|
|
34
|
+
}
|
|
35
|
+
/** Loads the WASM module once per process; a failed load is retried next call. */
|
|
36
|
+
function loadModule() {
|
|
37
|
+
if (modulePromise === undefined) {
|
|
38
|
+
modulePromise = importModule().catch((err) => {
|
|
39
|
+
modulePromise = undefined;
|
|
40
|
+
throw err;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return modulePromise;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Globals the script sees. `tools` is a lazy proxy so any name routes to the
|
|
47
|
+
* host without the catalog living inside the VM; `search` is an ordinary tool
|
|
48
|
+
* the host supplies. `console` hands lines to the host instead of printing.
|
|
49
|
+
* Host `globals` arrive as JSON text and may not replace anything already
|
|
50
|
+
* global.
|
|
51
|
+
*/
|
|
52
|
+
const PRELUDE = `
|
|
53
|
+
for (const [name, value] of Object.entries(JSON.parse(globalThis.__globals))) {
|
|
54
|
+
if (name in globalThis || name === "tools" || name === "console" || name.startsWith("__")) {
|
|
55
|
+
throw new Error("Global name is reserved: " + name);
|
|
56
|
+
}
|
|
57
|
+
globalThis[name] = value;
|
|
58
|
+
}
|
|
59
|
+
delete globalThis.__globals;
|
|
60
|
+
const __format = (value) => {
|
|
61
|
+
if (typeof value === "string") return value;
|
|
62
|
+
try {
|
|
63
|
+
const json = JSON.stringify(value);
|
|
64
|
+
return json === undefined ? String(value) : json;
|
|
65
|
+
} catch {
|
|
66
|
+
return String(value);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const __consoleLog = (...args) => {
|
|
70
|
+
__log(args.map(__format).join(" "));
|
|
71
|
+
};
|
|
72
|
+
const console = { log: __consoleLog, info: __consoleLog, warn: __consoleLog, error: __consoleLog, debug: __consoleLog };
|
|
73
|
+
const __enumerationError = () =>
|
|
74
|
+
new Error('tools cannot be enumerated. Call tools.search({ query: "..." }) to find tools; an empty query lists them all.');
|
|
75
|
+
const tools = new Proxy({}, {
|
|
76
|
+
get(_target, prop) {
|
|
77
|
+
if (prop === "then" || typeof prop === "symbol") return undefined;
|
|
78
|
+
const name = String(prop);
|
|
79
|
+
return async (args) => {
|
|
80
|
+
const json = JSON.stringify(args === undefined ? {} : args);
|
|
81
|
+
if (json === undefined) throw new TypeError("Tool arguments must be JSON-serialisable");
|
|
82
|
+
return JSON.parse(await __invokeTool(name, json));
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
has() { return true; },
|
|
86
|
+
ownKeys() { throw __enumerationError(); },
|
|
87
|
+
getOwnPropertyDescriptor() { throw __enumerationError(); },
|
|
88
|
+
});
|
|
89
|
+
`;
|
|
90
|
+
function wrapScript(code) {
|
|
91
|
+
return `${PRELUDE}
|
|
92
|
+
(async () => {
|
|
93
|
+
${code}
|
|
94
|
+
})().then((value) => {
|
|
95
|
+
let json;
|
|
96
|
+
try {
|
|
97
|
+
json = JSON.stringify(value === undefined ? null : value);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
throw new Error("Return value is not JSON-serialisable: " + (err && err.message ? err.message : String(err)));
|
|
100
|
+
}
|
|
101
|
+
if (json === undefined) throw new Error("Return value is not JSON-serialisable: " + typeof value);
|
|
102
|
+
return json;
|
|
103
|
+
});`;
|
|
104
|
+
}
|
|
105
|
+
/** Turns a value dumped out of the VM (usually a thrown Error) into one line. */
|
|
106
|
+
function describeThrown(dumped) {
|
|
107
|
+
if (isJsonObject(dumped) && typeof dumped.message === "string") {
|
|
108
|
+
return typeof dumped.name === "string" && dumped.name !== "" ? `${dumped.name}: ${dumped.message}` : dumped.message;
|
|
109
|
+
}
|
|
110
|
+
if (typeof dumped === "string")
|
|
111
|
+
return dumped;
|
|
112
|
+
return JSON.stringify(dumped) ?? String(dumped);
|
|
113
|
+
}
|
|
114
|
+
function describeRejection(reason) {
|
|
115
|
+
if (reason instanceof Error)
|
|
116
|
+
return reason.message;
|
|
117
|
+
return typeof reason === "string" ? reason : (JSON.stringify(reason) ?? String(reason));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Runs `code` (the body of an async function) against `tools` inside a fresh
|
|
121
|
+
* QuickJS runtime. Never throws: every failure, including a missing or broken
|
|
122
|
+
* QuickJS install, is reported as an `ok: false` outcome.
|
|
123
|
+
*/
|
|
124
|
+
export async function runSandboxedScript(code, tools, limitOverrides = {}, options = {}) {
|
|
125
|
+
const limits = { ...DEFAULT_EXECUTE_LIMITS, ...limitOverrides };
|
|
126
|
+
const startedAt = Date.now();
|
|
127
|
+
const deadline = startedAt + limits.deadlineMs;
|
|
128
|
+
const calls = [];
|
|
129
|
+
// Collected on the host as they are written, so a failed run still returns them.
|
|
130
|
+
const logs = [];
|
|
131
|
+
let droppedLogs = 0;
|
|
132
|
+
const finish = (result) => {
|
|
133
|
+
const kept = droppedLogs > 0 ? [...logs, `… [${droppedLogs} more log lines truncated]`] : logs;
|
|
134
|
+
return { ...result, logs: kept, calls, ms: Date.now() - startedAt };
|
|
135
|
+
};
|
|
136
|
+
const fail = (error) => finish({ ok: false, error });
|
|
137
|
+
let quickJs;
|
|
138
|
+
try {
|
|
139
|
+
quickJs = await loadModule();
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
return fail(`Sandbox unavailable: ${describeRejection(err)}`);
|
|
143
|
+
}
|
|
144
|
+
const byName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
145
|
+
const runtime = quickJs.newRuntime();
|
|
146
|
+
runtime.setMemoryLimit(limits.memoryBytes);
|
|
147
|
+
runtime.setMaxStackSize(limits.stackBytes);
|
|
148
|
+
runtime.setInterruptHandler(() => Date.now() > deadline);
|
|
149
|
+
const vm = runtime.newContext();
|
|
150
|
+
const deferreds = [];
|
|
151
|
+
const pending = new Set();
|
|
152
|
+
let totalCalls = 0;
|
|
153
|
+
let mutatingCalls = 0;
|
|
154
|
+
// Host handlers can settle after this function has returned (a deadline hit
|
|
155
|
+
// while a slow tool is still running). Touching the vm then aborts the process.
|
|
156
|
+
let alive = true;
|
|
157
|
+
/** Asks `onCall`, then runs the tool unless it refused or stubbed the call. */
|
|
158
|
+
const callTool = async (tool, argsJson) => {
|
|
159
|
+
if (options.onCall !== undefined) {
|
|
160
|
+
const args = JSON.parse(argsJson);
|
|
161
|
+
const decision = await options.onCall({ name: tool.name, args, mutating: tool.mutating });
|
|
162
|
+
if ("stub" in decision)
|
|
163
|
+
return { json: JSON.stringify(decision.stub), skipped: true };
|
|
164
|
+
if (!decision.allow)
|
|
165
|
+
throw new Error(decision.error);
|
|
166
|
+
}
|
|
167
|
+
return { json: await tool.invoke(argsJson), skipped: false };
|
|
168
|
+
};
|
|
169
|
+
vm.newFunction("__log", (lineHandle) => {
|
|
170
|
+
if (logs.length >= limits.maxLogLines) {
|
|
171
|
+
droppedLogs += 1;
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const line = vm.getString(lineHandle);
|
|
175
|
+
logs.push(line.length > limits.maxLogLineChars ? `${line.slice(0, limits.maxLogLineChars)}… [truncated]` : line);
|
|
176
|
+
}).consume((fn) => vm.setProp(vm.global, "__log", fn));
|
|
177
|
+
vm.newFunction("__invokeTool", (nameHandle, argsHandle) => {
|
|
178
|
+
const name = vm.getString(nameHandle);
|
|
179
|
+
const argsJson = argsHandle === undefined ? "{}" : vm.getString(argsHandle);
|
|
180
|
+
const deferred = vm.newPromise();
|
|
181
|
+
deferreds.push(deferred);
|
|
182
|
+
pending.add(deferred);
|
|
183
|
+
void deferred.settled.then(() => pending.delete(deferred));
|
|
184
|
+
const rejectWith = (message) => {
|
|
185
|
+
vm.newError(message).consume((error) => deferred.reject(error));
|
|
186
|
+
};
|
|
187
|
+
const tool = byName.get(name);
|
|
188
|
+
if (tool === undefined) {
|
|
189
|
+
rejectWith(`Unknown tool: ${name}`);
|
|
190
|
+
return deferred.handle;
|
|
191
|
+
}
|
|
192
|
+
if (totalCalls >= limits.maxCalls) {
|
|
193
|
+
rejectWith(`Tool call limit (${limits.maxCalls}) reached`);
|
|
194
|
+
return deferred.handle;
|
|
195
|
+
}
|
|
196
|
+
if (tool.mutating && mutatingCalls >= limits.maxMutatingCalls) {
|
|
197
|
+
rejectWith(`Mutating tool call limit (${limits.maxMutatingCalls}) reached`);
|
|
198
|
+
return deferred.handle;
|
|
199
|
+
}
|
|
200
|
+
// Counted before onCall, so refused and stubbed calls use up the caps like real ones.
|
|
201
|
+
totalCalls += 1;
|
|
202
|
+
if (tool.mutating)
|
|
203
|
+
mutatingCalls += 1;
|
|
204
|
+
const callStartedAt = Date.now();
|
|
205
|
+
callTool(tool, argsJson).then(({ json, skipped }) => {
|
|
206
|
+
if (!alive)
|
|
207
|
+
return;
|
|
208
|
+
const ms = Date.now() - callStartedAt;
|
|
209
|
+
calls.push(skipped ? { name, ms, ok: true, skipped: true } : { name, ms, ok: true });
|
|
210
|
+
vm.newString(json).consume((value) => deferred.resolve(value));
|
|
211
|
+
}, (reason) => {
|
|
212
|
+
if (!alive)
|
|
213
|
+
return;
|
|
214
|
+
calls.push({ name, ms: Date.now() - callStartedAt, ok: false });
|
|
215
|
+
rejectWith(describeRejection(reason));
|
|
216
|
+
});
|
|
217
|
+
return deferred.handle;
|
|
218
|
+
}).consume((fn) => vm.setProp(vm.global, "__invokeTool", fn));
|
|
219
|
+
try {
|
|
220
|
+
vm.newString(JSON.stringify(options.globals ?? {})).consume((json) => vm.setProp(vm.global, "__globals", json));
|
|
221
|
+
const evaluated = vm.evalCode(wrapScript(code), "execute.js");
|
|
222
|
+
if (evaluated.error) {
|
|
223
|
+
const message = describeThrown(vm.dump(evaluated.error));
|
|
224
|
+
evaluated.error.dispose();
|
|
225
|
+
return fail(message);
|
|
226
|
+
}
|
|
227
|
+
const promise = evaluated.value;
|
|
228
|
+
try {
|
|
229
|
+
// Drive the VM: run microtasks, then either finish, wait for the next
|
|
230
|
+
// host tool to settle, or give up at the deadline. Jobs are pumped before
|
|
231
|
+
// the deadline check so an interrupt or OOM thrown inside the script
|
|
232
|
+
// surfaces as its own message rather than the generic deadline one.
|
|
233
|
+
for (;;) {
|
|
234
|
+
const jobs = runtime.executePendingJobs();
|
|
235
|
+
if (jobs.error) {
|
|
236
|
+
const message = describeThrown(vm.dump(jobs.error));
|
|
237
|
+
jobs.error.dispose();
|
|
238
|
+
return fail(message);
|
|
239
|
+
}
|
|
240
|
+
const state = vm.getPromiseState(promise);
|
|
241
|
+
if (state.type === "fulfilled") {
|
|
242
|
+
const json = vm.getString(state.value);
|
|
243
|
+
state.value.dispose();
|
|
244
|
+
const result = JSON.parse(json);
|
|
245
|
+
return finish({ ok: true, result });
|
|
246
|
+
}
|
|
247
|
+
if (state.type === "rejected") {
|
|
248
|
+
const message = describeThrown(vm.dump(state.error));
|
|
249
|
+
state.error.dispose();
|
|
250
|
+
return fail(message);
|
|
251
|
+
}
|
|
252
|
+
// Pending: `state.error` is a plain host Error here, not a handle.
|
|
253
|
+
if (Date.now() > deadline) {
|
|
254
|
+
return fail(`Execution exceeded ${limits.deadlineMs}ms`);
|
|
255
|
+
}
|
|
256
|
+
if (jobs.value > 0)
|
|
257
|
+
continue;
|
|
258
|
+
if (pending.size === 0) {
|
|
259
|
+
return fail("Execution stalled: the script's promise never settles");
|
|
260
|
+
}
|
|
261
|
+
let timer;
|
|
262
|
+
const deadlineTimer = new Promise((resolve) => {
|
|
263
|
+
timer = setTimeout(resolve, Math.max(0, deadline - Date.now()));
|
|
264
|
+
});
|
|
265
|
+
try {
|
|
266
|
+
await Promise.race([...[...pending].map((deferred) => deferred.settled), deadlineTimer]);
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
if (timer !== undefined)
|
|
270
|
+
clearTimeout(timer);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
promise.dispose();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch (err) {
|
|
279
|
+
return fail(`Sandbox failure: ${describeRejection(err)}`);
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
alive = false;
|
|
283
|
+
for (const deferred of deferreds)
|
|
284
|
+
if (deferred.alive)
|
|
285
|
+
deferred.dispose();
|
|
286
|
+
vm.dispose();
|
|
287
|
+
runtime.dispose();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExecuteOutcome } from "./runtime.js";
|
|
2
|
+
/** Serialised outcomes longer than this have their result cut down to a preview. */
|
|
3
|
+
export declare const DEFAULT_RESULT_CHAR_CAP = 100000;
|
|
4
|
+
/**
|
|
5
|
+
* Pretty JSON of an outcome for a tool reply: `{ result | error, logs, calls, ms }`.
|
|
6
|
+
* When a successful outcome serialises to more than `maxChars`, the result is
|
|
7
|
+
* replaced by `{ truncated, note, resultPreview }` holding its first `maxChars`
|
|
8
|
+
* characters, so the caller is told to filter inside the script instead.
|
|
9
|
+
*/
|
|
10
|
+
export declare function serializeExecuteOutcome(outcome: ExecuteOutcome, maxChars?: number): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Serialised outcomes longer than this have their result cut down to a preview. */
|
|
2
|
+
export const DEFAULT_RESULT_CHAR_CAP = 100_000;
|
|
3
|
+
/**
|
|
4
|
+
* Pretty JSON of an outcome for a tool reply: `{ result | error, logs, calls, ms }`.
|
|
5
|
+
* When a successful outcome serialises to more than `maxChars`, the result is
|
|
6
|
+
* replaced by `{ truncated, note, resultPreview }` holding its first `maxChars`
|
|
7
|
+
* characters, so the caller is told to filter inside the script instead.
|
|
8
|
+
*/
|
|
9
|
+
export function serializeExecuteOutcome(outcome, maxChars = DEFAULT_RESULT_CHAR_CAP) {
|
|
10
|
+
const base = { logs: outcome.logs, calls: outcome.calls, ms: outcome.ms };
|
|
11
|
+
const full = JSON.stringify(outcome.ok ? { result: outcome.result, ...base } : { error: outcome.error, ...base }, null, 2);
|
|
12
|
+
if (full.length <= maxChars || !outcome.ok)
|
|
13
|
+
return full;
|
|
14
|
+
const preview = JSON.stringify(outcome.result);
|
|
15
|
+
return JSON.stringify({
|
|
16
|
+
truncated: true,
|
|
17
|
+
note: `Result was ${preview.length} characters; showing the first ${maxChars}. Filter or summarise inside the script instead.`,
|
|
18
|
+
resultPreview: `${preview.slice(0, maxChars)}…`,
|
|
19
|
+
...base,
|
|
20
|
+
}, null, 2);
|
|
21
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Artifacts core (`@vvedantb/server`)
|
|
2
|
+
|
|
3
|
+
The backend-safe core for artifacts: standalone documents (HTML, Markdown, SVG, code, or typed JSON such as a quiz) that run offline in a sandboxed iframe or WebView and keep per-user state through a small bridge. Everything here is plain strings and data. There is no DOM, no React, and no Convex import, so the same code runs in a Convex V8 function, a Node server, a browser and React Native.
|
|
4
|
+
|
|
5
|
+
- **Contract**: Zod schemas for the artifact type and format, the state spec, typed bodies (`quizBodyV1`, `flashcardsBodyV1`), and list/detail rows. Built with your `z`.
|
|
6
|
+
- **State**: limits, the pure ops the host and the server both apply, storage-shim prefixes, and the host's save debounce.
|
|
7
|
+
- **Rendering**: the built-in quiz and flashcards pages, the document wrapper with its CSP, and the guest bootstrap.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { createArtifactSchemas, wrapArtifactDocument } from "@vvedantb/server";
|
|
12
|
+
|
|
13
|
+
const artifacts = createArtifactSchemas(z);
|
|
14
|
+
|
|
15
|
+
// Server: check a body before saving it.
|
|
16
|
+
const checked = artifacts.validateArtifactBody("quiz", "json", body, 1);
|
|
17
|
+
if (!checked.ok) throw new Error(checked.error);
|
|
18
|
+
|
|
19
|
+
// Client: build the iframe srcdoc from the row, its body and the user's state.
|
|
20
|
+
iframe.srcdoc = wrapArtifactDocument(body, row.format, state.data, {
|
|
21
|
+
title: row.title,
|
|
22
|
+
template: row.stateSpec?.template,
|
|
23
|
+
stateGlobalAliases: ["app"], // optional: window.app.state works as well as window.artifactState
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Contract
|
|
28
|
+
|
|
29
|
+
`createArtifactSchemas(z)` takes zod 3.25+ or 4 (zod is an optional peer and the package never imports it) and returns:
|
|
30
|
+
|
|
31
|
+
| Schema | Shape |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| `artifactType` | `ARTIFACT_TYPES`: `document`, `report`, `slides`, `infographic`, `mindmap`, `quiz`, `flashcards`, `diagram`, `code`. What the artifact is, for filters and icons. |
|
|
34
|
+
| `artifactFormat` | `ARTIFACT_FORMATS`: `html`, `markdown`, `svg`, `code`, `json`. How the body renders. |
|
|
35
|
+
| `stateSpec` | `{ stateVersion: int ≥ 1, keys: string[] (≤ 32, each 1–64 chars), template?: "quiz" \| "flashcards" }` |
|
|
36
|
+
| `quizBodyV1` | `{ title, questions: [{ id, prompt, options: 2–5 strings, correctIndex }] }` (≥ 1 question; `correctIndex` must point at an option) |
|
|
37
|
+
| `flashcardsBodyV1` | `{ title, cards: [{ id, front, back }] }` (≥ 1 card) |
|
|
38
|
+
| `listRow` | `ArtifactListRow`: `id`, `title` (1–200 chars), `description?` (≤ 280), `type`, `format`, `language?`, `schemaVersion`, `stateSpec?`, `currentVersion`, `size` (bytes), `origin: { client, externalId? }`, `createdAt`, `updatedAt`, `teamId?`. Metadata only. |
|
|
39
|
+
| `detailRow` | `ArtifactDetailRow`: a list row plus `body` (≤ 400,000 chars). |
|
|
40
|
+
|
|
41
|
+
Strings in the typed bodies are trimmed and must not be empty. Objects strip unknown keys. Ids are strings, so the rows work for any store and any client. `origin.client` is a free string naming the writer, not an enum.
|
|
42
|
+
|
|
43
|
+
`validateArtifactBody(type, format, body, schemaVersion = 1)` returns `{ ok: true, json? }` or `{ ok: false, error }`:
|
|
44
|
+
|
|
45
|
+
- Any body over `ARTIFACT_BODY_MAX_CHARS` (400,000 characters) fails.
|
|
46
|
+
- `json` is only valid for the types in `ARTIFACT_JSON_TYPES` (`quiz` and `flashcards`, version 1). The body must parse and match the typed schema; `json` is the parsed body.
|
|
47
|
+
- Other formats are strings and pass once under the cap.
|
|
48
|
+
|
|
49
|
+
## State
|
|
50
|
+
|
|
51
|
+
State is a `Record<string, string>` per user, per artifact. The guest JSON-encodes values. The host keeps a copy, answers the guest from it, and saves it through its own store. The server applies the same ops and limits, so a write the host accepted is never refused for size.
|
|
52
|
+
|
|
53
|
+
| Limit | Value |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `ARTIFACT_STATE_MAX_KEYS` | 32 keys |
|
|
56
|
+
| `ARTIFACT_STATE_MAX_KEY_LENGTH` | 64 characters (after trimming) |
|
|
57
|
+
| `ARTIFACT_STATE_MAX_VALUE_BYTES` | 16 KiB per value (UTF-8) |
|
|
58
|
+
| `ARTIFACT_STATE_MAX_TOTAL_BYTES` | 64 KiB in total, keys included (UTF-8) |
|
|
59
|
+
| `ARTIFACT_STATE_MIN_WRITE_INTERVAL_MS` | 1 s between server writes for one artifact and user |
|
|
60
|
+
| `ARTIFACT_STATE_DAILY_WRITES` | `{ free: 400, pro: 4000 }` writes per user per UTC day (`utcDayKey(now)`, for example `20261022`) |
|
|
61
|
+
| `ARTIFACT_STATE_DEBOUNCE_MS`, `ARTIFACT_STATE_MAX_WAIT_MS` | the host saves 5 s after the last change, and at least every 30 s while changes keep coming |
|
|
62
|
+
| `ARTIFACT_VERSION_KEEP` | 10 versions kept per artifact |
|
|
63
|
+
|
|
64
|
+
The package holds the numbers only. Enforcing the write interval and daily caps is the server's job, since it holds the counters.
|
|
65
|
+
|
|
66
|
+
- `applyArtifactStateOp(current, op)`: one guest op (`get`, `set`, `getAll`, `remove`, `reset`). Returns `{ data, value, error? }`. On an error, `data` is `current`.
|
|
67
|
+
- `applyArtifactStatePatch(current, { sets?, removes?, reset? })`: a batched write, applied as reset, then sets, then removes. All or nothing: on an error, `data` is `current`.
|
|
68
|
+
- `validateArtifactStateMap(data)`: the first limit broken, or `undefined`.
|
|
69
|
+
- `parseArtifactStateOp(message)`: the op in a guest message, or `undefined` when it is malformed.
|
|
70
|
+
- `createTrailingMaxDebounce(flush, trailingMs?, maxMs?, timers?)`: `{ schedule, flushNow, cancel, isPending }`. Call `flushNow()` on `pagehide` and when the frame unmounts.
|
|
71
|
+
- Storage shims: the guest's `localStorage` and `sessionStorage` live in the same map under `ARTIFACT_LOCAL_STORAGE_PREFIX` (`ls:`) and `ARTIFACT_SESSION_STORAGE_PREFIX` (`ss:`). `storageView`, `clearPrefixedKeys`, `prefixedStorageKey` and `unprefixStorageKey` read and edit them.
|
|
72
|
+
|
|
73
|
+
## Rendering
|
|
74
|
+
|
|
75
|
+
`wrapArtifactDocument(body, format, snapshot?, options?)` returns the `srcdoc`:
|
|
76
|
+
|
|
77
|
+
| Format | Document |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `html` | The page as is when it has `<html`; otherwise wrapped in a minimal page. |
|
|
80
|
+
| `svg` | Centred on a white page. |
|
|
81
|
+
| `markdown`, `code` | Escaped text in a `<pre>`. Render Markdown in the host when you want formatting. |
|
|
82
|
+
| `json` | The built-in quiz or flashcards page; escaped text when the body does not parse. |
|
|
83
|
+
|
|
84
|
+
`options.template` (from `stateSpec.template`) is tried first for any format, so an older HTML-format body that holds quiz JSON still renders. `options.title` is the heading when the body has none (default "Artifact"). `options.stateGlobalAliases` is passed to the guest (see below).
|
|
85
|
+
|
|
86
|
+
The CSP meta tag and the guest script go at the start of `<head>`. `ARTIFACT_CSP` allows inline scripts and styles, and `data:`/`blob:` images, fonts and media. It blocks every network request, frames, objects, forms and `<base>`. Render the document in an iframe with `sandbox="allow-scripts"` and **no** `allow-same-origin`, or in a WebView with the same isolation.
|
|
87
|
+
|
|
88
|
+
`wrapArtifactHtml(html, snapshot?, options?)` does the injection step only, for a document you built yourself. `artifactGuestScript(snapshot?, options?)` is the inline script alone (snapshot, aliases, then `GUEST_BOOTSTRAP_SCRIPT`), for a React Native WebView's `injectedJavaScriptBeforeContentLoaded`.
|
|
89
|
+
|
|
90
|
+
`buildQuizHtml({ title, questions })` and `buildFlashcardsHtml({ title, cards })` build the offline pages. They keep progress in `window.artifactState` (quiz: `answers`, `currentIndex`, `submitted`, `score`, `total`; flashcards: `index`, `known`, `seen`). `htmlFromArtifactTemplate({ title, content, template? })` parses `content` and builds the page, or returns `undefined`. Its parsers (`parseQuizTemplate`, `parseFlashcardsTemplate`) are lenient so older bodies still render without zod: they also take a bare array, `question` for `prompt`, and missing ids. Use `validateArtifactBody` for writes.
|
|
91
|
+
|
|
92
|
+
Download helpers: `ARTIFACT_FORMAT_FILES[format]` gives `{ extension, mime }`, and `artifactFileName(title, format)` a safe file name. `formatFromLanguage(language)` maps a code-fence language to a format (`html`/`htm`, `svg`, `md`/`markdown`, otherwise `code`).
|
|
93
|
+
|
|
94
|
+
## Bridge protocol
|
|
95
|
+
|
|
96
|
+
1. The guest bootstrap runs first. It reads `window.__ARTIFACT_SNAPSHOT__` and `window.__ARTIFACT_ALIASES__` (set by `artifactGuestScript`), deletes them, and posts `{ type: "artifact:ready" }` to the parent.
|
|
97
|
+
2. The host checks `event.source` is its frame, creates a `MessageChannel`, and posts `{ type: "artifact:port" }` with `port2`.
|
|
98
|
+
3. The guest sends `{ type: "artifact:state", requestId, op, key?, value? }` on the port. The host parses it with `parseArtifactStateOp`, applies it with `applyArtifactStateOp`, schedules a save after `set`, `remove` or `reset`, and answers `{ type: "artifact:state-result", requestId, ok, value?, error? }`.
|
|
99
|
+
|
|
100
|
+
In a React Native WebView the guest sends through `window.ReactNativeWebView.postMessage` (JSON strings) and the host answers with `artifact:state-result` window messages. The constants are `ARTIFACT_READY_TYPE`, `ARTIFACT_PORT_TYPE`, `ARTIFACT_STATE_TYPE` and `ARTIFACT_STATE_RESULT_TYPE`.
|
|
101
|
+
|
|
102
|
+
The guest API, with promises and JSON values:
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
await window.artifactState.set("score", 3);
|
|
106
|
+
const all = await window.artifactState.getAll(); // { score: "3", ... } raw strings
|
|
107
|
+
await window.artifactState.get("score"); // "3"
|
|
108
|
+
await window.artifactState.remove("score");
|
|
109
|
+
await window.artifactState.reset();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The guest checks the limits before sending, so an over-quota `set` rejects (and `localStorage.setItem` throws `QuotaExceededError`) without reaching the host.
|
|
113
|
+
|
|
114
|
+
### Aliases
|
|
115
|
+
|
|
116
|
+
An app whose existing artifacts call another global (for example `window.app.state`) passes `stateGlobalAliases: ["app"]`. Each alias becomes `window[alias] = { state }`, with the same `state` object as `window.artifactState`. Aliases must be JavaScript identifiers and must not name a global the page or the bootstrap needs (`window`, `document`, `localStorage`, `artifactState`, …). `assertStateGlobalAliases` throws on a bad one, and the wrappers call it.
|
package/docs/sandbox.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Code sandbox (`@vvedantb/server`)
|
|
2
|
+
|
|
3
|
+
Runs untrusted JavaScript, such as model-written scripts, in QuickJS compiled to WebAssembly. The script calls host tools through a `tools` proxy, logs with `console`, and returns a JSON value. The host decides which tools exist, can refuse or stub each call, and gets back the result, the logs and a record of every call.
|
|
4
|
+
|
|
5
|
+
Node only (a Convex `"use node"` action, a plain Node server, an Electron main process).
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { runSandboxedScript, serializeExecuteOutcome, type SandboxTool } from "@vvedantb/server";
|
|
9
|
+
|
|
10
|
+
const tools: SandboxTool[] = [
|
|
11
|
+
{
|
|
12
|
+
name: "list_items",
|
|
13
|
+
mutating: false,
|
|
14
|
+
invoke: async (argsJson) => JSON.stringify(await listItems(JSON.parse(argsJson))),
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "close_item",
|
|
18
|
+
mutating: true,
|
|
19
|
+
invoke: async (argsJson) => JSON.stringify(await closeItem(JSON.parse(argsJson))),
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const outcome = await runSandboxedScript(
|
|
24
|
+
`const { rows } = await tools.list_items({ status: args.status });
|
|
25
|
+
console.log("found", rows.length);
|
|
26
|
+
return rows.map((row) => row.id);`,
|
|
27
|
+
tools,
|
|
28
|
+
{ deadlineMs: 10_000 },
|
|
29
|
+
{ globals: { args: { status: "open" } } },
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (outcome.ok) console.log(outcome.result, outcome.logs, outcome.calls);
|
|
33
|
+
else console.error(outcome.error);
|
|
34
|
+
|
|
35
|
+
const reply = serializeExecuteOutcome(outcome); // pretty JSON for a tool reply, with a preview for large results
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
QuickJS is two optional peers. Install them where you run the sandbox:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm install quickjs-emscripten-core@^0.32.0 @jitl/quickjs-singlefile-cjs-release-sync@^0.32.0
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Both load on the first `runSandboxedScript` call, never when the package root is imported. The WASM module loads once per process; a failed load is retried on the next call. Without them, `runSandboxedScript` returns `{ ok: false, error: "Sandbox unavailable: …" }`.
|
|
47
|
+
|
|
48
|
+
The package's `browser` field maps both to empty modules, so browser-platform bundles of the root (Convex's default V8 runtime) never pull in QuickJS or its Node built-ins, even when it is installed. Node bundles (esbuild `platform: "node"`) include it. The variant is CommonJS and requires Node built-ins, so an ESM Node bundle needs esbuild's usual banner:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
banner: { js: `import { createRequire } from "node:module"; const require = createRequire(import.meta.url);` }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
| Export | What it does |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `runSandboxedScript(code, tools, limits?, options?)` | Runs `code` as the body of an async function in a fresh QuickJS runtime. Resolves to an `ExecuteOutcome`. Never throws. |
|
|
59
|
+
| `SandboxTool` | `{ name, mutating, invoke(argsJson): Promise<string> }`. `invoke` gets the JSON text of the single argument object and resolves to the JSON text of the result. A rejection's message is what the script sees. |
|
|
60
|
+
| `ExecuteLimits`, `DEFAULT_EXECUTE_LIMITS` | Per-run limits. Pass a partial object to override some. |
|
|
61
|
+
| `SandboxOptions` | `{ globals?, onCall? }`. See below. |
|
|
62
|
+
| `SandboxCall`, `SandboxCallDecision` | What `onCall` receives and returns. |
|
|
63
|
+
| `ExecuteOutcome` | `{ ok: true, result, logs, calls, ms }` or `{ ok: false, error, logs, calls, ms }`. |
|
|
64
|
+
| `SandboxCallRecord` | One entry of `calls`: `{ name, ms, ok, skipped? }`. |
|
|
65
|
+
| `serializeExecuteOutcome(outcome, maxChars?)`, `DEFAULT_RESULT_CHAR_CAP` | Pretty JSON of an outcome. See [Large results](#large-results). |
|
|
66
|
+
|
|
67
|
+
### Limits
|
|
68
|
+
|
|
69
|
+
| Field | Default | What happens at the limit |
|
|
70
|
+
| --- | --- | --- |
|
|
71
|
+
| `deadlineMs` | 60 000 | Wall clock for the whole run, including time in tools. Script code is interrupted (`InternalError: interrupted`); a run waiting on a tool fails with `Execution exceeded <n>ms`. |
|
|
72
|
+
| `memoryBytes` | 64 MB | QuickJS heap. The run fails with `InternalError: out of memory`. |
|
|
73
|
+
| `stackBytes` | 1 MB | QuickJS stack. The run fails with a stack overflow error. |
|
|
74
|
+
| `maxCalls` | 50 | Further calls reject with `Tool call limit (<n>) reached`. |
|
|
75
|
+
| `maxMutatingCalls` | 10 | Calls to `mutating` tools beyond this reject with `Mutating tool call limit (<n>) reached`. |
|
|
76
|
+
| `maxLogLines` | 200 | Later lines are dropped and counted in a last line, `… [<n> more log lines truncated]`. |
|
|
77
|
+
| `maxLogLineChars` | 2 000 | Longer lines are cut and end with `… [truncated]`. |
|
|
78
|
+
|
|
79
|
+
A rejected call is an ordinary rejection, so a script can catch it and carry on.
|
|
80
|
+
|
|
81
|
+
## Inside the script
|
|
82
|
+
|
|
83
|
+
- `await tools.<name>(args)` calls a host tool with one JSON-serialisable argument (`{}` when omitted) and resolves to the parsed JSON result. Arguments that do not serialise reject with `Tool arguments must be JSON-serialisable`. An unknown name rejects with `Unknown tool: <name>`.
|
|
84
|
+
- `tools` cannot be enumerated. `Object.keys(tools)` throws and points the script at `tools.search({ query })`. `search` is an ordinary tool: supply one named `search` if scripts should be able to find tools.
|
|
85
|
+
- `console.log`, `info`, `warn`, `error` and `debug` collect lines into `logs`. Strings print as they are; other values as JSON.
|
|
86
|
+
- `return` a JSON-serialisable value. `undefined` becomes `null`. Anything else (a `BigInt`, a function) fails the run with `Return value is not JSON-serialisable`.
|
|
87
|
+
- There is no `fetch`, `require`, `import`, `process`, timer or filesystem. A promise that can never settle (nothing pending on the host) fails with `Execution stalled: the script's promise never settles`.
|
|
88
|
+
|
|
89
|
+
## Options
|
|
90
|
+
|
|
91
|
+
### `globals`
|
|
92
|
+
|
|
93
|
+
JSON-serialisable values set as globals before the script runs, for example `{ args }` for script parameters. They are copied in as JSON, so the script cannot reach host objects through them. A name that would replace something already global (`JSON`, `Object`), `tools`, `console`, or any name starting with `__` fails the run with `Global name is reserved: <name>`.
|
|
94
|
+
|
|
95
|
+
### `onCall`
|
|
96
|
+
|
|
97
|
+
Called before each tool call, after the name and the call caps are checked:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
onCall: (call: { name: string; args: JsonValue; mutating: boolean }) =>
|
|
101
|
+
SandboxCallDecision | Promise<SandboxCallDecision>;
|
|
102
|
+
|
|
103
|
+
type SandboxCallDecision =
|
|
104
|
+
| { allow: true } // run the tool
|
|
105
|
+
| { allow: false; error: string } // the script's call rejects with `error`
|
|
106
|
+
| { stub: JsonInput }; // the call resolves to `stub`; the tool does not run
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- Allow-list: return `{ allow: false, error }` for tools the caller may not use. The tool does not run, and the call is recorded with `ok: false`.
|
|
110
|
+
- Dry run: return `{ stub }` for `mutating` calls. The script sees the stub as the result, and the call is recorded with `ok: true, skipped: true`.
|
|
111
|
+
- A hook that throws or rejects refuses the call with its message.
|
|
112
|
+
- Refused and stubbed calls count against `maxCalls` and `maxMutatingCalls` like real ones, so a dry run stops where a real run would.
|
|
113
|
+
|
|
114
|
+
## Outcome
|
|
115
|
+
|
|
116
|
+
- `result` (on success) is the returned JSON value. `error` (on failure) is one line, such as `TypeError: x is not a function` or `Execution exceeded 60000ms`.
|
|
117
|
+
- `logs` are kept on failure too, up to the point the run stopped.
|
|
118
|
+
- `calls` lists every tool call that reached the host and settled before the run ended, in settle order: `{ name, ms, ok, skipped? }`. Calls rejected for an unknown name or a cap are not listed. A tool still running when the run ends is left to finish; its result is ignored.
|
|
119
|
+
- `ms` is the wall-clock time of the whole run.
|
|
120
|
+
|
|
121
|
+
## Large results
|
|
122
|
+
|
|
123
|
+
`serializeExecuteOutcome(outcome, maxChars = DEFAULT_RESULT_CHAR_CAP)` returns `{ result | error, logs, calls, ms }` as pretty JSON. When a successful outcome serialises to more than `maxChars` (default 100 000), the result is replaced by a preview:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"truncated": true,
|
|
128
|
+
"note": "Result was 250000 characters; showing the first 100000. Filter or summarise inside the script instead.",
|
|
129
|
+
"resultPreview": "[{\"id\":…",
|
|
130
|
+
"logs": [],
|
|
131
|
+
"calls": [],
|
|
132
|
+
"ms": 42
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Failed outcomes are never cut.
|
|
137
|
+
|
|
138
|
+
## How it works
|
|
139
|
+
|
|
140
|
+
Each run gets a fresh QuickJS runtime and context with the heap, stack and interrupt limits set, and both are disposed when the run ends, on every path. It uses the synchronous QuickJS build with deferred promises, not the asyncify build: an asyncified host call made from a pending microtask crashes the WASM module. Each tool call returns a deferred promise that the host settles when the tool finishes, and the host pumps pending jobs until the script's own promise settles, the deadline passes, or nothing is left to wait for. Host results that arrive after the run has ended are ignored, because touching a disposed context aborts the process.
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "Shared Convex backend helpers, MCP server scaffolding and Node-side MCP OAuth client helpers from one root import: query-limit errors, Clerk auth and token verification, Clerk-user lookups and ensure-user for Convex functions, bearer tokens, env, CORS, JSON responses, MCP route registration, a bearer-auth MCP HTTP handler, OAuth metadata, a JSON-RPC dispatcher, explorer tools, WebCrypto primitives, Convex optimistic-update helpers,
|
|
5
|
+
"description": "Shared Convex backend helpers, MCP server scaffolding and Node-side MCP OAuth client helpers from one root import: query-limit errors, Clerk auth and token verification, Clerk-user lookups and ensure-user for Convex functions, bearer tokens, env, CORS, JSON responses, MCP route registration, a bearer-auth MCP HTTP handler, OAuth metadata, a JSON-RPC dispatcher, explorer tools, WebCrypto primitives, Convex optimistic-update helpers, MCP OAuth client helpers (provider, sign-in, refresh, revocation, loopback redirect server) for desktop apps, a QuickJS code sandbox that bridges script tool calls to host handlers, and a pure artifacts core (Zod contract, state limits and ops, quiz and flashcards pages, a sandboxed document wrapper with CSP and a guest state bridge).",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
@@ -21,15 +21,21 @@
|
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
+
"docs/artifacts.md",
|
|
24
25
|
"docs/convex.md",
|
|
25
26
|
"docs/crypto.md",
|
|
26
27
|
"docs/mcp.md",
|
|
27
28
|
"docs/mcp-oauth-client.md",
|
|
28
29
|
"docs/migration.md",
|
|
30
|
+
"docs/sandbox.md",
|
|
29
31
|
"CHANGELOG.md",
|
|
30
32
|
"LICENSE"
|
|
31
33
|
],
|
|
32
34
|
"sideEffects": false,
|
|
35
|
+
"browser": {
|
|
36
|
+
"quickjs-emscripten-core": false,
|
|
37
|
+
"@jitl/quickjs-singlefile-cjs-release-sync": false
|
|
38
|
+
},
|
|
33
39
|
"scripts": {
|
|
34
40
|
"build": "tsc -p tsconfig.json",
|
|
35
41
|
"typecheck": "tsc -p tsconfig.test.json",
|
|
@@ -38,28 +44,38 @@
|
|
|
38
44
|
},
|
|
39
45
|
"peerDependencies": {
|
|
40
46
|
"@clerk/backend": ">=1",
|
|
47
|
+
"@jitl/quickjs-singlefile-cjs-release-sync": "^0.32.0",
|
|
41
48
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
42
49
|
"convex": "^1.24.0",
|
|
50
|
+
"quickjs-emscripten-core": "^0.32.0",
|
|
43
51
|
"zod": "^3.25.0 || ^4.0.0"
|
|
44
52
|
},
|
|
45
53
|
"peerDependenciesMeta": {
|
|
46
54
|
"@clerk/backend": {
|
|
47
55
|
"optional": true
|
|
48
56
|
},
|
|
57
|
+
"@jitl/quickjs-singlefile-cjs-release-sync": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
49
60
|
"@modelcontextprotocol/sdk": {
|
|
50
61
|
"optional": true
|
|
51
62
|
},
|
|
52
63
|
"convex": {
|
|
53
64
|
"optional": true
|
|
54
65
|
},
|
|
66
|
+
"quickjs-emscripten-core": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
55
69
|
"zod": {
|
|
56
70
|
"optional": true
|
|
57
71
|
}
|
|
58
72
|
},
|
|
59
73
|
"devDependencies": {
|
|
74
|
+
"@jitl/quickjs-singlefile-cjs-release-sync": "^0.32.0",
|
|
60
75
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
61
76
|
"@types/node": "^22.0.0",
|
|
62
77
|
"convex": "^1.47.0",
|
|
78
|
+
"quickjs-emscripten-core": "^0.32.0",
|
|
63
79
|
"typescript": "^5.9.0",
|
|
64
80
|
"vitest": "^3.2.0",
|
|
65
81
|
"zod": "^4.0.0",
|