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