bazilion 0.23.0 → 0.24.0

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 (95) hide show
  1. package/README.md +18 -7
  2. package/dist/cli-main.js +30 -13
  3. package/dist/cli-main.js.map +1 -1
  4. package/dist/daemon-main.js +325 -113
  5. package/dist/daemon-main.js.map +1 -1
  6. package/dist/web/client/assets/{AgentTabs-ZozvE4RV.js → AgentTabs-0mMqUuts.js} +1 -1
  7. package/dist/web/client/assets/{ChatPane-nv9xOKnM.js → ChatPane-C4ZAMSqQ.js} +2 -2
  8. package/dist/web/client/assets/{ConfigPage-D_3AsSG4.js → ConfigPage-CbALCsl0.js} +1 -1
  9. package/dist/web/client/assets/{ConfirmDialog-CH2zTXuo.js → ConfirmDialog-CB1a-szq.js} +1 -1
  10. package/dist/web/client/assets/{FieldRow-CcrDV3An.js → FieldRow-BHGq10hz.js} +1 -1
  11. package/dist/web/client/assets/{ProductionTeamPolicyEditor-DNJsrcW8.js → ProductionTeamPolicyEditor-B4Ysob7y.js} +1 -1
  12. package/dist/web/client/assets/{ProfileCommunicationEditor-B2SthMNH.js → ProfileCommunicationEditor-Bi1SwX0T.js} +1 -1
  13. package/dist/web/client/assets/{RecoveryState-DlaJiGZs.js → RecoveryState-CDWhoT3x.js} +1 -1
  14. package/dist/web/client/assets/{ResultCard-CF7a0iFy.js → ResultCard-Crmt8j95.js} +1 -1
  15. package/dist/web/client/assets/{ResultSourceConversation-X5SuheW6.js → ResultSourceConversation-CqwZKlKb.js} +1 -1
  16. package/dist/web/client/assets/{SectionTabs-CCHDsNpe.js → SectionTabs-mghnc98b.js} +1 -1
  17. package/dist/web/client/assets/{TeamTabs-BplbR2LB.js → TeamTabs-BuZ3DvCw.js} +1 -1
  18. package/dist/web/client/assets/{TemplatesTabs-DsnlhO7j.js → TemplatesTabs-D71oTTXM.js} +1 -1
  19. package/dist/web/client/assets/{UnsavedChangesGuard-BFGfvKOY.js → UnsavedChangesGuard-CiCtGDIH.js} +1 -1
  20. package/dist/web/client/assets/{_id-CHE9wjEm.js → _id-B-8ssJLW.js} +1 -1
  21. package/dist/web/client/assets/{_id-HgkOZjnh.js → _id-BVY0iUYM.js} +1 -1
  22. package/dist/web/client/assets/{_id-I4COPqTO.js → _id-C7A_A3eM.js} +1 -1
  23. package/dist/web/client/assets/{_id-W8yP8QHB.js → _id-CQlUNjzV.js} +1 -1
  24. package/dist/web/client/assets/{_id-CM4HcwqG.js → _id-CeALz6bj.js} +1 -1
  25. package/dist/web/client/assets/{_id-fxbpjlEa.js → _id-DQqcn57I.js} +1 -1
  26. package/dist/web/client/assets/{_id-eKsjDym9.js → _id-DRiwwqZL.js} +1 -1
  27. package/dist/web/client/assets/{_id-C75PSTfh.js → _id-DaqX-WEB.js} +1 -1
  28. package/dist/web/client/assets/{activity-BCYUctkB.js → activity-C5aaqPEN.js} +1 -1
  29. package/dist/web/client/assets/{activity-jvvmbNos.js → activity-D4Nt8GQM.js} +1 -1
  30. package/dist/web/client/assets/{agents-C6mJyZUx.js → agents-BPLszpKx.js} +1 -1
  31. package/dist/web/client/assets/{agents-CpusMfSn.js → agents-BUqq1VBQ.js} +1 -1
  32. package/dist/web/client/assets/{agents-CvLzI7m_.js → agents-DFOLPsgX.js} +1 -1
  33. package/dist/web/client/assets/{approvals-Cd2np6JM.js → approvals-8PPXdZxV.js} +1 -1
  34. package/dist/web/client/assets/{approvals-C2R4qUbS.js → approvals-MVCITL8Q.js} +1 -1
  35. package/dist/web/client/assets/{attention-Q_sRUULz.js → attention-DiyHVOcZ.js} +1 -1
  36. package/dist/web/client/assets/{attention-CFwT25yC.js → attention-e273gZ8d.js} +1 -1
  37. package/dist/web/client/assets/chevron-right-DgJy0QeF.js +1 -0
  38. package/dist/web/client/assets/{config-B7UhhXW6.js → config-Dm6OgnLh.js} +3 -3
  39. package/dist/web/client/assets/{context-Cjb1-4nB.js → context-DhgSlMk5.js} +1 -1
  40. package/dist/web/client/assets/{inbox-QoBXXR8s.js → inbox-B3To3KpL.js} +1 -1
  41. package/dist/web/client/assets/{inbox-CX0alCy_.js → inbox-C1_vHPb8.js} +1 -1
  42. package/dist/web/client/assets/{index-Du-fy_6d.js → index-DtEE9JX2.js} +2 -2
  43. package/dist/web/client/assets/{learning-C1n4NTM1.js → learning-B7wX_mkT.js} +1 -1
  44. package/dist/web/client/assets/{learning-VwXsV_lU.js → learning-DDwUAKmq.js} +1 -1
  45. package/dist/web/client/assets/{login-CqnOW-JM.js → login-CWaSGdgc.js} +1 -1
  46. package/dist/web/client/assets/{mcp-B02-ofb9.js → mcp-CO5iBKHD.js} +1 -1
  47. package/dist/web/client/assets/{mcp-DMpVmmfU.js → mcp-DO8sSn5c.js} +1 -1
  48. package/dist/web/client/assets/{members-va8WzU_O.js → members-Bd3z1Mbb.js} +1 -1
  49. package/dist/web/client/assets/{members-CEkRCNto.js → members-Dx9OcdY1.js} +1 -1
  50. package/dist/web/client/assets/{memory-DiGxdDEp.js → memory-BIZi6bBM.js} +1 -1
  51. package/dist/web/client/assets/{memory-DejWBeGz.js → memory-DrYbH0we.js} +1 -1
  52. package/dist/web/client/assets/{policy-DgIcquCb.js → policy-CcnTn0qG.js} +1 -1
  53. package/dist/web/client/assets/{policy-CEiX5AXJ.js → policy-Dsj-SWqE.js} +1 -1
  54. package/dist/web/client/assets/{results-DsK9IvTu.js → results-GeOLM5Cw.js} +1 -1
  55. package/dist/web/client/assets/{results-BBBBjgd1.js → results-t7jAchgU.js} +1 -1
  56. package/dist/web/client/assets/{review-X2RHaLwW.js → review-CQaZNlyx.js} +1 -1
  57. package/dist/web/client/assets/{review-BGbU_GAW.js → review-CYvx-3K2.js} +1 -1
  58. package/dist/web/client/assets/{routes-CNz-oflx.js → routes-DoK4DMdi.js} +1 -1
  59. package/dist/web/client/assets/{services-dcsfVgOY.js → services-BI7iyTHh.js} +1 -1
  60. package/dist/web/client/assets/{services-D7TEP2JX.js → services-c9HkxKEP.js} +1 -1
  61. package/dist/web/client/assets/{skills-CnI7SkP2.js → skills-B0O0zwg1.js} +1 -1
  62. package/dist/web/client/assets/{skills-NDtAsHyl.js → skills-Ddf5PBNn.js} +1 -1
  63. package/dist/web/client/assets/{styles-CjCML-UX.css → styles-e_ADuRbs.css} +1 -1
  64. package/dist/web/client/assets/{teams-DPgdJBly.js → teams-BDbkurIa.js} +1 -1
  65. package/dist/web/client/assets/{teams-DErd3Weq.js → teams-BNQ4z_k3.js} +1 -1
  66. package/dist/web/client/assets/{teams-DETtQypB.js → teams-Wvr8-LhE.js} +1 -1
  67. package/dist/web/client/assets/{teams-Dyll0JrQ.js → teams-kRB5hV3h.js} +1 -1
  68. package/dist/web/client/assets/{telegram-CAGu-kLc.js → telegram-Dx9tzt9d.js} +1 -1
  69. package/dist/web/client/assets/{templates-CgOQU6RS.js → templates-CGQ93r-m.js} +1 -1
  70. package/dist/web/client/assets/{tokens-BYVE1y6V.js → tokens-CsOJULk9.js} +1 -1
  71. package/dist/web/client/assets/{tokens-CvjME9aI.js → tokens-zqJy3CQD.js} +1 -1
  72. package/dist/web/client/assets/{triggers-Dmli752j.js → triggers-9UUKTR6l.js} +1 -1
  73. package/dist/web/client/assets/{triggers-BeZ7olEG.js → triggers-BiXb1VFy.js} +1 -1
  74. package/dist/web/client/assets/{verifications-CnLEVFoZ.js → verifications-BKoHhRqF.js} +1 -1
  75. package/dist/web/client/assets/{verifications-qQz5-X-o.js → verifications-CElk4UQp.js} +1 -1
  76. package/dist/web/client/assets/{welcome-BF3pg5U5.js → welcome-BdcpBETx.js} +1 -1
  77. package/dist/web/client/assets/{x-B-Fk6DuU.js → x-DtPVZP1O.js} +1 -1
  78. package/dist/web/server/assets/{ChatPane-DsDa1E0a.js → ChatPane-3CIVTz7o.js} +1 -0
  79. package/dist/web/server/assets/{ResultSourceConversation-NKiRGO6_.js → ResultSourceConversation-DwuGuTa-.js} +1 -1
  80. package/dist/web/server/assets/{_id-CrOJD02W.js → _id-C1-ygfez.js} +3 -3
  81. package/dist/web/server/assets/{_id-C1TCGcHL.js → _id-CWlZT9kI.js} +1 -1
  82. package/dist/web/server/assets/{_tanstack-start-manifest_v-CPSd5WEy.js → _tanstack-start-manifest_v-LR-ldomm.js} +134 -134
  83. package/dist/web/server/assets/{config-DX3c4Co0.js → config-CMxeC2Bd.js} +94 -2
  84. package/dist/web/server/assets/{config-DM2DIzMT.js → config-CbioK6nX.js} +1 -1
  85. package/dist/web/server/assets/{config-DTI4EPbU.js → config-CpHD812q.js} +6 -1
  86. package/dist/web/server/assets/{results-BYU6Bfzt.js → results-C6edENBF.js} +2 -2
  87. package/dist/web/server/assets/{results-Cr1B3XoP.js → results-DjTerNLY.js} +1 -1
  88. package/dist/web/server/assets/{router-B2R22qdF.js → router-Doy5hj6V.js} +5 -5
  89. package/dist/web/server/assets/{routes-BGMHt0b0.js → routes-ByEYvEFv.js} +2 -2
  90. package/dist/web/server/assets/{routes-kSjMHwrg.js → routes-Bz-Gprcp.js} +1 -1
  91. package/dist/web/server/server.js +3 -3
  92. package/dist/worker.js +157 -43
  93. package/dist/worker.js.map +1 -1
  94. package/package.json +8 -7
  95. package/dist/web/client/assets/chevron-right-BfSr7R_L.js +0 -1
