@wayai/cli 0.3.264 → 0.3.265

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
@@ -4888,6 +4888,37 @@ var init_fs_safety = __esm({
4888
4888
  }
4889
4889
  });
4890
4890
 
4891
+ // ../../packages/core/dist/chunk-NKLVUTFO.js
4892
+ var BASE_CREDENTIAL_MANAGED_BY, BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema, createBaseCredentialLinkBody, baseCredentialLinkParams, baseCredentialLinkQuery;
4893
+ var init_chunk_NKLVUTFO = __esm({
4894
+ "../../packages/core/dist/chunk-NKLVUTFO.js"() {
4895
+ "use strict";
4896
+ init_zod();
4897
+ BASE_CREDENTIAL_MANAGED_BY = {
4898
+ DIRECT: "direct",
4899
+ ORG_LINK: "org-link"
4900
+ };
4901
+ BASE_CREDENTIAL_NAME_MAX = 100;
4902
+ BASE_CREDENTIAL_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@+~=-]*$/;
4903
+ BASE_CREDENTIAL_NAME_CHARSET = "letters, digits and '. _ : @ + ~ = -', starting with a letter or digit";
4904
+ baseCredentialNameSchema = external_exports.string().min(1).max(BASE_CREDENTIAL_NAME_MAX).regex(BASE_CREDENTIAL_NAME_PATTERN, `name must use ${BASE_CREDENTIAL_NAME_CHARSET}`);
4905
+ createBaseCredentialLinkBody = external_exports.object({
4906
+ organization_id: external_exports.string().uuid(),
4907
+ base_id: external_exports.string().min(1),
4908
+ /** Defaults to a slug derived from the credential's display name. */
4909
+ name: baseCredentialNameSchema.optional()
4910
+ });
4911
+ baseCredentialLinkParams = external_exports.object({
4912
+ id: external_exports.string().uuid(),
4913
+ base_credential_id: external_exports.string().min(1)
4914
+ });
4915
+ baseCredentialLinkQuery = external_exports.object({
4916
+ organization_id: external_exports.string().uuid(),
4917
+ base_id: external_exports.string().min(1)
4918
+ });
4919
+ }
4920
+ });
4921
+
4891
4922
  // ../../packages/core/dist/chunk-HZ6CADSY.js
4892
4923
  function optionalTrimmedText(max) {
4893
4924
  return external_exports.string().trim().max(max).optional().transform((value) => value ? value : void 0);
@@ -5416,6 +5447,19 @@ var init_chunk_Q7KIQHAZ = __esm({
5416
5447
  }
5417
5448
  });
5418
5449
 
5450
+ // ../../packages/core/dist/chunk-HIGKBEPF.js
5451
+ var accessExplainQuery;
5452
+ var init_chunk_HIGKBEPF = __esm({
5453
+ "../../packages/core/dist/chunk-HIGKBEPF.js"() {
5454
+ "use strict";
5455
+ init_chunk_HZ6CADSY();
5456
+ init_zod();
5457
+ accessExplainQuery = external_exports.object({
5458
+ user_id: external_exports.string().regex(USER_ID_REGEX).optional()
5459
+ });
5460
+ }
5461
+ });
5462
+
5419
5463
  // ../../packages/core/dist/chunk-HA7CRZMX.js
5420
5464
  var connectionIdParam, connectorIdParam, listConnectionsQuery, deleteConnectionQuery, addConnectionBody, editConnectionBody, PRODUCTION_DIRECT_FIELDS, BESIDE_LINK_FIELDS, setProductionCredentialBody, registerWhatsappQuery, registerWhatsappBody, retryProvisioningQuery, resendDomainStatusQuery;
