ai-sdk-provider-codex-cli 0.3.0 → 0.5.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.
package/dist/index.d.cts CHANGED
@@ -1,11 +1,51 @@
1
1
  import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
2
2
 
3
+ /**
4
+ * Logger interface for custom logging.
5
+ * Allows consumers to provide their own logging implementation
6
+ * or disable logging entirely.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const customLogger: Logger = {
11
+ * debug: (message) => myLoggingService.debug(message),
12
+ * info: (message) => myLoggingService.info(message),
13
+ * warn: (message) => myLoggingService.warn(message),
14
+ * error: (message) => myLoggingService.error(message),
15
+ * };
16
+ * ```
17
+ */
3
18
  interface Logger {
19
+ /**
20
+ * Log a debug message. Only logged when verbose mode is enabled.
21
+ * Used for detailed execution tracing and troubleshooting.
22
+ */
23
+ debug: (message: string) => void;
24
+ /**
25
+ * Log an informational message. Only logged when verbose mode is enabled.
26
+ * Used for general execution flow information.
27
+ */
28
+ info: (message: string) => void;
29
+ /**
30
+ * Log a warning message.
31
+ */
4
32
  warn: (message: string) => void;
33
+ /**
34
+ * Log an error message.
35
+ */
5
36
  error: (message: string) => void;
6
37
  }
7
38
  type ApprovalMode = 'untrusted' | 'on-failure' | 'on-request' | 'never';
8
39
  type SandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
