@patodo/localapp 0.2.6 → 0.2.8

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.
Files changed (64) hide show
  1. package/.localapp-artifact.json +80 -80
  2. package/bin/localapp.mjs +539 -489
  3. package/package.json +1 -1
  4. package/runtime/native/adapter-manifest.json +1 -1
  5. package/runtime/native/win32-x64/localapp-native.exe +0 -0
  6. package/runtime/server/.localapp-server-runtime.json +57 -57
  7. package/runtime/server/bin/worker.cjs +325 -316
  8. package/runtime/server/web/404.html +1 -1
  9. package/runtime/server/web/inbox.html +1 -1
  10. package/runtime/server/web/inbox.txt +1 -1
  11. package/runtime/server/web/index.html +1 -1
  12. package/runtime/server/web/index.txt +1 -1
  13. package/runtime/server/web/my/analytics.html +1 -1
  14. package/runtime/server/web/my/analytics.txt +1 -1
  15. package/runtime/server/web/my/apps/placeholder/settings.html +1 -1
  16. package/runtime/server/web/my/apps/placeholder/settings.txt +1 -1
  17. package/runtime/server/web/my/apps.html +1 -1
  18. package/runtime/server/web/my/apps.txt +1 -1
  19. package/runtime/server/web/my/dashboard.html +1 -1
  20. package/runtime/server/web/my/dashboard.txt +1 -1
  21. package/runtime/server/web/my/device-actions.html +1 -1
  22. package/runtime/server/web/my/device-actions.txt +1 -1
  23. package/runtime/server/web/my/device-notifications.html +1 -1
  24. package/runtime/server/web/my/device-notifications.txt +1 -1
  25. package/runtime/server/web/my/favorites.html +1 -1
  26. package/runtime/server/web/my/favorites.txt +1 -1
  27. package/runtime/server/web/my/groups.html +1 -1
  28. package/runtime/server/web/my/groups.txt +1 -1
  29. package/runtime/server/web/my/info.html +1 -1
  30. package/runtime/server/web/my/info.txt +1 -1
  31. package/runtime/server/web/my/keys.html +1 -1
  32. package/runtime/server/web/my/keys.txt +1 -1
  33. package/runtime/server/web/my/orgs.html +1 -1
  34. package/runtime/server/web/my/orgs.txt +1 -1
  35. package/runtime/server/web/my/pages.html +1 -1
  36. package/runtime/server/web/my/pages.txt +1 -1
  37. package/runtime/server/web/my/peers.html +1 -1
  38. package/runtime/server/web/my/peers.txt +1 -1
  39. package/runtime/server/web/my/recent.html +1 -1
  40. package/runtime/server/web/my/recent.txt +1 -1
  41. package/runtime/server/web/my/settings.html +1 -1
  42. package/runtime/server/web/my/settings.txt +1 -1
  43. package/runtime/server/web/my/studio.html +1 -1
  44. package/runtime/server/web/my/studio.txt +1 -1
  45. package/runtime/server/web/my/subscriptions.html +1 -1
  46. package/runtime/server/web/my/subscriptions.txt +1 -1
  47. package/runtime/server/web/my/system.html +1 -1
  48. package/runtime/server/web/my/system.txt +1 -1
  49. package/runtime/server/web/my/tasks.html +1 -1
  50. package/runtime/server/web/my/tasks.txt +1 -1
  51. package/runtime/server/web/my/users.html +1 -1
  52. package/runtime/server/web/my/users.txt +1 -1
  53. package/runtime/server/web/my.html +1 -1
  54. package/runtime/server/web/my.txt +1 -1
  55. package/runtime/server/web/platform-shell/placeholder/placeholder.html +1 -1
  56. package/runtime/server/web/platform-shell/placeholder/placeholder.txt +1 -1
  57. package/runtime/server/web/platform-shell-preview.html +1 -1
  58. package/runtime/server/web/platform-shell-preview.txt +1 -1
  59. package/runtime/server/web/setup.html +1 -1
  60. package/runtime/server/web/setup.txt +1 -1
  61. package/template/runtime/version.json +1 -1
  62. package/template/tests/dev-shell-template.test.ts +4 -1
  63. /package/runtime/server/web/_next/static/{qBns-ZRUDtxsd4XX5SLLK → 53tcXasdrXUY226RhYFJX}/_buildManifest.js +0 -0
  64. /package/runtime/server/web/_next/static/{qBns-ZRUDtxsd4XX5SLLK → 53tcXasdrXUY226RhYFJX}/_ssgManifest.js +0 -0
