@runcofactor/cli 0.10.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 (150) hide show
  1. package/README.md +125 -0
  2. package/dist/api-catalog-GFGCLVS4.js +401 -0
  3. package/dist/api-catalog-GFGCLVS4.js.map +1 -0
  4. package/dist/attachment-SJC7D7FY.js +276 -0
  5. package/dist/attachment-SJC7D7FY.js.map +1 -0
  6. package/dist/auth-EN6NQCJY.js +31 -0
  7. package/dist/auth-EN6NQCJY.js.map +1 -0
  8. package/dist/bin.js +7 -0
  9. package/dist/bin.js.map +1 -0
  10. package/dist/chunk-3CZU7XCS.js +272 -0
  11. package/dist/chunk-3CZU7XCS.js.map +1 -0
  12. package/dist/chunk-4NRDONSC.js +1048 -0
  13. package/dist/chunk-4NRDONSC.js.map +1 -0
  14. package/dist/chunk-4PNOV7OV.js +51980 -0
  15. package/dist/chunk-4PNOV7OV.js.map +1 -0
  16. package/dist/chunk-52IO7ACJ.js +2941 -0
  17. package/dist/chunk-52IO7ACJ.js.map +1 -0
  18. package/dist/chunk-6LEZCKKV.js +663 -0
  19. package/dist/chunk-6LEZCKKV.js.map +1 -0
  20. package/dist/chunk-A4OFTUVV.js +170 -0
  21. package/dist/chunk-A4OFTUVV.js.map +1 -0
  22. package/dist/chunk-B2VISN2V.js +2459 -0
  23. package/dist/chunk-B2VISN2V.js.map +1 -0
  24. package/dist/chunk-CLAWT7BJ.js +271 -0
  25. package/dist/chunk-CLAWT7BJ.js.map +1 -0
  26. package/dist/chunk-GKY2KXO5.js +281 -0
  27. package/dist/chunk-GKY2KXO5.js.map +1 -0
  28. package/dist/chunk-I4QLI3JO.js +413 -0
  29. package/dist/chunk-I4QLI3JO.js.map +1 -0
  30. package/dist/chunk-IMPZAX6L.js +180 -0
  31. package/dist/chunk-IMPZAX6L.js.map +1 -0
  32. package/dist/chunk-J6SH7GQT.js +241 -0
  33. package/dist/chunk-J6SH7GQT.js.map +1 -0
  34. package/dist/chunk-JDBCZ3Z2.js +298 -0
  35. package/dist/chunk-JDBCZ3Z2.js.map +1 -0
  36. package/dist/chunk-JICSYFRJ.js +46 -0
  37. package/dist/chunk-JICSYFRJ.js.map +1 -0
  38. package/dist/chunk-JWHYXEA2.js +32 -0
  39. package/dist/chunk-JWHYXEA2.js.map +1 -0
  40. package/dist/chunk-N7HFALX3.js +88 -0
  41. package/dist/chunk-N7HFALX3.js.map +1 -0
  42. package/dist/chunk-Q4BO4Z5V.js +178 -0
  43. package/dist/chunk-Q4BO4Z5V.js.map +1 -0
  44. package/dist/chunk-QFDOWABX.js +195 -0
  45. package/dist/chunk-QFDOWABX.js.map +1 -0
  46. package/dist/chunk-SJJW77WN.js +605 -0
  47. package/dist/chunk-SJJW77WN.js.map +1 -0
  48. package/dist/chunk-VKVL7WBN.js +50 -0
  49. package/dist/chunk-VKVL7WBN.js.map +1 -0
  50. package/dist/chunk-WOHL4FTB.js +353 -0
  51. package/dist/chunk-WOHL4FTB.js.map +1 -0
  52. package/dist/chunk-XQXVG7RA.js +426 -0
  53. package/dist/chunk-XQXVG7RA.js.map +1 -0
  54. package/dist/chunk-ZD3KHESI.js +94 -0
  55. package/dist/chunk-ZD3KHESI.js.map +1 -0
  56. package/dist/credential-COLTBV6D.js +450 -0
  57. package/dist/credential-COLTBV6D.js.map +1 -0
  58. package/dist/credential-template-EEPYFG7R.js +291 -0
  59. package/dist/credential-template-EEPYFG7R.js.map +1 -0
  60. package/dist/debug-workflow-KOVH5GOP.js +259 -0
  61. package/dist/debug-workflow-KOVH5GOP.js.map +1 -0
  62. package/dist/dist-44PZR7BQ.js +423 -0
  63. package/dist/dist-44PZR7BQ.js.map +1 -0
  64. package/dist/docs-3SSORHB5.js +366 -0
  65. package/dist/docs-3SSORHB5.js.map +1 -0
  66. package/dist/doctor-OTSIWV6G.js +132 -0
  67. package/dist/doctor-OTSIWV6G.js.map +1 -0
  68. package/dist/feature-flag-T2LRZME3.js +283 -0
  69. package/dist/feature-flag-T2LRZME3.js.map +1 -0
  70. package/dist/file-type-S3UUBVCT.js +4205 -0
  71. package/dist/file-type-S3UUBVCT.js.map +1 -0
  72. package/dist/index.d.ts +3 -0
  73. package/dist/index.js +982 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/init-TGWRECT2.js +208 -0
  76. package/dist/init-TGWRECT2.js.map +1 -0
  77. package/dist/install-DXSNWZKO.js +295 -0
  78. package/dist/install-DXSNWZKO.js.map +1 -0
  79. package/dist/issues-XIZOPX6T.js +564 -0
  80. package/dist/issues-XIZOPX6T.js.map +1 -0
  81. package/dist/knobs-NBINZIUB.js +295 -0
  82. package/dist/knobs-NBINZIUB.js.map +1 -0
  83. package/dist/list-3TDHK637.js +59 -0
  84. package/dist/list-3TDHK637.js.map +1 -0
  85. package/dist/local-HICVD6PU.js +100 -0
  86. package/dist/local-HICVD6PU.js.map +1 -0
  87. package/dist/login-UOIUXVUK.js +315 -0
  88. package/dist/login-UOIUXVUK.js.map +1 -0
  89. package/dist/mcp-54IJEOUA.js +1956 -0
  90. package/dist/mcp-54IJEOUA.js.map +1 -0
  91. package/dist/pdf-extract-ABWV3L5X.js +13 -0
  92. package/dist/pdf-extract-ABWV3L5X.js.map +1 -0
  93. package/dist/pdfjs-DQ2YA5S3.js +41561 -0
  94. package/dist/pdfjs-DQ2YA5S3.js.map +1 -0
  95. package/dist/property-UXLOLPTD.js +701 -0
  96. package/dist/property-UXLOLPTD.js.map +1 -0
  97. package/dist/property-skill-guide.md +189 -0
  98. package/dist/psql-BYUUNLGG.js +115 -0
  99. package/dist/psql-BYUUNLGG.js.map +1 -0
  100. package/dist/record-4TR2UIIS.js +233 -0
  101. package/dist/record-4TR2UIIS.js.map +1 -0
  102. package/dist/redis-35VBUYW7.js +116 -0
  103. package/dist/redis-35VBUYW7.js.map +1 -0
  104. package/dist/release-OOLTUBUT.js +354 -0
  105. package/dist/release-OOLTUBUT.js.map +1 -0
  106. package/dist/sandbox-XGSUU6G7.js +2046 -0
  107. package/dist/sandbox-XGSUU6G7.js.map +1 -0
  108. package/dist/scenarios-GWLJEGHA.js +280 -0
  109. package/dist/scenarios-GWLJEGHA.js.map +1 -0
  110. package/dist/session-MYFNZPRP.js +2414 -0
  111. package/dist/session-MYFNZPRP.js.map +1 -0
  112. package/dist/skill-KM34LDMO.js +1839 -0
  113. package/dist/skill-KM34LDMO.js.map +1 -0
  114. package/dist/skills/debug-run/SKILL.md +262 -0
  115. package/dist/skills/debug-run/history/1.0.0.md +244 -0
  116. package/dist/skills/debug-run/history/1.0.1.md +245 -0
  117. package/dist/skills/debug-run/history/1.0.2.md +254 -0
  118. package/dist/skills/debug-run/history/1.1.0.md +262 -0
  119. package/dist/skills/debug-run/version.json +3 -0
  120. package/dist/spec-RA3CFEKG.js +951 -0
  121. package/dist/spec-RA3CFEKG.js.map +1 -0
  122. package/dist/src-LB4HBTJQ.js +1516 -0
  123. package/dist/src-LB4HBTJQ.js.map +1 -0
  124. package/dist/src-N3TPKGTY.js +244 -0
  125. package/dist/src-N3TPKGTY.js.map +1 -0
  126. package/dist/src-UVDX5UP6.js +17 -0
  127. package/dist/src-UVDX5UP6.js.map +1 -0
  128. package/dist/start-PSEQSQA3.js +151 -0
  129. package/dist/start-PSEQSQA3.js.map +1 -0
  130. package/dist/tag-YY6YAABQ.js +22 -0
  131. package/dist/tag-YY6YAABQ.js.map +1 -0
  132. package/dist/task-IQC3YR5K.js +922 -0
  133. package/dist/task-IQC3YR5K.js.map +1 -0
  134. package/dist/test-suite-DZNJFXDW.js +394 -0
  135. package/dist/test-suite-DZNJFXDW.js.map +1 -0
  136. package/dist/trace-HXIW7U2D.js +14 -0
  137. package/dist/trace-HXIW7U2D.js.map +1 -0
  138. package/dist/triage-ORG45R5W.js +16 -0
  139. package/dist/triage-ORG45R5W.js.map +1 -0
  140. package/dist/upgrade-L2VYMP2V.js +61 -0
  141. package/dist/upgrade-L2VYMP2V.js.map +1 -0
  142. package/dist/workflow-XYFH5LTP.js +3708 -0
  143. package/dist/workflow-XYFH5LTP.js.map +1 -0
  144. package/dist/workflow-cache-NQJQFWMV.js +253 -0
  145. package/dist/workflow-cache-NQJQFWMV.js.map +1 -0
  146. package/dist/workflow-debug-BGD4UIXU.js +927 -0
  147. package/dist/workflow-debug-BGD4UIXU.js.map +1 -0
  148. package/dist/workflow-proposals-MTUDX46O.js +382 -0
  149. package/dist/workflow-proposals-MTUDX46O.js.map +1 -0
  150. package/package.json +61 -0
