Skip to content

Latest commit

 

History

History

README.md

@execbox/quickjs

Default execbox executor for most deployments. It runs guest JavaScript in QuickJS and lets you keep the same API as you move between inline, worker-hosted, and process-hosted execution.

npm version License Docs

Use @execbox/quickjs When

  • you want the default execbox path with the easiest setup
  • you do not want a native addon in local development or CI
  • you want one package that can stay inline, move off-thread, or move into a child process later

Install

npm install @execbox/core @execbox/quickjs

Smallest Working Usage

import { resolveProvider } from "@execbox/core";
import { QuickJsExecutor } from "@execbox/quickjs";

const provider = resolveProvider({
  name: "tools",
  tools: {
    echo: {
      execute: async (input) => input,
    },
  },
});

const executor = new QuickJsExecutor();
const result = await executor.execute(`await tools.echo({ ok: true })`, [
  provider,
]);

console.log(result);

Host Modes

QuickJsExecutor keeps the same execution API while changing where the runtime lives:

Mode Use it when
Inline (default) You want the lowest-friction development path.
host: "worker" You want QuickJS off the main thread with pooled worker shells.
host: "process" You want QuickJS hosted in a child process with a stronger lifecycle split.
const executor = new QuickJsExecutor({
  host: "worker",
  pool: {
    maxSize: 4,
    prewarm: true,
  },
});

await executor.prewarm();

Advanced Imports

  • @execbox/quickjs/runner exports the reusable QuickJS runner
  • @execbox/quickjs/runner/protocol-endpoint exports the shared protocol endpoint used by hosted and remote flows

Operational Notes

  • Each execution gets a fresh QuickJS runtime with JSON-only tool and result boundaries.
  • This package is the default deployment path, not a hard security boundary for hostile or multi-tenant code.
  • If you need a stronger boundary, prefer host: "process" or move execution behind @execbox/remote.

Read Next