Skip to content
PluginStats

experimental-ai-sdk-code-mode weekly downloads statistics

By vercel-labs (8 listings) · npm · AI SDKs

QuickJS-backed code mode tool for AI SDK

View on npm Fresh · Dec 6, 2026

experimental-ai-sdk-code-mode has 11,802 recorded weekly downloads on npm, a decrease of 50.6% over the past 30 days, ranking #1212 of 3,247 tracked listings.

Weekly downloads
11,802
Official API · Dec 5, 2026
7-day growth
-29.3%
-4.9K weekly downloads
30-day growth
-50.6%
-12.1K weekly downloads
90-day growth
-39.0%
-7.6K weekly downloads
Rank
#1212
▼ 123 in 7 days

About experimental-ai-sdk-code-mode

AI SDK Code Mode

experimental-ai-sdk-code-mode provides an AI SDK tool that runs JavaScript or type-stripped TypeScript in an isolated QuickJS WASM sandbox. It is meant for agents that need to call several tools, combine their results, run independent tool calls concurrently, or do structured JSON transformations in one step.

Installation

pnpm add ai experimental-ai-sdk-code-mode

The runtime uses Node.js worker threads and is intended for server-side AI SDK tools, not browser execution.

ai is a peer dependency. The package supports AI SDK 6 stable and AI SDK 7 beta:

pnpm add ai@^6 experimental-ai-sdk-code-mode
pnpm add ai@beta experimental-ai-sdk-code-mode

Quick Start

import { generateText, tool } from "ai";
import { z } from "zod";
import { createCodeModeTool } from "experimental-ai-sdk-code-mode";

const search = tool({
  description: "Search indexed documents.",
  inputSchema: z.object({
    query: z.string(),
    limit: z.number().int().optional(),
  }),
  outputSchema: z.object({
    results: z.array(
      z.object({
        id: z.string(),
        title: z.string(),
      }),
    ),
  }),
  execute: async ({ query, limit }) => {
    return { results: await searchDocuments(query, limit) };
  },
});

const readDocument = tool({
  description: "Read a document by id.",
  inputSchema: z.object({
    id: z.string(),
  }),
  outputSchema: z.object({
    id: z.string(),
    title: z.string(),
    body: z.string(),
  }),
  execute: async ({ id }) => {
    return await readDocumentById(id);
  },
});

const codeMode = createCodeModeTool(
  {
    search,
    readDocument,
  },
  {
    executionPolicy: {
      timeoutMs: 30_000,
      memoryLimitBytes: 64 * 1024 * 1024,
    },
  },
);

const result = await generateText({
  model,
  tools: { codeMode },
  prompt: "Search for the latest internal QuickJS notes and summarize them.",
});

What The Model Sees

createCodeModeTool(tools) generates the code-mode tool description from the provided AI SDK tools. The description includes:

  • sandbox rules
  • whether fetch is available, plus the configured fetch policy when present
  • TypeScript call signatures for every provided tool, including return types when the tool provides an AI SDK outputSchema
  • examples for calling tools and returning the final value

For example, if you pass search and readDocument, the model sees guidance like this in the code-mode tool description:

declare const tools: {
  /** Search indexed documents. */
  search: (input: {
    query: string;
    limit?: number;
  }) => Promise<{
    results: Array<{
      id: string;
      title: string;
    }>;
  }>;
  /** Read a document by id. */
  readDocument: (input: {
    id: string;
  }) => Promise<{
    id: string;
    title: string;
    body: string;
  }>;
};

Inside code mode, calls look like normal async JavaScript:

const { results } = await tools.search({ query: "QuickJS", limit: 5 });
const documents = await Promise.all(
  results.map((item) => tools.readDocument({ id: item.id })),
);

return {
  count: documents.length,
  titles: documents.map((doc) => doc.title),
};

JSON.parse and JSON.stringify are available in the sandbox. Returned values and tool inputs/outputs must be JSON-serializable.

API

createCodeModeTool(tools, options?)

Returns an AI SDK tool() whose input schema is:

{
  js: string;
}

The js string is wrapped in an async function, so top-level await and return are supported:

const first = await tools.search({ query: "sandbox" });
return { first };

The package also exports the lower-level runner:

import { runCodeMode } from "experimental-ai-sdk-code-mode";

const output = await runCodeMode({
  js: "return await tools.add({ a: 1, b: 2 });",
  tools: {
    add: tool({
      inputSchema: z.object({ a: z.number(), b: z.number() }),
      execute: async ({ a, b }) => ({ sum: a + b }),
    }),
  },
});

