@integrity-labs/agt-cli 0.28.836 → 0.28.838

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.
@@ -60,7 +60,7 @@ import {
60
60
  safeWriteJsonAtomic,
61
61
  setConfigHash,
62
62
  tripClass
63
- } from "../chunk-E6B43IJZ.js";
63
+ } from "../chunk-MZNTGZA7.js";
64
64
  import {
65
65
  getProjectDir as getProjectDir2,
66
66
  getReadyTasks,
@@ -13669,7 +13669,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
13669
13669
  var lastVersionCheckAt = 0;
13670
13670
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
13671
13671
  var lastResponsivenessProbeAt = 0;
13672
- var agtCliVersion = true ? "0.28.836" : "dev";
13672
+ var agtCliVersion = true ? "0.28.838" : "dev";
13673
13673
  function resolveBrewPath(execFileSync2) {
13674
13674
  try {
13675
13675
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -3596,49 +3596,49 @@ var require_fast_uri = __commonJS({
3596
3596
  schemelessOptions.skipEscape = true;
3597
3597
  return serialize(resolved, schemelessOptions);
3598
3598
  }
3599
- function resolveComponent(base, relative, options, skipNormalization) {
3599
+ function resolveComponent(base, relative2, options, skipNormalization) {
3600
3600
  const target = {};
3601
3601
  if (!skipNormalization) {
3602
3602
  base = parse3(serialize(base, options), options);
3603
- relative = parse3(serialize(relative, options), options);
3603
+ relative2 = parse3(serialize(relative2, options), options);
3604
3604
  }
3605
3605
  options = options || {};
3606
- if (!options.tolerant && relative.scheme) {
3607
- target.scheme = relative.scheme;
3608
- target.userinfo = relative.userinfo;
3609
- target.host = relative.host;
3610
- target.port = relative.port;
3611
- target.path = removeDotSegments(relative.path || "");
3612
- target.query = relative.query;
3606
+ if (!options.tolerant && relative2.scheme) {
3607
+ target.scheme = relative2.scheme;
3608
+ target.userinfo = relative2.userinfo;
3609
+ target.host = relative2.host;
3610
+ target.port = relative2.port;
3611
+ target.path = removeDotSegments(relative2.path || "");
3612
+ target.query = relative2.query;
3613
3613
  } else {
3614
- if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
3615
- target.userinfo = relative.userinfo;
3616
- target.host = relative.host;
3617
- target.port = relative.port;
3618
- target.path = removeDotSegments(relative.path || "");
3619
- target.query = relative.query;
3614
+ if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
3615
+ target.userinfo = relative2.userinfo;
3616
+ target.host = relative2.host;
3617
+ target.port = relative2.port;
3618
+ target.path = removeDotSegments(relative2.path || "");
3619
+ target.query = relative2.query;
3620
3620
  } else {
3621
- if (!relative.path) {
3621
+ if (!relative2.path) {
3622
3622
  target.path = base.path;
3623
- if (relative.query !== void 0) {
3624
- target.query = relative.query;
3623
+ if (relative2.query !== void 0) {
3624
+ target.query = relative2.query;
3625
3625
  } else {
3626
3626
  target.query = base.query;
3627
3627
  }
3628
3628
  } else {
3629
- if (relative.path[0] === "/") {
3630
- target.path = removeDotSegments(relative.path);
3629
+ if (relative2.path[0] === "/") {
3630
+ target.path = removeDotSegments(relative2.path);
3631
3631
  } else {
3632
3632
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3633
- target.path = "/" + relative.path;
3633
+ target.path = "/" + relative2.path;
3634
3634
  } else if (!base.path) {
3635
- target.path = relative.path;
3635
+ target.path = relative2.path;
3636
3636
  } else {
3637
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
3637
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
3638
3638
  }
3639
3639
  target.path = removeDotSegments(target.path);
3640
3640
  }
3641
- target.query = relative.query;
3641
+ target.query = relative2.query;
3642
3642
  }
3643
3643
  target.userinfo = base.userinfo;
3644
3644
  target.host = base.host;
@@ -3646,7 +3646,7 @@ var require_fast_uri = __commonJS({
3646
3646
  }
3647
3647
  target.scheme = base.scheme;
3648
3648
  }
3649
- target.fragment = relative.fragment;
3649
+ target.fragment = relative2.fragment;
3650
3650
  return target;
3651
3651
  }
3652
3652
  function equal(uriA, uriB, options) {
@@ -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, value } = collItem;
11594
+ const { start, key, sep: sep2, value } = collItem;
11595
11595
  const keyProps = resolveProps.resolveProps(start, {
11596
11596
  indicator: "explicit-key-ind",
11597
- next: key ?? sep?.[0],
11597
+ next: key ?? sep2?.[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 && !sep) {
11611
+ if (!keyProps.anchor && !keyProps.tag && !sep2) {
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(sep ?? [], {
11635
+ const valueProps = resolveProps.resolveProps(sep2 ?? [], {
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, sep, null, valueProps, onError);
11651
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, 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 sep = "";
11742
+ let sep2 = "";
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 += sep + cb;
11757
- sep = "";
11756
+ comment += sep2 + cb;
11757
+ sep2 = "";
11758
11758
  break;
11759
11759
  }
11760
11760
  case "newline":
11761
11761
  if (comment)
11762
- sep += source;
11762
+ sep2 += 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, value } = collItem;
11805
+ const { start, key, sep: sep2, value } = collItem;
11806
11806
  const props = resolveProps.resolveProps(start, {
11807
11807
  flow: fcName,
11808
11808
  indicator: "explicit-key-ind",
11809
- next: key ?? sep?.[0],
11809
+ next: key ?? sep2?.[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 && !sep && !value) {
11816
+ if (!props.anchor && !props.tag && !sep2 && !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 && !sep && !props.found) {
11871
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError);
11870
+ if (!isMap && !sep2 && !props.found) {
11871
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, 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(sep ?? [], {
11883
+ const valueProps = resolveProps.resolveProps(sep2 ?? [], {
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 (sep)
11895
- for (const st of sep) {
11894
+ if (sep2)
11895
+ for (const st of sep2) {
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, sep, null, valueProps, onError) : null;
11912
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, 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 sep = "";
12092
+ let sep2 = "";
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 += sep + indent.slice(trimIndent) + content;
12110
- sep = "\n";
12109
+ value += sep2 + indent.slice(trimIndent) + content;
12110
+ sep2 = "\n";
12111
12111
  } else if (indent.length > trimIndent || content[0] === " ") {
12112
- if (sep === " ")
12113
- sep = "\n";
12114
- else if (!prevMoreIndented && sep === "\n")
12115
- sep = "\n\n";
12116
- value += sep + indent.slice(trimIndent) + content;
12117
- sep = "\n";
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";
12118
12118
  prevMoreIndented = true;
12119
12119
  } else if (content === "") {
12120
- if (sep === "\n")
12120
+ if (sep2 === "\n")
12121
12121
  value += "\n";
12122
12122
  else
12123
- sep = "\n";
12123
+ sep2 = "\n";
12124
12124
  } else {
12125
- value += sep + content;
12126
- sep = " ";
12125
+ value += sep2 + content;
12126
+ sep2 = " ";
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 sep = " ";
12308
+ let sep2 = " ";
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 (sep === "\n")
12314
- res += sep;
12313
+ if (sep2 === "\n")
12314
+ res += sep2;
12315
12315
  else
12316
- sep = "\n";
12316
+ sep2 = "\n";
12317
12317
  } else {
12318
- res += sep + match[1];
12319
- sep = " ";
12318
+ res += sep2 + match[1];
12319
+ sep2 = " ";
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 + sep + (match?.[1] ?? "");
12326
+ return res + sep2 + (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, value }) {
13134
+ function stringifyItem({ start, key, sep: sep2, 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 (sep)
13141
- for (const st of sep)
13140
+ if (sep2)
13141
+ for (const st of sep2)
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 sep;
14291
+ let sep2;
14292
14292
  if (scalar.end) {
14293
- sep = scalar.end;
14294
- sep.push(this.sourceToken);
14293
+ sep2 = scalar.end;
14294
+ sep2.push(this.sourceToken);
14295
14295
  delete scalar.end;
14296
14296
  } else
14297
- sep = [this.sourceToken];
14297
+ sep2 = [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 }]
14302
+ items: [{ start, key: scalar, sep: sep2 }]
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 sep = it.sep;
14456
- sep.push(this.sourceToken);
14455
+ const sep2 = it.sep;
14456
+ sep2.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 }]
14463
+ items: [{ start: start2, key, sep: sep2 }]
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 sep = fc.end.splice(1, fc.end.length);
14658
- sep.push(this.sourceToken);
14657
+ const sep2 = fc.end.splice(1, fc.end.length);
14658
+ sep2.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 }]
14663
+ items: [{ start, key: fc, sep: sep2 }]
14664
14664
  };
14665
14665
  this.onKeyLine = true;
14666
14666
  this.stack[this.stack.length - 1] = map;
@@ -18867,7 +18867,7 @@ var require_filters = __commonJS({
18867
18867
  return r.copySafeness(str, res);
18868
18868
  }
18869
18869
  _exports.indent = indent;
18870
- function join15(arr, del, attr) {
18870
+ function join16(arr, del, attr) {
18871
18871
  del = del || "";
18872
18872
  if (attr) {
18873
18873
  arr = lib.map(arr, function(v) {
@@ -18876,7 +18876,7 @@ var require_filters = __commonJS({
18876
18876
  }
18877
18877
  return arr.join(del);
18878
18878
  }
18879
- _exports.join = join15;
18879
+ _exports.join = join16;
18880
18880
  function last(arr) {
18881
18881
  return arr[arr.length - 1];
18882
18882
  }
@@ -20042,9 +20042,9 @@ var require_handler = __commonJS({
20042
20042
  if (this.fsw.closed) {
20043
20043
  return;
20044
20044
  }
20045
- const dirname3 = sysPath.dirname(file);
20045
+ const dirname2 = sysPath.dirname(file);
20046
20046
  const basename = sysPath.basename(file);
20047
- const parent = this.fsw._getWatchedDir(dirname3);
20047
+ const parent = this.fsw._getWatchedDir(dirname2);
20048
20048
  let prevStats = stats;
20049
20049
  if (parent.has(basename))
20050
20050
  return;
@@ -20071,7 +20071,7 @@ var require_handler = __commonJS({
20071
20071
  prevStats = newStats2;
20072
20072
  }
20073
20073
  } catch (error2) {
20074
- this.fsw._remove(dirname3, basename);
20074
+ this.fsw._remove(dirname2, basename);
20075
20075
  }
20076
20076
  } else if (parent.has(basename)) {
20077
20077
  const at = newStats.atimeMs;
@@ -20335,11 +20335,11 @@ var require_chokidar = __commonJS({
20335
20335
  if (matcher.path === string3)
20336
20336
  return true;
20337
20337
  if (matcher.recursive) {
20338
- const relative = sysPath.relative(matcher.path, string3);
20339
- if (!relative) {
20338
+ const relative2 = sysPath.relative(matcher.path, string3);
20339
+ if (!relative2) {
20340
20340
  return false;
20341
20341
  }
20342
- return !relative.startsWith("..") && !sysPath.isAbsolute(relative);
20342
+ return !relative2.startsWith("..") && !sysPath.isAbsolute(relative2);
20343
20343
  }
20344
20344
  return false;
20345
20345
  };
@@ -21307,11 +21307,11 @@ var require_globals = __commonJS({
21307
21307
  }
21308
21308
  };
21309
21309
  }
21310
- function _joiner(sep) {
21311
- sep = sep || ",";
21310
+ function _joiner(sep2) {
21311
+ sep2 = sep2 || ",";
21312
21312
  var first = true;
21313
21313
  return function() {
21314
- var val = first ? "" : sep;
21314
+ var val = first ? "" : sep2;
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(sep) {
21345
- return _joiner(sep);
21344
+ joiner: function joiner(sep2) {
21345
+ return _joiner(sep2);
21346
21346
  }
21347
21347
  };
21348
21348
  }
@@ -38427,7 +38427,7 @@ function readLockHolder(path) {
38427
38427
 
38428
38428
  // src/direct-chat-channel.ts
38429
38429
  import { homedir as homedir4 } from "os";
38430
- import { join as join14 } from "path";
38430
+ import { join as join15 } from "path";
38431
38431
  import { randomUUID } from "crypto";
38432
38432
  import {
38433
38433
  watch,
@@ -38443,25 +38443,54 @@ import {
38443
38443
  } from "fs";
38444
38444
 
38445
38445
  // src/direct-chat-inbound-attachments.ts
38446
- import { dirname as dirname2, join as join11 } from "path";
38447
- var MAX_INBOUND_ATTACHMENT_BYTES = 10 * 1024 * 1024;
38448
- var INBOUND_ATTACHMENTS_SUBDIR = "direct-chat-inbound";
38449
- function resolveInboundAttachmentsDir(input) {
38446
+ import { join as join12 } from "path";
38447
+
38448
+ // ../core/dist/provisioning/frameworks/claudecode/agent-dir-alias.js
38449
+ import { isAbsolute, join as join11, relative, sep } from "path";
38450
+ var VALID_CODE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
38451
+ var VALID_AGENT_ID = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
38452
+ var INITIATOR_BASENAME = ".current-turn-initiator.json";
38453
+ function isSafeAgentSegment(segment) {
38454
+ return VALID_CODE_NAME.test(segment) || VALID_AGENT_ID.test(segment);
38455
+ }
38456
+ function initiatorDirSegment(initiatorFile, homeDir) {
38457
+ const rel = relative(join11(homeDir, ".augmented"), initiatorFile);
38458
+ if (!rel || isAbsolute(rel))
38459
+ return null;
38460
+ const parts = rel.split(sep);
38461
+ if (parts.length !== 2 || parts[1] !== INITIATOR_BASENAME)
38462
+ return null;
38463
+ const segment = parts[0];
38464
+ if (segment === void 0)
38465
+ return null;
38466
+ return isSafeAgentSegment(segment) ? segment : null;
38467
+ }
38468
+ function resolveAgentDirAlias(input) {
38450
38469
  const { codeName, turnInitiatorFile, agentId, homeDir } = input;
38451
38470
  const codeNameTrimmed = typeof codeName === "string" ? codeName.trim() : "";
38452
- if (codeNameTrimmed) {
38453
- return join11(homeDir, ".augmented", codeNameTrimmed, INBOUND_ATTACHMENTS_SUBDIR);
38471
+ if (codeNameTrimmed && VALID_CODE_NAME.test(codeNameTrimmed)) {
38472
+ return join11(homeDir, ".augmented", codeNameTrimmed);
38454
38473
  }
38455
38474
  const initiator = typeof turnInitiatorFile === "string" ? turnInitiatorFile.trim() : "";
38456
38475
  if (initiator) {
38457
- return join11(dirname2(initiator), INBOUND_ATTACHMENTS_SUBDIR);
38476
+ const segment = initiatorDirSegment(initiator, homeDir);
38477
+ if (segment)
38478
+ return join11(homeDir, ".augmented", segment);
38458
38479
  }
38459
38480
  const agentIdTrimmed = typeof agentId === "string" ? agentId.trim() : "";
38460
- if (agentIdTrimmed) {
38461
- return join11(homeDir, ".augmented", agentIdTrimmed, INBOUND_ATTACHMENTS_SUBDIR);
38481
+ if (agentIdTrimmed && VALID_AGENT_ID.test(agentIdTrimmed)) {
38482
+ return join11(homeDir, ".augmented", agentIdTrimmed);
38462
38483
  }
38463
38484
  return null;
38464
38485
  }
38486
+
38487
+ // src/direct-chat-inbound-attachments.ts
38488
+ var MAX_INBOUND_ATTACHMENT_BYTES = 10 * 1024 * 1024;
38489
+ var INBOUND_ATTACHMENTS_SUBDIR = "direct-chat-inbound";
38490
+ function resolveInboundAttachmentsDir(input) {
38491
+ const alias = resolveAgentDirAlias(input);
38492
+ return alias === null ? null : join12(alias, INBOUND_ATTACHMENTS_SUBDIR);
38493
+ }
38465
38494
  function isImageContentType(contentType) {
38466
38495
  return typeof contentType === "string" && contentType.toLowerCase().startsWith("image/");
38467
38496
  }
@@ -38948,7 +38977,7 @@ function isMaintenanceModeActive(opts) {
38948
38977
  // src/account-enforcement-notice.ts
38949
38978
  import { readFileSync as readFileSync9 } from "fs";
38950
38979
  import { homedir as homedir3 } from "os";
38951
- import { join as join12 } from "path";
38980
+ import { join as join13 } from "path";
38952
38981
 
38953
38982
  // ../core/dist/channels/governance/sender-policy-decline.js
38954
38983
  function decideDeclineReply(input) {
@@ -38966,7 +38995,7 @@ function decideDeclineReply(input) {
38966
38995
  // src/account-enforcement-notice.ts
38967
38996
  function accountEnforcementMarkerPath(codeName) {
38968
38997
  if (!codeName) return null;
38969
- return join12(homedir3(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
38998
+ return join13(homedir3(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
38970
38999
  }
38971
39000
  function readAccountEnforcementMarker(opts) {
38972
39001
  const path = opts.filePath ?? accountEnforcementMarkerPath(opts.codeName);
@@ -39000,7 +39029,7 @@ function shouldSendAccountWarn(opts) {
39000
39029
 
39001
39030
  // ../core/dist/direct-chat/cursor-advance-telemetry.js
39002
39031
  import { readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "fs";
39003
- import { join as join13 } from "path";
39032
+ import { join as join14 } from "path";
39004
39033
  var CURSOR_SHORTFALL_COUNTER_SUFFIX = "-cursor-advance-classifications.json";
39005
39034
  function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
39006
39035
  if (!agentDir)
@@ -39008,7 +39037,7 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
39008
39037
  const key = cursorAdvanceCounterKey(route, verdict);
39009
39038
  if (key === null)
39010
39039
  return;
39011
- const path = join13(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
39040
+ const path = join14(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
39012
39041
  const counts = {};
39013
39042
  try {
39014
39043
  const parsed = JSON.parse(readFileSync10(path, "utf-8"));
@@ -39124,7 +39153,7 @@ var DIRECT_CHAT_ACCOUNT_WARN_COOLDOWN_MS = (() => {
39124
39153
  var AGT_HOST = process.env.AGT_HOST;
39125
39154
  var AGT_API_KEY = process.env.AGT_API_KEY;
39126
39155
  var AGT_AGENT_ID = process.env.AGT_AGENT_ID;
39127
- var DIRECT_CHAT_AGENT_DIR = AGT_AGENT_ID ? join14(homedir4(), ".augmented", AGT_AGENT_ID) : null;
39156
+ var DIRECT_CHAT_AGENT_DIR = AGT_AGENT_ID ? join15(homedir4(), ".augmented", AGT_AGENT_ID) : null;
39128
39157
  var INBOUND_ATTACHMENTS_DIR = resolveInboundAttachmentsDir({
39129
39158
  codeName: process.env.AGT_AGENT_CODE_NAME,
39130
39159
  turnInitiatorFile: process.env.AGT_TURN_INITIATOR_FILE,
@@ -39135,10 +39164,10 @@ var AGT_AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME;
39135
39164
  var directChatStderrLogStream = null;
39136
39165
  if (AGT_AGENT_CODE_NAME) {
39137
39166
  try {
39138
- const logDir = join14(homedir4(), ".augmented", AGT_AGENT_CODE_NAME);
39167
+ const logDir = join15(homedir4(), ".augmented", AGT_AGENT_CODE_NAME);
39139
39168
  mkdirSync5(logDir, { recursive: true });
39140
39169
  directChatStderrLogStream = createWriteStream(
39141
- join14(logDir, "direct-chat-channel-stderr.log"),
39170
+ join15(logDir, "direct-chat-channel-stderr.log"),
39142
39171
  { flags: "a", mode: 384 }
39143
39172
  );
39144
39173
  directChatStderrLogStream.on("error", () => {
@@ -39157,10 +39186,10 @@ if (AGT_AGENT_CODE_NAME) {
39157
39186
  } catch {
39158
39187
  }
39159
39188
  }
39160
- var PROGRESS_HEARTBEAT_PATH = AGT_AGENT_CODE_NAME ? join14(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, "channel-progress-heartbeat.json") : null;
39161
- var DIRECT_CHAT_PENDING_INBOUND_DIR = AGT_AGENT_CODE_NAME ? join14(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-pending-inbound") : null;
39162
- var DIRECT_CHAT_DELIVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join14(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-inbound-delivery-ledger") : null;
39163
- var DIRECT_CHAT_CODE_NAME_AGENT_DIR = AGT_AGENT_CODE_NAME ? join14(homedir4(), ".augmented", AGT_AGENT_CODE_NAME) : null;
39189
+ var PROGRESS_HEARTBEAT_PATH = AGT_AGENT_CODE_NAME ? join15(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, "channel-progress-heartbeat.json") : null;
39190
+ var DIRECT_CHAT_PENDING_INBOUND_DIR = AGT_AGENT_CODE_NAME ? join15(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-pending-inbound") : null;
39191
+ var DIRECT_CHAT_DELIVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join15(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-inbound-delivery-ledger") : null;
39192
+ var DIRECT_CHAT_CODE_NAME_AGENT_DIR = AGT_AGENT_CODE_NAME ? join15(homedir4(), ".augmented", AGT_AGENT_CODE_NAME) : null;
39164
39193
  var DIRECT_CHAT_STALE_MARKER_MS = 24 * 60 * 60 * 1e3;
39165
39194
  function judgeCursorAdvance(input, ctx) {
39166
39195
  const verdict = classifyCursorAdvance(input);
@@ -39180,8 +39209,8 @@ function recordDirectChatDelivery(sessionId, messageIds) {
39180
39209
  delivered_at: (/* @__PURE__ */ new Date()).toISOString()
39181
39210
  });
39182
39211
  }
39183
- var DIRECT_CHAT_RECOVERY_OUTBOX_DIR = AGT_AGENT_CODE_NAME ? join14(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-recovery-outbox") : null;
39184
- var DIRECT_CHAT_RECOVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join14(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-direct-chat-recovery-ledger") : null;
39212
+ var DIRECT_CHAT_RECOVERY_OUTBOX_DIR = AGT_AGENT_CODE_NAME ? join15(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, "direct-chat-recovery-outbox") : null;
39213
+ var DIRECT_CHAT_RECOVERY_LEDGER_DIR = AGT_AGENT_CODE_NAME ? join15(homedir4(), ".augmented", AGT_AGENT_CODE_NAME, ".agt-direct-chat-recovery-ledger") : null;
39185
39214
  var progressReceivedAt = /* @__PURE__ */ new Map();
39186
39215
  var directChatProgressState = { tracked: null };
39187
39216
  var directChatProgressTickRunning = false;
@@ -39209,7 +39238,7 @@ function seedProgressHeartbeat() {
39209
39238
  if (!PROGRESS_HEARTBEAT_PATH) return;
39210
39239
  const tmp = `${PROGRESS_HEARTBEAT_PATH}.${process.pid}.tmp`;
39211
39240
  try {
39212
- mkdirSync5(join14(homedir4(), ".augmented", AGT_AGENT_CODE_NAME), { recursive: true });
39241
+ mkdirSync5(join15(homedir4(), ".augmented", AGT_AGENT_CODE_NAME), { recursive: true });
39213
39242
  writeFileSync7(tmp, serializeProgressHeartbeat(SEED_PROGRESS_STEP, Date.now()), { mode: 384 });
39214
39243
  renameSync5(tmp, PROGRESS_HEARTBEAT_PATH);
39215
39244
  } catch {
@@ -39406,7 +39435,7 @@ var inboundAttachmentDeps = {
39406
39435
  },
39407
39436
  ensureDir: (dir) => mkdirSync5(dir, { recursive: true }),
39408
39437
  writeFile: (path, bytes) => writeFileSync7(path, bytes, { mode: 384 }),
39409
- joinPath: (...parts) => join14(...parts),
39438
+ joinPath: (...parts) => join15(...parts),
39410
39439
  warn: (msg) => process.stderr.write(`${msg}
39411
39440
  `)
39412
39441
  };
@@ -39811,7 +39840,7 @@ function scheduleDirectChatBusyAck(sessionId, messageId, arrivedWhileBusy) {
39811
39840
  let paneLogFreshAgeMs = null;
39812
39841
  if (DIRECT_CHAT_CODE_NAME_AGENT_DIR) {
39813
39842
  try {
39814
- const paneMtimeMs = statSync4(join14(DIRECT_CHAT_CODE_NAME_AGENT_DIR, "pane.log")).mtimeMs;
39843
+ const paneMtimeMs = statSync4(join15(DIRECT_CHAT_CODE_NAME_AGENT_DIR, "pane.log")).mtimeMs;
39815
39844
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
39816
39845
  } catch {
39817
39846
  }
@@ -40386,7 +40415,7 @@ function directChatRecoveryDeps() {
40386
40415
  if (!DIRECT_CHAT_RECOVERY_LEDGER_DIR) return;
40387
40416
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
40388
40417
  try {
40389
- const p2 = join14(DIRECT_CHAT_RECOVERY_LEDGER_DIR, markerName);
40418
+ const p2 = join15(DIRECT_CHAT_RECOVERY_LEDGER_DIR, markerName);
40390
40419
  if (existsSync6(p2)) unlinkSync4(p2);
40391
40420
  } catch {
40392
40421
  }
@@ -40437,7 +40466,7 @@ async function processDirectChatRecoveryOutboxFile(filename) {
40437
40466
  if (!enabled) return;
40438
40467
  directChatRecoveryInFlight.add(filename);
40439
40468
  try {
40440
- const fullPath = join14(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, filename);
40469
+ const fullPath = join15(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, filename);
40441
40470
  await consumeDirectChatRecoveryFile(fullPath, filename, directChatRecoveryDeps());
40442
40471
  } catch (err) {
40443
40472
  process.stderr.write(
@@ -40465,7 +40494,7 @@ if (DIRECT_CHAT_RECOVERY_OUTBOX_DIR) {
40465
40494
  if (!filename) return;
40466
40495
  const name = filename.toString();
40467
40496
  if (!name.endsWith(".json")) return;
40468
- if (existsSync6(join14(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, name))) {
40497
+ if (existsSync6(join15(DIRECT_CHAT_RECOVERY_OUTBOX_DIR, name))) {
40469
40498
  void processDirectChatRecoveryOutboxFile(name);
40470
40499
  }
40471
40500
  });