@aiaiai-pt/martha-cli 0.61.1 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/index.js +765 -717
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,36 +1,44 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
- var __create = Object.create;
4
- var __getProtoOf = Object.getPrototypeOf;
5
3
  var __defProp = Object.defineProperty;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __toESM = (mod, isNodeMode, target) => {
9
- target = mod != null ? __create(__getProtoOf(mod)) : {};
10
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
- for (let key of __getOwnPropNames(mod))
12
- if (!__hasOwnProp.call(to, key))
13
- __defProp(to, key, {
14
- get: () => mod[key],
15
- enumerable: true
16
- });
17
- return to;
18
- };
19
4
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
5
+ var __returnValue = (v) => v;
6
+ function __exportSetter(name, newValue) {
7
+ this[name] = __returnValue.bind(null, newValue);
8
+ }
20
9
  var __export = (target, all) => {
21
10
  for (var name in all)
22
11
  __defProp(target, name, {
23
12
  get: all[name],
24
13
  enumerable: true,
25
14
  configurable: true,
26
- set: (newValue) => all[name] = () => newValue
15
+ set: __exportSetter.bind(all, name)
16
+ });
17
+ };
18
+ var __esm = (fn, res, err) => () => {
19
+ if (fn)
20
+ try {
21
+ res = fn(fn = 0);
22
+ } catch (e) {
23
+ err = [e];
24
+ }
25
+ if (err)
26
+ throw err[0];
27
+ return res;
28
+ };
29
+ var __exportCjs = (target, getters, setters) => {
30
+ for (var name in getters)
31
+ __defProp(target, name, {
32
+ get: getters[name],
33
+ set: setters[name],
34
+ enumerable: true,
35
+ configurable: true
27
36
  });
28
37
  };
29
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
38
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
39
 
32
40
  // node_modules/commander/lib/error.js
