@vvedantb/server 0.4.1 → 0.5.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 +16 -0
- package/README.md +8 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -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/sandbox.md +140 -0
- package/package.json +17 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
Additive: a QuickJS code sandbox joins the root. Nothing in 0.4.1 changes.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `runSandboxedScript(code, tools, limits?, options?)`: runs untrusted JavaScript (the body of an async function) in a fresh QuickJS runtime. The script calls host tools with `await tools.<name>(args)`, logs with `console`, and returns a JSON value. Never throws; resolves to `{ ok, result | error, logs, calls, ms }`. See `docs/sandbox.md`.
|
|
10
|
+
- `DEFAULT_EXECUTE_LIMITS`: 60 s wall clock, 64 MB heap, 1 MB stack, 50 tool calls of which at most 10 mutating, logs capped at 200 lines of 2,000 characters. Every field can be overridden per run.
|
|
11
|
+
- `options.globals`: JSON-serialisable values set as VM globals, for example `{ args }`. Names that would replace an existing global are refused.
|
|
12
|
+
- `options.onCall`: called before each tool call with `{ name, args, mutating }`. Returns `{ allow: true }`, `{ allow: false, error }` (the script's call rejects; the tool does not run) or `{ stub }` (the call resolves to the stub; the tool does not run and the call is recorded with `skipped: true`). Refused and stubbed calls count against the call caps.
|
|
13
|
+
- `serializeExecuteOutcome(outcome, maxChars?)` and `DEFAULT_RESULT_CHAR_CAP` (100,000): pretty JSON of an outcome for a tool reply; a larger successful result becomes `{ truncated, note, resultPreview }`.
|
|
14
|
+
- Types: `SandboxTool`, `ExecuteLimits`, `ExecuteOutcome`, `SandboxOptions`, `SandboxCall`, `SandboxCallDecision`, `SandboxCallRecord`.
|
|
15
|
+
- New optional peers: `quickjs-emscripten-core` and `@jitl/quickjs-singlefile-cjs-release-sync` `^0.32.0`. They load on the first `runSandboxedScript` call, never when the root is imported. Without them the call returns `ok: false` with `Sandbox unavailable: …`.
|
|
16
|
+
- `package.json` `browser` field: maps both QuickJS packages to empty modules, so browser-platform bundles of the root (Convex V8) never include QuickJS or its Node built-ins, even when it is installed.
|
|
17
|
+
- Tests: `tests/sandbox` runs against real QuickJS (limits, deadline, out of memory, stack overflow, stalled promise, error mapping, disposal after a timeout, log caps, result preview, globals, `onCall` refusal and stubs, call caps). `tests-node/bundle.mjs` bundles the root for Convex V8 with QuickJS installed and checks no output contains it, and runs a Node bundle of the sandbox with no `node_modules`. `tests-node/esm-exports.mjs` covers the new exports and types, and the sandbox with and without QuickJS installed.
|
|
18
|
+
|
|
3
19
|
## 0.4.1
|
|
4
20
|
|
|
5
21
|
Docs and comments only; no runtime change.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vvedantb/server
|
|
2
2
|
|
|
3
|
-
Server-side helpers for Convex backends, Convex optimistic updates
|
|
3
|
+
Server-side helpers for Convex backends, Convex optimistic updates, Node-side MCP OAuth client helpers and a QuickJS code sandbox, from one root import.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
npm install @vvedantb/server
|
|
@@ -19,6 +19,7 @@ There are no subpath exports (0.2.0 removed `/convex` and `/mcp`; see [CHANGELOG
|
|
|
19
19
|
| Crypto | WebCrypto-only base64/base64url/hex, SHA-256, random tokens, `timingSafeEqual`, AES-GCM. Convex default runtime and Node 20+. | [docs/crypto.md](docs/crypto.md) |
|
|
20
20
|
| Optimistic updates | `mapLoadedQuery` (also `forEachLoadedQuery`, `updateAllCachedQueries`), `patchLoadedQuery`, `tempId`, `createMemoryOptimisticStore`. Client-side, no React. | [docs/convex.md](docs/convex.md#optimistic-updates-client-side) |
|
|
21
21
|
| MCP OAuth client | Node only (Electron main): OAuth provider over injected storage, sign-in, refresh, revocation, loopback redirect server. Node built-ins and the MCP SDK load on first use, so Convex V8 bundles of the root stay clean. | [docs/mcp-oauth-client.md](docs/mcp-oauth-client.md) |
|
|
22
|
+
| Code sandbox | Node only: `runSandboxedScript` runs untrusted JavaScript in QuickJS (WASM) with a `tools` proxy to host handlers, time, heap, stack, call and log limits, injected `globals`, and an `onCall` hook for allow-lists and dry runs. QuickJS loads on first call. | [docs/sandbox.md](docs/sandbox.md) |
|
|
22
23
|
|
|
23
24
|
Migration steps per app: [docs/migration.md](docs/migration.md).
|
|
24
25
|
|
|
@@ -30,24 +31,27 @@ All are optional. None is imported when the root loads.
|
|
|
30
31
|
- `zod` `^3.25.0 || ^4.0.0`: only if you pass zod schemas to `defineTool`, or your `z` to `createMcpOAuthStateSchema`.
|
|
31
32
|
- `convex` `^1.24.0`: types only, for the optimistic-update helpers. The package never imports `convex` at runtime: `registerMcpRoutes` and `createClerkUserAuth` type the router and ctx structurally, and `createMemoryOptimisticStore` carries its own copy of `getFunctionName` (`convex` is a dev dependency, used to check that real Convex types fit).
|
|
32
33
|
- `@modelcontextprotocol/sdk` `^1.29.0`: only for the MCP client OAuth calls, which import it on first use.
|
|
34
|
+
- `quickjs-emscripten-core` and `@jitl/quickjs-singlefile-cjs-release-sync` `^0.32.0`: only for `runSandboxedScript`, which imports them on first call. The `browser` field maps both to empty modules, so browser-platform bundles (Convex V8) of the root never include them.
|
|
33
35
|
|
|
34
36
|
No React, no web dependencies. `"sideEffects": false`. Compiled ESM with types in `dist`, built on pack.
|
|
35
37
|
|
|
36
38
|
## Layout
|
|
37
39
|
|
|
38
40
|
```
|
|
39
|
-
src/index.ts the only export: re-exports the
|
|
41
|
+
src/index.ts the only export: re-exports the five folders
|
|
40
42
|
src/convex/ Convex helpers and optimistic updates
|
|
41
43
|
src/mcp/ MCP scaffolding (imports ../convex by relative path)
|
|
42
44
|
src/mcp-oauth-client/ MCP OAuth client helpers (Node only; lazy node:http and SDK imports)
|
|
43
45
|
src/crypto/ WebCrypto primitives
|
|
46
|
+
src/sandbox/ QuickJS code sandbox (Node only; lazy QuickJS import)
|
|
44
47
|
tests/convex/ vitest
|
|
45
48
|
tests/mcp/ vitest, with fixtures/ (SDK captures, app references)
|
|
46
49
|
tests/mcp-oauth-client/ vitest, against fake MCP and authorization servers
|
|
47
50
|
tests/crypto/ vitest, with published vectors and app format parity
|
|
51
|
+
tests/sandbox/ vitest, against real QuickJS
|
|
48
52
|
tests-node/ plain Node checks of the built package: exports map and peers (esm-exports.mjs),
|
|
49
|
-
Convex V8 and Electron
|
|
50
|
-
docs/ convex.md, mcp.md, mcp-oauth-client.md, crypto.md, migration.md, migrated/<app>/
|
|
53
|
+
Convex V8 and Node/Electron bundles with esbuild (bundle.mjs)
|
|
54
|
+
docs/ convex.md, mcp.md, mcp-oauth-client.md, crypto.md, sandbox.md, migration.md, migrated/<app>/
|
|
51
55
|
scripts/ capture-sdk-fixtures.mjs
|
|
52
56
|
```
|
|
53
57
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { DEFAULT_EXECUTE_LIMITS, runSandboxedScript, type ExecuteLimits, type ExecuteOutcome, type SandboxCall, type SandboxCallDecision, type SandboxCallRecord, type SandboxOptions, type SandboxTool, } from "./runtime.js";
|
|
2
|
+
export { DEFAULT_RESULT_CHAR_CAP, serializeExecuteOutcome } from "./serialize.js";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type JsonInput, type JsonValue } from "../mcp/json.js";
|
|
2
|
+
export type SandboxTool = {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
/** true for tools that change state; counted against `maxMutatingCalls`. */
|
|
5
|
+
readonly mutating: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Receives the JSON text of the single argument object and resolves to the
|
|
8
|
+
* JSON text of the result. A rejection's message is what the script sees.
|
|
9
|
+
*/
|
|
10
|
+
readonly invoke: (argsJson: string) => Promise<string>;
|
|
11
|
+
};
|
|
12
|
+
export type ExecuteLimits = {
|
|
13
|
+
/** Wall clock for the whole execution, including time spent in tools. */
|
|
14
|
+
readonly deadlineMs: number;
|
|
15
|
+
/** QuickJS heap cap. */
|
|
16
|
+
readonly memoryBytes: number;
|
|
17
|
+
/** QuickJS stack cap. */
|
|
18
|
+
readonly stackBytes: number;
|
|
19
|
+
/** Total tool calls per execution. */
|
|
20
|
+
readonly maxCalls: number;
|
|
21
|
+
/** Subset cap for tools that change state. */
|
|
22
|
+
readonly maxMutatingCalls: number;
|
|
23
|
+
/** `console` lines kept; the rest are counted in one closing line. */
|
|
24
|
+
readonly maxLogLines: number;
|
|
25
|
+
/** Characters kept per `console` line. */
|
|
26
|
+
readonly maxLogLineChars: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const DEFAULT_EXECUTE_LIMITS: ExecuteLimits;
|
|
29
|
+
export type SandboxCallRecord = {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly ms: number;
|
|
32
|
+
readonly ok: boolean;
|
|
33
|
+
/** Set when `onCall` returned a stub, so the tool never ran. */
|
|
34
|
+
readonly skipped?: true;
|
|
35
|
+
};
|
|
36
|
+
type ExecuteTelemetry = {
|
|
37
|
+
readonly logs: readonly string[];
|
|
38
|
+
readonly calls: readonly SandboxCallRecord[];
|
|
39
|
+
readonly ms: number;
|
|
40
|
+
};
|
|
41
|
+
export type ExecuteOutcome = ({
|
|
42
|
+
readonly ok: true;
|
|
43
|
+
readonly result: JsonValue;
|
|
44
|
+
} & ExecuteTelemetry) | ({
|
|
45
|
+
readonly ok: false;
|
|
46
|
+
readonly error: string;
|
|
47
|
+
} & ExecuteTelemetry);
|
|
48
|
+
/** A tool call the script made, as `onCall` sees it, after the name and caps are checked. */
|
|
49
|
+
export type SandboxCall = {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly args: JsonValue;
|
|
52
|
+
readonly mutating: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* What `onCall` decides:
|
|
56
|
+
* - `{ allow: true }`: run the tool.
|
|
57
|
+
* - `{ allow: false, error }`: the script's call rejects with `error`; the tool does not run.
|
|
58
|
+
* - `{ stub }`: the call resolves to `stub` and the tool does not run (dry run). Recorded with `skipped: true`.
|
|
59
|
+
*/
|
|
60
|
+
export type SandboxCallDecision = {
|
|
61
|
+
readonly allow: true;
|
|
62
|
+
} | {
|
|
63
|
+
readonly allow: false;
|
|
64
|
+
readonly error: string;
|
|
65
|
+
} | {
|
|
66
|
+
readonly stub: JsonInput;
|
|
67
|
+
};
|
|
68
|
+
export type SandboxOptions = {
|
|
69
|
+
/** JSON-serialisable values set as VM globals before the script runs, for example `{ args }`. */
|
|
70
|
+
readonly globals?: Readonly<Record<string, JsonInput>>;
|
|
71
|
+
/** Called before each tool call. A throw or rejection refuses the call with its message. */
|
|
72
|
+
readonly onCall?: (call: SandboxCall) => SandboxCallDecision | Promise<SandboxCallDecision>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Runs `code` (the body of an async function) against `tools` inside a fresh
|
|
76
|
+
* QuickJS runtime. Never throws: every failure, including a missing or broken
|
|
77
|
+
* QuickJS install, is reported as an `ok: false` outcome.
|
|
78
|
+
*/
|
|
79
|
+
export declare function runSandboxedScript(code: string, tools: readonly SandboxTool[], limitOverrides?: Partial<ExecuteLimits>, options?: SandboxOptions): Promise<ExecuteOutcome>;
|
|
80
|
+
export {};
|
|
@@ -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
|
+
}
|
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.5.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, and a QuickJS code sandbox that bridges script tool calls to host handlers.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
@@ -26,10 +26,15 @@
|
|
|
26
26
|
"docs/mcp.md",
|
|
27
27
|
"docs/mcp-oauth-client.md",
|
|
28
28
|
"docs/migration.md",
|
|
29
|
+
"docs/sandbox.md",
|
|
29
30
|
"CHANGELOG.md",
|
|
30
31
|
"LICENSE"
|
|
31
32
|
],
|
|
32
33
|
"sideEffects": false,
|
|
34
|
+
"browser": {
|
|
35
|
+
"quickjs-emscripten-core": false,
|
|
36
|
+
"@jitl/quickjs-singlefile-cjs-release-sync": false
|
|
37
|
+
},
|
|
33
38
|
"scripts": {
|
|
34
39
|
"build": "tsc -p tsconfig.json",
|
|
35
40
|
"typecheck": "tsc -p tsconfig.test.json",
|
|
@@ -38,28 +43,38 @@
|
|
|
38
43
|
},
|
|
39
44
|
"peerDependencies": {
|
|
40
45
|
"@clerk/backend": ">=1",
|
|
46
|
+
"@jitl/quickjs-singlefile-cjs-release-sync": "^0.32.0",
|
|
41
47
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
42
48
|
"convex": "^1.24.0",
|
|
49
|
+
"quickjs-emscripten-core": "^0.32.0",
|
|
43
50
|
"zod": "^3.25.0 || ^4.0.0"
|
|
44
51
|
},
|
|
45
52
|
"peerDependenciesMeta": {
|
|
46
53
|
"@clerk/backend": {
|
|
47
54
|
"optional": true
|
|
48
55
|
},
|
|
56
|
+
"@jitl/quickjs-singlefile-cjs-release-sync": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
49
59
|
"@modelcontextprotocol/sdk": {
|
|
50
60
|
"optional": true
|
|
51
61
|
},
|
|
52
62
|
"convex": {
|
|
53
63
|
"optional": true
|
|
54
64
|
},
|
|
65
|
+
"quickjs-emscripten-core": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
55
68
|
"zod": {
|
|
56
69
|
"optional": true
|
|
57
70
|
}
|
|
58
71
|
},
|
|
59
72
|
"devDependencies": {
|
|
73
|
+
"@jitl/quickjs-singlefile-cjs-release-sync": "^0.32.0",
|
|
60
74
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
61
75
|
"@types/node": "^22.0.0",
|
|
62
76
|
"convex": "^1.47.0",
|
|
77
|
+
"quickjs-emscripten-core": "^0.32.0",
|
|
63
78
|
"typescript": "^5.9.0",
|
|
64
79
|
"vitest": "^3.2.0",
|
|
65
80
|
"zod": "^4.0.0",
|