@integrity-labs/agt-cli 0.28.1088 → 0.28.1089

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.
@@ -3599,49 +3599,49 @@ var require_fast_uri = __commonJS({
3599
3599
  schemelessOptions.skipEscape = true;
3600
3600
  return serialize(resolved, schemelessOptions);
3601
3601
  }
3602
- function resolveComponent(base, relative, options, skipNormalization) {
3602
+ function resolveComponent(base, relative2, options, skipNormalization) {
3603
3603
  const target = {};
3604
3604
  if (!skipNormalization) {
3605
3605
  base = parse3(serialize(base, options), options);
3606
- relative = parse3(serialize(relative, options), options);
3606
+ relative2 = parse3(serialize(relative2, options), options);
3607
3607
  }
3608
3608
  options = options || {};
3609
- if (!options.tolerant && relative.scheme) {
3610
- target.scheme = relative.scheme;
3611
- target.userinfo = relative.userinfo;
3612
- target.host = relative.host;
3613
- target.port = relative.port;
3614
- target.path = removeDotSegments(relative.path || "");
3615
- target.query = relative.query;
3609
+ if (!options.tolerant && relative2.scheme) {
3610
+ target.scheme = relative2.scheme;
3611
+ target.userinfo = relative2.userinfo;
3612
+ target.host = relative2.host;
3613
+ target.port = relative2.port;
3614
+ target.path = removeDotSegments(relative2.path || "");
3615
+ target.query = relative2.query;
3616
3616
  } else {
3617
- if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
3618
- target.userinfo = relative.userinfo;
3619
- target.host = relative.host;
3620
- target.port = relative.port;
3621
- target.path = removeDotSegments(relative.path || "");
3622
- target.query = relative.query;
3617
+ if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
3618
+ target.userinfo = relative2.userinfo;
3619
+ target.host = relative2.host;
3620
+ target.port = relative2.port;
3621
+ target.path = removeDotSegments(relative2.path || "");
3622
+ target.query = relative2.query;
3623
3623
  } else {
3624
- if (!relative.path) {
3624
+ if (!relative2.path) {
3625
3625
  target.path = base.path;
3626
- if (relative.query !== void 0) {
3627
- target.query = relative.query;
3626
+ if (relative2.query !== void 0) {
3627
+ target.query = relative2.query;
3628
3628
  } else {
3629
3629
  target.query = base.query;
3630
3630
  }
3631
3631
  } else {
3632
- if (relative.path[0] === "/") {
3633
- target.path = removeDotSegments(relative.path);
3632
+ if (relative2.path[0] === "/") {
3633
+ target.path = removeDotSegments(relative2.path);
3634
3634
  } else {
3635
3635
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3636
- target.path = "/" + relative.path;
3636
+ target.path = "/" + relative2.path;
3637
3637
  } else if (!base.path) {
3638
- target.path = relative.path;
3638
+ target.path = relative2.path;
3639
3639
  } else {
3640
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
3640
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
3641
3641
  }
3642
3642
  target.path = removeDotSegments(target.path);
3643
3643
  }
3644
- target.query = relative.query;
3644
+ target.query = relative2.query;
3645
3645
  }
3646
3646
  target.userinfo = base.userinfo;
3647
3647
  target.host = base.host;
@@ -3649,7 +3649,7 @@ var require_fast_uri = __commonJS({
3649
3649
  }
3650
3650
  target.scheme = base.scheme;
3651
3651
  }
3652
- target.fragment = relative.fragment;
3652
+ target.fragment = relative2.fragment;
3653
3653
  return target;
3654
3654
  }
3655
3655
  function equal(uriA, uriB, options) {
@@ -11656,10 +11656,10 @@ var require_resolve_block_map = __commonJS({
11656
11656
  let offset = bm.offset;
11657
11657
  let commentEnd = null;
11658
11658
  for (const collItem of bm.items) {
11659
- const { start, key: key2, sep: sep2, value } = collItem;
11659
+ const { start, key: key2, sep: sep3, value } = collItem;
11660
11660
  const keyProps = resolveProps.resolveProps(start, {
11661
11661
  indicator: "explicit-key-ind",
11662
- next: key2 ?? sep2?.[0],
11662
+ next: key2 ?? sep3?.[0],
11663
11663
  offset,
11664
11664
  onError,
11665
11665
  parentIndent: bm.indent,
@@ -11673,7 +11673,7 @@ var require_resolve_block_map = __commonJS({
11673
11673
  else if ("indent" in key2 && key2.indent !== bm.indent)
11674
11674
  onError(offset, "BAD_INDENT", startColMsg);
11675
11675
  }
11676
- if (!keyProps.anchor && !keyProps.tag && !sep2) {
11676
+ if (!keyProps.anchor && !keyProps.tag && !sep3) {
11677
11677
  commentEnd = keyProps.end;
11678
11678
  if (keyProps.comment) {
11679
11679
  if (map.comment)
@@ -11697,7 +11697,7 @@ var require_resolve_block_map = __commonJS({
11697
11697
  ctx.atKey = false;
11698
11698
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
11699
11699
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
11700
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
11700
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
11701
11701
  indicator: "map-value-ind",
11702
11702
  next: value,
11703
11703
  offset: keyNode.range[2],
@@ -11713,7 +11713,7 @@ var require_resolve_block_map = __commonJS({
11713
11713
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
11714
11714
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
11715
11715
  }
11716
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
11716
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep3, null, valueProps, onError);
11717
11717
  if (ctx.schema.compat)
11718
11718
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
11719
11719
  offset = valueNode.range[2];
@@ -11804,7 +11804,7 @@ var require_resolve_end = __commonJS({
11804
11804
  let comment = "";
11805
11805
  if (end) {
11806
11806
  let hasSpace = false;
11807
- let sep2 = "";
11807
+ let sep3 = "";
11808
11808
  for (const token of end) {
11809
11809
  const { source, type } = token;
11810
11810
  switch (type) {
@@ -11818,13 +11818,13 @@ var require_resolve_end = __commonJS({
11818
11818
  if (!comment)
11819
11819
  comment = cb;
11820
11820
  else
11821
- comment += sep2 + cb;
11822
- sep2 = "";
11821
+ comment += sep3 + cb;
11822
+ sep3 = "";
11823
11823
  break;
11824
11824
  }
11825
11825
  case "newline":
11826
11826
  if (comment)
11827
- sep2 += source;
11827
+ sep3 += source;
11828
11828
  hasSpace = true;
11829
11829
  break;
11830
11830
  default:
@@ -11867,18 +11867,18 @@ var require_resolve_flow_collection = __commonJS({
11867
11867
  let offset = fc.offset + fc.start.source.length;
11868
11868
  for (let i = 0; i < fc.items.length; ++i) {
11869
11869
  const collItem = fc.items[i];
11870
- const { start, key: key2, sep: sep2, value } = collItem;
11870
+ const { start, key: key2, sep: sep3, value } = collItem;
11871
11871
  const props = resolveProps.resolveProps(start, {
11872
11872
  flow: fcName,
11873
11873
  indicator: "explicit-key-ind",
11874
- next: key2 ?? sep2?.[0],
11874
+ next: key2 ?? sep3?.[0],
11875
11875
  offset,
11876
11876
  onError,
11877
11877
  parentIndent: fc.indent,
11878
11878
  startOnNewline: false
11879
11879
  });
11880
11880
  if (!props.found) {
11881
- if (!props.anchor && !props.tag && !sep2 && !value) {
11881
+ if (!props.anchor && !props.tag && !sep3 && !value) {
11882
11882
  if (i === 0 && props.comma)
11883
11883
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
11884
11884
  else if (i < fc.items.length - 1)
@@ -11932,8 +11932,8 @@ var require_resolve_flow_collection = __commonJS({
11932
11932
  }
11933
11933
  }
11934
11934
  }
11935
- if (!isMap && !sep2 && !props.found) {
11936
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
11935
+ if (!isMap && !sep3 && !props.found) {
11936
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep3, null, props, onError);
11937
11937
  coll.items.push(valueNode);
11938
11938
  offset = valueNode.range[2];
11939
11939
  if (isBlock(value))
@@ -11945,7 +11945,7 @@ var require_resolve_flow_collection = __commonJS({
11945
11945
  if (isBlock(key2))
11946
11946
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
11947
11947
  ctx.atKey = false;
11948
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
11948
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
11949
11949
  flow: fcName,
11950
11950
  indicator: "map-value-ind",
11951
11951
  next: value,
@@ -11956,8 +11956,8 @@ var require_resolve_flow_collection = __commonJS({
11956
11956
  });
11957
11957
  if (valueProps.found) {
11958
11958
  if (!isMap && !props.found && ctx.options.strict) {
11959
- if (sep2)
11960
- for (const st of sep2) {
11959
+ if (sep3)
11960
+ for (const st of sep3) {
11961
11961
  if (st === valueProps.found)
11962
11962
  break;
11963
11963
  if (st.type === "newline") {
@@ -11974,7 +11974,7 @@ var require_resolve_flow_collection = __commonJS({
11974
11974
  else
11975
11975
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
11976
11976
  }
11977
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
11977
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep3, null, valueProps, onError) : null;
11978
11978
  if (valueNode) {
11979
11979
  if (isBlock(value))
11980
11980
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -12154,7 +12154,7 @@ var require_resolve_block_scalar = __commonJS({
12154
12154
  chompStart = i + 1;
12155
12155
  }
12156
12156
  let value = "";
12157
- let sep2 = "";
12157
+ let sep3 = "";
12158
12158
  let prevMoreIndented = false;
12159
12159
  for (let i = 0; i < contentStart; ++i)
12160
12160
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -12171,24 +12171,24 @@ var require_resolve_block_scalar = __commonJS({
12171
12171
  indent = "";
12172
12172
  }
12173
12173
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
12174
- value += sep2 + indent.slice(trimIndent) + content;
12175
- sep2 = "\n";
12174
+ value += sep3 + indent.slice(trimIndent) + content;
12175
+ sep3 = "\n";
12176
12176
  } else if (indent.length > trimIndent || content[0] === " ") {
12177
- if (sep2 === " ")
12178
- sep2 = "\n";
12179
- else if (!prevMoreIndented && sep2 === "\n")
12180
- sep2 = "\n\n";
12181
- value += sep2 + indent.slice(trimIndent) + content;
12182
- sep2 = "\n";
12177
+ if (sep3 === " ")
12178
+ sep3 = "\n";
12179
+ else if (!prevMoreIndented && sep3 === "\n")
12180
+ sep3 = "\n\n";
12181
+ value += sep3 + indent.slice(trimIndent) + content;
12182
+ sep3 = "\n";
12183
12183
  prevMoreIndented = true;
12184
12184
  } else if (content === "") {
12185
- if (sep2 === "\n")
12185
+ if (sep3 === "\n")
12186
12186
  value += "\n";
12187
12187
  else
12188
- sep2 = "\n";
12188
+ sep3 = "\n";
12189
12189
  } else {
12190
- value += sep2 + content;
12191
- sep2 = " ";
12190
+ value += sep3 + content;
12191
+ sep3 = " ";
12192
12192
  prevMoreIndented = false;
12193
12193
  }
12194
12194
  }
@@ -12370,25 +12370,25 @@ var require_resolve_flow_scalar = __commonJS({
12370
12370
  if (!match)
12371
12371
  return source;
12372
12372
  let res = match[1];
12373
- let sep2 = " ";
12373
+ let sep3 = " ";
12374
12374
  let pos = first.lastIndex;
12375
12375
  line.lastIndex = pos;
12376
12376
  while (match = line.exec(source)) {
12377
12377
  if (match[1] === "") {
12378
- if (sep2 === "\n")
12379
- res += sep2;
12378
+ if (sep3 === "\n")
12379
+ res += sep3;
12380
12380
  else
12381
- sep2 = "\n";
12381
+ sep3 = "\n";
12382
12382
  } else {
12383
- res += sep2 + match[1];
12384
- sep2 = " ";
12383
+ res += sep3 + match[1];
12384
+ sep3 = " ";
12385
12385
  }
12386
12386
  pos = line.lastIndex;
12387
12387
  }
12388
12388
  const last = /[ \t]*(.*)/sy;
12389
12389
  last.lastIndex = pos;
12390
12390
  match = last.exec(source);
12391
- return res + sep2 + (match?.[1] ?? "");
12391
+ return res + sep3 + (match?.[1] ?? "");
12392
12392
  }
12393
12393
  function doubleQuotedValue(source, onError) {
12394
12394
  let res = "";
@@ -13196,14 +13196,14 @@ var require_cst_stringify = __commonJS({
13196
13196
  }
13197
13197
  }
13198
13198
  }
13199
- function stringifyItem({ start, key: key2, sep: sep2, value }) {
13199
+ function stringifyItem({ start, key: key2, sep: sep3, value }) {
13200
13200
  let res = "";
13201
13201
  for (const st of start)
13202
13202
  res += st.source;
13203
13203
  if (key2)
13204
13204
  res += stringifyToken(key2);
13205
- if (sep2)
13206
- for (const st of sep2)
13205
+ if (sep3)
13206
+ for (const st of sep3)
13207
13207
  res += st.source;
13208
13208
  if (value)
13209
13209
  res += stringifyToken(value);
@@ -14353,18 +14353,18 @@ var require_parser = __commonJS({
14353
14353
  if (this.type === "map-value-ind") {
14354
14354
  const prev = getPrevProps(this.peek(2));
14355
14355
  const start = getFirstKeyStartProps(prev);
14356
- let sep2;
14356
+ let sep3;
14357
14357
  if (scalar.end) {
14358
- sep2 = scalar.end;
14359
- sep2.push(this.sourceToken);
14358
+ sep3 = scalar.end;
14359
+ sep3.push(this.sourceToken);
14360
14360
  delete scalar.end;
14361
14361
  } else
14362
- sep2 = [this.sourceToken];
14362
+ sep3 = [this.sourceToken];
14363
14363
  const map = {
14364
14364
  type: "block-map",
14365
14365
  offset: scalar.offset,
14366
14366
  indent: scalar.indent,
14367
- items: [{ start, key: scalar, sep: sep2 }]
14367
+ items: [{ start, key: scalar, sep: sep3 }]
14368
14368
  };
14369
14369
  this.onKeyLine = true;
14370
14370
  this.stack[this.stack.length - 1] = map;
@@ -14517,15 +14517,15 @@ var require_parser = __commonJS({
14517
14517
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
14518
14518
  const start2 = getFirstKeyStartProps(it.start);
14519
14519
  const key2 = it.key;
14520
- const sep2 = it.sep;
14521
- sep2.push(this.sourceToken);
14520
+ const sep3 = it.sep;
14521
+ sep3.push(this.sourceToken);
14522
14522
  delete it.key;
14523
14523
  delete it.sep;
14524
14524
  this.stack.push({
14525
14525
  type: "block-map",
14526
14526
  offset: this.offset,
14527
14527
  indent: this.indent,
14528
- items: [{ start: start2, key: key2, sep: sep2 }]
14528
+ items: [{ start: start2, key: key2, sep: sep3 }]
14529
14529
  });
14530
14530
  } else if (start.length > 0) {
14531
14531
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -14719,13 +14719,13 @@ var require_parser = __commonJS({
14719
14719
  const prev = getPrevProps(parent);
14720
14720
  const start = getFirstKeyStartProps(prev);
14721
14721
  fixFlowSeqItems(fc);
14722
- const sep2 = fc.end.splice(1, fc.end.length);
14723
- sep2.push(this.sourceToken);
14722
+ const sep3 = fc.end.splice(1, fc.end.length);
14723
+ sep3.push(this.sourceToken);
14724
14724
  const map = {
14725
14725
  type: "block-map",
14726
14726
  offset: fc.offset,
14727
14727
  indent: fc.indent,
14728
- items: [{ start, key: fc, sep: sep2 }]
14728
+ items: [{ start, key: fc, sep: sep3 }]
14729
14729
  };
14730
14730
  this.onKeyLine = true;
14731
14731
  this.stack[this.stack.length - 1] = map;
@@ -18932,7 +18932,7 @@ var require_filters = __commonJS({
18932
18932
  return r.copySafeness(str, res);
18933
18933
  }
18934
18934
  _exports.indent = indent;
18935
- function join17(arr, del, attr) {
18935
+ function join19(arr, del, attr) {
18936
18936
  del = del || "";
18937
18937
  if (attr) {
18938
18938
  arr = lib.map(arr, function(v) {
@@ -18941,7 +18941,7 @@ var require_filters = __commonJS({
18941
18941
  }
18942
18942
  return arr.join(del);
18943
18943
  }
18944
- _exports.join = join17;
18944
+ _exports.join = join19;
18945
18945
  function last(arr) {
18946
18946
  return arr[arr.length - 1];
18947
18947
  }
@@ -20107,9 +20107,9 @@ var require_handler = __commonJS({
20107
20107
  if (this.fsw.closed) {
20108
20108
  return;
20109
20109
  }
20110
- const dirname4 = sysPath.dirname(file);
20110
+ const dirname5 = sysPath.dirname(file);
20111
20111
  const basename2 = sysPath.basename(file);
20112
- const parent = this.fsw._getWatchedDir(dirname4);
20112
+ const parent = this.fsw._getWatchedDir(dirname5);
20113
20113
  let prevStats = stats;
20114
20114
  if (parent.has(basename2))
20115
20115
  return;
@@ -20136,7 +20136,7 @@ var require_handler = __commonJS({
20136
20136
  prevStats = newStats2;
20137
20137
  }
20138
20138
  } catch (error2) {
20139
- this.fsw._remove(dirname4, basename2);
20139
+ this.fsw._remove(dirname5, basename2);
20140
20140
  }
20141
20141
  } else if (parent.has(basename2)) {
20142
20142
  const at = newStats.atimeMs;
@@ -20400,11 +20400,11 @@ var require_chokidar = __commonJS({
20400
20400
  if (matcher.path === string3)
20401
20401
  return true;
20402
20402
  if (matcher.recursive) {
20403
- const relative = sysPath.relative(matcher.path, string3);
20404
- if (!relative) {
20403
+ const relative2 = sysPath.relative(matcher.path, string3);
20404
+ if (!relative2) {
20405
20405
  return false;
20406
20406
  }
20407
- return !relative.startsWith("..") && !sysPath.isAbsolute(relative);
20407
+ return !relative2.startsWith("..") && !sysPath.isAbsolute(relative2);
20408
20408
  }
20409
20409
  return false;
20410
20410
  };
@@ -21372,11 +21372,11 @@ var require_globals = __commonJS({
21372
21372
  }
21373
21373
  };
21374
21374
  }
21375
- function _joiner(sep2) {
21376
- sep2 = sep2 || ",";
21375
+ function _joiner(sep3) {
21376
+ sep3 = sep3 || ",";
21377
21377
  var first = true;
21378
21378
  return function() {
21379
- var val = first ? "" : sep2;
21379
+ var val = first ? "" : sep3;
21380
21380
  first = false;
21381
21381
  return val;
21382
21382
  };
@@ -21406,8 +21406,8 @@ var require_globals = __commonJS({
21406
21406
  cycler: function cycler() {
21407
21407
  return _cycler(Array.prototype.slice.call(arguments));
21408
21408
  },
21409
- joiner: function joiner(sep2) {
21410
- return _joiner(sep2);
21409
+ joiner: function joiner(sep3) {
21410
+ return _joiner(sep3);
21411
21411
  }
21412
21412
  };
21413
21413
  }
@@ -30187,9 +30187,9 @@ import {
30187
30187
  createWriteStream,
30188
30188
  existsSync as existsSync9,
30189
30189
  ftruncateSync,
30190
- mkdirSync as mkdirSync9,
30190
+ mkdirSync as mkdirSync10,
30191
30191
  openSync as openSync2,
30192
- readFileSync as readFileSync14,
30192
+ readFileSync as readFileSync15,
30193
30193
  readdirSync as readdirSync6,
30194
30194
  realpathSync,
30195
30195
  renameSync as renameSync7,
@@ -30199,8 +30199,8 @@ import {
30199
30199
  writeFileSync as writeFileSync11,
30200
30200
  writeSync
30201
30201
  } from "fs";
30202
- import { homedir as homedir6 } from "os";
30203
- import { basename, extname, join as join16, resolve as resolve2 } from "path";
30202
+ import { homedir as homedir7 } from "os";
30203
+ import { basename, extname, join as join18, resolve as resolve2 } from "path";
30204
30204
 
30205
30205
  // ../core/dist/channels/interim-promise.js
30206
30206
  function decideMarkerEngagement(marker, kind, nowIso) {
@@ -40063,6 +40063,9 @@ function foldTurnInitiatorLedger(existing, marker, maxAgeMs = TURN_INITIATOR_MAX
40063
40063
  sender_id: marker.sender_id,
40064
40064
  ...marker.sender_name ? { sender_name: marker.sender_name } : {},
40065
40065
  ...marker.channel_ref ? { channel_ref: marker.channel_ref } : {},
40066
+ ...marker.chat_kind ? { chat_kind: marker.chat_kind } : {},
40067
+ ...marker.chat_id ? { chat_id: marker.chat_id } : {},
40068
+ ...marker.unattributed ? { unattributed: true } : {},
40066
40069
  ts: marker.ts
40067
40070
  });
40068
40071
  kept.sort((a, b) => b.ts - a.ts);
@@ -40077,7 +40080,7 @@ function updateTurnInitiatorLedger(singleSlotFile, marker) {
40077
40080
  } catch {
40078
40081
  }
40079
40082
  const next = foldTurnInitiatorLedger(existing, marker);
40080
- const tmp = `${ledgerFile}.tmp`;
40083
+ const tmp = `${ledgerFile}.${process.pid}.${Date.now()}.tmp`;
40081
40084
  writeFileSync4(tmp, JSON.stringify(next), "utf8");
40082
40085
  renameSync3(tmp, ledgerFile);
40083
40086
  }
@@ -40098,18 +40101,91 @@ function writeTurnInitiatorMarker(input) {
40098
40101
  }
40099
40102
  }
40100
40103
 
40104
+ // src/turn-context.ts
40105
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync7 } from "fs";
40106
+ import { homedir as homedir4 } from "os";
40107
+ import { dirname as dirname4, join as join7 } from "path";
40108
+
40109
+ // ../core/dist/provisioning/frameworks/claudecode/agent-dir-alias.js
40110
+ import { isAbsolute, join as join5, relative, sep as sep2 } from "path";
40111
+ var VALID_CODE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
40112
+ 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}$/;
40113
+ var INITIATOR_BASENAME = ".current-turn-initiator.json";
40114
+ function isSafeAgentSegment(segment) {
40115
+ return VALID_CODE_NAME.test(segment) || VALID_AGENT_ID.test(segment);
40116
+ }
40117
+ function initiatorDirSegment(initiatorFile, homeDir) {
40118
+ const rel = relative(join5(homeDir, ".augmented"), initiatorFile);
40119
+ if (!rel || isAbsolute(rel))
40120
+ return null;
40121
+ const parts = rel.split(sep2);
40122
+ if (parts.length !== 2 || parts[1] !== INITIATOR_BASENAME)
40123
+ return null;
40124
+ const segment = parts[0];
40125
+ if (segment === void 0)
40126
+ return null;
40127
+ return isSafeAgentSegment(segment) ? segment : null;
40128
+ }
40129
+ function resolveAgentDirAlias(input) {
40130
+ const { codeName, turnInitiatorFile, agentId, homeDir } = input;
40131
+ const codeNameTrimmed = typeof codeName === "string" ? codeName.trim() : "";
40132
+ if (codeNameTrimmed && VALID_CODE_NAME.test(codeNameTrimmed)) {
40133
+ return join5(homeDir, ".augmented", codeNameTrimmed);
40134
+ }
40135
+ const initiator = typeof turnInitiatorFile === "string" ? turnInitiatorFile.trim() : "";
40136
+ if (initiator) {
40137
+ const segment = initiatorDirSegment(initiator, homeDir);
40138
+ if (segment)
40139
+ return join5(homeDir, ".augmented", segment);
40140
+ }
40141
+ const agentIdTrimmed = typeof agentId === "string" ? agentId.trim() : "";
40142
+ if (agentIdTrimmed && VALID_AGENT_ID.test(agentIdTrimmed)) {
40143
+ return join5(homeDir, ".augmented", agentIdTrimmed);
40144
+ }
40145
+ return null;
40146
+ }
40147
+
40101
40148
  // src/scheduled-turn-marker.ts
40102
40149
  import { readFileSync as readFileSync6, unlinkSync as unlinkSync4 } from "fs";
40103
- import { join as join5 } from "path";
40150
+ import { join as join6 } from "path";
40104
40151
  var SCHEDULED_TURN_MARKER_FILENAME2 = ".current-scheduled-turn.json";
40105
40152
  var SCHEDULED_TURN_MAX_AGE_MS = 15 * 60 * 1e3;
40106
40153
  function clearScheduledTurnMarker(agentDir) {
40107
40154
  if (!agentDir) return;
40108
40155
  try {
40109
- unlinkSync4(join5(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
40156
+ unlinkSync4(join6(agentDir, SCHEDULED_TURN_MARKER_FILENAME2));
40157
+ } catch {
40158
+ }
40159
+ }
40160
+
40161
+ // src/turn-context.ts
40162
+ var TURN_INITIATOR_MARKER_FILENAME = ".current-turn-initiator.json";
40163
+ function writeUnattributedTurnMarker(channel, opts = {}) {
40164
+ try {
40165
+ const file = resolveTurnInitiatorFile(opts.env ?? process.env, opts.home ?? homedir4());
40166
+ if (!file) return;
40167
+ mkdirSync5(dirname4(file), { recursive: true });
40168
+ updateTurnInitiatorLedger(file, {
40169
+ channel,
40170
+ sender_id: "",
40171
+ channel_ref: "unattributed",
40172
+ unattributed: true,
40173
+ ts: opts.now ?? Date.now()
40174
+ });
40110
40175
  } catch {
40111
40176
  }
40112
40177
  }
40178
+ function resolveTurnInitiatorFile(env2 = process.env, home = homedir4()) {
40179
+ const injected = env2["AGT_TURN_INITIATOR_FILE"]?.trim();
40180
+ if (injected) return injected;
40181
+ const dir = resolveAgentDirAlias({
40182
+ codeName: env2["AGT_AGENT_CODE_NAME"],
40183
+ agentId: env2["AGT_AGENT_ID"],
40184
+ turnInitiatorFile: null,
40185
+ homeDir: home
40186
+ });
40187
+ return dir ? join7(dir, TURN_INITIATOR_MARKER_FILENAME) : null;
40188
+ }
40113
40189
 
40114
40190
  // src/watch-command.ts
40115
40191
  var WATCH_DEFAULT_DURATION_MS = 2 * 60 * 60 * 1e3;
@@ -40757,8 +40833,8 @@ function buildCommandRegistrations() {
40757
40833
  // src/telegram-offset-store.ts
40758
40834
  import {
40759
40835
  existsSync as existsSync3,
40760
- mkdirSync as mkdirSync5,
40761
- readFileSync as readFileSync7,
40836
+ mkdirSync as mkdirSync6,
40837
+ readFileSync as readFileSync8,
40762
40838
  renameSync as renameSync4,
40763
40839
  unlinkSync as unlinkSync5,
40764
40840
  writeFileSync as writeFileSync5
@@ -40768,7 +40844,7 @@ function loadPersistedOffset(filePath) {
40768
40844
  if (!filePath) return 0;
40769
40845
  try {
40770
40846
  const parsed = JSON.parse(
40771
- readFileSync7(filePath, "utf-8")
40847
+ readFileSync8(filePath, "utf-8")
40772
40848
  );
40773
40849
  const offset = parsed?.offset;
40774
40850
  if (typeof offset === "number" && Number.isFinite(offset) && offset > 0) {
@@ -40790,7 +40866,7 @@ function persistOffset(opts) {
40790
40866
  };
40791
40867
  const tmpPath = `${filePath}.${process.pid}.${randomUUID2()}.tmp`;
40792
40868
  try {
40793
- mkdirSync5(dir, { recursive: true, mode: 448 });
40869
+ mkdirSync6(dir, { recursive: true, mode: 448 });
40794
40870
  writeFileSync5(tmpPath, JSON.stringify(marker), { mode: 384 });
40795
40871
  renameSync4(tmpPath, filePath);
40796
40872
  } catch (err) {
@@ -40812,8 +40888,8 @@ function conversationalLaneMeta(expectsReply = true) {
40812
40888
  }
40813
40889
 
40814
40890
  // src/inbound-lane-telemetry.ts
40815
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
40816
- import { join as join6 } from "path";
40891
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "fs";
40892
+ import { join as join8 } from "path";
40817
40893
  var LANE_CLASSIFICATION_COUNTER_SUFFIX = "-lane-classifications.json";
40818
40894
  var SUSPECTED_MISCLASSIFICATION_KEY = "suspected_misclassification";
40819
40895
  var HUMAN_CHANNEL_SOURCES = /* @__PURE__ */ new Set([
@@ -40830,10 +40906,10 @@ function isSuspectedMisclassification(lane, source) {
40830
40906
  }
40831
40907
  function recordLaneClassification(agentDir, channel, classification) {
40832
40908
  if (!agentDir) return;
40833
- const path = join6(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
40909
+ const path = join8(agentDir, `${channel}${LANE_CLASSIFICATION_COUNTER_SUFFIX}`);
40834
40910
  let counts = {};
40835
40911
  try {
40836
- const parsed = JSON.parse(readFileSync8(path, "utf-8"));
40912
+ const parsed = JSON.parse(readFileSync9(path, "utf-8"));
40837
40913
  if (parsed && typeof parsed === "object") counts = parsed;
40838
40914
  } catch {
40839
40915
  }
@@ -40849,15 +40925,15 @@ function recordLaneClassification(agentDir, channel, classification) {
40849
40925
  }
40850
40926
 
40851
40927
  // src/agent-config-state.ts
40852
- import { existsSync as existsSync4, readFileSync as readFileSync9 } from "fs";
40853
- import { join as join7 } from "path";
40928
+ import { existsSync as existsSync4, readFileSync as readFileSync10 } from "fs";
40929
+ import { join as join9 } from "path";
40854
40930
  var SESSION_STATE_FILENAME = "session-state.json";
40855
40931
  function readAgentSessionState(stateDir) {
40856
40932
  if (!stateDir) return null;
40857
- const path = join7(stateDir, SESSION_STATE_FILENAME);
40933
+ const path = join9(stateDir, SESSION_STATE_FILENAME);
40858
40934
  if (!existsSync4(path)) return null;
40859
40935
  try {
40860
- const parsed = JSON.parse(readFileSync9(path, "utf-8"));
40936
+ const parsed = JSON.parse(readFileSync10(path, "utf-8"));
40861
40937
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
40862
40938
  return parsed;
40863
40939
  } catch {
@@ -41822,8 +41898,8 @@ function emitToolCallMarkupRedactionTelemetry(channel) {
41822
41898
 
41823
41899
  // src/rate-limit-watch.ts
41824
41900
  import { closeSync, fstatSync, openSync, readSync, readdirSync, statSync } from "fs";
41825
- import { homedir as homedir4 } from "os";
41826
- import { join as join8 } from "path";
41901
+ import { homedir as homedir5 } from "os";
41902
+ import { join as join10 } from "path";
41827
41903
  var DEFAULT_WATCH_MS = 5e3;
41828
41904
  var DEFAULT_POLL_MS = 400;
41829
41905
  var INITIAL_TAIL_BYTES = 256 * 1024;
@@ -41894,8 +41970,8 @@ function oldestTimestampMs(text) {
41894
41970
  }
41895
41971
  function agentTranscriptDir(opts) {
41896
41972
  const cwd = opts?.cwd ?? process.cwd();
41897
- const home = opts?.home ?? homedir4();
41898
- return join8(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
41973
+ const home = opts?.home ?? homedir5();
41974
+ return join10(home, ".claude", "projects", encodeClaudeProjectPath(cwd));
41899
41975
  }
41900
41976
  function classifyTranscriptSince(opts) {
41901
41977
  const dir = opts.transcriptDir ?? agentTranscriptDir({ cwd: opts.cwd, home: opts.home });
@@ -41908,7 +41984,7 @@ function classifyTranscriptSince(opts) {
41908
41984
  let newest = UNKNOWN_RATE_LIMIT;
41909
41985
  for (const name of entries) {
41910
41986
  if (!name.endsWith(".jsonl")) continue;
41911
- const path = join8(dir, name);
41987
+ const path = join10(dir, name);
41912
41988
  try {
41913
41989
  const st = statSync(path);
41914
41990
  if (!st.isFile() || st.mtimeMs < opts.sinceMs) continue;
@@ -41955,7 +42031,7 @@ async function watchForRateLimitRefusal(opts) {
41955
42031
 
41956
42032
  // src/turn-failure-watch.ts
41957
42033
  import { readdirSync as readdirSync2, statSync as statSync2 } from "fs";
41958
- import { join as join9 } from "path";
42034
+ import { join as join11 } from "path";
41959
42035
  function turnFailureNoticeEnabled(env2) {
41960
42036
  return resolveHostBooleanFlag({
41961
42037
  key: "wedge-transient-notice",
@@ -41985,7 +42061,7 @@ function classifyTurnFailureSince(opts) {
41985
42061
  const unrecognised = /* @__PURE__ */ new Set();
41986
42062
  for (const name of entries) {
41987
42063
  if (!name.endsWith(".jsonl")) continue;
41988
- const path = join9(dir, name);
42064
+ const path = join11(dir, name);
41989
42065
  let fingerprint;
41990
42066
  try {
41991
42067
  const st = statSync2(path);
@@ -42127,9 +42203,9 @@ function describeUnparsedRefusal(text) {
42127
42203
 
42128
42204
  // src/reply-intent-runtime.ts
42129
42205
  import { execFile as execFile2 } from "child_process";
42130
- import { existsSync as existsSync5, mkdirSync as mkdirSync6, writeFileSync as writeFileSync7 } from "fs";
42131
- import { homedir as homedir5 } from "os";
42132
- import { join as join10 } from "path";
42206
+ import { existsSync as existsSync5, mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "fs";
42207
+ import { homedir as homedir6 } from "os";
42208
+ import { join as join12 } from "path";
42133
42209
  var DEFAULT_CLAUDE_EVAL_MODEL = "claude-haiku-4-5-20251001";
42134
42210
  var DEFAULT_ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
42135
42211
  var ANTHROPIC_API_VERSION = "2023-06-01";
@@ -42228,12 +42304,12 @@ async function runAnthropicMessages(prompt, opts) {
42228
42304
  var emptyMcpConfigPath = null;
42229
42305
  function ensureEmptyMcpConfig() {
42230
42306
  if (emptyMcpConfigPath && existsSync5(emptyMcpConfigPath)) return emptyMcpConfigPath;
42231
- const dir = join10(homedir5(), ".augmented");
42307
+ const dir = join12(homedir6(), ".augmented");
42232
42308
  try {
42233
- mkdirSync6(dir, { recursive: true });
42309
+ mkdirSync7(dir, { recursive: true });
42234
42310
  } catch {
42235
42311
  }
42236
- const p2 = join10(dir, ".reply-intent-empty-mcp.json");
42312
+ const p2 = join12(dir, ".reply-intent-empty-mcp.json");
42237
42313
  writeFileSync7(p2, JSON.stringify({ mcpServers: {} }));
42238
42314
  emptyMcpConfigPath = p2;
42239
42315
  return p2;
@@ -42258,7 +42334,7 @@ function runClaudeP(prompt, model) {
42258
42334
  execFile2(
42259
42335
  "claude",
42260
42336
  args,
42261
- { cwd: homedir5(), timeout: CLASSIFY_TIMEOUT_MS, maxBuffer: 1 << 20 },
42337
+ { cwd: homedir6(), timeout: CLASSIFY_TIMEOUT_MS, maxBuffer: 1 << 20 },
42262
42338
  (err, stdout) => {
42263
42339
  if (err) {
42264
42340
  reject(err);
@@ -42380,11 +42456,11 @@ function emitTransientApiErrorTelemetry(channel, match, original) {
42380
42456
  }
42381
42457
 
42382
42458
  // src/telegram-pending-inbound-cleanup.ts
42383
- import { readdirSync as readdirSync3, readFileSync as readFileSync10, statSync as statSync3 } from "fs";
42384
- import { join as join11 } from "path";
42459
+ import { readdirSync as readdirSync3, readFileSync as readFileSync11, statSync as statSync3 } from "fs";
42460
+ import { join as join13 } from "path";
42385
42461
  function markerArrivalMs(fullPath) {
42386
42462
  try {
42387
- const received = JSON.parse(readFileSync10(fullPath, "utf-8")).received_at;
42463
+ const received = JSON.parse(readFileSync11(fullPath, "utf-8")).received_at;
42388
42464
  const parsed = received ? Date.parse(received) : Number.NaN;
42389
42465
  if (Number.isFinite(parsed)) return parsed;
42390
42466
  } catch {
@@ -42414,7 +42490,7 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
42414
42490
  for (const filename of filenames) {
42415
42491
  if (!filename.startsWith(prefix)) continue;
42416
42492
  if (!filename.endsWith(".json")) continue;
42417
- const fullPath = join11(pendingDir, filename);
42493
+ const fullPath = join13(pendingDir, filename);
42418
42494
  if (bounded && markerArrivalMs(fullPath) > cutoffMs) continue;
42419
42495
  op(fullPath);
42420
42496
  applied++;
@@ -42424,12 +42500,12 @@ function applyToChatMarkers(pendingDir, chatId, op, cutoffMs) {
42424
42500
 
42425
42501
  // src/recovery-ledger.ts
42426
42502
  import { existsSync as existsSync6, unlinkSync as unlinkSync6 } from "fs";
42427
- import { join as join12 } from "path";
42503
+ import { join as join14 } from "path";
42428
42504
  function recoveryLedgerEntryExists(ledgerDir, markerName, exists = (p2) => existsSync6(p2)) {
42429
42505
  if (!ledgerDir || !markerName) return false;
42430
42506
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return false;
42431
42507
  try {
42432
- return exists(join12(ledgerDir, markerName));
42508
+ return exists(join14(ledgerDir, markerName));
42433
42509
  } catch {
42434
42510
  return false;
42435
42511
  }
@@ -42440,23 +42516,23 @@ function removeRecoveryLedgerEntry(ledgerDir, markerName, unlink = (p2) => {
42440
42516
  if (!ledgerDir || !markerName) return;
42441
42517
  if (markerName.includes("/") || markerName.includes("\\") || markerName.includes("..")) return;
42442
42518
  try {
42443
- unlink(join12(ledgerDir, markerName));
42519
+ unlink(join14(ledgerDir, markerName));
42444
42520
  } catch {
42445
42521
  }
42446
42522
  }
42447
42523
 
42448
42524
  // src/inbound-delivery-ledger.ts
42449
- import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync4, readFileSync as readFileSync11, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
42450
- import { join as join13 } from "path";
42525
+ import { existsSync as existsSync7, mkdirSync as mkdirSync8, readdirSync as readdirSync4, readFileSync as readFileSync12, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
42526
+ import { join as join15 } from "path";
42451
42527
  function safeInboundId(inboundId) {
42452
42528
  return inboundId.replace(/[^A-Za-z0-9_-]/g, "_");
42453
42529
  }
42454
42530
  var defaultDeps = {
42455
- mkdir: (dir) => mkdirSync7(dir, { recursive: true }),
42531
+ mkdir: (dir) => mkdirSync8(dir, { recursive: true }),
42456
42532
  writeFile: (path, data) => writeFileSync8(path, data, "utf8"),
42457
42533
  rename: (from, to) => renameSync5(from, to),
42458
42534
  readdir: (dir) => readdirSync4(dir),
42459
- readFile: (path) => readFileSync11(path, "utf8"),
42535
+ readFile: (path) => readFileSync12(path, "utf8"),
42460
42536
  exists: (path) => existsSync7(path)
42461
42537
  };
42462
42538
  function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
@@ -42465,7 +42541,7 @@ function writeInboundDeliveryLedgerEntry(dir, record2, deps = defaultDeps) {
42465
42541
  if (!safe || safe.includes("/") || safe.includes("\\") || safe.includes("..")) return;
42466
42542
  try {
42467
42543
  deps.mkdir(dir);
42468
- const final = join13(dir, `${safe}.json`);
42544
+ const final = join15(dir, `${safe}.json`);
42469
42545
  const tmp = `${final}.tmp`;
42470
42546
  deps.writeFile(tmp, JSON.stringify(record2));
42471
42547
  deps.rename(tmp, final);
@@ -42697,15 +42773,15 @@ function createKanbanCardActiveClient(args) {
42697
42773
  // src/mcp-spawn-lock.ts
42698
42774
  import {
42699
42775
  existsSync as existsSync8,
42700
- mkdirSync as mkdirSync8,
42701
- readFileSync as readFileSync12,
42776
+ mkdirSync as mkdirSync9,
42777
+ readFileSync as readFileSync13,
42702
42778
  renameSync as renameSync6,
42703
42779
  statSync as statSync4,
42704
42780
  unlinkSync as unlinkSync7,
42705
42781
  utimesSync,
42706
42782
  writeFileSync as writeFileSync9
42707
42783
  } from "fs";
42708
- import { join as join14 } from "path";
42784
+ import { join as join16 } from "path";
42709
42785
  var STALE_LOCK_MS = 9e4;
42710
42786
  var HEARTBEAT_INTERVAL_MS = 3e4;
42711
42787
  function defaultIsPidAlive(pid) {
@@ -42728,7 +42804,7 @@ function acquireMcpSpawnLock(args) {
42728
42804
  const nowMs = options.nowMs ?? (() => Date.now());
42729
42805
  const lockMtimeMs = options.lockMtimeMs ?? defaultLockMtimeMs;
42730
42806
  const staleMs = options.staleMs ?? STALE_LOCK_MS;
42731
- const path = join14(agentDir, basename2);
42807
+ const path = join16(agentDir, basename2);
42732
42808
  const existing = readLockHolder(path);
42733
42809
  if (existing) {
42734
42810
  if (existing.pid === selfPid) {
@@ -42742,7 +42818,7 @@ function acquireMcpSpawnLock(args) {
42742
42818
  }
42743
42819
  }
42744
42820
  }
42745
- mkdirSync8(agentDir, { recursive: true, mode: 448 });
42821
+ mkdirSync9(agentDir, { recursive: true, mode: 448 });
42746
42822
  const tmpPath = `${path}.${selfPid}.tmp`;
42747
42823
  const payload = { pid: selfPid, started_at: now() };
42748
42824
  writeFileSync9(tmpPath, JSON.stringify(payload), { mode: 384 });
@@ -42795,7 +42871,7 @@ function defaultLockMtimeMs(path) {
42795
42871
  function readLockHolder(path) {
42796
42872
  if (!existsSync8(path)) return null;
42797
42873
  try {
42798
- const raw = readFileSync12(path, "utf8");
42874
+ const raw = readFileSync13(path, "utf8");
42799
42875
  const parsed = JSON.parse(raw);
42800
42876
  const pid = typeof parsed.pid === "number" ? parsed.pid : Number(parsed.pid);
42801
42877
  if (!Number.isFinite(pid) || pid <= 0) return null;
@@ -42807,8 +42883,8 @@ function readLockHolder(path) {
42807
42883
  }
42808
42884
 
42809
42885
  // src/ack-reaction.ts
42810
- import { readdirSync as readdirSync5, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
42811
- import { join as join15 } from "path";
42886
+ import { readdirSync as readdirSync5, readFileSync as readFileSync14, writeFileSync as writeFileSync10 } from "fs";
42887
+ import { join as join17 } from "path";
42812
42888
 
42813
42889
  // ../core/dist/channels/deflection-causes.js
42814
42890
  var DEFLECTION_CAUSES = [
@@ -43105,7 +43181,7 @@ var GIVE_UP_SIGNAL_MAX_AGE_MS = 30 * 60 * 1e3;
43105
43181
  function readGiveUpSignal(path, now = Date.now()) {
43106
43182
  if (!path) return null;
43107
43183
  try {
43108
- const raw = JSON.parse(readFileSync13(path, "utf8"));
43184
+ const raw = JSON.parse(readFileSync14(path, "utf8"));
43109
43185
  if (typeof raw.gave_up_at !== "string") return null;
43110
43186
  const t = Date.parse(raw.gave_up_at);
43111
43187
  if (!Number.isFinite(t) || t > now) return null;
@@ -43119,12 +43195,12 @@ function readGiveUpSignal(path, now = Date.now()) {
43119
43195
  var USAGE_LIMIT_LIVE_WINDOW_MS = 3 * 6e4;
43120
43196
  function readUsageLimitForBusyAck(agentDir, now = Date.now()) {
43121
43197
  if (!agentDir) return null;
43122
- const path = join15(agentDir, GIVE_UP_SIGNAL_FILENAME);
43198
+ const path = join17(agentDir, GIVE_UP_SIGNAL_FILENAME);
43123
43199
  const sig = readGiveUpSignal(path, now);
43124
43200
  if (sig?.reason !== "usage_limit") return null;
43125
43201
  let lastSeenMs = null;
43126
43202
  try {
43127
- const raw = JSON.parse(readFileSync13(path, "utf8"));
43203
+ const raw = JSON.parse(readFileSync14(path, "utf8"));
43128
43204
  if (typeof raw.usage_limit_last_seen_at === "string") {
43129
43205
  const t = Date.parse(raw.usage_limit_last_seen_at);
43130
43206
  if (Number.isFinite(t) && t <= now) lastSeenMs = t;
@@ -43143,7 +43219,7 @@ function readBlockedPromptForBusyAck(agentDir, now = Date.now()) {
43143
43219
  if (!agentDir) return null;
43144
43220
  let raw;
43145
43221
  try {
43146
- raw = JSON.parse(readFileSync13(join15(agentDir, BLOCKED_PROMPT_SIGNAL_FILENAME), "utf8"));
43222
+ raw = JSON.parse(readFileSync14(join17(agentDir, BLOCKED_PROMPT_SIGNAL_FILENAME), "utf8"));
43147
43223
  } catch {
43148
43224
  return null;
43149
43225
  }
@@ -43206,7 +43282,7 @@ function oldestPendingMarkerAgeMs(dir, now = Date.now(), opts) {
43206
43282
  if (!name.endsWith(".json")) continue;
43207
43283
  let receivedAt;
43208
43284
  try {
43209
- const raw = JSON.parse(readFileSync13(join15(dir, name), "utf-8"));
43285
+ const raw = JSON.parse(readFileSync14(join17(dir, name), "utf-8"));
43210
43286
  if (raw.discretionary === true) continue;
43211
43287
  if (!opts?.includeSeen && typeof raw.seen_at === "string" && raw.seen_at) continue;
43212
43288
  receivedAt = raw.received_at;
@@ -43302,14 +43378,14 @@ function isMarkerGenuinelyAged(receivedAt, nowMs, thresholdMs) {
43302
43378
  }
43303
43379
  var DEFLECTION_COUNTER_SUFFIX = "-deflections.json";
43304
43380
  function deflectionCounterPath(agentDir, channel) {
43305
- return join15(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
43381
+ return join17(agentDir, `${channel}${DEFLECTION_COUNTER_SUFFIX}`);
43306
43382
  }
43307
43383
  function recordChannelDeflection(agentDir, channel, cause) {
43308
43384
  if (!agentDir) return;
43309
43385
  const path = deflectionCounterPath(agentDir, channel);
43310
43386
  let counts = {};
43311
43387
  try {
43312
- const parsed = JSON.parse(readFileSync13(path, "utf-8"));
43388
+ const parsed = JSON.parse(readFileSync14(path, "utf-8"));
43313
43389
  if (parsed && typeof parsed === "object") counts = parsed;
43314
43390
  } catch {
43315
43391
  }
@@ -43408,7 +43484,7 @@ function redactId(id) {
43408
43484
  }
43409
43485
  var BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
43410
43486
  var AGENT_CODE_NAME = process.env.AGT_AGENT_CODE_NAME ?? "unknown";
43411
- var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join16(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
43487
+ var TELEGRAM_AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join18(homedir7(), ".augmented", AGENT_CODE_NAME) : null;
43412
43488
  var AGT_HOST = process.env.AGT_HOST ?? null;
43413
43489
  var AGT_API_KEY = process.env.AGT_API_KEY ?? null;
43414
43490
  var AGT_AGENT_ID = process.env.AGT_AGENT_ID ?? null;
@@ -43525,11 +43601,11 @@ var peerRateLimiter = peerRateApiClient && parsePeerAgentModeEnv(process.env.TEL
43525
43601
  log: (line) => process.stderr.write(`telegram-channel(${AGENT_CODE_NAME}): ${line}
43526
43602
  `)
43527
43603
  }) : createPeerRateLimiter();
43528
- var PEER_PRESENCE_STATE_FILE = TELEGRAM_AGENT_DIR ? join16(TELEGRAM_AGENT_DIR, "telegram-peer-presence.json") : null;
43604
+ var PEER_PRESENCE_STATE_FILE = TELEGRAM_AGENT_DIR ? join18(TELEGRAM_AGENT_DIR, "telegram-peer-presence.json") : null;
43529
43605
  function readPeerPresenceState() {
43530
43606
  if (!PEER_PRESENCE_STATE_FILE) return null;
43531
43607
  try {
43532
- const parsed = JSON.parse(readFileSync14(PEER_PRESENCE_STATE_FILE, "utf-8"));
43608
+ const parsed = JSON.parse(readFileSync15(PEER_PRESENCE_STATE_FILE, "utf-8"));
43533
43609
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
43534
43610
  return parsed;
43535
43611
  } catch {
@@ -43540,7 +43616,7 @@ function writePeerPresenceState(snapshot) {
43540
43616
  if (!PEER_PRESENCE_STATE_FILE || !TELEGRAM_AGENT_DIR) return;
43541
43617
  const tmp = `${PEER_PRESENCE_STATE_FILE}.tmp`;
43542
43618
  try {
43543
- mkdirSync9(TELEGRAM_AGENT_DIR, { recursive: true, mode: 448 });
43619
+ mkdirSync10(TELEGRAM_AGENT_DIR, { recursive: true, mode: 448 });
43544
43620
  writeFileSync11(tmp, JSON.stringify(snapshot), { mode: 384 });
43545
43621
  renameSync7(tmp, PEER_PRESENCE_STATE_FILE);
43546
43622
  } catch (err) {
@@ -43564,9 +43640,9 @@ if (!BOT_TOKEN) {
43564
43640
  var stderrLogStream = null;
43565
43641
  if (AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown") {
43566
43642
  try {
43567
- const logDir = join16(homedir6(), ".augmented", AGENT_CODE_NAME);
43568
- mkdirSync9(logDir, { recursive: true });
43569
- stderrLogStream = createWriteStream(join16(logDir, "telegram-channel-stderr.log"), {
43643
+ const logDir = join18(homedir7(), ".augmented", AGENT_CODE_NAME);
43644
+ mkdirSync10(logDir, { recursive: true });
43645
+ stderrLogStream = createWriteStream(join18(logDir, "telegram-channel-stderr.log"), {
43570
43646
  flags: "a",
43571
43647
  mode: 384
43572
43648
  });
@@ -43904,7 +43980,7 @@ function telegramMarkerReplayFacts(chatId, messageId) {
43904
43980
  const path = pendingInboundPath(chatId, messageId);
43905
43981
  if (!path || !existsSync9(path)) return null;
43906
43982
  try {
43907
- const marker = JSON.parse(readFileSync14(path, "utf-8"));
43983
+ const marker = JSON.parse(readFileSync15(path, "utf-8"));
43908
43984
  const facts = combineMarkerReplayFacts([
43909
43985
  { hasPayload: Boolean(marker.payload), discretionary: marker.discretionary }
43910
43986
  ]);
@@ -44030,7 +44106,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
44030
44106
  let paneLogFreshAgeMs = null;
44031
44107
  if (AGENT_DIR) {
44032
44108
  try {
44033
- const paneMtimeMs = statSync5(join16(AGENT_DIR, "pane.log")).mtimeMs;
44109
+ const paneMtimeMs = statSync5(join18(AGENT_DIR, "pane.log")).mtimeMs;
44034
44110
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
44035
44111
  } catch {
44036
44112
  }
@@ -44063,7 +44139,7 @@ function scheduleBusyAck(chatId, messageId, arrivedWhileBusy) {
44063
44139
  function __resetBusyAckNoticeThrottle() {
44064
44140
  lastBusyAckNoticeAt.clear();
44065
44141
  }
44066
- var RESTART_FLAGS_DIR = join16(homedir6(), ".augmented", "restart-flags");
44142
+ var RESTART_FLAGS_DIR = join18(homedir7(), ".augmented", "restart-flags");
44067
44143
  function actuateHostRestartTelegram() {
44068
44144
  return actuateHostRestart({
44069
44145
  agtHost: AGT_HOST,
@@ -44454,9 +44530,9 @@ async function handleRestartCommand(opts) {
44454
44530
  } else {
44455
44531
  writeTelegramRestartConfirm({ chat_id: opts.chatId, message_id: opts.messageId }, opts.requesterName);
44456
44532
  if (!existsSync9(RESTART_FLAGS_DIR)) {
44457
- mkdirSync9(RESTART_FLAGS_DIR, { recursive: true });
44533
+ mkdirSync10(RESTART_FLAGS_DIR, { recursive: true });
44458
44534
  }
44459
- const flagPath = join16(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
44535
+ const flagPath = join18(RESTART_FLAGS_DIR, `${AGENT_CODE_NAME}.flag`);
44460
44536
  const flag = {
44461
44537
  codeName: AGENT_CODE_NAME,
44462
44538
  source: "telegram",
@@ -44868,16 +44944,16 @@ async function classifyRestartCommand(text) {
44868
44944
  if (!ours) return "verification_failed";
44869
44945
  return target === ours ? "act" : "ignore";
44870
44946
  }
44871
- var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join16(homedir6(), ".augmented", AGENT_CODE_NAME) : null;
44872
- var PENDING_INBOUND_DIR = AGENT_DIR ? join16(AGENT_DIR, "telegram-pending-inbound") : null;
44873
- var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join16(AGENT_DIR, "telegram-recovery-outbox") : null;
44874
- var RECOVERY_LEDGER_DIR = AGENT_DIR ? join16(AGENT_DIR, ".agt-telegram-recovery-ledger") : null;
44875
- var DELIVERY_LEDGER_DIR = AGENT_DIR ? join16(AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
44876
- var RESTART_CONFIRM_FILE = AGENT_DIR ? join16(AGENT_DIR, "telegram-restart-confirm.json") : null;
44947
+ var AGENT_DIR = AGENT_CODE_NAME && AGENT_CODE_NAME !== "unknown" ? join18(homedir7(), ".augmented", AGENT_CODE_NAME) : null;
44948
+ var PENDING_INBOUND_DIR = AGENT_DIR ? join18(AGENT_DIR, "telegram-pending-inbound") : null;
44949
+ var RECOVERY_OUTBOX_DIR = AGENT_DIR ? join18(AGENT_DIR, "telegram-recovery-outbox") : null;
44950
+ var RECOVERY_LEDGER_DIR = AGENT_DIR ? join18(AGENT_DIR, ".agt-telegram-recovery-ledger") : null;
44951
+ var DELIVERY_LEDGER_DIR = AGENT_DIR ? join18(AGENT_DIR, ".agt-inbound-delivery-ledger") : null;
44952
+ var RESTART_CONFIRM_FILE = AGENT_DIR ? join18(AGENT_DIR, "telegram-restart-confirm.json") : null;
44877
44953
  var TELEGRAM_PROCESS_BOOT_MS = Date.now();
44878
- var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ? join16(AGENT_DIR, "telegram-recent-dms.json") : null;
44879
- var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ? join16(AGENT_DIR, "telegram-channel-add-restart.json") : null;
44880
- var TELEGRAM_OFFSET_FILE = AGENT_DIR ? join16(AGENT_DIR, "telegram-getupdates-offset.json") : null;
44954
+ var TELEGRAM_RECENT_DMS_FILE = AGENT_DIR ? join18(AGENT_DIR, "telegram-recent-dms.json") : null;
44955
+ var TELEGRAM_CHANNEL_ADD_RESTART_FILE = AGENT_DIR ? join18(AGENT_DIR, "telegram-channel-add-restart.json") : null;
44956
+ var TELEGRAM_OFFSET_FILE = AGENT_DIR ? join18(AGENT_DIR, "telegram-getupdates-offset.json") : null;
44881
44957
  var recentDms = /* @__PURE__ */ new Map();
44882
44958
  var recentDmPersister = TELEGRAM_RECENT_DMS_FILE ? createRecentDmPersister({
44883
44959
  filePath: TELEGRAM_RECENT_DMS_FILE,
@@ -44932,7 +45008,7 @@ function safeMarkerName(chatId, messageId) {
44932
45008
  }
44933
45009
  function pendingInboundPath(chatId, messageId) {
44934
45010
  if (!PENDING_INBOUND_DIR) return null;
44935
- return join16(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
45011
+ return join18(PENDING_INBOUND_DIR, safeMarkerName(chatId, messageId));
44936
45012
  }
44937
45013
  function writePendingInboundMarker(chatId, messageId, chatType, undeliverable = false, payload) {
44938
45014
  const path = pendingInboundPath(chatId, messageId);
@@ -44951,7 +45027,7 @@ function writePendingInboundMarker(chatId, messageId, chatType, undeliverable =
44951
45027
  ...payload ? { payload } : {}
44952
45028
  };
44953
45029
  try {
44954
- mkdirSync9(PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
45030
+ mkdirSync10(PENDING_INBOUND_DIR, { recursive: true, mode: 448 });
44955
45031
  writeFileSync11(path, JSON.stringify(marker), { mode: 384 });
44956
45032
  } catch (err) {
44957
45033
  process.stderr.write(
@@ -44980,7 +45056,7 @@ function rewriteTelegramMarkerInPlace(path, marker) {
44980
45056
  function clearTelegramMarkerFileWithHeal(fullPath) {
44981
45057
  let marker = null;
44982
45058
  try {
44983
- marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
45059
+ marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
44984
45060
  } catch {
44985
45061
  }
44986
45062
  if (marker?.chat_id) {
@@ -45000,7 +45076,7 @@ function clearTelegramMarkerFileWithHeal(fullPath) {
45000
45076
  function clearTelegramMarkerFileSilently(fullPath) {
45001
45077
  let marker = null;
45002
45078
  try {
45003
- marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
45079
+ marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
45004
45080
  } catch {
45005
45081
  }
45006
45082
  if (marker?.chat_id) {
@@ -45020,7 +45096,7 @@ function markTelegramMarkerPromisedInPlace(fullPath) {
45020
45096
  function markTelegramMarkerEngagedInPlace(fullPath, opts) {
45021
45097
  let marker;
45022
45098
  try {
45023
- marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
45099
+ marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
45024
45100
  } catch {
45025
45101
  return false;
45026
45102
  }
@@ -45036,7 +45112,7 @@ function markTelegramMarkerEngagedInPlace(fullPath, opts) {
45036
45112
  rewriteTelegramMarkerInPlace(fullPath, marker);
45037
45113
  if (!opts.promise) return false;
45038
45114
  try {
45039
- const readBack = JSON.parse(readFileSync14(fullPath, "utf-8"));
45115
+ const readBack = JSON.parse(readFileSync15(fullPath, "utf-8"));
45040
45116
  return typeof readBack.promised_at === "string" && readBack.promised_at.length > 0;
45041
45117
  } catch {
45042
45118
  return false;
@@ -45045,7 +45121,7 @@ function markTelegramMarkerEngagedInPlace(fullPath, opts) {
45045
45121
  function markTelegramMarkerSeenWithHeal(fullPath) {
45046
45122
  let marker = null;
45047
45123
  try {
45048
- marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
45124
+ marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
45049
45125
  } catch {
45050
45126
  return;
45051
45127
  }
@@ -45061,7 +45137,7 @@ function markTelegramMarkerSeenWithHeal(fullPath) {
45061
45137
  function markTelegramMarkerPromisedWithHeal(fullPath) {
45062
45138
  let marker = null;
45063
45139
  try {
45064
- marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
45140
+ marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
45065
45141
  } catch {
45066
45142
  return;
45067
45143
  }
@@ -45079,7 +45155,7 @@ function readPendingInboundMarker(chatId, messageId) {
45079
45155
  const path = pendingInboundPath(chatId, messageId);
45080
45156
  if (!path || !existsSync9(path)) return null;
45081
45157
  try {
45082
- return JSON.parse(readFileSync14(path, "utf-8"));
45158
+ return JSON.parse(readFileSync15(path, "utf-8"));
45083
45159
  } catch {
45084
45160
  return null;
45085
45161
  }
@@ -45099,10 +45175,10 @@ function nextRetryName(filename) {
45099
45175
  async function processRecoveryOutboxFile(filename) {
45100
45176
  if (!RECOVERY_OUTBOX_DIR) return;
45101
45177
  if (filename.endsWith(".poison.json") || filename.endsWith(".tmp")) return;
45102
- const fullPath = join16(RECOVERY_OUTBOX_DIR, filename);
45178
+ const fullPath = join18(RECOVERY_OUTBOX_DIR, filename);
45103
45179
  let payload;
45104
45180
  try {
45105
- const raw = readFileSync14(fullPath, "utf-8");
45181
+ const raw = readFileSync15(fullPath, "utf-8");
45106
45182
  payload = JSON.parse(raw);
45107
45183
  } catch (err) {
45108
45184
  process.stderr.write(
@@ -45196,7 +45272,7 @@ async function processRecoveryOutboxFile(filename) {
45196
45272
  const next = nextRetryName(filename);
45197
45273
  if (next) {
45198
45274
  try {
45199
- renameSync7(fullPath, join16(RECOVERY_OUTBOX_DIR, next.next));
45275
+ renameSync7(fullPath, join18(RECOVERY_OUTBOX_DIR, next.next));
45200
45276
  if (next.attempt >= MAX_RECOVERY_ATTEMPTS) {
45201
45277
  process.stderr.write(
45202
45278
  `telegram-channel(${AGENT_CODE_NAME}): ghost-reply recovery exhausted retries \u2014 moved to ${next.next}
@@ -45237,7 +45313,7 @@ function scanRecoveryRetries() {
45237
45313
  if (!f.includes(".retry-") || f.endsWith(".poison.json")) continue;
45238
45314
  let mtimeMs;
45239
45315
  try {
45240
- mtimeMs = statSync5(join16(RECOVERY_OUTBOX_DIR, f)).mtimeMs;
45316
+ mtimeMs = statSync5(join18(RECOVERY_OUTBOX_DIR, f)).mtimeMs;
45241
45317
  } catch {
45242
45318
  continue;
45243
45319
  }
@@ -45249,7 +45325,7 @@ function scanRecoveryRetries() {
45249
45325
  function startRecoveryOutboxWatcher() {
45250
45326
  if (!RECOVERY_OUTBOX_DIR) return;
45251
45327
  try {
45252
- mkdirSync9(RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
45328
+ mkdirSync10(RECOVERY_OUTBOX_DIR, { recursive: true, mode: 448 });
45253
45329
  } catch (err) {
45254
45330
  process.stderr.write(
45255
45331
  `telegram-channel(${AGENT_CODE_NAME}): recovery outbox mkdir failed: ${err.message}
@@ -45267,7 +45343,7 @@ function startRecoveryOutboxWatcher() {
45267
45343
  const watcher = watch(RECOVERY_OUTBOX_DIR, (event, filename) => {
45268
45344
  if (event !== "rename" || !filename) return;
45269
45345
  if (!isFirstAttemptOutboxFile(filename)) return;
45270
- if (existsSync9(join16(RECOVERY_OUTBOX_DIR, filename))) {
45346
+ if (existsSync9(join18(RECOVERY_OUTBOX_DIR, filename))) {
45271
45347
  void processRecoveryOutboxFile(filename);
45272
45348
  }
45273
45349
  });
@@ -45282,7 +45358,7 @@ function startRecoveryOutboxWatcher() {
45282
45358
  retryTimer.unref?.();
45283
45359
  }
45284
45360
  startRecoveryOutboxWatcher();
45285
- var NOTICE_OUTBOX_DIR = AGENT_DIR ? join16(AGENT_DIR, "telegram-notice-outbox") : null;
45361
+ var NOTICE_OUTBOX_DIR = AGENT_DIR ? join18(AGENT_DIR, "telegram-notice-outbox") : null;
45286
45362
  var NOTICE_MAX_AGE_MS = 9e4;
45287
45363
  var NOTICE_INFLIGHT = /* @__PURE__ */ new Set();
45288
45364
  async function processNoticeOutboxFile(filename) {
@@ -45290,7 +45366,7 @@ async function processNoticeOutboxFile(filename) {
45290
45366
  if (filename.startsWith(".") || filename.endsWith(".tmp") || !filename.endsWith(".json")) return;
45291
45367
  if (NOTICE_INFLIGHT.has(filename)) return;
45292
45368
  NOTICE_INFLIGHT.add(filename);
45293
- const fullPath = join16(NOTICE_OUTBOX_DIR, filename);
45369
+ const fullPath = join18(NOTICE_OUTBOX_DIR, filename);
45294
45370
  try {
45295
45371
  let mtimeMs;
45296
45372
  try {
@@ -45307,7 +45383,7 @@ async function processNoticeOutboxFile(filename) {
45307
45383
  }
45308
45384
  let payload;
45309
45385
  try {
45310
- const parsed = JSON.parse(readFileSync14(fullPath, "utf-8"));
45386
+ const parsed = JSON.parse(readFileSync15(fullPath, "utf-8"));
45311
45387
  if (!parsed || typeof parsed !== "object") throw new Error("not an object");
45312
45388
  payload = parsed;
45313
45389
  } catch {
@@ -45369,7 +45445,7 @@ async function processNoticeOutboxFile(filename) {
45369
45445
  function startNoticeOutboxWatcher() {
45370
45446
  if (!NOTICE_OUTBOX_DIR) return;
45371
45447
  try {
45372
- mkdirSync9(NOTICE_OUTBOX_DIR, { recursive: true, mode: 448 });
45448
+ mkdirSync10(NOTICE_OUTBOX_DIR, { recursive: true, mode: 448 });
45373
45449
  } catch (err) {
45374
45450
  process.stderr.write(
45375
45451
  `telegram-channel(${AGENT_CODE_NAME}): notice outbox mkdir failed: ${err.message}
@@ -45384,7 +45460,7 @@ function startNoticeOutboxWatcher() {
45384
45460
  try {
45385
45461
  const watcher = watch(NOTICE_OUTBOX_DIR, (event, filename) => {
45386
45462
  if (event !== "rename" || !filename) return;
45387
- if (existsSync9(join16(NOTICE_OUTBOX_DIR, filename))) void processNoticeOutboxFile(filename);
45463
+ if (existsSync9(join18(NOTICE_OUTBOX_DIR, filename))) void processNoticeOutboxFile(filename);
45388
45464
  });
45389
45465
  watcher.unref?.();
45390
45466
  } catch (err) {
@@ -45418,10 +45494,10 @@ function sweepTelegramStaleMarkers(thresholdMs) {
45418
45494
  for (const filename of filenames) {
45419
45495
  if (!filename.endsWith(".json")) continue;
45420
45496
  if (filename.endsWith(".tmp")) continue;
45421
- const fullPath = join16(PENDING_INBOUND_DIR, filename);
45497
+ const fullPath = join18(PENDING_INBOUND_DIR, filename);
45422
45498
  let marker;
45423
45499
  try {
45424
- marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
45500
+ marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
45425
45501
  } catch (err) {
45426
45502
  process.stderr.write(
45427
45503
  `telegram-channel(${AGENT_CODE_NAME}): stale-marker parse failed for ${redactId(filename)}: ${err.message}
@@ -45474,13 +45550,13 @@ var orphanSweepTimer = setInterval(() => {
45474
45550
  checkWatchdogGiveUpNotice();
45475
45551
  }, orphanSweepIntervalMs());
45476
45552
  orphanSweepTimer.unref?.();
45477
- var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ? join16(AGENT_DIR, "channel-progress-heartbeat.json") : null;
45553
+ var TELEGRAM_PROGRESS_HEARTBEAT_PATH = AGENT_DIR ? join18(AGENT_DIR, "channel-progress-heartbeat.json") : null;
45478
45554
  var telegramTrackedProgress = null;
45479
45555
  var telegramProgressTickRunning = false;
45480
45556
  function readTelegramProgressHeartbeat() {
45481
45557
  if (!TELEGRAM_PROGRESS_HEARTBEAT_PATH || !existsSync9(TELEGRAM_PROGRESS_HEARTBEAT_PATH)) return null;
45482
45558
  try {
45483
- return parseProgressHeartbeat(readFileSync14(TELEGRAM_PROGRESS_HEARTBEAT_PATH, "utf-8"));
45559
+ return parseProgressHeartbeat(readFileSync15(TELEGRAM_PROGRESS_HEARTBEAT_PATH, "utf-8"));
45484
45560
  } catch {
45485
45561
  return null;
45486
45562
  }
@@ -45507,7 +45583,7 @@ function findTelegramProgressTarget() {
45507
45583
  if (!name.endsWith(".json")) continue;
45508
45584
  let m;
45509
45585
  try {
45510
- m = JSON.parse(readFileSync14(join16(PENDING_INBOUND_DIR, name), "utf-8"));
45586
+ m = JSON.parse(readFileSync15(join18(PENDING_INBOUND_DIR, name), "utf-8"));
45511
45587
  } catch {
45512
45588
  continue;
45513
45589
  }
@@ -45638,7 +45714,7 @@ function listPendingInboundChatIds() {
45638
45714
  if (!name.endsWith(".json")) continue;
45639
45715
  try {
45640
45716
  const marker = JSON.parse(
45641
- readFileSync14(join16(PENDING_INBOUND_DIR, name), "utf8")
45717
+ readFileSync15(join18(PENDING_INBOUND_DIR, name), "utf8")
45642
45718
  );
45643
45719
  if (typeof marker.seen_at === "string" && marker.seen_at) continue;
45644
45720
  if (typeof marker.chat_id === "string" && marker.chat_id) chats.add(marker.chat_id);
@@ -45757,7 +45833,7 @@ async function notifyWatchdogGiveUp(chatId, reason, resetsHint = null) {
45757
45833
  }
45758
45834
  function checkWatchdogGiveUpNotice() {
45759
45835
  if (!AGENT_DIR) return;
45760
- const signal = readGiveUpSignal(join16(AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
45836
+ const signal = readGiveUpSignal(join18(AGENT_DIR, GIVE_UP_SIGNAL_FILENAME));
45761
45837
  const signalAtMs = signal?.atMs ?? null;
45762
45838
  const act = decideGiveUpNotice({
45763
45839
  signalAtMs,
@@ -46097,7 +46173,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
46097
46173
  isError: true
46098
46174
  };
46099
46175
  }
46100
- const allowedRoot = resolve2(homedir6(), ".augmented", AGENT_CODE_NAME, "project") + "/";
46176
+ const allowedRoot = resolve2(homedir7(), ".augmented", AGENT_CODE_NAME, "project") + "/";
46101
46177
  const resolvedPath = resolve2(path);
46102
46178
  if (!resolvedPath.startsWith(allowedRoot)) {
46103
46179
  return {
@@ -46145,7 +46221,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
46145
46221
  }
46146
46222
  let realRoot = allowedRoot;
46147
46223
  try {
46148
- realRoot = realpathSync(resolve2(homedir6(), ".augmented", AGENT_CODE_NAME, "project")) + "/";
46224
+ realRoot = realpathSync(resolve2(homedir7(), ".augmented", AGENT_CODE_NAME, "project")) + "/";
46149
46225
  } catch {
46150
46226
  }
46151
46227
  if (!realPath.startsWith(realRoot)) {
@@ -46174,7 +46250,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async (req) => {
46174
46250
  isError: true
46175
46251
  };
46176
46252
  }
46177
- bytes = readFileSync14(realPath);
46253
+ bytes = readFileSync15(realPath);
46178
46254
  } catch (err) {
46179
46255
  return { content: [{ type: "text", text: `Failed to read file: ${err.message}` }], isError: true };
46180
46256
  }
@@ -46838,7 +46914,7 @@ async function replayPendingTelegramMarkers() {
46838
46914
  let paneFreshAgeMs = null;
46839
46915
  if (AGENT_DIR) {
46840
46916
  try {
46841
- paneFreshAgeMs = Math.max(0, now - statSync5(join16(AGENT_DIR, "pane.log")).mtimeMs);
46917
+ paneFreshAgeMs = Math.max(0, now - statSync5(join18(AGENT_DIR, "pane.log")).mtimeMs);
46842
46918
  } catch {
46843
46919
  }
46844
46920
  }
@@ -46846,10 +46922,10 @@ async function replayPendingTelegramMarkers() {
46846
46922
  const entries = [];
46847
46923
  for (const name of filenames) {
46848
46924
  if (!name.endsWith(".json") || name.endsWith(".tmp")) continue;
46849
- const fullPath = join16(PENDING_INBOUND_DIR, name);
46925
+ const fullPath = join18(PENDING_INBOUND_DIR, name);
46850
46926
  let marker;
46851
46927
  try {
46852
- marker = JSON.parse(readFileSync14(fullPath, "utf-8"));
46928
+ marker = JSON.parse(readFileSync15(fullPath, "utf-8"));
46853
46929
  } catch {
46854
46930
  continue;
46855
46931
  }
@@ -46878,6 +46954,7 @@ async function replayPendingTelegramMarkers() {
46878
46954
  ...replayPayload,
46879
46955
  meta: { ...replayPayload.meta, replayed: "true" }
46880
46956
  };
46957
+ writeUnattributedTurnMarker("telegram");
46881
46958
  try {
46882
46959
  await mcp.notification({
46883
46960
  method: "notifications/claude/channel",
@@ -47487,7 +47564,7 @@ async function pollLoop() {
47487
47564
  let paneLogFreshAgeMs = null;
47488
47565
  if (AGENT_DIR) {
47489
47566
  try {
47490
- const paneMtimeMs = statSync5(join16(AGENT_DIR, "pane.log")).mtimeMs;
47567
+ const paneMtimeMs = statSync5(join18(AGENT_DIR, "pane.log")).mtimeMs;
47491
47568
  paneLogFreshAgeMs = Math.max(0, Date.now() - paneMtimeMs);
47492
47569
  } catch {
47493
47570
  }
@@ -47626,8 +47703,12 @@ async function pollLoop() {
47626
47703
  channel: "telegram",
47627
47704
  sender_id: String(userId),
47628
47705
  sender_name: userName,
47629
- channel_ref: String(chatId)
47706
+ channel_ref: String(chatId),
47707
+ // ENG-11348: only a 'private' chat is one-to-one.
47708
+ chat_kind: isTelegramPrivateChat(msg.chat?.type) ? "direct" : "group"
47630
47709
  });
47710
+ } else {
47711
+ writeUnattributedTurnMarker("telegram");
47631
47712
  }
47632
47713
  if (!isFromBot && !peerAgentMeta) {
47633
47714
  inboundContextClient?.recordInbound({