33
- var require_error = __commonJS((exports) => {
41
+ var require_error = __commonJS(function(exports) {
34
42
  class CommanderError extends Error {
35
43
  constructor(exitCode, code, message) {
36
44
  super(message);
@@ -54,7 +62,7 @@ var require_error = __commonJS((exports) => {
54
62
  });
55
63
 
56
64
  // node_modules/commander/lib/argument.js
57
- var require_argument = __commonJS((exports) => {
65
+ var require_argument = __commonJS(function(exports) {
58
66
  var { InvalidArgumentError } = require_error();
59
67
 
60
68
  class Argument {
@@ -134,7 +142,7 @@ var require_argument = __commonJS((exports) => {
134
142
  });
135
143
 
136
144
  // node_modules/commander/lib/help.js
137
- var require_help = __commonJS((exports) => {
145
+ var require_help = __commonJS(function(exports) {
138
146
  var { humanReadableArgName } = require_argument();
139
147
 
140
148
  class Help {
@@ -149,7 +157,7 @@ var require_help = __commonJS((exports) => {
149
157
  this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;
150
158
  }
151
159
  visibleCommands(cmd) {
152
- const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
160
+ const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
153
161
  const helpCommand = cmd._getHelpCommand();
154
162
  if (helpCommand && !helpCommand._hidden) {
155
163
  visibleCommands.push(helpCommand);
@@ -491,7 +499,7 @@ ${itemIndentStr}`);
491
499
  });
492
500
 
493
501
  // node_modules/commander/lib/option.js
494
- var require_option = __commonJS((exports) => {
502
+ var require_option = __commonJS(function(exports) {
495
503
  var { InvalidArgumentError } = require_error();
496
504
 
497
505
  class Option {
@@ -629,8 +637,8 @@ var require_option = __commonJS((exports) => {
629
637
  }
630
638
  }
631
639
  function camelcase(str) {
632
- return str.split("-").reduce((str2, word) => {
633
- return str2 + word[0].toUpperCase() + word.slice(1);
640
+ return str.split("-").reduce((str, word) => {
641
+ return str + word[0].toUpperCase() + word.slice(1);
634
642
  });
635
643
  }
636
644
  function splitOptionFlags(flags) {
@@ -675,7 +683,7 @@ var require_option = __commonJS((exports) => {
675
683
  });
676
684
 
677
685
  // node_modules/commander/lib/suggestSimilar.js
678
- var require_suggestSimilar = __commonJS((exports) => {
686
+ var require_suggestSimilar = __commonJS(function(exports) {
679
687
  var maxDistance = 3;
680
688
  function editDistance(a, b) {
681
689
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -748,7 +756,7 @@ var require_suggestSimilar = __commonJS((exports) => {
748
756
  });
749
757
 
750
758
  // node_modules/commander/lib/command.js
751
- var require_command = __commonJS((exports) => {
759
+ var require_command = __commonJS(function(exports) {
752
760
  var EventEmitter = __require("node:events").EventEmitter;
753
761
  var childProcess = __require("node:child_process");
754
762
  var path = __require("node:path");
@@ -1001,7 +1009,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1001
1009
  this._exitCallback = (err) => {
1002
1010
  if (err.code !== "commander.executeSubCommandAsync") {
1003
1011
  throw err;
1004
- } else {}
1012
+ }
1005
1013
  };
1006
1014
  }
1007
1015
  return this;
@@ -1201,44 +1209,44 @@ Expecting one of '${allowedValues.join("', '")}'`);
1201
1209
  });
1202
1210
  return source;
1203
1211
  }
1204
- _prepareUserArgs(argv, parseOptions) {
1205
- if (argv !== undefined && !Array.isArray(argv)) {
1212
+ _prepareUserArgs(argv2, parseOptions) {
1213
+ if (argv2 !== undefined && !Array.isArray(argv2)) {
1206
1214
  throw new Error("first parameter to parse must be array or undefined");
1207
1215
  }
1208
1216
  parseOptions = parseOptions || {};
1209
- if (argv === undefined && parseOptions.from === undefined) {
1217
+ if (argv2 === undefined && parseOptions.from === undefined) {
1210
1218
  if (process2.versions?.electron) {
1211
1219
  parseOptions.from = "electron";
1212
1220
  }
1213
- const execArgv = process2.execArgv ?? [];
1214
- if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
1221
+ const execArgv2 = process2.execArgv ?? [];
1222
+ if (execArgv2.includes("-e") || execArgv2.includes("--eval") || execArgv2.includes("-p") || execArgv2.includes("--print")) {
1215
1223
  parseOptions.from = "eval";
1216
1224
  }
1217
1225
  }
1218
- if (argv === undefined) {
1219
- argv = process2.argv;
1226
+ if (argv2 === undefined) {
1227
+ argv2 = process2.argv;
1220
1228
  }
1221
- this.rawArgs = argv.slice();
1229
+ this.rawArgs = argv2.slice();
1222
1230
  let userArgs;
1223
1231
  switch (parseOptions.from) {
1224
1232
  case undefined:
1225
1233
  case "node":
1226
- this._scriptPath = argv[1];
1227
- userArgs = argv.slice(2);
1234
+ this._scriptPath = argv2[1];
1235
+ userArgs = argv2.slice(2);
1228
1236
  break;
1229
1237
  case "electron":
1230
1238
  if (process2.defaultApp) {
1231
- this._scriptPath = argv[1];
1232
- userArgs = argv.slice(2);
1239
+ this._scriptPath = argv2[1];
1240
+ userArgs = argv2.slice(2);
1233
1241
  } else {
1234
- userArgs = argv.slice(1);
1242
+ userArgs = argv2.slice(1);
1235
1243
  }
1236
1244
  break;
1237
1245
  case "user":
1238
- userArgs = argv.slice(0);
1246
+ userArgs = argv2.slice(0);
1239
1247
  break;
1240
1248
  case "eval":
1241
- userArgs = argv.slice(1);
1249
+ userArgs = argv2.slice(1);
1242
1250
  break;
1243
1251
  default:
1244
1252
  throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
@@ -1761,18 +1769,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
1761
1769
  this.error(message, { code: "commander.missingMandatoryOptionValue" });
1762
1770
  }
1763
1771
  _conflictingOption(option, conflictingOption) {
1764
- const findBestOptionFromValue = (option2) => {
1765
- const optionKey = option2.attributeName();
1772
+ const findBestOptionFromValue = (option) => {
1773
+ const optionKey = option.attributeName();
1766
1774
  const optionValue = this.getOptionValue(optionKey);
1767
1775
  const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
1768
1776
  const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
1769
1777
  if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) {
1770
1778
  return negativeOption;
1771
1779
  }
1772
- return positiveOption || option2;
1780
+ return positiveOption || option;
1773
1781
  };
1774
- const getErrorMessage = (option2) => {
1775
- const bestOption = findBestOptionFromValue(option2);
1782
+ const getErrorMessage = (option) => {
1783
+ const bestOption = findBestOptionFromValue(option);
1776
1784
  const optionKey = bestOption.attributeName();
1777
1785
  const source = this.getOptionValueSource(optionKey);
1778
1786
  if (source === "env") {
@@ -1926,10 +1934,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1926
1934
  this._name = path.basename(filename, path.extname(filename));
1927
1935
  return this;
1928
1936
  }
1929
- executableDir(path2) {
1930
- if (path2 === undefined)
1937
+ executableDir(path) {
1938
+ if (path === undefined)
1931
1939
  return this._executableDir;
1932
- this._executableDir = path2;
1940
+ this._executableDir = path;
1933
1941
  return this;
1934
1942
  }
1935
1943
  helpInformation(contextOptions) {
@@ -2026,11 +2034,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2026
2034
  }
2027
2035
  help(contextOptions) {
2028
2036
  this.outputHelp(contextOptions);
2029
- let exitCode = Number(process2.exitCode ?? 0);
2030
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2031
- exitCode = 1;
2037
+ let exitCode2 = Number(process2.exitCode ?? 0);
2038
+ if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
2039
+ exitCode2 = 1;
2032
2040
  }
2033
- this._exit(exitCode, "commander.help", "(outputHelp)");
2041
+ this._exit(exitCode2, "commander.help", "(outputHelp)");
2034
2042
  }
2035
2043
  addHelpText(position, text) {
2036
2044
  const allowedValues = ["beforeAll", "before", "after", "afterAll"];
@@ -2102,26 +2110,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
2102
2110
  exports.useColor = useColor;
2103
2111
  });
2104
2112
 
2105
- // node_modules/commander/index.js
2106
- var require_commander = __commonJS((exports) => {
2107
- var { Argument } = require_argument();
2108
- var { Command } = require_command();
2109
- var { CommanderError, InvalidArgumentError } = require_error();
2110
- var { Help } = require_help();
2111
- var { Option } = require_option();
2112
- exports.program = new Command;
2113
- exports.createCommand = (name) => new Command(name);
2114
- exports.createOption = (flags, description) => new Option(flags, description);
2115
- exports.createArgument = (name, description) => new Argument(name, description);
2116
- exports.Command = Command;
2117
- exports.Option = Option;
2118
- exports.Argument = Argument;
2119
- exports.Help = Help;
2120
- exports.CommanderError = CommanderError;
2121
- exports.InvalidArgumentError = InvalidArgumentError;
2122
- exports.InvalidOptionArgumentError = InvalidArgumentError;
2123
- });
2124
-
2125
2113
  // src/lib/errors.ts
2126
2114
  function extractDetail(body) {
2127
2115
  if (typeof body === "string")
@@ -2197,7 +2185,7 @@ var init_errors = __esm(() => {
2197
2185
  });
2198
2186
 
2199
2187
  // node_modules/yaml/dist/nodes/identity.js
2200
- var require_identity = __commonJS((exports) => {
2188
+ var require_identity = __commonJS(function(exports) {
2201
2189
  var ALIAS = Symbol.for("yaml.alias");
2202
2190
  var DOC = Symbol.for("yaml.document");
2203
2191
  var MAP = Symbol.for("yaml.map");
@@ -2251,7 +2239,7 @@ var require_identity = __commonJS((exports) => {
2251
2239
  });
2252
2240
 
2253
2241
  // node_modules/yaml/dist/visit.js
2254
- var require_visit = __commonJS((exports) => {
2242
+ var require_visit = __commonJS(function(exports) {
2255
2243
  var identity = require_identity();
2256
2244
  var BREAK = Symbol("break visit");
2257
2245
  var SKIP = Symbol("skip children");
@@ -2406,7 +2394,7 @@ var require_visit = __commonJS((exports) => {
2406
2394
  });
2407
2395
 
2408
2396
  // node_modules/yaml/dist/doc/directives.js
2409
- var require_directives = __commonJS((exports) => {
2397
+ var require_directives = __commonJS(function(exports) {
2410
2398
  var identity = require_identity();
2411
2399
  var visit = require_visit();
2412
2400
  var escapeChars = {
@@ -2558,7 +2546,7 @@ var require_directives = __commonJS((exports) => {
2558
2546
  });
2559
2547
 
2560
2548
  // node_modules/yaml/dist/doc/anchors.js
2561
- var require_anchors = __commonJS((exports) => {
2549
+ var require_anchors = __commonJS(function(exports) {
2562
2550
  var identity = require_identity();
2563
2551
  var visit = require_visit();
2564
2552
  function anchorIsValid(anchor) {
@@ -2620,7 +2608,7 @@ var require_anchors = __commonJS((exports) => {
2620
2608
  });
2621
2609
 
2622
2610
  // node_modules/yaml/dist/doc/applyReviver.js
2623
- var require_applyReviver = __commonJS((exports) => {
2611
+ var require_applyReviver = __commonJS(function(exports) {
2624
2612
  function applyReviver(reviver, obj, key, val) {
2625
2613
  if (val && typeof val === "object") {
2626
2614
  if (Array.isArray(val)) {
@@ -2667,7 +2655,7 @@ var require_applyReviver = __commonJS((exports) => {
2667
2655
  });
2668
2656
 
2669
2657
  // node_modules/yaml/dist/nodes/toJS.js
2670
- var require_toJS = __commonJS((exports) => {
2658
+ var require_toJS = __commonJS(function(exports) {
2671
2659
  var identity = require_identity();
2672
2660
  function toJS(value, arg, ctx) {
2673
2661
  if (Array.isArray(value))
@@ -2677,8 +2665,8 @@ var require_toJS = __commonJS((exports) => {
2677
2665
  return value.toJSON(arg, ctx);
2678
2666
  const data = { aliasCount: 0, count: 1, res: undefined };
2679
2667
  ctx.anchors.set(value, data);
2680
- ctx.onCreate = (res2) => {
2681
- data.res = res2;
2668
+ ctx.onCreate = (res) => {
2669
+ data.res = res;
2682
2670
  delete ctx.onCreate;
2683
2671
  };
2684
2672
  const res = value.toJSON(arg, ctx);
@@ -2694,7 +2682,7 @@ var require_toJS = __commonJS((exports) => {
2694
2682
  });
2695
2683
 
2696
2684
  // node_modules/yaml/dist/nodes/Node.js
2697
- var require_Node = __commonJS((exports) => {
2685
+ var require_Node = __commonJS(function(exports) {
2698
2686
  var applyReviver = require_applyReviver();
2699
2687
  var identity = require_identity();
2700
2688
  var toJS = require_toJS();
@@ -2722,8 +2710,8 @@ var require_Node = __commonJS((exports) => {
2722
2710
  };
2723
2711
  const res = toJS.toJS(this, "", ctx);
2724
2712
  if (typeof onAnchor === "function")
2725
- for (const { count, res: res2 } of ctx.anchors.values())
2726
- onAnchor(res2, count);
2713
+ for (const { count, res } of ctx.anchors.values())
2714
+ onAnchor(res, count);
2727
2715
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
2728
2716
  }
2729
2717
  }
@@ -2731,7 +2719,7 @@ var require_Node = __commonJS((exports) => {
2731
2719
  });
2732
2720
 
2733
2721
  // node_modules/yaml/dist/nodes/Alias.js
2734
- var require_Alias = __commonJS((exports) => {
2722
+ var require_Alias = __commonJS(function(exports) {
2735
2723
  var anchors = require_anchors();
2736
2724
  var visit = require_visit();
2737
2725
  var identity = require_identity();
@@ -2775,16 +2763,16 @@ var require_Alias = __commonJS((exports) => {
2775
2763
  toJSON(_arg, ctx) {
2776
2764
  if (!ctx)
2777
2765
  return { source: this.source };
2778
- const { anchors: anchors2, doc, maxAliasCount } = ctx;
2766
+ const { anchors, doc, maxAliasCount } = ctx;
2779
2767
  const source = this.resolve(doc, ctx);
2780
2768
  if (!source) {
2781
2769
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
2782
2770
  throw new ReferenceError(msg);
2783
2771
  }
2784
- let data = anchors2.get(source);
2772
+ let data = anchors.get(source);
2785
2773
  if (!data) {
2786
2774
  toJS.toJS(source, null, ctx);
2787
- data = anchors2.get(source);
2775
+ data = anchors.get(source);
2788
2776
  }
2789
2777
  if (data?.res === undefined) {
2790
2778
  const msg = "This should not happen: Alias anchor was not resolved?";
@@ -2793,7 +2781,7 @@ var require_Alias = __commonJS((exports) => {
2793
2781
  if (maxAliasCount >= 0) {
2794
2782
  data.count += 1;
2795
2783
  if (data.aliasCount === 0)
2796
- data.aliasCount = getAliasCount(doc, source, anchors2);
2784
+ data.aliasCount = getAliasCount(doc, source, anchors);
2797
2785
  if (data.count * data.aliasCount > maxAliasCount) {
2798
2786
  const msg = "Excessive alias count indicates a resource exhaustion attack";
2799
2787
  throw new ReferenceError(msg);
@@ -2815,22 +2803,22 @@ var require_Alias = __commonJS((exports) => {
2815
2803
  return src;
2816
2804
  }
2817
2805
  }
2818
- function getAliasCount(doc, node, anchors2) {
2806
+ function getAliasCount(doc, node, anchors) {
2819
2807
  if (identity.isAlias(node)) {
2820
2808
  const source = node.resolve(doc);
2821
- const anchor = anchors2 && source && anchors2.get(source);
2809
+ const anchor = anchors && source && anchors.get(source);
2822
2810
  return anchor ? anchor.count * anchor.aliasCount : 0;
2823
2811
  } else if (identity.isCollection(node)) {
2824
2812
  let count = 0;
2825
2813
  for (const item of node.items) {
2826
- const c = getAliasCount(doc, item, anchors2);
2814
+ const c = getAliasCount(doc, item, anchors);
2827
2815
  if (c > count)
2828
2816
  count = c;
2829
2817
  }
2830
2818
  return count;
2831
2819
  } else if (identity.isPair(node)) {
2832
- const kc = getAliasCount(doc, node.key, anchors2);
2833
- const vc = getAliasCount(doc, node.value, anchors2);
2820
+ const kc = getAliasCount(doc, node.key, anchors);
2821
+ const vc = getAliasCount(doc, node.value, anchors);
2834
2822
  return Math.max(kc, vc);
2835
2823
  }
2836
2824
  return 1;
@@ -2839,7 +2827,7 @@ var require_Alias = __commonJS((exports) => {
2839
2827
  });
2840
2828
 
2841
2829
  // node_modules/yaml/dist/nodes/Scalar.js
2842
- var require_Scalar = __commonJS((exports) => {
2830
+ var require_Scalar = __commonJS(function(exports) {
2843
2831
  var identity = require_identity();
2844
2832
  var Node = require_Node();
2845
2833
  var toJS = require_toJS();
@@ -2867,7 +2855,7 @@ var require_Scalar = __commonJS((exports) => {
2867
2855
  });
2868
2856
 
2869
2857
  // node_modules/yaml/dist/doc/createNode.js
2870
- var require_createNode = __commonJS((exports) => {
2858
+ var require_createNode = __commonJS(function(exports) {
2871
2859
  var Alias = require_Alias();
2872
2860
  var identity = require_identity();
2873
2861
  var Scalar = require_Scalar();
@@ -2915,10 +2903,10 @@ var require_createNode = __commonJS((exports) => {
2915
2903
  value = value.toJSON();
2916
2904
  }
2917
2905
  if (!value || typeof value !== "object") {
2918
- const node2 = new Scalar.Scalar(value);
2906
+ const node = new Scalar.Scalar(value);
2919
2907
  if (ref)
2920
- ref.node = node2;
2921
- return node2;
2908
+ ref.node = node;
2909
+ return node;
2922
2910
  }
2923
2911
  tagObj = value instanceof Map ? schema[identity.MAP] : (Symbol.iterator in Object(value)) ? schema[identity.SEQ] : schema[identity.MAP];
2924
2912
  }
@@ -2939,7 +2927,7 @@ var require_createNode = __commonJS((exports) => {
2939
2927
  });
2940
2928
 
2941
2929
  // node_modules/yaml/dist/nodes/Collection.js
2942
- var require_Collection = __commonJS((exports) => {
2930
+ var require_Collection = __commonJS(function(exports) {
2943
2931
  var createNode = require_createNode();
2944
2932
  var identity = require_identity();
2945
2933
  var Node = require_Node();
@@ -3054,7 +3042,7 @@ var require_Collection = __commonJS((exports) => {
3054
3042
  });
3055
3043
 
3056
3044
  // node_modules/yaml/dist/stringify/stringifyComment.js
3057
- var require_stringifyComment = __commonJS((exports) => {
3045
+ var require_stringifyComment = __commonJS(function(exports) {
3058
3046
  var stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#");
3059
3047
  function indentComment(comment, indent) {
3060
3048
  if (/^\n+$/.test(comment))
@@ -3071,7 +3059,7 @@ var require_stringifyComment = __commonJS((exports) => {
3071
3059
  });
3072
3060
 
3073
3061
  // node_modules/yaml/dist/stringify/foldFlowLines.js
3074
- var require_foldFlowLines = __commonJS((exports) => {
3062
+ var require_foldFlowLines = __commonJS(function(exports) {
3075
3063
  var FOLD_FLOW = "flow";
3076
3064
  var FOLD_BLOCK = "block";
3077
3065
  var FOLD_QUOTED = "quoted";
@@ -3167,17 +3155,17 @@ var require_foldFlowLines = __commonJS((exports) => {
3167
3155
  if (onFold)
3168
3156
  onFold();
3169
3157
  let res = text.slice(0, folds[0]);
3170
- for (let i2 = 0;i2 < folds.length; ++i2) {
3171
- const fold = folds[i2];
3172
- const end2 = folds[i2 + 1] || text.length;
3158
+ for (let i = 0;i < folds.length; ++i) {
3159
+ const fold = folds[i];
3160
+ const end = folds[i + 1] || text.length;
3173
3161
  if (fold === 0)
3174
3162
  res = `
3175
- ${indent}${text.slice(0, end2)}`;
3163
+ ${indent}${text.slice(0, end)}`;
3176
3164
  else {
3177
3165
  if (mode === FOLD_QUOTED && escapedFolds[fold])
3178
3166
  res += `${text[fold]}\\`;
3179
3167
  res += `
3180
- ${indent}${text.slice(fold + 1, end2)}`;
3168
+ ${indent}${text.slice(fold + 1, end)}`;
3181
3169
  }
3182
3170
  }
3183
3171
  return res;
@@ -3208,7 +3196,7 @@ ${indent}${text.slice(fold + 1, end2)}`;
3208
3196
  });
3209
3197
 
3210
3198
  // node_modules/yaml/dist/stringify/stringifyString.js
3211
- var require_stringifyString = __commonJS((exports) => {
3199
+ var require_stringifyString = __commonJS(function(exports) {
3212
3200
  var Scalar = require_Scalar();
3213
3201
  var foldFlowLines = require_foldFlowLines();
3214
3202
  var getFoldOptions = (ctx, isBlock) => ({
@@ -3506,7 +3494,7 @@ ${indent}`);
3506
3494
  });
3507
3495
 
3508
3496
  // node_modules/yaml/dist/stringify/stringify.js
3509
- var require_stringify = __commonJS((exports) => {
3497
+ var require_stringify = __commonJS(function(exports) {
3510
3498
  var anchors = require_anchors();
3511
3499
  var identity = require_identity();
3512
3500
  var stringifyComment = require_stringifyComment();
@@ -3528,7 +3516,6 @@ var require_stringify = __commonJS((exports) => {
3528
3516
  nullStr: "null",
3529
3517
  simpleKeys: false,
3530
3518
  singleQuote: null,
3531
- trailingComma: false,
3532
3519
  trueStr: "true",
3533
3520
  verifyAliasOrder: true
3534
3521
  }, doc.schema.toStringOptions, options);
@@ -3627,7 +3614,7 @@ ${ctx.indent}${str}`;
3627
3614
  });
3628
3615
 
3629
3616
  // node_modules/yaml/dist/stringify/stringifyPair.js
3630
- var require_stringifyPair = __commonJS((exports) => {
3617
+ var require_stringifyPair = __commonJS(function(exports) {
3631
3618
  var identity = require_identity();
3632
3619
  var Scalar = require_Scalar();
3633
3620
  var stringify = require_stringify();
@@ -3763,7 +3750,7 @@ ${ctx.indent}`;
3763
3750
  });
3764
3751
 
3765
3752
  // node_modules/yaml/dist/log.js
3766
- var require_log = __commonJS((exports) => {
3753
+ var require_log = __commonJS(function(exports) {
3767
3754
  var node_process = __require("process");
3768
3755
  function debug(logLevel, ...messages) {
3769
3756
  if (logLevel === "debug")
@@ -3782,7 +3769,7 @@ var require_log = __commonJS((exports) => {
3782
3769
  });
3783
3770
 
3784
3771
  // node_modules/yaml/dist/schema/yaml-1.1/merge.js
3785
- var require_merge = __commonJS((exports) => {
3772
+ var require_merge = __commonJS(function(exports) {
3786
3773
  var identity = require_identity();
3787
3774
  var Scalar = require_Scalar();
3788
3775
  var MERGE_KEY = "<<";
@@ -3813,15 +3800,15 @@ var require_merge = __commonJS((exports) => {
3813
3800
  if (!identity.isMap(source))
3814
3801
  throw new Error("Merge sources must be maps or map aliases");
3815
3802
  const srcMap = source.toJSON(null, ctx, Map);
3816
- for (const [key, value2] of srcMap) {
3803
+ for (const [key, value] of srcMap) {
3817
3804
  if (map instanceof Map) {
3818
3805
  if (!map.has(key))
3819
- map.set(key, value2);
3806
+ map.set(key, value);
3820
3807
  } else if (map instanceof Set) {
3821
3808
  map.add(key);
3822
3809
  } else if (!Object.prototype.hasOwnProperty.call(map, key)) {
3823
3810
  Object.defineProperty(map, key, {
3824
- value: value2,
3811
+ value,
3825
3812
  writable: true,
3826
3813
  enumerable: true,
3827
3814
  configurable: true
@@ -3836,7 +3823,7 @@ var require_merge = __commonJS((exports) => {
3836
3823
  });
3837
3824
 
3838
3825
  // node_modules/yaml/dist/nodes/addPairToJSMap.js
3839
- var require_addPairToJSMap = __commonJS((exports) => {
3826
+ var require_addPairToJSMap = __commonJS(function(exports) {
3840
3827
  var log = require_log();
3841
3828
  var merge = require_merge();
3842
3829
  var stringify = require_stringify();
@@ -3897,7 +3884,7 @@ var require_addPairToJSMap = __commonJS((exports) => {
3897
3884
  });
3898
3885
 
3899
3886
  // node_modules/yaml/dist/nodes/Pair.js
3900
- var require_Pair = __commonJS((exports) => {
3887
+ var require_Pair = __commonJS(function(exports) {
3901
3888
  var createNode = require_createNode();
3902
3889
  var stringifyPair = require_stringifyPair();
3903
3890
  var addPairToJSMap = require_addPairToJSMap();
@@ -3935,14 +3922,14 @@ var require_Pair = __commonJS((exports) => {
3935
3922
  });
3936
3923
 
3937
3924
  // node_modules/yaml/dist/stringify/stringifyCollection.js
3938
- var require_stringifyCollection = __commonJS((exports) => {
3925
+ var require_stringifyCollection = __commonJS(function(exports) {
3939
3926
  var identity = require_identity();
3940
3927
  var stringify = require_stringify();
3941
3928
  var stringifyComment = require_stringifyComment();
3942
3929
  function stringifyCollection(collection, ctx, options) {
3943
3930
  const flow = ctx.inFlow ?? collection.flow;
3944
- const stringify2 = flow ? stringifyFlowCollection : stringifyBlockCollection;
3945
- return stringify2(collection, ctx, options);
3931
+ const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
3932
+ return stringify(collection, ctx, options);
3946
3933
  }
3947
3934
  function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
3948
3935
  const { indent, options: { commentString } } = ctx;
@@ -3951,13 +3938,13 @@ var require_stringifyCollection = __commonJS((exports) => {
3951
3938
  const lines = [];
3952
3939
  for (let i = 0;i < items.length; ++i) {
3953
3940
  const item = items[i];
3954
- let comment2 = null;
3941
+ let comment = null;
3955
3942
  if (identity.isNode(item)) {
3956
3943
  if (!chompKeep && item.spaceBefore)
3957
3944
  lines.push("");
3958
3945
  addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
3959
3946
  if (item.comment)
3960
- comment2 = item.comment;
3947
+ comment = item.comment;
3961
3948
  } else if (identity.isPair(item)) {
3962
3949
  const ik = identity.isNode(item.key) ? item.key : null;
3963
3950
  if (ik) {
@@ -3967,12 +3954,12 @@ var require_stringifyCollection = __commonJS((exports) => {
3967
3954
  }
3968
3955
  }
3969
3956
  chompKeep = false;
3970
- let str2 = stringify.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
3971
- if (comment2)
3972
- str2 += stringifyComment.lineComment(str2, itemIndent, commentString(comment2));
3973
- if (chompKeep && comment2)
3957
+ let str = stringify.stringify(item, itemCtx, () => comment = null, () => chompKeep = true);
3958
+ if (comment)
3959
+ str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
3960
+ if (chompKeep && comment)
3974
3961
  chompKeep = false;
3975
- lines.push(blockItemPrefix + str2);
3962
+ lines.push(blockItemPrefix + str);
3976
3963
  }
3977
3964
  let str;
3978
3965
  if (lines.length === 0) {
@@ -4037,20 +4024,13 @@ ${indent}${line}` : `
4037
4024
  if (comment)
4038
4025
  reqNewline = true;
4039
4026
  let str = stringify.stringify(item, itemCtx, () => comment = null);
4040
- reqNewline || (reqNewline = lines.length > linesAtValue || str.includes(`
4041
- `));
4042
- if (i < items.length - 1) {
4027
+ if (i < items.length - 1)
4043
4028
  str += ",";
4044
- } else if (ctx.options.trailingComma) {
4045
- if (ctx.options.lineWidth > 0) {
4046
- reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str.length + 2) > ctx.options.lineWidth);
4047
- }
4048
- if (reqNewline) {
4049
- str += ",";
4050
- }
4051
- }
4052
4029
  if (comment)
4053
4030
  str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
4031
+ if (!reqNewline && (lines.length > linesAtValue || str.includes(`
4032
+ `)))
4033
+ reqNewline = true;
4054
4034
  lines.push(str);
4055
4035
  linesAtValue = lines.length;
4056
4036
  }
@@ -4087,7 +4067,7 @@ ${indent}${end}`;
4087
4067
  });
4088
4068
 
4089
4069
  // node_modules/yaml/dist/nodes/YAMLMap.js
4090
- var require_YAMLMap = __commonJS((exports) => {
4070
+ var require_YAMLMap = __commonJS(function(exports) {
4091
4071
  var stringifyCollection = require_stringifyCollection();
4092
4072
  var addPairToJSMap = require_addPairToJSMap();
4093
4073
  var Collection = require_Collection();
@@ -4214,7 +4194,7 @@ var require_YAMLMap = __commonJS((exports) => {
4214
4194
  });
4215
4195
 
4216
4196
  // node_modules/yaml/dist/schema/common/map.js
4217
- var require_map = __commonJS((exports) => {
4197
+ var require_map = __commonJS(function(exports) {
4218
4198
  var identity = require_identity();
4219
4199
  var YAMLMap = require_YAMLMap();
4220
4200
  var map = {
@@ -4222,10 +4202,10 @@ var require_map = __commonJS((exports) => {
4222
4202
  default: true,
4223
4203
  nodeClass: YAMLMap.YAMLMap,
4224
4204
  tag: "tag:yaml.org,2002:map",
4225
- resolve(map2, onError) {
4226
- if (!identity.isMap(map2))
4205
+ resolve(map, onError) {
4206
+ if (!identity.isMap(map))
4227
4207
  onError("Expected a mapping for this tag");
4228
- return map2;
4208
+ return map;
4229
4209
  },
4230
4210
  createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx)
4231
4211
  };
@@ -4233,7 +4213,7 @@ var require_map = __commonJS((exports) => {
4233
4213
  });
4234
4214
 
4235
4215
  // node_modules/yaml/dist/nodes/YAMLSeq.js
4236
- var require_YAMLSeq = __commonJS((exports) => {
4216
+ var require_YAMLSeq = __commonJS(function(exports) {
4237
4217
  var createNode = require_createNode();
4238
4218
  var stringifyCollection = require_stringifyCollection();
4239
4219
  var Collection = require_Collection();
@@ -4326,7 +4306,7 @@ var require_YAMLSeq = __commonJS((exports) => {
4326
4306
  });
4327
4307
 
4328
4308
  // node_modules/yaml/dist/schema/common/seq.js
4329
- var require_seq = __commonJS((exports) => {
4309
+ var require_seq = __commonJS(function(exports) {
4330
4310
  var identity = require_identity();
4331
4311
  var YAMLSeq = require_YAMLSeq();
4332
4312
  var seq = {
@@ -4334,10 +4314,10 @@ var require_seq = __commonJS((exports) => {
4334
4314
  default: true,
4335
4315
  nodeClass: YAMLSeq.YAMLSeq,
4336
4316
  tag: "tag:yaml.org,2002:seq",
4337
- resolve(seq2, onError) {
4338
- if (!identity.isSeq(seq2))
4317
+ resolve(seq, onError) {
4318
+ if (!identity.isSeq(seq))
4339
4319
  onError("Expected a sequence for this tag");
4340
- return seq2;
4320
+ return seq;
4341
4321
  },
4342
4322
  createNode: (schema, obj, ctx) => YAMLSeq.YAMLSeq.from(schema, obj, ctx)
4343
4323
  };
@@ -4345,7 +4325,7 @@ var require_seq = __commonJS((exports) => {
4345
4325
  });
4346
4326
 
4347
4327
  // node_modules/yaml/dist/schema/common/string.js
4348
- var require_string = __commonJS((exports) => {
4328
+ var require_string = __commonJS(function(exports) {
4349
4329
  var stringifyString = require_stringifyString();
4350
4330
  var string = {
4351
4331
  identify: (value) => typeof value === "string",
@@ -4361,7 +4341,7 @@ var require_string = __commonJS((exports) => {
4361
4341
  });
4362
4342
 
4363
4343
  // node_modules/yaml/dist/schema/common/null.js
4364
- var require_null = __commonJS((exports) => {
4344
+ var require_null = __commonJS(function(exports) {
4365
4345
  var Scalar = require_Scalar();
4366
4346
  var nullTag = {
4367
4347
  identify: (value) => value == null,
@@ -4376,7 +4356,7 @@ var require_null = __commonJS((exports) => {
4376
4356
  });
4377
4357
 
4378
4358
  // node_modules/yaml/dist/schema/core/bool.js
4379
- var require_bool = __commonJS((exports) => {
4359
+ var require_bool = __commonJS(function(exports) {
4380
4360
  var Scalar = require_Scalar();
4381
4361
  var boolTag = {
4382
4362
  identify: (value) => typeof value === "boolean",
@@ -4397,7 +4377,7 @@ var require_bool = __commonJS((exports) => {
4397
4377
  });
4398
4378
 
4399
4379
  // node_modules/yaml/dist/stringify/stringifyNumber.js
4400
- var require_stringifyNumber = __commonJS((exports) => {
4380
+ var require_stringifyNumber = __commonJS(function(exports) {
4401
4381
  function stringifyNumber({ format, minFractionDigits, tag, value }) {
4402
4382
  if (typeof value === "bigint")
4403
4383
  return String(value);
@@ -4421,7 +4401,7 @@ var require_stringifyNumber = __commonJS((exports) => {
4421
4401
  });
4422
4402
 
4423
4403
  // node_modules/yaml/dist/schema/core/float.js
4424
- var require_float = __commonJS((exports) => {
4404
+ var require_float = __commonJS(function(exports) {
4425
4405
  var Scalar = require_Scalar();
4426
4406
  var stringifyNumber = require_stringifyNumber();
4427
4407
  var floatNaN = {
@@ -4464,7 +4444,7 @@ var require_float = __commonJS((exports) => {
4464
4444
  });
4465
4445
 
4466
4446
  // node_modules/yaml/dist/schema/core/int.js
4467
- var require_int = __commonJS((exports) => {
4447
+ var require_int = __commonJS(function(exports) {
4468
4448
  var stringifyNumber = require_stringifyNumber();
4469
4449
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
4470
4450
  var intResolve = (str, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str) : parseInt(str.substring(offset), radix);
@@ -4506,7 +4486,7 @@ var require_int = __commonJS((exports) => {
4506
4486
  });
4507
4487
 
4508
4488
  // node_modules/yaml/dist/schema/core/schema.js
4509
- var require_schema = __commonJS((exports) => {
4489
+ var require_schema = __commonJS(function(exports) {
4510
4490
  var map = require_map();
4511
4491
  var _null = require_null();
4512
4492
  var seq = require_seq();
@@ -4531,7 +4511,7 @@ var require_schema = __commonJS((exports) => {
4531
4511
  });
4532
4512
 
4533
4513
  // node_modules/yaml/dist/schema/json/schema.js
4534
- var require_schema2 = __commonJS((exports) => {
4514
+ var require_schema2 = __commonJS(function(exports) {
4535
4515
  var Scalar = require_Scalar();
4536
4516
  var map = require_map();
4537
4517
  var seq = require_seq();
@@ -4595,7 +4575,7 @@ var require_schema2 = __commonJS((exports) => {
4595
4575
  });
4596
4576
 
4597
4577
  // node_modules/yaml/dist/schema/yaml-1.1/binary.js
4598
- var require_binary = __commonJS((exports) => {
4578
+ var require_binary = __commonJS(function(exports) {
4599
4579
  var node_buffer = __require("buffer");
4600
4580
  var Scalar = require_Scalar();
4601
4581
  var stringifyString = require_stringifyString();
@@ -4650,7 +4630,7 @@ var require_binary = __commonJS((exports) => {
4650
4630
  });
4651
4631
 
4652
4632
  // node_modules/yaml/dist/schema/yaml-1.1/pairs.js
4653
- var require_pairs = __commonJS((exports) => {
4633
+ var require_pairs = __commonJS(function(exports) {
4654
4634
  var identity = require_identity();
4655
4635
  var Pair = require_Pair();
4656
4636
  var Scalar = require_Scalar();
@@ -4683,8 +4663,8 @@ ${cn.comment}` : item.comment;
4683
4663
  }
4684
4664
  function createPairs(schema, iterable, ctx) {
4685
4665
  const { replacer } = ctx;
4686
- const pairs2 = new YAMLSeq.YAMLSeq(schema);
4687
- pairs2.tag = "tag:yaml.org,2002:pairs";
4666
+ const pairs = new YAMLSeq.YAMLSeq(schema);
4667
+ pairs.tag = "tag:yaml.org,2002:pairs";
4688
4668
  let i = 0;
4689
4669
  if (iterable && Symbol.iterator in Object(iterable))
4690
4670
  for (let it of iterable) {
@@ -4708,9 +4688,9 @@ ${cn.comment}` : item.comment;
4708
4688
  } else {
4709
4689
  key = it;
4710
4690
  }
4711
- pairs2.items.push(Pair.createPair(key, value, ctx));
4691
+ pairs.items.push(Pair.createPair(key, value, ctx));
4712
4692
  }
4713
- return pairs2;
4693
+ return pairs;
4714
4694
  }
4715
4695
  var pairs = {
4716
4696
  collection: "seq",
@@ -4725,7 +4705,7 @@ ${cn.comment}` : item.comment;
4725
4705
  });
4726
4706
 
4727
4707
  // node_modules/yaml/dist/schema/yaml-1.1/omap.js
4728
- var require_omap = __commonJS((exports) => {
4708
+ var require_omap = __commonJS(function(exports) {
4729
4709
  var identity = require_identity();
4730
4710
  var toJS = require_toJS();
4731
4711
  var YAMLMap = require_YAMLMap();
@@ -4764,9 +4744,9 @@ var require_omap = __commonJS((exports) => {
4764
4744
  }
4765
4745
  static from(schema, iterable, ctx) {
4766
4746
  const pairs$1 = pairs.createPairs(schema, iterable, ctx);
4767
- const omap2 = new this;
4768
- omap2.items = pairs$1.items;
4769
- return omap2;
4747
+ const omap = new this;
4748
+ omap.items = pairs$1.items;
4749
+ return omap;
4770
4750
  }
4771
4751
  }
4772
4752
  YAMLOMap.tag = "tag:yaml.org,2002:omap";
@@ -4797,7 +4777,7 @@ var require_omap = __commonJS((exports) => {
4797
4777
  });
4798
4778
 
4799
4779
  // node_modules/yaml/dist/schema/yaml-1.1/bool.js
4800
- var require_bool2 = __commonJS((exports) => {
4780
+ var require_bool2 = __commonJS(function(exports) {
4801
4781
  var Scalar = require_Scalar();
4802
4782
  function boolStringify({ value, source }, ctx) {
4803
4783
  const boolObj = value ? trueTag : falseTag;
@@ -4826,7 +4806,7 @@ var require_bool2 = __commonJS((exports) => {
4826
4806
  });
4827
4807
 
4828
4808
  // node_modules/yaml/dist/schema/yaml-1.1/float.js
4829
- var require_float2 = __commonJS((exports) => {
4809
+ var require_float2 = __commonJS(function(exports) {
4830
4810
  var Scalar = require_Scalar();
4831
4811
  var stringifyNumber = require_stringifyNumber();
4832
4812
  var floatNaN = {
@@ -4872,7 +4852,7 @@ var require_float2 = __commonJS((exports) => {
4872
4852
  });
4873
4853
 
4874
4854
  // node_modules/yaml/dist/schema/yaml-1.1/int.js
4875
- var require_int2 = __commonJS((exports) => {
4855
+ var require_int2 = __commonJS(function(exports) {
4876
4856
  var stringifyNumber = require_stringifyNumber();
4877
4857
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
4878
4858
  function intResolve(str, offset, radix, { intAsBigInt }) {
@@ -4892,8 +4872,8 @@ var require_int2 = __commonJS((exports) => {
4892
4872
  str = `0x${str}`;
4893
4873
  break;
4894
4874
  }
4895
- const n2 = BigInt(str);
4896
- return sign === "-" ? BigInt(-1) * n2 : n2;
4875
+ const n = BigInt(str);
4876
+ return sign === "-" ? BigInt(-1) * n : n;
4897
4877
  }
4898
4878
  const n = parseInt(str, radix);
4899
4879
  return sign === "-" ? -1 * n : n;
@@ -4948,7 +4928,7 @@ var require_int2 = __commonJS((exports) => {
4948
4928
  });
4949
4929
 
4950
4930
  // node_modules/yaml/dist/schema/yaml-1.1/set.js
4951
- var require_set = __commonJS((exports) => {
4931
+ var require_set = __commonJS(function(exports) {
4952
4932
  var identity = require_identity();
4953
4933
  var Pair = require_Pair();
4954
4934
  var YAMLMap = require_YAMLMap();
@@ -4997,14 +4977,14 @@ var require_set = __commonJS((exports) => {
4997
4977
  }
4998
4978
  static from(schema, iterable, ctx) {
4999
4979
  const { replacer } = ctx;
5000
- const set2 = new this(schema);
4980
+ const set = new this(schema);
5001
4981
  if (iterable && Symbol.iterator in Object(iterable))
5002
4982
  for (let value of iterable) {
5003
4983
  if (typeof replacer === "function")
5004
4984
  value = replacer.call(iterable, value, value);
5005
- set2.items.push(Pair.createPair(value, null, ctx));
4985
+ set.items.push(Pair.createPair(value, null, ctx));
5006
4986
  }
5007
- return set2;
4987
+ return set;
5008
4988
  }
5009
4989
  }
5010
4990
  YAMLSet.tag = "tag:yaml.org,2002:set";
@@ -5031,13 +5011,13 @@ var require_set = __commonJS((exports) => {
5031
5011
  });
5032
5012
 
5033
5013
  // node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
5034
- var require_timestamp = __commonJS((exports) => {
5014
+ var require_timestamp = __commonJS(function(exports) {
5035
5015
  var stringifyNumber = require_stringifyNumber();
5036
5016
  function parseSexagesimal(str, asBigInt) {
5037
5017
  const sign = str[0];
5038
5018
  const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
5039
5019
  const num = (n) => asBigInt ? BigInt(n) : Number(n);
5040
- const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
5020
+ const res = parts.replace(/_/g, "").split(":").reduce((res, p) => res * num(60) + num(p), num(0));
5041
5021
  return sign === "-" ? num(-1) * res : res;
5042
5022
  }
5043
5023
  function stringifySexagesimal(node) {
@@ -5113,7 +5093,7 @@ var require_timestamp = __commonJS((exports) => {
5113
5093
  });
5114
5094
 
5115
5095
  // node_modules/yaml/dist/schema/yaml-1.1/schema.js
5116
- var require_schema3 = __commonJS((exports) => {
5096
+ var require_schema3 = __commonJS(function(exports) {
5117
5097
  var map = require_map();
5118
5098
  var _null = require_null();
5119
5099
  var seq = require_seq();
@@ -5154,7 +5134,7 @@ var require_schema3 = __commonJS((exports) => {
5154
5134
  });
5155
5135
 
5156
5136
  // node_modules/yaml/dist/schema/tags.js
5157
- var require_tags = __commonJS((exports) => {
5137
+ var require_tags = __commonJS(function(exports) {
5158
5138
  var map = require_map();
5159
5139
  var _null = require_null();
5160
5140
  var seq = require_seq();
@@ -5228,16 +5208,16 @@ var require_tags = __commonJS((exports) => {
5228
5208
  }
5229
5209
  if (addMergeTag)
5230
5210
  tags = tags.concat(merge.merge);
5231
- return tags.reduce((tags2, tag) => {
5211
+ return tags.reduce((tags, tag) => {
5232
5212
  const tagObj = typeof tag === "string" ? tagsByName[tag] : tag;
5233
5213
  if (!tagObj) {
5234
5214
  const tagName = JSON.stringify(tag);
5235
5215
  const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", ");
5236
5216
  throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
5237
5217
  }
5238
- if (!tags2.includes(tagObj))
5239
- tags2.push(tagObj);
5240
- return tags2;
5218
+ if (!tags.includes(tagObj))
5219
+ tags.push(tagObj);
5220
+ return tags;
5241
5221
  }, []);
5242
5222
  }
5243
5223
  exports.coreKnownTags = coreKnownTags;
@@ -5245,7 +5225,7 @@ var require_tags = __commonJS((exports) => {
5245
5225
  });
5246
5226
 
5247
5227
  // node_modules/yaml/dist/schema/Schema.js
5248
- var require_Schema = __commonJS((exports) => {
5228
+ var require_Schema = __commonJS(function(exports) {
5249
5229
  var identity = require_identity();
5250
5230
  var map = require_map();
5251
5231
  var seq = require_seq();
@@ -5275,7 +5255,7 @@ var require_Schema = __commonJS((exports) => {
5275
5255
  });
5276
5256
 
5277
5257
  // node_modules/yaml/dist/stringify/stringifyDocument.js
5278
- var require_stringifyDocument = __commonJS((exports) => {
5258
+ var require_stringifyDocument = __commonJS(function(exports) {
5279
5259
  var identity = require_identity();
5280
5260
  var stringify = require_stringify();
5281
5261
  var stringifyComment = require_stringifyComment();
@@ -5355,7 +5335,7 @@ var require_stringifyDocument = __commonJS((exports) => {
5355
5335
  });
5356
5336
 
5357
5337
  // node_modules/yaml/dist/doc/Document.js
5358
- var require_Document = __commonJS((exports) => {
5338
+ var require_Document = __commonJS(function(exports) {
5359
5339
  var Alias = require_Alias();
5360
5340
  var Collection = require_Collection();
5361
5341
  var identity = require_identity();
@@ -5564,8 +5544,8 @@ var require_Document = __commonJS((exports) => {
5564
5544
  };
5565
5545
  const res = toJS.toJS(this.contents, jsonArg ?? "", ctx);
5566
5546
  if (typeof onAnchor === "function")
5567
- for (const { count, res: res2 } of ctx.anchors.values())
5568
- onAnchor(res2, count);
5547
+ for (const { count, res } of ctx.anchors.values())
5548
+ onAnchor(res, count);
5569
5549
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
5570
5550
  }
5571
5551
  toJSON(jsonArg, onAnchor) {
@@ -5590,7 +5570,7 @@ var require_Document = __commonJS((exports) => {
5590
5570
  });
5591
5571
 
5592
5572
  // node_modules/yaml/dist/errors.js
5593
- var require_errors = __commonJS((exports) => {
5573
+ var require_errors = __commonJS(function(exports) {
5594
5574
  class YAMLError extends Error {
5595
5575
  constructor(name, pos, code, message) {
5596
5576
  super();
@@ -5655,7 +5635,7 @@ ${pointer}
5655
5635
  });
5656
5636
 
5657
5637
  // node_modules/yaml/dist/compose/resolve-props.js
5658
- var require_resolve_props = __commonJS((exports) => {
5638
+ var require_resolve_props = __commonJS(function(exports) {
5659
5639
  function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
5660
5640
  let spaceBefore = false;
5661
5641
  let atNewline = startOnNewline;
@@ -5785,7 +5765,7 @@ var require_resolve_props = __commonJS((exports) => {
5785
5765
  });
5786
5766
 
5787
5767
  // node_modules/yaml/dist/compose/util-contains-newline.js
5788
- var require_util_contains_newline = __commonJS((exports) => {
5768
+ var require_util_contains_newline = __commonJS(function(exports) {
5789
5769
  function containsNewline(key) {
5790
5770
  if (!key)
5791
5771
  return null;
@@ -5825,7 +5805,7 @@ var require_util_contains_newline = __commonJS((exports) => {
5825
5805
  });
5826
5806
 
5827
5807
  // node_modules/yaml/dist/compose/util-flow-indent-check.js
5828
- var require_util_flow_indent_check = __commonJS((exports) => {
5808
+ var require_util_flow_indent_check = __commonJS(function(exports) {
5829
5809
  var utilContainsNewline = require_util_contains_newline();
5830
5810
  function flowIndentCheck(indent, fc, onError) {
5831
5811
  if (fc?.type === "flow-collection") {
@@ -5840,7 +5820,7 @@ var require_util_flow_indent_check = __commonJS((exports) => {
5840
5820
  });
5841
5821
 
5842
5822
  // node_modules/yaml/dist/compose/util-map-includes.js
5843
- var require_util_map_includes = __commonJS((exports) => {
5823
+ var require_util_map_includes = __commonJS(function(exports) {
5844
5824
  var identity = require_identity();
5845
5825
  function mapIncludes(ctx, items, search) {
5846
5826
  const { uniqueKeys } = ctx.options;
@@ -5853,7 +5833,7 @@ var require_util_map_includes = __commonJS((exports) => {
5853
5833
  });
5854
5834
 
5855
5835
  // node_modules/yaml/dist/compose/resolve-block-map.js
5856
- var require_resolve_block_map = __commonJS((exports) => {
5836
+ var require_resolve_block_map = __commonJS(function(exports) {
5857
5837
  var Pair = require_Pair();
5858
5838
  var YAMLMap = require_YAMLMap();
5859
5839
  var resolveProps = require_resolve_props();
@@ -5960,7 +5940,7 @@ var require_resolve_block_map = __commonJS((exports) => {
5960
5940
  });
5961
5941
 
5962
5942
  // node_modules/yaml/dist/compose/resolve-block-seq.js
5963
- var require_resolve_block_seq = __commonJS((exports) => {
5943
+ var require_resolve_block_seq = __commonJS(function(exports) {
5964
5944
  var YAMLSeq = require_YAMLSeq();
5965
5945
  var resolveProps = require_resolve_props();
5966
5946
  var utilFlowIndentCheck = require_util_flow_indent_check();
@@ -6008,7 +5988,7 @@ var require_resolve_block_seq = __commonJS((exports) => {
6008
5988
  });
6009
5989
 
6010
5990
  // node_modules/yaml/dist/compose/resolve-end.js
6011
- var require_resolve_end = __commonJS((exports) => {
5991
+ var require_resolve_end = __commonJS(function(exports) {
6012
5992
  function resolveEnd(end, offset, reqSpace, onError) {
6013
5993
  let comment = "";
6014
5994
  if (end) {
@@ -6048,7 +6028,7 @@ var require_resolve_end = __commonJS((exports) => {
6048
6028
  });
6049
6029
 
6050
6030
  // node_modules/yaml/dist/compose/resolve-flow-collection.js
6051
- var require_resolve_flow_collection = __commonJS((exports) => {
6031
+ var require_resolve_flow_collection = __commonJS(function(exports) {
6052
6032
  var identity = require_identity();
6053
6033
  var Pair = require_Pair();
6054
6034
  var YAMLMap = require_YAMLMap();
@@ -6239,7 +6219,7 @@ var require_resolve_flow_collection = __commonJS((exports) => {
6239
6219
  });
6240
6220
 
6241
6221
  // node_modules/yaml/dist/compose/compose-collection.js
6242
- var require_compose_collection = __commonJS((exports) => {
6222
+ var require_compose_collection = __commonJS(function(exports) {
6243
6223
  var identity = require_identity();
6244
6224
  var Scalar = require_Scalar();
6245
6225
  var YAMLMap = require_YAMLMap();
@@ -6301,7 +6281,7 @@ var require_compose_collection = __commonJS((exports) => {
6301
6281
  });
6302
6282
 
6303
6283
  // node_modules/yaml/dist/compose/resolve-block-scalar.js
6304
- var require_resolve_block_scalar = __commonJS((exports) => {
6284
+ var require_resolve_block_scalar = __commonJS(function(exports) {
6305
6285
  var Scalar = require_Scalar();
6306
6286
  function resolveBlockScalar(ctx, scalar, onError) {
6307
6287
  const start = scalar.offset;
@@ -6319,12 +6299,12 @@ var require_resolve_block_scalar = __commonJS((exports) => {
6319
6299
  break;
6320
6300
  }
6321
6301
  if (chompStart === 0) {
6322
- const value2 = header.chomp === "+" && lines.length > 0 ? `
6302
+ const value = header.chomp === "+" && lines.length > 0 ? `
6323
6303
  `.repeat(Math.max(1, lines.length - 1)) : "";
6324
- let end2 = start + header.length;
6304
+ let end = start + header.length;
6325
6305
  if (scalar.source)
6326
- end2 += scalar.source.length;
6327
- return { value: value2, type, comment: header.comment, range: [start, end2, end2] };
6306
+ end += scalar.source.length;
6307
+ return { value, type, comment: header.comment, range: [start, end, end] };
6328
6308
  }
6329
6309
  let trimIndent = scalar.indent + header.indent;
6330
6310
  let offset = scalar.offset + header.length;
@@ -6494,7 +6474,7 @@ var require_resolve_block_scalar = __commonJS((exports) => {
6494
6474
  });
6495
6475
 
6496
6476
  // node_modules/yaml/dist/compose/resolve-flow-scalar.js
6497
- var require_resolve_flow_scalar = __commonJS((exports) => {
6477
+ var require_resolve_flow_scalar = __commonJS(function(exports) {
6498
6478
  var Scalar = require_Scalar();
6499
6479
  var resolveEnd = require_resolve_end();
6500
6480
  function resolveFlowScalar(scalar, strict, onError) {
@@ -6710,7 +6690,7 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
6710
6690
  });
6711
6691
 
6712
6692
  // node_modules/yaml/dist/compose/compose-scalar.js
6713
- var require_compose_scalar = __commonJS((exports) => {
6693
+ var require_compose_scalar = __commonJS(function(exports) {
6714
6694
  var identity = require_identity();
6715
6695
  var Scalar = require_Scalar();
6716
6696
  var resolveBlockScalar = require_resolve_block_scalar();
@@ -6772,9 +6752,9 @@ var require_compose_scalar = __commonJS((exports) => {
6772
6752
  return schema[identity.SCALAR];
6773
6753
  }
6774
6754
  function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
6775
- const tag = schema.tags.find((tag2) => (tag2.default === true || atKey && tag2.default === "key") && tag2.test?.test(value)) || schema[identity.SCALAR];
6755
+ const tag = schema.tags.find((tag) => (tag.default === true || atKey && tag.default === "key") && tag.test?.test(value)) || schema[identity.SCALAR];
6776
6756
  if (schema.compat) {
6777
- const compat = schema.compat.find((tag2) => tag2.default && tag2.test?.test(value)) ?? schema[identity.SCALAR];
6757
+ const compat = schema.compat.find((tag) => tag.default && tag.test?.test(value)) ?? schema[identity.SCALAR];
6778
6758
  if (tag.tag !== compat.tag) {
6779
6759
  const ts = directives.tagString(tag.tag);
6780
6760
  const cs = directives.tagString(compat.tag);
@@ -6788,7 +6768,7 @@ var require_compose_scalar = __commonJS((exports) => {
6788
6768
  });
6789
6769
 
6790
6770
  // node_modules/yaml/dist/compose/util-empty-scalar-position.js
6791
- var require_util_empty_scalar_position = __commonJS((exports) => {
6771
+ var require_util_empty_scalar_position = __commonJS(function(exports) {
6792
6772
  function emptyScalarPosition(offset, before, pos) {
6793
6773
  if (before) {
6794
6774
  pos ?? (pos = before.length);
@@ -6815,7 +6795,7 @@ var require_util_empty_scalar_position = __commonJS((exports) => {
6815
6795
  });
6816
6796
 
6817
6797
  // node_modules/yaml/dist/compose/compose-node.js
6818
- var require_compose_node = __commonJS((exports) => {
6798
+ var require_compose_node = __commonJS(function(exports) {
6819
6799
  var Alias = require_Alias();
6820
6800
  var identity = require_identity();
6821
6801
  var composeCollection = require_compose_collection();
@@ -6845,22 +6825,17 @@ var require_compose_node = __commonJS((exports) => {
6845
6825
  case "block-map":
6846
6826
  case "block-seq":
6847
6827
  case "flow-collection":
6848
- try {
6849
- node = composeCollection.composeCollection(CN, ctx, token, props, onError);
6850
- if (anchor)
6851
- node.anchor = anchor.source.substring(1);
6852
- } catch (error) {
6853
- const message = error instanceof Error ? error.message : String(error);
6854
- onError(token, "RESOURCE_EXHAUSTION", message);
6855
- }
6828
+ node = composeCollection.composeCollection(CN, ctx, token, props, onError);
6829
+ if (anchor)
6830
+ node.anchor = anchor.source.substring(1);
6856
6831
  break;
6857
6832
  default: {
6858
6833
  const message = token.type === "error" ? token.message : `Unsupported token (type: ${token.type})`;
6859
6834
  onError(token, "UNEXPECTED_TOKEN", message);
6835
+ node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError);
6860
6836
  isSrcToken = false;
6861
6837
  }
6862
6838
  }
6863
- node ?? (node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError));
6864
6839
  if (anchor && node.anchor === "")
6865
6840
  onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
6866
6841
  if (atKey && ctx.options.stringKeys && (!identity.isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) {
@@ -6918,7 +6893,7 @@ var require_compose_node = __commonJS((exports) => {
6918
6893
  });
6919
6894
 
6920
6895
  // node_modules/yaml/dist/compose/compose-doc.js
6921
- var require_compose_doc = __commonJS((exports) => {
6896
+ var require_compose_doc = __commonJS(function(exports) {
6922
6897
  var Document = require_Document();
6923
6898
  var composeNode = require_compose_node();
6924
6899
  var resolveEnd = require_resolve_end();
@@ -6958,7 +6933,7 @@ var require_compose_doc = __commonJS((exports) => {
6958
6933
  });
6959
6934
 
6960
6935
  // node_modules/yaml/dist/compose/composer.js
6961
- var require_composer = __commonJS((exports) => {
6936
+ var require_composer = __commonJS(function(exports) {
6962
6937
  var node_process = __require("process");
6963
6938
  var directives = require_directives();
6964
6939
  var Document = require_Document();
@@ -7147,7 +7122,7 @@ ${end.comment}` : end.comment;
7147
7122
  });
7148
7123
 
7149
7124
  // node_modules/yaml/dist/parse/cst-scalar.js
7150
- var require_cst_scalar = __commonJS((exports) => {
7125
+ var require_cst_scalar = __commonJS(function(exports) {
7151
7126
  var resolveBlockScalar = require_resolve_block_scalar();
7152
7127
  var resolveFlowScalar = require_resolve_flow_scalar();
7153
7128
  var errors = require_errors();
@@ -7337,7 +7312,7 @@ var require_cst_scalar = __commonJS((exports) => {
7337
7312
  });
7338
7313
 
7339
7314
  // node_modules/yaml/dist/parse/cst-stringify.js
7340
- var require_cst_stringify = __commonJS((exports) => {
7315
+ var require_cst_stringify = __commonJS(function(exports) {
7341
7316
  var stringify = (cst) => ("type" in cst) ? stringifyToken(cst) : stringifyItem(cst);
7342
7317
  function stringifyToken(token) {
7343
7318
  switch (token.type) {
@@ -7395,7 +7370,7 @@ var require_cst_stringify = __commonJS((exports) => {
7395
7370
  });
7396
7371
 
7397
7372
  // node_modules/yaml/dist/parse/cst-visit.js
7398
- var require_cst_visit = __commonJS((exports) => {
7373
+ var require_cst_visit = __commonJS(function(exports) {
7399
7374
  var BREAK = Symbol("break visit");
7400
7375
  var SKIP = Symbol("skip children");
7401
7376
  var REMOVE = Symbol("remove item");
@@ -7454,7 +7429,7 @@ var require_cst_visit = __commonJS((exports) => {
7454
7429
  });
7455
7430
 
7456
7431
  // node_modules/yaml/dist/parse/cst.js
7457
- var require_cst = __commonJS((exports) => {
7432
+ var require_cst = __commonJS(function(exports) {
7458
7433
  var cstScalar = require_cst_scalar();
7459
7434
  var cstStringify = require_cst_stringify();
7460
7435
  var cstVisit = require_cst_visit();
@@ -7555,7 +7530,7 @@ var require_cst = __commonJS((exports) => {
7555
7530
  });
7556
7531
 
7557
7532
  // node_modules/yaml/dist/parse/lexer.js
7558
- var require_lexer = __commonJS((exports) => {
7533
+ var require_lexer = __commonJS(function(exports) {
7559
7534
  var cst = require_cst();
7560
7535
  function isEmpty(ch) {
7561
7536
  switch (ch) {
@@ -7928,18 +7903,18 @@ var require_lexer = __commonJS((exports) => {
7928
7903
  let indent = 0;
7929
7904
  let ch;
7930
7905
  loop:
7931
- for (let i2 = this.pos;ch = this.buffer[i2]; ++i2) {
7906
+ for (let i = this.pos;ch = this.buffer[i]; ++i) {
7932
7907
  switch (ch) {
7933
7908
  case " ":
7934
7909
  indent += 1;
7935
7910
  break;
7936
7911
  case `
7937
7912
  `:
7938
- nl = i2;
7913
+ nl = i;
7939
7914
  indent = 0;
7940
7915
  break;
7941
7916
  case "\r": {
7942
- const next = this.buffer[i2 + 1];
7917
+ const next = this.buffer[i + 1];
7943
7918
  if (!next && !this.atEnd)
7944
7919
  return this.setNext("block-scalar");
7945
7920
  if (next === `
@@ -7982,16 +7957,16 @@ var require_lexer = __commonJS((exports) => {
7982
7957
  nl = i - 1;
7983
7958
  } else if (!this.blockScalarKeep) {
7984
7959
  do {
7985
- let i2 = nl - 1;
7986
- let ch2 = this.buffer[i2];
7987
- if (ch2 === "\r")
7988
- ch2 = this.buffer[--i2];
7989
- const lastChar = i2;
7990
- while (ch2 === " ")
7991
- ch2 = this.buffer[--i2];
7992
- if (ch2 === `
7993
- ` && i2 >= this.pos && i2 + 1 + indent > lastChar)
7994
- nl = i2;
7960
+ let i = nl - 1;
7961
+ let ch = this.buffer[i];
7962
+ if (ch === "\r")
7963
+ ch = this.buffer[--i];
7964
+ const lastChar = i;
7965
+ while (ch === " ")
7966
+ ch = this.buffer[--i];
7967
+ if (ch === `
7968
+ ` && i >= this.pos && i + 1 + indent > lastChar)
7969
+ nl = i;
7995
7970
  else
7996
7971
  break;
7997
7972
  } while (true);
@@ -8141,7 +8116,7 @@ var require_lexer = __commonJS((exports) => {
8141
8116
  });
8142
8117
 
8143
8118
  // node_modules/yaml/dist/parse/line-counter.js
8144
- var require_line_counter = __commonJS((exports) => {
8119
+ var require_line_counter = __commonJS(function(exports) {
8145
8120
  class LineCounter {
8146
8121
  constructor() {
8147
8122
  this.lineStarts = [];
@@ -8169,7 +8144,7 @@ var require_line_counter = __commonJS((exports) => {
8169
8144
  });
8170
8145
 
8171
8146
  // node_modules/yaml/dist/parse/parser.js
8172
- var require_parser = __commonJS((exports) => {
8147
+ var require_parser = __commonJS(function(exports) {
8173
8148
  var node_process = __require("process");
8174
8149
  var cst = require_cst();
8175
8150
  var lexer = require_lexer();
@@ -8660,12 +8635,12 @@ var require_parser = __commonJS((exports) => {
8660
8635
  if (includesToken(it.start, "newline")) {
8661
8636
  Object.assign(it, { key: null, sep: [this.sourceToken] });
8662
8637
  } else {
8663
- const start2 = getFirstKeyStartProps(it.start);
8638
+ const start = getFirstKeyStartProps(it.start);
8664
8639
  this.stack.push({
8665
8640
  type: "block-map",
8666
8641
  offset: this.offset,
8667
8642
  indent: this.indent,
8668
- items: [{ start: start2, key: null, sep: [this.sourceToken] }]
8643
+ items: [{ start, key: null, sep: [this.sourceToken] }]
8669
8644
  });
8670
8645
  }
8671
8646
  } else if (it.value) {
@@ -8678,7 +8653,7 @@ var require_parser = __commonJS((exports) => {
8678
8653
  items: [{ start, key: null, sep: [this.sourceToken] }]
8679
8654
  });
8680
8655
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
8681
- const start2 = getFirstKeyStartProps(it.start);
8656
+ const start = getFirstKeyStartProps(it.start);
8682
8657
  const key = it.key;
8683
8658
  const sep = it.sep;
8684
8659
  sep.push(this.sourceToken);
@@ -8688,7 +8663,7 @@ var require_parser = __commonJS((exports) => {
8688
8663
  type: "block-map",
8689
8664
  offset: this.offset,
8690
8665
  indent: this.indent,
8691
- items: [{ start: start2, key, sep }]
8666
+ items: [{ start, key, sep }]
8692
8667
  });
8693
8668
  } else if (start.length > 0) {
8694
8669
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -9018,7 +8993,7 @@ var require_parser = __commonJS((exports) => {
9018
8993
  });
9019
8994
 
9020
8995
  // node_modules/yaml/dist/public-api.js
9021
- var require_public_api = __commonJS((exports) => {
8996
+ var require_public_api = __commonJS(function(exports) {
9022
8997
  var composer = require_composer();
9023
8998
  var Document = require_Document();
9024
8999
  var errors = require_errors();
@@ -9032,22 +9007,22 @@ var require_public_api = __commonJS((exports) => {
9032
9007
  return { lineCounter: lineCounter$1, prettyErrors };
9033
9008
  }
9034
9009
  function parseAllDocuments(source, options = {}) {
9035
- const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
9036
- const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
9010
+ const { lineCounter, prettyErrors } = parseOptions(options);
9011
+ const parser$1 = new parser.Parser(lineCounter?.addNewLine);
9037
9012
  const composer$1 = new composer.Composer(options);
9038
9013
  const docs = Array.from(composer$1.compose(parser$1.parse(source)));
9039
- if (prettyErrors && lineCounter2)
9014
+ if (prettyErrors && lineCounter)
9040
9015
  for (const doc of docs) {
9041
- doc.errors.forEach(errors.prettifyError(source, lineCounter2));
9042
- doc.warnings.forEach(errors.prettifyError(source, lineCounter2));
9016
+ doc.errors.forEach(errors.prettifyError(source, lineCounter));
9017
+ doc.warnings.forEach(errors.prettifyError(source, lineCounter));
9043
9018
  }
9044
9019
  if (docs.length > 0)
9045
9020
  return docs;
9046
9021
  return Object.assign([], { empty: true }, composer$1.streamInfo());
9047
9022
  }
9048
9023
  function parseDocument(source, options = {}) {
9049
- const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
9050
- const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
9024
+ const { lineCounter, prettyErrors } = parseOptions(options);
9025
+ const parser$1 = new parser.Parser(lineCounter?.addNewLine);
9051
9026
  const composer$1 = new composer.Composer(options);
9052
9027
  let doc = null;
9053
9028
  for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
@@ -9058,9 +9033,9 @@ var require_public_api = __commonJS((exports) => {
9058
9033
  break;
9059
9034
  }
9060
9035
  }
9061
- if (prettyErrors && lineCounter2) {
9062
- doc.errors.forEach(errors.prettifyError(source, lineCounter2));
9063
- doc.warnings.forEach(errors.prettifyError(source, lineCounter2));
9036
+ if (prettyErrors && lineCounter) {
9037
+ doc.errors.forEach(errors.prettifyError(source, lineCounter));
9038
+ doc.warnings.forEach(errors.prettifyError(source, lineCounter));
9064
9039
  }
9065
9040
  return doc;
9066
9041
  }
@@ -9407,27 +9382,27 @@ async function* parseGenericSSE(body) {
9407
9382
  for (const rawLine of lines) {
9408
9383
  const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
9409
9384
  if (line === "") {
9410
- const evt2 = flush();
9411
- if (evt2)
9412
- yield evt2;
9385
+ const evt = flush();
9386
+ if (evt)
9387
+ yield evt;
9413
9388
  continue;
9414
9389
  }
9415
9390
  if (line.startsWith(":"))
9416
9391
  continue;
9417
9392
  const colon = line.indexOf(":");
9418
9393
  const field = colon === -1 ? line : line.slice(0, colon);
9419
- let value2 = colon === -1 ? "" : line.slice(colon + 1);
9420
- if (value2.startsWith(" "))
9421
- value2 = value2.slice(1);
9394
+ let value = colon === -1 ? "" : line.slice(colon + 1);
9395
+ if (value.startsWith(" "))
9396
+ value = value.slice(1);
9422
9397
  switch (field) {
9423
9398
  case "event":
9424
- event = value2;
9399
+ event = value;
9425
9400
  break;
9426
9401
  case "data":
9427
- dataLines.push(value2);
9402
+ dataLines.push(value);
9428
9403
  break;
9429
9404
  case "id":
9430
- id = value2;
9405
+ id = value;
9431
9406
  break;
9432
9407
  }
9433
9408
  }
@@ -9440,41 +9415,15 @@ async function* parseGenericSSE(body) {
9440
9415
  }
9441
9416
  }
9442
9417
  async function* parseSSEStream(body) {
9443
- const reader = body.getReader();
9444
- const decoder = new TextDecoder;
9445
- let buffer = "";
9446
- try {
9447
- while (true) {
9448
- const { done, value } = await reader.read();
9449
- if (done)
9450
- break;
9451
- buffer += decoder.decode(value, { stream: true });
9452
- const lines = buffer.split(`
9453
- `);
9454
- buffer = lines.pop();
9455
- for (const line of lines) {
9456
- const trimmed = line.trim();
9457
- if (!trimmed || trimmed.startsWith(":"))
9458
- continue;
9459
- if (trimmed.startsWith("data: ")) {
9460
- const data = trimmed.slice(6);
9461
- const event = parseDataLine(data);
9462
- if (event) {
9463
- yield event;
9464
- if (event.type === "done" || event.type === "error")
9465
- return;
9466
- }
9467
- }
9468
- }
9469
- }
9470
- if (buffer.trim().startsWith("data: ")) {
9471
- const data = buffer.trim().slice(6);
9472
- const event = parseDataLine(data);
9473
- if (event)
9474
- yield event;
9418
+ for await (const sse of parseGenericSSE(body)) {
9419
+ if (sse.event && sse.event !== "message")
9420
+ continue;
9421
+ const event = parseDataLine(sse.data);
9422
+ if (event) {
9423
+ yield event;
9424
+ if (event.type === "done" || event.type === "error")
9425
+ return;
9475
9426
  }
9476
- } finally {
9477
- reader.releaseLock();
9478
9427
  }
9479
9428
  }
9480
9429
  function parseDataLine(data) {
@@ -9501,6 +9450,12 @@ function parseDataLine(data) {
9501
9450
  if (obj.type === "clear") {
9502
9451
  return { type: "clear", data: "" };
9503
9452
  }
9453
+ if (obj.type === "handover_placeholder") {
9454
+ return { type: "token", data: String(obj.message ?? "") };
9455
+ }
9456
+ if (obj.type === "agent_progress" || obj.type === "widget") {
9457
+ return null;
9458
+ }
9504
9459
  if (obj.type === "done") {
9505
9460
  return {
9506
9461
  type: "done",
@@ -9521,7 +9476,6 @@ function parseDataLine(data) {
9521
9476
  // src/lib/api-client.ts
9522
9477
  var exports_api_client = {};
9523
9478
  __export(exports_api_client, {
9524
- sameHostRedirect: () => sameHostRedirect,
9525
9479
  MarthaAPIClient: () => MarthaAPIClient
9526
9480
  });
9527
9481
  import fs3 from "node:fs";
@@ -9563,11 +9517,22 @@ class MarthaAPIClient {
9563
9517
  getAccessToken;
9564
9518
  defaultTimeout;
9565
9519
  verbose;
9520
+ tenantFor;
9566
9521
  constructor(config) {
9567
9522
  this.baseUrl = config.baseUrl.replace(/\/+$/, "");
9568
9523
  this.getAccessToken = config.getAccessToken;
9569
9524
  this.defaultTimeout = config.timeout ?? 30000;
9570
9525
  this.verbose = config.verbose ?? false;
9526
+ this.tenantFor = config.tenantFor ?? (() => {
9527
+ return;
9528
+ });
9529
+ }
9530
+ authHeaders(token) {
9531
+ const tenant = this.tenantFor(token);
9532
+ return {
9533
+ Authorization: `Bearer ${token}`,
9534
+ ...tenant ? { "X-Martha-Tenant": tenant } : {}
9535
+ };
9571
9536
  }
9572
9537
  log(msg) {
9573
9538
  if (this.verbose)
@@ -9595,24 +9560,24 @@ class MarthaAPIClient {
9595
9560
  }
9596
9561
  return res;
9597
9562
  }
9598
- async get(path3, opts) {
9599
- return this.request("GET", path3, opts);
9563
+ async get(path, opts) {
9564
+ return this.request("GET", path, opts);
9600
9565
  }
9601
- async post(path3, body, opts) {
9602
- return this.request("POST", path3, { ...opts, body });
9566
+ async post(path, body, opts) {
9567
+ return this.request("POST", path, { ...opts, body });
9603
9568
  }
9604
- async put(path3, body, opts) {
9605
- return this.request("PUT", path3, { ...opts, body });
9569
+ async put(path, body, opts) {
9570
+ return this.request("PUT", path, { ...opts, body });
9606
9571
  }
9607
- async patch(path3, body, opts) {
9608
- return this.request("PATCH", path3, { ...opts, body });
9572
+ async patch(path, body, opts) {
9573
+ return this.request("PATCH", path, { ...opts, body });
9609
9574
  }
9610
- async del(path3, opts) {
9611
- return this.request("DELETE", path3, opts);
9575
+ async del(path, opts) {
9576
+ return this.request("DELETE", path, opts);
9612
9577
  }
9613
- async upload(path3, filePath, opts) {
9578
+ async upload(path, filePath, opts) {
9614
9579
  const token = await this.getAccessToken();
9615
- const url = this.buildUrl(path3, opts?.params);
9580
+ const url = this.buildUrl(path, opts?.params);
9616
9581
  const timeout = opts?.timeout ?? 120000;
9617
9582
  const fileBuffer = fs3.readFileSync(filePath);
9618
9583
  const fileName = nodePath.basename(filePath);
@@ -9625,7 +9590,7 @@ class MarthaAPIClient {
9625
9590
  res = await this.fetchSameHost(url, {
9626
9591
  method: "POST",
9627
9592
  headers: {
9628
- Authorization: `Bearer ${token}`,
9593
+ ...this.authHeaders(token),
9629
9594
  ...opts?.headers
9630
9595
  },
9631
9596
  body: formData,
@@ -9646,16 +9611,16 @@ class MarthaAPIClient {
9646
9611
  }
9647
9612
  return await res.json();
9648
9613
  }
9649
- async getRaw(path3, opts) {
9614
+ async getRaw(path, opts) {
9650
9615
  const token = await this.getAccessToken();
9651
- const url = this.buildUrl(path3, opts?.params);
9616
+ const url = this.buildUrl(path, opts?.params);
9652
9617
  const timeout = opts?.timeout ?? this.defaultTimeout;
9653
9618
  let res;
9654
9619
  try {
9655
9620
  res = await this.fetchSameHost(url, {
9656
9621
  method: "GET",
9657
9622
  headers: {
9658
- Authorization: `Bearer ${token}`,
9623
+ ...this.authHeaders(token),
9659
9624
  ...opts?.headers
9660
9625
  },
9661
9626
  signal: opts?.signal ?? AbortSignal.timeout(timeout)
@@ -9675,16 +9640,16 @@ class MarthaAPIClient {
9675
9640
  }
9676
9641
  return res;
9677
9642
  }
9678
- async postRaw(path3, body, opts) {
9643
+ async postRaw(path, body, opts) {
9679
9644
  const token = await this.getAccessToken();
9680
- const url = this.buildUrl(path3, opts?.params);
9645
+ const url = this.buildUrl(path, opts?.params);
9681
9646
  const timeout = opts?.timeout ?? 120000;
9682
9647
  let res;
9683
9648
  try {
9684
9649
  res = await this.fetchSameHost(url, {
9685
9650
  method: "POST",
9686
9651
  headers: {
9687
- Authorization: `Bearer ${token}`,
9652
+ ...this.authHeaders(token),
9688
9653
  "Content-Type": "application/json",
9689
9654
  ...opts?.headers
9690
9655
  },
@@ -9706,14 +9671,14 @@ class MarthaAPIClient {
9706
9671
  }
9707
9672
  return res;
9708
9673
  }
9709
- async* streamSSE(path3, body, opts) {
9674
+ async* streamSSE(path, body, opts) {
9710
9675
  const token = await this.getAccessToken();
9711
- const url = this.buildUrl(path3, opts?.params);
9676
+ const url = this.buildUrl(path, opts?.params);
9712
9677
  const timeout = opts?.timeout ?? 120000;
9713
9678
  const res = await this.fetchSameHost(url, {
9714
9679
  method: "POST",
9715
9680
  headers: {
9716
- Authorization: `Bearer ${token}`,
9681
+ ...this.authHeaders(token),
9717
9682
  "Content-Type": "application/json",
9718
9683
  ...opts?.headers
9719
9684
  },
@@ -9729,12 +9694,12 @@ class MarthaAPIClient {
9729
9694
  }
9730
9695
  yield* parseSSEStream(res.body);
9731
9696
  }
9732
- async request(method, path3, opts) {
9733
- const url = this.buildUrl(path3, opts?.params);
9697
+ async request(method, path, opts) {
9698
+ const url = this.buildUrl(path, opts?.params);
9734
9699
  const timeout = opts?.timeout ?? this.defaultTimeout;
9735
- const attempt = async (token2) => {
9700
+ const attempt = async (token) => {
9736
9701
  const headers = {
9737
- Authorization: `Bearer ${token2}`,
9702
+ ...this.authHeaders(token),
9738
9703
  ...opts?.headers
9739
9704
  };
9740
9705
  if (opts?.body !== undefined) {
@@ -9779,11 +9744,11 @@ class MarthaAPIClient {
9779
9744
  return;
9780
9745
  return await res.json();
9781
9746
  }
9782
- buildUrl(path3, params) {
9783
- if (/^(https?:)?\/\//i.test(path3)) {
9747
+ buildUrl(path, params) {
9748
+ if (/^(https?:)?\/\//i.test(path)) {
9784
9749
  throw new CLIError("Absolute URL paths are not allowed", 1 /* Error */);
9785
9750
  }
9786
- const url = new URL(path3, this.baseUrl);
9751
+ const url = new URL(path, this.baseUrl);
9787
9752
  if (params) {
9788
9753
  for (const [key, value] of Object.entries(params)) {
9789
9754
  url.searchParams.set(key, value);
@@ -9816,21 +9781,64 @@ var init_api_client = __esm(() => {
9816
9781
  };
9817
9782
  });
9818
9783
 
9784
+ // node_modules/commander/index.js
9785
+ var exports_commander = {};
9786
+ __exportCjs(exports_commander, {
9787
+ program: () => $program,
9788
+ createCommand: () => $createCommand,
9789
+ createOption: () => $createOption,
9790
+ createArgument: () => $createArgument,
9791
+ Command: () => $Command,
9792
+ Option: () => $Option,
9793
+ Argument: () => $Argument,
9794
+ Help: () => $Help,
9795
+ CommanderError: () => $CommanderError,
9796
+ InvalidArgumentError: () => $InvalidArgumentError,
9797
+ InvalidOptionArgumentError: () => $InvalidOptionArgumentError
9798
+ }, {
9799
+ program: (value) => $program = value,
9800
+ createCommand: (value) => $createCommand = value,
9801
+ createOption: (value) => $createOption = value,
9802
+ createArgument: (value) => $createArgument = value,
9803
+ Command: (value) => $Command = value,
9804
+ Option: (value) => $Option = value,
9805
+ Argument: (value) => $Argument = value,
9806
+ Help: (value) => $Help = value,
9807
+ CommanderError: (value) => $CommanderError = value,
9808
+ InvalidArgumentError: (value) => $InvalidArgumentError = value,
9809
+ InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
9810
+ });
9811
+ var { Argument } = require_argument();
9812
+ var { Command } = require_command();
9813
+ var { CommanderError, InvalidArgumentError } = require_error();
9814
+ var { Help } = require_help();
9815
+ var { Option } = require_option();
9816
+ var $program = new Command;
9817
+ var $createCommand = (name) => new Command(name);
9818
+ var $createOption = (flags, description) => new Option(flags, description);
9819
+ var $createArgument = (name, description) => new Argument(name, description);
9820
+ var $Command = Command;
9821
+ var $Option = Option;
9822
+ var $Argument = Argument;
9823
+ var $Help = Help;
9824
+ var $CommanderError = CommanderError;
9825
+ var $InvalidArgumentError = InvalidArgumentError;
9826
+ var $InvalidOptionArgumentError = InvalidArgumentError;
9827
+
9819
9828
  // node_modules/commander/esm.mjs
9820
- var import__ = __toESM(require_commander(), 1);
9821
9829
  var {
9822
9830
  program,
9823
9831
  createCommand,
9824
9832
  createArgument,
9825
9833
  createOption,
9826
- CommanderError,
9827
- InvalidArgumentError,
9834
+ CommanderError: CommanderError2,
9835
+ InvalidArgumentError: InvalidArgumentError2,
9828
9836
  InvalidOptionArgumentError,
9829
- Command,
9830
- Argument,
9831
- Option,
9832
- Help
9833
- } = import__.default;
9837
+ Command: Command2,
9838
+ Argument: Argument2,
9839
+ Option: Option2,
9840
+ Help: Help2
9841
+ } = exports_commander;
9834
9842
 
9835
9843
  // src/index.ts
9836
9844
  init_errors();
@@ -10379,9 +10387,9 @@ import { randomBytes, createHash } from "node:crypto";
10379
10387
  async function openBrowser(url) {
10380
10388
  const { execFile } = await import("node:child_process");
10381
10389
  const { platform } = await import("node:os");
10382
- const os3 = platform();
10390
+ const os = platform();
10383
10391
  return new Promise((resolve, reject) => {
10384
- if (os3 === "win32") {
10392
+ if (os === "win32") {
10385
10393
  execFile("cmd", ["/c", "start", "", url], (err) => {
10386
10394
  if (err)
10387
10395
  reject(err);
@@ -10389,7 +10397,7 @@ async function openBrowser(url) {
10389
10397
  resolve();
10390
10398
  });
10391
10399
  } else {
10392
- const cmd = os3 === "darwin" ? "open" : "xdg-open";
10400
+ const cmd = os === "darwin" ? "open" : "xdg-open";
10393
10401
  execFile(cmd, [url], (err) => {
10394
10402
  if (err)
10395
10403
  reject(err);
@@ -10797,6 +10805,21 @@ function belongsToClient(tokens, clientId) {
10797
10805
  const azp = claims?.azp ?? claims?.client_id;
10798
10806
  return azp ? azp === clientId : true;
10799
10807
  }
10808
+ var selection = {};
10809
+ var clean = (v) => typeof v === "string" && v.trim() ? v.trim() : undefined;
10810
+ function registerOrgSelection(program) {
10811
+ program.hook("preAction", (_root, action) => {
10812
+ const opts = action.optsWithGlobals();
10813
+ selection = { org: clean(opts.org), commandTenant: clean(opts.tenant) };
10814
+ });
10815
+ }
10816
+ function organizationsFromClaims(payload) {
10817
+ const orgs = payload.organizations;
10818
+ if (orgs && typeof orgs === "object" && !Array.isArray(orgs)) {
10819
+ return Object.keys(orgs);
10820
+ }
10821
+ return [];
10822
+ }
10800
10823
  function tenantFromClaims(payload) {
10801
10824
  const tid = payload.tenant_id;
10802
10825
  if (typeof tid === "string" && tid)
@@ -10831,43 +10854,59 @@ function createContext(opts) {
10831
10854
  return existing.access_token;
10832
10855
  }
10833
10856
  }
10834
- const { loginClientCredentials: loginClientCredentials2 } = await Promise.resolve().then(() => (init_client_credentials(), exports_client_credentials));
10835
- const tokens2 = await loginClientCredentials2({
10857
+ await Promise.resolve().then(() => init_client_credentials());
10858
+ const tokens = await loginClientCredentials({
10836
10859
  keycloakUrl: profile.keycloak_url,
10837
10860
  realm: profile.keycloak_realm,
10838
10861
  clientId,
10839
10862
  clientSecret
10840
10863
  });
10841
- tokenStore.saveTokens(profileName, tokens2);
10842
- return tokens2.access_token;
10864
+ tokenStore.saveTokens(profileName, tokens);
10865
+ return tokens.access_token;
10843
10866
  }
10844
10867
  if (!tokenStore.needsRefresh(profileName)) {
10845
- const tokens2 = tokenStore.getTokens(profileName);
10846
- if (tokens2)
10847
- return tokens2.access_token;
10868
+ const tokens = tokenStore.getTokens(profileName);
10869
+ if (tokens)
10870
+ return tokens.access_token;
10848
10871
  }
10849
10872
  const tokens = tokenStore.getTokens(profileName);
10850
10873
  if (tokens?.refresh_token && !tokenStore.isRefreshExpired(profileName)) {
10851
- const clientId2 = tokens.auth_type === "client_credentials" ? profile.client_id : "martha-cli";
10874
+ const clientId = tokens.auth_type === "client_credentials" ? profile.client_id : "martha-cli";
10852
10875
  const refreshed = await refreshAccessToken({
10853
10876
  keycloakUrl: profile.keycloak_url,
10854
10877
  realm: profile.keycloak_realm,
10855
10878
  refreshToken: tokens.refresh_token,
10856
- clientId: clientId2
10879
+ clientId
10857
10880
  });
10858
10881
  tokenStore.saveTokens(profileName, refreshed);
10859
10882
  return refreshed.access_token;
10860
10883
  }
10861
10884
  throw new CLIError("Not authenticated.", 2 /* Auth */, "Run `martha auth login` to authenticate.");
10862
10885
  };
10886
+ const explicitOrg = selection.org ?? clean(process.env.MARTHA_ORG);
10887
+ const { commandTenant } = selection;
10888
+ const tenantFor = (token) => {
10889
+ if (explicitOrg)
10890
+ return explicitOrg;
10891
+ if (commandTenant) {
10892
+ let orgs = [];
10893
+ try {
10894
+ orgs = organizationsFromClaims(decodeJwtPayload(token));
10895
+ } catch {}
10896
+ if (orgs.includes(commandTenant))
10897
+ return commandTenant;
10898
+ }
10899
+ return profile.org?.trim() || undefined;
10900
+ };
10863
10901
  const api = new MarthaAPIClient({
10864
10902
  baseUrl: profile.api_url,
10865
10903
  getAccessToken,
10866
- verbose: opts.verbose
10904
+ verbose: opts.verbose,
10905
+ tenantFor
10867
10906
  });
10868
10907
  const getTenantId = async () => {
10869
10908
  const token = await getAccessToken();
10870
- const tid = tenantFromClaims(decodeJwtPayload(token));
10909
+ const tid = tenantFor(token) ?? tenantFromClaims(decodeJwtPayload(token));
10871
10910
  if (!tid) {
10872
10911
  throw new CLIError("No tenant_id or organizations claim in access token.", 2 /* Auth */);
10873
10912
  }
@@ -10881,7 +10920,8 @@ function createContext(opts) {
10881
10920
  api,
10882
10921
  configDir: opts.configDir,
10883
10922
  getTenantId,
10884
- getAccessToken
10923
+ getAccessToken,
10924
+ tenantFor
10885
10925
  };
10886
10926
  }
10887
10927
 
@@ -10974,20 +11014,20 @@ init_errors();
10974
11014
  function an(word) {
10975
11015
  return /^[aeiou]/i.test(word) ? `an ${word}` : `a ${word}`;
10976
11016
  }
10977
- function registerDefinitionCommands(program2, config) {
10978
- const cmd = program2.command(config.typeNamePlural).description(`Manage ${config.typeName} definitions`);
11017
+ function registerDefinitionCommands(program, config) {
11018
+ const cmd = program.command(config.typeNamePlural).description(`Manage ${config.typeName} definitions`);
10979
11019
  function getCtx() {
10980
11020
  const ctx = createContext({
10981
- profileOverride: program2.opts().profile,
10982
- verbose: program2.opts().verbose
11021
+ profileOverride: program.opts().profile,
11022
+ verbose: program.opts().verbose
10983
11023
  });
10984
- if (program2.opts().apiUrl) {
10985
- ctx.profile.api_url = program2.opts().apiUrl;
11024
+ if (program.opts().apiUrl) {
11025
+ ctx.profile.api_url = program.opts().apiUrl;
10986
11026
  }
10987
11027
  return ctx;
10988
11028
  }
10989
11029
  function isJson() {
10990
- return !!program2.opts().json;
11030
+ return !!program.opts().json;
10991
11031
  }
10992
11032
  const listCmd = cmd.command("list").description(`List ${config.typeNamePlural}`).option("--inactive", "Include inactive items").option("--limit <n>", "Max results per page", "50").option("--search <term>", "Case-insensitive substring filter on name (server-side)").option("--all", "Auto-paginate until every matching item is fetched (server caps at 500/page)");
10993
11033
  if (config.extraListOptions) {
@@ -11204,7 +11244,7 @@ init_config();
11204
11244
  init_errors();
11205
11245
 
11206
11246
  // src/version.ts
11207
- var CLI_VERSION = "0.61.1";
11247
+ var CLI_VERSION = "0.62.0";
11208
11248
 
11209
11249
  // src/commands/sessions.ts
11210
11250
  function relativeTime(iso) {
@@ -11279,20 +11319,20 @@ function printSessionTable(sessions) {
11279
11319
  }).join(" "));
11280
11320
  }
11281
11321
  }
11282
- function registerSessionCommands(program2) {
11283
- const cmd = program2.command("sessions").description("Browse conversation history");
11322
+ function registerSessionCommands(program) {
11323
+ const cmd = program.command("sessions").description("Browse conversation history");
11284
11324
  function getCtx() {
11285
11325
  const ctx = createContext({
11286
- profileOverride: program2.opts().profile,
11287
- verbose: program2.opts().verbose
11326
+ profileOverride: program.opts().profile,
11327
+ verbose: program.opts().verbose
11288
11328
  });
11289
- if (program2.opts().apiUrl) {
11290
- ctx.profile.api_url = program2.opts().apiUrl;
11329
+ if (program.opts().apiUrl) {
11330
+ ctx.profile.api_url = program.opts().apiUrl;
11291
11331
  }
11292
11332
  return ctx;
11293
11333
  }
11294
11334
  function isJson() {
11295
- return !!program2.opts().json;
11335
+ return !!program.opts().json;
11296
11336
  }
11297
11337
  cmd.command("list").description("List your conversation sessions").option("--search <text>", "Filter sessions by title").option("--limit <n>", "Max results (default: 20)", "20").option("--skip <n>", "Offset for pagination", "0").option("--type <type>", "Filter by session type (api, sms, whatsapp)").option("--include-archived", "Include archived sessions").action(async (opts) => {
11298
11338
  const ctx = getCtx();
@@ -11917,8 +11957,8 @@ Attach it as this agent's host executor:
11917
11957
  });
11918
11958
  parentCmd.command("revoke-runner <agent>").description("Revoke a host runner's live channel connection(s) without rotating the " + "key (#802). Drops the live stream within one heartbeat and flips the " + "agent offline. Default revokes ALL connections; --connection targets one.").option("--connection <id>", "Revoke only this connection_id (default: all of the agent's connections)").action(async (agent, opts) => {
11919
11959
  const ctx = getCtx();
11920
- const path4 = `${API_PATH}/${encodeURIComponent(agent)}/revoke-runner` + (opts.connection ? `?connection=${encodeURIComponent(opts.connection)}` : "");
11921
- const result = await ctx.api.post(path4, {});
11960
+ const path = `${API_PATH}/${encodeURIComponent(agent)}/revoke-runner` + (opts.connection ? `?connection=${encodeURIComponent(opts.connection)}` : "");
11961
+ const result = await ctx.api.post(path, {});
11922
11962
  if (isJson()) {
11923
11963
  console.log(JSON.stringify(result, null, 2));
11924
11964
  return;
@@ -12079,8 +12119,8 @@ Attach it as this agent's host executor:
12079
12119
  });
12080
12120
  parentCmd.command("self-grant <agent>").description("View or configure an agent's self-provisioning policy (request-then-approve). " + "With no flags, prints the current policy.").option("--enable", "Allow the agent to REQUEST capability grants").option("--disable", "Disallow self-provisioning").option("--scope <scope>", "Scope ceiling: none | read_only | read_write").option("--allow <ref...>", "Add allow-list refs (function:NAME or mcp:integration/name)").option("--remove <ref...>", "Remove allow-list refs").option("--collection-root <id...>", "Add collection-subtree roots the agent may self-grant collection-scoped functions into").option("--remove-collection-root <id...>", "Remove collection roots").option("--max-pending <n>", "Max concurrently-pending requests").action(async (agent, opts) => {
12081
12121
  const ctx = getCtx();
12082
- const path4 = `${API_PATH}/${encodeURIComponent(agent)}`;
12083
- const current = await ctx.api.get(path4);
12122
+ const path = `${API_PATH}/${encodeURIComponent(agent)}`;
12123
+ const current = await ctx.api.get(path);
12084
12124
  const mutating = opts.enable || opts.disable || opts.scope !== undefined || (opts.allow?.length ?? 0) > 0 || (opts.remove?.length ?? 0) > 0 || (opts.collectionRoot?.length ?? 0) > 0 || (opts.removeCollectionRoot?.length ?? 0) > 0 || opts.maxPending !== undefined;
12085
12125
  if (!mutating) {
12086
12126
  if (isJson()) {
@@ -12132,7 +12172,7 @@ Attach it as this agent's host executor:
12132
12172
  roots.delete(c);
12133
12173
  body.self_grant_collection_roots = [...roots];
12134
12174
  }
12135
- const updated = await ctx.api.put(path4, body);
12175
+ const updated = await ctx.api.put(path, body);
12136
12176
  if (isJson()) {
12137
12177
  console.log(JSON.stringify(policyView(updated), null, 2));
12138
12178
  return;
@@ -12817,10 +12857,10 @@ class BrowserSession {
12817
12857
  let chromium;
12818
12858
  const candidates = [];
12819
12859
  try {
12820
- const { createRequire: createRequire2 } = await import("node:module");
12860
+ const { createRequire } = await import("node:module");
12821
12861
  const { pathToFileURL } = await import("node:url");
12822
- const path5 = await import("node:path");
12823
- const req = createRequire2(pathToFileURL(path5.join(process.cwd(), "noop.js")));
12862
+ const path = await import("node:path");
12863
+ const req = createRequire(pathToFileURL(path.join(process.cwd(), "noop.js")));
12824
12864
  candidates.push(pathToFileURL(req.resolve(moduleName)).href);
12825
12865
  } catch {}
12826
12866
  candidates.push(moduleName);
@@ -13070,19 +13110,19 @@ async function dispatchBackgroundJob(command, jobId, journal, opts) {
13070
13110
  const sentinelPath = path6.join(dir, `${jobId}.exit`);
13071
13111
  await fs7.writeFile(logPath, "");
13072
13112
  const fd = openSync2(logPath, "a");
13073
- const env2 = { ...process.env, MARTHA_JOB_SENTINEL: sentinelPath };
13113
+ const env = { ...process.env, MARTHA_JOB_SENTINEL: sentinelPath };
13074
13114
  const stdin = opts.stdinData != null ? "pipe" : "ignore";
13075
13115
  const child = opts.argv ? spawn2("/bin/sh", ["-c", `"$@"${SENTINEL_TAIL}`, "martha-job", ...opts.argv], {
13076
13116
  shell: false,
13077
13117
  cwd: opts.cwd,
13078
13118
  detached: true,
13079
- env: env2,
13119
+ env,
13080
13120
  stdio: [stdin, fd, fd]
13081
13121
  }) : spawn2("/bin/sh", ["-c", `( ${command} )${SENTINEL_TAIL}`], {
13082
13122
  shell: false,
13083
13123
  cwd: opts.cwd,
13084
13124
  detached: true,
13085
- env: env2,
13125
+ env,
13086
13126
  stdio: [stdin, fd, fd]
13087
13127
  });
13088
13128
  closeSync2(fd);
@@ -13860,11 +13900,11 @@ function formatToolStatus(data) {
13860
13900
  }
13861
13901
  }
13862
13902
  function promptPick(rl, count) {
13863
- return new Promise((resolve2) => {
13903
+ return new Promise((resolve) => {
13864
13904
  rl.question(source_default.dim(`Pick 1-${count} (or Enter to cancel): `), (ans) => {
13865
13905
  const trimmed = ans.trim();
13866
13906
  if (!trimmed) {
13867
- resolve2(-1);
13907
+ resolve(-1);
13868
13908
  return;
13869
13909
  }
13870
13910
  const n = parseInt(trimmed, 10);
@@ -13872,10 +13912,10 @@ function promptPick(rl, count) {
13872
13912
  process.stderr.write(source_default.yellow(`Invalid choice.
13873
13913
 
13874
13914
  `));
13875
- resolve2(-1);
13915
+ resolve(-1);
13876
13916
  return;
13877
13917
  }
13878
- resolve2(n - 1);
13918
+ resolve(n - 1);
13879
13919
  });
13880
13920
  });
13881
13921
  }
@@ -14257,16 +14297,16 @@ async function runOneShot(ctx, sessionId, message, isJson, clientId, agentName,
14257
14297
  console.log(stripApprovalWidgetTags(response));
14258
14298
  }
14259
14299
  }
14260
- function registerChatCommand(program2) {
14261
- program2.command("chat").description("Chat with a Martha agent").option("--session <id>", "Resume an existing session").option("--client <nameOrId>", "Use a specific client (name or ID)").option("--agent <name>", "Drive the chat with a specific copilot agent (defaults to profile.default_agent)").option("--message <text>", "Send a single message (non-interactive)").option("--show-tools", "Show tool calls and results during chat").option("--local-exec", "Allow the agent to run host tools on THIS machine (#568). Requires the server to have LOCAL_EXEC_ENABLED=1.").option("--yes", "Auto-approve host tool execution (required with --local-exec for non-interactive runs).").option("--local-agent <name>", "Which local coding agent `local_agent` delegates to: a preset (claude | codex | cursor-agent) or a raw command. Overrides MARTHA_LOCAL_AGENT_CMD and `config local_agent` for this run.").option("--timeout <seconds>", "Per-message HTTP timeout in seconds (default: 600)").action(async (opts) => {
14300
+ function registerChatCommand(program) {
14301
+ program.command("chat").description("Chat with a Martha agent").option("--session <id>", "Resume an existing session").option("--client <nameOrId>", "Use a specific client (name or ID)").option("--agent <name>", "Drive the chat with a specific copilot agent (defaults to profile.default_agent)").option("--message <text>", "Send a single message (non-interactive)").option("--show-tools", "Show tool calls and results during chat").option("--local-exec", "Allow the agent to run host tools on THIS machine (#568). Requires the server to have LOCAL_EXEC_ENABLED=1.").option("--yes", "Auto-approve host tool execution (required with --local-exec for non-interactive runs).").option("--local-agent <name>", "Which local coding agent `local_agent` delegates to: a preset (claude | codex | cursor-agent) or a raw command. Overrides MARTHA_LOCAL_AGENT_CMD and `config local_agent` for this run.").option("--timeout <seconds>", "Per-message HTTP timeout in seconds (default: 600)").action(async (opts) => {
14262
14302
  const ctx = createContext({
14263
- profileOverride: program2.opts().profile,
14264
- verbose: program2.opts().verbose
14303
+ profileOverride: program.opts().profile,
14304
+ verbose: program.opts().verbose
14265
14305
  });
14266
- if (program2.opts().apiUrl) {
14267
- ctx.profile.api_url = program2.opts().apiUrl;
14306
+ if (program.opts().apiUrl) {
14307
+ ctx.profile.api_url = program.opts().apiUrl;
14268
14308
  }
14269
- const isJson = !!program2.opts().json;
14309
+ const isJson = !!program.opts().json;
14270
14310
  let clientId;
14271
14311
  if (opts.client) {
14272
14312
  const parsed = parseInt(opts.client, 10);
@@ -14388,9 +14428,9 @@ async function deliverToChannel(buzzBin, target, text) {
14388
14428
  const args = ["messages", "send", "--channel", target.channelId, "--content", text];
14389
14429
  if (target.threadRef)
14390
14430
  args.push("--reply-to", target.threadRef);
14391
- const send = () => new Promise((resolve2) => {
14431
+ const send = () => new Promise((resolve) => {
14392
14432
  execFile(buzzBin, args, { timeout: 20000, maxBuffer: 1024 * 1024 }, (err, stdout, stderr) => {
14393
- resolve2({
14433
+ resolve({
14394
14434
  ok: !err,
14395
14435
  out: stdout?.slice(0, 2000) ?? "",
14396
14436
  err: err ? `${err.message}
@@ -14422,9 +14462,9 @@ async function runAcpServer(ctx, input, output, opts) {
14422
14462
  const sessions = new Map;
14423
14463
  let writeChain = Promise.resolve();
14424
14464
  const writeLine = (msg) => {
14425
- writeChain = writeChain.then(() => new Promise((resolve2) => {
14465
+ writeChain = writeChain.then(() => new Promise((resolve) => {
14426
14466
  output.write(JSON.stringify(msg) + `
14427
- `, () => resolve2());
14467
+ `, () => resolve());
14428
14468
  }));
14429
14469
  return writeChain;
14430
14470
  };
@@ -14613,12 +14653,12 @@ async function probeStartup(ctx) {
14613
14653
  throw new CLIError(`ACP startup failed: cannot reach Martha API at ${ctx.profile.api_url}: ${message}`, 1 /* Error */, "Check the API URL (--api-url / profile) and that the Martha API is up.");
14614
14654
  }
14615
14655
  }
14616
- function registerAcpServeCommand(program2) {
14617
- program2.command("acp-serve").description("Serve the Agent Client Protocol over stdio (newline-delimited JSON-RPC 2.0) so an ACP harness like Buzz's buzz-acp can drive a Martha agent").option("--client <nameOrId>", "Use a specific client id for the Martha session").option("--agent <name>", "Drive turns with a specific Martha agent (defaults to the credential/profile binding)").option("--post-reply", "After each completed turn, post the final answer back to the triggering Buzz channel via the `buzz` CLI (parsed from the prompt's [Context] section)").option("--buzz-bin <path>", "Path to the buzz CLI for --post-reply", "buzz").option("--timeout <seconds>", "Per-prompt HTTP timeout in seconds (default: 600)").action(async (opts) => {
14656
+ function registerAcpServeCommand(program) {
14657
+ program.command("acp-serve").description("Serve the Agent Client Protocol over stdio (newline-delimited JSON-RPC 2.0) so an ACP harness like Buzz's buzz-acp can drive a Martha agent").option("--client <nameOrId>", "Use a specific client id for the Martha session").option("--agent <name>", "Drive turns with a specific Martha agent (defaults to the credential/profile binding)").option("--post-reply", "After each completed turn, post the final answer back to the triggering Buzz channel via the `buzz` CLI (parsed from the prompt's [Context] section)").option("--buzz-bin <path>", "Path to the buzz CLI for --post-reply", "buzz").option("--timeout <seconds>", "Per-prompt HTTP timeout in seconds (default: 600)").action(async (opts) => {
14618
14658
  const ctx = createContext({
14619
- profileOverride: program2.opts().profile,
14620
- apiUrlOverride: program2.opts().apiUrl,
14621
- verbose: program2.opts().verbose
14659
+ profileOverride: program.opts().profile,
14660
+ apiUrlOverride: program.opts().apiUrl,
14661
+ verbose: program.opts().verbose
14622
14662
  });
14623
14663
  const timeoutMs = opts.timeout ? Math.max(1, Number(opts.timeout)) * 1000 : undefined;
14624
14664
  logJson("info", "martha acp-serve starting", {
@@ -14770,15 +14810,15 @@ function printAgentPrincipalReady(r, savedProfile) {
14770
14810
  Then: buzz channels add-member --channel <id> --pubkey <agent pubkey> --role member
14771
14811
  ` + " and @mention the agent in the channel."));
14772
14812
  }
14773
- function registerPrincipalCommands(program2) {
14774
- const principals = program2.command("principals").description("Provision principals — who may act, with what credential (mirrors the API's principals/bootstrap)");
14813
+ function registerPrincipalCommands(program) {
14814
+ const principals = program.command("principals").description("Provision principals — who may act, with what credential (mirrors the API's principals/bootstrap)");
14775
14815
  principals.command("bootstrap").description("Provision a principal. --mode human: your run-as client (what `martha init` wraps). " + "--mode integration: headless service account. --mode agent: service account bound " + "to ONE Martha-hosted agent (chat takeover) so the credential acts as the agent — " + "the shape an external ACP driver (Buzz, Zed) needs.").requiredOption("--mode <mode>", "human | integration | agent").option("--agent <name>", "Agent to bind (agent mode)").option("--prompt <text>", "System prompt — creates the agent when it doesn't exist yet (agent mode)").option("--label <label>", "Label for the service-account client id (default: the agent name in agent mode)").option("--intents <list>", "Comma-separated tool intents to grant (rag, documents, workflows, tasks)").option("--collections <list>", "Comma-separated collections (name, slug or id) the agent may read. Intents grant the retrieval TOOLS; without this they return nothing").option("--save-profile <name>", "Save the minted credential as a Martha profile, so anything that runs as this agent needs only MARTHA_PROFILE=<name> — no secret to copy").action(async (opts) => {
14776
14816
  const ctx = createContext({
14777
- profileOverride: program2.opts().profile,
14778
- apiUrlOverride: program2.opts().apiUrl,
14779
- verbose: program2.opts().verbose
14817
+ profileOverride: program.opts().profile,
14818
+ apiUrlOverride: program.opts().apiUrl,
14819
+ verbose: program.opts().verbose
14780
14820
  });
14781
- const isJson = !!program2.opts().json;
14821
+ const isJson = !!program.opts().json;
14782
14822
  switch (opts.mode) {
14783
14823
  case "agent": {
14784
14824
  if (!opts.agent) {
@@ -14875,7 +14915,7 @@ function buzzHarnessDefinition(opts = {}) {
14875
14915
  function isValidHarnessId(id) {
14876
14916
  return /^[a-z0-9_][a-z0-9_-]*$/.test(id);
14877
14917
  }
14878
- function buzzAppDataCandidates(platform, env2, home) {
14918
+ function buzzAppDataCandidates(platform, env, home) {
14879
14919
  const ids = [
14880
14920
  { build: "release", id: "xyz.block.buzz.app" },
14881
14921
  { build: "dev", id: "xyz.block.buzz.app.dev" }
@@ -14884,8 +14924,8 @@ function buzzAppDataCandidates(platform, env2, home) {
14884
14924
  if (platform === "darwin")
14885
14925
  return join4(home, "Library", "Application Support");
14886
14926
  if (platform === "win32")
14887
- return env2.APPDATA ?? join4(home, "AppData", "Roaming");
14888
- return env2.XDG_DATA_HOME ?? join4(home, ".local", "share");
14927
+ return env.APPDATA ?? join4(home, "AppData", "Roaming");
14928
+ return env.XDG_DATA_HOME ?? join4(home, ".local", "share");
14889
14929
  };
14890
14930
  const root = base();
14891
14931
  return ids.map(({ build, id }) => ({ build, dir: join4(root, id) }));
@@ -14893,12 +14933,12 @@ function buzzAppDataCandidates(platform, env2, home) {
14893
14933
  function chooseAppDataDir(candidates, exists) {
14894
14934
  return candidates.find((c) => exists(c.dir)) ?? null;
14895
14935
  }
14896
- function buzzAppCandidates(platform, env2, home) {
14936
+ function buzzAppCandidates(platform, env, home) {
14897
14937
  if (platform === "darwin") {
14898
14938
  return ["/Applications/Buzz.app", join4(home, "Applications", "Buzz.app")];
14899
14939
  }
14900
14940
  if (platform === "win32") {
14901
- const base = env2.LOCALAPPDATA ?? join4(home, "AppData", "Local");
14941
+ const base = env.LOCALAPPDATA ?? join4(home, "AppData", "Local");
14902
14942
  return [join4(base, "Programs", "Buzz")];
14903
14943
  }
14904
14944
  return [
@@ -14908,12 +14948,12 @@ function buzzAppCandidates(platform, env2, home) {
14908
14948
  ];
14909
14949
  }
14910
14950
  var BUZZ_RELEASES_URL = "https://github.com/block/buzz/releases/latest";
14911
- function buzzSidecarDirs(platform, env2, home) {
14951
+ function buzzSidecarDirs(platform, env, home) {
14912
14952
  if (platform === "darwin") {
14913
- return buzzAppCandidates(platform, env2, home).map((app) => join4(app, "Contents", "MacOS"));
14953
+ return buzzAppCandidates(platform, env, home).map((app) => join4(app, "Contents", "MacOS"));
14914
14954
  }
14915
14955
  if (platform === "win32") {
14916
- return buzzAppCandidates(platform, env2, home);
14956
+ return buzzAppCandidates(platform, env, home);
14917
14957
  }
14918
14958
  return ["/opt/Buzz"];
14919
14959
  }
@@ -14951,7 +14991,7 @@ ${looked}
14951
14991
  }
14952
14992
  var DEFAULT_BUZZ_KINDS = "9,46010,40007,7";
14953
14993
  function buzzAcpEnv(opts) {
14954
- const env2 = {
14994
+ const env = {
14955
14995
  BUZZ_RELAY_URL: opts.relayUrl,
14956
14996
  BUZZ_ACP_AGENT_COMMAND: opts.marthaBin,
14957
14997
  BUZZ_ACP_AGENT_ARGS: "acp-serve,--post-reply",
@@ -14961,16 +15001,16 @@ function buzzAcpEnv(opts) {
14961
15001
  ...opts.profile ? { MARTHA_PROFILE: opts.profile } : {}
14962
15002
  };
14963
15003
  if (opts.subscribe === "all")
14964
- env2.BUZZ_ACP_KINDS = opts.kinds;
14965
- return env2;
15004
+ env.BUZZ_ACP_KINDS = opts.kinds;
15005
+ return env;
14966
15006
  }
14967
- function resolveOnPath(bin, env2, platform, isExecutable) {
15007
+ function resolveOnPath(bin, env, platform, isExecutable) {
14968
15008
  if (bin.includes("/") || bin.includes("\\")) {
14969
15009
  return isExecutable(bin) ? bin : null;
14970
15010
  }
14971
- const exts = platform === "win32" ? (env2.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
15011
+ const exts = platform === "win32" ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
14972
15012
  const sep = platform === "win32" ? ";" : ":";
14973
- for (const dir of (env2.PATH ?? "").split(sep).filter(Boolean)) {
15013
+ for (const dir of (env.PATH ?? "").split(sep).filter(Boolean)) {
14974
15014
  for (const ext of exts) {
14975
15015
  const candidate = join4(dir, bin + ext);
14976
15016
  if (isExecutable(candidate))
@@ -14998,11 +15038,11 @@ function whichBuzz(bin) {
14998
15038
  isExecutable: executableOnDisk
14999
15039
  });
15000
15040
  }
15001
- function runBin(bin, args, env2) {
15002
- return new Promise((resolve2) => {
15003
- execFile2(bin, args, { env: env2, timeout: 15000, maxBuffer: 4 * 1024 * 1024 }, (err, stdout, stderr) => {
15041
+ function runBin(bin, args, env) {
15042
+ return new Promise((resolve) => {
15043
+ execFile2(bin, args, { env, timeout: 15000, maxBuffer: 4 * 1024 * 1024 }, (err, stdout, stderr) => {
15004
15044
  const code = err && typeof err.code === "number" ? err.code ?? 1 : err ? 1 : 0;
15005
- resolve2({
15045
+ resolve({
15006
15046
  code,
15007
15047
  stdout: stdout ?? "",
15008
15048
  stderr: (stderr ?? "").slice(0, 2000)
@@ -15130,15 +15170,15 @@ async function preflightBuzz(ctx, opts) {
15130
15170
  detail: relayProbe.detail,
15131
15171
  fix: relayProbe.ok ? undefined : `start the relay, or correct --relay (${opts.relayUrl})`
15132
15172
  });
15133
- const identity2 = process.env.BUZZ_PRIVATE_KEY;
15173
+ const identity = process.env.BUZZ_PRIVATE_KEY;
15134
15174
  checks.push({
15135
- ok: !!identity2,
15175
+ ok: !!identity,
15136
15176
  label: "channel identity",
15137
- detail: identity2 ? "BUZZ_PRIVATE_KEY set (not shown)" : "BUZZ_PRIVATE_KEY not set",
15138
- fix: identity2 ? undefined : "export BUZZ_PRIVATE_KEY=<the agent's nsec> — Martha-issued identities land in #1119"
15177
+ detail: identity ? "BUZZ_PRIVATE_KEY set (not shown)" : "BUZZ_PRIVATE_KEY not set",
15178
+ fix: identity ? undefined : "export BUZZ_PRIVATE_KEY=<the agent's nsec> — Martha-issued identities land in #1119"
15139
15179
  });
15140
- if (identity2 && relayProbe.ok && buzzPath) {
15141
- checks.push(await checkMembership(buzzPath, opts.relayUrl, identity2, opts.channelId));
15180
+ if (identity && relayProbe.ok && buzzPath) {
15181
+ checks.push(await checkMembership(buzzPath, opts.relayUrl, identity, opts.channelId));
15142
15182
  } else {
15143
15183
  checks.push({
15144
15184
  ok: null,
@@ -15181,12 +15221,12 @@ async function checkAgentPrincipal(ctx, agent, def) {
15181
15221
  };
15182
15222
  }
15183
15223
  }
15184
- async function checkMembership(buzzBin, relayUrl, identity2, channelId) {
15224
+ async function checkMembership(buzzBin, relayUrl, identity, channelId) {
15185
15225
  const label = "channel membership";
15186
15226
  const res = await runBin(buzzBin, ["--format", "compact", "channels", "list", "--member"], {
15187
15227
  ...process.env,
15188
15228
  BUZZ_RELAY_URL: relayUrl,
15189
- BUZZ_PRIVATE_KEY: identity2
15229
+ BUZZ_PRIVATE_KEY: identity
15190
15230
  });
15191
15231
  if (res.code !== 0) {
15192
15232
  const why = res.code === 3 ? "the relay rejected this identity" : res.code === 2 ? "relay/network error" : `buzz exited ${res.code}`;
@@ -15223,13 +15263,13 @@ async function checkMembership(buzzBin, relayUrl, identity2, channelId) {
15223
15263
  fix: channels.length ? undefined : "buzz channels add-member --channel <id> --pubkey <the agent's pubkey> --role member"
15224
15264
  };
15225
15265
  }
15226
- function emitManifest(kind, env2, opts) {
15266
+ function emitManifest(kind, env, opts) {
15227
15267
  const secretKeys = [
15228
15268
  "BUZZ_PRIVATE_KEY",
15229
15269
  "MARTHA_CLIENT_ID",
15230
15270
  "MARTHA_CLIENT_SECRET"
15231
15271
  ];
15232
- const entries = Object.entries(env2);
15272
+ const entries = Object.entries(env);
15233
15273
  if (kind === "docker") {
15234
15274
  const lines = [
15235
15275
  "docker run --rm \\",
@@ -15286,8 +15326,8 @@ function assertSupportedChannel(kind) {
15286
15326
  throw new CLIError(`Channel type '${kind}' is not implemented.`, 4 /* Validation */, `Supported: ${SUPPORTED_CHANNELS.join(", ")}. Slack and others land as separate slices — the verb and the preflight generalize, the precondition list does not.`);
15287
15327
  }
15288
15328
  }
15289
- function registerChannelCommands(program2) {
15290
- const channels = program2.command("channels").description("Put a Martha agent in an external conversation channel — from Buzz (install-harness) or from Martha (connect)");
15329
+ function registerChannelCommands(program) {
15330
+ const channels = program.command("channels").description("Put a Martha agent in an external conversation channel — from Buzz (install-harness) or from Martha (connect)");
15291
15331
  channels.command("install-harness <type>").description("Register Martha as a runtime in Buzz Desktop (a tier-3 custom harness definition). " + "Desktop then owns the agent's keypair, attestation and lifecycle — we only declare how to start the adapter.").option("--app-data <dir>", "Buzz Desktop app-data dir (default: auto-detect)").option("--id <id>", "Harness id", BUZZ_HARNESS_ID).option("--label <label>", "Name shown in Buzz's runtime picker", "Martha").option("--command <bin>", "Executable Buzz should spawn", "martha").option("--use-profile <name>", "Bake MARTHA_PROFILE into the definition as the DEFAULT for every agent on this runtime, so Edit Agent needs nothing. A per-agent MARTHA_PROFILE in Edit Agent overrides it — that is how two Buzz agents become two different Martha agents. Named --use-profile because the global --profile picks which profile this COMMAND talks to.").option("--print", "Print the definition instead of writing it").option("--force", "Overwrite an existing definition").action(async (type, opts) => {
15292
15332
  assertSupportedChannel(type);
15293
15333
  const def = buzzHarnessDefinition({
@@ -15333,7 +15373,7 @@ function registerChannelCommands(program2) {
15333
15373
  });
15334
15374
  channels.command("preflight <type>").description("Check every precondition for an agent to answer in a channel, and name the one command that fixes each gap. Exits non-zero if any check fails.").requiredOption("--agent <name>", "The Martha agent that will answer").option("--relay <url>", "Relay URL", "ws://localhost:3030").option("--channel <uuid>", "Check membership of one specific channel").option("--buzz-acp-bin <path>", "buzz-acp binary", "buzz-acp").option("--buzz-bin <path>", "buzz CLI binary", "buzz").option("--martha-bin <path>", "martha binary buzz-acp will spawn", "martha").action(async (type, opts) => {
15335
15375
  assertSupportedChannel(type);
15336
- const ctx = contextFor(program2);
15376
+ const ctx = contextFor(program);
15337
15377
  const checks = await preflightBuzz(ctx, {
15338
15378
  agent: opts.agent,
15339
15379
  relayUrl: opts.relay,
@@ -15351,7 +15391,7 @@ function registerChannelCommands(program2) {
15351
15391
  if (opts.subscribe !== "mentions" && opts.subscribe !== "all") {
15352
15392
  throw new CLIError(`--subscribe must be 'mentions' or 'all' (got '${opts.subscribe}').`, 4 /* Validation */);
15353
15393
  }
15354
- const ctx = contextFor(program2);
15394
+ const ctx = contextFor(program);
15355
15395
  const checks = await preflightBuzz(ctx, {
15356
15396
  agent: opts.agent,
15357
15397
  relayUrl: opts.relay,
@@ -15361,20 +15401,20 @@ function registerChannelCommands(program2) {
15361
15401
  buzzBin: opts.buzzBin
15362
15402
  });
15363
15403
  reportPreflight(type, opts.agent, checks, opts.emit ? "stderr" : "stdout");
15364
- const env2 = buzzAcpEnv({
15404
+ const env = buzzAcpEnv({
15365
15405
  relayUrl: opts.relay,
15366
15406
  subscribe: opts.subscribe,
15367
15407
  kinds: opts.kinds,
15368
15408
  multipleEventHandling: "queue",
15369
15409
  respondTo: opts.respondTo,
15370
15410
  marthaBin: opts.marthaBin,
15371
- profile: program2.opts().profile
15411
+ profile: program.opts().profile
15372
15412
  });
15373
15413
  if (opts.emit) {
15374
15414
  if (!["docker", "compose", "k8s"].includes(opts.emit)) {
15375
15415
  throw new CLIError(`--emit must be docker, compose or k8s (got '${opts.emit}').`, 4 /* Validation */);
15376
15416
  }
15377
- console.log(emitManifest(opts.emit, env2, {
15417
+ console.log(emitManifest(opts.emit, env, {
15378
15418
  agent: opts.agent,
15379
15419
  image: opts.image
15380
15420
  }));
@@ -15394,7 +15434,7 @@ function registerChannelCommands(program2) {
15394
15434
  if (opts.dryRun) {
15395
15435
  console.log(source_default.bold(`Would launch:
15396
15436
  `));
15397
- for (const [k, v] of Object.entries(env2))
15437
+ for (const [k, v] of Object.entries(env))
15398
15438
  console.log(` ${k}=${v}`);
15399
15439
  console.log(` ${acp.path}
15400
15440
  `);
@@ -15404,10 +15444,10 @@ function registerChannelCommands(program2) {
15404
15444
  Connecting '${opts.agent}' to ${opts.relay} …
15405
15445
  `));
15406
15446
  const child = spawn3(acp.path, [], {
15407
- env: { ...process.env, PATH: childPath, ...env2 },
15447
+ env: { ...process.env, PATH: childPath, ...env },
15408
15448
  stdio: "inherit"
15409
15449
  });
15410
- await new Promise((resolve2) => {
15450
+ await new Promise((resolve) => {
15411
15451
  child.on("exit", (code, signal) => {
15412
15452
  if (signal) {
15413
15453
  console.log(source_default.dim(`
@@ -15416,21 +15456,21 @@ buzz-acp terminated by ${signal}`));
15416
15456
  } else if (code) {
15417
15457
  process.exitCode = code;
15418
15458
  }
15419
- resolve2();
15459
+ resolve();
15420
15460
  });
15421
15461
  child.on("error", (err) => {
15422
15462
  console.error(source_default.red(`failed to start ${acp}: ${err.message}`));
15423
15463
  process.exitCode = 1 /* Error */;
15424
- resolve2();
15464
+ resolve();
15425
15465
  });
15426
15466
  });
15427
15467
  });
15428
15468
  }
15429
- function contextFor(program2) {
15469
+ function contextFor(program) {
15430
15470
  return createContext({
15431
- profileOverride: program2.opts().profile,
15432
- apiUrlOverride: program2.opts().apiUrl,
15433
- verbose: program2.opts().verbose
15471
+ profileOverride: program.opts().profile,
15472
+ apiUrlOverride: program.opts().apiUrl,
15473
+ verbose: program.opts().verbose
15434
15474
  });
15435
15475
  }
15436
15476
  function reportPreflight(type, agent, checks, stream = "stdout") {
@@ -15491,9 +15531,9 @@ init_errors();
15491
15531
  import { createInterface as createInterface4 } from "node:readline";
15492
15532
  function prompt(rl, question, defaultValue) {
15493
15533
  const suffix = defaultValue ? ` [${defaultValue}]` : "";
15494
- return new Promise((resolve2) => {
15534
+ return new Promise((resolve) => {
15495
15535
  rl.question(`${question}${suffix}: `, (answer) => {
15496
- resolve2(answer.trim() || defaultValue || "");
15536
+ resolve(answer.trim() || defaultValue || "");
15497
15537
  });
15498
15538
  });
15499
15539
  }
@@ -15737,22 +15777,22 @@ function configUse(profileName, configDir) {
15737
15777
  saveConfig(config, configDir);
15738
15778
  console.log(`Switched to profile ${source_default.cyan(profileName)}`);
15739
15779
  }
15740
- function registerConfigCommand(program2) {
15741
- const configCmd = program2.command("config").description("Manage CLI configuration and profiles");
15780
+ function registerConfigCommand(program) {
15781
+ const configCmd = program.command("config").description("Manage CLI configuration and profiles");
15742
15782
  configCmd.command("init").description("Interactive config setup").action(async () => {
15743
15783
  await configInit();
15744
15784
  });
15745
15785
  configCmd.command("show").description("Print current config").action(() => {
15746
- configShow(!!program2.opts().json, undefined, program2.opts().profile);
15786
+ configShow(!!program.opts().json, undefined, program.opts().profile);
15747
15787
  });
15748
15788
  configCmd.command("get <key>").description("Get a config value").action((key) => {
15749
- configGet(key, !!program2.opts().json, undefined, program2.opts().profile);
15789
+ configGet(key, !!program.opts().json, undefined, program.opts().profile);
15750
15790
  });
15751
15791
  configCmd.command("set <key> <value>").description("Set a config value").action((key, value) => {
15752
- configSet(key, value, !!program2.opts().json, undefined, program2.opts().profile);
15792
+ configSet(key, value, !!program.opts().json, undefined, program.opts().profile);
15753
15793
  });
15754
15794
  configCmd.command("profiles").description("List all profiles").action(() => {
15755
- configProfiles(!!program2.opts().json);
15795
+ configProfiles(!!program.opts().json);
15756
15796
  });
15757
15797
  configCmd.command("use <profile>").description("Switch active profile").action((profile) => {
15758
15798
  configUse(profile);
@@ -15776,7 +15816,7 @@ function registerConfigCommand(program2) {
15776
15816
  config.current_profile = name;
15777
15817
  }
15778
15818
  saveConfig(config);
15779
- if (program2.opts().json) {
15819
+ if (program.opts().json) {
15780
15820
  console.log(JSON.stringify({
15781
15821
  name,
15782
15822
  profile,
@@ -15799,14 +15839,14 @@ function registerConfigCommand(program2) {
15799
15839
  if (!process.stdin.isTTY) {
15800
15840
  throw new CLIError("Cannot confirm in non-interactive mode.", 4 /* Validation */, "Use --yes to skip confirmation.");
15801
15841
  }
15802
- const ok = await new Promise((resolve2) => {
15842
+ const ok = await new Promise((resolve) => {
15803
15843
  const rl = createInterface4({
15804
15844
  input: process.stdin,
15805
15845
  output: process.stderr
15806
15846
  });
15807
15847
  rl.question(`Delete profile '${name}'? (y/N) `, (answer) => {
15808
15848
  rl.close();
15809
- resolve2(answer.trim().toLowerCase() === "y");
15849
+ resolve(answer.trim().toLowerCase() === "y");
15810
15850
  });
15811
15851
  });
15812
15852
  if (!ok) {
@@ -15820,7 +15860,7 @@ function registerConfigCommand(program2) {
15820
15860
  config.current_profile = remaining[0] ?? "default";
15821
15861
  }
15822
15862
  saveConfig(config);
15823
- if (program2.opts().json) {
15863
+ if (program.opts().json) {
15824
15864
  console.log(JSON.stringify({ name, deleted: true }));
15825
15865
  return;
15826
15866
  }
@@ -16499,10 +16539,10 @@ function renderResults(results, isJson, warnings) {
16499
16539
  ${failed.length} failed.`));
16500
16540
  }
16501
16541
  }
16502
- function registerDefinitionsApply(program2) {
16503
- let defCmd = program2.commands.find((c) => c.name() === "definitions");
16542
+ function registerDefinitionsApply(program) {
16543
+ let defCmd = program.commands.find((c) => c.name() === "definitions");
16504
16544
  if (!defCmd) {
16505
- defCmd = program2.command("definitions").description("Cross-type definition operations");
16545
+ defCmd = program.command("definitions").description("Cross-type definition operations");
16506
16546
  }
16507
16547
  defCmd.command("apply").description("Apply definitions from YAML/JSON files (create or update, never deletes)").requiredOption("-f, --file <path>", "Path to a YAML/JSON file or directory of definitions").option("--dry-run", "Preview changes without applying").option("--yes", "Skip confirmation prompt").addHelpText("after", `
16508
16548
  Examples:
@@ -16512,13 +16552,13 @@ Examples:
16512
16552
  $ martha definitions apply -f definitions/ --dry-run Preview only
16513
16553
  $ martha definitions apply -f definitions/ --yes Skip confirmation`).action(async (opts) => {
16514
16554
  const ctx = createContext({
16515
- profileOverride: program2.opts().profile,
16516
- verbose: program2.opts().verbose
16555
+ profileOverride: program.opts().profile,
16556
+ verbose: program.opts().verbose
16517
16557
  });
16518
- if (program2.opts().apiUrl) {
16519
- ctx.profile.api_url = program2.opts().apiUrl;
16558
+ if (program.opts().apiUrl) {
16559
+ ctx.profile.api_url = program.opts().apiUrl;
16520
16560
  }
16521
- const isJson = !!program2.opts().json;
16561
+ const isJson = !!program.opts().json;
16522
16562
  const defs = loadDefinitions(opts.file);
16523
16563
  if (defs.length === 0) {
16524
16564
  if (isJson) {
@@ -16638,22 +16678,22 @@ function renderStats(stats) {
16638
16678
  const wf = stats.workflows;
16639
16679
  console.log(`Workflows: ${wf.total} total (${wf.active} active, ${wf.inactive} inactive)`);
16640
16680
  }
16641
- function registerDefinitionsExport(program2) {
16642
- let defCmd = program2.commands.find((c) => c.name() === "definitions");
16681
+ function registerDefinitionsExport(program) {
16682
+ let defCmd = program.commands.find((c) => c.name() === "definitions");
16643
16683
  if (!defCmd) {
16644
- defCmd = program2.command("definitions").description("Cross-type definition operations");
16684
+ defCmd = program.command("definitions").description("Cross-type definition operations");
16645
16685
  }
16646
16686
  function getCtx() {
16647
16687
  const ctx = createContext({
16648
- profileOverride: program2.opts().profile,
16649
- verbose: program2.opts().verbose
16688
+ profileOverride: program.opts().profile,
16689
+ verbose: program.opts().verbose
16650
16690
  });
16651
- if (program2.opts().apiUrl)
16652
- ctx.profile.api_url = program2.opts().apiUrl;
16691
+ if (program.opts().apiUrl)
16692
+ ctx.profile.api_url = program.opts().apiUrl;
16653
16693
  return ctx;
16654
16694
  }
16655
16695
  function isJson() {
16656
- return !!program2.opts().json;
16696
+ return !!program.opts().json;
16657
16697
  }
16658
16698
  defCmd.command("export").description("Export all definitions (functions and workflows)").option("--format <format>", "Output format: yaml or json (default: yaml)", "yaml").option("--output <file>", "Write to file instead of stdout").option("--inactive", "Include inactive definitions").option("--functions-only", "Export functions only").option("--workflows-only", "Export workflows only").action(async (opts) => {
16659
16699
  if (opts.functionsOnly && opts.workflowsOnly) {
@@ -16698,14 +16738,14 @@ function registerDefinitionsExport(program2) {
16698
16738
  renderPlan(ops);
16699
16739
  }
16700
16740
  });
16701
- const fnCmd = program2.commands.find((c) => c.name() === "functions");
16741
+ const fnCmd = program.commands.find((c) => c.name() === "functions");
16702
16742
  if (fnCmd) {
16703
16743
  fnCmd.command("export").description("Export function definitions").option("--format <format>", "Output format: yaml or json (default: yaml)", "yaml").option("--output <file>", "Write to file instead of stdout").option("--inactive", "Include inactive definitions").action(async (opts) => {
16704
16744
  const ctx = getCtx();
16705
16745
  await exportDefinitions(ctx, { ...opts, functionsOnly: true }, isJson());
16706
16746
  });
16707
16747
  }
16708
- const wfCmd = program2.commands.find((c) => c.name() === "workflows");
16748
+ const wfCmd = program.commands.find((c) => c.name() === "workflows");
16709
16749
  if (wfCmd) {
16710
16750
  wfCmd.command("export").description("Export workflow definitions").option("--format <format>", "Output format: yaml or json (default: yaml)", "yaml").option("--output <file>", "Write to file instead of stdout").option("--inactive", "Include inactive definitions").action(async (opts) => {
16711
16751
  const ctx = getCtx();
@@ -16924,7 +16964,7 @@ function colorStatus(status) {
16924
16964
  return fn(status);
16925
16965
  }
16926
16966
  function sleep2(ms) {
16927
- return new Promise((resolve2) => setTimeout(resolve2, ms));
16967
+ return new Promise((resolve) => setTimeout(resolve, ms));
16928
16968
  }
16929
16969
  async function pollUntilDone(ctx, executionId, intervalMs = 2000, timeoutMs = 300000) {
16930
16970
  const deadline = Date.now() + timeoutMs;
@@ -17334,8 +17374,8 @@ function registerProjectionCommands(parentCmd, getCtx, isJson) {
17334
17374
  } catch {}
17335
17375
  }
17336
17376
  if (opts.output) {
17337
- const fs10 = await import("node:fs/promises");
17338
- await fs10.writeFile(opts.output, toWrite, "utf-8");
17377
+ const fs = await import("node:fs/promises");
17378
+ await fs.writeFile(opts.output, toWrite, "utf-8");
17339
17379
  if (!isJson()) {
17340
17380
  console.error(source_default.dim(`Wrote ${format} projection of '${name}' to ${opts.output}`));
17341
17381
  }
@@ -17440,21 +17480,21 @@ var promptsConfig = {
17440
17480
  accessor: (item) => item.is_protected ? "yes" : "no"
17441
17481
  }
17442
17482
  ],
17443
- renderDetail: (prompt2) => {
17444
- console.log(source_default.bold(`Prompt: ${prompt2.name}
17483
+ renderDetail: (prompt) => {
17484
+ console.log(source_default.bold(`Prompt: ${prompt.name}
17445
17485
  `));
17446
- if (prompt2.description)
17447
- console.log(` ${prompt2.description}
17486
+ if (prompt.description)
17487
+ console.log(` ${prompt.description}
17448
17488
  `);
17449
- console.log(` Scope: ${prompt2.scope ?? "-"}`);
17450
- console.log(` Protected: ${prompt2.is_protected ? source_default.yellow("yes") : "no"}`);
17451
- const prod = prompt2.production;
17452
- const staging = prompt2.staging;
17489
+ console.log(` Scope: ${prompt.scope ?? "-"}`);
17490
+ console.log(` Protected: ${prompt.is_protected ? source_default.yellow("yes") : "no"}`);
17491
+ const prod = prompt.production;
17492
+ const staging = prompt.staging;
17453
17493
  console.log(` Prod Ver: ${prod?.version ?? "-"}`);
17454
17494
  console.log(` Staging Ver: ${staging?.version ?? "-"}`);
17455
- if (prompt2.updated_at)
17456
- console.log(` Updated: ${prompt2.updated_at}`);
17457
- const content = prompt2.content;
17495
+ if (prompt.updated_at)
17496
+ console.log(` Updated: ${prompt.updated_at}`);
17497
+ const content = prompt.content;
17458
17498
  if (content) {
17459
17499
  console.log(`
17460
17500
  ${source_default.bold("Content:")}`);
@@ -17689,7 +17729,7 @@ function nextSpinner() {
17689
17729
  return frame;
17690
17730
  }
17691
17731
  function sleep3(ms) {
17692
- return new Promise((resolve2) => setTimeout(resolve2, ms));
17732
+ return new Promise((resolve) => setTimeout(resolve, ms));
17693
17733
  }
17694
17734
  function formatBytes(bytes) {
17695
17735
  if (bytes < 1024)
@@ -17844,19 +17884,19 @@ Detached. Check status with: martha documents status ${documentId}`));
17844
17884
  process.removeListener("SIGINT", sigintHandler);
17845
17885
  }
17846
17886
  }
17847
- function registerDocumentCommands(program2) {
17848
- const cmd = program2.command("documents").description("Manage document collections and ingestion");
17887
+ function registerDocumentCommands(program) {
17888
+ const cmd = program.command("documents").description("Manage document collections and ingestion");
17849
17889
  function getCtx() {
17850
17890
  const ctx = createContext({
17851
- profileOverride: program2.opts().profile,
17852
- verbose: program2.opts().verbose
17891
+ profileOverride: program.opts().profile,
17892
+ verbose: program.opts().verbose
17853
17893
  });
17854
- if (program2.opts().apiUrl)
17855
- ctx.profile.api_url = program2.opts().apiUrl;
17894
+ if (program.opts().apiUrl)
17895
+ ctx.profile.api_url = program.opts().apiUrl;
17856
17896
  return ctx;
17857
17897
  }
17858
17898
  function isJson() {
17859
- return !!program2.opts().json;
17899
+ return !!program.opts().json;
17860
17900
  }
17861
17901
  async function resolveCollection(ctx, ref) {
17862
17902
  const looksLikeUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(ref);
@@ -18456,19 +18496,19 @@ Ingestion status — source ${sourceId}`));
18456
18496
  }
18457
18497
  }
18458
18498
  }
18459
- function registerDocumentSyncCommands(program2) {
18460
- const cmd = program2.command("document-sync").description("Manage durable document sync sources (Google Drive, etc.)");
18499
+ function registerDocumentSyncCommands(program) {
18500
+ const cmd = program.command("document-sync").description("Manage durable document sync sources (Google Drive, etc.)");
18461
18501
  function getCtx() {
18462
18502
  const ctx = createContext({
18463
- profileOverride: program2.opts().profile,
18464
- verbose: program2.opts().verbose
18503
+ profileOverride: program.opts().profile,
18504
+ verbose: program.opts().verbose
18465
18505
  });
18466
- if (program2.opts().apiUrl)
18467
- ctx.profile.api_url = program2.opts().apiUrl;
18506
+ if (program.opts().apiUrl)
18507
+ ctx.profile.api_url = program.opts().apiUrl;
18468
18508
  return ctx;
18469
18509
  }
18470
18510
  function isJson() {
18471
- return !!program2.opts().json;
18511
+ return !!program.opts().json;
18472
18512
  }
18473
18513
  function printSummary(name, s) {
18474
18514
  const tag = s.dry_run ? source_default.yellow(" (dry-run)") : "";
@@ -18490,17 +18530,17 @@ ${name}${tag}`));
18490
18530
  throw new CLIError("--source and --all are mutually exclusive", 4 /* Validation */);
18491
18531
  }
18492
18532
  const params = { dry_run: String(dryRun) };
18493
- let sources2;
18533
+ let sources;
18494
18534
  if (opts.all) {
18495
18535
  const all = await ctx.api.get("/api/admin/document-sync/sources", { params: { provider: "google_drive" } });
18496
- sources2 = all;
18536
+ sources = all;
18497
18537
  } else {
18498
- sources2 = [
18538
+ sources = [
18499
18539
  { id: opts.source, name: opts.source, provider: "google_drive" }
18500
18540
  ];
18501
18541
  }
18502
18542
  const results = [];
18503
- for (const src of sources2) {
18543
+ for (const src of sources) {
18504
18544
  const summary = await ctx.api.post(`/api/admin/document-sync/sources/${encodeURIComponent(src.id)}/reconcile-tree`, undefined, { params });
18505
18545
  results.push(summary);
18506
18546
  if (!isJson())
@@ -18627,17 +18667,17 @@ No google_drive sources found.`));
18627
18667
 
18628
18668
  // src/commands/approvals.ts
18629
18669
  init_errors();
18630
- function registerApprovalCommands(program2) {
18631
- const cmd = program2.command("approvals").description("Manage approval cases");
18670
+ function registerApprovalCommands(program) {
18671
+ const cmd = program.command("approvals").description("Manage approval cases");
18632
18672
  function getCtx() {
18633
18673
  return createContext({
18634
- profileOverride: program2.opts().profile,
18635
- apiUrlOverride: program2.opts().apiUrl,
18636
- verbose: program2.opts().verbose
18674
+ profileOverride: program.opts().profile,
18675
+ apiUrlOverride: program.opts().apiUrl,
18676
+ verbose: program.opts().verbose
18637
18677
  });
18638
18678
  }
18639
18679
  function isJson() {
18640
- return !!program2.opts().json;
18680
+ return !!program.opts().json;
18641
18681
  }
18642
18682
  cmd.command("list").description("List approval cases").option("--status <status>", "Filter by status").option("--assigned-to <user>", "Filter by assignee").option("--limit <n>", "Max results", "50").action(async (opts) => {
18643
18683
  const ctx = getCtx();
@@ -18723,19 +18763,19 @@ function renderAsk(a) {
18723
18763
  return lines.join(`
18724
18764
  `);
18725
18765
  }
18726
- function registerAskCommands(program2) {
18727
- const cmd = program2.command("asks").description("Agent asks — questions/approval requests to the human queue (agent credentials)");
18766
+ function registerAskCommands(program) {
18767
+ const cmd = program.command("asks").description("Agent asks — questions/approval requests to the human queue (agent credentials)");
18728
18768
  function getCtx() {
18729
18769
  const ctx = createContext({
18730
- profileOverride: program2.opts().profile,
18731
- verbose: program2.opts().verbose
18770
+ profileOverride: program.opts().profile,
18771
+ verbose: program.opts().verbose
18732
18772
  });
18733
- if (program2.opts().apiUrl)
18734
- ctx.profile.api_url = program2.opts().apiUrl;
18773
+ if (program.opts().apiUrl)
18774
+ ctx.profile.api_url = program.opts().apiUrl;
18735
18775
  return ctx;
18736
18776
  }
18737
18777
  function isJson() {
18738
- return !!program2.opts().json;
18778
+ return !!program.opts().json;
18739
18779
  }
18740
18780
  cmd.command("create").description("File an ask (the server attributes it to the token's agent)").requiredOption("--reason <text>", "The question / what approval is requested").option("--kind <kind>", `${KINDS.join(" | ")} (default agent_question)`, "agent_question").option("--context <text>", "Context summary for the reviewer").option("--questions <json>", "Structured questions JSON array (ask_user shape: question/header/options/multiSelect)").option("--expires-in <seconds>", "Auto-expire the ask after N seconds").option("--idempotency-key <key>", "Dedup key — retries with the same key do not double-file").action(async (opts) => {
18741
18781
  if (!KINDS.includes(opts.kind)) {
@@ -18857,18 +18897,18 @@ async function buildCreateTaskBody(ctx, opts) {
18857
18897
  body.sticky_assignment = true;
18858
18898
  return body;
18859
18899
  }
18860
- var sleep4 = (ms, signal) => new Promise((resolve2) => {
18900
+ var sleep4 = (ms, signal) => new Promise((resolve) => {
18861
18901
  if (signal?.aborted) {
18862
- resolve2();
18902
+ resolve();
18863
18903
  return;
18864
18904
  }
18865
18905
  const t = setTimeout(() => {
18866
18906
  signal?.removeEventListener("abort", onAbort);
18867
- resolve2();
18907
+ resolve();
18868
18908
  }, ms);
18869
18909
  const onAbort = () => {
18870
18910
  clearTimeout(t);
18871
- resolve2();
18911
+ resolve();
18872
18912
  };
18873
18913
  signal?.addEventListener("abort", onAbort, { once: true });
18874
18914
  });
@@ -18905,19 +18945,19 @@ var priorityColor = (priority) => {
18905
18945
  return priority;
18906
18946
  }
18907
18947
  };
18908
- function registerTaskCommands(program2) {
18909
- const cmd = program2.command("tasks").description("Manage agent tasks");
18948
+ function registerTaskCommands(program) {
18949
+ const cmd = program.command("tasks").description("Manage agent tasks");
18910
18950
  function getCtx() {
18911
18951
  const ctx = createContext({
18912
- profileOverride: program2.opts().profile,
18913
- verbose: program2.opts().verbose
18952
+ profileOverride: program.opts().profile,
18953
+ verbose: program.opts().verbose
18914
18954
  });
18915
- if (program2.opts().apiUrl)
18916
- ctx.profile.api_url = program2.opts().apiUrl;
18955
+ if (program.opts().apiUrl)
18956
+ ctx.profile.api_url = program.opts().apiUrl;
18917
18957
  return ctx;
18918
18958
  }
18919
18959
  function isJson() {
18920
- return !!program2.opts().json;
18960
+ return !!program.opts().json;
18921
18961
  }
18922
18962
  cmd.command("list").description("List tasks").option("--status <status>", "Filter by status (open, running, completed, failed, cancelled)").option("--agent <id>", "Filter by agent definition ID").option("--priority <priority>", "Filter by priority (low, medium, high, urgent)").option("--search <query>", "Search in title and goal").option("--limit <n>", "Max results", "50").action(async (opts) => {
18923
18963
  const ctx = getCtx();
@@ -19331,9 +19371,9 @@ function sleepUnref(ms) {
19331
19371
  }
19332
19372
  var ACK_INTERVAL_MS = 5000;
19333
19373
  function startupEchoLine(who, opts) {
19334
- const identity2 = who ? who.kind === "agent" ? `agent ${who.agent_name ?? "?"} (${(who.agent_id ?? "").slice(0, 8)}…)` : `${who.kind} ${who.sub ?? ""}`.trim() : "identity unknown (whoami unavailable)";
19374
+ const identity = who ? who.kind === "agent" ? `agent ${who.agent_name ?? "?"} (${(who.agent_id ?? "").slice(0, 8)}…)` : `${who.kind} ${who.sub ?? ""}`.trim() : "identity unknown (whoami unavailable)";
19335
19375
  const exec = opts.allowHostExec ? "host exec allowed" : "host exec refused (pass --allow-host-exec)";
19336
- return `[runner] attached as ${identity2} — this machine is the agent's hands (host executor; the agent reasons in Martha's cloud loop), cwd ${opts.cwd}, ${exec}`;
19376
+ return `[runner] attached as ${identity} — this machine is the agent's hands (host executor; the agent reasons in Martha's cloud loop), cwd ${opts.cwd}, ${exec}`;
19337
19377
  }
19338
19378
  function rejectRemovedTaskModeFlags(opts) {
19339
19379
  const used = [
@@ -19471,13 +19511,13 @@ async function runChannelLoop(ctx, state, abort) {
19471
19511
  }
19472
19512
  }
19473
19513
  }
19474
- function registerRunnerCommand(program2) {
19475
- program2.command("runner").description("Attach this machine as a cloud agent's hands (#714): hold the per-agent " + "channel open and execute host-tool calls the agent's Martha-hosted " + "reasoning loop parks on (chat gates and assigned-task parks). Identity " + "comes from the API token (the agent's runner key). The runner never " + "reasons and never runs tasks — self-hosted agents drive the task REST " + "(`martha tasks poll/claim/complete`) with their own code.").option("--tools", "Accepted no-op: hands mode is the only mode (kept so printed " + "setup-host-runner commands stay valid).").option("--cwd <dir>", "Scoped workspace for host execution", process.cwd()).option("--allow-host-exec", "Consent to run host commands (required to execute)").option("--yes", "Deprecated alias for --allow-host-exec").option("--local-agent <name>", "Local coding agent for local_agent delegation over the channel", DEFAULT_LOCAL_AGENT).option("--tasks", "REMOVED (#714): the runner no longer runs tasks").option("--channel", "REMOVED (#714): deprecated pre-#822 alias").option("--once", "REMOVED (#714): belonged to the task-executor mode").option("--team <name>", "REMOVED (#714): belonged to the task-executor mode").option("--agent <id>", "REMOVED (#714): identity comes from the API token").option("--poll-interval <ms>", "REMOVED (#714): the runner no longer polls").action(async (opts) => {
19514
+ function registerRunnerCommand(program) {
19515
+ program.command("runner").description("Attach this machine as a cloud agent's hands (#714): hold the per-agent " + "channel open and execute host-tool calls the agent's Martha-hosted " + "reasoning loop parks on (chat gates and assigned-task parks). Identity " + "comes from the API token (the agent's runner key). The runner never " + "reasons and never runs tasks — self-hosted agents drive the task REST " + "(`martha tasks poll/claim/complete`) with their own code.").option("--tools", "Accepted no-op: hands mode is the only mode (kept so printed " + "setup-host-runner commands stay valid).").option("--cwd <dir>", "Scoped workspace for host execution", process.cwd()).option("--allow-host-exec", "Consent to run host commands (required to execute)").option("--yes", "Deprecated alias for --allow-host-exec").option("--local-agent <name>", "Local coding agent for local_agent delegation over the channel", DEFAULT_LOCAL_AGENT).option("--tasks", "REMOVED (#714): the runner no longer runs tasks").option("--channel", "REMOVED (#714): deprecated pre-#822 alias").option("--once", "REMOVED (#714): belonged to the task-executor mode").option("--team <name>", "REMOVED (#714): belonged to the task-executor mode").option("--agent <id>", "REMOVED (#714): identity comes from the API token").option("--poll-interval <ms>", "REMOVED (#714): the runner no longer polls").action(async (opts) => {
19476
19516
  rejectRemovedTaskModeFlags(opts);
19477
19517
  const ctx = createContext({
19478
- profileOverride: program2.opts().profile,
19479
- verbose: program2.opts().verbose,
19480
- apiUrlOverride: program2.opts().apiUrl
19518
+ profileOverride: program.opts().profile,
19519
+ verbose: program.opts().verbose,
19520
+ apiUrlOverride: program.opts().apiUrl
19481
19521
  });
19482
19522
  const allowHostExec = !!(opts.allowHostExec || opts.yes);
19483
19523
  let who;
@@ -19516,19 +19556,19 @@ function registerRunnerCommand(program2) {
19516
19556
  init_errors();
19517
19557
  var API_PATH3 = "/api/admin/teams";
19518
19558
  var fmtDate3 = (v) => typeof v === "string" ? new Date(v).toISOString().slice(0, 16).replace("T", " ") : "-";
19519
- function registerTeamCommands(program2) {
19520
- const cmd = program2.command("teams").description("Manage agent teams");
19559
+ function registerTeamCommands(program) {
19560
+ const cmd = program.command("teams").description("Manage agent teams");
19521
19561
  function getCtx() {
19522
19562
  const ctx = createContext({
19523
- profileOverride: program2.opts().profile,
19524
- verbose: program2.opts().verbose
19563
+ profileOverride: program.opts().profile,
19564
+ verbose: program.opts().verbose
19525
19565
  });
19526
- if (program2.opts().apiUrl)
19527
- ctx.profile.api_url = program2.opts().apiUrl;
19566
+ if (program.opts().apiUrl)
19567
+ ctx.profile.api_url = program.opts().apiUrl;
19528
19568
  return ctx;
19529
19569
  }
19530
19570
  function isJson() {
19531
- return !!program2.opts().json;
19571
+ return !!program.opts().json;
19532
19572
  }
19533
19573
  cmd.command("create").description("Create a new team").requiredOption("--name <name>", "Team name").option("--description <text>", "Team description").option("--routing <strategy>", "Routing strategy (manual or round_robin)", "manual").action(async (opts) => {
19534
19574
  const ctx = getCtx();
@@ -19693,19 +19733,19 @@ function healthColor(status) {
19693
19733
  return source_default.dim(status);
19694
19734
  }
19695
19735
  }
19696
- function registerIntegrationCommands(program2) {
19697
- const cmd = program2.command("integrations").description("Manage integrations and OpenAPI specs");
19736
+ function registerIntegrationCommands(program) {
19737
+ const cmd = program.command("integrations").description("Manage integrations and OpenAPI specs");
19698
19738
  function getCtx() {
19699
19739
  const ctx = createContext({
19700
- profileOverride: program2.opts().profile,
19701
- verbose: program2.opts().verbose
19740
+ profileOverride: program.opts().profile,
19741
+ verbose: program.opts().verbose
19702
19742
  });
19703
- if (program2.opts().apiUrl)
19704
- ctx.profile.api_url = program2.opts().apiUrl;
19743
+ if (program.opts().apiUrl)
19744
+ ctx.profile.api_url = program.opts().apiUrl;
19705
19745
  return ctx;
19706
19746
  }
19707
19747
  function isJson() {
19708
- return !!program2.opts().json;
19748
+ return !!program.opts().json;
19709
19749
  }
19710
19750
  cmd.command("list").description("List all integrations").action(async () => {
19711
19751
  const ctx = getCtx();
@@ -19844,12 +19884,12 @@ ${data.length} spec(s)`));
19844
19884
  const created = result.created ?? [];
19845
19885
  const updated = result.updated ?? [];
19846
19886
  const skipped = result.skipped ?? [];
19847
- const errors2 = result.errors ?? [];
19887
+ const errors = result.errors ?? [];
19848
19888
  console.log(` Created: ${source_default.green(created.length)} ` + `Updated: ${source_default.yellow(updated.length)} ` + `Skipped: ${source_default.dim(skipped.length)}`);
19849
- if (errors2.length > 0) {
19889
+ if (errors.length > 0) {
19850
19890
  console.log(source_default.red(`
19851
- Errors (${errors2.length}):`));
19852
- for (const err of errors2) {
19891
+ Errors (${errors.length}):`));
19892
+ for (const err of errors) {
19853
19893
  console.log(source_default.red(` - ${err}`));
19854
19894
  }
19855
19895
  }
@@ -19918,11 +19958,11 @@ ${data.length} spec(s)`));
19918
19958
  console.log(source_default.yellow(` - ${w}`));
19919
19959
  }
19920
19960
  }
19921
- const errors2 = result.errors ?? [];
19922
- if (errors2.length > 0) {
19961
+ const errors = result.errors ?? [];
19962
+ if (errors.length > 0) {
19923
19963
  console.log(source_default.red(`
19924
- Errors (${errors2.length}):`));
19925
- for (const e of errors2) {
19964
+ Errors (${errors.length}):`));
19965
+ for (const e of errors) {
19926
19966
  console.log(source_default.red(` - ${e}`));
19927
19967
  }
19928
19968
  }
@@ -20004,8 +20044,8 @@ ${data.length} spec(s)`));
20004
20044
  Resources:
20005
20045
  `));
20006
20046
  for (const r of resources) {
20007
- const path9 = r.path || `/${r.name}`;
20008
- console.log(` ${source_default.cyan(r.label || r.name)}` + source_default.dim(` → ${path9}`));
20047
+ const path = r.path || `/${r.name}`;
20048
+ console.log(` ${source_default.cyan(r.label || r.name)}` + source_default.dim(` → ${path}`));
20009
20049
  }
20010
20050
  }
20011
20051
  try {
@@ -20025,14 +20065,14 @@ Functions:
20025
20065
  console.log(source_default.dim(`
20026
20066
  Proxy: martha integrations proxy ${name} GET /<path>`));
20027
20067
  });
20028
- cmd.command("proxy <name> <method> <path>").description("Send a request through the plugin proxy").option("--data <json>", "JSON request body").option("--query <params>", "Query params as key=val&key=val").action(async (name, method, path9, opts) => {
20068
+ cmd.command("proxy <name> <method> <path>").description("Send a request through the plugin proxy").option("--data <json>", "JSON request body").option("--query <params>", "Query params as key=val&key=val").action(async (name, method, path, opts) => {
20029
20069
  const ctx = getCtx();
20030
20070
  const upperMethod = method.toUpperCase();
20031
20071
  const allowed = new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
20032
20072
  if (!allowed.has(upperMethod)) {
20033
20073
  throw new CLIError(`Invalid method: ${method}`, 4 /* Validation */, "Allowed: GET, POST, PUT, PATCH, DELETE");
20034
20074
  }
20035
- const cleanPath = path9.startsWith("/") ? path9.slice(1) : path9;
20075
+ const cleanPath = path.startsWith("/") ? path.slice(1) : path;
20036
20076
  const proxyUrl = `/api/admin/plugins/${encodeURIComponent(name)}/${cleanPath}`;
20037
20077
  const params = {};
20038
20078
  if (opts.query) {
@@ -20092,17 +20132,17 @@ function renderTable(columns, items, opts) {
20092
20132
 
20093
20133
  // src/commands/connections.ts
20094
20134
  init_errors();
20095
- function registerConnectionCommands(program2) {
20096
- const cmd = program2.command("connections").description("Manage Vault-backed integration connections (credentials live in Vault)");
20135
+ function registerConnectionCommands(program) {
20136
+ const cmd = program.command("connections").description("Manage Vault-backed integration connections (credentials live in Vault)");
20097
20137
  function getCtx() {
20098
20138
  return createContext({
20099
- profileOverride: program2.opts().profile,
20100
- apiUrlOverride: program2.opts().apiUrl,
20101
- verbose: program2.opts().verbose
20139
+ profileOverride: program.opts().profile,
20140
+ apiUrlOverride: program.opts().apiUrl,
20141
+ verbose: program.opts().verbose
20102
20142
  });
20103
20143
  }
20104
20144
  function isJson() {
20105
- return !!program2.opts().json;
20145
+ return !!program.opts().json;
20106
20146
  }
20107
20147
  cmd.command("list").description("List connections for the current tenant").option("--integration <name>", "Filter by integration name").option("--scope <scope>", "Filter by scope (tenant|client|system)").action(async (opts) => {
20108
20148
  const ctx = getCtx();
@@ -20243,8 +20283,8 @@ async function resolveCredentialValue(value) {
20243
20283
  if (value === "-")
20244
20284
  return readStdin();
20245
20285
  if (value.startsWith("@")) {
20246
- const fs11 = await import("node:fs/promises");
20247
- return (await fs11.readFile(value.slice(1), "utf-8")).trim();
20286
+ const fs = await import("node:fs/promises");
20287
+ return (await fs.readFile(value.slice(1), "utf-8")).trim();
20248
20288
  }
20249
20289
  return value;
20250
20290
  }
@@ -20279,19 +20319,19 @@ async function readStdin() {
20279
20319
 
20280
20320
  // src/commands/notifications.ts
20281
20321
  var CHANNEL_IDS = new Set(["resend", "slack_webhook", "webhook"]);
20282
- function registerNotificationCommands(program2) {
20283
- const cmd = program2.command("notifications").description("Manage notification channels (email/Slack/webhook) — issue #116");
20322
+ function registerNotificationCommands(program) {
20323
+ const cmd = program.command("notifications").description("Manage notification channels (email/Slack/webhook) — issue #116");
20284
20324
  function getCtx() {
20285
20325
  const ctx = createContext({
20286
- profileOverride: program2.opts().profile,
20287
- verbose: program2.opts().verbose
20326
+ profileOverride: program.opts().profile,
20327
+ verbose: program.opts().verbose
20288
20328
  });
20289
- if (program2.opts().apiUrl)
20290
- ctx.profile.api_url = program2.opts().apiUrl;
20329
+ if (program.opts().apiUrl)
20330
+ ctx.profile.api_url = program.opts().apiUrl;
20291
20331
  return ctx;
20292
20332
  }
20293
20333
  function isJson() {
20294
- return !!program2.opts().json;
20334
+ return !!program.opts().json;
20295
20335
  }
20296
20336
  cmd.command("channels").description("List available notification channel types").action(async () => {
20297
20337
  const ctx = getCtx();
@@ -20359,8 +20399,8 @@ Notification connections`));
20359
20399
  if (credentialValue === "-") {
20360
20400
  credentialValue = await readStdin2();
20361
20401
  } else if (credentialValue?.startsWith("@")) {
20362
- const fs11 = await import("node:fs/promises");
20363
- credentialValue = await fs11.readFile(credentialValue.slice(1), "utf-8");
20402
+ const fs = await import("node:fs/promises");
20403
+ credentialValue = await fs.readFile(credentialValue.slice(1), "utf-8");
20364
20404
  }
20365
20405
  if (!credentialValue) {
20366
20406
  throw new Error("--credential-value is required (use '-' for stdin or '@path' for file).");
@@ -20410,11 +20450,11 @@ async function readStdin2() {
20410
20450
 
20411
20451
  // src/commands/messaging.ts
20412
20452
  init_errors();
20413
- async function messagingFetch(baseUrl, path9, opts) {
20414
- if (/^(https?:)?\/\//i.test(path9)) {
20453
+ async function messagingFetch(baseUrl, path, opts) {
20454
+ if (/^(https?:)?\/\//i.test(path)) {
20415
20455
  throw new CLIError("Absolute URL paths are not allowed", 1 /* Error */);
20416
20456
  }
20417
- const url = new URL(path9, baseUrl);
20457
+ const url = new URL(path, baseUrl);
20418
20458
  const headers = {
20419
20459
  "Content-Type": "application/json"
20420
20460
  };
@@ -20440,19 +20480,19 @@ async function messagingFetch(baseUrl, path9, opts) {
20440
20480
  }
20441
20481
  return res.json();
20442
20482
  }
20443
- function registerMessagingCommands(program2) {
20444
- const cmd = program2.command("messaging").description("Messaging provider commands (SMS, WhatsApp)");
20483
+ function registerMessagingCommands(program) {
20484
+ const cmd = program.command("messaging").description("Messaging provider commands (SMS, WhatsApp)");
20445
20485
  function getCtx() {
20446
20486
  const ctx = createContext({
20447
- profileOverride: program2.opts().profile,
20448
- verbose: program2.opts().verbose
20487
+ profileOverride: program.opts().profile,
20488
+ verbose: program.opts().verbose
20449
20489
  });
20450
- if (program2.opts().apiUrl)
20451
- ctx.profile.api_url = program2.opts().apiUrl;
20490
+ if (program.opts().apiUrl)
20491
+ ctx.profile.api_url = program.opts().apiUrl;
20452
20492
  return ctx;
20453
20493
  }
20454
20494
  function isJson() {
20455
- return !!program2.opts().json;
20495
+ return !!program.opts().json;
20456
20496
  }
20457
20497
  cmd.command("health").description("Check messaging provider health").action(async () => {
20458
20498
  const ctx = getCtx();
@@ -20712,7 +20752,7 @@ function renderSnippet(options) {
20712
20752
  return renderEsmSnippet(options);
20713
20753
  }
20714
20754
  }
20715
- function parseKeyValueFlags(items, allowedKeys, label, parser2) {
20755
+ function parseKeyValueFlags(items, allowedKeys, label, parser) {
20716
20756
  const result = {};
20717
20757
  for (const item of items ?? []) {
20718
20758
  const idx = item.indexOf("=");
@@ -20727,7 +20767,7 @@ function parseKeyValueFlags(items, allowedKeys, label, parser2) {
20727
20767
  if (!allowedKeys.includes(key)) {
20728
20768
  throw new CLIError(`Unsupported ${label} key: ${key}`, 4 /* Validation */, `Allowed keys: ${allowedKeys.join(", ")}`);
20729
20769
  }
20730
- result[key] = parser2(value);
20770
+ result[key] = parser(value);
20731
20771
  }
20732
20772
  return result;
20733
20773
  }
@@ -20940,12 +20980,12 @@ function formatDate(val) {
20940
20980
  function clientKey(c) {
20941
20981
  return String(c.client_key ?? c.keycloak_client_id ?? "-");
20942
20982
  }
20943
- function setClientKeyPayload(body, clientKey2, keycloakClientId) {
20944
- if (clientKey2 && keycloakClientId && clientKey2 !== keycloakClientId) {
20983
+ function setClientKeyPayload(body, clientKey, keycloakClientId) {
20984
+ if (clientKey && keycloakClientId && clientKey !== keycloakClientId) {
20945
20985
  throw new CLIError("--client-key and --keycloak-client-id must match when both are provided.", 4 /* Validation */, "Use --client-key for new commands; --keycloak-client-id is deprecated.");
20946
20986
  }
20947
- if (clientKey2)
20948
- body.client_key = clientKey2;
20987
+ if (clientKey)
20988
+ body.client_key = clientKey;
20949
20989
  if (keycloakClientId)
20950
20990
  body.keycloak_client_id = keycloakClientId;
20951
20991
  }
@@ -21054,17 +21094,17 @@ async function revokeEmbedCredentials(ctx, clientId) {
21054
21094
  return ctx.api.del(`${API}/${clientId}/embed-credentials`);
21055
21095
  }
21056
21096
  async function createEmbedCredentialApi(ctx, credentials) {
21057
- const [{ MarthaAPIClient: MarthaAPIClient2 }, { loginClientCredentials: loginClientCredentials2 }] = await Promise.all([
21097
+ const [{ MarthaAPIClient }, { loginClientCredentials }] = await Promise.all([
21058
21098
  Promise.resolve().then(() => (init_api_client(), exports_api_client)),
21059
21099
  Promise.resolve().then(() => (init_client_credentials(), exports_client_credentials))
21060
21100
  ]);
21061
- const tokens = await loginClientCredentials2({
21101
+ const tokens = await loginClientCredentials({
21062
21102
  keycloakUrl: ctx.profile.keycloak_url,
21063
21103
  realm: ctx.profile.keycloak_realm,
21064
21104
  clientId: credentials.service_account_client_id,
21065
21105
  clientSecret: credentials.client_secret
21066
21106
  });
21067
- return new MarthaAPIClient2({
21107
+ return new MarthaAPIClient({
21068
21108
  baseUrl: ctx.profile.api_url,
21069
21109
  getAccessToken: async () => tokens.access_token
21070
21110
  });
@@ -21076,20 +21116,20 @@ async function grantAccess(ctx, clientId, type, defName) {
21076
21116
  const body = type === "function" ? { function_id: defId } : type === "workflow" ? { workflow_id: defId } : { agent_name: defId };
21077
21117
  await ctx.api.post(endpoint, body);
21078
21118
  }
21079
- function registerClientCommands(program2) {
21080
- const cmd = program2.command("clients").description("Manage chat clients and access control");
21119
+ function registerClientCommands(program) {
21120
+ const cmd = program.command("clients").description("Manage chat clients and access control");
21081
21121
  function getCtx() {
21082
21122
  const ctx = createContext({
21083
- profileOverride: program2.opts().profile,
21084
- verbose: program2.opts().verbose
21123
+ profileOverride: program.opts().profile,
21124
+ verbose: program.opts().verbose
21085
21125
  });
21086
- if (program2.opts().apiUrl) {
21087
- ctx.profile.api_url = program2.opts().apiUrl;
21126
+ if (program.opts().apiUrl) {
21127
+ ctx.profile.api_url = program.opts().apiUrl;
21088
21128
  }
21089
21129
  return ctx;
21090
21130
  }
21091
21131
  function isJson() {
21092
- return !!program2.opts().json;
21132
+ return !!program.opts().json;
21093
21133
  }
21094
21134
  cmd.command("list").description("List clients").option("--limit <n>", "Max results", "50").action(async (opts) => {
21095
21135
  const ctx = getCtx();
@@ -21508,10 +21548,10 @@ Embed-token mode needs backend credentials. Provision them with:
21508
21548
  let tempCredentials;
21509
21549
  try {
21510
21550
  if (opts.createTempClient) {
21511
- const key2 = `cli-smoke-${Date.now()}`;
21551
+ const key = `cli-smoke-${Date.now()}`;
21512
21552
  client = await ctx.api.post(API, {
21513
21553
  name: `CLI Smoke ${Date.now()}`,
21514
- client_key: key2,
21554
+ client_key: key,
21515
21555
  embed_enabled: true,
21516
21556
  embed_allowed_origins: [origin],
21517
21557
  embed_default_mode: "launcher",
@@ -21647,16 +21687,16 @@ ${rows.length} grant(s)`));
21647
21687
  }
21648
21688
 
21649
21689
  // src/commands/models.ts
21650
- function registerModelsCommand(program2) {
21651
- program2.command("models").description("List available LLM models").option("--provider <name>", "Filter by provider (e.g. anthropic, openai)").action(async (opts) => {
21690
+ function registerModelsCommand(program) {
21691
+ program.command("models").description("List available LLM models").option("--provider <name>", "Filter by provider (e.g. anthropic, openai)").action(async (opts) => {
21652
21692
  const ctx = createContext({
21653
- profileOverride: program2.opts().profile,
21654
- verbose: program2.opts().verbose
21693
+ profileOverride: program.opts().profile,
21694
+ verbose: program.opts().verbose
21655
21695
  });
21656
- if (program2.opts().apiUrl) {
21657
- ctx.profile.api_url = program2.opts().apiUrl;
21696
+ if (program.opts().apiUrl) {
21697
+ ctx.profile.api_url = program.opts().apiUrl;
21658
21698
  }
21659
- const isJson = !!program2.opts().json;
21699
+ const isJson = !!program.opts().json;
21660
21700
  const params = new URLSearchParams;
21661
21701
  if (opts.provider)
21662
21702
  params.set("provider", opts.provider.toLowerCase());
@@ -21708,16 +21748,16 @@ var GROUPINGS = ["day", "agent", "model", "surface", "billing_owner"];
21708
21748
  function usd(value) {
21709
21749
  return value == null ? "-" : `$${Number(value).toFixed(4)}`;
21710
21750
  }
21711
- function registerSpendCommand(program2) {
21712
- program2.command("spend").description("LLM spend for a tenant, from Martha's own ledger").option("--tenant <id>", "Tenant (defaults to your own; others need super-admin)").option("--group-by <dim>", `One of: ${GROUPINGS.join(", ")}`, "day").option("--since <YYYY-MM-DD>", "Inclusive UTC start day").option("--until <YYYY-MM-DD>", "Exclusive UTC end day").action(async (opts) => {
21751
+ function registerSpendCommand(program) {
21752
+ program.command("spend").description("LLM spend for a tenant, from Martha's own ledger").option("--tenant <id>", "Tenant (defaults to your own; others need super-admin)").option("--group-by <dim>", `One of: ${GROUPINGS.join(", ")}`, "day").option("--since <YYYY-MM-DD>", "Inclusive UTC start day").option("--until <YYYY-MM-DD>", "Exclusive UTC end day").action(async (opts) => {
21713
21753
  const ctx = createContext({
21714
- profileOverride: program2.opts().profile,
21715
- verbose: program2.opts().verbose
21754
+ profileOverride: program.opts().profile,
21755
+ verbose: program.opts().verbose
21716
21756
  });
21717
- if (program2.opts().apiUrl) {
21718
- ctx.profile.api_url = program2.opts().apiUrl;
21757
+ if (program.opts().apiUrl) {
21758
+ ctx.profile.api_url = program.opts().apiUrl;
21719
21759
  }
21720
- const isJson = !!program2.opts().json;
21760
+ const isJson = !!program.opts().json;
21721
21761
  if (!GROUPINGS.includes(opts.groupBy)) {
21722
21762
  throw new CLIError(`--group-by must be one of: ${GROUPINGS.join(", ")}`, 4 /* Validation */);
21723
21763
  }
@@ -21768,22 +21808,22 @@ function oneOf(value, allowed, flag) {
21768
21808
  throw new CLIError(`${flag} must be one of: ${allowed.join(", ")}`, 4 /* Validation */);
21769
21809
  }
21770
21810
  }
21771
- function registerBudgetCommands(program2) {
21772
- const budget = program2.command("budget").description("LLM spend ceilings for a tenant");
21811
+ function registerBudgetCommands(program) {
21812
+ const budget = program.command("budget").description("LLM spend ceilings for a tenant");
21773
21813
  const context = () => {
21774
21814
  const ctx = createContext({
21775
- profileOverride: program2.opts().profile,
21776
- verbose: program2.opts().verbose
21815
+ profileOverride: program.opts().profile,
21816
+ verbose: program.opts().verbose
21777
21817
  });
21778
- if (program2.opts().apiUrl)
21779
- ctx.profile.api_url = program2.opts().apiUrl;
21818
+ if (program.opts().apiUrl)
21819
+ ctx.profile.api_url = program.opts().apiUrl;
21780
21820
  return ctx;
21781
21821
  };
21782
- const path9 = async (ctx, tenant) => `/api/admin/tenants/${encodeURIComponent(tenant ?? await ctx.getTenantId())}/llm-budgets`;
21822
+ const path = async (ctx, tenant) => `/api/admin/tenants/${encodeURIComponent(tenant ?? await ctx.getTenantId())}/llm-budgets`;
21783
21823
  budget.command("list").description("List the tenant's ceilings").option("--tenant <id>", "Tenant (defaults to your own)").action(async (opts) => {
21784
21824
  const ctx = context();
21785
- const data = await ctx.api.get(await path9(ctx, opts.tenant));
21786
- if (program2.opts().json) {
21825
+ const data = await ctx.api.get(await path(ctx, opts.tenant));
21826
+ if (program.opts().json) {
21787
21827
  console.log(JSON.stringify(data, null, 2));
21788
21828
  return;
21789
21829
  }
@@ -21803,22 +21843,22 @@ function registerBudgetCommands(program2) {
21803
21843
  throw new CLIError("--limit must be a non-negative USD amount", 4 /* Validation */);
21804
21844
  }
21805
21845
  const ctx = context();
21806
- const saved = await ctx.api.put(await path9(ctx, opts.tenant), {
21846
+ const saved = await ctx.api.put(await path(ctx, opts.tenant), {
21807
21847
  period: opts.period,
21808
21848
  limit_usd: opts.limit,
21809
21849
  action: opts.action,
21810
21850
  agent_id: opts.agent ?? null,
21811
21851
  note: opts.note ?? null
21812
21852
  });
21813
- if (program2.opts().json)
21853
+ if (program.opts().json)
21814
21854
  console.log(JSON.stringify(saved, null, 2));
21815
21855
  else
21816
21856
  console.log(`${saved.id} ${saved.period} $${saved.limit_usd} -> ${saved.action}`);
21817
21857
  });
21818
21858
  budget.command("rm <budgetId>").description("Delete a ceiling").option("--tenant <id>", "Tenant (defaults to your own)").action(async (budgetId, opts) => {
21819
21859
  const ctx = context();
21820
- await ctx.api.del(`${await path9(ctx, opts.tenant)}/${encodeURIComponent(budgetId)}`);
21821
- if (program2.opts().json)
21860
+ await ctx.api.del(`${await path(ctx, opts.tenant)}/${encodeURIComponent(budgetId)}`);
21861
+ if (program.opts().json)
21822
21862
  console.log(JSON.stringify({ deleted: budgetId }));
21823
21863
  else
21824
21864
  console.log(`deleted ${budgetId}`);
@@ -21863,19 +21903,19 @@ function parseCollectionRefs(csv) {
21863
21903
  return [];
21864
21904
  return csv.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
21865
21905
  }
21866
- function registerWikiCommands(program2) {
21867
- const cmd = program2.command("wiki").description("Manage wikis: list/create/delete wikis, browse pages, search, schema, settings (#631)");
21906
+ function registerWikiCommands(program) {
21907
+ const cmd = program.command("wiki").description("Manage wikis: list/create/delete wikis, browse pages, search, schema, settings (#631)");
21868
21908
  function getCtx() {
21869
21909
  const ctx = createContext({
21870
- profileOverride: program2.opts().profile,
21871
- verbose: program2.opts().verbose
21910
+ profileOverride: program.opts().profile,
21911
+ verbose: program.opts().verbose
21872
21912
  });
21873
- if (program2.opts().apiUrl)
21874
- ctx.profile.api_url = program2.opts().apiUrl;
21913
+ if (program.opts().apiUrl)
21914
+ ctx.profile.api_url = program.opts().apiUrl;
21875
21915
  return ctx;
21876
21916
  }
21877
21917
  function isJson() {
21878
- return !!program2.opts().json;
21918
+ return !!program.opts().json;
21879
21919
  }
21880
21920
  cmd.command("list").description("List the tenant's wikis (only those you can see)").action(async () => {
21881
21921
  const ctx = getCtx();
@@ -21975,16 +22015,16 @@ ${wikis.length} wiki${wikis.length === 1 ? "" : "s"}`));
21975
22015
  console.log(source_default.dim(`
21976
22016
  ${pages.length} pages`));
21977
22017
  });
21978
- cmd.command("get <path>").description("Fetch the raw markdown body of a wiki page").option("--wiki <slug>", "Wiki slug (default: the tenant default wiki)").option("--out <file>", "Write body to file instead of stdout").action(async (path9, opts) => {
22018
+ cmd.command("get <path>").description("Fetch the raw markdown body of a wiki page").option("--wiki <slug>", "Wiki slug (default: the tenant default wiki)").option("--out <file>", "Write body to file instead of stdout").action(async (path, opts) => {
21979
22019
  const ctx = getCtx();
21980
- const safe = path9.split("/").map(encodeURIComponent).join("/");
22020
+ const safe = path.split("/").map(encodeURIComponent).join("/");
21981
22021
  const slug = encodeURIComponent(opts.wiki ?? DEFAULT_WIKI_SLUG);
21982
22022
  const endpoint = `/api/wiki/${slug}/pages/${safe}`;
21983
22023
  const resp = await ctx.api.getRaw(endpoint, {
21984
22024
  headers: { Accept: "text/markdown,*/*" }
21985
22025
  });
21986
22026
  if (resp.status === 404) {
21987
- throw new CLIError(`page not found: ${path9}`, 3 /* NotFound */);
22027
+ throw new CLIError(`page not found: ${path}`, 3 /* NotFound */);
21988
22028
  }
21989
22029
  if (!resp.ok) {
21990
22030
  const detail = await resp.text();
@@ -21996,12 +22036,12 @@ ${pages.length} pages`));
21996
22036
  if (!isJson()) {
21997
22037
  console.log(source_default.dim(`wrote ${body.length} bytes to ${opts.out}`));
21998
22038
  } else {
21999
- console.log(JSON.stringify({ path: path9, bytes: body.length, file: opts.out }));
22039
+ console.log(JSON.stringify({ path, bytes: body.length, file: opts.out }));
22000
22040
  }
22001
22041
  return;
22002
22042
  }
22003
22043
  if (isJson()) {
22004
- console.log(JSON.stringify({ path: path9, body, etag: resp.headers.get("ETag") }));
22044
+ console.log(JSON.stringify({ path, body, etag: resp.headers.get("ETag") }));
22005
22045
  } else {
22006
22046
  process.stdout.write(body);
22007
22047
  }
@@ -22178,17 +22218,17 @@ ${pages.length} pages`));
22178
22218
 
22179
22219
  // src/commands/mcp.ts
22180
22220
  init_errors();
22181
- function registerMCPCommands(program2) {
22182
- const cmd = program2.command("mcp").description("Discover and call MCP tools");
22221
+ function registerMCPCommands(program) {
22222
+ const cmd = program.command("mcp").description("Discover and call MCP tools");
22183
22223
  function getCtx() {
22184
22224
  return createContext({
22185
- profileOverride: program2.opts().profile,
22186
- apiUrlOverride: program2.opts().apiUrl,
22187
- verbose: program2.opts().verbose
22225
+ profileOverride: program.opts().profile,
22226
+ apiUrlOverride: program.opts().apiUrl,
22227
+ verbose: program.opts().verbose
22188
22228
  });
22189
22229
  }
22190
22230
  function isJson() {
22191
- return !!program2.opts().json;
22231
+ return !!program.opts().json;
22192
22232
  }
22193
22233
  cmd.command("discover").description("Discover tools from an MCP server").option("--url <serverUrl>", "Direct MCP Streamable HTTP URL").option("--connection <connectionId>", "Martha connection UUID").option("--connection-ref <connectionRef>", "Martha connection reference").option("--force-refresh", "Bypass cached discovery").action(async (opts) => {
22194
22234
  const ctx = getCtx();
@@ -22482,7 +22522,7 @@ async function pollConnectionActive(ctx, connectionId) {
22482
22522
  });
22483
22523
  if (conn?.status === "active")
22484
22524
  return;
22485
- await new Promise((resolve2) => setTimeout(resolve2, intervalMs));
22525
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
22486
22526
  }
22487
22527
  throw new CLIError(`Timed out waiting for OAuth authorization (${Math.round(timeoutMs / 1000)}s).`, 1 /* Error */, "The browser consent may not have completed. Re-run to try again, or check " + "the connection status in the admin UI.");
22488
22528
  }
@@ -22544,7 +22584,7 @@ async function pollExecution(ctx, executionId, timeoutMs) {
22544
22584
  if (["completed", "failed", "cancelled", "timeout"].includes(last.status)) {
22545
22585
  return last;
22546
22586
  }
22547
- await new Promise((resolve2) => setTimeout(resolve2, 1000));
22587
+ await new Promise((resolve) => setTimeout(resolve, 1000));
22548
22588
  }
22549
22589
  throw new CLIError(`Timed out waiting for MCP workflow execution ${executionId}`, 1 /* Error */, last ? `Last status: ${last.status}` : undefined);
22550
22590
  }
@@ -22672,8 +22712,8 @@ async function resolveCredentialFlag(value) {
22672
22712
  return Buffer.concat(chunks).toString("utf-8").trim();
22673
22713
  }
22674
22714
  if (value.startsWith("@")) {
22675
- const fs12 = await import("node:fs/promises");
22676
- return (await fs12.readFile(value.slice(1), "utf-8")).trim();
22715
+ const fs = await import("node:fs/promises");
22716
+ return (await fs.readFile(value.slice(1), "utf-8")).trim();
22677
22717
  }
22678
22718
  return value;
22679
22719
  }
@@ -22689,16 +22729,16 @@ function assertOneOf(value, allowed, flag) {
22689
22729
  throw new CLIError(`${flag} must be one of: ${allowed.join(", ")}`, 4 /* Validation */);
22690
22730
  }
22691
22731
  }
22692
- function registerPolicyCommands(program2) {
22693
- const cmd = program2.command("policy").description("Manage the tenant's invoke-time capability policy");
22732
+ function registerPolicyCommands(program) {
22733
+ const cmd = program.command("policy").description("Manage the tenant's invoke-time capability policy");
22694
22734
  function getCtx() {
22695
22735
  return createContext({
22696
- profileOverride: program2.opts().profile,
22697
- apiUrlOverride: program2.opts().apiUrl,
22698
- verbose: program2.opts().verbose
22736
+ profileOverride: program.opts().profile,
22737
+ apiUrlOverride: program.opts().apiUrl,
22738
+ verbose: program.opts().verbose
22699
22739
  });
22700
22740
  }
22701
- const isJson = () => !!program2.opts().json;
22741
+ const isJson = () => !!program.opts().json;
22702
22742
  cmd.command("show").description("Show the current policy: settings + rules").action(async () => {
22703
22743
  const ctx = getCtx();
22704
22744
  const cfg = await ctx.api.get("/api/admin/policy");
@@ -22811,11 +22851,11 @@ var BASE = "/api/admin/agent-step/trust-roots";
22811
22851
  var FLEET_BASE = "/api/admin/agent-step/fleet";
22812
22852
  function resolveKeyMaterial(value) {
22813
22853
  if (value.startsWith("@")) {
22814
- const path9 = value.slice(1);
22854
+ const path = value.slice(1);
22815
22855
  try {
22816
- return readFileSync3(path9, "utf8").trim();
22856
+ return readFileSync3(path, "utf8").trim();
22817
22857
  } catch (e) {
22818
- throw new CLIError(`Could not read public key file '${path9}': ${e.message}`, 4 /* Validation */);
22858
+ throw new CLIError(`Could not read public key file '${path}': ${e.message}`, 4 /* Validation */);
22819
22859
  }
22820
22860
  }
22821
22861
  return value;
@@ -22838,17 +22878,17 @@ function printOne(tr) {
22838
22878
  if (tr.updated_at)
22839
22879
  console.log(` Updated: ${tr.updated_at}`);
22840
22880
  }
22841
- function registerAgentStepCommands(program2) {
22842
- const cmd = program2.command("agent-step").description("Author agent_step assets (execution_proof trust roots)");
22881
+ function registerAgentStepCommands(program) {
22882
+ const cmd = program.command("agent-step").description("Author agent_step assets (execution_proof trust roots)");
22843
22883
  const roots = cmd.command("trust-roots").description("Manage per-tenant/per-runner attestation trust roots (#1083)");
22844
22884
  function getCtx() {
22845
22885
  return createContext({
22846
- profileOverride: program2.opts().profile,
22847
- apiUrlOverride: program2.opts().apiUrl,
22848
- verbose: program2.opts().verbose
22886
+ profileOverride: program.opts().profile,
22887
+ apiUrlOverride: program.opts().apiUrl,
22888
+ verbose: program.opts().verbose
22849
22889
  });
22850
22890
  }
22851
- const isJson = () => !!program2.opts().json;
22891
+ const isJson = () => !!program.opts().json;
22852
22892
  roots.command("list").description("List the tenant's trust roots").action(async () => {
22853
22893
  const ctx = getCtx();
22854
22894
  const rows = await ctx.api.get(BASE);
@@ -23167,21 +23207,21 @@ var DEFAULT_ENTITY = "document_collection";
23167
23207
  var DEFAULT_ACTION = "read";
23168
23208
  var APPROVAL_ENTITY = "approval";
23169
23209
  var RESOLVE_ACTION = "resolve";
23170
- function registerAuthzCommands(program2) {
23210
+ function registerAuthzCommands(program) {
23171
23211
  function getCtx() {
23172
23212
  const ctx = createContext({
23173
- profileOverride: program2.opts().profile,
23174
- verbose: program2.opts().verbose
23213
+ profileOverride: program.opts().profile,
23214
+ verbose: program.opts().verbose
23175
23215
  });
23176
- if (program2.opts().apiUrl)
23177
- ctx.profile.api_url = program2.opts().apiUrl;
23216
+ if (program.opts().apiUrl)
23217
+ ctx.profile.api_url = program.opts().apiUrl;
23178
23218
  return ctx;
23179
23219
  }
23180
- const isJson = () => !!program2.opts().json;
23181
- registerCollections(program2, getCtx, isJson);
23182
- registerAccess(program2, getCtx, isJson);
23183
- registerGroups(program2, getCtx, isJson);
23184
- registerApprovers(program2, getCtx, isJson);
23220
+ const isJson = () => !!program.opts().json;
23221
+ registerCollections(program, getCtx, isJson);
23222
+ registerAccess(program, getCtx, isJson);
23223
+ registerGroups(program, getCtx, isJson);
23224
+ registerApprovers(program, getCtx, isJson);
23185
23225
  }
23186
23226
  function renderGrantsTable(resp) {
23187
23227
  if (resp.grants.length === 0) {
@@ -23196,8 +23236,8 @@ function renderGrantsTable(resp) {
23196
23236
  ` + lines.join(`
23197
23237
  `);
23198
23238
  }
23199
- function registerCollections(program2, getCtx, isJson) {
23200
- const cmd = program2.command("collections").description("Manage who can read a document collection (UMS authz)");
23239
+ function registerCollections(program, getCtx, isJson) {
23240
+ const cmd = program.command("collections").description("Manage who can read a document collection (UMS authz)");
23201
23241
  cmd.command("grant <collection>").description("Grant read access on a collection to a principal").requiredOption("--to <type:id>", "user|client|agent|group:<id>").option("--action <action>", "Action to grant", DEFAULT_ACTION).option("--tenant <tenant>", "Target tenant (super-admin only)").action(async (collection, opts) => {
23202
23242
  const ctx = getCtx();
23203
23243
  const json = isJson();
@@ -23267,8 +23307,8 @@ function registerCollections(program2, getCtx, isJson) {
23267
23307
  }
23268
23308
  });
23269
23309
  }
23270
- function registerAccess(program2, getCtx, isJson) {
23271
- const cmd = program2.command("access").description("Generic two-axis grant management (any entity type)");
23310
+ function registerAccess(program, getCtx, isJson) {
23311
+ const cmd = program.command("access").description("Generic two-axis grant management (any entity type)");
23272
23312
  cmd.command("grant").description("Grant access to a principal on an entity/object").requiredOption("--to <type:id>", "user|client|agent|group:<id>").option("--entity <entity_type>", "Entity type", DEFAULT_ENTITY).option("--object <id>", "Object id (omit for a tenant-root see-all grant)").option("--action <action>", "Action", DEFAULT_ACTION).option("--tenant <tenant>", "Target tenant (super-admin only)").action(async (opts) => {
23273
23313
  const ctx = getCtx();
23274
23314
  const json = isJson();
@@ -23342,8 +23382,8 @@ function registerAccess(program2, getCtx, isJson) {
23342
23382
  }
23343
23383
  });
23344
23384
  }
23345
- function registerGroups(program2, getCtx, isJson) {
23346
- const cmd = program2.command("groups").description("Manage UMS-native authz groups (#644)");
23385
+ function registerGroups(program, getCtx, isJson) {
23386
+ const cmd = program.command("groups").description("Manage UMS-native authz groups (#644)");
23347
23387
  cmd.command("create <name>").description("Create a group").option("--tenant <tenant>", "Target tenant (super-admin only)").action(async (name, opts) => {
23348
23388
  const ctx = getCtx();
23349
23389
  const json = isJson();
@@ -23439,8 +23479,8 @@ function registerGroups(program2, getCtx, isJson) {
23439
23479
  }
23440
23480
  });
23441
23481
  }
23442
- function registerApprovers(program2, getCtx, isJson) {
23443
- const cmd = program2.command("approvers").description("Manage who may resolve approval cases in the tenant (UMS approval/resolve). " + "Noun-first sugar over `access` on the approval entity.");
23482
+ function registerApprovers(program, getCtx, isJson) {
23483
+ const cmd = program.command("approvers").description("Manage who may resolve approval cases in the tenant (UMS approval/resolve). " + "Noun-first sugar over `access` on the approval entity.");
23444
23484
  cmd.command("add <group>").description("Make a group a tenant approver (its members can resolve approvals)").option("--tenant <tenant>", "Target tenant (super-admin only)").action(async (group, opts) => {
23445
23485
  const ctx = getCtx();
23446
23486
  const json = isJson();
@@ -23867,8 +23907,8 @@ async function askIntents() {
23867
23907
  });
23868
23908
  return parseIntents2(raw);
23869
23909
  }
23870
- function registerInitCommand(program2) {
23871
- program2.command("init").description("Create or update a profile, and optionally bootstrap an access principal").option("--preset <name>", "Preset: cloud or local", "cloud").option("--name <name>", "Profile name (defaults to preset name)").option("--force", "Overwrite an existing profile").option("--api-url <url>", "Override the API URL").option("--keycloak-url <url>", "Override the Keycloak URL").option("--keycloak-realm <realm>", "Override the Keycloak realm").option("--no-interactive", "Skip prompts; use defaults / overrides only").option("--bootstrap", "Provision an intent-scoped principal + grants after saving the profile").option("--mode <mode>", "Bootstrap mode: 'human' (your own client) or 'integration' (service account)").option("--intent <intents...>", "Usage buckets to grant: rag, documents, workflows, custom").option("--workflow <names...>", "Workflow name(s) to grant (workflows/custom intent)").option("--function <names...>", "Extra function name(s) to grant (custom intent)").option("--label <name>", "Integration mode: label for the SA client id").option("--agent", "Also provision a personal chat copilot (human mode) and set it as the default").option("--agent-name <name>", "Copilot agent name (defaults to copilot-{user})").option("--model <id>", "Copilot LLM model id (defaults to the platform default)").option("--host-runner", "Also set the copilot up to run host tools on THIS machine (mints a runner key + prints the `martha runner` command)").option("--yes", "Acknowledge non-interactive bootstrap side effects").action(async (opts, command) => {
23910
+ function registerInitCommand(program) {
23911
+ program.command("init").description("Create or update a profile, and optionally bootstrap an access principal").option("--preset <name>", "Preset: cloud or local", "cloud").option("--name <name>", "Profile name (defaults to preset name)").option("--force", "Overwrite an existing profile").option("--api-url <url>", "Override the API URL").option("--keycloak-url <url>", "Override the Keycloak URL").option("--keycloak-realm <realm>", "Override the Keycloak realm").option("--no-interactive", "Skip prompts; use defaults / overrides only").option("--bootstrap", "Provision an intent-scoped principal + grants after saving the profile").option("--mode <mode>", "Bootstrap mode: 'human' (your own client) or 'integration' (service account)").option("--intent <intents...>", "Usage buckets to grant: rag, documents, workflows, custom").option("--workflow <names...>", "Workflow name(s) to grant (workflows/custom intent)").option("--function <names...>", "Extra function name(s) to grant (custom intent)").option("--label <name>", "Integration mode: label for the SA client id").option("--agent", "Also provision a personal chat copilot (human mode) and set it as the default").option("--agent-name <name>", "Copilot agent name (defaults to copilot-{user})").option("--model <id>", "Copilot LLM model id (defaults to the platform default)").option("--host-runner", "Also set the copilot up to run host tools on THIS machine (mints a runner key + prints the `martha runner` command)").option("--yes", "Acknowledge non-interactive bootstrap side effects").action(async (opts, command) => {
23872
23912
  const globals = command.parent?.opts() ?? {};
23873
23913
  await initCommand({ ...opts, json: !!globals.json });
23874
23914
  });
@@ -23876,11 +23916,18 @@ function registerInitCommand(program2) {
23876
23916
 
23877
23917
  // src/commands/doctor.ts
23878
23918
  var FETCH_TIMEOUT_MS = 5000;
23879
- function resolveApiUrl(base, path9) {
23880
- return new URL(path9, base).toString();
23919
+ function resolveApiUrl(base, path) {
23920
+ return new URL(path, base).toString();
23921
+ }
23922
+ function authHeaders(ctx, token) {
23923
+ const tenant = ctx.tenantFor(token);
23924
+ return {
23925
+ Authorization: `Bearer ${token}`,
23926
+ ...tenant ? { "X-Martha-Tenant": tenant } : {}
23927
+ };
23881
23928
  }
23882
- function apiUrl(ctx, path9) {
23883
- return resolveApiUrl(ctx.profile.api_url, path9);
23929
+ function apiUrl(ctx, path) {
23930
+ return resolveApiUrl(ctx.profile.api_url, path);
23884
23931
  }
23885
23932
  async function fetchJSON(url, init) {
23886
23933
  const res = await fetch(url, {
@@ -24035,7 +24082,7 @@ async function checkAuthenticatedRequest(ctx) {
24035
24082
  const url = apiUrl(ctx, "/api/admin/definitions/agents");
24036
24083
  try {
24037
24084
  const { ok, status } = await fetchJSON(url, {
24038
- headers: { Authorization: `Bearer ${tokens.access_token}` }
24085
+ headers: authHeaders(ctx, tokens.access_token)
24039
24086
  });
24040
24087
  if (ok) {
24041
24088
  return { name: "API auth", status: "pass", detail: "token accepted" };
@@ -24080,7 +24127,7 @@ async function checkHostRunners(ctx) {
24080
24127
  const url = apiUrl(ctx, "/api/admin/definitions/agents/runner-presence");
24081
24128
  try {
24082
24129
  const { ok, status, json } = await fetchJSON(url, {
24083
- headers: { Authorization: `Bearer ${tokens.access_token}` }
24130
+ headers: authHeaders(ctx, tokens.access_token)
24084
24131
  });
24085
24132
  if (!ok) {
24086
24133
  return {
@@ -24162,14 +24209,14 @@ async function doctorCommand(ctx) {
24162
24209
  console.log(source_default.green(` All checks passed.`));
24163
24210
  }
24164
24211
  }
24165
- function registerDoctorCommand(program2) {
24166
- program2.command("doctor").description("Run diagnostic checks against the active profile").action(async () => {
24212
+ function registerDoctorCommand(program) {
24213
+ program.command("doctor").description("Run diagnostic checks against the active profile").action(async () => {
24167
24214
  const ctx = createContext({
24168
- profileOverride: program2.opts().profile,
24169
- verbose: program2.opts().verbose
24215
+ profileOverride: program.opts().profile,
24216
+ verbose: program.opts().verbose
24170
24217
  });
24171
- if (program2.opts().apiUrl) {
24172
- ctx.profile.api_url = program2.opts().apiUrl;
24218
+ if (program.opts().apiUrl) {
24219
+ ctx.profile.api_url = program.opts().apiUrl;
24173
24220
  }
24174
24221
  await doctorCommand(ctx);
24175
24222
  });
@@ -24202,8 +24249,8 @@ async function skillCommand() {
24202
24249
  const body = fs12.readFileSync(skillPath, "utf-8");
24203
24250
  process.stdout.write(body);
24204
24251
  }
24205
- function registerSkillCommand(program2) {
24206
- program2.command("skill").description("Print the bundled agent skill reference (SKILL.md) to stdout").action(async () => {
24252
+ function registerSkillCommand(program) {
24253
+ program.command("skill").description("Print the bundled agent skill reference (SKILL.md) to stdout").action(async () => {
24207
24254
  await skillCommand();
24208
24255
  });
24209
24256
  }
@@ -24273,9 +24320,9 @@ function resolveManager(explicit) {
24273
24320
  return fromInstall;
24274
24321
  return process.versions?.bun ? "bun" : "npm";
24275
24322
  }
24276
- function registerUpdateCommand(program2) {
24277
- program2.command("update").description("Update the Martha CLI to the latest published version").option("--check", "Report whether a newer version is available; don't install").option("--yes", "Skip the confirmation prompt").option("--manager <pm>", "Package manager to use: npm | bun (default: auto)").action(async (opts) => {
24278
- const isJson = !!program2.opts().json;
24323
+ function registerUpdateCommand(program) {
24324
+ program.command("update").description("Update the Martha CLI to the latest published version").option("--check", "Report whether a newer version is available; don't install").option("--yes", "Skip the confirmation prompt").option("--manager <pm>", "Package manager to use: npm | bun (default: auto)").action(async (opts) => {
24325
+ const isJson = !!program.opts().json;
24279
24326
  const latest = await fetchLatest();
24280
24327
  if (!latest) {
24281
24328
  throw new CLIError(`Could not reach the npm registry to determine the latest version (${LATEST_URL}). Check your network.`, 1 /* Error */);
@@ -24338,8 +24385,9 @@ function registerUpdateCommand(program2) {
24338
24385
  }
24339
24386
 
24340
24387
  // src/index.ts
24341
- var program2 = new Command;
24342
- program2.name("martha").description("Terminal-first client for the Martha AI platform").version(CLI_VERSION).option("--profile <name>", "Use a named profile").option("--json", "Machine-readable JSON output").option("--quiet", "Suppress non-essential output").option("--verbose", "Verbose logging").option("--no-color", "Disable color output").option("--api-url <url>", "Override API base URL");
24388
+ var program2 = new Command2;
24389
+ program2.name("martha").description("Terminal-first client for the Martha AI platform").version(CLI_VERSION).option("--profile <name>", "Use a named profile").option("--json", "Machine-readable JSON output").option("--quiet", "Suppress non-essential output").option("--verbose", "Verbose logging").option("--no-color", "Disable color output").option("--api-url <url>", "Override API base URL").option("--org <tenant>", "Organization to act in (X-Martha-Tenant); needed when your token authorizes several");
24390
+ registerOrgSelection(program2);
24343
24391
  program2.command("status").description("Check connection and auth status").action(async () => {
24344
24392
  const ctx = createContext({
24345
24393
  profileOverride: program2.opts().profile,