{"_id":"@agentkit-js/aisdk","_rev":"3-ae4e44285d9356ffb971e29ca931684f","name":"@agentkit-js/aisdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@agentkit-js/aisdk","version":"0.1.0","keywords":["ai-sdk","vercel","agent","sandbox","code-execution","tool","agentkit"],"author":{"name":"agentkit-js contributors"},"license":"Apache-2.0","_id":"@agentkit-js/aisdk@0.1.0","maintainers":[{"name":"tellerlin","email":"lintao_mailbox@163.com"}],"homepage":"https://github.com/telleroutlook/agentkit-js/tree/main/packages/aisdk#readme","bugs":{"url":"https://github.com/telleroutlook/agentkit-js/issues"},"dist":{"shasum":"d56da34edee17d92be91dcb6459d20bbf2026427","tarball":"https://registry.npmjs.org/@agentkit-js/aisdk/-/aisdk-0.1.0.tgz","fileCount":15,"integrity":"sha512-AkHu1FcyC82HP2p+Y9Tve91oIHLWwqMBYQ/pvLWA7wf3Ez2nqxafZWWGAPU/nAQHndCHf8f+iGHd38poZrAKYg==","signatures":[{"sig":"MEQCIHSO3dyz8aeNtZrliYJIpPS8vYEebk00k/YbLJRMaw1jAiBqFDwBOLXwYzyZ0HxBOKPjbHjH8Urbk7FmW1kwJn6rXA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@agentkit-js%2faisdk@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":63249},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"c629f75b91a8855e107cb0130c858b10e8ea6e79","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","clean":"rm -rf dist .turbo","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"tellerlin","email":"lintao_mailbox@163.com"},"deprecated":"This package has moved to @wasmagent/aisdk. Please update your dependency.","repository":{"url":"git+https://github.com/telleroutlook/agentkit-js.git","type":"git","directory":"packages/aisdk"},"_npmVersion":"10.9.8","description":"Drop agentkit-js sandbox kernels into the Vercel AI SDK as a `tool()` — edge-safe code execution with one capability manifest, no E2B / OS sandbox needed","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@agentkit-js/core":"workspace:*"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"ai":"^4.0.0","zod":"^3.22.0","vitest":"^2.1.0","typescript":"^5.7.0","@types/node":"^22.0.0"},"peerDependencies":{"ai":"^4.0.0 || ^5.0.0 || ^6.0.0","zod":"^3.22.0 || ^4.0.0"},"peerDependenciesMeta":{"ai":{"optional":false},"zod":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/aisdk_0.1.0_1781508321304_0.03812742866407848","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-06-15T07:25:21.033Z","modified":"2026-07-04T01:07:18.851Z","0.1.0":"2026-06-15T07:25:21.425Z"},"bugs":{"url":"https://github.com/telleroutlook/agentkit-js/issues"},"author":{"name":"agentkit-js contributors"},"license":"Apache-2.0","homepage":"https://github.com/telleroutlook/agentkit-js/tree/main/packages/aisdk#readme","keywords":["ai-sdk","vercel","agent","sandbox","code-execution","tool","agentkit"],"repository":{"url":"git+https://github.com/telleroutlook/agentkit-js.git","type":"git","directory":"packages/aisdk"},"description":"Drop agentkit-js sandbox kernels into the Vercel AI SDK as a `tool()` — edge-safe code execution with one capability manifest, no E2B / OS sandbox needed","maintainers":[{"email":"lintao_mailbox@163.com","name":"tellerlin"},{"email":"hyin.sybase@gmail.com","name":"haining-yin"}],"readme":"# @agentkit-js/aisdk\n\n> Drop agentkit-js sandbox kernels into the **Vercel AI SDK** as a `tool()`.\n> Edge-safe code execution, one capability manifest, no E2B / OS sandbox needed.\n\n[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/telleroutlook/agentkit-js/tree/main/examples/aisdk-quickjs?file=index.mjs)\n\n## Why this exists\n\nVercel AI SDK 6 has world-class React DX, streaming UI primitives, and\ndefault placement in every Next.js template. What it does NOT have is a way\nto run model-generated code inside a real sandbox on the edge. `node:vm` is\nforbidden on Cloudflare Workers and Vercel Edge; OS-level sandboxes (E2B,\nDaytona, Blaxel) need a server you don't have.\n\nagentkit's WASM kernels run JavaScript inside QuickJS-in-WASM\n(`@agentkit-js/kernel-quickjs`) — language-level isolation, no `node:vm`,\n~2 MB cold start. Perfect fill for that gap.\n\n## Compared to E2B / Blaxel\n\n|              | WASM kernel (`QuickJSKernel`) | E2B / Blaxel sandbox |\n| ------------ | ----------------------------- | -------------------- |\n| Cold start   | ~50 ms                        | 200–800 ms           |\n| Cost / call  | $0 (in-process)               | per-second billing   |\n| Isolation    | Language-level (V8 → QuickJS) | Process / firecracker |\n| Network      | Capability-gated `fetch`       | Full networking       |\n| Workers safe | ✅                             | ❌ (needs server)     |\n| File system  | Capability-gated `__fs__`      | Full POSIX            |\n\nUse the WASM kernel when \"model wrote a snippet to do math / parse JSON / try\nsomething\" is the workload. Use E2B/Blaxel when you need full POSIX, native\nbinaries, or untrusted multi-tenant isolation.\n\n## Install\n\n```bash\nnpm install ai @ai-sdk/openai @agentkit-js/aisdk @agentkit-js/kernel-quickjs \\\n  quickjs-emscripten @jitl/quickjs-wasmfile-release-sync zod\n```\n\n## One-shot snippet evaluation\n\n```ts\nimport { generateText } from \"ai\";\nimport { openai } from \"@ai-sdk/openai\";\nimport { sandboxedJsTool } from \"@agentkit-js/aisdk\";\nimport { QuickJSKernel } from \"@agentkit-js/kernel-quickjs\";\n\nconst kernel = new QuickJSKernel();\n\nconst { text } = await generateText({\n  model: openai(\"gpt-4o\"),\n  tools: {\n    runJs: sandboxedJsTool({\n      kernel,\n      capabilities: { allowedHosts: [\"api.example.com\"] },\n    }),\n  },\n  prompt: \"Compute the 12th Fibonacci number using the runJs tool.\",\n});\n```\n\n## Code-mode: collapse N tools behind one `execute_code`\n\n```ts\nimport { generateText } from \"ai\";\nimport { openai } from \"@ai-sdk/openai\";\nimport { codeModeTool } from \"@agentkit-js/aisdk\";\nimport { QuickJSKernel } from \"@agentkit-js/kernel-quickjs\";\nimport { ToolRegistry } from \"@agentkit-js/core\";\nimport { z } from \"zod\";\n\nconst tools = new ToolRegistry();\ntools.register({\n  name: \"search_docs\",\n  description: \"Search the docs corpus.\",\n  inputSchema: z.object({ query: z.string() }),\n  outputSchema: z.array(z.string()),\n  readOnly: true,\n  idempotent: true,\n  forward: async ({ query }) => searchDocs(query),\n});\n// …40 more tools…\n\nconst kernel = new QuickJSKernel();\n\nconst { text } = await generateText({\n  model: openai(\"gpt-4o\"),\n  tools: {\n    execute_code: codeModeTool({\n      kernel,\n      tools,\n      capabilities: {\n        cpuMs: 5_000,\n        memoryLimitBytes: 64 * 1024 * 1024,\n      },\n    }),\n  },\n  prompt: \"Find the three docs that mention 'cache invalidation' and summarise.\",\n});\n```\n\nThe model sees one tool, not forty. The script inside calls `callTool(...)`\nN times; only the script's return value re-enters the model context.\n\n## Capability manifest\n\nEvery kernel honours the same `CapabilityManifest`:\n\n| Field               | What it gates                                |\n| ------------------- | -------------------------------------------- |\n| `allowedHosts`      | Outbound `fetch()` (glob host allow-list)    |\n| `allowedReadPaths`  | `__fs__.readFile(path)`                      |\n| `allowedWritePaths` | `__fs__.writeFile(path, data)`               |\n| `env`               | Frozen `__env__` map exposed inside sandbox  |\n| `cpuMs`             | Per-call timeout (tightens kernel default)   |\n| `memoryLimitBytes`  | Hard runtime memory cap (where supported)    |\n\nSee [the unified policy face docs](https://github.com/telleroutlook/agentkit-js/blob/main/docs/guides/code-mode.md#security-policy-face)\nfor the per-kernel honouring matrix.\n\n## See also\n\n- [`docs/guides/code-mode.md`](https://github.com/telleroutlook/agentkit-js/blob/main/docs/guides/code-mode.md)\n  — the same code-mode pattern as a standalone MCP server.\n- [`@agentkit-js/mastra-sandbox`](https://www.npmjs.com/package/@agentkit-js/mastra-sandbox)\n  — the same kernels as a Mastra sandbox provider.\n\n## Memory tool (D3, 2026-06-13)\n\nCross-session memory backed by any `KvBackend` (Cloudflare KV, Redis,\nin-memory Map, …) — same primitive as `createMemoryTool` in\n`@agentkit-js/core`, exposed as a Vercel AI SDK `tool()`:\n\n```ts\nimport { generateText } from \"ai\";\nimport { memoryTool } from \"@agentkit-js/aisdk\";\nimport { MapKvBackend } from \"@agentkit-js/core\";\n\nawait generateText({\n  model: openai(\"gpt-4o-mini\"),\n  tools: { memory: memoryTool({ backend: new MapKvBackend() }) },\n  prompt: \"Remember that the user's preferred CSV delimiter is `;`.\",\n});\n```\n\nThe same `memoryTool` is also exposed by `@agentkit-js/claude-agent-sdk`\n(as `memoryClaudeTool`) and `@agentkit-js/openai-agents` (as\n`memoryAgentTool`) — pick the one that matches your framework and the\nbackend follows you across them.\n\n`ObservationalMemory` (continuous compression with prompt-cache-stable\nprefix — Mastra OM equivalent) is also re-exported for callers running\nan agentkit `MessageAssembler`.\n","readmeFilename":"README.md"}