Skip to content

Start typing to search the documentation.

Application API

Last updated View as Markdown

Import application composition APIs from @flue/runtime/app.

app.ts

app.ts is an optional authored application entrypoint. Without it, Flue generates an application that mounts flue() at /. When app.ts exists, its default export owns the request pipeline and must mount flue() explicitly to publish Flue routes.

import { flue } from '@flue/runtime/app';
import { Hono } from 'hono';

const app = new Hono();
app.route('/', flue());
export default app;

See Routing for middleware, custom routes, prefixes, and application-owned dispatch.

Fetchable

interface Fetchable {
  fetch(request: Request, env?: unknown, ctx?: unknown): Response | Promise<Response>;
}

Structural contract for the default export of an authored app.ts entry. Any object exposing a compatible fetch() method satisfies it, including a new Hono() instance.

On Cloudflare, env contains bindings and ctx is the ExecutionContext. On Node, env contains Hono’s Node adapter bindings for the incoming and outgoing messages, and ctx is undefined.

flue()

function flue(): Hono;

Creates a mountable Hono sub-app for Flue’s public HTTP and WebSocket API. Routes are relative to the application-chosen mount prefix.

RoutePurpose
GET /openapi.jsonReturn the public OpenAPI document.
POST /agents/:name/:idPrompt an HTTP-exposed agent instance.
GET /agents/:name/:idUpgrade to a WebSocket connection for a WebSocket-exposed agent instance.
POST /workflows/:nameStart an HTTP-exposed workflow run.
GET /workflows/:nameUpgrade to a WebSocket invocation for a WebSocket-exposed workflow.
GET /runs/:runIdRetrieve a workflow run record.
GET /runs/:runId/eventsRetrieve persisted workflow run events.
GET /runs/:runId/streamStream workflow run events over SSE.

Agent and workflow routes are available only when the corresponding module opts into that transport. Run routes inspect workflow runs only and may expose payloads, results, errors, and events. Applications publishing them should authorize access to the selected run. Direct agent prompts and dispatched agent inputs are not runs.

admin()

function admin(): Hono;

Creates a mountable Hono sub-app for read-only deployment inspection. Mount it explicitly beneath an application-chosen prefix and protect that mount with application-owned authorization.

import { admin, flue } from '@flue/runtime/app';
import { Hono, type MiddlewareHandler } from 'hono';
import { authenticateOperator } from './auth.ts';

const requireOperator: MiddlewareHandler = async (c, next) => {
  if (!(await authenticateOperator(c.req.raw))) {
    return c.json({ error: 'Unauthorized' }, 401);
  }

  await next();
};

const app = new Hono();
app.route('/', flue());
app.use('/admin/*', requireOperator);
app.route('/admin', admin());
export default app;
RoutePurpose
GET /openapi.jsonReturn the administrative OpenAPI document.
GET /agentsList built agents and their transport metadata.
GET /runsList workflow run summaries.
GET /runs/:runIdRetrieve a workflow run record.