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