@@ -0,0 +1,353 @@
1
+ import { createRequire as __cr } from "module"; const require = __cr(import.meta.url);
2
+ import {
3
+ VALID_MACRO_NAMES
4
+ } from "./chunk-SJJW77WN.js";
5
+ import {
6
+ apiFetch,
7
+ exitOnFailure,
8
+ isTerminalFailure
9
+ } from "./chunk-3CZU7XCS.js";
10
+ import {
11
+ getArgValue
12
+ } from "./chunk-A4OFTUVV.js";
13
+ import {
14
+ getCanaryTmpDir
15
+ } from "./chunk-JWHYXEA2.js";
16
+
17
+ // src/cli-helpers.ts
18
+ import fs from "fs/promises";
19
+ import path from "path";
20
+ import process from "process";
21
+ function toLifecycleLabel(stage) {
22
+ switch (stage) {
23
+ case "deprecated":
24
+ return "deprecated";
25
+ case "ready_for_cleanup":
26
+ return "ready_for_cleanup";
27
+ default:
28
+ return "active";
29
+ }
30
+ }
31
+ function parseLifecycleStage(argv) {
32
+ const stage = getArgValue(argv, "--stage");
33
+ if (!stage || !["active", "deprecated", "ready_for_cleanup"].includes(stage)) {
34
+ console.error(
35
+ "Error: --stage is required and must be one of: active, deprecated, ready_for_cleanup"
36
+ );
37
+ process.exit(1);
38
+ }
39
+ return stage;
40
+ }
41
+ async function apiRequest(apiUrl, token, method, path2, body, options) {
42
+ const result = await apiFetch(`${apiUrl}${path2}`, {
43
+ method,
44
+ headers: {
45
+ Authorization: `Bearer ${token}`,
46
+ "Content-Type": "application/json"
47
+ },
48
+ token,
49
+ ...options?.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {},
50
+ ...body ? { body: JSON.stringify(body) } : {}
51
+ });
52
+ if (!result.ok) {
53
+ const { failure } = result;
54
+ if (isTerminalFailure(failure)) exitOnFailure(failure);
55
+ const text = failure.body ?? "";
56
+ let errorMessage = failure.message;
57
+ let parsed = null;
58
+ try {
59
+ const data = JSON.parse(text);
60
+ if (data && typeof data === "object") {
61
+ parsed = data;
62
+ if (typeof parsed.error === "string") errorMessage = parsed.error;
63
+ }
64
+ } catch {
65
+ }
66
+ return { ...parsed, ok: false, error: errorMessage };
67
+ }
68
+ try {
69
+ return await result.response.json();
70
+ } catch {
71
+ return { ok: false, error: `Invalid JSON response (${result.response.status})` };
72
+ }
73
+ }
74
+ function renderWorkflowUserError(result) {
75
+ const code = typeof result.code === "string" ? result.code : null;
76
+ const message = typeof result.error === "string" ? result.error : null;
77
+ if (!code) return null;
78
+ if (code === "WORKFLOW_VALIDATION_FAILED") {
79
+ const issues = Array.isArray(result.issues) ? result.issues : [];
80
+ const errors = issues.filter((i) => (i.severity ?? "error") === "error");
81
+ const warnings = issues.filter((i) => i.severity === "warning");
82
+ const lines = [
83
+ `\u2716 Validation failed (${errors.length} error${errors.length === 1 ? "" : "s"}` + (warnings.length > 0 ? `, ${warnings.length} warning${warnings.length === 1 ? "" : "s"}` : "") + ")"
84
+ ];
85
+ if (message) lines.push(` ${message}`);
86
+ const byNode = /* @__PURE__ */ new Map();
87
+ for (const issue of issues) {
88
+ const key = issue.nodeId ?? "__flow__";
89
+ const arr = byNode.get(key) ?? [];
90
+ arr.push(issue);
91
+ byNode.set(key, arr);
92
+ }
93
+ for (const [nodeKey, nodeIssues] of byNode) {
94
+ const heading = nodeKey === "__flow__" ? "Flow" : `Node ${nodeKey}${nodeIssues[0]?.nodeType ? ` (${nodeIssues[0].nodeType})` : ""}`;
95
+ lines.push(` ${heading}:`);
96
+ for (const issue of nodeIssues) {
97
+ const sev = issue.severity === "warning" ? "\u26A0" : "\u2022";
98
+ const field = issue.field ? `${issue.field} \u2014 ` : "";
99
+ lines.push(` ${sev} ${field}${issue.message ?? ""}`);
100
+ }
101
+ }
102
+ return lines.join("\n");
103
+ }
104
+ if (code === "WORKFLOW_UNRESOLVED_VARIABLES") {
105
+ const lines = [`\u2716 ${code}`];
106
+ if (message) lines.push(` ${message}`);
107
+ const refs = Array.isArray(result.refs) ? result.refs : [];
108
+ const variables = Array.isArray(result.variables) ? result.variables : refs.map((r) => r.variable);
109
+ if (refs.length > 0) {
110
+ lines.push(" Unresolved references:");
111
+ for (const ref of refs) {
112
+ const loc = ref.field && ref.nodeId ? ` (node ${ref.nodeId}, ${ref.field})` : "";
113
+ lines.push(` \u2022 $var.${ref.variable}${loc}`);
114
+ }
115
+ } else if (variables.length > 0) {
116
+ lines.push(" Unresolved:");
117
+ for (const v of variables) lines.push(` \u2022 $var.${v}`);
118
+ }
119
+ const macroHints = variables.filter((v) => VALID_MACRO_NAMES.has(v.toUpperCase()));
120
+ if (macroHints.length > 0) {
121
+ lines.push(" Hint: these look like macro names, not variables:");
122
+ for (const v of macroHints) {
123
+ lines.push(` $var.${v} \u2192 $${v.toUpperCase()}()`);
124
+ }
125
+ }
126
+ return lines.join("\n");
127
+ }
128
+ if (code === "WORKFLOW_INVALID_INPUT_VALUES") {
129
+ const lines = [`\u2716 ${code}`];
130
+ if (message) lines.push(` ${message}`);
131
+ const issues = Array.isArray(result.issues) ? result.issues : [];
132
+ for (const issue of issues) {
133
+ const key = issue.key ?? "?";
134
+ const value = issue.value ?? "";
135
+ if (issue.reason === "self_referential") {
136
+ lines.push(` \u2022 ${key}: self-referential \u2192 ${value}`);
137
+ lines.push(` Use a literal or point at a different upstream variable.`);
138
+ } else if (issue.reason === "macro_name_used_as_var") {
139
+ lines.push(` \u2022 ${key}: macro name used as $var \u2192 ${value}`);
140
+ for (const v of issue.variables ?? []) {
141
+ lines.push(` $var.${v} \u2192 $${v.toUpperCase()}()`);
142
+ }
143
+ } else {
144
+ lines.push(` \u2022 ${key}: ${issue.reason ?? "invalid"} \u2192 ${value}`);
145
+ }
146
+ }
147
+ return lines.join("\n");
148
+ }
149
+ if (code === "WORKFLOW_INVALID_MACRO") {
150
+ const lines = [`\u2716 ${code}`];
151
+ if (message) lines.push(` ${message}`);
152
+ const invalid = Array.isArray(result.invalid) ? result.invalid : [];
153
+ const valid = Array.isArray(result.valid) ? result.valid : [];
154
+ if (invalid.length > 0) {
155
+ lines.push(` Invalid macro(s): ${invalid.map((n) => `$${n}()`).join(", ")}`);
156
+ }
157
+ if (valid.length > 0) {
158
+ lines.push(` Valid macros: ${valid.map((n) => `$${n}()`).join(", ")}`);
159
+ }
160
+ return lines.join("\n");
161
+ }
162
+ return `\u2716 ${code}${message ? `: ${message}` : ""}`;
163
+ }
164
+ async function downloadStorageState(opts) {
165
+ const tmpFile = path.join(getCanaryTmpDir(), `${opts.prefix ?? "canary-ss"}-${Date.now()}.json`);
166
+ try {
167
+ const res = await fetch(
168
+ `${opts.apiUrl}/org/properties/${opts.propertyId}/credentials/${opts.credentialId}/storage-state/download`,
169
+ {
170
+ headers: { Authorization: `Bearer ${opts.token}` },
171
+ redirect: "follow"
172
+ }
173
+ );
174
+ if (res.ok) {
175
+ const body = await res.text();
176
+ await fs.writeFile(tmpFile, body, "utf-8");
177
+ return tmpFile;
178
+ }
179
+ } catch {
180
+ }
181
+ return void 0;
182
+ }
183
+ async function selectCredential(apiUrl, token, credentialArg) {
184
+ const credentials = await fetchList(
185
+ apiUrl,
186
+ token,
187
+ "/org/credentials",
188
+ "items"
189
+ );
190
+ if (credentials.length === 0) {
191
+ console.error("No credentials found. Create one first in the web app.");
192
+ return null;
193
+ }
194
+ if (credentialArg) {
195
+ const match = credentials.find(
196
+ (c) => c.id === credentialArg || c.name.toLowerCase() === credentialArg.toLowerCase()
197
+ );
198
+ if (!match) {
199
+ console.error(`Credential "${credentialArg}" not found.`);
200
+ console.error("Available credentials:");
201
+ for (const c of credentials) {
202
+ const env = c.environmentName ? ` \u2014 ${c.environmentName}` : "";
203
+ const baseUrl = c.propertyBaseUrl ? ` \u2014 ${c.propertyBaseUrl}` : "";
204
+ console.error(` - ${c.name} [${c.propertyName ?? c.propertyId}${env}${baseUrl}]`);
205
+ }
206
+ return null;
207
+ }
208
+ return match;
209
+ }
210
+ console.log("\nSelect a credential:\n");
211
+ const labels = credentials.map((c) => {
212
+ const property = c.propertyName ?? c.propertyId;
213
+ const env = c.environmentName ? ` \u2014 ${c.environmentName}` : "";
214
+ const baseUrl = c.propertyBaseUrl ? ` \u2014 ${c.propertyBaseUrl}` : "";
215
+ return `${c.name} [${property}${env}${baseUrl}]`;
216
+ });
217
+ const readline = await import("readline");
218
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
219
+ const answer = await new Promise((resolve) => {
220
+ for (let i = 0; i < labels.length; i++) {
221
+ console.log(` ${i + 1}. ${labels[i]}`);
222
+ }
223
+ rl.question("\nEnter number: ", (ans) => {
224
+ rl.close();
225
+ resolve(ans.trim());
226
+ });
227
+ });
228
+ const idx = parseInt(answer, 10) - 1;
229
+ if (isNaN(idx) || idx < 0 || idx >= credentials.length) {
230
+ console.error("Invalid selection.");
231
+ return null;
232
+ }
233
+ return credentials[idx];
234
+ }
235
+ async function fetchProperties(apiUrl, token) {
236
+ return fetchList(apiUrl, token, "/org/properties", "items");
237
+ }
238
+ function getApplicationArg(argv) {
239
+ return getArgValue(argv, "--application") ?? getArgValue(argv, "--property");
240
+ }
241
+ function getApplicationIdArg(argv) {
242
+ return getArgValue(argv, "--application-id") ?? getArgValue(argv, "--property-id");
243
+ }
244
+ async function selectProperty(apiUrl, token, hint) {
245
+ const properties = await fetchProperties(apiUrl, token);
246
+ if (properties.length === 0) {
247
+ console.error("No applications found. Create one first in the web app.");
248
+ return null;
249
+ }
250
+ if (hint) {
251
+ const match = properties.find(
252
+ (p) => p.id === hint || p.name.toLowerCase() === hint.toLowerCase()
253
+ );
254
+ if (!match) {
255
+ console.error(`Application "${hint}" not found.`);
256
+ console.error("Available applications:");
257
+ for (const p of properties) {
258
+ console.error(` - ${p.name} (${p.baseUrl})`);
259
+ }
260
+ return null;
261
+ }
262
+ return match;
263
+ }
264
+ if (properties.length === 1) {
265
+ console.log(`Auto-selected application: ${properties[0].name}`);
266
+ return properties[0];
267
+ }
268
+ return promptChoice(
269
+ "Select an application:",
270
+ properties.map((p) => ({ label: `${p.name} \u2014 ${p.baseUrl}`, value: p }))
271
+ );
272
+ }
273
+ async function promptInput(question, defaultValue) {
274
+ const readline = await import("readline");
275
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
276
+ const prompt = defaultValue ? `${question} [${defaultValue}]: ` : `${question}: `;
277
+ const answer = await new Promise((resolve) => {
278
+ rl.question(prompt, (ans) => {
279
+ rl.close();
280
+ resolve(ans.trim());
281
+ });
282
+ });
283
+ return answer || defaultValue || "";
284
+ }
285
+ async function promptChoice(question, options) {
286
+ console.log(`
287
+ ${question}
288
+ `);
289
+ for (let i = 0; i < options.length; i++) {
290
+ console.log(` ${i + 1}. ${options[i].label}`);
291
+ }
292
+ const readline = await import("readline");
293
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
294
+ const answer = await new Promise((resolve) => {
295
+ rl.question("\nEnter number: ", (ans) => {
296
+ rl.close();
297
+ resolve(ans.trim());
298
+ });
299
+ });
300
+ const idx = parseInt(answer, 10) - 1;
301
+ if (isNaN(idx) || idx < 0 || idx >= options.length) {
302
+ console.error("Invalid selection.");
303
+ return null;
304
+ }
305
+ return options[idx].value;
306
+ }
307
+ async function uploadStorageState(opts) {
308
+ const result = await apiFetch(
309
+ `${opts.apiUrl}/org/properties/${opts.propertyId}/credentials/${opts.credentialId}/storage-state/upload`,
310
+ {
311
+ method: "PUT",
312
+ headers: {
313
+ Authorization: `Bearer ${opts.token}`,
314
+ "Content-Type": "application/json"
315
+ },
316
+ token: opts.token,
317
+ body: JSON.stringify({ storageState: opts.storageState })
318
+ }
319
+ );
320
+ if (!result.ok) exitOnFailure(result.failure);
321
+ return await result.response.json();
322
+ }
323
+ async function fetchList(apiUrl, token, path2, listKey) {
324
+ const result = await apiFetch(`${apiUrl}${path2}`, {
325
+ headers: { Authorization: `Bearer ${token}` },
326
+ token
327
+ });
328
+ if (!result.ok) exitOnFailure(result.failure);
329
+ const json = await result.response.json();
330
+ if (!json.ok) {
331
+ console.error(`Error: ${json.error}`);
332
+ process.exit(1);
333
+ }
334
+ return json[listKey] ?? [];
335
+ }
336
+
337
+ export {
338
+ toLifecycleLabel,
339
+ parseLifecycleStage,
340
+ apiRequest,
341
+ renderWorkflowUserError,
342
+ downloadStorageState,
343
+ selectCredential,
344
+ fetchProperties,
345
+ getApplicationArg,
346
+ getApplicationIdArg,
347
+ selectProperty,
348
+ promptInput,
349
+ promptChoice,
350
+ uploadStorageState,
351
+ fetchList
352
+ };
353
+ //# sourceMappingURL=chunk-WOHL4FTB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli-helpers.ts"],"sourcesContent":["/**\n * Shared CLI helpers for superadmin management commands (knobs, feature-flags).\n */\n\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { getCanaryTmpDir } from '@chatsdet/tmp';\nimport { VALID_MACRO_NAMES } from '@chatsdet/types';\nimport { getArgValue } from './auth.js';\nimport { apiFetch, exitOnFailure, isTerminalFailure } from './api-fetch.js';\n\nexport type LifecycleStage = 'active' | 'deprecated' | 'ready_for_cleanup';\n\nexport function toLifecycleLabel(stage: LifecycleStage): string {\n switch (stage) {\n case 'deprecated':\n return 'deprecated';\n case 'ready_for_cleanup':\n return 'ready_for_cleanup';\n default:\n return 'active';\n }\n}\n\nexport function parseLifecycleStage(argv: string[]): LifecycleStage {\n const stage = getArgValue(argv, '--stage');\n if (!stage || !['active', 'deprecated', 'ready_for_cleanup'].includes(stage)) {\n console.error(\n 'Error: --stage is required and must be one of: active, deprecated, ready_for_cleanup'\n );\n process.exit(1);\n }\n return stage as LifecycleStage;\n}\n\nexport async function apiRequest<T extends { ok: boolean; error?: string }>(\n apiUrl: string,\n token: string,\n method: string,\n path: string,\n body?: Record<string, unknown>,\n options?: { timeoutMs?: number }\n): Promise<T> {\n const result = await apiFetch(`${apiUrl}${path}`, {\n method,\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n token,\n ...(options?.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),\n ...(body ? { body: JSON.stringify(body) } : {}),\n });\n\n if (!result.ok) {\n const { failure } = result;\n // Terminal kinds (auth/proxy/TLS) surface the full diagnostic and exit;\n // http-error falls through so the caller can pretty-print structured\n // user errors (unresolved vars, invalid macros, etc.).\n if (isTerminalFailure(failure)) exitOnFailure(failure);\n const text = failure.body ?? '';\n let errorMessage = failure.message;\n let parsed: Record<string, unknown> | null = null;\n try {\n const data = JSON.parse(text);\n if (data && typeof data === 'object') {\n parsed = data as Record<string, unknown>;\n if (typeof parsed.error === 'string') errorMessage = parsed.error;\n }\n } catch {\n /* keep failure.message */\n }\n return { ...parsed, ok: false, error: errorMessage } as T;\n }\n\n try {\n return (await result.response.json()) as T;\n } catch {\n return { ok: false, error: `Invalid JSON response (${result.response.status})` } as T;\n }\n}\n\ntype UnresolvedRef = {\n nodeId?: string;\n nodeType?: string;\n field?: string;\n variable: string;\n};\n\n/**\n * Render a structured `userError` response from the workflow API into a\n * multi-line, actionable message. Recognizes `WORKFLOW_UNRESOLVED_VARIABLES`\n * and falls back to `✖ {code}: {message}` for other codes. Returns `null` if\n * the response body isn't a recognized structured error.\n */\nexport function renderWorkflowUserError(result: Record<string, unknown>): string | null {\n const code = typeof result.code === 'string' ? result.code : null;\n const message = typeof result.error === 'string' ? result.error : null;\n if (!code) return null;\n\n if (code === 'WORKFLOW_VALIDATION_FAILED') {\n type ValidationIssue = {\n nodeId?: string | null;\n nodeType?: string | null;\n field?: string;\n message?: string;\n severity?: 'error' | 'warning';\n };\n const issues = Array.isArray(result.issues) ? (result.issues as ValidationIssue[]) : [];\n const errors = issues.filter((i) => (i.severity ?? 'error') === 'error');\n const warnings = issues.filter((i) => i.severity === 'warning');\n\n const lines: string[] = [\n `✖ Validation failed (${errors.length} error${errors.length === 1 ? '' : 's'}` +\n (warnings.length > 0\n ? `, ${warnings.length} warning${warnings.length === 1 ? '' : 's'}`\n : '') +\n ')',\n ];\n if (message) lines.push(` ${message}`);\n\n // Group by nodeId (null = flow-level).\n const byNode = new Map<string, ValidationIssue[]>();\n for (const issue of issues) {\n const key = issue.nodeId ?? '__flow__';\n const arr = byNode.get(key) ?? [];\n arr.push(issue);\n byNode.set(key, arr);\n }\n for (const [nodeKey, nodeIssues] of byNode) {\n const heading =\n nodeKey === '__flow__'\n ? 'Flow'\n : `Node ${nodeKey}${nodeIssues[0]?.nodeType ? ` (${nodeIssues[0].nodeType})` : ''}`;\n lines.push(` ${heading}:`);\n for (const issue of nodeIssues) {\n const sev = issue.severity === 'warning' ? '⚠' : '•';\n const field = issue.field ? `${issue.field} — ` : '';\n lines.push(` ${sev} ${field}${issue.message ?? ''}`);\n }\n }\n return lines.join('\\n');\n }\n\n if (code === 'WORKFLOW_UNRESOLVED_VARIABLES') {\n const lines: string[] = [`✖ ${code}`];\n if (message) lines.push(` ${message}`);\n const refs = Array.isArray(result.refs) ? (result.refs as UnresolvedRef[]) : [];\n const variables = Array.isArray(result.variables)\n ? (result.variables as string[])\n : refs.map((r) => r.variable);\n\n if (refs.length > 0) {\n lines.push(' Unresolved references:');\n for (const ref of refs) {\n const loc = ref.field && ref.nodeId ? ` (node ${ref.nodeId}, ${ref.field})` : '';\n lines.push(` • $var.${ref.variable}${loc}`);\n }\n } else if (variables.length > 0) {\n lines.push(' Unresolved:');\n for (const v of variables) lines.push(` • $var.${v}`);\n }\n\n const macroHints = variables.filter((v) => VALID_MACRO_NAMES.has(v.toUpperCase()));\n if (macroHints.length > 0) {\n lines.push(' Hint: these look like macro names, not variables:');\n for (const v of macroHints) {\n lines.push(` $var.${v} → $${v.toUpperCase()}()`);\n }\n }\n return lines.join('\\n');\n }\n\n if (code === 'WORKFLOW_INVALID_INPUT_VALUES') {\n const lines: string[] = [`✖ ${code}`];\n if (message) lines.push(` ${message}`);\n const issues = Array.isArray(result.issues)\n ? (result.issues as Array<{\n key?: string;\n value?: string;\n reason?: string;\n variables?: string[];\n }>)\n : [];\n for (const issue of issues) {\n const key = issue.key ?? '?';\n const value = issue.value ?? '';\n if (issue.reason === 'self_referential') {\n lines.push(` • ${key}: self-referential → ${value}`);\n lines.push(` Use a literal or point at a different upstream variable.`);\n } else if (issue.reason === 'macro_name_used_as_var') {\n lines.push(` • ${key}: macro name used as $var → ${value}`);\n for (const v of issue.variables ?? []) {\n lines.push(` $var.${v} → $${v.toUpperCase()}()`);\n }\n } else {\n lines.push(` • ${key}: ${issue.reason ?? 'invalid'} → ${value}`);\n }\n }\n return lines.join('\\n');\n }\n\n if (code === 'WORKFLOW_INVALID_MACRO') {\n const lines: string[] = [`✖ ${code}`];\n if (message) lines.push(` ${message}`);\n const invalid = Array.isArray(result.invalid) ? (result.invalid as string[]) : [];\n const valid = Array.isArray(result.valid) ? (result.valid as string[]) : [];\n if (invalid.length > 0) {\n lines.push(` Invalid macro(s): ${invalid.map((n) => `$${n}()`).join(', ')}`);\n }\n if (valid.length > 0) {\n lines.push(` Valid macros: ${valid.map((n) => `$${n}()`).join(', ')}`);\n }\n return lines.join('\\n');\n }\n\n return `✖ ${code}${message ? `: ${message}` : ''}`;\n}\n\nexport async function downloadStorageState(opts: {\n apiUrl: string;\n token: string;\n propertyId: string;\n credentialId: string;\n prefix?: string;\n}): Promise<string | undefined> {\n const tmpFile = path.join(getCanaryTmpDir(), `${opts.prefix ?? 'canary-ss'}-${Date.now()}.json`);\n try {\n const res = await fetch(\n `${opts.apiUrl}/org/properties/${opts.propertyId}/credentials/${opts.credentialId}/storage-state/download`,\n {\n headers: { Authorization: `Bearer ${opts.token}` },\n redirect: 'follow',\n }\n );\n if (res.ok) {\n const body = await res.text();\n await fs.writeFile(tmpFile, body, 'utf-8');\n return tmpFile;\n }\n } catch {\n // Caller handles missing storage state\n }\n return undefined;\n}\n\n/* ── Credential selection ─────────────────────────────────────────────── */\n\nexport interface CredentialListItem {\n id: string;\n name: string;\n propertyId: string;\n propertyName?: string;\n propertyBaseUrl?: string;\n environmentId?: string | null;\n environmentName?: string | null;\n loginUrl?: string;\n storageStateS3Key?: string | null;\n isDefault?: boolean;\n isEphemeral?: boolean;\n}\n\n/**\n * Fetch org credentials and let the user pick one interactively.\n *\n * @param credentialArg - Credential name or ID to auto-select, or undefined for interactive\n * @returns The selected credential, or null if none found / invalid selection\n */\nexport async function selectCredential(\n apiUrl: string,\n token: string,\n credentialArg?: string\n): Promise<CredentialListItem | null> {\n const credentials = await fetchList<CredentialListItem>(\n apiUrl,\n token,\n '/org/credentials',\n 'items'\n );\n\n if (credentials.length === 0) {\n console.error('No credentials found. Create one first in the web app.');\n return null;\n }\n\n if (credentialArg) {\n const match = credentials.find(\n (c) => c.id === credentialArg || c.name.toLowerCase() === credentialArg.toLowerCase()\n );\n if (!match) {\n console.error(`Credential \"${credentialArg}\" not found.`);\n console.error('Available credentials:');\n for (const c of credentials) {\n const env = c.environmentName ? ` — ${c.environmentName}` : '';\n const baseUrl = c.propertyBaseUrl ? ` — ${c.propertyBaseUrl}` : '';\n console.error(` - ${c.name} [${c.propertyName ?? c.propertyId}${env}${baseUrl}]`);\n }\n return null;\n }\n return match;\n }\n\n // Interactive selection\n console.log('\\nSelect a credential:\\n');\n const labels = credentials.map((c) => {\n const property = c.propertyName ?? c.propertyId;\n const env = c.environmentName ? ` — ${c.environmentName}` : '';\n const baseUrl = c.propertyBaseUrl ? ` — ${c.propertyBaseUrl}` : '';\n return `${c.name} [${property}${env}${baseUrl}]`;\n });\n\n const readline = await import('node:readline');\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n const answer = await new Promise<string>((resolve) => {\n for (let i = 0; i < labels.length; i++) {\n console.log(` ${i + 1}. ${labels[i]}`);\n }\n rl.question('\\nEnter number: ', (ans) => {\n rl.close();\n resolve(ans.trim());\n });\n });\n\n const idx = parseInt(answer, 10) - 1;\n if (isNaN(idx) || idx < 0 || idx >= credentials.length) {\n console.error('Invalid selection.');\n return null;\n }\n\n return credentials[idx];\n}\n\n/* ── Property selection ──────────────────────────────────────────────── */\n\ninterface PropertyListItem {\n id: string;\n name: string;\n baseUrl: string;\n}\n\nexport async function fetchProperties(apiUrl: string, token: string): Promise<PropertyListItem[]> {\n return fetchList<PropertyListItem>(apiUrl, token, '/org/properties', 'items');\n}\n\n/**\n * Read the application/property selector flag. `--application` is the user-facing\n * name; `--property` is kept as a backwards-compat alias (read second). Internally\n * this is still a \"property\" — the rename is cosmetic.\n */\nexport function getApplicationArg(argv: string[]): string | undefined {\n return getArgValue(argv, '--application') ?? getArgValue(argv, '--property');\n}\n\n/**\n * Read the application/property UUID flag. `--application-id` is the user-facing\n * name; `--property-id` is kept as a backwards-compat alias.\n */\nexport function getApplicationIdArg(argv: string[]): string | undefined {\n return getArgValue(argv, '--application-id') ?? getArgValue(argv, '--property-id');\n}\n\nexport async function selectProperty(\n apiUrl: string,\n token: string,\n hint?: string\n): Promise<PropertyListItem | null> {\n const properties = await fetchProperties(apiUrl, token);\n\n if (properties.length === 0) {\n console.error('No applications found. Create one first in the web app.');\n return null;\n }\n\n if (hint) {\n const match = properties.find(\n (p) => p.id === hint || p.name.toLowerCase() === hint.toLowerCase()\n );\n if (!match) {\n console.error(`Application \"${hint}\" not found.`);\n console.error('Available applications:');\n for (const p of properties) {\n console.error(` - ${p.name} (${p.baseUrl})`);\n }\n return null;\n }\n return match;\n }\n\n if (properties.length === 1) {\n console.log(`Auto-selected application: ${properties[0].name}`);\n return properties[0];\n }\n\n return promptChoice(\n 'Select an application:',\n properties.map((p) => ({ label: `${p.name} — ${p.baseUrl}`, value: p }))\n );\n}\n\n/* ── Interactive prompt helpers ──────────────────────────────────────── */\n\nexport async function promptInput(question: string, defaultValue?: string): Promise<string> {\n const readline = await import('node:readline');\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n const prompt = defaultValue ? `${question} [${defaultValue}]: ` : `${question}: `;\n const answer = await new Promise<string>((resolve) => {\n rl.question(prompt, (ans) => {\n rl.close();\n resolve(ans.trim());\n });\n });\n return answer || defaultValue || '';\n}\n\nexport async function promptChoice<T>(\n question: string,\n options: Array<{ label: string; value: T }>\n): Promise<T | null> {\n console.log(`\\n${question}\\n`);\n for (let i = 0; i < options.length; i++) {\n console.log(` ${i + 1}. ${options[i].label}`);\n }\n const readline = await import('node:readline');\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n const answer = await new Promise<string>((resolve) => {\n rl.question('\\nEnter number: ', (ans) => {\n rl.close();\n resolve(ans.trim());\n });\n });\n\n const idx = parseInt(answer, 10) - 1;\n if (isNaN(idx) || idx < 0 || idx >= options.length) {\n console.error('Invalid selection.');\n return null;\n }\n return options[idx].value;\n}\n\nexport async function uploadStorageState(opts: {\n apiUrl: string;\n token: string;\n propertyId: string;\n credentialId: string;\n storageState: unknown;\n}): Promise<{ ok: boolean; s3Key?: string; error?: string }> {\n const result = await apiFetch(\n `${opts.apiUrl}/org/properties/${opts.propertyId}/credentials/${opts.credentialId}/storage-state/upload`,\n {\n method: 'PUT',\n headers: {\n Authorization: `Bearer ${opts.token}`,\n 'Content-Type': 'application/json',\n },\n token: opts.token,\n body: JSON.stringify({ storageState: opts.storageState }),\n }\n );\n\n if (!result.ok) exitOnFailure(result.failure);\n\n return (await result.response.json()) as { ok: boolean; s3Key?: string; error?: string };\n}\n\nexport async function fetchList<T>(\n apiUrl: string,\n token: string,\n path: string,\n listKey: string\n): Promise<T[]> {\n const result = await apiFetch(`${apiUrl}${path}`, {\n headers: { Authorization: `Bearer ${token}` },\n token,\n });\n\n if (!result.ok) exitOnFailure(result.failure);\n\n const json = (await result.response.json()) as Record<string, unknown>;\n\n if (!json.ok) {\n console.error(`Error: ${json.error}`);\n process.exit(1);\n }\n\n return (json[listKey] as T[]) ?? [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,OAAO,QAAQ;AACf,OAAO,UA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