@agentionai/agents 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,7 +42,7 @@ type OpenRouterAgentConfig = Omit<BaseAgentConfig, "vendor" | "model"> & OpenRou
42
42
  };
43
43
  type AgentConfig = ClaudeAgentConfig | OpenAIAgentConfig | GeminiAgentConfig | MistralAgentConfig | OllamaAgentConfig | LlamaCppAgentConfig | OpenRouterAgentConfig;
44
44
  export declare class Agent {
45
- static create(config: AgentConfig, history?: History): ClaudeAgent | GeminiAgent | MistralAgent | OllamaAgent | LlamaCppAgent | OpenRouterAgent | OpenAiAgent<(string & {}) | "gpt-5-pro" | "gpt-5.2-pro" | "gpt-5.4-pro" | "gpt-5.5-pro" | "o1" | "o1-pro" | "o3" | "o3-mini" | "o4-mini" | "gpt-5" | "gpt-5-mini" | "gpt-5-nano" | "gpt-5.1" | "gpt-5.2" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-nano" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-5.6-luna" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano" | "gpt-4o" | "gpt-4o-mini" | "gpt-4o-2024-11-20" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-turbo-preview" | "gpt-4-0125-preview" | "gpt-4-1106-preview" | "gpt-4" | "gpt-4-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-1106" | "o1-preview" | "o1-mini">;
45
+ static create(config: AgentConfig, history?: History): ClaudeAgent | GeminiAgent | MistralAgent | OllamaAgent | LlamaCppAgent | OpenRouterAgent | OpenAiAgent<(string & {}) | "gpt-5-pro" | "gpt-5.2-pro" | "gpt-5.4-pro" | "gpt-5.5-pro" | "o1" | "o1-pro" | "o3" | "o3-mini" | "o4-mini" | "gpt-5" | "gpt-5-mini" | "gpt-5-nano" | "gpt-5.1" | "gpt-5.2" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-nano" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-5.6-luna" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano" | "gpt-4o" | "gpt-4o-mini" | "gpt-4o-2024-11-20" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-turbo-preview" | "gpt-4-0125-preview" | "gpt-4-1106-preview" | "gpt-4" | "gpt-4-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-1106" | "o1-preview" | "o1-mini", import("openai/resources/models").Model>;
46
46
  }
47
47
  export {};
48
48
  //# sourceMappingURL=Agent.d.ts.map
@@ -137,6 +137,29 @@ export interface OpenAISpecificConfig {
137
137
  * see `lib/tools/BuiltInTool.ts`.
138
138
  */
139
139
  builtInTools?: BuiltInTool[];
140
+ /**
141
+ * Override the API base URL. Defaults to `api.openai.com/v1`; `CodexAgent`
142
+ * defaults it to `https://chatgpt.com/backend-api/codex`, and setting it
143
+ * there points at a Codex proxy instead.
144
+ */
145
+ baseURL?: string;
146
+ /**
147
+ * `CodexAgent` only: ChatGPT workspace to bill, sent as the
148
+ * `chatgpt-account-id` header.
149
+ */
150
+ accountId?: string;
151
+ /**
152
+ * `CodexAgent` only: client identifier sent as the `originator` header.
153
+ * OpenAI varies the model catalog by originator.
154
+ *
155
+ * @default "codex_cli_rs"
156
+ */
157
+ originator?: string;
158
+ /**
159
+ * `client_version` sent to the Codex models endpoint, which requires one and
160
+ * hides models newer than the version claimed.
161
+ */
162
+ clientVersion?: string;
140
163
  }