@@ -412,7 +412,7 @@ var init_web_ssrf = __esm({
412
412
  });
413
413
 
414
414
  // ../daemon/src/lib/browser/observation.ts
415
- import { createHash as createHash11, randomUUID as randomUUID32 } from "crypto";
415
+ import { createHash as createHash11, randomUUID as randomUUID33 } from "crypto";
416
416
  async function readDomStats(page, scope) {
417
417
  try {
418
418
  const stats = await (scope === void 0 ? page.evaluate("window.__bazilion_obs.stats()") : (typeof scope === "string" ? page.locator(scope) : scope).evaluate(
@@ -721,7 +721,7 @@ ${text3}`;
721
721
  if (!hasFreshness) complete2 = false;
722
722
  const chunks = chunkText(text3);
723
723
  const obs = {
724
- observationId: randomUUID32(),
724
+ observationId: randomUUID33(),
725
725
  agentId,
726
726
  tabId,
727
727
  capturedAt: this.nowFn(),
@@ -743,7 +743,7 @@ ${text3}`;
743
743
  const hasMore = index < obs.chunks.length - 1;
744
744
  let cursorId = null;
745
745
  if (hasMore) {
746
- cursorId = randomUUID32();
746
+ cursorId = randomUUID33();
747
747
  this.cursors.set(cursorId, {
748
748
  id: cursorId,
749
749
  observationId: obs.observationId,
@@ -1784,7 +1784,7 @@ var init_executable = __esm({
1784
1784
  });
1785
1785
 
1786
1786
  // ../daemon/src/lib/daemon-liveness.ts
1787
- import { createHash as createHash13, randomUUID as randomUUID33 } from "crypto";
1787
+ import { createHash as createHash13, randomUUID as randomUUID34 } from "crypto";
1788
1788
  import {
1789
1789
  chmodSync,
1790
1790
  closeSync as closeSync9,
@@ -1952,7 +1952,7 @@ function acquireDaemonLiveness(paths2) {
1952
1952
  mkdirSync9(dirname7(resolve7(paths2.home)), { recursive: true });
1953
1953
  const path = daemonLivenessPath(paths2.home);
1954
1954
  mkdirSync9(dirname7(path), { recursive: true });
1955
- const instanceId = randomUUID33();
1955
+ const instanceId = randomUUID34();
1956
1956
  const startedAt = Date.now();
1957
1957
  let fd = null;
1958
1958
  let reclaimClaim = null;
@@ -2317,7 +2317,7 @@ var init_guards = __esm({
2317
2317
  });
2318
2318
 
2319
2319
  // ../daemon/src/lib/browser/profile.ts
2320
- import { randomUUID as randomUUID34 } from "crypto";
2320
+ import { randomUUID as randomUUID35 } from "crypto";
2321
2321
  import {
2322
2322
  chmodSync as chmodSync3,
2323
2323
  closeSync as closeSync10,
@@ -2331,7 +2331,7 @@ import {
2331
2331
  readdirSync as readdirSync12,
2332
2332
  readFileSync as readFileSync15,
2333
2333
  readlinkSync as readlinkSync2,
2334
- readSync as readSync4,
2334
+ readSync as readSync3,
2335
2335
  renameSync as renameSync4,
2336
2336
  rmSync as rmSync15,
2337
2337
  unlinkSync as unlinkSync2,
@@ -2448,7 +2448,7 @@ function readBoundedFile(path) {
2448
2448
  if (!stat2.isFile()) return { error: `${path} is not a regular file` };
2449
2449
  if (stat2.size > MAX_BROWSER_METADATA_BYTES) return { error: `${path} exceeds metadata bound` };
2450
2450
  const buf = Buffer.alloc(Math.max(stat2.size, 1));
2451
- const read = stat2.size > 0 ? readSync4(fd, buf, 0, stat2.size, 0) : 0;
2451
+ const read = stat2.size > 0 ? readSync3(fd, buf, 0, stat2.size, 0) : 0;
2452
2452
  return buf.subarray(0, read).toString("utf8");
2453
2453
  } catch (error) {
2454
2454
  const code = error.code;
@@ -2464,7 +2464,7 @@ function writeAtomicBounded(path, value, mode = 384) {
2464
2464
  if (Buffer.byteLength(body, "utf8") > MAX_BROWSER_METADATA_BYTES) {
2465
2465
  throw new BrowserProfileError("browser_start_failed", "browser metadata exceeds bound");
2466
2466
  }
2467
- const tmp = `${path}.tmp-${process.pid}-${randomUUID34().slice(0, 8)}`;
2467
+ const tmp = `${path}.tmp-${process.pid}-${randomUUID35().slice(0, 8)}`;
2468
2468
  let fd = null;
2469
2469
  try {
2470
2470
  fd = openSync10(tmp, "wx", mode);
@@ -2607,7 +2607,7 @@ function writeAtomicBoundedExclusive(path, value) {
2607
2607
  if (Buffer.byteLength(body, "utf8") > MAX_BROWSER_METADATA_BYTES) {
2608
2608
  throw new BrowserProfileError("browser_start_failed", "browser metadata exceeds bound");
2609
2609
  }
2610
- const tmp = `${path}.claim-${process.pid}-${randomUUID34().slice(0, 8)}`;
2610
+ const tmp = `${path}.claim-${process.pid}-${randomUUID35().slice(0, 8)}`;
2611
2611
  let fd = null;
2612
2612
  try {
2613
2613
  fd = openSync10(tmp, "wx", 384);
@@ -2788,7 +2788,7 @@ var init_profile = __esm({
2788
2788
 
2789
2789
  // ../daemon/src/lib/browser/process.ts
2790
2790
  import { execFile as execFile2, spawn as spawn3 } from "child_process";
2791
- import { randomUUID as randomUUID35 } from "crypto";
2791
+ import { randomUUID as randomUUID36 } from "crypto";
2792
2792
  import {
2793
2793
  closeSync as closeSync11,
2794
2794
  constants as constants11,
@@ -2799,7 +2799,7 @@ import {
2799
2799
  readdirSync as readdirSync13,
2800
2800
  readFileSync as readFileSync16,
2801
2801
  readlinkSync as readlinkSync3,
2802
- readSync as readSync5,
2802
+ readSync as readSync4,
2803
2803
  renameSync as renameSync5,
2804
2804
  rmSync as rmSync16,
2805
2805
  writeFileSync as writeFileSync12
@@ -2911,7 +2911,7 @@ function prepareProfile(profileDir) {
2911
2911
  try {
2912
2912
  if (!fstatSync9(fd).isFile()) throw new Error("unsafe browser preferences");
2913
2913
  const bytes = Buffer.alloc(4 * 1024 * 1024 + 1);
2914
- const size = readSync5(fd, bytes, 0, bytes.length, 0);
2914
+ const size = readSync4(fd, bytes, 0, bytes.length, 0);
2915
2915
  if (size === bytes.length) throw new Error("oversized browser preferences");
2916
2916
  prefs = JSON.parse(bytes.subarray(0, size).toString("utf8"));
2917
2917
  } finally {
@@ -2925,7 +2925,7 @@ function prepareProfile(profileDir) {
2925
2925
  const record4 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
2926
2926
  prefs.session = { ...record4(prefs.session), restore_on_startup: 5 };
2927
2927
  prefs.profile = { ...record4(prefs.profile), exit_type: "Normal", exited_cleanly: true };
2928
- const tmp = `${path}.bazilion-${randomUUID35()}`;
2928
+ const tmp = `${path}.bazilion-${randomUUID36()}`;
2929
2929
  try {
2930
2930
  writeFileSync12(tmp, JSON.stringify(prefs), { flag: "wx", mode: 384 });
2931
2931
  renameSync5(tmp, path);
@@ -3132,7 +3132,7 @@ var init_process = __esm({
3132
3132
  });
3133
3133
 
3134
3134
  // ../daemon/src/lib/browser/launch.ts
3135
- import { randomUUID as randomUUID36 } from "crypto";
3135
+ import { randomUUID as randomUUID37 } from "crypto";
3136
3136
  import { join as join29 } from "path";
3137
3137
  function lockMayBeHeld(profileDir) {
3138
3138
  const pid = readSingletonLockPid(profileDir);
@@ -3164,7 +3164,7 @@ async function launchManagedBrowser(input) {
3164
3164
  "another browser may hold this profile lock"
3165
3165
  );
3166
3166
  }
3167
- const launchNonce = randomUUID36();
3167
+ const launchNonce = randomUUID37();
3168
3168
  const marker = {
3169
3169
  formatVersion: BROWSER_PROFILE_FORMAT_VERSION,
3170
3170
  agentId: input.agentId,
@@ -12544,7 +12544,7 @@ function reconcilePrivateResults(db, options = {}) {
12544
12544
  }
12545
12545
 
12546
12546
  // ../daemon/src/lib/coding-environment/lifecycle.ts
12547
- import { randomUUID as randomUUID28 } from "crypto";
12547
+ import { randomUUID as randomUUID29 } from "crypto";
12548
12548
 
12549
12549
  // ../daemon/src/lib/coding-environment/workspace.ts
12550
12550
  import { randomUUID as randomUUID25 } from "crypto";
@@ -12560,10 +12560,15 @@ import {
12560
12560
  lstatSync,
12561
12561
  opendirSync,
12562
12562
  openSync,
12563
- readSync,
12564
12563
  realpathSync as realpathSync2
12565
12564
  } from "fs";
12566
12565
  import { isAbsolute, join as join12 } from "path";
12566
+ import {
12567
+ assertDirectoryIdentitySync,
12568
+ openRootFileSync,
12569
+ readFileDescriptorBoundedSync
12570
+ } from "@openclaw/fs-safe/advanced";
12571
+ import { FsSafeError } from "@openclaw/fs-safe/errors";
12567
12572
  var hash3 = (value) => createHash9("sha256").update(value).digest("hex");
12568
12573
  var ContextReadError = class extends Error {
12569
12574
  code;
@@ -12576,7 +12581,7 @@ function identity(stat2) {
12576
12581
  return `${stat2.dev}:${stat2.ino}`;
12577
12582
  }
12578
12583
  function stamp(stat2) {
12579
- return `${identity(stat2)}:${stat2.size}:${stat2.mtimeMs}:${stat2.ctimeMs}`;
12584
+ return `${identity(stat2)}:${stat2.size}:${stat2.mtimeNs}:${stat2.ctimeNs}`;
12580
12585
  }
12581
12586
  function relativeParts(target) {
12582
12587
  if (target.length > 4096 || isAbsolute(target) || [...target].some(
@@ -12587,31 +12592,93 @@ function relativeParts(target) {
12587
12592
  if (parts.length > 17) throw new ContextReadError("depth_limit");
12588
12593
  return parts;
12589
12594
  }
12595
+ function component(name) {
12596
+ if (!name || name === "." || name === ".." || /[/\\\0]/.test(name))
12597
+ throw new ContextReadError("unsafe_target");
12598
+ }
12590
12599
  var ContextDirectory = class _ContextDirectory {
12591
12600
  fd;
12592
12601
  identity;
12593
- originalStamp;
12594
- children = [];
12595
- listing;
12596
- observedFiles = /* @__PURE__ */ new Map();
12597
12602
  registeredPath;
12598
12603
  label;
12599
12604
  parent;
12605
+ platform;
12606
+ canonicalPath;
12607
+ originalIdentity;
12608
+ children = [];
12609
+ listing;
12610
+ observedFiles = /* @__PURE__ */ new Map();
12611
+ closed = false;
12600
12612
  constructor(registeredPath, label = ".", parent) {
12613
+ const platform = parent?.platform ?? process.platform;
12614
+ if (platform !== "linux" && platform !== "darwin")
12615
+ throw new ContextReadError("safe_reads_unavailable");
12616
+ this.platform = platform;
12601
12617
  this.registeredPath = registeredPath;
12602
12618
  this.label = label;
12603
12619
  this.parent = parent;
12604
- if (process.platform !== "linux") throw new ContextReadError("safe_reads_unavailable");
12605
- const path = parent ? join12(parent.path, registeredPath) : realpathSync2(registeredPath);
12606
- this.fd = openSync(path, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
12607
- const stat2 = fstatSync(this.fd);
12608
- this.identity = hash3(identity(stat2));
12609
- this.originalStamp = identity(stat2);
12620
+ if (parent) component(registeredPath);
12621
+ parent?.assertCurrent();
12622
+ const canonicalPath = parent ? join12(parent.canonicalPath, registeredPath) : realpathSync2(registeredPath);
12623
+ let fd;
12624
+ try {
12625
+ if (platform === "linux") {
12626
+ this.canonicalPath = canonicalPath;
12627
+ fd = openSync(
12628
+ parent ? join12(parent.path, registeredPath) : canonicalPath,
12629
+ constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW
12630
+ );
12631
+ } else {
12632
+ const opened = openRootFileSync({
12633
+ rootPath: parent?.canonicalPath ?? canonicalPath,
12634
+ absolutePath: canonicalPath,
12635
+ boundaryLabel: "registered repository",
12636
+ allowedType: "directory",
12637
+ symlinks: "reject"
12638
+ });
12639
+ if (!opened.ok) throw new ContextReadError("root_changed");
12640
+ this.canonicalPath = opened.path;
12641
+ fd = opened.fd;
12642
+ }
12643
+ const stat2 = fstatSync(fd, { bigint: true });
12644
+ if (!stat2.isDirectory() || stat2.ino <= 0n) throw new ContextReadError("root_changed");
12645
+ this.fd = fd;
12646
+ this.originalIdentity = { dev: stat2.dev, ino: stat2.ino };
12647
+ this.identity = hash3(identity(stat2));
12648
+ if (platform === "darwin") this.assertCurrent();
12649
+ fd = void 0;
12650
+ } finally {
12651
+ if (fd !== void 0) closeSync(fd);
12652
+ }
12610
12653
  }
12611
12654
  get path() {
12612
- return `/proc/self/fd/${this.fd}`;
12655
+ return this.platform === "linux" ? `/proc/self/fd/${this.fd}` : this.canonicalPath;
12656
+ }
12657
+ /** Only the existing Linux backend admits a descriptor-pinned external Git worktree. */
12658
+ get gitWorktreePath() {
12659
+ return this.platform === "linux" ? `/proc/${process.pid}/fd/${this.fd}` : null;
12660
+ }
12661
+ assertCurrent() {
12662
+ if (this.closed) throw new ContextReadError("unreadable");
12663
+ if (this.platform === "linux") return;
12664
+ this.parent?.assertCurrent();
12665
+ try {
12666
+ const registered = this.parent ? join12(this.parent.canonicalPath, this.registeredPath) : realpathSync2(this.registeredPath);
12667
+ if (!this.parent && registered !== this.canonicalPath)
12668
+ throw new ContextReadError("root_changed");
12669
+ assertDirectoryIdentitySync(registered, {
12670
+ ...this.originalIdentity,
12671
+ realPath: this.canonicalPath
12672
+ });
12673
+ const retained = fstatSync(this.fd, { bigint: true });
12674
+ if (!retained.isDirectory() || identity(retained) !== identity(this.originalIdentity))
12675
+ throw new ContextReadError("root_changed");
12676
+ } catch {
12677
+ throw new ContextReadError("root_changed");
12678
+ }
12613
12679
  }
12614
12680
  directory(name) {
12681
+ component(name);
12615
12682
  const child = new _ContextDirectory(
12616
12683
  name,
12617
12684
  this.label === "." ? name : `${this.label}/${name}`,
@@ -12621,10 +12688,29 @@ var ContextDirectory = class _ContextDirectory {
12621
12688
  return child;
12622
12689
  }
12623
12690
  entry(name) {
12691
+ component(name);
12692
+ this.assertCurrent();
12693
+ try {
12694
+ const stat2 = lstatSync(join12(this.path, name));
12695
+ this.assertCurrent();
12696
+ return stat2;
12697
+ } catch (error) {
12698
+ this.assertCurrent();
12699
+ if (error.code === "ENOENT") return null;
12700
+ if (error instanceof ContextReadError) throw error;
12701
+ throw new ContextReadError("unreadable");
12702
+ }
12703
+ }
12704
+ observe(name) {
12705
+ this.assertCurrent();
12624
12706
  try {
12625
- return lstatSync(join12(this.path, name));
12707
+ const stat2 = lstatSync(join12(this.path, name), { bigint: true });
12708
+ this.assertCurrent();
12709
+ return stat2;
12626
12710
  } catch (error) {
12711
+ this.assertCurrent();
12627
12712
  if (error.code === "ENOENT") return null;
12713
+ if (error instanceof ContextReadError) throw error;
12628
12714
  throw new ContextReadError("unreadable");
12629
12715
  }
12630
12716
  }
@@ -12634,6 +12720,7 @@ var ContextDirectory = class _ContextDirectory {
12634
12720
  return names;
12635
12721
  }
12636
12722
  listNames() {
12723
+ this.assertCurrent();
12637
12724
  const handle13 = opendirSync(this.path);
12638
12725
  const names = [];
12639
12726
  try {
@@ -12643,58 +12730,71 @@ var ContextDirectory = class _ContextDirectory {
12643
12730
  names.push(entry.name);
12644
12731
  entry = handle13.readSync();
12645
12732
  }
12733
+ this.assertCurrent();
12646
12734
  return names.sort();
12647
12735
  } finally {
12648
12736
  handle13.closeSync();
12649
12737
  }
12650
12738
  }
12651
12739
  read(name, maxBytes) {
12652
- const entry = this.entry(name);
12740
+ component(name);
12741
+ const entry = this.observe(name);
12653
12742
  if (!entry) {
12654
12743
  this.observedFiles.set(name, null);
12655
12744
  return null;
12656
12745
  }
12657
12746
  if (!entry.isFile() || entry.isSymbolicLink()) throw new ContextReadError("unsafe_file");
12747
+ if (entry.ino <= 0n) throw new ContextReadError("unreadable");
12658
12748
  if (entry.size > maxBytes) throw new ContextReadError("byte_limit");
12659
12749
  let fd;
12660
12750
  try {
12661
- fd = openSync(
12662
- join12(this.path, name),
12663
- constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK
12664
- );
12665
- const before = fstatSync(fd);
12751
+ if (this.platform === "linux") {
12752
+ fd = openSync(
12753
+ join12(this.path, name),
12754
+ constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK
12755
+ );
12756
+ } else {
12757
+ this.assertCurrent();
12758
+ const opened = openRootFileSync({
12759
+ rootPath: this.canonicalPath,
12760
+ absolutePath: join12(this.canonicalPath, name),
12761
+ boundaryLabel: "captured repository directory",
12762
+ symlinks: "reject",
12763
+ maxBytes
12764
+ });
12765
+ if (!opened.ok) throw new ContextReadError("source_changed");
12766
+ fd = opened.fd;
12767
+ this.assertCurrent();
12768
+ }
12769
+ const before = fstatSync(fd, { bigint: true });
12666
12770
  if (!before.isFile() || stamp(entry) !== stamp(before))
12667
12771
  throw new ContextReadError("source_changed");
12668
- const buffer = Buffer.alloc(Math.min(maxBytes + 1, before.size + 1));
12669
- let size = 0;
12670
- while (size < buffer.length) {
12671
- const count3 = readSync(fd, buffer, size, buffer.length - size, null);
12672
- if (!count3) break;
12673
- size += count3;
12674
- }
12675
- if (size > maxBytes || size !== before.size || stamp(fstatSync(fd)) !== stamp(before)) {
12772
+ const buffer = readFileDescriptorBoundedSync(fd, maxBytes);
12773
+ if (BigInt(buffer.length) !== before.size || stamp(fstatSync(fd, { bigint: true })) !== stamp(before))
12676
12774
  throw new ContextReadError("source_changed");
12677
- }
12775
+ this.assertCurrent();
12678
12776
  this.observedFiles.set(name, stamp(before));
12679
- return buffer.subarray(0, size);
12777
+ return buffer;
12680
12778
  } catch (error) {
12681
12779
  if (error instanceof ContextReadError) throw error;
12780
+ if (error instanceof FsSafeError && error.code === "too-large")
12781
+ throw new ContextReadError("source_changed");
12682
12782
  throw new ContextReadError("unreadable");
12683
12783
  } finally {
12684
12784
  if (fd !== void 0) closeSync(fd);
12685
12785
  }
12686
12786
  }
12687
12787
  validate(skipGit = false, names) {
12788
+ this.assertCurrent();
12688
12789
  const currentPath = this.parent ? join12(this.parent.path, this.registeredPath) : realpathSync2(this.registeredPath);
12689
- const stat2 = lstatSync(currentPath);
12690
- if (!stat2.isDirectory() || identity(stat2) !== this.originalStamp)
12790
+ const stat2 = lstatSync(currentPath, { bigint: true });
12791
+ if (!stat2.isDirectory() || identity(stat2) !== identity(this.originalIdentity))
12691
12792
  throw new ContextReadError("root_changed");
12692
- if (this.listing !== void 0 && JSON.stringify(this.listNames()) !== this.listing) {
12793
+ if (this.listing !== void 0 && JSON.stringify(this.listNames()) !== this.listing)
12693
12794
  throw new ContextReadError("source_changed");
12694
- }
12695
12795
  for (const [name, previous] of this.observedFiles) {
12696
12796
  if (names && !names.has(name)) continue;
12697
- const current = this.entry(name);
12797
+ const current = this.observe(name);
12698
12798
  if ((current ? stamp(current) : null) !== previous)
12699
12799
  throw new ContextReadError("source_changed");
12700
12800
  }
@@ -12703,8 +12803,22 @@ var ContextDirectory = class _ContextDirectory {
12703
12803
  }
12704
12804
  }
12705
12805
  close() {
12706
- for (const child of this.children) child.close();
12707
- closeSync(this.fd);
12806
+ if (this.closed) return;
12807
+ this.closed = true;
12808
+ let failure;
12809
+ for (const child of this.children) {
12810
+ try {
12811
+ child.close();
12812
+ } catch (error) {
12813
+ failure ??= error;
12814
+ }
12815
+ }
12816
+ try {
12817
+ closeSync(this.fd);
12818
+ } catch (error) {
12819
+ failure ??= error;
12820
+ }
12821
+ if (failure) throw failure;
12708
12822
  }
12709
12823
  };
12710
12824
 
@@ -12725,7 +12839,7 @@ function overlappingWorkspaceRoots(a, b) {
12725
12839
  return contains(a, b) || contains(b, a);
12726
12840
  }
12727
12841
  function workspaceIdentity(registeredRoot) {
12728
- if (process.platform === "linux") {
12842
+ if (process.platform === "linux" || process.platform === "darwin") {
12729
12843
  const directory = new ContextDirectory(registeredRoot);
12730
12844
  try {
12731
12845
  const root2 = realpathSync3(registeredRoot);
@@ -13014,7 +13128,7 @@ var WorkspaceRecovery = class {
13014
13128
  };
13015
13129
 
13016
13130
  // ../daemon/src/lib/coding-environment/resources.ts
13017
- import { randomUUID as randomUUID27 } from "crypto";
13131
+ import { randomUUID as randomUUID28 } from "crypto";
13018
13132
 
13019
13133
  // ../daemon/src/runtime/shell/docker.ts
13020
13134
  import { spawn } from "child_process";
@@ -14234,6 +14348,56 @@ async function terminateRecordedContainer(identity3, creationAcknowledged = fals
14234
14348
  }
14235
14349
  }
14236
14350
 
14351
+ // ../daemon/src/runtime/worker/observed-child.ts
14352
+ import { ChildProcess } from "child_process";
14353
+ import { randomUUID as randomUUID27 } from "crypto";
14354
+ var ObservedChildWorker = class {
14355
+ constructor(pid, child, hostCommands) {
14356
+ this.child = child;
14357
+ if (process.platform !== "darwin" && process.platform !== "linux" || !(child instanceof ChildProcess) || !Number.isSafeInteger(pid) || pid <= 1 || pid === process.pid || child.pid !== pid || child.spawnfile !== process.execPath || child.exitCode !== null || child.signalCode !== null || !child.stdout || !child.stderr)
14358
+ throw new Error("Live worker ownership unavailable");
14359
+ try {
14360
+ process.kill(-pid, 0);
14361
+ } catch {
14362
+ throw new Error("Worker requires an isolated process group");
14363
+ }
14364
+ this.identity = Object.freeze({
14365
+ kind: "observed-posix-child",
14366
+ pid,
14367
+ token: randomUUID27(),
14368
+ hostCommands
14369
+ });
14370
+ child.once("close", (code, signal) => {
14371
+ this.closeObserved = true;
14372
+ this.closedNormally = code === 0 && signal === null && child.stdout?.readableEnded === true && child.stderr?.readableEnded === true;
14373
+ });
14374
+ }
14375
+ child;
14376
+ identity;
14377
+ closeObserved = false;
14378
+ closedNormally = false;
14379
+ matches(identity3) {
14380
+ return identity3.kind === this.identity.kind && identity3.pid === this.identity.pid && identity3.token === this.identity.token && identity3.hostCommands === this.identity.hostCommands;
14381
+ }
14382
+ async settled(observedNormalExit) {
14383
+ if (!observedNormalExit) return false;
14384
+ const deadline = Date.now() + 3500;
14385
+ while (Date.now() < deadline) {
14386
+ if (this.closedNormally) {
14387
+ try {
14388
+ process.kill(-this.identity.pid, 0);
14389
+ } catch (error) {
14390
+ return error.code === "ESRCH";
14391
+ }
14392
+ }
14393
+ if (this.closeObserved && !this.closedNormally || this.child.signalCode !== null || (this.child.exitCode ?? 0) !== 0)
14394
+ return false;
14395
+ await new Promise((resolve9) => setTimeout(resolve9, 25));
14396
+ }
14397
+ return false;
14398
+ }
14399
+ };
14400
+
14237
14401
  // ../daemon/src/runtime/worker/process-identity.ts
14238
14402
  import { readdirSync as readdirSync5, readFileSync as readFileSync8, readlinkSync, statSync as statSync4 } from "fs";
14239
14403
  function readStat(pid) {
@@ -14368,7 +14532,16 @@ var WorkspaceResources = class {
14368
14532
  this.db = db;
14369
14533
  }
14370
14534
  db;
14371
- registerWorker(lease, pid, hostCommands = false) {
14535
+ observedWorkers = /* @__PURE__ */ new Map();
14536
+ registerWorker(lease, pid, hostCommands = false, child) {
14537
+ if (process.platform === "darwin") {
14538
+ if (!child || this.observedWorkers.size >= 256)
14539
+ throw new Error("Live worker ownership unavailable");
14540
+ const observed = new ObservedChildWorker(pid, child, hostCommands);
14541
+ const id2 = this.register(lease, { kind: "worker", identity: observed.identity });
14542
+ this.observedWorkers.set(id2, observed);
14543
+ return id2;
14544
+ }
14372
14545
  return this.register(lease, {
14373
14546
  kind: "worker",
14374
14547
  identity: { ...captureWorkerProcess(pid), hostCommands }
@@ -14386,7 +14559,7 @@ var WorkspaceResources = class {
14386
14559
  }
14387
14560
  register(lease, resource) {
14388
14561
  return inTx(this.db, () => {
14389
- const id2 = randomUUID27();
14562
+ const id2 = randomUUID28();
14390
14563
  lease.attach({ id: id2, kind: resource.kind });
14391
14564
  this.db.raw.run(
14392
14565
  "INSERT INTO workspace_resources (id, writer_id, kind, identity_json) VALUES (?, ?, ?, ?)",
@@ -14406,9 +14579,12 @@ var WorkspaceResources = class {
14406
14579
  if (row2.cleanup_confirmed) return true;
14407
14580
  if (management?.confirmedWorkersOnly && row2.kind === "worker") return false;
14408
14581
  const identity3 = JSON.parse(row2.identity_json);
14409
- const confirmed = row2.kind === "worker" ? await terminateWorkerProcess(identity3, observedNormalExit) : await terminateRecordedContainer(identity3, row2.creation_acknowledged === 1);
14410
- if (confirmed)
14582
+ const observed = this.observedWorkers.get(id2);
14583
+ const confirmed = row2.kind === "worker" ? identity3.kind === "observed-posix-child" ? !!observed && observed.matches(identity3) && await observed.settled(observedNormalExit) : await terminateWorkerProcess(identity3, observedNormalExit) : await terminateRecordedContainer(identity3, row2.creation_acknowledged === 1);
14584
+ if (confirmed) {
14411
14585
  this.db.raw.run("UPDATE workspace_resources SET cleanup_confirmed = 1 WHERE id = ?", [id2]);
14586
+ this.observedWorkers.delete(id2);
14587
+ }
14412
14588
  return confirmed;
14413
14589
  }
14414
14590
  /** Workers first: stop new container requests before removing recorded containers. */
@@ -14462,9 +14638,9 @@ var WorkspaceLifecycle = class {
14462
14638
  worker(lease) {
14463
14639
  let id2;
14464
14640
  return {
14465
- beforeInput: (pid, hostCommands) => {
14641
+ beforeInput: (pid, hostCommands, child) => {
14466
14642
  if (id2) throw new Error("Worker resource already registered");
14467
- id2 = this.resources.registerWorker(lease, pid, hostCommands);
14643
+ id2 = this.resources.registerWorker(lease, pid, hostCommands, child);
14468
14644
  },
14469
14645
  afterExit: async (observedNormalExit) => id2 === void 0 || this.resources.cleanupResource(id2, observedNormalExit)
14470
14646
  };
@@ -14473,7 +14649,7 @@ var WorkspaceLifecycle = class {
14473
14649
  const prefix = `bazilion-${lease.writer.id}-`;
14474
14650
  const records2 = /* @__PURE__ */ new Map();
14475
14651
  return {
14476
- name: (kind) => `${prefix}${kind}-${randomUUID28()}`,
14652
+ name: (kind) => `${prefix}${kind}-${randomUUID29()}`,
14477
14653
  beforeCreate: async (identity3) => {
14478
14654
  if (!identity3.containerName.startsWith(prefix) || !/^bazilion-[a-z0-9-]{1,160}$/.test(identity3.containerName) || records2.has(identity3.containerName))
14479
14655
  throw new Error("Invalid turn container identity");
@@ -14508,7 +14684,7 @@ var WorkspaceLifecycle = class {
14508
14684
  };
14509
14685
 
14510
14686
  // ../daemon/src/lib/conversation-target.ts
14511
- import { randomUUID as randomUUID30 } from "crypto";
14687
+ import { randomUUID as randomUUID31 } from "crypto";
14512
14688
 
14513
14689
  // ../daemon/src/core/repos/conversations.ts
14514
14690
  var columns = "id, agent_id AS agentId, title, title_revision AS titleRevision, created_at AS createdAt, updated_at AS updatedAt";
@@ -14630,7 +14806,7 @@ function rename(db, agentId, id2, value, expectedRevision) {
14630
14806
  }
14631
14807
 
14632
14808
  // ../daemon/src/lib/conversation-file.ts
14633
- import { randomUUID as randomUUID29 } from "crypto";
14809
+ import { randomUUID as randomUUID30 } from "crypto";
14634
14810
  import {
14635
14811
  closeSync as closeSync4,
14636
14812
  constants as constants4,
@@ -14651,7 +14827,7 @@ import {
14651
14827
  fstatSync as fstatSync2,
14652
14828
  lstatSync as lstatSync2,
14653
14829
  openSync as openSync3,
14654
- readSync as readSync2,
14830
+ readSync,
14655
14831
  realpathSync as realpathSync5
14656
14832
  } from "fs";
14657
14833
  import { basename as basename3, join as join15 } from "path";
@@ -14674,7 +14850,7 @@ function readCanonicalSessionFile(directory, filename2, sessionId, minimumEntryO
14674
14850
  const buffer = Buffer.alloc(stat2.size + 1);
14675
14851
  let count3 = 0;
14676
14852
  while (count3 < buffer.length) {
14677
- const n = readSync2(fd, buffer, count3, buffer.length - count3, null);
14853
+ const n = readSync(fd, buffer, count3, buffer.length - count3, null);
14678
14854
  if (n === 0) break;
14679
14855
  count3 += n;
14680
14856
  }
@@ -14703,7 +14879,7 @@ function createConversationFile(paths2, agentId, conversationId, cwd) {
14703
14879
  if (realpathSync6(directory) !== directory) throw new Error("Conversation escaped its Agent");
14704
14880
  const filename2 = `${conversationId}.jsonl`;
14705
14881
  const destination = join16(directory, filename2);
14706
- const staging = join16(directory, `.conversation-${randomUUID29()}.tmp`);
14882
+ const staging = join16(directory, `.conversation-${randomUUID30()}.tmp`);
14707
14883
  const header2 = SessionManager.inMemory(cwd, { id: conversationId }).getHeader();
14708
14884
  const fd = openSync4(staging, constants4.O_WRONLY | constants4.O_CREAT | constants4.O_EXCL, 384);
14709
14885
  try {
@@ -14743,7 +14919,7 @@ function resolveConversationTarget(db, paths2, agentId, pinnedId) {
14743
14919
  db,
14744
14920
  agentId,
14745
14921
  {
14746
- requestId: randomUUID30(),
14922
+ requestId: randomUUID31(),
14747
14923
  expectedSelection: { conversationId: null, revision: 0 }
14748
14924
  },
14749
14925
  (newId) => createConversationFile(paths2, agentId, newId, agent.team.path)
@@ -14810,7 +14986,7 @@ async function runAgentLifecycleMutation(agentId, mutation) {
14810
14986
  }
14811
14987
 
14812
14988
  // ../daemon/src/lib/agent-loop-guard.ts
14813
- import { randomUUID as randomUUID31 } from "crypto";
14989
+ import { randomUUID as randomUUID32 } from "crypto";
14814
14990
  var DEFAULT_MAX_HOPS = 8;
14815
14991
  function toEvent(row2) {
14816
14992
  return {
@@ -14862,8 +15038,8 @@ function enforceMessageCausality(db, input) {
14862
15038
  const target = agents_exports.get(db, input.to);
14863
15039
  if (!source || !target) return null;
14864
15040
  const event2 = {
14865
- id: randomUUID31(),
14866
- causalChainId: input.causality.causalChainId ?? input.causality.parentMessageId ?? randomUUID31(),
15041
+ id: randomUUID32(),
15042
+ causalChainId: input.causality.causalChainId ?? input.causality.parentMessageId ?? randomUUID32(),
14867
15043
  parentMessageId: input.causality.parentMessageId,
14868
15044
  fromAgentId: input.from,
14869
15045
  toAgentId: input.to,
@@ -15195,8 +15371,8 @@ function ensureSafeParentDirectories(root, path) {
15195
15371
  assertContained(root, parent);
15196
15372
  const rel = relative3(root, parent);
15197
15373
  let current = root;
15198
- for (const component of rel.split(sep3).filter(Boolean)) {
15199
- current = join18(current, component);
15374
+ for (const component2 of rel.split(sep3).filter(Boolean)) {
15375
+ current = join18(current, component2);
15200
15376
  let info = lstatIfPresent(current);
15201
15377
  if (!info) {
15202
15378
  mkdirSync5(current);
@@ -16417,7 +16593,7 @@ import { InMemoryCredentialStore } from "@earendil-works/pi-ai";
16417
16593
  import { ModelRuntime } from "@earendil-works/pi-coding-agent";
16418
16594
  var PROVIDER_ALIASES = {
16419
16595
  bedrock: "amazon-bedrock",
16420
- "azure-openai": "azure-openai-responses"
16596
+ "azure-openai": "azure"
16421
16597
  };
16422
16598
  var PROTECTED_PROVIDER_NAMES = [
16423
16599
  "anthropic",
@@ -18956,7 +19132,7 @@ import {
18956
19132
  constants as constants8,
18957
19133
  fstatSync as fstatSync5,
18958
19134
  openSync as openSync7,
18959
- readSync as readSync3,
19135
+ readSync as readSync2,
18960
19136
  realpathSync as realpathSync11,
18961
19137
  statSync as statSync7
18962
19138
  } from "fs";
@@ -19059,7 +19235,7 @@ function deliverFileTool(cwd, sink, sessionId = "") {
19059
19235
  const buffer = Buffer.alloc(MAX_DELIVER_BYTES + 1);
19060
19236
  let length = 0;
19061
19237
  while (length < buffer.length) {
19062
- const count3 = readSync3(fd, buffer, length, buffer.length - length, null);
19238
+ const count3 = readSync2(fd, buffer, length, buffer.length - length, null);
19063
19239
  if (count3 === 0) break;
19064
19240
  length += count3;
19065
19241
  }
@@ -20510,10 +20686,6 @@ function explicitConversationFile(directory, target) {
20510
20686
  // ../daemon/src/runtime/providers/catalog.ts
20511
20687
  import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
20512
20688
  import { fetch as undiciFetch3 } from "undici";
20513
- var REGISTRY_TO_PI = {
20514
- bedrock: "amazon-bedrock",
20515
- "azure-openai": "azure-openai-responses"
20516
- };
20517
20689
  function liveEndpointFor(providerName, env) {
20518
20690
  switch (providerName) {
20519
20691
  case "lmstudio":
@@ -20541,7 +20713,7 @@ function liveEndpointFor(providerName, env) {
20541
20713
  case "nvidia":
20542
20714
  return "https://integrate.api.nvidia.com/v1";
20543
20715
  case "opencode-go":
20544
- return "https://opencode.ai/zen/go/v1";
20716
+ return "https://opencode.ai/inference/go/v1";
20545
20717
  case "xiaomi-token-plan-ams":
20546
20718
  return "https://token-plan-ams.xiaomimimo.com/v1";
20547
20719
  case "xiaomi-token-plan-cn":
@@ -20555,7 +20727,7 @@ function liveEndpointFor(providerName, env) {
20555
20727
  }
20556
20728
  }
20557
20729
  function piModels(providerName) {
20558
- const piName = REGISTRY_TO_PI[providerName] ?? providerName;
20730
+ const piName = piProviderName(providerName);
20559
20731
  try {
20560
20732
  const models = getBuiltinModels(piName);
20561
20733
  if (!models) return [];
@@ -21781,10 +21953,10 @@ async function* spawnWorker(spec, opts) {
21781
21953
  if (!child.stdout) throw new Error("worker spawn: stdout pipe missing");
21782
21954
  if (resourceLifecycle) {
21783
21955
  if (!child.pid) throw new Error("Worker PID unavailable");
21784
- resourceLifecycle.beforeInput(
21785
- child.pid,
21786
- spec.kind === "configured_operator_http" && env.BAZILION_BASH_SANDBOX !== "docker"
21787
- );
21956
+ const hostCommands = spec.kind === "configured_operator_http" && env.BAZILION_BASH_SANDBOX !== "docker";
21957
+ if (process.platform === "darwin")
21958
+ resourceLifecycle.beforeInput(child.pid, hostCommands, child);
21959
+ else resourceLifecycle.beforeInput(child.pid, hostCommands);
21788
21960
  }
21789
21961
  child.stdin?.write(serializedInput);
21790
21962
  child.stdin?.end();
@@ -22594,7 +22766,7 @@ function createBrowserHost(config, admission, dispatch = (agentId, action, args)
22594
22766
  }
22595
22767
 
22596
22768
  // ../daemon/src/lib/coding-environment/agent-host.ts
22597
- import { createHash as createHash15, randomUUID as randomUUID39 } from "crypto";
22769
+ import { createHash as createHash15, randomUUID as randomUUID40 } from "crypto";
22598
22770
 
22599
22771
  // ../daemon/src/core/repos/coding-command-logs.ts
22600
22772
  var CODING_LOG_BYTES = 2 * 1024 * 1024;
@@ -22814,7 +22986,7 @@ function pruneCodingCommandLogs(db, now = Date.now(), budgetBytes = CODING_LOG_H
22814
22986
  }
22815
22987
 
22816
22988
  // ../daemon/src/lib/communication.ts
22817
- import { randomUUID as randomUUID38 } from "crypto";
22989
+ import { randomUUID as randomUUID39 } from "crypto";
22818
22990
 
22819
22991
  // ../daemon/src/lib/question-approval.ts
22820
22992
  function questionApprovalReference(snapshot, kind) {
@@ -22909,7 +23081,7 @@ function questionVisible(db, item) {
22909
23081
  }
22910
23082
 
22911
23083
  // ../daemon/src/core/repos/results.ts
22912
- import { createHash as createHash14, randomUUID as randomUUID37 } from "crypto";
23084
+ import { createHash as createHash14, randomUUID as randomUUID38 } from "crypto";
22913
23085
 
22914
23086
  // ../daemon/src/core/tool-call-id.ts
22915
23087
  function isToolCallId(value) {
@@ -22985,7 +23157,7 @@ function publish(db, input) {
22985
23157
  "Result storage is full (1 GiB). Delete saved results before delivering more files."
22986
23158
  );
22987
23159
  }
22988
- const id2 = randomUUID37();
23160
+ const id2 = randomUUID38();
22989
23161
  db.raw.run(
22990
23162
  `INSERT INTO agent_results
22991
23163
  (id, team_id, agent_id, source_kind, session_id, tool_call_id, review_packet_id, review_revision,
@@ -23307,7 +23479,7 @@ function isUserFacingFrame(frame) {
23307
23479
  }
23308
23480
  function sendAgentMessage(db, input) {
23309
23481
  const attemptKind = input.attemptKind ?? "agent_tool";
23310
- const attemptId = input.attemptId ?? randomUUID38();
23482
+ const attemptId = input.attemptId ?? randomUUID39();
23311
23483
  const outcome = db.raw.transaction(
23312
23484
  () => {
23313
23485
  const causality = resolveMessageCausality(db, input);
@@ -23716,6 +23888,8 @@ function findRepositoryRoot(ancestry) {
23716
23888
  return [...ancestry].reverse().find((dir) => dir.entry(".git") !== null) ?? null;
23717
23889
  }
23718
23890
  async function captureRepositoryGit(root, budgetMs = INSPECTION_BUDGET_MS) {
23891
+ const worktree = root.gitWorktreePath;
23892
+ if (!worktree) throw new ContextReadError("git_inspection_unavailable");
23719
23893
  const start = Date.now();
23720
23894
  let bytes = 0;
23721
23895
  let count3 = 0;
@@ -23766,7 +23940,7 @@ async function captureRepositoryGit(root, budgetMs = INSPECTION_BUDGET_MS) {
23766
23940
  const inspectionArgs = (args) => [
23767
23941
  "--no-optional-locks",
23768
23942
  `--git-dir=${scratch}`,
23769
- `--work-tree=/proc/${process.pid}/fd/${root.fd}`,
23943
+ `--work-tree=${worktree}`,
23770
23944
  "-c",
23771
23945
  "core.fsmonitor=false",
23772
23946
  "-c",
@@ -25077,7 +25251,7 @@ function createCodingHost(input) {
25077
25251
  try {
25078
25252
  const environment2 = await snapshot(command.cwd);
25079
25253
  const receipt = {
25080
- id: randomUUID39(),
25254
+ id: randomUUID40(),
25081
25255
  agentId: input.agentId,
25082
25256
  teamId: input.teamId,
25083
25257
  turnId: input.turnId,
@@ -26161,7 +26335,7 @@ function createDbMessagingHost(db, opts = {}) {
26161
26335
  }
26162
26336
 
26163
26337
  // ../daemon/src/lib/question-service.ts
26164
- import { randomUUID as randomUUID41 } from "crypto";
26338
+ import { randomUUID as randomUUID42 } from "crypto";
26165
26339
 
26166
26340
  // ../daemon/src/lib/question-consumption.ts
26167
26341
  import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
@@ -26689,7 +26863,7 @@ function parseTelegramQuestionReply(db, authToken, update3) {
26689
26863
  }
26690
26864
 
26691
26865
  // ../daemon/src/lib/attachments.ts
26692
- import { randomUUID as randomUUID40 } from "crypto";
26866
+ import { randomUUID as randomUUID41 } from "crypto";
26693
26867
  import { closeSync as closeSync12, constants as constants12, fstatSync as fstatSync10, openSync as openSync12, writeFileSync as writeFileSync14 } from "fs";
26694
26868
  import { join as join31, posix } from "path";
26695
26869
  var MAX_FILE_BYTES = 25 * 1024 * 1024;
@@ -26716,7 +26890,7 @@ function saveInputFiles(agentDir, files, options = {}) {
26716
26890
  lines.push(`[attachment "${label}" skipped: too large (${fmtBytes(buf.byteLength)} > 25 MB)]`);
26717
26891
  continue;
26718
26892
  }
26719
- const filename2 = `${randomUUID40().slice(0, 8)}-${safeName(label)}`;
26893
+ const filename2 = `${randomUUID41().slice(0, 8)}-${safeName(label)}`;
26720
26894
  const path = join31(dir, filename2);
26721
26895
  let fd;
26722
26896
  try {
@@ -27589,7 +27763,7 @@ var QuestionService = class {
27589
27763
  turn.conversation.id
27590
27764
  ).length;
27591
27765
  this.#attached.add(turn);
27592
- const turnId = randomUUID41();
27766
+ const turnId = randomUUID42();
27593
27767
  const listeners = /* @__PURE__ */ new Set();
27594
27768
  if (onQuestion) listeners.add(onQuestion);
27595
27769
  this.#turns.set(turnId, {
@@ -29684,7 +29858,7 @@ function bound(value) {
29684
29858
  }
29685
29859
 
29686
29860
  // ../daemon/src/lib/review/dispatch.ts
29687
- import { randomUUID as randomUUID42 } from "crypto";
29861
+ import { randomUUID as randomUUID43 } from "crypto";
29688
29862
 
29689
29863
  // ../daemon/src/lib/review/preparation.ts
29690
29864
  async function prepareChangeReviewTurn(input) {
@@ -30047,7 +30221,7 @@ function refused(message) {
30047
30221
  }
30048
30222
 
30049
30223
  // ../daemon/src/lib/review/dispatch.ts
30050
- var REVIEW_DISPATCH_OWNER = randomUUID42();
30224
+ var REVIEW_DISPATCH_OWNER = randomUUID43();
30051
30225
  var REVIEW_LEASE_MS = 10 * 60 * 1e3;
30052
30226
  var dispatchRegistry = () => {
30053
30227
  const global = globalThis;
@@ -30488,9 +30662,9 @@ async function dispatchClaimableReviews(now = Date.now()) {
30488
30662
  }
30489
30663
 
30490
30664
  // ../daemon/src/lib/verification/admission.ts
30491
- import { randomUUID as randomUUID43 } from "crypto";
30665
+ import { randomUUID as randomUUID44 } from "crypto";
30492
30666
  var VERIFICATION_LEASE_MS = 10 * 60 * 1e3;
30493
- var VERIFICATION_DISPATCH_OWNER = randomUUID43();
30667
+ var VERIFICATION_DISPATCH_OWNER = randomUUID44();
30494
30668
  async function admitVerificationRequest(db, paths2, requestId2, now = Date.now()) {
30495
30669
  const request2 = getVerificationRequestById(db, requestId2, now);
30496
30670
  if (!request2) return { kind: "deferred", requestId: requestId2, reason: "unknown_or_expired" };
@@ -30628,7 +30802,7 @@ function safeTeam3(db, paths2, teamId) {
30628
30802
  }
30629
30803
 
30630
30804
  // ../daemon/src/lib/verification/executor.ts
30631
- import { randomUUID as randomUUID44 } from "crypto";
30805
+ import { randomUUID as randomUUID45 } from "crypto";
30632
30806
  import { existsSync as existsSync18 } from "fs";
30633
30807
  import { join as join33, posix as posix2, relative as relative8, sep as sep7 } from "path";
30634
30808
  import { createLocalBashOperations as createLocalBashOperations3 } from "@earendil-works/pi-coding-agent";
@@ -30659,14 +30833,14 @@ function createProtectedCheckExecutor(input) {
30659
30833
  }
30660
30834
  const container = buildContainerOperations(input, env, config.envAllowlist, absoluteCwd);
30661
30835
  if ("blocked" in container) return blocked3("environment_unavailable", container.blocked);
30662
- const commandId = randomUUID44();
30836
+ const commandId = randomUUID45();
30663
30837
  const startedAt = Date.now();
30664
30838
  const receipt = {
30665
30839
  id: commandId,
30666
30840
  agentId: input.request.recipientAgentId,
30667
30841
  teamId: input.request.teamId,
30668
30842
  turnId: input.attemptId,
30669
- toolCallId: `verification:${input.attemptId}:${randomUUID44()}`,
30843
+ toolCallId: `verification:${input.attemptId}:${randomUUID45()}`,
30670
30844
  input: {
30671
30845
  command,
30672
30846
  cwd: relative9,
@@ -32109,7 +32283,7 @@ async function authMiddleware(c, next) {
32109
32283
 
32110
32284
  // ../daemon/src/routes/agents.ts
32111
32285
  init_src();
32112
- import { randomUUID as randomUUID46 } from "crypto";
32286
+ import { randomUUID as randomUUID47 } from "crypto";
32113
32287
  import { existsSync as existsSync20, readFileSync as readFileSync17 } from "fs";
32114
32288
  import { join as join36 } from "path";
32115
32289
  import { Hono } from "hono";
@@ -33437,7 +33611,7 @@ async function notifyTelegramQueueStatus(db, agentId, itemId) {
33437
33611
  }
33438
33612
 
33439
33613
  // ../daemon/src/lib/user-queue-admission.ts
33440
- import { randomUUID as randomUUID45 } from "crypto";
33614
+ import { randomUUID as randomUUID46 } from "crypto";
33441
33615
  async function enqueueTelegramInput(binding, message, attachments2, context = getCtx()) {
33442
33616
  validateInput(message, attachments2);
33443
33617
  const { db, paths: paths2, authToken } = context;
@@ -33456,7 +33630,7 @@ async function enqueueTelegramInput(binding, message, attachments2, context = ge
33456
33630
  const existing = findAttempt(db, "telegram", binding.authorization.attemptId);
33457
33631
  return db.raw.transaction(() => {
33458
33632
  const item = accept(db, {
33459
- id: existing?.id ?? randomUUID45(),
33633
+ id: existing?.id ?? randomUUID46(),
33460
33634
  agentId,
33461
33635
  teamId: existing?.teamId ?? agent.team.id,
33462
33636
  conversationId,
@@ -35421,7 +35595,7 @@ agentsRouter.post("/:id/chat", async (c) => {
35421
35595
  if (!message && attachments2.length === 0) {
35422
35596
  return c.json({ error: "message or an attachment is required" }, 400);
35423
35597
  }
35424
- const requestAttemptId = c.req.header("x-request-id") ?? randomUUID46();
35598
+ const requestAttemptId = c.req.header("x-request-id") ?? randomUUID47();
35425
35599
  let preparedTurn;
35426
35600
  try {
35427
35601
  preparedTurn = await prepareAgentTurn({
@@ -37998,6 +38172,43 @@ var DOCKER_REMEDIATIONS = {
37998
38172
  "Docker preflight failed": "Check the local Docker daemon and protected image, then retry."
37999
38173
  };
38000
38174
 
38175
+ // ../daemon/src/lib/platform-capabilities.ts
38176
+ function projectPlatformCapabilities(platform = process.platform) {
38177
+ const linux = platform === "linux";
38178
+ const portable = linux || platform === "darwin";
38179
+ const unsupported = "Bazilion Agent turns are unsupported on this operating system.";
38180
+ return {
38181
+ platform: linux ? "Linux" : platform === "darwin" ? "macOS" : "Unsupported platform",
38182
+ note: "Platform support only, not an execution or connectivity test. Every turn still validates its provider, configuration, repository context and resource ownership.",
38183
+ capabilities: [
38184
+ {
38185
+ id: "ordinary_chat",
38186
+ label: "Ordinary interactive chat",
38187
+ support: portable ? "supported" : "unsupported",
38188
+ detail: portable ? "Select and test a provider, then try an Agent chat. No chat was run by this report." : unsupported
38189
+ },
38190
+ {
38191
+ id: "git_inspection",
38192
+ label: "Hardened Git inspection",
38193
+ support: linux ? "supported" : "unsupported",
38194
+ detail: linux ? "Repository layout and source checks still apply at capture time." : "Requires Linux descriptor-pinned Git inspection; ordinary chat does not grant this capability."
38195
+ },
38196
+ {
38197
+ id: "mcp_stdio",
38198
+ label: "MCP stdio",
38199
+ support: linux ? "supported" : "unsupported",
38200
+ detail: linux ? "Enable and test a configured server separately; process ownership checks still apply." : portable ? "Requires Linux process-tree retirement. Use Streamable HTTP instead." : unsupported
38201
+ },
38202
+ {
38203
+ id: "mcp_http",
38204
+ label: "MCP Streamable HTTP",
38205
+ support: portable ? "supported" : "unsupported",
38206
+ detail: portable ? "Portable transport. Enable and test a configured server separately; protected turns still deny MCP." : unsupported
38207
+ }
38208
+ ]
38209
+ };
38210
+ }
38211
+
38001
38212
  // ../daemon/src/lib/protected-docker-readiness-cache.ts
38002
38213
  function createProtectedDockerReadinessCache(ttlMs = 6e4, now = Date.now) {
38003
38214
  if (!Number.isSafeInteger(ttlMs) || ttlMs < 1) {
@@ -38193,6 +38404,7 @@ miscRouter.get("/health/details", async (c) => {
38193
38404
  // Structural install health only. Protected work has an explicit, independent signal below.
38194
38405
  ok: pathChecks.home && pathChecks.db && pathChecks.auth && pathChecks.profiles && pathChecks.agents && pathChecks.skills && (database === null || database.ok) && parseErrors === 0 && shellSecurity.ok,
38195
38406
  protectedWorkBaselineReady: executionSecurity.protectedUnattendedTurns.baseRuntimeReady,
38407
+ platformCapabilities: projectPlatformCapabilities(),
38196
38408
  home: paths2.home,
38197
38409
  paths: pathChecks,
38198
38410
  database,
@@ -38352,7 +38564,7 @@ import { bodyLimit } from "hono/body-limit";
38352
38564
  import { HTTPException } from "hono/http-exception";
38353
38565
 
38354
38566
  // ../daemon/src/lib/notification-control.ts
38355
- import { randomUUID as randomUUID47 } from "crypto";
38567
+ import { randomUUID as randomUUID48 } from "crypto";
38356
38568
 
38357
38569
  // ../daemon/src/lib/notification-authorization.ts
38358
38570
  function authorizeAttentionNotification(db, item, captured) {
@@ -38517,7 +38729,7 @@ var NotificationControl = class {
38517
38729
  );
38518
38730
  for (const item of items) byKind[item.kind]++;
38519
38731
  const value = {
38520
- id: randomUUID47(),
38732
+ id: randomUUID48(),
38521
38733
  settingsRevision: revision4,
38522
38734
  destinationId: binding.id,
38523
38735
  kinds,
@@ -39594,7 +39806,7 @@ async function parseImportInput(request2) {
39594
39806
 
39595
39807
  // ../daemon/src/routes/team-templates.ts
39596
39808
  init_src();
39597
- import { randomUUID as randomUUID48 } from "crypto";
39809
+ import { randomUUID as randomUUID49 } from "crypto";
39598
39810
  import { Hono as Hono17 } from "hono";
39599
39811
  var teamTemplatesRouter = new Hono17();
39600
39812
  teamTemplatesRouter.get("/", (c) => {
@@ -39634,7 +39846,7 @@ teamTemplatesRouter.post("/import", async (c) => {
39634
39846
  if (!profiles_exports.get(db, parsed.profileId)) {
39635
39847
  throw new Error(`profile not found: ${parsed.profileId}`);
39636
39848
  }
39637
- const slotId = randomUUID48();
39849
+ const slotId = randomUUID49();
39638
39850
  keyToSlot.set(clientKey, slotId);
39639
39851
  return { ...parsed, slotId };
39640
39852
  });