local-commander-agent-linux-x64 0.3.50 → 0.3.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/runtime/agent.mjs CHANGED
@@ -52,9 +52,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
52
52
  mod
53
53
  ));
54
54
 
55
- // node_modules/ws/lib/constants.js
55
+ // ../../node_modules/ws/lib/constants.js
56
56
  var require_constants = __commonJS({
57
- "node_modules/ws/lib/constants.js"(exports, module) {
57
+ "../../node_modules/ws/lib/constants.js"(exports, module) {
58
58
  "use strict";
59
59
  var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
60
60
  var hasBlob = typeof Blob !== "undefined";
@@ -75,9 +75,9 @@ var require_constants = __commonJS({
75
75
  }
76
76
  });
77
77
 
78
- // node_modules/ws/lib/buffer-util.js
78
+ // ../../node_modules/ws/lib/buffer-util.js
79
79
  var require_buffer_util = __commonJS({
80
- "node_modules/ws/lib/buffer-util.js"(exports, module) {
80
+ "../../node_modules/ws/lib/buffer-util.js"(exports, module) {
81
81
  "use strict";
82
82
  var { EMPTY_BUFFER } = require_constants();
83
83
  var FastBuffer = Buffer[Symbol.species];
@@ -150,9 +150,9 @@ var require_buffer_util = __commonJS({
150
150
  }
151
151
  });
152
152
 
153
- // node_modules/ws/lib/limiter.js
153
+ // ../../node_modules/ws/lib/limiter.js
154
154
  var require_limiter = __commonJS({
155
- "node_modules/ws/lib/limiter.js"(exports, module) {
155
+ "../../node_modules/ws/lib/limiter.js"(exports, module) {
156
156
  "use strict";
157
157
  var kDone = /* @__PURE__ */ Symbol("kDone");
158
158
  var kRun = /* @__PURE__ */ Symbol("kRun");
@@ -200,9 +200,9 @@ var require_limiter = __commonJS({
200
200
  }
201
201
  });
202
202
 
203
- // node_modules/ws/lib/permessage-deflate.js
203
+ // ../../node_modules/ws/lib/permessage-deflate.js
204
204
  var require_permessage_deflate = __commonJS({
205
- "node_modules/ws/lib/permessage-deflate.js"(exports, module) {
205
+ "../../node_modules/ws/lib/permessage-deflate.js"(exports, module) {
206
206
  "use strict";
207
207
  var zlib = __require("zlib");
208
208
  var bufferUtil = require_buffer_util();
@@ -583,9 +583,9 @@ var require_permessage_deflate = __commonJS({
583
583
  }
584
584
  });
585
585
 
586
- // node_modules/ws/lib/validation.js
586
+ // ../../node_modules/ws/lib/validation.js
587
587
  var require_validation = __commonJS({
588
- "node_modules/ws/lib/validation.js"(exports, module) {
588
+ "../../node_modules/ws/lib/validation.js"(exports, module) {
589
589
  "use strict";
590
590
  var { isUtf8 } = __require("buffer");
591
591
  var { hasBlob } = require_constants();
@@ -784,9 +784,9 @@ var require_validation = __commonJS({
784
784
  }
785
785
  });
786
786
 
787
- // node_modules/ws/lib/receiver.js
787
+ // ../../node_modules/ws/lib/receiver.js
788
788
  var require_receiver = __commonJS({
789
- "node_modules/ws/lib/receiver.js"(exports, module) {
789
+ "../../node_modules/ws/lib/receiver.js"(exports, module) {
790
790
  "use strict";
791
791
  var { Writable } = __require("stream");
792
792
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -1407,9 +1407,9 @@ var require_receiver = __commonJS({
1407
1407
  }
1408
1408
  });
1409
1409
 
1410
- // node_modules/ws/lib/sender.js
1410
+ // ../../node_modules/ws/lib/sender.js
1411
1411
  var require_sender = __commonJS({
1412
- "node_modules/ws/lib/sender.js"(exports, module) {
1412
+ "../../node_modules/ws/lib/sender.js"(exports, module) {
1413
1413
  "use strict";
1414
1414
  var { Duplex } = __require("stream");
1415
1415
  var { randomFillSync } = __require("crypto");
@@ -1900,9 +1900,9 @@ var require_sender = __commonJS({
1900
1900
  }
1901
1901
  });
1902
1902
 
1903
- // node_modules/ws/lib/event-target.js
1903
+ // ../../node_modules/ws/lib/event-target.js
1904
1904
  var require_event_target = __commonJS({
1905
- "node_modules/ws/lib/event-target.js"(exports, module) {
1905
+ "../../node_modules/ws/lib/event-target.js"(exports, module) {
1906
1906
  "use strict";
1907
1907
  var { kForOnEventAttribute, kListener } = require_constants();
1908
1908
  var kCode = /* @__PURE__ */ Symbol("kCode");
@@ -2129,9 +2129,9 @@ var require_event_target = __commonJS({
2129
2129
  }
2130
2130
  });
2131
2131
 
2132
- // node_modules/ws/lib/extension.js
2132
+ // ../../node_modules/ws/lib/extension.js
2133
2133
  var require_extension = __commonJS({
2134
- "node_modules/ws/lib/extension.js"(exports, module) {
2134
+ "../../node_modules/ws/lib/extension.js"(exports, module) {
2135
2135
  "use strict";
2136
2136
  var { tokenChars } = require_validation();
2137
2137
  function push(dest, name2, elem) {
@@ -2282,9 +2282,9 @@ var require_extension = __commonJS({
2282
2282
  }
2283
2283
  });
2284
2284
 
2285
- // node_modules/ws/lib/websocket.js
2285
+ // ../../node_modules/ws/lib/websocket.js
2286
2286
  var require_websocket = __commonJS({
2287
- "node_modules/ws/lib/websocket.js"(exports, module) {
2287
+ "../../node_modules/ws/lib/websocket.js"(exports, module) {
2288
2288
  "use strict";
2289
2289
  var EventEmitter = __require("events");
2290
2290
  var https2 = __require("https");
@@ -3191,9 +3191,9 @@ var require_websocket = __commonJS({
3191
3191
  }
3192
3192
  });
3193
3193
 
3194
- // node_modules/ws/lib/stream.js
3194
+ // ../../node_modules/ws/lib/stream.js
3195
3195
  var require_stream = __commonJS({
3196
- "node_modules/ws/lib/stream.js"(exports, module) {
3196
+ "../../node_modules/ws/lib/stream.js"(exports, module) {
3197
3197
  "use strict";
3198
3198
  var WebSocket2 = require_websocket();
3199
3199
  var { Duplex } = __require("stream");
@@ -3253,7 +3253,7 @@ var require_stream = __commonJS({
3253
3253
  };
3254
3254
  duplex._final = function(callback) {
3255
3255
  if (ws.readyState === ws.CONNECTING) {
3256
- ws.once("open", function open14() {
3256
+ ws.once("open", function open15() {
3257
3257
  duplex._final(callback);
3258
3258
  });
3259
3259
  return;
@@ -3274,7 +3274,7 @@ var require_stream = __commonJS({
3274
3274
  };
3275
3275
  duplex._write = function(chunk, encoding, callback) {
3276
3276
  if (ws.readyState === ws.CONNECTING) {
3277
- ws.once("open", function open14() {
3277
+ ws.once("open", function open15() {
3278
3278
  duplex._write(chunk, encoding, callback);
3279
3279
  });
3280
3280
  return;
@@ -3289,9 +3289,9 @@ var require_stream = __commonJS({
3289
3289
  }
3290
3290
  });
3291
3291
 
3292
- // node_modules/ws/lib/subprotocol.js
3292
+ // ../../node_modules/ws/lib/subprotocol.js
3293
3293
  var require_subprotocol = __commonJS({
3294
- "node_modules/ws/lib/subprotocol.js"(exports, module) {
3294
+ "../../node_modules/ws/lib/subprotocol.js"(exports, module) {
3295
3295
  "use strict";
3296
3296
  var { tokenChars } = require_validation();
3297
3297
  function parse4(header) {
@@ -3334,9 +3334,9 @@ var require_subprotocol = __commonJS({
3334
3334
  }
3335
3335
  });
3336
3336
 
3337
- // node_modules/ws/lib/websocket-server.js
3337
+ // ../../node_modules/ws/lib/websocket-server.js
3338
3338
  var require_websocket_server = __commonJS({
3339
- "node_modules/ws/lib/websocket-server.js"(exports, module) {
3339
+ "../../node_modules/ws/lib/websocket-server.js"(exports, module) {
3340
3340
  "use strict";
3341
3341
  var EventEmitter = __require("events");
3342
3342
  var http2 = __require("http");
@@ -3738,7 +3738,7 @@ var require_websocket_server = __commonJS({
3738
3738
  // agent/src/ai-connectivity/manager.ts
3739
3739
  import { performance } from "node:perf_hooks";
3740
3740
 
3741
- // node_modules/zod/v4/classic/external.js
3741
+ // ../../node_modules/zod/v4/classic/external.js
3742
3742
  var external_exports = {};
3743
3743
  __export(external_exports, {
3744
3744
  $brand: () => $brand,
@@ -4001,7 +4001,7 @@ __export(external_exports, {
4001
4001
  xor: () => xor
4002
4002
  });
4003
4003
 
4004
- // node_modules/zod/v4/core/index.js
4004
+ // ../../node_modules/zod/v4/core/index.js
4005
4005
  var core_exports2 = {};
4006
4006
  __export(core_exports2, {
4007
4007
  $ZodAny: () => $ZodAny,
@@ -4318,7 +4318,7 @@ __export(core_exports2, {
4318
4318
  withParser: () => withParser
4319
4319
  });
4320
4320
 
4321
- // node_modules/zod/v4/core/util.js
4321
+ // ../../node_modules/zod/v4/core/util.js
4322
4322
  var util_exports = {};
4323
4323
  __export(util_exports, {
4324
4324
  BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
@@ -4554,10 +4554,10 @@ function mergeDefs(...defs) {
4554
4554
  function cloneDef(schema) {
4555
4555
  return mergeDefs(schema._zod.def);
4556
4556
  }
4557
- function getElementAtPath(obj, path30) {
4558
- if (!path30)
4557
+ function getElementAtPath(obj, path32) {
4558
+ if (!path32)
4559
4559
  return obj;
4560
- return path30.reduce((acc, key) => acc?.[key], obj);
4560
+ return path32.reduce((acc, key) => acc?.[key], obj);
4561
4561
  }
4562
4562
  function promiseAllObject(promisesObj) {
4563
4563
  const keys = Object.keys(promisesObj);
@@ -4897,11 +4897,11 @@ function explicitlyAborted(x, startIndex = 0) {
4897
4897
  }
4898
4898
  return false;
4899
4899
  }
4900
- function prefixIssues(path30, issues) {
4900
+ function prefixIssues(path32, issues) {
4901
4901
  return issues.map((iss) => {
4902
4902
  var _a3;
4903
4903
  (_a3 = iss).path ?? (_a3.path = []);
4904
- iss.path.unshift(path30);
4904
+ iss.path.unshift(path32);
4905
4905
  return iss;
4906
4906
  });
4907
4907
  }
@@ -4952,14 +4952,14 @@ function codePointLength(str) {
4952
4952
  const units2 = str.length;
4953
4953
  if (!highSurrogate.test(str))
4954
4954
  return units2;
4955
- let count3 = units2;
4955
+ let count4 = units2;
4956
4956
  for (let i = 0; i < units2 - 1; i++) {
4957
4957
  if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
4958
- count3--;
4958
+ count4--;
4959
4959
  i++;
4960
4960
  }
4961
4961
  }
4962
- return count3;
4962
+ return count4;
4963
4963
  }
4964
4964
  function getLengthableOrigin(input2) {
4965
4965
  if (Array.isArray(input2))
@@ -5161,7 +5161,7 @@ function constantCatch(value) {
5161
5161
  return fn;
5162
5162
  }
5163
5163
 
5164
- // node_modules/zod/v4/core/core.js
5164
+ // ../../node_modules/zod/v4/core/core.js
5165
5165
  var _a;
5166
5166
  var NEVER = /* @__PURE__ */ Object.freeze({
5167
5167
  status: "aborted"
@@ -5171,8 +5171,8 @@ var _E = "captureStackTrace" in Error ? Error : null;
5171
5171
  function newError(Definition) {
5172
5172
  const E = _E;
5173
5173
  if (E) {
5174
- const saved = E.stackTraceLimit;
5175
- if (typeof saved === "number") {
5174
+ const saved2 = E.stackTraceLimit;
5175
+ if (typeof saved2 === "number") {
5176
5176
  try {
5177
5177
  E.stackTraceLimit = 0;
5178
5178
  } catch {
@@ -5182,7 +5182,7 @@ function newError(Definition) {
5182
5182
  try {
5183
5183
  return new Definition();
5184
5184
  } finally {
5185
- E.stackTraceLimit = saved;
5185
+ E.stackTraceLimit = saved2;
5186
5186
  }
5187
5187
  }
5188
5188
  }
@@ -5283,7 +5283,7 @@ function config(newConfig) {
5283
5283
  return globalConfig;
5284
5284
  }
5285
5285
 
5286
- // node_modules/zod/v4/core/errors.js
5286
+ // ../../node_modules/zod/v4/core/errors.js
5287
5287
  function _getMessage() {
5288
5288
  const internals = this._zod;
5289
5289
  internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
@@ -5351,16 +5351,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
5351
5351
  }
5352
5352
  function formatError(error62, mapper = (issue2) => issue2.message) {
5353
5353
  const fieldErrors = { _errors: [] };
5354
- const processError = (error63, path30 = []) => {
5354
+ const processError = (error63, path32 = []) => {
5355
5355
  for (const issue2 of error63.issues) {
5356
5356
  if (issue2.code === "invalid_union" && issue2.errors.length) {
5357
- issue2.errors.map((issues) => processError({ issues }, [...path30, ...issue2.path]));
5357
+ issue2.errors.map((issues) => processError({ issues }, [...path32, ...issue2.path]));
5358
5358
  } else if (issue2.code === "invalid_key") {
5359
- processError({ issues: issue2.issues }, [...path30, ...issue2.path]);
5359
+ processError({ issues: issue2.issues }, [...path32, ...issue2.path]);
5360
5360
  } else if (issue2.code === "invalid_element") {
5361
- processError({ issues: issue2.issues }, [...path30, ...issue2.path]);
5361
+ processError({ issues: issue2.issues }, [...path32, ...issue2.path]);
5362
5362
  } else {
5363
- const fullpath = [...path30, ...issue2.path];
5363
+ const fullpath = [...path32, ...issue2.path];
5364
5364
  if (fullpath.length === 0) {
5365
5365
  fieldErrors._errors.push(mapper(issue2));
5366
5366
  } else {
@@ -5399,17 +5399,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
5399
5399
  }
5400
5400
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
5401
5401
  const result2 = { errors: [] };
5402
- const processError = (error63, path30 = []) => {
5402
+ const processError = (error63, path32 = []) => {
5403
5403
  var _a3;
5404
5404
  for (const issue2 of error63.issues) {
5405
5405
  if (issue2.code === "invalid_union" && issue2.errors.length) {
5406
- issue2.errors.map((issues) => processError({ issues }, [...path30, ...issue2.path]));
5406
+ issue2.errors.map((issues) => processError({ issues }, [...path32, ...issue2.path]));
5407
5407
  } else if (issue2.code === "invalid_key") {
5408
- processError({ issues: issue2.issues }, [...path30, ...issue2.path]);
5408
+ processError({ issues: issue2.issues }, [...path32, ...issue2.path]);
5409
5409
  } else if (issue2.code === "invalid_element") {
5410
- processError({ issues: issue2.issues }, [...path30, ...issue2.path]);
5410
+ processError({ issues: issue2.issues }, [...path32, ...issue2.path]);
5411
5411
  } else {
5412
- const fullpath = [...path30, ...issue2.path];
5412
+ const fullpath = [...path32, ...issue2.path];
5413
5413
  if (fullpath.length === 0) {
5414
5414
  result2.errors.push(mapper(issue2));
5415
5415
  continue;
@@ -5448,8 +5448,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
5448
5448
  }
5449
5449
  function toDotPath(_path) {
5450
5450
  const segs = [];
5451
- const path30 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
5452
- for (const seg of path30) {
5451
+ const path32 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
5452
+ for (const seg of path32) {
5453
5453
  if (typeof seg === "number")
5454
5454
  segs.push(`[${seg}]`);
5455
5455
  else if (typeof seg === "symbol")
@@ -5475,7 +5475,7 @@ function prettifyError(error62) {
5475
5475
  return lines.join("\n");
5476
5476
  }
5477
5477
 
5478
- // node_modules/zod/v4/core/parse.js
5478
+ // ../../node_modules/zod/v4/core/parse.js
5479
5479
  function finalizeParams(callee, params) {
5480
5480
  return { callee: params?.callee ?? callee, Err: params?.Err };
5481
5481
  }
@@ -5635,7 +5635,7 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
5635
5635
  };
5636
5636
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
5637
5637
 
5638
- // node_modules/zod/v4/core/regexes.js
5638
+ // ../../node_modules/zod/v4/core/regexes.js
5639
5639
  var regexes_exports = {};
5640
5640
  __export(regexes_exports, {
5641
5641
  anyString: () => anyString,
@@ -5807,7 +5807,7 @@ var sha512_hex = /^[0-9a-fA-F]{128}$/;
5807
5807
  var sha512_base64 = /* @__PURE__ */ fixedBase64(86, "==");
5808
5808
  var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
5809
5809
 
5810
- // node_modules/zod/v4/core/checks.js
5810
+ // ../../node_modules/zod/v4/core/checks.js
5811
5811
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
5812
5812
  var _a3;
5813
5813
  inst._zod ?? (inst._zod = {});
@@ -6283,7 +6283,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
6283
6283
  };
6284
6284
  });
6285
6285
 
6286
- // node_modules/zod/v4/core/doc.js
6286
+ // ../../node_modules/zod/v4/core/doc.js
6287
6287
  var Doc = class {
6288
6288
  constructor(args = [], closed = {}) {
6289
6289
  this.content = [];
@@ -6324,14 +6324,14 @@ ${content.join("\n")}
6324
6324
  }
6325
6325
  };
6326
6326
 
6327
- // node_modules/zod/v4/core/versions.js
6327
+ // ../../node_modules/zod/v4/core/versions.js
6328
6328
  var version = {
6329
6329
  major: 4,
6330
6330
  minor: 6,
6331
6331
  patch: 5
6332
6332
  };
6333
6333
 
6334
- // node_modules/zod/v4/core/schemas.js
6334
+ // ../../node_modules/zod/v4/core/schemas.js
6335
6335
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
6336
6336
  var _a3;
6337
6337
  inst ?? (inst = {});
@@ -8564,9 +8564,9 @@ function partPattern(schema) {
8564
8564
  return own2;
8565
8565
  }
8566
8566
  if (def.options) {
8567
- const sources = def.options.map(partPattern);
8568
- if (sources.every(Boolean))
8569
- return `^(${sources.map((s) => cleanRegex(s)).join("|")})$`;
8567
+ const sources2 = def.options.map(partPattern);
8568
+ if (sources2.every(Boolean))
8569
+ return `^(${sources2.map((s) => cleanRegex(s)).join("|")})$`;
8570
8570
  }
8571
8571
  return leafPattern(schema);
8572
8572
  }
@@ -8745,7 +8745,7 @@ function handleRefineResult(result2, payload2, input2, inst) {
8745
8745
  }
8746
8746
  }
8747
8747
 
8748
- // node_modules/zod/v4/core/memoizer.js
8748
+ // ../../node_modules/zod/v4/core/memoizer.js
8749
8749
  var $ZodCyclicError = class extends Error {
8750
8750
  constructor() {
8751
8751
  super(`Cannot parse a reference cycle that closes through a transform`);
@@ -9022,7 +9022,7 @@ function isBackEdge(ctx, value) {
9022
9022
  return backEdges !== void 0 && isRef(value) && backEdges.has(value);
9023
9023
  }
9024
9024
 
9025
- // node_modules/zod/v4/locales/index.js
9025
+ // ../../node_modules/zod/v4/locales/index.js
9026
9026
  var locales_exports = {};
9027
9027
  __export(locales_exports, {
9028
9028
  ar: () => ar_default,
@@ -9090,7 +9090,7 @@ __export(locales_exports, {
9090
9090
  zhTW: () => zh_TW_default
9091
9091
  });
9092
9092
 
9093
- // node_modules/zod/v4/locales/ar.js
9093
+ // ../../node_modules/zod/v4/locales/ar.js
9094
9094
  var error = () => {
9095
9095
  const Sizable = {
9096
9096
  string: { unit: "\u062D\u0631\u0641", verb: "\u0623\u0646 \u064A\u062D\u0648\u064A" },
@@ -9202,7 +9202,7 @@ function ar_default() {
9202
9202
  };
9203
9203
  }
9204
9204
 
9205
- // node_modules/zod/v4/locales/az.js
9205
+ // ../../node_modules/zod/v4/locales/az.js
9206
9206
  var error2 = () => {
9207
9207
  const Sizable = {
9208
9208
  string: { unit: "simvol", verb: "olmal\u0131d\u0131r" },
@@ -9313,9 +9313,9 @@ function az_default() {
9313
9313
  };
9314
9314
  }
9315
9315
 
9316
- // node_modules/zod/v4/locales/be.js
9317
- function getBelarusianPlural(count3, one, few, many) {
9318
- const absCount = Math.abs(count3);
9316
+ // ../../node_modules/zod/v4/locales/be.js
9317
+ function getBelarusianPlural(count4, one, few, many) {
9318
+ const absCount = Math.abs(count4);
9319
9319
  const lastDigit = absCount % 10;
9320
9320
  const lastTwoDigits = absCount % 100;
9321
9321
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -9482,7 +9482,7 @@ function be_default() {
9482
9482
  };
9483
9483
  }
9484
9484
 
9485
- // node_modules/zod/v4/locales/bg.js
9485
+ // ../../node_modules/zod/v4/locales/bg.js
9486
9486
  var error4 = () => {
9487
9487
  const Sizable = {
9488
9488
  string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0430", verb: "\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430" },
@@ -9608,7 +9608,7 @@ function bg_default() {
9608
9608
  };
9609
9609
  }
9610
9610
 
9611
- // node_modules/zod/v4/locales/bn.js
9611
+ // ../../node_modules/zod/v4/locales/bn.js
9612
9612
  var error5 = () => {
9613
9613
  const Sizable = {
9614
9614
  string: { unit: "\u0985\u0995\u09CD\u09B7\u09B0", verb: "\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7" },
@@ -9722,7 +9722,7 @@ function bn_default() {
9722
9722
  };
9723
9723
  }
9724
9724
 
9725
- // node_modules/zod/v4/locales/ca.js
9725
+ // ../../node_modules/zod/v4/locales/ca.js
9726
9726
  var error6 = () => {
9727
9727
  const Sizable = {
9728
9728
  string: { unit: "car\xE0cters", verb: "contenir" },
@@ -9836,7 +9836,7 @@ function ca_default() {
9836
9836
  };
9837
9837
  }
9838
9838
 
9839
- // node_modules/zod/v4/locales/ckb.js
9839
+ // ../../node_modules/zod/v4/locales/ckb.js
9840
9840
  var error7 = () => {
9841
9841
  const Sizable = {
9842
9842
  string: { unit: "\u067E\u06CC\u062A", verb: "\u0628\u06CE\u062A" },
@@ -9969,7 +9969,7 @@ function ckb_default() {
9969
9969
  };
9970
9970
  }
9971
9971
 
9972
- // node_modules/zod/v4/locales/cs.js
9972
+ // ../../node_modules/zod/v4/locales/cs.js
9973
9973
  var error8 = () => {
9974
9974
  const Sizable = {
9975
9975
  string: { unit: "znak\u016F", verb: "m\xEDt" },
@@ -10086,7 +10086,7 @@ function cs_default() {
10086
10086
  };
10087
10087
  }
10088
10088
 
10089
- // node_modules/zod/v4/locales/da.js
10089
+ // ../../node_modules/zod/v4/locales/da.js
10090
10090
  var error9 = () => {
10091
10091
  const Sizable = {
10092
10092
  string: { unit: "tegn", verb: "havde" },
@@ -10207,7 +10207,7 @@ function da_default() {
10207
10207
  };
10208
10208
  }
10209
10209
 
10210
- // node_modules/zod/v4/locales/de.js
10210
+ // ../../node_modules/zod/v4/locales/de.js
10211
10211
  var error10 = () => {
10212
10212
  const Sizable = {
10213
10213
  string: { unit: "Zeichen", verb: "zu haben" },
@@ -10321,7 +10321,7 @@ function de_default() {
10321
10321
  };
10322
10322
  }
10323
10323
 
10324
- // node_modules/zod/v4/locales/el.js
10324
+ // ../../node_modules/zod/v4/locales/el.js
10325
10325
  var error11 = () => {
10326
10326
  const Sizable = {
10327
10327
  string: { unit: "\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2", verb: "\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9" },
@@ -10434,7 +10434,7 @@ function el_default() {
10434
10434
  };
10435
10435
  }
10436
10436
 
10437
- // node_modules/zod/v4/locales/en.js
10437
+ // ../../node_modules/zod/v4/locales/en.js
10438
10438
  var error12 = () => {
10439
10439
  const Sizable = {
10440
10440
  string: { unit: "characters", verb: "to have" },
@@ -10559,7 +10559,7 @@ function en_default() {
10559
10559
  };
10560
10560
  }
10561
10561
 
10562
- // node_modules/zod/v4/locales/eo.js
10562
+ // ../../node_modules/zod/v4/locales/eo.js
10563
10563
  var error13 = () => {
10564
10564
  const Sizable = {
10565
10565
  string: { unit: "karaktrojn", verb: "havi" },
@@ -10674,7 +10674,7 @@ function eo_default() {
10674
10674
  };
10675
10675
  }
10676
10676
 
10677
- // node_modules/zod/v4/locales/es.js
10677
+ // ../../node_modules/zod/v4/locales/es.js
10678
10678
  var error14 = () => {
10679
10679
  const Sizable = {
10680
10680
  string: { unit: "caracteres", verb: "tener" },
@@ -10811,7 +10811,7 @@ function es_default() {
10811
10811
  };
10812
10812
  }
10813
10813
 
10814
- // node_modules/zod/v4/locales/fa.js
10814
+ // ../../node_modules/zod/v4/locales/fa.js
10815
10815
  var error15 = () => {
10816
10816
  const Sizable = {
10817
10817
  string: { unit: "\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631", verb: "\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F" },
@@ -10931,7 +10931,7 @@ function fa_default() {
10931
10931
  };
10932
10932
  }
10933
10933
 
10934
- // node_modules/zod/v4/locales/fi.js
10934
+ // ../../node_modules/zod/v4/locales/fi.js
10935
10935
  var error16 = () => {
10936
10936
  const Sizable = {
10937
10937
  string: { unit: "merkki\xE4", subject: "merkkijonon" },
@@ -11049,7 +11049,7 @@ function fi_default() {
11049
11049
  };
11050
11050
  }
11051
11051
 
11052
- // node_modules/zod/v4/locales/fr.js
11052
+ // ../../node_modules/zod/v4/locales/fr.js
11053
11053
  var error17 = () => {
11054
11054
  const Sizable = {
11055
11055
  string: { unit: "caract\xE8res", verb: "avoir" },
@@ -11179,7 +11179,7 @@ function fr_default() {
11179
11179
  };
11180
11180
  }
11181
11181
 
11182
- // node_modules/zod/v4/locales/fr-CA.js
11182
+ // ../../node_modules/zod/v4/locales/fr-CA.js
11183
11183
  var error18 = () => {
11184
11184
  const Sizable = {
11185
11185
  string: { unit: "caract\xE8res", verb: "avoir" },
@@ -11292,7 +11292,7 @@ function fr_CA_default() {
11292
11292
  };
11293
11293
  }
11294
11294
 
11295
- // node_modules/zod/v4/locales/gu.js
11295
+ // ../../node_modules/zod/v4/locales/gu.js
11296
11296
  var error19 = () => {
11297
11297
  const Sizable = {
11298
11298
  string: { unit: "\u0A85\u0A95\u0ACD\u0AB7\u0AB0", verb: "\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F" },
@@ -11406,7 +11406,7 @@ function gu_default() {
11406
11406
  };
11407
11407
  }
11408
11408
 
11409
- // node_modules/zod/v4/locales/he.js
11409
+ // ../../node_modules/zod/v4/locales/he.js
11410
11410
  var error20 = () => {
11411
11411
  const TypeNames = {
11412
11412
  string: { label: "\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA", gender: "f" },
@@ -11608,7 +11608,7 @@ function he_default() {
11608
11608
  };
11609
11609
  }
11610
11610
 
11611
- // node_modules/zod/v4/locales/hi.js
11611
+ // ../../node_modules/zod/v4/locales/hi.js
11612
11612
  var error21 = () => {
11613
11613
  const Sizable = {
11614
11614
  string: { unit: "\u0905\u0915\u094D\u0937\u0930", verb: "\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F" },
@@ -11720,7 +11720,7 @@ function hi_default() {
11720
11720
  };
11721
11721
  }
11722
11722
 
11723
- // node_modules/zod/v4/locales/hr.js
11723
+ // ../../node_modules/zod/v4/locales/hr.js
11724
11724
  var error22 = () => {
11725
11725
  const Sizable = {
11726
11726
  string: { unit: "znakova", verb: "imati" },
@@ -11847,7 +11847,7 @@ function hr_default() {
11847
11847
  };
11848
11848
  }
11849
11849
 
11850
- // node_modules/zod/v4/locales/hu.js
11850
+ // ../../node_modules/zod/v4/locales/hu.js
11851
11851
  var error23 = () => {
11852
11852
  const Sizable = {
11853
11853
  string: { unit: "karakter", verb: "legyen" },
@@ -11961,9 +11961,9 @@ function hu_default() {
11961
11961
  };
11962
11962
  }
11963
11963
 
11964
- // node_modules/zod/v4/locales/hy.js
11965
- function getArmenianPlural(count3, one, many) {
11966
- return Math.abs(count3) === 1 ? one : many;
11964
+ // ../../node_modules/zod/v4/locales/hy.js
11965
+ function getArmenianPlural(count4, one, many) {
11966
+ return Math.abs(count4) === 1 ? one : many;
11967
11967
  }
11968
11968
  function withDefiniteArticle(word) {
11969
11969
  if (!word)
@@ -12120,7 +12120,7 @@ function hy_default() {
12120
12120
  };
12121
12121
  }
12122
12122
 
12123
- // node_modules/zod/v4/locales/id.js
12123
+ // ../../node_modules/zod/v4/locales/id.js
12124
12124
  var error25 = () => {
12125
12125
  const Sizable = {
12126
12126
  string: { unit: "karakter", verb: "memiliki" },
@@ -12232,7 +12232,7 @@ function id_default() {
12232
12232
  };
12233
12233
  }
12234
12234
 
12235
- // node_modules/zod/v4/locales/is.js
12235
+ // ../../node_modules/zod/v4/locales/is.js
12236
12236
  var error26 = () => {
12237
12237
  const Sizable = {
12238
12238
  string: { unit: "stafi", verb: "a\xF0 hafa" },
@@ -12347,7 +12347,7 @@ function is_default() {
12347
12347
  };
12348
12348
  }
12349
12349
 
12350
- // node_modules/zod/v4/locales/it.js
12350
+ // ../../node_modules/zod/v4/locales/it.js
12351
12351
  var error27 = () => {
12352
12352
  const Sizable = {
12353
12353
  string: { unit: "caratteri", verb: "avere" },
@@ -12461,7 +12461,7 @@ function it_default() {
12461
12461
  };
12462
12462
  }
12463
12463
 
12464
- // node_modules/zod/v4/locales/ja.js
12464
+ // ../../node_modules/zod/v4/locales/ja.js
12465
12465
  var error28 = () => {
12466
12466
  const Sizable = {
12467
12467
  string: { unit: "\u6587\u5B57", verb: "\u3067\u3042\u308B" },
@@ -12574,7 +12574,7 @@ function ja_default() {
12574
12574
  };
12575
12575
  }
12576
12576
 
12577
- // node_modules/zod/v4/locales/ka.js
12577
+ // ../../node_modules/zod/v4/locales/ka.js
12578
12578
  var error29 = () => {
12579
12579
  const Sizable = {
12580
12580
  string: { unit: "\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD", verb: "\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1" },
@@ -12692,7 +12692,7 @@ function ka_default() {
12692
12692
  };
12693
12693
  }
12694
12694
 
12695
- // node_modules/zod/v4/locales/km.js
12695
+ // ../../node_modules/zod/v4/locales/km.js
12696
12696
  var error30 = () => {
12697
12697
  const Sizable = {
12698
12698
  string: { unit: "\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A", verb: "\u1782\u17BD\u179A\u1798\u17B6\u1793" },
@@ -12808,12 +12808,12 @@ function km_default() {
12808
12808
  };
12809
12809
  }
12810
12810
 
12811
- // node_modules/zod/v4/locales/kh.js
12811
+ // ../../node_modules/zod/v4/locales/kh.js
12812
12812
  function kh_default() {
12813
12813
  return km_default();
12814
12814
  }
12815
12815
 
12816
- // node_modules/zod/v4/locales/kn.js
12816
+ // ../../node_modules/zod/v4/locales/kn.js
12817
12817
  var error31 = () => {
12818
12818
  const Sizable = {
12819
12819
  string: { unit: "\u0C85\u0C95\u0CCD\u0CB7\u0CB0\u0C97\u0CB3\u0CC1", verb: "\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1" },
@@ -12929,7 +12929,7 @@ function kn_default() {
12929
12929
  };
12930
12930
  }
12931
12931
 
12932
- // node_modules/zod/v4/locales/ko.js
12932
+ // ../../node_modules/zod/v4/locales/ko.js
12933
12933
  var error32 = () => {
12934
12934
  const Sizable = {
12935
12935
  string: { unit: "\uBB38\uC790", verb: "to have" },
@@ -13046,7 +13046,7 @@ function ko_default() {
13046
13046
  };
13047
13047
  }
13048
13048
 
13049
- // node_modules/zod/v4/locales/lt.js
13049
+ // ../../node_modules/zod/v4/locales/lt.js
13050
13050
  var capitalizeFirstCharacter = (text3) => {
13051
13051
  return text3.charAt(0).toUpperCase() + text3.slice(1);
13052
13052
  };
@@ -13254,7 +13254,7 @@ function lt_default() {
13254
13254
  };
13255
13255
  }
13256
13256
 
13257
- // node_modules/zod/v4/locales/mk.js
13257
+ // ../../node_modules/zod/v4/locales/mk.js
13258
13258
  var error34 = () => {
13259
13259
  const Sizable = {
13260
13260
  string: { unit: "\u0437\u043D\u0430\u0446\u0438", verb: "\u0434\u0430 \u0438\u043C\u0430\u0430\u0442" },
@@ -13369,7 +13369,7 @@ function mk_default() {
13369
13369
  };
13370
13370
  }
13371
13371
 
13372
- // node_modules/zod/v4/locales/ms.js
13372
+ // ../../node_modules/zod/v4/locales/ms.js
13373
13373
  var error35 = () => {
13374
13374
  const Sizable = {
13375
13375
  string: { unit: "aksara", verb: "mempunyai" },
@@ -13482,7 +13482,7 @@ function ms_default() {
13482
13482
  };
13483
13483
  }
13484
13484
 
13485
- // node_modules/zod/v4/locales/ne.js
13485
+ // ../../node_modules/zod/v4/locales/ne.js
13486
13486
  var error36 = () => {
13487
13487
  const Sizable = {
13488
13488
  string: { unit: "\u0905\u0915\u094D\u0937\u0930", verb: "\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B" },
@@ -13594,7 +13594,7 @@ function ne_default() {
13594
13594
  };
13595
13595
  }
13596
13596
 
13597
- // node_modules/zod/v4/locales/nl.js
13597
+ // ../../node_modules/zod/v4/locales/nl.js
13598
13598
  var error37 = () => {
13599
13599
  const Sizable = {
13600
13600
  string: { unit: "tekens", verb: "heeft" },
@@ -13710,7 +13710,7 @@ function nl_default() {
13710
13710
  };
13711
13711
  }
13712
13712
 
13713
- // node_modules/zod/v4/locales/nn.js
13713
+ // ../../node_modules/zod/v4/locales/nn.js
13714
13714
  var error38 = () => {
13715
13715
  const Sizable = {
13716
13716
  string: { unit: "teikn", verb: "\xE5 ha" },
@@ -13824,7 +13824,7 @@ function nn_default() {
13824
13824
  };
13825
13825
  }
13826
13826
 
13827
- // node_modules/zod/v4/locales/no.js
13827
+ // ../../node_modules/zod/v4/locales/no.js
13828
13828
  var error39 = () => {
13829
13829
  const Sizable = {
13830
13830
  string: { unit: "tegn", verb: "\xE5 ha" },
@@ -13938,7 +13938,7 @@ function no_default() {
13938
13938
  };
13939
13939
  }
13940
13940
 
13941
- // node_modules/zod/v4/locales/ota.js
13941
+ // ../../node_modules/zod/v4/locales/ota.js
13942
13942
  var error40 = () => {
13943
13943
  const Sizable = {
13944
13944
  string: { unit: "harf", verb: "olmal\u0131d\u0131r" },
@@ -14053,7 +14053,7 @@ function ota_default() {
14053
14053
  };
14054
14054
  }
14055
14055
 
14056
- // node_modules/zod/v4/locales/ps.js
14056
+ // ../../node_modules/zod/v4/locales/ps.js
14057
14057
  var error41 = () => {
14058
14058
  const Sizable = {
14059
14059
  string: { unit: "\u062A\u0648\u06A9\u064A", verb: "\u0648\u0644\u0631\u064A" },
@@ -14173,7 +14173,7 @@ function ps_default() {
14173
14173
  };
14174
14174
  }
14175
14175
 
14176
- // node_modules/zod/v4/locales/pl.js
14176
+ // ../../node_modules/zod/v4/locales/pl.js
14177
14177
  var error42 = () => {
14178
14178
  const Sizable = {
14179
14179
  string: { unit: "znak\xF3w", verb: "mie\u0107" },
@@ -14288,7 +14288,7 @@ function pl_default() {
14288
14288
  };
14289
14289
  }
14290
14290
 
14291
- // node_modules/zod/v4/locales/pt.js
14291
+ // ../../node_modules/zod/v4/locales/pt.js
14292
14292
  var error43 = () => {
14293
14293
  const Sizable = {
14294
14294
  string: { unit: "caracteres" },
@@ -14432,7 +14432,7 @@ function pt_default() {
14432
14432
  };
14433
14433
  }
14434
14434
 
14435
- // node_modules/zod/v4/locales/pt-BR.js
14435
+ // ../../node_modules/zod/v4/locales/pt-BR.js
14436
14436
  var error44 = () => {
14437
14437
  const Sizable = {
14438
14438
  string: { unit: "caracteres" },
@@ -14577,7 +14577,7 @@ function pt_BR_default() {
14577
14577
  };
14578
14578
  }
14579
14579
 
14580
- // node_modules/zod/v4/locales/ro.js
14580
+ // ../../node_modules/zod/v4/locales/ro.js
14581
14581
  var error45 = () => {
14582
14582
  const Sizable = {
14583
14583
  string: { unit: "caractere", verb: "s\u0103 aib\u0103" },
@@ -14700,9 +14700,9 @@ function ro_default() {
14700
14700
  };
14701
14701
  }
14702
14702
 
14703
- // node_modules/zod/v4/locales/ru.js
14704
- function getRussianPlural(count3, one, few, many) {
14705
- const absCount = Math.abs(count3);
14703
+ // ../../node_modules/zod/v4/locales/ru.js
14704
+ function getRussianPlural(count4, one, few, many) {
14705
+ const absCount = Math.abs(count4);
14706
14706
  const lastDigit = absCount % 10;
14707
14707
  const lastTwoDigits = absCount % 100;
14708
14708
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -14869,7 +14869,7 @@ function ru_default() {
14869
14869
  };
14870
14870
  }
14871
14871
 
14872
- // node_modules/zod/v4/locales/sk.js
14872
+ // ../../node_modules/zod/v4/locales/sk.js
14873
14873
  var error47 = () => {
14874
14874
  const Sizable = {
14875
14875
  string: { unit: "znakov", verb: "ma\u0165" },
@@ -14986,7 +14986,7 @@ function sk_default() {
14986
14986
  };
14987
14987
  }
14988
14988
 
14989
- // node_modules/zod/v4/locales/sl.js
14989
+ // ../../node_modules/zod/v4/locales/sl.js
14990
14990
  var error48 = () => {
14991
14991
  const Sizable = {
14992
14992
  string: { unit: "znakov", verb: "imeti" },
@@ -15101,7 +15101,7 @@ function sl_default() {
15101
15101
  };
15102
15102
  }
15103
15103
 
15104
- // node_modules/zod/v4/locales/sv.js
15104
+ // ../../node_modules/zod/v4/locales/sv.js
15105
15105
  var error49 = () => {
15106
15106
  const Sizable = {
15107
15107
  string: { unit: "tecken", verb: "att ha" },
@@ -15217,7 +15217,7 @@ function sv_default() {
15217
15217
  };
15218
15218
  }
15219
15219
 
15220
- // node_modules/zod/v4/locales/ta.js
15220
+ // ../../node_modules/zod/v4/locales/ta.js
15221
15221
  var error50 = () => {
15222
15222
  const Sizable = {
15223
15223
  string: { unit: "\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD", verb: "\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD" },
@@ -15333,7 +15333,7 @@ function ta_default() {
15333
15333
  };
15334
15334
  }
15335
15335
 
15336
- // node_modules/zod/v4/locales/tg.js
15336
+ // ../../node_modules/zod/v4/locales/tg.js
15337
15337
  var error51 = () => {
15338
15338
  const Sizable = {
15339
15339
  string: { unit: "\u0430\u043B\u043E\u043C\u0430\u0442", verb: "\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434" },
@@ -15450,7 +15450,7 @@ function tg_default() {
15450
15450
  };
15451
15451
  }
15452
15452
 
15453
- // node_modules/zod/v4/locales/th.js
15453
+ // ../../node_modules/zod/v4/locales/th.js
15454
15454
  var error52 = () => {
15455
15455
  const Sizable = {
15456
15456
  string: { unit: "\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23", verb: "\u0E04\u0E27\u0E23\u0E21\u0E35" },
@@ -15566,7 +15566,7 @@ function th_default() {
15566
15566
  };
15567
15567
  }
15568
15568
 
15569
- // node_modules/zod/v4/locales/tk.js
15569
+ // ../../node_modules/zod/v4/locales/tk.js
15570
15570
  var error53 = () => {
15571
15571
  const Sizable = {
15572
15572
  string: { unit: "simwol", verb: "bolmaly" },
@@ -15674,7 +15674,7 @@ function tk_default() {
15674
15674
  };
15675
15675
  }
15676
15676
 
15677
- // node_modules/zod/v4/locales/tr.js
15677
+ // ../../node_modules/zod/v4/locales/tr.js
15678
15678
  var error54 = () => {
15679
15679
  const Sizable = {
15680
15680
  string: { unit: "karakter", verb: "olmal\u0131" },
@@ -15785,7 +15785,7 @@ function tr_default() {
15785
15785
  };
15786
15786
  }
15787
15787
 
15788
- // node_modules/zod/v4/locales/uk.js
15788
+ // ../../node_modules/zod/v4/locales/uk.js
15789
15789
  var error55 = () => {
15790
15790
  const Sizable = {
15791
15791
  string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432", verb: "\u043C\u0430\u0442\u0438\u043C\u0435" },
@@ -15899,12 +15899,12 @@ function uk_default() {
15899
15899
  };
15900
15900
  }
15901
15901
 
15902
- // node_modules/zod/v4/locales/ua.js
15902
+ // ../../node_modules/zod/v4/locales/ua.js
15903
15903
  function ua_default() {
15904
15904
  return uk_default();
15905
15905
  }
15906
15906
 
15907
- // node_modules/zod/v4/locales/ur.js
15907
+ // ../../node_modules/zod/v4/locales/ur.js
15908
15908
  var error56 = () => {
15909
15909
  const Sizable = {
15910
15910
  string: { unit: "\u062D\u0631\u0648\u0641", verb: "\u06C1\u0648\u0646\u0627" },
@@ -16020,7 +16020,7 @@ function ur_default() {
16020
16020
  };
16021
16021
  }
16022
16022
 
16023
- // node_modules/zod/v4/locales/uz.js
16023
+ // ../../node_modules/zod/v4/locales/uz.js
16024
16024
  var error57 = () => {
16025
16025
  const Sizable = {
16026
16026
  string: { unit: "belgi", verb: "bo\u2018lishi kerak" },
@@ -16134,7 +16134,7 @@ function uz_default() {
16134
16134
  };
16135
16135
  }
16136
16136
 
16137
- // node_modules/zod/v4/locales/vi.js
16137
+ // ../../node_modules/zod/v4/locales/vi.js
16138
16138
  var error58 = () => {
16139
16139
  const Sizable = {
16140
16140
  string: { unit: "k\xFD t\u1EF1", verb: "c\xF3" },
@@ -16248,7 +16248,7 @@ function vi_default() {
16248
16248
  };
16249
16249
  }
16250
16250
 
16251
- // node_modules/zod/v4/locales/zh-CN.js
16251
+ // ../../node_modules/zod/v4/locales/zh-CN.js
16252
16252
  var error59 = () => {
16253
16253
  const Sizable = {
16254
16254
  string: { unit: "\u5B57\u7B26", verb: "\u5305\u542B" },
@@ -16363,7 +16363,7 @@ function zh_CN_default() {
16363
16363
  };
16364
16364
  }
16365
16365
 
16366
- // node_modules/zod/v4/locales/zh-TW.js
16366
+ // ../../node_modules/zod/v4/locales/zh-TW.js
16367
16367
  var error60 = () => {
16368
16368
  const Sizable = {
16369
16369
  string: { unit: "\u5B57\u5143", verb: "\u64C1\u6709" },
@@ -16476,7 +16476,7 @@ function zh_TW_default() {
16476
16476
  };
16477
16477
  }
16478
16478
 
16479
- // node_modules/zod/v4/locales/yo.js
16479
+ // ../../node_modules/zod/v4/locales/yo.js
16480
16480
  var error61 = () => {
16481
16481
  const Sizable = {
16482
16482
  string: { unit: "\xE0mi", verb: "n\xED" },
@@ -16589,7 +16589,7 @@ function yo_default() {
16589
16589
  };
16590
16590
  }
16591
16591
 
16592
- // node_modules/zod/v4/core/registries.js
16592
+ // ../../node_modules/zod/v4/core/registries.js
16593
16593
  var _a2;
16594
16594
  var $output = /* @__PURE__ */ Symbol("ZodOutput");
16595
16595
  var $input = /* @__PURE__ */ Symbol("ZodInput");
@@ -16639,7 +16639,7 @@ function registry() {
16639
16639
  (_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
16640
16640
  var globalRegistry = globalThis.__zod_globalRegistry;
16641
16641
 
16642
- // node_modules/zod/v4/core/compile.js
16642
+ // ../../node_modules/zod/v4/core/compile.js
16643
16643
  var INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
16644
16644
  var FALLBACK_FLAG = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
16645
16645
  var ZodCompileAsyncError = class extends Error {
@@ -18241,7 +18241,7 @@ function generateTransformCheck(doc, ctx, schema, accessor) {
18241
18241
  return accessor;
18242
18242
  }
18243
18243
 
18244
- // node_modules/zod/v4/core/api.js
18244
+ // ../../node_modules/zod/v4/core/api.js
18245
18245
  function snapshotChecks(def) {
18246
18246
  if (def.checks)
18247
18247
  def.checks = [...def.checks];
@@ -19300,9 +19300,9 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
19300
19300
  return inst;
19301
19301
  }
19302
19302
 
19303
- // node_modules/zod/v4/core/to-json-schema.js
19304
- function assignProps(target, ...sources) {
19305
- for (const source of sources) {
19303
+ // ../../node_modules/zod/v4/core/to-json-schema.js
19304
+ function assignProps(target, ...sources2) {
19305
+ for (const source of sources2) {
19306
19306
  for (const key of Reflect.ownKeys(source)) {
19307
19307
  if (Object.prototype.propertyIsEnumerable.call(source, key)) {
19308
19308
  assignProp(target, key, source[key]);
@@ -19830,7 +19830,7 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
19830
19830
  return finalize(ctx, schema);
19831
19831
  };
19832
19832
 
19833
- // node_modules/zod/v4/core/json-schema-processors.js
19833
+ // ../../node_modules/zod/v4/core/json-schema-processors.js
19834
19834
  var narrowMin = (agg, key, value) => {
19835
19835
  if (agg[key] === void 0 || value > agg[key])
19836
19836
  agg[key] = value;
@@ -20578,7 +20578,7 @@ function toJSONSchema(input2, params) {
20578
20578
  return finalize(ctx, input2);
20579
20579
  }
20580
20580
 
20581
- // node_modules/zod/v4/core/json-schema-generator.js
20581
+ // ../../node_modules/zod/v4/core/json-schema-generator.js
20582
20582
  var JSONSchemaGenerator = class {
20583
20583
  /** @deprecated Access via ctx instead */
20584
20584
  get metadataRegistry() {
@@ -20656,10 +20656,10 @@ var JSONSchemaGenerator = class {
20656
20656
  }
20657
20657
  };
20658
20658
 
20659
- // node_modules/zod/v4/core/json-schema.js
20659
+ // ../../node_modules/zod/v4/core/json-schema.js
20660
20660
  var json_schema_exports = {};
20661
20661
 
20662
- // node_modules/zod/v4/classic/schemas.js
20662
+ // ../../node_modules/zod/v4/classic/schemas.js
20663
20663
  var schemas_exports2 = {};
20664
20664
  __export(schemas_exports2, {
20665
20665
  ZodAny: () => ZodAny,
@@ -20840,7 +20840,7 @@ __export(schemas_exports2, {
20840
20840
  xor: () => xor
20841
20841
  });
20842
20842
 
20843
- // node_modules/zod/v4/classic/checks.js
20843
+ // ../../node_modules/zod/v4/classic/checks.js
20844
20844
  var checks_exports2 = {};
20845
20845
  __export(checks_exports2, {
20846
20846
  endsWith: () => _endsWith,
@@ -20875,7 +20875,7 @@ __export(checks_exports2, {
20875
20875
  uppercase: () => _uppercase
20876
20876
  });
20877
20877
 
20878
- // node_modules/zod/v4/classic/errors.js
20878
+ // ../../node_modules/zod/v4/classic/errors.js
20879
20879
  var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
20880
20880
  function _lazyMethod(proto, key, make) {
20881
20881
  Object.defineProperty(proto, key, {
@@ -20921,7 +20921,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, void 0
20921
20921
  Parent: Error
20922
20922
  });
20923
20923
 
20924
- // node_modules/zod/v4/classic/parse.js
20924
+ // ../../node_modules/zod/v4/classic/parse.js
20925
20925
  var parse2 = /* @__PURE__ */ _parse(ZodRealError);
20926
20926
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
20927
20927
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -20935,7 +20935,7 @@ var safeDecode2 = /* @__PURE__ */ _safeDecode(ZodRealError);
20935
20935
  var safeEncodeAsync2 = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
20936
20936
  var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
20937
20937
 
20938
- // node_modules/zod/v4/classic/schemas.js
20938
+ // ../../node_modules/zod/v4/classic/schemas.js
20939
20939
  function _ensureDefaultLocale() {
20940
20940
  if (!globalConfig.localeError)
20941
20941
  config(en_default());
@@ -22400,7 +22400,7 @@ function preprocess(fn, schema) {
22400
22400
  });
22401
22401
  }
22402
22402
 
22403
- // node_modules/zod/v4/classic/compat.js
22403
+ // ../../node_modules/zod/v4/classic/compat.js
22404
22404
  var ZodIssueCode = {
22405
22405
  invalid_type: "invalid_type",
22406
22406
  too_big: "too_big",
@@ -22426,7 +22426,7 @@ var ZodFirstPartyTypeKind;
22426
22426
  /* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
22427
22427
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
22428
22428
 
22429
- // node_modules/zod/v4/classic/iso.js
22429
+ // ../../node_modules/zod/v4/classic/iso.js
22430
22430
  var iso_exports = {};
22431
22431
  __export(iso_exports, {
22432
22432
  ZodISODate: () => ZodISODate,
@@ -22451,7 +22451,7 @@ function duration2(params) {
22451
22451
  return _isoDuration(ZodISODuration, params);
22452
22452
  }
22453
22453
 
22454
- // node_modules/zod/v4/classic/from-json-schema.js
22454
+ // ../../node_modules/zod/v4/classic/from-json-schema.js
22455
22455
  var z = {
22456
22456
  ...schemas_exports2,
22457
22457
  ...checks_exports2,
@@ -22551,13 +22551,13 @@ function resolveRef(ref, ctx) {
22551
22551
  if (!ref.startsWith("#")) {
22552
22552
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
22553
22553
  }
22554
- const path30 = ref.slice(1).split("/").filter(Boolean);
22555
- if (path30.length === 0) {
22554
+ const path32 = ref.slice(1).split("/").filter(Boolean);
22555
+ if (path32.length === 0) {
22556
22556
  return ctx.rootSchema;
22557
22557
  }
22558
22558
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
22559
- if (path30[0] === defsKey) {
22560
- const key = path30[1] === void 0 ? void 0 : decodeJSONPointerSegment(path30[1]);
22559
+ if (path32[0] === defsKey) {
22560
+ const key = path32[1] === void 0 ? void 0 : decodeJSONPointerSegment(path32[1]);
22561
22561
  if (!key || !ctx.defs[key]) {
22562
22562
  throw new Error(`Reference not found: ${ref}`);
22563
22563
  }
@@ -23184,7 +23184,7 @@ function fromJSONSchema(schema, params) {
23184
23184
  return convertSchema(normalized, ctx);
23185
23185
  }
23186
23186
 
23187
- // node_modules/zod/v4/core/visit.js
23187
+ // ../../node_modules/zod/v4/core/visit.js
23188
23188
  var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
23189
23189
  function visit(schema, fnOrHandlers) {
23190
23190
  const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
@@ -23339,7 +23339,7 @@ function visit(schema, fnOrHandlers) {
23339
23339
  return run2(schema);
23340
23340
  }
23341
23341
 
23342
- // node_modules/zod/v4/classic/deep-partial.js
23342
+ // ../../node_modules/zod/v4/classic/deep-partial.js
23343
23343
  function deepPartial(schema) {
23344
23344
  return visit(schema, {
23345
23345
  object: (s) => s.partial(),
@@ -23351,7 +23351,7 @@ function deepPartial(schema) {
23351
23351
  });
23352
23352
  }
23353
23353
 
23354
- // node_modules/zod/v4/classic/in-out.js
23354
+ // ../../node_modules/zod/v4/classic/in-out.js
23355
23355
  function withChecks(side, checks) {
23356
23356
  if (!checks?.length)
23357
23357
  return side;
@@ -23381,7 +23381,7 @@ function output(schema) {
23381
23381
  });
23382
23382
  }
23383
23383
 
23384
- // node_modules/zod/v4/classic/coerce.js
23384
+ // ../../node_modules/zod/v4/classic/coerce.js
23385
23385
  var coerce_exports = {};
23386
23386
  __export(coerce_exports, {
23387
23387
  bigint: () => bigint3,
@@ -23819,7 +23819,7 @@ import { createServer } from "node:http";
23819
23819
  import { connect as netConnect } from "node:net";
23820
23820
  import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
23821
23821
 
23822
- // node_modules/ws/wrapper.mjs
23822
+ // ../../node_modules/ws/wrapper.mjs
23823
23823
  var import_stream = __toESM(require_stream(), 1);
23824
23824
  var import_extension = __toESM(require_extension(), 1);
23825
23825
  var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
@@ -23830,7 +23830,7 @@ var import_websocket = __toESM(require_websocket(), 1);
23830
23830
  var import_websocket_server = __toESM(require_websocket_server(), 1);
23831
23831
  var wrapper_default = import_websocket.default;
23832
23832
 
23833
- // node_modules/jose/dist/webapi/lib/buffer_utils.js
23833
+ // ../../node_modules/jose/dist/webapi/lib/buffer_utils.js
23834
23834
  var encoder = new TextEncoder();
23835
23835
  var decoder = new TextDecoder();
23836
23836
  var strictDecoder = new TextDecoder("utf-8", { fatal: true });
@@ -23881,7 +23881,7 @@ function decodeBase64(encoded, url2 = false) {
23881
23881
  return bytes3;
23882
23882
  }
23883
23883
 
23884
- // node_modules/jose/dist/webapi/util/errors.js
23884
+ // ../../node_modules/jose/dist/webapi/util/errors.js
23885
23885
  var JOSEError = class extends Error {
23886
23886
  static code = "ERR_JOSE_GENERIC";
23887
23887
  code = "ERR_JOSE_GENERIC";
@@ -23933,7 +23933,7 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
23933
23933
  }
23934
23934
  };
23935
23935
 
23936
- // node_modules/jose/dist/webapi/util/base64url.js
23936
+ // ../../node_modules/jose/dist/webapi/util/base64url.js
23937
23937
  var invalid = "The input to be decoded is not correctly encoded.";
23938
23938
  function decode3(input2) {
23939
23939
  try {
@@ -23946,7 +23946,7 @@ function encode4(input2) {
23946
23946
  return encodeBase64(typeof input2 == "string" ? encoder.encode(input2) : input2, true);
23947
23947
  }
23948
23948
 
23949
- // node_modules/jose/dist/webapi/lib/validate.js
23949
+ // ../../node_modules/jose/dist/webapi/lib/validate.js
23950
23950
  function assertUint8Array(input2, label2) {
23951
23951
  if (!(input2 instanceof Uint8Array))
23952
23952
  throw new TypeError(`${label2} must be an instance of Uint8Array`);
@@ -24047,7 +24047,7 @@ function serializeJoseHeader(Err, header) {
24047
24047
  return [parsed, serialized];
24048
24048
  }
24049
24049
 
24050
- // node_modules/jose/dist/webapi/lib/key.js
24050
+ // ../../node_modules/jose/dist/webapi/lib/key.js
24051
24051
  var tag = (key) => key[Symbol.toStringTag];
24052
24052
  var jwkMatchesOp = (entry, key, usage) => {
24053
24053
  const { alg } = entry;
@@ -24178,7 +24178,7 @@ async function rawKey(key, expected, usage, extractable = false) {
24178
24178
  return key instanceof Uint8Array && (key = await crypto.subtle.importKey("raw", key, expected, extractable, [usage])), checkCryptoKey(key, expected, usage), key;
24179
24179
  }
24180
24180
 
24181
- // node_modules/jose/dist/webapi/lib/key_descriptor.js
24181
+ // ../../node_modules/jose/dist/webapi/lib/key_descriptor.js
24182
24182
  function table(entries) {
24183
24183
  const out = { __proto__: null };
24184
24184
  for (const alg in entries)
@@ -24186,7 +24186,7 @@ function table(entries) {
24186
24186
  return out;
24187
24187
  }
24188
24188
 
24189
- // node_modules/jose/dist/webapi/lib/jws_algorithms.js
24189
+ // ../../node_modules/jose/dist/webapi/lib/jws_algorithms.js
24190
24190
  var sig = [["verify"], ["sign"]];
24191
24191
  function hmac(bits) {
24192
24192
  const subtle = { name: "HMAC", hash: `SHA-${bits}` };
@@ -24256,7 +24256,7 @@ function jwsAlgorithm(alg) {
24256
24256
  return entry;
24257
24257
  }
24258
24258
 
24259
- // node_modules/jose/dist/webapi/lib/jws_verify.js
24259
+ // ../../node_modules/jose/dist/webapi/lib/jws_verify.js
24260
24260
  function prepareVerify(options) {
24261
24261
  return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
24262
24262
  }
@@ -24308,13 +24308,13 @@ async function verifyCompact(jws, shared, key) {
24308
24308
  return verifySignature({ payload: payload2, protected: protectedHeader, signature }, shared, key, encodeCompactUnencodedPayload);
24309
24309
  }
24310
24310
 
24311
- // node_modules/jose/dist/webapi/jws/compact/verify.js
24311
+ // ../../node_modules/jose/dist/webapi/jws/compact/verify.js
24312
24312
  async function compactVerify(jws, key, options) {
24313
24313
  const [result2] = await verifyCompact(jws, prepareVerify(options), key);
24314
24314
  return result2;
24315
24315
  }
24316
24316
 
24317
- // node_modules/jose/dist/webapi/lib/jwt_claims_set.js
24317
+ // ../../node_modules/jose/dist/webapi/lib/jwt_claims_set.js
24318
24318
  var epoch = (date6) => Math.floor(date6.getTime() / 1e3);
24319
24319
  var multipliers = {
24320
24320
  s: 1,
@@ -24400,7 +24400,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
24400
24400
  return payload2;
24401
24401
  }
24402
24402
 
24403
- // node_modules/jose/dist/webapi/jwt/verify.js
24403
+ // ../../node_modules/jose/dist/webapi/jwt/verify.js
24404
24404
  async function jwtVerify(jwt2, key, options) {
24405
24405
  const [verified, b64] = await verifyCompact(jwt2, prepareVerify(options), key);
24406
24406
  if (!b64)
@@ -24409,7 +24409,7 @@ async function jwtVerify(jwt2, key, options) {
24409
24409
  return { ...verified, payload: payload2 };
24410
24410
  }
24411
24411
 
24412
- // node_modules/jose/dist/webapi/lib/jws_sign.js
24412
+ // ../../node_modules/jose/dist/webapi/lib/jws_sign.js
24413
24413
  async function createSignature(input2, key, rejectUnencoded) {
24414
24414
  let [payload2, protectedHeader, unprotectedHeader, crit] = input2, protectedHeaderString = "";
24415
24415
  if (protectedHeader !== void 0) {
@@ -24447,7 +24447,7 @@ async function createCompactSignature(payload2, protectedHeader, crit, key, reje
24447
24447
  return `${jws.protected}.${jws.payload}.${jws.signature}`;
24448
24448
  }
24449
24449
 
24450
- // node_modules/jose/dist/webapi/jws/compact/sign.js
24450
+ // ../../node_modules/jose/dist/webapi/jws/compact/sign.js
24451
24451
  var CompactSign = class {
24452
24452
  #payload;
24453
24453
  #protectedHeader;
@@ -24464,7 +24464,7 @@ var CompactSign = class {
24464
24464
  }
24465
24465
  };
24466
24466
 
24467
- // node_modules/jose/dist/webapi/util/decode_jwt.js
24467
+ // ../../node_modules/jose/dist/webapi/util/decode_jwt.js
24468
24468
  function decodeJwt(jwt2) {
24469
24469
  if (typeof jwt2 != "string")
24470
24470
  throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
@@ -24593,7 +24593,7 @@ var RelayBridge = class _RelayBridge {
24593
24593
  const upstream = netConnect({ host, port });
24594
24594
  this.tunnels.add(socket);
24595
24595
  this.tunnels.add(upstream);
24596
- let open14 = false;
24596
+ let open15 = false;
24597
24597
  const cleanup = () => {
24598
24598
  this.tunnels.delete(socket);
24599
24599
  this.tunnels.delete(upstream);
@@ -24601,13 +24601,13 @@ var RelayBridge = class _RelayBridge {
24601
24601
  upstream.destroy();
24602
24602
  };
24603
24603
  const timer = setTimeout(() => {
24604
- if (!open14) {
24604
+ if (!open15) {
24605
24605
  refuse("504 Gateway Timeout");
24606
24606
  cleanup();
24607
24607
  }
24608
24608
  }, CONNECT_TIMEOUT_MS);
24609
24609
  upstream.once("connect", () => {
24610
- open14 = true;
24610
+ open15 = true;
24611
24611
  clearTimeout(timer);
24612
24612
  socket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
24613
24613
  if (head.length) upstream.write(head);
@@ -24616,7 +24616,7 @@ var RelayBridge = class _RelayBridge {
24616
24616
  });
24617
24617
  upstream.on("error", () => {
24618
24618
  clearTimeout(timer);
24619
- if (!open14) refuse("502 Bad Gateway");
24619
+ if (!open15) refuse("502 Bad Gateway");
24620
24620
  cleanup();
24621
24621
  });
24622
24622
  socket.on("error", cleanup);
@@ -24637,7 +24637,7 @@ var RelayBridge = class _RelayBridge {
24637
24637
  const remote = (0, import_stream.default)(ws, { allowHalfOpen: false });
24638
24638
  this.tunnels.add(socket);
24639
24639
  this.tunnels.add(remote);
24640
- let reply = Buffer.alloc(0), open14 = false;
24640
+ let reply = Buffer.alloc(0), open15 = false;
24641
24641
  const cleanup = () => {
24642
24642
  this.tunnels.delete(socket);
24643
24643
  this.tunnels.delete(remote);
@@ -24645,7 +24645,7 @@ var RelayBridge = class _RelayBridge {
24645
24645
  remote.destroy();
24646
24646
  };
24647
24647
  const timer = setTimeout(() => {
24648
- if (!open14) {
24648
+ if (!open15) {
24649
24649
  refuse("504 Gateway Timeout");
24650
24650
  cleanup();
24651
24651
  }
@@ -24667,7 +24667,7 @@ var RelayBridge = class _RelayBridge {
24667
24667
  cleanup();
24668
24668
  return;
24669
24669
  }
24670
- open14 = true;
24670
+ open15 = true;
24671
24671
  socket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
24672
24672
  const rest = reply.subarray(end + 4);
24673
24673
  if (rest.length) socket.write(rest);
@@ -24684,7 +24684,7 @@ Proxy-Authorization: Basic ${Buffer.from("lc:" + route.token).toString("base64")
24684
24684
  remote.on("data", onReply);
24685
24685
  });
24686
24686
  remote.on("error", () => {
24687
- if (!open14) refuse("502 Bad Gateway");
24687
+ if (!open15) refuse("502 Bad Gateway");
24688
24688
  cleanup();
24689
24689
  });
24690
24690
  socket.on("error", cleanup);
@@ -24930,14 +24930,14 @@ async function loadProxyModeFlag(dir) {
24930
24930
  }
24931
24931
  }
24932
24932
  async function writeProxyState(dir, state) {
24933
- const file2 = path.join(dir, "proxy.json");
24933
+ const file3 = path.join(dir, "proxy.json");
24934
24934
  try {
24935
24935
  if (!state) {
24936
- await rm(file2, { force: true });
24936
+ await rm(file3, { force: true });
24937
24937
  return;
24938
24938
  }
24939
24939
  await mkdir(dir, { recursive: true });
24940
- await writeFile(file2, JSON.stringify({ ...state, updatedAt: Date.now() }), { mode: 384 });
24940
+ await writeFile(file3, JSON.stringify({ ...state, updatedAt: Date.now() }), { mode: 384 });
24941
24941
  } catch {
24942
24942
  }
24943
24943
  }
@@ -25050,21 +25050,21 @@ import path2 from "node:path";
25050
25050
  import { spawn, spawnSync } from "node:child_process";
25051
25051
  import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
25052
25052
  var Receipt = external_exports.object({ version: external_exports.literal(1), deviceId: external_exports.string().uuid(), tenantId: external_exports.string().uuid(), accountId: external_exports.string().uuid(), bundleId: external_exports.string().regex(/^[a-f0-9]{64}$/) }).strict();
25053
- function networkPath(stateDirectory, name2) {
25054
- return path2.join(path2.dirname(stateDirectory), "Network", name2);
25053
+ function networkPath(stateDirectory2, name2) {
25054
+ return path2.join(path2.dirname(stateDirectory2), "Network", name2);
25055
25055
  }
25056
- async function networkDirectory(stateDirectory) {
25057
- const directory = path2.dirname(networkPath(stateDirectory, "x"));
25056
+ async function networkDirectory(stateDirectory2) {
25057
+ const directory = path2.dirname(networkPath(stateDirectory2, "x"));
25058
25058
  await fs.mkdir(directory, { recursive: true, mode: 448 });
25059
25059
  const stat2 = await fs.lstat(directory);
25060
25060
  if (!stat2.isDirectory() || stat2.isSymbolicLink()) throw Error("NETWORK_DIRECTORY_INVALID");
25061
25061
  return directory;
25062
25062
  }
25063
- async function networkPrepared(stateDirectory, identity) {
25063
+ async function networkPrepared(stateDirectory2, identity) {
25064
25064
  try {
25065
- const file2 = networkPath(stateDirectory, "network-prepared.json"), stat2 = await fs.lstat(file2);
25065
+ const file3 = networkPath(stateDirectory2, "network-prepared.json"), stat2 = await fs.lstat(file3);
25066
25066
  if (!stat2.isFile() || stat2.isSymbolicLink() || stat2.size > 1024) return false;
25067
- const receipt = Receipt.parse(JSON.parse(await fs.readFile(file2, "utf8"))), e = identity.enrollment;
25067
+ const receipt = Receipt.parse(JSON.parse(await fs.readFile(file3, "utf8"))), e = identity.enrollment;
25068
25068
  return !!e && receipt.deviceId === e.deviceId && receipt.tenantId === e.tenantId && receipt.accountId === e.accountId;
25069
25069
  } catch {
25070
25070
  return false;
@@ -25100,9 +25100,9 @@ async function payload(binaryDirectory) {
25100
25100
  throw error62;
25101
25101
  }
25102
25102
  }
25103
- async function installedNetworkHelper(stateDirectory) {
25103
+ async function installedNetworkHelper(stateDirectory2) {
25104
25104
  try {
25105
- const receipt = Receipt.parse(JSON.parse(await fs.readFile(networkPath(stateDirectory, "network-prepared.json"), "utf8")));
25105
+ const receipt = Receipt.parse(JSON.parse(await fs.readFile(networkPath(stateDirectory2, "network-prepared.json"), "utf8")));
25106
25106
  const programFiles = process.env.ProgramW6432 ?? process.env.ProgramFiles ?? "C:\\Program Files";
25107
25107
  const helper = path2.join(programFiles, "LocalCommander", "Network", receipt.bundleId, "NetworkService.exe"), stat2 = await fs.lstat(helper);
25108
25108
  if (!stat2.isFile() || stat2.isSymbolicLink() || stat2.size > 4 * 1024 * 1024 || (await fs.realpath(helper)).toLowerCase() !== path2.resolve(helper).toLowerCase()) return null;
@@ -25131,23 +25131,23 @@ async function elevated(helper, command, requestPath, directory) {
25131
25131
  await fs.rm(scriptPath, { force: true });
25132
25132
  }
25133
25133
  }
25134
- async function setupNetwork(binaryDirectory, stateDirectory, identity) {
25134
+ async function setupNetwork(binaryDirectory, stateDirectory2, identity) {
25135
25135
  const bundle = await payload(binaryDirectory);
25136
25136
  if (!bundle) return "not_packaged";
25137
25137
  const e = identity.enrollment;
25138
25138
  if (!e?.accountId) throw Error("NETWORK_ACCOUNT_BINDING_REQUIRED");
25139
25139
  const request = { ownerSid: windowsSid(), tenantId: e.tenantId, accountId: e.accountId, deviceId: e.deviceId, keyFingerprint: identity.fingerprint };
25140
- const directory = await networkDirectory(stateDirectory);
25140
+ const directory = await networkDirectory(stateDirectory2);
25141
25141
  const requestPath = path2.join(directory, "network-setup-" + randomUUID2() + ".json");
25142
25142
  await fs.writeFile(requestPath, JSON.stringify(request), { flag: "wx", mode: 384 });
25143
25143
  try {
25144
25144
  await elevated(bundle.helper, "setup", requestPath, directory);
25145
25145
  await localNetworkControl(e.deviceId);
25146
25146
  const receipt = Receipt.parse({ version: 1, deviceId: e.deviceId, tenantId: e.tenantId, accountId: e.accountId, bundleId: bundle.bundleId });
25147
- const file2 = path2.join(directory, "network-prepared.json"), temp = file2 + "." + randomUUID2();
25147
+ const file3 = path2.join(directory, "network-prepared.json"), temp = file3 + "." + randomUUID2();
25148
25148
  await fs.writeFile(temp, JSON.stringify(receipt), { flag: "wx", mode: 384 });
25149
25149
  try {
25150
- await fs.rename(temp, file2);
25150
+ await fs.rename(temp, file3);
25151
25151
  } finally {
25152
25152
  await fs.rm(temp, { force: true });
25153
25153
  }
@@ -25156,14 +25156,14 @@ async function setupNetwork(binaryDirectory, stateDirectory, identity) {
25156
25156
  await fs.rm(requestPath, { force: true });
25157
25157
  }
25158
25158
  }
25159
- async function removeNetwork(binaryDirectory, stateDirectory, identity) {
25159
+ async function removeNetwork(binaryDirectory, stateDirectory2, identity) {
25160
25160
  const e = identity.enrollment;
25161
- if (!e || !await networkPrepared(stateDirectory, identity)) return;
25161
+ if (!e || !await networkPrepared(stateDirectory2, identity)) return;
25162
25162
  await localNetworkControl(e.deviceId, "off");
25163
- const helper = (await payload(binaryDirectory))?.helper ?? await installedNetworkHelper(stateDirectory);
25163
+ const helper = (await payload(binaryDirectory))?.helper ?? await installedNetworkHelper(stateDirectory2);
25164
25164
  if (!helper) throw Error("NETWORK_REMOVAL_PACKAGE_REQUIRED");
25165
- await elevated(helper, "uninstall", void 0, await networkDirectory(stateDirectory));
25166
- await fs.rm(networkPath(stateDirectory, "network-prepared.json"), { force: true });
25165
+ await elevated(helper, "uninstall", void 0, await networkDirectory(stateDirectory2));
25166
+ await fs.rm(networkPath(stateDirectory2, "network-prepared.json"), { force: true });
25167
25167
  }
25168
25168
  async function openNetworkPanel(binaryDirectory, identity) {
25169
25169
  const bundle = await payload(binaryDirectory), e = identity.enrollment;
@@ -25177,8 +25177,8 @@ async function openNetworkPanel(binaryDirectory, identity) {
25177
25177
  }
25178
25178
 
25179
25179
  // agent/src/main.ts
25180
- import path29 from "node:path";
25181
- import os8 from "node:os";
25180
+ import path31 from "node:path";
25181
+ import os9 from "node:os";
25182
25182
 
25183
25183
  // agent/src/posix-store.ts
25184
25184
  import { constants } from "node:fs";
@@ -25597,7 +25597,7 @@ async function acquirePosixJournalGuard(directory, helper) {
25597
25597
  }
25598
25598
 
25599
25599
  // agent/src/main.ts
25600
- import { mkdir as mkdir14, open as open13, readFile as readFile12, realpath as realpath10, rm as rm10 } from "node:fs/promises";
25600
+ import { mkdir as mkdir16, open as open14, readFile as readFile14, realpath as realpath10, rm as rm12 } from "node:fs/promises";
25601
25601
  import { fileURLToPath } from "node:url";
25602
25602
 
25603
25603
  // packages/operations/src/crypto.ts
@@ -25734,8 +25734,8 @@ var exec2 = promisify2(execFile2);
25734
25734
  async function darwinSupervisorLiveness(helper, pids, records = []) {
25735
25735
  if (process.platform !== "darwin" || !process.getuid?.() || process.getuid() !== process.geteuid?.()) return null;
25736
25736
  const remaining = new Set(pids), uid = process.getuid(), deadline = Date.now() + 1e4, env = buildChildEnvironment(process.env);
25737
- const run2 = (file2, args) => exec2(
25738
- file2,
25737
+ const run2 = (file3, args) => exec2(
25738
+ file3,
25739
25739
  args,
25740
25740
  { env, timeout: Math.max(1, Math.min(7e3, deadline - Date.now())), maxBuffer: 8192, encoding: "utf8", windowsHide: true }
25741
25741
  );
@@ -26503,6 +26503,7 @@ var NATIVE_STATUS_CAPABILITY = "nativeStatusV1";
26503
26503
  var NativeStatusSchema = NativeCapacitySchema.extend({ type: external_exports.literal("nativeStatus"), active: external_exports.number().int().min(0).max(32), queued: external_exports.number().int().min(0).max(256), paused: external_exports.boolean() }).strict().refine((v) => v.active <= v.safeSlots);
26504
26504
  var TerminalEventSchema = external_exports.object({ type: external_exports.literal("executionResult"), protocolVersion: external_exports.literal(1), requestId: uuid11, tenantId: uuid11, deviceId: uuid11, connectionEpoch: epoch2, binding: ExecutionBindingSchema, state: external_exports.enum(["finished", "failed", "cancelled", "unknown", "rejected"]), resultCode: external_exports.string().regex(/^[A-Z0-9_]{1,40}$/), metrics: TerminalMetricsSchema.optional() }).strict();
26505
26505
  var HeldLeasesFrameSchema = external_exports.object({ type: external_exports.literal("heldLeases"), protocolVersion: external_exports.literal(1), connectionEpoch: epoch2, bindings: external_exports.array(ExecutionBindingSchema).min(1).max(64) }).strict();
26506
+ var FullLogStateSchema = external_exports.object({ type: external_exports.literal("fullLogState"), protocolVersion: external_exports.literal(1), connectionEpoch: epoch2, enabled: external_exports.boolean().nullable() }).strict();
26506
26507
  var TerminalEventAckSchema = external_exports.object({ type: external_exports.literal("executionResultAck"), protocolVersion: external_exports.literal(1), requestId: uuid11, ok: external_exports.boolean() }).strict();
26507
26508
  function canonicalJson(value) {
26508
26509
  function canonical2(v) {
@@ -26798,23 +26799,23 @@ var NativeJournal = class _NativeJournal {
26798
26799
  }
26799
26800
  const dir = await safeDirectory(directory), lockPath = path6.join(dir, "journal.lock"), nonce2 = randomBytes4(16).toString("hex");
26800
26801
  const guard = options.lockHelper ? await acquirePosixJournalGuard(dir, options.lockHelper) : void 0;
26801
- let file2;
26802
+ let file3;
26802
26803
  try {
26803
- file2 = await open3(lockPath, constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY, 384);
26804
+ file3 = await open3(lockPath, constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY, 384);
26804
26805
  } catch (e) {
26805
26806
  await guard?.close();
26806
26807
  if (e.code === "EEXIST") throw failure2("JOURNAL_LOCKED");
26807
26808
  throw e;
26808
26809
  }
26809
- const journal = new _NativeJournal(dir, box, { path: lockPath, nonce: nonce2, file: file2, guard }, { maxEntries, maxBytes, retentionMs, now: options.now ?? (() => /* @__PURE__ */ new Date()) });
26810
+ const journal = new _NativeJournal(dir, box, { path: lockPath, nonce: nonce2, file: file3, guard }, { maxEntries, maxBytes, retentionMs, now: options.now ?? (() => /* @__PURE__ */ new Date()) });
26810
26811
  try {
26811
- await file2.writeFile(JSON.stringify({ pid: process.pid, nonce: nonce2, createdAt: journal.now().toISOString() }));
26812
- await file2.sync();
26812
+ await file3.writeFile(JSON.stringify({ pid: process.pid, nonce: nonce2, createdAt: journal.now().toISOString() }));
26813
+ await file3.sync();
26813
26814
  await journal.load();
26814
26815
  await journal.loadStart(existed);
26815
26816
  return journal;
26816
26817
  } catch (e) {
26817
- await file2.close().catch(() => {
26818
+ await file3.close().catch(() => {
26818
26819
  });
26819
26820
  try {
26820
26821
  const value = JSON.parse(await readFile3(lockPath, "utf8"));
@@ -27152,7 +27153,7 @@ var NativeJournal = class _NativeJournal {
27152
27153
  * still alive; otherwise, including every entry from an older agent, it stays EXECUTION_UNKNOWN (#194). */
27153
27154
  recoverAfterRestart(liveness) {
27154
27155
  return this.enqueue(async () => {
27155
- let count3 = 0;
27156
+ let count4 = 0;
27156
27157
  const interrupted = [...this.entries.values()].filter((e) => ["accepted", "running"].includes(e.state));
27157
27158
  const pids = [...new Set(interrupted.flatMap((e) => e.supervisors ?? []))];
27158
27159
  const linuxSupervisors = interrupted.flatMap((e) => e.linuxSupervisors ?? []), darwinSupervisors = interrupted.flatMap((e) => e.darwinSupervisors ?? []);
@@ -27185,9 +27186,9 @@ var NativeJournal = class _NativeJournal {
27185
27186
  } });
27186
27187
  }
27187
27188
  await this.persist(e);
27188
- count3++;
27189
+ count4++;
27189
27190
  }
27190
- return count3;
27191
+ return count4;
27191
27192
  });
27192
27193
  }
27193
27194
  eligibleForPruning(entry, cutoff) {
@@ -27195,20 +27196,20 @@ var NativeJournal = class _NativeJournal {
27195
27196
  }
27196
27197
  admissionAvailable() {
27197
27198
  if (this.closed || this.lock.guard && !this.lock.guard.active) return false;
27198
- let count3 = this.entries.size, bytes3 = this.totalBytes;
27199
- if (count3 < this.options.maxEntries && bytes3 + MAX_ENVELOPE <= this.options.maxBytes) return true;
27199
+ let count4 = this.entries.size, bytes3 = this.totalBytes;
27200
+ if (count4 < this.options.maxEntries && bytes3 + MAX_ENVELOPE <= this.options.maxBytes) return true;
27200
27201
  const cutoff = this.now().getTime() - this.options.retentionMs;
27201
27202
  for (const entry of this.entries.values()) {
27202
27203
  if (!this.eligibleForPruning(entry, cutoff)) continue;
27203
- count3--;
27204
+ count4--;
27204
27205
  bytes3 -= this.sizes.get(entry.executionId);
27205
- if (count3 < this.options.maxEntries && bytes3 + MAX_ENVELOPE <= this.options.maxBytes) return true;
27206
+ if (count4 < this.options.maxEntries && bytes3 + MAX_ENVELOPE <= this.options.maxBytes) return true;
27206
27207
  }
27207
27208
  return false;
27208
27209
  }
27209
27210
  // Called only inside the serialized queue; enqueueing prune here would deadlock.
27210
27211
  async pruneEligible() {
27211
- let count3 = 0;
27212
+ let count4 = 0;
27212
27213
  const cutoff = this.now().getTime() - this.options.retentionMs;
27213
27214
  for (const e of [...this.entries.values()]) {
27214
27215
  if (!this.eligibleForPruning(e, cutoff)) continue;
@@ -27218,9 +27219,9 @@ var NativeJournal = class _NativeJournal {
27218
27219
  this.entries.delete(e.executionId);
27219
27220
  this.sizes.delete(e.executionId);
27220
27221
  this.digests.delete(e.executionId);
27221
- count3++;
27222
+ count4++;
27222
27223
  }
27223
- return count3;
27224
+ return count4;
27224
27225
  }
27225
27226
  prune() {
27226
27227
  return this.enqueue(() => this.pruneEligible());
@@ -28781,9 +28782,9 @@ function resolveWindowsLauncher(commandName, env = process.env) {
28781
28782
  const dir = entry.trim().replace(/^"(.*)"$/, "$1");
28782
28783
  if (!path11.win32.isAbsolute(dir)) continue;
28783
28784
  for (const ext of extensions) {
28784
- const file2 = path11.win32.join(dir, commandName + ext);
28785
+ const file3 = path11.win32.join(dir, commandName + ext);
28785
28786
  try {
28786
- if (statSync(file2).isFile()) return { file: file2, shell: ext === ".bat" || ext === ".cmd" };
28787
+ if (statSync(file3).isFile()) return { file: file3, shell: ext === ".bat" || ext === ".cmd" };
28787
28788
  } catch {
28788
28789
  }
28789
28790
  }
@@ -28804,8 +28805,8 @@ var Entry = external_exports.strictObject({
28804
28805
  });
28805
28806
  var State = external_exports.strictObject({ version: external_exports.literal(1), platform: external_exports.string().max(16), entries: external_exports.array(Entry).max(32) });
28806
28807
  var HostMemory = class {
28807
- constructor(file2, allowed, programs) {
28808
- this.file = file2;
28808
+ constructor(file3, allowed, programs) {
28809
+ this.file = file3;
28809
28810
  this.allowed = allowed;
28810
28811
  this.programs = programs;
28811
28812
  }
@@ -28845,9 +28846,9 @@ var HostMemory = class {
28845
28846
  else if (!this.programs && !available) available = (process.env.PATH ?? "").split(path12.delimiter).some((dir) => {
28846
28847
  if (!path12.isAbsolute(dir)) return false;
28847
28848
  try {
28848
- const file2 = path12.join(dir, command);
28849
- accessSync(file2, constants5.X_OK);
28850
- return statSync2(file2).isFile();
28849
+ const file3 = path12.join(dir, command);
28850
+ accessSync(file3, constants5.X_OK);
28851
+ return statSync2(file3).isFile();
28851
28852
  } catch {
28852
28853
  return false;
28853
28854
  }
@@ -28907,13 +28908,13 @@ var HostMemory = class {
28907
28908
  await mkdir5(directory2, { recursive: true, mode: 448 });
28908
28909
  const stat2 = await lstat5(directory2);
28909
28910
  if (!stat2.isDirectory() || stat2.isSymbolicLink()) throw Error("HOST_MEMORY_DIRECTORY_INVALID");
28910
- const file2 = await open5(temp, "wx", 384);
28911
+ const file3 = await open5(temp, "wx", 384);
28911
28912
  try {
28912
- await file2.writeFile(encoded);
28913
- await file2.close();
28913
+ await file3.writeFile(encoded);
28914
+ await file3.close();
28914
28915
  await rename3(temp, this.file);
28915
28916
  } finally {
28916
- await file2.close().catch(() => {
28917
+ await file3.close().catch(() => {
28917
28918
  });
28918
28919
  await rm4(temp, { force: true }).catch(() => {
28919
28920
  });
@@ -29140,11 +29141,11 @@ var PathGuard = class _PathGuard {
29140
29141
  // src/windows-file-read.ts
29141
29142
  import { execFile as execFile3 } from "node:child_process";
29142
29143
  import path14 from "node:path";
29143
- function readWindowsFile(bridge, file2, maxBytes, signal) {
29144
- return invokeRead(bridge, file2, maxBytes, false, signal);
29144
+ function readWindowsFile(bridge, file3, maxBytes, signal) {
29145
+ return invokeRead(bridge, file3, maxBytes, false, signal);
29145
29146
  }
29146
- async function readWindowsFilePrefix(bridge, file2, maxBytes, signal) {
29147
- const output2 = await invokeRead(bridge, file2, maxBytes, true, signal);
29147
+ async function readWindowsFilePrefix(bridge, file3, maxBytes, signal) {
29148
+ const output2 = await invokeRead(bridge, file3, maxBytes, true, signal);
29148
29149
  try {
29149
29150
  const value = JSON.parse(output2.toString("utf8"));
29150
29151
  if (!value || Object.keys(value).length !== 4 || typeof value.data !== "string" || !Number.isSafeInteger(value.size) || value.size < 0 || typeof value.modifiedAt !== "string" || new Date(value.modifiedAt).toISOString() !== value.modifiedAt || value.truncated !== value.size > maxBytes) throw Error();
@@ -29157,7 +29158,7 @@ async function readWindowsFilePrefix(bridge, file2, maxBytes, signal) {
29157
29158
  }
29158
29159
  function readWindowsFiles(bridge, files, maxBytes, maxTotalBytes, signal) {
29159
29160
  const input2 = JSON.stringify({ paths: files });
29160
- if (process.platform !== "win32" || !path14.isAbsolute(bridge) || files.length < 1 || files.length > 64 || files.some((file2) => !path14.isAbsolute(file2)) || Buffer.byteLength(input2) > 3e5 || !Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 1048576 || !Number.isSafeInteger(maxTotalBytes) || maxTotalBytes < 1 || maxTotalBytes > 16777216) {
29161
+ if (process.platform !== "win32" || !path14.isAbsolute(bridge) || files.length < 1 || files.length > 64 || files.some((file3) => !path14.isAbsolute(file3)) || Buffer.byteLength(input2) > 3e5 || !Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 1048576 || !Number.isSafeInteger(maxTotalBytes) || maxTotalBytes < 1 || maxTotalBytes > 16777216) {
29161
29162
  return Promise.reject(new Error("FILE_READ_ARGUMENT_INVALID"));
29162
29163
  }
29163
29164
  if (signal?.aborted) return Promise.reject(new Error("CANCELLED"));
@@ -29194,8 +29195,8 @@ function readWindowsFiles(bridge, files, maxBytes, maxTotalBytes, signal) {
29194
29195
  child.stdin.end(input2);
29195
29196
  });
29196
29197
  }
29197
- function invokeRead(bridge, file2, maxBytes, prefix, signal) {
29198
- if (process.platform !== "win32" || !path14.isAbsolute(bridge) || !path14.isAbsolute(file2) || !Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > (prefix ? 16777216 : 1048576)) {
29198
+ function invokeRead(bridge, file3, maxBytes, prefix, signal) {
29199
+ if (process.platform !== "win32" || !path14.isAbsolute(bridge) || !path14.isAbsolute(file3) || !Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > (prefix ? 16777216 : 1048576)) {
29199
29200
  return Promise.reject(new Error("FILE_READ_ARGUMENT_INVALID"));
29200
29201
  }
29201
29202
  if (signal?.aborted) return Promise.reject(new Error("CANCELLED"));
@@ -29218,7 +29219,7 @@ function invokeRead(bridge, file2, maxBytes, prefix, signal) {
29218
29219
  });
29219
29220
  child.stdin.on("error", () => {
29220
29221
  });
29221
- child.stdin.end(JSON.stringify({ path: file2 }));
29222
+ child.stdin.end(JSON.stringify({ path: file3 }));
29222
29223
  });
29223
29224
  }
29224
29225
 
@@ -29558,11 +29559,11 @@ async function portalScreenshot(socket, uid, token, signal) {
29558
29559
  signal.addEventListener("abort", abort, { once: true });
29559
29560
  connection.on("error", fail7);
29560
29561
  connection.on("close", () => fail7(Error("CLOSED")));
29561
- const call = (destination, path30, iface, member, signature = "", body = () => {
29562
+ const call = (destination, path32, iface, member, signature = "", body = () => {
29562
29563
  }) => new Promise((done, failed) => {
29563
29564
  const payload2 = new Writer();
29564
29565
  body(payload2);
29565
- const header = new Writer(), fields = [[1, "o", path30], [2, "s", iface], [3, "s", member], [6, "s", destination]];
29566
+ const header = new Writer(), fields = [[1, "o", path32], [2, "s", iface], [3, "s", member], [6, "s", destination]];
29566
29567
  if (signature) fields.push([8, "g", signature]);
29567
29568
  header.byte(108);
29568
29569
  header.byte(1);
@@ -29745,8 +29746,8 @@ function downscale(image, edge) {
29745
29746
  sums[x * 3 + 2] = sums[x * 3 + 2] + image.rgb[i + 2];
29746
29747
  }
29747
29748
  for (let x = 0; x < width; x++) {
29748
- const count3 = (ys[y + 1] - ys[y]) * (xs[x + 1] - xs[x]);
29749
- for (let c = 0; c < 3; c++) rgb[(y * width + x) * 3 + c] = Math.round(sums[x * 3 + c] / count3);
29749
+ const count4 = (ys[y + 1] - ys[y]) * (xs[x + 1] - xs[x]);
29750
+ for (let c = 0; c < 3; c++) rgb[(y * width + x) * 3 + c] = Math.round(sums[x * 3 + c] / count4);
29750
29751
  }
29751
29752
  }
29752
29753
  return { width, height, rgb };
@@ -30222,8 +30223,8 @@ var HUFFMAN = [
30222
30223
  var CODES = HUFFMAN.map(([, counts, values]) => {
30223
30224
  const table2 = [];
30224
30225
  let code = 0, at = 0;
30225
- counts.forEach((count3, index) => {
30226
- for (let i = 0; i < count3; i++) table2[values[at++]] = [code++, index + 1];
30226
+ counts.forEach((count4, index) => {
30227
+ for (let i = 0; i < count4; i++) table2[values[at++]] = [code++, index + 1];
30227
30228
  code <<= 1;
30228
30229
  });
30229
30230
  return table2;
@@ -30407,10 +30408,10 @@ function jpegSize(data) {
30407
30408
  }
30408
30409
  return null;
30409
30410
  }
30410
- function run(file2, args, signal, maxBuffer = 65536, env = buildChildEnvironment(process.env, process.platform)) {
30411
+ function run(file3, args, signal, maxBuffer = 65536, env = buildChildEnvironment(process.env, process.platform)) {
30411
30412
  return new Promise((resolve, reject) => {
30412
30413
  execFile4(
30413
- file2,
30414
+ file3,
30414
30415
  args,
30415
30416
  { encoding: "buffer", timeout: 15e3, maxBuffer, windowsHide: true, shell: false, env, signal },
30416
30417
  (error62, stdout, stderr) => error62 ? reject(Object.assign(error62, { stdout, stderr })) : resolve({ stdout, stderr })
@@ -30482,10 +30483,10 @@ var SESSION_VALUE = /^[A-Za-z0-9_.:,;=@+/-]{1,256}$/;
30482
30483
  var LINUX_SOURCE_BYTES = 150994944;
30483
30484
  async function linuxTool(name2) {
30484
30485
  for (const directory of ["/usr/bin", "/bin", "/usr/local/bin"]) {
30485
- const file2 = path17.posix.join(directory, name2);
30486
+ const file3 = path17.posix.join(directory, name2);
30486
30487
  try {
30487
- await access3(file2, constants7.X_OK);
30488
- return file2;
30488
+ await access3(file3, constants7.X_OK);
30489
+ return file3;
30489
30490
  } catch {
30490
30491
  }
30491
30492
  }
@@ -30530,8 +30531,8 @@ async function linuxSession(signal) {
30530
30531
  }
30531
30532
  }
30532
30533
  if (session.DISPLAY && !session.XAUTHORITY) {
30533
- const file2 = path17.posix.join(os4.homedir(), ".Xauthority");
30534
- if ((await lstat7(file2).catch(() => null))?.isFile()) take("XAUTHORITY", file2);
30534
+ const file3 = path17.posix.join(os4.homedir(), ".Xauthority");
30535
+ if ((await lstat7(file3).catch(() => null))?.isFile()) take("XAUTHORITY", file3);
30535
30536
  }
30536
30537
  if (session.XDG_RUNTIME_DIR) take("DBUS_SESSION_BUS_ADDRESS", "unix:path=" + session.XDG_RUNTIME_DIR + "/bus");
30537
30538
  const wayland = !!session.WAYLAND_DISPLAY || session.XDG_SESSION_TYPE === "wayland";
@@ -30554,13 +30555,13 @@ async function portalCapture(socket, signal) {
30554
30555
  const { code, uri } = answer;
30555
30556
  if (code === 1) throw new ScreenCaptureError("SCREEN_RECORDING_PERMISSION_REQUIRED");
30556
30557
  if (code !== 0 || !uri?.startsWith("file://")) throw new ScreenCaptureError("SCREEN_UNAVAILABLE");
30557
- const file2 = decodeURIComponent(new URL(uri).pathname), info = await lstat7(file2);
30558
+ const file3 = decodeURIComponent(new URL(uri).pathname), info = await lstat7(file3);
30558
30559
  const fresh = info.isFile() && info.uid === uid && info.mtimeMs >= started - 5e3;
30559
30560
  try {
30560
30561
  if (!fresh || info.size > LINUX_SOURCE_BYTES) throw new ScreenCaptureError("SCREEN_UNAVAILABLE");
30561
- return await readFile6(file2);
30562
+ return await readFile6(file3);
30562
30563
  } finally {
30563
- if (fresh) await unlink2(file2).catch(() => {
30564
+ if (fresh) await unlink2(file3).catch(() => {
30564
30565
  });
30565
30566
  }
30566
30567
  }
@@ -30643,16 +30644,16 @@ function result(body) {
30643
30644
  function stopped(signal) {
30644
30645
  if (signal.aborted) fail3("CANCELLED");
30645
30646
  }
30646
- async function readBoundedFile(file2, maxBytes, bridge, signal) {
30647
- const stat2 = await lstat8(file2);
30647
+ async function readBoundedFile(file3, maxBytes, bridge, signal) {
30648
+ const stat2 = await lstat8(file3);
30648
30649
  if (!stat2.isFile() || stat2.isSymbolicLink() || stat2.size > maxBytes) fail3("FILE_UNSUPPORTED_OR_TOO_LARGE");
30649
30650
  if (process.platform === "win32") {
30650
- if (maxBytes <= 1048576 || stat2.size <= 1048576) return readWindowsFile(bridge, file2, Math.min(maxBytes, 1048576), signal);
30651
- const read = await readWindowsFilePrefix(bridge, file2, maxBytes, signal);
30651
+ if (maxBytes <= 1048576 || stat2.size <= 1048576) return readWindowsFile(bridge, file3, Math.min(maxBytes, 1048576), signal);
30652
+ const read = await readWindowsFilePrefix(bridge, file3, maxBytes, signal);
30652
30653
  if (read.truncated) fail3("FILE_UNSUPPORTED_OR_TOO_LARGE");
30653
30654
  return read.data;
30654
30655
  }
30655
- const handle = await open6(file2, constants8.O_RDONLY | (constants8.O_NOFOLLOW ?? 0));
30656
+ const handle = await open6(file3, constants8.O_RDONLY | (constants8.O_NOFOLLOW ?? 0));
30656
30657
  try {
30657
30658
  const current2 = await handle.stat();
30658
30659
  if (!current2.isFile() || current2.size > maxBytes) fail3("FILE_UNSUPPORTED_OR_TOO_LARGE");
@@ -30708,9 +30709,9 @@ var NativeTools = class {
30708
30709
  }
30709
30710
  options;
30710
30711
  memory;
30711
- async readFile(file2, maxBytes, signal) {
30712
+ async readFile(file3, maxBytes, signal) {
30712
30713
  try {
30713
- return await readBoundedFile(file2, maxBytes, this.options.ownerBridgePath ?? path18.join(path18.dirname(this.options.helperPath), "OwnerBridge.exe"), signal);
30714
+ return await readBoundedFile(file3, maxBytes, this.options.ownerBridgePath ?? path18.join(path18.dirname(this.options.helperPath), "OwnerBridge.exe"), signal);
30714
30715
  } catch (error62) {
30715
30716
  if (error62.code === "ENOENT") throw error62;
30716
30717
  if (error62 instanceof Error && /^[A-Z_]{1,40}$/.test(error62.message)) fail3(error62.message);
@@ -31093,16 +31094,16 @@ var NativeTools = class {
31093
31094
  if (value) selectedHeaders[name2] = value.slice(0, 2048);
31094
31095
  }
31095
31096
  const reader = response.body?.getReader(), chunks = [];
31096
- let count3 = 0, truncated = false;
31097
+ let count4 = 0, truncated = false;
31097
31098
  try {
31098
31099
  if (reader) for (; ; ) {
31099
31100
  const part = await reader.read();
31100
31101
  if (part.done) break;
31101
31102
  const b = Buffer.from(part.value);
31102
- const take = Math.min(b.length, 1e5 - count3);
31103
+ const take = Math.min(b.length, 1e5 - count4);
31103
31104
  chunks.push(b.subarray(0, take));
31104
- count3 += take;
31105
- if (take !== b.length || count3 >= 1e5) {
31105
+ count4 += take;
31106
+ if (take !== b.length || count4 >= 1e5) {
31106
31107
  truncated = true;
31107
31108
  break;
31108
31109
  }
@@ -31144,8 +31145,8 @@ var NativeTools = class {
31144
31145
  else if (call.name === "git_diff") {
31145
31146
  argv = ["diff", "--no-ext-diff", "--no-textconv", ...call.args.staged ? ["--cached"] : []];
31146
31147
  if (call.args.file) {
31147
- const file2 = await resolve(path18.resolve(cwd, call.args.file));
31148
- const relative = path18.relative(cwd, file2);
31148
+ const file3 = await resolve(path18.resolve(cwd, call.args.file));
31149
+ const relative = path18.relative(cwd, file3);
31149
31150
  if (relative.startsWith(".." + path18.sep) || relative === ".." || path18.isAbsolute(relative)) fail3("PATH_NOT_ALLOWED");
31150
31151
  argv.push("--", relative);
31151
31152
  } else argv.push("--stat");
@@ -31177,9 +31178,9 @@ var NativeTools = class {
31177
31178
  }
31178
31179
  const contextFile = async (relative, limit, optional2 = false) => {
31179
31180
  try {
31180
- const file2 = await guard.resolveExisting(path18.join(primary, relative));
31181
- guard.assertSafeFile(file2);
31182
- return utf8(await this.readFile(file2, limit, signal));
31181
+ const file3 = await guard.resolveExisting(path18.join(primary, relative));
31182
+ guard.assertSafeFile(file3);
31183
+ return utf8(await this.readFile(file3, limit, signal));
31183
31184
  } catch (error62) {
31184
31185
  if (optional2 && error62.code === "ENOENT") return null;
31185
31186
  throw error62;
@@ -31656,11 +31657,11 @@ function parseNodeTapShadow(input2) {
31656
31657
  return passThrough(input2, "unrecognized_record", true, notices);
31657
31658
  }
31658
31659
  if (line === "") continue;
31659
- const count3 = SUMMARY_COUNT.exec(line);
31660
- if (count3) {
31661
- const key = count3[1];
31660
+ const count4 = SUMMARY_COUNT.exec(line);
31661
+ if (count4) {
31662
+ const key = count4[1];
31662
31663
  if (counts.has(key)) return passThrough(input2, "summary_inconsistent", true, notices);
31663
- counts.set(key, Number(count3[2]));
31664
+ counts.set(key, Number(count4[2]));
31664
31665
  continue;
31665
31666
  }
31666
31667
  const summaryDuration = SUMMARY_DURATION.exec(line);
@@ -31774,11 +31775,11 @@ function parseNodeTapFailureShadow(input2) {
31774
31775
  let durationMs = null;
31775
31776
  for (const line of lines.slice(index + 1)) {
31776
31777
  if (!line) continue;
31777
- const count3 = SUMMARY_COUNT.exec(line);
31778
- if (count3) {
31779
- const key = count3[1];
31778
+ const count4 = SUMMARY_COUNT.exec(line);
31779
+ if (count4) {
31780
+ const key = count4[1];
31780
31781
  if (counts.has(key)) return fallback("summary_inconsistent");
31781
- counts.set(key, Number(count3[2]));
31782
+ counts.set(key, Number(count4[2]));
31782
31783
  } else {
31783
31784
  const duration3 = SUMMARY_DURATION.exec(line);
31784
31785
  if (duration3) {
@@ -31872,7 +31873,7 @@ function shapeCommandResultForAgentDetailed(input2, result2) {
31872
31873
  if (parsed.state !== "candidate" && result2.exitCode === 0 && !result2.stdoutTruncated && !result2.stderrTruncated && result2.stderr === "") {
31873
31874
  const compact = compactJsonOutput(result2.stdout);
31874
31875
  if (compact !== null) {
31875
- const sent = bytes(compact), saved = originalBytes - sent;
31876
+ const sent = bytes(compact), saved2 = originalBytes - sent;
31876
31877
  return Object.freeze({ result: Object.freeze({ ...result2, stdout: compact }), telemetry: Object.freeze({
31877
31878
  parserId: "json-whitespace",
31878
31879
  parserVersion: "1",
@@ -31881,8 +31882,8 @@ function shapeCommandResultForAgentDetailed(input2, result2) {
31881
31882
  reason: "validated_compact",
31882
31883
  originalStdoutBytes: originalBytes,
31883
31884
  sentStdoutBytes: sent,
31884
- savedStdoutBytes: saved,
31885
- reductionPercent: originalBytes === 0 ? 0 : saved / originalBytes * 100
31885
+ savedStdoutBytes: saved2,
31886
+ reductionPercent: originalBytes === 0 ? 0 : saved2 / originalBytes * 100
31886
31887
  }) });
31887
31888
  }
31888
31889
  }
@@ -32957,7 +32958,7 @@ var LocalDirectClient = class _LocalDirectClient {
32957
32958
  }
32958
32959
  };
32959
32960
 
32960
- // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
32961
+ // ../../node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
32961
32962
  var __create2 = Object.create;
32962
32963
  var __defProp2 = Object.defineProperty;
32963
32964
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -32997,7 +32998,7 @@ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__
32997
32998
  enumerable: true
32998
32999
  }) : target, mod));
32999
33000
 
33000
- // node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs
33001
+ // ../../node_modules/@modelcontextprotocol/server/dist/dialects-DoSzNhcb.mjs
33001
33002
  var DRAFT_2020_12_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "http://json-schema.org/draft/2020-12/schema"]);
33002
33003
  var DRAFT_2019_09_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2019-09/schema", "http://json-schema.org/draft/2019-09/schema"]);
33003
33004
  var DRAFT_07_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft-07/schema", "http://json-schema.org/draft-07/schema"]);
@@ -33014,7 +33015,7 @@ function declaredDialect(schema, remedy) {
33014
33015
  throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${schema.$schema.slice(0, 200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${remedy}`);
33015
33016
  }
33016
33017
 
33017
- // node_modules/@modelcontextprotocol/core/dist/auth-CGP0BDVq.mjs
33018
+ // ../../node_modules/@modelcontextprotocol/core/dist/auth-CGP0BDVq.mjs
33018
33019
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
33019
33020
  var SUPPORTED_PROTOCOL_VERSIONS = [
33020
33021
  LATEST_PROTOCOL_VERSION,
@@ -33953,7 +33954,7 @@ var OAuthTokenRevocationRequestSchema = object({
33953
33954
  token_type_hint: string2().optional()
33954
33955
  }).strip();
33955
33956
 
33956
- // node_modules/@modelcontextprotocol/server/dist/src-D-y6h4N7.mjs
33957
+ // ../../node_modules/@modelcontextprotocol/server/dist/src-D-y6h4N7.mjs
33957
33958
  var BRANDS = /* @__PURE__ */ Symbol.for("mcp.sdk.errorBrands");
33958
33959
  function stampErrorBrands(instance, ctor) {
33959
33960
  const brands = /* @__PURE__ */ new Set();
@@ -36587,9 +36588,9 @@ var rev2026Codec = {
36587
36588
  });
36588
36589
  const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta3);
36589
36590
  if (!parsed.success) for (const issue2 of parsed.error.issues) {
36590
- const path30 = issue2.path.map(String);
36591
- const key = path30.length > 0 ? path30.join(".") : "_meta";
36592
- if (path30.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing")) continue;
36591
+ const path32 = issue2.path.map(String);
36592
+ const key = path32.length > 0 ? path32.join(".") : "_meta";
36593
+ if (path32.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing")) continue;
36593
36594
  issues.push({
36594
36595
  key,
36595
36596
  problem: issue2.message
@@ -36891,29 +36892,29 @@ var PERMITTED_X_MCP_HEADER_TYPES = /* @__PURE__ */ new Set([
36891
36892
  function scanXMcpHeaderDeclarations(inputSchema) {
36892
36893
  const declarations = [];
36893
36894
  const seenLower = /* @__PURE__ */ new Map();
36894
- const visit2 = (node2, path30, reachable) => {
36895
+ const visit2 = (node2, path32, reachable) => {
36895
36896
  if (node2 === null || typeof node2 !== "object") return void 0;
36896
36897
  const schema = node2;
36897
36898
  if (X_MCP_HEADER_KEY in schema) {
36898
- if (!reachable || path30.length === 0) return `${pathName(path30)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;
36899
+ if (!reachable || path32.length === 0) return `${pathName(path32)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;
36899
36900
  const raw = schema[X_MCP_HEADER_KEY];
36900
- if (typeof raw !== "string" || raw.length === 0) return `${pathName(path30)}: x-mcp-header MUST be a non-empty string`;
36901
- if (!RFC9110_TOKEN.test(raw)) return `${pathName(path30)}: x-mcp-header '${raw}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;
36901
+ if (typeof raw !== "string" || raw.length === 0) return `${pathName(path32)}: x-mcp-header MUST be a non-empty string`;
36902
+ if (!RFC9110_TOKEN.test(raw)) return `${pathName(path32)}: x-mcp-header '${raw}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;
36902
36903
  const type = typeof schema.type === "string" ? schema.type : void 0;
36903
- if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(path30)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${type ?? "<none>"}`;
36904
+ if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(path32)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${type ?? "<none>"}`;
36904
36905
  const lower = raw.toLowerCase();
36905
36906
  const prior = seenLower.get(lower);
36906
36907
  if (prior !== void 0) return `x-mcp-header '${raw}' is not case-insensitively unique (also declared as '${prior}')`;
36907
36908
  seenLower.set(lower, raw);
36908
36909
  declarations.push({
36909
- path: path30,
36910
+ path: path32,
36910
36911
  headerName: raw,
36911
36912
  type
36912
36913
  });
36913
36914
  }
36914
36915
  const properties = schema.properties;
36915
36916
  if (properties !== null && typeof properties === "object") for (const [key, child] of Object.entries(properties)) {
36916
- const fault$1 = visit2(child, [...path30, key], reachable);
36917
+ const fault$1 = visit2(child, [...path32, key], reachable);
36917
36918
  if (fault$1 !== void 0) return fault$1;
36918
36919
  }
36919
36920
  for (const k of NON_REACHABLE_SUBSCHEMA_KEYWORDS) {
@@ -36921,7 +36922,7 @@ function scanXMcpHeaderDeclarations(inputSchema) {
36921
36922
  if (sub === void 0) continue;
36922
36923
  const branches = Array.isArray(sub) ? sub : sub !== null && typeof sub === "object" && OBJECT_VALUED_SUBSCHEMA_KEYWORDS.has(k) ? Object.values(sub) : [sub];
36923
36924
  for (const branch of branches) {
36924
- const fault$1 = visit2(branch, [...path30, `<${k}>`], false);
36925
+ const fault$1 = visit2(branch, [...path32, `<${k}>`], false);
36925
36926
  if (fault$1 !== void 0) return fault$1;
36926
36927
  }
36927
36928
  }
@@ -36961,8 +36962,8 @@ var OBJECT_VALUED_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
36961
36962
  "$defs",
36962
36963
  "definitions"
36963
36964
  ]);
36964
- function pathName(path30) {
36965
- return path30.length === 0 ? "<root>" : path30.join(".");
36965
+ function pathName(path32) {
36966
+ return path32.length === 0 ? "<root>" : path32.join(".");
36966
36967
  }
36967
36968
  var HEADER_MISMATCH_ERROR_CODE = -32020;
36968
36969
  var INBOUND_VALIDATION_LADDER = [
@@ -37212,7 +37213,7 @@ var PROPERTY_KEYS_BY_TYPE = {
37212
37213
  array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
37213
37214
  };
37214
37215
  var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
37215
- function walkProperty(node2, path30, vendor, unsupported) {
37216
+ function walkProperty(node2, path32, vendor, unsupported) {
37216
37217
  if (!isJsonObject(node2)) return node2;
37217
37218
  const allowedKeys = typeof node2.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node2.type) ? PROPERTY_KEYS_BY_TYPE[node2.type] : void 0;
37218
37219
  if (allowedKeys === void 0) return node2;
@@ -37220,8 +37221,8 @@ function walkProperty(node2, path30, vendor, unsupported) {
37220
37221
  for (const [key, value] of Object.entries(node2)) if (allowedKeys.has(key) || isAnnotationOnlyJsonSchemaKeyword(key)) pruned[key] = value;
37221
37222
  else if (key === "pattern" && node2.type === "string" && typeof node2.format === "string") {
37222
37223
  if (!SUPPORTED_STRING_FORMATS.has(node2.format)) pruned[key] = value;
37223
- else if (typeof value !== "string" || !isLibraryFormatPattern(node2.format, value, vendor)) unsupported.push(`${path30}.${key}`);
37224
- } else unsupported.push(`${path30}.${key}`);
37224
+ else if (typeof value !== "string" || !isLibraryFormatPattern(node2.format, value, vendor)) unsupported.push(`${path32}.${key}`);
37225
+ } else unsupported.push(`${path32}.${key}`);
37225
37226
  return pruned;
37226
37227
  }
37227
37228
  function walkRequestedSchema(converted, vendor) {
@@ -37238,11 +37239,11 @@ function describeUnsupportedProperties(pruned, fallback) {
37238
37239
  const offenders = Object.entries(pruned.properties).filter(([, node2]) => !parseSchema(PrimitiveSchemaDefinitionSchema, node2).success).map(([name2]) => `properties.${name2}`);
37239
37240
  return offenders.length > 0 ? offenders.join(", ") : fallback;
37240
37241
  }
37241
- function findDroppedConstraintPaths(original, parsed, path30 = "") {
37242
- if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path30}[${index}]`));
37242
+ function findDroppedConstraintPaths(original, parsed, path32 = "") {
37243
+ if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path32}[${index}]`));
37243
37244
  if (!isJsonObject(original) || !isJsonObject(parsed)) return [];
37244
37245
  return Object.entries(original).flatMap(([key, value]) => {
37245
- const childPath = path30 ? `${path30}.${key}` : key;
37246
+ const childPath = path32 ? `${path32}.${key}` : key;
37246
37247
  if (!Object.prototype.hasOwnProperty.call(parsed, key)) return isAnnotationOnlyJsonSchemaKeyword(key) ? [] : [childPath];
37247
37248
  return findDroppedConstraintPaths(value, parsed[key], childPath);
37248
37249
  });
@@ -38534,7 +38535,7 @@ function normalizeRawShapeSchema(schema) {
38534
38535
  return schema;
38535
38536
  }
38536
38537
 
38537
- // node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs
38538
+ // ../../node_modules/@modelcontextprotocol/server/dist/ajvProvider-CEoC__sr.mjs
38538
38539
  var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
38539
38540
  Object.defineProperty(exports, "__esModule", { value: true });
38540
38541
  exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
@@ -40472,15 +40473,15 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
40472
40473
  return false;
40473
40474
  }
40474
40475
  function countKeys(schema) {
40475
- let count3 = 0;
40476
+ let count4 = 0;
40476
40477
  for (const key in schema) {
40477
40478
  if (key === "$ref") return Infinity;
40478
- count3++;
40479
+ count4++;
40479
40480
  if (SIMPLE_INLINED.has(key)) continue;
40480
- if (typeof schema[key] == "object") (0, util_1.eachItem)(schema[key], (sch) => count3 += countKeys(sch));
40481
- if (count3 === Infinity) return Infinity;
40481
+ if (typeof schema[key] == "object") (0, util_1.eachItem)(schema[key], (sch) => count4 += countKeys(sch));
40482
+ if (count4 === Infinity) return Infinity;
40482
40483
  }
40483
- return count3;
40484
+ return count4;
40484
40485
  }
40485
40486
  function getFullPath(resolver, id2 = "", normalize) {
40486
40487
  if (normalize !== false) id2 = normalizeId(id2);
@@ -41318,8 +41319,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41318
41319
  for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
41319
41320
  return ind;
41320
41321
  }
41321
- function removeDotSegments(path30) {
41322
- let input2 = path30;
41322
+ function removeDotSegments(path32) {
41323
+ let input2 = path32;
41323
41324
  const output2 = [];
41324
41325
  let nextSlash = -1;
41325
41326
  let len = 0;
@@ -41472,8 +41473,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41472
41473
  wsComponent.secure = void 0;
41473
41474
  }
41474
41475
  if (wsComponent.resourceName) {
41475
- const [path30, query] = wsComponent.resourceName.split("?");
41476
- wsComponent.path = path30 && path30 !== "/" ? path30 : void 0;
41476
+ const [path32, query] = wsComponent.resourceName.split("?");
41477
+ wsComponent.path = path32 && path32 !== "/" ? path32 : void 0;
41477
41478
  wsComponent.query = query;
41478
41479
  wsComponent.resourceName = void 0;
41479
41480
  }
@@ -43080,8 +43081,8 @@ var require_contains = /* @__PURE__ */ __commonJSMin(((exports) => {
43080
43081
  cxt.result(valid, () => cxt.reset());
43081
43082
  function validateItemsWithCount() {
43082
43083
  const schValid = gen.name("_valid");
43083
- const count3 = gen.let("count", 0);
43084
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count3)));
43084
+ const count4 = gen.let("count", 0);
43085
+ validateItems(schValid, () => gen.if(schValid, () => checkLimits(count4)));
43085
43086
  }
43086
43087
  function validateItems(_valid, block) {
43087
43088
  gen.forRange("i", 0, len, (i) => {
@@ -43094,13 +43095,13 @@ var require_contains = /* @__PURE__ */ __commonJSMin(((exports) => {
43094
43095
  block();
43095
43096
  });
43096
43097
  }
43097
- function checkLimits(count3) {
43098
- gen.code((0, codegen_1._)`${count3}++`);
43099
- if (max === void 0) gen.if((0, codegen_1._)`${count3} >= ${min}`, () => gen.assign(valid, true).break());
43098
+ function checkLimits(count4) {
43099
+ gen.code((0, codegen_1._)`${count4}++`);
43100
+ if (max === void 0) gen.if((0, codegen_1._)`${count4} >= ${min}`, () => gen.assign(valid, true).break());
43100
43101
  else {
43101
- gen.if((0, codegen_1._)`${count3} > ${max}`, () => gen.assign(valid, false).break());
43102
+ gen.if((0, codegen_1._)`${count4} > ${max}`, () => gen.assign(valid, false).break());
43102
43103
  if (min === 1) gen.assign(valid, true);
43103
- else gen.if((0, codegen_1._)`${count3} >= ${min}`, () => gen.assign(valid, true));
43104
+ else gen.if((0, codegen_1._)`${count4} >= ${min}`, () => gen.assign(valid, true));
43104
43105
  }
43105
43106
  }
43106
43107
  }
@@ -45544,10 +45545,10 @@ var AjvJsonSchemaValidator = class {
45544
45545
  };
45545
45546
  var Ajv = import_ajv.Ajv;
45546
45547
 
45547
- // node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs
45548
+ // ../../node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs
45548
45549
  import process2 from "node:process";
45549
45550
 
45550
- // node_modules/@modelcontextprotocol/server/dist/mcp-Dw2OlZ1f.mjs
45551
+ // ../../node_modules/@modelcontextprotocol/server/dist/mcp-Dw2OlZ1f.mjs
45551
45552
  var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
45552
45553
  function isCompletable(schema) {
45553
45554
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
@@ -46923,10 +46924,10 @@ function unwrapOptionalSchema(schema) {
46923
46924
  return schema.def?.innerType ?? schema;
46924
46925
  }
46925
46926
 
46926
- // node_modules/@modelcontextprotocol/server/dist/index.mjs
46927
+ // ../../node_modules/@modelcontextprotocol/server/dist/index.mjs
46927
46928
  var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
46928
46929
 
46929
- // node_modules/@modelcontextprotocol/server/dist/stdio.mjs
46930
+ // ../../node_modules/@modelcontextprotocol/server/dist/stdio.mjs
46930
46931
  var swallowsErrorsAfterClose = /* @__PURE__ */ Symbol("swallowsErrorsAfterClose");
46931
46932
  var StdioServerTransport = class {
46932
46933
  _readBuffer;
@@ -47275,6 +47276,42 @@ var NativeIncidentProducer = class {
47275
47276
  }
47276
47277
  };
47277
47278
 
47279
+ // packages/contracts/src/token-usage-protocol.ts
47280
+ var TOKEN_USAGE_CAPABILITY = "tokenUsageV1";
47281
+ var uuid20 = external_exports.string().uuid().toLowerCase();
47282
+ var epoch3 = external_exports.string().refine((v) => /^[1-9]\d{0,18}$/.test(v) && BigInt(v) <= 9223372036854775807n);
47283
+ var tokens = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
47284
+ var TokenUsageClientSchema = external_exports.enum(["claude-code", "codex"]);
47285
+ var TOKEN_USAGE_MODEL = /^[A-Za-z0-9][A-Za-z0-9._:/@+-]{0,79}$/;
47286
+ var TokenUsageRowSchema = external_exports.object({
47287
+ day: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine((v) => Number.isFinite(Date.parse(v + "T00:00:00Z"))),
47288
+ client: TokenUsageClientSchema,
47289
+ model: external_exports.string().regex(TOKEN_USAGE_MODEL),
47290
+ requests: tokens,
47291
+ inputTokens: tokens,
47292
+ cachedInputTokens: tokens,
47293
+ cacheWriteTokens: tokens,
47294
+ outputTokens: tokens,
47295
+ reasoningTokens: tokens.nullable()
47296
+ }).strict().refine((row) => row.cachedInputTokens + row.cacheWriteTokens <= row.inputTokens && (row.reasoningTokens === null || row.reasoningTokens <= row.outputTokens), "Subset exceeds total");
47297
+ var TokenUsageBatchSchema = external_exports.object({
47298
+ type: external_exports.literal("tokenUsageBatch"),
47299
+ protocolVersion: external_exports.literal(1),
47300
+ batchId: uuid20,
47301
+ connectionEpoch: epoch3,
47302
+ /** Random per agent state; a new state counts only usage after it started, so states never overlap. */
47303
+ stateId: uuid20,
47304
+ rows: external_exports.array(TokenUsageRowSchema).min(1).max(64)
47305
+ }).strict().refine((batch) => new Set(batch.rows.map((r) => `${r.day}|${r.client}|${r.model}`)).size === batch.rows.length, "Duplicate rows");
47306
+ var TokenUsageBatchResultSchema = external_exports.enum(["accepted", "invalid", "stale", "disabled", "retry", "busy"]);
47307
+ var TokenUsageBatchAckSchema = external_exports.object({
47308
+ type: external_exports.literal("tokenUsageBatchAck"),
47309
+ protocolVersion: external_exports.literal(1),
47310
+ batchId: uuid20.optional(),
47311
+ result: TokenUsageBatchResultSchema
47312
+ }).strict();
47313
+ var TokenUsageStateSchema = external_exports.object({ type: external_exports.literal("tokenUsageState"), protocolVersion: external_exports.literal(1), connectionEpoch: epoch3, enabled: external_exports.boolean() }).strict();
47314
+
47278
47315
  // agent/src/relay-client.ts
47279
47316
  var RelayClientError = class extends Error {
47280
47317
  constructor(code) {
@@ -47310,7 +47347,7 @@ function relayUrlFromEnrollment(enrollment) {
47310
47347
  url2.pathname = "/api/agent/relay";
47311
47348
  return url2.toString();
47312
47349
  }
47313
- function uuid20(value, code) {
47350
+ function uuid21(value, code) {
47314
47351
  if (typeof value !== "string" || !UUID2.test(value)) fail5(code);
47315
47352
  return value.toLowerCase();
47316
47353
  }
@@ -47318,7 +47355,7 @@ function protocol(value, expected) {
47318
47355
  if (value !== expected) fail5("RELAY_PROTOCOL_INVALID");
47319
47356
  return expected;
47320
47357
  }
47321
- function epoch3(value) {
47358
+ function epoch4(value) {
47322
47359
  if (typeof value !== "string" || !EPOCH.test(value) || BigInt(value) > 9223372036854775807n) fail5("RELAY_EPOCH_INVALID");
47323
47360
  return value;
47324
47361
  }
@@ -47440,11 +47477,11 @@ function sendJson(socket, value, maxBytes) {
47440
47477
  function validateChallenge(frame, expectedProtocol) {
47441
47478
  if (frame.type !== "challenge") fail5("RELAY_HANDSHAKE_INVALID");
47442
47479
  protocol(frame.protocolVersion, expectedProtocol);
47443
- uuid20(frame.gatewayId, "RELAY_HANDSHAKE_INVALID");
47480
+ uuid21(frame.gatewayId, "RELAY_HANDSHAKE_INVALID");
47444
47481
  if (typeof frame.nonce !== "string" || frame.nonce.length < 32 || frame.nonce.length > 512 || /[\u0000-\u001f\u007f]/u.test(frame.nonce)) fail5("RELAY_HANDSHAKE_INVALID");
47445
47482
  if (typeof frame.expiresAt !== "string" || !Number.isFinite(Date.parse(frame.expiresAt)) || Date.parse(frame.expiresAt) <= Date.now()) fail5("RELAY_HANDSHAKE_INVALID");
47446
47483
  return {
47447
- challengeId: uuid20(frame.challengeId, "RELAY_HANDSHAKE_INVALID"),
47484
+ challengeId: uuid21(frame.challengeId, "RELAY_HANDSHAKE_INVALID"),
47448
47485
  nonce: frame.nonce,
47449
47486
  // Older servers offer no capabilities and verify only the v1 proof.
47450
47487
  machineIdentity: Array.isArray(frame.capabilities) && frame.capabilities.includes(MACHINE_IDENTITY_CAPABILITY)
@@ -47453,27 +47490,27 @@ function validateChallenge(frame, expectedProtocol) {
47453
47490
  function validateReady(frame, enrollment, expectedProtocol) {
47454
47491
  if (frame.type !== "connected") fail5("RELAY_HANDSHAKE_INVALID");
47455
47492
  protocol(frame.protocolVersion, expectedProtocol);
47456
- if (uuid20(frame.tenantId, "RELAY_HANDSHAKE_INVALID") !== enrollment.tenantId.toLowerCase()) fail5("RELAY_ID_MISMATCH");
47457
- if (uuid20(frame.deviceId, "RELAY_HANDSHAKE_INVALID") !== enrollment.deviceId.toLowerCase()) fail5("RELAY_ID_MISMATCH");
47493
+ if (uuid21(frame.tenantId, "RELAY_HANDSHAKE_INVALID") !== enrollment.tenantId.toLowerCase()) fail5("RELAY_ID_MISMATCH");
47494
+ if (uuid21(frame.deviceId, "RELAY_HANDSHAKE_INVALID") !== enrollment.deviceId.toLowerCase()) fail5("RELAY_ID_MISMATCH");
47458
47495
  const terminalMetrics2 = Array.isArray(frame.capabilities) && frame.capabilities.includes(TERMINAL_METRICS_CAPABILITY);
47459
- return { connectionEpoch: epoch3(frame.connectionEpoch), terminalMetrics: terminalMetrics2 };
47496
+ return { connectionEpoch: epoch4(frame.connectionEpoch), terminalMetrics: terminalMetrics2 };
47460
47497
  }
47461
47498
  function validateRequest(frame, enrollment, expectedProtocol, connectionEpoch) {
47462
47499
  if (frame.type !== "relayFrame") fail5("RELAY_REQUEST_INVALID");
47463
47500
  protocol(frame.protocolVersion, expectedProtocol);
47464
- const tenantId = uuid20(frame.tenantId, "RELAY_REQUEST_INVALID");
47465
- const deviceId = uuid20(frame.deviceId, "RELAY_REQUEST_INVALID");
47501
+ const tenantId = uuid21(frame.tenantId, "RELAY_REQUEST_INVALID");
47502
+ const deviceId = uuid21(frame.deviceId, "RELAY_REQUEST_INVALID");
47466
47503
  if (tenantId !== enrollment.tenantId.toLowerCase() || deviceId !== enrollment.deviceId.toLowerCase()) fail5("RELAY_ID_MISMATCH");
47467
- if (epoch3(frame.connectionEpoch) !== connectionEpoch) fail5("RELAY_EPOCH_MISMATCH");
47504
+ if (epoch4(frame.connectionEpoch) !== connectionEpoch) fail5("RELAY_EPOCH_MISMATCH");
47468
47505
  const kind = frame.kind;
47469
47506
  if (typeof kind !== "string" || !REQUEST_KINDS.has(kind)) fail5("RELAY_REQUEST_INVALID");
47470
47507
  return {
47471
- requestId: uuid20(frame.requestId, "RELAY_REQUEST_INVALID"),
47508
+ requestId: uuid21(frame.requestId, "RELAY_REQUEST_INVALID"),
47472
47509
  tenantId,
47473
47510
  deviceId,
47474
47511
  connectionEpoch,
47475
- operationId: uuid20(frame.operationId, "RELAY_REQUEST_INVALID"),
47476
- executionId: uuid20(frame.executionId, "RELAY_REQUEST_INVALID"),
47512
+ operationId: uuid21(frame.operationId, "RELAY_REQUEST_INVALID"),
47513
+ executionId: uuid21(frame.executionId, "RELAY_REQUEST_INVALID"),
47477
47514
  kind,
47478
47515
  payload: frame.payload,
47479
47516
  deadlineAt: isoDate(frame.deadlineAt),
@@ -47515,8 +47552,8 @@ async function connectOnce(options) {
47515
47552
  const identity = await options.store.load();
47516
47553
  if (!identity || !identity.enrollment) fail5("ENROLLMENT_MISSING");
47517
47554
  const enrollment = identity.enrollment;
47518
- const tenantId = uuid20(enrollment.tenantId, "ENROLLMENT_INVALID");
47519
- const deviceId = uuid20(enrollment.deviceId, "ENROLLMENT_INVALID");
47555
+ const tenantId = uuid21(enrollment.tenantId, "ENROLLMENT_INVALID");
47556
+ const deviceId = uuid21(enrollment.deviceId, "ENROLLMENT_INVALID");
47520
47557
  const url2 = relayUrlFromEnrollment(enrollment);
47521
47558
  const socket = new wrapper_default(url2, [], {
47522
47559
  followRedirects: false,
@@ -47534,7 +47571,9 @@ async function connectOnce(options) {
47534
47571
  deviceId,
47535
47572
  guardIdentity: true,
47536
47573
  ...options.aiConnectivity ? { aiConnectivity: true } : {},
47537
- ...options.onHeldLeases ? { heldLeases: true } : {}
47574
+ ...options.onHeldLeases ? { heldLeases: true } : {},
47575
+ ...options.onFullLogChoice ? { fullLogNotice: true } : {},
47576
+ ...options.onTokenUsageState ? { tokenUsage: true } : {}
47538
47577
  }, maxFrameBytes);
47539
47578
  const challenge = validateChallenge(await waitForMessage(socket, maxFrameBytes, connectTimeoutMs, "RELAY_HANDSHAKE_TIMEOUT"), protocolVersion2);
47540
47579
  const machine = challenge.machineIdentity ? options.machineIdentity?.(deviceId) ?? null : null;
@@ -47561,6 +47600,7 @@ async function connectOnce(options) {
47561
47600
  const { connectionEpoch, terminalMetrics: terminalMetrics2 } = validateReady(readyFrame, enrollment, protocolVersion2);
47562
47601
  const rejectionResults = Array.isArray(readyFrame.capabilities) && readyFrame.capabilities.includes(REJECTION_RESULT_CAPABILITY);
47563
47602
  const incidents = Array.isArray(readyFrame.capabilities) && readyFrame.capabilities.includes("incidentBatchV1");
47603
+ const tokenUsage = !!options.onTokenUsageState && Array.isArray(readyFrame.capabilities) && readyFrame.capabilities.includes(TOKEN_USAGE_CAPABILITY);
47564
47604
  const monitorHeartbeat = Array.isArray(readyFrame.capabilities) && readyFrame.capabilities.includes("monitorHeartbeatV1") && typeof readyFrame.heartbeatMs === "number" && Number.isInteger(readyFrame.heartbeatMs) && readyFrame.heartbeatMs >= 1e3 && readyFrame.heartbeatMs <= 6e4 ? readyFrame.heartbeatMs : void 0;
47565
47605
  const nativeStatus = Array.isArray(readyFrame.capabilities) && readyFrame.capabilities.includes(NATIVE_STATUS_CAPABILITY) && options.status;
47566
47606
  const accessModes = Array.isArray(readyFrame.capabilities) && readyFrame.capabilities.includes(WORKSPACE_ACCESS_MODE_CAPABILITY);
@@ -47637,6 +47677,37 @@ async function connectOnce(options) {
47637
47677
  void (async () => {
47638
47678
  try {
47639
47679
  const frame = parseFrame(data, maxFrameBytes);
47680
+ if (frame.type === "fullLogState") {
47681
+ const state = FullLogStateSchema.safeParse(frame);
47682
+ if (state.success && state.data.connectionEpoch === connectionEpoch) {
47683
+ try {
47684
+ void Promise.resolve(options.onFullLogChoice?.(state.data.enabled)).catch(() => {
47685
+ });
47686
+ } catch {
47687
+ }
47688
+ }
47689
+ return;
47690
+ }
47691
+ if (frame.type === "tokenUsageState") {
47692
+ const state = TokenUsageStateSchema.safeParse(frame);
47693
+ if (tokenUsage && state.success && state.data.connectionEpoch === connectionEpoch) {
47694
+ try {
47695
+ options.onTokenUsageState?.(state.data.enabled);
47696
+ } catch {
47697
+ }
47698
+ }
47699
+ return;
47700
+ }
47701
+ if (frame.type === "tokenUsageBatchAck") {
47702
+ const ack = TokenUsageBatchAckSchema.safeParse(frame);
47703
+ if (tokenUsage && ack.success) {
47704
+ try {
47705
+ options.onTokenUsageAck?.(ack.data.batchId, ack.data.result);
47706
+ } catch {
47707
+ }
47708
+ }
47709
+ return;
47710
+ }
47640
47711
  if (frame.type === "aiConnectivityRevoked") {
47641
47712
  if (connectivity && frame.protocolVersion === 1 && frame.connectionEpoch === connectionEpoch) notifyConnectivityRevoked();
47642
47713
  return;
@@ -47767,6 +47838,15 @@ async function connectOnce(options) {
47767
47838
  return false;
47768
47839
  }
47769
47840
  } } : {},
47841
+ ...tokenUsage ? { sendTokenUsageBatch: (batch) => {
47842
+ try {
47843
+ if (socket.readyState !== wrapper_default.OPEN) return false;
47844
+ sendJson(socket, TokenUsageBatchSchema.parse({ type: "tokenUsageBatch", protocolVersion: 1, batchId: batch.batchId, connectionEpoch, stateId: batch.stateId, rows: batch.rows }), Math.min(maxFrameBytes, 32768));
47845
+ return true;
47846
+ } catch {
47847
+ return false;
47848
+ }
47849
+ } } : {},
47770
47850
  sendTerminal: (binding2, state, resultCode, metrics) => {
47771
47851
  if (state === "rejected" && !rejectionResults) return Promise.reject(new RelayClientError("RELAY_RESULT_UNSUPPORTED"));
47772
47852
  if (pendingTerminal.size >= 64) return Promise.reject(new RelayClientError("RELAY_PENDING_LIMIT"));
@@ -47985,10 +48065,10 @@ function canonicalOrigin2(value) {
47985
48065
  fail6("ORIGIN_INVALID");
47986
48066
  }
47987
48067
  }
47988
- function endpoint(origin, path30) {
47989
- return origin + path30;
48068
+ function endpoint(origin, path32) {
48069
+ return origin + path32;
47990
48070
  }
47991
- function uuid21(value, code) {
48071
+ function uuid22(value, code) {
47992
48072
  if (typeof value !== "string" || !UUID3.test(value)) fail6(code);
47993
48073
  return value.toLowerCase();
47994
48074
  }
@@ -48108,7 +48188,7 @@ var PairingClient = class {
48108
48188
  publicKey: identity.publicKeyPem,
48109
48189
  agentVersion: this.version
48110
48190
  }));
48111
- const pairingId = uuid21(response.pairingId, "PAIRING_RESPONSE_INVALID");
48191
+ const pairingId = uuid22(response.pairingId, "PAIRING_RESPONSE_INVALID");
48112
48192
  const expiresAt = parseDate(response.expiresAt, "PAIRING_RESPONSE_INVALID");
48113
48193
  const now = this.nowMs();
48114
48194
  if (expiresAt.getTime() <= now || expiresAt.getTime() - now > 30 * 6e4) fail6("PAIRING_RESPONSE_INVALID");
@@ -48142,7 +48222,7 @@ var PairingClient = class {
48142
48222
  }
48143
48223
  async completeOnce(beginResult, approved, displayNameValue) {
48144
48224
  const pairing = this.validateBeginResult(beginResult);
48145
- const tenantId = uuid21(approved.tenantId, "PAIRING_RESPONSE_INVALID");
48225
+ const tenantId = uuid22(approved.tenantId, "PAIRING_RESPONSE_INVALID");
48146
48226
  const email3 = accountEmail(approved.accountEmail);
48147
48227
  const name2 = displayName(displayNameValue);
48148
48228
  const identity = await this.currentIdentity();
@@ -48156,15 +48236,15 @@ var PairingClient = class {
48156
48236
  displayName: name2,
48157
48237
  agentVersion: this.version
48158
48238
  }));
48159
- const completedTenant = uuid21(response.tenantId, "PAIRING_RESPONSE_INVALID");
48239
+ const completedTenant = uuid22(response.tenantId, "PAIRING_RESPONSE_INVALID");
48160
48240
  if (completedTenant !== tenantId) fail6("PAIRING_RESPONSE_INVALID");
48161
- const deviceId = uuid21(response.deviceId, "PAIRING_RESPONSE_INVALID");
48241
+ const deviceId = uuid22(response.deviceId, "PAIRING_RESPONSE_INVALID");
48162
48242
  const enrollment = {
48163
48243
  tenantId,
48164
48244
  deviceId,
48165
48245
  serverOrigin: this.origin,
48166
48246
  accountEmail: email3,
48167
- ...response.accountId !== void 0 ? { accountId: uuid21(response.accountId, "PAIRING_RESPONSE_INVALID") } : {}
48247
+ ...response.accountId !== void 0 ? { accountId: uuid22(response.accountId, "PAIRING_RESPONSE_INVALID") } : {}
48168
48248
  };
48169
48249
  await this.store.saveEnrollment(enrollment);
48170
48250
  return { ...enrollment };
@@ -48178,7 +48258,7 @@ var PairingClient = class {
48178
48258
  state: response.state,
48179
48259
  expiresAt: parseDate(response.expiresAt, "PAIRING_RESPONSE_INVALID")
48180
48260
  };
48181
- if (response.tenantId !== void 0) result2.tenantId = uuid21(response.tenantId, "PAIRING_RESPONSE_INVALID");
48261
+ if (response.tenantId !== void 0) result2.tenantId = uuid22(response.tenantId, "PAIRING_RESPONSE_INVALID");
48182
48262
  if (response.accountEmail !== void 0) result2.accountEmail = accountEmail(response.accountEmail);
48183
48263
  return result2;
48184
48264
  }
@@ -48190,10 +48270,10 @@ var PairingClient = class {
48190
48270
  }
48191
48271
  validateBeginResult(value) {
48192
48272
  return {
48193
- pairingId: uuid21(value.pairingId, "PAIRING_INVALID"),
48273
+ pairingId: uuid22(value.pairingId, "PAIRING_INVALID"),
48194
48274
  pairingSecret: pairingSecret(value.pairingSecret),
48195
48275
  confirmationCode: confirmationCode(value.confirmationCode),
48196
- approvalUrl: approvalUrl(value.approvalUrl, this.origin, uuid21(value.pairingId, "PAIRING_INVALID")),
48276
+ approvalUrl: approvalUrl(value.approvalUrl, this.origin, uuid22(value.pairingId, "PAIRING_INVALID")),
48197
48277
  expiresAt: value.expiresAt instanceof Date ? new Date(value.expiresAt.getTime()) : parseDate(value.expiresAt, "PAIRING_INVALID"),
48198
48278
  keyFingerprint: fingerprint2(value.keyFingerprint)
48199
48279
  };
@@ -48724,9 +48804,9 @@ function commandSummary2(tool) {
48724
48804
  return { name: name2, command };
48725
48805
  }
48726
48806
  var ProductionMonitor = class {
48727
- constructor(directory, stateDirectory, agentVersion3) {
48807
+ constructor(directory, stateDirectory2, agentVersion3) {
48728
48808
  this.agentVersion = agentVersion3;
48729
- const key = createHash17("sha256").update(path23.resolve(stateDirectory).toLowerCase()).digest("hex");
48809
+ const key = createHash17("sha256").update(path23.resolve(stateDirectory2).toLowerCase()).digest("hex");
48730
48810
  this.file = path23.join(directory, key + ".json");
48731
48811
  this.transportFile = path23.join(directory, key + ".transport");
48732
48812
  }
@@ -48953,12 +49033,12 @@ var ProductionMonitor = class {
48953
49033
  });
48954
49034
  return this.writing;
48955
49035
  }
48956
- async write(file2, contents) {
48957
- const directory = path23.dirname(file2);
49036
+ async write(file3, contents) {
49037
+ const directory = path23.dirname(file3);
48958
49038
  await mkdir9(directory, { recursive: true, mode: 448 });
48959
49039
  const stat2 = await lstat10(directory);
48960
49040
  if (!stat2.isDirectory() || stat2.isSymbolicLink()) throw Error("MONITOR_DIRECTORY_INVALID");
48961
- const temporary = file2 + "." + this.instanceId + ".tmp";
49041
+ const temporary = file3 + "." + this.instanceId + ".tmp";
48962
49042
  const handle = await open9(temporary, "wx", 384);
48963
49043
  try {
48964
49044
  try {
@@ -48966,7 +49046,7 @@ var ProductionMonitor = class {
48966
49046
  } finally {
48967
49047
  await handle.close();
48968
49048
  }
48969
- await rename6(temporary, file2);
49049
+ await rename6(temporary, file3);
48970
49050
  } finally {
48971
49051
  await rm8(temporary, { force: true });
48972
49052
  }
@@ -48978,6 +49058,444 @@ var ProductionMonitor = class {
48978
49058
  }
48979
49059
  };
48980
49060
 
49061
+ // agent/src/full-log-notice.ts
49062
+ import { execFile as execFile5 } from "node:child_process";
49063
+ import { randomUUID as randomUUID13 } from "node:crypto";
49064
+ import { lstat as lstat11, mkdir as mkdir10, readFile as readFile10, rename as rename7, rm as rm9, writeFile as writeFile4 } from "node:fs/promises";
49065
+ import path24 from "node:path";
49066
+ import { promisify as promisify3 } from "node:util";
49067
+ var exec3 = promisify3(execFile5);
49068
+ var manageUrl = "https://localcmd.app";
49069
+ var noticeDirectory = (directory) => path24.join(directory, "optimization");
49070
+ var file2 = (directory) => path24.join(noticeDirectory(directory), "full-log-notice.json");
49071
+ async function saved(directory, enrollment) {
49072
+ if (!enrollment) return null;
49073
+ try {
49074
+ const parent = await lstat11(noticeDirectory(directory));
49075
+ if (!parent.isDirectory() || parent.isSymbolicLink()) return null;
49076
+ const info = await lstat11(file2(directory));
49077
+ if (!info.isFile() || info.isSymbolicLink() || info.size > 4096) return null;
49078
+ const value = JSON.parse(await readFile10(file2(directory), "utf8"));
49079
+ if (value.tenantId !== enrollment.tenantId || value.deviceId !== enrollment.deviceId || !(value.enabled === null || typeof value.enabled === "boolean") || !(value.lastNotified === null || typeof value.lastNotified === "boolean") || !Number.isInteger(value.pid) || value.pid <= 0 || !Number.isFinite(Date.parse(value.confirmedAt))) return null;
49080
+ return value;
49081
+ } catch {
49082
+ return null;
49083
+ }
49084
+ }
49085
+ async function readFullLogNotice(directory, enrollment) {
49086
+ const value = await saved(directory, enrollment);
49087
+ let live = false;
49088
+ if (value) {
49089
+ try {
49090
+ const processRecord = JSON.parse(await readFile10(path24.join(directory, "agent-process.json"), "utf8"));
49091
+ if (processRecord.pid === value.pid && Date.parse(processRecord.startedAt) <= Date.parse(value.confirmedAt)) {
49092
+ process.kill(value.pid, 0);
49093
+ live = true;
49094
+ }
49095
+ } catch {
49096
+ }
49097
+ }
49098
+ return { enabled: live ? value.enabled : null, confirmedAt: value?.confirmedAt ?? null, manageUrl };
49099
+ }
49100
+ async function showFullLogNotice(enabled) {
49101
+ const title = "Local Commander: full logs " + (enabled ? "enabled" : "disabled");
49102
+ const body = enabled ? "Your account owner enabled full logs for this computer. Tool requests and responses may be stored for up to 7 days. Review the choice at localcmd.app." : "Your account owner disabled full logs for this computer. Review the choice and deletion status at localcmd.app.";
49103
+ const options = { windowsHide: true, timeout: 12e3, maxBuffer: 4096 };
49104
+ if (process.platform === "win32") {
49105
+ const script = `Add-Type -AssemblyName System.Windows.Forms; Add-Type -AssemblyName System.Drawing; $notice=New-Object System.Windows.Forms.NotifyIcon; try { $notice.Icon=[System.Drawing.SystemIcons]::Information; $notice.Visible=$true; $notice.ShowBalloonTip(8000,'${title}','${body}',[System.Windows.Forms.ToolTipIcon]::Info); Start-Sleep -Seconds 8 } finally { $notice.Dispose() }`;
49106
+ await exec3("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script], options);
49107
+ } else if (process.platform === "darwin") {
49108
+ await exec3("/usr/bin/osascript", ["-e", `display notification "${body}" with title "${title}"`], options);
49109
+ } else if (process.platform === "linux") {
49110
+ await exec3("notify-send", ["--app-name=Local Commander", title, body], options);
49111
+ }
49112
+ }
49113
+ var FullLogNotice = class {
49114
+ constructor(directory, enrollment, notify = showFullLogNotice) {
49115
+ this.directory = directory;
49116
+ this.enrollment = enrollment;
49117
+ this.notify = notify;
49118
+ }
49119
+ directory;
49120
+ enrollment;
49121
+ notify;
49122
+ pending;
49123
+ writing;
49124
+ update(enabled) {
49125
+ this.pending = enabled;
49126
+ return this.writing ??= this.drain().finally(() => {
49127
+ this.writing = void 0;
49128
+ });
49129
+ }
49130
+ async drain() {
49131
+ await mkdir10(noticeDirectory(this.directory), { mode: 448 }).catch((error62) => {
49132
+ if (error62.code !== "EEXIST") throw error62;
49133
+ });
49134
+ const parent = await lstat11(noticeDirectory(this.directory));
49135
+ if (!parent.isDirectory() || parent.isSymbolicLink()) throw Error("FULL_LOG_NOTICE_DIRECTORY_INVALID");
49136
+ let previous = await saved(this.directory, this.enrollment);
49137
+ while (this.pending !== void 0) {
49138
+ const enabled = this.pending;
49139
+ this.pending = void 0;
49140
+ const changed = enabled !== null && enabled !== previous?.lastNotified && (enabled || previous?.lastNotified === true);
49141
+ const next = {
49142
+ ...this.enrollment,
49143
+ enabled,
49144
+ lastNotified: changed ? enabled : previous?.lastNotified ?? null,
49145
+ confirmedAt: (/* @__PURE__ */ new Date()).toISOString(),
49146
+ pid: process.pid
49147
+ };
49148
+ const temporary = file2(this.directory) + "." + randomUUID13() + ".tmp";
49149
+ try {
49150
+ await writeFile4(temporary, JSON.stringify(next) + "\n", { flag: "wx", mode: 384 });
49151
+ await rename7(temporary, file2(this.directory));
49152
+ } finally {
49153
+ await rm9(temporary, { force: true }).catch(() => {
49154
+ });
49155
+ }
49156
+ previous = next;
49157
+ if (changed) void this.notify(enabled).catch(() => {
49158
+ });
49159
+ }
49160
+ }
49161
+ };
49162
+
49163
+ // agent/src/token-usage.ts
49164
+ import { randomUUID as randomUUID14 } from "node:crypto";
49165
+ import { lstat as lstat12, mkdir as mkdir11, open as open10, readdir as readdir6, readFile as readFile11, rename as rename8, rm as rm10, writeFile as writeFile5 } from "node:fs/promises";
49166
+ import os8 from "node:os";
49167
+ import path25 from "node:path";
49168
+ var KEEP_DAYS = 35;
49169
+ var MAX_FILES = 1e4;
49170
+ var MAX_SCAN_BYTES = 256 * 1024 * 1024;
49171
+ var CHUNK_BYTES = 4 * 1024 * 1024;
49172
+ var MAX_ROWS = 64;
49173
+ var DAY_MS = 864e5;
49174
+ function tokenUsageRoots(env = process.env) {
49175
+ const home = os8.homedir();
49176
+ const absolute2 = (value, fallback) => value && path25.isAbsolute(value) ? value : fallback;
49177
+ return { claude: absolute2(env.CLAUDE_CONFIG_DIR, path25.join(home, ".claude")), codex: absolute2(env.CODEX_HOME, path25.join(home, ".codex")) };
49178
+ }
49179
+ var stateDirectory = (directory) => path25.join(directory, "optimization");
49180
+ var stateFile = (directory) => path25.join(stateDirectory(directory), "token-usage.json");
49181
+ var utcDay = (ms) => new Date(ms).toISOString().slice(0, 10);
49182
+ var count2 = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
49183
+ var modelName = (value) => typeof value === "string" && TOKEN_USAGE_MODEL.test(value) ? value : "unknown";
49184
+ async function sources(roots, since) {
49185
+ const found = [];
49186
+ const entries = async (dir) => {
49187
+ try {
49188
+ return await readdir6(dir, { withFileTypes: true });
49189
+ } catch {
49190
+ return [];
49191
+ }
49192
+ };
49193
+ const add = async (client, file3) => {
49194
+ if (found.length >= MAX_FILES) return;
49195
+ try {
49196
+ const info = await lstat12(file3);
49197
+ if (info.isFile() && info.mtimeMs >= since) found.push({ client, file: file3 });
49198
+ } catch {
49199
+ }
49200
+ };
49201
+ const projects = path25.join(roots.claude, "projects");
49202
+ for (const project of await entries(projects)) {
49203
+ if (!project.isDirectory()) continue;
49204
+ for (const entry of await entries(path25.join(projects, project.name))) {
49205
+ if (entry.isFile() && entry.name.endsWith(".jsonl")) await add("claude-code", path25.join(projects, project.name, entry.name));
49206
+ else if (entry.isDirectory()) {
49207
+ const subagents = path25.join(projects, project.name, entry.name, "subagents");
49208
+ for (const agent of await entries(subagents)) if (agent.isFile() && agent.name.endsWith(".jsonl")) await add("claude-code", path25.join(subagents, agent.name));
49209
+ }
49210
+ }
49211
+ }
49212
+ const sessions = path25.join(roots.codex, "sessions"), first = utcDay(since - DAY_MS);
49213
+ for (const year of await entries(sessions)) {
49214
+ if (!year.isDirectory() || !/^\d{4}$/.test(year.name) || year.name < first.slice(0, 4)) continue;
49215
+ for (const month of await entries(path25.join(sessions, year.name))) {
49216
+ if (!month.isDirectory() || !/^\d{2}$/.test(month.name) || `${year.name}-${month.name}` < first.slice(0, 7)) continue;
49217
+ for (const day of await entries(path25.join(sessions, year.name, month.name))) {
49218
+ if (!day.isDirectory() || !/^\d{2}$/.test(day.name) || `${year.name}-${month.name}-${day.name}` < first) continue;
49219
+ const folder = path25.join(sessions, year.name, month.name, day.name);
49220
+ for (const file3 of await entries(folder)) if (file3.isFile() && file3.name.endsWith(".jsonl")) await add("codex", path25.join(folder, file3.name));
49221
+ }
49222
+ }
49223
+ }
49224
+ return found;
49225
+ }
49226
+ function usageFromLine(client, line, file3) {
49227
+ if (client === "claude-code" ? !line.includes('"usage"') : !line.includes('"token_count"') && !line.includes('"turn_context"')) return null;
49228
+ let value;
49229
+ try {
49230
+ value = JSON.parse(line);
49231
+ } catch {
49232
+ return null;
49233
+ }
49234
+ const at = typeof value?.timestamp === "string" ? Date.parse(value.timestamp) : NaN;
49235
+ if (client === "claude-code") {
49236
+ const message2 = value?.type === "assistant" ? value.message : void 0, usage = message2?.usage;
49237
+ if (!usage || typeof message2.id !== "string" || message2.model === "<synthetic>") return null;
49238
+ if (message2.id === file3.lastMessageId) return null;
49239
+ file3.lastMessageId = message2.id.slice(0, 128);
49240
+ const input3 = count2(usage.input_tokens), cacheWrite2 = count2(usage.cache_creation_input_tokens ?? 0), cached3 = count2(usage.cache_read_input_tokens ?? 0), output3 = count2(usage.output_tokens);
49241
+ if (input3 === null || cacheWrite2 === null || cached3 === null || output3 === null || !Number.isFinite(at)) return null;
49242
+ return { at, model: modelName(message2.model), input: input3 + cacheWrite2 + cached3, cached: cached3, cacheWrite: cacheWrite2, output: output3, reasoning: null };
49243
+ }
49244
+ if (value?.type === "turn_context") {
49245
+ file3.model = modelName(value.payload?.model);
49246
+ return null;
49247
+ }
49248
+ const info = value?.type === "event_msg" && value.payload?.type === "token_count" ? value.payload.info : void 0;
49249
+ const total = count2(info?.total_token_usage?.total_tokens), last = info?.last_token_usage;
49250
+ if (total === null || !last || total === file3.lastTotal) return null;
49251
+ file3.lastTotal = total;
49252
+ const input2 = count2(last.input_tokens), cached2 = count2(last.cached_input_tokens ?? 0), cacheWrite = count2(last.cache_write_input_tokens ?? 0), output2 = count2(last.output_tokens), reasoning = count2(last.reasoning_output_tokens ?? 0);
49253
+ if (input2 === null || cached2 === null || cacheWrite === null || output2 === null || reasoning === null || !Number.isFinite(at)) return null;
49254
+ if (cached2 + cacheWrite > input2 || reasoning > output2) return null;
49255
+ return { at, model: file3.model ?? "unknown", input: input2, cached: cached2, cacheWrite, output: output2, reasoning };
49256
+ }
49257
+ async function readNew(source, file3, size, budget, countFrom, add) {
49258
+ if (size < file3.offset) Object.assign(file3, { offset: 0, lastMessageId: void 0, lastTotal: void 0, skipping: false });
49259
+ let read = 0;
49260
+ const handle = await open10(source.file, "r");
49261
+ try {
49262
+ while (file3.offset < size && read < budget) {
49263
+ const length = Math.min(CHUNK_BYTES, size - file3.offset);
49264
+ const buffer = Buffer.alloc(length);
49265
+ const { bytesRead } = await handle.read(buffer, 0, length, file3.offset);
49266
+ if (bytesRead <= 0) break;
49267
+ read += bytesRead;
49268
+ const end = buffer.lastIndexOf(10, bytesRead - 1);
49269
+ if (end < 0) {
49270
+ if (bytesRead < CHUNK_BYTES) break;
49271
+ file3.offset += bytesRead;
49272
+ file3.skipping = true;
49273
+ continue;
49274
+ }
49275
+ let start = 0;
49276
+ if (file3.skipping) {
49277
+ start = buffer.indexOf(10) + 1;
49278
+ file3.skipping = false;
49279
+ }
49280
+ for (const line of buffer.toString("utf8", start, end).split("\n")) {
49281
+ const usage = usageFromLine(source.client, line, file3);
49282
+ if (usage && usage.at >= countFrom) add(source.client, usage);
49283
+ }
49284
+ file3.offset += end + 1;
49285
+ }
49286
+ } finally {
49287
+ await handle.close();
49288
+ }
49289
+ return read;
49290
+ }
49291
+ var TokenUsageReporter = class {
49292
+ constructor(directory, enrollment, options = {}) {
49293
+ this.directory = directory;
49294
+ this.enrollment = enrollment;
49295
+ this.options = options;
49296
+ }
49297
+ directory;
49298
+ enrollment;
49299
+ options;
49300
+ saved;
49301
+ send;
49302
+ enabled = false;
49303
+ wanted = false;
49304
+ timer;
49305
+ running;
49306
+ inFlight;
49307
+ closed = false;
49308
+ failed = false;
49309
+ /** The state frame can arrive before the connection is handed over, so both feed one decision. */
49310
+ connected(send) {
49311
+ this.send = send;
49312
+ this.apply();
49313
+ }
49314
+ disconnected() {
49315
+ this.send = void 0;
49316
+ this.wanted = false;
49317
+ this.apply();
49318
+ if (this.inFlight) {
49319
+ clearTimeout(this.inFlight.timer);
49320
+ this.inFlight = void 0;
49321
+ }
49322
+ }
49323
+ close() {
49324
+ this.closed = true;
49325
+ this.disconnected();
49326
+ }
49327
+ /** The server's choice for this computer, sent after connect and on every change. */
49328
+ state(enabled) {
49329
+ this.wanted = enabled;
49330
+ this.apply();
49331
+ if (!enabled) void this.exclusive(async () => {
49332
+ const saved2 = await this.load();
49333
+ if (!saved2.paused) {
49334
+ saved2.paused = true;
49335
+ await this.persist();
49336
+ }
49337
+ }).catch(() => {
49338
+ });
49339
+ }
49340
+ apply() {
49341
+ const on = this.wanted && !!this.send && !this.closed;
49342
+ if (on && !this.enabled) {
49343
+ this.enabled = true;
49344
+ this.schedule(this.options.firstDelayMs ?? 6e4);
49345
+ } else if (!on && this.enabled) {
49346
+ this.enabled = false;
49347
+ clearTimeout(this.timer);
49348
+ this.timer = void 0;
49349
+ }
49350
+ }
49351
+ ack(batchId, result2) {
49352
+ const flight = this.inFlight;
49353
+ if (!flight || batchId !== flight.batchId) return;
49354
+ clearTimeout(flight.timer);
49355
+ this.inFlight = void 0;
49356
+ if (result2 === "disabled") {
49357
+ this.state(false);
49358
+ return;
49359
+ }
49360
+ if (result2 !== "accepted" && result2 !== "invalid") return;
49361
+ void this.exclusive(async () => {
49362
+ const saved2 = await this.load();
49363
+ for (const [key, version2] of Object.entries(flight.versions)) if (saved2.dirty[key] === version2) delete saved2.dirty[key];
49364
+ await this.persist();
49365
+ if (result2 === "accepted") this.flush();
49366
+ });
49367
+ }
49368
+ /** One scan and report now; used by the timer and by manual checks. */
49369
+ async scanOnce() {
49370
+ await this.exclusive(async () => {
49371
+ const saved2 = await this.load(), now = this.now();
49372
+ if (saved2.paused) {
49373
+ saved2.countFrom = new Date(now).toISOString();
49374
+ saved2.files = {};
49375
+ saved2.baseline = true;
49376
+ delete saved2.paused;
49377
+ }
49378
+ const countFrom = Date.parse(saved2.countFrom);
49379
+ const since = Math.max(countFrom, now - KEEP_DAYS * DAY_MS);
49380
+ let budget = MAX_SCAN_BYTES;
49381
+ const seen = /* @__PURE__ */ new Set();
49382
+ const baseline = saved2.baseline === true;
49383
+ for (const source of await sources(this.roots(), since - DAY_MS)) {
49384
+ if (budget <= 0) break;
49385
+ seen.add(source.file);
49386
+ let info;
49387
+ try {
49388
+ info = await lstat12(source.file);
49389
+ } catch {
49390
+ continue;
49391
+ }
49392
+ const file3 = saved2.files[source.file] ??= { offset: baseline ? info.size : 0, mtimeMs: 0 };
49393
+ file3.mtimeMs = info.mtimeMs;
49394
+ if (info.size === file3.offset) continue;
49395
+ try {
49396
+ budget -= await readNew(source, file3, info.size, budget, countFrom, (client, usage) => this.add(saved2, client, usage));
49397
+ } catch {
49398
+ }
49399
+ }
49400
+ if (baseline) delete saved2.baseline;
49401
+ for (const [name2, file3] of Object.entries(saved2.files)) if (!seen.has(name2) && file3.mtimeMs < now - KEEP_DAYS * DAY_MS) delete saved2.files[name2];
49402
+ const oldest = utcDay(now - KEEP_DAYS * DAY_MS);
49403
+ for (const key of Object.keys(saved2.totals)) if (key.slice(0, 10) < oldest) {
49404
+ delete saved2.totals[key];
49405
+ delete saved2.dirty[key];
49406
+ }
49407
+ await this.persist();
49408
+ });
49409
+ this.flush();
49410
+ }
49411
+ add(saved2, client, usage) {
49412
+ const key = `${utcDay(usage.at)}|${client}|${usage.model}`;
49413
+ const row = saved2.totals[key] ??= { requests: 0, inputTokens: 0, cachedInputTokens: 0, cacheWriteTokens: 0, outputTokens: 0, reasoningTokens: client === "codex" ? 0 : null };
49414
+ row.requests++;
49415
+ row.inputTokens += usage.input;
49416
+ row.cachedInputTokens += usage.cached;
49417
+ row.cacheWriteTokens += usage.cacheWrite;
49418
+ row.outputTokens += usage.output;
49419
+ if (row.reasoningTokens !== null && usage.reasoning !== null) row.reasoningTokens += usage.reasoning;
49420
+ saved2.dirty[key] = (saved2.dirty[key] ?? 0) + 1;
49421
+ }
49422
+ flush() {
49423
+ const saved2 = this.saved, send = this.send;
49424
+ if (!saved2 || !send || !this.enabled || this.inFlight) return;
49425
+ const keys = Object.keys(saved2.dirty).filter((key) => saved2.totals[key]).sort().slice(0, MAX_ROWS);
49426
+ if (!keys.length) return;
49427
+ const rows = keys.map((key) => {
49428
+ const [day, client, model] = key.split("|");
49429
+ return { day, client, model, ...saved2.totals[key] };
49430
+ });
49431
+ const batchId = randomUUID14(), versions = Object.fromEntries(keys.map((key) => [key, saved2.dirty[key]]));
49432
+ let sent = false;
49433
+ try {
49434
+ sent = send({ batchId, stateId: saved2.stateId, rows });
49435
+ } catch {
49436
+ }
49437
+ if (sent) this.inFlight = { batchId, versions, timer: setTimeout(() => {
49438
+ if (this.inFlight?.batchId === batchId) this.inFlight = void 0;
49439
+ }, 3e4).unref() };
49440
+ }
49441
+ schedule(delay4) {
49442
+ clearTimeout(this.timer);
49443
+ this.timer = setTimeout(() => {
49444
+ if (!this.enabled) return;
49445
+ void this.scanOnce().catch(() => {
49446
+ if (!this.failed) {
49447
+ this.failed = true;
49448
+ process.stderr.write("TOKEN_USAGE_SCAN_FAILED\n");
49449
+ }
49450
+ }).finally(() => {
49451
+ if (this.enabled) this.schedule(this.options.intervalMs ?? 36e5);
49452
+ });
49453
+ }, delay4);
49454
+ this.timer.unref();
49455
+ }
49456
+ exclusive(task) {
49457
+ const next = (this.running ?? Promise.resolve()).then(task, task);
49458
+ this.running = next.catch(() => {
49459
+ });
49460
+ return next;
49461
+ }
49462
+ now() {
49463
+ return (this.options.now ?? Date.now)();
49464
+ }
49465
+ roots() {
49466
+ return this.options.roots ?? tokenUsageRoots();
49467
+ }
49468
+ async load() {
49469
+ if (this.saved) return this.saved;
49470
+ let value;
49471
+ try {
49472
+ const info = await lstat12(stateFile(this.directory));
49473
+ if (info.isFile() && !info.isSymbolicLink() && info.size <= 16 * 1024 * 1024) {
49474
+ const parsed = JSON.parse(await readFile11(stateFile(this.directory), "utf8"));
49475
+ if (parsed.version === 1 && parsed.tenantId === this.enrollment.tenantId && parsed.deviceId === this.enrollment.deviceId && typeof parsed.stateId === "string" && Number.isFinite(Date.parse(parsed.countFrom)) && parsed.files && parsed.totals && parsed.dirty) value = parsed;
49476
+ }
49477
+ } catch {
49478
+ }
49479
+ return this.saved = value ?? { version: 1, ...this.enrollment, stateId: randomUUID14(), countFrom: new Date(this.now()).toISOString(), files: {}, totals: {}, dirty: {}, baseline: true };
49480
+ }
49481
+ async persist() {
49482
+ if (!this.saved) return;
49483
+ await mkdir11(stateDirectory(this.directory), { mode: 448 }).catch((error62) => {
49484
+ if (error62.code !== "EEXIST") throw error62;
49485
+ });
49486
+ const parent = await lstat12(stateDirectory(this.directory));
49487
+ if (!parent.isDirectory() || parent.isSymbolicLink()) throw Error("TOKEN_USAGE_DIRECTORY_INVALID");
49488
+ const temporary = stateFile(this.directory) + "." + randomUUID14() + ".tmp";
49489
+ try {
49490
+ await writeFile5(temporary, JSON.stringify(this.saved), { flag: "wx", mode: 384 });
49491
+ await rename8(temporary, stateFile(this.directory));
49492
+ } finally {
49493
+ await rm10(temporary, { force: true }).catch(() => {
49494
+ });
49495
+ }
49496
+ }
49497
+ };
49498
+
48981
49499
  // agent/src/native-event-buffer.ts
48982
49500
  import { createHash as createHash18 } from "node:crypto";
48983
49501
  function nativeFingerprint(code, executionId = "") {
@@ -49260,7 +49778,7 @@ var NativeEventSupervisor = class {
49260
49778
  };
49261
49779
 
49262
49780
  // agent/src/native-fabric-observer.ts
49263
- var uuid22 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
49781
+ var uuid23 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
49264
49782
  var NativeFabricObserver = class {
49265
49783
  constructor(supervisor, source) {
49266
49784
  this.supervisor = supervisor;
@@ -49282,7 +49800,7 @@ var NativeFabricObserver = class {
49282
49800
  unsubscribe;
49283
49801
  connected(authenticatedDeviceId) {
49284
49802
  this.disconnected();
49285
- if (uuid22.test(authenticatedDeviceId)) this.deviceId = authenticatedDeviceId.toLowerCase();
49803
+ if (uuid23.test(authenticatedDeviceId)) this.deviceId = authenticatedDeviceId.toLowerCase();
49286
49804
  this.activity();
49287
49805
  }
49288
49806
  disconnected() {
@@ -49317,17 +49835,17 @@ var NativeFabricObserver = class {
49317
49835
  void Promise.resolve().then(() => this.source.mailbox.snapshot()).then((state) => {
49318
49836
  if (this.closed || expired || generation !== this.generation) return;
49319
49837
  if (state.workers.length > 64 || state.assignments.length > 256 || state.messages.length > 1024) throw Error("FABRIC_BOUND_INVALID");
49320
- const workers = new Set(state.workers.filter((w) => w.device?.deviceId.toLowerCase() === deviceId && uuid22.test(w.workerId)).map((w) => w.workerId));
49838
+ const workers = new Set(state.workers.filter((w) => w.device?.deviceId.toLowerCase() === deviceId && uuid23.test(w.workerId)).map((w) => w.workerId));
49321
49839
  const assignments = new Map(state.assignments.filter((a) => workers.has(a.workerId)).map((a) => [a.assignmentId, a]));
49322
49840
  const refs = /* @__PURE__ */ new Map();
49323
49841
  for (const a of assignments.values()) {
49324
49842
  const id2 = a.execution?.executionId;
49325
- if (!id2 || !uuid22.test(id2)) continue;
49843
+ if (!id2 || !uuid23.test(id2)) continue;
49326
49844
  if (refs.has(id2.toLowerCase())) throw Error("FABRIC_EXECUTION_CONFLICT");
49327
49845
  refs.set(id2.toLowerCase(), {
49328
49846
  executionId: id2.toLowerCase(),
49329
49847
  workerId: a.workerId.toLowerCase(),
49330
- ...uuid22.test(a.taskId) ? { taskId: a.taskId.toLowerCase() } : {}
49848
+ ...uuid23.test(a.taskId) ? { taskId: a.taskId.toLowerCase() } : {}
49331
49849
  });
49332
49850
  }
49333
49851
  this.referencesByExecution.clear();
@@ -49379,27 +49897,27 @@ var NativeFabricObserver = class {
49379
49897
  };
49380
49898
 
49381
49899
  // agent/src/native-fabric-startup.ts
49382
- import { lstat as lstat12, mkdir as mkdir12, open as open11, readFile as readFile10 } from "node:fs/promises";
49383
- import path26 from "node:path";
49900
+ import { lstat as lstat14, mkdir as mkdir14, open as open12, readFile as readFile12 } from "node:fs/promises";
49901
+ import path28 from "node:path";
49384
49902
 
49385
49903
  // src/agent-fabric-service.ts
49386
- import { lstat as lstat11, mkdir as mkdir11, realpath as realpath9 } from "node:fs/promises";
49904
+ import { lstat as lstat13, mkdir as mkdir13, realpath as realpath9 } from "node:fs/promises";
49387
49905
  import { watch } from "node:fs";
49388
- import path25 from "node:path";
49906
+ import path27 from "node:path";
49389
49907
 
49390
49908
  // src/agent-runtime-identity.ts
49391
- import { createHash as createHash19, randomBytes as randomBytes8, randomUUID as randomUUID14, timingSafeEqual as timingSafeEqual4 } from "node:crypto";
49909
+ import { createHash as createHash19, randomBytes as randomBytes8, randomUUID as randomUUID16, timingSafeEqual as timingSafeEqual4 } from "node:crypto";
49392
49910
 
49393
49911
  // src/agent-fabric-state.ts
49394
- import { randomUUID as randomUUID13 } from "node:crypto";
49395
- import { mkdir as mkdir10, open as open10, rename as rename7, unlink as unlink3 } from "node:fs/promises";
49396
- import path24 from "node:path";
49912
+ import { randomUUID as randomUUID15 } from "node:crypto";
49913
+ import { mkdir as mkdir12, open as open11, rename as rename9, unlink as unlink3 } from "node:fs/promises";
49914
+ import path26 from "node:path";
49397
49915
  var queues = /* @__PURE__ */ new Map();
49398
49916
  var FabricStateFile = class {
49399
- constructor(file2, maxBytes, parse4) {
49917
+ constructor(file3, maxBytes, parse4) {
49400
49918
  this.maxBytes = maxBytes;
49401
49919
  this.parse = parse4;
49402
- this.file = path24.resolve(file2);
49920
+ this.file = path26.resolve(file3);
49403
49921
  }
49404
49922
  maxBytes;
49405
49923
  parse;
@@ -49417,7 +49935,7 @@ var FabricStateFile = class {
49417
49935
  return result2;
49418
49936
  }
49419
49937
  async load() {
49420
- const handle = await open10(this.file, "r");
49938
+ const handle = await open11(this.file, "r");
49421
49939
  try {
49422
49940
  const info = await handle.stat();
49423
49941
  if (!info.isFile() || info.size > this.maxBytes) throw Error("FABRIC_STATE_LIMIT");
@@ -49443,10 +49961,10 @@ var FabricStateFile = class {
49443
49961
  }
49444
49962
  update(fn, create) {
49445
49963
  return this.serial(async () => {
49446
- if (create) await mkdir10(path24.dirname(this.file), { recursive: true });
49964
+ if (create) await mkdir12(path26.dirname(this.file), { recursive: true });
49447
49965
  const lockPath = this.file + ".lock";
49448
- const token = randomUUID13();
49449
- const lock = await open10(lockPath, "wx", 384).catch((error62) => {
49966
+ const token = randomUUID15();
49967
+ const lock = await open11(lockPath, "wx", 384).catch((error62) => {
49450
49968
  if (error62.code === "EEXIST") throw Error("FABRIC_STATE_BUSY");
49451
49969
  throw error62;
49452
49970
  });
@@ -49464,7 +49982,7 @@ var FabricStateFile = class {
49464
49982
  const encoded = JSON.stringify(this.parse(state));
49465
49983
  if (Buffer.byteLength(encoded) > this.maxBytes) throw Error("FABRIC_STATE_LIMIT");
49466
49984
  const temporary = this.file + "." + token + ".tmp";
49467
- const handle = await open10(temporary, "wx", 384);
49985
+ const handle = await open11(temporary, "wx", 384);
49468
49986
  try {
49469
49987
  try {
49470
49988
  await handle.writeFile(encoded, "utf8");
@@ -49472,7 +49990,7 @@ var FabricStateFile = class {
49472
49990
  } finally {
49473
49991
  await handle.close();
49474
49992
  }
49475
- await rename7(temporary, this.file);
49993
+ await rename9(temporary, this.file);
49476
49994
  } finally {
49477
49995
  await unlink3(temporary).catch((error62) => {
49478
49996
  if (error62.code !== "ENOENT") throw error62;
@@ -49481,7 +49999,7 @@ var FabricStateFile = class {
49481
49999
  return result2;
49482
50000
  } finally {
49483
50001
  await lock.close();
49484
- const current2 = await open10(lockPath, "r");
50002
+ const current2 = await open11(lockPath, "r");
49485
50003
  try {
49486
50004
  if ((await current2.stat()).size > 1024 || JSON.parse(await current2.readFile("utf8")).token !== token)
49487
50005
  throw Error("FABRIC_STATE_LOCK_CHANGED");
@@ -49520,9 +50038,9 @@ function validKey(value) {
49520
50038
  return typeof value === "string" && /^[A-Za-z0-9_-]{43}$/.test(value);
49521
50039
  }
49522
50040
  var AgentRuntimeIdentityStore = class {
49523
- constructor(file2, now = Date.now) {
50041
+ constructor(file3, now = Date.now) {
49524
50042
  this.now = now;
49525
- this.state = new FabricStateFile(file2, MAX_BYTES, (value) => {
50043
+ this.state = new FabricStateFile(file3, MAX_BYTES, (value) => {
49526
50044
  const state = StateSchema.parse(value);
49527
50045
  if (new Set(state.bindings.map((item) => item.runtimeId)).size !== state.bindings.length)
49528
50046
  throw Error("RUNTIME_IDENTITY_STATE_CORRUPT");
@@ -49541,7 +50059,7 @@ var AgentRuntimeIdentityStore = class {
49541
50059
  issue() {
49542
50060
  return this.serial((state) => {
49543
50061
  if (state.bindings.length >= MAX_BINDINGS) throw Error("RUNTIME_IDENTITY_LIMIT");
49544
- const runtimeId = "rt-" + randomUUID14();
50062
+ const runtimeId = "rt-" + randomUUID16();
49545
50063
  const runtimeKey = randomBytes8(32).toString("base64url");
49546
50064
  const now = this.now();
49547
50065
  state.bindings.push({ runtimeId, keyHash: encodedDigest(runtimeKey), createdAt: now, lastUsedAt: now, revoked: false });
@@ -49574,10 +50092,10 @@ var AgentRuntimeIdentityStore = class {
49574
50092
  };
49575
50093
 
49576
50094
  // src/agent-fabric-mailbox.ts
49577
- import { randomUUID as randomUUID16 } from "node:crypto";
50095
+ import { randomUUID as randomUUID18 } from "node:crypto";
49578
50096
 
49579
50097
  // src/agent-fabric-timeline.ts
49580
- import { randomUUID as randomUUID15 } from "node:crypto";
50098
+ import { randomUUID as randomUUID17 } from "node:crypto";
49581
50099
  import { performance as performance2 } from "node:perf_hooks";
49582
50100
  var FabricId = external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,95}$/);
49583
50101
  var FabricUtc = external_exports.string().datetime({ precision: 3 }).refine((value) => new Date(value).toISOString() === value);
@@ -49586,7 +50104,7 @@ var FabricStampSchema = external_exports.strictObject({
49586
50104
  clockId: FabricId,
49587
50105
  monotonicMs: external_exports.number().finite().nonnegative().max(Number.MAX_SAFE_INTEGER)
49588
50106
  });
49589
- var processClockId = "clock-" + randomUUID15();
50107
+ var processClockId = "clock-" + randomUUID17();
49590
50108
  function createFabricClock() {
49591
50109
  return () => ({ atUtc: (/* @__PURE__ */ new Date()).toISOString(), clockId: processClockId, monotonicMs: performance2.now() });
49592
50110
  }
@@ -49772,12 +50290,12 @@ function parseState(value) {
49772
50290
  return state;
49773
50291
  }
49774
50292
  var AgentWorkerMailbox = class {
49775
- constructor(file2, controllerId, identities, clock = createFabricClock(), notify) {
50293
+ constructor(file3, controllerId, identities, clock = createFabricClock(), notify) {
49776
50294
  this.identities = identities;
49777
50295
  this.clock = clock;
49778
50296
  this.notify = notify;
49779
50297
  this.controllerId = FabricId.parse(controllerId);
49780
- this.state = new FabricStateFile(file2, 2 * 1024 * 1024, (value) => {
50298
+ this.state = new FabricStateFile(file3, 2 * 1024 * 1024, (value) => {
49781
50299
  const state = parseState(value);
49782
50300
  if (state.controllerId !== this.controllerId) throw Error("FABRIC_CONTROLLER_MISMATCH");
49783
50301
  return state;
@@ -49843,7 +50361,7 @@ var AgentWorkerMailbox = class {
49843
50361
  const now = this.clock().atUtc;
49844
50362
  const worker = {
49845
50363
  ...registration,
49846
- workerId: randomUUID16(),
50364
+ workerId: randomUUID18(),
49847
50365
  controllerId: this.controllerId,
49848
50366
  runtimeId: null,
49849
50367
  attribution: WorkerAttributionSchema.parse({}),
@@ -49877,7 +50395,7 @@ var AgentWorkerMailbox = class {
49877
50395
  if (state.messages.length >= MAX_MESSAGES) throw Error("FABRIC_MESSAGE_LIMIT");
49878
50396
  const now = this.clock();
49879
50397
  const message2 = {
49880
- messageId: randomUUID16(),
50398
+ messageId: randomUUID18(),
49881
50399
  key: request.key,
49882
50400
  assignmentId: assignment.assignmentId,
49883
50401
  direction,
@@ -49894,7 +50412,7 @@ var AgentWorkerMailbox = class {
49894
50412
  }
49895
50413
  async assign(input2) {
49896
50414
  const request = AssignmentInput.parse(input2);
49897
- const saved = await this.state.update((state) => {
50415
+ const saved2 = await this.state.update((state) => {
49898
50416
  this.worker(state, request.workerId);
49899
50417
  const existing = state.assignments.find((a) => a.runId === request.runId && a.selectedRuntime === request.selectedRuntime);
49900
50418
  if (existing) {
@@ -49907,7 +50425,7 @@ var AgentWorkerMailbox = class {
49907
50425
  const now = this.clock().atUtc;
49908
50426
  const assignment = {
49909
50427
  ...request,
49910
- assignmentId: randomUUID16(),
50428
+ assignmentId: randomUUID18(),
49911
50429
  phase: "assigned",
49912
50430
  createdAt: now,
49913
50431
  updatedAt: now,
@@ -49922,30 +50440,30 @@ var AgentWorkerMailbox = class {
49922
50440
  const { message: message2 } = this.append(state, assignment, "ASSIGN", "controller", { key: "assign", payloadRef: request.payloadRef });
49923
50441
  return { state, assignment, notice: message2 };
49924
50442
  });
49925
- if (saved.notice) this.emit(saved.state, saved.notice);
49926
- return saved.assignment;
50443
+ if (saved2.notice) this.emit(saved2.state, saved2.notice);
50444
+ return saved2.assignment;
49927
50445
  }
49928
50446
  async control(assignmentId, kind, input2) {
49929
50447
  Control.parse(kind);
49930
- const saved = await this.state.update((state) => {
50448
+ const saved2 = await this.state.update((state) => {
49931
50449
  const assignment = this.assignment(state, assignmentId);
49932
50450
  if (!assignmentActive(assignment)) throw Error("FABRIC_ASSIGNMENT_INACTIVE");
49933
50451
  return { state, ...this.append(state, assignment, kind, "controller", input2) };
49934
50452
  });
49935
- if (saved.added) this.emit(saved.state, saved.message);
49936
- return saved.message;
50453
+ if (saved2.added) this.emit(saved2.state, saved2.message);
50454
+ return saved2.message;
49937
50455
  }
49938
50456
  async report(workerId, credential, assignmentId, kind, input2) {
49939
50457
  Report.parse(kind);
49940
50458
  await this.identities.authenticate(credential.runtimeId, credential.runtimeKey);
49941
- const saved = await this.state.update((state) => {
50459
+ const saved2 = await this.state.update((state) => {
49942
50460
  this.bound(state, workerId, credential);
49943
50461
  const assignment = this.assignment(state, assignmentId);
49944
50462
  if (assignment.workerId !== workerId || assignment.phase === "not_started") throw Error("FABRIC_ASSIGNMENT_DENIED");
49945
50463
  return { state, ...this.append(state, assignment, kind, "worker", input2) };
49946
50464
  });
49947
- if (saved.added) this.emit(saved.state, saved.message);
49948
- return saved.message;
50465
+ if (saved2.added) this.emit(saved2.state, saved2.message);
50466
+ return saved2.message;
49949
50467
  }
49950
50468
  pending(state, direction, workerId) {
49951
50469
  const now = this.clock().atUtc;
@@ -49985,12 +50503,12 @@ var AgentWorkerMailbox = class {
49985
50503
  return this.state.update((state) => this.acknowledge(state, messageId, "to_controller"));
49986
50504
  }
49987
50505
  async adapterResult(assignmentId, payloadRef) {
49988
- const saved = await this.state.update((state) => {
50506
+ const saved2 = await this.state.update((state) => {
49989
50507
  const assignment = this.assignment(state, assignmentId);
49990
50508
  if (assignment.phase !== "exited") throw Error("FABRIC_RESULT_UNCONFIRMED");
49991
50509
  return { state, ...this.append(state, assignment, "RESULT", "adapter", { key: "result", payloadRef }) };
49992
50510
  });
49993
- if (saved.added) this.emit(saved.state, saved.message);
50511
+ if (saved2.added) this.emit(saved2.state, saved2.message);
49994
50512
  }
49995
50513
  claimLaunch(assignmentId) {
49996
50514
  return this.state.update((state) => {
@@ -50087,9 +50605,9 @@ var WorkerRequest = external_exports.discriminatedUnion("operation", [
50087
50605
  var AgentFabricService = class _AgentFabricService {
50088
50606
  constructor(directory, controllerId) {
50089
50607
  this.directory = directory;
50090
- this.identities = new AgentRuntimeIdentityStore(path25.join(directory, "identities.json"));
50608
+ this.identities = new AgentRuntimeIdentityStore(path27.join(directory, "identities.json"));
50091
50609
  this.mailbox = new AgentWorkerMailbox(
50092
- path25.join(directory, "mailbox.json"),
50610
+ path27.join(directory, "mailbox.json"),
50093
50611
  controllerId,
50094
50612
  this.identities,
50095
50613
  void 0,
@@ -50104,29 +50622,29 @@ var AgentFabricService = class _AgentFabricService {
50104
50622
  closed = false;
50105
50623
  static async open(directory, controllerId, device = null, initialize = true) {
50106
50624
  const expected = Binding.parse({ version: 1, controllerId, device, initialized: false });
50107
- const absolute2 = path25.resolve(directory);
50108
- for (let current2 = absolute2; ; current2 = path25.dirname(current2)) {
50625
+ const absolute2 = path27.resolve(directory);
50626
+ for (let current2 = absolute2; ; current2 = path27.dirname(current2)) {
50109
50627
  try {
50110
- if ((await lstat11(current2)).isSymbolicLink()) throw Error("FABRIC_DIRECTORY_INVALID");
50628
+ if ((await lstat13(current2)).isSymbolicLink()) throw Error("FABRIC_DIRECTORY_INVALID");
50111
50629
  } catch (error62) {
50112
50630
  if (error62.code !== "ENOENT") throw error62;
50113
50631
  }
50114
- if (path25.dirname(current2) === current2) break;
50632
+ if (path27.dirname(current2) === current2) break;
50115
50633
  }
50116
- if (initialize) await mkdir11(absolute2, { recursive: true, mode: 448 });
50117
- if (!(await lstat11(absolute2)).isDirectory() || (await realpath9(absolute2)).toLowerCase() !== absolute2.toLowerCase())
50634
+ if (initialize) await mkdir13(absolute2, { recursive: true, mode: 448 });
50635
+ if (!(await lstat13(absolute2)).isDirectory() || (await realpath9(absolute2)).toLowerCase() !== absolute2.toLowerCase())
50118
50636
  throw Error("FABRIC_DIRECTORY_INVALID");
50119
50637
  const present = /* @__PURE__ */ new Set();
50120
50638
  for (const name2 of ["binding.json", "mailbox.json", "identities.json"]) {
50121
- const file2 = await lstat11(path25.join(absolute2, name2)).catch((error62) => {
50639
+ const file3 = await lstat13(path27.join(absolute2, name2)).catch((error62) => {
50122
50640
  if (error62.code === "ENOENT") return null;
50123
50641
  throw error62;
50124
50642
  });
50125
- if (file2 && (!file2.isFile() || file2.isSymbolicLink())) throw Error("FABRIC_FILE_INVALID");
50126
- if (file2) present.add(name2);
50643
+ if (file3 && (!file3.isFile() || file3.isSymbolicLink())) throw Error("FABRIC_FILE_INVALID");
50644
+ if (file3) present.add(name2);
50127
50645
  }
50128
50646
  if (!present.has("binding.json") && present.size) throw Error("FABRIC_BINDING_MISSING");
50129
- const binding2 = new FabricStateFile(path25.join(absolute2, "binding.json"), 2048, (value) => Binding.parse(value));
50647
+ const binding2 = new FabricStateFile(path27.join(absolute2, "binding.json"), 2048, (value) => Binding.parse(value));
50130
50648
  const service2 = new _AgentFabricService(absolute2, controllerId);
50131
50649
  await binding2.update(async (state) => {
50132
50650
  if (state.controllerId !== expected.controllerId || JSON.stringify(state.device) !== JSON.stringify(expected.device))
@@ -50141,7 +50659,7 @@ var AgentFabricService = class _AgentFabricService {
50141
50659
  state.initialized = true;
50142
50660
  }
50143
50661
  const snapshot2 = await service2.mailbox.snapshot();
50144
- if (snapshot2.workers.some((worker) => worker.runtimeId !== null)) await lstat11(path25.join(absolute2, "identities.json"));
50662
+ if (snapshot2.workers.some((worker) => worker.runtimeId !== null)) await lstat13(path27.join(absolute2, "identities.json"));
50145
50663
  }, initialize ? () => expected : void 0);
50146
50664
  return service2;
50147
50665
  }
@@ -50158,8 +50676,8 @@ var AgentFabricService = class _AgentFabricService {
50158
50676
  this.listeners.add(callback);
50159
50677
  try {
50160
50678
  if (!this.watcher) {
50161
- this.watcher = watch(this.directory, { persistent: false }, (_event, file2) => {
50162
- if (file2?.toString().toLowerCase() === "mailbox.json") this.changed();
50679
+ this.watcher = watch(this.directory, { persistent: false }, (_event, file3) => {
50680
+ if (file3?.toString().toLowerCase() === "mailbox.json") this.changed();
50163
50681
  });
50164
50682
  this.watcher.on("error", () => {
50165
50683
  this.watcher?.close();
@@ -50225,51 +50743,51 @@ var OwnerRequest = external_exports.discriminatedUnion("operation", [
50225
50743
  })
50226
50744
  ]);
50227
50745
  var Delivery = external_exports.strictObject({ capability: external_exports.string().regex(/^[A-Za-z0-9+/]+={0,2}$/).max(4096), request: external_exports.unknown() });
50228
- async function openNativeFabric(stateDirectory, enrollment, box, initialize = true) {
50746
+ async function openNativeFabric(stateDirectory2, enrollment, box, initialize = true) {
50229
50747
  const controllerId = "device-" + external_exports.string().uuid().parse(enrollment.deviceId).toLowerCase();
50230
50748
  const tenantId = external_exports.string().uuid().parse(enrollment.tenantId).toLowerCase();
50231
- const parent = path26.join(stateDirectory, ".local-commander"), marker = path26.join(parent, "fabric-established.json");
50749
+ const parent = path28.join(stateDirectory2, ".local-commander"), marker = path28.join(parent, "fabric-established.json");
50232
50750
  try {
50233
- await mkdir12(parent, { mode: 448 });
50751
+ await mkdir14(parent, { mode: 448 });
50234
50752
  } catch (error62) {
50235
50753
  if (error62.code !== "EEXIST") throw error62;
50236
50754
  }
50237
- const parentInfo = await lstat12(parent);
50755
+ const parentInfo = await lstat14(parent);
50238
50756
  if (!parentInfo.isDirectory() || parentInfo.isSymbolicLink()) throw Error("FABRIC_DIRECTORY_INVALID");
50239
50757
  const expected = JSON.stringify({ version: 1, controllerId, tenantId });
50240
50758
  let fresh = false;
50241
50759
  try {
50242
- const info = await lstat12(marker);
50243
- if (!info.isFile() || info.isSymbolicLink() || info.size > 2048 || await readFile10(marker, "utf8") !== expected)
50760
+ const info = await lstat14(marker);
50761
+ if (!info.isFile() || info.isSymbolicLink() || info.size > 2048 || await readFile12(marker, "utf8") !== expected)
50244
50762
  throw Error("FABRIC_BINDING_CHANGED");
50245
50763
  } catch (error62) {
50246
50764
  if (error62.code !== "ENOENT" || !initialize) throw error62;
50247
- const file2 = await open11(marker, "wx", 384);
50765
+ const file3 = await open12(marker, "wx", 384);
50248
50766
  try {
50249
- await file2.writeFile(expected);
50250
- await file2.datasync();
50767
+ await file3.writeFile(expected);
50768
+ await file3.datasync();
50251
50769
  } finally {
50252
- await file2.close();
50770
+ await file3.close();
50253
50771
  }
50254
50772
  fresh = true;
50255
50773
  }
50256
50774
  const service2 = await AgentFabricService.open(
50257
- path26.join(stateDirectory, ".local-commander", "fabric"),
50775
+ path28.join(stateDirectory2, ".local-commander", "fabric"),
50258
50776
  controllerId,
50259
50777
  { deviceId: enrollment.deviceId.toLowerCase(), enrollmentEvidenceRef: "enrollment-" + tenantId },
50260
50778
  fresh
50261
50779
  );
50262
50780
  const purpose = "native-fabric:" + tenantId + ":" + controllerId;
50263
- const credentialFile = (workerId) => path26.join(service2.directory, external_exports.string().uuid().parse(workerId) + ".capability");
50781
+ const credentialFile = (workerId) => path28.join(service2.directory, external_exports.string().uuid().parse(workerId) + ".capability");
50264
50782
  const decode4 = (value) => {
50265
50783
  const credential = Credential.parse(JSON.parse(box.open(Buffer.from(value, "base64"), purpose).toString("utf8")));
50266
50784
  if (credential.controllerId !== controllerId) throw Error("FABRIC_WORKER_DENIED");
50267
50785
  return credential;
50268
50786
  };
50269
50787
  async function capability(workerId) {
50270
- const file2 = credentialFile(workerId), info = await lstat12(file2);
50788
+ const file3 = credentialFile(workerId), info = await lstat14(file3);
50271
50789
  if (!info.isFile() || info.isSymbolicLink() || info.size > 4096) throw Error("FABRIC_CREDENTIAL_UNKNOWN");
50272
- const encoded = await readFile10(file2, "utf8");
50790
+ const encoded = await readFile12(file3, "utf8");
50273
50791
  if (decode4(encoded).workerId !== workerId) throw Error("FABRIC_WORKER_DENIED");
50274
50792
  return encoded;
50275
50793
  }
@@ -50302,12 +50820,12 @@ async function openNativeFabric(stateDirectory, enrollment, box, initialize = tr
50302
50820
  } else {
50303
50821
  const credential = await service2.identities.issue();
50304
50822
  const encoded = box.seal(Buffer.from(JSON.stringify({ ...credential, workerId: worker.workerId, controllerId })), purpose).toString("base64");
50305
- const file2 = await open11(credentialFile(worker.workerId), "wx", 384);
50823
+ const file3 = await open12(credentialFile(worker.workerId), "wx", 384);
50306
50824
  try {
50307
- await file2.writeFile(encoded);
50308
- await file2.datasync();
50825
+ await file3.writeFile(encoded);
50826
+ await file3.datasync();
50309
50827
  } finally {
50310
- await file2.close();
50828
+ await file3.close();
50311
50829
  }
50312
50830
  await service2.mailbox.bindRuntime(worker.workerId, credential);
50313
50831
  }
@@ -50361,7 +50879,7 @@ async function readFabricRequest(input2 = process.stdin) {
50361
50879
 
50362
50880
  // agent/src/supervisor-liveness.ts
50363
50881
  import { spawn as spawn6 } from "node:child_process";
50364
- import path27 from "node:path";
50882
+ import path29 from "node:path";
50365
50883
  import { setTimeout as delay3 } from "node:timers/promises";
50366
50884
  var ROW = /^"([^"]+)","(\d{1,10})"/;
50367
50885
  function parseTasklist(output2, image) {
@@ -50376,7 +50894,7 @@ function parseTasklist(output2, image) {
50376
50894
  }
50377
50895
  function listProcesses(image, timeoutMs2 = 5e3) {
50378
50896
  if (process.platform !== "win32" || !/^[A-Za-z0-9._-]{1,64}\.exe$/i.test(image)) return Promise.resolve(null);
50379
- const tasklist = path27.join(process.env.SystemRoot || "C:\\Windows", "System32", "tasklist.exe");
50897
+ const tasklist = path29.join(process.env.SystemRoot || "C:\\Windows", "System32", "tasklist.exe");
50380
50898
  return new Promise((resolve) => {
50381
50899
  let output2 = "", settled = false;
50382
50900
  const finish = (value) => {
@@ -50405,8 +50923,8 @@ function listProcesses(image, timeoutMs2 = 5e3) {
50405
50923
  }
50406
50924
  function supervisorLiveness(helperPath, options = {}) {
50407
50925
  if (process.platform === "linux" && !options.list) return linuxSupervisorLiveness;
50408
- if (process.platform === "darwin" && !options.list) return (pids, _linux, darwin) => darwinSupervisorLiveness(path27.join(path27.dirname(helperPath), "posix-host"), pids, darwin);
50409
- const image = path27.basename(helperPath), waitMs = options.waitMs ?? 1e4, pollMs = options.pollMs ?? 500, list = options.list ?? listProcesses;
50926
+ if (process.platform === "darwin" && !options.list) return (pids, _linux, darwin) => darwinSupervisorLiveness(path29.join(path29.dirname(helperPath), "posix-host"), pids, darwin);
50927
+ const image = path29.basename(helperPath), waitMs = options.waitMs ?? 1e4, pollMs = options.pollMs ?? 500, list = options.list ?? listProcesses;
50410
50928
  return async (pids) => {
50411
50929
  const deadline = Date.now() + waitMs;
50412
50930
  for (; ; ) {
@@ -50421,17 +50939,17 @@ function supervisorLiveness(helperPath, options = {}) {
50421
50939
 
50422
50940
  // agent/src/content-audit.ts
50423
50941
  import { createReadStream } from "node:fs";
50424
- import { appendFile, lstat as lstat13, mkdir as mkdir13, open as open12, readdir as readdir6, readFile as readFile11, rename as rename8, rm as rm9, writeFile as writeFile4 } from "node:fs/promises";
50425
- import path28 from "node:path";
50942
+ import { appendFile, lstat as lstat15, mkdir as mkdir15, open as open13, readdir as readdir7, readFile as readFile13, rename as rename10, rm as rm11, writeFile as writeFile6 } from "node:fs/promises";
50943
+ import path30 from "node:path";
50426
50944
  import { performance as performance3 } from "node:perf_hooks";
50427
50945
  import { createInterface as createInterface2 } from "node:readline";
50428
50946
  import { randomBytes as randomBytes10 } from "node:crypto";
50429
50947
 
50430
50948
  // src/audit-crypto.ts
50431
50949
  import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, createHash as createHash20, randomBytes as randomBytes9 } from "node:crypto";
50432
- import { promisify as promisify3 } from "node:util";
50950
+ import { promisify as promisify4 } from "node:util";
50433
50951
  import { gunzipSync, gzip, gzipSync } from "node:zlib";
50434
- var gzipAsync = promisify3(gzip);
50952
+ var gzipAsync = promisify4(gzip);
50435
50953
  var AUDIT_ENCRYPTION_ALGORITHM = "A256GCM";
50436
50954
  var AUDIT_COMPRESSION = "gzip";
50437
50955
  var AUDIT_RECOVERY_KEY_PREFIX = "lca1_";
@@ -50589,19 +51107,19 @@ var AUDIT_MAX_BYTES = 512 * 1024 * 1024;
50589
51107
  var MAX_PENDING = 64;
50590
51108
  var FILE = /^(full|metrics)-(\d{4}-\d{2}-\d{2})\.jsonl$/;
50591
51109
  var PAUSED_FILE = "paused.json";
50592
- var DAY_MS = 864e5;
51110
+ var DAY_MS2 = 864e5;
50593
51111
  function contentAuditDirectory(stateDir) {
50594
- return path28.join(path28.dirname(path28.resolve(stateDir)), "Audit");
51112
+ return path30.join(path30.dirname(path30.resolve(stateDir)), "Audit");
50595
51113
  }
50596
51114
  async function plainDirectory(dir) {
50597
- await mkdir13(dir, { recursive: true, mode: 448 });
50598
- const info = await lstat13(dir);
51115
+ await mkdir15(dir, { recursive: true, mode: 448 });
51116
+ const info = await lstat15(dir);
50599
51117
  if (info.isSymbolicLink() || !info.isDirectory()) throw Error("AUDIT_DIRECTORY_INVALID");
50600
51118
  }
50601
51119
  async function auditFiles(dir) {
50602
51120
  let names;
50603
51121
  try {
50604
- names = await readdir6(dir);
51122
+ names = await readdir7(dir);
50605
51123
  } catch (error62) {
50606
51124
  if (error62.code === "ENOENT") return [];
50607
51125
  throw error62;
@@ -50610,18 +51128,18 @@ async function auditFiles(dir) {
50610
51128
  for (const name2 of names) {
50611
51129
  const match = FILE.exec(name2);
50612
51130
  if (!match) continue;
50613
- const info = await lstat13(path28.join(dir, name2));
51131
+ const info = await lstat15(path30.join(dir, name2));
50614
51132
  if (info.isFile()) files.push({ name: name2, kind: match[1], day: match[2], bytes: info.size });
50615
51133
  }
50616
51134
  return files.sort((a, b) => a.name.localeCompare(b.name));
50617
51135
  }
50618
- async function writeJsonAtomic(file2, value) {
50619
- const temp = `${file2}.${randomBytes10(6).toString("hex")}.tmp`;
51136
+ async function writeJsonAtomic(file3, value) {
51137
+ const temp = `${file3}.${randomBytes10(6).toString("hex")}.tmp`;
50620
51138
  try {
50621
- await writeFile4(temp, JSON.stringify(value) + "\n", { flag: "wx", mode: 384 });
50622
- await rename8(temp, file2);
51139
+ await writeFile6(temp, JSON.stringify(value) + "\n", { flag: "wx", mode: 384 });
51140
+ await rename10(temp, file3);
50623
51141
  } finally {
50624
- await rm9(temp, { force: true }).catch(() => {
51142
+ await rm11(temp, { force: true }).catch(() => {
50625
51143
  });
50626
51144
  }
50627
51145
  }
@@ -50648,7 +51166,7 @@ var ContentAudit = class _ContentAudit {
50648
51166
  skipped = 0;
50649
51167
  closed = false;
50650
51168
  static async open(options) {
50651
- const dir = path28.resolve(options.directory);
51169
+ const dir = path30.resolve(options.directory);
50652
51170
  await plainDirectory(dir);
50653
51171
  const audit = new _ContentAudit(
50654
51172
  dir,
@@ -50657,7 +51175,7 @@ var ContentAudit = class _ContentAudit {
50657
51175
  { retentionDays: options.retentionDays ?? AUDIT_RETENTION_DAYS, maxBytes: options.maxBytes ?? AUDIT_MAX_BYTES },
50658
51176
  options.now ?? (() => /* @__PURE__ */ new Date())
50659
51177
  );
50660
- await rm9(path28.join(dir, PAUSED_FILE), { force: true });
51178
+ await rm11(path30.join(dir, PAUSED_FILE), { force: true });
50661
51179
  await audit.rollover(audit.now());
50662
51180
  if (audit.usedBytes >= audit.limits.maxBytes) await audit.pause("QUOTA_EXCEEDED");
50663
51181
  return audit;
@@ -50727,25 +51245,25 @@ var ContentAudit = class _ContentAudit {
50727
51245
  await this.pause("QUOTA_EXCEEDED");
50728
51246
  return;
50729
51247
  }
50730
- await appendFile(path28.join(this.dir, `full-${day}.jsonl`), line, { mode: 384 });
50731
- await appendFile(path28.join(this.dir, `metrics-${day}.jsonl`), metrics, { mode: 384 });
51248
+ await appendFile(path30.join(this.dir, `full-${day}.jsonl`), line, { mode: 384 });
51249
+ await appendFile(path30.join(this.dir, `metrics-${day}.jsonl`), metrics, { mode: 384 });
50732
51250
  this.usedBytes += bytes3;
50733
51251
  }
50734
51252
  /** Daily retention runs on the first write of a new day; no timer or background scan. */
50735
51253
  async rollover(at) {
50736
51254
  this.day = at.toISOString().slice(0, 10);
50737
- const cutoff = new Date(at.getTime() - this.limits.retentionDays * DAY_MS).toISOString().slice(0, 10);
51255
+ const cutoff = new Date(at.getTime() - this.limits.retentionDays * DAY_MS2).toISOString().slice(0, 10);
50738
51256
  let used = 0;
50739
- for (const file2 of await auditFiles(this.dir)) {
50740
- if (file2.day <= cutoff) await rm9(path28.join(this.dir, file2.name), { force: true });
50741
- else used += file2.bytes;
51257
+ for (const file3 of await auditFiles(this.dir)) {
51258
+ if (file3.day <= cutoff) await rm11(path30.join(this.dir, file3.name), { force: true });
51259
+ else used += file3.bytes;
50742
51260
  }
50743
51261
  this.usedBytes = used;
50744
51262
  }
50745
51263
  async pause(reason) {
50746
51264
  if (this.paused) return;
50747
51265
  this.paused = reason;
50748
- await writeJsonAtomic(path28.join(this.dir, PAUSED_FILE), { reason, at: this.now().toISOString() });
51266
+ await writeJsonAtomic(path30.join(this.dir, PAUSED_FILE), { reason, at: this.now().toISOString() });
50749
51267
  }
50750
51268
  };
50751
51269
  function percentiles(values) {
@@ -50754,8 +51272,8 @@ function percentiles(values) {
50754
51272
  const at = (fraction) => sorted[Math.min(sorted.length - 1, Math.ceil(fraction * sorted.length) - 1)];
50755
51273
  return { p50: at(0.5), p95: at(0.95), max: sorted[sorted.length - 1] };
50756
51274
  }
50757
- async function* jsonLines(file2) {
50758
- const lines = createInterface2({ input: createReadStream(file2, { encoding: "utf8" }), crlfDelay: Infinity });
51275
+ async function* jsonLines(file3) {
51276
+ const lines = createInterface2({ input: createReadStream(file3, { encoding: "utf8" }), crlfDelay: Infinity });
50759
51277
  for await (const line of lines) {
50760
51278
  if (!line.trim()) continue;
50761
51279
  try {
@@ -50765,35 +51283,35 @@ async function* jsonLines(file2) {
50765
51283
  }
50766
51284
  }
50767
51285
  }
50768
- var count2 = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
51286
+ var count3 = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
50769
51287
  async function summarizeContentAudit(directory, key) {
50770
- const dir = path28.resolve(directory);
51288
+ const dir = path30.resolve(directory);
50771
51289
  const files = await auditFiles(dir);
50772
51290
  const days = /* @__PURE__ */ new Map();
50773
51291
  const sizes = [];
50774
51292
  const timings = [];
50775
- for (const file2 of files.filter((f) => f.kind === "metrics")) {
50776
- for await (const line of jsonLines(path28.join(dir, file2.name))) {
50777
- let day = days.get(file2.day);
51293
+ for (const file3 of files.filter((f) => f.kind === "metrics")) {
51294
+ for await (const line of jsonLines(path30.join(dir, file3.name))) {
51295
+ let day = days.get(file3.day);
50778
51296
  if (!day) {
50779
- day = { day: file2.day, records: 0, failed: 0, rawBytes: 0, sanitizedBytes: 0, compressedBytes: 0, envelopeBytes: 0 };
50780
- days.set(file2.day, day);
51297
+ day = { day: file3.day, records: 0, failed: 0, rawBytes: 0, sanitizedBytes: 0, compressedBytes: 0, envelopeBytes: 0 };
51298
+ days.set(file3.day, day);
50781
51299
  }
50782
51300
  day.records += 1;
50783
51301
  if (line.resultCode !== "SUCCESS") day.failed += 1;
50784
- day.rawBytes += count2(line.rawBytes);
50785
- day.sanitizedBytes += count2(line.sanitizedBytes);
50786
- day.compressedBytes += count2(line.compressedBytes);
50787
- day.envelopeBytes += count2(line.envelopeBytes);
51302
+ day.rawBytes += count3(line.rawBytes);
51303
+ day.sanitizedBytes += count3(line.sanitizedBytes);
51304
+ day.compressedBytes += count3(line.compressedBytes);
51305
+ day.envelopeBytes += count3(line.envelopeBytes);
50788
51306
  if (sizes.length < 1e5) {
50789
- sizes.push(count2(line.envelopeBytes));
50790
- timings.push(count2(line.encryptMs));
51307
+ sizes.push(count3(line.envelopeBytes));
51308
+ timings.push(count3(line.encryptMs));
50791
51309
  }
50792
51310
  }
50793
51311
  }
50794
51312
  let paused = null;
50795
51313
  try {
50796
- const value = JSON.parse(await readFile11(path28.join(dir, PAUSED_FILE), "utf8"));
51314
+ const value = JSON.parse(await readFile13(path30.join(dir, PAUSED_FILE), "utf8"));
50797
51315
  if (typeof value.reason === "string" && typeof value.at === "string") paused = { reason: value.reason.slice(0, 40), at: value.at.slice(0, 40) };
50798
51316
  } catch {
50799
51317
  }
@@ -50801,7 +51319,7 @@ async function summarizeContentAudit(directory, key) {
50801
51319
  const newest = files.filter((f) => f.kind === "full").at(-1);
50802
51320
  if (key && newest) {
50803
51321
  const tail = [];
50804
- for await (const line of jsonLines(path28.join(dir, newest.name))) {
51322
+ for await (const line of jsonLines(path30.join(dir, newest.name))) {
50805
51323
  tail.push(line);
50806
51324
  if (tail.length > 5) tail.shift();
50807
51325
  }
@@ -50819,7 +51337,7 @@ async function summarizeContentAudit(directory, key) {
50819
51337
  const rawBytes = total("rawBytes"), envelopeBytes = total("envelopeBytes");
50820
51338
  return {
50821
51339
  directory: dir,
50822
- fileBytes: files.reduce((sum, file2) => sum + file2.bytes, 0),
51340
+ fileBytes: files.reduce((sum, file3) => sum + file3.bytes, 0),
50823
51341
  paused,
50824
51342
  records: total("records"),
50825
51343
  rawBytes,
@@ -50835,10 +51353,10 @@ async function summarizeContentAudit(directory, key) {
50835
51353
  };
50836
51354
  }
50837
51355
  async function restoreContentAudit(input2, output2, key) {
50838
- const handle = await open12(path28.resolve(output2), "wx", 384);
51356
+ const handle = await open13(path30.resolve(output2), "wx", 384);
50839
51357
  let records = 0, failed = 0;
50840
51358
  try {
50841
- for await (const line of jsonLines(path28.resolve(input2))) {
51359
+ for await (const line of jsonLines(path30.resolve(input2))) {
50842
51360
  try {
50843
51361
  await handle.appendFile(JSON.stringify(decryptAuditRecord(line, key)) + "\n");
50844
51362
  records += 1;
@@ -50853,7 +51371,7 @@ async function restoreContentAudit(input2, output2, key) {
50853
51371
  }
50854
51372
 
50855
51373
  // agent/src/main.ts
50856
- var AGENT_VERSION2 = true ? "0.3.50" : "0.3.2";
51374
+ var AGENT_VERSION2 = true ? "0.3.52" : "0.3.2";
50857
51375
  var NETWORK_PUBLIC_KEY = true ? "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvmu+81vWtJBQDZNHcAIW\nzCSxpG+R9RBsum2df5mP2cOW+wyUDTpnYquFge1qgI5YYTF96j0xCyXL8B9FeNWs\n939opWNmv53j+CQlS4cEIQhBbZSCu0eC4icsVEzBhvf68MB+E668SOtZBcVTEnyh\n96PTcupxS10rQJBWDinbKBXRC2gvGYeu01rWa/nsrndy4vAYP5t3yQtdOC8e8mr0\n+2Mg2Qhiq+KiTCtDd+L9oXvoLqqJYbzUIveNGha25AWxF1Weblp0gOM87hell5gV\nK7q4ZLUq/wBRGYNmQRdLyV7/WRE1FFPSW21/SBZQ/5aU4UqJU/MjMcrJUrnRKngz\nYKmo0czkxS3N7Q2KVxomgR1AQSuQFKMrboZYKjShADp9RIYUxzs7cYg51Of5PnHh\n6Ax+VevDGfzjMD+yHuyxYZqCtX4OwgolJxz63UQbzKlris+8xb5lLYTbIuz90Pss\nn6HK/F5May25c6oMmS3nh/NsiZopL1OvdtWKTt1L4WlRAgMBAAE=\n-----END PUBLIC KEY-----\n" : "";
50858
51376
  var AI_CONNECTION_SHIPPED = false;
50859
51377
  var QUARANTINE_RETRY_MS = 6e4;
@@ -50867,11 +51385,11 @@ function processAlive(pid) {
50867
51385
  }
50868
51386
  }
50869
51387
  async function claimAgentProcess(stateDir, runtimeDir, version2) {
50870
- await mkdir14(stateDir, { recursive: true });
50871
- const file2 = path29.join(stateDir, "agent-process.json");
51388
+ await mkdir16(stateDir, { recursive: true });
51389
+ const file3 = path31.join(stateDir, "agent-process.json");
50872
51390
  for (let attempt = 0; attempt < 2; attempt += 1) {
50873
51391
  try {
50874
- const handle = await open13(file2, "wx", 384);
51392
+ const handle = await open14(file3, "wx", 384);
50875
51393
  try {
50876
51394
  await handle.writeFile(JSON.stringify({ pid: process.pid, runtimeDir, version: version2, startedAt: (/* @__PURE__ */ new Date()).toISOString() }) + "\n", "utf8");
50877
51395
  } finally {
@@ -50879,8 +51397,8 @@ async function claimAgentProcess(stateDir, runtimeDir, version2) {
50879
51397
  }
50880
51398
  return async () => {
50881
51399
  try {
50882
- const current2 = JSON.parse(await readFile12(file2, "utf8"));
50883
- if (current2.pid === process.pid) await rm10(file2, { force: true });
51400
+ const current2 = JSON.parse(await readFile14(file3, "utf8"));
51401
+ if (current2.pid === process.pid) await rm12(file3, { force: true });
50884
51402
  } catch {
50885
51403
  }
50886
51404
  };
@@ -50888,12 +51406,12 @@ async function claimAgentProcess(stateDir, runtimeDir, version2) {
50888
51406
  if (!error62 || typeof error62 !== "object" || !("code" in error62) || error62.code !== "EEXIST") throw error62;
50889
51407
  let stale = true;
50890
51408
  try {
50891
- const current2 = JSON.parse(await readFile12(file2, "utf8"));
51409
+ const current2 = JSON.parse(await readFile14(file3, "utf8"));
50892
51410
  stale = typeof current2.pid !== "number" || !processAlive(current2.pid);
50893
51411
  } catch {
50894
51412
  }
50895
51413
  if (!stale) throw Error("AGENT_ALREADY_RUNNING");
50896
- await rm10(file2, { force: true });
51414
+ await rm12(file3, { force: true });
50897
51415
  }
50898
51416
  }
50899
51417
  throw Error("AGENT_ALREADY_RUNNING");
@@ -51016,6 +51534,8 @@ async function runAgent(options) {
51016
51534
  safeSlots: runtime.status().safeSlots,
51017
51535
  status: () => runtime.status(),
51018
51536
  onIncidentAck: (ack) => incidentProducer.ack(ack),
51537
+ onFullLogChoice: options.onFullLogChoice,
51538
+ ...options.tokenUsage ? { onTokenUsageState: (enabled) => options.tokenUsage.state(enabled), onTokenUsageAck: (batchId, result2) => options.tokenUsage.ack(batchId, result2) } : {},
51019
51539
  // After bridge.connected, like requests: the journal has recorded this connection first.
51020
51540
  onHeldLeases: (bindings) => {
51021
51541
  void readyPromise.then(() => bridge.heldLeases(bindings)).catch(() => {
@@ -51049,6 +51569,7 @@ async function runAgent(options) {
51049
51569
  await options.journal.prune();
51050
51570
  connection.reportStatus?.();
51051
51571
  incidentProducer.connected(connection.sendIncidentBatch);
51572
+ options.tokenUsage?.connected(connection.sendTokenUsageBatch);
51052
51573
  supervisor.observe({ kind: "connected" });
51053
51574
  monitor(() => options.monitor?.setConnection("connected", connection));
51054
51575
  if (options.monitor && !connection.monitorFreshnessMs) {
@@ -51104,8 +51625,13 @@ async function runAgent(options) {
51104
51625
  clearInterval(legacyMonitorTimer);
51105
51626
  legacyMonitorTimer = void 0;
51106
51627
  incidentProducer.disconnected();
51628
+ options.tokenUsage?.disconnected();
51107
51629
  if (!options.signal.aborted) supervisor.observe({ kind: "disconnected" });
51108
51630
  monitor(() => options.monitor?.setConnection("disconnected"));
51631
+ try {
51632
+ options.onFullLogChoice?.(null);
51633
+ } catch {
51634
+ }
51109
51635
  connection?.close("agent_disconnect");
51110
51636
  await bridge.disconnected();
51111
51637
  connection = null;
@@ -51120,6 +51646,7 @@ async function runAgent(options) {
51120
51646
  } finally {
51121
51647
  fabric?.close();
51122
51648
  incidentProducer.close();
51649
+ options.tokenUsage?.close();
51123
51650
  supervisor.close();
51124
51651
  await options.journal.close();
51125
51652
  }
@@ -51146,10 +51673,10 @@ async function openContentAudit(store, stateDir) {
51146
51673
  async function main() {
51147
51674
  if (!["win32", "linux", "darwin"].includes(process.platform)) throw Error("PLATFORM_UNSUPPORTED");
51148
51675
  const appData = process.env.LC_AGENT_DATA_DIR ?? (process.platform === "win32" ? process.env.LOCALAPPDATA : posixDataHome());
51149
- if (!appData || !path29.isAbsolute(appData)) throw Error("APP_DATA_MISSING");
51150
- const stateDir = process.env.LC_AGENT_STATE_DIR ?? path29.join(appData, "LocalCommander", "Agent");
51151
- const binaryDir = path29.dirname(process.platform === "win32" ? process.execPath : await realpath10(process.execPath));
51152
- const ownerBridgePath = process.env.LC_OWNER_BRIDGE ?? path29.join(binaryDir, process.platform === "win32" ? "OwnerBridge.exe" : "owner-store");
51676
+ if (!appData || !path31.isAbsolute(appData)) throw Error("APP_DATA_MISSING");
51677
+ const stateDir = process.env.LC_AGENT_STATE_DIR ?? path31.join(appData, "LocalCommander", "Agent");
51678
+ const binaryDir = path31.dirname(process.platform === "win32" ? process.execPath : await realpath10(process.execPath));
51679
+ const ownerBridgePath = process.env.LC_OWNER_BRIDGE ?? path31.join(binaryDir, process.platform === "win32" ? "OwnerBridge.exe" : "owner-store");
51153
51680
  const store = await WindowsPrivateStore.open(stateDir, ownerBridgePath);
51154
51681
  const command = process.argv[2] ?? "run";
51155
51682
  if (process.platform !== "win32" && (command.startsWith("guard-") || command.startsWith("network-"))) throw Error("FEATURE_PLATFORM_UNSUPPORTED");
@@ -51159,7 +51686,7 @@ async function main() {
51159
51686
  const pairing = new PairingClient(store, { controlPlaneOrigin: origin, agentVersion: AGENT_VERSION2 });
51160
51687
  const begun = await pairing.begin();
51161
51688
  process.stdout.write(JSON.stringify({ approvalUrl: begun.approvalUrl, confirmationCode: begun.confirmationCode, expiresAt: begun.expiresAt.toISOString() }) + "\n");
51162
- await pairing.waitAndComplete(begun, os8.hostname().slice(0, 120));
51689
+ await pairing.waitAndComplete(begun, os9.hostname().slice(0, 120));
51163
51690
  process.stdout.write("DEVICE_PAIRED\n");
51164
51691
  return;
51165
51692
  }
@@ -51168,7 +51695,8 @@ async function main() {
51168
51695
  process.stdout.write(JSON.stringify({
51169
51696
  paired: !!identity?.enrollment,
51170
51697
  accountEmail: identity?.enrollment?.accountEmail ?? null,
51171
- deviceId: identity?.enrollment?.deviceId ?? null
51698
+ deviceId: identity?.enrollment?.deviceId ?? null,
51699
+ fullLogs: await readFullLogNotice(stateDir, identity?.enrollment)
51172
51700
  }) + "\n");
51173
51701
  return;
51174
51702
  }
@@ -51244,7 +51772,7 @@ async function main() {
51244
51772
  }
51245
51773
  if (command === "efficiency-report") {
51246
51774
  if (args.length) throw Error("AGENT_COMMAND_INVALID");
51247
- const ledger = await OptimizationLedger.open(path29.join(stateDir, "optimization"));
51775
+ const ledger = await OptimizationLedger.open(path31.join(stateDir, "optimization"));
51248
51776
  try {
51249
51777
  process.stdout.write(JSON.stringify(await ledger.report(), null, 2) + "\n");
51250
51778
  } finally {
@@ -51254,7 +51782,7 @@ async function main() {
51254
51782
  }
51255
51783
  if (command === "guard-configure") {
51256
51784
  if (args.length !== 1) throw Error("AGENT_COMMAND_INVALID");
51257
- const filename = await (await import("node:fs/promises")).realpath(path29.resolve(args[0]));
51785
+ const filename = await (await import("node:fs/promises")).realpath(path31.resolve(args[0]));
51258
51786
  const input2 = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(await readWindowsFile(ownerBridgePath, filename, 2e5)));
51259
51787
  if (!input2 || typeof input2 !== "object" || Object.keys(input2).sort().join(",") !== "compact,settings") throw Error("GUARD_CONFIGURATION_INVALID");
51260
51788
  await store.configureGuard(input2.settings, input2.compact);
@@ -51273,7 +51801,7 @@ async function main() {
51273
51801
  }
51274
51802
  if (command === "guard-evidence") {
51275
51803
  if (args.length) throw Error("AGENT_COMMAND_INVALID");
51276
- const journal = await NativeJournal.open(path29.join(stateDir, "journal"), new SecretBox({ "1": await store.loadDataKey() }));
51804
+ const journal = await NativeJournal.open(path31.join(stateDir, "journal"), new SecretBox({ "1": await store.loadDataKey() }));
51277
51805
  try {
51278
51806
  process.stdout.write(JSON.stringify(await journal.guardEvidence()) + "\n");
51279
51807
  } finally {
@@ -51285,7 +51813,7 @@ async function main() {
51285
51813
  if (args.length !== (command === "guard-export" ? 0 : 1)) throw Error("AGENT_COMMAND_INVALID");
51286
51814
  const identity = await store.load();
51287
51815
  if (!identity?.enrollment) throw Error("ENROLLMENT_MISSING");
51288
- const journal = await NativeJournal.open(path29.join(stateDir, "journal"), new SecretBox({ "1": await store.loadDataKey() }));
51816
+ const journal = await NativeJournal.open(path31.join(stateDir, "journal"), new SecretBox({ "1": await store.loadDataKey() }));
51289
51817
  try {
51290
51818
  const { tenantId, deviceId } = identity.enrollment;
51291
51819
  const records = (await journal.guardEvidence()).filter((record2) => record2.tenantId === tenantId && record2.deviceId === deviceId);
@@ -51363,33 +51891,40 @@ async function main() {
51363
51891
  if (args.length) throw Error("AGENT_COMMAND_INVALID");
51364
51892
  if (!(await store.load())?.enrollment) throw Error("ENROLLMENT_MISSING");
51365
51893
  const releaseProcess = await claimAgentProcess(stateDir, binaryDir, AGENT_VERSION2);
51366
- const monitor = new ProductionMonitor(path29.join(appData, "LocalCommander", "Monitor"), stateDir, AGENT_VERSION2);
51894
+ const monitor = new ProductionMonitor(path31.join(appData, "LocalCommander", "Monitor"), stateDir, AGENT_VERSION2);
51367
51895
  const publishMonitor = () => monitor.flush().catch(() => {
51368
51896
  process.stderr.write("MONITOR_WRITE_FAILED\n");
51369
51897
  });
51370
51898
  await publishMonitor();
51371
51899
  try {
51372
51900
  const journal = await NativeJournal.open(
51373
- path29.join(stateDir, "journal"),
51901
+ path31.join(stateDir, "journal"),
51374
51902
  new SecretBox({ "1": await store.loadDataKey() }),
51375
- process.platform === "win32" ? {} : { lockHelper: path29.join(binaryDir, "posix-host") }
51903
+ process.platform === "win32" ? {} : { lockHelper: path31.join(binaryDir, "posix-host") }
51376
51904
  );
51377
51905
  const ledgerLoss = () => {
51378
51906
  process.stderr.write("OPTIMIZATION_TELEMETRY_INCOMPLETE\n");
51379
51907
  };
51380
51908
  const efficiencyLedger = await new OptionalWork(ledgerLoss, 1e3, 1).run(
51381
- () => OptimizationLedger.open(path29.join(stateDir, "optimization")),
51909
+ () => OptimizationLedger.open(path31.join(stateDir, "optimization")),
51382
51910
  void 0,
51383
51911
  (ledger) => ledger.close()
51384
51912
  );
51385
51913
  try {
51386
- const helperPath = process.env.LC_JOB_HOST ?? path29.join(binaryDir, process.platform === "win32" ? "JobHost.exe" : "job-host.mjs");
51914
+ const helperPath = process.env.LC_JOB_HOST ?? path31.join(binaryDir, process.platform === "win32" ? "JobHost.exe" : "job-host.mjs");
51387
51915
  const tools = new NativeTools({ stateDirectory: stateDir, helperPath, ownerBridgePath, programs: await store.loadPrograms() });
51388
51916
  const stop = new AbortController();
51389
51917
  process.once("SIGINT", () => stop.abort());
51390
51918
  process.once("SIGTERM", () => stop.abort());
51391
51919
  const guard = await NativeGuard.open(store, journal);
51392
51920
  const enrollment = (await store.load()).enrollment;
51921
+ const fullLogNotice = new FullLogNotice(stateDir, enrollment);
51922
+ const onFullLogChoice = (enabled) => {
51923
+ void fullLogNotice.update(enabled).catch(() => {
51924
+ });
51925
+ };
51926
+ onFullLogChoice(null);
51927
+ const tokenUsage = process.env.LC_TOKEN_USAGE === "off" ? void 0 : new TokenUsageReporter(stateDir, enrollment);
51393
51928
  const fabric = await openNativeFabric(stateDir, enrollment, new SecretBox({ "1": await store.loadDataKey() })).catch(() => {
51394
51929
  process.stderr.write("FABRIC_STARTUP_FAILED\n");
51395
51930
  return void 0;
@@ -51418,6 +51953,8 @@ async function main() {
51418
51953
  guard,
51419
51954
  efficiencyLedger,
51420
51955
  monitor,
51956
+ onFullLogChoice,
51957
+ ...tokenUsage ? { tokenUsage } : {},
51421
51958
  localDirect: { key: localDirectKey(await store.loadDataKey()), directory: localDirectDirectory(appData) },
51422
51959
  supervisorLiveness: supervisorLiveness(helperPath),
51423
51960
  ...proxyMode ? { proxyMode: { providers: proxyMode.providers, publicKeyPem: NETWORK_PUBLIC_KEY, endpoint: proxyEndpoint, onState: onProxyState } } : {},
@@ -51454,7 +51991,7 @@ async function main() {
51454
51991
  await releaseProcess();
51455
51992
  }
51456
51993
  }
51457
- var entrypoint = process.argv[1] && (process.platform === "win32" ? path29.resolve(process.argv[1]) : await realpath10(process.argv[1]).catch(() => null));
51994
+ var entrypoint = process.argv[1] && (process.platform === "win32" ? path31.resolve(process.argv[1]) : await realpath10(process.argv[1]).catch(() => null));
51458
51995
  if (entrypoint === fileURLToPath(import.meta.url)) {
51459
51996
  void main().catch((error62) => {
51460
51997
  const code = error62 instanceof Error && /^[A-Z0-9_]{1,64}$/.test(error62.message) ? error62.message : "AGENT_START_FAILED";