/** * OpenAI Responses Adapter * * Integrates the OpenAI Responses API (the successor to Chat Completions and * the deprecated Assistants API) with the SwarmOrchestrator. Supports GPT-4.1 / * GPT-5.x class models, reasoning-effort control, and instructions. * * The Assistants API is scheduled for sunset — this adapter is the migration * path: agents registered here run against `POST /v1/responses`. * * Usage — built-in fetch: * const adapter = new OpenAIResponsesAdapter(); * adapter.registerAgent('writer', { * model: 'gpt-5.2', * apiKey: process.env.OPENAI_API_KEY, * instructions: 'You are a concise technical writer.', * }); * * Usage — bring-your-own client (official openai SDK): * import OpenAI from 'openai'; * const openai = new OpenAI(); * adapter.registerAgent('reasoner', { * model: 'o4-mini', * reasoningEffort: 'high', * client: { create: (params) => openai.responses.create(params) }, * }); * * @module OpenAIResponsesAdapter * @version 1.0.0 */ import { BaseAdapter } from './base-adapter'; import type { AdapterCapabilities, AgentPayload, AgentContext, AgentResult } from '../types/agent-adapter'; /** One output item from a Responses API result */ export interface ResponsesOutputItem { type: string; content?: Array<{ type: string; text?: string; }>; } /** Response shape returned by the Responses API */ export interface ResponsesApiResult { /** SDK convenience accessor — full concatenated output text */ output_text?: string; output?: ResponsesOutputItem[]; status?: string; usage?: { input_tokens?: number; output_tokens?: number; total_tokens?: number; }; } /** * Minimal interface for an OpenAI Responses client. Matches the official * `openai` SDK's `responses.create` signature; users supply their own SDK * instance — no hard dependency (BYOC). */ export interface OpenAIResponsesClient { create(params: { model: string; input: string; instructions?: string; max_output_tokens?: number; temperature?: number; reasoning?: { effort?: string; }; }): Promise; } /** Reasoning effort levels supported by reasoning-capable models */ export type ResponsesReasoningEffort = 'minimal' | 'low' | 'medium' | 'high'; /** Configuration for a registered OpenAI Responses agent */ export interface OpenAIResponsesAgentConfig { /** Model name — e.g. 'gpt-5.2', 'gpt-4.1', 'o4-mini' (default: 'gpt-4.1') */ model?: string; /** OpenAI API key — falls back to OPENAI_API_KEY env var */ apiKey?: string; /** Base URL override (default: 'https://api.openai.com/v1') */ baseUrl?: string; /** System-level instructions sent with every request */ instructions?: string; /** Maximum output tokens */ maxOutputTokens?: number; /** Temperature */ temperature?: number; /** Reasoning effort for reasoning-capable models (o-series, gpt-5.x) */ reasoningEffort?: ResponsesReasoningEffort; /** * Bring-your-own OpenAI SDK responses instance. If supplied, * apiKey / baseUrl are ignored and this client is used directly. */ client?: OpenAIResponsesClient; /** Additional headers to send with fetch-based requests */ headers?: Record; /** Request timeout in milliseconds (default: 120000) */ timeout?: number; } /** * Adapter that connects OpenAI models to the SwarmOrchestrator via the * Responses API. BYOC: supply an `openai` SDK responses instance, or let the * adapter call the REST API directly with an `OPENAI_API_KEY`. */ export declare class OpenAIResponsesAdapter extends BaseAdapter { readonly name = "openai-responses"; readonly version = "1.0.0"; private agents; get capabilities(): AdapterCapabilities; /** * Register an OpenAI Responses-powered agent. * * @param agentId Unique identifier used in `delegateTask` calls. * @param config Agent configuration. */ registerAgent(agentId: string, config?: OpenAIResponsesAgentConfig): void; executeAgent(agentId: string, payload: AgentPayload, context: AgentContext): Promise; shutdown(): Promise; private _createResponse; } //# sourceMappingURL=openai-responses-adapter.d.ts.map