@integrity-labs/agt-cli 0.28.1114 → 0.28.1115

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.
@@ -2988,7 +2988,7 @@ var require_compile = __commonJS({
2988
2988
  const schOrFunc = root.refs[ref];
2989
2989
  if (schOrFunc)
2990
2990
  return schOrFunc;
2991
- let _sch = resolve.call(this, root, ref);
2991
+ let _sch = resolve2.call(this, root, ref);
2992
2992
  if (_sch === void 0) {
2993
2993
  const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
2994
2994
  const { schemaId } = this.opts;
@@ -3015,7 +3015,7 @@ var require_compile = __commonJS({
3015
3015
  function sameSchemaEnv(s1, s2) {
3016
3016
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3017
3017
  }
3018
- function resolve(root, ref) {
3018
+ function resolve2(root, ref) {
3019
3019
  let sch;
3020
3020
  while (typeof (sch = this.refs[ref]) == "string")
3021
3021
  ref = sch;
@@ -3590,7 +3590,7 @@ var require_fast_uri = __commonJS({
3590
3590
  }
3591
3591
  return uri;
3592
3592
  }
3593
- function resolve(baseURI, relativeURI, options) {
3593
+ function resolve2(baseURI, relativeURI, options) {
3594
3594
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3595
3595
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
3596
3596
  schemelessOptions.skipEscape = true;
@@ -3817,7 +3817,7 @@ var require_fast_uri = __commonJS({
3817
3817
  var fastUri = {
3818
3818
  SCHEMES,
3819
3819
  normalize,
3820
- resolve,
3820
+ resolve: resolve2,
3821
3821
  resolveComponent,
3822
3822
  equal,
3823
3823
  serialize,
@@ -11591,10 +11591,10 @@ var require_resolve_block_map = __commonJS({
11591
11591
  let offset = bm.offset;
11592
11592
  let commentEnd = null;
11593
11593
  for (const collItem of bm.items) {
11594
- const { start, key, sep: sep2, value } = collItem;
11594
+ const { start, key, sep: sep3, value } = collItem;
11595
11595
  const keyProps = resolveProps.resolveProps(start, {
11596
11596
  indicator: "explicit-key-ind",
11597
- next: key ?? sep2?.[0],
11597
+ next: key ?? sep3?.[0],
11598
11598
  offset,
11599
11599
  onError,
11600
11600
  parentIndent: bm.indent,
@@ -11608,7 +11608,7 @@ var require_resolve_block_map = __commonJS({
11608
11608
  else if ("indent" in key && key.indent !== bm.indent)
11609
11609
  onError(offset, "BAD_INDENT", startColMsg);
11610
11610
  }
11611
- if (!keyProps.anchor && !keyProps.tag && !sep2) {
11611
+ if (!keyProps.anchor && !keyProps.tag && !sep3) {
11612
11612
  commentEnd = keyProps.end;
11613
11613
  if (keyProps.comment) {
11614
11614
  if (map.comment)
@@ -11632,7 +11632,7 @@ var require_resolve_block_map = __commonJS({
11632
11632
  ctx.atKey = false;
11633
11633
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
11634
11634
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
11635
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
11635
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
11636
11636
  indicator: "map-value-ind",
11637
11637
  next: value,
11638
11638
  offset: keyNode.range[2],
@@ -11648,7 +11648,7 @@ var require_resolve_block_map = __commonJS({
11648
11648
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
11649
11649
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
11650
11650
  }
11651
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
11651
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep3, null, valueProps, onError);
11652
11652
  if (ctx.schema.compat)
11653
11653
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
11654
11654
  offset = valueNode.range[2];
@@ -11739,7 +11739,7 @@ var require_resolve_end = __commonJS({
11739
11739
  let comment = "";
11740
11740
  if (end) {
11741
11741
  let hasSpace = false;
11742
- let sep2 = "";
11742
+ let sep3 = "";
11743
11743
  for (const token of end) {
11744
11744
  const { source, type } = token;
11745
11745
  switch (type) {
@@ -11753,13 +11753,13 @@ var require_resolve_end = __commonJS({
11753
11753
  if (!comment)
11754
11754
  comment = cb;
11755
11755
  else
11756
- comment += sep2 + cb;
11757
- sep2 = "";
11756
+ comment += sep3 + cb;
11757
+ sep3 = "";
11758
11758
  break;
11759
11759
  }
11760
11760
  case "newline":
11761
11761
  if (comment)
11762
- sep2 += source;
11762
+ sep3 += source;
11763
11763
  hasSpace = true;
11764
11764
  break;
11765
11765
  default:
@@ -11802,18 +11802,18 @@ var require_resolve_flow_collection = __commonJS({
11802
11802
  let offset = fc.offset + fc.start.source.length;
11803
11803
  for (let i = 0; i < fc.items.length; ++i) {
11804
11804
  const collItem = fc.items[i];
11805
- const { start, key, sep: sep2, value } = collItem;
11805
+ const { start, key, sep: sep3, value } = collItem;
11806
11806
  const props = resolveProps.resolveProps(start, {
11807
11807
  flow: fcName,
11808
11808
  indicator: "explicit-key-ind",
11809
- next: key ?? sep2?.[0],
11809
+ next: key ?? sep3?.[0],
11810
11810
  offset,
11811
11811
  onError,
11812
11812
  parentIndent: fc.indent,
11813
11813
  startOnNewline: false
11814
11814
  });
11815
11815
  if (!props.found) {
11816
- if (!props.anchor && !props.tag && !sep2 && !value) {
11816
+ if (!props.anchor && !props.tag && !sep3 && !value) {
11817
11817
  if (i === 0 && props.comma)
11818
11818
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
11819
11819
  else if (i < fc.items.length - 1)
@@ -11867,8 +11867,8 @@ var require_resolve_flow_collection = __commonJS({
11867
11867
  }
11868
11868
  }
11869
11869
  }
11870
- if (!isMap && !sep2 && !props.found) {
11871
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
11870
+ if (!isMap && !sep3 && !props.found) {
11871
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep3, null, props, onError);
11872
11872
  coll.items.push(valueNode);
11873
11873
  offset = valueNode.range[2];
11874
11874
  if (isBlock(value))
@@ -11880,7 +11880,7 @@ var require_resolve_flow_collection = __commonJS({
11880
11880
  if (isBlock(key))
11881
11881
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
11882
11882
  ctx.atKey = false;
11883
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
11883
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
11884
11884
  flow: fcName,
11885
11885
  indicator: "map-value-ind",
11886
11886
  next: value,
@@ -11891,8 +11891,8 @@ var require_resolve_flow_collection = __commonJS({
11891
11891
  });
11892
11892
  if (valueProps.found) {
11893
11893
  if (!isMap && !props.found && ctx.options.strict) {
11894
- if (sep2)
11895
- for (const st of sep2) {
11894
+ if (sep3)
11895
+ for (const st of sep3) {
11896
11896
  if (st === valueProps.found)
11897
11897
  break;
11898
11898
  if (st.type === "newline") {
@@ -11909,7 +11909,7 @@ var require_resolve_flow_collection = __commonJS({
11909
11909
  else
11910
11910
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
11911
11911
  }
11912
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
11912
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep3, null, valueProps, onError) : null;
11913
11913
  if (valueNode) {
11914
11914
  if (isBlock(value))
11915
11915
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -12089,7 +12089,7 @@ var require_resolve_block_scalar = __commonJS({
12089
12089
  chompStart = i + 1;
12090
12090
  }
12091
12091
  let value = "";
12092
- let sep2 = "";
12092
+ let sep3 = "";
12093
12093
  let prevMoreIndented = false;
12094
12094
  for (let i = 0; i < contentStart; ++i)
12095
12095
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -12106,24 +12106,24 @@ var require_resolve_block_scalar = __commonJS({
12106
12106
  indent = "";
12107
12107
  }
12108
12108
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
12109
- value += sep2 + indent.slice(trimIndent) + content;
12110
- sep2 = "\n";
12109
+ value += sep3 + indent.slice(trimIndent) + content;
12110
+ sep3 = "\n";
12111
12111
  } else if (indent.length > trimIndent || content[0] === " ") {
12112
- if (sep2 === " ")
12113
- sep2 = "\n";
12114
- else if (!prevMoreIndented && sep2 === "\n")
12115
- sep2 = "\n\n";
12116
- value += sep2 + indent.slice(trimIndent) + content;
12117
- sep2 = "\n";
12112
+ if (sep3 === " ")
12113
+ sep3 = "\n";
12114
+ else if (!prevMoreIndented && sep3 === "\n")
12115
+ sep3 = "\n\n";
12116
+ value += sep3 + indent.slice(trimIndent) + content;
12117
+ sep3 = "\n";
12118
12118
  prevMoreIndented = true;
12119
12119
  } else if (content === "") {
12120
- if (sep2 === "\n")
12120
+ if (sep3 === "\n")
12121
12121
  value += "\n";
12122
12122
  else
12123
- sep2 = "\n";
12123
+ sep3 = "\n";
12124
12124
  } else {
12125
- value += sep2 + content;
12126
- sep2 = " ";
12125
+ value += sep3 + content;
12126
+ sep3 = " ";
12127
12127
  prevMoreIndented = false;
12128
12128
  }
12129
12129
  }
@@ -12305,25 +12305,25 @@ var require_resolve_flow_scalar = __commonJS({
12305
12305
  if (!match)
12306
12306
  return source;
12307
12307
  let res = match[1];
12308
- let sep2 = " ";
12308
+ let sep3 = " ";
12309
12309
  let pos = first.lastIndex;
12310
12310
  line.lastIndex = pos;
12311
12311
  while (match = line.exec(source)) {
12312
12312
  if (match[1] === "") {
12313
- if (sep2 === "\n")
12314
- res += sep2;
12313
+ if (sep3 === "\n")
12314
+ res += sep3;
12315
12315
  else
12316
- sep2 = "\n";
12316
+ sep3 = "\n";
12317
12317
  } else {
12318
- res += sep2 + match[1];
12319
- sep2 = " ";
12318
+ res += sep3 + match[1];
12319
+ sep3 = " ";
12320
12320
  }
12321
12321
  pos = line.lastIndex;
12322
12322
  }
12323
12323
  const last = /[ \t]*(.*)/sy;
12324
12324
  last.lastIndex = pos;
12325
12325
  match = last.exec(source);
12326
- return res + sep2 + (match?.[1] ?? "");
12326
+ return res + sep3 + (match?.[1] ?? "");
12327
12327
  }
12328
12328
  function doubleQuotedValue(source, onError) {
12329
12329
  let res = "";
@@ -13131,14 +13131,14 @@ var require_cst_stringify = __commonJS({
13131
13131
  }
13132
13132
  }
13133
13133
  }
13134
- function stringifyItem({ start, key, sep: sep2, value }) {
13134
+ function stringifyItem({ start, key, sep: sep3, value }) {
13135
13135
  let res = "";
13136
13136
  for (const st of start)
13137
13137
  res += st.source;
13138
13138
  if (key)
13139
13139
  res += stringifyToken(key);
13140
- if (sep2)
13141
- for (const st of sep2)
13140
+ if (sep3)
13141
+ for (const st of sep3)
13142
13142
  res += st.source;
13143
13143
  if (value)
13144
13144
  res += stringifyToken(value);
@@ -14288,18 +14288,18 @@ var require_parser = __commonJS({
14288
14288
  if (this.type === "map-value-ind") {
14289
14289
  const prev = getPrevProps(this.peek(2));
14290
14290
  const start = getFirstKeyStartProps(prev);
14291
- let sep2;
14291
+ let sep3;
14292
14292
  if (scalar.end) {
14293
- sep2 = scalar.end;
14294
- sep2.push(this.sourceToken);
14293
+ sep3 = scalar.end;
14294
+ sep3.push(this.sourceToken);
14295
14295
  delete scalar.end;
14296
14296
  } else
14297
- sep2 = [this.sourceToken];
14297
+ sep3 = [this.sourceToken];
14298
14298
  const map = {
14299
14299
  type: "block-map",
14300
14300
  offset: scalar.offset,
14301
14301
  indent: scalar.indent,
14302
- items: [{ start, key: scalar, sep: sep2 }]
14302
+ items: [{ start, key: scalar, sep: sep3 }]
14303
14303
  };
14304
14304
  this.onKeyLine = true;
14305
14305
  this.stack[this.stack.length - 1] = map;
@@ -14452,15 +14452,15 @@ var require_parser = __commonJS({
14452
14452
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
14453
14453
  const start2 = getFirstKeyStartProps(it.start);
14454
14454
  const key = it.key;
14455
- const sep2 = it.sep;
14456
- sep2.push(this.sourceToken);
14455
+ const sep3 = it.sep;
14456
+ sep3.push(this.sourceToken);
14457
14457
  delete it.key;
14458
14458
  delete it.sep;
14459
14459
  this.stack.push({
14460
14460
  type: "block-map",
14461
14461
  offset: this.offset,
14462
14462
  indent: this.indent,
14463
- items: [{ start: start2, key, sep: sep2 }]
14463
+ items: [{ start: start2, key, sep: sep3 }]
14464
14464
  });
14465
14465
  } else if (start.length > 0) {
14466
14466
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -14654,13 +14654,13 @@ var require_parser = __commonJS({
14654
14654
  const prev = getPrevProps(parent);
14655
14655
  const start = getFirstKeyStartProps(prev);
14656
14656
  fixFlowSeqItems(fc);
14657
- const sep2 = fc.end.splice(1, fc.end.length);
14658
- sep2.push(this.sourceToken);
14657
+ const sep3 = fc.end.splice(1, fc.end.length);
14658
+ sep3.push(this.sourceToken);
14659
14659
  const map = {
14660
14660
  type: "block-map",
14661
14661
  offset: fc.offset,
14662
14662
  indent: fc.indent,
14663
- items: [{ start, key: fc, sep: sep2 }]
14663
+ items: [{ start, key: fc, sep: sep3 }]
14664
14664
  };
14665
14665
  this.onKeyLine = true;
14666
14666
  this.stack[this.stack.length - 1] = map;
@@ -17507,7 +17507,7 @@ var require_runtime = __commonJS({
17507
17507
  }
17508
17508
  return p2 && p2.lookup(name);
17509
17509
  };
17510
- _proto.resolve = function resolve(name, forWrite) {
17510
+ _proto.resolve = function resolve2(name, forWrite) {
17511
17511
  var p2 = forWrite && this.isolateWrites ? void 0 : this.parent;
17512
17512
  var val = this.variables[name];
17513
17513
  if (val !== void 0) {
@@ -19237,7 +19237,7 @@ var require_loader = __commonJS({
19237
19237
  return _EmitterObj.apply(this, arguments) || this;
19238
19238
  }
19239
19239
  var _proto = Loader.prototype;
19240
- _proto.resolve = function resolve(from, to) {
19240
+ _proto.resolve = function resolve2(from, to) {
19241
19241
  return path.resolve(path.dirname(from), to);
19242
19242
  };
19243
19243
  _proto.isRelative = function isRelative(filename) {
@@ -19448,10 +19448,10 @@ var require_readdirp = __commonJS({
19448
19448
  }
19449
19449
  async _formatEntry(dirent, path) {
19450
19450
  let entry;
19451
- const basename = this._isDirent ? dirent.name : dirent;
19451
+ const basename2 = this._isDirent ? dirent.name : dirent;
19452
19452
  try {
19453
- const fullPath = (0, node_path_1.resolve)((0, node_path_1.join)(path, basename));
19454
- entry = { path: (0, node_path_1.relative)(this._root, fullPath), fullPath, basename };
19453
+ const fullPath = (0, node_path_1.resolve)((0, node_path_1.join)(path, basename2));
19454
+ entry = { path: (0, node_path_1.relative)(this._root, fullPath), fullPath, basename: basename2 };
19455
19455
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
19456
19456
  } catch (err) {
19457
19457
  this._onError(err);
@@ -19521,9 +19521,9 @@ var require_readdirp = __commonJS({
19521
19521
  return new ReaddirpStream(options);
19522
19522
  }
19523
19523
  function readdirpPromise(root, options = {}) {
19524
- return new Promise((resolve, reject) => {
19524
+ return new Promise((resolve2, reject) => {
19525
19525
  const files = [];
19526
- readdirp(root, options).on("data", (entry) => files.push(entry)).on("end", () => resolve(files)).on("error", (error2) => reject(error2));
19526
+ readdirp(root, options).on("data", (entry) => files.push(entry)).on("end", () => resolve2(files)).on("error", (error2) => reject(error2));
19527
19527
  });
19528
19528
  }
19529
19529
  exports.default = readdirp;
@@ -20008,9 +20008,9 @@ var require_handler = __commonJS({
20008
20008
  _watchWithNodeFs(path, listener) {
20009
20009
  const opts = this.fsw.options;
20010
20010
  const directory = sysPath.dirname(path);
20011
- const basename = sysPath.basename(path);
20011
+ const basename2 = sysPath.basename(path);
20012
20012
  const parent = this.fsw._getWatchedDir(directory);
20013
- parent.add(basename);
20013
+ parent.add(basename2);
20014
20014
  const absolutePath = sysPath.resolve(path);
20015
20015
  const options = {
20016
20016
  persistent: opts.persistent
@@ -20020,7 +20020,7 @@ var require_handler = __commonJS({
20020
20020
  let closer;
20021
20021
  if (opts.usePolling) {
20022
20022
  const enableBin = opts.interval !== opts.binaryInterval;
20023
- options.interval = enableBin && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
20023
+ options.interval = enableBin && isBinaryPath(basename2) ? opts.binaryInterval : opts.interval;
20024
20024
  closer = setFsWatchFileListener(path, absolutePath, options, {
20025
20025
  listener,
20026
20026
  rawEmitter: this.fsw._emitRaw
@@ -20043,10 +20043,10 @@ var require_handler = __commonJS({
20043
20043
  return;
20044
20044
  }
20045
20045
  const dirname4 = sysPath.dirname(file);
20046
- const basename = sysPath.basename(file);
20046
+ const basename2 = sysPath.basename(file);
20047
20047
  const parent = this.fsw._getWatchedDir(dirname4);
20048
20048
  let prevStats = stats;
20049
- if (parent.has(basename))
20049
+ if (parent.has(basename2))
20050
20050
  return;
20051
20051
  const listener = async (path, newStats) => {
20052
20052
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
@@ -20071,9 +20071,9 @@ var require_handler = __commonJS({
20071
20071
  prevStats = newStats2;
20072
20072
  }
20073
20073
  } catch (error2) {
20074
- this.fsw._remove(dirname4, basename);
20074
+ this.fsw._remove(dirname4, basename2);
20075
20075
  }
20076
- } else if (parent.has(basename)) {
20076
+ } else if (parent.has(basename2)) {
20077
20077
  const at = newStats.atimeMs;
20078
20078
  const mt = newStats.mtimeMs;
20079
20079
  if (!at || at <= mt || mt !== prevStats.mtimeMs) {
@@ -20167,7 +20167,7 @@ var require_handler = __commonJS({
20167
20167
  this._addToNodeFs(path, initialAdd, wh, depth + 1);
20168
20168
  }
20169
20169
  }).on(EV.ERROR, this._boundHandleError);
20170
- return new Promise((resolve, reject) => {
20170
+ return new Promise((resolve2, reject) => {
20171
20171
  if (!stream)
20172
20172
  return reject();
20173
20173
  stream.once(exports.STR_END, () => {
@@ -20176,7 +20176,7 @@ var require_handler = __commonJS({
20176
20176
  return;
20177
20177
  }
20178
20178
  const wasThrottled = throttler ? throttler.clear() : false;
20179
- resolve(void 0);
20179
+ resolve2(void 0);
20180
20180
  previous.getChildren().filter((item) => {
20181
20181
  return item !== directory && !current.has(item);
20182
20182
  }).forEach((item) => {
@@ -21307,11 +21307,11 @@ var require_globals = __commonJS({
21307
21307
  }
21308
21308
  };
21309
21309
  }
21310
- function _joiner(sep2) {
21311
- sep2 = sep2 || ",";
21310
+ function _joiner(sep3) {
21311
+ sep3 = sep3 || ",";
21312
21312
  var first = true;
21313
21313
  return function() {
21314
- var val = first ? "" : sep2;
21314
+ var val = first ? "" : sep3;
21315
21315
  first = false;
21316
21316
  return val;
21317
21317
  };
@@ -21341,8 +21341,8 @@ var require_globals = __commonJS({
21341
21341
  cycler: function cycler() {
21342
21342
  return _cycler(Array.prototype.slice.call(arguments));
21343
21343
  },
21344
- joiner: function joiner(sep2) {
21345
- return _joiner(sep2);
21344
+ joiner: function joiner(sep3) {
21345
+ return _joiner(sep3);
21346
21346
  }
21347
21347
  };
21348
21348
  }
@@ -28188,7 +28188,7 @@ var Protocol = class {
28188
28188
  return;
28189
28189
  }
28190
28190
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
28191
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
28191
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
28192
28192
  options?.signal?.throwIfAborted();
28193
28193
  }
28194
28194
  } catch (error2) {
@@ -28205,7 +28205,7 @@ var Protocol = class {
28205
28205
  */
28206
28206
  request(request, resultSchema, options) {
28207
28207
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
28208
- return new Promise((resolve, reject) => {
28208
+ return new Promise((resolve2, reject) => {
28209
28209
  const earlyReject = (error2) => {
28210
28210
  reject(error2);
28211
28211
  };
@@ -28283,7 +28283,7 @@ var Protocol = class {
28283
28283
  if (!parseResult.success) {
28284
28284
  reject(parseResult.error);
28285
28285
  } else {
28286
- resolve(parseResult.data);
28286
+ resolve2(parseResult.data);
28287
28287
  }
28288
28288
  } catch (error2) {
28289
28289
  reject(error2);
@@ -28544,12 +28544,12 @@ var Protocol = class {
28544
28544
  }
28545
28545
  } catch {
28546
28546
  }
28547
- return new Promise((resolve, reject) => {
28547
+ return new Promise((resolve2, reject) => {
28548
28548
  if (signal.aborted) {
28549
28549
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
28550
28550
  return;
28551
28551
  }
28552
- const timeoutId = setTimeout(resolve, interval);
28552
+ const timeoutId = setTimeout(resolve2, interval);
28553
28553
  signal.addEventListener("abort", () => {
28554
28554
  clearTimeout(timeoutId);
28555
28555
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -29419,12 +29419,12 @@ var StdioServerTransport = class {
29419
29419
  this.onclose?.();
29420
29420
  }
29421
29421
  send(message) {
29422
- return new Promise((resolve) => {
29422
+ return new Promise((resolve2) => {
29423
29423
  const json = serializeMessage(message);
29424
29424
  if (this._stdout.write(json)) {
29425
- resolve();
29425
+ resolve2();
29426
29426
  } else {
29427
- this._stdout.once("drain", resolve);
29427
+ this._stdout.once("drain", resolve2);
29428
29428
  }
29429
29429
  });
29430
29430
  }
@@ -29561,6 +29561,9 @@ function shouldRefuseImpersonatedEgress(toolName, egressTools) {
29561
29561
  var DIRECT_CHAT_EGRESS_TOOLS = /* @__PURE__ */ new Set([
29562
29562
  "direct_chat.reply",
29563
29563
  "direct_chat.consume",
29564
+ // ENG-11455: puts a file into the customer's conversation storage, the
29565
+ // Direct Chat twin of telegram.upload_file (gated above for the same reason).
29566
+ "direct_chat.attach_file",
29564
29567
  "channel_request_input"
29565
29568
  ]);
29566
29569
 
@@ -32733,6 +32736,21 @@ var ASSET_TYPES = {
32733
32736
  // module header does not apply. Embedded as <audio src=...> in the page HTML.
32734
32737
  "audio/mpeg": { ext: "mp3", maxBytes: 20 * MB, enabled: true }
32735
32738
  };
32739
+ function sniffImageType(bytes) {
32740
+ const b = bytes;
32741
+ if (b.length >= 8 && b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71 && b[4] === 13 && b[5] === 10 && b[6] === 26 && b[7] === 10) {
32742
+ return "image/png";
32743
+ }
32744
+ if (b.length >= 3 && b[0] === 255 && b[1] === 216 && b[2] === 255)
32745
+ return "image/jpeg";
32746
+ if (b.length >= 6 && b[0] === 71 && b[1] === 73 && b[2] === 70 && b[3] === 56 && (b[4] === 55 || b[4] === 57) && b[5] === 97) {
32747
+ return "image/gif";
32748
+ }
32749
+ if (b.length >= 12 && b[0] === 82 && b[1] === 73 && b[2] === 70 && b[3] === 70 && b[8] === 87 && b[9] === 69 && b[10] === 66 && b[11] === 80) {
32750
+ return "image/webp";
32751
+ }
32752
+ return null;
32753
+ }
32736
32754
 
32737
32755
  // ../core/dist/integrations/augmented-live/codec.js
32738
32756
  var DEFAULT_CHUNK_BUDGET_BYTES = 180 * 1024;
@@ -35412,6 +35430,140 @@ var INSTALLABLE_NATIVE_INTEGRATION_IDS = INSTALLABLE_NATIVE_INTEGRATIONS.map((i)
35412
35430
  // ../core/dist/direct-chat/upload.js
35413
35431
  var MB2 = 1024 * 1024;
35414
35432
  var DIRECT_CHAT_UPLOAD_MAX_BYTES = 100 * MB2;
35433
+ var DIRECT_CHAT_UPLOAD_TYPES = {
35434
+ "image/png": { ext: "png", kind: "image" },
35435
+ "image/jpeg": { ext: "jpg", kind: "image" },
35436
+ "image/webp": { ext: "webp", kind: "image" },
35437
+ "image/gif": { ext: "gif", kind: "image" },
35438
+ "application/pdf": { ext: "pdf", kind: "document" },
35439
+ "text/plain": { ext: "txt", kind: "document" },
35440
+ "text/csv": { ext: "csv", kind: "document" },
35441
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
35442
+ ext: "docx",
35443
+ kind: "document"
35444
+ },
35445
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
35446
+ ext: "xlsx",
35447
+ kind: "document"
35448
+ },
35449
+ // CS-1916: PowerPoint decks. Same OOXML ZIP container as docx/xlsx, so it
35450
+ // shares their byte verification and the document cap. Legacy binary .ppt
35451
+ // (application/vnd.ms-powerpoint, an OLE2 file, not a ZIP) stays rejected,
35452
+ // matching .doc/.xls, which are not allowed either.
35453
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": {
35454
+ ext: "pptx",
35455
+ kind: "document"
35456
+ }
35457
+ };
35458
+ var OOXML_EXTS = /* @__PURE__ */ new Set(["docx", "xlsx", "pptx"]);
35459
+ function normalizeUploadContentType(contentType) {
35460
+ return (contentType ?? "").trim().toLowerCase();
35461
+ }
35462
+ function contentTypeForExtension(ext) {
35463
+ const e = (ext ?? "").trim().toLowerCase().replace(/^\./, "");
35464
+ const want = e === "jpeg" ? "jpg" : e;
35465
+ if (!want)
35466
+ return null;
35467
+ for (const [contentType, spec] of Object.entries(DIRECT_CHAT_UPLOAD_TYPES)) {
35468
+ if (spec.ext === want)
35469
+ return contentType;
35470
+ }
35471
+ return null;
35472
+ }
35473
+ function allowedUploadExtensions() {
35474
+ return Object.values(DIRECT_CHAT_UPLOAD_TYPES).map((s) => s.ext);
35475
+ }
35476
+ function formatUploadSize(bytes) {
35477
+ if (!Number.isFinite(bytes) || bytes < 0)
35478
+ return `${bytes} bytes`;
35479
+ if (bytes >= MB2)
35480
+ return `${Math.round(bytes / MB2)} MB`;
35481
+ if (bytes >= 1024)
35482
+ return `${Math.round(bytes / 1024)} KB`;
35483
+ return `${bytes} bytes`;
35484
+ }
35485
+ function formatTooLargeMessage(byteSize, maxBytes) {
35486
+ const size = formatUploadSize(byteSize);
35487
+ const limit = formatUploadSize(maxBytes);
35488
+ if (size === limit) {
35489
+ return `File is just over the ${limit} limit.`;
35490
+ }
35491
+ return `File is ${size}; the limit is ${limit}.`;
35492
+ }
35493
+ var PDF_MAGIC = [37, 80, 68, 70, 45];
35494
+ var ZIP_MAGIC = [80, 75, 3, 4];
35495
+ function startsWith(bytes, sig) {
35496
+ if (bytes.length < sig.length)
35497
+ return false;
35498
+ for (let i = 0; i < sig.length; i++) {
35499
+ if (bytes[i] !== sig[i])
35500
+ return false;
35501
+ }
35502
+ return true;
35503
+ }
35504
+ var DIRECT_CHAT_SNIFF_BYTES = 8192;
35505
+ function containsAscii(bytes, needle, limit = DIRECT_CHAT_SNIFF_BYTES) {
35506
+ const sig = Array.from(needle, (ch) => ch.charCodeAt(0));
35507
+ const end = Math.min(bytes.length, limit) - sig.length;
35508
+ for (let i = 0; i <= end; i++) {
35509
+ let match = true;
35510
+ for (let j = 0; j < sig.length; j++) {
35511
+ if (bytes[i + j] !== sig[j]) {
35512
+ match = false;
35513
+ break;
35514
+ }
35515
+ }
35516
+ if (match)
35517
+ return true;
35518
+ }
35519
+ return false;
35520
+ }
35521
+ function looksLikeText(bytes) {
35522
+ if (sniffImageType(bytes) !== null)
35523
+ return false;
35524
+ if (startsWith(bytes, PDF_MAGIC) || startsWith(bytes, ZIP_MAGIC))
35525
+ return false;
35526
+ const sample = bytes.subarray(0, Math.min(bytes.length, 4096));
35527
+ for (let i = 0; i < sample.length; i++) {
35528
+ if (sample[i] === 0)
35529
+ return false;
35530
+ }
35531
+ return true;
35532
+ }
35533
+ function verifyDirectChatUploadBytes(bytes, declaredContentType) {
35534
+ const contentType = normalizeUploadContentType(declaredContentType);
35535
+ const spec = DIRECT_CHAT_UPLOAD_TYPES[contentType];
35536
+ if (!spec)
35537
+ return { ok: false, reason: `content_type "${declaredContentType}" is not allowed` };
35538
+ if (spec.kind === "image") {
35539
+ const real = sniffImageType(bytes);
35540
+ if (real !== contentType) {
35541
+ return {
35542
+ ok: false,
35543
+ reason: `declared ${contentType} but the bytes are ${real ?? "not a recognized image"}`
35544
+ };
35545
+ }
35546
+ return { ok: true, contentType, ext: spec.ext, kind: spec.kind };
35547
+ }
35548
+ if (contentType === "application/pdf") {
35549
+ if (!startsWith(bytes, PDF_MAGIC))
35550
+ return { ok: false, reason: "declared application/pdf but the bytes are not a PDF" };
35551
+ return { ok: true, contentType, ext: spec.ext, kind: spec.kind };
35552
+ }
35553
+ if (OOXML_EXTS.has(spec.ext)) {
35554
+ if (!startsWith(bytes, ZIP_MAGIC)) {
35555
+ return { ok: false, reason: `declared ${contentType} but the bytes are not an OOXML (ZIP) container` };
35556
+ }
35557
+ if (!containsAscii(bytes, "[Content_Types].xml")) {
35558
+ return { ok: false, reason: `declared ${contentType} but the ZIP is not a valid OOXML document` };
35559
+ }
35560
+ return { ok: true, contentType, ext: spec.ext, kind: spec.kind };
35561
+ }
35562
+ if (!looksLikeText(bytes)) {
35563
+ return { ok: false, reason: `declared ${contentType} but the bytes look binary` };
35564
+ }
35565
+ return { ok: true, contentType, ext: spec.ext, kind: spec.kind };
35566
+ }
35415
35567
 
35416
35568
  // ../core/dist/direct-chat/notice-display.js
35417
35569
  var AGENT_DIRECTED_NOTICE_KINDS = [
@@ -40344,7 +40496,7 @@ function classifyTranscriptSince(opts) {
40344
40496
  }
40345
40497
  return newest;
40346
40498
  }
40347
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
40499
+ var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
40348
40500
  async function watchForRateLimitRefusal(opts) {
40349
40501
  const now = opts.now ?? (() => Date.now());
40350
40502
  const wait = opts.wait ?? sleep;
@@ -40386,7 +40538,7 @@ var FAST_POLL_MS = 500;
40386
40538
  var SLOW_POLL_MS = 3e3;
40387
40539
  var FAST_PHASE_MS = 1e4;
40388
40540
  var RETRYING_NOTICE_AFTER_MS = 3 * 6e4;
40389
- var sleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
40541
+ var sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
40390
40542
  function classifyTurnFailureSince(opts) {
40391
40543
  const dir = opts.transcriptDir ?? agentTranscriptDir({ cwd: opts.cwd, home: opts.home });
40392
40544
  let entries;
@@ -40611,7 +40763,7 @@ function defaultIsPidAlive(pid) {
40611
40763
  }
40612
40764
  }
40613
40765
  function acquireMcpSpawnLock(args) {
40614
- const { agentDir, basename, options = {} } = args;
40766
+ const { agentDir, basename: basename2, options = {} } = args;
40615
40767
  if (!agentDir) return { kind: "no-agent-dir" };
40616
40768
  const isPidAlive = options.isPidAlive ?? defaultIsPidAlive;
40617
40769
  const selfPid = options.selfPid ?? process.pid;
@@ -40619,7 +40771,7 @@ function acquireMcpSpawnLock(args) {
40619
40771
  const nowMs = options.nowMs ?? (() => Date.now());
40620
40772
  const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
40621
40773
  const staleMs = options.staleMs ?? STALE_LOCK_MS;
40622
- const path = join13(agentDir, basename);
40774
+ const path = join13(agentDir, basename2);
40623
40775
  const existing = readLockHolder(path);
40624
40776
  if (existing) {
40625
40777
  if (existing.pid === selfPid) {
@@ -40829,6 +40981,161 @@ async function downloadInboundAttachments(attachments, dir, deps) {
40829
40981
  return out;
40830
40982
  }
40831
40983
 
40984
+ // src/direct-chat-attach.ts
40985
+ import { createHash } from "crypto";
40986
+ import { constants as fsConstants, promises as fsp } from "fs";
40987
+ import { basename, extname, isAbsolute as isAbsolute2, resolve, sep as sep2 } from "path";
40988
+ import { Readable } from "stream";
40989
+ var PUT_TIMEOUT_MS = 1800 * 1e3;
40990
+ function redactUrls(text) {
40991
+ return text.replace(/https?:\/\/\S+/g, "<url>");
40992
+ }
40993
+ function isWithin(parent, child) {
40994
+ const p2 = parent.endsWith(sep2) ? parent : parent + sep2;
40995
+ return child === parent || child.startsWith(p2);
40996
+ }
40997
+ async function sha256OfHandle(handle) {
40998
+ const hash = createHash("sha256");
40999
+ await new Promise((resolvePromise, reject) => {
41000
+ const stream = handle.createReadStream({ start: 0, autoClose: false });
41001
+ stream.on("data", (chunk) => hash.update(chunk));
41002
+ stream.on("end", () => resolvePromise());
41003
+ stream.on("error", reject);
41004
+ });
41005
+ return hash.digest("hex");
41006
+ }
41007
+ async function attachWorkspaceFile(input, deps) {
41008
+ const rawPath = typeof input.path === "string" ? input.path.trim() : "";
41009
+ if (!rawPath) return { ok: false, error: "path is required" };
41010
+ if (!input.sessionId) return { ok: false, error: "session_id is required" };
41011
+ if (!deps.agentRoot) {
41012
+ return { ok: false, error: "cannot resolve your workspace directory on this host, so no file can be attached" };
41013
+ }
41014
+ const candidate = isAbsolute2(rawPath) ? rawPath : resolve(deps.cwd, rawPath);
41015
+ let realRoot;
41016
+ try {
41017
+ realRoot = await fsp.realpath(deps.agentRoot);
41018
+ } catch {
41019
+ return { ok: false, error: "cannot resolve your workspace directory on this host, so no file can be attached" };
41020
+ }
41021
+ let handle;
41022
+ try {
41023
+ handle = await fsp.open(candidate, fsConstants.O_RDONLY | fsConstants.O_NONBLOCK);
41024
+ } catch {
41025
+ return { ok: false, error: `no such file: ${rawPath}` };
41026
+ }
41027
+ try {
41028
+ if (deps.afterOpenForTest) await deps.afterOpenForTest();
41029
+ let size;
41030
+ let realFile;
41031
+ try {
41032
+ const opened = await handle.stat();
41033
+ if (!opened.isFile()) return { ok: false, error: `${rawPath} is not a regular file` };
41034
+ realFile = await fsp.realpath(candidate);
41035
+ if (!isWithin(realRoot, realFile)) {
41036
+ return {
41037
+ ok: false,
41038
+ error: `${rawPath} is outside your workspace; only files under your own agent directory can be attached`
41039
+ };
41040
+ }
41041
+ const atPath = await fsp.stat(realFile);
41042
+ if (atPath.dev !== opened.dev || atPath.ino !== opened.ino) {
41043
+ return { ok: false, error: `${rawPath} changed while it was being attached; try again` };
41044
+ }
41045
+ size = opened.size;
41046
+ } catch {
41047
+ return { ok: false, error: `cannot read ${rawPath}` };
41048
+ }
41049
+ if (size <= 0) return { ok: false, error: `${rawPath} is empty` };
41050
+ if (size > DIRECT_CHAT_UPLOAD_MAX_BYTES) {
41051
+ return { ok: false, error: formatTooLargeMessage(size, DIRECT_CHAT_UPLOAD_MAX_BYTES) };
41052
+ }
41053
+ const filename = basename(realFile);
41054
+ const contentType = contentTypeForExtension(extname(filename));
41055
+ if (!contentType) {
41056
+ return {
41057
+ ok: false,
41058
+ error: `${filename} has a file type that cannot be attached. Allowed: ${allowedUploadExtensions().join(", ")}`
41059
+ };
41060
+ }
41061
+ let head;
41062
+ try {
41063
+ const buf = Buffer.alloc(DIRECT_CHAT_SNIFF_BYTES);
41064
+ const { bytesRead } = await handle.read(buf, 0, DIRECT_CHAT_SNIFF_BYTES, 0);
41065
+ head = new Uint8Array(buf.subarray(0, bytesRead));
41066
+ } catch {
41067
+ return { ok: false, error: `cannot read ${rawPath}` };
41068
+ }
41069
+ const sniff = verifyDirectChatUploadBytes(head, contentType);
41070
+ if (!sniff.ok) {
41071
+ return { ok: false, error: `${filename} does not contain what its extension says (${sniff.reason})` };
41072
+ }
41073
+ let sha256;
41074
+ try {
41075
+ sha256 = await sha256OfHandle(handle);
41076
+ } catch {
41077
+ return { ok: false, error: `cannot read ${rawPath}` };
41078
+ }
41079
+ let minted;
41080
+ try {
41081
+ const res = await deps.apiPost("/host/direct-chat/uploads", {
41082
+ agent_id: deps.agentId,
41083
+ session_id: input.sessionId,
41084
+ filename,
41085
+ content_type: contentType,
41086
+ byte_size: size,
41087
+ sha256
41088
+ });
41089
+ minted = await res.json().catch(() => ({})) ?? {};
41090
+ if (!res.ok || !minted.upload_id || !minted.upload_url) {
41091
+ return {
41092
+ ok: false,
41093
+ error: redactUrls(`could not start the upload: ${minted.error ?? `HTTP ${res.status}`}`)
41094
+ };
41095
+ }
41096
+ } catch (err) {
41097
+ return { ok: false, error: redactUrls(`could not start the upload: ${err.message}`) };
41098
+ }
41099
+ const fetchImpl = deps.fetchImpl ?? fetch;
41100
+ try {
41101
+ const body = Readable.toWeb(handle.createReadStream({ start: 0, autoClose: false }));
41102
+ const put = await fetchImpl(minted.upload_url, {
41103
+ method: "PUT",
41104
+ headers: {
41105
+ "Content-Type": contentType,
41106
+ "If-None-Match": "*",
41107
+ "Content-Length": String(size)
41108
+ },
41109
+ body,
41110
+ // Required by Node's fetch for a streamed request body.
41111
+ duplex: "half",
41112
+ // Bounded by the presigned URL's own 30-minute validity: past that the PUT
41113
+ // cannot succeed anyway, so do not hold the tool call open beyond it.
41114
+ signal: AbortSignal.timeout(PUT_TIMEOUT_MS)
41115
+ });
41116
+ if (!(put.ok || put.status === 412)) {
41117
+ return { ok: false, error: `upload of ${filename} failed (HTTP ${put.status})` };
41118
+ }
41119
+ } catch (err) {
41120
+ return { ok: false, error: redactUrls(`upload of ${filename} failed: ${err.message}`) };
41121
+ }
41122
+ return { ok: true, file: { upload_id: minted.upload_id, filename, content_type: contentType, byte_size: size } };
41123
+ } finally {
41124
+ await handle.close().catch(() => void 0);
41125
+ }
41126
+ }
41127
+ function replySentText(data) {
41128
+ const linked = data?.attachments_linked ?? [];
41129
+ const rejected = data?.attachments_rejected ?? [];
41130
+ if (rejected.length > 0) {
41131
+ const list = rejected.map((r) => `${r.upload_id} (${redactUrls(r.reason)})`).join("; ");
41132
+ const attached = linked.length > 0 ? ` with ${linked.length} attachment(s)` : "";
41133
+ return `sent${attached}, but ${rejected.length} file(s) were NOT attached: ${list}. Tell the user, or fix and attach again in a follow-up reply.`;
41134
+ }
41135
+ if (linked.length > 0) return `sent with ${linked.length} attachment(s): ${linked.map((l) => l.filename).join(", ")}`;
41136
+ return "sent";
41137
+ }
41138
+
40832
41139
  // src/direct-chat-structured-payload.ts
40833
41140
  var RENDERED_KINDS = /* @__PURE__ */ new Set(["form_result", "button_click"]);
40834
41141
  var MAX_RENDERED_CHARS = 4e3;
@@ -41464,12 +41771,16 @@ function buildDirectChatMcpInstructions() {
41464
41771
  "Always reply to every direct chat message that expects a reply (its meta has requires_reply=true, or no requires_reply field) \u2014 the user is waiting in the webapp.",
41465
41772
  "NEVER call direct_chat_reply for a NOTICE \u2014 a notification whose meta has requires_reply=false (ENG-6381). It is an informational FYI (e.g. an integration-status update), not a question, and it has ALREADY been acknowledged for you. Replying would wrongly post into the operator\u2019s chat history and burn a turn. Just take it into account and carry on.",
41466
41773
  "In the rare case you deliberately handle a reply-expecting message without replying (e.g. an internal command), call direct_chat_consume with the session_id so it is not treated as undelivered and redelivered.",
41467
- "Keep replies concise and helpful. You have full access to all your MCP tools."
41774
+ // ENG-11455: replaces "You have full access to all your MCP tools", which
41775
+ // told the agent nothing it could act on. This blob is within ~40 chars of
41776
+ // the 2048 cap (eng-9649), so the file procedure lives in the
41777
+ // direct_chat_attach_file tool description; this line only points at it.
41778
+ "Keep replies concise. To send a file: direct_chat_attach_file, then its upload_id in direct_chat_reply upload_ids."
41468
41779
  ].join(" ");
41469
41780
  }
41470
41781
 
41471
41782
  // src/usage-limit-reactive-decision.ts
41472
- import { createHash } from "crypto";
41783
+ import { createHash as createHash2 } from "crypto";
41473
41784
  function shouldArmWatch(opts) {
41474
41785
  return !opts.isBot && opts.replyOwed;
41475
41786
  }
@@ -41504,7 +41815,7 @@ function decideUsageLimitCursorCall(opts) {
41504
41815
  }
41505
41816
  function describeUnparsedRefusal(text) {
41506
41817
  if (!text) return "refusal=absent";
41507
- const hash = createHash("sha256").update(text).digest("hex").slice(0, 12);
41818
+ const hash = createHash2("sha256").update(text).digest("hex").slice(0, 12);
41508
41819
  return `refusal_hash=${hash} refusal_len=${text.length}`;
41509
41820
  }
41510
41821
 
@@ -41533,6 +41844,12 @@ var INBOUND_ATTACHMENTS_DIR = resolveInboundAttachmentsDir({
41533
41844
  agentId: AGT_AGENT_ID,
41534
41845
  homeDir: homedir5()
41535
41846
  });
41847
+ var OUTBOUND_ATTACHMENT_ROOT = resolveAgentDirAlias({
41848
+ codeName: process.env.AGT_AGENT_CODE_NAME,
41849
+ turnInitiatorFile: process.env.AGT_TURN_INITIATOR_FILE,
41850
+ agentId: AGT_AGENT_ID,
41851
+ homeDir: homedir5()
41852
+ });
41536
41853
  var AGT_AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME;
41537
41854
  var directChatStderrLogStream = null;
41538
41855
  if (AGT_AGENT_CODE_NAME) {
@@ -41731,7 +42048,7 @@ var STREAM_REPLY_FLUSH_MS = (() => {
41731
42048
  const n = raw ? Number(raw) : NaN;
41732
42049
  return Number.isFinite(n) && n >= 0 ? n : 60;
41733
42050
  })();
41734
- var sleep3 = (ms) => ms > 0 ? new Promise((resolve) => setTimeout(resolve, ms)) : Promise.resolve();
42051
+ var sleep3 = (ms) => ms > 0 ? new Promise((resolve2) => setTimeout(resolve2, ms)) : Promise.resolve();
41735
42052
  async function apiPost(path, body) {
41736
42053
  const token = await getAuthToken();
41737
42054
  const res = await fetchWithTimeout(`${AGT_HOST}${path}`, {
@@ -41944,11 +42261,38 @@ mcp.setRequestHandler(ListToolsRequestSchema, async () => ({
41944
42261
  content: {
41945
42262
  type: "string",
41946
42263
  description: "The reply message (supports markdown)"
42264
+ },
42265
+ upload_ids: {
42266
+ type: "array",
42267
+ items: { type: "string" },
42268
+ description: "Files to attach to this reply: the upload_id values returned by direct_chat_attach_file in this same session (up to 10). The user downloads them from the chips under your message."
41947
42269
  }
41948
42270
  },
41949
42271
  required: ["session_id", "content"]
41950
42272
  }
41951
42273
  },
42274
+ {
42275
+ // ENG-11455: the Direct Chat counterpart of slack_upload_file. Uploads a
42276
+ // workspace file through the existing, verified upload path and returns an
42277
+ // upload_id to pass to direct_chat_reply. The storage URL never reaches
42278
+ // the agent (see direct-chat-attach.ts).
42279
+ name: "direct_chat.attach_file",
42280
+ description: "Attach a file from your workspace to a Direct Chat reply. Uploads it and returns an upload_id; then call direct_chat_reply with upload_ids: [that id] to send it. Allowed types: png, jpg, webp, gif, pdf, txt, csv, docx, xlsx, pptx, up to 100 MB. The file must really be what its extension says. Only files under your own agent directory can be attached.",
42281
+ inputSchema: {
42282
+ type: "object",
42283
+ properties: {
42284
+ session_id: {
42285
+ type: "string",
42286
+ description: "Session ID (from the session_id attribute in the <channel> tag)"
42287
+ },
42288
+ path: {
42289
+ type: "string",
42290
+ description: "Absolute path to the file (recommended). Must be under your own agent directory (~/.augmented/<code_name>/), e.g. in project/ or scratch/. A relative path resolves against your working directory."
42291
+ }
42292
+ },
42293
+ required: ["session_id", "path"]
42294
+ }
42295
+ },
41952
42296
  {
41953
42297
  name: "direct_chat.consume",
41954
42298
  description: "Acknowledge direct-chat message(s) you handled WITHOUT sending a reply (e.g. a command that only updated state, or a message you deliberately ignored). Pass the session_id from the <channel> tag. If you send a direct_chat_reply you do NOT also need to consume \u2014 the reply already acknowledges the message. Without one of the two, a silently-handled message is treated as undelivered and may be redelivered.",
@@ -42021,7 +42365,23 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
42021
42365
  };
42022
42366
  }
42023
42367
  if (name === "direct_chat.reply") {
42024
- const { session_id, content: rawContent } = args;
42368
+ const { session_id, content: rawContent, upload_ids: rawUploadIds } = args;
42369
+ let upload_ids;
42370
+ if (rawUploadIds !== void 0) {
42371
+ if (!Array.isArray(rawUploadIds) || rawUploadIds.some((x) => typeof x !== "string" || !x)) {
42372
+ return {
42373
+ content: [{ type: "text", text: "upload_ids must be an array of upload_id strings from direct_chat_attach_file" }],
42374
+ isError: true
42375
+ };
42376
+ }
42377
+ if (rawUploadIds.length > 10) {
42378
+ return {
42379
+ content: [{ type: "text", text: "At most 10 files can be attached to one reply" }],
42380
+ isError: true
42381
+ };
42382
+ }
42383
+ upload_ids = rawUploadIds.length > 0 ? rawUploadIds : void 0;
42384
+ }
42025
42385
  if (rawContent == null) {
42026
42386
  return {
42027
42387
  content: [{ type: "text", text: "Missing required argument: content" }],
@@ -42048,7 +42408,9 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
42048
42408
  agent_id: AGT_AGENT_ID,
42049
42409
  session_id,
42050
42410
  content: slices[0],
42051
- message_ids
42411
+ message_ids,
42412
+ // ENG-11455: files bind to the anchor row, the one that persists.
42413
+ ...upload_ids ? { upload_ids } : {}
42052
42414
  });
42053
42415
  const { body: data, httpOk, statusText } = await readCursorAdvanceBody(res);
42054
42416
  const verdict = judgeCursorAdvance(
@@ -42104,7 +42466,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
42104
42466
  await maybeSendDirectChatAccountWarn(session_id);
42105
42467
  void maybeSendDirectChatToolsOfflineNotice(session_id).catch(() => {
42106
42468
  });
42107
- return { content: [{ type: "text", text: "sent" }] };
42469
+ return { content: [{ type: "text", text: replySentText(data) }] };
42108
42470
  } catch (err) {
42109
42471
  return {
42110
42472
  content: [{ type: "text", text: `Failed: ${err.message}` }],
@@ -42117,7 +42479,8 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
42117
42479
  agent_id: AGT_AGENT_ID,
42118
42480
  session_id,
42119
42481
  content,
42120
- message_ids
42482
+ message_ids,
42483
+ ...upload_ids ? { upload_ids } : {}
42121
42484
  });
42122
42485
  const { body: data, httpOk, statusText } = await readCursorAdvanceBody(res);
42123
42486
  const verdict = judgeCursorAdvance(
@@ -42147,7 +42510,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
42147
42510
  await maybeSendDirectChatAccountWarn(session_id);
42148
42511
  void maybeSendDirectChatToolsOfflineNotice(session_id).catch(() => {
42149
42512
  });
42150
- return { content: [{ type: "text", text: "sent" }] };
42513
+ return { content: [{ type: "text", text: replySentText(data) }] };
42151
42514
  } catch (err) {
42152
42515
  return {
42153
42516
  content: [{ type: "text", text: `Failed: ${err.message}` }],
@@ -42155,6 +42518,36 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
42155
42518
  };
42156
42519
  }
42157
42520
  }
42521
+ if (name === "direct_chat.attach_file") {
42522
+ const { session_id, path } = args ?? {};
42523
+ if (!session_id || !path) {
42524
+ return {
42525
+ content: [{ type: "text", text: "Missing required argument: session_id and path" }],
42526
+ isError: true
42527
+ };
42528
+ }
42529
+ const result = await attachWorkspaceFile(
42530
+ { sessionId: session_id, path },
42531
+ { agentRoot: OUTBOUND_ATTACHMENT_ROOT, cwd: process.cwd(), apiPost, agentId: AGT_AGENT_ID }
42532
+ );
42533
+ if (!result.ok) {
42534
+ return { content: [{ type: "text", text: `Not attached: ${result.error}` }], isError: true };
42535
+ }
42536
+ return {
42537
+ content: [
42538
+ {
42539
+ type: "text",
42540
+ text: JSON.stringify({
42541
+ upload_id: result.file.upload_id,
42542
+ filename: result.file.filename,
42543
+ content_type: result.file.content_type,
42544
+ byte_size: result.file.byte_size,
42545
+ next: "Pass this upload_id in upload_ids on direct_chat_reply (same session_id) to send the file."
42546
+ })
42547
+ }
42548
+ ]
42549
+ };
42550
+ }
42158
42551
  if (name === "direct_chat.consume") {
42159
42552
  const { session_id } = args;
42160
42553
  const message_ids = claimTracker.peek(session_id);
@@ -42868,8 +43261,8 @@ if (DOORBELL_ENABLED && DIRECT_CHAT_AGENT_DIR) {
42868
43261
  if (sessionState.fresh) {
42869
43262
  void runBacklogDrain({
42870
43263
  attempt: () => pollOnce(void 0),
42871
- sleep: (ms) => new Promise((resolve) => {
42872
- const t = setTimeout(resolve, ms);
43264
+ sleep: (ms) => new Promise((resolve2) => {
43265
+ const t = setTimeout(resolve2, ms);
42873
43266
  t.unref?.();
42874
43267
  }),
42875
43268
  onLog: (line) => process.stderr.write(`${line}