lody 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +855 -782
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -6,8 +6,8 @@ import path__default, { normalize as normalize$1, resolve as resolve$1, parse as
6
6
  import * as os$1 from "os";
7
7
  import os__default from "os";
8
8
  import require$$3$4, { randomUUID as randomUUID$1, createHash as createHash$1, randomBytes as randomBytes$1 } from "crypto";
9
- import require$$1$8, { execSync, exec, execFileSync, execFile as execFile$1 } from "child_process";
10
- import require$$0$5, { inspect as inspect$1, types as types$6 } from "util";
9
+ import require$$1$8, { execFile as execFile$1, exec } from "child_process";
10
+ import require$$0$5, { inspect as inspect$1, types as types$6, promisify as promisify$1 } from "util";
11
11
  import require$$2$6 from "url";
12
12
  import * as moduleModule from "module";
13
13
  import moduleModule__default, { createRequire } from "module";
@@ -3921,7 +3921,7 @@ let __tla = Promise.all([
3921
3921
  const hasOwnProperty = objectProto.hasOwnProperty;
3922
3922
  const symToStringTag = Symbol ? Symbol.toStringTag : void 0;
3923
3923
  const nativeObjectToString = objectProto.toString;
3924
- function isPlainObject$7(value) {
3924
+ function isPlainObject$6(value) {
3925
3925
  if (!isObjectLike$1(value) || baseGetTag(value) !== objectTag) {
3926
3926
  return false;
3927
3927
  }
@@ -4067,7 +4067,7 @@ let __tla = Promise.all([
4067
4067
  return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "undefined" || value instanceof Date || value instanceof RegExp || value === null;
4068
4068
  }
4069
4069
  function shouldMerge(one, two) {
4070
- if (!isPlainObject$7(one) || !isPlainObject$7(two)) {
4070
+ if (!isPlainObject$6(one) || !isPlainObject$6(two)) {
4071
4071
  return false;
4072
4072
  }
4073
4073
  return true;
@@ -8394,7 +8394,7 @@ Error:`, e);
8394
8394
  function isPrimitive(wat) {
8395
8395
  return wat === null || isParameterizedString(wat) || typeof wat !== "object" && typeof wat !== "function";
8396
8396
  }
8397
- function isPlainObject$6(wat) {
8397
+ function isPlainObject$5(wat) {
8398
8398
  return isBuiltin(wat, "Object");
8399
8399
  }
8400
8400
  function isEvent(wat) {
@@ -8410,7 +8410,7 @@ Error:`, e);
8410
8410
  return Boolean(wat?.then && typeof wat.then === "function");
8411
8411
  }
8412
8412
  function isSyntheticEvent(wat) {
8413
- return isPlainObject$6(wat) && "nativeEvent" in wat && "preventDefault" in wat && "stopPropagation" in wat;
8413
+ return isPlainObject$5(wat) && "nativeEvent" in wat && "preventDefault" in wat && "stopPropagation" in wat;
8414
8414
  }
8415
8415
  function isInstanceOf(wat, base) {
8416
8416
  try {
@@ -9138,7 +9138,7 @@ Error:`, e);
9138
9138
  return this;
9139
9139
  }
9140
9140
  const scopeToMerge = typeof captureContext === "function" ? captureContext(this) : captureContext;
9141
- const scopeInstance = scopeToMerge instanceof Scope ? scopeToMerge.getScopeData() : isPlainObject$6(scopeToMerge) ? captureContext : void 0;
9141
+ const scopeInstance = scopeToMerge instanceof Scope ? scopeToMerge.getScopeData() : isPlainObject$5(scopeToMerge) ? captureContext : void 0;
9142
9142
  const { tags, attributes, extra, user, contexts, level, fingerprint = [], propagationContext, conversationId } = scopeInstance || {};
9143
9143
  this._tags = {
9144
9144
  ...this._tags,
@@ -12891,14 +12891,14 @@ Reason: ${reason}`);
12891
12891
  const invalidValueError = `${beforeSendLabel} must return \`null\` or a valid event.`;
12892
12892
  if (isThenable(beforeSendResult)) {
12893
12893
  return beforeSendResult.then((event) => {
12894
- if (!isPlainObject$6(event) && event !== null) {
12894
+ if (!isPlainObject$5(event) && event !== null) {
12895
12895
  throw _makeInternalError(invalidValueError);
12896
12896
  }
12897
12897
  return event;
12898
12898
  }, (e) => {
12899
12899
  throw _makeInternalError(`${beforeSendLabel} rejected with ${e}`);
12900
12900
  });
12901
- } else if (!isPlainObject$6(beforeSendResult) && beforeSendResult !== null) {
12901
+ } else if (!isPlainObject$5(beforeSendResult) && beforeSendResult !== null) {
12902
12902
  throw _makeInternalError(invalidValueError);
12903
12903
  }
12904
12904
  return beforeSendResult;
@@ -13121,7 +13121,7 @@ Reason: ${reason}`);
13121
13121
  ];
13122
13122
  }
13123
13123
  mechanism.synthetic = true;
13124
- if (isPlainObject$6(exception)) {
13124
+ if (isPlainObject$5(exception)) {
13125
13125
  const normalizeDepth = client?.getOptions().normalizeDepth;
13126
13126
  const extras = {
13127
13127
  ["__serialized__"]: normalizeToSize(exception, normalizeDepth)
@@ -36826,7 +36826,7 @@ Mongoose Error Code: ${error2.code}` : ""}`
36826
36826
  return client;
36827
36827
  }
36828
36828
  const name$1 = "lody";
36829
- const version$4 = "0.56.0";
36829
+ const version$4 = "0.57.0";
36830
36830
  const description$1 = "Lody Agent CLI tool for managing remote command execution";
36831
36831
  const type$2 = "module";
36832
36832
  const main$4 = "dist/index.js";
@@ -37780,11 +37780,11 @@ Task description:
37780
37780
  }
37781
37781
  function isDraftable(value) {
37782
37782
  if (!value) return false;
37783
- return isPlainObject$5(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!value.constructor?.[DRAFTABLE] || isMap(value) || isSet(value);
37783
+ return isPlainObject$4(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!value.constructor?.[DRAFTABLE] || isMap(value) || isSet(value);
37784
37784
  }
37785
37785
  var objectCtorString = Object.prototype.constructor.toString();
37786
37786
  var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
37787
- function isPlainObject$5(value) {
37787
+ function isPlainObject$4(value) {
37788
37788
  if (!value || typeof value !== "object") return false;
37789
37789
  const proto2 = Object.getPrototypeOf(value);
37790
37790
  if (proto2 === null || proto2 === Object.prototype) return true;
@@ -37846,7 +37846,7 @@ Task description:
37846
37846
  return new Set(base);
37847
37847
  }
37848
37848
  if (Array.isArray(base)) return Array.prototype.slice.call(base);
37849
- const isPlain = isPlainObject$5(base);
37849
+ const isPlain = isPlainObject$4(base);
37850
37850
  if (strict === true || strict === "class_only" && !isPlain) {
37851
37851
  const descriptors = Object.getOwnPropertyDescriptors(base);
37852
37852
  delete descriptors[DRAFT_STATE];
@@ -41407,7 +41407,7 @@ Task description:
41407
41407
  return false;
41408
41408
  }
41409
41409
  });
41410
- function isPlainObject$4(o) {
41410
+ function isPlainObject$3(o) {
41411
41411
  if (isObject$3(o) === false) return false;
41412
41412
  const ctor = o.constructor;
41413
41413
  if (ctor === void 0) return true;
@@ -41420,7 +41420,7 @@ Task description:
41420
41420
  return true;
41421
41421
  }
41422
41422
  function shallowClone(o) {
41423
- if (isPlainObject$4(o)) return {
41423
+ if (isPlainObject$3(o)) return {
41424
41424
  ...o
41425
41425
  };
41426
41426
  if (Array.isArray(o)) return [
@@ -41536,7 +41536,7 @@ Task description:
41536
41536
  return clone$2(schema2, def);
41537
41537
  }
41538
41538
  function extend$2(schema2, shape) {
41539
- if (!isPlainObject$4(shape)) {
41539
+ if (!isPlainObject$3(shape)) {
41540
41540
  throw new Error("Invalid input to extend: expected a plain object");
41541
41541
  }
41542
41542
  const checks = schema2._zod.def.checks;
@@ -41562,7 +41562,7 @@ Task description:
41562
41562
  return clone$2(schema2, def);
41563
41563
  }
41564
41564
  function safeExtend(schema2, shape) {
41565
- if (!isPlainObject$4(shape)) {
41565
+ if (!isPlainObject$3(shape)) {
41566
41566
  throw new Error("Invalid input to safeExtend: expected a plain object");
41567
41567
  }
41568
41568
  const def = mergeDefs(schema2._zod.def, {
@@ -43320,7 +43320,7 @@ Task description:
43320
43320
  data: a
43321
43321
  };
43322
43322
  }
43323
- if (isPlainObject$4(a) && isPlainObject$4(b)) {
43323
+ if (isPlainObject$3(a) && isPlainObject$3(b)) {
43324
43324
  const bKeys = Object.keys(b);
43325
43325
  const sharedKeys = Object.keys(a).filter((key2) => bKeys.indexOf(key2) !== -1);
43326
43326
  const newObj = {
@@ -43423,7 +43423,7 @@ Task description:
43423
43423
  $ZodType.init(inst, def);
43424
43424
  inst._zod.parse = (payload, ctx) => {
43425
43425
  const input2 = payload.value;
43426
- if (!isPlainObject$4(input2)) {
43426
+ if (!isPlainObject$3(input2)) {
43427
43427
  payload.issues.push({
43428
43428
  expected: "record",
43429
43429
  code: "invalid_type",
@@ -51112,6 +51112,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51112
51112
  parsedItemsByEntryIndex;
51113
51113
  toolCallEntryIndexById = /* @__PURE__ */ new Map();
51114
51114
  touchedAssistantEntryIndices = /* @__PURE__ */ new Set();
51115
+ changed = false;
51115
51116
  apply(notifications) {
51116
51117
  if (notifications.length === 0) {
51117
51118
  return this.history;
@@ -51131,6 +51132,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51131
51132
  this.postProcessTouchedAssistantEntries();
51132
51133
  return this.history;
51133
51134
  }
51135
+ hasChanges() {
51136
+ return this.changed;
51137
+ }
51134
51138
  primeToolCallIndexForBatch(notifications) {
51135
51139
  const unresolved = /* @__PURE__ */ new Set();
51136
51140
  for (const notification of notifications) {
@@ -51191,6 +51195,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51191
51195
  const items2 = Array.isArray(rawItems) ? rawItems : [];
51192
51196
  if (!Array.isArray(rawItems)) {
51193
51197
  entry2.items = items2;
51198
+ this.changed = true;
51194
51199
  }
51195
51200
  this.parsedItemsByEntryIndex[entryIndex] = items2;
51196
51201
  return items2;
@@ -51202,6 +51207,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51202
51207
  this.ensureEntryItems(lastIndex);
51203
51208
  if (!last2.modelInfo && this.model) {
51204
51209
  last2.modelInfo = this.model;
51210
+ this.changed = true;
51205
51211
  }
51206
51212
  return lastIndex;
51207
51213
  }
@@ -51216,6 +51222,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51216
51222
  fileDiff: []
51217
51223
  });
51218
51224
  this.parsedItemsByEntryIndex.push([]);
51225
+ this.changed = true;
51219
51226
  return this.history.length - 1;
51220
51227
  }
51221
51228
  applyMessageContent(message) {
@@ -51262,6 +51269,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51262
51269
  const entry2 = this.history[entryIndex];
51263
51270
  if (!entry2) return;
51264
51271
  entry2.plan = entries;
51272
+ this.changed = true;
51265
51273
  }
51266
51274
  appendOrMergeAdjacentText(entryIndex, kind, delta) {
51267
51275
  if (!delta) return;
@@ -51273,6 +51281,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51273
51281
  if (!text) {
51274
51282
  items2.pop();
51275
51283
  this.touchedAssistantEntryIndices.add(entryIndex);
51284
+ this.changed = true;
51276
51285
  return;
51277
51286
  }
51278
51287
  items2[items2.length - 1] = {
@@ -51280,6 +51289,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51280
51289
  text
51281
51290
  };
51282
51291
  this.touchedAssistantEntryIndices.add(entryIndex);
51292
+ this.changed = true;
51283
51293
  return;
51284
51294
  }
51285
51295
  items2.push({
@@ -51287,6 +51297,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51287
51297
  text: delta
51288
51298
  });
51289
51299
  this.touchedAssistantEntryIndices.add(entryIndex);
51300
+ this.changed = true;
51290
51301
  }
51291
51302
  upsertSingletonItem(entryIndex, type2, next2) {
51292
51303
  const entry2 = this.history[entryIndex];
@@ -51295,6 +51306,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51295
51306
  const last2 = items2[items2.length - 1];
51296
51307
  if (last2 && last2.type === type2) {
51297
51308
  items2[items2.length - 1] = next2;
51309
+ this.changed = true;
51298
51310
  return;
51299
51311
  }
51300
51312
  const withoutType = items2.filter((m) => m.type !== type2);
@@ -51302,6 +51314,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51302
51314
  const compacted = compactAdjacentTextAndThought(withoutType);
51303
51315
  entry2.items = compacted;
51304
51316
  this.parsedItemsByEntryIndex[entryIndex] = compacted;
51317
+ this.changed = true;
51305
51318
  }
51306
51319
  upsertProposedPlanItem(entryIndex, next2) {
51307
51320
  const entry2 = this.history[entryIndex];
@@ -51310,12 +51323,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51310
51323
  const existingIndex = items2.findIndex((item) => item.type === "proposed_plan" && item.turnId === next2.turnId);
51311
51324
  if (existingIndex >= 0) {
51312
51325
  items2[existingIndex] = next2;
51326
+ this.changed = true;
51313
51327
  return;
51314
51328
  }
51315
51329
  items2.push(next2);
51316
51330
  const compacted = compactAdjacentTextAndThought(items2);
51317
51331
  entry2.items = compacted;
51318
51332
  this.parsedItemsByEntryIndex[entryIndex] = compacted;
51333
+ this.changed = true;
51319
51334
  }
51320
51335
  upsertToolCall(entryIndex, incoming) {
51321
51336
  const entry2 = this.history[entryIndex];
@@ -51325,6 +51340,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51325
51340
  if (toolIndex >= 0) {
51326
51341
  const prevTool = items2[toolIndex];
51327
51342
  items2[toolIndex] = mergeToolCallMessage(prevTool, incoming);
51343
+ this.changed = true;
51328
51344
  return;
51329
51345
  }
51330
51346
  items2.push({
@@ -51334,6 +51350,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51334
51350
  kind: incoming.kind ?? void 0
51335
51351
  }) : void 0
51336
51352
  });
51353
+ this.changed = true;
51337
51354
  }
51338
51355
  postProcessTouchedAssistantEntries() {
51339
51356
  for (const entryIndex of this.touchedAssistantEntryIndices) {
@@ -51364,6 +51381,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51364
51381
  const compacted = compactAdjacentTextAndThought(newItems);
51365
51382
  entry2.items = compacted;
51366
51383
  this.parsedItemsByEntryIndex[entryIndex] = compacted;
51384
+ this.changed = true;
51367
51385
  }
51368
51386
  }
51369
51387
  }
@@ -51371,6 +51389,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51371
51389
  const applyNotificationOnHistory = (history, notifications, model, options = {}) => {
51372
51390
  return new NotificationOnHistoryApplier(history, options, model).apply(notifications);
51373
51391
  };
51392
+ const applyNotificationOnHistoryWithChange = (history, notifications, model, options = {}) => {
51393
+ const applier = new NotificationOnHistoryApplier(history, options, model);
51394
+ const nextHistory = applier.apply(notifications);
51395
+ return {
51396
+ history: nextHistory,
51397
+ changed: applier.hasChanges()
51398
+ };
51399
+ };
51374
51400
  const applyMessageContentsBatch = (history, messages, options = {}) => {
51375
51401
  if (messages.length === 0) {
51376
51402
  return history;
@@ -51678,15 +51704,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
51678
51704
  lastWasUserChunk = true;
51679
51705
  continue;
51680
51706
  }
51681
- const beforeLength = history.length;
51682
- const beforeSnapshot = JSON.stringify(history);
51683
- history = applyNotificationOnHistory(history, [
51707
+ const applied = applyNotificationOnHistoryWithChange(history, [
51684
51708
  notification
51685
51709
  ], void 0, {
51686
51710
  createId,
51687
51711
  now: now2
51688
51712
  });
51689
- if (history.length === beforeLength && JSON.stringify(history) === beforeSnapshot) {
51713
+ history = applied.history;
51714
+ if (!applied.changed) {
51690
51715
  const updateType = notification.update.sessionUpdate;
51691
51716
  if (updateType !== "session_info_update" && updateType !== "current_mode_update" && updateType !== "config_option_update" && updateType !== "usage_update" && updateType !== "available_commands_update") {
51692
51717
  droppedNotifications += 1;
@@ -54679,6 +54704,8 @@ ${tailedOutput}` : null;
54679
54704
  SITE_APP_BASE_PATH = process.env["SITE_APP_BASE_PATH"] ?? "";
54680
54705
  };
54681
54706
  const MACHINE_ID_FILE_NAME = "machine-id";
54707
+ const MACHINE_ID_COMMAND_TIMEOUT_MS = 1e3;
54708
+ const execFileAsync$4 = promisify$1(execFile$1);
54682
54709
  function getMachineIdFilePath() {
54683
54710
  return path__default.join(os__default.homedir(), ".lody", MACHINE_ID_FILE_NAME);
54684
54711
  }
@@ -54693,66 +54720,114 @@ ${tailedOutput}` : null;
54693
54720
  return false;
54694
54721
  }
54695
54722
  }
54723
+ function readPersistedDockerMachineId(inDocker) {
54724
+ if (!inDocker) {
54725
+ return null;
54726
+ }
54727
+ const machineIdPath = getMachineIdFilePath();
54728
+ if (fs__default.existsSync(machineIdPath)) {
54729
+ const id2 = fs__default.readFileSync(machineIdPath, "utf-8").trim();
54730
+ if (id2) return id2;
54731
+ }
54732
+ return null;
54733
+ }
54734
+ function readLinuxMachineId() {
54735
+ if (fs__default.existsSync("/etc/machine-id")) {
54736
+ return fs__default.readFileSync("/etc/machine-id", "utf-8").trim() || null;
54737
+ }
54738
+ if (fs__default.existsSync("/var/lib/dbus/machine-id")) {
54739
+ return fs__default.readFileSync("/var/lib/dbus/machine-id", "utf-8").trim() || null;
54740
+ }
54741
+ return null;
54742
+ }
54743
+ function persistDockerMachineId(baseId) {
54744
+ const suffix = require$$3$4.randomUUID().replace(/-/g, "").slice(0, 12);
54745
+ const dockerMachineId = `${baseId}-docker-${suffix}`;
54746
+ try {
54747
+ const machineIdPath = getMachineIdFilePath();
54748
+ fs__default.mkdirSync(path__default.dirname(machineIdPath), {
54749
+ recursive: true
54750
+ });
54751
+ fs__default.writeFileSync(machineIdPath, dockerMachineId, "utf-8");
54752
+ if (process.platform !== "win32") {
54753
+ try {
54754
+ fs__default.chmodSync(machineIdPath, 384);
54755
+ } catch {
54756
+ }
54757
+ }
54758
+ } catch {
54759
+ }
54760
+ return dockerMachineId;
54761
+ }
54762
+ function finalizeMachineId(baseId, inDocker) {
54763
+ if (!baseId) return null;
54764
+ if (inDocker) {
54765
+ return persistDockerMachineId(baseId);
54766
+ }
54767
+ return baseId;
54768
+ }
54769
+ async function readDarwinMachineId() {
54770
+ try {
54771
+ const { stdout } = await execFileAsync$4("ioreg", [
54772
+ "-rd1",
54773
+ "-c",
54774
+ "IOPlatformExpertDevice"
54775
+ ], {
54776
+ encoding: "utf-8",
54777
+ timeout: MACHINE_ID_COMMAND_TIMEOUT_MS
54778
+ });
54779
+ return String(stdout ?? "").match(/"IOPlatformUUID"\s=\s"(.+)"/)?.[1] ?? null;
54780
+ } catch {
54781
+ return null;
54782
+ }
54783
+ }
54784
+ async function readWindowsMachineId() {
54785
+ try {
54786
+ const { stdout } = await execFileAsync$4("wmic", [
54787
+ "csproduct",
54788
+ "get",
54789
+ "UUID"
54790
+ ], {
54791
+ encoding: "utf-8",
54792
+ timeout: MACHINE_ID_COMMAND_TIMEOUT_MS,
54793
+ windowsHide: true
54794
+ });
54795
+ return String(stdout ?? "").split("\n")[1]?.trim() || null;
54796
+ } catch {
54797
+ return null;
54798
+ }
54799
+ }
54696
54800
  function getSystemMachineId() {
54697
54801
  try {
54698
54802
  const inDocker = isRunningInDocker();
54699
- if (inDocker) {
54700
- const machineIdPath = getMachineIdFilePath();
54701
- if (fs__default.existsSync(machineIdPath)) {
54702
- const id2 = fs__default.readFileSync(machineIdPath, "utf-8").trim();
54703
- if (id2) return id2;
54704
- }
54803
+ const persisted = readPersistedDockerMachineId(inDocker);
54804
+ if (persisted) return persisted;
54805
+ let baseId = null;
54806
+ if (process.platform === "linux") {
54807
+ baseId = readLinuxMachineId();
54705
54808
  }
54809
+ return finalizeMachineId(baseId, inDocker);
54810
+ } catch {
54811
+ }
54812
+ return null;
54813
+ }
54814
+ async function getSystemMachineIdAsync() {
54815
+ try {
54816
+ const inDocker = isRunningInDocker();
54817
+ const persisted = readPersistedDockerMachineId(inDocker);
54818
+ if (persisted) return persisted;
54706
54819
  let baseId = null;
54707
54820
  if (process.platform === "linux") {
54708
- if (fs__default.existsSync("/etc/machine-id")) {
54709
- baseId = fs__default.readFileSync("/etc/machine-id", "utf-8").trim();
54710
- } else if (fs__default.existsSync("/var/lib/dbus/machine-id")) {
54711
- baseId = fs__default.readFileSync("/var/lib/dbus/machine-id", "utf-8").trim();
54712
- }
54821
+ baseId = readLinuxMachineId();
54713
54822
  } else if (process.platform === "darwin") {
54714
- try {
54715
- const uuid2 = execSync("ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID", {
54716
- encoding: "utf-8"
54717
- }).match(/"IOPlatformUUID" = "(.+)"/)?.[1];
54718
- baseId = uuid2 ?? null;
54719
- } catch {
54720
- baseId = null;
54721
- }
54823
+ baseId = await readDarwinMachineId();
54722
54824
  } else if (process.platform === "win32") {
54723
- try {
54724
- const uuid2 = execSync("wmic csproduct get UUID", {
54725
- encoding: "utf-8"
54726
- }).split("\n")[1]?.trim();
54727
- baseId = uuid2 ?? null;
54728
- } catch {
54729
- baseId = null;
54730
- }
54825
+ baseId = await readWindowsMachineId();
54731
54826
  }
54732
- if (!baseId) return null;
54733
- if (inDocker) {
54734
- const suffix = require$$3$4.randomUUID().replace(/-/g, "").slice(0, 12);
54735
- const dockerMachineId = `${baseId}-docker-${suffix}`;
54736
- try {
54737
- const machineIdPath = getMachineIdFilePath();
54738
- fs__default.mkdirSync(path__default.dirname(machineIdPath), {
54739
- recursive: true
54740
- });
54741
- fs__default.writeFileSync(machineIdPath, dockerMachineId, "utf-8");
54742
- if (process.platform !== "win32") {
54743
- try {
54744
- fs__default.chmodSync(machineIdPath, 384);
54745
- } catch {
54746
- }
54747
- }
54748
- } catch {
54749
- }
54750
- return dockerMachineId;
54751
- }
54752
- return baseId;
54827
+ return finalizeMachineId(baseId, inDocker);
54753
54828
  } catch {
54829
+ return null;
54754
54830
  }
54755
- return null;
54756
54831
  }
54757
54832
  const DEFAULT_HOST = "https://us.i.posthog.com";
54758
54833
  const FLUSH_INTERVAL_MS = 3e4;
@@ -74504,521 +74579,7 @@ ${info.stack}`;
74504
74579
  });
74505
74580
  });
74506
74581
  };
74507
- var crossSpawn = {
74508
- exports: {}
74509
- };
74510
- var windows;
74511
- var hasRequiredWindows;
74512
- function requireWindows() {
74513
- if (hasRequiredWindows) return windows;
74514
- hasRequiredWindows = 1;
74515
- windows = isexe;
74516
- isexe.sync = sync2;
74517
- var fs2 = fs__default;
74518
- function checkPathExt(path2, options) {
74519
- var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
74520
- if (!pathext) {
74521
- return true;
74522
- }
74523
- pathext = pathext.split(";");
74524
- if (pathext.indexOf("") !== -1) {
74525
- return true;
74526
- }
74527
- for (var i2 = 0; i2 < pathext.length; i2++) {
74528
- var p = pathext[i2].toLowerCase();
74529
- if (p && path2.substr(-p.length).toLowerCase() === p) {
74530
- return true;
74531
- }
74532
- }
74533
- return false;
74534
- }
74535
- function checkStat(stat2, path2, options) {
74536
- if (!stat2.isSymbolicLink() && !stat2.isFile()) {
74537
- return false;
74538
- }
74539
- return checkPathExt(path2, options);
74540
- }
74541
- function isexe(path2, options, cb) {
74542
- fs2.stat(path2, function(er, stat2) {
74543
- cb(er, er ? false : checkStat(stat2, path2, options));
74544
- });
74545
- }
74546
- function sync2(path2, options) {
74547
- return checkStat(fs2.statSync(path2), path2, options);
74548
- }
74549
- return windows;
74550
- }
74551
- var mode;
74552
- var hasRequiredMode;
74553
- function requireMode() {
74554
- if (hasRequiredMode) return mode;
74555
- hasRequiredMode = 1;
74556
- mode = isexe;
74557
- isexe.sync = sync2;
74558
- var fs2 = fs__default;
74559
- function isexe(path2, options, cb) {
74560
- fs2.stat(path2, function(er, stat2) {
74561
- cb(er, er ? false : checkStat(stat2, options));
74562
- });
74563
- }
74564
- function sync2(path2, options) {
74565
- return checkStat(fs2.statSync(path2), options);
74566
- }
74567
- function checkStat(stat2, options) {
74568
- return stat2.isFile() && checkMode(stat2, options);
74569
- }
74570
- function checkMode(stat2, options) {
74571
- var mod2 = stat2.mode;
74572
- var uid = stat2.uid;
74573
- var gid = stat2.gid;
74574
- var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
74575
- var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
74576
- var u = parseInt("100", 8);
74577
- var g = parseInt("010", 8);
74578
- var o = parseInt("001", 8);
74579
- var ug = u | g;
74580
- var ret = mod2 & o || mod2 & g && gid === myGid || mod2 & u && uid === myUid || mod2 & ug && myUid === 0;
74581
- return ret;
74582
- }
74583
- return mode;
74584
- }
74585
- var isexe_1;
74586
- var hasRequiredIsexe;
74587
- function requireIsexe() {
74588
- if (hasRequiredIsexe) return isexe_1;
74589
- hasRequiredIsexe = 1;
74590
- var core2;
74591
- if (process.platform === "win32" || commonjsGlobal.TESTING_WINDOWS) {
74592
- core2 = requireWindows();
74593
- } else {
74594
- core2 = requireMode();
74595
- }
74596
- isexe_1 = isexe;
74597
- isexe.sync = sync2;
74598
- function isexe(path2, options, cb) {
74599
- if (typeof options === "function") {
74600
- cb = options;
74601
- options = {};
74602
- }
74603
- if (!cb) {
74604
- if (typeof Promise !== "function") {
74605
- throw new TypeError("callback not provided");
74606
- }
74607
- return new Promise(function(resolve2, reject) {
74608
- isexe(path2, options || {}, function(er, is2) {
74609
- if (er) {
74610
- reject(er);
74611
- } else {
74612
- resolve2(is2);
74613
- }
74614
- });
74615
- });
74616
- }
74617
- core2(path2, options || {}, function(er, is2) {
74618
- if (er) {
74619
- if (er.code === "EACCES" || options && options.ignoreErrors) {
74620
- er = null;
74621
- is2 = false;
74622
- }
74623
- }
74624
- cb(er, is2);
74625
- });
74626
- }
74627
- function sync2(path2, options) {
74628
- try {
74629
- return core2.sync(path2, options || {});
74630
- } catch (er) {
74631
- if (options && options.ignoreErrors || er.code === "EACCES") {
74632
- return false;
74633
- } else {
74634
- throw er;
74635
- }
74636
- }
74637
- }
74638
- return isexe_1;
74639
- }
74640
- var which_1;
74641
- var hasRequiredWhich;
74642
- function requireWhich() {
74643
- if (hasRequiredWhich) return which_1;
74644
- hasRequiredWhich = 1;
74645
- const isWindows2 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
74646
- const path2 = path__default;
74647
- const COLON = isWindows2 ? ";" : ":";
74648
- const isexe = requireIsexe();
74649
- const getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), {
74650
- code: "ENOENT"
74651
- });
74652
- const getPathInfo = (cmd, opt) => {
74653
- const colon = opt.colon || COLON;
74654
- const pathEnv = cmd.match(/\//) || isWindows2 && cmd.match(/\\/) ? [
74655
- ""
74656
- ] : [
74657
- ...isWindows2 ? [
74658
- process.cwd()
74659
- ] : [],
74660
- ...(opt.path || process.env.PATH || "").split(colon)
74661
- ];
74662
- const pathExtExe = isWindows2 ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
74663
- const pathExt = isWindows2 ? pathExtExe.split(colon) : [
74664
- ""
74665
- ];
74666
- if (isWindows2) {
74667
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "") pathExt.unshift("");
74668
- }
74669
- return {
74670
- pathEnv,
74671
- pathExt,
74672
- pathExtExe
74673
- };
74674
- };
74675
- const which = (cmd, opt, cb) => {
74676
- if (typeof opt === "function") {
74677
- cb = opt;
74678
- opt = {};
74679
- }
74680
- if (!opt) opt = {};
74681
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
74682
- const found = [];
74683
- const step2 = (i2) => new Promise((resolve2, reject) => {
74684
- if (i2 === pathEnv.length) return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
74685
- const ppRaw = pathEnv[i2];
74686
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
74687
- const pCmd = path2.join(pathPart, cmd);
74688
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
74689
- resolve2(subStep(p, i2, 0));
74690
- });
74691
- const subStep = (p, i2, ii) => new Promise((resolve2, reject) => {
74692
- if (ii === pathExt.length) return resolve2(step2(i2 + 1));
74693
- const ext2 = pathExt[ii];
74694
- isexe(p + ext2, {
74695
- pathExt: pathExtExe
74696
- }, (er, is2) => {
74697
- if (!er && is2) {
74698
- if (opt.all) found.push(p + ext2);
74699
- else return resolve2(p + ext2);
74700
- }
74701
- return resolve2(subStep(p, i2, ii + 1));
74702
- });
74703
- });
74704
- return cb ? step2(0).then((res) => cb(null, res), cb) : step2(0);
74705
- };
74706
- const whichSync = (cmd, opt) => {
74707
- opt = opt || {};
74708
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
74709
- const found = [];
74710
- for (let i2 = 0; i2 < pathEnv.length; i2++) {
74711
- const ppRaw = pathEnv[i2];
74712
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
74713
- const pCmd = path2.join(pathPart, cmd);
74714
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
74715
- for (let j = 0; j < pathExt.length; j++) {
74716
- const cur = p + pathExt[j];
74717
- try {
74718
- const is2 = isexe.sync(cur, {
74719
- pathExt: pathExtExe
74720
- });
74721
- if (is2) {
74722
- if (opt.all) found.push(cur);
74723
- else return cur;
74724
- }
74725
- } catch (ex) {
74726
- }
74727
- }
74728
- }
74729
- if (opt.all && found.length) return found;
74730
- if (opt.nothrow) return null;
74731
- throw getNotFoundError(cmd);
74732
- };
74733
- which_1 = which;
74734
- which.sync = whichSync;
74735
- return which_1;
74736
- }
74737
- var pathKey = {
74738
- exports: {}
74739
- };
74740
- var hasRequiredPathKey;
74741
- function requirePathKey() {
74742
- if (hasRequiredPathKey) return pathKey.exports;
74743
- hasRequiredPathKey = 1;
74744
- const pathKey$1 = (options = {}) => {
74745
- const environment2 = options.env || process.env;
74746
- const platform2 = options.platform || process.platform;
74747
- if (platform2 !== "win32") {
74748
- return "PATH";
74749
- }
74750
- return Object.keys(environment2).reverse().find((key2) => key2.toUpperCase() === "PATH") || "Path";
74751
- };
74752
- pathKey.exports = pathKey$1;
74753
- pathKey.exports.default = pathKey$1;
74754
- return pathKey.exports;
74755
- }
74756
- var resolveCommand_1;
74757
- var hasRequiredResolveCommand;
74758
- function requireResolveCommand() {
74759
- if (hasRequiredResolveCommand) return resolveCommand_1;
74760
- hasRequiredResolveCommand = 1;
74761
- const path2 = path__default;
74762
- const which = requireWhich();
74763
- const getPathKey = requirePathKey();
74764
- function resolveCommandAttempt(parsed, withoutPathExt) {
74765
- const env2 = parsed.options.env || process.env;
74766
- const cwd = process.cwd();
74767
- const hasCustomCwd = parsed.options.cwd != null;
74768
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
74769
- if (shouldSwitchCwd) {
74770
- try {
74771
- process.chdir(parsed.options.cwd);
74772
- } catch (err2) {
74773
- }
74774
- }
74775
- let resolved;
74776
- try {
74777
- resolved = which.sync(parsed.command, {
74778
- path: env2[getPathKey({
74779
- env: env2
74780
- })],
74781
- pathExt: withoutPathExt ? path2.delimiter : void 0
74782
- });
74783
- } catch (e) {
74784
- } finally {
74785
- if (shouldSwitchCwd) {
74786
- process.chdir(cwd);
74787
- }
74788
- }
74789
- if (resolved) {
74790
- resolved = path2.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
74791
- }
74792
- return resolved;
74793
- }
74794
- function resolveCommand(parsed) {
74795
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
74796
- }
74797
- resolveCommand_1 = resolveCommand;
74798
- return resolveCommand_1;
74799
- }
74800
- var _escape = {};
74801
- var hasRequired_escape;
74802
- function require_escape() {
74803
- if (hasRequired_escape) return _escape;
74804
- hasRequired_escape = 1;
74805
- const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
74806
- function escapeCommand(arg) {
74807
- arg = arg.replace(metaCharsRegExp, "^$1");
74808
- return arg;
74809
- }
74810
- function escapeArgument(arg, doubleEscapeMetaChars) {
74811
- arg = `${arg}`;
74812
- arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
74813
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
74814
- arg = `"${arg}"`;
74815
- arg = arg.replace(metaCharsRegExp, "^$1");
74816
- if (doubleEscapeMetaChars) {
74817
- arg = arg.replace(metaCharsRegExp, "^$1");
74818
- }
74819
- return arg;
74820
- }
74821
- _escape.command = escapeCommand;
74822
- _escape.argument = escapeArgument;
74823
- return _escape;
74824
- }
74825
- var shebangRegex;
74826
- var hasRequiredShebangRegex;
74827
- function requireShebangRegex() {
74828
- if (hasRequiredShebangRegex) return shebangRegex;
74829
- hasRequiredShebangRegex = 1;
74830
- shebangRegex = /^#!(.*)/;
74831
- return shebangRegex;
74832
- }
74833
- var shebangCommand;
74834
- var hasRequiredShebangCommand;
74835
- function requireShebangCommand() {
74836
- if (hasRequiredShebangCommand) return shebangCommand;
74837
- hasRequiredShebangCommand = 1;
74838
- const shebangRegex2 = requireShebangRegex();
74839
- shebangCommand = (string2 = "") => {
74840
- const match5 = string2.match(shebangRegex2);
74841
- if (!match5) {
74842
- return null;
74843
- }
74844
- const [path2, argument2] = match5[0].replace(/#! ?/, "").split(" ");
74845
- const binary2 = path2.split("/").pop();
74846
- if (binary2 === "env") {
74847
- return argument2;
74848
- }
74849
- return argument2 ? `${binary2} ${argument2}` : binary2;
74850
- };
74851
- return shebangCommand;
74852
- }
74853
- var readShebang_1;
74854
- var hasRequiredReadShebang;
74855
- function requireReadShebang() {
74856
- if (hasRequiredReadShebang) return readShebang_1;
74857
- hasRequiredReadShebang = 1;
74858
- const fs2 = fs__default;
74859
- const shebangCommand2 = requireShebangCommand();
74860
- function readShebang(command2) {
74861
- const size2 = 150;
74862
- const buffer2 = Buffer.alloc(size2);
74863
- let fd;
74864
- try {
74865
- fd = fs2.openSync(command2, "r");
74866
- fs2.readSync(fd, buffer2, 0, size2, 0);
74867
- fs2.closeSync(fd);
74868
- } catch (e) {
74869
- }
74870
- return shebangCommand2(buffer2.toString());
74871
- }
74872
- readShebang_1 = readShebang;
74873
- return readShebang_1;
74874
- }
74875
- var parse_1$2;
74876
- var hasRequiredParse$2;
74877
- function requireParse$2() {
74878
- if (hasRequiredParse$2) return parse_1$2;
74879
- hasRequiredParse$2 = 1;
74880
- const path2 = path__default;
74881
- const resolveCommand = requireResolveCommand();
74882
- const escape2 = require_escape();
74883
- const readShebang = requireReadShebang();
74884
- const isWin = process.platform === "win32";
74885
- const isExecutableRegExp = /\.(?:com|exe)$/i;
74886
- const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
74887
- function detectShebang(parsed) {
74888
- parsed.file = resolveCommand(parsed);
74889
- const shebang = parsed.file && readShebang(parsed.file);
74890
- if (shebang) {
74891
- parsed.args.unshift(parsed.file);
74892
- parsed.command = shebang;
74893
- return resolveCommand(parsed);
74894
- }
74895
- return parsed.file;
74896
- }
74897
- function parseNonShell(parsed) {
74898
- if (!isWin) {
74899
- return parsed;
74900
- }
74901
- const commandFile = detectShebang(parsed);
74902
- const needsShell = !isExecutableRegExp.test(commandFile);
74903
- if (parsed.options.forceShell || needsShell) {
74904
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
74905
- parsed.command = path2.normalize(parsed.command);
74906
- parsed.command = escape2.command(parsed.command);
74907
- parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
74908
- const shellCommand = [
74909
- parsed.command
74910
- ].concat(parsed.args).join(" ");
74911
- parsed.args = [
74912
- "/d",
74913
- "/s",
74914
- "/c",
74915
- `"${shellCommand}"`
74916
- ];
74917
- parsed.command = process.env.comspec || "cmd.exe";
74918
- parsed.options.windowsVerbatimArguments = true;
74919
- }
74920
- return parsed;
74921
- }
74922
- function parse2(command2, args2, options) {
74923
- if (args2 && !Array.isArray(args2)) {
74924
- options = args2;
74925
- args2 = null;
74926
- }
74927
- args2 = args2 ? args2.slice(0) : [];
74928
- options = Object.assign({}, options);
74929
- const parsed = {
74930
- command: command2,
74931
- args: args2,
74932
- options,
74933
- file: void 0,
74934
- original: {
74935
- command: command2,
74936
- args: args2
74937
- }
74938
- };
74939
- return options.shell ? parsed : parseNonShell(parsed);
74940
- }
74941
- parse_1$2 = parse2;
74942
- return parse_1$2;
74943
- }
74944
- var enoent;
74945
- var hasRequiredEnoent;
74946
- function requireEnoent() {
74947
- if (hasRequiredEnoent) return enoent;
74948
- hasRequiredEnoent = 1;
74949
- const isWin = process.platform === "win32";
74950
- function notFoundError(original, syscall) {
74951
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
74952
- code: "ENOENT",
74953
- errno: "ENOENT",
74954
- syscall: `${syscall} ${original.command}`,
74955
- path: original.command,
74956
- spawnargs: original.args
74957
- });
74958
- }
74959
- function hookChildProcess(cp, parsed) {
74960
- if (!isWin) {
74961
- return;
74962
- }
74963
- const originalEmit = cp.emit;
74964
- cp.emit = function(name2, arg1) {
74965
- if (name2 === "exit") {
74966
- const err2 = verifyENOENT(arg1, parsed);
74967
- if (err2) {
74968
- return originalEmit.call(cp, "error", err2);
74969
- }
74970
- }
74971
- return originalEmit.apply(cp, arguments);
74972
- };
74973
- }
74974
- function verifyENOENT(status, parsed) {
74975
- if (isWin && status === 1 && !parsed.file) {
74976
- return notFoundError(parsed.original, "spawn");
74977
- }
74978
- return null;
74979
- }
74980
- function verifyENOENTSync(status, parsed) {
74981
- if (isWin && status === 1 && !parsed.file) {
74982
- return notFoundError(parsed.original, "spawnSync");
74983
- }
74984
- return null;
74985
- }
74986
- enoent = {
74987
- hookChildProcess,
74988
- verifyENOENT,
74989
- verifyENOENTSync,
74990
- notFoundError
74991
- };
74992
- return enoent;
74993
- }
74994
- var hasRequiredCrossSpawn;
74995
- function requireCrossSpawn() {
74996
- if (hasRequiredCrossSpawn) return crossSpawn.exports;
74997
- hasRequiredCrossSpawn = 1;
74998
- const cp = require$$1$8;
74999
- const parse2 = requireParse$2();
75000
- const enoent2 = requireEnoent();
75001
- function spawn2(command2, args2, options) {
75002
- const parsed = parse2(command2, args2, options);
75003
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
75004
- enoent2.hookChildProcess(spawned, parsed);
75005
- return spawned;
75006
- }
75007
- function spawnSync(command2, args2, options) {
75008
- const parsed = parse2(command2, args2, options);
75009
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
75010
- result.error = result.error || enoent2.verifyENOENTSync(result.status, parsed);
75011
- return result;
75012
- }
75013
- crossSpawn.exports = spawn2;
75014
- crossSpawn.exports.spawn = spawn2;
75015
- crossSpawn.exports.sync = spawnSync;
75016
- crossSpawn.exports._parse = parse2;
75017
- crossSpawn.exports._enoent = enoent2;
75018
- return crossSpawn.exports;
75019
- }
75020
- var crossSpawnExports = requireCrossSpawn();
75021
- const spawn = getDefaultExportFromCjs(crossSpawnExports);
74582
+ promisify(execFile);
75022
74583
  const AUTH_FILE_DETECTED = "configured";
