agent-relay 6.0.13 → 6.0.15

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
@@ -2234,7 +2234,7 @@ var require_websocket = __commonJS({
2234
2234
  "use strict";
2235
2235
  var EventEmitter6 = require("events");
2236
2236
  var https3 = require("https");
2237
- var http = require("http");
2237
+ var http2 = require("http");
2238
2238
  var net = require("net");
2239
2239
  var tls = require("tls");
2240
2240
  var { randomBytes: randomBytes9, createHash: createHash4 } = require("crypto");
@@ -2768,7 +2768,7 @@ var require_websocket = __commonJS({
2768
2768
  }
2769
2769
  const defaultPort = isSecure ? 443 : 80;
2770
2770
  const key = randomBytes9(16).toString("base64");
2771
- const request = isSecure ? https3.request : http.request;
2771
+ const request = isSecure ? https3.request : http2.request;
2772
2772
  const protocolSet = /* @__PURE__ */ new Set();
2773
2773
  let perMessageDeflate;
2774
2774
  opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
@@ -3262,7 +3262,7 @@ var require_websocket_server = __commonJS({
3262
3262
  "node_modules/ws/lib/websocket-server.js"(exports2, module2) {
3263
3263
  "use strict";
3264
3264
  var EventEmitter6 = require("events");
3265
- var http = require("http");
3265
+ var http2 = require("http");
3266
3266
  var { Duplex } = require("stream");
3267
3267
  var { createHash: createHash4 } = require("crypto");
3268
3268
  var extension2 = require_extension();
@@ -3337,8 +3337,8 @@ var require_websocket_server = __commonJS({
3337
3337
  );
3338
3338
  }
3339
3339
  if (options.port != null) {
3340
- this._server = http.createServer((req, res) => {
3341
- const body = http.STATUS_CODES[426];
3340
+ this._server = http2.createServer((req, res) => {
3341
+ const body = http2.STATUS_CODES[426];
3342
3342
  res.writeHead(426, {
3343
3343
  "Content-Length": body.length,
3344
3344
  "Content-Type": "text/plain"
@@ -3625,7 +3625,7 @@ var require_websocket_server = __commonJS({
3625
3625
  this.destroy();
3626
3626
  }
3627
3627
  function abortHandshake(socket, code, message, headers) {
3628
- message = message || http.STATUS_CODES[code];
3628
+ message = message || http2.STATUS_CODES[code];
3629
3629
  headers = {
3630
3630
  Connection: "close",
3631
3631
  "Content-Type": "text/html",
@@ -3634,7 +3634,7 @@ var require_websocket_server = __commonJS({
3634
3634
  };
3635
3635
  socket.once("finish", socket.destroy);
3636
3636
  socket.end(
3637
- `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
3637
+ `HTTP/1.1 ${code} ${http2.STATUS_CODES[code]}\r
3638
3638
  ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
3639
3639
  );
3640
3640
  }
@@ -4531,15 +4531,15 @@ var require_route = __commonJS({
4531
4531
  };
4532
4532
  }
4533
4533
  function wrapConversion(toModel, graph) {
4534
- const path25 = [graph[toModel].parent, toModel];
4534
+ const path28 = [graph[toModel].parent, toModel];
4535
4535
  let fn2 = conversions[graph[toModel].parent][toModel];
4536
4536
  let cur = graph[toModel].parent;
4537
4537
  while (graph[cur].parent) {
4538
- path25.unshift(graph[cur].parent);
4538
+ path28.unshift(graph[cur].parent);
4539
4539
  fn2 = link2(conversions[graph[cur].parent][cur], fn2);
4540
4540
  cur = graph[cur].parent;
4541
4541
  }
4542
- fn2.conversion = path25;
4542
+ fn2.conversion = path28;
4543
4543
  return fn2;
4544
4544
  }
4545
4545
  module2.exports = function(fromModel) {
@@ -4779,7 +4779,7 @@ var require_has_flag = __commonJS({
4779
4779
  var require_supports_color = __commonJS({
4780
4780
  "node_modules/supports-color/index.js"(exports2, module2) {
4781
4781
  "use strict";
4782
- var os12 = require("os");
4782
+ var os14 = require("os");
4783
4783
  var tty = require("tty");
4784
4784
  var hasFlag = require_has_flag();
4785
4785
  var { env } = process;
@@ -4827,7 +4827,7 @@ var require_supports_color = __commonJS({
4827
4827
  return min;
4828
4828
  }
4829
4829
  if (process.platform === "win32") {
4830
- const osRelease = os12.release().split(".");
4830
+ const osRelease = os14.release().split(".");
4831
4831
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
4832
4832
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
4833
4833
  }
@@ -5505,7 +5505,7 @@ var require_ignore = __commonJS({
5505
5505
  // path matching.
5506
5506
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
5507
5507
  // @returns {TestResult} true if a file is ignored
5508
- test(path25, checkUnignored, mode) {
5508
+ test(path28, checkUnignored, mode) {
5509
5509
  let ignored = false;
5510
5510
  let unignored = false;
5511
5511
  let matchedRule;
@@ -5514,7 +5514,7 @@ var require_ignore = __commonJS({
5514
5514
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
5515
5515
  return;
5516
5516
  }
5517
- const matched = rule[mode].test(path25);
5517
+ const matched = rule[mode].test(path28);
5518
5518
  if (!matched) {
5519
5519
  return;
5520
5520
  }
@@ -5535,17 +5535,17 @@ var require_ignore = __commonJS({
5535
5535
  var throwError = (message, Ctor) => {
5536
5536
  throw new Ctor(message);
5537
5537
  };
5538
- var checkPath = (path25, originalPath, doThrow) => {
5539
- if (!isString2(path25)) {
5538
+ var checkPath = (path28, originalPath, doThrow) => {
5539
+ if (!isString2(path28)) {
5540
5540
  return doThrow(
5541
5541
  `path must be a string, but got \`${originalPath}\``,
5542
5542
  TypeError
5543
5543
  );
5544
5544
  }
5545
- if (!path25) {
5545
+ if (!path28) {
5546
5546
  return doThrow(`path must not be empty`, TypeError);
5547
5547
  }
5548
- if (checkPath.isNotRelative(path25)) {
5548
+ if (checkPath.isNotRelative(path28)) {
5549
5549
  const r = "`path.relative()`d";
5550
5550
  return doThrow(
5551
5551
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -5554,7 +5554,7 @@ var require_ignore = __commonJS({
5554
5554
  }
5555
5555
  return true;
5556
5556
  };
5557
- var isNotRelative = (path25) => REGEX_TEST_INVALID_PATH.test(path25);
5557
+ var isNotRelative = (path28) => REGEX_TEST_INVALID_PATH.test(path28);
5558
5558
  checkPath.isNotRelative = isNotRelative;
5559
5559
  checkPath.convert = (p2) => p2;
5560
5560
  var Ignore = class {
@@ -5584,19 +5584,19 @@ var require_ignore = __commonJS({
5584
5584
  }
5585
5585
  // @returns {TestResult}
5586
5586
  _test(originalPath, cache, checkUnignored, slices) {
5587
- const path25 = originalPath && checkPath.convert(originalPath);
5587
+ const path28 = originalPath && checkPath.convert(originalPath);
5588
5588
  checkPath(
5589
- path25,
5589
+ path28,
5590
5590
  originalPath,
5591
5591
  this._strictPathCheck ? throwError : RETURN_FALSE
5592
5592
  );
5593
- return this._t(path25, cache, checkUnignored, slices);
5593
+ return this._t(path28, cache, checkUnignored, slices);
5594
5594
  }
5595
- checkIgnore(path25) {
5596
- if (!REGEX_TEST_TRAILING_SLASH.test(path25)) {
5597
- return this.test(path25);
5595
+ checkIgnore(path28) {
5596
+ if (!REGEX_TEST_TRAILING_SLASH.test(path28)) {
5597
+ return this.test(path28);
5598
5598
  }
5599
- const slices = path25.split(SLASH).filter(Boolean);
5599
+ const slices = path28.split(SLASH).filter(Boolean);
5600
5600
  slices.pop();
5601
5601
  if (slices.length) {
5602
5602
  const parent = this._t(
@@ -5609,18 +5609,18 @@ var require_ignore = __commonJS({
5609
5609
  return parent;
5610
5610
  }
5611
5611
  }
5612
- return this._rules.test(path25, false, MODE_CHECK_IGNORE);
5612
+ return this._rules.test(path28, false, MODE_CHECK_IGNORE);
5613
5613
  }
5614
- _t(path25, cache, checkUnignored, slices) {
5615
- if (path25 in cache) {
5616
- return cache[path25];
5614
+ _t(path28, cache, checkUnignored, slices) {
5615
+ if (path28 in cache) {
5616
+ return cache[path28];
5617
5617
  }
5618
5618
  if (!slices) {
5619
- slices = path25.split(SLASH).filter(Boolean);
5619
+ slices = path28.split(SLASH).filter(Boolean);
5620
5620
  }
5621
5621
  slices.pop();
5622
5622
  if (!slices.length) {
5623
- return cache[path25] = this._rules.test(path25, checkUnignored, MODE_IGNORE);
5623
+ return cache[path28] = this._rules.test(path28, checkUnignored, MODE_IGNORE);
5624
5624
  }
5625
5625
  const parent = this._t(
5626
5626
  slices.join(SLASH) + SLASH,
@@ -5628,29 +5628,29 @@ var require_ignore = __commonJS({
5628
5628
  checkUnignored,
5629
5629
  slices
5630
5630
  );
5631
- return cache[path25] = parent.ignored ? parent : this._rules.test(path25, checkUnignored, MODE_IGNORE);
5631
+ return cache[path28] = parent.ignored ? parent : this._rules.test(path28, checkUnignored, MODE_IGNORE);
5632
5632
  }
5633
- ignores(path25) {
5634
- return this._test(path25, this._ignoreCache, false).ignored;
5633
+ ignores(path28) {
5634
+ return this._test(path28, this._ignoreCache, false).ignored;
5635
5635
  }
5636
5636
  createFilter() {
5637
- return (path25) => !this.ignores(path25);
5637
+ return (path28) => !this.ignores(path28);
5638
5638
  }
5639
5639
  filter(paths) {
5640
5640
  return makeArray(paths).filter(this.createFilter());
5641
5641
  }
5642
5642
  // @returns {TestResult}
5643
- test(path25) {
5644
- return this._test(path25, this._testCache, true);
5643
+ test(path28) {
5644
+ return this._test(path28, this._testCache, true);
5645
5645
  }
5646
5646
  };
5647
5647
  var factory = (options) => new Ignore(options);
5648
- var isPathValid = (path25) => checkPath(path25 && checkPath.convert(path25), path25, RETURN_FALSE);
5648
+ var isPathValid = (path28) => checkPath(path28 && checkPath.convert(path28), path28, RETURN_FALSE);
5649
5649
  var setupWindows = () => {
5650
5650
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
5651
5651
  checkPath.convert = makePosix;
5652
5652
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
5653
- checkPath.isNotRelative = (path25) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path25) || isNotRelative(path25);
5653
+ checkPath.isNotRelative = (path28) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path28) || isNotRelative(path28);
5654
5654
  };
5655
5655
  if (
5656
5656
  // Detect `process` so that it can run in browsers.
@@ -5742,17 +5742,17 @@ var require_visit = __commonJS({
5742
5742
  visit.BREAK = BREAK;
5743
5743
  visit.SKIP = SKIP;
5744
5744
  visit.REMOVE = REMOVE;
5745
- function visit_(key, node, visitor, path25) {
5746
- const ctrl = callVisitor(key, node, visitor, path25);
5745
+ function visit_(key, node, visitor, path28) {
5746
+ const ctrl = callVisitor(key, node, visitor, path28);
5747
5747
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
5748
- replaceNode(key, path25, ctrl);
5749
- return visit_(key, ctrl, visitor, path25);
5748
+ replaceNode(key, path28, ctrl);
5749
+ return visit_(key, ctrl, visitor, path28);
5750
5750
  }
5751
5751
  if (typeof ctrl !== "symbol") {
5752
5752
  if (identity.isCollection(node)) {
5753
- path25 = Object.freeze(path25.concat(node));
5753
+ path28 = Object.freeze(path28.concat(node));
5754
5754
  for (let i = 0; i < node.items.length; ++i) {
5755
- const ci2 = visit_(i, node.items[i], visitor, path25);
5755
+ const ci2 = visit_(i, node.items[i], visitor, path28);
5756
5756
  if (typeof ci2 === "number")
5757
5757
  i = ci2 - 1;
5758
5758
  else if (ci2 === BREAK)
@@ -5763,13 +5763,13 @@ var require_visit = __commonJS({
5763
5763
  }
5764
5764
  }
5765
5765
  } else if (identity.isPair(node)) {
5766
- path25 = Object.freeze(path25.concat(node));
5767
- const ck = visit_("key", node.key, visitor, path25);
5766
+ path28 = Object.freeze(path28.concat(node));
5767
+ const ck = visit_("key", node.key, visitor, path28);
5768
5768
  if (ck === BREAK)
5769
5769
  return BREAK;
5770
5770
  else if (ck === REMOVE)
5771
5771
  node.key = null;
5772
- const cv = visit_("value", node.value, visitor, path25);
5772
+ const cv = visit_("value", node.value, visitor, path28);
5773
5773
  if (cv === BREAK)
5774
5774
  return BREAK;
5775
5775
  else if (cv === REMOVE)
@@ -5790,17 +5790,17 @@ var require_visit = __commonJS({
5790
5790
  visitAsync.BREAK = BREAK;
5791
5791
  visitAsync.SKIP = SKIP;
5792
5792
  visitAsync.REMOVE = REMOVE;
5793
- async function visitAsync_(key, node, visitor, path25) {
5794
- const ctrl = await callVisitor(key, node, visitor, path25);
5793
+ async function visitAsync_(key, node, visitor, path28) {
5794
+ const ctrl = await callVisitor(key, node, visitor, path28);
5795
5795
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
5796
- replaceNode(key, path25, ctrl);
5797
- return visitAsync_(key, ctrl, visitor, path25);
5796
+ replaceNode(key, path28, ctrl);
5797
+ return visitAsync_(key, ctrl, visitor, path28);
5798
5798
  }
5799
5799
  if (typeof ctrl !== "symbol") {
5800
5800
  if (identity.isCollection(node)) {
5801
- path25 = Object.freeze(path25.concat(node));
5801
+ path28 = Object.freeze(path28.concat(node));
5802
5802
  for (let i = 0; i < node.items.length; ++i) {
5803
- const ci2 = await visitAsync_(i, node.items[i], visitor, path25);
5803
+ const ci2 = await visitAsync_(i, node.items[i], visitor, path28);
5804
5804
  if (typeof ci2 === "number")
5805
5805
  i = ci2 - 1;
5806
5806
  else if (ci2 === BREAK)
@@ -5811,13 +5811,13 @@ var require_visit = __commonJS({
5811
5811
  }
5812
5812
  }
5813
5813
  } else if (identity.isPair(node)) {
5814
- path25 = Object.freeze(path25.concat(node));
5815
- const ck = await visitAsync_("key", node.key, visitor, path25);
5814
+ path28 = Object.freeze(path28.concat(node));
5815
+ const ck = await visitAsync_("key", node.key, visitor, path28);
5816
5816
  if (ck === BREAK)
5817
5817
  return BREAK;
5818
5818
  else if (ck === REMOVE)
5819
5819
  node.key = null;
5820
- const cv = await visitAsync_("value", node.value, visitor, path25);
5820
+ const cv = await visitAsync_("value", node.value, visitor, path28);
5821
5821
  if (cv === BREAK)
5822
5822
  return BREAK;
5823
5823
  else if (cv === REMOVE)
@@ -5844,23 +5844,23 @@ var require_visit = __commonJS({
5844
5844
  }
5845
5845
  return visitor;
5846
5846
  }
5847
- function callVisitor(key, node, visitor, path25) {
5847
+ function callVisitor(key, node, visitor, path28) {
5848
5848
  if (typeof visitor === "function")
5849
- return visitor(key, node, path25);
5849
+ return visitor(key, node, path28);
5850
5850
  if (identity.isMap(node))
5851
- return visitor.Map?.(key, node, path25);
5851
+ return visitor.Map?.(key, node, path28);
5852
5852
  if (identity.isSeq(node))
5853
- return visitor.Seq?.(key, node, path25);
5853
+ return visitor.Seq?.(key, node, path28);
5854
5854
  if (identity.isPair(node))
5855
- return visitor.Pair?.(key, node, path25);
5855
+ return visitor.Pair?.(key, node, path28);
5856
5856
  if (identity.isScalar(node))
5857
- return visitor.Scalar?.(key, node, path25);
5857
+ return visitor.Scalar?.(key, node, path28);
5858
5858
  if (identity.isAlias(node))
5859
- return visitor.Alias?.(key, node, path25);
5859
+ return visitor.Alias?.(key, node, path28);
5860
5860
  return void 0;
5861
5861
  }
5862
- function replaceNode(key, path25, node) {
5863
- const parent = path25[path25.length - 1];
5862
+ function replaceNode(key, path28, node) {
5863
+ const parent = path28[path28.length - 1];
5864
5864
  if (identity.isCollection(parent)) {
5865
5865
  parent.items[key] = node;
5866
5866
  } else if (identity.isPair(parent)) {
@@ -6470,10 +6470,10 @@ var require_Collection = __commonJS({
6470
6470
  var createNode = require_createNode();
6471
6471
  var identity = require_identity();
6472
6472
  var Node = require_Node();
6473
- function collectionFromPath(schema, path25, value) {
6473
+ function collectionFromPath(schema, path28, value) {
6474
6474
  let v2 = value;
6475
- for (let i = path25.length - 1; i >= 0; --i) {
6476
- const k2 = path25[i];
6475
+ for (let i = path28.length - 1; i >= 0; --i) {
6476
+ const k2 = path28[i];
6477
6477
  if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
6478
6478
  const a = [];
6479
6479
  a[k2] = v2;
@@ -6492,7 +6492,7 @@ var require_Collection = __commonJS({
6492
6492
  sourceObjects: /* @__PURE__ */ new Map()
6493
6493
  });
6494
6494
  }
6495
- var isEmptyPath = (path25) => path25 == null || typeof path25 === "object" && !!path25[Symbol.iterator]().next().done;
6495
+ var isEmptyPath = (path28) => path28 == null || typeof path28 === "object" && !!path28[Symbol.iterator]().next().done;
6496
6496
  var Collection = class extends Node.NodeBase {
6497
6497
  constructor(type, schema) {
6498
6498
  super(type);
@@ -6522,11 +6522,11 @@ var require_Collection = __commonJS({
6522
6522
  * be a Pair instance or a `{ key, value }` object, which may not have a key
6523
6523
  * that already exists in the map.
6524
6524
  */
6525
- addIn(path25, value) {
6526
- if (isEmptyPath(path25))
6525
+ addIn(path28, value) {
6526
+ if (isEmptyPath(path28))
6527
6527
  this.add(value);
6528
6528
  else {
6529
- const [key, ...rest] = path25;
6529
+ const [key, ...rest] = path28;
6530
6530
  const node = this.get(key, true);
6531
6531
  if (identity.isCollection(node))
6532
6532
  node.addIn(rest, value);
@@ -6540,8 +6540,8 @@ var require_Collection = __commonJS({
6540
6540
  * Removes a value from the collection.
6541
6541
  * @returns `true` if the item was found and removed.
6542
6542
  */
6543
- deleteIn(path25) {
6544
- const [key, ...rest] = path25;
6543
+ deleteIn(path28) {
6544
+ const [key, ...rest] = path28;
6545
6545
  if (rest.length === 0)
6546
6546
  return this.delete(key);
6547
6547
  const node = this.get(key, true);
@@ -6555,8 +6555,8 @@ var require_Collection = __commonJS({
6555
6555
  * scalar values from their surrounding node; to disable set `keepScalar` to
6556
6556
  * `true` (collections are always returned intact).
6557
6557
  */
6558
- getIn(path25, keepScalar) {
6559
- const [key, ...rest] = path25;
6558
+ getIn(path28, keepScalar) {
6559
+ const [key, ...rest] = path28;
6560
6560
  const node = this.get(key, true);
6561
6561
  if (rest.length === 0)
6562
6562
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -6574,8 +6574,8 @@ var require_Collection = __commonJS({
6574
6574
  /**
6575
6575
  * Checks if the collection includes a value with the key `key`.
6576
6576
  */
6577
- hasIn(path25) {
6578
- const [key, ...rest] = path25;
6577
+ hasIn(path28) {
6578
+ const [key, ...rest] = path28;
6579
6579
  if (rest.length === 0)
6580
6580
  return this.has(key);
6581
6581
  const node = this.get(key, true);
@@ -6585,8 +6585,8 @@ var require_Collection = __commonJS({
6585
6585
  * Sets a value in this collection. For `!!set`, `value` needs to be a
6586
6586
  * boolean to add/remove the item from the set.
6587
6587
  */
6588
- setIn(path25, value) {
6589
- const [key, ...rest] = path25;
6588
+ setIn(path28, value) {
6589
+ const [key, ...rest] = path28;
6590
6590
  if (rest.length === 0) {
6591
6591
  this.set(key, value);
6592
6592
  } else {
@@ -9101,9 +9101,9 @@ var require_Document = __commonJS({
9101
9101
  this.contents.add(value);
9102
9102
  }
9103
9103
  /** Adds a value to the document. */
9104
- addIn(path25, value) {
9104
+ addIn(path28, value) {
9105
9105
  if (assertCollection(this.contents))
9106
- this.contents.addIn(path25, value);
9106
+ this.contents.addIn(path28, value);
9107
9107
  }
9108
9108
  /**
9109
9109
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -9178,14 +9178,14 @@ var require_Document = __commonJS({
9178
9178
  * Removes a value from the document.
9179
9179
  * @returns `true` if the item was found and removed.
9180
9180
  */
9181
- deleteIn(path25) {
9182
- if (Collection.isEmptyPath(path25)) {
9181
+ deleteIn(path28) {
9182
+ if (Collection.isEmptyPath(path28)) {
9183
9183
  if (this.contents == null)
9184
9184
  return false;
9185
9185
  this.contents = null;
9186
9186
  return true;
9187
9187
  }
9188
- return assertCollection(this.contents) ? this.contents.deleteIn(path25) : false;
9188
+ return assertCollection(this.contents) ? this.contents.deleteIn(path28) : false;
9189
9189
  }
9190
9190
  /**
9191
9191
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -9200,10 +9200,10 @@ var require_Document = __commonJS({
9200
9200
  * scalar values from their surrounding node; to disable set `keepScalar` to
9201
9201
  * `true` (collections are always returned intact).
9202
9202
  */
9203
- getIn(path25, keepScalar) {
9204
- if (Collection.isEmptyPath(path25))
9203
+ getIn(path28, keepScalar) {
9204
+ if (Collection.isEmptyPath(path28))
9205
9205
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
9206
- return identity.isCollection(this.contents) ? this.contents.getIn(path25, keepScalar) : void 0;
9206
+ return identity.isCollection(this.contents) ? this.contents.getIn(path28, keepScalar) : void 0;
9207
9207
  }
9208
9208
  /**
9209
9209
  * Checks if the document includes a value with the key `key`.
@@ -9214,10 +9214,10 @@ var require_Document = __commonJS({
9214
9214
  /**
9215
9215
  * Checks if the document includes a value at `path`.
9216
9216
  */
9217
- hasIn(path25) {
9218
- if (Collection.isEmptyPath(path25))
9217
+ hasIn(path28) {
9218
+ if (Collection.isEmptyPath(path28))
9219
9219
  return this.contents !== void 0;
9220
- return identity.isCollection(this.contents) ? this.contents.hasIn(path25) : false;
9220
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path28) : false;
9221
9221
  }
9222
9222
  /**
9223
9223
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -9234,13 +9234,13 @@ var require_Document = __commonJS({
9234
9234
  * Sets a value in this document. For `!!set`, `value` needs to be a
9235
9235
  * boolean to add/remove the item from the set.
9236
9236
  */
9237
- setIn(path25, value) {
9238
- if (Collection.isEmptyPath(path25)) {
9237
+ setIn(path28, value) {
9238
+ if (Collection.isEmptyPath(path28)) {
9239
9239
  this.contents = value;
9240
9240
  } else if (this.contents == null) {
9241
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path25), value);
9241
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path28), value);
9242
9242
  } else if (assertCollection(this.contents)) {
9243
- this.contents.setIn(path25, value);
9243
+ this.contents.setIn(path28, value);
9244
9244
  }
9245
9245
  }
9246
9246
  /**
@@ -11198,9 +11198,9 @@ var require_cst_visit = __commonJS({
11198
11198
  visit.BREAK = BREAK;
11199
11199
  visit.SKIP = SKIP;
11200
11200
  visit.REMOVE = REMOVE;
11201
- visit.itemAtPath = (cst, path25) => {
11201
+ visit.itemAtPath = (cst, path28) => {
11202
11202
  let item = cst;
11203
- for (const [field, index] of path25) {
11203
+ for (const [field, index] of path28) {
11204
11204
  const tok = item?.[field];
11205
11205
  if (tok && "items" in tok) {
11206
11206
  item = tok.items[index];
@@ -11209,23 +11209,23 @@ var require_cst_visit = __commonJS({
11209
11209
  }
11210
11210
  return item;
11211
11211
  };
11212
- visit.parentCollection = (cst, path25) => {
11213
- const parent = visit.itemAtPath(cst, path25.slice(0, -1));
11214
- const field = path25[path25.length - 1][0];
11212
+ visit.parentCollection = (cst, path28) => {
11213
+ const parent = visit.itemAtPath(cst, path28.slice(0, -1));
11214
+ const field = path28[path28.length - 1][0];
11215
11215
  const coll = parent?.[field];
11216
11216
  if (coll && "items" in coll)
11217
11217
  return coll;
11218
11218
  throw new Error("Parent collection not found");
11219
11219
  };
11220
- function _visit(path25, item, visitor) {
11221
- let ctrl = visitor(item, path25);
11220
+ function _visit(path28, item, visitor) {
11221
+ let ctrl = visitor(item, path28);
11222
11222
  if (typeof ctrl === "symbol")
11223
11223
  return ctrl;
11224
11224
  for (const field of ["key", "value"]) {
11225
11225
  const token = item[field];
11226
11226
  if (token && "items" in token) {
11227
11227
  for (let i = 0; i < token.items.length; ++i) {
11228
- const ci2 = _visit(Object.freeze(path25.concat([[field, i]])), token.items[i], visitor);
11228
+ const ci2 = _visit(Object.freeze(path28.concat([[field, i]])), token.items[i], visitor);
11229
11229
  if (typeof ci2 === "number")
11230
11230
  i = ci2 - 1;
11231
11231
  else if (ci2 === BREAK)
@@ -11236,10 +11236,10 @@ var require_cst_visit = __commonJS({
11236
11236
  }
11237
11237
  }
11238
11238
  if (typeof ctrl === "function" && field === "key")
11239
- ctrl = ctrl(item, path25);
11239
+ ctrl = ctrl(item, path28);
11240
11240
  }
11241
11241
  }
11242
- return typeof ctrl === "function" ? ctrl(item, path25) : ctrl;
11242
+ return typeof ctrl === "function" ? ctrl(item, path28) : ctrl;
11243
11243
  }
11244
11244
  exports2.visit = visit;
11245
11245
  }
@@ -12524,14 +12524,14 @@ var require_parser = __commonJS({
12524
12524
  case "scalar":
12525
12525
  case "single-quoted-scalar":
12526
12526
  case "double-quoted-scalar": {
12527
- const fs13 = this.flowScalar(this.type);
12527
+ const fs15 = this.flowScalar(this.type);
12528
12528
  if (atNextItem || it2.value) {
12529
- map2.items.push({ start, key: fs13, sep: [] });
12529
+ map2.items.push({ start, key: fs15, sep: [] });
12530
12530
  this.onKeyLine = true;
12531
12531
  } else if (it2.sep) {
12532
- this.stack.push(fs13);
12532
+ this.stack.push(fs15);
12533
12533
  } else {
12534
- Object.assign(it2, { key: fs13, sep: [] });
12534
+ Object.assign(it2, { key: fs15, sep: [] });
12535
12535
  this.onKeyLine = true;
12536
12536
  }
12537
12537
  return;
@@ -12659,13 +12659,13 @@ var require_parser = __commonJS({
12659
12659
  case "scalar":
12660
12660
  case "single-quoted-scalar":
12661
12661
  case "double-quoted-scalar": {
12662
- const fs13 = this.flowScalar(this.type);
12662
+ const fs15 = this.flowScalar(this.type);
12663
12663
  if (!it2 || it2.value)
12664
- fc.items.push({ start: [], key: fs13, sep: [] });
12664
+ fc.items.push({ start: [], key: fs15, sep: [] });
12665
12665
  else if (it2.sep)
12666
- this.stack.push(fs13);
12666
+ this.stack.push(fs15);
12667
12667
  else
12668
- Object.assign(it2, { key: fs13, sep: [] });
12668
+ Object.assign(it2, { key: fs15, sep: [] });
12669
12669
  return;
12670
12670
  }
12671
12671
  case "flow-map-end":
@@ -13397,11 +13397,11 @@ __export(base_exports, {
13397
13397
  setCwd: () => setCwd,
13398
13398
  synchronizedOutput: () => synchronizedOutput
13399
13399
  });
13400
- var import_node_process, import_node_os11, 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;
13400
+ 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;
13401
13401
  var init_base = __esm({
13402
13402
  "node_modules/ansi-escapes/base.js"() {
13403
13403
  import_node_process = __toESM(require("node:process"), 1);
13404
- import_node_os11 = __toESM(require("node:os"), 1);
13404
+ import_node_os13 = __toESM(require("node:os"), 1);
13405
13405
  init_environment();
13406
13406
  ESC = "\x1B[";
13407
13407
  OSC = "\x1B]";
@@ -13481,7 +13481,7 @@ var init_base = __esm({
13481
13481
  if (isBrowser || !isWindows2) {
13482
13482
  return false;
13483
13483
  }
13484
- const parts = import_node_os11.default.release().split(".");
13484
+ const parts = import_node_os13.default.release().split(".");
13485
13485
  const major = Number(parts[0]);
13486
13486
  const build = Number(parts[2] ?? 0);
13487
13487
  if (major < 10) {
@@ -18838,8 +18838,8 @@ function repoEndpoint(owner, repo, suffix = "") {
18838
18838
  assertOwnerRepo(owner, repo);
18839
18839
  return `/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}${suffix}`;
18840
18840
  }
18841
- function contentsEndpoint(owner, repo, path25 = "") {
18842
- const normalizedPath = normalizeRepoPath(path25);
18841
+ function contentsEndpoint(owner, repo, path28 = "") {
18842
+ const normalizedPath = normalizeRepoPath(path28);
18843
18843
  const suffix = normalizedPath ? `/contents/${encodeRepoPath(normalizedPath)}` : "/contents";
18844
18844
  return repoEndpoint(owner, repo, suffix);
18845
18845
  }
@@ -18847,8 +18847,8 @@ function branchEndpoint(owner, repo, branch) {
18847
18847
  const normalizedBranch = assertNonEmptyString(branch, "branch");
18848
18848
  return repoEndpoint(owner, repo, `/branches/${encodeURIComponent(normalizedBranch)}`);
18849
18849
  }
18850
- function normalizeRepoPath(path25) {
18851
- return path25?.trim().replace(/^\/+/, "").replace(/\/+$/, "") ?? "";
18850
+ function normalizeRepoPath(path28) {
18851
+ return path28?.trim().replace(/^\/+/, "").replace(/\/+$/, "") ?? "";
18852
18852
  }
18853
18853
  function normalizePerPage(perPage) {
18854
18854
  if (typeof perPage === "undefined") {
@@ -18874,9 +18874,9 @@ function hasDefinedValue(values) {
18874
18874
  function optionalRecord(value) {
18875
18875
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
18876
18876
  }
18877
- function appendQuery(path25, query) {
18877
+ function appendQuery(path28, query) {
18878
18878
  if (!query) {
18879
- return path25;
18879
+ return path28;
18880
18880
  }
18881
18881
  const params = new URLSearchParams();
18882
18882
  for (const [name, rawValue] of Object.entries(query)) {
@@ -18889,9 +18889,9 @@ function appendQuery(path25, query) {
18889
18889
  }
18890
18890
  const serialized = params.toString();
18891
18891
  if (!serialized) {
18892
- return path25;
18892
+ return path28;
18893
18893
  }
18894
- return `${path25}${path25.includes("?") ? "&" : "?"}${serialized}`;
18894
+ return `${path28}${path28.includes("?") ? "&" : "?"}${serialized}`;
18895
18895
  }
18896
18896
  function nonEmpty(value) {
18897
18897
  const trimmed = value?.trim();
@@ -18966,8 +18966,8 @@ function visibilityValue(value, isPrivate) {
18966
18966
  function errorMessage(error51) {
18967
18967
  return error51 instanceof Error ? error51.message : String(error51);
18968
18968
  }
18969
- function encodeRepoPath(path25) {
18970
- return path25.split("/").map(encodeURIComponent).join("/");
18969
+ function encodeRepoPath(path28) {
18970
+ return path28.split("/").map(encodeURIComponent).join("/");
18971
18971
  }
18972
18972
  var init_utils = __esm({
18973
18973
  "packages/github-primitive/src/actions/utils.ts"() {
@@ -19104,10 +19104,10 @@ var init_commits = __esm({
19104
19104
  });
19105
19105
 
19106
19106
  // packages/github-primitive/src/actions/files.ts
19107
- async function listFiles(adapter, owner, repo, path25 = "", options = {}) {
19108
- return withActionError(`list GitHub files at ${owner}/${repo}/${path25}`, async () => {
19107
+ async function listFiles(adapter, owner, repo, path28 = "", options = {}) {
19108
+ return withActionError(`list GitHub files at ${owner}/${repo}/${path28}`, async () => {
19109
19109
  assertOwnerRepo(owner, repo);
19110
- const response = await adapter.request("GET", contentsEndpoint(owner, repo, path25), {
19110
+ const response = await adapter.request("GET", contentsEndpoint(owner, repo, path28), {
19111
19111
  query: {
19112
19112
  ref: options.ref
19113
19113
  }
@@ -19115,32 +19115,32 @@ async function listFiles(adapter, owner, repo, path25 = "", options = {}) {
19115
19115
  return Array.isArray(response) ? asArray(response, "repository contents").map(mapFile) : [mapFile(response)];
19116
19116
  });
19117
19117
  }
19118
- async function readFile3(adapter, owner, repo, path25, ref) {
19119
- return withActionError(`read GitHub file ${owner}/${repo}/${path25}`, async () => {
19118
+ async function readFile3(adapter, owner, repo, path28, ref) {
19119
+ return withActionError(`read GitHub file ${owner}/${repo}/${path28}`, async () => {
19120
19120
  assertOwnerRepo(owner, repo);
19121
- assertNonEmptyString(normalizeRepoPath(path25), "file path");
19122
- const response = await adapter.request("GET", contentsEndpoint(owner, repo, path25), {
19121
+ assertNonEmptyString(normalizeRepoPath(path28), "file path");
19122
+ const response = await adapter.request("GET", contentsEndpoint(owner, repo, path28), {
19123
19123
  query: {
19124
19124
  ref
19125
19125
  }
19126
19126
  });
19127
19127
  const file2 = mapFile(response);
19128
19128
  if (file2.type !== "file") {
19129
- throw new Error(`GitHub path "${path25}" is not a file.`);
19129
+ throw new Error(`GitHub path "${path28}" is not a file.`);
19130
19130
  }
19131
19131
  if (!file2.content) {
19132
- throw new Error(`GitHub file "${path25}" did not include content in the API response.`);
19132
+ throw new Error(`GitHub file "${path28}" did not include content in the API response.`);
19133
19133
  }
19134
19134
  if (file2.encoding && file2.encoding !== "base64") {
19135
- throw new Error(`GitHub file "${path25}" used unsupported encoding "${file2.encoding}".`);
19135
+ throw new Error(`GitHub file "${path28}" used unsupported encoding "${file2.encoding}".`);
19136
19136
  }
19137
19137
  return import_node_buffer.Buffer.from(file2.content.replace(/\s/g, ""), "base64").toString("utf8");
19138
19138
  });
19139
19139
  }
19140
- async function createFile(adapter, owner, repo, path25, content, message, options = {}) {
19141
- return withActionError(`create GitHub file ${owner}/${repo}/${path25}`, async () => {
19140
+ async function createFile(adapter, owner, repo, path28, content, message, options = {}) {
19141
+ return withActionError(`create GitHub file ${owner}/${repo}/${path28}`, async () => {
19142
19142
  assertOwnerRepo(owner, repo);
19143
- const normalizedPath = assertNonEmptyString(normalizeRepoPath(path25), "file path");
19143
+ const normalizedPath = assertNonEmptyString(normalizeRepoPath(path28), "file path");
19144
19144
  const commitMessage = assertNonEmptyString(message, "commit message");
19145
19145
  await adapter.request("PUT", contentsEndpoint(owner, repo, normalizedPath), {
19146
19146
  body: removeUndefinedValues({
@@ -19152,10 +19152,10 @@ async function createFile(adapter, owner, repo, path25, content, message, option
19152
19152
  });
19153
19153
  });
19154
19154
  }
19155
- async function updateFile(adapter, owner, repo, path25, content, message, sha, options = {}) {
19156
- return withActionError(`update GitHub file ${owner}/${repo}/${path25}`, async () => {
19155
+ async function updateFile(adapter, owner, repo, path28, content, message, sha, options = {}) {
19156
+ return withActionError(`update GitHub file ${owner}/${repo}/${path28}`, async () => {
19157
19157
  assertOwnerRepo(owner, repo);
19158
- const normalizedPath = assertNonEmptyString(normalizeRepoPath(path25), "file path");
19158
+ const normalizedPath = assertNonEmptyString(normalizeRepoPath(path28), "file path");
19159
19159
  const commitMessage = assertNonEmptyString(message, "commit message");
19160
19160
  const fileSha = assertNonEmptyString(sha, "file sha");
19161
19161
  const response = await adapter.request("PUT", contentsEndpoint(owner, repo, normalizedPath), {
@@ -19171,10 +19171,10 @@ async function updateFile(adapter, owner, repo, path25, content, message, sha, o
19171
19171
  return mapFile(contentRecord);
19172
19172
  });
19173
19173
  }
19174
- async function deleteFile(adapter, owner, repo, path25, sha, message, options = {}) {
19175
- return withActionError(`delete GitHub file ${owner}/${repo}/${path25}`, async () => {
19174
+ async function deleteFile(adapter, owner, repo, path28, sha, message, options = {}) {
19175
+ return withActionError(`delete GitHub file ${owner}/${repo}/${path28}`, async () => {
19176
19176
  assertOwnerRepo(owner, repo);
19177
- const normalizedPath = assertNonEmptyString(normalizeRepoPath(path25), "file path");
19177
+ const normalizedPath = assertNonEmptyString(normalizeRepoPath(path28), "file path");
19178
19178
  const fileSha = assertNonEmptyString(sha, "file sha");
19179
19179
  const commitMessage = assertNonEmptyString(message, "commit message");
19180
19180
  await adapter.request("DELETE", contentsEndpoint(owner, repo, normalizedPath), {
@@ -19538,15 +19538,15 @@ var init_repos = __esm({
19538
19538
  // packages/github-primitive/src/actions/users.ts
19539
19539
  async function getUser(adapter, params = {}) {
19540
19540
  return withActionError("get GitHub user", async () => {
19541
- const path25 = params.username ? `/users/${encodeURIComponent(assertNonEmptyString(params.username, "username"))}` : "/user";
19542
- const response = await adapter.request("GET", path25);
19541
+ const path28 = params.username ? `/users/${encodeURIComponent(assertNonEmptyString(params.username, "username"))}` : "/user";
19542
+ const response = await adapter.request("GET", path28);
19543
19543
  return mapUser(response);
19544
19544
  });
19545
19545
  }
19546
19546
  async function listOrganizations(adapter, params = {}) {
19547
19547
  return withActionError("list GitHub organizations", async () => {
19548
- const path25 = params.username ? `/users/${encodeURIComponent(assertNonEmptyString(params.username, "username"))}/orgs` : "/user/orgs";
19549
- const response = await adapter.request("GET", path25, {
19548
+ const path28 = params.username ? `/users/${encodeURIComponent(assertNonEmptyString(params.username, "username"))}/orgs` : "/user/orgs";
19549
+ const response = await adapter.request("GET", path28, {
19550
19550
  query: queryWithPerPage({}, params.perPage)
19551
19551
  });
19552
19552
  return asArray(response, "organizations").map(mapOrganization);
@@ -19588,11 +19588,11 @@ __export(local_runtime_exports, {
19588
19588
  GhCliClient: () => GhCliClient,
19589
19589
  GhCliError: () => GhCliError
19590
19590
  });
19591
- var import_node_child_process10, GhCliError, GhCliClient;
19591
+ var import_node_child_process11, GhCliError, GhCliClient;
19592
19592
  var init_local_runtime = __esm({
19593
19593
  "packages/github-primitive/src/local-runtime.ts"() {
19594
19594
  "use strict";
19595
- import_node_child_process10 = require("node:child_process");
19595
+ import_node_child_process11 = require("node:child_process");
19596
19596
  init_adapter();
19597
19597
  init_utils();
19598
19598
  init_types();
@@ -19647,9 +19647,9 @@ var init_local_runtime = __esm({
19647
19647
  type: user.type
19648
19648
  };
19649
19649
  }
19650
- async request(method, path25, options = {}) {
19650
+ async request(method, path28, options = {}) {
19651
19651
  return this.executeWithRetries(async () => {
19652
- const request = this.buildApiCommand(method, path25, options);
19652
+ const request = this.buildApiCommand(method, path28, options);
19653
19653
  const result = await this.runGhCommand(request.args, {
19654
19654
  input: request.input,
19655
19655
  parseJson: true,
@@ -19669,7 +19669,7 @@ var init_local_runtime = __esm({
19669
19669
  ...options.env
19670
19670
  };
19671
19671
  return new Promise((resolve4, reject) => {
19672
- const child = (0, import_node_child_process10.spawn)(command, args, {
19672
+ const child = (0, import_node_child_process11.spawn)(command, args, {
19673
19673
  cwd: options.cwd ?? this.config.cwd,
19674
19674
  env,
19675
19675
  stdio: ["pipe", "pipe", "pipe"]
@@ -19783,10 +19783,10 @@ var init_local_runtime = __esm({
19783
19783
  }
19784
19784
  });
19785
19785
  }
19786
- buildApiCommand(method, path25, options) {
19786
+ buildApiCommand(method, path28, options) {
19787
19787
  const args = [
19788
19788
  "api",
19789
- appendQuery(path25, options.query),
19789
+ appendQuery(path28, options.query),
19790
19790
  "--method",
19791
19791
  method,
19792
19792
  "--header",
@@ -19863,13 +19863,13 @@ async function parseJsonResponse(response) {
19863
19863
  );
19864
19864
  }
19865
19865
  }
19866
- function buildNangoProxyUrl(baseUrl, path25, query) {
19866
+ function buildNangoProxyUrl(baseUrl, path28, query) {
19867
19867
  const base = trimTrailingSlash(baseUrl) ?? DEFAULT_NANGO_BASE_URL;
19868
- const endpoint = stripLeadingSlash(path25);
19868
+ const endpoint = stripLeadingSlash(path28);
19869
19869
  return appendQuery(`${base}/proxy/${endpoint}`, query);
19870
19870
  }
19871
- function joinUrl(baseUrl, path25) {
19872
- return `${trimTrailingSlash(baseUrl) ?? baseUrl}/${stripLeadingSlash(path25)}`;
19871
+ function joinUrl(baseUrl, path28) {
19872
+ return `${trimTrailingSlash(baseUrl) ?? baseUrl}/${stripLeadingSlash(path28)}`;
19873
19873
  }
19874
19874
  function stripLeadingSlash(value) {
19875
19875
  return value.replace(/^\/+/, "");
@@ -19923,18 +19923,18 @@ var init_cloud_runtime = __esm({
19923
19923
  type: user.type
19924
19924
  };
19925
19925
  }
19926
- async request(method, path25, options = {}) {
19926
+ async request(method, path28, options = {}) {
19927
19927
  return this.executeWithRetries(async () => {
19928
19928
  if (this.hasNangoCredentials()) {
19929
19929
  try {
19930
- return await this.requestViaNango(method, path25, options);
19930
+ return await this.requestViaNango(method, path28, options);
19931
19931
  } catch (error51) {
19932
19932
  if (!this.hasRelayCloudCredentials()) {
19933
19933
  throw error51;
19934
19934
  }
19935
19935
  this.lastNangoFallbackError = error51;
19936
19936
  try {
19937
- return await this.requestViaRelayCloud(method, path25, options);
19937
+ return await this.requestViaRelayCloud(method, path28, options);
19938
19938
  } catch (relayError) {
19939
19939
  throw new GitHubApiError(
19940
19940
  `Nango GitHub proxy failed, then relay-cloud fallback failed: ${errorMessage2(relayError)}`,
@@ -19949,7 +19949,7 @@ var init_cloud_runtime = __esm({
19949
19949
  }
19950
19950
  }
19951
19951
  if (this.hasRelayCloudCredentials()) {
19952
- return this.requestViaRelayCloud(method, path25, options);
19952
+ return this.requestViaRelayCloud(method, path28, options);
19953
19953
  }
19954
19954
  throw new GitHubApiError(
19955
19955
  "Cloud GitHub runtime requires Nango credentials or relay-cloud proxy configuration."
@@ -19962,14 +19962,14 @@ var init_cloud_runtime = __esm({
19962
19962
  getLastNangoFallbackError() {
19963
19963
  return this.lastNangoFallbackError;
19964
19964
  }
19965
- async requestViaNango(method, path25, options) {
19965
+ async requestViaNango(method, path28, options) {
19966
19966
  const secretKey = this.config.nango.secretKey;
19967
19967
  const connectionId = this.config.nango.connectionId;
19968
19968
  const providerConfigKey = this.config.nango.providerConfigKey;
19969
19969
  if (!secretKey || !connectionId || !providerConfigKey) {
19970
19970
  throw new GitHubApiError("Nango GitHub proxy requires secretKey, connectionId, and providerConfigKey.");
19971
19971
  }
19972
- const url2 = buildNangoProxyUrl(this.config.nango.baseUrl, path25, options.query);
19972
+ const url2 = buildNangoProxyUrl(this.config.nango.baseUrl, path28, options.query);
19973
19973
  const response = await this.fetchWithTimeout(url2, {
19974
19974
  method,
19975
19975
  headers: {
@@ -19987,7 +19987,7 @@ var init_cloud_runtime = __esm({
19987
19987
  });
19988
19988
  return parseJsonResponse(response);
19989
19989
  }
19990
- async requestViaRelayCloud(method, path25, options) {
19990
+ async requestViaRelayCloud(method, path28, options) {
19991
19991
  const apiUrl = this.config.relayCloud.apiUrl;
19992
19992
  const accessToken = this.config.relayCloud.accessToken;
19993
19993
  const endpoint = this.config.relayCloud.endpoint ?? DEFAULT_RELAY_CLOUD_GITHUB_PROXY_ENDPOINT;
@@ -19996,7 +19996,7 @@ var init_cloud_runtime = __esm({
19996
19996
  }
19997
19997
  const payload = {
19998
19998
  method,
19999
- path: path25,
19999
+ path: path28,
20000
20000
  query: options.query,
20001
20001
  body: options.body,
20002
20002
  headers: options.headers,
@@ -20192,11 +20192,11 @@ function delay3(ms2) {
20192
20192
  setTimeout(resolve4, ms2);
20193
20193
  });
20194
20194
  }
20195
- var import_node_child_process11, import_node_util4, execFileAsync2, GitHubRuntimeDetector, BaseGitHubAdapter, GitHubAdapterFactory, GitHubClientFactory;
20195
+ var import_node_child_process12, import_node_util4, execFileAsync2, GitHubRuntimeDetector, BaseGitHubAdapter, GitHubAdapterFactory, GitHubClientFactory;
20196
20196
  var init_adapter = __esm({
20197
20197
  "packages/github-primitive/src/adapter.ts"() {
20198
20198
  "use strict";
20199
- import_node_child_process11 = require("node:child_process");
20199
+ import_node_child_process12 = require("node:child_process");
20200
20200
  import_node_util4 = require("node:util");
20201
20201
  init_branches();
20202
20202
  init_commits();
@@ -20208,7 +20208,7 @@ var init_adapter = __esm({
20208
20208
  init_utils();
20209
20209
  init_constants();
20210
20210
  init_types();
20211
- execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process11.execFile);
20211
+ execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process12.execFile);
20212
20212
  GitHubRuntimeDetector = class {
20213
20213
  static async detect(config2 = {}) {
20214
20214
  const normalized = normalizeGitHubRuntimeConfig(config2);
@@ -20373,23 +20373,23 @@ var init_adapter = __esm({
20373
20373
  return mergePR(this, owner, repo, pullNumber, options);
20374
20374
  }
20375
20375
  async listFiles(params) {
20376
- const { owner, repo, path: path25, ...options } = params;
20377
- return listFiles(this, owner, repo, path25, options);
20376
+ const { owner, repo, path: path28, ...options } = params;
20377
+ return listFiles(this, owner, repo, path28, options);
20378
20378
  }
20379
20379
  async readFile(params) {
20380
20380
  return readFile3(this, params.owner, params.repo, params.path, params.ref);
20381
20381
  }
20382
20382
  async createFile(params) {
20383
- const { owner, repo, path: path25, content, message, ...options } = params;
20384
- return createFile(this, owner, repo, path25, content, message, options);
20383
+ const { owner, repo, path: path28, content, message, ...options } = params;
20384
+ return createFile(this, owner, repo, path28, content, message, options);
20385
20385
  }
20386
20386
  async updateFile(params) {
20387
- const { owner, repo, path: path25, content, message, sha, ...options } = params;
20388
- return updateFile(this, owner, repo, path25, content, message, sha, options);
20387
+ const { owner, repo, path: path28, content, message, sha, ...options } = params;
20388
+ return updateFile(this, owner, repo, path28, content, message, sha, options);
20389
20389
  }
20390
20390
  async deleteFile(params) {
20391
- const { owner, repo, path: path25, sha, message, ...options } = params;
20392
- return deleteFile(this, owner, repo, path25, sha, message, options);
20391
+ const { owner, repo, path: path28, sha, message, ...options } = params;
20392
+ return deleteFile(this, owner, repo, path28, sha, message, options);
20393
20393
  }
20394
20394
  async listBranches(params) {
20395
20395
  return listBranches(this, params.owner, params.repo);
@@ -21148,7 +21148,7 @@ var require_instrument = __commonJS({
21148
21148
  Object.defineProperty(exports2, "__esModule", { value: true });
21149
21149
  exports2.addAppMetadata = addAppMetadata;
21150
21150
  exports2.getUserAgent = getUserAgent;
21151
- var os12 = __importStar(require("node:os"));
21151
+ var os14 = __importStar(require("node:os"));
21152
21152
  var node_path_1 = require("node:path");
21153
21153
  var packageJson = require_package();
21154
21154
  function replaceSlashes(s3) {
@@ -21162,7 +21162,7 @@ var require_instrument = __commonJS({
21162
21162
  }
21163
21163
  return result;
21164
21164
  }
21165
- var baseUserAgent = `${replaceSlashes(packageJson.name)}/${packageJson.version} ${toLatin1Safe((0, node_path_1.basename)(process.title))}/${process.version.replace("v", "")} ${os12.platform()}/${os12.release()}`;
21165
+ var baseUserAgent = `${replaceSlashes(packageJson.name)}/${packageJson.version} ${toLatin1Safe((0, node_path_1.basename)(process.title))}/${process.version.replace("v", "")} ${os14.platform()}/${os14.release()}`;
21166
21166
  var appMetadata = {};
21167
21167
  function addAppMetadata({ name, version: version2 }) {
21168
21168
  appMetadata[replaceSlashes(name)] = version2;
@@ -30362,11 +30362,11 @@ var require_mime_types = __commonJS({
30362
30362
  }
30363
30363
  return exts[0];
30364
30364
  }
30365
- function lookup(path25) {
30366
- if (!path25 || typeof path25 !== "string") {
30365
+ function lookup(path28) {
30366
+ if (!path28 || typeof path28 !== "string") {
30367
30367
  return false;
30368
30368
  }
30369
- var extension3 = extname("x." + path25).toLowerCase().substr(1);
30369
+ var extension3 = extname("x." + path28).toLowerCase().substr(1);
30370
30370
  if (!extension3) {
30371
30371
  return false;
30372
30372
  }
@@ -31471,11 +31471,11 @@ var require_form_data = __commonJS({
31471
31471
  "use strict";
31472
31472
  var CombinedStream = require_combined_stream();
31473
31473
  var util2 = require("util");
31474
- var path25 = require("path");
31475
- var http = require("http");
31474
+ var path28 = require("path");
31475
+ var http2 = require("http");
31476
31476
  var https3 = require("https");
31477
31477
  var parseUrl = require("url").parse;
31478
- var fs13 = require("fs");
31478
+ var fs15 = require("fs");
31479
31479
  var Stream = require("stream").Stream;
31480
31480
  var crypto3 = require("crypto");
31481
31481
  var mime = require_mime_types();
@@ -31542,7 +31542,7 @@ var require_form_data = __commonJS({
31542
31542
  if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
31543
31543
  callback(null, value.end + 1 - (value.start ? value.start : 0));
31544
31544
  } else {
31545
- fs13.stat(value.path, function(err, stat2) {
31545
+ fs15.stat(value.path, function(err, stat2) {
31546
31546
  if (err) {
31547
31547
  callback(err);
31548
31548
  return;
@@ -31599,11 +31599,11 @@ var require_form_data = __commonJS({
31599
31599
  FormData2.prototype._getContentDisposition = function(value, options) {
31600
31600
  var filename;
31601
31601
  if (typeof options.filepath === "string") {
31602
- filename = path25.normalize(options.filepath).replace(/\\/g, "/");
31602
+ filename = path28.normalize(options.filepath).replace(/\\/g, "/");
31603
31603
  } else if (options.filename || value && (value.name || value.path)) {
31604
- filename = path25.basename(options.filename || value && (value.name || value.path));
31604
+ filename = path28.basename(options.filename || value && (value.name || value.path));
31605
31605
  } else if (value && value.readable && hasOwn(value, "httpVersion")) {
31606
- filename = path25.basename(value.client._httpMessage.path || "");
31606
+ filename = path28.basename(value.client._httpMessage.path || "");
31607
31607
  }
31608
31608
  if (filename) {
31609
31609
  return 'filename="' + filename + '"';
@@ -31744,7 +31744,7 @@ var require_form_data = __commonJS({
31744
31744
  if (options.protocol === "https:") {
31745
31745
  request = https3.request(options);
31746
31746
  } else {
31747
- request = http.request(options);
31747
+ request = http2.request(options);
31748
31748
  }
31749
31749
  this.getLength(function(err, length) {
31750
31750
  if (err && err !== "Unknown stream") {
@@ -32457,7 +32457,7 @@ var require_follow_redirects = __commonJS({
32457
32457
  "node_modules/follow-redirects/index.js"(exports2, module2) {
32458
32458
  var url2 = require("url");
32459
32459
  var URL2 = url2.URL;
32460
- var http = require("http");
32460
+ var http2 = require("http");
32461
32461
  var https3 = require("https");
32462
32462
  var Writable2 = require("stream").Writable;
32463
32463
  var assert2 = require("assert");
@@ -32958,7 +32958,7 @@ var require_follow_redirects = __commonJS({
32958
32958
  function escapeRegex3(regex4) {
32959
32959
  return regex4.replace(/[\]\\/()*+?.$]/g, "\\$&");
32960
32960
  }
32961
- module2.exports = wrap({ http, https: https3 });
32961
+ module2.exports = wrap({ http: http2, https: https3 });
32962
32962
  module2.exports.wrap = wrap;
32963
32963
  }
32964
32964
  });
@@ -32970,11 +32970,11 @@ var require_axios = __commonJS({
32970
32970
  var FormData$1 = require_form_data();
32971
32971
  var crypto3 = require("crypto");
32972
32972
  var url2 = require("url");
32973
- var http = require("http");
32973
+ var http2 = require("http");
32974
32974
  var https3 = require("https");
32975
- var http2 = require("http2");
32975
+ var http22 = require("http2");
32976
32976
  var util2 = require("util");
32977
- var path25 = require("path");
32977
+ var path28 = require("path");
32978
32978
  var followRedirects = require_follow_redirects();
32979
32979
  var zlib = require("zlib");
32980
32980
  var stream = require("stream");
@@ -33848,9 +33848,9 @@ var require_axios = __commonJS({
33848
33848
  function removeBrackets(key) {
33849
33849
  return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
33850
33850
  }
33851
- function renderKey(path26, key, dots) {
33852
- if (!path26) return key;
33853
- return path26.concat(key).map(function each(token, i) {
33851
+ function renderKey(path29, key, dots) {
33852
+ if (!path29) return key;
33853
+ return path29.concat(key).map(function each(token, i) {
33854
33854
  token = removeBrackets(token);
33855
33855
  return !dots && i ? "[" + token + "]" : token;
33856
33856
  }).join(dots ? "." : "");
@@ -33899,13 +33899,13 @@ var require_axios = __commonJS({
33899
33899
  }
33900
33900
  return value;
33901
33901
  }
33902
- function defaultVisitor(value, key, path26) {
33902
+ function defaultVisitor(value, key, path29) {
33903
33903
  let arr = value;
33904
33904
  if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
33905
- formData.append(renderKey(path26, key, dots), convertValue(value));
33905
+ formData.append(renderKey(path29, key, dots), convertValue(value));
33906
33906
  return false;
33907
33907
  }
33908
- if (value && !path26 && typeof value === "object") {
33908
+ if (value && !path29 && typeof value === "object") {
33909
33909
  if (utils$1.endsWith(key, "{}")) {
33910
33910
  key = metaTokens ? key : key.slice(0, -2);
33911
33911
  value = JSON.stringify(value);
@@ -33924,7 +33924,7 @@ var require_axios = __commonJS({
33924
33924
  if (isVisitable(value)) {
33925
33925
  return true;
33926
33926
  }
33927
- formData.append(renderKey(path26, key, dots), convertValue(value));
33927
+ formData.append(renderKey(path29, key, dots), convertValue(value));
33928
33928
  return false;
33929
33929
  }
33930
33930
  const stack = [];
@@ -33933,19 +33933,19 @@ var require_axios = __commonJS({
33933
33933
  convertValue,
33934
33934
  isVisitable
33935
33935
  });
33936
- function build(value, path26, depth = 0) {
33936
+ function build(value, path29, depth = 0) {
33937
33937
  if (utils$1.isUndefined(value)) return;
33938
33938
  if (depth > maxDepth) {
33939
33939
  throw new AxiosError("Object is too deeply nested (" + depth + " levels). Max depth: " + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
33940
33940
  }
33941
33941
  if (stack.indexOf(value) !== -1) {
33942
- throw Error("Circular reference detected in " + path26.join("."));
33942
+ throw Error("Circular reference detected in " + path29.join("."));
33943
33943
  }
33944
33944
  stack.push(value);
33945
33945
  utils$1.forEach(value, function each(el, key) {
33946
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path26, exposedHelpers);
33946
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path29, exposedHelpers);
33947
33947
  if (result === true) {
33948
- build(el, path26 ? path26.concat(key) : [key], depth + 1);
33948
+ build(el, path29 ? path29.concat(key) : [key], depth + 1);
33949
33949
  }
33950
33950
  });
33951
33951
  stack.pop();
@@ -34133,7 +34133,7 @@ var require_axios = __commonJS({
34133
34133
  };
34134
34134
  function toURLEncodedForm(data, options) {
34135
34135
  return toFormData(data, new platform2.classes.URLSearchParams(), {
34136
- visitor: function(value, key, path26, helpers) {
34136
+ visitor: function(value, key, path29, helpers) {
34137
34137
  if (platform2.isNode && utils$1.isBuffer(value)) {
34138
34138
  this.append(key, value.toString("base64"));
34139
34139
  return false;
@@ -34161,11 +34161,11 @@ var require_axios = __commonJS({
34161
34161
  return obj;
34162
34162
  }
34163
34163
  function formDataToJSON(formData) {
34164
- function buildPath(path26, value, target, index) {
34165
- let name = path26[index++];
34164
+ function buildPath(path29, value, target, index) {
34165
+ let name = path29[index++];
34166
34166
  if (name === "__proto__") return true;
34167
34167
  const isNumericKey = Number.isFinite(+name);
34168
- const isLast = index >= path26.length;
34168
+ const isLast = index >= path29.length;
34169
34169
  name = !name && utils$1.isArray(target) ? target.length : name;
34170
34170
  if (isLast) {
34171
34171
  if (utils$1.hasOwnProp(target, name)) {
@@ -34178,7 +34178,7 @@ var require_axios = __commonJS({
34178
34178
  if (!target[name] || !utils$1.isObject(target[name])) {
34179
34179
  target[name] = [];
34180
34180
  }
34181
- const result = buildPath(path26, value, target[name], index);
34181
+ const result = buildPath(path29, value, target[name], index);
34182
34182
  if (result && utils$1.isArray(target[name])) {
34183
34183
  target[name] = arrayToObject(target[name]);
34184
34184
  }
@@ -35042,7 +35042,7 @@ var require_axios = __commonJS({
35042
35042
  }
35043
35043
  }
35044
35044
  }
35045
- const session = http2.connect(authority, options);
35045
+ const session = http22.connect(authority, options);
35046
35046
  let removed;
35047
35047
  const removeSession = () => {
35048
35048
  if (removed) {
@@ -35219,7 +35219,7 @@ var require_axios = __commonJS({
35219
35219
  HTTP2_HEADER_METHOD,
35220
35220
  HTTP2_HEADER_PATH,
35221
35221
  HTTP2_HEADER_STATUS
35222
- } = http2.constants;
35222
+ } = http22.constants;
35223
35223
  const http2Headers = {
35224
35224
  [HTTP2_HEADER_SCHEME]: options.protocol.replace(":", ""),
35225
35225
  [HTTP2_HEADER_METHOD]: options.method,
@@ -35490,8 +35490,8 @@ var require_axios = __commonJS({
35490
35490
  }
35491
35491
  if (config2.allowedSocketPaths != null) {
35492
35492
  const allowed = Array.isArray(config2.allowedSocketPaths) ? config2.allowedSocketPaths : [config2.allowedSocketPaths];
35493
- const resolvedSocket = path25.resolve(config2.socketPath);
35494
- const isAllowed = allowed.some((entry) => typeof entry === "string" && path25.resolve(entry) === resolvedSocket);
35493
+ const resolvedSocket = path28.resolve(config2.socketPath);
35494
+ const isAllowed = allowed.some((entry) => typeof entry === "string" && path28.resolve(entry) === resolvedSocket);
35495
35495
  if (!isAllowed) {
35496
35496
  return reject(new AxiosError(`socketPath "${config2.socketPath}" is not permitted by allowedSocketPaths`, AxiosError.ERR_BAD_OPTION_VALUE, config2));
35497
35497
  }
@@ -35513,7 +35513,7 @@ var require_axios = __commonJS({
35513
35513
  if (configTransport) {
35514
35514
  transport = configTransport;
35515
35515
  } else if (config2.maxRedirects === 0) {
35516
- transport = isHttpsRequest ? https3 : http;
35516
+ transport = isHttpsRequest ? https3 : http2;
35517
35517
  isNativeTransport = true;
35518
35518
  } else {
35519
35519
  if (config2.maxRedirects) {
@@ -35743,14 +35743,14 @@ var require_axios = __commonJS({
35743
35743
  var cookies = platform2.hasStandardBrowserEnv ? (
35744
35744
  // Standard browser envs support document.cookie
35745
35745
  {
35746
- write(name, value, expires, path26, domain2, secure, sameSite) {
35746
+ write(name, value, expires, path29, domain2, secure, sameSite) {
35747
35747
  if (typeof document === "undefined") return;
35748
35748
  const cookie = [`${name}=${encodeURIComponent(value)}`];
35749
35749
  if (utils$1.isNumber(expires)) {
35750
35750
  cookie.push(`expires=${new Date(expires).toUTCString()}`);
35751
35751
  }
35752
- if (utils$1.isString(path26)) {
35753
- cookie.push(`path=${path26}`);
35752
+ if (utils$1.isString(path29)) {
35753
+ cookie.push(`path=${path29}`);
35754
35754
  }
35755
35755
  if (utils$1.isString(domain2)) {
35756
35756
  cookie.push(`domain=${domain2}`);
@@ -41989,8 +41989,8 @@ var init_supermemory = __esm({
41989
41989
  /**
41990
41990
  * Make a fetch request to the Supermemory API
41991
41991
  */
41992
- async fetch(path25, options) {
41993
- const url2 = `${this.endpoint}${path25}`;
41992
+ async fetch(path28, options) {
41993
+ const url2 = `${this.endpoint}${path28}`;
41994
41994
  const controller = new AbortController();
41995
41995
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
41996
41996
  try {
@@ -43050,6 +43050,7 @@ __export(index_exports, {
43050
43050
  isWorktreeStep: () => isWorktreeStep,
43051
43051
  listLoggedAgents: () => listLoggedAgents,
43052
43052
  listPersonas: () => listPersonas,
43053
+ listWorkflowSchedules: () => listWorkflowSchedules,
43053
43054
  loadCustomSteps: () => loadCustomSteps,
43054
43055
  loadPersona: () => loadPersona,
43055
43056
  logAndTraceError: () => logAndTraceError,
@@ -43083,6 +43084,7 @@ __export(index_exports, {
43083
43084
  runScriptWorkflow: () => runScriptWorkflow,
43084
43085
  runVerification: () => runVerification,
43085
43086
  runWorkflow: () => runWorkflow,
43087
+ scheduleWorkflow: () => scheduleWorkflow,
43086
43088
  scrubForChannel: () => scrubForChannel,
43087
43089
  scrubSecrets: () => scrubSecrets,
43088
43090
  sendToChannel: () => sendToChannel,
@@ -43157,7 +43159,7 @@ var BrokerTransport = class {
43157
43159
  return this.baseUrl.replace(/^http/, "ws") + "/ws";
43158
43160
  }
43159
43161
  // ── HTTP ─────────────────────────────────────────────────────────────
43160
- async request(path25, init) {
43162
+ async request(path28, init) {
43161
43163
  const headers = new Headers(init?.headers);
43162
43164
  if (!headers.has("Content-Type")) {
43163
43165
  headers.set("Content-Type", "application/json");
@@ -43166,7 +43168,7 @@ var BrokerTransport = class {
43166
43168
  headers.set("X-API-Key", this.apiKey);
43167
43169
  }
43168
43170
  const signal = init?.signal ?? AbortSignal.timeout(this.requestTimeoutMs);
43169
- const res = await fetch(`${this.baseUrl}${path25}`, { ...init, headers, signal });
43171
+ const res = await fetch(`${this.baseUrl}${path28}`, { ...init, headers, signal });
43170
43172
  if (!res.ok) {
43171
43173
  let body;
43172
43174
  try {
@@ -43632,6 +43634,7 @@ var AgentRelayClient = class _AgentRelayClient {
43632
43634
  stdoutLines,
43633
43635
  stderrLines
43634
43636
  });
43637
+ drainBrokerStdoutAfterStartup(child);
43635
43638
  const client = new _AgentRelayClient({
43636
43639
  baseUrl,
43637
43640
  apiKey,
@@ -43930,6 +43933,13 @@ async function waitForApiUrl(child, timeoutMs, debug) {
43930
43933
  });
43931
43934
  });
43932
43935
  }
43936
+ function drainBrokerStdoutAfterStartup(child) {
43937
+ if (!child.stdout)
43938
+ return;
43939
+ child.stdout.on("data", () => {
43940
+ });
43941
+ child.stdout.resume();
43942
+ }
43933
43943
  function pushBufferedLine(lines, line) {
43934
43944
  lines.push(line);
43935
43945
  if (lines.length > 40) {
@@ -44494,8 +44504,8 @@ function getErrorMap() {
44494
44504
 
44495
44505
  // node_modules/zod/v3/helpers/parseUtil.js
44496
44506
  var makeIssue = (params) => {
44497
- const { data, path: path25, errorMaps, issueData } = params;
44498
- const fullPath = [...path25, ...issueData.path || []];
44507
+ const { data, path: path28, errorMaps, issueData } = params;
44508
+ const fullPath = [...path28, ...issueData.path || []];
44499
44509
  const fullIssue = {
44500
44510
  ...issueData,
44501
44511
  path: fullPath
@@ -44611,11 +44621,11 @@ var errorUtil;
44611
44621
 
44612
44622
  // node_modules/zod/v3/types.js
44613
44623
  var ParseInputLazyPath = class {
44614
- constructor(parent, value, path25, key) {
44624
+ constructor(parent, value, path28, key) {
44615
44625
  this._cachedPath = [];
44616
44626
  this.parent = parent;
44617
44627
  this.data = value;
44618
- this._path = path25;
44628
+ this._path = path28;
44619
44629
  this._key = key;
44620
44630
  }
44621
44631
  get path() {
@@ -51121,10 +51131,10 @@ function mergeDefs(...defs) {
51121
51131
  function cloneDef(schema) {
51122
51132
  return mergeDefs(schema._zod.def);
51123
51133
  }
51124
- function getElementAtPath(obj, path25) {
51125
- if (!path25)
51134
+ function getElementAtPath(obj, path28) {
51135
+ if (!path28)
51126
51136
  return obj;
51127
- return path25.reduce((acc, key) => acc?.[key], obj);
51137
+ return path28.reduce((acc, key) => acc?.[key], obj);
51128
51138
  }
51129
51139
  function promiseAllObject(promisesObj) {
51130
51140
  const keys = Object.keys(promisesObj);
@@ -51533,11 +51543,11 @@ function explicitlyAborted(x, startIndex = 0) {
51533
51543
  }
51534
51544
  return false;
51535
51545
  }
51536
- function prefixIssues(path25, issues) {
51546
+ function prefixIssues(path28, issues) {
51537
51547
  return issues.map((iss) => {
51538
51548
  var _a3;
51539
51549
  (_a3 = iss).path ?? (_a3.path = []);
51540
- iss.path.unshift(path25);
51550
+ iss.path.unshift(path28);
51541
51551
  return iss;
51542
51552
  });
51543
51553
  }
@@ -51684,16 +51694,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
51684
51694
  }
51685
51695
  function formatError(error51, mapper = (issue2) => issue2.message) {
51686
51696
  const fieldErrors = { _errors: [] };
51687
- const processError = (error52, path25 = []) => {
51697
+ const processError = (error52, path28 = []) => {
51688
51698
  for (const issue2 of error52.issues) {
51689
51699
  if (issue2.code === "invalid_union" && issue2.errors.length) {
51690
- issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
51700
+ issue2.errors.map((issues) => processError({ issues }, [...path28, ...issue2.path]));
51691
51701
  } else if (issue2.code === "invalid_key") {
51692
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
51702
+ processError({ issues: issue2.issues }, [...path28, ...issue2.path]);
51693
51703
  } else if (issue2.code === "invalid_element") {
51694
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
51704
+ processError({ issues: issue2.issues }, [...path28, ...issue2.path]);
51695
51705
  } else {
51696
- const fullpath = [...path25, ...issue2.path];
51706
+ const fullpath = [...path28, ...issue2.path];
51697
51707
  if (fullpath.length === 0) {
51698
51708
  fieldErrors._errors.push(mapper(issue2));
51699
51709
  } else {
@@ -51720,17 +51730,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
51720
51730
  }
51721
51731
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
51722
51732
  const result = { errors: [] };
51723
- const processError = (error52, path25 = []) => {
51733
+ const processError = (error52, path28 = []) => {
51724
51734
  var _a3, _b;
51725
51735
  for (const issue2 of error52.issues) {
51726
51736
  if (issue2.code === "invalid_union" && issue2.errors.length) {
51727
- issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
51737
+ issue2.errors.map((issues) => processError({ issues }, [...path28, ...issue2.path]));
51728
51738
  } else if (issue2.code === "invalid_key") {
51729
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
51739
+ processError({ issues: issue2.issues }, [...path28, ...issue2.path]);
51730
51740
  } else if (issue2.code === "invalid_element") {
51731
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
51741
+ processError({ issues: issue2.issues }, [...path28, ...issue2.path]);
51732
51742
  } else {
51733
- const fullpath = [...path25, ...issue2.path];
51743
+ const fullpath = [...path28, ...issue2.path];
51734
51744
  if (fullpath.length === 0) {
51735
51745
  result.errors.push(mapper(issue2));
51736
51746
  continue;
@@ -51762,8 +51772,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
51762
51772
  }
51763
51773
  function toDotPath(_path) {
51764
51774
  const segs = [];
51765
- const path25 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
51766
- for (const seg of path25) {
51775
+ const path28 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
51776
+ for (const seg of path28) {
51767
51777
  if (typeof seg === "number")
51768
51778
  segs.push(`[${seg}]`);
51769
51779
  else if (typeof seg === "symbol")
@@ -64455,13 +64465,13 @@ function resolveRef(ref, ctx) {
64455
64465
  if (!ref.startsWith("#")) {
64456
64466
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
64457
64467
  }
64458
- const path25 = ref.slice(1).split("/").filter(Boolean);
64459
- if (path25.length === 0) {
64468
+ const path28 = ref.slice(1).split("/").filter(Boolean);
64469
+ if (path28.length === 0) {
64460
64470
  return ctx.rootSchema;
64461
64471
  }
64462
64472
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
64463
- if (path25[0] === defsKey) {
64464
- const key = path25[1];
64473
+ if (path28[0] === defsKey) {
64474
+ const key = path28[1];
64465
64475
  if (!key || !ctx.defs[key]) {
64466
64476
  throw new Error(`Reference not found: ${ref}`);
64467
64477
  }
@@ -66624,8 +66634,8 @@ var HttpClient = class _HttpClient {
66624
66634
  version: this._originVersion
66625
66635
  }));
66626
66636
  }
66627
- async request(method, path25, body, query, options) {
66628
- const url2 = new URL(path25, this._baseUrl);
66637
+ async request(method, path28, body, query, options) {
66638
+ const url2 = new URL(path28, this._baseUrl);
66629
66639
  if (query) {
66630
66640
  for (const [k2, v2] of Object.entries(query)) {
66631
66641
  if (v2 !== void 0)
@@ -66695,20 +66705,20 @@ var HttpClient = class _HttpClient {
66695
66705
  return camelizeKeys(parsedData);
66696
66706
  }
66697
66707
  }
66698
- get(path25, query, options) {
66699
- return this.request("GET", path25, void 0, query, options);
66708
+ get(path28, query, options) {
66709
+ return this.request("GET", path28, void 0, query, options);
66700
66710
  }
66701
- post(path25, body, options) {
66702
- return this.request("POST", path25, body, void 0, options);
66711
+ post(path28, body, options) {
66712
+ return this.request("POST", path28, body, void 0, options);
66703
66713
  }
66704
- patch(path25, body, options) {
66705
- return this.request("PATCH", path25, body, void 0, options);
66714
+ patch(path28, body, options) {
66715
+ return this.request("PATCH", path28, body, void 0, options);
66706
66716
  }
66707
- put(path25, body, options) {
66708
- return this.request("PUT", path25, body, void 0, options);
66717
+ put(path28, body, options) {
66718
+ return this.request("PUT", path28, body, void 0, options);
66709
66719
  }
66710
- async delete(path25, options) {
66711
- await this.request("DELETE", path25, void 0, void 0, options);
66720
+ async delete(path28, options) {
66721
+ await this.request("DELETE", path28, void 0, void 0, options);
66712
66722
  }
66713
66723
  };
66714
66724
 
@@ -68760,15 +68770,15 @@ function listPersonas(options = {}) {
68760
68770
  for (const file2 of entries) {
68761
68771
  if (!file2.endsWith(".json"))
68762
68772
  continue;
68763
- const path25 = (0, import_node_path5.join)(dir, file2);
68773
+ const path28 = (0, import_node_path5.join)(dir, file2);
68764
68774
  let spec;
68765
68775
  try {
68766
- spec = parsePersonaFile(JSON.parse((0, import_node_fs3.readFileSync)(path25, "utf8")), path25);
68776
+ spec = parsePersonaFile(JSON.parse((0, import_node_fs3.readFileSync)(path28, "utf8")), path28);
68767
68777
  } catch {
68768
68778
  continue;
68769
68779
  }
68770
68780
  if (!byId.has(spec.id)) {
68771
- byId.set(spec.id, { id: spec.id, path: path25, spec });
68781
+ byId.set(spec.id, { id: spec.id, path: path28, spec });
68772
68782
  }
68773
68783
  }
68774
68784
  }
@@ -68801,11 +68811,11 @@ function findPersona(id, options = {}) {
68801
68811
  for (const file2 of entries) {
68802
68812
  if (!file2.endsWith(".json"))
68803
68813
  continue;
68804
- const path25 = (0, import_node_path5.join)(dir, file2);
68814
+ const path28 = (0, import_node_path5.join)(dir, file2);
68805
68815
  try {
68806
- const spec = parsePersonaFile(JSON.parse((0, import_node_fs3.readFileSync)(path25, "utf8")), path25);
68816
+ const spec = parsePersonaFile(JSON.parse((0, import_node_fs3.readFileSync)(path28, "utf8")), path28);
68807
68817
  if (spec.id === id)
68808
- return { id, path: path25, spec };
68818
+ return { id, path: path28, spec };
68809
68819
  } catch {
68810
68820
  continue;
68811
68821
  }
@@ -71688,9 +71698,9 @@ async function resolveCli(cli) {
71688
71698
  for (const binary of def.binaries) {
71689
71699
  try {
71690
71700
  const { stdout } = await execFileAsync("which", [binary]);
71691
- const path25 = stdout.trim();
71692
- if (path25) {
71693
- const result = { binary, path: path25 };
71701
+ const path28 = stdout.trim();
71702
+ if (path28) {
71703
+ const result = { binary, path: path28 };
71694
71704
  resolveCache.set(cli, result);
71695
71705
  return result;
71696
71706
  }
@@ -71727,9 +71737,9 @@ function resolveCliSync(cli) {
71727
71737
  for (const binary of def.binaries) {
71728
71738
  try {
71729
71739
  const stdout = execFileSync3("which", [binary], { stdio: ["pipe", "pipe", "ignore"] });
71730
- const path25 = stdout.toString().trim();
71731
- if (path25) {
71732
- const result = { binary, path: path25 };
71740
+ const path28 = stdout.toString().trim();
71741
+ if (path28) {
71742
+ const result = { binary, path: path28 };
71733
71743
  resolveCache.set(cli, result);
71734
71744
  return result;
71735
71745
  }
@@ -73061,10 +73071,10 @@ var RelayFileClient = class {
73061
73071
  signal: options.signal
73062
73072
  });
73063
73073
  }
73064
- async readFile(workspaceOrInput, path25, correlationId, signal) {
73074
+ async readFile(workspaceOrInput, path28, correlationId, signal) {
73065
73075
  const input = typeof workspaceOrInput === "string" ? {
73066
73076
  workspaceId: workspaceOrInput,
73067
- path: path25 ?? "",
73077
+ path: path28 ?? "",
73068
73078
  correlationId,
73069
73079
  signal
73070
73080
  } : workspaceOrInput;
@@ -73111,8 +73121,8 @@ var RelayFileClient = class {
73111
73121
  });
73112
73122
  }
73113
73123
  async writeFile(input) {
73114
- const { workspaceId, path: path25, correlationId, baseRevision, content, contentType, encoding, contentIdentity, signal } = input;
73115
- const query = buildQuery({ path: path25, forkId: input.forkId });
73124
+ const { workspaceId, path: path28, correlationId, baseRevision, content, contentType, encoding, contentIdentity, signal } = input;
73125
+ const query = buildQuery({ path: path28, forkId: input.forkId });
73116
73126
  return this.request({
73117
73127
  method: "PUT",
73118
73128
  path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/fs/file${query}`,
@@ -80006,11 +80016,11 @@ function extractDecisions(trajectory2) {
80006
80016
  }
80007
80017
  return decisions;
80008
80018
  }
80009
- function expandPath(path25) {
80010
- if (path25.startsWith("~")) {
80011
- return (0, import_path4.join)(process.env.HOME ?? "", path25.slice(1));
80019
+ function expandPath(path28) {
80020
+ if (path28.startsWith("~")) {
80021
+ return (0, import_path4.join)(process.env.HOME ?? "", path28.slice(1));
80012
80022
  }
80013
- return path25;
80023
+ return path28;
80014
80024
  }
80015
80025
  function describeReadFailure(reason, error51) {
80016
80026
  if (reason === "schema_violation" && error51 && typeof error51 === "object" && "issues" in error51) {
@@ -80027,11 +80037,11 @@ function describeReadFailure(reason, error51) {
80027
80037
  return String(error51);
80028
80038
  }
80029
80039
  var indexLocks = /* @__PURE__ */ new Map();
80030
- function withIndexLock(path25, task) {
80031
- const prev = indexLocks.get(path25) ?? Promise.resolve();
80040
+ function withIndexLock(path28, task) {
80041
+ const prev = indexLocks.get(path28) ?? Promise.resolve();
80032
80042
  const next = prev.then(task, task);
80033
80043
  indexLocks.set(
80034
- path25,
80044
+ path28,
80035
80045
  next.catch(() => void 0)
80036
80046
  );
80037
80047
  return next;
@@ -80260,8 +80270,8 @@ var FileStorage = class {
80260
80270
  const validation = validateTrajectory(input);
80261
80271
  if (!validation.success) {
80262
80272
  const issues = validation.errors?.issues.map((issue2) => {
80263
- const path25 = issue2.path.length > 0 ? issue2.path.join(".") : "root";
80264
- return `${path25}: ${issue2.message}`;
80273
+ const path28 = issue2.path.length > 0 ? issue2.path.join(".") : "root";
80274
+ return `${path28}: ${issue2.message}`;
80265
80275
  }).join("; ") ?? "unknown validation error";
80266
80276
  throw new Error(`Cannot save invalid trajectory: ${issues}`);
80267
80277
  }
@@ -80470,18 +80480,18 @@ var FileStorage = class {
80470
80480
  *
80471
80481
  * Does NOT log. Callers choose whether to warn, swallow, or throw.
80472
80482
  */
80473
- async readTrajectoryFile(path25) {
80483
+ async readTrajectoryFile(path28) {
80474
80484
  let content;
80475
80485
  try {
80476
- content = await (0, import_promises7.readFile)(path25, "utf-8");
80486
+ content = await (0, import_promises7.readFile)(path28, "utf-8");
80477
80487
  } catch (error51) {
80478
- return { ok: false, reason: "io_error", path: path25, error: error51 };
80488
+ return { ok: false, reason: "io_error", path: path28, error: error51 };
80479
80489
  }
80480
80490
  let data;
80481
80491
  try {
80482
80492
  data = JSON.parse(content);
80483
80493
  } catch (error51) {
80484
- return { ok: false, reason: "malformed_json", path: path25, error: error51 };
80494
+ return { ok: false, reason: "malformed_json", path: path28, error: error51 };
80485
80495
  }
80486
80496
  const validation = validateTrajectory(data);
80487
80497
  if (validation.success) {
@@ -80490,7 +80500,7 @@ var FileStorage = class {
80490
80500
  return {
80491
80501
  ok: false,
80492
80502
  reason: "schema_violation",
80493
- path: path25,
80503
+ path: path28,
80494
80504
  error: validation.errors
80495
80505
  };
80496
80506
  }
@@ -80499,8 +80509,8 @@ var FileStorage = class {
80499
80509
  * trajectory. Returns null for any failure and writes nothing to the
80500
80510
  * console — so nothing leaks into test output or the CLI spinner.
80501
80511
  */
80502
- async readTrajectoryOrNull(path25) {
80503
- const result = await this.readTrajectoryFile(path25);
80512
+ async readTrajectoryOrNull(path28) {
80513
+ const result = await this.readTrajectoryFile(path28);
80504
80514
  return result.ok ? result.trajectory : null;
80505
80515
  }
80506
80516
  /**
@@ -87033,8 +87043,531 @@ async function runWorkflow(yamlPath, options = {}) {
87033
87043
  return runner.execute(config2, options.workflow, options.vars, executeOptions);
87034
87044
  }
87035
87045
 
87036
- // packages/sdk/dist/workflows/builder.js
87046
+ // packages/cloud/src/auth.ts
87047
+ var import_promises9 = __toESM(require("node:fs/promises"), 1);
87048
+ var import_node_http = __toESM(require("node:http"), 1);
87049
+ var import_node_os12 = __toESM(require("node:os"), 1);
87050
+ var import_node_path32 = __toESM(require("node:path"), 1);
87051
+ var import_node_child_process9 = require("node:child_process");
87052
+
87053
+ // packages/cloud/src/types.ts
87054
+ var import_node_os11 = __toESM(require("node:os"), 1);
87037
87055
  var import_node_path31 = __toESM(require("node:path"), 1);
87056
+ var REFRESH_WINDOW_MS = 6e4;
87057
+ var AUTH_FILE_PATH = import_node_path31.default.join(import_node_os11.default.homedir(), ".agent-relay", "cloud-auth.json");
87058
+ function defaultApiUrl() {
87059
+ return process.env.CLOUD_API_URL?.trim() || "https://agentrelay.com/cloud";
87060
+ }
87061
+
87062
+ // packages/cloud/src/api-client.ts
87063
+ function trimLeadingSlash(p2) {
87064
+ return p2.replace(/^\/+/, "");
87065
+ }
87066
+ function withTrailingSlash(p2) {
87067
+ return p2.endsWith("/") ? p2 : `${p2}/`;
87068
+ }
87069
+ function buildApiUrl(apiUrl, p2) {
87070
+ return new URL(trimLeadingSlash(p2), withTrailingSlash(apiUrl));
87071
+ }
87072
+
87073
+ // packages/cloud/src/auth.ts
87074
+ var envBackedAuth = /* @__PURE__ */ new WeakSet();
87075
+ function markEnvBackedAuth(auth) {
87076
+ envBackedAuth.add(auth);
87077
+ return auth;
87078
+ }
87079
+ function isEnvBackedAuth(auth) {
87080
+ return envBackedAuth.has(auth);
87081
+ }
87082
+ function readEnvAuth(env = process.env) {
87083
+ const apiUrl = env.CLOUD_API_URL?.trim();
87084
+ const accessToken = env.CLOUD_API_ACCESS_TOKEN?.trim();
87085
+ const refreshToken = env.CLOUD_API_REFRESH_TOKEN?.trim();
87086
+ const accessTokenExpiresAt = env.CLOUD_API_ACCESS_TOKEN_EXPIRES_AT?.trim();
87087
+ if (!apiUrl || !accessToken || !refreshToken || !accessTokenExpiresAt) {
87088
+ return null;
87089
+ }
87090
+ try {
87091
+ new URL(apiUrl);
87092
+ } catch {
87093
+ return null;
87094
+ }
87095
+ if (Number.isNaN(Date.parse(accessTokenExpiresAt))) {
87096
+ return null;
87097
+ }
87098
+ return markEnvBackedAuth({
87099
+ apiUrl,
87100
+ accessToken,
87101
+ refreshToken,
87102
+ accessTokenExpiresAt
87103
+ });
87104
+ }
87105
+ function toEnvAuthRefreshError(error51) {
87106
+ const message = error51 instanceof Error && error51.message ? `${error51.message}. ` : "";
87107
+ return new Error(
87108
+ `${message}Env-backed cloud auth could not be refreshed interactively; re-provision CLOUD_API_URL, CLOUD_API_ACCESS_TOKEN, CLOUD_API_REFRESH_TOKEN, and CLOUD_API_ACCESS_TOKEN_EXPIRES_AT.`,
87109
+ error51 instanceof Error ? { cause: error51 } : void 0
87110
+ );
87111
+ }
87112
+ function isValidStoredAuth(value) {
87113
+ if (!value || typeof value !== "object") {
87114
+ return false;
87115
+ }
87116
+ const auth = value;
87117
+ return typeof auth.accessToken === "string" && typeof auth.refreshToken === "string" && typeof auth.accessTokenExpiresAt === "string" && typeof auth.apiUrl === "string";
87118
+ }
87119
+ async function readStoredAuth(env = process.env) {
87120
+ const envAuth = readEnvAuth(env);
87121
+ if (envAuth) {
87122
+ return envAuth;
87123
+ }
87124
+ try {
87125
+ const file2 = await import_promises9.default.readFile(AUTH_FILE_PATH, "utf8");
87126
+ const parsed = JSON.parse(file2);
87127
+ return isValidStoredAuth(parsed) ? parsed : null;
87128
+ } catch {
87129
+ return null;
87130
+ }
87131
+ }
87132
+ async function writeStoredAuth(auth) {
87133
+ await import_promises9.default.mkdir(import_node_path32.default.dirname(AUTH_FILE_PATH), {
87134
+ recursive: true,
87135
+ mode: 448
87136
+ });
87137
+ await import_promises9.default.writeFile(AUTH_FILE_PATH, `${JSON.stringify(auth, null, 2)}
87138
+ `, {
87139
+ encoding: "utf8",
87140
+ mode: 384
87141
+ });
87142
+ }
87143
+ function shouldRefresh(accessTokenExpiresAt) {
87144
+ const expiresAt = Date.parse(accessTokenExpiresAt);
87145
+ if (Number.isNaN(expiresAt)) {
87146
+ return true;
87147
+ }
87148
+ return expiresAt - Date.now() <= REFRESH_WINDOW_MS;
87149
+ }
87150
+ function openBrowser(url2) {
87151
+ const platform2 = import_node_os12.default.platform();
87152
+ if (platform2 === "darwin") {
87153
+ return (0, import_node_child_process9.spawn)("open", [url2], { stdio: "ignore", detached: true });
87154
+ }
87155
+ if (platform2 === "win32") {
87156
+ return (0, import_node_child_process9.spawn)("cmd", ["/c", "start", "", url2], { stdio: "ignore", detached: true });
87157
+ }
87158
+ return (0, import_node_child_process9.spawn)("xdg-open", [url2], { stdio: "ignore", detached: true });
87159
+ }
87160
+ function redirectToHostedCliAuthPage(response, apiUrl, options) {
87161
+ const resultUrl = buildApiUrl(apiUrl, "/cli/auth-result");
87162
+ resultUrl.searchParams.set("status", options.status);
87163
+ if (options.detail) {
87164
+ resultUrl.searchParams.set("detail", options.detail);
87165
+ }
87166
+ response.statusCode = 302;
87167
+ response.setHeader("location", resultUrl.toString());
87168
+ response.end();
87169
+ }
87170
+ async function beginBrowserLogin(apiUrl) {
87171
+ const state = crypto.randomUUID();
87172
+ return new Promise((resolve4, reject) => {
87173
+ let settled = false;
87174
+ const server = import_node_http.default.createServer((request, response) => {
87175
+ const requestUrl = new URL(request.url || "/", "http://127.0.0.1");
87176
+ if (requestUrl.pathname !== "/callback") {
87177
+ response.statusCode = 404;
87178
+ response.end("Not found");
87179
+ return;
87180
+ }
87181
+ const returnedState = requestUrl.searchParams.get("state");
87182
+ if (returnedState !== state) {
87183
+ redirectToHostedCliAuthPage(response, apiUrl, {
87184
+ status: "error",
87185
+ detail: "Invalid state parameter"
87186
+ });
87187
+ if (!settled) {
87188
+ settled = true;
87189
+ server.close();
87190
+ reject(new Error("Invalid state parameter in CLI login callback"));
87191
+ }
87192
+ return;
87193
+ }
87194
+ const error51 = requestUrl.searchParams.get("error");
87195
+ if (error51) {
87196
+ redirectToHostedCliAuthPage(response, apiUrl, {
87197
+ status: "error",
87198
+ detail: error51
87199
+ });
87200
+ if (!settled) {
87201
+ settled = true;
87202
+ server.close();
87203
+ reject(new Error(error51));
87204
+ }
87205
+ return;
87206
+ }
87207
+ const accessToken = requestUrl.searchParams.get("access_token");
87208
+ const refreshToken = requestUrl.searchParams.get("refresh_token");
87209
+ const accessTokenExpiresAt = requestUrl.searchParams.get("access_token_expires_at");
87210
+ const returnedApiUrl = requestUrl.searchParams.get("api_url");
87211
+ if (!accessToken || !refreshToken || !accessTokenExpiresAt || !returnedApiUrl) {
87212
+ redirectToHostedCliAuthPage(response, apiUrl, {
87213
+ status: "error",
87214
+ detail: "Expected access token, refresh token, API URL, and expiration timestamp."
87215
+ });
87216
+ if (!settled) {
87217
+ settled = true;
87218
+ server.close();
87219
+ reject(new Error("CLI login callback was missing required fields"));
87220
+ }
87221
+ return;
87222
+ }
87223
+ redirectToHostedCliAuthPage(response, returnedApiUrl, {
87224
+ status: "success",
87225
+ detail: `API endpoint: ${returnedApiUrl}`
87226
+ });
87227
+ if (!settled) {
87228
+ settled = true;
87229
+ server.close();
87230
+ resolve4({
87231
+ accessToken,
87232
+ refreshToken,
87233
+ accessTokenExpiresAt,
87234
+ apiUrl: returnedApiUrl
87235
+ });
87236
+ }
87237
+ });
87238
+ server.listen(0, "127.0.0.1", () => {
87239
+ const address = server.address();
87240
+ if (!address || typeof address === "string") {
87241
+ if (!settled) {
87242
+ settled = true;
87243
+ server.close();
87244
+ reject(new Error("Failed to start local callback server"));
87245
+ }
87246
+ return;
87247
+ }
87248
+ const callbackUrl = new URL("/callback", `http://127.0.0.1:${address.port}`);
87249
+ const loginUrl = buildApiUrl(apiUrl, "/api/v1/cli/login");
87250
+ loginUrl.searchParams.set("redirect_uri", callbackUrl.toString());
87251
+ loginUrl.searchParams.set("state", state);
87252
+ console.log(`Opening browser for cloud login: ${loginUrl.toString()}`);
87253
+ console.log("If the browser does not open, paste this URL into your browser.");
87254
+ try {
87255
+ const child = openBrowser(loginUrl.toString());
87256
+ child.unref();
87257
+ } catch {
87258
+ }
87259
+ });
87260
+ server.on("error", (error51) => {
87261
+ if (!settled) {
87262
+ settled = true;
87263
+ reject(error51);
87264
+ }
87265
+ });
87266
+ setTimeout(() => {
87267
+ if (!settled) {
87268
+ settled = true;
87269
+ server.close();
87270
+ reject(new Error("Timed out waiting for browser login"));
87271
+ }
87272
+ }, 5 * 6e4).unref();
87273
+ });
87274
+ }
87275
+ async function refreshStoredAuth(auth) {
87276
+ const response = await fetch(buildApiUrl(auth.apiUrl, "/api/v1/auth/token/refresh"), {
87277
+ method: "POST",
87278
+ headers: {
87279
+ "content-type": "application/json"
87280
+ },
87281
+ body: JSON.stringify({ refreshToken: auth.refreshToken })
87282
+ });
87283
+ const payload = await response.json().catch(() => null);
87284
+ if (!response.ok || !payload?.accessToken || !payload?.refreshToken || !payload?.accessTokenExpiresAt) {
87285
+ throw new Error("Stored cloud login has expired");
87286
+ }
87287
+ const nextAuth = {
87288
+ apiUrl: auth.apiUrl,
87289
+ accessToken: payload.accessToken,
87290
+ refreshToken: payload.refreshToken,
87291
+ accessTokenExpiresAt: payload.accessTokenExpiresAt
87292
+ };
87293
+ if (isEnvBackedAuth(auth)) {
87294
+ return markEnvBackedAuth(nextAuth);
87295
+ }
87296
+ await writeStoredAuth(nextAuth);
87297
+ return nextAuth;
87298
+ }
87299
+ async function loginWithBrowser(apiUrl) {
87300
+ const auth = await beginBrowserLogin(apiUrl);
87301
+ await writeStoredAuth(auth);
87302
+ console.log(`Logged in to ${auth.apiUrl}`);
87303
+ return auth;
87304
+ }
87305
+ async function ensureAuthenticated(apiUrl, options) {
87306
+ const force = options?.force === true;
87307
+ const stored = !force ? await readStoredAuth() : null;
87308
+ if (!stored) {
87309
+ return loginWithBrowser(apiUrl);
87310
+ }
87311
+ if (!shouldRefresh(stored.accessTokenExpiresAt)) {
87312
+ return stored;
87313
+ }
87314
+ try {
87315
+ return await refreshStoredAuth(stored);
87316
+ } catch (error51) {
87317
+ if (isEnvBackedAuth(stored)) {
87318
+ throw toEnvAuthRefreshError(error51);
87319
+ }
87320
+ return loginWithBrowser(stored.apiUrl);
87321
+ }
87322
+ }
87323
+ function apiFetch(apiUrl, accessToken, requestPath, init) {
87324
+ return fetch(buildApiUrl(apiUrl, requestPath), {
87325
+ ...init,
87326
+ headers: {
87327
+ "content-type": "application/json",
87328
+ authorization: `Bearer ${accessToken}`,
87329
+ ...init.headers ?? {}
87330
+ }
87331
+ });
87332
+ }
87333
+ async function authorizedApiFetch(auth, requestPath, init) {
87334
+ let activeAuth = auth;
87335
+ let response = await apiFetch(activeAuth.apiUrl, activeAuth.accessToken, requestPath, init);
87336
+ if (response.status !== 401) {
87337
+ return { response, auth: activeAuth };
87338
+ }
87339
+ try {
87340
+ activeAuth = await refreshStoredAuth(activeAuth);
87341
+ } catch (error51) {
87342
+ if (isEnvBackedAuth(activeAuth)) {
87343
+ throw toEnvAuthRefreshError(error51);
87344
+ }
87345
+ activeAuth = await loginWithBrowser(activeAuth.apiUrl);
87346
+ }
87347
+ response = await apiFetch(activeAuth.apiUrl, activeAuth.accessToken, requestPath, init);
87348
+ return { response, auth: activeAuth };
87349
+ }
87350
+
87351
+ // packages/cloud/src/workflows.ts
87352
+ var import_promises10 = __toESM(require("node:fs/promises"), 1);
87353
+ var import_node_path33 = __toESM(require("node:path"), 1);
87354
+ var import_ignore3 = __toESM(require_ignore(), 1);
87355
+ function validateYamlWorkflow(content) {
87356
+ const hasField = (field) => new RegExp(`^${field}\\s*:`, "m").test(content);
87357
+ if (!hasField("version")) {
87358
+ throw new Error('missing required field "version"');
87359
+ }
87360
+ if (!hasField("swarm")) {
87361
+ throw new Error('missing required field "swarm"');
87362
+ }
87363
+ if (!hasField("agents")) {
87364
+ throw new Error('missing required field "agents"');
87365
+ }
87366
+ if (!hasField("workflows")) {
87367
+ throw new Error('missing required field "workflows"');
87368
+ }
87369
+ }
87370
+ async function validateTypeScriptWorkflow(content) {
87371
+ const Bun = globalThis.Bun;
87372
+ if (typeof Bun !== "undefined") {
87373
+ try {
87374
+ const result = await Bun.build({
87375
+ stdin: { contents: content, loader: "ts" },
87376
+ throw: false
87377
+ });
87378
+ if (!result.success && result.logs?.length) {
87379
+ const errors = result.logs.filter((l) => l.level === "error").map((l) => l.message).join("\n");
87380
+ if (errors) {
87381
+ throw new Error(`Workflow file has syntax errors:
87382
+ ${errors}`);
87383
+ }
87384
+ }
87385
+ return;
87386
+ } catch (error51) {
87387
+ if (error51 instanceof Error && error51.message.startsWith("Workflow file has syntax errors")) {
87388
+ throw error51;
87389
+ }
87390
+ return;
87391
+ }
87392
+ }
87393
+ try {
87394
+ const { execSync: execSync6 } = await import("node:child_process");
87395
+ execSync6("npx --yes esbuild --loader=ts", {
87396
+ input: content,
87397
+ encoding: "utf-8",
87398
+ stdio: ["pipe", "pipe", "pipe"],
87399
+ timeout: 3e4
87400
+ });
87401
+ } catch (error51) {
87402
+ const err = error51;
87403
+ const stderr = typeof err.stderr === "string" ? err.stderr.trim() : "";
87404
+ if (err.killed || !err.status || err.status === 127 || /command not found|not found/i.test(stderr)) {
87405
+ return;
87406
+ }
87407
+ const message = stderr || "TypeScript validation failed";
87408
+ throw new Error(`Workflow file has syntax errors:
87409
+ ${message}`);
87410
+ }
87411
+ }
87412
+ function inferWorkflowFileType(filePath) {
87413
+ const ext = import_node_path33.default.extname(filePath).toLowerCase();
87414
+ switch (ext) {
87415
+ case ".yaml":
87416
+ case ".yml":
87417
+ return "yaml";
87418
+ case ".ts":
87419
+ case ".mts":
87420
+ case ".cts":
87421
+ return "ts";
87422
+ case ".py":
87423
+ return "py";
87424
+ default:
87425
+ return null;
87426
+ }
87427
+ }
87428
+ async function resolveWorkflowInput(workflowArg, explicitFileType) {
87429
+ const looksLikeFile = import_node_path33.default.isAbsolute(workflowArg) || workflowArg.includes(import_node_path33.default.sep) || inferWorkflowFileType(workflowArg) !== null;
87430
+ try {
87431
+ const workflow2 = await import_promises10.default.readFile(workflowArg, "utf-8");
87432
+ const fileType = explicitFileType ?? inferWorkflowFileType(workflowArg);
87433
+ if (!fileType) {
87434
+ throw new Error(`Could not infer workflow type from ${workflowArg}. Use --file-type.`);
87435
+ }
87436
+ return { workflow: workflow2, fileType };
87437
+ } catch (error51) {
87438
+ const err = error51;
87439
+ if (err.code === "EISDIR") {
87440
+ throw new Error(`Workflow path is not a file: ${workflowArg}`);
87441
+ }
87442
+ if (!isMissingFileError(error51)) {
87443
+ throw error51;
87444
+ }
87445
+ }
87446
+ if (looksLikeFile) {
87447
+ throw new Error(`Workflow file not found: ${workflowArg}`);
87448
+ }
87449
+ return {
87450
+ workflow: workflowArg,
87451
+ fileType: explicitFileType ?? "yaml"
87452
+ };
87453
+ }
87454
+ async function scheduleWorkflow(workflowArg, options = {}) {
87455
+ const hasCron = typeof options.cron === "string" && options.cron.trim().length > 0;
87456
+ const hasAt = typeof options.at === "string" && options.at.trim().length > 0;
87457
+ if (hasCron === hasAt) {
87458
+ throw new Error("Provide exactly one of --cron or --at.");
87459
+ }
87460
+ const apiUrl = options.apiUrl ?? defaultApiUrl();
87461
+ const auth = await ensureAuthenticated(apiUrl);
87462
+ const input = await resolveWorkflowInput(workflowArg, options.fileType);
87463
+ if (input.fileType === "ts") {
87464
+ await validateTypeScriptWorkflow(input.workflow);
87465
+ } else if (input.fileType === "yaml") {
87466
+ console.error("Validating workflow...");
87467
+ validateYamlWorkflow(input.workflow);
87468
+ }
87469
+ const requestBody = {
87470
+ name: options.name?.trim() || import_node_path33.default.basename(workflowArg),
87471
+ schedule_type: hasCron ? "cron" : "once",
87472
+ timezone: options.timezone?.trim() || "UTC",
87473
+ workflowRequest: {
87474
+ workflow: input.workflow,
87475
+ fileType: input.fileType,
87476
+ ...input.sourceFileType ? { sourceFileType: input.sourceFileType } : {}
87477
+ }
87478
+ };
87479
+ if (options.description?.trim()) {
87480
+ requestBody.description = options.description.trim();
87481
+ }
87482
+ if (hasCron) {
87483
+ requestBody.cron_expression = options.cron?.trim();
87484
+ } else {
87485
+ const scheduledAt = new Date(String(options.at));
87486
+ if (Number.isNaN(scheduledAt.getTime())) {
87487
+ throw new Error(`Invalid date for --at: ${options.at}`);
87488
+ }
87489
+ requestBody.scheduled_at = scheduledAt.toISOString();
87490
+ }
87491
+ const { response } = await authorizedApiFetch(auth, "/api/v1/workflows/schedules", {
87492
+ method: "POST",
87493
+ headers: {
87494
+ "Content-Type": "application/json",
87495
+ Accept: "application/json"
87496
+ },
87497
+ body: JSON.stringify(requestBody)
87498
+ });
87499
+ const payload = await readJsonResponse(response);
87500
+ if (!response.ok) {
87501
+ throw new Error(`Workflow schedule failed: ${describeResponseError(response, payload)}`);
87502
+ }
87503
+ if (!isWorkflowScheduleEnvelope(payload)) {
87504
+ throw new Error("Workflow schedule response was not valid JSON.");
87505
+ }
87506
+ return payload.schedule;
87507
+ }
87508
+ async function listWorkflowSchedules(options = {}) {
87509
+ const apiUrl = options.apiUrl ?? defaultApiUrl();
87510
+ const auth = await ensureAuthenticated(apiUrl);
87511
+ const { response } = await authorizedApiFetch(auth, "/api/v1/workflows/schedules", {
87512
+ headers: { Accept: "application/json" }
87513
+ });
87514
+ const payload = await readJsonResponse(response);
87515
+ if (!response.ok) {
87516
+ throw new Error(`Schedule list failed: ${describeResponseError(response, payload)}`);
87517
+ }
87518
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
87519
+ throw new Error("Schedule list response was not valid JSON.");
87520
+ }
87521
+ const schedules = payload.schedules;
87522
+ if (!Array.isArray(schedules)) {
87523
+ throw new Error("Schedule list response was not valid JSON.");
87524
+ }
87525
+ return schedules.filter(isWorkflowSchedule);
87526
+ }
87527
+ async function readJsonResponse(response) {
87528
+ const rawBody = await response.text();
87529
+ if (!rawBody) {
87530
+ return null;
87531
+ }
87532
+ try {
87533
+ return JSON.parse(rawBody);
87534
+ } catch {
87535
+ return rawBody;
87536
+ }
87537
+ }
87538
+ function describeResponseError(response, payload) {
87539
+ if (typeof payload === "string" && payload.trim()) {
87540
+ return `${response.status} ${response.statusText}: ${payload.trim()}`;
87541
+ }
87542
+ if (payload && typeof payload === "object" && !Array.isArray(payload)) {
87543
+ const record2 = payload;
87544
+ const message = record2.error ?? record2.message;
87545
+ if (typeof message === "string" && message.trim()) {
87546
+ return `${response.status} ${response.statusText}: ${message.trim()}`;
87547
+ }
87548
+ }
87549
+ return `${response.status} ${response.statusText}`;
87550
+ }
87551
+ function isWorkflowScheduleEnvelope(payload) {
87552
+ return Boolean(payload) && typeof payload === "object" && !Array.isArray(payload) && isWorkflowSchedule(payload.schedule);
87553
+ }
87554
+ function isWorkflowSchedule(value) {
87555
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
87556
+ return false;
87557
+ }
87558
+ const record2 = value;
87559
+ const hasNullableString = (field) => record2[field] === null || typeof record2[field] === "string";
87560
+ return typeof record2.id === "string" && typeof record2.relaycronScheduleId === "string" && typeof record2.userId === "string" && typeof record2.workspaceId === "string" && typeof record2.organizationId === "string" && typeof record2.name === "string" && hasNullableString("description") && (record2.scheduleType === "once" || record2.scheduleType === "cron") && hasNullableString("cronExpression") && hasNullableString("scheduledAt") && typeof record2.timezone === "string" && typeof record2.status === "string" && hasNullableString("lastTriggeredRunId") && hasNullableString("lastTriggeredAt") && typeof record2.createdAt === "string" && typeof record2.updatedAt === "string";
87561
+ }
87562
+ function isMissingFileError(error51) {
87563
+ return Boolean(error51 && typeof error51 === "object" && "code" in error51 && error51.code === "ENOENT");
87564
+ }
87565
+
87566
+ // packages/cloud/src/lib/ssh-interactive.ts
87567
+ var DEBUG = process.env.AGENT_RELAY_DEBUG_SSH === "1";
87568
+
87569
+ // packages/sdk/dist/workflows/builder.js
87570
+ var import_node_path34 = __toESM(require("node:path"), 1);
87038
87571
  var import_yaml3 = __toESM(require_dist(), 1);
87039
87572
 
87040
87573
  // packages/sdk/dist/workflows/cloud-runner.js
@@ -87393,7 +87926,7 @@ var WorkflowBuilder = class {
87393
87926
  async run(options = {}) {
87394
87927
  const config2 = this.toConfig();
87395
87928
  const runnerCwd = options.cwd ?? process.cwd();
87396
- const dbPath = import_node_path31.default.join(runnerCwd, ".agent-relay", "workflow-runs.jsonl");
87929
+ const dbPath = import_node_path34.default.join(runnerCwd, ".agent-relay", "workflow-runs.jsonl");
87397
87930
  const db = new JsonFileWorkflowDb(dbPath);
87398
87931
  const runner = new WorkflowRunner({
87399
87932
  cwd: options.cwd,
@@ -88311,7 +88844,7 @@ var StateStore = class extends import_node_events5.EventEmitter {
88311
88844
 
88312
88845
  // packages/sdk/dist/workflows/templates.js
88313
88846
  var import_node_fs23 = require("node:fs");
88314
- var import_node_path32 = __toESM(require("node:path"), 1);
88847
+ var import_node_path35 = __toESM(require("node:path"), 1);
88315
88848
  var import_node_url2 = require("node:url");
88316
88849
  var import_yaml4 = __toESM(require_dist(), 1);
88317
88850
  var YAML_EXTENSIONS = [".yaml", ".yml"];
@@ -88336,7 +88869,7 @@ var TemplateRegistry = class {
88336
88869
  fetcher;
88337
88870
  constructor(options = {}) {
88338
88871
  this.builtInTemplatesDir = this.resolveBuiltInTemplatesDir(options.builtInTemplatesDir);
88339
- this.customTemplatesDir = options.customTemplatesDir ? import_node_path32.default.resolve(options.customTemplatesDir) : import_node_path32.default.resolve(options.workspaceDir ?? process.cwd(), ".relay/workflows");
88872
+ this.customTemplatesDir = options.customTemplatesDir ? import_node_path35.default.resolve(options.customTemplatesDir) : import_node_path35.default.resolve(options.workspaceDir ?? process.cwd(), ".relay/workflows");
88340
88873
  this.fetcher = options.fetcher ?? fetch;
88341
88874
  }
88342
88875
  listBuiltInTemplates() {
@@ -88410,12 +88943,12 @@ var TemplateRegistry = class {
88410
88943
  if (!templateName) {
88411
88944
  throw new Error('Template name is required. Provide name explicitly or include a string "name" field.');
88412
88945
  }
88413
- if (templateName.includes("/") || templateName.includes("\\") || templateName.includes("..") || import_node_path32.default.isAbsolute(templateName)) {
88946
+ if (templateName.includes("/") || templateName.includes("\\") || templateName.includes("..") || import_node_path35.default.isAbsolute(templateName)) {
88414
88947
  throw new Error(`Invalid template name: "${templateName}" contains path separators or traversal sequences`);
88415
88948
  }
88416
88949
  this.validateRelayConfig(parsed, url2);
88417
88950
  await import_node_fs23.promises.mkdir(this.customTemplatesDir, { recursive: true });
88418
- const targetPath = import_node_path32.default.join(this.customTemplatesDir, `${templateName}.yaml`);
88951
+ const targetPath = import_node_path35.default.join(this.customTemplatesDir, `${templateName}.yaml`);
88419
88952
  await import_node_fs23.promises.writeFile(targetPath, (0, import_yaml4.stringify)(parsed), "utf-8");
88420
88953
  return targetPath;
88421
88954
  }
@@ -88437,12 +88970,12 @@ var TemplateRegistry = class {
88437
88970
  }
88438
88971
  resolveBuiltInTemplatesDir(explicitDir) {
88439
88972
  if (explicitDir) {
88440
- return import_node_path32.default.resolve(explicitDir);
88973
+ return import_node_path35.default.resolve(explicitDir);
88441
88974
  }
88442
- const currentDir = import_node_path32.default.dirname((0, import_node_url2.fileURLToPath)(import_meta_url));
88975
+ const currentDir = import_node_path35.default.dirname((0, import_node_url2.fileURLToPath)(import_meta_url));
88443
88976
  const candidates = [
88444
- import_node_path32.default.resolve(currentDir, "builtin-templates"),
88445
- import_node_path32.default.resolve(currentDir, "../workflows/builtin-templates")
88977
+ import_node_path35.default.resolve(currentDir, "builtin-templates"),
88978
+ import_node_path35.default.resolve(currentDir, "../workflows/builtin-templates")
88446
88979
  ];
88447
88980
  for (const candidate of candidates) {
88448
88981
  if ((0, import_node_fs23.existsSync)(candidate)) {
@@ -88465,7 +88998,7 @@ var TemplateRegistry = class {
88465
88998
  }
88466
88999
  async findTemplatePath(directory, templateName) {
88467
89000
  for (const ext of YAML_EXTENSIONS) {
88468
- const candidate = import_node_path32.default.join(directory, `${templateName}${ext}`);
89001
+ const candidate = import_node_path35.default.join(directory, `${templateName}${ext}`);
88469
89002
  try {
88470
89003
  const stat2 = await import_node_fs23.promises.stat(candidate);
88471
89004
  if (stat2.isFile()) {
@@ -88813,8 +89346,8 @@ function pythonVerifyCommand() {
88813
89346
 
88814
89347
  // packages/sdk/dist/workflows/run-script.js
88815
89348
  var import_node_fs24 = __toESM(require("node:fs"), 1);
88816
- var import_node_path33 = __toESM(require("node:path"), 1);
88817
- var import_node_child_process9 = require("node:child_process");
89349
+ var import_node_path36 = __toESM(require("node:path"), 1);
89350
+ var import_node_child_process10 = require("node:child_process");
88818
89351
  function diag(msg) {
88819
89352
  try {
88820
89353
  process.stderr.write(`[agent-relay] ${msg}
@@ -88828,12 +89361,12 @@ function diag(msg) {
88828
89361
  }
88829
89362
  }
88830
89363
  function findLocalSdkWorkspace(startDir) {
88831
- let current = import_node_path33.default.resolve(startDir);
88832
- const root = import_node_path33.default.parse(current).root;
89364
+ let current = import_node_path36.default.resolve(startDir);
89365
+ const root = import_node_path36.default.parse(current).root;
88833
89366
  while (true) {
88834
- const packageJsonPath = import_node_path33.default.join(current, "package.json");
88835
- const sdkDir = import_node_path33.default.join(current, "packages", "sdk");
88836
- const sdkPackageJsonPath = import_node_path33.default.join(sdkDir, "package.json");
89367
+ const packageJsonPath = import_node_path36.default.join(current, "package.json");
89368
+ const sdkDir = import_node_path36.default.join(current, "packages", "sdk");
89369
+ const sdkPackageJsonPath = import_node_path36.default.join(sdkDir, "package.json");
88837
89370
  try {
88838
89371
  if (import_node_fs24.default.existsSync(packageJsonPath) && import_node_fs24.default.existsSync(sdkPackageJsonPath)) {
88839
89372
  const pkg = JSON.parse(import_node_fs24.default.readFileSync(packageJsonPath, "utf8"));
@@ -88846,14 +89379,14 @@ function findLocalSdkWorkspace(startDir) {
88846
89379
  }
88847
89380
  if (current === root)
88848
89381
  return null;
88849
- current = import_node_path33.default.dirname(current);
89382
+ current = import_node_path36.default.dirname(current);
88850
89383
  }
88851
89384
  }
88852
- function ensureLocalSdkWorkflowRuntime(startDir, execRunner = import_node_child_process9.execFileSync) {
89385
+ function ensureLocalSdkWorkflowRuntime(startDir, execRunner = import_node_child_process10.execFileSync) {
88853
89386
  const workspace = findLocalSdkWorkspace(startDir);
88854
89387
  if (!workspace)
88855
89388
  return;
88856
- const workflowsEntry = import_node_path33.default.join(workspace.sdkDir, "dist", "workflows", "index.js");
89389
+ const workflowsEntry = import_node_path36.default.join(workspace.sdkDir, "dist", "workflows", "index.js");
88857
89390
  if (import_node_fs24.default.existsSync(workflowsEntry))
88858
89391
  return;
88859
89392
  console.log("[agent-relay] Detected local @agent-relay/sdk workspace without built workflows runtime; building packages/sdk...");
@@ -88935,7 +89468,7 @@ function formatWorkflowParseError(parsed) {
88935
89468
  }
88936
89469
  async function spawnRunnerWithStderrCapture(command, args, env) {
88937
89470
  return new Promise((resolve4) => {
88938
- const child = (0, import_node_child_process9.spawn)(command, args, {
89471
+ const child = (0, import_node_child_process10.spawn)(command, args, {
88939
89472
  stdio: ["inherit", "inherit", "pipe"],
88940
89473
  env
88941
89474
  });
@@ -88958,14 +89491,14 @@ async function spawnRunnerWithStderrCapture(command, args, env) {
88958
89491
  }
88959
89492
  async function runScriptWorkflow(filePath, options = {}) {
88960
89493
  diag(`runScriptWorkflow: resolving ${filePath}`);
88961
- const resolved = import_node_path33.default.resolve(filePath);
89494
+ const resolved = import_node_path36.default.resolve(filePath);
88962
89495
  if (!import_node_fs24.default.existsSync(resolved)) {
88963
89496
  throw new Error(`File not found: ${resolved}`);
88964
89497
  }
88965
- const ext = import_node_path33.default.extname(resolved).toLowerCase();
88966
- const runIdFile = import_node_path33.default.join(process.cwd(), ".agent-relay", `script-run-id-${process.pid}-${Date.now()}.txt`);
89498
+ const ext = import_node_path36.default.extname(resolved).toLowerCase();
89499
+ const runIdFile = import_node_path36.default.join(process.cwd(), ".agent-relay", `script-run-id-${process.pid}-${Date.now()}.txt`);
88967
89500
  try {
88968
- import_node_fs24.default.mkdirSync(import_node_path33.default.dirname(runIdFile), { recursive: true });
89501
+ import_node_fs24.default.mkdirSync(import_node_path36.default.dirname(runIdFile), { recursive: true });
88969
89502
  } catch {
88970
89503
  }
88971
89504
  const childEnv = { ...process.env, AGENT_RELAY_RUN_ID_FILE: runIdFile };
@@ -89003,7 +89536,7 @@ Run ID: ${runId}`;
89003
89536
  };
89004
89537
  if (ext === ".ts" || ext === ".tsx") {
89005
89538
  diag("runScriptWorkflow: ensureLocalSdkWorkflowRuntime start");
89006
- ensureLocalSdkWorkflowRuntime(import_node_path33.default.dirname(resolved));
89539
+ ensureLocalSdkWorkflowRuntime(import_node_path36.default.dirname(resolved));
89007
89540
  diag("runScriptWorkflow: ensureLocalSdkWorkflowRuntime done");
89008
89541
  const wrapRunnerError = (runner, result) => {
89009
89542
  const parsed = parseTsxStderr(result.stderr);
@@ -89058,7 +89591,7 @@ Run ID: ${runId}`;
89058
89591
  const runners = ["python3", "python"];
89059
89592
  for (const runner of runners) {
89060
89593
  diag(`runScriptWorkflow: trying runner ${runner}`);
89061
- const spawnResult = (0, import_node_child_process9.spawnSync)(runner, [resolved], {
89594
+ const spawnResult = (0, import_node_child_process10.spawnSync)(runner, [resolved], {
89062
89595
  stdio: "inherit",
89063
89596
  env: childEnv
89064
89597
  });
@@ -89208,8 +89741,8 @@ var GitHubClient = class _GitHubClient {
89208
89741
  /**
89209
89742
  * Execute a raw GitHub API request through the selected adapter.
89210
89743
  */
89211
- async request(method, path25, options) {
89212
- return (await this.getAdapter()).request(method, path25, options);
89744
+ async request(method, path28, options) {
89745
+ return (await this.getAdapter()).request(method, path28, options);
89213
89746
  }
89214
89747
  /**
89215
89748
  * Execute any registered GitHub primitive action by action name.
@@ -89309,23 +89842,23 @@ var GitHubClient = class _GitHubClient {
89309
89842
  /**
89310
89843
  * List files or directories at a repository path.
89311
89844
  */
89312
- async listFiles(owner, repo, path25 = "", options = {}) {
89313
- return (await this.getAdapter()).listFiles({ owner, repo, path: path25, ...options });
89845
+ async listFiles(owner, repo, path28 = "", options = {}) {
89846
+ return (await this.getAdapter()).listFiles({ owner, repo, path: path28, ...options });
89314
89847
  }
89315
89848
  /**
89316
89849
  * Read a repository file and return decoded UTF-8 content.
89317
89850
  */
89318
- async readFile(owner, repo, path25, ref) {
89319
- return (await this.getAdapter()).readFile({ owner, repo, path: path25, ref });
89851
+ async readFile(owner, repo, path28, ref) {
89852
+ return (await this.getAdapter()).readFile({ owner, repo, path: path28, ref });
89320
89853
  }
89321
89854
  /**
89322
89855
  * Create a repository file with a commit message.
89323
89856
  */
89324
- async createFile(owner, repo, path25, content, message, options = {}) {
89857
+ async createFile(owner, repo, path28, content, message, options = {}) {
89325
89858
  await (await this.getAdapter()).createFile({
89326
89859
  owner,
89327
89860
  repo,
89328
- path: path25,
89861
+ path: path28,
89329
89862
  content,
89330
89863
  message,
89331
89864
  ...options
@@ -89334,11 +89867,11 @@ var GitHubClient = class _GitHubClient {
89334
89867
  /**
89335
89868
  * Update a repository file with a commit message.
89336
89869
  */
89337
- async updateFile(owner, repo, path25, content, message, sha, options = {}) {
89870
+ async updateFile(owner, repo, path28, content, message, sha, options = {}) {
89338
89871
  return (await this.getAdapter()).updateFile({
89339
89872
  owner,
89340
89873
  repo,
89341
- path: path25,
89874
+ path: path28,
89342
89875
  content,
89343
89876
  message,
89344
89877
  sha,
@@ -89348,11 +89881,11 @@ var GitHubClient = class _GitHubClient {
89348
89881
  /**
89349
89882
  * Delete a repository file with a commit message.
89350
89883
  */
89351
- async deleteFile(owner, repo, path25, sha, message, options = {}) {
89884
+ async deleteFile(owner, repo, path28, sha, message, options = {}) {
89352
89885
  await (await this.getAdapter()).deleteFile({
89353
89886
  owner,
89354
89887
  repo,
89355
- path: path25,
89888
+ path: path28,
89356
89889
  sha,
89357
89890
  message,
89358
89891
  ...options
@@ -89734,10 +90267,10 @@ function projectionToText(value) {
89734
90267
  }
89735
90268
  return JSON.stringify(value);
89736
90269
  }
89737
- function resolvePath2(value, path25) {
89738
- if (!path25) return value;
90270
+ function resolvePath2(value, path28) {
90271
+ if (!path28) return value;
89739
90272
  let current = value;
89740
- for (const segment of path25.split(".")) {
90273
+ for (const segment of path28.split(".")) {
89741
90274
  if (Array.isArray(current) && /^\d+$/.test(segment)) {
89742
90275
  current = current[Number(segment)];
89743
90276
  continue;
@@ -90053,13 +90586,13 @@ function slackStepConfigFromWorkflowStep(step, resolvedParams) {
90053
90586
  function renderSlackTemplates(value, data) {
90054
90587
  return value.replace(
90055
90588
  /\{\{\s*steps\.([A-Za-z0-9_-]+)\.output(?:\.([A-Za-z0-9_.-]+))?\s*\}\}/g,
90056
- (_match, step, path25) => {
90589
+ (_match, step, path28) => {
90057
90590
  const stepData = data.steps;
90058
90591
  if (!isRecord3(stepData)) return "";
90059
90592
  const entry = stepData[String(step)];
90060
90593
  if (!isRecord3(entry)) return "";
90061
90594
  const output = entry.output;
90062
- const resolved = typeof path25 === "string" && path25.length > 0 ? resolvePath3(output, path25) : output;
90595
+ const resolved = typeof path28 === "string" && path28.length > 0 ? resolvePath3(output, path28) : output;
90063
90596
  return projectionToText2(resolved);
90064
90597
  }
90065
90598
  );
@@ -90197,10 +90730,10 @@ function projectionToText2(value) {
90197
90730
  }
90198
90731
  return JSON.stringify(value);
90199
90732
  }
90200
- function resolvePath3(value, path25) {
90201
- if (!path25) return value;
90733
+ function resolvePath3(value, path28) {
90734
+ if (!path28) return value;
90202
90735
  let current = value;
90203
- for (const segment of path25.split(".")) {
90736
+ for (const segment of path28.split(".")) {
90204
90737
  if (Array.isArray(current) && /^\d+$/.test(segment)) {
90205
90738
  current = current[Number(segment)];
90206
90739
  continue;
@@ -90425,7 +90958,7 @@ function isValidAgentName(name) {
90425
90958
 
90426
90959
  // packages/utils/dist/logger.js
90427
90960
  var import_node_fs25 = __toESM(require("node:fs"), 1);
90428
- var import_node_path34 = __toESM(require("node:path"), 1);
90961
+ var import_node_path37 = __toESM(require("node:path"), 1);
90429
90962
  function getLogFile() {
90430
90963
  return process.env.AGENT_RELAY_LOG_FILE;
90431
90964
  }
@@ -90443,7 +90976,7 @@ var LEVEL_PRIORITY = {
90443
90976
  };
90444
90977
  var createdLogDirs = /* @__PURE__ */ new Set();
90445
90978
  function ensureLogDir(logFile) {
90446
- const logDir = import_node_path34.default.dirname(logFile);
90979
+ const logDir = import_node_path37.default.dirname(logFile);
90447
90980
  if (!createdLogDirs.has(logDir) && !import_node_fs25.default.existsSync(logDir)) {
90448
90981
  import_node_fs25.default.mkdirSync(logDir, { recursive: true });
90449
90982
  createdLogDirs.add(logDir);
@@ -90744,14 +91277,14 @@ function benchmarkPatterns(iterations = 1e4) {
90744
91277
  }
90745
91278
 
90746
91279
  // packages/utils/dist/command-resolver.js
90747
- var import_node_child_process12 = require("node:child_process");
91280
+ var import_node_child_process13 = require("node:child_process");
90748
91281
  var import_node_fs26 = __toESM(require("node:fs"), 1);
90749
91282
  function resolveCommand(command) {
90750
91283
  if (command.startsWith("/")) {
90751
91284
  return resolveSymlinks(command);
90752
91285
  }
90753
91286
  try {
90754
- const output = (0, import_node_child_process12.execSync)(`which ${command}`, {
91287
+ const output = (0, import_node_child_process13.execSync)(`which ${command}`, {
90755
91288
  encoding: "utf-8",
90756
91289
  stdio: ["pipe", "pipe", "pipe"],
90757
91290
  // Ensure we have a reasonable PATH
@@ -90785,7 +91318,7 @@ function resolveSymlinks(filePath) {
90785
91318
  }
90786
91319
  function commandExists(command) {
90787
91320
  try {
90788
- (0, import_node_child_process12.execSync)(`which ${command}`, {
91321
+ (0, import_node_child_process13.execSync)(`which ${command}`, {
90789
91322
  encoding: "utf-8",
90790
91323
  stdio: ["pipe", "pipe", "pipe"]
90791
91324
  });
@@ -90796,9 +91329,9 @@ function commandExists(command) {
90796
91329
  }
90797
91330
 
90798
91331
  // packages/utils/dist/git-remote.js
90799
- var fs9 = __toESM(require("node:fs"), 1);
90800
- var path21 = __toESM(require("node:path"), 1);
90801
- var import_node_child_process13 = require("node:child_process");
91332
+ var fs11 = __toESM(require("node:fs"), 1);
91333
+ var path24 = __toESM(require("node:path"), 1);
91334
+ var import_node_child_process14 = require("node:child_process");
90802
91335
  function parseGitRemoteUrl(url2) {
90803
91336
  if (!url2)
90804
91337
  return null;
@@ -90814,11 +91347,11 @@ function parseGitRemoteUrl(url2) {
90814
91347
  }
90815
91348
  function getGitRemoteUrl(workingDirectory, remoteName = "origin") {
90816
91349
  try {
90817
- const gitDir = path21.join(workingDirectory, ".git");
90818
- if (!fs9.existsSync(gitDir)) {
91350
+ const gitDir = path24.join(workingDirectory, ".git");
91351
+ if (!fs11.existsSync(gitDir)) {
90819
91352
  return null;
90820
91353
  }
90821
- const result = (0, import_node_child_process13.execSync)(`git remote get-url ${remoteName}`, {
91354
+ const result = (0, import_node_child_process14.execSync)(`git remote get-url ${remoteName}`, {
90822
91355
  cwd: workingDirectory,
90823
91356
  encoding: "utf-8",
90824
91357
  timeout: 5e3,
@@ -90827,11 +91360,11 @@ function getGitRemoteUrl(workingDirectory, remoteName = "origin") {
90827
91360
  return result.trim() || null;
90828
91361
  } catch {
90829
91362
  try {
90830
- const configPath = path21.join(workingDirectory, ".git", "config");
90831
- if (!fs9.existsSync(configPath)) {
91363
+ const configPath = path24.join(workingDirectory, ".git", "config");
91364
+ if (!fs11.existsSync(configPath)) {
90832
91365
  return null;
90833
91366
  }
90834
- const config2 = fs9.readFileSync(configPath, "utf-8");
91367
+ const config2 = fs11.readFileSync(configPath, "utf-8");
90835
91368
  const remoteSection = new RegExp(`\\[remote\\s+"${remoteName}"\\][^\\[]*url\\s*=\\s*([^\\n]+)`, "i");
90836
91369
  const match = config2.match(remoteSection);
90837
91370
  return match?.[1]?.trim() || null;
@@ -90848,13 +91381,13 @@ function getRepoFullName(workingDirectory) {
90848
91381
  return parseGitRemoteUrl(remoteUrl);
90849
91382
  }
90850
91383
  function findGitRoot(startPath) {
90851
- let currentPath = path21.resolve(startPath);
90852
- const root = path21.parse(currentPath).root;
91384
+ let currentPath = path24.resolve(startPath);
91385
+ const root = path24.parse(currentPath).root;
90853
91386
  while (currentPath !== root) {
90854
- if (fs9.existsSync(path21.join(currentPath, ".git"))) {
91387
+ if (fs11.existsSync(path24.join(currentPath, ".git"))) {
90855
91388
  return currentPath;
90856
91389
  }
90857
- currentPath = path21.dirname(currentPath);
91390
+ currentPath = path24.dirname(currentPath);
90858
91391
  }
90859
91392
  return null;
90860
91393
  }
@@ -90872,16 +91405,16 @@ function getRepoFullNameFromPath(workingDirectory) {
90872
91405
 
90873
91406
  // packages/utils/dist/update-checker.js
90874
91407
  var import_node_fs27 = __toESM(require("node:fs"), 1);
90875
- var import_node_path35 = __toESM(require("node:path"), 1);
91408
+ var import_node_path38 = __toESM(require("node:path"), 1);
90876
91409
  var import_node_https2 = __toESM(require("node:https"), 1);
90877
- var import_node_os12 = __toESM(require("node:os"), 1);
91410
+ var import_node_os14 = __toESM(require("node:os"), 1);
90878
91411
  var import_compare_versions = __toESM(require_umd(), 1);
90879
91412
  var PACKAGE_NAME = "agent-relay";
90880
91413
  var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
90881
91414
  var NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
90882
91415
  function getCachePath() {
90883
- const cacheDir = import_node_path35.default.join(import_node_os12.default.homedir(), ".agent-relay");
90884
- return import_node_path35.default.join(cacheDir, "update-cache.json");
91416
+ const cacheDir = import_node_path38.default.join(import_node_os14.default.homedir(), ".agent-relay");
91417
+ return import_node_path38.default.join(cacheDir, "update-cache.json");
90885
91418
  }
90886
91419
  function readCache() {
90887
91420
  try {
@@ -90897,7 +91430,7 @@ function readCache() {
90897
91430
  function writeCache(cache) {
90898
91431
  try {
90899
91432
  const cachePath = getCachePath();
90900
- const cacheDir = import_node_path35.default.dirname(cachePath);
91433
+ const cacheDir = import_node_path38.default.dirname(cachePath);
90901
91434
  if (!import_node_fs27.default.existsSync(cacheDir)) {
90902
91435
  import_node_fs27.default.mkdirSync(cacheDir, { recursive: true });
90903
91436
  }
@@ -91181,8 +91714,8 @@ function validateModelForCli(cli, model) {
91181
91714
 
91182
91715
  // packages/utils/dist/relay-pty-path.js
91183
91716
  var import_node_fs28 = __toESM(require("node:fs"), 1);
91184
- var import_node_os13 = __toESM(require("node:os"), 1);
91185
- var import_node_path36 = __toESM(require("node:path"), 1);
91717
+ var import_node_os15 = __toESM(require("node:os"), 1);
91718
+ var import_node_path39 = __toESM(require("node:path"), 1);
91186
91719
  var SUPPORTED_PLATFORMS = {
91187
91720
  darwin: {
91188
91721
  arm64: "relay-pty-darwin-arm64",
@@ -91194,20 +91727,20 @@ var SUPPORTED_PLATFORMS = {
91194
91727
  }
91195
91728
  };
91196
91729
  function getPlatformBinaryName() {
91197
- const platform2 = import_node_os13.default.platform();
91198
- const arch = import_node_os13.default.arch();
91730
+ const platform2 = import_node_os15.default.platform();
91731
+ const arch = import_node_os15.default.arch();
91199
91732
  return SUPPORTED_PLATFORMS[platform2]?.[arch] ?? null;
91200
91733
  }
91201
91734
  function isPlatformSupported() {
91202
- const platform2 = import_node_os13.default.platform();
91203
- const arch = import_node_os13.default.arch();
91735
+ const platform2 = import_node_os15.default.platform();
91736
+ const arch = import_node_os15.default.arch();
91204
91737
  return SUPPORTED_PLATFORMS[platform2]?.[arch] !== void 0;
91205
91738
  }
91206
91739
  function getSupportedPlatforms() {
91207
91740
  const platforms = [];
91208
- for (const [os12, archs] of Object.entries(SUPPORTED_PLATFORMS)) {
91741
+ for (const [os14, archs] of Object.entries(SUPPORTED_PLATFORMS)) {
91209
91742
  for (const arch of Object.keys(archs)) {
91210
- platforms.push(`${os12}-${arch}`);
91743
+ platforms.push(`${os14}-${arch}`);
91211
91744
  }
91212
91745
  }
91213
91746
  return platforms.join(", ");
@@ -91230,22 +91763,22 @@ function findRelayPtyBinary(callerDirname) {
91230
91763
  const scopedMatch = normalizedCaller.match(/^(.+?\/node_modules)\/@agent-relay\//);
91231
91764
  const directMatch = normalizedCaller.match(/^(.+?\/node_modules\/agent-relay)/);
91232
91765
  if (scopedMatch) {
91233
- packageRoots.push(import_node_path36.default.join(scopedMatch[1], "agent-relay"));
91766
+ packageRoots.push(import_node_path39.default.join(scopedMatch[1], "agent-relay"));
91234
91767
  }
91235
91768
  if (directMatch) {
91236
91769
  packageRoots.push(directMatch[1]);
91237
91770
  }
91238
91771
  if (!normalizedCaller.includes("node_modules")) {
91239
- packageRoots.push(import_node_path36.default.join(callerDirname, "..", "..", ".."));
91772
+ packageRoots.push(import_node_path39.default.join(callerDirname, "..", "..", ".."));
91240
91773
  }
91241
91774
  const home = process.env.HOME || process.env.USERPROFILE || "";
91242
91775
  if (home) {
91243
- const npxCacheBase = import_node_path36.default.join(home, ".npm", "_npx");
91776
+ const npxCacheBase = import_node_path39.default.join(home, ".npm", "_npx");
91244
91777
  if (import_node_fs28.default.existsSync(npxCacheBase)) {
91245
91778
  try {
91246
91779
  const entries = import_node_fs28.default.readdirSync(npxCacheBase);
91247
91780
  for (const entry of entries) {
91248
- const npxPackage = import_node_path36.default.join(npxCacheBase, entry, "node_modules", "agent-relay");
91781
+ const npxPackage = import_node_path39.default.join(npxCacheBase, entry, "node_modules", "agent-relay");
91249
91782
  if (import_node_fs28.default.existsSync(npxPackage)) {
91250
91783
  packageRoots.push(npxPackage);
91251
91784
  }
@@ -91254,42 +91787,42 @@ function findRelayPtyBinary(callerDirname) {
91254
91787
  }
91255
91788
  }
91256
91789
  }
91257
- packageRoots.push(import_node_path36.default.join(process.cwd(), "node_modules", "agent-relay"));
91790
+ packageRoots.push(import_node_path39.default.join(process.cwd(), "node_modules", "agent-relay"));
91258
91791
  if (home) {
91259
- packageRoots.push(import_node_path36.default.join(home, ".nvm", "versions", "node", process.version, "lib", "node_modules", "agent-relay"));
91260
- packageRoots.push(import_node_path36.default.join(home, ".volta", "tools", "image", "packages", "agent-relay", "lib", "node_modules", "agent-relay"));
91261
- packageRoots.push(import_node_path36.default.join(home, ".fnm", "node-versions", process.version, "installation", "lib", "node_modules", "agent-relay"));
91262
- packageRoots.push(import_node_path36.default.join(home, "n", "lib", "node_modules", "agent-relay"));
91263
- packageRoots.push(import_node_path36.default.join(home, ".asdf", "installs", "nodejs", process.version.replace("v", ""), "lib", "node_modules", "agent-relay"));
91264
- packageRoots.push(import_node_path36.default.join(home, ".local", "share", "pnpm", "global", "node_modules", "agent-relay"));
91265
- packageRoots.push(import_node_path36.default.join(home, ".config", "yarn", "global", "node_modules", "agent-relay"));
91266
- packageRoots.push(import_node_path36.default.join(home, ".yarn", "global", "node_modules", "agent-relay"));
91267
- }
91268
- const bashInstallerDir = process.env.AGENT_RELAY_INSTALL_DIR ? import_node_path36.default.join(process.env.AGENT_RELAY_INSTALL_DIR, "bin") : home ? import_node_path36.default.join(home, ".agent-relay", "bin") : null;
91269
- const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ? import_node_path36.default.join(home, ".local", "bin") : null);
91270
- const nodePrefix = import_node_path36.default.resolve(import_node_path36.default.dirname(process.execPath), "..");
91271
- packageRoots.push(import_node_path36.default.join(nodePrefix, "lib", "node_modules", "agent-relay"));
91792
+ packageRoots.push(import_node_path39.default.join(home, ".nvm", "versions", "node", process.version, "lib", "node_modules", "agent-relay"));
91793
+ packageRoots.push(import_node_path39.default.join(home, ".volta", "tools", "image", "packages", "agent-relay", "lib", "node_modules", "agent-relay"));
91794
+ packageRoots.push(import_node_path39.default.join(home, ".fnm", "node-versions", process.version, "installation", "lib", "node_modules", "agent-relay"));
91795
+ packageRoots.push(import_node_path39.default.join(home, "n", "lib", "node_modules", "agent-relay"));
91796
+ packageRoots.push(import_node_path39.default.join(home, ".asdf", "installs", "nodejs", process.version.replace("v", ""), "lib", "node_modules", "agent-relay"));
91797
+ packageRoots.push(import_node_path39.default.join(home, ".local", "share", "pnpm", "global", "node_modules", "agent-relay"));
91798
+ packageRoots.push(import_node_path39.default.join(home, ".config", "yarn", "global", "node_modules", "agent-relay"));
91799
+ packageRoots.push(import_node_path39.default.join(home, ".yarn", "global", "node_modules", "agent-relay"));
91800
+ }
91801
+ 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;
91802
+ const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ? import_node_path39.default.join(home, ".local", "bin") : null);
91803
+ const nodePrefix = import_node_path39.default.resolve(import_node_path39.default.dirname(process.execPath), "..");
91804
+ packageRoots.push(import_node_path39.default.join(nodePrefix, "lib", "node_modules", "agent-relay"));
91272
91805
  packageRoots.push("/usr/local/lib/node_modules/agent-relay");
91273
91806
  packageRoots.push("/opt/homebrew/lib/node_modules/agent-relay");
91274
91807
  packageRoots.push("/usr/lib/node_modules/agent-relay");
91275
91808
  const candidates = [];
91276
91809
  for (const root of packageRoots) {
91277
91810
  if (platformBinary) {
91278
- candidates.push(import_node_path36.default.join(root, "bin", platformBinary));
91811
+ candidates.push(import_node_path39.default.join(root, "bin", platformBinary));
91279
91812
  }
91280
- candidates.push(import_node_path36.default.join(root, "bin", "relay-pty"));
91813
+ candidates.push(import_node_path39.default.join(root, "bin", "relay-pty"));
91281
91814
  }
91282
91815
  if (bashInstallerDir) {
91283
91816
  if (platformBinary) {
91284
- candidates.push(import_node_path36.default.join(bashInstallerDir, platformBinary));
91817
+ candidates.push(import_node_path39.default.join(bashInstallerDir, platformBinary));
91285
91818
  }
91286
- candidates.push(import_node_path36.default.join(bashInstallerDir, "relay-pty"));
91819
+ candidates.push(import_node_path39.default.join(bashInstallerDir, "relay-pty"));
91287
91820
  }
91288
91821
  if (bashInstallerBinDir) {
91289
91822
  if (platformBinary) {
91290
- candidates.push(import_node_path36.default.join(bashInstallerBinDir, platformBinary));
91823
+ candidates.push(import_node_path39.default.join(bashInstallerBinDir, platformBinary));
91291
91824
  }
91292
- candidates.push(import_node_path36.default.join(bashInstallerBinDir, "relay-pty"));
91825
+ candidates.push(import_node_path39.default.join(bashInstallerBinDir, "relay-pty"));
91293
91826
  }
91294
91827
  candidates.push("/app/bin/relay-pty");
91295
91828
  candidates.push("/usr/local/bin/relay-pty");
@@ -91320,7 +91853,7 @@ function isPlatformCompatibleBinary(filePath) {
91320
91853
  return false;
91321
91854
  }
91322
91855
  const magic = header.readUInt32BE(0);
91323
- const platform2 = import_node_os13.default.platform();
91856
+ const platform2 = import_node_os15.default.platform();
91324
91857
  if (platform2 === "darwin") {
91325
91858
  return isMachOBinary(magic);
91326
91859
  }
@@ -91949,56 +92482,56 @@ var HookRegistry = class {
91949
92482
  };
91950
92483
 
91951
92484
  // packages/trajectory/dist/integration.js
91952
- var import_node_child_process14 = require("node:child_process");
92485
+ var import_node_child_process15 = require("node:child_process");
91953
92486
 
91954
92487
  // packages/config/dist/project-namespace.js
91955
92488
  var import_node_crypto16 = __toESM(require("node:crypto"), 1);
91956
- var import_node_path37 = __toESM(require("node:path"), 1);
92489
+ var import_node_path40 = __toESM(require("node:path"), 1);
91957
92490
  var import_node_fs29 = __toESM(require("node:fs"), 1);
91958
- var import_node_os14 = __toESM(require("node:os"), 1);
92491
+ var import_node_os16 = __toESM(require("node:os"), 1);
91959
92492
  function getGlobalBaseDir2() {
91960
92493
  if (process.env.AGENT_RELAY_DATA_DIR) {
91961
92494
  return process.env.AGENT_RELAY_DATA_DIR;
91962
92495
  }
91963
92496
  const xdgDataHome = process.env.XDG_DATA_HOME;
91964
92497
  if (xdgDataHome) {
91965
- return import_node_path37.default.join(xdgDataHome, "agent-relay");
92498
+ return import_node_path40.default.join(xdgDataHome, "agent-relay");
91966
92499
  }
91967
- return import_node_path37.default.join(import_node_os14.default.homedir(), ".agent-relay");
92500
+ return import_node_path40.default.join(import_node_os16.default.homedir(), ".agent-relay");
91968
92501
  }
91969
92502
  var GLOBAL_BASE_DIR2 = getGlobalBaseDir2();
91970
92503
  var PROJECT_DATA_DIR = ".agent-relay";
91971
92504
  function hashPath(projectPath) {
91972
- const normalized = import_node_path37.default.resolve(projectPath);
92505
+ const normalized = import_node_path40.default.resolve(projectPath);
91973
92506
  const hash2 = import_node_crypto16.default.createHash("sha256").update(normalized).digest("hex");
91974
92507
  return hash2.substring(0, 12);
91975
92508
  }
91976
92509
  function findProjectRoot(startDir = process.cwd()) {
91977
92510
  if (process.env.AGENT_RELAY_PROJECT) {
91978
- return import_node_path37.default.resolve(process.env.AGENT_RELAY_PROJECT);
92511
+ return import_node_path40.default.resolve(process.env.AGENT_RELAY_PROJECT);
91979
92512
  }
91980
- let current = import_node_path37.default.resolve(startDir);
91981
- const root = import_node_path37.default.parse(current).root;
92513
+ let current = import_node_path40.default.resolve(startDir);
92514
+ const root = import_node_path40.default.parse(current).root;
91982
92515
  const markers = [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".agent-relay"];
91983
92516
  while (current !== root) {
91984
92517
  for (const marker of markers) {
91985
- if (import_node_fs29.default.existsSync(import_node_path37.default.join(current, marker))) {
92518
+ if (import_node_fs29.default.existsSync(import_node_path40.default.join(current, marker))) {
91986
92519
  return current;
91987
92520
  }
91988
92521
  }
91989
- current = import_node_path37.default.dirname(current);
92522
+ current = import_node_path40.default.dirname(current);
91990
92523
  }
91991
- return import_node_path37.default.resolve(startDir);
92524
+ return import_node_path40.default.resolve(startDir);
91992
92525
  }
91993
92526
  function getProjectPaths2(projectRoot) {
91994
92527
  const root = projectRoot ?? findProjectRoot();
91995
92528
  const projectId = hashPath(root);
91996
- const dataDir = import_node_path37.default.join(root, PROJECT_DATA_DIR);
92529
+ const dataDir = import_node_path40.default.join(root, PROJECT_DATA_DIR);
91997
92530
  return {
91998
92531
  dataDir,
91999
- teamDir: import_node_path37.default.join(dataDir, "team"),
92000
- dbPath: import_node_path37.default.join(dataDir, "messages.sqlite"),
92001
- socketPath: import_node_path37.default.join(dataDir, "relay.sock"),
92532
+ teamDir: import_node_path40.default.join(dataDir, "team"),
92533
+ dbPath: import_node_path40.default.join(dataDir, "messages.sqlite"),
92534
+ socketPath: import_node_path40.default.join(dataDir, "relay.sock"),
92002
92535
  projectRoot: root,
92003
92536
  projectId
92004
92537
  };
@@ -92006,15 +92539,15 @@ function getProjectPaths2(projectRoot) {
92006
92539
 
92007
92540
  // packages/config/dist/trajectory-config.js
92008
92541
  var import_node_fs30 = require("node:fs");
92009
- var import_node_path38 = require("node:path");
92010
- var import_node_os15 = require("node:os");
92542
+ var import_node_path41 = require("node:path");
92543
+ var import_node_os17 = require("node:os");
92011
92544
  var import_node_crypto17 = require("node:crypto");
92012
92545
  function getAgentRelayConfigDir() {
92013
- return process.env.AGENT_RELAY_CONFIG_DIR ?? (0, import_node_path38.join)((0, import_node_os15.homedir)(), ".config", "agent-relay");
92546
+ return process.env.AGENT_RELAY_CONFIG_DIR ?? (0, import_node_path41.join)((0, import_node_os17.homedir)(), ".config", "agent-relay");
92014
92547
  }
92015
92548
  var configCache = null;
92016
92549
  function getRelayConfigPath(_projectRoot) {
92017
- return (0, import_node_path38.join)(getAgentRelayConfigDir(), "relay.json");
92550
+ return (0, import_node_path41.join)(getAgentRelayConfigDir(), "relay.json");
92018
92551
  }
92019
92552
  function readRelayConfig(projectRoot) {
92020
92553
  const configPath = getRelayConfigPath(projectRoot);
@@ -92054,12 +92587,12 @@ function getProjectHash(projectRoot) {
92054
92587
  }
92055
92588
  function getUserTrajectoriesDir(projectRoot) {
92056
92589
  const projectHash = getProjectHash(projectRoot);
92057
- const configDir = process.env.XDG_CONFIG_HOME || (0, import_node_path38.join)((0, import_node_os15.homedir)(), ".config");
92058
- return (0, import_node_path38.join)(configDir, "agent-relay", "trajectories", projectHash);
92590
+ const configDir = process.env.XDG_CONFIG_HOME || (0, import_node_path41.join)((0, import_node_os17.homedir)(), ".config");
92591
+ return (0, import_node_path41.join)(configDir, "agent-relay", "trajectories", projectHash);
92059
92592
  }
92060
92593
  function getRepoTrajectoriesDir(projectRoot) {
92061
92594
  const root = projectRoot ?? getProjectPaths2().projectRoot;
92062
- return (0, import_node_path38.join)(root, ".trajectories");
92595
+ return (0, import_node_path41.join)(root, ".trajectories");
92063
92596
  }
92064
92597
  function getPrimaryTrajectoriesDir(projectRoot) {
92065
92598
  if (shouldStoreInRepo(projectRoot)) {
@@ -92078,7 +92611,7 @@ function getTrajectoryEnvVars(projectRoot) {
92078
92611
  async function runTrail(args) {
92079
92612
  return new Promise((resolve4) => {
92080
92613
  const trajectoryEnv = getTrajectoryEnvVars();
92081
- const proc = (0, import_node_child_process14.spawn)("trail", args, {
92614
+ const proc = (0, import_node_child_process15.spawn)("trail", args, {
92082
92615
  cwd: getProjectPaths2().projectRoot,
92083
92616
  env: { ...process.env, ...trajectoryEnv },
92084
92617
  stdio: ["pipe", "pipe", "pipe"]
@@ -92349,7 +92882,7 @@ var TrajectoryIntegration = class {
92349
92882
  */
92350
92883
  isTrailInstalledSync() {
92351
92884
  try {
92352
- (0, import_node_child_process14.execSync)("which trail", { stdio: "pipe" });
92885
+ (0, import_node_child_process15.execSync)("which trail", { stdio: "pipe" });
92353
92886
  return true;
92354
92887
  } catch {
92355
92888
  return false;
@@ -92700,7 +93233,7 @@ var HookEmitter = class {
92700
93233
 
92701
93234
  // packages/hooks/dist/inbox-check/utils.js
92702
93235
  var import_node_fs31 = require("node:fs");
92703
- var import_node_path39 = require("node:path");
93236
+ var import_node_path42 = require("node:path");
92704
93237
  var DEFAULT_INBOX_DIR = "/tmp/agent-relay";
92705
93238
  function getAgentName() {
92706
93239
  return process.env.AGENT_RELAY_NAME;
@@ -92710,7 +93243,7 @@ function getInboxPath(config2) {
92710
93243
  if (!agentName) {
92711
93244
  throw new Error("Agent name not configured. Set AGENT_RELAY_NAME env var.");
92712
93245
  }
92713
- return (0, import_node_path39.join)(config2.inboxDir, agentName, "inbox.md");
93246
+ return (0, import_node_path42.join)(config2.inboxDir, agentName, "inbox.md");
92714
93247
  }
92715
93248
  function inboxExists(inboxPath) {
92716
93249
  return (0, import_node_fs31.existsSync)(inboxPath);
@@ -92959,6 +93492,7 @@ init_dist2();
92959
93492
  isWorktreeStep,
92960
93493
  listLoggedAgents,
92961
93494
  listPersonas,
93495
+ listWorkflowSchedules,
92962
93496
  loadCustomSteps,
92963
93497
  loadPersona,
92964
93498
  logAndTraceError,
@@ -92992,6 +93526,7 @@ init_dist2();
92992
93526
  runScriptWorkflow,
92993
93527
  runVerification,
92994
93528
  runWorkflow,
93529
+ scheduleWorkflow,
92995
93530
  scrubForChannel,
92996
93531
  scrubSecrets,
92997
93532
  sendToChannel,