@ycodium-ai/agent-codex 0.2.2936 → 0.2.2942
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.js +51 -68
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -440,6 +440,9 @@ import {
|
|
|
440
440
|
ExecutorSpawnRefusedError
|
|
441
441
|
} from "@ycodium-ai/plugin-api/executor";
|
|
442
442
|
|
|
443
|
+
// src/connection.ts
|
|
444
|
+
import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
|
|
445
|
+
|
|
443
446
|
// src/config.ts
|
|
444
447
|
import { modelSelectionStringOption } from "@ycodium-ai/plugin-api/executor";
|
|
445
448
|
|
|
@@ -613,7 +616,6 @@ function modelIdFromSelection(selection) {
|
|
|
613
616
|
}
|
|
614
617
|
|
|
615
618
|
// src/connection.ts
|
|
616
|
-
import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
|
|
617
619
|
function codexApiConnectionError(recipe, environment) {
|
|
618
620
|
if (recipe.authMode !== "apiKey") return null;
|
|
619
621
|
try {
|
|
@@ -681,6 +683,29 @@ function shouldCrushApiKeys(authMode) {
|
|
|
681
683
|
return authMode === "chatgpt";
|
|
682
684
|
}
|
|
683
685
|
|
|
686
|
+
// src/appServerLaunch.ts
|
|
687
|
+
async function spawnCodexAppServer(input) {
|
|
688
|
+
await materializeCodexShadowHome(input.layout, input.host.log);
|
|
689
|
+
const env = input.env ?? buildCodexSpawnEnv({
|
|
690
|
+
recipe: input.recipe,
|
|
691
|
+
layout: input.layout,
|
|
692
|
+
...input.launchEnv === void 0 ? {} : { launchEnv: input.launchEnv },
|
|
693
|
+
crushApiKeys: shouldCrushApiKeys(input.recipe.authMode)
|
|
694
|
+
});
|
|
695
|
+
const args = input.args ?? [
|
|
696
|
+
...codexSpawnArgs(input.recipe, input.layout),
|
|
697
|
+
...input.extraArgs ?? []
|
|
698
|
+
];
|
|
699
|
+
const handle = await input.host.process.spawn({
|
|
700
|
+
program: input.recipe.binaryPath,
|
|
701
|
+
args,
|
|
702
|
+
owner: { bindingId: input.host.bindingId },
|
|
703
|
+
...input.cwd === void 0 ? {} : { cwd: input.cwd },
|
|
704
|
+
...input.env !== void 0 || Object.keys(env).length > 0 ? { env } : {}
|
|
705
|
+
});
|
|
706
|
+
return { handle, args };
|
|
707
|
+
}
|
|
708
|
+
|
|
684
709
|
// src/protocol.ts
|
|
685
710
|
var CODEX_INITIALIZE_PARAMS = {
|
|
686
711
|
clientInfo: { name: "ycodium", title: "Ycodium", version: "0" },
|
|
@@ -4076,11 +4101,12 @@ async function startCodexMcpOAuth(input) {
|
|
|
4076
4101
|
launchEnv: { ...input.processEnv, ...mcp.environment },
|
|
4077
4102
|
crushApiKeys: shouldCrushApiKeys(input.recipe.authMode)
|
|
4078
4103
|
});
|
|
4079
|
-
const handle = await
|
|
4080
|
-
|
|
4081
|
-
|
|
4104
|
+
const { handle } = await spawnCodexAppServer({
|
|
4105
|
+
host: input.host,
|
|
4106
|
+
recipe: input.recipe,
|
|
4107
|
+
layout: input.layout,
|
|
4082
4108
|
cwd: input.cwd,
|
|
4083
|
-
|
|
4109
|
+
args: [...tokenizeLaunchArgs(input.recipe.launchArgs), ...mcp.args],
|
|
4084
4110
|
env
|
|
4085
4111
|
});
|
|
4086
4112
|
let settle;
|
|
@@ -4370,10 +4396,11 @@ async function startCodexSignIn(input) {
|
|
|
4370
4396
|
const env = nativeLoginSpawnEnv(input.processEnv, isolatedHome);
|
|
4371
4397
|
const owner = { bindingId: input.host.bindingId };
|
|
4372
4398
|
const tryAppServer = async () => {
|
|
4373
|
-
const handle2 = await
|
|
4374
|
-
|
|
4399
|
+
const { handle: handle2 } = await spawnCodexAppServer({
|
|
4400
|
+
host: input.host,
|
|
4401
|
+
recipe: input.recipe,
|
|
4402
|
+
layout: input.layout,
|
|
4375
4403
|
args: tokenizeLaunchArgs(input.recipe.launchArgs),
|
|
4376
|
-
owner,
|
|
4377
4404
|
env
|
|
4378
4405
|
});
|
|
4379
4406
|
let completed;
|
|
@@ -4471,10 +4498,11 @@ async function verifyCodexSignIn(input) {
|
|
|
4471
4498
|
};
|
|
4472
4499
|
}
|
|
4473
4500
|
const env = nativeLoginSpawnEnv(input.processEnv, home);
|
|
4474
|
-
const handle = await
|
|
4475
|
-
|
|
4501
|
+
const { handle } = await spawnCodexAppServer({
|
|
4502
|
+
host: input.host,
|
|
4503
|
+
recipe: input.recipe,
|
|
4504
|
+
layout: input.layout,
|
|
4476
4505
|
args: tokenizeLaunchArgs(input.recipe.launchArgs),
|
|
4477
|
-
owner: { bindingId: input.host.bindingId },
|
|
4478
4506
|
env
|
|
4479
4507
|
});
|
|
4480
4508
|
const rpc = await createCodexRpcClient(handle, {
|
|
@@ -5638,22 +5666,12 @@ var createCodexInstance = (config, host, attachments, cache) => {
|
|
|
5638
5666
|
const probeAuth = () => accountToAuth2(readCodexAccount(accountHomeFromLayout(layoutFor(recipe))));
|
|
5639
5667
|
const probeAppServer = async (input) => {
|
|
5640
5668
|
const layout = layoutFor(recipe);
|
|
5641
|
-
const env = buildCodexSpawnEnv({
|
|
5642
|
-
recipe,
|
|
5643
|
-
layout,
|
|
5644
|
-
crushApiKeys: shouldCrushApiKeys(recipe.authMode)
|
|
5645
|
-
});
|
|
5646
5669
|
let handle;
|
|
5647
5670
|
let rpc;
|
|
5648
5671
|
let version = null;
|
|
5649
5672
|
try {
|
|
5650
5673
|
try {
|
|
5651
|
-
handle = await
|
|
5652
|
-
program: recipe.binaryPath,
|
|
5653
|
-
args: [...codexSpawnArgs(recipe, layout)],
|
|
5654
|
-
owner: { bindingId: host.bindingId },
|
|
5655
|
-
...Object.keys(env).length > 0 ? { env } : {}
|
|
5656
|
-
});
|
|
5674
|
+
({ handle } = await spawnCodexAppServer({ host, recipe, layout }));
|
|
5657
5675
|
} catch (error) {
|
|
5658
5676
|
if (error instanceof ExecutorSpawnRefusedError) throw error;
|
|
5659
5677
|
host.log.warn("codex binary could not be started", {
|
|
@@ -5691,19 +5709,9 @@ var createCodexInstance = (config, host, attachments, cache) => {
|
|
|
5691
5709
|
if (disposed) throw new Error("instance disposed");
|
|
5692
5710
|
if (signal?.aborted === true) throw new Error("aborted");
|
|
5693
5711
|
const layout = layoutFor(recipe);
|
|
5694
|
-
const env = buildCodexSpawnEnv({
|
|
5695
|
-
recipe,
|
|
5696
|
-
layout,
|
|
5697
|
-
crushApiKeys: shouldCrushApiKeys(recipe.authMode)
|
|
5698
|
-
});
|
|
5699
5712
|
let handle;
|
|
5700
5713
|
try {
|
|
5701
|
-
handle = await
|
|
5702
|
-
program: recipe.binaryPath,
|
|
5703
|
-
args: [...codexSpawnArgs(recipe, layout)],
|
|
5704
|
-
owner: { bindingId: host.bindingId },
|
|
5705
|
-
...Object.keys(env).length > 0 ? { env } : {}
|
|
5706
|
-
});
|
|
5714
|
+
({ handle } = await spawnCodexAppServer({ host, recipe, layout }));
|
|
5707
5715
|
} catch (error) {
|
|
5708
5716
|
if (error instanceof ExecutorSpawnRefusedError) {
|
|
5709
5717
|
const borrowed = [...threads.values()][0];
|
|
@@ -5811,22 +5819,15 @@ var createCodexInstance = (config, host, attachments, cache) => {
|
|
|
5811
5819
|
threads.delete(input.threadId);
|
|
5812
5820
|
}
|
|
5813
5821
|
const layout = layoutFor(recipe);
|
|
5814
|
-
await materializeCodexShadowHome(layout, host.log);
|
|
5815
5822
|
const mcp = codexMcpLaunchConfig(input.mcpServers ?? []);
|
|
5816
|
-
const
|
|
5823
|
+
const { handle, args } = await spawnCodexAppServer({
|
|
5824
|
+
host,
|
|
5817
5825
|
recipe,
|
|
5818
5826
|
layout,
|
|
5819
|
-
// MCP 那几个变量是宿主挑好的 server 带来的,铺在最终层:实例表盖不得。
|
|
5820
|
-
launchEnv: mcp.environment,
|
|
5821
|
-
crushApiKeys: shouldCrushApiKeys(recipe.authMode)
|
|
5822
|
-
});
|
|
5823
|
-
const args = [...codexSpawnArgs(recipe, layout), ...mcp.args];
|
|
5824
|
-
const handle = await host.process.spawn({
|
|
5825
|
-
program: recipe.binaryPath,
|
|
5826
|
-
args,
|
|
5827
5827
|
cwd,
|
|
5828
|
-
|
|
5829
|
-
|
|
5828
|
+
extraArgs: mcp.args,
|
|
5829
|
+
// MCP 那几个变量是宿主挑好的 server 带来的,铺在最终层:实例表盖不得。
|
|
5830
|
+
launchEnv: mcp.environment
|
|
5830
5831
|
});
|
|
5831
5832
|
trackHandle(handle, [recipe.binaryPath, ...args].join(" "), input.threadId);
|
|
5832
5833
|
let runtime;
|
|
@@ -5973,19 +5974,8 @@ var createCodexInstance = (config, host, attachments, cache) => {
|
|
|
5973
5974
|
throw new Error("Codex program path is not configured");
|
|
5974
5975
|
}
|
|
5975
5976
|
const layout = layoutFor(recipe);
|
|
5976
|
-
const
|
|
5977
|
-
|
|
5978
|
-
layout,
|
|
5979
|
-
crushApiKeys: shouldCrushApiKeys(recipe.authMode)
|
|
5980
|
-
});
|
|
5981
|
-
const args = [...codexSpawnArgs(recipe, layout)];
|
|
5982
|
-
const handle = await host.process.spawn({
|
|
5983
|
-
program: recipe.binaryPath,
|
|
5984
|
-
args,
|
|
5985
|
-
cwd: input.directory ?? host.workspacePath(input.projectId),
|
|
5986
|
-
owner: { bindingId: host.bindingId },
|
|
5987
|
-
...Object.keys(env).length > 0 ? { env } : {}
|
|
5988
|
-
});
|
|
5977
|
+
const cwd = input.directory ?? host.workspacePath(input.projectId);
|
|
5978
|
+
const { handle, args } = await spawnCodexAppServer({ host, recipe, layout, cwd });
|
|
5989
5979
|
trackHandle(handle, [recipe.binaryPath, ...args].join(" "));
|
|
5990
5980
|
const rpc = await createCodexRpcClient(handle, {
|
|
5991
5981
|
onNotification: () => void 0,
|
|
@@ -6010,18 +6000,11 @@ var createCodexInstance = (config, host, attachments, cache) => {
|
|
|
6010
6000
|
throw new Error("Codex program path is not configured");
|
|
6011
6001
|
}
|
|
6012
6002
|
const layout = layoutFor(recipe);
|
|
6013
|
-
const
|
|
6003
|
+
const { handle, args } = await spawnCodexAppServer({
|
|
6004
|
+
host,
|
|
6014
6005
|
recipe,
|
|
6015
6006
|
layout,
|
|
6016
|
-
|
|
6017
|
-
});
|
|
6018
|
-
const args = [...codexSpawnArgs(recipe, layout)];
|
|
6019
|
-
const handle = await host.process.spawn({
|
|
6020
|
-
program: recipe.binaryPath,
|
|
6021
|
-
args,
|
|
6022
|
-
cwd: input.cwd,
|
|
6023
|
-
owner: { bindingId: host.bindingId },
|
|
6024
|
-
...Object.keys(env).length > 0 ? { env } : {}
|
|
6007
|
+
cwd: input.cwd
|
|
6025
6008
|
});
|
|
6026
6009
|
trackHandle(handle, [recipe.binaryPath, ...args].join(" "));
|
|
6027
6010
|
const rpc = await createCodexRpcClient(handle, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-codex",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2942",
|
|
4
4
|
"description": "Codex executor: Codex CLI over the app-server JSON-RPC protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"tailwindcss": "^4.0.0",
|
|
30
30
|
"typescript": "~6.0.3",
|
|
31
31
|
"vite-plus": "0.2.2",
|
|
32
|
-
"
|
|
33
|
-
"ycodium-
|
|
32
|
+
"ycodium-executor-testing": "0.0.0",
|
|
33
|
+
"@ycodium-ai/plugin-api": "0.2.2942"
|
|
34
34
|
},
|
|
35
35
|
"ycodium": {
|
|
36
36
|
"plugin": "./dist/index.js",
|