ai-sdk-provider-codex-cli 1.0.3 → 1.0.5
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 +4 -4
- package/dist/index.cjs +14 -7
- package/dist/index.js +14 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,10 +21,10 @@ A community provider for Vercel AI SDK v6 that uses OpenAI's Codex CLI (non‑in
|
|
|
21
21
|
|
|
22
22
|
## Version Compatibility
|
|
23
23
|
|
|
24
|
-
| Provider Version | AI SDK Version | NPM Tag
|
|
25
|
-
| ---------------- | -------------- |
|
|
26
|
-
| 1.x.x | v6 | `latest`
|
|
27
|
-
| 0.x.x | v5 | `ai-sdk-v5`
|
|
24
|
+
| Provider Version | AI SDK Version | NPM Tag | NPM Installation |
|
|
25
|
+
| ---------------- | -------------- | ----------- | ----------------------------------------------------- |
|
|
26
|
+
| 1.x.x | v6 | `latest` | `npm i ai-sdk-provider-codex-cli ai@^6.0.0` |
|
|
27
|
+
| 0.x.x | v5 | `ai-sdk-v5` | `npm i ai-sdk-provider-codex-cli@ai-sdk-v5 ai@^5.0.0` |
|
|
28
28
|
|
|
29
29
|
## Installation
|
|
30
30
|
|
package/dist/index.cjs
CHANGED
|
@@ -539,7 +539,7 @@ var CodexCliLanguageModel = class {
|
|
|
539
539
|
const current = typeof data.type === "string" ? data.type : void 0;
|
|
540
540
|
return legacy ?? current;
|
|
541
541
|
}
|
|
542
|
-
buildArgs(
|
|
542
|
+
buildArgs(images = [], responseFormat, settings = this.settings) {
|
|
543
543
|
const base = resolveCodexPath(settings.codexPath, settings.allowNpx);
|
|
544
544
|
const args = [...base.args, "exec", "--experimental-json"];
|
|
545
545
|
if (settings.fullAuto) {
|
|
@@ -621,7 +621,6 @@ var CodexCliLanguageModel = class {
|
|
|
621
621
|
this.logger.warn(`[codex-cli] Failed to write image to temp file: ${String(e)}`);
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
-
args.push(promptText);
|
|
625
624
|
const env = {
|
|
626
625
|
...process.env,
|
|
627
626
|
...settings.env || {},
|
|
@@ -635,6 +634,10 @@ var CodexCliLanguageModel = class {
|
|
|
635
634
|
lastMessageIsTemp = true;
|
|
636
635
|
}
|
|
637
636
|
args.push("--output-last-message", lastMessagePath);
|
|
637
|
+
if (tempImagePaths.length > 0) {
|
|
638
|
+
args.push("--");
|
|
639
|
+
}
|
|
640
|
+
args.push("-");
|
|
638
641
|
return {
|
|
639
642
|
cmd: base.cmd,
|
|
640
643
|
args,
|
|
@@ -996,15 +999,17 @@ var CodexCliLanguageModel = class {
|
|
|
996
999
|
});
|
|
997
1000
|
const effectiveSettings = this.mergeSettings(providerOptions);
|
|
998
1001
|
const responseFormat = options.responseFormat?.type === "json" ? { type: "json", schema: options.responseFormat.schema } : void 0;
|
|
999
|
-
const { cmd, args, env, cwd, lastMessagePath, lastMessageIsTemp, schemaPath, tempImagePaths } = this.buildArgs(
|
|
1002
|
+
const { cmd, args, env, cwd, lastMessagePath, lastMessageIsTemp, schemaPath, tempImagePaths } = this.buildArgs(images, responseFormat, effectiveSettings);
|
|
1000
1003
|
this.logger.debug(
|
|
1001
1004
|
`[codex-cli] Executing Codex CLI: ${cmd} with ${args.length} arguments, cwd: ${cwd ?? "default"}`
|
|
1002
1005
|
);
|
|
1003
1006
|
let text = "";
|
|
1004
1007
|
let usage = createEmptyCodexUsage();
|
|
1005
|
-
|
|
1008
|
+
const finishReason = mapCodexCliFinishReason(void 0);
|
|
1006
1009
|
const startTime = Date.now();
|
|
1007
|
-
const child = child_process.spawn(cmd, args, { env, cwd, stdio: ["
|
|
1010
|
+
const child = child_process.spawn(cmd, args, { env, cwd, stdio: ["pipe", "pipe", "pipe"] });
|
|
1011
|
+
child.stdin.write(promptText);
|
|
1012
|
+
child.stdin.end();
|
|
1008
1013
|
let onAbort;
|
|
1009
1014
|
if (options.abortSignal) {
|
|
1010
1015
|
if (options.abortSignal.aborted) {
|
|
@@ -1162,14 +1167,16 @@ var CodexCliLanguageModel = class {
|
|
|
1162
1167
|
});
|
|
1163
1168
|
const effectiveSettings = this.mergeSettings(providerOptions);
|
|
1164
1169
|
const responseFormat = options.responseFormat?.type === "json" ? { type: "json", schema: options.responseFormat.schema } : void 0;
|
|
1165
|
-
const { cmd, args, env, cwd, lastMessagePath, lastMessageIsTemp, schemaPath, tempImagePaths } = this.buildArgs(
|
|
1170
|
+
const { cmd, args, env, cwd, lastMessagePath, lastMessageIsTemp, schemaPath, tempImagePaths } = this.buildArgs(images, responseFormat, effectiveSettings);
|
|
1166
1171
|
this.logger.debug(
|
|
1167
1172
|
`[codex-cli] Executing Codex CLI for streaming: ${cmd} with ${args.length} arguments`
|
|
1168
1173
|
);
|
|
1169
1174
|
const stream = new ReadableStream({
|
|
1170
1175
|
start: (controller) => {
|
|
1171
1176
|
const startTime = Date.now();
|
|
1172
|
-
const child = child_process.spawn(cmd, args, { env, cwd, stdio: ["
|
|
1177
|
+
const child = child_process.spawn(cmd, args, { env, cwd, stdio: ["pipe", "pipe", "pipe"] });
|
|
1178
|
+
child.stdin.write(promptText);
|
|
1179
|
+
child.stdin.end();
|
|
1173
1180
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1174
1181
|
let stderr = "";
|
|
1175
1182
|
let accumulatedText = "";
|
package/dist/index.js
CHANGED
|
@@ -536,7 +536,7 @@ var CodexCliLanguageModel = class {
|
|
|
536
536
|
const current = typeof data.type === "string" ? data.type : void 0;
|
|
537
537
|
return legacy ?? current;
|
|
538
538
|
}
|
|
539
|
-
buildArgs(
|
|
539
|
+
buildArgs(images = [], responseFormat, settings = this.settings) {
|
|
540
540
|
const base = resolveCodexPath(settings.codexPath, settings.allowNpx);
|
|
541
541
|
const args = [...base.args, "exec", "--experimental-json"];
|
|
542
542
|
if (settings.fullAuto) {
|
|
@@ -618,7 +618,6 @@ var CodexCliLanguageModel = class {
|
|
|
618
618
|
this.logger.warn(`[codex-cli] Failed to write image to temp file: ${String(e)}`);
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
-
args.push(promptText);
|
|
622
621
|
const env = {
|
|
623
622
|
...process.env,
|
|
624
623
|
...settings.env || {},
|
|
@@ -632,6 +631,10 @@ var CodexCliLanguageModel = class {
|
|
|
632
631
|
lastMessageIsTemp = true;
|
|
633
632
|
}
|
|
634
633
|
args.push("--output-last-message", lastMessagePath);
|
|
634
|
+
if (tempImagePaths.length > 0) {
|
|
635
|
+
args.push("--");
|
|
636
|
+
}
|
|
637
|
+
args.push("-");
|
|
635
638
|
return {
|
|
636
639
|
cmd: base.cmd,
|
|
637
640
|
args,
|
|
@@ -993,15 +996,17 @@ var CodexCliLanguageModel = class {
|
|
|
993
996
|
});
|
|
994
997
|
const effectiveSettings = this.mergeSettings(providerOptions);
|
|
995
998
|
const responseFormat = options.responseFormat?.type === "json" ? { type: "json", schema: options.responseFormat.schema } : void 0;
|
|
996
|
-
const { cmd, args, env, cwd, lastMessagePath, lastMessageIsTemp, schemaPath, tempImagePaths } = this.buildArgs(
|
|
999
|
+
const { cmd, args, env, cwd, lastMessagePath, lastMessageIsTemp, schemaPath, tempImagePaths } = this.buildArgs(images, responseFormat, effectiveSettings);
|
|
997
1000
|
this.logger.debug(
|
|
998
1001
|
`[codex-cli] Executing Codex CLI: ${cmd} with ${args.length} arguments, cwd: ${cwd ?? "default"}`
|
|
999
1002
|
);
|
|
1000
1003
|
let text = "";
|
|
1001
1004
|
let usage = createEmptyCodexUsage();
|
|
1002
|
-
|
|
1005
|
+
const finishReason = mapCodexCliFinishReason(void 0);
|
|
1003
1006
|
const startTime = Date.now();
|
|
1004
|
-
const child = spawn(cmd, args, { env, cwd, stdio: ["
|
|
1007
|
+
const child = spawn(cmd, args, { env, cwd, stdio: ["pipe", "pipe", "pipe"] });
|
|
1008
|
+
child.stdin.write(promptText);
|
|
1009
|
+
child.stdin.end();
|
|
1005
1010
|
let onAbort;
|
|
1006
1011
|
if (options.abortSignal) {
|
|
1007
1012
|
if (options.abortSignal.aborted) {
|
|
@@ -1159,14 +1164,16 @@ var CodexCliLanguageModel = class {
|
|
|
1159
1164
|
});
|
|
1160
1165
|
const effectiveSettings = this.mergeSettings(providerOptions);
|
|
1161
1166
|
const responseFormat = options.responseFormat?.type === "json" ? { type: "json", schema: options.responseFormat.schema } : void 0;
|
|
1162
|
-
const { cmd, args, env, cwd, lastMessagePath, lastMessageIsTemp, schemaPath, tempImagePaths } = this.buildArgs(
|
|
1167
|
+
const { cmd, args, env, cwd, lastMessagePath, lastMessageIsTemp, schemaPath, tempImagePaths } = this.buildArgs(images, responseFormat, effectiveSettings);
|
|
1163
1168
|
this.logger.debug(
|
|
1164
1169
|
`[codex-cli] Executing Codex CLI for streaming: ${cmd} with ${args.length} arguments`
|
|
1165
1170
|
);
|
|
1166
1171
|
const stream = new ReadableStream({
|
|
1167
1172
|
start: (controller) => {
|
|
1168
1173
|
const startTime = Date.now();
|
|
1169
|
-
const child = spawn(cmd, args, { env, cwd, stdio: ["
|
|
1174
|
+
const child = spawn(cmd, args, { env, cwd, stdio: ["pipe", "pipe", "pipe"] });
|
|
1175
|
+
child.stdin.write(promptText);
|
|
1176
|
+
child.stdin.end();
|
|
1170
1177
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1171
1178
|
let stderr = "";
|
|
1172
1179
|
let accumulatedText = "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-sdk-provider-codex-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "AI SDK v6 provider for OpenAI Codex CLI (use ChatGPT Plus/Pro subscription)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-sdk",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"jsonc-parser": "^3.3.1"
|
|
65
65
|
},
|
|
66
66
|
"optionalDependencies": {
|
|
67
|
-
"@openai/codex": "^0.
|
|
67
|
+
"@openai/codex": "^0.87.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@eslint/js": "^9.14.0",
|