@childclm/codexx 0.1.3 → 0.1.4
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/package.json +1 -1
- package/src/index.js +46 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -492,15 +492,44 @@ function hasOfficialSession(sessionId, projectRoot) {
|
|
|
492
492
|
|
|
493
493
|
function buildCodexEnv(provider) {
|
|
494
494
|
return {
|
|
495
|
+
CODEXX_PROVIDER_API_KEY: provider.apiKey,
|
|
495
496
|
OPENAI_API_KEY: provider.apiKey,
|
|
496
497
|
OPENAI_BASE_URL: provider.baseUrl || process.env.OPENAI_BASE_URL,
|
|
497
498
|
};
|
|
498
499
|
}
|
|
499
500
|
|
|
500
|
-
function
|
|
501
|
+
function tomlString(value) {
|
|
502
|
+
return JSON.stringify(String(value));
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function buildCodexProviderArgs(provider) {
|
|
506
|
+
if (!provider || !provider.baseUrl) return [];
|
|
507
|
+
|
|
508
|
+
const providerKey = "codexx";
|
|
509
|
+
const providerDisplayName = provider.modelProvider || "OpenAI";
|
|
510
|
+
return [
|
|
511
|
+
"-c",
|
|
512
|
+
`model_provider=${tomlString(providerKey)}`,
|
|
513
|
+
"-c",
|
|
514
|
+
`model_providers.${providerKey}.name=${tomlString(providerDisplayName)}`,
|
|
515
|
+
"-c",
|
|
516
|
+
`model_providers.${providerKey}.base_url=${tomlString(provider.baseUrl)}`,
|
|
517
|
+
"-c",
|
|
518
|
+
`model_providers.${providerKey}.wire_api=${tomlString("responses")}`,
|
|
519
|
+
"-c",
|
|
520
|
+
`model_providers.${providerKey}.requires_openai_auth=false`,
|
|
521
|
+
"-c",
|
|
522
|
+
`model_providers.${providerKey}.env_key=${tomlString("CODEXX_PROVIDER_API_KEY")}`,
|
|
523
|
+
];
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function runCodex(args, env, cwd = process.cwd(), rl = null, provider = null) {
|
|
501
527
|
return new Promise((resolve, reject) => {
|
|
502
528
|
const cmd = resolveCodexCommand();
|
|
503
|
-
const launch = buildCodexLaunch(
|
|
529
|
+
const launch = buildCodexLaunch(
|
|
530
|
+
cmd,
|
|
531
|
+
[...buildCodexProviderArgs(provider), ...args],
|
|
532
|
+
);
|
|
504
533
|
const settle = (done, value) => {
|
|
505
534
|
resumeTerminalAfterChild(rl);
|
|
506
535
|
done(value);
|
|
@@ -880,7 +909,7 @@ async function launchNewSession(rl, cwd = process.cwd()) {
|
|
|
880
909
|
await pause(rl, "按回车进入 Codex...");
|
|
881
910
|
|
|
882
911
|
const startedAtMs = Date.now();
|
|
883
|
-
await runCodex([], buildCodexEnv(provider), projectState.root, rl);
|
|
912
|
+
await runCodex([], buildCodexEnv(provider), projectState.root, rl, provider);
|
|
884
913
|
|
|
885
914
|
const linkedSessionId = await maybeLinkLatestSession(
|
|
886
915
|
projectState.root,
|
|
@@ -968,7 +997,13 @@ async function resumeSpecificSession(rl, sessionId, cwd = process.cwd()) {
|
|
|
968
997
|
console.log(`provider=${provider.name}`);
|
|
969
998
|
await pause(rl, "按回车进入 Codex...");
|
|
970
999
|
|
|
971
|
-
await runCodex(
|
|
1000
|
+
await runCodex(
|
|
1001
|
+
["resume", sessionId],
|
|
1002
|
+
buildCodexEnv(provider),
|
|
1003
|
+
projectState.root,
|
|
1004
|
+
rl,
|
|
1005
|
+
provider,
|
|
1006
|
+
);
|
|
972
1007
|
}
|
|
973
1008
|
|
|
974
1009
|
async function pickSessionAndResume(rl, cwd = process.cwd()) {
|
|
@@ -1115,7 +1150,13 @@ async function forkFromSession(rl, source, cwd = process.cwd()) {
|
|
|
1115
1150
|
await pause(rl, "按回车进入 Codex...");
|
|
1116
1151
|
|
|
1117
1152
|
const startedAtMs = Date.now();
|
|
1118
|
-
await runCodex(
|
|
1153
|
+
await runCodex(
|
|
1154
|
+
["fork", source.sessionId],
|
|
1155
|
+
buildCodexEnv(provider),
|
|
1156
|
+
projectState.root,
|
|
1157
|
+
rl,
|
|
1158
|
+
provider,
|
|
1159
|
+
);
|
|
1119
1160
|
|
|
1120
1161
|
const linkedSessionId = await maybeLinkLatestSession(
|
|
1121
1162
|
projectState.root,
|