141
164
  /**
142
165
  * Vendor-specific configuration for Mistral
@@ -0,0 +1,135 @@
1
+ import { History } from "../../history/History";
2
+ import { ModelInfo } from "../BaseAgent";
3
+ import { ResponseInputItem } from "openai/resources/responses/responses";
4
+ import { OpenAIModel } from "../model-types";
5
+ import { AgentConfig as OpenAiAgentConfig, OpenAiAgent } from "./OpenAiAgent";
6
+ import { CodexCredentials, CodexModelCard, CodexTokenProviderOptions } from "./codex-auth";
7
+ /**
8
+ * Models the ChatGPT-backed Codex backend serves.
9
+ *
10
+ * A different namespace from the platform API's — every platform id
11
+ * (`gpt-5.6`, `gpt-4.1-mini`, even `gpt-5.1-codex`) is rejected here with
12
+ * *"model is not supported when using Codex with a ChatGPT account"*. Probed
13
+ * live on 2026-09-09; `(string & {})` keeps a newer model usable without a
14
+ * release, while still autocompleting the known ones.
15
+ */
16
+ export type CodexModel = "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-5.5" | "gpt-6-astra" | "codex-auto-review" | (string & Record<never, never>);
17
+ /**
18
+ * Reasoning efforts the Codex models accept — a different set from the platform
19
+ * API's, and uniform across these models rather than per-family. Each model's
20
+ * live list is on `ModelInfo.raw.supported_reasoning_levels`.
21
+ */
22
+ export type CodexReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
23
+ export type CodexAgentConfig = Omit<OpenAiAgentConfig, "model" | "reasoningEffort" | "fetch" | "vendor"> & {
24
+ /** @default "gpt-5.6-luna" */
25
+ model?: CodexModel;
26
+ /**
27
+ * How hard the model should think. `medium` if unset — the backend's own
28
+ * default for these models.
29
+ */
30
+ reasoningEffort?: CodexReasoningEffort;
31
+ /**
32
+ * ChatGPT workspace to bill, sent as the `chatgpt-account-id` header. Take it
33
+ * from {@link loadCodexCredentials}; the backend may reject a request without
34
+ * one.
35
+ */
36
+ accountId?: string;
37
+ /**
38
+ * Client identifier sent as `originator`. OpenAI gates parts of the model
39
+ * catalog on this, so the default mirrors the Codex CLI.
40
+ *
41
+ * @default CODEX_ORIGINATOR
42
+ */
43
+ originator?: string;
44
+ /**
45
+ * `client_version` for the models endpoint, which 400s without one and hides
46
+ * models newer than the version claimed.
47
+ *
48
+ * @default CODEX_CLIENT_VERSION
49
+ */
50
+ clientVersion?: string;
51
+ };
52
+ /**
53
+ * Agent for OpenAI models reached through a **ChatGPT subscription** rather
54
+ * than a platform API key.
55
+ *
56
+ * Talks to `https://chatgpt.com/backend-api/codex`, the endpoint OpenAI's Codex
57
+ * CLI uses, so calls are billed against the subscription instead of an API
58
+ * account. It speaks the Responses API, hence the `OpenAiAgent` base — but the
59
+ * two are far enough apart that mixing them in one class meant lying to the
60
+ * type system about which models exist:
61
+ *
62
+ * | | platform | Codex |
63
+ * |---|---|---|
64
+ * | models | `gpt-5.6`, `gpt-4.1-mini`, … | `gpt-5.6-luna/sol/terra`, … — disjoint sets |
65
+ * | body | as written | `instructions` required, `stream: true`, no `max_output_tokens` |
66
+ * | errors | `{error: {…}}` | `{detail: …}` |
67
+ * | terminal event | `output` populated | `output: []`; content arrives as items |
68
+ * | models endpoint | `/v1/models` | `/models?client_version=…` |
69
+ *
70
+ * Nothing here is a documented public API and OpenAI can change it without
71
+ * notice; {@link OpenAiAgent} with a platform key remains the supported path.
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Reads the credentials `codex login` stored, and keeps the token fresh.
76
+ * const agent = await CodexAgent.fromCodexCli({
77
+ * id: "1",
78
+ * name: "Assistant",
79
+ * description: "A helpful assistant",
80
+ * });
81
+ *
82
+ * console.log(await agent.execute("Hello!"));
83
+ * ```
84
+ */
85
+ export declare class CodexAgent extends OpenAiAgent<OpenAIModel, CodexModelCard> {
86
+ private readonly accountId?;
87
+ private readonly originator;
88
+ private readonly clientVersion;
89
+ private readonly codexBaseURL;
90
+ constructor(config: CodexAgentConfig, history?: History);
91
+ /**
92
+ * Build an agent from the credentials `codex login` stored, wrapped in a
93
+ * provider that refreshes the access token as it ages out.
94
+ *
95
+ * @throws if no credentials are present — run `codex login` first.
96
+ */
97
+ static fromCodexCli(config: Omit<CodexAgentConfig, "apiKey" | "accountId"> & {
98
+ /** Read `auth.json` from somewhere other than `$CODEX_HOME`. */
99
+ codexHome?: string;
100
+ /** Forwarded to {@link createCodexTokenProvider}. */
101
+ tokenOptions?: CodexTokenProviderOptions;
102
+ }, history?: History): Promise<CodexAgent>;
103
+ /** Build an agent from credentials obtained however you like. */
104
+ static fromCredentials(credentials: CodexCredentials, config: Omit<CodexAgentConfig, "apiKey" | "accountId"> & {
105
+ tokenOptions?: CodexTokenProviderOptions;
106
+ }, history?: History): CodexAgent;
107
+ /** This backend refuses `stream: false` outright. */
108
+ protected get forceStreaming(): boolean;
109
+ /**
110
+ * Satisfy the backend's extra body validations, each of which is otherwise a
111
+ * bare `400`: *"Instructions are required"*, *"Input must be a list"*,
112
+ * *"Store must be set to false"*, *"Stream must be set to true"*,
113
+ * *"Unsupported parameter: max_output_tokens"*.
114
+ *
115
+ * `store: false` and a list-shaped `input` already hold at every call site in
116
+ * the base class.
117
+ */
118
+ protected transformRequestParams<T extends {
119
+ input: ResponseInputItem[];
120
+ }>(params: T): T;
121
+ /**
122
+ * List the models this ChatGPT account may drive.
123
+ *
124
+ * Neither the endpoint nor the shape matches the platform API's
125
+ * `/v1/models`: it needs a `client_version` query parameter (400s without
126
+ * one) and returns richer cards — the context window for this account's
127
+ * plan, the reasoning efforts the model accepts, the plans it is available
128
+ * in. The SDK has no method for it, so this goes out through `fetch`.
129
+ *
130
+ * Models whose `minimal_client_version` exceeds {@link clientVersion} are
131
+ * omitted by the server, not here.
132
+ */
133
+ listModels(): Promise<ModelInfo<CodexModelCard>[]>;
134
+ }
135
+ //# sourceMappingURL=CodexAgent.d.ts.map
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CodexAgent = void 0;
4
+ const AgentError_1 = require("../errors/AgentError");
5
+ const OpenAiAgent_1 = require("./OpenAiAgent");
6
+ const codex_auth_1 = require("./codex-auth");
7
+ /**
8
+ * Agent for OpenAI models reached through a **ChatGPT subscription** rather
9
+ * than a platform API key.
10
+ *
11
+ * Talks to `https://chatgpt.com/backend-api/codex`, the endpoint OpenAI's Codex
12
+ * CLI uses, so calls are billed against the subscription instead of an API
13
+ * account. It speaks the Responses API, hence the `OpenAiAgent` base — but the
14
+ * two are far enough apart that mixing them in one class meant lying to the
15
+ * type system about which models exist:
16
+ *
17
+ * | | platform | Codex |
18
+ * |---|---|---|
19
+ * | models | `gpt-5.6`, `gpt-4.1-mini`, … | `gpt-5.6-luna/sol/terra`, … — disjoint sets |
20
+ * | body | as written | `instructions` required, `stream: true`, no `max_output_tokens` |
21
+ * | errors | `{error: {…}}` | `{detail: …}` |
22
+ * | terminal event | `output` populated | `output: []`; content arrives as items |
23
+ * | models endpoint | `/v1/models` | `/models?client_version=…` |
24
+ *
25
+ * Nothing here is a documented public API and OpenAI can change it without
26
+ * notice; {@link OpenAiAgent} with a platform key remains the supported path.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Reads the credentials `codex login` stored, and keeps the token fresh.
31
+ * const agent = await CodexAgent.fromCodexCli({
32
+ * id: "1",
33
+ * name: "Assistant",
34
+ * description: "A helpful assistant",
35
+ * });
36
+ *
37
+ * console.log(await agent.execute("Hello!"));
38
+ * ```
39
+ */
40
+ class CodexAgent extends OpenAiAgent_1.OpenAiAgent {
41
+ constructor(config, history) {
42
+ const vendorConfig = config.vendorConfig?.openai ?? {};
43
+ const accountId = config.accountId ?? vendorConfig.accountId;
44
+ const originator = config.originator ?? vendorConfig.originator ?? codex_auth_1.CODEX_ORIGINATOR;
45
+ const baseURL = config.baseURL ?? vendorConfig.baseURL ?? codex_auth_1.CODEX_BASE_URL;
46
+ // Everything host-specific is passed *into* the base constructor rather
47
+ // than supplied by an override: the base runs before this class's fields
48
+ // are assigned, so an override could not read them.
49
+ super({
50
+ ...config,
51
+ model: config.model ?? "gpt-5.6-luna",
52
+ reasoningEffort: config.reasoningEffort,
53
+ baseURL,
54
+ defaultHeaders: {
55
+ ...(accountId ? { "chatgpt-account-id": accountId } : {}),
56
+ "OpenAI-Beta": "responses=experimental",
57
+ originator,
58
+ // Every Codex request is a stream; the SDK would send
59
+ // `application/json`, which no reference client does.
60
+ Accept: "text/event-stream",
61
+ ...config.defaultHeaders,
62
+ },
63
+ // This backend reports failures as `{detail: …}`, which the SDK drops
64
+ // on the floor — see wrapErrorBodyFetch().
65
+ fetch: (0, OpenAiAgent_1.wrapErrorBodyFetch)(),
66
+ // Cast: the codex-specific keys (accountId, originator, clientVersion)
67
+ // are not part of the base config, and `vendor` is supplied by it.
68
+ }, history);
69
+ this.accountId = accountId;
70
+ this.originator = originator;
71
+ this.clientVersion =
72
+ config.clientVersion ?? vendorConfig.clientVersion ?? codex_auth_1.CODEX_CLIENT_VERSION;
73
+ this.codexBaseURL = baseURL;
74
+ }
75
+ /**
76
+ * Build an agent from the credentials `codex login` stored, wrapped in a
77
+ * provider that refreshes the access token as it ages out.
78
+ *
79
+ * @throws if no credentials are present — run `codex login` first.
80
+ */
81
+ static async fromCodexCli(config, history) {
82
+ const credentials = await (0, codex_auth_1.loadCodexCredentials)(config.codexHome);
83
+ return CodexAgent.fromCredentials(credentials, config, history);
84
+ }
85
+ /** Build an agent from credentials obtained however you like. */
86
+ static fromCredentials(credentials, config, history) {
87
+ const tokens = (0, codex_auth_1.createCodexTokenProvider)(credentials, config.tokenOptions);
88
+ return new CodexAgent({
89
+ ...config,
90
+ // The function form: the SDK re-invokes it before every request, so a
91
+ // long run outlives the ~1h token.
92
+ apiKey: tokens.getToken,
93
+ accountId: credentials.accountId,
94
+ }, history);
95
+ }
96
+ /** This backend refuses `stream: false` outright. */
97
+ get forceStreaming() {
98
+ return true;
99
+ }
100
+ /**
101
+ * Satisfy the backend's extra body validations, each of which is otherwise a
102
+ * bare `400`: *"Instructions are required"*, *"Input must be a list"*,
103
+ * *"Store must be set to false"*, *"Stream must be set to true"*,
104
+ * *"Unsupported parameter: max_output_tokens"*.
105
+ *
106
+ * `store: false` and a list-shaped `input` already hold at every call site in
107
+ * the base class.
108
+ */
109
+ transformRequestParams(params) {
110
+ // Read from history rather than getSystemMessage(): that is the message
111
+ // being stripped from `input` below, and a caller may have replaced it.
112
+ const systemMessage = this.history.getSystemMessage() ?? this.getSystemMessage();
113
+ // Rejected outright, so it cannot merely be left undefined when the caller
114
+ // set `maxTokens`.
115
+ const { max_output_tokens: _dropped, ...rest } = params;
116
+ return {
117
+ ...rest,
118
+ // Must be present and non-empty.
119
+ instructions: systemMessage?.trim()
120
+ ? systemMessage
121
+ : "You are a helpful assistant.",
122
+ // The system prompt travels in `instructions` now, so drop the copy the
123
+ // transformer put in `input` rather than sending it twice.
124
+ input: params.input.filter((item) => !(typeof item === "object" &&
125
+ item !== null &&
126
+ "role" in item &&
127
+ item.role === "system")),
128
+ };
129
+ }
130
+ /**
131
+ * List the models this ChatGPT account may drive.
132
+ *
133
+ * Neither the endpoint nor the shape matches the platform API's
134
+ * `/v1/models`: it needs a `client_version` query parameter (400s without
135
+ * one) and returns richer cards — the context window for this account's
136
+ * plan, the reasoning efforts the model accepts, the plans it is available
137
+ * in. The SDK has no method for it, so this goes out through `fetch`.
138
+ *
139
+ * Models whose `minimal_client_version` exceeds {@link clientVersion} are
140
+ * omitted by the server, not here.
141
+ */
142
+ async listModels() {
143
+ try {
144
+ const token = await this.resolveApiKey();
145
+ const url = `${this.codexBaseURL}/models?client_version=${encodeURIComponent(this.clientVersion)}`;
146
+ const res = await fetch(url, {
147
+ headers: {
148
+ Authorization: `Bearer ${token}`,
149
+ ...(this.accountId ? { "chatgpt-account-id": this.accountId } : {}),
150
+ originator: this.originator,
151
+ },
152
+ });
153
+ if (!res.ok) {
154
+ const body = await res.text().catch(() => "");
155
+ throw new Error(`${res.status} ${res.statusText}${body ? `: ${body.slice(0, 300)}` : ""}`);
156
+ }
157
+ const data = (await res.json());
158
+ return (data.models ?? []).map((model) => ({
159
+ id: model.slug,
160
+ displayName: model.display_name,
161
+ // The plan's window, not the model's ceiling — `max_context_window` is
162
+ // on `raw` for anyone who needs the larger number.
163
+ contextLength: model.context_window,
164
+ capabilities: {
165
+ chat: true,
166
+ tools: true,
167
+ vision: model.input_modalities?.includes("image"),
168
+ thinking: (model.supported_reasoning_levels?.length ?? 0) > 0,
169
+ },
170
+ raw: model,
171
+ }));
172
+ }
173
+ catch (error) {
174
+ throw new AgentError_1.ExecutionError(`Failed to list Codex models: ${error instanceof Error ? error.message : "Unknown error"}`);
175
+ }
176
+ }
177
+ }
178
+ exports.CodexAgent = CodexAgent;
179
+ //# sourceMappingURL=CodexAgent.js.map
@@ -2,14 +2,30 @@ import { BaseAgent, BaseAgentConfig, ModelInfo, TokenUsage } from "../BaseAgent"
2
2
  import { ExecuteOptions } from "../cancellation";
