theclawbay 0.3.69 → 0.3.71
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.
|
@@ -26,6 +26,7 @@ const SEED_MARKER_KEY = "_theclawbay_seeded";
|
|
|
26
26
|
const SEED_MARKER_VALUE = "theclawbay";
|
|
27
27
|
const LEGACY_SEED_MARKER_VALUES = new Set([...TRACKED_MODEL_ID_SET, SEED_MARKER_VALUE, true]);
|
|
28
28
|
const SEEDED_CACHE_FRESHNESS_ISO = "2099-12-31T23:59:59.000Z";
|
|
29
|
+
const MINIMUM_CATALOG_CLIENT_VERSION = "0.124.0";
|
|
29
30
|
function objectRecordOr(value) {
|
|
30
31
|
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
31
32
|
return value;
|
|
@@ -64,7 +65,7 @@ function fingerprintModel(model) {
|
|
|
64
65
|
async function readJsonIfExists(filePath) {
|
|
65
66
|
try {
|
|
66
67
|
const raw = await promises_1.default.readFile(filePath, "utf8");
|
|
67
|
-
return JSON.parse(raw);
|
|
68
|
+
return JSON.parse(raw.replace(/^\uFEFF/, ""));
|
|
68
69
|
}
|
|
69
70
|
catch (error) {
|
|
70
71
|
const err = error;
|
|
@@ -73,6 +74,29 @@ async function readJsonIfExists(filePath) {
|
|
|
73
74
|
throw error;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
77
|
+
async function readModelsCacheIfExists(filePath) {
|
|
78
|
+
try {
|
|
79
|
+
const raw = await promises_1.default.readFile(filePath, "utf8");
|
|
80
|
+
const hadBom = raw.charCodeAt(0) === 0xfeff;
|
|
81
|
+
try {
|
|
82
|
+
return { exists: true, parsed: JSON.parse(raw.replace(/^\uFEFF/, "")), hadBom };
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
exists: true,
|
|
87
|
+
parsed: null,
|
|
88
|
+
hadBom,
|
|
89
|
+
parseError: error instanceof Error ? error.message : String(error),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
const err = error;
|
|
95
|
+
if (err.code === "ENOENT")
|
|
96
|
+
return { exists: false, parsed: null, hadBom: false };
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
76
100
|
async function removeFileIfExists(filePath) {
|
|
77
101
|
try {
|
|
78
102
|
await promises_1.default.unlink(filePath);
|
|
@@ -146,9 +170,6 @@ async function writePatchState(statePath, fingerprints) {
|
|
|
146
170
|
}, null, 2);
|
|
147
171
|
await promises_1.default.writeFile(statePath, `${contents}\n`, "utf8");
|
|
148
172
|
}
|
|
149
|
-
function findModel(models, slug) {
|
|
150
|
-
return models.find((entry) => entry.slug === slug) ?? null;
|
|
151
|
-
}
|
|
152
173
|
function hasSeedMarker(model) {
|
|
153
174
|
return LEGACY_SEED_MARKER_VALUES.has(model[SEED_MARKER_KEY]);
|
|
154
175
|
}
|
|
@@ -361,6 +382,51 @@ async function inferCodexClientVersionsFromInstalledExtensions() {
|
|
|
361
382
|
}
|
|
362
383
|
return [...versions];
|
|
363
384
|
}
|
|
385
|
+
function desktopAppCodexBinaryCandidates() {
|
|
386
|
+
const candidates = [];
|
|
387
|
+
const home = node_os_1.default.homedir();
|
|
388
|
+
if (node_os_1.default.platform() === "darwin") {
|
|
389
|
+
for (const appRoot of [
|
|
390
|
+
"/Applications/Codex.app",
|
|
391
|
+
"/Applications/OpenAI Codex.app",
|
|
392
|
+
node_path_1.default.join(home, "Applications", "Codex.app"),
|
|
393
|
+
node_path_1.default.join(home, "Applications", "OpenAI Codex.app"),
|
|
394
|
+
]) {
|
|
395
|
+
candidates.push(node_path_1.default.join(appRoot, "Contents", "Resources", "codex"), node_path_1.default.join(appRoot, "Contents", "Resources", "app", "resources", "codex"));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (node_os_1.default.platform() === "win32" || isWslInteropRuntime()) {
|
|
399
|
+
const installLocations = readWindowsCommandStdout("Get-AppxPackage OpenAI.Codex | ForEach-Object { $_.InstallLocation }");
|
|
400
|
+
if (installLocations) {
|
|
401
|
+
for (const installLocation of installLocations.split("\n")) {
|
|
402
|
+
const hostPath = resolveWindowsPathForHost(installLocation);
|
|
403
|
+
if (!hostPath)
|
|
404
|
+
continue;
|
|
405
|
+
candidates.push(node_path_1.default.join(hostPath, "app", "resources", "codex.exe"));
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return uniqueStrings(candidates);
|
|
410
|
+
}
|
|
411
|
+
async function inferCodexClientVersionsFromInstalledDesktopApps() {
|
|
412
|
+
const versions = new Set();
|
|
413
|
+
for (const candidate of desktopAppCodexBinaryCandidates()) {
|
|
414
|
+
if (!(await pathExists(candidate)))
|
|
415
|
+
continue;
|
|
416
|
+
const parsed = runVersionCommand(candidate, ["--version"]);
|
|
417
|
+
versions.add(parsed ?? MINIMUM_CATALOG_CLIENT_VERSION);
|
|
418
|
+
}
|
|
419
|
+
return [...versions];
|
|
420
|
+
}
|
|
421
|
+
function preferredPickerCacheClientVersion(pickerVersions) {
|
|
422
|
+
const compatible = pickerVersions.some((version) => compareCodexVersions(version, MINIMUM_CATALOG_CLIENT_VERSION) >= 0);
|
|
423
|
+
if (!compatible)
|
|
424
|
+
return null;
|
|
425
|
+
// The shared models_cache.json is accepted by newer picker builds when stamped
|
|
426
|
+
// with the oldest model-catalog version, but older app builds reject a cache
|
|
427
|
+
// stamped with a newer VS Code/CLI version.
|
|
428
|
+
return MINIMUM_CATALOG_CLIENT_VERSION;
|
|
429
|
+
}
|
|
364
430
|
async function inferCodexClientVersionFromVersionJson(codexHome) {
|
|
365
431
|
const parsed = await readJsonIfExists(node_path_1.default.join(codexHome, "version.json"));
|
|
366
432
|
const obj = objectRecordOr(parsed);
|
|
@@ -474,7 +540,13 @@ async function inferCodexClientVersion(codexHome) {
|
|
|
474
540
|
versions.push(parsed);
|
|
475
541
|
}
|
|
476
542
|
}
|
|
477
|
-
|
|
543
|
+
const pickerVersions = [
|
|
544
|
+
...await inferCodexClientVersionsFromInstalledDesktopApps(),
|
|
545
|
+
...await inferCodexClientVersionsFromInstalledExtensions(),
|
|
546
|
+
];
|
|
547
|
+
const pickerCacheClientVersion = preferredPickerCacheClientVersion(pickerVersions);
|
|
548
|
+
if (pickerCacheClientVersion)
|
|
549
|
+
return pickerCacheClientVersion;
|
|
478
550
|
const versionJsonVersion = await inferCodexClientVersionFromVersionJson(codexHome);
|
|
479
551
|
if (versionJsonVersion)
|
|
480
552
|
versions.push(versionJsonVersion);
|
|
@@ -497,16 +569,19 @@ async function ensureCodexModelCacheHasGpt54(params) {
|
|
|
497
569
|
const statePath = node_path_1.default.join(params.codexHome, MODELS_CACHE_STATE_FILE);
|
|
498
570
|
try {
|
|
499
571
|
const existingState = await readPatchState(statePath);
|
|
500
|
-
const
|
|
572
|
+
const cacheRead = await readModelsCacheIfExists(cachePath);
|
|
573
|
+
const parsed = cacheRead.parsed;
|
|
501
574
|
const catalogModels = buildCatalogModels();
|
|
502
575
|
const catalogModelMap = buildCatalogModelMap();
|
|
503
|
-
if (parsed === null) {
|
|
576
|
+
if (!cacheRead.exists || parsed === null) {
|
|
504
577
|
const clientVersion = await inferCodexClientVersion(params.codexHome);
|
|
505
578
|
if (!clientVersion) {
|
|
506
579
|
await removeFileIfExists(statePath);
|
|
507
580
|
return {
|
|
508
581
|
action: "skipped",
|
|
509
|
-
warning:
|
|
582
|
+
warning: cacheRead.exists
|
|
583
|
+
? "Codex models cache is not valid JSON, and Codex version could not be inferred for a safe The Claw Bay model catalog repair."
|
|
584
|
+
: "Codex models cache was not found, and Codex version could not be inferred for a safe The Claw Bay model catalog refresh.",
|
|
510
585
|
};
|
|
511
586
|
}
|
|
512
587
|
const docModels = cloneJson(catalogModels);
|
|
@@ -522,7 +597,7 @@ async function ensureCodexModelCacheHasGpt54(params) {
|
|
|
522
597
|
await promises_1.default.mkdir(params.codexHome, { recursive: true });
|
|
523
598
|
await promises_1.default.writeFile(cachePath, `${JSON.stringify(doc, null, 2)}\n`, "utf8");
|
|
524
599
|
await writePatchState(statePath, nextState);
|
|
525
|
-
return { action: "created" };
|
|
600
|
+
return { action: cacheRead.exists ? "refreshed" : "created" };
|
|
526
601
|
}
|
|
527
602
|
const doc = normalizeCacheDocument(parsed);
|
|
528
603
|
if (!doc) {
|
|
@@ -533,7 +608,7 @@ async function ensureCodexModelCacheHasGpt54(params) {
|
|
|
533
608
|
}
|
|
534
609
|
const clientVersion = (await inferCodexClientVersion(params.codexHome)) ??
|
|
535
610
|
(typeof doc.client_version === "string" && doc.client_version ? doc.client_version : null);
|
|
536
|
-
let changed =
|
|
611
|
+
let changed = cacheRead.hadBom;
|
|
537
612
|
let seeded = false;
|
|
538
613
|
const currentCatalogEntries = new Map();
|
|
539
614
|
const rest = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "theclawbay",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.71",
|
|
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": {
|