bdy 1.25.2-stage → 1.25.4-dev

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 (142) hide show
  1. package/distTs/package.json +20 -19
  2. package/distTs/src/agent/socket/tunnel.js +2 -0
  3. package/distTs/src/cliCommand.js +28 -0
  4. package/distTs/src/cliIndex.js +3 -1
  5. package/distTs/src/command/agent/proxy/status.js +9 -2
  6. package/distTs/src/command/agent/status.js +22 -6
  7. package/distTs/src/command/agent/tags/get.js +9 -2
  8. package/distTs/src/command/agent/target/status.js +9 -2
  9. package/distTs/src/command/agent/tunnel/http.js +4 -3
  10. package/distTs/src/command/agent/tunnel/list.js +7 -3
  11. package/distTs/src/command/agent/tunnel/remove.js +1 -2
  12. package/distTs/src/command/agent/tunnel/start.js +1 -2
  13. package/distTs/src/command/agent/tunnel/status.js +14 -3
  14. package/distTs/src/command/agent/tunnel/tcp.js +4 -3
  15. package/distTs/src/command/agent/tunnel/tls.js +4 -3
  16. package/distTs/src/command/agent/tunnel.js +11 -8
  17. package/distTs/src/command/agent/version.js +7 -2
  18. package/distTs/src/command/api/info.js +50 -2
  19. package/distTs/src/command/api/list.js +18 -2
  20. package/distTs/src/command/artifact/composer/publish.js +4 -2
  21. package/distTs/src/command/artifact/create.js +9 -2
  22. package/distTs/src/command/artifact/delete.js +4 -2
  23. package/distTs/src/command/artifact/docker.js +1 -1
  24. package/distTs/src/command/artifact/download.js +4 -2
  25. package/distTs/src/command/artifact/get.js +3 -1
  26. package/distTs/src/command/artifact/list.js +3 -1
  27. package/distTs/src/command/artifact/publish.js +24 -24
  28. package/distTs/src/command/artifact/version/create.js +9 -2
  29. package/distTs/src/command/artifact/version/delete.js +4 -2
  30. package/distTs/src/command/artifact/version/get.js +4 -2
  31. package/distTs/src/command/artifact/version/list.js +4 -2
  32. package/distTs/src/command/config/get/tunnel.js +8 -3
  33. package/distTs/src/command/config/get/tunnels.js +8 -3
  34. package/distTs/src/command/crawl/link.js +3 -2
  35. package/distTs/src/command/crawl/run.js +3 -2
  36. package/distTs/src/command/crawl.js +3 -4
  37. package/distTs/src/command/discover.js +34 -0
  38. package/distTs/src/command/distro/create.js +9 -2
  39. package/distTs/src/command/distro/delete.js +4 -2
  40. package/distTs/src/command/distro/get.js +4 -2
  41. package/distTs/src/command/distro/list.js +4 -2
  42. package/distTs/src/command/distro/route/create.js +9 -2
  43. package/distTs/src/command/distro/route/delete.js +4 -2
  44. package/distTs/src/command/distro/route/get.js +4 -2
  45. package/distTs/src/command/distro/route/list.js +4 -2
  46. package/distTs/src/command/distro/route/update.js +9 -2
  47. package/distTs/src/command/distro/route.js +9 -6
  48. package/distTs/src/command/distro/update.js +9 -2
  49. package/distTs/src/command/distro.js +14 -11
  50. package/distTs/src/command/domain/search.js +31 -10
  51. package/distTs/src/command/environment/create.js +6 -2
  52. package/distTs/src/command/environment/delete.js +1 -2
  53. package/distTs/src/command/environment/get.js +3 -2
  54. package/distTs/src/command/environment/list.js +1 -2
  55. package/distTs/src/command/environment/update.js +6 -2
  56. package/distTs/src/command/mcp.js +3 -2
  57. package/distTs/src/command/pipeline/create.js +4 -2
  58. package/distTs/src/command/pipeline/delete.js +4 -2
  59. package/distTs/src/command/pipeline/get.js +4 -2
  60. package/distTs/src/command/pipeline/list.js +4 -2
  61. package/distTs/src/command/pipeline/run/approve.js +5 -3
  62. package/distTs/src/command/pipeline/run/cancel.js +5 -3
  63. package/distTs/src/command/pipeline/run/list.js +4 -2
  64. package/distTs/src/command/pipeline/run/logs.js +5 -3
  65. package/distTs/src/command/pipeline/run/retry.js +5 -3
  66. package/distTs/src/command/pipeline/run/start.js +5 -3
  67. package/distTs/src/command/pipeline/run/status.js +5 -3
  68. package/distTs/src/command/pipeline/run.js +11 -9
  69. package/distTs/src/command/pipeline/update.js +4 -2
  70. package/distTs/src/command/pipeline/yaml.js +4 -2
  71. package/distTs/src/command/pipeline.js +17 -15
  72. package/distTs/src/command/pre.js +2 -1
  73. package/distTs/src/command/sandbox/app/add.js +10 -3
  74. package/distTs/src/command/sandbox/app/list.js +1 -2
  75. package/distTs/src/command/sandbox/app/logs.js +10 -6
  76. package/distTs/src/command/sandbox/app/remove.js +1 -2
  77. package/distTs/src/command/sandbox/app/start.js +1 -2
  78. package/distTs/src/command/sandbox/app/status.js +1 -2
  79. package/distTs/src/command/sandbox/app/stop.js +1 -2
  80. package/distTs/src/command/sandbox/app.js +11 -9
  81. package/distTs/src/command/sandbox/cp.js +3 -2
  82. package/distTs/src/command/sandbox/create.js +16 -7
  83. package/distTs/src/command/sandbox/endpoint/add.js +6 -2
  84. package/distTs/src/command/sandbox/endpoint/delete.js +1 -2
  85. package/distTs/src/command/sandbox/endpoint/get.js +1 -2
  86. package/distTs/src/command/sandbox/endpoint/list.js +1 -2
  87. package/distTs/src/command/sandbox/endpoint.js +8 -5
  88. package/distTs/src/command/sandbox/exec/command.js +15 -31
  89. package/distTs/src/command/sandbox/exec/kill.js +1 -2
  90. package/distTs/src/command/sandbox/exec/list.js +1 -2
  91. package/distTs/src/command/sandbox/exec/logs.js +4 -30
  92. package/distTs/src/command/sandbox/exec/status.js +1 -2
  93. package/distTs/src/command/sandbox/exec.js +9 -6
  94. package/distTs/src/command/sandbox/finishExec.js +33 -0
  95. package/distTs/src/command/sandbox/logs.js +14 -1
  96. package/distTs/src/command/sandbox/snapshot/create.js +10 -3
  97. package/distTs/src/command/sandbox/snapshot/delete.js +1 -2
  98. package/distTs/src/command/sandbox/snapshot/get.js +1 -2
  99. package/distTs/src/command/sandbox/snapshot/list.js +1 -2
  100. package/distTs/src/command/sandbox/snapshot.js +8 -5
  101. package/distTs/src/command/sandbox/ssh.js +3 -2
  102. package/distTs/src/command/target/create.js +8 -2
  103. package/distTs/src/command/target/delete.js +3 -2
  104. package/distTs/src/command/target/exec/command.js +1 -2
  105. package/distTs/src/command/target/exec/kill.js +1 -2
  106. package/distTs/src/command/target/exec/list.js +1 -2
  107. package/distTs/src/command/target/exec/logs.js +15 -3
  108. package/distTs/src/command/target/exec/status.js +1 -2
  109. package/distTs/src/command/target/exec.js +9 -6
  110. package/distTs/src/command/target/get.js +3 -2
  111. package/distTs/src/command/target/list.js +3 -2
  112. package/distTs/src/command/target/update.js +8 -2
  113. package/distTs/src/command/tests/capture.js +3 -2
  114. package/distTs/src/command/tests/unit/link.js +3 -2
  115. package/distTs/src/command/tests/unit/upload.js +3 -2
  116. package/distTs/src/command/tests/unit.js +3 -4
  117. package/distTs/src/command/tests/visual/link.js +3 -2
  118. package/distTs/src/command/tests/visual/session/close.js +3 -2
  119. package/distTs/src/command/tests/visual/session/create.js +3 -2
  120. package/distTs/src/command/tests/visual/session.js +6 -4
  121. package/distTs/src/command/tests/visual/setup.js +3 -2
  122. package/distTs/src/command/tests/visual/upload.js +3 -2
  123. package/distTs/src/command/tests/visual.js +9 -7
  124. package/distTs/src/command/tests.js +12 -10
  125. package/distTs/src/command/tunnel/http.js +3 -2
  126. package/distTs/src/command/tunnel/start.js +3 -2
  127. package/distTs/src/command/tunnel/tcp.js +1 -2
  128. package/distTs/src/command/tunnel/tls.js +1 -2
  129. package/distTs/src/command/tunnel.js +8 -5
  130. package/distTs/src/command/version.js +2 -1
  131. package/distTs/src/command/yaml/actions/info.js +1 -2
  132. package/distTs/src/command/yaml/actions/list.js +1 -2
  133. package/distTs/src/command/yaml/actions.js +3 -4
  134. package/distTs/src/command/yaml/pipeline.js +3 -2
  135. package/distTs/src/command/yaml/validate.js +114 -54
  136. package/distTs/src/command/yaml.js +8 -6
  137. package/distTs/src/discovery.js +119 -0
  138. package/distTs/src/openapi.js +8 -1
  139. package/distTs/src/output.js +39 -0
  140. package/distTs/src/texts.js +1570 -736
  141. package/distTs/src/utils.js +46 -17
  142. package/package.json +20 -19
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.discoverCommands = exports.describeCommand = void 0;
7
+ const cliCommand_1 = __importDefault(require("./cliCommand"));
8
+ const texts_1 = require("./texts");
9
+ const sortedChildren = (command) => command
10
+ .createHelp()
11
+ .visibleCommands(command)
12
+ // Commander may append a synthetic help command. Only expose registered commands.
13
+ .filter((child) => command.commands.includes(child))
14
+ .sort((a, b) => (a.name() < b.name() ? -1 : a.name() > b.name() ? 1 : 0));
15
+ const commandPath = (command) => command.parent
16
+ ? `${commandPath(command.parent)} ${command.name()}`
17
+ : command.name() || 'bdy';
18
+ const optionInfo = (option) => {
19
+ const value = option.flags.match(/[<[]([^>\]]+)[>\]]/)?.[1] ?? null;
20
+ // These are static documentation, never resolved values from opts(), env or config.
21
+ const env = option.envVar ??
22
+ option.description.match(/Can be set via variable:\s*([A-Z][A-Z0-9_]*)/)?.[1] ??
23
+ null;
24
+ const documentedDefault = option.description.match(/Default:\s*(.+)$/)?.[1] ?? null;
25
+ const choices = option.argChoices ??
26
+ (value &&
27
+ /^[A-Za-z][A-Za-z0-9_-]*(?:\|[A-Za-z][A-Za-z0-9_-]*)+$/.test(value)
28
+ ? value.split('|')
29
+ : null);
30
+ return {
31
+ flags: option.flags,
32
+ short: option.short ?? null,
33
+ long: option.long ?? null,
34
+ description: option.description,
35
+ required: option.mandatory,
36
+ value: value
37
+ ? {
38
+ name: value,
39
+ required: option.required,
40
+ variadic: !!option.variadic,
41
+ }
42
+ : null,
43
+ negated: option.negate,
44
+ choices,
45
+ default: option.defaultValue ?? null,
46
+ documented_default: documentedDefault,
47
+ env,
48
+ };
49
+ };
50
+ const describeCommand = (command) => ({
51
+ command: commandPath(command),
52
+ aliases: command.aliases(),
53
+ description: command.description(),
54
+ usage: `${commandPath(command)} ${command.usage()}`.trim(),
55
+ arguments: command.registeredArguments.map((argument) => ({
56
+ name: argument.name(),
57
+ description: argument.description,
58
+ required: argument.required,
59
+ variadic: argument.variadic,
60
+ choices: argument.argChoices ?? null,
61
+ default: argument.defaultValue ?? null,
62
+ })),
63
+ options: command
64
+ .createHelp()
65
+ .visibleOptions(command)
66
+ .filter((option) => option.long !== '--help')
67
+ .map(optionInfo),
68
+ required_scopes: command instanceof cliCommand_1.default ? command.requiredScopes : null,
69
+ examples: command instanceof cliCommand_1.default ? command.examples : [],
70
+ });
71
+ exports.describeCommand = describeCommand;
72
+ const describeTree = (command) => ({
73
+ ...(0, exports.describeCommand)(command),
74
+ subcommands: sortedChildren(command).map(describeTree),
75
+ });
76
+ const summarizeTree = (command) => [
77
+ {
78
+ command: commandPath(command),
79
+ description: command.description(),
80
+ },
81
+ ...sortedChildren(command).flatMap(summarizeTree),
82
+ ];
83
+ const discoverCommands = (program, path, version, full = false) => {
84
+ let selected = program;
85
+ const selectedPath = [];
86
+ for (const part of path) {
87
+ const child = sortedChildren(selected).find((command) => command.name() === part || command.aliases().includes(part));
88
+ if (!child)
89
+ return {
90
+ error: {
91
+ code: 'unknown_command',
92
+ message: (0, texts_1.ERR_DISCOVER_UNKNOWN_COMMAND)(part, commandPath(selected)),
93
+ hint: (0, texts_1.TXT_DISCOVER_COMMAND_HINT)(selectedPath),
94
+ },
95
+ };
96
+ selected = child;
97
+ selectedPath.push(child.name());
98
+ }
99
+ const commands = selected === program ? sortedChildren(program) : [selected];
100
+ const includeDetails = full || (selected !== program && sortedChildren(selected).length === 0);
101
+ return {
102
+ schema_version: 1,
103
+ cli_version: version,
104
+ // Root flags must precede the subcommand; keep them separate from local options.
105
+ ...(includeDetails
106
+ ? {
107
+ global_options: program
108
+ .createHelp()
109
+ .visibleOptions(program)
110
+ .map(optionInfo),
111
+ }
112
+ : {}),
113
+ commands: includeDetails
114
+ ? commands.map(describeTree)
115
+ : commands.flatMap(summarizeTree),
116
+ tips: texts_1.DISCOVERY_TIPS,
117
+ };
118
+ };
119
+ exports.discoverCommands = discoverCommands;
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiEndpoints = apiEndpoints;
4
+ exports.apiSpecification = apiSpecification;
4
5
  const docs_schema_1 = require("@buddy-works/docs-schema");
