@wave-ai-os/wave-cli 0.1.62 → 0.1.63

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 (4) hide show
  1. package/README.md +15 -10
  2. package/dist/index.cjs +306 -330
  3. package/dist/index.js +306 -330
  4. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -107,10 +107,10 @@ function parseDebug(rawDebugEnv) {
107
107
  return lowered === "1" || lowered === "true" || lowered === "yes";
108
108
  }
109
109
  function getConfig(options) {
110
- const token = options.token ?? options.jwt ?? process.env.WAVE_API_TOKEN ?? process.env.WAVE_JWT;
110
+ const token = options.token ?? process.env.WAVE_API_TOKEN;
111
111
  if (!token) {
112
112
  throw new CliError({
113
- message: "Missing API token. Pass --token/--jwt, use --token-stdin/--auth-json-stdin, or set WAVE_API_TOKEN/WAVE_JWT.",
113
+ message: "Missing API token. Pass --token, use --token-stdin/--auth-json-stdin, or set WAVE_API_TOKEN.",
114
114
  kind: "missing_auth",
115
115
  status: 401,
116
116
  exitCode: EXIT_CODES.missingOrInvalidAuth
@@ -2017,7 +2017,142 @@ async function getAuthStorageInfo(baseUrl) {
2017
2017
  return { kind: "file", available, path };
2018
2018
  }
2019
2019
 
2020
+ // src/authClient.ts
2021
+ var import_node_crypto2 = require("crypto");
2022
+
2023
+ // src/redaction.ts
2024
+ var TOKENISH_PATTERNS = [
2025
+ /\b(?:cli|wave|token|secret|bearer)[A-Za-z0-9._~+/=-]{8,}\b/gi,
2026
+ /\b[A-Za-z0-9._~+/=-]{24,}\b/g
2027
+ ];
2028
+ function redactOne(value) {
2029
+ if (value.length <= 8) {
2030
+ return "[redacted]";
2031
+ }
2032
+ return `${value.slice(0, 4)}...[redacted]...${value.slice(-4)}`;
2033
+ }
2034
+ function redactSecrets(input, knownSecrets = []) {
2035
+ let output = input;
2036
+ for (const secret of knownSecrets) {
2037
+ if (!secret) continue;
2038
+ output = output.split(secret).join(redactOne(secret));
2039
+ }
2040
+ for (const pattern of TOKENISH_PATTERNS) {
2041
+ output = output.replace(pattern, (match) => redactOne(match));
2042
+ }
2043
+ return output;
2044
+ }
2045
+ function redactUnknown(input, knownSecrets = []) {
2046
+ if (typeof input === "string") {
2047
+ return redactSecrets(input, knownSecrets);
2048
+ }
2049
+ if (Array.isArray(input)) {
2050
+ return input.map((entry2) => redactUnknown(entry2, knownSecrets));
2051
+ }
2052
+ if (!input || typeof input !== "object") {
2053
+ return input;
2054
+ }
2055
+ const output = {};
2056
+ for (const [key, value] of Object.entries(input)) {
2057
+ if (/token|secret|authorization|bearer/i.test(key)) {
2058
+ output[key] = typeof value === "string" ? redactSecrets(value, knownSecrets) : "[redacted]";
2059
+ continue;
2060
+ }
2061
+ output[key] = redactUnknown(value, knownSecrets);
2062
+ }
2063
+ return output;
2064
+ }
2065
+
2066
+ // src/authClient.ts
2067
+ function parseJsonSafely2(input) {
2068
+ try {
2069
+ return JSON.parse(input);
2070
+ } catch {
2071
+ return null;
2072
+ }
2073
+ }
2074
+ function graphqlErrors(payload, knownSecrets) {
2075
+ const errors = payload.errors;
2076
+ if (!Array.isArray(errors) || errors.length === 0) return null;
2077
+ return {
2078
+ code: "upstream_error",
2079
+ message: "GraphQL request failed.",
2080
+ status: 400,
2081
+ details: {
2082
+ errors: redactUnknown(errors, knownSecrets)
2083
+ }
2084
+ };
2085
+ }
2086
+ async function authGraphqlRequest(params) {
2087
+ const requestId = (0, import_node_crypto2.randomUUID)();
2088
+ const controller = new AbortController();
2089
+ const timeoutId = setTimeout(() => controller.abort(), params.timeoutMs);
2090
+ const knownSecrets = [params.token, ...params.knownSecrets ?? []].filter(
2091
+ (secret) => typeof secret === "string" && secret.length > 0
2092
+ );
2093
+ try {
2094
+ const url = new URL("/graphql", params.baseUrl);
2095
+ const response = await fetch(url, {
2096
+ method: "POST",
2097
+ headers: {
2098
+ Accept: "application/json",
2099
+ "Content-Type": "application/json",
2100
+ "X-Origin": "wave-cli",
2101
+ "X-Request-Id": requestId,
2102
+ ...params.token ? { Authorization: `Bearer ${params.token}` } : {}
2103
+ },
2104
+ body: JSON.stringify({ query: params.query, variables: params.variables ?? {} }),
2105
+ signal: controller.signal
2106
+ });
2107
+ const responseRequestId = response.headers.get("x-request-id") ?? requestId;
2108
+ const text = await response.text();
2109
+ const payload = text ? parseJsonSafely2(text) : null;
2110
+ const graph = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
2111
+ const gqlError = graphqlErrors(graph, knownSecrets);
2112
+ if (gqlError) {
2113
+ return { ok: false, error: gqlError, requestId: responseRequestId };
2114
+ }
2115
+ if (!response.ok) {
2116
+ return {
2117
+ ok: false,
2118
+ requestId: responseRequestId,
2119
+ error: {
2120
+ code: `http_${response.status}`,
2121
+ message: "Auth request failed.",
2122
+ status: response.status,
2123
+ details: { body: redactUnknown(graph, knownSecrets) }
2124
+ }
2125
+ };
2126
+ }
2127
+ const data = graph.data && typeof graph.data === "object" && !Array.isArray(graph.data) ? graph.data : {};
2128
+ return {
2129
+ ok: true,
2130
+ result: {
2131
+ status: response.status,
2132
+ requestId: responseRequestId,
2133
+ data
2134
+ }
2135
+ };
2136
+ } catch (error) {
2137
+ const message = error instanceof Error ? error.message : "Network error.";
2138
+ const timedOut = error instanceof Error && error.name === "AbortError";
2139
+ return {
2140
+ ok: false,
2141
+ requestId,
2142
+ error: {
2143
+ code: timedOut ? "timeout" : "network_error",
2144
+ message: redactSecrets(timedOut ? "Auth request timed out." : message, knownSecrets),
2145
+ status: timedOut ? 408 : 503,
2146
+ details: {}
2147
+ }
2148
+ };
2149
+ } finally {
2150
+ clearTimeout(timeoutId);
2151
+ }
2152
+ }
2153
+
2020
2154
  // src/commands/runtimeOptions.ts
2155
+ var CLI_AUTH_STATUS_QUERY = "query WaveCliAuthenticatedOrganization { cliAuthStatus { authenticated baseAuthStatus organization { id slug } } }";
2021
2156
  var stdinPromise = null;
2022
2157
  function normalize3(raw) {
2023
2158
  if (typeof raw !== "string") {
@@ -2051,7 +2186,6 @@ function parseAuthJson(raw) {
2051
2186
  const obj = parsed;
2052
2187
  return {
2053
2188
  token: normalize3(obj.token),
2054
- jwt: normalize3(obj.jwt),
2055
2189
  baseUrl: normalize3(obj.baseUrl ?? obj.base_url),
2056
2190
  organizationId: normalize3(obj.organizationId ?? obj.organization_id),
2057
2191
  timeoutMs: typeof obj.timeoutMs === "number" || typeof obj.timeoutMs === "string" ? obj.timeoutMs : typeof obj.timeout_ms === "number" || typeof obj.timeout_ms === "string" ? obj.timeout_ms : void 0,
@@ -2134,13 +2268,10 @@ function firstDefined(...values) {
2134
2268
  function resolveAuthToken(options, stdin, config, env) {
2135
2269
  const candidates = [
2136
2270
  { token: normalize3(options.token), source: "flag" },
2137
- { token: normalize3(options.jwt), source: "flag" },
2138
2271
  { token: normalize3(stdin.token), source: "stdin" },
2139
- { token: normalize3(stdin.jwt), source: "stdin" },
2140
2272
  { token: normalize3(env.WAVE_API_TOKEN), source: "env" },
2141
- { token: normalize3(env.WAVE_JWT), source: "env" },
2142
2273
  { token: normalize3(config.token), source: "config" },
2143
- { token: normalize3(config.jwt), source: "config" }
2274
+ { token: normalize3(config.token), source: "config" }
2144
2275
  ];
2145
2276
  return candidates.find((candidate) => candidate.token) ?? { source: "none" };
2146
2277
  }
@@ -2291,6 +2422,34 @@ async function resolveWithStoredToken(context) {
2291
2422
  }
2292
2423
  };
2293
2424
  }
2425
+ async function resolveWithAuthenticatedOrganization(context) {
2426
+ if (context.organizationIdSource === "flag" && context.organizationId) {
2427
+ return context;
2428
+ }
2429
+ const baseUrl = normalize3(context.runtimeOptions.baseUrl);
2430
+ const token = normalize3(context.runtimeOptions.token);
2431
+ if (!baseUrl || !token) {
2432
+ return {
2433
+ ...context,
2434
+ organizationId: void 0,
2435
+ organizationIdSource: "none",
2436
+ runtimeOptions: { ...context.runtimeOptions, organizationId: void 0 }
2437
+ };
2438
+ }
2439
+ const response = await authGraphqlRequest({
2440
+ baseUrl,
2441
+ token,
2442
+ timeoutMs: typeof context.runtimeOptions.timeoutMs === "number" ? context.runtimeOptions.timeoutMs : 1e4,
2443
+ query: CLI_AUTH_STATUS_QUERY
2444
+ });
2445
+ const organizationId = response.ok ? organizationIdFromCliAuthStatus(response.result.data) : void 0;
2446
+ return {
2447
+ ...context,
2448
+ organizationId,
2449
+ organizationIdSource: organizationId ? "token" : "none",
2450
+ runtimeOptions: { ...context.runtimeOptions, organizationId }
2451
+ };
2452
+ }
2294
2453
  function defaultConfigPath(env) {
2295
2454
  const explicitEnv = normalize3(env.WAVE_CONFIG_PATH);
2296
2455
  if (explicitEnv) return explicitEnv;
@@ -2353,11 +2512,21 @@ async function resolveStdinContext(options) {
2353
2512
  }
2354
2513
  return parseAuthJson(raw);
2355
2514
  }
2356
- async function resolveCommandContext(options) {
2515
+ async function resolveUnscopedCommandContext(options) {
2357
2516
  const stdin = await resolveStdinContext(options);
2358
2517
  const config = await resolveConfigFileContext(options, process.env);
2359
2518
  return resolveWithStoredToken(resolveFromSources(options, stdin, config, process.env));
2360
2519
  }
2520
+ async function resolveCommandContext(options) {
2521
+ return resolveWithAuthenticatedOrganization(await resolveUnscopedCommandContext(options));
2522
+ }
2523
+ function organizationIdFromCliAuthStatus(data) {
2524
+ const status = data.cliAuthStatus;
2525
+ if (!status || typeof status !== "object" || Array.isArray(status)) return void 0;
2526
+ const organization = status.organization;
2527
+ if (!organization || typeof organization !== "object" || Array.isArray(organization)) return void 0;
2528
+ return normalize3(organization.id);
2529
+ }
2361
2530
 
2362
2531
  // src/commands/organization.ts
2363
2532
  function normalize4(input) {
@@ -2371,10 +2540,14 @@ function resolveOrganizationId(raw) {
2371
2540
  const organizationId = normalize4(raw);
2372
2541
  if (!organizationId) {
2373
2542
  throw new CliError({
2374
- message: "Missing organization ID. Pass --organization-id, provide via --auth-json-stdin, or set WAVE_ORGANIZATION_ID.",
2375
- kind: "invalid_args",
2376
- status: 400,
2377
- exitCode: EXIT_CODES.invalidArgs
2543
+ message: "Missing authenticated organization scope. Pass --organization-id explicitly or authenticate with a Wave CLI token scoped to an organization.",
2544
+ kind: "missing_auth",
2545
+ status: 401,
2546
+ exitCode: EXIT_CODES.missingOrInvalidAuth,
2547
+ details: {
2548
+ suggestedCommands: ["wave auth status", "wave login"],
2549
+ ignoredOrganizationSources: ["stdin", "env", "config"]
2550
+ }
2378
2551
  });
2379
2552
  }
2380
2553
  return organizationId;
@@ -2462,140 +2635,6 @@ function registerGraphqlSearchCommand(command, config) {
2462
2635
  });
2463
2636
  }
2464
2637
 
2465
- // src/authClient.ts
2466
- var import_node_crypto2 = require("crypto");
2467
-
2468
- // src/redaction.ts
2469
- var TOKENISH_PATTERNS = [
2470
- /\b(?:cli|wave|token|secret|bearer)[A-Za-z0-9._~+/=-]{8,}\b/gi,
2471
- /\b[A-Za-z0-9._~+/=-]{24,}\b/g
2472
- ];
2473
- function redactOne(value) {
2474
- if (value.length <= 8) {
2475
- return "[redacted]";
2476
- }
2477
- return `${value.slice(0, 4)}...[redacted]...${value.slice(-4)}`;
2478
- }
2479
- function redactSecrets(input, knownSecrets = []) {
2480
- let output = input;
2481
- for (const secret of knownSecrets) {
2482
- if (!secret) continue;
2483
- output = output.split(secret).join(redactOne(secret));
2484
- }
2485
- for (const pattern of TOKENISH_PATTERNS) {
2486
- output = output.replace(pattern, (match) => redactOne(match));
2487
- }
2488
- return output;
2489
- }
2490
- function redactUnknown(input, knownSecrets = []) {
2491
- if (typeof input === "string") {
2492
- return redactSecrets(input, knownSecrets);
2493
- }
2494
- if (Array.isArray(input)) {
2495
- return input.map((entry2) => redactUnknown(entry2, knownSecrets));
2496
- }
2497
- if (!input || typeof input !== "object") {
2498
- return input;
2499
- }
2500
- const output = {};
2501
- for (const [key, value] of Object.entries(input)) {
2502
- if (/token|secret|authorization|bearer/i.test(key)) {
2503
- output[key] = typeof value === "string" ? redactSecrets(value, knownSecrets) : "[redacted]";
2504
- continue;
2505
- }
2506
- output[key] = redactUnknown(value, knownSecrets);
2507
- }
2508
- return output;
2509
- }
2510
-
2511
- // src/authClient.ts
2512
- function parseJsonSafely2(input) {
2513
- try {
2514
- return JSON.parse(input);
2515
- } catch {
2516
- return null;
2517
- }
2518
- }
2519
- function graphqlErrors(payload, knownSecrets) {
2520
- const errors = payload.errors;
2521
- if (!Array.isArray(errors) || errors.length === 0) return null;
2522
- return {
2523
- code: "upstream_error",
2524
- message: "GraphQL request failed.",
2525
- status: 400,
2526
- details: {
2527
- errors: redactUnknown(errors, knownSecrets)
2528
- }
2529
- };
2530
- }
2531
- async function authGraphqlRequest(params) {
2532
- const requestId = (0, import_node_crypto2.randomUUID)();
2533
- const controller = new AbortController();
2534
- const timeoutId = setTimeout(() => controller.abort(), params.timeoutMs);
2535
- const knownSecrets = [params.token, ...params.knownSecrets ?? []].filter(
2536
- (secret) => typeof secret === "string" && secret.length > 0
2537
- );
2538
- try {
2539
- const url = new URL("/graphql", params.baseUrl);
2540
- const response = await fetch(url, {
2541
- method: "POST",
2542
- headers: {
2543
- Accept: "application/json",
2544
- "Content-Type": "application/json",
2545
- "X-Origin": "wave-cli",
2546
- "X-Request-Id": requestId,
2547
- ...params.token ? { Authorization: `Bearer ${params.token}` } : {}
2548
- },
2549
- body: JSON.stringify({ query: params.query, variables: params.variables ?? {} }),
2550
- signal: controller.signal
2551
- });
2552
- const responseRequestId = response.headers.get("x-request-id") ?? requestId;
2553
- const text = await response.text();
2554
- const payload = text ? parseJsonSafely2(text) : null;
2555
- const graph = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
2556
- const gqlError = graphqlErrors(graph, knownSecrets);
2557
- if (gqlError) {
2558
- return { ok: false, error: gqlError, requestId: responseRequestId };
2559
- }
2560
- if (!response.ok) {
2561
- return {
2562
- ok: false,
2563
- requestId: responseRequestId,
2564
- error: {
2565
- code: `http_${response.status}`,
2566
- message: "Auth request failed.",
2567
- status: response.status,
2568
- details: { body: redactUnknown(graph, knownSecrets) }
2569
- }
2570
- };
2571
- }
2572
- const data = graph.data && typeof graph.data === "object" && !Array.isArray(graph.data) ? graph.data : {};
2573
- return {
2574
- ok: true,
2575
- result: {
2576
- status: response.status,
2577
- requestId: responseRequestId,
2578
- data
2579
- }
2580
- };
2581
- } catch (error) {
2582
- const message = error instanceof Error ? error.message : "Network error.";
2583
- const timedOut = error instanceof Error && error.name === "AbortError";
2584
- return {
2585
- ok: false,
2586
- requestId,
2587
- error: {
2588
- code: timedOut ? "timeout" : "network_error",
2589
- message: redactSecrets(timedOut ? "Auth request timed out." : message, knownSecrets),
2590
- status: timedOut ? 408 : 503,
2591
- details: {}
2592
- }
2593
- };
2594
- } finally {
2595
- clearTimeout(timeoutId);
2596
- }
2597
- }
2598
-
2599
2638
  // src/commands/tasks.ts
2600
2639
  var projectIdSchema = import_zod2.z.string().min(1);
2601
2640
  var idSchema = import_zod2.z.string().min(1);
@@ -2624,44 +2663,6 @@ function parseTaskUpdateJson(raw) {
2624
2663
  function parseLabelIds(raw) {
2625
2664
  return raw.split(",").map((labelId) => labelId.trim()).filter((labelId) => labelId.length > 0);
2626
2665
  }
2627
- function asRecord3(value) {
2628
- if (!value || typeof value !== "object" || Array.isArray(value)) {
2629
- return null;
2630
- }
2631
- return value;
2632
- }
2633
- function asNonEmptyString2(value) {
2634
- if (typeof value !== "string") {
2635
- return void 0;
2636
- }
2637
- const trimmed = value.trim();
2638
- return trimmed.length > 0 ? trimmed : void 0;
2639
- }
2640
- async function resolveTaskReadOrganizationId(params) {
2641
- const resolvedOrganizationId = asNonEmptyString2(params.organizationId);
2642
- if (params.organizationIdSource === "flag" && resolvedOrganizationId) {
2643
- return resolvedOrganizationId;
2644
- }
2645
- const baseUrl = asNonEmptyString2(params.runtimeOptions.baseUrl);
2646
- const token = asNonEmptyString2(params.runtimeOptions.token);
2647
- if (baseUrl && token) {
2648
- const result = await authGraphqlRequest({
2649
- baseUrl,
2650
- token,
2651
- timeoutMs: typeof params.runtimeOptions.timeoutMs === "number" ? params.runtimeOptions.timeoutMs : 1e4,
2652
- query: "query WaveCliTaskReadOrganization { cliAuthStatus { authenticated baseAuthStatus organization { id slug } } }"
2653
- });
2654
- if (result.ok) {
2655
- const status = asRecord3(result.result.data.cliAuthStatus);
2656
- const organization = status ? asRecord3(status.organization) : null;
2657
- const organizationId = organization ? asNonEmptyString2(organization.id) : void 0;
2658
- if (organizationId) {
2659
- return organizationId;
2660
- }
2661
- }
2662
- }
2663
- return resolveOrganizationId(resolvedOrganizationId);
2664
- }
2665
2666
  function registerTaskCommands(program) {
2666
2667
  const tasks = program.command("tasks").description("Task operations");
2667
2668
  tasks.command("list").option("--project-id <projectId>").option("--page <page>").option("--per <per>").option("--team-id <teamId>").option("--team-ids <teamIds>").option("--member-id <memberId>").option("--meeting-id <meetingId>").option("--field-name <fieldName>").option("--field-value <fieldValue>").option("--field-blank <fieldBlank>").option("--open <open>").option("--rank-direction <rankDirection>").option("--include-archived <includeArchived>").action(async (opts, cmd) => {
@@ -2698,11 +2699,7 @@ function registerTaskCommands(program) {
2698
2699
  tasks.command("show").requiredOption("--id <id>").action(async (opts, cmd) => {
2699
2700
  const parsed = idSchema.parse(opts.id);
2700
2701
  const context = await resolveCommandContext(cmd.optsWithGlobals());
2701
- const organizationId = await resolveTaskReadOrganizationId({
2702
- organizationId: context.organizationId,
2703
- organizationIdSource: context.organizationIdSource,
2704
- runtimeOptions: context.runtimeOptions
2705
- });
2702
+ const organizationId = resolveOrganizationId(context.organizationId);
2706
2703
  await runGraphqlQueryCommand({
2707
2704
  command: "tasks.show",
2708
2705
  runtimeOptions: context.runtimeOptions,
@@ -2714,9 +2711,9 @@ function registerTaskCommands(program) {
2714
2711
  isShow: true
2715
2712
  });
2716
2713
  });
2717
- tasks.command("create").requiredOption("--project-id <projectId>").option("--title <title>", "Legacy alias for --summary").option("--summary <summary>").action(async (opts, cmd) => {
2714
+ tasks.command("create").requiredOption("--project-id <projectId>").option("--summary <summary>").action(async (opts, cmd) => {
2718
2715
  const projectId = projectIdSchema.parse(opts.projectId);
2719
- const summary = summarySchema.parse(opts.summary ?? opts.title);
2716
+ const summary = summarySchema.parse(opts.summary);
2720
2717
  const context = await resolveCommandContext(cmd.optsWithGlobals());
2721
2718
  const organizationId = resolveOrganizationId(context.organizationId);
2722
2719
  await runGraphqlMutationCommand({
@@ -3604,16 +3601,16 @@ var displayPreferenceAttributesSelectionSet = "attributes { id viewType favorite
3604
3601
  var filterPreferenceAttributesSelectionSet = "attributes { id filterType filter memberId focusMemberId focusTeamId filterableId filterableType preferenceType agendaItemId }";
3605
3602
  var healthUpdateSummarySelectionSet = "id type value memberId status createdAt updatedAt updatableType updatableId parentUpdateId emojis { id name memberId } resources { ...ResourceSummaryFull }";
3606
3603
  var projectShowFullSelectionSet = `{ id type name slug description status priority createdAt updatedAt startDate targetDate archivedAt memberId organizationId teamIds emoji { id name memberId } backgroundImage { backgroundType gradientStart gradientEnd gradientDegrees color imageUrl image { url lowUrl } } favorites { id memberId } resources { ...ResourceSummaryFull } displayPreference { id type ${displayPreferenceAttributesSelectionSet} viewType favorite groupingField groupToggleState memberId focusMemberId focusTeamId displayableId displayableType preferenceType agendaItemId } filterPreferences { id type ${filterPreferenceAttributesSelectionSet} filterType filter memberId focusMemberId focusTeamId filterableId filterableType preferenceType agendaItemId } healthUpdates { ${healthUpdateSummarySelectionSet} replies { ${healthUpdateSummarySelectionSet} replies { id type } } } } fragment ResourceSummaryFull on ResourceSummary { id resourceType slug url skillId skill { id name slug emoji scope description } metadata { urlName imageUrl siteName providerName mediaType skillId skillName skillSlug skillScope skillEmoji skillDescription } attachment { id fileKey filename url } content { id name slug type firstChildSlug childCount } }`;
3607
- function asRecord4(value) {
3604
+ function asRecord3(value) {
3608
3605
  return value && typeof value === "object" ? value : null;
3609
3606
  }
3610
3607
  function toNonEmptyString(value) {
3611
3608
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
3612
3609
  }
3613
3610
  function normalizeProjectRowForDisplay(row) {
3614
- const record = asRecord4(row);
3611
+ const record = asRecord3(row);
3615
3612
  if (!record) return row;
3616
- const attributes = asRecord4(record.attributes);
3613
+ const attributes = asRecord3(record.attributes);
3617
3614
  const topLevelName = toNonEmptyString(record.name);
3618
3615
  const topLevelTitle = toNonEmptyString(record.title);
3619
3616
  const attributeName = toNonEmptyString(attributes?.name);
@@ -3628,7 +3625,7 @@ function normalizeProjectRowForDisplay(row) {
3628
3625
  };
3629
3626
  }
3630
3627
  function normalizeProjectsListForDisplay(payload) {
3631
- const record = asRecord4(payload);
3628
+ const record = asRecord3(payload);
3632
3629
  if (!record || !Array.isArray(record.data)) return payload;
3633
3630
  return {
3634
3631
  ...record,
@@ -3836,7 +3833,7 @@ var MEETING_STATUSES = /* @__PURE__ */ new Set(["upcoming", "active", "completed
3836
3833
  var MEETING_REPEATS = /* @__PURE__ */ new Set(["never", "weekly", "biweekly", "monthly", "quarterly"]);
3837
3834
  var createHelp2 = buildDataJsonHelp("meeting", "create") ?? 'JSON object for meeting or {"meeting": {...}}';
3838
3835
  var updateHelp2 = buildDataJsonHelp("meeting", "update") ?? 'JSON object for meeting or {"meeting": {...}}';
3839
- function asNonEmptyString3(value) {
3836
+ function asNonEmptyString2(value) {
3840
3837
  if (typeof value !== "string") {
3841
3838
  return void 0;
3842
3839
  }
@@ -3894,7 +3891,7 @@ function normalizeMeetingCreateBody(body) {
3894
3891
  });
3895
3892
  }
3896
3893
  const meeting = { ...entity };
3897
- const type = asNonEmptyString3(meeting.type);
3894
+ const type = asNonEmptyString2(meeting.type);
3898
3895
  if (!type || !MEETING_TYPES.has(type)) {
3899
3896
  throw new CliError({
3900
3897
  message: "Invalid meeting.type. Use one of: TeamMeeting, OneOnOneMeeting.",
@@ -3904,8 +3901,8 @@ function normalizeMeetingCreateBody(body) {
3904
3901
  details: { field: "meeting.type", allowed: Array.from(MEETING_TYPES) }
3905
3902
  });
3906
3903
  }
3907
- const memberId = asNonEmptyString3(meeting.member_id);
3908
- const date = asNonEmptyString3(meeting.date);
3904
+ const memberId = asNonEmptyString2(meeting.member_id);
3905
+ const date = asNonEmptyString2(meeting.date);
3909
3906
  const startTime = toFiniteNumber(meeting.start_time, "meeting.start_time");
3910
3907
  const missingRequired = [];
3911
3908
  if (!memberId) missingRequired.push("member_id");
@@ -3920,7 +3917,7 @@ function normalizeMeetingCreateBody(body) {
3920
3917
  details: { requiredFields: ["member_id", "date", "start_time"], rootKey: "meeting" }
3921
3918
  });
3922
3919
  }
3923
- const status = asNonEmptyString3(meeting.status);
3920
+ const status = asNonEmptyString2(meeting.status);
3924
3921
  if (status && !MEETING_STATUSES.has(status)) {
3925
3922
  throw new CliError({
3926
3923
  message: "Invalid meeting.status. Use one of: upcoming, active, completed.",
@@ -3930,7 +3927,7 @@ function normalizeMeetingCreateBody(body) {
3930
3927
  details: { field: "meeting.status", allowed: Array.from(MEETING_STATUSES) }
3931
3928
  });
3932
3929
  }
3933
- const repeats = asNonEmptyString3(meeting.repeats) ?? "never";
3930
+ const repeats = asNonEmptyString2(meeting.repeats) ?? "never";
3934
3931
  if (!MEETING_REPEATS.has(repeats)) {
3935
3932
  throw new CliError({
3936
3933
  message: "Invalid meeting.repeats. Use one of: never, weekly, biweekly, monthly, quarterly.",
@@ -4219,7 +4216,7 @@ var SKILL_SELECTION = `{
4219
4216
  createdAt
4220
4217
  updatedAt
4221
4218
  }`;
4222
- function asRecord5(value) {
4219
+ function asRecord4(value) {
4223
4220
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
4224
4221
  }
4225
4222
  function findSkillById(id) {
@@ -4227,7 +4224,7 @@ function findSkillById(id) {
4227
4224
  if (!Array.isArray(payload)) {
4228
4225
  return null;
4229
4226
  }
4230
- return payload.find((entry2) => String(asRecord5(entry2)?.id ?? "") === id) ?? null;
4227
+ return payload.find((entry2) => String(asRecord4(entry2)?.id ?? "") === id) ?? null;
4231
4228
  };
4232
4229
  }
4233
4230
  function registerSkillCommands(program) {
@@ -4619,7 +4616,7 @@ function normalizeTodosCreateBody(body) {
4619
4616
  }
4620
4617
  return { ...body, todo };
4621
4618
  }
4622
- function asNonEmptyString4(value) {
4619
+ function asNonEmptyString3(value) {
4623
4620
  if (typeof value !== "string") {
4624
4621
  return void 0;
4625
4622
  }
@@ -4627,7 +4624,7 @@ function asNonEmptyString4(value) {
4627
4624
  return trimmed.length > 0 ? trimmed : void 0;
4628
4625
  }
4629
4626
  function validateEnumField(params) {
4630
- const value = asNonEmptyString4(params.rawValue);
4627
+ const value = asNonEmptyString3(params.rawValue);
4631
4628
  if (!value) {
4632
4629
  return void 0;
4633
4630
  }
@@ -4661,7 +4658,7 @@ function normalizeKnowledgeCreateBody(body) {
4661
4658
  message: "Invalid content.status. Use one of: draft, published."
4662
4659
  });
4663
4660
  content.status = status ?? "draft";
4664
- const memberId = asNonEmptyString4(content.member_id);
4661
+ const memberId = asNonEmptyString3(content.member_id);
4665
4662
  if (!memberId) {
4666
4663
  throwMissingRequiredCreateFields("content", ["member_id"]);
4667
4664
  }
@@ -4670,7 +4667,7 @@ function normalizeKnowledgeCreateBody(body) {
4670
4667
  }
4671
4668
  function normalizeNewsCreateBody(body) {
4672
4669
  const headline = ensureEntityObject(body, "headline");
4673
- const memberId = asNonEmptyString4(headline.member_id);
4670
+ const memberId = asNonEmptyString3(headline.member_id);
4674
4671
  if (!memberId) {
4675
4672
  throwMissingRequiredCreateFields("headline", ["member_id"]);
4676
4673
  }
@@ -4699,14 +4696,14 @@ function normalizeNewsCreateBody(body) {
4699
4696
  }
4700
4697
  function normalizeQuestionsCreateBody(body) {
4701
4698
  const question = ensureEntityObject(body, "question");
4702
- const summary = asNonEmptyString4(question.summary);
4703
- const currentName = asNonEmptyString4(question.name);
4699
+ const summary = asNonEmptyString3(question.summary);
4700
+ const currentName = asNonEmptyString3(question.name);
4704
4701
  if (!currentName && summary) {
4705
4702
  question.name = summary;
4706
4703
  }
4707
4704
  delete question.summary;
4708
- const name = asNonEmptyString4(question.name);
4709
- const memberId = asNonEmptyString4(question.member_id);
4705
+ const name = asNonEmptyString3(question.name);
4706
+ const memberId = asNonEmptyString3(question.member_id);
4710
4707
  const missing = [];
4711
4708
  if (!name) missing.push("name");
4712
4709
  if (!memberId) missing.push("member_id");
@@ -4728,13 +4725,13 @@ function normalizeQuestionsCreateBody(body) {
4728
4725
  }
4729
4726
  function normalizeQuestionsUpdateBody(body) {
4730
4727
  const question = ensureEntityObject(body, "question");
4731
- const summary = asNonEmptyString4(question.summary);
4732
- const currentName = asNonEmptyString4(question.name);
4728
+ const summary = asNonEmptyString3(question.summary);
4729
+ const currentName = asNonEmptyString3(question.name);
4733
4730
  if (!currentName && summary) {
4734
4731
  question.name = summary;
4735
4732
  }
4736
4733
  delete question.summary;
4737
- const name = asNonEmptyString4(question.name);
4734
+ const name = asNonEmptyString3(question.name);
4738
4735
  if (name) {
4739
4736
  question.name = name;
4740
4737
  }
@@ -4751,9 +4748,9 @@ function normalizeQuestionsUpdateBody(body) {
4751
4748
  }
4752
4749
  function normalizePulseCreateBody(body) {
4753
4750
  const healthUpdate = ensureEntityObject(body, "health_update");
4754
- const healthUpdatableId = asNonEmptyString4(healthUpdate.health_updatable_id) ?? asNonEmptyString4(healthUpdate.updatable_id);
4755
- const healthUpdatableType = asNonEmptyString4(healthUpdate.health_updatable_type) ?? asNonEmptyString4(healthUpdate.updatable_type);
4756
- const memberId = asNonEmptyString4(healthUpdate.member_id);
4751
+ const healthUpdatableId = asNonEmptyString3(healthUpdate.health_updatable_id) ?? asNonEmptyString3(healthUpdate.updatable_id);
4752
+ const healthUpdatableType = asNonEmptyString3(healthUpdate.health_updatable_type) ?? asNonEmptyString3(healthUpdate.updatable_type);
4753
+ const memberId = asNonEmptyString3(healthUpdate.member_id);
4757
4754
  const status = validateEnumField({
4758
4755
  rawValue: healthUpdate.status,
4759
4756
  field: "health_update.status",
@@ -4778,8 +4775,8 @@ function normalizePulseCreateBody(body) {
4778
4775
  }
4779
4776
  function normalizeSurveysCreateBody(body) {
4780
4777
  const survey = ensureEntityObject(body, "survey");
4781
- const title = asNonEmptyString4(survey.title);
4782
- const currentName = asNonEmptyString4(survey.name);
4778
+ const title = asNonEmptyString3(survey.title);
4779
+ const currentName = asNonEmptyString3(survey.name);
4783
4780
  if (!currentName && title) {
4784
4781
  survey.name = title;
4785
4782
  }
@@ -4808,8 +4805,8 @@ function normalizeSurveysCreateBody(body) {
4808
4805
  }
4809
4806
  function normalizeSurveysUpdateBody(body) {
4810
4807
  const survey = ensureEntityObject(body, "survey");
4811
- const title = asNonEmptyString4(survey.title);
4812
- const currentName = asNonEmptyString4(survey.name);
4808
+ const title = asNonEmptyString3(survey.title);
4809
+ const currentName = asNonEmptyString3(survey.name);
4813
4810
  if (!currentName && title) {
4814
4811
  survey.name = title;
4815
4812
  }
@@ -4836,8 +4833,8 @@ function normalizeSurveysUpdateBody(body) {
4836
4833
  }
4837
4834
  function normalizeFeedbacksCreateBody(body) {
4838
4835
  const feedback = ensureEntityObject(body, "feedback");
4839
- const title = asNonEmptyString4(feedback.title);
4840
- const currentName = asNonEmptyString4(feedback.name);
4836
+ const title = asNonEmptyString3(feedback.title);
4837
+ const currentName = asNonEmptyString3(feedback.name);
4841
4838
  if (!currentName && title) {
4842
4839
  feedback.name = title;
4843
4840
  }
@@ -4854,7 +4851,7 @@ function normalizeFeedbacksCreateBody(body) {
4854
4851
  allowed: FEEDBACK_QUARTERS,
4855
4852
  message: "Invalid feedback.quarter. Use one of: q1, q2, q3, q4."
4856
4853
  });
4857
- const year = asNonEmptyString4(feedback.year);
4854
+ const year = asNonEmptyString3(feedback.year);
4858
4855
  const missing = [];
4859
4856
  if (!name) missing.push("name");
4860
4857
  if (!quarter) missing.push("quarter");
@@ -4869,8 +4866,8 @@ function normalizeFeedbacksCreateBody(body) {
4869
4866
  }
4870
4867
  function normalizeFeedbacksUpdateBody(body) {
4871
4868
  const feedback = ensureEntityObject(body, "feedback");
4872
- const title = asNonEmptyString4(feedback.title);
4873
- const currentName = asNonEmptyString4(feedback.name);
4869
+ const title = asNonEmptyString3(feedback.title);
4870
+ const currentName = asNonEmptyString3(feedback.name);
4874
4871
  if (!currentName && title) {
4875
4872
  feedback.name = title;
4876
4873
  }
@@ -4897,14 +4894,14 @@ function normalizeFeedbacksUpdateBody(body) {
4897
4894
  }
4898
4895
  function normalizeAccountabilityCreateBody(body) {
4899
4896
  const responsibility = ensureEntityObject(body, "responsibility");
4900
- const summary = asNonEmptyString4(responsibility.summary);
4901
- const currentName = asNonEmptyString4(responsibility.name);
4897
+ const summary = asNonEmptyString3(responsibility.summary);
4898
+ const currentName = asNonEmptyString3(responsibility.name);
4902
4899
  if (!currentName && summary) {
4903
4900
  responsibility.name = summary;
4904
4901
  }
4905
4902
  delete responsibility.summary;
4906
- const name = asNonEmptyString4(responsibility.name);
4907
- const memberId = asNonEmptyString4(responsibility.member_id);
4903
+ const name = asNonEmptyString3(responsibility.name);
4904
+ const memberId = asNonEmptyString3(responsibility.member_id);
4908
4905
  const missing = [];
4909
4906
  if (!name) missing.push("name");
4910
4907
  if (!memberId) missing.push("member_id");
@@ -4919,8 +4916,8 @@ function normalizeAccountabilityCreateBody(body) {
4919
4916
  }
4920
4917
  function normalizeAccountabilityUpdateBody(body) {
4921
4918
  const responsibility = ensureEntityObject(body, "responsibility");
4922
- const summary = asNonEmptyString4(responsibility.summary);
4923
- const currentName = asNonEmptyString4(responsibility.name);
4919
+ const summary = asNonEmptyString3(responsibility.summary);
4920
+ const currentName = asNonEmptyString3(responsibility.name);
4924
4921
  if (!currentName && summary) {
4925
4922
  responsibility.name = summary;
4926
4923
  }
@@ -4952,7 +4949,7 @@ function parseSmartKpiViewCreateBody(raw) {
4952
4949
  }
4953
4950
  function normalizeSmartKpiViewCreateBody(body) {
4954
4951
  const smartKpiView = ensureEntityObject(body, "smart_kpi_view");
4955
- const name = asNonEmptyString4(smartKpiView.name);
4952
+ const name = asNonEmptyString3(smartKpiView.name);
4956
4953
  if (!name) {
4957
4954
  throwMissingRequiredCreateFields("smart_kpi_view", ["name"]);
4958
4955
  }
@@ -4990,9 +4987,9 @@ function buildKpisCreateMutation(params) {
4990
4987
  });
4991
4988
  }
4992
4989
  const smartKpi = { ...entity };
4993
- const name = asNonEmptyString4(smartKpi.name);
4994
- const smartKpiViewId = asNonEmptyString4(smartKpi.smart_kpi_view_id);
4995
- const measurableGroupId = asNonEmptyString4(smartKpi.measurable_group_id);
4990
+ const name = asNonEmptyString3(smartKpi.name);
4991
+ const smartKpiViewId = asNonEmptyString3(smartKpi.smart_kpi_view_id);
4992
+ const measurableGroupId = asNonEmptyString3(smartKpi.measurable_group_id);
4996
4993
  const hasAllowedName = typeof name === "string" && SMART_KPI_NAME_SET.has(name);
4997
4994
  if (!name) {
4998
4995
  throw new CliError({
@@ -5012,7 +5009,7 @@ function buildKpisCreateMutation(params) {
5012
5009
  measurable_type: "number",
5013
5010
  condition: "greater_than_or_equal_to"
5014
5011
  };
5015
- const notes = asNonEmptyString4(smartKpi.notes);
5012
+ const notes = asNonEmptyString3(smartKpi.notes);
5016
5013
  if (notes) {
5017
5014
  measurable.notes = notes;
5018
5015
  }
@@ -5415,7 +5412,7 @@ function ensureRootObject(body, rootKey) {
5415
5412
  }
5416
5413
  return { ...root };
5417
5414
  }
5418
- function asNonEmptyString5(value) {
5415
+ function asNonEmptyString4(value) {
5419
5416
  if (typeof value !== "string") {
5420
5417
  return void 0;
5421
5418
  }
@@ -5425,7 +5422,7 @@ function asNonEmptyString5(value) {
5425
5422
  function normalizeOrganizationUpdateBody(body) {
5426
5423
  const organization = ensureRootObject(body, "organization");
5427
5424
  const detail = isRecord3(organization.organization_detail_attributes) ? { ...organization.organization_detail_attributes } : {};
5428
- const workspaceName = asNonEmptyString5(organization.workspace_name);
5425
+ const workspaceName = asNonEmptyString4(organization.workspace_name);
5429
5426
  if (workspaceName) {
5430
5427
  detail.workspace_name = workspaceName;
5431
5428
  }
@@ -5438,7 +5435,7 @@ function normalizeOrganizationUpdateBody(body) {
5438
5435
  function normalizeOrganizationMetaProfileUpdateBody(body) {
5439
5436
  const root = ensureRootObject(body, "organization_meta_profile");
5440
5437
  const profile = isRecord3(root.profile) ? { ...root.profile } : {};
5441
- const title = asNonEmptyString5(root.title);
5438
+ const title = asNonEmptyString4(root.title);
5442
5439
  if (title) {
5443
5440
  const companyIdentity = isRecord3(profile.company_identity) ? { ...profile.company_identity } : {};
5444
5441
  companyIdentity.one_sentence_summary = title;
@@ -5468,7 +5465,7 @@ function normalizeOrganizationMetaProfileUpdateBody(body) {
5468
5465
  function normalizeKeyMetricMetaProfileUpdateBody(body) {
5469
5466
  const root = ensureRootObject(body, "key_metric_meta_profile");
5470
5467
  const profile = isRecord3(root.profile) ? { ...root.profile } : {};
5471
- const annualRevenue = asNonEmptyString5(root.annual_revenue);
5468
+ const annualRevenue = asNonEmptyString4(root.annual_revenue);
5472
5469
  if (annualRevenue) {
5473
5470
  const financial = isRecord3(profile.financial) ? { ...profile.financial } : {};
5474
5471
  financial.revenue = annualRevenue;
@@ -5639,7 +5636,7 @@ function ensureRootObject2(body, rootKey) {
5639
5636
  }
5640
5637
  return { ...root };
5641
5638
  }
5642
- function asNonEmptyString6(value) {
5639
+ function asNonEmptyString5(value) {
5643
5640
  if (typeof value !== "string") {
5644
5641
  return void 0;
5645
5642
  }
@@ -5667,8 +5664,8 @@ function normalizeStrategicPlanUpdateBody(body) {
5667
5664
  }
5668
5665
  function normalizeStrategicObjectiveUpdateBody(body) {
5669
5666
  const strategicObjective = ensureRootObject2(body, "strategic_objective");
5670
- const title = asNonEmptyString6(strategicObjective.title);
5671
- if (!asNonEmptyString6(strategicObjective.summary) && title) {
5667
+ const title = asNonEmptyString5(strategicObjective.title);
5668
+ if (!asNonEmptyString5(strategicObjective.summary) && title) {
5672
5669
  strategicObjective.summary = title;
5673
5670
  }
5674
5671
  delete strategicObjective.title;
@@ -5691,8 +5688,8 @@ function normalizeStrategicObjectiveUpdateBody(body) {
5691
5688
  }
5692
5689
  function normalizeAnnualObjectiveCreateBody(body) {
5693
5690
  const annualObjective = ensureRootObject2(body, "annual_objective");
5694
- const title = asNonEmptyString6(annualObjective.title);
5695
- if (!asNonEmptyString6(annualObjective.name) && title) {
5691
+ const title = asNonEmptyString5(annualObjective.title);
5692
+ if (!asNonEmptyString5(annualObjective.name) && title) {
5696
5693
  annualObjective.name = title;
5697
5694
  }
5698
5695
  delete annualObjective.title;
@@ -5700,8 +5697,8 @@ function normalizeAnnualObjectiveCreateBody(body) {
5700
5697
  }
5701
5698
  function normalizeQuarterlyObjectiveCreateBody(body) {
5702
5699
  const quarterlyObjective = ensureRootObject2(body, "quarterly_objective");
5703
- const title = asNonEmptyString6(quarterlyObjective.title);
5704
- if (!asNonEmptyString6(quarterlyObjective.name) && title) {
5700
+ const title = asNonEmptyString5(quarterlyObjective.title);
5701
+ if (!asNonEmptyString5(quarterlyObjective.name) && title) {
5705
5702
  quarterlyObjective.name = title;
5706
5703
  }
5707
5704
  delete quarterlyObjective.title;
@@ -6502,7 +6499,7 @@ var import_zod16 = require("zod");
6502
6499
 
6503
6500
  // src/internalOptions.ts
6504
6501
  var INTERNAL_OPTIONS_KEY = "__waveInternalOptions";
6505
- function asRecord6(value) {
6502
+ function asRecord5(value) {
6506
6503
  if (!value || typeof value !== "object" || Array.isArray(value)) {
6507
6504
  return null;
6508
6505
  }
@@ -6516,7 +6513,7 @@ function setInternalCliOptions(program, options) {
6516
6513
  function getInternalCliOptions(command) {
6517
6514
  let current = command;
6518
6515
  while (current) {
6519
- const record = asRecord6(current[INTERNAL_OPTIONS_KEY]);
6516
+ const record = asRecord5(current[INTERNAL_OPTIONS_KEY]);
6520
6517
  if (record) {
6521
6518
  return {
6522
6519
  enableRetryOnEmptyPhrase: record.enableRetryOnEmptyPhrase === true
@@ -10188,7 +10185,7 @@ function positiveInt2(raw, fallback) {
10188
10185
  function requestTimeoutMs(totalTimeoutMs) {
10189
10186
  return Math.max(1e3, Math.min(totalTimeoutMs, 1e4));
10190
10187
  }
10191
- function asRecord7(value) {
10188
+ function asRecord6(value) {
10192
10189
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
10193
10190
  }
10194
10191
  function asString(value) {
@@ -10235,9 +10232,9 @@ function cliTokenFromPoll(payload) {
10235
10232
  return asString(payload.cliToken) ?? asString(payload.cli_token) ?? asString(payload.token);
10236
10233
  }
10237
10234
  function unwrapMutationResult(value) {
10238
- const record = asRecord7(value);
10235
+ const record = asRecord6(value);
10239
10236
  if (!record) return null;
10240
- const data = asRecord7(record.data);
10237
+ const data = asRecord6(record.data);
10241
10238
  if (data && (Object.prototype.hasOwnProperty.call(record, "ok") || Object.prototype.hasOwnProperty.call(record, "errors") || Object.prototype.hasOwnProperty.call(record, "errorCode") || Object.prototype.hasOwnProperty.call(record, "error_code"))) {
10242
10239
  return data;
10243
10240
  }
@@ -10255,7 +10252,7 @@ async function authStatusRequest(params) {
10255
10252
  });
10256
10253
  }
10257
10254
  async function runTokenLogin(cmd, opts) {
10258
- const context = await resolveCommandContext(cmd.optsWithGlobals());
10255
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
10259
10256
  const baseUrl = context.runtimeOptions.baseUrl;
10260
10257
  const globals = cmd.optsWithGlobals();
10261
10258
  const token = typeof opts.token === "string" && opts.token.trim() !== "" ? opts.token.trim() : typeof globals.token === "string" && globals.token.trim() !== "" ? globals.token.trim() : context.runtimeOptions.token;
@@ -10301,7 +10298,7 @@ async function runTokenLogin(cmd, opts) {
10301
10298
  exitCode: mapStatusToExitCode(status.error.status)
10302
10299
  });
10303
10300
  }
10304
- const statusData = asRecord7(status.result.data.cliAuthStatus) ?? {};
10301
+ const statusData = asRecord6(status.result.data.cliAuthStatus) ?? {};
10305
10302
  const storage = await writeStoredToken(token, baseUrl);
10306
10303
  const configPath2 = opts.saveBaseUrl ? await persistBaseUrl(baseUrl) : void 0;
10307
10304
  return printEnvelopeAndExit({
@@ -10322,7 +10319,7 @@ async function runTokenLogin(cmd, opts) {
10322
10319
  });
10323
10320
  }
10324
10321
  async function runBrowserLogin(cmd, opts) {
10325
- const context = await resolveCommandContext(cmd.optsWithGlobals());
10322
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
10326
10323
  const baseUrl = context.runtimeOptions.baseUrl;
10327
10324
  const timeoutMs = positiveInt2(opts.timeoutMs ?? context.runtimeOptions.timeoutMs, DEFAULT_LOGIN_TIMEOUT_MS);
10328
10325
  const pollIntervalMs = positiveInt2(opts.pollIntervalMs, DEFAULT_POLL_INTERVAL_MS);
@@ -10502,7 +10499,7 @@ async function runBrowserLogin(cmd, opts) {
10502
10499
  });
10503
10500
  }
10504
10501
  async function runLogout(cmd) {
10505
- const context = await resolveCommandContext(cmd.optsWithGlobals());
10502
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
10506
10503
  const baseUrl = context.runtimeOptions.baseUrl;
10507
10504
  const token = context.runtimeOptions.token;
10508
10505
  const timeoutMs = positiveInt2(context.runtimeOptions.timeoutMs, 1e4);
@@ -10518,7 +10515,7 @@ async function runLogout(cmd) {
10518
10515
  });
10519
10516
  if (result.ok) {
10520
10517
  requestId = result.result.requestId;
10521
- const payload = asRecord7(result.result.data.revokeCliToken) ?? {};
10518
+ const payload = asRecord6(result.result.data.revokeCliToken) ?? {};
10522
10519
  revokedRemote = payload.ok !== false;
10523
10520
  } else {
10524
10521
  requestId = result.requestId;
@@ -10541,7 +10538,7 @@ async function runLogout(cmd) {
10541
10538
  });
10542
10539
  }
10543
10540
  async function runAuthStatus(cmd) {
10544
- const context = await resolveCommandContext(cmd.optsWithGlobals());
10541
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
10545
10542
  const baseUrl = context.runtimeOptions.baseUrl;
10546
10543
  const token = context.runtimeOptions.token;
10547
10544
  const tokenSource = context.runtimeOptions.tokenSource ?? "none";
@@ -10581,7 +10578,7 @@ async function runAuthStatus(cmd) {
10581
10578
  exitCode: mapStatusToExitCode(result.error.status)
10582
10579
  });
10583
10580
  }
10584
- const status = asRecord7(result.result.data.cliAuthStatus) ?? {};
10581
+ const status = asRecord6(result.result.data.cliAuthStatus) ?? {};
10585
10582
  const baseAuthStatus = status.baseAuthStatus;
10586
10583
  return printEnvelopeAndExit({
10587
10584
  envelope: envelope({
@@ -12232,11 +12229,11 @@ function sanitizePlannerJson(value) {
12232
12229
  }
12233
12230
  return output;
12234
12231
  }
12235
- function asRecord8(value) {
12232
+ function asRecord7(value) {
12236
12233
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
12237
12234
  }
12238
12235
  function readPlannerStateKey(value, keys) {
12239
- const record = asRecord8(value);
12236
+ const record = asRecord7(value);
12240
12237
  if (!record) {
12241
12238
  return null;
12242
12239
  }
@@ -14940,7 +14937,7 @@ var AUTOMATION_SELECTION = `{
14940
14937
  createdAt
14941
14938
  updatedAt
14942
14939
  }`;
14943
- function asRecord9(value) {
14940
+ function asRecord8(value) {
14944
14941
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
14945
14942
  }
14946
14943
  function asRequiredString(value) {
@@ -14985,12 +14982,12 @@ function parseJson(value, optionName) {
14985
14982
  }
14986
14983
  }
14987
14984
  function normalizePersistedCreatePayload(payload) {
14988
- const mutation = asRecord9(payload);
14989
- const mutationData = asRecord9(mutation?.data);
14990
- const persisted = asRecord9(mutationData?.data) ?? mutationData;
14991
- const attributes = asRecord9(persisted?.attributes);
14992
- const meta = asRecord9(mutationData?.meta);
14993
- const idempotency = asRecord9(meta?.atlas_idempotency);
14985
+ const mutation = asRecord8(payload);
14986
+ const mutationData = asRecord8(mutation?.data);
14987
+ const persisted = asRecord8(mutationData?.data) ?? mutationData;
14988
+ const attributes = asRecord8(persisted?.attributes);
14989
+ const meta = asRecord8(mutationData?.meta);
14990
+ const idempotency = asRecord8(meta?.atlas_idempotency);
14994
14991
  const id = asRequiredString(persisted?.id);
14995
14992
  const slug = asRequiredString(persisted?.slug) ?? asRequiredString(attributes?.slug);
14996
14993
  const replay = idempotency?.replay;
@@ -15692,12 +15689,39 @@ function namespaceDoc(name) {
15692
15689
  }
15693
15690
  };
15694
15691
  }
15695
- function allNamespaceDocs() {
15696
- return [
15697
- ...PRIMARY_NAMESPACES.map(namespaceDoc),
15698
- ...ADVANCED_NAMESPACES.map(namespaceDoc),
15699
- ...ALIASES.map(namespaceDoc)
15700
- ];
15692
+ function advertisedCommands(command) {
15693
+ const children = command.commands.filter((child) => !["help", "schema", "examples"].includes(child.name())).map((child) => child.name());
15694
+ return children.length > 0 ? children : [command.name()];
15695
+ }
15696
+ function examplesForRegisteredCommand(name, commands) {
15697
+ if (commands.includes("list")) {
15698
+ return [
15699
+ `wave ${name} list --page 1 --per 10`,
15700
+ ...commands.includes("show") ? [`wave ${name} show --id 123`] : []
15701
+ ];
15702
+ }
15703
+ const [firstCommand] = commands;
15704
+ return firstCommand && firstCommand !== name ? [`wave ${name} ${firstCommand}`] : [`wave ${name}`];
15705
+ }
15706
+ function registeredNamespaceDoc(command) {
15707
+ const doc = namespaceDoc(command.name());
15708
+ const commands = advertisedCommands(command);
15709
+ const usesGenericDocumentation = !NAMESPACE_DOCS[command.name()];
15710
+ return {
15711
+ ...doc,
15712
+ ...usesGenericDocumentation ? { examples: examplesForRegisteredCommand(command.name(), commands) } : {},
15713
+ schema: {
15714
+ ...doc.schema,
15715
+ commands
15716
+ }
15717
+ };
15718
+ }
15719
+ function allNamespaceDocs(program) {
15720
+ const names = program.commands.map((command) => command.name()).filter((name) => name !== "help").filter((name, index, values) => values.indexOf(name) === index);
15721
+ return names.flatMap((name) => {
15722
+ const command = program.commands.find((candidate) => candidate.name() === name);
15723
+ return command ? [registeredNamespaceDoc(command)] : [];
15724
+ });
15701
15725
  }
15702
15726
  function buildEnvelope2(command, data) {
15703
15727
  return {
@@ -15780,43 +15804,6 @@ function commandSummary(command) {
15780
15804
  }))
15781
15805
  };
15782
15806
  }
15783
- function graphqlFields(program) {
15784
- const fields = /* @__PURE__ */ new Set([
15785
- "agent_markdown_status",
15786
- "agent_markdown_file",
15787
- "agent_markdown_children",
15788
- "os_md_search",
15789
- "os_md_wiki_lint",
15790
- "os_md_memory_quality",
15791
- "phantom_ledger_inventory",
15792
- "phantom_runs",
15793
- "phantom_run",
15794
- "phantom_reports",
15795
- "phantom_report",
15796
- "phantom_observation",
15797
- "phantom_observations",
15798
- "member_meta_profile",
15799
- "skills",
15800
- "destroy_task",
15801
- "raw_source_ingestion_plan",
15802
- "register_raw_source",
15803
- "ingest_raw_source",
15804
- "run_phantom_osmd_maintenance",
15805
- "markdown_tree_root",
15806
- "markdown_tree_node",
15807
- "markdown_tree_children",
15808
- "markdown_tree_subtree",
15809
- "ai_notes",
15810
- "ai_note"
15811
- ]);
15812
- for (const path of commandPaths(program)) {
15813
- const parts = path.split(" ");
15814
- if (parts.length >= 3) {
15815
- fields.add(parts.slice(1, -1).join("_").replaceAll("-", "_"));
15816
- }
15817
- }
15818
- return Array.from(fields).sort();
15819
- }
15820
15807
  function packageVersion() {
15821
15808
  try {
15822
15809
  const pkg = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path4.join)(process.cwd(), "package.json"), "utf8"));
@@ -15868,7 +15855,7 @@ async function resolveDoctorAuthOrganization(params) {
15868
15855
  }
15869
15856
  }
15870
15857
  async function runDoctor(cmd, opts) {
15871
- const context = await resolveCommandContext(cmd.optsWithGlobals());
15858
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
15872
15859
  const runtime = context.runtimeOptions;
15873
15860
  const baseUrl = runtime.baseUrl;
15874
15861
  const token = runtime.token;
@@ -15990,7 +15977,7 @@ function registerDiscoveryCommands(program) {
15990
15977
  stdout: "exactly one JSON envelope for machine commands",
15991
15978
  stderr: "diagnostics only"
15992
15979
  },
15993
- namespaces: allNamespaceDocs(),
15980
+ namespaces: allNamespaceDocs(program),
15994
15981
  toolSupportRegistry: {
15995
15982
  milestone: "WAVE-04",
15996
15983
  status: "registry_only",
@@ -16051,18 +16038,10 @@ function registerDiscoveryCommands(program) {
16051
16038
  return printEnvelopeAndExit({
16052
16039
  envelope: buildEnvelope2("api.ls", {
16053
16040
  commands: paths,
16054
- examples: ["wave api ls --json", "wave graphql fields --json"]
16041
+ examples: ["wave api ls --json"]
16055
16042
  })
16056
16043
  });
16057
16044
  });
16058
- const graphql = program.command("graphql").description("Discover GraphQL fields used by the CLI");
16059
- graphql.command("fields").description("List known GraphQL field names").option("--readable", "Print fields as plain lines").option("--json", "Emit the stable JSON envelope").action((opts) => {
16060
- const fields = graphqlFields(program);
16061
- if (opts.readable && !opts.json) {
16062
- return printTextAndExit({ text: fields.join("\n") });
16063
- }
16064
- return printEnvelopeAndExit({ envelope: buildEnvelope2("graphql.fields", { fields }) });
16065
- });
16066
16045
  program.command("doctor").description("Run read-only CLI diagnostics").option("--readable", "Print a human-readable diagnostic summary").option("--json", "Emit the stable JSON envelope").action((opts, cmd) => runDoctor(cmd, opts));
16067
16046
  const phantom = program.commands.find((command) => command.name() === "phantom");
16068
16047
  phantom?.addHelpText(
@@ -16076,7 +16055,6 @@ function attachNamespaceDiscovery(program) {
16076
16055
  ...ADVANCED_NAMESPACES,
16077
16056
  "capabilities",
16078
16057
  "api",
16079
- "graphql",
16080
16058
  "doctor",
16081
16059
  "auth"
16082
16060
  ]);
@@ -16086,7 +16064,7 @@ function attachNamespaceDiscovery(program) {
16086
16064
  if (!command.commands.some((child) => child.name() === "schema")) {
16087
16065
  command.command("schema").description("Describe this namespace's command and output contract").option("--readable", "Print a human-readable schema summary").option("--json", "Emit the stable JSON envelope").action((opts) => {
16088
16066
  const data = {
16089
- namespace: namespaceDoc(command.name()),
16067
+ namespace: registeredNamespaceDoc(command),
16090
16068
  command: commandSummary(command)
16091
16069
  };
16092
16070
  if (opts.readable && !opts.json) {
@@ -16102,7 +16080,7 @@ Output: ${data.namespace.schema.output}`
16102
16080
  }
16103
16081
  if (!command.commands.some((child) => child.name() === "examples")) {
16104
16082
  command.command("examples").description("Show scriptable examples for this namespace").option("--readable", "Print examples as shell lines").option("--json", "Emit the stable JSON envelope").action((opts) => {
16105
- const examples = namespaceDoc(command.name()).examples;
16083
+ const examples = registeredNamespaceDoc(command).examples;
16106
16084
  if (opts.readable && !opts.json) {
16107
16085
  return printTextAndExit({ text: examples.join("\n") });
16108
16086
  }
@@ -16122,7 +16100,6 @@ function attachDiscoveryHelp(program) {
16122
16100
  " wave capabilities list List primary, advanced, and alias namespaces",
16123
16101
  " wave capabilities tools List shared recent-tool support metadata",
16124
16102
  " wave api ls List scriptable command paths",
16125
- " wave graphql fields List known GraphQL fields",
16126
16103
  " wave <namespace> schema Describe namespace output and command contract",
16127
16104
  " wave <namespace> examples Show copyable examples",
16128
16105
  " wave doctor Run read-only diagnostics",
@@ -16146,7 +16123,6 @@ function attachDiscoveryHelp(program) {
16146
16123
  ["markdown-tree", "\nExamples:\n wave markdown-tree root --tree-view\n wave markdown-tree resolve --tool-key projects --node-key tasks --parent-id 123\n"],
16147
16124
  ["capabilities", "\nExamples:\n wave capabilities list\n wave capabilities list --readable\n wave capabilities tools\n wave capabilities tools mail\n"],
16148
16125
  ["api", "\nExamples:\n wave api ls\n wave api ls --readable\n"],
16149
- ["graphql", "\nExamples:\n wave graphql fields\n wave graphql fields --readable\n"],
16150
16126
  ["doctor", "\nExamples:\n wave doctor\n wave doctor --readable\n"]
16151
16127
  ]);
16152
16128
  for (const command of program.commands) {
@@ -16158,12 +16134,12 @@ function attachDiscoveryHelp(program) {
16158
16134
  }
16159
16135
 
16160
16136
  // src/version.ts
16161
- var CLI_VERSION = "0.1.62";
16137
+ var CLI_VERSION = "0.1.63";
16162
16138
 
16163
16139
  // src/cli.ts
16164
16140
  function buildCli(options) {
16165
16141
  const program = new import_commander.Command();
16166
- program.name("wave").description("Wave agent CLI").version(CLI_VERSION, "-V, --version", "output the version number").showHelpAfterError(false).allowExcessArguments(false).option("--token <token>", "API token (prefer WAVE_API_TOKEN env var)").option("--jwt <jwt>", "Legacy alias for --token (prefer WAVE_API_TOKEN env var)").option("--token-stdin", "Read API token from stdin").option(
16142
+ program.name("wave").description("Wave agent CLI").version(CLI_VERSION, "-V, --version", "output the version number").showHelpAfterError(false).allowExcessArguments(false).option("--token <token>", "API token (prefer WAVE_API_TOKEN env var)").option("--token-stdin", "Read API token from stdin").option(
16167
16143
  "--auth-json-stdin",
16168
16144
  "Read auth/runtime context JSON from stdin (token, baseUrl, organizationId, ...)"
16169
16145
  ).option(