@wayai/cli 0.3.310 → 0.3.312

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
@@ -5354,6 +5354,80 @@ var init_chunk_Q7KIQHAZ = __esm({
5354
5354
  }
5355
5355
  });
5356
5356
 
5357
+ // ../../packages/core/dist/chunk-IPXBFWUU.js
5358
+ var variantAiModeSchema, experimentStatusSchema, overlayUpdateSchema, experimentIdParam, variantIdParam, listExperimentsQuery, listVariantsQuery, listOverridesQuery, deleteOverrideQuery, createExperimentBody, updateExperimentBody, setExperimentStatusBody, createVariantBody, updateVariantBody, upsertOverrideBody;
5359
+ var init_chunk_IPXBFWUU = __esm({
5360
+ "../../packages/core/dist/chunk-IPXBFWUU.js"() {
5361
+ "use strict";
5362
+ init_chunk_6TSQ5HXC();
5363
+ init_zod();
5364
+ variantAiModeSchema = external_exports.enum(["pilot+copilot", "pilot", "copilot", "turned_off"]);
5365
+ experimentStatusSchema = external_exports.enum(["draft", "running", "stopped"]);
5366
+ overlayUpdateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v === void 0 ? void 0 : v && Object.keys(v).length > 0 ? v : null);
5367
+ experimentIdParam = external_exports.object({
5368
+ id: external_exports.string().uuid()
5369
+ });
5370
+ variantIdParam = external_exports.object({
5371
+ id: external_exports.string().uuid()
5372
+ });
5373
+ listExperimentsQuery = external_exports.object({
5374
+ hub_id: external_exports.string().uuid()
5375
+ });
5376
+ listVariantsQuery = external_exports.object({
5377
+ hub_id: external_exports.string().uuid(),
5378
+ experiment_id: external_exports.string().uuid().optional()
5379
+ });
5380
+ listOverridesQuery = external_exports.object({
5381
+ hub_id: external_exports.string().uuid(),
5382
+ variant_id: external_exports.string().uuid()
5383
+ });
5384
+ deleteOverrideQuery = external_exports.object({
5385
+ hub_id: external_exports.string().uuid(),
5386
+ variant_id: external_exports.string().uuid(),
5387
+ agent_id: external_exports.string().uuid()
5388
+ });
5389
+ createExperimentBody = external_exports.object({
5390
+ hub_id: external_exports.string().uuid(),
5391
+ experiment_slug: slugSchema.optional(),
5392
+ experiment_name: external_exports.string().min(1, "experiment_name is required").max(100, "experiment_name must be 100 characters or fewer"),
5393
+ primary_metric: external_exports.string().max(200).nullish(),
5394
+ status: experimentStatusSchema.default("draft")
5395
+ });
5396
+ updateExperimentBody = external_exports.object({
5397
+ // experiment_slug is immutable after first persist — not accepted here.
5398
+ experiment_name: external_exports.string().min(1).max(100).optional(),
5399
+ primary_metric: external_exports.string().max(200).nullish(),
5400
+ control_variant_id: external_exports.string().uuid().nullish()
5401
+ });
5402
+ setExperimentStatusBody = external_exports.object({
5403
+ status: experimentStatusSchema
5404
+ });
5405
+ createVariantBody = external_exports.object({
5406
+ hub_id: external_exports.string().uuid(),
5407
+ experiment_id: external_exports.string().uuid(),
5408
+ label: external_exports.string().min(1, "label is required").max(100, "label must be 100 characters or fewer"),
5409
+ weight: external_exports.number().positive().default(1),
5410
+ ai_mode: variantAiModeSchema.nullish(),
5411
+ is_control: external_exports.boolean().default(false)
5412
+ });
5413
+ updateVariantBody = external_exports.object({
5414
+ label: external_exports.string().min(1).max(100).optional(),
5415
+ weight: external_exports.number().positive().optional(),
5416
+ ai_mode: variantAiModeSchema.nullish(),
5417
+ is_control: external_exports.boolean().optional()
5418
+ });
5419
+ upsertOverrideBody = external_exports.object({
5420
+ hub_id: external_exports.string().uuid(),
5421
+ variant_id: external_exports.string().uuid(),
5422
+ agent_id: external_exports.string().uuid(),
5423
+ instructions: external_exports.string().nullish(),
5424
+ additional_context_template: external_exports.string().nullish(),
5425
+ connection_id: external_exports.string().uuid().nullish(),
5426
+ agent_settings_overlay: overlayUpdateSchema
5427
+ });
5428
+ }
5429
+ });
5430
+
5357
5431
  // ../../packages/core/dist/chunk-NKLVUTFO.js
5358
5432
  var BASE_CREDENTIAL_MANAGED_BY, BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema, createBaseCredentialLinkBody, baseCredentialLinkParams, baseCredentialLinkQuery;
