import { type Agent, type AgentInputItem, RunState, type AgentOutputType, type CallModelInputFilter, type HandoffInputData, type InputGuardrail, type ModelSettings, type OutputGuardrail, type RunResult, type Session, type SessionInputCallback, type StreamedRunResult, type TracingConfig } from '@openai/agents-core'; import { type SandboxRunConfig } from '@openai/agents-core/sandbox'; import { type ModelActivityOptions, type SerializableModelActivityOptions } from '../common/model-activity-options'; export interface TemporalRunOptions { /** Run context passed to agents and tools */ context?: TContext; /** Maximum agent loop turns before aborting */ maxTurns?: number; /** Previous OpenAI response ID for conversation continuity */ previousResponseId?: string; /** OpenAI conversation ID for multi-turn persistence */ conversationId?: string; /** Session state for conversation memory */ session?: Session; /** Customize how session history merges with current turn input */ sessionInputCallback?: SessionInputCallback; /** Edit system instructions or input items just before calling the model */ callModelInputFilter?: CallModelInputFilter; /** Per-run tracing config override */ tracing?: TracingConfig; /** * Stream incremental events as the model responds. Requires a `streamingTopic` * (set via the plugin's `modelParams` or the runner's `defaultModelParams`) and a * hosted `WorkflowStream` in the Workflow. * * @experimental Streaming support is experimental and may change without notice. */ stream?: boolean; /** Runner-level config overrides */ runConfig?: { /** Model name override (string only — Model objects can't cross the Workflow/Activity boundary) */ model?: string; /** Global model settings (temperature, topP, etc.). Non-null values override agent-specific settings. */ modelSettings?: ModelSettings; /** Global handoff input filter. Agent-level inputFilter takes precedence. */ handoffInputFilter?: (input: HandoffInputData) => HandoffInputData; /** Input guardrails run inline in the Workflow — callbacks must be deterministic */ inputGuardrails?: InputGuardrail[]; /** Output guardrails run inline in the Workflow — callbacks must be deterministic */ outputGuardrails?: OutputGuardrail>[]; /** Disable tracing for this run */ tracingDisabled?: boolean; /** Include sensitive data (tool I/O, LLM outputs) in trace spans */ traceIncludeSensitiveData?: boolean; /** Logical name for the run, used in tracing */ workflowName?: string; /** Custom trace ID */ traceId?: string; /** Grouping ID for linking traces (e.g., chat thread ID) */ groupId?: string; /** Additional metadata attached to the trace */ traceMetadata?: Record; /** * Sandbox runtime configuration used when execution reaches a `SandboxAgent`. * `client` must be created via `temporalSandboxClient(name)`. * * @experimental Sandbox support is experimental and may change without notice. */ sandbox?: SandboxRunConfig; }; } export interface TemporalOpenAIRunnerOptions { /** * Workflow-authored default Model Activity options, layered UNDER the client's * `modelParams` header: a client-set field wins, otherwise this default applies. * Because these options are constructed in the Workflow (not JSON-propagated), * they can carry the function form of `summary`. Use this to configure Workflows * started without the client interceptor, e.g. by a Schedule or the Temporal UI/CLI. */ defaultModelParams?: ModelActivityOptions; } /** * Layers Model Activity options least→most significant: * package `DEFAULT_MODEL_ACTIVITY_OPTIONS` < constructor `defaultModelParams` < * client header `modelParams`. Undefined field values are dropped at each layer so * an absent option never clobbers a value set by a lower layer. */ export declare function layerModelParams(defaultModelParams: ModelActivityOptions | undefined, headerModelParams: SerializableModelActivityOptions | undefined): ModelActivityOptions; /** * A Temporal-aware agent runner that delegates model calls to Activities. * * Use `run(agent, input)` for request-response runs. Pass `{ stream: true }` to * stream incremental events as the model responds — the returned * `StreamedRunResult` is async-iterable. Streaming requires a `streamingTopic` * (set via the plugin's `modelParams` or the runner's `defaultModelParams`) and a * hosted `WorkflowStream` in the Workflow. */ export declare class TemporalOpenAIRunner { private readonly modelParams; constructor(options?: TemporalOpenAIRunnerOptions); /** * `input` accepts a prompt string, structured `AgentInputItem[]`, or a * deserialized `RunState` to resume a previous run across `continueAsNew`. * Capture the current `RunState` via `result.state.toString()`. */ run, TContext = undefined>(agent: TAgent, input: string | AgentInputItem[] | RunState, options?: TemporalRunOptions & { stream?: false; }): Promise>; run, TContext = undefined>(agent: TAgent, input: string | AgentInputItem[] | RunState, options: TemporalRunOptions & { stream: true; }): Promise>; } /** * Returns the value the caller should throw: unwrapped TemporalFailure if * reachable via `cause` / `AggregateError.errors`, else an `AgentsWorkflowError` * ApplicationFailure wrapping a plain Error, else the original non-Error. */ export declare function normalizeAgentsRunError(error: unknown): unknown;