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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
@@ -128,9 +128,7 @@ function getConfig(options) {
128
128
  const parsed = configSchema.safeParse({
129
129
  baseUrl,
130
130
  token,
131
- organizationId: toOptionalNonEmpty(
132
- options.organizationId ?? process.env.WAVE_ORGANIZATION_ID ?? process.env.WAVE_ORG_ID
133
- ),
131
+ organizationId: toOptionalNonEmpty(options.organizationId),
134
132
  timeoutMs: parseTimeoutMs(options.timeoutMs ?? process.env.WAVE_TIMEOUT_MS),
135
133
  debug: options.debug ?? parseDebug(process.env.WAVE_DEBUG),
136
134
  agentName: toOptionalNonEmpty(options.agentName ?? process.env.WAVE_AGENT_NAME),
@@ -2017,7 +2015,142 @@ async function getAuthStorageInfo(baseUrl) {
2017
2015
  return { kind: "file", available, path };
2018
2016
  }
2019
2017
 
2018
+ // src/authClient.ts
2019
+ var import_node_crypto2 = require("crypto");
2020
+
2021
+ // src/redaction.ts
2022
+ var TOKENISH_PATTERNS = [
2023
+ /\b(?:cli|wave|token|secret|bearer)[A-Za-z0-9._~+/=-]{8,}\b/gi,
2024
+ /\b[A-Za-z0-9._~+/=-]{24,}\b/g
2025
+ ];
2026
+ function redactOne(value) {
2027
+ if (value.length <= 8) {
2028
+ return "[redacted]";
2029
+ }
2030
+ return `${value.slice(0, 4)}...[redacted]...${value.slice(-4)}`;
2031
+ }
2032
+ function redactSecrets(input, knownSecrets = []) {
2033
+ let output = input;
2034
+ for (const secret of knownSecrets) {
2035
+ if (!secret) continue;
2036
+ output = output.split(secret).join(redactOne(secret));
2037
+ }
2038
+ for (const pattern of TOKENISH_PATTERNS) {
2039
+ output = output.replace(pattern, (match) => redactOne(match));
2040
+ }
2041
+ return output;
2042
+ }
2043
+ function redactUnknown(input, knownSecrets = []) {
2044
+ if (typeof input === "string") {
2045
+ return redactSecrets(input, knownSecrets);
2046
+ }
2047
+ if (Array.isArray(input)) {
2048
+ return input.map((entry2) => redactUnknown(entry2, knownSecrets));
2049
+ }
2050
+ if (!input || typeof input !== "object") {
2051
+ return input;
2052
+ }
2053
+ const output = {};
2054
+ for (const [key, value] of Object.entries(input)) {
2055
+ if (/token|secret|authorization|bearer/i.test(key)) {
2056
+ output[key] = typeof value === "string" ? redactSecrets(value, knownSecrets) : "[redacted]";
2057
+ continue;
2058
+ }
2059
+ output[key] = redactUnknown(value, knownSecrets);
2060
+ }
2061
+ return output;
2062
+ }
2063
+
2064
+ // src/authClient.ts
2065
+ function parseJsonSafely2(input) {
2066
+ try {
2067
+ return JSON.parse(input);
2068
+ } catch {
2069
+ return null;
2070
+ }
2071
+ }
2072
+ function graphqlErrors(payload, knownSecrets) {
2073
+ const errors = payload.errors;
2074
+ if (!Array.isArray(errors) || errors.length === 0) return null;
2075
+ return {
2076
+ code: "upstream_error",
2077
+ message: "GraphQL request failed.",
2078
+ status: 400,
2079
+ details: {
2080
+ errors: redactUnknown(errors, knownSecrets)
2081
+ }
2082
+ };
2083
+ }
2084
+ async function authGraphqlRequest(params) {
2085
+ const requestId = (0, import_node_crypto2.randomUUID)();
2086
+ const controller = new AbortController();
2087
+ const timeoutId = setTimeout(() => controller.abort(), params.timeoutMs);
2088
+ const knownSecrets = [params.token, ...params.knownSecrets ?? []].filter(
2089
+ (secret) => typeof secret === "string" && secret.length > 0
2090
+ );
2091
+ try {
2092
+ const url = new URL("/graphql", params.baseUrl);
2093
+ const response = await fetch(url, {
2094
+ method: "POST",
2095
+ headers: {
2096
+ Accept: "application/json",
2097
+ "Content-Type": "application/json",
2098
+ "X-Origin": "wave-cli",
2099
+ "X-Request-Id": requestId,
2100
+ ...params.token ? { Authorization: `Bearer ${params.token}` } : {}
2101
+ },
2102
+ body: JSON.stringify({ query: params.query, variables: params.variables ?? {} }),
2103
+ signal: controller.signal
2104
+ });
2105
+ const responseRequestId = response.headers.get("x-request-id") ?? requestId;
2106
+ const text = await response.text();
2107
+ const payload = text ? parseJsonSafely2(text) : null;
2108
+ const graph = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
2109
+ const gqlError = graphqlErrors(graph, knownSecrets);
2110
+ if (gqlError) {
2111
+ return { ok: false, error: gqlError, requestId: responseRequestId };
2112
+ }
2113
+ if (!response.ok) {
2114
+ return {
2115
+ ok: false,
2116
+ requestId: responseRequestId,
2117
+ error: {
2118
+ code: `http_${response.status}`,
2119
+ message: "Auth request failed.",
2120
+ status: response.status,
2121
+ details: { body: redactUnknown(graph, knownSecrets) }
2122
+ }
2123
+ };
2124
+ }
2125
+ const data = graph.data && typeof graph.data === "object" && !Array.isArray(graph.data) ? graph.data : {};
2126
+ return {
2127
+ ok: true,
2128
+ result: {
2129
+ status: response.status,
2130
+ requestId: responseRequestId,
2131
+ data
2132
+ }
2133
+ };
2134
+ } catch (error) {
2135
+ const message = error instanceof Error ? error.message : "Network error.";
2136
+ const timedOut = error instanceof Error && error.name === "AbortError";
2137
+ return {
2138
+ ok: false,
2139
+ requestId,
2140
+ error: {
2141
+ code: timedOut ? "timeout" : "network_error",
2142
+ message: redactSecrets(timedOut ? "Auth request timed out." : message, knownSecrets),
2143
+ status: timedOut ? 408 : 503,
2144
+ details: {}
2145
+ }
2146
+ };
2147
+ } finally {
2148
+ clearTimeout(timeoutId);
2149
+ }
2150
+ }
2151
+
2020
2152
  // src/commands/runtimeOptions.ts
2153
+ var CLI_AUTH_STATUS_QUERY = "query WaveCliAuthenticatedOrganization { cliAuthStatus { authenticated baseAuthStatus organization { id slug } } }";
2021
2154
  var stdinPromise = null;
2022
2155
  function normalize3(raw) {
2023
2156
  if (typeof raw !== "string") {
@@ -2051,9 +2184,7 @@ function parseAuthJson(raw) {
2051
2184
  const obj = parsed;
2052
2185
  return {
2053
2186
  token: normalize3(obj.token),
2054
- jwt: normalize3(obj.jwt),
2055
2187
  baseUrl: normalize3(obj.baseUrl ?? obj.base_url),
2056
- organizationId: normalize3(obj.organizationId ?? obj.organization_id),
2057
2188
  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,
2058
2189
  debug: parseBool(obj.debug),
2059
2190
  agentName: normalize3(obj.agentName ?? obj.agent_name),
@@ -2134,13 +2265,9 @@ function firstDefined(...values) {
2134
2265
  function resolveAuthToken(options, stdin, config, env) {
2135
2266
  const candidates = [
2136
2267
  { token: normalize3(options.token), source: "flag" },
2137
- { token: normalize3(options.jwt), source: "flag" },
2138
2268
  { token: normalize3(stdin.token), source: "stdin" },
2139
- { token: normalize3(stdin.jwt), source: "stdin" },
2140
2269
  { token: normalize3(env.WAVE_API_TOKEN), source: "env" },
2141
- { token: normalize3(env.WAVE_JWT), source: "env" },
2142
- { token: normalize3(config.token), source: "config" },
2143
- { token: normalize3(config.jwt), source: "config" }
2270
+ { token: normalize3(config.token), source: "config" }
2144
2271
  ];
2145
2272
  return candidates.find((candidate) => candidate.token) ?? { source: "none" };
2146
2273
  }
@@ -2152,18 +2279,8 @@ function resolveFromSources(options, stdin, config, env) {
2152
2279
  normalize3(env.WAVE_API_URL),
2153
2280
  normalize3(config.baseUrl)
2154
2281
  );
2155
- const organizationCandidates = [
2156
- { organizationId: normalize3(options.organizationId), source: "flag" },
2157
- { organizationId: normalize3(stdin.organizationId), source: "stdin" },
2158
- { organizationId: normalize3(env.WAVE_ORGANIZATION_ID), source: "env" },
2159
- { organizationId: normalize3(env.WAVE_ORG_ID), source: "env" },
2160
- { organizationId: normalize3(config.organizationId), source: "config" }
2161
- ];
2162
- const resolvedOrganization = organizationCandidates.find((candidate) => candidate.organizationId) ?? {
2163
- organizationId: void 0,
2164
- source: "none"
2165
- };
2166
- const organizationId = resolvedOrganization.organizationId;
2282
+ const organizationId = normalize3(options.organizationId);
2283
+ const organizationIdSource = organizationId ? "flag" : "none";
2167
2284
  const timeoutMs = firstDefined(options.timeoutMs, stdin.timeoutMs, env.WAVE_TIMEOUT_MS, config.timeoutMs);
2168
2285
  const debug = firstDefined(
2169
2286
  options.debug,
@@ -2252,7 +2369,7 @@ function resolveFromSources(options, stdin, config, env) {
2252
2369
  const resolvedAuth = resolveAuthToken(options, stdin, config, env);
2253
2370
  return {
2254
2371
  organizationId,
2255
- organizationIdSource: resolvedOrganization.source,
2372
+ organizationIdSource,
2256
2373
  runtimeOptions: {
2257
2374
  token: resolvedAuth.token,
2258
2375
  tokenSource: resolvedAuth.token ? resolvedAuth.source : "none",
@@ -2291,6 +2408,34 @@ async function resolveWithStoredToken(context) {
2291
2408
  }
2292
2409
  };
2293
2410
  }
2411
+ async function resolveWithAuthenticatedOrganization(context) {
2412
+ if (context.organizationIdSource === "flag" && context.organizationId) {
2413
+ return context;
2414
+ }
2415
+ const baseUrl = normalize3(context.runtimeOptions.baseUrl);
2416
+ const token = normalize3(context.runtimeOptions.token);
2417
+ if (!baseUrl || !token) {
2418
+ return {
2419
+ ...context,
2420
+ organizationId: void 0,
2421
+ organizationIdSource: "none",
2422
+ runtimeOptions: { ...context.runtimeOptions, organizationId: void 0 }
2423
+ };
2424
+ }
2425
+ const response = await authGraphqlRequest({
2426
+ baseUrl,
2427
+ token,
2428
+ timeoutMs: typeof context.runtimeOptions.timeoutMs === "number" ? context.runtimeOptions.timeoutMs : 1e4,
2429
+ query: CLI_AUTH_STATUS_QUERY
2430
+ });
2431
+ const organizationId = response.ok ? organizationIdFromCliAuthStatus(response.result.data) : void 0;
2432
+ return {
2433
+ ...context,
2434
+ organizationId,
2435
+ organizationIdSource: organizationId ? "token" : "none",
2436
+ runtimeOptions: { ...context.runtimeOptions, organizationId }
2437
+ };
2438
+ }
2294
2439
  function defaultConfigPath(env) {
2295
2440
  const explicitEnv = normalize3(env.WAVE_CONFIG_PATH);
2296
2441
  if (explicitEnv) return explicitEnv;
@@ -2353,11 +2498,23 @@ async function resolveStdinContext(options) {
2353
2498
  }
2354
2499
  return parseAuthJson(raw);
2355
2500
  }
2356
- async function resolveCommandContext(options) {
2501
+ async function resolveUnscopedCommandContext(options) {
2357
2502
  const stdin = await resolveStdinContext(options);
2358
2503
  const config = await resolveConfigFileContext(options, process.env);
2359
2504
  return resolveWithStoredToken(resolveFromSources(options, stdin, config, process.env));
2360
2505
  }
2506
+ async function resolveCommandContext(options) {
2507
+ return resolveWithAuthenticatedOrganization(await resolveUnscopedCommandContext(options));
2508
+ }
2509
+ function organizationIdFromCliAuthStatus(data) {
2510
+ const status = data.cliAuthStatus;
2511
+ if (!status || typeof status !== "object" || Array.isArray(status)) return void 0;
2512
+ const cliAuthStatus = status;
2513
+ if (cliAuthStatus.authenticated !== true) return void 0;
2514
+ const organization = cliAuthStatus.organization;
2515
+ if (!organization || typeof organization !== "object" || Array.isArray(organization)) return void 0;
2516
+ return normalize3(organization.id);
2517
+ }
2361
2518
 
2362
2519
  // src/commands/organization.ts
2363
2520
  function normalize4(input) {
@@ -2371,10 +2528,14 @@ function resolveOrganizationId(raw) {
2371
2528
  const organizationId = normalize4(raw);
2372
2529
  if (!organizationId) {
2373
2530
  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
2531
+ message: "Missing authenticated organization scope. Pass --organization-id explicitly or authenticate with a Wave CLI token scoped to an organization.",
2532
+ kind: "missing_auth",
2533
+ status: 401,
2534
+ exitCode: EXIT_CODES.missingOrInvalidAuth,
2535
+ details: {
2536
+ suggestedCommands: ["wave auth status", "wave login"],
2537
+ ignoredOrganizationSources: ["stdin", "env", "config"]
2538
+ }
2378
2539
  });
2379
2540
  }
2380
2541
  return organizationId;
@@ -2462,140 +2623,6 @@ function registerGraphqlSearchCommand(command, config) {
2462
2623
  });
2463
2624
  }
2464
2625
 
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
2626
  // src/commands/tasks.ts
2600
2627
  var projectIdSchema = import_zod2.z.string().min(1);
2601
2628
  var idSchema = import_zod2.z.string().min(1);
@@ -2624,44 +2651,6 @@ function parseTaskUpdateJson(raw) {
2624
2651
  function parseLabelIds(raw) {
2625
2652
  return raw.split(",").map((labelId) => labelId.trim()).filter((labelId) => labelId.length > 0);
2626
2653
  }
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
2654
  function registerTaskCommands(program) {
2666
2655
  const tasks = program.command("tasks").description("Task operations");
2667
2656
  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 +2687,7 @@ function registerTaskCommands(program) {
2698
2687
  tasks.command("show").requiredOption("--id <id>").action(async (opts, cmd) => {
2699
2688
  const parsed = idSchema.parse(opts.id);
2700
2689
  const context = await resolveCommandContext(cmd.optsWithGlobals());
2701
- const organizationId = await resolveTaskReadOrganizationId({
2702
- organizationId: context.organizationId,
2703
- organizationIdSource: context.organizationIdSource,
2704
- runtimeOptions: context.runtimeOptions
2705
- });
2690
+ const organizationId = resolveOrganizationId(context.organizationId);
2706
2691
  await runGraphqlQueryCommand({
2707
2692
  command: "tasks.show",
2708
2693
  runtimeOptions: context.runtimeOptions,
@@ -2714,9 +2699,9 @@ function registerTaskCommands(program) {
2714
2699
  isShow: true
2715
2700
  });
2716
2701
  });
2717
- tasks.command("create").requiredOption("--project-id <projectId>").option("--title <title>", "Legacy alias for --summary").option("--summary <summary>").action(async (opts, cmd) => {
2702
+ tasks.command("create").requiredOption("--project-id <projectId>").option("--summary <summary>").action(async (opts, cmd) => {
2718
2703
  const projectId = projectIdSchema.parse(opts.projectId);
2719
- const summary = summarySchema.parse(opts.summary ?? opts.title);
2704
+ const summary = summarySchema.parse(opts.summary);
2720
2705
  const context = await resolveCommandContext(cmd.optsWithGlobals());
2721
2706
  const organizationId = resolveOrganizationId(context.organizationId);
2722
2707
  await runGraphqlMutationCommand({
@@ -3604,16 +3589,16 @@ var displayPreferenceAttributesSelectionSet = "attributes { id viewType favorite
3604
3589
  var filterPreferenceAttributesSelectionSet = "attributes { id filterType filter memberId focusMemberId focusTeamId filterableId filterableType preferenceType agendaItemId }";
3605
3590
  var healthUpdateSummarySelectionSet = "id type value memberId status createdAt updatedAt updatableType updatableId parentUpdateId emojis { id name memberId } resources { ...ResourceSummaryFull }";
3606
3591
  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) {
3592
+ function asRecord3(value) {
3608
3593
  return value && typeof value === "object" ? value : null;
3609
3594
  }
3610
3595
  function toNonEmptyString(value) {
3611
3596
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
3612
3597
  }
3613
3598
  function normalizeProjectRowForDisplay(row) {
3614
- const record = asRecord4(row);
3599
+ const record = asRecord3(row);
3615
3600
  if (!record) return row;
3616
- const attributes = asRecord4(record.attributes);
3601
+ const attributes = asRecord3(record.attributes);
3617
3602
  const topLevelName = toNonEmptyString(record.name);
3618
3603
  const topLevelTitle = toNonEmptyString(record.title);
3619
3604
  const attributeName = toNonEmptyString(attributes?.name);
@@ -3628,7 +3613,7 @@ function normalizeProjectRowForDisplay(row) {
3628
3613
  };
3629
3614
  }
3630
3615
  function normalizeProjectsListForDisplay(payload) {
3631
- const record = asRecord4(payload);
3616
+ const record = asRecord3(payload);
3632
3617
  if (!record || !Array.isArray(record.data)) return payload;
3633
3618
  return {
3634
3619
  ...record,
@@ -3836,7 +3821,7 @@ var MEETING_STATUSES = /* @__PURE__ */ new Set(["upcoming", "active", "completed
3836
3821
  var MEETING_REPEATS = /* @__PURE__ */ new Set(["never", "weekly", "biweekly", "monthly", "quarterly"]);
3837
3822
  var createHelp2 = buildDataJsonHelp("meeting", "create") ?? 'JSON object for meeting or {"meeting": {...}}';
3838
3823
  var updateHelp2 = buildDataJsonHelp("meeting", "update") ?? 'JSON object for meeting or {"meeting": {...}}';
3839
- function asNonEmptyString3(value) {
3824
+ function asNonEmptyString2(value) {
3840
3825
  if (typeof value !== "string") {
3841
3826
  return void 0;
3842
3827
  }
@@ -3894,7 +3879,7 @@ function normalizeMeetingCreateBody(body) {
3894
3879
  });
3895
3880
  }
3896
3881
  const meeting = { ...entity };
3897
- const type = asNonEmptyString3(meeting.type);
3882
+ const type = asNonEmptyString2(meeting.type);
3898
3883
  if (!type || !MEETING_TYPES.has(type)) {
3899
3884
  throw new CliError({
3900
3885
  message: "Invalid meeting.type. Use one of: TeamMeeting, OneOnOneMeeting.",
@@ -3904,8 +3889,8 @@ function normalizeMeetingCreateBody(body) {
3904
3889
  details: { field: "meeting.type", allowed: Array.from(MEETING_TYPES) }
3905
3890
  });
3906
3891
  }
3907
- const memberId = asNonEmptyString3(meeting.member_id);
3908
- const date = asNonEmptyString3(meeting.date);
3892
+ const memberId = asNonEmptyString2(meeting.member_id);
3893
+ const date = asNonEmptyString2(meeting.date);
3909
3894
  const startTime = toFiniteNumber(meeting.start_time, "meeting.start_time");
3910
3895
  const missingRequired = [];
3911
3896
  if (!memberId) missingRequired.push("member_id");
@@ -3920,7 +3905,7 @@ function normalizeMeetingCreateBody(body) {
3920
3905
  details: { requiredFields: ["member_id", "date", "start_time"], rootKey: "meeting" }
3921
3906
  });
3922
3907
  }
3923
- const status = asNonEmptyString3(meeting.status);
3908
+ const status = asNonEmptyString2(meeting.status);
3924
3909
  if (status && !MEETING_STATUSES.has(status)) {
3925
3910
  throw new CliError({
3926
3911
  message: "Invalid meeting.status. Use one of: upcoming, active, completed.",
@@ -3930,7 +3915,7 @@ function normalizeMeetingCreateBody(body) {
3930
3915
  details: { field: "meeting.status", allowed: Array.from(MEETING_STATUSES) }
3931
3916
  });
3932
3917
  }
3933
- const repeats = asNonEmptyString3(meeting.repeats) ?? "never";
3918
+ const repeats = asNonEmptyString2(meeting.repeats) ?? "never";
3934
3919
  if (!MEETING_REPEATS.has(repeats)) {
3935
3920
  throw new CliError({
3936
3921
  message: "Invalid meeting.repeats. Use one of: never, weekly, biweekly, monthly, quarterly.",
@@ -4219,7 +4204,7 @@ var SKILL_SELECTION = `{
4219
4204
  createdAt
4220
4205
  updatedAt
4221
4206
  }`;
4222
- function asRecord5(value) {
4207
+ function asRecord4(value) {
4223
4208
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
4224
4209
  }
4225
4210
  function findSkillById(id) {
@@ -4227,7 +4212,7 @@ function findSkillById(id) {
4227
4212
  if (!Array.isArray(payload)) {
4228
4213
  return null;
4229
4214
  }
4230
- return payload.find((entry2) => String(asRecord5(entry2)?.id ?? "") === id) ?? null;
4215
+ return payload.find((entry2) => String(asRecord4(entry2)?.id ?? "") === id) ?? null;
4231
4216
  };
4232
4217
  }
4233
4218
  function registerSkillCommands(program) {
@@ -4619,7 +4604,7 @@ function normalizeTodosCreateBody(body) {
4619
4604
  }
4620
4605
  return { ...body, todo };
4621
4606
  }
4622
- function asNonEmptyString4(value) {
4607
+ function asNonEmptyString3(value) {
4623
4608
  if (typeof value !== "string") {
4624
4609
  return void 0;
4625
4610
  }
@@ -4627,7 +4612,7 @@ function asNonEmptyString4(value) {
4627
4612
  return trimmed.length > 0 ? trimmed : void 0;
4628
4613
  }
4629
4614
  function validateEnumField(params) {
4630
- const value = asNonEmptyString4(params.rawValue);
4615
+ const value = asNonEmptyString3(params.rawValue);
4631
4616
  if (!value) {
4632
4617
  return void 0;
4633
4618
  }
@@ -4661,7 +4646,7 @@ function normalizeKnowledgeCreateBody(body) {
4661
4646
  message: "Invalid content.status. Use one of: draft, published."
4662
4647
  });
4663
4648
  content.status = status ?? "draft";
4664
- const memberId = asNonEmptyString4(content.member_id);
4649
+ const memberId = asNonEmptyString3(content.member_id);
4665
4650
  if (!memberId) {
4666
4651
  throwMissingRequiredCreateFields("content", ["member_id"]);
4667
4652
  }
@@ -4670,7 +4655,7 @@ function normalizeKnowledgeCreateBody(body) {
4670
4655
  }
4671
4656
  function normalizeNewsCreateBody(body) {
4672
4657
  const headline = ensureEntityObject(body, "headline");
4673
- const memberId = asNonEmptyString4(headline.member_id);
4658
+ const memberId = asNonEmptyString3(headline.member_id);
4674
4659
  if (!memberId) {
4675
4660
  throwMissingRequiredCreateFields("headline", ["member_id"]);
4676
4661
  }
@@ -4699,14 +4684,14 @@ function normalizeNewsCreateBody(body) {
4699
4684
  }
4700
4685
  function normalizeQuestionsCreateBody(body) {
4701
4686
  const question = ensureEntityObject(body, "question");
4702
- const summary = asNonEmptyString4(question.summary);
4703
- const currentName = asNonEmptyString4(question.name);
4687
+ const summary = asNonEmptyString3(question.summary);
4688
+ const currentName = asNonEmptyString3(question.name);
4704
4689
  if (!currentName && summary) {
4705
4690
  question.name = summary;
4706
4691
  }
4707
4692
  delete question.summary;
4708
- const name = asNonEmptyString4(question.name);
4709
- const memberId = asNonEmptyString4(question.member_id);
4693
+ const name = asNonEmptyString3(question.name);
4694
+ const memberId = asNonEmptyString3(question.member_id);
4710
4695
  const missing = [];
4711
4696
  if (!name) missing.push("name");
4712
4697
  if (!memberId) missing.push("member_id");
@@ -4728,13 +4713,13 @@ function normalizeQuestionsCreateBody(body) {
4728
4713
  }
4729
4714
  function normalizeQuestionsUpdateBody(body) {
4730
4715
  const question = ensureEntityObject(body, "question");
4731
- const summary = asNonEmptyString4(question.summary);
4732
- const currentName = asNonEmptyString4(question.name);
4716
+ const summary = asNonEmptyString3(question.summary);
4717
+ const currentName = asNonEmptyString3(question.name);
4733
4718
  if (!currentName && summary) {
4734
4719
  question.name = summary;
4735
4720
  }
4736
4721
  delete question.summary;
4737
- const name = asNonEmptyString4(question.name);
4722
+ const name = asNonEmptyString3(question.name);
4738
4723
  if (name) {
4739
4724
  question.name = name;
4740
4725
  }
@@ -4751,9 +4736,9 @@ function normalizeQuestionsUpdateBody(body) {
4751
4736
  }
4752
4737
  function normalizePulseCreateBody(body) {
4753
4738
  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);
4739
+ const healthUpdatableId = asNonEmptyString3(healthUpdate.health_updatable_id) ?? asNonEmptyString3(healthUpdate.updatable_id);
4740
+ const healthUpdatableType = asNonEmptyString3(healthUpdate.health_updatable_type) ?? asNonEmptyString3(healthUpdate.updatable_type);
4741
+ const memberId = asNonEmptyString3(healthUpdate.member_id);
4757
4742
  const status = validateEnumField({
4758
4743
  rawValue: healthUpdate.status,
4759
4744
  field: "health_update.status",
@@ -4778,8 +4763,8 @@ function normalizePulseCreateBody(body) {
4778
4763
  }
4779
4764
  function normalizeSurveysCreateBody(body) {
4780
4765
  const survey = ensureEntityObject(body, "survey");
4781
- const title = asNonEmptyString4(survey.title);
4782
- const currentName = asNonEmptyString4(survey.name);
4766
+ const title = asNonEmptyString3(survey.title);
4767
+ const currentName = asNonEmptyString3(survey.name);
4783
4768
  if (!currentName && title) {
4784
4769
  survey.name = title;
4785
4770
  }
@@ -4808,8 +4793,8 @@ function normalizeSurveysCreateBody(body) {
4808
4793
  }
4809
4794
  function normalizeSurveysUpdateBody(body) {
4810
4795
  const survey = ensureEntityObject(body, "survey");
4811
- const title = asNonEmptyString4(survey.title);
4812
- const currentName = asNonEmptyString4(survey.name);
4796
+ const title = asNonEmptyString3(survey.title);
4797
+ const currentName = asNonEmptyString3(survey.name);
4813
4798
  if (!currentName && title) {
4814
4799
  survey.name = title;
4815
4800
  }
@@ -4836,8 +4821,8 @@ function normalizeSurveysUpdateBody(body) {
4836
4821
  }
4837
4822
  function normalizeFeedbacksCreateBody(body) {
4838
4823
  const feedback = ensureEntityObject(body, "feedback");
4839
- const title = asNonEmptyString4(feedback.title);
4840
- const currentName = asNonEmptyString4(feedback.name);
4824
+ const title = asNonEmptyString3(feedback.title);
4825
+ const currentName = asNonEmptyString3(feedback.name);
4841
4826
  if (!currentName && title) {
4842
4827
  feedback.name = title;
4843
4828
  }
@@ -4854,7 +4839,7 @@ function normalizeFeedbacksCreateBody(body) {
4854
4839
  allowed: FEEDBACK_QUARTERS,
4855
4840
  message: "Invalid feedback.quarter. Use one of: q1, q2, q3, q4."
4856
4841
  });
4857
- const year = asNonEmptyString4(feedback.year);
4842
+ const year = asNonEmptyString3(feedback.year);
4858
4843
  const missing = [];
4859
4844
  if (!name) missing.push("name");
4860
4845
  if (!quarter) missing.push("quarter");
@@ -4869,8 +4854,8 @@ function normalizeFeedbacksCreateBody(body) {
4869
4854
  }
4870
4855
  function normalizeFeedbacksUpdateBody(body) {
4871
4856
  const feedback = ensureEntityObject(body, "feedback");
4872
- const title = asNonEmptyString4(feedback.title);
4873
- const currentName = asNonEmptyString4(feedback.name);
4857
+ const title = asNonEmptyString3(feedback.title);
4858
+ const currentName = asNonEmptyString3(feedback.name);
4874
4859
  if (!currentName && title) {
4875
4860
  feedback.name = title;
4876
4861
  }
@@ -4897,14 +4882,14 @@ function normalizeFeedbacksUpdateBody(body) {
4897
4882
  }
4898
4883
  function normalizeAccountabilityCreateBody(body) {
4899
4884
  const responsibility = ensureEntityObject(body, "responsibility");
4900
- const summary = asNonEmptyString4(responsibility.summary);
4901
- const currentName = asNonEmptyString4(responsibility.name);
4885
+ const summary = asNonEmptyString3(responsibility.summary);
4886
+ const currentName = asNonEmptyString3(responsibility.name);
4902
4887
  if (!currentName && summary) {
4903
4888
  responsibility.name = summary;
4904
4889
  }
4905
4890
  delete responsibility.summary;
4906
- const name = asNonEmptyString4(responsibility.name);
4907
- const memberId = asNonEmptyString4(responsibility.member_id);
4891
+ const name = asNonEmptyString3(responsibility.name);
4892
+ const memberId = asNonEmptyString3(responsibility.member_id);
4908
4893
  const missing = [];
4909
4894
  if (!name) missing.push("name");
4910
4895
  if (!memberId) missing.push("member_id");
@@ -4919,8 +4904,8 @@ function normalizeAccountabilityCreateBody(body) {
4919
4904
  }
4920
4905
  function normalizeAccountabilityUpdateBody(body) {
4921
4906
  const responsibility = ensureEntityObject(body, "responsibility");
4922
- const summary = asNonEmptyString4(responsibility.summary);
4923
- const currentName = asNonEmptyString4(responsibility.name);
4907
+ const summary = asNonEmptyString3(responsibility.summary);
4908
+ const currentName = asNonEmptyString3(responsibility.name);
4924
4909
  if (!currentName && summary) {
4925
4910
  responsibility.name = summary;
4926
4911
  }
@@ -4952,7 +4937,7 @@ function parseSmartKpiViewCreateBody(raw) {
4952
4937
  }
4953
4938
  function normalizeSmartKpiViewCreateBody(body) {
4954
4939
  const smartKpiView = ensureEntityObject(body, "smart_kpi_view");
4955
- const name = asNonEmptyString4(smartKpiView.name);
4940
+ const name = asNonEmptyString3(smartKpiView.name);
4956
4941
  if (!name) {
4957
4942
  throwMissingRequiredCreateFields("smart_kpi_view", ["name"]);
4958
4943
  }
@@ -4990,9 +4975,9 @@ function buildKpisCreateMutation(params) {
4990
4975
  });
4991
4976
  }
4992
4977
  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);
4978
+ const name = asNonEmptyString3(smartKpi.name);
4979
+ const smartKpiViewId = asNonEmptyString3(smartKpi.smart_kpi_view_id);
4980
+ const measurableGroupId = asNonEmptyString3(smartKpi.measurable_group_id);
4996
4981
  const hasAllowedName = typeof name === "string" && SMART_KPI_NAME_SET.has(name);
4997
4982
  if (!name) {
4998
4983
  throw new CliError({
@@ -5012,7 +4997,7 @@ function buildKpisCreateMutation(params) {
5012
4997
  measurable_type: "number",
5013
4998
  condition: "greater_than_or_equal_to"
5014
4999
  };
5015
- const notes = asNonEmptyString4(smartKpi.notes);
5000
+ const notes = asNonEmptyString3(smartKpi.notes);
5016
5001
  if (notes) {
5017
5002
  measurable.notes = notes;
5018
5003
  }
@@ -5415,7 +5400,7 @@ function ensureRootObject(body, rootKey) {
5415
5400
  }
5416
5401
  return { ...root };
5417
5402
  }
5418
- function asNonEmptyString5(value) {
5403
+ function asNonEmptyString4(value) {
5419
5404
  if (typeof value !== "string") {
5420
5405
  return void 0;
5421
5406
  }
@@ -5425,7 +5410,7 @@ function asNonEmptyString5(value) {
5425
5410
  function normalizeOrganizationUpdateBody(body) {
5426
5411
  const organization = ensureRootObject(body, "organization");
5427
5412
  const detail = isRecord3(organization.organization_detail_attributes) ? { ...organization.organization_detail_attributes } : {};
5428
- const workspaceName = asNonEmptyString5(organization.workspace_name);
5413
+ const workspaceName = asNonEmptyString4(organization.workspace_name);
5429
5414
  if (workspaceName) {
5430
5415
  detail.workspace_name = workspaceName;
5431
5416
  }
@@ -5438,7 +5423,7 @@ function normalizeOrganizationUpdateBody(body) {
5438
5423
  function normalizeOrganizationMetaProfileUpdateBody(body) {
5439
5424
  const root = ensureRootObject(body, "organization_meta_profile");
5440
5425
  const profile = isRecord3(root.profile) ? { ...root.profile } : {};
5441
- const title = asNonEmptyString5(root.title);
5426
+ const title = asNonEmptyString4(root.title);
5442
5427
  if (title) {
5443
5428
  const companyIdentity = isRecord3(profile.company_identity) ? { ...profile.company_identity } : {};
5444
5429
  companyIdentity.one_sentence_summary = title;
@@ -5468,7 +5453,7 @@ function normalizeOrganizationMetaProfileUpdateBody(body) {
5468
5453
  function normalizeKeyMetricMetaProfileUpdateBody(body) {
5469
5454
  const root = ensureRootObject(body, "key_metric_meta_profile");
5470
5455
  const profile = isRecord3(root.profile) ? { ...root.profile } : {};
5471
- const annualRevenue = asNonEmptyString5(root.annual_revenue);
5456
+ const annualRevenue = asNonEmptyString4(root.annual_revenue);
5472
5457
  if (annualRevenue) {
5473
5458
  const financial = isRecord3(profile.financial) ? { ...profile.financial } : {};
5474
5459
  financial.revenue = annualRevenue;
@@ -5639,7 +5624,7 @@ function ensureRootObject2(body, rootKey) {
5639
5624
  }
5640
5625
  return { ...root };
5641
5626
  }
5642
- function asNonEmptyString6(value) {
5627
+ function asNonEmptyString5(value) {
5643
5628
  if (typeof value !== "string") {
5644
5629
  return void 0;
5645
5630
  }
@@ -5667,8 +5652,8 @@ function normalizeStrategicPlanUpdateBody(body) {
5667
5652
  }
5668
5653
  function normalizeStrategicObjectiveUpdateBody(body) {
5669
5654
  const strategicObjective = ensureRootObject2(body, "strategic_objective");
5670
- const title = asNonEmptyString6(strategicObjective.title);
5671
- if (!asNonEmptyString6(strategicObjective.summary) && title) {
5655
+ const title = asNonEmptyString5(strategicObjective.title);
5656
+ if (!asNonEmptyString5(strategicObjective.summary) && title) {
5672
5657
  strategicObjective.summary = title;
5673
5658
  }
5674
5659
  delete strategicObjective.title;
@@ -5691,8 +5676,8 @@ function normalizeStrategicObjectiveUpdateBody(body) {
5691
5676
  }
5692
5677
  function normalizeAnnualObjectiveCreateBody(body) {
5693
5678
  const annualObjective = ensureRootObject2(body, "annual_objective");
5694
- const title = asNonEmptyString6(annualObjective.title);
5695
- if (!asNonEmptyString6(annualObjective.name) && title) {
5679
+ const title = asNonEmptyString5(annualObjective.title);
5680
+ if (!asNonEmptyString5(annualObjective.name) && title) {
5696
5681
  annualObjective.name = title;
5697
5682
  }
5698
5683
  delete annualObjective.title;
@@ -5700,8 +5685,8 @@ function normalizeAnnualObjectiveCreateBody(body) {
5700
5685
  }
5701
5686
  function normalizeQuarterlyObjectiveCreateBody(body) {
5702
5687
  const quarterlyObjective = ensureRootObject2(body, "quarterly_objective");
5703
- const title = asNonEmptyString6(quarterlyObjective.title);
5704
- if (!asNonEmptyString6(quarterlyObjective.name) && title) {
5688
+ const title = asNonEmptyString5(quarterlyObjective.title);
5689
+ if (!asNonEmptyString5(quarterlyObjective.name) && title) {
5705
5690
  quarterlyObjective.name = title;
5706
5691
  }
5707
5692
  delete quarterlyObjective.title;
@@ -6502,7 +6487,7 @@ var import_zod16 = require("zod");
6502
6487
 
6503
6488
  // src/internalOptions.ts
6504
6489
  var INTERNAL_OPTIONS_KEY = "__waveInternalOptions";
6505
- function asRecord6(value) {
6490
+ function asRecord5(value) {
6506
6491
  if (!value || typeof value !== "object" || Array.isArray(value)) {
6507
6492
  return null;
6508
6493
  }
@@ -6516,7 +6501,7 @@ function setInternalCliOptions(program, options) {
6516
6501
  function getInternalCliOptions(command) {
6517
6502
  let current = command;
6518
6503
  while (current) {
6519
- const record = asRecord6(current[INTERNAL_OPTIONS_KEY]);
6504
+ const record = asRecord5(current[INTERNAL_OPTIONS_KEY]);
6520
6505
  if (record) {
6521
6506
  return {
6522
6507
  enableRetryOnEmptyPhrase: record.enableRetryOnEmptyPhrase === true
@@ -10188,7 +10173,7 @@ function positiveInt2(raw, fallback) {
10188
10173
  function requestTimeoutMs(totalTimeoutMs) {
10189
10174
  return Math.max(1e3, Math.min(totalTimeoutMs, 1e4));
10190
10175
  }
10191
- function asRecord7(value) {
10176
+ function asRecord6(value) {
10192
10177
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
10193
10178
  }
10194
10179
  function asString(value) {
@@ -10235,9 +10220,9 @@ function cliTokenFromPoll(payload) {
10235
10220
  return asString(payload.cliToken) ?? asString(payload.cli_token) ?? asString(payload.token);
10236
10221
  }
10237
10222
  function unwrapMutationResult(value) {
10238
- const record = asRecord7(value);
10223
+ const record = asRecord6(value);
10239
10224
  if (!record) return null;
10240
- const data = asRecord7(record.data);
10225
+ const data = asRecord6(record.data);
10241
10226
  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
10227
  return data;
10243
10228
  }
@@ -10255,7 +10240,7 @@ async function authStatusRequest(params) {
10255
10240
  });
10256
10241
  }
10257
10242
  async function runTokenLogin(cmd, opts) {
10258
- const context = await resolveCommandContext(cmd.optsWithGlobals());
10243
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
10259
10244
  const baseUrl = context.runtimeOptions.baseUrl;
10260
10245
  const globals = cmd.optsWithGlobals();
10261
10246
  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 +10286,7 @@ async function runTokenLogin(cmd, opts) {
10301
10286
  exitCode: mapStatusToExitCode(status.error.status)
10302
10287
  });
10303
10288
  }
10304
- const statusData = asRecord7(status.result.data.cliAuthStatus) ?? {};
10289
+ const statusData = asRecord6(status.result.data.cliAuthStatus) ?? {};
10305
10290
  const storage = await writeStoredToken(token, baseUrl);
10306
10291
  const configPath2 = opts.saveBaseUrl ? await persistBaseUrl(baseUrl) : void 0;
10307
10292
  return printEnvelopeAndExit({
@@ -10322,7 +10307,7 @@ async function runTokenLogin(cmd, opts) {
10322
10307
  });
10323
10308
  }
10324
10309
  async function runBrowserLogin(cmd, opts) {
10325
- const context = await resolveCommandContext(cmd.optsWithGlobals());
10310
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
10326
10311
  const baseUrl = context.runtimeOptions.baseUrl;
10327
10312
  const timeoutMs = positiveInt2(opts.timeoutMs ?? context.runtimeOptions.timeoutMs, DEFAULT_LOGIN_TIMEOUT_MS);
10328
10313
  const pollIntervalMs = positiveInt2(opts.pollIntervalMs, DEFAULT_POLL_INTERVAL_MS);
@@ -10502,7 +10487,7 @@ async function runBrowserLogin(cmd, opts) {
10502
10487
  });
10503
10488
  }
10504
10489
  async function runLogout(cmd) {
10505
- const context = await resolveCommandContext(cmd.optsWithGlobals());
10490
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
10506
10491
  const baseUrl = context.runtimeOptions.baseUrl;
10507
10492
  const token = context.runtimeOptions.token;
10508
10493
  const timeoutMs = positiveInt2(context.runtimeOptions.timeoutMs, 1e4);
@@ -10518,7 +10503,7 @@ async function runLogout(cmd) {
10518
10503
  });
10519
10504
  if (result.ok) {
10520
10505
  requestId = result.result.requestId;
10521
- const payload = asRecord7(result.result.data.revokeCliToken) ?? {};
10506
+ const payload = asRecord6(result.result.data.revokeCliToken) ?? {};
10522
10507
  revokedRemote = payload.ok !== false;
10523
10508
  } else {
10524
10509
  requestId = result.requestId;
@@ -10541,7 +10526,7 @@ async function runLogout(cmd) {
10541
10526
  });
10542
10527
  }
10543
10528
  async function runAuthStatus(cmd) {
10544
- const context = await resolveCommandContext(cmd.optsWithGlobals());
10529
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
10545
10530
  const baseUrl = context.runtimeOptions.baseUrl;
10546
10531
  const token = context.runtimeOptions.token;
10547
10532
  const tokenSource = context.runtimeOptions.tokenSource ?? "none";
@@ -10581,7 +10566,7 @@ async function runAuthStatus(cmd) {
10581
10566
  exitCode: mapStatusToExitCode(result.error.status)
10582
10567
  });
10583
10568
  }
10584
- const status = asRecord7(result.result.data.cliAuthStatus) ?? {};
10569
+ const status = asRecord6(result.result.data.cliAuthStatus) ?? {};
10585
10570
  const baseAuthStatus = status.baseAuthStatus;
10586
10571
  return printEnvelopeAndExit({
10587
10572
  envelope: envelope({
@@ -12232,11 +12217,11 @@ function sanitizePlannerJson(value) {
12232
12217
  }
12233
12218
  return output;
12234
12219
  }
12235
- function asRecord8(value) {
12220
+ function asRecord7(value) {
12236
12221
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
12237
12222
  }
12238
12223
  function readPlannerStateKey(value, keys) {
12239
- const record = asRecord8(value);
12224
+ const record = asRecord7(value);
12240
12225
  if (!record) {
12241
12226
  return null;
12242
12227
  }
@@ -14463,7 +14448,7 @@ async function runDatasheetsQuery(cmd, config) {
14463
14448
  });
14464
14449
  }
14465
14450
  async function runDatasheetsMutation(cmd, opts, config) {
14466
- const context = await resolveCommandContext(cmd.optsWithGlobals());
14451
+ const context = config.organizationContext === "optional" ? await resolveUnscopedCommandContext(cmd.optsWithGlobals()) : await resolveCommandContext(cmd.optsWithGlobals());
14467
14452
  const variables = config.organizationContext === "optional" ? context.organizationId ? { organization_id: context.organizationId } : {} : { organization_id: resolveOrganizationId(context.organizationId) };
14468
14453
  for (const id of config.requiredIds ?? []) {
14469
14454
  variables[id.variable] = requireNonEmpty(opts[id.option], id.label, config.command);
@@ -14500,7 +14485,7 @@ async function runDatasheetsMutation(cmd, opts, config) {
14500
14485
  runtimeOptions: context.runtimeOptions,
14501
14486
  field: config.field,
14502
14487
  variables: normalizeGraphqlVariables2(variables),
14503
- variableTypes: { organization_id: "ID!" },
14488
+ variableTypes: config.organizationContext === "optional" && !context.organizationId ? {} : { organization_id: "ID!" },
14504
14489
  selectionSet: DATASHEET_MUTATION_SELECTION
14505
14490
  });
14506
14491
  }
@@ -14940,7 +14925,7 @@ var AUTOMATION_SELECTION = `{
14940
14925
  createdAt
14941
14926
  updatedAt
14942
14927
  }`;
14943
- function asRecord9(value) {
14928
+ function asRecord8(value) {
14944
14929
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
14945
14930
  }
14946
14931
  function asRequiredString(value) {
@@ -14985,12 +14970,12 @@ function parseJson(value, optionName) {
14985
14970
  }
14986
14971
  }
14987
14972
  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);
14973
+ const mutation = asRecord8(payload);
14974
+ const mutationData = asRecord8(mutation?.data);
14975
+ const persisted = asRecord8(mutationData?.data) ?? mutationData;
14976
+ const attributes = asRecord8(persisted?.attributes);
14977
+ const meta = asRecord8(mutationData?.meta);
14978
+ const idempotency = asRecord8(meta?.atlas_idempotency);
14994
14979
  const id = asRequiredString(persisted?.id);
14995
14980
  const slug = asRequiredString(persisted?.slug) ?? asRequiredString(attributes?.slug);
14996
14981
  const replay = idempotency?.replay;
@@ -15692,12 +15677,39 @@ function namespaceDoc(name) {
15692
15677
  }
15693
15678
  };
15694
15679
  }
15695
- function allNamespaceDocs() {
15696
- return [
15697
- ...PRIMARY_NAMESPACES.map(namespaceDoc),
15698
- ...ADVANCED_NAMESPACES.map(namespaceDoc),
15699
- ...ALIASES.map(namespaceDoc)
15700
- ];
15680
+ function advertisedCommands(command) {
15681
+ const children = command.commands.filter((child) => !["help", "schema", "examples"].includes(child.name())).map((child) => child.name());
15682
+ return children.length > 0 ? children : [command.name()];
15683
+ }
15684
+ function examplesForRegisteredCommand(name, commands) {
15685
+ if (commands.includes("list")) {
15686
+ return [
15687
+ `wave ${name} list --page 1 --per 10`,
15688
+ ...commands.includes("show") ? [`wave ${name} show --id 123`] : []
15689
+ ];
15690
+ }
15691
+ const [firstCommand] = commands;
15692
+ return firstCommand && firstCommand !== name ? [`wave ${name} ${firstCommand}`] : [`wave ${name}`];
15693
+ }
15694
+ function registeredNamespaceDoc(command) {
15695
+ const doc = namespaceDoc(command.name());
15696
+ const commands = advertisedCommands(command);
15697
+ const usesGenericDocumentation = !NAMESPACE_DOCS[command.name()];
15698
+ return {
15699
+ ...doc,
15700
+ ...usesGenericDocumentation ? { examples: examplesForRegisteredCommand(command.name(), commands) } : {},
15701
+ schema: {
15702
+ ...doc.schema,
15703
+ commands
15704
+ }
15705
+ };
15706
+ }
15707
+ function allNamespaceDocs(program) {
15708
+ const names = program.commands.map((command) => command.name()).filter((name) => name !== "help").filter((name, index, values) => values.indexOf(name) === index);
15709
+ return names.flatMap((name) => {
15710
+ const command = program.commands.find((candidate) => candidate.name() === name);
15711
+ return command ? [registeredNamespaceDoc(command)] : [];
15712
+ });
15701
15713
  }
15702
15714
  function buildEnvelope2(command, data) {
15703
15715
  return {
@@ -15780,43 +15792,6 @@ function commandSummary(command) {
15780
15792
  }))
15781
15793
  };
15782
15794
  }
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
15795
  function packageVersion() {
15821
15796
  try {
15822
15797
  const pkg = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path4.join)(process.cwd(), "package.json"), "utf8"));
@@ -15853,7 +15828,9 @@ async function resolveDoctorAuthOrganization(params) {
15853
15828
  if (!status || typeof status !== "object" || Array.isArray(status)) {
15854
15829
  return null;
15855
15830
  }
15856
- const organization = status.organization;
15831
+ const cliAuthStatus = status;
15832
+ if (cliAuthStatus.authenticated !== true) return null;
15833
+ const organization = cliAuthStatus.organization;
15857
15834
  if (!organization || typeof organization !== "object" || Array.isArray(organization)) {
15858
15835
  return null;
15859
15836
  }
@@ -15868,7 +15845,7 @@ async function resolveDoctorAuthOrganization(params) {
15868
15845
  }
15869
15846
  }
15870
15847
  async function runDoctor(cmd, opts) {
15871
- const context = await resolveCommandContext(cmd.optsWithGlobals());
15848
+ const context = await resolveUnscopedCommandContext(cmd.optsWithGlobals());
15872
15849
  const runtime = context.runtimeOptions;
15873
15850
  const baseUrl = runtime.baseUrl;
15874
15851
  const token = runtime.token;
@@ -15894,7 +15871,7 @@ async function runDoctor(cmd, opts) {
15894
15871
  name: "organization_id",
15895
15872
  ok: Boolean(organizationId || authOrganization?.id || authOrganization?.slug),
15896
15873
  status: organizationId || authOrganization?.id || authOrganization?.slug ? "resolved" : "missing",
15897
- source: organizationId ? "flag/stdin/env" : authOrganization ? "auth_token" : "unresolved",
15874
+ source: organizationId ? "explicit_flag" : authOrganization ? "auth_token" : "unresolved",
15898
15875
  ...authOrganization?.id ? { id: authOrganization.id } : {},
15899
15876
  ...authOrganization?.slug ? { slug: authOrganization.slug } : {}
15900
15877
  },
@@ -15990,7 +15967,7 @@ function registerDiscoveryCommands(program) {
15990
15967
  stdout: "exactly one JSON envelope for machine commands",
15991
15968
  stderr: "diagnostics only"
15992
15969
  },
15993
- namespaces: allNamespaceDocs(),
15970
+ namespaces: allNamespaceDocs(program),
15994
15971
  toolSupportRegistry: {
15995
15972
  milestone: "WAVE-04",
15996
15973
  status: "registry_only",
@@ -16051,18 +16028,10 @@ function registerDiscoveryCommands(program) {
16051
16028
  return printEnvelopeAndExit({
16052
16029
  envelope: buildEnvelope2("api.ls", {
16053
16030
  commands: paths,
16054
- examples: ["wave api ls --json", "wave graphql fields --json"]
16031
+ examples: ["wave api ls --json"]
16055
16032
  })
16056
16033
  });
16057
16034
  });
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
16035
  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
16036
  const phantom = program.commands.find((command) => command.name() === "phantom");
16068
16037
  phantom?.addHelpText(
@@ -16076,7 +16045,6 @@ function attachNamespaceDiscovery(program) {
16076
16045
  ...ADVANCED_NAMESPACES,
16077
16046
  "capabilities",
16078
16047
  "api",
16079
- "graphql",
16080
16048
  "doctor",
16081
16049
  "auth"
16082
16050
  ]);
@@ -16086,7 +16054,7 @@ function attachNamespaceDiscovery(program) {
16086
16054
  if (!command.commands.some((child) => child.name() === "schema")) {
16087
16055
  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
16056
  const data = {
16089
- namespace: namespaceDoc(command.name()),
16057
+ namespace: registeredNamespaceDoc(command),
16090
16058
  command: commandSummary(command)
16091
16059
  };
16092
16060
  if (opts.readable && !opts.json) {
@@ -16102,7 +16070,7 @@ Output: ${data.namespace.schema.output}`
16102
16070
  }
16103
16071
  if (!command.commands.some((child) => child.name() === "examples")) {
16104
16072
  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;
16073
+ const examples = registeredNamespaceDoc(command).examples;
16106
16074
  if (opts.readable && !opts.json) {
16107
16075
  return printTextAndExit({ text: examples.join("\n") });
16108
16076
  }
@@ -16122,7 +16090,6 @@ function attachDiscoveryHelp(program) {
16122
16090
  " wave capabilities list List primary, advanced, and alias namespaces",
16123
16091
  " wave capabilities tools List shared recent-tool support metadata",
16124
16092
  " wave api ls List scriptable command paths",
16125
- " wave graphql fields List known GraphQL fields",
16126
16093
  " wave <namespace> schema Describe namespace output and command contract",
16127
16094
  " wave <namespace> examples Show copyable examples",
16128
16095
  " wave doctor Run read-only diagnostics",
@@ -16146,7 +16113,6 @@ function attachDiscoveryHelp(program) {
16146
16113
  ["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
16114
  ["capabilities", "\nExamples:\n wave capabilities list\n wave capabilities list --readable\n wave capabilities tools\n wave capabilities tools mail\n"],
16148
16115
  ["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
16116
  ["doctor", "\nExamples:\n wave doctor\n wave doctor --readable\n"]
16151
16117
  ]);
16152
16118
  for (const command of program.commands) {
@@ -16158,20 +16124,20 @@ function attachDiscoveryHelp(program) {
16158
16124
  }
16159
16125
 
16160
16126
  // src/version.ts
16161
- var CLI_VERSION = "0.1.62";
16127
+ var CLI_VERSION = "0.1.65";
16162
16128
 
16163
16129
  // src/cli.ts
16164
16130
  function buildCli(options) {
16165
16131
  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(
16132
+ 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
16133
  "--auth-json-stdin",
16168
- "Read auth/runtime context JSON from stdin (token, baseUrl, organizationId, ...)"
16134
+ "Read auth/runtime context JSON from stdin (token, baseUrl, tracing fields, ...)"
16169
16135
  ).option(
16170
16136
  "--base-url <baseUrl>",
16171
16137
  "API base URL (prefer WAVE_API_BASE_URL env var)"
16172
16138
  ).option(
16173
16139
  "--organization-id <organizationId>",
16174
- "Organization ID (prefer WAVE_ORGANIZATION_ID env var)"
16140
+ "Explicit organization ID override"
16175
16141
  ).option(
16176
16142
  "--config <configPath>",
16177
16143
  "Optional JSON config file (default: WAVE_CONFIG_PATH or ~/.wave/config.json when present)"