@wayai/cli 0.3.207 → 0.3.209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -15031,6 +15031,47 @@ var init_expected = __esm({
15031
15031
  }
15032
15032
  });
15033
15033
 
15034
+ // src/lib/report-edit-args.ts
15035
+ function parseReportEditArgs(args2) {
15036
+ const patch = {};
15037
+ let reportId;
15038
+ for (let i = 0; i < args2.length; i++) {
15039
+ const arg = args2[i];
15040
+ const key = FLAG_TO_KEY[arg];
15041
+ if (key) {
15042
+ const value = args2[i + 1];
15043
+ if (value === void 0) {
15044
+ return { reportId, patch, error: `${arg} requires a value` };
15045
+ }
15046
+ patch[key] = value;
15047
+ i++;
15048
+ } else if (arg.startsWith("-")) {
15049
+ return { reportId, patch, error: `Unknown flag: ${arg}` };
15050
+ } else if (reportId === void 0) {
15051
+ reportId = arg;
15052
+ }
15053
+ }
15054
+ return { reportId, patch };
15055
+ }
15056
+ var FLAG_TO_KEY, REPORT_EDIT_FLAGS;
15057
+ var init_report_edit_args = __esm({
15058
+ "src/lib/report-edit-args.ts"() {
15059
+ "use strict";
15060
+ FLAG_TO_KEY = {
15061
+ "-t": "title",
15062
+ "--title": "title",
15063
+ "-d": "description",
15064
+ "--description": "description",
15065
+ "-e": "error_message",
15066
+ "--error": "error_message",
15067
+ "-s": "steps_to_reproduce",
15068
+ "--steps": "steps_to_reproduce",
15069
+ "--context": "additional_context"
15070
+ };
15071
+ REPORT_EDIT_FLAGS = Object.keys(FLAG_TO_KEY);
15072
+ }
15073
+ });
15074
+
15034
15075
  // src/lib/terminal-output.ts
15035
15076
  import { stripVTControlCharacters } from "util";