5359
5433
  var init_chunk_NKLVUTFO = __esm({
@@ -5753,76 +5827,21 @@ var init_chunk_HA7CRZMX = __esm({
5753
5827
  }
5754
5828
  });
5755
5829
 
5756
- // ../../packages/core/dist/chunk-IPXBFWUU.js
5757
- var variantAiModeSchema, experimentStatusSchema, overlayUpdateSchema, experimentIdParam, variantIdParam, listExperimentsQuery, listVariantsQuery, listOverridesQuery, deleteOverrideQuery, createExperimentBody, updateExperimentBody, setExperimentStatusBody, createVariantBody, updateVariantBody, upsertOverrideBody;
5758
- var init_chunk_IPXBFWUU = __esm({
5759
- "../../packages/core/dist/chunk-IPXBFWUU.js"() {
5830
+ // ../../packages/core/dist/chunk-GPM7PE44.js
5831
+ var bootstrapQuery;
5832
+ var init_chunk_GPM7PE44 = __esm({
5833
+ "../../packages/core/dist/chunk-GPM7PE44.js"() {
5760
5834
  "use strict";
5761
- init_chunk_6TSQ5HXC();
5762
5835
  init_zod();
5763
- variantAiModeSchema = external_exports.enum(["pilot+copilot", "pilot", "copilot", "turned_off"]);
5764
- experimentStatusSchema = external_exports.enum(["draft", "running", "stopped"]);
5765
- overlayUpdateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v === void 0 ? void 0 : v && Object.keys(v).length > 0 ? v : null);
5766
- experimentIdParam = external_exports.object({
5767
- id: external_exports.string().uuid()
5768
- });
5769
- variantIdParam = external_exports.object({
5770
- id: external_exports.string().uuid()
5771
- });
5772
- listExperimentsQuery = external_exports.object({
5773
- hub_id: external_exports.string().uuid()
5774
- });
5775
- listVariantsQuery = external_exports.object({
5776
- hub_id: external_exports.string().uuid(),
5777
- experiment_id: external_exports.string().uuid().optional()
5778
- });
5779
- listOverridesQuery = external_exports.object({
5780
- hub_id: external_exports.string().uuid(),
5781
- variant_id: external_exports.string().uuid()
5782
- });
5783
- deleteOverrideQuery = external_exports.object({
5784
- hub_id: external_exports.string().uuid(),
5785
- variant_id: external_exports.string().uuid(),
5786
- agent_id: external_exports.string().uuid()
5787
- });
5788
- createExperimentBody = external_exports.object({
5789
- hub_id: external_exports.string().uuid(),
5790
- experiment_slug: slugSchema.optional(),
5791
- experiment_name: external_exports.string().min(1, "experiment_name is required").max(100, "experiment_name must be 100 characters or fewer"),
5792
- primary_metric: external_exports.string().max(200).nullish(),
5793
- status: experimentStatusSchema.default("draft")
5794
- });
5795
- updateExperimentBody = external_exports.object({
5796
- // experiment_slug is immutable after first persist — not accepted here.
5797
- experiment_name: external_exports.string().min(1).max(100).optional(),
5798
- primary_metric: external_exports.string().max(200).nullish(),
5799
- control_variant_id: external_exports.string().uuid().nullish()
5800
- });
5801
- setExperimentStatusBody = external_exports.object({
5802
- status: experimentStatusSchema
5803
- });
5804
- createVariantBody = external_exports.object({
5805
- hub_id: external_exports.string().uuid(),
5806
- experiment_id: external_exports.string().uuid(),
5807
- label: external_exports.string().min(1, "label is required").max(100, "label must be 100 characters or fewer"),
5808
- weight: external_exports.number().positive().default(1),
5809
- ai_mode: variantAiModeSchema.nullish(),
5810
- is_control: external_exports.boolean().default(false)
5811
- });
5812
- updateVariantBody = external_exports.object({
5813
- label: external_exports.string().min(1).max(100).optional(),
5814
- weight: external_exports.number().positive().optional(),
5815
- ai_mode: variantAiModeSchema.nullish(),
5816
- is_control: external_exports.boolean().optional()
5817
- });
5818
- upsertOverrideBody = external_exports.object({
5819
- hub_id: external_exports.string().uuid(),
5820
- variant_id: external_exports.string().uuid(),
5821
- agent_id: external_exports.string().uuid(),
5822
- instructions: external_exports.string().nullish(),
5823
- additional_context_template: external_exports.string().nullish(),
5824
- connection_id: external_exports.string().uuid().nullish(),
5825
- agent_settings_overlay: overlayUpdateSchema
5836
+ bootstrapQuery = external_exports.object({
5837
+ active_hub_id: external_exports.string().uuid().optional(),
5838
+ active_conversation_id: external_exports.string().uuid().optional(),
5839
+ active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
5840
+ /**
5841
+ * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
5842
+ * preloads it as `people.active_thread` when the viewer is a member.
5843
+ */
5844
+ active_thread_id: external_exports.string().uuid().optional()
5826
5845
  });
5827
5846
  }
5828
5847
  });
@@ -6084,7 +6103,7 @@ var init_chunk_T6D3YZ6B = __esm({
6084
6103
  }
6085
6104
  });
6086
6105
 
6087
- // ../../packages/core/dist/chunk-HBWJDXLP.js
6106
+ // ../../packages/core/dist/chunk-U6S4MZGT.js
6088
6107
  function boundCustomerPartyIsValid(audience, parties, customer) {
6089
6108
  return audience !== REKOR_PERSON_AUDIENCE_STAFF && customer < parties.length && Array.isArray(parties[customer]);
6090
6109
  }
@@ -6098,8 +6117,8 @@ function isEncodedBoundPerson(raw) {
6098
6117
  return rekorBoundPersonSchema.safeParse(parsed).success;
6099
6118
  }
6100
6119
  var TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, seedConnectionBindingSchema, rekorSeedBindingSchema, rekorToolsetToolsSchema, rekorPersonIdSchema, rekorPersonAudienceSchema, rekorBoundPersonSchema, STATED_GENERATION_PATTERN, rekorBoundAttestation, rekorSeedAttestation, rekorResolvedToolsetSchema, REKOR_TOOL_KINDS_PARAM, REKOR_TOOL_KINDS_RESOLVE_SEARCH, resolvedRecordTypeSchema, reviewWritersSchema, sharedScopeSchema, resolvedFileToolSchema, rekorToolsetFileSchema, rekorToolsetFileUrlAnswerSchema, rekorToolsetFileListSchema, rekorToolsetFileGetSchema, rekorToolsetFilePutSchema, TOOLSET_CUSTOMER_FACING_REFUSAL_MARK, TOOLSET_CUSTOMER_FACING_REFUSAL, BASE_TOOLSET_ONLY_FOR_CUSTOMER_FACING, GENERIC_DATA_MCP_CUSTOMER_FACING_REFUSAL, GENERIC_DATA_API_CUSTOMER_FACING_REFUSAL;
6101
- var init_chunk_HBWJDXLP = __esm({
6102
- "../../packages/core/dist/chunk-HBWJDXLP.js"() {
6120
+ var init_chunk_U6S4MZGT = __esm({
6121
+ "../../packages/core/dist/chunk-U6S4MZGT.js"() {
6103
6122
  "use strict";
6104
6123
  init_chunk_T6D3YZ6B();
6105
6124
  init_chunk_SDOG6762();
@@ -6389,12 +6408,12 @@ var init_chunk_HBWJDXLP = __esm({
6389
6408
  }
6390
6409
  });
6391
6410
 
6392
- // ../../packages/core/dist/chunk-CLYMQMQH.js
6411
+ // ../../packages/core/dist/chunk-JW6QQD5K.js
6393
6412
  var TOOLSET_ANSWER_PERSON_PARTIES, toolsetAnswerPersonSchema, toolsetAnswerPersonsSchema;
6394
- var init_chunk_CLYMQMQH = __esm({
6395
- "../../packages/core/dist/chunk-CLYMQMQH.js"() {
6413
+ var init_chunk_JW6QQD5K = __esm({
6414
+ "../../packages/core/dist/chunk-JW6QQD5K.js"() {
6396
6415
  "use strict";
6397
- init_chunk_HBWJDXLP();
6416
+ init_chunk_U6S4MZGT();
6398
6417
  init_chunk_SDOG6762();
6399
6418
  init_zod();
6400
6419
  TOOLSET_ANSWER_PERSON_PARTIES = ["requester", "originator", "initiator", "delegator"];
@@ -6476,6 +6495,231 @@ var init_chunk_ZC6YGHNX = __esm({
6476
6495
  }
6477
6496
  });
6478
6497
 
6498
+ // ../../packages/core/dist/chunk-2YEGUQR7.js
6499
+ var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
6500
+ var init_chunk_2YEGUQR7 = __esm({
6501
+ "../../packages/core/dist/chunk-2YEGUQR7.js"() {
6502
+ "use strict";
6503
+ init_zod();
6504
+ PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
6505
+ CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
6506
+ PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
6507
+ userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
6508
+ personIdSchema = external_exports.string().refine(
6509
+ (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
6510
+ { message: PERSON_ID_FORM_MESSAGE }
6511
+ );
6512
+ }
6513
+ });
6514
+
6515
+ // ../../packages/core/dist/chunk-UAOHHCW5.js
6516
+ function normalizeContactPhone(raw) {
6517
+ const compact = raw.trim().replace(/[\s\-.()]/g, "");
6518
+ const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
6519
+ return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
6520
+ }
6521
+ function normalizeContactLabel(raw) {
6522
+ return raw.trim().replace(/\s+/g, " ").toLowerCase();
6523
+ }
6524
+ function importRowLabels(row, batchLabels) {
6525
+ return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
6526
+ }
6527
+ var CONTACT_ENVIRONMENTS, CONTACT_NAME_MAX, CONTACT_EMAIL_MAX, CONTACT_PHONE_INPUT_MAX, CONTACT_INSTAGRAM_SID_MAX, CONTACT_METADATA_MAX_BYTES, CONTACT_LABEL_MAX, CONTACT_LABELS_MAX, CONTACT_SCOPE_TAGS_MAX, CONTACT_PAGE_MAX, CONTACT_IMPORT_BATCH_MAX, CONTACT_SEARCH_MAX, CONTACT_LIST_NAME_MAX, CONTACT_LIST_NAME_REGEX, CONTACT_LIST_DESCRIPTION_MAX, CONTACT_LIST_FILTER_MAX, CONTACT_LIST_PINS_PER_REQUEST_MAX, SUPPRESSION_SCOPES, SUPPRESSION_ID_REGEX, contactName, contactPhone, contactEmail, contactInstagramSid, contactLabel, contactLabels, contactMetadata, scopeTagIds, contactVisibilitySchema, hasIdentity, IDENTITY_REQUIRED, contactBookOrgQuery, contactBookContactParam, contactBookListParam, contactBookHubParam, contactBookPageQuery, listContactBookContactsQuery, listHubContactBookContactsQuery, contactBookLinkCandidatesQuery, listContactBookListMembersQuery, contactRowFields, createContactBookContactBody, updateContactBookContactBody, contactImportRowSchema, importContactBookContactsBody, linkContactBookContactBody, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
6528
+ var init_chunk_UAOHHCW5 = __esm({
6529
+ "../../packages/core/dist/chunk-UAOHHCW5.js"() {
6530
+ "use strict";
6531
+ init_zod();
6532
+ CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
6533
+ CONTACT_NAME_MAX = 200;
6534
+ CONTACT_EMAIL_MAX = 320;
6535
+ CONTACT_PHONE_INPUT_MAX = 40;
6536
+ CONTACT_INSTAGRAM_SID_MAX = 64;
6537
+ CONTACT_METADATA_MAX_BYTES = 4096;
6538
+ CONTACT_LABEL_MAX = 64;
6539
+ CONTACT_LABELS_MAX = 20;
6540
+ CONTACT_SCOPE_TAGS_MAX = 20;
6541
+ CONTACT_PAGE_MAX = 100;
6542
+ CONTACT_IMPORT_BATCH_MAX = 500;
6543
+ CONTACT_SEARCH_MAX = 100;
6544
+ CONTACT_LIST_NAME_MAX = 64;
6545
+ CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
6546
+ CONTACT_LIST_DESCRIPTION_MAX = 1e3;
6547
+ CONTACT_LIST_FILTER_MAX = 20;
6548
+ CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
6549
+ SUPPRESSION_SCOPES = ["all", "marketing"];
6550
+ SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
6551
+ contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
6552
+ contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
6553
+ const phone = normalizeContactPhone(raw);
6554
+ if (phone === null) {
6555
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
6556
+ return external_exports.NEVER;
6557
+ }
6558
+ return phone;
6559
+ });
6560
+ contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
6561
+ contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
6562
+ contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label2) => label2.length > 0, "A label cannot be empty").refine((label2) => !label2.includes(","), "A label cannot contain a comma");
6563
+ contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
6564
+ contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
6565
+ try {
6566
+ return new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES;
6567
+ } catch {
6568
+ return false;
6569
+ }
6570
+ }, `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`);
6571
+ scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
6572
+ contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
6573
+ external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
6574
+ external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
6575
+ ]);
6576
+ hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
6577
+ IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
6578
+ contactBookOrgQuery = external_exports.object({
6579
+ organization_id: external_exports.string().uuid()
6580
+ });
6581
+ contactBookContactParam = external_exports.object({
6582
+ contactId: external_exports.string().uuid()
6583
+ });
6584
+ contactBookListParam = external_exports.object({
6585
+ listId: external_exports.string().uuid()
6586
+ });
6587
+ contactBookHubParam = external_exports.object({
6588
+ hubId: external_exports.string().uuid()
6589
+ });
6590
+ contactBookPageQuery = external_exports.object({
6591
+ cursor: external_exports.string().max(2048).optional(),
6592
+ limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
6593
+ });
6594
+ listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
6595
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
6596
+ label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
6597
+ scope_tag_id: external_exports.string().uuid().optional()
6598
+ });
6599
+ listHubContactBookContactsQuery = contactBookPageQuery.extend({
6600
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
6601
+ });
6602
+ contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
6603
+ email: contactEmail
6604
+ });
6605
+ listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6606
+ contactRowFields = {
6607
+ name: contactName,
6608
+ phone: contactPhone.nullish(),
6609
+ email: contactEmail.nullish(),
6610
+ instagram_sid: contactInstagramSid.nullish(),
6611
+ labels: contactLabels.optional(),
6612
+ metadata: contactMetadata.optional()
6613
+ };
6614
+ createContactBookContactBody = external_exports.object({
6615
+ organization_id: external_exports.string().uuid(),
6616
+ ...contactRowFields,
6617
+ visibility: contactVisibilitySchema,
6618
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6619
+ }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6620
+ updateContactBookContactBody = external_exports.object({
6621
+ name: contactName.optional(),
6622
+ phone: contactPhone.nullable().optional(),
6623
+ email: contactEmail.nullable().optional(),
6624
+ instagram_sid: contactInstagramSid.nullable().optional(),
6625
+ labels: contactLabels.optional(),
6626
+ metadata: contactMetadata.optional(),
6627
+ visibility: contactVisibilitySchema.optional(),
6628
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6629
+ }).strict();
6630
+ contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6631
+ importContactBookContactsBody = external_exports.object({
6632
+ organization_id: external_exports.string().uuid(),
6633
+ visibility: contactVisibilitySchema,
6634
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
6635
+ labels: contactLabels.optional(),
6636
+ rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
6637
+ }).strict().superRefine((batch, ctx) => {
6638
+ batch.rows.forEach((row, index) => {
6639
+ if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
6640
+ ctx.addIssue({
6641
+ code: external_exports.ZodIssueCode.custom,
6642
+ path: ["rows", index, "labels"],
6643
+ message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
6644
+ });
6645
+ }
6646
+ });
6647
+ });
6648
+ linkContactBookContactBody = external_exports.object({
6649
+ user_id: external_exports.string().min(1).max(128)
6650
+ }).strict();
6651
+ listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
6652
+ message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
6653
+ });
6654
+ contactListFilterSchema = external_exports.object({
6655
+ labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
6656
+ scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
6657
+ }).strict();
6658
+ createContactBookListBody = external_exports.object({
6659
+ organization_id: external_exports.string().uuid(),
6660
+ name: listName,
6661
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
6662
+ filter: contactListFilterSchema.optional()
6663
+ }).strict();
6664
+ updateContactBookListBody = external_exports.object({
6665
+ name: listName.optional(),
6666
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
6667
+ filter: contactListFilterSchema.optional()
6668
+ }).strict();
6669
+ updateContactBookListPinsBody = external_exports.object({
6670
+ add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
6671
+ remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
6672
+ }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
6673
+ suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
6674
+ external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
6675
+ external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
6676
+ external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
6677
+ ]);
6678
+ createContactBookSuppressionBody = external_exports.object({
6679
+ organization_id: external_exports.string().uuid(),
6680
+ identity: suppressionIdentitySchema,
6681
+ scope: external_exports.enum(SUPPRESSION_SCOPES)
6682
+ }).strict();
6683
+ contactBookSuppressionParam = external_exports.object({
6684
+ suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
6685
+ });
6686
+ listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6687
+ contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
6688
+ contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
6689
+ orgListReferenceSchema = listName;
6690
+ }
6691
+ });
6692
+
6693
+ // ../../packages/core/dist/chunk-MGBAXT5Y.js
6694
+ var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery, conversationCustomerPersonParam;
6695
+ var init_chunk_MGBAXT5Y = __esm({
6696
+ "../../packages/core/dist/chunk-MGBAXT5Y.js"() {
6697
+ "use strict";
6698
+ init_chunk_2YEGUQR7();
6699
+ init_chunk_UAOHHCW5();
6700
+ init_zod();
6701
+ PERSON_LINKS_MAX = 15;
6702
+ PERSON_DENY_PAGE_MAX = 100;
6703
+ personParam = external_exports.object({
6704
+ personId: userPersonIdSchema
6705
+ });
6706
+ personLinkParam = personParam.extend({
6707
+ targetId: personIdSchema
6708
+ });
6709
+ deniedPersonParam = external_exports.object({
6710
+ personId: personIdSchema
6711
+ });
6712
+ listDeniedPersonsQuery = contactBookOrgQuery.extend({
6713
+ cursor: personIdSchema.optional(),
6714
+ limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
6715
+ });
6716
+ conversationCustomerPersonParam = external_exports.object({
6717
+ hubId: external_exports.string().uuid(),
6718
+ conversationId: external_exports.string().uuid()
6719
+ });
6720
+ }
6721
+ });
6722
+
6479
6723
  // ../../packages/core/dist/chunk-5DGHIY7L.js
