/** * OpenAI Agents SDK Adapter * * Integrates the OpenAI Agents SDK (Python-first, but JS-compatible API) * with the SwarmOrchestrator. * * The OpenAI Agents SDK provides: * - Agent definition with instructions + tools * - Handoff between agents * - Guardrails (input/output validation) * - Tracing * * This adapter wraps user-supplied agent runners or HTTP endpoints * that expose the Agents SDK interface. No hard dependency on the SDK. * * Usage: * const adapter = new OpenAIAgentsAdapter(); * adapter.registerAgentRunner('researcher', { * runner: myAgentRunner, * }); * * @module OpenAIAgentsAdapter * @version 1.0.0 */ import { BaseAdapter } from './base-adapter'; import type { AdapterCapabilities, AgentPayload, AgentContext, AgentResult } from '../types/agent-adapter'; /** Tool definition for an OpenAI Agent */ export interface OAIAgentTool { /** Tool name */ name: string; /** Tool description */ description: string; /** JSON schema for the tool's parameters */ parameters: Record; } /** Result from an agent run */ export interface OAIAgentRunResult { /** Final text output */ output: string; /** Tool calls made during execution */ toolCalls?: Array<{ tool: string; args: Record; result: unknown; }>; /** Agent handoffs that occurred */ handoffs?: Array<{ from: string; to: string; reason?: string; }>; /** Whether guardrails triggered */ guardrailTriggered?: boolean; /** Token usage */ usage?: { inputTokens: number; outputTokens: number; }; } /** * Minimal interface for running an OpenAI Agent. * Wraps `Runner.run()` from the Agents SDK or an HTTP endpoint. */ export interface OAIAgentRunner { run(input: string, context?: Record): Promise; } /** Configuration for a registered OpenAI Agents SDK agent */ export interface OAIAgentsConfig { /** The agent runner instance */ runner: OAIAgentRunner; /** Agent instructions (system prompt) */ instructions?: string; /** Tools available to the agent */ tools?: OAIAgentTool[]; /** Model to use (default: 'gpt-4o') */ model?: string; /** Per-invocation timeout in ms (default: 120000) */ timeoutMs?: number; /** Whether handoffs are enabled */ handoffsEnabled?: boolean; } /** * Adapter for the OpenAI Agents SDK. * * Wraps agent runners that implement the OAIAgentRunner interface. * Supports tool use, handoffs, and guardrails via the SDK's execution model. */ export declare class OpenAIAgentsAdapter extends BaseAdapter { readonly name = "openai-agents"; readonly version = "1.0.0"; private runners; get capabilities(): AdapterCapabilities; /** * Register an OpenAI Agent runner as a named agent. */ registerAgentRunner(agentId: string, config: OAIAgentsConfig): void; executeAgent(agentId: string, payload: AgentPayload, _context: AgentContext): Promise; shutdown(): Promise; } //# sourceMappingURL=openai-agents-adapter.d.ts.map