@wave-ai-os/wave-cli 0.1.66 → 0.1.68
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 +37 -7
- package/dist/index.cjs +1021 -22
- package/dist/index.js +1021 -22
- package/package.json +1 -1
- package/scripts/benchmark-cli.mjs +1 -1
package/dist/index.js
CHANGED
|
@@ -57,6 +57,9 @@ function mapStatusToExitCode(status) {
|
|
|
57
57
|
return EXIT_CODES.generic;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
// src/runtimeDefaults.ts
|
|
61
|
+
var DEFAULT_PRODUCTION_API_BASE_URL = "https://api.ourwave.io";
|
|
62
|
+
|
|
60
63
|
// src/config.ts
|
|
61
64
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
62
65
|
var configSchema = z.object({
|
|
@@ -115,15 +118,7 @@ function getConfig(options) {
|
|
|
115
118
|
exitCode: EXIT_CODES.missingOrInvalidAuth
|
|
116
119
|
});
|
|
117
120
|
}
|
|
118
|
-
const baseUrl = options.baseUrl ?? process.env.WAVE_API_BASE_URL ?? process.env.WAVE_API_URL;
|
|
119
|
-
if (!baseUrl) {
|
|
120
|
-
throw new CliError({
|
|
121
|
-
message: "Missing API base URL. Pass --base-url, provide via --auth-json-stdin, or set WAVE_API_BASE_URL/WAVE_API_URL.",
|
|
122
|
-
kind: "invalid_args",
|
|
123
|
-
status: 400,
|
|
124
|
-
exitCode: EXIT_CODES.invalidArgs
|
|
125
|
-
});
|
|
126
|
-
}
|
|
121
|
+
const baseUrl = options.baseUrl ?? process.env.WAVE_API_BASE_URL ?? process.env.WAVE_API_URL ?? DEFAULT_PRODUCTION_API_BASE_URL;
|
|
127
122
|
const parsed = configSchema.safeParse({
|
|
128
123
|
baseUrl,
|
|
129
124
|
token,
|
|
@@ -2276,7 +2271,8 @@ function resolveFromSources(options, stdin, config, env) {
|
|
|
2276
2271
|
normalize3(stdin.baseUrl),
|
|
2277
2272
|
normalize3(env.WAVE_API_BASE_URL),
|
|
2278
2273
|
normalize3(env.WAVE_API_URL),
|
|
2279
|
-
normalize3(config.baseUrl)
|
|
2274
|
+
normalize3(config.baseUrl),
|
|
2275
|
+
DEFAULT_PRODUCTION_API_BASE_URL
|
|
2280
2276
|
);
|
|
2281
2277
|
const organizationId = normalize3(options.organizationId);
|
|
2282
2278
|
const organizationIdSource = organizationId ? "flag" : "none";
|
|
@@ -15033,6 +15029,649 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
15033
15029
|
// src/commands/discovery.ts
|
|
15034
15030
|
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
15035
15031
|
import { join as join3 } from "path";
|
|
15032
|
+
|
|
15033
|
+
// src/operationManifest.ts
|
|
15034
|
+
import { createHash } from "crypto";
|
|
15035
|
+
|
|
15036
|
+
// src/version.ts
|
|
15037
|
+
var CLI_VERSION = "0.1.68";
|
|
15038
|
+
|
|
15039
|
+
// src/operationMetadata.ts
|
|
15040
|
+
var DISCOVERY_OPERATION_IDS = [
|
|
15041
|
+
"accountability.examples",
|
|
15042
|
+
"accountability.schema",
|
|
15043
|
+
"agents.examples",
|
|
15044
|
+
"agents.schema",
|
|
15045
|
+
"api.examples",
|
|
15046
|
+
"api.ls",
|
|
15047
|
+
"api.schema",
|
|
15048
|
+
"auth.examples",
|
|
15049
|
+
"auth.schema",
|
|
15050
|
+
"automations.examples",
|
|
15051
|
+
"automations.schema",
|
|
15052
|
+
"broadcast.examples",
|
|
15053
|
+
"broadcast.schema",
|
|
15054
|
+
"capabilities.examples",
|
|
15055
|
+
"capabilities.list",
|
|
15056
|
+
"capabilities.schema",
|
|
15057
|
+
"capabilities.tools",
|
|
15058
|
+
"contacts.examples",
|
|
15059
|
+
"contacts.schema",
|
|
15060
|
+
"content.examples",
|
|
15061
|
+
"content.schema",
|
|
15062
|
+
"customers.examples",
|
|
15063
|
+
"customers.schema",
|
|
15064
|
+
"datasheets.examples",
|
|
15065
|
+
"datasheets.schema",
|
|
15066
|
+
"doctor",
|
|
15067
|
+
"doctor.examples",
|
|
15068
|
+
"doctor.schema",
|
|
15069
|
+
"feedbacks.examples",
|
|
15070
|
+
"feedbacks.schema",
|
|
15071
|
+
"foundation.examples",
|
|
15072
|
+
"foundation.schema",
|
|
15073
|
+
"issue-groups.examples",
|
|
15074
|
+
"issue-groups.schema",
|
|
15075
|
+
"issues.examples",
|
|
15076
|
+
"issues.schema",
|
|
15077
|
+
"knowledge.examples",
|
|
15078
|
+
"knowledge.schema",
|
|
15079
|
+
"kpis.examples",
|
|
15080
|
+
"kpis.schema",
|
|
15081
|
+
"list-items.examples",
|
|
15082
|
+
"list-items.schema",
|
|
15083
|
+
"lists.examples",
|
|
15084
|
+
"lists.schema",
|
|
15085
|
+
"mail.examples",
|
|
15086
|
+
"mail.schema",
|
|
15087
|
+
"markdown-tree.examples",
|
|
15088
|
+
"markdown-tree.schema",
|
|
15089
|
+
"meetings.examples",
|
|
15090
|
+
"meetings.schema",
|
|
15091
|
+
"members.examples",
|
|
15092
|
+
"members.schema",
|
|
15093
|
+
"milestones.examples",
|
|
15094
|
+
"milestones.schema",
|
|
15095
|
+
"news.examples",
|
|
15096
|
+
"news.schema",
|
|
15097
|
+
"organizations.examples",
|
|
15098
|
+
"organizations.schema",
|
|
15099
|
+
"osmd.examples",
|
|
15100
|
+
"osmd.schema",
|
|
15101
|
+
"planner.examples",
|
|
15102
|
+
"planner.schema",
|
|
15103
|
+
"project-content.examples",
|
|
15104
|
+
"project-content.schema",
|
|
15105
|
+
"projects.examples",
|
|
15106
|
+
"projects.schema",
|
|
15107
|
+
"pulse.examples",
|
|
15108
|
+
"pulse.schema",
|
|
15109
|
+
"questions.examples",
|
|
15110
|
+
"questions.schema",
|
|
15111
|
+
"recognition.examples",
|
|
15112
|
+
"recognition.schema",
|
|
15113
|
+
"rock-collections.examples",
|
|
15114
|
+
"rock-collections.schema",
|
|
15115
|
+
"rocks.examples",
|
|
15116
|
+
"rocks.schema",
|
|
15117
|
+
"scorecard-groups.examples",
|
|
15118
|
+
"scorecard-groups.schema",
|
|
15119
|
+
"scorecards.examples",
|
|
15120
|
+
"scorecards.schema",
|
|
15121
|
+
"skills.examples",
|
|
15122
|
+
"skills.schema",
|
|
15123
|
+
"stand-ups.examples",
|
|
15124
|
+
"stand-ups.schema",
|
|
15125
|
+
"subissues.examples",
|
|
15126
|
+
"subissues.schema",
|
|
15127
|
+
"subitems.examples",
|
|
15128
|
+
"subitems.schema",
|
|
15129
|
+
"subtasks.examples",
|
|
15130
|
+
"subtasks.schema",
|
|
15131
|
+
"subtodos.examples",
|
|
15132
|
+
"subtodos.schema",
|
|
15133
|
+
"support.examples",
|
|
15134
|
+
"support.schema",
|
|
15135
|
+
"surveys.examples",
|
|
15136
|
+
"surveys.schema",
|
|
15137
|
+
"talking-points.examples",
|
|
15138
|
+
"talking-points.schema",
|
|
15139
|
+
"tasks.examples",
|
|
15140
|
+
"tasks.schema",
|
|
15141
|
+
"teams.examples",
|
|
15142
|
+
"teams.schema",
|
|
15143
|
+
"time-tracking.examples",
|
|
15144
|
+
"time-tracking.schema",
|
|
15145
|
+
"todo-groups.examples",
|
|
15146
|
+
"todo-groups.schema",
|
|
15147
|
+
"todos.examples",
|
|
15148
|
+
"todos.schema",
|
|
15149
|
+
"whiteboards.examples",
|
|
15150
|
+
"whiteboards.schema"
|
|
15151
|
+
];
|
|
15152
|
+
var READ_OPERATION_IDS = [
|
|
15153
|
+
"accountability.list",
|
|
15154
|
+
"accountability.search",
|
|
15155
|
+
"accountability.show",
|
|
15156
|
+
"agents.show",
|
|
15157
|
+
"auth.status",
|
|
15158
|
+
"automations.show",
|
|
15159
|
+
"broadcast.community",
|
|
15160
|
+
"broadcast.list",
|
|
15161
|
+
"broadcast.open",
|
|
15162
|
+
"broadcast.workspace",
|
|
15163
|
+
"cat",
|
|
15164
|
+
"contacts.list",
|
|
15165
|
+
"contacts.search",
|
|
15166
|
+
"contacts.show",
|
|
15167
|
+
"content.list",
|
|
15168
|
+
"content.show",
|
|
15169
|
+
"customers.list",
|
|
15170
|
+
"customers.search",
|
|
15171
|
+
"customers.show",
|
|
15172
|
+
"datasheets.list",
|
|
15173
|
+
"datasheets.open",
|
|
15174
|
+
"datasheets.show",
|
|
15175
|
+
"feedbacks.list",
|
|
15176
|
+
"feedbacks.search",
|
|
15177
|
+
"feedbacks.show",
|
|
15178
|
+
"find",
|
|
15179
|
+
"foundation.annual-objectives.list",
|
|
15180
|
+
"foundation.annual-objectives.search",
|
|
15181
|
+
"foundation.annual-objectives.show",
|
|
15182
|
+
"foundation.quarterly-objectives.list",
|
|
15183
|
+
"foundation.quarterly-objectives.search",
|
|
15184
|
+
"foundation.quarterly-objectives.show",
|
|
15185
|
+
"foundation.strategic-objectives.show",
|
|
15186
|
+
"foundation.strategic-plans.show",
|
|
15187
|
+
"issue-groups.list",
|
|
15188
|
+
"issue-groups.search",
|
|
15189
|
+
"issue-groups.show",
|
|
15190
|
+
"issues.list",
|
|
15191
|
+
"issues.search",
|
|
15192
|
+
"issues.show",
|
|
15193
|
+
"knowledge.list",
|
|
15194
|
+
"knowledge.search",
|
|
15195
|
+
"knowledge.show",
|
|
15196
|
+
"kpis.list",
|
|
15197
|
+
"kpis.search",
|
|
15198
|
+
"kpis.show",
|
|
15199
|
+
"list-items.list",
|
|
15200
|
+
"list-items.search",
|
|
15201
|
+
"list-items.show",
|
|
15202
|
+
"lists.list",
|
|
15203
|
+
"lists.search",
|
|
15204
|
+
"lists.show",
|
|
15205
|
+
"ls",
|
|
15206
|
+
"mail.accounts",
|
|
15207
|
+
"mail.conversation",
|
|
15208
|
+
"mail.conversations",
|
|
15209
|
+
"mail.labels",
|
|
15210
|
+
"mail.message",
|
|
15211
|
+
"mail.messages",
|
|
15212
|
+
"mail.open",
|
|
15213
|
+
"mail.settings",
|
|
15214
|
+
"mail.snippets",
|
|
15215
|
+
"mail.sync-status",
|
|
15216
|
+
"mail.unread-count",
|
|
15217
|
+
"mail.validate-provider",
|
|
15218
|
+
"mail.workspace",
|
|
15219
|
+
"markdown-tree.children",
|
|
15220
|
+
"markdown-tree.resolve",
|
|
15221
|
+
"markdown-tree.root",
|
|
15222
|
+
"markdown-tree.subtree",
|
|
15223
|
+
"meetings.list",
|
|
15224
|
+
"meetings.search",
|
|
15225
|
+
"meetings.show",
|
|
15226
|
+
"members.list",
|
|
15227
|
+
"members.meta-profile",
|
|
15228
|
+
"members.search",
|
|
15229
|
+
"members.show",
|
|
15230
|
+
"milestones.list",
|
|
15231
|
+
"milestones.search",
|
|
15232
|
+
"news.list",
|
|
15233
|
+
"news.search",
|
|
15234
|
+
"news.show",
|
|
15235
|
+
"open",
|
|
15236
|
+
"organizations.key-metric-meta-profile.show",
|
|
15237
|
+
"organizations.meta-profile.show",
|
|
15238
|
+
"organizations.show",
|
|
15239
|
+
"osmd.agent.children",
|
|
15240
|
+
"osmd.agent.read",
|
|
15241
|
+
"osmd.agent.status",
|
|
15242
|
+
"osmd.children",
|
|
15243
|
+
"osmd.lint",
|
|
15244
|
+
"osmd.memory-quality",
|
|
15245
|
+
"osmd.read",
|
|
15246
|
+
"osmd.search",
|
|
15247
|
+
"osmd.status",
|
|
15248
|
+
"osmd.tree",
|
|
15249
|
+
"osmd.wiki.read",
|
|
15250
|
+
"osmd.wiki.status",
|
|
15251
|
+
"phantom.apply-operation",
|
|
15252
|
+
"phantom.apply-operations",
|
|
15253
|
+
"phantom.candidate",
|
|
15254
|
+
"phantom.candidates",
|
|
15255
|
+
"phantom.evidence",
|
|
15256
|
+
"phantom.evidences",
|
|
15257
|
+
"phantom.inventory",
|
|
15258
|
+
"phantom.observation",
|
|
15259
|
+
"phantom.observations",
|
|
15260
|
+
"phantom.report",
|
|
15261
|
+
"phantom.validation",
|
|
15262
|
+
"phantom.validations",
|
|
15263
|
+
"planner.booking-links",
|
|
15264
|
+
"planner.events",
|
|
15265
|
+
"planner.open",
|
|
15266
|
+
"planner.preferences",
|
|
15267
|
+
"planner.public-booking-link",
|
|
15268
|
+
"planner.state",
|
|
15269
|
+
"projects.list",
|
|
15270
|
+
"projects.search",
|
|
15271
|
+
"projects.show",
|
|
15272
|
+
"pulse.list",
|
|
15273
|
+
"pulse.search",
|
|
15274
|
+
"pulse.show",
|
|
15275
|
+
"questions.list",
|
|
15276
|
+
"questions.search",
|
|
15277
|
+
"questions.show",
|
|
15278
|
+
"recognition.list",
|
|
15279
|
+
"recognition.open",
|
|
15280
|
+
"recognition.point-balance",
|
|
15281
|
+
"recognition.show",
|
|
15282
|
+
"recognition.top-value",
|
|
15283
|
+
"rock-collections.list",
|
|
15284
|
+
"rock-collections.search",
|
|
15285
|
+
"rock-collections.show",
|
|
15286
|
+
"rocks.list",
|
|
15287
|
+
"rocks.search",
|
|
15288
|
+
"rocks.show",
|
|
15289
|
+
"scorecard-groups.list",
|
|
15290
|
+
"scorecard-groups.search",
|
|
15291
|
+
"scorecard-groups.show",
|
|
15292
|
+
"scorecards.list",
|
|
15293
|
+
"scorecards.search",
|
|
15294
|
+
"scorecards.show",
|
|
15295
|
+
"skills.list",
|
|
15296
|
+
"skills.show",
|
|
15297
|
+
"stand-ups.list",
|
|
15298
|
+
"stand-ups.search",
|
|
15299
|
+
"stand-ups.show",
|
|
15300
|
+
"subissues.list",
|
|
15301
|
+
"subissues.search",
|
|
15302
|
+
"subitems.list",
|
|
15303
|
+
"subitems.search",
|
|
15304
|
+
"subtasks.list",
|
|
15305
|
+
"subtasks.search",
|
|
15306
|
+
"subtodos.list",
|
|
15307
|
+
"subtodos.search",
|
|
15308
|
+
"support.counts",
|
|
15309
|
+
"support.inbox",
|
|
15310
|
+
"support.knowledge-articles",
|
|
15311
|
+
"support.knowledge-collections",
|
|
15312
|
+
"support.labels",
|
|
15313
|
+
"support.open",
|
|
15314
|
+
"support.settings",
|
|
15315
|
+
"support.ticket-counts",
|
|
15316
|
+
"support.tickets",
|
|
15317
|
+
"surveys.list",
|
|
15318
|
+
"surveys.search",
|
|
15319
|
+
"surveys.show",
|
|
15320
|
+
"talking-points.list",
|
|
15321
|
+
"talking-points.search",
|
|
15322
|
+
"tasks.list",
|
|
15323
|
+
"tasks.search",
|
|
15324
|
+
"tasks.show",
|
|
15325
|
+
"teams.list",
|
|
15326
|
+
"teams.show",
|
|
15327
|
+
"time-tracking.entries",
|
|
15328
|
+
"time-tracking.open",
|
|
15329
|
+
"time-tracking.projects",
|
|
15330
|
+
"time-tracking.report",
|
|
15331
|
+
"time-tracking.show",
|
|
15332
|
+
"time-tracking.timer",
|
|
15333
|
+
"time-tracking.timesheet",
|
|
15334
|
+
"todo-groups.list",
|
|
15335
|
+
"todo-groups.search",
|
|
15336
|
+
"todo-groups.show",
|
|
15337
|
+
"todos.list",
|
|
15338
|
+
"todos.search",
|
|
15339
|
+
"todos.show",
|
|
15340
|
+
"tree",
|
|
15341
|
+
"whiteboards.list",
|
|
15342
|
+
"whiteboards.open",
|
|
15343
|
+
"whiteboards.show"
|
|
15344
|
+
];
|
|
15345
|
+
var WRITE_OPERATION_IDS = [
|
|
15346
|
+
"accountability.create",
|
|
15347
|
+
"accountability.update",
|
|
15348
|
+
"agents.create",
|
|
15349
|
+
"automations.create",
|
|
15350
|
+
"contacts.create",
|
|
15351
|
+
"contacts.update",
|
|
15352
|
+
"content.create-contact",
|
|
15353
|
+
"content.create-customer",
|
|
15354
|
+
"content.create-manager",
|
|
15355
|
+
"content.create-member",
|
|
15356
|
+
"content.create-project",
|
|
15357
|
+
"content.create-team",
|
|
15358
|
+
"content.destroy",
|
|
15359
|
+
"content.update",
|
|
15360
|
+
"customers.create",
|
|
15361
|
+
"customers.update",
|
|
15362
|
+
"datasheets.archive",
|
|
15363
|
+
"datasheets.cell.upsert",
|
|
15364
|
+
"datasheets.column.archive",
|
|
15365
|
+
"datasheets.column.create",
|
|
15366
|
+
"datasheets.column.delete",
|
|
15367
|
+
"datasheets.column.reorder",
|
|
15368
|
+
"datasheets.column.update",
|
|
15369
|
+
"datasheets.create",
|
|
15370
|
+
"datasheets.export.create",
|
|
15371
|
+
"datasheets.favorite",
|
|
15372
|
+
"datasheets.form.archive",
|
|
15373
|
+
"datasheets.form.close",
|
|
15374
|
+
"datasheets.form.create",
|
|
15375
|
+
"datasheets.form.delete",
|
|
15376
|
+
"datasheets.form.publish",
|
|
15377
|
+
"datasheets.form.submit",
|
|
15378
|
+
"datasheets.form.update",
|
|
15379
|
+
"datasheets.import.commit",
|
|
15380
|
+
"datasheets.row.archive",
|
|
15381
|
+
"datasheets.row.create",
|
|
15382
|
+
"datasheets.row.delete",
|
|
15383
|
+
"datasheets.row.reorder",
|
|
15384
|
+
"datasheets.row.update",
|
|
15385
|
+
"datasheets.update",
|
|
15386
|
+
"datasheets.view.archive",
|
|
15387
|
+
"datasheets.view.create",
|
|
15388
|
+
"datasheets.view.delete",
|
|
15389
|
+
"datasheets.view.reorder",
|
|
15390
|
+
"datasheets.view.update",
|
|
15391
|
+
"feedbacks.create",
|
|
15392
|
+
"feedbacks.update",
|
|
15393
|
+
"foundation.annual-objectives.create",
|
|
15394
|
+
"foundation.annual-objectives.update",
|
|
15395
|
+
"foundation.quarterly-objectives.create",
|
|
15396
|
+
"foundation.quarterly-objectives.update",
|
|
15397
|
+
"foundation.strategic-objectives.update",
|
|
15398
|
+
"foundation.strategic-plans.update",
|
|
15399
|
+
"issue-groups.create",
|
|
15400
|
+
"issue-groups.update",
|
|
15401
|
+
"issues.create",
|
|
15402
|
+
"issues.update",
|
|
15403
|
+
"knowledge.create",
|
|
15404
|
+
"knowledge.update",
|
|
15405
|
+
"kpis.create",
|
|
15406
|
+
"kpis.update",
|
|
15407
|
+
"list-items.create",
|
|
15408
|
+
"list-items.update",
|
|
15409
|
+
"lists.create",
|
|
15410
|
+
"lists.update",
|
|
15411
|
+
"meetings.create",
|
|
15412
|
+
"meetings.notes",
|
|
15413
|
+
"meetings.update",
|
|
15414
|
+
"members.create",
|
|
15415
|
+
"members.update",
|
|
15416
|
+
"milestones.create",
|
|
15417
|
+
"milestones.destroy",
|
|
15418
|
+
"milestones.update",
|
|
15419
|
+
"news.create",
|
|
15420
|
+
"news.update",
|
|
15421
|
+
"organizations.key-metric-meta-profile.update",
|
|
15422
|
+
"organizations.meta-profile.update",
|
|
15423
|
+
"organizations.update",
|
|
15424
|
+
"osmd.agent.create",
|
|
15425
|
+
"osmd.agent.init",
|
|
15426
|
+
"osmd.agent.update",
|
|
15427
|
+
"osmd.ingest.file",
|
|
15428
|
+
"osmd.ingest.text",
|
|
15429
|
+
"osmd.ingest.transcript",
|
|
15430
|
+
"osmd.ingest.url",
|
|
15431
|
+
"osmd.phantom.run",
|
|
15432
|
+
"osmd.wiki.append-log",
|
|
15433
|
+
"osmd.wiki.create",
|
|
15434
|
+
"osmd.wiki.index-upsert",
|
|
15435
|
+
"osmd.wiki.update",
|
|
15436
|
+
"project-content.create",
|
|
15437
|
+
"project-content.destroy",
|
|
15438
|
+
"project-content.update",
|
|
15439
|
+
"projects.create",
|
|
15440
|
+
"projects.update",
|
|
15441
|
+
"pulse.create",
|
|
15442
|
+
"pulse.update",
|
|
15443
|
+
"questions.create",
|
|
15444
|
+
"questions.update",
|
|
15445
|
+
"rock-collections.create",
|
|
15446
|
+
"rock-collections.update",
|
|
15447
|
+
"rocks.create",
|
|
15448
|
+
"rocks.update",
|
|
15449
|
+
"rocks.update-status",
|
|
15450
|
+
"scorecard-groups.create",
|
|
15451
|
+
"scorecard-groups.update",
|
|
15452
|
+
"scorecards.create",
|
|
15453
|
+
"scorecards.update",
|
|
15454
|
+
"skills.create",
|
|
15455
|
+
"smart-kpi-views.create",
|
|
15456
|
+
"stand-ups.create",
|
|
15457
|
+
"stand-ups.update",
|
|
15458
|
+
"subissues.create",
|
|
15459
|
+
"subissues.destroy",
|
|
15460
|
+
"subissues.update",
|
|
15461
|
+
"subitems.create",
|
|
15462
|
+
"subitems.destroy",
|
|
15463
|
+
"subitems.update",
|
|
15464
|
+
"subtasks.create",
|
|
15465
|
+
"subtasks.destroy",
|
|
15466
|
+
"subtasks.update",
|
|
15467
|
+
"subtodos.create",
|
|
15468
|
+
"subtodos.destroy",
|
|
15469
|
+
"subtodos.update",
|
|
15470
|
+
"surveys.create",
|
|
15471
|
+
"surveys.update",
|
|
15472
|
+
"talking-points.create",
|
|
15473
|
+
"talking-points.destroy",
|
|
15474
|
+
"talking-points.update",
|
|
15475
|
+
"tasks.create",
|
|
15476
|
+
"tasks.destroy",
|
|
15477
|
+
"tasks.update",
|
|
15478
|
+
"teams.create",
|
|
15479
|
+
"teams.update",
|
|
15480
|
+
"todo-groups.create",
|
|
15481
|
+
"todo-groups.update",
|
|
15482
|
+
"todos.create",
|
|
15483
|
+
"todos.update"
|
|
15484
|
+
];
|
|
15485
|
+
var AUTH_OPERATION_IDS = ["login", "logout"];
|
|
15486
|
+
var DESTRUCTIVE_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
15487
|
+
"content.destroy",
|
|
15488
|
+
"datasheets.archive",
|
|
15489
|
+
"datasheets.column.archive",
|
|
15490
|
+
"datasheets.column.delete",
|
|
15491
|
+
"datasheets.form.archive",
|
|
15492
|
+
"datasheets.form.close",
|
|
15493
|
+
"datasheets.form.delete",
|
|
15494
|
+
"datasheets.form.publish",
|
|
15495
|
+
"datasheets.form.submit",
|
|
15496
|
+
"datasheets.import.commit",
|
|
15497
|
+
"datasheets.row.archive",
|
|
15498
|
+
"datasheets.row.delete",
|
|
15499
|
+
"datasheets.view.archive",
|
|
15500
|
+
"datasheets.view.delete",
|
|
15501
|
+
"milestones.destroy",
|
|
15502
|
+
"project-content.destroy",
|
|
15503
|
+
"subissues.destroy",
|
|
15504
|
+
"subitems.destroy",
|
|
15505
|
+
"subtasks.destroy",
|
|
15506
|
+
"subtodos.destroy",
|
|
15507
|
+
"talking-points.destroy",
|
|
15508
|
+
"tasks.destroy"
|
|
15509
|
+
]);
|
|
15510
|
+
var OPERATION_IDS_BY_CLASSIFICATION = {
|
|
15511
|
+
discovery: DISCOVERY_OPERATION_IDS,
|
|
15512
|
+
read: READ_OPERATION_IDS,
|
|
15513
|
+
write: WRITE_OPERATION_IDS,
|
|
15514
|
+
auth: AUTH_OPERATION_IDS
|
|
15515
|
+
};
|
|
15516
|
+
var metadataByOperationId = /* @__PURE__ */ new Map();
|
|
15517
|
+
for (const [classification, operationIds] of Object.entries(OPERATION_IDS_BY_CLASSIFICATION)) {
|
|
15518
|
+
for (const id of operationIds) {
|
|
15519
|
+
if (metadataByOperationId.has(id)) {
|
|
15520
|
+
throw new Error(`Duplicate Wave CLI operation metadata: ${id}`);
|
|
15521
|
+
}
|
|
15522
|
+
const atlasSafetyClass = classification === "discovery" ? "discovery" : classification === "read" ? "read_only" : classification === "auth" ? "auth" : DESTRUCTIVE_OPERATION_IDS.has(id) ? "destructive" : "mutation";
|
|
15523
|
+
if (DESTRUCTIVE_OPERATION_IDS.has(id) && classification !== "write") {
|
|
15524
|
+
throw new Error(`Destructive Wave CLI operation must be a write: ${id}`);
|
|
15525
|
+
}
|
|
15526
|
+
metadataByOperationId.set(id, {
|
|
15527
|
+
classification,
|
|
15528
|
+
requiresApproval: classification === "write",
|
|
15529
|
+
atlasSafetyClass,
|
|
15530
|
+
machine: {
|
|
15531
|
+
supportsValidate: true,
|
|
15532
|
+
supportsPreview: classification === "write",
|
|
15533
|
+
supportsExecute: true,
|
|
15534
|
+
executionMode: "sync"
|
|
15535
|
+
}
|
|
15536
|
+
});
|
|
15537
|
+
}
|
|
15538
|
+
}
|
|
15539
|
+
function registeredOperationMetadata(id) {
|
|
15540
|
+
return metadataByOperationId.get(id);
|
|
15541
|
+
}
|
|
15542
|
+
|
|
15543
|
+
// src/operationManifest.ts
|
|
15544
|
+
var MACHINE_PRESENTATION_OPTIONS = /* @__PURE__ */ new Set(["json", "readable"]);
|
|
15545
|
+
function hasAction(command) {
|
|
15546
|
+
return Boolean(command._actionHandler);
|
|
15547
|
+
}
|
|
15548
|
+
function commandPath(command) {
|
|
15549
|
+
const path = [];
|
|
15550
|
+
let current = command;
|
|
15551
|
+
while (current) {
|
|
15552
|
+
const name = current.name();
|
|
15553
|
+
if (name) path.unshift(name);
|
|
15554
|
+
current = current.parent ?? null;
|
|
15555
|
+
}
|
|
15556
|
+
return path;
|
|
15557
|
+
}
|
|
15558
|
+
function operationId(path) {
|
|
15559
|
+
return path.slice(1).join(".");
|
|
15560
|
+
}
|
|
15561
|
+
function inputKeyForArgument(argument) {
|
|
15562
|
+
return argument.name().replace(/<|>|\[|\]|\.\.\./g, "");
|
|
15563
|
+
}
|
|
15564
|
+
function inputSchemaFor(command) {
|
|
15565
|
+
const properties = {};
|
|
15566
|
+
const required = [];
|
|
15567
|
+
for (const argument of command.registeredArguments) {
|
|
15568
|
+
const key = inputKeyForArgument(argument);
|
|
15569
|
+
properties[key] = {
|
|
15570
|
+
type: argument.variadic ? "array" : "string",
|
|
15571
|
+
...argument.description ? { description: argument.description } : {}
|
|
15572
|
+
};
|
|
15573
|
+
if (argument.required) required.push(key);
|
|
15574
|
+
}
|
|
15575
|
+
for (const option of command.options) {
|
|
15576
|
+
const key = option.attributeName();
|
|
15577
|
+
if (MACHINE_PRESENTATION_OPTIONS.has(key)) continue;
|
|
15578
|
+
properties[key] = {
|
|
15579
|
+
type: option.required ? "string" : option.optional ? ["boolean", "string"] : "boolean",
|
|
15580
|
+
...option.description ? { description: option.description } : {}
|
|
15581
|
+
};
|
|
15582
|
+
if (option.mandatory) required.push(key);
|
|
15583
|
+
}
|
|
15584
|
+
return {
|
|
15585
|
+
type: "object",
|
|
15586
|
+
additionalProperties: false,
|
|
15587
|
+
properties,
|
|
15588
|
+
required: required.sort()
|
|
15589
|
+
};
|
|
15590
|
+
}
|
|
15591
|
+
function exampleFor(inputSchema) {
|
|
15592
|
+
const input = {};
|
|
15593
|
+
for (const key of inputSchema.required) {
|
|
15594
|
+
const propertyType = inputSchema.properties[key]?.type;
|
|
15595
|
+
const types = Array.isArray(propertyType) ? propertyType : [propertyType];
|
|
15596
|
+
input[key] = types.includes("array") ? ["example"] : types.includes("boolean") ? true : "example";
|
|
15597
|
+
}
|
|
15598
|
+
return [{ name: "minimal valid input", input }];
|
|
15599
|
+
}
|
|
15600
|
+
function outputSchema() {
|
|
15601
|
+
return {
|
|
15602
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
15603
|
+
type: "object",
|
|
15604
|
+
additionalProperties: false,
|
|
15605
|
+
properties: {
|
|
15606
|
+
ok: { type: "boolean" },
|
|
15607
|
+
command: { type: "string" },
|
|
15608
|
+
status: { type: "number" },
|
|
15609
|
+
data: { type: ["object", "array", "string", "number", "boolean", "null"] },
|
|
15610
|
+
error: { type: ["object", "null"] },
|
|
15611
|
+
meta: { type: "object" }
|
|
15612
|
+
},
|
|
15613
|
+
required: ["ok", "command", "status", "data", "error", "meta"]
|
|
15614
|
+
};
|
|
15615
|
+
}
|
|
15616
|
+
function listInvocableCommands(program) {
|
|
15617
|
+
const result = [];
|
|
15618
|
+
const visit = (command) => {
|
|
15619
|
+
if (command.name() !== "help" && hasAction(command)) result.push(command);
|
|
15620
|
+
for (const child of command.commands) visit(child);
|
|
15621
|
+
};
|
|
15622
|
+
for (const command of program.commands) visit(command);
|
|
15623
|
+
return result;
|
|
15624
|
+
}
|
|
15625
|
+
function entryFor(command, metadata) {
|
|
15626
|
+
const path = commandPath(command);
|
|
15627
|
+
const inputSchema = inputSchemaFor(command);
|
|
15628
|
+
const summary = command.description() || `Run ${path.join(" ")}.`;
|
|
15629
|
+
return {
|
|
15630
|
+
id: operationId(path),
|
|
15631
|
+
path,
|
|
15632
|
+
command: path.join(" "),
|
|
15633
|
+
summary,
|
|
15634
|
+
description: summary,
|
|
15635
|
+
classification: metadata.classification,
|
|
15636
|
+
requiresApproval: metadata.requiresApproval,
|
|
15637
|
+
atlasSafetyClass: metadata.atlasSafetyClass,
|
|
15638
|
+
inputSchema,
|
|
15639
|
+
outputSchema: outputSchema(),
|
|
15640
|
+
examples: exampleFor(inputSchema),
|
|
15641
|
+
machine: metadata.machine
|
|
15642
|
+
};
|
|
15643
|
+
}
|
|
15644
|
+
function digestFor(operations) {
|
|
15645
|
+
const canonical = JSON.stringify(operations);
|
|
15646
|
+
return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
|
|
15647
|
+
}
|
|
15648
|
+
function buildOperationManifest(program) {
|
|
15649
|
+
const operations = listInvocableCommands(program).map((command) => {
|
|
15650
|
+
const path = commandPath(command);
|
|
15651
|
+
const id = operationId(path);
|
|
15652
|
+
const metadata = registeredOperationMetadata(id);
|
|
15653
|
+
if (!metadata) {
|
|
15654
|
+
throw new Error(`Missing explicit Wave CLI operation metadata: ${id}`);
|
|
15655
|
+
}
|
|
15656
|
+
return entryFor(command, metadata);
|
|
15657
|
+
}).sort((left, right) => left.id.localeCompare(right.id));
|
|
15658
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15659
|
+
for (const operation of operations) {
|
|
15660
|
+
if (seen.has(operation.id)) {
|
|
15661
|
+
throw new Error(`Duplicate Wave CLI operation id: ${operation.id}`);
|
|
15662
|
+
}
|
|
15663
|
+
seen.add(operation.id);
|
|
15664
|
+
}
|
|
15665
|
+
return {
|
|
15666
|
+
manifestVersion: "1",
|
|
15667
|
+
cli: { package: "@wave-ai-os/wave-cli", version: CLI_VERSION },
|
|
15668
|
+
registryDigest: digestFor(operations),
|
|
15669
|
+
operationCount: operations.length,
|
|
15670
|
+
operations
|
|
15671
|
+
};
|
|
15672
|
+
}
|
|
15673
|
+
|
|
15674
|
+
// src/commands/discovery.ts
|
|
15036
15675
|
var PRIMARY_NAMESPACES = [
|
|
15037
15676
|
"osmd",
|
|
15038
15677
|
"broadcast",
|
|
@@ -15641,13 +16280,6 @@ function readableToolSupport(key) {
|
|
|
15641
16280
|
].join("\n");
|
|
15642
16281
|
}).join("\n\n");
|
|
15643
16282
|
}
|
|
15644
|
-
function commandPaths(command, prefix = command.name()) {
|
|
15645
|
-
const children = command.commands.filter((child) => !child.name().startsWith("help"));
|
|
15646
|
-
if (children.length === 0) {
|
|
15647
|
-
return [prefix];
|
|
15648
|
-
}
|
|
15649
|
-
return children.flatMap((child) => commandPaths(child, `${prefix} ${child.name()}`));
|
|
15650
|
-
}
|
|
15651
16283
|
function commandSummary(command) {
|
|
15652
16284
|
return {
|
|
15653
16285
|
name: command.name(),
|
|
@@ -15892,12 +16524,16 @@ function registerDiscoveryCommands(program) {
|
|
|
15892
16524
|
});
|
|
15893
16525
|
const api = program.command("api").description("Discover Wave API-backed CLI operations");
|
|
15894
16526
|
api.command("ls").description("List scriptable command paths").option("--readable", "Print command paths as plain lines").option("--json", "Emit the stable JSON envelope").action((opts) => {
|
|
15895
|
-
const
|
|
16527
|
+
const manifest = buildOperationManifest(program);
|
|
16528
|
+
const paths = manifest.operations.map((operation) => operation.command);
|
|
15896
16529
|
if (opts.readable && !opts.json) {
|
|
15897
16530
|
return printTextAndExit({ text: paths.join("\n") });
|
|
15898
16531
|
}
|
|
15899
16532
|
return printEnvelopeAndExit({
|
|
15900
16533
|
envelope: buildEnvelope2("api.ls", {
|
|
16534
|
+
...manifest,
|
|
16535
|
+
// Retained as a derived compatibility projection for existing CLI
|
|
16536
|
+
// callers. The manifest above is the sole inventory source.
|
|
15901
16537
|
commands: paths,
|
|
15902
16538
|
examples: ["wave api ls --json"]
|
|
15903
16539
|
})
|
|
@@ -15994,9 +16630,6 @@ function attachDiscoveryHelp(program) {
|
|
|
15994
16630
|
}
|
|
15995
16631
|
}
|
|
15996
16632
|
|
|
15997
|
-
// src/version.ts
|
|
15998
|
-
var CLI_VERSION = "0.1.66";
|
|
15999
|
-
|
|
16000
16633
|
// src/cli.ts
|
|
16001
16634
|
function buildCli(options) {
|
|
16002
16635
|
const program = new Command();
|
|
@@ -16005,7 +16638,7 @@ function buildCli(options) {
|
|
|
16005
16638
|
"Read auth/runtime context JSON from stdin (token, baseUrl, tracing fields, ...)"
|
|
16006
16639
|
).option(
|
|
16007
16640
|
"--base-url <baseUrl>",
|
|
16008
|
-
"API base URL (
|
|
16641
|
+
"API base URL (defaults to production; WAVE_API_BASE_URL overrides it)"
|
|
16009
16642
|
).option(
|
|
16010
16643
|
"--organization-id <organizationId>",
|
|
16011
16644
|
"Explicit organization ID override"
|
|
@@ -16078,6 +16711,371 @@ function buildCli(options) {
|
|
|
16078
16711
|
return program;
|
|
16079
16712
|
}
|
|
16080
16713
|
|
|
16714
|
+
// src/machine.ts
|
|
16715
|
+
import { createHash as createHash2 } from "crypto";
|
|
16716
|
+
var MACHINE_FLAGS = /* @__PURE__ */ new Set([
|
|
16717
|
+
"--machine",
|
|
16718
|
+
"--operation",
|
|
16719
|
+
"--phase",
|
|
16720
|
+
"--input-json"
|
|
16721
|
+
]);
|
|
16722
|
+
function machineEnvelope(params) {
|
|
16723
|
+
return {
|
|
16724
|
+
ok: params.ok,
|
|
16725
|
+
command: params.command,
|
|
16726
|
+
status: params.status,
|
|
16727
|
+
data: params.data ?? null,
|
|
16728
|
+
error: params.error ?? null,
|
|
16729
|
+
meta: { requestId: "machine" }
|
|
16730
|
+
};
|
|
16731
|
+
}
|
|
16732
|
+
function isPlainObject(value) {
|
|
16733
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
16734
|
+
}
|
|
16735
|
+
function hasAction2(command) {
|
|
16736
|
+
return Boolean(command._actionHandler);
|
|
16737
|
+
}
|
|
16738
|
+
function commandId(command) {
|
|
16739
|
+
const path = [];
|
|
16740
|
+
let current = command;
|
|
16741
|
+
while (current) {
|
|
16742
|
+
if (current.name()) path.unshift(current.name());
|
|
16743
|
+
current = current.parent;
|
|
16744
|
+
}
|
|
16745
|
+
return path.slice(1).join(".");
|
|
16746
|
+
}
|
|
16747
|
+
function parseMachineArgs(argv) {
|
|
16748
|
+
const values = {};
|
|
16749
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
16750
|
+
const flag = argv[index];
|
|
16751
|
+
if (!MACHINE_FLAGS.has(flag)) {
|
|
16752
|
+
return { error: `Unsupported machine flag: ${flag}` };
|
|
16753
|
+
}
|
|
16754
|
+
const value = argv[index + 1];
|
|
16755
|
+
if (!value || value.startsWith("--")) {
|
|
16756
|
+
return { error: `Missing value for ${flag}` };
|
|
16757
|
+
}
|
|
16758
|
+
if (flag in values) return { error: `Machine flag may be supplied only once: ${flag}` };
|
|
16759
|
+
values[flag] = value;
|
|
16760
|
+
index += 1;
|
|
16761
|
+
}
|
|
16762
|
+
if (values["--machine"] !== "execute") {
|
|
16763
|
+
return { error: '--machine must be "execute".' };
|
|
16764
|
+
}
|
|
16765
|
+
return {
|
|
16766
|
+
operation: values["--operation"],
|
|
16767
|
+
phase: values["--phase"],
|
|
16768
|
+
inputJson: values["--input-json"]
|
|
16769
|
+
};
|
|
16770
|
+
}
|
|
16771
|
+
async function readMachineInput(location) {
|
|
16772
|
+
if (location !== "-") {
|
|
16773
|
+
throw new Error('Machine input must be supplied with "--input-json -".');
|
|
16774
|
+
}
|
|
16775
|
+
let raw = "";
|
|
16776
|
+
process.stdin.setEncoding("utf8");
|
|
16777
|
+
for await (const chunk of process.stdin) raw += chunk;
|
|
16778
|
+
if (!raw.trim()) throw new Error("Machine input JSON is required.");
|
|
16779
|
+
const parsed = JSON.parse(raw);
|
|
16780
|
+
if (!isPlainObject(parsed)) throw new Error("Machine input must be a JSON object.");
|
|
16781
|
+
return parsed;
|
|
16782
|
+
}
|
|
16783
|
+
function inputDigest(input) {
|
|
16784
|
+
return `sha256:${createHash2("sha256").update(canonicalJson(input)).digest("hex")}`;
|
|
16785
|
+
}
|
|
16786
|
+
function canonicalJson(value) {
|
|
16787
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
16788
|
+
if (isPlainObject(value)) {
|
|
16789
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
|
|
16790
|
+
}
|
|
16791
|
+
return JSON.stringify(value);
|
|
16792
|
+
}
|
|
16793
|
+
function normalizeInput(input) {
|
|
16794
|
+
return Object.fromEntries(
|
|
16795
|
+
Object.keys(input).sort().map((key) => [key, input[key]])
|
|
16796
|
+
);
|
|
16797
|
+
}
|
|
16798
|
+
function parseTrustedJson(name, predicate) {
|
|
16799
|
+
const raw = process.env[name];
|
|
16800
|
+
if (!raw) return null;
|
|
16801
|
+
try {
|
|
16802
|
+
const parsed = JSON.parse(raw);
|
|
16803
|
+
return predicate(parsed) ? parsed : null;
|
|
16804
|
+
} catch {
|
|
16805
|
+
return null;
|
|
16806
|
+
}
|
|
16807
|
+
}
|
|
16808
|
+
function isTrustedAuth(value) {
|
|
16809
|
+
return isPlainObject(value) && typeof value.token === "string" && value.token.trim() !== "" && typeof value.baseUrl === "string" && value.baseUrl.trim() !== "" && typeof value.organizationId === "string" && value.organizationId.trim() !== "" && typeof value.actorId === "string" && value.actorId.trim() !== "";
|
|
16810
|
+
}
|
|
16811
|
+
function isTrustedApproval(value) {
|
|
16812
|
+
return isPlainObject(value) && typeof value.operation === "string" && typeof value.inputDigest === "string" && typeof value.cliVersion === "string" && typeof value.registryDigest === "string" && typeof value.organizationId === "string" && value.organizationId.trim() !== "" && typeof value.actorId === "string" && value.actorId.trim() !== "";
|
|
16813
|
+
}
|
|
16814
|
+
function operationCommand(program, id) {
|
|
16815
|
+
return listInvocableCommands(program).find((command) => commandId(command) === id);
|
|
16816
|
+
}
|
|
16817
|
+
function typeMatches(value, type) {
|
|
16818
|
+
if (type === "array") return Array.isArray(value);
|
|
16819
|
+
if (type === "null") return value === null;
|
|
16820
|
+
if (type === "object") return isPlainObject(value);
|
|
16821
|
+
return typeof value === type;
|
|
16822
|
+
}
|
|
16823
|
+
function validateInput(operation, input) {
|
|
16824
|
+
const allowed = new Set(Object.keys(operation.inputSchema.properties));
|
|
16825
|
+
const unknown = Object.keys(input).filter((key) => !allowed.has(key));
|
|
16826
|
+
const missing = operation.inputSchema.required.filter(
|
|
16827
|
+
(key) => input[key] === void 0 || input[key] === null || input[key] === ""
|
|
16828
|
+
);
|
|
16829
|
+
const typeErrors = Object.entries(input).flatMap(([key, value]) => {
|
|
16830
|
+
const property = operation.inputSchema.properties[key];
|
|
16831
|
+
if (!property) return [];
|
|
16832
|
+
const types = Array.isArray(property.type) ? property.type : [property.type];
|
|
16833
|
+
return types.some((type) => typeMatches(value, type)) ? [] : [`Invalid input type for ${key}: expected ${types.join(" or ")}.`];
|
|
16834
|
+
});
|
|
16835
|
+
return [
|
|
16836
|
+
...unknown.map((key) => `Unknown input property: ${key}`),
|
|
16837
|
+
...missing.map((key) => `Missing required input property: ${key}`),
|
|
16838
|
+
...typeErrors
|
|
16839
|
+
];
|
|
16840
|
+
}
|
|
16841
|
+
function optionValue(value) {
|
|
16842
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
16843
|
+
}
|
|
16844
|
+
function commandArgs(command, input) {
|
|
16845
|
+
const path = [];
|
|
16846
|
+
let current = command;
|
|
16847
|
+
while (current) {
|
|
16848
|
+
if (current.name()) path.unshift(current.name());
|
|
16849
|
+
current = current.parent;
|
|
16850
|
+
}
|
|
16851
|
+
const args = path.slice(1);
|
|
16852
|
+
for (const argument of command.registeredArguments) {
|
|
16853
|
+
const key = argument.name().replace(/<|>|\[|\]|\.\.\./g, "");
|
|
16854
|
+
const value = input[key];
|
|
16855
|
+
if (value === void 0) continue;
|
|
16856
|
+
if (Array.isArray(value)) args.push(...value.map(optionValue));
|
|
16857
|
+
else args.push(optionValue(value));
|
|
16858
|
+
}
|
|
16859
|
+
for (const option of command.options) {
|
|
16860
|
+
const key = option.attributeName();
|
|
16861
|
+
const value = input[key];
|
|
16862
|
+
if (value === void 0 || value === false) continue;
|
|
16863
|
+
const long = option.long;
|
|
16864
|
+
if (!long) continue;
|
|
16865
|
+
if (value === true) args.push(long);
|
|
16866
|
+
else args.push(long, optionValue(value));
|
|
16867
|
+
}
|
|
16868
|
+
return args;
|
|
16869
|
+
}
|
|
16870
|
+
function withTrustedMachineAuth(auth, callback) {
|
|
16871
|
+
const previousWaveEnvironment = Object.fromEntries(
|
|
16872
|
+
Object.entries(process.env).filter(([key]) => key.startsWith("WAVE_"))
|
|
16873
|
+
);
|
|
16874
|
+
for (const key of Object.keys(process.env)) {
|
|
16875
|
+
if (key.startsWith("WAVE_")) delete process.env[key];
|
|
16876
|
+
}
|
|
16877
|
+
if (auth) {
|
|
16878
|
+
process.env.WAVE_API_TOKEN = auth.token;
|
|
16879
|
+
process.env.WAVE_API_BASE_URL = auth.baseUrl;
|
|
16880
|
+
}
|
|
16881
|
+
process.env.WAVE_CLI_AUTH_STORAGE = "disabled";
|
|
16882
|
+
process.env.WAVE_CLI_HOME = "/dev/null";
|
|
16883
|
+
return callback().finally(() => {
|
|
16884
|
+
for (const key of Object.keys(process.env)) {
|
|
16885
|
+
if (key.startsWith("WAVE_")) delete process.env[key];
|
|
16886
|
+
}
|
|
16887
|
+
Object.assign(process.env, previousWaveEnvironment);
|
|
16888
|
+
});
|
|
16889
|
+
}
|
|
16890
|
+
function needsTrustedAuth(operation) {
|
|
16891
|
+
return operation.classification === "read" || operation.classification === "write" || operation.classification === "auth";
|
|
16892
|
+
}
|
|
16893
|
+
function resolveMachineOperation(program, id) {
|
|
16894
|
+
const manifest = buildOperationManifest(program);
|
|
16895
|
+
const operation = manifest.operations.find((candidate) => candidate.id === id);
|
|
16896
|
+
const command = operation ? operationCommand(program, id) : void 0;
|
|
16897
|
+
return operation && command && hasAction2(command) ? { operation, command } : null;
|
|
16898
|
+
}
|
|
16899
|
+
async function maybeRunMachineExecute(argv, program) {
|
|
16900
|
+
if (argv[0] !== "--machine") return false;
|
|
16901
|
+
const parsed = parseMachineArgs(argv);
|
|
16902
|
+
if (parsed.error || !parsed.operation || !parsed.phase) {
|
|
16903
|
+
return printEnvelopeAndExit({
|
|
16904
|
+
envelope: machineEnvelope({
|
|
16905
|
+
ok: false,
|
|
16906
|
+
status: 400,
|
|
16907
|
+
command: "machine.execute",
|
|
16908
|
+
error: { code: "invalid_args", message: parsed.error ?? "operation and phase are required." }
|
|
16909
|
+
}),
|
|
16910
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
16911
|
+
});
|
|
16912
|
+
}
|
|
16913
|
+
if (!["validate", "preview", "execute"].includes(parsed.phase)) {
|
|
16914
|
+
return printEnvelopeAndExit({
|
|
16915
|
+
envelope: machineEnvelope({
|
|
16916
|
+
ok: false,
|
|
16917
|
+
status: 400,
|
|
16918
|
+
command: "machine.execute",
|
|
16919
|
+
error: { code: "invalid_phase", message: `Unsupported machine phase: ${parsed.phase}` }
|
|
16920
|
+
}),
|
|
16921
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
16922
|
+
});
|
|
16923
|
+
}
|
|
16924
|
+
let input;
|
|
16925
|
+
try {
|
|
16926
|
+
input = await readMachineInput(parsed.inputJson);
|
|
16927
|
+
} catch (error) {
|
|
16928
|
+
return printEnvelopeAndExit({
|
|
16929
|
+
envelope: machineEnvelope({
|
|
16930
|
+
ok: false,
|
|
16931
|
+
status: 400,
|
|
16932
|
+
command: "machine.execute",
|
|
16933
|
+
error: { code: "invalid_input", message: error instanceof Error ? error.message : "Invalid machine input." }
|
|
16934
|
+
}),
|
|
16935
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
16936
|
+
});
|
|
16937
|
+
}
|
|
16938
|
+
const resolved = resolveMachineOperation(program, parsed.operation);
|
|
16939
|
+
if (!resolved) {
|
|
16940
|
+
return printEnvelopeAndExit({
|
|
16941
|
+
envelope: machineEnvelope({
|
|
16942
|
+
ok: false,
|
|
16943
|
+
status: 404,
|
|
16944
|
+
command: "machine.execute",
|
|
16945
|
+
error: { code: "unknown_operation", message: `Unknown operation: ${parsed.operation}` }
|
|
16946
|
+
}),
|
|
16947
|
+
exitCode: EXIT_CODES.notFound
|
|
16948
|
+
});
|
|
16949
|
+
}
|
|
16950
|
+
const normalizedInput = normalizeInput(input);
|
|
16951
|
+
const errors = validateInput(resolved.operation, normalizedInput);
|
|
16952
|
+
const digest = inputDigest(normalizedInput);
|
|
16953
|
+
if (errors.length > 0) {
|
|
16954
|
+
return printEnvelopeAndExit({
|
|
16955
|
+
envelope: machineEnvelope({
|
|
16956
|
+
ok: false,
|
|
16957
|
+
status: 400,
|
|
16958
|
+
command: "machine.execute",
|
|
16959
|
+
error: { code: "invalid_input", message: "Machine input did not match the operation schema.", details: { errors } },
|
|
16960
|
+
data: {
|
|
16961
|
+
operation: resolved.operation.id,
|
|
16962
|
+
normalizedInput,
|
|
16963
|
+
inputDigest: digest
|
|
16964
|
+
}
|
|
16965
|
+
}),
|
|
16966
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
16967
|
+
});
|
|
16968
|
+
}
|
|
16969
|
+
const manifest = buildOperationManifest(program);
|
|
16970
|
+
if (parsed.phase === "validate") {
|
|
16971
|
+
return printEnvelopeAndExit({
|
|
16972
|
+
envelope: machineEnvelope({
|
|
16973
|
+
ok: true,
|
|
16974
|
+
status: 200,
|
|
16975
|
+
command: "machine.execute",
|
|
16976
|
+
data: {
|
|
16977
|
+
status: "validated",
|
|
16978
|
+
operation: resolved.operation.id,
|
|
16979
|
+
normalizedInput,
|
|
16980
|
+
inputDigest: digest,
|
|
16981
|
+
cliVersion: manifest.cli.version,
|
|
16982
|
+
registryDigest: manifest.registryDigest
|
|
16983
|
+
}
|
|
16984
|
+
})
|
|
16985
|
+
});
|
|
16986
|
+
}
|
|
16987
|
+
if (parsed.phase === "preview") {
|
|
16988
|
+
if (resolved.operation.classification !== "write") {
|
|
16989
|
+
return printEnvelopeAndExit({
|
|
16990
|
+
envelope: machineEnvelope({
|
|
16991
|
+
ok: false,
|
|
16992
|
+
status: 400,
|
|
16993
|
+
command: "machine.execute",
|
|
16994
|
+
error: { code: "preview_not_supported", message: `${resolved.operation.id} is not a write operation.` }
|
|
16995
|
+
}),
|
|
16996
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
16997
|
+
});
|
|
16998
|
+
}
|
|
16999
|
+
return printEnvelopeAndExit({
|
|
17000
|
+
envelope: machineEnvelope({
|
|
17001
|
+
ok: true,
|
|
17002
|
+
status: 200,
|
|
17003
|
+
command: "machine.execute",
|
|
17004
|
+
data: {
|
|
17005
|
+
status: "preview",
|
|
17006
|
+
operation: resolved.operation.id,
|
|
17007
|
+
normalizedInput,
|
|
17008
|
+
preview: {
|
|
17009
|
+
title: resolved.operation.summary,
|
|
17010
|
+
command: resolved.operation.command,
|
|
17011
|
+
requestedInput: normalizedInput,
|
|
17012
|
+
summary: `Execute ${resolved.operation.command} with the validated input.`
|
|
17013
|
+
},
|
|
17014
|
+
inputDigest: digest,
|
|
17015
|
+
cliVersion: manifest.cli.version,
|
|
17016
|
+
registryDigest: manifest.registryDigest
|
|
17017
|
+
}
|
|
17018
|
+
})
|
|
17019
|
+
});
|
|
17020
|
+
}
|
|
17021
|
+
if (resolved.operation.classification === "auth") {
|
|
17022
|
+
return printEnvelopeAndExit({
|
|
17023
|
+
envelope: machineEnvelope({
|
|
17024
|
+
ok: true,
|
|
17025
|
+
status: 202,
|
|
17026
|
+
command: "machine.execute",
|
|
17027
|
+
data: {
|
|
17028
|
+
status: "continuation_required",
|
|
17029
|
+
operation: resolved.operation.id,
|
|
17030
|
+
message: "Interactive authentication is not run in machine mode. Continue through the MCP OAuth flow."
|
|
17031
|
+
}
|
|
17032
|
+
})
|
|
17033
|
+
});
|
|
17034
|
+
}
|
|
17035
|
+
const auth = parseTrustedJson("WAVE_MACHINE_AUTH_JSON", isTrustedAuth);
|
|
17036
|
+
if (needsTrustedAuth(resolved.operation) && !auth) {
|
|
17037
|
+
return printEnvelopeAndExit({
|
|
17038
|
+
envelope: machineEnvelope({
|
|
17039
|
+
ok: false,
|
|
17040
|
+
status: 401,
|
|
17041
|
+
command: "machine.execute",
|
|
17042
|
+
error: {
|
|
17043
|
+
code: "missing_machine_auth",
|
|
17044
|
+
message: "Machine execution requires trusted OAuth-bound auth context."
|
|
17045
|
+
}
|
|
17046
|
+
}),
|
|
17047
|
+
exitCode: EXIT_CODES.missingOrInvalidAuth
|
|
17048
|
+
});
|
|
17049
|
+
}
|
|
17050
|
+
if (resolved.operation.classification === "write") {
|
|
17051
|
+
const approval = parseTrustedJson("WAVE_MACHINE_APPROVAL_JSON", isTrustedApproval);
|
|
17052
|
+
if (!approval || approval.operation !== resolved.operation.id || approval.inputDigest !== digest || approval.cliVersion !== manifest.cli.version || approval.registryDigest !== manifest.registryDigest || approval.organizationId !== auth?.organizationId || approval.actorId !== auth?.actorId) {
|
|
17053
|
+
return printEnvelopeAndExit({
|
|
17054
|
+
envelope: machineEnvelope({
|
|
17055
|
+
ok: false,
|
|
17056
|
+
status: 403,
|
|
17057
|
+
command: "machine.execute",
|
|
17058
|
+
error: {
|
|
17059
|
+
code: "approval_required",
|
|
17060
|
+
message: "A matching server-managed approval is required before write execution.",
|
|
17061
|
+
details: { operation: resolved.operation.id, inputDigest: digest }
|
|
17062
|
+
}
|
|
17063
|
+
}),
|
|
17064
|
+
exitCode: EXIT_CODES.forbidden
|
|
17065
|
+
});
|
|
17066
|
+
}
|
|
17067
|
+
}
|
|
17068
|
+
try {
|
|
17069
|
+
await withTrustedMachineAuth(auth, async () => {
|
|
17070
|
+
await program.parseAsync([process.execPath, "wave", ...commandArgs(resolved.command, normalizedInput)]);
|
|
17071
|
+
});
|
|
17072
|
+
} catch (error) {
|
|
17073
|
+
if (isEnvelopeEmittedSignal(error)) return true;
|
|
17074
|
+
throw error;
|
|
17075
|
+
}
|
|
17076
|
+
return true;
|
|
17077
|
+
}
|
|
17078
|
+
|
|
16081
17079
|
// src/index.ts
|
|
16082
17080
|
function printCliFailure(params) {
|
|
16083
17081
|
printEnvelope({
|
|
@@ -16099,6 +17097,7 @@ function printCliFailure(params) {
|
|
|
16099
17097
|
}
|
|
16100
17098
|
async function main() {
|
|
16101
17099
|
const program = buildCli();
|
|
17100
|
+
if (await maybeRunMachineExecute(process.argv.slice(2), program)) return;
|
|
16102
17101
|
await program.parseAsync(process.argv);
|
|
16103
17102
|
}
|
|
16104
17103
|
main().catch((error) => {
|