This page documents the extension interfaces for Flue: sandbox connectors (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/withastro/flue/llms.txt
Use this file to discover all available pages before exploring further.
SandboxFactory, SandboxApi), custom tools (ToolDef, Type, createTools), MCP integration (connectMcpServer), and the @flue/runtime/app exports for provider configuration and app composition.
SandboxFactory
The interface your connector returns. Flue callscreateSessionEnv() once per session.
Called once per session. Receives
{ id: string; cwd?: string } and must return a Promise<SessionEnv>.SandboxApi
Implement this interface to build a custom connector. Pass it tocreateSandboxSessionEnv() to obtain a SessionEnv.
exec(command, options?)
Shell command to run.
Working directory.
Extra environment variables.
Wall-clock deadline in seconds. Primary cancellation contract — always forward to the provider SDK’s native timeout option. Return exit code
124 and a descriptive stderr on deadline expiry (matching the timeout(1) convention).Optional mid-flight cancellation. Forward only if the provider SDK has a real cancellation primitive. The runtime performs pre/post
signal.aborted checks for you.Promise<{ stdout: string; stderr: string; exitCode: number }>.
File methods
| Method | Signature | Notes |
|---|---|---|
readFile | (path) → Promise<string> | UTF-8 decode. |
readFileBuffer | (path) → Promise<Uint8Array> | Wrap Node Buffer: new Uint8Array(buf). |
writeFile | (path, content: string | Uint8Array) → Promise<void> | Accept both types. |
stat | (path) → Promise<FileStat> | Use new Date() and 0 for mtime/size if unavailable. |
readdir | (path) → Promise<string[]> | Entry names only, not full paths. |
exists | (path) → Promise<boolean> | Wrap in try/catch, return false on missing. |
mkdir | (path, options?) → Promise<void> | Fall back to exec('mkdir -p ...') for recursive case. |
rm | (path, options?) → Promise<void> | Honor recursive and force. |
FileStat
True if the path is a regular file.
True if the path is a directory.
True if the path is a symlink.
false is acceptable if the SDK does not expose this.File size in bytes. Use
0 if unavailable.Last modified time. Use
new Date() if unavailable.BashFactory
Alternative toSandboxFactory for custom just-bash configurations. Share an InMemoryFs instance across sessions to persist files.
BashFactory is typed as () => BashLike | Promise<BashLike>. Called once at init() time.
ToolDef
Define custom tools to extend the LLM’s capabilities. Pass toinit({ tools }) for harness-wide availability, or to individual prompt()/skill()/task() calls for call-scoped tools.
Unique tool name. Must not conflict with built-in tool names (see
BUILTIN_TOOL_NAMES).Tells the LLM when and how to use this tool.
JSON Schema-compatible parameter schema. Use
Type from @flue/runtime for hand-written schemas, or pass schemas discovered from MCP adapters.Tool implementation. Returns a string sent back to the LLM. Thrown errors become tool errors.
createTools(defs) and BUILTIN_TOOL_NAMES
connectMcpServer
Connect to a remote MCP (Model Context Protocol) server and use its tools in your agent.A local identifier for this MCP connection (used in logging).
Remote MCP server URL.
Headers to send with every MCP request. Keep secrets in
env, not in prompts or filesystem context.Transport protocol. Defaults to
'http' (streamable HTTP, the modern standard). Pass 'sse' for legacy SSE-only servers.Promise<McpServerConnection> with tools: ToolDef[] and close(): Promise<void>.
Always call
connection.close() in a finally block. Flue does not auto-detect transports, spawn stdio MCP servers, or handle OAuth callbacks.@flue/runtime/app exports
Import from @flue/runtime/app in your app.ts entry file.
flue()
Returns a Hono sub-app that handles all Flue agent routing. Use when you need custom middleware or additional routes alongside your agents.
configureProvider(name, settings)
Set runtime transport settings for a provider. Call inside the fetch() handler in app.ts — not at module level, since Cloudflare Workers may share module state across requests.
Provider name (e.g.
'anthropic', 'openai').Custom endpoint URL.
Extra headers merged into every request.
Override API key (useful for proxy/gateway scenarios).
Send
store: true for OpenAI Responses API.registerProvider(name, registration)
Register a custom or self-hosted provider.
observe(subscriber)
Subscribe to FlueEvent stream for monitoring, logging, or analytics.
(event: FlueEvent, ctx: FlueContext) — use ctx.id for the agent instance id.
admin()
Returns a read-only Hono sub-app exposing Flue’s deployment inspection routes (list agents, list instances, list/replay runs). Mount it alongside flue() when you want to expose admin endpoints.