agent-relay 7.0.0 → 7.1.0

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/index.cjs CHANGED
@@ -801,6 +801,10 @@ var require_receiver = __commonJS({
801
801
  * extensions
802
802
  * @param {Boolean} [options.isServer=false] Specifies whether to operate in
803
803
  * client or server mode
804
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
805
+ * buffered data chunks
806
+ * @param {Number} [options.maxFragments=0] The maximum number of message
807
+ * fragments
804
808
  * @param {Number} [options.maxPayload=0] The maximum allowed message length
805
809
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
806
810
  * not to skip UTF-8 validation for text and close messages
@@ -811,6 +815,8 @@ var require_receiver = __commonJS({
811
815
  this._binaryType = options.binaryType || BINARY_TYPES[0];
812
816
  this._extensions = options.extensions || {};
813
817
  this._isServer = !!options.isServer;
818
+ this._maxBufferedChunks = options.maxBufferedChunks | 0;
819
+ this._maxFragments = options.maxFragments | 0;
814
820
  this._maxPayload = options.maxPayload | 0;
815
821
  this._skipUTF8Validation = !!options.skipUTF8Validation;
816
822
  this[kWebSocket] = void 0;
@@ -840,6 +846,18 @@ var require_receiver = __commonJS({
840
846
  */
841
847
  _write(chunk, encoding, cb) {
842
848
  if (this._opcode === 8 && this._state == GET_INFO) return cb();
849
+ if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
850
+ cb(
851
+ this.createError(
852
+ RangeError,
853
+ "Too many buffered chunks",
854
+ false,
855
+ 1008,
856
+ "WS_ERR_TOO_MANY_BUFFERED_PARTS"
857
+ )
858
+ );
859
+ return;
860
+ }
843
861
  this._bufferedBytes += chunk.length;
844
862
  this._buffers.push(chunk);
845
863
  this.startLoop(cb);
@@ -1169,6 +1187,17 @@ var require_receiver = __commonJS({
1169
1187
  return;
1170
1188
  }
1171
1189
  if (data.length) {
1190
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
1191
+ const error51 = this.createError(
1192
+ RangeError,
1193
+ "Too many message fragments",
1194
+ false,
1195
+ 1008,
1196
+ "WS_ERR_TOO_MANY_BUFFERED_PARTS"
1197
+ );
1198
+ cb(error51);
1199
+ return;
1200
+ }
1172
1201
  this._messageLength = this._totalPayloadLength;
1173
1202
  this._fragments.push(data);
1174
1203
  }
@@ -1198,6 +1227,17 @@ var require_receiver = __commonJS({
1198
1227
  cb(error51);
1199
1228
  return;
1200
1229
  }
1230
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
1231
+ const error51 = this.createError(
1232
+ RangeError,
1233
+ "Too many message fragments",
1234
+ false,
1235
+ 1008,
1236
+ "WS_ERR_TOO_MANY_BUFFERED_PARTS"
1237
+ );
1238
+ cb(error51);
1239
+ return;
1240
+ }
1201
1241
  this._fragments.push(buf);
1202
1242
  }
1203
1243
  this.dataMessage(cb);
@@ -2404,6 +2444,10 @@ var require_websocket = __commonJS({
2404
2444
  * multiple times in the same tick
2405
2445
  * @param {Function} [options.generateMask] The function used to generate the
2406
2446
  * masking key
2447
+ * @param {Number} [options.maxBufferedChunks=0] The maximum number of
2448
+ * buffered data chunks
2449
+ * @param {Number} [options.maxFragments=0] The maximum number of message
2450
+ * fragments
2407
2451
  * @param {Number} [options.maxPayload=0] The maximum allowed message size
2408
2452
  * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
2409
2453
  * not to skip UTF-8 validation for text and close messages
@@ -2415,6 +2459,8 @@ var require_websocket = __commonJS({
2415
2459
  binaryType: this.binaryType,
2416
2460
  extensions: this._extensions,
2417
2461
  isServer: this._isServer,
2462
+ maxBufferedChunks: options.maxBufferedChunks,
2463
+ maxFragments: options.maxFragments,
2418
2464
  maxPayload: options.maxPayload,
2419
2465
  skipUTF8Validation: options.skipUTF8Validation
2420
2466
  });
@@ -2714,6 +2760,8 @@ var require_websocket = __commonJS({
2714
2760
  autoPong: true,
2715
2761
  closeTimeout: CLOSE_TIMEOUT,
2716
2762
  protocolVersion: protocolVersions[1],
2763
+ maxBufferedChunks: 1024 * 1024,
2764
+ maxFragments: 128 * 1024,
2717
2765
  maxPayload: 100 * 1024 * 1024,
2718
2766
  skipUTF8Validation: false,
2719
2767
  perMessageDeflate: true,
@@ -2956,6 +3004,8 @@ var require_websocket = __commonJS({
2956
3004
  websocket.setSocket(socket, head, {
2957
3005
  allowSynchronousEvents: opts.allowSynchronousEvents,
2958
3006
  generateMask: opts.generateMask,
3007
+ maxBufferedChunks: opts.maxBufferedChunks,
3008
+ maxFragments: opts.maxFragments,
2959
3009
  maxPayload: opts.maxPayload,
2960
3010
  skipUTF8Validation: opts.skipUTF8Validation
2961
3011
  });
@@ -3181,7 +3231,7 @@ var require_stream = __commonJS({
3181
3231
  };
3182
3232
  duplex._final = function(callback) {
3183
3233
  if (ws2.readyState === ws2.CONNECTING) {
3184
- ws2.once("open", function open2() {
3234
+ ws2.once("open", function open3() {
3185
3235
  duplex._final(callback);
3186
3236
  });
3187
3237
  return;
@@ -3202,7 +3252,7 @@ var require_stream = __commonJS({
3202
3252
  };
3203
3253
  duplex._write = function(chunk, encoding, callback) {
3204
3254
  if (ws2.readyState === ws2.CONNECTING) {
3205
- ws2.once("open", function open2() {
3255
+ ws2.once("open", function open3() {
3206
3256
  duplex._write(chunk, encoding, callback);
3207
3257
  });
3208
3258
  return;
@@ -3298,6 +3348,10 @@ var require_websocket_server = __commonJS({
3298
3348
  * called
3299
3349
  * @param {Function} [options.handleProtocols] A hook to handle protocols
3300
3350
  * @param {String} [options.host] The hostname where to bind the server
3351
+ * @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
3352
+ * buffered data chunks
3353
+ * @param {Number} [options.maxFragments=131072] The maximum number of message
3354
+ * fragments
3301
3355
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
3302
3356
  * size
3303
3357
  * @param {Boolean} [options.noServer=false] Enable no server mode
@@ -3319,6 +3373,8 @@ var require_websocket_server = __commonJS({
3319
3373
  options = {
3320
3374
  allowSynchronousEvents: true,
3321
3375
  autoPong: true,
3376
+ maxBufferedChunks: 1024 * 1024,
3377
+ maxFragments: 128 * 1024,
3322
3378
  maxPayload: 100 * 1024 * 1024,
3323
3379
  skipUTF8Validation: false,
3324
3380
  perMessageDeflate: false,
@@ -3598,6 +3654,8 @@ var require_websocket_server = __commonJS({
3598
3654
  socket.removeListener("error", socketOnError);
3599
3655
  ws2.setSocket(socket, head, {
3600
3656
  allowSynchronousEvents: this.options.allowSynchronousEvents,
3657
+ maxBufferedChunks: this.options.maxBufferedChunks,
3658
+ maxFragments: this.options.maxFragments,
3601
3659
  maxPayload: this.options.maxPayload,
3602
3660
  skipUTF8Validation: this.options.skipUTF8Validation
3603
3661
  });
@@ -5133,18 +5191,18 @@ var require_source = __commonJS({
5133
5191
  }
5134
5192
  }
5135
5193
  });
5136
- var createStyler = (open2, close, parent) => {
5194
+ var createStyler = (open3, close, parent) => {
5137
5195
  let openAll;
5138
5196
  let closeAll;
5139
5197
  if (parent === void 0) {
5140
- openAll = open2;
5198
+ openAll = open3;
5141
5199
  closeAll = close;
5142
5200
  } else {
5143
- openAll = parent.openAll + open2;
5201
+ openAll = parent.openAll + open3;
5144
5202
  closeAll = close + parent.closeAll;
5145
5203
  }
5146
5204
  return {
5147
- open: open2,
5205
+ open: open3,
5148
5206
  close,
5149
5207
  openAll,
5150
5208
  closeAll,
@@ -13358,7 +13416,7 @@ var require_rfdc = __commonJS({
13358
13416
  });
13359
13417
 
13360
13418
  // node_modules/environment/index.js
13361
- var isBrowser, isNode, isBun, isDeno, isElectron, isJsDom, isWebWorker, isDedicatedWorker, isSharedWorker, isServiceWorker, platform, isMacOs, isWindows, isLinux, isIos, isAndroid;
13419
+ var isBrowser, isNode, isBun, isDeno, isElectron, isJsDom, isWebWorker, isDedicatedWorker, isSharedWorker, isServiceWorker, platform2, isMacOs, isWindows, isLinux, isIos, isAndroid;
13362
13420
  var init_environment = __esm({
13363
13421
  "node_modules/environment/index.js"() {
13364
13422
  isBrowser = globalThis.window?.document !== void 0;
@@ -13371,12 +13429,12 @@ var init_environment = __esm({
13371
13429
  isDedicatedWorker = typeof DedicatedWorkerGlobalScope !== "undefined" && globalThis instanceof DedicatedWorkerGlobalScope;
13372
13430
  isSharedWorker = typeof SharedWorkerGlobalScope !== "undefined" && globalThis instanceof SharedWorkerGlobalScope;
13373
13431
  isServiceWorker = typeof ServiceWorkerGlobalScope !== "undefined" && globalThis instanceof ServiceWorkerGlobalScope;
13374
- platform = globalThis.navigator?.userAgentData?.platform;
13375
- isMacOs = platform === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform === "darwin";
13376
- isWindows = platform === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform === "win32";
13377
- isLinux = platform === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform === "linux";
13378
- isIos = platform === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform);
13379
- isAndroid = platform === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform === "android";
13432
+ platform2 = globalThis.navigator?.userAgentData?.platform;
13433
+ isMacOs = platform2 === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform === "darwin";
13434
+ isWindows = platform2 === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform === "win32";
13435
+ isLinux = platform2 === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform === "linux";
13436
+ isIos = platform2 === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform);
13437
+ isAndroid = platform2 === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform === "android";
13380
13438
  }
13381
13439
  });
13382
13440
 
@@ -13421,11 +13479,11 @@ __export(base_exports, {
13421
13479
  setCwd: () => setCwd,
13422
13480
  synchronizedOutput: () => synchronizedOutput
13423
13481
  });
13424
- var import_node_process, import_node_os13, ESC, OSC, BEL, SEP, isTerminalApp, isWindows2, isTmux, cwdFunction, wrapOsc, cursorTo, cursorMove, cursorUp, cursorDown, cursorForward, cursorBackward, cursorLeft, cursorSavePosition, cursorRestorePosition, cursorGetPosition, cursorNextLine, cursorPrevLine, cursorHide, cursorShow, eraseLines, eraseEndLine, eraseStartLine, eraseLine, eraseDown, eraseUp, eraseScreen, scrollUp, scrollDown, clearScreen, clearViewport, isOldWindows, clearTerminal, enterAlternativeScreen, exitAlternativeScreen, beginSynchronizedOutput, endSynchronizedOutput, synchronizedOutput, beep, link, image, iTerm, ConEmu, setCwd;
13482
+ var import_node_process, import_node_os14, ESC, OSC, BEL, SEP, isTerminalApp, isWindows2, isTmux, cwdFunction, wrapOsc, cursorTo, cursorMove, cursorUp, cursorDown, cursorForward, cursorBackward, cursorLeft, cursorSavePosition, cursorRestorePosition, cursorGetPosition, cursorNextLine, cursorPrevLine, cursorHide, cursorShow, eraseLines, eraseEndLine, eraseStartLine, eraseLine, eraseDown, eraseUp, eraseScreen, scrollUp, scrollDown, clearScreen, clearViewport, isOldWindows, clearTerminal, enterAlternativeScreen, exitAlternativeScreen, beginSynchronizedOutput, endSynchronizedOutput, synchronizedOutput, beep, link, image, iTerm, ConEmu, setCwd;
13425
13483
  var init_base = __esm({
13426
13484
  "node_modules/ansi-escapes/base.js"() {
13427
13485
  import_node_process = __toESM(require("node:process"), 1);
13428
- import_node_os13 = __toESM(require("node:os"), 1);
13486
+ import_node_os14 = __toESM(require("node:os"), 1);
13429
13487
  init_environment();
13430
13488
  ESC = "\x1B[";
13431
13489
  OSC = "\x1B]";
@@ -13505,7 +13563,7 @@ var init_base = __esm({
13505
13563
  if (isBrowser || !isWindows2) {
13506
13564
  return false;
13507
13565
  }
13508
- const parts = import_node_os13.default.release().split(".");
13566
+ const parts = import_node_os14.default.release().split(".");
13509
13567
  const major = Number(parts[0]);
13510
13568
  const build = Number(parts[2] ?? 0);
13511
13569
  if (major < 10) {
@@ -31566,12 +31624,12 @@ var require_form_data = __commonJS({
31566
31624
  if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
31567
31625
  callback(null, value.end + 1 - (value.start ? value.start : 0));
31568
31626
  } else {
31569
- fs15.stat(value.path, function(err, stat2) {
31627
+ fs15.stat(value.path, function(err, stat3) {
31570
31628
  if (err) {
31571
31629
  callback(err);
31572
31630
  return;
31573
31631
  }
31574
- var fileSize = stat2.size - (value.start ? value.start : 0);
31632
+ var fileSize = stat3.size - (value.start ? value.start : 0);
31575
31633
  callback(null, fileSize);
31576
31634
  });
31577
31635
  }
@@ -34615,14 +34673,14 @@ var require_axios = __commonJS({
34615
34673
  navigator: _navigator,
34616
34674
  origin
34617
34675
  });
34618
- var platform2 = {
34676
+ var platform3 = {
34619
34677
  ...utils,
34620
34678
  ...platform$1
34621
34679
  };
34622
34680
  function toURLEncodedForm(data, options) {
34623
- return toFormData(data, new platform2.classes.URLSearchParams(), {
34681
+ return toFormData(data, new platform3.classes.URLSearchParams(), {
34624
34682
  visitor: function(value, key, path29, helpers) {
34625
- if (platform2.isNode && utils$1.isBuffer(value)) {
34683
+ if (platform3.isNode && utils$1.isBuffer(value)) {
34626
34684
  this.append(key, value.toString("base64"));
34627
34685
  return false;
34628
34686
  }
@@ -34773,8 +34831,8 @@ var require_axios = __commonJS({
34773
34831
  maxContentLength: -1,
34774
34832
  maxBodyLength: -1,
34775
34833
  env: {
34776
- FormData: platform2.classes.FormData,
34777
- Blob: platform2.classes.Blob
34834
+ FormData: platform3.classes.FormData,
34835
+ Blob: platform3.classes.Blob
34778
34836
  },
34779
34837
  validateStatus: function validateStatus(status) {
34780
34838
  return status >= 200 && status < 300;
@@ -34915,7 +34973,7 @@ var require_axios = __commonJS({
34915
34973
  }
34916
34974
  var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
34917
34975
  function fromDataURI(uri, asBlob, options) {
34918
- const _Blob = options && options.Blob || platform2.classes.Blob;
34976
+ const _Blob = options && options.Blob || platform3.classes.Blob;
34919
34977
  const protocol = parseProtocol(uri);
34920
34978
  if (asBlob === void 0 && _Blob) {
34921
34979
  asBlob = true;
@@ -35074,7 +35132,7 @@ var require_axios = __commonJS({
35074
35132
  yield blob;
35075
35133
  }
35076
35134
  };
35077
- var BOUNDARY_ALPHABET = platform2.ALPHABET.ALPHA_DIGIT + "-_";
35135
+ var BOUNDARY_ALPHABET = platform3.ALPHABET.ALPHA_DIGIT + "-_";
35078
35136
  var textEncoder = typeof TextEncoder === "function" ? new TextEncoder() : new util2.TextEncoder();
35079
35137
  var CRLF = "\r\n";
35080
35138
  var CRLF_BYTES = textEncoder.encode(CRLF);
@@ -35122,7 +35180,7 @@ var require_axios = __commonJS({
35122
35180
  const {
35123
35181
  tag = "form-data-boundary",
35124
35182
  size = 25,
35125
- boundary = tag + "-" + platform2.generateString(size, BOUNDARY_ALPHABET)
35183
+ boundary = tag + "-" + platform3.generateString(size, BOUNDARY_ALPHABET)
35126
35184
  } = options || {};
35127
35185
  if (!utils$1.isFormData(form)) {
35128
35186
  throw TypeError("FormData instance required");
@@ -35522,7 +35580,7 @@ var require_axios = __commonJS({
35522
35580
  cache.set(key, agent);
35523
35581
  return agent;
35524
35582
  }
35525
- var supportedProtocols = platform2.protocols.map((protocol) => {
35583
+ var supportedProtocols = platform3.protocols.map((protocol) => {
35526
35584
  return protocol + ":";
35527
35585
  });
35528
35586
  var decodeURIComponentSafe = (value) => {
@@ -35883,7 +35941,7 @@ var require_axios = __commonJS({
35883
35941
  }
35884
35942
  });
35885
35943
  const fullPath = buildFullPath(config2.baseURL, config2.url, config2.allowAbsoluteUrls);
35886
- const parsed = new URL(fullPath, platform2.hasBrowserEnv ? platform2.origin : void 0);
35944
+ const parsed = new URL(fullPath, platform3.hasBrowserEnv ? platform3.origin : void 0);
35887
35945
  const protocol = parsed.protocol || supportedProtocols[0];
35888
35946
  if (protocol === "data:") {
35889
35947
  if (config2.maxContentLength > -1) {
@@ -36284,11 +36342,11 @@ var require_axios = __commonJS({
36284
36342
  }
36285
36343
  });
36286
36344
  };
36287
- var isURLSameOrigin = platform2.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url3) => {
36288
- url3 = new URL(url3, platform2.origin);
36345
+ var isURLSameOrigin = platform3.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url3) => {
36346
+ url3 = new URL(url3, platform3.origin);
36289
36347
  return origin2.protocol === url3.protocol && origin2.host === url3.host && (isMSIE || origin2.port === url3.port);
36290
- })(new URL(platform2.origin), platform2.navigator && /(msie|trident)/i.test(platform2.navigator.userAgent)) : () => true;
36291
- var cookies = platform2.hasStandardBrowserEnv ? (
36348
+ })(new URL(platform3.origin), platform3.navigator && /(msie|trident)/i.test(platform3.navigator.userAgent)) : () => true;
36349
+ var cookies = platform3.hasStandardBrowserEnv ? (
36292
36350
  // Standard browser envs support document.cookie
36293
36351
  {
36294
36352
  write(name, value, expires, path29, domain2, secure, sameSite) {
@@ -36468,13 +36526,13 @@ var require_axios = __commonJS({
36468
36526
  headers.set("Authorization", "Basic " + btoa((auth.username || "") + ":" + (auth.password ? encodeUTF8(auth.password) : "")));
36469
36527
  }
36470
36528
  if (utils$1.isFormData(data)) {
36471
- if (platform2.hasStandardBrowserEnv || platform2.hasStandardBrowserWebWorkerEnv) {
36529
+ if (platform3.hasStandardBrowserEnv || platform3.hasStandardBrowserWebWorkerEnv) {
36472
36530
  headers.setContentType(void 0);
36473
36531
  } else if (utils$1.isFunction(data.getHeaders)) {
36474
36532
  setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
36475
36533
  }
36476
36534
  }
36477
- if (platform2.hasStandardBrowserEnv) {
36535
+ if (platform3.hasStandardBrowserEnv) {
36478
36536
  if (utils$1.isFunction(withXSRFToken)) {
36479
36537
  withXSRFToken = withXSRFToken(newConfig);
36480
36538
  }
@@ -36610,7 +36668,7 @@ var require_axios = __commonJS({
36610
36668
  }
36611
36669
  }
36612
36670
  const protocol = parseProtocol(_config.url);
36613
- if (protocol && !platform2.protocols.includes(protocol)) {
36671
+ if (protocol && !platform3.protocols.includes(protocol)) {
36614
36672
  reject(new AxiosError("Unsupported protocol " + protocol + ":", AxiosError.ERR_BAD_REQUEST, config2));
36615
36673
  return;
36616
36674
  }
@@ -36773,7 +36831,7 @@ var require_axios = __commonJS({
36773
36831
  const encodeText = isFetchSupported && (typeof TextEncoder2 === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder2()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
36774
36832
  const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
36775
36833
  let duplexAccessed = false;
36776
- const request = new Request(platform2.origin, {
36834
+ const request = new Request(platform3.origin, {
36777
36835
  body: new ReadableStream2(),
36778
36836
  method: "POST",
36779
36837
  get duplex() {
@@ -36810,7 +36868,7 @@ var require_axios = __commonJS({
36810
36868
  return body.size;
36811
36869
  }
36812
36870
  if (utils$1.isSpecCompliantForm(body)) {
36813
- const _request = new Request(platform2.origin, {
36871
+ const _request = new Request(platform3.origin, {
36814
36872
  method: "POST",
36815
36873
  body
36816
36874
  });
@@ -43561,6 +43619,7 @@ __export(index_exports, {
43561
43619
  checkOutputContains: () => checkOutputContains,
43562
43620
  cleanLines: () => cleanLines,
43563
43621
  clearBinaryCache: () => clearBinaryCache,
43622
+ clearBrokerLogs: () => clearBrokerLogs,
43564
43623
  clearResolveCache: () => clearResolveCache,
43565
43624
  collectCliSession: () => collectCliSession,
43566
43625
  collectOutput: () => collectOutput,
@@ -43614,6 +43673,7 @@ __export(index_exports, {
43614
43673
  generateUniqueAgentName: () => generateUniqueAgentName,
43615
43674
  getAgentName: () => getAgentName,
43616
43675
  getBaseCli: () => getBaseCli,
43676
+ getBrokerLogDir: () => getBrokerLogDir,
43617
43677
  getCachedRelayPtyPath: () => getCachedRelayPtyPath,
43618
43678
  getCliDefinition: () => getCliDefinition,
43619
43679
  getCliRegistry: () => getCliRegistry,
@@ -43657,6 +43717,7 @@ __export(index_exports, {
43657
43717
  isTrajectoryTrackingAvailable: () => isTrajectoryTrackingAvailable,
43658
43718
  isValidAgentName: () => isValidAgentName,
43659
43719
  isWorktreeStep: () => isWorktreeStep,
43720
+ listBrokerLogs: () => listBrokerLogs,
43660
43721
  listLoggedAgents: () => listLoggedAgents,
43661
43722
  listPersonas: () => listPersonas,
43662
43723
  listWorkflowSchedules: () => listWorkflowSchedules,
@@ -43672,6 +43733,7 @@ __export(index_exports, {
43672
43733
  parseTsxStderr: () => parseTsxStderr,
43673
43734
  parseVoteCommand: () => parseVoteCommand,
43674
43735
  printUpdateNotification: () => printUpdateNotification,
43736
+ pruneBrokerLogs: () => pruneBrokerLogs,
43675
43737
  readInbox: () => readInbox,
43676
43738
  resetPatternMetrics: () => resetPatternMetrics,
43677
43739
  resolveAllCustomSteps: () => resolveAllCustomSteps,
@@ -43704,6 +43766,7 @@ __export(index_exports, {
43704
43766
  stripAnsi: () => stripAnsi,
43705
43767
  stripAnsiFast: () => stripAnsiFast,
43706
43768
  stripInjectedTaskEcho: () => stripInjectedTaskEcho,
43769
+ tailBrokerLog: () => tailBrokerLog,
43707
43770
  toReleaseResult: () => toReleaseResult,
43708
43771
  toSpawnResult: () => toSpawnResult,
43709
43772
  trackPatternPerformance: () => trackPatternPerformance,
@@ -44235,8 +44298,8 @@ var import_node_child_process = require("node:child_process");
44235
44298
  var import_node_module = require("node:module");
44236
44299
  var import_node_url = require("node:url");
44237
44300
  var BROKER_NAME = "agent-relay-broker";
44238
- function getOptionalDepPackageName(platform2 = process.platform, arch = process.arch) {
44239
- return `@agent-relay/broker-${platform2}-${arch}`;
44301
+ function getOptionalDepPackageName(platform3 = process.platform, arch = process.arch) {
44302
+ return `@agent-relay/broker-${platform3}-${arch}`;
44240
44303
  }
44241
44304
  function addUniquePath(paths, candidate) {
44242
44305
  if (!candidate || paths.includes(candidate)) {
@@ -44426,10 +44489,18 @@ function formatBrokerNotFoundError() {
44426
44489
 
44427
44490
  // packages/sdk/dist/event-bus.js
44428
44491
  var EventBus = class {
44492
+ // Stored type uses `unknown` for `R` so a single Set can hold handlers
44493
+ // from any overload — the dispatcher casts back when it cares about a
44494
+ // non-void return value (see `runBeforeSpawn` in `client.ts`).
44429
44495
  handlers = /* @__PURE__ */ new Map();
44430
44496
  /**
44431
44497
  * Register a handler for `event`. Returns an unsubscribe function that
44432
44498
  * removes the handler when called.
44499
+ *
44500
+ * The `R` generic is inferred from the handler return type; callers
44501
+ * that don't care about the return get the default `void` shape, while
44502
+ * events like `beforeAgentSpawn` can pass handlers that return a
44503
+ * `SpawnPatch`.
44433
44504
  */
44434
44505
  addListener(event, handler) {
44435
44506
  let set2 = this.handlers.get(event);
@@ -44510,7 +44581,8 @@ function buildSpawnPtyBody(input) {
44510
44581
  ...input.continueFrom !== void 0 ? { continueFrom: input.continueFrom } : {},
44511
44582
  ...input.idleThresholdSecs !== void 0 ? { idleThresholdSecs: input.idleThresholdSecs } : {},
44512
44583
  ...input.restartPolicy !== void 0 ? { restartPolicy: input.restartPolicy } : {},
44513
- ...input.skipRelayPrompt !== void 0 ? { skipRelayPrompt: input.skipRelayPrompt } : {}
44584
+ ...input.skipRelayPrompt !== void 0 ? { skipRelayPrompt: input.skipRelayPrompt } : {},
44585
+ ...input.agentResultSchema !== void 0 ? { agentResultSchema: input.agentResultSchema } : {}
44514
44586
  };
44515
44587
  }
44516
44588
  function buildSpawnProviderBody(input, transport) {
@@ -44530,6 +44602,7 @@ function buildSpawnProviderBody(input, transport) {
44530
44602
  ...input.idleThresholdSecs !== void 0 ? { idleThresholdSecs: input.idleThresholdSecs } : {},
44531
44603
  ...input.restartPolicy !== void 0 ? { restartPolicy: input.restartPolicy } : {},
44532
44604
  ...input.skipRelayPrompt !== void 0 ? { skipRelayPrompt: input.skipRelayPrompt } : {},
44605
+ ...input.agentResultSchema !== void 0 ? { agentResultSchema: input.agentResultSchema } : {},
44533
44606
  transport
44534
44607
  };
44535
44608
  }
@@ -44569,6 +44642,8 @@ var AgentRelayClient = class _AgentRelayClient {
44569
44642
  child = null;
44570
44643
  /** Lease renewal timer (only for spawned brokers). */
44571
44644
  leaseTimer = null;
44645
+ brokerExitInfo = null;
44646
+ brokerExitListeners = /* @__PURE__ */ new Set();
44572
44647
  workspaceKey;
44573
44648
  /** Resolved broker URL — captured so call-site lifecycle contexts can surface it. */
44574
44649
  baseUrl;
@@ -44584,16 +44659,9 @@ var AgentRelayClient = class _AgentRelayClient {
44584
44659
  requestTimeoutMs: options.requestTimeoutMs
44585
44660
  });
44586
44661
  }
44587
- /**
44588
- * Register a listener on the client's event bus. Returns an unsubscribe
44589
- * function. Equivalent to `client.eventBus.addListener(...)` but mirrors
44590
- * the `AgentRelay` facade API so direct-client callers don't need to
44591
- * reach through `.eventBus`.
44592
- */
44593
44662
  addListener(event, handler) {
44594
44663
  return this.eventBus.addListener(event, handler);
44595
44664
  }
44596
- /** Remove a previously-registered listener. */
44597
44665
  removeListener(event, handler) {
44598
44666
  this.eventBus.removeListener(event, handler);
44599
44667
  }
@@ -44714,6 +44782,7 @@ var AgentRelayClient = class _AgentRelayClient {
44714
44782
  ...options?.eventBus ? { eventBus: options.eventBus } : {}
44715
44783
  });
44716
44784
  client.child = child;
44785
+ client.installManagedBrokerExitHandler(child, stderrLines);
44717
44786
  const brokerExited = new Promise((_2, reject) => {
44718
44787
  child.once("exit", (code) => {
44719
44788
  reject(new Error(formatBrokerStartupError(`Broker process exited with code ${code} during initial handshake`, child, { binaryPath, args, cwd, stdoutLines, stderrLines })));
@@ -44734,18 +44803,13 @@ var AgentRelayClient = class _AgentRelayClient {
44734
44803
  await new Promise((resolve4) => setTimeout(resolve4, 1e3));
44735
44804
  }
44736
44805
  }
44737
- client.connectEvents();
44738
- client.leaseTimer = setInterval(() => {
44739
- client.renewLease().catch(() => {
44740
- });
44741
- }, 6e4);
44742
- child.on("exit", () => {
44743
- client.disconnectEvents();
44744
- if (client.leaseTimer) {
44745
- clearInterval(client.leaseTimer);
44746
- client.leaseTimer = null;
44747
- }
44748
- });
44806
+ if (!client.brokerExitInfo) {
44807
+ client.connectEvents();
44808
+ client.leaseTimer = setInterval(() => {
44809
+ client.renewLease().catch(() => {
44810
+ });
44811
+ }, 6e4);
44812
+ }
44749
44813
  return client;
44750
44814
  }
44751
44815
  /** PID of the managed broker process, if spawned locally. */
@@ -44771,6 +44835,33 @@ var AgentRelayClient = class _AgentRelayClient {
44771
44835
  onEvent(listener) {
44772
44836
  return this.transport.onEvent(listener);
44773
44837
  }
44838
+ /**
44839
+ * Subscribe to managed broker child-process exit.
44840
+ *
44841
+ * Clients created with `new AgentRelayClient(...)` or `connect()` do not own a
44842
+ * broker child process, so this is a no-op for them.
44843
+ */
44844
+ onBrokerExit(listener) {
44845
+ if (!this.child && !this.brokerExitInfo) {
44846
+ return () => {
44847
+ };
44848
+ }
44849
+ this.brokerExitListeners.add(listener);
44850
+ if (this.brokerExitInfo) {
44851
+ const info = cloneBrokerExitInfo(this.brokerExitInfo);
44852
+ queueMicrotask(() => {
44853
+ if (this.brokerExitListeners.has(listener)) {
44854
+ try {
44855
+ listener(info);
44856
+ } catch {
44857
+ }
44858
+ }
44859
+ });
44860
+ }
44861
+ return () => {
44862
+ this.brokerExitListeners.delete(listener);
44863
+ };
44864
+ }
44774
44865
  queryEvents(filter) {
44775
44866
  return this.transport.queryEvents(filter);
44776
44867
  }
@@ -45087,6 +45178,40 @@ var AgentRelayClient = class _AgentRelayClient {
45087
45178
  async getConfig() {
45088
45179
  return this.transport.request("/api/config");
45089
45180
  }
45181
+ notifyBrokerExit(info) {
45182
+ if (this.brokerExitInfo)
45183
+ return;
45184
+ this.brokerExitInfo = cloneBrokerExitInfo(info);
45185
+ for (const listener of this.brokerExitListeners) {
45186
+ try {
45187
+ listener(cloneBrokerExitInfo(info));
45188
+ } catch {
45189
+ }
45190
+ }
45191
+ }
45192
+ installManagedBrokerExitHandler(child, stderrLines) {
45193
+ const handleExit = (code, signal) => {
45194
+ this.notifyBrokerExit({
45195
+ code,
45196
+ signal,
45197
+ pid: child.pid,
45198
+ recentStderr: [...stderrLines]
45199
+ });
45200
+ this.disconnectEvents();
45201
+ if (this.leaseTimer) {
45202
+ clearInterval(this.leaseTimer);
45203
+ this.leaseTimer = null;
45204
+ }
45205
+ if (this.child === child) {
45206
+ this.child = null;
45207
+ }
45208
+ };
45209
+ if (child.exitCode !== null || child.signalCode !== null) {
45210
+ handleExit(child.exitCode, child.signalCode);
45211
+ return;
45212
+ }
45213
+ child.once("exit", handleExit);
45214
+ }
45090
45215
  };
45091
45216
  async function waitForApiUrl(child, timeoutMs, debug) {
45092
45217
  const { createInterface: createInterface2 } = await import("node:readline");
@@ -45150,6 +45275,12 @@ function pushBufferedLine(lines, line) {
45150
45275
  lines.splice(0, lines.length - 40);
45151
45276
  }
45152
45277
  }
45278
+ function cloneBrokerExitInfo(info) {
45279
+ return {
45280
+ ...info,
45281
+ recentStderr: [...info.recentStderr]
45282
+ };
45283
+ }
45153
45284
  function formatBrokerStartupError(message, child, debug) {
45154
45285
  const details = [
45155
45286
  `pid=${child.pid ?? "unknown"}`,
@@ -70714,27 +70845,9 @@ var AgentRelay = class {
70714
70845
  * the same events.
70715
70846
  */
70716
70847
  bus = new EventBus();
70717
- // ── Listener registration ───────────────────────────────────────────────
70718
- /**
70719
- * Register a listener for a relay lifecycle event. Returns an
70720
- * unsubscribe function.
70721
- *
70722
- * Example:
70723
- * ```ts
70724
- * const off = relay.addListener('agentSpawned', (agent) => console.log(agent.name));
70725
- * // later:
70726
- * off();
70727
- * ```
70728
- *
70729
- * Replaces the pre-2.x single-callback `on*` fields. Multiple listeners
70730
- * can register for the same event; they fire sequentially in
70731
- * registration order. Async handlers are awaited. Handler exceptions
70732
- * are caught and logged; one bad listener never blocks the others.
70733
- */
70734
70848
  addListener(event, handler) {
70735
70849
  return this.bus.addListener(event, handler);
70736
70850
  }
70737
- /** Remove a previously-registered listener. Idempotent. */
70738
70851
  removeListener(event, handler) {
70739
70852
  this.bus.removeListener(event, handler);
70740
70853
  }
@@ -70774,6 +70887,10 @@ var AgentRelay = class {
70774
70887
  deliveryStates = /* @__PURE__ */ new Map();
70775
70888
  agentActivityStates = /* @__PURE__ */ new Map();
70776
70889
  outputListeners = /* @__PURE__ */ new Map();
70890
+ resultContracts = /* @__PURE__ */ new Map();
70891
+ lastAgentResults = /* @__PURE__ */ new Map();
70892
+ resultResolvers = /* @__PURE__ */ new Map();
70893
+ resultResolverSeq = 0;
70777
70894
  exitResolvers = /* @__PURE__ */ new Map();
70778
70895
  exitResolverSeq = 0;
70779
70896
  idleResolvers = /* @__PURE__ */ new Map();
@@ -70919,6 +71036,10 @@ var AgentRelay = class {
70919
71036
  };
70920
71037
  await this.invokeLifecycleHook(input.onStart, lifecycleContext, `spawnPty("${input.name}") onStart`);
70921
71038
  let result;
71039
+ const resultContract = this.prepareAgentResultContract(input.result);
71040
+ if (resultContract) {
71041
+ this.resultContracts.set(input.name, resultContract);
71042
+ }
70922
71043
  try {
70923
71044
  result = await client.spawnPty({
70924
71045
  name: input.name,
@@ -70934,9 +71055,13 @@ var AgentRelay = class {
70934
71055
  shadowMode: input.shadowMode,
70935
71056
  idleThresholdSecs: input.idleThresholdSecs,
70936
71057
  restartPolicy: input.restartPolicy,
70937
- skipRelayPrompt: input.skipRelayPrompt
71058
+ skipRelayPrompt: input.skipRelayPrompt,
71059
+ agentResultSchema: resultContract?.jsonSchema
70938
71060
  });
70939
71061
  } catch (error51) {
71062
+ if (resultContract) {
71063
+ this.resultContracts.delete(input.name);
71064
+ }
70940
71065
  await this.invokeLifecycleHook(input.onError, {
70941
71066
  ...lifecycleContext,
70942
71067
  error: error51
@@ -70944,6 +71069,10 @@ var AgentRelay = class {
70944
71069
  throw error51;
70945
71070
  }
70946
71071
  this.resetAgentLifecycleState(result.name);
71072
+ if (result.name !== input.name && resultContract) {
71073
+ this.resultContracts.delete(input.name);
71074
+ this.resultContracts.set(result.name, resultContract);
71075
+ }
70947
71076
  const agent = this.makeAgent(result.name, result.runtime, channels);
70948
71077
  this.knownAgents.set(agent.name, agent);
70949
71078
  await this.invokeLifecycleHook(input.onSuccess, {
@@ -70969,6 +71098,7 @@ var AgentRelay = class {
70969
71098
  idleThresholdSecs: options?.idleThresholdSecs,
70970
71099
  restartPolicy: options?.restartPolicy,
70971
71100
  skipRelayPrompt: options?.skipRelayPrompt,
71101
+ result: options?.result,
70972
71102
  onStart: options?.onStart,
70973
71103
  onSuccess: options?.onSuccess,
70974
71104
  onError: options?.onError
@@ -71037,6 +71167,7 @@ var AgentRelay = class {
71037
71167
  idleThresholdSecs: options.idleThresholdSecs,
71038
71168
  restartPolicy: options.restartPolicy,
71039
71169
  skipRelayPrompt: options.skipRelayPrompt,
71170
+ result: options.result,
71040
71171
  onStart: options.onStart,
71041
71172
  onSuccess: options.onSuccess,
71042
71173
  onError: options.onError
@@ -71395,6 +71526,15 @@ var AgentRelay = class {
71395
71526
  entry.resolve("exited");
71396
71527
  }
71397
71528
  this.idleResolvers.clear();
71529
+ const shutdownError = new Error("AgentRelay shutdown before structured result was submitted");
71530
+ for (const waiters of this.resultResolvers.values()) {
71531
+ for (const waiter of waiters) {
71532
+ waiter.reject(shutdownError);
71533
+ }
71534
+ }
71535
+ this.resultResolvers.clear();
71536
+ this.resultContracts.clear();
71537
+ this.lastAgentResults.clear();
71398
71538
  }
71399
71539
  // ── Private helpers ─────────────────────────────────────────────────────
71400
71540
  ensureAgentHandle(name, runtime = "pty", channels = []) {
@@ -71652,10 +71792,14 @@ var AgentRelay = class {
71652
71792
  void this.bus.emit("agentReleased", agent);
71653
71793
  this.knownAgents.delete(event.name);
71654
71794
  this.outputListeners.delete(event.name);
71795
+ this.resultContracts.delete(event.name);
71655
71796
  this.exitResolvers.get(event.name)?.resolve("released");
71656
71797
  this.exitResolvers.delete(event.name);
71657
71798
  this.idleResolvers.get(event.name)?.resolve("exited");
71658
71799
  this.idleResolvers.delete(event.name);
71800
+ for (const waiter of this.takeResultResolvers(event.name)) {
71801
+ waiter.reject(new Error(`Agent '${event.name}' was released before submitting a result`));
71802
+ }
71659
71803
  break;
71660
71804
  }
71661
71805
  case "agent_exited": {
@@ -71673,10 +71817,14 @@ var AgentRelay = class {
71673
71817
  void this.bus.emit("agentExited", agent);
71674
71818
  this.knownAgents.delete(event.name);
71675
71819
  this.outputListeners.delete(event.name);
71820
+ this.resultContracts.delete(event.name);
71676
71821
  this.exitResolvers.get(event.name)?.resolve("exited");
71677
71822
  this.exitResolvers.delete(event.name);
71678
71823
  this.idleResolvers.get(event.name)?.resolve("exited");
71679
71824
  this.idleResolvers.delete(event.name);
71825
+ for (const waiter of this.takeResultResolvers(event.name)) {
71826
+ waiter.reject(new Error(`Agent '${event.name}' exited before submitting a result`));
71827
+ }
71680
71828
  break;
71681
71829
  }
71682
71830
  case "agent_exit": {
@@ -71765,12 +71913,141 @@ var AgentRelay = class {
71765
71913
  this.idleResolvers.delete(event.name);
71766
71914
  break;
71767
71915
  }
71916
+ case "agent_result": {
71917
+ this.dispatchAgentResult(event.name, {
71918
+ name: event.name,
71919
+ resultId: event.result_id,
71920
+ data: event.data,
71921
+ final: event.final,
71922
+ metadata: event.metadata ?? void 0
71923
+ });
71924
+ break;
71925
+ }
71768
71926
  }
71769
71927
  if (event.kind.startsWith("delivery_") || event.kind.startsWith("message_delivery_")) {
71770
71928
  void this.bus.emit("deliveryUpdate", event);
71771
71929
  }
71772
71930
  });
71773
71931
  }
71932
+ prepareAgentResultContract(options) {
71933
+ if (!options) {
71934
+ return void 0;
71935
+ }
71936
+ return {
71937
+ schema: options.schema,
71938
+ jsonSchema: options.jsonSchema ?? this.schemaToJsonSchema(options.schema),
71939
+ onResult: options.onResult
71940
+ };
71941
+ }
71942
+ schemaToJsonSchema(schema) {
71943
+ if (schema && typeof schema === "object" && this.isZodSchema(schema)) {
71944
+ return zodToJsonSchema(schema, { target: "jsonSchema7" });
71945
+ }
71946
+ return true;
71947
+ }
71948
+ isZodSchema(schema) {
71949
+ return "_def" in schema && typeof schema.safeParse === "function";
71950
+ }
71951
+ validateAgentResult(contract, value) {
71952
+ const schema = contract?.schema;
71953
+ if (!schema) {
71954
+ return value;
71955
+ }
71956
+ if (typeof schema === "function") {
71957
+ return schema(value);
71958
+ }
71959
+ if (typeof schema.safeParse === "function") {
71960
+ const parsed = schema.safeParse(value);
71961
+ if (parsed.success) {
71962
+ return parsed.data;
71963
+ }
71964
+ throw new Error(`Agent result failed schema validation: ${String(parsed.error)}`);
71965
+ }
71966
+ if (typeof schema.parse === "function") {
71967
+ return schema.parse(value);
71968
+ }
71969
+ return value;
71970
+ }
71971
+ takeResultResolvers(name) {
71972
+ const waiters = this.resultResolvers.get(name);
71973
+ if (!waiters || waiters.length === 0)
71974
+ return [];
71975
+ this.resultResolvers.delete(name);
71976
+ return waiters;
71977
+ }
71978
+ dispatchAgentResult(name, raw) {
71979
+ const contract = this.resultContracts.get(name);
71980
+ let result;
71981
+ try {
71982
+ const data = this.validateAgentResult(contract, raw.data);
71983
+ result = { ...raw, data };
71984
+ } catch (error51) {
71985
+ const err = error51 instanceof Error ? error51 : new Error(String(error51));
71986
+ for (const waiter of this.takeResultResolvers(name))
71987
+ waiter.reject(err);
71988
+ console.warn(`[AgentRelay] structured result from "${name}" failed validation`, err);
71989
+ return;
71990
+ }
71991
+ void this.bus.emit("agentResult", result);
71992
+ if (contract?.onResult) {
71993
+ Promise.resolve(contract.onResult(result.data, result)).catch((error51) => {
71994
+ console.warn(`[AgentRelay] result("${name}") onResult hook threw`, error51);
71995
+ });
71996
+ }
71997
+ if (result.final) {
71998
+ this.lastAgentResults.set(name, result);
71999
+ for (const waiter of this.takeResultResolvers(name))
72000
+ waiter.resolve(result);
72001
+ }
72002
+ }
72003
+ waitForAgentResult(name, timeoutMs) {
72004
+ const existing = this.lastAgentResults.get(name);
72005
+ if (existing) {
72006
+ return Promise.resolve(existing);
72007
+ }
72008
+ if (!this.knownAgents.has(name) && !this.resultContracts.has(name)) {
72009
+ return Promise.reject(new Error(`Agent '${name}' is not running and has no structured result`));
72010
+ }
72011
+ if (timeoutMs === 0) {
72012
+ return Promise.reject(new Error(`Timed out waiting for structured result from '${name}'`));
72013
+ }
72014
+ return new Promise((resolve4, reject) => {
72015
+ let timer;
72016
+ const token = ++this.resultResolverSeq;
72017
+ const waiter = {
72018
+ resolve: (result) => {
72019
+ if (timer)
72020
+ clearTimeout(timer);
72021
+ resolve4(result);
72022
+ },
72023
+ reject: (error51) => {
72024
+ if (timer)
72025
+ clearTimeout(timer);
72026
+ reject(error51);
72027
+ },
72028
+ token
72029
+ };
72030
+ const existingWaiters = this.resultResolvers.get(name);
72031
+ if (existingWaiters) {
72032
+ existingWaiters.push(waiter);
72033
+ } else {
72034
+ this.resultResolvers.set(name, [waiter]);
72035
+ }
72036
+ if (timeoutMs !== void 0) {
72037
+ timer = setTimeout(() => {
72038
+ const list = this.resultResolvers.get(name);
72039
+ if (list) {
72040
+ const idx = list.findIndex((w2) => w2.token === token);
72041
+ if (idx >= 0)
72042
+ list.splice(idx, 1);
72043
+ if (list.length === 0)
72044
+ this.resultResolvers.delete(name);
72045
+ }
72046
+ reject(new Error(`Timed out waiting for structured result from '${name}' after ${timeoutMs}ms`));
72047
+ }, timeoutMs);
72048
+ }
72049
+ });
72050
+ }
71774
72051
  makeAgent(name, runtime, channels) {
71775
72052
  const relay = this;
71776
72053
  let agentChannels = [...channels];
@@ -71819,6 +72096,11 @@ var AgentRelay = class {
71819
72096
  relay.exitResolvers.delete(name);
71820
72097
  relay.idleResolvers.get(name)?.resolve("exited");
71821
72098
  relay.idleResolvers.delete(name);
72099
+ relay.resultContracts.delete(name);
72100
+ relay.lastAgentResults.delete(name);
72101
+ for (const waiter of relay.takeResultResolvers(name)) {
72102
+ waiter.reject(new Error(`Agent '${name}' was released before submitting a result`));
72103
+ }
71822
72104
  await relay.invokeLifecycleHook(releaseOptions.onSuccess, releaseContext, `release("${name}") onSuccess`);
71823
72105
  return;
71824
72106
  }
@@ -71894,6 +72176,9 @@ var AgentRelay = class {
71894
72176
  }
71895
72177
  });
71896
72178
  },
72179
+ waitForResult(timeoutMs) {
72180
+ return relay.waitForAgentResult(name, timeoutMs);
72181
+ },
71897
72182
  async sendMessage(input) {
71898
72183
  const client = await relay.ensureStarted();
71899
72184
  let result;
@@ -71979,6 +72264,7 @@ var AgentRelay = class {
71979
72264
  idleThresholdSecs: options?.idleThresholdSecs,
71980
72265
  agentToken: options?.agentToken,
71981
72266
  skipRelayPrompt: options?.skipRelayPrompt,
72267
+ result: options?.result,
71982
72268
  onStart: options?.onStart,
71983
72269
  onSuccess: options?.onSuccess,
71984
72270
  onError: options?.onError
@@ -71993,6 +72279,10 @@ var AgentRelay = class {
71993
72279
  };
71994
72280
  await this.invokeLifecycleHook(options?.onStart, lifecycleContext, `spawn("${name}") onStart`);
71995
72281
  let result;
72282
+ const resultContract = this.prepareAgentResultContract(options?.result);
72283
+ if (resultContract) {
72284
+ this.resultContracts.set(name, resultContract);
72285
+ }
71996
72286
  try {
71997
72287
  result = await client.spawnProvider({
71998
72288
  name,
@@ -72005,9 +72295,13 @@ var AgentRelay = class {
72005
72295
  cwd: options?.cwd,
72006
72296
  idleThresholdSecs: options?.idleThresholdSecs,
72007
72297
  agentToken: options?.agentToken,
72008
- skipRelayPrompt: options?.skipRelayPrompt
72298
+ skipRelayPrompt: options?.skipRelayPrompt,
72299
+ agentResultSchema: resultContract?.jsonSchema
72009
72300
  });
72010
72301
  } catch (error51) {
72302
+ if (resultContract) {
72303
+ this.resultContracts.delete(name);
72304
+ }
72011
72305
  await this.invokeLifecycleHook(options?.onError, {
72012
72306
  ...lifecycleContext,
72013
72307
  error: error51
@@ -72015,6 +72309,10 @@ var AgentRelay = class {
72015
72309
  throw error51;
72016
72310
  }
72017
72311
  this.resetAgentLifecycleState(result.name);
72312
+ if (result.name !== name && resultContract) {
72313
+ this.resultContracts.delete(name);
72314
+ this.resultContracts.set(result.name, resultContract);
72315
+ }
72018
72316
  const agent = this.makeAgent(result.name, result.runtime, channels);
72019
72317
  this.knownAgents.set(agent.name, agent);
72020
72318
  await this.invokeLifecycleHook(options?.onSuccess, {
@@ -72042,6 +72340,10 @@ var AgentRelay = class {
72042
72340
  this.exitedAgents.delete(name);
72043
72341
  this.idleAgents.delete(name);
72044
72342
  this.agentActivityStates.delete(name);
72343
+ this.lastAgentResults.delete(name);
72344
+ for (const waiter of this.takeResultResolvers(name)) {
72345
+ waiter.reject(new Error(`Agent '${name}' lifecycle reset before structured result was submitted`));
72346
+ }
72045
72347
  }
72046
72348
  normalizeReleaseOptions(reasonOrOptions) {
72047
72349
  if (typeof reasonOrOptions === "string" || reasonOrOptions === void 0) {
@@ -72051,6 +72353,161 @@ var AgentRelay = class {
72051
72353
  }
72052
72354
  };
72053
72355
 
72356
+ // packages/sdk/dist/broker-logs.js
72357
+ var import_node_os4 = require("node:os");
72358
+ var import_node_path8 = require("node:path");
72359
+ var import_promises2 = require("node:fs/promises");
72360
+ var LOG_NAME_PATTERN = /^(?<brokerId>.+)\.log(?:\.(?<date>\d{4}-\d{2}-\d{2}))?$/;
72361
+ function getBrokerLogDir() {
72362
+ const home = (0, import_node_os4.homedir)();
72363
+ switch ((0, import_node_os4.platform)()) {
72364
+ case "darwin":
72365
+ return (0, import_node_path8.join)(home, "Library", "Logs", "agent-relay");
72366
+ case "win32": {
72367
+ const localAppData = process.env.LOCALAPPDATA ?? (0, import_node_path8.join)(home, "AppData", "Local");
72368
+ return (0, import_node_path8.join)(localAppData, "agent-relay", "Logs");
72369
+ }
72370
+ default: {
72371
+ const stateHome = process.env.XDG_STATE_HOME && process.env.XDG_STATE_HOME.length > 0 ? process.env.XDG_STATE_HOME : (0, import_node_path8.join)(home, ".local", "state");
72372
+ return (0, import_node_path8.join)(stateHome, "agent-relay", "logs");
72373
+ }
72374
+ }
72375
+ }
72376
+ async function listBrokerLogs(dir) {
72377
+ const logDir = dir ?? getBrokerLogDir();
72378
+ let entries;
72379
+ try {
72380
+ entries = await (0, import_promises2.readdir)(logDir);
72381
+ } catch (err) {
72382
+ if (err.code === "ENOENT")
72383
+ return [];
72384
+ throw err;
72385
+ }
72386
+ const files = [];
72387
+ for (const name of entries) {
72388
+ const match = LOG_NAME_PATTERN.exec(name);
72389
+ if (!match || !match.groups)
72390
+ continue;
72391
+ const fullPath = (0, import_node_path8.join)(logDir, name);
72392
+ let info;
72393
+ try {
72394
+ info = await (0, import_promises2.stat)(fullPath);
72395
+ } catch {
72396
+ continue;
72397
+ }
72398
+ if (!info.isFile())
72399
+ continue;
72400
+ files.push({
72401
+ path: fullPath,
72402
+ name,
72403
+ brokerId: match.groups.brokerId,
72404
+ date: match.groups.date ?? null,
72405
+ size: info.size,
72406
+ mtime: info.mtime
72407
+ });
72408
+ }
72409
+ files.sort((a, b2) => b2.mtime.getTime() - a.mtime.getTime());
72410
+ return files;
72411
+ }
72412
+ async function tailBrokerLog(brokerId, options = {}) {
72413
+ const lines = options.lines ?? 200;
72414
+ const files = (await listBrokerLogs(options.dir)).filter((f2) => f2.brokerId === brokerId);
72415
+ if (files.length === 0)
72416
+ return null;
72417
+ const target = files[0];
72418
+ return { path: target.path, content: await tailFile2(target.path, lines) };
72419
+ }
72420
+ async function pruneBrokerLogs(options = {}) {
72421
+ const keepDays = options.keepDays ?? 7;
72422
+ const cutoff = Date.now() - keepDays * 24 * 60 * 60 * 1e3;
72423
+ const files = await listBrokerLogs(options.dir);
72424
+ const removed = [];
72425
+ const kept = [];
72426
+ for (const file2 of files) {
72427
+ if (options.brokerId && file2.brokerId !== options.brokerId) {
72428
+ kept.push(file2);
72429
+ continue;
72430
+ }
72431
+ if (file2.date === null) {
72432
+ kept.push(file2);
72433
+ continue;
72434
+ }
72435
+ if (file2.mtime.getTime() >= cutoff) {
72436
+ kept.push(file2);
72437
+ continue;
72438
+ }
72439
+ if (!options.dryRun) {
72440
+ try {
72441
+ await (0, import_promises2.unlink)(file2.path);
72442
+ } catch (err) {
72443
+ if (err.code !== "ENOENT")
72444
+ throw err;
72445
+ }
72446
+ }
72447
+ removed.push(file2);
72448
+ }
72449
+ return { removed, kept };
72450
+ }
72451
+ async function clearBrokerLogs(options = {}) {
72452
+ const files = await listBrokerLogs(options.dir);
72453
+ const target = options.brokerId ? files.filter((f2) => f2.brokerId === options.brokerId) : files;
72454
+ if (options.dryRun)
72455
+ return target;
72456
+ for (const file2 of target) {
72457
+ try {
72458
+ await (0, import_promises2.unlink)(file2.path);
72459
+ } catch (err) {
72460
+ if (err.code !== "ENOENT")
72461
+ throw err;
72462
+ }
72463
+ }
72464
+ return target;
72465
+ }
72466
+ async function tailFile2(filePath, lines) {
72467
+ const CHUNK = 8192;
72468
+ let fh;
72469
+ try {
72470
+ fh = await (0, import_promises2.open)(filePath, "r");
72471
+ const { size } = await fh.stat();
72472
+ if (size === 0)
72473
+ return "";
72474
+ if (size <= CHUNK) {
72475
+ const buf = Buffer.alloc(size);
72476
+ await fh.read(buf, 0, size, 0);
72477
+ return tailLines(buf.toString("utf-8"), lines);
72478
+ }
72479
+ const chunks = [];
72480
+ let position = size;
72481
+ let newlines = 0;
72482
+ while (position > 0 && newlines <= lines) {
72483
+ const readSize = Math.min(CHUNK, position);
72484
+ position -= readSize;
72485
+ const buf = Buffer.alloc(readSize);
72486
+ await fh.read(buf, 0, readSize, position);
72487
+ chunks.unshift(buf);
72488
+ newlines += countNewlines(buf);
72489
+ }
72490
+ const combined = Buffer.concat(chunks).toString("utf-8");
72491
+ return tailLines(combined, lines);
72492
+ } finally {
72493
+ if (fh)
72494
+ await fh.close();
72495
+ }
72496
+ }
72497
+ function tailLines(text, count) {
72498
+ const split = text.split("\n");
72499
+ if (split.length > 0 && split[split.length - 1] === "")
72500
+ split.pop();
72501
+ return split.slice(-count).join("\n");
72502
+ }
72503
+ function countNewlines(buf) {
72504
+ let n = 0;
72505
+ for (const byte of buf)
72506
+ if (byte === 10)
72507
+ n++;
72508
+ return n;
72509
+ }
72510
+
72054
72511
  // packages/sdk/dist/consensus.js
72055
72512
  var import_node_crypto3 = require("node:crypto");
72056
72513
  var import_node_events = require("node:events");
@@ -72905,9 +73362,9 @@ function isRestrictedAgent(agent) {
72905
73362
  var import_node_child_process8 = require("node:child_process");
72906
73363
  var import_node_crypto8 = require("node:crypto");
72907
73364
  var import_node_fs21 = require("node:fs");
72908
- var import_promises8 = require("node:fs/promises");
72909
- var import_node_os9 = require("node:os");
72910
- var import_node_path29 = __toESM(require("node:path"), 1);
73365
+ var import_promises9 = require("node:fs/promises");
73366
+ var import_node_os10 = require("node:os");
73367
+ var import_node_path30 = __toESM(require("node:path"), 1);
72911
73368
  var import_chalk = __toESM(require_source(), 1);
72912
73369
  var import_ignore2 = __toESM(require_ignore(), 1);
72913
73370
  var import_yaml2 = __toESM(require_dist(), 1);
@@ -73108,10 +73565,10 @@ async function spawnFromEnv(options = {}) {
73108
73565
 
73109
73566
  // packages/sdk/dist/cli-resolver.js
73110
73567
  var import_node_child_process4 = require("node:child_process");
73111
- var import_promises2 = require("node:fs/promises");
73568
+ var import_promises3 = require("node:fs/promises");
73112
73569
  var import_node_fs5 = require("node:fs");
73113
- var import_node_path8 = require("node:path");
73114
- var import_node_os4 = require("node:os");
73570
+ var import_node_path9 = require("node:path");
73571
+ var import_node_os5 = require("node:os");
73115
73572
  var import_node_util2 = require("node:util");
73116
73573
  var execFileAsync = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
73117
73574
  var resolveCache = /* @__PURE__ */ new Map();
@@ -73120,7 +73577,7 @@ function clearResolveCache() {
73120
73577
  }
73121
73578
  function expandHome2(p2) {
73122
73579
  if (p2.startsWith("~/")) {
73123
- return (0, import_node_path8.join)((0, import_node_os4.homedir)(), p2.slice(2));
73580
+ return (0, import_node_path9.join)((0, import_node_os5.homedir)(), p2.slice(2));
73124
73581
  }
73125
73582
  return p2;
73126
73583
  }
@@ -73149,9 +73606,9 @@ async function resolveCli(cli) {
73149
73606
  if (seen.has(expanded))
73150
73607
  continue;
73151
73608
  seen.add(expanded);
73152
- const candidate = (0, import_node_path8.join)(expanded, binary);
73609
+ const candidate = (0, import_node_path9.join)(expanded, binary);
73153
73610
  try {
73154
- await (0, import_promises2.access)(candidate, import_promises2.constants.X_OK);
73611
+ await (0, import_promises3.access)(candidate, import_promises3.constants.X_OK);
73155
73612
  const result = { binary, path: candidate };
73156
73613
  resolveCache.set(cli, result);
73157
73614
  return result;
@@ -73188,7 +73645,7 @@ function resolveCliSync(cli) {
73188
73645
  if (seen.has(expanded))
73189
73646
  continue;
73190
73647
  seen.add(expanded);
73191
- const candidate = (0, import_node_path8.join)(expanded, binary);
73648
+ const candidate = (0, import_node_path9.join)(expanded, binary);
73192
73649
  try {
73193
73650
  (0, import_node_fs5.accessSync)(candidate, import_node_fs5.constants.X_OK);
73194
73651
  const result = { binary, path: candidate };
@@ -73295,11 +73752,11 @@ function isProxyEnabled(agentDef, swarmConfig) {
73295
73752
 
73296
73753
  // packages/sdk/dist/workflows/custom-steps.js
73297
73754
  var import_node_fs6 = require("node:fs");
73298
- var import_node_path9 = __toESM(require("node:path"), 1);
73755
+ var import_node_path10 = __toESM(require("node:path"), 1);
73299
73756
  var import_yaml = __toESM(require_dist(), 1);
73300
73757
  var CUSTOM_STEPS_FILE = ".relay/steps.yaml";
73301
73758
  function loadCustomSteps(cwd) {
73302
- const stepsPath = import_node_path9.default.join(cwd, CUSTOM_STEPS_FILE);
73759
+ const stepsPath = import_node_path10.default.join(cwd, CUSTOM_STEPS_FILE);
73303
73760
  const steps = /* @__PURE__ */ new Map();
73304
73761
  if (!(0, import_node_fs6.existsSync)(stepsPath)) {
73305
73762
  return steps;
@@ -73555,20 +74012,20 @@ function resolveAllCustomSteps(steps, customSteps) {
73555
74012
  return steps.map((step) => resolveCustomStep(step, customSteps));
73556
74013
  }
73557
74014
  function customStepsFileExists(cwd) {
73558
- return (0, import_node_fs6.existsSync)(import_node_path9.default.join(cwd, CUSTOM_STEPS_FILE));
74015
+ return (0, import_node_fs6.existsSync)(import_node_path10.default.join(cwd, CUSTOM_STEPS_FILE));
73559
74016
  }
73560
74017
  function getCustomStepsPath(cwd) {
73561
- return import_node_path9.default.join(cwd, CUSTOM_STEPS_FILE);
74018
+ return import_node_path10.default.join(cwd, CUSTOM_STEPS_FILE);
73562
74019
  }
73563
74020
 
73564
74021
  // packages/sdk/dist/provisioner/index.js
73565
74022
  var import_node_fs16 = require("node:fs");
73566
- var import_node_path23 = __toESM(require("node:path"), 1);
74023
+ var import_node_path24 = __toESM(require("node:path"), 1);
73567
74024
 
73568
74025
  // packages/sdk/dist/provisioner/audit.js
73569
- var import_promises3 = require("node:fs/promises");
73570
- var import_node_path10 = __toESM(require("node:path"), 1);
73571
- var DEFAULT_PERMISSION_AUDIT_RELATIVE_PATH = import_node_path10.default.join(".agent-relay", "permission-audit.json");
74026
+ var import_promises4 = require("node:fs/promises");
74027
+ var import_node_path11 = __toESM(require("node:path"), 1);
74028
+ var DEFAULT_PERMISSION_AUDIT_RELATIVE_PATH = import_node_path11.default.join(".agent-relay", "permission-audit.json");
73572
74029
  function isPlainObject4(value) {
73573
74030
  return typeof value === "object" && value !== null && !Array.isArray(value);
73574
74031
  }
@@ -73591,7 +74048,7 @@ function sanitizeJsonValue(value, key) {
73591
74048
  return String(value);
73592
74049
  }
73593
74050
  function getDefaultPermissionAuditPath(projectDir) {
73594
- return import_node_path10.default.resolve(projectDir, DEFAULT_PERMISSION_AUDIT_RELATIVE_PATH);
74051
+ return import_node_path11.default.resolve(projectDir, DEFAULT_PERMISSION_AUDIT_RELATIVE_PATH);
73595
74052
  }
73596
74053
  var PermissionAuditLog = class {
73597
74054
  entries = [];
@@ -73616,8 +74073,8 @@ var PermissionAuditLog = class {
73616
74073
  };
73617
74074
  }
73618
74075
  async writeTo(filePath) {
73619
- await (0, import_promises3.mkdir)(import_node_path10.default.dirname(filePath), { recursive: true });
73620
- await (0, import_promises3.writeFile)(filePath, `${JSON.stringify(this.toJSON(), null, 2)}
74076
+ await (0, import_promises4.mkdir)(import_node_path11.default.dirname(filePath), { recursive: true });
74077
+ await (0, import_promises4.writeFile)(filePath, `${JSON.stringify(this.toJSON(), null, 2)}
73621
74078
  `, "utf8");
73622
74079
  }
73623
74080
  summary() {
@@ -73638,7 +74095,7 @@ var PermissionAuditLog = class {
73638
74095
  // packages/sdk/dist/provisioner/compiler.js
73639
74096
  var import_ignore = __toESM(require_ignore(), 1);
73640
74097
  var import_node_fs7 = require("node:fs");
73641
- var import_node_path11 = __toESM(require("node:path"), 1);
74098
+ var import_node_path12 = __toESM(require("node:path"), 1);
73642
74099
  var SKIPPED_DIRS = /* @__PURE__ */ new Set([".git", ".relay", "node_modules"]);
73643
74100
  function cleanPatterns(content) {
73644
74101
  return content.split(/\r?\n/u).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#"));
@@ -73681,15 +74138,15 @@ function createMatcher(patterns) {
73681
74138
  return matcher;
73682
74139
  }
73683
74140
  function loadDotfileRules(projectDir, agentName) {
73684
- const resolvedProjectDir = import_node_path11.default.resolve(projectDir);
74141
+ const resolvedProjectDir = import_node_path12.default.resolve(projectDir);
73685
74142
  return {
73686
74143
  deny: unique([
73687
- ...readPatternFile(import_node_path11.default.join(resolvedProjectDir, ".agentignore")),
73688
- ...readPatternFile(import_node_path11.default.join(resolvedProjectDir, `.${agentName}.agentignore`))
74144
+ ...readPatternFile(import_node_path12.default.join(resolvedProjectDir, ".agentignore")),
74145
+ ...readPatternFile(import_node_path12.default.join(resolvedProjectDir, `.${agentName}.agentignore`))
73689
74146
  ]),
73690
74147
  readonly: unique([
73691
- ...readPatternFile(import_node_path11.default.join(resolvedProjectDir, ".agentreadonly")),
73692
- ...readPatternFile(import_node_path11.default.join(resolvedProjectDir, `.${agentName}.agentreadonly`))
74148
+ ...readPatternFile(import_node_path12.default.join(resolvedProjectDir, ".agentreadonly")),
74149
+ ...readPatternFile(import_node_path12.default.join(resolvedProjectDir, `.${agentName}.agentreadonly`))
73693
74150
  ])
73694
74151
  };
73695
74152
  }
@@ -73704,9 +74161,9 @@ function resolveScopedWorkdirPatterns(projectDir, workdir) {
73704
74161
  if (!workdir) {
73705
74162
  return void 0;
73706
74163
  }
73707
- const resolvedProjectDir = import_node_path11.default.resolve(projectDir);
73708
- const resolvedWorkdir = import_node_path11.default.resolve(resolvedProjectDir, workdir);
73709
- const relativeWorkdir = normalizeRelativePath(import_node_path11.default.relative(resolvedProjectDir, resolvedWorkdir));
74164
+ const resolvedProjectDir = import_node_path12.default.resolve(projectDir);
74165
+ const resolvedWorkdir = import_node_path12.default.resolve(resolvedProjectDir, workdir);
74166
+ const relativeWorkdir = normalizeRelativePath(import_node_path12.default.relative(resolvedProjectDir, resolvedWorkdir));
73710
74167
  if (relativeWorkdir === "" || relativeWorkdir === ".") {
73711
74168
  return void 0;
73712
74169
  }
@@ -73724,8 +74181,8 @@ function walkProjectFiles(projectDir, currentDir = projectDir, files = []) {
73724
74181
  if (entry.isDirectory() && SKIPPED_DIRS.has(entry.name)) {
73725
74182
  continue;
73726
74183
  }
73727
- const fullPath = import_node_path11.default.join(currentDir, entry.name);
73728
- const relativePath = normalizeRelativePath(import_node_path11.default.relative(projectDir, fullPath));
74184
+ const fullPath = import_node_path12.default.join(currentDir, entry.name);
74185
+ const relativePath = normalizeRelativePath(import_node_path12.default.relative(projectDir, fullPath));
73729
74186
  if (entry.isDirectory()) {
73730
74187
  walkProjectFiles(projectDir, fullPath, files);
73731
74188
  continue;
@@ -73769,7 +74226,7 @@ function buildSources(dotfileRules, preset, presetRules, fileRules, rawScopes, i
73769
74226
  function buildAcl(agentName, readonlyPaths, readwritePaths, deniedPaths) {
73770
74227
  const aclMap = /* @__PURE__ */ new Map();
73771
74228
  const addRule = (relativePath, rule) => {
73772
- const aclDir = normalizeAclDir(import_node_path11.default.posix.dirname(normalizeRelativePath(relativePath)));
74229
+ const aclDir = normalizeAclDir(import_node_path12.default.posix.dirname(normalizeRelativePath(relativePath)));
73773
74230
  const rules = aclMap.get(aclDir) ?? /* @__PURE__ */ new Set();
73774
74231
  rules.add(rule);
73775
74232
  aclMap.set(aclDir, rules);
@@ -73783,13 +74240,13 @@ function buildAcl(agentName, readonlyPaths, readwritePaths, deniedPaths) {
73783
74240
  }
73784
74241
  const deniedDirs = /* @__PURE__ */ new Map();
73785
74242
  for (const relativePath of deniedPaths) {
73786
- const aclDir = normalizeAclDir(import_node_path11.default.posix.dirname(normalizeRelativePath(relativePath)));
74243
+ const aclDir = normalizeAclDir(import_node_path12.default.posix.dirname(normalizeRelativePath(relativePath)));
73787
74244
  const summary = deniedDirs.get(aclDir) ?? { denied: 0, allowed: 0 };
73788
74245
  summary.denied += 1;
73789
74246
  deniedDirs.set(aclDir, summary);
73790
74247
  }
73791
74248
  for (const relativePath of [...readonlyPaths, ...readwritePaths]) {
73792
- const aclDir = normalizeAclDir(import_node_path11.default.posix.dirname(normalizeRelativePath(relativePath)));
74249
+ const aclDir = normalizeAclDir(import_node_path12.default.posix.dirname(normalizeRelativePath(relativePath)));
73793
74250
  const summary = deniedDirs.get(aclDir) ?? { denied: 0, allowed: 0 };
73794
74251
  summary.allowed += 1;
73795
74252
  deniedDirs.set(aclDir, summary);
@@ -73839,7 +74296,7 @@ function compileAgentPermissions(input) {
73839
74296
  const permissions = input.permissions ?? {};
73840
74297
  const effectiveAccess = permissions.access ?? "readwrite";
73841
74298
  const inherited = effectiveAccess !== "full" && permissions.inherit !== false;
73842
- const projectDir = import_node_path11.default.resolve(input.projectDir);
74299
+ const projectDir = import_node_path12.default.resolve(input.projectDir);
73843
74300
  const scopedInput = input;
73844
74301
  const dotfileRules = inherited ? loadDotfileRules(projectDir, input.agentName) : { deny: [], readonly: [] };
73845
74302
  const presetRules = expandPreset(effectiveAccess, {
@@ -73943,16 +74400,16 @@ function mergePermissionSources(dotfileScopes, yamlScopes, rawScopes) {
73943
74400
  var import_node_child_process5 = require("node:child_process");
73944
74401
  var import_node_crypto4 = require("node:crypto");
73945
74402
  var import_node_fs8 = require("node:fs");
73946
- var import_promises4 = require("node:fs/promises");
74403
+ var import_promises5 = require("node:fs/promises");
73947
74404
  var import_node_https = __toESM(require("node:https"), 1);
73948
- var import_node_os5 = __toESM(require("node:os"), 1);
73949
- var import_node_path12 = __toESM(require("node:path"), 1);
74405
+ var import_node_os6 = __toESM(require("node:os"), 1);
74406
+ var import_node_path13 = __toESM(require("node:path"), 1);
73950
74407
  var RELAYFILE_VERSION = "0.1.6";
73951
74408
  var RELEASE_BASE_URL = "https://github.com/AgentWorkforce/relayfile/releases/download";
73952
74409
  var CHECKSUMS_FILE = "checksums.txt";
73953
- var CACHE_DIR = import_node_path12.default.join(import_node_os5.default.homedir(), ".agent-relay", "bin");
73954
- var CACHE_PATH = import_node_path12.default.join(CACHE_DIR, "relayfile-mount");
73955
- var VERSION_PATH = import_node_path12.default.join(CACHE_DIR, "relayfile-mount.version");
74410
+ var CACHE_DIR = import_node_path13.default.join(import_node_os6.default.homedir(), ".agent-relay", "bin");
74411
+ var CACHE_PATH = import_node_path13.default.join(CACHE_DIR, "relayfile-mount");
74412
+ var VERSION_PATH = import_node_path13.default.join(CACHE_DIR, "relayfile-mount.version");
73956
74413
  var SUPPORTED_TARGETS = ["darwin-arm64", "darwin-amd64", "linux-arm64", "linux-amd64"].join(", ");
73957
74414
  var PLATFORM_ARCH_MAP = {
73958
74415
  "darwin:arm64": "darwin-arm64",
@@ -73964,9 +74421,9 @@ function ensureCacheDir() {
73964
74421
  (0, import_node_fs8.mkdirSync)(CACHE_DIR, { recursive: true });
73965
74422
  }
73966
74423
  function getRelayfileTarget() {
73967
- const target = PLATFORM_ARCH_MAP[`${import_node_os5.default.platform()}:${import_node_os5.default.arch()}`];
74424
+ const target = PLATFORM_ARCH_MAP[`${import_node_os6.default.platform()}:${import_node_os6.default.arch()}`];
73968
74425
  if (!target) {
73969
- throw new Error(`Unsupported platform for relayfile-mount: ${import_node_os5.default.platform()}-${import_node_os5.default.arch()}. Supported targets: ${SUPPORTED_TARGETS}.`);
74426
+ throw new Error(`Unsupported platform for relayfile-mount: ${import_node_os6.default.platform()}-${import_node_os6.default.arch()}. Supported targets: ${SUPPORTED_TARGETS}.`);
73970
74427
  }
73971
74428
  return target;
73972
74429
  }
@@ -74079,7 +74536,7 @@ function getExpectedChecksum(checksumContent, binaryName) {
74079
74536
  if (!match) {
74080
74537
  continue;
74081
74538
  }
74082
- const entryName = import_node_path12.default.basename(match[2].trim());
74539
+ const entryName = import_node_path13.default.basename(match[2].trim());
74083
74540
  if (entryName === binaryName) {
74084
74541
  return match[1].toLowerCase();
74085
74542
  }
@@ -74096,7 +74553,7 @@ async function verifyChecksum(filePath, binaryName) {
74096
74553
  }
74097
74554
  }
74098
74555
  function resignBinaryForMacOS(binaryPath) {
74099
- if (import_node_os5.default.platform() !== "darwin") {
74556
+ if (import_node_os6.default.platform() !== "darwin") {
74100
74557
  return;
74101
74558
  }
74102
74559
  try {
@@ -74109,7 +74566,7 @@ async function ensureRelayfileMountBinary(binaryPath) {
74109
74566
  return binaryPath;
74110
74567
  }
74111
74568
  if (process.env.RELAYFILE_ROOT) {
74112
- return import_node_path12.default.join(process.env.RELAYFILE_ROOT, "bin", "relayfile-mount");
74569
+ return import_node_path13.default.join(process.env.RELAYFILE_ROOT, "bin", "relayfile-mount");
74113
74570
  }
74114
74571
  const target = getRelayfileTarget();
74115
74572
  const binaryName = `relayfile-mount-${target}`;
@@ -74121,7 +74578,7 @@ async function ensureRelayfileMountBinary(binaryPath) {
74121
74578
  }
74122
74579
  return CACHE_PATH;
74123
74580
  }
74124
- const tempPath = import_node_path12.default.join(CACHE_DIR, `relayfile-mount.${process.pid}.${Date.now()}.download`);
74581
+ const tempPath = import_node_path13.default.join(CACHE_DIR, `relayfile-mount.${process.pid}.${Date.now()}.download`);
74125
74582
  try {
74126
74583
  await downloadBinary(downloadUrl, tempPath);
74127
74584
  await verifyChecksum(tempPath, binaryName);
@@ -74193,7 +74650,7 @@ async function ensureRelayfileMount(config2) {
74193
74650
  if (!(0, import_node_fs8.existsSync)(binaryPath)) {
74194
74651
  throw new Error(`missing relayfile mount binary: ${binaryPath}`);
74195
74652
  }
74196
- const mountPoint = config2.mountPoint ?? await (0, import_promises4.mkdtemp)(import_node_path12.default.join(import_node_os5.default.tmpdir(), `relayfile-mount-${config2.workspace}-`));
74653
+ const mountPoint = config2.mountPoint ?? await (0, import_promises5.mkdtemp)(import_node_path13.default.join(import_node_os6.default.tmpdir(), `relayfile-mount-${config2.workspace}-`));
74197
74654
  (0, import_node_fs8.mkdirSync)(mountPoint, { recursive: true });
74198
74655
  const mountBaseArgs = [
74199
74656
  "--base-url",
@@ -74237,12 +74694,12 @@ async function ensureRelayfileMount(config2) {
74237
74694
  if (mountProc) {
74238
74695
  await stopMountProcess(mountProc).catch(() => void 0);
74239
74696
  }
74240
- await (0, import_promises4.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
74697
+ await (0, import_promises5.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
74241
74698
  const message = error51 instanceof Error ? error51.message : String(error51);
74242
74699
  throw new Error(`${startupPhase} failed for ${config2.workspace}: ${message}`);
74243
74700
  }
74244
74701
  if (!mountProc || typeof mountProc.pid !== "number") {
74245
- await (0, import_promises4.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
74702
+ await (0, import_promises5.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
74246
74703
  throw new Error(`mount process startup failed for ${config2.workspace}: missing process id`);
74247
74704
  }
74248
74705
  let stopped = false;
@@ -74255,7 +74712,7 @@ async function ensureRelayfileMount(config2) {
74255
74712
  }
74256
74713
  stopped = true;
74257
74714
  await stopMountProcess(mountProc).catch(() => void 0);
74258
- await (0, import_promises4.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
74715
+ await (0, import_promises5.rm)(mountPoint, { recursive: true, force: true }).catch(() => void 0);
74259
74716
  }
74260
74717
  };
74261
74718
  }
@@ -75101,7 +75558,7 @@ var debugEnabled2 = (() => {
75101
75558
 
75102
75559
  // packages/sdk/dist/provisioner/seeder.js
75103
75560
  var import_node_fs15 = __toESM(require("node:fs"), 1);
75104
- var import_node_path22 = __toESM(require("node:path"), 1);
75561
+ var import_node_path23 = __toESM(require("node:path"), 1);
75105
75562
 
75106
75563
  // node_modules/tar/dist/esm/index.min.js
75107
75564
  var import_events = __toESM(require("events"), 1);
@@ -75109,7 +75566,7 @@ var import_fs = __toESM(require("fs"), 1);
75109
75566
  var import_node_events2 = require("node:events");
75110
75567
  var import_node_stream = __toESM(require("node:stream"), 1);
75111
75568
  var import_node_string_decoder = require("node:string_decoder");
75112
- var import_node_path13 = __toESM(require("node:path"), 1);
75569
+ var import_node_path14 = __toESM(require("node:path"), 1);
75113
75570
  var import_node_fs9 = __toESM(require("node:fs"), 1);
75114
75571
  var import_path = require("path");
75115
75572
  var import_events2 = require("events");
@@ -75117,27 +75574,27 @@ var import_assert = __toESM(require("assert"), 1);
75117
75574
  var import_buffer = require("buffer");
75118
75575
  var vs = __toESM(require("zlib"), 1);
75119
75576
  var import_zlib = __toESM(require("zlib"), 1);
75120
- var import_node_path14 = require("node:path");
75121
75577
  var import_node_path15 = require("node:path");
75578
+ var import_node_path16 = require("node:path");
75122
75579
  var import_fs2 = __toESM(require("fs"), 1);
75123
75580
  var import_fs3 = __toESM(require("fs"), 1);
75124
75581
  var import_path2 = __toESM(require("path"), 1);
75125
- var import_node_path16 = require("node:path");
75582
+ var import_node_path17 = require("node:path");
75126
75583
  var import_path3 = __toESM(require("path"), 1);
75127
75584
  var import_node_fs10 = __toESM(require("node:fs"), 1);
75128
75585
  var import_node_assert = __toESM(require("node:assert"), 1);
75129
75586
  var import_node_crypto5 = require("node:crypto");
75130
75587
  var import_node_fs11 = __toESM(require("node:fs"), 1);
75131
- var import_node_path17 = __toESM(require("node:path"), 1);
75588
+ var import_node_path18 = __toESM(require("node:path"), 1);
75132
75589
  var import_fs4 = __toESM(require("fs"), 1);
75133
75590
  var import_node_fs12 = __toESM(require("node:fs"), 1);
75134
- var import_node_path18 = __toESM(require("node:path"), 1);
75135
- var import_node_fs13 = __toESM(require("node:fs"), 1);
75136
- var import_promises5 = __toESM(require("node:fs/promises"), 1);
75137
75591
  var import_node_path19 = __toESM(require("node:path"), 1);
75138
- var import_node_path20 = require("node:path");
75592
+ var import_node_fs13 = __toESM(require("node:fs"), 1);
75593
+ var import_promises6 = __toESM(require("node:fs/promises"), 1);
75594
+ var import_node_path20 = __toESM(require("node:path"), 1);
75595
+ var import_node_path21 = require("node:path");
75139
75596
  var import_node_fs14 = __toESM(require("node:fs"), 1);
75140
- var import_node_path21 = __toESM(require("node:path"), 1);
75597
+ var import_node_path22 = __toESM(require("node:path"), 1);
75141
75598
  var vr = Object.defineProperty;
75142
75599
  var Mr = (s3, t) => {
75143
75600
  for (var e in t) vr(s3, e, { get: t[e], enumerable: true });
@@ -76030,12 +76487,12 @@ var k = class {
76030
76487
  }
76031
76488
  };
76032
76489
  var ln = (s3, t) => {
76033
- let i = s3, r = "", n, o = import_node_path14.posix.parse(s3).root || ".";
76490
+ let i = s3, r = "", n, o = import_node_path15.posix.parse(s3).root || ".";
76034
76491
  if (Buffer.byteLength(i) < 100) n = [i, r, false];
76035
76492
  else {
76036
- r = import_node_path14.posix.dirname(i), i = import_node_path14.posix.basename(i);
76493
+ r = import_node_path15.posix.dirname(i), i = import_node_path15.posix.basename(i);
76037
76494
  do
76038
- Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i = import_node_path14.posix.join(import_node_path14.posix.basename(r), i), r = import_node_path14.posix.dirname(r));
76495
+ Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i = import_node_path15.posix.join(import_node_path15.posix.basename(r), i), r = import_node_path15.posix.dirname(r));
76039
76496
  while (r !== o && n === void 0);
76040
76497
  n || (n = [s3.slice(0, 99), "", true]);
76041
76498
  }
@@ -76081,7 +76538,7 @@ var ct = class s {
76081
76538
  if (t === "") return Buffer.allocUnsafe(0);
76082
76539
  let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
76083
76540
  for (let n = 0; n < 512; n++) r[n] = 0;
76084
- new k({ path: ("PaxHeader/" + (0, import_node_path15.basename)(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t, 512, e, "utf8");
76541
+ new k({ path: ("PaxHeader/" + (0, import_node_path16.basename)(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t, 512, e, "utf8");
76085
76542
  for (let n = e + 512; n < r.length; n++) r[n] = 0;
76086
76543
  return r;
76087
76544
  }
@@ -76493,7 +76950,7 @@ var Ct = K(An, In, (s3) => new st(s3), (s3) => new st(s3), (s3, t) => {
76493
76950
  t?.length && $i(s3, t), s3.noResume || Dn(s3);
76494
76951
  });
76495
76952
  var Xi = (s3, t, e) => (s3 &= 4095, e && (s3 = (s3 | 384) & -19), t && (s3 & 256 && (s3 |= 64), s3 & 32 && (s3 |= 8), s3 & 4 && (s3 |= 1)), s3);
76496
- var { isAbsolute: kn, parse: Ks } = import_node_path16.win32;
76953
+ var { isAbsolute: kn, parse: Ks } = import_node_path17.win32;
76497
76954
  var ce = (s3) => {
76498
76955
  let t = "", e = Ks(s3);
76499
76956
  for (; kn(s3) || e.root; ) {
@@ -77202,11 +77659,11 @@ var Wn = (s3, t) => {
77202
77659
  };
77203
77660
  var hr = (s3, t) => {
77204
77661
  t.forEach((e) => {
77205
- e.charAt(0) === "@" ? Ct({ file: import_node_path13.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
77662
+ e.charAt(0) === "@" ? Ct({ file: import_node_path14.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
77206
77663
  }), s3.end();
77207
77664
  };
77208
77665
  var ar = async (s3, t) => {
77209
- for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path13.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
77666
+ for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path14.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
77210
77667
  s3.add(i);
77211
77668
  } }) : s3.add(e);
77212
77669
  s3.end();
@@ -77244,13 +77701,13 @@ var pi = (s3, t, e, i) => {
77244
77701
  });
77245
77702
  };
77246
77703
  var qn = (s3, t, e, i, r) => {
77247
- if (t.isDirectory()) us(import_node_path18.default.resolve(s3, t.name), e, i, (n) => {
77704
+ if (t.isDirectory()) us(import_node_path19.default.resolve(s3, t.name), e, i, (n) => {
77248
77705
  if (n) return r(n);
77249
- let o = import_node_path18.default.resolve(s3, t.name);
77706
+ let o = import_node_path19.default.resolve(s3, t.name);
77250
77707
  pi(o, e, i, r);
77251
77708
  });
77252
77709
  else {
77253
- let n = import_node_path18.default.resolve(s3, t.name);
77710
+ let n = import_node_path19.default.resolve(s3, t.name);
77254
77711
  pi(n, e, i, r);
77255
77712
  }
77256
77713
  };
@@ -77271,7 +77728,7 @@ var us = (s3, t, e, i) => {
77271
77728
  });
77272
77729
  };
77273
77730
  var Qn = (s3, t, e, i) => {
77274
- t.isDirectory() && ms(import_node_path18.default.resolve(s3, t.name), e, i), ds(import_node_path18.default.resolve(s3, t.name), e, i);
77731
+ t.isDirectory() && ms(import_node_path19.default.resolve(s3, t.name), e, i), ds(import_node_path19.default.resolve(s3, t.name), e, i);
77275
77732
  };
77276
77733
  var ms = (s3, t, e) => {
77277
77734
  let i;
@@ -77320,13 +77777,13 @@ var wr = (s3, t, e) => {
77320
77777
  E ? e(E) : x && a ? us(x, o, h, (Le) => S(Le)) : n ? import_node_fs13.default.chmod(s3, r, e) : e();
77321
77778
  };
77322
77779
  if (s3 === d) return jn(s3, S);
77323
- if (l) return import_promises5.default.mkdir(s3, { mode: r, recursive: true }).then((E) => S(null, E ?? void 0), S);
77324
- let N = f(import_node_path19.default.relative(d, s3)).split("/");
77780
+ if (l) return import_promises6.default.mkdir(s3, { mode: r, recursive: true }).then((E) => S(null, E ?? void 0), S);
77781
+ let N = f(import_node_path20.default.relative(d, s3)).split("/");
77325
77782
  ps(d, N, r, c, d, void 0, S);
77326
77783
  };
77327
77784
  var ps = (s3, t, e, i, r, n, o) => {
77328
77785
  if (t.length === 0) return o(null, n);
77329
- let h = t.shift(), a = f(import_node_path19.default.resolve(s3 + "/" + h));
77786
+ let h = t.shift(), a = f(import_node_path20.default.resolve(s3 + "/" + h));
77330
77787
  import_node_fs13.default.mkdir(a, e, Sr(a, t, e, i, r, n, o));
77331
77788
  };
77332
77789
  var Sr = (s3, t, e, i, r, n, o) => (h) => {
@@ -77360,9 +77817,9 @@ var yr = (s3, t) => {
77360
77817
  };
77361
77818
  if (s3 === c) return to(c), d();
77362
77819
  if (a) return d(import_node_fs13.default.mkdirSync(s3, { mode: i, recursive: true }) ?? void 0);
77363
- let T = f(import_node_path19.default.relative(c, s3)).split("/"), N;
77820
+ let T = f(import_node_path20.default.relative(c, s3)).split("/"), N;
77364
77821
  for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
77365
- x = f(import_node_path19.default.resolve(x));
77822
+ x = f(import_node_path20.default.resolve(x));
77366
77823
  try {
77367
77824
  import_node_fs13.default.mkdirSync(x, i), N = N || x;
77368
77825
  } catch {
@@ -77391,14 +77848,14 @@ var eo = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
77391
77848
  var io = eo === "win32";
77392
77849
  var so = (s3) => s3.split("/").slice(0, -1).reduce((e, i) => {
77393
77850
  let r = e.at(-1);
77394
- return r !== void 0 && (i = (0, import_node_path20.join)(r, i)), e.push(i || "/"), e;
77851
+ return r !== void 0 && (i = (0, import_node_path21.join)(r, i)), e.push(i || "/"), e;
77395
77852
  }, []);
77396
77853
  var Si = class {
77397
77854
  #t = /* @__PURE__ */ new Map();
77398
77855
  #i = /* @__PURE__ */ new Map();
77399
77856
  #s = /* @__PURE__ */ new Set();
77400
77857
  reserve(t, e) {
77401
- t = io ? ["win32 parallelization disabled"] : t.map((r) => mt((0, import_node_path20.join)(gr(r))));
77858
+ t = io ? ["win32 parallelization disabled"] : t.map((r) => mt((0, import_node_path21.join)(gr(r))));
77402
77859
  let i = new Set(t.map((r) => so(r)).reduce((r, n) => r.concat(n)));
77403
77860
  this.#i.set(e, { dirs: i, paths: t });
77404
77861
  for (let r of t) {
@@ -77538,7 +77995,7 @@ var qt = class extends st {
77538
77995
  if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
77539
77996
  this.uid = t.uid, this.gid = t.gid, this.setOwner = true;
77540
77997
  } else this.uid = void 0, this.gid = void 0, this.setOwner = false;
77541
- this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? !!(process.getuid && process.getuid() === 0) : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : oo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(import_node_path17.default.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : _r() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Or](e));
77998
+ this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? !!(process.getuid && process.getuid() === 0) : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : oo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(import_node_path18.default.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : _r() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Or](e));
77542
77999
  }
77543
78000
  warn(t, e, i = {}) {
77544
78001
  return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = false), super.warn(t, e, i);
@@ -77552,7 +78009,7 @@ var qt = class extends st {
77552
78009
  let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
77553
78010
  if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
77554
78011
  if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, { entry: t, [e]: i }), false;
77555
- let a = import_node_path17.default.posix.dirname(t.path), l = import_node_path17.default.posix.normalize(import_node_path17.default.posix.join(a, h.join("/")));
78012
+ let a = import_node_path18.default.posix.dirname(t.path), l = import_node_path18.default.posix.normalize(import_node_path18.default.posix.join(a, h.join("/")));
77556
78013
  if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, { entry: t, [e]: i }), false;
77557
78014
  }
77558
78015
  return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, { entry: t, [e]: i })), true;
@@ -77570,12 +78027,12 @@ var qt = class extends st {
77570
78027
  }
77571
78028
  if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: t, path: e, depth: i.length, maxDepth: this.maxDepth }), false;
77572
78029
  if (!this[ws](t, "path") || !this[ws](t, "linkpath")) return false;
77573
- if (t.absolute = import_node_path17.default.isAbsolute(t.path) ? f(import_node_path17.default.resolve(t.path)) : f(import_node_path17.default.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t, path: f(t.path), resolvedPath: t.absolute, cwd: this.cwd }), false;
78030
+ if (t.absolute = import_node_path18.default.isAbsolute(t.path) ? f(import_node_path18.default.resolve(t.path)) : f(import_node_path18.default.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t, path: f(t.path), resolvedPath: t.absolute, cwd: this.cwd }), false;
77574
78031
  if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return false;
77575
78032
  if (this.win32) {
77576
- let { root: r } = import_node_path17.default.win32.parse(String(t.absolute));
78033
+ let { root: r } = import_node_path18.default.win32.parse(String(t.absolute));
77577
78034
  t.absolute = r + Qi(String(t.absolute).slice(r.length));
77578
- let { root: n } = import_node_path17.default.win32.parse(t.path);
78035
+ let { root: n } = import_node_path18.default.win32.parse(t.path);
77579
78036
  t.path = n + Qi(t.path.slice(n.length));
77580
78037
  }
77581
78038
  return true;
@@ -77663,13 +78120,13 @@ var qt = class extends st {
77663
78120
  t.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
77664
78121
  }
77665
78122
  [xr](t, e) {
77666
- let i = f(import_node_path17.default.relative(this.cwd, import_node_path17.default.resolve(import_node_path17.default.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
78123
+ let i = f(import_node_path18.default.relative(this.cwd, import_node_path18.default.resolve(import_node_path18.default.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
77667
78124
  this[Re](t, this.cwd, i, () => this[Ri](t, String(t.linkpath), "symlink", e), (r) => {
77668
78125
  this[O](r, t), e();
77669
78126
  });
77670
78127
  }
77671
78128
  [Lr](t, e) {
77672
- let i = f(import_node_path17.default.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
78129
+ let i = f(import_node_path18.default.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
77673
78130
  this[Re](t, this.cwd, r, () => this[Ri](t, i, "link", e), (n) => {
77674
78131
  this[O](n, t), e();
77675
78132
  });
@@ -77677,10 +78134,10 @@ var qt = class extends st {
77677
78134
  [Re](t, e, i, r, n) {
77678
78135
  let o = i.shift();
77679
78136
  if (this.preservePaths || o === void 0) return r();
77680
- let h = import_node_path17.default.resolve(e, o);
78137
+ let h = import_node_path18.default.resolve(e, o);
77681
78138
  import_node_fs11.default.lstat(h, (a, l) => {
77682
78139
  if (a) return r();
77683
- if (l?.isSymbolicLink()) return n(new St(h, import_node_path17.default.resolve(h, i.join("/"))));
78140
+ if (l?.isSymbolicLink()) return n(new St(h, import_node_path18.default.resolve(h, i.join("/"))));
77684
78141
  this[Re](t, h, i, r, n);
77685
78142
  });
77686
78143
  }
@@ -77714,7 +78171,7 @@ var qt = class extends st {
77714
78171
  });
77715
78172
  }, n = () => {
77716
78173
  if (t.absolute !== this.cwd) {
77717
- let h = f(import_node_path17.default.dirname(String(t.absolute)));
78174
+ let h = f(import_node_path18.default.dirname(String(t.absolute)));
77718
78175
  if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
77719
78176
  if (a) {
77720
78177
  this[O](a, t), i();
@@ -77789,7 +78246,7 @@ var xe = class extends qt {
77789
78246
  this[Oe] = true;
77790
78247
  }
77791
78248
  if (t.absolute !== this.cwd) {
77792
- let n = f(import_node_path17.default.dirname(String(t.absolute)));
78249
+ let n = f(import_node_path18.default.dirname(String(t.absolute)));
77793
78250
  if (n !== this.cwd) {
77794
78251
  let o = this[yt](n, this.dmode);
77795
78252
  if (o) return this[O](o, t);
@@ -77889,10 +78346,10 @@ var xe = class extends qt {
77889
78346
  if (this.preservePaths || i.length === 0) return r();
77890
78347
  let o = e;
77891
78348
  for (let h of i) {
77892
- o = import_node_path17.default.resolve(o, h);
78349
+ o = import_node_path18.default.resolve(o, h);
77893
78350
  let [a, l] = ye(() => import_node_fs11.default.lstatSync(o));
77894
78351
  if (a) return r();
77895
- if (l.isSymbolicLink()) return n(new St(o, import_node_path17.default.resolve(e, i.join("/"))));
78352
+ if (l.isSymbolicLink()) return n(new St(o, import_node_path18.default.resolve(e, i.join("/"))));
77896
78353
  }
77897
78354
  r();
77898
78355
  }
@@ -77996,11 +78453,11 @@ var po = (s3, t) => {
77996
78453
  };
77997
78454
  var Eo = (s3, t) => {
77998
78455
  t.forEach((e) => {
77999
- e.charAt(0) === "@" ? Ct({ file: import_node_path21.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
78456
+ e.charAt(0) === "@" ? Ct({ file: import_node_path22.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
78000
78457
  }), s3.end();
78001
78458
  };
78002
78459
  var wo = async (s3, t) => {
78003
- for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path21.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
78460
+ for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path22.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
78004
78461
  s3.end();
78005
78462
  };
78006
78463
  var vt = K(uo, po, () => {
@@ -78077,7 +78534,7 @@ function isUtf8(raw) {
78077
78534
  }
78078
78535
  }
78079
78536
  function buildSeedFilePayload(filePath, rootDir) {
78080
- const relative3 = import_node_path22.default.relative(rootDir, filePath).split(import_node_path22.default.sep).join("/");
78537
+ const relative3 = import_node_path23.default.relative(rootDir, filePath).split(import_node_path23.default.sep).join("/");
78081
78538
  const raw = import_node_fs15.default.readFileSync(filePath);
78082
78539
  if (isUtf8(raw)) {
78083
78540
  return { path: `/${relative3}`, content: raw.toString("utf8"), encoding: "utf-8" };
@@ -78085,7 +78542,7 @@ function buildSeedFilePayload(filePath, rootDir) {
78085
78542
  return { path: `/${relative3}`, content: raw.toString("base64"), encoding: "base64" };
78086
78543
  }
78087
78544
  function collectSeedPaths(rootDir, currentRelative, excludeDirs, output) {
78088
- const absoluteDir = import_node_path22.default.join(rootDir, currentRelative);
78545
+ const absoluteDir = import_node_path23.default.join(rootDir, currentRelative);
78089
78546
  const entries = import_node_fs15.default.readdirSync(absoluteDir, { withFileTypes: true });
78090
78547
  for (const entry of entries) {
78091
78548
  if (excludeDirs.has(entry.name)) {
@@ -78095,7 +78552,7 @@ function collectSeedPaths(rootDir, currentRelative, excludeDirs, output) {
78095
78552
  continue;
78096
78553
  }
78097
78554
  const nextRelative = currentRelative ? `${currentRelative}/${entry.name}` : entry.name;
78098
- const absolutePath = import_node_path22.default.join(rootDir, nextRelative);
78555
+ const absolutePath = import_node_path23.default.join(rootDir, nextRelative);
78099
78556
  if (excludeDirs.has(nextRelative)) {
78100
78557
  continue;
78101
78558
  }
@@ -78110,15 +78567,15 @@ function collectSeedPaths(rootDir, currentRelative, excludeDirs, output) {
78110
78567
  if (entry.isSymbolicLink()) {
78111
78568
  try {
78112
78569
  const resolved = import_node_fs15.default.realpathSync(absolutePath);
78113
- if (!resolved.startsWith(rootDir + import_node_path22.default.sep) && resolved !== rootDir) {
78570
+ if (!resolved.startsWith(rootDir + import_node_path23.default.sep) && resolved !== rootDir) {
78114
78571
  continue;
78115
78572
  }
78116
- const stat2 = import_node_fs15.default.statSync(resolved);
78117
- if (stat2.isDirectory()) {
78573
+ const stat3 = import_node_fs15.default.statSync(resolved);
78574
+ if (stat3.isDirectory()) {
78118
78575
  collectSeedPaths(rootDir, nextRelative, excludeDirs, output);
78119
78576
  continue;
78120
78577
  }
78121
- if (stat2.isFile()) {
78578
+ if (stat3.isFile()) {
78122
78579
  output.push(absolutePath);
78123
78580
  }
78124
78581
  } catch {
@@ -78246,7 +78703,7 @@ async function seedAclRules(baseUrl, token, workspaceId, aclRules) {
78246
78703
  }
78247
78704
  async function seedWorkspace(baseUrl, token, workspaceId, projectDir, excludeDirs) {
78248
78705
  const workspace = normalizeWorkspaceId2(workspaceId);
78249
- const rootDir = import_node_path22.default.resolve(projectDir);
78706
+ const rootDir = import_node_path23.default.resolve(projectDir);
78250
78707
  const excludes = normalizeExcludeDirs([...DEFAULT_EXCLUDED_DIRS, ...excludeDirs]);
78251
78708
  const seedPaths = [];
78252
78709
  collectSeedPaths(rootDir, "", excludes, seedPaths);
@@ -78419,7 +78876,7 @@ function buildSummary(compilations) {
78419
78876
  function buildAgentResult(projectDir, name, token, compiled, mountPoint) {
78420
78877
  return {
78421
78878
  name,
78422
- tokenPath: import_node_path23.default.resolve(projectDir, ".relay", "tokens", `${name}.jwt`),
78879
+ tokenPath: import_node_path24.default.resolve(projectDir, ".relay", "tokens", `${name}.jwt`),
78423
78880
  token,
78424
78881
  scopes: [...compiled.scopes],
78425
78882
  compiled,
@@ -78478,7 +78935,7 @@ async function provisionWorkflowAgents(config2) {
78478
78935
  action: "mint",
78479
78936
  details: {
78480
78937
  workspace: config2.workspace,
78481
- jwtPath: import_node_path23.default.resolve(config2.projectDir, ".relay", "tokens", `${agent.name}.jwt`),
78938
+ jwtPath: import_node_path24.default.resolve(config2.projectDir, ".relay", "tokens", `${agent.name}.jwt`),
78482
78939
  scopeCount: compiled.scopes.length,
78483
78940
  scopes: [...compiled.scopes],
78484
78941
  ttlSeconds: config2.tokenTtlSeconds ?? null
@@ -78556,7 +79013,7 @@ async function provisionWorkflowAgents(config2) {
78556
79013
  });
78557
79014
  }
78558
79015
  if (!config2.skipMount) {
78559
- const mountRoot = import_node_path23.default.resolve(config2.mountBaseDir ?? import_node_path23.default.join(config2.projectDir, ".relay"));
79016
+ const mountRoot = import_node_path24.default.resolve(config2.mountBaseDir ?? import_node_path24.default.join(config2.projectDir, ".relay"));
78560
79017
  try {
78561
79018
  for (const agent of agents) {
78562
79019
  const token = tokens.get(agent.name);
@@ -78569,7 +79026,7 @@ async function provisionWorkflowAgents(config2) {
78569
79026
  relayfileUrl: config2.relayfileBaseUrl,
78570
79027
  workspace: config2.workspace,
78571
79028
  token,
78572
- mountPoint: import_node_path23.default.join(mountRoot, `workspace-${sanitizePathComponent(config2.workspace)}-${sanitizePathComponent(agent.name)}`)
79029
+ mountPoint: import_node_path24.default.join(mountRoot, `workspace-${sanitizePathComponent(config2.workspace)}-${sanitizePathComponent(agent.name)}`)
78573
79030
  });
78574
79031
  mounts.set(agent.name, mountHandle);
78575
79032
  agentResults[agent.name] = buildAgentResult(config2.projectDir, agent.name, token, compiled, mountHandle.mountPoint);
@@ -78624,13 +79081,13 @@ async function provisionWorkflowAgents(config2) {
78624
79081
 
78625
79082
  // packages/sdk/dist/workflows/collectors/claude.js
78626
79083
  var import_node_fs17 = require("node:fs");
78627
- var import_promises6 = require("node:fs/promises");
78628
- var import_node_os6 = require("node:os");
78629
- var import_node_path24 = __toESM(require("node:path"), 1);
79084
+ var import_promises7 = require("node:fs/promises");
79085
+ var import_node_os7 = require("node:os");
79086
+ var import_node_path25 = __toESM(require("node:path"), 1);
78630
79087
  var import_node_readline = require("node:readline");
78631
- var CLAUDE_HOME = import_node_path24.default.join((0, import_node_os6.homedir)(), ".claude");
78632
- var HISTORY_PATH = import_node_path24.default.join(CLAUDE_HOME, "history.jsonl");
78633
- var PROJECTS_PATH = import_node_path24.default.join(CLAUDE_HOME, "projects");
79088
+ var CLAUDE_HOME = import_node_path25.default.join((0, import_node_os7.homedir)(), ".claude");
79089
+ var HISTORY_PATH = import_node_path25.default.join(CLAUDE_HOME, "history.jsonl");
79090
+ var PROJECTS_PATH = import_node_path25.default.join(CLAUDE_HOME, "projects");
78634
79091
  var HISTORY_LOOKBACK_MS = 5e3;
78635
79092
  var ClaudeCodeCollector = class {
78636
79093
  canCollect() {
@@ -78641,7 +79098,7 @@ var ClaudeCodeCollector = class {
78641
79098
  if (!historyEntry) {
78642
79099
  return null;
78643
79100
  }
78644
- const sessionPath = import_node_path24.default.join(PROJECTS_PATH, encodeProjectPath(historyEntry.project), `${historyEntry.sessionId}.jsonl`);
79101
+ const sessionPath = import_node_path25.default.join(PROJECTS_PATH, encodeProjectPath(historyEntry.project), `${historyEntry.sessionId}.jsonl`);
78645
79102
  if (!await isReadableFileAsync(sessionPath)) {
78646
79103
  return null;
78647
79104
  }
@@ -78926,7 +79383,7 @@ function isReadableDirectory(dirPath) {
78926
79383
  }
78927
79384
  async function isReadableFileAsync(filePath) {
78928
79385
  try {
78929
- await (0, import_promises6.access)(filePath);
79386
+ await (0, import_promises7.access)(filePath);
78930
79387
  return true;
78931
79388
  } catch {
78932
79389
  return false;
@@ -78935,13 +79392,13 @@ async function isReadableFileAsync(filePath) {
78935
79392
 
78936
79393
  // packages/sdk/dist/workflows/collectors/codex.js
78937
79394
  var import_node_fs18 = __toESM(require("node:fs"), 1);
78938
- var import_node_os7 = __toESM(require("node:os"), 1);
78939
- var import_node_path25 = __toESM(require("node:path"), 1);
79395
+ var import_node_os8 = __toESM(require("node:os"), 1);
79396
+ var import_node_path26 = __toESM(require("node:path"), 1);
78940
79397
  var import_node_module2 = require("node:module");
78941
79398
  var require2 = (0, import_node_module2.createRequire)(import_meta_url);
78942
- var CODEX_HOME = import_node_path25.default.join(import_node_os7.default.homedir(), ".codex");
78943
- var DEFAULT_HISTORY_PATH = import_node_path25.default.join(CODEX_HOME, "history.jsonl");
78944
- var DEFAULT_STATE_PATH = import_node_path25.default.join(CODEX_HOME, "state_5.sqlite");
79399
+ var CODEX_HOME = import_node_path26.default.join(import_node_os8.default.homedir(), ".codex");
79400
+ var DEFAULT_HISTORY_PATH = import_node_path26.default.join(CODEX_HOME, "history.jsonl");
79401
+ var DEFAULT_STATE_PATH = import_node_path26.default.join(CODEX_HOME, "state_5.sqlite");
78945
79402
  function loadBetterSqlite3() {
78946
79403
  try {
78947
79404
  return require2("better-sqlite3");
@@ -79175,11 +79632,11 @@ var CodexCollector = class {
79175
79632
 
79176
79633
  // packages/sdk/dist/workflows/collectors/opencode.js
79177
79634
  var import_node_fs19 = __toESM(require("node:fs"), 1);
79178
- var import_node_os8 = __toESM(require("node:os"), 1);
79179
- var import_node_path26 = __toESM(require("node:path"), 1);
79635
+ var import_node_os9 = __toESM(require("node:os"), 1);
79636
+ var import_node_path27 = __toESM(require("node:path"), 1);
79180
79637
  var import_node_module3 = require("node:module");
79181
79638
  var require3 = (0, import_node_module3.createRequire)(import_meta_url);
79182
- var OPENCODE_DB_PATH = import_node_path26.default.join(import_node_os8.default.homedir(), ".local", "share", "opencode", "opencode.db");
79639
+ var OPENCODE_DB_PATH = import_node_path27.default.join(import_node_os9.default.homedir(), ".local", "share", "opencode", "opencode.db");
79183
79640
  var MATCH_WINDOW_GRACE_MS = 5e3;
79184
79641
  var ERROR_LINE_PATTERN = /^(Error|error:|Command failed|FAIL)\b/;
79185
79642
  function loadDatabaseConstructor() {
@@ -79920,7 +80377,7 @@ var import_node_child_process7 = require("node:child_process");
79920
80377
  // packages/sdk/dist/workflows/verification.js
79921
80378
  var import_node_child_process6 = require("node:child_process");
79922
80379
  var import_node_fs20 = require("node:fs");
79923
- var import_node_path27 = __toESM(require("node:path"), 1);
80380
+ var import_node_path28 = __toESM(require("node:path"), 1);
79924
80381
  var WorkflowCompletionError = class extends Error {
79925
80382
  completionReason;
79926
80383
  constructor(message, completionReason) {
@@ -80112,9 +80569,9 @@ function checkCustom(value, output, cwd = process.cwd()) {
80112
80569
  }
80113
80570
  }
80114
80571
  function checkFileExists(filePath, cwd = process.cwd()) {
80115
- const normalizedCwd = import_node_path27.default.resolve(cwd);
80116
- const resolved = import_node_path27.default.isAbsolute(filePath) ? import_node_path27.default.resolve(filePath) : import_node_path27.default.resolve(normalizedCwd, filePath);
80117
- if (!import_node_path27.default.isAbsolute(filePath) && !resolved.startsWith(normalizedCwd + import_node_path27.default.sep) && resolved !== normalizedCwd) {
80572
+ const normalizedCwd = import_node_path28.default.resolve(cwd);
80573
+ const resolved = import_node_path28.default.isAbsolute(filePath) ? import_node_path28.default.resolve(filePath) : import_node_path28.default.resolve(normalizedCwd, filePath);
80574
+ if (!import_node_path28.default.isAbsolute(filePath) && !resolved.startsWith(normalizedCwd + import_node_path28.default.sep) && resolved !== normalizedCwd) {
80118
80575
  return false;
80119
80576
  }
80120
80577
  return (0, import_node_fs20.existsSync)(resolved);
@@ -80947,14 +81404,14 @@ function delay(ms2) {
80947
81404
  }
80948
81405
 
80949
81406
  // packages/sdk/dist/workflows/trajectory.js
80950
- var import_node_path28 = require("node:path");
81407
+ var import_node_path29 = require("node:path");
80951
81408
 
80952
81409
  // node_modules/agent-trajectories/dist/chunk-WMJRBQB4.js
80953
81410
  var import_module = require("module");
80954
81411
  var import_crypto = require("crypto");
80955
81412
  var import_crypto2 = require("crypto");
80956
81413
  var import_fs5 = require("fs");
80957
- var import_promises7 = require("fs/promises");
81414
+ var import_promises8 = require("fs/promises");
80958
81415
  var import_path4 = require("path");
80959
81416
  var ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
80960
81417
  var ID_LENGTH = 12;
@@ -81551,9 +82008,9 @@ var FileStorage = class {
81551
82008
  * Initialize storage directories
81552
82009
  */
81553
82010
  async initialize() {
81554
- await (0, import_promises7.mkdir)(this.trajectoriesDir, { recursive: true });
81555
- await (0, import_promises7.mkdir)(this.activeDir, { recursive: true });
81556
- await (0, import_promises7.mkdir)(this.completedDir, { recursive: true });
82011
+ await (0, import_promises8.mkdir)(this.trajectoriesDir, { recursive: true });
82012
+ await (0, import_promises8.mkdir)(this.activeDir, { recursive: true });
82013
+ await (0, import_promises8.mkdir)(this.completedDir, { recursive: true });
81557
82014
  if (!(0, import_fs5.existsSync)(this.indexPath)) {
81558
82015
  await withIndexLock(this.indexPath, async () => {
81559
82016
  if (!(0, import_fs5.existsSync)(this.indexPath)) {
@@ -81592,7 +82049,7 @@ var FileStorage = class {
81592
82049
  const before = Object.keys(index.trajectories).length;
81593
82050
  const discovered = [];
81594
82051
  try {
81595
- const activeFiles = await (0, import_promises7.readdir)(this.activeDir);
82052
+ const activeFiles = await (0, import_promises8.readdir)(this.activeDir);
81596
82053
  for (const file2 of activeFiles) {
81597
82054
  if (!file2.endsWith(".json")) continue;
81598
82055
  discovered.push((0, import_path4.join)(this.activeDir, file2));
@@ -81678,13 +82135,13 @@ var FileStorage = class {
81678
82135
  if (candidates.length === 0) {
81679
82136
  return { moved: [], targetDir };
81680
82137
  }
81681
- await (0, import_promises7.mkdir)(targetDir, { recursive: true });
82138
+ await (0, import_promises8.mkdir)(targetDir, { recursive: true });
81682
82139
  const moved = [];
81683
82140
  for (const failure of candidates) {
81684
82141
  const dest = await this.resolveQuarantineDest(failure.path, targetDir);
81685
82142
  try {
81686
- await (0, import_promises7.mkdir)((0, import_path4.dirname)(dest), { recursive: true });
81687
- await (0, import_promises7.rename)(failure.path, dest);
82143
+ await (0, import_promises8.mkdir)((0, import_path4.dirname)(dest), { recursive: true });
82144
+ await (0, import_promises8.rename)(failure.path, dest);
81688
82145
  moved.push(failure);
81689
82146
  } catch (error51) {
81690
82147
  console.warn(
@@ -81726,7 +82183,7 @@ var FileStorage = class {
81726
82183
  async walkJsonFilesInto(dir, out) {
81727
82184
  let entries;
81728
82185
  try {
81729
- entries = await (0, import_promises7.readdir)(dir, { withFileTypes: true });
82186
+ entries = await (0, import_promises8.readdir)(dir, { withFileTypes: true });
81730
82187
  } catch (error51) {
81731
82188
  if (error51.code === "ENOENT") return;
81732
82189
  throw error51;
@@ -81766,19 +82223,19 @@ var FileStorage = class {
81766
82223
  this.completedDir,
81767
82224
  `${date5.getFullYear()}-${String(date5.getMonth() + 1).padStart(2, "0")}`
81768
82225
  );
81769
- await (0, import_promises7.mkdir)(monthDir, { recursive: true });
82226
+ await (0, import_promises8.mkdir)(monthDir, { recursive: true });
81770
82227
  filePath = (0, import_path4.join)(monthDir, `${trajectory2.id}.json`);
81771
82228
  const activePath = (0, import_path4.join)(this.activeDir, `${trajectory2.id}.json`);
81772
82229
  if ((0, import_fs5.existsSync)(activePath)) {
81773
- await (0, import_promises7.unlink)(activePath);
82230
+ await (0, import_promises8.unlink)(activePath);
81774
82231
  }
81775
82232
  const mdPath = (0, import_path4.join)(monthDir, `${trajectory2.id}.md`);
81776
82233
  const markdown = exportToMarkdown(trajectory2);
81777
- await (0, import_promises7.writeFile)(mdPath, markdown, "utf-8");
82234
+ await (0, import_promises8.writeFile)(mdPath, markdown, "utf-8");
81778
82235
  } else {
81779
82236
  filePath = (0, import_path4.join)(this.activeDir, `${trajectory2.id}.json`);
81780
82237
  }
81781
- await (0, import_promises7.writeFile)(filePath, JSON.stringify(trajectory2, null, 2), "utf-8");
82238
+ await (0, import_promises8.writeFile)(filePath, JSON.stringify(trajectory2, null, 2), "utf-8");
81782
82239
  await this.updateIndex(trajectory2, filePath);
81783
82240
  }
81784
82241
  /**
@@ -81799,7 +82256,7 @@ var FileStorage = class {
81799
82256
  if ((0, import_fs5.existsSync)(flatPath)) {
81800
82257
  return this.readTrajectoryOrNull(flatPath);
81801
82258
  }
81802
- const months = await (0, import_promises7.readdir)(this.completedDir);
82259
+ const months = await (0, import_promises8.readdir)(this.completedDir);
81803
82260
  for (const month of months) {
81804
82261
  const filePath = (0, import_path4.join)(this.completedDir, month, `${id}.json`);
81805
82262
  if ((0, import_fs5.existsSync)(filePath)) {
@@ -81818,7 +82275,7 @@ var FileStorage = class {
81818
82275
  */
81819
82276
  async getActive() {
81820
82277
  try {
81821
- const files = await (0, import_promises7.readdir)(this.activeDir);
82278
+ const files = await (0, import_promises8.readdir)(this.activeDir);
81822
82279
  const jsonFiles = files.filter((f2) => f2.endsWith(".json"));
81823
82280
  if (jsonFiles.length === 0) {
81824
82281
  return null;
@@ -81903,16 +82360,16 @@ var FileStorage = class {
81903
82360
  async delete(id) {
81904
82361
  const activePath = (0, import_path4.join)(this.activeDir, `${id}.json`);
81905
82362
  if ((0, import_fs5.existsSync)(activePath)) {
81906
- await (0, import_promises7.unlink)(activePath);
82363
+ await (0, import_promises8.unlink)(activePath);
81907
82364
  }
81908
82365
  await withIndexLock(this.indexPath, async () => {
81909
82366
  const index = await this.loadIndex();
81910
82367
  const entry = index.trajectories[id];
81911
82368
  if (entry?.path && (0, import_fs5.existsSync)(entry.path)) {
81912
- await (0, import_promises7.unlink)(entry.path);
82369
+ await (0, import_promises8.unlink)(entry.path);
81913
82370
  const mdPath = entry.path.replace(".json", ".md");
81914
82371
  if ((0, import_fs5.existsSync)(mdPath)) {
81915
- await (0, import_promises7.unlink)(mdPath);
82372
+ await (0, import_promises8.unlink)(mdPath);
81916
82373
  }
81917
82374
  }
81918
82375
  delete index.trajectories[id];
@@ -81965,7 +82422,7 @@ var FileStorage = class {
81965
82422
  async readTrajectoryFile(path28) {
81966
82423
  let content;
81967
82424
  try {
81968
- content = await (0, import_promises7.readFile)(path28, "utf-8");
82425
+ content = await (0, import_promises8.readFile)(path28, "utf-8");
81969
82426
  } catch (error51) {
81970
82427
  return { ok: false, reason: "io_error", path: path28, error: error51 };
81971
82428
  }
@@ -82011,7 +82468,7 @@ var FileStorage = class {
82011
82468
  async loadIndex() {
82012
82469
  let content;
82013
82470
  try {
82014
- content = await (0, import_promises7.readFile)(this.indexPath, "utf-8");
82471
+ content = await (0, import_promises8.readFile)(this.indexPath, "utf-8");
82015
82472
  } catch (error51) {
82016
82473
  if (error51.code !== "ENOENT") {
82017
82474
  console.error(
@@ -82054,8 +82511,8 @@ var FileStorage = class {
82054
82511
  async saveIndex(index) {
82055
82512
  index.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
82056
82513
  const tmpPath = `${this.indexPath}.${process.pid}.${(0, import_crypto2.randomUUID)()}.tmp`;
82057
- await (0, import_promises7.writeFile)(tmpPath, JSON.stringify(index, null, 2), "utf-8");
82058
- await (0, import_promises7.rename)(tmpPath, this.indexPath);
82514
+ await (0, import_promises8.writeFile)(tmpPath, JSON.stringify(index, null, 2), "utf-8");
82515
+ await (0, import_promises8.rename)(tmpPath, this.indexPath);
82059
82516
  }
82060
82517
  async updateIndex(trajectory2, filePath) {
82061
82518
  await withIndexLock(this.indexPath, async () => {
@@ -82179,8 +82636,8 @@ var WorkflowTrajectory = class {
82179
82636
  this.reflectOnConverge = cfg.reflectOnConverge !== false;
82180
82637
  this.autoDecisions = cfg.autoDecisions !== false;
82181
82638
  this.runId = runId;
82182
- const dataDir = process.env.TRAJECTORIES_DATA_DIR ?? (0, import_node_path28.join)(cwd, ".trajectories");
82183
- this.storageBaseDir = process.env.TRAJECTORIES_DATA_DIR ? (0, import_node_path28.dirname)(dataDir) : cwd;
82639
+ const dataDir = process.env.TRAJECTORIES_DATA_DIR ?? (0, import_node_path29.join)(cwd, ".trajectories");
82640
+ this.storageBaseDir = process.env.TRAJECTORIES_DATA_DIR ? (0, import_node_path29.dirname)(dataDir) : cwd;
82184
82641
  }
82185
82642
  async start(workflowName, stepCount, trackInfo, description, pattern) {
82186
82643
  if (!this.enabled)
@@ -82639,8 +83096,8 @@ var WorkflowRunner = class _WorkflowRunner {
82639
83096
  this.workspaceId = options.workspaceId ?? "local";
82640
83097
  this.relayOptions = options.relay ?? {};
82641
83098
  this.cwd = options.cwd ?? process.cwd();
82642
- this.summaryDir = options.summaryDir ?? import_node_path29.default.join(this.cwd, ".relay", "summaries");
82643
- this.workersPath = import_node_path29.default.join(this.cwd, ".agent-relay", "team", "workers.json");
83099
+ this.summaryDir = options.summaryDir ?? import_node_path30.default.join(this.cwd, ".relay", "summaries");
83100
+ this.workersPath = import_node_path30.default.join(this.cwd, ".agent-relay", "team", "workers.json");
82644
83101
  this.executor = options.executor;
82645
83102
  this.processBackend = options.processBackend;
82646
83103
  this.envSecrets = options.envSecrets;
@@ -82678,7 +83135,7 @@ var WorkflowRunner = class _WorkflowRunner {
82678
83135
  }
82679
83136
  seenNames.add(pd.name);
82680
83137
  const expanded = _WorkflowRunner.resolveEnvVars(pd.path);
82681
- const abs = import_node_path29.default.resolve(baseCwd, expanded);
83138
+ const abs = import_node_path30.default.resolve(baseCwd, expanded);
82682
83139
  resolved.set(pd.name, abs);
82683
83140
  const isRequired = pd.required !== false;
82684
83141
  if (!(0, import_node_fs21.existsSync)(abs)) {
@@ -83010,7 +83467,7 @@ var WorkflowRunner = class _WorkflowRunner {
83010
83467
  return resolved;
83011
83468
  }
83012
83469
  if (agent.cwd) {
83013
- return import_node_path29.default.resolve(this.cwd, agent.cwd);
83470
+ return import_node_path30.default.resolve(this.cwd, agent.cwd);
83014
83471
  }
83015
83472
  return this.cwd;
83016
83473
  }
@@ -83029,7 +83486,7 @@ var WorkflowRunner = class _WorkflowRunner {
83029
83486
  }
83030
83487
  resolveEffectiveCwd(step, agentDef) {
83031
83488
  if (step.cwd) {
83032
- return import_node_path29.default.resolve(this.cwd, step.cwd);
83489
+ return import_node_path30.default.resolve(this.cwd, step.cwd);
83033
83490
  }
83034
83491
  return this.resolveStepWorkdir(step) ?? (agentDef ? this.resolveAgentCwd(agentDef) : this.cwd);
83035
83492
  }
@@ -83038,14 +83495,14 @@ var WorkflowRunner = class _WorkflowRunner {
83038
83495
  if (!mount) {
83039
83496
  return cwd;
83040
83497
  }
83041
- const relative3 = import_node_path29.default.relative(this.cwd, cwd);
83498
+ const relative3 = import_node_path30.default.relative(this.cwd, cwd);
83042
83499
  if (relative3 === "") {
83043
83500
  return mount.mountPoint;
83044
83501
  }
83045
- if (relative3 === ".." || relative3.startsWith(`..${import_node_path29.default.sep}`)) {
83502
+ if (relative3 === ".." || relative3.startsWith(`..${import_node_path30.default.sep}`)) {
83046
83503
  return cwd;
83047
83504
  }
83048
- return import_node_path29.default.resolve(mount.mountPoint, relative3);
83505
+ return import_node_path30.default.resolve(mount.mountPoint, relative3);
83049
83506
  }
83050
83507
  resolveExecutionCwd(step, agentDef) {
83051
83508
  const cwd = this.resolveEffectiveCwd(step, agentDef);
@@ -83350,7 +83807,7 @@ ${next}` : next;
83350
83807
  }
83351
83808
  uniqueEvidenceRoots(roots) {
83352
83809
  return [
83353
- ...new Set(roots.filter((root) => Boolean(root)).map((root) => import_node_path29.default.resolve(root)))
83810
+ ...new Set(roots.filter((root) => Boolean(root)).map((root) => import_node_path30.default.resolve(root)))
83354
83811
  ];
83355
83812
  }
83356
83813
  captureFileSnapshot(root) {
@@ -83368,7 +83825,7 @@ ${next}` : next;
83368
83825
  if (entry.isDirectory() && _WorkflowRunner.EVIDENCE_IGNORED_DIRS.has(entry.name)) {
83369
83826
  continue;
83370
83827
  }
83371
- const fullPath = import_node_path29.default.join(currentPath, entry.name);
83828
+ const fullPath = import_node_path30.default.join(currentPath, entry.name);
83372
83829
  if (entry.isDirectory()) {
83373
83830
  visit(fullPath);
83374
83831
  continue;
@@ -83420,9 +83877,9 @@ ${next}` : next;
83420
83877
  return changes.sort((a, b2) => a.path.localeCompare(b2.path));
83421
83878
  }
83422
83879
  normalizeEvidencePath(filePath) {
83423
- const relative3 = import_node_path29.default.relative(this.cwd, filePath);
83880
+ const relative3 = import_node_path30.default.relative(this.cwd, filePath);
83424
83881
  if (!relative3 || relative3 === "")
83425
- return import_node_path29.default.basename(filePath);
83882
+ return import_node_path30.default.basename(filePath);
83426
83883
  return relative3.startsWith("..") ? filePath : relative3;
83427
83884
  }
83428
83885
  buildStepCompletionDecision(stepName, completionReason) {
@@ -83808,8 +84265,8 @@ ${next}` : next;
83808
84265
  // ── Parsing & validation ────────────────────────────────────────────────
83809
84266
  /** Parse a relay.yaml file from disk. */
83810
84267
  async parseYamlFile(filePath) {
83811
- const absPath = import_node_path29.default.resolve(this.cwd, filePath);
83812
- const raw = await (0, import_promises8.readFile)(absPath, "utf-8");
84268
+ const absPath = import_node_path30.default.resolve(this.cwd, filePath);
84269
+ const raw = await (0, import_promises9.readFile)(absPath, "utf-8");
83813
84270
  return this.parseYamlString(raw, absPath);
83814
84271
  }
83815
84272
  /** Parse a relay.yaml string. */
@@ -84008,14 +84465,14 @@ ${err.suggestion}`);
84008
84465
  }
84009
84466
  for (const agent of resolved.agents) {
84010
84467
  if (agent.cwd) {
84011
- const resolvedCwd = import_node_path29.default.resolve(this.cwd, agent.cwd);
84468
+ const resolvedCwd = import_node_path30.default.resolve(this.cwd, agent.cwd);
84012
84469
  if (!(0, import_node_fs21.existsSync)(resolvedCwd)) {
84013
84470
  warnings.push(`Agent "${agent.name}" cwd "${agent.cwd}" resolves to "${resolvedCwd}" which does not exist`);
84014
84471
  }
84015
84472
  }
84016
84473
  if (agent.additionalPaths) {
84017
84474
  for (const ap of agent.additionalPaths) {
84018
- const resolvedPath = import_node_path29.default.resolve(this.cwd, ap);
84475
+ const resolvedPath = import_node_path30.default.resolve(this.cwd, ap);
84019
84476
  if (!(0, import_node_fs21.existsSync)(resolvedPath)) {
84020
84477
  warnings.push(`Agent "${agent.name}" additionalPath "${ap}" resolves to "${resolvedPath}" which does not exist`);
84021
84478
  }
@@ -84590,7 +85047,7 @@ ${err.suggestion}`);
84590
85047
  }
84591
85048
  }
84592
85049
  this.log("Starting broker...");
84593
- const brokerBaseName = import_node_path29.default.basename(this.cwd) || "workflow";
85050
+ const brokerBaseName = import_node_path30.default.basename(this.cwd) || "workflow";
84594
85051
  const brokerName = `${brokerBaseName}-${runId.slice(0, 8)}`;
84595
85052
  this.relay = new AgentRelay({
84596
85053
  ...this.relayOptions,
@@ -84612,7 +85069,7 @@ ${err.suggestion}`);
84612
85069
  if (/Read\(/.test(stripped)) {
84613
85070
  const m2 = stripped.match(/Read\(\s*~?([^\s)"']{8,})/);
84614
85071
  if (m2) {
84615
- const base = import_node_path29.default.basename(m2[1]);
85072
+ const base = import_node_path30.default.basename(m2[1]);
84616
85073
  activity = base.length >= 3 ? `Reading ${base}` : "Reading file...";
84617
85074
  } else {
84618
85075
  activity = "Reading file...";
@@ -84620,7 +85077,7 @@ ${err.suggestion}`);
84620
85077
  } else if (/Edit\(/.test(stripped)) {
84621
85078
  const m2 = stripped.match(/Edit\(\s*~?([^\s)"']{8,})/);
84622
85079
  if (m2) {
84623
- const base = import_node_path29.default.basename(m2[1]);
85080
+ const base = import_node_path30.default.basename(m2[1]);
84624
85081
  activity = base.length >= 3 ? `Editing ${base}` : "Editing file...";
84625
85082
  } else {
84626
85083
  activity = "Editing file...";
@@ -85461,14 +85918,14 @@ Repair only what is needed for this step to produce the required artifact or evi
85461
85918
  const stepOutputContext = this.buildStepOutputContext(stepStates, runId);
85462
85919
  const branch = this.interpolateStepTask(step.branch ?? "", stepOutputContext);
85463
85920
  const baseBranch = step.baseBranch ? this.interpolateStepTask(step.baseBranch, stepOutputContext) : "HEAD";
85464
- const worktreePath = step.path ? this.interpolateStepTask(step.path, stepOutputContext) : import_node_path29.default.join(".worktrees", step.name);
85921
+ const worktreePath = step.path ? this.interpolateStepTask(step.path, stepOutputContext) : import_node_path30.default.join(".worktrees", step.name);
85465
85922
  const createBranch2 = step.createBranch !== false;
85466
85923
  const stepCwd = this.resolveStepWorkdir(step) ?? this.cwd;
85467
85924
  this.beginStepEvidence(step.name, [stepCwd], state.row.startedAt);
85468
85925
  if (!branch) {
85469
85926
  throw new Error('Worktree step missing required "branch" field');
85470
85927
  }
85471
- const absoluteWorktreePath = import_node_path29.default.resolve(stepCwd, worktreePath);
85928
+ const absoluteWorktreePath = import_node_path30.default.resolve(stepCwd, worktreePath);
85472
85929
  let branchExists = false;
85473
85930
  await new Promise((resolve4) => {
85474
85931
  const checkChild = (0, import_node_child_process8.spawn)("git", ["rev-parse", "--verify", "--quiet", branch], {
@@ -86551,8 +87008,8 @@ WORKER COMPLETION CONTRACT:
86551
87008
  promptTaskText: taskText
86552
87009
  };
86553
87010
  }
86554
- const taskTmpDir = (0, import_node_fs21.mkdtempSync)(import_node_path29.default.join((0, import_node_os9.tmpdir)(), "relay-pty-task-"));
86555
- const taskTmpFile = import_node_path29.default.join(taskTmpDir, `${agentName}-${Date.now()}.txt`);
87011
+ const taskTmpDir = (0, import_node_fs21.mkdtempSync)(import_node_path30.default.join((0, import_node_os10.tmpdir)(), "relay-pty-task-"));
87012
+ const taskTmpFile = import_node_path30.default.join(taskTmpDir, `${agentName}-${Date.now()}.txt`);
86556
87013
  (0, import_node_fs21.writeFileSync)(taskTmpFile, taskText, { encoding: "utf8", mode: 384, flag: "wx" });
86557
87014
  const promptTaskText = `TASK_FILE:${taskTmpFile}
86558
87015
  Read that file completely before taking any action.
@@ -86958,7 +87415,7 @@ DO NOT:
86958
87415
  - Output only status messages without the actual deliverable content`;
86959
87416
  const { cmd, args } = _WorkflowRunner.buildNonInteractiveCommand(agentDef.cli, taskWithDeliverable, modelArgs);
86960
87417
  const logsDir = this.getWorkerLogsDir();
86961
- const logPath = import_node_path29.default.join(logsDir, `${agentName}.log`);
87418
+ const logPath = import_node_path30.default.join(logsDir, `${agentName}.log`);
86962
87419
  const logStream = (0, import_node_fs21.createWriteStream)(logPath, { flags: "a" });
86963
87420
  this.registerWorker(agentName, agentDef.cli, step.task ?? "", void 0, false);
86964
87421
  let stopHeartbeat;
@@ -87126,7 +87583,7 @@ DO NOT:
87126
87583
  const preparedTask = this.prepareInteractiveSpawnTask(agentName, taskWithExit);
87127
87584
  this.ptyOutputBuffers.set(agentName, []);
87128
87585
  const logsDir = this.getWorkerLogsDir();
87129
- const logStream = (0, import_node_fs21.createWriteStream)(import_node_path29.default.join(logsDir, `${agentName}.log`), { flags: "a" });
87586
+ const logStream = (0, import_node_fs21.createWriteStream)(import_node_path30.default.join(logsDir, `${agentName}.log`), { flags: "a" });
87130
87587
  this.ptyLogStreams.set(agentName, logStream);
87131
87588
  this.ptyListeners.set(agentName, (chunk) => {
87132
87589
  const stripped = _WorkflowRunner.stripAnsi(chunk);
@@ -87176,8 +87633,8 @@ DO NOT:
87176
87633
  const oldName = agentName;
87177
87634
  this.ptyOutputBuffers.set(agent.name, this.ptyOutputBuffers.get(oldName) ?? []);
87178
87635
  this.ptyOutputBuffers.delete(oldName);
87179
- const oldLogPath = import_node_path29.default.join(logsDir, `${oldName}.log`);
87180
- const newLogPath = import_node_path29.default.join(logsDir, `${agent.name}.log`);
87636
+ const oldLogPath = import_node_path30.default.join(logsDir, `${oldName}.log`);
87637
+ const newLogPath = import_node_path30.default.join(logsDir, `${agent.name}.log`);
87181
87638
  const oldLogStream = this.ptyLogStreams.get(oldName);
87182
87639
  if (oldLogStream) {
87183
87640
  oldLogStream.end();
@@ -87287,15 +87744,15 @@ DO NOT:
87287
87744
  this.supervisedRuntimeAgents.delete(agentName);
87288
87745
  this.runtimeStepAgents.delete(agentName);
87289
87746
  if (preparedTask.taskTmpFile) {
87290
- await (0, import_promises8.unlink)(preparedTask.taskTmpFile).catch(() => void 0);
87747
+ await (0, import_promises9.unlink)(preparedTask.taskTmpFile).catch(() => void 0);
87291
87748
  }
87292
87749
  }
87293
87750
  let output;
87294
87751
  if (ptyChunks.length > 0) {
87295
87752
  output = ptyChunks.join("");
87296
87753
  } else {
87297
- const summaryPath = import_node_path29.default.join(this.summaryDir, `${step.name}.md`);
87298
- output = (0, import_node_fs21.existsSync)(summaryPath) ? await (0, import_promises8.readFile)(summaryPath, "utf-8") : exitResult === "timeout" ? "Agent completed (released after idle timeout)" : exitResult === "released" ? "Agent completed (idle \u2014 treated as done)" : `Agent exited (${exitResult})`;
87754
+ const summaryPath = import_node_path30.default.join(this.summaryDir, `${step.name}.md`);
87755
+ output = (0, import_node_fs21.existsSync)(summaryPath) ? await (0, import_promises9.readFile)(summaryPath, "utf-8") : exitResult === "timeout" ? "Agent completed (released after idle timeout)" : exitResult === "released" ? "Agent completed (idle \u2014 treated as done)" : `Agent exited (${exitResult})`;
87299
87756
  }
87300
87757
  if (ptyChunks.length === 0) {
87301
87758
  this.captureStepTerminalEvidence(evidenceStepName, { stdout: output, combined: output }, { exitCode: agent?.exitCode, exitSignal: agent?.exitSignal }, {
@@ -87747,7 +88204,7 @@ DO NOT:
87747
88204
  }
87748
88205
  }
87749
88206
  const outputDir = this.getStepOutputDir(runId);
87750
- const logsDir = import_node_path29.default.join(this.cwd, ".agent-relay", "team", "worker-logs");
88207
+ const logsDir = import_node_path30.default.join(this.cwd, ".agent-relay", "team", "worker-logs");
87751
88208
  console.log("");
87752
88209
  console.log(` Run ID: ${runId}`);
87753
88210
  console.log(` Step output: ${outputDir}`);
@@ -87833,7 +88290,7 @@ ${excerpt}` : "";
87833
88290
  if (!target)
87834
88291
  return;
87835
88292
  try {
87836
- (0, import_node_fs21.mkdirSync)(import_node_path29.default.dirname(target), { recursive: true });
88293
+ (0, import_node_fs21.mkdirSync)(import_node_path30.default.dirname(target), { recursive: true });
87837
88294
  (0, import_node_fs21.writeFileSync)(target, runId + "\n", "utf8");
87838
88295
  } catch {
87839
88296
  }
@@ -87870,16 +88327,16 @@ ${excerpt}` : "";
87870
88327
  /** Directory for persisted step outputs: .agent-relay/step-outputs/{runId}/ */
87871
88328
  getStepOutputDir(runId) {
87872
88329
  this.validateRunId(runId);
87873
- return import_node_path29.default.join(this.cwd, ".agent-relay", "step-outputs", runId);
88330
+ return import_node_path30.default.join(this.cwd, ".agent-relay", "step-outputs", runId);
87874
88331
  }
87875
88332
  /** Persist step output to disk and post full output as a channel message. */
87876
88333
  async persistStepOutput(runId, stepName, output) {
87877
- const outputPath = import_node_path29.default.join(this.getStepOutputDir(runId), `${stepName}.md`);
88334
+ const outputPath = import_node_path30.default.join(this.getStepOutputDir(runId), `${stepName}.md`);
87878
88335
  try {
87879
88336
  const dir = this.getStepOutputDir(runId);
87880
88337
  (0, import_node_fs21.mkdirSync)(dir, { recursive: true });
87881
88338
  const cleaned = _WorkflowRunner.stripAnsi(output);
87882
- await (0, import_promises8.writeFile)(outputPath, cleaned);
88339
+ await (0, import_promises9.writeFile)(outputPath, cleaned);
87883
88340
  } catch {
87884
88341
  }
87885
88342
  this.recordStepToolSideEffect(stepName, {
@@ -87904,32 +88361,32 @@ ${preview}
87904
88361
  \`\`\``, { stepName });
87905
88362
  }
87906
88363
  async persistAgentReport(runId, stepName, report) {
87907
- const reportPath = import_node_path29.default.join(this.getStepOutputDir(runId), `${stepName}.report.json`);
88364
+ const reportPath = import_node_path30.default.join(this.getStepOutputDir(runId), `${stepName}.report.json`);
87908
88365
  try {
87909
88366
  (0, import_node_fs21.mkdirSync)(this.getStepOutputDir(runId), { recursive: true });
87910
- await (0, import_promises8.writeFile)(reportPath, JSON.stringify(report, null, 2), "utf8");
88367
+ await (0, import_promises9.writeFile)(reportPath, JSON.stringify(report, null, 2), "utf8");
87911
88368
  } catch {
87912
88369
  }
87913
88370
  }
87914
88371
  /** Scan .agent-relay/step-outputs/ for the most recent run directory containing the needed steps. */
87915
88372
  findMostRecentRunWithSteps(stepNames) {
87916
88373
  try {
87917
- const baseDir = import_node_path29.default.join(this.cwd, ".agent-relay", "step-outputs");
88374
+ const baseDir = import_node_path30.default.join(this.cwd, ".agent-relay", "step-outputs");
87918
88375
  if (!(0, import_node_fs21.existsSync)(baseDir))
87919
88376
  return void 0;
87920
88377
  const entries = (0, import_node_fs21.readdirSync)(baseDir);
87921
88378
  let best;
87922
88379
  for (const entry of entries) {
87923
- const dirPath = import_node_path29.default.join(baseDir, entry);
88380
+ const dirPath = import_node_path30.default.join(baseDir, entry);
87924
88381
  try {
87925
- const stat2 = (0, import_node_fs21.statSync)(dirPath);
87926
- if (!stat2.isDirectory())
88382
+ const stat3 = (0, import_node_fs21.statSync)(dirPath);
88383
+ if (!stat3.isDirectory())
87927
88384
  continue;
87928
- const hasAny = [...stepNames].some((name) => (0, import_node_fs21.existsSync)(import_node_path29.default.join(dirPath, `${name}.md`)));
88385
+ const hasAny = [...stepNames].some((name) => (0, import_node_fs21.existsSync)(import_node_path30.default.join(dirPath, `${name}.md`)));
87929
88386
  if (!hasAny)
87930
88387
  continue;
87931
- if (!best || stat2.mtimeMs > best.mtime) {
87932
- best = { name: entry, mtime: stat2.mtimeMs };
88388
+ if (!best || stat3.mtimeMs > best.mtime) {
88389
+ best = { name: entry, mtime: stat3.mtimeMs };
87933
88390
  }
87934
88391
  } catch {
87935
88392
  continue;
@@ -87943,7 +88400,7 @@ ${preview}
87943
88400
  /** Load persisted step output from disk. */
87944
88401
  loadStepOutput(runId, stepName) {
87945
88402
  try {
87946
- const filePath = import_node_path29.default.join(this.getStepOutputDir(runId), `${stepName}.md`);
88403
+ const filePath = import_node_path30.default.join(this.getStepOutputDir(runId), `${stepName}.md`);
87947
88404
  if (!(0, import_node_fs21.existsSync)(filePath))
87948
88405
  return void 0;
87949
88406
  return (0, import_node_fs21.readFileSync)(filePath, "utf-8");
@@ -87972,7 +88429,7 @@ ${preview}
87972
88429
  return null;
87973
88430
  let resumeConfig = config2 ?? this.currentConfig;
87974
88431
  if (!resumeConfig) {
87975
- const yamlPath = import_node_path29.default.join(this.cwd, "relay.yaml");
88432
+ const yamlPath = import_node_path30.default.join(this.cwd, "relay.yaml");
87976
88433
  if ((0, import_node_fs21.existsSync)(yamlPath)) {
87977
88434
  try {
87978
88435
  const raw = (0, import_node_fs21.readFileSync)(yamlPath, "utf-8");
@@ -88001,8 +88458,8 @@ ${preview}
88001
88458
  let earliestMtime = Date.now();
88002
88459
  for (const stepName of cachedStepNames) {
88003
88460
  try {
88004
- const mdPath = import_node_path29.default.join(stepOutputDir, `${stepName}.md`);
88005
- const reportPath = import_node_path29.default.join(stepOutputDir, `${stepName}.report.json`);
88461
+ const mdPath = import_node_path30.default.join(stepOutputDir, `${stepName}.md`);
88462
+ const reportPath = import_node_path30.default.join(stepOutputDir, `${stepName}.report.json`);
88006
88463
  const mdStat = (0, import_node_fs21.existsSync)(mdPath) ? (0, import_node_fs21.statSync)(mdPath) : null;
88007
88464
  const reportStat = (0, import_node_fs21.existsSync)(reportPath) ? (0, import_node_fs21.statSync)(reportPath) : null;
88008
88465
  const mtime = Math.max(mdStat?.mtimeMs ?? 0, reportStat?.mtimeMs ?? 0);
@@ -88056,7 +88513,7 @@ ${preview}
88056
88513
  }
88057
88514
  /** Get or create the worker logs directory (.agent-relay/team/worker-logs) */
88058
88515
  getWorkerLogsDir() {
88059
- const logsDir = import_node_path29.default.join(this.cwd, ".agent-relay", "team", "worker-logs");
88516
+ const logsDir = import_node_path30.default.join(this.cwd, ".agent-relay", "team", "worker-logs");
88060
88517
  (0, import_node_fs21.mkdirSync)(logsDir, { recursive: true });
88061
88518
  return logsDir;
88062
88519
  }
@@ -88068,12 +88525,12 @@ ${preview}
88068
88525
  spawnedAt: Date.now(),
88069
88526
  pid,
88070
88527
  interactive,
88071
- logFile: import_node_path29.default.join(this.getWorkerLogsDir(), `${agentName}.log`)
88528
+ logFile: import_node_path30.default.join(this.getWorkerLogsDir(), `${agentName}.log`)
88072
88529
  };
88073
88530
  this.activeWorkers.set(agentName, workerEntry);
88074
88531
  this.workersFileLock = this.workersFileLock.then(() => {
88075
88532
  try {
88076
- (0, import_node_fs21.mkdirSync)(import_node_path29.default.dirname(this.workersPath), { recursive: true });
88533
+ (0, import_node_fs21.mkdirSync)(import_node_path30.default.dirname(this.workersPath), { recursive: true });
88077
88534
  const existing = this.readWorkers().filter((w2) => w2.name !== agentName);
88078
88535
  existing.push({ name: agentName, ...workerEntry });
88079
88536
  this.writeWorkers(existing);
@@ -88110,8 +88567,8 @@ ${preview}
88110
88567
 
88111
88568
  // packages/sdk/dist/workflows/file-db.js
88112
88569
  var import_node_fs22 = require("node:fs");
88113
- var import_node_os10 = __toESM(require("node:os"), 1);
88114
- var import_node_path30 = __toESM(require("node:path"), 1);
88570
+ var import_node_os11 = __toESM(require("node:os"), 1);
88571
+ var import_node_path31 = __toESM(require("node:path"), 1);
88115
88572
  var JsonFileWorkflowDb = class _JsonFileWorkflowDb {
88116
88573
  filePath;
88117
88574
  /** Whether persistence is active. False = in-memory-only mode. */
@@ -88127,7 +88584,7 @@ var JsonFileWorkflowDb = class _JsonFileWorkflowDb {
88127
88584
  constructor(filePathOrOptions) {
88128
88585
  const options = typeof filePathOrOptions === "string" ? { filePath: filePathOrOptions } : filePathOrOptions;
88129
88586
  this.onWriteFailure = options.onWriteFailure;
88130
- const requestedPath = options.filePath ?? import_node_path30.default.join(".agent-relay", "workflow-runs.jsonl");
88587
+ const requestedPath = options.filePath ?? import_node_path31.default.join(".agent-relay", "workflow-runs.jsonl");
88131
88588
  const homeFallback = options.homeFallback ?? false;
88132
88589
  const { resolvedPath, writable } = _JsonFileWorkflowDb.resolveStoragePath(requestedPath, homeFallback);
88133
88590
  this.filePath = resolvedPath;
@@ -88144,7 +88601,7 @@ var JsonFileWorkflowDb = class _JsonFileWorkflowDb {
88144
88601
  }
88145
88602
  hasStepOutputs(runId) {
88146
88603
  try {
88147
- const dir = import_node_path30.default.join(import_node_path30.default.dirname(this.filePath), "step-outputs", runId);
88604
+ const dir = import_node_path31.default.join(import_node_path31.default.dirname(this.filePath), "step-outputs", runId);
88148
88605
  return (0, import_node_fs22.existsSync)(dir) && (0, import_node_fs22.readdirSync)(dir).length > 0;
88149
88606
  } catch {
88150
88607
  return false;
@@ -88154,16 +88611,16 @@ var JsonFileWorkflowDb = class _JsonFileWorkflowDb {
88154
88611
  static resolveStoragePath(requestedPath, homeFallback) {
88155
88612
  const candidates = [requestedPath];
88156
88613
  if (homeFallback) {
88157
- const base = import_node_path30.default.basename(requestedPath) || "workflow-runs.jsonl";
88158
- candidates.push(import_node_path30.default.join(import_node_os10.default.homedir(), ".agent-relay", `workflow-runs-${base}`));
88614
+ const base = import_node_path31.default.basename(requestedPath) || "workflow-runs.jsonl";
88615
+ candidates.push(import_node_path31.default.join(import_node_os11.default.homedir(), ".agent-relay", `workflow-runs-${base}`));
88159
88616
  }
88160
88617
  for (let i = 0; i < candidates.length; i++) {
88161
88618
  const candidate = candidates[i];
88162
88619
  const isLastCandidate = i === candidates.length - 1;
88163
88620
  try {
88164
- (0, import_node_fs22.mkdirSync)(import_node_path30.default.dirname(candidate), { recursive: true });
88621
+ (0, import_node_fs22.mkdirSync)(import_node_path31.default.dirname(candidate), { recursive: true });
88165
88622
  if (!isLastCandidate) {
88166
- (0, import_node_fs22.accessSync)(import_node_path30.default.dirname(candidate), import_node_fs22.constants.W_OK);
88623
+ (0, import_node_fs22.accessSync)(import_node_path31.default.dirname(candidate), import_node_fs22.constants.W_OK);
88167
88624
  if ((0, import_node_fs22.existsSync)(candidate)) {
88168
88625
  (0, import_node_fs22.accessSync)(candidate, import_node_fs22.constants.W_OK);
88169
88626
  }
@@ -88452,17 +88909,17 @@ async function runWorkflow(yamlPath, options = {}) {
88452
88909
  }
88453
88910
 
88454
88911
  // packages/cloud/src/auth.ts
88455
- var import_promises9 = __toESM(require("node:fs/promises"), 1);
88912
+ var import_promises10 = __toESM(require("node:fs/promises"), 1);
88456
88913
  var import_node_http = __toESM(require("node:http"), 1);
88457
- var import_node_os12 = __toESM(require("node:os"), 1);
88458
- var import_node_path32 = __toESM(require("node:path"), 1);
88914
+ var import_node_os13 = __toESM(require("node:os"), 1);
88915
+ var import_node_path33 = __toESM(require("node:path"), 1);
88459
88916
  var import_node_child_process9 = require("node:child_process");
88460
88917
 
88461
88918
  // packages/cloud/src/types.ts
88462
- var import_node_os11 = __toESM(require("node:os"), 1);
88463
- var import_node_path31 = __toESM(require("node:path"), 1);
88919
+ var import_node_os12 = __toESM(require("node:os"), 1);
88920
+ var import_node_path32 = __toESM(require("node:path"), 1);
88464
88921
  var REFRESH_WINDOW_MS = 6e4;
88465
- var AUTH_FILE_PATH = import_node_path31.default.join(import_node_os11.default.homedir(), ".agent-relay", "cloud-auth.json");
88922
+ var AUTH_FILE_PATH = import_node_path32.default.join(import_node_os12.default.homedir(), ".agent-relay", "cloud-auth.json");
88466
88923
  function defaultApiUrl() {
88467
88924
  return process.env.CLOUD_API_URL?.trim() || "https://agentrelay.com/cloud";
88468
88925
  }
@@ -88530,7 +88987,7 @@ async function readStoredAuth(env = process.env) {
88530
88987
  return envAuth;
88531
88988
  }
88532
88989
  try {
88533
- const file2 = await import_promises9.default.readFile(AUTH_FILE_PATH, "utf8");
88990
+ const file2 = await import_promises10.default.readFile(AUTH_FILE_PATH, "utf8");
88534
88991
  const parsed = JSON.parse(file2);
88535
88992
  return isValidStoredAuth(parsed) ? parsed : null;
88536
88993
  } catch {
@@ -88538,11 +88995,11 @@ async function readStoredAuth(env = process.env) {
88538
88995
  }
88539
88996
  }
88540
88997
  async function writeStoredAuth(auth) {
88541
- await import_promises9.default.mkdir(import_node_path32.default.dirname(AUTH_FILE_PATH), {
88998
+ await import_promises10.default.mkdir(import_node_path33.default.dirname(AUTH_FILE_PATH), {
88542
88999
  recursive: true,
88543
89000
  mode: 448
88544
89001
  });
88545
- await import_promises9.default.writeFile(AUTH_FILE_PATH, `${JSON.stringify(auth, null, 2)}
89002
+ await import_promises10.default.writeFile(AUTH_FILE_PATH, `${JSON.stringify(auth, null, 2)}
88546
89003
  `, {
88547
89004
  encoding: "utf8",
88548
89005
  mode: 384
@@ -88556,11 +89013,11 @@ function shouldRefresh(accessTokenExpiresAt) {
88556
89013
  return expiresAt - Date.now() <= REFRESH_WINDOW_MS;
88557
89014
  }
88558
89015
  function openBrowser(url2) {
88559
- const platform2 = import_node_os12.default.platform();
88560
- if (platform2 === "darwin") {
89016
+ const platform3 = import_node_os13.default.platform();
89017
+ if (platform3 === "darwin") {
88561
89018
  return (0, import_node_child_process9.spawn)("open", [url2], { stdio: "ignore", detached: true });
88562
89019
  }
88563
- if (platform2 === "win32") {
89020
+ if (platform3 === "win32") {
88564
89021
  return (0, import_node_child_process9.spawn)("cmd", ["/c", "start", "", url2], { stdio: "ignore", detached: true });
88565
89022
  }
88566
89023
  return (0, import_node_child_process9.spawn)("xdg-open", [url2], { stdio: "ignore", detached: true });
@@ -88757,8 +89214,8 @@ async function authorizedApiFetch(auth, requestPath, init) {
88757
89214
  }
88758
89215
 
88759
89216
  // packages/cloud/src/workflows.ts
88760
- var import_promises10 = __toESM(require("node:fs/promises"), 1);
88761
- var import_node_path33 = __toESM(require("node:path"), 1);
89217
+ var import_promises11 = __toESM(require("node:fs/promises"), 1);
89218
+ var import_node_path34 = __toESM(require("node:path"), 1);
88762
89219
  var import_ignore3 = __toESM(require_ignore(), 1);
88763
89220
  function validateYamlWorkflow(content) {
88764
89221
  const hasField = (field) => new RegExp(`^${field}\\s*:`, "m").test(content);
@@ -88818,7 +89275,7 @@ ${message}`);
88818
89275
  }
88819
89276
  }
88820
89277
  function inferWorkflowFileType(filePath) {
88821
- const ext = import_node_path33.default.extname(filePath).toLowerCase();
89278
+ const ext = import_node_path34.default.extname(filePath).toLowerCase();
88822
89279
  switch (ext) {
88823
89280
  case ".yaml":
88824
89281
  case ".yml":
@@ -88834,9 +89291,9 @@ function inferWorkflowFileType(filePath) {
88834
89291
  }
88835
89292
  }
88836
89293
  async function resolveWorkflowInput(workflowArg, explicitFileType) {
88837
- const looksLikeFile = import_node_path33.default.isAbsolute(workflowArg) || workflowArg.includes(import_node_path33.default.sep) || inferWorkflowFileType(workflowArg) !== null;
89294
+ const looksLikeFile = import_node_path34.default.isAbsolute(workflowArg) || workflowArg.includes(import_node_path34.default.sep) || inferWorkflowFileType(workflowArg) !== null;
88838
89295
  try {
88839
- const workflow2 = await import_promises10.default.readFile(workflowArg, "utf-8");
89296
+ const workflow2 = await import_promises11.default.readFile(workflowArg, "utf-8");
88840
89297
  const fileType = explicitFileType ?? inferWorkflowFileType(workflowArg);
88841
89298
  if (!fileType) {
88842
89299
  throw new Error(`Could not infer workflow type from ${workflowArg}. Use --file-type.`);
@@ -88875,7 +89332,7 @@ async function scheduleWorkflow(workflowArg, options = {}) {
88875
89332
  validateYamlWorkflow(input.workflow);
88876
89333
  }
88877
89334
  const requestBody = {
88878
- name: options.name?.trim() || import_node_path33.default.basename(workflowArg),
89335
+ name: options.name?.trim() || import_node_path34.default.basename(workflowArg),
88879
89336
  schedule_type: hasCron ? "cron" : "once",
88880
89337
  timezone: options.timezone?.trim() || "UTC",
88881
89338
  workflowRequest: {
@@ -88976,7 +89433,7 @@ function isMissingFileError(error51) {
88976
89433
  var DEBUG = process.env.AGENT_RELAY_DEBUG_SSH === "1";
88977
89434
 
88978
89435
  // packages/sdk/dist/workflows/builder.js
88979
- var import_node_path34 = __toESM(require("node:path"), 1);
89436
+ var import_node_path35 = __toESM(require("node:path"), 1);
88980
89437
  var import_yaml3 = __toESM(require_dist(), 1);
88981
89438
 
88982
89439
  // packages/sdk/dist/workflows/cloud-runner.js
@@ -89335,7 +89792,7 @@ var WorkflowBuilder = class {
89335
89792
  async run(options = {}) {
89336
89793
  const config2 = this.toConfig();
89337
89794
  const runnerCwd = options.cwd ?? process.cwd();
89338
- const dbPath = import_node_path34.default.join(runnerCwd, ".agent-relay", "workflow-runs.jsonl");
89795
+ const dbPath = import_node_path35.default.join(runnerCwd, ".agent-relay", "workflow-runs.jsonl");
89339
89796
  const db = new JsonFileWorkflowDb(dbPath);
89340
89797
  const runner = new WorkflowRunner({
89341
89798
  cwd: options.cwd,
@@ -90253,7 +90710,7 @@ var StateStore = class extends import_node_events5.EventEmitter {
90253
90710
 
90254
90711
  // packages/sdk/dist/workflows/templates.js
90255
90712
  var import_node_fs23 = require("node:fs");
90256
- var import_node_path35 = __toESM(require("node:path"), 1);
90713
+ var import_node_path36 = __toESM(require("node:path"), 1);
90257
90714
  var import_node_url2 = require("node:url");
90258
90715
  var import_yaml4 = __toESM(require_dist(), 1);
90259
90716
  var YAML_EXTENSIONS = [".yaml", ".yml"];
@@ -90278,7 +90735,7 @@ var TemplateRegistry = class {
90278
90735
  fetcher;
90279
90736
  constructor(options = {}) {
90280
90737
  this.builtInTemplatesDir = this.resolveBuiltInTemplatesDir(options.builtInTemplatesDir);
90281
- this.customTemplatesDir = options.customTemplatesDir ? import_node_path35.default.resolve(options.customTemplatesDir) : import_node_path35.default.resolve(options.workspaceDir ?? process.cwd(), ".relay/workflows");
90738
+ this.customTemplatesDir = options.customTemplatesDir ? import_node_path36.default.resolve(options.customTemplatesDir) : import_node_path36.default.resolve(options.workspaceDir ?? process.cwd(), ".relay/workflows");
90282
90739
  this.fetcher = options.fetcher ?? fetch;
90283
90740
  }
90284
90741
  listBuiltInTemplates() {
@@ -90352,12 +90809,12 @@ var TemplateRegistry = class {
90352
90809
  if (!templateName) {
90353
90810
  throw new Error('Template name is required. Provide name explicitly or include a string "name" field.');
90354
90811
  }
90355
- if (templateName.includes("/") || templateName.includes("\\") || templateName.includes("..") || import_node_path35.default.isAbsolute(templateName)) {
90812
+ if (templateName.includes("/") || templateName.includes("\\") || templateName.includes("..") || import_node_path36.default.isAbsolute(templateName)) {
90356
90813
  throw new Error(`Invalid template name: "${templateName}" contains path separators or traversal sequences`);
90357
90814
  }
90358
90815
  this.validateRelayConfig(parsed, url2);
90359
90816
  await import_node_fs23.promises.mkdir(this.customTemplatesDir, { recursive: true });
90360
- const targetPath = import_node_path35.default.join(this.customTemplatesDir, `${templateName}.yaml`);
90817
+ const targetPath = import_node_path36.default.join(this.customTemplatesDir, `${templateName}.yaml`);
90361
90818
  await import_node_fs23.promises.writeFile(targetPath, (0, import_yaml4.stringify)(parsed), "utf-8");
90362
90819
  return targetPath;
90363
90820
  }
@@ -90379,12 +90836,12 @@ var TemplateRegistry = class {
90379
90836
  }
90380
90837
  resolveBuiltInTemplatesDir(explicitDir) {
90381
90838
  if (explicitDir) {
90382
- return import_node_path35.default.resolve(explicitDir);
90839
+ return import_node_path36.default.resolve(explicitDir);
90383
90840
  }
90384
- const currentDir = import_node_path35.default.dirname((0, import_node_url2.fileURLToPath)(import_meta_url));
90841
+ const currentDir = import_node_path36.default.dirname((0, import_node_url2.fileURLToPath)(import_meta_url));
90385
90842
  const candidates = [
90386
- import_node_path35.default.resolve(currentDir, "builtin-templates"),
90387
- import_node_path35.default.resolve(currentDir, "../workflows/builtin-templates")
90843
+ import_node_path36.default.resolve(currentDir, "builtin-templates"),
90844
+ import_node_path36.default.resolve(currentDir, "../workflows/builtin-templates")
90388
90845
  ];
90389
90846
  for (const candidate of candidates) {
90390
90847
  if ((0, import_node_fs23.existsSync)(candidate)) {
@@ -90407,10 +90864,10 @@ var TemplateRegistry = class {
90407
90864
  }
90408
90865
  async findTemplatePath(directory, templateName) {
90409
90866
  for (const ext of YAML_EXTENSIONS) {
90410
- const candidate = import_node_path35.default.join(directory, `${templateName}${ext}`);
90867
+ const candidate = import_node_path36.default.join(directory, `${templateName}${ext}`);
90411
90868
  try {
90412
- const stat2 = await import_node_fs23.promises.stat(candidate);
90413
- if (stat2.isFile()) {
90869
+ const stat3 = await import_node_fs23.promises.stat(candidate);
90870
+ if (stat3.isFile()) {
90414
90871
  return candidate;
90415
90872
  }
90416
90873
  } catch {
@@ -90755,7 +91212,7 @@ function pythonVerifyCommand() {
90755
91212
 
90756
91213
  // packages/sdk/dist/workflows/run-script.js
90757
91214
  var import_node_fs24 = __toESM(require("node:fs"), 1);
90758
- var import_node_path36 = __toESM(require("node:path"), 1);
91215
+ var import_node_path37 = __toESM(require("node:path"), 1);
90759
91216
  var import_node_child_process10 = require("node:child_process");
90760
91217
  function diag(msg) {
90761
91218
  try {
@@ -90770,12 +91227,12 @@ function diag(msg) {
90770
91227
  }
90771
91228
  }
90772
91229
  function findLocalSdkWorkspace(startDir) {
90773
- let current = import_node_path36.default.resolve(startDir);
90774
- const root = import_node_path36.default.parse(current).root;
91230
+ let current = import_node_path37.default.resolve(startDir);
91231
+ const root = import_node_path37.default.parse(current).root;
90775
91232
  while (true) {
90776
- const packageJsonPath = import_node_path36.default.join(current, "package.json");
90777
- const sdkDir = import_node_path36.default.join(current, "packages", "sdk");
90778
- const sdkPackageJsonPath = import_node_path36.default.join(sdkDir, "package.json");
91233
+ const packageJsonPath = import_node_path37.default.join(current, "package.json");
91234
+ const sdkDir = import_node_path37.default.join(current, "packages", "sdk");
91235
+ const sdkPackageJsonPath = import_node_path37.default.join(sdkDir, "package.json");
90779
91236
  try {
90780
91237
  if (import_node_fs24.default.existsSync(packageJsonPath) && import_node_fs24.default.existsSync(sdkPackageJsonPath)) {
90781
91238
  const pkg = JSON.parse(import_node_fs24.default.readFileSync(packageJsonPath, "utf8"));
@@ -90788,14 +91245,14 @@ function findLocalSdkWorkspace(startDir) {
90788
91245
  }
90789
91246
  if (current === root)
90790
91247
  return null;
90791
- current = import_node_path36.default.dirname(current);
91248
+ current = import_node_path37.default.dirname(current);
90792
91249
  }
90793
91250
  }
90794
91251
  function ensureLocalSdkWorkflowRuntime(startDir, execRunner = import_node_child_process10.execFileSync) {
90795
91252
  const workspace = findLocalSdkWorkspace(startDir);
90796
91253
  if (!workspace)
90797
91254
  return;
90798
- const workflowsEntry = import_node_path36.default.join(workspace.sdkDir, "dist", "workflows", "index.js");
91255
+ const workflowsEntry = import_node_path37.default.join(workspace.sdkDir, "dist", "workflows", "index.js");
90799
91256
  if (import_node_fs24.default.existsSync(workflowsEntry))
90800
91257
  return;
90801
91258
  console.log("[agent-relay] Detected local @agent-relay/sdk workspace without built workflows runtime; building SDK workflow dependencies...");
@@ -90858,8 +91315,8 @@ function resolveLocalTypeScriptImport(fromFile, specifier) {
90858
91315
  if (!specifier.startsWith(".") && !specifier.startsWith("/")) {
90859
91316
  return null;
90860
91317
  }
90861
- const basePath = specifier.startsWith("/") ? import_node_path36.default.resolve(specifier) : import_node_path36.default.resolve(import_node_path36.default.dirname(fromFile), specifier);
90862
- const ext = import_node_path36.default.extname(basePath);
91318
+ const basePath = specifier.startsWith("/") ? import_node_path37.default.resolve(specifier) : import_node_path37.default.resolve(import_node_path37.default.dirname(fromFile), specifier);
91319
+ const ext = import_node_path37.default.extname(basePath);
90863
91320
  const candidates = ext === ".js" || ext === ".mjs" || ext === ".cjs" ? [
90864
91321
  `${basePath.slice(0, -ext.length)}.ts`,
90865
91322
  `${basePath.slice(0, -ext.length)}.tsx`,
@@ -90871,10 +91328,10 @@ function resolveLocalTypeScriptImport(fromFile, specifier) {
90871
91328
  `${basePath}.tsx`,
90872
91329
  `${basePath}.mts`,
90873
91330
  `${basePath}.cts`,
90874
- import_node_path36.default.join(basePath, "index.ts"),
90875
- import_node_path36.default.join(basePath, "index.tsx"),
90876
- import_node_path36.default.join(basePath, "index.mts"),
90877
- import_node_path36.default.join(basePath, "index.cts")
91331
+ import_node_path37.default.join(basePath, "index.ts"),
91332
+ import_node_path37.default.join(basePath, "index.tsx"),
91333
+ import_node_path37.default.join(basePath, "index.mts"),
91334
+ import_node_path37.default.join(basePath, "index.cts")
90878
91335
  ];
90879
91336
  for (const candidate of candidates) {
90880
91337
  if (/\.(?:ts|tsx|mts|cts)$/.test(candidate) && import_node_fs24.default.existsSync(candidate)) {
@@ -90895,7 +91352,7 @@ function findStaticLocalTypeScriptImports(filePath, source) {
90895
91352
  return imports;
90896
91353
  }
90897
91354
  function shouldSkipNodeStripTypesPreflight(filePath, seen = /* @__PURE__ */ new Set(), isEntry = true) {
90898
- const resolvedPath = import_node_path36.default.resolve(filePath);
91355
+ const resolvedPath = import_node_path37.default.resolve(filePath);
90899
91356
  if (seen.has(resolvedPath)) {
90900
91357
  return false;
90901
91358
  }
@@ -91024,14 +91481,14 @@ async function spawnRunnerWithStderrCapture(command, args, env) {
91024
91481
  }
91025
91482
  async function runScriptWorkflow(filePath, options = {}) {
91026
91483
  diag(`runScriptWorkflow: resolving ${filePath}`);
91027
- const resolved = import_node_path36.default.resolve(filePath);
91484
+ const resolved = import_node_path37.default.resolve(filePath);
91028
91485
  if (!import_node_fs24.default.existsSync(resolved)) {
91029
91486
  throw new Error(`File not found: ${resolved}`);
91030
91487
  }
91031
- const ext = import_node_path36.default.extname(resolved).toLowerCase();
91032
- const runIdFile = import_node_path36.default.join(process.cwd(), ".agent-relay", `script-run-id-${process.pid}-${Date.now()}.txt`);
91488
+ const ext = import_node_path37.default.extname(resolved).toLowerCase();
91489
+ const runIdFile = import_node_path37.default.join(process.cwd(), ".agent-relay", `script-run-id-${process.pid}-${Date.now()}.txt`);
91033
91490
  try {
91034
- import_node_fs24.default.mkdirSync(import_node_path36.default.dirname(runIdFile), { recursive: true });
91491
+ import_node_fs24.default.mkdirSync(import_node_path37.default.dirname(runIdFile), { recursive: true });
91035
91492
  } catch {
91036
91493
  }
91037
91494
  const childEnv = { ...process.env, AGENT_RELAY_RUN_ID_FILE: runIdFile };
@@ -91069,7 +91526,7 @@ Run ID: ${runId}`;
91069
91526
  };
91070
91527
  if (ext === ".ts" || ext === ".tsx") {
91071
91528
  diag("runScriptWorkflow: ensureLocalSdkWorkflowRuntime start");
91072
- ensureLocalSdkWorkflowRuntime(import_node_path36.default.dirname(resolved));
91529
+ ensureLocalSdkWorkflowRuntime(import_node_path37.default.dirname(resolved));
91073
91530
  diag("runScriptWorkflow: ensureLocalSdkWorkflowRuntime done");
91074
91531
  const wrapRunnerError = (runner, result) => {
91075
91532
  const parsed = parseTsxStderr(result.stderr);
@@ -92495,7 +92952,7 @@ function isValidAgentName(name) {
92495
92952
 
92496
92953
  // packages/utils/dist/logger.js
92497
92954
  var import_node_fs25 = __toESM(require("node:fs"), 1);
92498
- var import_node_path37 = __toESM(require("node:path"), 1);
92955
+ var import_node_path38 = __toESM(require("node:path"), 1);
92499
92956
  function getLogFile() {
92500
92957
  return process.env.AGENT_RELAY_LOG_FILE;
92501
92958
  }
@@ -92513,7 +92970,7 @@ var LEVEL_PRIORITY = {
92513
92970
  };
92514
92971
  var createdLogDirs = /* @__PURE__ */ new Set();
92515
92972
  function ensureLogDir(logFile) {
92516
- const logDir = import_node_path37.default.dirname(logFile);
92973
+ const logDir = import_node_path38.default.dirname(logFile);
92517
92974
  if (!createdLogDirs.has(logDir) && !import_node_fs25.default.existsSync(logDir)) {
92518
92975
  import_node_fs25.default.mkdirSync(logDir, { recursive: true });
92519
92976
  createdLogDirs.add(logDir);
@@ -92959,16 +93416,16 @@ function getRepoFullNameFromPath(workingDirectory) {
92959
93416
 
92960
93417
  // packages/utils/dist/update-checker.js
92961
93418
  var import_node_fs27 = __toESM(require("node:fs"), 1);
92962
- var import_node_path38 = __toESM(require("node:path"), 1);
93419
+ var import_node_path39 = __toESM(require("node:path"), 1);
92963
93420
  var import_node_https2 = __toESM(require("node:https"), 1);
92964
- var import_node_os14 = __toESM(require("node:os"), 1);
93421
+ var import_node_os15 = __toESM(require("node:os"), 1);
92965
93422
  var import_compare_versions = __toESM(require_umd(), 1);
92966
93423
  var PACKAGE_NAME = "agent-relay";
92967
93424
  var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
92968
93425
  var NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
92969
93426
  function getCachePath() {
92970
- const cacheDir = import_node_path38.default.join(import_node_os14.default.homedir(), ".agent-relay");
92971
- return import_node_path38.default.join(cacheDir, "update-cache.json");
93427
+ const cacheDir = import_node_path39.default.join(import_node_os15.default.homedir(), ".agent-relay");
93428
+ return import_node_path39.default.join(cacheDir, "update-cache.json");
92972
93429
  }
92973
93430
  function readCache() {
92974
93431
  try {
@@ -92984,7 +93441,7 @@ function readCache() {
92984
93441
  function writeCache(cache) {
92985
93442
  try {
92986
93443
  const cachePath = getCachePath();
92987
- const cacheDir = import_node_path38.default.dirname(cachePath);
93444
+ const cacheDir = import_node_path39.default.dirname(cachePath);
92988
93445
  if (!import_node_fs27.default.existsSync(cacheDir)) {
92989
93446
  import_node_fs27.default.mkdirSync(cacheDir, { recursive: true });
92990
93447
  }
@@ -93268,8 +93725,8 @@ function validateModelForCli(cli, model) {
93268
93725
 
93269
93726
  // packages/utils/dist/relay-pty-path.js
93270
93727
  var import_node_fs28 = __toESM(require("node:fs"), 1);
93271
- var import_node_os15 = __toESM(require("node:os"), 1);
93272
- var import_node_path39 = __toESM(require("node:path"), 1);
93728
+ var import_node_os16 = __toESM(require("node:os"), 1);
93729
+ var import_node_path40 = __toESM(require("node:path"), 1);
93273
93730
  var SUPPORTED_PLATFORMS = {
93274
93731
  darwin: {
93275
93732
  arm64: "relay-pty-darwin-arm64",
@@ -93281,14 +93738,14 @@ var SUPPORTED_PLATFORMS = {
93281
93738
  }
93282
93739
  };
93283
93740
  function getPlatformBinaryName() {
93284
- const platform2 = import_node_os15.default.platform();
93285
- const arch = import_node_os15.default.arch();
93286
- return SUPPORTED_PLATFORMS[platform2]?.[arch] ?? null;
93741
+ const platform3 = import_node_os16.default.platform();
93742
+ const arch = import_node_os16.default.arch();
93743
+ return SUPPORTED_PLATFORMS[platform3]?.[arch] ?? null;
93287
93744
  }
93288
93745
  function isPlatformSupported() {
93289
- const platform2 = import_node_os15.default.platform();
93290
- const arch = import_node_os15.default.arch();
93291
- return SUPPORTED_PLATFORMS[platform2]?.[arch] !== void 0;
93746
+ const platform3 = import_node_os16.default.platform();
93747
+ const arch = import_node_os16.default.arch();
93748
+ return SUPPORTED_PLATFORMS[platform3]?.[arch] !== void 0;
93292
93749
  }
93293
93750
  function getSupportedPlatforms() {
93294
93751
  const platforms = [];
@@ -93317,19 +93774,19 @@ function findRelayPtyBinary(callerDirname) {
93317
93774
  const scopedMatch = normalizedCaller.match(/^(.+?\/node_modules)\/@agent-relay\//);
93318
93775
  const directMatch = normalizedCaller.match(/^(.+?\/node_modules\/agent-relay)/);
93319
93776
  if (scopedMatch) {
93320
- packageRoots.push(import_node_path39.default.join(scopedMatch[1], "agent-relay"));
93777
+ packageRoots.push(import_node_path40.default.join(scopedMatch[1], "agent-relay"));
93321
93778
  }
93322
93779
  if (directMatch) {
93323
93780
  packageRoots.push(directMatch[1]);
93324
93781
  }
93325
93782
  const home = process.env.HOME || process.env.USERPROFILE || "";
93326
93783
  if (home) {
93327
- const npxCacheBase = import_node_path39.default.join(home, ".npm", "_npx");
93784
+ const npxCacheBase = import_node_path40.default.join(home, ".npm", "_npx");
93328
93785
  if (import_node_fs28.default.existsSync(npxCacheBase)) {
93329
93786
  try {
93330
93787
  const entries = import_node_fs28.default.readdirSync(npxCacheBase);
93331
93788
  for (const entry of entries) {
93332
- const npxPackage = import_node_path39.default.join(npxCacheBase, entry, "node_modules", "agent-relay");
93789
+ const npxPackage = import_node_path40.default.join(npxCacheBase, entry, "node_modules", "agent-relay");
93333
93790
  if (import_node_fs28.default.existsSync(npxPackage)) {
93334
93791
  packageRoots.push(npxPackage);
93335
93792
  }
@@ -93338,42 +93795,42 @@ function findRelayPtyBinary(callerDirname) {
93338
93795
  }
93339
93796
  }
93340
93797
  }
93341
- packageRoots.push(import_node_path39.default.join(process.cwd(), "node_modules", "agent-relay"));
93798
+ packageRoots.push(import_node_path40.default.join(process.cwd(), "node_modules", "agent-relay"));
93342
93799
  if (home) {
93343
- packageRoots.push(import_node_path39.default.join(home, ".nvm", "versions", "node", process.version, "lib", "node_modules", "agent-relay"));
93344
- packageRoots.push(import_node_path39.default.join(home, ".volta", "tools", "image", "packages", "agent-relay", "lib", "node_modules", "agent-relay"));
93345
- packageRoots.push(import_node_path39.default.join(home, ".fnm", "node-versions", process.version, "installation", "lib", "node_modules", "agent-relay"));
93346
- packageRoots.push(import_node_path39.default.join(home, "n", "lib", "node_modules", "agent-relay"));
93347
- packageRoots.push(import_node_path39.default.join(home, ".asdf", "installs", "nodejs", process.version.replace("v", ""), "lib", "node_modules", "agent-relay"));
93348
- packageRoots.push(import_node_path39.default.join(home, ".local", "share", "pnpm", "global", "node_modules", "agent-relay"));
93349
- packageRoots.push(import_node_path39.default.join(home, ".config", "yarn", "global", "node_modules", "agent-relay"));
93350
- packageRoots.push(import_node_path39.default.join(home, ".yarn", "global", "node_modules", "agent-relay"));
93351
- }
93352
- const bashInstallerDir = process.env.AGENT_RELAY_INSTALL_DIR ? import_node_path39.default.join(process.env.AGENT_RELAY_INSTALL_DIR, "bin") : home ? import_node_path39.default.join(home, ".agent-relay", "bin") : null;
93353
- const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ? import_node_path39.default.join(home, ".local", "bin") : null);
93354
- const nodePrefix = import_node_path39.default.resolve(import_node_path39.default.dirname(process.execPath), "..");
93355
- packageRoots.push(import_node_path39.default.join(nodePrefix, "lib", "node_modules", "agent-relay"));
93800
+ packageRoots.push(import_node_path40.default.join(home, ".nvm", "versions", "node", process.version, "lib", "node_modules", "agent-relay"));
93801
+ packageRoots.push(import_node_path40.default.join(home, ".volta", "tools", "image", "packages", "agent-relay", "lib", "node_modules", "agent-relay"));
93802
+ packageRoots.push(import_node_path40.default.join(home, ".fnm", "node-versions", process.version, "installation", "lib", "node_modules", "agent-relay"));
93803
+ packageRoots.push(import_node_path40.default.join(home, "n", "lib", "node_modules", "agent-relay"));
93804
+ packageRoots.push(import_node_path40.default.join(home, ".asdf", "installs", "nodejs", process.version.replace("v", ""), "lib", "node_modules", "agent-relay"));
93805
+ packageRoots.push(import_node_path40.default.join(home, ".local", "share", "pnpm", "global", "node_modules", "agent-relay"));
93806
+ packageRoots.push(import_node_path40.default.join(home, ".config", "yarn", "global", "node_modules", "agent-relay"));
93807
+ packageRoots.push(import_node_path40.default.join(home, ".yarn", "global", "node_modules", "agent-relay"));
93808
+ }
93809
+ const bashInstallerDir = process.env.AGENT_RELAY_INSTALL_DIR ? import_node_path40.default.join(process.env.AGENT_RELAY_INSTALL_DIR, "bin") : home ? import_node_path40.default.join(home, ".agent-relay", "bin") : null;
93810
+ const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ? import_node_path40.default.join(home, ".local", "bin") : null);
93811
+ const nodePrefix = import_node_path40.default.resolve(import_node_path40.default.dirname(process.execPath), "..");
93812
+ packageRoots.push(import_node_path40.default.join(nodePrefix, "lib", "node_modules", "agent-relay"));
93356
93813
  packageRoots.push("/usr/local/lib/node_modules/agent-relay");
93357
93814
  packageRoots.push("/opt/homebrew/lib/node_modules/agent-relay");
93358
93815
  packageRoots.push("/usr/lib/node_modules/agent-relay");
93359
93816
  const candidates = [];
93360
93817
  for (const root of packageRoots) {
93361
93818
  if (platformBinary) {
93362
- candidates.push(import_node_path39.default.join(root, "bin", platformBinary));
93819
+ candidates.push(import_node_path40.default.join(root, "bin", platformBinary));
93363
93820
  }
93364
- candidates.push(import_node_path39.default.join(root, "bin", "relay-pty"));
93821
+ candidates.push(import_node_path40.default.join(root, "bin", "relay-pty"));
93365
93822
  }
93366
93823
  if (bashInstallerDir) {
93367
93824
  if (platformBinary) {
93368
- candidates.push(import_node_path39.default.join(bashInstallerDir, platformBinary));
93825
+ candidates.push(import_node_path40.default.join(bashInstallerDir, platformBinary));
93369
93826
  }
93370
- candidates.push(import_node_path39.default.join(bashInstallerDir, "relay-pty"));
93827
+ candidates.push(import_node_path40.default.join(bashInstallerDir, "relay-pty"));
93371
93828
  }
93372
93829
  if (bashInstallerBinDir) {
93373
93830
  if (platformBinary) {
93374
- candidates.push(import_node_path39.default.join(bashInstallerBinDir, platformBinary));
93831
+ candidates.push(import_node_path40.default.join(bashInstallerBinDir, platformBinary));
93375
93832
  }
93376
- candidates.push(import_node_path39.default.join(bashInstallerBinDir, "relay-pty"));
93833
+ candidates.push(import_node_path40.default.join(bashInstallerBinDir, "relay-pty"));
93377
93834
  }
93378
93835
  candidates.push("/app/bin/relay-pty");
93379
93836
  candidates.push("/usr/local/bin/relay-pty");
@@ -93404,11 +93861,11 @@ function isPlatformCompatibleBinary(filePath) {
93404
93861
  return false;
93405
93862
  }
93406
93863
  const magic = header.readUInt32BE(0);
93407
- const platform2 = import_node_os15.default.platform();
93408
- if (platform2 === "darwin") {
93864
+ const platform3 = import_node_os16.default.platform();
93865
+ if (platform3 === "darwin") {
93409
93866
  return isMachOBinary(magic);
93410
93867
  }
93411
- if (platform2 === "linux") {
93868
+ if (platform3 === "linux") {
93412
93869
  return magic === 2135247942;
93413
93870
  }
93414
93871
  return true;
@@ -94037,52 +94494,52 @@ var import_node_child_process15 = require("node:child_process");
94037
94494
 
94038
94495
  // packages/config/dist/project-namespace.js
94039
94496
  var import_node_crypto16 = __toESM(require("node:crypto"), 1);
94040
- var import_node_path40 = __toESM(require("node:path"), 1);
94497
+ var import_node_path41 = __toESM(require("node:path"), 1);
94041
94498
  var import_node_fs29 = __toESM(require("node:fs"), 1);
94042
- var import_node_os16 = __toESM(require("node:os"), 1);
94499
+ var import_node_os17 = __toESM(require("node:os"), 1);
94043
94500
  function getGlobalBaseDir2() {
94044
94501
  if (process.env.AGENT_RELAY_DATA_DIR) {
94045
94502
  return process.env.AGENT_RELAY_DATA_DIR;
94046
94503
  }
94047
94504
  const xdgDataHome = process.env.XDG_DATA_HOME;
94048
94505
  if (xdgDataHome) {
94049
- return import_node_path40.default.join(xdgDataHome, "agent-relay");
94506
+ return import_node_path41.default.join(xdgDataHome, "agent-relay");
94050
94507
  }
94051
- return import_node_path40.default.join(import_node_os16.default.homedir(), ".agent-relay");
94508
+ return import_node_path41.default.join(import_node_os17.default.homedir(), ".agent-relay");
94052
94509
  }
94053
94510
  var GLOBAL_BASE_DIR2 = getGlobalBaseDir2();
94054
94511
  var PROJECT_DATA_DIR = ".agent-relay";
94055
94512
  function hashPath(projectPath) {
94056
- const normalized = import_node_path40.default.resolve(projectPath);
94513
+ const normalized = import_node_path41.default.resolve(projectPath);
94057
94514
  const hash2 = import_node_crypto16.default.createHash("sha256").update(normalized).digest("hex");
94058
94515
  return hash2.substring(0, 12);
94059
94516
  }
94060
94517
  function findProjectRoot(startDir = process.cwd()) {
94061
94518
  if (process.env.AGENT_RELAY_PROJECT) {
94062
- return import_node_path40.default.resolve(process.env.AGENT_RELAY_PROJECT);
94519
+ return import_node_path41.default.resolve(process.env.AGENT_RELAY_PROJECT);
94063
94520
  }
94064
- let current = import_node_path40.default.resolve(startDir);
94065
- const root = import_node_path40.default.parse(current).root;
94521
+ let current = import_node_path41.default.resolve(startDir);
94522
+ const root = import_node_path41.default.parse(current).root;
94066
94523
  const markers = [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".agent-relay"];
94067
94524
  while (current !== root) {
94068
94525
  for (const marker of markers) {
94069
- if (import_node_fs29.default.existsSync(import_node_path40.default.join(current, marker))) {
94526
+ if (import_node_fs29.default.existsSync(import_node_path41.default.join(current, marker))) {
94070
94527
  return current;
94071
94528
  }
94072
94529
  }
94073
- current = import_node_path40.default.dirname(current);
94530
+ current = import_node_path41.default.dirname(current);
94074
94531
  }
94075
- return import_node_path40.default.resolve(startDir);
94532
+ return import_node_path41.default.resolve(startDir);
94076
94533
  }
94077
94534
  function getProjectPaths2(projectRoot) {
94078
94535
  const root = projectRoot ?? findProjectRoot();
94079
94536
  const projectId = hashPath(root);
94080
- const dataDir = import_node_path40.default.join(root, PROJECT_DATA_DIR);
94537
+ const dataDir = import_node_path41.default.join(root, PROJECT_DATA_DIR);
94081
94538
  return {
94082
94539
  dataDir,
94083
- teamDir: import_node_path40.default.join(dataDir, "team"),
94084
- dbPath: import_node_path40.default.join(dataDir, "messages.sqlite"),
94085
- socketPath: import_node_path40.default.join(dataDir, "relay.sock"),
94540
+ teamDir: import_node_path41.default.join(dataDir, "team"),
94541
+ dbPath: import_node_path41.default.join(dataDir, "messages.sqlite"),
94542
+ socketPath: import_node_path41.default.join(dataDir, "relay.sock"),
94086
94543
  projectRoot: root,
94087
94544
  projectId
94088
94545
  };
@@ -94090,22 +94547,22 @@ function getProjectPaths2(projectRoot) {
94090
94547
 
94091
94548
  // packages/config/dist/trajectory-config.js
94092
94549
  var import_node_fs30 = require("node:fs");
94093
- var import_node_path41 = require("node:path");
94094
- var import_node_os17 = require("node:os");
94550
+ var import_node_path42 = require("node:path");
94551
+ var import_node_os18 = require("node:os");
94095
94552
  var import_node_crypto17 = require("node:crypto");
94096
94553
  function getAgentRelayConfigDir() {
94097
- return process.env.AGENT_RELAY_CONFIG_DIR ?? (0, import_node_path41.join)((0, import_node_os17.homedir)(), ".config", "agent-relay");
94554
+ return process.env.AGENT_RELAY_CONFIG_DIR ?? (0, import_node_path42.join)((0, import_node_os18.homedir)(), ".config", "agent-relay");
94098
94555
  }
94099
94556
  var configCache = null;
94100
94557
  function getRelayConfigPath(_projectRoot) {
94101
- return (0, import_node_path41.join)(getAgentRelayConfigDir(), "relay.json");
94558
+ return (0, import_node_path42.join)(getAgentRelayConfigDir(), "relay.json");
94102
94559
  }
94103
94560
  function readRelayConfig(projectRoot) {
94104
94561
  const configPath = getRelayConfigPath(projectRoot);
94105
94562
  if (configCache && configCache.path === configPath) {
94106
94563
  try {
94107
- const stat2 = (0, import_node_fs30.statSync)(configPath);
94108
- if (stat2.mtimeMs === configCache.mtime) {
94564
+ const stat3 = (0, import_node_fs30.statSync)(configPath);
94565
+ if (stat3.mtimeMs === configCache.mtime) {
94109
94566
  return configCache.config;
94110
94567
  }
94111
94568
  } catch {
@@ -94118,8 +94575,8 @@ function readRelayConfig(projectRoot) {
94118
94575
  const content = (0, import_node_fs30.readFileSync)(configPath, "utf-8");
94119
94576
  const config2 = JSON.parse(content);
94120
94577
  try {
94121
- const stat2 = (0, import_node_fs30.statSync)(configPath);
94122
- configCache = { path: configPath, config: config2, mtime: stat2.mtimeMs };
94578
+ const stat3 = (0, import_node_fs30.statSync)(configPath);
94579
+ configCache = { path: configPath, config: config2, mtime: stat3.mtimeMs };
94123
94580
  } catch {
94124
94581
  }
94125
94582
  return config2;
@@ -94138,12 +94595,12 @@ function getProjectHash(projectRoot) {
94138
94595
  }
94139
94596
  function getUserTrajectoriesDir(projectRoot) {
94140
94597
  const projectHash = getProjectHash(projectRoot);
94141
- const configDir = process.env.XDG_CONFIG_HOME || (0, import_node_path41.join)((0, import_node_os17.homedir)(), ".config");
94142
- return (0, import_node_path41.join)(configDir, "agent-relay", "trajectories", projectHash);
94598
+ const configDir = process.env.XDG_CONFIG_HOME || (0, import_node_path42.join)((0, import_node_os18.homedir)(), ".config");
94599
+ return (0, import_node_path42.join)(configDir, "agent-relay", "trajectories", projectHash);
94143
94600
  }
94144
94601
  function getRepoTrajectoriesDir(projectRoot) {
94145
94602
  const root = projectRoot ?? getProjectPaths2().projectRoot;
94146
- return (0, import_node_path41.join)(root, ".trajectories");
94603
+ return (0, import_node_path42.join)(root, ".trajectories");
94147
94604
  }
94148
94605
  function getPrimaryTrajectoriesDir(projectRoot) {
94149
94606
  if (shouldStoreInRepo(projectRoot)) {
@@ -94784,7 +95241,7 @@ var HookEmitter = class {
94784
95241
 
94785
95242
  // packages/hooks/dist/inbox-check/utils.js
94786
95243
  var import_node_fs31 = require("node:fs");
94787
- var import_node_path42 = require("node:path");
95244
+ var import_node_path43 = require("node:path");
94788
95245
  var DEFAULT_INBOX_DIR = "/tmp/agent-relay";
94789
95246
  function getAgentName() {
94790
95247
  return process.env.AGENT_RELAY_NAME;
@@ -94794,7 +95251,7 @@ function getInboxPath(config2) {
94794
95251
  if (!agentName) {
94795
95252
  throw new Error("Agent name not configured. Set AGENT_RELAY_NAME env var.");
94796
95253
  }
94797
- return (0, import_node_path42.join)(config2.inboxDir, agentName, "inbox.md");
95254
+ return (0, import_node_path43.join)(config2.inboxDir, agentName, "inbox.md");
94798
95255
  }
94799
95256
  function inboxExists(inboxPath) {
94800
95257
  return (0, import_node_fs31.existsSync)(inboxPath);
@@ -94948,6 +95405,7 @@ init_dist2();
94948
95405
  checkOutputContains,
94949
95406
  cleanLines,
94950
95407
  clearBinaryCache,
95408
+ clearBrokerLogs,
94951
95409
  clearResolveCache,
94952
95410
  collectCliSession,
94953
95411
  collectOutput,
@@ -95001,6 +95459,7 @@ init_dist2();
95001
95459
  generateUniqueAgentName,
95002
95460
  getAgentName,
95003
95461
  getBaseCli,
95462
+ getBrokerLogDir,
95004
95463
  getCachedRelayPtyPath,
95005
95464
  getCliDefinition,
95006
95465
  getCliRegistry,
@@ -95044,6 +95503,7 @@ init_dist2();
95044
95503
  isTrajectoryTrackingAvailable,
95045
95504
  isValidAgentName,
95046
95505
  isWorktreeStep,
95506
+ listBrokerLogs,
95047
95507
  listLoggedAgents,
95048
95508
  listPersonas,
95049
95509
  listWorkflowSchedules,
@@ -95059,6 +95519,7 @@ init_dist2();
95059
95519
  parseTsxStderr,
95060
95520
  parseVoteCommand,
95061
95521
  printUpdateNotification,
95522
+ pruneBrokerLogs,
95062
95523
  readInbox,
95063
95524
  resetPatternMetrics,
95064
95525
  resolveAllCustomSteps,
@@ -95091,6 +95552,7 @@ init_dist2();
95091
95552
  stripAnsi,
95092
95553
  stripAnsiFast,
95093
95554
  stripInjectedTaskEcho,
95555
+ tailBrokerLog,
95094
95556
  toReleaseResult,
95095
95557
  toSpawnResult,
95096
95558
  trackPatternPerformance,