5421
5465
  var init_chunk_HA7CRZMX = __esm({
@@ -5567,1458 +5611,1446 @@ var init_chunk_IPXBFWUU = __esm({
5567
5611
  }
5568
5612
  });
5569
5613
 
5570
- // ../../packages/core/dist/chunk-NKLVUTFO.js
5571
- var BASE_CREDENTIAL_MANAGED_BY, BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema, createBaseCredentialLinkBody, baseCredentialLinkParams, baseCredentialLinkQuery;
5572
- var init_chunk_NKLVUTFO = __esm({
5573
- "../../packages/core/dist/chunk-NKLVUTFO.js"() {
5614
+ // ../../packages/core/dist/chunk-7GDM456L.js
5615
+ var REKOR_ACTOR_TYPE_HEADER, REKOR_ACTOR_ID_HEADER, REKOR_ACTOR_LABEL_HEADER, REKOR_ACTOR_ORG_HEADER, REKOR_ACTOR_ADMIN_HEADER, REKOR_CLIENT_HEADER, REKOR_TOOL_ID_HEADER, REKOR_CLIENTS, rekorClientSchema, MAX_REKOR_TOOL_ID_LENGTH, rekorToolIdSchema, REKOR_V1_PREFIX, DATA_PROXY_ORG_QUERY_PARAM, MAX_PROVISIONING_BODY_BYTES, dataProxyQuery, rekorAttestation, REQUIRED_REKOR_ATTESTATION_HEADERS, REKOR_BOUND_BASE_HEADER, REKOR_BOUND_TOOLSET_HEADER, REKOR_BOUND_TOKEN_HEADER, REKOR_BOUND_CUSTOMER_HEADER, REKOR_BOUND_ACCESS_HEADER, REKOR_BOUND_ACCESS_SCOPE_HEADER, REKOR_BOUND_PAGE_HEADER, REKOR_BOUND_PERSON_HEADER, REKOR_PERSON_AUDIENCE_STAFF, REKOR_PERSON_AUDIENCE_CUSTOMER, REKOR_PERSON_ALL, REKOR_ACCESS_SCOPE_CUSTOMER, DATA_BASE_GENERATION_HEADER, REKOR_MAX_ACTOR_ID_LENGTH, REKOR_MAX_ACTOR_LABEL_LENGTH, REKOR_MAX_ACCESS_DIMENSIONS, REKOR_MAX_ACCESS_VALUES, REKOR_MAX_ACCESS_ID_LENGTH, REKOR_MAX_ACCESS_HEADER_LENGTH, REKOR_MAX_PERSON_PARTIES, REKOR_MAX_PERSON_IDS, REKOR_MAX_PERSON_ID_LENGTH, REKOR_MAX_PERSON_HEADER_LENGTH;
5616
+ var init_chunk_7GDM456L = __esm({
5617
+ "../../packages/core/dist/chunk-7GDM456L.js"() {
5574
5618
  "use strict";
5575
5619
  init_zod();
5576
- BASE_CREDENTIAL_MANAGED_BY = {
5577
- DIRECT: "direct",
5578
- ORG_LINK: "org-link"
5579
- };
5580
- BASE_CREDENTIAL_NAME_MAX = 100;
5581
- BASE_CREDENTIAL_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@+~=-]*$/;
5582
- BASE_CREDENTIAL_NAME_CHARSET = "letters, digits and '. _ : @ + ~ = -', starting with a letter or digit";
5583
- baseCredentialNameSchema = external_exports.string().min(1).max(BASE_CREDENTIAL_NAME_MAX).regex(BASE_CREDENTIAL_NAME_PATTERN, `name must use ${BASE_CREDENTIAL_NAME_CHARSET}`);
5584
- createBaseCredentialLinkBody = external_exports.object({
5585
- organization_id: external_exports.string().uuid(),
5586
- base_id: external_exports.string().min(1),
5587
- /** Defaults to a slug derived from the credential's display name. */
5588
- name: baseCredentialNameSchema.optional()
5589
- });
5590
- baseCredentialLinkParams = external_exports.object({
5591
- id: external_exports.string().uuid(),
5592
- base_credential_id: external_exports.string().min(1)
5620
+ REKOR_ACTOR_TYPE_HEADER = "X-Rekor-Actor-Type";
5621
+ REKOR_ACTOR_ID_HEADER = "X-Rekor-Actor-Id";
5622
+ REKOR_ACTOR_LABEL_HEADER = "X-Rekor-Actor-Label";
5623
+ REKOR_ACTOR_ORG_HEADER = "X-Rekor-Actor-Org";
5624
+ REKOR_ACTOR_ADMIN_HEADER = "X-Rekor-Actor-Admin";
5625
+ REKOR_CLIENT_HEADER = "X-Rekor-Client";
5626
+ REKOR_TOOL_ID_HEADER = "X-Rekor-Tool-Id";
5627
+ REKOR_CLIENTS = ["api", "cli", "mcp"];
5628
+ rekorClientSchema = external_exports.enum(REKOR_CLIENTS);
5629
+ MAX_REKOR_TOOL_ID_LENGTH = 128;
5630
+ rekorToolIdSchema = external_exports.string().trim().min(1).max(MAX_REKOR_TOOL_ID_LENGTH);
5631
+ REKOR_V1_PREFIX = "/v1";
5632
+ DATA_PROXY_ORG_QUERY_PARAM = "org_id";
5633
+ MAX_PROVISIONING_BODY_BYTES = 256 * 1024;
5634
+ dataProxyQuery = external_exports.object({
5635
+ [DATA_PROXY_ORG_QUERY_PARAM]: external_exports.string().uuid().optional()
5593
5636
  });
5594
- baseCredentialLinkQuery = external_exports.object({
5595
- organization_id: external_exports.string().uuid(),
5596
- base_id: external_exports.string().min(1)
5637
+ rekorAttestation = external_exports.object({
5638
+ [REKOR_ACTOR_TYPE_HEADER]: external_exports.enum(["user", "token"]),
5639
+ [REKOR_ACTOR_ID_HEADER]: external_exports.string().min(1),
5640
+ [REKOR_ACTOR_LABEL_HEADER]: external_exports.string(),
5641
+ [REKOR_ACTOR_ORG_HEADER]: external_exports.string().uuid(),
5642
+ [REKOR_ACTOR_ADMIN_HEADER]: external_exports.enum(["0", "1"]),
5643
+ [REKOR_CLIENT_HEADER]: rekorClientSchema,
5644
+ [REKOR_TOOL_ID_HEADER]: rekorToolIdSchema.optional()
5597
5645
  });
5646
+ REQUIRED_REKOR_ATTESTATION_HEADERS = Object.entries(rekorAttestation.shape).filter(([, field]) => !field.isOptional()).map(([header]) => header);
5647
+ REKOR_BOUND_BASE_HEADER = "X-Rekor-Bound-Base";
5648
+ REKOR_BOUND_TOOLSET_HEADER = "X-Rekor-Bound-Toolset";
5649
+ REKOR_BOUND_TOKEN_HEADER = "X-Rekor-Bound-Token";
5650
+ REKOR_BOUND_CUSTOMER_HEADER = "X-Rekor-Bound-Customer";
5651
+ REKOR_BOUND_ACCESS_HEADER = "X-Rekor-Bound-Access";
5652
+ REKOR_BOUND_ACCESS_SCOPE_HEADER = "X-Rekor-Bound-Access-Scope";
5653
+ REKOR_BOUND_PAGE_HEADER = "X-Rekor-Bound-Page";
5654
+ REKOR_BOUND_PERSON_HEADER = "X-Rekor-Bound-Person";
5655
+ REKOR_PERSON_AUDIENCE_STAFF = "staff";
5656
+ REKOR_PERSON_AUDIENCE_CUSTOMER = "customer";
5657
+ REKOR_PERSON_ALL = "*";
5658
+ REKOR_ACCESS_SCOPE_CUSTOMER = "customer";
5659
+ DATA_BASE_GENERATION_HEADER = "X-Data-Base-Generation";
5660
+ REKOR_MAX_ACTOR_ID_LENGTH = 256;
5661
+ REKOR_MAX_ACTOR_LABEL_LENGTH = 256;
5662
+ REKOR_MAX_ACCESS_DIMENSIONS = 8;
5663
+ REKOR_MAX_ACCESS_VALUES = 100;
5664
+ REKOR_MAX_ACCESS_ID_LENGTH = 32;
5665
+ REKOR_MAX_ACCESS_HEADER_LENGTH = 65536;
5666
+ REKOR_MAX_PERSON_PARTIES = 16;
5667
+ REKOR_MAX_PERSON_IDS = 16;
5668
+ REKOR_MAX_PERSON_ID_LENGTH = 64;
5669
+ REKOR_MAX_PERSON_HEADER_LENGTH = 32768;
5598
5670
  }
5599
5671
  });
5600
5672
 
5601
- // ../../packages/core/dist/chunk-ZC6YGHNX.js
5602
- var updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, recordAiDisclosureAcceptanceBody, activityQuery, deletionModeSchema, deletionRequestBody;
5603
- var init_chunk_ZC6YGHNX = __esm({
5604
- "../../packages/core/dist/chunk-ZC6YGHNX.js"() {
5673
+ // ../../packages/core/dist/chunk-CRZFVWXY.js
5674
+ function isPersonAccessAll(lists) {
5675
+ return lists !== void 0 && lists.read.length === 1 && lists.read[0] === ACCESS_UNRESTRICTED && lists.write.length === 1 && lists.write[0] === ACCESS_UNRESTRICTED;
5676
+ }
5677
+ function holdsPersonAccess(assignment) {
5678
+ return assignment != null && Object.hasOwn(assignment, PERSON_ACCESS_KEY);
5679
+ }
5680
+ function withoutPersonAccess(assignment) {
5681
+ if (!holdsPersonAccess(assignment)) return assignment;
5682
+ const dimensions = {};
5683
+ for (const [key, lists] of Object.entries(assignment)) if (key !== PERSON_ACCESS_KEY) dimensions[key] = lists;
5684
+ return dimensions;
5685
+ }
5686
+ function personAccessRefusal(holders) {
5687
+ return `${holders} never hold "${PERSON_ACCESS_KEY}"`;
5688
+ }
5689
+ function personlessAssignmentSchema(holders) {
5690
+ return heldAccessAssignmentSchema.refine((assignment) => !holdsPersonAccess(assignment), {
5691
+ message: personAccessRefusal(holders),
5692
+ path: [PERSON_ACCESS_KEY]
5693
+ });
5694
+ }
5695
+ function writeWithinRead(assignment) {
5696
+ return Object.values(assignment).every(({ read, write }) => read.includes(ACCESS_UNRESTRICTED) || !write.includes(ACCESS_UNRESTRICTED) && write.every((id) => read.includes(id)));
5697
+ }
5698
+ function isEncodedAccessSet(raw) {
5699
+ let parsed;
5700
+ try {
5701
+ parsed = JSON.parse(raw);
5702
+ } catch {
5703
+ return false;
5704
+ }
5705
+ return accessSetSchema.safeParse(parsed).success;
5706
+ }
5707
+ function assignmentHasUnrestricted(assignment) {
5708
+ return Object.values(assignment).some((lists) => lists.read.includes(ACCESS_UNRESTRICTED) || lists.write.includes(ACCESS_UNRESTRICTED));
5709
+ }
5710
+ var ACCESS_UNRESTRICTED, ACCESS_ID_REGEX, ACCESS_ID_MAX_LENGTH, MAX_ACCESS_DIMENSIONS_PER_ORG, MAX_ACCESS_VALUES_PER_DIMENSION, ACCESS_LABEL_MAX_LENGTH, accessIdSchema, accessLabelSchema, accessValueListSchema, accessListsSchema, accessAssignmentSchema, PERSON_ACCESS_KEY, heldAccessKeySchema, heldAccessAssignmentSchema, AGENT_PERSON_ACCESS_REFUSAL, accessSetSchema, accessDimensionParam, accessValueParam, orgMemberParam, orgHubParam, createAccessDimensionBody, updateAccessDimensionBody, createAccessValueBody, updateAccessValueBody, setMemberAccessValuesBody, HUB_PERSON_KINDS, ACCESS_PERSON_KINDS, setHubUserAccessValuesBody, setHubAccessValuesBody, setAgentAccessValuesBody;
5711
+ var init_chunk_CRZFVWXY = __esm({
5712
+ "../../packages/core/dist/chunk-CRZFVWXY.js"() {
5605
5713
  "use strict";
5714
+ init_chunk_7GDM456L();
5715
+ init_chunk_HZ6CADSY();
5716
+ init_chunk_YROEDMVZ();
5606
5717
  init_zod();
5607
- updateUserBody = external_exports.object({
5608
- user_language: external_exports.string().optional(),
5609
- /** true: dark; false: light; null: follow each device's own setting (`AppearanceMode`). */
5610
- ui_dark_mode: external_exports.boolean().nullable().optional(),
5611
- profile_name: external_exports.string().optional(),
5612
- link_email_to_identities: external_exports.boolean().optional()
5613
- }).refine(
5614
- (data) => Object.values(data).some((v) => v !== void 0),
5615
- { message: "At least one field must be provided" }
5616
- );
5617
- updateProfileBody = external_exports.object({
5618
- display_name: external_exports.string().optional(),
5619
- avatar_url: external_exports.string().optional(),
5620
- preferences: external_exports.record(external_exports.unknown()).optional()
5621
- }).refine(
5622
- (data) => Object.values(data).some((v) => v !== void 0),
5623
- { message: "At least one field must be provided" }
5718
+ ACCESS_UNRESTRICTED = "*";
5719
+ ACCESS_ID_REGEX = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
5720
+ ACCESS_ID_MAX_LENGTH = REKOR_MAX_ACCESS_ID_LENGTH;
5721
+ MAX_ACCESS_DIMENSIONS_PER_ORG = REKOR_MAX_ACCESS_DIMENSIONS;
5722
+ MAX_ACCESS_VALUES_PER_DIMENSION = REKOR_MAX_ACCESS_VALUES;
5723
+ ACCESS_LABEL_MAX_LENGTH = 100;
5724
+ accessIdSchema = external_exports.string().min(1).max(ACCESS_ID_MAX_LENGTH).regex(ACCESS_ID_REGEX, { message: 'Must be ASCII letters, digits, "_" or "-", starting with a letter or digit (e.g. "class", "7A")' });
5725
+ accessLabelSchema = external_exports.string().trim().min(1).max(ACCESS_LABEL_MAX_LENGTH);
5726
+ accessValueListSchema = external_exports.array(external_exports.union([accessIdSchema, external_exports.literal(ACCESS_UNRESTRICTED)])).max(MAX_ACCESS_VALUES_PER_DIMENSION).refine((list2) => !list2.includes(ACCESS_UNRESTRICTED) || list2.length === 1, {
5727
+ message: `"${ACCESS_UNRESTRICTED}" reaches the dimension unrestricted, so it stands alone in its list`
5728
+ });
5729
+ accessListsSchema = external_exports.object({ read: accessValueListSchema, write: accessValueListSchema }).strict();
5730
+ accessAssignmentSchema = external_exports.record(accessIdSchema, accessListsSchema).refine((assignment) => Object.keys(assignment).length <= MAX_ACCESS_DIMENSIONS_PER_ORG, {
5731
+ message: `An assignment names at most ${MAX_ACCESS_DIMENSIONS_PER_ORG} dimensions`
5732
+ });
5733
+ PERSON_ACCESS_KEY = "$person";
5734
+ heldAccessKeySchema = external_exports.string().refine(
5735
+ (key) => key === PERSON_ACCESS_KEY || accessIdSchema.safeParse(key).success,
5736
+ { message: `Must be "${PERSON_ACCESS_KEY}" or a dimension id: ASCII letters, digits, "_" or "-", starting with a letter or digit (e.g. "class", "7A")` }
5624
5737
  );
5625
- pathnameRegex = /^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@/?%]*$/;
5626
- updatePreferencesBody = external_exports.object({
5627
- last_viewed_nav: external_exports.string().regex(pathnameRegex, "Must be a URL pathname").max(2048).optional(),
5628
- dismissed_agentic_shortcut: external_exports.boolean().optional(),
5629
- opened_guide: external_exports.boolean().optional()
5630
- }).passthrough();
5631
- registerPushTokenBody = external_exports.object({
5632
- token: external_exports.string().min(1).max(512),
5633
- platform: external_exports.enum(["ios", "android"]),
5634
- /** Stable per-install id so re-registration replaces the prior token for the device. */
5635
- device_id: external_exports.string().min(1).max(128).optional(),
5636
- /**
5637
- * The build opens a person-to-person thread from a push (gh #4661): only a token registered
5638
- * with it receives thread pushes, whose `data` carries `thread_id` and no `conversation_id`.
5639
- * Each registration states it afresh, so a build that sends none clears it.
5640
- */
5641
- supports_threads: external_exports.boolean().optional(),
5642
- /**
5643
- * The build opens a community from a push (gh #4872 Decision 8): only a token registered with it
5644
- * receives a community's pushes (an announcement, a reply to the member's forum post), whose
5645
- * `data` is `CommunityPushData` — never a `conversation_id` or a `thread_id`. Each registration
5646
- * states it afresh, so a build that sends none clears it.
5647
- */
5648
- supports_communities: external_exports.boolean().optional()
5738
+ heldAccessAssignmentSchema = external_exports.record(heldAccessKeySchema, accessListsSchema).superRefine((assignment, ctx) => {
5739
+ if (holdsPersonAccess(assignment) && !isPersonAccessAll(assignment[PERSON_ACCESS_KEY])) {
5740
+ ctx.addIssue({
5741
+ code: external_exports.ZodIssueCode.custom,
5742
+ path: [PERSON_ACCESS_KEY],
5743
+ message: `"${PERSON_ACCESS_KEY}" holds only { "read": ["${ACCESS_UNRESTRICTED}"], "write": ["${ACCESS_UNRESTRICTED}"] }: every person's records`
5744
+ });
5745
+ }
5746
+ if (Object.keys(withoutPersonAccess(assignment)).length > MAX_ACCESS_DIMENSIONS_PER_ORG) {
5747
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `An assignment names at most ${MAX_ACCESS_DIMENSIONS_PER_ORG} dimensions` });
5748
+ }
5649
5749
  });
5650
- deletePushTokenQuery = external_exports.object({
5651
- token: external_exports.string().min(1).max(512)
5750
+ AGENT_PERSON_ACCESS_REFUSAL = `A customer-facing agent (${CUSTOMER_FACING_AGENT_ROLES.map((role) => AGENT_ROLE_DISPLAY[role]).join(", ")}) never holds "${PERSON_ACCESS_KEY}" in its access values: remove it, or give the agent another role`;
5751
+ accessSetSchema = accessAssignmentSchema.refine(writeWithinRead, {
5752
+ message: "An access set writes only what it reads"
5652
5753
  });
5653
- recordAiDisclosureAcceptanceBody = external_exports.object({
5654
- version: external_exports.number().int().positive(),
5655
- withdrawn_at_seen: external_exports.string().datetime().nullable().optional()
5754
+ accessDimensionParam = external_exports.object({
5755
+ id: uuidSchema,
5756
+ dimensionId: accessIdSchema
5656
5757
  });
5657
- activityQuery = external_exports.object({
5658
- limit: external_exports.coerce.number().int().min(1).max(100).optional()
5758
+ accessValueParam = accessDimensionParam.extend({
5759
+ valueId: accessIdSchema
5659
5760
  });
5660
- deletionModeSchema = external_exports.enum(["scheduled", "immediate"]);
5661
- deletionRequestBody = external_exports.object({
5662
- mode: deletionModeSchema,
5663
- /** User-supplied reason captured in the audit log; bounded to bound logged PII. */
5664
- reason: external_exports.string().max(500).optional(),
5665
- /** Type-to-confirm value; must equal the user's email (constant-time compared). */
5666
- email_confirmation: external_exports.string().min(1).max(320)
5761
+ orgMemberParam = external_exports.object({
5762
+ id: uuidSchema,
5763
+ userId: external_exports.string().min(1).max(256)
5667
5764
  });
5668
- }
5669
- });
5670
-
5671
- // ../../packages/core/dist/chunk-ACKF2MVU.js
5672
- var MAX_NAME_LENGTH, MAX_VALUE_LENGTH, MAX_TAGS, MAX_TAG_LENGTH, MAX_SCOPE_HUBS, MAX_SCOPE_TAGS, vaultSecretScopeSchema, vaultCreateBody, vaultUpdateBody;
5673
- var init_chunk_ACKF2MVU = __esm({
5674
- "../../packages/core/dist/chunk-ACKF2MVU.js"() {
5675
- "use strict";
5676
- init_chunk_HZ6CADSY();
5677
- init_zod();
5678
- MAX_NAME_LENGTH = 100;
5679
- MAX_VALUE_LENGTH = 32 * 1024;
5680
- MAX_TAGS = 20;
5681
- MAX_TAG_LENGTH = 50;
5682
- MAX_SCOPE_HUBS = 100;
5683
- MAX_SCOPE_TAGS = 50;
5684
- vaultSecretScopeSchema = external_exports.object({
5685
- hubs: external_exports.array(external_exports.string().min(1)).max(MAX_SCOPE_HUBS).optional(),
5686
- tags: external_exports.array(external_exports.string().min(1).max(MAX_TAG_LENGTH)).max(MAX_SCOPE_TAGS).optional()
5687
- }).strict();
5688
- vaultCreateBody = external_exports.object({
5689
- name: external_exports.string().trim().min(1, "name is required").max(MAX_NAME_LENGTH, `name must be ${MAX_NAME_LENGTH} characters or fewer`),
5690
- value: external_exports.string().min(1, "value is required").max(MAX_VALUE_LENGTH, `value must be ${MAX_VALUE_LENGTH} characters or fewer`),
5691
- tags: external_exports.array(external_exports.string().min(1).max(MAX_TAG_LENGTH, `Tag must be ${MAX_TAG_LENGTH} characters or fewer`)).max(MAX_TAGS, `Maximum ${MAX_TAGS} tags allowed`).optional().default([]),
5692
- scope: vaultSecretScopeSchema.optional().default({})
5693
- }).strict();
5694
- vaultUpdateBody = external_exports.object({
5695
- name: external_exports.string().trim().min(1).max(MAX_NAME_LENGTH).optional(),
5696
- value: external_exports.string().min(1).max(MAX_VALUE_LENGTH).optional(),
5697
- tags: external_exports.array(external_exports.string().min(1).max(MAX_TAG_LENGTH)).max(MAX_TAGS).optional(),
5698
- scope: vaultSecretScopeSchema.optional()
5699
- }).strict();
5700
- }
5701
- });
5702
-
5703
- // ../../packages/core/dist/chunk-HIGKBEPF.js
5704
- var accessExplainQuery;
5705
- var init_chunk_HIGKBEPF = __esm({
5706
- "../../packages/core/dist/chunk-HIGKBEPF.js"() {
5707
- "use strict";
5708
- init_chunk_HZ6CADSY();
5709
- init_zod();
5710
- accessExplainQuery = external_exports.object({
5711
- user_id: external_exports.string().regex(USER_ID_REGEX).optional()
5765
+ orgHubParam = external_exports.object({
5766
+ id: uuidSchema,
5767
+ hubId: uuidSchema
5768
+ });
5769
+ createAccessDimensionBody = external_exports.object({
5770
+ dimension_id: accessIdSchema,
5771
+ label: accessLabelSchema
5772
+ });
5773
+ updateAccessDimensionBody = external_exports.object({
5774
+ label: accessLabelSchema
5775
+ });
5776
+ createAccessValueBody = external_exports.object({
5777
+ value_id: accessIdSchema,
5778
+ label: accessLabelSchema
5779
+ });
5780
+ updateAccessValueBody = external_exports.object({
5781
+ label: accessLabelSchema.optional(),
5782
+ retired: external_exports.boolean().optional()
5783
+ }).refine((body) => body.label !== void 0 || body.retired !== void 0, {
5784
+ message: "Nothing to change: pass label, retired, or both"
5785
+ });
5786
+ setMemberAccessValuesBody = external_exports.object({
5787
+ values: heldAccessAssignmentSchema
5788
+ });
5789
+ HUB_PERSON_KINDS = ["hub_admin", "hub_team_member", "hub_user"];
5790
+ ACCESS_PERSON_KINDS = ["org_member", ...HUB_PERSON_KINDS, "public"];
5791
+ setHubUserAccessValuesBody = external_exports.object({
5792
+ values: personlessAssignmentSchema("A hub user's values").refine((assignment) => !assignmentHasUnrestricted(assignment), {
5793
+ message: `A hub user's values never hold "${ACCESS_UNRESTRICTED}"`
5794
+ })
5795
+ });
5796
+ setHubAccessValuesBody = external_exports.object({
5797
+ values: personlessAssignmentSchema("A hub's values and its public values")
5798
+ });
5799
+ setAgentAccessValuesBody = external_exports.object({
5800
+ values: heldAccessAssignmentSchema.nullable()
5712
5801
  });
5713
5802
  }
5714
5803
  });
5715
5804
 
5716
- // ../../packages/core/dist/chunk-5XEJSR22.js
5717
- var DATA_PROXY_MOUNT, DATA_PROXY_PREFIX, BASE_DESTRUCTION_MOUNT, BASE_DESTRUCTION_PREFIX, BASE_DESTRUCTION_CONFIRM_PATH, COMMUNITY_EMAIL_UNSUBSCRIBE_PATH, CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH, AUTOMATION_WEBHOOK_MOUNT, MANAGED_AGENTS_WEBHOOK_MOUNT;
5718
- var init_chunk_5XEJSR22 = __esm({
5719
- "../../packages/core/dist/chunk-5XEJSR22.js"() {
5720
- "use strict";
5721
- DATA_PROXY_MOUNT = "/data";
5722
- DATA_PROXY_PREFIX = `/api${DATA_PROXY_MOUNT}`;
5723
- BASE_DESTRUCTION_MOUNT = "/bases";
5724
- BASE_DESTRUCTION_PREFIX = `/api${BASE_DESTRUCTION_MOUNT}`;
5725
- BASE_DESTRUCTION_CONFIRM_PATH = `${BASE_DESTRUCTION_PREFIX}/destruction/confirm`;
5726
- COMMUNITY_EMAIL_UNSUBSCRIBE_PATH = "/api/communities/email-unsubscribe";
5727
- CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH = "/api/contact-book/email-unsubscribe";
5728
- AUTOMATION_WEBHOOK_MOUNT = "/webhooks/automations";
5729
- MANAGED_AGENTS_WEBHOOK_MOUNT = "/webhooks/managed-agents";
5730
- }
5731
- });
5732
-
5733
- // ../../packages/core/dist/chunk-D7SSWNL3.js
5734
- function matchPath(pattern, path45) {
5735
- const pathSegments2 = path45.replace(/\/$/, "").split("/");
5736
- const isPrefix = pattern.endsWith("/*");
5737
- const patternSegments = (isPrefix ? pattern.slice(0, -2) : pattern).split("/");
5738
- if (isPrefix ? pathSegments2.length < patternSegments.length : pathSegments2.length !== patternSegments.length) {
5739
- return false;
5740
- }
5741
- return patternSegments.every((segment, i) => segment === "*" ? pathSegments2[i] !== "" : segment === pathSegments2[i]);
5805
+ // ../../packages/core/dist/chunk-Q6CHATUL.js
5806
+ function boundCustomerPartyIsValid(audience, parties, customer) {
5807
+ return audience !== REKOR_PERSON_AUDIENCE_STAFF && customer < parties.length && Array.isArray(parties[customer]);
5742
5808
  }
5743
- function getEndpointConfig(path45) {
5744
- for (const excluded of EXCLUDED_PATHS) {
5745
- if (matchPath(excluded, path45)) {
5746
- return null;
5747
- }
5748
- }
5749
- const normalizedPath = path45.replace(/\/$/, "");
5750
- if (!normalizedPath.endsWith("/*") && Object.prototype.hasOwnProperty.call(ENDPOINT_CONFIGS, normalizedPath)) {
5751
- return ENDPOINT_CONFIGS[normalizedPath];
5752
- }
5753
- const sortedPatterns = Object.keys(ENDPOINT_CONFIGS).sort((a, b) => b.length - a.length);
5754
- for (const pattern of sortedPatterns) {
5755
- if (matchPath(pattern, path45)) {
5756
- return ENDPOINT_CONFIGS[pattern];
5757
- }
5809
+ function isEncodedBoundPerson(raw) {
5810
+ let parsed;
5811
+ try {
5812
+ parsed = JSON.parse(raw);
5813
+ } catch {
5814
+ return false;
5758
5815
  }
5759
- return { tier: "STANDARD" };
5816
+ return rekorBoundPersonSchema.safeParse(parsed).success;
5760
5817
  }
5761
- var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
5762
- var init_chunk_D7SSWNL3 = __esm({
5763
- "../../packages/core/dist/chunk-D7SSWNL3.js"() {
5818
+ var TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, rekorToolsetToolsSchema, rekorPersonIdSchema, rekorPersonAudienceSchema, rekorBoundPersonSchema, rekorBoundAttestation, 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;
5819
+ var init_chunk_Q6CHATUL = __esm({
5820
+ "../../packages/core/dist/chunk-Q6CHATUL.js"() {
5764
5821
  "use strict";
5765
- init_chunk_5XEJSR22();
5766
- ENDPOINT_CONFIGS = {
5767
- // OAuth callbacks - strict, fail-closed (prevent brute force)
5768
- "/oauth/callback/*": { tier: "STRICT", failClosed: true },
5769
- // Auth endpoints - strict, fail-closed
5770
- "/auth/phone": { tier: "STRICT", failClosed: true },
5771
- "/auth/mcp/exchange": { tier: "MODERATE", failClosed: true },
5772
- // Native magic-code login (pre-auth) — STRICT per-IP bounds a single host; WorkOS owns
5773
- // the per-email lockout / TTL / single-use guarantees.
5774
- "/api/auth/magic-code/*": { tier: "STRICT", failClosed: true },
5775
- // Native password login (pre-auth) — same posture as magic-code above. STRICT per-IP bounds a
5776
- // single host but FAILS OPEN on a binding error (like every IP limit); the `failClosed` flag
5777
- // here is inert on a pre-auth route (it's only enforced on the per-user branch, which needs an
5778
- // authenticated caller). The fail-CLOSED brute-force guarantee for the static credential comes
5779
- // from the route's per-email caps (burst + cumulative hourly), not this flag.
5780
- "/api/auth/password/*": { tier: "STRICT", failClosed: true },
5781
- // Every `/api/*` group whose paths carry ids pins `userLimitKey` (gh #4756), held there by
5782
- // `security/endpoint-invariants.test.ts`.
5783
- // Billing - moderate, fail-closed with user limits
5784
- "/api/billing/*": {
5785
- tier: "MODERATE",
5786
- userLimit: 100,
5787
- failClosed: true,
5788
- skipAuthenticatedUsers: true,
5789
- userLimitKey: "/api/billing/*"
5790
- },
5791
- "/webhooks/stripe": { tier: "MODERATE", failClosed: true },
5792
- "/webhooks/workos": { tier: "MODERATE", failClosed: true },
5793
- // API endpoints - standard with user limits
5794
- // 500 because the web's settings live updates refetch per hub in every open tab, whatever page
5795
- // it shows (`settingsLiveUpdateStore.ts`): one batch of changes costs about 10 + 4 per agent
5796
- // whose tools were opened + 2 per loaded resource, so a CLI push and publish (both hubs) with
5797
- // two tabs open passes 150 in a minute. A multi-file resource upload adds 2–5 per file.
5798
- "/api/setup/*": {
5799
- tier: "STANDARD",
5800
- userLimit: 500,
5801
- skipAuthenticatedUsers: true,
5802
- userLimitKey: "/api/setup/*"
5803
- },
5804
- // 500 because an eval run's drill-down (`SessionResults.tsx`) fetches its list and then every
5805
- // LLM turn's record at once: up to 201 requests (`OBSERVABILITY_LIST_CAP`, 200). Sending keeps
5806
- // the 150 it had when each path held its own budget, on the exact key below.
5807
- "/api/conversations/*": {
5808
- tier: "STANDARD",
5809
- userLimit: 500,
5810
- skipAuthenticatedUsers: true,
5811
- userLimitKey: "/api/conversations/*"
5812
- },
5813
- "/api/conversations/send-message": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
5814
- "/api/users/*": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
5815
- "/api/analytics/*": {
5816
- tier: "STANDARD",
5817
- userLimit: 150,
5818
- skipAuthenticatedUsers: true,
5819
- userLimitKey: "/api/analytics/*"
5820
- },
5821
- // 500 because `wayai eval-results --eval` reads completed sessions one by one, newest first,
5822
- // until one holds the eval (up to the 1000 the list returns). Tenant SQL keeps the 150 it had
5823
- // when each path held its own budget: each query may run 30 s on shared-tenant ClickHouse
5824
- // after its caller has gone (`sql-validator.ts`, stage 10b).
5825
- "/api/evals/*": {
5826
- tier: "STANDARD",
5827
- userLimit: 500,
5828
- skipAuthenticatedUsers: true,
5829
- userLimitKey: "/api/evals/*"
5830
- },
5831
- "/api/evals/sql": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
5832
- // An eval run's calls (gh #4418), kept off the end user's call budgets below. Create keeps the
5833
- // 150 it had: it opens a provider session on the org's own key, billed per second. The routes
5834
- // on one call take a budget of their own so no eval read can spend it: a refused hang-up
5835
- // leaves the call running, and billing. 500 because a call suite polls each run's record
5836
- // every second, about 64 requests a minute per suite.
5837
- "/api/evals/calls": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
5838
- "/api/evals/calls/*": {
5839
- tier: "STANDARD",
5840
- userLimit: 500,
5841
- skipAuthenticatedUsers: true,
5842
- userLimitKey: "/api/evals/calls/*"
5843
- },
5844
- "/api/files/*": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
5845
- // The org contact book (wayai#4931 PR 2b). A CSV import sends one request per
5846
- // `CONTACT_IMPORT_BATCH_MAX` rows, so 150 a minute imports 75,000 rows a minute.
5847
- "/api/contact-book/*": {
5848
- tier: "STANDARD",
5849
- userLimit: 150,
5850
- skipAuthenticatedUsers: true,
5851
- userLimitKey: "/api/contact-book/*"
5852
- },
5853
- // An automation email's one-click unsubscribe (wayai#4931 PR 2d) — public: its token is its one
5854
- // credential, so this per-IP limit is its one bound, and runs before the route reads anything.
5855
- // MODERATE (30/min per IP), as the community email's unsubscribe, for the same reason: mail
5856
- // clients' one-click unsubscribe POSTs it from their own servers, which many recipients' clicks
5857
- // share. An exact key, so it wins over the wildcard above.
5858
- [CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH]: { tier: "MODERATE" },
5859
- "/api/automations/*": {
5860
- tier: "STANDARD",
5861
- userLimit: 150,
5862
- skipAuthenticatedUsers: true,
5863
- userLimitKey: "/api/automations/*"
5864
- },
5865
- // A hub's own contact lists (wayai#4931 PR 2c): config edits, at the automations' rate.
5866
- "/api/hub-contact-lists/*": {
5867
- tier: "STANDARD",
5868
- userLimit: 150,
5869
- skipAuthenticatedUsers: true,
5870
- userLimitKey: "/api/hub-contact-lists/*"
5871
- },
5872
- "/api/message-templates/*": {
5873
- tier: "STANDARD",
5874
- userLimit: 150,
5875
- skipAuthenticatedUsers: true,
5876
- userLimitKey: "/api/message-templates/*"
5877
- },
5878
- "/api/live-updates/*": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
5879
- "/api/hub-users/*": {
5880
- tier: "STANDARD",
5881
- userLimit: 150,
5882
- skipAuthenticatedUsers: true,
5883
- userLimitKey: "/api/hub-users/*"
5884
- },
5885
- "/api/conversation-state/*": {
5886
- tier: "STANDARD",
5887
- userLimit: 150,
5888
- skipAuthenticatedUsers: true,
5889
- userLimitKey: "/api/conversation-state/*"
5890
- },
5891
- // The authenticated byte route (`routes/files/r2.ts`), mounted after its `authMiddleware` so
5892
- // the caller is known: each request reads the HubDO its key names, and a hub id never created
5893
- // still wakes a Durable Object (gh #4747; since gh #4775 T5 one that writes nothing). The key is pinned
5894
- // because the paths are file keys, which would otherwise each get a fresh budget (and one
5895
- // over 256 characters would be refused outright, `checkUserLimitNative`).
5896
- //
5897
- // 500 a minute because the web chat fetches every attachment of every loaded message at
5898
- // once, with no list virtualization: up to 50 per 50-message page, 200 per ended
5899
- // conversation or history entry at one file per message, and 4 per message at most in its
5900
- // image grid. Repeats come from the browser's HTTP cache (`private, max-age=3600`); mobile
5901
- // renders through a disk cache and plays audio from `/files/signed`. The budget is shared by
5902
- // a caller's tabs and devices. The other two byte routes, `/files/signed/*` and
5903
- // `/files/public/*`, mount no limiter (the reason is at their entries in
5904
- // `security/endpoint-invariants.test.ts`'s route registry).
5905
- "/files/auth/*": {
5906
- tier: "STANDARD",
5907
- userLimit: 500,
5908
- skipAuthenticatedUsers: true,
5909
- userLimitKey: "/files/auth/*"
5910
- },
5911
- // Channel webhooks - high throughput (external systems, never authenticated)
5912
- "/webhooks/whatsapp/*": { tier: "HIGH" },
5913
- "/webhooks/instagram/*": { tier: "HIGH" },
5914
- // An automation's webhook deliveries (wayai#4931 D13) — no bearer token: the automation's
5915
- // secret is the credential, checked against one HubDO read. This per-IP limit runs first, before
5916
- // anything is read. HIGH, as the channel webhooks: senders are servers, and an integration
5917
- // platform's egress addresses carry many tenants' deliveries. The per-automation budget is
5918
- // `AUTOMATION_WEBHOOK_PER_AUTOMATION_LIMIT`, counted after the delivery is verified.
5919
- [`${AUTOMATION_WEBHOOK_MOUNT}/*`]: { tier: "HIGH" },
5920
- // Managed Agents session events (#5083 Phase 4): one delivery per hosted tool round, and one
5921
- // vendor address carries every tenant's, so BULK. The per-connection budget is
5922
- // `MANAGED_AGENTS_WEBHOOK_PER_CONNECTION_LIMIT`, counted after the delivery is verified.
5923
- [`${MANAGED_AGENTS_WEBHOOK_MOUNT}/*`]: { tier: "BULK" },
5924
- // Reports (CLI → platform_report triage queue). One per-user budget covers intake
5925
- // (POST), the content edit (PATCH /:id), the reporter read-back (GET, GET /:id), and the
5926
- // verification loop (POST /:id/accept, /:id/contest). The limiter is path-based, so a
5927
- // method-level split (loose reads, strict writes) isn't expressible — GET /:id and PATCH
5928
- // /:id share a path. So the budget is sized for the read-heavy poll loop (a reporter agent
5929
- // polling `report get`/`list` while it waits for the fix), at 60/hour. Intake-flooding stays
5930
- // bounded regardless: identical reports collapse on `fingerprint` (ON CONFLICT DO NOTHING),
5931
- // so a runaway create loop merges rather than floods. Still STRICT tier + failClosed so a
5932
- // genuinely runaway distinct-report loop surfaces as 429. The `/*` is load-bearing — an
5933
- // exact `/api/reports` key would leave the `/:id` paths unmatched (→ unthrottled).
5934
- // `userLimitKey` is equally load-bearing: without it, middleware falls back to each request's
5935
- // path and report IDs/actions receive independent counters instead of this shared budget.
5936
- "/api/reports/*": {
5937
- tier: "STRICT",
5938
- userLimit: 60,
5939
- userWindow: 3600,
5940
- failClosed: true,
5941
- skipAuthenticatedUsers: true,
5942
- userLimitKey: "/api/reports/*"
5943
- },
5944
- // Admin report mutations (transition/group/ungroup/edit) — platform-admin
5945
- // gated at the route, rate-limited here as defense-in-depth. Generous STANDARD
5946
- // cap so legitimate triage bursts aren't throttled (grouping is one request
5947
- // even for many members); deliberately NOT failClosed so a Redis blip never
5948
- // blocks an admin's triage. The bare GET reads share this budget harmlessly.
5949
- "/api/admin/reports/*": { tier: "STANDARD", userLimit: 150, userLimitKey: "/api/admin/reports/*" },
5950
- // GitHub webhook (issues.closed → platform_report addressed). MODERATE +
5951
- // fail-closed; GitHub retries on transient failures so a brief Redis blip
5952
- // doesn't lose state.
5953
- "/webhooks/github": { tier: "MODERATE", failClosed: true },
5954
- // Account deletion — strict on the destructive POST + public undo. The
5955
- // /api/users/* default tier above ALSO matches these, but `getEndpointConfig`
5956
- // returns the longest-prefix match, so the more specific entries here win.
5957
- // `skipAuthenticatedUsers` deliberately omitted: every caller is authenticated,
5958
- // so including it would make `userLimit` a no-op — the per-user cap IS the gate.
5959
- "/api/users/me/deletion": { tier: "STRICT", userLimit: 3, userWindow: 3600, failClosed: true },
5960
- "/api/users/me/deletion/preflight": { tier: "STANDARD", userLimit: 30, failClosed: true },
5961
- "/api/users/deletion/undo": { tier: "STRICT", failClosed: true },
5962
- // Production-base destruction.
5963
- //
5964
- // Keyed off the CONTRACT constants, not literals: `BASE_DESTRUCTION_CONFIRM_PATH`'s own
5965
- // docstring promises that the mount, the `AUTH_BYPASS_PATHS` entry, the rate-limit key and
5966
- // the URL the email embeds move together, and a literal here is exactly how that promise
5967
- // goes quietly false — leaving an unauthenticated HMAC endpoint on the default tier.
5968
- //
5969
- // The emailed GET is PUBLIC, so it gets the IP-tier bound the pre-auth routes get.
5970
- // `failClosed` is deliberately NOT set: it is only consulted on the per-USER branch, which
5971
- // needs an authenticated caller, so on a pre-auth route it is inert — the same thing
5972
- // `/api/auth/magic-code/send` above says about itself. The IP limiter fails OPEN on a
5973
- // limiter error by design (`packages/runtime/src/rate-limiter.ts`), and claiming otherwise
5974
- // would tell the next auditor a protection exists that does not.
5975
- [BASE_DESTRUCTION_CONFIRM_PATH]: { tier: "STRICT" },
5976
- // The console's read, which every production base's settings pane issues on mount. Without
5977
- // its own entry it inherits the mount-wide budget below, and an admin clicking through
5978
- // thirty bases in an hour would be 429'd by a limit sized for irreversible writes.
5979
- [`${BASE_DESTRUCTION_PREFIX}/destructions`]: { tier: "STANDARD", userLimit: 150 },
5980
- // The mutating routes: initiate, the authenticated confirm, and cancel. Per user rather than
5981
- // per IP — all three are authenticated and org-admin gated — and hourly, since a single human
5982
- // touching thirty production-deletion operations in an hour is already far past normal.
5983
- // Longest-prefix wins, so the two entries above are not widened by this one. The key is
5984
- // pinned so those thirty are counted across every base the caller touches (gh #4756).
5985
- [`${BASE_DESTRUCTION_PREFIX}/*`]: {
5986
- tier: "STANDARD",
5987
- userLimit: 30,
5988
- userWindow: 3600,
5989
- failClosed: true,
5990
- userLimitKey: `${BASE_DESTRUCTION_PREFIX}/*`
5991
- },
5992
- // Email-invite preview — public, fail-closed. MODERATE (30/min IP) leaves
5993
- // headroom for the signup-page server-fetch + reloads + prefetches; STRICT
5994
- // would throttle legitimate users opening the link in multiple tabs.
5995
- "/api/invites/preview": { tier: "MODERATE", failClosed: true },
5996
- // "Don't email me again" (gh #4661) — public; one POST per click on its confirm page. STRICT
5997
- // per IP. No `failClosed`: it is consulted only on the per-user branch, which a pre-auth route
5998
- // never reaches (see `BASE_DESTRUCTION_CONFIRM_PATH` above).
5999
- "/api/invites/unsubscribe": { tier: "STRICT" },
6000
- // Admin DO debug reads — the ONE deliberate deviation from the Data Explorer
6001
- // catch-all below, and the only reason a per-route key still exists here.
6002
- // Platform-admin is enforced at the route; this is the independent
6003
- // defense-in-depth signal so a runaway investigation script surfaces as 429.
6004
- //
6005
- // STRICT is kept ON PURPOSE even though the catch-all moved off it: per IP, at 5/min vs
6006
- // STANDARD's 100/min, walking 10k ids takes ~33h instead of ~100min — a detection window
6007
- // worth keeping on the routes that return RAW DO ROWS.
6008
- //
6009
- // The cost, stated rather than elided: STRICT is one bucket shared with
6010
- // `/oauth/callback/*` and `/api/auth/magic-code/*`, so a debug session from a
6011
- // NAT'd office IP can 429 a colleague's login for up to a minute. That trade is
6012
- // accepted for a rare, deliberate investigation surface — and is exactly why the
6013
- // browse routes below are NOT here.
6014
- //
6015
- // The key is pinned, so a sweep of `/debug/do/hub/<id>/tables` across ids spends one
6016
- // per-admin budget (gh #4756). 120 an hour: an agent's investigation of a dozen
6017
- // conversations made 37 debug reads in its busiest hour.
6018
- "/api/admin/data-explorer/debug/*": {
6019
- tier: "STRICT",
6020
- userLimit: 120,
6021
- userWindow: 3600,
6022
- failClosed: true,
6023
- userLimitKey: "/api/admin/data-explorer/debug/*"
6024
- },
6025
- // Catch-all for the rest of the Data Explorer (`/search`, `/entity/*`, `/do/*`,
6026
- // `/kv/*`, the DELETE routes). Added as a catch-all rather than another per-route
6027
- // key because this budget kept lagging behind routes joining the debug boundary:
6028
- // with no match the path falls to the default, which sets no `userLimit`, so the
6029
- // per-user layer never runs at all. `getEndpointConfig` takes the longest match,
6030
- // so `debug/*` above still wins.
6031
- //
6032
- // `/entity/*` deliberately has NO key of its own: it needs precisely this config,
6033
- // and a duplicate entry is how the two drift apart on the next edit.
6034
- //
6035
- // `tier` is deliberately STANDARD, not STRICT. `tier` is the per-IP knob and
6036
- // STRICT is 5/min keyed on IP ALONE — one bucket shared across every STRICT
6037
- // endpoint. On these browse routes that breaks the console (open Browse KV and
6038
- // inspect four values = 6 requests; expand six org rows in the search results =
6039
- // 6 `/entity/org/:id` calls) and would drain the same IP's budget for
6040
- // `/oauth/callback/*` and `/api/auth/magic-code/*`, which on a NAT'd office IP
6041
- // means all admins. The per-user hourly cap is the leg that matters here.
6042
- //
6043
- // The canonical key is deliberate: request paths contain DO ids and arbitrary
6044
- // malformed requests can contain credential material. Keying on the request path
6045
- // both stores that material in Redis/logs and gives every target a fresh counter.
6046
- // One stable identity makes every browse request consume the same per-admin
6047
- // budget without storing request targets.
6048
- //
6049
- // 600/hour preserves the original pagination requirement (about 30k rows at
6050
- // 50/page) while now genuinely bounding id/key enumeration across the surface.
6051
- "/api/admin/data-explorer/*": {
6052
- tier: "STANDARD",
6053
- userLimit: 600,
6054
- userWindow: 3600,
6055
- failClosed: true,
6056
- userLimitKey: "/api/admin/data-explorer/*"
6057
- },
6058
- // Admin harness incident-response (harness-agents PR 2.9b) — mass-destroy reaps
6059
- // EVERY live harness session/token/slot in scope, so it gets a strict budget
6060
- // (STRICT + a low per-user hourly cap + fail-closed). Platform-admin is enforced
6061
- // at the route; this is the independent defense-in-depth signal so a runaway
6062
- // reap loop surfaces as 429. The break-glass disable/enable rides through
6063
- // `/api/admin/config` (its own STANDARD budget), not this key.
6064
- "/api/admin/harness/*": {
6065
- tier: "STRICT",
6066
- userLimit: 10,
6067
- userWindow: 3600,
6068
- failClosed: true,
6069
- userLimitKey: "/api/admin/harness/*"
6070
- },
6071
- // Platform-wide team-orphan repair — a single call can WRITE across every hub of
6072
- // every org (HubDO purge + UserDO mirror fan-out), so it gets the same strict,
6073
- // fail-closed budget as the other cross-platform admin write. Exact path (not a
6074
- // prefix): the sibling `/api/admin/hubs/:hubId/harness` flag flips stay on the
6075
- // default admin budget. Platform-admin is enforced at the route; this is the
6076
- // defense-in-depth signal that a repair loop surfaces as 429.
6077
- "/api/admin/hubs/repair-team-orphans": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6078
- // Branching-orphan repair (#4577) — deletes named production rows, and its report mode
6079
- // fans out over every production hub of every org, so it takes the same strict,
6080
- // fail-closed budget as the team-orphan repair. Exact path, for the same reason.
6081
- "/api/admin/hubs/repair-branching-orphans": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6082
- // Knowledge-blob repair (#5142 step 5 C1) — deletes R2 objects across every hub of a scope, so it
6083
- // takes the same strict, fail-closed budget as the other hub repairs. Exact path, for the same reason.
6084
- "/api/admin/hubs/repair-knowledge-blobs": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6085
- // CI/GitOps endpoints - standard with user limits. 500 because `wayai push` makes four requests
6086
- // (pull, diff, push, pull) and a GitOps job may push every hub at once with one token; when
6087
- // each path held its own 100, that ran to 100 hubs a minute.
6088
- "/api/ci/*": { tier: "STANDARD", userLimit: 500, skipAuthenticatedUsers: true, userLimitKey: "/api/ci/*" },
6089
- // A hub's team pages and their bridge (#5333; owner decision of 2026-10-27): a signed-in caller is
6090
- // counted on one budget of their own across every hub's page routes instead of the per-IP tier,
6091
- // which a team behind one address shares. The bridge's own budgets still apply on top: 60 calls a
6092
- // minute per viewer and page (30 on a customer page), 150 per viewer across a hub's pages, 200 per hub
6093
- // across its customer pages and 500 per hub (`PAGE_BRIDGE_*` below).
6094
- "/api/hubs/*/pages/*": { tier: "STANDARD", userLimit: 500, skipAuthenticatedUsers: true, userLimitKey: "/api/hubs/*/pages/*" },
6095
- // Attested `/v1` proxy onto the data API's `AttestedEntrypoint`. `userLimitKey` is load-bearing here: the
6096
- // per-user budget defaults to the full request path, and this surface's paths carry base,
6097
- // record, and file ids — so without a pinned key every distinct resource would get its own
6098
- // fresh budget and the per-user limit would bound nothing. One shared budget across the
6099
- // whole data surface is the intent.
6100
- [`${DATA_PROXY_PREFIX}/*`]: {
6101
- tier: "STANDARD",
6102
- userLimit: 150,
6103
- skipAuthenticatedUsers: true,
6104
- userLimitKey: `${DATA_PROXY_PREFIX}/*`
6105
- },
6106
- // Voice calls — the end user's call routes (`routes/api/calls`). Every caller is signed
6107
- // in, so the per-IP tier is skipped for them: Brazilian mobile carriers put many callers
6108
- // behind one IP, and a shared bucket would refuse one caller for another's traffic.
6109
- //
6110
- // Create is the only route that spends: it opens a provider session on the org's own
6111
- // key, billed per second. So it takes its own exact key and an hourly per-user cap, which
6112
- // lives on Redis and is fail-closed like the other hourly caps. The exact key wins over
6113
- // the wildcard below, which also matches `/api/calls` (see `getEndpointConfig`).
6114
- "/api/calls": {
6115
- tier: "STANDARD",
6116
- userLimit: 30,
6117
- userWindow: 3600,
6118
- failClosed: true,
6119
- skipAuthenticatedUsers: true,
6120
- userLimitKey: "/api/calls"
6121
- },
6122
- // The routes on one call: `ready`, hang-up, the delegation report and the status read; and
6123
- // the opening read (`/api/calls/openings/:language`), one per call, before it exists.
6124
- // NEVER fail-closed: a refused hang-up leaves the call running, and billing, until a
6125
- // limit ends it. The 60 s budget runs on the native binding, which fails open. The key is
6126
- // pinned because the paths carry the call id, which would otherwise give every call a
6127
- // fresh budget.
6128
- "/api/calls/*": {
6129
- tier: "STANDARD",
6130
- userLimit: 150,
6131
- skipAuthenticatedUsers: true,
6132
- userLimitKey: "/api/calls/*"
6133
- },
6134
- // Contacts between accounts (gh #4661, `routes/api/contacts`). Every caller is signed in, so
6135
- // the per-IP tier is skipped. The keys are pinned because the paths carry user and invite
6136
- // ids, which would otherwise give each id a fresh budget. Blocks take their own, lower
6137
- // budget (#4661 Limits: blocks are rate-limited). The invites-per-day cap and every list
6138
- // cap are counted in the caller's UserDO, in the same write they bound, not here.
6139
- "/api/contacts/*": {
6140
- tier: "STANDARD",
6141
- userLimit: 60,
6142
- skipAuthenticatedUsers: true,
6143
- userLimitKey: "/api/contacts/*"
6144
- },
6145
- "/api/contacts/blocks/*": {
6146
- tier: "STANDARD",
6147
- userLimit: 30,
6148
- skipAuthenticatedUsers: true,
6149
- userLimitKey: "/api/contacts/blocks/*"
6150
- },
6151
- // Person-to-person threads (gh #4661, `routes/api/threads`): the per-user send limit, 60 a
6152
- // minute on the native binding. Every thread route shares the one budget, reads included:
6153
- // the paths carry thread and message ids, so the key is pinned, and a pattern here cannot
6154
- // tell a send from a read of the same path. Like every 60 s budget it fails open on a
6155
- // binding error, so it bounds sends in the steady state only.
6156
- "/api/threads/*": {
6157
- tier: "STANDARD",
6158
- userLimit: 60,
6159
- skipAuthenticatedUsers: true,
6160
- userLimitKey: "/api/threads/*"
6161
- },
6162
- // An org admin's erasure of one person's thread messages (gh #4661 owner decision 7): any user
6163
- // can own a free org, so each request arms that org's alarm, and this caps how fast one person
6164
- // can ask. The org's own daily cap (`PEOPLE_ORG_ERASURES_PER_DAY`, counted in its OrgDO in the
6165
- // write it bounds) is the fail-closed bound; this budget, on the native binding, fails open.
6166
- "/api/threads/org-erasures": {
6167
- tier: "STANDARD",
6168
- userLimit: 10,
6169
- skipAuthenticatedUsers: true,
6170
- userLimitKey: "/api/threads/org-erasures"
6171
- },
6172
- // A person's report of a message, thread or person (`people-reports.ts`): each one written
6173
- // arms the PlatformDO's alarm and emails the platform admins, so it takes its own, lower
6174
- // budget. The reporter's daily cap (`PEOPLE_REPORTS_PER_DAY`, counted in the report store in
6175
- // the write it bounds) is the fail-closed bound; this budget, on the native binding, fails open.
6176
- "/api/threads/reports": {
6177
- tier: "STANDARD",
6178
- userLimit: 10,
6179
- skipAuthenticatedUsers: true,
6180
- userLimitKey: "/api/threads/reports"
6181
- },
6182
- // Communities (gh #4872, `routes/api/communities`): every signed-in route under the mount (the
6183
- // preview below excepted) shares one per-user budget, which is also each member's send limit and
6184
- // bounds the reads that scan a community's rows (a title search, the stats); a community's own
6185
- // limits (its rate, the daily caps, slow mode) are counted in its CommunityDO, in the write they
6186
- // bound. Every caller is signed in, so the per-IP tier is skipped; the key is pinned because the
6187
- // paths carry community, room and message ids.
6188
- "/api/communities/*": {
6189
- tier: "STANDARD",
6190
- userLimit: 60,
6191
- skipAuthenticatedUsers: true,
6192
- userLimitKey: "/api/communities/*"
6193
- },
6194
- // The join page's preview of a link — public, fetched from the visitor's browser, so this
6195
- // per-IP limit is its one bound and runs before the route reads anything (#4872
6196
- // owner-delegated decision 9). MODERATE (30/min per IP) leaves room for reloads and several
6197
- // tabs. An exact key, so it wins over the wildcard above.
6198
- "/api/communities/join-preview": { tier: "MODERATE" },
6199
- // An announcement email's unsubscribe (#4872 PR 8a) — public: its token is its one credential, so
6200
- // this per-IP limit is its one bound, and runs before the route reads anything. MODERATE (30/min
6201
- // per IP), not STRICT: mail clients' one-click unsubscribe POSTs it from their own servers, which
6202
- // many members' clicks share, and STRICT's 5/min bucket is shared with sign-in. An exact key, so
6203
- // it wins over the wildcard above.
6204
- [COMMUNITY_EMAIL_UNSUBSCRIBE_PATH]: { tier: "MODERATE" },
6205
- // The WayAI Guide's help entry (wayai#4948, `routes/api/guide.ts`): one POST per click by a viewer
6206
- // the snapshot does not show enrolled, which reads the person's row on the Guide hub and writes only
6207
- // what is missing (an enrolled viewer's click opens the hub without a request). Every caller is
6208
- // signed in, so the per-IP tier is skipped; 10 a minute per person on the native binding (fails
6209
- // open, like every 60 s budget) bounds what a looping client costs the one Guide HubDO.
6210
- "/api/guide/access": {
6211
- tier: "STANDARD",
6212
- userLimit: 10,
6213
- skipAuthenticatedUsers: true,
6214
- userLimitKey: "/api/guide/access"
6215
- },
6216
- // App channel - high throughput with user limits
6217
- "/channels/app/*": { tier: "HIGH", userLimit: 500, skipAuthenticatedUsers: true },
6218
- // API channel (api-channel-connector) - machine-to-machine, high throughput
6219
- "/channels/api/*": { tier: "HIGH", userLimit: 500, skipAuthenticatedUsers: true },
6220
- // System/scheduled - high throughput (internal)
6221
- "/channels/system/*": { tier: "HIGH", skipAuthenticatedUsers: true },
6222
- "/scheduled/*": { tier: "HIGH", skipAuthenticatedUsers: true },
6223
- // WebSocket - standard with user limit to prevent connection spam
6224
- "/live-updates/ws": { tier: "STANDARD", userLimit: 100, failClosed: true },
6225
- // A community's live socket (gh #4872 PR 5, `GET /communities/:communityId/live`): outside
6226
- // `/api/*`, with no bearer token, so its per-IP tier is its one bound before the CommunityDO
6227
- // checks the ticket. STANDARD, as `/live-updates/ws`: a client opens one per community it shows
6228
- // and reconnects within the hour.
6229
- "/communities/*": { tier: "STANDARD" },
6230
- // WS ticket mint - per-user 60/min accommodates aggressive reconnect patterns
6231
- // without opening abuse vectors; fail-closed so Redis outages don't let
6232
- // runaway clients mint unbounded tickets.
6233
- "/api/auth/ws-ticket": { tier: "MODERATE", userLimit: 60, failClosed: true, skipAuthenticatedUsers: true },
6234
- "/api/auth/session-check": { tier: "STANDARD", userLimit: 120, skipAuthenticatedUsers: true },
6235
- "/api/auth/logout": { tier: "MODERATE", userLimit: 10, failClosed: true, skipAuthenticatedUsers: true }
6236
- };
6237
- EXCLUDED_PATHS = /* @__PURE__ */ new Set(["/health"]);
6238
- }
6239
- });
6240
-
6241
- // ../../packages/core/dist/chunk-7QJBCQR3.js
6242
- function fileSnapshotChanged(run) {
6243
- return run.written + run.removed > 0;
6244
- }
6245
- async function runFileSnapshot(opts) {
6246
- const run = { pages: 0, written: 0, removed: 0, unchanged: 0 };
6247
- const seen = /* @__PURE__ */ new Set();
6248
- let cursor;
6249
- while (run.pages < FILE_SNAPSHOT_MAX_PAGES) {
6250
- const page = await sendWithRetry(opts, cursor);
6251
- run.pages++;
6252
- run.written += page.written;
6253
- run.removed += page.removed;
6254
- run.unchanged += page.unchanged;
6255
- opts.onPage?.(page, run.pages);
6256
- if (page.next_cursor === null) return run;
6257
- if (seen.has(page.next_cursor)) {
6258
- throw new Error(`The preview file snapshot repeated its cursor after page ${run.pages}, so it would never end.`);
6259
- }
6260
- seen.add(page.next_cursor);
6261
- cursor = page.next_cursor;
6262
- }
6263
- throw new Error(`The preview file snapshot did not end after ${FILE_SNAPSHOT_MAX_PAGES} pages.`);
6264
- }
6265
- async function sendWithRetry(opts, cursor) {
6266
- for (let attempt = 1; ; attempt++) {
6267
- let body;
6268
- try {
6269
- body = await opts.sendPage(cursor);
6270
- } catch (error) {
6271
- if (attempt < FILE_SNAPSHOT_CONFLICT_ATTEMPTS && opts.isConflict(error)) continue;
6272
- throw error;
6273
- }
6274
- const parsed = rekorFileSnapshotAnswerSchema.safeParse(body);
6275
- if (!parsed.success) {
6276
- throw new Error("The data product answered a preview file snapshot page WayAI cannot read: nothing more was sent.");
6277
- }
6278
- return parsed.data.data;
6279
- }
6280
- }
6281
- var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
6282
- var init_chunk_7QJBCQR3 = __esm({
6283
- "../../packages/core/dist/chunk-7QJBCQR3.js"() {
6284
- "use strict";
6285
- init_chunk_D7SSWNL3();
6286
- init_chunk_5XEJSR22();
6287
- init_zod();
6288
- rekorFileSnapshotAnswerSchema = external_exports.object({
6289
- data: external_exports.object({
6290
- next_cursor: external_exports.string().nullable(),
6291
- /** Files the page created or replaced on the preview. */
6292
- written: external_exports.number().int(),
6293
- /** The preview's own files, ones production does not hold, the page removed. */
6294
- removed: external_exports.number().int(),
6295
- /** Files the page found already equal to production's. */
6296
- unchanged: external_exports.number().int()
6297
- })
6298
- });
6299
- FILE_SNAPSHOT_MAX_PAGES = 1e4;
6300
- FILE_SNAPSHOT_CONFLICT_ATTEMPTS = 3;
6301
- FILE_SNAPSHOT_PAGE_SPACING_MS = Math.ceil(
6302
- 6e4 / Math.max(1, Math.floor((getEndpointConfig(`${DATA_PROXY_PREFIX}/files/snapshot`)?.userLimit ?? 60) * 4 / 5))
6303
- );
6304
- FILE_SNAPSHOT_CONFLICT_STATUS = 409;
6305
- }
6306
- });
6307
-
6308
- // ../../packages/core/dist/chunk-IPDOHAZ5.js
6309
- var reportSourceSchema, intakeReportSourceSchema, reportClassificationSchema, reportStatusSchema, reportLocaleSchema, reportMessageAuthorRoleSchema, reportMessageSchema, sentryRefStatusSchema, createReportBody, editReportBody, reporterReportSummarySchema, reporterListResponseSchema, getReportResponseSchema, reporterTransitionResponseSchema, contestReportBody, reporterListQuery, listReportsQuery, GITHUB_ISSUE_URL_REGEX, githubIssueUrlSchema, transitionReportBody, groupReportsBody, holdReportBody;
6310
- var init_chunk_IPDOHAZ5 = __esm({
6311
- "../../packages/core/dist/chunk-IPDOHAZ5.js"() {
6312
- "use strict";
6313
- init_chunk_HZ6CADSY();
6314
- init_zod();
6315
- reportSourceSchema = external_exports.enum(["sentry", "cli", "review", "security_audit"]);
6316
- intakeReportSourceSchema = external_exports.enum(["cli", "review", "security_audit"]);
6317
- reportClassificationSchema = external_exports.enum(["bug", "flaky_test", "security", "enhancement"]);
6318
- reportStatusSchema = external_exports.enum([
6319
- "pending",
6320
- "grouped",
6321
- "escalated",
6322
- "shipped",
6323
- "contested",
6324
- "addressed",
6325
- "dismissed"
6326
- ]);
6327
- reportLocaleSchema = external_exports.enum(["en", "pt", "es"]);
6328
- reportMessageAuthorRoleSchema = external_exports.enum(["reporter", "triage", "fixer", "system"]);
6329
- reportMessageSchema = external_exports.object({
6330
- message_id: external_exports.string(),
6331
- author_role: reportMessageAuthorRoleSchema,
6332
- /** The status transition this note accompanied (e.g. 'shipped'); null for a free/system note. */
6333
- transition: external_exports.string().nullable(),
6334
- body: external_exports.string(),
6335
- created_at: timestampSchema,
6336
- /**
6337
- * Visibility: `false` = reporter-facing (the default for every narrative entry); `true` =
6338
- * triage-internal (e.g. a `hold` rationale) — surfaced to platform admins only and NEVER
6339
- * returned on the reporter read path. The reporter's `GET /api/reports/:id` filters these out.
6340
- */
6341
- internal: external_exports.boolean()
6342
- });
6343
- sentryRefStatusSchema = external_exports.enum(["valid", "not_found", "mismatch", "unverified"]);
6344
- createReportBody = external_exports.object({
6345
- title: external_exports.string().min(5).max(256),
6346
- description: external_exports.string().min(10).max(5e3),
6347
- steps_to_reproduce: external_exports.string().max(3e3).optional(),
6348
- error_message: external_exports.string().max(2e3).optional(),
6349
- // Taxonomy (server defaults: source=cli, classification=bug when absent).
6350
- source: intakeReportSourceSchema.optional(),
6351
- classification: reportClassificationSchema.optional(),
6352
- // Stable dedup key (e.g. "<file>::<test>" for flaky, "<file>:<line>" for
6353
- // security). When present, the fingerprint uses it instead of the body hash.
6354
- dedup_key: external_exports.string().min(1).max(256).optional(),
6355
- // Context fields (auto-captured by the CLI)
6356
- organization_id: external_exports.string().optional(),
6357
- hub_id: external_exports.string().uuid().optional(),
6358
- hub_name: external_exports.string().max(256).optional(),
6359
- conversation_id: external_exports.string().uuid().optional(),
6360
- agent_id: external_exports.string().uuid().optional(),
6361
- agent_name: external_exports.string().max(256).optional(),
6362
- client_version: external_exports.string().max(64).optional(),
6363
- additional_context: external_exports.string().max(2e3).optional()
6364
- });
6365
- editReportBody = external_exports.object({
6366
- title: external_exports.string().min(5).max(256).optional(),
6367
- description: external_exports.string().min(10).max(5e3).optional(),
6368
- steps_to_reproduce: external_exports.string().max(3e3).optional(),
6369
- error_message: external_exports.string().max(2e3).optional(),
6370
- additional_context: external_exports.string().max(2e3).optional()
6371
- }).strict().refine((b) => Object.keys(b).length > 0, {
6372
- message: "at least one field must be provided"
6373
- });
6374
- reporterReportSummarySchema = external_exports.object({
6375
- report_id: external_exports.string(),
6376
- title: external_exports.string(),
6377
- description: external_exports.string(),
6378
- classification: reportClassificationSchema,
6379
- status: reportStatusSchema,
6380
- created_at: timestampSchema,
6381
- triaged_at: timestampSchema.nullable(),
6382
- resolved_at: timestampSchema.nullable(),
6383
- /** How many times the reporter has contested (gates the hard cap). */
6384
- contest_count: external_exports.number(),
6385
- /** True once triage issued a non-contestable (final) dismissal. */
6386
- dismissal_final: external_exports.boolean()
6387
- });
6388
- reporterListResponseSchema = external_exports.object({
6389
- data: external_exports.array(reporterReportSummarySchema)
6390
- });
6391
- getReportResponseSchema = external_exports.object({
6392
- report: reporterReportSummarySchema,
6393
- messages: external_exports.array(reportMessageSchema)
6394
- });
6395
- reporterTransitionResponseSchema = external_exports.object({
6396
- report: reporterReportSummarySchema
6397
- });
6398
- contestReportBody = external_exports.object({
6399
- reason: external_exports.string().min(1).max(5e3)
6400
- });
6401
- reporterListQuery = external_exports.object({
6402
- status: reportStatusSchema.optional()
6403
- });
6404
- listReportsQuery = external_exports.object({
6405
- status: reportStatusSchema.optional(),
6406
- source: reportSourceSchema.optional(),
6407
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
6408
- offset: external_exports.coerce.number().int().min(0).optional(),
6409
- /** ISO 8601 lower bound on created_at. */
6410
- since: external_exports.string().datetime().optional(),
6411
- /**
6412
- * ISO 8601 lower bound on resolution time — "what did we resolve recently", which `since`
6413
- * (a created_at filter) cannot answer for a long-lived report resolved yesterday. Implies
6414
- * a terminal status (`addressed`/`dismissed`) and orders on that same axis.
6415
- */
6416
- resolved_since: external_exports.string().datetime().optional()
6417
- });
6418
- GITHUB_ISSUE_URL_REGEX = /^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+(?:[/?#]|$)/;
6419
- githubIssueUrlSchema = external_exports.string().url().refine((u) => GITHUB_ISSUE_URL_REGEX.test(u), {
6420
- message: "must be an https://github.com/<owner>/<repo>/issues/<number> URL"
6421
- });
6422
- transitionReportBody = external_exports.discriminatedUnion("target", [
6423
- external_exports.object({
6424
- target: external_exports.literal("escalated"),
6425
- gh_issue_url: githubIssueUrlSchema,
6426
- ai_verdict: external_exports.string().max(2e3).optional()
6427
- }),
6428
- external_exports.object({
6429
- target: external_exports.literal("shipped"),
6430
- note: external_exports.string().min(1).max(2e3).optional()
6431
- }),
6432
- external_exports.object({
6433
- target: external_exports.literal("addressed")
6434
- }),
6435
- external_exports.object({
6436
- target: external_exports.literal("dismissed"),
6437
- dismissal_reason: external_exports.string().min(1).max(5e3),
6438
- ai_verdict: external_exports.string().max(2e3).optional(),
6439
- final: external_exports.boolean().optional()
6440
- })
6441
- ]);
6442
- groupReportsBody = external_exports.object({
6443
- member_ids: external_exports.array(external_exports.string().uuid()).min(1).max(100)
6444
- });
6445
- holdReportBody = external_exports.object({
6446
- reason: external_exports.string().min(1).max(5e3)
6447
- });
6448
- }
6449
- });
6450
-
6451
- // ../../packages/core/dist/chunk-GPM7PE44.js
6452
- var bootstrapQuery;
6453
- var init_chunk_GPM7PE44 = __esm({
6454
- "../../packages/core/dist/chunk-GPM7PE44.js"() {
6455
- "use strict";
6456
- init_zod();
6457
- bootstrapQuery = external_exports.object({
6458
- active_hub_id: external_exports.string().uuid().optional(),
6459
- active_conversation_id: external_exports.string().uuid().optional(),
6460
- active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
6461
- /**
6462
- * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
6463
- * preloads it as `people.active_thread` when the viewer is a member.
6464
- */
6465
- active_thread_id: external_exports.string().uuid().optional()
6466
- });
6467
- }
6468
- });
6469
-
6470
- // ../../packages/core/dist/chunk-5VL6LBFD.js
6471
- var PERMISSIONS;
6472
- var init_chunk_5VL6LBFD = __esm({
6473
- "../../packages/core/dist/chunk-5VL6LBFD.js"() {
6474
- "use strict";
6475
- PERMISSIONS = [
6476
- "hub:read",
6477
- "hub:write",
6478
- "hub:admin",
6479
- "conversation:read",
6480
- "conversation:write",
6481
- "analytics:read",
6482
- "billing:read",
6483
- "billing:write",
6484
- "org:read",
6485
- "org:write",
6486
- "org:admin",
6487
- "contacts:write",
6488
- "platform:admin",
6489
- "*"
6490
- ];
6491
- }
6492
- });
6493
-
6494
- // ../../packages/core/dist/chunk-VEERWOZ6.js
6495
- var MAX_NAME_LENGTH2, MAX_HUBS_PER_GRANT, MAX_HUB_TAGS_PER_GRANT, MAX_GRANTS, permissionEnum, grantScopeSchema, grantSchema, createTokenBody, tokenOrgIdParam;
6496
- var init_chunk_VEERWOZ6 = __esm({
6497
- "../../packages/core/dist/chunk-VEERWOZ6.js"() {
6498
- "use strict";
6499
- init_chunk_5VL6LBFD();
6500
- init_chunk_HZ6CADSY();
6501
- init_zod();
6502
- MAX_NAME_LENGTH2 = 100;
6503
- MAX_HUBS_PER_GRANT = 50;
6504
- MAX_HUB_TAGS_PER_GRANT = 20;
6505
- MAX_GRANTS = 20;
6506
- permissionEnum = external_exports.enum(PERMISSIONS).refine(
6507
- (p) => p !== "platform:admin",
6508
- { message: "platform:admin cannot be delegated via token creation" }
6509
- );
6510
- grantScopeSchema = external_exports.object({
6511
- // Required: every token grant must declare its org tenancy. The handler
6512
- // also strict-checks this as defense-in-depth, but failing at the Zod
6513
- // boundary keeps the generated client type honest (org_id: string).
6514
- org_id: external_exports.string().min(1),
6515
- hubs: external_exports.array(external_exports.string().min(1)).min(1, "Each grant must have scope.hubs as a non-empty array").max(MAX_HUBS_PER_GRANT),
6516
- hub_tags: external_exports.array(external_exports.string().min(1)).min(1, "scope.hub_tags must be a non-empty array if provided").max(MAX_HUB_TAGS_PER_GRANT).optional(),
6517
- environments: external_exports.array(external_exports.enum(["production", "preview"])).min(1, "scope.environments must be a non-empty array if provided").optional()
6518
- }).strict();
6519
- grantSchema = external_exports.object({
6520
- scope: grantScopeSchema,
6521
- permissions: external_exports.array(permissionEnum).min(1, "Each grant must have permissions as a non-empty array")
6522
- }).strict();
6523
- createTokenBody = external_exports.object({
6524
- name: external_exports.string().trim().min(1, "name is required").max(MAX_NAME_LENGTH2, `name must be ${MAX_NAME_LENGTH2} characters or fewer`),
6525
- grants: external_exports.array(grantSchema).min(1, "grants must be a non-empty array").max(MAX_GRANTS),
6526
- expires_at: external_exports.string().datetime({ message: "expires_at must be a valid ISO 8601 date" }).refine(
6527
- (s) => new Date(s).getTime() > Date.now(),
6528
- { message: "expires_at must be in the future" }
6529
- ).optional()
6530
- });
6531
- tokenOrgIdParam = external_exports.object({ orgId: uuidSchema });
6532
- }
6533
- });
6534
-
6535
- // ../../packages/core/dist/chunk-35OU33GJ.js
6536
- var REKOR_ACTOR_TYPE_HEADER, REKOR_ACTOR_ID_HEADER, REKOR_ACTOR_LABEL_HEADER, REKOR_ACTOR_ORG_HEADER, REKOR_ACTOR_ADMIN_HEADER, REKOR_CLIENT_HEADER, REKOR_TOOL_ID_HEADER, REKOR_CLIENTS, rekorClientSchema, MAX_REKOR_TOOL_ID_LENGTH, rekorToolIdSchema, REKOR_V1_PREFIX, DATA_PROXY_ORG_QUERY_PARAM, MAX_PROVISIONING_BODY_BYTES, dataProxyQuery, rekorAttestation, REQUIRED_REKOR_ATTESTATION_HEADERS, REKOR_BOUND_BASE_HEADER, REKOR_BOUND_TOOLSET_HEADER, REKOR_BOUND_TOKEN_HEADER, REKOR_BOUND_CUSTOMER_HEADER, REKOR_BOUND_ACCESS_HEADER, REKOR_BOUND_ACCESS_SCOPE_HEADER, REKOR_BOUND_PAGE_HEADER, REKOR_BOUND_PERSON_HEADER, REKOR_PERSON_AUDIENCE_STAFF, REKOR_PERSON_AUDIENCE_CUSTOMER, REKOR_PERSON_ALL, REKOR_ACCESS_SCOPE_CUSTOMER, DATA_BASE_GENERATION_HEADER, REKOR_MAX_ACTOR_ID_LENGTH, REKOR_MAX_ACTOR_LABEL_LENGTH, REKOR_MAX_ACCESS_DIMENSIONS, REKOR_MAX_ACCESS_VALUES, REKOR_MAX_ACCESS_ID_LENGTH, REKOR_MAX_ACCESS_HEADER_LENGTH, REKOR_MAX_PERSON_PARTIES, REKOR_MAX_PERSON_IDS, REKOR_MAX_PERSON_ID_LENGTH, REKOR_MAX_PERSON_HEADER_LENGTH;
6537
- var init_chunk_35OU33GJ = __esm({
6538
- "../../packages/core/dist/chunk-35OU33GJ.js"() {
6539
- "use strict";
6540
- init_zod();
6541
- REKOR_ACTOR_TYPE_HEADER = "X-Rekor-Actor-Type";
6542
- REKOR_ACTOR_ID_HEADER = "X-Rekor-Actor-Id";
6543
- REKOR_ACTOR_LABEL_HEADER = "X-Rekor-Actor-Label";
6544
- REKOR_ACTOR_ORG_HEADER = "X-Rekor-Actor-Org";
6545
- REKOR_ACTOR_ADMIN_HEADER = "X-Rekor-Actor-Admin";
6546
- REKOR_CLIENT_HEADER = "X-Rekor-Client";
6547
- REKOR_TOOL_ID_HEADER = "X-Rekor-Tool-Id";
6548
- REKOR_CLIENTS = ["api", "cli", "mcp"];
6549
- rekorClientSchema = external_exports.enum(REKOR_CLIENTS);
6550
- MAX_REKOR_TOOL_ID_LENGTH = 128;
6551
- rekorToolIdSchema = external_exports.string().trim().min(1).max(MAX_REKOR_TOOL_ID_LENGTH);
6552
- REKOR_V1_PREFIX = "/v1";
6553
- DATA_PROXY_ORG_QUERY_PARAM = "org_id";
6554
- MAX_PROVISIONING_BODY_BYTES = 256 * 1024;
6555
- dataProxyQuery = external_exports.object({
6556
- [DATA_PROXY_ORG_QUERY_PARAM]: external_exports.string().uuid().optional()
6557
- });
6558
- rekorAttestation = external_exports.object({
6559
- [REKOR_ACTOR_TYPE_HEADER]: external_exports.enum(["user", "token"]),
6560
- [REKOR_ACTOR_ID_HEADER]: external_exports.string().min(1),
6561
- [REKOR_ACTOR_LABEL_HEADER]: external_exports.string(),
6562
- [REKOR_ACTOR_ORG_HEADER]: external_exports.string().uuid(),
6563
- [REKOR_ACTOR_ADMIN_HEADER]: external_exports.enum(["0", "1"]),
6564
- [REKOR_CLIENT_HEADER]: rekorClientSchema,
6565
- [REKOR_TOOL_ID_HEADER]: rekorToolIdSchema.optional()
6566
- });
6567
- REQUIRED_REKOR_ATTESTATION_HEADERS = Object.entries(rekorAttestation.shape).filter(([, field]) => !field.isOptional()).map(([header]) => header);
6568
- REKOR_BOUND_BASE_HEADER = "X-Rekor-Bound-Base";
6569
- REKOR_BOUND_TOOLSET_HEADER = "X-Rekor-Bound-Toolset";
6570
- REKOR_BOUND_TOKEN_HEADER = "X-Rekor-Bound-Token";
6571
- REKOR_BOUND_CUSTOMER_HEADER = "X-Rekor-Bound-Customer";
6572
- REKOR_BOUND_ACCESS_HEADER = "X-Rekor-Bound-Access";
6573
- REKOR_BOUND_ACCESS_SCOPE_HEADER = "X-Rekor-Bound-Access-Scope";
6574
- REKOR_BOUND_PAGE_HEADER = "X-Rekor-Bound-Page";
6575
- REKOR_BOUND_PERSON_HEADER = "X-Rekor-Bound-Person";
6576
- REKOR_PERSON_AUDIENCE_STAFF = "staff";
6577
- REKOR_PERSON_AUDIENCE_CUSTOMER = "customer";
6578
- REKOR_PERSON_ALL = "*";
6579
- REKOR_ACCESS_SCOPE_CUSTOMER = "customer";
6580
- DATA_BASE_GENERATION_HEADER = "X-Data-Base-Generation";
6581
- REKOR_MAX_ACTOR_ID_LENGTH = 256;
6582
- REKOR_MAX_ACTOR_LABEL_LENGTH = 256;
6583
- REKOR_MAX_ACCESS_DIMENSIONS = 8;
6584
- REKOR_MAX_ACCESS_VALUES = 100;
6585
- REKOR_MAX_ACCESS_ID_LENGTH = 32;
6586
- REKOR_MAX_ACCESS_HEADER_LENGTH = 65536;
6587
- REKOR_MAX_PERSON_PARTIES = 16;
6588
- REKOR_MAX_PERSON_IDS = 16;
6589
- REKOR_MAX_PERSON_ID_LENGTH = 64;
6590
- REKOR_MAX_PERSON_HEADER_LENGTH = 32768;
6591
- }
6592
- });
6593
-
6594
- // ../../packages/core/dist/chunk-ELIEEYPK.js
6595
- function isPersonAccessAll(lists) {
6596
- return lists !== void 0 && lists.read.length === 1 && lists.read[0] === ACCESS_UNRESTRICTED && lists.write.length === 1 && lists.write[0] === ACCESS_UNRESTRICTED;
6597
- }
6598
- function holdsPersonAccess(assignment) {
6599
- return assignment != null && Object.hasOwn(assignment, PERSON_ACCESS_KEY);
6600
- }
6601
- function withoutPersonAccess(assignment) {
6602
- if (!holdsPersonAccess(assignment)) return assignment;
6603
- const dimensions = {};
6604
- for (const [key, lists] of Object.entries(assignment)) if (key !== PERSON_ACCESS_KEY) dimensions[key] = lists;
6605
- return dimensions;
6606
- }
6607
- function personAccessRefusal(holders) {
6608
- return `${holders} never hold "${PERSON_ACCESS_KEY}"`;
6609
- }
6610
- function personlessAssignmentSchema(holders) {
6611
- return heldAccessAssignmentSchema.refine((assignment) => !holdsPersonAccess(assignment), {
6612
- message: personAccessRefusal(holders),
6613
- path: [PERSON_ACCESS_KEY]
6614
- });
6615
- }
6616
- function writeWithinRead(assignment) {
6617
- return Object.values(assignment).every(({ read, write }) => read.includes(ACCESS_UNRESTRICTED) || !write.includes(ACCESS_UNRESTRICTED) && write.every((id) => read.includes(id)));
6618
- }
6619
- function isEncodedAccessSet(raw) {
6620
- let parsed;
6621
- try {
6622
- parsed = JSON.parse(raw);
6623
- } catch {
6624
- return false;
6625
- }
6626
- return accessSetSchema.safeParse(parsed).success;
6627
- }
6628
- function assignmentHasUnrestricted(assignment) {
6629
- return Object.values(assignment).some((lists) => lists.read.includes(ACCESS_UNRESTRICTED) || lists.write.includes(ACCESS_UNRESTRICTED));
6630
- }
6631
- var ACCESS_UNRESTRICTED, ACCESS_ID_REGEX, ACCESS_ID_MAX_LENGTH, MAX_ACCESS_DIMENSIONS_PER_ORG, MAX_ACCESS_VALUES_PER_DIMENSION, ACCESS_LABEL_MAX_LENGTH, accessIdSchema, accessLabelSchema, accessValueListSchema, accessListsSchema, accessAssignmentSchema, PERSON_ACCESS_KEY, heldAccessKeySchema, heldAccessAssignmentSchema, AGENT_PERSON_ACCESS_REFUSAL, accessSetSchema, accessDimensionParam, accessValueParam, orgMemberParam, orgHubParam, createAccessDimensionBody, updateAccessDimensionBody, createAccessValueBody, updateAccessValueBody, setMemberAccessValuesBody, HUB_PERSON_KINDS, ACCESS_PERSON_KINDS, setHubUserAccessValuesBody, setHubAccessValuesBody, setAgentAccessValuesBody;
6632
- var init_chunk_ELIEEYPK = __esm({
6633
- "../../packages/core/dist/chunk-ELIEEYPK.js"() {
6634
- "use strict";
6635
- init_chunk_35OU33GJ();
6636
- init_chunk_HZ6CADSY();
6637
- init_chunk_YROEDMVZ();
6638
- init_zod();
6639
- ACCESS_UNRESTRICTED = "*";
6640
- ACCESS_ID_REGEX = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
6641
- ACCESS_ID_MAX_LENGTH = REKOR_MAX_ACCESS_ID_LENGTH;
6642
- MAX_ACCESS_DIMENSIONS_PER_ORG = REKOR_MAX_ACCESS_DIMENSIONS;
6643
- MAX_ACCESS_VALUES_PER_DIMENSION = REKOR_MAX_ACCESS_VALUES;
6644
- ACCESS_LABEL_MAX_LENGTH = 100;
6645
- accessIdSchema = external_exports.string().min(1).max(ACCESS_ID_MAX_LENGTH).regex(ACCESS_ID_REGEX, { message: 'Must be ASCII letters, digits, "_" or "-", starting with a letter or digit (e.g. "class", "7A")' });
6646
- accessLabelSchema = external_exports.string().trim().min(1).max(ACCESS_LABEL_MAX_LENGTH);
6647
- accessValueListSchema = external_exports.array(external_exports.union([accessIdSchema, external_exports.literal(ACCESS_UNRESTRICTED)])).max(MAX_ACCESS_VALUES_PER_DIMENSION).refine((list2) => !list2.includes(ACCESS_UNRESTRICTED) || list2.length === 1, {
6648
- message: `"${ACCESS_UNRESTRICTED}" reaches the dimension unrestricted, so it stands alone in its list`
6649
- });
6650
- accessListsSchema = external_exports.object({ read: accessValueListSchema, write: accessValueListSchema }).strict();
6651
- accessAssignmentSchema = external_exports.record(accessIdSchema, accessListsSchema).refine((assignment) => Object.keys(assignment).length <= MAX_ACCESS_DIMENSIONS_PER_ORG, {
6652
- message: `An assignment names at most ${MAX_ACCESS_DIMENSIONS_PER_ORG} dimensions`
6653
- });
6654
- PERSON_ACCESS_KEY = "$person";
6655
- heldAccessKeySchema = external_exports.string().refine(
6656
- (key) => key === PERSON_ACCESS_KEY || accessIdSchema.safeParse(key).success,
6657
- { message: `Must be "${PERSON_ACCESS_KEY}" or a dimension id: ASCII letters, digits, "_" or "-", starting with a letter or digit (e.g. "class", "7A")` }
6658
- );
6659
- heldAccessAssignmentSchema = external_exports.record(heldAccessKeySchema, accessListsSchema).superRefine((assignment, ctx) => {
6660
- if (holdsPersonAccess(assignment) && !isPersonAccessAll(assignment[PERSON_ACCESS_KEY])) {
6661
- ctx.addIssue({
6662
- code: external_exports.ZodIssueCode.custom,
6663
- path: [PERSON_ACCESS_KEY],
6664
- message: `"${PERSON_ACCESS_KEY}" holds only { "read": ["${ACCESS_UNRESTRICTED}"], "write": ["${ACCESS_UNRESTRICTED}"] }: every person's records`
6665
- });
6666
- }
6667
- if (Object.keys(withoutPersonAccess(assignment)).length > MAX_ACCESS_DIMENSIONS_PER_ORG) {
6668
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `An assignment names at most ${MAX_ACCESS_DIMENSIONS_PER_ORG} dimensions` });
6669
- }
6670
- });
6671
- AGENT_PERSON_ACCESS_REFUSAL = `A customer-facing agent (${CUSTOMER_FACING_AGENT_ROLES.map((role) => AGENT_ROLE_DISPLAY[role]).join(", ")}) never holds "${PERSON_ACCESS_KEY}" in its access values: remove it, or give the agent another role`;
6672
- accessSetSchema = accessAssignmentSchema.refine(writeWithinRead, {
6673
- message: "An access set writes only what it reads"
6674
- });
6675
- accessDimensionParam = external_exports.object({
6676
- id: uuidSchema,
6677
- dimensionId: accessIdSchema
5822
+ init_chunk_CRZFVWXY();
5823
+ init_chunk_7GDM456L();
5824
+ init_zod();
5825
+ TOOLSET_SLUG_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
5826
+ REKOR_STRUCTURAL_ID_PATTERN = TOOLSET_SLUG_PATTERN;
5827
+ baseEnvironmentSchema = external_exports.enum(["preview", "production"]);
5828
+ toolsetFileToolSchema = external_exports.object({
5829
+ file_type: external_exports.string().min(1),
5830
+ path_prefix: external_exports.string(),
5831
+ /** The entry's authored description of its tools (`description_override`), when it has one. */
5832
+ description: external_exports.string().min(1).optional(),
5833
+ tools: external_exports.object({
5834
+ list: external_exports.string().min(1).optional(),
5835
+ get: external_exports.string().min(1).optional(),
5836
+ put: external_exports.string().min(1).optional(),
5837
+ delete: external_exports.string().min(1).optional(),
5838
+ get_url: external_exports.string().min(1).optional(),
5839
+ put_url: external_exports.string().min(1).optional()
5840
+ })
6678
5841
  });
6679
- accessValueParam = accessDimensionParam.extend({
6680
- valueId: accessIdSchema
5842
+ toolsetSurfaceSchema = external_exports.object({
5843
+ /** Any record, composite, relationship or SQL Action tool: the toolset reaches records. */
5844
+ records: external_exports.boolean(),
5845
+ sql_query: external_exports.boolean(),
5846
+ batch: external_exports.boolean(),
5847
+ /**
5848
+ * The toolset serves one customer per call (#5083 RK2): its every call names the customer it serves. No call names
5849
+ * one — an agent's (#5473 2b1, an eval run's included since 2-eval) or a page's (2b2) — so it is refused it. The
5850
+ * data product reports no toolset as customer-scoped since it removed customer scope (#5473 2c), so a surface
5851
+ * recorded since reads `false`; one recorded before keeps `true` until its next tool sync or token save. Absent on
5852
+ * a surface recorded before it was, which reads as not scoped: its calls name no customer.
5853
+ */
5854
+ customer_scoped: external_exports.boolean().optional(),
5855
+ /**
5856
+ * A key of the resolve this side neither describes nor classifies exposes something: a kind of tool
5857
+ * the data product added later, counted in `records`. The customer-facing rule never admits it, to
5858
+ * any holder, until it is classified here. Absent on a surface recorded before it was,
5859
+ * which reads as present.
5860
+ */
5861
+ unclassified_tools: external_exports.boolean().optional(),
5862
+ /**
5863
+ * Any of its file tools writes: an operation other than `list`, `get` and `get_url` (`put`, `delete`,
5864
+ * `put_url`, or one the data product adds later), or an entry this side cannot read. Absent on a surface recorded
5865
+ * before it was, which the customer-facing rule reads as writing until the connection's next tool
5866
+ * sync or token save records it.
5867
+ */
5868
+ file_writes: external_exports.boolean().optional(),
5869
+ /**
5870
+ * A record type the resolve's `record_types` carries names the toolset among its writers
5871
+ * (`x-review.writers`, #5083 RK4): the toolset writes the type's drafts and reads its every record,
5872
+ * drafts included. Those are the types its actions and composite record steps reach, and every
5873
+ * reviewed type it reaches otherwise: at a relationship tool's or a composite relationship step's
5874
+ * end, in a `batch` entry, or, through `sql_query`, all of them (decision 198). Or such a type's
5875
+ * declaration this side cannot read, or a resolve reaching records that carries no record types.
5876
+ * Absent on a surface recorded before it was, which the customer-facing rule reads as writing, for a
5877
+ * toolset reaching records, until the connection's next tool sync or token save records it.
5878
+ */
5879
+ review_writes: external_exports.boolean().optional(),
5880
+ /**
5881
+ * Every record type the toolset reaches, at least one, is reviewed (`x-review`), holds no customer data
5882
+ * (`shared`), and does not name it among its writers: each call reads only that type's approved
5883
+ * records (#5083 decision 182, Q9). Never with a SQL Action, whose query reads its types' every
5884
+ * record, drafts included. Absent on a surface recorded before it was, which reads as false.
5885
+ */
5886
+ approved_reads_only: external_exports.boolean().optional(),
5887
+ /**
5888
+ * The toolset's file tools. Absent when it has none, and on a surface recorded before they were.
5889
+ * A list this side cannot read is dropped rather than failing the binding, which every call and
5890
+ * the customer-facing rule read: the next tool sync records it again.
5891
+ */
5892
+ files: external_exports.array(toolsetFileToolSchema).optional().catch(void 0)
6681
5893
  });
6682
- orgMemberParam = external_exports.object({
6683
- id: uuidSchema,
6684
- userId: external_exports.string().min(1).max(256)
5894
+ toolsetConnectionBindingSchema = external_exports.object({
5895
+ base_id: external_exports.string().min(1),
5896
+ /** The slug the token was resolved against — `settings.toolset` at that write. */
5897
+ toolset: external_exports.string().min(1),
5898
+ /** The base's incarnation when the token was written; a bound attested call states it. */
5899
+ base_generation: external_exports.number().int().min(1),
5900
+ environment: baseEnvironmentSchema,
5901
+ surface: toolsetSurfaceSchema,
5902
+ /**
5903
+ * The id of the token the binding was resolved from, as its resolve reports it; a bound attested
5904
+ * call names it (`REKOR_BOUND_TOKEN_HEADER`), so the data product refuses the binding once the token
5905
+ * is revoked or expires (owner decision 41). Absent on a binding recorded before the report carried
5906
+ * it: its calls name none until a token save, or a tool sync while the token still stands, records it.
5907
+ * One that does not read is dropped rather than failing the binding.
5908
+ */
5909
+ token_id: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN).optional().catch(void 0)
6685
5910
  });
6686
- orgHubParam = external_exports.object({
6687
- id: uuidSchema,
6688
- hubId: uuidSchema
5911
+ rekorToolsetToolsSchema = external_exports.object({
5912
+ data: external_exports.object({
5913
+ tools: external_exports.array(external_exports.object({
5914
+ name: external_exports.string(),
5915
+ description: external_exports.string().optional(),
5916
+ inputSchema: external_exports.record(external_exports.unknown()).optional()
5917
+ }))
5918
+ })
6689
5919
  });
6690
- createAccessDimensionBody = external_exports.object({
6691
- dimension_id: accessIdSchema,
6692
- label: accessLabelSchema
5920
+ rekorPersonIdSchema = external_exports.string().max(REKOR_MAX_PERSON_ID_LENGTH).regex(REKOR_STRUCTURAL_ID_PATTERN);
5921
+ rekorPersonAudienceSchema = external_exports.enum([REKOR_PERSON_AUDIENCE_STAFF, REKOR_PERSON_AUDIENCE_CUSTOMER]);
5922
+ rekorBoundPersonSchema = external_exports.object({
5923
+ audience: rekorPersonAudienceSchema,
5924
+ parties: external_exports.array(external_exports.union([external_exports.array(rekorPersonIdSchema).max(REKOR_MAX_PERSON_IDS), external_exports.literal(REKOR_PERSON_ALL)])).max(REKOR_MAX_PERSON_PARTIES),
5925
+ agent_all: external_exports.boolean(),
5926
+ customer: external_exports.number().int().nonnegative().optional()
5927
+ }).strict().refine((person) => !person.agent_all || person.audience === REKOR_PERSON_AUDIENCE_STAFF, {
5928
+ message: `The agent's "*" applies only to a staff call`,
5929
+ path: ["agent_all"]
5930
+ }).refine((person) => person.customer === void 0 || boundCustomerPartyIsValid(person.audience, person.parties, person.customer), {
5931
+ message: "The customer party is a listed party of person ids, on a call that is not staff's",
5932
+ path: ["customer"]
6693
5933
  });
6694
- updateAccessDimensionBody = external_exports.object({
6695
- label: accessLabelSchema
5934
+ rekorBoundAttestation = rekorAttestation.extend({
5935
+ [REKOR_ACTOR_TYPE_HEADER]: external_exports.enum(["token", "user"]),
5936
+ /** Trimmed and checked as the far side trims and checks it. */
5937
+ [REKOR_ACTOR_ID_HEADER]: external_exports.string().trim().min(1).max(REKOR_MAX_ACTOR_ID_LENGTH),
5938
+ [REKOR_ACTOR_LABEL_HEADER]: external_exports.string().max(REKOR_MAX_ACTOR_LABEL_LENGTH),
5939
+ [REKOR_ACTOR_ADMIN_HEADER]: external_exports.literal("0"),
5940
+ [REKOR_BOUND_BASE_HEADER]: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN),
5941
+ [REKOR_BOUND_TOOLSET_HEADER]: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN),
5942
+ /**
5943
+ * Decimal digits only, as the far side parses it, and at most 15 of them: its `Number()` reads
5944
+ * every such value back exactly, where a longer one may round or overflow to `Infinity` (a 400).
5945
+ */
5946
+ [DATA_BASE_GENERATION_HEADER]: external_exports.string().regex(/^[1-9]\d{0,14}$/),
5947
+ /** The token the binding was resolved from, when the connection records it (owner decision 41). */
5948
+ [REKOR_BOUND_TOKEN_HEADER]: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN).optional(),
5949
+ /**
5950
+ * The customer the call serves (#5083 RK2): a contact id, which the contact book mints as a UUID.
5951
+ * Every UUID is an id the far side reads back as the customer's external id.
5952
+ */
5953
+ [REKOR_BOUND_CUSTOMER_HEADER]: external_exports.string().uuid().optional(),
5954
+ /**
5955
+ * The access set the call carries (#5358): an access set's header text (`encodeAccessSet`), within
5956
+ * the far side's header cap. Tool calls carry one; the config reads (resolve, tool definitions) do not.
5957
+ */
5958
+ [REKOR_BOUND_ACCESS_HEADER]: external_exports.string().max(REKOR_MAX_ACCESS_HEADER_LENGTH).refine(isEncodedAccessSet, {
5959
+ message: "Not an access set"
5960
+ }).optional(),
5961
+ /**
5962
+ * Where the access set applies (#5358), when only on the call's customer's own records: its one value.
5963
+ * Sent only beside the set, which the far side holds it to (the refinement below).
5964
+ */
5965
+ [REKOR_BOUND_ACCESS_SCOPE_HEADER]: external_exports.literal(REKOR_ACCESS_SCOPE_CUSTOMER).optional(),
5966
+ /**
5967
+ * The hub whose page makes the call (#5333): sent on every call of the page bridge, and on no other.
5968
+ * A hub id, read by the far side under the same structural charset as the other bound ids.
5969
+ */
5970
+ [REKOR_BOUND_PAGE_HEADER]: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN).optional(),
5971
+ /**
5972
+ * The persons the call is for (#5473 §9): their header text (`encodeBoundPerson`), within the far side's
5973
+ * header cap. Every tool call carries it beside its access set (`apps/backend/src/rekor/access-set.ts`); the
5974
+ * config reads do not. The far side holds a call's reads and writes of a person-ruled record type to its parties,
5975
+ * whatever its audience, and a customer-facing call to its audience gate (#5473 2a).
5976
+ */
5977
+ [REKOR_BOUND_PERSON_HEADER]: external_exports.string().max(REKOR_MAX_PERSON_HEADER_LENGTH).refine(isEncodedBoundPerson, {
5978
+ message: "Not the persons a bound call is for"
5979
+ }).optional()
5980
+ }).superRefine((bag, ctx) => {
5981
+ if (bag[REKOR_BOUND_ACCESS_SCOPE_HEADER] !== void 0 && bag[REKOR_BOUND_ACCESS_HEADER] === void 0) {
5982
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: [REKOR_BOUND_ACCESS_SCOPE_HEADER], message: "Accepted only beside an access set" });
5983
+ }
5984
+ if (bag[REKOR_ACTOR_TYPE_HEADER] === "user" && (bag[REKOR_BOUND_PAGE_HEADER] === void 0 || bag[REKOR_BOUND_CUSTOMER_HEADER] !== void 0)) {
5985
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: [REKOR_ACTOR_TYPE_HEADER], message: "A person is attested only on a team page's call" });
5986
+ }
6696
5987
  });
6697
- createAccessValueBody = external_exports.object({
6698
- value_id: accessIdSchema,
6699
- label: accessLabelSchema
5988
+ rekorResolvedToolsetSchema = external_exports.object({
5989
+ data: external_exports.object({
5990
+ base_id: external_exports.string().min(1),
5991
+ environment: baseEnvironmentSchema,
5992
+ base_generation: external_exports.number().int().min(1),
5993
+ /**
5994
+ * The calling token's binding, or null for a token bound to none. A bound token can call only
5995
+ * its toolset's tools, which is what a toolset connection stores (#5083 decision 14). Its org
5996
+ * is the token's own: base ids are unique only per org, so the base id alone does not say
5997
+ * which base the token reaches.
5998
+ */
5999
+ toolset_binding: external_exports.object({
6000
+ org_id: external_exports.string().optional(),
6001
+ base_id: external_exports.string(),
6002
+ toolset_id: external_exports.string(),
6003
+ /**
6004
+ * The token's own id, which a bound call names (`REKOR_BOUND_TOKEN_HEADER`); absent when the
6005
+ * caller has none (owner decision 41), and dropped when it is not an id the far side reads back.
6006
+ */
6007
+ token_id: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN).optional().catch(void 0),
6008
+ /**
6009
+ * Whether the token is bound to persons (#5473 2-tokens), answered only for one that is: a save to a hub
6010
+ * connection refuses such a token (#5473 2b3). Any other value is a resolve this side cannot read.
6011
+ */
6012
+ person_bound: external_exports.boolean().optional()
6013
+ }).nullable().optional(),
6014
+ actions: external_exports.array(external_exports.unknown()).optional(),
6015
+ composites: external_exports.array(external_exports.unknown()).optional(),
6016
+ relationships: external_exports.array(external_exports.unknown()).optional(),
6017
+ /**
6018
+ * The toolset's SQL Actions (#5311): each a fixed, read-only query over the record types it
6019
+ * declares, which the resolve also carries in `record_types` and `record_type_scopes`.
6020
+ */
6021
+ sql_actions: external_exports.array(external_exports.unknown()).optional(),
6022
+ files: external_exports.array(external_exports.unknown()).optional(),
6023
+ batch: external_exports.object({ enabled: external_exports.boolean().optional() }).passthrough().nullable().optional(),
6024
+ sql_query: external_exports.boolean().optional(),
6025
+ /**
6026
+ * The toolset serves one customer per call (#5083 RK2). Absent reads as not scoped. Always `false` since the data
6027
+ * product removed customer scope (#5473 2c).
6028
+ */
6029
+ customer_scope: external_exports.boolean().optional(),
6030
+ /**
6031
+ * Record types the toolset reaches, by id, as the data product stores them (`json_schema`
6032
+ * included): each one its actions, composite record steps and SQL Actions reach, and each reviewed one it
6033
+ * reaches otherwise (relationship ends, `batch` entries, every one through `sql_query`; #5083
6034
+ * decision 198). An unreviewed type it reaches only otherwise is not here. A reviewed type's
6035
+ * `x-review` names its writers (RK4).
6036
+ */
6037
+ record_types: external_exports.record(external_exports.unknown()).optional(),
6038
+ /**
6039
+ * What each record type the toolset's actions, composite steps, SQL Actions and relationship tools reach is to a
6040
+ * customer scope (`{ role }`, or null), by id (#5083 RK2). A reviewed type `record_types` carries
6041
+ * because only a `batch` entry or `sql_query` reaches it has none. Since the data product removed customer
6042
+ * scope (#5473 2c), `{ role: 'shared' }` is a type whose `x-access` declares `{ shared: true }`.
6043
+ */
6044
+ record_type_scopes: external_exports.record(external_exports.unknown()).optional(),
6045
+ /**
6046
+ * The kind of each tool the toolset publishes, by the name it is published under (wayai#5333 decision
6047
+ * 6), sent only to a caller that asks (`REKOR_TOOL_KINDS_RESOLVE_SEARCH`). Read by `rekorToolKindLookup`;
6048
+ * a map this side cannot read is dropped, so every tool reads as a write.
6049
+ */
6050
+ tool_kinds: external_exports.record(external_exports.string()).optional().catch(void 0)
6051
+ }).passthrough()
6700
6052
  });
6701
- updateAccessValueBody = external_exports.object({
6702
- label: accessLabelSchema.optional(),
6703
- retired: external_exports.boolean().optional()
6704
- }).refine((body) => body.label !== void 0 || body.retired !== void 0, {
6705
- message: "Nothing to change: pass label, retired, or both"
6053
+ REKOR_TOOL_KINDS_PARAM = "tool_kinds";
6054
+ REKOR_TOOL_KINDS_RESOLVE_SEARCH = new URLSearchParams({ [REKOR_TOOL_KINDS_PARAM]: "true" }).toString();
6055
+ resolvedRecordTypeSchema = external_exports.object({ json_schema: external_exports.record(external_exports.unknown()) });
6056
+ reviewWritersSchema = external_exports.object({ writers: external_exports.array(external_exports.string()).optional() });
6057
+ sharedScopeSchema = external_exports.object({ role: external_exports.literal("shared") });
6058
+ resolvedFileToolSchema = external_exports.object({
6059
+ file_type: external_exports.string().min(1),
6060
+ path_prefix: external_exports.string().nullish(),
6061
+ operations: external_exports.array(external_exports.unknown()),
6062
+ name: external_exports.unknown().optional(),
6063
+ names: external_exports.unknown().optional(),
6064
+ description_override: external_exports.unknown().optional()
6706
6065
  });
6707
- setMemberAccessValuesBody = external_exports.object({
6708
- values: heldAccessAssignmentSchema
6066
+ rekorToolsetFileSchema = external_exports.object({
6067
+ path: external_exports.string().min(1),
6068
+ version: external_exports.number().int().min(1),
6069
+ content_type: external_exports.string().optional()
6070
+ }).passthrough();
6071
+ rekorToolsetFileUrlAnswerSchema = external_exports.object({
6072
+ data: external_exports.object({
6073
+ url: external_exports.string(),
6074
+ expires_at: external_exports.string(),
6075
+ path: external_exports.string(),
6076
+ content_sha256: external_exports.string()
6077
+ }).passthrough()
6709
6078
  });
6710
- HUB_PERSON_KINDS = ["hub_admin", "hub_team_member", "hub_user"];
6711
- ACCESS_PERSON_KINDS = ["org_member", ...HUB_PERSON_KINDS, "public"];
6712
- setHubUserAccessValuesBody = external_exports.object({
6713
- values: personlessAssignmentSchema("A hub user's values").refine((assignment) => !assignmentHasUnrestricted(assignment), {
6714
- message: `A hub user's values never hold "${ACCESS_UNRESTRICTED}"`
6079
+ rekorToolsetFileListSchema = external_exports.object({ data: external_exports.array(rekorToolsetFileSchema) });
6080
+ rekorToolsetFileGetSchema = external_exports.object({
6081
+ data: rekorToolsetFileSchema.extend({
6082
+ content: external_exports.string(),
6083
+ encoding: external_exports.enum(["utf-8", "base64"])
6715
6084
  })
6716
6085
  });
6717
- setHubAccessValuesBody = external_exports.object({
6718
- values: personlessAssignmentSchema("A hub's values and its public values")
6719
- });
6720
- setAgentAccessValuesBody = external_exports.object({
6721
- values: heldAccessAssignmentSchema.nullable()
6722
- });
6086
+ rekorToolsetFilePutSchema = external_exports.object({ data: rekorToolsetFileSchema });
6087
+ TOOLSET_CUSTOMER_FACING_REFUSAL_MARK = "A customer-facing agent (a pilot, pilot specialist or pilot advisor) can use a toolset only when it exposes files alone: no record, composite or relationship tools, and neither sql_query nor batch";
6088
+ TOOLSET_CUSTOMER_FACING_REFUSAL = `${TOOLSET_CUSTOMER_FACING_REFUSAL_MARK}, nor a file put, delete or put_url, nor a write of a reviewed record type, nor a kind of tool WayAI does not classify. Its record, composite, relationship and SQL Action tools are admitted to a customer-facing agent and a customer page, since the data product holds each of their calls to the record types that declare person rules or shared access`;
6723
6089
  }
6724
6090
  });
6725
6091
 
6726
- // ../../packages/core/dist/chunk-WBTBXPD2.js
6727
- function boundCustomerPartyIsValid(audience, parties, customer) {
6728
- return audience !== REKOR_PERSON_AUDIENCE_STAFF && customer < parties.length && Array.isArray(parties[customer]);
6729
- }
6730
- function isEncodedBoundPerson(raw) {
6731
- let parsed;
6732
- try {
6733
- parsed = JSON.parse(raw);
6734
- } catch {
6735
- return false;
6092
+ // ../../packages/core/dist/chunk-OJMHQF7E.js
6093
+ var TOOLSET_ANSWER_PERSON_PARTIES, toolsetAnswerPersonSchema, toolsetAnswerPersonsSchema;
6094
+ var init_chunk_OJMHQF7E = __esm({
6095
+ "../../packages/core/dist/chunk-OJMHQF7E.js"() {
6096
+ "use strict";
6097
+ init_chunk_Q6CHATUL();
6098
+ init_chunk_7GDM456L();
6099
+ init_zod();
6100
+ TOOLSET_ANSWER_PERSON_PARTIES = ["requester", "originator", "initiator", "delegator"];
6101
+ toolsetAnswerPersonSchema = external_exports.object({
6102
+ party: external_exports.enum(TOOLSET_ANSWER_PERSON_PARTIES),
6103
+ person_id: rekorPersonIdSchema
6104
+ }).strict();
6105
+ toolsetAnswerPersonsSchema = external_exports.array(toolsetAnswerPersonSchema).min(1).max(REKOR_MAX_PERSON_PARTIES);
6736
6106
  }
6737
- return rekorBoundPersonSchema.safeParse(parsed).success;
6738
- }
6739
- var TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, rekorToolsetToolsSchema, rekorPersonIdSchema, rekorPersonAudienceSchema, rekorBoundPersonSchema, rekorBoundAttestation, 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;
6740
- var init_chunk_WBTBXPD2 = __esm({
6741
- "../../packages/core/dist/chunk-WBTBXPD2.js"() {
6107
+ });
6108
+
6109
+ // ../../packages/core/dist/chunk-ZC6YGHNX.js
6110
+ var updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, recordAiDisclosureAcceptanceBody, activityQuery, deletionModeSchema, deletionRequestBody;
6111
+ var init_chunk_ZC6YGHNX = __esm({
6112
+ "../../packages/core/dist/chunk-ZC6YGHNX.js"() {
6742
6113
  "use strict";
6743
- init_chunk_ELIEEYPK();
6744
- init_chunk_35OU33GJ();
6745
6114
  init_zod();
6746
- TOOLSET_SLUG_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
6747
- REKOR_STRUCTURAL_ID_PATTERN = TOOLSET_SLUG_PATTERN;
6748
- baseEnvironmentSchema = external_exports.enum(["preview", "production"]);
6749
- toolsetFileToolSchema = external_exports.object({
6750
- file_type: external_exports.string().min(1),
6751
- path_prefix: external_exports.string(),
6752
- /** The entry's authored description of its tools (`description_override`), when it has one. */
6753
- description: external_exports.string().min(1).optional(),
6754
- tools: external_exports.object({
6755
- list: external_exports.string().min(1).optional(),
6756
- get: external_exports.string().min(1).optional(),
6757
- put: external_exports.string().min(1).optional(),
6758
- delete: external_exports.string().min(1).optional(),
6759
- get_url: external_exports.string().min(1).optional(),
6760
- put_url: external_exports.string().min(1).optional()
6761
- })
6762
- });
6763
- toolsetSurfaceSchema = external_exports.object({
6764
- /** Any record, composite, relationship or SQL Action tool: the toolset reaches records. */
6765
- records: external_exports.boolean(),
6766
- sql_query: external_exports.boolean(),
6767
- batch: external_exports.boolean(),
6768
- /**
6769
- * The toolset serves one customer per call (#5083 RK2): its every call names the customer it serves. Only an eval
6770
- * run names one; every other call, an agent's (#5473 2b1) or a page's (2b2), names none, so it is refused it. The
6771
- * data product reports no toolset as customer-scoped since it removed customer scope (#5473 2c), so a surface
6772
- * recorded since reads `false`; one recorded before keeps `true` until its next tool sync or token save. Absent on
6773
- * a surface recorded before it was, which reads as not scoped: its calls name no customer.
6774
- */
6775
- customer_scoped: external_exports.boolean().optional(),
6776
- /**
6777
- * A key of the resolve this side neither describes nor classifies exposes something: a kind of tool
6778
- * the data product added later, counted in `records`. The customer-facing rule never admits it, to
6779
- * any holder, until it is classified here. Absent on a surface recorded before it was,
6780
- * which reads as present.
6781
- */
6782
- unclassified_tools: external_exports.boolean().optional(),
6783
- /**
6784
- * Any of its file tools writes: an operation other than `list`, `get` and `get_url` (`put`, `delete`,
6785
- * `put_url`, or one the data product adds later), or an entry this side cannot read. Absent on a surface recorded
6786
- * before it was, which the customer-facing rule reads as writing until the connection's next tool
6787
- * sync or token save records it.
6788
- */
6789
- file_writes: external_exports.boolean().optional(),
6115
+ updateUserBody = external_exports.object({
6116
+ user_language: external_exports.string().optional(),
6117
+ /** true: dark; false: light; null: follow each device's own setting (`AppearanceMode`). */
6118
+ ui_dark_mode: external_exports.boolean().nullable().optional(),
6119
+ profile_name: external_exports.string().optional(),
6120
+ link_email_to_identities: external_exports.boolean().optional()
6121
+ }).refine(
6122
+ (data) => Object.values(data).some((v) => v !== void 0),
6123
+ { message: "At least one field must be provided" }
6124
+ );
6125
+ updateProfileBody = external_exports.object({
6126
+ display_name: external_exports.string().optional(),
6127
+ avatar_url: external_exports.string().optional(),
6128
+ preferences: external_exports.record(external_exports.unknown()).optional()
6129
+ }).refine(
6130
+ (data) => Object.values(data).some((v) => v !== void 0),
6131
+ { message: "At least one field must be provided" }
6132
+ );
6133
+ pathnameRegex = /^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@/?%]*$/;
6134
+ updatePreferencesBody = external_exports.object({
6135
+ last_viewed_nav: external_exports.string().regex(pathnameRegex, "Must be a URL pathname").max(2048).optional(),
6136
+ dismissed_agentic_shortcut: external_exports.boolean().optional(),
6137
+ opened_guide: external_exports.boolean().optional()
6138
+ }).passthrough();
6139
+ registerPushTokenBody = external_exports.object({
6140
+ token: external_exports.string().min(1).max(512),
6141
+ platform: external_exports.enum(["ios", "android"]),
6142
+ /** Stable per-install id so re-registration replaces the prior token for the device. */
6143
+ device_id: external_exports.string().min(1).max(128).optional(),
6790
6144
  /**
6791
- * A record type the resolve's `record_types` carries names the toolset among its writers
6792
- * (`x-review.writers`, #5083 RK4): the toolset writes the type's drafts and reads its every record,
6793
- * drafts included. Those are the types its actions and composite record steps reach, and every
6794
- * reviewed type it reaches otherwise: at a relationship tool's or a composite relationship step's
6795
- * end, in a `batch` entry, or, through `sql_query`, all of them (decision 198). Or such a type's
6796
- * declaration this side cannot read, or a resolve reaching records that carries no record types.
6797
- * Absent on a surface recorded before it was, which the customer-facing rule reads as writing, for a
6798
- * toolset reaching records, until the connection's next tool sync or token save records it.
6145
+ * The build opens a person-to-person thread from a push (gh #4661): only a token registered
6146
+ * with it receives thread pushes, whose `data` carries `thread_id` and no `conversation_id`.
6147
+ * Each registration states it afresh, so a build that sends none clears it.
6799
6148
  */
6800
- review_writes: external_exports.boolean().optional(),
6149
+ supports_threads: external_exports.boolean().optional(),
6801
6150
  /**
6802
- * Every record type the toolset reaches, at least one, is reviewed (`x-review`), holds no customer data
6803
- * (`shared`), and does not name it among its writers: each call reads only that type's approved
6804
- * records (#5083 decision 182, Q9). Never with a SQL Action, whose query reads its types' every
6805
- * record, drafts included. Absent on a surface recorded before it was, which reads as false.
6151
+ * The build opens a community from a push (gh #4872 Decision 8): only a token registered with it
6152
+ * receives a community's pushes (an announcement, a reply to the member's forum post), whose
6153
+ * `data` is `CommunityPushData` — never a `conversation_id` or a `thread_id`. Each registration
6154
+ * states it afresh, so a build that sends none clears it.
6806
6155
  */
6807
- approved_reads_only: external_exports.boolean().optional(),
6156
+ supports_communities: external_exports.boolean().optional()
6157
+ });
6158
+ deletePushTokenQuery = external_exports.object({
6159
+ token: external_exports.string().min(1).max(512)
6160
+ });
6161
+ recordAiDisclosureAcceptanceBody = external_exports.object({
6162
+ version: external_exports.number().int().positive(),
6163
+ withdrawn_at_seen: external_exports.string().datetime().nullable().optional()
6164
+ });
6165
+ activityQuery = external_exports.object({
6166
+ limit: external_exports.coerce.number().int().min(1).max(100).optional()
6167
+ });
6168
+ deletionModeSchema = external_exports.enum(["scheduled", "immediate"]);
6169
+ deletionRequestBody = external_exports.object({
6170
+ mode: deletionModeSchema,
6171
+ /** User-supplied reason captured in the audit log; bounded to bound logged PII. */
6172
+ reason: external_exports.string().max(500).optional(),
6173
+ /** Type-to-confirm value; must equal the user's email (constant-time compared). */
6174
+ email_confirmation: external_exports.string().min(1).max(320)
6175
+ });
6176
+ }
6177
+ });
6178
+
6179
+ // ../../packages/core/dist/chunk-ACKF2MVU.js
6180
+ var MAX_NAME_LENGTH, MAX_VALUE_LENGTH, MAX_TAGS, MAX_TAG_LENGTH, MAX_SCOPE_HUBS, MAX_SCOPE_TAGS, vaultSecretScopeSchema, vaultCreateBody, vaultUpdateBody;
6181
+ var init_chunk_ACKF2MVU = __esm({
6182
+ "../../packages/core/dist/chunk-ACKF2MVU.js"() {
6183
+ "use strict";
6184
+ init_chunk_HZ6CADSY();
6185
+ init_zod();
6186
+ MAX_NAME_LENGTH = 100;
6187
+ MAX_VALUE_LENGTH = 32 * 1024;
6188
+ MAX_TAGS = 20;
6189
+ MAX_TAG_LENGTH = 50;
6190
+ MAX_SCOPE_HUBS = 100;
6191
+ MAX_SCOPE_TAGS = 50;
6192
+ vaultSecretScopeSchema = external_exports.object({
6193
+ hubs: external_exports.array(external_exports.string().min(1)).max(MAX_SCOPE_HUBS).optional(),
6194
+ tags: external_exports.array(external_exports.string().min(1).max(MAX_TAG_LENGTH)).max(MAX_SCOPE_TAGS).optional()
6195
+ }).strict();
6196
+ vaultCreateBody = external_exports.object({
6197
+ name: external_exports.string().trim().min(1, "name is required").max(MAX_NAME_LENGTH, `name must be ${MAX_NAME_LENGTH} characters or fewer`),
6198
+ value: external_exports.string().min(1, "value is required").max(MAX_VALUE_LENGTH, `value must be ${MAX_VALUE_LENGTH} characters or fewer`),
6199
+ tags: external_exports.array(external_exports.string().min(1).max(MAX_TAG_LENGTH, `Tag must be ${MAX_TAG_LENGTH} characters or fewer`)).max(MAX_TAGS, `Maximum ${MAX_TAGS} tags allowed`).optional().default([]),
6200
+ scope: vaultSecretScopeSchema.optional().default({})
6201
+ }).strict();
6202
+ vaultUpdateBody = external_exports.object({
6203
+ name: external_exports.string().trim().min(1).max(MAX_NAME_LENGTH).optional(),
6204
+ value: external_exports.string().min(1).max(MAX_VALUE_LENGTH).optional(),
6205
+ tags: external_exports.array(external_exports.string().min(1).max(MAX_TAG_LENGTH)).max(MAX_TAGS).optional(),
6206
+ scope: vaultSecretScopeSchema.optional()
6207
+ }).strict();
6208
+ }
6209
+ });
6210
+
6211
+ // ../../packages/core/dist/chunk-5DGHIY7L.js
6212
+ var rekorBaseChangeMessageSchema;
6213
+ var init_chunk_5DGHIY7L = __esm({
6214
+ "../../packages/core/dist/chunk-5DGHIY7L.js"() {
6215
+ "use strict";
6216
+ init_zod();
6217
+ rekorBaseChangeMessageSchema = external_exports.object({
6218
+ /** The WayAI org UUID — one id namespace. */
6219
+ org_id: external_exports.string().uuid(),
6808
6220
  /**
6809
- * The toolset's file tools. Absent when it has none, and on a surface recorded before they were.
6810
- * A list this side cannot read is dropped rather than failing the binding, which every call and
6811
- * the customer-facing rule read: the next tool sync records it again.
6221
+ * Not a UUID: a preview base id is `{prod_base_id}--{slug}`. Immutable per base — a
6222
+ * preview clone is its OWN base_id — so `(base_id, scope)` keys never collide across
6223
+ * environments. Empty is never a real base id, so it is non-conforming rather than a
6224
+ * frame keyed on nothing.
6812
6225
  */
6813
- files: external_exports.array(toolsetFileToolSchema).optional().catch(void 0)
6814
- });
6815
- toolsetConnectionBindingSchema = external_exports.object({
6816
6226
  base_id: external_exports.string().min(1),
6817
- /** The slug the token was resolved against — `settings.toolset` at that write. */
6818
- toolset: external_exports.string().min(1),
6819
- /** The base's incarnation when the token was written; a bound attested call states it. */
6820
- base_generation: external_exports.number().int().min(1),
6821
- environment: baseEnvironmentSchema,
6822
- surface: toolsetSurfaceSchema,
6823
6227
  /**
6824
- * The id of the token the binding was resolved from, as its resolve reports it; a bound attested
6825
- * call names it (`REKOR_BOUND_TOKEN_HEADER`), so the data product refuses the binding once the token
6826
- * is revoked or expires (owner decision 41). Absent on a binding recorded before the report carried
6827
- * it: its calls name none until a token save, or a tool sync while the token still stands, records it.
6828
- * One that does not read is dropped rather than failing the binding.
6228
+ * Rides along so the client scopes its refetch without a lookup; the inspector scopes
6229
+ * by side.
6829
6230
  */
6830
- token_id: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN).optional().catch(void 0)
6231
+ environment: external_exports.enum(["production", "preview"]),
6232
+ /** Which pane refetches. `base` covers create/delete/promote/config changes. */
6233
+ scope: external_exports.enum(["records", "record_types", "files", "base"])
6831
6234
  });
6832
- rekorToolsetToolsSchema = external_exports.object({
6235
+ }
6236
+ });
6237
+
6238
+ // ../../packages/core/dist/chunk-5XEJSR22.js
6239
+ var DATA_PROXY_MOUNT, DATA_PROXY_PREFIX, BASE_DESTRUCTION_MOUNT, BASE_DESTRUCTION_PREFIX, BASE_DESTRUCTION_CONFIRM_PATH, COMMUNITY_EMAIL_UNSUBSCRIBE_PATH, CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH, AUTOMATION_WEBHOOK_MOUNT, MANAGED_AGENTS_WEBHOOK_MOUNT;
6240
+ var init_chunk_5XEJSR22 = __esm({
6241
+ "../../packages/core/dist/chunk-5XEJSR22.js"() {
6242
+ "use strict";
6243
+ DATA_PROXY_MOUNT = "/data";
6244
+ DATA_PROXY_PREFIX = `/api${DATA_PROXY_MOUNT}`;
6245
+ BASE_DESTRUCTION_MOUNT = "/bases";
6246
+ BASE_DESTRUCTION_PREFIX = `/api${BASE_DESTRUCTION_MOUNT}`;
6247
+ BASE_DESTRUCTION_CONFIRM_PATH = `${BASE_DESTRUCTION_PREFIX}/destruction/confirm`;
6248
+ COMMUNITY_EMAIL_UNSUBSCRIBE_PATH = "/api/communities/email-unsubscribe";
6249
+ CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH = "/api/contact-book/email-unsubscribe";
6250
+ AUTOMATION_WEBHOOK_MOUNT = "/webhooks/automations";
6251
+ MANAGED_AGENTS_WEBHOOK_MOUNT = "/webhooks/managed-agents";
6252
+ }
6253
+ });
6254
+
6255
+ // ../../packages/core/dist/chunk-D7SSWNL3.js
6256
+ function matchPath(pattern, path45) {
6257
+ const pathSegments2 = path45.replace(/\/$/, "").split("/");
6258
+ const isPrefix = pattern.endsWith("/*");
6259
+ const patternSegments = (isPrefix ? pattern.slice(0, -2) : pattern).split("/");
6260
+ if (isPrefix ? pathSegments2.length < patternSegments.length : pathSegments2.length !== patternSegments.length) {
6261
+ return false;
6262
+ }
6263
+ return patternSegments.every((segment, i) => segment === "*" ? pathSegments2[i] !== "" : segment === pathSegments2[i]);
6264
+ }
6265
+ function getEndpointConfig(path45) {
6266
+ for (const excluded of EXCLUDED_PATHS) {
6267
+ if (matchPath(excluded, path45)) {
6268
+ return null;
6269
+ }
6270
+ }
6271
+ const normalizedPath = path45.replace(/\/$/, "");
6272
+ if (!normalizedPath.endsWith("/*") && Object.prototype.hasOwnProperty.call(ENDPOINT_CONFIGS, normalizedPath)) {
6273
+ return ENDPOINT_CONFIGS[normalizedPath];
6274
+ }
6275
+ const sortedPatterns = Object.keys(ENDPOINT_CONFIGS).sort((a, b) => b.length - a.length);
6276
+ for (const pattern of sortedPatterns) {
6277
+ if (matchPath(pattern, path45)) {
6278
+ return ENDPOINT_CONFIGS[pattern];
6279
+ }
6280
+ }
6281
+ return { tier: "STANDARD" };
6282
+ }
6283
+ var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
6284
+ var init_chunk_D7SSWNL3 = __esm({
6285
+ "../../packages/core/dist/chunk-D7SSWNL3.js"() {
6286
+ "use strict";
6287
+ init_chunk_5XEJSR22();
6288
+ ENDPOINT_CONFIGS = {
6289
+ // OAuth callbacks - strict, fail-closed (prevent brute force)
6290
+ "/oauth/callback/*": { tier: "STRICT", failClosed: true },
6291
+ // Auth endpoints - strict, fail-closed
6292
+ "/auth/phone": { tier: "STRICT", failClosed: true },
6293
+ "/auth/mcp/exchange": { tier: "MODERATE", failClosed: true },
6294
+ // Native magic-code login (pre-auth) — STRICT per-IP bounds a single host; WorkOS owns
6295
+ // the per-email lockout / TTL / single-use guarantees.
6296
+ "/api/auth/magic-code/*": { tier: "STRICT", failClosed: true },
6297
+ // Native password login (pre-auth) — same posture as magic-code above. STRICT per-IP bounds a
6298
+ // single host but FAILS OPEN on a binding error (like every IP limit); the `failClosed` flag
6299
+ // here is inert on a pre-auth route (it's only enforced on the per-user branch, which needs an
6300
+ // authenticated caller). The fail-CLOSED brute-force guarantee for the static credential comes
6301
+ // from the route's per-email caps (burst + cumulative hourly), not this flag.
6302
+ "/api/auth/password/*": { tier: "STRICT", failClosed: true },
6303
+ // Every `/api/*` group whose paths carry ids pins `userLimitKey` (gh #4756), held there by
6304
+ // `security/endpoint-invariants.test.ts`.
6305
+ // Billing - moderate, fail-closed with user limits
6306
+ "/api/billing/*": {
6307
+ tier: "MODERATE",
6308
+ userLimit: 100,
6309
+ failClosed: true,
6310
+ skipAuthenticatedUsers: true,
6311
+ userLimitKey: "/api/billing/*"
6312
+ },
6313
+ "/webhooks/stripe": { tier: "MODERATE", failClosed: true },
6314
+ "/webhooks/workos": { tier: "MODERATE", failClosed: true },
6315
+ // API endpoints - standard with user limits
6316
+ // 500 because the web's settings live updates refetch per hub in every open tab, whatever page
6317
+ // it shows (`settingsLiveUpdateStore.ts`): one batch of changes costs about 10 + 4 per agent
6318
+ // whose tools were opened + 2 per loaded resource, so a CLI push and publish (both hubs) with
6319
+ // two tabs open passes 150 in a minute. A multi-file resource upload adds 2–5 per file.
6320
+ "/api/setup/*": {
6321
+ tier: "STANDARD",
6322
+ userLimit: 500,
6323
+ skipAuthenticatedUsers: true,
6324
+ userLimitKey: "/api/setup/*"
6325
+ },
6326
+ // 500 because an eval run's drill-down (`SessionResults.tsx`) fetches its list and then every
6327
+ // LLM turn's record at once: up to 201 requests (`OBSERVABILITY_LIST_CAP`, 200). Sending keeps
6328
+ // the 150 it had when each path held its own budget, on the exact key below.
6329
+ "/api/conversations/*": {
6330
+ tier: "STANDARD",
6331
+ userLimit: 500,
6332
+ skipAuthenticatedUsers: true,
6333
+ userLimitKey: "/api/conversations/*"
6334
+ },
6335
+ "/api/conversations/send-message": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
6336
+ "/api/users/*": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
6337
+ "/api/analytics/*": {
6338
+ tier: "STANDARD",
6339
+ userLimit: 150,
6340
+ skipAuthenticatedUsers: true,
6341
+ userLimitKey: "/api/analytics/*"
6342
+ },
6343
+ // 500 because `wayai eval-results --eval` reads completed sessions one by one, newest first,
6344
+ // until one holds the eval (up to the 1000 the list returns). Tenant SQL keeps the 150 it had
6345
+ // when each path held its own budget: each query may run 30 s on shared-tenant ClickHouse
6346
+ // after its caller has gone (`sql-validator.ts`, stage 10b).
6347
+ "/api/evals/*": {
6348
+ tier: "STANDARD",
6349
+ userLimit: 500,
6350
+ skipAuthenticatedUsers: true,
6351
+ userLimitKey: "/api/evals/*"
6352
+ },
6353
+ "/api/evals/sql": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
6354
+ // An eval run's calls (gh #4418), kept off the end user's call budgets below. Create keeps the
6355
+ // 150 it had: it opens a provider session on the org's own key, billed per second. The routes
6356
+ // on one call take a budget of their own so no eval read can spend it: a refused hang-up
6357
+ // leaves the call running, and billing. 500 because a call suite polls each run's record
6358
+ // every second, about 64 requests a minute per suite.
6359
+ "/api/evals/calls": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
6360
+ "/api/evals/calls/*": {
6361
+ tier: "STANDARD",
6362
+ userLimit: 500,
6363
+ skipAuthenticatedUsers: true,
6364
+ userLimitKey: "/api/evals/calls/*"
6365
+ },
6366
+ "/api/files/*": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
6367
+ // The org contact book (wayai#4931 PR 2b). A CSV import sends one request per
6368
+ // `CONTACT_IMPORT_BATCH_MAX` rows, so 150 a minute imports 75,000 rows a minute.
6369
+ "/api/contact-book/*": {
6370
+ tier: "STANDARD",
6371
+ userLimit: 150,
6372
+ skipAuthenticatedUsers: true,
6373
+ userLimitKey: "/api/contact-book/*"
6374
+ },
6375
+ // An automation email's one-click unsubscribe (wayai#4931 PR 2d) — public: its token is its one
6376
+ // credential, so this per-IP limit is its one bound, and runs before the route reads anything.
6377
+ // MODERATE (30/min per IP), as the community email's unsubscribe, for the same reason: mail
6378
+ // clients' one-click unsubscribe POSTs it from their own servers, which many recipients' clicks
6379
+ // share. An exact key, so it wins over the wildcard above.
6380
+ [CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH]: { tier: "MODERATE" },
6381
+ "/api/automations/*": {
6382
+ tier: "STANDARD",
6383
+ userLimit: 150,
6384
+ skipAuthenticatedUsers: true,
6385
+ userLimitKey: "/api/automations/*"
6386
+ },
6387
+ // A hub's own contact lists (wayai#4931 PR 2c): config edits, at the automations' rate.
6388
+ "/api/hub-contact-lists/*": {
6389
+ tier: "STANDARD",
6390
+ userLimit: 150,
6391
+ skipAuthenticatedUsers: true,
6392
+ userLimitKey: "/api/hub-contact-lists/*"
6393
+ },
6394
+ "/api/message-templates/*": {
6395
+ tier: "STANDARD",
6396
+ userLimit: 150,
6397
+ skipAuthenticatedUsers: true,
6398
+ userLimitKey: "/api/message-templates/*"
6399
+ },
6400
+ "/api/live-updates/*": { tier: "STANDARD", userLimit: 150, skipAuthenticatedUsers: true },
6401
+ "/api/hub-users/*": {
6402
+ tier: "STANDARD",
6403
+ userLimit: 150,
6404
+ skipAuthenticatedUsers: true,
6405
+ userLimitKey: "/api/hub-users/*"
6406
+ },
6407
+ "/api/conversation-state/*": {
6408
+ tier: "STANDARD",
6409
+ userLimit: 150,
6410
+ skipAuthenticatedUsers: true,
6411
+ userLimitKey: "/api/conversation-state/*"
6412
+ },
6413
+ // The authenticated byte route (`routes/files/r2.ts`), mounted after its `authMiddleware` so
6414
+ // the caller is known: each request reads the HubDO its key names, and a hub id never created
6415
+ // still wakes a Durable Object (gh #4747; since gh #4775 T5 one that writes nothing). The key is pinned
6416
+ // because the paths are file keys, which would otherwise each get a fresh budget (and one
6417
+ // over 256 characters would be refused outright, `checkUserLimitNative`).
6418
+ //
6419
+ // 500 a minute because the web chat fetches every attachment of every loaded message at
6420
+ // once, with no list virtualization: up to 50 per 50-message page, 200 per ended
6421
+ // conversation or history entry at one file per message, and 4 per message at most in its
6422
+ // image grid. Repeats come from the browser's HTTP cache (`private, max-age=3600`); mobile
6423
+ // renders through a disk cache and plays audio from `/files/signed`. The budget is shared by
6424
+ // a caller's tabs and devices. The other two byte routes, `/files/signed/*` and
6425
+ // `/files/public/*`, mount no limiter (the reason is at their entries in
6426
+ // `security/endpoint-invariants.test.ts`'s route registry).
6427
+ "/files/auth/*": {
6428
+ tier: "STANDARD",
6429
+ userLimit: 500,
6430
+ skipAuthenticatedUsers: true,
6431
+ userLimitKey: "/files/auth/*"
6432
+ },
6433
+ // Channel webhooks - high throughput (external systems, never authenticated)
6434
+ "/webhooks/whatsapp/*": { tier: "HIGH" },
6435
+ "/webhooks/instagram/*": { tier: "HIGH" },
6436
+ // An automation's webhook deliveries (wayai#4931 D13) — no bearer token: the automation's
6437
+ // secret is the credential, checked against one HubDO read. This per-IP limit runs first, before
6438
+ // anything is read. HIGH, as the channel webhooks: senders are servers, and an integration
6439
+ // platform's egress addresses carry many tenants' deliveries. The per-automation budget is
6440
+ // `AUTOMATION_WEBHOOK_PER_AUTOMATION_LIMIT`, counted after the delivery is verified.
6441
+ [`${AUTOMATION_WEBHOOK_MOUNT}/*`]: { tier: "HIGH" },
6442
+ // Managed Agents session events (#5083 Phase 4): one delivery per hosted tool round, and one
6443
+ // vendor address carries every tenant's, so BULK. The per-connection budget is
6444
+ // `MANAGED_AGENTS_WEBHOOK_PER_CONNECTION_LIMIT`, counted after the delivery is verified.
6445
+ [`${MANAGED_AGENTS_WEBHOOK_MOUNT}/*`]: { tier: "BULK" },
6446
+ // Reports (CLI → platform_report triage queue). One per-user budget covers intake
6447
+ // (POST), the content edit (PATCH /:id), the reporter read-back (GET, GET /:id), and the
6448
+ // verification loop (POST /:id/accept, /:id/contest). The limiter is path-based, so a
6449
+ // method-level split (loose reads, strict writes) isn't expressible — GET /:id and PATCH
6450
+ // /:id share a path. So the budget is sized for the read-heavy poll loop (a reporter agent
6451
+ // polling `report get`/`list` while it waits for the fix), at 60/hour. Intake-flooding stays
6452
+ // bounded regardless: identical reports collapse on `fingerprint` (ON CONFLICT DO NOTHING),
6453
+ // so a runaway create loop merges rather than floods. Still STRICT tier + failClosed so a
6454
+ // genuinely runaway distinct-report loop surfaces as 429. The `/*` is load-bearing — an
6455
+ // exact `/api/reports` key would leave the `/:id` paths unmatched (→ unthrottled).
6456
+ // `userLimitKey` is equally load-bearing: without it, middleware falls back to each request's
6457
+ // path and report IDs/actions receive independent counters instead of this shared budget.
6458
+ "/api/reports/*": {
6459
+ tier: "STRICT",
6460
+ userLimit: 60,
6461
+ userWindow: 3600,
6462
+ failClosed: true,
6463
+ skipAuthenticatedUsers: true,
6464
+ userLimitKey: "/api/reports/*"
6465
+ },
6466
+ // Admin report mutations (transition/group/ungroup/edit) — platform-admin
6467
+ // gated at the route, rate-limited here as defense-in-depth. Generous STANDARD
6468
+ // cap so legitimate triage bursts aren't throttled (grouping is one request
6469
+ // even for many members); deliberately NOT failClosed so a Redis blip never
6470
+ // blocks an admin's triage. The bare GET reads share this budget harmlessly.
6471
+ "/api/admin/reports/*": { tier: "STANDARD", userLimit: 150, userLimitKey: "/api/admin/reports/*" },
6472
+ // GitHub webhook (issues.closed → platform_report addressed). MODERATE +
6473
+ // fail-closed; GitHub retries on transient failures so a brief Redis blip
6474
+ // doesn't lose state.
6475
+ "/webhooks/github": { tier: "MODERATE", failClosed: true },
6476
+ // Account deletion — strict on the destructive POST + public undo. The
6477
+ // /api/users/* default tier above ALSO matches these, but `getEndpointConfig`
6478
+ // returns the longest-prefix match, so the more specific entries here win.
6479
+ // `skipAuthenticatedUsers` deliberately omitted: every caller is authenticated,
6480
+ // so including it would make `userLimit` a no-op — the per-user cap IS the gate.
6481
+ "/api/users/me/deletion": { tier: "STRICT", userLimit: 3, userWindow: 3600, failClosed: true },
6482
+ "/api/users/me/deletion/preflight": { tier: "STANDARD", userLimit: 30, failClosed: true },
6483
+ "/api/users/deletion/undo": { tier: "STRICT", failClosed: true },
6484
+ // Production-base destruction.
6485
+ //
6486
+ // Keyed off the CONTRACT constants, not literals: `BASE_DESTRUCTION_CONFIRM_PATH`'s own
6487
+ // docstring promises that the mount, the `AUTH_BYPASS_PATHS` entry, the rate-limit key and
6488
+ // the URL the email embeds move together, and a literal here is exactly how that promise
6489
+ // goes quietly false — leaving an unauthenticated HMAC endpoint on the default tier.
6490
+ //
6491
+ // The emailed GET is PUBLIC, so it gets the IP-tier bound the pre-auth routes get.
6492
+ // `failClosed` is deliberately NOT set: it is only consulted on the per-USER branch, which
6493
+ // needs an authenticated caller, so on a pre-auth route it is inert — the same thing
6494
+ // `/api/auth/magic-code/send` above says about itself. The IP limiter fails OPEN on a
6495
+ // limiter error by design (`packages/runtime/src/rate-limiter.ts`), and claiming otherwise
6496
+ // would tell the next auditor a protection exists that does not.
6497
+ [BASE_DESTRUCTION_CONFIRM_PATH]: { tier: "STRICT" },
6498
+ // The console's read, which every production base's settings pane issues on mount. Without
6499
+ // its own entry it inherits the mount-wide budget below, and an admin clicking through
6500
+ // thirty bases in an hour would be 429'd by a limit sized for irreversible writes.
6501
+ [`${BASE_DESTRUCTION_PREFIX}/destructions`]: { tier: "STANDARD", userLimit: 150 },
6502
+ // The mutating routes: initiate, the authenticated confirm, and cancel. Per user rather than
6503
+ // per IP — all three are authenticated and org-admin gated — and hourly, since a single human
6504
+ // touching thirty production-deletion operations in an hour is already far past normal.
6505
+ // Longest-prefix wins, so the two entries above are not widened by this one. The key is
6506
+ // pinned so those thirty are counted across every base the caller touches (gh #4756).
6507
+ [`${BASE_DESTRUCTION_PREFIX}/*`]: {
6508
+ tier: "STANDARD",
6509
+ userLimit: 30,
6510
+ userWindow: 3600,
6511
+ failClosed: true,
6512
+ userLimitKey: `${BASE_DESTRUCTION_PREFIX}/*`
6513
+ },
6514
+ // Email-invite preview — public, fail-closed. MODERATE (30/min IP) leaves
6515
+ // headroom for the signup-page server-fetch + reloads + prefetches; STRICT
6516
+ // would throttle legitimate users opening the link in multiple tabs.
6517
+ "/api/invites/preview": { tier: "MODERATE", failClosed: true },
6518
+ // "Don't email me again" (gh #4661) — public; one POST per click on its confirm page. STRICT
6519
+ // per IP. No `failClosed`: it is consulted only on the per-user branch, which a pre-auth route
6520
+ // never reaches (see `BASE_DESTRUCTION_CONFIRM_PATH` above).
6521
+ "/api/invites/unsubscribe": { tier: "STRICT" },
6522
+ // Admin DO debug reads — the ONE deliberate deviation from the Data Explorer
6523
+ // catch-all below, and the only reason a per-route key still exists here.
6524
+ // Platform-admin is enforced at the route; this is the independent
6525
+ // defense-in-depth signal so a runaway investigation script surfaces as 429.
6526
+ //
6527
+ // STRICT is kept ON PURPOSE even though the catch-all moved off it: per IP, at 5/min vs
6528
+ // STANDARD's 100/min, walking 10k ids takes ~33h instead of ~100min — a detection window
6529
+ // worth keeping on the routes that return RAW DO ROWS.
6530
+ //
6531
+ // The cost, stated rather than elided: STRICT is one bucket shared with
6532
+ // `/oauth/callback/*` and `/api/auth/magic-code/*`, so a debug session from a
6533
+ // NAT'd office IP can 429 a colleague's login for up to a minute. That trade is
6534
+ // accepted for a rare, deliberate investigation surface — and is exactly why the
6535
+ // browse routes below are NOT here.
6536
+ //
6537
+ // The key is pinned, so a sweep of `/debug/do/hub/<id>/tables` across ids spends one
6538
+ // per-admin budget (gh #4756). 120 an hour: an agent's investigation of a dozen
6539
+ // conversations made 37 debug reads in its busiest hour.
6540
+ "/api/admin/data-explorer/debug/*": {
6541
+ tier: "STRICT",
6542
+ userLimit: 120,
6543
+ userWindow: 3600,
6544
+ failClosed: true,
6545
+ userLimitKey: "/api/admin/data-explorer/debug/*"
6546
+ },
6547
+ // Catch-all for the rest of the Data Explorer (`/search`, `/entity/*`, `/do/*`,
6548
+ // `/kv/*`, the DELETE routes). Added as a catch-all rather than another per-route
6549
+ // key because this budget kept lagging behind routes joining the debug boundary:
6550
+ // with no match the path falls to the default, which sets no `userLimit`, so the
6551
+ // per-user layer never runs at all. `getEndpointConfig` takes the longest match,
6552
+ // so `debug/*` above still wins.
6553
+ //
6554
+ // `/entity/*` deliberately has NO key of its own: it needs precisely this config,
6555
+ // and a duplicate entry is how the two drift apart on the next edit.
6556
+ //
6557
+ // `tier` is deliberately STANDARD, not STRICT. `tier` is the per-IP knob and
6558
+ // STRICT is 5/min keyed on IP ALONE — one bucket shared across every STRICT
6559
+ // endpoint. On these browse routes that breaks the console (open Browse KV and
6560
+ // inspect four values = 6 requests; expand six org rows in the search results =
6561
+ // 6 `/entity/org/:id` calls) and would drain the same IP's budget for
6562
+ // `/oauth/callback/*` and `/api/auth/magic-code/*`, which on a NAT'd office IP
6563
+ // means all admins. The per-user hourly cap is the leg that matters here.
6564
+ //
6565
+ // The canonical key is deliberate: request paths contain DO ids and arbitrary
6566
+ // malformed requests can contain credential material. Keying on the request path
6567
+ // both stores that material in Redis/logs and gives every target a fresh counter.
6568
+ // One stable identity makes every browse request consume the same per-admin
6569
+ // budget without storing request targets.
6570
+ //
6571
+ // 600/hour preserves the original pagination requirement (about 30k rows at
6572
+ // 50/page) while now genuinely bounding id/key enumeration across the surface.
6573
+ "/api/admin/data-explorer/*": {
6574
+ tier: "STANDARD",
6575
+ userLimit: 600,
6576
+ userWindow: 3600,
6577
+ failClosed: true,
6578
+ userLimitKey: "/api/admin/data-explorer/*"
6579
+ },
6580
+ // Admin harness incident-response (harness-agents PR 2.9b) — mass-destroy reaps
6581
+ // EVERY live harness session/token/slot in scope, so it gets a strict budget
6582
+ // (STRICT + a low per-user hourly cap + fail-closed). Platform-admin is enforced
6583
+ // at the route; this is the independent defense-in-depth signal so a runaway
6584
+ // reap loop surfaces as 429. The break-glass disable/enable rides through
6585
+ // `/api/admin/config` (its own STANDARD budget), not this key.
6586
+ "/api/admin/harness/*": {
6587
+ tier: "STRICT",
6588
+ userLimit: 10,
6589
+ userWindow: 3600,
6590
+ failClosed: true,
6591
+ userLimitKey: "/api/admin/harness/*"
6592
+ },
6593
+ // Platform-wide team-orphan repair — a single call can WRITE across every hub of
6594
+ // every org (HubDO purge + UserDO mirror fan-out), so it gets the same strict,
6595
+ // fail-closed budget as the other cross-platform admin write. Exact path (not a
6596
+ // prefix): the sibling `/api/admin/hubs/:hubId/harness` flag flips stay on the
6597
+ // default admin budget. Platform-admin is enforced at the route; this is the
6598
+ // defense-in-depth signal that a repair loop surfaces as 429.
6599
+ "/api/admin/hubs/repair-team-orphans": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6600
+ // Branching-orphan repair (#4577) — deletes named production rows, and its report mode
6601
+ // fans out over every production hub of every org, so it takes the same strict,
6602
+ // fail-closed budget as the team-orphan repair. Exact path, for the same reason.
6603
+ "/api/admin/hubs/repair-branching-orphans": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6604
+ // Knowledge-blob repair (#5142 step 5 C1) — deletes R2 objects across every hub of a scope, so it
6605
+ // takes the same strict, fail-closed budget as the other hub repairs. Exact path, for the same reason.
6606
+ "/api/admin/hubs/repair-knowledge-blobs": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6607
+ // CI/GitOps endpoints - standard with user limits. 500 because `wayai push` makes four requests
6608
+ // (pull, diff, push, pull) and a GitOps job may push every hub at once with one token; when
6609
+ // each path held its own 100, that ran to 100 hubs a minute.
6610
+ "/api/ci/*": { tier: "STANDARD", userLimit: 500, skipAuthenticatedUsers: true, userLimitKey: "/api/ci/*" },
6611
+ // A hub's team pages and their bridge (#5333; owner decision of 2026-10-27): a signed-in caller is
6612
+ // counted on one budget of their own across every hub's page routes instead of the per-IP tier,
6613
+ // which a team behind one address shares. The bridge's own budgets still apply on top: 60 calls a
6614
+ // minute per viewer and page (30 on a customer page), 150 per viewer across a hub's pages, 200 per hub
6615
+ // across its customer pages and 500 per hub (`PAGE_BRIDGE_*` below).
6616
+ "/api/hubs/*/pages/*": { tier: "STANDARD", userLimit: 500, skipAuthenticatedUsers: true, userLimitKey: "/api/hubs/*/pages/*" },
6617
+ // Attested `/v1` proxy onto the data API's `AttestedEntrypoint`. `userLimitKey` is load-bearing here: the
6618
+ // per-user budget defaults to the full request path, and this surface's paths carry base,
6619
+ // record, and file ids — so without a pinned key every distinct resource would get its own
6620
+ // fresh budget and the per-user limit would bound nothing. One shared budget across the
6621
+ // whole data surface is the intent.
6622
+ [`${DATA_PROXY_PREFIX}/*`]: {
6623
+ tier: "STANDARD",
6624
+ userLimit: 150,
6625
+ skipAuthenticatedUsers: true,
6626
+ userLimitKey: `${DATA_PROXY_PREFIX}/*`
6627
+ },
6628
+ // Voice calls — the end user's call routes (`routes/api/calls`). Every caller is signed
6629
+ // in, so the per-IP tier is skipped for them: Brazilian mobile carriers put many callers
6630
+ // behind one IP, and a shared bucket would refuse one caller for another's traffic.
6631
+ //
6632
+ // Create is the only route that spends: it opens a provider session on the org's own
6633
+ // key, billed per second. So it takes its own exact key and an hourly per-user cap, which
6634
+ // lives on Redis and is fail-closed like the other hourly caps. The exact key wins over
6635
+ // the wildcard below, which also matches `/api/calls` (see `getEndpointConfig`).
6636
+ "/api/calls": {
6637
+ tier: "STANDARD",
6638
+ userLimit: 30,
6639
+ userWindow: 3600,
6640
+ failClosed: true,
6641
+ skipAuthenticatedUsers: true,
6642
+ userLimitKey: "/api/calls"
6643
+ },
6644
+ // The routes on one call: `ready`, hang-up, the delegation report and the status read; and
6645
+ // the opening read (`/api/calls/openings/:language`), one per call, before it exists.
6646
+ // NEVER fail-closed: a refused hang-up leaves the call running, and billing, until a
6647
+ // limit ends it. The 60 s budget runs on the native binding, which fails open. The key is
6648
+ // pinned because the paths carry the call id, which would otherwise give every call a
6649
+ // fresh budget.
6650
+ "/api/calls/*": {
6651
+ tier: "STANDARD",
6652
+ userLimit: 150,
6653
+ skipAuthenticatedUsers: true,
6654
+ userLimitKey: "/api/calls/*"
6655
+ },
6656
+ // Contacts between accounts (gh #4661, `routes/api/contacts`). Every caller is signed in, so
6657
+ // the per-IP tier is skipped. The keys are pinned because the paths carry user and invite
6658
+ // ids, which would otherwise give each id a fresh budget. Blocks take their own, lower
6659
+ // budget (#4661 Limits: blocks are rate-limited). The invites-per-day cap and every list
6660
+ // cap are counted in the caller's UserDO, in the same write they bound, not here.
6661
+ "/api/contacts/*": {
6662
+ tier: "STANDARD",
6663
+ userLimit: 60,
6664
+ skipAuthenticatedUsers: true,
6665
+ userLimitKey: "/api/contacts/*"
6666
+ },
6667
+ "/api/contacts/blocks/*": {
6668
+ tier: "STANDARD",
6669
+ userLimit: 30,
6670
+ skipAuthenticatedUsers: true,
6671
+ userLimitKey: "/api/contacts/blocks/*"
6672
+ },
6673
+ // Person-to-person threads (gh #4661, `routes/api/threads`): the per-user send limit, 60 a
6674
+ // minute on the native binding. Every thread route shares the one budget, reads included:
6675
+ // the paths carry thread and message ids, so the key is pinned, and a pattern here cannot
6676
+ // tell a send from a read of the same path. Like every 60 s budget it fails open on a
6677
+ // binding error, so it bounds sends in the steady state only.
6678
+ "/api/threads/*": {
6679
+ tier: "STANDARD",
6680
+ userLimit: 60,
6681
+ skipAuthenticatedUsers: true,
6682
+ userLimitKey: "/api/threads/*"
6683
+ },
6684
+ // An org admin's erasure of one person's thread messages (gh #4661 owner decision 7): any user
6685
+ // can own a free org, so each request arms that org's alarm, and this caps how fast one person
6686
+ // can ask. The org's own daily cap (`PEOPLE_ORG_ERASURES_PER_DAY`, counted in its OrgDO in the
6687
+ // write it bounds) is the fail-closed bound; this budget, on the native binding, fails open.
6688
+ "/api/threads/org-erasures": {
6689
+ tier: "STANDARD",
6690
+ userLimit: 10,
6691
+ skipAuthenticatedUsers: true,
6692
+ userLimitKey: "/api/threads/org-erasures"
6693
+ },
6694
+ // A person's report of a message, thread or person (`people-reports.ts`): each one written
6695
+ // arms the PlatformDO's alarm and emails the platform admins, so it takes its own, lower
6696
+ // budget. The reporter's daily cap (`PEOPLE_REPORTS_PER_DAY`, counted in the report store in
6697
+ // the write it bounds) is the fail-closed bound; this budget, on the native binding, fails open.
6698
+ "/api/threads/reports": {
6699
+ tier: "STANDARD",
6700
+ userLimit: 10,
6701
+ skipAuthenticatedUsers: true,
6702
+ userLimitKey: "/api/threads/reports"
6703
+ },
6704
+ // Communities (gh #4872, `routes/api/communities`): every signed-in route under the mount (the
6705
+ // preview below excepted) shares one per-user budget, which is also each member's send limit and
6706
+ // bounds the reads that scan a community's rows (a title search, the stats); a community's own
6707
+ // limits (its rate, the daily caps, slow mode) are counted in its CommunityDO, in the write they
6708
+ // bound. Every caller is signed in, so the per-IP tier is skipped; the key is pinned because the
6709
+ // paths carry community, room and message ids.
6710
+ "/api/communities/*": {
6711
+ tier: "STANDARD",
6712
+ userLimit: 60,
6713
+ skipAuthenticatedUsers: true,
6714
+ userLimitKey: "/api/communities/*"
6715
+ },
6716
+ // The join page's preview of a link — public, fetched from the visitor's browser, so this
6717
+ // per-IP limit is its one bound and runs before the route reads anything (#4872
6718
+ // owner-delegated decision 9). MODERATE (30/min per IP) leaves room for reloads and several
6719
+ // tabs. An exact key, so it wins over the wildcard above.
6720
+ "/api/communities/join-preview": { tier: "MODERATE" },
6721
+ // An announcement email's unsubscribe (#4872 PR 8a) — public: its token is its one credential, so
6722
+ // this per-IP limit is its one bound, and runs before the route reads anything. MODERATE (30/min
6723
+ // per IP), not STRICT: mail clients' one-click unsubscribe POSTs it from their own servers, which
6724
+ // many members' clicks share, and STRICT's 5/min bucket is shared with sign-in. An exact key, so
6725
+ // it wins over the wildcard above.
6726
+ [COMMUNITY_EMAIL_UNSUBSCRIBE_PATH]: { tier: "MODERATE" },
6727
+ // The WayAI Guide's help entry (wayai#4948, `routes/api/guide.ts`): one POST per click by a viewer
6728
+ // the snapshot does not show enrolled, which reads the person's row on the Guide hub and writes only
6729
+ // what is missing (an enrolled viewer's click opens the hub without a request). Every caller is
6730
+ // signed in, so the per-IP tier is skipped; 10 a minute per person on the native binding (fails
6731
+ // open, like every 60 s budget) bounds what a looping client costs the one Guide HubDO.
6732
+ "/api/guide/access": {
6733
+ tier: "STANDARD",
6734
+ userLimit: 10,
6735
+ skipAuthenticatedUsers: true,
6736
+ userLimitKey: "/api/guide/access"
6737
+ },
6738
+ // App channel - high throughput with user limits
6739
+ "/channels/app/*": { tier: "HIGH", userLimit: 500, skipAuthenticatedUsers: true },
6740
+ // API channel (api-channel-connector) - machine-to-machine, high throughput
6741
+ "/channels/api/*": { tier: "HIGH", userLimit: 500, skipAuthenticatedUsers: true },
6742
+ // System/scheduled - high throughput (internal)
6743
+ "/channels/system/*": { tier: "HIGH", skipAuthenticatedUsers: true },
6744
+ "/scheduled/*": { tier: "HIGH", skipAuthenticatedUsers: true },
6745
+ // WebSocket - standard with user limit to prevent connection spam
6746
+ "/live-updates/ws": { tier: "STANDARD", userLimit: 100, failClosed: true },
6747
+ // A community's live socket (gh #4872 PR 5, `GET /communities/:communityId/live`): outside
6748
+ // `/api/*`, with no bearer token, so its per-IP tier is its one bound before the CommunityDO
6749
+ // checks the ticket. STANDARD, as `/live-updates/ws`: a client opens one per community it shows
6750
+ // and reconnects within the hour.
6751
+ "/communities/*": { tier: "STANDARD" },
6752
+ // WS ticket mint - per-user 60/min accommodates aggressive reconnect patterns
6753
+ // without opening abuse vectors; fail-closed so Redis outages don't let
6754
+ // runaway clients mint unbounded tickets.
6755
+ "/api/auth/ws-ticket": { tier: "MODERATE", userLimit: 60, failClosed: true, skipAuthenticatedUsers: true },
6756
+ "/api/auth/session-check": { tier: "STANDARD", userLimit: 120, skipAuthenticatedUsers: true },
6757
+ "/api/auth/logout": { tier: "MODERATE", userLimit: 10, failClosed: true, skipAuthenticatedUsers: true }
6758
+ };
6759
+ EXCLUDED_PATHS = /* @__PURE__ */ new Set(["/health"]);
6760
+ }
6761
+ });
6762
+
6763
+ // ../../packages/core/dist/chunk-7QJBCQR3.js
6764
+ function fileSnapshotChanged(run) {
6765
+ return run.written + run.removed > 0;
6766
+ }
6767
+ async function runFileSnapshot(opts) {
6768
+ const run = { pages: 0, written: 0, removed: 0, unchanged: 0 };
6769
+ const seen = /* @__PURE__ */ new Set();
6770
+ let cursor;
6771
+ while (run.pages < FILE_SNAPSHOT_MAX_PAGES) {
6772
+ const page = await sendWithRetry(opts, cursor);
6773
+ run.pages++;
6774
+ run.written += page.written;
6775
+ run.removed += page.removed;
6776
+ run.unchanged += page.unchanged;
6777
+ opts.onPage?.(page, run.pages);
6778
+ if (page.next_cursor === null) return run;
6779
+ if (seen.has(page.next_cursor)) {
6780
+ throw new Error(`The preview file snapshot repeated its cursor after page ${run.pages}, so it would never end.`);
6781
+ }
6782
+ seen.add(page.next_cursor);
6783
+ cursor = page.next_cursor;
6784
+ }
6785
+ throw new Error(`The preview file snapshot did not end after ${FILE_SNAPSHOT_MAX_PAGES} pages.`);
6786
+ }
6787
+ async function sendWithRetry(opts, cursor) {
6788
+ for (let attempt = 1; ; attempt++) {
6789
+ let body;
6790
+ try {
6791
+ body = await opts.sendPage(cursor);
6792
+ } catch (error) {
6793
+ if (attempt < FILE_SNAPSHOT_CONFLICT_ATTEMPTS && opts.isConflict(error)) continue;
6794
+ throw error;
6795
+ }
6796
+ const parsed = rekorFileSnapshotAnswerSchema.safeParse(body);
6797
+ if (!parsed.success) {
6798
+ throw new Error("The data product answered a preview file snapshot page WayAI cannot read: nothing more was sent.");
6799
+ }
6800
+ return parsed.data.data;
6801
+ }
6802
+ }
6803
+ var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
6804
+ var init_chunk_7QJBCQR3 = __esm({
6805
+ "../../packages/core/dist/chunk-7QJBCQR3.js"() {
6806
+ "use strict";
6807
+ init_chunk_D7SSWNL3();
6808
+ init_chunk_5XEJSR22();
6809
+ init_zod();
6810
+ rekorFileSnapshotAnswerSchema = external_exports.object({
6833
6811
  data: external_exports.object({
6834
- tools: external_exports.array(external_exports.object({
6835
- name: external_exports.string(),
6836
- description: external_exports.string().optional(),
6837
- inputSchema: external_exports.record(external_exports.unknown()).optional()
6838
- }))
6812
+ next_cursor: external_exports.string().nullable(),
6813
+ /** Files the page created or replaced on the preview. */
6814
+ written: external_exports.number().int(),
6815
+ /** The preview's own files, ones production does not hold, the page removed. */
6816
+ removed: external_exports.number().int(),
6817
+ /** Files the page found already equal to production's. */
6818
+ unchanged: external_exports.number().int()
6839
6819
  })
6840
6820
  });
6841
- rekorPersonIdSchema = external_exports.string().max(REKOR_MAX_PERSON_ID_LENGTH).regex(REKOR_STRUCTURAL_ID_PATTERN);
6842
- rekorPersonAudienceSchema = external_exports.enum([REKOR_PERSON_AUDIENCE_STAFF, REKOR_PERSON_AUDIENCE_CUSTOMER]);
6843
- rekorBoundPersonSchema = external_exports.object({
6844
- audience: rekorPersonAudienceSchema,
6845
- parties: external_exports.array(external_exports.union([external_exports.array(rekorPersonIdSchema).max(REKOR_MAX_PERSON_IDS), external_exports.literal(REKOR_PERSON_ALL)])).max(REKOR_MAX_PERSON_PARTIES),
6846
- agent_all: external_exports.boolean(),
6847
- customer: external_exports.number().int().nonnegative().optional()
6848
- }).strict().refine((person) => !person.agent_all || person.audience === REKOR_PERSON_AUDIENCE_STAFF, {
6849
- message: `The agent's "*" applies only to a staff call`,
6850
- path: ["agent_all"]
6851
- }).refine((person) => person.customer === void 0 || boundCustomerPartyIsValid(person.audience, person.parties, person.customer), {
6852
- message: "The customer party is a listed party of person ids, on a call that is not staff's",
6853
- path: ["customer"]
6854
- });
6855
- rekorBoundAttestation = rekorAttestation.extend({
6856
- [REKOR_ACTOR_TYPE_HEADER]: external_exports.enum(["token", "user"]),
6857
- /** Trimmed and checked as the far side trims and checks it. */
6858
- [REKOR_ACTOR_ID_HEADER]: external_exports.string().trim().min(1).max(REKOR_MAX_ACTOR_ID_LENGTH),
6859
- [REKOR_ACTOR_LABEL_HEADER]: external_exports.string().max(REKOR_MAX_ACTOR_LABEL_LENGTH),
6860
- [REKOR_ACTOR_ADMIN_HEADER]: external_exports.literal("0"),
6861
- [REKOR_BOUND_BASE_HEADER]: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN),
6862
- [REKOR_BOUND_TOOLSET_HEADER]: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN),
6863
- /**
6864
- * Decimal digits only, as the far side parses it, and at most 15 of them: its `Number()` reads
6865
- * every such value back exactly, where a longer one may round or overflow to `Infinity` (a 400).
6866
- */
6867
- [DATA_BASE_GENERATION_HEADER]: external_exports.string().regex(/^[1-9]\d{0,14}$/),
6868
- /** The token the binding was resolved from, when the connection records it (owner decision 41). */
6869
- [REKOR_BOUND_TOKEN_HEADER]: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN).optional(),
6870
- /**
6871
- * The customer the call serves (#5083 RK2): a contact id, which the contact book mints as a UUID.
6872
- * Every UUID is an id the far side reads back as the customer's external id.
6873
- */
6874
- [REKOR_BOUND_CUSTOMER_HEADER]: external_exports.string().uuid().optional(),
6875
- /**
6876
- * The access set the call carries (#5358): an access set's header text (`encodeAccessSet`), within
6877
- * the far side's header cap. Tool calls carry one; the config reads (resolve, tool definitions) do not.
6878
- */
6879
- [REKOR_BOUND_ACCESS_HEADER]: external_exports.string().max(REKOR_MAX_ACCESS_HEADER_LENGTH).refine(isEncodedAccessSet, {
6880
- message: "Not an access set"
6881
- }).optional(),
6882
- /**
6883
- * Where the access set applies (#5358), when only on the call's customer's own records: its one value.
6884
- * Sent only beside the set, which the far side holds it to (the refinement below).
6885
- */
6886
- [REKOR_BOUND_ACCESS_SCOPE_HEADER]: external_exports.literal(REKOR_ACCESS_SCOPE_CUSTOMER).optional(),
6887
- /**
6888
- * The hub whose page makes the call (#5333): sent on every call of the page bridge, and on no other.
6889
- * A hub id, read by the far side under the same structural charset as the other bound ids.
6890
- */
6891
- [REKOR_BOUND_PAGE_HEADER]: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN).optional(),
6821
+ FILE_SNAPSHOT_MAX_PAGES = 1e4;
6822
+ FILE_SNAPSHOT_CONFLICT_ATTEMPTS = 3;
6823
+ FILE_SNAPSHOT_PAGE_SPACING_MS = Math.ceil(
6824
+ 6e4 / Math.max(1, Math.floor((getEndpointConfig(`${DATA_PROXY_PREFIX}/files/snapshot`)?.userLimit ?? 60) * 4 / 5))
6825
+ );
6826
+ FILE_SNAPSHOT_CONFLICT_STATUS = 409;
6827
+ }
6828
+ });
6829
+
6830
+ // ../../packages/core/dist/chunk-IPDOHAZ5.js
6831
+ var reportSourceSchema, intakeReportSourceSchema, reportClassificationSchema, reportStatusSchema, reportLocaleSchema, reportMessageAuthorRoleSchema, reportMessageSchema, sentryRefStatusSchema, createReportBody, editReportBody, reporterReportSummarySchema, reporterListResponseSchema, getReportResponseSchema, reporterTransitionResponseSchema, contestReportBody, reporterListQuery, listReportsQuery, GITHUB_ISSUE_URL_REGEX, githubIssueUrlSchema, transitionReportBody, groupReportsBody, holdReportBody;
6832
+ var init_chunk_IPDOHAZ5 = __esm({
6833
+ "../../packages/core/dist/chunk-IPDOHAZ5.js"() {
6834
+ "use strict";
6835
+ init_chunk_HZ6CADSY();
6836
+ init_zod();
6837
+ reportSourceSchema = external_exports.enum(["sentry", "cli", "review", "security_audit"]);
6838
+ intakeReportSourceSchema = external_exports.enum(["cli", "review", "security_audit"]);
6839
+ reportClassificationSchema = external_exports.enum(["bug", "flaky_test", "security", "enhancement"]);
6840
+ reportStatusSchema = external_exports.enum([
6841
+ "pending",
6842
+ "grouped",
6843
+ "escalated",
6844
+ "shipped",
6845
+ "contested",
6846
+ "addressed",
6847
+ "dismissed"
6848
+ ]);
6849
+ reportLocaleSchema = external_exports.enum(["en", "pt", "es"]);
6850
+ reportMessageAuthorRoleSchema = external_exports.enum(["reporter", "triage", "fixer", "system"]);
6851
+ reportMessageSchema = external_exports.object({
6852
+ message_id: external_exports.string(),
6853
+ author_role: reportMessageAuthorRoleSchema,
6854
+ /** The status transition this note accompanied (e.g. 'shipped'); null for a free/system note. */
6855
+ transition: external_exports.string().nullable(),
6856
+ body: external_exports.string(),
6857
+ created_at: timestampSchema,
6892
6858
  /**
6893
- * The persons the call is for (#5473 §9): their header text (`encodeBoundPerson`), within the far side's
6894
- * header cap. Every tool call carries it beside its access set (`apps/backend/src/rekor/access-set.ts`); the
6895
- * config reads do not. The far side holds a call's reads and writes of a person-ruled record type to its parties,
6896
- * whatever its audience, and a customer-facing call to its audience gate (#5473 2a).
6859
+ * Visibility: `false` = reporter-facing (the default for every narrative entry); `true` =
6860
+ * triage-internal (e.g. a `hold` rationale) — surfaced to platform admins only and NEVER
6861
+ * returned on the reporter read path. The reporter's `GET /api/reports/:id` filters these out.
6897
6862
  */
6898
- [REKOR_BOUND_PERSON_HEADER]: external_exports.string().max(REKOR_MAX_PERSON_HEADER_LENGTH).refine(isEncodedBoundPerson, {
6899
- message: "Not the persons a bound call is for"
6900
- }).optional()
6901
- }).superRefine((bag, ctx) => {
6902
- if (bag[REKOR_BOUND_ACCESS_SCOPE_HEADER] !== void 0 && bag[REKOR_BOUND_ACCESS_HEADER] === void 0) {
6903
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: [REKOR_BOUND_ACCESS_SCOPE_HEADER], message: "Accepted only beside an access set" });
6904
- }
6905
- if (bag[REKOR_ACTOR_TYPE_HEADER] === "user" && (bag[REKOR_BOUND_PAGE_HEADER] === void 0 || bag[REKOR_BOUND_CUSTOMER_HEADER] !== void 0)) {
6906
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: [REKOR_ACTOR_TYPE_HEADER], message: "A person is attested only on a team page's call" });
6907
- }
6863
+ internal: external_exports.boolean()
6908
6864
  });
6909
- rekorResolvedToolsetSchema = external_exports.object({
6910
- data: external_exports.object({
6911
- base_id: external_exports.string().min(1),
6912
- environment: baseEnvironmentSchema,
6913
- base_generation: external_exports.number().int().min(1),
6914
- /**
6915
- * The calling token's binding, or null for a token bound to none. A bound token can call only
6916
- * its toolset's tools, which is what a toolset connection stores (#5083 decision 14). Its org
6917
- * is the token's own: base ids are unique only per org, so the base id alone does not say
6918
- * which base the token reaches.
6919
- */
6920
- toolset_binding: external_exports.object({
6921
- org_id: external_exports.string().optional(),
6922
- base_id: external_exports.string(),
6923
- toolset_id: external_exports.string(),
6924
- /**
6925
- * The token's own id, which a bound call names (`REKOR_BOUND_TOKEN_HEADER`); absent when the
6926
- * caller has none (owner decision 41), and dropped when it is not an id the far side reads back.
6927
- */
6928
- token_id: external_exports.string().regex(REKOR_STRUCTURAL_ID_PATTERN).optional().catch(void 0)
6929
- }).nullable().optional(),
6930
- actions: external_exports.array(external_exports.unknown()).optional(),
6931
- composites: external_exports.array(external_exports.unknown()).optional(),
6932
- relationships: external_exports.array(external_exports.unknown()).optional(),
6933
- /**
6934
- * The toolset's SQL Actions (#5311): each a fixed, read-only query over the record types it
6935
- * declares, which the resolve also carries in `record_types` and `record_type_scopes`.
6936
- */
6937
- sql_actions: external_exports.array(external_exports.unknown()).optional(),
6938
- files: external_exports.array(external_exports.unknown()).optional(),
6939
- batch: external_exports.object({ enabled: external_exports.boolean().optional() }).passthrough().nullable().optional(),
6940
- sql_query: external_exports.boolean().optional(),
6941
- /**
6942
- * The toolset serves one customer per call (#5083 RK2). Absent reads as not scoped. Always `false` since the data
6943
- * product removed customer scope (#5473 2c).
6944
- */
6945
- customer_scope: external_exports.boolean().optional(),
6946
- /**
6947
- * Record types the toolset reaches, by id, as the data product stores them (`json_schema`
6948
- * included): each one its actions, composite record steps and SQL Actions reach, and each reviewed one it
6949
- * reaches otherwise (relationship ends, `batch` entries, every one through `sql_query`; #5083
6950
- * decision 198). An unreviewed type it reaches only otherwise is not here. A reviewed type's
6951
- * `x-review` names its writers (RK4).
6952
- */
6953
- record_types: external_exports.record(external_exports.unknown()).optional(),
6954
- /**
6955
- * What each record type the toolset's actions, composite steps, SQL Actions and relationship tools reach is to a
6956
- * customer scope (`{ role }`, or null), by id (#5083 RK2). A reviewed type `record_types` carries
6957
- * because only a `batch` entry or `sql_query` reaches it has none. Since the data product removed customer
6958
- * scope (#5473 2c), `{ role: 'shared' }` is a type whose `x-access` declares `{ shared: true }`.
6959
- */
6960
- record_type_scopes: external_exports.record(external_exports.unknown()).optional(),
6961
- /**
6962
- * The kind of each tool the toolset publishes, by the name it is published under (wayai#5333 decision
6963
- * 6), sent only to a caller that asks (`REKOR_TOOL_KINDS_RESOLVE_SEARCH`). Read by `rekorToolKindLookup`;
6964
- * a map this side cannot read is dropped, so every tool reads as a write.
6965
- */
6966
- tool_kinds: external_exports.record(external_exports.string()).optional().catch(void 0)
6967
- }).passthrough()
6865
+ sentryRefStatusSchema = external_exports.enum(["valid", "not_found", "mismatch", "unverified"]);
6866
+ createReportBody = external_exports.object({
6867
+ title: external_exports.string().min(5).max(256),
6868
+ description: external_exports.string().min(10).max(5e3),
6869
+ steps_to_reproduce: external_exports.string().max(3e3).optional(),
6870
+ error_message: external_exports.string().max(2e3).optional(),
6871
+ // Taxonomy (server defaults: source=cli, classification=bug when absent).
6872
+ source: intakeReportSourceSchema.optional(),
6873
+ classification: reportClassificationSchema.optional(),
6874
+ // Stable dedup key (e.g. "<file>::<test>" for flaky, "<file>:<line>" for
6875
+ // security). When present, the fingerprint uses it instead of the body hash.
6876
+ dedup_key: external_exports.string().min(1).max(256).optional(),
6877
+ // Context fields (auto-captured by the CLI)
6878
+ organization_id: external_exports.string().optional(),
6879
+ hub_id: external_exports.string().uuid().optional(),
6880
+ hub_name: external_exports.string().max(256).optional(),
6881
+ conversation_id: external_exports.string().uuid().optional(),
6882
+ agent_id: external_exports.string().uuid().optional(),
6883
+ agent_name: external_exports.string().max(256).optional(),
6884
+ client_version: external_exports.string().max(64).optional(),
6885
+ additional_context: external_exports.string().max(2e3).optional()
6886
+ });
6887
+ editReportBody = external_exports.object({
6888
+ title: external_exports.string().min(5).max(256).optional(),
6889
+ description: external_exports.string().min(10).max(5e3).optional(),
6890
+ steps_to_reproduce: external_exports.string().max(3e3).optional(),
6891
+ error_message: external_exports.string().max(2e3).optional(),
6892
+ additional_context: external_exports.string().max(2e3).optional()
6893
+ }).strict().refine((b) => Object.keys(b).length > 0, {
6894
+ message: "at least one field must be provided"
6968
6895
  });
6969
- REKOR_TOOL_KINDS_PARAM = "tool_kinds";
6970
- REKOR_TOOL_KINDS_RESOLVE_SEARCH = new URLSearchParams({ [REKOR_TOOL_KINDS_PARAM]: "true" }).toString();
6971
- resolvedRecordTypeSchema = external_exports.object({ json_schema: external_exports.record(external_exports.unknown()) });
6972
- reviewWritersSchema = external_exports.object({ writers: external_exports.array(external_exports.string()).optional() });
6973
- sharedScopeSchema = external_exports.object({ role: external_exports.literal("shared") });
6974
- resolvedFileToolSchema = external_exports.object({
6975
- file_type: external_exports.string().min(1),
6976
- path_prefix: external_exports.string().nullish(),
6977
- operations: external_exports.array(external_exports.unknown()),
6978
- name: external_exports.unknown().optional(),
6979
- names: external_exports.unknown().optional(),
6980
- description_override: external_exports.unknown().optional()
6896
+ reporterReportSummarySchema = external_exports.object({
6897
+ report_id: external_exports.string(),
6898
+ title: external_exports.string(),
6899
+ description: external_exports.string(),
6900
+ classification: reportClassificationSchema,
6901
+ status: reportStatusSchema,
6902
+ created_at: timestampSchema,
6903
+ triaged_at: timestampSchema.nullable(),
6904
+ resolved_at: timestampSchema.nullable(),
6905
+ /** How many times the reporter has contested (gates the hard cap). */
6906
+ contest_count: external_exports.number(),
6907
+ /** True once triage issued a non-contestable (final) dismissal. */
6908
+ dismissal_final: external_exports.boolean()
6981
6909
  });
6982
- rekorToolsetFileSchema = external_exports.object({
6983
- path: external_exports.string().min(1),
6984
- version: external_exports.number().int().min(1),
6985
- content_type: external_exports.string().optional()
6986
- }).passthrough();
6987
- rekorToolsetFileUrlAnswerSchema = external_exports.object({
6988
- data: external_exports.object({
6989
- url: external_exports.string(),
6990
- expires_at: external_exports.string(),
6991
- path: external_exports.string(),
6992
- content_sha256: external_exports.string()
6993
- }).passthrough()
6910
+ reporterListResponseSchema = external_exports.object({
6911
+ data: external_exports.array(reporterReportSummarySchema)
6994
6912
  });
6995
- rekorToolsetFileListSchema = external_exports.object({ data: external_exports.array(rekorToolsetFileSchema) });
6996
- rekorToolsetFileGetSchema = external_exports.object({
6997
- data: rekorToolsetFileSchema.extend({
6998
- content: external_exports.string(),
6999
- encoding: external_exports.enum(["utf-8", "base64"])
6913
+ getReportResponseSchema = external_exports.object({
6914
+ report: reporterReportSummarySchema,
6915
+ messages: external_exports.array(reportMessageSchema)
6916
+ });
6917
+ reporterTransitionResponseSchema = external_exports.object({
6918
+ report: reporterReportSummarySchema
6919
+ });
6920
+ contestReportBody = external_exports.object({
6921
+ reason: external_exports.string().min(1).max(5e3)
6922
+ });
6923
+ reporterListQuery = external_exports.object({
6924
+ status: reportStatusSchema.optional()
6925
+ });
6926
+ listReportsQuery = external_exports.object({
6927
+ status: reportStatusSchema.optional(),
6928
+ source: reportSourceSchema.optional(),
6929
+ limit: external_exports.coerce.number().int().min(1).max(200).optional(),
6930
+ offset: external_exports.coerce.number().int().min(0).optional(),
6931
+ /** ISO 8601 lower bound on created_at. */
6932
+ since: external_exports.string().datetime().optional(),
6933
+ /**
6934
+ * ISO 8601 lower bound on resolution time — "what did we resolve recently", which `since`
6935
+ * (a created_at filter) cannot answer for a long-lived report resolved yesterday. Implies
6936
+ * a terminal status (`addressed`/`dismissed`) and orders on that same axis.
6937
+ */
6938
+ resolved_since: external_exports.string().datetime().optional()
6939
+ });
6940
+ GITHUB_ISSUE_URL_REGEX = /^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+(?:[/?#]|$)/;
6941
+ githubIssueUrlSchema = external_exports.string().url().refine((u) => GITHUB_ISSUE_URL_REGEX.test(u), {
6942
+ message: "must be an https://github.com/<owner>/<repo>/issues/<number> URL"
6943
+ });
6944
+ transitionReportBody = external_exports.discriminatedUnion("target", [
6945
+ external_exports.object({
6946
+ target: external_exports.literal("escalated"),
6947
+ gh_issue_url: githubIssueUrlSchema,
6948
+ ai_verdict: external_exports.string().max(2e3).optional()
6949
+ }),
6950
+ external_exports.object({
6951
+ target: external_exports.literal("shipped"),
6952
+ note: external_exports.string().min(1).max(2e3).optional()
6953
+ }),
6954
+ external_exports.object({
6955
+ target: external_exports.literal("addressed")
6956
+ }),
6957
+ external_exports.object({
6958
+ target: external_exports.literal("dismissed"),
6959
+ dismissal_reason: external_exports.string().min(1).max(5e3),
6960
+ ai_verdict: external_exports.string().max(2e3).optional(),
6961
+ final: external_exports.boolean().optional()
7000
6962
  })
6963
+ ]);
6964
+ groupReportsBody = external_exports.object({
6965
+ member_ids: external_exports.array(external_exports.string().uuid()).min(1).max(100)
6966
+ });
6967
+ holdReportBody = external_exports.object({
6968
+ reason: external_exports.string().min(1).max(5e3)
7001
6969
  });
7002
- rekorToolsetFilePutSchema = external_exports.object({ data: rekorToolsetFileSchema });
7003
- TOOLSET_CUSTOMER_FACING_REFUSAL_MARK = "A customer-facing agent (a pilot, pilot specialist or pilot advisor) can use a toolset only when it exposes files alone: no record, composite or relationship tools, and neither sql_query nor batch";
7004
- TOOLSET_CUSTOMER_FACING_REFUSAL = `${TOOLSET_CUSTOMER_FACING_REFUSAL_MARK}, nor a file put, delete or put_url, nor a write of a reviewed record type, nor a kind of tool WayAI does not classify. Its record, composite, relationship and SQL Action tools are admitted to a customer-facing agent and a customer page, since the data product holds each of their calls to the record types that declare person rules or shared access`;
7005
6970
  }
7006
6971
  });
7007
6972
 
7008
- // ../../packages/core/dist/chunk-A7TMHX3E.js
7009
- var TOOLSET_ANSWER_PERSON_PARTIES, toolsetAnswerPersonSchema, toolsetAnswerPersonsSchema;
7010
- var init_chunk_A7TMHX3E = __esm({
7011
- "../../packages/core/dist/chunk-A7TMHX3E.js"() {
6973
+ // ../../packages/core/dist/chunk-GPM7PE44.js
6974
+ var bootstrapQuery;
6975
+ var init_chunk_GPM7PE44 = __esm({
6976
+ "../../packages/core/dist/chunk-GPM7PE44.js"() {
7012
6977
  "use strict";
7013
- init_chunk_WBTBXPD2();
7014
- init_chunk_35OU33GJ();
7015
6978
  init_zod();
7016
- TOOLSET_ANSWER_PERSON_PARTIES = ["requester", "originator", "initiator", "delegator"];
7017
- toolsetAnswerPersonSchema = external_exports.object({
7018
- party: external_exports.enum(TOOLSET_ANSWER_PERSON_PARTIES),
7019
- person_id: rekorPersonIdSchema
6979
+ bootstrapQuery = external_exports.object({
6980
+ active_hub_id: external_exports.string().uuid().optional(),
6981
+ active_conversation_id: external_exports.string().uuid().optional(),
6982
+ active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
6983
+ /**
6984
+ * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
6985
+ * preloads it as `people.active_thread` when the viewer is a member.
6986
+ */
6987
+ active_thread_id: external_exports.string().uuid().optional()
6988
+ });
6989
+ }
6990
+ });
6991
+
6992
+ // ../../packages/core/dist/chunk-5VL6LBFD.js
6993
+ var PERMISSIONS;
6994
+ var init_chunk_5VL6LBFD = __esm({
6995
+ "../../packages/core/dist/chunk-5VL6LBFD.js"() {
6996
+ "use strict";
6997
+ PERMISSIONS = [
6998
+ "hub:read",
6999
+ "hub:write",
7000
+ "hub:admin",
7001
+ "conversation:read",
7002
+ "conversation:write",
7003
+ "analytics:read",
7004
+ "billing:read",
7005
+ "billing:write",
7006
+ "org:read",
7007
+ "org:write",
7008
+ "org:admin",
7009
+ "contacts:write",
7010
+ "platform:admin",
7011
+ "*"
7012
+ ];
7013
+ }
7014
+ });
7015
+
7016
+ // ../../packages/core/dist/chunk-VEERWOZ6.js
7017
+ var MAX_NAME_LENGTH2, MAX_HUBS_PER_GRANT, MAX_HUB_TAGS_PER_GRANT, MAX_GRANTS, permissionEnum, grantScopeSchema, grantSchema, createTokenBody, tokenOrgIdParam;
7018
+ var init_chunk_VEERWOZ6 = __esm({
7019
+ "../../packages/core/dist/chunk-VEERWOZ6.js"() {
7020
+ "use strict";
7021
+ init_chunk_5VL6LBFD();
7022
+ init_chunk_HZ6CADSY();
7023
+ init_zod();
7024
+ MAX_NAME_LENGTH2 = 100;
7025
+ MAX_HUBS_PER_GRANT = 50;
7026
+ MAX_HUB_TAGS_PER_GRANT = 20;
7027
+ MAX_GRANTS = 20;
7028
+ permissionEnum = external_exports.enum(PERMISSIONS).refine(
7029
+ (p) => p !== "platform:admin",
7030
+ { message: "platform:admin cannot be delegated via token creation" }
7031
+ );
7032
+ grantScopeSchema = external_exports.object({
7033
+ // Required: every token grant must declare its org tenancy. The handler
7034
+ // also strict-checks this as defense-in-depth, but failing at the Zod
7035
+ // boundary keeps the generated client type honest (org_id: string).
7036
+ org_id: external_exports.string().min(1),
7037
+ hubs: external_exports.array(external_exports.string().min(1)).min(1, "Each grant must have scope.hubs as a non-empty array").max(MAX_HUBS_PER_GRANT),
7038
+ hub_tags: external_exports.array(external_exports.string().min(1)).min(1, "scope.hub_tags must be a non-empty array if provided").max(MAX_HUB_TAGS_PER_GRANT).optional(),
7039
+ environments: external_exports.array(external_exports.enum(["production", "preview"])).min(1, "scope.environments must be a non-empty array if provided").optional()
7020
7040
  }).strict();
7021
- toolsetAnswerPersonsSchema = external_exports.array(toolsetAnswerPersonSchema).min(1).max(REKOR_MAX_PERSON_PARTIES);
7041
+ grantSchema = external_exports.object({
7042
+ scope: grantScopeSchema,
7043
+ permissions: external_exports.array(permissionEnum).min(1, "Each grant must have permissions as a non-empty array")
7044
+ }).strict();
7045
+ createTokenBody = external_exports.object({
7046
+ name: external_exports.string().trim().min(1, "name is required").max(MAX_NAME_LENGTH2, `name must be ${MAX_NAME_LENGTH2} characters or fewer`),
7047
+ grants: external_exports.array(grantSchema).min(1, "grants must be a non-empty array").max(MAX_GRANTS),
7048
+ expires_at: external_exports.string().datetime({ message: "expires_at must be a valid ISO 8601 date" }).refine(
7049
+ (s) => new Date(s).getTime() > Date.now(),
7050
+ { message: "expires_at must be in the future" }
7051
+ ).optional()
7052
+ });
7053
+ tokenOrgIdParam = external_exports.object({ orgId: uuidSchema });
7022
7054
  }
7023
7055
  });
7024
7056
 
@@ -7126,6 +7158,23 @@ var init_chunk_Y7CFCYX4 = __esm({
7126
7158
  }
7127
7159
  });
7128
7160
 
7161
+ // ../../packages/core/dist/chunk-2YEGUQR7.js
7162
+ var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
7163
+ var init_chunk_2YEGUQR7 = __esm({
7164
+ "../../packages/core/dist/chunk-2YEGUQR7.js"() {
7165
+ "use strict";
7166
+ init_zod();
7167
+ PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
7168
+ CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
7169
+ PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
7170
+ userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
7171
+ personIdSchema = external_exports.string().refine(
7172
+ (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
7173
+ { message: PERSON_ID_FORM_MESSAGE }
7174
+ );
7175
+ }
7176
+ });
7177
+
7129
7178
  // ../../packages/core/dist/chunk-S5SVBLGT.js
7130
7179
  function normalizeContactPhone(raw) {
7131
7180
  const compact = raw.trim().replace(/[\s\-.()]/g, "");
@@ -7301,23 +7350,16 @@ var init_chunk_S5SVBLGT = __esm({
7301
7350
  }
7302
7351
  });
7303
7352
 
7304
- // ../../packages/core/dist/chunk-3GUHAF3O.js
7305
- var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery;
7306
- var init_chunk_3GUHAF3O = __esm({
7307
- "../../packages/core/dist/chunk-3GUHAF3O.js"() {
7353
+ // ../../packages/core/dist/chunk-L4SFHNKQ.js
7354
+ var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery;
7355
+ var init_chunk_L4SFHNKQ = __esm({
7356
+ "../../packages/core/dist/chunk-L4SFHNKQ.js"() {
7308
7357
  "use strict";
7358
+ init_chunk_2YEGUQR7();
7309
7359
  init_chunk_S5SVBLGT();
7310
7360
  init_zod();
7311
- PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
7312
- CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
7313
7361
  PERSON_LINKS_MAX = 15;
7314
7362
  PERSON_DENY_PAGE_MAX = 100;
7315
- PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
7316
- userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
7317
- personIdSchema = external_exports.string().refine(
7318
- (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
7319
- { message: PERSON_ID_FORM_MESSAGE }
7320
- );
7321
7363
  personParam = external_exports.object({
7322
7364
  personId: userPersonIdSchema
7323
7365
  });
@@ -7334,33 +7376,6 @@ var init_chunk_3GUHAF3O = __esm({
7334
7376
  }
7335
7377
  });
7336
7378
 
7337
- // ../../packages/core/dist/chunk-5DGHIY7L.js
7338
- var rekorBaseChangeMessageSchema;
7339
- var init_chunk_5DGHIY7L = __esm({
7340
- "../../packages/core/dist/chunk-5DGHIY7L.js"() {
7341
- "use strict";
7342
- init_zod();
7343
- rekorBaseChangeMessageSchema = external_exports.object({
7344
- /** The WayAI org UUID — one id namespace. */
7345
- org_id: external_exports.string().uuid(),
7346
- /**
7347
- * Not a UUID: a preview base id is `{prod_base_id}--{slug}`. Immutable per base — a
7348
- * preview clone is its OWN base_id — so `(base_id, scope)` keys never collide across
7349
- * environments. Empty is never a real base id, so it is non-conforming rather than a
7350
- * frame keyed on nothing.
7351
- */
7352
- base_id: external_exports.string().min(1),
7353
- /**
7354
- * Rides along so the client scopes its refetch without a lookup; the inspector scopes
7355
- * by side.
7356
- */
7357
- environment: external_exports.enum(["production", "preview"]),
7358
- /** Which pane refetches. `base` covers create/delete/promote/config changes. */
7359
- scope: external_exports.enum(["records", "record_types", "files", "base"])
7360
- });
7361
- }
7362
- });
7363
-
7364
7379
  // ../../packages/core/dist/chunk-YUZFHVB2.js
7365
7380
  var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
7366
7381
  var init_chunk_YUZFHVB2 = __esm({
@@ -7864,12 +7879,12 @@ var init_chunk_FBV7NLKO = __esm({
7864
7879
  }
7865
7880
  });
7866
7881
 
7867
- // ../../packages/core/dist/chunk-WLFAY7KL.js
7882
+ // ../../packages/core/dist/chunk-M54FTJWH.js
7868
7883
  var hubPageWatchParam, pageWatchedBaseSchema, hubPageWatchResponseSchema;
7869
- var init_chunk_WLFAY7KL = __esm({
7870
- "../../packages/core/dist/chunk-WLFAY7KL.js"() {
7884
+ var init_chunk_M54FTJWH = __esm({
7885
+ "../../packages/core/dist/chunk-M54FTJWH.js"() {
7871
7886
  "use strict";
7872
- init_chunk_WBTBXPD2();
7887
+ init_chunk_Q6CHATUL();
7873
7888
  init_chunk_FBV7NLKO();
7874
7889
  init_chunk_HZ6CADSY();
7875
7890
  init_zod();
@@ -12769,7 +12784,7 @@ var init_chunk_2ISUBJG7 = __esm({
12769
12784
  }
12770
12785
  });
12771
12786
 
12772
- // ../../packages/core/dist/chunk-B7I5PFCN.js
12787
+ // ../../packages/core/dist/chunk-EKL5AOYR.js
12773
12788
  function describeRole(role) {
12774
12789
  if (typeof role === "string") {
12775
12790
  return JSON.stringify(role.length > ROLE_ECHO_MAX ? `${role.slice(0, ROLE_ECHO_MAX)}\u2026` : role);
@@ -12857,12 +12872,29 @@ function evalInitialStateError(input) {
12857
12872
  }
12858
12873
  return null;
12859
12874
  }
12860
- function evalCustomerContactIdError(input) {
12875
+ function evalPersonIssue(input) {
12861
12876
  const record = asEvalInputRecord(input);
12862
12877
  if (record === null) return null;
12863
- const value = record.customer_contact_id;
12864
- if (value === void 0 || value === null) return null;
12865
- return evalCustomerContactIdSchema.safeParse(value).success ? null : "customer_contact_id must be a contact id (a UUID)";
12878
+ const person = record.person;
12879
+ const alias = record.customer_contact_id;
12880
+ const declaresPerson = person !== void 0 && person !== null;
12881
+ const declaresAlias = alias !== void 0 && alias !== null;
12882
+ if (declaresPerson && declaresAlias) {
12883
+ return { key: "person", message: "declare person or customer_contact_id (its deprecated alias), not both" };
12884
+ }
12885
+ if (declaresPerson) {
12886
+ if (Array.isArray(person) && person.includes("*")) {
12887
+ return { key: "person", message: 'person never holds "*": declare the person ids the runs are for' };
12888
+ }
12889
+ return evalPersonSchema.safeParse(person).success ? null : {
12890
+ key: "person",
12891
+ message: `person must be a list of 1 to ${EVAL_PERSON_MAX} person ids (prs_\u2026) or contact ids (lowercase UUIDs), each once`
12892
+ };
12893
+ }
12894
+ if (declaresAlias && !evalCustomerContactIdAliasSchema.safeParse(alias).success) {
12895
+ return { key: "customer_contact_id", message: "customer_contact_id must be a contact id (a UUID) or a person id (prs_\u2026)" };
12896
+ }
12897
+ return null;
12866
12898
  }
12867
12899
  function evalNameError(name) {
12868
12900
  if (name === void 0) return null;
@@ -12895,11 +12927,9 @@ function refineEvalInitialState(value, ctx) {
12895
12927
  });
12896
12928
  }
12897
12929
  }
12898
- function refineEvalCustomer(value, ctx) {
12899
- const error = evalCustomerContactIdError(value.eval);
12900
- if (error) {
12901
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["eval", "customer_contact_id"], message: error });
12902
- }
12930
+ function refineEvalPerson(value, ctx) {
12931
+ const issue = evalPersonIssue(value.eval);
12932
+ if (issue) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["eval", issue.key], message: issue.message });
12903
12933
  }
12904
12934
  function refineEvalAttachments(value, ctx) {
12905
12935
  const triggerError = evalTurnAttachmentsError(value.eval.message_text);
@@ -12942,10 +12972,12 @@ function unprovenRunCount(counts) {
12942
12972
  function terminalRunCount(counts) {
12943
12973
  return counts.successful_runs + counts.failed_runs;
12944
12974
  }
12945
- var evalIdParam, sessionIdParam, scenarioSetIdParam, hubIdQuery, EVAL_FIXTURE_NAME_MAX_LENGTH, evalFixtureOverrideSchema, runSessionQuery, runJourneyQuery, EVAL_INPUT_ROLES, EVAL_INPUT_ROLE_LIST, ROLE_ECHO_MAX, EVAL_INITIAL_STATE_SCOPES, MAX_INITIAL_STATE_ENTRIES, evalInitialStateEntry, evalCustomerContactIdSchema, evalBody, EVAL_LIST_MAX_LIMIT, evalListLimit, getEvalsQuery, toggleEvalBody, bulkToggleEvalsBody, pacingConfigSchema, EVAL_MAX_SELECTED_SCENARIOS, evalScenarioSelectionEntrySchema, evalScenarioSelectionSchema, sessionConfigSchema, createSessionBody, getSessionsQuery, getSessionResultsQuery, getSessionRunsQuery, evalAnalyticsQuery, getSessionCostQuery, compareSessionsQuery, evalsSqlBody, evalsSqlSchemaQuery, exportResultsQuery, validateEvalBody, hubAgentsQuery, createScenarioSetBody, updateScenarioSetBody, scenarioSetsHubQuery, createScenarioFromConversationBody, createJourneyFromConversationBody, evalAttachmentRef, turnMayCarryAttachments, ATTACHMENTS_USER_ONLY_MESSAGE, journeyIdParam, journeyToolCallSchema, journeyTurnSchema, journeyStepOverrideSchema, fixtureField, createJourneyBody, updateJourneyBody, evalSessionConfigResponseSchema, evalSessionResponseSchema, evalSessionListConfigSchema, evalSessionListItemSchema, seedReleaseStatusSchema, EVAL_SESSION_NOT_QUIESCENT;
12946
- var init_chunk_B7I5PFCN = __esm({
12947
- "../../packages/core/dist/chunk-B7I5PFCN.js"() {
12975
+ var evalIdParam, sessionIdParam, scenarioSetIdParam, hubIdQuery, EVAL_FIXTURE_NAME_MAX_LENGTH, evalFixtureOverrideSchema, runSessionQuery, runJourneyQuery, EVAL_INPUT_ROLES, EVAL_INPUT_ROLE_LIST, ROLE_ECHO_MAX, EVAL_INITIAL_STATE_SCOPES, MAX_INITIAL_STATE_ENTRIES, evalInitialStateEntry, EVAL_PERSON_MAX, evalPersonSchema, evalCustomerContactIdAliasSchema, evalBody, EVAL_LIST_MAX_LIMIT, evalListLimit, getEvalsQuery, toggleEvalBody, bulkToggleEvalsBody, pacingConfigSchema, EVAL_MAX_SELECTED_SCENARIOS, evalScenarioSelectionEntrySchema, evalScenarioSelectionSchema, sessionConfigSchema, createSessionBody, getSessionsQuery, getSessionResultsQuery, getSessionRunsQuery, evalAnalyticsQuery, getSessionCostQuery, compareSessionsQuery, evalsSqlBody, evalsSqlSchemaQuery, exportResultsQuery, validateEvalBody, hubAgentsQuery, createScenarioSetBody, updateScenarioSetBody, scenarioSetsHubQuery, createScenarioFromConversationBody, createJourneyFromConversationBody, evalAttachmentRef, turnMayCarryAttachments, ATTACHMENTS_USER_ONLY_MESSAGE, journeyIdParam, journeyToolCallSchema, journeyTurnSchema, journeyStepOverrideSchema, fixtureField, createJourneyBody, updateJourneyBody, evalSessionConfigResponseSchema, evalSessionResponseSchema, evalSessionListConfigSchema, evalSessionListItemSchema, seedReleaseStatusSchema, EVAL_SESSION_NOT_QUIESCENT;
12976
+ var init_chunk_EKL5AOYR = __esm({
12977
+ "../../packages/core/dist/chunk-EKL5AOYR.js"() {
12948
12978
  "use strict";
12979
+ init_chunk_2YEGUQR7();
12980
+ init_chunk_7GDM456L();
12949
12981
  init_chunk_4LXDRTO4();
12950
12982
  init_chunk_WTOA3ANF();
12951
12983
  init_chunk_2ISUBJG7();
@@ -12981,10 +13013,12 @@ var init_chunk_B7I5PFCN = __esm({
12981
13013
  scope: external_exports.enum(EVAL_INITIAL_STATE_SCOPES).default("user"),
12982
13014
  value: external_exports.record(external_exports.unknown())
12983
13015
  });
12984
- evalCustomerContactIdSchema = uuidSchema;
13016
+ EVAL_PERSON_MAX = REKOR_MAX_PERSON_IDS;
13017
+ evalPersonSchema = external_exports.array(personIdSchema).min(1).max(EVAL_PERSON_MAX).refine((ids) => new Set(ids).size === ids.length, { message: "Each person id is declared once" });
13018
+ evalCustomerContactIdAliasSchema = external_exports.union([uuidSchema, personIdSchema]);
12985
13019
  evalBody = external_exports.object({
12986
13020
  eval: external_exports.record(external_exports.unknown())
12987
- }).superRefine(refineEvalName).superRefine(refineEvalMessageTextRole).superRefine(refineEvalAttachments).superRefine(refineEvalInitialState).superRefine(refineEvalCustomer);
13021
+ }).superRefine(refineEvalName).superRefine(refineEvalMessageTextRole).superRefine(refineEvalAttachments).superRefine(refineEvalInitialState).superRefine(refineEvalPerson);
12988
13022
  EVAL_LIST_MAX_LIMIT = 1e3;
12989
13023
  evalListLimit = external_exports.string().regex(/^\d+$/).refine((v) => Number(v) <= EVAL_LIST_MAX_LIMIT, {
12990
13024
  message: `limit must be ${EVAL_LIST_MAX_LIMIT} or less`
@@ -14012,7 +14046,7 @@ var init_chunk_TU4Y4MEX = __esm({
14012
14046
  }
14013
14047
  });
14014
14048
 
14015
- // ../../packages/core/dist/chunk-EHFD6TXQ.js
14049
+ // ../../packages/core/dist/chunk-3ZJUPWWJ.js
14016
14050
  function refineHubAsCodeCustomTools(config, ctx) {
14017
14051
  const agents = config.agents;
14018
14052
  if (!Array.isArray(agents)) return;
@@ -14158,17 +14192,17 @@ function refineHubAsCodeEvals(config, ctx) {
14158
14192
  }
14159
14193
  }
14160
14194
  }
14161
- function refineHubAsCodeCustomers(config, ctx) {
14195
+ function refineHubAsCodePersons(config, ctx) {
14162
14196
  for (const [key, kind] of [["evals", "eval"], ["journeys", "journey"]]) {
14163
14197
  const entries = config[key];
14164
14198
  if (!Array.isArray(entries)) continue;
14165
14199
  entries.forEach((entry, i) => {
14166
- const error = evalCustomerContactIdError(entry);
14167
- if (error) {
14200
+ const issue = evalPersonIssue(entry);
14201
+ if (issue) {
14168
14202
  ctx.addIssue({
14169
14203
  code: external_exports.ZodIssueCode.custom,
14170
- path: [key, i, "customer_contact_id"],
14171
- message: `${kind} "${entry?.name ?? "<unnamed>"}": ${error}`
14204
+ path: [key, i, issue.key],
14205
+ message: `${kind} "${entry?.name ?? "<unnamed>"}": ${issue.message}`
14172
14206
  });
14173
14207
  }
14174
14208
  });
@@ -14622,12 +14656,12 @@ function skillSectionsAsResources(scope) {
14622
14656
  };
14623
14657
  }
14624
14658
  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, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, boundedHubAsCodeResourcesSchema, isPlainObject, MIN_SKILLS_LAYOUT_CLI, 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;
14625
- var init_chunk_EHFD6TXQ = __esm({
14626
- "../../packages/core/dist/chunk-EHFD6TXQ.js"() {
14659
+ var init_chunk_3ZJUPWWJ = __esm({
14660
+ "../../packages/core/dist/chunk-3ZJUPWWJ.js"() {
14627
14661
  "use strict";
14628
14662
  init_chunk_SARVKRZB();
14629
- init_chunk_ELIEEYPK();
14630
- init_chunk_B7I5PFCN();
14663
+ init_chunk_CRZFVWXY();
14664
+ init_chunk_EKL5AOYR();
14631
14665
  init_chunk_LBDH7LCG();
14632
14666
  init_chunk_4LXDRTO4();
14633
14667
  init_chunk_TU4Y4MEX();
@@ -14746,7 +14780,7 @@ var init_chunk_EHFD6TXQ = __esm({
14746
14780
  refineHubAsCodeLanes(config, ctx);
14747
14781
  refineHubAsCodePresentation(config, ctx);
14748
14782
  refineHubAsCodeEvals(config, ctx);
14749
- refineHubAsCodeCustomers(config, ctx);
14783
+ refineHubAsCodePersons(config, ctx);
14750
14784
  refineHubAsCodeEvalAttachments(config, ctx);
14751
14785
  refineHubAsCodeCallOpenings(config, ctx);
14752
14786
  refineHubAsCodeAccessValues(config, ctx);
@@ -16162,33 +16196,33 @@ var init_chunk_EV3MAOEX = __esm({
16162
16196
  var init_contracts = __esm({
16163
16197
  "../../packages/core/dist/contracts/index.js"() {
16164
16198
  "use strict";
16199
+ init_chunk_NKLVUTFO();
16165
16200
  init_chunk_WL5QGKHN();
16166
16201
  init_chunk_YVY2TZK2();
16167
16202
  init_chunk_VXEAR36B();
16168
16203
  init_chunk_RACEDHG6();
16169
16204
  init_chunk_Q7KIQHAZ();
16205
+ init_chunk_HIGKBEPF();
16170
16206
  init_chunk_HA7CRZMX();
16171
16207
  init_chunk_MF2VVXBR();
16172
16208
  init_chunk_IPXBFWUU();
16173
- init_chunk_NKLVUTFO();
16209
+ init_chunk_OJMHQF7E();
16174
16210
  init_chunk_ZC6YGHNX();
16175
16211
  init_chunk_ACKF2MVU();
16176
- init_chunk_HIGKBEPF();
16212
+ init_chunk_5DGHIY7L();
16177
16213
  init_chunk_7QJBCQR3();
16178
16214
  init_chunk_IPDOHAZ5();
16179
16215
  init_chunk_GPM7PE44();
16180
16216
  init_chunk_VEERWOZ6();
16181
- init_chunk_A7TMHX3E();
16182
16217
  init_chunk_ZXK6N2HN();
16183
16218
  init_chunk_Y7CFCYX4();
16184
- init_chunk_3GUHAF3O();
16185
- init_chunk_5DGHIY7L();
16219
+ init_chunk_L4SFHNKQ();
16186
16220
  init_chunk_YUZFHVB2();
16187
16221
  init_chunk_I3O2RACG();
16188
16222
  init_chunk_34LE6P7E();
16189
16223
  init_chunk_FPSDNS2E();
16190
- init_chunk_WLFAY7KL();
16191
- init_chunk_WBTBXPD2();
16224
+ init_chunk_M54FTJWH();
16225
+ init_chunk_Q6CHATUL();
16192
16226
  init_chunk_OPETF4GS();
16193
16227
  init_chunk_SY6PLCPK();
16194
16228
  init_chunk_KMAC3O3L();
@@ -16210,11 +16244,12 @@ var init_contracts = __esm({
16210
16244
  init_chunk_E4DIIOOE();
16211
16245
  init_chunk_7CYHPF35();
16212
16246
  init_chunk_BPCNB5RT();
16213
- init_chunk_EHFD6TXQ();
16247
+ init_chunk_3ZJUPWWJ();
16214
16248
  init_chunk_SARVKRZB();
16215
- init_chunk_ELIEEYPK();
16216
- init_chunk_35OU33GJ();
16217
- init_chunk_B7I5PFCN();
16249
+ init_chunk_CRZFVWXY();
16250
+ init_chunk_EKL5AOYR();
16251
+ init_chunk_2YEGUQR7();
16252
+ init_chunk_7GDM456L();
16218
16253
  init_chunk_LBDH7LCG();
16219
16254
  init_chunk_4LXDRTO4();
16220
16255
  init_chunk_JDJ4EUOL();
@@ -21769,13 +21804,7 @@ function parseEvalYaml(filePath2, relPath, setName, hubFolder, bytesByHash) {
21769
21804
  if (targetBase) evalEntry.target_base = targetBase;
21770
21805
  const initialState = parseInitialStateField(data.initial_state, `Eval "${evalName}" in ${relPath}`);
21771
21806
  if (initialState) evalEntry.initial_state = initialState;
21772
- const customer = parseFixtureField(
21773
- data.customer_contact_id,
21774
- `Eval "${evalName}" in ${relPath}`,
21775
- "customer_contact_id",
21776
- "the customer's contact id"
21777
- );
21778
- if (customer) evalEntry.customer_contact_id = customer;
21807
+ Object.assign(evalEntry, parsePersonFields(data, `Eval "${evalName}" in ${relPath}`));
21779
21808
  return evalEntry;
21780
21809
  }
21781
21810
  function parseInitialStateField(raw, label2) {
@@ -21820,6 +21849,17 @@ function parseFixtureField(raw, label2, key, hint = "the Rekor fixture name") {
21820
21849
  const trimmed = raw.trim();
21821
21850
  return trimmed.length > 0 ? trimmed : void 0;
21822
21851
  }
21852
+ function parsePersonFields(data, label2) {
21853
+ const alias = parseFixtureField(data.customer_contact_id, label2, "customer_contact_id", 'a contact id; prefer "person"');
21854
+ if (data.person === void 0 || data.person === null) return alias ? { customer_contact_id: alias } : {};
21855
+ if (!Array.isArray(data.person) || !data.person.every((id) => typeof id === "string")) {
21856
+ throw expected(`${label2}: "person" must be a list of ids (person ids or contact ids).`);
21857
+ }
21858
+ if (alias) {
21859
+ throw expected(`${label2}: declare "person" or "customer_contact_id" (its deprecated alias), not both.`);
21860
+ }
21861
+ return { person: data.person };
21862
+ }
21823
21863
  function scanJourneyYamlFiles(hubFolder, bytesByHash, unreadable) {
21824
21864
  const journeysDir = path17.join(hubFolder, "journeys");
21825
21865
  if (!fs14.existsSync(journeysDir)) return [];
@@ -21895,13 +21935,7 @@ function parseJourneyYaml(filePath2, relPath, hubFolder, bytesByHash) {
21895
21935
  }
21896
21936
  const variables = parseVariablesMap(data.variables, `Journey "${journeyName}" in ${relPath}`);
21897
21937
  if (variables) journeyEntry.variables = variables;
21898
- const customer = parseFixtureField(
21899
- data.customer_contact_id,
21900
- `Journey "${journeyName}" in ${relPath}`,
21901
- "customer_contact_id",
21902
- "the customer's contact id"
21903
- );
21904
- if (customer) journeyEntry.customer_contact_id = customer;
21938
+ Object.assign(journeyEntry, parsePersonFields(data, `Journey "${journeyName}" in ${relPath}`));
21905
21939
  const fixture = parseFixtureField(data.fixture, `Journey "${journeyName}" in ${relPath}`, "fixture");
21906
21940
  if (fixture) journeyEntry.fixture = fixture;
21907
21941
  const targetBase = parseFixtureField(data.target_base, `Journey "${journeyName}" in ${relPath}`, "target_base");
@@ -22110,8 +22144,8 @@ function buildEvalYamlObject(evalEntry, slug) {
22110
22144
  if (Array.isArray(evalEntry.initial_state) && evalEntry.initial_state.length > 0) {
22111
22145
  out.initial_state = evalEntry.initial_state;
22112
22146
  }
22113
- if (typeof evalEntry.customer_contact_id === "string" && evalEntry.customer_contact_id) {
22114
- out.customer_contact_id = evalEntry.customer_contact_id;
22147
+ if (Array.isArray(evalEntry.person) && evalEntry.person.length > 0) {
22148
+ out.person = evalEntry.person;
22115
22149
  }
22116
22150
  assertAttachmentsAreLocalPaths(evalEntry.input, `eval "${evalEntry.name}" input`);
22117
22151
  out.input = evalEntry.input;
@@ -22341,8 +22375,8 @@ function buildJourneyYamlObject(journeyEntry, slug) {
22341
22375
  if (typeof journeyEntry.target_base === "string" && journeyEntry.target_base.trim()) {
22342
22376
  out.target_base = journeyEntry.target_base.trim();
22343
22377
  }
22344
- if (typeof journeyEntry.customer_contact_id === "string" && journeyEntry.customer_contact_id) {
22345
- out.customer_contact_id = journeyEntry.customer_contact_id;
22378
+ if (Array.isArray(journeyEntry.person) && journeyEntry.person.length > 0) {
22379
+ out.person = journeyEntry.person;
22346
22380
  }
22347
22381
  if (journeyEntry.variables && Object.keys(journeyEntry.variables).length > 0) {
22348
22382
  out.variables = journeyEntry.variables;