@chrysb/alphaclaw 0.9.19 → 0.9.20

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/bin/alphaclaw.js CHANGED
@@ -4,7 +4,7 @@
4
4
  const fs = require("fs");
5
5
  const os = require("os");
6
6
  const path = require("path");
7
- const { execSync } = require("child_process");
7
+ const { execFileSync, execSync } = require("child_process");
8
8
  const {
9
9
  shouldSkipSystemCronInstall,
10
10
  resolveGitAskPassPath,
@@ -733,6 +733,20 @@ if (fs.existsSync(path.join(openclawDir, ".git"))) {
733
733
  }
734
734
  }
735
735
 
736
+ if (fs.existsSync(configPath)) {
737
+ try {
738
+ execFileSync(process.execPath, [
739
+ path.join(__dirname, "..", "lib", "scripts", "migrate-openclaw-codex.js"),
740
+ ], {
741
+ env: process.env,
742
+ stdio: "inherit",
743
+ timeout: 60_000,
744
+ });
745
+ } catch (error) {
746
+ console.error(`[alphaclaw] Codex migration process failed: ${error.message}`);
747
+ }
748
+ }
749
+
736
750
  if (fs.existsSync(configPath)) {
737
751
  console.log("[alphaclaw] Config exists, reconciling channels...");
738
752
 
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { migrateLegacyCodexState } = require("../server/openclaw-codex-migration");
4
+
5
+ migrateLegacyCodexState()
6
+ .then((result) => {
7
+ if (result.changed) {
8
+ console.log("[alphaclaw] Migrated legacy OpenAI Codex model and auth state");
9
+ }
10
+ for (const warning of result.warnings) {
11
+ console.warn(`[alphaclaw] Codex migration warning: ${warning}`);
12
+ }
13
+ })
14
+ .catch((error) => {
15
+ console.error(`[alphaclaw] Codex migration failed: ${error.message}`);
16
+ process.exitCode = 1;
17
+ });
@@ -281,7 +281,12 @@ const createAuthProfiles = () => {
281
281
 
282
282
  // ── Legacy Codex-specific wrappers ──
283
283
 
284
- const listCodexProfiles = () => listProfilesByProvider("openai-codex");
284
+ const listCodexProfiles = () =>
285
+ listProfiles().filter(
286
+ (profile) =>
287
+ profile.type === "oauth" &&
288
+ (profile.provider === "openai" || profile.provider === "openai-codex"),
289
+ );
285
290
 
286
291
  const getCodexProfile = () => {
287
292
  const profiles = listCodexProfiles();
@@ -299,7 +304,7 @@ const createAuthProfiles = () => {
299
304
  const upsertCodexProfile = ({ access, refresh, expires, accountId }) => {
300
305
  upsertProfile(CODEX_PROFILE_ID, {
301
306
  type: "oauth",
302
- provider: "openai-codex",
307
+ provider: "openai",
303
308
  access,
304
309
  refresh,
305
310
  expires,
@@ -311,7 +316,10 @@ const createAuthProfiles = () => {
311
316
  const store = loadAuthStore();
312
317
  let changed = false;
313
318
  for (const [id, cred] of Object.entries(store.profiles || {})) {
314
- if (cred?.provider === "openai-codex") {
319
+ if (
320
+ cred?.type === "oauth" &&
321
+ (cred.provider === "openai" || cred.provider === "openai-codex")
322
+ ) {
315
323
  delete store.profiles[id];
316
324
  changed = true;
317
325
  }
@@ -321,7 +329,10 @@ const createAuthProfiles = () => {
321
329
  if (!canSyncOpenclawAuthReferences()) return changed;
322
330
  let cfg = loadOpenclawConfig();
323
331
  for (const [id, cred] of Object.entries(cfg.auth?.profiles || {})) {
324
- if (cred?.provider === "openai-codex") {
332
+ if (
333
+ cred?.mode === "oauth" &&
334
+ (cred.provider === "openai" || cred.provider === "openai-codex")
335
+ ) {
325
336
  cfg = removeConfigAuthReference(cfg, id);
326
337
  }
327
338
  }
@@ -28,7 +28,7 @@ const AUTH_PROFILES_PATH = path.join(
28
28
  "agent",
29
29
  "auth-profiles.json",
30
30
  );
31
- const CODEX_PROFILE_ID = "openai-codex:codex-cli";
31
+ const CODEX_PROFILE_ID = "openai:codex-cli";
32
32
  const CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
33
33
  const CODEX_OAUTH_AUTHORIZE_URL = "https://auth.openai.com/oauth/authorize";
34
34
  const CODEX_OAUTH_TOKEN_URL = "https://auth.openai.com/oauth/token";
@@ -0,0 +1,78 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { pathToFileURL } = require("url");
4
+
5
+ const findOpenclawDistModule = (prefix) => {
6
+ const entryPath = require.resolve("openclaw");
7
+ const distDir = path.dirname(entryPath);
8
+ const filename = fs
9
+ .readdirSync(distDir)
10
+ .find((name) => name.startsWith(`${prefix}-`) && name.endsWith(".js"));
11
+ if (!filename) throw new Error(`OpenClaw migration module not found: ${prefix}`);
12
+ return path.join(distDir, filename);
13
+ };
14
+
15
+ const writeConfig = (configPath, cfg) => {
16
+ fs.writeFileSync(configPath, `${JSON.stringify(cfg, null, 2)}\n`, "utf8");
17
+ };
18
+
19
+ const migrateLegacyCodexState = async ({
20
+ configPath = process.env.OPENCLAW_CONFIG_PATH,
21
+ env = process.env,
22
+ } = {}) => {
23
+ if (!configPath || !fs.existsSync(configPath)) {
24
+ return { changed: false, changes: [], warnings: [] };
25
+ }
26
+
27
+ const cfg = JSON.parse(fs.readFileSync(configPath, "utf8"));
28
+ const routeModule = await import(
29
+ pathToFileURL(findOpenclawDistModule("codex-route-warnings")).href
30
+ );
31
+ const authModule = await import(
32
+ pathToFileURL(findOpenclawDistModule("doctor-auth-flat-profiles")).href
33
+ );
34
+
35
+ const changes = [];
36
+ const warnings = [];
37
+ const routeRepair = routeModule.r({ cfg, env, shouldRepair: true });
38
+ let nextCfg = routeRepair.cfg;
39
+ changes.push(...routeRepair.changes);
40
+ warnings.push(...routeRepair.warnings);
41
+
42
+ const profileIdMap = authModule.t({ cfg: nextCfg, env });
43
+ const configAuthRepair = authModule.a(nextCfg, { profileIdMap });
44
+ nextCfg = configAuthRepair.config;
45
+ changes.push(...configAuthRepair.changes);
46
+ warnings.push(...configAuthRepair.warnings);
47
+
48
+ if (changes.length > 0) writeConfig(configPath, nextCfg);
49
+
50
+ const storeRepair = await authModule.o({ cfg: nextCfg, env });
51
+ changes.push(...storeRepair.changes);
52
+ warnings.push(...storeRepair.warnings);
53
+
54
+ const sqliteMigration = await authModule.n({
55
+ cfg: nextCfg,
56
+ env,
57
+ prompter: { confirmAutoFix: async () => true },
58
+ });
59
+ changes.push(...sqliteMigration.changes);
60
+ warnings.push(...sqliteMigration.warnings);
61
+ if (sqliteMigration.configChanged) writeConfig(configPath, nextCfg);
62
+
63
+ const sessionRepair = await routeModule.i({
64
+ cfg: nextCfg,
65
+ env,
66
+ shouldRepair: true,
67
+ });
68
+ changes.push(...sessionRepair.changes);
69
+ warnings.push(...sessionRepair.warnings);
70
+
71
+ return {
72
+ changed: changes.length > 0,
73
+ changes,
74
+ warnings,
75
+ };
76
+ };
77
+
78
+ module.exports = { migrateLegacyCodexState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrysb/alphaclaw",
3
- "version": "0.9.19",
3
+ "version": "0.9.20",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },