@wayai/cli 0.3.326 → 0.3.328

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
@@ -6859,7 +6859,7 @@ var init_chunk_5FO3GNKP = __esm({
6859
6859
  }
6860
6860
  });
6861
6861
 
6862
- // ../../packages/core/dist/chunk-PC3774CE.js
6862
+ // ../../packages/core/dist/chunk-763PRRIT.js
6863
6863
  function matchPath(pattern, path45) {
6864
6864
  const pathSegments2 = path45.replace(/\/$/, "").split("/");
6865
6865
  const isPrefix = pattern.endsWith("/*");
@@ -6888,8 +6888,8 @@ function getEndpointConfig(path45) {
6888
6888
  return { tier: "STANDARD" };
6889
6889
  }
6890
6890
  var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
6891
- var init_chunk_PC3774CE = __esm({
6892
- "../../packages/core/dist/chunk-PC3774CE.js"() {
6891
+ var init_chunk_763PRRIT = __esm({
6892
+ "../../packages/core/dist/chunk-763PRRIT.js"() {
6893
6893
  "use strict";
6894
6894
  init_chunk_5FO3GNKP();
6895
6895
  ENDPOINT_CONFIGS = {
@@ -7224,9 +7224,6 @@ var init_chunk_PC3774CE = __esm({
7224
7224
  // The WayAI-host token clear (#5644 steps 6–7) deletes connections and org credentials, and its dry run fans out over
7225
7225
  // every hub of every org: the same strict, fail-closed budget.
7226
7226
  "/api/admin/hubs/clear-wayai-host-tokens": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
7227
- // The credentials-vault importer (wayai#5644 D2-M6) decrypts and moves an org's credentials, or puts them back:
7228
- // strict and fail-closed like the hub repairs, with room for the re-runs a bounded run takes (`max_puts`).
7229
- "/api/admin/vault-import/*": { tier: "STRICT", userLimit: 60, userWindow: 3600, failClosed: true, userLimitKey: "/api/admin/vault-import/*" },
7230
7227
  // CI/GitOps endpoints - standard with user limits. 500 because `wayai push` makes four requests
7231
7228
  // (pull, diff, push, pull) and a GitOps job may push every hub at once with one token; when
7232
7229
  // each path held its own 100, that ran to 100 hubs a minute.
@@ -7347,8 +7344,8 @@ var init_chunk_PC3774CE = __esm({
7347
7344
  // many members' clicks share, and STRICT's 5/min bucket is shared with sign-in. An exact key, so
7348
7345
  // it wins over the wildcard above.
7349
7346
  [COMMUNITY_EMAIL_UNSUBSCRIBE_PATH]: { tier: "MODERATE" },
7350
- // Case spaces (wayai#5921, `cases/routes.ts`): every route under the mount shares one per-user
7351
- // budget. Each is one person's page or write, at most a few hundred Durable Object reads (the
7347
+ // Case spaces (wayai#5921, `cases/routes.ts`): every route under the mount (the upload below excepted) shares
7348
+ // one per-user budget. Each is one person's page or write, at most a few hundred Durable Object reads (the
7352
7349
  // list of their spaces); a space's own limits are counted in its CaseDO. Every caller is a web
7353
7350
  // session, so the per-IP tier is skipped; the key is pinned because the paths carry org, space,
7354
7351
  // person and team ids.
@@ -7358,6 +7355,14 @@ var init_chunk_PC3774CE = __esm({
7358
7355
  skipAuthenticatedUsers: true,
7359
7356
  userLimitKey: "/api/cases/*"
7360
7357
  },
7358
+ // A case file upload (`POST …/cases/:code/uploads`): each carries up to 20 MiB the Worker holds in memory, hashes
7359
+ // and stores, so it takes its own, lower budget, keyed once for every case.
7360
+ "/api/cases/*/*/cases/*/uploads": {
7361
+ tier: "STANDARD",
7362
+ userLimit: 10,
7363
+ skipAuthenticatedUsers: true,
7364
+ userLimitKey: "/api/cases/*/*/cases/*/uploads"
7365
+ },
7361
7366
  // The WayAI Guide's help entry (wayai#4948, `routes/api/guide.ts`): one POST per click by a viewer
7362
7367
  // the snapshot does not show enrolled, which reads the person's row on the Guide hub and writes only
7363
7368
  // what is missing (an enrolled viewer's click opens the hub without a request). Every caller is
@@ -7394,7 +7399,7 @@ var init_chunk_PC3774CE = __esm({
7394
7399
  }
7395
7400
  });
7396
7401
 
7397
- // ../../packages/core/dist/chunk-HFEOIQF4.js
7402
+ // ../../packages/core/dist/chunk-THZG62YP.js
7398
7403
  function fileSnapshotChanged(run) {
7399
7404
  return run.written + run.removed > 0;
7400
7405
  }
@@ -7435,10 +7440,10 @@ async function sendWithRetry(opts, cursor) {
7435
7440
  }
7436
7441
  }
7437
7442
  var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
7438
- var init_chunk_HFEOIQF4 = __esm({
7439
- "../../packages/core/dist/chunk-HFEOIQF4.js"() {
7443
+ var init_chunk_THZG62YP = __esm({
7444
+ "../../packages/core/dist/chunk-THZG62YP.js"() {
7440
7445
  "use strict";
7441
- init_chunk_PC3774CE();
7446
+ init_chunk_763PRRIT();
7442
7447
  init_chunk_5FO3GNKP();
7443
7448
  init_zod();
7444
7449
  rekorFileSnapshotAnswerSchema = external_exports.object({
@@ -15956,12 +15961,14 @@ var init_chunk_N7TIWXUC = __esm({
15956
15961
  }
15957
15962
  });
15958
15963
 
15959
- // ../../packages/core/dist/chunk-PZCHHX22.js
15960
- var CASE_FILE_SHA_PATTERN, caseFileShaSchema, CASE_REVISION_MESSAGE_MAX_LENGTH, CASE_REVISION_SESSION_MAX_LENGTH, CASE_REVISION_ENTRIES_MAX, caseRevisionEntryShape, caseRevisionShape;
15961
- var init_chunk_PZCHHX22 = __esm({
15962
- "../../packages/core/dist/chunk-PZCHHX22.js"() {
15964
+ // ../../packages/core/dist/chunk-VMWWH3YC.js
15965
+ var CASE_FILE_SHA_PATTERN, caseFileShaSchema, CASE_REVISION_MESSAGE_MAX_LENGTH, CASE_REVISION_SESSION_MAX_LENGTH, CASE_REVISION_ENTRIES_MAX, caseRevisionEntryShape, caseRevisionShape, CASE_UPLOAD_BODY_MAX_BYTES, CASE_UPLOAD_REVISION_FIELD, isBlob, caseUploadForm, CASE_FILES_PAGE_MAX, caseFilesQuery, caseFileReadPath, CASE_FILE_VERSIONS_PAGE_MAX, caseFileVersionsQuery, caseFileContentQuery;
15966
+ var init_chunk_VMWWH3YC = __esm({
15967
+ "../../packages/core/dist/chunk-VMWWH3YC.js"() {
15963
15968
  "use strict";
15964
15969
  init_chunk_N7TIWXUC();
15970
+ init_chunk_IZPR5A6I();
15971
+ init_chunk_HZ6CADSY();
15965
15972
  init_zod();
15966
15973
  CASE_FILE_SHA_PATTERN = /^[0-9a-f]{64}$/;
15967
15974
  caseFileShaSchema = external_exports.string().regex(CASE_FILE_SHA_PATTERN);
@@ -15984,6 +15991,46 @@ var init_chunk_PZCHHX22 = __esm({
15984
15991
  session: external_exports.string().trim().min(1).max(CASE_REVISION_SESSION_MAX_LENGTH).nullable().default(null),
15985
15992
  entries: external_exports.array(caseRevisionEntryShape).min(1).max(CASE_REVISION_ENTRIES_MAX)
15986
15993
  }).strict();
15994
+ CASE_UPLOAD_BODY_MAX_BYTES = 20 * 1024 * 1024;
15995
+ CASE_UPLOAD_REVISION_FIELD = "revision";
15996
+ isBlob = (value) => typeof Blob !== "undefined" && value instanceof Blob;
15997
+ caseUploadForm = external_exports.record(external_exports.string(), external_exports.unknown()).transform((form2, ctx) => {
15998
+ const refuse2 = (message, path45) => {
15999
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message, path: [path45] });
16000
+ return external_exports.NEVER;
16001
+ };
16002
+ const text4 = form2[CASE_UPLOAD_REVISION_FIELD];
16003
+ if (typeof text4 !== "string") return refuse2("The revision is required", CASE_UPLOAD_REVISION_FIELD);
16004
+ let revision;
16005
+ try {
16006
+ revision = JSON.parse(text4);
16007
+ } catch {
16008
+ return refuse2("The revision is not JSON", CASE_UPLOAD_REVISION_FIELD);
16009
+ }
16010
+ const parsed = caseRevisionShape.safeParse(revision);
16011
+ if (!parsed.success) return refuse2(parsed.error.issues[0]?.message ?? "The revision is not of its shape", CASE_UPLOAD_REVISION_FIELD);
16012
+ const parts = [];
16013
+ for (const [field, value] of Object.entries(form2)) {
16014
+ if (field === CASE_UPLOAD_REVISION_FIELD) continue;
16015
+ if (!CASE_FILE_SHA_PATTERN.test(field) || !isBlob(value)) return refuse2("A part is named by its content's SHA-256 and holds its bytes", field);
16016
+ parts.push({ sha: field, bytes: value });
16017
+ }
16018
+ return { revision, fields: parsed.data, parts };
16019
+ });
16020
+ CASE_FILES_PAGE_MAX = 500;
16021
+ caseFilesQuery = casePageQuery.extend({
16022
+ limit: external_exports.coerce.number().int().min(1).max(CASE_FILES_PAGE_MAX).optional()
16023
+ });
16024
+ caseFileReadPath = caseRevisionEntryShape.shape.path;
16025
+ CASE_FILE_VERSIONS_PAGE_MAX = 100;
16026
+ caseFileVersionsQuery = casePageQuery.extend({
16027
+ path: caseFileReadPath,
16028
+ limit: external_exports.coerce.number().int().min(1).max(CASE_FILE_VERSIONS_PAGE_MAX).optional()
16029
+ });
16030
+ caseFileContentQuery = external_exports.object({
16031
+ path: caseFileReadPath,
16032
+ revision_id: uuidSchema.optional()
16033
+ });
15987
16034
  }
15988
16035
  });
15989
16036
 
@@ -16970,10 +17017,10 @@ var init_chunk_BFG4ZWR4 = __esm({
16970
17017
  }
16971
17018
  });
16972
17019
 
16973
- // ../../packages/core/dist/chunk-7VJ4SOFF.js
17020
+ // ../../packages/core/dist/chunk-UY32MQHG.js
16974
17021
  var dataExplorerDebugDoType, DEBUG_READ_MAX_LIMIT, DEBUG_READ_DEFAULT_LIMIT;
16975
- var init_chunk_7VJ4SOFF = __esm({
16976
- "../../packages/core/dist/chunk-7VJ4SOFF.js"() {
17022
+ var init_chunk_UY32MQHG = __esm({
17023
+ "../../packages/core/dist/chunk-UY32MQHG.js"() {
16977
17024
  "use strict";
16978
17025
  init_zod();
16979
17026
  dataExplorerDebugDoType = external_exports.enum(["hub", "org", "conversation", "user", "platform", "thread", "community", "contact_book", "batch"]);
@@ -17084,7 +17131,7 @@ var init_chunk_OMPT4ZHR = __esm({
17084
17131
  }
17085
17132
  });
17086
17133
 
17087
- // ../../packages/core/dist/chunk-3UITNZV5.js
17134
+ // ../../packages/core/dist/chunk-HHVS7IP4.js
17088
17135
  function refineScopedTarget(data, ctx) {
17089
17136
  if (data.scope === "org") {
17090
17137
  if (!data.org_id) {
@@ -17110,12 +17157,12 @@ function refineScopedTarget(data, ctx) {
17110
17157
  }
17111
17158
  }
17112
17159
  var adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, PRICING_PLAN_ID_RE, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, MAX_VOICE_CALL_MINUTE_OPS, voiceCallMinuteOps, AUTOMATION_GATE_EVALUATIONS_PER_OPERATION_BOUND, automationGateEvaluationsPerOperation, AUTOMATION_RUN_RETENTION_DAYS_MAX, automationRunRetentionDays, turnDeadlineSeconds, casesLimit, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetShape, adminScopedTargetBody, adminDryRunByDefaultTargetBody, WAYAI_HOST_TOKEN_TARGET_KINDS, WAYAI_HOST_TOKEN_MAX_TARGETS, adminClearWayaiHostTokensBody, BRANCHING_ORPHAN_ENTITY_TYPES, BRANCHING_ORPHAN_MAX_TARGETS, adminRepairBranchingOrphansBody, adminRepairLegacyOrgGrantsBody, adminRepairCredentialServicesBody, adminRepairCompedPlansBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysBody, dataExplorerKvKeyBody, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteBody, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, dataExplorerDebugCountsDoType, dataExplorerDebugCountsParam, debugHubConvParam, debugMessageIdQuery;
17113
- var init_chunk_3UITNZV5 = __esm({
17114
- "../../packages/core/dist/chunk-3UITNZV5.js"() {
17160
+ var init_chunk_HHVS7IP4 = __esm({
17161
+ "../../packages/core/dist/chunk-HHVS7IP4.js"() {
17115
17162
  "use strict";
17116
17163
  init_chunk_FECLIZTY();
17117
17164
  init_chunk_BFG4ZWR4();
17118
- init_chunk_7VJ4SOFF();
17165
+ init_chunk_UY32MQHG();
17119
17166
  init_chunk_XEG3QEIZ();
17120
17167
  init_chunk_OMPT4ZHR();
17121
17168
  init_chunk_HZ6CADSY();
@@ -17262,7 +17309,7 @@ var init_chunk_3UITNZV5 = __esm({
17262
17309
  cases_files_per_case_max: casesLimit(2e4).optional(),
17263
17310
  cases_comments_notes_per_case_max: casesLimit(2e4).optional(),
17264
17311
  cases_verdicts_per_case_max: casesLimit(5e4).optional(),
17265
- cases_space_bytes_quota: casesLimit(1024 ** 4).optional(),
17312
+ cases_case_bytes_quota: casesLimit(1024 ** 4).optional(),
17266
17313
  cases_note_max_bytes: casesLimit(64 * 1024).optional(),
17267
17314
  cases_verdict_reason_max_bytes: casesLimit(16 * 1024).optional(),
17268
17315
  /** How many automation gate evaluations bill one operation (`automationGateEvaluationsPerOperation`). */
@@ -17703,7 +17750,7 @@ var init_contracts = __esm({
17703
17750
  init_chunk_ZC6YGHNX();
17704
17751
  init_chunk_MGBAXT5Y();
17705
17752
  init_chunk_5DGHIY7L();
17706
- init_chunk_HFEOIQF4();
17753
+ init_chunk_THZG62YP();
17707
17754
  init_chunk_IPDOHAZ5();
17708
17755
  init_chunk_34LE6P7E();
17709
17756
  init_chunk_FPSDNS2E();
@@ -17744,7 +17791,7 @@ var init_contracts = __esm({
17744
17791
  init_chunk_7CYHPF35();
17745
17792
  init_chunk_NETRUHZF();
17746
17793
  init_chunk_KHL7NZSL();
17747
- init_chunk_PZCHHX22();
17794
+ init_chunk_VMWWH3YC();
17748
17795
  init_chunk_QVZPT7ZX();
17749
17796
  init_chunk_E4AVT2QI();
17750
17797
  init_chunk_B2AXWIKU();
@@ -17766,10 +17813,10 @@ var init_contracts = __esm({
17766
17813
  init_chunk_N7TIWXUC();
17767
17814
  init_chunk_IZPR5A6I();
17768
17815
  init_chunk_NVKU5PPQ();
17769
- init_chunk_3UITNZV5();
17816
+ init_chunk_HHVS7IP4();
17770
17817
  init_chunk_FECLIZTY();
17771
17818
  init_chunk_BFG4ZWR4();
17772
- init_chunk_7VJ4SOFF();
17819
+ init_chunk_UY32MQHG();
17773
17820
  init_chunk_XEG3QEIZ();
17774
17821
  init_chunk_D3EP4TDU();
17775
17822
  init_chunk_YZHCIGDZ();
@@ -17785,7 +17832,7 @@ var init_contracts = __esm({
17785
17832
  init_chunk_ZIGA5RCU();
17786
17833
  init_chunk_FBV7NLKO();
17787
17834
  init_chunk_VYINA6YP();
17788
- init_chunk_PC3774CE();
17835
+ init_chunk_763PRRIT();
17789
17836
  init_chunk_XKMRLZKH();
17790
17837
  init_chunk_SOJMWM63();
17791
17838
  init_chunk_5FO3GNKP();
@@ -17881,10 +17928,10 @@ var init_chunk_RPGBR5IN = __esm({
17881
17928
  }
17882
17929
  });
17883
17930
 
17884
- // ../../packages/core/dist/chunk-FZ7BJJW7.js
17931
+ // ../../packages/core/dist/chunk-6KZ3JNQ2.js
17885
17932
  var ENVELOPE_PREFIX, CREDENTIAL_REFERENCE_PREFIX;
17886
- var init_chunk_FZ7BJJW7 = __esm({
17887
- "../../packages/core/dist/chunk-FZ7BJJW7.js"() {
17933
+ var init_chunk_6KZ3JNQ2 = __esm({
17934
+ "../../packages/core/dist/chunk-6KZ3JNQ2.js"() {
17888
17935
  "use strict";
17889
17936
  ENVELOPE_PREFIX = "enc:v1:";
17890
17937
  CREDENTIAL_REFERENCE_PREFIX = `${ENVELOPE_PREFIX}vault:`;
@@ -17943,7 +17990,7 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
17943
17990
  var init_dist = __esm({
17944
17991
  "../../packages/core/dist/index.js"() {
17945
17992
  "use strict";
17946
- init_chunk_PC3774CE();
17993
+ init_chunk_763PRRIT();
17947
17994
  init_chunk_XKMRLZKH();
17948
17995
  init_chunk_SOJMWM63();
17949
17996
  init_chunk_5FO3GNKP();
@@ -17963,7 +18010,7 @@ var init_dist = __esm({
17963
18010
  init_chunk_FEOO3UPS();
17964
18011
  init_chunk_RPGBR5IN();
17965
18012
  init_chunk_C2UEA2KW();
17966
- init_chunk_FZ7BJJW7();
18013
+ init_chunk_6KZ3JNQ2();
17967
18014
  init_chunk_ZDTX3DG5();
17968
18015
  init_chunk_3MF6FWS5();
17969
18016
  init_chunk_JP7XIMUA();
@@ -19192,8 +19239,6 @@ var init_utils = __esm({
19192
19239
  ["admin hubs clear-wayai-host-tokens", { positionals: 0, values: ["--org", "--hub", "--id"], dryRun: true }],
19193
19240
  ["admin orgs repair-legacy-grants", { positionals: 0, values: ["--org"], dryRun: true }],
19194
19241
  ["admin orgs repair-credential-services", { positionals: 0, values: ["--org"], dryRun: true }],
19195
- ["admin vault import", { positionals: 0, values: ["--org", "--connector", "--max-puts", "--approved"] }],
19196
- ["admin vault revert", { positionals: 0, values: ["--org", "--connector"] }],
19197
19242
  ["admin vault base-dry-run", { positionals: 0, values: ["--org", "--base", "--after"] }],
19198
19243
  ["admin vault mount-credential-count", { positionals: 0, values: ["--org", "--cursor"] }],
19199
19244
  ["admin harness mass-destroy", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
@@ -19717,14 +19762,6 @@ var init_api_client = __esm({
19717
19762
  async adminRepairKnowledgeBlobs(body) {
19718
19763
  return this.request("POST", "/api/admin/hubs/repair-knowledge-blobs", body);
19719
19764
  }
19720
- // Used by `wayai admin vault import` (platform-admin gated, wayai#5644).
19721
- async adminVaultImportRun(body) {
19722
- return this.request("POST", "/api/admin/vault-import/run", body);
19723
- }
19724
- // Used by `wayai admin vault revert` (platform-admin gated, wayai#5644).
19725
- async adminVaultImportRevert(body) {
19726
- return this.request("POST", "/api/admin/vault-import/revert", body);
19727
- }
19728
19765
  // Used by `wayai admin hubs repair-credential-links` (platform-admin gated).
19729
19766
  async adminRepairCredentialLinks(body) {
19730
19767
  return this.request("POST", "/api/admin/hubs/repair-credential-links", body);
@@ -39219,29 +39256,13 @@ var init_file_map = __esm({
39219
39256
  });
39220
39257
 
39221
39258
  // ../../packages/core/dist/contracts/vault-import.js
39222
- var VAULT_IMPORT_DEFAULT_PUTS, VAULT_IMPORT_MAX_PUTS, VAULT_IMPORT_MAX_APPROVED, vaultImportRunBody, vaultImportRevertBody, dryRunKey, dryRunCount, dryRunCounts, dryRunTable, baseVaultDryRunReport, BASE_VAULT_DRY_RUN_UNREADABLE, dryRunBaseId, baseVaultDryRunBase, BASE_VAULT_DRY_RUN_LISTINGS, baseVaultDryRunPage, baseVaultDryRunQuery, S3_CREDENTIAL_COUNT_PAGE_KEYS, s3CountInstant, s3CountCursor, s3CredentialCountOrg, s3CredentialCountPage, s3CredentialCountQuery;
39259
+ var dryRunKey, dryRunCount, dryRunCounts, dryRunTable, baseVaultDryRunReport, BASE_VAULT_DRY_RUN_UNREADABLE, dryRunBaseId, baseVaultDryRunBase, BASE_VAULT_DRY_RUN_LISTINGS, baseVaultDryRunPage, baseVaultDryRunQuery, S3_CREDENTIAL_COUNT_PAGE_KEYS, s3CountInstant, s3CountCursor, s3CredentialCountOrg, s3CredentialCountPage, s3CredentialCountQuery;
39223
39260
  var init_vault_import = __esm({
39224
39261
  "../../packages/core/dist/contracts/vault-import.js"() {
39225
39262
  "use strict";
39226
39263
  init_chunk_HZ6CADSY();
39227
39264
  init_chunk_MIWZOSPI();
39228
39265
  init_zod();
39229
- VAULT_IMPORT_DEFAULT_PUTS = 25;
39230
- VAULT_IMPORT_MAX_PUTS = 100;
39231
- VAULT_IMPORT_MAX_APPROVED = 1e3;
39232
- vaultImportRunBody = external_exports.object({
39233
- org_id: uuidSchema,
39234
- /** A catalog `connector_id` the vault holds fields of. */
39235
- connector_id: external_exports.string().min(1).max(128),
39236
- dry_run: external_exports.boolean().optional().default(true),
39237
- max_puts: external_exports.number().int().min(1).max(VAULT_IMPORT_MAX_PUTS).optional().default(VAULT_IMPORT_DEFAULT_PUTS),
39238
- /**
39239
- * REST API, External Resources and MCP Server only, and required for their real run: the `policy_hash` of each
39240
- * value a dry run listed that the owner approved (`VaultImportPolicyEntry`). Any other value stays (`not_approved`).
39241
- */
39242
- approved_policies: external_exports.array(external_exports.string().regex(/^[0-9a-f]{64}$/)).max(VAULT_IMPORT_MAX_APPROVED).optional()
39243
- }).strict();
39244
- vaultImportRevertBody = vaultImportRunBody.omit({ max_puts: true, approved_policies: true });
39245
39266
  dryRunKey = external_exports.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
39246
39267
  dryRunCount = external_exports.number().int().nonnegative();
39247
39268
  dryRunCounts = external_exports.record(dryRunKey, dryRunCount);
@@ -39686,12 +39707,6 @@ async function adminCommand(args2) {
39686
39707
  process.exit(1);
39687
39708
  }
39688
39709
  switch (sub) {
39689
- case "import":
39690
- await runVaultImport(flagArgs);
39691
- return;
39692
- case "revert":
39693
- await runVaultRevert(flagArgs);
39694
- return;
39695
39710
  case "base-dry-run":
39696
39711
  await runVaultBaseDryRun(flagArgs);
39697
39712
  return;
@@ -40432,152 +40447,6 @@ async function runClearWayaiHostTokens(flagArgs) {
40432
40447
  console.log(` ${r.outcome.padEnd(12)} ${r.kind}:${r.id}${why}`);
40433
40448
  }
40434
40449
  }
40435
- function printCustomerReport(customer, dryRun) {
40436
- const c = customer.census;
40437
- const auth = Object.entries(c.by_auth).map(([k, n]) => `${k}=${n}`).join(" ") || "-";
40438
- 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}`);
40439
- console.log(`policies (${customer.policies.length}; old ciphertext kept ${customer.undo_days} days for revert):`);
40440
- for (const p of customer.policies) {
40441
- const subject = p.credential_id ? `credential ${p.credential_id}` : p.headers ? `literal header ${p.headers.join(", ")} \u2192` : "value";
40442
- console.log(` ${subject} ${p.field}${p.spans_hubs ? " (SPANS HUBS)" : ""}: ${p.reasons.length > 0 ? `stays (${p.reasons.join(", ")})` : dryRun ? "would move" : "approved"}`);
40443
- if (p.policy) {
40444
- if (p.policy.legacy_origin) console.log(" LEGACY ORIGIN (http or another port, moved as it is)");
40445
- for (const scope of p.policy.scopes) {
40446
- 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");
40447
- console.log(` ${scope.origin}${scope.path} (${scope.match}) ${scope.methods.join(",")} [${placements.join(", ")}] headers=${scope.headers.join(",") || "-"}`);
40448
- }
40449
- console.log(` policy_hash=${p.policy_hash}`);
40450
- }
40451
- for (const r of p.rows) console.log(` hub=${r.hub_id} connection=${r.connection_id}`);
40452
- }
40453
- for (const r of customer.stays) console.log(` stays (${r.reason}): ${r.entries}`);
40454
- if (dryRun && customer.policies.some((p) => p.reasons.length === 0)) {
40455
- console.log("To move them: save this dry run with --json, review it, then --apply --approved <that file>.");
40456
- }
40457
- }
40458
- function printVaultReport(data) {
40459
- 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(", ")}`);
40460
- if (data.reenable.length === 0) return;
40461
- console.log(`${data.dry_run ? "Would need" : "Need"} their channel enabled again, on the preview hub (${data.reenable.length}):`);
40462
- 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)"}`);
40463
- }
40464
- function parseVaultFlags(flagArgs, usage4, importFlags) {
40465
- let orgId;
40466
- let connectorId;
40467
- let maxPuts;
40468
- let approvedFile;
40469
- let apply = false;
40470
- let yes = false;
40471
- let jsonOutput = false;
40472
- for (let i = 0; i < flagArgs.length; i++) {
40473
- const flag = flagArgs[i];
40474
- if (flag === "--org") {
40475
- orgId = requireFlagValue(flagArgs, ++i, "--org");
40476
- } else if (flag === "--connector") {
40477
- connectorId = requireFlagValue(flagArgs, ++i, "--connector");
40478
- } else if (flag === "--max-puts" && importFlags) {
40479
- maxPuts = parsePositiveIntFlag("--max-puts", flagArgs[++i]);
40480
- } else if (flag === "--approved" && importFlags) {
40481
- approvedFile = requireFlagValue(flagArgs, ++i, "--approved");
40482
- } else if (flag === "--apply") {
40483
- apply = true;
40484
- } else if (flag === "--yes" || flag === "-y") {
40485
- yes = true;
40486
- } else if (flag === "--json") {
40487
- jsonOutput = true;
40488
- } else {
40489
- console.error(`Unknown flag: ${flag}`);
40490
- console.error(usage4);
40491
- process.exit(1);
40492
- }
40493
- }
40494
- if (!orgId || !connectorId) {
40495
- console.error("--org and --connector are required.");
40496
- console.error(usage4);
40497
- process.exit(1);
40498
- }
40499
- return { orgId, connectorId, maxPuts, approvedFile, apply, yes, jsonOutput };
40500
- }
40501
- function readApprovedPolicies(file) {
40502
- let parsed;
40503
- try {
40504
- parsed = JSON.parse(fs32.readFileSync(file, "utf8"));
40505
- } catch (err) {
40506
- console.error(`--approved: cannot read ${file} as a dry run's --json output: ${err instanceof Error ? err.message : String(err)}`);
40507
- process.exit(1);
40508
- }
40509
- const report2 = parsed;
40510
- const customer = report2.data?.customer ?? report2.customer;
40511
- if (!customer || !Array.isArray(customer.policies)) {
40512
- console.error(`--approved: ${file} holds no customer.policies (a REST API, External Resources or MCP Server dry run's --json output)`);
40513
- process.exit(1);
40514
- }
40515
- return customer.policies.flatMap((p) => typeof p.policy_hash === "string" && Array.isArray(p.reasons) && p.reasons.length === 0 ? [p.policy_hash] : []);
40516
- }
40517
- async function runVaultImport(flagArgs) {
40518
- const USAGE8 = "wayai admin vault import --org <org_id> --connector <connector_id> [--max-puts <n>] [--approved <dry-run.json>] [--apply] [--yes] [--json]";
40519
- const { orgId, connectorId, maxPuts, approvedFile, apply, yes, jsonOutput } = parseVaultFlags(flagArgs, USAGE8, true);
40520
- const approved = approvedFile ? readApprovedPolicies(approvedFile) : void 0;
40521
- if (apply && !yes && !jsonOutput) {
40522
- console.log(`About to MOVE organization ${orgId}'s credentials of connector ${connectorId} into the credentials vault.`);
40523
- console.log("Run without --apply first to see what would move.");
40524
- if (!await confirm("Proceed?")) {
40525
- console.log("Aborted.");
40526
- return;
40527
- }
40528
- }
40529
- const { config, accessToken } = await requireAuth();
40530
- const client = new ApiClient({ apiUrl: config.api_url, accessToken });
40531
- let data;
40532
- try {
40533
- data = (await client.adminVaultImportRun({
40534
- org_id: orgId,
40535
- connector_id: connectorId,
40536
- dry_run: !apply,
40537
- ...maxPuts ? { max_puts: maxPuts } : {},
40538
- ...apply && approved ? { approved_policies: approved } : {}
40539
- })).data;
40540
- } catch (err) {
40541
- exitOnApiError(err);
40542
- throw err;
40543
- }
40544
- if (jsonOutput) {
40545
- console.log(JSON.stringify(data, null, 2));
40546
- return;
40547
- }
40548
- console.log(`vault import (${data.connector}) \u2014 ${data.dry_run ? "DRY RUN \u2014 nothing written" : "written"}: gate=${data.gate_open ? "open" : "CLOSED"} hubs_scanned=${data.hubs_scanned} values_remaining=${data.values_remaining}`);
40549
- if (data.rate_limited) console.log("The vault's per-org rate limit stopped the run \u2014 re-run in a minute.");
40550
- for (const c of data.counts) console.log(` ${c.field} ${c.link} ${c.stored}: rows=${c.rows} values=${c.values}`);
40551
- if (data.trimmed_rows !== void 0) console.log(` trimmed before the put (as a send trims a token): rows=${data.trimmed_rows}`);
40552
- 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)`);
40553
- for (const v of data.values) {
40554
- const expiry = v.expires_at === void 0 ? "" : ` expires_at=${v.expires_at ?? "none"}`;
40555
- const header = v.headers ? ` (from header ${v.headers.join(", ")})` : "";
40556
- console.log(` value ${v.field}${header} \u2192 ${v.secret_id ?? "-"}: ${v.outcome}${v.code ? ` (${v.code})` : ""}${expiry}`);
40557
- for (const r of v.rows) console.log(` hub=${r.hub_id} connection=${r.connection_id}: ${r.outcome}`);
40558
- }
40559
- const credentials = data.credentials ?? [];
40560
- if (credentials.length > 0) {
40561
- console.log(`org credentials: ${credentials.length} credentials_remaining=${data.credentials_remaining ?? 0}`);
40562
- for (const r of data.credential_reasons ?? []) console.log(` stays (${r.reason}): ${r.credentials}`);
40563
- for (const c of credentials) {
40564
- const reasons = c.reasons.length > 0 ? ` (${c.reasons.join(", ")})` : "";
40565
- console.log(` credential ${c.credential_id} ${c.field} \u2192 ${c.secret_id ?? "-"}: ${c.outcome}${reasons}${c.code ? ` (${c.code})` : ""}${c.credential_row ? ` credential_row=${c.credential_row}` : ""}`);
40566
- for (const r of c.rows) console.log(` hub=${r.hub_id} connection=${r.connection_id}: ${r.outcome}`);
40567
- for (const r of c.stale_rows) console.log(` stale: hub=${r.hub_id} connection=${r.connection_id}`);
40568
- }
40569
- if (credentials.some((c) => c.reasons.includes("stale_row"))) {
40570
- console.log("A credential with a stale row moves once `wayai admin hubs repair-credential-links --org <org_id> --apply` writes its current value.");
40571
- }
40572
- }
40573
- if (data.customer) printCustomerReport(data.customer, data.dry_run);
40574
- const voiceRows = data.voice_rows ?? [];
40575
- if (voiceRows.length > 0) {
40576
- 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.`);
40577
- for (const r of voiceRows) console.log(` hub=${r.hub_id}${r.preview ? " (preview)" : ""} connection=${r.connection_id}`);
40578
- }
40579
- printVaultReport(data);
40580
- }
40581
40450
  async function readAdminPages(read, nextOf, start, paceMs = 0) {
40582
40451
  const pages = [];
40583
40452
  let cursor = start;
@@ -40702,41 +40571,6 @@ async function runVaultS3CredentialCount(flagArgs) {
40702
40571
  console.log(`${row.org_id}: live ${row.live}, expired ${row.expired}, no expiry ${row.no_expiry}, created ${row.oldest_created_at ?? "?"} to ${row.newest_created_at ?? "?"}, last expires ${lastExpiry(row)}`);
40703
40572
  }
40704
40573
  }
40705
- async function runVaultRevert(flagArgs) {
40706
- const USAGE8 = "wayai admin vault revert --org <org_id> --connector <connector_id> [--apply] [--yes] [--json]";
40707
- const { orgId, connectorId, apply, yes, jsonOutput } = parseVaultFlags(flagArgs, USAGE8, false);
40708
- if (apply && !yes && !jsonOutput) {
40709
- console.log(`About to PUT BACK organization ${orgId}'s moved credentials of connector ${connectorId}, and erase their vault entries.`);
40710
- console.log("Run without --apply first to see what would go back.");
40711
- if (!await confirm("Proceed?")) {
40712
- console.log("Aborted.");
40713
- return;
40714
- }
40715
- }
40716
- const { config, accessToken } = await requireAuth();
40717
- const client = new ApiClient({ apiUrl: config.api_url, accessToken });
40718
- let data;
40719
- try {
40720
- data = (await client.adminVaultImportRevert({ org_id: orgId, connector_id: connectorId, dry_run: !apply })).data;
40721
- } catch (err) {
40722
- exitOnApiError(err);
40723
- throw err;
40724
- }
40725
- if (jsonOutput) {
40726
- console.log(JSON.stringify(data, null, 2));
40727
- return;
40728
- }
40729
- 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)`}`);
40730
- for (const v of data.values) {
40731
- console.log(` value ${v.field} \u2190 ${v.secret_id}${v.code ? `: ${v.code}` : ""}`);
40732
- for (const r of v.rows) console.log(` hub=${r.hub_id} connection=${r.connection_id}: ${r.outcome}`);
40733
- }
40734
- for (const c of data.credentials ?? []) {
40735
- console.log(` credential ${c.credential_id} ${c.field} \u2190 ${c.secret_id}${c.code ? `: ${c.code}` : ""}${c.credential_row ? ` credential_row=${c.credential_row}` : ""}`);
40736
- for (const r of c.rows) console.log(` hub=${r.hub_id} connection=${r.connection_id}: ${r.outcome}`);
40737
- }
40738
- printVaultReport(data);
40739
- }
40740
40574
  async function runRepairBranchingOrphans(flagArgs) {
40741
40575
  const USAGE8 = "wayai admin hubs repair-branching-orphans --all | --org <org_id> | --hub <hub_id> [--id <type>:<id> ...] [--dry-run] [--yes] [--json]";
40742
40576
  const targets = [];
@@ -42037,10 +41871,9 @@ Usage:
42037
41871
  wayai admin do tables <type> <id>
42038
41872
  wayai admin do read <type> <id> <table> [--limit N] [--id X] [--json]
42039
41873
  wayai admin do counts <hub|org> <id> [--json] Numbers, no text: a hub's toolset connections, knowledge placeholders per stored
42040
- text, summary and kanban context schemas' verdicts, secret columns' shapes,
42041
- (production) publish state and stored_credentials, its values still needing
42042
- MASTER_KEY or held by the vault, per store; an org's
42043
- skills, hub links, moved-knowledge registry, credentials' shapes and stored_credentials
41874
+ text, summary and kanban context schemas' verdicts, secret columns' shapes and
41875
+ (production) publish state; an org's skills, hub links, moved-knowledge
41876
+ registry and credentials' shapes
42044
41877
 
42045
41878
  wayai admin analytics tables
42046
41879
  wayai admin analytics read <table> [--conversation-id X] [--hub-id Y] [--message-id Z] [--limit N] [--json]
@@ -42098,12 +41931,6 @@ Usage:
42098
41931
  wayai admin orgs repair-credential-services --all | --org <org_id> [--apply] [--yes] [--json]
42099
41932
  Name the service of each API Key or Bearer Token org credential created before credentials named one, from its live links (#5644), so a push can pick it again; a credential whose links show no one service, or of a service another credential is already named for, is left unnamed with its reason. A dry run by default; --apply writes. Idempotent
42100
41933
 
42101
- wayai admin vault import --org <org_id> --connector <connector_id> [--max-puts <n>] [--approved <dry-run.json>] [--apply] [--yes] [--json]
42102
- 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
42103
-
42104
- wayai admin vault revert --org <org_id> --connector <connector_id> [--apply] [--yes] [--json]
42105
- 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
42106
-
42107
41934
  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)
42108
41935
  wayai admin harness enable Flip the platform harness_enabled flag ON
42109
41936
  wayai admin harness status Print the platform harness_enabled flag
@@ -42944,7 +42771,7 @@ var init_actions = __esm({
42944
42771
 
42945
42772
  // src/data/commands/attachments.ts
42946
42773
  import { Command as Command3 } from "commander";
42947
- import { readFileSync as readFileSync20 } from "fs";
42774
+ import { readFileSync as readFileSync19 } from "fs";
42948
42775
  function findAttachmentByFilename(attachments, filename) {
42949
42776
  return attachments.find((a) => a.key.endsWith(`/${filename}`)) ?? null;
42950
42777
  }
@@ -42985,7 +42812,7 @@ function buildAttachmentsCommand() {
42985
42812
  printOutput(data, outputFormat(this));
42986
42813
  return;
42987
42814
  }
42988
- const body = readFileSync20(opts.file);
42815
+ const body = readFileSync19(opts.file);
42989
42816
  await client.upload(uploadPathFrom(data?.upload_url), body, opts.contentType);
42990
42817
  printOutput({ ...data, uploaded: true }, outputFormat(this));
42991
42818
  });
@@ -43556,7 +43383,7 @@ var init_credentials = __esm({
43556
43383
 
43557
43384
  // src/data/commands/sql.ts
43558
43385
  import { Command as Command8 } from "commander";
43559
- import { readFileSync as readFileSync21 } from "fs";
43386
+ import { readFileSync as readFileSync20 } from "fs";
43560
43387
  function buildBasesSqlCommand() {
43561
43388
  return withBaseOption(new Command8("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(
43562
43389
  "--param <kv...>",
@@ -43566,7 +43393,7 @@ function buildBasesSqlCommand() {
43566
43393
  let query;
43567
43394
  if (opts.file) {
43568
43395
  try {
43569
- query = readFileSync21(opts.file, "utf-8").trim();
43396
+ query = readFileSync20(opts.file, "utf-8").trim();
43570
43397
  } catch (e) {
43571
43398
  throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
43572
43399
  }
@@ -44245,7 +44072,7 @@ var init_file_types = __esm({
44245
44072
 
44246
44073
  // src/data/commands/files.ts
44247
44074
  import { Command as Command12 } from "commander";
44248
- import { readFileSync as readFileSync22, writeFileSync as writeFileSync11 } from "fs";
44075
+ import { readFileSync as readFileSync21, writeFileSync as writeFileSync11 } from "fs";
44249
44076
  import { basename as basename29 } from "path";
44250
44077
  function renderFileDiff(fileType, filePath3, from, to, d) {
44251
44078
  console.log(sanitizeTerminalText(`${fileType}/${filePath3}: v${from} \u2192 v${to}`));
@@ -44302,7 +44129,7 @@ function buildFilesCommand() {
44302
44129
  label: opts.label,
44303
44130
  metadata: opts.metadata === void 0 ? void 0 : parseData(opts.metadata, "--metadata")
44304
44131
  });
44305
- const body = readFileSync22(opts.file);
44132
+ const body = readFileSync21(opts.file);
44306
44133
  const client = await createDataClient();
44307
44134
  printOutput(
44308
44135
  await client.upload(
@@ -45265,7 +45092,7 @@ init_errors3();
45265
45092
  init_mask_secrets();
45266
45093
  init_utils();
45267
45094
  init_registry();
45268
- import { readFileSync as readFileSync23 } from "fs";
45095
+ import { readFileSync as readFileSync22 } from "fs";
45269
45096
  import { fileURLToPath as fileURLToPath2 } from "url";
45270
45097
  import { dirname as dirname16, join as join39 } from "path";
45271
45098
 
@@ -45423,7 +45250,7 @@ Run \`wayai admin skill install\` to update.`);
45423
45250
 
45424
45251
  // src/index.ts
45425
45252
  var __dirname = dirname16(fileURLToPath2(import.meta.url));
45426
- var pkg = JSON.parse(readFileSync23(join39(__dirname, "..", "package.json"), "utf-8"));
45253
+ var pkg = JSON.parse(readFileSync22(join39(__dirname, "..", "package.json"), "utf-8"));
45427
45254
  var [, , command, ...args] = process.argv;
45428
45255
  var isBackgroundRefresh = command === REFRESH_COMMAND;
45429
45256
  if (!isBackgroundRefresh) initSentry(command, pkg.version);