75023
74584
  function resolveHomeDir(options) {
75024
74585
  return options?.homeDir ?? os$1.homedir();
@@ -78502,7 +78063,7 @@ ${fromBody}`;
78502
78063
  broadcastSessionUpdate: (trigger) => broadcastSessionUpdate(trigger)
78503
78064
  };
78504
78065
  }
78505
- function isPlainObject$3(value) {
78066
+ function isPlainObject$2(value) {
78506
78067
  if (value === null || typeof value !== "object") {
78507
78068
  return false;
78508
78069
  }
@@ -78519,7 +78080,7 @@ ${fromBody}`;
78519
78080
  return true;
78520
78081
  }
78521
78082
  function _defu(baseObject, defaults2, namespace = ".", merger) {
78522
- if (!isPlainObject$3(defaults2)) {
78083
+ if (!isPlainObject$2(defaults2)) {
78523
78084
  return _defu(baseObject, {}, namespace, merger);
78524
78085
  }
78525
78086
  const object2 = {
@@ -78541,7 +78102,7 @@ ${fromBody}`;
78541
78102
  ...value,
78542
78103
  ...object2[key2]
78543
78104
  ];
78544
- } else if (isPlainObject$3(value) && isPlainObject$3(object2[key2])) {
78105
+ } else if (isPlainObject$2(value) && isPlainObject$2(object2[key2])) {
78545
78106
  object2[key2] = _defu(value, object2[key2], (namespace ? `${namespace}.` : "") + key2.toString(), merger);
78546
78107
  } else {
78547
78108
  object2[key2] = value;
@@ -79745,7 +79306,7 @@ ${fromBody}`;
79745
79306
  };
79746
79307
  }
79747
79308
  async bootstrapFromSessionToken(sessionToken, machineName) {
79748
- const machineId = getSystemMachineId() || v4();
79309
+ const machineId = await getSystemMachineIdAsync() || v4();
79749
79310
  return await this.finalizeLoginFromSessionToken({
79750
79311
  sessionToken,
79751
79312
  machineName,
@@ -79767,7 +79328,7 @@ ${fromBody}`;
79767
79328
  error: "Invalid API key. Generate a new key and retry."
79768
79329
  };
79769
79330
  }
79770
- const machineId = getSystemMachineId() || v4();
79331
+ const machineId = await getSystemMachineIdAsync() || v4();
79771
79332
  const authInfo = {
79772
79333
  token: accessToken,
79773
79334
  user: validation2.user,
@@ -79784,7 +79345,7 @@ ${fromBody}`;
79784
79345
  };
79785
79346
  }
79786
79347
  async login(machineName) {
79787
- const machineId = getSystemMachineId() || v4();
79348
+ const machineId = await getSystemMachineIdAsync() || v4();
79788
79349
  this.logger.debug(`[device-auth] siteUrl=${this.siteUrl} serverUrl=${this.serverUrl}`);
79789
79350
  const deviceCodeRes = await this.betterAuthClient.device.code({
79790
79351
  client_id: DEVICE_CLIENT_ID
@@ -101321,11 +100882,11 @@ stream:${scope2.streamId}`;
101321
100882
  };
101322
100883
  return constants$3;
101323
100884
  }
101324
- var parse_1$1;
101325
- var hasRequiredParse$1;
101326
- function requireParse$1() {
101327
- if (hasRequiredParse$1) return parse_1$1;
101328
- hasRequiredParse$1 = 1;
100885
+ var parse_1$2;
100886
+ var hasRequiredParse$2;
100887
+ function requireParse$2() {
100888
+ if (hasRequiredParse$2) return parse_1$2;
100889
+ hasRequiredParse$2 = 1;
101329
100890
  const stringify2 = requireStringify();
101330
100891
  const { MAX_LENGTH, CHAR_BACKSLASH, CHAR_BACKTICK, CHAR_COMMA, CHAR_DOT, CHAR_LEFT_PARENTHESES, CHAR_RIGHT_PARENTHESES, CHAR_LEFT_CURLY_BRACE, CHAR_RIGHT_CURLY_BRACE, CHAR_LEFT_SQUARE_BRACKET, CHAR_RIGHT_SQUARE_BRACKET, CHAR_DOUBLE_QUOTE, CHAR_SINGLE_QUOTE, CHAR_NO_BREAK_SPACE, CHAR_ZERO_WIDTH_NOBREAK_SPACE } = requireConstants$2();
101331
100892
  const parse2 = (input2, options = {}) => {
@@ -101589,8 +101150,8 @@ stream:${scope2.streamId}`;
101589
101150
  });
101590
101151
  return ast;
101591
101152
  };
101592
- parse_1$1 = parse2;
101593
- return parse_1$1;
101153
+ parse_1$2 = parse2;
101154
+ return parse_1$2;
101594
101155
  }
101595
101156
  var braces_1;
101596
101157
  var hasRequiredBraces;
@@ -101600,7 +101161,7 @@ stream:${scope2.streamId}`;
101600
101161
  const stringify2 = requireStringify();
101601
101162
  const compile2 = requireCompile$1();
101602
101163
  const expand2 = requireExpand$1();
101603
- const parse2 = requireParse$1();
101164
+ const parse2 = requireParse$2();
101604
101165
  const braces = (input2, options = {}) => {
101605
101166
  let output = [];
101606
101167
  if (Array.isArray(input2)) {
@@ -102189,11 +101750,11 @@ stream:${scope2.streamId}`;
102189
101750
  scan_1 = scan2;
102190
101751
  return scan_1;
102191
101752
  }
