import type { Agent } from "../types.js"; /** * Transport-neutral durable run lifecycle sink for agent-service adoption work. */ export interface DurableRunSink { startRun(input: TStartInput): Promise | TRun; appendEvents(run: TRun, events: TEvent[]): Promise | void; finalizeRun(run: TRun, terminalState: TTerminalState): Promise | void; cancelRun(run: TRun, terminalState: TTerminalState): Promise | void; } /** * Host-facing server config for the agent service runtime shell. */ export type AgentServiceRouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS"; /** Configuration used by agent service cors. */ export interface AgentServiceCorsConfig { origins?: string[]; credentials?: boolean; allowMethods?: AgentServiceRouteMethod[]; allowHeaders?: string[]; maxAgeSeconds?: number; } /** Configuration used by agent service server. */ export interface AgentServiceServerConfig { port?: number; basePath?: string; cors?: boolean | AgentServiceCorsConfig; } /** Public API contract for agent service route. */ export interface AgentServiceRoute { method: AgentServiceRouteMethod; path: string; handler: (request: Request, params: Record) => Promise | Response; } export interface AgentServiceRuntime { readonly contract: NormalizedAgentServiceContract; fetch(request: Request): Promise; request(input: string | URL | Request, init?: RequestInit): Promise; setShuttingDown(shuttingDown?: boolean): void; } /** Public API contract for agent registry. */ export type AgentRegistry = Record; export interface AgentServiceContractBase { serviceName: string; server?: AgentServiceServerConfig; durableRunSink?: DurableRunSink; } /** * Multi-agent service contract. Framework services route to * `defaultAgentId` unless the host chooses another registered agent. */ export interface AgentServiceRegistryContract extends AgentServiceContractBase { agents: AgentRegistry; defaultAgentId: string; } /** * Single-agent convenience accepted by `defineAgentService()`. Implementations * must normalize this shape into the same registry path used by multi-agent * services so framework users are not boxed into one-agent-per-process. */ export interface AgentServiceSingleAgentContract extends AgentServiceContractBase { agent: Agent; defaultAgentId?: string; } /** * Framework-owned agent service contract. */ export type AgentContract = AgentServiceRegistryContract | AgentServiceSingleAgentContract; /** Public API contract for normalized agent service contract. */ export interface NormalizedAgentServiceContract extends AgentServiceContractBase { agents: AgentRegistry; defaultAgentId: string; } /** * Type-preserving service definition for request-native agent service runtimes. */ export interface AgentServiceDefinition { contract: NormalizedAgentServiceContract; createRuntime(options?: { routes?: AgentServiceRoute[]; }): AgentServiceRuntime; } /** * Define an agent service and expose a policy-neutral runtime shell. * * The first implementation slice owns contract normalization plus standard * health/readiness behavior. Hosts pass product-specific routes explicitly so * auth, observability, durable sinks, and AG-UI execution policy can keep * migrating in smaller additive seams. */ export declare function defineAgentService(contract: AgentContract): AgentServiceDefinition; //# sourceMappingURL=definition.d.ts.map