/** * OpenAI agent that uses the Strategy pattern for prompt/output handling. * * The original OpenAIAgent remains untouched for backwards compatibility. * This class provides the strategy-aware variant for the Polaris Creativa pipeline. * * Contains ZERO conditionals about layers. All behavioral variation * comes from the PromptStrategy and OutputParserStrategy injected at construction. * * Supports: * - Structured Outputs (json_schema) for deterministic parsing (Layers 2 & 4) * - AbortController for latency bounding (Layer 1 parallel timeout) */ import { StrategyAgent } from "../base/strategy-agent"; import { GameState } from "../../domains/base/game-state"; import { Action } from "../../domains/base/action"; import { Agent } from "../base/agent"; import { AgentOutput } from "../../types/agent-output"; import { PromptStrategy } from "../../strategies/prompt-strategy"; import { OutputParserStrategy } from "../../strategies/output-parser-strategy"; import { AgentRole, PolarisEngineTask } from "../../types/task"; import { AgentParameters } from "../base/parameters"; /** * Optional: JSON Schema definition for Structured Outputs. * If provided, the agent will use response_format: { type: "json_schema", ... } * instead of relying on regex-based post-hoc parsing. */ export interface StructuredOutputSchema { /** Schema name (required by OpenAI's Structured Outputs) */ readonly name: string; /** Whether all properties are required (enables strict mode) */ readonly strict: boolean; /** The JSON Schema definition */ readonly schema: Record; } export interface OpenAIStrategyAgentConfig { role: AgentRole; task: PolarisEngineTask; promptStrategy: PromptStrategy; outputParserStrategy: OutputParserStrategy; /** OpenAI-specific config */ model?: string; apiKey?: string; maxTokens?: number; temperature?: number; name?: string; /** Additional agent parameters (bias, weight, etc.) */ parameters?: Partial; /** * If provided, enforces Structured Outputs at the API level. * The LLM is guaranteed to return JSON conforming to this schema. * Eliminates regex-based parsing fallbacks entirely. */ structuredOutputSchema?: StructuredOutputSchema; } export declare class OpenAIStrategyAgent extends StrategyAgent { private client; private model; private defaultMaxTokens; private defaultTemperature; private structuredSchema; private logger; /** * AbortController signal — injected by the pipeline for timeout enforcement. * The agent does NOT manage its own timeout. The pipeline owns the deadline. */ private _abortSignal; constructor(config: OpenAIStrategyAgentConfig); /** * Inject an AbortSignal for timeout enforcement. * Called by the pipeline — NOT by the agent itself. */ setAbortSignal(signal: AbortSignal): void; initialize(): Promise; /** * Core evaluation method. * Delegates ALL prompt construction to this.promptStrategy * and ALL output parsing to this.outputParserStrategy. * Contains ZERO layer-awareness logic. */ evaluate(state: GameState, actions?: Action[]): Promise; selectAction(_state: GameState, actions: Action[]): Promise; clone(): Agent; } //# sourceMappingURL=openai-strategy-agent.d.ts.map