5
6
  const texts_1 = require("./texts");
6
7
  const utils_1 = require("./utils");
7
8
  const diskCache_1 = require("./diskCache");
8
9
  let held = null;
10
+ let specification = null;
9
11
  async function apiEndpoints(baseUrl) {
10
12
  if (held)
11
13
  return held;
@@ -18,10 +20,15 @@ async function apiEndpoints(baseUrl) {
18
20
  if (!raw)
19
21
  throw new Error(texts_1.ERR_SCHEMA_FETCH_FAILED);
20
22
  try {
21
- held = docs_schema_1.BuddySchema.from({ api: JSON.parse(raw) }).api;
23
+ specification = JSON.parse(raw);
24
+ held = docs_schema_1.BuddySchema.from({ api: specification }).api;
22
25
  }
23
26
  catch {
24
27
  throw new Error(texts_1.ERR_SCHEMA_FETCH_FAILED);
25
28
  }
26
29
  return held;
27
30
  }
31
+ async function apiSpecification(baseUrl) {
32
+ await apiEndpoints(baseUrl);
33
+ return specification;
34
+ }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const texts_1 = require("./texts");
7
7
  const utils_1 = require("./utils");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
+ const node_readline_1 = require("node:readline");
9
10
  let _terminal = null;
10
11
  function getTerminal() {
11
12
  if (!_terminal) {
@@ -134,6 +135,15 @@ class Output {
134
135
  msg += '\n';
135
136
  getTerminal()(msg);
136
137
  }
138
+ static progress(quiet, output = this.normal.bind(this)) {
139
+ return (txt, newLine = true, replacePrevious = false) => {
140
+ if (quiet)
141
+ return;
142
+ if (replacePrevious)
143
+ this.clearPreviousLine();
144
+ output(txt, newLine);
145
+ };
146
+ }
137
147
  // Payload output (command results, logs, JSON): bypasses terminal-kit,
138
148
  // whose printf-style formatting and ^-markup corrupt data containing
139
149
  // % or ^ sequences. newLine=false emits a mid-stream chunk, keeping
@@ -652,6 +662,35 @@ class Output {
652
662
  static json(json) {
653
663
  this.data(JSON.stringify(json));
654
664
  }
665
+ static async streamCommandLogs(body, jsonl) {
666
+ // readline preserves UTF-8 and records split across transport chunks.
667
+ const lines = (0, node_readline_1.createInterface)({ input: body, crlfDelay: Infinity });
668
+ for await (const line of lines) {
669
+ if (!line.trim())
670
+ continue;
671
+ let record;
672
+ try {
673
+ record = JSON.parse(line);
674
+ }
675
+ catch {
676
+ continue;
677
+ }
678
+ if (typeof record?.data !== 'string')
679
+ continue;
680
+ if (jsonl) {
681
+ this.json({
682
+ type: 'log',
683
+ ...(record.stream === 'stdout' || record.stream === 'stderr'
684
+ ? { stream: record.stream }
685
+ : {}),
686
+ data: record.data,
687
+ });
688
+ }
689
+ else if (record.data) {
690
+ this.data(record.data);
691
+ }
692
+ }
693
+ }
655
694
  static exitError(err) {
656
695
  this.clearUndici();
657
696
  this.clearTerminal();