agent-relay 6.0.14 → 6.0.16

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
  /**
@@ -10815,8 +10815,10 @@ ${cb}` : comment;
10815
10815
  }
10816
10816
  }
10817
10817
  if (afterDoc) {
10818
- Array.prototype.push.apply(doc.errors, this.errors);
10819
- Array.prototype.push.apply(doc.warnings, this.warnings);
10818
+ for (let i = 0; i < this.errors.length; ++i)
10819
+ doc.errors.push(this.errors[i]);
10820
+ for (let i = 0; i < this.warnings.length; ++i)
10821
+ doc.warnings.push(this.warnings[i]);
10820
10822
  } else {
10821
10823
  doc.errors = this.errors;
10822
10824
  doc.warnings = this.warnings;
@@ -11198,9 +11200,9 @@ var require_cst_visit = __commonJS({
11198
11200
  visit.BREAK = BREAK;
11199
11201
  visit.SKIP = SKIP;
11200
11202
  visit.REMOVE = REMOVE;
11201
- visit.itemAtPath = (cst, path25) => {
11203
+ visit.itemAtPath = (cst, path28) => {
11202
11204
  let item = cst;
11203
- for (const [field, index] of path25) {
11205
+ for (const [field, index] of path28) {
11204
11206
  const tok = item?.[field];
11205
11207
  if (tok && "items" in tok) {
11206
11208
  item = tok.items[index];
@@ -11209,23 +11211,23 @@ var require_cst_visit = __commonJS({
11209
11211
  }
11210
11212
  return item;
11211
11213
  };
11212
- visit.parentCollection = (cst, path25) => {
11213
- const parent = visit.itemAtPath(cst, path25.slice(0, -1));
11214
- const field = path25[path25.length - 1][0];
11214
+ visit.parentCollection = (cst, path28) => {
11215
+ const parent = visit.itemAtPath(cst, path28.slice(0, -1));
11216
+ const field = path28[path28.length - 1][0];
11215
11217
  const coll = parent?.[field];
11216
11218
  if (coll && "items" in coll)
11217
11219
  return coll;
11218
11220
  throw new Error("Parent collection not found");
11219
11221
  };
11220
- function _visit(path25, item, visitor) {
11221
- let ctrl = visitor(item, path25);
11222
+ function _visit(path28, item, visitor) {
11223
+ let ctrl = visitor(item, path28);
11222
11224
  if (typeof ctrl === "symbol")
11223
11225
  return ctrl;
11224
11226
  for (const field of ["key", "value"]) {
11225
11227
  const token = item[field];
11226
11228
  if (token && "items" in token) {
11227
11229
  for (let i = 0; i < token.items.length; ++i) {
11228
- const ci2 = _visit(Object.freeze(path25.concat([[field, i]])), token.items[i], visitor);
11230
+ const ci2 = _visit(Object.freeze(path28.concat([[field, i]])), token.items[i], visitor);
11229
11231
  if (typeof ci2 === "number")
11230
11232
  i = ci2 - 1;
11231
11233
  else if (ci2 === BREAK)
@@ -11236,10 +11238,10 @@ var require_cst_visit = __commonJS({
11236
11238
  }
11237
11239
  }
11238
11240
  if (typeof ctrl === "function" && field === "key")
11239
- ctrl = ctrl(item, path25);
11241
+ ctrl = ctrl(item, path28);
11240
11242
  }
11241
11243
  }
11242
- return typeof ctrl === "function" ? ctrl(item, path25) : ctrl;
11244
+ return typeof ctrl === "function" ? ctrl(item, path28) : ctrl;
11243
11245
  }
11244
11246
  exports2.visit = visit;
11245
11247
  }
@@ -11549,7 +11551,7 @@ var require_lexer = __commonJS({
11549
11551
  const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
11550
11552
  this.indentNext = this.indentValue + 1;
11551
11553
  this.indentValue += n;
11552
- return yield* this.parseBlockStart();
11554
+ return "block-start";
11553
11555
  }
11554
11556
  return "doc";
11555
11557
  }
@@ -11848,28 +11850,38 @@ var require_lexer = __commonJS({
11848
11850
  return 0;
11849
11851
  }
11850
11852
  *pushIndicators() {
11851
- switch (this.charAt(0)) {
11852
- case "!":
11853
- return (yield* this.pushTag()) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
11854
- case "&":
11855
- return (yield* this.pushUntil(isNotAnchorChar)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
11856
- case "-":
11857
- // this is an error
11858
- case "?":
11859
- // this is an error outside flow collections
11860
- case ":": {
11861
- const inFlow = this.flowLevel > 0;
11862
- const ch1 = this.charAt(1);
11863
- if (isEmpty(ch1) || inFlow && flowIndicatorChars.has(ch1)) {
11864
- if (!inFlow)
11865
- this.indentNext = this.indentValue + 1;
11866
- else if (this.flowKey)
11867
- this.flowKey = false;
11868
- return (yield* this.pushCount(1)) + (yield* this.pushSpaces(true)) + (yield* this.pushIndicators());
11853
+ let n = 0;
11854
+ loop: while (true) {
11855
+ switch (this.charAt(0)) {
11856
+ case "!":
11857
+ n += yield* this.pushTag();
11858
+ n += yield* this.pushSpaces(true);
11859
+ continue loop;
11860
+ case "&":
11861
+ n += yield* this.pushUntil(isNotAnchorChar);
11862
+ n += yield* this.pushSpaces(true);
11863
+ continue loop;
11864
+ case "-":
11865
+ // this is an error
11866
+ case "?":
11867
+ // this is an error outside flow collections
11868
+ case ":": {
11869
+ const inFlow = this.flowLevel > 0;
11870
+ const ch1 = this.charAt(1);
11871
+ if (isEmpty(ch1) || inFlow && flowIndicatorChars.has(ch1)) {
11872
+ if (!inFlow)
11873
+ this.indentNext = this.indentValue + 1;
11874
+ else if (this.flowKey)
11875
+ this.flowKey = false;
11876
+ n += yield* this.pushCount(1);
11877
+ n += yield* this.pushSpaces(true);
11878
+ continue loop;
11879
+ }
11869
11880
  }
11870
11881
  }
11882
+ break loop;
11871
11883
  }
11872
- return 0;
11884
+ return n;
11873
11885
  }
11874
11886
  *pushTag() {
11875
11887
  if (this.charAt(1) === "<") {
@@ -12028,6 +12040,13 @@ var require_parser = __commonJS({
12028
12040
  }
12029
12041
  return prev.splice(i, prev.length);
12030
12042
  }
12043
+ function arrayPushArray(target, source) {
12044
+ if (source.length < 1e5)
12045
+ Array.prototype.push.apply(target, source);
12046
+ else
12047
+ for (let i = 0; i < source.length; ++i)
12048
+ target.push(source[i]);
12049
+ }
12031
12050
  function fixFlowSeqItems(fc) {
12032
12051
  if (fc.start.type === "flow-seq-start") {
12033
12052
  for (const it2 of fc.items) {
@@ -12037,11 +12056,11 @@ var require_parser = __commonJS({
12037
12056
  delete it2.key;
12038
12057
  if (isFlowToken(it2.value)) {
12039
12058
  if (it2.value.end)
12040
- Array.prototype.push.apply(it2.value.end, it2.sep);
12059
+ arrayPushArray(it2.value.end, it2.sep);
12041
12060
  else
12042
12061
  it2.value.end = it2.sep;
12043
12062
  } else
12044
- Array.prototype.push.apply(it2.start, it2.sep);
12063
+ arrayPushArray(it2.start, it2.sep);
12045
12064
  delete it2.sep;
12046
12065
  }
12047
12066
  }
@@ -12396,7 +12415,7 @@ var require_parser = __commonJS({
12396
12415
  const prev = map2.items[map2.items.length - 2];
12397
12416
  const end = prev?.value?.end;
12398
12417
  if (Array.isArray(end)) {
12399
- Array.prototype.push.apply(end, it2.start);
12418
+ arrayPushArray(end, it2.start);
12400
12419
  end.push(this.sourceToken);
12401
12420
  map2.items.pop();
12402
12421
  return;
@@ -12524,14 +12543,14 @@ var require_parser = __commonJS({
12524
12543
  case "scalar":
12525
12544
  case "single-quoted-scalar":
12526
12545
  case "double-quoted-scalar": {
12527
- const fs13 = this.flowScalar(this.type);
12546
+ const fs15 = this.flowScalar(this.type);
12528
12547
  if (atNextItem || it2.value) {
12529
- map2.items.push({ start, key: fs13, sep: [] });
12548
+ map2.items.push({ start, key: fs15, sep: [] });
12530
12549
  this.onKeyLine = true;
12531
12550
  } else if (it2.sep) {
12532
- this.stack.push(fs13);
12551
+ this.stack.push(fs15);
12533
12552
  } else {
12534
- Object.assign(it2, { key: fs13, sep: [] });
12553
+ Object.assign(it2, { key: fs15, sep: [] });
12535
12554
  this.onKeyLine = true;
12536
12555
  }
12537
12556
  return;
@@ -12584,7 +12603,7 @@ var require_parser = __commonJS({
12584
12603
  const prev = seq.items[seq.items.length - 2];
12585
12604
  const end = prev?.value?.end;
12586
12605
  if (Array.isArray(end)) {
12587
- Array.prototype.push.apply(end, it2.start);
12606
+ arrayPushArray(end, it2.start);
12588
12607
  end.push(this.sourceToken);
12589
12608
  seq.items.pop();
12590
12609
  return;
@@ -12659,13 +12678,13 @@ var require_parser = __commonJS({
12659
12678
  case "scalar":
12660
12679
  case "single-quoted-scalar":
12661
12680
  case "double-quoted-scalar": {
12662
- const fs13 = this.flowScalar(this.type);
12681
+ const fs15 = this.flowScalar(this.type);
12663
12682
  if (!it2 || it2.value)
12664
- fc.items.push({ start: [], key: fs13, sep: [] });
12683
+ fc.items.push({ start: [], key: fs15, sep: [] });
12665
12684
  else if (it2.sep)
12666
- this.stack.push(fs13);
12685
+ this.stack.push(fs15);
12667
12686
  else
12668
- Object.assign(it2, { key: fs13, sep: [] });
12687
+ Object.assign(it2, { key: fs15, sep: [] });
12669
12688
  return;
12670
12689
  }
12671
12690
  case "flow-map-end":
@@ -13397,11 +13416,11 @@ __export(base_exports, {
13397
13416
  setCwd: () => setCwd,
13398
13417
  synchronizedOutput: () => synchronizedOutput
13399
13418
  });
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;
13419
+ 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
13420
  var init_base = __esm({
13402
13421
  "node_modules/ansi-escapes/base.js"() {
13403
13422
  import_node_process = __toESM(require("node:process"), 1);
13404
- import_node_os11 = __toESM(require("node:os"), 1);
13423
+ import_node_os13 = __toESM(require("node:os"), 1);
13405
13424
  init_environment();
13406
13425
  ESC = "\x1B[";
13407
13426
  OSC = "\x1B]";
@@ -13481,7 +13500,7 @@ var init_base = __esm({
13481
13500
  if (isBrowser || !isWindows2) {
13482
13501
  return false;
13483
13502
  }
13484
- const parts = import_node_os11.default.release().split(".");
13503
+ const parts = import_node_os13.default.release().split(".");
13485
13504
  const major = Number(parts[0]);
13486
13505
  const build = Number(parts[2] ?? 0);
13487
13506
  if (major < 10) {
@@ -18838,8 +18857,8 @@ function repoEndpoint(owner, repo, suffix = "") {
18838
18857
  assertOwnerRepo(owner, repo);
18839
18858
  return `/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}${suffix}`;
18840
18859
  }
18841
- function contentsEndpoint(owner, repo, path25 = "") {
18842
- const normalizedPath = normalizeRepoPath(path25);
18860
+ function contentsEndpoint(owner, repo, path28 = "") {
18861
+ const normalizedPath = normalizeRepoPath(path28);
18843
18862
  const suffix = normalizedPath ? `/contents/${encodeRepoPath(normalizedPath)}` : "/contents";
18844
18863
  return repoEndpoint(owner, repo, suffix);
18845
18864
  }
@@ -18847,8 +18866,8 @@ function branchEndpoint(owner, repo, branch) {
18847
18866
  const normalizedBranch = assertNonEmptyString(branch, "branch");
18848
18867
  return repoEndpoint(owner, repo, `/branches/${encodeURIComponent(normalizedBranch)}`);
18849
18868
  }
18850
- function normalizeRepoPath(path25) {
18851
- return path25?.trim().replace(/^\/+/, "").replace(/\/+$/, "") ?? "";
18869
+ function normalizeRepoPath(path28) {
18870
+ return path28?.trim().replace(/^\/+/, "").replace(/\/+$/, "") ?? "";
18852
18871
  }
18853
18872
  function normalizePerPage(perPage) {
18854
18873
  if (typeof perPage === "undefined") {
@@ -18874,9 +18893,9 @@ function hasDefinedValue(values) {
18874
18893
  function optionalRecord(value) {
18875
18894
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
18876
18895
  }
18877
- function appendQuery(path25, query) {
18896
+ function appendQuery(path28, query) {
18878
18897
  if (!query) {
18879
- return path25;
18898
+ return path28;
18880
18899
  }
18881
18900
  const params = new URLSearchParams();
18882
18901
  for (const [name, rawValue] of Object.entries(query)) {
@@ -18889,9 +18908,9 @@ function appendQuery(path25, query) {
18889
18908
  }
18890
18909
  const serialized = params.toString();
18891
18910
  if (!serialized) {
18892
- return path25;
18911
+ return path28;
18893
18912
  }
18894
- return `${path25}${path25.includes("?") ? "&" : "?"}${serialized}`;
18913
+ return `${path28}${path28.includes("?") ? "&" : "?"}${serialized}`;
18895
18914
  }
18896
18915
  function nonEmpty(value) {
18897
18916
  const trimmed = value?.trim();
@@ -18966,8 +18985,8 @@ function visibilityValue(value, isPrivate) {
18966
18985
  function errorMessage(error51) {
18967
18986
  return error51 instanceof Error ? error51.message : String(error51);
18968
18987
  }
18969
- function encodeRepoPath(path25) {
18970
- return path25.split("/").map(encodeURIComponent).join("/");
18988
+ function encodeRepoPath(path28) {
18989
+ return path28.split("/").map(encodeURIComponent).join("/");
18971
18990
  }
18972
18991
  var init_utils = __esm({
18973
18992
  "packages/github-primitive/src/actions/utils.ts"() {
@@ -19104,10 +19123,10 @@ var init_commits = __esm({
19104
19123
  });
19105
19124
 
19106
19125
  // 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 () => {
19126
+ async function listFiles(adapter, owner, repo, path28 = "", options = {}) {
19127
+ return withActionError(`list GitHub files at ${owner}/${repo}/${path28}`, async () => {
19109
19128
  assertOwnerRepo(owner, repo);
19110
- const response = await adapter.request("GET", contentsEndpoint(owner, repo, path25), {
19129
+ const response = await adapter.request("GET", contentsEndpoint(owner, repo, path28), {
19111
19130
  query: {
19112
19131
  ref: options.ref
19113
19132
  }
@@ -19115,32 +19134,32 @@ async function listFiles(adapter, owner, repo, path25 = "", options = {}) {
19115
19134
  return Array.isArray(response) ? asArray(response, "repository contents").map(mapFile) : [mapFile(response)];
19116
19135
  });
19117
19136
  }
19118
- async function readFile3(adapter, owner, repo, path25, ref) {
19119
- return withActionError(`read GitHub file ${owner}/${repo}/${path25}`, async () => {
19137
+ async function readFile3(adapter, owner, repo, path28, ref) {
19138
+ return withActionError(`read GitHub file ${owner}/${repo}/${path28}`, async () => {
19120
19139
  assertOwnerRepo(owner, repo);
19121
- assertNonEmptyString(normalizeRepoPath(path25), "file path");
19122
- const response = await adapter.request("GET", contentsEndpoint(owner, repo, path25), {
19140
+ assertNonEmptyString(normalizeRepoPath(path28), "file path");
19141
+ const response = await adapter.request("GET", contentsEndpoint(owner, repo, path28), {
19123
19142
  query: {
19124
19143
  ref
19125
19144
  }
19126
19145
  });
19127
19146
  const file2 = mapFile(response);
19128
19147
  if (file2.type !== "file") {
19129
- throw new Error(`GitHub path "${path25}" is not a file.`);
19148
+ throw new Error(`GitHub path "${path28}" is not a file.`);
19130
19149
  }
19131
19150
  if (!file2.content) {
19132
- throw new Error(`GitHub file "${path25}" did not include content in the API response.`);
19151
+ throw new Error(`GitHub file "${path28}" did not include content in the API response.`);
19133
19152
  }
19134
19153
  if (file2.encoding && file2.encoding !== "base64") {
19135
- throw new Error(`GitHub file "${path25}" used unsupported encoding "${file2.encoding}".`);
19154
+ throw new Error(`GitHub file "${path28}" used unsupported encoding "${file2.encoding}".`);
19136
19155
  }
19137
19156
  return import_node_buffer.Buffer.from(file2.content.replace(/\s/g, ""), "base64").toString("utf8");
19138
19157
  });
19139
19158
  }
19140
- async function createFile(adapter, owner, repo, path25, content, message, options = {}) {
19141
- return withActionError(`create GitHub file ${owner}/${repo}/${path25}`, async () => {
19159
+ async function createFile(adapter, owner, repo, path28, content, message, options = {}) {
19160
+ return withActionError(`create GitHub file ${owner}/${repo}/${path28}`, async () => {
19142
19161
  assertOwnerRepo(owner, repo);
19143
- const normalizedPath = assertNonEmptyString(normalizeRepoPath(path25), "file path");
19162
+ const normalizedPath = assertNonEmptyString(normalizeRepoPath(path28), "file path");
19144
19163
  const commitMessage = assertNonEmptyString(message, "commit message");
19145
19164
  await adapter.request("PUT", contentsEndpoint(owner, repo, normalizedPath), {
19146
19165
  body: removeUndefinedValues({
@@ -19152,10 +19171,10 @@ async function createFile(adapter, owner, repo, path25, content, message, option
19152
19171
  });
19153
19172
  });
19154
19173
  }
19155
- async function updateFile(adapter, owner, repo, path25, content, message, sha, options = {}) {
19156
- return withActionError(`update GitHub file ${owner}/${repo}/${path25}`, async () => {
19174
+ async function updateFile(adapter, owner, repo, path28, content, message, sha, options = {}) {
19175
+ return withActionError(`update GitHub file ${owner}/${repo}/${path28}`, async () => {
19157
19176
  assertOwnerRepo(owner, repo);
19158
- const normalizedPath = assertNonEmptyString(normalizeRepoPath(path25), "file path");
19177
+ const normalizedPath = assertNonEmptyString(normalizeRepoPath(path28), "file path");
19159
19178
  const commitMessage = assertNonEmptyString(message, "commit message");
19160
19179
  const fileSha = assertNonEmptyString(sha, "file sha");
19161
19180
  const response = await adapter.request("PUT", contentsEndpoint(owner, repo, normalizedPath), {
@@ -19171,10 +19190,10 @@ async function updateFile(adapter, owner, repo, path25, content, message, sha, o
19171
19190
  return mapFile(contentRecord);
19172
19191
  });
19173
19192
  }
19174
- async function deleteFile(adapter, owner, repo, path25, sha, message, options = {}) {
19175
- return withActionError(`delete GitHub file ${owner}/${repo}/${path25}`, async () => {
19193
+ async function deleteFile(adapter, owner, repo, path28, sha, message, options = {}) {
19194
+ return withActionError(`delete GitHub file ${owner}/${repo}/${path28}`, async () => {
19176
19195
  assertOwnerRepo(owner, repo);
19177
- const normalizedPath = assertNonEmptyString(normalizeRepoPath(path25), "file path");
19196
+ const normalizedPath = assertNonEmptyString(normalizeRepoPath(path28), "file path");
19178
19197
  const fileSha = assertNonEmptyString(sha, "file sha");
19179
19198
  const commitMessage = assertNonEmptyString(message, "commit message");
19180
19199
  await adapter.request("DELETE", contentsEndpoint(owner, repo, normalizedPath), {
@@ -19538,15 +19557,15 @@ var init_repos = __esm({
19538
19557
  // packages/github-primitive/src/actions/users.ts
19539
19558
  async function getUser(adapter, params = {}) {
19540
19559
  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);
19560
+ const path28 = params.username ? `/users/${encodeURIComponent(assertNonEmptyString(params.username, "username"))}` : "/user";
19561
+ const response = await adapter.request("GET", path28);
19543
19562
  return mapUser(response);
19544
19563
  });
19545
19564
  }
19546
19565
  async function listOrganizations(adapter, params = {}) {
19547
19566
  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, {
19567
+ const path28 = params.username ? `/users/${encodeURIComponent(assertNonEmptyString(params.username, "username"))}/orgs` : "/user/orgs";
19568
+ const response = await adapter.request("GET", path28, {
19550
19569
  query: queryWithPerPage({}, params.perPage)
19551
19570
  });
19552
19571
  return asArray(response, "organizations").map(mapOrganization);
@@ -19588,11 +19607,11 @@ __export(local_runtime_exports, {
19588
19607
  GhCliClient: () => GhCliClient,
19589
19608
  GhCliError: () => GhCliError
19590
19609
  });
19591
- var import_node_child_process10, GhCliError, GhCliClient;
19610
+ var import_node_child_process11, GhCliError, GhCliClient;
19592
19611
  var init_local_runtime = __esm({
19593
19612
  "packages/github-primitive/src/local-runtime.ts"() {
19594
19613
  "use strict";
19595
- import_node_child_process10 = require("node:child_process");
19614
+ import_node_child_process11 = require("node:child_process");
19596
19615
  init_adapter();
19597
19616
  init_utils();
19598
19617
  init_types();
@@ -19647,9 +19666,9 @@ var init_local_runtime = __esm({
19647
19666
  type: user.type
19648
19667
  };
19649
19668
  }
19650
- async request(method, path25, options = {}) {
19669
+ async request(method, path28, options = {}) {
19651
19670
  return this.executeWithRetries(async () => {
19652
- const request = this.buildApiCommand(method, path25, options);
19671
+ const request = this.buildApiCommand(method, path28, options);
19653
19672
  const result = await this.runGhCommand(request.args, {
19654
19673
  input: request.input,
19655
19674
  parseJson: true,
@@ -19669,7 +19688,7 @@ var init_local_runtime = __esm({
19669
19688
  ...options.env
19670
19689
  };
19671
19690
  return new Promise((resolve4, reject) => {
19672
- const child = (0, import_node_child_process10.spawn)(command, args, {
19691
+ const child = (0, import_node_child_process11.spawn)(command, args, {
19673
19692
  cwd: options.cwd ?? this.config.cwd,
19674
19693
  env,
19675
19694
  stdio: ["pipe", "pipe", "pipe"]
@@ -19783,10 +19802,10 @@ var init_local_runtime = __esm({
19783
19802
  }
19784
19803
  });
19785
19804
  }
19786
- buildApiCommand(method, path25, options) {
19805
+ buildApiCommand(method, path28, options) {
19787
19806
  const args = [
19788
19807
  "api",
19789
- appendQuery(path25, options.query),
19808
+ appendQuery(path28, options.query),
19790
19809
  "--method",
19791
19810
  method,
19792
19811
  "--header",
@@ -19863,13 +19882,13 @@ async function parseJsonResponse(response) {
19863
19882
  );
19864
19883
  }
19865
19884
  }
19866
- function buildNangoProxyUrl(baseUrl, path25, query) {
19885
+ function buildNangoProxyUrl(baseUrl, path28, query) {
19867
19886
  const base = trimTrailingSlash(baseUrl) ?? DEFAULT_NANGO_BASE_URL;
19868
- const endpoint = stripLeadingSlash(path25);
19887
+ const endpoint = stripLeadingSlash(path28);
19869
19888
  return appendQuery(`${base}/proxy/${endpoint}`, query);
19870
19889
  }
19871
- function joinUrl(baseUrl, path25) {
19872
- return `${trimTrailingSlash(baseUrl) ?? baseUrl}/${stripLeadingSlash(path25)}`;
19890
+ function joinUrl(baseUrl, path28) {
19891
+ return `${trimTrailingSlash(baseUrl) ?? baseUrl}/${stripLeadingSlash(path28)}`;
19873
19892
  }
19874
19893
  function stripLeadingSlash(value) {
19875
19894
  return value.replace(/^\/+/, "");
@@ -19923,18 +19942,18 @@ var init_cloud_runtime = __esm({
19923
19942
  type: user.type
19924
19943
  };
19925
19944
  }
19926
- async request(method, path25, options = {}) {
19945
+ async request(method, path28, options = {}) {
19927
19946
  return this.executeWithRetries(async () => {
19928
19947
  if (this.hasNangoCredentials()) {
19929
19948
  try {
19930
- return await this.requestViaNango(method, path25, options);
19949
+ return await this.requestViaNango(method, path28, options);
19931
19950
  } catch (error51) {
19932
19951
  if (!this.hasRelayCloudCredentials()) {
19933
19952
  throw error51;
19934
19953
  }
19935
19954
  this.lastNangoFallbackError = error51;
19936
19955
  try {
19937
- return await this.requestViaRelayCloud(method, path25, options);
19956
+ return await this.requestViaRelayCloud(method, path28, options);
19938
19957
  } catch (relayError) {
19939
19958
  throw new GitHubApiError(
19940
19959
  `Nango GitHub proxy failed, then relay-cloud fallback failed: ${errorMessage2(relayError)}`,
@@ -19949,7 +19968,7 @@ var init_cloud_runtime = __esm({
19949
19968
  }
19950
19969
  }
19951
19970
  if (this.hasRelayCloudCredentials()) {
19952
- return this.requestViaRelayCloud(method, path25, options);
19971
+ return this.requestViaRelayCloud(method, path28, options);
19953
19972
  }
19954
19973
  throw new GitHubApiError(
19955
19974
  "Cloud GitHub runtime requires Nango credentials or relay-cloud proxy configuration."
@@ -19962,14 +19981,14 @@ var init_cloud_runtime = __esm({
19962
19981
  getLastNangoFallbackError() {
19963
19982
  return this.lastNangoFallbackError;
19964
19983
  }
19965
- async requestViaNango(method, path25, options) {
19984
+ async requestViaNango(method, path28, options) {
19966
19985
  const secretKey = this.config.nango.secretKey;
19967
19986
  const connectionId = this.config.nango.connectionId;
19968
19987
  const providerConfigKey = this.config.nango.providerConfigKey;
19969
19988
  if (!secretKey || !connectionId || !providerConfigKey) {
19970
19989
  throw new GitHubApiError("Nango GitHub proxy requires secretKey, connectionId, and providerConfigKey.");
19971
19990
  }
19972
- const url2 = buildNangoProxyUrl(this.config.nango.baseUrl, path25, options.query);
19991
+ const url2 = buildNangoProxyUrl(this.config.nango.baseUrl, path28, options.query);
19973
19992
  const response = await this.fetchWithTimeout(url2, {
19974
19993
  method,
19975
19994
  headers: {
@@ -19987,7 +20006,7 @@ var init_cloud_runtime = __esm({
19987
20006
  });
19988
20007
  return parseJsonResponse(response);
19989
20008
  }
19990
- async requestViaRelayCloud(method, path25, options) {
20009
+ async requestViaRelayCloud(method, path28, options) {
19991
20010
  const apiUrl = this.config.relayCloud.apiUrl;
19992
20011
  const accessToken = this.config.relayCloud.accessToken;
19993
20012
  const endpoint = this.config.relayCloud.endpoint ?? DEFAULT_RELAY_CLOUD_GITHUB_PROXY_ENDPOINT;
@@ -19996,7 +20015,7 @@ var init_cloud_runtime = __esm({
19996
20015
  }
19997
20016
  const payload = {
19998
20017
  method,
19999
- path: path25,
20018
+ path: path28,
20000
20019
  query: options.query,
20001
20020
  body: options.body,
20002
20021
  headers: options.headers,
@@ -20192,11 +20211,11 @@ function delay3(ms2) {
20192
20211
  setTimeout(resolve4, ms2);
20193
20212
  });
20194
20213
  }
20195
- var import_node_child_process11, import_node_util4, execFileAsync2, GitHubRuntimeDetector, BaseGitHubAdapter, GitHubAdapterFactory, GitHubClientFactory;
20214
+ var import_node_child_process12, import_node_util4, execFileAsync2, GitHubRuntimeDetector, BaseGitHubAdapter, GitHubAdapterFactory, GitHubClientFactory;
20196
20215
  var init_adapter = __esm({
20197
20216
  "packages/github-primitive/src/adapter.ts"() {
20198
20217
  "use strict";
20199
- import_node_child_process11 = require("node:child_process");
20218
+ import_node_child_process12 = require("node:child_process");
20200
20219
  import_node_util4 = require("node:util");
20201
20220
  init_branches();
20202
20221
  init_commits();
@@ -20208,7 +20227,7 @@ var init_adapter = __esm({
20208
20227
  init_utils();
20209
20228
  init_constants();
20210
20229
  init_types();
20211
- execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process11.execFile);
20230
+ execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process12.execFile);
20212
20231
  GitHubRuntimeDetector = class {
20213
20232
  static async detect(config2 = {}) {
20214
20233
  const normalized = normalizeGitHubRuntimeConfig(config2);
@@ -20373,23 +20392,23 @@ var init_adapter = __esm({
20373
20392
  return mergePR(this, owner, repo, pullNumber, options);
20374
20393
  }
20375
20394
  async listFiles(params) {
20376
- const { owner, repo, path: path25, ...options } = params;
20377
- return listFiles(this, owner, repo, path25, options);
20395
+ const { owner, repo, path: path28, ...options } = params;
20396
+ return listFiles(this, owner, repo, path28, options);
20378
20397
  }
20379
20398
  async readFile(params) {
20380
20399
  return readFile3(this, params.owner, params.repo, params.path, params.ref);
20381
20400
  }
20382
20401
  async createFile(params) {
20383
- const { owner, repo, path: path25, content, message, ...options } = params;
20384
- return createFile(this, owner, repo, path25, content, message, options);
20402
+ const { owner, repo, path: path28, content, message, ...options } = params;
20403
+ return createFile(this, owner, repo, path28, content, message, options);
20385
20404
  }
20386
20405
  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);
20406
+ const { owner, repo, path: path28, content, message, sha, ...options } = params;
20407
+ return updateFile(this, owner, repo, path28, content, message, sha, options);
20389
20408
  }
20390
20409
  async deleteFile(params) {
20391
- const { owner, repo, path: path25, sha, message, ...options } = params;
20392
- return deleteFile(this, owner, repo, path25, sha, message, options);
20410
+ const { owner, repo, path: path28, sha, message, ...options } = params;
20411
+ return deleteFile(this, owner, repo, path28, sha, message, options);
20393
20412
  }
20394
20413
  async listBranches(params) {
20395
20414
  return listBranches(this, params.owner, params.repo);
@@ -21148,7 +21167,7 @@ var require_instrument = __commonJS({
21148
21167
  Object.defineProperty(exports2, "__esModule", { value: true });
21149
21168
  exports2.addAppMetadata = addAppMetadata;
21150
21169
  exports2.getUserAgent = getUserAgent;
21151
- var os12 = __importStar(require("node:os"));
21170
+ var os14 = __importStar(require("node:os"));
21152
21171
  var node_path_1 = require("node:path");
21153
21172
  var packageJson = require_package();
21154
21173
  function replaceSlashes(s3) {
@@ -21162,7 +21181,7 @@ var require_instrument = __commonJS({
21162
21181
  }
21163
21182
  return result;
21164
21183
  }
21165
- var baseUserAgent = `${replaceSlashes(packageJson.name)}/${packageJson.version} ${toLatin1Safe((0, node_path_1.basename)(process.title))}/${process.version.replace("v", "")} ${os12.platform()}/${os12.release()}`;
21184
+ var baseUserAgent = `${replaceSlashes(packageJson.name)}/${packageJson.version} ${toLatin1Safe((0, node_path_1.basename)(process.title))}/${process.version.replace("v", "")} ${os14.platform()}/${os14.release()}`;
21166
21185
  var appMetadata = {};
21167
21186
  function addAppMetadata({ name, version: version2 }) {
21168
21187
  appMetadata[replaceSlashes(name)] = version2;
@@ -30362,11 +30381,11 @@ var require_mime_types = __commonJS({
30362
30381
  }
30363
30382
  return exts[0];
30364
30383
  }
30365
- function lookup(path25) {
30366
- if (!path25 || typeof path25 !== "string") {
30384
+ function lookup(path28) {
30385
+ if (!path28 || typeof path28 !== "string") {
30367
30386
  return false;
30368
30387
  }
30369
- var extension3 = extname("x." + path25).toLowerCase().substr(1);
30388
+ var extension3 = extname("x." + path28).toLowerCase().substr(1);
30370
30389
  if (!extension3) {
30371
30390
  return false;
30372
30391
  }
@@ -31471,11 +31490,11 @@ var require_form_data = __commonJS({
31471
31490
  "use strict";
31472
31491
  var CombinedStream = require_combined_stream();
31473
31492
  var util2 = require("util");
31474
- var path25 = require("path");
31475
- var http = require("http");
31493
+ var path28 = require("path");
31494
+ var http2 = require("http");
31476
31495
  var https3 = require("https");
31477
31496
  var parseUrl = require("url").parse;
31478
- var fs13 = require("fs");
31497
+ var fs15 = require("fs");
31479
31498
  var Stream = require("stream").Stream;
31480
31499
  var crypto3 = require("crypto");
31481
31500
  var mime = require_mime_types();
@@ -31542,7 +31561,7 @@ var require_form_data = __commonJS({
31542
31561
  if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
31543
31562
  callback(null, value.end + 1 - (value.start ? value.start : 0));
31544
31563
  } else {
31545
- fs13.stat(value.path, function(err, stat2) {
31564
+ fs15.stat(value.path, function(err, stat2) {
31546
31565
  if (err) {
31547
31566
  callback(err);
31548
31567
  return;
@@ -31599,11 +31618,11 @@ var require_form_data = __commonJS({
31599
31618
  FormData2.prototype._getContentDisposition = function(value, options) {
31600
31619
  var filename;
31601
31620
  if (typeof options.filepath === "string") {
31602
- filename = path25.normalize(options.filepath).replace(/\\/g, "/");
31621
+ filename = path28.normalize(options.filepath).replace(/\\/g, "/");
31603
31622
  } else if (options.filename || value && (value.name || value.path)) {
31604
- filename = path25.basename(options.filename || value && (value.name || value.path));
31623
+ filename = path28.basename(options.filename || value && (value.name || value.path));
31605
31624
  } else if (value && value.readable && hasOwn(value, "httpVersion")) {
31606
- filename = path25.basename(value.client._httpMessage.path || "");
31625
+ filename = path28.basename(value.client._httpMessage.path || "");
31607
31626
  }
31608
31627
  if (filename) {
31609
31628
  return 'filename="' + filename + '"';
@@ -31744,7 +31763,7 @@ var require_form_data = __commonJS({
31744
31763
  if (options.protocol === "https:") {
31745
31764
  request = https3.request(options);
31746
31765
  } else {
31747
- request = http.request(options);
31766
+ request = http2.request(options);
31748
31767
  }
31749
31768
  this.getLength(function(err, length) {
31750
31769
  if (err && err !== "Unknown stream") {
@@ -32457,7 +32476,7 @@ var require_follow_redirects = __commonJS({
32457
32476
  "node_modules/follow-redirects/index.js"(exports2, module2) {
32458
32477
  var url2 = require("url");
32459
32478
  var URL2 = url2.URL;
32460
- var http = require("http");
32479
+ var http2 = require("http");
32461
32480
  var https3 = require("https");
32462
32481
  var Writable2 = require("stream").Writable;
32463
32482
  var assert2 = require("assert");
@@ -32958,7 +32977,7 @@ var require_follow_redirects = __commonJS({
32958
32977
  function escapeRegex3(regex4) {
32959
32978
  return regex4.replace(/[\]\\/()*+?.$]/g, "\\$&");
32960
32979
  }
32961
- module2.exports = wrap({ http, https: https3 });
32980
+ module2.exports = wrap({ http: http2, https: https3 });
32962
32981
  module2.exports.wrap = wrap;
32963
32982
  }
32964
32983
  });
@@ -32970,11 +32989,11 @@ var require_axios = __commonJS({
32970
32989
  var FormData$1 = require_form_data();
32971
32990
  var crypto3 = require("crypto");
32972
32991
  var url2 = require("url");
32973
- var http = require("http");
32992
+ var http2 = require("http");
32974
32993
  var https3 = require("https");
32975
- var http2 = require("http2");
32994
+ var http22 = require("http2");
32976
32995
  var util2 = require("util");
32977
- var path25 = require("path");
32996
+ var path28 = require("path");
32978
32997
  var followRedirects = require_follow_redirects();
32979
32998
  var zlib = require("zlib");
32980
32999
  var stream = require("stream");
@@ -33848,9 +33867,9 @@ var require_axios = __commonJS({
33848
33867
  function removeBrackets(key) {
33849
33868
  return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
33850
33869
  }
33851
- function renderKey(path26, key, dots) {
33852
- if (!path26) return key;
33853
- return path26.concat(key).map(function each(token, i) {
33870
+ function renderKey(path29, key, dots) {
33871
+ if (!path29) return key;
33872
+ return path29.concat(key).map(function each(token, i) {
33854
33873
  token = removeBrackets(token);
33855
33874
  return !dots && i ? "[" + token + "]" : token;
33856
33875
  }).join(dots ? "." : "");
@@ -33899,13 +33918,13 @@ var require_axios = __commonJS({
33899
33918
  }
33900
33919
  return value;
33901
33920
  }
33902
- function defaultVisitor(value, key, path26) {
33921
+ function defaultVisitor(value, key, path29) {
33903
33922
  let arr = value;
33904
33923
  if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
33905
- formData.append(renderKey(path26, key, dots), convertValue(value));
33924
+ formData.append(renderKey(path29, key, dots), convertValue(value));
33906
33925
  return false;
33907
33926
  }
33908
- if (value && !path26 && typeof value === "object") {
33927
+ if (value && !path29 && typeof value === "object") {
33909
33928
  if (utils$1.endsWith(key, "{}")) {
33910
33929
  key = metaTokens ? key : key.slice(0, -2);
33911
33930
  value = JSON.stringify(value);
@@ -33924,7 +33943,7 @@ var require_axios = __commonJS({
33924
33943
  if (isVisitable(value)) {
33925
33944
  return true;
33926
33945
  }
33927
- formData.append(renderKey(path26, key, dots), convertValue(value));
33946
+ formData.append(renderKey(path29, key, dots), convertValue(value));
33928
33947
  return false;
33929
33948
  }
33930
33949
  const stack = [];
@@ -33933,19 +33952,19 @@ var require_axios = __commonJS({
33933
33952
  convertValue,
33934
33953
  isVisitable
33935
33954
  });
33936
- function build(value, path26, depth = 0) {
33955
+ function build(value, path29, depth = 0) {
33937
33956
  if (utils$1.isUndefined(value)) return;
33938
33957
  if (depth > maxDepth) {
33939
33958
  throw new AxiosError("Object is too deeply nested (" + depth + " levels). Max depth: " + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
33940
33959
  }
33941
33960
  if (stack.indexOf(value) !== -1) {
33942
- throw Error("Circular reference detected in " + path26.join("."));
33961
+ throw Error("Circular reference detected in " + path29.join("."));
33943
33962
  }
33944
33963
  stack.push(value);
33945
33964
  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);
33965
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path29, exposedHelpers);
33947
33966
  if (result === true) {
33948
- build(el, path26 ? path26.concat(key) : [key], depth + 1);
33967
+ build(el, path29 ? path29.concat(key) : [key], depth + 1);
33949
33968
  }
33950
33969
  });
33951
33970
  stack.pop();
@@ -34133,7 +34152,7 @@ var require_axios = __commonJS({
34133
34152
  };
34134
34153
  function toURLEncodedForm(data, options) {
34135
34154
  return toFormData(data, new platform2.classes.URLSearchParams(), {
34136
- visitor: function(value, key, path26, helpers) {
34155
+ visitor: function(value, key, path29, helpers) {
34137
34156
  if (platform2.isNode && utils$1.isBuffer(value)) {
34138
34157
  this.append(key, value.toString("base64"));
34139
34158
  return false;
@@ -34161,11 +34180,11 @@ var require_axios = __commonJS({
34161
34180
  return obj;
34162
34181
  }
34163
34182
  function formDataToJSON(formData) {
34164
- function buildPath(path26, value, target, index) {
34165
- let name = path26[index++];
34183
+ function buildPath(path29, value, target, index) {
34184
+ let name = path29[index++];
34166
34185
  if (name === "__proto__") return true;
34167
34186
  const isNumericKey = Number.isFinite(+name);
34168
- const isLast = index >= path26.length;
34187
+ const isLast = index >= path29.length;
34169
34188
  name = !name && utils$1.isArray(target) ? target.length : name;
34170
34189
  if (isLast) {
34171
34190
  if (utils$1.hasOwnProp(target, name)) {
@@ -34178,7 +34197,7 @@ var require_axios = __commonJS({
34178
34197
  if (!target[name] || !utils$1.isObject(target[name])) {
34179
34198
  target[name] = [];
34180
34199
  }
34181
- const result = buildPath(path26, value, target[name], index);
34200
+ const result = buildPath(path29, value, target[name], index);
34182
34201
  if (result && utils$1.isArray(target[name])) {
34183
34202
  target[name] = arrayToObject(target[name]);
34184
34203
  }
@@ -35042,7 +35061,7 @@ var require_axios = __commonJS({
35042
35061
  }
35043
35062
  }
35044
35063
  }
35045
- const session = http2.connect(authority, options);
35064
+ const session = http22.connect(authority, options);
35046
35065
  let removed;
35047
35066
  const removeSession = () => {
35048
35067
  if (removed) {
@@ -35219,7 +35238,7 @@ var require_axios = __commonJS({
35219
35238
  HTTP2_HEADER_METHOD,
35220
35239
  HTTP2_HEADER_PATH,
35221
35240
  HTTP2_HEADER_STATUS
35222
- } = http2.constants;
35241
+ } = http22.constants;
35223
35242
  const http2Headers = {
35224
35243
  [HTTP2_HEADER_SCHEME]: options.protocol.replace(":", ""),
35225
35244
  [HTTP2_HEADER_METHOD]: options.method,
@@ -35490,8 +35509,8 @@ var require_axios = __commonJS({
35490
35509
  }
35491
35510
  if (config2.allowedSocketPaths != null) {
35492
35511
  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);
35512
+ const resolvedSocket = path28.resolve(config2.socketPath);
35513
+ const isAllowed = allowed.some((entry) => typeof entry === "string" && path28.resolve(entry) === resolvedSocket);
35495
35514
  if (!isAllowed) {
35496
35515
  return reject(new AxiosError(`socketPath "${config2.socketPath}" is not permitted by allowedSocketPaths`, AxiosError.ERR_BAD_OPTION_VALUE, config2));
35497
35516
  }
@@ -35513,7 +35532,7 @@ var require_axios = __commonJS({
35513
35532
  if (configTransport) {
35514
35533
  transport = configTransport;
35515
35534
  } else if (config2.maxRedirects === 0) {
35516
- transport = isHttpsRequest ? https3 : http;
35535
+ transport = isHttpsRequest ? https3 : http2;
35517
35536
  isNativeTransport = true;
35518
35537
  } else {
35519
35538
  if (config2.maxRedirects) {
@@ -35743,14 +35762,14 @@ var require_axios = __commonJS({
35743
35762
  var cookies = platform2.hasStandardBrowserEnv ? (
35744
35763
  // Standard browser envs support document.cookie
35745
35764
  {
35746
- write(name, value, expires, path26, domain2, secure, sameSite) {
35765
+ write(name, value, expires, path29, domain2, secure, sameSite) {
35747
35766
  if (typeof document === "undefined") return;
35748
35767
  const cookie = [`${name}=${encodeURIComponent(value)}`];
35749
35768
  if (utils$1.isNumber(expires)) {
35750
35769
  cookie.push(`expires=${new Date(expires).toUTCString()}`);
35751
35770
  }
35752
- if (utils$1.isString(path26)) {
35753
- cookie.push(`path=${path26}`);
35771
+ if (utils$1.isString(path29)) {
35772
+ cookie.push(`path=${path29}`);
35754
35773
  }
35755
35774
  if (utils$1.isString(domain2)) {
35756
35775
  cookie.push(`domain=${domain2}`);
@@ -41989,8 +42008,8 @@ var init_supermemory = __esm({
41989
42008
  /**
41990
42009
  * Make a fetch request to the Supermemory API
41991
42010
  */
