gencow 0.1.225 → 0.1.226
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 +3 -3
- package/runtime/server.mjs +121 -103
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gencow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.226",
|
|
4
4
|
"description": "Gencow — AI Backend Engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^25.9.5",
|
|
35
35
|
"better-auth": "^1.6.23",
|
|
36
|
-
"@gencow/core": "0.1.43",
|
|
37
36
|
"@gencow/client": "0.2.7",
|
|
38
|
-
"@gencow/react": "0.2.7"
|
|
37
|
+
"@gencow/react": "0.2.7",
|
|
38
|
+
"@gencow/core": "0.1.43"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"prebuild": "pnpm --filter @gencow/migration-contract run build && pnpm --filter @gencow/server run build",
|
package/runtime/server.mjs
CHANGED
|
@@ -105514,7 +105514,7 @@ var require_package = __commonJS({
|
|
|
105514
105514
|
// ../../node_modules/.pnpm/sharp@0.34.5/node_modules/sharp/lib/libvips.js
|
|
105515
105515
|
var require_libvips = __commonJS({
|
|
105516
105516
|
"../../node_modules/.pnpm/sharp@0.34.5/node_modules/sharp/lib/libvips.js"(exports2, module2) {
|
|
105517
|
-
var { spawnSync } = __require("node:child_process");
|
|
105517
|
+
var { spawnSync: spawnSync2 } = __require("node:child_process");
|
|
105518
105518
|
var { createHash: createHash86 } = __require("node:crypto");
|
|
105519
105519
|
var semverCoerce = require_coerce();
|
|
105520
105520
|
var semverGreaterThanOrEqualTo = require_gte();
|
|
@@ -105601,7 +105601,7 @@ var require_libvips = __commonJS({
|
|
|
105601
105601
|
};
|
|
105602
105602
|
var isRosetta = () => {
|
|
105603
105603
|
if (process.platform === "darwin" && process.arch === "x64") {
|
|
105604
|
-
const translated =
|
|
105604
|
+
const translated = spawnSync2("sysctl sysctl.proc_translated", spawnSyncOptions).stdout;
|
|
105605
105605
|
return (translated || "").trim() === "sysctl.proc_translated: 1";
|
|
105606
105606
|
}
|
|
105607
105607
|
return false;
|
|
@@ -105618,13 +105618,13 @@ var require_libvips = __commonJS({
|
|
|
105618
105618
|
}
|
|
105619
105619
|
return "";
|
|
105620
105620
|
};
|
|
105621
|
-
var spawnRebuild = () =>
|
|
105621
|
+
var spawnRebuild = () => spawnSync2(`node-gyp rebuild --directory=src ${isEmscripten() ? "--nodedir=emscripten" : ""}`, {
|
|
105622
105622
|
...spawnSyncOptions,
|
|
105623
105623
|
stdio: "inherit"
|
|
105624
105624
|
}).status;
|
|
105625
105625
|
var globalLibvipsVersion = () => {
|
|
105626
105626
|
if (process.platform !== "win32") {
|
|
105627
|
-
const globalLibvipsVersion2 =
|
|
105627
|
+
const globalLibvipsVersion2 = spawnSync2("pkg-config --modversion vips-cpp", {
|
|
105628
105628
|
...spawnSyncOptions,
|
|
105629
105629
|
env: {
|
|
105630
105630
|
...process.env,
|
|
@@ -105638,7 +105638,7 @@ var require_libvips = __commonJS({
|
|
|
105638
105638
|
};
|
|
105639
105639
|
var pkgConfigPath = () => {
|
|
105640
105640
|
if (process.platform !== "win32") {
|
|
105641
|
-
const brewPkgConfigPath =
|
|
105641
|
+
const brewPkgConfigPath = spawnSync2(
|
|
105642
105642
|
'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',
|
|
105643
105643
|
spawnSyncOptions
|
|
105644
105644
|
).stdout || "";
|
|
@@ -166712,6 +166712,7 @@ async function registerManagedAnalyticsIngestRoute(app2, functionsPath, analytic
|
|
|
166712
166712
|
const ingest = createManagedAnalyticsIngestHandler({
|
|
166713
166713
|
authorizationToken: readAnalyticsIngestToken(tokenFileValue),
|
|
166714
166714
|
analyticsRawSql: params.analyticsRawSql,
|
|
166715
|
+
logger: console,
|
|
166715
166716
|
resolveSite: async (record2) => {
|
|
166716
166717
|
const analyticsSites2 = await import(resolve46(params.functionsPath, "analytics-sites.ts"));
|
|
166717
166718
|
const rows4 = await params.db.select().from(appsTable).where(eqOp(appsTable.id, record2.appId)).limit(1);
|
|
@@ -403685,6 +403686,17 @@ var init_runner_process_identity_store = __esm({
|
|
|
403685
403686
|
});
|
|
403686
403687
|
|
|
403687
403688
|
// ../platform/src/cowbox-control-handoff.ts
|
|
403689
|
+
import { spawnSync } from "node:child_process";
|
|
403690
|
+
import { existsSync as existsSync38 } from "node:fs";
|
|
403691
|
+
function supportsCowboxControlHandoff(binary) {
|
|
403692
|
+
if (!binary || !existsSync38(binary)) return false;
|
|
403693
|
+
const probe = spawnSync(binary, ["run", "--control-ready-fd"], { encoding: "utf8", timeout: 2e3, stdio: ["ignore", "pipe", "pipe"] });
|
|
403694
|
+
return !/unexpected argument ['"]?--control-ready-fd/u.test(`${probe.stdout || ""}
|
|
403695
|
+
${probe.stderr || ""}`);
|
|
403696
|
+
}
|
|
403697
|
+
function shouldUseHostCowbox(pinned, host) {
|
|
403698
|
+
return Boolean(pinned && pinned !== host && !supportsCowboxControlHandoff(pinned) && supportsCowboxControlHandoff(host));
|
|
403699
|
+
}
|
|
403688
403700
|
function parseCowboxControlHandoff(source, expectedPid) {
|
|
403689
403701
|
const lines = source.split(/\r?\n/u).map((line) => line.trim()).filter(Boolean);
|
|
403690
403702
|
if (lines.length !== 1 || Buffer.byteLength(lines[0]) > MAX_CONTROL_RECORD_BYTES) return null;
|
|
@@ -403876,7 +403888,7 @@ import { spawn } from "child_process";
|
|
|
403876
403888
|
import {
|
|
403877
403889
|
chmodSync as chmodSync2,
|
|
403878
403890
|
closeSync as closeSync5,
|
|
403879
|
-
existsSync as
|
|
403891
|
+
existsSync as existsSync39,
|
|
403880
403892
|
mkdirSync as mkdirSync9,
|
|
403881
403893
|
openSync as openSync5,
|
|
403882
403894
|
readFileSync as readFileSync39,
|
|
@@ -403888,11 +403900,11 @@ import { homedir } from "os";
|
|
|
403888
403900
|
import { Readable as Readable5 } from "node:stream";
|
|
403889
403901
|
function findBunBin() {
|
|
403890
403902
|
const envBun = process.env.BUN_BIN;
|
|
403891
|
-
if (envBun &&
|
|
403903
|
+
if (envBun && existsSync39(envBun)) return envBun;
|
|
403892
403904
|
const defaultBun = "/usr/local/bin/bun";
|
|
403893
|
-
if (
|
|
403905
|
+
if (existsSync39(defaultBun)) return defaultBun;
|
|
403894
403906
|
const homeBun = resolve76(homedir(), ".bun", "bin", "bun");
|
|
403895
|
-
if (
|
|
403907
|
+
if (existsSync39(homeBun)) return homeBun;
|
|
403896
403908
|
return "bun";
|
|
403897
403909
|
}
|
|
403898
403910
|
function appendLogCache(appName, line) {
|
|
@@ -403910,7 +403922,7 @@ function savePid(appName, pid) {
|
|
|
403910
403922
|
}
|
|
403911
403923
|
function readPid(appName) {
|
|
403912
403924
|
const file2 = pidFile(appName);
|
|
403913
|
-
if (!
|
|
403925
|
+
if (!existsSync39(file2)) return null;
|
|
403914
403926
|
const content = readFileSync39(file2, "utf-8").trim();
|
|
403915
403927
|
const pid = parseInt(content, 10);
|
|
403916
403928
|
return isNaN(pid) ? null : pid;
|
|
@@ -403969,7 +403981,7 @@ var init_direct_runner = __esm({
|
|
|
403969
403981
|
MEMORY_MAX_DEFAULT = process.env.GENCOW_APP_MEMORY_MAX || "256M";
|
|
403970
403982
|
CPU_QUOTA = process.env.GENCOW_APP_CPU_QUOTA || "100%";
|
|
403971
403983
|
COWBOX_BIN = process.env.COWBOX_BIN || "/usr/local/bin/cowbox";
|
|
403972
|
-
useCowbox = process.platform === "linux" &&
|
|
403984
|
+
useCowbox = process.platform === "linux" && existsSync39(COWBOX_BIN);
|
|
403973
403985
|
BUN_BIN = findBunBin();
|
|
403974
403986
|
SERVER_ENTRY = "";
|
|
403975
403987
|
logCache = /* @__PURE__ */ new Map();
|
|
@@ -403990,7 +404002,7 @@ var init_direct_runner = __esm({
|
|
|
403990
404002
|
this.detachedProcess = dependencies.detachedProcess ?? true;
|
|
403991
404003
|
this.waitForControlHandoff = dependencies.waitForControlHandoff ?? waitForCowboxControlHandoff;
|
|
403992
404004
|
const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
|
|
403993
|
-
this.useSystemd = isRoot &&
|
|
404005
|
+
this.useSystemd = isRoot && existsSync39("/usr/bin/systemd-run") && process.platform === "linux";
|
|
403994
404006
|
console.log(`[direct-runner] Using bun: ${BUN_BIN}`);
|
|
403995
404007
|
if (useCowbox) {
|
|
403996
404008
|
const profilePath = resolveCowboxProfilePath("worker");
|
|
@@ -404036,8 +404048,14 @@ var init_direct_runner = __esm({
|
|
|
404036
404048
|
throw new Error("[direct-runner] SERVER_ENTRY not set \u2014 call setServerEntry() first");
|
|
404037
404049
|
}
|
|
404038
404050
|
const bunBinary = options?.bunBinary || BUN_BIN;
|
|
404039
|
-
|
|
404040
|
-
|
|
404051
|
+
let cowboxBinary = options?.cowboxBinary || COWBOX_BIN;
|
|
404052
|
+
if (shouldUseHostCowbox(options?.cowboxBinary, COWBOX_BIN)) {
|
|
404053
|
+
console.warn(
|
|
404054
|
+
`[direct-runner] ${appName}: pinned cowbox lacks control handoff; using host cowbox ${COWBOX_BIN}`
|
|
404055
|
+
);
|
|
404056
|
+
cowboxBinary = COWBOX_BIN;
|
|
404057
|
+
}
|
|
404058
|
+
const useCowboxForBoot = process.platform === "linux" && existsSync39(cowboxBinary);
|
|
404041
404059
|
const runtimeServerEntry = options?.serverEntry ? serverEntry : resolveRuntimeServerEntryPath(dataDir, serverEntry);
|
|
404042
404060
|
if (!options?.dependencyPrepared) {
|
|
404043
404061
|
await prepareAppDependencyHygiene(appName, dataDir, console);
|
|
@@ -404081,7 +404099,7 @@ var init_direct_runner = __esm({
|
|
|
404081
404099
|
const runtimeDir = resolve76(appRuntimeDir, "runtime");
|
|
404082
404100
|
const legacyRuntimeReleaseDir = resolve76(appRuntimeDir, "release");
|
|
404083
404101
|
const appOwnedDepsDir = resolve76(dataDir, ".gencow-app-deps");
|
|
404084
|
-
const runtimeReleaseDir =
|
|
404102
|
+
const runtimeReleaseDir = existsSync39(runtimeDir) ? runtimeDir : options?.runtimeRoot || env2.GENCOW_RUNTIME_RELEASE_DIR || legacyRuntimeReleaseDir;
|
|
404085
404103
|
const profilePath = resolveCowboxProfilePath("worker");
|
|
404086
404104
|
const profileSource = readCowboxProfile("worker", profilePath);
|
|
404087
404105
|
const profileVariables = new Set(extractCowboxTemplateVariables(profileSource));
|
|
@@ -404487,16 +404505,16 @@ __export(nsjail_runner_exports, {
|
|
|
404487
404505
|
buildNsjailArgs: () => buildNsjailArgs
|
|
404488
404506
|
});
|
|
404489
404507
|
import { spawn as spawn2 } from "child_process";
|
|
404490
|
-
import { existsSync as
|
|
404508
|
+
import { existsSync as existsSync40, readFileSync as readFileSync40, writeFileSync as writeFileSync9, unlinkSync as unlinkSync3, mkdirSync as mkdirSync10 } from "fs";
|
|
404491
404509
|
import { resolve as resolve77 } from "path";
|
|
404492
404510
|
import { homedir as homedir2 } from "os";
|
|
404493
404511
|
function findBunBin2() {
|
|
404494
404512
|
const envBun = process.env.BUN_BIN;
|
|
404495
|
-
if (envBun &&
|
|
404513
|
+
if (envBun && existsSync40(envBun)) return envBun;
|
|
404496
404514
|
const homeBun = resolve77(homedir2(), ".bun", "bin", "bun");
|
|
404497
|
-
if (
|
|
404515
|
+
if (existsSync40(homeBun)) return homeBun;
|
|
404498
404516
|
const defaultBun = "/usr/local/bin/bun";
|
|
404499
|
-
if (
|
|
404517
|
+
if (existsSync40(defaultBun)) return defaultBun;
|
|
404500
404518
|
return "bun";
|
|
404501
404519
|
}
|
|
404502
404520
|
function appendLogCache2(appName, line) {
|
|
@@ -404514,7 +404532,7 @@ function savePid2(appName, pid) {
|
|
|
404514
404532
|
}
|
|
404515
404533
|
function readPid2(appName) {
|
|
404516
404534
|
const file2 = pidFile2(appName);
|
|
404517
|
-
if (!
|
|
404535
|
+
if (!existsSync40(file2)) return null;
|
|
404518
404536
|
const content = readFileSync40(file2, "utf-8").trim();
|
|
404519
404537
|
const pid = parseInt(content, 10);
|
|
404520
404538
|
return isNaN(pid) ? null : pid;
|
|
@@ -404654,7 +404672,7 @@ var init_nsjail_runner = __esm({
|
|
|
404654
404672
|
if (!serverEntry) {
|
|
404655
404673
|
throw new Error("[nsjail-runner] SERVER_ENTRY not set \u2014 call setServerEntry() first");
|
|
404656
404674
|
}
|
|
404657
|
-
if (!
|
|
404675
|
+
if (!existsSync40(NSJAIL_BIN)) {
|
|
404658
404676
|
throw new Error(`[nsjail-runner] nsjail not found at ${NSJAIL_BIN}. Install nsjail first.`);
|
|
404659
404677
|
}
|
|
404660
404678
|
const runtimeServerEntry = options?.serverEntry ? serverEntry : resolveRuntimeServerEntryPath(dataDir, serverEntry);
|
|
@@ -404907,7 +404925,7 @@ __export(bun_runner_exports, {
|
|
|
404907
404925
|
});
|
|
404908
404926
|
import { spawn as spawn3 } from "child_process";
|
|
404909
404927
|
import { createHash as createHash52 } from "node:crypto";
|
|
404910
|
-
import { existsSync as
|
|
404928
|
+
import { existsSync as existsSync41 } from "fs";
|
|
404911
404929
|
import { resolve as resolve78 } from "path";
|
|
404912
404930
|
import { homedir as homedir3 } from "os";
|
|
404913
404931
|
function ensureInit(serverEntry) {
|
|
@@ -404916,13 +404934,13 @@ function ensureInit(serverEntry) {
|
|
|
404916
404934
|
SERVER_ENTRY3 = serverEntry;
|
|
404917
404935
|
}
|
|
404918
404936
|
const envBun = process.env.BUN_BIN;
|
|
404919
|
-
if (envBun &&
|
|
404937
|
+
if (envBun && existsSync41(envBun)) {
|
|
404920
404938
|
BUN_BIN3 = envBun;
|
|
404921
404939
|
BUN_ARGS = ["run"];
|
|
404922
404940
|
return;
|
|
404923
404941
|
}
|
|
404924
404942
|
const homeBun = resolve78(homedir3(), ".bun", "bin", "bun");
|
|
404925
|
-
if (
|
|
404943
|
+
if (existsSync41(homeBun)) {
|
|
404926
404944
|
BUN_BIN3 = homeBun;
|
|
404927
404945
|
BUN_ARGS = ["run"];
|
|
404928
404946
|
return;
|
|
@@ -405438,7 +405456,7 @@ var init_runtime_boot_failure = __esm({
|
|
|
405438
405456
|
|
|
405439
405457
|
// ../platform/src/provisioner-bundles.ts
|
|
405440
405458
|
import {
|
|
405441
|
-
existsSync as
|
|
405459
|
+
existsSync as existsSync42,
|
|
405442
405460
|
chmodSync as chmodSync3,
|
|
405443
405461
|
closeSync as closeSync6,
|
|
405444
405462
|
fsyncSync as fsyncSync3,
|
|
@@ -405520,7 +405538,7 @@ function writePromotionJournal(journal) {
|
|
|
405520
405538
|
}
|
|
405521
405539
|
function readPromotionJournal(dataDir) {
|
|
405522
405540
|
const path4 = journalPath(dataDir);
|
|
405523
|
-
if (!
|
|
405541
|
+
if (!existsSync42(path4)) return null;
|
|
405524
405542
|
const parsed = JSON.parse(readFileSync41(path4, "utf8"));
|
|
405525
405543
|
const expectedDataDir = resolve79(dataDir);
|
|
405526
405544
|
const expectedBackupPrefix = `.${basename12(expectedDataDir)}-backup-`;
|
|
@@ -405551,7 +405569,7 @@ function recoverInterruptedBundlePromotion(dataDir, options = {}) {
|
|
|
405551
405569
|
for (const relativePath of [...journal.managedPaths].reverse()) {
|
|
405552
405570
|
const livePath = resolve79(journal.dataDir, relativePath);
|
|
405553
405571
|
const backupPath = resolve79(journal.backupDir, relativePath);
|
|
405554
|
-
if (
|
|
405572
|
+
if (existsSync42(backupPath)) {
|
|
405555
405573
|
rmSync9(livePath, { recursive: true, force: true });
|
|
405556
405574
|
mkdirSync12(dirname19(livePath), { recursive: true });
|
|
405557
405575
|
renameSync5(backupPath, livePath);
|
|
@@ -405577,7 +405595,7 @@ function promoteStagedBundlePaths(params) {
|
|
|
405577
405595
|
backupDir,
|
|
405578
405596
|
managedPaths,
|
|
405579
405597
|
originalPaths: Object.fromEntries(
|
|
405580
|
-
managedPaths.map((relativePath) => [relativePath,
|
|
405598
|
+
managedPaths.map((relativePath) => [relativePath, existsSync42(resolve79(params.dataDir, relativePath))])
|
|
405581
405599
|
)
|
|
405582
405600
|
};
|
|
405583
405601
|
writePromotionJournal(journal);
|
|
@@ -405585,13 +405603,13 @@ function promoteStagedBundlePaths(params) {
|
|
|
405585
405603
|
for (const relativePath of managedPaths) {
|
|
405586
405604
|
const stagedPath = resolve79(params.stagingDir, relativePath);
|
|
405587
405605
|
const livePath = resolve79(params.dataDir, relativePath);
|
|
405588
|
-
if (!
|
|
405606
|
+
if (!existsSync42(stagedPath) && !removeWhenMissing.has(relativePath)) continue;
|
|
405589
405607
|
const backupPath = resolve79(backupDir, relativePath);
|
|
405590
|
-
if (
|
|
405608
|
+
if (existsSync42(livePath)) {
|
|
405591
405609
|
mkdirSync12(dirname19(backupPath), { recursive: true });
|
|
405592
405610
|
renameSync5(livePath, backupPath);
|
|
405593
405611
|
}
|
|
405594
|
-
if (
|
|
405612
|
+
if (existsSync42(stagedPath)) {
|
|
405595
405613
|
mkdirSync12(dirname19(livePath), { recursive: true });
|
|
405596
405614
|
renameSync5(stagedPath, livePath);
|
|
405597
405615
|
}
|
|
@@ -405615,7 +405633,7 @@ async function saveBundleCopy(dataDir, hash9, tarGzBuffer, keepCount = 3) {
|
|
|
405615
405633
|
const bundlesDir = resolve79(dataDir, "bundles");
|
|
405616
405634
|
mkdirSync12(bundlesDir, { recursive: true, mode: 448 });
|
|
405617
405635
|
const bundlePath = resolve79(bundlesDir, `${hash9}.tar.gz`);
|
|
405618
|
-
if (!
|
|
405636
|
+
if (!existsSync42(bundlePath)) {
|
|
405619
405637
|
writeFileSync10(bundlePath, tarGzBuffer, { mode: 384 });
|
|
405620
405638
|
}
|
|
405621
405639
|
chmodSync3(bundlePath, 384);
|
|
@@ -405646,7 +405664,7 @@ var init_provisioner_bundles = __esm({
|
|
|
405646
405664
|
});
|
|
405647
405665
|
|
|
405648
405666
|
// ../platform/src/provisioner-app-runtime.ts
|
|
405649
|
-
import { existsSync as
|
|
405667
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync13 } from "fs";
|
|
405650
405668
|
import { resolve as resolve80 } from "path";
|
|
405651
405669
|
async function measureWakeStage(timing, stage, operation) {
|
|
405652
405670
|
return timing ? timing.measure(stage, operation) : operation();
|
|
@@ -405662,7 +405680,7 @@ function ensureAppRuntimeDirectories(dataDir) {
|
|
|
405662
405680
|
function hasCronDefinitions(dataDir) {
|
|
405663
405681
|
const cronsTs = resolve80(dataDir, "gencow", "crons.ts");
|
|
405664
405682
|
const cronsJs = resolve80(dataDir, "gencow", "crons.js");
|
|
405665
|
-
return
|
|
405683
|
+
return existsSync43(cronsTs) || existsSync43(cronsJs);
|
|
405666
405684
|
}
|
|
405667
405685
|
function collectRunnerCrashLogs(runner2, appName, maxLines = 20, appInstanceId) {
|
|
405668
405686
|
try {
|
|
@@ -406077,7 +406095,7 @@ var init_provisioner_blue_green = __esm({
|
|
|
406077
406095
|
|
|
406078
406096
|
// ../platform/src/provisioner-deploy-runtime.ts
|
|
406079
406097
|
import { createHash as createHash54 } from "crypto";
|
|
406080
|
-
import { existsSync as
|
|
406098
|
+
import { existsSync as existsSync44, readFileSync as readFileSync42 } from "fs";
|
|
406081
406099
|
import { resolve as resolve81 } from "path";
|
|
406082
406100
|
async function assertDeployBundlePreflight(tarGzBuffer) {
|
|
406083
406101
|
await assertDeployDependencyCompatibilityFromBundle(tarGzBuffer);
|
|
@@ -406178,17 +406196,17 @@ async function applyLinuxBundlePermissions(appName, dataDir, logger3) {
|
|
|
406178
406196
|
}
|
|
406179
406197
|
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
406180
406198
|
try {
|
|
406181
|
-
const readOnlyTargets = [`${dataDir}/gencow`, `${dataDir}/node_modules`].filter(
|
|
406199
|
+
const readOnlyTargets = [`${dataDir}/gencow`, `${dataDir}/node_modules`].filter(existsSync44);
|
|
406182
406200
|
if (readOnlyTargets.length > 0) {
|
|
406183
406201
|
execFileSync2("chmod", ["-R", "755", ...readOnlyTargets], { stdio: "ignore" });
|
|
406184
406202
|
}
|
|
406185
|
-
if (
|
|
406203
|
+
if (existsSync44(`${dataDir}/gencow-bc`)) {
|
|
406186
406204
|
try {
|
|
406187
406205
|
execFileSync2("chmod", ["-R", "755", `${dataDir}/gencow-bc`], { stdio: "ignore" });
|
|
406188
406206
|
} catch {
|
|
406189
406207
|
}
|
|
406190
406208
|
}
|
|
406191
|
-
const writableTargets = [`${dataDir}/uploads`, `${dataDir}/data`].filter(
|
|
406209
|
+
const writableTargets = [`${dataDir}/uploads`, `${dataDir}/data`].filter(existsSync44);
|
|
406192
406210
|
if (writableTargets.length > 0) {
|
|
406193
406211
|
try {
|
|
406194
406212
|
execFileSync2("chown", ["-R", "65534:65534", ...writableTargets], { stdio: "ignore" });
|
|
@@ -406221,7 +406239,7 @@ async function deployBundleRuntime(params) {
|
|
|
406221
406239
|
try {
|
|
406222
406240
|
await applyLinuxBundlePermissions(params.appName, stagedBundle.path, logger3);
|
|
406223
406241
|
assertCronManifestReadyForDeploy(stagedBundle.path);
|
|
406224
|
-
const manifest =
|
|
406242
|
+
const manifest = existsSync44(resolve81(stagedBundle.path, MIGRATION_BUNDLE_MANIFEST_PATH)) ? assertDeploymentMigrationBundleManifest(stagedBundle.path, params.migrationCliVersion) : null;
|
|
406225
406243
|
await params.pushAppSchema(params.appName, stagedBundle.path, {
|
|
406226
406244
|
verifiedSchemaSources: manifest?.schemaSources
|
|
406227
406245
|
});
|
|
@@ -406320,7 +406338,7 @@ async function deployBundleRuntime(params) {
|
|
|
406320
406338
|
async function rollbackBundleRuntime(params) {
|
|
406321
406339
|
const logger3 = params.logger ?? console;
|
|
406322
406340
|
const bundlePath = resolve81(params.dataDir, "bundles", `${params.bundleHash}.tar.gz`);
|
|
406323
|
-
if (!
|
|
406341
|
+
if (!existsSync44(bundlePath)) {
|
|
406324
406342
|
throw new Error(`Bundle ${params.bundleHash.slice(0, 8)} not found on disk`);
|
|
406325
406343
|
}
|
|
406326
406344
|
const tarGzBuffer = readFileSync42(bundlePath);
|
|
@@ -406587,7 +406605,7 @@ var init_platform_system_sql = __esm({
|
|
|
406587
406605
|
|
|
406588
406606
|
// ../platform/src/provisioner-env-builder.ts
|
|
406589
406607
|
import { createHash as createHash55 } from "crypto";
|
|
406590
|
-
import { existsSync as
|
|
406608
|
+
import { existsSync as existsSync45, readFileSync as readFileSync43 } from "fs";
|
|
406591
406609
|
import { resolve as resolve82 } from "path";
|
|
406592
406610
|
function addManagedPublicOrigin(origins, origin) {
|
|
406593
406611
|
const raw2 = origin?.trim();
|
|
@@ -406685,7 +406703,7 @@ function removeWakeSignalReservedTenantEnvVars(params) {
|
|
|
406685
406703
|
}
|
|
406686
406704
|
function readCronManifestDeployId(dataDir) {
|
|
406687
406705
|
const manifestPath = resolve82(dataDir, CRON_MANIFEST_RELATIVE_PATH2);
|
|
406688
|
-
if (!
|
|
406706
|
+
if (!existsSync45(manifestPath)) return void 0;
|
|
406689
406707
|
try {
|
|
406690
406708
|
const parsed = JSON.parse(readFileSync43(manifestPath, "utf8"));
|
|
406691
406709
|
return parsed.version === 2 && typeof parsed.deployId === "string" && parsed.deployId.trim() ? parsed.deployId.trim() : void 0;
|
|
@@ -406694,7 +406712,7 @@ function readCronManifestDeployId(dataDir) {
|
|
|
406694
406712
|
}
|
|
406695
406713
|
}
|
|
406696
406714
|
function isCapacitySmokeRuntime(dataDir) {
|
|
406697
|
-
return
|
|
406715
|
+
return existsSync45(resolve82(dataDir, CAPACITY_SMOKE_RUNTIME_MARKER));
|
|
406698
406716
|
}
|
|
406699
406717
|
async function buildProvisionerAppEnv(params) {
|
|
406700
406718
|
const logger3 = params.logger ?? console;
|
|
@@ -407333,7 +407351,7 @@ var init_env_crypto = __esm({
|
|
|
407333
407351
|
});
|
|
407334
407352
|
|
|
407335
407353
|
// ../platform/src/provisioner-env-runtime.ts
|
|
407336
|
-
import { chownSync, existsSync as
|
|
407354
|
+
import { chownSync, existsSync as existsSync46, writeFileSync as writeFileSync11 } from "fs";
|
|
407337
407355
|
import { resolve as resolve83 } from "path";
|
|
407338
407356
|
async function readTenantEnvRowsWithSystemRls(sql112, appDbId) {
|
|
407339
407357
|
return withPlatformSystemSqlTransaction(sql112, async (transaction) => {
|
|
@@ -407426,7 +407444,7 @@ async function syncEnvFile(params) {
|
|
|
407426
407444
|
(params.logger ?? console).log(`[provisioner] .env.runtime synced (${Object.keys(vars).length} var(s))`);
|
|
407427
407445
|
}
|
|
407428
407446
|
function hasWarmPoolBytecodeBundle(dataDir) {
|
|
407429
|
-
return
|
|
407447
|
+
return existsSync46(resolve83(dataDir, "gencow-bc", "index.js"));
|
|
407430
407448
|
}
|
|
407431
407449
|
function canUseWarmPoolDeployCandidate(params) {
|
|
407432
407450
|
return params.hasWarmPoolActive && params.hasBytecodeBundle && params.supportsDeployCandidates && params.hasAssignDeployCandidate && params.hasPromoteDeployCandidate && params.hasDiscardDeployCandidate;
|
|
@@ -407678,11 +407696,11 @@ var init_runtime_bom = __esm({
|
|
|
407678
407696
|
});
|
|
407679
407697
|
|
|
407680
407698
|
// ../platform/src/deployment-runtime-preparation.ts
|
|
407681
|
-
import { existsSync as
|
|
407699
|
+
import { existsSync as existsSync47, readFileSync as readFileSync44 } from "fs";
|
|
407682
407700
|
import { join as join20, resolve as resolve84 } from "path";
|
|
407683
407701
|
function inferPlatformRepoRoot(cwd = process.cwd()) {
|
|
407684
407702
|
const candidate = resolve84(cwd, "../..");
|
|
407685
|
-
return
|
|
407703
|
+
return existsSync47(join20(candidate, PLATFORM_RUNTIME_BUILD_SERVER_ENTRY)) ? candidate : cwd;
|
|
407686
407704
|
}
|
|
407687
407705
|
function runtimePublicationKey(params, baseDir) {
|
|
407688
407706
|
return JSON.stringify({
|
|
@@ -407700,7 +407718,7 @@ function runtimePublicationKey(params, baseDir) {
|
|
|
407700
407718
|
}
|
|
407701
407719
|
function readPublishedManagedRuntimeMetadata(publishedReleaseDir) {
|
|
407702
407720
|
const manifestPath = resolve84(publishedReleaseDir, "..", "runtime-manifest.json");
|
|
407703
|
-
if (!
|
|
407721
|
+
if (!existsSync47(manifestPath)) {
|
|
407704
407722
|
return {};
|
|
407705
407723
|
}
|
|
407706
407724
|
const manifest = parseDeploymentRuntimeManifest(readFileSync44(manifestPath, "utf-8"));
|
|
@@ -407775,7 +407793,7 @@ var init_deployment_runtime_preparation = __esm({
|
|
|
407775
407793
|
});
|
|
407776
407794
|
|
|
407777
407795
|
// ../platform/src/runtime-bom-catalog.ts
|
|
407778
|
-
import { existsSync as
|
|
407796
|
+
import { existsSync as existsSync48, readdirSync as readdirSync18, readFileSync as readFileSync45 } from "fs";
|
|
407779
407797
|
import { resolve as resolve85 } from "path";
|
|
407780
407798
|
function extractBomFromManifest(manifest, source = "platform") {
|
|
407781
407799
|
const partitioned = partitionReleaseOwnedPackages(
|
|
@@ -407942,7 +407960,7 @@ var init_app_dependency_installer = __esm({
|
|
|
407942
407960
|
|
|
407943
407961
|
// ../platform/src/provisioner-runtime-build.ts
|
|
407944
407962
|
import {
|
|
407945
|
-
existsSync as
|
|
407963
|
+
existsSync as existsSync49,
|
|
407946
407964
|
mkdirSync as mkdirSync14,
|
|
407947
407965
|
readFileSync as readFileSync46,
|
|
407948
407966
|
readdirSync as readdirSync19,
|
|
@@ -407955,7 +407973,7 @@ import { execSync } from "child_process";
|
|
|
407955
407973
|
import { dirname as dirname20, join as join21, resolve as resolve86 } from "path";
|
|
407956
407974
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
407957
407975
|
function bomFromManifestPath(manifestPath) {
|
|
407958
|
-
if (!
|
|
407976
|
+
if (!existsSync49(manifestPath)) return null;
|
|
407959
407977
|
try {
|
|
407960
407978
|
const manifest = parseDeploymentRuntimeManifest(readFileSync46(manifestPath, "utf-8"));
|
|
407961
407979
|
const bom = runtimeBomFromManifest(manifest);
|
|
@@ -407987,7 +408005,7 @@ function resolveBomForInstall(dataDir, options = {}) {
|
|
|
407987
408005
|
}
|
|
407988
408006
|
function readDeclaredManagedDependenciesFromAuditManifest(dataDir) {
|
|
407989
408007
|
const manifestPath = resolve86(dataDir, DEPLOY_DEPENDENCY_AUDIT_MANIFEST);
|
|
407990
|
-
if (!
|
|
408008
|
+
if (!existsSync49(manifestPath)) return null;
|
|
407991
408009
|
try {
|
|
407992
408010
|
const parsed = JSON.parse(readFileSync46(manifestPath, "utf-8"));
|
|
407993
408011
|
if (parsed.schemaVersion !== 1 || !parsed.dependencies || typeof parsed.dependencies !== "object") {
|
|
@@ -408047,7 +408065,7 @@ function dependencyRootName(name) {
|
|
|
408047
408065
|
function resolveManagedPublicPackageSet(dataDir, options) {
|
|
408048
408066
|
const generationManifestPath2 = options.runtimeRoot ? resolve86(options.runtimeRoot, "..", "runtime-manifest.json") : null;
|
|
408049
408067
|
const generationManifest = generationManifestPath2 ? readManagedRuntimeManifest(generationManifestPath2) : null;
|
|
408050
|
-
if (generationManifestPath2 &&
|
|
408068
|
+
if (generationManifestPath2 && existsSync49(generationManifestPath2) && !generationManifest) {
|
|
408051
408069
|
throw new Error("[runtime-layout] selective runtime generation manifest is invalid");
|
|
408052
408070
|
}
|
|
408053
408071
|
const runtimeManifest = readManagedRuntimeManifestForApp(dataDir) ?? generationManifest;
|
|
@@ -408076,7 +408094,7 @@ function collectUserDependencies(deps, options = {}) {
|
|
|
408076
408094
|
}
|
|
408077
408095
|
function findMissingAppOwnedDependencies(dataDir) {
|
|
408078
408096
|
const pkgPath = join21(dataDir, "package.json");
|
|
408079
|
-
if (!
|
|
408097
|
+
if (!existsSync49(pkgPath)) return [];
|
|
408080
408098
|
let pkg;
|
|
408081
408099
|
try {
|
|
408082
408100
|
pkg = JSON.parse(readFileSync46(pkgPath, "utf-8"));
|
|
@@ -408084,7 +408102,7 @@ function findMissingAppOwnedDependencies(dataDir) {
|
|
|
408084
408102
|
return [];
|
|
408085
408103
|
}
|
|
408086
408104
|
return Object.keys(collectUserDependencies(pkg.dependencies || {})).filter(
|
|
408087
|
-
(packageName) => !
|
|
408105
|
+
(packageName) => !existsSync49(join21(getAppOwnedNodeModulesPath(dataDir), ...packageName.split("/"), "package.json"))
|
|
408088
408106
|
);
|
|
408089
408107
|
}
|
|
408090
408108
|
async function ensureAppOwnedDependencies(appName, dataDir, options = {}) {
|
|
@@ -408150,11 +408168,11 @@ async function compileBytecode(appName, dataDir) {
|
|
|
408150
408168
|
const bcDir = resolve86(dataDir, "gencow-bc");
|
|
408151
408169
|
const entryFile = resolve86(gencowDir, "index.ts");
|
|
408152
408170
|
const authFile = resolve86(gencowDir, "auth.ts");
|
|
408153
|
-
if (!
|
|
408171
|
+
if (!existsSync49(entryFile)) {
|
|
408154
408172
|
console.log(`[provisioner] ${appName}: no index.ts \u2014 skipping bytecode compile`);
|
|
408155
408173
|
return false;
|
|
408156
408174
|
}
|
|
408157
|
-
if (
|
|
408175
|
+
if (existsSync49(authFile)) {
|
|
408158
408176
|
console.log(`[provisioner] ${appName}: auth.ts present \u2014 skipping bytecode compile`);
|
|
408159
408177
|
removeDirectoryIfExists(bcDir);
|
|
408160
408178
|
return false;
|
|
@@ -408172,7 +408190,7 @@ async function compileBytecode(appName, dataDir) {
|
|
|
408172
408190
|
);
|
|
408173
408191
|
const jsFile = resolve86(bcDir, "index.js");
|
|
408174
408192
|
const jscFile = resolve86(bcDir, "index.js.jsc");
|
|
408175
|
-
if (
|
|
408193
|
+
if (existsSync49(jsFile) && existsSync49(jscFile)) {
|
|
408176
408194
|
const jsSize = statSync12(jsFile).size;
|
|
408177
408195
|
if (jsSize < 10) {
|
|
408178
408196
|
console.warn(`[provisioner] ${appName}: bytecode bundle too small (${jsSize}B) \u2014 removing`);
|
|
@@ -408218,7 +408236,7 @@ async function installUserDependencies(appName, dataDir, repoRoot2 = resolve86(_
|
|
|
408218
408236
|
);
|
|
408219
408237
|
}
|
|
408220
408238
|
const pkgPath = join21(dataDir, "package.json");
|
|
408221
|
-
if (!
|
|
408239
|
+
if (!existsSync49(pkgPath)) {
|
|
408222
408240
|
composeManagedRuntimeNodeModules(dataDir, options.runtimeRoot || repoRoot2);
|
|
408223
408241
|
return;
|
|
408224
408242
|
}
|
|
@@ -408266,8 +408284,8 @@ async function installUserDependencies(appName, dataDir, repoRoot2 = resolve86(_
|
|
|
408266
408284
|
}
|
|
408267
408285
|
console.log(`[provisioner] ${appName}: installing ${depNames.length} user dep(s): ${depNames.join(", ")}`);
|
|
408268
408286
|
const sourceLockPath = join21(dataDir, "pnpm-lock.yaml");
|
|
408269
|
-
const lockfilelessLegacyInstall = options.allowLegacyLockfilelessInstall === true && !
|
|
408270
|
-
if (!
|
|
408287
|
+
const lockfilelessLegacyInstall = options.allowLegacyLockfilelessInstall === true && !existsSync49(sourceLockPath);
|
|
408288
|
+
if (!existsSync49(sourceLockPath) && !lockfilelessLegacyInstall) {
|
|
408271
408289
|
throw new AppDependencyInstallError("lock_missing");
|
|
408272
408290
|
}
|
|
408273
408291
|
writeFileSync12(userPkgPath, `${JSON.stringify(buildUserDependencyInstallManifest(userDeps), null, 2)}
|
|
@@ -408313,7 +408331,7 @@ async function installUserDependencies(appName, dataDir, repoRoot2 = resolve86(_
|
|
|
408313
408331
|
`[provisioner] ${appName}: pruned staged platform dep(s): ${prunedStagedDeps.map((finding) => finding.packageName).join(", ")}`
|
|
408314
408332
|
);
|
|
408315
408333
|
}
|
|
408316
|
-
if (!
|
|
408334
|
+
if (!existsSync49(appOwnedNodeModulesPath)) {
|
|
408317
408335
|
composeManagedRuntimeNodeModules(dataDir, options.runtimeRoot || repoRoot2);
|
|
408318
408336
|
return;
|
|
408319
408337
|
}
|
|
@@ -410713,9 +410731,9 @@ var init_provisioner_database_preflight = __esm({
|
|
|
410713
410731
|
});
|
|
410714
410732
|
|
|
410715
410733
|
// ../platform/src/provisioner-runtime-inspection.ts
|
|
410716
|
-
function runProcessInspection(command,
|
|
410734
|
+
function runProcessInspection(command, spawnSync2 = (args) => Bun.spawnSync(args)) {
|
|
410717
410735
|
try {
|
|
410718
|
-
return
|
|
410736
|
+
return spawnSync2(command);
|
|
410719
410737
|
} catch (error51) {
|
|
410720
410738
|
const rawCode = error51 && typeof error51 === "object" && typeof error51.code === "string" ? error51.code : "UNKNOWN";
|
|
410721
410739
|
const code = /^[A-Z0-9_]+$/u.test(rawCode) ? rawCode : "UNKNOWN";
|
|
@@ -410796,8 +410814,8 @@ function getListeningPortsByPid(pid) {
|
|
|
410796
410814
|
}
|
|
410797
410815
|
return parseListeningPorts(proc.stdout.toString());
|
|
410798
410816
|
}
|
|
410799
|
-
function getListeningPidsByPort(port,
|
|
410800
|
-
const proc = runProcessInspection(["lsof", "-ti", `:${port}`, "-sTCP:LISTEN"],
|
|
410817
|
+
function getListeningPidsByPort(port, spawnSync2) {
|
|
410818
|
+
const proc = runProcessInspection(["lsof", "-ti", `:${port}`, "-sTCP:LISTEN"], spawnSync2);
|
|
410801
410819
|
if (proc.exitCode !== 0) {
|
|
410802
410820
|
return [];
|
|
410803
410821
|
}
|
|
@@ -410878,8 +410896,8 @@ function normalizeRuntimePidCandidates(params) {
|
|
|
410878
410896
|
}
|
|
410879
410897
|
return [...candidates].sort((a, b2) => a - b2);
|
|
410880
410898
|
}
|
|
410881
|
-
function getManagedRuntimePids(appName, dataDir, trackedPids,
|
|
410882
|
-
const proc = runProcessInspection(["ps", "-eo", "pid=,ppid=,command="],
|
|
410899
|
+
function getManagedRuntimePids(appName, dataDir, trackedPids, spawnSync2) {
|
|
410900
|
+
const proc = runProcessInspection(["ps", "-eo", "pid=,ppid=,command="], spawnSync2);
|
|
410883
410901
|
if (proc.exitCode !== 0) {
|
|
410884
410902
|
return [];
|
|
410885
410903
|
}
|
|
@@ -411302,16 +411320,16 @@ var init_warm_pool_client = __esm({
|
|
|
411302
411320
|
|
|
411303
411321
|
// ../platform/src/warm-pool-manager.ts
|
|
411304
411322
|
import { spawn as spawn4 } from "child_process";
|
|
411305
|
-
import { existsSync as
|
|
411323
|
+
import { existsSync as existsSync50 } from "fs";
|
|
411306
411324
|
import { resolve as resolve92, dirname as dirname22 } from "path";
|
|
411307
411325
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
411308
411326
|
import { homedir as homedir4 } from "os";
|
|
411309
411327
|
function findBunBin3() {
|
|
411310
411328
|
const envBun = process.env.BUN_BIN;
|
|
411311
|
-
if (envBun &&
|
|
411312
|
-
if (
|
|
411329
|
+
if (envBun && existsSync50(envBun)) return envBun;
|
|
411330
|
+
if (existsSync50("/usr/local/bin/bun")) return "/usr/local/bin/bun";
|
|
411313
411331
|
const homeBun = resolve92(homedir4(), ".bun", "bin", "bun");
|
|
411314
|
-
if (
|
|
411332
|
+
if (existsSync50(homeBun)) return homeBun;
|
|
411315
411333
|
return "bun";
|
|
411316
411334
|
}
|
|
411317
411335
|
async function initWarmPool(size2) {
|
|
@@ -411661,7 +411679,7 @@ var init_warm_pool_manager = __esm({
|
|
|
411661
411679
|
COWBOX_BIN2 = process.env.COWBOX_BIN || "/usr/local/bin/cowbox";
|
|
411662
411680
|
MEMORY_MAX_DEFAULT2 = process.env.GENCOW_APP_MEMORY_MAX || "256M";
|
|
411663
411681
|
APP_PORT_RANGE = loadAppPortRange().spec;
|
|
411664
|
-
useCowbox2 = process.platform === "linux" &&
|
|
411682
|
+
useCowbox2 = process.platform === "linux" && existsSync50(COWBOX_BIN2);
|
|
411665
411683
|
workers = /* @__PURE__ */ new Map();
|
|
411666
411684
|
idleQueue = [];
|
|
411667
411685
|
assignedApps = /* @__PURE__ */ new Map();
|
|
@@ -412429,7 +412447,7 @@ var init_schema_deployment_decision = __esm({
|
|
|
412429
412447
|
});
|
|
412430
412448
|
|
|
412431
412449
|
// ../platform/src/provisioner-drizzle-tsconfig.ts
|
|
412432
|
-
import { existsSync as
|
|
412450
|
+
import { existsSync as existsSync51, readFileSync as readFileSync50, unlinkSync as unlinkSync8, writeFileSync as writeFileSync14 } from "fs";
|
|
412433
412451
|
import { resolve as resolve94 } from "path";
|
|
412434
412452
|
function isRecord7(value) {
|
|
412435
412453
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
@@ -412492,7 +412510,7 @@ import {
|
|
|
412492
412510
|
chmodSync as chmodSync5,
|
|
412493
412511
|
chownSync as chownSync2,
|
|
412494
412512
|
cpSync as cpSync2,
|
|
412495
|
-
existsSync as
|
|
412513
|
+
existsSync as existsSync52,
|
|
412496
412514
|
lstatSync as lstatSync10,
|
|
412497
412515
|
mkdirSync as mkdirSync17,
|
|
412498
412516
|
mkdtempSync as mkdtempSync7,
|
|
@@ -412546,7 +412564,7 @@ function assertRegularTree(directory) {
|
|
|
412546
412564
|
}
|
|
412547
412565
|
}
|
|
412548
412566
|
function makeTreeRemovable(path4) {
|
|
412549
|
-
if (!
|
|
412567
|
+
if (!existsSync52(path4)) return;
|
|
412550
412568
|
const stats = lstatSync10(path4);
|
|
412551
412569
|
if (!stats.isDirectory()) {
|
|
412552
412570
|
chmodSync5(path4, 384);
|
|
@@ -412569,7 +412587,7 @@ function resolveDrizzleKitEntry(repoRoot2) {
|
|
|
412569
412587
|
resolve95(repoRoot2, "packages/server/node_modules/drizzle-kit/bin.cjs"),
|
|
412570
412588
|
resolve95(repoRoot2, "node_modules/drizzle-kit/bin.cjs")
|
|
412571
412589
|
];
|
|
412572
|
-
const entry = candidates.find((candidate) =>
|
|
412590
|
+
const entry = candidates.find((candidate) => existsSync52(candidate));
|
|
412573
412591
|
if (!entry) throw new Error("drizzle-kit entry not found in platform node_modules");
|
|
412574
412592
|
return entry;
|
|
412575
412593
|
}
|
|
@@ -412581,7 +412599,7 @@ function resolveNodeBinary() {
|
|
|
412581
412599
|
"/usr/bin/node",
|
|
412582
412600
|
...pathCandidates
|
|
412583
412601
|
].filter((candidate) => !!candidate);
|
|
412584
|
-
const binary = candidates.find((candidate) =>
|
|
412602
|
+
const binary = candidates.find((candidate) => existsSync52(candidate) && lstatSync10(candidate).isFile());
|
|
412585
412603
|
if (!binary) throw new Error("node binary not found for canonical schema proof");
|
|
412586
412604
|
return binary;
|
|
412587
412605
|
}
|
|
@@ -412604,11 +412622,11 @@ function buildCanonicalDrizzleConfig(schemaPaths, outDir) {
|
|
|
412604
412622
|
].join("\n");
|
|
412605
412623
|
}
|
|
412606
412624
|
function findGeneratedSql(outDir) {
|
|
412607
|
-
if (!
|
|
412625
|
+
if (!existsSync52(outDir)) return "";
|
|
412608
412626
|
const sqlPath = readdirSync20(outDir).flatMap((entry) => {
|
|
412609
412627
|
if (entry.endsWith(".sql")) return [resolve95(outDir, entry)];
|
|
412610
412628
|
const nested = resolve95(outDir, entry, "migration.sql");
|
|
412611
|
-
return
|
|
412629
|
+
return existsSync52(nested) ? [nested] : [];
|
|
412612
412630
|
}).sort()[0];
|
|
412613
412631
|
return sqlPath ? readFileSync51(sqlPath, "utf8") : "";
|
|
412614
412632
|
}
|
|
@@ -412653,7 +412671,7 @@ function isolatedCommand(params) {
|
|
|
412653
412671
|
const drizzleArgs = [params.drizzleKitEntry, "generate", "--config", params.configPath];
|
|
412654
412672
|
if (process.platform === "linux") {
|
|
412655
412673
|
const cowbox = process.env.COWBOX_BIN || "/usr/local/bin/cowbox";
|
|
412656
|
-
if (!
|
|
412674
|
+
if (!existsSync52(cowbox)) throw new Error("canonical schema proof sandbox is unavailable");
|
|
412657
412675
|
const profilePath = resolveCowboxProfilePath("schemaProof");
|
|
412658
412676
|
const profileSource = readCowboxProfile("schemaProof", profilePath);
|
|
412659
412677
|
return {
|
|
@@ -412681,7 +412699,7 @@ function isolatedCommand(params) {
|
|
|
412681
412699
|
]
|
|
412682
412700
|
};
|
|
412683
412701
|
}
|
|
412684
|
-
if (process.platform === "darwin" &&
|
|
412702
|
+
if (process.platform === "darwin" && existsSync52("/usr/bin/sandbox-exec")) {
|
|
412685
412703
|
return {
|
|
412686
412704
|
command: "/usr/bin/sandbox-exec",
|
|
412687
412705
|
args: ["-p", sandboxExecProfile(params.outputRoot, params.tempRoot), params.nodeBinary, ...drizzleArgs]
|
|
@@ -412694,7 +412712,7 @@ async function generateCanonicalSchemaSql(params) {
|
|
|
412694
412712
|
const backendRoot = resolve95(dataDir, "gencow");
|
|
412695
412713
|
let relativeSources;
|
|
412696
412714
|
try {
|
|
412697
|
-
if (!
|
|
412715
|
+
if (!existsSync52(backendRoot)) throw new Error("backend source root is missing");
|
|
412698
412716
|
assertRegularTree(backendRoot);
|
|
412699
412717
|
relativeSources = params.schemaSourcePaths.map((sourcePath) => {
|
|
412700
412718
|
const absolute = resolve95(sourcePath);
|
|
@@ -412727,7 +412745,7 @@ async function generateCanonicalSchemaSql(params) {
|
|
|
412727
412745
|
const sourceTsconfig = resolve95(dataDir, "tsconfig.json");
|
|
412728
412746
|
writeFileSync15(
|
|
412729
412747
|
resolve95(proofRoot, "tsconfig.json"),
|
|
412730
|
-
buildDrizzleRuntimeTsconfig(
|
|
412748
|
+
buildDrizzleRuntimeTsconfig(existsSync52(sourceTsconfig) ? readFileSync51(sourceTsconfig, "utf8") : ""),
|
|
412731
412749
|
{ mode: 292 }
|
|
412732
412750
|
);
|
|
412733
412751
|
const stagedSources = relativeSources.map((sourcePath) => resolve95(stagedBackendRoot, sourcePath));
|
|
@@ -412808,12 +412826,12 @@ var init_canonical_schema_proof_runner = __esm({
|
|
|
412808
412826
|
|
|
412809
412827
|
// ../platform/src/workspace-schema-sources.ts
|
|
412810
412828
|
import { createHash as createHash62 } from "node:crypto";
|
|
412811
|
-
import { existsSync as
|
|
412829
|
+
import { existsSync as existsSync53, lstatSync as lstatSync11, readFileSync as readFileSync52 } from "node:fs";
|
|
412812
412830
|
import { relative as relative22, resolve as resolve96, sep as sep6 } from "node:path";
|
|
412813
412831
|
function declaresUnverifiableSchemaSource(dataDir) {
|
|
412814
412832
|
for (const filename of ["gencow.config.ts", "gencow.config.js"]) {
|
|
412815
412833
|
const configPath = resolve96(dataDir, filename);
|
|
412816
|
-
if (!
|
|
412834
|
+
if (!existsSync53(configPath) || !lstatSync11(configPath).isFile()) continue;
|
|
412817
412835
|
try {
|
|
412818
412836
|
if (/\bschema\s*:/u.test(readFileSync52(configPath, "utf8"))) return true;
|
|
412819
412837
|
} catch {
|
|
@@ -412833,7 +412851,7 @@ function resolveWorkspaceSchemaSourcePaths(params) {
|
|
|
412833
412851
|
const backendRoot = resolve96(params.dataDir, "gencow");
|
|
412834
412852
|
if (!params.verifiedSchemaSources) {
|
|
412835
412853
|
const legacySources = LEGACY_SCHEMA_SOURCE_PATHS.map((path4) => resolve96(backendRoot, path4)).filter(
|
|
412836
|
-
(path4) =>
|
|
412854
|
+
(path4) => existsSync53(path4)
|
|
412837
412855
|
);
|
|
412838
412856
|
if (legacySources.length === 0 && declaresUnverifiableSchemaSource(params.dataDir)) {
|
|
412839
412857
|
throw new Error("configured schema source requires a verified manifest");
|
|
@@ -412845,7 +412863,7 @@ function resolveWorkspaceSchemaSourcePaths(params) {
|
|
|
412845
412863
|
return params.verifiedSchemaSources.map((source) => {
|
|
412846
412864
|
const sourcePath = resolve96(backendRoot, source.path);
|
|
412847
412865
|
const folded = source.path.toLocaleLowerCase("en-US");
|
|
412848
|
-
if (seen.has(source.path) || caseFolded.has(folded) || !isWithin2(backendRoot, sourcePath) || !
|
|
412866
|
+
if (seen.has(source.path) || caseFolded.has(folded) || !isWithin2(backendRoot, sourcePath) || !existsSync53(sourcePath)) {
|
|
412849
412867
|
throw new Error("verified schema source contract is invalid");
|
|
412850
412868
|
}
|
|
412851
412869
|
const stats = lstatSync11(sourcePath);
|
|
@@ -412874,7 +412892,7 @@ var init_workspace_schema_sources = __esm({
|
|
|
412874
412892
|
});
|
|
412875
412893
|
|
|
412876
412894
|
// ../platform/src/provisioner-schema.ts
|
|
412877
|
-
import { existsSync as
|
|
412895
|
+
import { existsSync as existsSync54, readFileSync as readFileSync53, readdirSync as readdirSync21 } from "fs";
|
|
412878
412896
|
import { createHash as createHash63 } from "node:crypto";
|
|
412879
412897
|
import { basename as basename13, dirname as dirname24, resolve as resolve97 } from "path";
|
|
412880
412898
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
@@ -413492,14 +413510,14 @@ var init_app_runtime_events = __esm({
|
|
|
413492
413510
|
});
|
|
413493
413511
|
|
|
413494
413512
|
// ../platform/src/runtime-execution-source.ts
|
|
413495
|
-
import { existsSync as
|
|
413513
|
+
import { existsSync as existsSync55, realpathSync as realpathSync10 } from "fs";
|
|
413496
413514
|
import { relative as relative23, resolve as resolve98 } from "path";
|
|
413497
413515
|
function isWithinRoot2(root2, candidate) {
|
|
413498
413516
|
const relativePath = relative23(root2, candidate);
|
|
413499
413517
|
return relativePath === "" || !relativePath.startsWith("..") && !relativePath.startsWith("/");
|
|
413500
413518
|
}
|
|
413501
413519
|
function requireExistingPath(path4, label) {
|
|
413502
|
-
if (!
|
|
413520
|
+
if (!existsSync55(path4)) {
|
|
413503
413521
|
throw new RuntimeBootError("runtime_generation_incomplete", `${label} missing: ${path4}`);
|
|
413504
413522
|
}
|
|
413505
413523
|
return realpathSync10(path4);
|
|
@@ -413571,11 +413589,11 @@ var init_runtime_execution_source = __esm({
|
|
|
413571
413589
|
});
|
|
413572
413590
|
|
|
413573
413591
|
// ../platform/src/provisioner-verified-runtime-layout.ts
|
|
413574
|
-
import { existsSync as
|
|
413592
|
+
import { existsSync as existsSync56, mkdirSync as mkdirSync18, readFileSync as readFileSync54, rmSync as rmSync12 } from "fs";
|
|
413575
413593
|
function isPrepared(dataDir, source) {
|
|
413576
413594
|
if (!isManagedRuntimeNodeModules(dataDir)) return false;
|
|
413577
413595
|
if (!isManagedRuntimeReleaseLinked(dataDir, source.runtimeRoot)) return false;
|
|
413578
|
-
if (!
|
|
413596
|
+
if (!existsSync56(getManagedRuntimeReleaseManifestPath(dataDir))) return false;
|
|
413579
413597
|
try {
|
|
413580
413598
|
const manifest = JSON.parse(readFileSync54(getManagedRuntimeReleaseManifestPath(dataDir), "utf8"));
|
|
413581
413599
|
return manifest.releaseId === source.releaseId;
|
|
@@ -413657,7 +413675,7 @@ var init_provisioner_verified_runtime_layout = __esm({
|
|
|
413657
413675
|
|
|
413658
413676
|
// ../platform/src/legacy-runtime-dependency-evidence.ts
|
|
413659
413677
|
import { createHash as createHash64 } from "node:crypto";
|
|
413660
|
-
import { existsSync as
|
|
413678
|
+
import { existsSync as existsSync57, lstatSync as lstatSync12, readFileSync as readFileSync55, realpathSync as realpathSync11, statSync as statSync13 } from "node:fs";
|
|
413661
413679
|
import { join as join23, resolve as resolve99, sep as sep7 } from "node:path";
|
|
413662
413680
|
function sha25611(value) {
|
|
413663
413681
|
return `sha256:${createHash64("sha256").update(value).digest("hex")}`;
|
|
@@ -413712,7 +413730,7 @@ function buildLegacyRuntimeDependencyEvidence(dataDir) {
|
|
|
413712
413730
|
const packageJson = parsePackageJson(packageBytes);
|
|
413713
413731
|
const dependencies = dependencyMap(packageJson?.dependencies);
|
|
413714
413732
|
if (!packageJson || !dependencies) return null;
|
|
413715
|
-
const presentLockfiles = LOCKFILE_NAMES.filter((name) =>
|
|
413733
|
+
const presentLockfiles = LOCKFILE_NAMES.filter((name) => existsSync57(join23(dataDir, name)));
|
|
413716
413734
|
if (presentLockfiles.length > 1) return null;
|
|
413717
413735
|
const lockfileName = presentLockfiles[0] ?? null;
|
|
413718
413736
|
const lockfileBytes = lockfileName ? readBoundedRegularFile(join23(dataDir, lockfileName), MAX_LOCKFILE_BYTES) : null;
|
|
@@ -413778,7 +413796,7 @@ var init_runtime_legacy_policy = __esm({
|
|
|
413778
413796
|
});
|
|
413779
413797
|
|
|
413780
413798
|
// ../platform/src/legacy-runtime-preparation.ts
|
|
413781
|
-
import { existsSync as
|
|
413799
|
+
import { existsSync as existsSync58 } from "fs";
|
|
413782
413800
|
function inspectLegacyRuntimePreparation(params, dependencies = DEFAULT_INSPECTION_DEPENDENCIES) {
|
|
413783
413801
|
const metadata = dependencies.readMetadata(params.dataDir);
|
|
413784
413802
|
if (!metadata) return { kind: "preparation-required", reason: "metadata_missing" };
|
|
@@ -413874,7 +413892,7 @@ var init_legacy_runtime_preparation = __esm({
|
|
|
413874
413892
|
resolveGeneration: resolvePublishedRuntimeGenerationRef,
|
|
413875
413893
|
isReleaseLinked: isManagedRuntimeReleaseLinked,
|
|
413876
413894
|
isNodeModulesLinked: isManagedRuntimeNodeModules,
|
|
413877
|
-
releaseManifestExists:
|
|
413895
|
+
releaseManifestExists: existsSync58,
|
|
413878
413896
|
buildDependencyEvidence: buildLegacyRuntimeDependencyEvidence
|
|
413879
413897
|
};
|
|
413880
413898
|
}
|
|
@@ -419205,10 +419223,10 @@ function calcExpiresAt(retentionDays, now = /* @__PURE__ */ new Date()) {
|
|
|
419205
419223
|
}
|
|
419206
419224
|
function resolvePgBin() {
|
|
419207
419225
|
if (resolvedPgBin) return resolvedPgBin;
|
|
419208
|
-
const { existsSync:
|
|
419226
|
+
const { existsSync: existsSync60 } = __require("fs");
|
|
419209
419227
|
const { execSync: execSync2 } = __require("child_process");
|
|
419210
419228
|
for (const candidate of PG_BIN_CANDIDATES) {
|
|
419211
|
-
if (
|
|
419229
|
+
if (existsSync60(`${candidate}/pg_dump`)) {
|
|
419212
419230
|
resolvedPgBin = candidate;
|
|
419213
419231
|
console.log(`[backup] pg_dump found at ${candidate}/pg_dump`);
|
|
419214
419232
|
return resolvedPgBin;
|
|
@@ -433776,7 +433794,7 @@ var logger = (fn2 = console.log) => {
|
|
|
433776
433794
|
};
|
|
433777
433795
|
|
|
433778
433796
|
// ../server/dist/index.js
|
|
433779
|
-
import { existsSync as
|
|
433797
|
+
import { existsSync as existsSync59, readFileSync as readFileSync57 } from "fs";
|
|
433780
433798
|
import { resolve as resolve115 } from "path";
|
|
433781
433799
|
|
|
433782
433800
|
// ../server/dist/database.js
|
|
@@ -445725,10 +445743,10 @@ function createAdminRoutes(db, rawSql, driver, getCtx, storage, functionsPath, o
|
|
|
445725
445743
|
if (info2.crons.length === 0 && functionsPath) {
|
|
445726
445744
|
try {
|
|
445727
445745
|
const { resolve: resolve116 } = await import("path");
|
|
445728
|
-
const { existsSync:
|
|
445746
|
+
const { existsSync: existsSync60 } = await import("fs");
|
|
445729
445747
|
const cronsPath = resolve116(functionsPath, "crons.ts");
|
|
445730
445748
|
const cronsPathJs = resolve116(functionsPath, "crons.js");
|
|
445731
|
-
const cronsFile =
|
|
445749
|
+
const cronsFile = existsSync60(cronsPath) ? cronsPath : existsSync60(cronsPathJs) ? cronsPathJs : null;
|
|
445732
445750
|
if (cronsFile) {
|
|
445733
445751
|
const cronsModule = await import(cronsFile);
|
|
445734
445752
|
const cronsBuilder = cronsModule.default;
|
|
@@ -461749,7 +461767,7 @@ async function main() {
|
|
|
461749
461767
|
isWarmWorker,
|
|
461750
461768
|
logger: console,
|
|
461751
461769
|
env: process.env,
|
|
461752
|
-
existsSyncImpl:
|
|
461770
|
+
existsSyncImpl: existsSync59,
|
|
461753
461771
|
readFileSyncImpl: readFileSync57,
|
|
461754
461772
|
parseRuntimeEnvContentImpl: parseRuntimeEnvContent,
|
|
461755
461773
|
applyRuntimeEnvSnapshotImpl: applyRuntimeEnvSnapshot
|