@wayai/cli 0.3.297 → 0.3.299

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
@@ -38438,16 +38438,40 @@ async function runRepairCredentialLinks(flagArgs) {
38438
38438
  console.log(` hub=${r.hub_id} connection=${r.connection_id} credential=${r.credential_id}: ${r.outcome}${reason}${stale}${written}`);
38439
38439
  }
38440
38440
  }
38441
+ function printCustomerReport(customer, dryRun) {
38442
+ const c = customer.census;
38443
+ const auth = Object.entries(c.by_auth).map(([k, n]) => `${k}=${n}`).join(" ") || "-";
38444
+ console.log(`connections: ${c.connections} (${auth}) http=${c.http} non_default_port=${c.non_default_port} wayai_host=${c.wayai_host} body_placement=${c.body_placement} literal_header_secret=${c.literal_header_secret} secret_url=${c.secret_url}`);
38445
+ console.log(`policies (${customer.policies.length}; old ciphertext kept ${customer.undo_days} days for revert):`);
38446
+ for (const p of customer.policies) {
38447
+ const subject = p.credential_id ? `credential ${p.credential_id}` : p.headers ? `literal header ${p.headers.join(", ")} \u2192` : "value";
38448
+ console.log(` ${subject} ${p.field}${p.spans_hubs ? " (SPANS HUBS)" : ""}: ${p.reasons.length > 0 ? `stays (${p.reasons.join(", ")})` : dryRun ? "would move" : "approved"}`);
38449
+ if (p.policy) {
38450
+ if (p.policy.legacy_origin) console.log(" LEGACY ORIGIN (http or another port, moved as it is)");
38451
+ for (const scope of p.policy.scopes) {
38452
+ const placements = scope.placements.map((pl) => pl.kind === "header" ? `header:${pl.name}` : pl.kind === "query" ? `query:${pl.name}` : pl.kind === "path" ? `path:${pl.after}` : "basic");
38453
+ console.log(` ${scope.origin}${scope.path} (${scope.match}) ${scope.methods.join(",")} [${placements.join(", ")}] headers=${scope.headers.join(",") || "-"}`);
38454
+ }
38455
+ console.log(` policy_hash=${p.policy_hash}`);
38456
+ }
38457
+ for (const r of p.rows) console.log(` hub=${r.hub_id} connection=${r.connection_id}`);
38458
+ }
38459
+ for (const r of customer.stays) console.log(` stays (${r.reason}): ${r.entries}`);
38460
+ if (dryRun && customer.policies.some((p) => p.reasons.length === 0)) {
38461
+ console.log("To move them: save this dry run with --json, review it, then --apply --approved <that file>.");
38462
+ }
38463
+ }
38441
38464
  function printVaultReport(data) {
38442
38465
  if (data.hubs_errored.length > 0) console.log(`WARNING: ${data.hubs_errored.length} hub(s) could not be read and were SKIPPED \u2014 re-run to cover them: ${data.hubs_errored.join(", ")}`);
38443
38466
  if (data.reenable.length === 0) return;
38444
38467
  console.log(`${data.dry_run ? "Would need" : "Need"} their channel enabled again, on the preview hub (${data.reenable.length}):`);
38445
38468
  for (const r of data.reenable) console.log(` hub=${r.hub_id}${r.preview ? " (preview)" : ""} connection=${r.connection_id} bot=${r.bot_username ?? "-"}${r.enabled ? "" : " (disabled)"}`);
38446
38469
  }
