Documentation menu
Documentation

The host bridge

Let isolated agents request narrow, permission-aware actions from a Bun host.

A boundary, not a shared global

Agent code runs in workerd. Host tools run in Bun. Ayjnt sends a tool description and validated input across a private bridge; the Bun implementation never ships into the isolate.

The bridge is active under ayjnt run and compiled executables. Deployed Cloudflare Workers have no Bun host process, so host tools are rejected unless explicitly marked optional on deploy.

Declare side effects

sideEffectsRuntime permission
readAllowed by default
writeRequires --allow-host-writes
execRequires --allow-host-exec
agents/code/tools.host.ts
import { z } from "zod";
import { confinePath, hostTool } from "ayjnt/tools";

const root = process.cwd();

export const readProjectFile = hostTool({
  description: "Read a UTF-8 file inside the project.",
  sideEffects: "read",
  inputSchema: z.object({ path: z.string() }),
  execute: ({ path }) => Bun.file(confinePath(root, path)).text(),
});