import { type ProviderUsageOperator } from "@mono-agent/agent-contracts"; import { type AgentResponder, type ChannelInteractionHub, type ProcessJobOperator, type ProviderAuthOperator } from "@mono-agent/agent-contracts"; import { type CronOperatorService } from "./cron.js"; import type { RequestToolEnvironmentConfig } from "./config.js"; export interface TuiAdapterLogger { debug?(message: string, metadata?: Record): void; info?(message: string, metadata?: Record): void; warn?(message: string, metadata?: Record): void; error?(message: string, metadata?: Record): void; } export type TuiSkillAvailability = "inlined" | "on-demand" | "unavailable"; export type TuiSkillUnavailableReason = "not-selected" | "read-skill-disabled" | "unsupported-name"; export interface TuiSkillInfo { readonly name: string; readonly description: string; readonly availability: TuiSkillAvailability; /** Canonical composer reference. Present only when this skill can be inserted. */ readonly reference?: string; readonly unavailableReason?: TuiSkillUnavailableReason; } export type TuiSkillRegistry = { readonly status: "ready"; readonly items: readonly TuiSkillInfo[]; readonly total: number; readonly truncated?: true; } | { readonly status: "error"; readonly items: readonly []; }; /** Static facts surfaced by GET /v1/info so the TUI can label the session. */ export interface TuiModelOption { readonly effortLevels?: readonly string[]; /** * Configured fallback-route effort. A string pins the route, `null` selects * provider default, and absence means the producer predates this field. */ readonly effort?: string | null; readonly reasoning?: boolean; readonly reasoningMode?: string; readonly label?: string; /** Known model context capacity, in tokens. Omitted when unknown. */ readonly contextWindow?: number; /** Canonical provider id the model belongs to. */ readonly provider?: string; /** Provider display label. */ readonly providerLabel?: string; } /** One provider advertised in the bounded `/v1/info` provider catalog. */ export interface TuiProviderInfo { /** Canonical provider id, e.g. "anthropic". */ readonly id: string; /** Human display label, e.g. "Anthropic". */ readonly label: string; /** Number of models this provider advertises (post-narrowing, post-cap). */ readonly modelCount: number; /** Present only when the advertised list was capped, so a UI can say "100 of 351". */ readonly totalModelCount?: number; readonly source: "builtin" | "custom" | "discovered"; /** The agent explicitly supports this provider: it is listed in `providers`, * or a configured runtime route uses it. */ readonly configured?: true; } /** One model served by the lazy `/v1/models` catalog endpoint. */ export interface TuiCatalogModel { readonly id: string; readonly name: string; readonly provider: string; readonly providerLabel: string; readonly contextWindow?: number; readonly reasoning?: boolean; readonly effortLevels?: readonly string[]; readonly reasoningMode?: string; } /** A bounded, serializable model-catalog page produced by the injected provider. */ export interface TuiModelCatalogRequest { /** Provider-scoped listing. Mutually exclusive with `query`. */ readonly provider?: string; /** Cross-provider text search. Mutually exclusive with `provider`. */ readonly query?: string; /** Opaque pagination cursor returned by a previous page. */ readonly cursor?: string; /** Page size, already bounded by the adapter to 1..maxPageSize. */ readonly limit: number; } export interface TuiModelCatalogPage { readonly models: readonly TuiCatalogModel[]; readonly nextCursor?: string; readonly truncated: boolean; } /** * Injected model-catalog data source for GET /v1/models. The adapter validates, * bounds, and serializes; the channel composition layer supplies the data * (mirroring the `info` seam). Absent when the host does not serve a catalog, * in which case `/v1/models` 404s and `/v1/info` omits the `modelCatalog` * capability. */ export type TuiModelCatalogProvider = (request: TuiModelCatalogRequest) => TuiModelCatalogPage; /** Static facts surfaced by GET /v1/info so the TUI can label the session. */ export interface TuiAdapterInfo { readonly label?: string; readonly model?: string; /** * The statically configured reasoning-effort level. Per-run overrides * (e.g. a per-trigger effort override on a given turn) do NOT flow through * here — those arrive via the `run_config` runtime_telemetry event instead. */ readonly effort?: string; /** * The candidate models a TUI session may switch to — the host's primary model * first, then each configured fallback, as canonical reference strings. Absent * on older agents; the TUI tolerates that and offers no model picker. */ readonly models?: readonly string[]; /** * Per-model reasoning/effort metadata, keyed by the same canonical ref * strings that appear in `models`. Local-provider models resolve a precise * `reasoningMode` (`"effort"` with graded `effortLevels`, `"toggle"` for * binary thinking, or `"none"`); cloud models degrade to `{ reasoning: true }` * with no mode/levels so the TUI falls back to the global effort enum. Absent * on older agents; the TUI tolerates that and offers no model-aware picker. */ readonly modelOptions?: Record; /** Bounded provider catalog so the TUI can browse beyond the configured shortlist. */ readonly providers?: readonly TuiProviderInfo[]; /** Bounded active-agent skill registry. Absent only on older producers. */ readonly skills?: TuiSkillRegistry; } export interface TuiAdapterOptions { readonly host?: string; readonly port?: number; readonly basePath?: string; readonly allowNonLoopback?: boolean; readonly apiKey?: string; /** Optional loopback-only boundary for ACP request-scoped process-tool env. */ readonly requestToolEnvironment?: RequestToolEnvironmentConfig; readonly responder: AgentResponder; readonly logger?: TuiAdapterLogger; /** * Static info, OR a provider invoked fresh on every GET /v1/info. Discovery * of local-provider models can change after the adapter starts (an endpoint * started later, or restarted); a provider lets `/v1/info` reflect that * without a restart. The channel composition layer is responsible for * caching/rate-limiting any expensive work the provider does — this adapter * just calls it (and awaits it) on every request. */ readonly info?: TuiAdapterInfo | (() => TuiAdapterInfo | Promise); /** * Optional lazy model-catalog data source served through GET /v1/models. * Absent when the host does not expose a browsable catalog. The adapter * validates/bounds/serializes every request and response; the supplier * returns already-bounded, deterministic pages. */ readonly modelCatalog?: TuiModelCatalogProvider; /** * Invoked when the already-listening HTTP server dies (e.g. EADDRINUSE * appearing later, socket-level failure). The hosting channel driver maps * this to its onFailure hook so the channel flips to "failed" instead of * silently serving nothing. */ readonly onServerError?: (reason: string) => void; /** In-process bridge state used by the web console's structured AskUser form. */ readonly interaction?: ChannelInteractionHub; /** Agent-owned cron truth and controls. Absent on older/non-cron hosts. */ readonly cron?: CronOperatorService; /** Owner-authorized process-job control plane; omitted when unavailable. */ readonly processJobs?: ProcessJobOperator; /** Independent owner bearer for process-job routes. Required with processJobs. */ readonly processJobsBearer?: string; /** Pi credential status/login surface; uses apiKey when the endpoint has one. */ readonly providerAuth?: ProviderAuthOperator; readonly providerUsage?: ProviderUsageOperator; } export interface TuiAdapterStartResult { readonly url: string; readonly baseUrl: string; readonly infoUrl: string; readonly turnsUrl: string; readonly host: string; readonly port: number; stop(): Promise; } export declare function startTuiAdapter(options: TuiAdapterOptions): Promise; //# sourceMappingURL=server.d.ts.map