From 3f1ee7c158fecbb37bee14228c57eea2a8707b58 Mon Sep 17 00:00:00 2001 From: Jack Herrington Date: Sun, 15 Nov 2026 18:19:56 -0800 Subject: [PATCH 01/14] refactor(isolate): extract engine-agnostic isolate base into @tanstack/ai-isolate The isolate contract (IsolateDriver, IsolateConfig, IsolateContext, ExecutionResult, NormalizedError, ToolBinding) and the shared wrapCode helper lived inside @tanstack/ai-code-mode, forcing every sandbox driver to depend on Code Mode just for the contract. Move them into a new @tanstack/ai-isolate package and point the six drivers (quickjs, quickjs-bun, node, cloudflare, e2b, daytona) at it. @tanstack/ai-code-mode re-exports the same types and wrapCode, so its public API is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- .changeset/extract-ai-isolate-contract.md | 14 + packages/ai-code-mode/package.json | 1 + packages/ai-code-mode/src/index.ts | 5 +- packages/ai-code-mode/src/types.ts | 157 ++-------- packages/ai-isolate-cloudflare/package.json | 2 +- .../src/isolate-driver.ts | 2 +- .../tests/isolate-driver.test.ts | 2 +- packages/ai-isolate-daytona/package.json | 4 +- packages/ai-isolate-daytona/src/index.ts | 2 +- .../ai-isolate-daytona/src/isolate-driver.ts | 2 +- .../tests/isolate-driver.test.ts | 2 +- .../ai-isolate-daytona/tests/live.test.ts | 2 +- packages/ai-isolate-e2b/package.json | 3 +- packages/ai-isolate-e2b/src/isolate-driver.ts | 2 +- .../tests/isolate-driver.test.ts | 2 +- packages/ai-isolate-node/package.json | 2 +- .../ai-isolate-node/src/error-normalizer.ts | 2 +- packages/ai-isolate-node/src/index.ts | 4 +- .../ai-isolate-node/src/isolate-context.ts | 4 +- .../ai-isolate-node/src/isolate-driver.ts | 2 +- .../tests/isolate-driver.test.ts | 2 +- .../benchmarks/compare-with-wasm.ts | 2 +- packages/ai-isolate-quickjs-bun/package.json | 2 +- .../src/error-normalizer.ts | 2 +- packages/ai-isolate-quickjs-bun/src/index.ts | 4 +- .../src/isolate-context.ts | 4 +- .../src/isolate-driver.ts | 2 +- .../tests/isolate-driver.test.ts | 2 +- packages/ai-isolate-quickjs/package.json | 2 +- .../src/error-normalizer.ts | 2 +- packages/ai-isolate-quickjs/src/index.ts | 4 +- .../ai-isolate-quickjs/src/isolate-context.ts | 4 +- .../ai-isolate-quickjs/src/isolate-driver.ts | 2 +- .../tests/isolate-driver.test.ts | 2 +- packages/ai-isolate/README.md | 79 +++++ packages/ai-isolate/package.json | 61 ++++ .../src/code-wrapper.ts | 0 packages/ai-isolate/src/index.ts | 153 ++++++++++ .../tests/code-wrapper.test.ts | 0 packages/ai-isolate/tsconfig.json | 8 + packages/ai-isolate/vite.config.ts | 36 +++ pnpm-lock.yaml | 284 ++++++++++-------- 42 files changed, 574 insertions(+), 299 deletions(-) create mode 100644 .changeset/extract-ai-isolate-contract.md create mode 100644 packages/ai-isolate/README.md create mode 100644 packages/ai-isolate/package.json rename packages/{ai-code-mode => ai-isolate}/src/code-wrapper.ts (100%) create mode 100644 packages/ai-isolate/src/index.ts rename packages/{ai-code-mode => ai-isolate}/tests/code-wrapper.test.ts (100%) create mode 100644 packages/ai-isolate/tsconfig.json create mode 100644 packages/ai-isolate/vite.config.ts diff --git a/.changeset/extract-ai-isolate-contract.md b/.changeset/extract-ai-isolate-contract.md new file mode 100644 index 0000000000..8c8dd5987b --- /dev/null +++ b/.changeset/extract-ai-isolate-contract.md @@ -0,0 +1,14 @@ +--- +'@tanstack/ai-isolate': minor +'@tanstack/ai-code-mode': patch +'@tanstack/ai-isolate-quickjs': patch +'@tanstack/ai-isolate-quickjs-bun': patch +'@tanstack/ai-isolate-node': patch +'@tanstack/ai-isolate-cloudflare': patch +'@tanstack/ai-isolate-e2b': patch +'@tanstack/ai-isolate-daytona': patch +--- + +Add `@tanstack/ai-isolate`, the engine-agnostic isolate base. It owns the contract every sandbox driver implements (`IsolateDriver`, `IsolateConfig`, `IsolateContext`, `ExecutionResult`, `NormalizedError`, `ToolBinding`) plus the shared `wrapCode` helper. These previously lived inside `@tanstack/ai-code-mode`, which forced every driver to depend on Code Mode just for the contract. + +Drivers (`quickjs`, `quickjs-bun`, `node`, `cloudflare`, `e2b`, `daytona`) now depend on `@tanstack/ai-isolate` instead of `@tanstack/ai-code-mode`. `@tanstack/ai-code-mode` re-exports the same types and `wrapCode`, so its public API is unchanged. diff --git a/packages/ai-code-mode/package.json b/packages/ai-code-mode/package.json index 4c6c6ee8ea..981081b401 100644 --- a/packages/ai-code-mode/package.json +++ b/packages/ai-code-mode/package.json @@ -65,6 +65,7 @@ "tanstack-intent" ], "dependencies": { + "@tanstack/ai-isolate": "workspace:^", "sucrase": "^3.35.0" }, "peerDependencies": { diff --git a/packages/ai-code-mode/src/index.ts b/packages/ai-code-mode/src/index.ts index fcef061116..5a58153f4e 100644 --- a/packages/ai-code-mode/src/index.ts +++ b/packages/ai-code-mode/src/index.ts @@ -33,8 +33,9 @@ export { // TypeScript stripping utility export { stripTypeScript } from './strip-typescript' -// Code wrapper utility (used by isolate drivers) -export { wrapCode } from './code-wrapper' +// Code wrapper utility (used by isolate drivers) — now lives in +// @tanstack/ai-isolate, re-exported here to keep the public API stable. +export { wrapCode } from '@tanstack/ai-isolate' // All types export type { diff --git a/packages/ai-code-mode/src/types.ts b/packages/ai-code-mode/src/types.ts index 63b50d79fd..e2ca1fb890 100644 --- a/packages/ai-code-mode/src/types.ts +++ b/packages/ai-code-mode/src/types.ts @@ -11,144 +11,29 @@ import type { SecretParameterHandler } from './validate-bindings' // Isolate Driver Interfaces // ============================================================================ -/** - * Interface for isolate/sandbox drivers - * Each runtime environment implements this to provide sandboxed code execution - */ -export interface IsolateDriver { - /** - * Create a new isolated execution context with tool bindings - */ - createContext: (config: IsolateConfig) => Promise -} - -/** - * Configuration for creating an isolate context - */ -export interface IsolateConfig { - /** - * Tools transformed into callable bindings for the sandbox - */ - bindings: Record - - /** - * Execution timeout in milliseconds (default: 30000) - */ - timeout?: number - - /** - * Memory limit in MB (default: 128) - */ - memoryLimit?: number -} - -/** - * Isolated execution context with tool bindings injected - */ -export interface IsolateContext { - /** - * Execute generated code and return results. Drivers stop the run when - * `options.signal` aborts, if their runtime can. - */ - execute: ( - code: string, - options?: { signal?: AbortSignal }, - ) => Promise> - - /** - * Clean up sandbox resources - */ - dispose: () => Promise -} - -/** - * Result of code execution in the sandbox - */ -export interface ExecutionResult { - /** - * Whether execution completed without errors - */ - success: boolean - - /** - * Return value from the executed code (if successful) - */ - value?: T - - /** - * Normalized error information (if failed) - */ - error?: NormalizedError - - /** - * Console output captured during execution - */ - logs?: Array -} - -/** - * Normalized error format for cross-runtime compatibility - */ -export interface NormalizedError { - /** - * Error name/type - */ - name: string - - /** - * Error message - */ - message: string - - /** - * Stack trace (if available) - */ - stack?: string - - /** - * Error code (if available) - */ - code?: string -} - -// ============================================================================ -// Tool Binding Interfaces -// ============================================================================ - -/** - * A tool transformed into a format suitable for sandbox injection - */ -export interface ToolBinding { - /** - * Unique tool identifier - */ - name: string - - /** - * Human-readable description for the LLM - */ - description: string - - /** - * JSON Schema for tool input parameters - */ - inputSchema: Record - - /** - * JSON Schema for tool output (optional) - */ - outputSchema?: Record | undefined - - /** - * The execute function that will be injected into the sandbox. - * Accepts optional context for emitting custom events. - */ - execute: (args: unknown, context?: ToolExecutionContext) => Promise +// The engine-agnostic isolate contract now lives in @tanstack/ai-isolate so +// driver packages can depend on it without pulling in Code Mode. Imported for +// local use below and re-exported to keep the @tanstack/ai-code-mode public +// API stable. +import type { + ExecutionResult, + IsolateConfig, + IsolateContext, + IsolateDriver, + NormalizedError, + ToolBinding, +} from '@tanstack/ai-isolate' + +export type { + ExecutionResult, + IsolateConfig, + IsolateContext, + IsolateDriver, + NormalizedError, + ToolBinding, + ToolExecutionContext, } -// Re-export for convenience -export type { ToolExecutionContext } - /** * Runs around each external call of a program. `run` runs the tool. * `call.name` is the tool name as code mode knows it, without the diff --git a/packages/ai-isolate-cloudflare/package.json b/packages/ai-isolate-cloudflare/package.json index e449d81b27..36ddaeacf4 100644 --- a/packages/ai-isolate-cloudflare/package.json +++ b/packages/ai-isolate-cloudflare/package.json @@ -67,7 +67,7 @@ "code-execution" ], "dependencies": { - "@tanstack/ai-code-mode": "workspace:^" + "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { "@cloudflare/workers-types": "^4.20260317.1", diff --git a/packages/ai-isolate-cloudflare/src/isolate-driver.ts b/packages/ai-isolate-cloudflare/src/isolate-driver.ts index 7966a55e9b..470b3e5b0d 100644 --- a/packages/ai-isolate-cloudflare/src/isolate-driver.ts +++ b/packages/ai-isolate-cloudflare/src/isolate-driver.ts @@ -4,7 +4,7 @@ import type { IsolateContext, IsolateDriver, ToolBinding, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' import type { ExecuteRequest, ExecuteResponse, diff --git a/packages/ai-isolate-cloudflare/tests/isolate-driver.test.ts b/packages/ai-isolate-cloudflare/tests/isolate-driver.test.ts index 0946ad1bd0..9063e61e7b 100644 --- a/packages/ai-isolate-cloudflare/tests/isolate-driver.test.ts +++ b/packages/ai-isolate-cloudflare/tests/isolate-driver.test.ts @@ -3,7 +3,7 @@ import { createCloudflareIsolateDriver, type CloudflareIsolateDriverConfig, } from '../src/isolate-driver' -import type { ToolBinding } from '@tanstack/ai-code-mode' +import type { ToolBinding } from '@tanstack/ai-isolate' import type { ExecuteRequest, ExecuteResponse } from '../src/types' const WORKER_URL = 'https://code-mode.example.com' diff --git a/packages/ai-isolate-daytona/package.json b/packages/ai-isolate-daytona/package.json index eaacf2ad03..84982d4eae 100644 --- a/packages/ai-isolate-daytona/package.json +++ b/packages/ai-isolate-daytona/package.json @@ -50,11 +50,11 @@ "code-execution" ], "peerDependencies": { - "@tanstack/ai-code-mode": "workspace:^" + "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { "@daytona/sdk": "^0.192.0", - "@tanstack/ai-code-mode": "workspace:*", + "@tanstack/ai-isolate": "workspace:*", "@vitest/coverage-v8": "4.1.12" } } diff --git a/packages/ai-isolate-daytona/src/index.ts b/packages/ai-isolate-daytona/src/index.ts index 5c26e5ad10..f0622b4d92 100644 --- a/packages/ai-isolate-daytona/src/index.ts +++ b/packages/ai-isolate-daytona/src/index.ts @@ -33,4 +33,4 @@ export type { IsolateContext, IsolateDriver, NormalizedError, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' diff --git a/packages/ai-isolate-daytona/src/isolate-driver.ts b/packages/ai-isolate-daytona/src/isolate-driver.ts index e61406c7c2..7b491a2bb7 100644 --- a/packages/ai-isolate-daytona/src/isolate-driver.ts +++ b/packages/ai-isolate-daytona/src/isolate-driver.ts @@ -7,7 +7,7 @@ import type { IsolateDriver, NormalizedError, ToolBinding, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' import type { DaytonaCodeRunResponse, DaytonaExecutionEnvelope, diff --git a/packages/ai-isolate-daytona/tests/isolate-driver.test.ts b/packages/ai-isolate-daytona/tests/isolate-driver.test.ts index 8ee409d7e6..1bf78afa72 100644 --- a/packages/ai-isolate-daytona/tests/isolate-driver.test.ts +++ b/packages/ai-isolate-daytona/tests/isolate-driver.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import { createDaytonaIsolateDriver } from '../src/isolate-driver' import { DAYTONA_RESULT_MARKER } from '../src/wrap-code' -import type { ToolBinding } from '@tanstack/ai-code-mode' +import type { ToolBinding } from '@tanstack/ai-isolate' import type { DaytonaCodeRunParams, DaytonaCodeRunResponse, diff --git a/packages/ai-isolate-daytona/tests/live.test.ts b/packages/ai-isolate-daytona/tests/live.test.ts index 4e10526b03..8913807702 100644 --- a/packages/ai-isolate-daytona/tests/live.test.ts +++ b/packages/ai-isolate-daytona/tests/live.test.ts @@ -2,7 +2,7 @@ import { CodeLanguage, Daytona } from '@daytona/sdk' import { describe, expect, it } from 'vitest' import { createDaytonaIsolateDriver } from '../src/isolate-driver' import { DAYTONA_RESULT_MARKER } from '../src/wrap-code' -import type { ToolBinding } from '@tanstack/ai-code-mode' +import type { ToolBinding } from '@tanstack/ai-isolate' import type { DaytonaCodeRunParams, DaytonaCodeRunResponse, diff --git a/packages/ai-isolate-e2b/package.json b/packages/ai-isolate-e2b/package.json index fe3bba41e8..d6cef9d4c0 100644 --- a/packages/ai-isolate-e2b/package.json +++ b/packages/ai-isolate-e2b/package.json @@ -50,11 +50,12 @@ "code-execution" ], "peerDependencies": { - "@tanstack/ai-code-mode": "workspace:^" + "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { "@tanstack/ai": "workspace:*", "@tanstack/ai-code-mode": "workspace:*", + "@tanstack/ai-isolate": "workspace:*", "@vitest/coverage-v8": "4.1.12", "e2b": "^2.46.1", "zod": "^4.2.0" diff --git a/packages/ai-isolate-e2b/src/isolate-driver.ts b/packages/ai-isolate-e2b/src/isolate-driver.ts index 2b4fe0d35a..1b355c2e12 100644 --- a/packages/ai-isolate-e2b/src/isolate-driver.ts +++ b/packages/ai-isolate-e2b/src/isolate-driver.ts @@ -6,7 +6,7 @@ import type { IsolateContext, IsolateDriver, ToolBinding, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' import type { RunnerMessage, ToolReply } from './runner' /** The slice of an E2B `CommandHandle` the driver uses. */ diff --git a/packages/ai-isolate-e2b/tests/isolate-driver.test.ts b/packages/ai-isolate-e2b/tests/isolate-driver.test.ts index 06f12b25d0..e58cb9507c 100644 --- a/packages/ai-isolate-e2b/tests/isolate-driver.test.ts +++ b/packages/ai-isolate-e2b/tests/isolate-driver.test.ts @@ -11,7 +11,7 @@ import { basename, join } from 'node:path' import { describe, expect, it } from 'vitest' import { createE2BIsolateDriver } from '../src/index' import type { ChildProcess } from 'node:child_process' -import type { ToolBinding } from '@tanstack/ai-code-mode' +import type { ToolBinding } from '@tanstack/ai-isolate' import type { E2BCommandHandleLike, E2BSandboxLike } from '../src/index' interface FakeOptions { diff --git a/packages/ai-isolate-node/package.json b/packages/ai-isolate-node/package.json index 67e0614679..1a35359e48 100644 --- a/packages/ai-isolate-node/package.json +++ b/packages/ai-isolate-node/package.json @@ -61,7 +61,7 @@ "isolated-vm": "^7.0.2" }, "peerDependencies": { - "@tanstack/ai-code-mode": "workspace:^" + "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { "@vitest/coverage-v8": "4.1.12" diff --git a/packages/ai-isolate-node/src/error-normalizer.ts b/packages/ai-isolate-node/src/error-normalizer.ts index 742f0325ed..8621dde10a 100644 --- a/packages/ai-isolate-node/src/error-normalizer.ts +++ b/packages/ai-isolate-node/src/error-normalizer.ts @@ -1,4 +1,4 @@ -import type { NormalizedError } from '@tanstack/ai-code-mode' +import type { NormalizedError } from '@tanstack/ai-isolate' /** * Normalize various error types into a consistent format diff --git a/packages/ai-isolate-node/src/index.ts b/packages/ai-isolate-node/src/index.ts index 7ac6225b11..a29e75aa9e 100644 --- a/packages/ai-isolate-node/src/index.ts +++ b/packages/ai-isolate-node/src/index.ts @@ -4,11 +4,11 @@ export { type NodeIsolateDriverConfig, } from './isolate-driver' -// Re-export types from ai-code-mode for convenience +// Re-export types from ai-isolate for convenience export type { IsolateDriver, IsolateConfig, IsolateContext, ExecutionResult, NormalizedError, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' diff --git a/packages/ai-isolate-node/src/isolate-context.ts b/packages/ai-isolate-node/src/isolate-context.ts index b0491f0ceb..659ea67a9e 100644 --- a/packages/ai-isolate-node/src/isolate-context.ts +++ b/packages/ai-isolate-node/src/isolate-context.ts @@ -1,7 +1,7 @@ -import { wrapCode } from '@tanstack/ai-code-mode' +import { wrapCode } from '@tanstack/ai-isolate' import { normalizeError } from './error-normalizer' import type ivm from 'isolated-vm' -import type { ExecutionResult, IsolateContext } from '@tanstack/ai-code-mode' +import type { ExecutionResult, IsolateContext } from '@tanstack/ai-isolate' /** * IsolateContext implementation using isolated-vm diff --git a/packages/ai-isolate-node/src/isolate-driver.ts b/packages/ai-isolate-node/src/isolate-driver.ts index 6193e5df6c..ac69e6e1bf 100644 --- a/packages/ai-isolate-node/src/isolate-driver.ts +++ b/packages/ai-isolate-node/src/isolate-driver.ts @@ -6,7 +6,7 @@ import type { IsolateConfig, IsolateContext, IsolateDriver, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' /** * Configuration for the Node.js isolate driver diff --git a/packages/ai-isolate-node/tests/isolate-driver.test.ts b/packages/ai-isolate-node/tests/isolate-driver.test.ts index 8ffe30a4c2..d57cb925df 100644 --- a/packages/ai-isolate-node/tests/isolate-driver.test.ts +++ b/packages/ai-isolate-node/tests/isolate-driver.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' import { createNodeIsolateDriver, probeIsolatedVm } from '../src/isolate-driver' -import type { ToolBinding } from '@tanstack/ai-code-mode' +import type { ToolBinding } from '@tanstack/ai-isolate' const addonAvailable = probeIsolatedVm().compatible diff --git a/packages/ai-isolate-quickjs-bun/benchmarks/compare-with-wasm.ts b/packages/ai-isolate-quickjs-bun/benchmarks/compare-with-wasm.ts index 002982bc80..758fb9d25c 100644 --- a/packages/ai-isolate-quickjs-bun/benchmarks/compare-with-wasm.ts +++ b/packages/ai-isolate-quickjs-bun/benchmarks/compare-with-wasm.ts @@ -16,7 +16,7 @@ import * as os from 'node:os' import process from 'node:process' import { createQuickJSIsolateDriver } from '@tanstack/ai-isolate-quickjs' import { createQuickJSBunIsolateDriver } from '../src/index' -import type { IsolateDriver, ToolBinding } from '@tanstack/ai-code-mode' +import type { IsolateDriver, ToolBinding } from '@tanstack/ai-isolate' const FRESH_CONTEXT_ITERATIONS = 30 const WARM_CONTEXT_ITERATIONS = 100 diff --git a/packages/ai-isolate-quickjs-bun/package.json b/packages/ai-isolate-quickjs-bun/package.json index e836c1f68a..e86744e568 100644 --- a/packages/ai-isolate-quickjs-bun/package.json +++ b/packages/ai-isolate-quickjs-bun/package.json @@ -63,7 +63,7 @@ "quickjs-bun": "0.1.2" }, "peerDependencies": { - "@tanstack/ai-code-mode": "workspace:^" + "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { "@tanstack/ai-isolate-quickjs": "workspace:*", diff --git a/packages/ai-isolate-quickjs-bun/src/error-normalizer.ts b/packages/ai-isolate-quickjs-bun/src/error-normalizer.ts index 3fafac9e5d..d29bd99065 100644 --- a/packages/ai-isolate-quickjs-bun/src/error-normalizer.ts +++ b/packages/ai-isolate-quickjs-bun/src/error-normalizer.ts @@ -1,4 +1,4 @@ -import type { NormalizedError } from '@tanstack/ai-code-mode' +import type { NormalizedError } from '@tanstack/ai-isolate' const MEMORY_LIMIT_ERROR = 'MemoryLimitError' const STACK_OVERFLOW_ERROR = 'StackOverflowError' diff --git a/packages/ai-isolate-quickjs-bun/src/index.ts b/packages/ai-isolate-quickjs-bun/src/index.ts index 70b05e2289..d4bae49c12 100644 --- a/packages/ai-isolate-quickjs-bun/src/index.ts +++ b/packages/ai-isolate-quickjs-bun/src/index.ts @@ -3,11 +3,11 @@ export { type QuickJSBunIsolateDriverConfig, } from './isolate-driver' -// Re-export types from ai-code-mode for convenience +// Re-export types from ai-isolate for convenience export type { IsolateDriver, IsolateConfig, IsolateContext, ExecutionResult, NormalizedError, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' diff --git a/packages/ai-isolate-quickjs-bun/src/isolate-context.ts b/packages/ai-isolate-quickjs-bun/src/isolate-context.ts index 261c6158ab..1b65484417 100644 --- a/packages/ai-isolate-quickjs-bun/src/isolate-context.ts +++ b/packages/ai-isolate-quickjs-bun/src/isolate-context.ts @@ -1,4 +1,4 @@ -import { wrapCode } from '@tanstack/ai-code-mode' +import { wrapCode } from '@tanstack/ai-isolate' import { isFatalQuickJSLimitError, memoryLimitError, @@ -9,7 +9,7 @@ import type { IsolateContext, NormalizedError, ToolBinding, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' import type * as QuickJSBun from 'quickjs-bun' import type { Deferred, JSContext, JSRuntime, JSValue } from 'quickjs-bun' diff --git a/packages/ai-isolate-quickjs-bun/src/isolate-driver.ts b/packages/ai-isolate-quickjs-bun/src/isolate-driver.ts index 6c6acd9392..4936133d4a 100644 --- a/packages/ai-isolate-quickjs-bun/src/isolate-driver.ts +++ b/packages/ai-isolate-quickjs-bun/src/isolate-driver.ts @@ -9,7 +9,7 @@ import type { IsolateConfig, IsolateContext, IsolateDriver, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' import type { QuickJS } from 'quickjs-bun' import type { QuickJSBunModule } from './isolate-context' diff --git a/packages/ai-isolate-quickjs-bun/tests/isolate-driver.test.ts b/packages/ai-isolate-quickjs-bun/tests/isolate-driver.test.ts index 057144dc3a..6483b254b7 100644 --- a/packages/ai-isolate-quickjs-bun/tests/isolate-driver.test.ts +++ b/packages/ai-isolate-quickjs-bun/tests/isolate-driver.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' import { createQuickJSBunIsolateDriver } from '../src/isolate-driver' -import type { ToolBinding } from '@tanstack/ai-code-mode' +import type { ToolBinding } from '@tanstack/ai-isolate' function makeBinding( name: string, diff --git a/packages/ai-isolate-quickjs/package.json b/packages/ai-isolate-quickjs/package.json index 184d0875af..24ded54d6f 100644 --- a/packages/ai-isolate-quickjs/package.json +++ b/packages/ai-isolate-quickjs/package.json @@ -58,7 +58,7 @@ "quickjs-emscripten": "^0.31.0" }, "peerDependencies": { - "@tanstack/ai-code-mode": "workspace:^" + "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { "@vitest/coverage-v8": "4.1.12" diff --git a/packages/ai-isolate-quickjs/src/error-normalizer.ts b/packages/ai-isolate-quickjs/src/error-normalizer.ts index 18523ed2d8..19686948f6 100644 --- a/packages/ai-isolate-quickjs/src/error-normalizer.ts +++ b/packages/ai-isolate-quickjs/src/error-normalizer.ts @@ -1,4 +1,4 @@ -import type { NormalizedError } from '@tanstack/ai-code-mode' +import type { NormalizedError } from '@tanstack/ai-isolate' const MEMORY_LIMIT_ERROR = 'MemoryLimitError' const STACK_OVERFLOW_ERROR = 'StackOverflowError' diff --git a/packages/ai-isolate-quickjs/src/index.ts b/packages/ai-isolate-quickjs/src/index.ts index 13f4658c93..599220a5c4 100644 --- a/packages/ai-isolate-quickjs/src/index.ts +++ b/packages/ai-isolate-quickjs/src/index.ts @@ -3,11 +3,11 @@ export { type QuickJSIsolateDriverConfig, } from './isolate-driver' -// Re-export types from ai-code-mode for convenience +// Re-export types from ai-isolate for convenience export type { IsolateDriver, IsolateConfig, IsolateContext, ExecutionResult, NormalizedError, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' diff --git a/packages/ai-isolate-quickjs/src/isolate-context.ts b/packages/ai-isolate-quickjs/src/isolate-context.ts index aca5a1f5f7..6fabdee8e2 100644 --- a/packages/ai-isolate-quickjs/src/isolate-context.ts +++ b/packages/ai-isolate-quickjs/src/isolate-context.ts @@ -1,4 +1,4 @@ -import { wrapCode } from '@tanstack/ai-code-mode' +import { wrapCode } from '@tanstack/ai-isolate' import { TIMEOUT_ERROR, isFatalQuickJSLimitError, @@ -9,7 +9,7 @@ import type { QuickJSHandle, VmCallResult, } from 'quickjs-emscripten' -import type { ExecutionResult, IsolateContext } from '@tanstack/ai-code-mode' +import type { ExecutionResult, IsolateContext } from '@tanstack/ai-isolate' /** * Execution state shared with the tool bindings created in the driver. diff --git a/packages/ai-isolate-quickjs/src/isolate-driver.ts b/packages/ai-isolate-quickjs/src/isolate-driver.ts index bb247fc6e1..8efed54f12 100644 --- a/packages/ai-isolate-quickjs/src/isolate-driver.ts +++ b/packages/ai-isolate-quickjs/src/isolate-driver.ts @@ -12,7 +12,7 @@ import type { IsolateContext, IsolateDriver, ToolBinding, -} from '@tanstack/ai-code-mode' +} from '@tanstack/ai-isolate' /** Default memory limit in MB (matches Node isolate driver default). */ const DEFAULT_MEMORY_LIMIT_MB = 128 diff --git a/packages/ai-isolate-quickjs/tests/isolate-driver.test.ts b/packages/ai-isolate-quickjs/tests/isolate-driver.test.ts index 5248badafc..c02565cca0 100644 --- a/packages/ai-isolate-quickjs/tests/isolate-driver.test.ts +++ b/packages/ai-isolate-quickjs/tests/isolate-driver.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { createQuickJSIsolateDriver } from '../src/isolate-driver' import { normalizeError } from '../src/error-normalizer' -import type { ToolBinding } from '@tanstack/ai-code-mode' +import type { ToolBinding } from '@tanstack/ai-isolate' function makeBinding( name: string, diff --git a/packages/ai-isolate/README.md b/packages/ai-isolate/README.md new file mode 100644 index 0000000000..f96eb17acd --- /dev/null +++ b/packages/ai-isolate/README.md @@ -0,0 +1,79 @@ +
+ + + + TanStack AI + +
+ +
+ +# @tanstack/ai-isolate + +The engine-agnostic isolate contract for TanStack AI. This package owns the +`IsolateDriver` interface and its supporting types — the single seam that every +sandbox driver implements and that Code Mode (and other consumers) run against — +plus the small engine-agnostic helpers drivers share (`wrapCode`). + +It ships **no engine**. Pick a driver package for a concrete engine: + +- [`@tanstack/ai-isolate-quickjs`](https://www.npmjs.com/package/@tanstack/ai-isolate-quickjs) — QuickJS WASM, runs everywhere +- [`@tanstack/ai-isolate-node`](https://www.npmjs.com/package/@tanstack/ai-isolate-node) — Node `isolated-vm` +- [`@tanstack/ai-isolate-cloudflare`](https://www.npmjs.com/package/@tanstack/ai-isolate-cloudflare) — Cloudflare Workers +- [`@tanstack/ai-isolate-e2b`](https://www.npmjs.com/package/@tanstack/ai-isolate-e2b) — E2B +- [`@tanstack/ai-isolate-daytona`](https://www.npmjs.com/package/@tanstack/ai-isolate-daytona) — Daytona + +## Installation + +```bash +pnpm add @tanstack/ai-isolate +``` + +## The contract + +```typescript group=readme +import type { + IsolateDriver, + IsolateConfig, + IsolateContext, + ExecutionResult, + NormalizedError, + ToolBinding, +} from '@tanstack/ai-isolate' +``` + +A driver implements one method: + +```typescript group=readme +const driver: IsolateDriver = { + async createContext(config) { + // config.bindings — the injected capability surface (the security boundary) + // config.timeout / config.memoryLimit — per-context limits + return { + async execute(code, options) { + // run `code` against the injected bindings; honor options.signal + return { success: true, value: undefined } + }, + async dispose() {}, + } + }, +} +``` + +The injected `bindings` are the capability surface — a program receives exactly +the host functions you inject and nothing else. The sandbox engine is the second +wall. + +## License + +MIT diff --git a/packages/ai-isolate/package.json b/packages/ai-isolate/package.json new file mode 100644 index 0000000000..2cc2be78a5 --- /dev/null +++ b/packages/ai-isolate/package.json @@ -0,0 +1,61 @@ +{ + "name": "@tanstack/ai-isolate", + "version": "1.1.0", + "description": "Engine-agnostic isolate contract for TanStack AI — the shared IsolateDriver interface that every sandbox driver implements.", + "author": "Tanner Linsley", + "license": "MIT", + "homepage": "https://tanstack.com/ai", + "repository": { + "type": "git", + "url": "git+https://github.com/TanStack/ai.git", + "directory": "packages/ai-isolate" + }, + "bugs": { + "url": "https://github.com/TanStack/ai/issues" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "type": "module", + "module": "./dist/esm/index.js", + "types": "./dist/esm/index.d.ts", + "exports": { + ".": { + "types": "./dist/esm/index.d.ts", + "import": "./dist/esm/index.js" + } + }, + "sideEffects": false, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "vite build", + "clean": "premove ./build ./dist", + "lint:fix": "oxlint src --type-aware --fix", + "test:build": "publint --strict", + "test:oxlint": "oxlint src --type-aware", + "test:coverage": "vitest run --passWithNoTests --coverage --coverage.include='src/**' --coverage.reporter=text-summary --coverage.reporter=json-summary", + "test:lib": "vitest --passWithNoTests", + "test:lib:dev": "pnpm test:lib --watch", + "test:types": "tsc" + }, + "keywords": [ + "ai", + "ai-sdk", + "typescript", + "tanstack", + "code-mode", + "isolate", + "sandbox", + "code-execution" + ], + "peerDependencies": { + "@tanstack/ai": "workspace:^" + }, + "devDependencies": { + "@tanstack/ai": "workspace:*" + } +} diff --git a/packages/ai-code-mode/src/code-wrapper.ts b/packages/ai-isolate/src/code-wrapper.ts similarity index 100% rename from packages/ai-code-mode/src/code-wrapper.ts rename to packages/ai-isolate/src/code-wrapper.ts diff --git a/packages/ai-isolate/src/index.ts b/packages/ai-isolate/src/index.ts new file mode 100644 index 0000000000..b2f2ce89ab --- /dev/null +++ b/packages/ai-isolate/src/index.ts @@ -0,0 +1,153 @@ +import type { ToolExecutionContext } from '@tanstack/ai' + +// ============================================================================ +// Shared helpers +// ============================================================================ + +export { wrapCode } from './code-wrapper' + +// ============================================================================ +// Isolate Driver Interfaces +// ============================================================================ + +/** + * Interface for isolate/sandbox drivers. + * + * Each runtime environment (QuickJS, Node, Cloudflare, E2B, Daytona, …) + * implements this to provide sandboxed code execution. This is the single + * engine-agnostic seam every driver shares — the injected binding set is the + * security boundary, the sandbox is defense in depth. + */ +export interface IsolateDriver { + /** + * Create a new isolated execution context with tool bindings + */ + createContext: (config: IsolateConfig) => Promise +} + +/** + * Configuration for creating an isolate context + */ +export interface IsolateConfig { + /** + * Tools transformed into callable bindings for the sandbox + */ + bindings: Record + + /** + * Execution timeout in milliseconds (default: 30000) + */ + timeout?: number + + /** + * Memory limit in MB (default: 128) + */ + memoryLimit?: number +} + +/** + * Isolated execution context with tool bindings injected + */ +export interface IsolateContext { + /** + * Execute generated code and return results. Drivers stop the run when + * `options.signal` aborts, if their runtime can. + */ + execute: ( + code: string, + options?: { signal?: AbortSignal }, + ) => Promise> + + /** + * Clean up sandbox resources + */ + dispose: () => Promise +} + +/** + * Result of code execution in the sandbox + */ +export interface ExecutionResult { + /** + * Whether execution completed without errors + */ + success: boolean + + /** + * Return value from the executed code (if successful) + */ + value?: T + + /** + * Normalized error information (if failed) + */ + error?: NormalizedError + + /** + * Console output captured during execution + */ + logs?: Array +} + +/** + * Normalized error format for cross-runtime compatibility + */ +export interface NormalizedError { + /** + * Error name/type + */ + name: string + + /** + * Error message + */ + message: string + + /** + * Stack trace (if available) + */ + stack?: string + + /** + * Error code (if available) + */ + code?: string +} + +// ============================================================================ +// Tool Binding Interfaces +// ============================================================================ + +/** + * A tool transformed into a format suitable for sandbox injection + */ +export interface ToolBinding { + /** + * Unique tool identifier + */ + name: string + + /** + * Human-readable description for the LLM + */ + description: string + + /** + * JSON Schema for tool input parameters + */ + inputSchema: Record + + /** + * JSON Schema for tool output (optional) + */ + outputSchema?: Record | undefined + + /** + * The execute function that will be injected into the sandbox. + * Accepts optional context for emitting custom events. + */ + execute: (args: unknown, context?: ToolExecutionContext) => Promise +} + +// Re-export for convenience +export type { ToolExecutionContext } diff --git a/packages/ai-code-mode/tests/code-wrapper.test.ts b/packages/ai-isolate/tests/code-wrapper.test.ts similarity index 100% rename from packages/ai-code-mode/tests/code-wrapper.test.ts rename to packages/ai-isolate/tests/code-wrapper.test.ts diff --git a/packages/ai-isolate/tsconfig.json b/packages/ai-isolate/tsconfig.json new file mode 100644 index 0000000000..c38689f4ea --- /dev/null +++ b/packages/ai-isolate/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": ["src", "tests"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/ai-isolate/vite.config.ts b/packages/ai-isolate/vite.config.ts new file mode 100644 index 0000000000..68a4c83533 --- /dev/null +++ b/packages/ai-isolate/vite.config.ts @@ -0,0 +1,36 @@ +import { defineConfig, mergeConfig } from 'vitest/config' +import { tanstackViteConfig } from '@tanstack/vite-config' +import packageJson from './package.json' + +const config = defineConfig({ + test: { + name: packageJson.name, + dir: './', + watch: false, + globals: true, + environment: 'node', + include: ['src/**/*.test.ts', 'tests/**/*.test.ts'], + coverage: { + provider: 'v8', + reporter: ['text', 'json', 'html', 'lcov'], + exclude: [ + 'node_modules/', + 'dist/', + 'tests/', + '**/*.test.ts', + '**/*.config.ts', + '**/types.ts', + ], + include: ['src/**/*.ts'], + }, + }, +}) + +export default mergeConfig( + config, + tanstackViteConfig({ + entry: ['./src/index.ts'], + srcDir: './src', + cjs: false, + }), +) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0068c95ed..6c952bda18 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -76,7 +76,7 @@ importers: version: 23.3.2 oxfmt: specifier: ^0.59.0 - version: 0.59.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)) + version: 0.59.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)) oxlint: specifier: ^1.89.0 version: 1.89.0(oxlint-tsgolint@7.0.2004) @@ -457,7 +457,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.1.18 - version: 4.1.18(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 4.1.18(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@tanstack/ai': specifier: workspace:* version: link:../../../packages/ai @@ -472,10 +472,10 @@ importers: version: 1.170.41(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tanstack/react-start': specifier: ^1.168.60 - version: 1.168.60(crossws@0.4.6(srvx@0.11.22))(esbuild@0.28.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(rolldown@1.2.19)(rollup@4.60.1)(vite-plugin-solid@2.11.16(solid-js@1.9.19)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 1.168.60(crossws@0.4.6(srvx@0.11.22))(esbuild@0.28.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(rolldown@1.2.19)(rollup@4.60.1)(vite-plugin-solid@2.11.16(solid-js@1.9.19)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: ^1.168.42 - version: 1.168.42(@tanstack/react-router@1.170.41(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(esbuild@0.28.2)(rolldown@1.2.19)(rollup@4.60.1)(vite-plugin-solid@2.11.16(solid-js@1.9.19)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 1.168.42(@tanstack/react-router@1.170.41(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(esbuild@0.28.2)(rolldown@1.2.19)(rollup@4.60.1)(vite-plugin-solid@2.11.16(solid-js@1.9.19)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) react: specifier: ^19.2.3 version: 19.2.3 @@ -488,22 +488,22 @@ importers: devDependencies: '@types/node': specifier: ^24.10.1 - version: 24.10.3 + version: 24.13.6 '@types/react': specifier: ^19.2.7 - version: 19.2.18 + version: 19.3.0 '@types/react-dom': specifier: ^19.2.3 - version: 19.2.3(@types/react@19.2.18) + version: 19.2.3(@types/react@19.3.0) '@vitejs/plugin-react': specifier: ^6.3.0 - version: 6.3.0(babel-plugin-react-compiler@1.0.0)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 6.3.0(babel-plugin-react-compiler@1.0.0)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) typescript: specifier: 5.9.3 version: 5.9.3 vite: specifier: ^8.3.8 - version: 8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0) + version: 8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0) examples/react/generate-image: dependencies: @@ -2197,7 +2197,7 @@ importers: version: 11.11.1 lucide-svelte: specifier: ^0.468.0 - version: 0.468.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)) + version: 0.468.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)) marked: specifier: ^18.1.3 version: 18.1.3 @@ -2210,13 +2210,13 @@ importers: devDependencies: '@sveltejs/adapter-auto': specifier: ^8.0.1 - version: 8.0.1(@sveltejs/kit@2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))) + version: 8.0.1(@sveltejs/kit@2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))) '@sveltejs/kit': specifier: ^2.70.4 - version: 2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@sveltejs/vite-plugin-svelte': specifier: ^7.3.1 - version: 7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@tailwindcss/vite': specifier: ^4.1.18 version: 4.1.18(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) @@ -2225,10 +2225,10 @@ importers: version: 24.10.3 svelte: specifier: ^5.57.3 - version: 5.57.3(@typescript-eslint/types@8.59.4) + version: 5.58.0(@typescript-eslint/types@8.59.4) svelte-check: specifier: ^4.7.8 - version: 4.7.8(picomatch@4.0.7)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3) + version: 4.7.8(picomatch@4.0.7)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3) tailwindcss: specifier: ^4.1.18 version: 4.1.18 @@ -2593,6 +2593,9 @@ importers: packages/ai-code-mode: dependencies: + '@tanstack/ai-isolate': + specifier: workspace:^ + version: link:../ai-isolate sucrase: specifier: ^3.35.0 version: 3.35.1 @@ -2805,7 +2808,7 @@ importers: version: 0.5.1(csstype@3.2.3)(solid-js@1.9.19) '@tanstack/devtools-utils': specifier: ^0.7.0 - version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) + version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) goober: specifier: ^2.1.18 version: 2.1.18(csstype@3.2.3) @@ -3051,11 +3054,17 @@ importers: specifier: ^4.2.0 version: 4.2.1 + packages/ai-isolate: + devDependencies: + '@tanstack/ai': + specifier: workspace:* + version: link:../ai + packages/ai-isolate-cloudflare: dependencies: - '@tanstack/ai-code-mode': + '@tanstack/ai-isolate': specifier: workspace:^ - version: link:../ai-code-mode + version: link:../ai-isolate devDependencies: '@cloudflare/workers-types': specifier: ^4.20260317.1 @@ -3072,9 +3081,9 @@ importers: '@daytona/sdk': specifier: ^0.192.0 version: 0.192.0(supports-color@7.2.0)(ws@8.21.0) - '@tanstack/ai-code-mode': + '@tanstack/ai-isolate': specifier: workspace:* - version: link:../ai-code-mode + version: link:../ai-isolate '@vitest/coverage-v8': specifier: 4.1.12 version: 4.1.12(vitest@4.1.12) @@ -3087,6 +3096,9 @@ importers: '@tanstack/ai-code-mode': specifier: workspace:* version: link:../ai-code-mode + '@tanstack/ai-isolate': + specifier: workspace:* + version: link:../ai-isolate '@vitest/coverage-v8': specifier: 4.1.12 version: 4.1.12(vitest@4.1.12) @@ -3099,9 +3111,9 @@ importers: packages/ai-isolate-node: dependencies: - '@tanstack/ai-code-mode': + '@tanstack/ai-isolate': specifier: workspace:^ - version: link:../ai-code-mode + version: link:../ai-isolate isolated-vm: specifier: ^7.0.2 version: 7.0.2 @@ -3112,9 +3124,9 @@ importers: packages/ai-isolate-quickjs: dependencies: - '@tanstack/ai-code-mode': + '@tanstack/ai-isolate': specifier: workspace:^ - version: link:../ai-code-mode + version: link:../ai-isolate quickjs-emscripten: specifier: ^0.31.0 version: 0.31.0 @@ -3125,9 +3137,9 @@ importers: packages/ai-isolate-quickjs-bun: dependencies: - '@tanstack/ai-code-mode': + '@tanstack/ai-isolate': specifier: workspace:^ - version: link:../ai-code-mode + version: link:../ai-isolate quickjs-bun: specifier: 0.1.2 version: 0.1.2 @@ -3331,7 +3343,7 @@ importers: devDependencies: '@octanejs/testing-library': specifier: 0.1.62 - version: 0.1.62(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))) + version: 0.1.62(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))) '@standard-schema/spec': specifier: ^1.1.0 version: 1.1.0 @@ -3340,7 +3352,7 @@ importers: version: link:../ai '@tsrx/oxc': specifier: 0.20.0 - version: 0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)) + version: 0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)) '@types/node': specifier: ^24.10.1 version: 24.10.3 @@ -3352,7 +3364,7 @@ importers: version: 20.14.6 octane: specifier: 0.12.1 - version: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) vite: specifier: ^8.3.8 version: 8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0) @@ -3532,7 +3544,7 @@ importers: version: link:../ai-client '@tanstack/markdown': specifier: ^1.2.0 - version: 1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3) + version: 1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3) devDependencies: '@mcp-ui/client': specifier: ^7.1.1 @@ -3829,7 +3841,7 @@ importers: version: link:../ai-client '@tanstack/markdown': specifier: ^1.2.0 - version: 1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3) + version: 1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3) devDependencies: '@solidjs/testing-library': specifier: ^0.8.10 @@ -3879,10 +3891,10 @@ importers: version: 1.1.0 '@sveltejs/package': specifier: ^3.0.2 - version: 3.0.2(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3) + version: 3.0.2(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3) '@sveltejs/vite-plugin-svelte': specifier: ^7.3.1 - version: 7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@tanstack/ai': specifier: workspace:* version: link:../ai @@ -3897,10 +3909,10 @@ importers: version: 27.4.0(@noble/hashes@2.3.0) svelte: specifier: ^5.57.3 - version: 5.57.3(@typescript-eslint/types@8.59.4) + version: 5.58.0(@typescript-eslint/types@8.59.4) svelte-check: specifier: ^4.7.8 - version: 4.7.8(picomatch@4.0.7)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3) + version: 4.7.8(picomatch@4.0.7)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3) typescript: specifier: 5.9.3 version: 5.9.3 @@ -4000,7 +4012,7 @@ importers: version: link:../ai-client '@tanstack/markdown': specifier: ^1.2.0 - version: 1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3) + version: 1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3) devDependencies: '@standard-schema/spec': specifier: ^1.1.0 @@ -4090,7 +4102,7 @@ importers: version: link:../ai-devtools '@tanstack/devtools-utils': specifier: ^0.7.0 - version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@10.28.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) + version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@10.28.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) preact: specifier: ^10.0.0 || ^11.0.0-0 version: 10.28.1 @@ -4106,7 +4118,7 @@ importers: version: link:../ai-devtools '@tanstack/devtools-utils': specifier: ^0.7.0 - version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.7)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) + version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.7)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) devDependencies: '@types/react': specifier: ^19.2.7 @@ -4125,7 +4137,7 @@ importers: version: link:../ai-devtools '@tanstack/devtools-utils': specifier: ^0.7.0 - version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) + version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) devDependencies: solid-js: specifier: ^1.9.19 @@ -4144,11 +4156,11 @@ importers: version: link:../ai-devtools '@tanstack/devtools-utils': specifier: ^0.7.0 - version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) + version: 0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2)) devDependencies: svelte: specifier: ^5.57.3 - version: 5.57.3(@typescript-eslint/types@8.59.4) + version: 5.58.0(@typescript-eslint/types@8.59.4) vite: specifier: ^8.3.8 version: 8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0) @@ -4933,6 +4945,10 @@ packages: resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==} engines: {node: '>=6.9.0'} + '@babel/code-frame@7.29.0': + resolution: {integrity: sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==} + engines: {node: '>=6.9.0'} + '@babel/code-frame@7.29.7': resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==} engines: {node: '>=6.9.0'} @@ -7274,9 +7290,6 @@ packages: '@jridgewell/source-map@0.3.11': resolution: {integrity: sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==} - '@jridgewell/sourcemap-codec@1.5.5': - resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} - '@jridgewell/sourcemap-codec@1.6.0': resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==} @@ -11322,7 +11335,9 @@ packages: '@smithy/core@3.26.0': resolution: {integrity: sha512-mLUktFAn+Pa2agl1J7VgtYNFWCX8/b4GMJSK1hCu4YCvtBfM6F8Os3EP4ry+DFFlXOf3wyvlgXhuUdFoy52D3g==} engines: {node: '>=18.0.0'} - deprecated: Deprecated due to a bug in custom logger data redaction. See https://github.com/aws/aws-sdk-js-v3/issues/8393. + deprecated: |- + Deprecated due to a bug in custom logger data redaction. Upgrade to the latest version. If you used a custom logger with this + version, review your logs and rotate any credentials or other secrets. See https://github.com/aws/aws-sdk-js-v3/issues/8393. '@smithy/credential-provider-imds@4.4.2': resolution: {integrity: sha512-18UMDMyrAbDcpmL1gLUA7ww0fRTcdCrSjSJOi2Sbld+tVjwD/pW+OAwjlScFLR7vvBnhZrIPQ7kVuTf1mnJLug==} @@ -12938,11 +12953,6 @@ packages: peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 - acorn@8.15.0: - resolution: {integrity: sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==} - engines: {node: '>=0.4.0'} - hasBin: true - acorn@8.18.0: resolution: {integrity: sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==} engines: {node: '>=0.4.0'} @@ -14621,6 +14631,14 @@ packages: '@typescript-eslint/types': optional: true + esrap@2.4.2: + resolution: {integrity: sha512-WpVZsWnSheHBy+fGrO/0duwnbe6ODZH1QyBbjupreSCJGojaBWRncrq+HVeIJ8eHQjEwSJg9hC4yPJyNVOrpqg==} + peerDependencies: + '@typescript-eslint/types': ^8.2.0 + peerDependenciesMeta: + '@typescript-eslint/types': + optional: true + esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} engines: {node: '>=4.0'} @@ -18535,6 +18553,12 @@ packages: peerDependencies: seroval: ^1.0 + seroval-plugins@1.6.7: + resolution: {integrity: sha512-4Nk35ttD3DTDJW4hgw5StsVAPeU6qnDFnULAouw6tQ7oLTV/ICXrWpsXo2EE52eSP2joUMazbVf52mFEcADqRw==} + engines: {node: '>=10'} + peerDependencies: + seroval: ^1.0 + seroval@1.6.12: resolution: {integrity: sha512-CqbIVfk/7GL3ITwZI55lcPbpQbjHZ2DD5cUj4iH7E9YsCfHNJV1mx7yNp86Z84w5IpmkZZS/2s5vPOWmVWSdQg==} engines: {node: '>=10'} @@ -18965,8 +18989,8 @@ packages: svelte: ^3.55 || ^4.0.0-next.0 || ^4.0 || ^5.0.0-next.0 typescript: ^4.9.4 || ^5.0.0 || ^6.0.0 - svelte@5.57.3: - resolution: {integrity: sha512-5mAftM3SoDV9X0zdF386F9p2pv8iKOwi/KfBS1XnBAkVCKFzVOLHUoa8iGWAt4buoicLmyWVRpuuD5wplXOQsg==} + svelte@5.58.0: + resolution: {integrity: sha512-rOMKTD9WP2C6ahWDmntey4p+JqUxtup1w9G3KdVuTbNGHi5u97iMw0CIc8a+F5rZtiH7x98kVniDlBRRR5e98w==} engines: {node: '>=18'} symbol-tree@3.2.4: @@ -21000,6 +21024,12 @@ snapshots: js-tokens: 4.0.0 picocolors: 1.1.1 + '@babel/code-frame@7.29.0': + dependencies: + '@babel/helper-validator-identifier': 7.29.7 + js-tokens: 4.0.0 + picocolors: 1.1.1 + '@babel/code-frame@7.29.7': dependencies: '@babel/helper-validator-identifier': 7.29.7 @@ -23551,7 +23581,7 @@ snapshots: getenv: 2.0.0 glob: 13.0.0 ignore: 5.3.2 - minimatch: 10.2.5 + minimatch: 10.2.6 resolve-from: 5.0.0 semver: 7.8.5 transitivePeerDependencies: @@ -23610,7 +23640,7 @@ snapshots: '@expo/metro-config@56.0.13(expo@56.0.5)(typescript@5.9.3)': dependencies: - '@babel/code-frame': 7.29.7 + '@babel/code-frame': 7.29.0 '@babel/core': 7.29.7(supports-color@7.2.0) '@babel/generator': 7.29.8 '@expo/config': 56.0.9(typescript@5.9.3) @@ -23621,7 +23651,7 @@ snapshots: '@expo/spawn-async': 1.8.0 '@jridgewell/gen-mapping': 0.3.13 '@jridgewell/remapping': 2.3.5 - '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/sourcemap-codec': 1.6.0 browserslist: 4.29.0 chalk: 4.1.2 debug: 4.4.3(supports-color@7.2.0) @@ -24144,8 +24174,6 @@ snapshots: '@jridgewell/gen-mapping': 0.3.13 '@jridgewell/trace-mapping': 0.3.31 - '@jridgewell/sourcemap-codec@1.5.5': {} - '@jridgewell/sourcemap-codec@1.6.0': {} '@jridgewell/trace-mapping@0.3.31': @@ -24532,6 +24560,13 @@ snapshots: '@emnapi/runtime': 1.11.3 '@tybys/wasm-util': 0.9.0 + '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.0)(@emnapi/runtime@1.11.0)': + dependencies: + '@emnapi/core': 1.11.0 + '@emnapi/runtime': 1.11.0 + '@tybys/wasm-util': 0.10.3 + optional: true + '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)': dependencies: '@emnapi/core': 1.11.1 @@ -24553,13 +24588,6 @@ snapshots: '@tybys/wasm-util': 0.10.3 optional: true - '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@1.11.0)(@emnapi/runtime@1.11.0)': - dependencies: - '@emnapi/core': 1.11.0 - '@emnapi/runtime': 1.11.0 - '@tybys/wasm-util': 0.10.3 - optional: true - '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': dependencies: '@emnapi/core': 2.0.0-beta.2 @@ -24675,10 +24703,10 @@ snapshots: '@nx/nx-win32-x64-msvc@23.3.2': optional: true - '@octanejs/testing-library@0.1.62(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))': + '@octanejs/testing-library@0.1.62(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))': dependencies: '@testing-library/dom': 10.4.1 - octane: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + octane: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@one-ini/wasm@0.1.1': {} @@ -25300,7 +25328,7 @@ snapshots: dependencies: '@emnapi/core': 1.11.0 '@emnapi/runtime': 1.11.0 - '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@1.11.0)(@emnapi/runtime@1.11.0) + '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.0)(@emnapi/runtime@1.11.0) optional: true '@oxc-resolver/binding-win32-arm64-msvc@11.21.3': @@ -28592,15 +28620,15 @@ snapshots: dependencies: acorn: 8.18.0 - '@sveltejs/adapter-auto@8.0.1(@sveltejs/kit@2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))': + '@sveltejs/adapter-auto@8.0.1(@sveltejs/kit@2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))': dependencies: - '@sveltejs/kit': 2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + '@sveltejs/kit': 2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) - '@sveltejs/kit@2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': + '@sveltejs/kit@2.70.4(@opentelemetry/api@1.9.1)(@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': dependencies: '@standard-schema/spec': 1.1.0 '@sveltejs/acorn-typescript': 1.0.13(acorn@8.18.0) - '@sveltejs/vite-plugin-svelte': 7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + '@sveltejs/vite-plugin-svelte': 7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@types/cookie': 0.6.0 acorn: 8.18.0 cookie: 0.6.0 @@ -28611,7 +28639,7 @@ snapshots: mrmime: 2.0.1 set-cookie-parser: 3.1.2 sirv: 3.0.2 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) vite: 8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0) optionalDependencies: '@opentelemetry/api': 1.9.1 @@ -28619,21 +28647,21 @@ snapshots: '@sveltejs/load-config@0.2.3': {} - '@sveltejs/package@3.0.2(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3)': + '@sveltejs/package@3.0.2(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3)': dependencies: '@sveltejs/load-config': 0.2.3 chokidar: 6.0.0 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) - svelte2tsx: 0.7.63(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) + svelte2tsx: 0.7.63(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3) optionalDependencies: typescript: 5.9.3 - '@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': + '@sveltejs/vite-plugin-svelte@7.3.1(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': dependencies: deepmerge: 4.3.1 magic-string: 1.4.5 obug: 2.2.1 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) vite: 8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0) vitefu: 1.1.3(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) @@ -28782,34 +28810,34 @@ snapshots: transitivePeerDependencies: - csstype - '@tanstack/devtools-utils@0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@10.28.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2))': + '@tanstack/devtools-utils@0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@10.28.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2))': optionalDependencies: '@angular/core': 22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1) '@types/react': 19.2.18 preact: 10.28.1 react: 19.2.3 solid-js: 1.9.19 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) vue: 3.5.25(typescript@7.0.2) - '@tanstack/devtools-utils@0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2))': + '@tanstack/devtools-utils@0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.18)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2))': optionalDependencies: '@angular/core': 22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1) '@types/react': 19.2.18 preact: 11.0.1 react: 19.2.3 solid-js: 1.9.19 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) vue: 3.5.25(typescript@7.0.2) - '@tanstack/devtools-utils@0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.7)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2))': + '@tanstack/devtools-utils@0.7.0(@angular/core@22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1))(@types/react@19.2.7)(preact@11.0.1)(react@19.2.3)(solid-js@1.9.19)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(vue@3.5.25(typescript@7.0.2))': optionalDependencies: '@angular/core': 22.2.4(@angular/compiler@22.2.4)(rxjs@7.8.2)(zone.js@0.15.1) '@types/react': 19.2.7 preact: 11.0.1 react: 19.2.3 solid-js: 1.9.19 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) vue: 3.5.25(typescript@7.0.2) '@tanstack/devtools-vite@0.5.3(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': @@ -28882,14 +28910,14 @@ snapshots: '@tanstack/history@1.162.4': {} - '@tanstack/markdown@1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3)': + '@tanstack/markdown@1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3)': optionalDependencies: - octane: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + octane: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) react: 19.2.3 - '@tanstack/markdown@1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3)': + '@tanstack/markdown@1.2.0(octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(react@19.2.3)': optionalDependencies: - octane: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + octane: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) react: 19.2.3 '@tanstack/nitro-v2-vite-plugin@1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.19)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': @@ -29262,8 +29290,8 @@ snapshots: dependencies: '@tanstack/history': 1.162.4 cookie-es: 3.1.1 - seroval: 1.6.12 - seroval-plugins: 1.6.12(seroval@1.6.12) + seroval: 1.6.7 + seroval-plugins: 1.6.7(seroval@1.6.7) '@tanstack/router-devtools-core@1.141.1(@tanstack/router-core@1.171.34)(csstype@3.2.3)(solid-js@1.9.19)': dependencies: @@ -29730,10 +29758,10 @@ snapshots: '@tsrx/oxc-win32-x64-msvc@0.20.0': optional: true - '@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4))': + '@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4))': dependencies: '@oxc-project/types': 0.150.0 - oxfmt-current: oxfmt@0.68.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)) + oxfmt-current: oxfmt@0.68.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)) oxlint-current: oxlint@1.83.0(oxlint-tsgolint@7.0.2002) oxlint-tsgolint: 7.0.2002 pathe: 2.0.3 @@ -30030,7 +30058,7 @@ snapshots: '@typescript-eslint/utils': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@7.0.2) '@typescript-eslint/visitor-keys': 8.59.4 eslint: 9.39.4(jiti@2.7.0) - ignore: 7.0.6 + ignore: 7.0.5 natural-compare: 1.4.0 ts-api-utils: 2.5.0(typescript@7.0.2) typescript: 7.0.2 @@ -30735,11 +30763,9 @@ snapshots: dependencies: acorn: 8.18.0 - acorn-jsx@5.3.2(acorn@8.15.0): + acorn-jsx@5.3.2(acorn@8.18.0): dependencies: - acorn: 8.15.0 - - acorn@8.15.0: {} + acorn: 8.18.0 acorn@8.18.0: {} @@ -31837,7 +31863,7 @@ snapshots: css-tree@3.2.1: dependencies: mdn-data: 2.27.1 - source-map-js: 1.2.2 + source-map-js: 1.2.1 css-what@6.2.2: {} @@ -32573,8 +32599,8 @@ snapshots: espree@10.4.0: dependencies: - acorn: 8.15.0 - acorn-jsx: 5.3.2(acorn@8.15.0) + acorn: 8.18.0 + acorn-jsx: 5.3.2(acorn@8.18.0) eslint-visitor-keys: 4.2.1 esprima@4.0.1: {} @@ -32589,6 +32615,12 @@ snapshots: optionalDependencies: '@typescript-eslint/types': 8.59.4 + esrap@2.4.2(@typescript-eslint/types@8.59.4): + dependencies: + '@jridgewell/sourcemap-codec': 1.6.0 + optionalDependencies: + '@typescript-eslint/types': 8.59.4 + esrecurse@4.3.0: dependencies: estraverse: 5.3.0 @@ -34473,9 +34505,9 @@ snapshots: dependencies: solid-js: 1.9.19 - lucide-svelte@0.468.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)): + lucide-svelte@0.468.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)): dependencies: - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) lunr@2.3.9: {} @@ -34503,7 +34535,7 @@ snapshots: dependencies: '@babel/parser': 7.29.9 '@babel/types': 7.29.8 - source-map-js: 1.2.2 + source-map-js: 1.2.1 make-dir@2.1.0: dependencies: @@ -35324,9 +35356,9 @@ snapshots: jsonc-parser: 3.3.1 less: 4.6.6 ora: 9.4.0 - postcss: 8.5.33 - rolldown: 1.2.19 - rolldown-plugin-dts: 0.28.8(@volar/typescript@2.4.28)(oxc-resolver@11.21.3)(rolldown@1.2.19)(typescript@6.0.2) + postcss: 8.5.28 + rolldown: 1.2.9 + rolldown-plugin-dts: 0.28.8(@volar/typescript@2.4.28)(oxc-resolver@11.21.3)(rolldown@1.2.9)(typescript@6.0.2) rxjs: 7.8.2 sass: 1.107.1 sass-embedded: 1.107.1 @@ -35925,7 +35957,7 @@ snapshots: dependencies: ohash: 2.0.11 - octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)): + octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)): dependencies: '@tsrx/core': 0.5.5(@typescript-eslint/types@8.59.4) '@types/react': 19.3.0 @@ -35937,7 +35969,7 @@ snapshots: es-module-lexer: 1.7.0 esrap: 2.3.7(@typescript-eslint/types@8.59.4) optionalDependencies: - '@tsrx/oxc': 0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)) + '@tsrx/oxc': 0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)) react: 19.2.3 react-dom: 19.2.3(react@19.2.3) typescript: 5.9.3 @@ -35946,7 +35978,7 @@ snapshots: - '@typescript-eslint/types' optional: true - octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)): + octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)): dependencies: '@tsrx/core': 0.5.5(@typescript-eslint/types@8.59.4) '@types/react': 19.3.0 @@ -35958,7 +35990,7 @@ snapshots: es-module-lexer: 1.7.0 esrap: 2.3.7(@typescript-eslint/types@8.59.4) optionalDependencies: - '@tsrx/oxc': 0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)) + '@tsrx/oxc': 0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)) react: 19.2.3 react-dom: 19.2.3(react@19.2.3) typescript: 6.0.3 @@ -35966,7 +35998,7 @@ snapshots: transitivePeerDependencies: - '@typescript-eslint/types' - octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)): + octane@0.12.1(@tsrx/oxc@0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.107.1)(sass@1.107.1)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)): dependencies: '@tsrx/core': 0.5.5(@typescript-eslint/types@8.59.4) '@types/react': 19.3.0 @@ -35978,7 +36010,7 @@ snapshots: es-module-lexer: 1.7.0 esrap: 2.3.7(@typescript-eslint/types@8.59.4) optionalDependencies: - '@tsrx/oxc': 0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)) + '@tsrx/oxc': 0.20.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)) react: 19.2.3 react-dom: 19.2.3(react@19.2.3) typescript: 6.0.3 @@ -36301,7 +36333,7 @@ snapshots: - '@emnapi/core' - '@emnapi/runtime' - oxfmt@0.59.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)): + oxfmt@0.59.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)): dependencies: tinypool: 2.1.0 optionalDependencies: @@ -36324,9 +36356,9 @@ snapshots: '@oxfmt/binding-win32-arm64-msvc': 0.59.0 '@oxfmt/binding-win32-ia32-msvc': 0.59.0 '@oxfmt/binding-win32-x64-msvc': 0.59.0 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) - oxfmt@0.68.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)): + oxfmt@0.68.0(svelte@5.58.0(@typescript-eslint/types@8.59.4)): dependencies: tinypool: 2.1.2 optionalDependencies: @@ -36349,7 +36381,7 @@ snapshots: '@oxfmt/binding-win32-arm64-msvc': 0.68.0 '@oxfmt/binding-win32-ia32-msvc': 0.68.0 '@oxfmt/binding-win32-x64-msvc': 0.68.0 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) oxlint-plugin-eslint@1.89.0: {} @@ -37746,12 +37778,12 @@ snapshots: transitivePeerDependencies: - oxc-resolver - rolldown-plugin-dts@0.28.8(@volar/typescript@2.4.28)(oxc-resolver@11.21.3)(rolldown@1.2.19)(typescript@6.0.2): + rolldown-plugin-dts@0.28.8(@volar/typescript@2.4.28)(oxc-resolver@11.21.3)(rolldown@1.2.9)(typescript@6.0.2): dependencies: dts-resolver: 3.0.0(oxc-resolver@11.21.3) get-tsconfig: 5.0.0-beta.6 obug: 3.0.0 - rolldown: 1.2.19 + rolldown: 1.2.9 yuku-ast: 0.19.0 yuku-codegen: 0.19.0 yuku-parser: 0.19.0 @@ -38194,7 +38226,7 @@ snapshots: dependencies: chokidar: 5.0.0 immutable: 5.1.9 - source-map-js: 1.2.2 + source-map-js: 1.2.1 optionalDependencies: '@parcel/watcher': 2.6.0 @@ -38279,6 +38311,10 @@ snapshots: dependencies: seroval: 1.6.12 + seroval-plugins@1.6.7(seroval@1.6.7): + dependencies: + seroval: 1.6.7 + seroval@1.6.12: {} seroval@1.6.7: {} @@ -38725,7 +38761,7 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - svelte-check@4.7.8(picomatch@4.0.7)(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3): + svelte-check@4.7.8(picomatch@4.0.7)(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3): dependencies: '@jridgewell/trace-mapping': 0.3.31 '@sveltejs/load-config': 0.2.3 @@ -38733,19 +38769,19 @@ snapshots: fdir: 6.5.0(picomatch@4.0.7) picocolors: 1.1.1 sade: 1.8.1 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) typescript: 5.9.3 transitivePeerDependencies: - picomatch - svelte2tsx@0.7.63(svelte@5.57.3(@typescript-eslint/types@8.59.4))(typescript@5.9.3): + svelte2tsx@0.7.63(svelte@5.58.0(@typescript-eslint/types@8.59.4))(typescript@5.9.3): dependencies: dedent-js: 1.0.1 scule: 1.3.0 - svelte: 5.57.3(@typescript-eslint/types@8.59.4) + svelte: 5.58.0(@typescript-eslint/types@8.59.4) typescript: 5.9.3 - svelte@5.57.3(@typescript-eslint/types@8.59.4): + svelte@5.58.0(@typescript-eslint/types@8.59.4): dependencies: '@jridgewell/remapping': 2.3.5 '@jridgewell/sourcemap-codec': 1.6.0 @@ -38757,7 +38793,7 @@ snapshots: clsx: 2.1.1 devalue: 5.9.4 esm-env: 1.2.2 - esrap: 2.3.7(@typescript-eslint/types@8.59.4) + esrap: 2.4.2(@typescript-eslint/types@8.59.4) is-reference: 3.0.3 locate-character: 3.0.0 magic-string: 0.30.21 From 71f323f752dc7a709b28c87c6e9e548f9cb78676 Mon Sep 17 00:00:00 2001 From: Jack Herrington Date: Sun, 15 Nov 2026 19:27:35 -0800 Subject: [PATCH 02/14] feat(ai-secure-mcp): security envelope for self-hosting an MCP server Add @tanstack/ai-secure-mcp. createSecureMcpServer wraps createMCPServer with the primitives a self-hoster needs to expose a server to the internet: - hashed bearer-token auth (SHA-256, constant-time compare) - scopes plus a per-client target allowlist - deny-by-default egress (one allowlisted capability, no generic fetch) - per-client sliding-window rate limits - a redacted append-only JSONL audit log - a pluggable tripwire notifier (ntfy, webhook, silent) with debounce - two-phase propose/confirm approval (in memory, single-use, fail-closed) - a go-live preflight that refuses a public funnel while a default is unsafe Built on the existing createMCPServer seams (handle authInfo + context), so it needs no change to @tanstack/ai-mcp. Co-Authored-By: Claude Opus 4.8 (1M context) --- .changeset/add-ai-secure-mcp.md | 5 + packages/ai-secure-mcp/README.md | 134 ++++++++++++ packages/ai-secure-mcp/package.json | 73 +++++++ packages/ai-secure-mcp/src/approval.ts | 80 +++++++ packages/ai-secure-mcp/src/audit.ts | 104 +++++++++ packages/ai-secure-mcp/src/auth.ts | 60 ++++++ packages/ai-secure-mcp/src/clients-file.ts | 55 +++++ packages/ai-secure-mcp/src/deploy.ts | 75 +++++++ packages/ai-secure-mcp/src/egress.ts | 77 +++++++ packages/ai-secure-mcp/src/guard.ts | 169 +++++++++++++++ packages/ai-secure-mcp/src/index.ts | 49 +++++ packages/ai-secure-mcp/src/notifier.ts | 114 ++++++++++ packages/ai-secure-mcp/src/rate-limit.ts | 37 ++++ packages/ai-secure-mcp/src/server.ts | 198 ++++++++++++++++++ packages/ai-secure-mcp/src/types.ts | 84 ++++++++ packages/ai-secure-mcp/tests/approval.test.ts | 64 ++++++ packages/ai-secure-mcp/tests/audit.test.ts | 69 ++++++ packages/ai-secure-mcp/tests/auth.test.ts | 62 ++++++ packages/ai-secure-mcp/tests/deploy.test.ts | 61 ++++++ packages/ai-secure-mcp/tests/egress.test.ts | 49 +++++ packages/ai-secure-mcp/tests/guard.test.ts | 149 +++++++++++++ packages/ai-secure-mcp/tests/notifier.test.ts | 74 +++++++ .../ai-secure-mcp/tests/rate-limit.test.ts | 22 ++ packages/ai-secure-mcp/tests/server.test.ts | 93 ++++++++ packages/ai-secure-mcp/tsconfig.json | 8 + packages/ai-secure-mcp/vite.config.ts | 36 ++++ pnpm-lock.yaml | 19 ++ 27 files changed, 2020 insertions(+) create mode 100644 .changeset/add-ai-secure-mcp.md create mode 100644 packages/ai-secure-mcp/README.md create mode 100644 packages/ai-secure-mcp/package.json create mode 100644 packages/ai-secure-mcp/src/approval.ts create mode 100644 packages/ai-secure-mcp/src/audit.ts create mode 100644 packages/ai-secure-mcp/src/auth.ts create mode 100644 packages/ai-secure-mcp/src/clients-file.ts create mode 100644 packages/ai-secure-mcp/src/deploy.ts create mode 100644 packages/ai-secure-mcp/src/egress.ts create mode 100644 packages/ai-secure-mcp/src/guard.ts create mode 100644 packages/ai-secure-mcp/src/index.ts create mode 100644 packages/ai-secure-mcp/src/notifier.ts create mode 100644 packages/ai-secure-mcp/src/rate-limit.ts create mode 100644 packages/ai-secure-mcp/src/server.ts create mode 100644 packages/ai-secure-mcp/src/types.ts create mode 100644 packages/ai-secure-mcp/tests/approval.test.ts create mode 100644 packages/ai-secure-mcp/tests/audit.test.ts create mode 100644 packages/ai-secure-mcp/tests/auth.test.ts create mode 100644 packages/ai-secure-mcp/tests/deploy.test.ts create mode 100644 packages/ai-secure-mcp/tests/egress.test.ts create mode 100644 packages/ai-secure-mcp/tests/guard.test.ts create mode 100644 packages/ai-secure-mcp/tests/notifier.test.ts create mode 100644 packages/ai-secure-mcp/tests/rate-limit.test.ts create mode 100644 packages/ai-secure-mcp/tests/server.test.ts create mode 100644 packages/ai-secure-mcp/tsconfig.json create mode 100644 packages/ai-secure-mcp/vite.config.ts diff --git a/.changeset/add-ai-secure-mcp.md b/.changeset/add-ai-secure-mcp.md new file mode 100644 index 0000000000..9237a35877 --- /dev/null +++ b/.changeset/add-ai-secure-mcp.md @@ -0,0 +1,5 @@ +--- +'@tanstack/ai-secure-mcp': minor +--- + +Add `@tanstack/ai-secure-mcp`, a security envelope around `createMCPServer` for self-hosting an MCP server on the internet. `createSecureMcpServer` wraps your tools with hashed-token bearer auth, scopes and a per-client target allowlist, deny-by-default egress (no generic `fetch`), a per-client sliding-window rate limit, a redacted append-only JSONL audit log, a pluggable tripwire notifier (`ntfyNotifier`, `webhookNotifier`, `silentNotifier`), and two-phase propose/confirm approval. A go-live preflight refuses a public Tailscale funnel while a secure default is off (unhashed token, open egress, audit or notifier off). diff --git a/packages/ai-secure-mcp/README.md b/packages/ai-secure-mcp/README.md new file mode 100644 index 0000000000..cc30a3a0aa --- /dev/null +++ b/packages/ai-secure-mcp/README.md @@ -0,0 +1,134 @@ +
+ + + + TanStack AI + +
+ +
+ +# @tanstack/ai-secure-mcp + +A security envelope around [`createMCPServer`](https://www.npmjs.com/package/@tanstack/ai-mcp) +for a self-hoster who wants to expose a TanStack AI MCP server to the internet. + +It wraps your server with: + +- **Hashed-token auth** — bearer tokens stored as SHA-256 hashes, constant-time compare. +- **Scopes and a target allowlist** — a token holds scopes; a scope can be narrowed to named resources. +- **Deny-by-default egress** — one allowlisted `egress` capability, no generic `fetch`. +- **Rate limits** — a per-client sliding window. +- **A redacted audit log** — append-only JSONL, args redacted to id-like fields, no secrets. +- **A tripwire notifier** — push a signal to your phone when someone pokes at the server. +- **Two-phase approval** — a tool can return a proposal; a separate confirm runs the action. +- **Go-live preflight** — refuses a public funnel while a secure default is off. + +## Installation + +```bash +pnpm add @tanstack/ai-secure-mcp +``` + +## Quick start + +```typescript +import { + createSecureMcpServer, + hashToken, + ntfyNotifier, +} from '@tanstack/ai-secure-mcp' +import type { AnyServerTool } from '@tanstack/ai' + +declare const hueTools: Array + +const server = createSecureMcpServer({ + name: 'home', + version: '1.0.0', + tools: hueTools, + clients: [ + { + id: 'alice', + // Store the hash, never the raw token. + tokenHash: hashToken('the-raw-token-alice-holds'), + scopes: ['read', 'control'], + }, + ], + egress: ['https://api.hue.local'], // deny-by-default allowlist + policy: { + scopes: { setLights: 'control' }, // setLights needs the control scope + approve: ['buyMovie'], // buyMovie needs two-phase approval + }, + audit: { path: './audit.jsonl', retentionDays: 90 }, + notify: ntfyNotifier({ topic: 'my-home-mcp' }), + funnel: { port: 8787 }, +}) + +// Serve it from your HTTP handler. +export default server.fetch +``` + +`server.preflight` holds the secure-default problems. `server.tailscale` holds +the command to expose the server when you pass `funnel`. + +## Reaching the network from a tool + +A tool receives the `egress` capability on `ctx.context`. It is the only way to +the network, and it refuses any origin not on the allowlist. + +```typescript +import { toolDefinition } from '@tanstack/ai' +import { z } from 'zod' +import type { SecureRequestContext } from '@tanstack/ai-secure-mcp' + +const getLights = toolDefinition({ + name: 'getLights', + description: 'List the lights on the Hue bridge', + inputSchema: z.object({}), +}).server(async (_args, ctx) => { + const res = await ctx.context.egress('https://api.hue.local/lights') + return { status: res.status } +}) +``` + +## Two-phase approval + +A tool in `policy.approve` does not act on the first call. It returns an +envelope: + +```json +{ "status": "approval_required", "proposalId": "…", "summary": "Run buyMovie" } +``` + +A separate, authenticated call to the `approve_proposal` tool with that +`proposalId` runs the action. Proposals are in memory, single-use, and expire, +so a crash cannot leave a ghost approval. + +## Secure defaults + +| Concern | Default | Footgun it prevents | +| --- | --- | --- | +| Egress | deny-by-default allowlist | a tool exfiltrating data | +| Generic HTTP | not injectable | SSRF through a "helpful" tool | +| Tokens | hash-only, constant-time | replay from a leaked store | +| Secrets | never in the audit log or a notification | prompt/response exfiltration | +| Approval state | in memory, fail-closed on restart | a ghost approval after a crash | +| Exposure | tailnet-only unless you opt into a public funnel | accidental internet | + +The preflight refuses a public funnel while a token is unhashed, egress is open, +or the audit log or notifier is off. The funnel URL is not a secret: auth stands +on its own. + +## License + +MIT diff --git a/packages/ai-secure-mcp/package.json b/packages/ai-secure-mcp/package.json new file mode 100644 index 0000000000..76611ebf5e --- /dev/null +++ b/packages/ai-secure-mcp/package.json @@ -0,0 +1,73 @@ +{ + "name": "@tanstack/ai-secure-mcp", + "version": "1.1.0", + "description": "Security envelope for self-hosting a TanStack AI MCP server: hashed-token auth, scopes, deny-by-default egress, rate limits, redacted audit, a tripwire notifier, and two-phase approval.", + "author": "Tanner Linsley", + "license": "MIT", + "homepage": "https://tanstack.com/ai", + "repository": { + "type": "git", + "url": "git+https://github.com/TanStack/ai.git", + "directory": "packages/ai-secure-mcp" + }, + "bugs": { + "url": "https://github.com/TanStack/ai/issues" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "type": "module", + "module": "./dist/esm/index.js", + "types": "./dist/esm/index.d.ts", + "exports": { + ".": { + "types": "./dist/esm/index.d.ts", + "import": "./dist/esm/index.js" + } + }, + "sideEffects": false, + "engines": { + "node": ">=18" + }, + "files": [ + "dist", + "src" + ], + "scripts": { + "build": "vite build", + "clean": "premove ./build ./dist", + "lint:fix": "oxlint src --type-aware --fix", + "test:build": "publint --strict", + "test:oxlint": "oxlint src --type-aware", + "test:coverage": "vitest run --passWithNoTests --coverage --coverage.include='src/**' --coverage.reporter=text-summary --coverage.reporter=json-summary", + "test:lib": "vitest --passWithNoTests", + "test:lib:dev": "pnpm test:lib --watch", + "test:types": "tsc" + }, + "keywords": [ + "ai", + "ai-sdk", + "typescript", + "tanstack", + "mcp", + "security", + "self-hosted", + "auth", + "egress", + "audit" + ], + "dependencies": { + "@modelcontextprotocol/server": "^2.0.0", + "@tanstack/ai-mcp": "workspace:^" + }, + "peerDependencies": { + "@tanstack/ai": "workspace:^", + "zod": "^3.0.0 || ^4.0.0" + }, + "devDependencies": { + "@tanstack/ai": "workspace:*", + "@vitest/coverage-v8": "4.1.10", + "zod": "^4.2.0" + } +} diff --git a/packages/ai-secure-mcp/src/approval.ts b/packages/ai-secure-mcp/src/approval.ts new file mode 100644 index 0000000000..f94ffa64a9 --- /dev/null +++ b/packages/ai-secure-mcp/src/approval.ts @@ -0,0 +1,80 @@ +import { randomUUID } from 'node:crypto' +import { SecureMcpError } from './types' + +/** The envelope a tool returns instead of acting, when approval is needed. */ +export interface ApprovalRequired { + status: 'approval_required' + proposalId: string + summary: string + expiresAt: number +} + +interface Proposal { + owner: string + summary: string + run: () => Promise + expiresAt: number +} + +/** + * Holds pending two-phase approvals. A tool call proposes an action and gets a + * {@link ApprovalRequired} envelope. A later confirm, by the same client, runs + * the action. + * + * The store is in memory and fail-closed: a restart drops every proposal, so a + * ghost approval cannot run after a crash. Each proposal is single-use and + * expires. + */ +export interface ApprovalStore { + propose: (input: { + owner: string + summary: string + run: () => Promise + }) => ApprovalRequired + confirm: (proposalId: string, owner: string) => Promise + pendingCount: () => number +} + +export function createApprovalStore(options?: { + /** How long a proposal stays valid, 300000 ms (5 minutes) by default. */ + ttlMs?: number + /** A clock in ms, for tests. */ + now?: () => number + /** An id source, for tests. */ + newId?: () => string +}): ApprovalStore { + const ttlMs = options?.ttlMs ?? 300_000 + const now = options?.now ?? (() => Date.now()) + const newId = options?.newId ?? (() => randomUUID()) + const proposals = new Map() + + return { + propose: ({ owner, summary, run }) => { + const proposalId = newId() + const expiresAt = now() + ttlMs + proposals.set(proposalId, { owner, summary, run, expiresAt }) + return { status: 'approval_required', proposalId, summary, expiresAt } + }, + + confirm: async (proposalId, owner) => { + const proposal = proposals.get(proposalId) + // Do not tell a caller whether an id exists for another owner. + if (proposal === undefined || proposal.owner !== owner) { + throw new SecureMcpError( + 'not_found', + 'No pending proposal with that id.', + ) + } + if (now() >= proposal.expiresAt) { + proposals.delete(proposalId) + throw new SecureMcpError('proposal_expired', 'The proposal expired.') + } + // Single-use: remove before running, so a failed action cannot be + // retried by replaying the same id. + proposals.delete(proposalId) + return proposal.run() + }, + + pendingCount: () => proposals.size, + } +} diff --git a/packages/ai-secure-mcp/src/audit.ts b/packages/ai-secure-mcp/src/audit.ts new file mode 100644 index 0000000000..61810259df --- /dev/null +++ b/packages/ai-secure-mcp/src/audit.ts @@ -0,0 +1,104 @@ +import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises' +import { dirname } from 'node:path' + +/** One line of the audit log. Secrets and tokens are never present. */ +export interface AuditEntry { + /** The client id, or undefined for an unauthenticated attempt. */ + client?: string + /** What happened, for example `tool_call`, `auth_failure`, `egress_denied`. */ + event: string + /** The tool name, when the event is a tool call. */ + tool?: string + /** `ok`, `denied`, or `error`. */ + outcome: string + /** The raw tool input. It is redacted before it is written. */ + args?: unknown + /** The error code, when the outcome is an error. */ + code?: string +} + +/** + * Keeps only id-like and query-like fields; everything else is redacted. The + * match is a suffix, so camelCase (`movieId`) and snake_case (`movie_id`) both + * count. + */ +const KEEP = /(id|ids|query|q|name|title|kind|type|scope|origin)$/i + +/** + * Redacts tool input to id-like and query-like fields. A non-object becomes a + * type tag. This keeps a useful trail without storing a secret value. + */ +export function redactArgs(args: unknown): unknown { + if (args === null || typeof args !== 'object') { + return args === undefined ? undefined : `[${typeof args}]` + } + if (Array.isArray(args)) return '[array]' + const out: Record = {} + for (const [key, value] of Object.entries(args as Record)) { + out[key] = + KEEP.test(key) && (typeof value === 'string' || typeof value === 'number') + ? value + : '[redacted]' + } + return out +} + +export interface AuditLog { + record: (entry: AuditEntry) => Promise +} + +/** + * An append-only JSONL audit log. Each line is one event with a timestamp and + * redacted args. On start it drops lines older than `retentionDays`. + * + * @param options.path - The JSONL file to append to + * @param options.retentionDays - Days to keep; older lines are pruned on start + * @param options.now - A clock in ms, for tests + */ +export function createAuditLog(options: { + path: string + retentionDays?: number + now?: () => number +}): AuditLog { + const now = options.now ?? (() => Date.now()) + // Prune and ensure the directory on first write, once. + const ready = (async () => { + await mkdir(dirname(options.path), { recursive: true }).catch(() => {}) + if (options.retentionDays === undefined) return + const cutoff = now() - options.retentionDays * 86_400_000 + let text: string + try { + text = await readFile(options.path, 'utf8') + } catch { + return + } + const kept = text + .split('\n') + .filter(Boolean) + .filter((line) => { + try { + const t = (JSON.parse(line) as { time?: number }).time + return typeof t !== 'number' || t >= cutoff + } catch { + return false + } + }) + await writeFile(options.path, kept.length ? kept.join('\n') + '\n' : '') + })() + + return { + record: async (entry) => { + await ready + const line = JSON.stringify({ + time: now(), + client: entry.client, + event: entry.event, + tool: entry.tool, + outcome: entry.outcome, + code: entry.code, + args: redactArgs(entry.args), + }) + await appendFile(options.path, line + '\n', 'utf8') + }, + } +} diff --git a/packages/ai-secure-mcp/src/auth.ts b/packages/ai-secure-mcp/src/auth.ts new file mode 100644 index 0000000000..4126474540 --- /dev/null +++ b/packages/ai-secure-mcp/src/auth.ts @@ -0,0 +1,60 @@ +import { createHash, timingSafeEqual } from 'node:crypto' +import { SecureMcpError } from './types' +import type { ClientRecord } from './types' + +/** + * Hashes a raw bearer token into the lowercase hex SHA-256 stored in a + * {@link ClientRecord}. Use it to fill a clients file and to compare a + * presented token. + */ +export function hashToken(token: string): string { + return createHash('sha256').update(token, 'utf8').digest('hex') +} + +/** + * Compares two hex strings in constant time. Returns false for a length + * mismatch. Use it so a timing side channel cannot reveal the token. + */ +export function constantTimeEqual(a: string, b: string): boolean { + const left = Buffer.from(a, 'utf8') + const right = Buffer.from(b, 'utf8') + if (left.length !== right.length) return false + return timingSafeEqual(left, right) +} + +/** Reads the bearer token from an `Authorization` header value. */ +export function bearerToken(header: string | null): string | undefined { + if (header === null) return undefined + const match = /^Bearer (.+)$/.exec(header.trim()) + return match?.[1] +} + +/** + * Finds the client that owns a raw token, in constant time per record. Throws + * `auth_failure` when no record matches or the token is expired. + * + * @param token - The raw bearer token from the request + * @param clients - The known clients, each with a token hash + * @param nowSeconds - The current time in Unix seconds, for expiry + */ +export function verifyToken( + token: string, + clients: ReadonlyArray, + nowSeconds: number, +): ClientRecord { + const presented = hashToken(token) + let found: ClientRecord | undefined + // Check every record so the time does not depend on the match position. + for (const client of clients) { + if (constantTimeEqual(presented, client.tokenHash)) { + found = client + } + } + if (found === undefined) { + throw new SecureMcpError('auth_failure', 'The token is not valid.') + } + if (found.expiresAt !== undefined && nowSeconds >= found.expiresAt) { + throw new SecureMcpError('auth_failure', 'The token is expired.') + } + return found +} diff --git a/packages/ai-secure-mcp/src/clients-file.ts b/packages/ai-secure-mcp/src/clients-file.ts new file mode 100644 index 0000000000..9d2e9bded6 --- /dev/null +++ b/packages/ai-secure-mcp/src/clients-file.ts @@ -0,0 +1,55 @@ +import { readFile } from 'node:fs/promises' +import { SecureMcpError } from './types' +import type { ClientRecord } from './types' + +function isRecord(value: unknown): value is Record { + return typeof value === 'object' && value !== null +} + +function toClient(value: unknown, index: number): ClientRecord { + if ( + !isRecord(value) || + typeof value.id !== 'string' || + typeof value.tokenHash !== 'string' || + !Array.isArray(value.scopes) + ) { + throw new SecureMcpError( + 'invalid_input', + `Client at index ${index} needs id, tokenHash, and scopes.`, + ) + } + const client: ClientRecord = { + id: value.id, + tokenHash: value.tokenHash, + scopes: value.scopes.filter((s): s is string => typeof s === 'string'), + } + if (Array.isArray(value.targets)) { + client.targets = value.targets.filter( + (t): t is string => typeof t === 'string', + ) + } + if (typeof value.expiresAt === 'number') { + client.expiresAt = value.expiresAt + } + return client +} + +/** + * Reads a clients file: a JSON array of `{ id, tokenHash, scopes, targets?, + * expiresAt? }`. The file holds token hashes only, never a raw token. + */ +export async function clientsFromFile( + path: string, +): Promise> { + let data: unknown + try { + data = JSON.parse(await readFile(path, 'utf8')) + } catch (error) { + const detail = error instanceof Error ? error.message : 'read failed' + throw new SecureMcpError('invalid_input', `Cannot read ${path}: ${detail}`) + } + if (!Array.isArray(data)) { + throw new SecureMcpError('invalid_input', `${path} must be a JSON array.`) + } + return data.map(toClient) +} diff --git a/packages/ai-secure-mcp/src/deploy.ts b/packages/ai-secure-mcp/src/deploy.ts new file mode 100644 index 0000000000..e2b8cfa526 --- /dev/null +++ b/packages/ai-secure-mcp/src/deploy.ts @@ -0,0 +1,75 @@ +import type { ClientRecord } from './types' + +/** What the preflight reads to decide whether the server is safe to expose. */ +export interface PreflightInput { + clients: ReadonlyArray + /** True when egress is deny-by-default (an allowlist is set). */ + egressDenyByDefault: boolean + /** True when the audit log is on. */ + auditOn: boolean + /** True when a real notifier is set (not the silent one). */ + notifierOn: boolean +} + +/** The result of a preflight: the problems that make public exposure unsafe. */ +export interface PreflightResult { + ok: boolean + problems: Array +} + +const HASH = /^[0-9a-f]{64}$/ + +/** + * Checks the secure-by-default rules before the server goes public. It returns + * the problems; the caller refuses a public funnel while any remain. + */ +export function preflight(input: PreflightInput): PreflightResult { + const problems: Array = [] + if (input.clients.length === 0) { + problems.push('No clients are configured, so no token can authenticate.') + } + for (const client of input.clients) { + if (!HASH.test(client.tokenHash)) { + problems.push( + `Client "${client.id}" has a token that is not a SHA-256 hash.`, + ) + } + } + if (!input.egressDenyByDefault) { + problems.push('Egress is not deny-by-default. Set an egress allowlist.') + } + if (!input.auditOn) { + problems.push('The audit log is off. Turn it on before you go public.') + } + if (!input.notifierOn) { + problems.push('The notifier is off. Turn it on before you go public.') + } + return { ok: problems.length === 0, problems } +} + +/** + * Builds the Tailscale command to expose the server. The default is Serve, + * which is tailnet-only. Funnel is public: opt into it on purpose. + * + * The Funnel URL is not a secret. Auth stands on its own, so no security may + * depend on the URL being unguessable. + * + * @param options.port - The local port the server listens on + * @param options.public - Use Funnel (public) instead of Serve (tailnet-only) + */ +export function tailscaleCommand(options: { + port: number + public?: boolean +}): { command: string; note: string } { + const target = `http://127.0.0.1:${options.port}` + if (options.public === true) { + return { + command: `tailscale funnel --bg --https=443 ${target}`, + note: 'Public on the internet. The URL is not a secret; auth stands on its own.', + } + } + return { + command: `tailscale serve --bg --https=443 ${target}`, + note: 'Reachable only on your tailnet. Use { public: true } to go public.', + } +} diff --git a/packages/ai-secure-mcp/src/egress.ts b/packages/ai-secure-mcp/src/egress.ts new file mode 100644 index 0000000000..81f51a1bca --- /dev/null +++ b/packages/ai-secure-mcp/src/egress.ts @@ -0,0 +1,77 @@ +import { SecureMcpError } from './types' + +/** + * A guarded fetch. It reaches only an origin on the allowlist. There is no + * generic fetch: this is the single way a tool touches the network. + */ +export type EgressFetch = ( + url: string, + init?: RequestInit, +) => Promise + +/** + * Builds a deny-by-default egress function. + * + * It refuses any origin not in `allow` with `egress_denied`. It follows no + * redirect (`redirect: 'error'`) and stops after `timeoutMs`. A network error + * or timeout becomes `backend_unavailable`. The HTTP status passes through, so + * the tool decides what a 404 or 500 means. + * + * @param options.allow - The allowed origins, for example `https://api.hue.local` + * @param options.timeoutMs - The per-request timeout, 10000 ms by default + * @param options.onDenied - Runs when an origin is refused, for audit and notify + * @param options.fetch - The fetch to use, the global `fetch` by default + */ +export function createEgress(options: { + allow: ReadonlyArray + timeoutMs?: number + onDenied?: (origin: string) => void + fetch?: (url: string, init?: RequestInit) => Promise +}): EgressFetch { + const allowed = new Set() + for (const entry of options.allow) { + try { + allowed.add(new URL(entry).origin) + } catch { + throw new SecureMcpError( + 'invalid_input', + `Egress allowlist entry is not a URL: ${entry}`, + ) + } + } + const timeoutMs = options.timeoutMs ?? 10_000 + const fetchImpl = options.fetch ?? fetch + + return async (url, init) => { + let origin: string + try { + origin = new URL(url).origin + } catch { + throw new SecureMcpError('invalid_input', `Not a URL: ${url}`) + } + if (!allowed.has(origin)) { + options.onDenied?.(origin) + throw new SecureMcpError( + 'egress_denied', + `Egress to ${origin} is not on the allowlist.`, + ) + } + const controller = new AbortController() + const timer = setTimeout(() => controller.abort(), timeoutMs) + try { + return await fetchImpl(url, { + ...init, + redirect: 'error', + signal: controller.signal, + }) + } catch (error) { + const detail = error instanceof Error ? error.message : 'request failed' + throw new SecureMcpError( + 'backend_unavailable', + `Egress to ${origin} failed: ${detail}`, + ) + } finally { + clearTimeout(timer) + } + } +} diff --git a/packages/ai-secure-mcp/src/guard.ts b/packages/ai-secure-mcp/src/guard.ts new file mode 100644 index 0000000000..434a82b52a --- /dev/null +++ b/packages/ai-secure-mcp/src/guard.ts @@ -0,0 +1,169 @@ +import { toolDefinition } from '@tanstack/ai' +import { z } from 'zod' +import { SecureMcpError } from './types' +import type { AnyServerTool, ToolExecutionContext } from '@tanstack/ai' +import type { ApprovalStore } from './approval' +import type { AuditLog } from './audit' +import type { EgressFetch } from './egress' +import type { AccessPolicy, ClientRecord, SecurityNotifier } from './types' + +/** + * The per-request values the envelope injects into `ctx.context`. A tool reads + * `ctx.context.egress` to reach the network. The guard reads `secure` to know + * the caller. + */ +export interface SecureRequestContext { + secure: { client: ClientRecord } + egress: EgressFetch +} + +interface GuardDeps { + policy: AccessPolicy + approvals: ApprovalStore + audit?: AuditLog + notify: SecurityNotifier + summarize: (toolName: string, args: unknown) => string +} + +function isRecord(value: unknown): value is Record { + return typeof value === 'object' && value !== null +} + +/** Reads the verified client the outer fetch injected into the tool context. */ +function readClient( + context: ToolExecutionContext | undefined, +): ClientRecord { + // Typed as present, but a misuse could still leave it out at runtime. + const client = context?.context?.secure?.client + if (client === undefined) { + throw new SecureMcpError('auth_failure', 'The request is not authenticated.') + } + return client +} + +/** + * Wraps each tool with the access guard: scope, then target allowlist, then + * two-phase approval, then the call. Every outcome is audited. A refusal also + * pings the notifier. + */ +export function guardTools( + tools: ReadonlyArray, + deps: GuardDeps, +): Array { + return tools.map((tool) => { + const original = tool.execute + const execute = async ( + args: unknown, + context?: ToolExecutionContext, + ): Promise => { + const client = readClient(context) + + const scope = deps.policy.scopes?.[tool.name] + if (scope !== undefined && !client.scopes.includes(scope)) { + return refuse(deps, client, tool.name, args, 'forbidden_scope', `This token does not hold the "${scope}" scope.`) + } + + const targetField = deps.policy.targetParam?.[tool.name] + if (targetField !== undefined && client.targets !== undefined) { + const value = isRecord(args) ? args[targetField] : undefined + if (!client.targets.includes(String(value))) { + return refuse(deps, client, tool.name, args, 'forbidden_scope', 'This token may not reach that target.') + } + } + + if (deps.policy.approve?.includes(tool.name)) { + const summary = deps.summarize(tool.name, args) + const envelope = deps.approvals.propose({ + owner: client.id, + summary, + run: async () => original?.(args, context), + }) + await deps.audit?.record({ + client: client.id, + event: 'tool_proposed', + tool: tool.name, + outcome: 'ok', + args, + }) + void deps.notify.notify({ + kind: 'approval_pending', + proposalId: envelope.proposalId, + summary, + }) + return envelope + } + + try { + const result = await original?.(args, context) + await deps.audit?.record({ + client: client.id, + event: 'tool_call', + tool: tool.name, + outcome: 'ok', + args, + }) + return result + } catch (error) { + await deps.audit?.record({ + client: client.id, + event: 'tool_call', + tool: tool.name, + outcome: 'error', + code: error instanceof SecureMcpError ? error.code : undefined, + args, + }) + throw error + } + } + return { ...tool, execute } + }) +} + +async function refuse( + deps: GuardDeps, + client: ClientRecord, + tool: string, + args: unknown, + code: 'forbidden_scope', + message: string, +): Promise { + await deps.audit?.record({ + client: client.id, + event: 'tool_call', + tool, + outcome: 'denied', + code, + args, + }) + void deps.notify.notify({ kind: 'forbidden_scope', client: client.id, tool }) + throw new SecureMcpError(code, message) +} + +/** + * Builds the `approve_proposal` tool. A client confirms its own pending + * proposal by id; the stored action then runs host-side. + */ +export function createConfirmTool(deps: { + approvals: ApprovalStore + audit?: AuditLog +}): AnyServerTool { + const tool: AnyServerTool = toolDefinition({ + name: 'approve_proposal', + description: + 'Confirm a pending approval by its proposalId. Runs the proposed action.', + inputSchema: z.object({ + proposalId: z.string().describe('The id from an approval_required reply.'), + }), + }).server(async ({ proposalId }, context) => { + const client = readClient(context) + const result = await deps.approvals.confirm(proposalId, client.id) + await deps.audit?.record({ + client: client.id, + event: 'approval_confirmed', + outcome: 'ok', + args: { proposalId }, + }) + return { confirmed: true, result } + }) + return tool +} diff --git a/packages/ai-secure-mcp/src/index.ts b/packages/ai-secure-mcp/src/index.ts new file mode 100644 index 0000000000..7441f1eb82 --- /dev/null +++ b/packages/ai-secure-mcp/src/index.ts @@ -0,0 +1,49 @@ +// The envelope +export { createSecureMcpServer } from './server' +export type { SecureMcpConfig, SecureMcpServer } from './server' + +// Auth + clients +export { hashToken, constantTimeEqual, bearerToken, verifyToken } from './auth' +export { clientsFromFile } from './clients-file' + +// Egress +export { createEgress } from './egress' +export type { EgressFetch } from './egress' + +// Two-phase approval +export { createApprovalStore } from './approval' +export type { ApprovalStore, ApprovalRequired } from './approval' + +// Rate limiting +export { createRateLimiter } from './rate-limit' +export type { RateLimiter } from './rate-limit' + +// Audit +export { createAuditLog, redactArgs } from './audit' +export type { AuditLog, AuditEntry } from './audit' + +// Notifiers +export { + ntfyNotifier, + webhookNotifier, + silentNotifier, + debounceNotifier, + describeEvent, +} from './notifier' + +// Go-live +export { preflight, tailscaleCommand } from './deploy' +export type { PreflightInput, PreflightResult } from './deploy' + +// Guard context (for typing a tool's ctx) +export type { SecureRequestContext } from './guard' + +// Shared types +export { SecureMcpError } from './types' +export type { + ErrorCode, + ClientRecord, + SecurityEvent, + SecurityNotifier, + AccessPolicy, +} from './types' diff --git a/packages/ai-secure-mcp/src/notifier.ts b/packages/ai-secure-mcp/src/notifier.ts new file mode 100644 index 0000000000..3477541eed --- /dev/null +++ b/packages/ai-secure-mcp/src/notifier.ts @@ -0,0 +1,114 @@ +import type { SecurityEvent, SecurityNotifier } from './types' + +/** A one-line, secret-free summary of an event, for a push body. */ +export function describeEvent(event: SecurityEvent): string { + switch (event.kind) { + case 'auth_failure': + return `Auth failure${event.client ? ` for ${event.client}` : ''}${ + event.ip ? ` from ${event.ip}` : '' + }` + case 'forbidden_scope': + return `${event.client} was refused tool ${event.tool} (scope)` + case 'egress_denied': + return `Egress to ${event.origin} was refused${ + event.tool ? ` from ${event.tool}` : '' + }` + case 'rate_limited': + return `${event.client} hit the rate limit` + case 'approval_pending': + return `Approval needed: ${event.summary} (${event.proposalId})` + case 'malformed_request': + return `Malformed request: ${event.detail}` + } +} + +/** A notifier that does nothing. Use it to turn notifications off on purpose. */ +export function silentNotifier(): SecurityNotifier { + return { notify: async () => {} } +} + +/** + * A notifier that pushes to an [ntfy](https://ntfy.sh) topic. Zero infra: the + * body is the event summary. No secret or token is ever in the body. + * + * @param options.topic - The ntfy topic to publish to + * @param options.priority - The ntfy priority header (1 to 5) + * @param options.serverUrl - The ntfy server, `https://ntfy.sh` by default + */ +export function ntfyNotifier(options: { + topic: string + priority?: 1 | 2 | 3 | 4 | 5 + serverUrl?: string + fetch?: (url: string, init?: RequestInit) => Promise +}): SecurityNotifier { + const base = (options.serverUrl ?? 'https://ntfy.sh').replace(/\/+$/, '') + const fetchImpl = options.fetch ?? fetch + return { + notify: async (event) => { + const headers: Record = { Title: `MCP: ${event.kind}` } + if (options.priority !== undefined) { + headers.Priority = String(options.priority) + } + // Best-effort. A down notifier must not break the request path. + try { + await fetchImpl(`${base}/${encodeURIComponent(options.topic)}`, { + method: 'POST', + headers, + body: describeEvent(event), + }) + } catch { + // swallow + } + }, + } +} + +/** + * A notifier that POSTs the event as JSON to a webhook. Use it for Slack, + * Discord, or your own handler. + */ +export function webhookNotifier( + url: string, + fetchImpl: (url: string, init?: RequestInit) => Promise = fetch, +): SecurityNotifier { + return { + notify: async (event) => { + try { + await fetchImpl(url, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ ...event, text: describeEvent(event) }), + }) + } catch { + // swallow + } + }, + } +} + +/** + * Wraps a notifier so the same event kind for the same client is sent at most + * once per window. A scanner cannot turn the tripwire into a self-DoS. + * + * @param inner - The notifier to protect + * @param windowMs - The quiet window per key, 60000 ms by default + * @param now - A clock in ms, for tests + */ +export function debounceNotifier( + inner: SecurityNotifier, + windowMs = 60_000, + now: () => number = () => Date.now(), +): SecurityNotifier { + const lastSent = new Map() + return { + notify: async (event) => { + const client = 'client' in event ? event.client : '' + const key = `${event.kind}:${client ?? ''}` + const at = now() + const prev = lastSent.get(key) + if (prev !== undefined && at - prev < windowMs) return + lastSent.set(key, at) + await inner.notify(event) + }, + } +} diff --git a/packages/ai-secure-mcp/src/rate-limit.ts b/packages/ai-secure-mcp/src/rate-limit.ts new file mode 100644 index 0000000000..08a931d147 --- /dev/null +++ b/packages/ai-secure-mcp/src/rate-limit.ts @@ -0,0 +1,37 @@ +/** + * A per-client sliding-window rate limiter. It keeps the recent call times for + * each client and refuses a call that would pass the limit in the window. + * + * ponytail: in-memory per process. For many server instances, swap in a shared + * store behind the same `allow` method. + */ +export interface RateLimiter { + /** Returns true when the call is within the limit, and records it. */ + allow: (clientId: string) => boolean +} + +export function createRateLimiter(options: { + /** The most calls allowed in one window. */ + limit: number + /** The window length in ms. */ + windowMs: number + /** A clock in ms, for tests. */ + now?: () => number +}): RateLimiter { + const hits = new Map>() + const now = options.now ?? (() => Date.now()) + return { + allow: (clientId) => { + const at = now() + const cutoff = at - options.windowMs + const recent = (hits.get(clientId) ?? []).filter((t) => t > cutoff) + if (recent.length >= options.limit) { + hits.set(clientId, recent) + return false + } + recent.push(at) + hits.set(clientId, recent) + return true + }, + } +} diff --git a/packages/ai-secure-mcp/src/server.ts b/packages/ai-secure-mcp/src/server.ts new file mode 100644 index 0000000000..349b89ab5d --- /dev/null +++ b/packages/ai-secure-mcp/src/server.ts @@ -0,0 +1,198 @@ +import { createMCPServer } from '@tanstack/ai-mcp/server' +import { bearerToken, verifyToken } from './auth' +import { createApprovalStore } from './approval' +import { createAuditLog } from './audit' +import { createEgress } from './egress' +import { createConfirmTool, guardTools } from './guard' +import { silentNotifier } from './notifier' +import { createRateLimiter } from './rate-limit' +import { preflight, tailscaleCommand } from './deploy' +import { SecureMcpError } from './types' +import type { AuthInfo } from '@modelcontextprotocol/server' +import type { AnyServerTool } from '@tanstack/ai' +import type { SampleRequest } from '@tanstack/ai-mcp/server' +import type { AuditLog } from './audit' +import type { PreflightResult } from './deploy' +import type { + AccessPolicy, + ClientRecord, + SecurityNotifier, +} from './types' + +/** Config for {@link createSecureMcpServer}. */ +export interface SecureMcpConfig { + name: string + version: string + /** The tools to serve. The envelope wraps each one with the access guard. */ + tools: ReadonlyArray + /** The known clients, by token hash. See `hashToken` and `clientsFromFile`. */ + clients: ReadonlyArray + /** The egress allowlist. Without it, no tool can reach the network. */ + egress?: + | ReadonlyArray + | { allow: ReadonlyArray; timeoutMs?: number } + /** Per-tool scope, target, and approval rules. */ + policy?: AccessPolicy + /** Sliding-window rate limit per client. `false` turns it off. */ + rateLimit?: { limit: number; windowMs: number } | false + /** Redacted JSONL audit log. `false` turns it off (not recommended). */ + audit?: { path: string; retentionDays?: number } | false + /** Where to send tripwire events. Defaults to a silent sink. */ + notify?: SecurityNotifier + /** Two-phase approval settings. */ + approval?: { ttlMs?: number } + /** Builds the host-side summary shown with an approval request. */ + summarize?: (toolName: string, args: unknown) => string + /** When set, the result carries the Tailscale command to expose the server. */ + funnel?: { port: number; public?: boolean } + /** The model adapter for `ctx.context.sample` on spec 2026. */ + sample?: (request: SampleRequest) => Promise +} + +/** The result of {@link createSecureMcpServer}. */ +export interface SecureMcpServer { + /** Serve one HTTP request. Does auth, rate-limit, audit, then delegates. */ + fetch: (request: Request) => Promise + /** The secure-default check computed from the config. */ + preflight: PreflightResult + /** The Tailscale command, when `funnel` is set. */ + tailscale?: { command: string; note: string } +} + +const FAR_FUTURE = 4_102_444_800 // 2100-01-01, for a token with no expiry + +function jsonError(status: number, code: string, headers?: HeadersInit) { + return new Response(JSON.stringify({ error: { code } }), { + status, + headers: { 'content-type': 'application/json', ...headers }, + }) +} + +/** + * Wraps `createMCPServer` with the security envelope a self-hoster needs to + * expose a server to the internet: hashed-token auth, scopes and a target + * allowlist, deny-by-default egress, rate limits, a redacted audit log, a + * tripwire notifier, and two-phase approval. + * + * It refuses to go public (`funnel.public`) while the preflight finds a + * problem, such as an unhashed token or egress that is not deny-by-default. + */ +export function createSecureMcpServer( + config: SecureMcpConfig, +): SecureMcpServer { + const notify = config.notify ?? silentNotifier() + const audit: AuditLog | undefined = + config.audit === false || config.audit === undefined + ? undefined + : createAuditLog(config.audit) + + let allow: ReadonlyArray = [] + let egressTimeoutMs: number | undefined + if (config.egress !== undefined) { + if ('allow' in config.egress) { + allow = config.egress.allow + egressTimeoutMs = config.egress.timeoutMs + } else { + allow = config.egress + } + } + const egress = createEgress({ + allow, + ...(egressTimeoutMs === undefined ? {} : { timeoutMs: egressTimeoutMs }), + onDenied: (origin) => void notify.notify({ kind: 'egress_denied', origin }), + }) + + const policy: AccessPolicy = config.policy ?? {} + const approvals = createApprovalStore(config.approval) + const summarize = + config.summarize ?? ((toolName: string) => `Run ${toolName}`) + + const guarded = guardTools(config.tools, { + policy, + approvals, + audit, + notify, + summarize, + }) + const tools: Array = policy.approve?.length + ? [...guarded, createConfirmTool({ approvals, audit })] + : guarded + + const inner = createMCPServer({ + name: config.name, + version: config.version, + tools, + ...(config.sample === undefined ? {} : { sample: config.sample }), + }) + + const rl = + config.rateLimit === false + ? undefined + : createRateLimiter(config.rateLimit ?? { limit: 60, windowMs: 60_000 }) + + const check = preflight({ + clients: config.clients, + egressDenyByDefault: allow.length > 0, + auditOn: audit !== undefined, + notifierOn: config.notify !== undefined, + }) + if (config.funnel?.public === true && !check.ok) { + throw new SecureMcpError( + 'invalid_input', + `Refusing to expose a public funnel. Fix: ${check.problems.join(' ')}`, + ) + } + + const nowSeconds = () => Math.floor(Date.now() / 1000) + + const fetch = async (request: Request): Promise => { + const token = bearerToken(request.headers.get('authorization')) + if (token === undefined) { + void notify.notify({ kind: 'auth_failure' }) + await audit?.record({ event: 'auth_failure', outcome: 'denied' }) + return jsonError(401, 'auth_failure', { + 'www-authenticate': 'Bearer', + }) + } + + let client: ClientRecord + try { + client = verifyToken(token, config.clients, nowSeconds()) + } catch { + void notify.notify({ kind: 'auth_failure' }) + await audit?.record({ event: 'auth_failure', outcome: 'denied' }) + return jsonError(401, 'auth_failure', { 'www-authenticate': 'Bearer' }) + } + + if (rl !== undefined && !rl.allow(client.id)) { + void notify.notify({ kind: 'rate_limited', client: client.id }) + await audit?.record({ + client: client.id, + event: 'rate_limited', + outcome: 'denied', + }) + return jsonError(429, 'rate_limited') + } + + const authInfo: AuthInfo = { + token: '[redacted]', + clientId: client.id, + scopes: client.scopes, + expiresAt: client.expiresAt ?? FAR_FUTURE, + extra: {}, + } + + return inner.handle(request, { + authInfo, + context: { secure: { client }, egress }, + }) + } + + return { + fetch, + preflight: check, + ...(config.funnel === undefined + ? {} + : { tailscale: tailscaleCommand(config.funnel) }), + } +} diff --git a/packages/ai-secure-mcp/src/types.ts b/packages/ai-secure-mcp/src/types.ts new file mode 100644 index 0000000000..e70f4607bb --- /dev/null +++ b/packages/ai-secure-mcp/src/types.ts @@ -0,0 +1,84 @@ +/** + * The fixed error taxonomy. Capabilities and the envelope refuse with one of + * these codes. The code crosses every boundary intact, so a caller sees the + * reason and never a leaked stack. + */ +export type ErrorCode = + | 'invalid_input' + | 'auth_failure' + | 'forbidden_scope' + | 'rate_limited' + | 'egress_denied' + | 'not_found' + | 'backend_unavailable' + | 'proposal_expired' + | 'malformed_request' + +/** + * An error with a stable {@link ErrorCode}. The message is safe to show the + * caller: put no secret in it. + */ +export class SecureMcpError extends Error { + readonly code: ErrorCode + constructor(code: ErrorCode, message: string) { + super(message) + this.name = 'SecureMcpError' + this.code = code + } +} + +/** + * One client of the server. The token is stored only as a SHA-256 hash. + * The raw token lives in the client's own credential store, never here. + */ +export interface ClientRecord { + /** A stable name for the client. Used in the audit log and notifications. */ + id: string + /** Lowercase hex SHA-256 of the bearer token. See `hashToken`. */ + tokenHash: string + /** The scopes this client holds. A tool can require one of these. */ + scopes: Array + /** + * The resources this client can reach within a scope. When set, a tool with + * a target parameter refuses a value that is not in this list. + */ + targets?: Array + /** Unix seconds after which the token is invalid. */ + expiresAt?: number +} + +/** + * An event worth a human's attention. The notifier sends it off the box, so it + * must carry no secret and no token material. + */ +export type SecurityEvent = + | { kind: 'auth_failure'; client?: string; ip?: string } + | { kind: 'forbidden_scope'; client: string; tool: string } + | { kind: 'egress_denied'; origin: string; tool?: string } + | { kind: 'rate_limited'; client: string } + | { kind: 'approval_pending'; proposalId: string; summary: string } + | { kind: 'malformed_request'; detail: string } + +/** + * A sink for {@link SecurityEvent}. It is best-effort and must never block or + * throw into the request path. + */ +export interface SecurityNotifier { + notify: (event: SecurityEvent) => Promise +} + +/** The per-tool access policy. A tool not named here needs only a valid token. */ +export interface AccessPolicy { + /** The scope a client must hold to call the named tool. */ + scopes?: Record + /** + * The input field that names the target resource for the named tool. The + * guard reads that field and checks it against the client's `targets`. + */ + targetParam?: Record + /** + * Tools that need two-phase approval (tier 3). A call returns a proposal + * instead of acting; a later confirm runs the action. + */ + approve?: Array +} diff --git a/packages/ai-secure-mcp/tests/approval.test.ts b/packages/ai-secure-mcp/tests/approval.test.ts new file mode 100644 index 0000000000..545c11ee76 --- /dev/null +++ b/packages/ai-secure-mcp/tests/approval.test.ts @@ -0,0 +1,64 @@ +import { describe, expect, it } from 'vitest' +import { createApprovalStore } from '../src/approval' + +function fixedIds() { + let n = 0 + return () => `id-${(n += 1)}` +} + +describe('createApprovalStore', () => { + it('proposes, then confirms once, running the action', async () => { + const store = createApprovalStore({ now: () => 0, newId: fixedIds() }) + let ran = 0 + const env = store.propose({ + owner: 'alice', + summary: 'Add Dune to Radarr', + run: async () => { + ran += 1 + return 'done' + }, + }) + expect(env).toMatchObject({ + status: 'approval_required', + proposalId: 'id-1', + summary: 'Add Dune to Radarr', + }) + expect(store.pendingCount()).toBe(1) + + expect(await store.confirm('id-1', 'alice')).toBe('done') + expect(ran).toBe(1) + expect(store.pendingCount()).toBe(0) + }) + + it('is single-use: a second confirm fails', async () => { + const store = createApprovalStore({ now: () => 0, newId: fixedIds() }) + store.propose({ owner: 'a', summary: 's', run: async () => 1 }) + await store.confirm('id-1', 'a') + await expect(store.confirm('id-1', 'a')).rejects.toMatchObject({ + code: 'not_found', + }) + }) + + it('refuses a confirm from another owner', async () => { + const store = createApprovalStore({ now: () => 0, newId: fixedIds() }) + store.propose({ owner: 'a', summary: 's', run: async () => 1 }) + await expect(store.confirm('id-1', 'b')).rejects.toMatchObject({ + code: 'not_found', + }) + }) + + it('expires a proposal after the ttl', async () => { + let t = 0 + const store = createApprovalStore({ + ttlMs: 100, + now: () => t, + newId: fixedIds(), + }) + store.propose({ owner: 'a', summary: 's', run: async () => 1 }) + t = 100 + await expect(store.confirm('id-1', 'a')).rejects.toMatchObject({ + code: 'proposal_expired', + }) + expect(store.pendingCount()).toBe(0) + }) +}) diff --git a/packages/ai-secure-mcp/tests/audit.test.ts b/packages/ai-secure-mcp/tests/audit.test.ts new file mode 100644 index 0000000000..68edc69898 --- /dev/null +++ b/packages/ai-secure-mcp/tests/audit.test.ts @@ -0,0 +1,69 @@ +import { mkdtemp, readFile, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { describe, expect, it } from 'vitest' +import { createAuditLog, redactArgs } from '../src/audit' + +describe('redactArgs', () => { + it('keeps id-like and query-like fields, redacts the rest', () => { + expect( + redactArgs({ movieId: 'tt123', query: 'dune', apiKey: 'secret', n: 5 }), + ).toEqual({ + movieId: 'tt123', + query: 'dune', + apiKey: '[redacted]', + n: '[redacted]', + }) + }) + + it('does not leak a non-object value', () => { + expect(redactArgs('a-secret-string')).toBe('[string]') + expect(redactArgs([1, 2, 3])).toBe('[array]') + }) +}) + +describe('createAuditLog', () => { + it('appends one JSONL line per event with redacted args', async () => { + const dir = await mkdtemp(join(tmpdir(), 'audit-')) + const path = join(dir, 'audit.jsonl') + const log = createAuditLog({ path, now: () => 1000 }) + await log.record({ + client: 'alice', + event: 'tool_call', + tool: 'buyMovie', + outcome: 'ok', + args: { movieId: 'tt1', apiKey: 'nope' }, + }) + const lines = (await readFile(path, 'utf8')).trim().split('\n') + expect(lines).toHaveLength(1) + const row = JSON.parse(lines[0]!) + expect(row).toMatchObject({ + time: 1000, + client: 'alice', + tool: 'buyMovie', + outcome: 'ok', + args: { movieId: 'tt1', apiKey: '[redacted]' }, + }) + expect(JSON.stringify(row)).not.toContain('nope') + }) + + it('prunes lines older than retentionDays on start', async () => { + const dir = await mkdtemp(join(tmpdir(), 'audit-')) + const path = join(dir, 'audit.jsonl') + const dayMs = 86_400_000 + const old = JSON.stringify({ time: 0, event: 'old' }) + const fresh = JSON.stringify({ time: 5 * dayMs, event: 'fresh' }) + await writeFile(path, old + '\n' + fresh + '\n') + + const log = createAuditLog({ + path, + retentionDays: 2, + now: () => 5 * dayMs, + }) + await log.record({ event: 'new', outcome: 'ok' }) + const text = await readFile(path, 'utf8') + expect(text).not.toContain('"old"') + expect(text).toContain('"fresh"') + expect(text).toContain('"new"') + }) +}) diff --git a/packages/ai-secure-mcp/tests/auth.test.ts b/packages/ai-secure-mcp/tests/auth.test.ts new file mode 100644 index 0000000000..f6b799f4a4 --- /dev/null +++ b/packages/ai-secure-mcp/tests/auth.test.ts @@ -0,0 +1,62 @@ +import { describe, expect, it } from 'vitest' +import { SecureMcpError } from '../src/types' +import { bearerToken, constantTimeEqual, hashToken, verifyToken } from '../src/auth' +import type { ClientRecord } from '../src/types' + +const client: ClientRecord = { + id: 'alice', + tokenHash: hashToken('secret-token'), + scopes: ['read'], +} + +describe('hashToken', () => { + it('is a 64-char hex digest and is stable', () => { + const h = hashToken('secret-token') + expect(h).toMatch(/^[0-9a-f]{64}$/) + expect(h).toBe(hashToken('secret-token')) + }) + + it('differs for a different token', () => { + expect(hashToken('a')).not.toBe(hashToken('b')) + }) +}) + +describe('constantTimeEqual', () => { + it('matches equal strings and rejects others', () => { + expect(constantTimeEqual('abc', 'abc')).toBe(true) + expect(constantTimeEqual('abc', 'abd')).toBe(false) + expect(constantTimeEqual('abc', 'abcd')).toBe(false) + }) +}) + +describe('bearerToken', () => { + it('reads a Bearer token and ignores other shapes', () => { + expect(bearerToken('Bearer xyz')).toBe('xyz') + expect(bearerToken(' Bearer xyz ')).toBe(' xyz') + expect(bearerToken('Basic xyz')).toBeUndefined() + expect(bearerToken(null)).toBeUndefined() + }) +}) + +describe('verifyToken', () => { + it('returns the matching client', () => { + expect(verifyToken('secret-token', [client], 0).id).toBe('alice') + }) + + it('throws auth_failure for an unknown token', () => { + expect(() => verifyToken('nope', [client], 0)).toThrow(SecureMcpError) + try { + verifyToken('nope', [client], 0) + } catch (error) { + expect((error as SecureMcpError).code).toBe('auth_failure') + } + }) + + it('throws auth_failure for an expired token', () => { + const expiring: ClientRecord = { ...client, expiresAt: 100 } + expect(verifyToken('secret-token', [expiring], 50).id).toBe('alice') + expect(() => verifyToken('secret-token', [expiring], 100)).toThrow( + /expired/, + ) + }) +}) diff --git a/packages/ai-secure-mcp/tests/deploy.test.ts b/packages/ai-secure-mcp/tests/deploy.test.ts new file mode 100644 index 0000000000..a8d0b35ea7 --- /dev/null +++ b/packages/ai-secure-mcp/tests/deploy.test.ts @@ -0,0 +1,61 @@ +import { describe, expect, it } from 'vitest' +import { hashToken } from '../src/auth' +import { preflight, tailscaleCommand } from '../src/deploy' +import type { ClientRecord } from '../src/types' + +const good: ClientRecord = { + id: 'alice', + tokenHash: hashToken('t'), + scopes: ['read'], +} + +describe('preflight', () => { + it('passes when every rule holds', () => { + const r = preflight({ + clients: [good], + egressDenyByDefault: true, + auditOn: true, + notifierOn: true, + }) + expect(r.ok).toBe(true) + expect(r.problems).toEqual([]) + }) + + it('flags unhashed tokens, open egress, and off audit/notifier', () => { + const r = preflight({ + clients: [{ id: 'bob', tokenHash: 'plaintext', scopes: [] }], + egressDenyByDefault: false, + auditOn: false, + notifierOn: false, + }) + expect(r.ok).toBe(false) + expect(r.problems.join(' ')).toMatch(/SHA-256/) + expect(r.problems.join(' ')).toMatch(/Egress/) + expect(r.problems.join(' ')).toMatch(/audit/) + expect(r.problems.join(' ')).toMatch(/notifier/) + }) + + it('flags an empty client list', () => { + const r = preflight({ + clients: [], + egressDenyByDefault: true, + auditOn: true, + notifierOn: true, + }) + expect(r.ok).toBe(false) + }) +}) + +describe('tailscaleCommand', () => { + it('defaults to tailnet-only serve', () => { + const r = tailscaleCommand({ port: 8787 }) + expect(r.command).toContain('tailscale serve') + expect(r.command).toContain('http://127.0.0.1:8787') + }) + + it('uses funnel when public', () => { + const r = tailscaleCommand({ port: 8787, public: true }) + expect(r.command).toContain('tailscale funnel') + expect(r.note).toMatch(/not a secret/) + }) +}) diff --git a/packages/ai-secure-mcp/tests/egress.test.ts b/packages/ai-secure-mcp/tests/egress.test.ts new file mode 100644 index 0000000000..d683049d22 --- /dev/null +++ b/packages/ai-secure-mcp/tests/egress.test.ts @@ -0,0 +1,49 @@ +import { describe, expect, it, vi } from 'vitest' +import { SecureMcpError } from '../src/types' +import { createEgress } from '../src/egress' + +describe('createEgress', () => { + it('allows a listed origin and passes the HTTP status through', async () => { + const fetchImpl = vi.fn( + async (_url: string, _init?: RequestInit) => + new Response('body', { status: 404 }), + ) + const egress = createEgress({ + allow: ['https://api.hue.local'], + fetch: fetchImpl, + }) + const res = await egress('https://api.hue.local/lights') + expect(res.status).toBe(404) + // redirect is forced to error, not followed. + expect(fetchImpl.mock.calls[0]![1]?.redirect).toBe('error') + }) + + it('refuses an off-list origin with egress_denied and reports it', async () => { + const onDenied = vi.fn() + const egress = createEgress({ + allow: ['https://api.hue.local'], + onDenied, + fetch: async () => new Response('should not run'), + }) + await expect(egress('https://evil.test/steal')).rejects.toMatchObject({ + code: 'egress_denied', + }) + expect(onDenied).toHaveBeenCalledWith('https://evil.test') + }) + + it('maps a network failure to backend_unavailable', async () => { + const egress = createEgress({ + allow: ['https://api.hue.local'], + fetch: async () => { + throw new Error('ECONNREFUSED') + }, + }) + await expect(egress('https://api.hue.local/x')).rejects.toMatchObject({ + code: 'backend_unavailable', + }) + }) + + it('rejects a non-URL allowlist entry at build time', () => { + expect(() => createEgress({ allow: ['not a url'] })).toThrow(SecureMcpError) + }) +}) diff --git a/packages/ai-secure-mcp/tests/guard.test.ts b/packages/ai-secure-mcp/tests/guard.test.ts new file mode 100644 index 0000000000..49516c87e4 --- /dev/null +++ b/packages/ai-secure-mcp/tests/guard.test.ts @@ -0,0 +1,149 @@ +import { toolDefinition } from '@tanstack/ai' +import { z } from 'zod' +import { describe, expect, it } from 'vitest' +import { createApprovalStore } from '../src/approval' +import { createConfirmTool, guardTools } from '../src/guard' +import type { ApprovalRequired } from '../src/approval' +import type { AuditEntry, AuditLog } from '../src/audit' +import type { SecureRequestContext } from '../src/guard' +import type { + AccessPolicy, + ClientRecord, + SecurityEvent, + SecurityNotifier, +} from '../src/types' + +function capturingNotifier(): SecurityNotifier & { events: Array } { + const events: Array = [] + return { events, notify: async (event) => void events.push(event) } +} + +function capturingAudit(): AuditLog & { entries: Array } { + const entries: Array = [] + return { entries, record: async (entry) => void entries.push(entry) } +} + +const noopEgress = async () => new Response() + +function contextFor(client: ClientRecord) { + return { context: { secure: { client }, egress: noopEgress } } satisfies { + context: SecureRequestContext + } +} + +const setLights = toolDefinition({ + name: 'setLights', + description: 'Set a room light', + inputSchema: z.object({ room: z.string(), on: z.boolean() }), +}).server(async ({ room, on }) => ({ room, on })) + +const buyMovie = toolDefinition({ + name: 'buyMovie', + description: 'Buy a movie', + inputSchema: z.object({ movieId: z.string() }), +}).server(async ({ movieId }) => ({ bought: movieId })) + +function setup(policy: AccessPolicy) { + const notify = capturingNotifier() + const audit = capturingAudit() + const approvals = createApprovalStore({ newId: () => 'prop-1' }) + const [guardedLights, guardedMovie] = guardTools([setLights, buyMovie], { + policy, + approvals, + audit, + notify, + summarize: (name, args) => `${name}:${JSON.stringify(args)}`, + }) + return { notify, audit, approvals, guardedLights, guardedMovie } +} + +const control: ClientRecord = { + id: 'alice', + tokenHash: 'x', + scopes: ['control'], +} + +describe('guardTools — scopes', () => { + it('runs the tool when the client holds the scope', async () => { + const { guardedLights, audit } = setup({ scopes: { setLights: 'control' } }) + const result = await guardedLights!.execute!( + { room: 'den', on: true }, + contextFor(control), + ) + expect(result).toEqual({ room: 'den', on: true }) + expect(audit.entries.at(-1)).toMatchObject({ outcome: 'ok', tool: 'setLights' }) + }) + + it('refuses and notifies when the client lacks the scope', async () => { + const { guardedLights, notify, audit } = setup({ + scopes: { setLights: 'control' }, + }) + const reader: ClientRecord = { id: 'bob', tokenHash: 'y', scopes: ['read'] } + await expect( + guardedLights!.execute!({ room: 'den', on: true }, contextFor(reader)), + ).rejects.toMatchObject({ code: 'forbidden_scope' }) + expect(notify.events).toContainEqual({ + kind: 'forbidden_scope', + client: 'bob', + tool: 'setLights', + }) + expect(audit.entries.at(-1)).toMatchObject({ outcome: 'denied' }) + }) +}) + +describe('guardTools — target allowlist', () => { + it('refuses a target not in the client allowlist', async () => { + const { guardedLights } = setup({ targetParam: { setLights: 'room' } }) + const scoped: ClientRecord = { + id: 'kid', + tokenHash: 'z', + scopes: [], + targets: ['living-room'], + } + await expect( + guardedLights!.execute!({ room: 'bedroom', on: true }, contextFor(scoped)), + ).rejects.toMatchObject({ code: 'forbidden_scope' }) + // An allowed target runs. + await expect( + guardedLights!.execute!( + { room: 'living-room', on: true }, + contextFor(scoped), + ), + ).resolves.toEqual({ room: 'living-room', on: true }) + }) +}) + +describe('guardTools — two-phase approval', () => { + it('returns a proposal instead of acting, then confirms', async () => { + const { guardedMovie, approvals, notify, audit } = setup({ + approve: ['buyMovie'], + }) + const envelope = (await guardedMovie!.execute!( + { movieId: 'tt1' }, + contextFor(control), + )) as ApprovalRequired + expect(envelope).toMatchObject({ + status: 'approval_required', + proposalId: 'prop-1', + }) + expect(notify.events).toContainEqual({ + kind: 'approval_pending', + proposalId: 'prop-1', + summary: 'buyMovie:{"movieId":"tt1"}', + }) + + const confirm = createConfirmTool({ approvals, audit }) + const confirmed = await confirm.execute!( + { proposalId: 'prop-1' }, + contextFor(control), + ) + expect(confirmed).toEqual({ confirmed: true, result: { bought: 'tt1' } }) + }) + + it('refuses an unauthenticated call', async () => { + const { guardedLights } = setup({}) + await expect( + guardedLights!.execute!({ room: 'den', on: true }, undefined), + ).rejects.toMatchObject({ code: 'auth_failure' }) + }) +}) diff --git a/packages/ai-secure-mcp/tests/notifier.test.ts b/packages/ai-secure-mcp/tests/notifier.test.ts new file mode 100644 index 0000000000..f7cc63797b --- /dev/null +++ b/packages/ai-secure-mcp/tests/notifier.test.ts @@ -0,0 +1,74 @@ +import { describe, expect, it, vi } from 'vitest' +import { + debounceNotifier, + describeEvent, + ntfyNotifier, + silentNotifier, +} from '../src/notifier' +import type { SecurityEvent, SecurityNotifier } from '../src/types' + +describe('describeEvent', () => { + it('summarizes without leaking structure', () => { + expect(describeEvent({ kind: 'rate_limited', client: 'bob' })).toContain( + 'bob', + ) + expect( + describeEvent({ kind: 'egress_denied', origin: 'evil.test' }), + ).toContain('evil.test') + }) +}) + +describe('ntfyNotifier', () => { + it('posts the summary to the topic and never throws on failure', async () => { + const fetchImpl = vi.fn( + async (_url: string, _init?: RequestInit) => new Response('ok'), + ) + const n = ntfyNotifier({ topic: 'my-topic', priority: 5, fetch: fetchImpl }) + await n.notify({ kind: 'auth_failure', client: 'x' }) + expect(fetchImpl).toHaveBeenCalledOnce() + const [url, init] = fetchImpl.mock.calls[0]! + expect(url).toBe('https://ntfy.sh/my-topic') + expect(String(init?.body)).toContain('x') + + const boom = ntfyNotifier({ + topic: 't', + fetch: async () => { + throw new Error('down') + }, + }) + await expect(boom.notify({ kind: 'rate_limited', client: 'y' })).resolves.toBeUndefined() + }) +}) + +describe('debounceNotifier', () => { + it('suppresses repeats of the same kind+client within the window', async () => { + let calls = 0 + const inner: SecurityNotifier = { notify: async () => { calls += 1 } } + let t = 0 + const n = debounceNotifier(inner, 1000, () => t) + const ev: SecurityEvent = { kind: 'auth_failure', client: 'a' } + await n.notify(ev) + await n.notify(ev) + expect(calls).toBe(1) + t = 1000 + await n.notify(ev) + expect(calls).toBe(2) + }) + + it('does not suppress different clients', async () => { + let calls = 0 + const inner: SecurityNotifier = { notify: async () => { calls += 1 } } + const n = debounceNotifier(inner, 1000, () => 0) + await n.notify({ kind: 'forbidden_scope', client: 'a', tool: 't' }) + await n.notify({ kind: 'forbidden_scope', client: 'b', tool: 't' }) + expect(calls).toBe(2) + }) +}) + +describe('silentNotifier', () => { + it('does nothing', async () => { + await expect( + silentNotifier().notify({ kind: 'rate_limited', client: 'z' }), + ).resolves.toBeUndefined() + }) +}) diff --git a/packages/ai-secure-mcp/tests/rate-limit.test.ts b/packages/ai-secure-mcp/tests/rate-limit.test.ts new file mode 100644 index 0000000000..0f6a4a84fc --- /dev/null +++ b/packages/ai-secure-mcp/tests/rate-limit.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from 'vitest' +import { createRateLimiter } from '../src/rate-limit' + +describe('createRateLimiter', () => { + it('allows up to the limit, then refuses, then recovers', () => { + let t = 0 + const rl = createRateLimiter({ limit: 2, windowMs: 1000, now: () => t }) + expect(rl.allow('a')).toBe(true) + expect(rl.allow('a')).toBe(true) + expect(rl.allow('a')).toBe(false) + // Window slides: the first two calls age out. + t = 1001 + expect(rl.allow('a')).toBe(true) + }) + + it('tracks clients independently', () => { + const rl = createRateLimiter({ limit: 1, windowMs: 1000, now: () => 0 }) + expect(rl.allow('a')).toBe(true) + expect(rl.allow('b')).toBe(true) + expect(rl.allow('a')).toBe(false) + }) +}) diff --git a/packages/ai-secure-mcp/tests/server.test.ts b/packages/ai-secure-mcp/tests/server.test.ts new file mode 100644 index 0000000000..d050b1c901 --- /dev/null +++ b/packages/ai-secure-mcp/tests/server.test.ts @@ -0,0 +1,93 @@ +import { toolDefinition } from '@tanstack/ai' +import { z } from 'zod' +import { describe, expect, it } from 'vitest' +import { hashToken } from '../src/auth' +import { createSecureMcpServer } from '../src/server' +import type { ClientRecord } from '../src/types' + +const ping = toolDefinition({ + name: 'ping', + description: 'Health ping', + inputSchema: z.object({}), +}).server(async () => ({ pong: true })) + +const alice: ClientRecord = { + id: 'alice', + tokenHash: hashToken('alice-token'), + scopes: ['read'], +} + +function base() { + return { + name: 'home', + version: '1.0.0', + tools: [ping], + clients: [alice], + egress: ['https://api.hue.local'], + audit: false as const, + } +} + +function mcpRequest(token?: string) { + const headers: Record = { 'content-type': 'application/json' } + if (token !== undefined) headers.authorization = `Bearer ${token}` + return new Request('https://mcp.local/', { + method: 'POST', + headers, + body: JSON.stringify({ + jsonrpc: '2.0', + id: 1, + method: 'tools/list', + params: {}, + }), + }) +} + +describe('createSecureMcpServer — auth pipeline', () => { + it('returns 401 with no token', async () => { + const server = createSecureMcpServer(base()) + const res = await server.fetch(mcpRequest()) + expect(res.status).toBe(401) + expect(res.headers.get('www-authenticate')).toBe('Bearer') + }) + + it('returns 401 for a bad token', async () => { + const server = createSecureMcpServer(base()) + expect((await server.fetch(mcpRequest('wrong'))).status).toBe(401) + }) + + it('does not 401 a valid token (request reaches the inner server)', async () => { + const server = createSecureMcpServer(base()) + const res = await server.fetch(mcpRequest('alice-token')) + expect(res.status).not.toBe(401) + }) + + it('rate limits a client after the configured number of calls', async () => { + const server = createSecureMcpServer({ + ...base(), + rateLimit: { limit: 1, windowMs: 60_000 }, + }) + expect((await server.fetch(mcpRequest('alice-token'))).status).not.toBe(429) + expect((await server.fetch(mcpRequest('alice-token'))).status).toBe(429) + }) +}) + +describe('createSecureMcpServer — go-live safety', () => { + it('computes the preflight from the config', () => { + const server = createSecureMcpServer(base()) + // audit off + silent notifier => not ready for public exposure. + expect(server.preflight.ok).toBe(false) + expect(server.preflight.problems.join(' ')).toMatch(/audit/) + }) + + it('refuses to build a public funnel while the preflight fails', () => { + expect(() => + createSecureMcpServer({ ...base(), funnel: { port: 8787, public: true } }), + ).toThrow(/Refusing to expose a public funnel/) + }) + + it('exposes the tailscale command when funnel is set', () => { + const server = createSecureMcpServer({ ...base(), funnel: { port: 8787 } }) + expect(server.tailscale?.command).toContain('tailscale serve') + }) +}) diff --git a/packages/ai-secure-mcp/tsconfig.json b/packages/ai-secure-mcp/tsconfig.json new file mode 100644 index 0000000000..c38689f4ea --- /dev/null +++ b/packages/ai-secure-mcp/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": ["src", "tests"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/ai-secure-mcp/vite.config.ts b/packages/ai-secure-mcp/vite.config.ts new file mode 100644 index 0000000000..68a4c83533 --- /dev/null +++ b/packages/ai-secure-mcp/vite.config.ts @@ -0,0 +1,36 @@ +import { defineConfig, mergeConfig } from 'vitest/config' +import { tanstackViteConfig } from '@tanstack/vite-config' +import packageJson from './package.json' + +const config = defineConfig({ + test: { + name: packageJson.name, + dir: './', + watch: false, + globals: true, + environment: 'node', + include: ['src/**/*.test.ts', 'tests/**/*.test.ts'], + coverage: { + provider: 'v8', + reporter: ['text', 'json', 'html', 'lcov'], + exclude: [ + 'node_modules/', + 'dist/', + 'tests/', + '**/*.test.ts', + '**/*.config.ts', + '**/types.ts', + ], + include: ['src/**/*.ts'], + }, + }, +}) + +export default mergeConfig( + config, + tanstackViteConfig({ + entry: ['./src/index.ts'], + srcDir: './src', + cjs: false, + }), +) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6c952bda18..44af541967 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3815,6 +3815,25 @@ importers: specifier: 4.1.12 version: 4.1.12(vitest@4.1.12) + packages/ai-secure-mcp: + dependencies: + '@modelcontextprotocol/server': + specifier: ^2.0.0 + version: 2.1.0 + '@tanstack/ai-mcp': + specifier: workspace:^ + version: link:../ai-mcp + devDependencies: + '@tanstack/ai': + specifier: workspace:* + version: link:../ai + '@vitest/coverage-v8': + specifier: 4.1.10 + version: 4.1.10(vitest@4.1.11) + zod: + specifier: ^4.2.0 + version: 4.6.5 + packages/ai-skills: dependencies: '@tanstack/ai': From 79ef3121c57156497cd53f3fbb01db1b90d8332d Mon Sep 17 00:00:00 2001 From: Jack Herrington Date: Thu, 19 Nov 2026 14:41:48 -0800 Subject: [PATCH 03/14] fix(ai-secure-mcp): address CodeRabbit review + unblock CI Rebase onto main and resolve the broken lockfile that failed every CI check: pin @vitest/coverage-v8 to 4.1.12 (was 4.1.10) in ai-secure-mcp, ai-isolate-daytona, and ai-isolate-e2b, and regenerate pnpm-lock.yaml so --frozen-lockfile installs again. CodeRabbit fixes: - egress: combine the caller's AbortSignal with the timeout (AbortSignal.any) instead of replacing init.signal, honor an already-aborted caller signal, and keep the deadline armed while the response body streams. - approval: prune expired proposals on propose/pendingCount and bound the pending map (maxPending) so unconfirmed proposals cannot leak closures. - audit: drop free-text `query`/`q` from the KEEP allowlist so query values are redacted; initialize the log lazily on first record so a prune/write failure surfaces to the caller instead of an unhandled rejection. - auth: accept case-insensitive Bearer scheme and multiple separator spaces. - clients-file: reject a malformed `targets` or `expiresAt` instead of silently dropping the restriction (which would widen token reach / drop expiry). - guard: audit both outcomes of a confirmed approved run; drop outputSchema on approval-gated tools so the approval_required envelope is not rejected by the MCP output-schema check. - notifier/server: add safeNotifier and wrap the notifier so a custom notify() that rejects cannot become an unhandled rejection on any fire-and-forget call site. - docs: describe egress as an opt-in helper, not an enforced network boundary (README, changeset, egress/guard doc comments); document the new @tanstack/ai-isolate peer in the isolate-driver READMEs. Add/extend unit tests for all behavior changes (approval pruning + bound, audit query redaction + lazy-init failure, bearer parsing, clients-file validation, confirmed-run error audit, outputSchema stripping, egress signal combination). Co-Authored-By: Claude Opus 4.8 (1M context) --- .changeset/add-ai-secure-mcp.md | 2 +- packages/ai-isolate-daytona/README.md | 2 +- packages/ai-isolate-e2b/README.md | 2 +- packages/ai-isolate-node/README.md | 5 +- packages/ai-isolate-quickjs/README.md | 5 +- packages/ai-secure-mcp/README.md | 32 +++++--- packages/ai-secure-mcp/package.json | 2 +- packages/ai-secure-mcp/src/approval.ts | 25 ++++++- packages/ai-secure-mcp/src/audit.ts | 27 ++++--- packages/ai-secure-mcp/src/auth.ts | 8 +- packages/ai-secure-mcp/src/clients-file.ts | 32 ++++++-- packages/ai-secure-mcp/src/deploy.ts | 8 +- packages/ai-secure-mcp/src/egress.ts | 46 +++++++++--- packages/ai-secure-mcp/src/guard.ts | 68 +++++++++++++++-- packages/ai-secure-mcp/src/index.ts | 1 + packages/ai-secure-mcp/src/notifier.ts | 19 +++++ packages/ai-secure-mcp/src/server.ts | 12 ++- packages/ai-secure-mcp/tests/approval.test.ts | 28 +++++++ packages/ai-secure-mcp/tests/audit.test.ts | 17 ++++- packages/ai-secure-mcp/tests/auth.test.ts | 14 +++- .../ai-secure-mcp/tests/clients-file.test.ts | 73 +++++++++++++++++++ packages/ai-secure-mcp/tests/egress.test.ts | 31 ++++++++ packages/ai-secure-mcp/tests/guard.test.ts | 66 ++++++++++++++++- packages/ai-secure-mcp/tests/notifier.test.ts | 16 +++- packages/ai-secure-mcp/tests/server.test.ts | 5 +- pnpm-lock.yaml | 52 ++++++------- 26 files changed, 494 insertions(+), 104 deletions(-) create mode 100644 packages/ai-secure-mcp/tests/clients-file.test.ts diff --git a/.changeset/add-ai-secure-mcp.md b/.changeset/add-ai-secure-mcp.md index 9237a35877..71f0a11659 100644 --- a/.changeset/add-ai-secure-mcp.md +++ b/.changeset/add-ai-secure-mcp.md @@ -2,4 +2,4 @@ '@tanstack/ai-secure-mcp': minor --- -Add `@tanstack/ai-secure-mcp`, a security envelope around `createMCPServer` for self-hosting an MCP server on the internet. `createSecureMcpServer` wraps your tools with hashed-token bearer auth, scopes and a per-client target allowlist, deny-by-default egress (no generic `fetch`), a per-client sliding-window rate limit, a redacted append-only JSONL audit log, a pluggable tripwire notifier (`ntfyNotifier`, `webhookNotifier`, `silentNotifier`), and two-phase propose/confirm approval. A go-live preflight refuses a public Tailscale funnel while a secure default is off (unhashed token, open egress, audit or notifier off). +Add `@tanstack/ai-secure-mcp`, a security envelope around `createMCPServer` for self-hosting an MCP server on the internet. `createSecureMcpServer` wraps your tools with hashed-token bearer auth, scopes and a per-client target allowlist, a deny-by-default egress helper a tool opts into (it is not an enforced network boundary — a tool that calls global `fetch` still reaches the network), a per-client sliding-window rate limit, a redacted append-only JSONL audit log, a pluggable tripwire notifier (`ntfyNotifier`, `webhookNotifier`, `silentNotifier`), and two-phase propose/confirm approval. A go-live preflight refuses a public Tailscale funnel while a secure default is off (unhashed token, open egress, audit or notifier off). diff --git a/packages/ai-isolate-daytona/README.md b/packages/ai-isolate-daytona/README.md index 250a8c39f1..42a6c05479 100644 --- a/packages/ai-isolate-daytona/README.md +++ b/packages/ai-isolate-daytona/README.md @@ -27,7 +27,7 @@ This package runs generated JavaScript or TypeScript in a caller-provided Dayton ## Installation ```bash -pnpm add @tanstack/ai-isolate-daytona @tanstack/ai-code-mode +pnpm add @tanstack/ai-isolate-daytona @tanstack/ai-isolate @tanstack/ai-code-mode ``` If you use the official Daytona SDK to create sandboxes, install it in your app too: diff --git a/packages/ai-isolate-e2b/README.md b/packages/ai-isolate-e2b/README.md index 60283b54fd..2c08cdd280 100644 --- a/packages/ai-isolate-e2b/README.md +++ b/packages/ai-isolate-e2b/README.md @@ -27,7 +27,7 @@ Run the TypeScript that the model writes in an E2B sandbox, while your tools sta ## Installation ```bash -pnpm add @tanstack/ai-isolate-e2b @tanstack/ai-code-mode e2b +pnpm add @tanstack/ai-isolate-e2b @tanstack/ai-isolate e2b ``` ## Usage diff --git a/packages/ai-isolate-node/README.md b/packages/ai-isolate-node/README.md index db03e2ce8d..1c913751c9 100644 --- a/packages/ai-isolate-node/README.md +++ b/packages/ai-isolate-node/README.md @@ -31,9 +31,12 @@ Node.js V8 isolate driver for TanStack AI Code Mode. Uses [`isolated-vm`](https: ## Installation ```bash -pnpm add @tanstack/ai-isolate-node +pnpm add @tanstack/ai-isolate-node @tanstack/ai-isolate ``` +`@tanstack/ai-isolate` is a peer dependency. A package manager that does not +auto-install peers needs it listed explicitly. + ## Usage ```typescript diff --git a/packages/ai-isolate-quickjs/README.md b/packages/ai-isolate-quickjs/README.md index 99099c309f..ae3b66f8bf 100644 --- a/packages/ai-isolate-quickjs/README.md +++ b/packages/ai-isolate-quickjs/README.md @@ -25,9 +25,12 @@ QuickJS WASM driver for TanStack AI Code Mode. Runs everywhere — Node.js, brow ## Installation ```bash -pnpm add @tanstack/ai-isolate-quickjs +pnpm add @tanstack/ai-isolate-quickjs @tanstack/ai-isolate ``` +`@tanstack/ai-isolate` is a peer dependency. A package manager that does not +auto-install peers needs it listed explicitly, or the driver fails to load. + ## Usage ```typescript diff --git a/packages/ai-secure-mcp/README.md b/packages/ai-secure-mcp/README.md index cc30a3a0aa..856966991c 100644 --- a/packages/ai-secure-mcp/README.md +++ b/packages/ai-secure-mcp/README.md @@ -27,7 +27,7 @@ It wraps your server with: - **Hashed-token auth** — bearer tokens stored as SHA-256 hashes, constant-time compare. - **Scopes and a target allowlist** — a token holds scopes; a scope can be narrowed to named resources. -- **Deny-by-default egress** — one allowlisted `egress` capability, no generic `fetch`. +- **Deny-by-default egress helper** — one allowlisted `egress` capability a tool uses on purpose. It is not an enforced network boundary: a tool that calls global `fetch` still reaches the network. For enforced isolation, run the server behind a separate execution or network boundary. - **Rate limits** — a per-client sliding window. - **A redacted audit log** — append-only JSONL, args redacted to id-like fields, no secrets. - **A tripwire notifier** — push a signal to your phone when someone pokes at the server. @@ -83,8 +83,12 @@ the command to expose the server when you pass `funnel`. ## Reaching the network from a tool -A tool receives the `egress` capability on `ctx.context`. It is the only way to -the network, and it refuses any origin not on the allowlist. +A tool receives the `egress` capability on `ctx.context`. A tool must use it on +purpose; it then refuses any origin not on the allowlist. It is not an enforced +boundary: a tool that calls global `fetch` directly bypasses `egress` and its +allowlist. Write tools to reach the network only through `ctx.context.egress`, +and run the server behind a separate execution or network boundary when you need +enforced confinement. ```typescript import { toolDefinition } from '@tanstack/ai' @@ -116,14 +120,20 @@ so a crash cannot leave a ghost approval. ## Secure defaults -| Concern | Default | Footgun it prevents | -| --- | --- | --- | -| Egress | deny-by-default allowlist | a tool exfiltrating data | -| Generic HTTP | not injectable | SSRF through a "helpful" tool | -| Tokens | hash-only, constant-time | replay from a leaked store | -| Secrets | never in the audit log or a notification | prompt/response exfiltration | -| Approval state | in memory, fail-closed on restart | a ghost approval after a crash | -| Exposure | tailnet-only unless you opt into a public funnel | accidental internet | +| Concern | Default | Footgun it prevents | +| -------------- | ------------------------------------------------ | ------------------------------------------------------------------------------ | +| Egress helper | deny-by-default allowlist | a tool exfiltrating data _when it uses `ctx.context.egress`_ | +| Generic HTTP | not injected into the context | SSRF through a "helpful" tool _that reaches the network only through `egress`_ | +| Tokens | hash-only, constant-time | replay from a leaked store | +| Secrets | never in the audit log or a notification | prompt/response exfiltration | +| Approval state | in memory, fail-closed on restart | a ghost approval after a crash | +| Exposure | tailnet-only unless you opt into a public funnel | accidental internet | + +The egress allowlist is a helper, not an enforced boundary. It stops +exfiltration and SSRF only for a tool that reaches the network through +`ctx.context.egress`; a tool that calls global `fetch` bypasses it. Enforced +network confinement needs a separate execution or network boundary around the +server. The preflight refuses a public funnel while a token is unhashed, egress is open, or the audit log or notifier is off. The funnel URL is not a secret: auth stands diff --git a/packages/ai-secure-mcp/package.json b/packages/ai-secure-mcp/package.json index 76611ebf5e..2cf8f458ed 100644 --- a/packages/ai-secure-mcp/package.json +++ b/packages/ai-secure-mcp/package.json @@ -67,7 +67,7 @@ }, "devDependencies": { "@tanstack/ai": "workspace:*", - "@vitest/coverage-v8": "4.1.10", + "@vitest/coverage-v8": "4.1.12", "zod": "^4.2.0" } } diff --git a/packages/ai-secure-mcp/src/approval.ts b/packages/ai-secure-mcp/src/approval.ts index f94ffa64a9..500a8842cf 100644 --- a/packages/ai-secure-mcp/src/approval.ts +++ b/packages/ai-secure-mcp/src/approval.ts @@ -38,18 +38,38 @@ export interface ApprovalStore { export function createApprovalStore(options?: { /** How long a proposal stays valid, 300000 ms (5 minutes) by default. */ ttlMs?: number + /** The most pending proposals to hold at once, 1000 by default. */ + maxPending?: number /** A clock in ms, for tests. */ now?: () => number /** An id source, for tests. */ newId?: () => string }): ApprovalStore { const ttlMs = options?.ttlMs ?? 300_000 + const maxPending = options?.maxPending ?? 1000 const now = options?.now ?? (() => Date.now()) const newId = options?.newId ?? (() => randomUUID()) const proposals = new Map() + // Drop every proposal past its expiry. Called on each store operation so an + // unconfirmed proposal cannot pin its `run` closure (args, context) forever. + const pruneExpired = () => { + const at = now() + for (const [id, proposal] of proposals) { + if (at >= proposal.expiresAt) proposals.delete(id) + } + } + return { propose: ({ owner, summary, run }) => { + pruneExpired() + // Bound the map even when nothing has expired: evict the oldest pending + // proposal (Map preserves insertion order) so a flood cannot grow it. + while (proposals.size >= maxPending) { + const oldest = proposals.keys().next().value + if (oldest === undefined) break + proposals.delete(oldest) + } const proposalId = newId() const expiresAt = now() + ttlMs proposals.set(proposalId, { owner, summary, run, expiresAt }) @@ -75,6 +95,9 @@ export function createApprovalStore(options?: { return proposal.run() }, - pendingCount: () => proposals.size, + pendingCount: () => { + pruneExpired() + return proposals.size + }, } } diff --git a/packages/ai-secure-mcp/src/audit.ts b/packages/ai-secure-mcp/src/audit.ts index 61810259df..f1be9eb2a9 100644 --- a/packages/ai-secure-mcp/src/audit.ts +++ b/packages/ai-secure-mcp/src/audit.ts @@ -18,15 +18,19 @@ export interface AuditEntry { } /** - * Keeps only id-like and query-like fields; everything else is redacted. The - * match is a suffix, so camelCase (`movieId`) and snake_case (`movie_id`) both - * count. + * Keeps only id-like fields; everything else is redacted. The match is a + * suffix, so camelCase (`movieId`) and snake_case (`movie_id`) both count. + * + * Free-text fields such as `query`/`q` are intentionally excluded: a query + * string is not id-like and can carry a secret (for example + * `ALTER USER alice PASSWORD 'x'`). Retain one only through an explicit + * per-tool allowlist that documents its safe content. */ -const KEEP = /(id|ids|query|q|name|title|kind|type|scope|origin)$/i +const KEEP = /(id|ids|name|title|kind|type|scope|origin)$/i /** - * Redacts tool input to id-like and query-like fields. A non-object becomes a - * type tag. This keeps a useful trail without storing a secret value. + * Redacts tool input to id-like fields. A non-object becomes a type tag. This + * keeps a useful trail without storing a secret value. */ export function redactArgs(args: unknown): unknown { if (args === null || typeof args !== 'object') { @@ -61,8 +65,7 @@ export function createAuditLog(options: { now?: () => number }): AuditLog { const now = options.now ?? (() => Date.now()) - // Prune and ensure the directory on first write, once. - const ready = (async () => { + const init = async () => { await mkdir(dirname(options.path), { recursive: true }).catch(() => {}) if (options.retentionDays === undefined) return const cutoff = now() - options.retentionDays * 86_400_000 @@ -84,10 +87,16 @@ export function createAuditLog(options: { } }) await writeFile(options.path, kept.length ? kept.join('\n') + '\n' : '') - })() + } + // Prune and ensure the directory once, lazily on the first `record`. Running + // init eagerly here would leave its rejection unhandled until a later + // `record` awaits it, which can crash the process on Node's default handler. + // A failure is preserved and surfaced to the caller of `record`. + let ready: Promise | undefined return { record: async (entry) => { + ready ??= init() await ready const line = JSON.stringify({ time: now(), diff --git a/packages/ai-secure-mcp/src/auth.ts b/packages/ai-secure-mcp/src/auth.ts index 4126474540..0c7d2ec128 100644 --- a/packages/ai-secure-mcp/src/auth.ts +++ b/packages/ai-secure-mcp/src/auth.ts @@ -22,10 +22,14 @@ export function constantTimeEqual(a: string, b: string): boolean { return timingSafeEqual(left, right) } -/** Reads the bearer token from an `Authorization` header value. */ +/** + * Reads the bearer token from an `Authorization` header value. The scheme name + * is case-insensitive (RFC 7235) and one or more spaces may separate it from + * the token (RFC 6750), so `bearer xyz` and `Bearer xyz` both yield `xyz`. + */ export function bearerToken(header: string | null): string | undefined { if (header === null) return undefined - const match = /^Bearer (.+)$/.exec(header.trim()) + const match = /^Bearer +(.+)$/i.exec(header.trim()) return match?.[1] } diff --git a/packages/ai-secure-mcp/src/clients-file.ts b/packages/ai-secure-mcp/src/clients-file.ts index 9d2e9bded6..6177c4c208 100644 --- a/packages/ai-secure-mcp/src/clients-file.ts +++ b/packages/ai-secure-mcp/src/clients-file.ts @@ -23,12 +23,34 @@ function toClient(value: unknown, index: number): ClientRecord { tokenHash: value.tokenHash, scopes: value.scopes.filter((s): s is string => typeof s === 'string'), } - if (Array.isArray(value.targets)) { - client.targets = value.targets.filter( - (t): t is string => typeof t === 'string', - ) + // A present `targets` must be an array of strings. A malformed value is + // rejected, never silently dropped: dropping it would widen the token's reach + // to every target instead of the intended restriction. + if (value.targets !== undefined) { + if ( + !Array.isArray(value.targets) || + !value.targets.every((t) => typeof t === 'string') + ) { + throw new SecureMcpError( + 'invalid_input', + `Client at index ${index} has a "targets" that is not an array of strings.`, + ) + } + client.targets = value.targets } - if (typeof value.expiresAt === 'number') { + // A present `expiresAt` must be a finite number (Unix seconds). A malformed + // value is rejected, never silently dropped: dropping it would turn an + // intended expiry into a token that never expires. + if (value.expiresAt !== undefined) { + if ( + typeof value.expiresAt !== 'number' || + !Number.isFinite(value.expiresAt) + ) { + throw new SecureMcpError( + 'invalid_input', + `Client at index ${index} has an "expiresAt" that is not a finite number.`, + ) + } client.expiresAt = value.expiresAt } return client diff --git a/packages/ai-secure-mcp/src/deploy.ts b/packages/ai-secure-mcp/src/deploy.ts index e2b8cfa526..0b74ef7c56 100644 --- a/packages/ai-secure-mcp/src/deploy.ts +++ b/packages/ai-secure-mcp/src/deploy.ts @@ -57,10 +57,10 @@ export function preflight(input: PreflightInput): PreflightResult { * @param options.port - The local port the server listens on * @param options.public - Use Funnel (public) instead of Serve (tailnet-only) */ -export function tailscaleCommand(options: { - port: number - public?: boolean -}): { command: string; note: string } { +export function tailscaleCommand(options: { port: number; public?: boolean }): { + command: string + note: string +} { const target = `http://127.0.0.1:${options.port}` if (options.public === true) { return { diff --git a/packages/ai-secure-mcp/src/egress.ts b/packages/ai-secure-mcp/src/egress.ts index 81f51a1bca..786d49d84a 100644 --- a/packages/ai-secure-mcp/src/egress.ts +++ b/packages/ai-secure-mcp/src/egress.ts @@ -1,13 +1,12 @@ import { SecureMcpError } from './types' /** - * A guarded fetch. It reaches only an origin on the allowlist. There is no - * generic fetch: this is the single way a tool touches the network. + * A guarded fetch. It reaches only an origin on the allowlist. It is a helper a + * tool opts into, not an enforced boundary: a tool that calls global `fetch` + * directly bypasses it. For enforced confinement, run the server behind a + * separate execution or network boundary. */ -export type EgressFetch = ( - url: string, - init?: RequestInit, -) => Promise +export type EgressFetch = (url: string, init?: RequestInit) => Promise /** * Builds a deny-by-default egress function. @@ -57,21 +56,50 @@ export function createEgress(options: { ) } const controller = new AbortController() + // The deadline stays armed until the caller's combined signal settles, so it + // still aborts a slow body stream: `fetch` resolves on headers, not on body + // completion. The timer fires at most once and is cleared on cancellation. const timer = setTimeout(() => controller.abort(), timeoutMs) + // Combine the caller's signal with the timeout so caller cancellation still + // aborts the request and an already-aborted caller signal is honored, + // instead of replacing `init.signal` with a fresh active one. + const signal = combineSignals(init?.signal ?? undefined, controller.signal) + // Clear the timer once the operation can no longer time out: either the + // deadline fired, or the caller aborted, or the caller finished reading and + // dropped its reference (GC'd timer). Attach cleanup to the combined signal. + if (signal.aborted) { + clearTimeout(timer) + throw new SecureMcpError( + 'backend_unavailable', + `Egress to ${origin} failed: ${signal.reason instanceof Error ? signal.reason.message : 'aborted'}`, + ) + } + signal.addEventListener('abort', () => clearTimeout(timer), { once: true }) try { return await fetchImpl(url, { ...init, redirect: 'error', - signal: controller.signal, + signal, }) } catch (error) { + clearTimeout(timer) const detail = error instanceof Error ? error.message : 'request failed' throw new SecureMcpError( 'backend_unavailable', `Egress to ${origin} failed: ${detail}`, ) - } finally { - clearTimeout(timer) } } } + +/** Combines abort signals; aborts the result when any input aborts. */ +function combineSignals( + a: AbortSignal | undefined, + b: AbortSignal, +): AbortSignal { + if (a === undefined) return b + // `AbortSignal.any` is available on every runtime this package targets + // (Node 18.17+, modern browsers). It aborts as soon as either input aborts + // and carries the first abort reason. + return AbortSignal.any([a, b]) +} diff --git a/packages/ai-secure-mcp/src/guard.ts b/packages/ai-secure-mcp/src/guard.ts index 434a82b52a..af544fd6f8 100644 --- a/packages/ai-secure-mcp/src/guard.ts +++ b/packages/ai-secure-mcp/src/guard.ts @@ -8,8 +8,10 @@ import type { EgressFetch } from './egress' import type { AccessPolicy, ClientRecord, SecurityNotifier } from './types' /** - * The per-request values the envelope injects into `ctx.context`. A tool reads - * `ctx.context.egress` to reach the network. The guard reads `secure` to know + * The per-request values the envelope injects into `ctx.context`. A tool should + * reach the network only through `ctx.context.egress`, which refuses any origin + * off the allowlist. This is a helper, not an enforced boundary: a tool that + * calls global `fetch` directly bypasses it. The guard reads `secure` to know * the caller. */ export interface SecureRequestContext { @@ -36,7 +38,10 @@ function readClient( // Typed as present, but a misuse could still leave it out at runtime. const client = context?.context?.secure?.client if (client === undefined) { - throw new SecureMcpError('auth_failure', 'The request is not authenticated.') + throw new SecureMcpError( + 'auth_failure', + 'The request is not authenticated.', + ) } return client } @@ -60,14 +65,28 @@ export function guardTools( const scope = deps.policy.scopes?.[tool.name] if (scope !== undefined && !client.scopes.includes(scope)) { - return refuse(deps, client, tool.name, args, 'forbidden_scope', `This token does not hold the "${scope}" scope.`) + return refuse( + deps, + client, + tool.name, + args, + 'forbidden_scope', + `This token does not hold the "${scope}" scope.`, + ) } const targetField = deps.policy.targetParam?.[tool.name] if (targetField !== undefined && client.targets !== undefined) { const value = isRecord(args) ? args[targetField] : undefined if (!client.targets.includes(String(value))) { - return refuse(deps, client, tool.name, args, 'forbidden_scope', 'This token may not reach that target.') + return refuse( + deps, + client, + tool.name, + args, + 'forbidden_scope', + 'This token may not reach that target.', + ) } } @@ -76,7 +95,32 @@ export function guardTools( const envelope = deps.approvals.propose({ owner: client.id, summary, - run: async () => original?.(args, context), + // Audit both outcomes of the confirmed run. The proposal is consumed + // single-use before this runs, so a throw here would otherwise leave + // no execution record for the failed approved action. + run: async () => { + try { + const result = await original?.(args, context) + await deps.audit?.record({ + client: client.id, + event: 'tool_call', + tool: tool.name, + outcome: 'ok', + args, + }) + return result + } catch (error) { + await deps.audit?.record({ + client: client.id, + event: 'tool_call', + tool: tool.name, + outcome: 'error', + code: error instanceof SecureMcpError ? error.code : undefined, + args, + }) + throw error + } + }, }) await deps.audit?.record({ client: client.id, @@ -115,6 +159,14 @@ export function guardTools( throw error } } + // An approval-gated tool returns the `approval_required` envelope on the + // first call, not its own output shape. Keeping an `outputSchema` would make + // the MCP server reject that envelope as a schema mismatch, so the client + // would never receive the `proposalId` the confirm tool needs. Drop it. + if (deps.policy.approve?.includes(tool.name)) { + const { outputSchema: _outputSchema, ...rest } = tool + return { ...rest, execute } + } return { ...tool, execute } }) } @@ -152,7 +204,9 @@ export function createConfirmTool(deps: { description: 'Confirm a pending approval by its proposalId. Runs the proposed action.', inputSchema: z.object({ - proposalId: z.string().describe('The id from an approval_required reply.'), + proposalId: z + .string() + .describe('The id from an approval_required reply.'), }), }).server(async ({ proposalId }, context) => { const client = readClient(context) diff --git a/packages/ai-secure-mcp/src/index.ts b/packages/ai-secure-mcp/src/index.ts index 7441f1eb82..883d45fa37 100644 --- a/packages/ai-secure-mcp/src/index.ts +++ b/packages/ai-secure-mcp/src/index.ts @@ -27,6 +27,7 @@ export { ntfyNotifier, webhookNotifier, silentNotifier, + safeNotifier, debounceNotifier, describeEvent, } from './notifier' diff --git a/packages/ai-secure-mcp/src/notifier.ts b/packages/ai-secure-mcp/src/notifier.ts index 3477541eed..3090ce479a 100644 --- a/packages/ai-secure-mcp/src/notifier.ts +++ b/packages/ai-secure-mcp/src/notifier.ts @@ -27,6 +27,25 @@ export function silentNotifier(): SecurityNotifier { return { notify: async () => {} } } +/** + * Wraps a notifier so a rejected `notify` can never surface as an unhandled + * rejection. A notification is best-effort: a custom notifier that throws or + * rejects must not crash the request path, which on Node's default handler an + * unhandled rejection can do. Notification failures stay separate from the + * request's own outcome. + */ +export function safeNotifier(inner: SecurityNotifier): SecurityNotifier { + return { + notify: async (event) => { + try { + await inner.notify(event) + } catch { + // swallow: a down notifier must not break the request path. + } + }, + } +} + /** * A notifier that pushes to an [ntfy](https://ntfy.sh) topic. Zero infra: the * body is the event summary. No secret or token is ever in the body. diff --git a/packages/ai-secure-mcp/src/server.ts b/packages/ai-secure-mcp/src/server.ts index 349b89ab5d..168cd2ae6e 100644 --- a/packages/ai-secure-mcp/src/server.ts +++ b/packages/ai-secure-mcp/src/server.ts @@ -4,7 +4,7 @@ import { createApprovalStore } from './approval' import { createAuditLog } from './audit' import { createEgress } from './egress' import { createConfirmTool, guardTools } from './guard' -import { silentNotifier } from './notifier' +import { safeNotifier, silentNotifier } from './notifier' import { createRateLimiter } from './rate-limit' import { preflight, tailscaleCommand } from './deploy' import { SecureMcpError } from './types' @@ -13,11 +13,7 @@ import type { AnyServerTool } from '@tanstack/ai' import type { SampleRequest } from '@tanstack/ai-mcp/server' import type { AuditLog } from './audit' import type { PreflightResult } from './deploy' -import type { - AccessPolicy, - ClientRecord, - SecurityNotifier, -} from './types' +import type { AccessPolicy, ClientRecord, SecurityNotifier } from './types' /** Config for {@link createSecureMcpServer}. */ export interface SecureMcpConfig { @@ -80,7 +76,9 @@ function jsonError(status: number, code: string, headers?: HeadersInit) { export function createSecureMcpServer( config: SecureMcpConfig, ): SecureMcpServer { - const notify = config.notify ?? silentNotifier() + // Wrap the notifier so a custom `notify` that rejects cannot become an + // unhandled rejection on any of the fire-and-forget (`void`) call sites. + const notify = safeNotifier(config.notify ?? silentNotifier()) const audit: AuditLog | undefined = config.audit === false || config.audit === undefined ? undefined diff --git a/packages/ai-secure-mcp/tests/approval.test.ts b/packages/ai-secure-mcp/tests/approval.test.ts index 545c11ee76..7dfe59ad79 100644 --- a/packages/ai-secure-mcp/tests/approval.test.ts +++ b/packages/ai-secure-mcp/tests/approval.test.ts @@ -61,4 +61,32 @@ describe('createApprovalStore', () => { }) expect(store.pendingCount()).toBe(0) }) + + it('prunes expired proposals without a confirm, so the map cannot grow', () => { + let t = 0 + const store = createApprovalStore({ + ttlMs: 100, + now: () => t, + newId: fixedIds(), + }) + store.propose({ owner: 'a', summary: 's', run: async () => 1 }) + store.propose({ owner: 'a', summary: 's', run: async () => 1 }) + expect(store.pendingCount()).toBe(2) + // Advance past the ttl. No one confirms the expired ids. + t = 101 + // pendingCount prunes, so the stale proposals and their closures are gone. + expect(store.pendingCount()).toBe(0) + // A later propose also prunes first, so it starts from a clean map. + store.propose({ owner: 'a', summary: 's', run: async () => 1 }) + expect(store.pendingCount()).toBe(1) + }) + + it('bounds the number of pending proposals', () => { + const store = createApprovalStore({ maxPending: 2, newId: fixedIds() }) + store.propose({ owner: 'a', summary: '1', run: async () => 1 }) + store.propose({ owner: 'a', summary: '2', run: async () => 2 }) + store.propose({ owner: 'a', summary: '3', run: async () => 3 }) + // The oldest was evicted to stay within the bound. + expect(store.pendingCount()).toBe(2) + }) }) diff --git a/packages/ai-secure-mcp/tests/audit.test.ts b/packages/ai-secure-mcp/tests/audit.test.ts index 68edc69898..75fa48ea54 100644 --- a/packages/ai-secure-mcp/tests/audit.test.ts +++ b/packages/ai-secure-mcp/tests/audit.test.ts @@ -5,12 +5,13 @@ import { describe, expect, it } from 'vitest' import { createAuditLog, redactArgs } from '../src/audit' describe('redactArgs', () => { - it('keeps id-like and query-like fields, redacts the rest', () => { + it('keeps id-like fields and redacts the rest, including free-text query', () => { expect( redactArgs({ movieId: 'tt123', query: 'dune', apiKey: 'secret', n: 5 }), ).toEqual({ movieId: 'tt123', - query: 'dune', + // `query` is free text and can carry a secret, so it is redacted. + query: '[redacted]', apiKey: '[redacted]', n: '[redacted]', }) @@ -66,4 +67,16 @@ describe('createAuditLog', () => { expect(text).toContain('"fresh"') expect(text).toContain('"new"') }) + + it('does not start init until the first record, so a failure cannot float', async () => { + const dir = await mkdtemp(join(tmpdir(), 'audit-')) + // A path whose parent is an existing file. mkdir is best-effort, but the + // append then rejects, and that rejection must reach the record() caller + // rather than surface as an unhandled rejection during construction. + const file = join(dir, 'a-file') + await writeFile(file, 'x') + const log = createAuditLog({ path: join(file, 'audit.jsonl') }) + // Construction did nothing; the first record triggers and surfaces the fault. + await expect(log.record({ event: 'x', outcome: 'ok' })).rejects.toThrow() + }) }) diff --git a/packages/ai-secure-mcp/tests/auth.test.ts b/packages/ai-secure-mcp/tests/auth.test.ts index f6b799f4a4..b312cfaae0 100644 --- a/packages/ai-secure-mcp/tests/auth.test.ts +++ b/packages/ai-secure-mcp/tests/auth.test.ts @@ -1,6 +1,11 @@ import { describe, expect, it } from 'vitest' import { SecureMcpError } from '../src/types' -import { bearerToken, constantTimeEqual, hashToken, verifyToken } from '../src/auth' +import { + bearerToken, + constantTimeEqual, + hashToken, + verifyToken, +} from '../src/auth' import type { ClientRecord } from '../src/types' const client: ClientRecord = { @@ -30,9 +35,12 @@ describe('constantTimeEqual', () => { }) describe('bearerToken', () => { - it('reads a Bearer token and ignores other shapes', () => { + it('reads a Bearer token across case and spacing, ignores other shapes', () => { expect(bearerToken('Bearer xyz')).toBe('xyz') - expect(bearerToken(' Bearer xyz ')).toBe(' xyz') + // The scheme is case-insensitive and allows extra separator spaces. + expect(bearerToken('bearer xyz')).toBe('xyz') + expect(bearerToken('Bearer xyz')).toBe('xyz') + expect(bearerToken(' Bearer xyz ')).toBe('xyz') expect(bearerToken('Basic xyz')).toBeUndefined() expect(bearerToken(null)).toBeUndefined() }) diff --git a/packages/ai-secure-mcp/tests/clients-file.test.ts b/packages/ai-secure-mcp/tests/clients-file.test.ts new file mode 100644 index 0000000000..566cfe269d --- /dev/null +++ b/packages/ai-secure-mcp/tests/clients-file.test.ts @@ -0,0 +1,73 @@ +import { mkdtemp, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { describe, expect, it } from 'vitest' +import { clientsFromFile } from '../src/clients-file' + +async function writeClients(value: unknown): Promise { + const dir = await mkdtemp(join(tmpdir(), 'clients-')) + const path = join(dir, 'clients.json') + await writeFile(path, JSON.stringify(value), 'utf8') + return path +} + +const base = { + id: 'alice', + tokenHash: 'a'.repeat(64), + scopes: ['read'], +} + +describe('clientsFromFile', () => { + it('reads a well-formed clients file', async () => { + const path = await writeClients([ + { ...base, targets: ['den'], expiresAt: 1700000000 }, + ]) + const clients = await clientsFromFile(path) + expect(clients).toEqual([ + { + id: 'alice', + tokenHash: 'a'.repeat(64), + scopes: ['read'], + targets: ['den'], + expiresAt: 1700000000, + }, + ]) + }) + + it('allows an absent targets and expiresAt', async () => { + const path = await writeClients([base]) + const [client] = await clientsFromFile(path) + expect(client?.targets).toBeUndefined() + expect(client?.expiresAt).toBeUndefined() + }) + + it('rejects a malformed targets instead of dropping the restriction', async () => { + const path = await writeClients([{ ...base, targets: 'den' }]) + await expect(clientsFromFile(path)).rejects.toMatchObject({ + code: 'invalid_input', + }) + }) + + it('rejects a targets array that holds a non-string', async () => { + const path = await writeClients([{ ...base, targets: ['den', 5] }]) + await expect(clientsFromFile(path)).rejects.toMatchObject({ + code: 'invalid_input', + }) + }) + + it('rejects a malformed expiresAt instead of dropping the expiry', async () => { + const path = await writeClients([{ ...base, expiresAt: '1700000000' }]) + await expect(clientsFromFile(path)).rejects.toMatchObject({ + code: 'invalid_input', + }) + }) + + it('rejects a non-finite expiresAt', async () => { + // JSON has no Infinity, so a non-finite value arrives as a string or null; + // both are non-number and rejected. Guard the finite check directly too. + const path = await writeClients([{ ...base, expiresAt: null }]) + await expect(clientsFromFile(path)).rejects.toMatchObject({ + code: 'invalid_input', + }) + }) +}) diff --git a/packages/ai-secure-mcp/tests/egress.test.ts b/packages/ai-secure-mcp/tests/egress.test.ts index d683049d22..985bd27c7a 100644 --- a/packages/ai-secure-mcp/tests/egress.test.ts +++ b/packages/ai-secure-mcp/tests/egress.test.ts @@ -46,4 +46,35 @@ describe('createEgress', () => { it('rejects a non-URL allowlist entry at build time', () => { expect(() => createEgress({ allow: ['not a url'] })).toThrow(SecureMcpError) }) + + it('honors a caller signal that is already aborted', async () => { + const fetchImpl = vi.fn(async () => new Response('body')) + const egress = createEgress({ + allow: ['https://api.hue.local'], + fetch: fetchImpl, + }) + await expect( + egress('https://api.hue.local/x', { signal: AbortSignal.abort() }), + ).rejects.toMatchObject({ code: 'backend_unavailable' }) + // The request never went out, because the caller had already cancelled. + expect(fetchImpl).not.toHaveBeenCalled() + }) + + it('passes a combined signal to fetch so caller cancellation reaches it', async () => { + let seen: AbortSignal | undefined + const egress = createEgress({ + allow: ['https://api.hue.local'], + fetch: async (_url, init) => { + seen = init?.signal ?? undefined + return new Response('body') + }, + }) + const controller = new AbortController() + await egress('https://api.hue.local/x', { signal: controller.signal }) + expect(seen).toBeInstanceOf(AbortSignal) + expect(seen?.aborted).toBe(false) + // A later caller abort propagates to the signal fetch received. + controller.abort() + expect(seen?.aborted).toBe(true) + }) }) diff --git a/packages/ai-secure-mcp/tests/guard.test.ts b/packages/ai-secure-mcp/tests/guard.test.ts index 49516c87e4..d255c81d9e 100644 --- a/packages/ai-secure-mcp/tests/guard.test.ts +++ b/packages/ai-secure-mcp/tests/guard.test.ts @@ -13,7 +13,9 @@ import type { SecurityNotifier, } from '../src/types' -function capturingNotifier(): SecurityNotifier & { events: Array } { +function capturingNotifier(): SecurityNotifier & { + events: Array +} { const events: Array = [] return { events, notify: async (event) => void events.push(event) } } @@ -71,7 +73,10 @@ describe('guardTools — scopes', () => { contextFor(control), ) expect(result).toEqual({ room: 'den', on: true }) - expect(audit.entries.at(-1)).toMatchObject({ outcome: 'ok', tool: 'setLights' }) + expect(audit.entries.at(-1)).toMatchObject({ + outcome: 'ok', + tool: 'setLights', + }) }) it('refuses and notifies when the client lacks the scope', async () => { @@ -101,7 +106,10 @@ describe('guardTools — target allowlist', () => { targets: ['living-room'], } await expect( - guardedLights!.execute!({ room: 'bedroom', on: true }, contextFor(scoped)), + guardedLights!.execute!( + { room: 'bedroom', on: true }, + contextFor(scoped), + ), ).rejects.toMatchObject({ code: 'forbidden_scope' }) // An allowed target runs. await expect( @@ -146,4 +154,56 @@ describe('guardTools — two-phase approval', () => { guardedLights!.execute!({ room: 'den', on: true }, undefined), ).rejects.toMatchObject({ code: 'auth_failure' }) }) + + it('audits a confirmed run that throws, then rethrows', async () => { + const failing = toolDefinition({ + name: 'buyMovie', + description: 'Buy a movie', + inputSchema: z.object({ movieId: z.string() }), + }).server(async () => { + throw new Error('backend down') + }) + const notify = capturingNotifier() + const audit = capturingAudit() + const approvals = createApprovalStore({ newId: () => 'prop-1' }) + const [guarded] = guardTools([failing], { + policy: { approve: ['buyMovie'] }, + approvals, + audit, + notify, + summarize: () => 's', + }) + await guarded!.execute!({ movieId: 'tt1' }, contextFor(control)) + const confirm = createConfirmTool({ approvals, audit }) + await expect( + confirm.execute!({ proposalId: 'prop-1' }, contextFor(control)), + ).rejects.toThrow('backend down') + // The failed approved action left an error record. + expect(audit.entries).toContainEqual( + expect.objectContaining({ + event: 'tool_call', + tool: 'buyMovie', + outcome: 'error', + }), + ) + }) + + it('drops the outputSchema on an approval-gated tool', () => { + const withSchema = toolDefinition({ + name: 'buyMovie', + description: 'Buy a movie', + inputSchema: z.object({ movieId: z.string() }), + outputSchema: z.object({ bought: z.string() }), + }).server(async ({ movieId }) => ({ bought: movieId })) + const [guarded] = guardTools([withSchema], { + policy: { approve: ['buyMovie'] }, + approvals: createApprovalStore(), + notify: capturingNotifier(), + summarize: () => 's', + }) + // The approval envelope does not match the tool's outputSchema, so the + // wrapped tool must not advertise one — otherwise the MCP server would + // reject the envelope and the client would never get the proposalId. + expect(guarded!.outputSchema).toBeUndefined() + }) }) diff --git a/packages/ai-secure-mcp/tests/notifier.test.ts b/packages/ai-secure-mcp/tests/notifier.test.ts index f7cc63797b..1c66064f8b 100644 --- a/packages/ai-secure-mcp/tests/notifier.test.ts +++ b/packages/ai-secure-mcp/tests/notifier.test.ts @@ -36,14 +36,20 @@ describe('ntfyNotifier', () => { throw new Error('down') }, }) - await expect(boom.notify({ kind: 'rate_limited', client: 'y' })).resolves.toBeUndefined() + await expect( + boom.notify({ kind: 'rate_limited', client: 'y' }), + ).resolves.toBeUndefined() }) }) describe('debounceNotifier', () => { it('suppresses repeats of the same kind+client within the window', async () => { let calls = 0 - const inner: SecurityNotifier = { notify: async () => { calls += 1 } } + const inner: SecurityNotifier = { + notify: async () => { + calls += 1 + }, + } let t = 0 const n = debounceNotifier(inner, 1000, () => t) const ev: SecurityEvent = { kind: 'auth_failure', client: 'a' } @@ -57,7 +63,11 @@ describe('debounceNotifier', () => { it('does not suppress different clients', async () => { let calls = 0 - const inner: SecurityNotifier = { notify: async () => { calls += 1 } } + const inner: SecurityNotifier = { + notify: async () => { + calls += 1 + }, + } const n = debounceNotifier(inner, 1000, () => 0) await n.notify({ kind: 'forbidden_scope', client: 'a', tool: 't' }) await n.notify({ kind: 'forbidden_scope', client: 'b', tool: 't' }) diff --git a/packages/ai-secure-mcp/tests/server.test.ts b/packages/ai-secure-mcp/tests/server.test.ts index d050b1c901..d2740f929c 100644 --- a/packages/ai-secure-mcp/tests/server.test.ts +++ b/packages/ai-secure-mcp/tests/server.test.ts @@ -82,7 +82,10 @@ describe('createSecureMcpServer — go-live safety', () => { it('refuses to build a public funnel while the preflight fails', () => { expect(() => - createSecureMcpServer({ ...base(), funnel: { port: 8787, public: true } }), + createSecureMcpServer({ + ...base(), + funnel: { port: 8787, public: true }, + }), ).toThrow(/Refusing to expose a public funnel/) }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 44af541967..8985b74329 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3828,8 +3828,8 @@ importers: specifier: workspace:* version: link:../ai '@vitest/coverage-v8': - specifier: 4.1.10 - version: 4.1.10(vitest@4.1.11) + specifier: 4.1.12 + version: 4.1.12(vitest@4.1.12) zod: specifier: ^4.2.0 version: 4.6.5 @@ -18572,12 +18572,6 @@ packages: peerDependencies: seroval: ^1.0 - seroval-plugins@1.6.7: - resolution: {integrity: sha512-4Nk35ttD3DTDJW4hgw5StsVAPeU6qnDFnULAouw6tQ7oLTV/ICXrWpsXo2EE52eSP2joUMazbVf52mFEcADqRw==} - engines: {node: '>=10'} - peerDependencies: - seroval: ^1.0 - seroval@1.6.12: resolution: {integrity: sha512-CqbIVfk/7GL3ITwZI55lcPbpQbjHZ2DD5cUj4iH7E9YsCfHNJV1mx7yNp86Z84w5IpmkZZS/2s5vPOWmVWSdQg==} engines: {node: '>=10'} @@ -24579,13 +24573,6 @@ snapshots: '@emnapi/runtime': 1.11.3 '@tybys/wasm-util': 0.9.0 - '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.0)(@emnapi/runtime@1.11.0)': - dependencies: - '@emnapi/core': 1.11.0 - '@emnapi/runtime': 1.11.0 - '@tybys/wasm-util': 0.10.3 - optional: true - '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)': dependencies: '@emnapi/core': 1.11.1 @@ -24607,6 +24594,13 @@ snapshots: '@tybys/wasm-util': 0.10.3 optional: true + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@1.11.0)(@emnapi/runtime@1.11.0)': + dependencies: + '@emnapi/core': 1.11.0 + '@emnapi/runtime': 1.11.0 + '@tybys/wasm-util': 0.10.3 + optional: true + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': dependencies: '@emnapi/core': 2.0.0-beta.2 @@ -25347,7 +25341,7 @@ snapshots: dependencies: '@emnapi/core': 1.11.0 '@emnapi/runtime': 1.11.0 - '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.0)(@emnapi/runtime@1.11.0) + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@1.11.0)(@emnapi/runtime@1.11.0) optional: true '@oxc-resolver/binding-win32-arm64-msvc@11.21.3': @@ -29309,8 +29303,8 @@ snapshots: dependencies: '@tanstack/history': 1.162.4 cookie-es: 3.1.1 - seroval: 1.6.7 - seroval-plugins: 1.6.7(seroval@1.6.7) + seroval: 1.6.12 + seroval-plugins: 1.6.12(seroval@1.6.12) '@tanstack/router-devtools-core@1.141.1(@tanstack/router-core@1.171.34)(csstype@3.2.3)(solid-js@1.9.19)': dependencies: @@ -30077,7 +30071,7 @@ snapshots: '@typescript-eslint/utils': 8.59.4(eslint@9.39.4(jiti@2.7.0))(typescript@7.0.2) '@typescript-eslint/visitor-keys': 8.59.4 eslint: 9.39.4(jiti@2.7.0) - ignore: 7.0.5 + ignore: 7.0.6 natural-compare: 1.4.0 ts-api-utils: 2.5.0(typescript@7.0.2) typescript: 7.0.2 @@ -31882,7 +31876,7 @@ snapshots: css-tree@3.2.1: dependencies: mdn-data: 2.27.1 - source-map-js: 1.2.1 + source-map-js: 1.2.2 css-what@6.2.2: {} @@ -34554,7 +34548,7 @@ snapshots: dependencies: '@babel/parser': 7.29.9 '@babel/types': 7.29.8 - source-map-js: 1.2.1 + source-map-js: 1.2.2 make-dir@2.1.0: dependencies: @@ -35375,9 +35369,9 @@ snapshots: jsonc-parser: 3.3.1 less: 4.6.6 ora: 9.4.0 - postcss: 8.5.28 - rolldown: 1.2.9 - rolldown-plugin-dts: 0.28.8(@volar/typescript@2.4.28)(oxc-resolver@11.21.3)(rolldown@1.2.9)(typescript@6.0.2) + postcss: 8.5.33 + rolldown: 1.2.19 + rolldown-plugin-dts: 0.28.8(@volar/typescript@2.4.28)(oxc-resolver@11.21.3)(rolldown@1.2.19)(typescript@6.0.2) rxjs: 7.8.2 sass: 1.107.1 sass-embedded: 1.107.1 @@ -37797,12 +37791,12 @@ snapshots: transitivePeerDependencies: - oxc-resolver - rolldown-plugin-dts@0.28.8(@volar/typescript@2.4.28)(oxc-resolver@11.21.3)(rolldown@1.2.9)(typescript@6.0.2): + rolldown-plugin-dts@0.28.8(@volar/typescript@2.4.28)(oxc-resolver@11.21.3)(rolldown@1.2.19)(typescript@6.0.2): dependencies: dts-resolver: 3.0.0(oxc-resolver@11.21.3) get-tsconfig: 5.0.0-beta.6 obug: 3.0.0 - rolldown: 1.2.9 + rolldown: 1.2.19 yuku-ast: 0.19.0 yuku-codegen: 0.19.0 yuku-parser: 0.19.0 @@ -38245,7 +38239,7 @@ snapshots: dependencies: chokidar: 5.0.0 immutable: 5.1.9 - source-map-js: 1.2.1 + source-map-js: 1.2.2 optionalDependencies: '@parcel/watcher': 2.6.0 @@ -38330,10 +38324,6 @@ snapshots: dependencies: seroval: 1.6.12 - seroval-plugins@1.6.7(seroval@1.6.7): - dependencies: - seroval: 1.6.7 - seroval@1.6.12: {} seroval@1.6.7: {} From 9ab49078f7ab1c66c888a7f8f8495d775d4c9716 Mon Sep 17 00:00:00 2001 From: Jack Herrington Date: Thu, 19 Nov 2026 16:48:09 -0800 Subject: [PATCH 04/14] fix(ai-secure-mcp): address CodeRabbit review on audit, egress, and docs - audit: reject non-finite/negative retentionDays at construction so a NaN cutoff cannot wipe the audit log on the first record; add unit tests. - egress: unref the deadline timer so a completed request does not keep Node's event loop alive for the remaining timeout. - egress: wrap the Response body reads so a stalled-body abort keeps the documented backend_unavailable taxonomy instead of a raw abort error. - egress: guard AbortSignal.any with a runtime check and a manual fallback for the Node 18.16 floor permitted by engines.node. - secure-mcp README: qualify the audit redaction guarantee (id-like fields retain string values), document that a client can confirm its own proposal, and limit the exposure claim to the generated Tailscale command. - isolate-e2b README: keep @tanstack/ai-code-mode in the install command so the usage example resolves. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/ai-isolate-e2b/README.md | 2 +- packages/ai-secure-mcp/README.md | 19 ++++- packages/ai-secure-mcp/src/audit.ts | 12 +++ packages/ai-secure-mcp/src/egress.ts | 82 ++++++++++++++++++--- packages/ai-secure-mcp/tests/audit.test.ts | 21 ++++++ packages/ai-secure-mcp/tests/egress.test.ts | 51 +++++++++++++ 6 files changed, 173 insertions(+), 14 deletions(-) diff --git a/packages/ai-isolate-e2b/README.md b/packages/ai-isolate-e2b/README.md index 2c08cdd280..ea122c73d7 100644 --- a/packages/ai-isolate-e2b/README.md +++ b/packages/ai-isolate-e2b/README.md @@ -27,7 +27,7 @@ Run the TypeScript that the model writes in an E2B sandbox, while your tools sta ## Installation ```bash -pnpm add @tanstack/ai-isolate-e2b @tanstack/ai-isolate e2b +pnpm add @tanstack/ai-isolate-e2b @tanstack/ai-code-mode @tanstack/ai-isolate e2b ``` ## Usage diff --git a/packages/ai-secure-mcp/README.md b/packages/ai-secure-mcp/README.md index 856966991c..14ce163e7a 100644 --- a/packages/ai-secure-mcp/README.md +++ b/packages/ai-secure-mcp/README.md @@ -29,7 +29,7 @@ It wraps your server with: - **Scopes and a target allowlist** — a token holds scopes; a scope can be narrowed to named resources. - **Deny-by-default egress helper** — one allowlisted `egress` capability a tool uses on purpose. It is not an enforced network boundary: a tool that calls global `fetch` still reaches the network. For enforced isolation, run the server behind a separate execution or network boundary. - **Rate limits** — a per-client sliding window. -- **A redacted audit log** — append-only JSONL, args redacted to id-like fields, no secrets. +- **A redacted audit log** — append-only JSONL, args redacted to id-like fields. A field keeps its value only when its name ends in an id-like suffix (`id`, `name`, `title`, `kind`, `type`, `scope`, `origin`); every other field is replaced with `[redacted]`. This is name-based, not value-based: a secret passed in an id-like field such as `sessionId` is written in full. Keep secrets out of those fields. - **A tripwire notifier** — push a signal to your phone when someone pokes at the server. - **Two-phase approval** — a tool can return a proposal; a separate confirm runs the action. - **Go-live preflight** — refuses a public funnel while a secure default is off. @@ -118,6 +118,13 @@ A separate, authenticated call to the `approve_proposal` tool with that `proposalId` runs the action. Proposals are in memory, single-use, and expire, so a crash cannot leave a ghost approval. +The confirm step checks only that the confirming client id matches the client +that made the proposal. It is not an independent approver: the same client, with +the same token, can make both the proposal and the confirm. This two-phase flow +adds a deliberate second step and an audit trail; it does not by itself prove a +human reviewed the action. For real human-in-the-loop approval, route the +confirm through a different client or an out-of-band channel. + ## Secure defaults | Concern | Default | Footgun it prevents | @@ -127,7 +134,7 @@ so a crash cannot leave a ghost approval. | Tokens | hash-only, constant-time | replay from a leaked store | | Secrets | never in the audit log or a notification | prompt/response exfiltration | | Approval state | in memory, fail-closed on restart | a ghost approval after a crash | -| Exposure | tailnet-only unless you opt into a public funnel | accidental internet | +| Exposure | the _generated Tailscale command_ is tailnet-only unless you opt into a public funnel | accidental internet _through that command_ | The egress allowlist is a helper, not an enforced boundary. It stops exfiltration and SSRF only for a tool that reaches the network through @@ -139,6 +146,14 @@ The preflight refuses a public funnel while a token is unhashed, egress is open, or the audit log or notifier is off. The funnel URL is not a secret: auth stands on its own. +The exposure guarantee covers only the Tailscale command this package +generates. The package returns a `fetch` handler; it does not create, bind, or +restrict the HTTP listener. If you serve `server.fetch` yourself on a public +interface, it is reachable from the internet whether or not you set +`funnel.public`, and the public-funnel preflight does not run. For any public +deployment that does not go through the generated Tailscale funnel, restrict the +listener yourself and run `server.preflight` before you expose it. + ## License MIT diff --git a/packages/ai-secure-mcp/src/audit.ts b/packages/ai-secure-mcp/src/audit.ts index f1be9eb2a9..4308c031a1 100644 --- a/packages/ai-secure-mcp/src/audit.ts +++ b/packages/ai-secure-mcp/src/audit.ts @@ -65,6 +65,18 @@ export function createAuditLog(options: { now?: () => number }): AuditLog { const now = options.now ?? (() => Date.now()) + // Reject a bad retention up front. A NaN or non-finite value makes `cutoff` + // NaN, and then every `t >= cutoff` is false, so the first `record` would + // wipe the whole history before appending. A negative value would prune + // future entries. Validate at construction, before any file is touched. + if ( + options.retentionDays !== undefined && + (!Number.isFinite(options.retentionDays) || options.retentionDays < 0) + ) { + throw new RangeError( + `retentionDays must be a finite, non-negative number, got ${options.retentionDays}`, + ) + } const init = async () => { await mkdir(dirname(options.path), { recursive: true }).catch(() => {}) if (options.retentionDays === undefined) return diff --git a/packages/ai-secure-mcp/src/egress.ts b/packages/ai-secure-mcp/src/egress.ts index 786d49d84a..a013564a09 100644 --- a/packages/ai-secure-mcp/src/egress.ts +++ b/packages/ai-secure-mcp/src/egress.ts @@ -59,7 +59,11 @@ export function createEgress(options: { // The deadline stays armed until the caller's combined signal settles, so it // still aborts a slow body stream: `fetch` resolves on headers, not on body // completion. The timer fires at most once and is cleared on cancellation. + // `unref` keeps the deadline live for an unfinished body but does not hold + // the event loop open on its own, so a completed request can let the process + // exit without waiting out the remaining `timeoutMs`. const timer = setTimeout(() => controller.abort(), timeoutMs) + timer.unref?.() // Combine the caller's signal with the timeout so caller cancellation still // aborts the request and an already-aborted caller signal is honored, // instead of replacing `init.signal` with a fresh active one. @@ -75,31 +79,87 @@ export function createEgress(options: { ) } signal.addEventListener('abort', () => clearTimeout(timer), { once: true }) + const fail = (error: unknown): SecureMcpError => { + clearTimeout(timer) + const detail = error instanceof Error ? error.message : 'request failed' + return new SecureMcpError( + 'backend_unavailable', + `Egress to ${origin} failed: ${detail}`, + ) + } + let response: Response try { - return await fetchImpl(url, { + response = await fetchImpl(url, { ...init, redirect: 'error', signal, }) } catch (error) { - clearTimeout(timer) - const detail = error instanceof Error ? error.message : 'request failed' - throw new SecureMcpError( - 'backend_unavailable', - `Egress to ${origin} failed: ${detail}`, - ) + throw fail(error) } + // `fetch` resolves on headers, so a body that stalls past the deadline + // aborts during the body read, which happens after this function returns. + // Wrap the body reads so that failure keeps the documented + // `backend_unavailable` taxonomy instead of surfacing a raw abort error. + return wrapBody(response, fail) } } +/** + * Wraps the body-consuming methods of a `Response` so a transport failure + * during the body read (for example a stalled body that the deadline aborts) + * is translated the same way as a failure of the fetch promise. Streaming, + * status, and headers pass through unchanged. + */ +function wrapBody( + response: Response, + fail: (error: unknown) => SecureMcpError, +): Response { + return new Proxy(response, { + get(target, prop, receiver) { + if ( + prop === 'text' || + prop === 'json' || + prop === 'arrayBuffer' || + prop === 'blob' || + prop === 'formData' || + prop === 'bytes' + ) { + const method = Reflect.get(target, prop, target) as unknown + if (typeof method !== 'function') { + return Reflect.get(target, prop, receiver) + } + const fn = method as (...a: Array) => Promise + return (...args: Array) => + fn.apply(target, args).catch((error: unknown) => { + throw fail(error) + }) + } + const value = Reflect.get(target, prop, target) + return typeof value === 'function' ? value.bind(target) : value + }, + }) +} + /** Combines abort signals; aborts the result when any input aborts. */ function combineSignals( a: AbortSignal | undefined, b: AbortSignal, ): AbortSignal { if (a === undefined) return b - // `AbortSignal.any` is available on every runtime this package targets - // (Node 18.17+, modern browsers). It aborts as soon as either input aborts - // and carries the first abort reason. - return AbortSignal.any([a, b]) + // `AbortSignal.any` is the fast path, but `engines.node` allows 18.16 where + // it does not exist yet (added in 18.17). The lib types assume it is always + // present, so guard with a runtime check and fall back to a manual combiner + // so a caller signal on an older runtime does not throw before fetch runs. + if (typeof AbortSignal.any === 'function') return AbortSignal.any([a, b]) + const controller = new AbortController() + const abort = (reason: unknown) => controller.abort(reason) + for (const s of [a, b]) { + if (s.aborted) { + abort(s.reason) + break + } + s.addEventListener('abort', () => abort(s.reason), { once: true }) + } + return controller.signal } diff --git a/packages/ai-secure-mcp/tests/audit.test.ts b/packages/ai-secure-mcp/tests/audit.test.ts index 75fa48ea54..43170c462a 100644 --- a/packages/ai-secure-mcp/tests/audit.test.ts +++ b/packages/ai-secure-mcp/tests/audit.test.ts @@ -68,6 +68,27 @@ describe('createAuditLog', () => { expect(text).toContain('"new"') }) + it('rejects an invalid retentionDays before touching the log', async () => { + const dir = await mkdtemp(join(tmpdir(), 'audit-')) + const path = join(dir, 'audit.jsonl') + // Seed an existing history that a bad cutoff would wipe. + await writeFile(path, JSON.stringify({ time: 0, event: 'old' }) + '\n') + for (const bad of [Number.NaN, -1, Infinity, -Infinity]) { + expect(() => createAuditLog({ path, retentionDays: bad })).toThrow( + RangeError, + ) + } + // The existing log is untouched because construction threw first. + expect(await readFile(path, 'utf8')).toContain('"old"') + }) + + it('accepts zero and omitted retentionDays', async () => { + const dir = await mkdtemp(join(tmpdir(), 'audit-')) + const path = join(dir, 'audit.jsonl') + expect(() => createAuditLog({ path, retentionDays: 0 })).not.toThrow() + expect(() => createAuditLog({ path })).not.toThrow() + }) + it('does not start init until the first record, so a failure cannot float', async () => { const dir = await mkdtemp(join(tmpdir(), 'audit-')) // A path whose parent is an existing file. mkdir is best-effort, but the diff --git a/packages/ai-secure-mcp/tests/egress.test.ts b/packages/ai-secure-mcp/tests/egress.test.ts index 985bd27c7a..6ef7cfb287 100644 --- a/packages/ai-secure-mcp/tests/egress.test.ts +++ b/packages/ai-secure-mcp/tests/egress.test.ts @@ -77,4 +77,55 @@ describe('createEgress', () => { controller.abort() expect(seen?.aborted).toBe(true) }) + + it('unrefs the deadline timer so a completed request does not hold the loop', async () => { + let timer: { unref?: () => void } | undefined + const spy = vi.spyOn(global, 'setTimeout') + const egress = createEgress({ + allow: ['https://api.hue.local'], + fetch: async () => new Response('body'), + }) + await egress('https://api.hue.local/x') + timer = spy.mock.results[0]?.value + // Node timers expose `unref`; it must have been called so a finished + // request cannot delay process exit by the remaining timeout. + expect(typeof timer?.unref).toBe('function') + spy.mockRestore() + }) + + it('maps a body-read transport failure to backend_unavailable', async () => { + // Headers arrive, but reading the body rejects (a stalled body the deadline + // aborts behaves this way). The error must keep the documented taxonomy. + const egress = createEgress({ + allow: ['https://api.hue.local'], + fetch: async () => { + const res = new Response('ok') + res.text = async () => { + throw new Error('aborted') + } + return res + }, + }) + const res = await egress('https://api.hue.local/x') + expect(res.status).toBe(200) + await expect(res.text()).rejects.toMatchObject({ + code: 'backend_unavailable', + }) + }) + + it('leaves status, headers, and streaming body on the wrapped response', async () => { + const egress = createEgress({ + allow: ['https://api.hue.local'], + fetch: async () => + new Response('hello', { + status: 201, + headers: { 'x-test': 'yes' }, + }), + }) + const res = await egress('https://api.hue.local/x') + expect(res.status).toBe(201) + expect(res.headers.get('x-test')).toBe('yes') + expect(res.body).toBeInstanceOf(ReadableStream) + expect(await res.text()).toBe('hello') + }) }) From 2cb0c5377d60257660ce3eca966d03fd8a8626c8 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 00:49:59 +0000 Subject: [PATCH 05/14] ci: apply automated fixes --- packages/ai-secure-mcp/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/ai-secure-mcp/README.md b/packages/ai-secure-mcp/README.md index 14ce163e7a..b2cbcb6d6a 100644 --- a/packages/ai-secure-mcp/README.md +++ b/packages/ai-secure-mcp/README.md @@ -127,14 +127,14 @@ confirm through a different client or an out-of-band channel. ## Secure defaults -| Concern | Default | Footgun it prevents | -| -------------- | ------------------------------------------------ | ------------------------------------------------------------------------------ | -| Egress helper | deny-by-default allowlist | a tool exfiltrating data _when it uses `ctx.context.egress`_ | -| Generic HTTP | not injected into the context | SSRF through a "helpful" tool _that reaches the network only through `egress`_ | -| Tokens | hash-only, constant-time | replay from a leaked store | -| Secrets | never in the audit log or a notification | prompt/response exfiltration | -| Approval state | in memory, fail-closed on restart | a ghost approval after a crash | -| Exposure | the _generated Tailscale command_ is tailnet-only unless you opt into a public funnel | accidental internet _through that command_ | +| Concern | Default | Footgun it prevents | +| -------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | +| Egress helper | deny-by-default allowlist | a tool exfiltrating data _when it uses `ctx.context.egress`_ | +| Generic HTTP | not injected into the context | SSRF through a "helpful" tool _that reaches the network only through `egress`_ | +| Tokens | hash-only, constant-time | replay from a leaked store | +| Secrets | never in the audit log or a notification | prompt/response exfiltration | +| Approval state | in memory, fail-closed on restart | a ghost approval after a crash | +| Exposure | the _generated Tailscale command_ is tailnet-only unless you opt into a public funnel | accidental internet _through that command_ | The egress allowlist is a helper, not an enforced boundary. It stops exfiltration and SSRF only for a tool that reaches the network through From 629f8f7389c18ba6274625d2b93070f0e0f383fb Mon Sep 17 00:00:00 2001 From: Jack Herrington Date: Thu, 19 Nov 2026 17:03:32 -0800 Subject: [PATCH 06/14] fix(ai-secure-mcp): address egress deadline, listener leak, README consistency, and test - egress: separate error translation from deadline cleanup so a second body-method rejection cannot clear the timer that guards the first, still-running read; clear the timer only when the request genuinely settles. - egress: on the manual AbortSignal fallback, detach both fallback listeners when either signal aborts, so reusing a long-lived caller signal no longer leaks one listener (and controller) per request. - README: drop the "route confirm through a different client" advice that contradicted the clarification that confirm only matches the proposer's own client id; keep the out-of-band channel guidance. - tests: spy on the deadline timer's unref so the test fails if timer.unref?.() is removed from createEgress, not just that the method exists. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/ai-secure-mcp/README.md | 6 ++-- packages/ai-secure-mcp/src/egress.ts | 31 ++++++++++++++++++--- packages/ai-secure-mcp/tests/egress.test.ts | 25 +++++++++++++---- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/packages/ai-secure-mcp/README.md b/packages/ai-secure-mcp/README.md index b2cbcb6d6a..dc40cffc6b 100644 --- a/packages/ai-secure-mcp/README.md +++ b/packages/ai-secure-mcp/README.md @@ -122,8 +122,10 @@ The confirm step checks only that the confirming client id matches the client that made the proposal. It is not an independent approver: the same client, with the same token, can make both the proposal and the confirm. This two-phase flow adds a deliberate second step and an audit trail; it does not by itself prove a -human reviewed the action. For real human-in-the-loop approval, route the -confirm through a different client or an out-of-band channel. +human reviewed the action. For real human-in-the-loop approval, drive the +confirm from an out-of-band channel that acts under the proposer's identity, for +example an approval service that the proposing client calls after a human signs +off. ## Secure defaults diff --git a/packages/ai-secure-mcp/src/egress.ts b/packages/ai-secure-mcp/src/egress.ts index a013564a09..e880bce2ca 100644 --- a/packages/ai-secure-mcp/src/egress.ts +++ b/packages/ai-secure-mcp/src/egress.ts @@ -79,8 +79,13 @@ export function createEgress(options: { ) } signal.addEventListener('abort', () => clearTimeout(timer), { once: true }) + // Translate a transport error into the documented taxonomy. It does not + // touch the deadline: a body-method rejection (for example a second + // `text()` call that rejects because the body is already in use) must not + // clear the timer that still guards the first, still-running read. The + // timer is cleared only when the request genuinely settles: the fetch + // promise rejects below, the deadline fires, or the caller aborts. const fail = (error: unknown): SecureMcpError => { - clearTimeout(timer) const detail = error instanceof Error ? error.message : 'request failed' return new SecureMcpError( 'backend_unavailable', @@ -95,6 +100,9 @@ export function createEgress(options: { signal, }) } catch (error) { + // The fetch promise rejected, so the request attempt is over: clear the + // deadline here, not inside `fail`. + clearTimeout(timer) throw fail(error) } // `fetch` resolves on headers, so a body that stalls past the deadline @@ -153,13 +161,28 @@ function combineSignals( // so a caller signal on an older runtime does not throw before fetch runs. if (typeof AbortSignal.any === 'function') return AbortSignal.any([a, b]) const controller = new AbortController() - const abort = (reason: unknown) => controller.abort(reason) + // Track both listeners so that when either input aborts we detach the other. + // `{ once: true }` only removes the listener that runs, so reusing a + // long-lived caller signal across requests would otherwise retain one dead + // listener (and this controller) per request on it. + const listeners: Array<{ signal: AbortSignal; handler: () => void }> = [] + const cleanup = () => { + for (const { signal, handler } of listeners) { + signal.removeEventListener('abort', handler) + } + } + const abort = (reason: unknown) => { + cleanup() + controller.abort(reason) + } for (const s of [a, b]) { if (s.aborted) { abort(s.reason) - break + return controller.signal } - s.addEventListener('abort', () => abort(s.reason), { once: true }) + const handler = () => abort(s.reason) + listeners.push({ signal: s, handler }) + s.addEventListener('abort', handler, { once: true }) } return controller.signal } diff --git a/packages/ai-secure-mcp/tests/egress.test.ts b/packages/ai-secure-mcp/tests/egress.test.ts index 6ef7cfb287..38956ca277 100644 --- a/packages/ai-secure-mcp/tests/egress.test.ts +++ b/packages/ai-secure-mcp/tests/egress.test.ts @@ -79,17 +79,30 @@ describe('createEgress', () => { }) it('unrefs the deadline timer so a completed request does not hold the loop', async () => { - let timer: { unref?: () => void } | undefined - const spy = vi.spyOn(global, 'setTimeout') + // Spy on the timer's own `unref` before `createEgress` can call it, so the + // test fails if `timer.unref?.()` is dropped from the source. Wrapping + // `setTimeout` lets us attach the spy to the real timer it returns. + const realSetTimeout = global.setTimeout + const unrefSpy = vi.fn() + const spy = vi + .spyOn(global, 'setTimeout') + .mockImplementation(((...args: Parameters) => { + const timer = realSetTimeout(...args) + const original = (timer as { unref?: () => unknown }).unref + ;(timer as { unref?: () => unknown }).unref = function unref() { + unrefSpy() + return original?.call(this) + } + return timer + }) as typeof setTimeout) const egress = createEgress({ allow: ['https://api.hue.local'], fetch: async () => new Response('body'), }) await egress('https://api.hue.local/x') - timer = spy.mock.results[0]?.value - // Node timers expose `unref`; it must have been called so a finished - // request cannot delay process exit by the remaining timeout. - expect(typeof timer?.unref).toBe('function') + // The deadline timer must be unref'd so a finished request cannot delay + // process exit by the remaining timeout. + expect(unrefSpy).toHaveBeenCalledTimes(1) spy.mockRestore() }) From 00bf4b8425c84904138aacdc6f49cf8a124e35bb Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 01:05:37 +0000 Subject: [PATCH 07/14] ci: apply automated fixes --- packages/ai-secure-mcp/tests/egress.test.ts | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/ai-secure-mcp/tests/egress.test.ts b/packages/ai-secure-mcp/tests/egress.test.ts index 38956ca277..6d97efbacb 100644 --- a/packages/ai-secure-mcp/tests/egress.test.ts +++ b/packages/ai-secure-mcp/tests/egress.test.ts @@ -84,17 +84,17 @@ describe('createEgress', () => { // `setTimeout` lets us attach the spy to the real timer it returns. const realSetTimeout = global.setTimeout const unrefSpy = vi.fn() - const spy = vi - .spyOn(global, 'setTimeout') - .mockImplementation(((...args: Parameters) => { - const timer = realSetTimeout(...args) - const original = (timer as { unref?: () => unknown }).unref - ;(timer as { unref?: () => unknown }).unref = function unref() { - unrefSpy() - return original?.call(this) - } - return timer - }) as typeof setTimeout) + const spy = vi.spyOn(global, 'setTimeout').mockImplementation((( + ...args: Parameters + ) => { + const timer = realSetTimeout(...args) + const original = (timer as { unref?: () => unknown }).unref + ;(timer as { unref?: () => unknown }).unref = function unref() { + unrefSpy() + return original?.call(this) + } + return timer + }) as typeof setTimeout) const egress = createEgress({ allow: ['https://api.hue.local'], fetch: async () => new Response('body'), From 76b0533d943345f96d68b717c5c76b9814ad26bd Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Fri, 20 Nov 2026 14:38:41 +0100 Subject: [PATCH 08/14] fix(ai-secure-mcp): address review findings - Audit and notify only the first 10 auth failures per minute. Every failure still gets a 401, so a scanner cannot fill the disk or flood the notifier. - Remove the inverted egress preflight rule. An empty allowlist blocks every origin, so it is the strictest setting. - Count silentNotifier() as "notifier off" in the preflight. - Return the tool result when the success audit write fails. The action already ran, and an error would make the client retry it. - Prune the audit log through a temp file and rename, so a crash cannot lose the history. - README: say that two-phase approval is not human approval. Changeset: note the drivers' new peer dependency. --- .changeset/add-ai-secure-mcp.md | 2 +- .changeset/extract-ai-isolate-contract.md | 2 + packages/ai-secure-mcp/README.md | 9 ++- packages/ai-secure-mcp/src/audit.ts | 14 +++- packages/ai-secure-mcp/src/deploy.ts | 5 -- packages/ai-secure-mcp/src/guard.ts | 81 +++++++++------------ packages/ai-secure-mcp/src/notifier.ts | 14 +++- packages/ai-secure-mcp/src/server.ts | 32 +++++--- packages/ai-secure-mcp/tests/deploy.test.ts | 6 +- packages/ai-secure-mcp/tests/guard.test.ts | 26 +++++++ packages/ai-secure-mcp/tests/server.test.ts | 51 ++++++++++++- 11 files changed, 163 insertions(+), 79 deletions(-) diff --git a/.changeset/add-ai-secure-mcp.md b/.changeset/add-ai-secure-mcp.md index 71f0a11659..9d4446d3bc 100644 --- a/.changeset/add-ai-secure-mcp.md +++ b/.changeset/add-ai-secure-mcp.md @@ -2,4 +2,4 @@ '@tanstack/ai-secure-mcp': minor --- -Add `@tanstack/ai-secure-mcp`, a security envelope around `createMCPServer` for self-hosting an MCP server on the internet. `createSecureMcpServer` wraps your tools with hashed-token bearer auth, scopes and a per-client target allowlist, a deny-by-default egress helper a tool opts into (it is not an enforced network boundary — a tool that calls global `fetch` still reaches the network), a per-client sliding-window rate limit, a redacted append-only JSONL audit log, a pluggable tripwire notifier (`ntfyNotifier`, `webhookNotifier`, `silentNotifier`), and two-phase propose/confirm approval. A go-live preflight refuses a public Tailscale funnel while a secure default is off (unhashed token, open egress, audit or notifier off). +Add `@tanstack/ai-secure-mcp`, a security envelope around `createMCPServer` for self-hosting an MCP server on the internet. `createSecureMcpServer` wraps your tools with hashed-token bearer auth, scopes and a per-client target allowlist, a deny-by-default egress helper a tool opts into (it is not an enforced network boundary — a tool that calls global `fetch` still reaches the network), a per-client sliding-window rate limit, a redacted append-only JSONL audit log, a pluggable tripwire notifier (`ntfyNotifier`, `webhookNotifier`, `silentNotifier`), and two-phase propose/confirm approval. A go-live preflight refuses a public Tailscale funnel while a secure default is off (unhashed token, audit off, or notifier off or silent). diff --git a/.changeset/extract-ai-isolate-contract.md b/.changeset/extract-ai-isolate-contract.md index 8c8dd5987b..898709ff44 100644 --- a/.changeset/extract-ai-isolate-contract.md +++ b/.changeset/extract-ai-isolate-contract.md @@ -12,3 +12,5 @@ Add `@tanstack/ai-isolate`, the engine-agnostic isolate base. It owns the contract every sandbox driver implements (`IsolateDriver`, `IsolateConfig`, `IsolateContext`, `ExecutionResult`, `NormalizedError`, `ToolBinding`) plus the shared `wrapCode` helper. These previously lived inside `@tanstack/ai-code-mode`, which forced every driver to depend on Code Mode just for the contract. Drivers (`quickjs`, `quickjs-bun`, `node`, `cloudflare`, `e2b`, `daytona`) now depend on `@tanstack/ai-isolate` instead of `@tanstack/ai-code-mode`. `@tanstack/ai-code-mode` re-exports the same types and `wrapCode`, so its public API is unchanged. + +The drivers' peer dependency is now `@tanstack/ai-isolate`. If your package manager does not install peer dependencies for you (for example pnpm with `auto-install-peers=false`), add `@tanstack/ai-isolate` next to your driver. diff --git a/packages/ai-secure-mcp/README.md b/packages/ai-secure-mcp/README.md index dc40cffc6b..fa2edcaed7 100644 --- a/packages/ai-secure-mcp/README.md +++ b/packages/ai-secure-mcp/README.md @@ -28,10 +28,10 @@ It wraps your server with: - **Hashed-token auth** — bearer tokens stored as SHA-256 hashes, constant-time compare. - **Scopes and a target allowlist** — a token holds scopes; a scope can be narrowed to named resources. - **Deny-by-default egress helper** — one allowlisted `egress` capability a tool uses on purpose. It is not an enforced network boundary: a tool that calls global `fetch` still reaches the network. For enforced isolation, run the server behind a separate execution or network boundary. -- **Rate limits** — a per-client sliding window. +- **Rate limits** — a per-client sliding window. Auth failures share one budget: only the first 10 per minute are audited and notified, so a scanner cannot fill the disk or flood your phone. Every failure still gets a 401. - **A redacted audit log** — append-only JSONL, args redacted to id-like fields. A field keeps its value only when its name ends in an id-like suffix (`id`, `name`, `title`, `kind`, `type`, `scope`, `origin`); every other field is replaced with `[redacted]`. This is name-based, not value-based: a secret passed in an id-like field such as `sessionId` is written in full. Keep secrets out of those fields. - **A tripwire notifier** — push a signal to your phone when someone pokes at the server. -- **Two-phase approval** — a tool can return a proposal; a separate confirm runs the action. +- **Two-phase approval** — a tool can return a proposal; a separate confirm runs the action. The same token can confirm its own proposal, so this is not human approval. See [Two-phase approval](#two-phase-approval). - **Go-live preflight** — refuses a public funnel while a secure default is off. ## Installation @@ -144,8 +144,9 @@ exfiltration and SSRF only for a tool that reaches the network through network confinement needs a separate execution or network boundary around the server. -The preflight refuses a public funnel while a token is unhashed, egress is open, -or the audit log or notifier is off. The funnel URL is not a secret: auth stands +The preflight refuses a public funnel while a token is unhashed, or the audit log +or notifier is off. `silentNotifier()` counts as off. An empty egress allowlist +is fine: it blocks every origin. The funnel URL is not a secret: auth stands on its own. The exposure guarantee covers only the Tailscale command this package diff --git a/packages/ai-secure-mcp/src/audit.ts b/packages/ai-secure-mcp/src/audit.ts index 4308c031a1..7bf8a0b5d2 100644 --- a/packages/ai-secure-mcp/src/audit.ts +++ b/packages/ai-secure-mcp/src/audit.ts @@ -1,4 +1,10 @@ -import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises' +import { + appendFile, + mkdir, + readFile, + rename, + writeFile, +} from 'node:fs/promises' import { dirname } from 'node:path' /** One line of the audit log. Secrets and tokens are never present. */ @@ -98,7 +104,11 @@ export function createAuditLog(options: { return false } }) - await writeFile(options.path, kept.length ? kept.join('\n') + '\n' : '') + // Write a temp file and rename it over the log. `rename` is atomic on one + // file system, so a crash mid-write cannot lose the history. + const tmp = `${options.path}.tmp` + await writeFile(tmp, kept.length ? kept.join('\n') + '\n' : '') + await rename(tmp, options.path) } // Prune and ensure the directory once, lazily on the first `record`. Running // init eagerly here would leave its rejection unhandled until a later diff --git a/packages/ai-secure-mcp/src/deploy.ts b/packages/ai-secure-mcp/src/deploy.ts index 0b74ef7c56..dc68e8efd0 100644 --- a/packages/ai-secure-mcp/src/deploy.ts +++ b/packages/ai-secure-mcp/src/deploy.ts @@ -3,8 +3,6 @@ import type { ClientRecord } from './types' /** What the preflight reads to decide whether the server is safe to expose. */ export interface PreflightInput { clients: ReadonlyArray - /** True when egress is deny-by-default (an allowlist is set). */ - egressDenyByDefault: boolean /** True when the audit log is on. */ auditOn: boolean /** True when a real notifier is set (not the silent one). */ @@ -35,9 +33,6 @@ export function preflight(input: PreflightInput): PreflightResult { ) } } - if (!input.egressDenyByDefault) { - problems.push('Egress is not deny-by-default. Set an egress allowlist.') - } if (!input.auditOn) { problems.push('The audit log is off. Turn it on before you go public.') } diff --git a/packages/ai-secure-mcp/src/guard.ts b/packages/ai-secure-mcp/src/guard.ts index af544fd6f8..fe792d5949 100644 --- a/packages/ai-secure-mcp/src/guard.ts +++ b/packages/ai-secure-mcp/src/guard.ts @@ -63,6 +63,36 @@ export function guardTools( ): Promise => { const client = readClient(context) + const runAndAudit = async (): Promise => { + let result: unknown + try { + result = await original?.(args, context) + } catch (error) { + await deps.audit?.record({ + client: client.id, + event: 'tool_call', + tool: tool.name, + outcome: 'error', + code: error instanceof SecureMcpError ? error.code : undefined, + args, + }) + throw error + } + // The action already ran. If this audit write fails, still return the + // result: an error here would make the client retry and run the + // action twice. + await deps.audit + ?.record({ + client: client.id, + event: 'tool_call', + tool: tool.name, + outcome: 'ok', + args, + }) + .catch(() => {}) + return result + } + const scope = deps.policy.scopes?.[tool.name] if (scope !== undefined && !client.scopes.includes(scope)) { return refuse( @@ -95,32 +125,9 @@ export function guardTools( const envelope = deps.approvals.propose({ owner: client.id, summary, - // Audit both outcomes of the confirmed run. The proposal is consumed - // single-use before this runs, so a throw here would otherwise leave - // no execution record for the failed approved action. - run: async () => { - try { - const result = await original?.(args, context) - await deps.audit?.record({ - client: client.id, - event: 'tool_call', - tool: tool.name, - outcome: 'ok', - args, - }) - return result - } catch (error) { - await deps.audit?.record({ - client: client.id, - event: 'tool_call', - tool: tool.name, - outcome: 'error', - code: error instanceof SecureMcpError ? error.code : undefined, - args, - }) - throw error - } - }, + // The proposal is consumed single-use before this runs, so the run + // audits its own outcome. + run: runAndAudit, }) await deps.audit?.record({ client: client.id, @@ -137,27 +144,7 @@ export function guardTools( return envelope } - try { - const result = await original?.(args, context) - await deps.audit?.record({ - client: client.id, - event: 'tool_call', - tool: tool.name, - outcome: 'ok', - args, - }) - return result - } catch (error) { - await deps.audit?.record({ - client: client.id, - event: 'tool_call', - tool: tool.name, - outcome: 'error', - code: error instanceof SecureMcpError ? error.code : undefined, - args, - }) - throw error - } + return runAndAudit() } // An approval-gated tool returns the `approval_required` envelope on the // first call, not its own output shape. Keeping an `outputSchema` would make diff --git a/packages/ai-secure-mcp/src/notifier.ts b/packages/ai-secure-mcp/src/notifier.ts index 3090ce479a..ee79e0b559 100644 --- a/packages/ai-secure-mcp/src/notifier.ts +++ b/packages/ai-secure-mcp/src/notifier.ts @@ -22,9 +22,19 @@ export function describeEvent(event: SecurityEvent): string { } } -/** A notifier that does nothing. Use it to turn notifications off on purpose. */ +const SILENT: SecurityNotifier = Object.freeze({ notify: async () => {} }) + +/** + * A notifier that does nothing. Use it to turn notifications off on purpose. + * The go-live preflight counts it as "notifier off". + */ export function silentNotifier(): SecurityNotifier { - return { notify: async () => {} } + return SILENT +} + +/** True for the notifier that {@link silentNotifier} returns. */ +export function isSilentNotifier(notifier: SecurityNotifier): boolean { + return notifier === SILENT } /** diff --git a/packages/ai-secure-mcp/src/server.ts b/packages/ai-secure-mcp/src/server.ts index 168cd2ae6e..dcd31960d8 100644 --- a/packages/ai-secure-mcp/src/server.ts +++ b/packages/ai-secure-mcp/src/server.ts @@ -4,7 +4,7 @@ import { createApprovalStore } from './approval' import { createAuditLog } from './audit' import { createEgress } from './egress' import { createConfirmTool, guardTools } from './guard' -import { safeNotifier, silentNotifier } from './notifier' +import { isSilentNotifier, safeNotifier, silentNotifier } from './notifier' import { createRateLimiter } from './rate-limit' import { preflight, tailscaleCommand } from './deploy' import { SecureMcpError } from './types' @@ -56,6 +56,8 @@ export interface SecureMcpServer { } const FAR_FUTURE = 4_102_444_800 // 2100-01-01, for a token with no expiry +/** The auth failures audited and notified per window. More only get a 401. */ +const AUTH_FAILURE_BUDGET = { limit: 10, windowMs: 60_000 } function jsonError(status: number, code: string, headers?: HeadersInit) { return new Response(JSON.stringify({ error: { code } }), { @@ -130,9 +132,8 @@ export function createSecureMcpServer( const check = preflight({ clients: config.clients, - egressDenyByDefault: allow.length > 0, auditOn: audit !== undefined, - notifierOn: config.notify !== undefined, + notifierOn: config.notify !== undefined && !isSilentNotifier(config.notify), }) if (config.funnel?.public === true && !check.ok) { throw new SecureMcpError( @@ -143,23 +144,30 @@ export function createSecureMcpServer( const nowSeconds = () => Math.floor(Date.now() / 1000) - const fetch = async (request: Request): Promise => { - const token = bearerToken(request.headers.get('authorization')) - if (token === undefined) { + // An unauthenticated caller has no client id to rate-limit, and each failure + // writes to disk and pings the notifier. Only the first failures in each + // window are audited and notified, so a scanner cannot fill the disk or + // flood the phone. Every failure still gets a 401. + // ponytail: one global budget, a per-IP budget if one scanner should not + // hide another. + const authFailures = createRateLimiter(AUTH_FAILURE_BUDGET) + const denyAuth = async (): Promise => { + if (authFailures.allow('*')) { void notify.notify({ kind: 'auth_failure' }) await audit?.record({ event: 'auth_failure', outcome: 'denied' }) - return jsonError(401, 'auth_failure', { - 'www-authenticate': 'Bearer', - }) } + return jsonError(401, 'auth_failure', { 'www-authenticate': 'Bearer' }) + } + + const fetch = async (request: Request): Promise => { + const token = bearerToken(request.headers.get('authorization')) + if (token === undefined) return denyAuth() let client: ClientRecord try { client = verifyToken(token, config.clients, nowSeconds()) } catch { - void notify.notify({ kind: 'auth_failure' }) - await audit?.record({ event: 'auth_failure', outcome: 'denied' }) - return jsonError(401, 'auth_failure', { 'www-authenticate': 'Bearer' }) + return denyAuth() } if (rl !== undefined && !rl.allow(client.id)) { diff --git a/packages/ai-secure-mcp/tests/deploy.test.ts b/packages/ai-secure-mcp/tests/deploy.test.ts index a8d0b35ea7..fa325d26a5 100644 --- a/packages/ai-secure-mcp/tests/deploy.test.ts +++ b/packages/ai-secure-mcp/tests/deploy.test.ts @@ -13,7 +13,6 @@ describe('preflight', () => { it('passes when every rule holds', () => { const r = preflight({ clients: [good], - egressDenyByDefault: true, auditOn: true, notifierOn: true, }) @@ -21,16 +20,14 @@ describe('preflight', () => { expect(r.problems).toEqual([]) }) - it('flags unhashed tokens, open egress, and off audit/notifier', () => { + it('flags unhashed tokens and off audit/notifier', () => { const r = preflight({ clients: [{ id: 'bob', tokenHash: 'plaintext', scopes: [] }], - egressDenyByDefault: false, auditOn: false, notifierOn: false, }) expect(r.ok).toBe(false) expect(r.problems.join(' ')).toMatch(/SHA-256/) - expect(r.problems.join(' ')).toMatch(/Egress/) expect(r.problems.join(' ')).toMatch(/audit/) expect(r.problems.join(' ')).toMatch(/notifier/) }) @@ -38,7 +35,6 @@ describe('preflight', () => { it('flags an empty client list', () => { const r = preflight({ clients: [], - egressDenyByDefault: true, auditOn: true, notifierOn: true, }) diff --git a/packages/ai-secure-mcp/tests/guard.test.ts b/packages/ai-secure-mcp/tests/guard.test.ts index d255c81d9e..7c4cfc6b26 100644 --- a/packages/ai-secure-mcp/tests/guard.test.ts +++ b/packages/ai-secure-mcp/tests/guard.test.ts @@ -207,3 +207,29 @@ describe('guardTools — two-phase approval', () => { expect(guarded!.outputSchema).toBeUndefined() }) }) + +describe('guardTools — audit failure after the call', () => { + it('returns the result when the success audit write fails', async () => { + let calls = 0 + const counted = toolDefinition({ + name: 'counted', + description: 'Counts calls', + inputSchema: z.object({}), + }).server(async () => ({ calls: ++calls })) + const [guarded] = guardTools([counted], { + policy: {}, + approvals: createApprovalStore(), + audit: { + record: async () => { + throw new Error('disk full') + }, + }, + notify: capturingNotifier(), + summarize: (name) => name, + }) + await expect(guarded!.execute!({}, contextFor(control))).resolves.toEqual({ + calls: 1, + }) + expect(calls).toBe(1) + }) +}) diff --git a/packages/ai-secure-mcp/tests/server.test.ts b/packages/ai-secure-mcp/tests/server.test.ts index d2740f929c..cd53594f2e 100644 --- a/packages/ai-secure-mcp/tests/server.test.ts +++ b/packages/ai-secure-mcp/tests/server.test.ts @@ -1,9 +1,13 @@ +import { mkdtemp, readFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' import { toolDefinition } from '@tanstack/ai' import { z } from 'zod' import { describe, expect, it } from 'vitest' import { hashToken } from '../src/auth' +import { silentNotifier } from '../src/notifier' import { createSecureMcpServer } from '../src/server' -import type { ClientRecord } from '../src/types' +import type { ClientRecord, SecurityEvent } from '../src/types' const ping = toolDefinition({ name: 'ping', @@ -94,3 +98,48 @@ describe('createSecureMcpServer — go-live safety', () => { expect(server.tailscale?.command).toContain('tailscale serve') }) }) + +describe('createSecureMcpServer — preflight rules', () => { + async function auditPath() { + return join(await mkdtemp(join(tmpdir(), 'secure-mcp-')), 'audit.jsonl') + } + + it('allows a public funnel with an empty egress allowlist', async () => { + const server = createSecureMcpServer({ + ...base(), + egress: [], + audit: { path: await auditPath() }, + notify: { notify: async () => {} }, + funnel: { port: 8787, public: true }, + }) + expect(server.preflight).toEqual({ ok: true, problems: [] }) + }) + + it('counts silentNotifier() as notifier off', async () => { + const server = createSecureMcpServer({ + ...base(), + audit: { path: await auditPath() }, + notify: silentNotifier(), + }) + expect(server.preflight.ok).toBe(false) + expect(server.preflight.problems.join(' ')).toMatch(/notifier/) + }) +}) + +describe('createSecureMcpServer — auth failure flood', () => { + it('audits and notifies only the first failures in a window', async () => { + const path = join(await mkdtemp(join(tmpdir(), 'secure-mcp-')), 'a.jsonl') + const events: Array = [] + const server = createSecureMcpServer({ + ...base(), + audit: { path }, + notify: { notify: async (event) => void events.push(event) }, + }) + for (let i = 0; i < 25; i++) { + expect((await server.fetch(mcpRequest('wrong'))).status).toBe(401) + } + const lines = (await readFile(path, 'utf8')).trim().split('\n') + expect(lines).toHaveLength(10) + expect(events).toHaveLength(10) + }) +}) From 937d0c8775f8df69fb07ebb320b135bd603e6d24 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Fri, 20 Nov 2026 14:53:30 +0100 Subject: [PATCH 09/14] fix(ai-secure-mcp): send every approval alert through debounceNotifier approval_pending has no client, so all proposals shared one debounce key and only the first one per window reached the user. Key it by proposalId. --- packages/ai-secure-mcp/src/notifier.ts | 11 ++++++++-- packages/ai-secure-mcp/tests/notifier.test.ts | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/ai-secure-mcp/src/notifier.ts b/packages/ai-secure-mcp/src/notifier.ts index ee79e0b559..e5a2c97a44 100644 --- a/packages/ai-secure-mcp/src/notifier.ts +++ b/packages/ai-secure-mcp/src/notifier.ts @@ -118,6 +118,7 @@ export function webhookNotifier( /** * Wraps a notifier so the same event kind for the same client is sent at most * once per window. A scanner cannot turn the tripwire into a self-DoS. + * `approval_pending` is keyed by `proposalId`, so every proposal is sent. * * @param inner - The notifier to protect * @param windowMs - The quiet window per key, 60000 ms by default @@ -131,8 +132,14 @@ export function debounceNotifier( const lastSent = new Map() return { notify: async (event) => { - const client = 'client' in event ? event.client : '' - const key = `${event.kind}:${client ?? ''}` + // Each approval is its own request for a human, so it is never merged. + const id = + event.kind === 'approval_pending' + ? event.proposalId + : 'client' in event + ? event.client + : '' + const key = `${event.kind}:${id ?? ''}` const at = now() const prev = lastSent.get(key) if (prev !== undefined && at - prev < windowMs) return diff --git a/packages/ai-secure-mcp/tests/notifier.test.ts b/packages/ai-secure-mcp/tests/notifier.test.ts index 1c66064f8b..213417ecd9 100644 --- a/packages/ai-secure-mcp/tests/notifier.test.ts +++ b/packages/ai-secure-mcp/tests/notifier.test.ts @@ -73,6 +73,27 @@ describe('debounceNotifier', () => { await n.notify({ kind: 'forbidden_scope', client: 'b', tool: 't' }) expect(calls).toBe(2) }) + + it('sends each approval_pending proposal, but not a repeat of one', async () => { + const sent: Array = [] + const n = debounceNotifier( + { notify: async (event) => void sent.push(event) }, + 1000, + () => 0, + ) + const p1: SecurityEvent = { + kind: 'approval_pending', + proposalId: 'p1', + summary: 'Run buyMovie', + } + await n.notify(p1) + await n.notify({ ...p1, proposalId: 'p2' }) + await n.notify(p1) + expect(sent.map((e) => 'proposalId' in e && e.proposalId)).toEqual([ + 'p1', + 'p2', + ]) + }) }) describe('silentNotifier', () => { From 2497946162d80de1d445612f0c821cb63979dc22 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Fri, 20 Nov 2026 15:31:51 +0100 Subject: [PATCH 10/14] ci(bun-test): pin Bun to 1.4.4 Bun 1.4.5 fails to compile quickjs-bun's native quickjs.c through bun:ffi cc, so every quickjs-bun driver test fails. --- .github/workflows/bun-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bun-test.yml b/.github/workflows/bun-test.yml index 808fa4e097..dd3dc3bec4 100644 --- a/.github/workflows/bun-test.yml +++ b/.github/workflows/bun-test.yml @@ -43,7 +43,9 @@ jobs: uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: # The driver requires Bun >= 1.3.14 (see the package `engines` field). - bun-version: latest + # Pinned: Bun 1.4.5 fails to compile quickjs-bun's quickjs.c through + # bun:ffi `cc`. Go back to `latest` when Bun or quickjs-bun fixes it. + bun-version: 1.4.4 - name: Build package and its workspace dependencies # `@tanstack/ai-code-mode` is a `workspace:*` peer dependency and is # imported at runtime (`wrapCode`) by the driver, so it must be built to From 0cbc39a6151c6b1d94dc21dcb23e67fcdcc15f6a Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Fri, 20 Nov 2026 15:35:36 +0100 Subject: [PATCH 11/14] Revert "ci(bun-test): pin Bun to 1.4.4" This reverts commit 2497946162d80de1d445612f0c821cb63979dc22. --- .github/workflows/bun-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/bun-test.yml b/.github/workflows/bun-test.yml index dd3dc3bec4..808fa4e097 100644 --- a/.github/workflows/bun-test.yml +++ b/.github/workflows/bun-test.yml @@ -43,9 +43,7 @@ jobs: uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: # The driver requires Bun >= 1.3.14 (see the package `engines` field). - # Pinned: Bun 1.4.5 fails to compile quickjs-bun's quickjs.c through - # bun:ffi `cc`. Go back to `latest` when Bun or quickjs-bun fixes it. - bun-version: 1.4.4 + bun-version: latest - name: Build package and its workspace dependencies # `@tanstack/ai-code-mode` is a `workspace:*` peer dependency and is # imported at runtime (`wrapCode`) by the driver, so it must be built to From 44f67f2bdf3ea680405bb153eea6012aef5d7488 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Fri, 20 Nov 2026 15:49:01 +0100 Subject: [PATCH 12/14] fix(ai-isolate-quickjs-bun): update quickjs-bun to 0.2.0 quickjs-bun 0.1.2 cannot compile its native quickjs.c through bun:ffi cc on the Ubuntu 26.04 runner image, so every Bun driver test failed on main too. 0.2.0 compiles there. It needs Bun >= 1.4.0, so the engine floor, docs, and @types/bun move with it. --- .changeset/bump-quickjs-bun-0-2.md | 5 + .github/workflows/bun-test.yml | 2 +- docs/code-mode/code-mode-isolates.md | 2 +- examples/ts-code-mode-web/package.json | 2 +- packages/ai-isolate-quickjs-bun/README.md | 2 +- packages/ai-isolate-quickjs-bun/package.json | 6 +- .../src/isolate-driver.ts | 2 +- packages/ai-isolate-quickjs-bun/tsconfig.json | 3 + pnpm-lock.yaml | 141 +++++++++--------- 9 files changed, 87 insertions(+), 78 deletions(-) create mode 100644 .changeset/bump-quickjs-bun-0-2.md diff --git a/.changeset/bump-quickjs-bun-0-2.md b/.changeset/bump-quickjs-bun-0-2.md new file mode 100644 index 0000000000..8112ba0912 --- /dev/null +++ b/.changeset/bump-quickjs-bun-0-2.md @@ -0,0 +1,5 @@ +--- +'@tanstack/ai-isolate-quickjs-bun': patch +--- + +Update `quickjs-bun` to 0.2.0. Version 0.1.2 cannot compile its native code on Ubuntu 26.04, so the driver failed to create a context there. The driver now needs Bun 1.4.0 or later. diff --git a/.github/workflows/bun-test.yml b/.github/workflows/bun-test.yml index 808fa4e097..47c77bb2d9 100644 --- a/.github/workflows/bun-test.yml +++ b/.github/workflows/bun-test.yml @@ -42,7 +42,7 @@ jobs: - name: Setup Bun uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: - # The driver requires Bun >= 1.3.14 (see the package `engines` field). + # The driver requires Bun >= 1.4.0 (see the package `engines` field). bun-version: latest - name: Build package and its workspace dependencies # `@tanstack/ai-code-mode` is a `workspace:*` peer dependency and is diff --git a/docs/code-mode/code-mode-isolates.md b/docs/code-mode/code-mode-isolates.md index 42948d9dea..cd4ab8b28a 100644 --- a/docs/code-mode/code-mode-isolates.md +++ b/docs/code-mode/code-mode-isolates.md @@ -149,7 +149,7 @@ octane: @tanstack/ai-isolate-quickjs-bun -The driver needs Bun 1.3.14 or later. On Node.js, it throws an error when it creates a context, so use the Node or QuickJS WASM driver there. On Windows, set the `QUICKJS_BUN_NATIVE_LIBRARY` environment variable to a prebuilt QuickJS dynamic library. +The driver needs Bun 1.4.0 or later. On Node.js, it throws an error when it creates a context, so use the Node or QuickJS WASM driver there. On Windows, set the `QUICKJS_BUN_NATIVE_LIBRARY` environment variable to a prebuilt QuickJS dynamic library. ```typescript import { createQuickJSBunIsolateDriver } from '@tanstack/ai-isolate-quickjs-bun' diff --git a/examples/ts-code-mode-web/package.json b/examples/ts-code-mode-web/package.json index e2b04a942d..6466ddc0c0 100644 --- a/examples/ts-code-mode-web/package.json +++ b/examples/ts-code-mode-web/package.json @@ -44,7 +44,7 @@ "motion": "^11.15.0", "nitro": "3.0.260610-beta", "puppeteer": "^24.34.0", - "quickjs-bun": "0.1.2", + "quickjs-bun": "0.2.0", "quickjs-emscripten": "^0.31.0", "quickjs-emscripten-core": "^0.31.0", "react": "^19.2.3", diff --git a/packages/ai-isolate-quickjs-bun/README.md b/packages/ai-isolate-quickjs-bun/README.md index c71b662ec4..21c13cd5d5 100644 --- a/packages/ai-isolate-quickjs-bun/README.md +++ b/packages/ai-isolate-quickjs-bun/README.md @@ -24,7 +24,7 @@ Native QuickJS driver for TanStack AI Code Mode on the [Bun](https://bun.sh) run ## Requirements -- Bun `>= 1.3.14` — the driver throws a descriptive error when used on Node.js (use `@tanstack/ai-isolate-node` or `@tanstack/ai-isolate-quickjs` there). +- Bun `>= 1.4.0` — the driver throws a descriptive error when used on Node.js (use `@tanstack/ai-isolate-node` or `@tanstack/ai-isolate-quickjs` there). - macOS or Linux on `x86_64`/`aarch64` work out of the box ([`quickjs-bun`](https://github.com/superpowerdotcom/quickjs-bun) compiles the vendored QuickJS sources on the fly with Bun's embedded TinyCC — no build tools needed). On Windows, point the `QUICKJS_BUN_NATIVE_LIBRARY` environment variable at a prebuilt QuickJS dynamic library. > **Dependency note:** this driver is built against [`quickjs-bun`](https://github.com/superpowerdotcom/quickjs-bun) `0.1.2` and pins it exactly, because `quickjs-bun` is an early-stage package (pre-1.0) that compiles QuickJS through TinyCC/`bun:ffi` — its API and platform support may change between patch releases. The version is intentionally not widened to a `^`/`~` range until the upstream API stabilizes. Consumers inherit `quickjs-bun`'s supply-chain and platform-support surface (notably the Windows `QUICKJS_BUN_NATIVE_LIBRARY` requirement above). diff --git a/packages/ai-isolate-quickjs-bun/package.json b/packages/ai-isolate-quickjs-bun/package.json index e86744e568..8aa81904e9 100644 --- a/packages/ai-isolate-quickjs-bun/package.json +++ b/packages/ai-isolate-quickjs-bun/package.json @@ -32,7 +32,7 @@ "src" ], "engines": { - "bun": ">=1.3.14" + "bun": ">=1.4.0" }, "scripts": { "build": "vite build", @@ -60,14 +60,14 @@ "code-execution" ], "dependencies": { - "quickjs-bun": "0.1.2" + "quickjs-bun": "0.2.0" }, "peerDependencies": { "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { "@tanstack/ai-isolate-quickjs": "workspace:*", - "@types/bun": "^1.3.14", + "@types/bun": "^1.4.4", "@vitest/coverage-v8": "4.1.12" } } diff --git a/packages/ai-isolate-quickjs-bun/src/isolate-driver.ts b/packages/ai-isolate-quickjs-bun/src/isolate-driver.ts index 4936133d4a..4f9618186c 100644 --- a/packages/ai-isolate-quickjs-bun/src/isolate-driver.ts +++ b/packages/ai-isolate-quickjs-bun/src/isolate-driver.ts @@ -167,7 +167,7 @@ export interface QuickJSBunIsolateDriverConfig { * memory "limit" is QuickJS's internal accounting (`JS_SetMemoryLimit`), not a * hardware/OS boundary. For a stronger boundary use `@tanstack/ai-isolate-node` * (a separate V8 isolate) or the WASM driver (WebAssembly linear-memory - * sandbox). It requires Bun >= 1.3.14 — on Node.js use + * sandbox). It requires Bun >= 1.4.0 — on Node.js use * `@tanstack/ai-isolate-node` or `@tanstack/ai-isolate-quickjs` instead. * * Tools are injected as async functions that bridge back to the host. diff --git a/packages/ai-isolate-quickjs-bun/tsconfig.json b/packages/ai-isolate-quickjs-bun/tsconfig.json index 1908972dc8..ef92a22e04 100644 --- a/packages/ai-isolate-quickjs-bun/tsconfig.json +++ b/packages/ai-isolate-quickjs-bun/tsconfig.json @@ -4,6 +4,9 @@ // quickjs-bun ships TypeScript sources that use import attributes // (`with { type: "file" }`), which require a newer module target. "module": "ESNext", + // quickjs-bun 0.2 sources use ES2024 APIs (String#isWellFormed, + // SharedArrayBuffer#growable). Bun supports them. + "lib": ["DOM", "DOM.Iterable", "ES2024"], // The root base restricts `types` to ["node"], which suppresses // auto-inclusion of @types/bun. quickjs-bun's sources (and our driver) // rely on the `Bun` global and the `bun:ffi` module, so re-add "bun". diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 96c787d20a..2c51f2f0c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1067,7 +1067,7 @@ importers: version: 17.2.3 nitro: specifier: 3.0.260610-beta - version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) + version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) tailwindcss: specifier: ^4.1.18 version: 4.1.18 @@ -1233,13 +1233,13 @@ importers: version: 11.18.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3) nitro: specifier: 3.0.260610-beta - version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) + version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) puppeteer: specifier: ^24.34.0 version: 24.39.1(supports-color@7.2.0)(typescript@5.9.3) quickjs-bun: - specifier: 0.1.2 - version: 0.1.2 + specifier: 0.2.0 + version: 0.2.0 quickjs-emscripten: specifier: ^0.31.0 version: 0.31.0 @@ -1330,7 +1330,7 @@ importers: version: 0.10.0 nitro: specifier: 3.0.260610-beta - version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) + version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) react: specifier: ^19.2.3 version: 19.2.3 @@ -1532,7 +1532,7 @@ importers: version: 0.561.0(react@19.2.3) nitro: specifier: 3.0.260610-beta - version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) + version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) react: specifier: ^19.2.3 version: 19.2.3 @@ -1668,7 +1668,7 @@ importers: version: 0.561.0(react@19.2.3) nitro: specifier: 3.0.260610-beta - version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) + version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) react: specifier: ^19.2.3 version: 19.2.3 @@ -1781,7 +1781,7 @@ importers: version: 0.561.0(react@19.2.3) nitro: specifier: 3.0.260610-beta - version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.4.2)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@3.3.1)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) + version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.4.2)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@3.3.1)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) react: specifier: ^19.2.3 version: 19.2.3 @@ -1869,7 +1869,7 @@ importers: version: 0.561.0(react@19.2.3) nitro: specifier: 3.0.260610-beta - version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) + version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) radix-ui: specifier: ^1.4.3 version: 1.4.3(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) @@ -1978,7 +1978,7 @@ importers: version: 0.561.0(react@19.2.3) nitro: specifier: 3.0.260610-beta - version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.4.2)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@3.3.1)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) + version: 3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.4.2)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@3.3.1)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0) radix-ui: specifier: ^1.4.3 version: 1.4.3(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) @@ -2091,7 +2091,7 @@ importers: version: link:../../packages/ai-solid '@tanstack/nitro-v2-vite-plugin': specifier: ^1.155.0 - version: 1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.4)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.4)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: ^1.168.42 version: 1.168.42(@tanstack/react-router@1.170.41(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(esbuild@0.28.2)(rolldown@1.3.1)(rollup@4.60.1)(vite-plugin-solid@2.11.16(solid-js@1.9.19)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)))(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) @@ -3144,15 +3144,15 @@ importers: specifier: workspace:^ version: link:../ai-isolate quickjs-bun: - specifier: 0.1.2 - version: 0.1.2 + specifier: 0.2.0 + version: 0.2.0 devDependencies: '@tanstack/ai-isolate-quickjs': specifier: workspace:* version: link:../ai-isolate-quickjs '@types/bun': - specifier: ^1.3.14 - version: 1.3.14 + specifier: ^1.4.4 + version: 1.4.4 '@vitest/coverage-v8': specifier: 4.1.12 version: 4.1.12(vitest@4.1.12) @@ -3520,7 +3520,7 @@ importers: version: 4.1.12(vitest@4.1.12) drizzle-orm: specifier: ^0.45.4 - version: 0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2))(typescript@7.0.2))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2)) + version: 0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2))(typescript@7.0.2))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2)) pg: specifier: ^8.23.1 version: 8.23.1 @@ -4430,7 +4430,7 @@ importers: version: 0.4.1 '@tanstack/nitro-v2-vite-plugin': specifier: ^1.155.0 - version: 1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@tanstack/react-ai-devtools': specifier: workspace:* version: link:../../packages/react-ai-devtools @@ -4563,7 +4563,7 @@ importers: version: link:../../packages/ai-skills '@tanstack/nitro-v2-vite-plugin': specifier: ^1.155.0 - version: 1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) + version: 1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) '@tanstack/react-ai-devtools': specifier: workspace:* version: link:../../packages/react-ai-devtools @@ -12175,8 +12175,8 @@ packages: '@types/babel__traverse@7.28.0': resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==} - '@types/bun@1.3.14': - resolution: {integrity: sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw==} + '@types/bun@1.4.4': + resolution: {integrity: sha512-9wkRDXUXK124pEnAutE6n/l18j+i9GC5IAHK8TmX/2nlySETmky0OU6yL5U8pW1AoKh++AN9auDCr647BfurjQ==} '@types/chai@5.2.3': resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} @@ -13530,8 +13530,8 @@ packages: resolution: {integrity: sha512-lHblz4ahamxpTmnsk+MNTRWsjYKv965MwOrSJyeD588rR3Jcu7swE+0wN5F+PbL5cjgu/9ObkhfzEPuofEMwLA==} engines: {node: '>=10.0.0'} - bun-types@1.3.14: - resolution: {integrity: sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ==} + bun-types@1.4.4: + resolution: {integrity: sha512-yjrJh5oGX7mMPKGd19YXyIjmEuj4G4zNC30bs7PM9Az7NQ3ndF3j6hbeRdvJTRQEhJ/FYQwW0a2moweEi2hMxQ==} bundle-name@4.1.0: resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} @@ -17828,9 +17828,9 @@ packages: queue@6.0.2: resolution: {integrity: sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==} - quickjs-bun@0.1.2: - resolution: {integrity: sha512-mmbG4UwB+FqckVGJXttx4vAg92X/mjcp5e42UZXWrIe80m48x6/Vs3SW3UFTHzRzGFHuzCPnChCKB+W7AK8OSA==} - engines: {bun: '>=1.3.14'} + quickjs-bun@0.2.0: + resolution: {integrity: sha512-UqwpIYDF6cm9Wx7Qa0Ls644f/W/A2r3O920WJGN+ZdtFMpfeKBZ8JuWoJYP5EqZ3ATq2lqCec8vUhbQP5NkLjg==} + engines: {bun: '>=1.4.0'} quickjs-emscripten-core@0.31.0: resolution: {integrity: sha512-oQz8p0SiKDBc1TC7ZBK2fr0GoSHZKA0jZIeXxsnCyCs4y32FStzCW4d1h6E1sE0uHDMbGITbk2zhNaytaoJwXQ==} @@ -28863,9 +28863,9 @@ snapshots: octane: 0.12.1(@tsrx/oxc@0.20.0(svelte@5.57.3(@typescript-eslint/types@8.59.4)))(@typescript-eslint/types@8.59.4)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@6.0.3)(vite@8.3.8(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0)) react: 19.2.3 - '@tanstack/nitro-v2-vite-plugin@1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': + '@tanstack/nitro-v2-vite-plugin@1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': dependencies: - nitropack: 2.13.1(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1) + nitropack: 2.13.1(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1) pathe: 2.0.3 vite: 8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0) transitivePeerDependencies: @@ -28899,9 +28899,9 @@ snapshots: - uploadthing - xml2js - '@tanstack/nitro-v2-vite-plugin@1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.4)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': + '@tanstack/nitro-v2-vite-plugin@1.155.0(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.4)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))': dependencies: - nitropack: 2.13.1(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.4) + nitropack: 2.13.1(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.4) pathe: 2.0.3 vite: 8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0) transitivePeerDependencies: @@ -29761,9 +29761,9 @@ snapshots: dependencies: '@babel/types': 7.29.8 - '@types/bun@1.3.14': + '@types/bun@1.4.4': dependencies: - bun-types: 1.3.14 + bun-types: 1.4.4 '@types/chai@5.2.3': dependencies: @@ -31381,9 +31381,10 @@ snapshots: buildcheck@0.0.7: optional: true - bun-types@1.3.14: + bun-types@1.4.4: dependencies: '@types/node': 24.13.6 + undici-types: 7.18.2 bundle-name@4.1.0: dependencies: @@ -31926,25 +31927,25 @@ snapshots: dayjs@1.11.19: {} - db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3): + db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3): optionalDependencies: '@electric-sql/pglite': 0.5.11 better-sqlite3: 12.11.1 - drizzle-orm: 0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)) + drizzle-orm: 0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)) mysql2: 3.15.3 - db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3): + db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3): optionalDependencies: '@electric-sql/pglite': 0.5.11 better-sqlite3: 12.11.1 - drizzle-orm: 0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)) + drizzle-orm: 0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)) mysql2: 3.15.3 - db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3): + db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3): optionalDependencies: '@electric-sql/pglite': 0.5.11 better-sqlite3: 12.11.1 - drizzle-orm: 0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)) + drizzle-orm: 0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)) mysql2: 3.15.3 de-indent@1.0.2: {} @@ -32140,7 +32141,7 @@ snapshots: dotenv@17.4.2: {} - drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)): + drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)): optionalDependencies: '@cloudflare/workers-types': 4.20260317.1 '@electric-sql/pglite': 0.5.11 @@ -32148,14 +32149,14 @@ snapshots: '@prisma/client': 7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3) '@types/pg': 8.23.1 better-sqlite3: 12.11.1 - bun-types: 1.3.14 + bun-types: 1.4.4 mysql2: 3.15.3 pg: 8.23.1 postgres: 3.4.7 prisma: 7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3) optional: true - drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2))(typescript@7.0.2))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2)): + drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2))(typescript@7.0.2))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2)): optionalDependencies: '@cloudflare/workers-types': 4.20260317.1 '@electric-sql/pglite': 0.5.11 @@ -32163,13 +32164,13 @@ snapshots: '@prisma/client': 7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2))(typescript@7.0.2) '@types/pg': 8.23.1 better-sqlite3: 12.11.1 - bun-types: 1.3.14 + bun-types: 1.4.4 mysql2: 3.15.3 pg: 8.23.1 postgres: 3.4.7 prisma: 7.9.0(@types/react-dom@19.2.3(@types/react@19.3.0))(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@7.0.2) - drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)): + drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)): optionalDependencies: '@cloudflare/workers-types': 4.20260317.1 '@electric-sql/pglite': 0.5.11 @@ -32177,21 +32178,21 @@ snapshots: '@prisma/client': 7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3) '@types/pg': 8.23.1 better-sqlite3: 12.11.1 - bun-types: 1.3.14 + bun-types: 1.4.4 mysql2: 3.15.3 pg: 8.23.1 postgres: 3.4.7 prisma: 7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3) optional: true - drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)): + drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)): optionalDependencies: '@electric-sql/pglite': 0.5.11 '@opentelemetry/api': 1.9.1 '@prisma/client': 7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3) '@types/pg': 8.23.1 better-sqlite3: 12.11.1 - bun-types: 1.3.14 + bun-types: 1.4.4 mysql2: 3.15.3 pg: 8.23.1 postgres: 3.4.7 @@ -35345,11 +35346,11 @@ snapshots: - oxc-resolver - vue-tsc - nitro@3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0): + nitro@3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.2.3)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@2.0.0)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0): dependencies: consola: 3.4.2 crossws: 0.4.6(srvx@0.11.17) - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) env-runner: 0.1.14(miniflare@4.20260617.1)(wrangler@4.103.0) h3: 2.0.1-rc.22(crossws@0.4.6(srvx@0.11.17)) hookable: 6.1.1 @@ -35360,7 +35361,7 @@ snapshots: rolldown: 1.2.4 srvx: 0.11.17 unenv: 2.0.0-rc.24 - unstorage: 2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3) + unstorage: 2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3) optionalDependencies: dotenv: 17.2.3 giget: 2.0.0 @@ -35399,11 +35400,11 @@ snapshots: - uploadthing - wrangler - nitro@3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.4.2)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@3.3.1)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0): + nitro@3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.4.2)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@3.3.1)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0): dependencies: consola: 3.4.2 crossws: 0.4.6(srvx@0.11.17) - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) env-runner: 0.1.14(miniflare@4.20260617.1)(wrangler@4.103.0) h3: 2.0.1-rc.22(crossws@0.4.6(srvx@0.11.22)) hookable: 6.1.1 @@ -35414,7 +35415,7 @@ snapshots: rolldown: 1.2.4 srvx: 0.11.17 unenv: 2.0.0-rc.24 - unstorage: 2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3) + unstorage: 2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3) optionalDependencies: dotenv: 17.4.2 giget: 3.3.1 @@ -35453,11 +35454,11 @@ snapshots: - uploadthing - wrangler - nitro@3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.4.2)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@3.3.1)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0): + nitro@3.0.260610-beta(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(chokidar@5.0.0)(dotenv@17.4.2)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(giget@3.3.1)(jiti@2.7.0)(lru-cache@11.5.3)(miniflare@4.20260617.1)(mysql2@3.15.3)(rollup@4.60.1)(vite@8.3.8(@types/node@24.10.3)(esbuild@0.28.2)(jiti@2.7.0)(less@4.6.6)(sass-embedded@1.108.2)(sass@1.108.2)(terser@5.44.1)(tsx@4.23.15)(yaml@2.9.0))(wrangler@4.103.0): dependencies: consola: 3.4.2 crossws: 0.4.6(srvx@0.11.17) - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) env-runner: 0.1.14(miniflare@4.20260617.1)(wrangler@4.103.0) h3: 2.0.1-rc.22(crossws@0.4.6(srvx@0.11.22)) hookable: 6.1.1 @@ -35468,7 +35469,7 @@ snapshots: rolldown: 1.2.4 srvx: 0.11.17 unenv: 2.0.0-rc.24 - unstorage: 2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3) + unstorage: 2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3) optionalDependencies: dotenv: 17.4.2 giget: 3.3.1 @@ -35507,7 +35508,7 @@ snapshots: - uploadthing - wrangler - nitropack@2.13.1(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1): + nitropack@2.13.1(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.3.1): dependencies: '@cloudflare/kv-asset-handler': 0.4.2 '@rollup/plugin-alias': 6.0.0(rollup@4.60.1) @@ -35528,7 +35529,7 @@ snapshots: cookie-es: 2.0.1 croner: 9.1.0 crossws: 0.3.5 - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) defu: 6.1.4 destr: 2.0.5 dot-prop: 10.1.0 @@ -35574,7 +35575,7 @@ snapshots: unenv: 2.0.0-rc.24 unimport: 5.6.0 unplugin-utils: 0.3.1 - unstorage: 1.17.4(aws4fetch@1.0.20)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(ioredis@5.9.2) + unstorage: 1.17.4(aws4fetch@1.0.20)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(ioredis@5.9.2) untyped: 2.0.0 unwasm: 0.5.3 youch: 4.1.0-beta.13 @@ -35609,7 +35610,7 @@ snapshots: - supports-color - uploadthing - nitropack@2.13.1(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.4): + nitropack@2.13.1(@electric-sql/pglite@0.5.11)(aws4fetch@1.0.20)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3)(rolldown@1.2.4): dependencies: '@cloudflare/kv-asset-handler': 0.4.2 '@rollup/plugin-alias': 6.0.0(rollup@4.60.1) @@ -35630,7 +35631,7 @@ snapshots: cookie-es: 2.0.1 croner: 9.1.0 crossws: 0.3.5 - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) defu: 6.1.4 destr: 2.0.5 dot-prop: 10.1.0 @@ -35676,7 +35677,7 @@ snapshots: unenv: 2.0.0-rc.24 unimport: 5.6.0 unplugin-utils: 0.3.1 - unstorage: 1.17.4(aws4fetch@1.0.20)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(ioredis@5.9.2) + unstorage: 1.17.4(aws4fetch@1.0.20)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(ioredis@5.9.2) untyped: 2.0.0 unwasm: 0.5.3 youch: 4.1.0-beta.13 @@ -37007,7 +37008,7 @@ snapshots: dependencies: inherits: 2.0.4 - quickjs-bun@0.1.2: {} + quickjs-bun@0.2.0: {} quickjs-emscripten-core@0.31.0: dependencies: @@ -39331,7 +39332,7 @@ snapshots: - '@emnapi/core' - '@emnapi/runtime' - unstorage@1.17.4(aws4fetch@1.0.20)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(ioredis@5.9.2): + unstorage@1.17.4(aws4fetch@1.0.20)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(ioredis@5.9.2): dependencies: anymatch: 3.1.3 chokidar: 5.0.0 @@ -39343,10 +39344,10 @@ snapshots: ufo: 1.6.4 optionalDependencies: aws4fetch: 1.0.20 - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) ioredis: 5.9.2 - unstorage@1.17.4(aws4fetch@1.0.20)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(ioredis@5.9.2): + unstorage@1.17.4(aws4fetch@1.0.20)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(ioredis@5.9.2): dependencies: anymatch: 3.1.3 chokidar: 5.0.0 @@ -39358,22 +39359,22 @@ snapshots: ufo: 1.6.4 optionalDependencies: aws4fetch: 1.0.20 - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@cloudflare/workers-types@4.20260317.1)(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react@19.3.0)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) ioredis: 5.9.2 - unstorage@2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3): + unstorage@2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3): optionalDependencies: aws4fetch: 1.0.20 chokidar: 5.0.0 - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.18))(@types/react@19.2.18)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) lru-cache: 11.5.3 ofetch: 2.0.0-alpha.3 - unstorage@2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3): + unstorage@2.0.0-alpha.7(aws4fetch@1.0.20)(chokidar@5.0.0)(db0@0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3))(lru-cache@11.5.3)(ofetch@2.0.0-alpha.3): optionalDependencies: aws4fetch: 1.0.20 chokidar: 5.0.0 - db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.3.14)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) + db0: 0.3.4(@electric-sql/pglite@0.5.11)(better-sqlite3@12.11.1)(drizzle-orm@0.45.4(@electric-sql/pglite@0.5.11)(@opentelemetry/api@1.9.1)(@prisma/client@7.9.0(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@types/pg@8.23.1)(better-sqlite3@12.11.1)(bun-types@1.4.4)(mysql2@3.15.3)(pg@8.23.1)(postgres@3.4.7)(prisma@7.9.0(@types/react-dom@19.2.3(@types/react@19.2.7))(@types/react@19.2.7)(better-sqlite3@12.11.1)(magicast@0.5.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3)))(mysql2@3.15.3) lru-cache: 11.5.3 ofetch: 2.0.0-alpha.3 From 5969c63ce410f22d261697c1616c702e7ede0609 Mon Sep 17 00:00:00 2001 From: Tom Beckenham <34339192+tombeckenham@users.noreply.github.com> Date: Sat, 21 Nov 2026 16:32:38 +1100 Subject: [PATCH 13/14] fix(ai-secure-mcp): refuse config that fails open, and fix the confirm path - Throw when a policy names a tool that is not in `tools`, or a tool has no `execute`. A misspelt name left the real tool with no scope check and no approval. - An egress allowlist entry must be an http(s) origin. An entry with no scheme parsed to the origin "null", which matches every `data:` and `file:` URL. - Run an approved action with the context of the confirm call. It used the abort signal and hooks of the propose request, which has ended. - Return the result when the audit write after a confirm fails. The action already ran and the proposal is spent. - Reject unknown keys and non-string scopes in the clients file, a duplicate client id, and an `expiresAt` in milliseconds. - Reject a NaN or non-positive rate limit, window, ttl, and maxPending. - Match a target only when it is a string. - Retry a failed audit init, notify before the audit write on a scope refusal, give 429s the tripwire budget, and prune the debounce map. - Correct the comments that claimed more than the code enforces. fix(isolate): make @tanstack/ai-isolate a dependency of the drivers The drivers import `wrapCode` from it at runtime, so a required peer in a patch release broke installs that do not add peers. The Bun workflow now runs when `packages/ai-isolate` changes. --- .changeset/extract-ai-isolate-contract.md | 4 +- .github/workflows/bun-test.yml | 4 +- packages/ai-isolate-daytona/README.md | 2 +- packages/ai-isolate-daytona/package.json | 2 +- packages/ai-isolate-e2b/README.md | 2 +- packages/ai-isolate-e2b/package.json | 2 +- packages/ai-isolate-node/README.md | 5 +- packages/ai-isolate-node/package.json | 4 +- packages/ai-isolate-quickjs-bun/README.md | 2 +- packages/ai-isolate-quickjs-bun/package.json | 4 +- packages/ai-isolate-quickjs/README.md | 5 +- packages/ai-isolate-quickjs/package.json | 4 +- packages/ai-secure-mcp/README.md | 2 +- packages/ai-secure-mcp/src/approval.ts | 37 +++++--- packages/ai-secure-mcp/src/audit.ts | 21 +++-- packages/ai-secure-mcp/src/clients-file.ts | 32 +++++-- packages/ai-secure-mcp/src/egress.ts | 26 +++++- packages/ai-secure-mcp/src/guard.ts | 77 +++++++++++----- packages/ai-secure-mcp/src/notifier.ts | 5 ++ packages/ai-secure-mcp/src/rate-limit.ts | 11 +++ packages/ai-secure-mcp/src/server.ts | 79 +++++++++++----- packages/ai-secure-mcp/tests/approval.test.ts | 8 ++ .../ai-secure-mcp/tests/clients-file.test.ts | 18 ++++ packages/ai-secure-mcp/tests/egress.test.ts | 32 +++++++ packages/ai-secure-mcp/tests/guard.test.ts | 89 +++++++++++++++++-- .../ai-secure-mcp/tests/rate-limit.test.ts | 15 ++++ packages/ai-secure-mcp/tests/server.test.ts | 69 ++++++++++++++ pnpm-lock.yaml | 18 ++-- 28 files changed, 471 insertions(+), 108 deletions(-) diff --git a/.changeset/extract-ai-isolate-contract.md b/.changeset/extract-ai-isolate-contract.md index 898709ff44..3e4d6f59c1 100644 --- a/.changeset/extract-ai-isolate-contract.md +++ b/.changeset/extract-ai-isolate-contract.md @@ -11,6 +11,4 @@ Add `@tanstack/ai-isolate`, the engine-agnostic isolate base. It owns the contract every sandbox driver implements (`IsolateDriver`, `IsolateConfig`, `IsolateContext`, `ExecutionResult`, `NormalizedError`, `ToolBinding`) plus the shared `wrapCode` helper. These previously lived inside `@tanstack/ai-code-mode`, which forced every driver to depend on Code Mode just for the contract. -Drivers (`quickjs`, `quickjs-bun`, `node`, `cloudflare`, `e2b`, `daytona`) now depend on `@tanstack/ai-isolate` instead of `@tanstack/ai-code-mode`. `@tanstack/ai-code-mode` re-exports the same types and `wrapCode`, so its public API is unchanged. - -The drivers' peer dependency is now `@tanstack/ai-isolate`. If your package manager does not install peer dependencies for you (for example pnpm with `auto-install-peers=false`), add `@tanstack/ai-isolate` next to your driver. +Drivers (`quickjs`, `quickjs-bun`, `node`, `cloudflare`, `e2b`, `daytona`) now depend on `@tanstack/ai-isolate` instead of `@tanstack/ai-code-mode`. It is a regular dependency of each driver, so you install nothing extra. `@tanstack/ai-code-mode` re-exports the same types and `wrapCode`, so its public API is unchanged. diff --git a/.github/workflows/bun-test.yml b/.github/workflows/bun-test.yml index 47c77bb2d9..e309fc78f2 100644 --- a/.github/workflows/bun-test.yml +++ b/.github/workflows/bun-test.yml @@ -15,7 +15,7 @@ on: pull_request: paths: - 'packages/ai-isolate-quickjs-bun/**' - - 'packages/ai-code-mode/**' + - 'packages/ai-isolate/**' - '.github/workflows/bun-test.yml' concurrency: @@ -45,7 +45,7 @@ jobs: # The driver requires Bun >= 1.4.0 (see the package `engines` field). bun-version: latest - name: Build package and its workspace dependencies - # `@tanstack/ai-code-mode` is a `workspace:*` peer dependency and is + # `@tanstack/ai-isolate` is a workspace dependency and is # imported at runtime (`wrapCode`) by the driver, so it must be built to # `dist/` before the Bun tests can import it. nx builds the dependency # graph first via `^build`. diff --git a/packages/ai-isolate-daytona/README.md b/packages/ai-isolate-daytona/README.md index 42a6c05479..250a8c39f1 100644 --- a/packages/ai-isolate-daytona/README.md +++ b/packages/ai-isolate-daytona/README.md @@ -27,7 +27,7 @@ This package runs generated JavaScript or TypeScript in a caller-provided Dayton ## Installation ```bash -pnpm add @tanstack/ai-isolate-daytona @tanstack/ai-isolate @tanstack/ai-code-mode +pnpm add @tanstack/ai-isolate-daytona @tanstack/ai-code-mode ``` If you use the official Daytona SDK to create sandboxes, install it in your app too: diff --git a/packages/ai-isolate-daytona/package.json b/packages/ai-isolate-daytona/package.json index 84982d4eae..63e9173c90 100644 --- a/packages/ai-isolate-daytona/package.json +++ b/packages/ai-isolate-daytona/package.json @@ -49,7 +49,7 @@ "isolate", "code-execution" ], - "peerDependencies": { + "dependencies": { "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { diff --git a/packages/ai-isolate-e2b/README.md b/packages/ai-isolate-e2b/README.md index ea122c73d7..60283b54fd 100644 --- a/packages/ai-isolate-e2b/README.md +++ b/packages/ai-isolate-e2b/README.md @@ -27,7 +27,7 @@ Run the TypeScript that the model writes in an E2B sandbox, while your tools sta ## Installation ```bash -pnpm add @tanstack/ai-isolate-e2b @tanstack/ai-code-mode @tanstack/ai-isolate e2b +pnpm add @tanstack/ai-isolate-e2b @tanstack/ai-code-mode e2b ``` ## Usage diff --git a/packages/ai-isolate-e2b/package.json b/packages/ai-isolate-e2b/package.json index d6cef9d4c0..5907afbd41 100644 --- a/packages/ai-isolate-e2b/package.json +++ b/packages/ai-isolate-e2b/package.json @@ -49,7 +49,7 @@ "isolate", "code-execution" ], - "peerDependencies": { + "dependencies": { "@tanstack/ai-isolate": "workspace:^" }, "devDependencies": { diff --git a/packages/ai-isolate-node/README.md b/packages/ai-isolate-node/README.md index 1c913751c9..db03e2ce8d 100644 --- a/packages/ai-isolate-node/README.md +++ b/packages/ai-isolate-node/README.md @@ -31,12 +31,9 @@ Node.js V8 isolate driver for TanStack AI Code Mode. Uses [`isolated-vm`](https: ## Installation ```bash -pnpm add @tanstack/ai-isolate-node @tanstack/ai-isolate +pnpm add @tanstack/ai-isolate-node ``` -`@tanstack/ai-isolate` is a peer dependency. A package manager that does not -auto-install peers needs it listed explicitly. - ## Usage ```typescript diff --git a/packages/ai-isolate-node/package.json b/packages/ai-isolate-node/package.json index 1a35359e48..8882f9179e 100644 --- a/packages/ai-isolate-node/package.json +++ b/packages/ai-isolate-node/package.json @@ -58,11 +58,9 @@ "code-execution" ], "dependencies": { + "@tanstack/ai-isolate": "workspace:^", "isolated-vm": "^7.0.2" }, - "peerDependencies": { - "@tanstack/ai-isolate": "workspace:^" - }, "devDependencies": { "@vitest/coverage-v8": "4.1.12" } diff --git a/packages/ai-isolate-quickjs-bun/README.md b/packages/ai-isolate-quickjs-bun/README.md index 21c13cd5d5..b828aed7b6 100644 --- a/packages/ai-isolate-quickjs-bun/README.md +++ b/packages/ai-isolate-quickjs-bun/README.md @@ -27,7 +27,7 @@ Native QuickJS driver for TanStack AI Code Mode on the [Bun](https://bun.sh) run - Bun `>= 1.4.0` — the driver throws a descriptive error when used on Node.js (use `@tanstack/ai-isolate-node` or `@tanstack/ai-isolate-quickjs` there). - macOS or Linux on `x86_64`/`aarch64` work out of the box ([`quickjs-bun`](https://github.com/superpowerdotcom/quickjs-bun) compiles the vendored QuickJS sources on the fly with Bun's embedded TinyCC — no build tools needed). On Windows, point the `QUICKJS_BUN_NATIVE_LIBRARY` environment variable at a prebuilt QuickJS dynamic library. -> **Dependency note:** this driver is built against [`quickjs-bun`](https://github.com/superpowerdotcom/quickjs-bun) `0.1.2` and pins it exactly, because `quickjs-bun` is an early-stage package (pre-1.0) that compiles QuickJS through TinyCC/`bun:ffi` — its API and platform support may change between patch releases. The version is intentionally not widened to a `^`/`~` range until the upstream API stabilizes. Consumers inherit `quickjs-bun`'s supply-chain and platform-support surface (notably the Windows `QUICKJS_BUN_NATIVE_LIBRARY` requirement above). +> **Dependency note:** this driver is built against [`quickjs-bun`](https://github.com/superpowerdotcom/quickjs-bun) `0.2.0` and pins it exactly, because `quickjs-bun` is an early-stage package (pre-1.0) that compiles QuickJS through TinyCC/`bun:ffi` — its API and platform support may change between patch releases. The version is intentionally not widened to a `^`/`~` range until the upstream API stabilizes. Consumers inherit `quickjs-bun`'s supply-chain and platform-support surface (notably the Windows `QUICKJS_BUN_NATIVE_LIBRARY` requirement above). ## Installation diff --git a/packages/ai-isolate-quickjs-bun/package.json b/packages/ai-isolate-quickjs-bun/package.json index 8aa81904e9..1c45c3ef7b 100644 --- a/packages/ai-isolate-quickjs-bun/package.json +++ b/packages/ai-isolate-quickjs-bun/package.json @@ -60,11 +60,9 @@ "code-execution" ], "dependencies": { + "@tanstack/ai-isolate": "workspace:^", "quickjs-bun": "0.2.0" }, - "peerDependencies": { - "@tanstack/ai-isolate": "workspace:^" - }, "devDependencies": { "@tanstack/ai-isolate-quickjs": "workspace:*", "@types/bun": "^1.4.4", diff --git a/packages/ai-isolate-quickjs/README.md b/packages/ai-isolate-quickjs/README.md index ae3b66f8bf..99099c309f 100644 --- a/packages/ai-isolate-quickjs/README.md +++ b/packages/ai-isolate-quickjs/README.md @@ -25,12 +25,9 @@ QuickJS WASM driver for TanStack AI Code Mode. Runs everywhere — Node.js, brow ## Installation ```bash -pnpm add @tanstack/ai-isolate-quickjs @tanstack/ai-isolate +pnpm add @tanstack/ai-isolate-quickjs ``` -`@tanstack/ai-isolate` is a peer dependency. A package manager that does not -auto-install peers needs it listed explicitly, or the driver fails to load. - ## Usage ```typescript diff --git a/packages/ai-isolate-quickjs/package.json b/packages/ai-isolate-quickjs/package.json index 24ded54d6f..bc680b3b59 100644 --- a/packages/ai-isolate-quickjs/package.json +++ b/packages/ai-isolate-quickjs/package.json @@ -55,11 +55,9 @@ "code-execution" ], "dependencies": { + "@tanstack/ai-isolate": "workspace:^", "quickjs-emscripten": "^0.31.0" }, - "peerDependencies": { - "@tanstack/ai-isolate": "workspace:^" - }, "devDependencies": { "@vitest/coverage-v8": "4.1.12" } diff --git a/packages/ai-secure-mcp/README.md b/packages/ai-secure-mcp/README.md index fa2edcaed7..1534c0315b 100644 --- a/packages/ai-secure-mcp/README.md +++ b/packages/ai-secure-mcp/README.md @@ -134,7 +134,7 @@ off. | Egress helper | deny-by-default allowlist | a tool exfiltrating data _when it uses `ctx.context.egress`_ | | Generic HTTP | not injected into the context | SSRF through a "helpful" tool _that reaches the network only through `egress`_ | | Tokens | hash-only, constant-time | replay from a leaked store | -| Secrets | never in the audit log or a notification | prompt/response exfiltration | +| Secrets | the raw token is never logged or notified; args are redacted by field name | prompt/response exfiltration | | Approval state | in memory, fail-closed on restart | a ghost approval after a crash | | Exposure | the _generated Tailscale command_ is tailnet-only unless you opt into a public funnel | accidental internet _through that command_ | diff --git a/packages/ai-secure-mcp/src/approval.ts b/packages/ai-secure-mcp/src/approval.ts index 500a8842cf..000186174d 100644 --- a/packages/ai-secure-mcp/src/approval.ts +++ b/packages/ai-secure-mcp/src/approval.ts @@ -9,10 +9,10 @@ export interface ApprovalRequired { expiresAt: number } -interface Proposal { +interface Proposal { owner: string summary: string - run: () => Promise + run: (context: TContext) => Promise expiresAt: number } @@ -24,18 +24,26 @@ interface Proposal { * The store is in memory and fail-closed: a restart drops every proposal, so a * ghost approval cannot run after a crash. Each proposal is single-use and * expires. + * + * `run` receives the context of the confirming call, not the proposing one. + * The proposing request has ended by then, so its abort signal and its + * request-bound hooks are dead. */ -export interface ApprovalStore { +export interface ApprovalStore { propose: (input: { owner: string summary: string - run: () => Promise + run: (context: TContext) => Promise }) => ApprovalRequired - confirm: (proposalId: string, owner: string) => Promise + confirm: ( + proposalId: string, + owner: string, + context: TContext, + ) => Promise pendingCount: () => number } -export function createApprovalStore(options?: { +export function createApprovalStore(options?: { /** How long a proposal stays valid, 300000 ms (5 minutes) by default. */ ttlMs?: number /** The most pending proposals to hold at once, 1000 by default. */ @@ -44,14 +52,21 @@ export function createApprovalStore(options?: { now?: () => number /** An id source, for tests. */ newId?: () => string -}): ApprovalStore { +}): ApprovalStore { const ttlMs = options?.ttlMs ?? 300_000 const maxPending = options?.maxPending ?? 1000 + // A NaN or infinite `ttlMs` gives an expiry that no clock passes, and a NaN + // `maxPending` never bounds the map. Refuse both at construction. + if (!Number.isFinite(ttlMs) || ttlMs <= 0 || !(maxPending >= 1)) { + throw new RangeError( + `ttlMs must be a finite, positive number and maxPending at least 1, got ${ttlMs} and ${maxPending}`, + ) + } const now = options?.now ?? (() => Date.now()) const newId = options?.newId ?? (() => randomUUID()) - const proposals = new Map() + const proposals = new Map>() - // Drop every proposal past its expiry. Called on each store operation so an + // Drop every proposal past its expiry. Called on each `propose` so an // unconfirmed proposal cannot pin its `run` closure (args, context) forever. const pruneExpired = () => { const at = now() @@ -76,7 +91,7 @@ export function createApprovalStore(options?: { return { status: 'approval_required', proposalId, summary, expiresAt } }, - confirm: async (proposalId, owner) => { + confirm: async (proposalId, owner, context) => { const proposal = proposals.get(proposalId) // Do not tell a caller whether an id exists for another owner. if (proposal === undefined || proposal.owner !== owner) { @@ -92,7 +107,7 @@ export function createApprovalStore(options?: { // Single-use: remove before running, so a failed action cannot be // retried by replaying the same id. proposals.delete(proposalId) - return proposal.run() + return proposal.run(context) }, pendingCount: () => { diff --git a/packages/ai-secure-mcp/src/audit.ts b/packages/ai-secure-mcp/src/audit.ts index 7bf8a0b5d2..4ced49c5f1 100644 --- a/packages/ai-secure-mcp/src/audit.ts +++ b/packages/ai-secure-mcp/src/audit.ts @@ -7,7 +7,10 @@ import { } from 'node:fs/promises' import { dirname } from 'node:path' -/** One line of the audit log. Secrets and tokens are never present. */ +/** + * One line of the audit log. The bearer token is never present. Args are + * redacted by field name, see `redactArgs`. + */ export interface AuditEntry { /** The client id, or undefined for an unauthenticated attempt. */ client?: string @@ -59,10 +62,13 @@ export interface AuditLog { /** * An append-only JSONL audit log. Each line is one event with a timestamp and - * redacted args. On start it drops lines older than `retentionDays`. + * redacted args. The first `record` after the process starts drops lines + * older than `retentionDays`. It is not a rolling retention: a long-running + * server prunes once. * * @param options.path - The JSONL file to append to - * @param options.retentionDays - Days to keep; older lines are pruned on start + * @param options.retentionDays - Days to keep; older lines are pruned once, + * on the first `record` * @param options.now - A clock in ms, for tests */ export function createAuditLog(options: { @@ -113,12 +119,17 @@ export function createAuditLog(options: { // Prune and ensure the directory once, lazily on the first `record`. Running // init eagerly here would leave its rejection unhandled until a later // `record` awaits it, which can crash the process on Node's default handler. - // A failure is preserved and surfaced to the caller of `record`. + // A failure is surfaced to the caller of `record` and not kept, so the next + // `record` tries again: a full disk during the prune must not turn the log + // off until restart. let ready: Promise | undefined return { record: async (entry) => { - ready ??= init() + ready ??= init().catch((error: unknown) => { + ready = undefined + throw error + }) await ready const line = JSON.stringify({ time: now(), diff --git a/packages/ai-secure-mcp/src/clients-file.ts b/packages/ai-secure-mcp/src/clients-file.ts index 6177c4c208..fd92c5336b 100644 --- a/packages/ai-secure-mcp/src/clients-file.ts +++ b/packages/ai-secure-mcp/src/clients-file.ts @@ -6,31 +6,49 @@ function isRecord(value: unknown): value is Record { return typeof value === 'object' && value !== null } +const KNOWN_KEYS = new Set([ + 'id', + 'tokenHash', + 'scopes', + 'targets', + 'expiresAt', +]) + +function isStrings(value: unknown): value is Array { + return Array.isArray(value) && value.every((v) => typeof v === 'string') +} + function toClient(value: unknown, index: number): ClientRecord { if ( !isRecord(value) || typeof value.id !== 'string' || typeof value.tokenHash !== 'string' || - !Array.isArray(value.scopes) + !isStrings(value.scopes) ) { throw new SecureMcpError( 'invalid_input', - `Client at index ${index} needs id, tokenHash, and scopes.`, + `Client at index ${index} needs id, tokenHash, and scopes (an array of strings).`, + ) + } + // A misspelt `targets` or `expiresAt` (`target`, `expires_at`) would be + // ignored, and the token would reach every target and never expire. + const unknown = Object.keys(value).filter((key) => !KNOWN_KEYS.has(key)) + if (unknown.length > 0) { + throw new SecureMcpError( + 'invalid_input', + `Client at index ${index} has unknown keys: ${unknown.join(', ')}.`, ) } const client: ClientRecord = { id: value.id, tokenHash: value.tokenHash, - scopes: value.scopes.filter((s): s is string => typeof s === 'string'), + scopes: value.scopes, } // A present `targets` must be an array of strings. A malformed value is // rejected, never silently dropped: dropping it would widen the token's reach // to every target instead of the intended restriction. if (value.targets !== undefined) { - if ( - !Array.isArray(value.targets) || - !value.targets.every((t) => typeof t === 'string') - ) { + if (!isStrings(value.targets)) { throw new SecureMcpError( 'invalid_input', `Client at index ${index} has a "targets" that is not an array of strings.`, diff --git a/packages/ai-secure-mcp/src/egress.ts b/packages/ai-secure-mcp/src/egress.ts index e880bce2ca..9f93bfdc01 100644 --- a/packages/ai-secure-mcp/src/egress.ts +++ b/packages/ai-secure-mcp/src/egress.ts @@ -16,7 +16,9 @@ export type EgressFetch = (url: string, init?: RequestInit) => Promise * or timeout becomes `backend_unavailable`. The HTTP status passes through, so * the tool decides what a 404 or 500 means. * - * @param options.allow - The allowed origins, for example `https://api.hue.local` + * @param options.allow - The allowed origins, for example `https://api.hue.local`. + * Each entry is an `http` or `https` origin with no path, query, or + * credentials. Wildcards are not supported. * @param options.timeoutMs - The per-request timeout, 10000 ms by default * @param options.onDenied - Runs when an origin is refused, for audit and notify * @param options.fetch - The fetch to use, the global `fetch` by default @@ -29,14 +31,32 @@ export function createEgress(options: { }): EgressFetch { const allowed = new Set() for (const entry of options.allow) { + let parsed: URL | undefined try { - allowed.add(new URL(entry).origin) + parsed = new URL(entry) } catch { + // Refused below. + } + // An entry with no scheme, such as `localhost:8080`, parses with the host + // as the scheme and the origin `"null"`. Every `data:` and `file:` URL has + // that origin too, so accepting it would allow them all. A path or query + // is refused as well: only the origin is matched, so it would be dropped + // and the whole origin allowed. + if ( + parsed === undefined || + (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') || + parsed.pathname !== '/' || + parsed.search !== '' || + parsed.hash !== '' || + parsed.username !== '' || + parsed.password !== '' + ) { throw new SecureMcpError( 'invalid_input', - `Egress allowlist entry is not a URL: ${entry}`, + `Egress allowlist entry must be an http(s) origin such as https://api.example.com, got: ${entry}`, ) } + allowed.add(parsed.origin) } const timeoutMs = options.timeoutMs ?? 10_000 const fetchImpl = options.fetch ?? fetch diff --git a/packages/ai-secure-mcp/src/guard.ts b/packages/ai-secure-mcp/src/guard.ts index fe792d5949..9074e6749a 100644 --- a/packages/ai-secure-mcp/src/guard.ts +++ b/packages/ai-secure-mcp/src/guard.ts @@ -19,9 +19,14 @@ export interface SecureRequestContext { egress: EgressFetch } +/** The tool context a guarded call receives. */ +export type GuardContext = + | ToolExecutionContext + | undefined + interface GuardDeps { policy: AccessPolicy - approvals: ApprovalStore + approvals: ApprovalStore audit?: AuditLog notify: SecurityNotifier summarize: (toolName: string, args: unknown) => string @@ -32,9 +37,7 @@ function isRecord(value: unknown): value is Record { } /** Reads the verified client the outer fetch injected into the tool context. */ -function readClient( - context: ToolExecutionContext | undefined, -): ClientRecord { +function readClient(context: GuardContext): ClientRecord { // Typed as present, but a misuse could still leave it out at runtime. const client = context?.context?.secure?.client if (client === undefined) { @@ -48,25 +51,51 @@ function readClient( /** * Wraps each tool with the access guard: scope, then target allowlist, then - * two-phase approval, then the call. Every outcome is audited. A refusal also - * pings the notifier. + * two-phase approval, then the call. Each outcome is recorded when an audit + * log is set. A refusal also pings the notifier. + * + * It throws `invalid_input` when the policy names a tool that is not in + * `tools`, or a tool has no `execute`. A misspelt name would otherwise leave + * the real tool with no scope check and no approval. */ export function guardTools( tools: ReadonlyArray, deps: GuardDeps, ): Array { + const names = new Set(tools.map((tool) => tool.name)) + const unknown = [ + ...Object.keys(deps.policy.scopes ?? {}), + ...Object.keys(deps.policy.targetParam ?? {}), + ...(deps.policy.approve ?? []), + ].filter((name) => !names.has(name)) + if (unknown.length > 0) { + throw new SecureMcpError( + 'invalid_input', + `The policy names tools that are not in \`tools\`: ${[...new Set(unknown)].join(', ')}.`, + ) + } return tools.map((tool) => { const original = tool.execute + if (original === undefined) { + throw new SecureMcpError( + 'invalid_input', + `Tool "${tool.name}" has no execute function.`, + ) + } const execute = async ( args: unknown, context?: ToolExecutionContext, ): Promise => { const client = readClient(context) - const runAndAudit = async (): Promise => { + // `runContext` is the context of the call that runs the action. For an + // approved tool that is the confirm call, not the propose call. + const runAndAudit = async ( + runContext: GuardContext, + ): Promise => { let result: unknown try { - result = await original?.(args, context) + result = await original(args, runContext) } catch (error) { await deps.audit?.record({ client: client.id, @@ -108,7 +137,9 @@ export function guardTools( const targetField = deps.policy.targetParam?.[tool.name] if (targetField !== undefined && client.targets !== undefined) { const value = isRecord(args) ? args[targetField] : undefined - if (!client.targets.includes(String(value))) { + // Only a string can name a target. `String(['kitchen'])` is + // `'kitchen'`, so a coerced array would pass the list. + if (typeof value !== 'string' || !client.targets.includes(value)) { return refuse( deps, client, @@ -144,7 +175,7 @@ export function guardTools( return envelope } - return runAndAudit() + return runAndAudit(context) } // An approval-gated tool returns the `approval_required` envelope on the // first call, not its own output shape. Keeping an `outputSchema` would make @@ -166,6 +197,8 @@ async function refuse( code: 'forbidden_scope', message: string, ): Promise { + // Notify first: a failing audit write must not silence the tripwire. + void deps.notify.notify({ kind: 'forbidden_scope', client: client.id, tool }) await deps.audit?.record({ client: client.id, event: 'tool_call', @@ -174,16 +207,16 @@ async function refuse( code, args, }) - void deps.notify.notify({ kind: 'forbidden_scope', client: client.id, tool }) throw new SecureMcpError(code, message) } /** * Builds the `approve_proposal` tool. A client confirms its own pending - * proposal by id; the stored action then runs host-side. + * proposal by id; the stored action then runs host-side, with the context of + * this confirm call. */ export function createConfirmTool(deps: { - approvals: ApprovalStore + approvals: ApprovalStore audit?: AuditLog }): AnyServerTool { const tool: AnyServerTool = toolDefinition({ @@ -197,13 +230,17 @@ export function createConfirmTool(deps: { }), }).server(async ({ proposalId }, context) => { const client = readClient(context) - const result = await deps.approvals.confirm(proposalId, client.id) - await deps.audit?.record({ - client: client.id, - event: 'approval_confirmed', - outcome: 'ok', - args: { proposalId }, - }) + const result = await deps.approvals.confirm(proposalId, client.id, context) + // The action already ran, and the proposal is spent. If this audit write + // fails, still return the result: the client could not retry. + await deps.audit + ?.record({ + client: client.id, + event: 'approval_confirmed', + outcome: 'ok', + args: { proposalId }, + }) + .catch(() => {}) return { confirmed: true, result } }) return tool diff --git a/packages/ai-secure-mcp/src/notifier.ts b/packages/ai-secure-mcp/src/notifier.ts index e5a2c97a44..f5d037d37c 100644 --- a/packages/ai-secure-mcp/src/notifier.ts +++ b/packages/ai-secure-mcp/src/notifier.ts @@ -141,6 +141,11 @@ export function debounceNotifier( : '' const key = `${event.kind}:${id ?? ''}` const at = now() + // Drop keys past their window. Each proposal adds a key of its own, so + // without this the map grows for the life of the process. + for (const [sentKey, sentAt] of lastSent) { + if (at - sentAt >= windowMs) lastSent.delete(sentKey) + } const prev = lastSent.get(key) if (prev !== undefined && at - prev < windowMs) return lastSent.set(key, at) diff --git a/packages/ai-secure-mcp/src/rate-limit.ts b/packages/ai-secure-mcp/src/rate-limit.ts index 08a931d147..36417e1fd6 100644 --- a/packages/ai-secure-mcp/src/rate-limit.ts +++ b/packages/ai-secure-mcp/src/rate-limit.ts @@ -18,6 +18,17 @@ export function createRateLimiter(options: { /** A clock in ms, for tests. */ now?: () => number }): RateLimiter { + // A NaN limit or window makes every comparison false, so nothing is ever + // limited. Refuse it at construction; use `rateLimit: false` to turn it off. + if ( + !(options.limit > 0) || + !Number.isFinite(options.windowMs) || + options.windowMs <= 0 + ) { + throw new RangeError( + `limit must be positive and windowMs finite and positive, got ${options.limit} and ${options.windowMs}`, + ) + } const hits = new Map>() const now = options.now ?? (() => Date.now()) return { diff --git a/packages/ai-secure-mcp/src/server.ts b/packages/ai-secure-mcp/src/server.ts index dcd31960d8..3a87ae1473 100644 --- a/packages/ai-secure-mcp/src/server.ts +++ b/packages/ai-secure-mcp/src/server.ts @@ -13,6 +13,7 @@ import type { AnyServerTool } from '@tanstack/ai' import type { SampleRequest } from '@tanstack/ai-mcp/server' import type { AuditLog } from './audit' import type { PreflightResult } from './deploy' +import type { GuardContext } from './guard' import type { AccessPolicy, ClientRecord, SecurityNotifier } from './types' /** Config for {@link createSecureMcpServer}. */ @@ -23,7 +24,10 @@ export interface SecureMcpConfig { tools: ReadonlyArray /** The known clients, by token hash. See `hashToken` and `clientsFromFile`. */ clients: ReadonlyArray - /** The egress allowlist. Without it, no tool can reach the network. */ + /** + * The allowlist for `ctx.context.egress`. Without it, that helper refuses + * every origin. It does not stop a tool that calls global `fetch`. + */ egress?: | ReadonlyArray | { allow: ReadonlyArray; timeoutMs?: number } @@ -31,7 +35,10 @@ export interface SecureMcpConfig { policy?: AccessPolicy /** Sliding-window rate limit per client. `false` turns it off. */ rateLimit?: { limit: number; windowMs: number } | false - /** Redacted JSONL audit log. `false` turns it off (not recommended). */ + /** + * Redacted JSONL audit log. It is off unless you set it: pass `{ path }` to + * turn it on. A public funnel needs it. + */ audit?: { path: string; retentionDays?: number } | false /** Where to send tripwire events. Defaults to a silent sink. */ notify?: SecurityNotifier @@ -56,8 +63,13 @@ export interface SecureMcpServer { } const FAR_FUTURE = 4_102_444_800 // 2100-01-01, for a token with no expiry -/** The auth failures audited and notified per window. More only get a 401. */ -const AUTH_FAILURE_BUDGET = { limit: 10, windowMs: 60_000 } +/** Above this, an `expiresAt` is milliseconds, not seconds (year 5138). */ +const MAX_EXPIRES_AT = 1e11 +/** + * The auth failures, and the rate-limit refusals per client, that are audited + * and notified per window. More only get the 401 or 429. + */ +const TRIPWIRE_BUDGET = { limit: 10, windowMs: 60_000 } function jsonError(status: number, code: string, headers?: HeadersInit) { return new Response(JSON.stringify({ error: { code } }), { @@ -69,11 +81,14 @@ function jsonError(status: number, code: string, headers?: HeadersInit) { /** * Wraps `createMCPServer` with the security envelope a self-hoster needs to * expose a server to the internet: hashed-token auth, scopes and a target - * allowlist, deny-by-default egress, rate limits, a redacted audit log, a - * tripwire notifier, and two-phase approval. + * allowlist, a deny-by-default egress helper, rate limits, a redacted audit + * log, a tripwire notifier, and two-phase approval. * - * It refuses to go public (`funnel.public`) while the preflight finds a - * problem, such as an unhashed token or egress that is not deny-by-default. + * It throws `invalid_input` when the config cannot be enforced as written: a + * policy that names an unknown tool, a duplicate client id, an `expiresAt` in + * milliseconds, or an egress entry that is not an http(s) origin. It also + * throws when `funnel.public` is set while the preflight finds a problem: no + * clients, a token that is not a SHA-256 hash, audit off, or notifier off. */ export function createSecureMcpServer( config: SecureMcpConfig, @@ -102,8 +117,29 @@ export function createSecureMcpServer( onDenied: (origin) => void notify.notify({ kind: 'egress_denied', origin }), }) + const ids = new Set() + for (const client of config.clients) { + // Two records with one id share a rate-limit bucket and can confirm each + // other's proposals. + if (ids.has(client.id)) { + throw new SecureMcpError( + 'invalid_input', + `Client id "${client.id}" is used more than once.`, + ) + } + ids.add(client.id) + // `expiresAt` is Unix seconds. A value from `Date.now()` is milliseconds + // and would expire in about 50,000 years. + if (client.expiresAt !== undefined && client.expiresAt > MAX_EXPIRES_AT) { + throw new SecureMcpError( + 'invalid_input', + `Client "${client.id}" has an expiresAt in milliseconds. Use Unix seconds.`, + ) + } + } + const policy: AccessPolicy = config.policy ?? {} - const approvals = createApprovalStore(config.approval) + const approvals = createApprovalStore(config.approval) const summarize = config.summarize ?? ((toolName: string) => `Run ${toolName}`) @@ -147,12 +183,13 @@ export function createSecureMcpServer( // An unauthenticated caller has no client id to rate-limit, and each failure // writes to disk and pings the notifier. Only the first failures in each // window are audited and notified, so a scanner cannot fill the disk or - // flood the phone. Every failure still gets a 401. - // ponytail: one global budget, a per-IP budget if one scanner should not - // hide another. - const authFailures = createRateLimiter(AUTH_FAILURE_BUDGET) + // flood the phone. Every failure still gets a 401. A client over its own + // rate limit gets the same budget, keyed by its id. + // ponytail: one global auth budget, a per-IP budget if one scanner should + // not hide another. + const tripwireBudget = createRateLimiter(TRIPWIRE_BUDGET) const denyAuth = async (): Promise => { - if (authFailures.allow('*')) { + if (tripwireBudget.allow('auth_failure')) { void notify.notify({ kind: 'auth_failure' }) await audit?.record({ event: 'auth_failure', outcome: 'denied' }) } @@ -171,12 +208,14 @@ export function createSecureMcpServer( } if (rl !== undefined && !rl.allow(client.id)) { - void notify.notify({ kind: 'rate_limited', client: client.id }) - await audit?.record({ - client: client.id, - event: 'rate_limited', - outcome: 'denied', - }) + if (tripwireBudget.allow(`rate_limited:${client.id}`)) { + void notify.notify({ kind: 'rate_limited', client: client.id }) + await audit?.record({ + client: client.id, + event: 'rate_limited', + outcome: 'denied', + }) + } return jsonError(429, 'rate_limited') } diff --git a/packages/ai-secure-mcp/tests/approval.test.ts b/packages/ai-secure-mcp/tests/approval.test.ts index 7dfe59ad79..a011fb9235 100644 --- a/packages/ai-secure-mcp/tests/approval.test.ts +++ b/packages/ai-secure-mcp/tests/approval.test.ts @@ -90,3 +90,11 @@ describe('createApprovalStore', () => { expect(store.pendingCount()).toBe(2) }) }) + +describe('createApprovalStore — bad numbers', () => { + it('refuses a ttl that would never expire', () => { + expect(() => createApprovalStore({ ttlMs: NaN })).toThrow(RangeError) + expect(() => createApprovalStore({ ttlMs: Infinity })).toThrow(RangeError) + expect(() => createApprovalStore({ maxPending: NaN })).toThrow(RangeError) + }) +}) diff --git a/packages/ai-secure-mcp/tests/clients-file.test.ts b/packages/ai-secure-mcp/tests/clients-file.test.ts index 566cfe269d..8dc12c9d9e 100644 --- a/packages/ai-secure-mcp/tests/clients-file.test.ts +++ b/packages/ai-secure-mcp/tests/clients-file.test.ts @@ -71,3 +71,21 @@ describe('clientsFromFile', () => { }) }) }) + +describe('clientsFromFile — keys it does not know', () => { + it('rejects a misspelt key instead of dropping the restriction', async () => { + for (const extra of [{ target: ['den'] }, { expires_at: 1700000000 }]) { + const path = await writeClients([{ ...base, ...extra }]) + await expect(clientsFromFile(path)).rejects.toMatchObject({ + code: 'invalid_input', + }) + } + }) + + it('rejects a scopes array that holds a non-string', async () => { + const path = await writeClients([{ ...base, scopes: ['read', 1] }]) + await expect(clientsFromFile(path)).rejects.toMatchObject({ + code: 'invalid_input', + }) + }) +}) diff --git a/packages/ai-secure-mcp/tests/egress.test.ts b/packages/ai-secure-mcp/tests/egress.test.ts index 6d97efbacb..60d70608b1 100644 --- a/packages/ai-secure-mcp/tests/egress.test.ts +++ b/packages/ai-secure-mcp/tests/egress.test.ts @@ -142,3 +142,35 @@ describe('createEgress', () => { expect(await res.text()).toBe('hello') }) }) + +describe('createEgress — allowlist entries', () => { + it('refuses an entry that is not an http(s) origin', () => { + // `localhost:8080` parses with the origin "null", which is also the origin + // of every `data:` and `file:` URL. A path or query would be dropped. + for (const entry of [ + 'localhost:8080', + 'api.hue.local:443', + 'file:///etc', + 'https://api.hue.local/v1', + 'https://api.hue.local?x=1', + 'https://user@api.hue.local', + ]) { + expect(() => createEgress({ allow: [entry] }), entry).toThrow( + SecureMcpError, + ) + } + expect(() => + createEgress({ allow: ['https://api.hue.local/', 'http://[::1]:8080'] }), + ).not.toThrow() + }) + + it('refuses an opaque-origin URL', async () => { + const egress = createEgress({ + allow: ['https://api.hue.local'], + fetch: async () => new Response('should not run'), + }) + await expect(egress('data:text/plain,hi')).rejects.toMatchObject({ + code: 'egress_denied', + }) + }) +}) diff --git a/packages/ai-secure-mcp/tests/guard.test.ts b/packages/ai-secure-mcp/tests/guard.test.ts index 7c4cfc6b26..34e7eb26fa 100644 --- a/packages/ai-secure-mcp/tests/guard.test.ts +++ b/packages/ai-secure-mcp/tests/guard.test.ts @@ -5,7 +5,7 @@ import { createApprovalStore } from '../src/approval' import { createConfirmTool, guardTools } from '../src/guard' import type { ApprovalRequired } from '../src/approval' import type { AuditEntry, AuditLog } from '../src/audit' -import type { SecureRequestContext } from '../src/guard' +import type { GuardContext, SecureRequestContext } from '../src/guard' import type { AccessPolicy, ClientRecord, @@ -48,7 +48,7 @@ const buyMovie = toolDefinition({ function setup(policy: AccessPolicy) { const notify = capturingNotifier() const audit = capturingAudit() - const approvals = createApprovalStore({ newId: () => 'prop-1' }) + const approvals = createApprovalStore({ newId: () => 'prop-1' }) const [guardedLights, guardedMovie] = guardTools([setLights, buyMovie], { policy, approvals, @@ -165,7 +165,9 @@ describe('guardTools — two-phase approval', () => { }) const notify = capturingNotifier() const audit = capturingAudit() - const approvals = createApprovalStore({ newId: () => 'prop-1' }) + const approvals = createApprovalStore({ + newId: () => 'prop-1', + }) const [guarded] = guardTools([failing], { policy: { approve: ['buyMovie'] }, approvals, @@ -197,7 +199,7 @@ describe('guardTools — two-phase approval', () => { }).server(async ({ movieId }) => ({ bought: movieId })) const [guarded] = guardTools([withSchema], { policy: { approve: ['buyMovie'] }, - approvals: createApprovalStore(), + approvals: createApprovalStore(), notify: capturingNotifier(), summarize: () => 's', }) @@ -218,7 +220,7 @@ describe('guardTools — audit failure after the call', () => { }).server(async () => ({ calls: ++calls })) const [guarded] = guardTools([counted], { policy: {}, - approvals: createApprovalStore(), + approvals: createApprovalStore(), audit: { record: async () => { throw new Error('disk full') @@ -233,3 +235,80 @@ describe('guardTools — audit failure after the call', () => { expect(calls).toBe(1) }) }) + +describe('guardTools — config that cannot be enforced', () => { + it('refuses a policy that names an unknown tool', () => { + // A misspelt name would leave the real tool with no scope and no approval. + for (const policy of [ + { scopes: { setLight: 'control' } }, + { targetParam: { setLight: 'room' } }, + { approve: ['buyMovei'] }, + ] satisfies Array) { + expect(() => setup(policy)).toThrow(/not in `tools`/) + } + }) + + it('refuses a target that is not a string', async () => { + const { guardedLights } = setup({ targetParam: { setLights: 'room' } }) + // `String(['living-room'])` is `'living-room'`, so a coerced value passes. + await expect( + guardedLights!.execute!( + { room: ['living-room'], on: true }, + contextFor({ ...control, targets: ['living-room'] }), + ), + ).rejects.toMatchObject({ code: 'forbidden_scope' }) + }) +}) + +describe('approve_proposal — the confirm call', () => { + function gated(audit?: AuditLog) { + const seen: Array = [] + const tool = toolDefinition({ + name: 'buyMovie', + description: 'Buy a movie', + inputSchema: z.object({ movieId: z.string() }), + }).server(async (_args, context) => { + seen.push(context) + return { bought: true } + }) + const approvals = createApprovalStore({ + newId: () => 'prop-1', + }) + const [guarded] = guardTools([tool], { + policy: { approve: ['buyMovie'] }, + approvals, + notify: capturingNotifier(), + summarize: () => 's', + }) + return { seen, guarded, confirm: createConfirmTool({ approvals, audit }) } + } + + it('runs the action once, with the context of the confirm call', async () => { + const { seen, guarded, confirm } = gated() + await guarded!.execute!({ movieId: 'tt1' }, contextFor(control)) + // Nothing runs at propose time. + expect(seen).toEqual([]) + + const confirmContext = contextFor(control) + await confirm.execute!({ proposalId: 'prop-1' }, confirmContext) + // The propose request has ended; its signal and hooks are dead. + expect(seen).toEqual([confirmContext]) + + await expect( + confirm.execute!({ proposalId: 'prop-1' }, confirmContext), + ).rejects.toMatchObject({ code: 'not_found' }) + expect(seen).toHaveLength(1) + }) + + it('returns the result when the confirm audit write fails', async () => { + const { guarded, confirm } = gated({ + record: async () => { + throw new Error('disk full') + }, + }) + await guarded!.execute!({ movieId: 'tt1' }, contextFor(control)) + await expect( + confirm.execute!({ proposalId: 'prop-1' }, contextFor(control)), + ).resolves.toEqual({ confirmed: true, result: { bought: true } }) + }) +}) diff --git a/packages/ai-secure-mcp/tests/rate-limit.test.ts b/packages/ai-secure-mcp/tests/rate-limit.test.ts index 0f6a4a84fc..82b064231e 100644 --- a/packages/ai-secure-mcp/tests/rate-limit.test.ts +++ b/packages/ai-secure-mcp/tests/rate-limit.test.ts @@ -20,3 +20,18 @@ describe('createRateLimiter', () => { expect(rl.allow('a')).toBe(false) }) }) + +describe('createRateLimiter — bad numbers', () => { + it('refuses a limit or window that would turn the limiter off', () => { + // `Number(process.env.RATE_LIMIT)` with the variable unset is NaN. + expect(() => createRateLimiter({ limit: NaN, windowMs: 1000 })).toThrow( + RangeError, + ) + expect(() => createRateLimiter({ limit: 1, windowMs: NaN })).toThrow( + RangeError, + ) + expect(() => createRateLimiter({ limit: 1, windowMs: -1 })).toThrow( + RangeError, + ) + }) +}) diff --git a/packages/ai-secure-mcp/tests/server.test.ts b/packages/ai-secure-mcp/tests/server.test.ts index cd53594f2e..4c3b89977f 100644 --- a/packages/ai-secure-mcp/tests/server.test.ts +++ b/packages/ai-secure-mcp/tests/server.test.ts @@ -143,3 +143,72 @@ describe('createSecureMcpServer — auth failure flood', () => { expect(events).toHaveLength(10) }) }) + +describe('createSecureMcpServer — config it refuses', () => { + it('refuses a duplicate client id', () => { + const twin = { ...alice, tokenHash: hashToken('other-token') } + expect(() => + createSecureMcpServer({ ...base(), clients: [alice, twin] }), + ).toThrow(/more than once/) + }) + + it('refuses an expiresAt in milliseconds', () => { + expect(() => + createSecureMcpServer({ + ...base(), + clients: [{ ...alice, expiresAt: Date.now() + 60_000 }], + }), + ).toThrow(/Unix seconds/) + }) + + it('refuses a policy that names an unknown tool', () => { + expect(() => + createSecureMcpServer({ + ...base(), + policy: { scopes: { pong: 'read' } }, + }), + ).toThrow(/not in `tools`/) + }) +}) + +describe('createSecureMcpServer — a real tool call', () => { + function call(token: string, name: string) { + return new Request('https://mcp.local/', { + method: 'POST', + headers: { + 'content-type': 'application/json', + accept: 'application/json, text/event-stream', + authorization: `Bearer ${token}`, + }, + body: JSON.stringify({ + jsonrpc: '2.0', + id: 1, + method: 'tools/call', + params: { name, arguments: {} }, + }), + }) + } + + it('runs a tool for a client with the scope, and refuses one without', async () => { + const bob: ClientRecord = { + id: 'bob', + tokenHash: hashToken('bob-token'), + scopes: [], + } + const server = createSecureMcpServer({ + ...base(), + clients: [alice, bob], + policy: { scopes: { ping: 'read' } }, + }) + // The guard reads the client the envelope put in the tool context, so + // this fails if the context does not reach the tool. + const ok = await server.fetch(call('alice-token', 'ping')) + expect(ok.status).toBe(200) + expect(await ok.text()).toContain('"structuredContent":{"pong":true}') + + const denied = await server.fetch(call('bob-token', 'ping')) + const body = await denied.text() + expect(body).toContain('"isError":true') + expect(body).not.toContain('pong') + }) +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ccebb1e01c..8eae3fd6ee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3181,18 +3181,23 @@ importers: version: 4.103.0(@cloudflare/workers-types@4.20260317.1) packages/ai-isolate-daytona: + dependencies: + '@tanstack/ai-isolate': + specifier: workspace:^ + version: link:../ai-isolate devDependencies: '@daytona/sdk': specifier: ^0.192.0 version: 0.192.0(supports-color@7.2.0)(ws@8.21.0) - '@tanstack/ai-isolate': - specifier: workspace:* - version: link:../ai-isolate '@vitest/coverage-v8': specifier: 4.1.12 version: 4.1.12(vitest@4.1.12) packages/ai-isolate-e2b: + dependencies: + '@tanstack/ai-isolate': + specifier: workspace:^ + version: link:../ai-isolate devDependencies: '@tanstack/ai': specifier: workspace:* @@ -3200,9 +3205,6 @@ importers: '@tanstack/ai-code-mode': specifier: workspace:* version: link:../ai-code-mode - '@tanstack/ai-isolate': - specifier: workspace:* - version: link:../ai-isolate '@vitest/coverage-v8': specifier: 4.1.12 version: 4.1.12(vitest@4.1.12) @@ -11500,9 +11502,7 @@ packages: '@smithy/core@3.26.0': resolution: {integrity: sha512-mLUktFAn+Pa2agl1J7VgtYNFWCX8/b4GMJSK1hCu4YCvtBfM6F8Os3EP4ry+DFFlXOf3wyvlgXhuUdFoy52D3g==} engines: {node: '>=18.0.0'} - deprecated: |- - Deprecated due to a bug in custom logger data redaction. Upgrade to the latest version. If you used a custom logger with this - version, review your logs and rotate any credentials or other secrets. See https://github.com/aws/aws-sdk-js-v3/issues/8393. + deprecated: Deprecated due to a bug in custom logger data redaction. See https://github.com/aws/aws-sdk-js-v3/issues/8393. '@smithy/credential-provider-imds@4.4.2': resolution: {integrity: sha512-18UMDMyrAbDcpmL1gLUA7ww0fRTcdCrSjSJOi2Sbld+tVjwD/pW+OAwjlScFLR7vvBnhZrIPQ7kVuTf1mnJLug==} From 9ace51839c4bcde35da21456eae2068cb29d279f Mon Sep 17 00:00:00 2001 From: Tom Beckenham <34339192+tombeckenham@users.noreply.github.com> Date: Sat, 21 Nov 2026 17:04:50 +1100 Subject: [PATCH 14/14] chore(isolate): drop the duplicate ai-isolate devDependency in e2b and daytona It is a regular dependency now, so knip reports the devDependency as unused. --- packages/ai-isolate-daytona/package.json | 1 - packages/ai-isolate-e2b/package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/ai-isolate-daytona/package.json b/packages/ai-isolate-daytona/package.json index 63e9173c90..9543bb9d88 100644 --- a/packages/ai-isolate-daytona/package.json +++ b/packages/ai-isolate-daytona/package.json @@ -54,7 +54,6 @@ }, "devDependencies": { "@daytona/sdk": "^0.192.0", - "@tanstack/ai-isolate": "workspace:*", "@vitest/coverage-v8": "4.1.12" } } diff --git a/packages/ai-isolate-e2b/package.json b/packages/ai-isolate-e2b/package.json index 5907afbd41..d9c876a0c3 100644 --- a/packages/ai-isolate-e2b/package.json +++ b/packages/ai-isolate-e2b/package.json @@ -55,7 +55,6 @@ "devDependencies": { "@tanstack/ai": "workspace:*", "@tanstack/ai-code-mode": "workspace:*", - "@tanstack/ai-isolate": "workspace:*", "@vitest/coverage-v8": "4.1.12", "e2b": "^2.46.1", "zod": "^4.2.0"