102192
- var parse_1;
102193
- var hasRequiredParse;
102194
- function requireParse() {
102195
- if (hasRequiredParse) return parse_1;
102196
- hasRequiredParse = 1;
101753
+ var parse_1$1;
101754
+ var hasRequiredParse$1;
101755
+ function requireParse$1() {
101756
+ if (hasRequiredParse$1) return parse_1$1;
101757
+ hasRequiredParse$1 = 1;
102197
101758
  const constants2 = requireConstants$1();
102198
101759
  const utils2 = requireUtils$4();
102199
101760
  const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants2;
@@ -103081,8 +102642,8 @@ stream:${scope2.streamId}`;
103081
102642
  }
103082
102643
  return source;
103083
102644
  };
103084
- parse_1 = parse2;
103085
- return parse_1;
102645
+ parse_1$1 = parse2;
102646
+ return parse_1$1;
103086
102647
  }
103087
102648
  var picomatch_1;
103088
102649
  var hasRequiredPicomatch$1;
@@ -103091,7 +102652,7 @@ stream:${scope2.streamId}`;
103091
102652
  hasRequiredPicomatch$1 = 1;
103092
102653
  const path2 = path__default;
103093
102654
  const scan2 = requireScan$1();
103094
- const parse2 = requireParse();
102655
+ const parse2 = requireParse$1();
103095
102656
  const utils2 = requireUtils$4();
103096
102657
  const constants2 = requireConstants$1();
103097
102658
  const isObject2 = (val) => val && typeof val === "object" && !Array.isArray(val);
@@ -118479,55 +118040,6 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
118479
118040
  ...entry2,
118480
118041
  inputConfig: normalizeSessionTurnInputConfig(entry2.inputConfig)
118481
118042
  });
