@kenkaiiii/gg-boss 4.10.1 → 4.10.2

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.
@@ -3225,8 +3225,8 @@ var require_utils = __commonJS({
3225
3225
  }
3226
3226
  return ind;
3227
3227
  }
3228
- function removeDotSegments(path45) {
3229
- let input = path45;
3228
+ function removeDotSegments(path46) {
3229
+ let input = path46;
3230
3230
  const output = [];
3231
3231
  let nextSlash = -1;
3232
3232
  let len = 0;
@@ -3426,8 +3426,8 @@ var require_schemes = __commonJS({
3426
3426
  wsComponent.secure = void 0;
3427
3427
  }
3428
3428
  if (wsComponent.resourceName) {
3429
- const [path45, query] = wsComponent.resourceName.split("?");
3430
- wsComponent.path = path45 && path45 !== "/" ? path45 : void 0;
3429
+ const [path46, query] = wsComponent.resourceName.split("?");
3430
+ wsComponent.path = path46 && path46 !== "/" ? path46 : void 0;
3431
3431
  wsComponent.query = query;
3432
3432
  wsComponent.resourceName = void 0;
3433
3433
  }
@@ -6835,12 +6835,12 @@ var require_dist = __commonJS({
6835
6835
  throw new Error(`Unknown format "${name}"`);
6836
6836
  return f;
6837
6837
  };
6838
- function addFormats(ajv, list, fs38, exportName) {
6838
+ function addFormats(ajv, list, fs39, exportName) {
6839
6839
  var _a6;
6840
6840
  var _b;
6841
6841
  (_a6 = (_b = ajv.opts.code).formats) !== null && _a6 !== void 0 ? _a6 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
6842
6842
  for (const f of list)
6843
- ajv.addFormat(f, fs38[f]);
6843
+ ajv.addFormat(f, fs39[f]);
6844
6844
  }
6845
6845
  module.exports = exports = formatsPlugin;
6846
6846
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6855,8 +6855,8 @@ var require_windows = __commonJS({
6855
6855
  init_esm_shims();
6856
6856
  module.exports = isexe;
6857
6857
  isexe.sync = sync;
6858
- var fs38 = __require("fs");
6859
- function checkPathExt(path45, options) {
6858
+ var fs39 = __require("fs");
6859
+ function checkPathExt(path46, options) {
6860
6860
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
6861
6861
  if (!pathext) {
6862
6862
  return true;
@@ -6867,25 +6867,25 @@ var require_windows = __commonJS({
6867
6867
  }
6868
6868
  for (var i = 0; i < pathext.length; i++) {
6869
6869
  var p = pathext[i].toLowerCase();
6870
- if (p && path45.substr(-p.length).toLowerCase() === p) {
6870
+ if (p && path46.substr(-p.length).toLowerCase() === p) {
6871
6871
  return true;
6872
6872
  }
6873
6873
  }
6874
6874
  return false;
6875
6875
  }
6876
- function checkStat(stat, path45, options) {
6876
+ function checkStat(stat, path46, options) {
6877
6877
  if (!stat.isSymbolicLink() && !stat.isFile()) {
6878
6878
  return false;
6879
6879
  }
6880
- return checkPathExt(path45, options);
6880
+ return checkPathExt(path46, options);
6881
6881
  }
6882
- function isexe(path45, options, cb) {
6883
- fs38.stat(path45, function(er, stat) {
6884
- cb(er, er ? false : checkStat(stat, path45, options));
6882
+ function isexe(path46, options, cb) {
6883
+ fs39.stat(path46, function(er, stat) {
6884
+ cb(er, er ? false : checkStat(stat, path46, options));
6885
6885
  });
6886
6886
  }
6887
- function sync(path45, options) {
6888
- return checkStat(fs38.statSync(path45), path45, options);
6887
+ function sync(path46, options) {
6888
+ return checkStat(fs39.statSync(path46), path46, options);
6889
6889
  }
6890
6890
  }
6891
6891
  });
@@ -6897,14 +6897,14 @@ var require_mode = __commonJS({
6897
6897
  init_esm_shims();
6898
6898
  module.exports = isexe;
6899
6899
  isexe.sync = sync;
6900
- var fs38 = __require("fs");
6901
- function isexe(path45, options, cb) {
6902
- fs38.stat(path45, function(er, stat) {
6900
+ var fs39 = __require("fs");
6901
+ function isexe(path46, options, cb) {
6902
+ fs39.stat(path46, function(er, stat) {
6903
6903
  cb(er, er ? false : checkStat(stat, options));
6904
6904
  });
6905
6905
  }
6906
- function sync(path45, options) {
6907
- return checkStat(fs38.statSync(path45), options);
6906
+ function sync(path46, options) {
6907
+ return checkStat(fs39.statSync(path46), options);
6908
6908
  }
6909
6909
  function checkStat(stat, options) {
6910
6910
  return stat.isFile() && checkMode(stat, options);
@@ -6930,7 +6930,7 @@ var require_isexe = __commonJS({
6930
6930
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
6931
6931
  "use strict";
6932
6932
  init_esm_shims();
6933
- var fs38 = __require("fs");
6933
+ var fs39 = __require("fs");
6934
6934
  var core;
6935
6935
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
6936
6936
  core = require_windows();
@@ -6939,7 +6939,7 @@ var require_isexe = __commonJS({
6939
6939
  }
6940
6940
  module.exports = isexe;
6941
6941
  isexe.sync = sync;
6942
- function isexe(path45, options, cb) {
6942
+ function isexe(path46, options, cb) {
6943
6943
  if (typeof options === "function") {
6944
6944
  cb = options;
6945
6945
  options = {};
@@ -6949,7 +6949,7 @@ var require_isexe = __commonJS({
6949
6949
  throw new TypeError("callback not provided");
6950
6950
  }
6951
6951
  return new Promise(function(resolve2, reject) {
6952
- isexe(path45, options || {}, function(er, is) {
6952
+ isexe(path46, options || {}, function(er, is) {
6953
6953
  if (er) {
6954
6954
  reject(er);
6955
6955
  } else {
@@ -6958,7 +6958,7 @@ var require_isexe = __commonJS({
6958
6958
  });
6959
6959
  });
6960
6960
  }
6961
- core(path45, options || {}, function(er, is) {
6961
+ core(path46, options || {}, function(er, is) {
6962
6962
  if (er) {
6963
6963
  if (er.code === "EACCES" || options && options.ignoreErrors) {
6964
6964
  er = null;
@@ -6968,9 +6968,9 @@ var require_isexe = __commonJS({
6968
6968
  cb(er, is);
6969
6969
  });
6970
6970
  }
6971
- function sync(path45, options) {
6971
+ function sync(path46, options) {
6972
6972
  try {
6973
- return core.sync(path45, options || {});
6973
+ return core.sync(path46, options || {});
6974
6974
  } catch (er) {
6975
6975
  if (options && options.ignoreErrors || er.code === "EACCES") {
6976
6976
  return false;
@@ -6988,7 +6988,7 @@ var require_which = __commonJS({
6988
6988
  "use strict";
6989
6989
  init_esm_shims();
6990
6990
  var isWindows3 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
6991
- var path45 = __require("path");
6991
+ var path46 = __require("path");
6992
6992
  var COLON = isWindows3 ? ";" : ":";
6993
6993
  var isexe = require_isexe();
6994
6994
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -7026,7 +7026,7 @@ var require_which = __commonJS({
7026
7026
  return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
7027
7027
  const ppRaw = pathEnv[i];
7028
7028
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
7029
- const pCmd = path45.join(pathPart, cmd);
7029
+ const pCmd = path46.join(pathPart, cmd);
7030
7030
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
7031
7031
  resolve2(subStep(p, i, 0));
7032
7032
  });
@@ -7053,7 +7053,7 @@ var require_which = __commonJS({
7053
7053
  for (let i = 0; i < pathEnv.length; i++) {
7054
7054
  const ppRaw = pathEnv[i];
7055
7055
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
7056
- const pCmd = path45.join(pathPart, cmd);
7056
+ const pCmd = path46.join(pathPart, cmd);
7057
7057
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
7058
7058
  for (let j = 0; j < pathExt.length; j++) {
7059
7059
  const cur = p + pathExt[j];
@@ -7103,7 +7103,7 @@ var require_resolveCommand = __commonJS({
7103
7103
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
7104
7104
  "use strict";
7105
7105
  init_esm_shims();
7106
- var path45 = __require("path");
7106
+ var path46 = __require("path");
7107
7107
  var which = require_which();
7108
7108
  var getPathKey = require_path_key();
7109
7109
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -7121,7 +7121,7 @@ var require_resolveCommand = __commonJS({
7121
7121
  try {
7122
7122
  resolved = which.sync(parsed.command, {
7123
7123
  path: env2[getPathKey({ env: env2 })],
7124
- pathExt: withoutPathExt ? path45.delimiter : void 0
7124
+ pathExt: withoutPathExt ? path46.delimiter : void 0
7125
7125
  });
7126
7126
  } catch (e) {
7127
7127
  } finally {
@@ -7130,7 +7130,7 @@ var require_resolveCommand = __commonJS({
7130
7130
  }
7131
7131
  }
7132
7132
  if (resolved) {
7133
- resolved = path45.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
7133
+ resolved = path46.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
7134
7134
  }
7135
7135
  return resolved;
7136
7136
  }
@@ -7187,8 +7187,8 @@ var require_shebang_command = __commonJS({
7187
7187
  if (!match) {
7188
7188
  return null;
7189
7189
  }
7190
- const [path45, argument] = match[0].replace(/#! ?/, "").split(" ");
7191
- const binary = path45.split("/").pop();
7190
+ const [path46, argument] = match[0].replace(/#! ?/, "").split(" ");
7191
+ const binary = path46.split("/").pop();
7192
7192
  if (binary === "env") {
7193
7193
  return argument;
7194
7194
  }
@@ -7202,16 +7202,16 @@ var require_readShebang = __commonJS({
7202
7202
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
7203
7203
  "use strict";
7204
7204
  init_esm_shims();
7205
- var fs38 = __require("fs");
7205
+ var fs39 = __require("fs");
7206
7206
  var shebangCommand = require_shebang_command();
7207
7207
  function readShebang(command) {
7208
7208
  const size = 150;
7209
7209
  const buffer = Buffer.alloc(size);
7210
7210
  let fd2;
7211
7211
  try {
7212
- fd2 = fs38.openSync(command, "r");
7213
- fs38.readSync(fd2, buffer, 0, size, 0);
7214
- fs38.closeSync(fd2);
7212
+ fd2 = fs39.openSync(command, "r");
7213
+ fs39.readSync(fd2, buffer, 0, size, 0);
7214
+ fs39.closeSync(fd2);
7215
7215
  } catch (e) {
7216
7216
  }
7217
7217
  return shebangCommand(buffer.toString());
@@ -7225,7 +7225,7 @@ var require_parse = __commonJS({
7225
7225
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
7226
7226
  "use strict";
7227
7227
  init_esm_shims();
7228
- var path45 = __require("path");
7228
+ var path46 = __require("path");
7229
7229
  var resolveCommand = require_resolveCommand();
7230
7230
  var escape4 = require_escape();
7231
7231
  var readShebang = require_readShebang();
@@ -7250,7 +7250,7 @@ var require_parse = __commonJS({
7250
7250
  const needsShell = !isExecutableRegExp.test(commandFile);
7251
7251
  if (parsed.options.forceShell || needsShell) {
7252
7252
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
7253
- parsed.command = path45.normalize(parsed.command);
7253
+ parsed.command = path46.normalize(parsed.command);
7254
7254
  parsed.command = escape4.command(parsed.command);
7255
7255
  parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
7256
7256
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -17765,10 +17765,10 @@ var require_react_reconciler_development = __commonJS({
17765
17765
  fiber = fiber.next, id2--;
17766
17766
  return fiber;
17767
17767
  }
17768
- function copyWithSetImpl(obj, path45, index, value) {
17769
- if (index >= path45.length) return value;
17770
- var key = path45[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
17771
- updated[key] = copyWithSetImpl(obj[key], path45, index + 1, value);
17768
+ function copyWithSetImpl(obj, path46, index, value) {
17769
+ if (index >= path46.length) return value;
17770
+ var key = path46[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
17771
+ updated[key] = copyWithSetImpl(obj[key], path46, index + 1, value);
17772
17772
  return updated;
17773
17773
  }
17774
17774
  function copyWithRename(obj, oldPath, newPath) {
@@ -17795,11 +17795,11 @@ var require_react_reconciler_development = __commonJS({
17795
17795
  );
17796
17796
  return updated;
17797
17797
  }
17798
- function copyWithDeleteImpl(obj, path45, index) {
17799
- var key = path45[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
17800
- if (index + 1 === path45.length)
17798
+ function copyWithDeleteImpl(obj, path46, index) {
17799
+ var key = path46[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
17800
+ if (index + 1 === path46.length)
17801
17801
  return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
17802
- updated[key] = copyWithDeleteImpl(obj[key], path45, index + 1);
17802
+ updated[key] = copyWithDeleteImpl(obj[key], path46, index + 1);
17803
17803
  return updated;
17804
17804
  }
17805
17805
  function shouldSuspendImpl() {
@@ -31076,29 +31076,29 @@ var require_react_reconciler_development = __commonJS({
31076
31076
  var didWarnAboutNestedUpdates = false;
31077
31077
  var didWarnAboutFindNodeInStrictMode = {};
31078
31078
  var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, scheduleRetry = null, setErrorHandler = null, setSuspenseHandler = null;
31079
- overrideHookState = function(fiber, id2, path45, value) {
31079
+ overrideHookState = function(fiber, id2, path46, value) {
31080
31080
  id2 = findHook(fiber, id2);
31081
- null !== id2 && (path45 = copyWithSetImpl(id2.memoizedState, path45, 0, value), id2.memoizedState = path45, id2.baseState = path45, fiber.memoizedProps = assign({}, fiber.memoizedProps), path45 = enqueueConcurrentRenderForLane(fiber, 2), null !== path45 && scheduleUpdateOnFiber(path45, fiber, 2));
31081
+ null !== id2 && (path46 = copyWithSetImpl(id2.memoizedState, path46, 0, value), id2.memoizedState = path46, id2.baseState = path46, fiber.memoizedProps = assign({}, fiber.memoizedProps), path46 = enqueueConcurrentRenderForLane(fiber, 2), null !== path46 && scheduleUpdateOnFiber(path46, fiber, 2));
31082
31082
  };
31083
- overrideHookStateDeletePath = function(fiber, id2, path45) {
31083
+ overrideHookStateDeletePath = function(fiber, id2, path46) {
31084
31084
  id2 = findHook(fiber, id2);
31085
- null !== id2 && (path45 = copyWithDeleteImpl(id2.memoizedState, path45, 0), id2.memoizedState = path45, id2.baseState = path45, fiber.memoizedProps = assign({}, fiber.memoizedProps), path45 = enqueueConcurrentRenderForLane(fiber, 2), null !== path45 && scheduleUpdateOnFiber(path45, fiber, 2));
31085
+ null !== id2 && (path46 = copyWithDeleteImpl(id2.memoizedState, path46, 0), id2.memoizedState = path46, id2.baseState = path46, fiber.memoizedProps = assign({}, fiber.memoizedProps), path46 = enqueueConcurrentRenderForLane(fiber, 2), null !== path46 && scheduleUpdateOnFiber(path46, fiber, 2));
31086
31086
  };
31087
31087
  overrideHookStateRenamePath = function(fiber, id2, oldPath, newPath) {
31088
31088
  id2 = findHook(fiber, id2);
31089
31089
  null !== id2 && (oldPath = copyWithRename(id2.memoizedState, oldPath, newPath), id2.memoizedState = oldPath, id2.baseState = oldPath, fiber.memoizedProps = assign({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), null !== oldPath && scheduleUpdateOnFiber(oldPath, fiber, 2));
31090
31090
  };
31091
- overrideProps = function(fiber, path45, value) {
31092
- fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path45, 0, value);
31091
+ overrideProps = function(fiber, path46, value) {
31092
+ fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path46, 0, value);
31093
31093
  fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
31094
- path45 = enqueueConcurrentRenderForLane(fiber, 2);
31095
- null !== path45 && scheduleUpdateOnFiber(path45, fiber, 2);
31094
+ path46 = enqueueConcurrentRenderForLane(fiber, 2);
31095
+ null !== path46 && scheduleUpdateOnFiber(path46, fiber, 2);
31096
31096
  };
31097
- overridePropsDeletePath = function(fiber, path45) {
31098
- fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path45, 0);
31097
+ overridePropsDeletePath = function(fiber, path46) {
31098
+ fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path46, 0);
31099
31099
  fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
31100
- path45 = enqueueConcurrentRenderForLane(fiber, 2);
31101
- null !== path45 && scheduleUpdateOnFiber(path45, fiber, 2);
31100
+ path46 = enqueueConcurrentRenderForLane(fiber, 2);
31101
+ null !== path46 && scheduleUpdateOnFiber(path46, fiber, 2);
31102
31102
  };
31103
31103
  overridePropsRenamePath = function(fiber, oldPath, newPath) {
31104
31104
  fiber.pendingProps = copyWithRename(
@@ -34333,15 +34333,15 @@ function redactSensitive(body) {
34333
34333
  }
34334
34334
  return null;
34335
34335
  }
34336
- async function checkCredentialsFileSafety(path45, onWarn = (m) => console.warn(`anthropic-sdk: ${m}`)) {
34336
+ async function checkCredentialsFileSafety(path46, onWarn = (m) => console.warn(`anthropic-sdk: ${m}`)) {
34337
34337
  if (typeof process === "undefined" || process.platform === "win32")
34338
34338
  return;
34339
- const fs38 = await import("fs");
34340
- let resolved = path45;
34339
+ const fs39 = await import("fs");
34340
+ let resolved = path46;
34341
34341
  let st;
34342
34342
  try {
34343
- resolved = await fs38.promises.realpath(path45);
34344
- st = await fs38.promises.stat(resolved);
34343
+ resolved = await fs39.promises.realpath(path46);
34344
+ st = await fs39.promises.stat(resolved);
34345
34345
  } catch {
34346
34346
  return;
34347
34347
  }
@@ -34357,27 +34357,27 @@ async function checkCredentialsFileSafety(path45, onWarn = (m) => console.warn(`
34357
34357
  }
34358
34358
  }
34359
34359
  async function writeCredentialsFileAtomic(targetPath, data) {
34360
- const fs38 = await import("fs");
34361
- const path45 = await import("path");
34362
- const dir = path45.dirname(targetPath);
34363
- await fs38.promises.mkdir(dir, { recursive: true, mode: 448 });
34360
+ const fs39 = await import("fs");
34361
+ const path46 = await import("path");
34362
+ const dir = path46.dirname(targetPath);
34363
+ await fs39.promises.mkdir(dir, { recursive: true, mode: 448 });
34364
34364
  const tmpPath = `${targetPath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
34365
34365
  try {
34366
- const fh = await fs38.promises.open(tmpPath, "w", 384);
34366
+ const fh = await fs39.promises.open(tmpPath, "w", 384);
34367
34367
  try {
34368
34368
  await fh.writeFile(JSON.stringify(data, null, 2));
34369
34369
  await fh.sync();
34370
34370
  } finally {
34371
34371
  await fh.close();
34372
34372
  }
34373
- await fs38.promises.rename(tmpPath, targetPath);
34373
+ await fs39.promises.rename(tmpPath, targetPath);
34374
34374
  } catch (err) {
34375
- await fs38.promises.unlink(tmpPath).catch(() => {
34375
+ await fs39.promises.unlink(tmpPath).catch(() => {
34376
34376
  });
34377
34377
  throw err;
34378
34378
  }
34379
34379
  try {
34380
- const dirFh = await fs38.promises.open(dir, "r");
34380
+ const dirFh = await fs39.promises.open(dir, "r");
34381
34381
  try {
34382
34382
  await dirFh.sync();
34383
34383
  } finally {
@@ -34679,12 +34679,12 @@ var loadConfigWithSource = async (profile) => {
34679
34679
  return null;
34680
34680
  }
34681
34681
  validateProfileName(profileName);
34682
- const fs38 = await import("fs");
34683
- const path45 = await import("path");
34684
- const configPath = path45.join(rootConfigPath, "configs", `${profileName}.json`);
34682
+ const fs39 = await import("fs");
34683
+ const path46 = await import("path");
34684
+ const configPath = path46.join(rootConfigPath, "configs", `${profileName}.json`);
34685
34685
  let configRaw;
34686
34686
  try {
34687
- configRaw = await fs38.promises.readFile(configPath, "utf-8");
34687
+ configRaw = await fs39.promises.readFile(configPath, "utf-8");
34688
34688
  } catch (err) {
34689
34689
  if (err?.code !== "ENOENT") {
34690
34690
  throw new Error(`failed to read config file ${configPath}: ${err}`);
@@ -34765,37 +34765,37 @@ var getCredentialsPath = async (config2, profile) => {
34765
34765
  return null;
34766
34766
  }
34767
34767
  validateProfileName(profileName);
34768
- const path45 = await import("path");
34769
- return path45.join(rootConfigPath, "credentials", `${profileName}.json`);
34768
+ const path46 = await import("path");
34769
+ return path46.join(rootConfigPath, "credentials", `${profileName}.json`);
34770
34770
  };
34771
34771
  var getRootConfigPath = async () => {
34772
34772
  if (!supportsLocalConfigFiles()) {
34773
34773
  return null;
34774
34774
  }
34775
- const path45 = await import("path");
34775
+ const path46 = await import("path");
34776
34776
  const configDir = readEnv("ANTHROPIC_CONFIG_DIR");
34777
34777
  if (configDir) {
34778
34778
  return configDir;
34779
34779
  }
34780
- const os12 = getPlatformHeaders()["X-Stainless-OS"];
34781
- if (os12 === "Windows") {
34780
+ const os13 = getPlatformHeaders()["X-Stainless-OS"];
34781
+ if (os13 === "Windows") {
34782
34782
  const appData = readEnv("APPDATA");
34783
34783
  if (appData) {
34784
- return path45.join(appData, "Anthropic");
34784
+ return path46.join(appData, "Anthropic");
34785
34785
  }
34786
34786
  const userProfile = readEnv("USERPROFILE");
34787
34787
  if (userProfile) {
34788
- return path45.join(userProfile, "AppData", "Roaming", "Anthropic");
34788
+ return path46.join(userProfile, "AppData", "Roaming", "Anthropic");
34789
34789
  }
34790
34790
  return null;
34791
34791
  }
34792
34792
  const xdgConfigHome = readEnv("XDG_CONFIG_HOME");
34793
34793
  if (xdgConfigHome) {
34794
- return path45.join(xdgConfigHome, "anthropic");
34794
+ return path46.join(xdgConfigHome, "anthropic");
34795
34795
  }
34796
34796
  const home = readEnv("HOME");
34797
34797
  if (home) {
34798
- return path45.join(home, ".config", "anthropic");
34798
+ return path46.join(home, ".config", "anthropic");
34799
34799
  }
34800
34800
  return null;
34801
34801
  };
@@ -34812,11 +34812,11 @@ var getActiveProfileName = async () => {
34812
34812
  if (profileName) {
34813
34813
  return profileName;
34814
34814
  }
34815
- const fs38 = await import("fs");
34816
- const path45 = await import("path");
34817
- const filePath = path45.join(rootConfigPath, "active_config");
34815
+ const fs39 = await import("fs");
34816
+ const path46 = await import("path");
34817
+ const filePath = path46.join(rootConfigPath, "active_config");
34818
34818
  try {
34819
- return (await fs38.promises.readFile(filePath, "utf-8")).trim() || "default";
34819
+ return (await fs39.promises.readFile(filePath, "utf-8")).trim() || "default";
34820
34820
  } catch (err) {
34821
34821
  if (err?.code !== "ENOENT") {
34822
34822
  throw new Error(`failed to read ${filePath}: ${err}`);
@@ -34827,21 +34827,21 @@ var getActiveProfileName = async () => {
34827
34827
 
34828
34828
  // ../../node_modules/.pnpm/@anthropic-ai+sdk@0.94.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs
34829
34829
  init_esm_shims();
34830
- function identityTokenFromFile(path45) {
34831
- if (!path45) {
34830
+ function identityTokenFromFile(path46) {
34831
+ if (!path46) {
34832
34832
  throw new AnthropicError("Identity token file path is empty");
34833
34833
  }
34834
34834
  return async () => {
34835
- const fs38 = await import("fs");
34835
+ const fs39 = await import("fs");
34836
34836
  let content;
34837
34837
  try {
34838
- content = await fs38.promises.readFile(path45, "utf-8");
34838
+ content = await fs39.promises.readFile(path46, "utf-8");
34839
34839
  } catch (err) {
34840
- throw new AnthropicError(`Failed to read identity token file at ${path45}: ${err}`);
34840
+ throw new AnthropicError(`Failed to read identity token file at ${path46}: ${err}`);
34841
34841
  }
34842
34842
  const token = content.trim();
34843
34843
  if (!token) {
34844
- throw new AnthropicError(`Identity token file at ${path45} is empty`);
34844
+ throw new AnthropicError(`Identity token file at ${path46} is empty`);
34845
34845
  }
34846
34846
  return token;
34847
34847
  };
@@ -34916,11 +34916,11 @@ function oidcFederationProvider(config2) {
34916
34916
  init_esm_shims();
34917
34917
  function userOAuthProvider(config2) {
34918
34918
  return async (opts) => {
34919
- const fs38 = await import("fs");
34919
+ const fs39 = await import("fs");
34920
34920
  await checkCredentialsFileSafety(config2.credentialsPath, config2.onSafetyWarning);
34921
34921
  let raw;
34922
34922
  try {
34923
- raw = await fs38.promises.readFile(config2.credentialsPath, "utf-8");
34923
+ raw = await fs39.promises.readFile(config2.credentialsPath, "utf-8");
34924
34924
  } catch (err) {
34925
34925
  throw new WorkloadIdentityError(`Credentials file not found at ${config2.credentialsPath}: ${err}`);
34926
34926
  }
@@ -35084,11 +35084,11 @@ function resolveIdentityTokenProvider(auth2) {
35084
35084
  }
35085
35085
  function cachedExchangeProvider(exchange, credentialsPath, onCacheWriteError, onSafetyWarning) {
35086
35086
  return async (opts) => {
35087
- const fs38 = await import("fs");
35087
+ const fs39 = await import("fs");
35088
35088
  await checkCredentialsFileSafety(credentialsPath, onSafetyWarning);
35089
35089
  let existing;
35090
35090
  try {
35091
- const raw = await fs38.promises.readFile(credentialsPath, "utf-8");
35091
+ const raw = await fs39.promises.readFile(credentialsPath, "utf-8");
35092
35092
  existing = JSON.parse(raw);
35093
35093
  const token = existing?.["access_token"];
35094
35094
  if (token && !opts?.forceRefresh) {
@@ -35927,12 +35927,12 @@ function encodeURIPath(str2) {
35927
35927
  return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
35928
35928
  }
35929
35929
  var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
35930
- var createPathTagFunction = (pathEncoder = encodeURIPath) => function path45(statics, ...params) {
35930
+ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path46(statics, ...params) {
35931
35931
  if (statics.length === 1)
35932
35932
  return statics[0];
35933
35933
  let postPath = false;
35934
35934
  const invalidSegments = [];
35935
- const path46 = statics.reduce((previousValue, currentValue, index) => {
35935
+ const path47 = statics.reduce((previousValue, currentValue, index) => {
35936
35936
  if (/[?#]/.test(currentValue)) {
35937
35937
  postPath = true;
35938
35938
  }
@@ -35949,7 +35949,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path45(sta
35949
35949
  }
35950
35950
  return previousValue + currentValue + (index === params.length ? "" : encoded);
35951
35951
  }, "");
35952
- const pathOnly = path46.split(/[?#]/, 1)[0];
35952
+ const pathOnly = path47.split(/[?#]/, 1)[0];
35953
35953
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
35954
35954
  let match;
35955
35955
  while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
@@ -35970,10 +35970,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path45(sta
35970
35970
  }, "");
35971
35971
  throw new AnthropicError(`Path parameters result in path with invalid segments:
35972
35972
  ${invalidSegments.map((e) => e.error).join("\n")}
35973
- ${path46}
35973
+ ${path47}
35974
35974
  ${underline}`);
35975
35975
  }
35976
- return path46;
35976
+ return path47;
35977
35977
  };
35978
35978
  var path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
35979
35979
 
@@ -40734,9 +40734,9 @@ var BaseAnthropic = class {
40734
40734
  makeStatusError(status, error51, message, headers) {
40735
40735
  return APIError.generate(status, error51, message, headers);
40736
40736
  }
40737
- buildURL(path45, query, defaultBaseURL) {
40737
+ buildURL(path46, query, defaultBaseURL) {
40738
40738
  const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
40739
- const url2 = isAbsoluteURL(path45) ? new URL(path45) : new URL(baseURL + (baseURL.endsWith("/") && path45.startsWith("/") ? path45.slice(1) : path45));
40739
+ const url2 = isAbsoluteURL(path46) ? new URL(path46) : new URL(baseURL + (baseURL.endsWith("/") && path46.startsWith("/") ? path46.slice(1) : path46));
40740
40740
  const defaultQuery = this.defaultQuery();
40741
40741
  const pathQuery = Object.fromEntries(url2.searchParams);
40742
40742
  if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
@@ -40780,24 +40780,24 @@ var BaseAnthropic = class {
40780
40780
  request.headers = headers;
40781
40781
  }
40782
40782
  }
40783
- get(path45, opts) {
40784
- return this.methodRequest("get", path45, opts);
40783
+ get(path46, opts) {
40784
+ return this.methodRequest("get", path46, opts);
40785
40785
  }
40786
- post(path45, opts) {
40787
- return this.methodRequest("post", path45, opts);
40786
+ post(path46, opts) {
40787
+ return this.methodRequest("post", path46, opts);
40788
40788
  }
40789
- patch(path45, opts) {
40790
- return this.methodRequest("patch", path45, opts);
40789
+ patch(path46, opts) {
40790
+ return this.methodRequest("patch", path46, opts);
40791
40791
  }
40792
- put(path45, opts) {
40793
- return this.methodRequest("put", path45, opts);
40792
+ put(path46, opts) {
40793
+ return this.methodRequest("put", path46, opts);
40794
40794
  }
40795
- delete(path45, opts) {
40796
- return this.methodRequest("delete", path45, opts);
40795
+ delete(path46, opts) {
40796
+ return this.methodRequest("delete", path46, opts);
40797
40797
  }
40798
- methodRequest(method, path45, opts) {
40798
+ methodRequest(method, path46, opts) {
40799
40799
  return this.request(Promise.resolve(opts).then((opts2) => {
40800
- return { method, path: path45, ...opts2 };
40800
+ return { method, path: path46, ...opts2 };
40801
40801
  }));
40802
40802
  }
40803
40803
  request(options, remainingRetries = null) {
@@ -40902,8 +40902,8 @@ var BaseAnthropic = class {
40902
40902
  }));
40903
40903
  return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
40904
40904
  }
40905
- getAPIList(path45, Page3, opts) {
40906
- return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path45, ...opts2 })) : { method: "get", path: path45, ...opts });
40905
+ getAPIList(path46, Page3, opts) {
40906
+ return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path46, ...opts2 })) : { method: "get", path: path46, ...opts });
40907
40907
  }
40908
40908
  requestAPIList(Page3, options) {
40909
40909
  const request = this.makeRequest(options, null, void 0);
@@ -40997,14 +40997,14 @@ var BaseAnthropic = class {
40997
40997
  }
40998
40998
  async buildRequest(inputOptions, { retryCount = 0 } = {}) {
40999
40999
  const options = { ...inputOptions };
41000
- const { method, path: path45, query, defaultBaseURL } = options;
41000
+ const { method, path: path46, query, defaultBaseURL } = options;
41001
41001
  if (this._authState.resolution) {
41002
41002
  await this._authState.resolution;
41003
41003
  }
41004
41004
  if (!this._baseURLIsExplicit && this._authState.baseURL && this.baseURL !== this._authState.baseURL) {
41005
41005
  this.baseURL = this._authState.baseURL;
41006
41006
  }
41007
- const url2 = this.buildURL(path45, query, defaultBaseURL);
41007
+ const url2 = this.buildURL(path46, query, defaultBaseURL);
41008
41008
  if ("timeout" in options)
41009
41009
  validatePositiveInteger("timeout", options.timeout);
41010
41010
  options.timeout = options.timeout ?? this.timeout;
@@ -41891,10 +41891,10 @@ function mergeDefs(...defs) {
41891
41891
  function cloneDef(schema) {
41892
41892
  return mergeDefs(schema._zod.def);
41893
41893
  }
41894
- function getElementAtPath(obj, path45) {
41895
- if (!path45)
41894
+ function getElementAtPath(obj, path46) {
41895
+ if (!path46)
41896
41896
  return obj;
41897
- return path45.reduce((acc, key) => acc?.[key], obj);
41897
+ return path46.reduce((acc, key) => acc?.[key], obj);
41898
41898
  }
41899
41899
  function promiseAllObject(promisesObj) {
41900
41900
  const keys = Object.keys(promisesObj);
@@ -42303,11 +42303,11 @@ function explicitlyAborted(x, startIndex = 0) {
42303
42303
  }
42304
42304
  return false;
42305
42305
  }
42306
- function prefixIssues(path45, issues) {
42306
+ function prefixIssues(path46, issues) {
42307
42307
  return issues.map((iss) => {
42308
42308
  var _a6;
42309
42309
  (_a6 = iss).path ?? (_a6.path = []);
42310
- iss.path.unshift(path45);
42310
+ iss.path.unshift(path46);
42311
42311
  return iss;
42312
42312
  });
42313
42313
  }
@@ -42454,16 +42454,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
42454
42454
  }
42455
42455
  function formatError(error51, mapper = (issue2) => issue2.message) {
42456
42456
  const fieldErrors = { _errors: [] };
42457
- const processError = (error52, path45 = []) => {
42457
+ const processError = (error52, path46 = []) => {
42458
42458
  for (const issue2 of error52.issues) {
42459
42459
  if (issue2.code === "invalid_union" && issue2.errors.length) {
42460
- issue2.errors.map((issues) => processError({ issues }, [...path45, ...issue2.path]));
42460
+ issue2.errors.map((issues) => processError({ issues }, [...path46, ...issue2.path]));
42461
42461
  } else if (issue2.code === "invalid_key") {
42462
- processError({ issues: issue2.issues }, [...path45, ...issue2.path]);
42462
+ processError({ issues: issue2.issues }, [...path46, ...issue2.path]);
42463
42463
  } else if (issue2.code === "invalid_element") {
42464
- processError({ issues: issue2.issues }, [...path45, ...issue2.path]);
42464
+ processError({ issues: issue2.issues }, [...path46, ...issue2.path]);
42465
42465
  } else {
42466
- const fullpath = [...path45, ...issue2.path];
42466
+ const fullpath = [...path46, ...issue2.path];
42467
42467
  if (fullpath.length === 0) {
42468
42468
  fieldErrors._errors.push(mapper(issue2));
42469
42469
  } else {
@@ -42490,17 +42490,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
42490
42490
  }
42491
42491
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
42492
42492
  const result = { errors: [] };
42493
- const processError = (error52, path45 = []) => {
42493
+ const processError = (error52, path46 = []) => {
42494
42494
  var _a6, _b;
42495
42495
  for (const issue2 of error52.issues) {
42496
42496
  if (issue2.code === "invalid_union" && issue2.errors.length) {
42497
- issue2.errors.map((issues) => processError({ issues }, [...path45, ...issue2.path]));
42497
+ issue2.errors.map((issues) => processError({ issues }, [...path46, ...issue2.path]));
42498
42498
  } else if (issue2.code === "invalid_key") {
42499
- processError({ issues: issue2.issues }, [...path45, ...issue2.path]);
42499
+ processError({ issues: issue2.issues }, [...path46, ...issue2.path]);
42500
42500
  } else if (issue2.code === "invalid_element") {
42501
- processError({ issues: issue2.issues }, [...path45, ...issue2.path]);
42501
+ processError({ issues: issue2.issues }, [...path46, ...issue2.path]);
42502
42502
  } else {
42503
- const fullpath = [...path45, ...issue2.path];
42503
+ const fullpath = [...path46, ...issue2.path];
42504
42504
  if (fullpath.length === 0) {
42505
42505
  result.errors.push(mapper(issue2));
42506
42506
  continue;
@@ -42532,8 +42532,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
42532
42532
  }
42533
42533
  function toDotPath(_path) {
42534
42534
  const segs = [];
42535
- const path45 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
42536
- for (const seg of path45) {
42535
+ const path46 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
42536
+ for (const seg of path46) {
42537
42537
  if (typeof seg === "number")
42538
42538
  segs.push(`[${seg}]`);
42539
42539
  else if (typeof seg === "symbol")
@@ -55306,13 +55306,13 @@ function resolveRef(ref, ctx) {
55306
55306
  if (!ref.startsWith("#")) {
55307
55307
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
55308
55308
  }
55309
- const path45 = ref.slice(1).split("/").filter(Boolean);
55310
- if (path45.length === 0) {
55309
+ const path46 = ref.slice(1).split("/").filter(Boolean);
55310
+ if (path46.length === 0) {
55311
55311
  return ctx.rootSchema;
55312
55312
  }
55313
55313
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
55314
- if (path45[0] === defsKey) {
55315
- const key = path45[1];
55314
+ if (path46[0] === defsKey) {
55315
+ const key = path46[1];
55316
55316
  if (!key || !ctx.defs[key]) {
55317
55317
  throw new Error(`Reference not found: ${ref}`);
55318
55318
  }
@@ -57541,12 +57541,12 @@ function encodeURIPath2(str2) {
57541
57541
  return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
57542
57542
  }
57543
57543
  var EMPTY2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
57544
- var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path45(statics, ...params) {
57544
+ var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path46(statics, ...params) {
57545
57545
  if (statics.length === 1)
57546
57546
  return statics[0];
57547
57547
  let postPath = false;
57548
57548
  const invalidSegments = [];
57549
- const path46 = statics.reduce((previousValue, currentValue, index) => {
57549
+ const path47 = statics.reduce((previousValue, currentValue, index) => {
57550
57550
  if (/[?#]/.test(currentValue)) {
57551
57551
  postPath = true;
57552
57552
  }
@@ -57563,7 +57563,7 @@ var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path45(s
57563
57563
  }
57564
57564
  return previousValue + currentValue + (index === params.length ? "" : encoded);
57565
57565
  }, "");
57566
- const pathOnly = path46.split(/[?#]/, 1)[0];
57566
+ const pathOnly = path47.split(/[?#]/, 1)[0];
57567
57567
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
57568
57568
  let match;
57569
57569
  while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
@@ -57584,10 +57584,10 @@ var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path45(s
57584
57584
  }, "");
57585
57585
  throw new OpenAIError(`Path parameters result in path with invalid segments:
57586
57586
  ${invalidSegments.map((e) => e.error).join("\n")}
57587
- ${path46}
57587
+ ${path47}
57588
57588
  ${underline}`);
57589
57589
  }
57590
- return path46;
57590
+ return path47;
57591
57591
  };
57592
57592
  var path2 = /* @__PURE__ */ createPathTagFunction2(encodeURIPath2);
57593
57593
 
@@ -62713,9 +62713,9 @@ var OpenAI = class {
62713
62713
  this.apiKey = token;
62714
62714
  return true;
62715
62715
  }
62716
- buildURL(path45, query, defaultBaseURL) {
62716
+ buildURL(path46, query, defaultBaseURL) {
62717
62717
  const baseURL = !__classPrivateFieldGet2(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
62718
- const url2 = isAbsoluteURL2(path45) ? new URL(path45) : new URL(baseURL + (baseURL.endsWith("/") && path45.startsWith("/") ? path45.slice(1) : path45));
62718
+ const url2 = isAbsoluteURL2(path46) ? new URL(path46) : new URL(baseURL + (baseURL.endsWith("/") && path46.startsWith("/") ? path46.slice(1) : path46));
62719
62719
  const defaultQuery = this.defaultQuery();
62720
62720
  const pathQuery = Object.fromEntries(url2.searchParams);
62721
62721
  if (!isEmptyObj2(defaultQuery) || !isEmptyObj2(pathQuery)) {
@@ -62740,24 +62740,24 @@ var OpenAI = class {
62740
62740
  */
62741
62741
  async prepareRequest(request, { url: url2, options }) {
62742
62742
  }
62743
- get(path45, opts) {
62744
- return this.methodRequest("get", path45, opts);
62743
+ get(path46, opts) {
62744
+ return this.methodRequest("get", path46, opts);
62745
62745
  }
62746
- post(path45, opts) {
62747
- return this.methodRequest("post", path45, opts);
62746
+ post(path46, opts) {
62747
+ return this.methodRequest("post", path46, opts);
62748
62748
  }
62749
- patch(path45, opts) {
62750
- return this.methodRequest("patch", path45, opts);
62749
+ patch(path46, opts) {
62750
+ return this.methodRequest("patch", path46, opts);
62751
62751
  }
62752
- put(path45, opts) {
62753
- return this.methodRequest("put", path45, opts);
62752
+ put(path46, opts) {
62753
+ return this.methodRequest("put", path46, opts);
62754
62754
  }
62755
- delete(path45, opts) {
62756
- return this.methodRequest("delete", path45, opts);
62755
+ delete(path46, opts) {
62756
+ return this.methodRequest("delete", path46, opts);
62757
62757
  }
62758
- methodRequest(method, path45, opts) {
62758
+ methodRequest(method, path46, opts) {
62759
62759
  return this.request(Promise.resolve(opts).then((opts2) => {
62760
- return { method, path: path45, ...opts2 };
62760
+ return { method, path: path46, ...opts2 };
62761
62761
  }));
62762
62762
  }
62763
62763
  request(options, remainingRetries = null) {
@@ -62875,8 +62875,8 @@ var OpenAI = class {
62875
62875
  }));
62876
62876
  return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
62877
62877
  }
62878
- getAPIList(path45, Page3, opts) {
62879
- return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path45, ...opts2 })) : { method: "get", path: path45, ...opts });
62878
+ getAPIList(path46, Page3, opts) {
62879
+ return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path46, ...opts2 })) : { method: "get", path: path46, ...opts });
62880
62880
  }
62881
62881
  requestAPIList(Page3, options) {
62882
62882
  const request = this.makeRequest(options, null, void 0);
@@ -62967,8 +62967,8 @@ var OpenAI = class {
62967
62967
  }
62968
62968
  async buildRequest(inputOptions, { retryCount = 0 } = {}) {
62969
62969
  const options = { ...inputOptions };
62970
- const { method, path: path45, query, defaultBaseURL } = options;
62971
- const url2 = this.buildURL(path45, query, defaultBaseURL);
62970
+ const { method, path: path46, query, defaultBaseURL } = options;
62971
+ const url2 = this.buildURL(path46, query, defaultBaseURL);
62972
62972
  if ("timeout" in options)
62973
62973
  validatePositiveInteger2("timeout", options.timeout);
62974
62974
  options.timeout = options.timeout ?? this.timeout;
@@ -64703,11 +64703,11 @@ async function* runStream2(options) {
64703
64703
  }
64704
64704
  }
64705
64705
  if (getEnvironment()?.GGAI_DUMP_REQUEST) {
64706
- const fs38 = await import("fs");
64706
+ const fs39 = await import("fs");
64707
64707
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
64708
64708
  const dumpPath = `/tmp/ggai-request-${ts}.json`;
64709
- fs38.writeFileSync(dumpPath, JSON.stringify(params, null, 2));
64710
- fs38.appendFileSync(
64709
+ fs39.writeFileSync(dumpPath, JSON.stringify(params, null, 2));
64710
+ fs39.appendFileSync(
64711
64711
  "/tmp/ggai-requests.log",
64712
64712
  `[${ts}] ${dumpPath} messages=${params.messages.length}
64713
64713
  `
@@ -67448,37 +67448,41 @@ var Agent = class {
67448
67448
  }
67449
67449
  };
67450
67450
 
67451
- // ../gg-core/dist/chunk-RBR3MTVM.js
67451
+ // ../gg-core/dist/chunk-6O2YPYRP.js
67452
67452
  init_esm_shims();
67453
67453
  var MODELS = [
67454
67454
  // ── Anthropic ──────────────────────────────────────────
67455
- {
67456
- id: "claude-fable-5",
67457
- name: "Claude Fable 5",
67458
- provider: "anthropic",
67459
- contextWindow: 1e6,
67460
- maxOutputTokens: 128e3,
67461
- supportsThinking: true,
67462
- supportsImages: true,
67463
- supportsVideo: false,
67464
- costTier: "high",
67465
- maxThinkingLevel: "max"
67466
- },
67467
- {
67468
- // Mythos-class model offered through Project Glasswing (limited
67469
- // availability, invitation-only). Same underlying model as Fable 5 with
67470
- // some safeguards lifted; kept here so approved accounts can select it.
67471
- id: "claude-mythos-5",
67472
- name: "Claude Mythos 5",
67473
- provider: "anthropic",
67474
- contextWindow: 1e6,
67475
- maxOutputTokens: 128e3,
67476
- supportsThinking: true,
67477
- supportsImages: true,
67478
- supportsVideo: false,
67479
- costTier: "high",
67480
- maxThinkingLevel: "max"
67481
- },
67455
+ // NOTE: Claude Fable 5 (`claude-fable-5`) and Claude Mythos 5
67456
+ // (`claude-mythos-5`) are temporarily unavailable, so they're commented out
67457
+ // here to keep them out of the /model selector and avoid user confusion.
67458
+ // Re-enable once they're generally available again.
67459
+ // {
67460
+ // id: "claude-fable-5",
67461
+ // name: "Claude Fable 5",
67462
+ // provider: "anthropic",
67463
+ // contextWindow: 1_000_000,
67464
+ // maxOutputTokens: 128_000,
67465
+ // supportsThinking: true,
67466
+ // supportsImages: true,
67467
+ // supportsVideo: false,
67468
+ // costTier: "high",
67469
+ // maxThinkingLevel: "max",
67470
+ // },
67471
+ // {
67472
+ // // Mythos-class model offered through Project Glasswing (limited
67473
+ // // availability, invitation-only). Same underlying model as Fable 5 with
67474
+ // // some safeguards lifted; kept here so approved accounts can select it.
67475
+ // id: "claude-mythos-5",
67476
+ // name: "Claude Mythos 5",
67477
+ // provider: "anthropic",
67478
+ // contextWindow: 1_000_000,
67479
+ // maxOutputTokens: 128_000,
67480
+ // supportsThinking: true,
67481
+ // supportsImages: true,
67482
+ // supportsVideo: false,
67483
+ // costTier: "high",
67484
+ // maxThinkingLevel: "max",
67485
+ // },
67482
67486
  {
67483
67487
  id: "claude-opus-4-8",
67484
67488
  name: "Claude Opus 4.8",
@@ -68246,12 +68250,12 @@ function macOsProductVersion() {
68246
68250
  }
68247
68251
  }
68248
68252
  function deviceModel() {
68249
- const os12 = type();
68253
+ const os13 = type();
68250
68254
  const version2 = release();
68251
68255
  const osArch = arch();
68252
- if (os12 === "Darwin") return `macOS ${macOsProductVersion() ?? version2} ${osArch}`;
68253
- if (os12 === "Windows_NT") return `Windows ${version2} ${osArch}`;
68254
- return `${os12} ${version2} ${osArch}`.trim();
68256
+ if (os13 === "Darwin") return `macOS ${macOsProductVersion() ?? version2} ${osArch}`;
68257
+ if (os13 === "Windows_NT") return `Windows ${version2} ${osArch}`;
68258
+ return `${os13} ${version2} ${osArch}`.trim();
68255
68259
  }
68256
68260
  function deviceId() {
68257
68261
  const idPath = path32.join(getAppPaths().agentDir, "kimi_device_id");
@@ -70084,18 +70088,18 @@ import fs10 from "fs/promises";
70084
70088
  import { spawn as spawn4 } from "child_process";
70085
70089
  import { createReadStream } from "fs";
70086
70090
  var localOperations = {
70087
- readFile: (path45) => fs10.readFile(path45, "utf-8"),
70088
- writeFile: async (path45, content) => {
70091
+ readFile: (path46) => fs10.readFile(path46, "utf-8"),
70092
+ writeFile: async (path46, content) => {
70089
70093
  const { dirname: dirname3 } = await import("path");
70090
- await fs10.mkdir(dirname3(path45), { recursive: true });
70091
- await fs10.writeFile(path45, content, "utf-8");
70094
+ await fs10.mkdir(dirname3(path46), { recursive: true });
70095
+ await fs10.writeFile(path46, content, "utf-8");
70092
70096
  },
70093
- stat: (path45) => fs10.stat(path45),
70094
- lstat: (path45) => fs10.lstat(path45),
70095
- readdir: (path45, options) => fs10.readdir(path45, options),
70096
- mkdir: (path45) => fs10.mkdir(path45, { recursive: true }).then(() => {
70097
+ stat: (path46) => fs10.stat(path46),
70098
+ lstat: (path46) => fs10.lstat(path46),
70099
+ readdir: (path46, options) => fs10.readdir(path46, options),
70100
+ mkdir: (path46) => fs10.mkdir(path46, { recursive: true }).then(() => {
70097
70101
  }),
70098
- createReadStream: (path45, encoding) => createReadStream(path45, { encoding }),
70102
+ createReadStream: (path46, encoding) => createReadStream(path46, { encoding }),
70099
70103
  spawn: (command, args, options) => spawn4(command, args, {
70100
70104
  cwd: options.cwd,
70101
70105
  env: options.env,
@@ -70857,16 +70861,16 @@ var Diff = class {
70857
70861
  }
70858
70862
  }
70859
70863
  }
70860
- addToPath(path45, added, removed, oldPosInc, options) {
70861
- const last = path45.lastComponent;
70864
+ addToPath(path46, added, removed, oldPosInc, options) {
70865
+ const last = path46.lastComponent;
70862
70866
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
70863
70867
  return {
70864
- oldPos: path45.oldPos + oldPosInc,
70868
+ oldPos: path46.oldPos + oldPosInc,
70865
70869
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
70866
70870
  };
70867
70871
  } else {
70868
70872
  return {
70869
- oldPos: path45.oldPos + oldPosInc,
70873
+ oldPos: path46.oldPos + oldPosInc,
70870
70874
  lastComponent: { count: 1, added, removed, previousComponent: last }
70871
70875
  };
70872
70876
  }
@@ -75191,7 +75195,8 @@ var EventBus = class {
75191
75195
  toolCallId: event.toolCallId,
75192
75196
  result: event.result,
75193
75197
  isError: event.isError,
75194
- durationMs: event.durationMs
75198
+ durationMs: event.durationMs,
75199
+ details: event.details
75195
75200
  });
75196
75201
  break;
75197
75202
  case "turn_end":
@@ -83450,6 +83455,193 @@ var BUNDLED_AGENTS = [
83450
83455
  }
83451
83456
  ];
83452
83457
 
83458
+ // ../ggcoder/dist/utils/session-title.js
83459
+ init_esm_shims();
83460
+ var TITLE_PROMPT = `Generate an extremely short title (3-7 words) summarizing what the user is asking for. Just the title, nothing else. No quotes, no punctuation at the end.`;
83461
+ async function generateSessionTitle(opts) {
83462
+ let apiKey = opts.apiKey;
83463
+ let accountId = opts.accountId;
83464
+ if (opts.resolveCredentials) {
83465
+ const creds = await opts.resolveCredentials();
83466
+ apiKey = creds.apiKey;
83467
+ accountId = creds.accountId;
83468
+ }
83469
+ const model = opts.provider === "anthropic" ? "claude-haiku-4-5-20251001" : opts.provider === "openai" ? "gpt-5.1-codex-mini" : opts.provider === "glm" ? "glm-4.7-flash" : opts.provider === "moonshot" ? "kimi-k2.7-code" : "claude-haiku-4-5-20251001";
83470
+ const messages = [
83471
+ { role: "system", content: TITLE_PROMPT },
83472
+ {
83473
+ role: "user",
83474
+ content: `User asked: "${truncate2(opts.userMessage, 300)}"
83475
+
83476
+ Assistant began: "${truncate2(opts.assistantPreview, 200)}"`
83477
+ }
83478
+ ];
83479
+ try {
83480
+ const result = stream({
83481
+ provider: opts.provider,
83482
+ model,
83483
+ messages,
83484
+ maxTokens: 30,
83485
+ temperature: 0,
83486
+ apiKey,
83487
+ baseUrl: opts.baseUrl,
83488
+ accountId
83489
+ });
83490
+ result.response.catch(() => {
83491
+ });
83492
+ const response = await result;
83493
+ const msg = response.message;
83494
+ const text = typeof msg.content === "string" ? msg.content : msg.content.filter((c2) => c2.type === "text").map((c2) => c2.text).join("");
83495
+ return text.trim().replace(/[."]+$/, "") || "New conversation";
83496
+ } catch {
83497
+ return fallbackTitle(opts.userMessage);
83498
+ }
83499
+ }
83500
+ function truncate2(s, max) {
83501
+ if (s.length <= max)
83502
+ return s;
83503
+ return s.slice(0, max) + "\u2026";
83504
+ }
83505
+ function fallbackTitle(userMessage) {
83506
+ if (!userMessage)
83507
+ return "New conversation";
83508
+ const cleaned = userMessage.replace(/^\/\S+\s*/, "").replace(/\s+/g, " ").trim();
83509
+ const first = cleaned.split(/[.\n]/)[0]?.trim() ?? cleaned;
83510
+ if (first.length <= 50)
83511
+ return first;
83512
+ const t = first.slice(0, 50);
83513
+ const sp = t.lastIndexOf(" ");
83514
+ return (sp > 20 ? t.slice(0, sp) : t) + "\u2026";
83515
+ }
83516
+
83517
+ // ../ggcoder/dist/core/ideal-review.js
83518
+ init_esm_shims();
83519
+ var IDEAL_REVIEW_PROMPT = "Ideal? Review the actual work against the user's request before the final response. Is it simple, focused, correct, and aligned? Did you over-edit, leave TODOs, miss an obvious case the request called for, or introduce risk? Judge this by reading the code you changed \u2014 do NOT run builds, typechecks, linters, or test suites now; that happens at commit time via /commit. If anything is wrong, fix it now. If everything is good, respond with the final answer only; do not mention this ideal review unless it changed the work.";
83520
+ function evaluateIdealReview(stats) {
83521
+ const reasons = [];
83522
+ let score = 0;
83523
+ if (stats.changedLines >= 120) {
83524
+ score += 2;
83525
+ reasons.push(`${stats.changedLines} changed lines`);
83526
+ } else if (stats.changedLines >= 60) {
83527
+ score += 1;
83528
+ reasons.push(`${stats.changedLines} changed lines`);
83529
+ }
83530
+ if (stats.toolCalls >= 8) {
83531
+ score += 1;
83532
+ reasons.push(`${stats.toolCalls} tool calls`);
83533
+ }
83534
+ if (stats.writeCalls + stats.editCalls >= 4) {
83535
+ score += 2;
83536
+ reasons.push(`${stats.writeCalls + stats.editCalls} file mutation calls`);
83537
+ } else if (stats.writeCalls + stats.editCalls >= 2) {
83538
+ score += 1;
83539
+ reasons.push(`${stats.writeCalls + stats.editCalls} file mutation calls`);
83540
+ }
83541
+ if (stats.bashCalls > 0 && stats.writeCalls + stats.editCalls > 0) {
83542
+ score += 1;
83543
+ reasons.push("shell command plus file mutation");
83544
+ }
83545
+ if (stats.toolFailures > 0) {
83546
+ score += 2;
83547
+ reasons.push(`${stats.toolFailures} failed tool calls`);
83548
+ }
83549
+ if (stats.turns >= 6) {
83550
+ score += 1;
83551
+ reasons.push(`${stats.turns} agent turns`);
83552
+ }
83553
+ return { shouldReview: score >= 4, score, reasons };
83554
+ }
83555
+ function buildIdealReviewMessage(reasons) {
83556
+ const reasonText = reasons.length > 0 ? ` Triggered because: ${reasons.join(", ")}.` : "";
83557
+ return {
83558
+ role: "user",
83559
+ content: `${IDEAL_REVIEW_PROMPT}${reasonText}`
83560
+ };
83561
+ }
83562
+
83563
+ // ../ggcoder/dist/core/loop-breaker.js
83564
+ init_esm_shims();
83565
+ var CONSECUTIVE_FAILURE_LIMIT = 3;
83566
+ var SIGNATURE_REPEAT_LIMIT = 3;
83567
+ var SAME_FILE_EDIT_LIMIT = 5;
83568
+ var LOOP_BREAK_PROMPT = "Stuck? You've repeated essentially the same action and it keeps failing or not advancing. Stop and break the pattern. Read the latest error or result literally \u2014 not what you expected it to say. Then question the assumption underneath your approach: the file, path, API, command, or premise you've been treating as true may be wrong. Either try a fundamentally different approach or, if you genuinely cannot make progress, stop and tell the user what's blocking you and what you need. Do NOT repeat the previous attempt with minor tweaks. Do not mention this note unless it changed your approach.";
83569
+ function toolCallSignature(name, args) {
83570
+ return `${name}\0${canonicalize(args)}`;
83571
+ }
83572
+ function canonicalize(value) {
83573
+ if (value === null || typeof value !== "object") {
83574
+ return JSON.stringify(value) ?? "null";
83575
+ }
83576
+ if (Array.isArray(value)) {
83577
+ return `[${value.map(canonicalize).join(",")}]`;
83578
+ }
83579
+ const entries = Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
83580
+ return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalize(v)}`).join(",")}}`;
83581
+ }
83582
+ var TEXT_REPETITION_MIN_LENGTH = 40;
83583
+ var TEXT_REPETITION_MIN_REPEATS = 3;
83584
+ var TEXT_REPETITION_TAIL = 4096;
83585
+ function detectTextRepetition(text) {
83586
+ if (text.length < TEXT_REPETITION_MIN_LENGTH * TEXT_REPETITION_MIN_REPEATS) {
83587
+ return false;
83588
+ }
83589
+ const tail = text.slice(-TEXT_REPETITION_TAIL);
83590
+ const maxBlock = Math.floor(tail.length / TEXT_REPETITION_MIN_REPEATS);
83591
+ for (let block2 = TEXT_REPETITION_MIN_LENGTH; block2 <= maxBlock; block2++) {
83592
+ const unit = tail.slice(tail.length - block2);
83593
+ let repeats = 1;
83594
+ let offset = tail.length - block2 * 2;
83595
+ while (offset >= 0 && tail.slice(offset, offset + block2) === unit) {
83596
+ repeats++;
83597
+ offset -= block2;
83598
+ }
83599
+ if (repeats >= TEXT_REPETITION_MIN_REPEATS)
83600
+ return true;
83601
+ }
83602
+ return false;
83603
+ }
83604
+ function evaluateLoopBreak(stats) {
83605
+ const reasons = [];
83606
+ if (stats.consecutiveFailures >= CONSECUTIVE_FAILURE_LIMIT) {
83607
+ reasons.push(`${stats.consecutiveFailures} consecutive failed tool calls`);
83608
+ }
83609
+ if (stats.maxSignatureRepeats >= SIGNATURE_REPEAT_LIMIT) {
83610
+ reasons.push(`identical tool call repeated ${stats.maxSignatureRepeats}x`);
83611
+ }
83612
+ if (stats.maxSameFileEdits >= SAME_FILE_EDIT_LIMIT) {
83613
+ reasons.push(`${stats.maxSameFileEdits} edits to the same file`);
83614
+ }
83615
+ if (stats.textRepetitionDetected) {
83616
+ reasons.push("repeated output detected");
83617
+ }
83618
+ return { shouldBreak: reasons.length > 0, reasons };
83619
+ }
83620
+ function buildLoopBreakMessage(reasons) {
83621
+ const reasonText = reasons.length > 0 ? ` Triggered because: ${reasons.join(", ")}.` : "";
83622
+ return {
83623
+ role: "user",
83624
+ content: `${LOOP_BREAK_PROMPT}${reasonText}`
83625
+ };
83626
+ }
83627
+
83628
+ // ../ggcoder/dist/core/regrounding.js
83629
+ init_esm_shims();
83630
+ function buildRegroundingMessage(originalRequest) {
83631
+ const trimmed = originalRequest.trim();
83632
+ const pin = trimmed.length > 0 ? `
83633
+
83634
+ The user's original request was:
83635
+
83636
+ ${trimmed}
83637
+
83638
+ ` : " The original request is in the earlier messages that remain. ";
83639
+ return {
83640
+ role: "user",
83641
+ content: "Re-ground. The conversation was just compacted, so earlier detail is now a summary and easy to drift from." + pin + "Before continuing, re-anchor on two things: that original request, and the specific objective you're working on right now. Verify your next step still serves the original ask \u2014 not a reshaped or narrowed version of it. If the summary dropped a constraint, file, or requirement you were tracking, recover it from the messages that remain before acting. Then continue. Do not restate this note; just proceed correctly."
83642
+ };
83643
+ }
83644
+
83453
83645
  // ../ggcoder/dist/core/agent-session.js
83454
83646
  import crypto8 from "crypto";
83455
83647
  import fs29 from "fs/promises";
@@ -83465,6 +83657,34 @@ var AgentSession = class {
83465
83657
  tools = [];
83466
83658
  skills = [];
83467
83659
  cacheKeyLogged = false;
83660
+ // ── Self-correction hook state (mirrors the TUI's useAgentLoop refs) ──
83661
+ // Reset at the start of every run; observed from the event stream; read by
83662
+ // the loop-break (mid-loop) and ideal-review (pre-stop) callbacks.
83663
+ hookStats = {
83664
+ changedLines: 0,
83665
+ toolCalls: 0,
83666
+ toolFailures: 0,
83667
+ turns: 0,
83668
+ writeCalls: 0,
83669
+ editCalls: 0,
83670
+ bashCalls: 0
83671
+ };
83672
+ hookText = "";
83673
+ hookConsecutiveFailures = 0;
83674
+ hookMaxSignatureRepeats = 0;
83675
+ hookMaxSameFileEdits = 0;
83676
+ hookSignatureCounts = /* @__PURE__ */ new Map();
83677
+ hookFileEditCounts = /* @__PURE__ */ new Map();
83678
+ hookToolCalls = /* @__PURE__ */ new Map();
83679
+ idealReviewInjected = false;
83680
+ loopBreakInjected = false;
83681
+ regroundingInjected = false;
83682
+ compactionOccurred = false;
83683
+ originalRequest = "";
83684
+ // Messages queued by the user while a run is in flight. Drained at the
83685
+ // mid-loop steering boundary (user steering wins over the hooks), mirroring
83686
+ // the TUI's getSteeringMessages.
83687
+ userQueue = [];
83468
83688
  processManager;
83469
83689
  lspManager;
83470
83690
  mcpManager;
@@ -83475,6 +83695,8 @@ var AgentSession = class {
83475
83695
  maxTokens;
83476
83696
  thinkingLevel;
83477
83697
  customSystemPrompt;
83698
+ /** Shared with the tool layer so plan-mode restrictions read live state. */
83699
+ planModeRef = { current: false };
83478
83700
  sessionId = "";
83479
83701
  sessionPath = "";
83480
83702
  lastPersistedIndex = 0;
@@ -83519,7 +83741,14 @@ var AgentSession = class {
83519
83741
  lspDiagnostics: this.settingsManager.get("lspDiagnostics"),
83520
83742
  // Lazy — sessionId isn't assigned yet when createTools() runs, so we
83521
83743
  // must defer reading the cache key until the sub-agent actually fires.
83522
- getCacheKey: () => this.getPromptCacheKey()
83744
+ getCacheKey: () => this.getPromptCacheKey(),
83745
+ // Plan mode: only wired when the host supplies callbacks. The ref is
83746
+ // shared so bash/edit/write enforce read-only restrictions live.
83747
+ ...this.opts.onEnterPlan || this.opts.onExitPlan ? {
83748
+ planModeRef: this.planModeRef,
83749
+ onEnterPlan: this.opts.onEnterPlan,
83750
+ onExitPlan: this.opts.onExitPlan
83751
+ } : {}
83523
83752
  });
83524
83753
  this.tools = tools;
83525
83754
  this.processManager = processManager;
@@ -83630,6 +83859,173 @@ ${parsed.args}` : promptText;
83630
83859
  this.lastPersistedIndex = this.messages.length;
83631
83860
  await this.runLoop();
83632
83861
  }
83862
+ /**
83863
+ * Prompt with multimodal attachments (images / videos) alongside optional
83864
+ * text. Images and videos become native content blocks the model can see;
83865
+ * non-media files are surfaced as a text note with their saved path so the
83866
+ * agent can open them with its tools. Slash-command parsing is skipped —
83867
+ * attachments are always a direct conversational turn.
83868
+ */
83869
+ async promptWithAttachments(text, attachments) {
83870
+ const parts = [];
83871
+ const fileNotes = [];
83872
+ for (const a of attachments) {
83873
+ if (a.kind === "image") {
83874
+ parts.push({ type: "image", mediaType: a.mediaType, data: a.data });
83875
+ } else if (a.kind === "video") {
83876
+ parts.push({ type: "video", mediaType: a.mediaType, data: a.data });
83877
+ } else if (a.path) {
83878
+ fileNotes.push(`- ${a.name} (saved at ${a.path})`);
83879
+ }
83880
+ }
83881
+ const textParts = [];
83882
+ if (text.trim())
83883
+ textParts.push(text.trim());
83884
+ if (fileNotes.length > 0) {
83885
+ textParts.push(`Attached files (inspect with your tools):
83886
+ ${fileNotes.join("\n")}`);
83887
+ }
83888
+ if (textParts.length > 0)
83889
+ parts.unshift({ type: "text", text: textParts.join("\n\n") });
83890
+ if (parts.length === 0)
83891
+ return;
83892
+ const userMessage = { role: "user", content: parts };
83893
+ this.messages.push(userMessage);
83894
+ await this.persistMessage(userMessage);
83895
+ this.lastPersistedIndex = this.messages.length;
83896
+ await this.runLoop();
83897
+ }
83898
+ /**
83899
+ * Reset per-run self-correction hook state. Mirrors the TUI's run_start
83900
+ * resets so each run evaluates the hooks from a clean slate. `originalRequest`
83901
+ * is the verbatim user ask, pinned for post-compaction re-grounding.
83902
+ */
83903
+ resetHookState(originalRequest) {
83904
+ this.hookStats = {
83905
+ changedLines: 0,
83906
+ toolCalls: 0,
83907
+ toolFailures: 0,
83908
+ turns: 0,
83909
+ writeCalls: 0,
83910
+ editCalls: 0,
83911
+ bashCalls: 0
83912
+ };
83913
+ this.hookText = "";
83914
+ this.hookConsecutiveFailures = 0;
83915
+ this.hookMaxSignatureRepeats = 0;
83916
+ this.hookMaxSameFileEdits = 0;
83917
+ this.hookSignatureCounts.clear();
83918
+ this.hookFileEditCounts.clear();
83919
+ this.hookToolCalls.clear();
83920
+ this.idealReviewInjected = false;
83921
+ this.loopBreakInjected = false;
83922
+ this.regroundingInjected = false;
83923
+ this.compactionOccurred = false;
83924
+ this.originalRequest = originalRequest;
83925
+ }
83926
+ /**
83927
+ * Fold one agent event into the hook stat accumulators. Pure bookkeeping —
83928
+ * the same signals the TUI's useAgentLoop collects, so the loop-break and
83929
+ * ideal-review decisions match across the CLI and the app.
83930
+ */
83931
+ trackHookEvent(event) {
83932
+ switch (event.type) {
83933
+ case "text_delta":
83934
+ this.hookText += event.text;
83935
+ break;
83936
+ case "tool_call_start":
83937
+ this.hookToolCalls.set(event.toolCallId, { name: event.name, args: event.args ?? {} });
83938
+ break;
83939
+ case "tool_call_end": {
83940
+ const call = this.hookToolCalls.get(event.toolCallId);
83941
+ const name = call?.name ?? "";
83942
+ const args = call?.args;
83943
+ this.hookStats.toolCalls += 1;
83944
+ if (event.isError)
83945
+ this.hookStats.toolFailures += 1;
83946
+ if (name === "write")
83947
+ this.hookStats.writeCalls += 1;
83948
+ if (name === "edit")
83949
+ this.hookStats.editCalls += 1;
83950
+ if (name === "bash")
83951
+ this.hookStats.bashCalls += 1;
83952
+ this.hookConsecutiveFailures = event.isError ? this.hookConsecutiveFailures + 1 : 0;
83953
+ const sig = toolCallSignature(name, args);
83954
+ const sigNext = (this.hookSignatureCounts.get(sig) ?? 0) + 1;
83955
+ this.hookSignatureCounts.set(sig, sigNext);
83956
+ if (sigNext > this.hookMaxSignatureRepeats)
83957
+ this.hookMaxSignatureRepeats = sigNext;
83958
+ if ((name === "edit" || name === "write") && args) {
83959
+ const filePath = args.file_path;
83960
+ if (typeof filePath === "string") {
83961
+ const fileNext = (this.hookFileEditCounts.get(filePath) ?? 0) + 1;
83962
+ this.hookFileEditCounts.set(filePath, fileNext);
83963
+ if (fileNext > this.hookMaxSameFileEdits)
83964
+ this.hookMaxSameFileEdits = fileNext;
83965
+ }
83966
+ }
83967
+ if (name === "edit" && !event.isError) {
83968
+ const diff3 = event.details?.diff ?? event.result;
83969
+ const added = (diff3.match(/^\+[^+]/gm) ?? []).length;
83970
+ const removed = (diff3.match(/^-[^-]/gm) ?? []).length;
83971
+ this.hookStats.changedLines += added + removed;
83972
+ }
83973
+ break;
83974
+ }
83975
+ case "turn_end":
83976
+ this.hookStats.turns = event.turn;
83977
+ break;
83978
+ }
83979
+ }
83980
+ /**
83981
+ * Mid-loop steering hook: fires the loop-breaker when the agent looks stuck,
83982
+ * then post-compaction re-grounding. At most one of each per run. Mirrors the
83983
+ * TUI's getSteeringMessages ordering (minus user steering, which the app
83984
+ * delivers as normal prompts).
83985
+ */
83986
+ getHookSteeringMessages() {
83987
+ if (this.userQueue.length > 0) {
83988
+ const merged = this.userQueue.splice(0).join("\n\n");
83989
+ return [{ role: "user", content: merged }];
83990
+ }
83991
+ if (!this.settingsManager.get("idealReviewEnabled"))
83992
+ return null;
83993
+ if (!this.loopBreakInjected) {
83994
+ const decision = evaluateLoopBreak({
83995
+ consecutiveFailures: this.hookConsecutiveFailures,
83996
+ maxSignatureRepeats: this.hookMaxSignatureRepeats,
83997
+ maxSameFileEdits: this.hookMaxSameFileEdits,
83998
+ textRepetitionDetected: detectTextRepetition(this.hookText)
83999
+ });
84000
+ if (decision.shouldBreak) {
84001
+ this.loopBreakInjected = true;
84002
+ this.eventBus.emit("hook", { kind: "loop_break" });
84003
+ return [buildLoopBreakMessage(decision.reasons)];
84004
+ }
84005
+ }
84006
+ if (!this.regroundingInjected && this.compactionOccurred) {
84007
+ this.regroundingInjected = true;
84008
+ this.eventBus.emit("hook", { kind: "regrounding" });
84009
+ return [buildRegroundingMessage(this.originalRequest)];
84010
+ }
84011
+ return null;
84012
+ }
84013
+ /**
84014
+ * Pre-stop follow-up hook: runs the ideal review once, when the agent would
84015
+ * otherwise finish and the change set is substantial enough to warrant it.
84016
+ */
84017
+ getHookFollowUpMessages() {
84018
+ if (!this.settingsManager.get("idealReviewEnabled"))
84019
+ return null;
84020
+ if (this.idealReviewInjected)
84021
+ return null;
84022
+ const decision = evaluateIdealReview(this.hookStats);
84023
+ if (!decision.shouldReview)
84024
+ return null;
84025
+ this.idealReviewInjected = true;
84026
+ this.eventBus.emit("hook", { kind: "ideal" });
84027
+ return [buildIdealReviewMessage(decision.reasons)];
84028
+ }
83633
84029
  /** Auto-compact if needed, run agent loop with auth retry, and persist messages. */
83634
84030
  async runLoop() {
83635
84031
  if (!this.cacheKeyLogged) {
@@ -83641,6 +84037,9 @@ ${parsed.args}` : promptText;
83641
84037
  transient: String(!!this.opts.transient)
83642
84038
  });
83643
84039
  }
84040
+ const lastUser = [...this.messages].reverse().find((m) => m.role === "user");
84041
+ const originalRequest = typeof lastUser?.content === "string" ? lastUser.content : "";
84042
+ this.resetHookState(originalRequest);
83644
84043
  let creds = await this.authStorage.resolveCredentials(this.provider);
83645
84044
  if (this.settingsManager.get("autoCompact")) {
83646
84045
  const contextWindow = getContextWindow(this.model, {
@@ -83650,6 +84049,7 @@ ${parsed.args}` : promptText;
83650
84049
  const threshold = this.settingsManager.get("compactThreshold");
83651
84050
  if (shouldCompact(this.messages, contextWindow, threshold)) {
83652
84051
  await this.compact(creds);
84052
+ this.compactionOccurred = true;
83653
84053
  }
83654
84054
  }
83655
84055
  const userAgent = this.provider === "anthropic" ? await getClaudeCliUserAgent() : void 0;
@@ -83679,9 +84079,14 @@ ${parsed.args}` : promptText;
83679
84079
  userAgent,
83680
84080
  // clearToolUses disabled — causes model to output unsolicited context summaries
83681
84081
  // Single tool result shouldn't exceed 30% of context window (in chars)
83682
- maxToolResultChars: Math.floor(getContextWindow(this.model, { provider: this.provider, accountId }) * 3.5 * 0.3)
84082
+ maxToolResultChars: Math.floor(getContextWindow(this.model, { provider: this.provider, accountId }) * 3.5 * 0.3),
84083
+ // Self-correction hooks (same as the TUI): loop-break + re-grounding are
84084
+ // polled mid-loop; the ideal review is polled when the agent would stop.
84085
+ getSteeringMessages: () => this.getHookSteeringMessages(),
84086
+ getFollowUpMessages: () => this.getHookFollowUpMessages()
83683
84087
  });
83684
84088
  for await (const event of generator) {
84089
+ this.trackHookEvent(event);
83685
84090
  this.eventBus.forwardAgentEvent(event);
83686
84091
  }
83687
84092
  };
@@ -83833,12 +84238,93 @@ ${parsed.args}` : promptText;
83833
84238
  cwd: this.cwd,
83834
84239
  sessionId: this.sessionId,
83835
84240
  sessionPath: this.sessionPath,
83836
- messageCount: this.messages.length
84241
+ messageCount: this.messages.length,
84242
+ planMode: this.planModeRef.current
83837
84243
  };
83838
84244
  }
84245
+ getPlanMode() {
84246
+ return this.planModeRef.current;
84247
+ }
84248
+ /** Queue a user message to be injected mid-run as steering. Returns the new
84249
+ * queue length. No-op semantics are the caller's concern. */
84250
+ queueMessage(text) {
84251
+ this.userQueue.push(text);
84252
+ return this.userQueue.length;
84253
+ }
84254
+ /** Number of messages currently queued. */
84255
+ getQueuedCount() {
84256
+ return this.userQueue.length;
84257
+ }
84258
+ /** Clear the queue, returning the combined text (to restore to the composer). */
84259
+ drainQueue() {
84260
+ return this.userQueue.splice(0).join("\n\n");
84261
+ }
84262
+ /** Snapshot of background processes (bash run_in_background), newest-state. */
84263
+ listBackgroundProcesses() {
84264
+ return this.processManager?.list() ?? [];
84265
+ }
84266
+ /** Stop a background process by id. Returns a human-readable status string. */
84267
+ async killBackgroundProcess(id2) {
84268
+ if (!this.processManager)
84269
+ return `No background process with id "${id2}"`;
84270
+ return this.processManager.stop(id2);
84271
+ }
84272
+ /**
84273
+ * Toggle plan mode: flips the shared ref (so tools enforce read-only
84274
+ * restrictions) and rebuilds the system prompt in place so the model is told
84275
+ * about the mode change on its next turn. No-op when a custom system prompt
84276
+ * is in force (the host owns the prompt then).
84277
+ */
84278
+ async setPlanMode(active) {
84279
+ this.planModeRef.current = active;
84280
+ if (this.customSystemPrompt)
84281
+ return;
84282
+ const rebuilt = await buildSystemPrompt(this.cwd, this.skills, active, void 0, this.tools.map((tool) => tool.name), void 0, this.provider);
84283
+ if (this.messages[0]?.role === "system") {
84284
+ this.messages[0] = { role: "system", content: rebuilt };
84285
+ } else {
84286
+ this.messages.unshift({ role: "system", content: rebuilt });
84287
+ }
84288
+ }
83839
84289
  getMessages() {
83840
84290
  return this.messages;
83841
84291
  }
84292
+ /**
84293
+ * Generate a short LLM session title from the conversation so far (first user
84294
+ * message + first assistant reply). Best-effort; returns null on failure or
84295
+ * when there's no user message yet. Uses the cheapest model for the provider.
84296
+ */
84297
+ async generateTitle() {
84298
+ const extractText = (content) => typeof content === "string" ? content : content.map((c2) => c2.type === "text" && "text" in c2 && typeof c2.text === "string" ? c2.text : "").join(" ");
84299
+ const userMsg = this.messages.find((m) => m.role === "user");
84300
+ const assistantMsg = this.messages.find((m) => m.role === "assistant");
84301
+ const userText = userMsg ? extractText(userMsg.content) : "";
84302
+ if (!userText.trim())
84303
+ return null;
84304
+ try {
84305
+ const creds = await this.authStorage.resolveCredentials(this.provider);
84306
+ const title = await generateSessionTitle({
84307
+ provider: this.provider,
84308
+ userMessage: userText,
84309
+ assistantPreview: assistantMsg ? extractText(assistantMsg.content).slice(0, 200) : "",
84310
+ apiKey: creds.accessToken,
84311
+ baseUrl: this.baseUrl ?? creds.baseUrl,
84312
+ accountId: creds.accountId
84313
+ });
84314
+ return title || null;
84315
+ } catch {
84316
+ return null;
84317
+ }
84318
+ }
84319
+ /** Current reasoning/thinking level, or undefined when thinking is off. */
84320
+ getThinkingLevel() {
84321
+ return this.thinkingLevel;
84322
+ }
84323
+ /** Set the reasoning/thinking level (undefined turns thinking off). Takes
84324
+ * effect on the next prompt, since the in-flight loop reads it at start. */
84325
+ setThinkingLevel(level) {
84326
+ this.thinkingLevel = level;
84327
+ }
83842
84328
  /** Replace the abort signal (e.g. after cancellation). */
83843
84329
  setSignal(signal) {
83844
84330
  this.opts = { ...this.opts, signal };
@@ -88939,8 +89425,8 @@ var cleanupYogaNode = (node) => {
88939
89425
  var currentUpdatePriority = import_constants3.NoEventPriority;
88940
89426
  var currentRootNode;
88941
89427
  async function loadPackageJson() {
88942
- const fs38 = await import("fs");
88943
- const content = fs38.readFileSync(new URL("../package.json", import.meta.url), "utf8");
89428
+ const fs39 = await import("fs");
89429
+ const content = fs39.readFileSync(new URL("../package.json", import.meta.url), "utf8");
88944
89430
  return JSON.parse(content);
88945
89431
  }
88946
89432
  var packageJson = isDev() ? await loadPackageJson() : { name: void 0, version: void 0 };
@@ -90630,8 +91116,8 @@ function Text({ color: color2, backgroundColor, dimColor = false, bold = false,
90630
91116
  }
90631
91117
 
90632
91118
  // ../../node_modules/.pnpm/@kenkaiiii+ink@6.8.0-gg.2_@types+react@19.2.14_react@19.2.5/node_modules/@kenkaiiii/ink/build/components/ErrorOverview.js
90633
- var cleanupPath = (path45) => {
90634
- return path45?.replace(`file://${cwd()}/`, "");
91119
+ var cleanupPath = (path46) => {
91120
+ return path46?.replace(`file://${cwd()}/`, "");
90635
91121
  };
90636
91122
  var stackUtils = new import_stack_utils.default({
90637
91123
  cwd: cwd(),
@@ -93308,9 +93794,6 @@ var notificationPath = resolve(__dirname2, "../../assets/end-notification.mp3");
93308
93794
  init_esm_shims();
93309
93795
  var import_react43 = __toESM(require_react(), 1);
93310
93796
 
93311
- // ../ggcoder/dist/core/loop-breaker.js
93312
- init_esm_shims();
93313
-
93314
93797
  // ../ggcoder/dist/ui/hooks/useTranscriptHistory.js
93315
93798
  init_esm_shims();
93316
93799
  var import_react44 = __toESM(require_react(), 1);
@@ -93919,8 +94402,8 @@ function shortenValue(value, maxLength = MAX_DETAIL_LENGTH) {
93919
94402
  const tailLength = maxLength - 1 - headLength;
93920
94403
  return `${normalized.slice(0, headLength)}\u2026${normalized.slice(-tailLength)}`;
93921
94404
  }
93922
- function basename2(path45) {
93923
- const trimmed = path45.replace(/\/+$/u, "");
94405
+ function basename2(path46) {
94406
+ const trimmed = path46.replace(/\/+$/u, "");
93924
94407
  return trimmed.split("/").filter(Boolean).at(-1) ?? trimmed;
93925
94408
  }
93926
94409
  function uniqueValues(values) {
@@ -111271,9 +111754,6 @@ var getPendingUpdate = updater.getPendingUpdate;
111271
111754
  var startPeriodicUpdateCheck = updater.startPeriodicUpdateCheck;
111272
111755
  var stopPeriodicUpdateCheck = updater.stopPeriodicUpdateCheck;
111273
111756
 
111274
- // ../ggcoder/dist/utils/session-title.js
111275
- init_esm_shims();
111276
-
111277
111757
  // ../ggcoder/dist/core/setup-history.js
111278
111758
  init_esm_shims();
111279
111759
  import fs33 from "fs";
@@ -111304,12 +111784,6 @@ init_esm_shims();
111304
111784
  // ../ggcoder/dist/ui/submit-slash-commands.js
111305
111785
  init_esm_shims();
111306
111786
 
111307
- // ../ggcoder/dist/core/ideal-review.js
111308
- init_esm_shims();
111309
-
111310
- // ../ggcoder/dist/core/regrounding.js
111311
- init_esm_shims();
111312
-
111313
111787
  // ../ggcoder/dist/ui/thinking-level.js
111314
111788
  init_esm_shims();
111315
111789
 
@@ -112403,6 +112877,276 @@ var DISABLE_MODIFY_OTHER_KEYS = "\x1B[>4;0m";
112403
112877
  var SCREEN_CLEAR = DISABLE_MODIFY_OTHER_KEYS + "\x1B[2J\x1B[3J\x1B[H";
112404
112878
  var VIEWPORT_CLEAR = DISABLE_MODIFY_OTHER_KEYS + "\x1B[2J\x1B[H";
112405
112879
 
112880
+ // ../ggcoder/dist/core/project-discovery.js
112881
+ init_esm_shims();
112882
+ import fs34 from "fs/promises";
112883
+ import { createReadStream as createReadStream3 } from "fs";
112884
+ import readline3 from "readline";
112885
+ import os12 from "os";
112886
+ import path40 from "path";
112887
+ async function discoverProjects() {
112888
+ const [gg, cc, cx] = await Promise.all([
112889
+ discoverGgcoderProjects(),
112890
+ discoverClaudeProjects(),
112891
+ discoverCodexProjects()
112892
+ ]);
112893
+ const byPath = /* @__PURE__ */ new Map();
112894
+ for (const p of [...gg, ...cc, ...cx]) {
112895
+ const existing = byPath.get(p.path);
112896
+ if (!existing) {
112897
+ byPath.set(p.path, p);
112898
+ continue;
112899
+ }
112900
+ byPath.set(p.path, {
112901
+ name: existing.name,
112902
+ path: existing.path,
112903
+ lastActiveMs: Math.max(existing.lastActiveMs, p.lastActiveMs),
112904
+ lastActiveDisplay: "",
112905
+ // recomputed below
112906
+ sources: mergeSources(existing.sources, p.sources)
112907
+ });
112908
+ }
112909
+ const merged = Array.from(byPath.values()).map((p) => ({
112910
+ ...p,
112911
+ lastActiveDisplay: formatRelativeTime(p.lastActiveMs)
112912
+ }));
112913
+ merged.sort((a, b) => b.lastActiveMs - a.lastActiveMs);
112914
+ return merged;
112915
+ }
112916
+ var SOURCE_ORDER = {
112917
+ ggcoder: 0,
112918
+ "claude-code": 1,
112919
+ codex: 2
112920
+ };
112921
+ function mergeSources(a, b) {
112922
+ const set2 = /* @__PURE__ */ new Set([...a, ...b]);
112923
+ return Array.from(set2).sort((x, y) => SOURCE_ORDER[x] - SOURCE_ORDER[y]);
112924
+ }
112925
+ async function discoverGgcoderProjects() {
112926
+ const sessionsDir = getAppPaths().sessionsDir;
112927
+ let entries;
112928
+ try {
112929
+ entries = await fs34.readdir(sessionsDir);
112930
+ } catch {
112931
+ return [];
112932
+ }
112933
+ const results = [];
112934
+ for (const entry of entries) {
112935
+ const dir = path40.join(sessionsDir, entry);
112936
+ const mtime = await maxJsonlMtime(dir);
112937
+ if (mtime === null)
112938
+ continue;
112939
+ const decoded = path40.resolve("/" + entry.replace(/_/g, "/"));
112940
+ if (!await isDirectory(decoded))
112941
+ continue;
112942
+ results.push({
112943
+ name: path40.basename(decoded),
112944
+ path: decoded,
112945
+ lastActiveMs: mtime,
112946
+ lastActiveDisplay: formatRelativeTime(mtime),
112947
+ sources: ["ggcoder"]
112948
+ });
112949
+ }
112950
+ return results;
112951
+ }
112952
+ async function discoverClaudeProjects() {
112953
+ const projectsDir = path40.join(os12.homedir(), ".claude", "projects");
112954
+ let entries;
112955
+ try {
112956
+ entries = await fs34.readdir(projectsDir);
112957
+ } catch {
112958
+ return [];
112959
+ }
112960
+ const results = await Promise.all(entries.map(async (entry) => {
112961
+ const dir = path40.join(projectsDir, entry);
112962
+ const mtime = await maxJsonlMtime(dir);
112963
+ if (mtime === null)
112964
+ return null;
112965
+ const cwd2 = await readFirstFromJsonlDir(dir, claudeCwdExtractor) ?? fallbackDashDecode(entry);
112966
+ if (!cwd2)
112967
+ return null;
112968
+ if (!await isDirectory(cwd2))
112969
+ return null;
112970
+ return {
112971
+ name: path40.basename(cwd2),
112972
+ path: cwd2,
112973
+ lastActiveMs: mtime,
112974
+ lastActiveDisplay: formatRelativeTime(mtime),
112975
+ sources: ["claude-code"]
112976
+ };
112977
+ }));
112978
+ return results.filter((p) => p !== null);
112979
+ }
112980
+ async function discoverCodexProjects() {
112981
+ const sessionsDir = path40.join(os12.homedir(), ".codex", "sessions");
112982
+ if (!await isDirectory(sessionsDir))
112983
+ return [];
112984
+ const files = await collectJsonlFiles(sessionsDir, 4);
112985
+ if (files.length === 0)
112986
+ return [];
112987
+ files.sort((a, b) => b.mtime - a.mtime);
112988
+ const byCwd = /* @__PURE__ */ new Map();
112989
+ for (const f of files) {
112990
+ const cwd2 = await readFirstFromFile(f.path, codexCwdExtractor);
112991
+ if (!cwd2)
112992
+ continue;
112993
+ const prev = byCwd.get(cwd2);
112994
+ if (prev === void 0 || f.mtime > prev)
112995
+ byCwd.set(cwd2, f.mtime);
112996
+ }
112997
+ const results = [];
112998
+ for (const [cwd2, mtime] of byCwd) {
112999
+ if (!await isDirectory(cwd2))
113000
+ continue;
113001
+ results.push({
113002
+ name: path40.basename(cwd2),
113003
+ path: cwd2,
113004
+ lastActiveMs: mtime,
113005
+ lastActiveDisplay: formatRelativeTime(mtime),
113006
+ sources: ["codex"]
113007
+ });
113008
+ }
113009
+ return results;
113010
+ }
113011
+ async function isDirectory(p) {
113012
+ try {
113013
+ const s = await fs34.stat(p);
113014
+ return s.isDirectory();
113015
+ } catch {
113016
+ return false;
113017
+ }
113018
+ }
113019
+ async function maxJsonlMtime(dir) {
113020
+ if (!await isDirectory(dir))
113021
+ return null;
113022
+ const files = await collectJsonlFiles(dir, 2);
113023
+ if (files.length === 0)
113024
+ return null;
113025
+ let max = 0;
113026
+ for (const f of files)
113027
+ if (f.mtime > max)
113028
+ max = f.mtime;
113029
+ return max > 0 ? max : null;
113030
+ }
113031
+ async function collectJsonlFiles(dir, maxDepth) {
113032
+ const out = [];
113033
+ await walk(dir, 0);
113034
+ return out;
113035
+ async function walk(current, depth) {
113036
+ let entries;
113037
+ try {
113038
+ entries = await fs34.readdir(current, { withFileTypes: true });
113039
+ } catch {
113040
+ return;
113041
+ }
113042
+ for (const e of entries) {
113043
+ const full = path40.join(current, e.name);
113044
+ if (e.isFile() && e.name.endsWith(".jsonl")) {
113045
+ try {
113046
+ const s = await fs34.stat(full);
113047
+ out.push({ path: full, mtime: s.mtimeMs });
113048
+ } catch {
113049
+ }
113050
+ } else if (e.isDirectory() && depth < maxDepth) {
113051
+ await walk(full, depth + 1);
113052
+ }
113053
+ }
113054
+ }
113055
+ }
113056
+ var claudeCwdExtractor = (line) => {
113057
+ try {
113058
+ const parsed = JSON.parse(line);
113059
+ if (typeof parsed.cwd === "string" && parsed.cwd.startsWith("/"))
113060
+ return parsed.cwd;
113061
+ } catch {
113062
+ }
113063
+ return null;
113064
+ };
113065
+ var CODEX_CWD_RE = /<cwd>([^<]+)<\/cwd>/;
113066
+ var codexCwdExtractor = (line) => {
113067
+ try {
113068
+ const parsed = JSON.parse(line);
113069
+ const cwd2 = parsed.payload?.cwd;
113070
+ if (typeof cwd2 === "string" && cwd2.startsWith("/"))
113071
+ return cwd2;
113072
+ } catch {
113073
+ }
113074
+ const m = CODEX_CWD_RE.exec(line);
113075
+ if (m && m[1] && m[1].startsWith("/"))
113076
+ return m[1];
113077
+ return null;
113078
+ };
113079
+ async function readFirstFromJsonlDir(dir, extractor) {
113080
+ const files = await collectJsonlFiles(dir, 2);
113081
+ if (files.length === 0)
113082
+ return null;
113083
+ files.sort((a, b) => b.mtime - a.mtime);
113084
+ for (const f of files) {
113085
+ const v = await readFirstFromFile(f.path, extractor);
113086
+ if (v)
113087
+ return v;
113088
+ }
113089
+ return null;
113090
+ }
113091
+ async function readFirstFromFile(file2, extractor) {
113092
+ return new Promise((resolve2) => {
113093
+ const stream2 = createReadStream3(file2, { encoding: "utf-8" });
113094
+ const rl = readline3.createInterface({ input: stream2, crlfDelay: Infinity });
113095
+ let lines = 0;
113096
+ let done = false;
113097
+ const MAX_LINES2 = 200;
113098
+ const finish = (value) => {
113099
+ if (done)
113100
+ return;
113101
+ done = true;
113102
+ resolve2(value);
113103
+ rl.close();
113104
+ stream2.destroy();
113105
+ };
113106
+ rl.on("line", (line) => {
113107
+ if (done)
113108
+ return;
113109
+ lines++;
113110
+ if (lines > MAX_LINES2) {
113111
+ finish(null);
113112
+ return;
113113
+ }
113114
+ const v = extractor(line);
113115
+ if (v)
113116
+ finish(v);
113117
+ });
113118
+ rl.on("close", () => finish(null));
113119
+ rl.on("error", () => finish(null));
113120
+ stream2.on("error", () => finish(null));
113121
+ });
113122
+ }
113123
+ function fallbackDashDecode(entry) {
113124
+ if (!entry.startsWith("-"))
113125
+ return null;
113126
+ return "/" + entry.slice(1).replace(/-/g, "/");
113127
+ }
113128
+ function formatRelativeTime(ms) {
113129
+ if (ms === 0)
113130
+ return "\u2014";
113131
+ const diff3 = Date.now() - ms;
113132
+ if (diff3 < 6e4)
113133
+ return "just now";
113134
+ const min = 6e4;
113135
+ const hour = 60 * min;
113136
+ const day = 24 * hour;
113137
+ const week = 7 * day;
113138
+ const month = 30 * day;
113139
+ if (diff3 < hour)
113140
+ return `${Math.floor(diff3 / min)}m ago`;
113141
+ if (diff3 < day)
113142
+ return `${Math.floor(diff3 / hour)}h ago`;
113143
+ if (diff3 < week)
113144
+ return `${Math.floor(diff3 / day)}d ago`;
113145
+ if (diff3 < month)
113146
+ return `${Math.floor(diff3 / week)}w ago`;
113147
+ return `${Math.floor(diff3 / month)}mo ago`;
113148
+ }
113149
+
112406
113150
  // src/boss-store.ts
112407
113151
  init_esm_shims();
112408
113152
  var import_react97 = __toESM(require_react(), 1);
@@ -113667,17 +114411,17 @@ var EventQueue = class {
113667
114411
 
113668
114412
  // src/settings.ts
113669
114413
  init_esm_shims();
113670
- import fs34 from "fs/promises";
113671
- import path40 from "path";
114414
+ import fs35 from "fs/promises";
114415
+ import path41 from "path";
113672
114416
  function settingsPath() {
113673
- return path40.join(getAppPaths().agentDir, "boss", "settings.json");
114417
+ return path41.join(getAppPaths().agentDir, "boss", "settings.json");
113674
114418
  }
113675
114419
  async function ensureDir() {
113676
- await fs34.mkdir(path40.dirname(settingsPath()), { recursive: true, mode: 448 });
114420
+ await fs35.mkdir(path41.dirname(settingsPath()), { recursive: true, mode: 448 });
113677
114421
  }
113678
114422
  async function loadSettings() {
113679
114423
  try {
113680
- const content = await fs34.readFile(settingsPath(), "utf-8");
114424
+ const content = await fs35.readFile(settingsPath(), "utf-8");
113681
114425
  const parsed = JSON.parse(content);
113682
114426
  if (!parsed || typeof parsed !== "object") return {};
113683
114427
  return parsed;
@@ -113692,8 +114436,8 @@ async function saveSettings(patch) {
113692
114436
  const merged = { ...current, ...patch };
113693
114437
  await ensureDir();
113694
114438
  const tmp = `${settingsPath()}.${process.pid}.tmp`;
113695
- await fs34.writeFile(tmp, JSON.stringify(merged, null, 2) + "\n", "utf-8");
113696
- await fs34.rename(tmp, settingsPath());
114439
+ await fs35.writeFile(tmp, JSON.stringify(merged, null, 2) + "\n", "utf-8");
114440
+ await fs35.rename(tmp, settingsPath());
113697
114441
  });
113698
114442
  writeChain = next.catch(() => void 0);
113699
114443
  await next;
@@ -114085,18 +114829,18 @@ init_esm_shims();
114085
114829
  // src/tasks-store.ts
114086
114830
  init_esm_shims();
114087
114831
  var import_react98 = __toESM(require_react(), 1);
114088
- import fs35 from "fs/promises";
114089
- import path41 from "path";
114832
+ import fs36 from "fs/promises";
114833
+ import path43 from "path";
114090
114834
  import crypto10 from "crypto";
114091
114835
  function getPlanPath() {
114092
- return path41.join(getAppPaths().agentDir, "boss", "plan.json");
114836
+ return path43.join(getAppPaths().agentDir, "boss", "plan.json");
114093
114837
  }
114094
114838
  async function ensureDir2() {
114095
- await fs35.mkdir(path41.dirname(getPlanPath()), { recursive: true, mode: 448 });
114839
+ await fs36.mkdir(path43.dirname(getPlanPath()), { recursive: true, mode: 448 });
114096
114840
  }
114097
114841
  async function loadPlan() {
114098
114842
  try {
114099
- const content = await fs35.readFile(getPlanPath(), "utf-8");
114843
+ const content = await fs36.readFile(getPlanPath(), "utf-8");
114100
114844
  const parsed = JSON.parse(content);
114101
114845
  return Array.isArray(parsed.tasks) ? parsed.tasks : [];
114102
114846
  } catch {
@@ -114110,8 +114854,8 @@ async function persist(tasks) {
114110
114854
  await ensureDir2();
114111
114855
  const finalPath = getPlanPath();
114112
114856
  const tmpPath = `${finalPath}.${process.pid}.tmp`;
114113
- await fs35.writeFile(tmpPath, snapshot, "utf-8");
114114
- await fs35.rename(tmpPath, finalPath);
114857
+ await fs36.writeFile(tmpPath, snapshot, "utf-8");
114858
+ await fs36.rename(tmpPath, finalPath);
114115
114859
  });
114116
114860
  persistChain = next.catch(() => void 0);
114117
114861
  await next;
@@ -114381,11 +115125,11 @@ function createTaskTools(deps) {
114381
115125
  init_esm_shims();
114382
115126
  import { spawn as spawn8, execFileSync as execFileSync4 } from "child_process";
114383
115127
  import { fileURLToPath as fileURLToPath5 } from "url";
114384
- import path43 from "path";
114385
- import fs36 from "fs";
115128
+ import path44 from "path";
115129
+ import fs37 from "fs";
114386
115130
  function readMp3DurationMs(file2) {
114387
115131
  try {
114388
- const buf = fs36.readFileSync(file2);
115132
+ const buf = fs37.readFileSync(file2);
114389
115133
  let i = 0;
114390
115134
  if (buf.length >= 10 && buf[0] === 73 && buf[1] === 68 && buf[2] === 51) {
114391
115135
  const tagSize = (buf[6] & 127) << 21 | (buf[7] & 127) << 14 | (buf[8] & 127) << 7 | buf[9] & 127;
@@ -114442,10 +115186,10 @@ function getSplashAudioDurationMs() {
114442
115186
  return ms && ms > 0 ? ms : 1500;
114443
115187
  }
114444
115188
  function assetPath(name) {
114445
- const here = path43.dirname(fileURLToPath5(import.meta.url));
114446
- const dist = path43.join(here, name);
114447
- if (fs36.existsSync(dist)) return dist;
114448
- return path43.join(here, "..", "assets", name);
115189
+ const here = path44.dirname(fileURLToPath5(import.meta.url));
115190
+ const dist = path44.join(here, name);
115191
+ if (fs37.existsSync(dist)) return dist;
115192
+ return path44.join(here, "..", "assets", name);
114449
115193
  }
114450
115194
  function splashAssetPath() {
114451
115195
  return assetPath("splash.mp3");
@@ -114485,15 +115229,15 @@ function trySpawn(cmd, args) {
114485
115229
  }
114486
115230
  function isWsl() {
114487
115231
  if (process.platform !== "linux") return false;
114488
- return !!process.env.WSL_DISTRO_NAME || fs36.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop");
115232
+ return !!process.env.WSL_DISTRO_NAME || fs37.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop");
114489
115233
  }
114490
115234
  async function tryPlayOnWindowsHost(file2) {
114491
115235
  try {
114492
- const here = path43.dirname(fileURLToPath5(import.meta.url));
114493
- const devAssets = path43.resolve(here, "..", "assets");
114494
- const resolved = path43.resolve(file2);
114495
- const inDist = resolved === here || resolved.startsWith(here + path43.sep);
114496
- const inAssets = resolved === devAssets || resolved.startsWith(devAssets + path43.sep);
115236
+ const here = path44.dirname(fileURLToPath5(import.meta.url));
115237
+ const devAssets = path44.resolve(here, "..", "assets");
115238
+ const resolved = path44.resolve(file2);
115239
+ const inDist = resolved === here || resolved.startsWith(here + path44.sep);
115240
+ const inAssets = resolved === devAssets || resolved.startsWith(devAssets + path44.sep);
114497
115241
  if (!inDist && !inAssets) {
114498
115242
  return false;
114499
115243
  }
@@ -114557,7 +115301,7 @@ async function tryPlayOnWindowsHost(file2) {
114557
115301
  }
114558
115302
  }
114559
115303
  async function playFile(file2) {
114560
- if (!fs36.existsSync(file2)) return;
115304
+ if (!fs37.existsSync(file2)) return;
114561
115305
  const platform2 = process.platform;
114562
115306
  if (platform2 === "darwin") {
114563
115307
  await trySpawn("afplay", [file2]);
@@ -114655,37 +115399,37 @@ function truncateOversizedToolResults2(messages, opts = {}) {
114655
115399
 
114656
115400
  // src/sessions.ts
114657
115401
  init_esm_shims();
114658
- import fs37 from "fs/promises";
114659
- import path44 from "path";
115402
+ import fs38 from "fs/promises";
115403
+ import path45 from "path";
114660
115404
  import crypto11 from "crypto";
114661
115405
  var BOSS_SUBDIR = "boss";
114662
115406
  var SESSIONS_SUBDIR = "sessions";
114663
115407
  function getBossDir() {
114664
- return path44.join(getAppPaths().agentDir, BOSS_SUBDIR);
115408
+ return path45.join(getAppPaths().agentDir, BOSS_SUBDIR);
114665
115409
  }
114666
115410
  function getSessionsDir() {
114667
- return path44.join(getBossDir(), SESSIONS_SUBDIR);
115411
+ return path45.join(getBossDir(), SESSIONS_SUBDIR);
114668
115412
  }
114669
115413
  async function ensureSessionsDir() {
114670
115414
  const dir = getSessionsDir();
114671
- await fs37.mkdir(dir, { recursive: true, mode: 448 });
115415
+ await fs38.mkdir(dir, { recursive: true, mode: 448 });
114672
115416
  return dir;
114673
115417
  }
114674
115418
  async function createSession2() {
114675
115419
  await ensureSessionsDir();
114676
115420
  const id2 = `${Date.now()}-${crypto11.randomBytes(4).toString("hex")}`;
114677
- const filePath = path44.join(getSessionsDir(), `${id2}.jsonl`);
114678
- await fs37.writeFile(filePath, "", "utf-8");
115421
+ const filePath = path45.join(getSessionsDir(), `${id2}.jsonl`);
115422
+ await fs38.writeFile(filePath, "", "utf-8");
114679
115423
  return { id: id2, filePath };
114680
115424
  }
114681
115425
  async function appendMessages(filePath, msgs) {
114682
115426
  if (msgs.length === 0) return;
114683
115427
  const lines = msgs.map((m) => JSON.stringify(m)).join("\n") + "\n";
114684
- await fs37.appendFile(filePath, lines, "utf-8");
115428
+ await fs38.appendFile(filePath, lines, "utf-8");
114685
115429
  }
114686
115430
  async function loadSession2(filePath) {
114687
115431
  try {
114688
- const content = await fs37.readFile(filePath, "utf-8");
115432
+ const content = await fs38.readFile(filePath, "utf-8");
114689
115433
  const lines = content.split("\n").filter((l) => l.length > 0);
114690
115434
  const messages = [];
114691
115435
  for (const line of lines) {
@@ -114701,8 +115445,8 @@ async function loadSession2(filePath) {
114701
115445
  }
114702
115446
  async function inspectSession(filePath, id2) {
114703
115447
  try {
114704
- const stat = await fs37.stat(filePath);
114705
- const content = await fs37.readFile(filePath, "utf-8");
115448
+ const stat = await fs38.stat(filePath);
115449
+ const content = await fs38.readFile(filePath, "utf-8");
114706
115450
  const lines = content.split("\n").filter((l) => l.length > 0);
114707
115451
  let firstUserMessage;
114708
115452
  for (const line of lines) {
@@ -114735,7 +115479,7 @@ async function listSessions2() {
114735
115479
  await ensureSessionsDir();
114736
115480
  let entries;
114737
115481
  try {
114738
- entries = await fs37.readdir(getSessionsDir());
115482
+ entries = await fs38.readdir(getSessionsDir());
114739
115483
  } catch {
114740
115484
  return [];
114741
115485
  }
@@ -114743,7 +115487,7 @@ async function listSessions2() {
114743
115487
  for (const name of entries) {
114744
115488
  if (!name.endsWith(".jsonl")) continue;
114745
115489
  const id2 = name.replace(/\.jsonl$/, "");
114746
- const info = await inspectSession(path44.join(getSessionsDir(), name), id2);
115490
+ const info = await inspectSession(path45.join(getSessionsDir(), name), id2);
114747
115491
  if (info) infos.push(info);
114748
115492
  }
114749
115493
  infos.sort((a, b) => b.lastModified - a.lastModified);
@@ -114754,7 +115498,7 @@ async function getMostRecent() {
114754
115498
  return all[0] ?? null;
114755
115499
  }
114756
115500
  async function getSessionById(id2) {
114757
- const filePath = path44.join(getSessionsDir(), `${id2}.jsonl`);
115501
+ const filePath = path45.join(getSessionsDir(), `${id2}.jsonl`);
114758
115502
  return inspectSession(filePath, id2);
114759
115503
  }
114760
115504
 
@@ -115573,6 +116317,7 @@ export {
115573
116317
  MessageResponse,
115574
116318
  ToolExecution,
115575
116319
  ToolGroupExecution,
116320
+ discoverProjects,
115576
116321
  bossToolGroupRenderers,
115577
116322
  useBossState,
115578
116323
  subscribeToBossStore,
@@ -115708,4 +116453,4 @@ react/cjs/react-jsx-runtime.development.js:
115708
116453
  * LICENSE file in the root directory of this source tree.
115709
116454
  *)
115710
116455
  */
115711
- //# sourceMappingURL=chunk-EV37X3XL.js.map
116456
+ //# sourceMappingURL=chunk-UH3DA72U.js.map