@lavilas/codex 1.3.60 → 1.3.61
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/codex.js +9 -11
- package/bin/platform-resolver.js +380 -3
- package/bin/postinstall.js +3 -0
- package/package.json +7 -7
package/bin/codex.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Unified entry point for the Codex CLI.
|
|
3
3
|
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { chmodSync, existsSync, readdirSync, statSync } from "fs";
|
|
5
|
+
import { chmodSync, existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import path from "path";
|
|
8
8
|
import { fileURLToPath } from "url";
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
detectPackageManager,
|
|
12
12
|
getCodexBinaryName,
|
|
13
13
|
resolveTargetTriple,
|
|
14
|
+
resolveRuntimeCacheRoot,
|
|
14
15
|
selectVendorInstallation,
|
|
15
16
|
updateCommandForPackageManager,
|
|
16
17
|
} from "./platform-resolver.js";
|
|
@@ -20,6 +21,9 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
20
21
|
const __dirname = path.dirname(__filename);
|
|
21
22
|
const packageDir = path.join(__dirname, "..");
|
|
22
23
|
const require = createRequire(import.meta.url);
|
|
24
|
+
const rootPackageJson = JSON.parse(
|
|
25
|
+
readFileSync(path.join(packageDir, "package.json"), "utf8"),
|
|
26
|
+
);
|
|
23
27
|
|
|
24
28
|
const { platform, arch } = process;
|
|
25
29
|
const targetTriple = resolveTargetTriple(platform, arch);
|
|
@@ -35,18 +39,14 @@ if (!platformPackage) {
|
|
|
35
39
|
|
|
36
40
|
const codexBinaryName = getCodexBinaryName(process.platform);
|
|
37
41
|
const localVendorRoot = path.join(packageDir, "vendor");
|
|
38
|
-
const localBinaryPath = path.join(
|
|
39
|
-
localVendorRoot,
|
|
40
|
-
targetTriple,
|
|
41
|
-
"codex",
|
|
42
|
-
codexBinaryName,
|
|
43
|
-
);
|
|
44
42
|
|
|
45
43
|
const selectedInstallation = selectVendorInstallation({
|
|
46
44
|
packageDir,
|
|
47
45
|
platformPackage,
|
|
48
46
|
targetTriple,
|
|
49
47
|
binaryName: codexBinaryName,
|
|
48
|
+
packageVersion: rootPackageJson.version ?? null,
|
|
49
|
+
runtimeCacheRoot: resolveRuntimeCacheRoot(),
|
|
50
50
|
localVendorRoot,
|
|
51
51
|
requireResolve: (specifier) => require.resolve(specifier),
|
|
52
52
|
});
|
|
@@ -59,9 +59,7 @@ if (!selectedInstallation) {
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const
|
|
63
|
-
const archRoot = path.join(vendorRoot, targetTriple);
|
|
64
|
-
const binaryPath = path.join(archRoot, "codex", codexBinaryName);
|
|
62
|
+
const binaryPath = selectedInstallation.binaryPath;
|
|
65
63
|
|
|
66
64
|
// Use an asynchronous spawn instead of spawnSync so that Node is able to
|
|
67
65
|
// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
|
|
@@ -80,7 +78,7 @@ function getUpdatedPath(newDirs) {
|
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
const additionalDirs = [];
|
|
83
|
-
const pathDir =
|
|
81
|
+
const pathDir = selectedInstallation.pathDir;
|
|
84
82
|
if (existsSync(pathDir)) {
|
|
85
83
|
additionalDirs.push(pathDir);
|
|
86
84
|
}
|
package/bin/platform-resolver.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
+
chmodSync,
|
|
3
|
+
copyFileSync,
|
|
2
4
|
existsSync,
|
|
5
|
+
lstatSync,
|
|
3
6
|
mkdirSync,
|
|
4
7
|
readFileSync,
|
|
5
8
|
readdirSync,
|
|
9
|
+
realpathSync,
|
|
10
|
+
renameSync,
|
|
11
|
+
rmSync,
|
|
6
12
|
statSync,
|
|
7
13
|
writeFileSync,
|
|
8
14
|
} from "node:fs";
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
16
|
+
import os from "node:os";
|
|
9
17
|
import path from "node:path";
|
|
10
18
|
|
|
11
19
|
export const PLATFORM_PACKAGE_BY_TARGET = {
|
|
@@ -95,6 +103,73 @@ function packageInstallDir(packageDir, platformPackage) {
|
|
|
95
103
|
return path.join(packageDir, "node_modules", ...packageNameSegments(platformPackage));
|
|
96
104
|
}
|
|
97
105
|
|
|
106
|
+
function packageCacheBaseDir(runtimeCacheRoot, platformPackage) {
|
|
107
|
+
if (!runtimeCacheRoot) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return path.join(runtimeCacheRoot, ...packageNameSegments(platformPackage));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function packageCacheDir(
|
|
114
|
+
runtimeCacheRoot,
|
|
115
|
+
platformPackage,
|
|
116
|
+
packageVersion,
|
|
117
|
+
manifestDigest = null,
|
|
118
|
+
) {
|
|
119
|
+
if (!runtimeCacheRoot || !packageVersion) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const cacheBaseDir = packageCacheBaseDir(runtimeCacheRoot, platformPackage);
|
|
123
|
+
if (!cacheBaseDir) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const cacheKey = manifestDigest
|
|
127
|
+
? `${packageVersion}-${manifestDigest.slice(0, 12)}`
|
|
128
|
+
: packageVersion;
|
|
129
|
+
return path.join(cacheBaseDir, cacheKey);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function resolveRuntimeCacheRoot({
|
|
133
|
+
env = process.env,
|
|
134
|
+
homeDir = (() => {
|
|
135
|
+
try {
|
|
136
|
+
return os.homedir();
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
})(),
|
|
141
|
+
platformName = process.platform,
|
|
142
|
+
} = {}) {
|
|
143
|
+
const explicitCacheDir =
|
|
144
|
+
env.LAVILAS_CODEX_VENDOR_CACHE_DIR ?? env.CODEX_VENDOR_CACHE_DIR ?? null;
|
|
145
|
+
if (explicitCacheDir) {
|
|
146
|
+
return path.resolve(explicitCacheDir);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const codexHome =
|
|
150
|
+
env.CODEX_HOME ?? (homeDir ? path.join(homeDir, ".codex") : null);
|
|
151
|
+
if (codexHome) {
|
|
152
|
+
return path.join(codexHome, "runtime", "npm");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (!homeDir) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
switch (platformName) {
|
|
160
|
+
case "win32": {
|
|
161
|
+
const localAppData = env.LOCALAPPDATA || path.join(homeDir, "AppData", "Local");
|
|
162
|
+
return path.join(localAppData, "Lavilas", "Codex", "runtime", "npm");
|
|
163
|
+
}
|
|
164
|
+
case "darwin":
|
|
165
|
+
return path.join(homeDir, "Library", "Caches", "Lavilas", "Codex", "runtime", "npm");
|
|
166
|
+
default: {
|
|
167
|
+
const xdgCacheHome = env.XDG_CACHE_HOME || path.join(homeDir, ".cache");
|
|
168
|
+
return path.join(xdgCacheHome, "lavilas-codex", "runtime", "npm");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
98
173
|
function readJsonFile(filePath) {
|
|
99
174
|
try {
|
|
100
175
|
if (!existsSync(filePath)) {
|
|
@@ -110,7 +185,89 @@ function vendorManifestFor(vendorRoot) {
|
|
|
110
185
|
return readJsonFile(path.join(vendorRoot, "manifest.json"));
|
|
111
186
|
}
|
|
112
187
|
|
|
113
|
-
function
|
|
188
|
+
function vendorManifestDigest(vendorRoot) {
|
|
189
|
+
try {
|
|
190
|
+
const manifestContents = readFileSync(path.join(vendorRoot, "manifest.json"));
|
|
191
|
+
return createHash("sha256").update(manifestContents).digest("hex");
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function readyMarkerPathFor(vendorRoot) {
|
|
198
|
+
return path.join(path.dirname(vendorRoot), ".ready.json");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function readyMarkerFor(vendorRoot) {
|
|
202
|
+
return readJsonFile(readyMarkerPathFor(vendorRoot));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function validateVendorManifest(manifest, vendorRoot) {
|
|
206
|
+
if (!manifest || typeof manifest !== "object") {
|
|
207
|
+
return { valid: false, reason: "missing manifest.json" };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const files = manifest.files;
|
|
211
|
+
if (!files || typeof files !== "object") {
|
|
212
|
+
return { valid: false, reason: "invalid manifest.json files map" };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
for (const [relativePath, metadata] of Object.entries(files)) {
|
|
216
|
+
const candidatePath = path.join(vendorRoot, relativePath);
|
|
217
|
+
if (!existsSync(candidatePath)) {
|
|
218
|
+
return { valid: false, reason: `missing ${relativePath}` };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
let candidateStat;
|
|
222
|
+
try {
|
|
223
|
+
candidateStat = statSync(candidatePath);
|
|
224
|
+
} catch {
|
|
225
|
+
return { valid: false, reason: `unable to stat ${relativePath}` };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (!candidateStat.isFile() || candidateStat.size <= 0) {
|
|
229
|
+
return { valid: false, reason: `invalid ${relativePath}` };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (
|
|
233
|
+
metadata &&
|
|
234
|
+
typeof metadata === "object" &&
|
|
235
|
+
typeof metadata.size === "number" &&
|
|
236
|
+
metadata.size !== candidateStat.size
|
|
237
|
+
) {
|
|
238
|
+
return { valid: false, reason: `size mismatch for ${relativePath}` };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return { valid: true };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function validateVendorRoot(
|
|
246
|
+
candidate,
|
|
247
|
+
targetTriple,
|
|
248
|
+
binaryName,
|
|
249
|
+
{ requireReadyMarker = false } = {},
|
|
250
|
+
) {
|
|
251
|
+
const manifest = vendorManifestFor(candidate.vendorRoot);
|
|
252
|
+
const manifestValidation = validateVendorManifest(manifest, candidate.vendorRoot);
|
|
253
|
+
if (!manifestValidation.valid) {
|
|
254
|
+
return manifestValidation;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (requireReadyMarker) {
|
|
258
|
+
const readyMarker = readyMarkerFor(candidate.vendorRoot);
|
|
259
|
+
if (!readyMarker || typeof readyMarker !== "object") {
|
|
260
|
+
return { valid: false, reason: "missing .ready.json" };
|
|
261
|
+
}
|
|
262
|
+
if (
|
|
263
|
+
candidate.cacheKey &&
|
|
264
|
+
typeof readyMarker.cacheKey === "string" &&
|
|
265
|
+
readyMarker.cacheKey !== candidate.cacheKey
|
|
266
|
+
) {
|
|
267
|
+
return { valid: false, reason: "runtime cache marker mismatch" };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
114
271
|
const binaryRelativePath = `${targetTriple}/codex/${binaryName}`;
|
|
115
272
|
const binaryPath = path.join(candidate.vendorRoot, binaryRelativePath);
|
|
116
273
|
if (!existsSync(binaryPath)) {
|
|
@@ -127,7 +284,6 @@ function validateVendorRoot(candidate, targetTriple, binaryName) {
|
|
|
127
284
|
return { valid: false, reason: `invalid ${binaryRelativePath}` };
|
|
128
285
|
}
|
|
129
286
|
|
|
130
|
-
const manifest = vendorManifestFor(candidate.vendorRoot);
|
|
131
287
|
const expectedBinary = manifest?.files?.[binaryRelativePath];
|
|
132
288
|
if (
|
|
133
289
|
expectedBinary &&
|
|
@@ -161,6 +317,199 @@ function pushCandidate(candidates, seen, vendorRoot, source) {
|
|
|
161
317
|
candidates.push({ vendorRoot: resolvedRoot, source });
|
|
162
318
|
}
|
|
163
319
|
|
|
320
|
+
function copyDirectoryRecursive(sourceDir, destinationDir) {
|
|
321
|
+
mkdirSync(destinationDir, { recursive: true });
|
|
322
|
+
|
|
323
|
+
for (const entry of readdirSync(sourceDir, { withFileTypes: true })) {
|
|
324
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
325
|
+
const destinationPath = path.join(destinationDir, entry.name);
|
|
326
|
+
|
|
327
|
+
if (entry.isDirectory()) {
|
|
328
|
+
copyDirectoryRecursive(sourcePath, destinationPath);
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (entry.isSymbolicLink()) {
|
|
333
|
+
const resolvedPath = realpathSync(sourcePath);
|
|
334
|
+
const resolvedStat = statSync(resolvedPath);
|
|
335
|
+
if (resolvedStat.isDirectory()) {
|
|
336
|
+
copyDirectoryRecursive(resolvedPath, destinationPath);
|
|
337
|
+
} else {
|
|
338
|
+
copyFileSync(resolvedPath, destinationPath);
|
|
339
|
+
chmodSync(destinationPath, resolvedStat.mode);
|
|
340
|
+
}
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const sourceStat = lstatSync(sourcePath);
|
|
345
|
+
if (sourceStat.isDirectory()) {
|
|
346
|
+
copyDirectoryRecursive(sourcePath, destinationPath);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
copyFileSync(sourcePath, destinationPath);
|
|
351
|
+
chmodSync(destinationPath, sourceStat.mode);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function runtimeCacheCandidate({
|
|
356
|
+
runtimeCacheRoot,
|
|
357
|
+
platformPackage,
|
|
358
|
+
packageVersion,
|
|
359
|
+
manifestDigest = null,
|
|
360
|
+
source = "runtime-cache",
|
|
361
|
+
}) {
|
|
362
|
+
const cacheDir = packageCacheDir(
|
|
363
|
+
runtimeCacheRoot,
|
|
364
|
+
platformPackage,
|
|
365
|
+
packageVersion,
|
|
366
|
+
manifestDigest,
|
|
367
|
+
);
|
|
368
|
+
if (!cacheDir) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
vendorRoot: path.join(cacheDir, "vendor"),
|
|
373
|
+
cacheKey: path.basename(cacheDir),
|
|
374
|
+
source,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function collectRuntimeCacheCandidates({
|
|
379
|
+
runtimeCacheRoot,
|
|
380
|
+
platformPackage,
|
|
381
|
+
packageVersion,
|
|
382
|
+
}) {
|
|
383
|
+
const cacheBaseDir = packageCacheBaseDir(runtimeCacheRoot, platformPackage);
|
|
384
|
+
if (!cacheBaseDir || !packageVersion || !existsSync(cacheBaseDir)) {
|
|
385
|
+
return [];
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const versionPrefix = `${packageVersion}-`;
|
|
389
|
+
return readdirSync(cacheBaseDir, { withFileTypes: true })
|
|
390
|
+
.filter((entry) => entry.isDirectory() && entry.name.startsWith(versionPrefix))
|
|
391
|
+
.map((entry) => ({
|
|
392
|
+
vendorRoot: path.join(cacheBaseDir, entry.name, "vendor"),
|
|
393
|
+
cacheKey: entry.name,
|
|
394
|
+
source: "runtime-cache",
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function materializeRuntimeCache({
|
|
399
|
+
runtimeCacheRoot,
|
|
400
|
+
platformPackage,
|
|
401
|
+
packageVersion,
|
|
402
|
+
targetTriple,
|
|
403
|
+
binaryName,
|
|
404
|
+
sourceInstallation,
|
|
405
|
+
}) {
|
|
406
|
+
const manifestDigest = vendorManifestDigest(sourceInstallation.vendorRoot);
|
|
407
|
+
const cacheDir = packageCacheDir(
|
|
408
|
+
runtimeCacheRoot,
|
|
409
|
+
platformPackage,
|
|
410
|
+
packageVersion,
|
|
411
|
+
manifestDigest,
|
|
412
|
+
);
|
|
413
|
+
if (!cacheDir || !manifestDigest) {
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const cachedCandidate = runtimeCacheCandidate({
|
|
418
|
+
runtimeCacheRoot,
|
|
419
|
+
platformPackage,
|
|
420
|
+
packageVersion,
|
|
421
|
+
manifestDigest,
|
|
422
|
+
source: `runtime-cache:${sourceInstallation.source}`,
|
|
423
|
+
});
|
|
424
|
+
if (!cachedCandidate) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const cachedInstallation = validateVendorRoot(
|
|
429
|
+
cachedCandidate,
|
|
430
|
+
targetTriple,
|
|
431
|
+
binaryName,
|
|
432
|
+
{ requireReadyMarker: true },
|
|
433
|
+
);
|
|
434
|
+
if (cachedInstallation.valid) {
|
|
435
|
+
return cachedInstallation;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const cacheParentDir = path.dirname(cacheDir);
|
|
439
|
+
mkdirSync(cacheParentDir, { recursive: true });
|
|
440
|
+
|
|
441
|
+
const tempCacheDir = path.join(
|
|
442
|
+
cacheParentDir,
|
|
443
|
+
`.tmp-${packageVersion}-${process.pid}-${Date.now()}-${Math.random()
|
|
444
|
+
.toString(16)
|
|
445
|
+
.slice(2)}`,
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
try {
|
|
449
|
+
copyDirectoryRecursive(sourceInstallation.vendorRoot, path.join(tempCacheDir, "vendor"));
|
|
450
|
+
|
|
451
|
+
const stagedInstallation = validateVendorRoot(
|
|
452
|
+
{
|
|
453
|
+
vendorRoot: path.join(tempCacheDir, "vendor"),
|
|
454
|
+
cacheKey: path.basename(cacheDir),
|
|
455
|
+
source: `runtime-cache-staging:${sourceInstallation.source}`,
|
|
456
|
+
},
|
|
457
|
+
targetTriple,
|
|
458
|
+
binaryName,
|
|
459
|
+
);
|
|
460
|
+
if (!stagedInstallation.valid) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const readyMarker = {
|
|
465
|
+
cacheKey: path.basename(cacheDir),
|
|
466
|
+
platformPackage,
|
|
467
|
+
packageVersion,
|
|
468
|
+
targetTriple,
|
|
469
|
+
manifestSha256: manifestDigest,
|
|
470
|
+
createdAt: new Date().toISOString(),
|
|
471
|
+
};
|
|
472
|
+
writeFileSync(
|
|
473
|
+
readyMarkerPathFor(path.join(tempCacheDir, "vendor")),
|
|
474
|
+
`${JSON.stringify(readyMarker, null, 2)}\n`,
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
try {
|
|
478
|
+
renameSync(tempCacheDir, cacheDir);
|
|
479
|
+
} catch {
|
|
480
|
+
const currentInstallation = validateVendorRoot(
|
|
481
|
+
cachedCandidate,
|
|
482
|
+
targetTriple,
|
|
483
|
+
binaryName,
|
|
484
|
+
{ requireReadyMarker: true },
|
|
485
|
+
);
|
|
486
|
+
if (currentInstallation.valid) {
|
|
487
|
+
return currentInstallation;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const currentReadyMarker = readyMarkerFor(cachedCandidate.vendorRoot);
|
|
491
|
+
if (!currentReadyMarker && existsSync(cacheDir)) {
|
|
492
|
+
rmSync(cacheDir, { recursive: true, force: true });
|
|
493
|
+
renameSync(tempCacheDir, cacheDir);
|
|
494
|
+
} else {
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const finalInstallation = validateVendorRoot(
|
|
500
|
+
cachedCandidate,
|
|
501
|
+
targetTriple,
|
|
502
|
+
binaryName,
|
|
503
|
+
{ requireReadyMarker: true },
|
|
504
|
+
);
|
|
505
|
+
return finalInstallation.valid ? finalInstallation : null;
|
|
506
|
+
} catch {
|
|
507
|
+
return null;
|
|
508
|
+
} finally {
|
|
509
|
+
rmSync(tempCacheDir, { recursive: true, force: true });
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
164
513
|
export function collectVendorCandidates({
|
|
165
514
|
packageDir,
|
|
166
515
|
platformPackage,
|
|
@@ -216,6 +565,8 @@ export function selectVendorInstallation({
|
|
|
216
565
|
platformPackage,
|
|
217
566
|
targetTriple,
|
|
218
567
|
binaryName,
|
|
568
|
+
packageVersion = null,
|
|
569
|
+
runtimeCacheRoot = null,
|
|
219
570
|
localVendorRoot = path.join(packageDir, "vendor"),
|
|
220
571
|
requireResolve = null,
|
|
221
572
|
}) {
|
|
@@ -228,9 +579,35 @@ export function selectVendorInstallation({
|
|
|
228
579
|
for (const candidate of candidates) {
|
|
229
580
|
const result = validateVendorRoot(candidate, targetTriple, binaryName);
|
|
230
581
|
if (result.valid) {
|
|
231
|
-
return
|
|
582
|
+
return (
|
|
583
|
+
materializeRuntimeCache({
|
|
584
|
+
runtimeCacheRoot,
|
|
585
|
+
platformPackage,
|
|
586
|
+
packageVersion,
|
|
587
|
+
targetTriple,
|
|
588
|
+
binaryName,
|
|
589
|
+
sourceInstallation: result,
|
|
590
|
+
}) ?? result
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
for (const cachedCandidate of collectRuntimeCacheCandidates({
|
|
596
|
+
runtimeCacheRoot,
|
|
597
|
+
platformPackage,
|
|
598
|
+
packageVersion,
|
|
599
|
+
})) {
|
|
600
|
+
const cachedInstallation = validateVendorRoot(
|
|
601
|
+
cachedCandidate,
|
|
602
|
+
targetTriple,
|
|
603
|
+
binaryName,
|
|
604
|
+
{ requireReadyMarker: true },
|
|
605
|
+
);
|
|
606
|
+
if (cachedInstallation.valid) {
|
|
607
|
+
return cachedInstallation;
|
|
232
608
|
}
|
|
233
609
|
}
|
|
610
|
+
|
|
234
611
|
return null;
|
|
235
612
|
}
|
|
236
613
|
|
package/bin/postinstall.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ensurePlatformPackageMetadata,
|
|
12
12
|
getCodexBinaryName,
|
|
13
13
|
resolveTargetTriple,
|
|
14
|
+
resolveRuntimeCacheRoot,
|
|
14
15
|
selectVendorInstallation,
|
|
15
16
|
updateCommandForPackageManager,
|
|
16
17
|
} from "./platform-resolver.js";
|
|
@@ -51,6 +52,8 @@ const selectedInstallation = selectVendorInstallation({
|
|
|
51
52
|
platformPackage,
|
|
52
53
|
targetTriple,
|
|
53
54
|
binaryName: getCodexBinaryName(),
|
|
55
|
+
packageVersion: rootPackageJson.version ?? null,
|
|
56
|
+
runtimeCacheRoot: resolveRuntimeCacheRoot(),
|
|
54
57
|
requireResolve: (specifier) => require.resolve(specifier),
|
|
55
58
|
});
|
|
56
59
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lavilas/codex",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.61",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codex": "bin/codex.js",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"packageManager": "pnpm@10.29.3+sha512.498e1fb4cca5aa06c1dcf2611e6fafc50972ffe7189998c409e90de74566444298ffe43e6cd2acdc775ba1aa7cc5e092a8b7054c811ba8c5770f84693d33d2dc",
|
|
28
28
|
"optionalDependencies": {
|
|
29
|
-
"@lavilas/codex-linux-x64": "1.3.
|
|
30
|
-
"@lavilas/codex-linux-arm64": "1.3.
|
|
31
|
-
"@lavilas/codex-darwin-x64": "1.3.
|
|
32
|
-
"@lavilas/codex-darwin-arm64": "1.3.
|
|
33
|
-
"@lavilas/codex-win32-x64": "1.3.
|
|
34
|
-
"@lavilas/codex-win32-arm64": "1.3.
|
|
29
|
+
"@lavilas/codex-linux-x64": "1.3.61",
|
|
30
|
+
"@lavilas/codex-linux-arm64": "1.3.61",
|
|
31
|
+
"@lavilas/codex-darwin-x64": "1.3.61",
|
|
32
|
+
"@lavilas/codex-darwin-arm64": "1.3.61",
|
|
33
|
+
"@lavilas/codex-win32-x64": "1.3.61",
|
|
34
|
+
"@lavilas/codex-win32-arm64": "1.3.61"
|
|
35
35
|
}
|
|
36
36
|
}
|