@wingmanpm/cli 0.1.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.
- package/LICENSE +202 -0
- package/README.md +99 -0
- package/dist/api.d.ts +23 -0
- package/dist/api.js +248 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.d.ts +54 -0
- package/dist/auth.js +160 -0
- package/dist/auth.js.map +1 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +40 -0
- package/dist/bin.js.map +1 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.js +153 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +24 -0
- package/dist/constants.js +36 -0
- package/dist/constants.js.map +1 -0
- package/dist/credential-lock.d.ts +12 -0
- package/dist/credential-lock.js +138 -0
- package/dist/credential-lock.js.map +1 -0
- package/dist/errors.d.ts +30 -0
- package/dist/errors.js +68 -0
- package/dist/errors.js.map +1 -0
- package/dist/input.d.ts +5 -0
- package/dist/input.js +51 -0
- package/dist/input.js.map +1 -0
- package/dist/keychain.d.ts +39 -0
- package/dist/keychain.js +133 -0
- package/dist/keychain.js.map +1 -0
- package/dist/oauth-config.d.ts +10 -0
- package/dist/oauth-config.js +113 -0
- package/dist/oauth-config.js.map +1 -0
- package/dist/oauth.d.ts +75 -0
- package/dist/oauth.js +543 -0
- package/dist/oauth.js.map +1 -0
- package/dist/output.d.ts +29 -0
- package/dist/output.js +210 -0
- package/dist/output.js.map +1 -0
- package/dist/process.d.ts +8 -0
- package/dist/process.js +30 -0
- package/dist/process.js.map +1 -0
- package/dist/program.d.ts +17 -0
- package/dist/program.js +771 -0
- package/dist/program.js.map +1 -0
- package/dist/sanitize.d.ts +11 -0
- package/dist/sanitize.js +154 -0
- package/dist/sanitize.js.map +1 -0
- package/package.json +43 -0
package/dist/program.js
ADDED
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ApiClient } from "./api.js";
|
|
4
|
+
import { AuthManager, verifyAndStoreOAuthSession } from "./auth.js";
|
|
5
|
+
import { assertTrustedApiUrl, assertTrustedIssuer, configPath, readConfig, resolveRuntimeConfig, writeConfig, } from "./config.js";
|
|
6
|
+
import { DOCS_URL, ExitCode, SUPPORT_EMAIL, TERMINAL_TASK_STATUSES, VERSION, } from "./constants.js";
|
|
7
|
+
import { FileCredentialLock } from "./credential-lock.js";
|
|
8
|
+
import { CliError, usageError } from "./errors.js";
|
|
9
|
+
import { mergeDefined, parseDataOption, parseInteger, parseJsonField } from "./input.js";
|
|
10
|
+
import { createCredentialVault } from "./keychain.js";
|
|
11
|
+
import { assertOpaqueAccessToken, discoverAuthorizationServer, loginWithDeviceAuthorization, revokeTokens, } from "./oauth.js";
|
|
12
|
+
import { createOutputContext, sanitizeCsvDocument, writeCsvDocument, writeData, } from "./output.js";
|
|
13
|
+
const ProductListSchema = z.array(z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
name: z.string(),
|
|
16
|
+
}).passthrough());
|
|
17
|
+
const TaskSchema = z.object({
|
|
18
|
+
id: z.string(),
|
|
19
|
+
status: z.string(),
|
|
20
|
+
is_partial: z.boolean().nullish(),
|
|
21
|
+
skipped_count: z.number().nullish(),
|
|
22
|
+
}).passthrough();
|
|
23
|
+
const RegionSchema = z.enum(["US", "EU", "APAC"]);
|
|
24
|
+
const SentimentSchema = z.enum([
|
|
25
|
+
"very_positive", "positive", "neutral", "negative", "very_negative",
|
|
26
|
+
]);
|
|
27
|
+
const ClassificationSchema = z.enum([
|
|
28
|
+
"feedback", "bug", "feature_request", "other", "survey_response",
|
|
29
|
+
]);
|
|
30
|
+
const JsonObjectSchema = z.record(z.string(), z.unknown());
|
|
31
|
+
const ProductCreateSchema = z.object({
|
|
32
|
+
name: z.string().min(1).max(255),
|
|
33
|
+
region: RegionSchema.optional(),
|
|
34
|
+
data_residency: RegionSchema.optional(),
|
|
35
|
+
timezone: z.string().max(50).optional(),
|
|
36
|
+
color: z.string().regex(/^#[0-9A-Fa-f]{6}$/).nullable().optional(),
|
|
37
|
+
description: z.string().nullable().optional(),
|
|
38
|
+
}).strict();
|
|
39
|
+
const ProductUpdateSchema = ProductCreateSchema.partial().strict();
|
|
40
|
+
const FeedbackCreateSchema = z.object({
|
|
41
|
+
text: z.string().min(1).max(100_000),
|
|
42
|
+
submitter: z.string().max(500).nullable().optional(),
|
|
43
|
+
metadata_jsonb: JsonObjectSchema.nullable().optional(),
|
|
44
|
+
}).strict();
|
|
45
|
+
const FeedbackUpdateSchema = z.object({
|
|
46
|
+
text: z.string().nullable().optional(),
|
|
47
|
+
submitter: z.string().nullable().optional(),
|
|
48
|
+
sentiment: SentimentSchema.nullable().optional(),
|
|
49
|
+
classification: ClassificationSchema.nullable().optional(),
|
|
50
|
+
description: z.string().nullable().optional(),
|
|
51
|
+
theme_id: z.string().uuid().nullable().optional(),
|
|
52
|
+
metadata_jsonb: JsonObjectSchema.nullable().optional(),
|
|
53
|
+
scores_jsonb: JsonObjectSchema.nullable().optional(),
|
|
54
|
+
}).strict();
|
|
55
|
+
const ThemeCreateSchema = z.object({
|
|
56
|
+
name: z.string().min(1).max(500),
|
|
57
|
+
summary: z.string().optional(),
|
|
58
|
+
sentiment: SentimentSchema.nullable().optional(),
|
|
59
|
+
}).strict();
|
|
60
|
+
const ThemeUpdateSchema = z.object({
|
|
61
|
+
name: z.string().min(1).max(500).nullable().optional(),
|
|
62
|
+
summary: z.string().nullable().optional(),
|
|
63
|
+
sentiment: SentimentSchema.nullable().optional(),
|
|
64
|
+
metadata_jsonb: JsonObjectSchema.nullable().optional(),
|
|
65
|
+
scores_jsonb: JsonObjectSchema.nullable().optional(),
|
|
66
|
+
}).strict();
|
|
67
|
+
export function createProgram(dependencies = {}) {
|
|
68
|
+
const env = dependencies.env ?? process.env;
|
|
69
|
+
const fetchImpl = dependencies.fetchImpl ?? fetch;
|
|
70
|
+
const vault = dependencies.vault ?? createCredentialVault(process.platform);
|
|
71
|
+
const credentialLock = dependencies.credentialLock ?? new FileCredentialLock();
|
|
72
|
+
const setExitCode = dependencies.setExitCode ?? ((code) => { process.exitCode = code; });
|
|
73
|
+
const program = new Command()
|
|
74
|
+
.name("wingman")
|
|
75
|
+
.description("Secure, agent-native CLI for WingmanPM")
|
|
76
|
+
.version(VERSION)
|
|
77
|
+
.showHelpAfterError()
|
|
78
|
+
.addHelpText("after", `\nDocumentation: ${DOCS_URL}\n`)
|
|
79
|
+
.option("--output <format>", "output format: json, table, jsonl, or csv")
|
|
80
|
+
.option("--compact", "return high-signal fields for lower token usage")
|
|
81
|
+
.option("--agent", "agent-safe mode: JSON, compact, non-interactive, and no color")
|
|
82
|
+
.option("--product <id-or-name>", "product UUID or exact product name")
|
|
83
|
+
.option("--api-url <url>", "WingmanPM API origin")
|
|
84
|
+
.option("--issuer <url>", "trusted Gateway authorization server")
|
|
85
|
+
.option("--timeout <milliseconds>", "per-request timeout", "30000")
|
|
86
|
+
.option("--idempotency-key <key>", "reuse a safe key when retrying an ambiguous POST (1-128 characters)")
|
|
87
|
+
.option("--no-input", "disable interactive input")
|
|
88
|
+
.option("--no-color", "disable ANSI color output")
|
|
89
|
+
.exitOverride()
|
|
90
|
+
.configureOutput({
|
|
91
|
+
writeOut: (value) => (dependencies.stdout ?? process.stdout).write(value),
|
|
92
|
+
writeErr: () => undefined,
|
|
93
|
+
outputError: () => undefined,
|
|
94
|
+
});
|
|
95
|
+
const context = async () => {
|
|
96
|
+
const global = program.opts();
|
|
97
|
+
const stored = await readConfig(configPath(env));
|
|
98
|
+
const runtime = resolveRuntimeConfig(stored, global, env);
|
|
99
|
+
assertTrustedApiUrl(runtime.apiUrl, env);
|
|
100
|
+
assertTrustedIssuer(runtime.issuer, env);
|
|
101
|
+
const output = createOutputContext(global, dependencies.stdout, dependencies.stderr);
|
|
102
|
+
const auth = new AuthManager(vault, runtime, env, fetchImpl, credentialLock);
|
|
103
|
+
const api = new ApiClient({
|
|
104
|
+
apiUrl: runtime.apiUrl,
|
|
105
|
+
timeoutMs: runtime.timeoutMs,
|
|
106
|
+
getAccessToken: async () => (await auth.getSession()).accessToken,
|
|
107
|
+
...(global.idempotencyKey ? { idempotencyKey: global.idempotencyKey } : {}),
|
|
108
|
+
requireExplicitIdempotencyKey: global.agent === true,
|
|
109
|
+
fetchImpl,
|
|
110
|
+
});
|
|
111
|
+
return {
|
|
112
|
+
runtime,
|
|
113
|
+
output,
|
|
114
|
+
vault,
|
|
115
|
+
api,
|
|
116
|
+
auth,
|
|
117
|
+
fetchImpl,
|
|
118
|
+
env,
|
|
119
|
+
credentialLock,
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
registerAuth(program, context, setExitCode);
|
|
123
|
+
registerWhoami(program, context);
|
|
124
|
+
registerDoctor(program, context, setExitCode);
|
|
125
|
+
registerProducts(program, context);
|
|
126
|
+
registerFeedback(program, context);
|
|
127
|
+
registerThemes(program, context);
|
|
128
|
+
registerPrioritize(program, context);
|
|
129
|
+
registerInsights(program, context);
|
|
130
|
+
registerTasks(program, context, setExitCode);
|
|
131
|
+
return program;
|
|
132
|
+
}
|
|
133
|
+
function registerAuth(program, context, _setExitCode) {
|
|
134
|
+
const auth = program.command("auth").description("Manage Wingman authentication");
|
|
135
|
+
auth.command("login")
|
|
136
|
+
.description("Sign in with Gateway device authorization")
|
|
137
|
+
.option("--no-open", "print the URL without opening a browser")
|
|
138
|
+
.action(async (options) => {
|
|
139
|
+
const ctx = await context();
|
|
140
|
+
await ctx.credentialLock.run(async () => {
|
|
141
|
+
if (!await ctx.vault.available()) {
|
|
142
|
+
throw new CliError("credential_vault_unavailable", "The OS credential vault is unavailable. Install/configure the platform credential service, or use WINGMAN_ACCESS_TOKEN for an ephemeral session.", { exitCode: ExitCode.Authentication });
|
|
143
|
+
}
|
|
144
|
+
if (ctx.env.WINGMAN_ACCESS_TOKEN?.trim()) {
|
|
145
|
+
throw new CliError("environment_token_active", "Unset WINGMAN_ACCESS_TOKEN before starting a persistent OAuth login.", { exitCode: ExitCode.Authentication });
|
|
146
|
+
}
|
|
147
|
+
if (await ctx.vault.get()) {
|
|
148
|
+
throw new CliError("already_authenticated", "A WingmanPM OAuth session already exists. Run `wingman auth logout` before signing in again.", { exitCode: ExitCode.Authentication });
|
|
149
|
+
}
|
|
150
|
+
const tokens = await loginWithDeviceAuthorization({
|
|
151
|
+
issuer: ctx.runtime.issuer,
|
|
152
|
+
apiUrl: ctx.runtime.apiUrl,
|
|
153
|
+
timeoutMs: Math.max(ctx.runtime.timeoutMs, 10 * 60_000),
|
|
154
|
+
openBrowser: options.open,
|
|
155
|
+
fetchImpl: ctx.fetchImpl,
|
|
156
|
+
onDeviceAuthorization: ({ userCode, verificationUri }) => {
|
|
157
|
+
ctx.output.stderr.write(`Authorize WingmanPM CLI with code ${userCode}: ${verificationUri}\n`);
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
const account = await verifyAndStoreOAuthSession(tokens, ctx.vault, ctx.runtime, ctx.fetchImpl);
|
|
161
|
+
await writeConfig({
|
|
162
|
+
apiUrl: ctx.runtime.apiUrl,
|
|
163
|
+
issuer: ctx.runtime.issuer,
|
|
164
|
+
...(ctx.runtime.productId ? { productId: ctx.runtime.productId } : {}),
|
|
165
|
+
}, configPath(ctx.env));
|
|
166
|
+
writeData(ctx.output, {
|
|
167
|
+
authenticated: true,
|
|
168
|
+
credential_store: ctx.vault.kind,
|
|
169
|
+
expires_at: new Date(tokens.expiresAt).toISOString(),
|
|
170
|
+
scopes: tokens.scope?.split(/\s+/).filter(Boolean) ?? [],
|
|
171
|
+
account,
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
auth.command("status")
|
|
176
|
+
.description("Show local session status and verify it with WingmanPM")
|
|
177
|
+
.option("--local", "do not call the API")
|
|
178
|
+
.action(async (options) => {
|
|
179
|
+
const ctx = await context();
|
|
180
|
+
const status = await ctx.auth.localStatus();
|
|
181
|
+
if (!status.authenticated || options.local) {
|
|
182
|
+
writeData(ctx.output, status);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const account = await ctx.api.request("/api/v1/cli/context");
|
|
186
|
+
writeData(ctx.output, { ...status, verified: true, account });
|
|
187
|
+
});
|
|
188
|
+
auth.command("logout")
|
|
189
|
+
.description("Revoke the OAuth session remotely, then remove local credentials")
|
|
190
|
+
.action(async () => {
|
|
191
|
+
const ctx = await context();
|
|
192
|
+
await ctx.credentialLock.run(async () => {
|
|
193
|
+
const environmentToken = ctx.env.WINGMAN_ACCESS_TOKEN?.trim();
|
|
194
|
+
const vaultAvailable = await ctx.vault.available();
|
|
195
|
+
let storedRecord = null;
|
|
196
|
+
if (vaultAvailable) {
|
|
197
|
+
try {
|
|
198
|
+
storedRecord = await ctx.vault.get();
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
if (error instanceof CliError && error.code === "credential_vault_corrupt") {
|
|
202
|
+
throw new CliError("credential_vault_corrupt", `The local credential is unreadable, so logout cannot revoke it safely. Contact ${SUPPORT_EMAIL}; run \`wingman auth reset --force-local\` only after support confirms the remote grant was revoked.`, {
|
|
203
|
+
exitCode: ExitCode.Authentication,
|
|
204
|
+
details: {
|
|
205
|
+
action_required: `Contact ${SUPPORT_EMAIL} and wait for confirmation that the CLI grant was revoked before removing the local credential.`,
|
|
206
|
+
},
|
|
207
|
+
cause: error,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const records = [];
|
|
214
|
+
if (environmentToken && environmentToken !== storedRecord?.accessToken) {
|
|
215
|
+
assertOpaqueAccessToken(environmentToken);
|
|
216
|
+
records.push({
|
|
217
|
+
accessToken: environmentToken,
|
|
218
|
+
tokenType: "Bearer",
|
|
219
|
+
expiresAt: Date.now() + 60_000,
|
|
220
|
+
issuer: ctx.runtime.issuer,
|
|
221
|
+
clientId: "wingman-cli-device",
|
|
222
|
+
apiUrl: ctx.runtime.apiUrl,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (storedRecord)
|
|
226
|
+
records.push(storedRecord);
|
|
227
|
+
if (records.length === 0) {
|
|
228
|
+
if (!vaultAvailable && !environmentToken) {
|
|
229
|
+
throw new CliError("credential_vault_unavailable", "The OS credential vault is unavailable and no environment session is set.", { exitCode: ExitCode.Authentication });
|
|
230
|
+
}
|
|
231
|
+
writeData(ctx.output, { authenticated: false, revoked: false });
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
for (const record of records) {
|
|
235
|
+
await revokeTokens(record, ctx.fetchImpl, ctx.runtime.timeoutMs);
|
|
236
|
+
}
|
|
237
|
+
if (storedRecord)
|
|
238
|
+
await ctx.vault.delete();
|
|
239
|
+
writeData(ctx.output, {
|
|
240
|
+
authenticated: false,
|
|
241
|
+
revoked: true,
|
|
242
|
+
...(environmentToken ? {
|
|
243
|
+
environment_token_still_set: true,
|
|
244
|
+
environment_token_revoked: true,
|
|
245
|
+
action_required: "Unset the now-revoked WINGMAN_ACCESS_TOKEN in the calling environment.",
|
|
246
|
+
} : {}),
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
auth.command("reset")
|
|
251
|
+
.description("Remove an unreadable local credential after external revocation")
|
|
252
|
+
.option("--force-local", "confirm local-only removal of a corrupt credential")
|
|
253
|
+
.action(async (options) => {
|
|
254
|
+
if (!options.forceLocal) {
|
|
255
|
+
throw usageError(`auth reset requires --force-local after ${SUPPORT_EMAIL} confirms the CLI authorization was revoked.`);
|
|
256
|
+
}
|
|
257
|
+
const ctx = await context();
|
|
258
|
+
await ctx.credentialLock.run(async () => {
|
|
259
|
+
if (!await ctx.vault.available()) {
|
|
260
|
+
throw new CliError("credential_vault_unavailable", "The OS credential vault is unavailable; no local credential was changed.", { exitCode: ExitCode.Authentication });
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
const record = await ctx.vault.get();
|
|
264
|
+
if (record === null) {
|
|
265
|
+
writeData(ctx.output, {
|
|
266
|
+
authenticated: false,
|
|
267
|
+
local_credential_removed: false,
|
|
268
|
+
});
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
throw new CliError("credential_vault_readable", "The local credential is readable. Run `wingman auth logout` so it is revoked before removal.", { exitCode: ExitCode.Authentication });
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
if (!(error instanceof CliError) || error.code !== "credential_vault_corrupt") {
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
await ctx.vault.delete();
|
|
279
|
+
writeData(ctx.output, {
|
|
280
|
+
authenticated: false,
|
|
281
|
+
revoked: false,
|
|
282
|
+
local_credential_removed: true,
|
|
283
|
+
external_revocation_required: true,
|
|
284
|
+
action_required: `Do not log in again until ${SUPPORT_EMAIL} confirms the remote CLI grant was revoked.`,
|
|
285
|
+
...(ctx.env.WINGMAN_ACCESS_TOKEN?.trim() ? {
|
|
286
|
+
environment_token_still_set: true,
|
|
287
|
+
} : {}),
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function registerWhoami(program, context) {
|
|
293
|
+
program.command("whoami")
|
|
294
|
+
.description("Show effective actor, workspace, role, plan, credits, and access")
|
|
295
|
+
.action(async () => {
|
|
296
|
+
const ctx = await context();
|
|
297
|
+
writeData(ctx.output, await ctx.api.request("/api/v1/cli/context"));
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function registerDoctor(program, context, setExitCode) {
|
|
301
|
+
program.command("doctor")
|
|
302
|
+
.description("Check configuration, credential storage, OAuth, API, and authentication")
|
|
303
|
+
.action(async () => {
|
|
304
|
+
const ctx = await context();
|
|
305
|
+
const checks = [];
|
|
306
|
+
const environmentSession = Boolean(ctx.env.WINGMAN_ACCESS_TOKEN?.trim());
|
|
307
|
+
checks.push({ check: "config", ok: true, detail: "No secrets are stored in config." });
|
|
308
|
+
const vaultAvailable = await ctx.vault.available();
|
|
309
|
+
checks.push({
|
|
310
|
+
check: "credential_vault",
|
|
311
|
+
ok: vaultAvailable || environmentSession,
|
|
312
|
+
detail: vaultAvailable
|
|
313
|
+
? ctx.vault.kind
|
|
314
|
+
: environmentSession
|
|
315
|
+
? `${ctx.vault.kind}; ephemeral environment session active.`
|
|
316
|
+
: ctx.vault.kind,
|
|
317
|
+
});
|
|
318
|
+
try {
|
|
319
|
+
await discoverAuthorizationServer(ctx.runtime.issuer, ctx.fetchImpl, ctx.runtime.timeoutMs);
|
|
320
|
+
checks.push({ check: "oauth_discovery", ok: true, detail: ctx.runtime.issuer });
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
checks.push({ check: "oauth_discovery", ok: false, detail: errorMessage(error) });
|
|
324
|
+
}
|
|
325
|
+
try {
|
|
326
|
+
const response = await ctx.fetchImpl(`${ctx.runtime.apiUrl}/api/v1/health`, {
|
|
327
|
+
headers: { Accept: "application/json" },
|
|
328
|
+
signal: AbortSignal.timeout(ctx.runtime.timeoutMs),
|
|
329
|
+
redirect: "error",
|
|
330
|
+
});
|
|
331
|
+
checks.push({ check: "api", ok: response.ok, detail: `HTTP ${response.status}` });
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
checks.push({ check: "api", ok: false, detail: errorMessage(error) });
|
|
335
|
+
}
|
|
336
|
+
try {
|
|
337
|
+
const status = await ctx.auth.localStatus();
|
|
338
|
+
if (!status.authenticated) {
|
|
339
|
+
checks.push({ check: "authentication", ok: false, detail: "No session." });
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
await ctx.api.request("/api/v1/cli/context");
|
|
343
|
+
checks.push({
|
|
344
|
+
check: "authentication",
|
|
345
|
+
ok: true,
|
|
346
|
+
detail: status.source ?? "credential-vault",
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
checks.push({ check: "authentication", ok: false, detail: errorMessage(error) });
|
|
352
|
+
}
|
|
353
|
+
const ok = checks.every((check) => check.ok);
|
|
354
|
+
writeData(ctx.output, { ok, checks });
|
|
355
|
+
if (!ok)
|
|
356
|
+
setExitCode(ExitCode.Service);
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
function registerProducts(program, context) {
|
|
360
|
+
const products = program.command("products").description("Read and update authorized products");
|
|
361
|
+
products.command("list")
|
|
362
|
+
.description("List products visible to the current account")
|
|
363
|
+
.action(async () => {
|
|
364
|
+
const ctx = await context();
|
|
365
|
+
writeData(ctx.output, await ctx.api.request("/api/v1/products"));
|
|
366
|
+
});
|
|
367
|
+
products.command("show [product]")
|
|
368
|
+
.description("Show one product")
|
|
369
|
+
.action(async (product) => {
|
|
370
|
+
const ctx = await context();
|
|
371
|
+
const id = await resolveProductId(ctx, product);
|
|
372
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${encodeURIComponent(id)}`));
|
|
373
|
+
});
|
|
374
|
+
products.command("create")
|
|
375
|
+
.description("Create a product (server plan limits apply)")
|
|
376
|
+
.option("--name <name>")
|
|
377
|
+
.option("--description <description>")
|
|
378
|
+
.option("--region <region>")
|
|
379
|
+
.option("--data-residency <region>")
|
|
380
|
+
.option("--timezone <timezone>")
|
|
381
|
+
.option("--color <hex>")
|
|
382
|
+
.option("--data <json-or-file>", "JSON object or @file")
|
|
383
|
+
.action(async (options) => {
|
|
384
|
+
const ctx = await context();
|
|
385
|
+
const body = validateBody(ProductCreateSchema, mergeDefined(await parseDataOption(options.data), {
|
|
386
|
+
name: options.name,
|
|
387
|
+
description: options.description,
|
|
388
|
+
region: options.region,
|
|
389
|
+
data_residency: options.dataResidency,
|
|
390
|
+
timezone: options.timezone,
|
|
391
|
+
color: options.color,
|
|
392
|
+
}));
|
|
393
|
+
writeData(ctx.output, await ctx.api.request("/api/v1/products", { method: "POST", body }));
|
|
394
|
+
});
|
|
395
|
+
products.command("update [product]")
|
|
396
|
+
.description("Update a product")
|
|
397
|
+
.option("--name <name>")
|
|
398
|
+
.option("--description <description>")
|
|
399
|
+
.option("--region <region>")
|
|
400
|
+
.option("--data-residency <region>")
|
|
401
|
+
.option("--timezone <timezone>")
|
|
402
|
+
.option("--color <hex>")
|
|
403
|
+
.option("--data <json-or-file>", "JSON object or @file")
|
|
404
|
+
.action(async (product, options) => {
|
|
405
|
+
const ctx = await context();
|
|
406
|
+
const id = await resolveProductId(ctx, product);
|
|
407
|
+
const body = validateBody(ProductUpdateSchema, mergeDefined(await parseDataOption(options.data), {
|
|
408
|
+
name: options.name,
|
|
409
|
+
description: options.description,
|
|
410
|
+
region: options.region,
|
|
411
|
+
data_residency: options.dataResidency,
|
|
412
|
+
timezone: options.timezone,
|
|
413
|
+
color: options.color,
|
|
414
|
+
}));
|
|
415
|
+
requireNonEmptyBody(body);
|
|
416
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${encodeURIComponent(id)}`, {
|
|
417
|
+
method: "PATCH", body,
|
|
418
|
+
}));
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function registerFeedback(program, context) {
|
|
422
|
+
const feedback = program.command("feedback").description("Read, add, and update feedback");
|
|
423
|
+
feedback.command("list")
|
|
424
|
+
.description("List feedback items")
|
|
425
|
+
.option("--theme-id <id>")
|
|
426
|
+
.option("--source-id <id...>")
|
|
427
|
+
.option("--file-id <id>")
|
|
428
|
+
.option("--sentiment <value>")
|
|
429
|
+
.option("--classification <value>")
|
|
430
|
+
.option("--search <text>")
|
|
431
|
+
.option("--unthemed-only")
|
|
432
|
+
.option("--resolution-status <open|completed|all>")
|
|
433
|
+
.option("--limit <number>", "page size", "50")
|
|
434
|
+
.option("--offset <number>", "page offset", "0")
|
|
435
|
+
.action(async (options) => {
|
|
436
|
+
const ctx = await context();
|
|
437
|
+
const product = await resolveProductId(ctx);
|
|
438
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/feedback-items`, {
|
|
439
|
+
query: {
|
|
440
|
+
theme_id: stringOption(options.themeId),
|
|
441
|
+
source_id: arrayOption(options.sourceId),
|
|
442
|
+
file_id: stringOption(options.fileId),
|
|
443
|
+
sentiment: stringOption(options.sentiment),
|
|
444
|
+
classification: stringOption(options.classification),
|
|
445
|
+
search: stringOption(options.search),
|
|
446
|
+
unthemed_only: options.unthemedOnly === true ? true : undefined,
|
|
447
|
+
resolution_status: stringOption(options.resolutionStatus),
|
|
448
|
+
limit: parseInteger(String(options.limit), "--limit", 1, 100),
|
|
449
|
+
offset: parseInteger(String(options.offset), "--offset", 0),
|
|
450
|
+
},
|
|
451
|
+
}));
|
|
452
|
+
});
|
|
453
|
+
feedback.command("show <item-id>")
|
|
454
|
+
.description("Show one feedback item")
|
|
455
|
+
.option("--details", "include related theme and source details")
|
|
456
|
+
.action(async (itemId, options) => {
|
|
457
|
+
const ctx = await context();
|
|
458
|
+
const product = await resolveProductId(ctx);
|
|
459
|
+
const suffix = options.details ? "/details" : "";
|
|
460
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/feedback-items/${encodeURIComponent(itemId)}${suffix}`));
|
|
461
|
+
});
|
|
462
|
+
feedback.command("add")
|
|
463
|
+
.description("Add feedback through the dedicated CLI-safe ingestion endpoint")
|
|
464
|
+
.option("--text <text>")
|
|
465
|
+
.option("--submitter <submitter>")
|
|
466
|
+
.option("--metadata <json>")
|
|
467
|
+
.option("--data <json-or-file>", "JSON object or @file")
|
|
468
|
+
.action(async (options) => {
|
|
469
|
+
const ctx = await context();
|
|
470
|
+
const product = await resolveProductId(ctx);
|
|
471
|
+
const body = validateBody(FeedbackCreateSchema, mergeDefined(await parseDataOption(options.data), {
|
|
472
|
+
text: options.text,
|
|
473
|
+
submitter: options.submitter,
|
|
474
|
+
metadata_jsonb: parseJsonField(options.metadata, "--metadata"),
|
|
475
|
+
}));
|
|
476
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/feedback-items`, {
|
|
477
|
+
method: "POST", body,
|
|
478
|
+
}));
|
|
479
|
+
});
|
|
480
|
+
feedback.command("update <item-id>")
|
|
481
|
+
.description("Update a feedback item")
|
|
482
|
+
.option("--text <text>")
|
|
483
|
+
.option("--submitter <submitter>")
|
|
484
|
+
.option("--sentiment <value>")
|
|
485
|
+
.option("--classification <value>")
|
|
486
|
+
.option("--description <description>")
|
|
487
|
+
.option("--theme-id <id>")
|
|
488
|
+
.option("--clear-theme", "unlink the item from its theme")
|
|
489
|
+
.option("--metadata <json>")
|
|
490
|
+
.option("--scores <json>")
|
|
491
|
+
.option("--data <json-or-file>", "JSON object or @file")
|
|
492
|
+
.action(async (itemId, options) => {
|
|
493
|
+
const ctx = await context();
|
|
494
|
+
const product = await resolveProductId(ctx);
|
|
495
|
+
if (options.clearTheme && options.themeId)
|
|
496
|
+
throw usageError("Use either --theme-id or --clear-theme, not both.");
|
|
497
|
+
const body = validateBody(FeedbackUpdateSchema, mergeDefined(await parseDataOption(stringOption(options.data)), {
|
|
498
|
+
text: options.text,
|
|
499
|
+
submitter: options.submitter,
|
|
500
|
+
sentiment: options.sentiment,
|
|
501
|
+
classification: options.classification,
|
|
502
|
+
description: options.description,
|
|
503
|
+
theme_id: options.clearTheme ? null : options.themeId,
|
|
504
|
+
metadata_jsonb: parseJsonField(stringOption(options.metadata), "--metadata"),
|
|
505
|
+
scores_jsonb: parseJsonField(stringOption(options.scores), "--scores"),
|
|
506
|
+
}));
|
|
507
|
+
requireNonEmptyBody(body);
|
|
508
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/feedback-items/${encodeURIComponent(itemId)}`, { method: "PATCH", body }));
|
|
509
|
+
});
|
|
510
|
+
feedback.command("summary")
|
|
511
|
+
.description("Show aggregate feedback summary")
|
|
512
|
+
.action(async () => {
|
|
513
|
+
const ctx = await context();
|
|
514
|
+
const product = await resolveProductId(ctx);
|
|
515
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/feedback/summary`));
|
|
516
|
+
});
|
|
517
|
+
feedback.command("export")
|
|
518
|
+
.description("Export feedback as CSV; use --output csv for raw CSV")
|
|
519
|
+
.option("--theme-id <id>")
|
|
520
|
+
.option("--source-id <id>")
|
|
521
|
+
.action(async (options) => {
|
|
522
|
+
const ctx = await context();
|
|
523
|
+
const product = await resolveProductId(ctx);
|
|
524
|
+
const csv = await ctx.api.request(`/api/v1/products/${product}/feedback-items/export`, {
|
|
525
|
+
query: { theme_id: options.themeId, source_id: options.sourceId },
|
|
526
|
+
accept: "text/csv",
|
|
527
|
+
raw: true,
|
|
528
|
+
});
|
|
529
|
+
if (ctx.output.format === "csv" || ctx.output.format === "table") {
|
|
530
|
+
writeCsvDocument(ctx.output, csv);
|
|
531
|
+
}
|
|
532
|
+
else
|
|
533
|
+
writeData(ctx.output, { format: "csv", data: sanitizeCsvDocument(csv) });
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
function registerThemes(program, context) {
|
|
537
|
+
const themes = program.command("themes").description("Read, create, and update feedback themes");
|
|
538
|
+
themes.command("list")
|
|
539
|
+
.description("List themes")
|
|
540
|
+
.option("--status <status>", "active, solved, archived, or all")
|
|
541
|
+
.option("--non-empty-only")
|
|
542
|
+
.option("--limit <number>", "page size", "50")
|
|
543
|
+
.option("--offset <number>", "page offset", "0")
|
|
544
|
+
.action(async (options) => {
|
|
545
|
+
const ctx = await context();
|
|
546
|
+
const product = await resolveProductId(ctx);
|
|
547
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/themes`, {
|
|
548
|
+
query: {
|
|
549
|
+
status: options.status,
|
|
550
|
+
non_empty_only: options.nonEmptyOnly === true ? true : undefined,
|
|
551
|
+
limit: parseInteger(options.limit, "--limit", 1, 100),
|
|
552
|
+
offset: parseInteger(options.offset, "--offset", 0),
|
|
553
|
+
},
|
|
554
|
+
}));
|
|
555
|
+
});
|
|
556
|
+
themes.command("show <theme-id>")
|
|
557
|
+
.description("Show one theme")
|
|
558
|
+
.action(async (themeId) => {
|
|
559
|
+
const ctx = await context();
|
|
560
|
+
const product = await resolveProductId(ctx);
|
|
561
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/themes/${encodeURIComponent(themeId)}`));
|
|
562
|
+
});
|
|
563
|
+
themes.command("items <theme-id>")
|
|
564
|
+
.description("Show a theme with its feedback items")
|
|
565
|
+
.option("--limit <number>", "item page size", "50")
|
|
566
|
+
.option("--offset <number>", "item page offset", "0")
|
|
567
|
+
.action(async (themeId, options) => {
|
|
568
|
+
const ctx = await context();
|
|
569
|
+
const product = await resolveProductId(ctx);
|
|
570
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/themes/${encodeURIComponent(themeId)}/items`, { query: {
|
|
571
|
+
items_limit: parseInteger(options.limit, "--limit", 1, 100),
|
|
572
|
+
items_offset: parseInteger(options.offset, "--offset", 0),
|
|
573
|
+
} }));
|
|
574
|
+
});
|
|
575
|
+
themes.command("create")
|
|
576
|
+
.description("Create a theme")
|
|
577
|
+
.option("--name <name>")
|
|
578
|
+
.option("--summary <summary>")
|
|
579
|
+
.option("--sentiment <value>")
|
|
580
|
+
.option("--data <json-or-file>", "JSON object or @file")
|
|
581
|
+
.action(async (options) => {
|
|
582
|
+
const ctx = await context();
|
|
583
|
+
const product = await resolveProductId(ctx);
|
|
584
|
+
const body = validateBody(ThemeCreateSchema, mergeDefined(await parseDataOption(options.data), {
|
|
585
|
+
name: options.name, summary: options.summary, sentiment: options.sentiment,
|
|
586
|
+
}));
|
|
587
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/themes`, {
|
|
588
|
+
method: "POST", body,
|
|
589
|
+
}));
|
|
590
|
+
});
|
|
591
|
+
themes.command("update <theme-id>")
|
|
592
|
+
.description("Update a theme")
|
|
593
|
+
.option("--name <name>")
|
|
594
|
+
.option("--summary <summary>")
|
|
595
|
+
.option("--sentiment <value>")
|
|
596
|
+
.option("--metadata <json>")
|
|
597
|
+
.option("--scores <json>")
|
|
598
|
+
.option("--data <json-or-file>", "JSON object or @file")
|
|
599
|
+
.action(async (themeId, options) => {
|
|
600
|
+
const ctx = await context();
|
|
601
|
+
const product = await resolveProductId(ctx);
|
|
602
|
+
const body = validateBody(ThemeUpdateSchema, mergeDefined(await parseDataOption(options.data), {
|
|
603
|
+
name: options.name,
|
|
604
|
+
summary: options.summary,
|
|
605
|
+
sentiment: options.sentiment,
|
|
606
|
+
metadata_jsonb: parseJsonField(options.metadata, "--metadata"),
|
|
607
|
+
scores_jsonb: parseJsonField(options.scores, "--scores"),
|
|
608
|
+
}));
|
|
609
|
+
requireNonEmptyBody(body);
|
|
610
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/themes/${encodeURIComponent(themeId)}`, { method: "PATCH", body }));
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
function registerPrioritize(program, context) {
|
|
614
|
+
const prioritize = program.command("prioritize").description("Read prioritization scores");
|
|
615
|
+
prioritize.command("list")
|
|
616
|
+
.description("List prioritization scores")
|
|
617
|
+
.option("--theme-id <id>")
|
|
618
|
+
.option("--framework <framework>")
|
|
619
|
+
.option("--active-only")
|
|
620
|
+
.option("--limit <number>", "page size", "50")
|
|
621
|
+
.option("--offset <number>", "page offset", "0")
|
|
622
|
+
.action(async (options) => {
|
|
623
|
+
const ctx = await context();
|
|
624
|
+
const product = await resolveProductId(ctx);
|
|
625
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/prioritization/scores`, {
|
|
626
|
+
query: {
|
|
627
|
+
theme_id: options.themeId,
|
|
628
|
+
framework: options.framework,
|
|
629
|
+
active_only: options.activeOnly === true ? true : undefined,
|
|
630
|
+
limit: parseInteger(options.limit, "--limit", 1, 100),
|
|
631
|
+
offset: parseInteger(options.offset, "--offset", 0),
|
|
632
|
+
},
|
|
633
|
+
}));
|
|
634
|
+
});
|
|
635
|
+
prioritize.command("show <score-id>")
|
|
636
|
+
.description("Show one prioritization score")
|
|
637
|
+
.action(async (scoreId) => {
|
|
638
|
+
const ctx = await context();
|
|
639
|
+
const product = await resolveProductId(ctx);
|
|
640
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/prioritization/scores/${encodeURIComponent(scoreId)}`));
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
function registerInsights(program, context) {
|
|
644
|
+
const insights = program.command("insights").description("Read product and portfolio insights");
|
|
645
|
+
insights.command("overview")
|
|
646
|
+
.description("Show the product command-deck overview")
|
|
647
|
+
.option("--timeframe <all|7d|30d|quarter>", "timeframe", "all")
|
|
648
|
+
.action(async (options) => {
|
|
649
|
+
const ctx = await context();
|
|
650
|
+
const product = await resolveProductId(ctx);
|
|
651
|
+
writeData(ctx.output, await ctx.api.request("/api/v1/stats/command-deck", {
|
|
652
|
+
query: { product_id: product, timeframe: options.timeframe },
|
|
653
|
+
}));
|
|
654
|
+
});
|
|
655
|
+
insights.command("portfolio")
|
|
656
|
+
.description("Show authorized workspace-wide portfolio insights")
|
|
657
|
+
.option("--timeframe <all|7d|30d|quarter>", "timeframe", "30d")
|
|
658
|
+
.action(async (options) => {
|
|
659
|
+
const ctx = await context();
|
|
660
|
+
writeData(ctx.output, await ctx.api.request("/api/v1/stats/portfolio", {
|
|
661
|
+
query: { timeframe: options.timeframe },
|
|
662
|
+
}));
|
|
663
|
+
});
|
|
664
|
+
insights.command("health")
|
|
665
|
+
.description("Show deterministic Wingman health score")
|
|
666
|
+
.action(async () => {
|
|
667
|
+
const ctx = await context();
|
|
668
|
+
const product = await resolveProductId(ctx);
|
|
669
|
+
writeData(ctx.output, await ctx.api.request(`/api/v1/products/${product}/health`));
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
function registerTasks(program, context, setExitCode) {
|
|
673
|
+
const tasks = program.command("tasks").description("Inspect asynchronous task runs");
|
|
674
|
+
tasks.command("show <task-id>")
|
|
675
|
+
.description("Show a task run")
|
|
676
|
+
.action(async (taskId) => {
|
|
677
|
+
const ctx = await context();
|
|
678
|
+
const product = await resolveProductId(ctx);
|
|
679
|
+
const task = TaskSchema.parse(await fetchTask(ctx, product, taskId));
|
|
680
|
+
writeData(ctx.output, task);
|
|
681
|
+
setTaskExitCode(task, setExitCode);
|
|
682
|
+
});
|
|
683
|
+
tasks.command("wait <task-id>")
|
|
684
|
+
.description("Poll until a task completes, fails, or is cancelled")
|
|
685
|
+
.option("--interval <milliseconds>", "poll interval", "2000")
|
|
686
|
+
.option("--wait-timeout <milliseconds>", "overall wait timeout", "600000")
|
|
687
|
+
.action(async (taskId, options) => {
|
|
688
|
+
const ctx = await context();
|
|
689
|
+
const product = await resolveProductId(ctx);
|
|
690
|
+
const interval = parseInteger(options.interval, "--interval", 250, 60_000);
|
|
691
|
+
const waitTimeout = parseInteger(options.waitTimeout, "--wait-timeout", interval, 3_600_000);
|
|
692
|
+
const started = Date.now();
|
|
693
|
+
let task = TaskSchema.parse(await fetchTask(ctx, product, taskId));
|
|
694
|
+
while (!TERMINAL_TASK_STATUSES.has(task.status)) {
|
|
695
|
+
if (Date.now() - started >= waitTimeout) {
|
|
696
|
+
throw new CliError("task_wait_timeout", "Timed out waiting for task completion.", {
|
|
697
|
+
exitCode: ExitCode.Timeout,
|
|
698
|
+
retryable: true,
|
|
699
|
+
details: { task_id: task.id, status: task.status },
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
await delay(interval);
|
|
703
|
+
task = TaskSchema.parse(await fetchTask(ctx, product, taskId));
|
|
704
|
+
}
|
|
705
|
+
writeData(ctx.output, task);
|
|
706
|
+
setTaskExitCode(task, setExitCode);
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
async function fetchTask(ctx, product, taskId) {
|
|
710
|
+
return await ctx.api.request(`/api/v1/products/${product}/tasks/${encodeURIComponent(taskId)}`);
|
|
711
|
+
}
|
|
712
|
+
async function resolveProductId(ctx, explicit) {
|
|
713
|
+
const identifier = explicit ?? ctx.runtime.productId;
|
|
714
|
+
if (!identifier) {
|
|
715
|
+
throw usageError("A product is required. Pass --product <uuid-or-exact-name>.");
|
|
716
|
+
}
|
|
717
|
+
if (isUuid(identifier))
|
|
718
|
+
return identifier;
|
|
719
|
+
const products = ProductListSchema.parse(await ctx.api.request("/api/v1/products"));
|
|
720
|
+
const matches = products.filter((product) => product.name.toLocaleLowerCase() === identifier.toLocaleLowerCase());
|
|
721
|
+
if (matches.length === 0) {
|
|
722
|
+
throw new CliError("product_not_found", `No authorized product named ${JSON.stringify(identifier)} was found.`, {
|
|
723
|
+
exitCode: ExitCode.NotFound,
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
if (matches.length > 1) {
|
|
727
|
+
throw usageError(`Product name ${JSON.stringify(identifier)} is ambiguous; use a UUID.`);
|
|
728
|
+
}
|
|
729
|
+
return matches[0]?.id ?? identifier;
|
|
730
|
+
}
|
|
731
|
+
function setTaskExitCode(task, setExitCode) {
|
|
732
|
+
if (task.status === "completed" && task.is_partial === true) {
|
|
733
|
+
setExitCode(ExitCode.Partial);
|
|
734
|
+
}
|
|
735
|
+
else if (task.status === "failed" || task.status === "cancelled") {
|
|
736
|
+
setExitCode(ExitCode.Service);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
function requireNonEmptyBody(body) {
|
|
740
|
+
if (Object.keys(body).length === 0)
|
|
741
|
+
throw usageError("At least one update field is required.");
|
|
742
|
+
}
|
|
743
|
+
function validateBody(schema, body) {
|
|
744
|
+
try {
|
|
745
|
+
return schema.parse(body);
|
|
746
|
+
}
|
|
747
|
+
catch (error) {
|
|
748
|
+
if (error instanceof z.ZodError) {
|
|
749
|
+
throw usageError("Command payload is invalid.", error.issues);
|
|
750
|
+
}
|
|
751
|
+
throw error;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
function stringOption(value) {
|
|
755
|
+
return typeof value === "string" ? value : undefined;
|
|
756
|
+
}
|
|
757
|
+
function arrayOption(value) {
|
|
758
|
+
if (Array.isArray(value))
|
|
759
|
+
return value;
|
|
760
|
+
return typeof value === "string" ? [value] : undefined;
|
|
761
|
+
}
|
|
762
|
+
function isUuid(value) {
|
|
763
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
764
|
+
}
|
|
765
|
+
function errorMessage(error) {
|
|
766
|
+
return error instanceof Error ? error.message : String(error);
|
|
767
|
+
}
|
|
768
|
+
async function delay(milliseconds) {
|
|
769
|
+
await new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
770
|
+
}
|
|
771
|
+
//# sourceMappingURL=program.js.map
|