40
+ type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
41
+ /**
42
+ * Reasoning summary detail level.
43
+ * Note: The API error messages claim 'concise' and 'none' are valid, but they are
44
+ * actually rejected with 400 errors. Only 'auto' and 'detailed' work in practice.
45
+ */
46
+ type ReasoningSummary = 'auto' | 'detailed';
47
+ type ReasoningSummaryFormat = 'none' | 'experimental';
48
+ type ModelVerbosity = 'low' | 'medium' | 'high';
9
49
  interface CodexCliSettings {
10
50
  codexPath?: string;
11
51
  cwd?: string;
@@ -20,10 +60,116 @@ interface CodexCliSettings {
20
60
  env?: Record<string, string>;
21
61
  verbose?: boolean;
22
62
  logger?: Logger | false;
63
+ /**
64
+ * Controls reasoning effort for reasoning-capable models (o3, o4-mini, gpt-5, gpt-5-codex).
65
+ * Higher effort produces more thorough reasoning at the cost of latency.
66
+ *
67
+ * Maps to: `-c model_reasoning_effort=<value>`
68
+ * @see https://platform.openai.com/docs/guides/reasoning
69
+ */
70
+ reasoningEffort?: ReasoningEffort;
71
+ /**
72
+ * Controls reasoning summary detail level.
73
+ *
74
+ * Valid values: 'auto' | 'detailed'
75
+ * Note: Despite API error messages claiming 'concise' and 'none' are valid,
76
+ * they are rejected with 400 errors in practice.
77
+ *
78
+ * Maps to: `-c model_reasoning_summary=<value>`
79
+ * @see https://platform.openai.com/docs/guides/reasoning#reasoning-summaries
80
+ */
81
+ reasoningSummary?: ReasoningSummary;
82
+ /**
83
+ * Controls reasoning summary format (experimental).
84
+ *
85
+ * Maps to: `-c model_reasoning_summary_format=<value>`
86
+ */
87
+ reasoningSummaryFormat?: ReasoningSummaryFormat;
88
+ /**
89
+ * Controls output length/detail for GPT-5 family models.
90
+ * Only applies to models using the Responses API.
91
+ *
92
+ * Maps to: `-c model_verbosity=<value>`
93
+ */
94
+ modelVerbosity?: ModelVerbosity;
95
+ /**
96
+ * Include experimental plan tool that the model can use to update its current plan.
97
+ *
98
+ * Maps to: `--include-plan-tool`
99
+ */
100
+ includePlanTool?: boolean;
101
+ /**
102
+ * Configuration profile from config.toml to specify default options.
103
+ *
104
+ * Maps to: `--profile <name>`
105
+ */
106
+ profile?: string;
107
+ /**
108
+ * Use OSS provider (experimental).
109
+ *
110
+ * Maps to: `--oss`
111
+ */
112
+ oss?: boolean;
113
+ /**
114
+ * Enable web search tool for the model.
115
+ *
116
+ * Maps to: `-c tools.web_search=true`
117
+ */
118
+ webSearch?: boolean;
119
+ /**
120
+ * Generic Codex CLI config overrides. Allows setting any config value
121
+ * without updating the provider.
122
+ *
123
+ * Each entry maps to: `-c <key>=<value>`
124
+ *
125
+ * Examples:
126
+ * - `{ experimental_resume: '/tmp/session.jsonl' }`
127
+ * - `{ 'model_providers.custom.base_url': 'http://localhost:8000' }`
128
+ * - `{ 'sandbox_workspace_write': { network_access: true } }`
129
+ *
130
+ * Values are serialized:
131
+ * - string → raw string
132
+ * - number/boolean → String(value)
133
+ * - plain objects → flattened recursively to dotted keys
134
+ * - arrays → JSON.stringify(value)
135
+ * - other objects (Date, RegExp, Map, etc.) → JSON.stringify(value)
136
+ */
137
+ configOverrides?: Record<string, string | number | boolean | object>;
23
138
  }
24
139
  interface CodexCliProviderSettings {
25
140
  defaultSettings?: CodexCliSettings;
26
141
  }
142
+ /**
143
+ * Per-call overrides supplied through AI SDK providerOptions.
144
+ * These values take precedence over constructor-level CodexCliSettings.
145
+ */
146
+ interface CodexCliProviderOptions {
147
+ /**
148
+ * Per-call override for reasoning depth.
149
+ * Maps to `model_reasoning_effort`.
150
+ */
151
+ reasoningEffort?: ReasoningEffort;
152
+ /**
153
+ * Per-call override for reasoning summary detail level.
154
+ * Maps to `model_reasoning_summary`.
155
+ */
156
+ reasoningSummary?: ReasoningSummary;
157
+ /**
158
+ * Per-call override for reasoning summary format.
159
+ * Maps to `model_reasoning_summary_format`.
160
+ */
161
+ reasoningSummaryFormat?: ReasoningSummaryFormat;
162
+ /**
163
+ * AI SDK naming for per-call verbosity overrides.
164
+ * Maps to Codex `model_verbosity`.
165
+ */
166
+ textVerbosity?: ModelVerbosity;
167
+ /**
168
+ * Per-call Codex CLI config overrides. These are merged with
169
+ * constructor-level overrides with per-call values taking precedence.
170
+ */
171
+ configOverrides?: Record<string, string | number | boolean | object>;
172
+ }
27
173
 
28
174
  interface CodexCliProvider extends ProviderV2 {
29
175
  (modelId: string, settings?: CodexCliSettings): LanguageModelV2;
@@ -51,8 +197,15 @@ declare class CodexCliLanguageModel implements LanguageModelV2 {
51
197
  private logger;
52
198
  private sessionId?;
53
199
  constructor(options: CodexLanguageModelOptions);
200
+ private mergeSettings;
54
201
  private getItemType;
55
202
  private buildArgs;
203
+ private addConfigOverride;
204
+ /**
205
+ * Serialize a config override value into a CLI-safe string.
206
+ */
207
+ private serializeConfigValue;
208
+ private isPlainObject;
56
209
  private sanitizeJsonSchema;
57
210
  private mapWarnings;
58
211
  private parseExperimentalJsonEvent;
@@ -70,4 +223,4 @@ declare class CodexCliLanguageModel implements LanguageModelV2 {
70
223
 
71
224
  declare function isAuthenticationError(err: unknown): boolean;
72
225
 
73
- export { CodexCliLanguageModel, type CodexCliProvider, type CodexCliProviderSettings, type CodexCliSettings, type Logger, codexCli, createCodexCli, isAuthenticationError };
226
+ export { CodexCliLanguageModel, type CodexCliProvider, type CodexCliProviderOptions, type CodexCliProviderSettings, type CodexCliSettings, type Logger, type ModelVerbosity, type ReasoningEffort, type ReasoningSummary, type ReasoningSummaryFormat, codexCli, createCodexCli, isAuthenticationError };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,51 @@
1
1
  import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
2
2
 
3
+ /**
4
+ * Logger interface for custom logging.
5
+ * Allows consumers to provide their own logging implementation
6
+ * or disable logging entirely.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const customLogger: Logger = {
11
+ * debug: (message) => myLoggingService.debug(message),
12
+ * info: (message) => myLoggingService.info(message),
13
+ * warn: (message) => myLoggingService.warn(message),
14
+ * error: (message) => myLoggingService.error(message),
15
+ * };
16
+ * ```
17
+ */
3
18
  interface Logger {
19
+ /**
20
+ * Log a debug message. Only logged when verbose mode is enabled.
21
+ * Used for detailed execution tracing and troubleshooting.
22
+ */
23
+ debug: (message: string) => void;
24
+ /**
25
+ * Log an informational message. Only logged when verbose mode is enabled.
26
+ * Used for general execution flow information.
27
+ */
28
+ info: (message: string) => void;
29
+ /**
30
+ * Log a warning message.
31
+ */
4
32
  warn: (message: string) => void;
33
+ /**
34
+ * Log an error message.
35
+ */
5
36
  error: (message: string) => void;
6
37
  }
7
38
  type ApprovalMode = 'untrusted' | 'on-failure' | 'on-request' | 'never';
8
39
  type SandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
40
+ type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
41
+ /**
42
+ * Reasoning summary detail level.
43
+ * Note: The API error messages claim 'concise' and 'none' are valid, but they are
44
+ * actually rejected with 400 errors. Only 'auto' and 'detailed' work in practice.
45
+ */
46
+ type ReasoningSummary = 'auto' | 'detailed';
47
+ type ReasoningSummaryFormat = 'none' | 'experimental';
48
+ type ModelVerbosity = 'low' | 'medium' | 'high';
9
49
  interface CodexCliSettings {
10
50
  codexPath?: string;
11
51
  cwd?: string;
@@ -20,10 +60,116 @@ interface CodexCliSettings {
20
60
  env?: Record<string, string>;
21
61
  verbose?: boolean;
22
62
  logger?: Logger | false;
63
+ /**
64
+ * Controls reasoning effort for reasoning-capable models (o3, o4-mini, gpt-5, gpt-5-codex).
65
+ * Higher effort produces more thorough reasoning at the cost of latency.
66
+ *
67
+ * Maps to: `-c model_reasoning_effort=<value>`
68
+ * @see https://platform.openai.com/docs/guides/reasoning
69
+ */
70
+ reasoningEffort?: ReasoningEffort;
71
+ /**
72
+ * Controls reasoning summary detail level.
73
+ *
74
+ * Valid values: 'auto' | 'detailed'
75
+ * Note: Despite API error messages claiming 'concise' and 'none' are valid,
76
+ * they are rejected with 400 errors in practice.
77
+ *
78
+ * Maps to: `-c model_reasoning_summary=<value>`
79
+ * @see https://platform.openai.com/docs/guides/reasoning#reasoning-summaries
80
+ */
81
+ reasoningSummary?: ReasoningSummary;
82
+ /**
83
+ * Controls reasoning summary format (experimental).
84
+ *
85
+ * Maps to: `-c model_reasoning_summary_format=<value>`
86
+ */
87
+ reasoningSummaryFormat?: ReasoningSummaryFormat;
88
+ /**
89
+ * Controls output length/detail for GPT-5 family models.
90
+ * Only applies to models using the Responses API.
91
+ *
92
+ * Maps to: `-c model_verbosity=<value>`
93
+ */
94
+ modelVerbosity?: ModelVerbosity;
95
+ /**
96
+ * Include experimental plan tool that the model can use to update its current plan.
97
+ *
98
+ * Maps to: `--include-plan-tool`
99
+ */
100
+ includePlanTool?: boolean;
101
+ /**
102
+ * Configuration profile from config.toml to specify default options.
103
+ *
104
+ * Maps to: `--profile <name>`
105
+ */
106
+ profile?: string;
107
+ /**
108
+ * Use OSS provider (experimental).
109
+ *
110
+ * Maps to: `--oss`
111
+ */
112
+ oss?: boolean;
113
+ /**
114
+ * Enable web search tool for the model.
115
+ *
116
+ * Maps to: `-c tools.web_search=true`
117
+ */
118
+ webSearch?: boolean;
119
+ /**
120
+ * Generic Codex CLI config overrides. Allows setting any config value
121
+ * without updating the provider.
122
+ *
123
+ * Each entry maps to: `-c <key>=<value>`
124
+ *
125
+ * Examples:
126
+ * - `{ experimental_resume: '/tmp/session.jsonl' }`
127
+ * - `{ 'model_providers.custom.base_url': 'http://localhost:8000' }`
128
+ * - `{ 'sandbox_workspace_write': { network_access: true } }`
129
+ *
130
+ * Values are serialized:
131
+ * - string → raw string
132
+ * - number/boolean → String(value)
133
+ * - plain objects → flattened recursively to dotted keys
134
+ * - arrays → JSON.stringify(value)
135
+ * - other objects (Date, RegExp, Map, etc.) → JSON.stringify(value)
136
+ */
137
+ configOverrides?: Record<string, string | number | boolean | object>;
23
138
  }
24
139
  interface CodexCliProviderSettings {
25
140
  defaultSettings?: CodexCliSettings;
26
141
  }
142
+ /**
143
+ * Per-call overrides supplied through AI SDK providerOptions.
144
+ * These values take precedence over constructor-level CodexCliSettings.
145
+ */
146
+ interface CodexCliProviderOptions {
147
+ /**
148
+ * Per-call override for reasoning depth.
149
+ * Maps to `model_reasoning_effort`.
150
+ */
151
+ reasoningEffort?: ReasoningEffort;
152
+ /**
153
+ * Per-call override for reasoning summary detail level.
154
+ * Maps to `model_reasoning_summary`.
155
+ */
156
+ reasoningSummary?: ReasoningSummary;
157
+ /**
158
+ * Per-call override for reasoning summary format.
159
+ * Maps to `model_reasoning_summary_format`.
160
+ */
161
+ reasoningSummaryFormat?: ReasoningSummaryFormat;
162
+ /**
163
+ * AI SDK naming for per-call verbosity overrides.
164
+ * Maps to Codex `model_verbosity`.
165
+ */
166
+ textVerbosity?: ModelVerbosity;
167
+ /**
168
+ * Per-call Codex CLI config overrides. These are merged with
169
+ * constructor-level overrides with per-call values taking precedence.
170
+ */
171
+ configOverrides?: Record<string, string | number | boolean | object>;
172
+ }
27
173
 
28
174
  interface CodexCliProvider extends ProviderV2 {
29
175
  (modelId: string, settings?: CodexCliSettings): LanguageModelV2;
@@ -51,8 +197,15 @@ declare class CodexCliLanguageModel implements LanguageModelV2 {
51
197
  private logger;
52
198
  private sessionId?;
53
199
  constructor(options: CodexLanguageModelOptions);
200
+ private mergeSettings;
54
201
  private getItemType;
55
202
  private buildArgs;
203
+ private addConfigOverride;
204
+ /**
205
+ * Serialize a config override value into a CLI-safe string.
206
+ */
207
+ private serializeConfigValue;
208
+ private isPlainObject;
56
209
  private sanitizeJsonSchema;
57
210
  private mapWarnings;
58
211
  private parseExperimentalJsonEvent;
@@ -70,4 +223,4 @@ declare class CodexCliLanguageModel implements LanguageModelV2 {
70
223
 
71
224
  declare function isAuthenticationError(err: unknown): boolean;
72
225
 
73
- export { CodexCliLanguageModel, type CodexCliProvider, type CodexCliProviderSettings, type CodexCliSettings, type Logger, codexCli, createCodexCli, isAuthenticationError };
226
+ export { CodexCliLanguageModel, type CodexCliProvider, type CodexCliProviderOptions, type CodexCliProviderSettings, type CodexCliSettings, type Logger, type ModelVerbosity, type ReasoningEffort, type ReasoningSummary, type ReasoningSummaryFormat, codexCli, createCodexCli, isAuthenticationError };