package/bin/localapp.mjs CHANGED
@@ -98,7 +98,7 @@ var require_pend = __commonJS({
98
98
  // node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/fd-slicer.js
99
99
  var require_fd_slicer = __commonJS({
100
100
  "node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/fd-slicer.js"(exports) {
101
- var fs30 = __require("fs");
101
+ var fs31 = __require("fs");
102
102
  var util3 = __require("util");
103
103
  var stream = __require("stream");
104
104
  var Readable2 = stream.Readable;
@@ -118,7 +118,7 @@ var require_fd_slicer = __commonJS({
118
118
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
119
119
  var self2 = this;
120
120
  self2.pend.go(function(cb) {
121
- fs30.read(self2.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
121
+ fs31.read(self2.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
122
122
  cb();
123
123
  callback(err, bytesRead, buffer2);
124
124
  });
@@ -135,7 +135,7 @@ var require_fd_slicer = __commonJS({
135
135
  self2.refCount -= 1;
136
136
  if (self2.refCount < 0) throw new Error("invalid unref");
137
137
  if (self2.refCount > 0) return;
138
- fs30.close(self2.fd, onCloseDone);
138
+ fs31.close(self2.fd, onCloseDone);
139
139
  function onCloseDone(err) {
140
140
  if (err) {
141
141
  self2.emit("error", err);
@@ -167,7 +167,7 @@ var require_fd_slicer = __commonJS({
167
167
  }
168
168
  self2.context.pend.go(function(cb) {
169
169
  var buffer = Buffer.allocUnsafe(toRead);
170
- fs30.read(self2.context.fd, buffer, 0, toRead, self2.pos, function(err, bytesRead) {
170
+ fs31.read(self2.context.fd, buffer, 0, toRead, self2.pos, function(err, bytesRead) {
171
171
  if (err) {
172
172
  self2.destroy(err);
173
173
  } else if (bytesRead === 0) {
@@ -527,7 +527,7 @@ var require_crc32 = __commonJS({
527
527
  // node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/index.js
528
528
  var require_yauzl = __commonJS({
529
529
  "node_modules/.pnpm/yauzl@3.4.0/node_modules/yauzl/index.js"(exports) {
530
- var fs30 = __require("fs");
530
+ var fs31 = __require("fs");
531
531
  var zlib2 = __require("zlib");
532
532
  var fd_slicer = require_fd_slicer();
533
533
  var util3 = __require("util");
@@ -552,9 +552,9 @@ var require_yauzl = __commonJS({
552
552
  exports.Entry = Entry;
553
553
  exports.LocalFileHeader = LocalFileHeader;
554
554
  exports.RandomAccessReader = RandomAccessReader;
555
- function openPromise(path35, options2) {
555
+ function openPromise(path36, options2) {
556
556
  return new Promise((resolve2, reject) => {
557
- open2(path35, { ...options2, lazyEntries: true }, function(err, zipfile) {
557
+ open2(path36, { ...options2, lazyEntries: true }, function(err, zipfile) {
558
558
  if (err) return reject(err);
559
559
  resolve2(zipfile);
560
560
  });
@@ -584,7 +584,7 @@ var require_yauzl = __commonJS({
584
584
  });
585
585
  });
586
586
  }
587
- function open2(path35, options2, callback) {
587
+ function open2(path36, options2, callback) {
588
588
  if (typeof options2 === "function") {
589
589
  callback = options2;
590
590
  options2 = null;
@@ -596,10 +596,10 @@ var require_yauzl = __commonJS({
596
596
  if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
597
597
  if (options2.strictFileNames == null) options2.strictFileNames = false;
598
598
  if (callback == null) callback = defaultCallback;
599
- fs30.open(path35, "r", function(err, fd) {
599
+ fs31.open(path36, "r", function(err, fd) {
600
600
  if (err) return callback(err);
601
601
  fromFd(fd, options2, function(err2, zipfile) {
602
- if (err2) fs30.close(fd, defaultCallback);
602
+ if (err2) fs31.close(fd, defaultCallback);
603
603
  callback(err2, zipfile);
604
604
  });
605
605
  });
@@ -616,7 +616,7 @@ var require_yauzl = __commonJS({
616
616
  if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
617
617
  if (options2.strictFileNames == null) options2.strictFileNames = false;
618
618
  if (callback == null) callback = defaultCallback;
619
- fs30.fstat(fd, function(err, stats) {
619
+ fs31.fstat(fd, function(err, stats) {
620
620
  if (err) return callback(err);
621
621
  var reader = new fd_slicer.FdSlicer(fd);
622
622
  fromRandomAccessReader(reader, stats.size, options2, callback);
@@ -2423,7 +2423,7 @@ var init_escape = __esm({
2423
2423
  });
2424
2424
 
2425
2425
  // node_modules/.pnpm/minimatch@10.2.5/node_modules/minimatch/dist/esm/index.js
2426
- var minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path9, sep, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
2426
+ var minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path10, sep, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
2427
2427
  var init_esm3 = __esm({
2428
2428
  "node_modules/.pnpm/minimatch@10.2.5/node_modules/minimatch/dist/esm/index.js"() {
2429
2429
  init_esm2();
@@ -2492,11 +2492,11 @@ var init_esm3 = __esm({
2492
2492
  return (f) => f.length === len && f !== "." && f !== "..";
2493
2493
  };
2494
2494
  defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
2495
- path9 = {
2495
+ path10 = {
2496
2496
  win32: { sep: "\\" },
2497
2497
  posix: { sep: "/" }
2498
2498
  };
2499
- sep = defaultPlatform === "win32" ? path9.win32.sep : path9.posix.sep;
2499
+ sep = defaultPlatform === "win32" ? path10.win32.sep : path10.posix.sep;
2500
2500
  minimatch.sep = sep;
2501
2501
  GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
2502
2502
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -3245,12 +3245,12 @@ var init_esm3 = __esm({
3245
3245
  });
3246
3246
 
3247
3247
  // node_modules/.pnpm/readdir-glob@3.0.0/node_modules/readdir-glob/dist/index.mjs
3248
- import * as fs7 from "fs";
3248
+ import * as fs8 from "fs";
3249
3249
  import { EventEmitter } from "events";
3250
3250
  import { resolve } from "path";
3251
3251
  function readdir2(dir, strict) {
3252
3252
  return new Promise((resolve$1, reject) => {
3253
- fs7.readdir(dir, { withFileTypes: true }, (err, files) => {
3253
+ fs8.readdir(dir, { withFileTypes: true }, (err, files) => {
3254
3254
  if (err) switch (err.code) {
3255
3255
  case "ENOTDIR":
3256
3256
  if (strict) reject(err);
@@ -3273,7 +3273,7 @@ function readdir2(dir, strict) {
3273
3273
  }
3274
3274
  function getStat(file, followSymlinks) {
3275
3275
  return new Promise((resolve$1) => {
3276
- const statFunc = followSymlinks ? fs7.stat : fs7.lstat;
3276
+ const statFunc = followSymlinks ? fs8.stat : fs8.lstat;
3277
3277
  statFunc(file, (err, stats) => {
3278
3278
  if (err) switch (err.code) {
3279
3279
  case "ENOENT":
@@ -3288,13 +3288,13 @@ function getStat(file, followSymlinks) {
3288
3288
  });
3289
3289
  });
3290
3290
  }
3291
- async function* exploreWalkAsync(dir, path35, followSymlinks, useStat, shouldSkip, strict) {
3292
- let files = await readdir2(path35 + dir, strict);
3291
+ async function* exploreWalkAsync(dir, path36, followSymlinks, useStat, shouldSkip, strict) {
3292
+ let files = await readdir2(path36 + dir, strict);
3293
3293
  for (const file of files) {
3294
3294
  let name = file.name;
3295
3295
  const filename = dir + "/" + name;
3296
3296
  const relative = filename.slice(1);
3297
- const absolute = path35 + "/" + relative;
3297
+ const absolute = path36 + "/" + relative;
3298
3298
  let stat2 = file;
3299
3299
  if (useStat || followSymlinks) stat2 = await getStat(absolute, followSymlinks) ?? stat2;
3300
3300
  if (stat2.isDirectory()) {
@@ -3304,7 +3304,7 @@ async function* exploreWalkAsync(dir, path35, followSymlinks, useStat, shouldSki
3304
3304
  absolute,
3305
3305
  stat: stat2
3306
3306
  };
3307
- yield* exploreWalkAsync(filename, path35, followSymlinks, useStat, shouldSkip, false);
3307
+ yield* exploreWalkAsync(filename, path36, followSymlinks, useStat, shouldSkip, false);
3308
3308
  }
3309
3309
  } else yield {
3310
3310
  relative,
@@ -3313,8 +3313,8 @@ async function* exploreWalkAsync(dir, path35, followSymlinks, useStat, shouldSki
3313
3313
  };
3314
3314
  }
3315
3315
  }
3316
- async function* explore(path35, followSymlinks, useStat, shouldSkip) {
3317
- yield* exploreWalkAsync("", path35, followSymlinks, useStat, shouldSkip, true);
3316
+ async function* explore(path36, followSymlinks, useStat, shouldSkip) {
3317
+ yield* exploreWalkAsync("", path36, followSymlinks, useStat, shouldSkip, true);
3318
3318
  }
3319
3319
  function readOptions(options2) {
3320
3320
  return {
@@ -13799,22 +13799,22 @@ var require_ours = __commonJS({
13799
13799
  // node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js
13800
13800
  var require_normalize_path = __commonJS({
13801
13801
  "node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js"(exports, module) {
13802
- module.exports = function(path35, stripTrailing) {
13803
- if (typeof path35 !== "string") {
13802
+ module.exports = function(path36, stripTrailing) {
13803
+ if (typeof path36 !== "string") {
13804
13804
  throw new TypeError("expected path to be a string");
13805
13805
  }
13806
- if (path35 === "\\" || path35 === "/") return "/";
13807
- var len = path35.length;
13808
- if (len <= 1) return path35;
13806
+ if (path36 === "\\" || path36 === "/") return "/";
13807
+ var len = path36.length;
13808
+ if (len <= 1) return path36;
13809
13809
  var prefix = "";
13810
- if (len > 4 && path35[3] === "\\") {
13811
- var ch = path35[2];
13812
- if ((ch === "?" || ch === ".") && path35.slice(0, 2) === "\\\\") {
13813
- path35 = path35.slice(2);
13810
+ if (len > 4 && path36[3] === "\\") {
13811
+ var ch = path36[2];
13812
+ if ((ch === "?" || ch === ".") && path36.slice(0, 2) === "\\\\") {
13813
+ path36 = path36.slice(2);
13814
13814
  prefix = "//";
13815
13815
  }
13816
13816
  }
13817
- var segs = path35.split(/[/\\]+/);
13817
+ var segs = path36.split(/[/\\]+/);
13818
13818
  if (stripTrailing !== false && segs[segs.length - 1] === "") {
13819
13819
  segs.pop();
13820
13820
  }
@@ -19519,15 +19519,15 @@ var require_sql_wasm = __commonJS({
19519
19519
  "undefined" != typeof __filename ? ya = __filename : ba && (ya = self.location.href);
19520
19520
  var za = "", Aa, Ba;
19521
19521
  if (ca) {
19522
- var fs30 = __require("node:fs");
19522
+ var fs31 = __require("node:fs");
19523
19523
  za = __dirname + "/";
19524
19524
  Ba = (a) => {
19525
19525
  a = Ca(a) ? new URL(a) : a;
19526
- return fs30.readFileSync(a);
19526
+ return fs31.readFileSync(a);
19527
19527
  };
19528
19528
  Aa = async (a) => {
19529
19529
  a = Ca(a) ? new URL(a) : a;
19530
- return fs30.readFileSync(a, void 0);
19530
+ return fs31.readFileSync(a, void 0);
19531
19531
  };
19532
19532
  1 < process.argv.length && (wa = process.argv[1].replace(/\\/g, "/"));
19533
19533
  process.argv.slice(2);
@@ -19809,7 +19809,7 @@ var require_sql_wasm = __commonJS({
19809
19809
  if (ca) {
19810
19810
  var b = Buffer.alloc(256), c = 0, d = process.stdin.fd;
19811
19811
  try {
19812
- c = fs30.readSync(d, b, 0, 256);
19812
+ c = fs31.readSync(d, b, 0, 256);
19813
19813
  } catch (e) {
19814
19814
  if (e.toString().includes("EOF")) c = 0;
19815
19815
  else throw e;
@@ -25068,8 +25068,8 @@ Usage:
25068
25068
  localapp -V
25069
25069
  `]
25070
25070
  ]);
25071
- function resolveHelpTopic(path35) {
25072
- return TOPICS.get(path35.join(" "));
25071
+ function resolveHelpTopic(path36) {
25072
+ return TOPICS.get(path36.join(" "));
25073
25073
  }
25074
25074
  function renderHelp(topic) {
25075
25075
  const help2 = HELP.get(topic);
@@ -25569,9 +25569,9 @@ var LocalAppClient = class {
25569
25569
  this.setTimeout = dependencies.setTimeout ?? globalThis.setTimeout;
25570
25570
  this.clearTimeout = dependencies.clearTimeout ?? globalThis.clearTimeout;
25571
25571
  }
25572
- async requestJson(path35, options2 = {}) {
25572
+ async requestJson(path36, options2 = {}) {
25573
25573
  const body = options2.body === void 0 ? void 0 : JSON.stringify(options2.body);
25574
- return this.request(path35, {
25574
+ return this.request(path36, {
25575
25575
  method: options2.method ?? "GET",
25576
25576
  body,
25577
25577
  timeoutMs: options2.timeoutMs ?? 3e4,
@@ -25579,11 +25579,11 @@ var LocalAppClient = class {
25579
25579
  signal: options2.signal
25580
25580
  });
25581
25581
  }
25582
- async getJson(path35, timeoutMs = 3e4) {
25583
- return this.requestJson(path35, { method: "GET", timeoutMs });
25582
+ async getJson(path36, timeoutMs = 3e4) {
25583
+ return this.requestJson(path36, { method: "GET", timeoutMs });
25584
25584
  }
25585
- async postJson(path35, body, timeoutMs = 3e4) {
25586
- return this.requestJson(path35, { method: "POST", body, timeoutMs });
25585
+ async postJson(path36, body, timeoutMs = 3e4) {
25586
+ return this.requestJson(path36, { method: "POST", body, timeoutMs });
25587
25587
  }
25588
25588
  async installPackage(packagePath, signal) {
25589
25589
  const form = new FormData();
@@ -25596,8 +25596,8 @@ var LocalAppClient = class {
25596
25596
  async getSyncJob(id) {
25597
25597
  return this.getJson(`/api/sync-jobs/${encodeURIComponent(id)}`);
25598
25598
  }
25599
- async request(path35, options2) {
25600
- if (!path35.startsWith("/") || path35.startsWith("//")) return { ok: false, error: "Request path must be relative to the LocalApp Server" };
25599
+ async request(path36, options2) {
25600
+ if (!path36.startsWith("/") || path36.startsWith("//")) return { ok: false, error: "Request path must be relative to the LocalApp Server" };
25601
25601
  const controller = new AbortController();
25602
25602
  let timedOut = false;
25603
25603
  const timeout2 = this.setTimeout(() => {
@@ -25609,7 +25609,7 @@ var LocalAppClient = class {
25609
25609
  if (options2.signal?.aborted) onExternalAbort();
25610
25610
  try {
25611
25611
  const version = await loadPackageVersion();
25612
- const response = await fetch(`${this.serverUrl}${path35}`, {
25612
+ const response = await fetch(`${this.serverUrl}${path36}`, {
25613
25613
  method: options2.method,
25614
25614
  body: options2.body,
25615
25615
  headers: { "X-API-Key": this.apiKey, "X-CLI-Version": version, ...options2.headers },
@@ -25767,8 +25767,8 @@ function withoutApiKeys(value2) {
25767
25767
 
25768
25768
  // packages/localapp/src/commands/init.ts
25769
25769
  import { spawn } from "node:child_process";
25770
- import fs4 from "node:fs/promises";
25771
- import path6 from "node:path";
25770
+ import fs5 from "node:fs/promises";
25771
+ import path7 from "node:path";
25772
25772
  import { fileURLToPath as fileURLToPath2 } from "node:url";
25773
25773
 
25774
25774
  // packages/localapp/src/errors.ts
@@ -25805,33 +25805,83 @@ function isValidProjectName(name) {
25805
25805
  return /^[a-z][a-z0-9-]{1,61}[a-z0-9]$/.test(name) && !name.includes("--");
25806
25806
  }
25807
25807
 
25808
+ // packages/localapp/src/process/command-invocation.ts
25809
+ import fs2 from "node:fs";
25810
+ import path4 from "node:path";
25811
+ function resolveCommandInvocation(command, args, options2 = {}) {
25812
+ const platform = options2.platform ?? process.platform;
25813
+ const env = options2.env ?? process.env;
25814
+ if (platform !== "win32" || !isBareCommandName(command)) return { command, args: [...args] };
25815
+ const interpreter = options2.commandInterpreter ?? env.ComSpec ?? env.COMSPEC ?? defaultCommandInterpreter(env);
25816
+ return { command: interpreter, args: ["/d", "/s", "/c", command, ...args] };
25817
+ }
25818
+ function isBareCommandName(command) {
25819
+ if (command.includes("/") || command.includes("\\") || command.includes("\0")) return false;
25820
+ return command.length > 0;
25821
+ }
25822
+ function defaultCommandInterpreter(env) {
25823
+ const systemRoot = env.SystemRoot ?? env.SYSTEMROOT ?? "C:\\Windows";
25824
+ return path4.win32.join(systemRoot, "System32", "cmd.exe");
25825
+ }
25826
+ function resolveExecutablePath(command, options2 = {}) {
25827
+ const platform = options2.platform ?? process.platform;
25828
+ const env = options2.env ?? process.env;
25829
+ if (!isBareCommandName(command)) return void 0;
25830
+ const pathApi = platform === "win32" ? path4.win32 : path4.posix;
25831
+ const searchPath = env.PATH ?? env.Path ?? env.path ?? "";
25832
+ const extensions = platform === "win32" ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((entry) => entry.toLowerCase()) : [""];
25833
+ const names = platform === "win32" ? pathApi.extname(command) === "" ? extensions.map((extension2) => `${command}${extension2}`) : [command] : [command];
25834
+ const isFile2 = options2.isFile ?? ((candidate) => {
25835
+ try {
25836
+ return fs2.statSync(candidate).isFile();
25837
+ } catch {
25838
+ return false;
25839
+ }
25840
+ });
25841
+ for (const directory of searchPath.split(pathApi.delimiter)) {
25842
+ const trimmed = directory.trim();
25843
+ if (trimmed === "") continue;
25844
+ const unquoted = trimmed.length >= 2 && trimmed.startsWith('"') && trimmed.endsWith('"') ? trimmed.slice(1, -1) : trimmed;
25845
+ for (const name of names) {
25846
+ const candidate = pathApi.join(unquoted, name);
25847
+ if (isFile2(candidate)) return candidate;
25848
+ }
25849
+ }
25850
+ return void 0;
25851
+ }
25852
+ function resolveOwnedCommand(command, options2 = {}) {
25853
+ const platform = options2.platform ?? process.platform;
25854
+ if (platform !== "win32") return command;
25855
+ return resolveExecutablePath(command, options2) ?? command;
25856
+ }
25857
+
25808
25858
  // packages/localapp/src/project/safety.ts
25809
25859
  import crypto2 from "node:crypto";
25810
25860
  import { constants as constants2 } from "node:fs";
25811
- import fs2 from "node:fs/promises";
25812
- import path4 from "node:path";
25861
+ import fs3 from "node:fs/promises";
25862
+ import path5 from "node:path";
25813
25863
  var NOT_PROJECT_MESSAGE = "This directory is not a LocalApp project. Run the command from a project created by localapp init.";
25814
25864
  var UNSAFE_PATH_MESSAGE = "The LocalApp project contains a replaced, symlinked, or unsafe managed path. Restore real project directories before retrying.";
25815
25865
  async function verifyProjectBase(projectDirectory) {
25816
- const root = path4.resolve(projectDirectory);
25866
+ const root = path5.resolve(projectDirectory);
25817
25867
  const rootGuard = await captureDirectoryGuard(root, void 0, "not_localapp_project");
25818
- const localAppDirectory = path4.join(root, ".localapp");
25819
- const claudeDirectory = path4.join(root, ".claude");
25820
- const skillsDirectory = path4.join(claudeDirectory, "skills");
25821
- const sourceDirectory = path4.join(root, "src");
25868
+ const localAppDirectory = path5.join(root, ".localapp");
25869
+ const claudeDirectory = path5.join(root, ".claude");
25870
+ const skillsDirectory = path5.join(claudeDirectory, "skills");
25871
+ const sourceDirectory = path5.join(root, "src");
25822
25872
  const localAppGuard = await captureDirectoryGuard(localAppDirectory, rootGuard, "not_localapp_project");
25823
25873
  const claudeGuard = await captureDirectoryGuard(claudeDirectory, rootGuard, "not_localapp_project");
25824
25874
  const skillsGuard = await captureDirectoryGuard(skillsDirectory, claudeGuard, "not_localapp_project");
25825
25875
  const sourceGuard = await captureDirectoryGuard(sourceDirectory, rootGuard, "not_localapp_project");
25826
- const packagePath = path4.join(root, "package.json");
25827
- const configPath = path4.join(localAppDirectory, "project-config.json");
25828
- await requireProjectJson(path4.join(root, "manifest.json"), true, rootGuard);
25876
+ const packagePath = path5.join(root, "package.json");
25877
+ const configPath = path5.join(localAppDirectory, "project-config.json");
25878
+ await requireProjectJson(path5.join(root, "manifest.json"), true, rootGuard);
25829
25879
  await requireProjectJson(packagePath, false, rootGuard);
25830
- await requireProjectJson(path4.join(localAppDirectory, "dev-config.json"), false, localAppGuard);
25880
+ await requireProjectJson(path5.join(localAppDirectory, "dev-config.json"), false, localAppGuard);
25831
25881
  return {
25832
25882
  root,
25833
25883
  localAppDirectory,
25834
- runtimeDirectory: path4.join(localAppDirectory, "runtime"),
25884
+ runtimeDirectory: path5.join(localAppDirectory, "runtime"),
25835
25885
  claudeDirectory,
25836
25886
  skillsDirectory,
25837
25887
  sourceDirectory,
@@ -25850,19 +25900,19 @@ async function verifyManagedProject(project) {
25850
25900
  await captureDirectoryGuard(project.runtimeDirectory, project.localAppGuard, "not_localapp_project");
25851
25901
  await assertTreeHasNoSymlinks(project.runtimeDirectory);
25852
25902
  for (const name of await managedSkillNames(project.skillsDirectory, project.skillsGuard)) {
25853
- await assertTreeHasNoSymlinks(path4.join(project.skillsDirectory, name));
25903
+ await assertTreeHasNoSymlinks(path5.join(project.skillsDirectory, name));
25854
25904
  }
25855
25905
  }
25856
25906
  async function verifyInitParent(directory) {
25857
- const resolved = path4.resolve(directory);
25907
+ const resolved = path5.resolve(directory);
25858
25908
  await captureDirectoryGuard(resolved, void 0, "unsafe_project_path");
25859
25909
  return resolved;
25860
25910
  }
25861
25911
  async function captureDirectoryGuard(directory, parent, missingCode = "unsafe_project_path") {
25862
- const resolved = path4.resolve(directory);
25912
+ const resolved = path5.resolve(directory);
25863
25913
  if (parent !== void 0) {
25864
25914
  await verifyDirectoryGuard(parent);
25865
- if (path4.dirname(resolved) !== parent.directory) throw unsafePath();
25915
+ if (path5.dirname(resolved) !== parent.directory) throw unsafePath();
25866
25916
  }
25867
25917
  const stat2 = await lstatBigIntOptional(resolved);
25868
25918
  if (stat2 === void 0) {
@@ -25870,8 +25920,8 @@ async function captureDirectoryGuard(directory, parent, missingCode = "unsafe_pr
25870
25920
  throw unsafePath();
25871
25921
  }
25872
25922
  if (stat2.isSymbolicLink() || !stat2.isDirectory()) throw unsafePath();
25873
- const real = await fs2.realpath(resolved).catch(() => void 0);
25874
- if (real === void 0 || path4.resolve(real) !== resolved) throw unsafePath();
25923
+ const real = await fs3.realpath(resolved).catch(() => void 0);
25924
+ if (real === void 0 || path5.resolve(real) !== resolved) throw unsafePath();
25875
25925
  return {
25876
25926
  directory: resolved,
25877
25927
  chain: [...parent?.chain ?? [], { path: resolved, ...identityOf(stat2) }]
@@ -25881,15 +25931,15 @@ async function verifyDirectoryGuard(guard) {
25881
25931
  for (const expected of guard.chain) {
25882
25932
  const stat2 = await lstatBigIntOptional(expected.path);
25883
25933
  if (stat2 === void 0 || stat2.isSymbolicLink() || !stat2.isDirectory() || !matchesIdentity(stat2, expected)) throw unsafePath();
25884
- const real = await fs2.realpath(expected.path).catch(() => void 0);
25885
- if (real === void 0 || path4.resolve(real) !== expected.path) throw unsafePath();
25934
+ const real = await fs3.realpath(expected.path).catch(() => void 0);
25935
+ if (real === void 0 || path5.resolve(real) !== expected.path) throw unsafePath();
25886
25936
  }
25887
25937
  }
25888
25938
  async function capturePathIdentity(target, kind = "directory") {
25889
25939
  const stat2 = await lstatBigIntOptional(target);
25890
25940
  if (stat2 === void 0 || stat2.isSymbolicLink() || (kind === "directory" ? !stat2.isDirectory() : !stat2.isFile())) throw unsafePath();
25891
- const real = await fs2.realpath(target).catch(() => void 0);
25892
- if (real === void 0 || path4.resolve(real) !== path4.resolve(target)) throw unsafePath();
25941
+ const real = await fs3.realpath(target).catch(() => void 0);
25942
+ if (real === void 0 || path5.resolve(real) !== path5.resolve(target)) throw unsafePath();
25893
25943
  return identityOf(stat2);
25894
25944
  }
25895
25945
  async function verifyPathIdentity(target, expected, kind = "directory") {
@@ -25897,32 +25947,32 @@ async function verifyPathIdentity(target, expected, kind = "directory") {
25897
25947
  if (stat2 === void 0 || stat2.isSymbolicLink() || (kind === "directory" ? !stat2.isDirectory() : !stat2.isFile()) || !matchesIdentity(stat2, expected)) {
25898
25948
  throw unsafePath();
25899
25949
  }
25900
- const real = await fs2.realpath(target).catch(() => void 0);
25901
- if (real === void 0 || path4.resolve(real) !== path4.resolve(target)) throw unsafePath();
25950
+ const real = await fs3.realpath(target).catch(() => void 0);
25951
+ if (real === void 0 || path5.resolve(real) !== path5.resolve(target)) throw unsafePath();
25902
25952
  }
25903
25953
  async function guardedRename(options2) {
25904
- if (path4.dirname(path4.resolve(options2.source)) !== options2.sourceParent.directory || path4.dirname(path4.resolve(options2.destination)) !== options2.destinationParent.directory) throw unsafePath();
25954
+ if (path5.dirname(path5.resolve(options2.source)) !== options2.sourceParent.directory || path5.dirname(path5.resolve(options2.destination)) !== options2.destinationParent.directory) throw unsafePath();
25905
25955
  await options2.hooks?.beforeRename?.(options2.source, options2.destination);
25906
25956
  await verifyDirectoryGuard(options2.sourceParent);
25907
25957
  await verifyDirectoryGuard(options2.destinationParent);
25908
25958
  await verifyPathIdentity(options2.source, options2.sourceIdentity);
25909
25959
  if (await lstatOptional(options2.destination) !== void 0) throw unsafePath();
25910
- await fs2.rename(options2.source, options2.destination);
25960
+ await fs3.rename(options2.source, options2.destination);
25911
25961
  }
25912
25962
  async function guardedCreateTemporaryDirectory(options2) {
25913
- const prefixPath = path4.resolve(options2.parent.directory, options2.prefix);
25914
- if (path4.dirname(prefixPath) !== options2.parent.directory || path4.basename(prefixPath) !== options2.prefix) throw unsafePath();
25963
+ const prefixPath = path5.resolve(options2.parent.directory, options2.prefix);
25964
+ if (path5.dirname(prefixPath) !== options2.parent.directory || path5.basename(prefixPath) !== options2.prefix) throw unsafePath();
25915
25965
  await options2.hooks?.beforeCreate?.(prefixPath, "temporary-directory");
25916
25966
  await verifyDirectoryGuard(options2.parent);
25917
- const directory = await fs2.mkdtemp(prefixPath);
25967
+ const directory = await fs3.mkdtemp(prefixPath);
25918
25968
  return captureDirectoryGuard(directory, options2.parent);
25919
25969
  }
25920
25970
  async function guardedCreateDirectory(options2) {
25921
- const target = path4.resolve(options2.target);
25922
- if (path4.dirname(target) !== options2.parent.directory) throw unsafePath();
25971
+ const target = path5.resolve(options2.target);
25972
+ if (path5.dirname(target) !== options2.parent.directory) throw unsafePath();
25923
25973
  await options2.hooks?.beforeCreate?.(target, "directory");
25924
25974
  await verifyDirectoryGuard(options2.parent);
25925
- await fs2.mkdir(target).catch((error) => {
25975
+ await fs3.mkdir(target).catch((error) => {
25926
25976
  if (error.code === "EEXIST") throw unsafePath();
25927
25977
  throw error;
25928
25978
  });
@@ -25931,14 +25981,14 @@ async function guardedCreateDirectory(options2) {
25931
25981
  function createGuardedCopyDestination(root, hooks) {
25932
25982
  const guards = /* @__PURE__ */ new Map([[root.directory, root]]);
25933
25983
  const ensureDirectory = async (destination) => {
25934
- const resolved = path4.resolve(destination);
25984
+ const resolved = path5.resolve(destination);
25935
25985
  if (!isInside(root.directory, resolved)) throw unsafePath();
25936
25986
  const existing = guards.get(resolved);
25937
25987
  if (existing !== void 0) {
25938
25988
  await verifyDirectoryGuard(existing);
25939
25989
  return;
25940
25990
  }
25941
- const parentPath = path4.dirname(resolved);
25991
+ const parentPath = path5.dirname(resolved);
25942
25992
  await ensureDirectory(parentPath);
25943
25993
  const parent = guards.get(parentPath);
25944
25994
  if (parent === void 0) throw unsafePath();
@@ -25947,15 +25997,15 @@ function createGuardedCopyDestination(root, hooks) {
25947
25997
  return {
25948
25998
  ensureDirectory,
25949
25999
  copyFile: async (source, destination) => {
25950
- const target = path4.resolve(destination);
26000
+ const target = path5.resolve(destination);
25951
26001
  if (!isInside(root.directory, target) || target === root.directory) throw unsafePath();
25952
- const parent = guards.get(path4.dirname(target));
26002
+ const parent = guards.get(path5.dirname(target));
25953
26003
  if (parent === void 0) throw unsafePath();
25954
26004
  await hooks?.beforeCreate?.(target, "file");
25955
26005
  const sourceIdentity = await capturePathIdentity(source, "file");
25956
26006
  await verifyPathIdentity(source, sourceIdentity, "file");
25957
26007
  await verifyDirectoryGuard(parent);
25958
- await fs2.copyFile(source, target, constants2.COPYFILE_EXCL).catch((error) => {
26008
+ await fs3.copyFile(source, target, constants2.COPYFILE_EXCL).catch((error) => {
25959
26009
  if (error.code === "EEXIST") throw unsafePath();
25960
26010
  throw error;
25961
26011
  });
@@ -25963,14 +26013,14 @@ function createGuardedCopyDestination(root, hooks) {
25963
26013
  };
25964
26014
  }
25965
26015
  async function guardedRemoveTree(options2) {
25966
- if (path4.dirname(path4.resolve(options2.target)) !== options2.parent.directory) throw unsafePath();
26016
+ if (path5.dirname(path5.resolve(options2.target)) !== options2.parent.directory) throw unsafePath();
25967
26017
  await options2.hooks?.beforeRemove?.(options2.target);
25968
26018
  await verifyDirectoryGuard(options2.parent);
25969
26019
  await verifyPathIdentity(options2.target, options2.targetIdentity);
25970
26020
  await assertTreeHasNoSymlinks(options2.target);
25971
26021
  await verifyDirectoryGuard(options2.parent);
25972
26022
  await verifyPathIdentity(options2.target, options2.targetIdentity);
25973
- await fs2.rm(options2.target, { recursive: true });
26023
+ await fs3.rm(options2.target, { recursive: true });
25974
26024
  }
25975
26025
  async function readProjectConfig(project) {
25976
26026
  await verifyDirectoryGuard(project.localAppGuard);
@@ -25978,7 +26028,7 @@ async function readProjectConfig(project) {
25978
26028
  if (stat2 === void 0) return {};
25979
26029
  if (!stat2.isFile() || stat2.isSymbolicLink()) throw unsafePath();
25980
26030
  try {
25981
- const parsed = JSON.parse(await fs2.readFile(project.configPath, "utf8"));
26031
+ const parsed = JSON.parse(await fs3.readFile(project.configPath, "utf8"));
25982
26032
  if (!isRecord2(parsed)) throw new Error("invalid config");
25983
26033
  return parsed;
25984
26034
  } catch {
@@ -25990,15 +26040,15 @@ async function writeProjectConfig(project, value2, hooks) {
25990
26040
  `, project.localAppGuard, hooks);
25991
26041
  }
25992
26042
  async function atomicWriteFile(target, contents, parent, hooks) {
25993
- if (path4.dirname(path4.resolve(target)) !== parent.directory) throw unsafePath();
26043
+ if (path5.dirname(path5.resolve(target)) !== parent.directory) throw unsafePath();
25994
26044
  await verifyDirectoryGuard(parent);
25995
26045
  const existingStat = await lstatOptional(target);
25996
26046
  if (existingStat !== void 0 && (!existingStat.isFile() || existingStat.isSymbolicLink())) throw unsafePath();
25997
26047
  const existingIdentity = existingStat === void 0 ? void 0 : identityOf(existingStat);
25998
- const temporary = path4.join(parent.directory, `.${path4.basename(target)}.${process.pid}.${crypto2.randomUUID()}.tmp`);
26048
+ const temporary = path5.join(parent.directory, `.${path5.basename(target)}.${process.pid}.${crypto2.randomUUID()}.tmp`);
25999
26049
  await hooks?.beforeCreate?.(temporary, "file");
26000
26050
  await verifyDirectoryGuard(parent);
26001
- await fs2.writeFile(temporary, contents, { flag: "wx" });
26051
+ await fs3.writeFile(temporary, contents, { flag: "wx" });
26002
26052
  const temporaryIdentity = await capturePathIdentity(temporary, "file");
26003
26053
  let committed = false;
26004
26054
  try {
@@ -26010,7 +26060,7 @@ async function atomicWriteFile(target, contents, parent, hooks) {
26010
26060
  } else {
26011
26061
  await verifyPathIdentity(target, existingIdentity, "file");
26012
26062
  }
26013
- await fs2.rename(temporary, target);
26063
+ await fs3.rename(temporary, target);
26014
26064
  committed = true;
26015
26065
  } finally {
26016
26066
  if (!committed) {
@@ -26022,7 +26072,7 @@ async function managedSkillNames(skillsDirectory, guard) {
26022
26072
  if (guard !== void 0) await verifyDirectoryGuard(guard);
26023
26073
  const stat2 = await lstatOptional(skillsDirectory);
26024
26074
  if (stat2 === void 0 || stat2.isSymbolicLink() || !stat2.isDirectory()) throw unsafePath();
26025
- const entries = await fs2.readdir(skillsDirectory, { withFileTypes: true });
26075
+ const entries = await fs3.readdir(skillsDirectory, { withFileTypes: true });
26026
26076
  const names = [];
26027
26077
  for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
26028
26078
  if (!isManagedSkillName(entry.name)) continue;
@@ -26037,20 +26087,20 @@ function isManagedSkillName(name) {
26037
26087
  async function assertTreeHasNoSymlinks(root) {
26038
26088
  const stat2 = await lstatOptional(root);
26039
26089
  if (stat2 === void 0 || stat2.isSymbolicLink() || !stat2.isDirectory()) throw unsafePath();
26040
- const entries = await fs2.readdir(root, { withFileTypes: true });
26090
+ const entries = await fs3.readdir(root, { withFileTypes: true });
26041
26091
  for (const entry of entries) {
26042
26092
  if (entry.isSymbolicLink()) throw unsafePath();
26043
- const entryPath = path4.join(root, entry.name);
26093
+ const entryPath = path5.join(root, entry.name);
26044
26094
  if (entry.isDirectory()) await assertTreeHasNoSymlinks(entryPath);
26045
26095
  else if (!entry.isFile()) throw unsafePath();
26046
26096
  }
26047
26097
  }
26048
26098
  async function lstatOptional(target) {
26049
- return fs2.lstat(target).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26099
+ return fs3.lstat(target).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26050
26100
  }
26051
26101
  function isInside(root, target) {
26052
- const relative = path4.relative(root, target);
26053
- return relative === "" || !relative.startsWith(`..${path4.sep}`) && relative !== ".." && !path4.isAbsolute(relative);
26102
+ const relative = path5.relative(root, target);
26103
+ return relative === "" || !relative.startsWith(`..${path5.sep}`) && relative !== ".." && !path5.isAbsolute(relative);
26054
26104
  }
26055
26105
  function unsafePath() {
26056
26106
  return lifecycleError("unsafe_project_path", UNSAFE_PATH_MESSAGE);
@@ -26061,7 +26111,7 @@ async function requireProjectJson(filePath, manifest, parent) {
26061
26111
  if (stat2 === void 0) throw lifecycleError("not_localapp_project", NOT_PROJECT_MESSAGE);
26062
26112
  if (stat2.isSymbolicLink() || !stat2.isFile()) throw unsafePath();
26063
26113
  try {
26064
- const parsed = JSON.parse(await fs2.readFile(filePath, "utf8"));
26114
+ const parsed = JSON.parse(await fs3.readFile(filePath, "utf8"));
26065
26115
  if (!isRecord2(parsed)) throw new Error("invalid json");
26066
26116
  if (manifest && (typeof parsed.name !== "string" || typeof parsed.platformVersion !== "string")) throw new Error("invalid manifest");
26067
26117
  } catch {
@@ -26071,10 +26121,10 @@ async function requireProjectJson(filePath, manifest, parent) {
26071
26121
  async function removeTemporaryFile(target, identity, parent) {
26072
26122
  await verifyDirectoryGuard(parent);
26073
26123
  await verifyPathIdentity(target, identity, "file");
26074
- await fs2.rm(target);
26124
+ await fs3.rm(target);
26075
26125
  }
26076
26126
  async function lstatBigIntOptional(target) {
26077
- return fs2.lstat(target, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26127
+ return fs3.lstat(target, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26078
26128
  }
26079
26129
  function identityOf(stat2) {
26080
26130
  return { device: stat2.dev.toString(), inode: stat2.ino.toString() };
@@ -26087,15 +26137,15 @@ function isRecord2(value2) {
26087
26137
  }
26088
26138
 
26089
26139
  // packages/localapp/src/template/copy.ts
26090
- import fs3 from "node:fs/promises";
26091
- import path5 from "node:path";
26140
+ import fs4 from "node:fs/promises";
26141
+ import path6 from "node:path";
26092
26142
  async function copyDirectory(source, destination, excludedNames = /* @__PURE__ */ new Set(), destinationMutations) {
26093
- const sourceStat = await fs3.lstat(source);
26143
+ const sourceStat = await fs4.lstat(source);
26094
26144
  if (sourceStat.isSymbolicLink() || !sourceStat.isDirectory()) {
26095
26145
  throw new Error(`Refusing to copy an unsafe template directory: ${source}`);
26096
26146
  }
26097
26147
  if (destinationMutations === void 0) {
26098
- const destinationStat = await fs3.lstat(destination).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26148
+ const destinationStat = await fs4.lstat(destination).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26099
26149
  if (destinationStat !== void 0 && (destinationStat.isSymbolicLink() || !destinationStat.isDirectory())) {
26100
26150
  throw new Error(`Refusing to copy through an unsafe destination: ${destination}`);
26101
26151
  }
@@ -26103,19 +26153,19 @@ async function copyDirectory(source, destination, excludedNames = /* @__PURE__ *
26103
26153
  } else {
26104
26154
  await destinationMutations.ensureDirectory(destination);
26105
26155
  }
26106
- const entries = await fs3.readdir(source, { withFileTypes: true });
26156
+ const entries = await fs4.readdir(source, { withFileTypes: true });
26107
26157
  for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
26108
26158
  if (excludedNames.has(entry.name) || entry.name.endsWith(".tsbuildinfo")) continue;
26109
- const sourcePath = path5.join(source, entry.name);
26110
- const destinationPath = path5.join(destination, entry.name);
26159
+ const sourcePath = path6.join(source, entry.name);
26160
+ const destinationPath = path6.join(destination, entry.name);
26111
26161
  if (entry.isDirectory()) {
26112
26162
  await copyDirectory(sourcePath, destinationPath, excludedNames, destinationMutations);
26113
26163
  } else if (entry.isFile()) {
26114
- const currentSourceStat = await fs3.lstat(sourcePath);
26164
+ const currentSourceStat = await fs4.lstat(sourcePath);
26115
26165
  if (currentSourceStat.isSymbolicLink() || !currentSourceStat.isFile()) {
26116
26166
  throw new Error(`Builtin template may only contain regular files: ${sourcePath}`);
26117
26167
  }
26118
- if (destinationMutations === void 0) await fs3.copyFile(sourcePath, destinationPath);
26168
+ if (destinationMutations === void 0) await fs4.copyFile(sourcePath, destinationPath);
26119
26169
  else await destinationMutations.copyFile(sourcePath, destinationPath);
26120
26170
  } else if (entry.isSymbolicLink()) {
26121
26171
  throw new Error(`Builtin template may not contain symbolic links: ${sourcePath}`);
@@ -26123,18 +26173,18 @@ async function copyDirectory(source, destination, excludedNames = /* @__PURE__ *
26123
26173
  }
26124
26174
  }
26125
26175
  async function isDirectory(directory) {
26126
- return fs3.lstat(directory).then((stat2) => stat2.isDirectory() && !stat2.isSymbolicLink(), () => false);
26176
+ return fs4.lstat(directory).then((stat2) => stat2.isDirectory() && !stat2.isSymbolicLink(), () => false);
26127
26177
  }
26128
26178
  async function createDirectoryWithoutSymlinks(directory) {
26129
- const stat2 = await fs3.lstat(directory).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26179
+ const stat2 = await fs4.lstat(directory).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26130
26180
  if (stat2 !== void 0) {
26131
26181
  if (stat2.isSymbolicLink() || !stat2.isDirectory()) throw new Error(`Refusing to copy through an unsafe destination: ${directory}`);
26132
26182
  return;
26133
26183
  }
26134
- const parent = path5.dirname(directory);
26184
+ const parent = path6.dirname(directory);
26135
26185
  if (parent === directory) throw new Error(`Refusing to create an unsafe destination: ${directory}`);
26136
26186
  await createDirectoryWithoutSymlinks(parent);
26137
- await fs3.mkdir(directory);
26187
+ await fs4.mkdir(directory);
26138
26188
  }
26139
26189
 
26140
26190
  // packages/localapp/src/commands/init.ts
@@ -26143,19 +26193,19 @@ async function initializeProject(options2) {
26143
26193
  throw lifecycleError("invalid_project_name", "Invalid name. Use 3-63 lowercase letters, digits, or hyphens; start with a letter and do not end with or repeat hyphens.");
26144
26194
  }
26145
26195
  const cwd = await verifyInitParent(options2.cwd);
26146
- const useCurrentDirectory = path6.basename(cwd) === options2.name && await isEmptyDirectory(cwd);
26147
- const projectDir = useCurrentDirectory ? cwd : path6.join(cwd, options2.name);
26196
+ const useCurrentDirectory = path7.basename(cwd) === options2.name && await isEmptyDirectory(cwd);
26197
+ const projectDir = useCurrentDirectory ? cwd : path7.join(cwd, options2.name);
26148
26198
  if (!useCurrentDirectory && await pathExists(projectDir)) {
26149
26199
  throw lifecycleError("project_directory_exists", `Project directory already exists: ${options2.name}. Choose another name or remove the directory.`);
26150
26200
  }
26151
26201
  const templateDirectory = await resolveTemplateDirectory();
26152
- if (!useCurrentDirectory) await fs4.mkdir(projectDir);
26202
+ if (!useCurrentDirectory) await fs5.mkdir(projectDir);
26153
26203
  try {
26154
26204
  await copyUserZone(templateDirectory, projectDir);
26155
26205
  await copyManagedZone(templateDirectory, projectDir);
26156
26206
  const manifest = await writeProjectManifest(projectDir, options2.name, options2.description);
26157
- await fs4.mkdir(path6.join(projectDir, ".localapp"), { recursive: true });
26158
- await fs4.writeFile(path6.join(projectDir, ".localapp/dev-config.json"), `${JSON.stringify({ serverUrl: "" }, null, 2)}
26207
+ await fs5.mkdir(path7.join(projectDir, ".localapp"), { recursive: true });
26208
+ await fs5.writeFile(path7.join(projectDir, ".localapp/dev-config.json"), `${JSON.stringify({ serverUrl: "" }, null, 2)}
26159
26209
  `);
26160
26210
  if (!options2.skipInstall) await installDependencies(projectDir, options2.io);
26161
26211
  options2.io.stdout(`${JSON.stringify({ created: options2.name })}
@@ -26164,7 +26214,7 @@ async function initializeProject(options2) {
26164
26214
  options2.io.stderr("Project created locally. Run localapp app install --target <profile> when it is ready to publish.\n");
26165
26215
  return { projectDir, manifest };
26166
26216
  } catch (error) {
26167
- if (!useCurrentDirectory) await fs4.rm(projectDir, { recursive: true, force: true });
26217
+ if (!useCurrentDirectory) await fs5.rm(projectDir, { recursive: true, force: true });
26168
26218
  if (error instanceof LocalAppLifecycleError) throw error;
26169
26219
  throw lifecycleError("project_initialization_failed", "Project initialization failed. Check the builtin template and destination permissions, then retry.");
26170
26220
  }
@@ -26172,33 +26222,33 @@ async function initializeProject(options2) {
26172
26222
  async function resolveTemplateDirectory() {
26173
26223
  const explicit = process.env.LOCALAPP_TEMPLATE_DIR;
26174
26224
  if (explicit !== void 0 && await isDirectory(explicit)) return explicit;
26175
- let packageDirectory = path6.dirname(fileURLToPath2(import.meta.url));
26225
+ let packageDirectory = path7.dirname(fileURLToPath2(import.meta.url));
26176
26226
  for (let level = 0; level < 4; level += 1) {
26177
- const packagedTemplate = path6.join(packageDirectory, "template");
26227
+ const packagedTemplate = path7.join(packageDirectory, "template");
26178
26228
  if (await isDirectory(packagedTemplate)) return packagedTemplate;
26179
- packageDirectory = path6.dirname(packageDirectory);
26229
+ packageDirectory = path7.dirname(packageDirectory);
26180
26230
  }
26181
26231
  throw lifecycleError("builtin_template_unavailable", "Builtin template is unavailable. Reinstall localapp or rebuild the package before running init.");
26182
26232
  }
26183
26233
  async function copyUserZone(templateDirectory, projectDirectory) {
26184
26234
  const userExcludes = /* @__PURE__ */ new Set([".claude", ".next", ".DS_Store", "data", "dist", "node_modules", "runtime", "template.gitignore"]);
26185
26235
  await copyDirectory(templateDirectory, projectDirectory, userExcludes);
26186
- const stagedGitignore = path6.join(templateDirectory, "template.gitignore");
26187
- if (await pathExists(stagedGitignore)) await fs4.copyFile(stagedGitignore, path6.join(projectDirectory, ".gitignore"));
26188
- const stagedNpmrc = path6.join(templateDirectory, "template.npmrc");
26189
- if (await pathExists(stagedNpmrc)) await fs4.copyFile(stagedNpmrc, path6.join(projectDirectory, ".npmrc"));
26236
+ const stagedGitignore = path7.join(templateDirectory, "template.gitignore");
26237
+ if (await pathExists(stagedGitignore)) await fs5.copyFile(stagedGitignore, path7.join(projectDirectory, ".gitignore"));
26238
+ const stagedNpmrc = path7.join(templateDirectory, "template.npmrc");
26239
+ if (await pathExists(stagedNpmrc)) await fs5.copyFile(stagedNpmrc, path7.join(projectDirectory, ".npmrc"));
26190
26240
  }
26191
26241
  async function copyManagedZone(templateDirectory, projectDirectory, destinationMutations) {
26192
- await copyDirectory(path6.join(templateDirectory, "runtime"), path6.join(projectDirectory, ".localapp/runtime"), void 0, destinationMutations);
26193
- const skillsDirectory = path6.join(templateDirectory, ".claude/skills");
26242
+ await copyDirectory(path7.join(templateDirectory, "runtime"), path7.join(projectDirectory, ".localapp/runtime"), void 0, destinationMutations);
26243
+ const skillsDirectory = path7.join(templateDirectory, ".claude/skills");
26194
26244
  if (!await isDirectory(skillsDirectory)) return;
26195
- const names = await fs4.readdir(skillsDirectory, { withFileTypes: true });
26245
+ const names = await fs5.readdir(skillsDirectory, { withFileTypes: true });
26196
26246
  for (const entry of names.sort((left, right) => left.name.localeCompare(right.name))) {
26197
26247
  if (!isManagedSkill(entry.name)) continue;
26198
26248
  if (entry.isSymbolicLink() || !entry.isDirectory()) throw new Error(`Builtin template contains an unsafe managed skill: ${entry.name}`);
26199
26249
  await copyDirectory(
26200
- path6.join(skillsDirectory, entry.name),
26201
- path6.join(projectDirectory, ".claude/skills", entry.name),
26250
+ path7.join(skillsDirectory, entry.name),
26251
+ path7.join(projectDirectory, ".claude/skills", entry.name),
26202
26252
  void 0,
26203
26253
  destinationMutations
26204
26254
  );
@@ -26209,7 +26259,8 @@ function isManagedSkill(name) {
26209
26259
  }
26210
26260
  async function installDependencies(projectDirectory, io) {
26211
26261
  await new Promise((resolve2, reject) => {
26212
- const child = spawn("npm", ["install"], { cwd: projectDirectory, stdio: ["ignore", "pipe", "pipe"] });
26262
+ const invocation = resolveCommandInvocation("npm", ["install"]);
26263
+ const child = spawn(invocation.command, invocation.args, { cwd: projectDirectory, stdio: ["ignore", "pipe", "pipe"] });
26213
26264
  child.stdout.setEncoding("utf8");
26214
26265
  child.stderr.setEncoding("utf8");
26215
26266
  child.stdout.on("data", (chunk) => io.stdout(chunk));
@@ -26221,16 +26272,16 @@ async function installDependencies(projectDirectory, io) {
26221
26272
  });
26222
26273
  }
26223
26274
  async function pathExists(target) {
26224
- return fs4.access(target).then(() => true, () => false);
26275
+ return fs5.access(target).then(() => true, () => false);
26225
26276
  }
26226
26277
  async function isEmptyDirectory(directory) {
26227
- const entries = await fs4.readdir(directory).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26278
+ const entries = await fs5.readdir(directory).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26228
26279
  return entries !== void 0 && entries.length === 0;
26229
26280
  }
26230
26281
 
26231
26282
  // packages/localapp/src/commands/sync-template.ts
26232
- import fs5 from "node:fs/promises";
26233
- import path7 from "node:path";
26283
+ import fs6 from "node:fs/promises";
26284
+ import path8 from "node:path";
26234
26285
  async function syncManagedTemplate(projectDir, { quiet }, hooks = {}) {
26235
26286
  const project = await verifyProjectBase(projectDir);
26236
26287
  const config = await readProjectConfig(project);
@@ -26244,16 +26295,16 @@ async function syncManagedTemplate(projectDir, { quiet }, hooks = {}) {
26244
26295
  try {
26245
26296
  backupRoot = await createRecoveryRoot(".sync-backup-", project.localAppGuard, hooks);
26246
26297
  await copyManagedZone(templateDirectory, stageRoot.path, createGuardedCopyDestination(stageRoot.guard, hooks));
26247
- const stagedLocalApp = await captureDirectoryGuard(path7.join(stageRoot.path, ".localapp"), stageRoot.guard);
26248
- const stagedRuntimePath = path7.join(stagedLocalApp.directory, "runtime");
26298
+ const stagedLocalApp = await captureDirectoryGuard(path8.join(stageRoot.path, ".localapp"), stageRoot.guard);
26299
+ const stagedRuntimePath = path8.join(stagedLocalApp.directory, "runtime");
26249
26300
  const stagedRuntime = await pathReference(stagedRuntimePath, stagedLocalApp);
26250
- const stagedClaude = await captureDirectoryGuard(path7.join(stageRoot.path, ".claude"), stageRoot.guard);
26251
- const stagedSkills = await captureDirectoryGuard(path7.join(stagedClaude.directory, "skills"), stagedClaude);
26301
+ const stagedClaude = await captureDirectoryGuard(path8.join(stageRoot.path, ".claude"), stageRoot.guard);
26302
+ const stagedSkills = await captureDirectoryGuard(path8.join(stagedClaude.directory, "skills"), stagedClaude);
26252
26303
  version = await readStagedVersion(stagedRuntimePath);
26253
26304
  const oldSkills = await managedSkillNames(project.skillsDirectory, project.skillsGuard);
26254
26305
  const newSkills = await managedSkillNames(stagedSkills.directory, stagedSkills);
26255
26306
  const backupSkills = await guardedCreateDirectory({
26256
- target: path7.join(backupRoot.path, "skills"),
26307
+ target: path8.join(backupRoot.path, "skills"),
26257
26308
  parent: backupRoot.guard,
26258
26309
  hooks
26259
26310
  });
@@ -26263,17 +26314,17 @@ async function syncManagedTemplate(projectDir, { quiet }, hooks = {}) {
26263
26314
  currentParent: project.localAppGuard,
26264
26315
  current: await pathReference(project.runtimeDirectory, project.localAppGuard),
26265
26316
  staged: stagedRuntime,
26266
- backupPath: path7.join(backupRoot.path, "runtime"),
26317
+ backupPath: path8.join(backupRoot.path, "runtime"),
26267
26318
  backupParent: backupRoot.guard,
26268
26319
  movedCurrent: false,
26269
26320
  installedStaged: false
26270
26321
  },
26271
26322
  ...await Promise.all([.../* @__PURE__ */ new Set([...oldSkills, ...newSkills])].sort().map(async (name) => ({
26272
- currentPath: path7.join(project.skillsDirectory, name),
26323
+ currentPath: path8.join(project.skillsDirectory, name),
26273
26324
  currentParent: project.skillsGuard,
26274
- ...oldSkills.includes(name) ? { current: await pathReference(path7.join(project.skillsDirectory, name), project.skillsGuard) } : {},
26275
- ...newSkills.includes(name) ? { staged: await pathReference(path7.join(stagedSkills.directory, name), stagedSkills) } : {},
26276
- backupPath: path7.join(backupSkills.directory, name),
26325
+ ...oldSkills.includes(name) ? { current: await pathReference(path8.join(project.skillsDirectory, name), project.skillsGuard) } : {},
26326
+ ...newSkills.includes(name) ? { staged: await pathReference(path8.join(stagedSkills.directory, name), stagedSkills) } : {},
26327
+ backupPath: path8.join(backupSkills.directory, name),
26277
26328
  backupParent: backupSkills,
26278
26329
  movedCurrent: false,
26279
26330
  installedStaged: false
@@ -26314,7 +26365,7 @@ async function pathReference(target, parent) {
26314
26365
  return { path: target, parent, identity: await capturePathIdentity(target) };
26315
26366
  }
26316
26367
  async function readStagedVersion(runtimeDirectory) {
26317
- const parsed = JSON.parse(await fs5.readFile(path7.join(runtimeDirectory, "version.json"), "utf8"));
26368
+ const parsed = JSON.parse(await fs6.readFile(path8.join(runtimeDirectory, "version.json"), "utf8"));
26318
26369
  if (parsed === null || typeof parsed !== "object" || typeof parsed.cliVersion !== "string") {
26319
26370
  throw new Error("invalid staged runtime version");
26320
26371
  }
@@ -26383,8 +26434,8 @@ async function cleanupRecoveryRoots(roots, hooks) {
26383
26434
 
26384
26435
  // packages/localapp/src/commands/eject-template.ts
26385
26436
  import crypto3 from "node:crypto";
26386
- import fs6 from "node:fs/promises";
26387
- import path8 from "node:path";
26437
+ import fs7 from "node:fs/promises";
26438
+ import path9 from "node:path";
26388
26439
 
26389
26440
  // packages/localapp/src/template/package-json.ts
26390
26441
  function rewritePackageJsonForEjectValue(packageJson) {
@@ -26437,7 +26488,7 @@ async function ejectManagedTemplate(projectDir, hooks = {}) {
26437
26488
  }
26438
26489
  }
26439
26490
  async function prepareTransaction(project) {
26440
- const packageContents = await fs6.readFile(project.packagePath, "utf8");
26491
+ const packageContents = await fs7.readFile(project.packagePath, "utf8");
26441
26492
  let packageJson;
26442
26493
  try {
26443
26494
  const parsed = JSON.parse(packageContents);
@@ -26468,12 +26519,12 @@ async function prepareMove(project, source, destination) {
26468
26519
  const destinationParentGuard = moveParentGuard(project, destination);
26469
26520
  await verifyDirectoryGuard(sourceParent);
26470
26521
  await verifyDirectoryGuard(destinationParentGuard);
26471
- const sourceStat = await fs6.lstat(sourcePath, { bigint: true });
26522
+ const sourceStat = await fs7.lstat(sourcePath, { bigint: true });
26472
26523
  if (sourceStat.isSymbolicLink() || !sourceStat.isDirectory()) throw unsafeTransaction();
26473
26524
  await capturePathIdentity(sourcePath);
26474
26525
  await assertTreeHasNoSymlinks(sourcePath);
26475
26526
  if (await lstatOptional(destinationPath) !== void 0) throw collision(destination);
26476
- const destinationParent = await fs6.lstat(path8.dirname(destinationPath), { bigint: true });
26527
+ const destinationParent = await fs7.lstat(path9.dirname(destinationPath), { bigint: true });
26477
26528
  if (destinationParent.isSymbolicLink() || !destinationParent.isDirectory() || destinationParent.dev !== sourceStat.dev) {
26478
26529
  throw lifecycleError("template_eject_filesystem", "Eject requires managed sources and destinations to be directories on the same filesystem.");
26479
26530
  }
@@ -26484,15 +26535,15 @@ async function resumeMove(project, move, hooks) {
26484
26535
  const destinationPath = projectPath(project, move.destination);
26485
26536
  const sourceParent = moveParentGuard(project, move.source);
26486
26537
  const destinationParent = moveParentGuard(project, move.destination);
26487
- const source = await fs6.lstat(sourcePath, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26488
- const destination = await fs6.lstat(destinationPath, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26538
+ const source = await fs7.lstat(sourcePath, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26539
+ const destination = await fs7.lstat(destinationPath, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
26489
26540
  if (source !== void 0) {
26490
26541
  if (!matchesIdentity2(source, move) || source.isSymbolicLink() || !source.isDirectory()) throw unsafeTransaction();
26491
26542
  await assertTreeHasNoSymlinks(sourcePath);
26492
26543
  if (destination !== void 0) throw collision(move.destination);
26493
26544
  await verifyDirectoryGuard(sourceParent);
26494
26545
  await verifyDirectoryGuard(destinationParent);
26495
- const destinationParentStat = await fs6.lstat(path8.dirname(destinationPath), { bigint: true });
26546
+ const destinationParentStat = await fs7.lstat(path9.dirname(destinationPath), { bigint: true });
26496
26547
  if (destinationParentStat.dev !== source.dev) {
26497
26548
  throw lifecycleError("template_eject_filesystem", "Eject requires managed sources and destinations to be directories on the same filesystem.");
26498
26549
  }
@@ -26514,7 +26565,7 @@ async function resumeMove(project, move, hooks) {
26514
26565
  await assertTreeHasNoSymlinks(destinationPath);
26515
26566
  }
26516
26567
  async function installEjectedPackage(project, transaction, hooks) {
26517
- const current = await fs6.readFile(project.packagePath, "utf8");
26568
+ const current = await fs7.readFile(project.packagePath, "utf8");
26518
26569
  const currentHash = sha256(current);
26519
26570
  if (currentHash === transaction.ejectedPackageHash) return;
26520
26571
  if (currentHash !== transaction.originalPackageHash) {
@@ -26546,7 +26597,7 @@ function parseMove(value2, project) {
26546
26597
  return move;
26547
26598
  }
26548
26599
  function projectPath(project, relative) {
26549
- const target = path8.resolve(project.root, relative);
26600
+ const target = path9.resolve(project.root, relative);
26550
26601
  if (!isInside(project.root, target)) throw unsafeTransaction();
26551
26602
  return target;
26552
26603
  }
@@ -26571,13 +26622,13 @@ function unsafeTransaction() {
26571
26622
 
26572
26623
  // packages/localapp/src/project/check.ts
26573
26624
  import { spawn as spawn2 } from "node:child_process";
26574
- import fs12 from "node:fs/promises";
26575
- import path15 from "node:path";
26625
+ import fs13 from "node:fs/promises";
26626
+ import path16 from "node:path";
26576
26627
 
26577
26628
  // packages/server/src/lib/app-package.ts
26578
26629
  import crypto4 from "node:crypto";
26579
- import fs8 from "node:fs";
26580
- import path10 from "node:path";
26630
+ import fs9 from "node:fs";
26631
+ import path11 from "node:path";
26581
26632
  import { Transform as Transform5 } from "node:stream";
26582
26633
  var import_yauzl = __toESM(require_yauzl());
26583
26634
  import { pipeline } from "node:stream/promises";
@@ -26618,17 +26669,17 @@ var MAX_APP_PACKAGE_BYTES = 512 * 1024 * 1024;
26618
26669
  var METADATA_PATHS = /* @__PURE__ */ new Set(["package.json", "checksums.json"]);
26619
26670
  var FIXED_ARCHIVE_DATE = /* @__PURE__ */ new Date("1980-01-01T00:00:00.000Z");
26620
26671
  var AppPackageValidationError = class extends Error {
26621
- constructor(message, path35) {
26672
+ constructor(message, path36) {
26622
26673
  super(message);
26623
- this.path = path35;
26674
+ this.path = path36;
26624
26675
  this.name = "AppPackageValidationError";
26625
26676
  }
26626
26677
  path;
26627
26678
  code = "APP_PACKAGE_INVALID";
26628
26679
  };
26629
26680
  async function inspectAppPackage(filePath) {
26630
- const packagePath = path10.resolve(filePath);
26631
- const stat2 = await fs8.promises.stat(packagePath).catch((error) => {
26681
+ const packagePath = path11.resolve(filePath);
26682
+ const stat2 = await fs9.promises.stat(packagePath).catch((error) => {
26632
26683
  throw new AppPackageValidationError(`Cannot read application package: ${error instanceof Error ? error.message : String(error)}`);
26633
26684
  });
26634
26685
  if (!stat2.isFile()) throw new AppPackageValidationError("Application package must be a regular file");
@@ -26830,7 +26881,7 @@ function assertSafeArchivePath(entryPath, allowDirectory) {
26830
26881
  throw new AppPackageValidationError(`Unsafe package path: ${entryPath}`, entryPath);
26831
26882
  }
26832
26883
  const parts = candidate.split("/");
26833
- if (parts.some((part) => !part || part === "." || part === "..") || path10.posix.normalize(candidate) !== candidate) {
26884
+ if (parts.some((part) => !part || part === "." || part === "..") || path11.posix.normalize(candidate) !== candidate) {
26834
26885
  throw new AppPackageValidationError(`Unsafe package path: ${entryPath}`, entryPath);
26835
26886
  }
26836
26887
  }
@@ -26932,7 +26983,7 @@ function openEntry(zipFile, entry) {
26932
26983
  }
26933
26984
  async function sha256File(filePath) {
26934
26985
  const hash = crypto4.createHash("sha256");
26935
- await pipeline(fs8.createReadStream(filePath), new Transform5({
26986
+ await pipeline(fs9.createReadStream(filePath), new Transform5({
26936
26987
  transform(chunk, _encoding, callback) {
26937
26988
  hash.update(chunk);
26938
26989
  callback(null, chunk);
@@ -26956,8 +27007,8 @@ function isRecord3(value2) {
26956
27007
 
26957
27008
  // packages/server-core/src/lib/app-db.ts
26958
27009
  var import_sql = __toESM(require_sql_wasm());
26959
- import fs9 from "node:fs";
26960
- import path11 from "node:path";
27010
+ import fs10 from "node:fs";
27011
+ import path12 from "node:path";
26961
27012
  import { AsyncLocalStorage } from "node:async_hooks";
26962
27013
 
26963
27014
  // packages/server-core/src/lib/runtime-errors.ts
@@ -26998,10 +27049,10 @@ function saveConnection(dbPath) {
26998
27049
  if (!entry) return;
26999
27050
  if (!entry.dirty) return;
27000
27051
  if (entry.transactionDepth > 0) return;
27001
- const dir = path11.dirname(dbPath);
27002
- if (!fs9.existsSync(dir)) fs9.mkdirSync(dir, { recursive: true });
27052
+ const dir = path12.dirname(dbPath);
27053
+ if (!fs10.existsSync(dir)) fs10.mkdirSync(dir, { recursive: true });
27003
27054
  const data = entry.db.export();
27004
- fs9.writeFileSync(dbPath, Buffer.from(data));
27055
+ fs10.writeFileSync(dbPath, Buffer.from(data));
27005
27056
  entry.dirty = false;
27006
27057
  }
27007
27058
  function evictConnectionForDbPath(dbPath) {
@@ -27050,8 +27101,8 @@ function execRawSql(dbPath, sql, params) {
27050
27101
  }
27051
27102
 
27052
27103
  // packages/server-core/src/lib/backend-contract.ts
27053
- import fs10 from "node:fs";
27054
- import path12 from "node:path";
27104
+ import fs11 from "node:fs";
27105
+ import path13 from "node:path";
27055
27106
  import { createHash } from "node:crypto";
27056
27107
 
27057
27108
  // packages/server-core/src/generated/platform-capabilities.ts
@@ -27344,7 +27395,7 @@ function discoverBackendFiles(projectDir, config, options2) {
27344
27395
  return relativePaths.filter((relativePath2) => relativePath2.endsWith(".json") && !isHostedActionFile(relativePath2)).sort().map((relativePath2) => {
27345
27396
  const normalized = normalizePath4(relativePath2);
27346
27397
  return {
27347
- absolutePath: path12.join(projectDir, normalized),
27398
+ absolutePath: path13.join(projectDir, normalized),
27348
27399
  relativePath: normalized,
27349
27400
  schemaUrl: "",
27350
27401
  kind: kindFromPath(normalized)
@@ -27362,17 +27413,17 @@ function isHostedActionFile(relativePath2) {
27362
27413
  return relativePath2.endsWith("/actions.manifest.json") || relativePath2.endsWith("/actions.bundle.mjs") || relativePath2 === "actions.manifest.json" || relativePath2 === "actions.bundle.mjs" || /(^|\/)actions\/.+\.(?:ts|tsx|js|mjs)$/.test(relativePath2);
27363
27414
  }
27364
27415
  function discoverByRoot(projectDir, root) {
27365
- const rootPath = path12.resolve(projectDir, root);
27416
+ const rootPath = path13.resolve(projectDir, root);
27366
27417
  if (!isInside2(projectDir, rootPath)) {
27367
27418
  throw new Error(`backend.root must stay inside project directory: ${root}`);
27368
27419
  }
27369
- if (!fs10.existsSync(rootPath) || !fs10.statSync(rootPath).isDirectory()) {
27420
+ if (!fs11.existsSync(rootPath) || !fs11.statSync(rootPath).isDirectory()) {
27370
27421
  throw new Error(`backend root does not exist: ${root}`);
27371
27422
  }
27372
- return walkFiles(rootPath).map((filePath) => normalizePath4(path12.relative(projectDir, filePath)));
27423
+ return walkFiles(rootPath).map((filePath) => normalizePath4(path13.relative(projectDir, filePath)));
27373
27424
  }
27374
27425
  function discoverByInclude(projectDir, patterns) {
27375
- const allProjectFiles = walkFiles(projectDir).map((filePath) => normalizePath4(path12.relative(projectDir, filePath)));
27426
+ const allProjectFiles = walkFiles(projectDir).map((filePath) => normalizePath4(path13.relative(projectDir, filePath)));
27376
27427
  const matched = /* @__PURE__ */ new Set();
27377
27428
  for (const pattern of patterns) {
27378
27429
  const regex = globToRegExp(normalizePath4(pattern));
@@ -27385,10 +27436,10 @@ function discoverByInclude(projectDir, patterns) {
27385
27436
  return Array.from(matched);
27386
27437
  }
27387
27438
  function walkFiles(dir) {
27388
- if (!fs10.existsSync(dir)) return [];
27439
+ if (!fs11.existsSync(dir)) return [];
27389
27440
  const result = [];
27390
- for (const entry of fs10.readdirSync(dir, { withFileTypes: true })) {
27391
- const entryPath = path12.join(dir, entry.name);
27441
+ for (const entry of fs11.readdirSync(dir, { withFileTypes: true })) {
27442
+ const entryPath = path13.join(dir, entry.name);
27392
27443
  if (entry.isDirectory()) {
27393
27444
  result.push(...walkFiles(entryPath));
27394
27445
  } else if (entry.isFile()) {
@@ -27398,7 +27449,7 @@ function walkFiles(dir) {
27398
27449
  return result;
27399
27450
  }
27400
27451
  function readBackendJson(file) {
27401
- const raw = fs10.readFileSync(file.absolutePath, "utf8");
27452
+ const raw = fs11.readFileSync(file.absolutePath, "utf8");
27402
27453
  const value2 = JSON.parse(raw);
27403
27454
  const schemaUrl = value2.$schema;
27404
27455
  if (typeof schemaUrl !== "string" || !schemaUrl.trim()) {
@@ -27957,7 +28008,7 @@ function extractSqlParams(sql) {
27957
28008
  return names;
27958
28009
  }
27959
28010
  function kindFromPath(relativePath2) {
27960
- const basename2 = path12.posix.basename(relativePath2);
28011
+ const basename2 = path13.posix.basename(relativePath2);
27961
28012
  if (basename2 === "schema.json") return "schema";
27962
28013
  if (basename2 === "queries.json") return "queries";
27963
28014
  if (basename2 === "mutations.json") return "mutations";
@@ -27986,8 +28037,8 @@ function normalizePath4(filePath) {
27986
28037
  return filePath.replace(/\\/g, "/");
27987
28038
  }
27988
28039
  function isInside2(root, candidate) {
27989
- const relative = path12.relative(path12.resolve(root), path12.resolve(candidate));
27990
- return relative === "" || !relative.startsWith("..") && !path12.isAbsolute(relative);
28040
+ const relative = path13.relative(path13.resolve(root), path13.resolve(candidate));
28041
+ return relative === "" || !relative.startsWith("..") && !path13.isAbsolute(relative);
27991
28042
  }
27992
28043
  function isRecord4(value2) {
27993
28044
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
@@ -28037,15 +28088,15 @@ function validateMigrationFilenames(filenames) {
28037
28088
  }
28038
28089
 
28039
28090
  // packages/localapp/src/project/backend.ts
28040
- import path14 from "node:path";
28091
+ import path15 from "node:path";
28041
28092
 
28042
28093
  // packages/localapp/src/project/files.ts
28043
28094
  import { constants as constants3 } from "node:fs";
28044
- import fs11 from "node:fs/promises";
28095
+ import fs12 from "node:fs/promises";
28045
28096
  import { randomUUID as randomUUID2 } from "node:crypto";
28046
- import path13 from "node:path";
28097
+ import path14 from "node:path";
28047
28098
  async function readProjectJson(projectDir, filename, hooks) {
28048
- const filePath = path13.join(projectDir, filename);
28099
+ const filePath = path14.join(projectDir, filename);
28049
28100
  const content = await readVerifiedFile(projectDir, filePath, filename, hooks);
28050
28101
  let value2;
28051
28102
  try {
@@ -28060,16 +28111,16 @@ async function collectProjectTree(options2) {
28060
28111
  const root = await resolveProjectDirectory(options2);
28061
28112
  if (root === void 0) return [];
28062
28113
  const files = [];
28063
- await collectTree(path13.resolve(options2.projectDir), root, root, options2.label, files, options2.hooks);
28114
+ await collectTree(path14.resolve(options2.projectDir), root, root, options2.label, files, options2.hooks);
28064
28115
  return files.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
28065
28116
  }
28066
28117
  async function captureRegularProjectFile(projectDir, filePath, label, hooks) {
28067
- const root = path13.resolve(projectDir);
28068
- const target = path13.resolve(filePath);
28118
+ const root = path14.resolve(projectDir);
28119
+ const target = path14.resolve(filePath);
28069
28120
  if (!isInside3(root, target) || target === root) throw unsafePath2(`${label} must stay inside the project`);
28070
- const ancestors = await captureDirectoryChain(root, path13.dirname(target), label);
28121
+ const ancestors = await captureDirectoryChain(root, path14.dirname(target), label);
28071
28122
  await hooks?.afterAncestorValidation?.(target);
28072
- const stat2 = await fs11.lstat(target, { bigint: true }).catch((error) => {
28123
+ const stat2 = await fs12.lstat(target, { bigint: true }).catch((error) => {
28073
28124
  if (error.code === "ENOENT") throw lifecycleError("project_file_missing", `${label} does not exist`);
28074
28125
  throw error;
28075
28126
  });
@@ -28081,17 +28132,17 @@ async function readVerifiedFile(projectDir, filePath, label, hooks) {
28081
28132
  return readValidatedRegularFile(filePath, label, captured, hooks);
28082
28133
  }
28083
28134
  async function resolveProjectDirectory(options2) {
28084
- const root = path13.resolve(options2.projectDir);
28135
+ const root = path14.resolve(options2.projectDir);
28085
28136
  const configured = options2.configuredPath.trim();
28086
- if (!configured || path13.isAbsolute(configured)) {
28137
+ if (!configured || path14.isAbsolute(configured)) {
28087
28138
  throw unsafePath2(`${options2.label} must be a non-empty relative path inside the project`);
28088
28139
  }
28089
- const target = path13.resolve(root, configured);
28140
+ const target = path14.resolve(root, configured);
28090
28141
  if (!isInside3(root, target) || target === root) {
28091
28142
  throw unsafePath2(`${options2.label} must stay inside the project and must not be the project root`);
28092
28143
  }
28093
28144
  await assertPathChainHasNoSymlinks(root, target, options2.label, !options2.required);
28094
- const stat2 = await fs11.lstat(target).catch((error) => {
28145
+ const stat2 = await fs12.lstat(target).catch((error) => {
28095
28146
  if (error.code === "ENOENT" && !options2.required) return void 0;
28096
28147
  if (error.code === "ENOENT") throw lifecycleError("project_directory_missing", `${options2.label} does not exist: ${options2.configuredPath}`);
28097
28148
  throw error;
@@ -28102,18 +28153,18 @@ async function resolveProjectDirectory(options2) {
28102
28153
  }
28103
28154
  async function resolveSafePackageOutput(options2) {
28104
28155
  const configured = options2.outputPath ?? `${options2.defaultName}.localapp`;
28105
- const outputPath = path13.resolve(options2.projectDir, configured);
28106
- if (path13.extname(outputPath) !== ".localapp") {
28156
+ const outputPath = path14.resolve(options2.projectDir, configured);
28157
+ if (path14.extname(outputPath) !== ".localapp") {
28107
28158
  throw lifecycleError("invalid_package_output", "Application package output must use the .localapp extension");
28108
28159
  }
28109
28160
  for (const protectedDirectory of options2.protectedDirectories) {
28110
- const protectedPath = path13.resolve(options2.projectDir, protectedDirectory);
28161
+ const protectedPath = path14.resolve(options2.projectDir, protectedDirectory);
28111
28162
  if (isInside3(protectedPath, outputPath)) {
28112
28163
  throw lifecycleError("invalid_package_output", "Application package output must be outside dist, migrations, and backend source directories");
28113
28164
  }
28114
28165
  }
28115
28166
  await assertExistingOutputChainHasNoSymlinks(outputPath);
28116
- const stat2 = await fs11.lstat(outputPath).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
28167
+ const stat2 = await fs12.lstat(outputPath).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
28117
28168
  if (stat2 !== void 0 && (stat2.isSymbolicLink() || !stat2.isFile())) {
28118
28169
  throw unsafePath2("Application package output must be a regular file without symlinks");
28119
28170
  }
@@ -28123,28 +28174,28 @@ async function resolveSafePackageOutput(options2) {
28123
28174
  return { path: outputPath, exists: stat2 !== void 0 };
28124
28175
  }
28125
28176
  async function preparePackageOutput(outputPath, overwrite) {
28126
- const parentPath = path13.dirname(outputPath);
28127
- await fs11.mkdir(parentPath, { recursive: true, mode: 448 });
28177
+ const parentPath = path14.dirname(outputPath);
28178
+ await fs12.mkdir(parentPath, { recursive: true, mode: 448 });
28128
28179
  await assertExistingOutputChainHasNoSymlinks(parentPath);
28129
- const parentStat = await fs11.lstat(parentPath, { bigint: true });
28180
+ const parentStat = await fs12.lstat(parentPath, { bigint: true });
28130
28181
  if (parentStat.isSymbolicLink() || !parentStat.isDirectory()) {
28131
28182
  throw unsafePath2("Application package output parent must be a directory without symlinks");
28132
28183
  }
28133
- const outputStat = await fs11.lstat(outputPath, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
28184
+ const outputStat = await fs12.lstat(outputPath, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
28134
28185
  if (outputStat !== void 0 && (outputStat.isSymbolicLink() || !outputStat.isFile())) {
28135
28186
  throw unsafePath2("Application package output must be a regular file without symlinks");
28136
28187
  }
28137
28188
  if (outputStat !== void 0 && !overwrite) throw packageOutputExists();
28138
28189
  return {
28139
28190
  path: outputPath,
28140
- temporaryPath: path13.join(parentPath, `.${path13.basename(outputPath)}.${process.pid}.${randomUUID2()}.tmp`),
28191
+ temporaryPath: path14.join(parentPath, `.${path14.basename(outputPath)}.${process.pid}.${randomUUID2()}.tmp`),
28141
28192
  parent: { path: parentPath, dev: parentStat.dev, ino: parentStat.ino },
28142
28193
  overwrite
28143
28194
  };
28144
28195
  }
28145
28196
  async function capturePreparedTemporary(prepared) {
28146
28197
  await verifyPreparedParent(prepared);
28147
- const stat2 = await fs11.lstat(prepared.temporaryPath, { bigint: true });
28198
+ const stat2 = await fs12.lstat(prepared.temporaryPath, { bigint: true });
28148
28199
  if (stat2.isSymbolicLink() || !stat2.isFile()) throw unsafePath2("Application package temporary output is unsafe");
28149
28200
  return { dev: stat2.dev, ino: stat2.ino, size: Number(stat2.size) };
28150
28201
  }
@@ -28156,14 +28207,14 @@ function normalizeArchiveRelativePath(value2, label) {
28156
28207
  return normalized;
28157
28208
  }
28158
28209
  function asyncReaddir(directory) {
28159
- return fs11.readdir(directory, { withFileTypes: true });
28210
+ return fs12.readdir(directory, { withFileTypes: true });
28160
28211
  }
28161
28212
  async function collectTree(projectDir, root, current, label, files, hooks) {
28162
28213
  const entries = (await asyncReaddir(current)).sort((left, right) => left.name.localeCompare(right.name));
28163
28214
  for (const entry of entries) {
28164
- const absolutePath = path13.join(current, entry.name);
28165
- const relativePath2 = path13.relative(root, absolutePath).replaceAll(path13.sep, "/");
28166
- const stat2 = await fs11.lstat(absolutePath, { bigint: true });
28215
+ const absolutePath = path14.join(current, entry.name);
28216
+ const relativePath2 = path14.relative(root, absolutePath).replaceAll(path14.sep, "/");
28217
+ const stat2 = await fs12.lstat(absolutePath, { bigint: true });
28167
28218
  if (stat2.isSymbolicLink()) throw unsafePath2(`${label} must not contain symlinks: ${relativePath2}`);
28168
28219
  if (stat2.isDirectory()) {
28169
28220
  await collectTree(projectDir, root, absolutePath, label, files, hooks);
@@ -28181,13 +28232,13 @@ async function collectTree(projectDir, root, current, label, files, hooks) {
28181
28232
  async function readValidatedRegularFile(filePath, label, expected, hooks) {
28182
28233
  await hooks?.beforeOpen?.(filePath);
28183
28234
  const flags = process.platform !== "win32" && typeof constants3.O_NOFOLLOW === "number" ? constants3.O_RDONLY | constants3.O_NOFOLLOW : "r";
28184
- const handle = await fs11.open(filePath, flags).catch(() => {
28235
+ const handle = await fs12.open(filePath, flags).catch(() => {
28185
28236
  throw unsafePath2(`${label} changed before it could be opened safely`);
28186
28237
  });
28187
28238
  try {
28188
28239
  const opened = await handle.stat({ bigint: true });
28189
28240
  await verifyDirectoryChain(expected.ancestors, label);
28190
- const current = await fs11.lstat(filePath, { bigint: true }).catch(() => void 0);
28241
+ const current = await fs12.lstat(filePath, { bigint: true }).catch(() => void 0);
28191
28242
  if (current === void 0 || current.isSymbolicLink() || !current.isFile() || current.dev !== expected.file.dev || current.ino !== expected.file.ino || !opened.isFile() || opened.dev !== expected.file.dev || opened.ino !== expected.file.ino) {
28192
28243
  throw unsafePath2(`${label} changed before it could be read safely`);
28193
28244
  }
@@ -28197,17 +28248,17 @@ async function readValidatedRegularFile(filePath, label, expected, hooks) {
28197
28248
  }
28198
28249
  }
28199
28250
  async function captureDirectoryChain(root, target, label) {
28200
- const relative = path13.relative(root, target);
28201
- if (relative.startsWith("..") || path13.isAbsolute(relative)) throw unsafePath2(`${label} escaped the project`);
28251
+ const relative = path14.relative(root, target);
28252
+ if (relative.startsWith("..") || path14.isAbsolute(relative)) throw unsafePath2(`${label} escaped the project`);
28202
28253
  const directories = [root];
28203
28254
  let current = root;
28204
- for (const component of relative.split(path13.sep).filter(Boolean)) {
28205
- current = path13.join(current, component);
28255
+ for (const component of relative.split(path14.sep).filter(Boolean)) {
28256
+ current = path14.join(current, component);
28206
28257
  directories.push(current);
28207
28258
  }
28208
28259
  const identities = [];
28209
28260
  for (const directory of directories) {
28210
- const stat2 = await fs11.lstat(directory, { bigint: true }).catch(() => void 0);
28261
+ const stat2 = await fs12.lstat(directory, { bigint: true }).catch(() => void 0);
28211
28262
  if (stat2 === void 0 || stat2.isSymbolicLink() || !stat2.isDirectory()) {
28212
28263
  throw unsafePath2(`${label} must not contain symlinks`);
28213
28264
  }
@@ -28217,21 +28268,21 @@ async function captureDirectoryChain(root, target, label) {
28217
28268
  }
28218
28269
  async function verifyDirectoryChain(expected, label) {
28219
28270
  for (const directory of expected) {
28220
- const stat2 = await fs11.lstat(directory.path, { bigint: true }).catch(() => void 0);
28271
+ const stat2 = await fs12.lstat(directory.path, { bigint: true }).catch(() => void 0);
28221
28272
  if (stat2 === void 0 || stat2.isSymbolicLink() || !stat2.isDirectory() || stat2.dev !== directory.dev || stat2.ino !== directory.ino) {
28222
28273
  throw unsafePath2(`${label} changed before it could be read safely`);
28223
28274
  }
28224
28275
  }
28225
28276
  }
28226
28277
  async function assertPathChainHasNoSymlinks(root, target, label, allowMissingTail = false) {
28227
- const relative = path13.relative(root, target);
28228
- if (relative.startsWith("..") || path13.isAbsolute(relative)) throw unsafePath2(`${label} escaped the project`);
28278
+ const relative = path14.relative(root, target);
28279
+ if (relative.startsWith("..") || path14.isAbsolute(relative)) throw unsafePath2(`${label} escaped the project`);
28229
28280
  let current = root;
28230
- const rootStat = await fs11.lstat(root);
28281
+ const rootStat = await fs12.lstat(root);
28231
28282
  if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) throw unsafePath2("Project directory must not be symlinked");
28232
- for (const component of relative.split(path13.sep).filter(Boolean)) {
28233
- current = path13.join(current, component);
28234
- const stat2 = await fs11.lstat(current).catch((error) => {
28283
+ for (const component of relative.split(path14.sep).filter(Boolean)) {
28284
+ current = path14.join(current, component);
28285
+ const stat2 = await fs12.lstat(current).catch((error) => {
28235
28286
  if (allowMissingTail && error.code === "ENOENT") return void 0;
28236
28287
  throw error;
28237
28288
  });
@@ -28240,26 +28291,26 @@ async function assertPathChainHasNoSymlinks(root, target, label, allowMissingTai
28240
28291
  }
28241
28292
  }
28242
28293
  async function assertExistingOutputChainHasNoSymlinks(outputPath) {
28243
- const parsed = path13.parse(outputPath);
28244
- const components = outputPath.slice(parsed.root.length).split(path13.sep).filter(Boolean);
28294
+ const parsed = path14.parse(outputPath);
28295
+ const components = outputPath.slice(parsed.root.length).split(path14.sep).filter(Boolean);
28245
28296
  let current = parsed.root;
28246
28297
  for (const component of components) {
28247
- current = path13.join(current, component);
28248
- const stat2 = await fs11.lstat(current).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
28298
+ current = path14.join(current, component);
28299
+ const stat2 = await fs12.lstat(current).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
28249
28300
  if (stat2 === void 0) return;
28250
28301
  if (stat2.isSymbolicLink()) throw unsafePath2("Application package output path must not contain symlinks");
28251
28302
  }
28252
28303
  }
28253
28304
  async function verifyPreparedParent(prepared) {
28254
28305
  await assertExistingOutputChainHasNoSymlinks(prepared.parent.path);
28255
- const stat2 = await fs11.lstat(prepared.parent.path, { bigint: true });
28306
+ const stat2 = await fs12.lstat(prepared.parent.path, { bigint: true });
28256
28307
  if (stat2.isSymbolicLink() || !stat2.isDirectory() || stat2.dev !== prepared.parent.dev || stat2.ino !== prepared.parent.ino) {
28257
28308
  throw unsafePath2("Application package output parent changed during publication");
28258
28309
  }
28259
28310
  }
28260
28311
  function isInside3(root, target) {
28261
- const relative = path13.relative(root, target);
28262
- return relative === "" || !relative.startsWith(`..${path13.sep}`) && relative !== ".." && !path13.isAbsolute(relative);
28312
+ const relative = path14.relative(root, target);
28313
+ return relative === "" || !relative.startsWith(`..${path14.sep}`) && relative !== ".." && !path14.isAbsolute(relative);
28263
28314
  }
28264
28315
  function unsafePath2(message) {
28265
28316
  return lifecycleError("unsafe_project_path", message);
@@ -28320,7 +28371,7 @@ function validateBackendConfig(config) {
28320
28371
  }
28321
28372
  for (const pattern of config.include ?? []) {
28322
28373
  const normalized = pattern.replaceAll("\\", "/");
28323
- if (path14.posix.isAbsolute(normalized) || normalized.split("/").includes("..")) {
28374
+ if (path15.posix.isAbsolute(normalized) || normalized.split("/").includes("..")) {
28324
28375
  throw new Error(`manifest backend.include must stay inside the project: ${pattern}`);
28325
28376
  }
28326
28377
  }
@@ -28340,7 +28391,7 @@ var CHECK_PHASES = ["project", "capabilities", "migrations", "backend", "tests",
28340
28391
  var RESERVED_NAMES2 = /* @__PURE__ */ new Set(["api", "serve", "health", "cli", "keys", "upload", "pages", "schemas"]);
28341
28392
  async function checkProject(options2) {
28342
28393
  throwIfCheckAborted(options2.signal);
28343
- const projectDir = path15.resolve(options2.projectDir);
28394
+ const projectDir = path16.resolve(options2.projectDir);
28344
28395
  const report = createReport();
28345
28396
  let manifest;
28346
28397
  try {
@@ -28488,7 +28539,7 @@ async function detectPackageManager(projectDir, packageJson) {
28488
28539
  ["npm-shrinkwrap.json", "npm"]
28489
28540
  ];
28490
28541
  for (const [filename, manager] of locks) {
28491
- if (await fs12.access(path15.join(projectDir, filename)).then(() => true, () => false)) return manager;
28542
+ if (await fs13.access(path16.join(projectDir, filename)).then(() => true, () => false)) return manager;
28492
28543
  }
28493
28544
  return "npm";
28494
28545
  }
@@ -28670,7 +28721,7 @@ function compareVersion(left, right) {
28670
28721
  }
28671
28722
  function validateRelativeDirectory(value2, label) {
28672
28723
  const normalized = value2.replaceAll("\\", "/");
28673
- if (!normalized || path15.posix.isAbsolute(normalized) || normalized.split("/").includes("..") || normalized.split("/").filter((part) => part && part !== ".").length === 0) {
28724
+ if (!normalized || path16.posix.isAbsolute(normalized) || normalized.split("/").includes("..") || normalized.split("/").filter((part) => part && part !== ".").length === 0) {
28674
28725
  throw new Error(`${label} must be a relative directory inside the project`);
28675
28726
  }
28676
28727
  }
@@ -28731,10 +28782,10 @@ async function check(io, json) {
28731
28782
 
28732
28783
  // packages/localapp/src/project/package.ts
28733
28784
  import { spawn as spawn3 } from "node:child_process";
28734
- import path16 from "node:path";
28785
+ import path17 from "node:path";
28735
28786
  async function buildApplicationPackage(options2) {
28736
28787
  throwIfPackageBuildAborted(options2.signal);
28737
- const projectDir = path16.resolve(options2.projectDir);
28788
+ const projectDir = path17.resolve(options2.projectDir);
28738
28789
  const manifest = await loadAndValidateProjectManifest(projectDir, options2.fileHooks);
28739
28790
  throwIfPackageBuildAborted(options2.signal);
28740
28791
  const backendRoot = manifest.backend?.root ?? "backend";
@@ -28967,8 +29018,8 @@ async function createAnchoredPackageCandidate(prepared, hooks, signal) {
28967
29018
  const config = Buffer.from(JSON.stringify({
28968
29019
  dev: prepared.parent.dev.toString(),
28969
29020
  ino: prepared.parent.ino.toString(),
28970
- temporary: path16.basename(prepared.temporaryPath),
28971
- target: path16.basename(prepared.path),
29021
+ temporary: path17.basename(prepared.temporaryPath),
29022
+ target: path17.basename(prepared.path),
28972
29023
  overwrite: prepared.overwrite
28973
29024
  })).toString("base64url");
28974
29025
  const child = spawn3(process.execPath, ["--input-type=commonjs", "--eval", PACKAGE_OUTPUT_HELPER, config], {
@@ -29127,22 +29178,22 @@ async function buildPackage(output, io) {
29127
29178
  }
29128
29179
 
29129
29180
  // packages/localapp/src/commands/app-install.ts
29130
- import fs14 from "node:fs/promises";
29131
- import path18 from "node:path";
29181
+ import fs15 from "node:fs/promises";
29182
+ import path19 from "node:path";
29132
29183
 
29133
29184
  // packages/localapp/src/project/target.ts
29134
- import fs13 from "node:fs/promises";
29135
- import path17 from "node:path";
29185
+ import fs14 from "node:fs/promises";
29186
+ import path18 from "node:path";
29136
29187
  async function resolveProjectTarget(options2) {
29137
29188
  const defaultProfile = await readDefaultProfile(options2.projectDir, options2.readHooks);
29138
29189
  const store = options2.profileStore ?? new ProfileStore();
29139
29190
  return store.resolve(options2.target ?? defaultProfile);
29140
29191
  }
29141
29192
  async function readDefaultProfile(projectDir, hooks) {
29142
- const root = await captureDirectory(path17.resolve(projectDir));
29193
+ const root = await captureDirectory(path18.resolve(projectDir));
29143
29194
  if (root === void 0) throw unsafePath();
29144
- const localAppDirectory = path17.join(root.path, ".localapp");
29145
- const publishPath = path17.join(localAppDirectory, "publish.json");
29195
+ const localAppDirectory = path18.join(root.path, ".localapp");
29196
+ const publishPath = path18.join(localAppDirectory, "publish.json");
29146
29197
  const directory = await captureDirectory(localAppDirectory);
29147
29198
  if (directory === void 0) {
29148
29199
  await verifyDirectory(root);
@@ -29176,7 +29227,7 @@ async function readDefaultProfile(projectDir, hooks) {
29176
29227
  async function captureDirectory(target) {
29177
29228
  let stat2;
29178
29229
  try {
29179
- stat2 = await fs13.lstat(target, { bigint: true });
29230
+ stat2 = await fs14.lstat(target, { bigint: true });
29180
29231
  } catch (error) {
29181
29232
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") return void 0;
29182
29233
  throw lifecycleError("publish_config_unreadable", "Cannot safely read .localapp/publish.json");
@@ -29185,14 +29236,14 @@ async function captureDirectory(target) {
29185
29236
  return { path: target, device: stat2.dev, inode: stat2.ino };
29186
29237
  }
29187
29238
  async function verifyDirectory(expected) {
29188
- const stat2 = await fs13.lstat(expected.path, { bigint: true }).catch(() => void 0);
29239
+ const stat2 = await fs14.lstat(expected.path, { bigint: true }).catch(() => void 0);
29189
29240
  if (stat2 === void 0 || stat2.isSymbolicLink() || !stat2.isDirectory() || stat2.dev !== expected.device || stat2.ino !== expected.inode) {
29190
29241
  throw unsafePath();
29191
29242
  }
29192
29243
  }
29193
29244
  async function lstatOrAbsent(target) {
29194
29245
  try {
29195
- return await fs13.lstat(target);
29246
+ return await fs14.lstat(target);
29196
29247
  } catch (error) {
29197
29248
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") return void 0;
29198
29249
  throw lifecycleError("publish_config_unreadable", "Cannot safely read .localapp/publish.json");
@@ -29207,7 +29258,7 @@ function invalidPublishConfig() {
29207
29258
 
29208
29259
  // packages/localapp/src/commands/app-install.ts
29209
29260
  async function installApplication(options2) {
29210
- const projectDir = path18.resolve(options2.projectDir);
29261
+ const projectDir = path19.resolve(options2.projectDir);
29211
29262
  const target = await resolveProjectTarget({ projectDir, target: options2.target, profileStore: options2.profileStore });
29212
29263
  const packagePath = options2.packagePath === void 0 ? (await buildApplicationPackage({ projectDir })).path : await inspectExplicitPackage(options2.packagePath);
29213
29264
  const response = await new LocalAppClient(target).installPackage(packagePath);
@@ -29219,11 +29270,11 @@ async function installApplication(options2) {
29219
29270
  async function inspectExplicitPackage(input) {
29220
29271
  let packagePath;
29221
29272
  try {
29222
- packagePath = await fs14.realpath(input);
29273
+ packagePath = await fs15.realpath(input);
29223
29274
  } catch {
29224
29275
  throw lifecycleError("application_package_invalid", "Application package is invalid");
29225
29276
  }
29226
- if (path18.extname(packagePath).toLowerCase() !== ".localapp") {
29277
+ if (path19.extname(packagePath).toLowerCase() !== ".localapp") {
29227
29278
  throw lifecycleError("application_package_invalid", "Application package must use the .localapp extension");
29228
29279
  }
29229
29280
  try {
@@ -29302,26 +29353,26 @@ function safeResponseMessage2(response, credential, fallback) {
29302
29353
  // packages/localapp/src/commands/dev.ts
29303
29354
  import { randomBytes as randomBytes2 } from "node:crypto";
29304
29355
  import { chmodSync, renameSync } from "node:fs";
29305
- import fs18 from "node:fs/promises";
29356
+ import fs19 from "node:fs/promises";
29306
29357
  import net from "node:net";
29307
- import path23 from "node:path";
29358
+ import path24 from "node:path";
29308
29359
  import { fileURLToPath as fileURLToPath4 } from "node:url";
29309
29360
 
29310
29361
  // packages/localapp/src/dev/credentials.ts
29311
29362
  import { randomBytes } from "node:crypto";
29312
- import fs15 from "node:fs/promises";
29313
- import path19 from "node:path";
29363
+ import fs16 from "node:fs/promises";
29364
+ import path20 from "node:path";
29314
29365
  var API_KEY_PATTERN = /^localapp_dev_[0-9a-f]{64}$/;
29315
29366
  var PASSWORD_PATTERN = /^localapp_dev_password_[0-9a-f]{64}$/;
29316
29367
  var JWT_SECRET_PATTERN = /^[A-Za-z0-9_-]{43}$/;
29317
29368
  async function readOrCreateDevCredentials(projectDir) {
29318
- const stateRoot = path19.join(path19.resolve(projectDir), "tmp/localapp-dev");
29319
- await fs15.mkdir(stateRoot, { recursive: true, mode: 448 });
29320
- if (process.platform !== "win32") await fs15.chmod(stateRoot, 448);
29369
+ const stateRoot = path20.join(path20.resolve(projectDir), "tmp/localapp-dev");
29370
+ await fs16.mkdir(stateRoot, { recursive: true, mode: 448 });
29371
+ if (process.platform !== "win32") await fs16.chmod(stateRoot, 448);
29321
29372
  const paths = {
29322
- apiKey: path19.join(stateRoot, "server-api-key"),
29323
- password: path19.join(stateRoot, "server-password"),
29324
- jwtSecret: path19.join(stateRoot, "server-jwt-secret")
29373
+ apiKey: path20.join(stateRoot, "server-api-key"),
29374
+ password: path20.join(stateRoot, "server-password"),
29375
+ jwtSecret: path20.join(stateRoot, "server-jwt-secret")
29325
29376
  };
29326
29377
  const [apiKey, password, jwtSecret] = await Promise.all([
29327
29378
  readOrCreatePrivateValue(paths.apiKey, API_KEY_PATTERN, () => `localapp_dev_${randomBytes(32).toString("hex")}`),
@@ -29336,7 +29387,7 @@ async function readOrCreatePrivateValue(filePath, pattern, generate) {
29336
29387
  const generated = generate();
29337
29388
  let handle;
29338
29389
  try {
29339
- handle = await fs15.open(filePath, "wx", 384);
29390
+ handle = await fs16.open(filePath, "wx", 384);
29340
29391
  await handle.writeFile(`${generated}
29341
29392
  `, "utf8");
29342
29393
  await handle.sync();
@@ -29348,20 +29399,20 @@ async function readOrCreatePrivateValue(filePath, pattern, generate) {
29348
29399
  } finally {
29349
29400
  await handle?.close();
29350
29401
  }
29351
- if (process.platform !== "win32") await fs15.chmod(filePath, 384);
29402
+ if (process.platform !== "win32") await fs16.chmod(filePath, 384);
29352
29403
  return generated;
29353
29404
  }
29354
29405
  async function readPrivateValue(filePath) {
29355
29406
  let stat2;
29356
29407
  try {
29357
- stat2 = await fs15.lstat(filePath);
29408
+ stat2 = await fs16.lstat(filePath);
29358
29409
  } catch (error) {
29359
29410
  if (error.code === "ENOENT") return void 0;
29360
29411
  throw privateCredentialError(filePath);
29361
29412
  }
29362
29413
  if (stat2.isSymbolicLink() || !stat2.isFile()) throw privateCredentialError(filePath);
29363
- if (process.platform !== "win32") await fs15.chmod(filePath, 384);
29364
- const value2 = (await fs15.readFile(filePath, "utf8")).trim();
29414
+ if (process.platform !== "win32") await fs16.chmod(filePath, 384);
29415
+ const value2 = (await fs16.readFile(filePath, "utf8")).trim();
29365
29416
  if (!value2) throw privateCredentialError(filePath);
29366
29417
  return value2;
29367
29418
  }
@@ -29379,17 +29430,17 @@ import { spawn as spawn5 } from "node:child_process";
29379
29430
  // packages/localapp/src/native/native-adapter.ts
29380
29431
  import { spawn as spawn4 } from "node:child_process";
29381
29432
  import { existsSync } from "node:fs";
29382
- import fs17 from "node:fs/promises";
29433
+ import fs18 from "node:fs/promises";
29383
29434
  import { homedir as homedir2 } from "node:os";
29384
- import path22 from "node:path";
29435
+ import path23 from "node:path";
29385
29436
 
29386
29437
  // packages/localapp/src/artifact-directory.ts
29387
29438
  import { realpathSync } from "node:fs";
29388
- import path20 from "node:path";
29439
+ import path21 from "node:path";
29389
29440
  import { fileURLToPath as fileURLToPath3 } from "node:url";
29390
29441
  function artifactDirectoryFromEntrypoint(entrypoint) {
29391
29442
  const canonical = realpathSync(entrypoint);
29392
- return path20.resolve(path20.dirname(canonical), "..");
29443
+ return path21.resolve(path21.dirname(canonical), "..");
29393
29444
  }
29394
29445
  function localAppArtifactDirectory(entrypoint = process.argv[1]) {
29395
29446
  if (entrypoint !== void 0 && entrypoint.length > 0) {
@@ -29398,7 +29449,7 @@ function localAppArtifactDirectory(entrypoint = process.argv[1]) {
29398
29449
  } catch {
29399
29450
  }
29400
29451
  }
29401
- return path20.resolve(path20.dirname(fileURLToPath3(import.meta.url)), "..");
29452
+ return path21.resolve(path21.dirname(fileURLToPath3(import.meta.url)), "..");
29402
29453
  }
29403
29454
 
29404
29455
  // packages/server/src/lib/device-action-types.ts
@@ -29524,27 +29575,27 @@ function invalid2() {
29524
29575
 
29525
29576
  // packages/localapp/src/native/adapter-selection.ts
29526
29577
  import crypto5 from "node:crypto";
29527
- import fs16 from "node:fs/promises";
29528
- import path21 from "node:path";
29578
+ import fs17 from "node:fs/promises";
29579
+ import path22 from "node:path";
29529
29580
  async function selectNativeAdapter(options2) {
29530
29581
  const platform = options2.platform ?? process.platform;
29531
29582
  const arch = options2.arch ?? process.arch;
29532
29583
  const target = targetFor(platform, arch);
29533
- const root = path21.resolve(options2.root);
29584
+ const root = path22.resolve(options2.root);
29534
29585
  let value2;
29535
29586
  try {
29536
- value2 = JSON.parse(await fs16.readFile(path21.join(root, "adapter-manifest.json"), "utf8"));
29587
+ value2 = JSON.parse(await fs17.readFile(path22.join(root, "adapter-manifest.json"), "utf8"));
29537
29588
  } catch {
29538
29589
  throw unsupported(platform, arch);
29539
29590
  }
29540
29591
  const manifest = parseManifest(value2, target, root, platform, arch);
29541
29592
  for (const asset of manifest.assets) {
29542
- const absolute = path21.join(root, ...asset.path.split("/"));
29593
+ const absolute = path22.join(root, ...asset.path.split("/"));
29543
29594
  let bytes;
29544
29595
  try {
29545
- const stat2 = await fs16.lstat(absolute);
29596
+ const stat2 = await fs17.lstat(absolute);
29546
29597
  if (!stat2.isFile() || stat2.isSymbolicLink()) throw new Error("unsafe native asset");
29547
- bytes = await fs16.readFile(absolute);
29598
+ bytes = await fs17.readFile(absolute);
29548
29599
  } catch {
29549
29600
  throw lifecycleError("native_adapter_digest_invalid", "The selected LocalApp native adapter is missing or unsafe");
29550
29601
  }
@@ -29560,8 +29611,8 @@ async function selectNativeAdapter(options2) {
29560
29611
  return {
29561
29612
  target,
29562
29613
  root,
29563
- executable: path21.join(root, ...executable.split("/")),
29564
- ipcClient: path21.join(root, ...ipcClient.split("/")),
29614
+ executable: path22.join(root, ...executable.split("/")),
29615
+ ipcClient: path22.join(root, ...ipcClient.split("/")),
29565
29616
  signing: manifest.signing,
29566
29617
  assets: manifest.assets
29567
29618
  };
@@ -29594,7 +29645,7 @@ function parseSingleManifest(value2, target, root, platform, arch) {
29594
29645
  throw unsupported(platform, arch);
29595
29646
  }
29596
29647
  const assets = value2.assets.map((asset) => {
29597
- if (!record(asset) || !exactKeys(asset, ["path", "sha256"]) || typeof asset.path !== "string" || typeof asset.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(asset.sha256) || !safeRelativeAsset(asset.path) || !asset.path.startsWith(`${target}/`) || path21.resolve(root, ...asset.path.split("/")).startsWith(`${root}${path21.sep}`) === false) {
29648
+ if (!record(asset) || !exactKeys(asset, ["path", "sha256"]) || typeof asset.path !== "string" || typeof asset.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(asset.sha256) || !safeRelativeAsset(asset.path) || !asset.path.startsWith(`${target}/`) || path22.resolve(root, ...asset.path.split("/")).startsWith(`${root}${path22.sep}`) === false) {
29598
29649
  throw unsupported(platform, arch);
29599
29650
  }
29600
29651
  return { path: asset.path, sha256: asset.sha256 };
@@ -29603,7 +29654,7 @@ function parseSingleManifest(value2, target, root, platform, arch) {
29603
29654
  return { signing: { mode: value2.signing.mode }, assets };
29604
29655
  }
29605
29656
  function safeRelativeAsset(value2) {
29606
- return value2.length > 0 && value2.length <= 512 && !value2.includes("\\") && !value2.startsWith("/") && !value2.endsWith("/") && path21.posix.normalize(value2) === value2 && value2.split("/").every((part) => part && part !== "." && part !== "..");
29657
+ return value2.length > 0 && value2.length <= 512 && !value2.includes("\\") && !value2.startsWith("/") && !value2.endsWith("/") && path22.posix.normalize(value2) === value2 && value2.split("/").every((part) => part && part !== "." && part !== "..");
29607
29658
  }
29608
29659
  function record(value2) {
29609
29660
  return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
@@ -29720,12 +29771,12 @@ function validateNativeNotificationEnvelope(value2, platform = process.platform)
29720
29771
  async function installLinuxScheme(options2) {
29721
29772
  if (!safeAbsoluteLocalPath(options2.dataHome, "linux")) throw lifecycleError("native_adapter_invalid", "The Linux data directory is invalid");
29722
29773
  const desktop = buildLinuxDesktopEntry(options2.nodePath, options2.ipcClientPath);
29723
- const applications = path22.posix.join(options2.dataHome, "applications");
29774
+ const applications = path23.posix.join(options2.dataHome, "applications");
29724
29775
  const filename = "localapp.desktop";
29725
- const destination = path22.posix.join(applications, filename);
29726
- await fs17.mkdir(applications, { recursive: true, mode: 448 });
29727
- const current = await fs17.readFile(destination, "utf8").catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
29728
- if (current !== desktop) await fs17.writeFile(destination, desktop, { mode: 420 });
29776
+ const destination = path23.posix.join(applications, filename);
29777
+ await fs18.mkdir(applications, { recursive: true, mode: 448 });
29778
+ const current = await fs18.readFile(destination, "utf8").catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
29779
+ if (current !== desktop) await fs18.writeFile(destination, desktop, { mode: 420 });
29729
29780
  await options2.run("xdg-mime", ["default", filename, "x-scheme-handler/localapp"]);
29730
29781
  }
29731
29782
  function buildLinuxDesktopEntry(nodePath, ipcClientPath) {
@@ -29754,9 +29805,9 @@ async function writeBridgeConfiguration(options2) {
29754
29805
  if (options2.environment !== void 0) configuration.environment = options2.environment;
29755
29806
  const content = `${JSON.stringify(configuration)}
29756
29807
  `;
29757
- await fs17.mkdir(path22.dirname(options2.configPath), { recursive: true, mode: 448 });
29758
- const current = await fs17.readFile(options2.configPath, "utf8").catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
29759
- if (current !== content) await fs17.writeFile(options2.configPath, content, { mode: 384 });
29808
+ await fs18.mkdir(path23.dirname(options2.configPath), { recursive: true, mode: 448 });
29809
+ const current = await fs18.readFile(options2.configPath, "utf8").catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
29810
+ if (current !== content) await fs18.writeFile(options2.configPath, content, { mode: 384 });
29760
29811
  }
29761
29812
  function bridgeRuntimeEnvironment(env, platform) {
29762
29813
  const keys = ["LOCALAPP_SUPPORT_DIR", "LOCALAPP_RUNTIME_DIR", "LOCALAPP_DATA_DIR"];
@@ -29770,13 +29821,13 @@ function bridgeRuntimeEnvironment(env, platform) {
29770
29821
  return Object.keys(environment).length === 0 ? void 0 : environment;
29771
29822
  }
29772
29823
  function nativeBridgeConfigPath(platform, supportDir, env) {
29773
- if (supportDir !== void 0) return platform === "win32" ? path22.win32.join(supportDir, "native-bridge.json") : path22.join(supportDir, "native-bridge.json");
29774
- if (platform === "darwin") return path22.join(homedir2(), "Library", "Application Support", "LocalApp", "native-bridge.json");
29775
- if (platform === "win32") return path22.win32.join(env.LOCALAPPDATA ?? path22.win32.join(homedir2(), "AppData", "Local"), "LocalApp", "native-bridge.json");
29776
- return path22.join(env.XDG_DATA_HOME ?? path22.join(homedir2(), ".local", "share"), "localapp", "native-bridge.json");
29824
+ if (supportDir !== void 0) return platform === "win32" ? path23.win32.join(supportDir, "native-bridge.json") : path23.join(supportDir, "native-bridge.json");
29825
+ if (platform === "darwin") return path23.join(homedir2(), "Library", "Application Support", "LocalApp", "native-bridge.json");
29826
+ if (platform === "win32") return path23.win32.join(env.LOCALAPPDATA ?? path23.win32.join(homedir2(), "AppData", "Local"), "LocalApp", "native-bridge.json");
29827
+ return path23.join(env.XDG_DATA_HOME ?? path23.join(homedir2(), ".local", "share"), "localapp", "native-bridge.json");
29777
29828
  }
29778
29829
  function linuxDataHome(env) {
29779
- return env.XDG_DATA_HOME ?? path22.join(homedir2(), ".local", "share");
29830
+ return env.XDG_DATA_HOME ?? path23.join(homedir2(), ".local", "share");
29780
29831
  }
29781
29832
  function createWindowsProcessTreeAdapter(helper) {
29782
29833
  return { spawnOwned: (command, args, options2) => helper.spawn(command, args, options2) };
@@ -29804,7 +29855,7 @@ function resolveWindowsNativeExecutable(options2 = {}) {
29804
29855
  const roots = [env.LOCALAPP_RELEASE_PATH, options2.artifactDirectory ?? localAppArtifactDirectory()];
29805
29856
  for (const root of roots) {
29806
29857
  if (root === void 0 || root.length === 0) continue;
29807
- const candidate = path22.join(root, "runtime", "native", `win32-${arch}`, "localapp-native.exe");
29858
+ const candidate = path23.join(root, "runtime", "native", `win32-${arch}`, "localapp-native.exe");
29808
29859
  if (existsSync(candidate)) return candidate;
29809
29860
  }
29810
29861
  return void 0;
@@ -29886,7 +29937,7 @@ function boundedTimeout(value2, fallback) {
29886
29937
  }
29887
29938
  async function verifyRegularLocalFile(iconPath) {
29888
29939
  try {
29889
- const stat2 = await fs17.lstat(iconPath);
29940
+ const stat2 = await fs18.lstat(iconPath);
29890
29941
  return stat2.isFile() && !stat2.isSymbolicLink();
29891
29942
  } catch {
29892
29943
  return false;
@@ -29964,7 +30015,7 @@ var PackagedLinuxNotificationSession = class {
29964
30015
  function createPackagedLinuxNotificationSession(selected, nodePath, environment, timeoutMs) {
29965
30016
  const relative = `${selected.target}/localapp-notifications`;
29966
30017
  if (!selected.assets.some((asset) => asset.path === relative)) return unsupportedLinuxNotificationSession();
29967
- return new PackagedLinuxNotificationSession(path22.join(selected.root, ...relative.split("/")), nodePath, selected.ipcClient, environment, timeoutMs);
30018
+ return new PackagedLinuxNotificationSession(path23.join(selected.root, ...relative.split("/")), nodePath, selected.ipcClient, environment, timeoutMs);
29968
30019
  }
29969
30020
  function readLinuxAccepted(child, timeoutMs) {
29970
30021
  return new Promise((resolve2, reject) => {
@@ -30041,7 +30092,7 @@ function desktopExecQuote(value2) {
30041
30092
  }
30042
30093
  function safeAbsoluteLocalPath(value2, platform) {
30043
30094
  if (typeof value2 !== "string" || value2.length === 0 || value2.includes("\0") || /[\r\n]/.test(value2) || /^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(value2)) return false;
30044
- const pathApi = platform === "win32" ? path22.win32 : path22.posix;
30095
+ const pathApi = platform === "win32" ? path23.win32 : path23.posix;
30045
30096
  if (!pathApi.isAbsolute(value2) || pathApi.normalize(value2) !== value2) return false;
30046
30097
  return !value2.split(/[\\/]/).some((part) => part === "." || part === "..");
30047
30098
  }
@@ -30571,10 +30622,10 @@ function isRecord9(value2) {
30571
30622
  // packages/localapp/src/commands/dev.ts
30572
30623
  var DEV_USER_ID = "dev-user";
30573
30624
  async function runDev(options2, dependencies = {}) {
30574
- const projectDir = path23.resolve(options2.projectDir);
30575
- const stateRoot = path23.join(projectDir, "tmp/localapp-dev");
30576
- const dataDir = path23.join(stateRoot, "server");
30577
- const packagesDir = path23.join(stateRoot, "packages");
30625
+ const projectDir = path24.resolve(options2.projectDir);
30626
+ const stateRoot = path24.join(projectDir, "tmp/localapp-dev");
30627
+ const dataDir = path24.join(stateRoot, "server");
30628
+ const packagesDir = path24.join(stateRoot, "packages");
30578
30629
  const spawnProcess = dependencies.spawnOwnedProcess ?? spawnOwnedProcess;
30579
30630
  const lifecycle = new DevLifecycle();
30580
30631
  const abort = () => lifecycle.abort();
@@ -30588,8 +30639,8 @@ async function runDev(options2, dependencies = {}) {
30588
30639
  const credentials = await lifecycle.runPhase(() => readOrCreateDevCredentials(projectDir));
30589
30640
  await lifecycle.runPhase(async () => {
30590
30641
  await Promise.all([
30591
- fs18.mkdir(dataDir, { recursive: true, mode: 448 }),
30592
- fs18.mkdir(packagesDir, { recursive: true, mode: 448 })
30642
+ fs19.mkdir(dataDir, { recursive: true, mode: 448 }),
30643
+ fs19.mkdir(packagesDir, { recursive: true, mode: 448 })
30593
30644
  ]);
30594
30645
  });
30595
30646
  const serverLauncher = dependencies.serverLauncher ?? embeddedServerLauncher();
@@ -30626,7 +30677,7 @@ async function runDev(options2, dependencies = {}) {
30626
30677
  const initialize = dependencies.initializeServer ?? initializeServer;
30627
30678
  await lifecycle.runPhase((signal) => initialize(ready.listenUrl, ready.setupUrl, credentials.password, signal));
30628
30679
  const version = uniqueDevVersion();
30629
- const packagePath = path23.join(packagesDir, `${manifest.name}-${version}.localapp`);
30680
+ const packagePath = path24.join(packagesDir, `${manifest.name}-${version}.localapp`);
30630
30681
  const build = dependencies.buildApplicationPackage ?? buildApplicationPackage;
30631
30682
  const runBuildCommand = createOwnedProjectCommandRunner(lifecycle, spawnProcess, dependencies.windowsAdapter);
30632
30683
  const applicationPackage = await lifecycle.runPhase((signal) => build({
@@ -30661,7 +30712,7 @@ async function runDev(options2, dependencies = {}) {
30661
30712
  "--strictPort"
30662
30713
  ];
30663
30714
  lifecycle.assertActive();
30664
- const vite = lifecycle.spawn(() => spawnProcess(configuredVite.command, viteArgs, {
30715
+ const vite = lifecycle.spawn(() => spawnProcess(resolveOwnedCommand(configuredVite.command), viteArgs, {
30665
30716
  cwd: projectDir,
30666
30717
  env: { ...process.env, LOCALAPP_DEV_API_KEY: credentials.apiKey },
30667
30718
  stdio: "ignore",
@@ -30837,8 +30888,7 @@ var DevLifecycle = class {
30837
30888
  function createOwnedProjectCommandRunner(lifecycle, spawnProcess, windowsAdapter) {
30838
30889
  return async (invocation) => {
30839
30890
  lifecycle.assertActive();
30840
- const command = process.platform === "win32" ? `${invocation.command}.cmd` : invocation.command;
30841
- const child = lifecycle.spawn(() => spawnProcess(command, invocation.args, {
30891
+ const child = lifecycle.spawn(() => spawnProcess(resolveOwnedCommand(invocation.command), invocation.args, {
30842
30892
  cwd: invocation.cwd,
30843
30893
  stdio: "ignore",
30844
30894
  windowsAdapter
@@ -30884,15 +30934,15 @@ function isErrorCode(value2, code) {
30884
30934
  }
30885
30935
  async function writeDevConfig(options2) {
30886
30936
  throwIfAborted(options2.signal);
30887
- const projectDir = path23.resolve(options2.projectDir);
30888
- const localAppDir = path23.join(projectDir, ".localapp");
30889
- const stateRoot = path23.join(projectDir, "tmp/localapp-dev");
30937
+ const projectDir = path24.resolve(options2.projectDir);
30938
+ const localAppDir = path24.join(projectDir, ".localapp");
30939
+ const stateRoot = path24.join(projectDir, "tmp/localapp-dev");
30890
30940
  await Promise.all([
30891
- fs18.mkdir(localAppDir, { recursive: true }),
30892
- fs18.mkdir(stateRoot, { recursive: true, mode: 448 })
30941
+ fs19.mkdir(localAppDir, { recursive: true }),
30942
+ fs19.mkdir(stateRoot, { recursive: true, mode: 448 })
30893
30943
  ]);
30894
- const temporary = path23.join(stateRoot, `dev-config.${process.pid}.${randomBytes2(8).toString("hex")}.next`);
30895
- const destination = path23.join(localAppDir, "dev-config.json");
30944
+ const temporary = path24.join(stateRoot, `dev-config.${process.pid}.${randomBytes2(8).toString("hex")}.next`);
30945
+ const destination = path24.join(localAppDir, "dev-config.json");
30896
30946
  const value2 = {
30897
30947
  serverUrl: options2.serverUrl,
30898
30948
  userId: DEV_USER_ID,
@@ -30900,7 +30950,7 @@ async function writeDevConfig(options2) {
30900
30950
  appServerPort: options2.appServerPort
30901
30951
  };
30902
30952
  try {
30903
- await fs18.writeFile(temporary, `${JSON.stringify(value2, null, 2)}
30953
+ await fs19.writeFile(temporary, `${JSON.stringify(value2, null, 2)}
30904
30954
  `, {
30905
30955
  flag: "wx",
30906
30956
  mode: 384,
@@ -30910,16 +30960,16 @@ async function writeDevConfig(options2) {
30910
30960
  renameSync(temporary, destination);
30911
30961
  if (process.platform !== "win32") chmodSync(destination, 384);
30912
30962
  } finally {
30913
- await fs18.rm(temporary, { force: true });
30963
+ await fs19.rm(temporary, { force: true });
30914
30964
  }
30915
30965
  }
30916
30966
  function embeddedServerLauncher() {
30917
- return path23.resolve(path23.dirname(fileURLToPath4(import.meta.url)), "../runtime/server/bin/server.mjs");
30967
+ return path24.resolve(path24.dirname(fileURLToPath4(import.meta.url)), "../runtime/server/bin/server.mjs");
30918
30968
  }
30919
30969
  async function readManifest(projectDir) {
30920
30970
  let value2;
30921
30971
  try {
30922
- value2 = JSON.parse(await fs18.readFile(path23.join(projectDir, "manifest.json"), "utf8"));
30972
+ value2 = JSON.parse(await fs19.readFile(path24.join(projectDir, "manifest.json"), "utf8"));
30923
30973
  } catch {
30924
30974
  throw lifecycleError("project_manifest_missing", "No valid manifest.json found. Run 'localapp init' first.");
30925
30975
  }
@@ -31019,15 +31069,15 @@ function throwIfAborted(signal) {
31019
31069
  if (signal?.aborted) throw abortedDevelopment();
31020
31070
  }
31021
31071
  async function isFile(filePath) {
31022
- return fs18.stat(filePath).then((stat2) => stat2.isFile(), () => false);
31072
+ return fs19.stat(filePath).then((stat2) => stat2.isFile(), () => false);
31023
31073
  }
31024
31074
  function isRecord10(value2) {
31025
31075
  return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
31026
31076
  }
31027
31077
 
31028
31078
  // packages/localapp/src/commands/server.ts
31029
- import fs25 from "node:fs/promises";
31030
- import path30 from "node:path";
31079
+ import fs26 from "node:fs/promises";
31080
+ import path31 from "node:path";
31031
31081
 
31032
31082
  // packages/localapp/src/daemon/ipc-client.ts
31033
31083
  import net2 from "node:net";
@@ -31291,21 +31341,21 @@ function transportError(error) {
31291
31341
 
31292
31342
  // packages/localapp/src/daemon/release-store.ts
31293
31343
  import crypto6 from "node:crypto";
31294
- import fs19 from "node:fs/promises";
31344
+ import fs20 from "node:fs/promises";
31295
31345
  import { constants as fsConstants } from "node:fs";
31296
- import path24 from "node:path";
31346
+ import path25 from "node:path";
31297
31347
  var DIGEST = /^[0-9a-f]{64}$/;
31298
31348
  var VERSION = /^[0-9A-Za-z][0-9A-Za-z.+_-]{0,127}$/;
31299
31349
  async function verifyReleaseArtifact(directory) {
31300
- return (await inspectReleaseArtifact(path24.resolve(directory))).manifest;
31350
+ return (await inspectReleaseArtifact(path25.resolve(directory))).manifest;
31301
31351
  }
31302
31352
  async function publishRelease(options2) {
31303
- const sourceDirectory = path24.resolve(options2.sourceDirectory);
31353
+ const sourceDirectory = path25.resolve(options2.sourceDirectory);
31304
31354
  const inspected = await inspectReleaseArtifact(sourceDirectory);
31305
31355
  await ensurePrivateDirectories(options2.layout);
31306
31356
  return withReleaseLock(options2.layout, options2.lockTimeoutMs ?? 5e3, async () => {
31307
31357
  const releaseName = `${inspected.manifest.version}-${inspected.manifest.artifactDigest}`;
31308
- const releasePath = path24.join(options2.layout.releasesDir, releaseName);
31358
+ const releasePath = path25.join(options2.layout.releasesDir, releaseName);
31309
31359
  const existing = await lstatOptional2(releasePath);
31310
31360
  if (existing === void 0) {
31311
31361
  await publishImmutableDirectory(releasePath, inspected, options2.layout.releasesDir);
@@ -31321,7 +31371,7 @@ async function publishRelease(options2) {
31321
31371
  entrypoint: inspected.manifest.entrypoint,
31322
31372
  bootstrapEntrypoint: inspected.manifest.bootstrapEntrypoint
31323
31373
  };
31324
- const launcherBytes = await readRegularFile(path24.join(releasePath, ...inspected.manifest.bootstrapEntrypoint.split("/")));
31374
+ const launcherBytes = await readRegularFile(path25.join(releasePath, ...inspected.manifest.bootstrapEntrypoint.split("/")));
31325
31375
  await ensureStableLauncher(options2.layout.launcherPath, launcherBytes);
31326
31376
  await writeAtomic(options2.layout.currentManifestPath, Buffer.from(`${JSON.stringify(current, null, 2)}
31327
31377
  `), 384);
@@ -31338,8 +31388,8 @@ async function readCurrentRelease(layout) {
31338
31388
  if (!isRecord12(value2) || !hasExactKeys2(value2, ["version", "artifactDigest", "releasePath", "entrypoint", "bootstrapEntrypoint"]) || typeof value2.version !== "string" || !VERSION.test(value2.version) || typeof value2.artifactDigest !== "string" || !DIGEST.test(value2.artifactDigest) || typeof value2.releasePath !== "string" || typeof value2.entrypoint !== "string" || typeof value2.bootstrapEntrypoint !== "string") {
31339
31389
  throw lifecycleError("release_current_invalid", "The current LocalApp release manifest is missing or invalid");
31340
31390
  }
31341
- const expectedPath = path24.join(layout.releasesDir, `${value2.version}-${value2.artifactDigest}`);
31342
- if (path24.resolve(value2.releasePath) !== path24.resolve(expectedPath) || !isSafeRelativeFile(value2.entrypoint) || !isSafeRelativeFile(value2.bootstrapEntrypoint)) {
31391
+ const expectedPath = path25.join(layout.releasesDir, `${value2.version}-${value2.artifactDigest}`);
31392
+ if (path25.resolve(value2.releasePath) !== path25.resolve(expectedPath) || !isSafeRelativeFile(value2.entrypoint) || !isSafeRelativeFile(value2.bootstrapEntrypoint)) {
31343
31393
  throw lifecycleError("release_current_invalid", "The current LocalApp release manifest is missing or invalid");
31344
31394
  }
31345
31395
  return {
@@ -31352,9 +31402,9 @@ async function readCurrentRelease(layout) {
31352
31402
  }
31353
31403
  async function inspectReleaseArtifact(directory) {
31354
31404
  try {
31355
- const root = await fs19.lstat(directory);
31405
+ const root = await fs20.lstat(directory);
31356
31406
  if (!root.isDirectory() || root.isSymbolicLink()) throw invalidArtifact();
31357
- const manifestPath = path24.join(directory, ".localapp-artifact.json");
31407
+ const manifestPath = path25.join(directory, ".localapp-artifact.json");
31358
31408
  const manifestBytes = await readRegularFile(manifestPath);
31359
31409
  const manifest = parseArtifactManifest(JSON.parse(manifestBytes.toString("utf8")));
31360
31410
  const observed = await listArtifactFiles(directory);
@@ -31364,7 +31414,7 @@ async function inspectReleaseArtifact(directory) {
31364
31414
  }
31365
31415
  const files = /* @__PURE__ */ new Map();
31366
31416
  for (const entry of manifest.files) {
31367
- const bytes = await readRegularFile(path24.join(directory, ...entry.path.split("/")));
31417
+ const bytes = await readRegularFile(path25.join(directory, ...entry.path.split("/")));
31368
31418
  if (bytes.byteLength !== entry.size || sha2563(bytes) !== entry.sha256) throw invalidArtifact();
31369
31419
  files.set(entry.path, bytes);
31370
31420
  }
@@ -31491,13 +31541,13 @@ function parseArtifactFile(value2) {
31491
31541
  async function listArtifactFiles(root) {
31492
31542
  const files = /* @__PURE__ */ new Set();
31493
31543
  const visit = async (directory, prefix) => {
31494
- const entries = await fs19.readdir(directory, { withFileTypes: true });
31544
+ const entries = await fs20.readdir(directory, { withFileTypes: true });
31495
31545
  for (const entry of entries) {
31496
31546
  const relativePath2 = prefix ? `${prefix}/${entry.name}` : entry.name;
31497
31547
  if (relativePath2 === ".localapp-artifact.json") continue;
31498
31548
  if (!isSafeRelativeFile(relativePath2)) throw invalidArtifact();
31499
31549
  if (entry.isSymbolicLink()) throw invalidArtifact();
31500
- if (entry.isDirectory()) await visit(path24.join(directory, entry.name), relativePath2);
31550
+ if (entry.isDirectory()) await visit(path25.join(directory, entry.name), relativePath2);
31501
31551
  else if (entry.isFile()) files.add(relativePath2);
31502
31552
  else throw invalidArtifact();
31503
31553
  }
@@ -31506,25 +31556,25 @@ async function listArtifactFiles(root) {
31506
31556
  return files;
31507
31557
  }
31508
31558
  async function publishImmutableDirectory(releasePath, inspected, releasesDirectory) {
31509
- const staging = await fs19.mkdtemp(path24.join(releasesDirectory, ".release-stage-"));
31510
- if (process.platform !== "win32") await fs19.chmod(staging, 448);
31559
+ const staging = await fs20.mkdtemp(path25.join(releasesDirectory, ".release-stage-"));
31560
+ if (process.platform !== "win32") await fs20.chmod(staging, 448);
31511
31561
  try {
31512
31562
  for (const [relativePath2, bytes] of inspected.files) {
31513
- const destination = path24.join(staging, ...relativePath2.split("/"));
31514
- await fs19.mkdir(path24.dirname(destination), { recursive: true, mode: 448 });
31515
- await fs19.writeFile(destination, bytes, { flag: "wx", mode: isExecutableReleaseFile(relativePath2, inspected.manifest) ? 448 : 384 });
31563
+ const destination = path25.join(staging, ...relativePath2.split("/"));
31564
+ await fs20.mkdir(path25.dirname(destination), { recursive: true, mode: 448 });
31565
+ await fs20.writeFile(destination, bytes, { flag: "wx", mode: isExecutableReleaseFile(relativePath2, inspected.manifest) ? 448 : 384 });
31516
31566
  }
31517
- await fs19.writeFile(path24.join(staging, ".localapp-artifact.json"), inspected.manifestBytes, { flag: "wx", mode: 384 });
31567
+ await fs20.writeFile(path25.join(staging, ".localapp-artifact.json"), inspected.manifestBytes, { flag: "wx", mode: 384 });
31518
31568
  await inspectReleaseArtifact(staging);
31519
31569
  try {
31520
- await fs19.rename(staging, releasePath);
31570
+ await fs20.rename(staging, releasePath);
31521
31571
  } catch (error) {
31522
31572
  if (error.code !== "EEXIST" && error.code !== "ENOTEMPTY") throw error;
31523
31573
  const existing = await inspectReleaseArtifact(releasePath);
31524
31574
  if (existing.manifest.artifactDigest !== inspected.manifest.artifactDigest) throw invalidArtifact();
31525
31575
  }
31526
31576
  } finally {
31527
- await fs19.rm(staging, { recursive: true, force: true });
31577
+ await fs20.rm(staging, { recursive: true, force: true });
31528
31578
  }
31529
31579
  }
31530
31580
  function isExecutableReleaseFile(relativePath2, manifest) {
@@ -31534,7 +31584,7 @@ function isExecutableReleaseFile(relativePath2, manifest) {
31534
31584
  async function ensurePrivateDirectories(layout) {
31535
31585
  validateRuntimeLayout(layout);
31536
31586
  await ensurePrivateDirectory(layout.supportDir);
31537
- for (const directory of [layout.releasesDir, layout.logsDir, path24.dirname(layout.launcherPath), layout.runtimeDir]) {
31587
+ for (const directory of [layout.releasesDir, layout.logsDir, path25.dirname(layout.launcherPath), layout.runtimeDir]) {
31538
31588
  await ensurePrivateDirectory(directory);
31539
31589
  }
31540
31590
  }
@@ -31557,12 +31607,12 @@ async function withReleaseLock(layout, timeoutMs, operation) {
31557
31607
  }
31558
31608
  }
31559
31609
  async function tryCreateReleaseLock(layout) {
31560
- const temporary = path24.join(layout.runtimeDir, `.release-lock.${process.pid}.${crypto6.randomUUID()}.next`);
31610
+ const temporary = path25.join(layout.runtimeDir, `.release-lock.${process.pid}.${crypto6.randomUUID()}.next`);
31561
31611
  let handle;
31562
31612
  let identity;
31563
31613
  let linked = false;
31564
31614
  try {
31565
- handle = await fs19.open(temporary, "wx", 384);
31615
+ handle = await fs20.open(temporary, "wx", 384);
31566
31616
  const stat2 = await handle.stat({ bigint: true });
31567
31617
  if (!stat2.isFile()) throw lifecycleError("release_store_lock_invalid", "The LocalApp release lock could not be initialized");
31568
31618
  identity = { dev: stat2.dev, ino: stat2.ino };
@@ -31570,13 +31620,13 @@ async function tryCreateReleaseLock(layout) {
31570
31620
  `);
31571
31621
  await handle.sync();
31572
31622
  try {
31573
- await fs19.link(temporary, layout.releaseLockPath);
31623
+ await fs20.link(temporary, layout.releaseLockPath);
31574
31624
  } catch (error) {
31575
31625
  if (error.code === "EEXIST") return void 0;
31576
31626
  throw error;
31577
31627
  }
31578
31628
  linked = true;
31579
- const canonical = await fs19.lstat(layout.releaseLockPath, { bigint: true });
31629
+ const canonical = await fs20.lstat(layout.releaseLockPath, { bigint: true });
31580
31630
  if (!canonical.isFile() || canonical.isSymbolicLink() || canonical.dev !== identity.dev || canonical.ino !== identity.ino) {
31581
31631
  throw lifecycleError("release_store_lock_invalid", "The LocalApp release lock identity changed during creation");
31582
31632
  }
@@ -31590,12 +31640,12 @@ async function tryCreateReleaseLock(layout) {
31590
31640
  if (!linked || identity === void 0) {
31591
31641
  await handle?.close().catch(() => void 0);
31592
31642
  if (identity !== void 0) await unlinkOwnedPath(temporary, identity).catch(() => void 0);
31593
- else await fs19.rm(temporary, { force: true }).catch(() => void 0);
31643
+ else await fs20.rm(temporary, { force: true }).catch(() => void 0);
31594
31644
  }
31595
31645
  }
31596
31646
  }
31597
31647
  async function reclaimDeadReleaseLock(lockPath) {
31598
- const before = await fs19.lstat(lockPath, { bigint: true }).catch((error) => {
31648
+ const before = await fs20.lstat(lockPath, { bigint: true }).catch((error) => {
31599
31649
  if (error.code === "ENOENT") return void 0;
31600
31650
  throw error;
31601
31651
  });
@@ -31620,42 +31670,42 @@ function processExists(pid) {
31620
31670
  }
31621
31671
  }
31622
31672
  async function unlinkOwnedPath(filePath, identity) {
31623
- const current = await fs19.lstat(filePath, { bigint: true }).catch((error) => {
31673
+ const current = await fs20.lstat(filePath, { bigint: true }).catch((error) => {
31624
31674
  if (error.code === "ENOENT") return void 0;
31625
31675
  throw error;
31626
31676
  });
31627
31677
  if (current === void 0 || current.isSymbolicLink() || current.dev !== identity.dev || current.ino !== identity.ino) return false;
31628
- await fs19.unlink(filePath);
31678
+ await fs20.unlink(filePath);
31629
31679
  return true;
31630
31680
  }
31631
31681
  async function ensurePrivateDirectory(directory) {
31632
- await fs19.mkdir(directory, { recursive: true, mode: 448 });
31633
- const stat2 = await fs19.lstat(directory);
31682
+ await fs20.mkdir(directory, { recursive: true, mode: 448 });
31683
+ const stat2 = await fs20.lstat(directory);
31634
31684
  if (!stat2.isDirectory() || stat2.isSymbolicLink()) {
31635
31685
  throw lifecycleError("release_path_unsafe", "A LocalApp release directory is not a private regular directory");
31636
31686
  }
31637
31687
  if (process.platform !== "win32") {
31638
- await fs19.chmod(directory, 448);
31639
- const secured = await fs19.lstat(directory);
31688
+ await fs20.chmod(directory, 448);
31689
+ const secured = await fs20.lstat(directory);
31640
31690
  if (!secured.isDirectory() || secured.isSymbolicLink() || (secured.mode & 63) !== 0) {
31641
31691
  throw lifecycleError("release_path_unsafe", "A LocalApp release directory is not private");
31642
31692
  }
31643
31693
  }
31644
31694
  }
31645
31695
  function validateRuntimeLayout(layout) {
31646
- const support = path24.resolve(layout.supportDir);
31696
+ const support = path25.resolve(layout.supportDir);
31647
31697
  const expected = [
31648
- [layout.releasesDir, path24.join(support, "releases")],
31649
- [layout.currentManifestPath, path24.join(support, "current.json")],
31650
- [layout.launcherPath, path24.join(support, "bin", "localapp-daemon-bootstrap.mjs")],
31651
- [layout.logsDir, path24.join(support, "logs")]
31698
+ [layout.releasesDir, path25.join(support, "releases")],
31699
+ [layout.currentManifestPath, path25.join(support, "current.json")],
31700
+ [layout.launcherPath, path25.join(support, "bin", "localapp-daemon-bootstrap.mjs")],
31701
+ [layout.logsDir, path25.join(support, "logs")]
31652
31702
  ];
31653
- if (expected.some(([actual, canonical]) => path24.resolve(actual) !== path24.resolve(canonical)) || path24.resolve(layout.releaseLockPath) !== path24.resolve(layout.runtimeDir, "release.lock")) {
31703
+ if (expected.some(([actual, canonical]) => path25.resolve(actual) !== path25.resolve(canonical)) || path25.resolve(layout.releaseLockPath) !== path25.resolve(layout.runtimeDir, "release.lock")) {
31654
31704
  throw lifecycleError("release_path_unsafe", "The LocalApp release layout is invalid");
31655
31705
  }
31656
31706
  }
31657
31707
  async function ensureStableLauncher(filePath, bytes) {
31658
- const existing = await fs19.lstat(filePath).catch((error) => {
31708
+ const existing = await fs20.lstat(filePath).catch((error) => {
31659
31709
  if (error.code === "ENOENT") return void 0;
31660
31710
  throw error;
31661
31711
  });
@@ -31670,30 +31720,30 @@ async function ensureStableLauncher(filePath, bytes) {
31670
31720
  if (!current.equals(bytes)) {
31671
31721
  throw lifecycleError("release_launcher_incompatible", "The stable LocalApp launcher is incompatible with this release");
31672
31722
  }
31673
- if (process.platform !== "win32") await fs19.chmod(filePath, 448);
31723
+ if (process.platform !== "win32") await fs20.chmod(filePath, 448);
31674
31724
  }
31675
31725
  async function writeAtomic(filePath, bytes, mode) {
31676
- await fs19.mkdir(path24.dirname(filePath), { recursive: true, mode: 448 });
31677
- const temporary = path24.join(path24.dirname(filePath), `.${path24.basename(filePath)}.${process.pid}.${crypto6.randomUUID()}.next`);
31726
+ await fs20.mkdir(path25.dirname(filePath), { recursive: true, mode: 448 });
31727
+ const temporary = path25.join(path25.dirname(filePath), `.${path25.basename(filePath)}.${process.pid}.${crypto6.randomUUID()}.next`);
31678
31728
  let handle;
31679
31729
  try {
31680
- handle = await fs19.open(temporary, "wx", mode);
31730
+ handle = await fs20.open(temporary, "wx", mode);
31681
31731
  await handle.writeFile(bytes);
31682
31732
  await handle.sync();
31683
31733
  await handle.close();
31684
31734
  handle = void 0;
31685
- await fs19.rename(temporary, filePath);
31686
- if (process.platform !== "win32") await fs19.chmod(filePath, mode);
31735
+ await fs20.rename(temporary, filePath);
31736
+ if (process.platform !== "win32") await fs20.chmod(filePath, mode);
31687
31737
  } finally {
31688
31738
  await handle?.close();
31689
- await fs19.rm(temporary, { force: true });
31739
+ await fs20.rm(temporary, { force: true });
31690
31740
  }
31691
31741
  }
31692
31742
  async function readRegularFile(filePath) {
31693
- const before = await fs19.lstat(filePath, { bigint: true });
31743
+ const before = await fs20.lstat(filePath, { bigint: true });
31694
31744
  if (!before.isFile() || before.isSymbolicLink()) throw invalidArtifact();
31695
31745
  const noFollow = "O_NOFOLLOW" in fsConstants ? fsConstants.O_NOFOLLOW : 0;
31696
- const handle = await fs19.open(filePath, fsConstants.O_RDONLY | noFollow);
31746
+ const handle = await fs20.open(filePath, fsConstants.O_RDONLY | noFollow);
31697
31747
  try {
31698
31748
  const opened = await handle.stat({ bigint: true });
31699
31749
  if (!opened.isFile() || opened.dev !== before.dev || opened.ino !== before.ino) throw invalidArtifact();
@@ -31706,7 +31756,7 @@ async function readRegularFile(filePath) {
31706
31756
  }
31707
31757
  }
31708
31758
  function isSafeRelativeFile(value2) {
31709
- return value2.length > 0 && value2.length <= 512 && !value2.includes("\\") && !value2.startsWith("/") && path24.posix.normalize(value2) === value2 && !value2.endsWith("/") && value2.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
31759
+ return value2.length > 0 && value2.length <= 512 && !value2.includes("\\") && !value2.startsWith("/") && path25.posix.normalize(value2) === value2 && !value2.endsWith("/") && value2.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
31710
31760
  }
31711
31761
  function compareArtifactFiles(left, right) {
31712
31762
  return left.path < right.path ? -1 : left.path > right.path ? 1 : 0;
@@ -31729,18 +31779,18 @@ function isRecord12(value2) {
31729
31779
  return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
31730
31780
  }
31731
31781
  async function lstatOptional2(filePath) {
31732
- return fs19.lstat(filePath).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
31782
+ return fs20.lstat(filePath).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
31733
31783
  }
31734
31784
 
31735
31785
  // packages/localapp/src/daemon/runtime-layout.ts
31736
31786
  import crypto7 from "node:crypto";
31737
31787
  import { homedir as homedir3 } from "node:os";
31738
- import path25 from "node:path";
31788
+ import path26 from "node:path";
31739
31789
  function createRuntimeLayout(options2 = {}) {
31740
31790
  const platform = options2.platform ?? process.platform;
31741
31791
  const env = options2.env ?? process.env;
31742
31792
  const homeDirectory = options2.homeDir ?? homedir3();
31743
- const pathApi = platform === "win32" ? path25.win32 : path25.posix;
31793
+ const pathApi = platform === "win32" ? path26.win32 : path26.posix;
31744
31794
  const supportDir = options2.supportDir ?? defaultSupportDirectory(platform, env, homeDirectory, pathApi);
31745
31795
  const runtimeDir = options2.runtimeDir ?? defaultRuntimeDirectory(platform, env, homeDirectory, supportDir, options2.uid, pathApi);
31746
31796
  const dataDir = options2.dataDir ?? pathApi.join(supportDir, "data");
@@ -31778,38 +31828,38 @@ function defaultRuntimeDirectory(platform, env, homeDirectory, supportDirectory,
31778
31828
  }
31779
31829
 
31780
31830
  // packages/localapp/src/service/service-manager.ts
31781
- import fs24 from "node:fs/promises";
31831
+ import fs25 from "node:fs/promises";
31782
31832
  import { spawn as spawn6 } from "node:child_process";
31783
31833
 
31784
31834
  // packages/localapp/src/service/linux-systemd-user.ts
31785
- import fs21 from "node:fs/promises";
31786
- import path27 from "node:path";
31835
+ import fs22 from "node:fs/promises";
31836
+ import path28 from "node:path";
31787
31837
 
31788
31838
  // packages/localapp/src/service/service-files.ts
31789
31839
  import crypto8 from "node:crypto";
31790
- import fs20 from "node:fs/promises";
31791
- import path26 from "node:path";
31840
+ import fs21 from "node:fs/promises";
31841
+ import path27 from "node:path";
31792
31842
  async function writeServiceFile(filePath, value2) {
31793
- const existing = await fs20.readFile(filePath, "utf8").catch((error) => {
31843
+ const existing = await fs21.readFile(filePath, "utf8").catch((error) => {
31794
31844
  if (error.code === "ENOENT") return void 0;
31795
31845
  throw error;
31796
31846
  });
31797
31847
  if (existing === value2) return false;
31798
- await fs20.mkdir(path26.dirname(filePath), { recursive: true, mode: 448 });
31799
- const temporary = path26.join(path26.dirname(filePath), `.${path26.basename(filePath)}.${process.pid}.${crypto8.randomUUID()}.next`);
31848
+ await fs21.mkdir(path27.dirname(filePath), { recursive: true, mode: 448 });
31849
+ const temporary = path27.join(path27.dirname(filePath), `.${path27.basename(filePath)}.${process.pid}.${crypto8.randomUUID()}.next`);
31800
31850
  let handle;
31801
31851
  try {
31802
- handle = await fs20.open(temporary, "wx", 384);
31852
+ handle = await fs21.open(temporary, "wx", 384);
31803
31853
  await handle.writeFile(value2, "utf8");
31804
31854
  await handle.sync();
31805
31855
  await handle.close();
31806
31856
  handle = void 0;
31807
- await fs20.rename(temporary, filePath);
31808
- if (process.platform !== "win32") await fs20.chmod(filePath, 384);
31857
+ await fs21.rename(temporary, filePath);
31858
+ if (process.platform !== "win32") await fs21.chmod(filePath, 384);
31809
31859
  return true;
31810
31860
  } finally {
31811
31861
  await handle?.close();
31812
- await fs20.rm(temporary, { force: true });
31862
+ await fs21.rm(temporary, { force: true });
31813
31863
  }
31814
31864
  }
31815
31865
  function xmlEscape(value2) {
@@ -31819,8 +31869,8 @@ function xmlEscape(value2) {
31819
31869
  // packages/localapp/src/service/linux-systemd-user.ts
31820
31870
  var UNIT_NAME = "localapp.service";
31821
31871
  function createLinuxSystemdUserService(options2) {
31822
- const configHome = options2.env?.XDG_CONFIG_HOME ?? path27.join(options2.homeDir, ".config");
31823
- const registrationPath = path27.join(configHome, "systemd", "user", UNIT_NAME);
31872
+ const configHome = options2.env?.XDG_CONFIG_HOME ?? path28.join(options2.homeDir, ".config");
31873
+ const registrationPath = path28.join(configHome, "systemd", "user", UNIT_NAME);
31824
31874
  const unit = buildUnit(options2);
31825
31875
  const systemctl = options2.env?.SYSTEMCTL_PATH ?? "systemctl";
31826
31876
  return {
@@ -31858,7 +31908,7 @@ function createLinuxSystemdUserService(options2) {
31858
31908
  if (disabled.code !== 0 && !isMissingUnit(disabled.stderr)) {
31859
31909
  throw lifecycleError("user_service_command_failed", "The systemd user service could not be removed");
31860
31910
  }
31861
- await fs21.rm(registrationPath, { force: true });
31911
+ await fs22.rm(registrationPath, { force: true });
31862
31912
  await runServiceCommand(options2.run, { command: systemctl, args: ["--user", "daemon-reload"] });
31863
31913
  }
31864
31914
  };
@@ -31894,15 +31944,15 @@ function systemdQuote(value2) {
31894
31944
 
31895
31945
  // packages/localapp/src/service/macos-launch-agent.ts
31896
31946
  import crypto9 from "node:crypto";
31897
- import fs22 from "node:fs/promises";
31898
- import path28 from "node:path";
31947
+ import fs23 from "node:fs/promises";
31948
+ import path29 from "node:path";
31899
31949
  var LABEL = "com.localapp.daemon";
31900
31950
  function createMacosLaunchAgent(options2) {
31901
31951
  const uid = options2.uid ?? (typeof process.getuid === "function" ? process.getuid() : void 0);
31902
31952
  if (!Number.isSafeInteger(uid) || (uid ?? -1) < 0) {
31903
31953
  throw lifecycleError("user_service_configuration_invalid", "The current macOS user identity is unavailable");
31904
31954
  }
31905
- const registrationPath = path28.join(options2.homeDir, "Library", "LaunchAgents", `${LABEL}.plist`);
31955
+ const registrationPath = path29.join(options2.homeDir, "Library", "LaunchAgents", `${LABEL}.plist`);
31906
31956
  const domain = `gui/${uid}`;
31907
31957
  const target = `${domain}/${LABEL}`;
31908
31958
  const plist = buildPlist(options2);
@@ -31912,7 +31962,7 @@ function createMacosLaunchAgent(options2) {
31912
31962
  registrationPath,
31913
31963
  async install() {
31914
31964
  const installed = await writeServiceFile(registrationPath, plist);
31915
- const receipt = await fs22.readFile(receiptPath, "utf8").then((value2) => value2.trim(), () => void 0);
31965
+ const receipt = await fs23.readFile(receiptPath, "utf8").then((value2) => value2.trim(), () => void 0);
31916
31966
  const loaded = await options2.run({ command: "/bin/launchctl", args: ["print", target] });
31917
31967
  if (loaded.code === 0 && receipt === plistDigest) return { mode: "service", installed };
31918
31968
  if (loaded.code !== 0 && !isMissingService(loaded.stderr)) {
@@ -31956,8 +32006,8 @@ function createMacosLaunchAgent(options2) {
31956
32006
  if (result.code !== 0 && !/could not find service|no such process/i.test(result.stderr)) {
31957
32007
  throw lifecycleError("user_service_command_failed", "The macOS LaunchAgent could not be removed");
31958
32008
  }
31959
- await fs22.rm(registrationPath, { force: true });
31960
- await fs22.rm(receiptPath, { force: true });
32009
+ await fs23.rm(registrationPath, { force: true });
32010
+ await fs23.rm(receiptPath, { force: true });
31961
32011
  }
31962
32012
  };
31963
32013
  }
@@ -31994,13 +32044,13 @@ ${environment}
31994
32044
  }
31995
32045
 
31996
32046
  // packages/localapp/src/service/windows-user-task.ts
31997
- import fs23 from "node:fs/promises";
31998
- import path29 from "node:path";
32047
+ import fs24 from "node:fs/promises";
32048
+ import path30 from "node:path";
31999
32049
  var TASK_NAME = "LocalApp User Daemon";
32000
32050
  function createWindowsUserTask(options2) {
32001
- const registrationPath = path29.join(options2.layout.supportDir, "service", "windows-user-task.json");
32051
+ const registrationPath = path30.join(options2.layout.supportDir, "service", "windows-user-task.json");
32002
32052
  const systemRoot = options2.env?.SystemRoot ?? options2.env?.SYSTEMROOT ?? "C:\\Windows";
32003
- const scheduler = path29.win32.join(systemRoot, "System32", "schtasks.exe");
32053
+ const scheduler = path30.win32.join(systemRoot, "System32", "schtasks.exe");
32004
32054
  const taskCommand = `${quoteWindowsArgument(options2.nodePath)} ${quoteWindowsArgument(options2.layout.launcherPath)}`;
32005
32055
  const metadata = `${JSON.stringify({
32006
32056
  schemaVersion: 1,
@@ -32013,9 +32063,9 @@ function createWindowsUserTask(options2) {
32013
32063
  registrationPath,
32014
32064
  async install() {
32015
32065
  const installed = await writeServiceFile(registrationPath, metadata);
32016
- const definitionPath = path29.join(path29.dirname(registrationPath), "windows-user-task.xml");
32017
- await fs23.mkdir(path29.dirname(definitionPath), { recursive: true });
32018
- await fs23.writeFile(definitionPath, taskDefinition(options2.nodePath, options2.layout.launcherPath));
32066
+ const definitionPath = path30.join(path30.dirname(registrationPath), "windows-user-task.xml");
32067
+ await fs24.mkdir(path30.dirname(definitionPath), { recursive: true });
32068
+ await fs24.writeFile(definitionPath, taskDefinition(options2.nodePath, options2.layout.launcherPath));
32019
32069
  await runServiceCommand(options2.run, {
32020
32070
  command: scheduler,
32021
32071
  args: ["/Create", "/TN", TASK_NAME, "/XML", definitionPath, "/F"]
@@ -32048,7 +32098,7 @@ function createWindowsUserTask(options2) {
32048
32098
  if (result.code !== 0 && !/cannot find|does not exist/i.test(result.stderr)) {
32049
32099
  throw lifecycleError("user_service_command_failed", "The Windows user task could not be removed");
32050
32100
  }
32051
- await fs23.rm(registrationPath, { force: true });
32101
+ await fs24.rm(registrationPath, { force: true });
32052
32102
  }
32053
32103
  };
32054
32104
  }
@@ -32197,7 +32247,7 @@ function withLogs(manager, layout) {
32197
32247
  if (!Number.isSafeInteger(lines) || lines < 1 || lines > 1e4) {
32198
32248
  throw lifecycleError("user_service_logs_invalid", "The requested log line count is invalid");
32199
32249
  }
32200
- const handle = await fs24.open(layout.daemonLogPath, "r").catch((error) => {
32250
+ const handle = await fs25.open(layout.daemonLogPath, "r").catch((error) => {
32201
32251
  if (error.code === "ENOENT") return void 0;
32202
32252
  throw error;
32203
32253
  });
@@ -32229,7 +32279,7 @@ async function runServerCommand(options2, dependencies = {}) {
32229
32279
  const artifactDirectory = dependencies.artifactDirectory ?? defaultArtifactDirectory();
32230
32280
  await (dependencies.verifyReleaseArtifact ?? verifyReleaseArtifact)(artifactDirectory);
32231
32281
  const release = await (dependencies.publishRelease ?? publishRelease)({ sourceDirectory: artifactDirectory, layout });
32232
- const native = await (dependencies.createNativeAdapter ?? createNativeAdapter)(path30.join(release.releasePath, "runtime", "native"), { supportDir: layout.supportDir });
32282
+ const native = await (dependencies.createNativeAdapter ?? createNativeAdapter)(path31.join(release.releasePath, "runtime", "native"), { supportDir: layout.supportDir });
32233
32283
  await native.installScheme();
32234
32284
  const manager = service();
32235
32285
  const installed = await manager.install();
@@ -32269,7 +32319,7 @@ async function runServerForeground(options2, dependencies = {}) {
32269
32319
  const artifact = dependencies.artifactDirectory ?? defaultArtifactDirectory();
32270
32320
  const manifest = await verifyReleaseArtifact(artifact);
32271
32321
  if (typeof manifest.serverEntrypoint !== "string") throw lifecycleError("canonical_server_unavailable", "The packed canonical LocalApp Server runtime is unavailable");
32272
- const entrypoint = path30.join(artifact, ...manifest.serverEntrypoint.split("/"));
32322
+ const entrypoint = path31.join(artifact, ...manifest.serverEntrypoint.split("/"));
32273
32323
  const child = (dependencies.spawnOwnedProcess ?? spawnOwnedProcess)(process.execPath, [
32274
32324
  entrypoint,
32275
32325
  "start",
@@ -32337,7 +32387,7 @@ async function readyStatus(ipc, health) {
32337
32387
  async function waitForStopped(layout, ipc) {
32338
32388
  const deadline = Date.now() + 15e3;
32339
32389
  while (Date.now() < deadline) {
32340
- const lockMissing = await fs25.lstat(layout.lockPath).then(() => false, (error) => error.code === "ENOENT");
32390
+ const lockMissing = await fs26.lstat(layout.lockPath).then(() => false, (error) => error.code === "ENOENT");
32341
32391
  try {
32342
32392
  await ipc.request({ type: "status" });
32343
32393
  } catch (error) {
@@ -32396,7 +32446,7 @@ function publicRelease(release) {
32396
32446
  }
32397
32447
  async function removeTransientRuntimeFiles(layout) {
32398
32448
  await Promise.all([layout.lockPath, layout.controlEndpoint].map(async (target) => {
32399
- const stat2 = await fs25.lstat(target).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
32449
+ const stat2 = await fs26.lstat(target).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
32400
32450
  if (stat2 !== void 0) throw lifecycleError("daemon_ownership_unproven", "LocalApp refuses to remove an unproven daemon ownership artifact");
32401
32451
  }));
32402
32452
  }
@@ -32406,8 +32456,8 @@ function delay2(ms) {
32406
32456
 
32407
32457
  // packages/localapp/src/daemon/daemon.ts
32408
32458
  import crypto11 from "node:crypto";
32409
- import fs28 from "node:fs/promises";
32410
- import path33 from "node:path";
32459
+ import fs29 from "node:fs/promises";
32460
+ import path34 from "node:path";
32411
32461
 
32412
32462
  // packages/localapp/src/activation/activation-broker.ts
32413
32463
  var DEVICE_ACTION_STATUSES = /* @__PURE__ */ new Set([
@@ -32516,8 +32566,8 @@ function recordWithExactKeys(value2, keys) {
32516
32566
  import crypto10 from "node:crypto";
32517
32567
  import { execFile } from "node:child_process";
32518
32568
  import { constants as constants4 } from "node:fs";
32519
- import fs26 from "node:fs/promises";
32520
- import path31 from "node:path";
32569
+ import fs27 from "node:fs/promises";
32570
+ import path32 from "node:path";
32521
32571
  import { promisify } from "node:util";
32522
32572
  var EMPTY_STATE = { version: 1, sources: [] };
32523
32573
  var SOURCE_ID = /^[A-Za-z0-9](?:[A-Za-z0-9_-]{0,127})$/;
@@ -32541,7 +32591,7 @@ var DeliveryStore = class {
32541
32591
  tail = Promise.resolve();
32542
32592
  poisoned = false;
32543
32593
  constructor(options2) {
32544
- this.statePath = path31.resolve(options2.statePath);
32594
+ this.statePath = path32.resolve(options2.statePath);
32545
32595
  this.now = options2.now ?? (() => /* @__PURE__ */ new Date());
32546
32596
  this.randomBytes = options2.randomBytes ?? crypto10.randomBytes;
32547
32597
  this.fault = options2.fault;
@@ -32574,7 +32624,7 @@ var DeliveryStore = class {
32574
32624
  return snapshot(source);
32575
32625
  });
32576
32626
  }
32577
- async preparePending(sourceId, value2, expiresAt, sourceLabel = sourceId, iconPath = path31.resolve(process.cwd(), "localapp-notification.png")) {
32627
+ async preparePending(sourceId, value2, expiresAt, sourceLabel = sourceId, iconPath = path32.resolve(process.cwd(), "localapp-notification.png")) {
32578
32628
  return this.mutate((state) => {
32579
32629
  const source = requiredSource(state, sourceId);
32580
32630
  const delivery = validateDelivery(value2);
@@ -32717,9 +32767,9 @@ var DeliveryStore = class {
32717
32767
  });
32718
32768
  }
32719
32769
  async withFileLock(operation) {
32720
- const parent = path31.dirname(this.statePath);
32770
+ const parent = path32.dirname(this.statePath);
32721
32771
  await ensurePrivateParent(parent);
32722
- const lockPath = path31.join(parent, `.${path31.basename(this.statePath)}.lock`);
32772
+ const lockPath = path32.join(parent, `.${path32.basename(this.statePath)}.lock`);
32723
32773
  const deadline = Date.now() + this.lockTimeoutMs;
32724
32774
  let lock;
32725
32775
  while (lock === void 0) {
@@ -32730,7 +32780,7 @@ var DeliveryStore = class {
32730
32780
  await new Promise((resolve2) => setTimeout(resolve2, 10));
32731
32781
  }
32732
32782
  try {
32733
- await removeOwnedStaleTemps(parent, path31.basename(this.statePath));
32783
+ await removeOwnedStaleTemps(parent, path32.basename(this.statePath));
32734
32784
  return await operation();
32735
32785
  } finally {
32736
32786
  await lock.handle.close().catch(() => void 0);
@@ -32746,12 +32796,12 @@ var DeliveryStore = class {
32746
32796
  return run;
32747
32797
  }
32748
32798
  async read() {
32749
- await ensurePrivateParent(path31.dirname(this.statePath));
32799
+ await ensurePrivateParent(path32.dirname(this.statePath));
32750
32800
  let handle;
32751
32801
  try {
32752
- const before = await fs26.lstat(this.statePath, { bigint: true });
32802
+ const before = await fs27.lstat(this.statePath, { bigint: true });
32753
32803
  assertPrivateRegular(before, "Notification delivery state");
32754
- handle = await fs26.open(this.statePath, process.platform === "win32" ? "r" : constants4.O_RDONLY | constants4.O_NOFOLLOW);
32804
+ handle = await fs27.open(this.statePath, process.platform === "win32" ? "r" : constants4.O_RDONLY | constants4.O_NOFOLLOW);
32755
32805
  const opened = await handle.stat({ bigint: true });
32756
32806
  assertPrivateRegular(opened, "Notification delivery state");
32757
32807
  if (!sameIdentity(before, opened)) throw unsafe("Notification delivery state identity changed");
@@ -32768,11 +32818,11 @@ var DeliveryStore = class {
32768
32818
  }
32769
32819
  }
32770
32820
  async publish(state) {
32771
- const parent = path31.dirname(this.statePath);
32821
+ const parent = path32.dirname(this.statePath);
32772
32822
  const parentBefore = await privateDirectoryIdentity(parent);
32773
- const parentHandle = await fs26.open(parent, "r");
32823
+ const parentHandle = await fs27.open(parent, "r");
32774
32824
  let existing;
32775
- const temporary = path31.join(parent, `.${path31.basename(this.statePath)}.${process.pid}.${this.token(12)}.tmp`);
32825
+ const temporary = path32.join(parent, `.${path32.basename(this.statePath)}.${process.pid}.${this.token(12)}.tmp`);
32776
32826
  let handle;
32777
32827
  let tempIdentity;
32778
32828
  let renamed = false;
@@ -32782,10 +32832,10 @@ var DeliveryStore = class {
32782
32832
  const content = Buffer.from(`${JSON.stringify(state)}
32783
32833
  `);
32784
32834
  if (content.byteLength > MAX_STATE_BYTES) throw new Error("Notification delivery state is too large");
32785
- handle = await fs26.open(temporary, "wx", 384);
32835
+ handle = await fs27.open(temporary, "wx", 384);
32786
32836
  const created = await handle.stat({ bigint: true });
32787
32837
  assertPrivateRegular(created, "Notification delivery temporary file");
32788
- tempIdentity = await fs26.lstat(temporary, { bigint: true });
32838
+ tempIdentity = await fs27.lstat(temporary, { bigint: true });
32789
32839
  if (!sameIdentity(created, tempIdentity)) throw unsafe("Notification delivery temporary identity changed");
32790
32840
  await handle.writeFile(content);
32791
32841
  await handle.sync();
@@ -32799,7 +32849,7 @@ var DeliveryStore = class {
32799
32849
  if (!optionalSameIdentity(existing, current)) throw unsafe("Notification delivery state was replaced");
32800
32850
  await this.fault?.("before-rename");
32801
32851
  try {
32802
- await renameInPinnedParent(parent, path31.basename(temporary), path31.basename(this.statePath), parentBefore, tempIdentity);
32852
+ await renameInPinnedParent(parent, path32.basename(temporary), path32.basename(this.statePath), parentBefore, tempIdentity);
32803
32853
  renamed = true;
32804
32854
  } catch (error) {
32805
32855
  if (error instanceof PinnedRenamePreconditionError) throw error;
@@ -32818,7 +32868,7 @@ var DeliveryStore = class {
32818
32868
  await handle?.close().catch(() => void 0);
32819
32869
  if (!renamed && tempIdentity !== void 0) {
32820
32870
  const current = await optionalLstat(temporary);
32821
- if (current !== void 0 && sameIdentity(tempIdentity, current)) await fs26.rm(temporary, { force: true }).catch(() => void 0);
32871
+ if (current !== void 0 && sameIdentity(tempIdentity, current)) await fs27.rm(temporary, { force: true }).catch(() => void 0);
32822
32872
  }
32823
32873
  throw error;
32824
32874
  } finally {
@@ -32944,7 +32994,7 @@ function validateDisplaySourceLabel(value2) {
32944
32994
  return value2;
32945
32995
  }
32946
32996
  function validateIconPath(value2) {
32947
- if (typeof value2 !== "string" || value2.length > 2048 || !path31.isAbsolute(value2) || path31.resolve(value2) !== value2 || /[\u0000-\u001f\u007f]/.test(value2)) throw new Error("Notification icon path is invalid");
32997
+ if (typeof value2 !== "string" || value2.length > 2048 || !path32.isAbsolute(value2) || path32.resolve(value2) !== value2 || /[\u0000-\u001f\u007f]/.test(value2)) throw new Error("Notification icon path is invalid");
32948
32998
  return value2;
32949
32999
  }
32950
33000
  function validateSourceId(value2) {
@@ -33006,18 +33056,18 @@ async function ensurePrivateParent(directory) {
33006
33056
  await assertNoSymlinkAncestors(directory, true);
33007
33057
  const existing = await optionalLstat(directory);
33008
33058
  if (existing === void 0) {
33009
- await fs26.mkdir(directory, { recursive: true, mode: 448 });
33010
- if (process.platform !== "win32") await fs26.chmod(directory, 448);
33059
+ await fs27.mkdir(directory, { recursive: true, mode: 448 });
33060
+ if (process.platform !== "win32") await fs27.chmod(directory, 448);
33011
33061
  }
33012
33062
  await assertNoSymlinkAncestors(directory, false);
33013
33063
  await privateDirectoryIdentity(directory);
33014
33064
  }
33015
33065
  async function assertNoSymlinkAncestors(target, allowMissingTail) {
33016
- const absolute = path31.resolve(target);
33017
- const parsed = path31.parse(absolute);
33066
+ const absolute = path32.resolve(target);
33067
+ const parsed = path32.parse(absolute);
33018
33068
  let current = parsed.root;
33019
- for (const segment of absolute.slice(parsed.root.length).split(path31.sep).filter(Boolean)) {
33020
- current = path31.join(current, segment);
33069
+ for (const segment of absolute.slice(parsed.root.length).split(path32.sep).filter(Boolean)) {
33070
+ current = path32.join(current, segment);
33021
33071
  const stat2 = await optionalLstat(current);
33022
33072
  if (stat2 === void 0) {
33023
33073
  if (allowMissingTail) return;
@@ -33027,7 +33077,7 @@ async function assertNoSymlinkAncestors(target, allowMissingTail) {
33027
33077
  }
33028
33078
  }
33029
33079
  async function privateDirectoryIdentity(directory) {
33030
- const stat2 = await fs26.lstat(directory, { bigint: true });
33080
+ const stat2 = await fs27.lstat(directory, { bigint: true });
33031
33081
  if (!stat2.isDirectory() || stat2.isSymbolicLink() || stat2.nlink < 1n) throw unsafe("Notification delivery parent path is unsafe");
33032
33082
  if (process.platform !== "win32" && ((BigInt(stat2.mode) & 0o777n) !== 0o700n || BigInt(stat2.uid) !== BigInt(process.getuid?.() ?? Number(stat2.uid)))) throw unsafe("Notification delivery parent permissions are unsafe");
33033
33083
  return stat2;
@@ -33044,7 +33094,7 @@ function optionalSameIdentity(a, b) {
33044
33094
  }
33045
33095
  async function optionalLstat(target) {
33046
33096
  try {
33047
- return await fs26.lstat(target, { bigint: true });
33097
+ return await fs27.lstat(target, { bigint: true });
33048
33098
  } catch (error) {
33049
33099
  if (isCode(error, "ENOENT")) return void 0;
33050
33100
  throw error;
@@ -33081,16 +33131,16 @@ async function renameInPinnedParent(parent, source, destination, identity, sourc
33081
33131
  }
33082
33132
  async function removeOwnedStaleTemps(parent, basename2) {
33083
33133
  const prefix = `.${basename2}.`;
33084
- const names = (await fs26.readdir(parent)).filter((name) => name.startsWith(prefix) && name.endsWith(".tmp"));
33134
+ const names = (await fs27.readdir(parent)).filter((name) => name.startsWith(prefix) && name.endsWith(".tmp"));
33085
33135
  if (names.length === 0) return;
33086
33136
  for (const name of names) {
33087
- const target = path31.join(parent, name);
33088
- const stat2 = await fs26.lstat(target, { bigint: true });
33137
+ const target = path32.join(parent, name);
33138
+ const stat2 = await fs27.lstat(target, { bigint: true });
33089
33139
  assertPrivateRegular(stat2, "Notification delivery stale temporary file");
33090
33140
  await unlinkOwned(target, { dev: BigInt(stat2.dev), ino: BigInt(stat2.ino) });
33091
33141
  }
33092
33142
  if (process.platform !== "win32") {
33093
- const directory = await fs26.open(parent, "r");
33143
+ const directory = await fs27.open(parent, "r");
33094
33144
  try {
33095
33145
  await directory.sync();
33096
33146
  } finally {
@@ -33182,12 +33232,12 @@ function strictJsonParse(input) {
33182
33232
  return result;
33183
33233
  }
33184
33234
  async function tryAcquireLock(lockPath) {
33185
- const temporary = path31.join(path31.dirname(lockPath), `.${path31.basename(lockPath)}.${process.pid}.${crypto10.randomUUID()}.next`);
33235
+ const temporary = path32.join(path32.dirname(lockPath), `.${path32.basename(lockPath)}.${process.pid}.${crypto10.randomUUID()}.next`);
33186
33236
  let handle;
33187
33237
  let identity;
33188
33238
  let linked = false;
33189
33239
  try {
33190
- handle = await fs26.open(temporary, "wx", 384);
33240
+ handle = await fs27.open(temporary, "wx", 384);
33191
33241
  const opened = await handle.stat({ bigint: true });
33192
33242
  assertPrivateRegular(opened, "Notification delivery lock");
33193
33243
  identity = { dev: opened.dev, ino: opened.ino };
@@ -33195,13 +33245,13 @@ async function tryAcquireLock(lockPath) {
33195
33245
  `);
33196
33246
  await handle.sync();
33197
33247
  try {
33198
- await fs26.link(temporary, lockPath);
33248
+ await fs27.link(temporary, lockPath);
33199
33249
  } catch (error) {
33200
33250
  if (isCode(error, "EEXIST")) return void 0;
33201
33251
  throw error;
33202
33252
  }
33203
33253
  linked = true;
33204
- const visible = await fs26.lstat(lockPath, { bigint: true });
33254
+ const visible = await fs27.lstat(lockPath, { bigint: true });
33205
33255
  if (!sameIdentity(opened, visible)) throw unsafe("Notification delivery lock identity changed");
33206
33256
  if (!await unlinkOwned(temporary, identity)) throw unsafe("Notification delivery lock temporary identity changed");
33207
33257
  return { handle, identity };
@@ -33212,7 +33262,7 @@ async function tryAcquireLock(lockPath) {
33212
33262
  if (!linked) {
33213
33263
  await handle?.close().catch(() => void 0);
33214
33264
  if (identity !== void 0) await unlinkOwned(temporary, identity).catch(() => void 0);
33215
- else await fs26.rm(temporary, { force: true }).catch(() => void 0);
33265
+ else await fs27.rm(temporary, { force: true }).catch(() => void 0);
33216
33266
  }
33217
33267
  }
33218
33268
  }
@@ -33224,7 +33274,7 @@ async function reclaimDeadLock(lockPath) {
33224
33274
  const linkedTemporary = visible.linkedTemporary;
33225
33275
  let handle;
33226
33276
  try {
33227
- handle = await fs26.open(lockPath, process.platform === "win32" ? "r" : constants4.O_RDONLY | constants4.O_NOFOLLOW);
33277
+ handle = await fs27.open(lockPath, process.platform === "win32" ? "r" : constants4.O_RDONLY | constants4.O_NOFOLLOW);
33228
33278
  const opened = await handle.stat({ bigint: true });
33229
33279
  if (!sameIdentity(before, opened)) return false;
33230
33280
  const bytes = await handle.readFile();
@@ -33256,11 +33306,11 @@ async function validateVisibleLock(stat2, lockPath) {
33256
33306
  throw unsafe("Notification delivery lock path is unsafe");
33257
33307
  }
33258
33308
  if (stat2.nlink === 1n) return { stable: true, linkedTemporary: void 0 };
33259
- const prefix = `.${path31.basename(lockPath)}.`;
33260
- const candidates = (await fs26.readdir(path31.dirname(lockPath))).filter((name) => name.startsWith(prefix) && name.endsWith(".next"));
33309
+ const prefix = `.${path32.basename(lockPath)}.`;
33310
+ const candidates = (await fs27.readdir(path32.dirname(lockPath))).filter((name) => name.startsWith(prefix) && name.endsWith(".next"));
33261
33311
  const same = [];
33262
33312
  for (const name of candidates) {
33263
- const candidate = path31.join(path31.dirname(lockPath), name);
33313
+ const candidate = path32.join(path32.dirname(lockPath), name);
33264
33314
  const metadata = await optionalLstat(candidate);
33265
33315
  if (metadata !== void 0 && sameIdentity(stat2, metadata)) same.push(candidate);
33266
33316
  }
@@ -33283,7 +33333,7 @@ function processExists2(pid) {
33283
33333
  async function unlinkOwned(target, identity) {
33284
33334
  const current = await optionalLstat(target);
33285
33335
  if (current === void 0 || current.isSymbolicLink() || current.dev !== identity.dev || current.ino !== identity.ino) return false;
33286
- await fs26.unlink(target);
33336
+ await fs27.unlink(target);
33287
33337
  return true;
33288
33338
  }
33289
33339
  function unchanged(value2) {
@@ -33997,9 +34047,9 @@ function delay3(ms, signal) {
33997
34047
  }
33998
34048
 
33999
34049
  // packages/localapp/src/daemon/ipc-server.ts
34000
- import fs27 from "node:fs/promises";
34050
+ import fs28 from "node:fs/promises";
34001
34051
  import net3 from "node:net";
34002
- import path32 from "node:path";
34052
+ import path33 from "node:path";
34003
34053
  var DEFAULT_TIMEOUT_MS2 = 5e3;
34004
34054
  async function createIpcServer(options2) {
34005
34055
  const platform = options2.platform ?? process.platform;
@@ -34020,7 +34070,7 @@ async function createIpcServer(options2) {
34020
34070
  });
34021
34071
  let identity;
34022
34072
  if (platform !== "win32") {
34023
- const stat2 = await fs27.lstat(options2.endpoint, { bigint: true });
34073
+ const stat2 = await fs28.lstat(options2.endpoint, { bigint: true });
34024
34074
  if (!stat2.isSocket() || stat2.isSymbolicLink()) {
34025
34075
  await closeNetServer(server);
34026
34076
  throw lifecycleError("ipc_path_unsafe", "The LocalApp control endpoint is not a socket");
@@ -34100,15 +34150,15 @@ function serveConnection(socket, handle, afterResponse, timeoutMs, platform) {
34100
34150
  });
34101
34151
  }
34102
34152
  async function prepareUnixEndpoint(endpoint, reclaim) {
34103
- const parent = path32.dirname(endpoint);
34104
- const parentStat = await fs27.lstat(parent).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
34153
+ const parent = path33.dirname(endpoint);
34154
+ const parentStat = await fs28.lstat(parent).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
34105
34155
  if (parentStat === void 0 || !parentStat.isDirectory() || parentStat.isSymbolicLink() || (Number(parentStat.mode) & 63) !== 0) throw lifecycleError("ipc_path_unsafe", "The LocalApp control directory is not private");
34106
- const existing = await fs27.lstat(endpoint, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
34156
+ const existing = await fs28.lstat(endpoint, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
34107
34157
  if (existing === void 0) return;
34108
34158
  if (!existing.isSocket() || existing.isSymbolicLink() || reclaim === void 0 || !await reclaim()) throw lifecycleError("ipc_path_unsafe", "The LocalApp control endpoint already exists");
34109
- const current = await fs27.lstat(endpoint, { bigint: true });
34159
+ const current = await fs28.lstat(endpoint, { bigint: true });
34110
34160
  if (!current.isSocket() || current.isSymbolicLink() || current.dev !== existing.dev || current.ino !== existing.ino) throw lifecycleError("ipc_path_unsafe", "The LocalApp control endpoint changed during stale cleanup");
34111
- await fs27.unlink(endpoint);
34161
+ await fs28.unlink(endpoint);
34112
34162
  }
34113
34163
  async function closeNetServer(server) {
34114
34164
  await new Promise((resolve2) => server.close(() => resolve2()));
@@ -34117,8 +34167,8 @@ async function closeServer(server, sockets, endpoint, identity, timeoutMs) {
34117
34167
  for (const socket of sockets) socket.destroy();
34118
34168
  await Promise.race([closeNetServer(server), new Promise((resolve2) => setTimeout(resolve2, timeoutMs))]);
34119
34169
  if (identity === void 0) return;
34120
- const current = await fs27.lstat(endpoint, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
34121
- if (current !== void 0 && current.isSocket() && !current.isSymbolicLink() && current.dev === identity.dev && current.ino === identity.ino) await fs27.unlink(endpoint);
34170
+ const current = await fs28.lstat(endpoint, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
34171
+ if (current !== void 0 && current.isSocket() && !current.isSymbolicLink() && current.dev === identity.dev && current.ino === identity.ino) await fs28.unlink(endpoint);
34122
34172
  }
34123
34173
 
34124
34174
  // packages/localapp/src/daemon/daemon.ts
@@ -34137,7 +34187,7 @@ async function acquireDaemonLock(options2) {
34137
34187
  let reclaimed = false;
34138
34188
  while (true) {
34139
34189
  try {
34140
- const handle = await fs28.open(options2.layout.lockPath, "wx", 384);
34190
+ const handle = await fs29.open(options2.layout.lockPath, "wx", 384);
34141
34191
  try {
34142
34192
  await handle.writeFile(`${JSON.stringify(record6)}
34143
34193
  `);
@@ -34154,7 +34204,7 @@ async function acquireDaemonLock(options2) {
34154
34204
  } };
34155
34205
  } catch (error) {
34156
34206
  await handle.close().catch(() => void 0);
34157
- await fs28.unlink(options2.layout.lockPath).catch(() => void 0);
34207
+ await fs29.unlink(options2.layout.lockPath).catch(() => void 0);
34158
34208
  throw error;
34159
34209
  }
34160
34210
  } catch (error) {
@@ -34291,7 +34341,7 @@ var LocalAppDaemon = class {
34291
34341
  const current = await readCurrentRelease(this.options.layout);
34292
34342
  const manifest = await verifyReleaseArtifact(current.releasePath);
34293
34343
  if (typeof manifest.serverEntrypoint !== "string") throw lifecycleError("canonical_server_unavailable", "The packed canonical LocalApp Server runtime is unavailable");
34294
- const entrypoint = path33.join(current.releasePath, ...manifest.serverEntrypoint.split("/"));
34344
+ const entrypoint = path34.join(current.releasePath, ...manifest.serverEntrypoint.split("/"));
34295
34345
  const spawn8 = this.options.spawnOwnedProcess ?? spawnOwnedProcess;
34296
34346
  const server = spawn8(process.execPath, [entrypoint, "start", "--data-dir", this.options.layout.dataDir, "--host", "127.0.0.1", "--port", "0"], {
34297
34347
  cwd: current.releasePath,
@@ -34361,12 +34411,12 @@ var LocalAppDaemon = class {
34361
34411
  if (failure !== void 0) throw failure;
34362
34412
  }
34363
34413
  async createDefaultNotificationRuntime(options2) {
34364
- const store = new DeliveryStore({ statePath: path33.join(this.options.layout.supportDir, "notifications", "delivery-state.json") });
34365
- const native = await createNativeAdapter(path33.join(options2.releasePath, "runtime", "native"), { supportDir: this.options.layout.supportDir });
34414
+ const store = new DeliveryStore({ statePath: path34.join(this.options.layout.supportDir, "notifications", "delivery-state.json") });
34415
+ const native = await createNativeAdapter(path34.join(options2.releasePath, "runtime", "native"), { supportDir: this.options.layout.supportDir });
34366
34416
  const dispatcher = new NotificationDispatcher({
34367
34417
  store,
34368
34418
  adapter: native,
34369
- iconPath: path33.join(options2.releasePath, "runtime", "server", "web", "home", "redline-launch-hero.png")
34419
+ iconPath: path34.join(options2.releasePath, "runtime", "server", "web", "home", "redline-launch-hero.png")
34370
34420
  });
34371
34421
  const manager = new NotificationConnectionManager({
34372
34422
  localServerOrigin: options2.listenUrl,
@@ -34456,17 +34506,17 @@ async function verifyHealth2(listenUrl, timeoutMs) {
34456
34506
  }
34457
34507
  }
34458
34508
  async function readLock(lockPath) {
34459
- const before = await fs28.lstat(lockPath, { bigint: true });
34509
+ const before = await fs29.lstat(lockPath, { bigint: true });
34460
34510
  if (!before.isFile() || before.isSymbolicLink() || process.platform !== "win32" && (Number(before.mode) & 63) !== 0) {
34461
34511
  throw lifecycleError("daemon_lock_invalid", "The LocalApp daemon lock is unsafe");
34462
34512
  }
34463
34513
  let value2;
34464
34514
  try {
34465
- value2 = JSON.parse(await fs28.readFile(lockPath, "utf8"));
34515
+ value2 = JSON.parse(await fs29.readFile(lockPath, "utf8"));
34466
34516
  } catch {
34467
34517
  throw lifecycleError("daemon_lock_invalid", "The LocalApp daemon lock is malformed");
34468
34518
  }
34469
- const after = await fs28.lstat(lockPath, { bigint: true });
34519
+ const after = await fs29.lstat(lockPath, { bigint: true });
34470
34520
  if (!after.isFile() || after.isSymbolicLink() || after.dev !== before.dev || after.ino !== before.ino) {
34471
34521
  throw lifecycleError("daemon_lock_invalid", "The LocalApp daemon lock changed while reading");
34472
34522
  }
@@ -34497,20 +34547,20 @@ async function probeEndpoint(endpoint, bootId) {
34497
34547
  }
34498
34548
  }
34499
34549
  async function ensurePrivateRuntimeDirectory(directory) {
34500
- await fs28.mkdir(directory, { recursive: true, mode: 448 });
34501
- const stat2 = await fs28.lstat(directory);
34550
+ await fs29.mkdir(directory, { recursive: true, mode: 448 });
34551
+ const stat2 = await fs29.lstat(directory);
34502
34552
  if (!stat2.isDirectory() || stat2.isSymbolicLink() || process.platform !== "win32" && (stat2.mode & 63) !== 0) {
34503
34553
  throw lifecycleError("daemon_lock_invalid", "The LocalApp runtime directory is unsafe");
34504
34554
  }
34505
34555
  }
34506
34556
  async function unlinkOwned2(filePath, identity) {
34507
- const current = await fs28.lstat(filePath, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
34557
+ const current = await fs29.lstat(filePath, { bigint: true }).catch((error) => error.code === "ENOENT" ? void 0 : Promise.reject(error));
34508
34558
  if (current === void 0 || !current.isFile() || current.isSymbolicLink() || current.dev !== identity.dev || current.ino !== identity.ino) return false;
34509
- await fs28.unlink(filePath);
34559
+ await fs29.unlink(filePath);
34510
34560
  return true;
34511
34561
  }
34512
34562
  function digestDataRoot(dataDir) {
34513
- return crypto11.createHash("sha256").update(path33.resolve(dataDir)).digest("hex");
34563
+ return crypto11.createHash("sha256").update(path34.resolve(dataDir)).digest("hex");
34514
34564
  }
34515
34565
  async function withCleanupTimeout(operation, timeoutMs) {
34516
34566
  let timer;
@@ -34574,8 +34624,8 @@ async function verifyWindowsRuntimeOwnership(layout) {
34574
34624
  }
34575
34625
 
34576
34626
  // packages/localapp/src/main.ts
34577
- import path34 from "node:path";
34578
- import fs29 from "node:fs";
34627
+ import path35 from "node:path";
34628
+ import fs30 from "node:fs";
34579
34629
  import { fileURLToPath as fileURLToPath5 } from "node:url";
34580
34630
  async function runLocalApp(argv, io = defaultCliIo()) {
34581
34631
  try {
@@ -34592,7 +34642,7 @@ async function runLocalApp(argv, io = defaultCliIo()) {
34592
34642
  } else if (command.kind === "whoami") {
34593
34643
  return whoami(command, io);
34594
34644
  } else if (command.kind === "init") {
34595
- const name = command.name ?? path34.basename(process.cwd());
34645
+ const name = command.name ?? path35.basename(process.cwd());
34596
34646
  await initializeProject({ cwd: process.cwd(), name, skipInstall: command.skipInstall, skipDeploy: command.skipDeploy, io });
34597
34647
  } else if (command.kind === "sync-template") {
34598
34648
  const result = await syncManagedTemplate(process.cwd(), command);
@@ -34679,9 +34729,9 @@ if (process.argv[1] !== void 0 && isMainModule(fileURLToPath5(import.meta.url),
34679
34729
  }
34680
34730
  function isMainModule(modulePath, invokedPath) {
34681
34731
  try {
34682
- return fs29.realpathSync(modulePath) === fs29.realpathSync(invokedPath);
34732
+ return fs30.realpathSync(modulePath) === fs30.realpathSync(invokedPath);
34683
34733
  } catch {
34684
- return path34.resolve(modulePath) === path34.resolve(invokedPath);
34734
+ return path35.resolve(modulePath) === path35.resolve(invokedPath);
34685
34735
  }
34686
34736
  }
34687
34737
  export {