ai-sdk-provider-codex-cli 0.2.0 → 0.4.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/README.md +104 -2
- package/dist/index.cjs +532 -96
- package/dist/index.d.cts +131 -1
- package/dist/index.d.ts +131 -1
- package/dist/index.js +532 -96
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -6,6 +6,15 @@ interface Logger {
|
|
|
6
6
|
}
|
|
7
7
|
type ApprovalMode = 'untrusted' | 'on-failure' | 'on-request' | 'never';
|
|
8
8
|
type SandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
|
|
9
|
+
type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
|
|
10
|
+
/**
|
|
11
|
+
* Reasoning summary detail level.
|
|
12
|
+
* Note: The API error messages claim 'concise' and 'none' are valid, but they are
|
|
13
|
+
* actually rejected with 400 errors. Only 'auto' and 'detailed' work in practice.
|
|
14
|
+
*/
|
|
15
|
+
type ReasoningSummary = 'auto' | 'detailed';
|
|
16
|
+
type ReasoningSummaryFormat = 'none' | 'experimental';
|
|
17
|
+
type ModelVerbosity = 'low' | 'medium' | 'high';
|
|
9
18
|
interface CodexCliSettings {
|
|
10
19
|
codexPath?: string;
|
|
11
20
|
cwd?: string;
|
|
@@ -20,10 +29,116 @@ interface CodexCliSettings {
|
|
|
20
29
|
env?: Record<string, string>;
|
|
21
30
|
verbose?: boolean;
|
|
22
31
|
logger?: Logger | false;
|
|
32
|
+
/**
|
|
33
|
+
* Controls reasoning effort for reasoning-capable models (o3, o4-mini, gpt-5, gpt-5-codex).
|
|
34
|
+
* Higher effort produces more thorough reasoning at the cost of latency.
|
|
35
|
+
*
|
|
36
|
+
* Maps to: `-c model_reasoning_effort=<value>`
|
|
37
|
+
* @see https://platform.openai.com/docs/guides/reasoning
|
|
38
|
+
*/
|
|
39
|
+
reasoningEffort?: ReasoningEffort;
|
|
40
|
+
/**
|
|
41
|
+
* Controls reasoning summary detail level.
|
|
42
|
+
*
|
|
43
|
+
* Valid values: 'auto' | 'detailed'
|
|
44
|
+
* Note: Despite API error messages claiming 'concise' and 'none' are valid,
|
|
45
|
+
* they are rejected with 400 errors in practice.
|
|
46
|
+
*
|
|
47
|
+
* Maps to: `-c model_reasoning_summary=<value>`
|
|
48
|
+
* @see https://platform.openai.com/docs/guides/reasoning#reasoning-summaries
|
|
49
|
+
*/
|
|
50
|
+
reasoningSummary?: ReasoningSummary;
|
|
51
|
+
/**
|
|
52
|
+
* Controls reasoning summary format (experimental).
|
|
53
|
+
*
|
|
54
|
+
* Maps to: `-c model_reasoning_summary_format=<value>`
|
|
55
|
+
*/
|
|
56
|
+
reasoningSummaryFormat?: ReasoningSummaryFormat;
|
|
57
|
+
/**
|
|
58
|
+
* Controls output length/detail for GPT-5 family models.
|
|
59
|
+
* Only applies to models using the Responses API.
|
|
60
|
+
*
|
|
61
|
+
* Maps to: `-c model_verbosity=<value>`
|
|
62
|
+
*/
|
|
63
|
+
modelVerbosity?: ModelVerbosity;
|
|
64
|
+
/**
|
|
65
|
+
* Include experimental plan tool that the model can use to update its current plan.
|
|
66
|
+
*
|
|
67
|
+
* Maps to: `--include-plan-tool`
|
|
68
|
+
*/
|
|
69
|
+
includePlanTool?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Configuration profile from config.toml to specify default options.
|
|
72
|
+
*
|
|
73
|
+
* Maps to: `--profile <name>`
|
|
74
|
+
*/
|
|
75
|
+
profile?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Use OSS provider (experimental).
|
|
78
|
+
*
|
|
79
|
+
* Maps to: `--oss`
|
|
80
|
+
*/
|
|
81
|
+
oss?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Enable web search tool for the model.
|
|
84
|
+
*
|
|
85
|
+
* Maps to: `-c tools.web_search=true`
|
|
86
|
+
*/
|
|
87
|
+
webSearch?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Generic Codex CLI config overrides. Allows setting any config value
|
|
90
|
+
* without updating the provider.
|
|
91
|
+
*
|
|
92
|
+
* Each entry maps to: `-c <key>=<value>`
|
|
93
|
+
*
|
|
94
|
+
* Examples:
|
|
95
|
+
* - `{ experimental_resume: '/tmp/session.jsonl' }`
|
|
96
|
+
* - `{ 'model_providers.custom.base_url': 'http://localhost:8000' }`
|
|
97
|
+
* - `{ 'sandbox_workspace_write': { network_access: true } }`
|
|
98
|
+
*
|
|
99
|
+
* Values are serialized:
|
|
100
|
+
* - string → raw string
|
|
101
|
+
* - number/boolean → String(value)
|
|
102
|
+
* - plain objects → flattened recursively to dotted keys
|
|
103
|
+
* - arrays → JSON.stringify(value)
|
|
104
|
+
* - other objects (Date, RegExp, Map, etc.) → JSON.stringify(value)
|
|
105
|
+
*/
|
|
106
|
+
configOverrides?: Record<string, string | number | boolean | object>;
|
|
23
107
|
}
|
|
24
108
|
interface CodexCliProviderSettings {
|
|
25
109
|
defaultSettings?: CodexCliSettings;
|
|
26
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Per-call overrides supplied through AI SDK providerOptions.
|
|
113
|
+
* These values take precedence over constructor-level CodexCliSettings.
|
|
114
|
+
*/
|
|
115
|
+
interface CodexCliProviderOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Per-call override for reasoning depth.
|
|
118
|
+
* Maps to `model_reasoning_effort`.
|
|
119
|
+
*/
|
|
120
|
+
reasoningEffort?: ReasoningEffort;
|
|
121
|
+
/**
|
|
122
|
+
* Per-call override for reasoning summary detail level.
|
|
123
|
+
* Maps to `model_reasoning_summary`.
|
|
124
|
+
*/
|
|
125
|
+
reasoningSummary?: ReasoningSummary;
|
|
126
|
+
/**
|
|
127
|
+
* Per-call override for reasoning summary format.
|
|
128
|
+
* Maps to `model_reasoning_summary_format`.
|
|
129
|
+
*/
|
|
130
|
+
reasoningSummaryFormat?: ReasoningSummaryFormat;
|
|
131
|
+
/**
|
|
132
|
+
* AI SDK naming for per-call verbosity overrides.
|
|
133
|
+
* Maps to Codex `model_verbosity`.
|
|
134
|
+
*/
|
|
135
|
+
textVerbosity?: ModelVerbosity;
|
|
136
|
+
/**
|
|
137
|
+
* Per-call Codex CLI config overrides. These are merged with
|
|
138
|
+
* constructor-level overrides with per-call values taking precedence.
|
|
139
|
+
*/
|
|
140
|
+
configOverrides?: Record<string, string | number | boolean | object>;
|
|
141
|
+
}
|
|
27
142
|
|
|
28
143
|
interface CodexCliProvider extends ProviderV2 {
|
|
29
144
|
(modelId: string, settings?: CodexCliSettings): LanguageModelV2;
|
|
@@ -51,10 +166,25 @@ declare class CodexCliLanguageModel implements LanguageModelV2 {
|
|
|
51
166
|
private logger;
|
|
52
167
|
private sessionId?;
|
|
53
168
|
constructor(options: CodexLanguageModelOptions);
|
|
169
|
+
private mergeSettings;
|
|
170
|
+
private getItemType;
|
|
54
171
|
private buildArgs;
|
|
172
|
+
private addConfigOverride;
|
|
173
|
+
/**
|
|
174
|
+
* Serialize a config override value into a CLI-safe string.
|
|
175
|
+
*/
|
|
176
|
+
private serializeConfigValue;
|
|
177
|
+
private isPlainObject;
|
|
55
178
|
private sanitizeJsonSchema;
|
|
56
179
|
private mapWarnings;
|
|
57
180
|
private parseExperimentalJsonEvent;
|
|
181
|
+
private extractUsage;
|
|
182
|
+
private getToolName;
|
|
183
|
+
private buildToolInputPayload;
|
|
184
|
+
private buildToolResultPayload;
|
|
185
|
+
private safeStringify;
|
|
186
|
+
private emitToolInvocation;
|
|
187
|
+
private emitToolResult;
|
|
58
188
|
private handleSpawnError;
|
|
59
189
|
doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
60
190
|
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
@@ -62,4 +192,4 @@ declare class CodexCliLanguageModel implements LanguageModelV2 {
|
|
|
62
192
|
|
|
63
193
|
declare function isAuthenticationError(err: unknown): boolean;
|
|
64
194
|
|
|
65
|
-
export { CodexCliLanguageModel, type CodexCliProvider, type CodexCliProviderSettings, type CodexCliSettings, type Logger, codexCli, createCodexCli, isAuthenticationError };
|
|
195
|
+
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
|
@@ -6,6 +6,15 @@ interface Logger {
|
|
|
6
6
|
}
|
|
7
7
|
type ApprovalMode = 'untrusted' | 'on-failure' | 'on-request' | 'never';
|
|
8
8
|
type SandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
|
|
9
|
+
type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
|
|
10
|
+
/**
|
|
11
|
+
* Reasoning summary detail level.
|
|
12
|
+
* Note: The API error messages claim 'concise' and 'none' are valid, but they are
|
|
13
|
+
* actually rejected with 400 errors. Only 'auto' and 'detailed' work in practice.
|
|
14
|
+
*/
|
|
15
|
+
type ReasoningSummary = 'auto' | 'detailed';
|
|
16
|
+
type ReasoningSummaryFormat = 'none' | 'experimental';
|
|
17
|
+
type ModelVerbosity = 'low' | 'medium' | 'high';
|
|
9
18
|
interface CodexCliSettings {
|
|
10
19
|
codexPath?: string;
|
|
11
20
|
cwd?: string;
|
|
@@ -20,10 +29,116 @@ interface CodexCliSettings {
|
|
|
20
29
|
env?: Record<string, string>;
|
|
21
30
|
verbose?: boolean;
|
|
22
31
|
logger?: Logger | false;
|
|
32
|
+
/**
|
|
33
|
+
* Controls reasoning effort for reasoning-capable models (o3, o4-mini, gpt-5, gpt-5-codex).
|
|
34
|
+
* Higher effort produces more thorough reasoning at the cost of latency.
|
|
35
|
+
*
|
|
36
|
+
* Maps to: `-c model_reasoning_effort=<value>`
|
|
37
|
+
* @see https://platform.openai.com/docs/guides/reasoning
|
|
38
|
+
*/
|
|
39
|
+
reasoningEffort?: ReasoningEffort;
|
|
40
|
+
/**
|
|
41
|
+
* Controls reasoning summary detail level.
|
|
42
|
+
*
|
|
43
|
+
* Valid values: 'auto' | 'detailed'
|
|
44
|
+
* Note: Despite API error messages claiming 'concise' and 'none' are valid,
|
|
45
|
+
* they are rejected with 400 errors in practice.
|
|
46
|
+
*
|
|
47
|
+
* Maps to: `-c model_reasoning_summary=<value>`
|
|
48
|
+
* @see https://platform.openai.com/docs/guides/reasoning#reasoning-summaries
|
|
49
|
+
*/
|
|
50
|
+
reasoningSummary?: ReasoningSummary;
|
|
51
|
+
/**
|
|
52
|
+
* Controls reasoning summary format (experimental).
|
|
53
|
+
*
|
|
54
|
+
* Maps to: `-c model_reasoning_summary_format=<value>`
|
|
55
|
+
*/
|
|
56
|
+
reasoningSummaryFormat?: ReasoningSummaryFormat;
|
|
57
|
+
/**
|
|
58
|
+
* Controls output length/detail for GPT-5 family models.
|
|
59
|
+
* Only applies to models using the Responses API.
|
|
60
|
+
*
|
|
61
|
+
* Maps to: `-c model_verbosity=<value>`
|
|
62
|
+
*/
|
|
63
|
+
modelVerbosity?: ModelVerbosity;
|
|
64
|
+
/**
|
|
65
|
+
* Include experimental plan tool that the model can use to update its current plan.
|
|
66
|
+
*
|
|
67
|
+
* Maps to: `--include-plan-tool`
|
|
68
|
+
*/
|
|
69
|
+
includePlanTool?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Configuration profile from config.toml to specify default options.
|
|
72
|
+
*
|
|
73
|
+
* Maps to: `--profile <name>`
|
|
74
|
+
*/
|
|
75
|
+
profile?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Use OSS provider (experimental).
|
|
78
|
+
*
|
|
79
|
+
* Maps to: `--oss`
|
|
80
|
+
*/
|
|
81
|
+
oss?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Enable web search tool for the model.
|
|
84
|
+
*
|
|
85
|
+
* Maps to: `-c tools.web_search=true`
|
|
86
|
+
*/
|
|
87
|
+
webSearch?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Generic Codex CLI config overrides. Allows setting any config value
|
|
90
|
+
* without updating the provider.
|
|
91
|
+
*
|
|
92
|
+
* Each entry maps to: `-c <key>=<value>`
|
|
93
|
+
*
|
|
94
|
+
* Examples:
|
|
95
|
+
* - `{ experimental_resume: '/tmp/session.jsonl' }`
|
|
96
|
+
* - `{ 'model_providers.custom.base_url': 'http://localhost:8000' }`
|
|
97
|
+
* - `{ 'sandbox_workspace_write': { network_access: true } }`
|
|
98
|
+
*
|
|
99
|
+
* Values are serialized:
|
|
100
|
+
* - string → raw string
|
|
101
|
+
* - number/boolean → String(value)
|
|
102
|
+
* - plain objects → flattened recursively to dotted keys
|
|
103
|
+
* - arrays → JSON.stringify(value)
|
|
104
|
+
* - other objects (Date, RegExp, Map, etc.) → JSON.stringify(value)
|
|
105
|
+
*/
|
|
106
|
+
configOverrides?: Record<string, string | number | boolean | object>;
|
|
23
107
|
}
|
|
24
108
|
interface CodexCliProviderSettings {
|
|
25
109
|
defaultSettings?: CodexCliSettings;
|
|
26
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Per-call overrides supplied through AI SDK providerOptions.
|
|
113
|
+
* These values take precedence over constructor-level CodexCliSettings.
|
|
114
|
+
*/
|
|
115
|
+
interface CodexCliProviderOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Per-call override for reasoning depth.
|
|
118
|
+
* Maps to `model_reasoning_effort`.
|
|
119
|
+
*/
|
|
120
|
+
reasoningEffort?: ReasoningEffort;
|
|
121
|
+
/**
|
|
122
|
+
* Per-call override for reasoning summary detail level.
|
|
123
|
+
* Maps to `model_reasoning_summary`.
|
|
124
|
+
*/
|
|
125
|
+
reasoningSummary?: ReasoningSummary;
|
|
126
|
+
/**
|
|
127
|
+
* Per-call override for reasoning summary format.
|
|
128
|
+
* Maps to `model_reasoning_summary_format`.
|
|
129
|
+
*/
|
|
130
|
+
reasoningSummaryFormat?: ReasoningSummaryFormat;
|
|
131
|
+
/**
|
|
132
|
+
* AI SDK naming for per-call verbosity overrides.
|
|
133
|
+
* Maps to Codex `model_verbosity`.
|
|
134
|
+
*/
|
|
135
|
+
textVerbosity?: ModelVerbosity;
|
|
136
|
+
/**
|
|
137
|
+
* Per-call Codex CLI config overrides. These are merged with
|
|
138
|
+
* constructor-level overrides with per-call values taking precedence.
|
|
139
|
+
*/
|
|
140
|
+
configOverrides?: Record<string, string | number | boolean | object>;
|
|
141
|
+
}
|
|
27
142
|
|
|
28
143
|
interface CodexCliProvider extends ProviderV2 {
|
|
29
144
|
(modelId: string, settings?: CodexCliSettings): LanguageModelV2;
|
|
@@ -51,10 +166,25 @@ declare class CodexCliLanguageModel implements LanguageModelV2 {
|
|
|
51
166
|
private logger;
|
|
52
167
|
private sessionId?;
|
|
53
168
|
constructor(options: CodexLanguageModelOptions);
|
|
169
|
+
private mergeSettings;
|
|
170
|
+
private getItemType;
|
|
54
171
|
private buildArgs;
|
|
172
|
+
private addConfigOverride;
|
|
173
|
+
/**
|
|
174
|
+
* Serialize a config override value into a CLI-safe string.
|
|
175
|
+
*/
|
|
176
|
+
private serializeConfigValue;
|
|
177
|
+
private isPlainObject;
|
|
55
178
|
private sanitizeJsonSchema;
|
|
56
179
|
private mapWarnings;
|
|
57
180
|
private parseExperimentalJsonEvent;
|
|
181
|
+
private extractUsage;
|
|
182
|
+
private getToolName;
|
|
183
|
+
private buildToolInputPayload;
|
|
184
|
+
private buildToolResultPayload;
|
|
185
|
+
private safeStringify;
|
|
186
|
+
private emitToolInvocation;
|
|
187
|
+
private emitToolResult;
|
|
58
188
|
private handleSpawnError;
|
|
59
189
|
doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
60
190
|
doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
@@ -62,4 +192,4 @@ declare class CodexCliLanguageModel implements LanguageModelV2 {
|
|
|
62
192
|
|
|
63
193
|
declare function isAuthenticationError(err: unknown): boolean;
|
|
64
194
|
|
|
65
|
-
export { CodexCliLanguageModel, type CodexCliProvider, type CodexCliProviderSettings, type CodexCliSettings, type Logger, codexCli, createCodexCli, isAuthenticationError };
|
|
195
|
+
export { CodexCliLanguageModel, type CodexCliProvider, type CodexCliProviderOptions, type CodexCliProviderSettings, type CodexCliSettings, type Logger, type ModelVerbosity, type ReasoningEffort, type ReasoningSummary, type ReasoningSummaryFormat, codexCli, createCodexCli, isAuthenticationError };
|