import * as node_http from 'node:http'; import * as express from 'express'; import { Response, Request } from 'express'; import { AgentIsolationContext } from '@cuylabs/agent-foundry-agentserver-core'; declare class ResponseContext { readonly responseId: string; readonly request: CreateResponse; readonly createdAt: number; readonly modeFlags: ResponseModeFlags; readonly sessionId: string; readonly previousResponseId?: string; readonly conversationId?: string; readonly clientHeaders: Record; readonly queryParameters: Record; readonly isolation: AgentIsolationContext; isShutdownRequested: boolean; private readonly provider?; private readonly historyLimit; private readonly inputItems; private resolvedInputCache?; private historyCache?; constructor(options: { responseId: string; request: CreateResponse; modeFlags: ResponseModeFlags; sessionId?: string; provider?: ResponseProvider; inputItems?: OutputItem[]; previousResponseId?: string; conversationId?: string; historyLimit?: number; clientHeaders?: Record; queryParameters?: Record; isolation?: AgentIsolationContext; createdAt?: number; }); getInputItems(options?: { resolveReferences?: boolean; }): Promise; getInputText(options?: { resolveReferences?: boolean; }): Promise; getHistory(): Promise; getInputItemsForPersistence(): Promise; } type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue; }; interface AgentReference { type: "agent_reference"; name: string; version?: string; id?: string; } interface ConversationReference { id: string; } interface CreateResponse { input?: ResponseInput; model?: string; stream?: boolean; background?: boolean; store?: boolean; previous_response_id?: string | null; conversation?: string | ConversationReference | null; metadata?: Record | null; response_id?: string; agent_session_id?: string; agent_reference?: AgentReference; [key: string]: unknown; } type ResponseInput = string | InputItem | InputItem[]; type InputItem = ItemMessage | ItemReference | FunctionCallOutputItem | Record; interface ItemMessage { id?: string; type: "message"; role: "user" | "assistant" | "system" | "developer"; content: string | MessageContent[]; } interface ItemReference { type: "item_reference"; id: string; } interface FunctionCallOutputItem { id?: string; type: "function_call_output"; call_id: string; output: string; } type MessageContent = MessageContentInputText | MessageContentOutputText | MessageContentRefusal | Record; interface MessageContentInputText { type: "input_text"; text: string; } interface MessageContentOutputText { type: "output_text"; text: string; annotations?: unknown[]; } interface MessageContentRefusal { type: "refusal"; refusal: string; } interface OutputItem { id: string; type: string; status?: string; role?: string; content?: MessageContent[]; [key: string]: unknown; } type ResponseStatus = "queued" | "in_progress" | "completed" | "failed" | "cancelled" | "incomplete"; interface ResponseError { code: string; message: string; type?: string; } interface ResponseUsage { input_tokens?: number; output_tokens?: number; total_tokens?: number; [key: string]: unknown; } interface ResponseObject { id: string; object: "response"; created_at: number; status: ResponseStatus; model?: string; stream?: boolean; background?: boolean; store?: boolean; output: OutputItem[]; error?: ResponseError | null; previous_response_id?: string | null; conversation?: ConversationReference; metadata?: Record | null; usage?: ResponseUsage | null; [key: string]: unknown; } interface ResponseStreamEvent { type: string; sequence_number?: number; response?: ResponseObject; item?: OutputItem; item_id?: string; output_index?: number; content_index?: number; part?: MessageContent; delta?: string; text?: string; error?: ResponseError; [key: string]: unknown; } interface ResponseModeFlags { stream: boolean; background: boolean; store: boolean; } interface ResponseHandlerContext { request: CreateResponse; context: ResponseContext; signal: AbortSignal; } type ResponseHandlerResult = AsyncIterable> | Iterable>; type ResponseHandler = (request: CreateResponse, context: ResponseContext, signal: AbortSignal) => ResponseHandlerResult | Promise; declare abstract class ResponsesHandler { abstract handle(request: CreateResponse, context: ResponseContext, signal: AbortSignal): ResponseHandlerResult | Promise; getOpenApi?(): unknown; close?(): Promise | void; } type ResponsesHandlerFactory = () => ResponsesHandler; type ResponsesHandlerInput = ResponsesHandler | ResponsesHandlerFactory | ResponseHandler; interface ResponseProvider { createResponse(response: ResponseObject, inputItems: OutputItem[], options?: { historyItemIds?: readonly string[]; isolation?: AgentIsolationContext; }): Promise; getResponse(responseId: string, options?: { isolation?: AgentIsolationContext; }): Promise; updateResponse(response: ResponseObject, options?: { isolation?: AgentIsolationContext; }): Promise; deleteResponse(responseId: string, options?: { isolation?: AgentIsolationContext; }): Promise; getItems(itemIds: readonly string[], options?: { isolation?: AgentIsolationContext; }): Promise>; getInputItems(responseId: string, options?: { after?: string; ascending?: boolean; before?: string; isolation?: AgentIsolationContext; limit?: number; }): Promise; getHistoryItemIds(previousResponseId: string | undefined, conversationId: string | undefined, limit: number, options?: { isolation?: AgentIsolationContext; }): Promise; getHistoryItems?(previousResponseId: string | undefined, conversationId: string | undefined, limit: number, options?: { isolation?: AgentIsolationContext; }): Promise; } interface ResponseStreamProvider { appendStreamEvent(responseId: string, event: ResponseStreamEvent, options?: { isolation?: AgentIsolationContext; }): Promise; saveStreamEvents?(responseId: string, events: ResponseStreamEvent[], options?: { isolation?: AgentIsolationContext; }): Promise; getStreamEvents(responseId: string, options?: { isolation?: AgentIsolationContext; }): Promise; deleteStreamEvents(responseId: string, options?: { isolation?: AgentIsolationContext; }): Promise; } interface ResponsesServerLogger { info(message: string, meta?: Record): void; warn(message: string, meta?: Record): void; error(message: string, meta?: Record): void; debug?(message: string, meta?: Record): void; } interface ResponsesServer { readonly app: express.Express; readonly server: node_http.Server; readonly port: number; readonly host: string; close(): Promise; } interface ResponsesServerOptions { handler: ResponsesHandlerInput; port?: number; host?: string; appName?: string; bodyLimit?: string; requestLogging?: boolean; trustProxy?: boolean | number | string; gracefulShutdownTimeoutSeconds?: number; configureObservability?: boolean; logger?: ResponsesServerLogger; store?: ResponseProvider & Partial; defaultModel?: string; defaultFetchHistoryCount?: number; } interface ResponsesRequest extends Request { body: CreateResponse; } type ExpressResponse = Response; export { type AgentReference as A, type CreateResponse as C, type ExpressResponse as E, type FunctionCallOutputItem as F, type InputItem as I, type JsonValue as J, type MessageContent as M, type OutputItem as O, type ResponsesServerOptions as R, type ResponsesServer as a, type ResponseObject as b, type ResponseInput as c, type ConversationReference as d, type ItemMessage as e, type ItemReference as f, type MessageContentInputText as g, type MessageContentOutputText as h, type MessageContentRefusal as i, ResponseContext as j, type ResponseError as k, type ResponseHandler as l, type ResponseHandlerContext as m, type ResponseHandlerResult as n, type ResponseModeFlags as o, type ResponseProvider as p, type ResponseStatus as q, type ResponseStreamEvent as r, type ResponseStreamProvider as s, type ResponseUsage as t, ResponsesHandler as u, type ResponsesHandlerFactory as v, type ResponsesHandlerInput as w, type ResponsesRequest as x, type ResponsesServerLogger as y };