118482
- const isPlainObject$2 = (value) => {
118483
- if (typeof value !== "object" || value === null) return false;
118484
- const proto2 = Object.getPrototypeOf(value);
118485
- return proto2 === Object.prototype || proto2 === null;
118486
- };
118487
- const stripUndefinedForMirror = (value) => {
118488
- const visit2 = (current2) => {
118489
- if (current2 === void 0) return void 0;
118490
- if (current2 === null || typeof current2 !== "object") return current2;
118491
- if (Array.isArray(current2)) {
118492
- let changed = false;
118493
- const next22 = [];
118494
- for (const item of current2) {
118495
- const sanitized = visit2(item);
118496
- if (sanitized === void 0) {
118497
- changed = true;
118498
- continue;
118499
- }
118500
- if (sanitized !== item) {
118501
- changed = true;
118502
- }
118503
- next22.push(sanitized);
118504
- }
118505
- return changed ? next22 : current2;
118506
- }
118507
- if (!isPlainObject$2(current2)) {
118508
- return current2;
118509
- }
118510
- let next2 = null;
118511
- for (const [key2, raw2] of Object.entries(current2)) {
118512
- const sanitized = visit2(raw2);
118513
- if (sanitized === void 0) {
118514
- if (!next2) next2 = {
118515
- ...current2
118516
- };
118517
- delete next2[key2];
118518
- continue;
118519
- }
118520
- if (sanitized !== raw2) {
118521
- if (!next2) next2 = {
118522
- ...current2
118523
- };
118524
- next2[key2] = sanitized;
118525
- }
118526
- }
118527
- return next2 ?? current2;
118528
- };
118529
- return visit2(value);
118530
- };
118531
118043
  let streamsDiagnosticsInstalled = false;
118532
118044
  let streamsDiagLogger = null;