3
3
  import { History, MessageContent } from "../../history/History";
4
4
  import { type BuiltInTool } from "../../tools/BuiltInTool";
5
- import { Tool, Response, ResponseUsage } from "openai/resources/responses/responses";
5
+ import { Tool, Response, ResponseInputItem, ResponseUsage } from "openai/resources/responses/responses";
6
6
  import type { Model as OpenAIModelCard } from "openai/resources/models";
7
7
  import { OpenAIModel, ReasoningEffort, ReasoningEffortFor } from "../model-types";
8
8
  import { StreamChunk } from "../openai-compatible/OpenAICompatibleAgent";
9
- type AgentConfig<M extends OpenAIModel = OpenAIModel> = BaseAgentConfig & {
10
- apiKey: string;
9
+ export type AgentConfig<M extends OpenAIModel = OpenAIModel> = Omit<BaseAgentConfig, "apiKey"> & {
10
+ /**
11
+ * Platform API key, or an async function returning one.
12
+ *
13
+ * A function is re-invoked before every request, so a rotating or refreshed
14
+ * credential stays current across a long run — which is how `CodexAgent`
15
+ * keeps a ChatGPT OAuth token alive.
16
+ */
17
+ apiKey: string | (() => Promise<string>);
11
18
  model?: M;
12
19
  maxTokens?: number;
20
+ /**
21
+ * Override the API base URL. Defaults to the SDK's `api.openai.com/v1`.
22
+ */
23
+ baseURL?: string;
24
+ /**
25
+ * Replace the `fetch` used for every request — for interception, proxying, or
26
+ * normalising a non-OpenAI host's error bodies (see {@link wrapErrorBodyFetch}).
27
+ */
28
+ fetch?: typeof fetch;
13
29
  disableParallelToolUse?: boolean;
14
30
  /**
15
31
  * Ask for the least reasoning the configured model supports (e.g. `minimal` on
@@ -47,6 +63,37 @@ type AgentConfig<M extends OpenAIModel = OpenAIModel> = BaseAgentConfig & {
47
63
  * `reasoningEffort` explicitly to override.
48
64
  */
49
65
  export declare function lowestReasoningEffort(model: string | undefined): ReasoningEffort | undefined;
66
+ /**
67
+ * `fetch` wrapper that rewrites a non-OpenAI-shaped error body into the shape
68
+ * the SDK can read.
69
+ *
70
+ * `APIError.generate` takes the message from `body.error` and throws the rest
71
+ * away (`openai/core/error.js`), so a backend that reports failures as
72
+ * `{"detail": "..."}` — which the ChatGPT Codex endpoint does, for all four of
73
+ * its body validations plus auth failures — surfaces as the useless
74
+ * `400 status code (no body)`. Nesting the original body under `error` puts the
75
+ * real reason back in the thrown error.
76
+ *
77
+ * Only touches error responses; successful (streaming) responses pass straight
78
+ * through untouched.
79
+ */
80
+ export declare function wrapErrorBodyFetch(baseFetch?: typeof fetch): typeof fetch;
81
+ /**
82
+ * Pull a human-readable message out of an OpenAI-shaped error.
83
+ *
84
+ * `api.openai.com` answers with `{ error: { message, code } }`, but not every
85
+ * host behind this SDK does — the ChatGPT Codex backend reports its validation
86
+ * failures as `{ detail: "Instructions are required" }`. Reading
87
+ * `error.error.message` blindly turns those into a `TypeError` that hides the
88
+ * real cause, so every field is probed defensively and the SDK's own `message`
89
+ * is the last resort.
90
+ */
91
+ export declare function describeOpenAIError(error: unknown): {
92
+ message: string;
93
+ code?: string;
94
+ status?: number;
95
+ body?: unknown;
96
+ };
50
97
  /**
51
98
  * Agent for OpenAI models using the Responses API.
52
99
  *
@@ -62,7 +109,7 @@ export declare function lowestReasoningEffort(model: string | undefined): Reason
62
109
  * const response = await agent.execute("Hello!");
63
110
  * ```
64
111
  */
65
- export declare class OpenAiAgent<M extends OpenAIModel = OpenAIModel> extends BaseAgent {
112
+ export declare class OpenAiAgent<M extends OpenAIModel = OpenAIModel, TModelCard = OpenAIModelCard> extends BaseAgent {
66
113
  private client;
67
114
  /**
68
115
  * Resolved runtime config. Deliberately not narrowed by `M` — the constructor
@@ -75,6 +122,19 @@ export declare class OpenAiAgent<M extends OpenAIModel = OpenAIModel> extends Ba
75
122
  private vizEventId?;
76
123
  /** Count of tool calls in current execution */
77
124
  private currentToolCallCount;
125
+ /**
126
+ * Whether a non-streaming call must be issued as a stream and collapsed.
127
+ * `false` here; `CodexAgent` overrides it, since that backend refuses
128
+ * `stream: false` outright.
129
+ */
130
+ protected get forceStreaming(): boolean;
131
+ /**
132
+ * Last chance to reshape a request body before it goes out. Identity here —
133
+ * `CodexAgent` overrides it to satisfy that backend's extra validations.
134
+ */
135
+ protected transformRequestParams<T extends {
136
+ input: ResponseInputItem[];
137
+ }>(params: T): T;
78
138
  constructor(config: Omit<AgentConfig<M>, "vendor">, history?: History);
79
139
  /**
80
140
  * List the models available to this API key.
@@ -83,7 +143,9 @@ export declare class OpenAiAgent<M extends OpenAIModel = OpenAIModel> extends Ba
83
143
  * image models alike — so filter by `id` if you only want the ones this
84
144
  * agent can drive.
85
145
  */
86
- listModels(): Promise<ModelInfo<OpenAIModelCard>[]>;
146
+ listModels(): Promise<ModelInfo<TModelCard>[]>;
147
+ /** The configured key, resolving the function form if that is what was given. */
148
+ protected resolveApiKey(): Promise<string>;
87
149
  protected getToolDefinitions(): Tool[];
88
150
  /**
89
151
  * Combine locally-executed tool definitions with provider-defined
@@ -94,6 +156,28 @@ export declare class OpenAiAgent<M extends OpenAIModel = OpenAIModel> extends Ba
94
156
  * uses for its own `ToolUnion[]`.
95
157
  */
96
158
  protected getAllToolDefinitions(): Tool[];
159
+ /**
160
+ * Rebuild a terminal response's `output` from the items streamed alongside it.
161
+ *
162
+ * The Codex backend sends `response.completed` with `output: []` and no
163
+ * `output_text`, unlike the platform API which fills both in — the content
164
+ * only ever arrives as `response.output_item.done` events. Everything
165
+ * downstream (tool-call detection, the text written to history) reads
166
+ * `output`, so without this a Codex turn silently commits an empty assistant
167
+ * message and drops every tool call.
168
+ *
169
+ * A no-op wherever `output` is already populated, so the platform path is
170
+ * untouched.
171
+ */
172
+ private repairStreamedOutput;
173
+ /**
174
+ * Issue a non-streaming Responses API call.
175
+ *
176
+ * When {@link forceStreaming} is set the request is streamed and the terminal
177
+ * event's `response` handed back instead — giving callers the same `Response`
178
+ * either way, at the cost of buffering the turn.
179
+ */
180
+ private createResponse;
97
181
  /**
98
182
  * Build the `reasoning` field for a Responses API request, as an object to
99
183
  * spread into the request params.
@@ -131,5 +215,4 @@ export declare class OpenAiAgent<M extends OpenAIModel = OpenAIModel> extends Ba
131
215
  private streamTurn;
132
216
  protected parseUsage(input: ResponseUsage): TokenUsage;
133
217
  }
134
- export {};
135
218
  //# sourceMappingURL=OpenAiAgent.d.ts.map