@fangyb/ahchat-bridge 0.1.41 → 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cli.cjs +785 -484
  2. package/dist/index.js +653 -352
  3. package/package.json +12 -12
package/dist/cli.cjs CHANGED
@@ -269,7 +269,7 @@ var require_errorUtils = __commonJS({
269
269
  var WARNING_MESSAGES = {
270
270
  [types_js_1.OfficeWarningType.PERFORMANCE_TIP]: (tip) => `\u26A1\uFE0F Performance Tip: ${tip}`,
271
271
  [types_js_1.OfficeWarningType.OCR_FAILED]: (name) => `OCR failed for ${name}:`,
272
- [types_js_1.OfficeWarningType.CHART_DATA_EXTRACTION_FAILED]: (path36) => `Failed to extract chart data from ${path36}:`,
272
+ [types_js_1.OfficeWarningType.CHART_DATA_EXTRACTION_FAILED]: (path37) => `Failed to extract chart data from ${path37}:`,
273
273
  [types_js_1.OfficeWarningType.PDF_WORKER_FALLBACK]: `Could not auto-resolve local worker path, falling back to CDN:`,
274
274
  [types_js_1.OfficeWarningType.ATTACHMENT_EXTRACTION_FAILED]: `Error extracting embedded attachments:`,
275
275
  [types_js_1.OfficeWarningType.PAGE_LOAD_FAILED]: (page) => `Error loading page ${page}:`,
@@ -14008,11 +14008,11 @@ var require_defaultOptions2 = __commonJS({
14008
14008
  "../../node_modules/.pnpm/tesseract.js@7.0.0/node_modules/tesseract.js/src/worker/node/defaultOptions.js"(exports2, module2) {
14009
14009
  "use strict";
14010
14010
  init_cjs_shims();
14011
- var path36 = require("path");
14011
+ var path37 = require("path");
14012
14012
  var defaultOptions = require_defaultOptions();
14013
14013
  module2.exports = {
14014
14014
  ...defaultOptions,
14015
- workerPath: path36.join(__dirname, "..", "..", "worker-script", "node", "index.js")
14015
+ workerPath: path37.join(__dirname, "..", "..", "worker-script", "node", "index.js")
14016
14016
  };
14017
14017
  }
14018
14018
  });
@@ -14796,14 +14796,14 @@ var require_url_state_machine = __commonJS({
14796
14796
  return url2.replace(/\u0009|\u000A|\u000D/g, "");
14797
14797
  }
14798
14798
  function shortenPath(url2) {
14799
- const path36 = url2.path;
14800
- if (path36.length === 0) {
14799
+ const path37 = url2.path;
14800
+ if (path37.length === 0) {
14801
14801
  return;
14802
14802
  }
14803
- if (url2.scheme === "file" && path36.length === 1 && isNormalizedWindowsDriveLetter(path36[0])) {
14803
+ if (url2.scheme === "file" && path37.length === 1 && isNormalizedWindowsDriveLetter(path37[0])) {
14804
14804
  return;
14805
14805
  }
14806
- path36.pop();
14806
+ path37.pop();
14807
14807
  }
14808
14808
  function includesCredentials(url2) {
14809
14809
  return url2.username !== "" || url2.password !== "";
@@ -17109,10 +17109,10 @@ var require_loadImage = __commonJS({
17109
17109
  "use strict";
17110
17110
  init_cjs_shims();
17111
17111
  var util = require("util");
17112
- var fs26 = require("fs");
17112
+ var fs27 = require("fs");
17113
17113
  var fetch3 = global.fetch || (init_lib(), __toCommonJS(lib_exports));
17114
17114
  var isURL = require_is_url();
17115
- var readFile3 = util.promisify(fs26.readFile);
17115
+ var readFile3 = util.promisify(fs27.readFile);
17116
17116
  module2.exports = async (image) => {
17117
17117
  let data = image;
17118
17118
  if (typeof image === "undefined") {
@@ -17220,20 +17220,20 @@ var require_createWorker = __commonJS({
17220
17220
  action: "load",
17221
17221
  payload: { options: { lstmOnly: lstmOnlyCore, corePath: options.corePath, logging: options.logging } }
17222
17222
  }));
17223
- const writeText = (path36, text, jobId) => startJob(createJob({
17223
+ const writeText = (path37, text, jobId) => startJob(createJob({
17224
17224
  id: jobId,
17225
17225
  action: "FS",
17226
- payload: { method: "writeFile", args: [path36, text] }
17226
+ payload: { method: "writeFile", args: [path37, text] }
17227
17227
  }));
17228
- const readText = (path36, jobId) => startJob(createJob({
17228
+ const readText = (path37, jobId) => startJob(createJob({
17229
17229
  id: jobId,
17230
17230
  action: "FS",
17231
- payload: { method: "readFile", args: [path36, { encoding: "utf8" }] }
17231
+ payload: { method: "readFile", args: [path37, { encoding: "utf8" }] }
17232
17232
  }));
17233
- const removeFile = (path36, jobId) => startJob(createJob({
17233
+ const removeFile = (path37, jobId) => startJob(createJob({
17234
17234
  id: jobId,
17235
17235
  action: "FS",
17236
- payload: { method: "unlink", args: [path36] }
17236
+ payload: { method: "unlink", args: [path37] }
17237
17237
  }));
17238
17238
  const FS = (method, args, jobId) => startJob(createJob({
17239
17239
  id: jobId,
@@ -17895,8 +17895,8 @@ var require_zipUtils = __commonJS({
17895
17895
  (0, fflate_1.unzip)(new Uint8Array(zipInput.buffer, zipInput.byteOffset, zipInput.byteLength), { filter: (file2) => filterFn(file2.name) }, (err, decompressed) => {
17896
17896
  if (err)
17897
17897
  return reject(err);
17898
- resolve(Object.entries(decompressed).map(([path36, data]) => ({
17899
- path: path36,
17898
+ resolve(Object.entries(decompressed).map(([path37, data]) => ({
17899
+ path: path37,
17900
17900
  content: Buffer.from(data)
17901
17901
  })));
17902
17902
  });
@@ -24266,8 +24266,8 @@ async function fileTypeFromTokenizer(tokenizer, options) {
24266
24266
  async function fileTypeStream(webStream, options) {
24267
24267
  return new FileTypeParser(options).toDetectionStream(webStream, options);
24268
24268
  }
24269
- async function fileTypeFromFile(path36, options) {
24270
- return new FileTypeParser(options).fromFile(path36);
24269
+ async function fileTypeFromFile(path37, options) {
24270
+ return new FileTypeParser(options).fromFile(path37);
24271
24271
  }
24272
24272
  var reasonableDetectionSizeInBytes, maximumMpegOffsetTolerance, maximumNestedGzipDetectionSizeInBytes, maximumNestedGzipProbeDepth, unknownSizeGzipProbeTimeoutInMilliseconds, maximumId3HeaderSizeInBytes, maximumTiffTagCount, maximumDetectionReentryCount, maximumTiffStreamIfdOffsetInBytes, maximumTiffIfdOffsetInBytes, FileTypeParser, supportedExtensions, supportedMimeTypes;
24273
24273
  var init_source = __esm({
@@ -24371,13 +24371,13 @@ var init_source = __esm({
24371
24371
  const tokenizer = this.createTokenizerFromWebStream(stream);
24372
24372
  return this.fromTokenizer(tokenizer);
24373
24373
  }
24374
- async fromFile(path36) {
24374
+ async fromFile(path37) {
24375
24375
  this.options.signal?.throwIfAborted();
24376
24376
  const [{ default: fsPromises }, { FileTokenizer }] = await Promise.all([
24377
24377
  importAtRuntime("node:fs/promises"),
24378
24378
  importAtRuntime("strtok3")
24379
24379
  ]);
24380
- const fileHandle = await fsPromises.open(path36, fsPromises.constants.O_RDONLY | fsPromises.constants.O_NONBLOCK);
24380
+ const fileHandle = await fsPromises.open(path37, fsPromises.constants.O_RDONLY | fsPromises.constants.O_NONBLOCK);
24381
24381
  const fileStat = await fileHandle.stat();
24382
24382
  if (!fileStat.isFile()) {
24383
24383
  await fileHandle.close();
@@ -24385,7 +24385,7 @@ var init_source = __esm({
24385
24385
  }
24386
24386
  const tokenizer = new FileTokenizer(fileHandle, {
24387
24387
  ...this.getTokenizerOptions(),
24388
- fileInfo: { path: path36, size: fileStat.size }
24388
+ fileInfo: { path: path37, size: fileStat.size }
24389
24389
  });
24390
24390
  return this.fromTokenizer(tokenizer);
24391
24391
  }
@@ -26267,33 +26267,33 @@ function renderRichText({
26267
26267
  container.append(fragment);
26268
26268
  }
26269
26269
  function makePathFromDrawOPS(data) {
26270
- const path36 = new Path2D();
26270
+ const path37 = new Path2D();
26271
26271
  if (!data) {
26272
- return path36;
26272
+ return path37;
26273
26273
  }
26274
26274
  for (let i = 0, ii = data.length; i < ii; ) {
26275
26275
  switch (data[i++]) {
26276
26276
  case DrawOPS.moveTo:
26277
- path36.moveTo(data[i++], data[i++]);
26277
+ path37.moveTo(data[i++], data[i++]);
26278
26278
  break;
26279
26279
  case DrawOPS.lineTo:
26280
- path36.lineTo(data[i++], data[i++]);
26280
+ path37.lineTo(data[i++], data[i++]);
26281
26281
  break;
26282
26282
  case DrawOPS.curveTo:
26283
- path36.bezierCurveTo(data[i++], data[i++], data[i++], data[i++], data[i++], data[i++]);
26283
+ path37.bezierCurveTo(data[i++], data[i++], data[i++], data[i++], data[i++], data[i++]);
26284
26284
  break;
26285
26285
  case DrawOPS.quadraticCurveTo:
26286
- path36.quadraticCurveTo(data[i++], data[i++], data[i++], data[i++]);
26286
+ path37.quadraticCurveTo(data[i++], data[i++], data[i++], data[i++]);
26287
26287
  break;
26288
26288
  case DrawOPS.closePath:
26289
- path36.closePath();
26289
+ path37.closePath();
26290
26290
  break;
26291
26291
  default:
26292
26292
  warn(`Unrecognized drawing path operator: ${data[i - 1]}`);
26293
26293
  break;
26294
26294
  }
26295
26295
  }
26296
- return path36;
26296
+ return path37;
26297
26297
  }
26298
26298
  function bindEvents(obj, element, names) {
26299
26299
  for (const name of names) {
@@ -26373,8 +26373,8 @@ function wrapReason(ex) {
26373
26373
  return new UnknownErrorException(ex.message, ex.toString());
26374
26374
  }
26375
26375
  async function node_utils_fetchData(url2) {
26376
- const fs26 = process.getBuiltinModule("fs");
26377
- const data = await fs26.promises.readFile(url2);
26376
+ const fs27 = process.getBuiltinModule("fs");
26377
+ const data = await fs27.promises.readFile(url2);
26378
26378
  return new Uint8Array(data);
26379
26379
  }
26380
26380
  function initWebGPUMesh() {
@@ -34466,11 +34466,11 @@ var init_pdf = __esm({
34466
34466
  } catch (ex) {
34467
34467
  warn(`getPathGenerator - ignoring character: "${ex}".`);
34468
34468
  }
34469
- const path36 = makePathFromDrawOPS(cmds?.path);
34469
+ const path37 = makePathFromDrawOPS(cmds?.path);
34470
34470
  if (!this.fontExtraProperties) {
34471
34471
  objs.delete(objId);
34472
34472
  }
34473
- return this.compiledGlyphs[character] = path36;
34473
+ return this.compiledGlyphs[character] = path37;
34474
34474
  }
34475
34475
  get black() {
34476
34476
  return this.#fontData.black;
@@ -37112,27 +37112,27 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37112
37112
  this._cachedGetSinglePixelWidth = null;
37113
37113
  }
37114
37114
  constructPath(opIdx, op, data, minMax) {
37115
- let [path36] = data;
37115
+ let [path37] = data;
37116
37116
  if (!minMax) {
37117
- path36 ||= data[0] = new Path2D();
37118
- this[op](opIdx, path36);
37117
+ path37 ||= data[0] = new Path2D();
37118
+ this[op](opIdx, path37);
37119
37119
  return;
37120
37120
  }
37121
37121
  if (this.dependencyTracker !== null) {
37122
37122
  const outerExtraSize = op === OPS.stroke ? this.current.lineWidth / 2 : 0;
37123
37123
  this.dependencyTracker.resetBBox(opIdx).recordBBox(opIdx, this.ctx, minMax[0] - outerExtraSize, minMax[2] + outerExtraSize, minMax[1] - outerExtraSize, minMax[3] + outerExtraSize).recordDependencies(opIdx, ["transform"]);
37124
37124
  }
37125
- if (!(path36 instanceof Path2D)) {
37126
- path36 = data[0] = makePathFromDrawOPS(path36);
37125
+ if (!(path37 instanceof Path2D)) {
37126
+ path37 = data[0] = makePathFromDrawOPS(path37);
37127
37127
  }
37128
37128
  Util.axialAlignedBoundingBox(minMax, getCurrentTransform(this.ctx), this.current.minMax);
37129
- this[op](opIdx, path36);
37129
+ this[op](opIdx, path37);
37130
37130
  this._pathStartIdx = opIdx;
37131
37131
  }
37132
37132
  closePath(opIdx) {
37133
37133
  this.ctx.closePath();
37134
37134
  }
37135
- stroke(opIdx, path36, consumePath = true) {
37135
+ stroke(opIdx, path37, consumePath = true) {
37136
37136
  const ctx = this.ctx;
37137
37137
  const strokeColor = this.current.strokeColor;
37138
37138
  ctx.globalAlpha = this.current.strokeAlpha;
@@ -37143,25 +37143,25 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37143
37143
  ctx.strokeStyle = strokeColor.getPattern(ctx, this, getCurrentTransformInverse(ctx), PathType.STROKE, opIdx);
37144
37144
  if (baseTransform) {
37145
37145
  const newPath = new Path2D();
37146
- newPath.addPath(path36, ctx.getTransform().invertSelf().multiplySelf(baseTransform));
37147
- path36 = newPath;
37146
+ newPath.addPath(path37, ctx.getTransform().invertSelf().multiplySelf(baseTransform));
37147
+ path37 = newPath;
37148
37148
  }
37149
- this.rescaleAndStroke(path36, false);
37149
+ this.rescaleAndStroke(path37, false);
37150
37150
  ctx.restore();
37151
37151
  } else {
37152
- this.rescaleAndStroke(path36, true);
37152
+ this.rescaleAndStroke(path37, true);
37153
37153
  }
37154
37154
  }
37155
37155
  this.dependencyTracker?.recordDependencies(opIdx, Dependencies.stroke);
37156
37156
  if (consumePath) {
37157
- this.consumePath(opIdx, path36, this.current.getClippedPathBoundingBox(PathType.STROKE, getCurrentTransform(this.ctx)));
37157
+ this.consumePath(opIdx, path37, this.current.getClippedPathBoundingBox(PathType.STROKE, getCurrentTransform(this.ctx)));
37158
37158
  }
37159
37159
  ctx.globalAlpha = this.current.fillAlpha;
37160
37160
  }
37161
- closeStroke(opIdx, path36) {
37162
- this.stroke(opIdx, path36);
37161
+ closeStroke(opIdx, path37) {
37162
+ this.stroke(opIdx, path37);
37163
37163
  }
37164
- fill(opIdx, path36, consumePath = true) {
37164
+ fill(opIdx, path37, consumePath = true) {
37165
37165
  const ctx = this.ctx;
37166
37166
  const fillColor = this.current.fillColor;
37167
37167
  const isPatternFill = this.current.patternFill;
@@ -37173,18 +37173,18 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37173
37173
  ctx.fillStyle = fillColor.getPattern(ctx, this, getCurrentTransformInverse(ctx), PathType.FILL, opIdx);
37174
37174
  if (baseTransform) {
37175
37175
  const newPath = new Path2D();
37176
- newPath.addPath(path36, ctx.getTransform().invertSelf().multiplySelf(baseTransform));
37177
- path36 = newPath;
37176
+ newPath.addPath(path37, ctx.getTransform().invertSelf().multiplySelf(baseTransform));
37177
+ path37 = newPath;
37178
37178
  }
37179
37179
  needRestore = true;
37180
37180
  }
37181
37181
  const intersect = this.current.getClippedPathBoundingBox();
37182
37182
  if (this.contentVisible && intersect !== null) {
37183
37183
  if (this.pendingEOFill) {
37184
- ctx.fill(path36, "evenodd");
37184
+ ctx.fill(path37, "evenodd");
37185
37185
  this.pendingEOFill = false;
37186
37186
  } else {
37187
- ctx.fill(path36);
37187
+ ctx.fill(path37);
37188
37188
  }
37189
37189
  }
37190
37190
  this.dependencyTracker?.recordDependencies(opIdx, Dependencies.fill);
@@ -37193,34 +37193,34 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37193
37193
  this.dependencyTracker?.restore(opIdx);
37194
37194
  }
37195
37195
  if (consumePath) {
37196
- this.consumePath(opIdx, path36, intersect);
37196
+ this.consumePath(opIdx, path37, intersect);
37197
37197
  }
37198
37198
  }
37199
- eoFill(opIdx, path36) {
37199
+ eoFill(opIdx, path37) {
37200
37200
  this.pendingEOFill = true;
37201
- this.fill(opIdx, path36);
37201
+ this.fill(opIdx, path37);
37202
37202
  }
37203
- fillStroke(opIdx, path36) {
37204
- this.fill(opIdx, path36, false);
37205
- this.stroke(opIdx, path36, false);
37206
- this.consumePath(opIdx, path36);
37203
+ fillStroke(opIdx, path37) {
37204
+ this.fill(opIdx, path37, false);
37205
+ this.stroke(opIdx, path37, false);
37206
+ this.consumePath(opIdx, path37);
37207
37207
  }
37208
- eoFillStroke(opIdx, path36) {
37208
+ eoFillStroke(opIdx, path37) {
37209
37209
  this.pendingEOFill = true;
37210
- this.fillStroke(opIdx, path36);
37210
+ this.fillStroke(opIdx, path37);
37211
37211
  }
37212
- closeFillStroke(opIdx, path36) {
37213
- this.fillStroke(opIdx, path36);
37212
+ closeFillStroke(opIdx, path37) {
37213
+ this.fillStroke(opIdx, path37);
37214
37214
  }
37215
- closeEOFillStroke(opIdx, path36) {
37215
+ closeEOFillStroke(opIdx, path37) {
37216
37216
  this.pendingEOFill = true;
37217
- this.fillStroke(opIdx, path36);
37217
+ this.fillStroke(opIdx, path37);
37218
37218
  }
37219
- endPath(opIdx, path36) {
37220
- this.consumePath(opIdx, path36);
37219
+ endPath(opIdx, path37) {
37220
+ this.consumePath(opIdx, path37);
37221
37221
  }
37222
- rawFillPath(opIdx, path36) {
37223
- this.ctx.fill(path36);
37222
+ rawFillPath(opIdx, path37) {
37223
+ this.ctx.fill(path37);
37224
37224
  this.dependencyTracker?.recordDependencies(opIdx, Dependencies.rawFillPath).recordOperation(opIdx);
37225
37225
  }
37226
37226
  clip(opIdx) {
@@ -37258,12 +37258,12 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37258
37258
  x,
37259
37259
  y,
37260
37260
  fontSize,
37261
- path: path36
37261
+ path: path37
37262
37262
  } of paths) {
37263
- if (!path36) {
37263
+ if (!path37) {
37264
37264
  continue;
37265
37265
  }
37266
- newPath.addPath(path36, new DOMMatrix(transform2).preMultiplySelf(invTransf).translate(x, y).scale(fontSize, -fontSize));
37266
+ newPath.addPath(path37, new DOMMatrix(transform2).preMultiplySelf(invTransf).translate(x, y).scale(fontSize, -fontSize));
37267
37267
  }
37268
37268
  ctx.clip(newPath);
37269
37269
  }
@@ -37356,9 +37356,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37356
37356
  this.moveText(opIdx, 0, this.current.leading);
37357
37357
  this.dependencyTracker?.recordIncrementalData("moveText", this.dependencyTracker.getSimpleIndex("leading") ?? opIdx);
37358
37358
  }
37359
- #getScaledPath(path36, currentTransform, transform2) {
37359
+ #getScaledPath(path37, currentTransform, transform2) {
37360
37360
  const newPath = new Path2D();
37361
- newPath.addPath(path36, new DOMMatrix(transform2).invertSelf().multiplySelf(currentTransform));
37361
+ newPath.addPath(path37, new DOMMatrix(transform2).invertSelf().multiplySelf(currentTransform));
37362
37362
  return newPath;
37363
37363
  }
37364
37364
  paintChar(opIdx, character, x, y, patternFillTransform, patternStrokeTransform) {
@@ -37371,11 +37371,11 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37371
37371
  const isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
37372
37372
  const patternFill = current.patternFill && !font.missingFile;
37373
37373
  const patternStroke = current.patternStroke && !font.missingFile;
37374
- let path36;
37374
+ let path37;
37375
37375
  if ((font.disableFontFace || isAddToPathSet || patternFill || patternStroke) && !font.missingFile) {
37376
- path36 = font.getPathGenerator(this.commonObjs, character);
37376
+ path37 = font.getPathGenerator(this.commonObjs, character);
37377
37377
  }
37378
- if (path36 && (font.disableFontFace || patternFill || patternStroke)) {
37378
+ if (path37 && (font.disableFontFace || patternFill || patternStroke)) {
37379
37379
  ctx.save();
37380
37380
  ctx.translate(x, y);
37381
37381
  ctx.scale(fontSize, -fontSize);
@@ -37385,10 +37385,10 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37385
37385
  if (patternFillTransform) {
37386
37386
  currentTransform = ctx.getTransform();
37387
37387
  ctx.setTransform(...patternFillTransform);
37388
- const scaledPath = this.#getScaledPath(path36, currentTransform, patternFillTransform);
37388
+ const scaledPath = this.#getScaledPath(path37, currentTransform, patternFillTransform);
37389
37389
  ctx.fill(scaledPath);
37390
37390
  } else {
37391
- ctx.fill(path36);
37391
+ ctx.fill(path37);
37392
37392
  }
37393
37393
  }
37394
37394
  if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
@@ -37405,10 +37405,10 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37405
37405
  const transf = Util.transform([a, b, c, d, 0, 0], invPatternTransform);
37406
37406
  Util.singularValueDecompose2dScale(transf, XY);
37407
37407
  ctx.lineWidth *= Math.max(XY[0], XY[1]) / fontSize;
37408
- ctx.stroke(this.#getScaledPath(path36, currentTransform, patternStrokeTransform));
37408
+ ctx.stroke(this.#getScaledPath(path37, currentTransform, patternStrokeTransform));
37409
37409
  } else {
37410
37410
  ctx.lineWidth /= fontSize;
37411
- ctx.stroke(path36);
37411
+ ctx.stroke(path37);
37412
37412
  }
37413
37413
  }
37414
37414
  ctx.restore();
@@ -37431,7 +37431,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37431
37431
  x,
37432
37432
  y,
37433
37433
  fontSize,
37434
- path: path36
37434
+ path: path37
37435
37435
  });
37436
37436
  this.dependencyTracker?.recordCharacterBBox(opIdx, ctx, font, fontSize, x, y);
37437
37437
  }
@@ -37844,9 +37844,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
37844
37844
  const [x0, y0, x1, y1] = group.bbox;
37845
37845
  clip.rect(x0, y0, x1 - x0, y1 - y0);
37846
37846
  if (group.matrix) {
37847
- const path36 = new Path2D();
37848
- path36.addPath(clip, new DOMMatrix(group.matrix));
37849
- clip = path36;
37847
+ const path37 = new Path2D();
37848
+ path37.addPath(clip, new DOMMatrix(group.matrix));
37849
+ clip = path37;
37850
37850
  }
37851
37851
  groupCtx.clip(clip);
37852
37852
  }
@@ -38224,7 +38224,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
38224
38224
  }
38225
38225
  endCompat(opIdx) {
38226
38226
  }
38227
- consumePath(opIdx, path36, clipBox) {
38227
+ consumePath(opIdx, path37, clipBox) {
38228
38228
  const isEmpty = this.current.isEmptyClip();
38229
38229
  if (this.pendingClip) {
38230
38230
  this.current.updateClipFromPath();
@@ -38236,9 +38236,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
38236
38236
  if (this.pendingClip) {
38237
38237
  if (!isEmpty) {
38238
38238
  if (this.pendingClip === EO_CLIP) {
38239
- ctx.clip(path36, "evenodd");
38239
+ ctx.clip(path37, "evenodd");
38240
38240
  } else {
38241
- ctx.clip(path36);
38241
+ ctx.clip(path37);
38242
38242
  }
38243
38243
  }
38244
38244
  this.pendingClip = null;
@@ -38311,7 +38311,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
38311
38311
  }
38312
38312
  return this._cachedScaleForStroking;
38313
38313
  }
38314
- rescaleAndStroke(path36, saveRestore) {
38314
+ rescaleAndStroke(path37, saveRestore) {
38315
38315
  const {
38316
38316
  ctx,
38317
38317
  current: {
@@ -38321,7 +38321,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
38321
38321
  const [scaleX, scaleY] = this.getScaleForStroking();
38322
38322
  if (scaleX === scaleY) {
38323
38323
  ctx.lineWidth = (lineWidth || 1) * scaleX;
38324
- ctx.stroke(path36);
38324
+ ctx.stroke(path37);
38325
38325
  return;
38326
38326
  }
38327
38327
  const dashes = ctx.getLineDash();
@@ -38332,7 +38332,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
38332
38332
  SCALE_MATRIX.a = 1 / scaleX;
38333
38333
  SCALE_MATRIX.d = 1 / scaleY;
38334
38334
  const newPath = new Path2D();
38335
- newPath.addPath(path36, SCALE_MATRIX);
38335
+ newPath.addPath(path37, SCALE_MATRIX);
38336
38336
  if (dashes.length > 0) {
38337
38337
  const scale = Math.max(scaleX, scaleY);
38338
38338
  ctx.setLineDash(dashes.map((x) => x / scale));
@@ -39057,9 +39057,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
39057
39057
  url: url2
39058
39058
  } = stream._source;
39059
39059
  this._isStreamingSupported = !disableStream;
39060
- const fs26 = process.getBuiltinModule("fs");
39061
- fs26.promises.lstat(url2).then((stat3) => {
39062
- const readStream = fs26.createReadStream(url2);
39060
+ const fs27 = process.getBuiltinModule("fs");
39061
+ fs27.promises.lstat(url2).then((stat3) => {
39062
+ const readStream = fs27.createReadStream(url2);
39063
39063
  const readableStream = getReadableStream(readStream);
39064
39064
  this._reader = readableStream.getReader();
39065
39065
  const {
@@ -39109,9 +39109,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
39109
39109
  const {
39110
39110
  url: url2
39111
39111
  } = stream._source;
39112
- const fs26 = process.getBuiltinModule("fs");
39112
+ const fs27 = process.getBuiltinModule("fs");
39113
39113
  try {
39114
- const readStream = fs26.createReadStream(url2, {
39114
+ const readStream = fs27.createReadStream(url2, {
39115
39115
  start: begin,
39116
39116
  end: end - 1
39117
39117
  });
@@ -49140,11 +49140,11 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
49140
49140
  };
49141
49141
  ContourDrawOutline = class extends InkDrawOutline {
49142
49142
  toSVGPath() {
49143
- let path36 = super.toSVGPath();
49144
- if (!path36.endsWith("Z")) {
49145
- path36 += "Z";
49143
+ let path37 = super.toSVGPath();
49144
+ if (!path37.endsWith("Z")) {
49145
+ path37 += "Z";
49146
49146
  }
49147
- return path36;
49147
+ return path37;
49148
49148
  }
49149
49149
  };
49150
49150
  BASE_HEADER_LENGTH = 8;
@@ -51614,13 +51614,13 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
51614
51614
  const root = this.#createSVG();
51615
51615
  const defs = _DrawLayer._svgFactory.createElement("defs");
51616
51616
  root.append(defs);
51617
- const path36 = _DrawLayer._svgFactory.createElement("path");
51618
- defs.append(path36);
51617
+ const path37 = _DrawLayer._svgFactory.createElement("path");
51618
+ defs.append(path37);
51619
51619
  const pathId = `path_${id}`;
51620
- path36.setAttribute("id", pathId);
51621
- path36.setAttribute("vector-effect", "non-scaling-stroke");
51620
+ path37.setAttribute("id", pathId);
51621
+ path37.setAttribute("vector-effect", "non-scaling-stroke");
51622
51622
  if (isPathUpdatable) {
51623
- this.#toUpdate.set(id, path36);
51623
+ this.#toUpdate.set(id, path37);
51624
51624
  }
51625
51625
  const clipPathId = hasClip ? this.#createClipPath(defs, pathId) : null;
51626
51626
  const use = _DrawLayer._svgFactory.createElement("use");
@@ -51638,11 +51638,11 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
51638
51638
  const root = this.#createSVG();
51639
51639
  const defs = _DrawLayer._svgFactory.createElement("defs");
51640
51640
  root.append(defs);
51641
- const path36 = _DrawLayer._svgFactory.createElement("path");
51642
- defs.append(path36);
51641
+ const path37 = _DrawLayer._svgFactory.createElement("path");
51642
+ defs.append(path37);
51643
51643
  const pathId = `path_${id}`;
51644
- path36.setAttribute("id", pathId);
51645
- path36.setAttribute("vector-effect", "non-scaling-stroke");
51644
+ path37.setAttribute("id", pathId);
51645
+ path37.setAttribute("vector-effect", "non-scaling-stroke");
51646
51646
  let maskId;
51647
51647
  if (mustRemoveSelfIntersections) {
51648
51648
  const mask = _DrawLayer._svgFactory.createElement("mask");
@@ -51689,7 +51689,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
51689
51689
  root,
51690
51690
  bbox,
51691
51691
  rootClass,
51692
- path: path36
51692
+ path: path37
51693
51693
  } = properties;
51694
51694
  const element = typeof elementOrId === "number" ? this.#mapping.get(elementOrId) : elementOrId;
51695
51695
  if (!element) {
@@ -51709,10 +51709,10 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
51709
51709
  classList.toggle(className, value);
51710
51710
  }
51711
51711
  }
51712
- if (path36) {
51712
+ if (path37) {
51713
51713
  const defs = element.firstElementChild;
51714
51714
  const pathElement = defs.firstElementChild;
51715
- this.#updateProperties(pathElement, path36);
51715
+ this.#updateProperties(pathElement, path37);
51716
51716
  }
51717
51717
  }
51718
51718
  updateParent(id, layer) {
@@ -55435,14 +55435,14 @@ var require_OfficeParser = __commonJS({
55435
55435
  } else if (typeof file2 === "string") {
55436
55436
  filePath = file2;
55437
55437
  (0, envUtils_js_1.assertNode)("path-parsing");
55438
- const fs26 = await import("fs");
55439
- if (!fs26.existsSync(file2)) {
55438
+ const fs27 = await import("fs");
55439
+ if (!fs27.existsSync(file2)) {
55440
55440
  throw (0, errorUtils_js_1.getOfficeError)(types_js_1.OfficeErrorType.FILE_DOES_NOT_EXIST, internalConfig, file2);
55441
55441
  }
55442
- if (fs26.lstatSync(file2).isDirectory()) {
55442
+ if (fs27.lstatSync(file2).isDirectory()) {
55443
55443
  throw (0, errorUtils_js_1.getOfficeError)(types_js_1.OfficeErrorType.LOCATION_NOT_FOUND, internalConfig, file2);
55444
55444
  }
55445
- buffer = fs26.readFileSync(file2);
55445
+ buffer = fs27.readFileSync(file2);
55446
55446
  ext = ext || file2.split(".").pop() || "";
55447
55447
  } else {
55448
55448
  throw (0, errorUtils_js_1.getOfficeError)(types_js_1.OfficeErrorType.INVALID_INPUT, internalConfig);
@@ -57093,8 +57093,8 @@ function dateNF_fix(str, dateNF, match) {
57093
57093
  if (Y == -1 && m == -1 && d == -1) return timestr;
57094
57094
  return datestr + "T" + timestr;
57095
57095
  }
57096
- function set_fs(fs26) {
57097
- _fs = fs26;
57096
+ function set_fs(fs27) {
57097
+ _fs = fs27;
57098
57098
  }
57099
57099
  function blobify(data) {
57100
57100
  if (typeof data === "string") return s2ab(data);
@@ -57158,11 +57158,11 @@ function write_dl(fname, payload, enc) {
57158
57158
  }
57159
57159
  throw new Error("cannot save file " + fname);
57160
57160
  }
57161
- function read_binary(path36) {
57162
- if (typeof _fs !== "undefined") return _fs.readFileSync(path36);
57163
- if (typeof Deno !== "undefined") return Deno.readFileSync(path36);
57161
+ function read_binary(path37) {
57162
+ if (typeof _fs !== "undefined") return _fs.readFileSync(path37);
57163
+ if (typeof Deno !== "undefined") return Deno.readFileSync(path37);
57164
57164
  if (typeof $ !== "undefined" && typeof File !== "undefined" && typeof Folder !== "undefined") try {
57165
- var infile = File(path36);
57165
+ var infile = File(path37);
57166
57166
  infile.open("r");
57167
57167
  infile.encoding = "binary";
57168
57168
  var data = infile.read();
@@ -57171,7 +57171,7 @@ function read_binary(path36) {
57171
57171
  } catch (e) {
57172
57172
  if (!e.message || !e.message.match(/onstruct/)) throw e;
57173
57173
  }
57174
- throw new Error("Cannot access file " + path36);
57174
+ throw new Error("Cannot access file " + path37);
57175
57175
  }
57176
57176
  function keys(o) {
57177
57177
  var ks = Object.keys(o), o2 = [];
@@ -57428,16 +57428,16 @@ function zipentries(zip) {
57428
57428
  for (var i = 0; i < k.length; ++i) if (k[i].slice(-1) != "/") o.push(k[i].replace(/^Root Entry[\/]/, ""));
57429
57429
  return o.sort();
57430
57430
  }
57431
- function zip_add_file(zip, path36, content) {
57431
+ function zip_add_file(zip, path37, content) {
57432
57432
  if (zip.FullPaths) {
57433
57433
  if (typeof content == "string") {
57434
57434
  var res;
57435
57435
  if (has_buf) res = Buffer_from(content);
57436
57436
  else res = utf8decode(content);
57437
- return CFB.utils.cfb_add(zip, path36, res);
57437
+ return CFB.utils.cfb_add(zip, path37, res);
57438
57438
  }
57439
- CFB.utils.cfb_add(zip, path36, content);
57440
- } else zip.file(path36, content);
57439
+ CFB.utils.cfb_add(zip, path37, content);
57440
+ } else zip.file(path37, content);
57441
57441
  }
57442
57442
  function zip_new() {
57443
57443
  return CFB.utils.cfb_new();
@@ -57454,11 +57454,11 @@ function zip_read(d, o) {
57454
57454
  }
57455
57455
  throw new Error("Unrecognized type " + o.type);
57456
57456
  }
57457
- function resolve_path(path36, base) {
57458
- if (path36.charAt(0) == "/") return path36.slice(1);
57457
+ function resolve_path(path37, base) {
57458
+ if (path37.charAt(0) == "/") return path37.slice(1);
57459
57459
  var result = base.split("/");
57460
57460
  if (base.slice(-1) != "/") result.pop();
57461
- var target = path36.split("/");
57461
+ var target = path37.split("/");
57462
57462
  while (target.length !== 0) {
57463
57463
  var step = target.shift();
57464
57464
  if (step === "..") result.pop();
@@ -72023,19 +72023,19 @@ function safe_parse_wbrels(wbrels, sheets) {
72023
72023
  }
72024
72024
  return !wbrels || wbrels.length === 0 ? null : wbrels;
72025
72025
  }
72026
- function safe_parse_sheet(zip, path36, relsPath, sheet, idx, sheetRels, sheets, stype, opts, wb, themes, styles3) {
72026
+ function safe_parse_sheet(zip, path37, relsPath, sheet, idx, sheetRels, sheets, stype, opts, wb, themes, styles3) {
72027
72027
  try {
72028
- sheetRels[sheet] = parse_rels(getzipstr(zip, relsPath, true), path36);
72029
- var data = getzipdata(zip, path36);
72028
+ sheetRels[sheet] = parse_rels(getzipstr(zip, relsPath, true), path37);
72029
+ var data = getzipdata(zip, path37);
72030
72030
  var _ws;
72031
72031
  switch (stype) {
72032
72032
  case "sheet":
72033
- _ws = parse_ws(data, path36, idx, opts, sheetRels[sheet], wb, themes, styles3);
72033
+ _ws = parse_ws(data, path37, idx, opts, sheetRels[sheet], wb, themes, styles3);
72034
72034
  break;
72035
72035
  case "chart":
72036
- _ws = parse_cs(data, path36, idx, opts, sheetRels[sheet], wb, themes, styles3);
72036
+ _ws = parse_cs(data, path37, idx, opts, sheetRels[sheet], wb, themes, styles3);
72037
72037
  if (!_ws || !_ws["!drawel"]) break;
72038
- var dfile = resolve_path(_ws["!drawel"].Target, path36);
72038
+ var dfile = resolve_path(_ws["!drawel"].Target, path37);
72039
72039
  var drelsp = get_rels_path(dfile);
72040
72040
  var draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));
72041
72041
  var chartp = resolve_path(draw, dfile);
@@ -72043,10 +72043,10 @@ function safe_parse_sheet(zip, path36, relsPath, sheet, idx, sheetRels, sheets,
72043
72043
  _ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);
72044
72044
  break;
72045
72045
  case "macro":
72046
- _ws = parse_ms(data, path36, idx, opts, sheetRels[sheet], wb, themes, styles3);
72046
+ _ws = parse_ms(data, path37, idx, opts, sheetRels[sheet], wb, themes, styles3);
72047
72047
  break;
72048
72048
  case "dialog":
72049
- _ws = parse_ds(data, path36, idx, opts, sheetRels[sheet], wb, themes, styles3);
72049
+ _ws = parse_ds(data, path37, idx, opts, sheetRels[sheet], wb, themes, styles3);
72050
72050
  break;
72051
72051
  default:
72052
72052
  throw new Error("Unrecognized sheet type " + stype);
@@ -72056,13 +72056,13 @@ function safe_parse_sheet(zip, path36, relsPath, sheet, idx, sheetRels, sheets,
72056
72056
  if (sheetRels && sheetRels[sheet]) keys(sheetRels[sheet]).forEach(function(n) {
72057
72057
  var dfile2 = "";
72058
72058
  if (sheetRels[sheet][n].Type == RELS.CMNT) {
72059
- dfile2 = resolve_path(sheetRels[sheet][n].Target, path36);
72059
+ dfile2 = resolve_path(sheetRels[sheet][n].Target, path37);
72060
72060
  var comments = parse_cmnt(getzipdata(zip, dfile2, true), dfile2, opts);
72061
72061
  if (!comments || !comments.length) return;
72062
72062
  sheet_insert_comments(_ws, comments, false);
72063
72063
  }
72064
72064
  if (sheetRels[sheet][n].Type == RELS.TCMNT) {
72065
- dfile2 = resolve_path(sheetRels[sheet][n].Target, path36);
72065
+ dfile2 = resolve_path(sheetRels[sheet][n].Target, path37);
72066
72066
  tcomments = tcomments.concat(parse_tcmnt_xml(getzipdata(zip, dfile2, true), opts));
72067
72067
  }
72068
72068
  });
@@ -72166,7 +72166,7 @@ function parse_zip(zip, opts) {
72166
72166
  if (opts.bookDeps && dir.calcchain) deps = parse_cc(getzipdata(zip, strip_front_slash(dir.calcchain)), dir.calcchain, opts);
72167
72167
  var i = 0;
72168
72168
  var sheetRels = {};
72169
- var path36, relsPath;
72169
+ var path37, relsPath;
72170
72170
  {
72171
72171
  var wbsheets = wb.Sheets;
72172
72172
  props.Worksheets = wbsheets.length;
@@ -72191,15 +72191,15 @@ function parse_zip(zip, opts) {
72191
72191
  wsloop: for (i = 0; i != props.Worksheets; ++i) {
72192
72192
  var stype = "sheet";
72193
72193
  if (wbrels && wbrels[i]) {
72194
- path36 = "xl/" + wbrels[i][1].replace(/[\/]?xl\//, "");
72195
- if (!safegetzipfile(zip, path36)) path36 = wbrels[i][1];
72196
- if (!safegetzipfile(zip, path36)) path36 = wbrelsfile.replace(/_rels\/.*$/, "") + wbrels[i][1];
72194
+ path37 = "xl/" + wbrels[i][1].replace(/[\/]?xl\//, "");
72195
+ if (!safegetzipfile(zip, path37)) path37 = wbrels[i][1];
72196
+ if (!safegetzipfile(zip, path37)) path37 = wbrelsfile.replace(/_rels\/.*$/, "") + wbrels[i][1];
72197
72197
  stype = wbrels[i][2];
72198
72198
  } else {
72199
- path36 = "xl/worksheets/sheet" + (i + 1 - nmode) + "." + wbext;
72200
- path36 = path36.replace(/sheet0\./, "sheet.");
72199
+ path37 = "xl/worksheets/sheet" + (i + 1 - nmode) + "." + wbext;
72200
+ path37 = path37.replace(/sheet0\./, "sheet.");
72201
72201
  }
72202
- relsPath = path36.replace(/^(.*)(\/)([^\/]*)$/, "$1/_rels/$3.rels");
72202
+ relsPath = path37.replace(/^(.*)(\/)([^\/]*)$/, "$1/_rels/$3.rels");
72203
72203
  if (opts && opts.sheets != null) switch (typeof opts.sheets) {
72204
72204
  case "number":
72205
72205
  if (i != opts.sheets) continue wsloop;
@@ -72217,7 +72217,7 @@ function parse_zip(zip, opts) {
72217
72217
  if (!snjseen) continue wsloop;
72218
72218
  }
72219
72219
  }
72220
- safe_parse_sheet(zip, path36, relsPath, props.SheetNames[i], i, sheetRels, sheets, stype, opts, wb, themes, styles3);
72220
+ safe_parse_sheet(zip, path37, relsPath, props.SheetNames[i], i, sheetRels, sheets, stype, opts, wb, themes, styles3);
72221
72221
  }
72222
72222
  out = {
72223
72223
  Directory: dir,
@@ -73114,7 +73114,7 @@ function sheet_to_json(sheet, opts) {
73114
73114
  out.length = outi;
73115
73115
  return out;
73116
73116
  }
73117
- function make_csv_row(sheet, r, R, cols, fs26, rs, FS, o) {
73117
+ function make_csv_row(sheet, r, R, cols, fs27, rs, FS, o) {
73118
73118
  var isempty = true;
73119
73119
  var row = [], txt = "", rr = encode_row(R);
73120
73120
  for (var C = r.s.c; C <= r.e.c; ++C) {
@@ -73124,7 +73124,7 @@ function make_csv_row(sheet, r, R, cols, fs26, rs, FS, o) {
73124
73124
  else if (val.v != null) {
73125
73125
  isempty = false;
73126
73126
  txt = "" + (o.rawNumbers && val.t == "n" ? val.v : format_cell(val, null, o));
73127
- for (var i = 0, cc = 0; i !== txt.length; ++i) if ((cc = txt.charCodeAt(i)) === fs26 || cc === rs || cc === 34 || o.forceQuotes) {
73127
+ for (var i = 0, cc = 0; i !== txt.length; ++i) if ((cc = txt.charCodeAt(i)) === fs27 || cc === rs || cc === 34 || o.forceQuotes) {
73128
73128
  txt = '"' + txt.replace(qreg, '""') + '"';
73129
73129
  break;
73130
73130
  }
@@ -73144,7 +73144,7 @@ function sheet_to_csv(sheet, opts) {
73144
73144
  var o = opts == null ? {} : opts;
73145
73145
  if (sheet == null || sheet["!ref"] == null) return "";
73146
73146
  var r = safe_decode_range(sheet["!ref"]);
73147
- var FS = o.FS !== void 0 ? o.FS : ",", fs26 = FS.charCodeAt(0);
73147
+ var FS = o.FS !== void 0 ? o.FS : ",", fs27 = FS.charCodeAt(0);
73148
73148
  var RS = o.RS !== void 0 ? o.RS : "\n", rs = RS.charCodeAt(0);
73149
73149
  var endregex = new RegExp((FS == "|" ? "\\|" : FS) + "+$");
73150
73150
  var row = "", cols = [];
@@ -73155,7 +73155,7 @@ function sheet_to_csv(sheet, opts) {
73155
73155
  var w = 0;
73156
73156
  for (var R = r.s.r; R <= r.e.r; ++R) {
73157
73157
  if ((rowinfo[R] || {}).hidden) continue;
73158
- row = make_csv_row(sheet, r, R, cols, fs26, rs, FS, o);
73158
+ row = make_csv_row(sheet, r, R, cols, fs27, rs, FS, o);
73159
73159
  if (row == null) {
73160
73160
  continue;
73161
73161
  }
@@ -73387,7 +73387,7 @@ function write_csv_stream(sheet, opts) {
73387
73387
  return stream;
73388
73388
  }
73389
73389
  var r = safe_decode_range(sheet["!ref"]);
73390
- var FS = o.FS !== void 0 ? o.FS : ",", fs26 = FS.charCodeAt(0);
73390
+ var FS = o.FS !== void 0 ? o.FS : ",", fs27 = FS.charCodeAt(0);
73391
73391
  var RS = o.RS !== void 0 ? o.RS : "\n", rs = RS.charCodeAt(0);
73392
73392
  var endregex = new RegExp((FS == "|" ? "\\|" : FS) + "+$");
73393
73393
  var row = "", cols = [];
@@ -73405,7 +73405,7 @@ function write_csv_stream(sheet, opts) {
73405
73405
  while (R <= r.e.r) {
73406
73406
  ++R;
73407
73407
  if ((rowinfo[R - 1] || {}).hidden) continue;
73408
- row = make_csv_row(sheet, r, R - 1, cols, fs26, rs, FS, o);
73408
+ row = make_csv_row(sheet, r, R - 1, cols, fs27, rs, FS, o);
73409
73409
  if (row != null) {
73410
73410
  if (o.strip) row = row.replace(endregex, "");
73411
73411
  if (row || o.blankrows !== false) return stream.push((w++ ? RS : "") + row);
@@ -74035,9 +74035,9 @@ var init_xlsx = __esm({
74035
74035
  }
74036
74036
  return o;
74037
74037
  }
74038
- var fs26;
74038
+ var fs27;
74039
74039
  function get_fs() {
74040
- return fs26 || (fs26 = {});
74040
+ return fs27 || (fs27 = {});
74041
74041
  }
74042
74042
  function parse3(file2, options) {
74043
74043
  if (file2[0] == 80 && file2[1] == 75) return parse_zip2(file2, options);
@@ -74320,7 +74320,7 @@ var init_xlsx = __esm({
74320
74320
  }
74321
74321
  function read_file(filename2, options) {
74322
74322
  get_fs();
74323
- return parse3(fs26.readFileSync(filename2), options);
74323
+ return parse3(fs27.readFileSync(filename2), options);
74324
74324
  }
74325
74325
  function read2(blob, options) {
74326
74326
  var type = options && options.type;
@@ -74601,7 +74601,7 @@ var init_xlsx = __esm({
74601
74601
  }
74602
74602
  return o;
74603
74603
  }
74604
- function find2(cfb, path36) {
74604
+ function find2(cfb, path37) {
74605
74605
  var UCFullPaths = cfb.FullPaths.map(function(x) {
74606
74606
  return x.toUpperCase();
74607
74607
  });
@@ -74610,11 +74610,11 @@ var init_xlsx = __esm({
74610
74610
  return y[y.length - (x.slice(-1) == "/" ? 2 : 1)];
74611
74611
  });
74612
74612
  var k = false;
74613
- if (path36.charCodeAt(0) === 47) {
74613
+ if (path37.charCodeAt(0) === 47) {
74614
74614
  k = true;
74615
- path36 = UCFullPaths[0].slice(0, -1) + path36;
74616
- } else k = path36.indexOf("/") !== -1;
74617
- var UCPath = path36.toUpperCase();
74615
+ path37 = UCFullPaths[0].slice(0, -1) + path37;
74616
+ } else k = path37.indexOf("/") !== -1;
74617
+ var UCPath = path37.toUpperCase();
74618
74618
  var w = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
74619
74619
  if (w !== -1) return cfb.FileIndex[w];
74620
74620
  var m = !UCPath.match(chr1);
@@ -74650,7 +74650,7 @@ var init_xlsx = __esm({
74650
74650
  function write_file(cfb, filename2, options) {
74651
74651
  get_fs();
74652
74652
  var o = _write(cfb, options);
74653
- fs26.writeFileSync(filename2, o);
74653
+ fs27.writeFileSync(filename2, o);
74654
74654
  }
74655
74655
  function a2s2(o) {
74656
74656
  var out = new Array(o.length);
@@ -74662,7 +74662,7 @@ var init_xlsx = __esm({
74662
74662
  switch (options && options.type || "buffer") {
74663
74663
  case "file":
74664
74664
  get_fs();
74665
- fs26.writeFileSync(options.filename, o);
74665
+ fs27.writeFileSync(options.filename, o);
74666
74666
  return o;
74667
74667
  case "binary":
74668
74668
  return typeof o == "string" ? o : a2s2(o);
@@ -91236,7 +91236,7 @@ var require_websocket_server = __commonJS({
91236
91236
 
91237
91237
  // src/cli.ts
91238
91238
  init_cjs_shims();
91239
- var import_node_path33 = __toESM(require("path"), 1);
91239
+ var import_node_path34 = __toESM(require("path"), 1);
91240
91240
  var import_node_fs19 = __toESM(require("fs"), 1);
91241
91241
 
91242
91242
  // ../../node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
@@ -92832,11 +92832,11 @@ var RotatingFileStream = class extends import_stream.Writable {
92832
92832
  timeout;
92833
92833
  timeoutPromise;
92834
92834
  constructor(generator, options) {
92835
- const { encoding, history, maxFiles, maxSize, path: path36 } = options;
92835
+ const { encoding, history, maxFiles, maxSize, path: path37 } = options;
92836
92836
  super({ decodeStrings: true, defaultEncoding: encoding });
92837
92837
  this.createGzip = import_zlib.createGzip;
92838
92838
  this.exec = import_child_process.exec;
92839
- this.filename = path36 + generator(null);
92839
+ this.filename = path37 + generator(null);
92840
92840
  this.fsCreateReadStream = import_fs.createReadStream;
92841
92841
  this.fsCreateWriteStream = import_fs.createWriteStream;
92842
92842
  this.fsOpen = import_promises.open;
@@ -92848,7 +92848,7 @@ var RotatingFileStream = class extends import_stream.Writable {
92848
92848
  this.options = options;
92849
92849
  this.stdout = process.stdout;
92850
92850
  if (maxFiles || maxSize)
92851
- options.history = path36 + (history ? history : this.generator(null) + ".txt");
92851
+ options.history = path37 + (history ? history : this.generator(null) + ".txt");
92852
92852
  this.on("close", () => this.finished ? null : this.emit("finish"));
92853
92853
  this.on("finish", () => this.finished = this.clear());
92854
92854
  (async () => {
@@ -92976,9 +92976,9 @@ var RotatingFileStream = class extends import_stream.Writable {
92976
92976
  return this.move();
92977
92977
  }
92978
92978
  async findName() {
92979
- const { interval, path: path36, intervalBoundary } = this.options;
92979
+ const { interval, path: path37, intervalBoundary } = this.options;
92980
92980
  for (let index = 1; index < 1e3; ++index) {
92981
- const filename = path36 + this.generator(interval && intervalBoundary ? new Date(this.prev) : this.rotation, index);
92981
+ const filename = path37 + this.generator(interval && intervalBoundary ? new Date(this.prev) : this.rotation, index);
92982
92982
  if (!await exists(filename))
92983
92983
  return filename;
92984
92984
  }
@@ -93008,11 +93008,11 @@ var RotatingFileStream = class extends import_stream.Writable {
93008
93008
  return this.unlink(filename);
93009
93009
  }
93010
93010
  async classical() {
93011
- const { compress, path: path36, rotate } = this.options;
93011
+ const { compress, path: path37, rotate } = this.options;
93012
93012
  let rotatedName = "";
93013
93013
  for (let count = rotate; count > 0; --count) {
93014
- const currName = path36 + this.generator(count);
93015
- const prevName = count === 1 ? this.filename : path36 + this.generator(count - 1);
93014
+ const currName = path37 + this.generator(count);
93015
+ const prevName = count === 1 ? this.filename : path37 + this.generator(count - 1);
93016
93016
  if (!await exists(prevName))
93017
93017
  continue;
93018
93018
  if (!rotatedName)
@@ -94007,7 +94007,7 @@ function logClaudeRuntimeResolution(resolution) {
94007
94007
  // src/start.ts
94008
94008
  init_cjs_shims();
94009
94009
  var import_node_os15 = __toESM(require("os"), 1);
94010
- var import_node_path31 = __toESM(require("path"), 1);
94010
+ var import_node_path32 = __toESM(require("path"), 1);
94011
94011
  var import_node_crypto6 = __toESM(require("crypto"), 1);
94012
94012
 
94013
94013
  // ../shared/src/index.ts
@@ -97174,14 +97174,14 @@ function agentIdArray(value) {
97174
97174
  function normalizeModelScopeSkill(value) {
97175
97175
  if (!isRecord2(value)) return null;
97176
97176
  const id = stringValue(value.id);
97177
- const path36 = stringValue(value.path);
97177
+ const path37 = stringValue(value.path);
97178
97178
  const name = stringValue(value.name);
97179
97179
  const displayName = stringValue(value.displayName, name);
97180
97180
  const url2 = stringValue(value.url);
97181
- if (!id || !path36 || !name || !displayName || !url2) return null;
97181
+ if (!id || !path37 || !name || !displayName || !url2) return null;
97182
97182
  return {
97183
97183
  id,
97184
- path: path36,
97184
+ path: path37,
97185
97185
  name,
97186
97186
  displayName,
97187
97187
  description: stringValue(value.description),
@@ -97528,9 +97528,9 @@ init_cjs_shims();
97528
97528
  var import_node_child_process3 = require("child_process");
97529
97529
  var import_node_crypto3 = require("crypto");
97530
97530
  var import_node_fs6 = __toESM(require("fs"), 1);
97531
- var import_promises3 = __toESM(require("fs/promises"), 1);
97531
+ var import_promises4 = __toESM(require("fs/promises"), 1);
97532
97532
  var import_node_os7 = __toESM(require("os"), 1);
97533
- var import_node_path13 = __toESM(require("path"), 1);
97533
+ var import_node_path14 = __toESM(require("path"), 1);
97534
97534
  var sdk2 = __toESM(require("@anthropic-ai/claude-agent-sdk"), 1);
97535
97535
 
97536
97536
  // src/attachmentAdapter.ts
@@ -98421,6 +98421,8 @@ var HttpMcpAuditClient = class {
98421
98421
 
98422
98422
  // src/neuralMcpServer.ts
98423
98423
  init_cjs_shims();
98424
+ var import_promises3 = __toESM(require("fs/promises"), 1);
98425
+ var import_node_path11 = __toESM(require("path"), 1);
98424
98426
  var sdk = __toESM(require("@anthropic-ai/claude-agent-sdk"), 1);
98425
98427
 
98426
98428
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/index.js
@@ -99202,10 +99204,10 @@ function mergeDefs(...defs) {
99202
99204
  function cloneDef(schema) {
99203
99205
  return mergeDefs(schema._zod.def);
99204
99206
  }
99205
- function getElementAtPath(obj, path36) {
99206
- if (!path36)
99207
+ function getElementAtPath(obj, path37) {
99208
+ if (!path37)
99207
99209
  return obj;
99208
- return path36.reduce((acc, key) => acc?.[key], obj);
99210
+ return path37.reduce((acc, key) => acc?.[key], obj);
99209
99211
  }
99210
99212
  function promiseAllObject(promisesObj) {
99211
99213
  const keys2 = Object.keys(promisesObj);
@@ -99614,11 +99616,11 @@ function explicitlyAborted(x, startIndex = 0) {
99614
99616
  }
99615
99617
  return false;
99616
99618
  }
99617
- function prefixIssues(path36, issues) {
99619
+ function prefixIssues(path37, issues) {
99618
99620
  return issues.map((iss) => {
99619
99621
  var _a3;
99620
99622
  (_a3 = iss).path ?? (_a3.path = []);
99621
- iss.path.unshift(path36);
99623
+ iss.path.unshift(path37);
99622
99624
  return iss;
99623
99625
  });
99624
99626
  }
@@ -99765,16 +99767,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
99765
99767
  }
99766
99768
  function formatError(error51, mapper = (issue2) => issue2.message) {
99767
99769
  const fieldErrors = { _errors: [] };
99768
- const processError = (error52, path36 = []) => {
99770
+ const processError = (error52, path37 = []) => {
99769
99771
  for (const issue2 of error52.issues) {
99770
99772
  if (issue2.code === "invalid_union" && issue2.errors.length) {
99771
- issue2.errors.map((issues) => processError({ issues }, [...path36, ...issue2.path]));
99773
+ issue2.errors.map((issues) => processError({ issues }, [...path37, ...issue2.path]));
99772
99774
  } else if (issue2.code === "invalid_key") {
99773
- processError({ issues: issue2.issues }, [...path36, ...issue2.path]);
99775
+ processError({ issues: issue2.issues }, [...path37, ...issue2.path]);
99774
99776
  } else if (issue2.code === "invalid_element") {
99775
- processError({ issues: issue2.issues }, [...path36, ...issue2.path]);
99777
+ processError({ issues: issue2.issues }, [...path37, ...issue2.path]);
99776
99778
  } else {
99777
- const fullpath = [...path36, ...issue2.path];
99779
+ const fullpath = [...path37, ...issue2.path];
99778
99780
  if (fullpath.length === 0) {
99779
99781
  fieldErrors._errors.push(mapper(issue2));
99780
99782
  } else {
@@ -99801,17 +99803,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
99801
99803
  }
99802
99804
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
99803
99805
  const result = { errors: [] };
99804
- const processError = (error52, path36 = []) => {
99806
+ const processError = (error52, path37 = []) => {
99805
99807
  var _a3, _b;
99806
99808
  for (const issue2 of error52.issues) {
99807
99809
  if (issue2.code === "invalid_union" && issue2.errors.length) {
99808
- issue2.errors.map((issues) => processError({ issues }, [...path36, ...issue2.path]));
99810
+ issue2.errors.map((issues) => processError({ issues }, [...path37, ...issue2.path]));
99809
99811
  } else if (issue2.code === "invalid_key") {
99810
- processError({ issues: issue2.issues }, [...path36, ...issue2.path]);
99812
+ processError({ issues: issue2.issues }, [...path37, ...issue2.path]);
99811
99813
  } else if (issue2.code === "invalid_element") {
99812
- processError({ issues: issue2.issues }, [...path36, ...issue2.path]);
99814
+ processError({ issues: issue2.issues }, [...path37, ...issue2.path]);
99813
99815
  } else {
99814
- const fullpath = [...path36, ...issue2.path];
99816
+ const fullpath = [...path37, ...issue2.path];
99815
99817
  if (fullpath.length === 0) {
99816
99818
  result.errors.push(mapper(issue2));
99817
99819
  continue;
@@ -99843,8 +99845,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
99843
99845
  }
99844
99846
  function toDotPath(_path) {
99845
99847
  const segs = [];
99846
- const path36 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
99847
- for (const seg of path36) {
99848
+ const path37 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
99849
+ for (const seg of path37) {
99848
99850
  if (typeof seg === "number")
99849
99851
  segs.push(`[${seg}]`);
99850
99852
  else if (typeof seg === "symbol")
@@ -112617,13 +112619,13 @@ function resolveRef(ref, ctx) {
112617
112619
  if (!ref.startsWith("#")) {
112618
112620
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
112619
112621
  }
112620
- const path36 = ref.slice(1).split("/").filter(Boolean);
112621
- if (path36.length === 0) {
112622
+ const path37 = ref.slice(1).split("/").filter(Boolean);
112623
+ if (path37.length === 0) {
112622
112624
  return ctx.rootSchema;
112623
112625
  }
112624
112626
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
112625
- if (path36[0] === defsKey) {
112626
- const key = path36[1];
112627
+ if (path37[0] === defsKey) {
112628
+ const key = path37[1];
112627
112629
  if (!key || !ctx.defs[key]) {
112628
112630
  throw new Error(`Reference not found: ${ref}`);
112629
112631
  }
@@ -113418,6 +113420,138 @@ function normalizeDocumentText(value) {
113418
113420
  var logger10 = createModuleLogger("neural.mcpServer");
113419
113421
  var VIDEO_GENERATION_SKILL_ID = OFFICIAL_MEDIA_SKILL_IDS[0];
113420
113422
  var AUTO_LOCAL_ENHANCER_LIMIT = 2;
113423
+ var WORKDIR_ATTACHMENT_MARKER_KIND = "ahchat_workdir_attachment";
113424
+ var WORKDIR_FIND_DEFAULT_MAX_RESULTS = 20;
113425
+ var WORKDIR_FIND_MAX_RESULTS = 50;
113426
+ var WORKDIR_FIND_MAX_SCANNED_FILES = 5e3;
113427
+ var WORKDIR_FIND_MAX_DEPTH = 8;
113428
+ var WORKDIR_FIND_SKIP_DIRS = /* @__PURE__ */ new Set([
113429
+ ".ahchat-attachments",
113430
+ ".git",
113431
+ ".next",
113432
+ ".turbo",
113433
+ "build",
113434
+ "coverage",
113435
+ "dist",
113436
+ "node_modules"
113437
+ ]);
113438
+ var WORKDIR_FILE_MIME_BY_EXT = {
113439
+ ".csv": "text/csv",
113440
+ ".doc": "application/msword",
113441
+ ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
113442
+ ".gif": "image/gif",
113443
+ ".htm": "text/html",
113444
+ ".html": "text/html",
113445
+ ".jpeg": "image/jpeg",
113446
+ ".jpg": "image/jpeg",
113447
+ ".json": "application/json",
113448
+ ".m4a": "audio/mp4",
113449
+ ".md": "text/markdown",
113450
+ ".mp3": "audio/mpeg",
113451
+ ".mp4": "video/mp4",
113452
+ ".pdf": "application/pdf",
113453
+ ".png": "image/png",
113454
+ ".ppt": "application/vnd.ms-powerpoint",
113455
+ ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
113456
+ ".svg": "image/svg+xml",
113457
+ ".txt": "text/plain",
113458
+ ".wav": "audio/wav",
113459
+ ".webm": "video/webm",
113460
+ ".webp": "image/webp",
113461
+ ".xls": "application/vnd.ms-excel",
113462
+ ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
113463
+ };
113464
+ function normalizeWorkdirRelativePath(value) {
113465
+ return value.split(import_node_path11.default.sep).join("/");
113466
+ }
113467
+ function inferWorkdirFileMimeType(filePath) {
113468
+ return WORKDIR_FILE_MIME_BY_EXT[import_node_path11.default.extname(filePath).toLowerCase()] ?? "application/octet-stream";
113469
+ }
113470
+ function boundedWorkdirResultLimit(value) {
113471
+ if (!Number.isFinite(value)) return WORKDIR_FIND_DEFAULT_MAX_RESULTS;
113472
+ return Math.min(WORKDIR_FIND_MAX_RESULTS, Math.max(1, Math.floor(value)));
113473
+ }
113474
+ async function resolveWorkdirRoot(cwd) {
113475
+ const rawCwd = (cwd ?? process.cwd()).trim();
113476
+ if (!rawCwd) throw new Error("\u5F53\u524D scope \u6CA1\u6709\u53EF\u7528\u5DE5\u4F5C\u76EE\u5F55\u3002");
113477
+ const resolvedCwd = import_node_path11.default.resolve(rawCwd);
113478
+ const stat3 = await import_promises3.default.stat(resolvedCwd).catch(() => null);
113479
+ if (!stat3?.isDirectory()) throw new Error(`\u5DE5\u4F5C\u76EE\u5F55\u4E0D\u53EF\u7528\uFF1A${resolvedCwd}`);
113480
+ return { cwd: resolvedCwd, realCwd: await import_promises3.default.realpath(resolvedCwd) };
113481
+ }
113482
+ async function resolveWorkdirFilePath(requestedPath, cwd) {
113483
+ const trimmed = requestedPath.trim();
113484
+ if (!trimmed) throw new Error("path \u4E0D\u80FD\u4E3A\u7A7A\u3002");
113485
+ const root = await resolveWorkdirRoot(cwd);
113486
+ const candidate = import_node_path11.default.resolve(root.cwd, trimmed);
113487
+ let realTarget;
113488
+ try {
113489
+ realTarget = await import_promises3.default.realpath(candidate);
113490
+ } catch {
113491
+ throw new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${trimmed}`);
113492
+ }
113493
+ if (!isPathInside(root.realCwd, realTarget)) {
113494
+ throw new Error("\u53EA\u80FD\u8BBF\u95EE\u5F53\u524D scope \u5DE5\u4F5C\u76EE\u5F55\u5185\u7684\u6587\u4EF6\u3002");
113495
+ }
113496
+ const stat3 = await import_promises3.default.stat(realTarget);
113497
+ if (!stat3.isFile()) throw new Error(`\u4E0D\u662F\u53EF\u53D1\u9001\u6587\u4EF6\uFF1A${trimmed}`);
113498
+ const relativePath = normalizeWorkdirRelativePath(import_node_path11.default.relative(root.realCwd, realTarget));
113499
+ return {
113500
+ absolutePath: realTarget,
113501
+ fileName: import_node_path11.default.basename(realTarget),
113502
+ relativePath,
113503
+ size: stat3.size,
113504
+ mtimeMs: stat3.mtimeMs
113505
+ };
113506
+ }
113507
+ function formatWorkdirFileSize(bytes) {
113508
+ if (bytes < 1024) return `${bytes} B`;
113509
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
113510
+ return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
113511
+ }
113512
+ async function findWorkdirFiles(args) {
113513
+ const root = await resolveWorkdirRoot(args.cwd);
113514
+ const needle = args.query?.trim().toLowerCase() ?? "";
113515
+ const limit = boundedWorkdirResultLimit(args.maxResults);
113516
+ const results = [];
113517
+ let scanned = 0;
113518
+ async function walk(dir, depth) {
113519
+ if (results.length >= limit || scanned >= WORKDIR_FIND_MAX_SCANNED_FILES || depth > WORKDIR_FIND_MAX_DEPTH) return;
113520
+ let entries;
113521
+ try {
113522
+ entries = await import_promises3.default.readdir(dir, { withFileTypes: true });
113523
+ } catch {
113524
+ return;
113525
+ }
113526
+ entries.sort((a, b) => a.name.localeCompare(b.name));
113527
+ for (const entry of entries) {
113528
+ if (results.length >= limit || scanned >= WORKDIR_FIND_MAX_SCANNED_FILES) break;
113529
+ if (entry.isDirectory()) {
113530
+ if (!WORKDIR_FIND_SKIP_DIRS.has(entry.name)) {
113531
+ await walk(import_node_path11.default.join(dir, entry.name), depth + 1);
113532
+ }
113533
+ continue;
113534
+ }
113535
+ if (!entry.isFile()) continue;
113536
+ scanned++;
113537
+ const absolutePath = import_node_path11.default.join(dir, entry.name);
113538
+ const relativePath = normalizeWorkdirRelativePath(import_node_path11.default.relative(root.realCwd, absolutePath));
113539
+ if (needle && !relativePath.toLowerCase().includes(needle) && !entry.name.toLowerCase().includes(needle)) {
113540
+ continue;
113541
+ }
113542
+ const stat3 = await import_promises3.default.stat(absolutePath).catch(() => null);
113543
+ if (!stat3?.isFile()) continue;
113544
+ results.push({
113545
+ relativePath,
113546
+ fileName: entry.name,
113547
+ size: stat3.size,
113548
+ mtimeMs: stat3.mtimeMs
113549
+ });
113550
+ }
113551
+ }
113552
+ await walk(root.realCwd, 0);
113553
+ return results.sort((a, b) => b.mtimeMs - a.mtimeMs).slice(0, limit);
113554
+ }
113421
113555
  function formatSkillEntry(entry, index) {
113422
113556
  return [
113423
113557
  `${index + 1}. ${entry.displayName} (${entry.name})`,
@@ -114372,6 +114506,122 @@ ${result.warnings.map((warning) => `- ${warning}`).join("\n")}
114372
114506
  },
114373
114507
  {}
114374
114508
  );
114509
+ const findWorkdirFilesTool = sdk.tool(
114510
+ "find_workdir_files",
114511
+ `Find files inside the current scope working directory only.
114512
+ Use this when the user asks you to locate a generated/output file before sending it as an attachment. It returns relative paths that can be passed to send_workdir_file.`,
114513
+ {
114514
+ query: external_exports.string().optional().describe("Optional case-insensitive substring to match against file names or relative paths."),
114515
+ max_results: external_exports.number().int().min(1).max(WORKDIR_FIND_MAX_RESULTS).optional().describe(
114516
+ `Maximum files to return. Defaults to ${WORKDIR_FIND_DEFAULT_MAX_RESULTS}, hard max ${WORKDIR_FIND_MAX_RESULTS}.`
114517
+ )
114518
+ },
114519
+ async (args) => {
114520
+ const query4 = args.query?.trim();
114521
+ const maxResults = boundedWorkdirResultLimit(args.max_results);
114522
+ logger10.info("find_workdir_files tool called", {
114523
+ agentId: deps.agentId,
114524
+ scope: currentScopeKey,
114525
+ query: query4 ?? null,
114526
+ maxResults
114527
+ });
114528
+ try {
114529
+ const files = await findWorkdirFiles({
114530
+ cwd: deps.cwd,
114531
+ query: query4,
114532
+ maxResults
114533
+ });
114534
+ if (files.length === 0) {
114535
+ return {
114536
+ content: [{
114537
+ type: "text",
114538
+ text: `[find_workdir_files] \u672A\u627E\u5230\u5339\u914D\u6587\u4EF6\u3002scope=${currentScopeKey}`
114539
+ }]
114540
+ };
114541
+ }
114542
+ const lines = files.map((file2, index) => {
114543
+ const modified = new Date(file2.mtimeMs).toISOString();
114544
+ return `${index + 1}. ${file2.relativePath} (${formatWorkdirFileSize(file2.size)}, modified ${modified})`;
114545
+ });
114546
+ return {
114547
+ content: [{
114548
+ type: "text",
114549
+ text: [
114550
+ `[find_workdir_files] \u627E\u5230 ${files.length} \u4E2A\u6587\u4EF6\uFF08\u53EA\u80FD\u53D1\u9001\u5F53\u524D scope \u5DE5\u4F5C\u76EE\u5F55\u5185\u6587\u4EF6\uFF09\uFF1A`,
114551
+ ...lines,
114552
+ "",
114553
+ '\u8981\u53D1\u7ED9\u7528\u6237\u65F6\uFF0C\u8C03\u7528 send_workdir_file(path="<\u4E0A\u9762\u7684\u76F8\u5BF9\u8DEF\u5F84>")\u3002'
114554
+ ].join("\n")
114555
+ }]
114556
+ };
114557
+ } catch (e) {
114558
+ const message = e instanceof Error ? e.message : String(e);
114559
+ logger10.error("find_workdir_files failed", {
114560
+ agentId: deps.agentId,
114561
+ scope: currentScopeKey,
114562
+ query: query4 ?? null,
114563
+ error: e
114564
+ });
114565
+ return {
114566
+ content: [{ type: "text", text: `[find_workdir_files] failed: ${message}` }],
114567
+ isError: true
114568
+ };
114569
+ }
114570
+ },
114571
+ {}
114572
+ );
114573
+ const sendWorkdirFileTool = sdk.tool(
114574
+ "send_workdir_file",
114575
+ `Send a real file from the current scope working directory as a clickable AHChat attachment on this visible reply.
114576
+ Only files inside the current scope cwd are allowed. Directories, missing files, and paths outside cwd are rejected. Pass a relative path from find_workdir_files when possible.`,
114577
+ {
114578
+ path: external_exports.string().min(1).describe("File path to send. Prefer a relative path returned by find_workdir_files; absolute paths are accepted only when they are inside the current scope cwd.")
114579
+ },
114580
+ async (args) => {
114581
+ const requestedPath = args.path.trim();
114582
+ logger10.info("send_workdir_file tool called", {
114583
+ agentId: deps.agentId,
114584
+ scope: currentScopeKey,
114585
+ path: requestedPath
114586
+ });
114587
+ try {
114588
+ const file2 = await resolveWorkdirFilePath(requestedPath, deps.cwd);
114589
+ const marker = {
114590
+ ok: true,
114591
+ kind: WORKDIR_ATTACHMENT_MARKER_KIND,
114592
+ path: file2.absolutePath,
114593
+ relative_path: file2.relativePath,
114594
+ file_name: file2.fileName,
114595
+ mime_type: inferWorkdirFileMimeType(file2.absolutePath),
114596
+ size: file2.size,
114597
+ attachment_source: "agent_explicit_send"
114598
+ };
114599
+ return {
114600
+ content: [{
114601
+ type: "text",
114602
+ text: [
114603
+ JSON.stringify(marker),
114604
+ "",
114605
+ `[send_workdir_file] \u5DF2\u51C6\u5907\u53D1\u9001\u9644\u4EF6\uFF1A${file2.relativePath} (${formatWorkdirFileSize(file2.size)})\u3002\u8BF7\u5728\u672C\u8F6E\u53EF\u89C1\u56DE\u590D\u91CC\u7B80\u77ED\u8BF4\u660E\u9644\u4EF6\u5DF2\u9644\u4E0A\uFF0C\u4E0D\u8981\u91CD\u590D\u8F93\u51FA\u6587\u4EF6\u5168\u6587\u3002`
114606
+ ].join("\n")
114607
+ }]
114608
+ };
114609
+ } catch (e) {
114610
+ const message = e instanceof Error ? e.message : String(e);
114611
+ logger10.error("send_workdir_file failed", {
114612
+ agentId: deps.agentId,
114613
+ scope: currentScopeKey,
114614
+ path: requestedPath,
114615
+ error: e
114616
+ });
114617
+ return {
114618
+ content: [{ type: "text", text: `[send_workdir_file] failed: ${message}` }],
114619
+ isError: true
114620
+ };
114621
+ }
114622
+ },
114623
+ {}
114624
+ );
114375
114625
  const createGroupIssueTool = deps.serverApiUrl ? sdk.tool(
114376
114626
  "create_group_issue",
114377
114627
  `\u628A\u5F53\u524D\u7FA4\u91CC\u7684\u771F\u5B9E\u95EE\u9898\u5199\u5165\u95EE\u9898\u9762\u677F\u3002
@@ -116703,7 +116953,13 @@ nextOffset=${json2.nextOffset}\uFF08\u7EE7\u7EED\u67E5\u8BE2\u65F6\u4F20 offset=
116703
116953
  },
116704
116954
  {}
116705
116955
  ) : null;
116706
- const tools = [neuralSend, neuralListScopes, readDocumentTool];
116956
+ const tools = [
116957
+ neuralSend,
116958
+ neuralListScopes,
116959
+ readDocumentTool,
116960
+ findWorkdirFilesTool,
116961
+ sendWorkdirFileTool
116962
+ ];
116707
116963
  if (readChatHistory) tools.push(readChatHistory);
116708
116964
  if (selfNote) tools.push(selfNote);
116709
116965
  if (listContacts) tools.push(listContacts);
@@ -116735,7 +116991,7 @@ nextOffset=${json2.nextOffset}\uFF08\u7EE7\u7EED\u67E5\u8BE2\u65F6\u4F20 offset=
116735
116991
  version: "2.3.0",
116736
116992
  tools
116737
116993
  });
116738
- const toolNames = ["neural_send", "neural_list_scopes", "read_document"];
116994
+ const toolNames = ["neural_send", "neural_list_scopes", "read_document", "find_workdir_files", "send_workdir_file"];
116739
116995
  if (readChatHistory) toolNames.push("read_chat_history");
116740
116996
  if (selfNote) toolNames.push("self_note");
116741
116997
  if (listContacts) toolNames.push("list_contacts");
@@ -118490,24 +118746,24 @@ function resetAccumulators(proc) {
118490
118746
 
118491
118747
  // src/forkHistoryReplay.ts
118492
118748
  init_cjs_shims();
118493
- var fs5 = __toESM(require("fs/promises"), 1);
118494
- var path11 = __toESM(require("path"), 1);
118749
+ var fs6 = __toESM(require("fs/promises"), 1);
118750
+ var path12 = __toESM(require("path"), 1);
118495
118751
  var logger13 = createModuleLogger("bridge.forkHistoryReplay");
118496
118752
  function metaPath(dataDir, agentId) {
118497
- return path11.join(dataDir, "fork-meta", `${agentId}.json`);
118753
+ return path12.join(dataDir, "fork-meta", `${agentId}.json`);
118498
118754
  }
118499
118755
  async function writeForkMeta(dataDir, agentId, meta3) {
118500
118756
  const fp = metaPath(dataDir, agentId);
118501
- await fs5.mkdir(path11.dirname(fp), { recursive: true });
118502
- await fs5.writeFile(fp, JSON.stringify(meta3), "utf-8");
118757
+ await fs6.mkdir(path12.dirname(fp), { recursive: true });
118758
+ await fs6.writeFile(fp, JSON.stringify(meta3), "utf-8");
118503
118759
  logger13.info("Fork meta written", { agentId, fp, sourceConversationId: meta3.sourceConversationId });
118504
118760
  }
118505
118761
  async function consumeForkMeta(dataDir, agentId) {
118506
118762
  const fp = metaPath(dataDir, agentId);
118507
118763
  try {
118508
- const raw = await fs5.readFile(fp, "utf-8");
118764
+ const raw = await fs6.readFile(fp, "utf-8");
118509
118765
  const meta3 = JSON.parse(raw);
118510
- await fs5.unlink(fp);
118766
+ await fs6.unlink(fp);
118511
118767
  logger13.info("Fork meta consumed (one-shot)", { agentId, sourceConversationId: meta3.sourceConversationId });
118512
118768
  return meta3;
118513
118769
  } catch {
@@ -118535,21 +118791,21 @@ function buildForkHistorySection(messages) {
118535
118791
  // src/sessionSlug.ts
118536
118792
  init_cjs_shims();
118537
118793
  var import_node_os6 = __toESM(require("os"), 1);
118538
- var import_node_path11 = __toESM(require("path"), 1);
118539
- var CLAUDE_PROJECTS_DIR = import_node_path11.default.join(import_node_os6.default.homedir(), ".claude", "projects");
118794
+ var import_node_path12 = __toESM(require("path"), 1);
118795
+ var CLAUDE_PROJECTS_DIR = import_node_path12.default.join(import_node_os6.default.homedir(), ".claude", "projects");
118540
118796
  function cwdToSlug(cwd) {
118541
118797
  return cwd.replace(/[^a-zA-Z0-9-]/g, "-");
118542
118798
  }
118543
118799
  function sessionDirForCwd(cwd) {
118544
- return import_node_path11.default.join(CLAUDE_PROJECTS_DIR, cwdToSlug(cwd));
118800
+ return import_node_path12.default.join(CLAUDE_PROJECTS_DIR, cwdToSlug(cwd));
118545
118801
  }
118546
118802
  function sessionFilePath(cwd, sessionId) {
118547
- return import_node_path11.default.join(sessionDirForCwd(cwd), `${sessionId}.jsonl`);
118803
+ return import_node_path12.default.join(sessionDirForCwd(cwd), `${sessionId}.jsonl`);
118548
118804
  }
118549
118805
 
118550
118806
  // src/workdirMapper.ts
118551
118807
  init_cjs_shims();
118552
- var import_node_path12 = __toESM(require("path"), 1);
118808
+ var import_node_path13 = __toESM(require("path"), 1);
118553
118809
  function extractAhchatWorkspaceParts(requestedPath) {
118554
118810
  const normalized = requestedPath.trim().replace(/\\/g, "/");
118555
118811
  const marker = "/.ahchat/users/";
@@ -118585,15 +118841,15 @@ function extractAhchatWorkspaceParts(requestedPath) {
118585
118841
  function extractAhchatWorkspaceSuffix(requestedPath) {
118586
118842
  const parts = extractAhchatWorkspaceParts(requestedPath);
118587
118843
  if (!parts || parts.length === 0) return null;
118588
- return import_node_path12.default.join(...parts);
118844
+ return import_node_path13.default.join(...parts);
118589
118845
  }
118590
118846
  function remapServerWorkspacePath(requestedPath, workspacesDir) {
118591
118847
  const parts = extractAhchatWorkspaceParts(requestedPath);
118592
118848
  if (!parts) return { path: requestedPath, remapped: false };
118593
- const remappedPath = parts.length > 0 ? import_node_path12.default.join(workspacesDir, ...parts) : workspacesDir;
118849
+ const remappedPath = parts.length > 0 ? import_node_path13.default.join(workspacesDir, ...parts) : workspacesDir;
118594
118850
  return {
118595
118851
  path: remappedPath,
118596
- remapped: import_node_path12.default.normalize(requestedPath) !== import_node_path12.default.normalize(remappedPath)
118852
+ remapped: import_node_path13.default.normalize(requestedPath) !== import_node_path13.default.normalize(remappedPath)
118597
118853
  };
118598
118854
  }
118599
118855
 
@@ -118714,10 +118970,51 @@ var SMITH_ALLOWED_TOOLS = [
118714
118970
  // neural bridge — cross-scope coordination when Smith is pulled into a group
118715
118971
  "mcp__neural__neural_send",
118716
118972
  "mcp__neural__neural_list_scopes",
118973
+ // bounded current-scope workdir attachments
118974
+ "mcp__neural__find_workdir_files",
118975
+ "mcp__neural__send_workdir_file",
118717
118976
  // interaction / planning
118718
118977
  "AskUserQuestion",
118719
118978
  "Write"
118720
118979
  ];
118980
+ function isVisionMcpServerName(serverName) {
118981
+ return serverName === "vision";
118982
+ }
118983
+ function selectSmithVisionMcp(resolved) {
118984
+ const resolvedMcpServers = resolved.mcpServers ?? {};
118985
+ const resolvedAllowedTools = resolved.allowedTools ?? [];
118986
+ const resolvedToolAbi = resolved.toolAbi ?? [];
118987
+ const visionServerNames = /* @__PURE__ */ new Set();
118988
+ for (const server of resolvedToolAbi) {
118989
+ if (server.providerId === "volcengine_vision" || isVisionMcpServerName(server.serverName)) {
118990
+ visionServerNames.add(server.serverName);
118991
+ }
118992
+ }
118993
+ for (const toolName of resolvedAllowedTools) {
118994
+ const parsed = parseMcpRuntimeToolName(toolName);
118995
+ if (parsed && isVisionMcpServerName(parsed.serverName)) {
118996
+ visionServerNames.add(parsed.serverName);
118997
+ }
118998
+ }
118999
+ for (const serverName of Object.keys(resolvedMcpServers)) {
119000
+ if (isVisionMcpServerName(serverName)) {
119001
+ visionServerNames.add(serverName);
119002
+ }
119003
+ }
119004
+ if (visionServerNames.size === 0) {
119005
+ return { mcpServers: {}, allowedTools: [], toolAbi: [] };
119006
+ }
119007
+ return {
119008
+ mcpServers: Object.fromEntries(
119009
+ Object.entries(resolvedMcpServers).filter(([serverName]) => visionServerNames.has(serverName))
119010
+ ),
119011
+ allowedTools: resolvedAllowedTools.filter((toolName) => {
119012
+ const parsed = parseMcpRuntimeToolName(toolName);
119013
+ return Boolean(parsed && visionServerNames.has(parsed.serverName));
119014
+ }),
119015
+ toolAbi: resolvedToolAbi.filter((server) => visionServerNames.has(server.serverName))
119016
+ };
119017
+ }
118721
119018
  function resolveVisionMcpToolHints(externalMcp) {
118722
119019
  let describe3 = null;
118723
119020
  let ocr = null;
@@ -118785,7 +119082,7 @@ function uniqueNormalizedPaths(paths) {
118785
119082
  for (const item of paths) {
118786
119083
  const trimmed = item.trim();
118787
119084
  if (!trimmed) continue;
118788
- const normalized = import_node_path13.default.normalize(trimmed);
119085
+ const normalized = import_node_path14.default.normalize(trimmed);
118789
119086
  const key = process.platform === "win32" ? normalized.toLowerCase() : normalized;
118790
119087
  if (seen.has(key)) continue;
118791
119088
  seen.add(key);
@@ -118815,7 +119112,7 @@ function resolveReadToolImagePath(input, cwd) {
118815
119112
  if (typeof raw !== "string" || raw.trim().length === 0) return null;
118816
119113
  const trimmed = raw.trim();
118817
119114
  if (!IMAGE_READ_EXT_RE.test(trimmed)) return null;
118818
- const abs = import_node_path13.default.isAbsolute(trimmed) ? import_node_path13.default.normalize(trimmed) : import_node_path13.default.resolve(cwd, trimmed);
119115
+ const abs = import_node_path14.default.isAbsolute(trimmed) ? import_node_path14.default.normalize(trimmed) : import_node_path14.default.resolve(cwd, trimmed);
118819
119116
  return { raw: trimmed, abs };
118820
119117
  }
118821
119118
  function usesIsolatedProjectBackend(cfg) {
@@ -118834,14 +119131,14 @@ function buildModelGatewayBaseUrl(serverApiUrl, subscriptionId) {
118834
119131
  }
118835
119132
  async function chownForRootSpawn(targetPath, target) {
118836
119133
  try {
118837
- await import_promises3.default.chown(targetPath, NODE_USER_UID, NODE_USER_UID);
119134
+ await import_promises4.default.chown(targetPath, NODE_USER_UID, NODE_USER_UID);
118838
119135
  } catch (error51) {
118839
119136
  logger15.error("Best-effort root chown failed", { error: error51, target, path: targetPath });
118840
119137
  }
118841
119138
  }
118842
119139
  function readCronLockSnapshot() {
118843
119140
  try {
118844
- const lockPath2 = import_node_path13.default.join(import_node_os7.default.homedir(), ".claude", "scheduled_tasks.lock");
119141
+ const lockPath2 = import_node_path14.default.join(import_node_os7.default.homedir(), ".claude", "scheduled_tasks.lock");
118845
119142
  if (!import_node_fs6.default.existsSync(lockPath2)) {
118846
119143
  return { exists: false, sessionId: null, pid: null };
118847
119144
  }
@@ -119113,8 +119410,8 @@ var AgentManager = class {
119113
119410
  this.emit = emit;
119114
119411
  if (typeof options === "function") {
119115
119412
  this.queryFn = options;
119116
- this.workspacesDir = import_node_path13.default.join(import_node_os7.default.homedir(), ".ahchat", "workspaces");
119117
- this.agentConfigDir = import_node_path13.default.join(import_node_os7.default.homedir(), ".ahchat", "agent-config");
119413
+ this.workspacesDir = import_node_path14.default.join(import_node_os7.default.homedir(), ".ahchat", "workspaces");
119414
+ this.agentConfigDir = import_node_path14.default.join(import_node_os7.default.homedir(), ".ahchat", "agent-config");
119118
119415
  this.queryConfig = DEFAULT_QUERY_CONFIG;
119119
119416
  this.askQuestionRegistry = new AskQuestionRegistry();
119120
119417
  this.groupRegistry = null;
@@ -119131,13 +119428,13 @@ var AgentManager = class {
119131
119428
  this.bridgeToken = null;
119132
119429
  this.currentBridgeKey = null;
119133
119430
  this.defaultModel = null;
119134
- this.dataDir = import_node_path13.default.join(import_node_os7.default.homedir(), ".ahchat");
119431
+ this.dataDir = import_node_path14.default.join(import_node_os7.default.homedir(), ".ahchat");
119135
119432
  this.workdirOverrideStore = null;
119136
119433
  this.officeCliRuntime = null;
119137
119434
  } else {
119138
119435
  this.queryFn = options?.queryFn ?? null;
119139
- this.workspacesDir = options?.workspacesDir ?? import_node_path13.default.join(import_node_os7.default.homedir(), ".ahchat", "workspaces");
119140
- this.agentConfigDir = options?.agentConfigDir ?? import_node_path13.default.join(import_node_os7.default.homedir(), ".ahchat", "agent-config");
119436
+ this.workspacesDir = options?.workspacesDir ?? import_node_path14.default.join(import_node_os7.default.homedir(), ".ahchat", "workspaces");
119437
+ this.agentConfigDir = options?.agentConfigDir ?? import_node_path14.default.join(import_node_os7.default.homedir(), ".ahchat", "agent-config");
119141
119438
  this.queryConfig = options?.queryConfig ?? DEFAULT_QUERY_CONFIG;
119142
119439
  this.askQuestionRegistry = options?.askQuestionRegistry ?? new AskQuestionRegistry();
119143
119440
  this.groupRegistry = options?.groupRegistry ?? null;
@@ -119154,7 +119451,7 @@ var AgentManager = class {
119154
119451
  this.mcpAuditRecorder = options?.mcpAuditRecorder ?? new HttpMcpAuditClient(this.serverApiUrl, this.bridgeToken);
119155
119452
  this.mcpBillingPreflightChecker = options?.mcpBillingPreflightChecker ?? new HttpMcpBillingClient(this.serverApiUrl, this.bridgeToken);
119156
119453
  this.defaultModel = options?.defaultModel ?? null;
119157
- this.dataDir = options?.dataDir ?? import_node_path13.default.join(import_node_os7.default.homedir(), ".ahchat");
119454
+ this.dataDir = options?.dataDir ?? import_node_path14.default.join(import_node_os7.default.homedir(), ".ahchat");
119158
119455
  this.workdirOverrideStore = options?.workdirOverrideStore ?? null;
119159
119456
  this.officeCliRuntime = options?.officeCliRuntime ?? null;
119160
119457
  }
@@ -119187,9 +119484,9 @@ var AgentManager = class {
119187
119484
  const normalized = requestedCwd.trim();
119188
119485
  const ahchatSuffix = extractAhchatWorkspaceSuffix(normalized);
119189
119486
  if (ahchatSuffix) {
119190
- return import_node_path13.default.join(this.workspacesDir, ahchatSuffix);
119487
+ return import_node_path14.default.join(this.workspacesDir, ahchatSuffix);
119191
119488
  }
119192
- return import_node_path13.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119489
+ return import_node_path14.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119193
119490
  }
119194
119491
  localScopeDirName(agentConfig, scope) {
119195
119492
  if (scope.kind === "group") return `Group-${scope.groupId}`;
@@ -119200,9 +119497,9 @@ var AgentManager = class {
119200
119497
  if (scope.kind === "group") {
119201
119498
  const groupCwd = this.groupRegistry?.getById(scope.groupId)?.workingDirectory?.trim();
119202
119499
  if (groupCwd) return groupCwd;
119203
- return import_node_path13.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119500
+ return import_node_path14.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119204
119501
  }
119205
- const local = import_node_path13.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119502
+ const local = import_node_path14.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119206
119503
  return agentConfig.workingDirectory?.trim() || local;
119207
119504
  }
119208
119505
  runtimeCwdInput(agentConfig, scope, cwd) {
@@ -119214,7 +119511,7 @@ var AgentManager = class {
119214
119511
  if (requested && (!agentCwd || !this.isSameRuntimeCwd(requested, agentCwd))) {
119215
119512
  return requested;
119216
119513
  }
119217
- return import_node_path13.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119514
+ return import_node_path14.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119218
119515
  }
119219
119516
  return agentConfig.workingDirectory?.trim() || requested || this.scopeCwdInput(agentConfig, scope);
119220
119517
  }
@@ -119249,7 +119546,7 @@ var AgentManager = class {
119249
119546
  let cwd = this.remapServerWorkspaceCwd(agentConfig, scope, requestedCwd);
119250
119547
  let fallbackForensicsId;
119251
119548
  if (!isFullyQualifiedAbsolutePath(cwd)) {
119252
- const fallback = import_node_path13.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119549
+ const fallback = import_node_path14.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
119253
119550
  logger15.error(
119254
119551
  "Working directory is not usable on this machine; using local sandbox fallback",
119255
119552
  {
@@ -119285,7 +119582,7 @@ var AgentManager = class {
119285
119582
  cwd = this.fallbackCwd(agentConfig, scope, cwd);
119286
119583
  }
119287
119584
  try {
119288
- await import_promises3.default.mkdir(cwd, { recursive: true });
119585
+ await import_promises4.default.mkdir(cwd, { recursive: true });
119289
119586
  return cwd;
119290
119587
  } catch (e) {
119291
119588
  const fallback = this.fallbackCwd(agentConfig, scope, cwd);
@@ -119312,7 +119609,7 @@ var AgentManager = class {
119312
119609
  },
119313
119610
  outcome: { result: "second_layer_fallback" }
119314
119611
  });
119315
- await import_promises3.default.mkdir(fallback, { recursive: true });
119612
+ await import_promises4.default.mkdir(fallback, { recursive: true });
119316
119613
  return fallback;
119317
119614
  }
119318
119615
  }
@@ -119506,25 +119803,25 @@ var AgentManager = class {
119506
119803
  }
119507
119804
  settingsPathForConfig(cfg, effectiveConfigDir) {
119508
119805
  if (!usesIsolatedProjectBackend(cfg)) return void 0;
119509
- return import_node_path13.default.join(effectiveConfigDir, "settings.json");
119806
+ return import_node_path14.default.join(effectiveConfigDir, "settings.json");
119510
119807
  }
119511
119808
  isSameRuntimeCwd(a, b) {
119512
- const left = import_node_path13.default.normalize(a);
119513
- const right = import_node_path13.default.normalize(b);
119809
+ const left = import_node_path14.default.normalize(a);
119810
+ const right = import_node_path14.default.normalize(b);
119514
119811
  return process.platform === "win32" ? left.toLowerCase() === right.toLowerCase() : left === right;
119515
119812
  }
119516
119813
  sessionProjectDirs(agentConfig, effectiveConfigDir) {
119517
119814
  return uniqueNormalizedPaths([
119518
- import_node_path13.default.join(effectiveConfigDir, "api-key-agents", agentConfig.id, "projects"),
119519
- import_node_path13.default.join(effectiveConfigDir, "projects"),
119520
- import_node_path13.default.join(import_node_os7.default.homedir(), ".claude", "projects")
119815
+ import_node_path14.default.join(effectiveConfigDir, "api-key-agents", agentConfig.id, "projects"),
119816
+ import_node_path14.default.join(effectiveConfigDir, "projects"),
119817
+ import_node_path14.default.join(import_node_os7.default.homedir(), ".claude", "projects")
119521
119818
  ]);
119522
119819
  }
119523
119820
  sessionPathsForCwd(projectsDirs, cwd, sessionId) {
119524
119821
  return uniqueNormalizedPaths(
119525
119822
  projectsDirs.flatMap(
119526
119823
  (projectsDir) => claudeProjectSlugCandidates(cwd).map(
119527
- (slug) => import_node_path13.default.join(projectsDir, slug, `${sessionId}.jsonl`)
119824
+ (slug) => import_node_path14.default.join(projectsDir, slug, `${sessionId}.jsonl`)
119528
119825
  )
119529
119826
  )
119530
119827
  );
@@ -119545,7 +119842,7 @@ var AgentManager = class {
119545
119842
  }
119546
119843
  for (const entry of entries) {
119547
119844
  if (!entry.isDirectory()) continue;
119548
- const candidate = import_node_path13.default.join(projectsDir, entry.name, `${sessionId}.jsonl`);
119845
+ const candidate = import_node_path14.default.join(projectsDir, entry.name, `${sessionId}.jsonl`);
119549
119846
  if (import_node_fs6.default.existsSync(candidate)) found.push(candidate);
119550
119847
  }
119551
119848
  }
@@ -119560,12 +119857,12 @@ var AgentManager = class {
119560
119857
  }
119561
119858
  const currentPathSet = new Set(
119562
119859
  currentCwdPaths.map(
119563
- (candidate) => process.platform === "win32" ? import_node_path13.default.normalize(candidate).toLowerCase() : import_node_path13.default.normalize(candidate)
119860
+ (candidate) => process.platform === "win32" ? import_node_path14.default.normalize(candidate).toLowerCase() : import_node_path14.default.normalize(candidate)
119564
119861
  )
119565
119862
  );
119566
119863
  const foundElsewhere = this.findSessionJsonlFiles(projectsDirs, sessionId).filter(
119567
119864
  (candidate) => {
119568
- const normalized = process.platform === "win32" ? import_node_path13.default.normalize(candidate).toLowerCase() : import_node_path13.default.normalize(candidate);
119865
+ const normalized = process.platform === "win32" ? import_node_path14.default.normalize(candidate).toLowerCase() : import_node_path14.default.normalize(candidate);
119569
119866
  return !currentPathSet.has(normalized);
119570
119867
  }
119571
119868
  );
@@ -119586,7 +119883,7 @@ var AgentManager = class {
119586
119883
  return null;
119587
119884
  }
119588
119885
  scopePromptFingerprint(agentConfig, scope, agentCwd, scopesSection, externalMcpFingerprint, runtimeToolPolicyFingerprint = "") {
119589
- const hash2 = (0, import_node_crypto3.createHash)("sha256").update(SCOPE_PROMPT_FINGERPRINT_REVISION).update("\0").update(agentConfig.id).update("\0").update(agentConfig.name).update("\0").update(scopeKey(scope)).update("\0").update(import_node_path13.default.normalize(agentCwd)).update("\0").update(scopesSection).update("\0").update(externalMcpFingerprint);
119886
+ const hash2 = (0, import_node_crypto3.createHash)("sha256").update(SCOPE_PROMPT_FINGERPRINT_REVISION).update("\0").update(agentConfig.id).update("\0").update(agentConfig.name).update("\0").update(scopeKey(scope)).update("\0").update(import_node_path14.default.normalize(agentCwd)).update("\0").update(scopesSection).update("\0").update(externalMcpFingerprint);
119590
119887
  if (runtimeToolPolicyFingerprint) {
119591
119888
  hash2.update("\0runtimeToolPolicy\0").update(runtimeToolPolicyFingerprint);
119592
119889
  }
@@ -119943,7 +120240,7 @@ var AgentManager = class {
119943
120240
  const scopedInstructions = cfg.instructions?.trim() && scope.kind === "group" ? `# Agent project instructions
119944
120241
  ${cfg.instructions.trim()}` : "";
119945
120242
  if (cfg.instructions?.trim() && scope.kind === "single") {
119946
- await import_promises3.default.writeFile(import_node_path13.default.join(agentCwd, "CLAUDE.md"), cfg.instructions.trim(), "utf-8");
120243
+ await import_promises4.default.writeFile(import_node_path14.default.join(agentCwd, "CLAUDE.md"), cfg.instructions.trim(), "utf-8");
119947
120244
  logger15.info("CLAUDE.md written", {
119948
120245
  agentId: agentConfig.id,
119949
120246
  scope: scopeKey(scope),
@@ -119952,10 +120249,10 @@ ${cfg.instructions.trim()}` : "";
119952
120249
  }
119953
120250
  let effectiveConfigDir = this.agentConfigDir;
119954
120251
  if (cfg.subscriptionType !== "system" && cfg.apiKey) {
119955
- effectiveConfigDir = import_node_path13.default.join(this.agentConfigDir, "api-key-agents", agentConfig.id);
120252
+ effectiveConfigDir = import_node_path14.default.join(this.agentConfigDir, "api-key-agents", agentConfig.id);
119956
120253
  let isNew = false;
119957
120254
  try {
119958
- await import_promises3.default.access(effectiveConfigDir);
120255
+ await import_promises4.default.access(effectiveConfigDir);
119959
120256
  } catch (e) {
119960
120257
  logger15.debug("Agent API key config dir missing; creating isolated dir", {
119961
120258
  error: e,
@@ -119963,7 +120260,7 @@ ${cfg.instructions.trim()}` : "";
119963
120260
  });
119964
120261
  isNew = true;
119965
120262
  }
119966
- await import_promises3.default.mkdir(effectiveConfigDir, { recursive: true });
120263
+ await import_promises4.default.mkdir(effectiveConfigDir, { recursive: true });
119967
120264
  if (isNew) {
119968
120265
  this.sessionStore.delete(agentConfig.id, scope);
119969
120266
  this.dispatchMemory.deleteScope(agentConfig.id, scope);
@@ -119971,13 +120268,13 @@ ${cfg.instructions.trim()}` : "";
119971
120268
  agentId: agentConfig.id
119972
120269
  });
119973
120270
  }
119974
- const settingsPath = import_node_path13.default.join(effectiveConfigDir, "settings.json");
120271
+ const settingsPath = import_node_path14.default.join(effectiveConfigDir, "settings.json");
119975
120272
  const envEntries = buildAnthropicCredentialEnv(cfg);
119976
120273
  if (cfg.apiBaseUrl) envEntries.ANTHROPIC_BASE_URL = cfg.apiBaseUrl;
119977
120274
  let existingSettings = {};
119978
120275
  if (import_node_fs6.default.existsSync(settingsPath)) {
119979
120276
  try {
119980
- const raw = await import_promises3.default.readFile(settingsPath, "utf-8");
120277
+ const raw = await import_promises4.default.readFile(settingsPath, "utf-8");
119981
120278
  existingSettings = JSON.parse(raw);
119982
120279
  } catch (error51) {
119983
120280
  logger15.error("Failed to read existing API-key agent settings; starting fresh", {
@@ -119992,7 +120289,7 @@ ${cfg.instructions.trim()}` : "";
119992
120289
  if (envEntries.ANTHROPIC_AUTH_TOKEN) delete mergedEnv.ANTHROPIC_API_KEY;
119993
120290
  if (envEntries.ANTHROPIC_API_KEY) delete mergedEnv.ANTHROPIC_AUTH_TOKEN;
119994
120291
  const mergedSettings = { ...existingSettings, env: mergedEnv };
119995
- await import_promises3.default.writeFile(settingsPath, JSON.stringify(mergedSettings, null, 2), "utf-8");
120292
+ await import_promises4.default.writeFile(settingsPath, JSON.stringify(mergedSettings, null, 2), "utf-8");
119996
120293
  logger15.info("API-key agent using isolated config dir", {
119997
120294
  agentId: agentConfig.id,
119998
120295
  configDirKind: "api-key-agent",
@@ -120095,13 +120392,15 @@ ${cfg.instructions.trim()}` : "";
120095
120392
  isSmith: smithAgent,
120096
120393
  cwd: agentCwd
120097
120394
  }) ?? { mcpServers: {}, allowedTools: [], toolAbi: [] };
120098
- const externalMcp = smithAgent ? { mcpServers: {}, allowedTools: [], toolAbi: [] } : resolvedExternalMcp;
120099
- if (smithAgent && (Object.keys(resolvedExternalMcp.mcpServers).length > 0 || resolvedExternalMcp.allowedTools.length > 0 || (resolvedExternalMcp.toolAbi?.length ?? 0) > 0)) {
120100
- logger15.info("Smith external MCP ignored by fixed tool whitelist", {
120395
+ const externalMcp = smithAgent ? selectSmithVisionMcp(resolvedExternalMcp) : resolvedExternalMcp;
120396
+ if (smithAgent && (Object.keys(resolvedExternalMcp.mcpServers).length !== Object.keys(externalMcp.mcpServers).length || resolvedExternalMcp.allowedTools.length !== externalMcp.allowedTools.length || (resolvedExternalMcp.toolAbi?.length ?? 0) !== (externalMcp.toolAbi?.length ?? 0))) {
120397
+ logger15.info("Smith external MCP filtered by fixed tool whitelist", {
120101
120398
  agentId: agentConfig.id,
120102
120399
  scope: scopeKey(scope),
120103
120400
  serverNames: Object.keys(resolvedExternalMcp.mcpServers),
120104
- allowedToolCount: resolvedExternalMcp.allowedTools.length
120401
+ allowedToolCount: resolvedExternalMcp.allowedTools.length,
120402
+ retainedServerNames: Object.keys(externalMcp.mcpServers),
120403
+ retainedAllowedToolCount: externalMcp.allowedTools.length
120105
120404
  });
120106
120405
  }
120107
120406
  const visionMcpTools = resolveVisionMcpToolHints(externalMcp);
@@ -120225,6 +120524,8 @@ ${cfg.instructions.trim()}` : "";
120225
120524
  "AskUserQuestion",
120226
120525
  "mcp__neural__neural_send",
120227
120526
  "mcp__neural__neural_list_scopes",
120527
+ "mcp__neural__find_workdir_files",
120528
+ "mcp__neural__send_workdir_file",
120228
120529
  "mcp__neural__self_note",
120229
120530
  "mcp__neural__list_contacts",
120230
120531
  "mcp__neural__create_group",
@@ -120545,7 +120846,7 @@ Do NOT use "..." as content \u2014 write specific, project-relevant content.`;
120545
120846
  if (isRunningAsRoot()) {
120546
120847
  await chownForRootSpawn(effectiveConfigDir, "configDir");
120547
120848
  await chownForRootSpawn(agentCwd, "agentCwd");
120548
- const settingsFilePath = import_node_path13.default.join(effectiveConfigDir, "settings.json");
120849
+ const settingsFilePath = import_node_path14.default.join(effectiveConfigDir, "settings.json");
120549
120850
  await chownForRootSpawn(settingsFilePath, "settingsFile");
120550
120851
  options.spawnClaudeCodeProcess = (spawnOptions) => {
120551
120852
  const env2 = { ...spawnOptions.env, HOME: "/home/node" };
@@ -120615,7 +120916,7 @@ Do NOT use "..." as content \u2014 write specific, project-relevant content.`;
120615
120916
  mergedTasks: [],
120616
120917
  planModeBuffer: [],
120617
120918
  createdAt: Date.now(),
120618
- supportsVision: modelInputMode === "vision",
120919
+ supportsVision: cfg.supportsVision === true,
120619
120920
  modelInputMode,
120620
120921
  visionMcpTools,
120621
120922
  quietFlushTimer: null,
@@ -120803,7 +121104,7 @@ ${trimmed}`;
120803
121104
  promptWorkdir(agentConfig, scope, requestedCwd) {
120804
121105
  const remapped = this.remapServerWorkspaceCwd(agentConfig, scope, requestedCwd);
120805
121106
  if (!isFullyQualifiedAbsolutePath(remapped)) {
120806
- return import_node_path13.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
121107
+ return import_node_path14.default.join(this.workspacesDir, this.localScopeDirName(agentConfig, scope));
120807
121108
  }
120808
121109
  return remapped;
120809
121110
  }
@@ -121508,12 +121809,12 @@ ${lines.join("\n")}`;
121508
121809
  }
121509
121810
  async materializeAttachment(runtime, attachment, buffer) {
121510
121811
  const safeFileName = this.safeAttachmentFileName(attachment.fileName);
121511
- const attachmentDir = import_node_path13.default.join(runtime.cwd, ".ahchat-attachments", attachment.id);
121812
+ const attachmentDir = import_node_path14.default.join(runtime.cwd, ".ahchat-attachments", attachment.id);
121512
121813
  let filePath = await this.resolveExistingWorkspaceAttachmentPath(runtime, attachment);
121513
121814
  if (!filePath) {
121514
- await import_promises3.default.mkdir(attachmentDir, { recursive: true });
121515
- filePath = import_node_path13.default.join(attachmentDir, safeFileName);
121516
- await import_promises3.default.writeFile(filePath, buffer);
121815
+ await import_promises4.default.mkdir(attachmentDir, { recursive: true });
121816
+ filePath = import_node_path14.default.join(attachmentDir, safeFileName);
121817
+ await import_promises4.default.writeFile(filePath, buffer);
121517
121818
  }
121518
121819
  const materialized = { filePath };
121519
121820
  if (isReadableDocumentPath(filePath)) {
@@ -121542,10 +121843,10 @@ ${lines.join("\n")}`;
121542
121843
  const rawPath = typeof localWorkspacePath === "string" && localWorkspacePath.trim() ? localWorkspacePath : workspacePath;
121543
121844
  if (typeof rawPath !== "string" || !rawPath.trim()) return null;
121544
121845
  const remapped = remapServerWorkspacePath(rawPath, this.workspacesDir);
121545
- const candidate = import_node_path13.default.resolve(remapped.path);
121846
+ const candidate = import_node_path14.default.resolve(remapped.path);
121546
121847
  if (!this.isPathInsideBase(candidate, runtime.cwd)) return null;
121547
121848
  try {
121548
- const stat3 = await import_promises3.default.stat(candidate);
121849
+ const stat3 = await import_promises4.default.stat(candidate);
121549
121850
  return stat3.isFile() ? candidate : null;
121550
121851
  } catch (e) {
121551
121852
  logger15.warn("Workspace attachment path unavailable", {
@@ -121560,13 +121861,13 @@ ${lines.join("\n")}`;
121560
121861
  }
121561
121862
  }
121562
121863
  isPathInsideBase(filePath, basePath) {
121563
- const resolvedFile = import_node_path13.default.resolve(filePath);
121564
- const resolvedBase = import_node_path13.default.resolve(basePath);
121565
- const relative = import_node_path13.default.relative(resolvedBase, resolvedFile);
121566
- return relative === "" || !relative.startsWith("..") && !import_node_path13.default.isAbsolute(relative);
121864
+ const resolvedFile = import_node_path14.default.resolve(filePath);
121865
+ const resolvedBase = import_node_path14.default.resolve(basePath);
121866
+ const relative = import_node_path14.default.relative(resolvedBase, resolvedFile);
121867
+ return relative === "" || !relative.startsWith("..") && !import_node_path14.default.isAbsolute(relative);
121567
121868
  }
121568
121869
  safeAttachmentFileName(fileName) {
121569
- const baseName = import_node_path13.default.basename(fileName).replace(/[\0/:\\]/g, "_").trim();
121870
+ const baseName = import_node_path14.default.basename(fileName).replace(/[\0/:\\]/g, "_").trim();
121570
121871
  return baseName || "attachment";
121571
121872
  }
121572
121873
  emitTaskPushError(runtime, task, error51) {
@@ -123945,8 +124246,8 @@ async function readJson(res) {
123945
124246
  return null;
123946
124247
  }
123947
124248
  }
123948
- function apiUrl(baseUrl, path36) {
123949
- return new URL(path36, baseUrl).toString();
124249
+ function apiUrl(baseUrl, path37) {
124250
+ return new URL(path37, baseUrl).toString();
123950
124251
  }
123951
124252
  async function fetchServerSkillSet(options) {
123952
124253
  try {
@@ -124201,8 +124502,8 @@ var HttpAgentRegistry = class {
124201
124502
  lastRefreshCount = null;
124202
124503
  apiUrl(suffix) {
124203
124504
  const base = this.serverApiUrl.replace(/\/$/, "");
124204
- const path36 = suffix.startsWith("/") ? suffix : `/${suffix}`;
124205
- return `${base}${path36}`;
124505
+ const path37 = suffix.startsWith("/") ? suffix : `/${suffix}`;
124506
+ return `${base}${path37}`;
124206
124507
  }
124207
124508
  async refresh() {
124208
124509
  const attempt = async () => {
@@ -124306,8 +124607,8 @@ var HttpSubscriptionRegistry = class {
124306
124607
  lastRefreshCount = null;
124307
124608
  apiUrl(suffix) {
124308
124609
  const base = this.serverApiUrl.replace(/\/$/, "");
124309
- const path36 = suffix.startsWith("/") ? suffix : `/${suffix}`;
124310
- return `${base}${path36}`;
124610
+ const path37 = suffix.startsWith("/") ? suffix : `/${suffix}`;
124611
+ return `${base}${path37}`;
124311
124612
  }
124312
124613
  rebuildPrimaryAlias() {
124313
124614
  this.subscriptions.delete(PRIMARY_COMPANY_SUBSCRIPTION_ID);
@@ -124387,7 +124688,7 @@ var HttpSubscriptionRegistry = class {
124387
124688
  // src/mcpRegistry.ts
124388
124689
  init_cjs_shims();
124389
124690
  var import_node_fs7 = __toESM(require("fs"), 1);
124390
- var import_node_path14 = __toESM(require("path"), 1);
124691
+ var import_node_path15 = __toESM(require("path"), 1);
124391
124692
  var import_node_url = require("url");
124392
124693
  var logger20 = createModuleLogger("mcp.registry");
124393
124694
  var AHCHAT_BUILTIN_MCP_COMMAND = "ahchat-builtin";
@@ -124409,8 +124710,8 @@ var HttpMcpRegistry = class {
124409
124710
  lastRefreshCount = null;
124410
124711
  apiUrl(suffix) {
124411
124712
  const base = this.serverApiUrl.replace(/\/$/, "");
124412
- const path36 = suffix.startsWith("/") ? suffix : `/${suffix}`;
124413
- return `${base}${path36}`;
124713
+ const path37 = suffix.startsWith("/") ? suffix : `/${suffix}`;
124714
+ return `${base}${path37}`;
124414
124715
  }
124415
124716
  async refresh() {
124416
124717
  this.refreshLocal();
@@ -124602,13 +124903,13 @@ function resolveVisionMcpExecutable(extraArgs, options = {}) {
124602
124903
  return resolveBundledMcpExecutable("visionMcpCli", extraArgs, options);
124603
124904
  }
124604
124905
  function resolveBundledMcpExecutable(cliBaseName, extraArgs, options = {}) {
124605
- const currentDir = options.currentDir ?? import_node_path14.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
124906
+ const currentDir = options.currentDir ?? import_node_path15.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
124606
124907
  const cwd = options.cwd ?? process.cwd();
124607
124908
  const execPath = options.execPath ?? process.execPath;
124608
124909
  const existsSync3 = options.existsSync ?? import_node_fs7.default.existsSync;
124609
124910
  const distCliPath = firstExistingPath(
124610
124911
  [
124611
- import_node_path14.default.join(currentDir, `${cliBaseName}.cjs`)
124912
+ import_node_path15.default.join(currentDir, `${cliBaseName}.cjs`)
124612
124913
  ],
124613
124914
  existsSync3
124614
124915
  );
@@ -124621,7 +124922,7 @@ function resolveBundledMcpExecutable(cliBaseName, extraArgs, options = {}) {
124621
124922
  }
124622
124923
  const sourceCliPath = firstExistingPath(
124623
124924
  [
124624
- import_node_path14.default.join(currentDir, `${cliBaseName}.ts`)
124925
+ import_node_path15.default.join(currentDir, `${cliBaseName}.ts`)
124625
124926
  ],
124626
124927
  existsSync3
124627
124928
  );
@@ -124630,9 +124931,9 @@ function resolveBundledMcpExecutable(cliBaseName, extraArgs, options = {}) {
124630
124931
  }
124631
124932
  const workspaceDistCliPath = firstExistingPath(
124632
124933
  [
124633
- import_node_path14.default.resolve(currentDir, `../../bridge/dist/${cliBaseName}.cjs`),
124634
- import_node_path14.default.resolve(cwd, `packages/desktop/dist/${cliBaseName}.cjs`),
124635
- import_node_path14.default.resolve(cwd, `packages/bridge/dist/${cliBaseName}.cjs`)
124934
+ import_node_path15.default.resolve(currentDir, `../../bridge/dist/${cliBaseName}.cjs`),
124935
+ import_node_path15.default.resolve(cwd, `packages/desktop/dist/${cliBaseName}.cjs`),
124936
+ import_node_path15.default.resolve(cwd, `packages/bridge/dist/${cliBaseName}.cjs`)
124636
124937
  ],
124637
124938
  existsSync3
124638
124939
  );
@@ -124645,8 +124946,8 @@ function resolveBundledMcpExecutable(cliBaseName, extraArgs, options = {}) {
124645
124946
  }
124646
124947
  const workspaceSourceCliPath = firstExistingPath(
124647
124948
  [
124648
- import_node_path14.default.resolve(currentDir, `../../bridge/src/${cliBaseName}.ts`),
124649
- import_node_path14.default.resolve(cwd, `packages/bridge/src/${cliBaseName}.ts`)
124949
+ import_node_path15.default.resolve(currentDir, `../../bridge/src/${cliBaseName}.ts`),
124950
+ import_node_path15.default.resolve(cwd, `packages/bridge/src/${cliBaseName}.ts`)
124650
124951
  ],
124651
124952
  existsSync3
124652
124953
  );
@@ -124667,7 +124968,7 @@ function firstExistingPath(paths, existsSync3) {
124667
124968
  function shouldRunExecPathAsNode(execPath, options) {
124668
124969
  if (typeof options.isElectron === "boolean") return options.isElectron;
124669
124970
  if (process.versions.electron) return true;
124670
- return import_node_path14.default.basename(execPath).toLowerCase().includes("electron");
124971
+ return import_node_path15.default.basename(execPath).toLowerCase().includes("electron");
124671
124972
  }
124672
124973
  function uniqueServerName(serverName, usedNames) {
124673
124974
  if (!usedNames.has(serverName)) return serverName;
@@ -124707,12 +125008,12 @@ function toolPolicies(connection) {
124707
125008
  // src/localMcpStore.ts
124708
125009
  init_cjs_shims();
124709
125010
  var import_node_fs8 = __toESM(require("fs"), 1);
124710
- var import_node_path15 = __toESM(require("path"), 1);
125011
+ var import_node_path16 = __toESM(require("path"), 1);
124711
125012
  var logger21 = createModuleLogger("bridge.localMcpStore");
124712
125013
  var LocalMcpStore = class {
124713
125014
  constructor(dataDir) {
124714
125015
  this.dataDir = dataDir;
124715
- this.filePath = import_node_path15.default.join(dataDir, LOCAL_MCP_CONNECTIONS_FILENAME);
125016
+ this.filePath = import_node_path16.default.join(dataDir, LOCAL_MCP_CONNECTIONS_FILENAME);
124716
125017
  }
124717
125018
  dataDir;
124718
125019
  filePath;
@@ -124744,12 +125045,12 @@ function isNodeErrorCode(error51, code) {
124744
125045
  // src/localSkillStore.ts
124745
125046
  init_cjs_shims();
124746
125047
  var import_node_fs9 = __toESM(require("fs"), 1);
124747
- var import_node_path16 = __toESM(require("path"), 1);
125048
+ var import_node_path17 = __toESM(require("path"), 1);
124748
125049
  var logger22 = createModuleLogger("bridge.localSkillStore");
124749
125050
  var LocalSkillStore = class {
124750
125051
  constructor(dataDir, runtimeScope = {}) {
124751
125052
  this.dataDir = dataDir;
124752
- this.filePath = import_node_path16.default.join(dataDir, LOCAL_SKILLS_FILENAME);
125053
+ this.filePath = import_node_path17.default.join(dataDir, LOCAL_SKILLS_FILENAME);
124753
125054
  this.runtimeScope = runtimeScope;
124754
125055
  }
124755
125056
  dataDir;
@@ -125509,9 +125810,9 @@ var ServerConnector = class {
125509
125810
 
125510
125811
  // src/contextDumper.ts
125511
125812
  init_cjs_shims();
125512
- var import_promises4 = __toESM(require("fs/promises"), 1);
125813
+ var import_promises5 = __toESM(require("fs/promises"), 1);
125513
125814
  var import_node_os9 = __toESM(require("os"), 1);
125514
- var import_node_path17 = __toESM(require("path"), 1);
125815
+ var import_node_path18 = __toESM(require("path"), 1);
125515
125816
  var sdk3 = __toESM(require("@anthropic-ai/claude-agent-sdk"), 1);
125516
125817
  var logger25 = createModuleLogger("bridge.contextDumper");
125517
125818
  var TRUNCATE_THRESHOLD = 5e4;
@@ -125541,11 +125842,11 @@ function cwdToProjectSlug(cwd) {
125541
125842
  }
125542
125843
  function resolveJsonlPathInProjectsDir(projectsDir, sessionId, cwd) {
125543
125844
  const slug = cwdToProjectSlug(cwd);
125544
- return import_node_path17.default.join(projectsDir, slug, `${sessionId}.jsonl`);
125845
+ return import_node_path18.default.join(projectsDir, slug, `${sessionId}.jsonl`);
125545
125846
  }
125546
125847
  function resolveProjectDirInProjectsDir(projectsDir, cwd) {
125547
125848
  const slug = cwdToProjectSlug(cwd);
125548
- return import_node_path17.default.join(projectsDir, slug);
125849
+ return import_node_path18.default.join(projectsDir, slug);
125549
125850
  }
125550
125851
  function errorCode(e) {
125551
125852
  if (e instanceof Error && "code" in e) {
@@ -125556,7 +125857,7 @@ function errorCode(e) {
125556
125857
  }
125557
125858
  async function isReadableFile(filePath) {
125558
125859
  try {
125559
- const stat3 = await import_promises4.default.stat(filePath);
125860
+ const stat3 = await import_promises5.default.stat(filePath);
125560
125861
  return stat3.isFile();
125561
125862
  } catch (e) {
125562
125863
  const code = errorCode(e);
@@ -125571,7 +125872,7 @@ function uniquePaths(paths) {
125571
125872
  for (const p of paths) {
125572
125873
  const trimmed = p.trim();
125573
125874
  if (!trimmed) continue;
125574
- const key = import_node_path17.default.normalize(trimmed);
125875
+ const key = import_node_path18.default.normalize(trimmed);
125575
125876
  if (seen.has(key)) continue;
125576
125877
  seen.add(key);
125577
125878
  out.push(trimmed);
@@ -125587,7 +125888,7 @@ function inferAhchatUserAgentConfigDir(workdir) {
125587
125888
  const userSlug = afterMarker.split("/").find(Boolean);
125588
125889
  if (!userSlug) return null;
125589
125890
  const userDataDir2 = normalized.slice(0, markerIndex + marker.length + userSlug.length);
125590
- return import_node_path17.default.join(import_node_path17.default.normalize(userDataDir2), "agent-config");
125891
+ return import_node_path18.default.join(import_node_path18.default.normalize(userDataDir2), "agent-config");
125591
125892
  }
125592
125893
  function inferredAgentConfigDirsFromWorkdirs(workdirs) {
125593
125894
  return uniquePaths(workdirs.map((workdir) => inferAhchatUserAgentConfigDir(workdir) ?? ""));
@@ -125600,19 +125901,19 @@ function claudeProjectsDirs(opts) {
125600
125901
  ]);
125601
125902
  return uniquePaths([
125602
125903
  ...configDirs.flatMap((configDir) => [
125603
- import_node_path17.default.join(configDir, "api-key-agents", opts.agentId, "projects"),
125604
- import_node_path17.default.join(configDir, "projects")
125904
+ import_node_path18.default.join(configDir, "api-key-agents", opts.agentId, "projects"),
125905
+ import_node_path18.default.join(configDir, "projects")
125605
125906
  ]),
125606
- import_node_path17.default.join(import_node_os9.default.homedir(), ".claude", "projects")
125907
+ import_node_path18.default.join(import_node_os9.default.homedir(), ".claude", "projects")
125607
125908
  ]);
125608
125909
  }
125609
125910
  function fallbackBridgeWorkspacePath(requestedCwd, workspacesDir, fallbackSegment) {
125610
125911
  const suffix = extractAhchatWorkspaceSuffix(requestedCwd);
125611
- if (suffix) return import_node_path17.default.join(workspacesDir, suffix);
125912
+ if (suffix) return import_node_path18.default.join(workspacesDir, suffix);
125612
125913
  const normalized = requestedCwd.trim();
125613
- const basename = normalized ? import_node_path17.default.basename(import_node_path17.default.normalize(normalized)) : "";
125614
- const segment = basename && basename !== "." && basename !== import_node_path17.default.sep ? basename : fallbackSegment;
125615
- return import_node_path17.default.join(workspacesDir, segment);
125914
+ const basename = normalized ? import_node_path18.default.basename(import_node_path18.default.normalize(normalized)) : "";
125915
+ const segment = basename && basename !== "." && basename !== import_node_path18.default.sep ? basename : fallbackSegment;
125916
+ return import_node_path18.default.join(workspacesDir, segment);
125616
125917
  }
125617
125918
  function cwdCandidatesForBridge(requestedCwd, opts) {
125618
125919
  const candidates = [requestedCwd];
@@ -125648,11 +125949,11 @@ async function resolveDumpWorkdir(requestedCwd, opts) {
125648
125949
  return remapped.path;
125649
125950
  }
125650
125951
  try {
125651
- await import_promises4.default.mkdir(requestedCwd, { recursive: true });
125952
+ await import_promises5.default.mkdir(requestedCwd, { recursive: true });
125652
125953
  return requestedCwd;
125653
125954
  } catch (e) {
125654
125955
  const fallback = fallbackBridgeWorkspacePath(requestedCwd, opts.workspacesDir, opts.fallbackSegment);
125655
- if (import_node_path17.default.normalize(fallback) === import_node_path17.default.normalize(requestedCwd)) throw e;
125956
+ if (import_node_path18.default.normalize(fallback) === import_node_path18.default.normalize(requestedCwd)) throw e;
125656
125957
  logger25.warn("Dump workdir inaccessible; using local Bridge workspace fallback", {
125657
125958
  agentId: opts.agentId,
125658
125959
  requested: requestedCwd,
@@ -125666,7 +125967,7 @@ async function findJsonlInClaudeProjects(sessionId, projectsDirs) {
125666
125967
  for (const projectsDir of projectsDirs) {
125667
125968
  let dirs;
125668
125969
  try {
125669
- dirs = await import_promises4.default.readdir(projectsDir, { withFileTypes: true });
125970
+ dirs = await import_promises5.default.readdir(projectsDir, { withFileTypes: true });
125670
125971
  } catch (e) {
125671
125972
  const code = errorCode(e);
125672
125973
  if (code === "ENOENT" || code === "ENOTDIR") continue;
@@ -125675,7 +125976,7 @@ async function findJsonlInClaudeProjects(sessionId, projectsDirs) {
125675
125976
  }
125676
125977
  for (const dir of dirs) {
125677
125978
  if (!dir.isDirectory()) continue;
125678
- const candidate = import_node_path17.default.join(projectsDir, dir.name, `${sessionId}.jsonl`);
125979
+ const candidate = import_node_path18.default.join(projectsDir, dir.name, `${sessionId}.jsonl`);
125679
125980
  if (await isReadableFile(candidate)) return candidate;
125680
125981
  }
125681
125982
  }
@@ -125684,7 +125985,7 @@ async function findJsonlInClaudeProjects(sessionId, projectsDirs) {
125684
125985
  async function latestJsonlInProjectDir(projectDir) {
125685
125986
  let entries;
125686
125987
  try {
125687
- entries = await import_promises4.default.readdir(projectDir, { withFileTypes: true });
125988
+ entries = await import_promises5.default.readdir(projectDir, { withFileTypes: true });
125688
125989
  } catch (e) {
125689
125990
  const code = errorCode(e);
125690
125991
  if (code === "ENOENT" || code === "ENOTDIR") return null;
@@ -125694,15 +125995,15 @@ async function latestJsonlInProjectDir(projectDir) {
125694
125995
  let latest = null;
125695
125996
  for (const entry of entries) {
125696
125997
  if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
125697
- const jsonlPath = import_node_path17.default.join(projectDir, entry.name);
125998
+ const jsonlPath = import_node_path18.default.join(projectDir, entry.name);
125698
125999
  let stat3;
125699
126000
  try {
125700
- stat3 = await import_promises4.default.stat(jsonlPath);
126001
+ stat3 = await import_promises5.default.stat(jsonlPath);
125701
126002
  } catch (e) {
125702
126003
  logger25.warn("Discovered JSONL stat failed", { jsonlPath, error: e });
125703
126004
  continue;
125704
126005
  }
125705
- const sessionId = import_node_path17.default.basename(entry.name, ".jsonl");
126006
+ const sessionId = import_node_path18.default.basename(entry.name, ".jsonl");
125706
126007
  const discovered = { sessionId, jsonlPath, lastModified: stat3.mtimeMs };
125707
126008
  if (!latest || discovered.lastModified > latest.lastModified) {
125708
126009
  latest = discovered;
@@ -125711,8 +126012,8 @@ async function latestJsonlInProjectDir(projectDir) {
125711
126012
  return latest;
125712
126013
  }
125713
126014
  function isAgentIsolatedProjectsDir(projectsDir, agentId) {
125714
- const normalized = import_node_path17.default.normalize(projectsDir).toLowerCase();
125715
- const marker = import_node_path17.default.normalize(import_node_path17.default.join("api-key-agents", agentId, "projects")).toLowerCase();
126015
+ const normalized = import_node_path18.default.normalize(projectsDir).toLowerCase();
126016
+ const marker = import_node_path18.default.normalize(import_node_path18.default.join("api-key-agents", agentId, "projects")).toLowerCase();
125716
126017
  return normalized.endsWith(marker);
125717
126018
  }
125718
126019
  async function discoverLatestJsonlForScope(opts) {
@@ -125731,7 +126032,7 @@ async function discoverLatestJsonlForScope(opts) {
125731
126032
  if (!isAgentIsolatedProjectsDir(projectsDir, opts.agentId)) continue;
125732
126033
  let dirs;
125733
126034
  try {
125734
- dirs = await import_promises4.default.readdir(projectsDir, { withFileTypes: true });
126035
+ dirs = await import_promises5.default.readdir(projectsDir, { withFileTypes: true });
125735
126036
  } catch (e) {
125736
126037
  const code = errorCode(e);
125737
126038
  if (code === "ENOENT" || code === "ENOTDIR") continue;
@@ -125740,7 +126041,7 @@ async function discoverLatestJsonlForScope(opts) {
125740
126041
  }
125741
126042
  for (const dir of dirs) {
125742
126043
  if (!dir.isDirectory()) continue;
125743
- const latest = await latestJsonlInProjectDir(import_node_path17.default.join(projectsDir, dir.name));
126044
+ const latest = await latestJsonlInProjectDir(import_node_path18.default.join(projectsDir, dir.name));
125744
126045
  if (latest) discovered.push(latest);
125745
126046
  }
125746
126047
  }
@@ -125777,7 +126078,7 @@ function friendlyScopeError(e) {
125777
126078
  }
125778
126079
  var RENDERABLE_TYPES = /* @__PURE__ */ new Set(["user", "assistant", "system", "attachment"]);
125779
126080
  async function readJsonlEntries(filePath) {
125780
- const raw = await import_promises4.default.readFile(filePath, "utf-8");
126081
+ const raw = await import_promises5.default.readFile(filePath, "utf-8");
125781
126082
  const entries = [];
125782
126083
  for (const line of raw.split("\n")) {
125783
126084
  const trimmed = line.trim();
@@ -126133,8 +126434,8 @@ async function dumpAgentContext(agentId, deps) {
126133
126434
  agentId,
126134
126435
  workdirOverrideStore: deps.workdirOverrideStore
126135
126436
  });
126136
- const dumpDir = import_node_path17.default.join(localWorkdir, "sessioninfo");
126137
- await import_promises4.default.mkdir(dumpDir, { recursive: true });
126437
+ const dumpDir = import_node_path18.default.join(localWorkdir, "sessioninfo");
126438
+ await import_promises5.default.mkdir(dumpDir, { recursive: true });
126138
126439
  const groupWorkdirs = deps.groupRegistry?.getMyGroups(agentId).map((group) => group.workingDirectory) ?? [];
126139
126440
  const inferredAgentConfigDirs = inferredAgentConfigDirsFromWorkdirs([
126140
126441
  workdir,
@@ -126212,7 +126513,7 @@ async function dumpAgentContext(agentId, deps) {
126212
126513
  projectsDirs,
126213
126514
  sessionStore: deps.sessionStore
126214
126515
  });
126215
- resolvedSessionId = recovered ? import_node_path17.default.basename(jsonlPath, ".jsonl") : resolvedSessionId;
126516
+ resolvedSessionId = recovered ? import_node_path18.default.basename(jsonlPath, ".jsonl") : resolvedSessionId;
126216
126517
  if (recovered) {
126217
126518
  try {
126218
126519
  const info2 = await sdk3.getSessionInfo(resolvedSessionId);
@@ -126261,10 +126562,10 @@ async function dumpAgentContext(agentId, deps) {
126261
126562
  jsonlPath
126262
126563
  });
126263
126564
  const filename = scopeFilename(agent.name, scopeKey2, groupName);
126264
- const filePath = import_node_path17.default.join(dumpDir, filename);
126265
- await import_promises4.default.writeFile(filePath, html, "utf-8");
126565
+ const filePath = import_node_path18.default.join(dumpDir, filename);
126566
+ await import_promises5.default.writeFile(filePath, html, "utf-8");
126266
126567
  dumpedFiles.push(filename);
126267
- const stat3 = await import_promises4.default.stat(filePath);
126568
+ const stat3 = await import_promises5.default.stat(filePath);
126268
126569
  logger25.info("Scope context dumped", {
126269
126570
  agentId,
126270
126571
  scopeKey: scopeKey2,
@@ -126305,9 +126606,9 @@ async function dumpAgentContext(agentId, deps) {
126305
126606
  init_cjs_shims();
126306
126607
  var import_node_child_process4 = require("child_process");
126307
126608
  var import_node_crypto4 = __toESM(require("crypto"), 1);
126308
- var import_promises5 = __toESM(require("fs/promises"), 1);
126609
+ var import_promises6 = __toESM(require("fs/promises"), 1);
126309
126610
  var import_node_os10 = __toESM(require("os"), 1);
126310
- var import_node_path18 = __toESM(require("path"), 1);
126611
+ var import_node_path19 = __toESM(require("path"), 1);
126311
126612
  var import_node_util2 = require("util");
126312
126613
  var logger26 = createModuleLogger("bridge.clipboardFiles");
126313
126614
  var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
@@ -126318,28 +126619,28 @@ function isRecord5(value) {
126318
126619
  }
126319
126620
  function normalizeLocalPath(targetPath) {
126320
126621
  const trimmed = targetPath.trim();
126321
- const expanded = trimmed === "~" || trimmed.startsWith("~/") || trimmed.startsWith("~\\") ? import_node_path18.default.join(import_node_os10.default.homedir(), trimmed.slice(2)) : trimmed;
126322
- return import_node_path18.default.normalize(import_node_path18.default.resolve(expanded));
126622
+ const expanded = trimmed === "~" || trimmed.startsWith("~/") || trimmed.startsWith("~\\") ? import_node_path19.default.join(import_node_os10.default.homedir(), trimmed.slice(2)) : trimmed;
126623
+ return import_node_path19.default.normalize(import_node_path19.default.resolve(expanded));
126323
126624
  }
126324
126625
  function normalizeClipboardIdentityKey(value) {
126325
126626
  return process.platform === "win32" ? value.toLowerCase() : value;
126326
126627
  }
126327
126628
  async function resolveClipboardPathKey(resolvedPath) {
126328
126629
  try {
126329
- return normalizeClipboardIdentityKey(await import_promises5.default.realpath(resolvedPath));
126630
+ return normalizeClipboardIdentityKey(await import_promises6.default.realpath(resolvedPath));
126330
126631
  } catch (e) {
126331
126632
  logger26.debug("Clipboard realpath read skipped", { error: e, path: resolvedPath });
126332
126633
  return normalizeClipboardIdentityKey(resolvedPath);
126333
126634
  }
126334
126635
  }
126335
126636
  function looksLikeWindowsShortFileName(fileName) {
126336
- return /~\d/i.test(import_node_path18.default.basename(fileName));
126637
+ return /~\d/i.test(import_node_path19.default.basename(fileName));
126337
126638
  }
126338
126639
  function fileContentHash(buffer) {
126339
126640
  return import_node_crypto4.default.createHash("sha256").update(buffer).digest("hex");
126340
126641
  }
126341
126642
  function mimeTypeForFileName(fileName) {
126342
- const ext = import_node_path18.default.extname(fileName).toLowerCase();
126643
+ const ext = import_node_path19.default.extname(fileName).toLowerCase();
126343
126644
  if (ext === ".jpg" || ext === ".jpeg") return "image/jpeg";
126344
126645
  if (ext === ".png") return "image/png";
126345
126646
  if (ext === ".webp") return "image/webp";
@@ -126404,7 +126705,7 @@ async function readWindowsClipboardPathCandidates() {
126404
126705
  }
126405
126706
  }
126406
126707
  async function filePayloadFromPath(resolvedPath) {
126407
- const stat3 = await import_promises5.default.stat(resolvedPath);
126708
+ const stat3 = await import_promises6.default.stat(resolvedPath);
126408
126709
  if (!stat3.isFile()) return null;
126409
126710
  if (stat3.size > MAX_CLIPBOARD_FILE_SIZE) {
126410
126711
  logger26.warn("Clipboard file skipped because it is too large", {
@@ -126413,10 +126714,10 @@ async function filePayloadFromPath(resolvedPath) {
126413
126714
  });
126414
126715
  return null;
126415
126716
  }
126416
- const buffer = await import_promises5.default.readFile(resolvedPath);
126717
+ const buffer = await import_promises6.default.readFile(resolvedPath);
126417
126718
  const mimeType = mimeTypeForFileName(resolvedPath);
126418
126719
  return {
126419
- fileName: import_node_path18.default.basename(resolvedPath),
126720
+ fileName: import_node_path19.default.basename(resolvedPath),
126420
126721
  mimeType,
126421
126722
  contentBase64: buffer.toString("base64"),
126422
126723
  size: buffer.length,
@@ -126440,7 +126741,7 @@ async function readClipboardFiles() {
126440
126741
  const contentIndexes = /* @__PURE__ */ new Map();
126441
126742
  for (const resolvedPath of pathCandidates) {
126442
126743
  try {
126443
- const stat3 = await import_promises5.default.stat(resolvedPath);
126744
+ const stat3 = await import_promises6.default.stat(resolvedPath);
126444
126745
  if (stat3.isDirectory()) {
126445
126746
  skippedDirectoryCount += 1;
126446
126747
  continue;
@@ -126490,8 +126791,8 @@ async function readClipboardFiles() {
126490
126791
 
126491
126792
  // src/listDir.ts
126492
126793
  init_cjs_shims();
126493
- var import_promises6 = __toESM(require("fs/promises"), 1);
126494
- var import_node_path19 = __toESM(require("path"), 1);
126794
+ var import_promises7 = __toESM(require("fs/promises"), 1);
126795
+ var import_node_path20 = __toESM(require("path"), 1);
126495
126796
  var logger27 = createModuleLogger("bridge.listDir");
126496
126797
  function shouldIncludeEntry(name) {
126497
126798
  if (!name.startsWith(".")) return true;
@@ -126500,16 +126801,16 @@ function shouldIncludeEntry(name) {
126500
126801
  async function listDirectoryEntries(dirPath) {
126501
126802
  const resolvedDirPath = resolveUserPath(dirPath);
126502
126803
  logger27.info("listDirectoryEntries start", { path: dirPath, resolvedPath: resolvedDirPath });
126503
- const raw = await import_promises6.default.readdir(resolvedDirPath, { withFileTypes: true });
126804
+ const raw = await import_promises7.default.readdir(resolvedDirPath, { withFileTypes: true });
126504
126805
  const entries = [];
126505
126806
  for (const entry of raw) {
126506
126807
  if (!shouldIncludeEntry(entry.name)) continue;
126507
- const fullPath = import_node_path19.default.join(resolvedDirPath, entry.name);
126808
+ const fullPath = import_node_path20.default.join(resolvedDirPath, entry.name);
126508
126809
  const isDir = entry.isDirectory();
126509
126810
  let size;
126510
126811
  let mtime;
126511
126812
  try {
126512
- const stat3 = await import_promises6.default.stat(fullPath);
126813
+ const stat3 = await import_promises7.default.stat(fullPath);
126513
126814
  mtime = stat3.mtime.toISOString();
126514
126815
  if (!isDir) size = stat3.size;
126515
126816
  } catch (statErr) {
@@ -126538,20 +126839,20 @@ function normalizeRelativePath(relativePath) {
126538
126839
  return normalized;
126539
126840
  }
126540
126841
  function ensureInsideBase(baseDir, targetPath) {
126541
- const relative = import_node_path19.default.relative(baseDir, targetPath);
126542
- if (relative.startsWith("..") || import_node_path19.default.isAbsolute(relative)) {
126842
+ const relative = import_node_path20.default.relative(baseDir, targetPath);
126843
+ if (relative.startsWith("..") || import_node_path20.default.isAbsolute(relative)) {
126543
126844
  throw new Error("path is outside working directory");
126544
126845
  }
126545
126846
  }
126546
126847
  function ensureNotBaseDir(baseDir, targetPath) {
126547
- if (import_node_path19.default.relative(baseDir, targetPath) === "") {
126848
+ if (import_node_path20.default.relative(baseDir, targetPath) === "") {
126548
126849
  throw new Error("refusing to delete working directory root");
126549
126850
  }
126550
126851
  }
126551
126852
  async function ensureRealPathInsideBase(baseDir, targetPath) {
126552
126853
  const [realBase, realTarget] = await Promise.all([
126553
- import_promises6.default.realpath(baseDir),
126554
- import_promises6.default.realpath(targetPath)
126854
+ import_promises7.default.realpath(baseDir),
126855
+ import_promises7.default.realpath(targetPath)
126555
126856
  ]);
126556
126857
  ensureInsideBase(realBase, realTarget);
126557
126858
  return realTarget;
@@ -126559,11 +126860,11 @@ async function ensureRealPathInsideBase(baseDir, targetPath) {
126559
126860
  async function writeWorkdirFile(opts) {
126560
126861
  const resolvedBaseDir = resolveUserPath(opts.baseDir);
126561
126862
  const safeRelativePath = normalizeRelativePath(opts.relativePath);
126562
- const targetPath = import_node_path19.default.resolve(resolvedBaseDir, safeRelativePath);
126863
+ const targetPath = import_node_path20.default.resolve(resolvedBaseDir, safeRelativePath);
126563
126864
  ensureInsideBase(resolvedBaseDir, targetPath);
126564
126865
  const buffer = Buffer.from(opts.contentBase64, "base64");
126565
- await import_promises6.default.mkdir(import_node_path19.default.dirname(targetPath), { recursive: true });
126566
- await import_promises6.default.writeFile(targetPath, buffer, { flag: opts.overwrite ? "w" : "wx" });
126866
+ await import_promises7.default.mkdir(import_node_path20.default.dirname(targetPath), { recursive: true });
126867
+ await import_promises7.default.writeFile(targetPath, buffer, { flag: opts.overwrite ? "w" : "wx" });
126567
126868
  logger27.info("writeWorkdirFile ok", {
126568
126869
  baseDir: opts.baseDir,
126569
126870
  path: targetPath,
@@ -126575,12 +126876,12 @@ async function writeWorkdirFile(opts) {
126575
126876
  async function readWorkdirFile(filePath, baseDir) {
126576
126877
  const resolvedPath = resolveUserPath(filePath);
126577
126878
  const safePath = baseDir ? await ensureRealPathInsideBase(resolveUserPath(baseDir), resolvedPath) : resolvedPath;
126578
- const stat3 = await import_promises6.default.stat(safePath);
126879
+ const stat3 = await import_promises7.default.stat(safePath);
126579
126880
  if (!stat3.isFile()) throw new Error("path is not a file");
126580
- const buffer = await import_promises6.default.readFile(safePath);
126881
+ const buffer = await import_promises7.default.readFile(safePath);
126581
126882
  logger27.info("readWorkdirFile ok", { path: filePath, baseDir, resolvedPath: safePath, size: buffer.length });
126582
126883
  return {
126583
- fileName: import_node_path19.default.basename(safePath),
126884
+ fileName: import_node_path20.default.basename(safePath),
126584
126885
  contentBase64: buffer.toString("base64"),
126585
126886
  size: buffer.length
126586
126887
  };
@@ -126590,9 +126891,9 @@ async function allocateTrashPath(trashDir, name) {
126590
126891
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
126591
126892
  for (let index = 0; index < 1e3; index += 1) {
126592
126893
  const suffix = index === 0 ? "" : `-${index}`;
126593
- const candidate = import_node_path19.default.join(trashDir, `${stamp}-${safeName}${suffix}`);
126894
+ const candidate = import_node_path20.default.join(trashDir, `${stamp}-${safeName}${suffix}`);
126594
126895
  try {
126595
- await import_promises6.default.lstat(candidate);
126896
+ await import_promises7.default.lstat(candidate);
126596
126897
  } catch (e) {
126597
126898
  if (e instanceof Error && "code" in e && e.code === "ENOENT") return candidate;
126598
126899
  throw e;
@@ -126608,15 +126909,15 @@ async function trashWorkdirPath(opts) {
126608
126909
  const resolvedBaseDir = resolveUserPath(opts.baseDir);
126609
126910
  const resolvedTargetPath = resolveUserPath(opts.targetPath);
126610
126911
  const [realBase, realTarget] = await Promise.all([
126611
- import_promises6.default.realpath(resolvedBaseDir),
126612
- import_promises6.default.realpath(resolvedTargetPath)
126912
+ import_promises7.default.realpath(resolvedBaseDir),
126913
+ import_promises7.default.realpath(resolvedTargetPath)
126613
126914
  ]);
126614
126915
  ensureInsideBase(realBase, realTarget);
126615
126916
  ensureNotBaseDir(realBase, realTarget);
126616
- const trashDir = import_node_path19.default.join(resolvedBaseDir, ".ahchat-trash");
126617
- await import_promises6.default.mkdir(trashDir, { recursive: true });
126618
- const trashedPath = await allocateTrashPath(trashDir, import_node_path19.default.basename(resolvedTargetPath));
126619
- await import_promises6.default.rename(resolvedTargetPath, trashedPath);
126917
+ const trashDir = import_node_path20.default.join(resolvedBaseDir, ".ahchat-trash");
126918
+ await import_promises7.default.mkdir(trashDir, { recursive: true });
126919
+ const trashedPath = await allocateTrashPath(trashDir, import_node_path20.default.basename(resolvedTargetPath));
126920
+ await import_promises7.default.rename(resolvedTargetPath, trashedPath);
126620
126921
  logger27.info("trashWorkdirPath ok", {
126621
126922
  path: opts.targetPath,
126622
126923
  baseDir: opts.baseDir,
@@ -126629,7 +126930,7 @@ async function trashWorkdirPath(opts) {
126629
126930
  // src/logScanner.ts
126630
126931
  init_cjs_shims();
126631
126932
  var import_node_fs10 = __toESM(require("fs"), 1);
126632
- var import_node_path20 = __toESM(require("path"), 1);
126933
+ var import_node_path21 = __toESM(require("path"), 1);
126633
126934
  var import_node_os11 = __toESM(require("os"), 1);
126634
126935
  var import_node_readline = __toESM(require("readline"), 1);
126635
126936
  var logger28 = createModuleLogger("bridge.logScanner");
@@ -126644,10 +126945,10 @@ function listLogFiles(logsDir, baseName) {
126644
126945
  }
126645
126946
  const escapedBaseName = baseName.replace(".", "\\.");
126646
126947
  const pattern = new RegExp(`^${escapedBaseName}(?:[.-].+)?$`);
126647
- return names.filter((n) => pattern.test(n)).map((n) => import_node_path20.default.join(logsDir, n));
126948
+ return names.filter((n) => pattern.test(n)).map((n) => import_node_path21.default.join(logsDir, n));
126648
126949
  }
126649
126950
  async function scanFile(filePath, source, filter, state) {
126650
- const file2 = import_node_path20.default.basename(filePath);
126951
+ const file2 = import_node_path21.default.basename(filePath);
126651
126952
  const stream = import_node_fs10.default.createReadStream(filePath, { encoding: "utf-8" });
126652
126953
  const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
126653
126954
  let lineNum = 0;
@@ -126691,7 +126992,7 @@ async function scanLocalLogs(logsDir, baseName, filter) {
126691
126992
  };
126692
126993
  }
126693
126994
  async function scanBridgeLogs(filter) {
126694
- const logDir = import_node_path20.default.join(loadBridgeConfig().dataDir || import_node_path20.default.join(import_node_os11.default.homedir(), ".ahchat"), "logs");
126995
+ const logDir = import_node_path21.default.join(loadBridgeConfig().dataDir || import_node_path21.default.join(import_node_os11.default.homedir(), ".ahchat"), "logs");
126695
126996
  logger28.info("scanBridgeLogs start", {
126696
126997
  logDir,
126697
126998
  startIso: filter.startIso,
@@ -126712,8 +127013,8 @@ async function scanBridgeLogs(filter) {
126712
127013
  // src/logUploader.ts
126713
127014
  init_cjs_shims();
126714
127015
  var import_node_fs11 = __toESM(require("fs"), 1);
126715
- var import_promises7 = __toESM(require("fs/promises"), 1);
126716
- var import_node_path21 = __toESM(require("path"), 1);
127016
+ var import_promises8 = __toESM(require("fs/promises"), 1);
127017
+ var import_node_path22 = __toESM(require("path"), 1);
126717
127018
  var logger29 = createModuleLogger("bridge.logUploader");
126718
127019
  var STALE_RATE_LIMIT_SKIP_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
126719
127020
  var DEFAULT_LOG_UPLOAD_INTERVAL_MS = 24 * 60 * 60 * 1e3;
@@ -126757,27 +127058,27 @@ function parseUploadErrorBody(bodyText) {
126757
127058
  }
126758
127059
  }
126759
127060
  function defaultLogFile(dataDir) {
126760
- return import_node_path21.default.join(dataDir, "logs", "bridge.log");
127061
+ return import_node_path22.default.join(dataDir, "logs", "bridge.log");
126761
127062
  }
126762
127063
  function defaultCursorFile(dataDir) {
126763
- return import_node_path21.default.join(dataDir, "log-upload-cursor.json");
127064
+ return import_node_path22.default.join(dataDir, "log-upload-cursor.json");
126764
127065
  }
126765
127066
  function uploadedFileName(logFile, explicit) {
126766
127067
  const trimmed = explicit?.trim();
126767
- return trimmed || import_node_path21.default.basename(logFile);
127068
+ return trimmed || import_node_path22.default.basename(logFile);
126768
127069
  }
126769
127070
  function normalizeTarget(file2, dataDir) {
126770
127071
  const fileName = uploadedFileName(file2.logFile, file2.uploadedFileName);
126771
127072
  const safeName = fileName.replace(/[^a-zA-Z0-9._-]/g, "_");
126772
127073
  return {
126773
127074
  logFile: file2.logFile,
126774
- cursorFile: file2.cursorFile ?? import_node_path21.default.join(dataDir, `log-upload-cursor-${safeName}.json`),
127075
+ cursorFile: file2.cursorFile ?? import_node_path22.default.join(dataDir, `log-upload-cursor-${safeName}.json`),
126775
127076
  uploadedFileName: fileName
126776
127077
  };
126777
127078
  }
126778
127079
  function cursorFileForLog(dataDir, fileName) {
126779
127080
  const safeName = fileName.replace(/[^a-zA-Z0-9._-]/g, "_");
126780
- return import_node_path21.default.join(dataDir, `log-upload-cursor-${safeName}.json`);
127081
+ return import_node_path22.default.join(dataDir, `log-upload-cursor-${safeName}.json`);
126781
127082
  }
126782
127083
  function logFileFingerprint(stat3) {
126783
127084
  if (typeof stat3.dev === "number" && typeof stat3.ino === "number" && stat3.ino > 0) {
@@ -126786,11 +127087,11 @@ function logFileFingerprint(stat3) {
126786
127087
  return void 0;
126787
127088
  }
126788
127089
  async function listRotatedBridgeTargets(primary, dataDir) {
126789
- const logDir = import_node_path21.default.dirname(primary.logFile);
126790
- const baseName = import_node_path21.default.basename(primary.logFile);
127090
+ const logDir = import_node_path22.default.dirname(primary.logFile);
127091
+ const baseName = import_node_path22.default.basename(primary.logFile);
126791
127092
  let names;
126792
127093
  try {
126793
- names = await import_promises7.default.readdir(logDir);
127094
+ names = await import_promises8.default.readdir(logDir);
126794
127095
  } catch (e) {
126795
127096
  if (e instanceof Error && "code" in e && e.code === "ENOENT") return [];
126796
127097
  throw e;
@@ -126800,7 +127101,7 @@ async function listRotatedBridgeTargets(primary, dataDir) {
126800
127101
  return names.filter((name) => pattern.test(name)).sort().map((name) => {
126801
127102
  if (name === baseName) return primary;
126802
127103
  return {
126803
- logFile: import_node_path21.default.join(logDir, name),
127104
+ logFile: import_node_path22.default.join(logDir, name),
126804
127105
  cursorFile: cursorFileForLog(dataDir, name),
126805
127106
  uploadedFileName: name
126806
127107
  };
@@ -126817,7 +127118,7 @@ function safeCursor(raw) {
126817
127118
  }
126818
127119
  async function readCursor(filePath) {
126819
127120
  try {
126820
- const raw = await import_promises7.default.readFile(filePath, "utf8");
127121
+ const raw = await import_promises8.default.readFile(filePath, "utf8");
126821
127122
  return safeCursor(JSON.parse(raw));
126822
127123
  } catch (e) {
126823
127124
  if (e instanceof Error && "code" in e && e.code === "ENOENT") {
@@ -126828,8 +127129,8 @@ async function readCursor(filePath) {
126828
127129
  }
126829
127130
  }
126830
127131
  async function writeCursor(filePath, cursor) {
126831
- await import_promises7.default.mkdir(import_node_path21.default.dirname(filePath), { recursive: true });
126832
- await import_promises7.default.writeFile(filePath, JSON.stringify(cursor), "utf8");
127132
+ await import_promises8.default.mkdir(import_node_path22.default.dirname(filePath), { recursive: true });
127133
+ await import_promises8.default.writeFile(filePath, JSON.stringify(cursor), "utf8");
126833
127134
  }
126834
127135
  async function readStreamText(filePath, start) {
126835
127136
  const stream = import_node_fs11.default.createReadStream(filePath, { start, encoding: "utf8" });
@@ -127056,7 +127357,7 @@ var BridgeLogUploader = class {
127056
127357
  async readNewEntries(target, cursor) {
127057
127358
  let stat3;
127058
127359
  try {
127059
- stat3 = await import_promises7.default.stat(target.logFile);
127360
+ stat3 = await import_promises8.default.stat(target.logFile);
127060
127361
  } catch (e) {
127061
127362
  if (e instanceof Error && "code" in e && e.code === "ENOENT") {
127062
127363
  logger29.debug("Bridge log file not found for upload yet", { logFile: target.logFile });
@@ -127152,7 +127453,7 @@ var BridgeLogUploader = class {
127152
127453
  // src/skillStore.ts
127153
127454
  init_cjs_shims();
127154
127455
  var import_node_fs12 = __toESM(require("fs"), 1);
127155
- var import_node_path22 = __toESM(require("path"), 1);
127456
+ var import_node_path23 = __toESM(require("path"), 1);
127156
127457
  var logger30 = createModuleLogger("bridge.skillStore");
127157
127458
  var MANAGED_CACHE_MARKER = "<!-- ahchat-skill-cache";
127158
127459
  var SAFE_SKILL_NAME_RE = /^[a-zA-Z0-9_-]+$/;
@@ -127181,8 +127482,8 @@ var SkillStore = class {
127181
127482
  skillsDir;
127182
127483
  indexPath;
127183
127484
  constructor(dataDir) {
127184
- this.skillsDir = import_node_path22.default.join(dataDir, "skills");
127185
- this.indexPath = import_node_path22.default.join(this.skillsDir, INDEX_FILE_NAME);
127485
+ this.skillsDir = import_node_path23.default.join(dataDir, "skills");
127486
+ this.indexPath = import_node_path23.default.join(this.skillsDir, INDEX_FILE_NAME);
127186
127487
  import_node_fs12.default.mkdirSync(this.skillsDir, { recursive: true });
127187
127488
  logger30.info("SkillStore initialized", { skillsDir: this.skillsDir });
127188
127489
  }
@@ -127191,7 +127492,7 @@ var SkillStore = class {
127191
127492
  logger30.warn("Skill read: unsafe name", { name });
127192
127493
  return "";
127193
127494
  }
127194
- const filePath = import_node_path22.default.join(this.skillsDir, `${name}.md`);
127495
+ const filePath = import_node_path23.default.join(this.skillsDir, `${name}.md`);
127195
127496
  try {
127196
127497
  const content = import_node_fs12.default.readFileSync(filePath, "utf-8");
127197
127498
  logger30.info("Skill read", { name, bytes: content.length });
@@ -127219,7 +127520,7 @@ var SkillStore = class {
127219
127520
  if (!isSafeSkillName(name)) {
127220
127521
  throw new Error(`Unsafe skill name: ${name}`);
127221
127522
  }
127222
- const filePath = import_node_path22.default.join(this.skillsDir, `${name}.md`);
127523
+ const filePath = import_node_path23.default.join(this.skillsDir, `${name}.md`);
127223
127524
  const tmpPath = `${filePath}.tmp`;
127224
127525
  let existing = "";
127225
127526
  try {
@@ -127264,7 +127565,7 @@ var SkillStore = class {
127264
127565
  const content = this.readExisting(name);
127265
127566
  if (!isPrunableManagedSkillCache(content)) continue;
127266
127567
  try {
127267
- import_node_fs12.default.unlinkSync(import_node_path22.default.join(this.skillsDir, `${name}.md`));
127568
+ import_node_fs12.default.unlinkSync(import_node_path23.default.join(this.skillsDir, `${name}.md`));
127268
127569
  pruned += 1;
127269
127570
  logger30.info("Managed skill cache pruned", { name });
127270
127571
  } catch (e) {
@@ -127301,7 +127602,7 @@ var SkillStore = class {
127301
127602
  const content = this.readExisting(name);
127302
127603
  if (managedSkillCacheSource(content) !== source) continue;
127303
127604
  try {
127304
- import_node_fs12.default.unlinkSync(import_node_path22.default.join(this.skillsDir, `${name}.md`));
127605
+ import_node_fs12.default.unlinkSync(import_node_path23.default.join(this.skillsDir, `${name}.md`));
127305
127606
  pruned += 1;
127306
127607
  logger30.info("Managed skill cache pruned by source", { name, source });
127307
127608
  } catch (e) {
@@ -127325,7 +127626,7 @@ var SkillStore = class {
127325
127626
  }
127326
127627
  readExisting(name) {
127327
127628
  try {
127328
- return import_node_fs12.default.readFileSync(import_node_path22.default.join(this.skillsDir, `${name}.md`), "utf-8");
127629
+ return import_node_fs12.default.readFileSync(import_node_path23.default.join(this.skillsDir, `${name}.md`), "utf-8");
127329
127630
  } catch (e) {
127330
127631
  if (!isNotFoundError(e)) logger30.warn("Managed skill cache read failed", { name, error: e });
127331
127632
  return "";
@@ -127373,7 +127674,7 @@ function normalizeSkillIndexEntry(value) {
127373
127674
  init_cjs_shims();
127374
127675
  var childProcess = __toESM(require("child_process"), 1);
127375
127676
  var import_node_fs13 = __toESM(require("fs"), 1);
127376
- var import_node_path23 = __toESM(require("path"), 1);
127677
+ var import_node_path24 = __toESM(require("path"), 1);
127377
127678
  var logger31 = createModuleLogger("bridge.lockfile");
127378
127679
  var lockPath = null;
127379
127680
  var releaseRegistered = false;
@@ -127475,7 +127776,7 @@ function isLiveBridgeLockOwner(pid) {
127475
127776
  return false;
127476
127777
  }
127477
127778
  function acquireLock(dataDir) {
127478
- const file2 = import_node_path23.default.join(dataDir, "bridge.lock");
127779
+ const file2 = import_node_path24.default.join(dataDir, "bridge.lock");
127479
127780
  lockPath = file2;
127480
127781
  if (import_node_fs13.default.existsSync(file2)) {
127481
127782
  const raw = import_node_fs13.default.readFileSync(file2, "utf-8").trim();
@@ -127487,7 +127788,7 @@ function acquireLock(dataDir) {
127487
127788
  logger31.info("Removing stale bridge.lock", { pid, path: file2 });
127488
127789
  }
127489
127790
  }
127490
- import_node_fs13.default.mkdirSync(import_node_path23.default.dirname(file2), { recursive: true });
127791
+ import_node_fs13.default.mkdirSync(import_node_path24.default.dirname(file2), { recursive: true });
127491
127792
  import_node_fs13.default.writeFileSync(file2, String(process.pid), "utf-8");
127492
127793
  logger31.info("Acquired bridge lock", { path: file2, pid: process.pid });
127493
127794
  if (!releaseRegistered) {
@@ -127514,12 +127815,12 @@ function releaseLock() {
127514
127815
  // src/localWorkdirOverrideStore.ts
127515
127816
  init_cjs_shims();
127516
127817
  var import_node_fs14 = __toESM(require("fs"), 1);
127517
- var import_node_path24 = __toESM(require("path"), 1);
127818
+ var import_node_path25 = __toESM(require("path"), 1);
127518
127819
  var logger32 = createModuleLogger("bridge.localWorkdirOverride");
127519
127820
  var LocalWorkdirOverrideStore = class {
127520
127821
  filePath;
127521
127822
  constructor(dataDir) {
127522
- this.filePath = import_node_path24.default.join(dataDir, LOCAL_WORKDIR_OVERRIDES_FILENAME);
127823
+ this.filePath = import_node_path25.default.join(dataDir, LOCAL_WORKDIR_OVERRIDES_FILENAME);
127523
127824
  }
127524
127825
  read() {
127525
127826
  try {
@@ -127543,7 +127844,7 @@ var LocalWorkdirOverrideStore = class {
127543
127844
  const current = { version: 1, overrides: this.read() };
127544
127845
  const next = upsertLocalWorkdirOverride(current, args);
127545
127846
  import_node_fs14.default.mkdirSync(args.localWorkdir, { recursive: true });
127546
- import_node_fs14.default.mkdirSync(import_node_path24.default.dirname(this.filePath), { recursive: true });
127847
+ import_node_fs14.default.mkdirSync(import_node_path25.default.dirname(this.filePath), { recursive: true });
127547
127848
  import_node_fs14.default.writeFileSync(this.filePath, `${JSON.stringify(next, null, 2)}
127548
127849
  `, "utf8");
127549
127850
  const saved = next.overrides.find(
@@ -127968,7 +128269,7 @@ async function handleGroupArchivedPush(deps, payload) {
127968
128269
  // src/sessionStore.ts
127969
128270
  init_cjs_shims();
127970
128271
  var import_node_fs15 = __toESM(require("fs"), 1);
127971
- var import_node_path25 = __toESM(require("path"), 1);
128272
+ var import_node_path26 = __toESM(require("path"), 1);
127972
128273
  var logger35 = createModuleLogger("session.store");
127973
128274
  var SessionStore = class {
127974
128275
  filePath;
@@ -127976,8 +128277,8 @@ var SessionStore = class {
127976
128277
  cache;
127977
128278
  fingerprints;
127978
128279
  constructor(dataDir) {
127979
- this.filePath = import_node_path25.default.join(dataDir, "sessions.json");
127980
- this.fingerprintPath = import_node_path25.default.join(dataDir, "session-fingerprints.json");
128280
+ this.filePath = import_node_path26.default.join(dataDir, "sessions.json");
128281
+ this.fingerprintPath = import_node_path26.default.join(dataDir, "session-fingerprints.json");
127981
128282
  this.cache = this.loadFromDisk();
127982
128283
  this.fingerprints = this.loadMapFromDisk(this.fingerprintPath, "session fingerprints");
127983
128284
  }
@@ -128076,7 +128377,7 @@ var SessionStore = class {
128076
128377
  }
128077
128378
  saveToDisk() {
128078
128379
  try {
128079
- const dir = import_node_path25.default.dirname(this.filePath);
128380
+ const dir = import_node_path26.default.dirname(this.filePath);
128080
128381
  import_node_fs15.default.mkdirSync(dir, { recursive: true });
128081
128382
  import_node_fs15.default.writeFileSync(this.filePath, JSON.stringify(this.cache, null, 2), "utf-8");
128082
128383
  } catch (e) {
@@ -128085,7 +128386,7 @@ var SessionStore = class {
128085
128386
  }
128086
128387
  saveFingerprintsToDisk() {
128087
128388
  try {
128088
- const dir = import_node_path25.default.dirname(this.fingerprintPath);
128389
+ const dir = import_node_path26.default.dirname(this.fingerprintPath);
128089
128390
  import_node_fs15.default.mkdirSync(dir, { recursive: true });
128090
128391
  import_node_fs15.default.writeFileSync(
128091
128392
  this.fingerprintPath,
@@ -128104,7 +128405,7 @@ var SessionStore = class {
128104
128405
  // src/workdirEnsure.ts
128105
128406
  init_cjs_shims();
128106
128407
  var import_node_fs16 = __toESM(require("fs"), 1);
128107
- var import_node_path26 = __toESM(require("path"), 1);
128408
+ var import_node_path27 = __toESM(require("path"), 1);
128108
128409
  function resolveBridgeWorkdirPath(requestedPath, workspacesDir, workdirOverrideStore, target) {
128109
128410
  const overridden = target ? workdirOverrideStore?.resolvePath(requestedPath, target) : workdirOverrideStore?.resolvePath(requestedPath);
128110
128411
  if (overridden?.overridden) {
@@ -128116,15 +128417,15 @@ function ensureBridgeWorkdirExists(requestedPath, workspacesDir, workdirOverride
128116
128417
  const trimmed = requestedPath.trim();
128117
128418
  if (!trimmed) return null;
128118
128419
  const resolved = resolveBridgeWorkdirPath(trimmed, workspacesDir, workdirOverrideStore, target);
128119
- if (!import_node_path26.default.isAbsolute(resolved.path)) return { ...resolved, ensured: false };
128420
+ if (!import_node_path27.default.isAbsolute(resolved.path)) return { ...resolved, ensured: false };
128120
128421
  import_node_fs16.default.mkdirSync(resolved.path, { recursive: true });
128121
128422
  return { ...resolved, ensured: true };
128122
128423
  }
128123
128424
 
128124
128425
  // src/forkAgentFiles.ts
128125
128426
  init_cjs_shims();
128126
- var fs20 = __toESM(require("fs/promises"), 1);
128127
- var path28 = __toESM(require("path"), 1);
128427
+ var fs21 = __toESM(require("fs/promises"), 1);
128428
+ var path29 = __toESM(require("path"), 1);
128128
128429
  var logger36 = createModuleLogger("bridge.forkAgentFiles");
128129
128430
  async function forkAgentFiles(sourceAgentId, newAgentId, sourceWorkdir, newWorkdir, dataDir, sessionStore, sourceConversationId) {
128130
128431
  logger36.info("Fork file copy starting", {
@@ -128136,15 +128437,15 @@ async function forkAgentFiles(sourceAgentId, newAgentId, sourceWorkdir, newWorkd
128136
128437
  sourceConversationId
128137
128438
  });
128138
128439
  try {
128139
- const stat3 = await fs20.stat(sourceWorkdir).catch(() => null);
128440
+ const stat3 = await fs21.stat(sourceWorkdir).catch(() => null);
128140
128441
  if (stat3?.isDirectory()) {
128141
- await fs20.cp(sourceWorkdir, newWorkdir, { recursive: true });
128442
+ await fs21.cp(sourceWorkdir, newWorkdir, { recursive: true });
128142
128443
  logger36.info("Workdir copied", {
128143
128444
  from: sourceWorkdir,
128144
128445
  to: newWorkdir
128145
128446
  });
128146
128447
  } else {
128147
- await fs20.mkdir(newWorkdir, { recursive: true });
128448
+ await fs21.mkdir(newWorkdir, { recursive: true });
128148
128449
  logger36.info("Workdir created (source did not exist)", {
128149
128450
  newWorkdir
128150
128451
  });
@@ -128153,14 +128454,14 @@ async function forkAgentFiles(sourceAgentId, newAgentId, sourceWorkdir, newWorkd
128153
128454
  logger36.error("Workdir copy failed", { error: e });
128154
128455
  throw e;
128155
128456
  }
128156
- const srcNotebook = path28.join(dataDir, "agent-memory", sourceAgentId, "notebook.md");
128157
- const dstNotebookDir = path28.join(dataDir, "agent-memory", newAgentId);
128158
- const dstNotebook = path28.join(dstNotebookDir, "notebook.md");
128457
+ const srcNotebook = path29.join(dataDir, "agent-memory", sourceAgentId, "notebook.md");
128458
+ const dstNotebookDir = path29.join(dataDir, "agent-memory", newAgentId);
128459
+ const dstNotebook = path29.join(dstNotebookDir, "notebook.md");
128159
128460
  try {
128160
- const nbStat = await fs20.stat(srcNotebook).catch(() => null);
128461
+ const nbStat = await fs21.stat(srcNotebook).catch(() => null);
128161
128462
  if (nbStat?.isFile()) {
128162
- await fs20.mkdir(dstNotebookDir, { recursive: true });
128163
- await fs20.copyFile(srcNotebook, dstNotebook);
128463
+ await fs21.mkdir(dstNotebookDir, { recursive: true });
128464
+ await fs21.copyFile(srcNotebook, dstNotebook);
128164
128465
  logger36.info("Notebook copied", {
128165
128466
  from: srcNotebook,
128166
128467
  to: dstNotebook
@@ -128178,12 +128479,12 @@ async function forkAgentFiles(sourceAgentId, newAgentId, sourceWorkdir, newWorkd
128178
128479
  if (sourceSessionId) {
128179
128480
  try {
128180
128481
  const srcPath = sessionFilePath(sourceWorkdir, sourceSessionId);
128181
- const srcStat = await fs20.stat(srcPath).catch(() => null);
128482
+ const srcStat = await fs21.stat(srcPath).catch(() => null);
128182
128483
  if (srcStat?.isFile()) {
128183
128484
  const dstDir = sessionDirForCwd(newWorkdir);
128184
- await fs20.mkdir(dstDir, { recursive: true });
128185
- const dstPath = path28.join(dstDir, `${sourceSessionId}.jsonl`);
128186
- await fs20.copyFile(srcPath, dstPath);
128485
+ await fs21.mkdir(dstDir, { recursive: true });
128486
+ const dstPath = path29.join(dstDir, `${sourceSessionId}.jsonl`);
128487
+ await fs21.copyFile(srcPath, dstPath);
128187
128488
  sessionStore.set(newAgentId, { kind: "single" }, sourceSessionId);
128188
128489
  sessionCopied = true;
128189
128490
  logger36.info("Session JSONL copied and registered", {
@@ -128230,7 +128531,7 @@ async function forkAgentFiles(sourceAgentId, newAgentId, sourceWorkdir, newWorkd
128230
128531
  // src/feedbackCodexAnalyzer.ts
128231
128532
  init_cjs_shims();
128232
128533
  var import_node_child_process5 = require("child_process");
128233
- var import_node_path27 = __toESM(require("path"), 1);
128534
+ var import_node_path28 = __toESM(require("path"), 1);
128234
128535
  var logger37 = createModuleLogger("feedbackCodexAnalyzer");
128235
128536
  var DEFAULT_TIMEOUT_MS2 = 10 * 60 * 1e3;
128236
128537
  var MAX_OUTPUT_BYTES = 2 * 1024 * 1024;
@@ -128255,12 +128556,12 @@ function resolveFeedbackCodexOptions(defaultWorkdir, env2 = process.env) {
128255
128556
  const logDataDir = readOptionalEnv("AHCHAT_FEEDBACK_LOG_DATA_DIR", env2) ?? DEFAULT_LOG_DATA_DIR;
128256
128557
  return {
128257
128558
  executable: readOptionalEnv("AHCHAT_FEEDBACK_CODEX_EXECUTABLE", env2) ?? readOptionalEnv("CODEX_EXECUTABLE", env2) ?? "codex",
128258
- workdir: import_node_path27.default.resolve(readOptionalEnv("AHCHAT_FEEDBACK_CODEX_WORKDIR", env2) ?? defaultWorkdir),
128559
+ workdir: import_node_path28.default.resolve(readOptionalEnv("AHCHAT_FEEDBACK_CODEX_WORKDIR", env2) ?? defaultWorkdir),
128259
128560
  model: readOptionalEnv("AHCHAT_FEEDBACK_CODEX_MODEL", env2),
128260
128561
  timeoutMs: readPositiveIntEnv("AHCHAT_FEEDBACK_CODEX_TIMEOUT_MS", DEFAULT_TIMEOUT_MS2, env2),
128261
128562
  logSshTarget: readOptionalEnv("AHCHAT_FEEDBACK_LOG_SSH_TARGET", env2) ?? DEFAULT_LOG_SSH_TARGET,
128262
128563
  logDataDir,
128263
- logServerLogDir: readOptionalEnv("AHCHAT_FEEDBACK_LOG_SERVER_LOG_DIR", env2) ?? import_node_path27.default.posix.join(logDataDir, "logs"),
128564
+ logServerLogDir: readOptionalEnv("AHCHAT_FEEDBACK_LOG_SERVER_LOG_DIR", env2) ?? import_node_path28.default.posix.join(logDataDir, "logs"),
128264
128565
  logUploadTable: readOptionalEnv("AHCHAT_FEEDBACK_LOG_UPLOAD_TABLE", env2) ?? DEFAULT_LOG_UPLOAD_TABLE
128265
128566
  };
128266
128567
  }
@@ -128453,7 +128754,7 @@ function buildFeedbackAnalysisPrompt(payload, options, attachments) {
128453
128754
  - \u751F\u4EA7\u65E5\u5FD7\u76EE\u6807\uFF1A${options.logSshTarget}
128454
128755
  - AHChat \u6570\u636E\u76EE\u5F55\uFF1A${options.logDataDir}
128455
128756
  - \u670D\u52A1\u7AEF\u65E5\u5FD7\u76EE\u5F55\uFF1A${options.logServerLogDir}
128456
- - Bridge \u4E0A\u4F20\u65E5\u5FD7\u6570\u636E\u5E93\uFF1A${import_node_path27.default.posix.join(options.logDataDir, "data.db")}
128757
+ - Bridge \u4E0A\u4F20\u65E5\u5FD7\u6570\u636E\u5E93\uFF1A${import_node_path28.default.posix.join(options.logDataDir, "data.db")}
128457
128758
  - \u4E0A\u4F20\u65E5\u5FD7\u8868\uFF1A${options.logUploadTable}
128458
128759
  - \u5982\u679C\u76EE\u6807\u673A\u5668\u4E0A\u7684\u5B9A\u65F6\u4EFB\u52A1\u6216\u670D\u52A1\u914D\u7F6E\u663E\u793A\u65E5\u5FD7\u76EE\u5F55\u4E0D\u540C\uFF0C\u4EE5\u5B9E\u9645\u914D\u7F6E\u4E3A\u51C6\u3002
128459
128760
  - \u53EA\u505A\u53EA\u8BFB\u67E5\u8BE2\uFF1B\u4E0D\u8981\u590D\u5236\u6570\u636E\u5E93\uFF1B\u53EF\u7528 ssh \u5230\u76EE\u6807\u673A\u5668\u540E\u901A\u8FC7 python3/sqlite3 \u67E5\u8BE2\u3002
@@ -128629,15 +128930,15 @@ async function analyzeFeedbackWithLocalCodex(payload, options, attachments = [])
128629
128930
 
128630
128931
  // src/modelQuerier.ts
128631
128932
  init_cjs_shims();
128632
- var import_promises8 = __toESM(require("fs/promises"), 1);
128933
+ var import_promises9 = __toESM(require("fs/promises"), 1);
128633
128934
  var import_node_os12 = __toESM(require("os"), 1);
128634
- var import_node_path28 = __toESM(require("path"), 1);
128935
+ var import_node_path29 = __toESM(require("path"), 1);
128635
128936
  var sdk4 = __toESM(require("@anthropic-ai/claude-agent-sdk"), 1);
128636
128937
  var logger38 = createModuleLogger("bridge.modelQuerier");
128637
128938
  async function listModels(queryFn, opts = {}) {
128638
128939
  const t0 = Date.now();
128639
- const cwd = opts.cwd ?? import_node_path28.default.join(import_node_os12.default.homedir(), ".ahchat", "workspaces", "_list_models");
128640
- await import_promises8.default.mkdir(cwd, { recursive: true });
128940
+ const cwd = opts.cwd ?? import_node_path29.default.join(import_node_os12.default.homedir(), ".ahchat", "workspaces", "_list_models");
128941
+ await import_promises9.default.mkdir(cwd, { recursive: true });
128641
128942
  const fn = queryFn ?? sdk4.query;
128642
128943
  const ic = new InputController();
128643
128944
  ic.push("Reply with exactly: PING", "");
@@ -128703,9 +129004,9 @@ init_cjs_shims();
128703
129004
  var import_node_child_process6 = require("child_process");
128704
129005
  var import_node_crypto5 = __toESM(require("crypto"), 1);
128705
129006
  var import_node_fs17 = __toESM(require("fs"), 1);
128706
- var import_promises9 = __toESM(require("fs/promises"), 1);
129007
+ var import_promises10 = __toESM(require("fs/promises"), 1);
128707
129008
  var import_node_os13 = __toESM(require("os"), 1);
128708
- var import_node_path29 = __toESM(require("path"), 1);
129009
+ var import_node_path30 = __toESM(require("path"), 1);
128709
129010
  var import_node_util3 = require("util");
128710
129011
  var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process6.execFile);
128711
129012
  var logger39 = createModuleLogger("bridge.officeRuntimeSetup");
@@ -128765,7 +129066,7 @@ async function fetchUrl2(url2, outputPath, timeoutMs) {
128765
129066
  const res = await fetch(url2, { signal: controller.signal });
128766
129067
  if (!res.ok) return false;
128767
129068
  const bytes = Buffer.from(await res.arrayBuffer());
128768
- await import_promises9.default.writeFile(outputPath, bytes);
129069
+ await import_promises10.default.writeFile(outputPath, bytes);
128769
129070
  return true;
128770
129071
  } catch (error51) {
128771
129072
  logger39.error("OfficeCLI runtime download failed", { error: error51, url: url2 });
@@ -128787,7 +129088,7 @@ function parseChecksumManifest(raw, asset) {
128787
129088
  return null;
128788
129089
  }
128789
129090
  async function sha256(filePath) {
128790
- return import_node_crypto5.default.createHash("sha256").update(await import_promises9.default.readFile(filePath)).digest("hex");
129091
+ return import_node_crypto5.default.createHash("sha256").update(await import_promises10.default.readFile(filePath)).digest("hex");
128791
129092
  }
128792
129093
  async function runBestEffort(command, args) {
128793
129094
  try {
@@ -128815,10 +129116,10 @@ async function installManagedOfficeCliRuntime(env2) {
128815
129116
  const githubBase = `https://github.com/${REPO}/releases/download/${version4}`;
128816
129117
  const mirrorAssetBase = `${mirrorBase(env2)}/releases/download/${version4}`;
128817
129118
  const timeoutMs = readTimeoutMs(env2);
128818
- await import_promises9.default.mkdir(binDir, { recursive: true });
128819
- const tmpDir = await import_promises9.default.mkdtemp(import_node_path29.default.join(import_node_os13.default.tmpdir(), "ahchat-officecli-"));
128820
- const tmpBinary = import_node_path29.default.join(tmpDir, asset);
128821
- const tmpSums = import_node_path29.default.join(tmpDir, "SHA256SUMS");
129119
+ await import_promises10.default.mkdir(binDir, { recursive: true });
129120
+ const tmpDir = await import_promises10.default.mkdtemp(import_node_path30.default.join(import_node_os13.default.tmpdir(), "ahchat-officecli-"));
129121
+ const tmpBinary = import_node_path30.default.join(tmpDir, asset);
129122
+ const tmpSums = import_node_path30.default.join(tmpDir, "SHA256SUMS");
128822
129123
  try {
128823
129124
  const binarySource = await fetchWithFallback(
128824
129125
  `${mirrorAssetBase}/${asset}`,
@@ -128834,21 +129135,21 @@ async function installManagedOfficeCliRuntime(env2) {
128834
129135
  timeoutMs
128835
129136
  );
128836
129137
  if (!checksumSource) throw new Error(`Could not download SHA256SUMS for OfficeCLI ${version4}`);
128837
- const expected = parseChecksumManifest(await import_promises9.default.readFile(tmpSums, "utf-8"), asset);
129138
+ const expected = parseChecksumManifest(await import_promises10.default.readFile(tmpSums, "utf-8"), asset);
128838
129139
  if (!expected) throw new Error(`SHA256SUMS does not contain ${asset}`);
128839
129140
  const actual = await sha256(tmpBinary);
128840
129141
  if (expected !== actual) {
128841
129142
  throw new Error(`Checksum mismatch for ${asset}: expected ${expected}, got ${actual}`);
128842
129143
  }
128843
- const staged = import_node_path29.default.join(binDir, `${import_node_path29.default.basename(target)}.new`);
128844
- await import_promises9.default.copyFile(tmpBinary, staged);
128845
- await import_promises9.default.chmod(staged, 493);
129144
+ const staged = import_node_path30.default.join(binDir, `${import_node_path30.default.basename(target)}.new`);
129145
+ await import_promises10.default.copyFile(tmpBinary, staged);
129146
+ await import_promises10.default.chmod(staged, 493);
128846
129147
  await codesignIfNeeded(staged);
128847
- await import_promises9.default.rm(target, { force: true });
128848
- await import_promises9.default.rename(staged, target);
129148
+ await import_promises10.default.rm(target, { force: true });
129149
+ await import_promises10.default.rename(staged, target);
128849
129150
  return { path: target, asset, binarySource, checksumSource };
128850
129151
  } finally {
128851
- await import_promises9.default.rm(tmpDir, { recursive: true, force: true });
129152
+ await import_promises10.default.rm(tmpDir, { recursive: true, force: true });
128852
129153
  }
128853
129154
  }
128854
129155
  async function ensureOfficeCliRuntime(env2 = process.env) {
@@ -128887,9 +129188,9 @@ async function ensureOfficeCliRuntime(env2 = process.env) {
128887
129188
 
128888
129189
  // src/promptOptimizer.ts
128889
129190
  init_cjs_shims();
128890
- var import_promises10 = __toESM(require("fs/promises"), 1);
129191
+ var import_promises11 = __toESM(require("fs/promises"), 1);
128891
129192
  var import_node_os14 = __toESM(require("os"), 1);
128892
- var import_node_path30 = __toESM(require("path"), 1);
129193
+ var import_node_path31 = __toESM(require("path"), 1);
128893
129194
  var sdk5 = __toESM(require("@anthropic-ai/claude-agent-sdk"), 1);
128894
129195
  var logger40 = createModuleLogger("bridge.promptOptimizer");
128895
129196
  var OPTIMIZER_SYSTEM_PROMPT = `You are an expert prompt editor for ALL-CAN Agent creation.
@@ -128933,8 +129234,8 @@ async function optimizePrompt(queryFn, opts) {
128933
129234
  const prompt = opts.systemPrompt.trim();
128934
129235
  if (!prompt) throw new Error("systemPrompt is required");
128935
129236
  const t0 = Date.now();
128936
- const cwd = opts.cwd ?? import_node_path30.default.join(import_node_os14.default.homedir(), ".ahchat", "workspaces", "_prompt_optimizer");
128937
- await import_promises10.default.mkdir(cwd, { recursive: true });
129237
+ const cwd = opts.cwd ?? import_node_path31.default.join(import_node_os14.default.homedir(), ".ahchat", "workspaces", "_prompt_optimizer");
129238
+ await import_promises11.default.mkdir(cwd, { recursive: true });
128938
129239
  const fn = queryFn ?? sdk5.query;
128939
129240
  const ic = new InputController();
128940
129241
  ic.push(buildUserPrompt(opts), "");
@@ -129198,10 +129499,10 @@ function agentRuntimeConfigSnapshot(rawConfig) {
129198
129499
  };
129199
129500
  }
129200
129501
  async function syncClaudeCredentialsToNodeAccessibleDir(agentConfigDir) {
129201
- const rootClaudeDir = import_node_path31.default.join(process.env.HOME ?? "/root", ".claude");
129202
- const fs26 = await import("fs/promises");
129502
+ const rootClaudeDir = import_node_path32.default.join(process.env.HOME ?? "/root", ".claude");
129503
+ const fs27 = await import("fs/promises");
129203
129504
  try {
129204
- await fs26.access(rootClaudeDir);
129505
+ await fs27.access(rootClaudeDir);
129205
129506
  } catch (e) {
129206
129507
  logger42.info("No /root/.claude to sync", { rootClaudeDir });
129207
129508
  logger42.debug("Root Claude dir access failed", { error: e });
@@ -129209,10 +129510,10 @@ async function syncClaudeCredentialsToNodeAccessibleDir(agentConfigDir) {
129209
129510
  }
129210
129511
  const filesToSync = [".credentials.json", "settings.json", ".credentials.backup.json"];
129211
129512
  for (const file2 of filesToSync) {
129212
- const src = import_node_path31.default.join(rootClaudeDir, file2);
129213
- const dest = import_node_path31.default.join(agentConfigDir, file2);
129513
+ const src = import_node_path32.default.join(rootClaudeDir, file2);
129514
+ const dest = import_node_path32.default.join(agentConfigDir, file2);
129214
129515
  try {
129215
- await fs26.copyFile(src, dest);
129516
+ await fs27.copyFile(src, dest);
129216
129517
  logger42.info("Synced credential file", { file: file2, from: src, to: dest });
129217
129518
  } catch (e) {
129218
129519
  logger42.debug("Credential file not present, skipping", { file: file2, src });
@@ -129221,26 +129522,26 @@ async function syncClaudeCredentialsToNodeAccessibleDir(agentConfigDir) {
129221
129522
  }
129222
129523
  }
129223
129524
  async function chownRecursive(dirPath, uid, gid) {
129224
- const fs26 = await import("fs/promises");
129525
+ const fs27 = await import("fs/promises");
129225
129526
  try {
129226
- await fs26.chown(dirPath, uid, gid);
129527
+ await fs27.chown(dirPath, uid, gid);
129227
129528
  } catch (e) {
129228
129529
  logger42.debug("chown skipped", { error: e, uid, gid });
129229
129530
  }
129230
129531
  let entries;
129231
129532
  try {
129232
- entries = await fs26.readdir(dirPath, { withFileTypes: true });
129533
+ entries = await fs27.readdir(dirPath, { withFileTypes: true });
129233
129534
  } catch (e) {
129234
129535
  logger42.debug("chown directory read skipped", { error: e });
129235
129536
  return;
129236
129537
  }
129237
129538
  for (const entry of entries) {
129238
- const fullPath = import_node_path31.default.join(dirPath, entry.name);
129539
+ const fullPath = import_node_path32.default.join(dirPath, entry.name);
129239
129540
  if (entry.isDirectory()) {
129240
129541
  await chownRecursive(fullPath, uid, gid);
129241
129542
  } else {
129242
129543
  try {
129243
- await fs26.chown(fullPath, uid, gid);
129544
+ await fs27.chown(fullPath, uid, gid);
129244
129545
  } catch (e) {
129245
129546
  logger42.debug("chown skipped", { error: e, uid, gid });
129246
129547
  }
@@ -129252,7 +129553,7 @@ async function startBridge(config2) {
129252
129553
  configureBridgeLogger(config2);
129253
129554
  ensureDir(config2.dataDir);
129254
129555
  ensureDir(config2.agentConfigDir);
129255
- const workspacesDir = import_node_path31.default.join(config2.dataDir, "workspaces");
129556
+ const workspacesDir = import_node_path32.default.join(config2.dataDir, "workspaces");
129256
129557
  ensureDir(workspacesDir);
129257
129558
  process.env.CLAUDE_CONFIG_DIR = config2.agentConfigDir;
129258
129559
  installBridgeFetchAuth(config2.serverApiUrl, config2.bridgeToken);
@@ -129347,7 +129648,7 @@ Bridge token (register this machine at Settings \u2192 \u5DF2\u8FDE\u63A5\u7684\
129347
129648
  wsMetrics.start(5e3);
129348
129649
  const sessionStore = new SessionStore(config2.dataDir);
129349
129650
  const workdirOverrideStore = new LocalWorkdirOverrideStore(config2.dataDir);
129350
- const memoryRoot = import_node_path31.default.join(config2.dataDir, "agent-memory");
129651
+ const memoryRoot = import_node_path32.default.join(config2.dataDir, "agent-memory");
129351
129652
  const memoryStore = new AgentMemoryStore(memoryRoot, config2.serverApiUrl, config2.bridgeToken);
129352
129653
  logger42.info("Agent memory store initialized", { rootDir: memoryRoot });
129353
129654
  const smithNotebook = memoryStore.read(SMITH_AGENT_ID);
@@ -130403,7 +130704,7 @@ init_cjs_shims();
130403
130704
  var import_node_child_process7 = require("child_process");
130404
130705
  var import_node_fs18 = __toESM(require("fs"), 1);
130405
130706
  var import_node_os16 = __toESM(require("os"), 1);
130406
- var import_node_path32 = __toESM(require("path"), 1);
130707
+ var import_node_path33 = __toESM(require("path"), 1);
130407
130708
  var logger44 = createModuleLogger("bridge.protocol");
130408
130709
  var MACOS_PROTOCOL_APP_NAME = "ALL-CAN Bridge.app";
130409
130710
  var LEGACY_MACOS_PROTOCOL_APP_NAME = "AHChatBridge.app";
@@ -130417,10 +130718,10 @@ function desktopExecQuote(value) {
130417
130718
  return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
130418
130719
  }
130419
130720
  function getStableCliPath() {
130420
- return import_node_path32.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge", "cli.cjs");
130721
+ return import_node_path33.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge", "cli.cjs");
130421
130722
  }
130422
130723
  function getStableExePath() {
130423
- const bridgeDir = import_node_path32.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130724
+ const bridgeDir = import_node_path33.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130424
130725
  import_node_fs18.default.mkdirSync(bridgeDir, { recursive: true });
130425
130726
  const stablePath = getStableCliPath();
130426
130727
  import_node_fs18.default.copyFileSync(__filename, stablePath);
@@ -130428,7 +130729,7 @@ function getStableExePath() {
130428
130729
  return stablePath;
130429
130730
  }
130430
130731
  function writePosixLauncher(bridgeDir, stableExePath) {
130431
- const launchScriptPath = import_node_path32.default.join(bridgeDir, "launch-bridge.sh");
130732
+ const launchScriptPath = import_node_path33.default.join(bridgeDir, "launch-bridge.sh");
130432
130733
  const augmentedPath = buildAugmentedPath();
130433
130734
  import_node_fs18.default.writeFileSync(
130434
130735
  launchScriptPath,
@@ -130466,9 +130767,9 @@ function registerProtocolHandler() {
130466
130767
  function registerWindows() {
130467
130768
  const nodeExe = process.execPath;
130468
130769
  const stableExePath = getStableExePath();
130469
- const bridgeDir = import_node_path32.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130770
+ const bridgeDir = import_node_path33.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130470
130771
  const augmentedPath = buildAugmentedPath();
130471
- const psLauncherPath = import_node_path32.default.join(bridgeDir, "launch-bridge.ps1");
130772
+ const psLauncherPath = import_node_path33.default.join(bridgeDir, "launch-bridge.ps1");
130472
130773
  import_node_fs18.default.writeFileSync(
130473
130774
  psLauncherPath,
130474
130775
  [
@@ -130496,7 +130797,7 @@ function registerWindows() {
130496
130797
  ].join("\r\n")
130497
130798
  );
130498
130799
  const handlerValue = `powershell -ExecutionPolicy Bypass -File "${psLauncherPath}" -url "%1"`;
130499
- const psRegisterPath = import_node_path32.default.join(bridgeDir, "register-protocol.ps1");
130800
+ const psRegisterPath = import_node_path33.default.join(bridgeDir, "register-protocol.ps1");
130500
130801
  import_node_fs18.default.writeFileSync(
130501
130802
  psRegisterPath,
130502
130803
  [
@@ -130520,10 +130821,10 @@ function registerWindows() {
130520
130821
  logger44.info("Windows protocol handler registered", { psLauncherPath });
130521
130822
  }
130522
130823
  function registerMacOS() {
130523
- const appDir = import_node_path32.default.join(import_node_os16.default.homedir(), "Applications", MACOS_PROTOCOL_APP_NAME);
130524
- const legacyAppDir = import_node_path32.default.join(import_node_os16.default.homedir(), "Applications", LEGACY_MACOS_PROTOCOL_APP_NAME);
130824
+ const appDir = import_node_path33.default.join(import_node_os16.default.homedir(), "Applications", MACOS_PROTOCOL_APP_NAME);
130825
+ const legacyAppDir = import_node_path33.default.join(import_node_os16.default.homedir(), "Applications", LEGACY_MACOS_PROTOCOL_APP_NAME);
130525
130826
  const stableExePath = getStableExePath();
130526
- const bridgeDir = import_node_path32.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130827
+ const bridgeDir = import_node_path33.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130527
130828
  const launchScriptPath = writePosixLauncher(bridgeDir, stableExePath);
130528
130829
  const escapedScriptPath = launchScriptPath.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
130529
130830
  const appleScript = [
@@ -130532,7 +130833,7 @@ function registerMacOS() {
130532
130833
  ` do shell script "/bin/bash " & (quoted form of launchScript) & " " & (quoted form of thisURL) & " >/tmp/ahchat-bridge.log 2>&1 &"`,
130533
130834
  `end open location`
130534
130835
  ].join("\n");
130535
- const tmpScript = import_node_path32.default.join(import_node_os16.default.tmpdir(), "AHChatBridge.applescript");
130836
+ const tmpScript = import_node_path33.default.join(import_node_os16.default.tmpdir(), "AHChatBridge.applescript");
130536
130837
  import_node_fs18.default.writeFileSync(tmpScript, appleScript);
130537
130838
  try {
130538
130839
  import_node_fs18.default.rmSync(appDir, { recursive: true, force: true });
@@ -130550,7 +130851,7 @@ function registerMacOS() {
130550
130851
  } catch {
130551
130852
  }
130552
130853
  }
130553
- const plistPath = import_node_path32.default.join(appDir, "Contents", "Info.plist");
130854
+ const plistPath = import_node_path33.default.join(appDir, "Contents", "Info.plist");
130554
130855
  const urlTypes = JSON.stringify([{ CFBundleURLName: "ALL-CAN Bridge", CFBundleURLSchemes: ["ahchat"] }]);
130555
130856
  (0, import_node_child_process7.execSync)(
130556
130857
  `/usr/bin/plutil -insert CFBundleURLTypes -json ${JSON.stringify(urlTypes)} ${JSON.stringify(plistPath)}`,
@@ -130566,7 +130867,7 @@ function registerMacOS() {
130566
130867
  }
130567
130868
  function registerLinux() {
130568
130869
  const stableExePath = getStableExePath();
130569
- const bridgeDir = import_node_path32.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130870
+ const bridgeDir = import_node_path33.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130570
130871
  const launchScriptPath = writePosixLauncher(bridgeDir, stableExePath);
130571
130872
  const desktopFile = [
130572
130873
  `[Desktop Entry]`,
@@ -130576,8 +130877,8 @@ function registerLinux() {
130576
130877
  `NoDisplay=true`,
130577
130878
  `MimeType=x-scheme-handler/ahchat;`
130578
130879
  ].join("\n");
130579
- const desktopPath = import_node_path32.default.join(import_node_os16.default.homedir(), ".local", "share", "applications", "ahchat-bridge.desktop");
130580
- import_node_fs18.default.mkdirSync(import_node_path32.default.dirname(desktopPath), { recursive: true });
130880
+ const desktopPath = import_node_path33.default.join(import_node_os16.default.homedir(), ".local", "share", "applications", "ahchat-bridge.desktop");
130881
+ import_node_fs18.default.mkdirSync(import_node_path33.default.dirname(desktopPath), { recursive: true });
130581
130882
  import_node_fs18.default.writeFileSync(desktopPath, desktopFile);
130582
130883
  try {
130583
130884
  (0, import_node_child_process7.execSync)("update-desktop-database ~/.local/share/applications/", { stdio: "pipe" });
@@ -130594,10 +130895,10 @@ function unregisterProtocolHandler() {
130594
130895
  `powershell -ExecutionPolicy Bypass -Command "Remove-Item -Path 'HKCU:\\Software\\Classes\\ahchat' -Recurse -Force -ErrorAction SilentlyContinue"`,
130595
130896
  { stdio: "pipe" }
130596
130897
  );
130597
- const bridgeDir = import_node_path32.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130898
+ const bridgeDir = import_node_path33.default.join(import_node_os16.default.homedir(), ".ahchat", "bridge");
130598
130899
  for (const f of ["launch-bridge.ps1", "register-protocol.ps1"]) {
130599
130900
  try {
130600
- import_node_fs18.default.unlinkSync(import_node_path32.default.join(bridgeDir, f));
130901
+ import_node_fs18.default.unlinkSync(import_node_path33.default.join(bridgeDir, f));
130601
130902
  } catch {
130602
130903
  }
130603
130904
  }
@@ -130606,8 +130907,8 @@ function unregisterProtocolHandler() {
130606
130907
  logger44.warn("Failed to unregister Windows protocol handler", { error: e });
130607
130908
  }
130608
130909
  } else if (platform === "darwin") {
130609
- const appDir = import_node_path32.default.join(import_node_os16.default.homedir(), "Applications", MACOS_PROTOCOL_APP_NAME);
130610
- const legacyAppDir = import_node_path32.default.join(import_node_os16.default.homedir(), "Applications", LEGACY_MACOS_PROTOCOL_APP_NAME);
130910
+ const appDir = import_node_path33.default.join(import_node_os16.default.homedir(), "Applications", MACOS_PROTOCOL_APP_NAME);
130911
+ const legacyAppDir = import_node_path33.default.join(import_node_os16.default.homedir(), "Applications", LEGACY_MACOS_PROTOCOL_APP_NAME);
130611
130912
  try {
130612
130913
  import_node_fs18.default.rmSync(appDir, { recursive: true, force: true });
130613
130914
  import_node_fs18.default.rmSync(legacyAppDir, { recursive: true, force: true });
@@ -130616,7 +130917,7 @@ function unregisterProtocolHandler() {
130616
130917
  logger44.warn("Failed to unregister macOS protocol handler", { error: e });
130617
130918
  }
130618
130919
  } else {
130619
- const desktopPath = import_node_path32.default.join(import_node_os16.default.homedir(), ".local", "share", "applications", "ahchat-bridge.desktop");
130920
+ const desktopPath = import_node_path33.default.join(import_node_os16.default.homedir(), ".local", "share", "applications", "ahchat-bridge.desktop");
130620
130921
  try {
130621
130922
  import_node_fs18.default.unlinkSync(desktopPath);
130622
130923
  logger44.info("Linux protocol handler unregistered");
@@ -130636,10 +130937,10 @@ function isProtocolRegistered() {
130636
130937
  return false;
130637
130938
  }
130638
130939
  } else if (platform === "darwin") {
130639
- const appDir = import_node_path32.default.join(import_node_os16.default.homedir(), "Applications", MACOS_PROTOCOL_APP_NAME);
130640
- return stableCliExists && import_node_fs18.default.existsSync(import_node_path32.default.join(appDir, "Contents", "Info.plist"));
130940
+ const appDir = import_node_path33.default.join(import_node_os16.default.homedir(), "Applications", MACOS_PROTOCOL_APP_NAME);
130941
+ return stableCliExists && import_node_fs18.default.existsSync(import_node_path33.default.join(appDir, "Contents", "Info.plist"));
130641
130942
  } else {
130642
- const desktopPath = import_node_path32.default.join(import_node_os16.default.homedir(), ".local", "share", "applications", "ahchat-bridge.desktop");
130943
+ const desktopPath = import_node_path33.default.join(import_node_os16.default.homedir(), ".local", "share", "applications", "ahchat-bridge.desktop");
130643
130944
  return stableCliExists && import_node_fs18.default.existsSync(desktopPath);
130644
130945
  }
130645
130946
  }
@@ -130648,9 +130949,9 @@ function isProtocolRegistered() {
130648
130949
  var logger45 = createModuleLogger("bridge");
130649
130950
  function readCliVersion() {
130650
130951
  const candidates = [
130651
- import_node_path33.default.resolve(__dirname, "../package.json"),
130652
- import_node_path33.default.resolve(__dirname, "../../package.json"),
130653
- import_node_path33.default.resolve(process.cwd(), "packages/bridge/package.json")
130952
+ import_node_path34.default.resolve(__dirname, "../package.json"),
130953
+ import_node_path34.default.resolve(__dirname, "../../package.json"),
130954
+ import_node_path34.default.resolve(process.cwd(), "packages/bridge/package.json")
130654
130955
  ];
130655
130956
  for (const candidate of candidates) {
130656
130957
  if (!import_node_fs19.default.existsSync(candidate)) continue;
@@ -130727,7 +131028,7 @@ function buildDoctorReport(args) {
130727
131028
  dataDir: resolveBridgeDataDir(args) ?? resolveUserPath("~/.ahchat"),
130728
131029
  server,
130729
131030
  tokenProvided: Boolean(args.token),
130730
- pathPreview: (process.env.PATH ?? "").split(import_node_path33.default.delimiter).slice(0, 12)
131031
+ pathPreview: (process.env.PATH ?? "").split(import_node_path34.default.delimiter).slice(0, 12)
130731
131032
  };
130732
131033
  }
130733
131034
  function writeDoctorText(report) {