Options

interface CodeModeOptions {
  executionPolicy?: {
    timeoutMs?: number;
    memoryLimitBytes?: number;
    maxStackSizeBytes?: number;
    maxResultBytes?: number;
    maxSourceBytes?: number;
    maxToolInputBytes?: number;
    maxToolOutputBytes?: number;
    maxBridgeRequests?: number;
    maxInFlightBridgeRequests?: number;
  };
  fetchPolicy?: false | {
    fetch?: typeof globalThis.fetch;
    allowedOrigins?: string[];
    allowedUrlPrefixes?: string[];
    allowedMethods?: string[];
    maxResponseBytes?: number;
    allowRedirects?: boolean;
    maxRedirects?: number;
  };
  approval?: {
    mode?: "callback" | "interrupt";
    onApprovalRequired?: (request: {
      toolName: string;
      input: unknown;
      toolCallId: string;
    }) =>
      | "approved"
      | "denied"
      | { approved: boolean; reason?: string }
      | Promise<"approved" | "denied" | { approved: boolean; reason?: string }>;
  };
  lifecycle?: {
    onNestedToolCall?: (event: CodeModeNestedToolCallEvent) => void | Promise<void>;
    onNestedToolResult?: (event: CodeModeNestedToolResultEvent) => void | Promise<void>;
    onFetchRequest?: (event: CodeModeFetchRequestEvent) => void | Promise<void>;
    onFetchResult?: (event: CodeModeFetchResultEvent) => void | Promise<void>;
    onInterrupt?: (event: CodeModeInterruptEvent) => void | Promise<void>;
    onTrace?: (trace: CodeModeTrace) => void | Promise<void>;
    onHookError?: (
      error: unknown,
      event: CodeModeLifecycleHookErrorEvent,
    ) => void | Promise<void>;
  };
  telemetry?: {
    isEnabled?: boolean;
    tracer?: unknown;
    recordInputs?: boolean;
    recordOutputs?: boolean;
    functionId?: string;
    metadata?: Record<string, unknown>;
  };
  modelOutput?: {
    includeNestedToolSummary?: boolean;
    includeNestedToolOutputs?: boolean;
    includeFetchSummary?: boolean;
    maxSummaryEntries?: number;
  };
}

Defaults:…

Description from the npm listing.

  • ai-sdk
  • agents
  • code-mode
  • quickjs
  • sandbox
  • tools

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

experimental-ai-sdk-code-mode weekly downloads on npm, last 90 days: 11,802 weekly downloads as of Dec 5, 2026, -39.0% over 90 days.experimental-ai-sdk-code-modeWeekly downloads on npm · Last 90 days11,802downloads / week-39.0% over 90 days05K10K15K20K25K30K35KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
experimental-ai-sdk-code-mode weekly downloads on npm, last 90 days: 11,802 weekly downloads as of Dec 5, 2026, -39.0% over 90 days.

7/30/90-day growth

experimental-ai-sdk-code-mode weekly downloads growth on npm: -29.3% over 7 days, -50.6% over 30 days, -39.0% over 90 days.experimental-ai-sdk-code-modeWeekly downloads growth on npm11,802downloads / week now7-day growth-4,881 weekly downloads-29.3%30-day growth-12,107 weekly downloads-50.6%90-day growth-7,558 weekly downloads-39.0%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
experimental-ai-sdk-code-mode weekly downloads growth on npm: -29.3% over 7 days, -50.6% over 30 days, -39.0% over 90 days.

Ranking history

experimental-ai-sdk-code-mode npm ranking history: currently #1212 (by weekly downloads).experimental-ai-sdk-code-modenpm ranking · by weekly downloads · Last 90 days#1212current rank#900#950#1000#1050#1100#1150#1200#1250#1300Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 44 observations · Updated Dec 5, 2026pluginstats.com
experimental-ai-sdk-code-mode npm ranking history: currently #1212 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 61, #12 (overall #1,212)
All npm: every listing in weekly downloads order

Listing placement

AI SDKs378 listings · 19 pages · page 5, #5 (overall #85)
AI SDKs: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (170)
Recent weekly downloads observations for experimental-ai-sdk-code-mode
Date (UTC)Weekly downloadsChange vs. previous
11,802+69
11,733+1.1K
10,655+1.3K
9,308+1.5K
7,805-3.6K
11,383-3.4K
14,784-1.9K
16,683-940
17,623-1.2K
18,802-1.5K
20,278-2.3K
22,600+303
22,297+1.7K
20,604—

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/experimental-ai-sdk-code-mode. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.