41992
- async fetch(path25, options) {
41993
- const url2 = `${this.endpoint}${path25}`;
42011
+ async fetch(path28, options) {
42012
+ const url2 = `${this.endpoint}${path28}`;
41994
42013
  const controller = new AbortController();
41995
42014
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
41996
42015
  try {
@@ -43050,6 +43069,7 @@ __export(index_exports, {
43050
43069
  isWorktreeStep: () => isWorktreeStep,
43051
43070
  listLoggedAgents: () => listLoggedAgents,
43052
43071
  listPersonas: () => listPersonas,
43072
+ listWorkflowSchedules: () => listWorkflowSchedules,
43053
43073
  loadCustomSteps: () => loadCustomSteps,
43054
43074
  loadPersona: () => loadPersona,
43055
43075
  logAndTraceError: () => logAndTraceError,
@@ -43083,6 +43103,7 @@ __export(index_exports, {
43083
43103
  runScriptWorkflow: () => runScriptWorkflow,
43084
43104
  runVerification: () => runVerification,
43085
43105
  runWorkflow: () => runWorkflow,
43106
+ scheduleWorkflow: () => scheduleWorkflow,
43086
43107
  scrubForChannel: () => scrubForChannel,
43087
43108
  scrubSecrets: () => scrubSecrets,
43088
43109
  sendToChannel: () => sendToChannel,
@@ -43157,7 +43178,7 @@ var BrokerTransport = class {
43157
43178
  return this.baseUrl.replace(/^http/, "ws") + "/ws";
43158
43179
  }
43159
43180
  // ── HTTP ─────────────────────────────────────────────────────────────
43160
- async request(path25, init) {
43181
+ async request(path28, init) {
43161
43182
  const headers = new Headers(init?.headers);
43162
43183
  if (!headers.has("Content-Type")) {
43163
43184
  headers.set("Content-Type", "application/json");
@@ -43166,7 +43187,7 @@ var BrokerTransport = class {
43166
43187
  headers.set("X-API-Key", this.apiKey);
43167
43188
  }
43168
43189
  const signal = init?.signal ?? AbortSignal.timeout(this.requestTimeoutMs);
43169
- const res = await fetch(`${this.baseUrl}${path25}`, { ...init, headers, signal });
43190
+ const res = await fetch(`${this.baseUrl}${path28}`, { ...init, headers, signal });
43170
43191
  if (!res.ok) {
43171
43192
  let body;
43172
43193
  try {
@@ -43632,6 +43653,7 @@ var AgentRelayClient = class _AgentRelayClient {
43632
43653
  stdoutLines,
43633
43654
  stderrLines
43634
43655
  });
43656
+ drainBrokerStdioAfterStartup(child);
43635
43657
  const client = new _AgentRelayClient({
43636
43658
  baseUrl,
43637
43659
  apiKey,
@@ -43930,6 +43952,15 @@ async function waitForApiUrl(child, timeoutMs, debug) {
43930
43952
  });
43931
43953
  });
43932
43954
  }
43955
+ function drainBrokerStdioAfterStartup(child) {
43956
+ for (const stream of [child.stdout, child.stderr]) {
43957
+ if (!stream)
43958
+ continue;
43959
+ stream.on("data", () => {
43960
+ });
43961
+ stream.resume();
43962
+ }
43963
+ }
43933
43964
  function pushBufferedLine(lines, line) {
43934
43965
  lines.push(line);
43935
43966
  if (lines.length > 40) {
@@ -44494,8 +44525,8 @@ function getErrorMap() {
44494
44525
 
44495
44526
  // node_modules/zod/v3/helpers/parseUtil.js
44496
44527
  var makeIssue = (params) => {
44497
- const { data, path: path25, errorMaps, issueData } = params;
44498
- const fullPath = [...path25, ...issueData.path || []];
44528
+ const { data, path: path28, errorMaps, issueData } = params;
44529
+ const fullPath = [...path28, ...issueData.path || []];
44499
44530
  const fullIssue = {
44500
44531
  ...issueData,
44501
44532
  path: fullPath
@@ -44611,11 +44642,11 @@ var errorUtil;
44611
44642
 
44612
44643
  // node_modules/zod/v3/types.js
44613
44644
  var ParseInputLazyPath = class {
44614
- constructor(parent, value, path25, key) {
44645
+ constructor(parent, value, path28, key) {
44615
44646
  this._cachedPath = [];
44616
44647
  this.parent = parent;
44617
44648
  this.data = value;
44618
- this._path = path25;
44649
+ this._path = path28;
44619
44650
  this._key = key;
44620
44651
  }
44621
44652
  get path() {
@@ -51121,10 +51152,10 @@ function mergeDefs(...defs) {
51121
51152
  function cloneDef(schema) {
51122
51153
  return mergeDefs(schema._zod.def);
51123
51154
  }
51124
- function getElementAtPath(obj, path25) {
51125
- if (!path25)
51155
+ function getElementAtPath(obj, path28) {
51156
+ if (!path28)
51126
51157
  return obj;
51127
- return path25.reduce((acc, key) => acc?.[key], obj);
51158
+ return path28.reduce((acc, key) => acc?.[key], obj);
51128
51159
  }
51129
51160
  function promiseAllObject(promisesObj) {
51130
51161
  const keys = Object.keys(promisesObj);
@@ -51533,11 +51564,11 @@ function explicitlyAborted(x, startIndex = 0) {
51533
51564
  }
51534
51565
  return false;
51535
51566
  }
51536
- function prefixIssues(path25, issues) {
51567
+ function prefixIssues(path28, issues) {
51537
51568
  return issues.map((iss) => {
51538
51569
  var _a3;
51539
51570
  (_a3 = iss).path ?? (_a3.path = []);
51540
- iss.path.unshift(path25);
51571
+ iss.path.unshift(path28);
51541
51572
  return iss;
51542
51573
  });
51543
51574
  }
@@ -51684,16 +51715,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
51684
51715
  }
51685
51716
  function formatError(error51, mapper = (issue2) => issue2.message) {
51686
51717
  const fieldErrors = { _errors: [] };
51687
- const processError = (error52, path25 = []) => {
51718
+ const processError = (error52, path28 = []) => {
51688
51719
  for (const issue2 of error52.issues) {
51689
51720
  if (issue2.code === "invalid_union" && issue2.errors.length) {
51690
- issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
51721
+ issue2.errors.map((issues) => processError({ issues }, [...path28, ...issue2.path]));
51691
51722
  } else if (issue2.code === "invalid_key") {
51692
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
51723
+ processError({ issues: issue2.issues }, [...path28, ...issue2.path]);
51693
51724
  } else if (issue2.code === "invalid_element") {
51694
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
51725
+ processError({ issues: issue2.issues }, [...path28, ...issue2.path]);
51695
51726
  } else {
51696
- const fullpath = [...path25, ...issue2.path];
51727
+ const fullpath = [...path28, ...issue2.path];
51697
51728
  if (fullpath.length === 0) {
51698
51729
  fieldErrors._errors.push(mapper(issue2));
51699
51730
  } else {
@@ -51720,17 +51751,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
51720
51751
  }
51721
51752
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
51722
51753
  const result = { errors: [] };
51723
- const processError = (error52, path25 = []) => {
51754
+ const processError = (error52, path28 = []) => {
51724
51755
  var _a3, _b;
51725
51756
  for (const issue2 of error52.issues) {
51726
51757
  if (issue2.code === "invalid_union" && issue2.errors.length) {
51727
- issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
51758
+ issue2.errors.map((issues) => processError({ issues }, [...path28, ...issue2.path]));
51728
51759
  } else if (issue2.code === "invalid_key") {
51729
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
51760
+ processError({ issues: issue2.issues }, [...path28, ...issue2.path]);
51730
51761
  } else if (issue2.code === "invalid_element") {
51731
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
51762
+ processError({ issues: issue2.issues }, [...path28, ...issue2.path]);
51732
51763
  } else {
51733
- const fullpath = [...path25, ...issue2.path];
51764
+ const fullpath = [...path28, ...issue2.path];
51734
51765
  if (fullpath.length === 0) {
51735
51766
  result.errors.push(mapper(issue2));
51736
51767
  continue;
@@ -51762,8 +51793,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
51762
51793
  }
51763
51794
  function toDotPath(_path) {
51764
51795
  const segs = [];
51765
- const path25 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
51766
- for (const seg of path25) {
51796
+ const path28 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
51797
+ for (const seg of path28) {
51767
51798
  if (typeof seg === "number")
51768
51799
  segs.push(`[${seg}]`);
51769
51800
  else if (typeof seg === "symbol")
@@ -64455,13 +64486,13 @@ function resolveRef(ref, ctx) {
64455
64486
  if (!ref.startsWith("#")) {
64456
64487
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
64457
64488
  }
64458
- const path25 = ref.slice(1).split("/").filter(Boolean);
64459
- if (path25.length === 0) {
64489
+ const path28 = ref.slice(1).split("/").filter(Boolean);
64490
+ if (path28.length === 0) {
64460
64491
  return ctx.rootSchema;
64461
64492
  }
64462
64493
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
64463
- if (path25[0] === defsKey) {
64464
- const key = path25[1];
64494
+ if (path28[0] === defsKey) {
64495
+ const key = path28[1];
64465
64496
  if (!key || !ctx.defs[key]) {
64466
64497
  throw new Error(`Reference not found: ${ref}`);
64467
64498
  }
@@ -66624,8 +66655,8 @@ var HttpClient = class _HttpClient {
66624
66655
  version: this._originVersion
66625
66656
  }));
66626
66657
  }
66627
- async request(method, path25, body, query, options) {
66628
- const url2 = new URL(path25, this._baseUrl);
66658
+ async request(method, path28, body, query, options) {
66659
+ const url2 = new URL(path28, this._baseUrl);
66629
66660
  if (query) {
66630
66661
  for (const [k2, v2] of Object.entries(query)) {
66631
66662
  if (v2 !== void 0)
@@ -66695,20 +66726,20 @@ var HttpClient = class _HttpClient {
66695
66726
  return camelizeKeys(parsedData);
66696
66727
  }
66697
66728
  }
66698
- get(path25, query, options) {
66699
- return this.request("GET", path25, void 0, query, options);
66729
+ get(path28, query, options) {
66730
+ return this.request("GET", path28, void 0, query, options);
66700
66731
  }
66701
- post(path25, body, options) {
66702
- return this.request("POST", path25, body, void 0, options);
66732
+ post(path28, body, options) {
66733
+ return this.request("POST", path28, body, void 0, options);
66703
66734
  }
66704
- patch(path25, body, options) {
66705
- return this.request("PATCH", path25, body, void 0, options);
66735
+ patch(path28, body, options) {
66736
+ return this.request("PATCH", path28, body, void 0, options);
66706
66737
  }
66707
- put(path25, body, options) {
66708
- return this.request("PUT", path25, body, void 0, options);
66738
+ put(path28, body, options) {
66739
+ return this.request("PUT", path28, body, void 0, options);
66709
66740
  }
66710
- async delete(path25, options) {
66711
- await this.request("DELETE", path25, void 0, void 0, options);
66741
+ async delete(path28, options) {
66742
+ await this.request("DELETE", path28, void 0, void 0, options);
66712
66743
  }
66713
66744
  };
66714
66745
 
@@ -68760,15 +68791,15 @@ function listPersonas(options = {}) {
68760
68791
  for (const file2 of entries) {
68761
68792
  if (!file2.endsWith(".json"))
68762
68793
  continue;
68763
- const path25 = (0, import_node_path5.join)(dir, file2);
68794
+ const path28 = (0, import_node_path5.join)(dir, file2);
68764
68795
  let spec;
68765
68796
  try {
68766
- spec = parsePersonaFile(JSON.parse((0, import_node_fs3.readFileSync)(path25, "utf8")), path25);
68797
+ spec = parsePersonaFile(JSON.parse((0, import_node_fs3.readFileSync)(path28, "utf8")), path28);
68767
68798
  } catch {
68768
68799
  continue;
68769
68800
  }
68770
68801
  if (!byId.has(spec.id)) {
68771
- byId.set(spec.id, { id: spec.id, path: path25, spec });
68802
+ byId.set(spec.id, { id: spec.id, path: path28, spec });
68772
68803
  }
68773
68804
  }
68774
68805
  }
@@ -68801,11 +68832,11 @@ function findPersona(id, options = {}) {
68801
68832
  for (const file2 of entries) {
68802
68833
  if (!file2.endsWith(".json"))
68803
68834
  continue;
68804
- const path25 = (0, import_node_path5.join)(dir, file2);
68835
+ const path28 = (0, import_node_path5.join)(dir, file2);
68805
68836
  try {
68806
- const spec = parsePersonaFile(JSON.parse((0, import_node_fs3.readFileSync)(path25, "utf8")), path25);
68837
+ const spec = parsePersonaFile(JSON.parse((0, import_node_fs3.readFileSync)(path28, "utf8")), path28);
68807
68838
  if (spec.id === id)
68808
- return { id, path: path25, spec };
68839
+ return { id, path: path28, spec };
68809
68840
  } catch {
68810
68841
  continue;
68811
68842
  }
@@ -71688,9 +71719,9 @@ async function resolveCli(cli) {
71688
71719
  for (const binary of def.binaries) {
71689
71720
  try {
71690
71721
  const { stdout } = await execFileAsync("which", [binary]);
71691
- const path25 = stdout.trim();
71692
- if (path25) {
71693
- const result = { binary, path: path25 };
71722
+ const path28 = stdout.trim();
71723
+ if (path28) {
71724
+ const result = { binary, path: path28 };
71694
71725
  resolveCache.set(cli, result);
71695
71726
  return result;
71696
71727
  }
@@ -71727,9 +71758,9 @@ function resolveCliSync(cli) {
71727
71758
  for (const binary of def.binaries) {
71728
71759
  try {
71729
71760
  const stdout = execFileSync3("which", [binary], { stdio: ["pipe", "pipe", "ignore"] });
71730
- const path25 = stdout.toString().trim();
71731
- if (path25) {
71732
- const result = { binary, path: path25 };
71761
+ const path28 = stdout.toString().trim();
71762
+ if (path28) {
71763
+ const result = { binary, path: path28 };
71733
71764
  resolveCache.set(cli, result);
71734
71765
  return result;
71735
71766
  }
@@ -73061,10 +73092,10 @@ var RelayFileClient = class {
73061
73092
  signal: options.signal
73062
73093
  });
73063
73094
  }
73064
- async readFile(workspaceOrInput, path25, correlationId, signal) {
73095
+ async readFile(workspaceOrInput, path28, correlationId, signal) {
73065
73096
  const input = typeof workspaceOrInput === "string" ? {
73066
73097
  workspaceId: workspaceOrInput,
73067
- path: path25 ?? "",
73098
+ path: path28 ?? "",
73068
73099
  correlationId,
73069
73100
  signal
73070
73101
  } : workspaceOrInput;
@@ -73111,8 +73142,8 @@ var RelayFileClient = class {
73111
73142
  });
73112
73143
  }
73113
73144
  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 });
73145
+ const { workspaceId, path: path28, correlationId, baseRevision, content, contentType, encoding, contentIdentity, signal } = input;
73146
+ const query = buildQuery({ path: path28, forkId: input.forkId });
73116
73147
  return this.request({
73117
73148
  method: "PUT",
73118
73149
  path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/fs/file${query}`,
@@ -80006,11 +80037,11 @@ function extractDecisions(trajectory2) {
80006
80037
  }
80007
80038
  return decisions;
80008
80039
  }
80009
- function expandPath(path25) {
80010
- if (path25.startsWith("~")) {
80011
- return (0, import_path4.join)(process.env.HOME ?? "", path25.slice(1));
80040
+ function expandPath(path28) {
80041
+ if (path28.startsWith("~")) {
80042
+ return (0, import_path4.join)(process.env.HOME ?? "", path28.slice(1));
80012
80043
  }
80013
- return path25;
80044
+ return path28;
80014
80045
  }
80015
80046
  function describeReadFailure(reason, error51) {
80016
80047
  if (reason === "schema_violation" && error51 && typeof error51 === "object" && "issues" in error51) {
@@ -80027,11 +80058,11 @@ function describeReadFailure(reason, error51) {
80027
80058
  return String(error51);
80028
80059
  }
80029
80060
  var indexLocks = /* @__PURE__ */ new Map();
80030
- function withIndexLock(path25, task) {
80031
- const prev = indexLocks.get(path25) ?? Promise.resolve();
80061
+ function withIndexLock(path28, task) {
80062
+ const prev = indexLocks.get(path28) ?? Promise.resolve();
80032
80063
  const next = prev.then(task, task);
80033
80064
  indexLocks.set(
80034
- path25,
80065
+ path28,
80035
80066
  next.catch(() => void 0)
80036
80067
  );
80037
80068
  return next;
@@ -80260,8 +80291,8 @@ var FileStorage = class {
80260
80291
  const validation = validateTrajectory(input);
80261
80292
  if (!validation.success) {
80262
80293
  const issues = validation.errors?.issues.map((issue2) => {
80263
- const path25 = issue2.path.length > 0 ? issue2.path.join(".") : "root";
80264
- return `${path25}: ${issue2.message}`;
80294
+ const path28 = issue2.path.length > 0 ? issue2.path.join(".") : "root";
80295
+ return `${path28}: ${issue2.message}`;
80265
80296
  }).join("; ") ?? "unknown validation error";
80266
80297
  throw new Error(`Cannot save invalid trajectory: ${issues}`);
80267
80298
  }
@@ -80470,18 +80501,18 @@ var FileStorage = class {
80470
80501
  *
80471
80502
  * Does NOT log. Callers choose whether to warn, swallow, or throw.
80472
80503
  */
80473
- async readTrajectoryFile(path25) {
80504
+ async readTrajectoryFile(path28) {
80474
80505
  let content;
80475
80506
  try {
80476
- content = await (0, import_promises7.readFile)(path25, "utf-8");
80507
+ content = await (0, import_promises7.readFile)(path28, "utf-8");
80477
80508
  } catch (error51) {
80478
- return { ok: false, reason: "io_error", path: path25, error: error51 };
80509
+ return { ok: false, reason: "io_error", path: path28, error: error51 };
80479
80510
  }
80480
80511
  let data;
80481
80512
  try {
80482
80513
  data = JSON.parse(content);
80483
80514
  } catch (error51) {
80484
- return { ok: false, reason: "malformed_json", path: path25, error: error51 };
80515
+ return { ok: false, reason: "malformed_json", path: path28, error: error51 };
80485
80516
  }
80486
80517
  const validation = validateTrajectory(data);
80487
80518
  if (validation.success) {
@@ -80490,7 +80521,7 @@ var FileStorage = class {
80490
80521
  return {
80491
80522
  ok: false,
80492
80523
  reason: "schema_violation",
80493
- path: path25,
80524
+ path: path28,
80494
80525
  error: validation.errors
80495
80526
  };
80496
80527
  }
@@ -80499,8 +80530,8 @@ var FileStorage = class {
80499
80530
  * trajectory. Returns null for any failure and writes nothing to the
80500
80531
  * console — so nothing leaks into test output or the CLI spinner.
80501
80532
  */
80502
- async readTrajectoryOrNull(path25) {
80503
- const result = await this.readTrajectoryFile(path25);
80533
+ async readTrajectoryOrNull(path28) {
80534
+ const result = await this.readTrajectoryFile(path28);
80504
80535
  return result.ok ? result.trajectory : null;
80505
80536
  }
80506
80537
  /**
@@ -87033,8 +87064,531 @@ async function runWorkflow(yamlPath, options = {}) {
87033
87064
  return runner.execute(config2, options.workflow, options.vars, executeOptions);
87034
87065
  }
87035
87066
 
87036
- // packages/sdk/dist/workflows/builder.js
87067
+ // packages/cloud/src/auth.ts
87068
+ var import_promises9 = __toESM(require("node:fs/promises"), 1);
87069
+ var import_node_http = __toESM(require("node:http"), 1);
87070
+ var import_node_os12 = __toESM(require("node:os"), 1);
87071
+ var import_node_path32 = __toESM(require("node:path"), 1);
87072
+ var import_node_child_process9 = require("node:child_process");
87073
+
87074
+ // packages/cloud/src/types.ts
87075
+ var import_node_os11 = __toESM(require("node:os"), 1);
87037
87076
  var import_node_path31 = __toESM(require("node:path"), 1);
87077
+ var REFRESH_WINDOW_MS = 6e4;
87078
+ var AUTH_FILE_PATH = import_node_path31.default.join(import_node_os11.default.homedir(), ".agent-relay", "cloud-auth.json");
87079
+ function defaultApiUrl() {
87080
+ return process.env.CLOUD_API_URL?.trim() || "https://agentrelay.com/cloud";
87081
+ }
87082
+
87083
+ // packages/cloud/src/api-client.ts
87084
+ function trimLeadingSlash(p2) {
87085
+ return p2.replace(/^\/+/, "");
87086
+ }
87087
+ function withTrailingSlash(p2) {
87088
+ return p2.endsWith("/") ? p2 : `${p2}/`;
87089
+ }
87090
+ function buildApiUrl(apiUrl, p2) {
87091
+ return new URL(trimLeadingSlash(p2), withTrailingSlash(apiUrl));
87092
+ }
87093
+
87094
+ // packages/cloud/src/auth.ts
87095
+ var envBackedAuth = /* @__PURE__ */ new WeakSet();
87096
+ function markEnvBackedAuth(auth) {
87097
+ envBackedAuth.add(auth);
87098
+ return auth;
87099
+ }
87100
+ function isEnvBackedAuth(auth) {
87101
+ return envBackedAuth.has(auth);
87102
+ }
87103
+ function readEnvAuth(env = process.env) {
87104
+ const apiUrl = env.CLOUD_API_URL?.trim();
87105
+ const accessToken = env.CLOUD_API_ACCESS_TOKEN?.trim();
87106
+ const refreshToken = env.CLOUD_API_REFRESH_TOKEN?.trim();
87107
+ const accessTokenExpiresAt = env.CLOUD_API_ACCESS_TOKEN_EXPIRES_AT?.trim();
87108
+ if (!apiUrl || !accessToken || !refreshToken || !accessTokenExpiresAt) {
87109
+ return null;
87110
+ }
87111
+ try {
87112
+ new URL(apiUrl);
87113
+ } catch {
87114
+ return null;
87115
+ }
87116
+ if (Number.isNaN(Date.parse(accessTokenExpiresAt))) {
87117
+ return null;
87118
+ }
87119
+ return markEnvBackedAuth({
87120
+ apiUrl,
87121
+ accessToken,
87122
+ refreshToken,
87123
+ accessTokenExpiresAt
87124
+ });
87125
+ }
87126
+ function toEnvAuthRefreshError(error51) {
87127
+ const message = error51 instanceof Error && error51.message ? `${error51.message}. ` : "";
87128
+ return new Error(
87129
+ `${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.`,
87130
+ error51 instanceof Error ? { cause: error51 } : void 0
87131
+ );
87132
+ }
87133
+ function isValidStoredAuth(value) {
87134
+ if (!value || typeof value !== "object") {
87135
+ return false;
87136
+ }
87137
+ const auth = value;
87138
+ return typeof auth.accessToken === "string" && typeof auth.refreshToken === "string" && typeof auth.accessTokenExpiresAt === "string" && typeof auth.apiUrl === "string";
87139
+ }
87140
+ async function readStoredAuth(env = process.env) {
87141
+ const envAuth = readEnvAuth(env);
87142
+ if (envAuth) {
87143
+ return envAuth;
87144
+ }
87145
+ try {
87146
+ const file2 = await import_promises9.default.readFile(AUTH_FILE_PATH, "utf8");
87147
+ const parsed = JSON.parse(file2);
87148
+ return isValidStoredAuth(parsed) ? parsed : null;
87149
+ } catch {
87150
+ return null;
87151
+ }
87152
+ }
87153
+ async function writeStoredAuth(auth) {
87154
+ await import_promises9.default.mkdir(import_node_path32.default.dirname(AUTH_FILE_PATH), {
87155
+ recursive: true,
87156
+ mode: 448
87157
+ });
87158
+ await import_promises9.default.writeFile(AUTH_FILE_PATH, `${JSON.stringify(auth, null, 2)}
87159
+ `, {
87160
+ encoding: "utf8",
87161
+ mode: 384
87162
+ });
87163
+ }
87164
+ function shouldRefresh(accessTokenExpiresAt) {
87165
+ const expiresAt = Date.parse(accessTokenExpiresAt);
87166
+ if (Number.isNaN(expiresAt)) {
87167
+ return true;
87168
+ }
87169
+ return expiresAt - Date.now() <= REFRESH_WINDOW_MS;
87170
+ }
87171
+ function openBrowser(url2) {
87172
+ const platform2 = import_node_os12.default.platform();
87173
+ if (platform2 === "darwin") {
87174
+ return (0, import_node_child_process9.spawn)("open", [url2], { stdio: "ignore", detached: true });
87175
+ }
87176
+ if (platform2 === "win32") {
87177
+ return (0, import_node_child_process9.spawn)("cmd", ["/c", "start", "", url2], { stdio: "ignore", detached: true });
87178
+ }
87179
+ return (0, import_node_child_process9.spawn)("xdg-open", [url2], { stdio: "ignore", detached: true });
87180
+ }
87181
+ function redirectToHostedCliAuthPage(response, apiUrl, options) {
87182
+ const resultUrl = buildApiUrl(apiUrl, "/cli/auth-result");
87183
+ resultUrl.searchParams.set("status", options.status);
87184
+ if (options.detail) {
87185
+ resultUrl.searchParams.set("detail", options.detail);
87186
+ }
87187
+ response.statusCode = 302;
87188
+ response.setHeader("location", resultUrl.toString());
87189
+ response.end();
87190
+ }
87191
+ async function beginBrowserLogin(apiUrl) {
87192
+ const state = crypto.randomUUID();
87193
+ return new Promise((resolve4, reject) => {
87194
+ let settled = false;
87195
+ const server = import_node_http.default.createServer((request, response) => {
87196
+ const requestUrl = new URL(request.url || "/", "http://127.0.0.1");
87197
+ if (requestUrl.pathname !== "/callback") {
87198
+ response.statusCode = 404;
87199
+ response.end("Not found");
87200
+ return;
87201
+ }
87202
+ const returnedState = requestUrl.searchParams.get("state");
87203
+ if (returnedState !== state) {
87204
+ redirectToHostedCliAuthPage(response, apiUrl, {
87205
+ status: "error",
87206
+ detail: "Invalid state parameter"
87207
+ });
87208
+ if (!settled) {
87209
+ settled = true;
87210
+ server.close();
87211
+ reject(new Error("Invalid state parameter in CLI login callback"));
87212
+ }
87213
+ return;
87214
+ }
87215
+ const error51 = requestUrl.searchParams.get("error");
87216
+ if (error51) {
87217
+ redirectToHostedCliAuthPage(response, apiUrl, {
87218
+ status: "error",
87219
+ detail: error51
87220
+ });
87221
+ if (!settled) {
87222
+ settled = true;
87223
+ server.close();
87224
+ reject(new Error(error51));
87225
+ }
87226
+ return;
87227
+ }
87228
+ const accessToken = requestUrl.searchParams.get("access_token");
87229
+ const refreshToken = requestUrl.searchParams.get("refresh_token");
87230
+ const accessTokenExpiresAt = requestUrl.searchParams.get("access_token_expires_at");
87231
+ const returnedApiUrl = requestUrl.searchParams.get("api_url");
87232
+ if (!accessToken || !refreshToken || !accessTokenExpiresAt || !returnedApiUrl) {
87233
+ redirectToHostedCliAuthPage(response, apiUrl, {
87234
+ status: "error",
87235
+ detail: "Expected access token, refresh token, API URL, and expiration timestamp."
87236
+ });
87237
+ if (!settled) {
87238
+ settled = true;
87239
+ server.close();
87240
+ reject(new Error("CLI login callback was missing required fields"));
87241
+ }
87242
+ return;
87243
+ }
87244
+ redirectToHostedCliAuthPage(response, returnedApiUrl, {
87245
+ status: "success",
87246
+ detail: `API endpoint: ${returnedApiUrl}`
87247
+ });
87248
+ if (!settled) {
87249
+ settled = true;
87250
+ server.close();
87251
+ resolve4({
87252
+ accessToken,
87253
+ refreshToken,
87254
+ accessTokenExpiresAt,
87255
+ apiUrl: returnedApiUrl
87256
+ });
87257
+ }
87258
+ });
87259
+ server.listen(0, "127.0.0.1", () => {
87260
+ const address = server.address();
87261
+ if (!address || typeof address === "string") {
87262
+ if (!settled) {
87263
+ settled = true;
87264
+ server.close();
87265
+ reject(new Error("Failed to start local callback server"));
87266
+ }
87267
+ return;
87268
+ }
87269
+ const callbackUrl = new URL("/callback", `http://127.0.0.1:${address.port}`);
87270
+ const loginUrl = buildApiUrl(apiUrl, "/api/v1/cli/login");
87271
+ loginUrl.searchParams.set("redirect_uri", callbackUrl.toString());
87272
+ loginUrl.searchParams.set("state", state);
87273
+ console.log(`Opening browser for cloud login: ${loginUrl.toString()}`);
87274
+ console.log("If the browser does not open, paste this URL into your browser.");
87275
+ try {
87276
+ const child = openBrowser(loginUrl.toString());
87277
+ child.unref();
87278
+ } catch {
87279
+ }
87280
+ });
87281
+ server.on("error", (error51) => {
87282
+ if (!settled) {
87283
+ settled = true;
87284
+ reject(error51);
87285
+ }
87286
+ });
87287
+ setTimeout(() => {
87288
+ if (!settled) {
87289
+ settled = true;
87290
+ server.close();
87291
+ reject(new Error("Timed out waiting for browser login"));
87292
+ }
87293
+ }, 5 * 6e4).unref();
87294
+ });
87295
+ }
87296
+ async function refreshStoredAuth(auth) {
87297
+ const response = await fetch(buildApiUrl(auth.apiUrl, "/api/v1/auth/token/refresh"), {
87298
+ method: "POST",
87299
+ headers: {
87300
+ "content-type": "application/json"
87301
+ },
87302
+ body: JSON.stringify({ refreshToken: auth.refreshToken })
87303
+ });
87304
+ const payload = await response.json().catch(() => null);
87305
+ if (!response.ok || !payload?.accessToken || !payload?.refreshToken || !payload?.accessTokenExpiresAt) {
87306
+ throw new Error("Stored cloud login has expired");
87307
+ }
87308
+ const nextAuth = {
87309
+ apiUrl: auth.apiUrl,
87310
+ accessToken: payload.accessToken,
87311
+ refreshToken: payload.refreshToken,
87312
+ accessTokenExpiresAt: payload.accessTokenExpiresAt
87313
+ };
87314
+ if (isEnvBackedAuth(auth)) {
87315
+ return markEnvBackedAuth(nextAuth);
87316
+ }
87317
+ await writeStoredAuth(nextAuth);
87318
+ return nextAuth;
87319
+ }
87320
+ async function loginWithBrowser(apiUrl) {
87321
+ const auth = await beginBrowserLogin(apiUrl);
87322
+ await writeStoredAuth(auth);
87323
+ console.log(`Logged in to ${auth.apiUrl}`);
87324
+ return auth;
87325
+ }
87326
+ async function ensureAuthenticated(apiUrl, options) {
87327
+ const force = options?.force === true;
87328
+ const stored = !force ? await readStoredAuth() : null;
87329
+ if (!stored) {
87330
+ return loginWithBrowser(apiUrl);
87331
+ }
87332
+ if (!shouldRefresh(stored.accessTokenExpiresAt)) {
87333
+ return stored;
87334
+ }
87335
+ try {
87336
+ return await refreshStoredAuth(stored);
87337
+ } catch (error51) {
87338
+ if (isEnvBackedAuth(stored)) {
87339
+ throw toEnvAuthRefreshError(error51);
87340
+ }
87341
+ return loginWithBrowser(stored.apiUrl);
87342
+ }
87343
+ }
87344
+ function apiFetch(apiUrl, accessToken, requestPath, init) {
87345
+ return fetch(buildApiUrl(apiUrl, requestPath), {
87346
+ ...init,
87347
+ headers: {
87348
+ "content-type": "application/json",
87349
+ authorization: `Bearer ${accessToken}`,
87350
+ ...init.headers ?? {}
87351
+ }
87352
+ });
87353
+ }
87354
+ async function authorizedApiFetch(auth, requestPath, init) {
87355
+ let activeAuth = auth;
87356
+ let response = await apiFetch(activeAuth.apiUrl, activeAuth.accessToken, requestPath, init);
87357
+ if (response.status !== 401) {
87358
+ return { response, auth: activeAuth };
87359
+ }
87360
+ try {
87361
+ activeAuth = await refreshStoredAuth(activeAuth);
87362
+ } catch (error51) {
87363
+ if (isEnvBackedAuth(activeAuth)) {
87364
+ throw toEnvAuthRefreshError(error51);
87365
+ }
87366
+ activeAuth = await loginWithBrowser(activeAuth.apiUrl);
87367
+ }
87368
+ response = await apiFetch(activeAuth.apiUrl, activeAuth.accessToken, requestPath, init);
87369
+ return { response, auth: activeAuth };
87370
+ }
87371
+
87372
+ // packages/cloud/src/workflows.ts
87373
+ var import_promises10 = __toESM(require("node:fs/promises"), 1);
87374
+ var import_node_path33 = __toESM(require("node:path"), 1);
87375
+ var import_ignore3 = __toESM(require_ignore(), 1);
87376
+ function validateYamlWorkflow(content) {
87377
+ const hasField = (field) => new RegExp(`^${field}\\s*:`, "m").test(content);
87378
+ if (!hasField("version")) {
87379
+ throw new Error('missing required field "version"');
87380
+ }
87381
+ if (!hasField("swarm")) {
87382
+ throw new Error('missing required field "swarm"');
87383
+ }
87384
+ if (!hasField("agents")) {
87385
+ throw new Error('missing required field "agents"');
87386
+ }
87387
+ if (!hasField("workflows")) {
87388
+ throw new Error('missing required field "workflows"');
87389
+ }
87390
+ }
87391
+ async function validateTypeScriptWorkflow(content) {
87392
+ const Bun = globalThis.Bun;
87393
+ if (typeof Bun !== "undefined") {
87394
+ try {
87395
+ const result = await Bun.build({
87396
+ stdin: { contents: content, loader: "ts" },
87397
+ throw: false
87398
+ });
87399
+ if (!result.success && result.logs?.length) {
87400
+ const errors = result.logs.filter((l) => l.level === "error").map((l) => l.message).join("\n");
87401
+ if (errors) {
87402
+ throw new Error(`Workflow file has syntax errors:
87403
+ ${errors}`);
87404
+ }
87405
+ }
87406
+ return;
87407
+ } catch (error51) {
87408
+ if (error51 instanceof Error && error51.message.startsWith("Workflow file has syntax errors")) {
87409
+ throw error51;
87410
+ }
87411
+ return;
87412
+ }
87413
+ }
87414
+ try {
87415
+ const { execSync: execSync6 } = await import("node:child_process");
87416
+ execSync6("npx --yes esbuild --loader=ts", {
87417
+ input: content,
87418
+ encoding: "utf-8",
87419
+ stdio: ["pipe", "pipe", "pipe"],
87420
+ timeout: 3e4
87421
+ });
87422
+ } catch (error51) {
87423
+ const err = error51;
87424
+ const stderr = typeof err.stderr === "string" ? err.stderr.trim() : "";
87425
+ if (err.killed || !err.status || err.status === 127 || /command not found|not found/i.test(stderr)) {
87426
+ return;
87427
+ }
87428
+ const message = stderr || "TypeScript validation failed";
87429
+ throw new Error(`Workflow file has syntax errors:
87430
+ ${message}`);
87431
+ }
87432
+ }
87433
+ function inferWorkflowFileType(filePath) {
87434
+ const ext = import_node_path33.default.extname(filePath).toLowerCase();
87435
+ switch (ext) {
87436
+ case ".yaml":
87437
+ case ".yml":
87438
+ return "yaml";
87439
+ case ".ts":
87440
+ case ".mts":
87441
+ case ".cts":
87442
+ return "ts";
87443
+ case ".py":
87444
+ return "py";
87445
+ default:
87446
+ return null;
87447
+ }
87448
+ }
87449
+ async function resolveWorkflowInput(workflowArg, explicitFileType) {
87450
+ const looksLikeFile = import_node_path33.default.isAbsolute(workflowArg) || workflowArg.includes(import_node_path33.default.sep) || inferWorkflowFileType(workflowArg) !== null;
87451
+ try {
87452
+ const workflow2 = await import_promises10.default.readFile(workflowArg, "utf-8");
87453
+ const fileType = explicitFileType ?? inferWorkflowFileType(workflowArg);
87454
+ if (!fileType) {
87455
+ throw new Error(`Could not infer workflow type from ${workflowArg}. Use --file-type.`);
87456
+ }
87457
+ return { workflow: workflow2, fileType };
87458
+ } catch (error51) {
87459
+ const err = error51;
87460
+ if (err.code === "EISDIR") {
87461
+ throw new Error(`Workflow path is not a file: ${workflowArg}`);
87462
+ }
87463
+ if (!isMissingFileError(error51)) {
87464
+ throw error51;
87465
+ }
87466
+ }
87467
+ if (looksLikeFile) {
87468
+ throw new Error(`Workflow file not found: ${workflowArg}`);
87469
+ }
87470
+ return {
87471
+ workflow: workflowArg,
87472
+ fileType: explicitFileType ?? "yaml"
87473
+ };
87474
+ }
87475
+ async function scheduleWorkflow(workflowArg, options = {}) {
87476
+ const hasCron = typeof options.cron === "string" && options.cron.trim().length > 0;
87477
+ const hasAt = typeof options.at === "string" && options.at.trim().length > 0;
87478
+ if (hasCron === hasAt) {
87479
+ throw new Error("Provide exactly one of --cron or --at.");
87480
+ }
87481
+ const apiUrl = options.apiUrl ?? defaultApiUrl();
87482
+ const auth = await ensureAuthenticated(apiUrl);
87483
+ const input = await resolveWorkflowInput(workflowArg, options.fileType);
87484
+ if (input.fileType === "ts") {
87485
+ await validateTypeScriptWorkflow(input.workflow);
87486
+ } else if (input.fileType === "yaml") {
87487
+ console.error("Validating workflow...");
87488
+ validateYamlWorkflow(input.workflow);
87489
+ }
87490
+ const requestBody = {
87491
+ name: options.name?.trim() || import_node_path33.default.basename(workflowArg),
87492
+ schedule_type: hasCron ? "cron" : "once",
87493
+ timezone: options.timezone?.trim() || "UTC",
87494
+ workflowRequest: {
87495
+ workflow: input.workflow,
87496
+ fileType: input.fileType,
87497
+ ...input.sourceFileType ? { sourceFileType: input.sourceFileType } : {}
87498
+ }
87499
+ };
87500
+ if (options.description?.trim()) {
87501
+ requestBody.description = options.description.trim();
87502
+ }
87503
+ if (hasCron) {
87504
+ requestBody.cron_expression = options.cron?.trim();
87505
+ } else {
87506
+ const scheduledAt = new Date(String(options.at));
87507
+ if (Number.isNaN(scheduledAt.getTime())) {
87508
+ throw new Error(`Invalid date for --at: ${options.at}`);
87509
+ }
87510
+ requestBody.scheduled_at = scheduledAt.toISOString();
87511
+ }
87512
+ const { response } = await authorizedApiFetch(auth, "/api/v1/workflows/schedules", {
87513
+ method: "POST",
87514
+ headers: {
87515
+ "Content-Type": "application/json",
87516
+ Accept: "application/json"
87517
+ },
87518
+ body: JSON.stringify(requestBody)
87519
+ });
87520
+ const payload = await readJsonResponse(response);
87521
+ if (!response.ok) {
87522
+ throw new Error(`Workflow schedule failed: ${describeResponseError(response, payload)}`);
87523
+ }
87524
+ if (!isWorkflowScheduleEnvelope(payload)) {
87525
+ throw new Error("Workflow schedule response was not valid JSON.");
87526
+ }
87527
+ return payload.schedule;
87528
+ }
87529
+ async function listWorkflowSchedules(options = {}) {
87530
+ const apiUrl = options.apiUrl ?? defaultApiUrl();
87531
+ const auth = await ensureAuthenticated(apiUrl);
87532
+ const { response } = await authorizedApiFetch(auth, "/api/v1/workflows/schedules", {
87533
+ headers: { Accept: "application/json" }
87534
+ });
87535
+ const payload = await readJsonResponse(response);
87536
+ if (!response.ok) {
87537
+ throw new Error(`Schedule list failed: ${describeResponseError(response, payload)}`);
87538
+ }
87539
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
87540
+ throw new Error("Schedule list response was not valid JSON.");
87541
+ }
87542
+ const schedules = payload.schedules;
87543
+ if (!Array.isArray(schedules)) {
87544
+ throw new Error("Schedule list response was not valid JSON.");
87545
+ }
87546
+ return schedules.filter(isWorkflowSchedule);
87547
+ }
87548
+ async function readJsonResponse(response) {
87549
+ const rawBody = await response.text();
87550
+ if (!rawBody) {
87551
+ return null;
87552
+ }
87553
+ try {
87554
+ return JSON.parse(rawBody);
87555
+ } catch {
87556
+ return rawBody;
87557
+ }
87558
+ }
87559
+ function describeResponseError(response, payload) {
87560
+ if (typeof payload === "string" && payload.trim()) {
87561
+ return `${response.status} ${response.statusText}: ${payload.trim()}`;
87562
+ }
87563
+ if (payload && typeof payload === "object" && !Array.isArray(payload)) {
87564
+ const record2 = payload;
87565
+ const message = record2.error ?? record2.message;
87566
+ if (typeof message === "string" && message.trim()) {
87567
+ return `${response.status} ${response.statusText}: ${message.trim()}`;
87568
+ }
87569
+ }
87570
+ return `${response.status} ${response.statusText}`;
87571
+ }
87572
+ function isWorkflowScheduleEnvelope(payload) {
87573
+ return Boolean(payload) && typeof payload === "object" && !Array.isArray(payload) && isWorkflowSchedule(payload.schedule);
87574
+ }
87575
+ function isWorkflowSchedule(value) {
87576
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
87577
+ return false;
87578
+ }
87579
+ const record2 = value;
87580
+ const hasNullableString = (field) => record2[field] === null || typeof record2[field] === "string";
87581
+ 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";
87582
+ }
87583
+ function isMissingFileError(error51) {
87584
+ return Boolean(error51 && typeof error51 === "object" && "code" in error51 && error51.code === "ENOENT");
87585
+ }
87586
+
87587
+ // packages/cloud/src/lib/ssh-interactive.ts
87588
+ var DEBUG = process.env.AGENT_RELAY_DEBUG_SSH === "1";
87589
+
87590
+ // packages/sdk/dist/workflows/builder.js
87591
+ var import_node_path34 = __toESM(require("node:path"), 1);
87038
87592
  var import_yaml3 = __toESM(require_dist(), 1);
87039
87593
 
87040
87594
  // packages/sdk/dist/workflows/cloud-runner.js
@@ -87393,7 +87947,7 @@ var WorkflowBuilder = class {
87393
87947
  async run(options = {}) {
87394
87948
  const config2 = this.toConfig();
87395
87949
  const runnerCwd = options.cwd ?? process.cwd();
87396
- const dbPath = import_node_path31.default.join(runnerCwd, ".agent-relay", "workflow-runs.jsonl");
87950
+ const dbPath = import_node_path34.default.join(runnerCwd, ".agent-relay", "workflow-runs.jsonl");
87397
87951
  const db = new JsonFileWorkflowDb(dbPath);
87398
87952
  const runner = new WorkflowRunner({
87399
87953
  cwd: options.cwd,
@@ -88311,7 +88865,7 @@ var StateStore = class extends import_node_events5.EventEmitter {
88311
88865
 
88312
88866
  // packages/sdk/dist/workflows/templates.js
88313
88867
  var import_node_fs23 = require("node:fs");
88314
- var import_node_path32 = __toESM(require("node:path"), 1);
88868
+ var import_node_path35 = __toESM(require("node:path"), 1);
88315
88869
  var import_node_url2 = require("node:url");
88316
88870
  var import_yaml4 = __toESM(require_dist(), 1);
88317
88871
  var YAML_EXTENSIONS = [".yaml", ".yml"];
@@ -88336,7 +88890,7 @@ var TemplateRegistry = class {
88336
88890
  fetcher;
88337
88891
  constructor(options = {}) {
88338
88892
  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");
88893
+ this.customTemplatesDir = options.customTemplatesDir ? import_node_path35.default.resolve(options.customTemplatesDir) : import_node_path35.default.resolve(options.workspaceDir ?? process.cwd(), ".relay/workflows");
88340
88894
  this.fetcher = options.fetcher ?? fetch;
88341
88895
  }
88342
88896
  listBuiltInTemplates() {
@@ -88410,12 +88964,12 @@ var TemplateRegistry = class {
88410
88964
  if (!templateName) {
88411
88965
  throw new Error('Template name is required. Provide name explicitly or include a string "name" field.');
88412
88966
  }
88413
- if (templateName.includes("/") || templateName.includes("\\") || templateName.includes("..") || import_node_path32.default.isAbsolute(templateName)) {
88967
+ if (templateName.includes("/") || templateName.includes("\\") || templateName.includes("..") || import_node_path35.default.isAbsolute(templateName)) {
88414
88968
  throw new Error(`Invalid template name: "${templateName}" contains path separators or traversal sequences`);
88415
88969
  }
88416
88970
  this.validateRelayConfig(parsed, url2);
88417
88971
  await import_node_fs23.promises.mkdir(this.customTemplatesDir, { recursive: true });
88418
- const targetPath = import_node_path32.default.join(this.customTemplatesDir, `${templateName}.yaml`);
88972
+ const targetPath = import_node_path35.default.join(this.customTemplatesDir, `${templateName}.yaml`);
88419
88973
  await import_node_fs23.promises.writeFile(targetPath, (0, import_yaml4.stringify)(parsed), "utf-8");
88420
88974
  return targetPath;
88421
88975
  }
@@ -88437,12 +88991,12 @@ var TemplateRegistry = class {
88437
88991
  }
88438
88992
  resolveBuiltInTemplatesDir(explicitDir) {
88439
88993
  if (explicitDir) {
88440
- return import_node_path32.default.resolve(explicitDir);
88994
+ return import_node_path35.default.resolve(explicitDir);
88441
88995
  }
88442
- const currentDir = import_node_path32.default.dirname((0, import_node_url2.fileURLToPath)(import_meta_url));
88996
+ const currentDir = import_node_path35.default.dirname((0, import_node_url2.fileURLToPath)(import_meta_url));
88443
88997
  const candidates = [
88444
- import_node_path32.default.resolve(currentDir, "builtin-templates"),
88445
- import_node_path32.default.resolve(currentDir, "../workflows/builtin-templates")
88998
+ import_node_path35.default.resolve(currentDir, "builtin-templates"),
88999
+ import_node_path35.default.resolve(currentDir, "../workflows/builtin-templates")
88446
89000
  ];
88447
89001
  for (const candidate of candidates) {
88448
89002
  if ((0, import_node_fs23.existsSync)(candidate)) {
@@ -88465,7 +89019,7 @@ var TemplateRegistry = class {
88465
89019
  }
88466
89020
  async findTemplatePath(directory, templateName) {
88467
89021
  for (const ext of YAML_EXTENSIONS) {
88468
- const candidate = import_node_path32.default.join(directory, `${templateName}${ext}`);
89022
+ const candidate = import_node_path35.default.join(directory, `${templateName}${ext}`);
88469
89023
  try {
88470
89024
  const stat2 = await import_node_fs23.promises.stat(candidate);
88471
89025
  if (stat2.isFile()) {
@@ -88813,8 +89367,8 @@ function pythonVerifyCommand() {
88813
89367
 
88814
89368
  // packages/sdk/dist/workflows/run-script.js
88815
89369
  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");
89370
+ var import_node_path36 = __toESM(require("node:path"), 1);
89371
+ var import_node_child_process10 = require("node:child_process");
88818
89372
  function diag(msg) {
88819
89373
  try {
88820
89374
  process.stderr.write(`[agent-relay] ${msg}
@@ -88828,12 +89382,12 @@ function diag(msg) {
88828
89382
  }
88829
89383
  }
88830
89384
  function findLocalSdkWorkspace(startDir) {
88831
- let current = import_node_path33.default.resolve(startDir);
88832
- const root = import_node_path33.default.parse(current).root;
89385
+ let current = import_node_path36.default.resolve(startDir);
89386
+ const root = import_node_path36.default.parse(current).root;
88833
89387
  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");
89388
+ const packageJsonPath = import_node_path36.default.join(current, "package.json");
89389
+ const sdkDir = import_node_path36.default.join(current, "packages", "sdk");
89390
+ const sdkPackageJsonPath = import_node_path36.default.join(sdkDir, "package.json");
88837
89391
  try {
88838
89392
  if (import_node_fs24.default.existsSync(packageJsonPath) && import_node_fs24.default.existsSync(sdkPackageJsonPath)) {
88839
89393
  const pkg = JSON.parse(import_node_fs24.default.readFileSync(packageJsonPath, "utf8"));
@@ -88846,14 +89400,14 @@ function findLocalSdkWorkspace(startDir) {
88846
89400
  }
88847
89401
  if (current === root)
88848
89402
  return null;
88849
- current = import_node_path33.default.dirname(current);
89403
+ current = import_node_path36.default.dirname(current);
88850
89404
  }
88851
89405
  }
88852
- function ensureLocalSdkWorkflowRuntime(startDir, execRunner = import_node_child_process9.execFileSync) {
89406
+ function ensureLocalSdkWorkflowRuntime(startDir, execRunner = import_node_child_process10.execFileSync) {
88853
89407
  const workspace = findLocalSdkWorkspace(startDir);
88854
89408
  if (!workspace)
88855
89409
  return;
88856
- const workflowsEntry = import_node_path33.default.join(workspace.sdkDir, "dist", "workflows", "index.js");
89410
+ const workflowsEntry = import_node_path36.default.join(workspace.sdkDir, "dist", "workflows", "index.js");
88857
89411
  if (import_node_fs24.default.existsSync(workflowsEntry))
88858
89412
  return;
88859
89413
  console.log("[agent-relay] Detected local @agent-relay/sdk workspace without built workflows runtime; building packages/sdk...");
@@ -88935,7 +89489,7 @@ function formatWorkflowParseError(parsed) {
88935
89489
  }
88936
89490
  async function spawnRunnerWithStderrCapture(command, args, env) {
88937
89491
  return new Promise((resolve4) => {
88938
- const child = (0, import_node_child_process9.spawn)(command, args, {
89492
+ const child = (0, import_node_child_process10.spawn)(command, args, {
88939
89493
  stdio: ["inherit", "inherit", "pipe"],
88940
89494
  env
88941
89495
  });
@@ -88958,14 +89512,14 @@ async function spawnRunnerWithStderrCapture(command, args, env) {
88958
89512
  }
88959
89513
  async function runScriptWorkflow(filePath, options = {}) {
88960
89514
  diag(`runScriptWorkflow: resolving ${filePath}`);
88961
- const resolved = import_node_path33.default.resolve(filePath);
89515
+ const resolved = import_node_path36.default.resolve(filePath);
88962
89516
  if (!import_node_fs24.default.existsSync(resolved)) {
88963
89517
  throw new Error(`File not found: ${resolved}`);
88964
89518
  }
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`);
89519
+ const ext = import_node_path36.default.extname(resolved).toLowerCase();
89520
+ const runIdFile = import_node_path36.default.join(process.cwd(), ".agent-relay", `script-run-id-${process.pid}-${Date.now()}.txt`);
88967
89521
  try {
88968
- import_node_fs24.default.mkdirSync(import_node_path33.default.dirname(runIdFile), { recursive: true });
89522
+ import_node_fs24.default.mkdirSync(import_node_path36.default.dirname(runIdFile), { recursive: true });
88969
89523
  } catch {
88970
89524
  }
88971
89525
  const childEnv = { ...process.env, AGENT_RELAY_RUN_ID_FILE: runIdFile };
@@ -89003,7 +89557,7 @@ Run ID: ${runId}`;
89003
89557
  };
89004
89558
  if (ext === ".ts" || ext === ".tsx") {
89005
89559
  diag("runScriptWorkflow: ensureLocalSdkWorkflowRuntime start");
89006
- ensureLocalSdkWorkflowRuntime(import_node_path33.default.dirname(resolved));
89560
+ ensureLocalSdkWorkflowRuntime(import_node_path36.default.dirname(resolved));
89007
89561
  diag("runScriptWorkflow: ensureLocalSdkWorkflowRuntime done");
89008
89562
  const wrapRunnerError = (runner, result) => {
89009
89563
  const parsed = parseTsxStderr(result.stderr);
@@ -89058,7 +89612,7 @@ Run ID: ${runId}`;
89058
89612
  const runners = ["python3", "python"];
89059
89613
  for (const runner of runners) {
89060
89614
  diag(`runScriptWorkflow: trying runner ${runner}`);
89061
- const spawnResult = (0, import_node_child_process9.spawnSync)(runner, [resolved], {
89615
+ const spawnResult = (0, import_node_child_process10.spawnSync)(runner, [resolved], {
89062
89616
  stdio: "inherit",
89063
89617
  env: childEnv
89064
89618
  });
@@ -89208,8 +89762,8 @@ var GitHubClient = class _GitHubClient {
89208
89762
  /**
89209
89763
  * Execute a raw GitHub API request through the selected adapter.
89210
89764
  */
89211
- async request(method, path25, options) {
89212
- return (await this.getAdapter()).request(method, path25, options);
89765
+ async request(method, path28, options) {
89766
+ return (await this.getAdapter()).request(method, path28, options);
89213
89767
  }
89214
89768
  /**
89215
89769
  * Execute any registered GitHub primitive action by action name.
@@ -89309,23 +89863,23 @@ var GitHubClient = class _GitHubClient {
89309
89863
  /**
89310
89864
  * List files or directories at a repository path.
89311
89865
  */
89312
- async listFiles(owner, repo, path25 = "", options = {}) {
89313
- return (await this.getAdapter()).listFiles({ owner, repo, path: path25, ...options });
89866
+ async listFiles(owner, repo, path28 = "", options = {}) {
89867
+ return (await this.getAdapter()).listFiles({ owner, repo, path: path28, ...options });
89314
89868
  }
89315
89869
  /**
89316
89870
  * Read a repository file and return decoded UTF-8 content.
89317
89871
  */
89318
- async readFile(owner, repo, path25, ref) {
89319
- return (await this.getAdapter()).readFile({ owner, repo, path: path25, ref });
89872
+ async readFile(owner, repo, path28, ref) {
89873
+ return (await this.getAdapter()).readFile({ owner, repo, path: path28, ref });
89320
89874
  }
89321
89875
  /**
89322
89876
  * Create a repository file with a commit message.
89323
89877
  */
89324
- async createFile(owner, repo, path25, content, message, options = {}) {
89878
+ async createFile(owner, repo, path28, content, message, options = {}) {
89325
89879
  await (await this.getAdapter()).createFile({
89326
89880
  owner,
89327
89881
  repo,
89328
- path: path25,
89882
+ path: path28,
89329
89883
  content,
89330
89884
  message,
89331
89885
  ...options
@@ -89334,11 +89888,11 @@ var GitHubClient = class _GitHubClient {
89334
89888
  /**
89335
89889
  * Update a repository file with a commit message.
89336
89890
  */
89337
- async updateFile(owner, repo, path25, content, message, sha, options = {}) {
89891
+ async updateFile(owner, repo, path28, content, message, sha, options = {}) {
89338
89892
  return (await this.getAdapter()).updateFile({
89339
89893
  owner,
89340
89894
  repo,
89341
- path: path25,
89895
+ path: path28,
89342
89896
  content,
89343
89897
  message,
89344
89898
  sha,
@@ -89348,11 +89902,11 @@ var GitHubClient = class _GitHubClient {
89348
89902
  /**
89349
89903
  * Delete a repository file with a commit message.
89350
89904
  */
89351
- async deleteFile(owner, repo, path25, sha, message, options = {}) {
89905
+ async deleteFile(owner, repo, path28, sha, message, options = {}) {
89352
89906
  await (await this.getAdapter()).deleteFile({
89353
89907
  owner,
89354
89908
  repo,
89355
- path: path25,
89909
+ path: path28,
89356
89910
  sha,
89357
89911
  message,
89358
89912
  ...options
@@ -89734,10 +90288,10 @@ function projectionToText(value) {
89734
90288
  }
89735
90289
  return JSON.stringify(value);
89736
90290
  }
89737
- function resolvePath2(value, path25) {
89738
- if (!path25) return value;
90291
+ function resolvePath2(value, path28) {
90292
+ if (!path28) return value;
89739
90293
  let current = value;
89740
- for (const segment of path25.split(".")) {
90294
+ for (const segment of path28.split(".")) {
89741
90295
  if (Array.isArray(current) && /^\d+$/.test(segment)) {
89742
90296
  current = current[Number(segment)];
89743
90297
  continue;
@@ -90053,13 +90607,13 @@ function slackStepConfigFromWorkflowStep(step, resolvedParams) {
90053
90607
  function renderSlackTemplates(value, data) {
90054
90608
  return value.replace(
90055
90609
  /\{\{\s*steps\.([A-Za-z0-9_-]+)\.output(?:\.([A-Za-z0-9_.-]+))?\s*\}\}/g,
90056
- (_match, step, path25) => {
90610
+ (_match, step, path28) => {
90057
90611
  const stepData = data.steps;
90058
90612
  if (!isRecord3(stepData)) return "";
90059
90613
  const entry = stepData[String(step)];
90060
90614
  if (!isRecord3(entry)) return "";
90061
90615
  const output = entry.output;
90062
- const resolved = typeof path25 === "string" && path25.length > 0 ? resolvePath3(output, path25) : output;
90616
+ const resolved = typeof path28 === "string" && path28.length > 0 ? resolvePath3(output, path28) : output;
90063
90617
  return projectionToText2(resolved);
90064
90618
  }
90065
90619
  );
@@ -90197,10 +90751,10 @@ function projectionToText2(value) {
90197
90751
  }
90198
90752
  return JSON.stringify(value);
90199
90753
  }
90200
- function resolvePath3(value, path25) {
90201
- if (!path25) return value;
90754
+ function resolvePath3(value, path28) {
90755
+ if (!path28) return value;
90202
90756
  let current = value;
90203
- for (const segment of path25.split(".")) {
90757
+ for (const segment of path28.split(".")) {
90204
90758
  if (Array.isArray(current) && /^\d+$/.test(segment)) {
90205
90759
  current = current[Number(segment)];
90206
90760
  continue;
@@ -90425,7 +90979,7 @@ function isValidAgentName(name) {
90425
90979
 
90426
90980
  // packages/utils/dist/logger.js
90427
90981
  var import_node_fs25 = __toESM(require("node:fs"), 1);
90428
- var import_node_path34 = __toESM(require("node:path"), 1);
90982
+ var import_node_path37 = __toESM(require("node:path"), 1);
90429
90983
  function getLogFile() {
90430
90984
  return process.env.AGENT_RELAY_LOG_FILE;
90431
90985
  }
@@ -90443,7 +90997,7 @@ var LEVEL_PRIORITY = {
90443
90997
  };
90444
90998
  var createdLogDirs = /* @__PURE__ */ new Set();
90445
90999
  function ensureLogDir(logFile) {
90446
- const logDir = import_node_path34.default.dirname(logFile);
91000
+ const logDir = import_node_path37.default.dirname(logFile);
90447
91001
  if (!createdLogDirs.has(logDir) && !import_node_fs25.default.existsSync(logDir)) {
90448
91002
  import_node_fs25.default.mkdirSync(logDir, { recursive: true });
90449
91003
  createdLogDirs.add(logDir);
@@ -90744,14 +91298,14 @@ function benchmarkPatterns(iterations = 1e4) {
90744
91298
  }
90745
91299
 
90746
91300
  // packages/utils/dist/command-resolver.js
90747
- var import_node_child_process12 = require("node:child_process");
91301
+ var import_node_child_process13 = require("node:child_process");
90748
91302
  var import_node_fs26 = __toESM(require("node:fs"), 1);
90749
91303
  function resolveCommand(command) {
90750
91304
  if (command.startsWith("/")) {
90751
91305
  return resolveSymlinks(command);
90752
91306
  }
90753
91307
  try {
90754
- const output = (0, import_node_child_process12.execSync)(`which ${command}`, {
91308
+ const output = (0, import_node_child_process13.execSync)(`which ${command}`, {
90755
91309
  encoding: "utf-8",
90756
91310
  stdio: ["pipe", "pipe", "pipe"],
90757
91311
  // Ensure we have a reasonable PATH
@@ -90785,7 +91339,7 @@ function resolveSymlinks(filePath) {
90785
91339
  }
90786
91340
  function commandExists(command) {
90787
91341
  try {
90788
- (0, import_node_child_process12.execSync)(`which ${command}`, {
91342
+ (0, import_node_child_process13.execSync)(`which ${command}`, {
90789
91343
  encoding: "utf-8",
90790
91344
  stdio: ["pipe", "pipe", "pipe"]
90791
91345
  });
@@ -90796,9 +91350,9 @@ function commandExists(command) {
90796
91350
  }
90797
91351
 
90798
91352
  // 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");
91353
+ var fs11 = __toESM(require("node:fs"), 1);
91354
+ var path24 = __toESM(require("node:path"), 1);
91355
+ var import_node_child_process14 = require("node:child_process");
90802
91356
  function parseGitRemoteUrl(url2) {
90803
91357
  if (!url2)
90804
91358
  return null;
@@ -90814,11 +91368,11 @@ function parseGitRemoteUrl(url2) {
90814
91368
  }
90815
91369
  function getGitRemoteUrl(workingDirectory, remoteName = "origin") {
90816
91370
  try {
90817
- const gitDir = path21.join(workingDirectory, ".git");
90818
- if (!fs9.existsSync(gitDir)) {
91371
+ const gitDir = path24.join(workingDirectory, ".git");
91372
+ if (!fs11.existsSync(gitDir)) {
90819
91373
  return null;
90820
91374
  }
90821
- const result = (0, import_node_child_process13.execSync)(`git remote get-url ${remoteName}`, {
91375
+ const result = (0, import_node_child_process14.execSync)(`git remote get-url ${remoteName}`, {
90822
91376
  cwd: workingDirectory,
90823
91377
  encoding: "utf-8",
90824
91378
  timeout: 5e3,
@@ -90827,11 +91381,11 @@ function getGitRemoteUrl(workingDirectory, remoteName = "origin") {
90827
91381
  return result.trim() || null;
90828
91382
  } catch {
90829
91383
  try {
90830
- const configPath = path21.join(workingDirectory, ".git", "config");
90831
- if (!fs9.existsSync(configPath)) {
91384
+ const configPath = path24.join(workingDirectory, ".git", "config");
91385
+ if (!fs11.existsSync(configPath)) {
90832
91386
  return null;
90833
91387
  }
90834
- const config2 = fs9.readFileSync(configPath, "utf-8");
91388
+ const config2 = fs11.readFileSync(configPath, "utf-8");
90835
91389
  const remoteSection = new RegExp(`\\[remote\\s+"${remoteName}"\\][^\\[]*url\\s*=\\s*([^\\n]+)`, "i");
90836
91390
  const match = config2.match(remoteSection);
90837
91391
  return match?.[1]?.trim() || null;
@@ -90848,13 +91402,13 @@ function getRepoFullName(workingDirectory) {
90848
91402
  return parseGitRemoteUrl(remoteUrl);
90849
91403
  }
90850
91404
  function findGitRoot(startPath) {
90851
- let currentPath = path21.resolve(startPath);
90852
- const root = path21.parse(currentPath).root;
91405
+ let currentPath = path24.resolve(startPath);
91406
+ const root = path24.parse(currentPath).root;
90853
91407
  while (currentPath !== root) {
90854
- if (fs9.existsSync(path21.join(currentPath, ".git"))) {
91408
+ if (fs11.existsSync(path24.join(currentPath, ".git"))) {
90855
91409
  return currentPath;
90856
91410
  }
90857
- currentPath = path21.dirname(currentPath);
91411
+ currentPath = path24.dirname(currentPath);
90858
91412
  }
90859
91413
  return null;
90860
91414
  }
@@ -90872,16 +91426,16 @@ function getRepoFullNameFromPath(workingDirectory) {
90872
91426
 
90873
91427
  // packages/utils/dist/update-checker.js
90874
91428
  var import_node_fs27 = __toESM(require("node:fs"), 1);
90875
- var import_node_path35 = __toESM(require("node:path"), 1);
91429
+ var import_node_path38 = __toESM(require("node:path"), 1);
90876
91430
  var import_node_https2 = __toESM(require("node:https"), 1);
90877
- var import_node_os12 = __toESM(require("node:os"), 1);
91431
+ var import_node_os14 = __toESM(require("node:os"), 1);
90878
91432
  var import_compare_versions = __toESM(require_umd(), 1);
90879
91433
  var PACKAGE_NAME = "agent-relay";
90880
91434
  var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
90881
91435
  var NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
90882
91436
  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");
91437
+ const cacheDir = import_node_path38.default.join(import_node_os14.default.homedir(), ".agent-relay");
91438
+ return import_node_path38.default.join(cacheDir, "update-cache.json");
90885
91439
  }
90886
91440
  function readCache() {
90887
91441
  try {
@@ -90897,7 +91451,7 @@ function readCache() {
90897
91451
  function writeCache(cache) {
90898
91452
  try {
90899
91453
  const cachePath = getCachePath();
90900
- const cacheDir = import_node_path35.default.dirname(cachePath);
91454
+ const cacheDir = import_node_path38.default.dirname(cachePath);
90901
91455
  if (!import_node_fs27.default.existsSync(cacheDir)) {
90902
91456
  import_node_fs27.default.mkdirSync(cacheDir, { recursive: true });
90903
91457
  }
@@ -91181,8 +91735,8 @@ function validateModelForCli(cli, model) {
91181
91735
 
91182
91736
  // packages/utils/dist/relay-pty-path.js
91183
91737
  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);
91738
+ var import_node_os15 = __toESM(require("node:os"), 1);
91739
+ var import_node_path39 = __toESM(require("node:path"), 1);
91186
91740
  var SUPPORTED_PLATFORMS = {
91187
91741
  darwin: {
91188
91742
  arm64: "relay-pty-darwin-arm64",
@@ -91194,20 +91748,20 @@ var SUPPORTED_PLATFORMS = {
91194
91748
  }
91195
91749
  };
91196
91750
  function getPlatformBinaryName() {
91197
- const platform2 = import_node_os13.default.platform();
91198
- const arch = import_node_os13.default.arch();
91751
+ const platform2 = import_node_os15.default.platform();
91752
+ const arch = import_node_os15.default.arch();
91199
91753
  return SUPPORTED_PLATFORMS[platform2]?.[arch] ?? null;
91200
91754
  }
91201
91755
  function isPlatformSupported() {
91202
- const platform2 = import_node_os13.default.platform();
91203
- const arch = import_node_os13.default.arch();
91756
+ const platform2 = import_node_os15.default.platform();
91757
+ const arch = import_node_os15.default.arch();
91204
91758
  return SUPPORTED_PLATFORMS[platform2]?.[arch] !== void 0;
91205
91759
  }
91206
91760
  function getSupportedPlatforms() {
91207
91761
  const platforms = [];
91208
- for (const [os12, archs] of Object.entries(SUPPORTED_PLATFORMS)) {
91762
+ for (const [os14, archs] of Object.entries(SUPPORTED_PLATFORMS)) {
91209
91763
  for (const arch of Object.keys(archs)) {
91210
- platforms.push(`${os12}-${arch}`);
91764
+ platforms.push(`${os14}-${arch}`);
91211
91765
  }
91212
91766
  }
91213
91767
  return platforms.join(", ");
@@ -91230,22 +91784,22 @@ function findRelayPtyBinary(callerDirname) {
91230
91784
  const scopedMatch = normalizedCaller.match(/^(.+?\/node_modules)\/@agent-relay\//);
91231
91785
  const directMatch = normalizedCaller.match(/^(.+?\/node_modules\/agent-relay)/);
91232
91786
  if (scopedMatch) {
91233
- packageRoots.push(import_node_path36.default.join(scopedMatch[1], "agent-relay"));
91787
+ packageRoots.push(import_node_path39.default.join(scopedMatch[1], "agent-relay"));
91234
91788
  }
91235
91789
  if (directMatch) {
91236
91790
  packageRoots.push(directMatch[1]);
91237
91791
  }
91238
91792
  if (!normalizedCaller.includes("node_modules")) {
91239
- packageRoots.push(import_node_path36.default.join(callerDirname, "..", "..", ".."));
91793
+ packageRoots.push(import_node_path39.default.join(callerDirname, "..", "..", ".."));
91240
91794
  }
91241
91795
  const home = process.env.HOME || process.env.USERPROFILE || "";
91242
91796
  if (home) {
91243
- const npxCacheBase = import_node_path36.default.join(home, ".npm", "_npx");
91797
+ const npxCacheBase = import_node_path39.default.join(home, ".npm", "_npx");
91244
91798
  if (import_node_fs28.default.existsSync(npxCacheBase)) {
91245
91799
  try {
91246
91800
  const entries = import_node_fs28.default.readdirSync(npxCacheBase);
91247
91801
  for (const entry of entries) {
91248
- const npxPackage = import_node_path36.default.join(npxCacheBase, entry, "node_modules", "agent-relay");
91802
+ const npxPackage = import_node_path39.default.join(npxCacheBase, entry, "node_modules", "agent-relay");
91249
91803
  if (import_node_fs28.default.existsSync(npxPackage)) {
91250
91804
  packageRoots.push(npxPackage);
91251
91805
  }
@@ -91254,42 +91808,42 @@ function findRelayPtyBinary(callerDirname) {
91254
91808
  }
91255
91809
  }
91256
91810
  }
91257
- packageRoots.push(import_node_path36.default.join(process.cwd(), "node_modules", "agent-relay"));
91811
+ packageRoots.push(import_node_path39.default.join(process.cwd(), "node_modules", "agent-relay"));
91258
91812
  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"));
91813
+ packageRoots.push(import_node_path39.default.join(home, ".nvm", "versions", "node", process.version, "lib", "node_modules", "agent-relay"));
91814
+ packageRoots.push(import_node_path39.default.join(home, ".volta", "tools", "image", "packages", "agent-relay", "lib", "node_modules", "agent-relay"));
91815
+ packageRoots.push(import_node_path39.default.join(home, ".fnm", "node-versions", process.version, "installation", "lib", "node_modules", "agent-relay"));
91816
+ packageRoots.push(import_node_path39.default.join(home, "n", "lib", "node_modules", "agent-relay"));
91817
+ packageRoots.push(import_node_path39.default.join(home, ".asdf", "installs", "nodejs", process.version.replace("v", ""), "lib", "node_modules", "agent-relay"));
91818
+ packageRoots.push(import_node_path39.default.join(home, ".local", "share", "pnpm", "global", "node_modules", "agent-relay"));
91819
+ packageRoots.push(import_node_path39.default.join(home, ".config", "yarn", "global", "node_modules", "agent-relay"));
91820
+ packageRoots.push(import_node_path39.default.join(home, ".yarn", "global", "node_modules", "agent-relay"));
91821
+ }
91822
+ 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;
91823
+ const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ? import_node_path39.default.join(home, ".local", "bin") : null);
91824
+ const nodePrefix = import_node_path39.default.resolve(import_node_path39.default.dirname(process.execPath), "..");
91825
+ packageRoots.push(import_node_path39.default.join(nodePrefix, "lib", "node_modules", "agent-relay"));
91272
91826
  packageRoots.push("/usr/local/lib/node_modules/agent-relay");
91273
91827
  packageRoots.push("/opt/homebrew/lib/node_modules/agent-relay");
91274
91828
  packageRoots.push("/usr/lib/node_modules/agent-relay");
91275
91829
  const candidates = [];
91276
91830
  for (const root of packageRoots) {
91277
91831
  if (platformBinary) {
91278
- candidates.push(import_node_path36.default.join(root, "bin", platformBinary));
91832
+ candidates.push(import_node_path39.default.join(root, "bin", platformBinary));
91279
91833
  }
91280
- candidates.push(import_node_path36.default.join(root, "bin", "relay-pty"));
91834
+ candidates.push(import_node_path39.default.join(root, "bin", "relay-pty"));
91281
91835
  }
91282
91836
  if (bashInstallerDir) {
91283
91837
  if (platformBinary) {
91284
- candidates.push(import_node_path36.default.join(bashInstallerDir, platformBinary));
91838
+ candidates.push(import_node_path39.default.join(bashInstallerDir, platformBinary));
91285
91839
  }
91286
- candidates.push(import_node_path36.default.join(bashInstallerDir, "relay-pty"));
91840
+ candidates.push(import_node_path39.default.join(bashInstallerDir, "relay-pty"));
91287
91841
  }
91288
91842
  if (bashInstallerBinDir) {
91289
91843
  if (platformBinary) {
91290
- candidates.push(import_node_path36.default.join(bashInstallerBinDir, platformBinary));
91844
+ candidates.push(import_node_path39.default.join(bashInstallerBinDir, platformBinary));
91291
91845
  }
91292
- candidates.push(import_node_path36.default.join(bashInstallerBinDir, "relay-pty"));
91846
+ candidates.push(import_node_path39.default.join(bashInstallerBinDir, "relay-pty"));
91293
91847
  }
91294
91848
  candidates.push("/app/bin/relay-pty");
91295
91849
  candidates.push("/usr/local/bin/relay-pty");
@@ -91320,7 +91874,7 @@ function isPlatformCompatibleBinary(filePath) {
91320
91874
  return false;
91321
91875
  }
91322
91876
  const magic = header.readUInt32BE(0);
91323
- const platform2 = import_node_os13.default.platform();
91877
+ const platform2 = import_node_os15.default.platform();
91324
91878
  if (platform2 === "darwin") {
91325
91879
  return isMachOBinary(magic);
91326
91880
  }
@@ -91949,56 +92503,56 @@ var HookRegistry = class {
91949
92503
  };
91950
92504
 
91951
92505
  // packages/trajectory/dist/integration.js
91952
- var import_node_child_process14 = require("node:child_process");
92506
+ var import_node_child_process15 = require("node:child_process");
91953
92507
 
91954
92508
  // packages/config/dist/project-namespace.js
91955
92509
  var import_node_crypto16 = __toESM(require("node:crypto"), 1);
91956
- var import_node_path37 = __toESM(require("node:path"), 1);
92510
+ var import_node_path40 = __toESM(require("node:path"), 1);
91957
92511
  var import_node_fs29 = __toESM(require("node:fs"), 1);
91958
- var import_node_os14 = __toESM(require("node:os"), 1);
92512
+ var import_node_os16 = __toESM(require("node:os"), 1);
91959
92513
  function getGlobalBaseDir2() {
91960
92514
  if (process.env.AGENT_RELAY_DATA_DIR) {
91961
92515
  return process.env.AGENT_RELAY_DATA_DIR;
91962
92516
  }
91963
92517
  const xdgDataHome = process.env.XDG_DATA_HOME;
91964
92518
  if (xdgDataHome) {
91965
- return import_node_path37.default.join(xdgDataHome, "agent-relay");
92519
+ return import_node_path40.default.join(xdgDataHome, "agent-relay");
91966
92520
  }
91967
- return import_node_path37.default.join(import_node_os14.default.homedir(), ".agent-relay");
92521
+ return import_node_path40.default.join(import_node_os16.default.homedir(), ".agent-relay");
91968
92522
  }
91969
92523
  var GLOBAL_BASE_DIR2 = getGlobalBaseDir2();
91970
92524
  var PROJECT_DATA_DIR = ".agent-relay";
91971
92525
  function hashPath(projectPath) {
91972
- const normalized = import_node_path37.default.resolve(projectPath);
92526
+ const normalized = import_node_path40.default.resolve(projectPath);
91973
92527
  const hash2 = import_node_crypto16.default.createHash("sha256").update(normalized).digest("hex");
91974
92528
  return hash2.substring(0, 12);
91975
92529
  }
91976
92530
  function findProjectRoot(startDir = process.cwd()) {
91977
92531
  if (process.env.AGENT_RELAY_PROJECT) {
91978
- return import_node_path37.default.resolve(process.env.AGENT_RELAY_PROJECT);
92532
+ return import_node_path40.default.resolve(process.env.AGENT_RELAY_PROJECT);
91979
92533
  }
91980
- let current = import_node_path37.default.resolve(startDir);
91981
- const root = import_node_path37.default.parse(current).root;
92534
+ let current = import_node_path40.default.resolve(startDir);
92535
+ const root = import_node_path40.default.parse(current).root;
91982
92536
  const markers = [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".agent-relay"];
91983
92537
  while (current !== root) {
91984
92538
  for (const marker of markers) {
91985
- if (import_node_fs29.default.existsSync(import_node_path37.default.join(current, marker))) {
92539
+ if (import_node_fs29.default.existsSync(import_node_path40.default.join(current, marker))) {
91986
92540
  return current;
91987
92541
  }
91988
92542
  }
91989
- current = import_node_path37.default.dirname(current);
92543
+ current = import_node_path40.default.dirname(current);
91990
92544
  }
91991
- return import_node_path37.default.resolve(startDir);
92545
+ return import_node_path40.default.resolve(startDir);
91992
92546
  }
91993
92547
  function getProjectPaths2(projectRoot) {
91994
92548
  const root = projectRoot ?? findProjectRoot();
91995
92549
  const projectId = hashPath(root);
91996
- const dataDir = import_node_path37.default.join(root, PROJECT_DATA_DIR);
92550
+ const dataDir = import_node_path40.default.join(root, PROJECT_DATA_DIR);
91997
92551
  return {
91998
92552
  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"),
92553
+ teamDir: import_node_path40.default.join(dataDir, "team"),
92554
+ dbPath: import_node_path40.default.join(dataDir, "messages.sqlite"),
92555
+ socketPath: import_node_path40.default.join(dataDir, "relay.sock"),
92002
92556
  projectRoot: root,
92003
92557
  projectId
92004
92558
  };
@@ -92006,15 +92560,15 @@ function getProjectPaths2(projectRoot) {
92006
92560
 
92007
92561
  // packages/config/dist/trajectory-config.js
92008
92562
  var import_node_fs30 = require("node:fs");
92009
- var import_node_path38 = require("node:path");
92010
- var import_node_os15 = require("node:os");
92563
+ var import_node_path41 = require("node:path");
92564
+ var import_node_os17 = require("node:os");
92011
92565
  var import_node_crypto17 = require("node:crypto");
92012
92566
  function getAgentRelayConfigDir() {
92013
- return process.env.AGENT_RELAY_CONFIG_DIR ?? (0, import_node_path38.join)((0, import_node_os15.homedir)(), ".config", "agent-relay");
92567
+ return process.env.AGENT_RELAY_CONFIG_DIR ?? (0, import_node_path41.join)((0, import_node_os17.homedir)(), ".config", "agent-relay");
92014
92568
  }
92015
92569
  var configCache = null;
92016
92570
  function getRelayConfigPath(_projectRoot) {
92017
- return (0, import_node_path38.join)(getAgentRelayConfigDir(), "relay.json");
92571
+ return (0, import_node_path41.join)(getAgentRelayConfigDir(), "relay.json");
92018
92572
  }
92019
92573
  function readRelayConfig(projectRoot) {
92020
92574
  const configPath = getRelayConfigPath(projectRoot);
@@ -92054,12 +92608,12 @@ function getProjectHash(projectRoot) {
92054
92608
  }
92055
92609
  function getUserTrajectoriesDir(projectRoot) {
92056
92610
  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);
92611
+ const configDir = process.env.XDG_CONFIG_HOME || (0, import_node_path41.join)((0, import_node_os17.homedir)(), ".config");
92612
+ return (0, import_node_path41.join)(configDir, "agent-relay", "trajectories", projectHash);
92059
92613
  }
92060
92614
  function getRepoTrajectoriesDir(projectRoot) {
92061
92615
  const root = projectRoot ?? getProjectPaths2().projectRoot;
92062
- return (0, import_node_path38.join)(root, ".trajectories");
92616
+ return (0, import_node_path41.join)(root, ".trajectories");
92063
92617
  }
92064
92618
  function getPrimaryTrajectoriesDir(projectRoot) {
92065
92619
  if (shouldStoreInRepo(projectRoot)) {
@@ -92078,7 +92632,7 @@ function getTrajectoryEnvVars(projectRoot) {
92078
92632
  async function runTrail(args) {
92079
92633
  return new Promise((resolve4) => {
92080
92634
  const trajectoryEnv = getTrajectoryEnvVars();
92081
- const proc = (0, import_node_child_process14.spawn)("trail", args, {
92635
+ const proc = (0, import_node_child_process15.spawn)("trail", args, {
92082
92636
  cwd: getProjectPaths2().projectRoot,
92083
92637
  env: { ...process.env, ...trajectoryEnv },
92084
92638
  stdio: ["pipe", "pipe", "pipe"]
@@ -92349,7 +92903,7 @@ var TrajectoryIntegration = class {
92349
92903
  */
92350
92904
  isTrailInstalledSync() {
92351
92905
  try {
92352
- (0, import_node_child_process14.execSync)("which trail", { stdio: "pipe" });
92906
+ (0, import_node_child_process15.execSync)("which trail", { stdio: "pipe" });
92353
92907
  return true;
92354
92908
  } catch {
92355
92909
  return false;
@@ -92700,7 +93254,7 @@ var HookEmitter = class {
92700
93254
 
92701
93255
  // packages/hooks/dist/inbox-check/utils.js
92702
93256
  var import_node_fs31 = require("node:fs");
92703
- var import_node_path39 = require("node:path");
93257
+ var import_node_path42 = require("node:path");
92704
93258
  var DEFAULT_INBOX_DIR = "/tmp/agent-relay";
92705
93259
  function getAgentName() {
92706
93260
  return process.env.AGENT_RELAY_NAME;
@@ -92710,7 +93264,7 @@ function getInboxPath(config2) {
92710
93264
  if (!agentName) {
92711
93265
  throw new Error("Agent name not configured. Set AGENT_RELAY_NAME env var.");
92712
93266
  }
92713
- return (0, import_node_path39.join)(config2.inboxDir, agentName, "inbox.md");
93267
+ return (0, import_node_path42.join)(config2.inboxDir, agentName, "inbox.md");
92714
93268
  }
92715
93269
  function inboxExists(inboxPath) {
92716
93270
  return (0, import_node_fs31.existsSync)(inboxPath);
@@ -92959,6 +93513,7 @@ init_dist2();
92959
93513
  isWorktreeStep,
92960
93514
  listLoggedAgents,
92961
93515
  listPersonas,
93516
+ listWorkflowSchedules,
92962
93517
  loadCustomSteps,
92963
93518
  loadPersona,
92964
93519
  logAndTraceError,
@@ -92992,6 +93547,7 @@ init_dist2();
92992
93547
  runScriptWorkflow,
92993
93548
  runVerification,
92994
93549
  runWorkflow,
93550
+ scheduleWorkflow,
92995
93551
  scrubForChannel,
92996
93552
  scrubSecrets,
92997
93553
  sendToChannel,