theclawbay 0.3.68 → 0.3.70
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/commands/setup.js
CHANGED
|
@@ -28,7 +28,9 @@ const DEFAULT_PROVIDER_ID = "theclawbay";
|
|
|
28
28
|
const CLI_HTTP_USER_AGENT = "theclawbay-cli";
|
|
29
29
|
const SUPPORTED_MODEL_IDS = (0, supported_models_1.getSupportedModelIds)();
|
|
30
30
|
const MODEL_DISPLAY_NAMES = (0, supported_models_1.getSupportedModelDisplayNames)();
|
|
31
|
-
const DEFAULT_CODEX_MODEL =
|
|
31
|
+
const DEFAULT_CODEX_MODEL = (["gpt-5.5", "gpt-5.4"].find((modelId) => SUPPORTED_MODEL_IDS.includes(modelId)) ??
|
|
32
|
+
SUPPORTED_MODEL_IDS[0] ??
|
|
33
|
+
"gpt-5.4");
|
|
32
34
|
const DEFAULT_CONTINUE_MODEL = DEFAULT_CODEX_MODEL;
|
|
33
35
|
const DEFAULT_CLINE_MODEL = DEFAULT_CODEX_MODEL;
|
|
34
36
|
const DEFAULT_OPENCLAW_MODEL = DEFAULT_CODEX_MODEL;
|
|
@@ -40,6 +40,16 @@ function readWindowsCommandStdout(command) {
|
|
|
40
40
|
const output = result.stdout.replace(/\r/g, "").trim();
|
|
41
41
|
return output || null;
|
|
42
42
|
}
|
|
43
|
+
function desktopClientsLikelyRunning() {
|
|
44
|
+
if (node_os_1.default.platform() === "win32" || isWslInteropRuntime()) {
|
|
45
|
+
const running = readWindowsCommandStdout("Get-Process Code,Codex -ErrorAction SilentlyContinue | Select-Object -ExpandProperty ProcessName");
|
|
46
|
+
return Boolean(running);
|
|
47
|
+
}
|
|
48
|
+
const result = (0, node_child_process_1.spawnSync)("sh", ["-lc", "pgrep -if '(^|/)(code|codex)$' >/dev/null"], {
|
|
49
|
+
stdio: "ignore",
|
|
50
|
+
});
|
|
51
|
+
return result.status === 0;
|
|
52
|
+
}
|
|
43
53
|
function resolveWindowsPathForHost(input) {
|
|
44
54
|
if (!input)
|
|
45
55
|
return null;
|
|
@@ -333,31 +343,18 @@ function buildStatsigPatchScript() {
|
|
|
333
343
|
" finally:",
|
|
334
344
|
" db.close()",
|
|
335
345
|
" print(json.dumps(result))",
|
|
336
|
-
].join("
|
|
346
|
+
].join("\n");
|
|
337
347
|
}
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
if (dbDirs.length === 0)
|
|
341
|
-
return { patched: 0, warnings: [] };
|
|
342
|
-
const python = await ensureLocalPythonWithLevelDbSupport();
|
|
343
|
-
if (!python) {
|
|
344
|
-
return {
|
|
345
|
-
patched: 0,
|
|
346
|
-
warnings: [
|
|
347
|
-
"Could not install the local desktop model-picker helper, so Codex app model labels may stay stale until the next supported cache refresh.",
|
|
348
|
-
],
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
const run = (0, node_child_process_1.spawnSync)(python.command, [...python.args, "-c", buildStatsigPatchScript(), JSON.stringify(DESKTOP_MODEL_IDS), ...dbDirs], {
|
|
348
|
+
function patchStatsigCache(python, dbDir) {
|
|
349
|
+
const run = (0, node_child_process_1.spawnSync)(python.command, [...python.args, "-c", buildStatsigPatchScript(), JSON.stringify(DESKTOP_MODEL_IDS), dbDir], {
|
|
352
350
|
encoding: "utf8",
|
|
353
351
|
stdio: ["ignore", "pipe", "pipe"],
|
|
354
352
|
});
|
|
355
353
|
if (run.status !== 0) {
|
|
354
|
+
const detail = (run.stderr || run.stdout || "").trim();
|
|
356
355
|
return {
|
|
357
356
|
patched: 0,
|
|
358
|
-
|
|
359
|
-
"Could not refresh the desktop model-picker cache. Close Codex app / VS Code and rerun setup if the picker still shows Custom.",
|
|
360
|
-
],
|
|
357
|
+
warning: detail ? `${dbDir}: ${detail}` : `${dbDir}: desktop cache helper exited with status ${run.status}`,
|
|
361
358
|
};
|
|
362
359
|
}
|
|
363
360
|
let patched = 0;
|
|
@@ -368,7 +365,7 @@ async function patchDesktopStatsigCaches() {
|
|
|
368
365
|
const parsed = JSON.parse(line);
|
|
369
366
|
patched += typeof parsed.patched === "number" ? parsed.patched : 0;
|
|
370
367
|
if (typeof parsed.error === "string" && parsed.error.trim()) {
|
|
371
|
-
const dbLabel = typeof parsed.db === "string" ? parsed.db :
|
|
368
|
+
const dbLabel = typeof parsed.db === "string" ? parsed.db : dbDir;
|
|
372
369
|
warnings.push(`${dbLabel}: ${parsed.error.trim()}`);
|
|
373
370
|
}
|
|
374
371
|
}
|
|
@@ -376,7 +373,45 @@ async function patchDesktopStatsigCaches() {
|
|
|
376
373
|
continue;
|
|
377
374
|
}
|
|
378
375
|
}
|
|
379
|
-
return { patched, warnings };
|
|
376
|
+
return { patched, warning: warnings.length > 0 ? warnings.join(" ") : undefined };
|
|
377
|
+
}
|
|
378
|
+
async function patchDesktopStatsigCaches() {
|
|
379
|
+
const dbDirs = await desktopStatsigLevelDbCandidates();
|
|
380
|
+
if (dbDirs.length === 0)
|
|
381
|
+
return { patched: 0, warnings: [] };
|
|
382
|
+
const python = await ensureLocalPythonWithLevelDbSupport();
|
|
383
|
+
if (!python) {
|
|
384
|
+
return {
|
|
385
|
+
patched: 0,
|
|
386
|
+
warnings: [
|
|
387
|
+
"Could not install the local desktop model-picker helper, so Codex app model labels may stay stale until the next supported cache refresh.",
|
|
388
|
+
],
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
let patched = 0;
|
|
392
|
+
const warnings = [];
|
|
393
|
+
for (const dbDir of dbDirs) {
|
|
394
|
+
const result = patchStatsigCache(python, dbDir);
|
|
395
|
+
patched += result.patched;
|
|
396
|
+
if (result.warning)
|
|
397
|
+
warnings.push(result.warning);
|
|
398
|
+
}
|
|
399
|
+
if (patched === 0 && warnings.length > 0) {
|
|
400
|
+
const prefix = desktopClientsLikelyRunning()
|
|
401
|
+
? "Could not refresh the desktop model-picker cache because VS Code or Codex app is still running."
|
|
402
|
+
: "Could not refresh the desktop model-picker cache.";
|
|
403
|
+
return {
|
|
404
|
+
patched,
|
|
405
|
+
warnings: [`${prefix} ${warnings.join(" ")}`],
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
if (patched > 0 && warnings.length > 0) {
|
|
409
|
+
const filteredWarnings = warnings.filter((warning) => !/does not exist|No such file/i.test(warning));
|
|
410
|
+
if (filteredWarnings.length > 0) {
|
|
411
|
+
return { patched, warnings: filteredWarnings };
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return { patched, warnings: [] };
|
|
380
415
|
}
|
|
381
416
|
async function ensureCodexDesktopModelPickerSupport() {
|
|
382
417
|
try {
|
|
@@ -64,7 +64,7 @@ function fingerprintModel(model) {
|
|
|
64
64
|
async function readJsonIfExists(filePath) {
|
|
65
65
|
try {
|
|
66
66
|
const raw = await promises_1.default.readFile(filePath, "utf8");
|
|
67
|
-
return JSON.parse(raw);
|
|
67
|
+
return JSON.parse(raw.replace(/^\uFEFF/, ""));
|
|
68
68
|
}
|
|
69
69
|
catch (error) {
|
|
70
70
|
const err = error;
|
|
@@ -73,6 +73,29 @@ async function readJsonIfExists(filePath) {
|
|
|
73
73
|
throw error;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
async function readModelsCacheIfExists(filePath) {
|
|
77
|
+
try {
|
|
78
|
+
const raw = await promises_1.default.readFile(filePath, "utf8");
|
|
79
|
+
const hadBom = raw.charCodeAt(0) === 0xfeff;
|
|
80
|
+
try {
|
|
81
|
+
return { exists: true, parsed: JSON.parse(raw.replace(/^\uFEFF/, "")), hadBom };
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
exists: true,
|
|
86
|
+
parsed: null,
|
|
87
|
+
hadBom,
|
|
88
|
+
parseError: error instanceof Error ? error.message : String(error),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const err = error;
|
|
94
|
+
if (err.code === "ENOENT")
|
|
95
|
+
return { exists: false, parsed: null, hadBom: false };
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
76
99
|
async function removeFileIfExists(filePath) {
|
|
77
100
|
try {
|
|
78
101
|
await promises_1.default.unlink(filePath);
|
|
@@ -146,9 +169,6 @@ async function writePatchState(statePath, fingerprints) {
|
|
|
146
169
|
}, null, 2);
|
|
147
170
|
await promises_1.default.writeFile(statePath, `${contents}\n`, "utf8");
|
|
148
171
|
}
|
|
149
|
-
function findModel(models, slug) {
|
|
150
|
-
return models.find((entry) => entry.slug === slug) ?? null;
|
|
151
|
-
}
|
|
152
172
|
function hasSeedMarker(model) {
|
|
153
173
|
return LEGACY_SEED_MARKER_VALUES.has(model[SEED_MARKER_KEY]);
|
|
154
174
|
}
|
|
@@ -497,16 +517,19 @@ async function ensureCodexModelCacheHasGpt54(params) {
|
|
|
497
517
|
const statePath = node_path_1.default.join(params.codexHome, MODELS_CACHE_STATE_FILE);
|
|
498
518
|
try {
|
|
499
519
|
const existingState = await readPatchState(statePath);
|
|
500
|
-
const
|
|
520
|
+
const cacheRead = await readModelsCacheIfExists(cachePath);
|
|
521
|
+
const parsed = cacheRead.parsed;
|
|
501
522
|
const catalogModels = buildCatalogModels();
|
|
502
523
|
const catalogModelMap = buildCatalogModelMap();
|
|
503
|
-
if (parsed === null) {
|
|
524
|
+
if (!cacheRead.exists || parsed === null) {
|
|
504
525
|
const clientVersion = await inferCodexClientVersion(params.codexHome);
|
|
505
526
|
if (!clientVersion) {
|
|
506
527
|
await removeFileIfExists(statePath);
|
|
507
528
|
return {
|
|
508
529
|
action: "skipped",
|
|
509
|
-
warning:
|
|
530
|
+
warning: cacheRead.exists
|
|
531
|
+
? "Codex models cache is not valid JSON, and Codex version could not be inferred for a safe The Claw Bay model catalog repair."
|
|
532
|
+
: "Codex models cache was not found, and Codex version could not be inferred for a safe The Claw Bay model catalog refresh.",
|
|
510
533
|
};
|
|
511
534
|
}
|
|
512
535
|
const docModels = cloneJson(catalogModels);
|
|
@@ -522,7 +545,7 @@ async function ensureCodexModelCacheHasGpt54(params) {
|
|
|
522
545
|
await promises_1.default.mkdir(params.codexHome, { recursive: true });
|
|
523
546
|
await promises_1.default.writeFile(cachePath, `${JSON.stringify(doc, null, 2)}\n`, "utf8");
|
|
524
547
|
await writePatchState(statePath, nextState);
|
|
525
|
-
return { action: "created" };
|
|
548
|
+
return { action: cacheRead.exists ? "refreshed" : "created" };
|
|
526
549
|
}
|
|
527
550
|
const doc = normalizeCacheDocument(parsed);
|
|
528
551
|
if (!doc) {
|
|
@@ -533,7 +556,7 @@ async function ensureCodexModelCacheHasGpt54(params) {
|
|
|
533
556
|
}
|
|
534
557
|
const clientVersion = (await inferCodexClientVersion(params.codexHome)) ??
|
|
535
558
|
(typeof doc.client_version === "string" && doc.client_version ? doc.client_version : null);
|
|
536
|
-
let changed =
|
|
559
|
+
let changed = cacheRead.hadBom;
|
|
537
560
|
let seeded = false;
|
|
538
561
|
const currentCatalogEntries = new Map();
|
|
539
562
|
const rest = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "theclawbay",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.70",
|
|
4
4
|
"description": "CLI for connecting Codex, Continue, Cline, GSD, OpenClaw, OpenCode, Kilo, Roo Code, Aider, experimental Trae, and experimental Zo to The Claw Bay.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|