118533
118045
  function installStreamsDiagnostics(logger2) {
@@ -119620,7 +119132,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
119620
119132
  let attemptedTail = null;
119621
119133
  try {
119622
119134
  this.mirror.setState((prev) => {
119623
- const nextHistory = stripUndefinedForMirror(updateFn(prev.history || []));
119135
+ const nextHistory = updateFn(prev.history || []);
119624
119136
  attemptedTail = this.summarizeHistoryTailForDiagnostics(nextHistory);
119625
119137
  prev.history = nextHistory;
119626
119138
  return prev;
@@ -120550,8 +120062,10 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120550
120062
  return raw2;
120551
120063
  }
120552
120064
  };
120065
+ const execFileAsync$3 = promisify(execFile);
120553
120066
  const DEFAULT_GIT_COMMAND_TIMEOUT_MS = 5e3;
120554
120067
  const GIT_CHECKOUT_TIMEOUT_MS = 3e4;
120068
+ const GIT_COMMAND_MAX_BUFFER_BYTES$1 = 16 * 1024 * 1024;
120555
120069
  function tryRealpath(inputPath) {
120556
120070
  try {
120557
120071
  if (typeof fs$6.realpathSync.native === "function") {
@@ -120594,58 +120108,46 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120594
120108
  const hash2 = createHash("sha256").update(normalizedRootPath).digest("hex").slice(0, 24);
120595
120109
  return `local-project-${hash2}`;
120596
120110
  }
120597
- function runGitCommand$1(rootPath, args2, options = {}) {
120111
+ async function runGitCommand$1(rootPath, args2, options = {}) {
120598
120112
  const timeoutMs = options.timeoutMs ?? DEFAULT_GIT_COMMAND_TIMEOUT_MS;
120599
120113
  try {
120600
- const result = spawn.sync("git", args2, {
120114
+ const result = await execFileAsync$3("git", args2, {
120601
120115
  cwd: rootPath,
120602
120116
  encoding: "utf-8",
120603
- stdio: [
120604
- "ignore",
120605
- "pipe",
120606
- "pipe"
120607
- ],
120608
120117
  timeout: timeoutMs,
120609
120118
  killSignal: "SIGTERM",
120119
+ maxBuffer: GIT_COMMAND_MAX_BUFFER_BYTES$1,
120610
120120
  env: {
120611
120121
  ...process.env,
120612
120122
  GIT_TERMINAL_PROMPT: "0",
120613
120123
  GIT_OPTIONAL_LOCKS: "0"
120614
120124
  }
120615
120125
  });
120616
- if (result.error) {
120617
- const message = result.error.message || `Git command timed out after ${timeoutMs}ms: git ${args2.join(" ")}`;
120618
- const commandResult2 = {
120619
- status: null,
120620
- stdout: String(result.stdout ?? ""),
120621
- stderr: message
120622
- };
120623
- return commandResult2;
120624
- }
120625
120126
  const commandResult = {
120626
- status: result.status ?? null,
120127
+ status: 0,
120627
120128
  stdout: String(result.stdout ?? ""),
120628
120129
  stderr: String(result.stderr ?? "")
120629
120130
  };
120630
120131
  return commandResult;
120631
120132
  } catch (error2) {
120632
- const message = error2 instanceof Error ? error2.message : String(error2);
120133
+ const withOutput = error2;
120134
+ const message = error2 instanceof Error ? error2.message || `Git command failed after ${timeoutMs}ms: git ${args2.join(" ")}` : String(error2);
120633
120135
  return {
120634
- status: null,
120635
- stdout: "",
120636
- stderr: message
120136
+ status: typeof withOutput?.code === "number" ? withOutput.code : null,
120137
+ stdout: String(withOutput?.stdout ?? ""),
120138
+ stderr: String(withOutput?.stderr ?? message)
120637
120139
  };
120638
120140
  }
120639
120141
  }
120640
- function isGitRepository(rootPath) {
120641
- const probe = runGitCommand$1(rootPath, [
120142
+ async function isGitRepository(rootPath) {
120143
+ const probe = await runGitCommand$1(rootPath, [
120642
120144
  "rev-parse",
120643
120145
  "--is-inside-work-tree"
120644
120146
  ]);
120645
120147
  return probe.status === 0 && probe.stdout.trim() === "true";
120646
120148
  }
120647
- function assertGitRepository(rootPath) {
120648
- if (!isGitRepository(rootPath)) {
120149
+ async function assertGitRepository(rootPath) {
120150
+ if (!await isGitRepository(rootPath)) {
120649
120151
  throw new Error("Local project is not a git repository");
120650
120152
  }
120651
120153
  }
@@ -120657,14 +120159,14 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120657
120159
  const name2 = trimmed.slice(prefix.length).trim();
120658
120160
  return name2 || null;
120659
120161
  }
120660
- function listGitRemotes(rootPath) {
120661
- const remoteResult = runGitCommand$1(rootPath, [
120162
+ async function listGitRemotes(rootPath) {
120163
+ const remoteResult = await runGitCommand$1(rootPath, [
120662
120164
  "remote"
120663
120165
  ]);
120664
120166
  if (remoteResult.status !== 0) return [];
120665
120167
  return remoteResult.stdout.split("\n").map((line3) => line3.trim()).filter(Boolean);
120666
120168
  }
120667
- function resolveGitRemoteUrl(rootPath, remoteName, direction) {
120169
+ async function resolveGitRemoteUrl(rootPath, remoteName, direction) {
120668
120170
  const args2 = [
120669
120171
  "remote",
120670
120172
  "get-url"
@@ -120673,7 +120175,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120673
120175
  args2.push("--push");
120674
120176
  }
120675
120177
  args2.push(remoteName);
120676
- const result = runGitCommand$1(rootPath, args2);
120178
+ const result = await runGitCommand$1(rootPath, args2);
120677
120179
  if (result.status !== 0) return null;
120678
120180
  const url = result.stdout.trim();
120679
120181
  return url || null;
@@ -120686,8 +120188,8 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120686
120188
  return null;
120687
120189
  }
120688
120190
  }
120689
- function resolveCurrentBranchRemote(rootPath, remotes) {
120690
- const currentBranchResult = runGitCommand$1(rootPath, [
120191
+ async function resolveCurrentBranchRemote(rootPath, remotes) {
120192
+ const currentBranchResult = await runGitCommand$1(rootPath, [
120691
120193
  "rev-parse",
120692
120194
  "--abbrev-ref",
120693
120195
  "HEAD"
@@ -120699,7 +120201,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120699
120201
  if (!currentBranch || currentBranch === "HEAD") {
120700
120202
  return null;
120701
120203
  }
120702
- const remoteResult = runGitCommand$1(rootPath, [
120204
+ const remoteResult = await runGitCommand$1(rootPath, [
120703
120205
  "config",
120704
120206
  `branch.${currentBranch}.remote`
120705
120207
  ]);
@@ -120712,11 +120214,11 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120712
120214
  }
120713
120215
  return remoteName;
120714
120216
  }
120715
- function probeGitHubRemoteAtRootPath(rootPath) {
120716
- assertGitRepository(rootPath);
120717
- const remotes = listGitRemotes(rootPath);
120217
+ async function probeGitHubRemoteAtRootPath(rootPath) {
120218
+ await assertGitRepository(rootPath);
120219
+ const remotes = await listGitRemotes(rootPath);
120718
120220
  if (remotes.length === 0) return null;
120719
- const currentBranchRemote = resolveCurrentBranchRemote(rootPath, remotes);
120221
+ const currentBranchRemote = await resolveCurrentBranchRemote(rootPath, remotes);
120720
120222
  const prioritizedRemotes = [];
120721
120223
  if (currentBranchRemote && remotes.includes(currentBranchRemote)) {
120722
120224
  prioritizedRemotes.push(currentBranchRemote);
@@ -120739,7 +120241,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120739
120241
  });
120740
120242
  }
120741
120243
  for (const candidate of candidates) {
120742
- const remoteUrl = resolveGitRemoteUrl(rootPath, candidate.remoteName, candidate.direction);
120244
+ const remoteUrl = await resolveGitRemoteUrl(rootPath, candidate.remoteName, candidate.direction);
120743
120245
  if (!remoteUrl) {
120744
120246
  continue;
120745
120247
  }
@@ -120755,10 +120257,10 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120755
120257
  }
120756
120258
  return null;
120757
120259
  }
120758
- function listLocalProjectBranchesAtRootPath(rootPath) {
120759
- assertGitRepository(rootPath);
120760
- const remotes = listGitRemotes(rootPath);
120761
- const refsResult = runGitCommand$1(rootPath, [
120260
+ async function listLocalProjectBranchesAtRootPath(rootPath) {
120261
+ await assertGitRepository(rootPath);
120262
+ const remotes = await listGitRemotes(rootPath);
120263
+ const refsResult = await runGitCommand$1(rootPath, [
120762
120264
  "for-each-ref",
120763
120265
  "--format=%(refname)",
120764
120266
  "refs/heads",
@@ -120792,7 +120294,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120792
120294
  branchesSet.add(branchName);
120793
120295
  }
120794
120296
  }
120795
- const currentResult = runGitCommand$1(rootPath, [
120297
+ const currentResult = await runGitCommand$1(rootPath, [
120796
120298
  "rev-parse",
120797
120299
  "--abbrev-ref",
120798
120300
  "HEAD"
@@ -120804,7 +120306,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120804
120306
  }
120805
120307
  let defaultBranchFromRemote = null;
120806
120308
  for (const remote of remotes) {
120807
- const defaultResult = runGitCommand$1(rootPath, [
120309
+ const defaultResult = await runGitCommand$1(rootPath, [
120808
120310
  "symbolic-ref",
120809
120311
  "--quiet",
120810
120312
  "--short",
@@ -120833,9 +120335,9 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120833
120335
  defaultBranch
120834
120336
  };
120835
120337
  }
120836
- function getLocalProjectWorkingTreeAtRootPath(rootPath) {
120837
- assertGitRepository(rootPath);
120838
- const statusResult = runGitCommand$1(rootPath, [
120338
+ async function getLocalProjectWorkingTreeAtRootPath(rootPath) {
120339
+ await assertGitRepository(rootPath);
120340
+ const statusResult = await runGitCommand$1(rootPath, [
120839
120341
  "status",
120840
120342
  "--porcelain=v1",
120841
120343
  "--untracked-files=normal"
@@ -120877,16 +120379,16 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120877
120379
  conflicted
120878
120380
  };
120879
120381
  }
120880
- function getLocalProjectGitStateAtRootPath(rootPath) {
120382
+ async function getLocalProjectGitStateAtRootPath(rootPath) {
120881
120383
  const normalizedRootPath = ensureLocalProjectRootPath(rootPath);
120882
- if (!isGitRepository(normalizedRootPath)) {
120384
+ if (!await isGitRepository(normalizedRootPath)) {
120883
120385
  return {
120884
120386
  git: false
120885
120387
  };
120886
120388
  }
120887
- const branches = listLocalProjectBranchesAtRootPath(normalizedRootPath);
120888
- const githubRemote = probeGitHubRemoteAtRootPath(normalizedRootPath);
120889
- const workingTree = getLocalProjectWorkingTreeAtRootPath(normalizedRootPath);
120389
+ const branches = await listLocalProjectBranchesAtRootPath(normalizedRootPath);
120390
+ const githubRemote = await probeGitHubRemoteAtRootPath(normalizedRootPath);
120391
+ const workingTree = await getLocalProjectWorkingTreeAtRootPath(normalizedRootPath);
120890
120392
  return {
120891
120393
  git: true,
120892
120394
  branches: branches.branches,
@@ -120904,19 +120406,19 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120904
120406
  if (workingTree.untracked) blockers.push("untracked files");
120905
120407
  return blockers;
120906
120408
  }
120907
- function checkoutLocalProjectBranchAtRootPath(rootPath, branchName) {
120409
+ async function checkoutLocalProjectBranchAtRootPath(rootPath, branchName) {
120908
120410
  const normalizedRootPath = ensureLocalProjectRootPath(rootPath);
120909
120411
  const normalizedBranchName = branchName.trim();
120910
120412
  if (!normalizedBranchName) {
120911
120413
  throw new Error("Branch name is required");
120912
120414
  }
120913
- assertGitRepository(normalizedRootPath);
120914
- const workingTree = getLocalProjectWorkingTreeAtRootPath(normalizedRootPath);
120415
+ await assertGitRepository(normalizedRootPath);
120416
+ const workingTree = await getLocalProjectWorkingTreeAtRootPath(normalizedRootPath);
120915
120417
  if (!workingTree.clean) {
120916
120418
  const blockers = getWorkingTreeBlockers(workingTree);
120917
120419
  throw new Error(`Cannot switch branches with local changes: ${blockers.join(", ")}`);
120918
120420
  }
120919
- const checkoutResult = runGitCommand$1(normalizedRootPath, [
120421
+ const checkoutResult = await runGitCommand$1(normalizedRootPath, [
120920
120422
  "checkout",
120921
120423
  normalizedBranchName
120922
120424
  ], {
@@ -120926,7 +120428,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
120926
120428
  const reason = checkoutResult.stderr.trim() || checkoutResult.stdout.trim() || "unknown error";
120927
120429
  throw new Error(`Failed to checkout git branch: ${reason}`);
120928
120430
  }
120929
- const currentResult = runGitCommand$1(normalizedRootPath, [
120431
+ const currentResult = await runGitCommand$1(normalizedRootPath, [
120930
120432
  "rev-parse",
120931
120433
  "--abbrev-ref",
120932
120434
  "HEAD"
@@ -121902,6 +121404,521 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
121902
121404
  }
121903
121405
  return void 0;
121904
121406
  };
121407
+ var crossSpawn = {
121408
+ exports: {}
121409
+ };
121410
+ var windows;
121411
+ var hasRequiredWindows;
121412
+ function requireWindows() {
121413
+ if (hasRequiredWindows) return windows;
121414
+ hasRequiredWindows = 1;
121415
+ windows = isexe;
121416
+ isexe.sync = sync2;
121417
+ var fs2 = fs__default;
121418
+ function checkPathExt(path2, options) {
121419
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
121420
+ if (!pathext) {
121421
+ return true;
121422
+ }
121423
+ pathext = pathext.split(";");
121424
+ if (pathext.indexOf("") !== -1) {
121425
+ return true;
121426
+ }
121427
+ for (var i2 = 0; i2 < pathext.length; i2++) {
121428
+ var p = pathext[i2].toLowerCase();
121429
+ if (p && path2.substr(-p.length).toLowerCase() === p) {
121430
+ return true;
121431
+ }
121432
+ }
121433
+ return false;
121434
+ }
121435
+ function checkStat(stat2, path2, options) {
121436
+ if (!stat2.isSymbolicLink() && !stat2.isFile()) {
121437
+ return false;
121438
+ }
121439
+ return checkPathExt(path2, options);
121440
+ }
121441
+ function isexe(path2, options, cb) {
121442
+ fs2.stat(path2, function(er, stat2) {
121443
+ cb(er, er ? false : checkStat(stat2, path2, options));
121444
+ });
121445
+ }
121446
+ function sync2(path2, options) {
121447
+ return checkStat(fs2.statSync(path2), path2, options);
121448
+ }
121449
+ return windows;
121450
+ }
121451
+ var mode;
121452
+ var hasRequiredMode;
121453
+ function requireMode() {
121454
+ if (hasRequiredMode) return mode;
121455
+ hasRequiredMode = 1;
121456
+ mode = isexe;
121457
+ isexe.sync = sync2;
121458
+ var fs2 = fs__default;
121459
+ function isexe(path2, options, cb) {
121460
+ fs2.stat(path2, function(er, stat2) {
121461
+ cb(er, er ? false : checkStat(stat2, options));
121462
+ });
121463
+ }
121464
+ function sync2(path2, options) {
121465
+ return checkStat(fs2.statSync(path2), options);
121466
+ }
121467
+ function checkStat(stat2, options) {
121468
+ return stat2.isFile() && checkMode(stat2, options);
121469
+ }
121470
+ function checkMode(stat2, options) {
121471
+ var mod2 = stat2.mode;
121472
+ var uid = stat2.uid;
121473
+ var gid = stat2.gid;
121474
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
121475
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
121476
+ var u = parseInt("100", 8);
121477
+ var g = parseInt("010", 8);
121478
+ var o = parseInt("001", 8);
121479
+ var ug = u | g;
121480
+ var ret = mod2 & o || mod2 & g && gid === myGid || mod2 & u && uid === myUid || mod2 & ug && myUid === 0;
121481
+ return ret;
121482
+ }
121483
+ return mode;
121484
+ }
121485
+ var isexe_1;
121486
+ var hasRequiredIsexe;
121487
+ function requireIsexe() {
121488
+ if (hasRequiredIsexe) return isexe_1;
121489
+ hasRequiredIsexe = 1;
121490
+ var core2;
121491
+ if (process.platform === "win32" || commonjsGlobal.TESTING_WINDOWS) {
121492
+ core2 = requireWindows();
121493
+ } else {
121494
+ core2 = requireMode();
121495
+ }
121496
+ isexe_1 = isexe;
121497
+ isexe.sync = sync2;
121498
+ function isexe(path2, options, cb) {
121499
+ if (typeof options === "function") {
121500
+ cb = options;
121501
+ options = {};
121502
+ }
121503
+ if (!cb) {
121504
+ if (typeof Promise !== "function") {
121505
+ throw new TypeError("callback not provided");
121506
+ }
121507
+ return new Promise(function(resolve2, reject) {
121508
+ isexe(path2, options || {}, function(er, is2) {
121509
+ if (er) {
121510
+ reject(er);
121511
+ } else {
121512
+ resolve2(is2);
121513
+ }
121514
+ });
121515
+ });
121516
+ }
121517
+ core2(path2, options || {}, function(er, is2) {
121518
+ if (er) {
121519
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
121520
+ er = null;
121521
+ is2 = false;
121522
+ }
121523
+ }
121524
+ cb(er, is2);
121525
+ });
121526
+ }
121527
+ function sync2(path2, options) {
121528
+ try {
121529
+ return core2.sync(path2, options || {});
121530
+ } catch (er) {
121531
+ if (options && options.ignoreErrors || er.code === "EACCES") {
121532
+ return false;
121533
+ } else {
121534
+ throw er;
121535
+ }
121536
+ }
121537
+ }
121538
+ return isexe_1;
121539
+ }
121540
+ var which_1;
121541
+ var hasRequiredWhich;
121542
+ function requireWhich() {
121543
+ if (hasRequiredWhich) return which_1;
121544
+ hasRequiredWhich = 1;
121545
+ const isWindows2 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
121546
+ const path2 = path__default;
121547
+ const COLON = isWindows2 ? ";" : ":";
121548
+ const isexe = requireIsexe();
121549
+ const getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), {
121550
+ code: "ENOENT"
121551
+ });
121552
+ const getPathInfo = (cmd, opt) => {
121553
+ const colon = opt.colon || COLON;
121554
+ const pathEnv = cmd.match(/\//) || isWindows2 && cmd.match(/\\/) ? [
121555
+ ""
121556
+ ] : [
121557
+ ...isWindows2 ? [
121558
+ process.cwd()
121559
+ ] : [],
121560
+ ...(opt.path || process.env.PATH || "").split(colon)
121561
+ ];
121562
+ const pathExtExe = isWindows2 ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
121563
+ const pathExt = isWindows2 ? pathExtExe.split(colon) : [
121564
+ ""
121565
+ ];
121566
+ if (isWindows2) {
121567
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "") pathExt.unshift("");
121568
+ }
121569
+ return {
121570
+ pathEnv,
121571
+ pathExt,
121572
+ pathExtExe
121573
+ };
121574
+ };
121575
+ const which = (cmd, opt, cb) => {
121576
+ if (typeof opt === "function") {
121577
+ cb = opt;
121578
+ opt = {};
121579
+ }
121580
+ if (!opt) opt = {};
121581
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
121582
+ const found = [];
121583
+ const step2 = (i2) => new Promise((resolve2, reject) => {
121584
+ if (i2 === pathEnv.length) return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
121585
+ const ppRaw = pathEnv[i2];
121586
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
121587
+ const pCmd = path2.join(pathPart, cmd);
121588
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
121589
+ resolve2(subStep(p, i2, 0));
121590
+ });
121591
+ const subStep = (p, i2, ii) => new Promise((resolve2, reject) => {
121592
+ if (ii === pathExt.length) return resolve2(step2(i2 + 1));
121593
+ const ext2 = pathExt[ii];
121594
+ isexe(p + ext2, {
121595
+ pathExt: pathExtExe
121596
+ }, (er, is2) => {
121597
+ if (!er && is2) {
121598
+ if (opt.all) found.push(p + ext2);
121599
+ else return resolve2(p + ext2);
121600
+ }
121601
+ return resolve2(subStep(p, i2, ii + 1));
121602
+ });
121603
+ });
121604
+ return cb ? step2(0).then((res) => cb(null, res), cb) : step2(0);
121605
+ };
121606
+ const whichSync = (cmd, opt) => {
121607
+ opt = opt || {};
121608
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
121609
+ const found = [];
121610
+ for (let i2 = 0; i2 < pathEnv.length; i2++) {
121611
+ const ppRaw = pathEnv[i2];
121612
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
121613
+ const pCmd = path2.join(pathPart, cmd);
121614
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
121615
+ for (let j = 0; j < pathExt.length; j++) {
121616
+ const cur = p + pathExt[j];
121617
+ try {
121618
+ const is2 = isexe.sync(cur, {
121619
+ pathExt: pathExtExe
121620
+ });
121621
+ if (is2) {
121622
+ if (opt.all) found.push(cur);
121623
+ else return cur;
121624
+ }
121625
+ } catch (ex) {
121626
+ }
121627
+ }
121628
+ }
121629
+ if (opt.all && found.length) return found;
121630
+ if (opt.nothrow) return null;
121631
+ throw getNotFoundError(cmd);
121632
+ };
121633
+ which_1 = which;
121634
+ which.sync = whichSync;
121635
+ return which_1;
121636
+ }
121637
+ var pathKey = {
121638
+ exports: {}
121639
+ };
121640
+ var hasRequiredPathKey;
121641
+ function requirePathKey() {
121642
+ if (hasRequiredPathKey) return pathKey.exports;
121643
+ hasRequiredPathKey = 1;
121644
+ const pathKey$1 = (options = {}) => {
121645
+ const environment2 = options.env || process.env;
121646
+ const platform2 = options.platform || process.platform;
121647
+ if (platform2 !== "win32") {
121648
+ return "PATH";
121649
+ }
121650
+ return Object.keys(environment2).reverse().find((key2) => key2.toUpperCase() === "PATH") || "Path";
121651
+ };
121652
+ pathKey.exports = pathKey$1;
121653
+ pathKey.exports.default = pathKey$1;
121654
+ return pathKey.exports;
121655
+ }
121656
+ var resolveCommand_1;
121657
+ var hasRequiredResolveCommand;
121658
+ function requireResolveCommand() {
121659
+ if (hasRequiredResolveCommand) return resolveCommand_1;
121660
+ hasRequiredResolveCommand = 1;
121661
+ const path2 = path__default;
121662
+ const which = requireWhich();
121663
+ const getPathKey = requirePathKey();
121664
+ function resolveCommandAttempt(parsed, withoutPathExt) {
121665
+ const env2 = parsed.options.env || process.env;
121666
+ const cwd = process.cwd();
121667
+ const hasCustomCwd = parsed.options.cwd != null;
121668
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
121669
+ if (shouldSwitchCwd) {
121670
+ try {
121671
+ process.chdir(parsed.options.cwd);
121672
+ } catch (err2) {
121673
+ }
121674
+ }
121675
+ let resolved;
121676
+ try {
121677
+ resolved = which.sync(parsed.command, {
121678
+ path: env2[getPathKey({
121679
+ env: env2
121680
+ })],
121681
+ pathExt: withoutPathExt ? path2.delimiter : void 0
121682
+ });
121683
+ } catch (e) {
121684
+ } finally {
121685
+ if (shouldSwitchCwd) {
121686
+ process.chdir(cwd);
121687
+ }
121688
+ }
121689
+ if (resolved) {
121690
+ resolved = path2.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
121691
+ }
121692
+ return resolved;
121693
+ }
121694
+ function resolveCommand(parsed) {
121695
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
121696
+ }
121697
+ resolveCommand_1 = resolveCommand;
121698
+ return resolveCommand_1;
121699
+ }
121700
+ var _escape = {};
121701
+ var hasRequired_escape;
121702
+ function require_escape() {
121703
+ if (hasRequired_escape) return _escape;
121704
+ hasRequired_escape = 1;
121705
+ const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
121706
+ function escapeCommand(arg) {
121707
+ arg = arg.replace(metaCharsRegExp, "^$1");
121708
+ return arg;
121709
+ }
121710
+ function escapeArgument(arg, doubleEscapeMetaChars) {
121711
+ arg = `${arg}`;
121712
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
121713
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
121714
+ arg = `"${arg}"`;
121715
+ arg = arg.replace(metaCharsRegExp, "^$1");
121716
+ if (doubleEscapeMetaChars) {
121717
+ arg = arg.replace(metaCharsRegExp, "^$1");
121718
+ }
121719
+ return arg;
121720
+ }
121721
+ _escape.command = escapeCommand;
121722
+ _escape.argument = escapeArgument;
121723
+ return _escape;
121724
+ }
121725
+ var shebangRegex;
121726
+ var hasRequiredShebangRegex;
121727
+ function requireShebangRegex() {
121728
+ if (hasRequiredShebangRegex) return shebangRegex;
121729
+ hasRequiredShebangRegex = 1;
121730
+ shebangRegex = /^#!(.*)/;
121731
+ return shebangRegex;
121732
+ }
121733
+ var shebangCommand;
121734
+ var hasRequiredShebangCommand;
121735
+ function requireShebangCommand() {
121736
+ if (hasRequiredShebangCommand) return shebangCommand;
121737
+ hasRequiredShebangCommand = 1;
121738
+ const shebangRegex2 = requireShebangRegex();
121739
+ shebangCommand = (string2 = "") => {
121740
+ const match5 = string2.match(shebangRegex2);
121741
+ if (!match5) {
121742
+ return null;
121743
+ }
121744
+ const [path2, argument2] = match5[0].replace(/#! ?/, "").split(" ");
121745
+ const binary2 = path2.split("/").pop();
121746
+ if (binary2 === "env") {
121747
+ return argument2;
121748
+ }
121749
+ return argument2 ? `${binary2} ${argument2}` : binary2;
121750
+ };
121751
+ return shebangCommand;
121752
+ }
121753
+ var readShebang_1;
121754
+ var hasRequiredReadShebang;
121755
+ function requireReadShebang() {
121756
+ if (hasRequiredReadShebang) return readShebang_1;
121757
+ hasRequiredReadShebang = 1;
121758
+ const fs2 = fs__default;
121759
+ const shebangCommand2 = requireShebangCommand();
121760
+ function readShebang(command2) {
121761
+ const size2 = 150;
121762
+ const buffer2 = Buffer.alloc(size2);
121763
+ let fd;
121764
+ try {
121765
+ fd = fs2.openSync(command2, "r");
121766
+ fs2.readSync(fd, buffer2, 0, size2, 0);
121767
+ fs2.closeSync(fd);
121768
+ } catch (e) {
121769
+ }
121770
+ return shebangCommand2(buffer2.toString());
121771
+ }
121772
+ readShebang_1 = readShebang;
121773
+ return readShebang_1;
121774
+ }
121775
+ var parse_1;
121776
+ var hasRequiredParse;
121777
+ function requireParse() {
121778
+ if (hasRequiredParse) return parse_1;
121779
+ hasRequiredParse = 1;
121780
+ const path2 = path__default;
121781
+ const resolveCommand = requireResolveCommand();
121782
+ const escape2 = require_escape();
121783
+ const readShebang = requireReadShebang();
121784
+ const isWin = process.platform === "win32";
121785
+ const isExecutableRegExp = /\.(?:com|exe)$/i;
121786
+ const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
121787
+ function detectShebang(parsed) {
121788
+ parsed.file = resolveCommand(parsed);
121789
+ const shebang = parsed.file && readShebang(parsed.file);
121790
+ if (shebang) {
121791
+ parsed.args.unshift(parsed.file);
121792
+ parsed.command = shebang;
121793
+ return resolveCommand(parsed);
121794
+ }
121795
+ return parsed.file;
121796
+ }
121797
+ function parseNonShell(parsed) {
121798
+ if (!isWin) {
121799
+ return parsed;
121800
+ }
121801
+ const commandFile = detectShebang(parsed);
121802
+ const needsShell = !isExecutableRegExp.test(commandFile);
121803
+ if (parsed.options.forceShell || needsShell) {
121804
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
121805
+ parsed.command = path2.normalize(parsed.command);
121806
+ parsed.command = escape2.command(parsed.command);
121807
+ parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
121808
+ const shellCommand = [
121809
+ parsed.command
121810
+ ].concat(parsed.args).join(" ");
121811
+ parsed.args = [
121812
+ "/d",
121813
+ "/s",
121814
+ "/c",
121815
+ `"${shellCommand}"`
121816
+ ];
121817
+ parsed.command = process.env.comspec || "cmd.exe";
121818
+ parsed.options.windowsVerbatimArguments = true;
121819
+ }
121820
+ return parsed;
121821
+ }
121822
+ function parse2(command2, args2, options) {
121823
+ if (args2 && !Array.isArray(args2)) {
121824
+ options = args2;
121825
+ args2 = null;
121826
+ }
121827
+ args2 = args2 ? args2.slice(0) : [];
121828
+ options = Object.assign({}, options);
121829
+ const parsed = {
121830
+ command: command2,
121831
+ args: args2,
121832
+ options,
121833
+ file: void 0,
121834
+ original: {
121835
+ command: command2,
121836
+ args: args2
121837
+ }
121838
+ };
121839
+ return options.shell ? parsed : parseNonShell(parsed);
121840
+ }
121841
+ parse_1 = parse2;
121842
+ return parse_1;
121843
+ }
121844
+ var enoent;
121845
+ var hasRequiredEnoent;
121846
+ function requireEnoent() {
121847
+ if (hasRequiredEnoent) return enoent;
121848
+ hasRequiredEnoent = 1;
121849
+ const isWin = process.platform === "win32";
121850
+ function notFoundError(original, syscall) {
121851
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
121852
+ code: "ENOENT",
121853
+ errno: "ENOENT",
121854
+ syscall: `${syscall} ${original.command}`,
121855
+ path: original.command,
121856
+ spawnargs: original.args
121857
+ });
121858
+ }
121859
+ function hookChildProcess(cp, parsed) {
121860
+ if (!isWin) {
121861
+ return;
121862
+ }
121863
+ const originalEmit = cp.emit;
121864
+ cp.emit = function(name2, arg1) {
121865
+ if (name2 === "exit") {
121866
+ const err2 = verifyENOENT(arg1, parsed);
121867
+ if (err2) {
121868
+ return originalEmit.call(cp, "error", err2);
121869
+ }
121870
+ }
121871
+ return originalEmit.apply(cp, arguments);
121872
+ };
121873
+ }
121874
+ function verifyENOENT(status, parsed) {
121875
+ if (isWin && status === 1 && !parsed.file) {
121876
+ return notFoundError(parsed.original, "spawn");
121877
+ }
121878
+ return null;
121879
+ }
121880
+ function verifyENOENTSync(status, parsed) {
121881
+ if (isWin && status === 1 && !parsed.file) {
121882
+ return notFoundError(parsed.original, "spawnSync");
121883
+ }
121884
+ return null;
121885
+ }
121886
+ enoent = {
121887
+ hookChildProcess,
121888
+ verifyENOENT,
121889
+ verifyENOENTSync,
121890
+ notFoundError
121891
+ };
121892
+ return enoent;
121893
+ }
121894
+ var hasRequiredCrossSpawn;
121895
+ function requireCrossSpawn() {
121896
+ if (hasRequiredCrossSpawn) return crossSpawn.exports;
121897
+ hasRequiredCrossSpawn = 1;
121898
+ const cp = require$$1$8;
121899
+ const parse2 = requireParse();
121900
+ const enoent2 = requireEnoent();
121901
+ function spawn2(command2, args2, options) {
121902
+ const parsed = parse2(command2, args2, options);
121903
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
121904
+ enoent2.hookChildProcess(spawned, parsed);
121905
+ return spawned;
121906
+ }
121907
+ function spawnSync(command2, args2, options) {
121908
+ const parsed = parse2(command2, args2, options);
121909
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
121910
+ result.error = result.error || enoent2.verifyENOENTSync(result.status, parsed);
121911
+ return result;
121912
+ }
121913
+ crossSpawn.exports = spawn2;
121914
+ crossSpawn.exports.spawn = spawn2;
121915
+ crossSpawn.exports.sync = spawnSync;
121916
+ crossSpawn.exports._parse = parse2;
121917
+ crossSpawn.exports._enoent = enoent2;
121918
+ return crossSpawn.exports;
121919
+ }
121920
+ var crossSpawnExports = requireCrossSpawn();
121921
+ const spawn = getDefaultExportFromCjs(crossSpawnExports);
121905
121922
  const AGENT_METHODS = {
121906
121923
  authenticate: "authenticate",
121907
121924
  document_did_change: "document/didChange",
@@ -133697,6 +133714,8 @@ ${error2.stderrTail ?? ""}`;
133697
133714
  }
133698
133715
  return null;
133699
133716
  };
133717
+ const execFileAsync$2 = promisify$1(execFile$1);
133718
+ const TITLE_GIT_TIMEOUT_MS = 5e3;
133700
133719
  const buildTitlePrompt = (taskPrompt) => {
133701
133720
  const text = DEFAULT_TITLE_GENERATION_PROMPT.replace(/\$\{prompt\}/g, taskPrompt);
133702
133721
  return [
@@ -133715,42 +133734,39 @@ ${error2.stderrTail ?? ""}`;
133715
133734
  if (!withoutMarkdown) return null;
133716
133735
  return withoutMarkdown.slice(0, 80);
133717
133736
  };
133718
- const ensureWorkdirIsGitRepo = (workdir, logger2) => {
133719
- const isGitRepo = () => {
133737
+ const ensureWorkdirIsGitRepo = async (workdir, logger2) => {
133738
+ const isGitRepo = async () => {
133720
133739
  try {
133721
- const result = spawn.sync("git", [
133740
+ const result = await execFileAsync$2("git", [
133722
133741
  "rev-parse",
133723
133742
  "--is-inside-work-tree"
133724
133743
  ], {
133725
133744
  cwd: workdir,
133726
- stdio: "ignore"
133745
+ encoding: "utf8",
133746
+ timeout: TITLE_GIT_TIMEOUT_MS
133727
133747
  });
133728
- return result.status === 0 && !result.error;
133748
+ return String(result.stdout ?? "").trim() === "true";
133729
133749
  } catch {
133730
133750
  return false;
133731
133751
  }
133732
133752
  };
133733
- if (isGitRepo()) {
133753
+ if (await isGitRepo()) {
133734
133754
  return true;
133735
133755
  }
133736
133756
  try {
133737
- const result = spawn.sync("git", [
133757
+ await execFileAsync$2("git", [
133738
133758
  "init",
133739
133759
  "--quiet"
133740
133760
  ], {
133741
133761
  cwd: workdir,
133742
- stdio: "ignore"
133762
+ encoding: "utf8",
133763
+ timeout: TITLE_GIT_TIMEOUT_MS
133743
133764
  });
133744
- if (result.status !== 0 || result.error) {
133745
- const errorMessage = result.error?.message ?? `git init exited with code ${result.status}`;
133746
- logger2.debug(`[title-generator] Failed to init git repo in ${workdir}: ${errorMessage}`);
133747
- return false;
133748
- }
133749
133765
  } catch (error2) {
133750
133766
  logger2.debug(`[title-generator] Failed to init git repo in ${workdir}: ${formatErrorMessage(error2)}`);
133751
133767
  return false;
133752
133768
  }
133753
- return isGitRepo();
133769
+ return await isGitRepo();
133754
133770
  };
133755
133771
  const noopTerminalManager = {
133756
133772
  createTerminal: async () => {
@@ -133772,7 +133788,7 @@ ${error2.stderrTail ?? ""}`;
133772
133788
  fs$4.mkdirSync(workdir, {
133773
133789
  recursive: true
133774
133790
  });
133775
- if (options.agentType === "codex" && !ensureWorkdirIsGitRepo(workdir, options.logger)) {
133791
+ if (options.agentType === "codex" && !await ensureWorkdirIsGitRepo(workdir, options.logger)) {
133776
133792
  return sanitizeTitle(options.taskPrompt);
133777
133793
  }
133778
133794
  const collectTextFromUpdate = (notification) => {
@@ -136526,9 +136542,11 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
136526
136542
  }
136527
136543
  return resolveAgentConfigEnvForSessionResume(repo, options.agentConfigId);
136528
136544
  };
136529
- function getMemoryPressureSnapshot() {
136530
- const windowsStatus = getWindowsMemoryStatus();
136531
- const systemAvailable = getSystemAvailableMemoryBytes(windowsStatus);
136545
+ const execFileAsync$1 = promisify$1(execFile$1);
136546
+ const MEMORY_PROBE_TIMEOUT_MS = 1e3;
136547
+ async function getMemoryPressureSnapshot() {
136548
+ const windowsStatus = await getWindowsMemoryStatus();
136549
+ const systemAvailable = await getSystemAvailableMemoryBytes(windowsStatus);
136532
136550
  const cgroupAvailable = getCgroupAvailableMemoryBytes();
136533
136551
  const availableMemoryBytes = cgroupAvailable !== null ? Math.min(systemAvailable, cgroupAvailable) : systemAvailable;
136534
136552
  const effectiveMemoryLimitBytes = getEffectiveMemoryLimitBytes();
@@ -136550,14 +136568,17 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
136550
136568
  }
136551
136569
  return totalMem;
136552
136570
  }
136553
- function getSystemAvailableMemoryBytes(windowsStatus) {
136571
+ async function getSystemAvailableMemoryBytes(windowsStatus) {
136554
136572
  if (windowsStatus) {
136555
136573
  return Math.max(windowsStatus.availableBytes, os__default.freemem());
136556
136574
  }
136557
- const darwinAvailable = getDarwinAvailableMemoryBytes();
136575
+ const darwinAvailable = await getDarwinAvailableMemoryBytes();
136558
136576
  if (darwinAvailable !== null) {
136559
136577
  return darwinAvailable;
136560
136578
  }
136579
+ return getSystemAvailableMemoryBytesSync();
136580
+ }
136581
+ function getSystemAvailableMemoryBytesSync() {
136561
136582
  try {
136562
136583
  const meminfo = readFileSync("/proc/meminfo", "utf8");
136563
136584
  const match5 = meminfo.match(/MemAvailable:\s+(\d+)/);
@@ -136568,7 +136589,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
136568
136589
  }
136569
136590
  return os__default.freemem();
136570
136591
  }
136571
- function getWindowsMemoryStatus() {
136592
+ async function getWindowsMemoryStatus() {
136572
136593
  if (process.platform !== "win32") {
136573
136594
  return null;
136574
136595
  }
@@ -136578,7 +136599,7 @@ $mem = Get-CimInstance -ClassName Win32_PerfFormattedData_PerfOS_Memory |
136578
136599
  Select-Object AvailableBytes, CommitLimit, CommittedBytes
136579
136600
  $mem | ConvertTo-Json -Compress
136580
136601
  `;
136581
- const output = execFileSync("powershell.exe", [
136602
+ const { stdout } = await execFileAsync$1("powershell.exe", [
136582
136603
  "-NoProfile",
136583
136604
  "-NonInteractive",
136584
136605
  "-ExecutionPolicy",
@@ -136586,9 +136607,11 @@ $mem | ConvertTo-Json -Compress
136586
136607
  "-Command",
136587
136608
  script
136588
136609
  ], {
136589
- encoding: "utf8"
136610
+ encoding: "utf8",
136611
+ timeout: MEMORY_PROBE_TIMEOUT_MS,
136612
+ windowsHide: true
136590
136613
  });
136591
- return parseWindowsMemoryStatus(output);
136614
+ return parseWindowsMemoryStatus(String(stdout ?? ""));
136592
136615
  } catch {
136593
136616
  return null;
136594
136617
  }
@@ -136612,15 +136635,16 @@ $mem | ConvertTo-Json -Compress
136612
136635
  return null;
136613
136636
  }
136614
136637
  }
136615
- function getDarwinAvailableMemoryBytes() {
136638
+ async function getDarwinAvailableMemoryBytes() {
136616
136639
  if (process.platform !== "darwin") {
136617
136640
  return null;
136618
136641
  }
136619
136642
  try {
136620
- const vmStatOutput = execFileSync("vm_stat", {
136621
- encoding: "utf8"
136643
+ const { stdout } = await execFileAsync$1("vm_stat", [], {
136644
+ encoding: "utf8",
136645
+ timeout: MEMORY_PROBE_TIMEOUT_MS
136622
136646
  });
136623
- const parsed = parseDarwinAvailableMemoryBytes(vmStatOutput);
136647
+ const parsed = parseDarwinAvailableMemoryBytes(String(stdout ?? ""));
136624
136648
  if (parsed !== null) {
136625
136649
  return Math.max(parsed, os__default.freemem());
136626
136650
  }
@@ -137194,13 +137218,13 @@ $mem | ConvertTo-Json -Compress
137194
137218
  }
137195
137219
  async logTurnStartResources(sessionId, mode2) {
137196
137220
  try {
137197
- const memorySnapshot = getMemoryPressureSnapshot();
137198
- const availableMemoryBytes = memorySnapshot.availableMemoryBytes;
137199
- const memoryFreePercent = memorySnapshot.effectiveMemoryLimitBytes > 0 ? availableMemoryBytes / memorySnapshot.effectiveMemoryLimitBytes * 100 : null;
137200
- const [resources, freeDiskBytes] = await Promise.all([
137221
+ const [memorySnapshot, resources, freeDiskBytes] = await Promise.all([
137222
+ getMemoryPressureSnapshot(),
137201
137223
  this.deps.collectMachineResources().catch(() => null),
137202
137224
  this.getFreeDiskBytes()
137203
137225
  ]);
137226
+ const availableMemoryBytes = memorySnapshot.availableMemoryBytes;
137227
+ const memoryFreePercent = memorySnapshot.effectiveMemoryLimitBytes > 0 ? availableMemoryBytes / memorySnapshot.effectiveMemoryLimitBytes * 100 : null;
137204
137228
  const cpuUsagePercent = resources?.cpuUsagePercent ?? null;
137205
137229
  this.deps.logger.info(`[${sessionId}] Turn start resources (mode=${mode2}): memoryAvailable=${this.formatGiB(availableMemoryBytes)} memoryAvailablePercent=${this.formatPercent(memoryFreePercent)} cpuUsage=${this.formatPercent(cpuUsagePercent)} diskFree=${this.formatGiB(freeDiskBytes)}`);
137206
137230
  } catch (error2) {
@@ -137458,9 +137482,9 @@ $mem | ConvertTo-Json -Compress
137458
137482
  this.deps.logger.warn(`[${options.sessionId}] Failed to finalize halted turn ${options.turnId} (${options.reason}): ${formatErrorMessage(error2)}`);
137459
137483
  }
137460
137484
  }
137461
- prepareLocalProjectBranch(options) {
137485
+ async prepareLocalProjectBranch(options) {
137462
137486
  const { project, workdir, branch } = options;
137463
- const gitState = getLocalProjectGitStateAtRootPath(workdir);
137487
+ const gitState = await getLocalProjectGitStateAtRootPath(workdir);
137464
137488
  if (!gitState.git) {
137465
137489
  throw new Error(`Local project is not a git repository: ${project.localProjectId}`);
137466
137490
  }
@@ -137470,7 +137494,7 @@ $mem | ConvertTo-Json -Compress
137470
137494
  if (project.useWorktree === true || gitState.currentBranch === branch) {
137471
137495
  return branch;
137472
137496
  }
137473
- return checkoutLocalProjectBranchAtRootPath(workdir, branch).currentBranch;
137497
+ return (await checkoutLocalProjectBranchAtRootPath(workdir, branch)).currentBranch;
137474
137498
  }
137475
137499
  isAgentDisconnectedError(error2) {
137476
137500
  const errorMessage = formatErrorMessage(error2).toLowerCase();
@@ -138487,11 +138511,12 @@ $mem | ConvertTo-Json -Compress
138487
138511
  return void 0;
138488
138512
  }
138489
138513
  if (branch) {
138490
- branch = self2.prepareLocalProjectBranch({
138514
+ const requestedBranch = branch;
138515
+ branch = yield* self2.tryPromise(() => self2.prepareLocalProjectBranch({
138491
138516
  project,
138492
138517
  workdir,
138493
- branch
138494
- });
138518
+ branch: requestedBranch
138519
+ }));
138495
138520
  sessionConfig.branch = branch;
138496
138521
  }
138497
138522
  }
@@ -144511,7 +144536,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
144511
144536
  return failure("local_project_not_found", `Local project not found: ${args2.localProjectId}`);
144512
144537
  }
144513
144538
  try {
144514
- const state2 = getLocalProjectGitStateAtRootPath(rootPath);
144539
+ const state2 = await getLocalProjectGitStateAtRootPath(rootPath);
144515
144540
  return {
144516
144541
  type: "local-project/git-state_response",
144517
144542
  machineId: this.machineId,
@@ -146658,7 +146683,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
146658
146683
  async evictForMemoryPressure(excludeSessionId) {
146659
146684
  const thresholdBytes = this.config.memoryThresholdBytes;
146660
146685
  const commitThresholdBytes = getWindowsCommitThresholdBytes(thresholdBytes);
146661
- let memorySnapshot = getMemoryPressureSnapshot();
146686
+ let memorySnapshot = await getMemoryPressureSnapshot();
146662
146687
  let availableMemory = memorySnapshot.availableMemoryBytes;
146663
146688
  let pressureReason = this.getPressureReason(memorySnapshot, thresholdBytes, commitThresholdBytes);
146664
146689
  if (!this.config.enabled) {
@@ -146715,7 +146740,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
146715
146740
  this.deps.logger.debug(`[GC] Evicting session ${sessionId} (idle ${Math.round(idleMs / 1e3)}s) due to memory pressure`);
146716
146741
  await this.deps.cleanSession(sessionId);
146717
146742
  evictedSessionIds.push(sessionId);
146718
- memorySnapshot = getMemoryPressureSnapshot();
146743
+ memorySnapshot = await getMemoryPressureSnapshot();
146719
146744
  availableMemory = memorySnapshot.availableMemoryBytes;
146720
146745
  pressureReason = this.getPressureReason(memorySnapshot, thresholdBytes, commitThresholdBytes);
146721
146746
  } catch (error2) {
@@ -147839,7 +147864,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
147839
147864
  const wrapperSourceTemplate = `#!/usr/bin/env node
147840
147865
  'use strict';
147841
147866
 
147842
- const { spawn, spawnSync } = require('child_process');
147867
+ const { spawn } = require('child_process');
147843
147868
  const crypto = require('crypto');
147844
147869
  const fs = require('fs');
147845
147870
  const path = require('path');
@@ -147929,10 +147954,40 @@ const spawnGh = (command, args, options) => {
147929
147954
  return spawn(spec.command, spec.args, options);
147930
147955
  };
147931
147956
 
147932
- const spawnSyncGh = (command, args, options) => {
147957
+ const runGhCommand = (command, args, options) => new Promise((resolve) => {
147933
147958
  const spec = buildWindowsSpawnSpec(command, args);
147934
- return spawnSync(spec.command, spec.args, options);
147935
- };
147959
+ const timeoutMs = Number(options && options.timeout) || 0;
147960
+ const child = spawn(spec.command, spec.args, {
147961
+ ...options,
147962
+ timeout: undefined,
147963
+ });
147964
+ let stdout = '';
147965
+ if (child.stdout) {
147966
+ child.stdout.on('data', (chunk) => {
147967
+ stdout += String(chunk || '');
147968
+ });
147969
+ }
147970
+ let settled = false;
147971
+ let timeoutId = null;
147972
+ const finish = (result) => {
147973
+ if (settled) return;
147974
+ settled = true;
147975
+ if (timeoutId) clearTimeout(timeoutId);
147976
+ resolve({ stdout, ...result });
147977
+ };
147978
+ if (timeoutMs > 0) {
147979
+ timeoutId = setTimeout(() => {
147980
+ try {
147981
+ child.kill('SIGTERM');
147982
+ } catch {
147983
+ // best effort
147984
+ }
147985
+ finish({ status: null, error: new Error('Command timed out') });
147986
+ }, timeoutMs);
147987
+ }
147988
+ child.on('error', (error) => finish({ status: null, error }));
147989
+ child.on('close', (code) => finish({ status: code == null ? null : code }));
147990
+ });
147936
147991
 
147937
147992
  const fingerprintToken = (token) => crypto.createHash('sha256').update(token).digest('hex');
147938
147993
 
@@ -147978,10 +148033,10 @@ const buildGhAuthEnv = (env) => {
147978
148033
  return nextEnv;
147979
148034
  };
147980
148035
 
147981
- const isGhCliAuthed = (ghPath) => {
148036
+ const isGhCliAuthed = async (ghPath) => {
147982
148037
  if (!ghPath) return false;
147983
148038
  try {
147984
- const result = spawnSyncGh(ghPath, ['auth', 'status'], {
148039
+ const result = await runGhCommand(ghPath, ['auth', 'status'], {
147985
148040
  env: buildGhAuthEnv(process.env),
147986
148041
  stdio: ['ignore', 'ignore', 'ignore'],
147987
148042
  timeout: 5000,
@@ -148020,9 +148075,9 @@ const parseRepoFromUrl = (raw) => {
148020
148075
  return null;
148021
148076
  };
148022
148077
 
148023
- const readGitRemoteOrigin = () => {
148078
+ const readGitRemoteOrigin = async () => {
148024
148079
  try {
148025
- const result = spawnSync('git', ['remote', 'get-url', 'origin'], {
148080
+ const result = await runGhCommand('git', ['remote', 'get-url', 'origin'], {
148026
148081
  encoding: 'utf8',
148027
148082
  stdio: ['ignore', 'pipe', 'ignore'],
148028
148083
  timeout: 5000,
@@ -148034,12 +148089,12 @@ const readGitRemoteOrigin = () => {
148034
148089
  }
148035
148090
  };
148036
148091
 
148037
- const readRepoFullName = () => {
148092
+ const readRepoFullName = async () => {
148038
148093
  const fromEnv =
148039
148094
  process.env.LODY_GITHUB_REPO_FULL_NAME ||
148040
148095
  process.env.GITHUB_REPOSITORY ||
148041
148096
  process.env.GH_REPO;
148042
- return parseRepoFromUrl(fromEnv) || parseRepoFromUrl(readGitRemoteOrigin());
148097
+ return parseRepoFromUrl(fromEnv) || parseRepoFromUrl(await readGitRemoteOrigin());
148043
148098
  };
148044
148099
 
148045
148100
  const BROKER_STATE_PATHS = [
@@ -148205,7 +148260,7 @@ const buildGhEnv = async (ghCommand) => {
148205
148260
  return { env };
148206
148261
  }
148207
148262
 
148208
- const repoFullName = readRepoFullName();
148263
+ const repoFullName = await readRepoFullName();
148209
148264
  const hasBroker = !!getBrokerConfig();
148210
148265
  if (repoFullName && hasBroker) {
148211
148266
  const result = await fetchTokenFromBroker(repoFullName);
@@ -148217,7 +148272,7 @@ const buildGhEnv = async (ghCommand) => {
148217
148272
  return { env };
148218
148273
  }
148219
148274
 
148220
- if (isGhCliAuthed(ghCommand)) {
148275
+ if (await isGhCliAuthed(ghCommand)) {
148221
148276
  clearManagedTokenEnv(env);
148222
148277
  return { env };
148223
148278
  }
@@ -155315,8 +155370,13 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
155315
155370
  const DEFAULT_LOCAL_PROJECT_READ_MAX_BYTES = 64 * 1024;
155316
155371
  const HARD_LOCAL_PROJECT_READ_MAX_BYTES = 1024 * 1024;
155317
155372
  const GIT_COMMAND_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
155373
+ const LOCAL_PROJECT_GIT_COMMAND_TIMEOUT_MS = 5e3;
155374
+ const LOCAL_PROJECT_WALK_YIELD_EVERY_ENTRIES = 1e3;
155318
155375
  const execFileAsync = promisify(execFile);
155319
155376
  const LOCAL_REPO_ID_RE = /^local---[0-9a-f]{12}$/;
155377
+ const yieldToEventLoop = () => new Promise((resolve2) => {
155378
+ setImmediate(resolve2);
155379
+ });
155320
155380
  function clampInteger(value, min2, max2, fallback2) {
155321
155381
  if (typeof value !== "number" || Number.isNaN(value) || !Number.isFinite(value)) {
155322
155382
  return fallback2;
@@ -155394,7 +155454,14 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
155394
155454
  const result = await execFileAsync("git", args2, {
155395
155455
  cwd: rootPath,
155396
155456
  encoding: "utf8",
155397
- maxBuffer: GIT_COMMAND_MAX_BUFFER_BYTES
155457
+ maxBuffer: GIT_COMMAND_MAX_BUFFER_BYTES,
155458
+ timeout: LOCAL_PROJECT_GIT_COMMAND_TIMEOUT_MS,
155459
+ killSignal: "SIGTERM",
155460
+ env: {
155461
+ ...process.env,
155462
+ GIT_TERMINAL_PROMPT: "0",
155463
+ GIT_OPTIONAL_LOCKS: "0"
155464
+ }
155398
155465
  });
155399
155466
  return {
155400
155467
  status: 0,
@@ -155535,7 +155602,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
155535
155602
  return ignored;
155536
155603
  };
155537
155604
  }
155538
- function listLocalProjectFilesByWalk(rootPath, maxFiles) {
155605
+ async function listLocalProjectFilesByWalk(rootPath, maxFiles) {
155539
155606
  const paths = [];
155540
155607
  const stack = [
155541
155608
  {
@@ -155545,18 +155612,24 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
155545
155612
  ];
155546
155613
  const shouldIgnorePath = buildGitignoreMatcher(rootPath);
155547
155614
  let truncated = false;
155615
+ let entriesSinceYield = 0;
155548
155616
  while (stack.length > 0 && !truncated) {
155549
155617
  const current2 = stack.pop();
155550
155618
  if (!current2) break;
155551
155619
  let entries = [];
155552
155620
  try {
155553
- entries = fs$6.readdirSync(current2.absolutePath, {
155621
+ entries = await fs$6.promises.readdir(current2.absolutePath, {
155554
155622
  withFileTypes: true
155555
155623
  });
155556
155624
  } catch {
155557
155625
  continue;
155558
155626
  }
155559
155627
  for (const entry2 of entries) {
155628
+ entriesSinceYield += 1;
155629
+ if (entriesSinceYield >= LOCAL_PROJECT_WALK_YIELD_EVERY_ENTRIES) {
155630
+ entriesSinceYield = 0;
155631
+ await yieldToEventLoop();
155632
+ }
155560
155633
  const name2 = entry2.name;
155561
155634
  if (!name2 || name2 === "." || name2 === "..") {
155562
155635
  continue;
@@ -155597,7 +155670,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
155597
155670
  }
155598
155671
  async function listFilesAtRootPath(rootPath, maxFiles) {
155599
155672
  const normalizedRootPath = normalizeRootPath(rootPath);
155600
- return await listLocalProjectFilesFromGit(normalizedRootPath, maxFiles) ?? listLocalProjectFilesByWalk(normalizedRootPath, maxFiles);
155673
+ return await listLocalProjectFilesFromGit(normalizedRootPath, maxFiles) ?? await listLocalProjectFilesByWalk(normalizedRootPath, maxFiles);
155601
155674
  }
155602
155675
  function resolveSessionWorktreeRootPath(repoKey, sessionId) {
155603
155676
  const normalizedRepoKey = repoKey.trim();
@@ -155630,8 +155703,8 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
155630
155703
  rootPath: resolvedRootPath
155631
155704
  };
155632
155705
  }
155633
- getProjectGitState(rootPath) {
155634
- return getLocalProjectGitStateAtRootPath(rootPath);
155706
+ async getProjectGitState(rootPath) {
155707
+ return await getLocalProjectGitStateAtRootPath(rootPath);
155635
155708
  }
155636
155709
  async listProjectFiles(rootPath, options) {
155637
155710
  const maxFiles = clampInteger(options?.maxFiles, 1, HARD_LOCAL_PROJECT_MAX_FILES, DEFAULT_LOCAL_PROJECT_MAX_FILES);
@@ -155641,9 +155714,9 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
155641
155714
  const maxBytes = clampInteger(options?.maxBytes, 1, HARD_LOCAL_PROJECT_READ_MAX_BYTES, DEFAULT_LOCAL_PROJECT_READ_MAX_BYTES);
155642
155715
  return readLocalFileAtRoot(rootPath, relativePath, maxBytes);
155643
155716
  }
155644
- checkoutProjectBranch(rootPath, branchName) {
155717
+ async checkoutProjectBranch(rootPath, branchName) {
155645
155718
  try {
155646
- const result = checkoutLocalProjectBranchAtRootPath(rootPath, branchName);
155719
+ const result = await checkoutLocalProjectBranchAtRootPath(rootPath, branchName);
155647
155720
  return {
155648
155721
  success: true,
155649
155722
  currentBranch: result.currentBranch
@@ -156378,7 +156451,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
156378
156451
  return {
156379
156452
  ok: true,
156380
156453
  type: "local-project/git-state",
156381
- result: this.localProjectControlService.getProjectGitState(rootPath)
156454
+ result: await this.localProjectControlService.getProjectGitState(rootPath)
156382
156455
  };
156383
156456
  }
156384
156457
  if (message.type === "local-project/list-files") {
@@ -156409,7 +156482,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
156409
156482
  return {
156410
156483
  ok: true,
156411
156484
  type: "local-project/checkout-branch",
156412
- result: this.localProjectControlService.checkoutProjectBranch(rootPath, message.branchName)
156485
+ result: await this.localProjectControlService.checkoutProjectBranch(rootPath, message.branchName)
156413
156486
  };
156414
156487
  }
156415
156488
  if (message.type === "local-project/sync-history") {
@@ -186624,7 +186697,7 @@ ${entry2.text}`).join("\n\n");
186624
186697
  throw new Error(`Local project selector is ambiguous: ${normalizedSelector}. Use a project id instead.`);
186625
186698
  }
186626
186699
  const project = matches[0];
186627
- const branch = resolveLocalProjectBranchForCreate(project, requestedBranch);
186700
+ const branch = await resolveLocalProjectBranchForCreate(project, requestedBranch);
186628
186701
  return {
186629
186702
  kind: "local",
186630
186703
  localProjectId: project.id,
@@ -186633,8 +186706,8 @@ ${entry2.text}`).join("\n\n");
186633
186706
  } : {}
186634
186707
  };
186635
186708
  }
186636
- function resolveLocalProjectBranchForCreate(project, requestedBranch) {
186637
- const gitState = getLocalProjectGitStateAtRootPath(project.rootPath);
186709
+ async function resolveLocalProjectBranchForCreate(project, requestedBranch) {
186710
+ const gitState = await getLocalProjectGitStateAtRootPath(project.rootPath);
186638
186711
  if (!gitState.git) {
186639
186712
  if (requestedBranch) {
186640
186713
  throw new Error("Cannot use --branch with a local project that is not a git repository.");