6480
6724
  var rekorBaseChangeMessageSchema;
6481
6725
  var init_chunk_5DGHIY7L = __esm({
@@ -6521,7 +6765,7 @@ var init_chunk_5FO3GNKP = __esm({
6521
6765
  }
6522
6766
  });
6523
6767
 
6524
- // ../../packages/core/dist/chunk-DWJOFJEA.js
6768
+ // ../../packages/core/dist/chunk-EJRDF5B6.js
6525
6769
  function matchPath(pattern, path45) {
6526
6770
  const pathSegments2 = path45.replace(/\/$/, "").split("/");
6527
6771
  const isPrefix = pattern.endsWith("/*");
@@ -6550,8 +6794,8 @@ function getEndpointConfig(path45) {
6550
6794
  return { tier: "STANDARD" };
6551
6795
  }
6552
6796
  var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
6553
- var init_chunk_DWJOFJEA = __esm({
6554
- "../../packages/core/dist/chunk-DWJOFJEA.js"() {
6797
+ var init_chunk_EJRDF5B6 = __esm({
6798
+ "../../packages/core/dist/chunk-EJRDF5B6.js"() {
6555
6799
  "use strict";
6556
6800
  init_chunk_5FO3GNKP();
6557
6801
  ENDPOINT_CONFIGS = {
@@ -6881,6 +7125,9 @@ var init_chunk_DWJOFJEA = __esm({
6881
7125
  // takes the same strict, fail-closed budget as the other hub repairs. Exact path, for the same reason.
6882
7126
  "/api/admin/hubs/repair-knowledge-blobs": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6883
7127
  "/api/admin/hubs/repair-credential-links": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
7128
+ // The WayAI-host token clear (#5644 steps 6–7) deletes connections and org credentials, and its dry run fans out over
7129
+ // every hub of every org: the same strict, fail-closed budget.
7130
+ "/api/admin/hubs/clear-wayai-host-tokens": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6884
7131
  // The credentials-vault importer (wayai#5644 D2-M6) decrypts and moves an org's credentials, or puts them back:
6885
7132
  // strict and fail-closed like the hub repairs, with room for the re-runs a bounded run takes (`max_puts`).
6886
7133
  "/api/admin/vault-import/*": { tier: "STRICT", userLimit: 60, userWindow: 3600, failClosed: true, userLimitKey: "/api/admin/vault-import/*" },
@@ -7004,6 +7251,17 @@ var init_chunk_DWJOFJEA = __esm({
7004
7251
  // many members' clicks share, and STRICT's 5/min bucket is shared with sign-in. An exact key, so
7005
7252
  // it wins over the wildcard above.
7006
7253
  [COMMUNITY_EMAIL_UNSUBSCRIBE_PATH]: { tier: "MODERATE" },
7254
+ // Case spaces (wayai#5921, `cases/routes.ts`): every route under the mount shares one per-user
7255
+ // budget. Each is one person's page or write, at most a few hundred Durable Object reads (the
7256
+ // list of their spaces); a space's own limits are counted in its CaseDO. Every caller is a web
7257
+ // session, so the per-IP tier is skipped; the key is pinned because the paths carry org, space,
7258
+ // person and team ids.
7259
+ "/api/cases/*": {
7260
+ tier: "STANDARD",
7261
+ userLimit: 60,
7262
+ skipAuthenticatedUsers: true,
7263
+ userLimitKey: "/api/cases/*"
7264
+ },
7007
7265
  // The WayAI Guide's help entry (wayai#4948, `routes/api/guide.ts`): one POST per click by a viewer
7008
7266
  // the snapshot does not show enrolled, which reads the person's row on the Guide hub and writes only
7009
7267
  // what is missing (an enrolled viewer's click opens the hub without a request). Every caller is
@@ -7040,7 +7298,7 @@ var init_chunk_DWJOFJEA = __esm({
7040
7298
  }
7041
7299
  });
7042
7300
 
7043
- // ../../packages/core/dist/chunk-UVGO72D6.js
7301
+ // ../../packages/core/dist/chunk-2FWVCLBC.js
7044
7302
  function fileSnapshotChanged(run) {
7045
7303
  return run.written + run.removed > 0;
7046
7304
  }
@@ -7081,10 +7339,10 @@ async function sendWithRetry(opts, cursor) {
7081
7339
  }
7082
7340
  }
7083
7341
  var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
7084
- var init_chunk_UVGO72D6 = __esm({
7085
- "../../packages/core/dist/chunk-UVGO72D6.js"() {
7342
+ var init_chunk_2FWVCLBC = __esm({
7343
+ "../../packages/core/dist/chunk-2FWVCLBC.js"() {
7086
7344
  "use strict";
7087
- init_chunk_DWJOFJEA();
7345
+ init_chunk_EJRDF5B6();
7088
7346
  init_chunk_5FO3GNKP();
7089
7347
  init_zod();
7090
7348
  rekorFileSnapshotAnswerSchema = external_exports.object({
@@ -7345,22 +7603,41 @@ var init_chunk_PFGVH2CX = __esm({
7345
7603
  }
7346
7604
  });
7347
7605
 
7348
- // ../../packages/core/dist/chunk-GPM7PE44.js
7349
- var bootstrapQuery;
7350
- var init_chunk_GPM7PE44 = __esm({
7351
- "../../packages/core/dist/chunk-GPM7PE44.js"() {
7606
+ // ../../packages/core/dist/chunk-FPSDNS2E.js
7607
+ var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
7608
+ var init_chunk_FPSDNS2E = __esm({
7609
+ "../../packages/core/dist/chunk-FPSDNS2E.js"() {
7352
7610
  "use strict";
7353
7611
  init_zod();
7354
- bootstrapQuery = external_exports.object({
7355
- active_hub_id: external_exports.string().uuid().optional(),
7356
- active_conversation_id: external_exports.string().uuid().optional(),
7357
- active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
7358
- /**
7359
- * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
7360
- * preloads it as `people.active_thread` when the viewer is a member.
7361
- */
7362
- active_thread_id: external_exports.string().uuid().optional()
7612
+ noticeSeveritySchema = external_exports.enum(["critical", "warn", "info"]);
7613
+ noticeStatusSchema = external_exports.enum(["active", "resolved"]);
7614
+ NOTICE_SCOPE_REGEX = /^(global|provider:[a-z0-9_-]{1,40}|service:[a-z0-9_-]{1,40})$/;
7615
+ noticeScopeSchema = external_exports.string().regex(NOTICE_SCOPE_REGEX, "scope must be 'global', 'provider:<x>', or 'service:<x>'");
7616
+ noticeLinkSchema = external_exports.string().url().refine((u) => /^https?:\/\//i.test(u), { message: "link must be an http(s) URL" });
7617
+ createNoticeBody = external_exports.object({
7618
+ severity: noticeSeveritySchema.default("info"),
7619
+ scope: noticeScopeSchema.default("global"),
7620
+ title: external_exports.string().trim().min(1).max(200),
7621
+ body: external_exports.string().max(2e3).optional(),
7622
+ link: noticeLinkSchema.optional(),
7623
+ starts_at: external_exports.string().datetime().optional(),
7624
+ ends_at: external_exports.string().datetime().optional()
7625
+ });
7626
+ updateNoticeBody = external_exports.object({
7627
+ severity: noticeSeveritySchema.optional(),
7628
+ scope: noticeScopeSchema.optional(),
7629
+ title: external_exports.string().trim().min(1).max(200).optional(),
7630
+ body: external_exports.string().max(2e3).nullable().optional(),
7631
+ link: noticeLinkSchema.nullable().optional(),
7632
+ starts_at: external_exports.string().datetime().optional(),
7633
+ ends_at: external_exports.string().datetime().nullable().optional()
7634
+ }).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be provided" });
7635
+ listNoticesQuery = external_exports.object({
7636
+ status: noticeStatusSchema.optional(),
7637
+ limit: external_exports.coerce.number().int().min(1).max(200).optional(),
7638
+ offset: external_exports.coerce.number().int().min(0).optional()
7363
7639
  });
7640
+ noticeIdParamSchema = external_exports.object({ id: external_exports.string().min(1) });
7364
7641
  }
7365
7642
  });
7366
7643
 
@@ -7749,12 +8026,12 @@ var init_chunk_FBV7NLKO = __esm({
7749
8026
  }
7750
8027
  });
7751
8028
 
7752
- // ../../packages/core/dist/chunk-CHXSDXBE.js
8029
+ // ../../packages/core/dist/chunk-TSIH4Y2H.js
7753
8030
  var hubPageWatchParam, pageWatchedBaseSchema, hubPageWatchResponseSchema;
7754
- var init_chunk_CHXSDXBE = __esm({
7755
- "../../packages/core/dist/chunk-CHXSDXBE.js"() {
8031
+ var init_chunk_TSIH4Y2H = __esm({
8032
+ "../../packages/core/dist/chunk-TSIH4Y2H.js"() {
7756
8033
  "use strict";
7757
- init_chunk_HBWJDXLP();
8034
+ init_chunk_U6S4MZGT();
7758
8035
  init_chunk_FBV7NLKO();
7759
8036
  init_chunk_HZ6CADSY();
7760
8037
  init_zod();
@@ -7870,231 +8147,6 @@ var init_chunk_Y7CFCYX4 = __esm({
7870
8147
  }
7871
8148
  });
7872
8149
 
7873
- // ../../packages/core/dist/chunk-2YEGUQR7.js
7874
- var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
7875
- var init_chunk_2YEGUQR7 = __esm({
7876
- "../../packages/core/dist/chunk-2YEGUQR7.js"() {
7877
- "use strict";
7878
- init_zod();
7879
- PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
7880
- CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
7881
- PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
7882
- userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
7883
- personIdSchema = external_exports.string().refine(
7884
- (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
7885
- { message: PERSON_ID_FORM_MESSAGE }
7886
- );
7887
- }
7888
- });
7889
-
7890
- // ../../packages/core/dist/chunk-UAOHHCW5.js
7891
- function normalizeContactPhone(raw) {
7892
- const compact = raw.trim().replace(/[\s\-.()]/g, "");
7893
- const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
7894
- return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
7895
- }
7896
- function normalizeContactLabel(raw) {
7897
- return raw.trim().replace(/\s+/g, " ").toLowerCase();
7898
- }
7899
- function importRowLabels(row, batchLabels) {
7900
- return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
7901
- }
7902
- var CONTACT_ENVIRONMENTS, CONTACT_NAME_MAX, CONTACT_EMAIL_MAX, CONTACT_PHONE_INPUT_MAX, CONTACT_INSTAGRAM_SID_MAX, CONTACT_METADATA_MAX_BYTES, CONTACT_LABEL_MAX, CONTACT_LABELS_MAX, CONTACT_SCOPE_TAGS_MAX, CONTACT_PAGE_MAX, CONTACT_IMPORT_BATCH_MAX, CONTACT_SEARCH_MAX, CONTACT_LIST_NAME_MAX, CONTACT_LIST_NAME_REGEX, CONTACT_LIST_DESCRIPTION_MAX, CONTACT_LIST_FILTER_MAX, CONTACT_LIST_PINS_PER_REQUEST_MAX, SUPPRESSION_SCOPES, SUPPRESSION_ID_REGEX, contactName, contactPhone, contactEmail, contactInstagramSid, contactLabel, contactLabels, contactMetadata, scopeTagIds, contactVisibilitySchema, hasIdentity, IDENTITY_REQUIRED, contactBookOrgQuery, contactBookContactParam, contactBookListParam, contactBookHubParam, contactBookPageQuery, listContactBookContactsQuery, listHubContactBookContactsQuery, contactBookLinkCandidatesQuery, listContactBookListMembersQuery, contactRowFields, createContactBookContactBody, updateContactBookContactBody, contactImportRowSchema, importContactBookContactsBody, linkContactBookContactBody, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
7903
- var init_chunk_UAOHHCW5 = __esm({
7904
- "../../packages/core/dist/chunk-UAOHHCW5.js"() {
7905
- "use strict";
7906
- init_zod();
7907
- CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
7908
- CONTACT_NAME_MAX = 200;
7909
- CONTACT_EMAIL_MAX = 320;
7910
- CONTACT_PHONE_INPUT_MAX = 40;
7911
- CONTACT_INSTAGRAM_SID_MAX = 64;
7912
- CONTACT_METADATA_MAX_BYTES = 4096;
7913
- CONTACT_LABEL_MAX = 64;
7914
- CONTACT_LABELS_MAX = 20;
7915
- CONTACT_SCOPE_TAGS_MAX = 20;
7916
- CONTACT_PAGE_MAX = 100;
7917
- CONTACT_IMPORT_BATCH_MAX = 500;
7918
- CONTACT_SEARCH_MAX = 100;
7919
- CONTACT_LIST_NAME_MAX = 64;
7920
- CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
7921
- CONTACT_LIST_DESCRIPTION_MAX = 1e3;
7922
- CONTACT_LIST_FILTER_MAX = 20;
7923
- CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
7924
- SUPPRESSION_SCOPES = ["all", "marketing"];
7925
- SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
7926
- contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
7927
- contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
7928
- const phone = normalizeContactPhone(raw);
7929
- if (phone === null) {
7930
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
7931
- return external_exports.NEVER;
7932
- }
7933
- return phone;
7934
- });
7935
- contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
7936
- contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
7937
- contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label2) => label2.length > 0, "A label cannot be empty").refine((label2) => !label2.includes(","), "A label cannot contain a comma");
7938
- contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
7939
- contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
7940
- try {
7941
- return new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES;
7942
- } catch {
7943
- return false;
7944
- }
7945
- }, `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`);
7946
- scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
7947
- contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
7948
- external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
7949
- external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
7950
- ]);
7951
- hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
7952
- IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
7953
- contactBookOrgQuery = external_exports.object({
7954
- organization_id: external_exports.string().uuid()
7955
- });
7956
- contactBookContactParam = external_exports.object({
7957
- contactId: external_exports.string().uuid()
7958
- });
7959
- contactBookListParam = external_exports.object({
7960
- listId: external_exports.string().uuid()
7961
- });
7962
- contactBookHubParam = external_exports.object({
7963
- hubId: external_exports.string().uuid()
7964
- });
7965
- contactBookPageQuery = external_exports.object({
7966
- cursor: external_exports.string().max(2048).optional(),
7967
- limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
7968
- });
7969
- listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
7970
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
7971
- label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
7972
- scope_tag_id: external_exports.string().uuid().optional()
7973
- });
7974
- listHubContactBookContactsQuery = contactBookPageQuery.extend({
7975
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
7976
- });
7977
- contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
7978
- email: contactEmail
7979
- });
7980
- listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
7981
- contactRowFields = {
7982
- name: contactName,
7983
- phone: contactPhone.nullish(),
7984
- email: contactEmail.nullish(),
7985
- instagram_sid: contactInstagramSid.nullish(),
7986
- labels: contactLabels.optional(),
7987
- metadata: contactMetadata.optional()
7988
- };
7989
- createContactBookContactBody = external_exports.object({
7990
- organization_id: external_exports.string().uuid(),
7991
- ...contactRowFields,
7992
- visibility: contactVisibilitySchema,
7993
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
7994
- }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
7995
- updateContactBookContactBody = external_exports.object({
7996
- name: contactName.optional(),
7997
- phone: contactPhone.nullable().optional(),
7998
- email: contactEmail.nullable().optional(),
7999
- instagram_sid: contactInstagramSid.nullable().optional(),
8000
- labels: contactLabels.optional(),
8001
- metadata: contactMetadata.optional(),
8002
- visibility: contactVisibilitySchema.optional(),
8003
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
8004
- }).strict();
8005
- contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
8006
- importContactBookContactsBody = external_exports.object({
8007
- organization_id: external_exports.string().uuid(),
8008
- visibility: contactVisibilitySchema,
8009
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
8010
- labels: contactLabels.optional(),
8011
- rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
8012
- }).strict().superRefine((batch, ctx) => {
8013
- batch.rows.forEach((row, index) => {
8014
- if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
8015
- ctx.addIssue({
8016
- code: external_exports.ZodIssueCode.custom,
8017
- path: ["rows", index, "labels"],
8018
- message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
8019
- });
8020
- }
8021
- });
8022
- });
8023
- linkContactBookContactBody = external_exports.object({
8024
- user_id: external_exports.string().min(1).max(128)
8025
- }).strict();
8026
- listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
8027
- message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
8028
- });
8029
- contactListFilterSchema = external_exports.object({
8030
- labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
8031
- scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
8032
- }).strict();
8033
- createContactBookListBody = external_exports.object({
8034
- organization_id: external_exports.string().uuid(),
8035
- name: listName,
8036
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
8037
- filter: contactListFilterSchema.optional()
8038
- }).strict();
8039
- updateContactBookListBody = external_exports.object({
8040
- name: listName.optional(),
8041
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
8042
- filter: contactListFilterSchema.optional()
8043
- }).strict();
8044
- updateContactBookListPinsBody = external_exports.object({
8045
- add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
8046
- remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
8047
- }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
8048
- suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
8049
- external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
8050
- external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
8051
- external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
8052
- ]);
8053
- createContactBookSuppressionBody = external_exports.object({
8054
- organization_id: external_exports.string().uuid(),
8055
- identity: suppressionIdentitySchema,
8056
- scope: external_exports.enum(SUPPRESSION_SCOPES)
8057
- }).strict();
8058
- contactBookSuppressionParam = external_exports.object({
8059
- suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
8060
- });
8061
- listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
8062
- contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
8063
- contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
8064
- orgListReferenceSchema = listName;
8065
- }
8066
- });
8067
-
8068
- // ../../packages/core/dist/chunk-MGBAXT5Y.js
8069
- var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery, conversationCustomerPersonParam;
8070
- var init_chunk_MGBAXT5Y = __esm({
8071
- "../../packages/core/dist/chunk-MGBAXT5Y.js"() {
8072
- "use strict";
8073
- init_chunk_2YEGUQR7();
8074
- init_chunk_UAOHHCW5();
8075
- init_zod();
8076
- PERSON_LINKS_MAX = 15;
8077
- PERSON_DENY_PAGE_MAX = 100;
8078
- personParam = external_exports.object({
8079
- personId: userPersonIdSchema
8080
- });
8081
- personLinkParam = personParam.extend({
8082
- targetId: personIdSchema
8083
- });
8084
- deniedPersonParam = external_exports.object({
8085
- personId: personIdSchema
8086
- });
8087
- listDeniedPersonsQuery = contactBookOrgQuery.extend({
8088
- cursor: personIdSchema.optional(),
8089
- limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
8090
- });
8091
- conversationCustomerPersonParam = external_exports.object({
8092
- hubId: external_exports.string().uuid(),
8093
- conversationId: external_exports.string().uuid()
8094
- });
8095
- }
8096
- });
8097
-
8098
8150
  // ../../packages/core/dist/chunk-YUZFHVB2.js
8099
8151
  var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
8100
8152
  var init_chunk_YUZFHVB2 = __esm({
@@ -8541,41 +8593,18 @@ var init_chunk_34LE6P7E = __esm({
8541
8593
  }
8542
8594
  });
8543
8595
 
8544
- // ../../packages/core/dist/chunk-FPSDNS2E.js
8545
- var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
8546
- var init_chunk_FPSDNS2E = __esm({
8547
- "../../packages/core/dist/chunk-FPSDNS2E.js"() {
8596
+ // ../../packages/core/dist/chunk-IR2NOSI3.js
8597
+ var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
8598
+ var init_chunk_IR2NOSI3 = __esm({
8599
+ "../../packages/core/dist/chunk-IR2NOSI3.js"() {
8548
8600
  "use strict";
8601
+ init_chunk_HZ6CADSY();
8549
8602
  init_zod();
8550
- noticeSeveritySchema = external_exports.enum(["critical", "warn", "info"]);
8551
- noticeStatusSchema = external_exports.enum(["active", "resolved"]);
8552
- NOTICE_SCOPE_REGEX = /^(global|provider:[a-z0-9_-]{1,40}|service:[a-z0-9_-]{1,40})$/;
8553
- noticeScopeSchema = external_exports.string().regex(NOTICE_SCOPE_REGEX, "scope must be 'global', 'provider:<x>', or 'service:<x>'");
8554
- noticeLinkSchema = external_exports.string().url().refine((u) => /^https?:\/\//i.test(u), { message: "link must be an http(s) URL" });
8555
- createNoticeBody = external_exports.object({
8556
- severity: noticeSeveritySchema.default("info"),
8557
- scope: noticeScopeSchema.default("global"),
8558
- title: external_exports.string().trim().min(1).max(200),
8559
- body: external_exports.string().max(2e3).optional(),
8560
- link: noticeLinkSchema.optional(),
8561
- starts_at: external_exports.string().datetime().optional(),
8562
- ends_at: external_exports.string().datetime().optional()
8563
- });
8564
- updateNoticeBody = external_exports.object({
8565
- severity: noticeSeveritySchema.optional(),
8566
- scope: noticeScopeSchema.optional(),
8567
- title: external_exports.string().trim().min(1).max(200).optional(),
8568
- body: external_exports.string().max(2e3).nullable().optional(),
8569
- link: noticeLinkSchema.nullable().optional(),
8570
- starts_at: external_exports.string().datetime().optional(),
8571
- ends_at: external_exports.string().datetime().nullable().optional()
8572
- }).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be provided" });
8573
- listNoticesQuery = external_exports.object({
8574
- status: noticeStatusSchema.optional(),
8575
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
8576
- offset: external_exports.coerce.number().int().min(0).optional()
8577
- });
8578
- noticeIdParamSchema = external_exports.object({ id: external_exports.string().min(1) });
8603
+ adminSetGuideHubBody = external_exports.object({
8604
+ hub_id: uuidSchema,
8605
+ dry_run: external_exports.boolean().optional()
8606
+ }).strict();
8607
+ GUIDE_HUB_INELIGIBLE_REASON = "guide_hub_ineligible";
8579
8608
  }
8580
8609
  });
8581
8610
 
@@ -9042,6 +9071,29 @@ var init_chunk_KMAC3O3L = __esm({
9042
9071
  }
9043
9072
  });
9044
9073
 
9074
+ // ../../packages/core/dist/chunk-MH4O3YEX.js
9075
+ var stateOperationBody;
9076
+ var init_chunk_MH4O3YEX = __esm({
9077
+ "../../packages/core/dist/chunk-MH4O3YEX.js"() {
9078
+ "use strict";
9079
+ init_chunk_6TSQ5HXC();
9080
+ init_zod();
9081
+ stateOperationBody = external_exports.object({
9082
+ hub_id: external_exports.string().uuid(),
9083
+ operation: external_exports.enum(["get", "update", "set_path", "reset"]),
9084
+ state_slug: slugSchema,
9085
+ /**
9086
+ * Deprecated and ignored. Scope is derived from the hub's state definition.
9087
+ * Kept on the schema so legacy bodies still validate.
9088
+ */
9089
+ state_scope: external_exports.enum(["conversation", "user"]).optional(),
9090
+ updates: external_exports.record(external_exports.unknown()).optional(),
9091
+ path: external_exports.array(external_exports.string()).optional(),
9092
+ value: external_exports.unknown().optional()
9093
+ });
9094
+ }
9095
+ });
9096
+
9045
9097
  // ../../packages/core/dist/chunk-IBL7FANV.js
9046
9098
  var SUMMARIZATION_THRESHOLD_MIN, SUMMARIZATION_THRESHOLD_MAX;
9047
9099
  var init_chunk_IBL7FANV = __esm({
@@ -12582,21 +12634,6 @@ var init_chunk_C4HEZ7ZI = __esm({
12582
12634
  }
12583
12635
  });
12584
12636
 
12585
- // ../../packages/core/dist/chunk-IR2NOSI3.js
12586
- var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
12587
- var init_chunk_IR2NOSI3 = __esm({
12588
- "../../packages/core/dist/chunk-IR2NOSI3.js"() {
12589
- "use strict";
12590
- init_chunk_HZ6CADSY();
12591
- init_zod();
12592
- adminSetGuideHubBody = external_exports.object({
12593
- hub_id: uuidSchema,
12594
- dry_run: external_exports.boolean().optional()
12595
- }).strict();
12596
- GUIDE_HUB_INELIGIBLE_REASON = "guide_hub_ineligible";
12597
- }
12598
- });
12599
-
12600
12637
  // ../../packages/core/dist/chunk-YULHXJ5M.js
12601
12638
  var COMMUNITY_LESSON_TREE_MAX_BYTES, COMMUNITY_LESSON_LINK_PROTOCOLS, COMMUNITY_LESSON_TREE_TOO_LARGE_REASON, COMMUNITY_LESSON_TREE_TOO_DEEP_REASON, COMMUNITY_LESSON_LINE_PREFIX_TOO_WIDE_REASON, LINK_SCHEME;
12602
12639
  var init_chunk_YULHXJ5M = __esm({
@@ -12700,29 +12737,6 @@ var init_chunk_ACGAI25T = __esm({
12700
12737
  }
12701
12738
  });
12702
12739
 
12703
- // ../../packages/core/dist/chunk-MH4O3YEX.js
12704
- var stateOperationBody;
12705
- var init_chunk_MH4O3YEX = __esm({
12706
- "../../packages/core/dist/chunk-MH4O3YEX.js"() {
12707
- "use strict";
12708
- init_chunk_6TSQ5HXC();
12709
- init_zod();
12710
- stateOperationBody = external_exports.object({
12711
- hub_id: external_exports.string().uuid(),
12712
- operation: external_exports.enum(["get", "update", "set_path", "reset"]),
12713
- state_slug: slugSchema,
12714
- /**
12715
- * Deprecated and ignored. Scope is derived from the hub's state definition.
12716
- * Kept on the schema so legacy bodies still validate.
12717
- */
12718
- state_scope: external_exports.enum(["conversation", "user"]).optional(),
12719
- updates: external_exports.record(external_exports.unknown()).optional(),
12720
- path: external_exports.array(external_exports.string()).optional(),
12721
- value: external_exports.unknown().optional()
12722
- });
12723
- }
12724
- });
12725
-
12726
12740
  // ../../packages/core/dist/chunk-PZPOUXJR.js
12727
12741
  var navItemSchema, hubCountResetBody, navItemCountResetBody, typingBody;
12728
12742
  var init_chunk_PZPOUXJR = __esm({
@@ -12790,6 +12804,55 @@ var init_chunk_YWZFB34T = __esm({
12790
12804
  }
12791
12805
  });
12792
12806
 
12807
+ // ../../packages/core/dist/chunk-EEUXUSMH.js
12808
+ var CASE_SPACE_NAME_MAX_LENGTH, CASE_TEAM_NAME_MAX_LENGTH, CASE_TEAM_MEMBERS_MAX, CASE_MEMBERS_PAGE_MAX, CASE_PAGE_CURSOR_MAX_LENGTH, CASE_LEVELS, CASE_REGISTRY_CLOSED_REASON, caseSpaceNameSchema, adminCreateCaseSpaceBody, caseOrgParam, caseSpaceParam, caseMemberParam, caseAdministratorParam, caseTeamParam, casePageQuery, saveCaseMemberBody, caseTeamScopeSchema, caseTeamMemberInput, caseTeamFields, createCaseTeamBody, updateCaseTeamBody;
12809
+ var init_chunk_EEUXUSMH = __esm({
12810
+ "../../packages/core/dist/chunk-EEUXUSMH.js"() {
12811
+ "use strict";
12812
+ init_chunk_ZVXO3XL6();
12813
+ init_chunk_HZ6CADSY();
12814
+ init_zod();
12815
+ CASE_SPACE_NAME_MAX_LENGTH = 200;
12816
+ CASE_TEAM_NAME_MAX_LENGTH = 200;
12817
+ CASE_TEAM_MEMBERS_MAX = 1e3;
12818
+ CASE_MEMBERS_PAGE_MAX = 200;
12819
+ CASE_PAGE_CURSOR_MAX_LENGTH = 2048;
12820
+ CASE_LEVELS = ["read", "edit", "conduct"];
12821
+ CASE_REGISTRY_CLOSED_REASON = "case_registry_closed";
12822
+ caseSpaceNameSchema = external_exports.string().trim().min(1).max(CASE_SPACE_NAME_MAX_LENGTH);
12823
+ adminCreateCaseSpaceBody = external_exports.object({ org_id: uuidSchema, name: caseSpaceNameSchema }).strict();
12824
+ caseOrgParam = external_exports.object({ org_id: uuidSchema });
12825
+ caseSpaceParam = caseOrgParam.extend({ space_id: uuidSchema });
12826
+ caseMemberParam = caseSpaceParam.extend({ person_id: uuidSchema });
12827
+ caseAdministratorParam = caseSpaceParam.extend({ user_id: peopleUserIdSchema });
12828
+ caseTeamParam = caseSpaceParam.extend({ team_id: uuidSchema });
12829
+ casePageQuery = external_exports.object({
12830
+ limit: external_exports.coerce.number().int().min(1).max(CASE_MEMBERS_PAGE_MAX).optional(),
12831
+ cursor: external_exports.string().min(1).max(CASE_PAGE_CURSOR_MAX_LENGTH).optional()
12832
+ });
12833
+ saveCaseMemberBody = external_exports.object({
12834
+ user_id: peopleUserIdSchema,
12835
+ guest: external_exports.boolean().default(false),
12836
+ registry: external_exports.boolean().default(false)
12837
+ }).strict().refine((body) => !(body.guest && body.registry), { message: "A guest cannot hold the Registry flag", path: ["registry"] });
12838
+ caseTeamScopeSchema = external_exports.object({ kind: external_exports.literal("space"), target_id: external_exports.null() }).strict();
12839
+ caseTeamMemberInput = external_exports.object({
12840
+ person_id: uuidSchema,
12841
+ level: external_exports.enum(CASE_LEVELS),
12842
+ approve: external_exports.boolean(),
12843
+ confidential: external_exports.boolean()
12844
+ }).strict();
12845
+ caseTeamFields = {
12846
+ name: external_exports.string().trim().min(1).max(CASE_TEAM_NAME_MAX_LENGTH),
12847
+ active: external_exports.boolean(),
12848
+ scopes: external_exports.array(caseTeamScopeSchema).max(1),
12849
+ members: external_exports.array(caseTeamMemberInput).max(CASE_TEAM_MEMBERS_MAX)
12850
+ };
12851
+ createCaseTeamBody = external_exports.object(caseTeamFields).strict();
12852
+ updateCaseTeamBody = external_exports.object({ ...caseTeamFields, expected_updated_at: timestampSchema.optional() }).strict();
12853
+ }
12854
+ });
12855
+
12793
12856
  // ../../packages/core/dist/chunk-7CYHPF35.js
12794
12857
  var appMessageSenderType, appMessageReceiverType, apiChannelMessage, apiChannelMessageBody, appMessageBody, appMessageResponse;
12795
12858
  var init_chunk_7CYHPF35 = __esm({
@@ -13684,6 +13747,57 @@ var init_chunk_LBDH7LCG = __esm({
13684
13747
  }
13685
13748
  });
13686
13749
 
13750
+ // ../../packages/core/dist/chunk-D3EP4TDU.js
13751
+ var primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody;
13752
+ var init_chunk_D3EP4TDU = __esm({
13753
+ "../../packages/core/dist/chunk-D3EP4TDU.js"() {
13754
+ "use strict";
13755
+ init_chunk_HZ6CADSY();
13756
+ init_zod();
13757
+ primaryRegionSchema = external_exports.enum([
13758
+ "wnam",
13759
+ "enam",
13760
+ "sam",
13761
+ "weur",
13762
+ "eeur",
13763
+ "apac",
13764
+ "oc",
13765
+ "afr",
13766
+ "me"
13767
+ ]);
13768
+ placementSourceSchema = external_exports.enum([
13769
+ "hub_config",
13770
+ "org_config",
13771
+ "parent_cascade",
13772
+ "cf_colo",
13773
+ "country",
13774
+ "fallback",
13775
+ "unpinned"
13776
+ ]);
13777
+ orgIdParam = external_exports.object({
13778
+ id: uuidSchema
13779
+ });
13780
+ orgAdminIdParam = external_exports.object({
13781
+ id: uuidSchema,
13782
+ adminId: external_exports.string().min(1)
13783
+ });
13784
+ createOrganizationBody = external_exports.object({
13785
+ organization_name: external_exports.string().min(1, "organization_name is required"),
13786
+ // Write-once at creation; updateOrganizationBody does not accept this.
13787
+ primary_region: primaryRegionSchema.optional()
13788
+ });
13789
+ updateOrganizationBody = external_exports.object({
13790
+ organization_name: external_exports.string().min(1).optional(),
13791
+ organization_avatar_url: external_exports.string().url().nullable().optional(),
13792
+ timezone: external_exports.string().optional(),
13793
+ business_hours: external_exports.unknown().optional()
13794
+ }).passthrough();
13795
+ addOrgAdminBody = external_exports.object({
13796
+ user_email: external_exports.string().email("valid email is required")
13797
+ });
13798
+ }
13799
+ });
13800
+
13687
13801
  // ../../packages/core/dist/chunk-X5PZZVTS.js
13688
13802
  function isEventRelativeFollowupType(type) {
13689
13803
  return typeof type === "string" && EVENT_RELATIVE_FOLLOWUP_TYPES.includes(type);
@@ -14082,57 +14196,6 @@ var init_chunk_X5PZZVTS = __esm({
14082
14196
  }
14083
14197
  });
14084
14198
 
14085
- // ../../packages/core/dist/chunk-D3EP4TDU.js
14086
- var primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody;
14087
- var init_chunk_D3EP4TDU = __esm({
14088
- "../../packages/core/dist/chunk-D3EP4TDU.js"() {
14089
- "use strict";
14090
- init_chunk_HZ6CADSY();
14091
- init_zod();
14092
- primaryRegionSchema = external_exports.enum([
14093
- "wnam",
14094
- "enam",
14095
- "sam",
14096
- "weur",
14097
- "eeur",
14098
- "apac",
14099
- "oc",
14100
- "afr",
14101
- "me"
14102
- ]);
14103
- placementSourceSchema = external_exports.enum([
14104
- "hub_config",
14105
- "org_config",
14106
- "parent_cascade",
14107
- "cf_colo",
14108
- "country",
14109
- "fallback",
14110
- "unpinned"
14111
- ]);
14112
- orgIdParam = external_exports.object({
14113
- id: uuidSchema
14114
- });
14115
- orgAdminIdParam = external_exports.object({
14116
- id: uuidSchema,
14117
- adminId: external_exports.string().min(1)
14118
- });
14119
- createOrganizationBody = external_exports.object({
14120
- organization_name: external_exports.string().min(1, "organization_name is required"),
14121
- // Write-once at creation; updateOrganizationBody does not accept this.
14122
- primary_region: primaryRegionSchema.optional()
14123
- });
14124
- updateOrganizationBody = external_exports.object({
14125
- organization_name: external_exports.string().min(1).optional(),
14126
- organization_avatar_url: external_exports.string().url().nullable().optional(),
14127
- timezone: external_exports.string().optional(),
14128
- business_hours: external_exports.unknown().optional()
14129
- }).passthrough();
14130
- addOrgAdminBody = external_exports.object({
14131
- user_email: external_exports.string().email("valid email is required")
14132
- });
14133
- }
14134
- });
14135
-
14136
14199
  // ../../packages/core/dist/chunk-K5UAZWFF.js
14137
14200
  function byLocale(entry) {
14138
14201
  const shape = Object.fromEntries(SUPPORTED_LOCALES.map((locale) => [locale, entry.optional()]));
@@ -14171,7 +14234,7 @@ var init_chunk_K5UAZWFF = __esm({
14171
14234
  }
14172
14235
  });
14173
14236
 
14174
- // ../../packages/core/dist/chunk-MO23HUAX.js
14237
+ // ../../packages/core/dist/chunk-7NQZRSSJ.js
14175
14238
  function refineLaneReferences(val, ctx) {
14176
14239
  const lanes = val.lanes;
14177
14240
  const statuses = val.kanban_statuses;
@@ -14195,11 +14258,11 @@ function describeSyncWarning(warning) {
14195
14258
  return `${label2}: ${parts.join("; ")}. Promote the base so production's tools match the preview's.`;
14196
14259
  }
14197
14260
  var hubIdParam, hubAdminIdParam, hubUserIdParam, hubAgentIdParam, hubIdentityIdParam, hubTeamIdParam, hubTeamUserDeleteParam, hubSchemaQuery, HUB_USERS_PAGE_SIZE_MAX, HUB_USERS_SEARCH_MAX, HUB_USERS_CHANNEL_TYPES, getHubUsersQuery, PREVIEW_LABEL_MAX_LENGTH, MAX_ENDED_INDEX_RETENTION_DAYS, MAX_EVAL_RETENTION_DAYS, MAX_END_USER_DAILY_MESSAGE_LIMIT, endUserDailyMessageLimitField, previewLabelField, hubTagsField, createHubBody, updateHubBody, HUB_TAG_CHANGE_REFUSED, hubTagChangeRefusalSchema, addHubAdminBody, addHubIdentityAuthorizationBody, contactDecisionBody, approveContactBody, CONTACT_ACCESS_PAGE_SIZE_MAX, listContactAccessQuery, createHubTeamBody, updateHubTeamBody, addHubTeamUserBody, reassignHubUserBody, replicatePreviewBody, HUB_DIFF_SECTION_SET, HUB_DIFF_SECTIONS, updateChannelTestIdentitiesBody, claimCodeChannelParam, claimCodeDeleteParam;
14198
- var init_chunk_MO23HUAX = __esm({
14199
- "../../packages/core/dist/chunk-MO23HUAX.js"() {
14261
+ var init_chunk_7NQZRSSJ = __esm({
14262
+ "../../packages/core/dist/chunk-7NQZRSSJ.js"() {
14200
14263
  "use strict";
14201
- init_chunk_X5PZZVTS();
14202
14264
  init_chunk_D3EP4TDU();
14265
+ init_chunk_X5PZZVTS();
14203
14266
  init_chunk_K5UAZWFF();
14204
14267
  init_chunk_HZ6CADSY();
14205
14268
  init_zod();
@@ -14395,7 +14458,7 @@ var init_chunk_MO23HUAX = __esm({
14395
14458
  }
14396
14459
  });
14397
14460
 
14398
- // ../../packages/core/dist/chunk-KOLSAPLZ.js
14461
+ // ../../packages/core/dist/chunk-Z6H7PHIF.js
14399
14462
  function declaresNoConnection(agent) {
14400
14463
  return agent.connection === null && !agent.connection_id;
14401
14464
  }
@@ -15127,15 +15190,15 @@ function skillSectionsAsResources(scope) {
15127
15190
  };
15128
15191
  }
15129
15192
  var MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, MAX_HUB_AS_CODE_PAGE_MANIFEST_CHARS, hubAsCodePagesSchema, MAX_CALL_OPENING_CARRIERS, MAX_CALL_OPENING_AGGREGATE_ENCODED_BYTES, HUB_AS_CODE_AGENT_TOOL_KEYS, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, flagEntriesOf, boundedHubAsCodeResourcesSchema, isPlainObject, MIN_SKILLS_LAYOUT_CLI, MAX_HUB_AS_CODE_DEPTH, NAMED_DEPTH_SEGMENTS, NAMED_DEPTH_KEY_CHARS, fieldName, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, CI_APPLY_ENTITY_KINDS, CI_APPLY_OPERATIONS, ciApplyErrorBaseSchema, ciApplyErrorSchema, ciSyncCountSchema, ciSyncChangesSchema, ciSyncWarningSchema, ciSyncResponseSchema;
15130
- var init_chunk_KOLSAPLZ = __esm({
15131
- "../../packages/core/dist/chunk-KOLSAPLZ.js"() {
15193
+ var init_chunk_Z6H7PHIF = __esm({
15194
+ "../../packages/core/dist/chunk-Z6H7PHIF.js"() {
15132
15195
  "use strict";
15133
15196
  init_chunk_YI3ORIXJ();
15134
15197
  init_chunk_T6D3YZ6B();
15135
15198
  init_chunk_66EZQ7Y7();
15136
15199
  init_chunk_LBDH7LCG();
15137
15200
  init_chunk_4LXDRTO4();
15138
- init_chunk_MO23HUAX();
15201
+ init_chunk_7NQZRSSJ();
15139
15202
  init_chunk_X5PZZVTS();
15140
15203
  init_chunk_K5UAZWFF();
15141
15204
  init_chunk_L4YFOZGK();
@@ -15625,7 +15688,7 @@ var init_chunk_OMPT4ZHR = __esm({
15625
15688
  }
15626
15689
  });
15627
15690
 
15628
- // ../../packages/core/dist/chunk-I3PBCSF4.js
15691
+ // ../../packages/core/dist/chunk-377XFDXA.js
15629
15692
  function refineScopedTarget(data, ctx) {
15630
15693
  if (data.scope === "org") {
15631
15694
  if (!data.org_id) {
@@ -15650,14 +15713,14 @@ function refineScopedTarget(data, ctx) {
15650
15713
  }
15651
15714
  }
15652
15715
  }
15653
- 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, BRANCHING_ORPHAN_ENTITY_TYPES, BRANCHING_ORPHAN_MAX_TARGETS, adminRepairBranchingOrphansBody, adminRepairLegacyOrgGrantsBody, 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;
15654
- var init_chunk_I3PBCSF4 = __esm({
15655
- "../../packages/core/dist/chunk-I3PBCSF4.js"() {
15716
+ 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, 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;
15717
+ var init_chunk_377XFDXA = __esm({
15718
+ "../../packages/core/dist/chunk-377XFDXA.js"() {
15656
15719
  "use strict";
15657
15720
  init_chunk_FECLIZTY();
15658
15721
  init_chunk_BFG4ZWR4();
15659
15722
  init_chunk_2R5D4TEX();
15660
- init_chunk_MO23HUAX();
15723
+ init_chunk_7NQZRSSJ();
15661
15724
  init_chunk_OMPT4ZHR();
15662
15725
  init_chunk_HZ6CADSY();
15663
15726
  init_chunk_MIWZOSPI();
@@ -15844,6 +15907,17 @@ var init_chunk_I3PBCSF4 = __esm({
15844
15907
  });
15845
15908
  adminScopedTargetBody = adminScopedTargetShape.strict().superRefine(refineScopedTarget);
15846
15909
  adminDryRunByDefaultTargetBody = adminScopedTargetShape.extend({ dry_run: external_exports.boolean().optional().default(true) }).strict().superRefine(refineScopedTarget);
15910
+ WAYAI_HOST_TOKEN_TARGET_KINDS = ["toolset", "seed", "connection", "credential"];
15911
+ WAYAI_HOST_TOKEN_MAX_TARGETS = 50;
15912
+ adminClearWayaiHostTokensBody = adminScopedTargetShape.extend({
15913
+ dry_run: external_exports.boolean().optional().default(true),
15914
+ targets: external_exports.array(external_exports.object({ kind: external_exports.enum(WAYAI_HOST_TOKEN_TARGET_KINDS), id: external_exports.string().uuid() }).strict()).min(1).max(WAYAI_HOST_TOKEN_MAX_TARGETS).optional()
15915
+ }).strict().superRefine((data, ctx) => {
15916
+ refineScopedTarget(data, ctx);
15917
+ if (!data.dry_run && !data.targets) {
15918
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "dry_run: false requires targets", path: ["targets"] });
15919
+ }
15920
+ });
15847
15921
  BRANCHING_ORPHAN_ENTITY_TYPES = [
15848
15922
  "agent",
15849
15923
  "agent_parameter",
@@ -16436,6 +16510,7 @@ var init_contracts = __esm({
16436
16510
  "use strict";
16437
16511
  init_chunk_RACEDHG6();
16438
16512
  init_chunk_Q7KIQHAZ();
16513
+ init_chunk_IPXBFWUU();
16439
16514
  init_chunk_NKLVUTFO();
16440
16515
  init_chunk_WL5QGKHN();
16441
16516
  init_chunk_YVY2TZK2();
@@ -16443,47 +16518,47 @@ var init_contracts = __esm({
16443
16518
  init_chunk_HIGKBEPF();
16444
16519
  init_chunk_HA7CRZMX();
16445
16520
  init_chunk_MF2VVXBR();
16446
- init_chunk_IPXBFWUU();
16521
+ init_chunk_GPM7PE44();
16447
16522
  init_chunk_P5GJNS5R();
16448
- init_chunk_CLYMQMQH();
16523
+ init_chunk_JW6QQD5K();
16449
16524
  init_chunk_ZC6YGHNX();
16525
+ init_chunk_MGBAXT5Y();
16450
16526
  init_chunk_5DGHIY7L();
16451
- init_chunk_UVGO72D6();
16527
+ init_chunk_2FWVCLBC();
16452
16528
  init_chunk_IPDOHAZ5();
16453
16529
  init_chunk_PFGVH2CX();
16454
- init_chunk_GPM7PE44();
16455
- init_chunk_CHXSDXBE();
16456
- init_chunk_HBWJDXLP();
16530
+ init_chunk_FPSDNS2E();
16531
+ init_chunk_TSIH4Y2H();
16532
+ init_chunk_U6S4MZGT();
16457
16533
  init_chunk_ZXK6N2HN();
16458
16534
  init_chunk_Y7CFCYX4();
16459
- init_chunk_MGBAXT5Y();
16460
16535
  init_chunk_YUZFHVB2();
16461
16536
  init_chunk_I3O2RACG();
16462
16537
  init_chunk_CMRECH67();
16463
16538
  init_chunk_34LE6P7E();
16464
- init_chunk_FPSDNS2E();
16539
+ init_chunk_IR2NOSI3();
16465
16540
  init_chunk_OPETF4GS();
16466
16541
  init_chunk_SY6PLCPK();
16467
16542
  init_chunk_KMAC3O3L();
16543
+ init_chunk_MH4O3YEX();
16468
16544
  init_chunk_65MH4JRN();
16469
16545
  init_chunk_KSTYTQ7I();
16470
16546
  init_chunk_LKBSHANA();
16471
16547
  init_chunk_I2EVH3FR();
16472
16548
  init_chunk_C4HEZ7ZI();
16473
- init_chunk_IR2NOSI3();
16474
16549
  init_chunk_UCYWGWQT();
16475
16550
  init_chunk_6AYIXGDT();
16476
16551
  init_chunk_YULHXJ5M();
16477
16552
  init_chunk_V4FRPRH5();
16478
16553
  init_chunk_LWMLR2WI();
16479
16554
  init_chunk_ACGAI25T();
16480
- init_chunk_MH4O3YEX();
16481
16555
  init_chunk_YWZFB34T();
16482
16556
  init_chunk_PZPOUXJR();
16483
16557
  init_chunk_E4DIIOOE();
16558
+ init_chunk_EEUXUSMH();
16484
16559
  init_chunk_7CYHPF35();
16485
16560
  init_chunk_NETRUHZF();
16486
- init_chunk_KOLSAPLZ();
16561
+ init_chunk_Z6H7PHIF();
16487
16562
  init_chunk_YI3ORIXJ();
16488
16563
  init_chunk_T6D3YZ6B();
16489
16564
  init_chunk_66EZQ7Y7();
@@ -16493,13 +16568,13 @@ var init_contracts = __esm({
16493
16568
  init_chunk_4LXDRTO4();
16494
16569
  init_chunk_JDJ4EUOL();
16495
16570
  init_chunk_NVKU5PPQ();
16496
- init_chunk_I3PBCSF4();
16571
+ init_chunk_377XFDXA();
16497
16572
  init_chunk_FECLIZTY();
16498
16573
  init_chunk_BFG4ZWR4();
16499
16574
  init_chunk_2R5D4TEX();
16500
- init_chunk_MO23HUAX();
16501
- init_chunk_X5PZZVTS();
16575
+ init_chunk_7NQZRSSJ();
16502
16576
  init_chunk_D3EP4TDU();
16577
+ init_chunk_X5PZZVTS();
16503
16578
  init_chunk_K5UAZWFF();
16504
16579
  init_chunk_2PZIF56U();
16505
16580
  init_chunk_UEJOG2Q7();
@@ -16510,7 +16585,7 @@ var init_contracts = __esm({
16510
16585
  init_chunk_L4YFOZGK();
16511
16586
  init_chunk_ULQGJUXZ();
16512
16587
  init_chunk_OMPT4ZHR();
16513
- init_chunk_DWJOFJEA();
16588
+ init_chunk_EJRDF5B6();
16514
16589
  init_chunk_SOJMWM63();
16515
16590
  init_chunk_WTOA3ANF();
16516
16591
  init_chunk_5FO3GNKP();
@@ -16674,7 +16749,7 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
16674
16749
  var init_dist = __esm({
16675
16750
  "../../packages/core/dist/index.js"() {
16676
16751
  "use strict";
16677
- init_chunk_DWJOFJEA();
16752
+ init_chunk_EJRDF5B6();
16678
16753
  init_chunk_SOJMWM63();
16679
16754
  init_chunk_WTOA3ANF();
16680
16755
  init_chunk_5FO3GNKP();
@@ -17919,6 +17994,7 @@ var init_utils = __esm({
17919
17994
  ["admin hubs repair-branching-orphans", { positionals: 0, values: ["--org", "--hub", "--id"], dryRun: true }],
17920
17995
  ["admin hubs repair-credential-links", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
17921
17996
  ["admin hubs repair-knowledge-blobs", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
17997
+ ["admin hubs clear-wayai-host-tokens", { positionals: 0, values: ["--org", "--hub", "--id"], dryRun: true }],
17922
17998
  ["admin orgs repair-legacy-grants", { positionals: 0, values: ["--org"], dryRun: true }],
17923
17999
  ["admin vault import", { positionals: 0, values: ["--org", "--connector", "--max-puts", "--approved"] }],
17924
18000
  ["admin vault revert", { positionals: 0, values: ["--org", "--connector"] }],
@@ -17933,6 +18009,7 @@ var init_utils = __esm({
17933
18009
  ["admin cases enable", { positionals: 0 }],
17934
18010
  ["admin cases disable", { positionals: 0 }],
17935
18011
  ["admin cases status", { positionals: 0 }],
18012
+ ["admin cases create", { positionals: 0, values: ["--org", "--name"] }],
17936
18013
  ["admin communities enable", { positionals: 0 }],
17937
18014
  ["admin communities disable", { positionals: 0 }],
17938
18015
  ["admin communities status", { positionals: 0 }],
@@ -18455,6 +18532,10 @@ var init_api_client = __esm({
18455
18532
  async adminRepairCredentialLinks(body) {
18456
18533
  return this.request("POST", "/api/admin/hubs/repair-credential-links", body);
18457
18534
  }
18535
+ // Used by `wayai admin hubs clear-wayai-host-tokens` (platform-admin gated, wayai#5644 steps 6-7).
18536
+ async adminClearWayaiHostTokens(body) {
18537
+ return this.request("POST", "/api/admin/hubs/clear-wayai-host-tokens", body);
18538
+ }
18458
18539
  // Report twin candidates, or delete named production rows no preview maps (#4577).
18459
18540
  // Used by `wayai admin hubs repair-branching-orphans` (platform-admin gated).
18460
18541
  async adminRepairBranchingOrphans(body) {
@@ -18482,6 +18563,11 @@ var init_api_client = __esm({
18482
18563
  async adminCreateCommunity(body) {
18483
18564
  return this.request("POST", "/api/admin/communities", body);
18484
18565
  }
18566
+ // Create an org's case space (platform-admin gated, wayai#5921). Used by
18567
+ // `wayai admin cases create`.
18568
+ async adminCreateCaseSpace(body) {
18569
+ return this.request("POST", "/api/admin/cases/spaces", body);
18570
+ }
18485
18571
  // Destroy an org-owned community (platform-admin gated, gh #4872). Used by
18486
18572
  // `wayai admin communities destroy`.
18487
18573
  async adminDestroyCommunity(communityId) {
@@ -22927,7 +23013,7 @@ var init_hub_materializer = __esm({
22927
23013
  var init_ci = __esm({
22928
23014
  "../../packages/core/dist/contracts/ci.js"() {
22929
23015
  "use strict";
22930
- init_chunk_KOLSAPLZ();
23016
+ init_chunk_Z6H7PHIF();
22931
23017
  init_chunk_YI3ORIXJ();
22932
23018
  init_chunk_T6D3YZ6B();
22933
23019
  init_chunk_66EZQ7Y7();
@@ -22935,9 +23021,9 @@ var init_ci = __esm({
22935
23021
  init_chunk_2YEGUQR7();
22936
23022
  init_chunk_LBDH7LCG();
22937
23023
  init_chunk_4LXDRTO4();
22938
- init_chunk_MO23HUAX();
22939
- init_chunk_X5PZZVTS();
23024
+ init_chunk_7NQZRSSJ();
22940
23025
  init_chunk_D3EP4TDU();
23026
+ init_chunk_X5PZZVTS();
22941
23027
  init_chunk_K5UAZWFF();
22942
23028
  init_chunk_L4YFOZGK();
22943
23029
  init_chunk_WTOA3ANF();
@@ -38118,6 +38204,9 @@ async function adminCommand(args2) {
38118
38204
  case "repair-knowledge-blobs":
38119
38205
  await runRepairKnowledgeBlobs(flagArgs);
38120
38206
  return;
38207
+ case "clear-wayai-host-tokens":
38208
+ await runClearWayaiHostTokens(flagArgs);
38209
+ return;
38121
38210
  default:
38122
38211
  printHelp2();
38123
38212
  process.exit(1);
@@ -38215,6 +38304,9 @@ async function adminCommand(args2) {
38215
38304
  case "status":
38216
38305
  await runPlatformGateStatus(CASES_GATE, flagArgs);
38217
38306
  return;
38307
+ case "create":
38308
+ await runCasesCreate(flagArgs);
38309
+ return;
38218
38310
  default:
38219
38311
  printHelp2();
38220
38312
  process.exit(1);
@@ -38798,6 +38890,90 @@ async function runRepairCredentialLinks(flagArgs) {
38798
38890
  console.log(` hub=${r.hub_id} connection=${r.connection_id} credential=${r.credential_id}: ${r.outcome}${reason}${stale}${written}`);
38799
38891
  }
38800
38892
  }
38893
+ async function runClearWayaiHostTokens(flagArgs) {
38894
+ const USAGE8 = "wayai admin hubs clear-wayai-host-tokens --all | --org <org_id> | --hub <hub_id> [--id <kind>:<id> ...] [--apply] [--yes] [--json]";
38895
+ const targets = [];
38896
+ const scopeArgs = [];
38897
+ for (let i = 0; i < flagArgs.length; i++) {
38898
+ if (flagArgs[i] !== "--id") {
38899
+ scopeArgs.push(flagArgs[i]);
38900
+ continue;
38901
+ }
38902
+ const raw = requireFlagValue(flagArgs, ++i, "--id");
38903
+ const sep9 = raw.indexOf(":");
38904
+ const kind = raw.slice(0, sep9);
38905
+ const id = raw.slice(sep9 + 1);
38906
+ if (sep9 < 1 || !uuidSchema.safeParse(id).success || !WAYAI_HOST_TOKEN_TARGET_KINDS.includes(kind)) {
38907
+ console.error(`--id takes <kind>:<id>, with kind one of: ${WAYAI_HOST_TOKEN_TARGET_KINDS.join(", ")}. Got: ${raw}`);
38908
+ process.exit(1);
38909
+ }
38910
+ targets.push({ kind, id });
38911
+ }
38912
+ const { body, targetLabel, apply, yes, jsonOutput } = parseApplyTargetFlags(scopeArgs, USAGE8);
38913
+ if (apply && targets.length === 0) {
38914
+ console.error("--apply acts only on the targets named with --id <kind>:<id>, as the dry run lists them.");
38915
+ console.error(USAGE8);
38916
+ process.exit(1);
38917
+ }
38918
+ if (apply && !yes && !jsonOutput) {
38919
+ console.log(`About to clear or DELETE ${targets.length} named target(s) in: ${targetLabel}:`);
38920
+ for (const t of targets) console.log(` ${t.kind}:${t.id}`);
38921
+ console.log("Each is judged again first, and skipped with its reason when it no longer qualifies.");
38922
+ console.log("Run without --apply first to see what each would do.");
38923
+ const ok = await confirm("Proceed?");
38924
+ if (!ok) {
38925
+ console.log("Aborted.");
38926
+ return;
38927
+ }
38928
+ }
38929
+ const { config, accessToken } = await requireAuth();
38930
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
38931
+ let response;
38932
+ try {
38933
+ response = await client.adminClearWayaiHostTokens({ ...body, dry_run: !apply, ...targets.length > 0 ? { targets } : {} });
38934
+ } catch (err) {
38935
+ exitOnApiError(err);
38936
+ throw err;
38937
+ }
38938
+ const data = response.data;
38939
+ if (jsonOutput) {
38940
+ console.log(JSON.stringify(data, null, 2));
38941
+ return;
38942
+ }
38943
+ const mode = data.dry_run ? "DRY RUN \u2014 nothing written" : "written";
38944
+ console.log(
38945
+ `clear-wayai-host-tokens (${data.scope}) \u2014 ${mode}: hubs_scanned=${data.hubs_scanned} candidates=${data.candidates.length} credentials=${data.credentials.length}`
38946
+ );
38947
+ if (data.hubs_errored > 0 || data.orgs_errored > 0) {
38948
+ console.log(
38949
+ `WARNING: ${data.orgs_errored} org(s) and ${data.hubs_errored} hub(s) errored and were SKIPPED \u2014 re-run to cover them.`
38950
+ );
38951
+ }
38952
+ for (const c of data.candidates) {
38953
+ const facts = [
38954
+ c.kind,
38955
+ c.hub_environment ?? "hub?",
38956
+ c.host ? `host=${c.host}` : null,
38957
+ c.stores_ciphertext ? "stores_token" : null,
38958
+ c.organization_credential_id ? `credential=${c.organization_credential_id}` : null,
38959
+ c.linked_credential_ids.length > 0 ? `links=${c.linked_credential_ids.join(",")}` : null,
38960
+ c.seed_base_id ? `bound_base=${c.seed_base_id}` : null,
38961
+ c.seeded_bases.length > 0 ? `seeds=${c.seeded_bases.join(",")}` : null,
38962
+ c.mapped_by.length > 0 ? `mapped_by=${c.mapped_by.join(",")}` : null,
38963
+ c.referenced_by.length > 0 ? `referenced_by=${c.referenced_by.join(",")}` : null
38964
+ ].filter(Boolean).join(" ");
38965
+ console.log(` ${c.target} org=${c.org_id} hub=${c.hub_id} ${facts} -> ${c.action ?? `none (${c.reason})`}`);
38966
+ }
38967
+ for (const c of data.credentials) {
38968
+ console.log(
38969
+ ` ${c.target} org=${c.org_id} named_by=${c.named_by.join(",") || "-"} linked_by=${c.linked_by.join(",") || "-"} base_links=${c.base_links} -> ${c.action ?? `none (${c.reason})`}`
38970
+ );
38971
+ }
38972
+ for (const r of data.results) {
38973
+ const why = r.reason ? ` (${r.reason}${r.detail ? `: ${r.detail}` : ""})` : "";
38974
+ console.log(` ${r.outcome.padEnd(12)} ${r.kind}:${r.id}${why}`);
38975
+ }
38976
+ }
38801
38977
  function printCustomerReport(customer, dryRun) {
38802
38978
  const c = customer.census;
38803
38979
  const auth = Object.entries(c.by_auth).map(([k, n]) => `${k}=${n}`).join(" ") || "-";
@@ -39345,6 +39521,60 @@ async function runCasesToggle(enable, flagArgs) {
39345
39521
  await runPlatformGateToggle(CASES_GATE, enable, flagArgs);
39346
39522
  console.log(PLATFORM_CONFIG_PROPAGATION_NOTE);
39347
39523
  }
39524
+ async function runCasesCreate(flagArgs) {
39525
+ const usage3 = "wayai admin cases create --org <org_id> --name <name> [--json]";
39526
+ let orgId;
39527
+ let name;
39528
+ let jsonOutput = false;
39529
+ for (let i = 0; i < flagArgs.length; i++) {
39530
+ const flag = flagArgs[i];
39531
+ if (flag === "--org") {
39532
+ orgId = requireFlagValue(flagArgs, i + 1, "--org");
39533
+ i++;
39534
+ } else if (flag === "--name") {
39535
+ name = requireFlagValue(flagArgs, i + 1, "--name");
39536
+ i++;
39537
+ } else if (flag === "--json") {
39538
+ jsonOutput = true;
39539
+ } else {
39540
+ console.error(`Unknown flag: ${flag}`);
39541
+ console.error(usage3);
39542
+ process.exit(1);
39543
+ }
39544
+ }
39545
+ const parsed = adminCreateCaseSpaceBody.safeParse({ org_id: orgId, name });
39546
+ if (!parsed.success) {
39547
+ console.error(parsed.error.issues.map((issue) => `--${issue.path[0] === "org_id" ? "org" : issue.path[0]}: ${issue.message}`).join("\n"));
39548
+ console.error(usage3);
39549
+ process.exit(1);
39550
+ }
39551
+ const { config, accessToken } = await requireAuth();
39552
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
39553
+ let data;
39554
+ try {
39555
+ data = (await client.adminCreateCaseSpace(parsed.data)).data;
39556
+ } catch (err) {
39557
+ if (err instanceof ApiError && err.status === 404) {
39558
+ console.error(`Organization ${parsed.data.org_id} not found.`);
39559
+ process.exit(1);
39560
+ }
39561
+ if (err instanceof ApiError && err.status === 409) {
39562
+ console.error(conflictReasonOf(err) === CASE_REGISTRY_CLOSED_REASON ? `A deletion of organization ${parsed.data.org_id} closed it to new case spaces.` : "The organization already holds as many case spaces as it may (`wayai admin config` cases_spaces_per_org_max).");
39563
+ process.exit(1);
39564
+ }
39565
+ if (err instanceof ApiError && err.status === 503) {
39566
+ console.error(errorCodeOf(err.body) === "TRANSIENT_STORAGE" ? `The platform was briefly unavailable, and the case space may have been created. Check organization ${parsed.data.org_id}'s case spaces before running the command again.` : "The case space was not created in time. Run the command again.");
39567
+ process.exit(1);
39568
+ }
39569
+ exitOnApiError(err);
39570
+ throw err;
39571
+ }
39572
+ if (jsonOutput) {
39573
+ console.log(JSON.stringify(data, null, 2));
39574
+ return;
39575
+ }
39576
+ console.log(`Created case space ${data.space_id} \u2014 "${data.name}", of organization ${data.org_id}. Its owner administers it.`);
39577
+ }
39348
39578
  async function runCommunitiesToggle(enable, flagArgs) {
39349
39579
  await runPlatformGateToggle(COMMUNITIES_GATE, enable, flagArgs);
39350
39580
  if (enable) {
@@ -40294,6 +40524,9 @@ Usage:
40294
40524
  wayai admin hubs repair-knowledge-blobs --all | --org <org_id> | --hub <hub_id> [--apply] [--yes] [--json]
40295
40525
  Report, or with --apply delete, the R2 objects under each hub no file row holds (retired knowledge's, #5142), older than a day; never eval attachments or call openings. A dry run by default. Run it once the deploy that retired knowledge is fully live: a hub on older code stops on its first page, as errored
40296
40526
 
40527
+ wayai admin hubs clear-wayai-host-tokens --all | --org <org_id> | --hub <hub_id> [--id <kind>:<id> ...] [--apply] [--yes] [--json]
40528
+ List the WayAI tokens hub connections and org credentials still hold (#5644), each with what --id <kind>:<id> would do: clear a Base Toolset connection's stored token and org credential link (toolset), clear a bound eval seed connection's token (seed), delete another connection to WayAI's data service (connection), delete an org credential nothing links any more (credential). A dry run by default; --apply acts only on the --id targets, each judged again first
40529
+
40297
40530
  wayai admin orgs repair-legacy-grants --all | --org <org_id> [--dry-run] [--yes] [--json]
40298
40531
  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
40299
40532
 
@@ -40322,6 +40555,8 @@ Usage:
40322
40555
  wayai admin cases enable Flip the platform cases_enabled kill switch ON
40323
40556
  wayai admin cases disable Flip it OFF
40324
40557
  wayai admin cases status Print the kill switch
40558
+ wayai admin cases create --org <org_id> --name <name> [--json]
40559
+ Create a case space of the org, which its owner administers; works while the switch is OFF
40325
40560
 
40326
40561
  wayai admin communities enable Flip the platform communities_enabled kill switch ON (members reach communities while threads is ON too)
40327
40562
  wayai admin communities disable Flip it OFF: no member reaches a community
@@ -40404,6 +40639,11 @@ Sources:
40404
40639
  \`repair-knowledge-blobs\` sweeps the R2 objects retired hub knowledge left
40405
40640
  behind once its rows were deleted: keys no file row holds, older than a
40406
40641
  day. It reports by default and deletes only with --apply.
40642
+ \`clear-wayai-host-tokens\` clears the WayAI tokens hub connections still store
40643
+ (#5644): it lists every candidate and what it would do, and acts only on
40644
+ the targets --id names, with --apply. A seed's token goes only once it records
40645
+ its binding; a production row goes only once no preview maps it and nothing
40646
+ points at it.
40407
40647
  orgs Org roster repair. \`repair-legacy-grants\` fixes member_grant rows the
40408
40648
  platform-admin org-admin add wrote before #3922: the email landed in the
40409
40649
  user_id column with user_email NULL. Auth reads UserDO, never member_grant,
@@ -40434,7 +40674,8 @@ Sources:
40434
40674
  about 60 s.
40435
40675
  cases The cases gate, default-deny: the PLATFORM-wide cases_enabled switch
40436
40676
  (\`enable\`/\`disable\`), independent of threads. Changes land within about
40437
- 60 s.
40677
+ 60 s. \`create\` makes an org's case space, whichever way the switch is set;
40678
+ deleting an org destroys its spaces too.
40438
40679
  communities Org-owned communities. \`enable\`/\`disable\` flip the PLATFORM-wide
40439
40680
  communities_enabled switch, default-deny and nested in threads: members
40440
40681
  reach a community only while both switches are on. \`create\` makes a
@@ -40477,6 +40718,8 @@ Examples:
40477
40718
  wayai admin hubs repair-branching-orphans --hub <prod-hub-id> --id connection:<id> --dry-run
40478
40719
  wayai admin hubs repair-knowledge-blobs --all
40479
40720
  wayai admin hubs repair-knowledge-blobs --hub <hub-id> --apply
40721
+ wayai admin hubs clear-wayai-host-tokens --all
40722
+ wayai admin hubs clear-wayai-host-tokens --org <org-id> --id toolset:<connection-id> --id credential:<credential-id> --apply
40480
40723
  wayai admin orgs repair-legacy-grants --all --dry-run
40481
40724
  wayai admin orgs repair-legacy-grants --org <org-id> --yes
40482
40725
  wayai admin harness disable