@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.
package/dist/mcp/index.js CHANGED
@@ -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: sep2, value } = collItem;
11594
+ const { start, key, sep: sep3, value } = collItem;
11595
11595
  const keyProps = resolveProps.resolveProps(start, {
11596
11596
  indicator: "explicit-key-ind",
11597
- next: key ?? sep2?.[0],
11597
+ next: key ?? sep3?.[0],
11598
11598
  offset,
11599
11599
  onError,
11600
11600
  parentIndent: bm.indent,
@@ -11608,7 +11608,7 @@ var require_resolve_block_map = __commonJS({
11608
11608
  else if ("indent" in key && key.indent !== bm.indent)
11609
11609
  onError(offset, "BAD_INDENT", startColMsg);
11610
11610
  }
11611
- if (!keyProps.anchor && !keyProps.tag && !sep2) {
11611
+ if (!keyProps.anchor && !keyProps.tag && !sep3) {
11612
11612
  commentEnd = keyProps.end;
11613
11613
  if (keyProps.comment) {
11614
11614
  if (map.comment)
@@ -11632,7 +11632,7 @@ var require_resolve_block_map = __commonJS({
11632
11632
  ctx.atKey = false;
11633
11633
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
11634
11634
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
11635
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
11635
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
11636
11636
  indicator: "map-value-ind",
11637
11637
  next: value,
11638
11638
  offset: keyNode.range[2],
@@ -11648,7 +11648,7 @@ var require_resolve_block_map = __commonJS({
11648
11648
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
11649
11649
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
11650
11650
  }
11651
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
11651
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep3, null, valueProps, onError);
11652
11652
  if (ctx.schema.compat)
11653
11653
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
11654
11654
  offset = valueNode.range[2];
@@ -11739,7 +11739,7 @@ var require_resolve_end = __commonJS({
11739
11739
  let comment = "";
11740
11740
  if (end) {
11741
11741
  let hasSpace = false;
11742
- let sep2 = "";
11742
+ let sep3 = "";
11743
11743
  for (const token of end) {
11744
11744
  const { source, type } = token;
11745
11745
  switch (type) {
@@ -11753,13 +11753,13 @@ var require_resolve_end = __commonJS({
11753
11753
  if (!comment)
11754
11754
  comment = cb;
11755
11755
  else
11756
- comment += sep2 + cb;
11757
- sep2 = "";
11756
+ comment += sep3 + cb;
11757
+ sep3 = "";
11758
11758
  break;
11759
11759
  }
11760
11760
  case "newline":
11761
11761
  if (comment)
11762
- sep2 += source;
11762
+ sep3 += source;
11763
11763
  hasSpace = true;
11764
11764
  break;
11765
11765
  default:
@@ -11802,18 +11802,18 @@ var require_resolve_flow_collection = __commonJS({
11802
11802
  let offset = fc.offset + fc.start.source.length;
11803
11803
  for (let i = 0; i < fc.items.length; ++i) {
11804
11804
  const collItem = fc.items[i];
11805
- const { start, key, sep: sep2, value } = collItem;
11805
+ const { start, key, sep: sep3, value } = collItem;
11806
11806
  const props = resolveProps.resolveProps(start, {
11807
11807
  flow: fcName,
11808
11808
  indicator: "explicit-key-ind",
11809
- next: key ?? sep2?.[0],
11809
+ next: key ?? sep3?.[0],
11810
11810
  offset,
11811
11811
  onError,
11812
11812
  parentIndent: fc.indent,
11813
11813
  startOnNewline: false
11814
11814
  });
11815
11815
  if (!props.found) {
11816
- if (!props.anchor && !props.tag && !sep2 && !value) {
11816
+ if (!props.anchor && !props.tag && !sep3 && !value) {
11817
11817
  if (i === 0 && props.comma)
11818
11818
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
11819
11819
  else if (i < fc.items.length - 1)
@@ -11867,8 +11867,8 @@ var require_resolve_flow_collection = __commonJS({
11867
11867
  }
11868
11868
  }
11869
11869
  }
11870
- if (!isMap && !sep2 && !props.found) {
11871
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
11870
+ if (!isMap && !sep3 && !props.found) {
11871
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep3, null, props, onError);
11872
11872
  coll.items.push(valueNode);
11873
11873
  offset = valueNode.range[2];
11874
11874
  if (isBlock(value))
@@ -11880,7 +11880,7 @@ var require_resolve_flow_collection = __commonJS({
11880
11880
  if (isBlock(key))
11881
11881
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
11882
11882
  ctx.atKey = false;
11883
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
11883
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
11884
11884
  flow: fcName,
11885
11885
  indicator: "map-value-ind",
11886
11886
  next: value,
@@ -11891,8 +11891,8 @@ var require_resolve_flow_collection = __commonJS({
11891
11891
  });
11892
11892
  if (valueProps.found) {
11893
11893
  if (!isMap && !props.found && ctx.options.strict) {
11894
- if (sep2)
11895
- for (const st of sep2) {
11894
+ if (sep3)
11895
+ for (const st of sep3) {
11896
11896
  if (st === valueProps.found)
11897
11897
  break;
11898
11898
  if (st.type === "newline") {
@@ -11909,7 +11909,7 @@ var require_resolve_flow_collection = __commonJS({
11909
11909
  else
11910
11910
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
11911
11911
  }
11912
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
11912
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep3, null, valueProps, onError) : null;
11913
11913
  if (valueNode) {
11914
11914
  if (isBlock(value))
11915
11915
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -12089,7 +12089,7 @@ var require_resolve_block_scalar = __commonJS({
12089
12089
  chompStart = i + 1;
12090
12090
  }
12091
12091
  let value = "";
12092
- let sep2 = "";
12092
+ let sep3 = "";
12093
12093
  let prevMoreIndented = false;
12094
12094
  for (let i = 0; i < contentStart; ++i)
12095
12095
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -12106,24 +12106,24 @@ var require_resolve_block_scalar = __commonJS({
12106
12106
  indent = "";
12107
12107
  }
12108
12108
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
12109
- value += sep2 + indent.slice(trimIndent) + content;
12110
- sep2 = "\n";
12109
+ value += sep3 + indent.slice(trimIndent) + content;
12110
+ sep3 = "\n";
12111
12111
  } else if (indent.length > trimIndent || content[0] === " ") {
12112
- if (sep2 === " ")
12113
- sep2 = "\n";
12114
- else if (!prevMoreIndented && sep2 === "\n")
12115
- sep2 = "\n\n";
12116
- value += sep2 + indent.slice(trimIndent) + content;
12117
- sep2 = "\n";
12112
+ if (sep3 === " ")
12113
+ sep3 = "\n";
12114
+ else if (!prevMoreIndented && sep3 === "\n")
12115
+ sep3 = "\n\n";
12116
+ value += sep3 + indent.slice(trimIndent) + content;
12117
+ sep3 = "\n";
12118
12118
  prevMoreIndented = true;
12119
12119
  } else if (content === "") {
12120
- if (sep2 === "\n")
12120
+ if (sep3 === "\n")
12121
12121
  value += "\n";
12122
12122
  else
12123
- sep2 = "\n";
12123
+ sep3 = "\n";
12124
12124
  } else {
12125
- value += sep2 + content;
12126
- sep2 = " ";
12125
+ value += sep3 + content;
12126
+ sep3 = " ";
12127
12127
  prevMoreIndented = false;
12128
12128
  }
12129
12129
  }
@@ -12305,25 +12305,25 @@ var require_resolve_flow_scalar = __commonJS({
12305
12305
  if (!match)
12306
12306
  return source;
12307
12307
  let res = match[1];
12308
- let sep2 = " ";
12308
+ let sep3 = " ";
12309
12309
  let pos = first.lastIndex;
12310
12310
  line.lastIndex = pos;
12311
12311
  while (match = line.exec(source)) {
12312
12312
  if (match[1] === "") {
12313
- if (sep2 === "\n")
12314
- res += sep2;
12313
+ if (sep3 === "\n")
12314
+ res += sep3;
12315
12315
  else
12316
- sep2 = "\n";
12316
+ sep3 = "\n";
12317
12317
  } else {
12318
- res += sep2 + match[1];
12319
- sep2 = " ";
12318
+ res += sep3 + match[1];
12319
+ sep3 = " ";
12320
12320
  }
12321
12321
  pos = line.lastIndex;
12322
12322
  }
12323
12323
  const last = /[ \t]*(.*)/sy;
12324
12324
  last.lastIndex = pos;
12325
12325
  match = last.exec(source);
12326
- return res + sep2 + (match?.[1] ?? "");
12326
+ return res + sep3 + (match?.[1] ?? "");
12327
12327
  }
12328
12328
  function doubleQuotedValue(source, onError) {
12329
12329
  let res = "";
@@ -13131,14 +13131,14 @@ var require_cst_stringify = __commonJS({
13131
13131
  }
13132
13132
  }
13133
13133
  }
13134
- function stringifyItem({ start, key, sep: sep2, value }) {
13134
+ function stringifyItem({ start, key, sep: sep3, value }) {
13135
13135
  let res = "";
13136
13136
  for (const st of start)
13137
13137
  res += st.source;
13138
13138
  if (key)
13139
13139
  res += stringifyToken(key);
13140
- if (sep2)
13141
- for (const st of sep2)
13140
+ if (sep3)
13141
+ for (const st of sep3)
13142
13142
  res += st.source;
13143
13143
  if (value)
13144
13144
  res += stringifyToken(value);
@@ -14288,18 +14288,18 @@ var require_parser = __commonJS({
14288
14288
  if (this.type === "map-value-ind") {
14289
14289
  const prev = getPrevProps(this.peek(2));
14290
14290
  const start = getFirstKeyStartProps(prev);
14291
- let sep2;
14291
+ let sep3;
14292
14292
  if (scalar.end) {
14293
- sep2 = scalar.end;
14294
- sep2.push(this.sourceToken);
14293
+ sep3 = scalar.end;
14294
+ sep3.push(this.sourceToken);
14295
14295
  delete scalar.end;
14296
14296
  } else
14297
- sep2 = [this.sourceToken];
14297
+ sep3 = [this.sourceToken];
14298
14298
  const map = {
14299
14299
  type: "block-map",
14300
14300
  offset: scalar.offset,
14301
14301
  indent: scalar.indent,
14302
- items: [{ start, key: scalar, sep: sep2 }]
14302
+ items: [{ start, key: scalar, sep: sep3 }]
14303
14303
  };
14304
14304
  this.onKeyLine = true;
14305
14305
  this.stack[this.stack.length - 1] = map;
@@ -14452,15 +14452,15 @@ var require_parser = __commonJS({
14452
14452
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
14453
14453
  const start2 = getFirstKeyStartProps(it.start);
14454
14454
  const key = it.key;
14455
- const sep2 = it.sep;
14456
- sep2.push(this.sourceToken);
14455
+ const sep3 = it.sep;
14456
+ sep3.push(this.sourceToken);
14457
14457
  delete it.key;
14458
14458
  delete it.sep;
14459
14459
  this.stack.push({
14460
14460
  type: "block-map",
14461
14461
  offset: this.offset,
14462
14462
  indent: this.indent,
14463
- items: [{ start: start2, key, sep: sep2 }]
14463
+ items: [{ start: start2, key, sep: sep3 }]
14464
14464
  });
14465
14465
  } else if (start.length > 0) {
14466
14466
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -14654,13 +14654,13 @@ var require_parser = __commonJS({
14654
14654
  const prev = getPrevProps(parent);
14655
14655
  const start = getFirstKeyStartProps(prev);
14656
14656
  fixFlowSeqItems(fc);
14657
- const sep2 = fc.end.splice(1, fc.end.length);
14658
- sep2.push(this.sourceToken);
14657
+ const sep3 = fc.end.splice(1, fc.end.length);
14658
+ sep3.push(this.sourceToken);
14659
14659
  const map = {
14660
14660
  type: "block-map",
14661
14661
  offset: fc.offset,
14662
14662
  indent: fc.indent,
14663
- items: [{ start, key: fc, sep: sep2 }]
14663
+ items: [{ start, key: fc, sep: sep3 }]
14664
14664
  };
14665
14665
  this.onKeyLine = true;
14666
14666
  this.stack[this.stack.length - 1] = map;
@@ -18867,7 +18867,7 @@ var require_filters = __commonJS({
18867
18867
  return r.copySafeness(str, res);
18868
18868
  }
18869
18869
  _exports.indent = indent;
18870
- function join5(arr, del, attr) {
18870
+ function join7(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 = join5;
18879
+ _exports.join = join7;
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 dirname2 = sysPath.dirname(file);
20045
+ const dirname3 = sysPath.dirname(file);
20046
20046
  const basename2 = sysPath.basename(file);
20047
- const parent = this.fsw._getWatchedDir(dirname2);
20047
+ const parent = this.fsw._getWatchedDir(dirname3);
20048
20048
  let prevStats = stats;
20049
20049
  if (parent.has(basename2))
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(dirname2, basename2);
20074
+ this.fsw._remove(dirname3, basename2);
20075
20075
  }
20076
20076
  } else if (parent.has(basename2)) {
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(sep2) {
21311
- sep2 = sep2 || ",";
21310
+ function _joiner(sep3) {
21311
+ sep3 = sep3 || ",";
21312
21312
  var first = true;
21313
21313
  return function() {
21314
- var val = first ? "" : sep2;
21314
+ var val = first ? "" : sep3;
21315
21315
  first = false;
21316
21316
  return val;
21317
21317
  };
@@ -21341,8 +21341,8 @@ var require_globals = __commonJS({
21341
21341
  cycler: function cycler() {
21342
21342
  return _cycler(Array.prototype.slice.call(arguments));
21343
21343
  },
21344
- joiner: function joiner(sep2) {
21345
- return _joiner(sep2);
21344
+ joiner: function joiner(sep3) {
21345
+ return _joiner(sep3);
21346
21346
  }
21347
21347
  };
21348
21348
  }
@@ -22368,7 +22368,7 @@ var require_nunjucks = __commonJS({
22368
22368
  });
22369
22369
 
22370
22370
  // src/index.ts
22371
- import { mkdtemp, writeFile } from "fs/promises";
22371
+ import { writeFile } from "fs/promises";
22372
22372
  import {
22373
22373
  closeSync,
22374
22374
  constants as fsConstants,
@@ -29692,8 +29692,8 @@ function kanbanGetErrorMessage(status, id, fallbackMessage) {
29692
29692
  }
29693
29693
 
29694
29694
  // src/index.ts
29695
- import { homedir as homedir3, tmpdir } from "os";
29696
- import { basename, isAbsolute, join as join4, resolve as pathResolve, sep } from "path";
29695
+ import { homedir as homedir3 } from "os";
29696
+ import { basename, isAbsolute as isAbsolute2, join as join6, resolve as pathResolve, sep as sep2 } from "path";
29697
29697
 
29698
29698
  // src/host-file-path.ts
29699
29699
  var SKILL_BODY_PATH_MAX_BYTES = 512 * 1024;
@@ -29784,9 +29784,9 @@ function openContained(target, roots, opts) {
29784
29784
  }
29785
29785
  }
29786
29786
  }
29787
- function isContained(candidate, root, sep2) {
29787
+ function isContained(candidate, root, sep3) {
29788
29788
  if (candidate === root) return true;
29789
- const rootWithSep = root.endsWith(sep2) ? root : root + sep2;
29789
+ const rootWithSep = root.endsWith(sep3) ? root : root + sep3;
29790
29790
  return candidate.startsWith(rootWithSep);
29791
29791
  }
29792
29792
  function resolveHostFilePath(toolName, args, opts) {
@@ -29865,6 +29865,72 @@ function resolveHostFilePath(toolName, args, opts) {
29865
29865
  }
29866
29866
  }
29867
29867
 
29868
+ // src/artefact-work-dir.ts
29869
+ import { mkdir, mkdtemp } from "fs/promises";
29870
+ import { existsSync } from "fs";
29871
+ import { dirname, join as join2 } from "path";
29872
+
29873
+ // ../core/dist/provisioning/frameworks/claudecode/agent-dir-alias.js
29874
+ import { isAbsolute, join, relative, sep } from "path";
29875
+ var VALID_CODE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
29876
+ 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}$/;
29877
+ var INITIATOR_BASENAME = ".current-turn-initiator.json";
29878
+ function isSafeAgentSegment(segment) {
29879
+ return VALID_CODE_NAME.test(segment) || VALID_AGENT_ID.test(segment);
29880
+ }
29881
+ function initiatorDirSegment(initiatorFile, homeDir) {
29882
+ const rel = relative(join(homeDir, ".augmented"), initiatorFile);
29883
+ if (!rel || isAbsolute(rel))
29884
+ return null;
29885
+ const parts = rel.split(sep);
29886
+ if (parts.length !== 2 || parts[1] !== INITIATOR_BASENAME)
29887
+ return null;
29888
+ const segment = parts[0];
29889
+ if (segment === void 0)
29890
+ return null;
29891
+ return isSafeAgentSegment(segment) ? segment : null;
29892
+ }
29893
+ function resolveAgentDirAlias(input) {
29894
+ const { codeName, turnInitiatorFile, agentId, homeDir } = input;
29895
+ const codeNameTrimmed = typeof codeName === "string" ? codeName.trim() : "";
29896
+ if (codeNameTrimmed && VALID_CODE_NAME.test(codeNameTrimmed)) {
29897
+ return join(homeDir, ".augmented", codeNameTrimmed);
29898
+ }
29899
+ const initiator = typeof turnInitiatorFile === "string" ? turnInitiatorFile.trim() : "";
29900
+ if (initiator) {
29901
+ const segment = initiatorDirSegment(initiator, homeDir);
29902
+ if (segment)
29903
+ return join(homeDir, ".augmented", segment);
29904
+ }
29905
+ const agentIdTrimmed = typeof agentId === "string" ? agentId.trim() : "";
29906
+ if (agentIdTrimmed && VALID_AGENT_ID.test(agentIdTrimmed)) {
29907
+ return join(homeDir, ".augmented", agentIdTrimmed);
29908
+ }
29909
+ return null;
29910
+ }
29911
+ function resolveAgentScratchDir(input) {
29912
+ const alias = resolveAgentDirAlias(input);
29913
+ return alias === null ? null : join(alias, "scratch");
29914
+ }
29915
+
29916
+ // src/artefact-work-dir.ts
29917
+ async function makeArtefactWorkDir(prefix, env2) {
29918
+ const scratch = resolveAgentScratchDir(env2);
29919
+ if (scratch === null) {
29920
+ throw new Error(
29921
+ "Cannot save the artefact: none of AGT_AGENT_CODE_NAME, AGT_TURN_INITIATOR_FILE or AGT_AGENT_ID is set, so this server cannot tell which agent directory the file belongs in."
29922
+ );
29923
+ }
29924
+ const agentDir = dirname(scratch);
29925
+ if (!existsSync(agentDir)) {
29926
+ throw new Error(
29927
+ `Cannot save the artefact: the agent directory ${agentDir} does not exist on this host.`
29928
+ );
29929
+ }
29930
+ await mkdir(scratch, { recursive: true });
29931
+ return mkdtemp(join2(scratch, prefix));
29932
+ }
29933
+
29868
29934
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
29869
29935
  var external_exports = {};
29870
29936
  __export(external_exports, {
@@ -44642,12 +44708,12 @@ function selectIntegrationsToRefresh(input) {
44642
44708
  }
44643
44709
 
44644
44710
  // src/self-restart.ts
44645
- import { existsSync, mkdirSync, renameSync, writeFileSync } from "fs";
44711
+ import { existsSync as existsSync2, mkdirSync, renameSync, writeFileSync } from "fs";
44646
44712
  import { homedir } from "os";
44647
- import { join } from "path";
44713
+ import { join as join3 } from "path";
44648
44714
  import { randomUUID } from "crypto";
44649
44715
  function restartFlagsDir() {
44650
- return join(homedir(), ".augmented", "restart-flags");
44716
+ return join3(homedir(), ".augmented", "restart-flags");
44651
44717
  }
44652
44718
  function isSelfRestartEnabled(env2) {
44653
44719
  const raw = (env2.AGT_AGENT_SELF_RESTART_ENABLED ?? "").trim().toLowerCase();
@@ -44658,8 +44724,8 @@ function buildAgentRestartFlag(codeName, reason, nowMs) {
44658
44724
  }
44659
44725
  function writeAgentRestartFlag(codeName, reason, nowMs) {
44660
44726
  const dir = restartFlagsDir();
44661
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
44662
- const path = join(dir, `${codeName}.flag`);
44727
+ if (!existsSync2(dir)) mkdirSync(dir, { recursive: true });
44728
+ const path = join3(dir, `${codeName}.flag`);
44663
44729
  const flag = buildAgentRestartFlag(codeName, reason, nowMs);
44664
44730
  const tmpPath = `${path}.${process.pid}.${randomUUID()}.tmp`;
44665
44731
  writeFileSync(tmpPath, JSON.stringify(flag) + "\n", "utf8");
@@ -44668,18 +44734,18 @@ function writeAgentRestartFlag(codeName, reason, nowMs) {
44668
44734
  }
44669
44735
 
44670
44736
  // src/self-restart-confirm.ts
44671
- import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2 } from "fs";
44737
+ import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync2 } from "fs";
44672
44738
  import { homedir as homedir2 } from "os";
44673
- import { join as join2 } from "path";
44739
+ import { join as join4 } from "path";
44674
44740
 
44675
44741
  // src/restart-confirm.ts
44676
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, renameSync as renameSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
44677
- import { dirname } from "path";
44742
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync, renameSync as renameSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
44743
+ import { dirname as dirname2 } from "path";
44678
44744
  import { randomUUID as randomUUID2 } from "crypto";
44679
44745
  var RESTART_CONFIRM_MAX_AGE_MS = 10 * 60 * 1e3;
44680
44746
  function writeRestartConfirmMarker(filePath, marker) {
44681
- const dir = dirname(filePath);
44682
- if (!existsSync2(dir)) mkdirSync2(dir, { recursive: true, mode: 448 });
44747
+ const dir = dirname2(filePath);
44748
+ if (!existsSync3(dir)) mkdirSync2(dir, { recursive: true, mode: 448 });
44683
44749
  const tmpPath = `${filePath}.${process.pid}.${randomUUID2()}.tmp`;
44684
44750
  writeFileSync2(tmpPath, JSON.stringify(marker) + "\n", { encoding: "utf8", mode: 384 });
44685
44751
  renameSync2(tmpPath, filePath);
@@ -44688,7 +44754,7 @@ function writeRestartConfirmMarker(filePath, marker) {
44688
44754
  // src/self-restart-confirm.ts
44689
44755
  var SELF_RESTART_PENDING_FRESHNESS_MS = 5 * 60 * 1e3;
44690
44756
  function selfRestartAgentDir(codeName) {
44691
- return join2(homedir2(), ".augmented", codeName);
44757
+ return join4(homedir2(), ".augmented", codeName);
44692
44758
  }
44693
44759
  function selectFreshestPending(candidates, nowMs, maxAgeMs) {
44694
44760
  let best = null;
@@ -44701,7 +44767,7 @@ function selectFreshestPending(candidates, nowMs, maxAgeMs) {
44701
44767
  return best;
44702
44768
  }
44703
44769
  function readMarkerDir(dir, toCandidate) {
44704
- if (!existsSync3(dir)) return [];
44770
+ if (!existsSync4(dir)) return [];
44705
44771
  const out = [];
44706
44772
  let entries;
44707
44773
  try {
@@ -44712,7 +44778,7 @@ function readMarkerDir(dir, toCandidate) {
44712
44778
  for (const entry of entries) {
44713
44779
  if (!entry.endsWith(".json") || entry.endsWith(".tmp")) continue;
44714
44780
  try {
44715
- const parsed = JSON.parse(readFileSync2(join2(dir, entry), "utf8"));
44781
+ const parsed = JSON.parse(readFileSync2(join4(dir, entry), "utf8"));
44716
44782
  if (!parsed || typeof parsed !== "object") continue;
44717
44783
  const candidate = toCandidate(parsed);
44718
44784
  if (candidate) out.push(candidate);
@@ -44722,7 +44788,7 @@ function readMarkerDir(dir, toCandidate) {
44722
44788
  return out;
44723
44789
  }
44724
44790
  function readPendingCandidates(agentDir) {
44725
- const slack = readMarkerDir(join2(agentDir, "slack-pending-inbound"), (p2) => {
44791
+ const slack = readMarkerDir(join4(agentDir, "slack-pending-inbound"), (p2) => {
44726
44792
  const channel = p2["channel"];
44727
44793
  if (typeof channel !== "string" || channel.length === 0) return null;
44728
44794
  const threadTs = p2["thread_ts"];
@@ -44730,7 +44796,7 @@ function readPendingCandidates(agentDir) {
44730
44796
  if (typeof threadTs === "string" && threadTs.length > 0) reply["thread_ts"] = threadTs;
44731
44797
  return { source: "slack", receivedAtMs: Date.parse(String(p2["received_at"])), reply };
44732
44798
  });
44733
- const telegram = readMarkerDir(join2(agentDir, "telegram-pending-inbound"), (p2) => {
44799
+ const telegram = readMarkerDir(join4(agentDir, "telegram-pending-inbound"), (p2) => {
44734
44800
  const chatId = p2["chat_id"];
44735
44801
  if (chatId == null || typeof chatId !== "string" && typeof chatId !== "number") return null;
44736
44802
  const reply = { chat_id: chatId };
@@ -44751,17 +44817,17 @@ function captureSelfRestartConfirm(opts) {
44751
44817
  // human, so buildBackOnlineText degrades to the generic copy.
44752
44818
  reply: best.reply
44753
44819
  };
44754
- const file = best.source === "slack" ? join2(opts.agentDir, "slack-restart-confirm.json") : join2(opts.agentDir, "telegram-restart-confirm.json");
44820
+ const file = best.source === "slack" ? join4(opts.agentDir, "slack-restart-confirm.json") : join4(opts.agentDir, "telegram-restart-confirm.json");
44755
44821
  writeRestartConfirmMarker(file, marker);
44756
44822
  return best.source;
44757
44823
  }
44758
44824
 
44759
44825
  // ../core/dist/integrations/forwarded-tools-report.js
44760
44826
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
44761
- import { join as join3 } from "path";
44827
+ import { join as join5 } from "path";
44762
44828
  var FORWARDED_TOOLS_REPORT_FILENAME = "forwarded-tools.json";
44763
44829
  function forwardedToolsReportPath(agentDir) {
44764
- return join3(agentDir, FORWARDED_TOOLS_REPORT_FILENAME);
44830
+ return join5(agentDir, FORWARDED_TOOLS_REPORT_FILENAME);
44765
44831
  }
44766
44832
  function writeForwardedToolsReport(agentDir, report) {
44767
44833
  try {
@@ -48250,9 +48316,9 @@ async function forwardToolCall(toolName, args) {
48250
48316
  // root to its canonical form so both sides of the comparison are real
48251
48317
  // paths. Falls back to the unresolved join if the dir is missing, which
48252
48318
  // then simply refuses (there is nothing to read anyway).
48253
- agentDir: canonicalAgentDir(join4(homedir3(), ".augmented", AGT_AGENT_CODE_NAME)),
48319
+ agentDir: canonicalAgentDir(join6(homedir3(), ".augmented", AGT_AGENT_CODE_NAME)),
48254
48320
  // agent-dir-allow: immediately realpath-resolved to the ADR-0049 agent_id-keyed dir before use as a containment root
48255
- path: { isAbsolute, resolve: pathResolve, join: join4, sep },
48321
+ path: { isAbsolute: isAbsolute2, resolve: pathResolve, join: join6, sep: sep2 },
48256
48322
  // O_NOFOLLOW is the whole point of opening by flags: the path is already
48257
48323
  // symlink-resolved, so a symlink at the final component means it was
48258
48324
  // swapped after the check, and this turns that into an ELOOP.
@@ -48648,7 +48714,12 @@ async function fetchArtefactRevision(artefactId) {
48648
48714
  }
48649
48715
  }
48650
48716
  async function saveArtefactSourceToFile(artefactId) {
48651
- const dir = await mkdtemp(join4(tmpdir(), "augmented-artefact-source-"));
48717
+ const dir = await makeArtefactWorkDir("augmented-artefact-source-", {
48718
+ codeName: AGT_AGENT_CODE_NAME,
48719
+ turnInitiatorFile: process.env.AGT_TURN_INITIATOR_FILE,
48720
+ agentId: AGT_AGENT_ID,
48721
+ homeDir: homedir3()
48722
+ });
48652
48723
  const readOnce = async () => {
48653
48724
  const before = await fetchArtefactRevision(artefactId);
48654
48725
  const assembled = await assembleArtefactSource(
@@ -48662,7 +48733,7 @@ async function saveArtefactSourceToFile(artefactId) {
48662
48733
  };
48663
48734
  let result = await readOnce();
48664
48735
  if (result.revisionState !== "stable") result = await readOnce();
48665
- const filePath = join4(dir, safeDownloadName(`${artefactId}.html`, `${artefactId}.html`));
48736
+ const filePath = join6(dir, safeDownloadName(`${artefactId}.html`, `${artefactId}.html`));
48666
48737
  await writeFile(filePath, result.html, "utf8");
48667
48738
  return {
48668
48739
  path: filePath,
@@ -48741,7 +48812,7 @@ async function exportArtefactToFile(dir, artefactId, format, item) {
48741
48812
  return { kind: "pending", jobId: outcome.jobId, retryAfterMs: outcome.retryAfterMs };
48742
48813
  }
48743
48814
  const fallback = `${artefactId}${item !== void 0 ? `-item-${item + 1}` : ""}.${format}`;
48744
- const filePath = join4(dir, safeDownloadName(outcome.body.filename, fallback));
48815
+ const filePath = join6(dir, safeDownloadName(outcome.body.filename, fallback));
48745
48816
  const buf = Buffer.from(outcome.body.base64, "base64");
48746
48817
  await writeFile(filePath, buf);
48747
48818
  return {
@@ -48764,7 +48835,12 @@ async function resolveItemCountForPng(artefactId) {
48764
48835
  return { count: 1, total: 1 };
48765
48836
  }
48766
48837
  async function downloadArtefactText(params) {
48767
- const dir = await mkdtemp(join4(tmpdir(), "augmented-artefact-"));
48838
+ const dir = await makeArtefactWorkDir("augmented-artefact-", {
48839
+ codeName: AGT_AGENT_CODE_NAME,
48840
+ turnInitiatorFile: process.env.AGT_TURN_INITIATOR_FILE,
48841
+ agentId: AGT_AGENT_ID,
48842
+ homeDir: homedir3()
48843
+ });
48768
48844
  let items;
48769
48845
  let truncatedFrom = null;
48770
48846
  if (params.format === "pdf") {