@suluk/chat - v0.2.1
    Preparing search index...

    Interface ChatOptions

    @suluk/chat — a contract-driven chat AGENT for any suluk app. The same OpenAPI v4 operations that drive the API, SDK, docs, admin, panel, and MCP server are projected (via @suluk/mcp) into tools an in-page assistant can call; an OpenRouter tool-use loop drives them, with the model chosen by @suluk/models (never hardcoded) and every call executed through the store's own access gate — so the agent can BROWSE and, when the user is permitted, ACT. Ships the server loop (chatApp, Hono-mountable SSE) + a theme-aware floating chatWidget. Pure pieces (runAgent, parseSSEStream, toolsToOpenAI) are independently testable. CANDIDATE tooling — NOT official OAS.

    interface ChatOptions {
        document:
            | OpenAPIv4Document
            | ((c: Context) => OpenAPIv4Document | Promise<OpenAPIv4Document>);
        basePath?: string;
        apiKey?: string | ((c: Context) => string | undefined);
        model?: string;
        select?: { reqs?: HardFilters; prefs?: Preferences };
        catalog?: ModelCatalog;
        exec: (
            c: Context,
            op: McpOp,
            args: Record<string, unknown>,
        ) => Promise<unknown>;
        system?: string | ((c: Context) => string);
        clientTools?: false;
        authorize?: (c: Context) => boolean | Promise<boolean>;
        maxSteps?: number;
        temperature?: number;
        referer?: string;
        title?: string;
        baseUrl?: string;
        greeting?: string;
        include?: "read" | "all";
        hide?: string[];
        only?: string[];
    }

    Hierarchy

    • Pick<ToolsOptions, "include" | "hide" | "only">
      • ChatOptions
    Index

    Properties

    document:
        | OpenAPIv4Document
        | ((c: Context) => OpenAPIv4Document | Promise<OpenAPIv4Document>)

    The v4 document, or a per-request function (e.g. (c) => projectDocument(doc, viewerOf(c))).

    basePath?: string
    apiKey?: string | ((c: Context) => string | undefined)

    OpenRouter API key (or a per-request resolver, e.g. (c) => c.env.OPENROUTER_API_KEY). Absent → graceful 503.

    model?: string

    Explicit OpenRouter model id; omit to let @suluk/models pick one (default: tool-reliable).

    select?: { reqs?: HardFilters; prefs?: Preferences }

    Model-selection inputs when model is omitted.

    catalog?: ModelCatalog

    The catalog the model is selected from when model is omitted. Defaults to the lean built-in SEED_CATALOG (a handful of strong, tool-reliable models) — which keeps this widget's edge-worker bundle small (the full 337-model OPENROUTER_CATALOG adds ~150KB gzipped, and under the default tool-reliable profile it selects a pricier FRONTIER model — e.g. claude-sonnet-4.5 vs the seed's gemini-2.5-flash). Pass OPENROUTER_CATALOG from @suluk/models for always-current, full-catalog selection (mind the cost/bundle trade-off).

    exec: (c: Context, op: McpOp, args: Record<string, unknown>) => Promise<unknown>

    Execute a tool call against the store (e.g. appExec(app) bound per request).

    system?: string | ((c: Context) => string)
    clientTools?: false

    Set false to ignore any browser-declared client tools / state snapshot from the request (default: accept, validated). Client tools are browser-executed and unprivileged; server tools always stay gated by exec.

    authorize?: (c: Context) => boolean | Promise<boolean>

    Gate the endpoint (default: open — anonymous users may chat; mutations are still gated by exec).

    maxSteps?: number
    temperature?: number
    referer?: string

    OpenRouter attribution.

    title?: string
    baseUrl?: string
    greeting?: string

    Shown by GET /info (e.g. the widget's opening line).

    include?: "read" | "all"

    "read" (default) exposes only GET/HEAD operations; "all" also exposes mutations.

    hide?: string[]

    Operation names to omit.

    only?: string[]

    If set, expose ONLY these operation names (after hide).