15036
15077
  function sanitizeTerminalText(value) {
@@ -16102,34 +16143,73 @@ function shouldInterceptHelp(command2, args2, ownHelpCommands) {
16102
16143
  function isDryRunToken(arg) {
16103
16144
  return /^--dry-run(=\S*)?$/.test(arg);
16104
16145
  }
16146
+ function unreadRefusal(invocation, token, why) {
16147
+ const shown2 = token === "" ? '""' : sanitizeTerminalText(token);
16148
+ return `\`${invocation}\` does not read \`${shown2}\`${why}, so it is refused rather than run without it.`;
16149
+ }
16105
16150
  function unreadDryRunRefusal(invocation, token, readsBare) {
16106
- const only = readsBare ? " (only a bare `--dry-run`)" : "";
16107
- return `\`${invocation}\` does not read \`${sanitizeTerminalText(token)}\`${only}, so it is refused rather than run without it.`;
16151
+ return unreadRefusal(invocation, token, readsBare ? " (only a bare `--dry-run`)" : "");
16152
+ }
16153
+ function noValueRefusal(invocation, flag) {
16154
+ return `\`${invocation} ${flag}\` needs ${FLAG_TARGETS[flag] ?? "a value"}, and none followed it.`;
16155
+ }
16156
+ function positionalCount(n) {
16157
+ return n === 0 ? "no positional argument" : n === 1 ? "one positional argument" : `${n} positional arguments`;
16158
+ }
16159
+ function unreadArgumentRefusal(invocation, args2, reads, splitsAtFirstLongFlag) {
16160
+ const takesValue = (flag) => reads.values?.includes(flag) === true;
16161
+ const missing = (value) => value === void 0 || FLAG_SHAPED.test(value) || value === "" && reads.readsEmpty !== true;
16162
+ const takes = ` (it takes ${positionalCount(reads.positionals)})`;
16163
+ const firstLongFlag = args2.findIndex((arg) => arg.startsWith("--"));
16164
+ const flagsFrom = !splitsAtFirstLongFlag ? 0 : firstLongFlag === -1 ? args2.length : firstLongFlag;
16165
+ let positionals = 0;
16166
+ for (let i = 0; i < args2.length; i++) {
16167
+ const arg = args2[i];
16168
+ if (i < flagsFrom) {
16169
+ if (++positionals > reads.positionals) return unreadRefusal(invocation, arg, takes);
16170
+ continue;
16171
+ }
16172
+ const spelled = EQUALS_SPELLING.exec(arg);
16173
+ if (spelled) {
16174
+ const [, flag, value] = spelled;
16175
+ if (reads.equals?.includes(flag)) {
16176
+ if (value === "") return noValueRefusal(invocation, flag);
16177
+ } else if (takesValue(flag)) {
16178
+ return value === "" ? noValueRefusal(invocation, flag) : unreadRefusal(invocation, arg, ` (only \`${flag} <value>\`)`);
16179
+ } else {
16180
+ return unreadRefusal(invocation, arg, "");
16181
+ }
16182
+ } else if (takesValue(arg)) {
16183
+ if (missing(args2[i + 1])) return noValueRefusal(invocation, arg);
16184
+ i++;
16185
+ } else if (!arg.startsWith("-")) {
16186
+ if (splitsAtFirstLongFlag) {
16187
+ return unreadRefusal(invocation, arg, " (it reads positionals only before its first `--` flag)");
16188
+ }
16189
+ if (++positionals > reads.positionals) return unreadRefusal(invocation, arg, takes);
16190
+ }
16191
+ }
16192
+ return null;
16108
16193
  }
16109
16194
  function entryFlagRefusal(command2, args2, dataNamespaces) {
16110
- if (command2 === void 0 || ["help", "--help", "-h", "--version", "-v"].includes(command2)) return null;
16195
+ if (command2 === void 0 || HELP_AND_VERSION.includes(command2)) return null;
16111
16196
  if (dataNamespaces.has(command2)) return null;
16112
16197
  const words = [command2];
16113
16198
  for (const arg of args2.slice(0, 2)) {
16114
16199
  if (!/^[a-z][a-z-]*$/.test(arg)) break;
16115
16200
  words.push(arg);
16116
16201
  }
16117
- const invocation = `wayai ${words.join(" ")}`;
16118
- let parsed;
16119
- for (let n = words.length; n > 0 && parsed === void 0; n--) {
16120
- parsed = PARSED_BY_THE_COMMAND.get(words.slice(0, n).join(" "));
16121
- }
16122
- if (parsed === "all") return null;
16202
+ let named = words.length;
16203
+ let reads = PARSER_READS.get(words.join(" "));
16204
+ while (reads === void 0 && --named > 0) reads = PARSER_READS.get(words.slice(0, named).join(" "));
16205
+ const invocation = `wayai ${words.slice(0, named || words.length).join(" ")}`;
16206
+ if (reads === "all") return null;
16123
16207
  const dryRuns = args2.filter(isDryRunToken);
16124
- const readsBare = parsed === "bare --dry-run";
16208
+ const readsBare = typeof reads === "object" && reads.dryRun === true;
16125
16209
  const refused = readsBare ? dryRuns.find((token) => token !== "--dry-run") : dryRuns[0];
16126
16210
  if (refused !== void 0) return unreadDryRunRefusal(invocation, refused, readsBare);
16127
- if (parsed === "selectors") return null;
16128
- for (const { flag, noun } of SELECTOR_FLAGS) {
16129
- const empty = args2.some((arg, i) => arg === `${flag}=` || arg === flag && (args2[i + 1] ?? "") === "");
16130
- if (empty) return `\`${invocation} ${flag}\` needs ${noun}, and none followed it.`;
16131
- }
16132
- return null;
16211
+ if (reads === void 0 || reads === "selectors") return null;
16212
+ return unreadArgumentRefusal(invocation, args2.slice(named - 1), reads, SPLITS_AT_FIRST_LONG_FLAG.has(command2));
16133
16213
  }
16134
16214
  function isNewerVersion(latest, current) {
16135
16215
  const strip = (v) => v.replace(/[-+].*$/, "");
@@ -16162,12 +16242,13 @@ function resolveSecretSource(source) {
16162
16242
  }
16163
16243
  return "prompt";
16164
16244
  }
16165
- var UUID_RE3, slugify2, OWN_HELP_COMMANDS, PARSED_BY_THE_COMMAND, SELECTOR_FLAGS;
16245
+ var UUID_RE3, slugify2, OWN_HELP_COMMANDS, HELP_AND_VERSION, PARSER_READS, SPLITS_AT_FIRST_LONG_FLAG, FLAG_TARGETS, EQUALS_SPELLING, FLAG_SHAPED;
16166
16246
  var init_utils = __esm({
16167
16247
  "src/lib/utils.ts"() {
16168
16248
  "use strict";
16169
16249
  init_dist();
16170
16250
  init_expected();
16251
+ init_report_edit_args();
16171
16252
  init_terminal_output();
16172
16253
  UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16173
16254
  slugify2 = slugifySkillName;
@@ -16179,23 +16260,168 @@ var init_utils = __esm({
16179
16260
  "alerts",
16180
16261
  "communities"
16181
16262
  ]);
16182
- PARSED_BY_THE_COMMAND = /* @__PURE__ */ new Map([
16263
+ HELP_AND_VERSION = ["help", "--help", "-h", "--version", "-v"];
16264
+ PARSER_READS = /* @__PURE__ */ new Map([
16183
16265
  ["pull", "all"],
16184
16266
  ["push", "all"],
16185
16267
  ["communities", "all"],
16186
- ["sync-mcp", "bare --dry-run"],
16187
- ["admin hubs repair-team-orphans", "bare --dry-run"],
16188
- ["admin hubs repair-branching-orphans", "bare --dry-run"],
16189
- ["admin orgs repair-legacy-grants", "bare --dry-run"],
16190
- ["admin harness mass-destroy", "bare --dry-run"],
16191
16268
  ["use", "selectors"],
16192
16269
  ["unbind", "selectors"],
16193
- ["unlock", "selectors"]
16270
+ ["unlock", "selectors"],
16271
+ ["login", { positionals: 0, values: ["--api-url"] }],
16272
+ ["logout", { positionals: 0 }],
16273
+ ["status", { positionals: 0 }],
16274
+ ["whoami", { positionals: 0 }],
16275
+ ["init", { positionals: 0, values: ["--org"] }],
16276
+ ["create", { positionals: 1, values: ["--label"] }],
16277
+ ["diff", { positionals: 0, values: ["--hub"] }],
16278
+ ["replicate", { positionals: 1, values: ["--label", "--hub"] }],
16279
+ ["relabel", { positionals: 1, values: ["--hub"] }],
16280
+ ["publish", { positionals: 0, values: ["--hub"] }],
16281
+ ["sync", { positionals: 0, values: ["--hub"] }],
16282
+ ["migrate", { positionals: 0 }],
16283
+ ["send-message", { positionals: 1, values: ["--hub", "-c", "--conversation", "-f", "--file"] }],
16284
+ [
16285
+ "conversations",
16286
+ {
16287
+ positionals: 2,
16288
+ values: ["--hub", "--org", "--status", "--limit", "--offset", "--message-id", "--period", "--from", "--to", "--set", "--type"],
16289
+ equals: ["--org"]
16290
+ }
16291
+ ],
16292
+ ["alerts", { positionals: 0, values: ["--hub"] }],
16293
+ [
16294
+ "delete-history",
16295
+ { positionals: 0, values: ["--hub", "--user-id", "--conversation-id"], equals: ["--user-id", "--conversation-id"] }
16296
+ ],
16297
+ ["sync-skills", { positionals: 0, values: ["--hub", "--connection-id"] }],
16298
+ ["sync-mcp", { positionals: 0, values: ["--hub", "--connection"], dryRun: true }],
16299
+ ["evals", { positionals: 0, values: ["--hub"] }],
16300
+ ["evals sql", { positionals: 1, values: ["--hub", "--limit"] }],
16301
+ ["run-eval", { positionals: 0, values: ["--hub", "--timeout", "--set", "--eval", "--runs", "--pacing", "--fixture"] }],
16302
+ ["eval-results", { positionals: 0, values: ["--hub", "--session", "--eval"] }],
16303
+ [
16304
+ "eval call",
16305
+ {
16306
+ positionals: 0,
16307
+ values: [
16308
+ "--hub",
16309
+ "--journey",
16310
+ "--runs",
16311
+ "--plan",
16312
+ "--clips",
16313
+ "--tts-voice",
16314
+ "--tts-model",
16315
+ "--max-call-seconds",
16316
+ "--max-operations",
16317
+ "--usd-per-minute",
16318
+ "--max-usd",
16319
+ "--latency-p95-ms",
16320
+ "--json"
16321
+ ]
16322
+ }
16323
+ ],
16324
+ ["eval capture", { positionals: 1, values: ["--hub", "--set", "--name", "--instructions"] }],
16325
+ ["eval journey capture", { positionals: 1, values: ["--hub", "--name", "--instructions"] }],
16326
+ ["eval session stop", { positionals: 1, values: ["--hub"] }],
16327
+ ["eval session delete", { positionals: 1, values: ["--hub"] }],
16328
+ ["analytics", { positionals: 0, values: ["--hub", "--period", "--from", "--to", "--metric", "--filter"] }],
16329
+ [
16330
+ "analytics query",
16331
+ { positionals: 0, values: ["--hub", "--metric", "--group-by", "--order-by", "--filter", "--from", "--to", "--limit"] }
16332
+ ],
16333
+ ["analytics sql", { positionals: 1, values: ["--hub", "--limit"] }],
16334
+ ["create-credential", { positionals: 0, values: ["--name", "--type", "--org", "--description", "--tag", "--environment"] }],
16335
+ ["update-credential", { positionals: 0, values: ["--name", "--rename", "--org", "--description", "--tag", "--environment"] }],
16336
+ ["set-connection-credential", { positionals: 0, values: ["--hub", "--connection", "--org-credential", "--field"] }],
16337
+ ["org create", { positionals: 1, values: ["--region"] }],
16338
+ ["org pull", { positionals: 0 }],
16339
+ ["org diff", { positionals: 0 }],
16340
+ ["org push", { positionals: 0 }],
16341
+ ["list", { positionals: 0, values: ["--org"] }],
16342
+ [
16343
+ "report create",
16344
+ {
16345
+ positionals: 0,
16346
+ values: [
16347
+ "-t",
16348
+ "--title",
16349
+ "-d",
16350
+ "--description",
16351
+ "--source",
16352
+ "--classification",
16353
+ "--dedup-key",
16354
+ "--hub",
16355
+ "--conversation",
16356
+ "-e",
16357
+ "--error",
16358
+ "-s",
16359
+ "--steps",
16360
+ "--context"
16361
+ ]
16362
+ }
16363
+ ],
16364
+ ["report edit", { positionals: 1, values: REPORT_EDIT_FLAGS, readsEmpty: true }],
16365
+ ["report list", { positionals: 0, values: ["--status"] }],
16366
+ ["report get", { positionals: 1 }],
16367
+ ["report accept", { positionals: 1 }],
16368
+ ["report contest", { positionals: 1, values: ["--reason"] }],
16369
+ ["update", { positionals: 0 }],
16370
+ ["admin archive", { positionals: 2, values: ["--message-id", "--out"] }],
16371
+ ["admin observability", { positionals: 2, values: ["--message-id"] }],
16372
+ ["admin do tables", { positionals: 2 }],
16373
+ ["admin do read", { positionals: 3, values: ["--limit", "--id"] }],
16374
+ ["admin analytics tables", { positionals: 0 }],
16375
+ ["admin analytics read", { positionals: 1, values: ["--limit", "--conversation-id", "--hub-id", "--message-id"] }],
16376
+ ["admin report list", { positionals: 0, values: ["--status", "--source", "--limit", "--offset", "--since", "--resolved-since"] }],
16377
+ ["admin report show", { positionals: 1 }],
16378
+ ["admin report group", { positionals: Infinity }],
16379
+ ["admin report ungroup", { positionals: 1 }],
16380
+ ["admin report escalate", { positionals: 1, values: ["--gh", "--verdict"] }],
16381
+ ["admin report shipped", { positionals: 1, values: ["--note"] }],
16382
+ ["admin report addressed", { positionals: 1 }],
16383
+ ["admin report dismiss", { positionals: 1, values: ["--reason", "--verdict"] }],
16384
+ ["admin report hold", { positionals: 1, values: ["--reason"] }],
16385
+ ["admin report update", { positionals: 1, values: REPORT_EDIT_FLAGS, readsEmpty: true }],
16386
+ ["admin people list", { positionals: 0, values: ["--since", "--limit", "--offset"] }],
16387
+ ["admin people show", { positionals: 1 }],
16388
+ ["admin people dismiss", { positionals: 1, values: ["--note"] }],
16389
+ ["admin people remove-message", { positionals: 1, values: ["--message", "--note"] }],
16390
+ ["admin people user", { positionals: 1 }],
16391
+ ["admin people suspend", { positionals: 1, values: ["--report", "--note"] }],
16392
+ ["admin people unsuspend", { positionals: 1, values: ["--note"] }],
16393
+ ["admin notice create", { positionals: 0, values: ["--title", "--severity", "--scope", "--body", "--link", "--starts", "--ends"] }],
16394
+ ["admin notice list", { positionals: 0, values: ["--status", "--limit", "--offset"] }],
16395
+ ["admin notice resolve", { positionals: 1 }],
16396
+ ["admin skill install", { positionals: 1 }],
16397
+ ["admin sandbox exec", { positionals: 1, values: ["--hub", "--connection", "--cmd", "--egress", "--allow", "--timeout"] }],
16398
+ ["admin hubs repair-team-orphans", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
16399
+ ["admin hubs repair-branching-orphans", { positionals: 0, values: ["--org", "--hub", "--id"], dryRun: true }],
16400
+ ["admin orgs repair-legacy-grants", { positionals: 0, values: ["--org"], dryRun: true }],
16401
+ ["admin harness mass-destroy", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
16402
+ ["admin harness disable", { positionals: 0 }],
16403
+ ["admin harness enable", { positionals: 0 }],
16404
+ ["admin harness status", { positionals: 0 }],
16405
+ ["admin threads enable", { positionals: 0 }],
16406
+ ["admin threads disable", { positionals: 0 }],
16407
+ ["admin threads status", { positionals: 0 }],
16408
+ ["admin communities enable", { positionals: 0 }],
16409
+ ["admin communities disable", { positionals: 0 }],
16410
+ ["admin communities status", { positionals: 0 }],
16411
+ ["admin communities create", { positionals: 0, values: ["--org", "--name"] }],
16412
+ ["admin communities destroy", { positionals: 1 }],
16413
+ ["admin guide set-hub", { positionals: 1 }],
16414
+ ["admin guide clear", { positionals: 0 }],
16415
+ ["admin guide status", { positionals: 0 }],
16416
+ ["admin voice-calls enable", { positionals: 0 }],
16417
+ ["admin voice-calls disable", { positionals: 0 }],
16418
+ ["admin voice-calls status", { positionals: 0 }],
16419
+ ["admin voice-calls price", { positionals: 0, values: ["--ops-per-minute"] }]
16194
16420
  ]);
16195
- SELECTOR_FLAGS = [
16196
- { flag: "--hub", noun: "a hub" },
16197
- { flag: "--org", noun: "an organization" }
16198
- ];
16421
+ SPLITS_AT_FIRST_LONG_FLAG = /* @__PURE__ */ new Set(["admin"]);
16422
+ FLAG_TARGETS = { "--hub": "a hub", "--org": "an organization" };
16423
+ EQUALS_SPELLING = /^(--?[A-Za-z][A-Za-z0-9-]*)=([\s\S]*)$/;
16424
+ FLAG_SHAPED = /^-\S*$/;
16199
16425
  }
16200
16426
  });
16201
16427
 
@@ -31773,46 +31999,6 @@ These commands need a browser sign-in (\`wayai login\`). An API token
31773
31999
  }
31774
32000
  });
31775
32001
 
31776
- // src/lib/report-edit-args.ts
31777
- function parseReportEditArgs(args2) {
31778
- const patch = {};
31779
- let reportId;
31780
- for (let i = 0; i < args2.length; i++) {
31781
- const arg = args2[i];
31782
- const key = FLAG_TO_KEY[arg];
31783
- if (key) {
31784
- const value = args2[i + 1];
31785
- if (value === void 0) {
31786
- return { reportId, patch, error: `${arg} requires a value` };
31787
- }
31788
- patch[key] = value;
31789
- i++;
31790
- } else if (arg.startsWith("-")) {
31791
- return { reportId, patch, error: `Unknown flag: ${arg}` };
31792
- } else if (reportId === void 0) {
31793
- reportId = arg;
31794
- }
31795
- }
31796
- return { reportId, patch };
31797
- }
31798
- var FLAG_TO_KEY;
31799
- var init_report_edit_args = __esm({
31800
- "src/lib/report-edit-args.ts"() {
31801
- "use strict";
31802
- FLAG_TO_KEY = {
31803
- "-t": "title",
31804
- "--title": "title",
31805
- "-d": "description",
31806
- "--description": "description",
31807
- "-e": "error_message",
31808
- "--error": "error_message",
31809
- "-s": "steps_to_reproduce",
31810
- "--steps": "steps_to_reproduce",
31811
- "--context": "additional_context"
31812
- };
31813
- }
31814
- });
31815
-
31816
32002
  // src/lib/file-map.ts
31817
32003
  import * as fs28 from "fs";
31818
32004
  import * as path39 from "path";