ComposioHQ/composio · error · Error

Local FFI execution requires the Bun runtime used by the pac

Error message

Local FFI execution requires the Bun runtime used by the packaged Composio CLI.

What it means

FFI execution uses bun:ffi, which only exists in the Bun runtime that the packaged Composio CLI is built on. If the code is running under Node.js (or any non-Bun runtime), the isBun check fails and execution is refused before importing bun:ffi.

Source

Thrown at ts/packages/cli-local-tools/src/runtime.ts:249

): Promise<string> => {
  if (typeof execution.library === 'string') return execution.library;
  const resolved = await resolveBundledBinary(context.toolkit, execution.library, {
    currentPlatform: context.platform,
  });
  if (resolved?.exists) return resolved.path;
  if (execution.library.fallbackCommand) return execution.library.fallbackCommand;
  throw new Error(
    `Bundled FFI library ${execution.library.bundledBinary} was not found for ${context.platform}.`
  );
};

const runLocalFfiTool = async (
  execution: LocalFfiExecution,
  input: Record<string, unknown>,
  context: LocalExecutionContext
): Promise<LocalExecutionResult> => {
  if (!isBun) {
    throw new Error(
      'Local FFI execution requires the Bun runtime used by the packaged Composio CLI.'
    );
  }

  const { dlopen, FFIType } = (await import('bun:ffi')) as typeof import('bun:ffi');
  const libraryPath = await resolveFfiLibraryPath(execution, context);
  const bindings = Object.fromEntries(
    Object.entries(execution.symbols).map(([name, symbol]) => [
      name,
      {
        args: symbol.args.map(type => FFIType[ffiTypeMap[type] as keyof typeof FFIType]),
        returns: FFIType[ffiTypeMap[symbol.returns] as keyof typeof FFIType],
      },
    ])
  );
  const library = dlopen(libraryPath, bindings);
  const handle: LocalFfiLibraryHandle = {
    path: libraryPath,

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Run the code under the packaged Composio CLI (Bun-based)
  2. Use bun or bun test to execute code paths that use FFI tools
  3. Avoid FFI-based local tools in Node-only environments; prefer command-based tools

Example fix

// before: node script.js  (FFI tool)
// after: bun run script.ts  (or use the packaged composio CLI)
Defensive patterns

Strategy: type-guard

Validate before calling

const canFfi = typeof (globalThis as any).Bun !== 'undefined';

Type guard

const isBunRuntime = (): boolean => typeof (globalThis as { Bun?: unknown }).Bun !== 'undefined';

Try / catch

try { ... } catch (e) { if (e.message.includes('requires the Bun runtime')) useCommandToolInstead(); }

Prevention

When it happens

Trigger: Importing and executing a local FFI tool from a Node.js script or from tsx/jest; running the CLI unpackaged under node; test runners that execute under Node.

Common situations: SDK consumers embedding cli-local-tools in a Node app; unit tests run with node-based runners hitting FFI tools.

Related errors


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/1fa0b327c04bac7c. Report an issue: GitHub.