38447
- function parseVaultFlags(flagArgs, usage3, allowMaxPuts) {
38470
+ function parseVaultFlags(flagArgs, usage3, importFlags) {
38448
38471
  let orgId;
38449
38472
  let connectorId;
38450
38473
  let maxPuts;
38474
+ let approvedFile;
38451
38475
  let apply = false;
38452
38476
  let yes = false;
38453
38477
  let jsonOutput = false;
@@ -38457,8 +38481,10 @@ function parseVaultFlags(flagArgs, usage3, allowMaxPuts) {
38457
38481
  orgId = requireFlagValue(flagArgs, ++i, "--org");
38458
38482
  } else if (flag === "--connector") {
38459
38483
  connectorId = requireFlagValue(flagArgs, ++i, "--connector");
38460
- } else if (flag === "--max-puts" && allowMaxPuts) {
38484
+ } else if (flag === "--max-puts" && importFlags) {
38461
38485
  maxPuts = parsePositiveIntFlag("--max-puts", flagArgs[++i]);
38486
+ } else if (flag === "--approved" && importFlags) {
38487
+ approvedFile = requireFlagValue(flagArgs, ++i, "--approved");
38462
38488
  } else if (flag === "--apply") {
38463
38489
  apply = true;
38464
38490
  } else if (flag === "--yes" || flag === "-y") {
@@ -38476,11 +38502,28 @@ function parseVaultFlags(flagArgs, usage3, allowMaxPuts) {
38476
38502
  console.error(usage3);
38477
38503
  process.exit(1);
38478
38504
  }
38479
- return { orgId, connectorId, maxPuts, apply, yes, jsonOutput };
38505
+ return { orgId, connectorId, maxPuts, approvedFile, apply, yes, jsonOutput };
38506
+ }
38507
+ function readApprovedPolicies(file) {
38508
+ let parsed;
38509
+ try {
38510
+ parsed = JSON.parse(fs32.readFileSync(file, "utf8"));
38511
+ } catch (err) {
38512
+ console.error(`--approved: cannot read ${file} as a dry run's --json output: ${err instanceof Error ? err.message : String(err)}`);
38513
+ process.exit(1);
38514
+ }
38515
+ const report2 = parsed;
38516
+ const customer = report2.data?.customer ?? report2.customer;
38517
+ if (!customer || !Array.isArray(customer.policies)) {
38518
+ console.error(`--approved: ${file} holds no customer.policies (a REST API, External Resources or MCP Server dry run's --json output)`);
38519
+ process.exit(1);
38520
+ }
38521
+ return customer.policies.flatMap((p) => typeof p.policy_hash === "string" && Array.isArray(p.reasons) && p.reasons.length === 0 ? [p.policy_hash] : []);
38480
38522
  }
38481
38523
  async function runVaultImport(flagArgs) {
38482
- const USAGE8 = "wayai admin vault import --org <org_id> --connector <connector_id> [--max-puts <n>] [--apply] [--yes] [--json]";
38483
- const { orgId, connectorId, maxPuts, apply, yes, jsonOutput } = parseVaultFlags(flagArgs, USAGE8, true);
38524
+ const USAGE8 = "wayai admin vault import --org <org_id> --connector <connector_id> [--max-puts <n>] [--approved <dry-run.json>] [--apply] [--yes] [--json]";
38525
+ const { orgId, connectorId, maxPuts, approvedFile, apply, yes, jsonOutput } = parseVaultFlags(flagArgs, USAGE8, true);
38526
+ const approved = approvedFile ? readApprovedPolicies(approvedFile) : void 0;
38484
38527
  if (apply && !yes && !jsonOutput) {
38485
38528
  console.log(`About to MOVE organization ${orgId}'s credentials of connector ${connectorId} into the credentials vault.`);
38486
38529
  console.log("Run without --apply first to see what would move.");
@@ -38493,7 +38536,13 @@ async function runVaultImport(flagArgs) {
38493
38536
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
38494
38537
  let data;
38495
38538
  try {
38496
- data = (await client.adminVaultImportRun({ org_id: orgId, connector_id: connectorId, dry_run: !apply, ...maxPuts ? { max_puts: maxPuts } : {} })).data;
38539
+ data = (await client.adminVaultImportRun({
38540
+ org_id: orgId,
38541
+ connector_id: connectorId,
38542
+ dry_run: !apply,
38543
+ ...maxPuts ? { max_puts: maxPuts } : {},
38544
+ ...apply && approved ? { approved_policies: approved } : {}
38545
+ })).data;
38497
38546
  } catch (err) {
38498
38547
  exitOnApiError(err);
38499
38548
  throw err;
@@ -38509,7 +38558,8 @@ async function runVaultImport(flagArgs) {
38509
38558
  for (const l of data.legacy_rows ?? []) console.log(` ${l.field} ${l.stored}: rows=${l.rows} (stays as stored: the vault does not hold it)`);
38510
38559
  for (const v of data.values) {
38511
38560
  const expiry = v.expires_at === void 0 ? "" : ` expires_at=${v.expires_at ?? "none"}`;
38512
- console.log(` value ${v.field} \u2192 ${v.secret_id ?? "-"}: ${v.outcome}${v.code ? ` (${v.code})` : ""}${expiry}`);
38561
+ const header = v.headers ? ` (from header ${v.headers.join(", ")})` : "";
38562
+ console.log(` value ${v.field}${header} \u2192 ${v.secret_id ?? "-"}: ${v.outcome}${v.code ? ` (${v.code})` : ""}${expiry}`);
38513
38563
  for (const r of v.rows) console.log(` hub=${r.hub_id} connection=${r.connection_id}: ${r.outcome}`);
38514
38564
  }
38515
38565
  const credentials = data.credentials ?? [];
@@ -38526,6 +38576,7 @@ async function runVaultImport(flagArgs) {
38526
38576
  console.log("A credential with a stale row moves once `wayai admin hubs repair-credential-links --org <org_id> --apply` writes its current value.");
38527
38577
  }
38528
38578
  }
38579
+ if (data.customer) printCustomerReport(data.customer, data.dry_run);
38529
38580
  const voiceRows = data.voice_rows ?? [];
38530
38581
  if (voiceRows.length > 0) {
38531
38582
  console.log(`GPT-Live connections this run ${data.dry_run ? "would move" : "moved"} (${voiceRows.length}): a call live on one keeps its key; one started after, or a restarted call control, goes through the vault. Live calls are not counted.`);
@@ -38557,7 +38608,7 @@ async function runVaultRevert(flagArgs) {
38557
38608
  console.log(JSON.stringify(data, null, 2));
38558
38609
  return;
38559
38610
  }
38560
- console.log(`vault revert (${data.connector}) \u2014 ${data.dry_run ? "DRY RUN \u2014 nothing written" : "written"}: hubs_scanned=${data.hubs_scanned} undo_rows=${data.undo_rows}`);
38611
+ console.log(`vault revert (${data.connector}) \u2014 ${data.dry_run ? "DRY RUN \u2014 nothing written" : "written"}: hubs_scanned=${data.hubs_scanned} undo_rows=${data.undo_rows}${data.undo_days === void 0 ? "" : ` (within ${data.undo_days} days of the move)`}`);
38561
38612
  for (const v of data.values) {
38562
38613
  console.log(` value ${v.field} \u2190 ${v.secret_id}${v.code ? `: ${v.code}` : ""}`);
38563
38614
  for (const r of v.rows) console.log(` hub=${r.hub_id} connection=${r.connection_id}: ${r.outcome}`);
@@ -39813,11 +39864,11 @@ Usage:
39813
39864
  wayai admin orgs repair-legacy-grants --all | --org <org_id> [--dry-run] [--yes] [--json]
39814
39865
  Repair org-admin roster rows keyed by email with a NULL user_email (pre-#3922 platform-admin adds): grant the real access they never conferred, or drop the phantom seat. Idempotent \u2014 run --dry-run first
39815
39866
 
39816
- wayai admin vault import --org <org_id> --connector <connector_id> [--max-puts <n>] [--apply] [--yes] [--json]
39817
- Move one org's stored credentials of one connector into the credentials vault, no re-entry (#5644). A dry run by default (counts by field, link kind and form); --apply needs the connector's gate open, puts each distinct value once for the direct rows holding it, moves each org credential with the rows it supplies when all of them may move (else names why it stays), and keeps the old ciphertext 30 days for revert. Re-run until values_remaining and credentials_remaining are 0. Lists Telegram bots to enable again. WhatsApp and Instagram: trims each token as a send does (rows counted), puts it with its expiry, and counts the legacy api_key rows that stay
39867
+ wayai admin vault import --org <org_id> --connector <connector_id> [--max-puts <n>] [--approved <dry-run.json>] [--apply] [--yes] [--json]
39868
+ Move one org's stored credentials of one connector into the credentials vault, no re-entry (#5644). A dry run by default (counts by field, link kind and form); --apply needs the connector's gate open, puts each distinct value once for the direct rows holding it, moves each org credential with the rows it supplies when all of them may move (else names why it stays), and keeps the old ciphertext 30 days for revert. Re-run until values_remaining and credentials_remaining are 0. Lists Telegram bots to enable again. WhatsApp and Instagram: trims each token as a send does (rows counted), puts it with its expiry, and counts the legacy api_key rows that stay. REST API, External Resources, MCP Server: prints each value's derived policy or why it stays and counts the connections; --apply moves only what --approved (the reviewed dry run's --json) lists, keeping the old ciphertext 7 days
39818
39869
 
39819
39870
  wayai admin vault revert --org <org_id> --connector <connector_id> [--apply] [--yes] [--json]
39820
- Put back what vault import moved, within 30 days, and erase the vault entries no row names; a WhatsApp or Instagram token the vault renewed since stays (renewed). A dry run by default
39871
+ Put back what vault import moved, within 30 days (7 for REST API, External Resources, MCP Server), and erase the vault entries no row names; a WhatsApp or Instagram token the vault renewed since stays (renewed). A dry run by default
39821
39872
 
39822
39873
  wayai admin harness disable Flip the platform harness_enabled flag OFF (break-glass: blocks harness-agent writes and the per-turn kill switch aborts each harness turn on its next invocation)
39823
39874
  wayai admin harness enable Flip the platform harness_enabled flag ON
@@ -40596,7 +40647,7 @@ var init_actions = __esm({
40596
40647
 
40597
40648
  // src/data/commands/attachments.ts
40598
40649
  import { Command as Command2 } from "commander";
40599
- import { readFileSync as readFileSync19 } from "fs";
40650
+ import { readFileSync as readFileSync20 } from "fs";
40600
40651
  function findAttachmentByFilename(attachments, filename) {
40601
40652
  return attachments.find((a) => a.key.endsWith(`/${filename}`)) ?? null;
40602
40653
  }
@@ -40637,7 +40688,7 @@ function buildAttachmentsCommand() {
40637
40688
  printOutput(data, outputFormat(this));
40638
40689
  return;
40639
40690
  }
40640
- const body = readFileSync19(opts.file);
40691
+ const body = readFileSync20(opts.file);
40641
40692
  await client.upload(uploadPathFrom(data?.upload_url), body, opts.contentType);
40642
40693
  printOutput({ ...data, uploaded: true }, outputFormat(this));
40643
40694
  });
@@ -41134,7 +41185,7 @@ var init_providers = __esm({
41134
41185
 
41135
41186
  // src/data/commands/credentials.ts
41136
41187
  import { Command as Command6 } from "commander";
41137
- import { readFileSync as readFileSync20 } from "fs";
41188
+ import { readFileSync as readFileSync21 } from "fs";
41138
41189
  function withValueSourceOptions(cmd, what) {
41139
41190
  return cmd.option(
41140
41191
  "--file <path>",
@@ -41147,7 +41198,7 @@ async function resolveValue(opts, label2) {
41147
41198
  throw expected("--file cannot be combined with --value-stdin or --value-prompt \u2014 pass one.");
41148
41199
  }
41149
41200
  try {
41150
- return readFileSync20(opts.file).toString("base64");
41201
+ return readFileSync21(opts.file).toString("base64");
41151
41202
  } catch (e) {
41152
41203
  throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
41153
41204
  }
@@ -41296,7 +41347,7 @@ var init_credentials = __esm({
41296
41347
 
41297
41348
  // src/data/commands/sql.ts
41298
41349
  import { Command as Command7 } from "commander";
41299
- import { readFileSync as readFileSync21 } from "fs";
41350
+ import { readFileSync as readFileSync22 } from "fs";
41300
41351
  function buildBasesSqlCommand() {
41301
41352
  return withBaseOption(new Command7("sql")).description("Execute a read-only SQL query against base data").argument("[query]", "SQL query (SELECT only)").option("--file <path>", "Read SQL from a file instead of the argument").option(
41302
41353
  "--param <kv...>",
@@ -41306,7 +41357,7 @@ function buildBasesSqlCommand() {
41306
41357
  let query;
41307
41358
  if (opts.file) {
41308
41359
  try {
41309
- query = readFileSync21(opts.file, "utf-8").trim();
41360
+ query = readFileSync22(opts.file, "utf-8").trim();
41310
41361
  } catch (e) {
41311
41362
  throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
41312
41363
  }
@@ -41989,7 +42040,7 @@ var init_file_types = __esm({
41989
42040
 
41990
42041
  // src/data/commands/files.ts
41991
42042
  import { Command as Command11 } from "commander";
41992
- import { readFileSync as readFileSync22, writeFileSync as writeFileSync11 } from "fs";
42043
+ import { readFileSync as readFileSync23, writeFileSync as writeFileSync11 } from "fs";
41993
42044
  import { basename as basename29 } from "path";
41994
42045
  function renderFileDiff(fileType, filePath2, from, to, d) {
41995
42046
  console.log(sanitizeTerminalText(`${fileType}/${filePath2}: v${from} \u2192 v${to}`));
@@ -42046,7 +42097,7 @@ function buildFilesCommand() {
42046
42097
  label: opts.label,
42047
42098
  metadata: opts.metadata === void 0 ? void 0 : parseData(opts.metadata, "--metadata")
42048
42099
  });
42049
- const body = readFileSync22(opts.file);
42100
+ const body = readFileSync23(opts.file);
42050
42101
  const client = await createDataClient();
42051
42102
  printOutput(
42052
42103
  await client.upload(
@@ -43135,7 +43186,7 @@ init_errors2();
43135
43186
  init_mask_secrets();
43136
43187
  init_utils();
43137
43188
  init_registry();
43138
- import { readFileSync as readFileSync23 } from "fs";
43189
+ import { readFileSync as readFileSync24 } from "fs";
43139
43190
  import { fileURLToPath as fileURLToPath2 } from "url";
43140
43191
  import { dirname as dirname16, join as join39 } from "path";
43141
43192
 
@@ -43293,7 +43344,7 @@ Run \`wayai admin skill install\` to update.`);
43293
43344
 
43294
43345
  // src/index.ts
43295
43346
  var __dirname = dirname16(fileURLToPath2(import.meta.url));
43296
- var pkg = JSON.parse(readFileSync23(join39(__dirname, "..", "package.json"), "utf-8"));
43347
+ var pkg = JSON.parse(readFileSync24(join39(__dirname, "..", "package.json"), "utf-8"));
43297
43348
  var [, , command, ...args] = process.argv;
43298
43349
  var isBackgroundRefresh = command === REFRESH_COMMAND;
43299
43350
  if (!isBackgroundRefresh) initSentry(command, pkg.version);