@wayai/cli 0.3.318 → 0.3.320

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
@@ -5104,6 +5104,85 @@ var init_fs_safety = __esm({
5104
5104
  }
5105
5105
  });
5106
5106
 
5107
+ // ../../packages/core/dist/chunk-Q7KIQHAZ.js
5108
+ var initialValueCreateSchema, initialValueUpdateSchema, stateIdParam, listStatesQuery, stateNameSchema, createStateBody, updateStateBody, reorderStatesBody;
5109
+ var init_chunk_Q7KIQHAZ = __esm({
5110
+ "../../packages/core/dist/chunk-Q7KIQHAZ.js"() {
5111
+ "use strict";
5112
+ init_chunk_6TSQ5HXC();
5113
+ init_zod();
5114
+ initialValueCreateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v && Object.keys(v).length > 0 ? v : null);
5115
+ initialValueUpdateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v === void 0 ? void 0 : v && Object.keys(v).length > 0 ? v : null);
5116
+ stateIdParam = external_exports.object({
5117
+ id: external_exports.string().uuid()
5118
+ });
5119
+ listStatesQuery = external_exports.object({
5120
+ hub_id: external_exports.string().uuid()
5121
+ });
5122
+ stateNameSchema = external_exports.string().min(1, "state_name is required").max(100, "state_name must be 100 characters or fewer").refine((v) => visibleLength(v) > 0, "state_name must not be blank");
5123
+ createStateBody = external_exports.object({
5124
+ hub_id: external_exports.string().uuid(),
5125
+ state_slug: slugSchema,
5126
+ state_name: stateNameSchema,
5127
+ state_scope: external_exports.enum(["conversation", "user"]),
5128
+ state_description: external_exports.string().max(1e3).nullish(),
5129
+ json_schema: external_exports.record(external_exports.unknown()).default({}),
5130
+ initial_value: initialValueCreateSchema,
5131
+ display_order: external_exports.number().int().nonnegative().optional(),
5132
+ is_enabled: external_exports.boolean().default(true),
5133
+ inject_in_last_message: external_exports.boolean().default(true)
5134
+ });
5135
+ updateStateBody = external_exports.object({
5136
+ // state_slug is immutable after first persist — not accepted here.
5137
+ state_name: stateNameSchema.optional(),
5138
+ state_scope: external_exports.enum(["conversation", "user"]).optional(),
5139
+ state_description: external_exports.string().max(1e3).nullish(),
5140
+ json_schema: external_exports.record(external_exports.unknown()).optional(),
5141
+ initial_value: initialValueUpdateSchema,
5142
+ display_order: external_exports.number().int().nonnegative().optional(),
5143
+ is_enabled: external_exports.boolean().optional(),
5144
+ inject_in_last_message: external_exports.boolean().optional()
5145
+ });
5146
+ reorderStatesBody = external_exports.object({
5147
+ states: external_exports.array(external_exports.object({
5148
+ state_id: external_exports.string().uuid(),
5149
+ display_order: external_exports.number().int().nonnegative()
5150
+ })).min(1)
5151
+ });
5152
+ }
5153
+ });
5154
+
5155
+ // ../../packages/core/dist/chunk-NKLVUTFO.js
5156
+ var BASE_CREDENTIAL_MANAGED_BY, BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema, createBaseCredentialLinkBody, baseCredentialLinkParams, baseCredentialLinkQuery;
5157
+ var init_chunk_NKLVUTFO = __esm({
5158
+ "../../packages/core/dist/chunk-NKLVUTFO.js"() {
5159
+ "use strict";
5160
+ init_zod();
5161
+ BASE_CREDENTIAL_MANAGED_BY = {
5162
+ DIRECT: "direct",
5163
+ ORG_LINK: "org-link"
5164
+ };
5165
+ BASE_CREDENTIAL_NAME_MAX = 100;
5166
+ BASE_CREDENTIAL_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@+~=-]*$/;
5167
+ BASE_CREDENTIAL_NAME_CHARSET = "letters, digits and '. _ : @ + ~ = -', starting with a letter or digit";
5168
+ baseCredentialNameSchema = external_exports.string().min(1).max(BASE_CREDENTIAL_NAME_MAX).regex(BASE_CREDENTIAL_NAME_PATTERN, `name must use ${BASE_CREDENTIAL_NAME_CHARSET}`);
5169
+ createBaseCredentialLinkBody = external_exports.object({
5170
+ organization_id: external_exports.string().uuid(),
5171
+ base_id: external_exports.string().min(1),
5172
+ /** Defaults to a slug derived from the credential's display name. */
5173
+ name: baseCredentialNameSchema.optional()
5174
+ });
5175
+ baseCredentialLinkParams = external_exports.object({
5176
+ id: external_exports.string().uuid(),
5177
+ base_credential_id: external_exports.string().min(1)
5178
+ });
5179
+ baseCredentialLinkQuery = external_exports.object({
5180
+ organization_id: external_exports.string().uuid(),
5181
+ base_id: external_exports.string().min(1)
5182
+ });
5183
+ }
5184
+ });
5185
+
5107
5186
  // ../../packages/core/dist/chunk-HZ6CADSY.js
5108
5187
  function optionalTrimmedText(max) {
5109
5188
  return external_exports.string().trim().max(max).optional().transform((value) => value ? value : void 0);
@@ -5593,50 +5672,15 @@ var init_chunk_RACEDHG6 = __esm({
5593
5672
  }
5594
5673
  });
5595
5674
 
5596
- // ../../packages/core/dist/chunk-Q7KIQHAZ.js
5597
- var initialValueCreateSchema, initialValueUpdateSchema, stateIdParam, listStatesQuery, stateNameSchema, createStateBody, updateStateBody, reorderStatesBody;
5598
- var init_chunk_Q7KIQHAZ = __esm({
5599
- "../../packages/core/dist/chunk-Q7KIQHAZ.js"() {
5675
+ // ../../packages/core/dist/chunk-HIGKBEPF.js
5676
+ var accessExplainQuery;
5677
+ var init_chunk_HIGKBEPF = __esm({
5678
+ "../../packages/core/dist/chunk-HIGKBEPF.js"() {
5600
5679
  "use strict";
5601
- init_chunk_6TSQ5HXC();
5680
+ init_chunk_HZ6CADSY();
5602
5681
  init_zod();
5603
- initialValueCreateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v && Object.keys(v).length > 0 ? v : null);
5604
- initialValueUpdateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v === void 0 ? void 0 : v && Object.keys(v).length > 0 ? v : null);
5605
- stateIdParam = external_exports.object({
5606
- id: external_exports.string().uuid()
5607
- });
5608
- listStatesQuery = external_exports.object({
5609
- hub_id: external_exports.string().uuid()
5610
- });
5611
- stateNameSchema = external_exports.string().min(1, "state_name is required").max(100, "state_name must be 100 characters or fewer").refine((v) => visibleLength(v) > 0, "state_name must not be blank");
5612
- createStateBody = external_exports.object({
5613
- hub_id: external_exports.string().uuid(),
5614
- state_slug: slugSchema,
5615
- state_name: stateNameSchema,
5616
- state_scope: external_exports.enum(["conversation", "user"]),
5617
- state_description: external_exports.string().max(1e3).nullish(),
5618
- json_schema: external_exports.record(external_exports.unknown()).default({}),
5619
- initial_value: initialValueCreateSchema,
5620
- display_order: external_exports.number().int().nonnegative().optional(),
5621
- is_enabled: external_exports.boolean().default(true),
5622
- inject_in_last_message: external_exports.boolean().default(true)
5623
- });
5624
- updateStateBody = external_exports.object({
5625
- // state_slug is immutable after first persist — not accepted here.
5626
- state_name: stateNameSchema.optional(),
5627
- state_scope: external_exports.enum(["conversation", "user"]).optional(),
5628
- state_description: external_exports.string().max(1e3).nullish(),
5629
- json_schema: external_exports.record(external_exports.unknown()).optional(),
5630
- initial_value: initialValueUpdateSchema,
5631
- display_order: external_exports.number().int().nonnegative().optional(),
5632
- is_enabled: external_exports.boolean().optional(),
5633
- inject_in_last_message: external_exports.boolean().optional()
5634
- });
5635
- reorderStatesBody = external_exports.object({
5636
- states: external_exports.array(external_exports.object({
5637
- state_id: external_exports.string().uuid(),
5638
- display_order: external_exports.number().int().nonnegative()
5639
- })).min(1)
5682
+ accessExplainQuery = external_exports.object({
5683
+ user_id: external_exports.string().regex(USER_ID_REGEX).optional()
5640
5684
  });
5641
5685
  }
5642
5686
  });
@@ -5792,377 +5836,6 @@ var init_chunk_IPXBFWUU = __esm({
5792
5836
  }
5793
5837
  });
5794
5838
 
5795
- // ../../packages/core/dist/chunk-NKLVUTFO.js
5796
- var BASE_CREDENTIAL_MANAGED_BY, BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema, createBaseCredentialLinkBody, baseCredentialLinkParams, baseCredentialLinkQuery;
5797
- var init_chunk_NKLVUTFO = __esm({
5798
- "../../packages/core/dist/chunk-NKLVUTFO.js"() {
5799
- "use strict";
5800
- init_zod();
5801
- BASE_CREDENTIAL_MANAGED_BY = {
5802
- DIRECT: "direct",
5803
- ORG_LINK: "org-link"
5804
- };
5805
- BASE_CREDENTIAL_NAME_MAX = 100;
5806
- BASE_CREDENTIAL_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@+~=-]*$/;
5807
- BASE_CREDENTIAL_NAME_CHARSET = "letters, digits and '. _ : @ + ~ = -', starting with a letter or digit";
5808
- baseCredentialNameSchema = external_exports.string().min(1).max(BASE_CREDENTIAL_NAME_MAX).regex(BASE_CREDENTIAL_NAME_PATTERN, `name must use ${BASE_CREDENTIAL_NAME_CHARSET}`);
5809
- createBaseCredentialLinkBody = external_exports.object({
5810
- organization_id: external_exports.string().uuid(),
5811
- base_id: external_exports.string().min(1),
5812
- /** Defaults to a slug derived from the credential's display name. */
5813
- name: baseCredentialNameSchema.optional()
5814
- });
5815
- baseCredentialLinkParams = external_exports.object({
5816
- id: external_exports.string().uuid(),
5817
- base_credential_id: external_exports.string().min(1)
5818
- });
5819
- baseCredentialLinkQuery = external_exports.object({
5820
- organization_id: external_exports.string().uuid(),
5821
- base_id: external_exports.string().min(1)
5822
- });
5823
- }
5824
- });
5825
-
5826
- // ../../packages/core/dist/chunk-ZC6YGHNX.js
5827
- var updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, recordAiDisclosureAcceptanceBody, activityQuery, deletionModeSchema, deletionRequestBody;
5828
- var init_chunk_ZC6YGHNX = __esm({
5829
- "../../packages/core/dist/chunk-ZC6YGHNX.js"() {
5830
- "use strict";
5831
- init_zod();
5832
- updateUserBody = external_exports.object({
5833
- user_language: external_exports.string().optional(),
5834
- /** true: dark; false: light; null: follow each device's own setting (`AppearanceMode`). */
5835
- ui_dark_mode: external_exports.boolean().nullable().optional(),
5836
- profile_name: external_exports.string().optional(),
5837
- link_email_to_identities: external_exports.boolean().optional()
5838
- }).refine(
5839
- (data) => Object.values(data).some((v) => v !== void 0),
5840
- { message: "At least one field must be provided" }
5841
- );
5842
- updateProfileBody = external_exports.object({
5843
- display_name: external_exports.string().optional(),
5844
- avatar_url: external_exports.string().optional(),
5845
- preferences: external_exports.record(external_exports.unknown()).optional()
5846
- }).refine(
5847
- (data) => Object.values(data).some((v) => v !== void 0),
5848
- { message: "At least one field must be provided" }
5849
- );
5850
- pathnameRegex = /^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@/?%]*$/;
5851
- updatePreferencesBody = external_exports.object({
5852
- last_viewed_nav: external_exports.string().regex(pathnameRegex, "Must be a URL pathname").max(2048).optional(),
5853
- dismissed_agentic_shortcut: external_exports.boolean().optional(),
5854
- opened_guide: external_exports.boolean().optional()
5855
- }).passthrough();
5856
- registerPushTokenBody = external_exports.object({
5857
- token: external_exports.string().min(1).max(512),
5858
- platform: external_exports.enum(["ios", "android"]),
5859
- /** Stable per-install id so re-registration replaces the prior token for the device. */
5860
- device_id: external_exports.string().min(1).max(128).optional(),
5861
- /**
5862
- * The build opens a person-to-person thread from a push (gh #4661): only a token registered
5863
- * with it receives thread pushes, whose `data` carries `thread_id` and no `conversation_id`.
5864
- * Each registration states it afresh, so a build that sends none clears it.
5865
- */
5866
- supports_threads: external_exports.boolean().optional(),
5867
- /**
5868
- * The build opens a community from a push (gh #4872 Decision 8): only a token registered with it
5869
- * receives a community's pushes (an announcement, a reply to the member's forum post), whose
5870
- * `data` is `CommunityPushData` — never a `conversation_id` or a `thread_id`. Each registration
5871
- * states it afresh, so a build that sends none clears it.
5872
- */
5873
- supports_communities: external_exports.boolean().optional()
5874
- });
5875
- deletePushTokenQuery = external_exports.object({
5876
- token: external_exports.string().min(1).max(512)
5877
- });
5878
- recordAiDisclosureAcceptanceBody = external_exports.object({
5879
- version: external_exports.number().int().positive(),
5880
- withdrawn_at_seen: external_exports.string().datetime().nullable().optional()
5881
- });
5882
- activityQuery = external_exports.object({
5883
- limit: external_exports.coerce.number().int().min(1).max(100).optional()
5884
- });
5885
- deletionModeSchema = external_exports.enum(["scheduled", "immediate"]);
5886
- deletionRequestBody = external_exports.object({
5887
- mode: deletionModeSchema,
5888
- /** User-supplied reason captured in the audit log; bounded to bound logged PII. */
5889
- reason: external_exports.string().max(500).optional(),
5890
- /** Type-to-confirm value; must equal the user's email (constant-time compared). */
5891
- email_confirmation: external_exports.string().min(1).max(320)
5892
- });
5893
- }
5894
- });
5895
-
5896
- // ../../packages/core/dist/chunk-HIGKBEPF.js
5897
- var accessExplainQuery;
5898
- var init_chunk_HIGKBEPF = __esm({
5899
- "../../packages/core/dist/chunk-HIGKBEPF.js"() {
5900
- "use strict";
5901
- init_chunk_HZ6CADSY();
5902
- init_zod();
5903
- accessExplainQuery = external_exports.object({
5904
- user_id: external_exports.string().regex(USER_ID_REGEX).optional()
5905
- });
5906
- }
5907
- });
5908
-
5909
- // ../../packages/core/dist/chunk-IPDOHAZ5.js
5910
- 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;
5911
- var init_chunk_IPDOHAZ5 = __esm({
5912
- "../../packages/core/dist/chunk-IPDOHAZ5.js"() {
5913
- "use strict";
5914
- init_chunk_HZ6CADSY();
5915
- init_zod();
5916
- reportSourceSchema = external_exports.enum(["sentry", "cli", "review", "security_audit"]);
5917
- intakeReportSourceSchema = external_exports.enum(["cli", "review", "security_audit"]);
5918
- reportClassificationSchema = external_exports.enum(["bug", "flaky_test", "security", "enhancement"]);
5919
- reportStatusSchema = external_exports.enum([
5920
- "pending",
5921
- "grouped",
5922
- "escalated",
5923
- "shipped",
5924
- "contested",
5925
- "addressed",
5926
- "dismissed"
5927
- ]);
5928
- reportLocaleSchema = external_exports.enum(["en", "pt", "es"]);
5929
- reportMessageAuthorRoleSchema = external_exports.enum(["reporter", "triage", "fixer", "system"]);
5930
- reportMessageSchema = external_exports.object({
5931
- message_id: external_exports.string(),
5932
- author_role: reportMessageAuthorRoleSchema,
5933
- /** The status transition this note accompanied (e.g. 'shipped'); null for a free/system note. */
5934
- transition: external_exports.string().nullable(),
5935
- body: external_exports.string(),
5936
- created_at: timestampSchema,
5937
- /**
5938
- * Visibility: `false` = reporter-facing (the default for every narrative entry); `true` =
5939
- * triage-internal (e.g. a `hold` rationale) — surfaced to platform admins only and NEVER
5940
- * returned on the reporter read path. The reporter's `GET /api/reports/:id` filters these out.
5941
- */
5942
- internal: external_exports.boolean()
5943
- });
5944
- sentryRefStatusSchema = external_exports.enum(["valid", "not_found", "mismatch", "unverified"]);
5945
- createReportBody = external_exports.object({
5946
- title: external_exports.string().min(5).max(256),
5947
- description: external_exports.string().min(10).max(5e3),
5948
- steps_to_reproduce: external_exports.string().max(3e3).optional(),
5949
- error_message: external_exports.string().max(2e3).optional(),
5950
- // Taxonomy (server defaults: source=cli, classification=bug when absent).
5951
- source: intakeReportSourceSchema.optional(),
5952
- classification: reportClassificationSchema.optional(),
5953
- // Stable dedup key (e.g. "<file>::<test>" for flaky, "<file>:<line>" for
5954
- // security). When present, the fingerprint uses it instead of the body hash.
5955
- dedup_key: external_exports.string().min(1).max(256).optional(),
5956
- // Context fields (auto-captured by the CLI)
5957
- organization_id: external_exports.string().optional(),
5958
- hub_id: external_exports.string().uuid().optional(),
5959
- hub_name: external_exports.string().max(256).optional(),
5960
- conversation_id: external_exports.string().uuid().optional(),
5961
- agent_id: external_exports.string().uuid().optional(),
5962
- agent_name: external_exports.string().max(256).optional(),
5963
- client_version: external_exports.string().max(64).optional(),
5964
- additional_context: external_exports.string().max(2e3).optional()
5965
- });
5966
- editReportBody = external_exports.object({
5967
- title: external_exports.string().min(5).max(256).optional(),
5968
- description: external_exports.string().min(10).max(5e3).optional(),
5969
- steps_to_reproduce: external_exports.string().max(3e3).optional(),
5970
- error_message: external_exports.string().max(2e3).optional(),
5971
- additional_context: external_exports.string().max(2e3).optional()
5972
- }).strict().refine((b) => Object.keys(b).length > 0, {
5973
- message: "at least one field must be provided"
5974
- });
5975
- reporterReportSummarySchema = external_exports.object({
5976
- report_id: external_exports.string(),
5977
- title: external_exports.string(),
5978
- description: external_exports.string(),
5979
- classification: reportClassificationSchema,
5980
- status: reportStatusSchema,
5981
- created_at: timestampSchema,
5982
- triaged_at: timestampSchema.nullable(),
5983
- resolved_at: timestampSchema.nullable(),
5984
- /** How many times the reporter has contested (gates the hard cap). */
5985
- contest_count: external_exports.number(),
5986
- /** True once triage issued a non-contestable (final) dismissal. */
5987
- dismissal_final: external_exports.boolean()
5988
- });
5989
- reporterListResponseSchema = external_exports.object({
5990
- data: external_exports.array(reporterReportSummarySchema)
5991
- });
5992
- getReportResponseSchema = external_exports.object({
5993
- report: reporterReportSummarySchema,
5994
- messages: external_exports.array(reportMessageSchema)
5995
- });
5996
- reporterTransitionResponseSchema = external_exports.object({
5997
- report: reporterReportSummarySchema
5998
- });
5999
- contestReportBody = external_exports.object({
6000
- reason: external_exports.string().min(1).max(5e3)
6001
- });
6002
- reporterListQuery = external_exports.object({
6003
- status: reportStatusSchema.optional()
6004
- });
6005
- listReportsQuery = external_exports.object({
6006
- status: reportStatusSchema.optional(),
6007
- source: reportSourceSchema.optional(),
6008
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
6009
- offset: external_exports.coerce.number().int().min(0).optional(),
6010
- /** ISO 8601 lower bound on created_at. */
6011
- since: external_exports.string().datetime().optional(),
6012
- /**
6013
- * ISO 8601 lower bound on resolution time — "what did we resolve recently", which `since`
6014
- * (a created_at filter) cannot answer for a long-lived report resolved yesterday. Implies
6015
- * a terminal status (`addressed`/`dismissed`) and orders on that same axis.
6016
- */
6017
- resolved_since: external_exports.string().datetime().optional()
6018
- });
6019
- GITHUB_ISSUE_URL_REGEX = /^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+(?:[/?#]|$)/;
6020
- githubIssueUrlSchema = external_exports.string().url().refine((u) => GITHUB_ISSUE_URL_REGEX.test(u), {
6021
- message: "must be an https://github.com/<owner>/<repo>/issues/<number> URL"
6022
- });
6023
- transitionReportBody = external_exports.discriminatedUnion("target", [
6024
- external_exports.object({
6025
- target: external_exports.literal("escalated"),
6026
- gh_issue_url: githubIssueUrlSchema,
6027
- ai_verdict: external_exports.string().max(2e3).optional()
6028
- }),
6029
- external_exports.object({
6030
- target: external_exports.literal("shipped"),
6031
- note: external_exports.string().min(1).max(2e3).optional()
6032
- }),
6033
- external_exports.object({
6034
- target: external_exports.literal("addressed")
6035
- }),
6036
- external_exports.object({
6037
- target: external_exports.literal("dismissed"),
6038
- dismissal_reason: external_exports.string().min(1).max(5e3),
6039
- ai_verdict: external_exports.string().max(2e3).optional(),
6040
- final: external_exports.boolean().optional()
6041
- })
6042
- ]);
6043
- groupReportsBody = external_exports.object({
6044
- member_ids: external_exports.array(external_exports.string().uuid()).min(1).max(100)
6045
- });
6046
- holdReportBody = external_exports.object({
6047
- reason: external_exports.string().min(1).max(5e3)
6048
- });
6049
- }
6050
- });
6051
-
6052
- // ../../packages/core/dist/chunk-KEN2DASI.js
6053
- var SECOND_FACTOR_TIERS, secondFactorTier, META_ENTITY_ID_PATTERN, metaEntityId, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, normalizeEmail, REVIEW_ACCOUNT_EMAILS;
6054
- var init_chunk_KEN2DASI = __esm({
6055
- "../../packages/core/dist/chunk-KEN2DASI.js"() {
6056
- "use strict";
6057
- init_zod();
6058
- SECOND_FACTOR_TIERS = ["off", "settings"];
6059
- secondFactorTier = external_exports.enum(SECOND_FACTOR_TIERS);
6060
- META_ENTITY_ID_PATTERN = /^\d{1,32}$/;
6061
- metaEntityId = external_exports.string().regex(META_ENTITY_ID_PATTERN, "must be a numeric Meta entity id");
6062
- whatsappCallbackBody = external_exports.object({
6063
- state: external_exports.string().min(1, "state is required"),
6064
- code: external_exports.string().optional(),
6065
- access_token: external_exports.string().optional(),
6066
- user_id: external_exports.string().optional(),
6067
- /**
6068
- * The phone number and WABA the operator actually picked in Meta's Embedded
6069
- * Signup popup (posted to the opener as `WA_EMBEDDED_SIGNUP`). Optional:
6070
- * older clients, and the redirect-based flow, never see that event and fall
6071
- * back to discovery.
6072
- */
6073
- phone_number_id: metaEntityId.optional(),
6074
- waba_id: metaEntityId.optional()
6075
- }).refine(
6076
- (data) => !!data.access_token || !!data.code,
6077
- { message: "Missing required parameters: state and either access_token or code" }
6078
- );
6079
- authMeResponse = external_exports.object({
6080
- user_id: external_exports.string(),
6081
- email: external_exports.string(),
6082
- org_id: external_exports.string().nullable(),
6083
- is_platform_admin: external_exports.boolean()
6084
- });
6085
- wsTicketResponse = external_exports.object({
6086
- ticket: external_exports.string(),
6087
- /** Seconds until the ticket expires if unconsumed. */
6088
- expires_in: external_exports.number()
6089
- });
6090
- sessionCheckResponse = external_exports.object({
6091
- valid: external_exports.literal(true)
6092
- });
6093
- logoutResponse = external_exports.object({
6094
- success: external_exports.literal(true)
6095
- });
6096
- magicCodeSendBody = external_exports.object({
6097
- email: external_exports.string().email("Invalid email").max(254)
6098
- // RFC 5321 max; bounds the request payload
6099
- });
6100
- magicCodeSendResponse = external_exports.object({
6101
- success: external_exports.literal(true)
6102
- });
6103
- magicCodeVerifyBody = external_exports.object({
6104
- email: external_exports.string().email("Invalid email").max(254),
6105
- // RFC 5321 max; bounds the request payload
6106
- code: external_exports.string().min(1, "Code is required").max(12)
6107
- // WorkOS sends a 6-digit code; bound the input
6108
- });
6109
- magicCodeVerifyResponse = external_exports.object({
6110
- access_token: external_exports.string(),
6111
- refresh_token: external_exports.string()
6112
- });
6113
- passwordLoginBody = external_exports.object({
6114
- email: external_exports.string().email("Invalid email").max(254),
6115
- // RFC 5321 max; bounds the request payload
6116
- password: external_exports.string().min(1, "Password is required").max(128)
6117
- // bound the payload; WorkOS validates
6118
- });
6119
- normalizeEmail = (email) => email.trim().toLowerCase();
6120
- REVIEW_ACCOUNT_EMAILS = new Set(
6121
- ["apple.review@wayai.pro", "play.review@wayai.pro", "microsoft.review@wayai.pro", "meta.review@wayai.pro"].map(
6122
- normalizeEmail
6123
- )
6124
- );
6125
- }
6126
- });
6127
-
6128
- // ../../packages/core/dist/chunk-PFGVH2CX.js
6129
- var secondFactorCode, secondFactorRecoveryCode, secondFactorCodeBody, secondFactorRecoveryBody, secondFactorDisableBody, setOrgSecondFactorBody;
6130
- var init_chunk_PFGVH2CX = __esm({
6131
- "../../packages/core/dist/chunk-PFGVH2CX.js"() {
6132
- "use strict";
6133
- init_chunk_KEN2DASI();
6134
- init_zod();
6135
- secondFactorCode = external_exports.string().regex(/^\d{6}$/, "Enter the 6-digit code");
6136
- secondFactorRecoveryCode = external_exports.string().min(1, "Enter a recovery code").max(64);
6137
- secondFactorCodeBody = external_exports.object({ code: secondFactorCode });
6138
- secondFactorRecoveryBody = external_exports.object({ recovery_code: secondFactorRecoveryCode });
6139
- secondFactorDisableBody = external_exports.union([
6140
- external_exports.object({ code: secondFactorCode, recovery_code: external_exports.undefined().optional() }),
6141
- external_exports.object({ recovery_code: secondFactorRecoveryCode, code: external_exports.undefined().optional() })
6142
- ]);
6143
- setOrgSecondFactorBody = external_exports.object({ tier: secondFactorTier });
6144
- }
6145
- });
6146
-
6147
- // ../../packages/core/dist/chunk-WE4KMHZK.js
6148
- var bootstrapQuery;
6149
- var init_chunk_WE4KMHZK = __esm({
6150
- "../../packages/core/dist/chunk-WE4KMHZK.js"() {
6151
- "use strict";
6152
- init_zod();
6153
- bootstrapQuery = external_exports.object({
6154
- active_hub_id: external_exports.string().uuid().optional(),
6155
- active_conversation_id: external_exports.string().uuid().optional(),
6156
- active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
6157
- /**
6158
- * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
6159
- * preloads it as `people.active_thread` when the viewer is a member.
6160
- */
6161
- active_thread_id: external_exports.string().uuid().optional()
6162
- });
6163
- }
6164
- });
6165
-
6166
5839
  // ../../packages/core/dist/chunk-SCC6AVLY.js
6167
5840
  var PERMISSIONS;
6168
5841
  var init_chunk_SCC6AVLY = __esm({
@@ -6228,10 +5901,10 @@ var init_chunk_P5GJNS5R = __esm({
6228
5901
  }
6229
5902
  });
6230
5903
 
6231
- // ../../packages/core/dist/chunk-SDOG6762.js
6232
- 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, REKOR_LIFECYCLE_PREFIX, REKOR_BASE_VAULT_DRY_RUN_PATH, 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_ACCESS_HEADER, REKOR_BOUND_PAGE_HEADER, REKOR_BOUND_PERSON_HEADER, REKOR_BOUND_CAPABILITY_HEADER, REKOR_BOUND_CAPABILITY_SEED, REKOR_PERSON_AUDIENCE_STAFF, REKOR_PERSON_AUDIENCE_CUSTOMER, REKOR_PERSON_ALL, 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;
6233
- var init_chunk_SDOG6762 = __esm({
6234
- "../../packages/core/dist/chunk-SDOG6762.js"() {
5904
+ // ../../packages/core/dist/chunk-RLS7WBVR.js
5905
+ 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, REKOR_LIFECYCLE_PREFIX, REKOR_BASE_VAULT_DRY_RUN_PATH, REKOR_S3_CREDENTIAL_COUNT_PATH, 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_ACCESS_HEADER, REKOR_BOUND_PAGE_HEADER, REKOR_BOUND_PERSON_HEADER, REKOR_BOUND_CAPABILITY_HEADER, REKOR_BOUND_CAPABILITY_SEED, REKOR_PERSON_AUDIENCE_STAFF, REKOR_PERSON_AUDIENCE_CUSTOMER, REKOR_PERSON_ALL, 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;
5906
+ var init_chunk_RLS7WBVR = __esm({
5907
+ "../../packages/core/dist/chunk-RLS7WBVR.js"() {
6235
5908
  "use strict";
6236
5909
  init_zod();
6237
5910
  REKOR_ACTOR_TYPE_HEADER = "X-Rekor-Actor-Type";
@@ -6248,6 +5921,7 @@ var init_chunk_SDOG6762 = __esm({
6248
5921
  REKOR_V1_PREFIX = "/v1";
6249
5922
  REKOR_LIFECYCLE_PREFIX = "/lifecycle";
6250
5923
  REKOR_BASE_VAULT_DRY_RUN_PATH = `${REKOR_LIFECYCLE_PREFIX}/vault-dry-run`;
5924
+ REKOR_S3_CREDENTIAL_COUNT_PATH = `${REKOR_LIFECYCLE_PREFIX}/s3-credential-count`;
6251
5925
  DATA_PROXY_ORG_QUERY_PARAM = "org_id";
6252
5926
  MAX_PROVISIONING_BODY_BYTES = 256 * 1024;
6253
5927
  dataProxyQuery = external_exports.object({
@@ -6288,7 +5962,7 @@ var init_chunk_SDOG6762 = __esm({
6288
5962
  }
6289
5963
  });
6290
5964
 
6291
- // ../../packages/core/dist/chunk-MFUQ2NQ5.js
5965
+ // ../../packages/core/dist/chunk-XYKOUYXA.js
6292
5966
  function isPersonAccessAll(lists) {
6293
5967
  return lists !== void 0 && lists.read.length === 1 && lists.read[0] === ACCESS_UNRESTRICTED && lists.write.length === 1 && lists.write[0] === ACCESS_UNRESTRICTED;
6294
5968
  }
@@ -6326,10 +6000,10 @@ function assignmentHasUnrestricted(assignment) {
6326
6000
  return Object.values(assignment).some((lists) => lists.read.includes(ACCESS_UNRESTRICTED) || lists.write.includes(ACCESS_UNRESTRICTED));
6327
6001
  }
6328
6002
  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;
6329
- var init_chunk_MFUQ2NQ5 = __esm({
6330
- "../../packages/core/dist/chunk-MFUQ2NQ5.js"() {
6003
+ var init_chunk_XYKOUYXA = __esm({
6004
+ "../../packages/core/dist/chunk-XYKOUYXA.js"() {
6331
6005
  "use strict";
6332
- init_chunk_SDOG6762();
6006
+ init_chunk_RLS7WBVR();
6333
6007
  init_chunk_HZ6CADSY();
6334
6008
  init_chunk_ZTNFLGW5();
6335
6009
  init_zod();
@@ -6420,7 +6094,7 @@ var init_chunk_MFUQ2NQ5 = __esm({
6420
6094
  }
6421
6095
  });
6422
6096
 
6423
- // ../../packages/core/dist/chunk-FN7WRXIP.js
6097
+ // ../../packages/core/dist/chunk-U4FSUKVU.js
6424
6098
  function boundCustomerPartyIsValid(audience, parties, customer) {
6425
6099
  return audience !== REKOR_PERSON_AUDIENCE_STAFF && customer < parties.length && Array.isArray(parties[customer]);
6426
6100
  }
@@ -6434,11 +6108,11 @@ function isEncodedBoundPerson(raw) {
6434
6108
  return rekorBoundPersonSchema.safeParse(parsed).success;
6435
6109
  }
6436
6110
  var TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, seedConnectionBindingSchema, rekorSeedBindingSchema, rekorToolsetToolsSchema, rekorPersonIdSchema, rekorPersonAudienceSchema, rekorBoundPersonSchema, STATED_GENERATION_PATTERN, rekorBoundAttestation, rekorSeedAttestation, rekorResolvedToolsetSchema, REKOR_TOOL_KINDS_PARAM, REKOR_TOOL_KINDS_RESOLVE_SEARCH, resolvedRecordTypeSchema, reviewWritersSchema, sharedScopeSchema, resolvedFileToolSchema, rekorToolsetFileSchema, rekorToolsetFileUrlAnswerSchema, rekorToolsetFileListSchema, rekorToolsetFileGetSchema, rekorToolsetFilePutSchema, TOOLSET_CUSTOMER_FACING_REFUSAL_MARK, TOOLSET_CUSTOMER_FACING_REFUSAL, BASE_TOOLSET_ONLY_FOR_CUSTOMER_FACING, GENERIC_DATA_MCP_CUSTOMER_FACING_REFUSAL, GENERIC_DATA_API_CUSTOMER_FACING_REFUSAL;
6437
- var init_chunk_FN7WRXIP = __esm({
6438
- "../../packages/core/dist/chunk-FN7WRXIP.js"() {
6111
+ var init_chunk_U4FSUKVU = __esm({
6112
+ "../../packages/core/dist/chunk-U4FSUKVU.js"() {
6439
6113
  "use strict";
6440
- init_chunk_MFUQ2NQ5();
6441
- init_chunk_SDOG6762();
6114
+ init_chunk_XYKOUYXA();
6115
+ init_chunk_RLS7WBVR();
6442
6116
  init_zod();
6443
6117
  TOOLSET_SLUG_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
6444
6118
  REKOR_STRUCTURAL_ID_PATTERN = TOOLSET_SLUG_PATTERN;
@@ -6725,13 +6399,13 @@ var init_chunk_FN7WRXIP = __esm({
6725
6399
  }
6726
6400
  });
6727
6401
 
6728
- // ../../packages/core/dist/chunk-5VGCQRPR.js
6402
+ // ../../packages/core/dist/chunk-BZVN5MG2.js
6729
6403
  var TOOLSET_ANSWER_PERSON_PARTIES, toolsetAnswerPersonSchema, toolsetAnswerPersonsSchema;
6730
- var init_chunk_5VGCQRPR = __esm({
6731
- "../../packages/core/dist/chunk-5VGCQRPR.js"() {
6404
+ var init_chunk_BZVN5MG2 = __esm({
6405
+ "../../packages/core/dist/chunk-BZVN5MG2.js"() {
6732
6406
  "use strict";
6733
- init_chunk_FN7WRXIP();
6734
- init_chunk_SDOG6762();
6407
+ init_chunk_U4FSUKVU();
6408
+ init_chunk_RLS7WBVR();
6735
6409
  init_zod();
6736
6410
  TOOLSET_ANSWER_PERSON_PARTIES = ["requester", "originator", "initiator", "delegator"];
6737
6411
  toolsetAnswerPersonSchema = external_exports.object({
@@ -6742,303 +6416,72 @@ var init_chunk_5VGCQRPR = __esm({
6742
6416
  }
6743
6417
  });
6744
6418
 
6745
- // ../../packages/core/dist/chunk-ZVXO3XL6.js
6746
- var PEOPLE_CONTACT_PAGE_MAX, PEOPLE_CONTACT_PAGE_DEFAULT, PEOPLE_CONTACT_EMAIL_MAX_LENGTH, peopleUserIdSchema, peopleInviteEmailSchema, peopleContactInviteBody, peopleContactInviteIdParam, peopleContactUserIdParam, peopleContactBlockBody, peopleContactPageQuery, peopleOutgoingInviteSchema, peopleContactPersonSchema, peopleContactSchema, peopleIncomingInviteSchema, peopleBlockedUserSchema;
6747
- var init_chunk_ZVXO3XL6 = __esm({
6748
- "../../packages/core/dist/chunk-ZVXO3XL6.js"() {
6749
- "use strict";
6750
- init_chunk_HZ6CADSY();
6751
- init_zod();
6752
- PEOPLE_CONTACT_PAGE_MAX = 100;
6753
- PEOPLE_CONTACT_PAGE_DEFAULT = 50;
6754
- PEOPLE_CONTACT_EMAIL_MAX_LENGTH = 254;
6755
- peopleUserIdSchema = external_exports.string().max(64).regex(USER_ID_REGEX, "must be a user id");
6756
- peopleInviteEmailSchema = external_exports.string().trim().max(PEOPLE_CONTACT_EMAIL_MAX_LENGTH).email();
6757
- peopleContactInviteBody = external_exports.object({
6758
- email: peopleInviteEmailSchema
6759
- }).strict();
6760
- peopleContactInviteIdParam = external_exports.object({ inviteId: uuidSchema });
6761
- peopleContactUserIdParam = external_exports.object({ userId: peopleUserIdSchema });
6762
- peopleContactBlockBody = external_exports.object({ user_id: peopleUserIdSchema, thread_id: uuidSchema.optional(), community_id: uuidSchema.optional() }).strict().refine((body) => body.thread_id === void 0 || body.community_id === void 0, {
6763
- message: "Name a thread or a community, not both",
6764
- path: ["community_id"]
6765
- });
6766
- peopleContactPageQuery = external_exports.object({
6767
- cursor: external_exports.string().min(1).max(256).optional(),
6768
- limit: external_exports.coerce.number().int().min(1).max(PEOPLE_CONTACT_PAGE_MAX).default(PEOPLE_CONTACT_PAGE_DEFAULT)
6769
- });
6770
- peopleOutgoingInviteSchema = external_exports.object({
6771
- invite_id: uuidSchema,
6772
- email: external_exports.string(),
6773
- status: external_exports.literal("sent"),
6774
- created_at: timestampSchema,
6775
- expires_at: timestampSchema
6776
- }).strict();
6777
- peopleContactPersonSchema = external_exports.object({
6778
- user_id: peopleUserIdSchema,
6779
- display_name: external_exports.string().nullable(),
6780
- email: external_exports.string().nullable()
6781
- }).strict();
6782
- peopleContactSchema = peopleContactPersonSchema.extend({ contact_since: timestampSchema, thread_id: uuidSchema }).strict();
6783
- peopleIncomingInviteSchema = external_exports.object({
6784
- invite_id: uuidSchema,
6785
- inviter: peopleContactPersonSchema,
6786
- created_at: timestampSchema,
6787
- expires_at: timestampSchema
6788
- }).strict();
6789
- peopleBlockedUserSchema = peopleContactPersonSchema.extend({ blocked_at: timestampSchema, deleted_user: external_exports.boolean() }).strict();
6790
- }
6791
- });
6792
-
6793
- // ../../packages/core/dist/chunk-Y7CFCYX4.js
6794
- var PEOPLE_REPORT_DETAILS_MAX_LENGTH, peopleReportReasonSchema, reportDetailsSchema, reportFields, peopleReportBody;
6795
- var init_chunk_Y7CFCYX4 = __esm({
6796
- "../../packages/core/dist/chunk-Y7CFCYX4.js"() {
6797
- "use strict";
6798
- init_chunk_ZVXO3XL6();
6799
- init_chunk_HZ6CADSY();
6800
- init_zod();
6801
- PEOPLE_REPORT_DETAILS_MAX_LENGTH = 500;
6802
- peopleReportReasonSchema = external_exports.enum(["spam", "harassment", "hate", "sexual", "violence", "other"]);
6803
- reportDetailsSchema = optionalTrimmedText(PEOPLE_REPORT_DETAILS_MAX_LENGTH);
6804
- reportFields = { reason: peopleReportReasonSchema, details: reportDetailsSchema };
6805
- peopleReportBody = external_exports.discriminatedUnion("target", [
6806
- external_exports.object({ target: external_exports.literal("message"), thread_id: uuidSchema, message_id: uuidSchema, ...reportFields }).strict(),
6807
- external_exports.object({ target: external_exports.literal("thread"), thread_id: uuidSchema, ...reportFields }).strict(),
6808
- external_exports.object({ target: external_exports.literal("user"), user_id: peopleUserIdSchema, thread_id: uuidSchema.optional(), ...reportFields }).strict(),
6809
- external_exports.object({
6810
- target: external_exports.literal("community_message"),
6811
- community_id: uuidSchema,
6812
- room_id: uuidSchema,
6813
- message_id: uuidSchema,
6814
- ...reportFields
6815
- }).strict(),
6816
- external_exports.object({ target: external_exports.literal("community_member"), community_id: uuidSchema, user_id: peopleUserIdSchema, ...reportFields }).strict()
6817
- ]);
6818
- }
6819
- });
6820
-
6821
- // ../../packages/core/dist/chunk-2YEGUQR7.js
6822
- var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
6823
- var init_chunk_2YEGUQR7 = __esm({
6824
- "../../packages/core/dist/chunk-2YEGUQR7.js"() {
6419
+ // ../../packages/core/dist/chunk-ZC6YGHNX.js
6420
+ var updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, recordAiDisclosureAcceptanceBody, activityQuery, deletionModeSchema, deletionRequestBody;
6421
+ var init_chunk_ZC6YGHNX = __esm({
6422
+ "../../packages/core/dist/chunk-ZC6YGHNX.js"() {
6825
6423
  "use strict";
6826
6424
  init_zod();
6827
- PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
6828
- CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
6829
- PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
6830
- userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
6831
- personIdSchema = external_exports.string().refine(
6832
- (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
6833
- { message: PERSON_ID_FORM_MESSAGE }
6425
+ updateUserBody = external_exports.object({
6426
+ user_language: external_exports.string().optional(),
6427
+ /** true: dark; false: light; null: follow each device's own setting (`AppearanceMode`). */
6428
+ ui_dark_mode: external_exports.boolean().nullable().optional(),
6429
+ profile_name: external_exports.string().optional(),
6430
+ link_email_to_identities: external_exports.boolean().optional()
6431
+ }).refine(
6432
+ (data) => Object.values(data).some((v) => v !== void 0),
6433
+ { message: "At least one field must be provided" }
6834
6434
  );
6835
- }
6836
- });
6837
-
6838
- // ../../packages/core/dist/chunk-UAOHHCW5.js
6839
- function normalizeContactPhone(raw) {
6840
- const compact = raw.trim().replace(/[\s\-.()]/g, "");
6841
- const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
6842
- return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
6843
- }
6844
- function normalizeContactLabel(raw) {
6845
- return raw.trim().replace(/\s+/g, " ").toLowerCase();
6846
- }
6847
- function importRowLabels(row, batchLabels) {
6848
- return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
6849
- }
6850
- var CONTACT_ENVIRONMENTS, CONTACT_NAME_MAX, CONTACT_EMAIL_MAX, CONTACT_PHONE_INPUT_MAX, CONTACT_INSTAGRAM_SID_MAX, CONTACT_METADATA_MAX_BYTES, CONTACT_LABEL_MAX, CONTACT_LABELS_MAX, CONTACT_SCOPE_TAGS_MAX, CONTACT_PAGE_MAX, CONTACT_IMPORT_BATCH_MAX, CONTACT_SEARCH_MAX, CONTACT_LIST_NAME_MAX, CONTACT_LIST_NAME_REGEX, CONTACT_LIST_DESCRIPTION_MAX, CONTACT_LIST_FILTER_MAX, CONTACT_LIST_PINS_PER_REQUEST_MAX, SUPPRESSION_SCOPES, SUPPRESSION_ID_REGEX, contactName, contactPhone, contactEmail, contactInstagramSid, contactLabel, contactLabels, contactMetadata, scopeTagIds, contactVisibilitySchema, hasIdentity, IDENTITY_REQUIRED, contactBookOrgQuery, contactBookContactParam, contactBookListParam, contactBookHubParam, contactBookPageQuery, listContactBookContactsQuery, listHubContactBookContactsQuery, contactBookLinkCandidatesQuery, listContactBookListMembersQuery, contactRowFields, createContactBookContactBody, updateContactBookContactBody, contactImportRowSchema, importContactBookContactsBody, linkContactBookContactBody, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
6851
- var init_chunk_UAOHHCW5 = __esm({
6852
- "../../packages/core/dist/chunk-UAOHHCW5.js"() {
6853
- "use strict";
6854
- init_zod();
6855
- CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
6856
- CONTACT_NAME_MAX = 200;
6857
- CONTACT_EMAIL_MAX = 320;
6858
- CONTACT_PHONE_INPUT_MAX = 40;
6859
- CONTACT_INSTAGRAM_SID_MAX = 64;
6860
- CONTACT_METADATA_MAX_BYTES = 4096;
6861
- CONTACT_LABEL_MAX = 64;
6862
- CONTACT_LABELS_MAX = 20;
6863
- CONTACT_SCOPE_TAGS_MAX = 20;
6864
- CONTACT_PAGE_MAX = 100;
6865
- CONTACT_IMPORT_BATCH_MAX = 500;
6866
- CONTACT_SEARCH_MAX = 100;
6867
- CONTACT_LIST_NAME_MAX = 64;
6868
- CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
6869
- CONTACT_LIST_DESCRIPTION_MAX = 1e3;
6870
- CONTACT_LIST_FILTER_MAX = 20;
6871
- CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
6872
- SUPPRESSION_SCOPES = ["all", "marketing"];
6873
- SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
6874
- contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
6875
- contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
6876
- const phone = normalizeContactPhone(raw);
6877
- if (phone === null) {
6878
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
6879
- return external_exports.NEVER;
6880
- }
6881
- return phone;
6882
- });
6883
- contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
6884
- contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
6885
- contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label3) => label3.length > 0, "A label cannot be empty").refine((label3) => !label3.includes(","), "A label cannot contain a comma");
6886
- contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
6887
- contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
6888
- try {
6889
- return new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES;
6890
- } catch {
6891
- return false;
6892
- }
6893
- }, `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`);
6894
- scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
6895
- contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
6896
- external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
6897
- external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
6898
- ]);
6899
- hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
6900
- IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
6901
- contactBookOrgQuery = external_exports.object({
6902
- organization_id: external_exports.string().uuid()
6903
- });
6904
- contactBookContactParam = external_exports.object({
6905
- contactId: external_exports.string().uuid()
6906
- });
6907
- contactBookListParam = external_exports.object({
6908
- listId: external_exports.string().uuid()
6909
- });
6910
- contactBookHubParam = external_exports.object({
6911
- hubId: external_exports.string().uuid()
6912
- });
6913
- contactBookPageQuery = external_exports.object({
6914
- cursor: external_exports.string().max(2048).optional(),
6915
- limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
6916
- });
6917
- listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
6918
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
6919
- label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
6920
- scope_tag_id: external_exports.string().uuid().optional()
6921
- });
6922
- listHubContactBookContactsQuery = contactBookPageQuery.extend({
6923
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
6924
- });
6925
- contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
6926
- email: contactEmail
6927
- });
6928
- listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6929
- contactRowFields = {
6930
- name: contactName,
6931
- phone: contactPhone.nullish(),
6932
- email: contactEmail.nullish(),
6933
- instagram_sid: contactInstagramSid.nullish(),
6934
- labels: contactLabels.optional(),
6935
- metadata: contactMetadata.optional()
6936
- };
6937
- createContactBookContactBody = external_exports.object({
6938
- organization_id: external_exports.string().uuid(),
6939
- ...contactRowFields,
6940
- visibility: contactVisibilitySchema,
6941
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6942
- }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6943
- updateContactBookContactBody = external_exports.object({
6944
- name: contactName.optional(),
6945
- phone: contactPhone.nullable().optional(),
6946
- email: contactEmail.nullable().optional(),
6947
- instagram_sid: contactInstagramSid.nullable().optional(),
6948
- labels: contactLabels.optional(),
6949
- metadata: contactMetadata.optional(),
6950
- visibility: contactVisibilitySchema.optional(),
6951
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6952
- }).strict();
6953
- contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6954
- importContactBookContactsBody = external_exports.object({
6955
- organization_id: external_exports.string().uuid(),
6956
- visibility: contactVisibilitySchema,
6957
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
6958
- labels: contactLabels.optional(),
6959
- rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
6960
- }).strict().superRefine((batch, ctx) => {
6961
- batch.rows.forEach((row, index) => {
6962
- if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
6963
- ctx.addIssue({
6964
- code: external_exports.ZodIssueCode.custom,
6965
- path: ["rows", index, "labels"],
6966
- message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
6967
- });
6968
- }
6969
- });
6970
- });
6971
- linkContactBookContactBody = external_exports.object({
6972
- user_id: external_exports.string().min(1).max(128)
6973
- }).strict();
6974
- listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
6975
- message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
6976
- });
6977
- contactListFilterSchema = external_exports.object({
6978
- labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
6979
- scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
6980
- }).strict();
6981
- createContactBookListBody = external_exports.object({
6982
- organization_id: external_exports.string().uuid(),
6983
- name: listName,
6984
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
6985
- filter: contactListFilterSchema.optional()
6986
- }).strict();
6987
- updateContactBookListBody = external_exports.object({
6988
- name: listName.optional(),
6989
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
6990
- filter: contactListFilterSchema.optional()
6991
- }).strict();
6992
- updateContactBookListPinsBody = external_exports.object({
6993
- add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
6994
- remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
6995
- }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
6996
- suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
6997
- external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
6998
- external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
6999
- external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
7000
- ]);
7001
- createContactBookSuppressionBody = external_exports.object({
7002
- organization_id: external_exports.string().uuid(),
7003
- identity: suppressionIdentitySchema,
7004
- scope: external_exports.enum(SUPPRESSION_SCOPES)
7005
- }).strict();
7006
- contactBookSuppressionParam = external_exports.object({
7007
- suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
7008
- });
7009
- listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
7010
- contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
7011
- contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
7012
- orgListReferenceSchema = listName;
7013
- }
7014
- });
7015
-
7016
- // ../../packages/core/dist/chunk-MGBAXT5Y.js
7017
- var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery, conversationCustomerPersonParam;
7018
- var init_chunk_MGBAXT5Y = __esm({
7019
- "../../packages/core/dist/chunk-MGBAXT5Y.js"() {
7020
- "use strict";
7021
- init_chunk_2YEGUQR7();
7022
- init_chunk_UAOHHCW5();
7023
- init_zod();
7024
- PERSON_LINKS_MAX = 15;
7025
- PERSON_DENY_PAGE_MAX = 100;
7026
- personParam = external_exports.object({
7027
- personId: userPersonIdSchema
6435
+ updateProfileBody = external_exports.object({
6436
+ display_name: external_exports.string().optional(),
6437
+ avatar_url: external_exports.string().optional(),
6438
+ preferences: external_exports.record(external_exports.unknown()).optional()
6439
+ }).refine(
6440
+ (data) => Object.values(data).some((v) => v !== void 0),
6441
+ { message: "At least one field must be provided" }
6442
+ );
6443
+ pathnameRegex = /^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@/?%]*$/;
6444
+ updatePreferencesBody = external_exports.object({
6445
+ last_viewed_nav: external_exports.string().regex(pathnameRegex, "Must be a URL pathname").max(2048).optional(),
6446
+ dismissed_agentic_shortcut: external_exports.boolean().optional(),
6447
+ opened_guide: external_exports.boolean().optional()
6448
+ }).passthrough();
6449
+ registerPushTokenBody = external_exports.object({
6450
+ token: external_exports.string().min(1).max(512),
6451
+ platform: external_exports.enum(["ios", "android"]),
6452
+ /** Stable per-install id so re-registration replaces the prior token for the device. */
6453
+ device_id: external_exports.string().min(1).max(128).optional(),
6454
+ /**
6455
+ * The build opens a person-to-person thread from a push (gh #4661): only a token registered
6456
+ * with it receives thread pushes, whose `data` carries `thread_id` and no `conversation_id`.
6457
+ * Each registration states it afresh, so a build that sends none clears it.
6458
+ */
6459
+ supports_threads: external_exports.boolean().optional(),
6460
+ /**
6461
+ * The build opens a community from a push (gh #4872 Decision 8): only a token registered with it
6462
+ * receives a community's pushes (an announcement, a reply to the member's forum post), whose
6463
+ * `data` is `CommunityPushData` — never a `conversation_id` or a `thread_id`. Each registration
6464
+ * states it afresh, so a build that sends none clears it.
6465
+ */
6466
+ supports_communities: external_exports.boolean().optional()
7028
6467
  });
7029
- personLinkParam = personParam.extend({
7030
- targetId: personIdSchema
6468
+ deletePushTokenQuery = external_exports.object({
6469
+ token: external_exports.string().min(1).max(512)
7031
6470
  });
7032
- deniedPersonParam = external_exports.object({
7033
- personId: personIdSchema
6471
+ recordAiDisclosureAcceptanceBody = external_exports.object({
6472
+ version: external_exports.number().int().positive(),
6473
+ withdrawn_at_seen: external_exports.string().datetime().nullable().optional()
7034
6474
  });
7035
- listDeniedPersonsQuery = contactBookOrgQuery.extend({
7036
- cursor: personIdSchema.optional(),
7037
- limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
6475
+ activityQuery = external_exports.object({
6476
+ limit: external_exports.coerce.number().int().min(1).max(100).optional()
7038
6477
  });
7039
- conversationCustomerPersonParam = external_exports.object({
7040
- hubId: external_exports.string().uuid(),
7041
- conversationId: external_exports.string().uuid()
6478
+ deletionModeSchema = external_exports.enum(["scheduled", "immediate"]);
6479
+ deletionRequestBody = external_exports.object({
6480
+ mode: deletionModeSchema,
6481
+ /** User-supplied reason captured in the audit log; bounded to bound logged PII. */
6482
+ reason: external_exports.string().max(500).optional(),
6483
+ /** Type-to-confirm value; must equal the user's email (constant-time compared). */
6484
+ email_confirmation: external_exports.string().min(1).max(320)
7042
6485
  });
7043
6486
  }
7044
6487
  });
@@ -7088,7 +6531,7 @@ var init_chunk_5FO3GNKP = __esm({
7088
6531
  }
7089
6532
  });
7090
6533
 
7091
- // ../../packages/core/dist/chunk-EJRDF5B6.js
6534
+ // ../../packages/core/dist/chunk-PC3774CE.js
7092
6535
  function matchPath(pattern, path45) {
7093
6536
  const pathSegments2 = path45.replace(/\/$/, "").split("/");
7094
6537
  const isPrefix = pattern.endsWith("/*");
@@ -7117,8 +6560,8 @@ function getEndpointConfig(path45) {
7117
6560
  return { tier: "STANDARD" };
7118
6561
  }
7119
6562
  var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
7120
- var init_chunk_EJRDF5B6 = __esm({
7121
- "../../packages/core/dist/chunk-EJRDF5B6.js"() {
6563
+ var init_chunk_PC3774CE = __esm({
6564
+ "../../packages/core/dist/chunk-PC3774CE.js"() {
7122
6565
  "use strict";
7123
6566
  init_chunk_5FO3GNKP();
7124
6567
  ENDPOINT_CONFIGS = {
@@ -7448,6 +6891,8 @@ var init_chunk_EJRDF5B6 = __esm({
7448
6891
  // takes the same strict, fail-closed budget as the other hub repairs. Exact path, for the same reason.
7449
6892
  "/api/admin/hubs/repair-knowledge-blobs": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
7450
6893
  "/api/admin/hubs/repair-credential-links": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
6894
+ // The org credential service backfill (#5644) writes org credentials, and its dry run reads every org: the same budget.
6895
+ "/api/admin/organizations/repair-credential-services": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
7451
6896
  // The WayAI-host token clear (#5644 steps 6–7) deletes connections and org credentials, and its dry run fans out over
7452
6897
  // every hub of every org: the same strict, fail-closed budget.
7453
6898
  "/api/admin/hubs/clear-wayai-host-tokens": { tier: "STRICT", userLimit: 10, userWindow: 3600, failClosed: true },
@@ -7621,7 +7066,7 @@ var init_chunk_EJRDF5B6 = __esm({
7621
7066
  }
7622
7067
  });
7623
7068
 
7624
- // ../../packages/core/dist/chunk-2FWVCLBC.js
7069
+ // ../../packages/core/dist/chunk-HFEOIQF4.js
7625
7070
  function fileSnapshotChanged(run) {
7626
7071
  return run.written + run.removed > 0;
7627
7072
  }
@@ -7662,10 +7107,10 @@ async function sendWithRetry(opts, cursor) {
7662
7107
  }
7663
7108
  }
7664
7109
  var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
7665
- var init_chunk_2FWVCLBC = __esm({
7666
- "../../packages/core/dist/chunk-2FWVCLBC.js"() {
7110
+ var init_chunk_HFEOIQF4 = __esm({
7111
+ "../../packages/core/dist/chunk-HFEOIQF4.js"() {
7667
7112
  "use strict";
7668
- init_chunk_EJRDF5B6();
7113
+ init_chunk_PC3774CE();
7669
7114
  init_chunk_5FO3GNKP();
7670
7115
  init_zod();
7671
7116
  rekorFileSnapshotAnswerSchema = external_exports.object({
@@ -7688,6 +7133,635 @@ var init_chunk_2FWVCLBC = __esm({
7688
7133
  }
7689
7134
  });
7690
7135
 
7136
+ // ../../packages/core/dist/chunk-IPDOHAZ5.js
7137
+ 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;
7138
+ var init_chunk_IPDOHAZ5 = __esm({
7139
+ "../../packages/core/dist/chunk-IPDOHAZ5.js"() {
7140
+ "use strict";
7141
+ init_chunk_HZ6CADSY();
7142
+ init_zod();
7143
+ reportSourceSchema = external_exports.enum(["sentry", "cli", "review", "security_audit"]);
7144
+ intakeReportSourceSchema = external_exports.enum(["cli", "review", "security_audit"]);
7145
+ reportClassificationSchema = external_exports.enum(["bug", "flaky_test", "security", "enhancement"]);
7146
+ reportStatusSchema = external_exports.enum([
7147
+ "pending",
7148
+ "grouped",
7149
+ "escalated",
7150
+ "shipped",
7151
+ "contested",
7152
+ "addressed",
7153
+ "dismissed"
7154
+ ]);
7155
+ reportLocaleSchema = external_exports.enum(["en", "pt", "es"]);
7156
+ reportMessageAuthorRoleSchema = external_exports.enum(["reporter", "triage", "fixer", "system"]);
7157
+ reportMessageSchema = external_exports.object({
7158
+ message_id: external_exports.string(),
7159
+ author_role: reportMessageAuthorRoleSchema,
7160
+ /** The status transition this note accompanied (e.g. 'shipped'); null for a free/system note. */
7161
+ transition: external_exports.string().nullable(),
7162
+ body: external_exports.string(),
7163
+ created_at: timestampSchema,
7164
+ /**
7165
+ * Visibility: `false` = reporter-facing (the default for every narrative entry); `true` =
7166
+ * triage-internal (e.g. a `hold` rationale) — surfaced to platform admins only and NEVER
7167
+ * returned on the reporter read path. The reporter's `GET /api/reports/:id` filters these out.
7168
+ */
7169
+ internal: external_exports.boolean()
7170
+ });
7171
+ sentryRefStatusSchema = external_exports.enum(["valid", "not_found", "mismatch", "unverified"]);
7172
+ createReportBody = external_exports.object({
7173
+ title: external_exports.string().min(5).max(256),
7174
+ description: external_exports.string().min(10).max(5e3),
7175
+ steps_to_reproduce: external_exports.string().max(3e3).optional(),
7176
+ error_message: external_exports.string().max(2e3).optional(),
7177
+ // Taxonomy (server defaults: source=cli, classification=bug when absent).
7178
+ source: intakeReportSourceSchema.optional(),
7179
+ classification: reportClassificationSchema.optional(),
7180
+ // Stable dedup key (e.g. "<file>::<test>" for flaky, "<file>:<line>" for
7181
+ // security). When present, the fingerprint uses it instead of the body hash.
7182
+ dedup_key: external_exports.string().min(1).max(256).optional(),
7183
+ // Context fields (auto-captured by the CLI)
7184
+ organization_id: external_exports.string().optional(),
7185
+ hub_id: external_exports.string().uuid().optional(),
7186
+ hub_name: external_exports.string().max(256).optional(),
7187
+ conversation_id: external_exports.string().uuid().optional(),
7188
+ agent_id: external_exports.string().uuid().optional(),
7189
+ agent_name: external_exports.string().max(256).optional(),
7190
+ client_version: external_exports.string().max(64).optional(),
7191
+ additional_context: external_exports.string().max(2e3).optional()
7192
+ });
7193
+ editReportBody = external_exports.object({
7194
+ title: external_exports.string().min(5).max(256).optional(),
7195
+ description: external_exports.string().min(10).max(5e3).optional(),
7196
+ steps_to_reproduce: external_exports.string().max(3e3).optional(),
7197
+ error_message: external_exports.string().max(2e3).optional(),
7198
+ additional_context: external_exports.string().max(2e3).optional()
7199
+ }).strict().refine((b) => Object.keys(b).length > 0, {
7200
+ message: "at least one field must be provided"
7201
+ });
7202
+ reporterReportSummarySchema = external_exports.object({
7203
+ report_id: external_exports.string(),
7204
+ title: external_exports.string(),
7205
+ description: external_exports.string(),
7206
+ classification: reportClassificationSchema,
7207
+ status: reportStatusSchema,
7208
+ created_at: timestampSchema,
7209
+ triaged_at: timestampSchema.nullable(),
7210
+ resolved_at: timestampSchema.nullable(),
7211
+ /** How many times the reporter has contested (gates the hard cap). */
7212
+ contest_count: external_exports.number(),
7213
+ /** True once triage issued a non-contestable (final) dismissal. */
7214
+ dismissal_final: external_exports.boolean()
7215
+ });
7216
+ reporterListResponseSchema = external_exports.object({
7217
+ data: external_exports.array(reporterReportSummarySchema)
7218
+ });
7219
+ getReportResponseSchema = external_exports.object({
7220
+ report: reporterReportSummarySchema,
7221
+ messages: external_exports.array(reportMessageSchema)
7222
+ });
7223
+ reporterTransitionResponseSchema = external_exports.object({
7224
+ report: reporterReportSummarySchema
7225
+ });
7226
+ contestReportBody = external_exports.object({
7227
+ reason: external_exports.string().min(1).max(5e3)
7228
+ });
7229
+ reporterListQuery = external_exports.object({
7230
+ status: reportStatusSchema.optional()
7231
+ });
7232
+ listReportsQuery = external_exports.object({
7233
+ status: reportStatusSchema.optional(),
7234
+ source: reportSourceSchema.optional(),
7235
+ limit: external_exports.coerce.number().int().min(1).max(200).optional(),
7236
+ offset: external_exports.coerce.number().int().min(0).optional(),
7237
+ /** ISO 8601 lower bound on created_at. */
7238
+ since: external_exports.string().datetime().optional(),
7239
+ /**
7240
+ * ISO 8601 lower bound on resolution time — "what did we resolve recently", which `since`
7241
+ * (a created_at filter) cannot answer for a long-lived report resolved yesterday. Implies
7242
+ * a terminal status (`addressed`/`dismissed`) and orders on that same axis.
7243
+ */
7244
+ resolved_since: external_exports.string().datetime().optional()
7245
+ });
7246
+ GITHUB_ISSUE_URL_REGEX = /^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+(?:[/?#]|$)/;
7247
+ githubIssueUrlSchema = external_exports.string().url().refine((u) => GITHUB_ISSUE_URL_REGEX.test(u), {
7248
+ message: "must be an https://github.com/<owner>/<repo>/issues/<number> URL"
7249
+ });
7250
+ transitionReportBody = external_exports.discriminatedUnion("target", [
7251
+ external_exports.object({
7252
+ target: external_exports.literal("escalated"),
7253
+ gh_issue_url: githubIssueUrlSchema,
7254
+ ai_verdict: external_exports.string().max(2e3).optional()
7255
+ }),
7256
+ external_exports.object({
7257
+ target: external_exports.literal("shipped"),
7258
+ note: external_exports.string().min(1).max(2e3).optional()
7259
+ }),
7260
+ external_exports.object({
7261
+ target: external_exports.literal("addressed")
7262
+ }),
7263
+ external_exports.object({
7264
+ target: external_exports.literal("dismissed"),
7265
+ dismissal_reason: external_exports.string().min(1).max(5e3),
7266
+ ai_verdict: external_exports.string().max(2e3).optional(),
7267
+ final: external_exports.boolean().optional()
7268
+ })
7269
+ ]);
7270
+ groupReportsBody = external_exports.object({
7271
+ member_ids: external_exports.array(external_exports.string().uuid()).min(1).max(100)
7272
+ });
7273
+ holdReportBody = external_exports.object({
7274
+ reason: external_exports.string().min(1).max(5e3)
7275
+ });
7276
+ }
7277
+ });
7278
+
7279
+ // ../../packages/core/dist/chunk-KEN2DASI.js
7280
+ var SECOND_FACTOR_TIERS, secondFactorTier, META_ENTITY_ID_PATTERN, metaEntityId, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, normalizeEmail, REVIEW_ACCOUNT_EMAILS;
7281
+ var init_chunk_KEN2DASI = __esm({
7282
+ "../../packages/core/dist/chunk-KEN2DASI.js"() {
7283
+ "use strict";
7284
+ init_zod();
7285
+ SECOND_FACTOR_TIERS = ["off", "settings"];
7286
+ secondFactorTier = external_exports.enum(SECOND_FACTOR_TIERS);
7287
+ META_ENTITY_ID_PATTERN = /^\d{1,32}$/;
7288
+ metaEntityId = external_exports.string().regex(META_ENTITY_ID_PATTERN, "must be a numeric Meta entity id");
7289
+ whatsappCallbackBody = external_exports.object({
7290
+ state: external_exports.string().min(1, "state is required"),
7291
+ code: external_exports.string().optional(),
7292
+ access_token: external_exports.string().optional(),
7293
+ user_id: external_exports.string().optional(),
7294
+ /**
7295
+ * The phone number and WABA the operator actually picked in Meta's Embedded
7296
+ * Signup popup (posted to the opener as `WA_EMBEDDED_SIGNUP`). Optional:
7297
+ * older clients, and the redirect-based flow, never see that event and fall
7298
+ * back to discovery.
7299
+ */
7300
+ phone_number_id: metaEntityId.optional(),
7301
+ waba_id: metaEntityId.optional()
7302
+ }).refine(
7303
+ (data) => !!data.access_token || !!data.code,
7304
+ { message: "Missing required parameters: state and either access_token or code" }
7305
+ );
7306
+ authMeResponse = external_exports.object({
7307
+ user_id: external_exports.string(),
7308
+ email: external_exports.string(),
7309
+ org_id: external_exports.string().nullable(),
7310
+ is_platform_admin: external_exports.boolean()
7311
+ });
7312
+ wsTicketResponse = external_exports.object({
7313
+ ticket: external_exports.string(),
7314
+ /** Seconds until the ticket expires if unconsumed. */
7315
+ expires_in: external_exports.number()
7316
+ });
7317
+ sessionCheckResponse = external_exports.object({
7318
+ valid: external_exports.literal(true)
7319
+ });
7320
+ logoutResponse = external_exports.object({
7321
+ success: external_exports.literal(true)
7322
+ });
7323
+ magicCodeSendBody = external_exports.object({
7324
+ email: external_exports.string().email("Invalid email").max(254)
7325
+ // RFC 5321 max; bounds the request payload
7326
+ });
7327
+ magicCodeSendResponse = external_exports.object({
7328
+ success: external_exports.literal(true)
7329
+ });
7330
+ magicCodeVerifyBody = external_exports.object({
7331
+ email: external_exports.string().email("Invalid email").max(254),
7332
+ // RFC 5321 max; bounds the request payload
7333
+ code: external_exports.string().min(1, "Code is required").max(12)
7334
+ // WorkOS sends a 6-digit code; bound the input
7335
+ });
7336
+ magicCodeVerifyResponse = external_exports.object({
7337
+ access_token: external_exports.string(),
7338
+ refresh_token: external_exports.string()
7339
+ });
7340
+ passwordLoginBody = external_exports.object({
7341
+ email: external_exports.string().email("Invalid email").max(254),
7342
+ // RFC 5321 max; bounds the request payload
7343
+ password: external_exports.string().min(1, "Password is required").max(128)
7344
+ // bound the payload; WorkOS validates
7345
+ });
7346
+ normalizeEmail = (email) => email.trim().toLowerCase();
7347
+ REVIEW_ACCOUNT_EMAILS = new Set(
7348
+ ["apple.review@wayai.pro", "play.review@wayai.pro", "microsoft.review@wayai.pro", "meta.review@wayai.pro"].map(
7349
+ normalizeEmail
7350
+ )
7351
+ );
7352
+ }
7353
+ });
7354
+
7355
+ // ../../packages/core/dist/chunk-PFGVH2CX.js
7356
+ var secondFactorCode, secondFactorRecoveryCode, secondFactorCodeBody, secondFactorRecoveryBody, secondFactorDisableBody, setOrgSecondFactorBody;
7357
+ var init_chunk_PFGVH2CX = __esm({
7358
+ "../../packages/core/dist/chunk-PFGVH2CX.js"() {
7359
+ "use strict";
7360
+ init_chunk_KEN2DASI();
7361
+ init_zod();
7362
+ secondFactorCode = external_exports.string().regex(/^\d{6}$/, "Enter the 6-digit code");
7363
+ secondFactorRecoveryCode = external_exports.string().min(1, "Enter a recovery code").max(64);
7364
+ secondFactorCodeBody = external_exports.object({ code: secondFactorCode });
7365
+ secondFactorRecoveryBody = external_exports.object({ recovery_code: secondFactorRecoveryCode });
7366
+ secondFactorDisableBody = external_exports.union([
7367
+ external_exports.object({ code: secondFactorCode, recovery_code: external_exports.undefined().optional() }),
7368
+ external_exports.object({ recovery_code: secondFactorRecoveryCode, code: external_exports.undefined().optional() })
7369
+ ]);
7370
+ setOrgSecondFactorBody = external_exports.object({ tier: secondFactorTier });
7371
+ }
7372
+ });
7373
+
7374
+ // ../../packages/core/dist/chunk-WE4KMHZK.js
7375
+ var bootstrapQuery;
7376
+ var init_chunk_WE4KMHZK = __esm({
7377
+ "../../packages/core/dist/chunk-WE4KMHZK.js"() {
7378
+ "use strict";
7379
+ init_zod();
7380
+ bootstrapQuery = external_exports.object({
7381
+ active_hub_id: external_exports.string().uuid().optional(),
7382
+ active_conversation_id: external_exports.string().uuid().optional(),
7383
+ active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
7384
+ /**
7385
+ * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
7386
+ * preloads it as `people.active_thread` when the viewer is a member.
7387
+ */
7388
+ active_thread_id: external_exports.string().uuid().optional()
7389
+ });
7390
+ }
7391
+ });
7392
+
7393
+ // ../../packages/core/dist/chunk-ZVXO3XL6.js
7394
+ var PEOPLE_CONTACT_PAGE_MAX, PEOPLE_CONTACT_PAGE_DEFAULT, PEOPLE_CONTACT_EMAIL_MAX_LENGTH, peopleUserIdSchema, peopleInviteEmailSchema, peopleContactInviteBody, peopleContactInviteIdParam, peopleContactUserIdParam, peopleContactBlockBody, peopleContactPageQuery, peopleOutgoingInviteSchema, peopleContactPersonSchema, peopleContactSchema, peopleIncomingInviteSchema, peopleBlockedUserSchema;
7395
+ var init_chunk_ZVXO3XL6 = __esm({
7396
+ "../../packages/core/dist/chunk-ZVXO3XL6.js"() {
7397
+ "use strict";
7398
+ init_chunk_HZ6CADSY();
7399
+ init_zod();
7400
+ PEOPLE_CONTACT_PAGE_MAX = 100;
7401
+ PEOPLE_CONTACT_PAGE_DEFAULT = 50;
7402
+ PEOPLE_CONTACT_EMAIL_MAX_LENGTH = 254;
7403
+ peopleUserIdSchema = external_exports.string().max(64).regex(USER_ID_REGEX, "must be a user id");
7404
+ peopleInviteEmailSchema = external_exports.string().trim().max(PEOPLE_CONTACT_EMAIL_MAX_LENGTH).email();
7405
+ peopleContactInviteBody = external_exports.object({
7406
+ email: peopleInviteEmailSchema
7407
+ }).strict();
7408
+ peopleContactInviteIdParam = external_exports.object({ inviteId: uuidSchema });
7409
+ peopleContactUserIdParam = external_exports.object({ userId: peopleUserIdSchema });
7410
+ peopleContactBlockBody = external_exports.object({ user_id: peopleUserIdSchema, thread_id: uuidSchema.optional(), community_id: uuidSchema.optional() }).strict().refine((body) => body.thread_id === void 0 || body.community_id === void 0, {
7411
+ message: "Name a thread or a community, not both",
7412
+ path: ["community_id"]
7413
+ });
7414
+ peopleContactPageQuery = external_exports.object({
7415
+ cursor: external_exports.string().min(1).max(256).optional(),
7416
+ limit: external_exports.coerce.number().int().min(1).max(PEOPLE_CONTACT_PAGE_MAX).default(PEOPLE_CONTACT_PAGE_DEFAULT)
7417
+ });
7418
+ peopleOutgoingInviteSchema = external_exports.object({
7419
+ invite_id: uuidSchema,
7420
+ email: external_exports.string(),
7421
+ status: external_exports.literal("sent"),
7422
+ created_at: timestampSchema,
7423
+ expires_at: timestampSchema
7424
+ }).strict();
7425
+ peopleContactPersonSchema = external_exports.object({
7426
+ user_id: peopleUserIdSchema,
7427
+ display_name: external_exports.string().nullable(),
7428
+ email: external_exports.string().nullable()
7429
+ }).strict();
7430
+ peopleContactSchema = peopleContactPersonSchema.extend({ contact_since: timestampSchema, thread_id: uuidSchema }).strict();
7431
+ peopleIncomingInviteSchema = external_exports.object({
7432
+ invite_id: uuidSchema,
7433
+ inviter: peopleContactPersonSchema,
7434
+ created_at: timestampSchema,
7435
+ expires_at: timestampSchema
7436
+ }).strict();
7437
+ peopleBlockedUserSchema = peopleContactPersonSchema.extend({ blocked_at: timestampSchema, deleted_user: external_exports.boolean() }).strict();
7438
+ }
7439
+ });
7440
+
7441
+ // ../../packages/core/dist/chunk-ZXK6N2HN.js
7442
+ var PEOPLE_MODERATION_NOTE_MAX_LENGTH, ADMIN_PEOPLE_REPORTS_PAGE_MAX, ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT, PEOPLE_SUSPENDED_REASON, peopleModerationActionSchema, moderationNoteSchema, adminPeopleReportListQuery, adminPeopleReportIdParam, adminPeopleMessageRemovalBody, adminPeopleSuspendBody, adminPeopleNoteBody;
7443
+ var init_chunk_ZXK6N2HN = __esm({
7444
+ "../../packages/core/dist/chunk-ZXK6N2HN.js"() {
7445
+ "use strict";
7446
+ init_chunk_ZVXO3XL6();
7447
+ init_chunk_HZ6CADSY();
7448
+ init_zod();
7449
+ PEOPLE_MODERATION_NOTE_MAX_LENGTH = 500;
7450
+ ADMIN_PEOPLE_REPORTS_PAGE_MAX = 100;
7451
+ ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT = 50;
7452
+ PEOPLE_SUSPENDED_REASON = "suspended";
7453
+ peopleModerationActionSchema = external_exports.enum(["remove_message", "suspend", "unsuspend", "dismiss"]);
7454
+ moderationNoteSchema = optionalTrimmedText(PEOPLE_MODERATION_NOTE_MAX_LENGTH);
7455
+ adminPeopleReportListQuery = external_exports.object({
7456
+ pending: external_exports.enum(["true", "false"]).optional().transform((value) => value === "true"),
7457
+ /** Lower bound on `created_at`. */
7458
+ since: timestampSchema.optional(),
7459
+ limit: external_exports.coerce.number().int().min(1).max(ADMIN_PEOPLE_REPORTS_PAGE_MAX).default(ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT),
7460
+ offset: external_exports.coerce.number().int().min(0).default(0)
7461
+ });
7462
+ adminPeopleReportIdParam = external_exports.object({ reportId: uuidSchema });
7463
+ adminPeopleMessageRemovalBody = external_exports.object({ report_id: uuidSchema, message_id: uuidSchema.optional(), note: moderationNoteSchema }).strict();
7464
+ adminPeopleSuspendBody = external_exports.object({ report_id: uuidSchema.optional(), note: moderationNoteSchema }).strict();
7465
+ adminPeopleNoteBody = external_exports.object({ note: moderationNoteSchema }).strict();
7466
+ }
7467
+ });
7468
+
7469
+ // ../../packages/core/dist/chunk-Y7CFCYX4.js
7470
+ var PEOPLE_REPORT_DETAILS_MAX_LENGTH, peopleReportReasonSchema, reportDetailsSchema, reportFields, peopleReportBody;
7471
+ var init_chunk_Y7CFCYX4 = __esm({
7472
+ "../../packages/core/dist/chunk-Y7CFCYX4.js"() {
7473
+ "use strict";
7474
+ init_chunk_ZVXO3XL6();
7475
+ init_chunk_HZ6CADSY();
7476
+ init_zod();
7477
+ PEOPLE_REPORT_DETAILS_MAX_LENGTH = 500;
7478
+ peopleReportReasonSchema = external_exports.enum(["spam", "harassment", "hate", "sexual", "violence", "other"]);
7479
+ reportDetailsSchema = optionalTrimmedText(PEOPLE_REPORT_DETAILS_MAX_LENGTH);
7480
+ reportFields = { reason: peopleReportReasonSchema, details: reportDetailsSchema };
7481
+ peopleReportBody = external_exports.discriminatedUnion("target", [
7482
+ external_exports.object({ target: external_exports.literal("message"), thread_id: uuidSchema, message_id: uuidSchema, ...reportFields }).strict(),
7483
+ external_exports.object({ target: external_exports.literal("thread"), thread_id: uuidSchema, ...reportFields }).strict(),
7484
+ external_exports.object({ target: external_exports.literal("user"), user_id: peopleUserIdSchema, thread_id: uuidSchema.optional(), ...reportFields }).strict(),
7485
+ external_exports.object({
7486
+ target: external_exports.literal("community_message"),
7487
+ community_id: uuidSchema,
7488
+ room_id: uuidSchema,
7489
+ message_id: uuidSchema,
7490
+ ...reportFields
7491
+ }).strict(),
7492
+ external_exports.object({ target: external_exports.literal("community_member"), community_id: uuidSchema, user_id: peopleUserIdSchema, ...reportFields }).strict()
7493
+ ]);
7494
+ }
7495
+ });
7496
+
7497
+ // ../../packages/core/dist/chunk-2YEGUQR7.js
7498
+ var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
7499
+ var init_chunk_2YEGUQR7 = __esm({
7500
+ "../../packages/core/dist/chunk-2YEGUQR7.js"() {
7501
+ "use strict";
7502
+ init_zod();
7503
+ PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
7504
+ CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
7505
+ PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
7506
+ userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
7507
+ personIdSchema = external_exports.string().refine(
7508
+ (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
7509
+ { message: PERSON_ID_FORM_MESSAGE }
7510
+ );
7511
+ }
7512
+ });
7513
+
7514
+ // ../../packages/core/dist/chunk-UAOHHCW5.js
7515
+ function normalizeContactPhone(raw) {
7516
+ const compact = raw.trim().replace(/[\s\-.()]/g, "");
7517
+ const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
7518
+ return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
7519
+ }
7520
+ function normalizeContactLabel(raw) {
7521
+ return raw.trim().replace(/\s+/g, " ").toLowerCase();
7522
+ }
7523
+ function importRowLabels(row, batchLabels) {
7524
+ return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
7525
+ }
7526
+ var CONTACT_ENVIRONMENTS, CONTACT_NAME_MAX, CONTACT_EMAIL_MAX, CONTACT_PHONE_INPUT_MAX, CONTACT_INSTAGRAM_SID_MAX, CONTACT_METADATA_MAX_BYTES, CONTACT_LABEL_MAX, CONTACT_LABELS_MAX, CONTACT_SCOPE_TAGS_MAX, CONTACT_PAGE_MAX, CONTACT_IMPORT_BATCH_MAX, CONTACT_SEARCH_MAX, CONTACT_LIST_NAME_MAX, CONTACT_LIST_NAME_REGEX, CONTACT_LIST_DESCRIPTION_MAX, CONTACT_LIST_FILTER_MAX, CONTACT_LIST_PINS_PER_REQUEST_MAX, SUPPRESSION_SCOPES, SUPPRESSION_ID_REGEX, contactName, contactPhone, contactEmail, contactInstagramSid, contactLabel, contactLabels, contactMetadata, scopeTagIds, contactVisibilitySchema, hasIdentity, IDENTITY_REQUIRED, contactBookOrgQuery, contactBookContactParam, contactBookListParam, contactBookHubParam, contactBookPageQuery, listContactBookContactsQuery, listHubContactBookContactsQuery, contactBookLinkCandidatesQuery, listContactBookListMembersQuery, contactRowFields, createContactBookContactBody, updateContactBookContactBody, contactImportRowSchema, importContactBookContactsBody, linkContactBookContactBody, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
7527
+ var init_chunk_UAOHHCW5 = __esm({
7528
+ "../../packages/core/dist/chunk-UAOHHCW5.js"() {
7529
+ "use strict";
7530
+ init_zod();
7531
+ CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
7532
+ CONTACT_NAME_MAX = 200;
7533
+ CONTACT_EMAIL_MAX = 320;
7534
+ CONTACT_PHONE_INPUT_MAX = 40;
7535
+ CONTACT_INSTAGRAM_SID_MAX = 64;
7536
+ CONTACT_METADATA_MAX_BYTES = 4096;
7537
+ CONTACT_LABEL_MAX = 64;
7538
+ CONTACT_LABELS_MAX = 20;
7539
+ CONTACT_SCOPE_TAGS_MAX = 20;
7540
+ CONTACT_PAGE_MAX = 100;
7541
+ CONTACT_IMPORT_BATCH_MAX = 500;
7542
+ CONTACT_SEARCH_MAX = 100;
7543
+ CONTACT_LIST_NAME_MAX = 64;
7544
+ CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
7545
+ CONTACT_LIST_DESCRIPTION_MAX = 1e3;
7546
+ CONTACT_LIST_FILTER_MAX = 20;
7547
+ CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
7548
+ SUPPRESSION_SCOPES = ["all", "marketing"];
7549
+ SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
7550
+ contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
7551
+ contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
7552
+ const phone = normalizeContactPhone(raw);
7553
+ if (phone === null) {
7554
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
7555
+ return external_exports.NEVER;
7556
+ }
7557
+ return phone;
7558
+ });
7559
+ contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
7560
+ contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
7561
+ contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label3) => label3.length > 0, "A label cannot be empty").refine((label3) => !label3.includes(","), "A label cannot contain a comma");
7562
+ contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
7563
+ contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
7564
+ try {
7565
+ return new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES;
7566
+ } catch {
7567
+ return false;
7568
+ }
7569
+ }, `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`);
7570
+ scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
7571
+ contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
7572
+ external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
7573
+ external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
7574
+ ]);
7575
+ hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
7576
+ IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
7577
+ contactBookOrgQuery = external_exports.object({
7578
+ organization_id: external_exports.string().uuid()
7579
+ });
7580
+ contactBookContactParam = external_exports.object({
7581
+ contactId: external_exports.string().uuid()
7582
+ });
7583
+ contactBookListParam = external_exports.object({
7584
+ listId: external_exports.string().uuid()
7585
+ });
7586
+ contactBookHubParam = external_exports.object({
7587
+ hubId: external_exports.string().uuid()
7588
+ });
7589
+ contactBookPageQuery = external_exports.object({
7590
+ cursor: external_exports.string().max(2048).optional(),
7591
+ limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
7592
+ });
7593
+ listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
7594
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
7595
+ label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
7596
+ scope_tag_id: external_exports.string().uuid().optional()
7597
+ });
7598
+ listHubContactBookContactsQuery = contactBookPageQuery.extend({
7599
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
7600
+ });
7601
+ contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
7602
+ email: contactEmail
7603
+ });
7604
+ listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
7605
+ contactRowFields = {
7606
+ name: contactName,
7607
+ phone: contactPhone.nullish(),
7608
+ email: contactEmail.nullish(),
7609
+ instagram_sid: contactInstagramSid.nullish(),
7610
+ labels: contactLabels.optional(),
7611
+ metadata: contactMetadata.optional()
7612
+ };
7613
+ createContactBookContactBody = external_exports.object({
7614
+ organization_id: external_exports.string().uuid(),
7615
+ ...contactRowFields,
7616
+ visibility: contactVisibilitySchema,
7617
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
7618
+ }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
7619
+ updateContactBookContactBody = external_exports.object({
7620
+ name: contactName.optional(),
7621
+ phone: contactPhone.nullable().optional(),
7622
+ email: contactEmail.nullable().optional(),
7623
+ instagram_sid: contactInstagramSid.nullable().optional(),
7624
+ labels: contactLabels.optional(),
7625
+ metadata: contactMetadata.optional(),
7626
+ visibility: contactVisibilitySchema.optional(),
7627
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
7628
+ }).strict();
7629
+ contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
7630
+ importContactBookContactsBody = external_exports.object({
7631
+ organization_id: external_exports.string().uuid(),
7632
+ visibility: contactVisibilitySchema,
7633
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
7634
+ labels: contactLabels.optional(),
7635
+ rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
7636
+ }).strict().superRefine((batch, ctx) => {
7637
+ batch.rows.forEach((row, index) => {
7638
+ if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
7639
+ ctx.addIssue({
7640
+ code: external_exports.ZodIssueCode.custom,
7641
+ path: ["rows", index, "labels"],
7642
+ message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
7643
+ });
7644
+ }
7645
+ });
7646
+ });
7647
+ linkContactBookContactBody = external_exports.object({
7648
+ user_id: external_exports.string().min(1).max(128)
7649
+ }).strict();
7650
+ listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
7651
+ message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
7652
+ });
7653
+ contactListFilterSchema = external_exports.object({
7654
+ labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
7655
+ scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
7656
+ }).strict();
7657
+ createContactBookListBody = external_exports.object({
7658
+ organization_id: external_exports.string().uuid(),
7659
+ name: listName,
7660
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
7661
+ filter: contactListFilterSchema.optional()
7662
+ }).strict();
7663
+ updateContactBookListBody = external_exports.object({
7664
+ name: listName.optional(),
7665
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
7666
+ filter: contactListFilterSchema.optional()
7667
+ }).strict();
7668
+ updateContactBookListPinsBody = external_exports.object({
7669
+ add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
7670
+ remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
7671
+ }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
7672
+ suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
7673
+ external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
7674
+ external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
7675
+ external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
7676
+ ]);
7677
+ createContactBookSuppressionBody = external_exports.object({
7678
+ organization_id: external_exports.string().uuid(),
7679
+ identity: suppressionIdentitySchema,
7680
+ scope: external_exports.enum(SUPPRESSION_SCOPES)
7681
+ }).strict();
7682
+ contactBookSuppressionParam = external_exports.object({
7683
+ suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
7684
+ });
7685
+ listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
7686
+ contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
7687
+ contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
7688
+ orgListReferenceSchema = listName;
7689
+ }
7690
+ });
7691
+
7692
+ // ../../packages/core/dist/chunk-MGBAXT5Y.js
7693
+ var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery, conversationCustomerPersonParam;
7694
+ var init_chunk_MGBAXT5Y = __esm({
7695
+ "../../packages/core/dist/chunk-MGBAXT5Y.js"() {
7696
+ "use strict";
7697
+ init_chunk_2YEGUQR7();
7698
+ init_chunk_UAOHHCW5();
7699
+ init_zod();
7700
+ PERSON_LINKS_MAX = 15;
7701
+ PERSON_DENY_PAGE_MAX = 100;
7702
+ personParam = external_exports.object({
7703
+ personId: userPersonIdSchema
7704
+ });
7705
+ personLinkParam = personParam.extend({
7706
+ targetId: personIdSchema
7707
+ });
7708
+ deniedPersonParam = external_exports.object({
7709
+ personId: personIdSchema
7710
+ });
7711
+ listDeniedPersonsQuery = contactBookOrgQuery.extend({
7712
+ cursor: personIdSchema.optional(),
7713
+ limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
7714
+ });
7715
+ conversationCustomerPersonParam = external_exports.object({
7716
+ hubId: external_exports.string().uuid(),
7717
+ conversationId: external_exports.string().uuid()
7718
+ });
7719
+ }
7720
+ });
7721
+
7722
+ // ../../packages/core/dist/chunk-YUZFHVB2.js
7723
+ var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
7724
+ var init_chunk_YUZFHVB2 = __esm({
7725
+ "../../packages/core/dist/chunk-YUZFHVB2.js"() {
7726
+ "use strict";
7727
+ init_zod();
7728
+ invitePreviewQuery = external_exports.object({
7729
+ token: external_exports.string().min(1).max(2048)
7730
+ });
7731
+ inviteRolePreviewResponse = external_exports.object({
7732
+ inviter_name: external_exports.string(),
7733
+ entity_id: external_exports.string().uuid(),
7734
+ entity_name: external_exports.string(),
7735
+ entity_type: external_exports.enum(["org", "hub"]),
7736
+ role: external_exports.enum(["org_admin", "admin", "team_user", "user"]),
7737
+ expires_at: external_exports.string().datetime()
7738
+ });
7739
+ inviteContactPreviewResponse = external_exports.object({
7740
+ inviter_name: external_exports.string().nullable(),
7741
+ entity_id: external_exports.string().uuid(),
7742
+ entity_type: external_exports.literal("contact"),
7743
+ role: external_exports.literal("contact"),
7744
+ expires_at: external_exports.string().datetime()
7745
+ });
7746
+ invitePreviewResponse = external_exports.union([inviteRolePreviewResponse, inviteContactPreviewResponse]);
7747
+ inviteUnsubscribeBody = external_exports.object({ token: external_exports.string().min(1).max(256) }).strict();
7748
+ }
7749
+ });
7750
+
7751
+ // ../../packages/core/dist/chunk-I3O2RACG.js
7752
+ var managedAgentsWebhookParams, MANAGED_AGENTS_WEBHOOK_BODY_MAX_BYTES;
7753
+ var init_chunk_I3O2RACG = __esm({
7754
+ "../../packages/core/dist/chunk-I3O2RACG.js"() {
7755
+ "use strict";
7756
+ init_zod();
7757
+ managedAgentsWebhookParams = external_exports.object({
7758
+ hub_id: external_exports.string().uuid(),
7759
+ connection_id: external_exports.string().uuid()
7760
+ });
7761
+ MANAGED_AGENTS_WEBHOOK_BODY_MAX_BYTES = 16 * 1024;
7762
+ }
7763
+ });
7764
+
7691
7765
  // ../../packages/core/dist/chunk-6J742GLA.js
7692
7766
  var PEOPLE_THREAD_MESSAGE_MAX_LENGTH, PEOPLE_THREAD_MESSAGES_PAGE_MAX, PEOPLE_THREAD_PAGE_MAX, PEOPLE_THREAD_PAGE_DEFAULT, PEOPLE_GROUP_NAME_MAX_LENGTH, PEOPLE_GROUP_AVATAR_URL_MAX_LENGTH, PEOPLE_THREAD_ATTACHMENT_MAX_BYTES, PEOPLE_THREAD_ATTACHMENT_NAME_MAX_LENGTH, PEOPLE_ATTACHMENT_STORAGE_PER_USER_BYTES, PEOPLE_THREAD_ATTACHMENT_MAX_MB, PEOPLE_THREAD_ATTACHMENT_URL_TTL_SECONDS, PEOPLE_THREAD_ATTACHMENT_URLS_MAX, peopleThreadIdParam, peopleThreadMessageIdParam, peopleThreadListQuery, peopleThreadMessagesQuery, peopleThreadAttachmentUploadSchema, peopleThreadSendBody, peopleThreadAttachmentUrlsBody, peopleThreadReadBody, peopleThreadSettingsBody, peopleGroupNameSchema, peopleGroupAvatarUrlSchema, peopleGroupCreateBody, peopleOrgDirectBody, peopleGroupUpdateBody, peopleGroupInviteBody, peopleOrgErasureBody, peopleGroupLeaveBody, peopleGroupInviteIdParam, peopleGroupIncomingInviteIdParam, peopleGroupMemberParam, peopleThreadKindSchema, peopleThreadMemberSchema, peopleThreadLastMessageSchema, peopleGroupRoleSchema, peopleGroupSummarySchema, peopleThreadSummarySchema, peopleThreadAttachmentSchema, peopleThreadMessageSchema, peopleGroupMemberSchema, peopleGroupSentInviteSchema, peopleGroupIncomingInviteSchema;
7693
7767
  var init_chunk_6J742GLA = __esm({
@@ -8514,12 +8588,12 @@ var init_chunk_FBV7NLKO = __esm({
8514
8588
  }
8515
8589
  });
8516
8590
 
8517
- // ../../packages/core/dist/chunk-XPI4K6MX.js
8591
+ // ../../packages/core/dist/chunk-GBX5UNUO.js
8518
8592
  var hubPageWatchParam, pageWatchedBaseSchema, hubPageWatchResponseSchema;
8519
- var init_chunk_XPI4K6MX = __esm({
8520
- "../../packages/core/dist/chunk-XPI4K6MX.js"() {
8593
+ var init_chunk_GBX5UNUO = __esm({
8594
+ "../../packages/core/dist/chunk-GBX5UNUO.js"() {
8521
8595
  "use strict";
8522
- init_chunk_FN7WRXIP();
8596
+ init_chunk_U4FSUKVU();
8523
8597
  init_chunk_FBV7NLKO();
8524
8598
  init_chunk_HZ6CADSY();
8525
8599
  init_zod();
@@ -8531,31 +8605,58 @@ var init_chunk_XPI4K6MX = __esm({
8531
8605
  }
8532
8606
  });
8533
8607
 
8534
- // ../../packages/core/dist/chunk-ZXK6N2HN.js
8535
- var PEOPLE_MODERATION_NOTE_MAX_LENGTH, ADMIN_PEOPLE_REPORTS_PAGE_MAX, ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT, PEOPLE_SUSPENDED_REASON, peopleModerationActionSchema, moderationNoteSchema, adminPeopleReportListQuery, adminPeopleReportIdParam, adminPeopleMessageRemovalBody, adminPeopleSuspendBody, adminPeopleNoteBody;
8536
- var init_chunk_ZXK6N2HN = __esm({
8537
- "../../packages/core/dist/chunk-ZXK6N2HN.js"() {
8608
+ // ../../packages/core/dist/chunk-SY6PLCPK.js
8609
+ var jsonSchemaSchema, hubUserIdentity, stateValueEntry, getHubUserContextResponse, updateHubUserBody, updateHubUserResponse, unlockHubUserNameResponse, stateResetParams, stateResetResponse;
8610
+ var init_chunk_SY6PLCPK = __esm({
8611
+ "../../packages/core/dist/chunk-SY6PLCPK.js"() {
8538
8612
  "use strict";
8539
- init_chunk_ZVXO3XL6();
8540
- init_chunk_HZ6CADSY();
8613
+ init_chunk_6TSQ5HXC();
8541
8614
  init_zod();
8542
- PEOPLE_MODERATION_NOTE_MAX_LENGTH = 500;
8543
- ADMIN_PEOPLE_REPORTS_PAGE_MAX = 100;
8544
- ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT = 50;
8545
- PEOPLE_SUSPENDED_REASON = "suspended";
8546
- peopleModerationActionSchema = external_exports.enum(["remove_message", "suspend", "unsuspend", "dismiss"]);
8547
- moderationNoteSchema = optionalTrimmedText(PEOPLE_MODERATION_NOTE_MAX_LENGTH);
8548
- adminPeopleReportListQuery = external_exports.object({
8549
- pending: external_exports.enum(["true", "false"]).optional().transform((value) => value === "true"),
8550
- /** Lower bound on `created_at`. */
8551
- since: timestampSchema.optional(),
8552
- limit: external_exports.coerce.number().int().min(1).max(ADMIN_PEOPLE_REPORTS_PAGE_MAX).default(ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT),
8553
- offset: external_exports.coerce.number().int().min(0).default(0)
8615
+ jsonSchemaSchema = external_exports.record(external_exports.unknown());
8616
+ hubUserIdentity = external_exports.object({
8617
+ user_id: external_exports.string().nullable(),
8618
+ user_name: external_exports.string().nullable(),
8619
+ user_email: external_exports.string().nullable(),
8620
+ user_name_locked: external_exports.boolean(),
8621
+ created_at: external_exports.string(),
8622
+ updated_at: external_exports.string().nullable(),
8623
+ hub_user_id: external_exports.string().optional(),
8624
+ enabled: external_exports.boolean().optional(),
8625
+ hub_team_id: external_exports.string().nullable().optional(),
8626
+ source: external_exports.enum(["grant", "auto"]).optional()
8627
+ });
8628
+ stateValueEntry = external_exports.object({
8629
+ state_slug: external_exports.string(),
8630
+ state_name: external_exports.string(),
8631
+ state_description: external_exports.string().nullable().optional(),
8632
+ scope: external_exports.enum(["user", "conversation"]),
8633
+ json_schema: jsonSchemaSchema,
8634
+ initial_value: external_exports.unknown(),
8635
+ value: external_exports.unknown(),
8636
+ is_reserved: external_exports.boolean()
8637
+ });
8638
+ getHubUserContextResponse = external_exports.object({
8639
+ user: hubUserIdentity,
8640
+ user_states: external_exports.array(stateValueEntry),
8641
+ conversation_states: external_exports.array(stateValueEntry)
8642
+ });
8643
+ updateHubUserBody = external_exports.object({
8644
+ // Non-empty, non-null. `.nullable()` here would bypass `.min(1)` and let an
8645
+ // admin arm the lock on a null name — see hub-do.ts updateHubUser null-guard.
8646
+ user_name: external_exports.string().min(1).max(120)
8647
+ });
8648
+ updateHubUserResponse = external_exports.object({
8649
+ user: hubUserIdentity
8650
+ });
8651
+ unlockHubUserNameResponse = external_exports.object({
8652
+ user: hubUserIdentity
8653
+ });
8654
+ stateResetParams = external_exports.object({
8655
+ stateSlug: slugSchema
8656
+ });
8657
+ stateResetResponse = external_exports.object({
8658
+ ok: external_exports.literal(true)
8554
8659
  });
8555
- adminPeopleReportIdParam = external_exports.object({ reportId: uuidSchema });
8556
- adminPeopleMessageRemovalBody = external_exports.object({ report_id: uuidSchema, message_id: uuidSchema.optional(), note: moderationNoteSchema }).strict();
8557
- adminPeopleSuspendBody = external_exports.object({ report_id: uuidSchema.optional(), note: moderationNoteSchema }).strict();
8558
- adminPeopleNoteBody = external_exports.object({ note: moderationNoteSchema }).strict();
8559
8660
  }
8560
8661
  });
8561
8662
 
@@ -8923,46 +9024,114 @@ var init_chunk_KMAC3O3L = __esm({
8923
9024
  }
8924
9025
  });
8925
9026
 
8926
- // ../../packages/core/dist/chunk-YUZFHVB2.js
8927
- var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
8928
- var init_chunk_YUZFHVB2 = __esm({
8929
- "../../packages/core/dist/chunk-YUZFHVB2.js"() {
9027
+ // ../../packages/core/dist/chunk-KSTYTQ7I.js
9028
+ var copilotSuggestBody, copilotSuggestResponse;
9029
+ var init_chunk_KSTYTQ7I = __esm({
9030
+ "../../packages/core/dist/chunk-KSTYTQ7I.js"() {
8930
9031
  "use strict";
8931
9032
  init_zod();
8932
- invitePreviewQuery = external_exports.object({
8933
- token: external_exports.string().min(1).max(2048)
8934
- });
8935
- inviteRolePreviewResponse = external_exports.object({
8936
- inviter_name: external_exports.string(),
8937
- entity_id: external_exports.string().uuid(),
8938
- entity_name: external_exports.string(),
8939
- entity_type: external_exports.enum(["org", "hub"]),
8940
- role: external_exports.enum(["org_admin", "admin", "team_user", "user"]),
8941
- expires_at: external_exports.string().datetime()
9033
+ copilotSuggestBody = external_exports.object({
9034
+ hub_id: external_exports.string().uuid()
8942
9035
  });
8943
- inviteContactPreviewResponse = external_exports.object({
8944
- inviter_name: external_exports.string().nullable(),
8945
- entity_id: external_exports.string().uuid(),
8946
- entity_type: external_exports.literal("contact"),
8947
- role: external_exports.literal("contact"),
8948
- expires_at: external_exports.string().datetime()
9036
+ copilotSuggestResponse = external_exports.object({
9037
+ status: external_exports.enum(["processing", "skipped"]),
9038
+ reason: external_exports.string().optional()
8949
9039
  });
8950
- invitePreviewResponse = external_exports.union([inviteRolePreviewResponse, inviteContactPreviewResponse]);
8951
- inviteUnsubscribeBody = external_exports.object({ token: external_exports.string().min(1).max(256) }).strict();
8952
9040
  }
8953
9041
  });
8954
9042
 
8955
- // ../../packages/core/dist/chunk-I3O2RACG.js
8956
- var managedAgentsWebhookParams, MANAGED_AGENTS_WEBHOOK_BODY_MAX_BYTES;
8957
- var init_chunk_I3O2RACG = __esm({
8958
- "../../packages/core/dist/chunk-I3O2RACG.js"() {
9043
+ // ../../packages/core/dist/chunk-LKBSHANA.js
9044
+ var DESKTOP_SHELL_VERSION_RE, DESKTOP_PLATFORMS, DESKTOP_FLAVORS, desktopShellInfoSchema, DESKTOP_PRESENCE_STATES, desktopPresenceSchema, desktopUpdateSchema, DESKTOP_SIGN_IN_URL_MAX_LENGTH, DESKTOP_APP_PATH_MAX_LENGTH, desktopAppPathSchema, DESKTOP_NOTIFICATION_KINDS, DESKTOP_NOTIFICATION_TITLE_MAX_LENGTH, DESKTOP_NOTIFICATION_BODY_MAX_LENGTH, notificationTitleSchema, notificationBodySchema, desktopNotificationSchema, DESKTOP_BADGE_MAX_COUNT, DESKTOP_BADGE_LABEL_MAX_LENGTH, desktopBadgeSchema, desktopNavigateSchema, desktopSettingsSchema, desktopSettingsChangeSchema, desktopBridgeArgsSchemas;
9045
+ var init_chunk_LKBSHANA = __esm({
9046
+ "../../packages/core/dist/chunk-LKBSHANA.js"() {
8959
9047
  "use strict";
8960
9048
  init_zod();
8961
- managedAgentsWebhookParams = external_exports.object({
8962
- hub_id: external_exports.string().uuid(),
8963
- connection_id: external_exports.string().uuid()
9049
+ DESKTOP_SHELL_VERSION_RE = /^(0|[1-9]\d{0,5})\.(0|[1-9]\d{0,5})\.(0|[1-9]\d{0,5})(-[0-9A-Za-z.-]{1,32})?$/;
9050
+ DESKTOP_PLATFORMS = ["darwin", "win32"];
9051
+ DESKTOP_FLAVORS = ["production", "development"];
9052
+ desktopShellInfoSchema = external_exports.object({
9053
+ /** The shell's own release version, independent of the web deploy. */
9054
+ shellVersion: external_exports.string().regex(DESKTOP_SHELL_VERSION_RE),
9055
+ /** The Electron runtime the shell was built with. */
9056
+ electronVersion: external_exports.string().regex(/^\d{1,4}\.\d{1,4}\.\d{1,4}(-[0-9A-Za-z.-]{1,32})?$/),
9057
+ platform: external_exports.enum(DESKTOP_PLATFORMS),
9058
+ /** CPU architecture as Node reports it (`arm64`, `x64`). */
9059
+ arch: external_exports.string().regex(/^[a-z0-9_]{1,16}$/),
9060
+ flavor: external_exports.enum(DESKTOP_FLAVORS),
9061
+ /**
9062
+ * Present, and true, when the shell runs from the Microsoft Store's package: the Store updates it,
9063
+ * and Windows alone opens it at login (the package's startup task, which the person turns on in
9064
+ * Windows' settings). An optional field, so no new `bridgeVersion`: an older page ignores it, and
9065
+ * its absence is every other shell.
9066
+ */
9067
+ store: external_exports.literal(true).optional()
8964
9068
  });
8965
- MANAGED_AGENTS_WEBHOOK_BODY_MAX_BYTES = 16 * 1024;
9069
+ DESKTOP_PRESENCE_STATES = ["present", "away"];
9070
+ desktopPresenceSchema = external_exports.object({
9071
+ presence: external_exports.enum(DESKTOP_PRESENCE_STATES),
9072
+ mainWindow: external_exports.object({
9073
+ shown: external_exports.boolean(),
9074
+ focused: external_exports.boolean()
9075
+ })
9076
+ });
9077
+ desktopUpdateSchema = external_exports.object({
9078
+ ready: external_exports.object({
9079
+ version: external_exports.string().regex(DESKTOP_SHELL_VERSION_RE),
9080
+ offerRestart: external_exports.boolean()
9081
+ }).nullable()
9082
+ });
9083
+ DESKTOP_SIGN_IN_URL_MAX_LENGTH = 4096;
9084
+ DESKTOP_APP_PATH_MAX_LENGTH = 512;
9085
+ desktopAppPathSchema = external_exports.string().max(DESKTOP_APP_PATH_MAX_LENGTH).regex(/^\/(?![/\\])[^\s\\]*$/);
9086
+ DESKTOP_NOTIFICATION_KINDS = ["handoff", "message", "summary"];
9087
+ DESKTOP_NOTIFICATION_TITLE_MAX_LENGTH = 200;
9088
+ DESKTOP_NOTIFICATION_BODY_MAX_LENGTH = 500;
9089
+ notificationTitleSchema = external_exports.string().min(1).max(DESKTOP_NOTIFICATION_TITLE_MAX_LENGTH);
9090
+ notificationBodySchema = external_exports.string().max(DESKTOP_NOTIFICATION_BODY_MAX_LENGTH);
9091
+ desktopNotificationSchema = external_exports.object({
9092
+ kind: external_exports.enum(DESKTOP_NOTIFICATION_KINDS),
9093
+ title: notificationTitleSchema,
9094
+ body: notificationBodySchema,
9095
+ path: desktopAppPathSchema,
9096
+ withoutPreview: external_exports.object({ title: notificationTitleSchema, body: notificationBodySchema }).optional()
9097
+ });
9098
+ DESKTOP_BADGE_MAX_COUNT = 1e6;
9099
+ DESKTOP_BADGE_LABEL_MAX_LENGTH = 200;
9100
+ desktopBadgeSchema = external_exports.object({
9101
+ count: external_exports.number().int().min(0).max(DESKTOP_BADGE_MAX_COUNT),
9102
+ label: external_exports.string().max(DESKTOP_BADGE_LABEL_MAX_LENGTH)
9103
+ });
9104
+ desktopNavigateSchema = external_exports.object({
9105
+ path: desktopAppPathSchema
9106
+ });
9107
+ desktopSettingsSchema = external_exports.object({
9108
+ /** The app opens when the person logs in to the computer: the operating system's own login item. */
9109
+ openAtLogin: external_exports.boolean(),
9110
+ /** Closing the window keeps the app running in the tray (true), or quits it (false). */
9111
+ closeToTray: external_exports.boolean(),
9112
+ /** The shell shows notifications (true), or none (false). The badge is not a notification. */
9113
+ notifications: external_exports.boolean(),
9114
+ /**
9115
+ * A customer message's notification shows the customer's name and words, where the platform
9116
+ * allows them at all (`desktopShowsCustomerWords`: macOS); elsewhere the shell never shows them.
9117
+ */
9118
+ messagePreview: external_exports.boolean()
9119
+ });
9120
+ desktopSettingsChangeSchema = desktopSettingsSchema.partial().strict().refine((change) => Object.values(change).every((value) => typeof value === "boolean"), {
9121
+ message: "each setting changed is true or false"
9122
+ });
9123
+ desktopBridgeArgsSchemas = {
9124
+ getShellInfo: external_exports.tuple([]),
9125
+ getPresence: external_exports.tuple([]),
9126
+ openSignIn: external_exports.tuple([external_exports.string().max(DESKTOP_SIGN_IN_URL_MAX_LENGTH)]),
9127
+ getUpdate: external_exports.tuple([]),
9128
+ restartToUpdate: external_exports.tuple([]),
9129
+ notify: external_exports.tuple([desktopNotificationSchema]),
9130
+ setBadge: external_exports.tuple([desktopBadgeSchema]),
9131
+ clearAll: external_exports.tuple([]),
9132
+ getSettings: external_exports.tuple([]),
9133
+ setSettings: external_exports.tuple([desktopSettingsChangeSchema])
9134
+ };
8966
9135
  }
8967
9136
  });
8968
9137
 
@@ -10365,58 +10534,72 @@ var init_chunk_OPETF4GS = __esm({
10365
10534
  }
10366
10535
  });
10367
10536
 
10368
- // ../../packages/core/dist/chunk-SY6PLCPK.js
10369
- var jsonSchemaSchema, hubUserIdentity, stateValueEntry, getHubUserContextResponse, updateHubUserBody, updateHubUserResponse, unlockHubUserNameResponse, stateResetParams, stateResetResponse;
10370
- var init_chunk_SY6PLCPK = __esm({
10371
- "../../packages/core/dist/chunk-SY6PLCPK.js"() {
10537
+ // ../../packages/core/dist/chunk-YULHXJ5M.js
10538
+ var COMMUNITY_LESSON_TREE_MAX_BYTES, COMMUNITY_LESSON_LINK_PROTOCOLS, COMMUNITY_LESSON_TREE_TOO_LARGE_REASON, COMMUNITY_LESSON_TREE_TOO_DEEP_REASON, COMMUNITY_LESSON_LINE_PREFIX_TOO_WIDE_REASON, LINK_SCHEME;
10539
+ var init_chunk_YULHXJ5M = __esm({
10540
+ "../../packages/core/dist/chunk-YULHXJ5M.js"() {
10541
+ "use strict";
10542
+ COMMUNITY_LESSON_TREE_MAX_BYTES = 512 * 1024;
10543
+ COMMUNITY_LESSON_LINK_PROTOCOLS = ["http", "https", "mailto"];
10544
+ COMMUNITY_LESSON_TREE_TOO_LARGE_REASON = "lesson_tree_too_large";
10545
+ COMMUNITY_LESSON_TREE_TOO_DEEP_REASON = "lesson_tree_too_deep";
10546
+ COMMUNITY_LESSON_LINE_PREFIX_TOO_WIDE_REASON = "lesson_line_prefix_too_wide";
10547
+ LINK_SCHEME = new RegExp(`^(${COMMUNITY_LESSON_LINK_PROTOCOLS.join("|")}):`, "i");
10548
+ }
10549
+ });
10550
+
10551
+ // ../../packages/core/dist/chunk-V4FRPRH5.js
10552
+ var CONSULT_THREAD_STATUSES, consultThreadStatus, CONSULT_THREAD_TITLE_MAX, consultThreadTitle, consultThreadSummary, listConsultThreadsQuery, listConsultThreadsResponse, createConsultThreadBody, createConsultThreadResponse, consultThreadIdParam, updateConsultThreadBody, updateConsultThreadResponse, CONSULT_AWAIT_TIMEOUT_MS;
10553
+ var init_chunk_V4FRPRH5 = __esm({
10554
+ "../../packages/core/dist/chunk-V4FRPRH5.js"() {
10372
10555
  "use strict";
10373
- init_chunk_6TSQ5HXC();
10374
10556
  init_zod();
10375
- jsonSchemaSchema = external_exports.record(external_exports.unknown());
10376
- hubUserIdentity = external_exports.object({
10377
- user_id: external_exports.string().nullable(),
10378
- user_name: external_exports.string().nullable(),
10379
- user_email: external_exports.string().nullable(),
10380
- user_name_locked: external_exports.boolean(),
10381
- created_at: external_exports.string(),
10382
- updated_at: external_exports.string().nullable(),
10383
- hub_user_id: external_exports.string().optional(),
10384
- enabled: external_exports.boolean().optional(),
10385
- hub_team_id: external_exports.string().nullable().optional(),
10386
- source: external_exports.enum(["grant", "auto"]).optional()
10557
+ CONSULT_THREAD_STATUSES = ["open", "awaiting", "resolved", "cancelled_at_close"];
10558
+ consultThreadStatus = external_exports.enum(CONSULT_THREAD_STATUSES);
10559
+ CONSULT_THREAD_TITLE_MAX = 120;
10560
+ consultThreadTitle = external_exports.string().trim().min(1).max(CONSULT_THREAD_TITLE_MAX);
10561
+ consultThreadSummary = external_exports.object({
10562
+ consult_thread_id: external_exports.string(),
10563
+ conversation_id: external_exports.string(),
10564
+ initiator_type: external_exports.enum(["team", "agent"]),
10565
+ initiator_id: external_exports.string(),
10566
+ engaged_agent_id: external_exports.string().nullable(),
10567
+ engaged_agent_name: external_exports.string().nullable(),
10568
+ title: external_exports.string().nullable(),
10569
+ status: consultThreadStatus,
10570
+ created_at: external_exports.string()
10387
10571
  });
10388
- stateValueEntry = external_exports.object({
10389
- state_slug: external_exports.string(),
10390
- state_name: external_exports.string(),
10391
- state_description: external_exports.string().nullable().optional(),
10392
- scope: external_exports.enum(["user", "conversation"]),
10393
- json_schema: jsonSchemaSchema,
10394
- initial_value: external_exports.unknown(),
10395
- value: external_exports.unknown(),
10396
- is_reserved: external_exports.boolean()
10572
+ listConsultThreadsQuery = external_exports.object({
10573
+ hub_id: external_exports.string().uuid()
10397
10574
  });
10398
- getHubUserContextResponse = external_exports.object({
10399
- user: hubUserIdentity,
10400
- user_states: external_exports.array(stateValueEntry),
10401
- conversation_states: external_exports.array(stateValueEntry)
10575
+ listConsultThreadsResponse = external_exports.object({
10576
+ threads: external_exports.array(consultThreadSummary)
10402
10577
  });
10403
- updateHubUserBody = external_exports.object({
10404
- // Non-empty, non-null. `.nullable()` here would bypass `.min(1)` and let an
10405
- // admin arm the lock on a null name — see hub-do.ts updateHubUser null-guard.
10406
- user_name: external_exports.string().min(1).max(120)
10578
+ createConsultThreadBody = external_exports.object({
10579
+ hub_id: external_exports.string().uuid(),
10580
+ title: consultThreadTitle.optional(),
10581
+ // Optionally engage a consultant on creation. Validated server-side against the
10582
+ // hub's `consultant`-role agents; a non-consultant / unknown id is rejected.
10583
+ engaged_agent_id: external_exports.string().uuid().optional()
10407
10584
  });
10408
- updateHubUserResponse = external_exports.object({
10409
- user: hubUserIdentity
10585
+ createConsultThreadResponse = external_exports.object({
10586
+ thread: consultThreadSummary
10410
10587
  });
10411
- unlockHubUserNameResponse = external_exports.object({
10412
- user: hubUserIdentity
10588
+ consultThreadIdParam = external_exports.object({
10589
+ id: external_exports.string().uuid(),
10590
+ threadId: external_exports.string().uuid()
10413
10591
  });
10414
- stateResetParams = external_exports.object({
10415
- stateSlug: slugSchema
10592
+ updateConsultThreadBody = external_exports.object({
10593
+ hub_id: external_exports.string().uuid(),
10594
+ title: consultThreadTitle.optional(),
10595
+ engaged_agent_id: external_exports.string().uuid().optional()
10596
+ }).refine((v) => v.title !== void 0 || v.engaged_agent_id !== void 0, {
10597
+ message: "Provide a title and/or an engaged_agent_id to update"
10416
10598
  });
10417
- stateResetResponse = external_exports.object({
10418
- ok: external_exports.literal(true)
10599
+ updateConsultThreadResponse = external_exports.object({
10600
+ thread: consultThreadSummary
10419
10601
  });
10602
+ CONSULT_AWAIT_TIMEOUT_MS = 15 * 6e4;
10420
10603
  }
10421
10604
  });
10422
10605
 
@@ -12603,114 +12786,115 @@ var init_chunk_WEV7ZGHP = __esm({
12603
12786
  }
12604
12787
  });
12605
12788
 
12606
- // ../../packages/core/dist/chunk-KSTYTQ7I.js
12607
- var copilotSuggestBody, copilotSuggestResponse;
12608
- var init_chunk_KSTYTQ7I = __esm({
12609
- "../../packages/core/dist/chunk-KSTYTQ7I.js"() {
12610
- "use strict";
12611
- init_zod();
12612
- copilotSuggestBody = external_exports.object({
12613
- hub_id: external_exports.string().uuid()
12614
- });
12615
- copilotSuggestResponse = external_exports.object({
12616
- status: external_exports.enum(["processing", "skipped"]),
12617
- reason: external_exports.string().optional()
12618
- });
12619
- }
12620
- });
12621
-
12622
- // ../../packages/core/dist/chunk-LKBSHANA.js
12623
- var DESKTOP_SHELL_VERSION_RE, DESKTOP_PLATFORMS, DESKTOP_FLAVORS, desktopShellInfoSchema, DESKTOP_PRESENCE_STATES, desktopPresenceSchema, desktopUpdateSchema, DESKTOP_SIGN_IN_URL_MAX_LENGTH, DESKTOP_APP_PATH_MAX_LENGTH, desktopAppPathSchema, DESKTOP_NOTIFICATION_KINDS, DESKTOP_NOTIFICATION_TITLE_MAX_LENGTH, DESKTOP_NOTIFICATION_BODY_MAX_LENGTH, notificationTitleSchema, notificationBodySchema, desktopNotificationSchema, DESKTOP_BADGE_MAX_COUNT, DESKTOP_BADGE_LABEL_MAX_LENGTH, desktopBadgeSchema, desktopNavigateSchema, desktopSettingsSchema, desktopSettingsChangeSchema, desktopBridgeArgsSchemas;
12624
- var init_chunk_LKBSHANA = __esm({
12625
- "../../packages/core/dist/chunk-LKBSHANA.js"() {
12789
+ // ../../packages/core/dist/chunk-7CYHPF35.js
12790
+ var appMessageSenderType, appMessageReceiverType, apiChannelMessage, apiChannelMessageBody, appMessageBody, appMessageResponse;
12791
+ var init_chunk_7CYHPF35 = __esm({
12792
+ "../../packages/core/dist/chunk-7CYHPF35.js"() {
12626
12793
  "use strict";
12794
+ init_chunk_HZ6CADSY();
12627
12795
  init_zod();
12628
- DESKTOP_SHELL_VERSION_RE = /^(0|[1-9]\d{0,5})\.(0|[1-9]\d{0,5})\.(0|[1-9]\d{0,5})(-[0-9A-Za-z.-]{1,32})?$/;
12629
- DESKTOP_PLATFORMS = ["darwin", "win32"];
12630
- DESKTOP_FLAVORS = ["production", "development"];
12631
- desktopShellInfoSchema = external_exports.object({
12632
- /** The shell's own release version, independent of the web deploy. */
12633
- shellVersion: external_exports.string().regex(DESKTOP_SHELL_VERSION_RE),
12634
- /** The Electron runtime the shell was built with. */
12635
- electronVersion: external_exports.string().regex(/^\d{1,4}\.\d{1,4}\.\d{1,4}(-[0-9A-Za-z.-]{1,32})?$/),
12636
- platform: external_exports.enum(DESKTOP_PLATFORMS),
12637
- /** CPU architecture as Node reports it (`arm64`, `x64`). */
12638
- arch: external_exports.string().regex(/^[a-z0-9_]{1,16}$/),
12639
- flavor: external_exports.enum(DESKTOP_FLAVORS),
12640
- /**
12641
- * Present, and true, when the shell runs from the Microsoft Store's package: the Store updates it,
12642
- * and Windows alone opens it at login (the package's startup task, which the person turns on in
12643
- * Windows' settings). An optional field, so no new `bridgeVersion`: an older page ignores it, and
12644
- * its absence is every other shell.
12645
- */
12646
- store: external_exports.literal(true).optional()
12647
- });
12648
- DESKTOP_PRESENCE_STATES = ["present", "away"];
12649
- desktopPresenceSchema = external_exports.object({
12650
- presence: external_exports.enum(DESKTOP_PRESENCE_STATES),
12651
- mainWindow: external_exports.object({
12652
- shown: external_exports.boolean(),
12653
- focused: external_exports.boolean()
12654
- })
12655
- });
12656
- desktopUpdateSchema = external_exports.object({
12657
- ready: external_exports.object({
12658
- version: external_exports.string().regex(DESKTOP_SHELL_VERSION_RE),
12659
- offerRestart: external_exports.boolean()
12660
- }).nullable()
12661
- });
12662
- DESKTOP_SIGN_IN_URL_MAX_LENGTH = 4096;
12663
- DESKTOP_APP_PATH_MAX_LENGTH = 512;
12664
- desktopAppPathSchema = external_exports.string().max(DESKTOP_APP_PATH_MAX_LENGTH).regex(/^\/(?![/\\])[^\s\\]*$/);
12665
- DESKTOP_NOTIFICATION_KINDS = ["handoff", "message", "summary"];
12666
- DESKTOP_NOTIFICATION_TITLE_MAX_LENGTH = 200;
12667
- DESKTOP_NOTIFICATION_BODY_MAX_LENGTH = 500;
12668
- notificationTitleSchema = external_exports.string().min(1).max(DESKTOP_NOTIFICATION_TITLE_MAX_LENGTH);
12669
- notificationBodySchema = external_exports.string().max(DESKTOP_NOTIFICATION_BODY_MAX_LENGTH);
12670
- desktopNotificationSchema = external_exports.object({
12671
- kind: external_exports.enum(DESKTOP_NOTIFICATION_KINDS),
12672
- title: notificationTitleSchema,
12673
- body: notificationBodySchema,
12674
- path: desktopAppPathSchema,
12675
- withoutPreview: external_exports.object({ title: notificationTitleSchema, body: notificationBodySchema }).optional()
12676
- });
12677
- DESKTOP_BADGE_MAX_COUNT = 1e6;
12678
- DESKTOP_BADGE_LABEL_MAX_LENGTH = 200;
12679
- desktopBadgeSchema = external_exports.object({
12680
- count: external_exports.number().int().min(0).max(DESKTOP_BADGE_MAX_COUNT),
12681
- label: external_exports.string().max(DESKTOP_BADGE_LABEL_MAX_LENGTH)
12796
+ appMessageSenderType = external_exports.enum(["user", "team"]);
12797
+ appMessageReceiverType = external_exports.enum(["user", "team", "agent", "assistant"]).transform((v) => v === "assistant" ? "agent" : v);
12798
+ apiChannelMessage = external_exports.object({
12799
+ text: clientOptionalString,
12800
+ attachments: external_exports.array(messageAttachment).max(MAX_ATTACHMENTS_PER_MESSAGE).nullish().transform((v) => v ?? void 0)
12801
+ }).refine((m) => m.text && m.text.length > 0 || m.attachments && m.attachments.length > 0, {
12802
+ message: "message must have text or at least one attachment"
12682
12803
  });
12683
- desktopNavigateSchema = external_exports.object({
12684
- path: desktopAppPathSchema
12804
+ apiChannelMessageBody = external_exports.object({
12805
+ // Correlation id (task hubs): new → new conversation, repeat → continue. min 1 so an
12806
+ // empty string can't masquerade as a ref. Mutually exclusive with conversation_id.
12807
+ external_ref: external_exports.string().min(1).max(256).optional(),
12808
+ // Continue a specific WayAI conversation (authorized against the hub/channel + owner).
12809
+ // UUID-validated here (unlike the app channel, whose client we control): allocation
12810
+ // only treats a UUID-shaped id as a provided conversation, so a malformed id would
12811
+ // otherwise skip the owner guard and silently MINT a new conversation instead of
12812
+ // rejecting. A format 400 is shape-only — not an existence oracle (a valid-but-unknown
12813
+ // UUID still collapses to the opaque authorization error downstream).
12814
+ conversation_id: external_exports.string().uuid().optional(),
12815
+ // On-behalf-of end-user identity. Absent → per-connection service principal (task-hub
12816
+ // only; chat hub rejects with 422 in the route).
12817
+ user: external_exports.object({
12818
+ id: external_exports.string().min(1),
12819
+ email: clientOptionalString,
12820
+ name: clientOptionalString
12821
+ }).optional(),
12822
+ message: apiChannelMessage,
12823
+ // Idempotency key: maps to channel_message_sid, deduped within one conversation
12824
+ // (ConversationDO.storeMessage). A retried POST resolves to the same conversation (a chat
12825
+ // hub's user, the external_ref, the conversation_id, or on a task hub with neither, this key
12826
+ // scoped by the sender), so it echoes the original message_id and skips billing / turn
12827
+ // dispatch. A failed store answers a retryable 503 only when this key is set; without it a
12828
+ // retry could store the message twice, so it answers 400.
12829
+ client_message_id: external_exports.string().min(1).max(256).optional()
12830
+ }).refine((b) => !(b.external_ref && b.conversation_id), {
12831
+ message: "provide external_ref or conversation_id, not both",
12832
+ path: ["external_ref"]
12685
12833
  });
12686
- desktopSettingsSchema = external_exports.object({
12687
- /** The app opens when the person logs in to the computer: the operating system's own login item. */
12688
- openAtLogin: external_exports.boolean(),
12689
- /** Closing the window keeps the app running in the tray (true), or quits it (false). */
12690
- closeToTray: external_exports.boolean(),
12691
- /** The shell shows notifications (true), or none (false). The badge is not a notification. */
12692
- notifications: external_exports.boolean(),
12693
- /**
12694
- * A customer message's notification shows the customer's name and words, where the platform
12695
- * allows them at all (`desktopShowsCustomerWords`: macOS); elsewhere the shell never shows them.
12696
- */
12697
- messagePreview: external_exports.boolean()
12834
+ appMessageBody = external_exports.object({
12835
+ // Message content — three historical aliases. All optional: an attachment-only
12836
+ // or voice-only message carries no text.
12837
+ content: clientOptionalString,
12838
+ message_text: clientOptionalString,
12839
+ message_body: clientOptionalString,
12840
+ // Conversation context. Ids are plain strings rather than `.uuid()` on purpose:
12841
+ // they are AUTHORIZED downstream, which is the stronger guarantee — a well-formed
12842
+ // uuid belonging to another tenant must fail just as hard as junk. `hub_id` is
12843
+ // gated by `assertHubEndUserAccess` (gh #3286) and `conversation_id` by HubDO's
12844
+ // conversation_index owner check (gh #2781, #3281). The route's own falsy guards
12845
+ // ('hub_id is required') still reject an empty one.
12846
+ hub_id: clientOptionalString,
12847
+ channel_id: clientOptionalString,
12848
+ conversation_id: clientOptionalString,
12849
+ hub_type: external_exports.enum(["chat", "task"]).nullish().transform((v) => v ?? void 0),
12850
+ // Stable idempotency key for one explicit task-hub launcher. HubDO scopes it
12851
+ // to the authenticated user and resolves retries/tabs to one conversation.
12852
+ task_start_id: external_exports.string().uuid().nullish().transform((v) => v ?? void 0),
12853
+ // Routing.
12854
+ sender_type: appMessageSenderType.nullish().transform((v) => v ?? void 0),
12855
+ receiver_type: appMessageReceiverType.nullish().transform((v) => v ?? void 0),
12856
+ // Only meaningful on a team send, where `validateAppTeamSendContext` proves the
12857
+ // caller may send to this receiver. Absent on a team send to a conversation with no
12858
+ // person, which names its `conversation_id` instead. The end-user branch ignores it —
12859
+ // see the receiver derivation in the route.
12860
+ user_receiver_id: clientOptionalString,
12861
+ // ── Internal consult (consultant-agents PR 2 — H1.0) ──────────────────────
12862
+ // A team member handling a customer conversation can tag a `consultant`-role
12863
+ // agent for a PRIVATE, team-only exchange that never reaches the customer. A
12864
+ // consult send is a team send with `receiver_type: 'agent'` targeting the
12865
+ // consultant; `user_receiver_id` identifies the customer whose conversation this is
12866
+ // (and is authorized by `validateAppTeamSendContext`, exactly as a team→user send is),
12867
+ // and is absent, as on a team→user send, when the conversation has no person. The consultant is resolved from `agent_receiver_id`
12868
+ // when supplied, else from an `@mention` parsed out of the message text against
12869
+ // the hub's consultant agents. `consult_thread_id` continues an existing thread;
12870
+ // absent, the route creates/reuses the single implicit thread. These fields are
12871
+ // inert on every non-consult send (end-user send, team→user send).
12872
+ agent_receiver_id: clientOptionalString,
12873
+ consult_thread_id: clientOptionalString,
12874
+ is_first_message: clientOptionalBoolean,
12875
+ end_conversation: clientOptionalBoolean,
12876
+ // Pre-generated by the client so the optimistic bubble and the stored row share
12877
+ // a key (transcription live-updates land on the same row instead of duplicating).
12878
+ message_id: clientOptionalString,
12879
+ attachments: external_exports.array(messageAttachment).max(MAX_ATTACHMENTS_PER_MESSAGE).nullish().transform((v) => v ?? void 0),
12880
+ // Base64-encoded audio for STT. Size-capped in the route (the cap is a byte
12881
+ // budget tied to the /channels/* bodyLimit, not a shape rule).
12882
+ audio_file: clientOptionalString
12698
12883
  });
12699
- desktopSettingsChangeSchema = desktopSettingsSchema.partial().strict().refine((change) => Object.values(change).every((value) => typeof value === "boolean"), {
12700
- message: "each setting changed is true or false"
12884
+ appMessageResponse = external_exports.object({
12885
+ success: external_exports.boolean(),
12886
+ message: external_exports.string(),
12887
+ result: external_exports.object({
12888
+ conversation_id: external_exports.string().optional(),
12889
+ message_id: external_exports.string().optional(),
12890
+ status: external_exports.string().optional(),
12891
+ files: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).optional(),
12892
+ // True when this request reused a task-start/message id already accepted by
12893
+ // the server. Clients must replace their optimistic payload with a fresh
12894
+ // authoritative read because another tab may have won with different text.
12895
+ deduped: external_exports.boolean().optional()
12896
+ }).optional()
12701
12897
  });
12702
- desktopBridgeArgsSchemas = {
12703
- getShellInfo: external_exports.tuple([]),
12704
- getPresence: external_exports.tuple([]),
12705
- openSignIn: external_exports.tuple([external_exports.string().max(DESKTOP_SIGN_IN_URL_MAX_LENGTH)]),
12706
- getUpdate: external_exports.tuple([]),
12707
- restartToUpdate: external_exports.tuple([]),
12708
- notify: external_exports.tuple([desktopNotificationSchema]),
12709
- setBadge: external_exports.tuple([desktopBadgeSchema]),
12710
- clearAll: external_exports.tuple([]),
12711
- getSettings: external_exports.tuple([]),
12712
- setSettings: external_exports.tuple([desktopSettingsChangeSchema])
12713
- };
12714
12898
  }
12715
12899
  });
12716
12900
 
@@ -12778,7 +12962,7 @@ var init_chunk_NETRUHZF = __esm({
12778
12962
  }
12779
12963
  });
12780
12964
 
12781
- // ../../packages/core/dist/chunk-EH45EEIA.js
12965
+ // ../../packages/core/dist/chunk-JSPSTJH4.js
12782
12966
  function toolParametersViolations(params) {
12783
12967
  try {
12784
12968
  if (containsKanbanPlaceholders(params)) return [];
@@ -12835,8 +13019,8 @@ function refineToolConfig(value, ctx) {
12835
13019
  }
12836
13020
  }
12837
13021
  var nonBlank, DEFAULT_TOOL_CONFIG_DESCRIPTION, MAX_CUSTOM_TOOL_CONFIG_TEXT_LAYERS, toolIdParam, listToolsQuery, toolAgentQuery, deleteToolQuery, toolConnectionsQuery, nativeToolIdSchema, CONTEXT_BOUNDARIES, contextBoundarySchema, addNativeToolBody, addMcpToolBody, toolReplaySettingsFields, toolReplaySettingsSchema, createCustomToolBody, updateCustomToolBody, updateToolExecutionConfigBody;
12838
- var init_chunk_EH45EEIA = __esm({
12839
- "../../packages/core/dist/chunk-EH45EEIA.js"() {
13022
+ var init_chunk_JSPSTJH4 = __esm({
13023
+ "../../packages/core/dist/chunk-JSPSTJH4.js"() {
12840
13024
  "use strict";
12841
13025
  init_chunk_WEXVYJ5H();
12842
13026
  init_chunk_HZ6CADSY();
@@ -12950,7 +13134,7 @@ var init_chunk_2ISUBJG7 = __esm({
12950
13134
  }
12951
13135
  });
12952
13136
 
12953
- // ../../packages/core/dist/chunk-ACXXM7PI.js
13137
+ // ../../packages/core/dist/chunk-FQ6TZ2X4.js
12954
13138
  function describeRole(role) {
12955
13139
  if (typeof role === "string") {
12956
13140
  return JSON.stringify(role.length > ROLE_ECHO_MAX ? `${role.slice(0, ROLE_ECHO_MAX)}\u2026` : role);
@@ -13129,11 +13313,11 @@ function terminalRunCount(counts) {
13129
13313
  return counts.successful_runs + counts.failed_runs;
13130
13314
  }
13131
13315
  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, EVAL_PERSON_ALIAS_RETIRED, EVAL_PERSON_ALIAS_REFUSED, 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;
13132
- var init_chunk_ACXXM7PI = __esm({
13133
- "../../packages/core/dist/chunk-ACXXM7PI.js"() {
13316
+ var init_chunk_FQ6TZ2X4 = __esm({
13317
+ "../../packages/core/dist/chunk-FQ6TZ2X4.js"() {
13134
13318
  "use strict";
13135
13319
  init_chunk_2YEGUQR7();
13136
- init_chunk_SDOG6762();
13320
+ init_chunk_RLS7WBVR();
13137
13321
  init_chunk_4LXDRTO4();
13138
13322
  init_chunk_MLNQUHG5();
13139
13323
  init_chunk_2ISUBJG7();
@@ -13496,57 +13680,6 @@ var init_chunk_LBDH7LCG = __esm({
13496
13680
  }
13497
13681
  });
13498
13682
 
13499
- // ../../packages/core/dist/chunk-D3EP4TDU.js
13500
- var primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody;
13501
- var init_chunk_D3EP4TDU = __esm({
13502
- "../../packages/core/dist/chunk-D3EP4TDU.js"() {
13503
- "use strict";
13504
- init_chunk_HZ6CADSY();
13505
- init_zod();
13506
- primaryRegionSchema = external_exports.enum([
13507
- "wnam",
13508
- "enam",
13509
- "sam",
13510
- "weur",
13511
- "eeur",
13512
- "apac",
13513
- "oc",
13514
- "afr",
13515
- "me"
13516
- ]);
13517
- placementSourceSchema = external_exports.enum([
13518
- "hub_config",
13519
- "org_config",
13520
- "parent_cascade",
13521
- "cf_colo",
13522
- "country",
13523
- "fallback",
13524
- "unpinned"
13525
- ]);
13526
- orgIdParam = external_exports.object({
13527
- id: uuidSchema
13528
- });
13529
- orgAdminIdParam = external_exports.object({
13530
- id: uuidSchema,
13531
- adminId: external_exports.string().min(1)
13532
- });
13533
- createOrganizationBody = external_exports.object({
13534
- organization_name: external_exports.string().min(1, "organization_name is required"),
13535
- // Write-once at creation; updateOrganizationBody does not accept this.
13536
- primary_region: primaryRegionSchema.optional()
13537
- });
13538
- updateOrganizationBody = external_exports.object({
13539
- organization_name: external_exports.string().min(1).optional(),
13540
- organization_avatar_url: external_exports.string().url().nullable().optional(),
13541
- timezone: external_exports.string().optional(),
13542
- business_hours: external_exports.unknown().optional()
13543
- }).passthrough();
13544
- addOrgAdminBody = external_exports.object({
13545
- user_email: external_exports.string().email("valid email is required")
13546
- });
13547
- }
13548
- });
13549
-
13550
13683
  // ../../packages/core/dist/chunk-X5PZZVTS.js
13551
13684
  function isEventRelativeFollowupType(type) {
13552
13685
  return typeof type === "string" && EVENT_RELATIVE_FOLLOWUP_TYPES.includes(type);
@@ -13945,6 +14078,57 @@ var init_chunk_X5PZZVTS = __esm({
13945
14078
  }
13946
14079
  });
13947
14080
 
14081
+ // ../../packages/core/dist/chunk-D3EP4TDU.js
14082
+ var primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody;
14083
+ var init_chunk_D3EP4TDU = __esm({
14084
+ "../../packages/core/dist/chunk-D3EP4TDU.js"() {
14085
+ "use strict";
14086
+ init_chunk_HZ6CADSY();
14087
+ init_zod();
14088
+ primaryRegionSchema = external_exports.enum([
14089
+ "wnam",
14090
+ "enam",
14091
+ "sam",
14092
+ "weur",
14093
+ "eeur",
14094
+ "apac",
14095
+ "oc",
14096
+ "afr",
14097
+ "me"
14098
+ ]);
14099
+ placementSourceSchema = external_exports.enum([
14100
+ "hub_config",
14101
+ "org_config",
14102
+ "parent_cascade",
14103
+ "cf_colo",
14104
+ "country",
14105
+ "fallback",
14106
+ "unpinned"
14107
+ ]);
14108
+ orgIdParam = external_exports.object({
14109
+ id: uuidSchema
14110
+ });
14111
+ orgAdminIdParam = external_exports.object({
14112
+ id: uuidSchema,
14113
+ adminId: external_exports.string().min(1)
14114
+ });
14115
+ createOrganizationBody = external_exports.object({
14116
+ organization_name: external_exports.string().min(1, "organization_name is required"),
14117
+ // Write-once at creation; updateOrganizationBody does not accept this.
14118
+ primary_region: primaryRegionSchema.optional()
14119
+ });
14120
+ updateOrganizationBody = external_exports.object({
14121
+ organization_name: external_exports.string().min(1).optional(),
14122
+ organization_avatar_url: external_exports.string().url().nullable().optional(),
14123
+ timezone: external_exports.string().optional(),
14124
+ business_hours: external_exports.unknown().optional()
14125
+ }).passthrough();
14126
+ addOrgAdminBody = external_exports.object({
14127
+ user_email: external_exports.string().email("valid email is required")
14128
+ });
14129
+ }
14130
+ });
14131
+
13948
14132
  // ../../packages/core/dist/chunk-PIZTARVG.js
13949
14133
  function byLocale(entry) {
13950
14134
  const shape = Object.fromEntries(SUPPORTED_LOCALES.map((locale) => [locale, entry.optional()]));
@@ -13983,7 +14167,7 @@ var init_chunk_PIZTARVG = __esm({
13983
14167
  }
13984
14168
  });
13985
14169
 
13986
- // ../../packages/core/dist/chunk-5LACAGAY.js
14170
+ // ../../packages/core/dist/chunk-L5KGJZQD.js
13987
14171
  function refineLaneReferences(val, ctx) {
13988
14172
  const lanes = val.lanes;
13989
14173
  const statuses = val.kanban_statuses;
@@ -14007,11 +14191,11 @@ function describeSyncWarning(warning) {
14007
14191
  return `${label3}: ${parts.join("; ")}. Promote the base so production's tools match the preview's.`;
14008
14192
  }
14009
14193
  var hubIdParam, hubAdminIdParam, hubUserIdParam, hubAgentIdParam, hubIdentityIdParam, hubTeamIdParam, hubTeamUserDeleteParam, hubSchemaQuery, HUB_USERS_PAGE_SIZE_MAX, HUB_USERS_SEARCH_MAX, HUB_USERS_CHANNEL_TYPES, getHubUsersQuery, PREVIEW_LABEL_MAX_LENGTH, MAX_ENDED_INDEX_RETENTION_DAYS, MAX_EVAL_RETENTION_DAYS, MAX_END_USER_DAILY_MESSAGE_LIMIT, endUserDailyMessageLimitField, previewLabelField, hubTagsField, createHubBody, updateHubBody, HUB_TAG_CHANGE_REFUSED, hubTagChangeRefusalSchema, addHubAdminBody, addHubIdentityAuthorizationBody, contactDecisionBody, approveContactBody, CONTACT_ACCESS_PAGE_SIZE_MAX, listContactAccessQuery, createHubTeamBody, updateHubTeamBody, addHubTeamUserBody, reassignHubUserBody, replicatePreviewBody, HUB_DIFF_SECTION_SET, HUB_DIFF_SECTIONS, updateChannelTestIdentitiesBody, claimCodeChannelParam, claimCodeDeleteParam;
14010
- var init_chunk_5LACAGAY = __esm({
14011
- "../../packages/core/dist/chunk-5LACAGAY.js"() {
14194
+ var init_chunk_L5KGJZQD = __esm({
14195
+ "../../packages/core/dist/chunk-L5KGJZQD.js"() {
14012
14196
  "use strict";
14013
- init_chunk_D3EP4TDU();
14014
14197
  init_chunk_X5PZZVTS();
14198
+ init_chunk_D3EP4TDU();
14015
14199
  init_chunk_PIZTARVG();
14016
14200
  init_chunk_HZ6CADSY();
14017
14201
  init_zod();
@@ -14207,7 +14391,7 @@ var init_chunk_5LACAGAY = __esm({
14207
14391
  }
14208
14392
  });
14209
14393
 
14210
- // ../../packages/core/dist/chunk-T65A4OFV.js
14394
+ // ../../packages/core/dist/chunk-RUFGXTXW.js
14211
14395
  function declaresNoConnection(agent) {
14212
14396
  return agent.connection === null && !agent.connection_id;
14213
14397
  }
@@ -14939,15 +15123,15 @@ function skillSectionsAsResources(scope) {
14939
15123
  };
14940
15124
  }
14941
15125
  var MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, MAX_HUB_AS_CODE_PAGE_MANIFEST_CHARS, hubAsCodePagesSchema, MAX_CALL_OPENING_CARRIERS, MAX_CALL_OPENING_AGGREGATE_ENCODED_BYTES, HUB_AS_CODE_AGENT_TOOL_KEYS, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, flagEntriesOf, boundedHubAsCodeResourcesSchema, isPlainObject, MIN_SKILLS_LAYOUT_CLI, MAX_HUB_AS_CODE_DEPTH, NAMED_DEPTH_SEGMENTS, NAMED_DEPTH_KEY_CHARS, fieldName, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, CI_APPLY_ENTITY_KINDS, CI_APPLY_OPERATIONS, ciApplyErrorBaseSchema, ciApplyErrorSchema, ciSyncCountSchema, ciSyncChangesSchema, ciSyncWarningSchema, ciSyncResponseSchema;
14942
- var init_chunk_T65A4OFV = __esm({
14943
- "../../packages/core/dist/chunk-T65A4OFV.js"() {
15126
+ var init_chunk_RUFGXTXW = __esm({
15127
+ "../../packages/core/dist/chunk-RUFGXTXW.js"() {
14944
15128
  "use strict";
14945
- init_chunk_EH45EEIA();
14946
- init_chunk_MFUQ2NQ5();
14947
- init_chunk_ACXXM7PI();
15129
+ init_chunk_JSPSTJH4();
15130
+ init_chunk_XYKOUYXA();
15131
+ init_chunk_FQ6TZ2X4();
14948
15132
  init_chunk_LBDH7LCG();
14949
15133
  init_chunk_4LXDRTO4();
14950
- init_chunk_5LACAGAY();
15134
+ init_chunk_L5KGJZQD();
14951
15135
  init_chunk_X5PZZVTS();
14952
15136
  init_chunk_PIZTARVG();
14953
15137
  init_chunk_3VHOXD5Y();
@@ -15274,75 +15458,6 @@ var init_chunk_JDJ4EUOL = __esm({
15274
15458
  }
15275
15459
  });
15276
15460
 
15277
- // ../../packages/core/dist/chunk-YULHXJ5M.js
15278
- var COMMUNITY_LESSON_TREE_MAX_BYTES, COMMUNITY_LESSON_LINK_PROTOCOLS, COMMUNITY_LESSON_TREE_TOO_LARGE_REASON, COMMUNITY_LESSON_TREE_TOO_DEEP_REASON, COMMUNITY_LESSON_LINE_PREFIX_TOO_WIDE_REASON, LINK_SCHEME;
15279
- var init_chunk_YULHXJ5M = __esm({
15280
- "../../packages/core/dist/chunk-YULHXJ5M.js"() {
15281
- "use strict";
15282
- COMMUNITY_LESSON_TREE_MAX_BYTES = 512 * 1024;
15283
- COMMUNITY_LESSON_LINK_PROTOCOLS = ["http", "https", "mailto"];
15284
- COMMUNITY_LESSON_TREE_TOO_LARGE_REASON = "lesson_tree_too_large";
15285
- COMMUNITY_LESSON_TREE_TOO_DEEP_REASON = "lesson_tree_too_deep";
15286
- COMMUNITY_LESSON_LINE_PREFIX_TOO_WIDE_REASON = "lesson_line_prefix_too_wide";
15287
- LINK_SCHEME = new RegExp(`^(${COMMUNITY_LESSON_LINK_PROTOCOLS.join("|")}):`, "i");
15288
- }
15289
- });
15290
-
15291
- // ../../packages/core/dist/chunk-V4FRPRH5.js
15292
- var CONSULT_THREAD_STATUSES, consultThreadStatus, CONSULT_THREAD_TITLE_MAX, consultThreadTitle, consultThreadSummary, listConsultThreadsQuery, listConsultThreadsResponse, createConsultThreadBody, createConsultThreadResponse, consultThreadIdParam, updateConsultThreadBody, updateConsultThreadResponse, CONSULT_AWAIT_TIMEOUT_MS;
15293
- var init_chunk_V4FRPRH5 = __esm({
15294
- "../../packages/core/dist/chunk-V4FRPRH5.js"() {
15295
- "use strict";
15296
- init_zod();
15297
- CONSULT_THREAD_STATUSES = ["open", "awaiting", "resolved", "cancelled_at_close"];
15298
- consultThreadStatus = external_exports.enum(CONSULT_THREAD_STATUSES);
15299
- CONSULT_THREAD_TITLE_MAX = 120;
15300
- consultThreadTitle = external_exports.string().trim().min(1).max(CONSULT_THREAD_TITLE_MAX);
15301
- consultThreadSummary = external_exports.object({
15302
- consult_thread_id: external_exports.string(),
15303
- conversation_id: external_exports.string(),
15304
- initiator_type: external_exports.enum(["team", "agent"]),
15305
- initiator_id: external_exports.string(),
15306
- engaged_agent_id: external_exports.string().nullable(),
15307
- engaged_agent_name: external_exports.string().nullable(),
15308
- title: external_exports.string().nullable(),
15309
- status: consultThreadStatus,
15310
- created_at: external_exports.string()
15311
- });
15312
- listConsultThreadsQuery = external_exports.object({
15313
- hub_id: external_exports.string().uuid()
15314
- });
15315
- listConsultThreadsResponse = external_exports.object({
15316
- threads: external_exports.array(consultThreadSummary)
15317
- });
15318
- createConsultThreadBody = external_exports.object({
15319
- hub_id: external_exports.string().uuid(),
15320
- title: consultThreadTitle.optional(),
15321
- // Optionally engage a consultant on creation. Validated server-side against the
15322
- // hub's `consultant`-role agents; a non-consultant / unknown id is rejected.
15323
- engaged_agent_id: external_exports.string().uuid().optional()
15324
- });
15325
- createConsultThreadResponse = external_exports.object({
15326
- thread: consultThreadSummary
15327
- });
15328
- consultThreadIdParam = external_exports.object({
15329
- id: external_exports.string().uuid(),
15330
- threadId: external_exports.string().uuid()
15331
- });
15332
- updateConsultThreadBody = external_exports.object({
15333
- hub_id: external_exports.string().uuid(),
15334
- title: consultThreadTitle.optional(),
15335
- engaged_agent_id: external_exports.string().uuid().optional()
15336
- }).refine((v) => v.title !== void 0 || v.engaged_agent_id !== void 0, {
15337
- message: "Provide a title and/or an engaged_agent_id to update"
15338
- });
15339
- updateConsultThreadResponse = external_exports.object({
15340
- thread: consultThreadSummary
15341
- });
15342
- CONSULT_AWAIT_TIMEOUT_MS = 15 * 6e4;
15343
- }
15344
- });
15345
-
15346
15461
  // ../../packages/core/dist/chunk-FOFCV4SW.js
15347
15462
  function isCaseAttributeDate(text4) {
15348
15463
  const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text4);
@@ -15459,10 +15574,10 @@ var init_chunk_VYINA6YP = __esm({
15459
15574
  }
15460
15575
  });
15461
15576
 
15462
- // ../../packages/core/dist/chunk-VHPMMK6K.js
15577
+ // ../../packages/core/dist/chunk-KYBVSEJ2.js
15463
15578
  var CASE_SPACE_NAME_MAX_LENGTH, CASE_SPACE_DEFAULT_TIME_ZONE, CASE_TEAM_NAME_MAX_LENGTH, CASE_TEAM_MEMBERS_MAX, CASE_TEAM_SCOPES_MAX, CASE_MEMBERS_PAGE_MAX, CASE_PAGE_CURSOR_MAX_LENGTH, CASE_LEVELS, CASE_TEAM_TARGET_KINDS, CASE_REGISTRY_CLOSED_REASON, caseSpaceNameSchema, caseSpaceTimeZoneSchema, updateCaseSpaceSettingsBody, adminCreateCaseSpaceBody, caseOrgParam, caseSpaceParam, caseMemberParam, caseAdministratorParam, caseTeamParam, casePageQuery, saveCaseMemberBody, caseTeamScopeSchema, caseTeamMemberInput, caseTeamFields, createCaseTeamBody, updateCaseTeamBody;
15464
- var init_chunk_VHPMMK6K = __esm({
15465
- "../../packages/core/dist/chunk-VHPMMK6K.js"() {
15579
+ var init_chunk_KYBVSEJ2 = __esm({
15580
+ "../../packages/core/dist/chunk-KYBVSEJ2.js"() {
15466
15581
  "use strict";
15467
15582
  init_chunk_VYINA6YP();
15468
15583
  init_chunk_ZVXO3XL6();
@@ -15476,7 +15591,7 @@ var init_chunk_VHPMMK6K = __esm({
15476
15591
  CASE_MEMBERS_PAGE_MAX = 200;
15477
15592
  CASE_PAGE_CURSOR_MAX_LENGTH = 2048;
15478
15593
  CASE_LEVELS = ["read", "edit", "conduct"];
15479
- CASE_TEAM_TARGET_KINDS = ["party_group", "party", "instrument", "case_type"];
15594
+ CASE_TEAM_TARGET_KINDS = ["party_group", "party", "instrument", "case_type", "case"];
15480
15595
  CASE_REGISTRY_CLOSED_REASON = "case_registry_closed";
15481
15596
  caseSpaceNameSchema = external_exports.string().trim().min(1).max(CASE_SPACE_NAME_MAX_LENGTH);
15482
15597
  caseSpaceTimeZoneSchema = external_exports.string().trim().min(1).max(TIME_ZONE_NAME_MAX_LENGTH).refine(isTimeZone, "Not a time zone (an IANA name such as America/Sao_Paulo)");
@@ -15522,7 +15637,7 @@ var init_chunk_VHPMMK6K = __esm({
15522
15637
  }
15523
15638
  });
15524
15639
 
15525
- // ../../packages/core/dist/chunk-KQSPA427.js
15640
+ // ../../packages/core/dist/chunk-GKXAUKRL.js
15526
15641
  function resolveItemLink(phaseFolder, target) {
15527
15642
  const slash = target.lastIndexOf("/");
15528
15643
  const folder = slash < 0 ? phaseFolder : target.slice(0, slash);
@@ -15721,11 +15836,11 @@ function caseTypeDefinitionProblem(definition) {
15721
15836
  return null;
15722
15837
  }
15723
15838
  var CASE_CODE_PATTERN, CASE_PHASE_CODE_PATTERN, CASE_PHASE_FOLDER_PATTERN, CASE_INPUT_KEY_PATTERN, CASE_CALCULATION_CODE_PATTERN, CASE_AGENDA_GROUP_CODE_PATTERN, CASE_DECISION_CODE_PATTERN, CASE_DECISION_OPTION_CODE_PATTERN, CASE_DECISION_EFFECT_PATTERN, FILE_PATH_SEGMENT_PATTERN, CASE_REVIEW_MODES, CASE_OUTPUT_FORMATS, CASE_INPUT_ORIGINS, CASE_TEMPLATE_MODES, CASE_AGENDA_QUORUMS, CASE_DECISION_TYPES, CASE_NUMERIC_DECISION_TYPES, CASE_TYPE_NAME_MAX_LENGTH, CASE_CODE_MAX_LENGTH, CASE_FILE_PATH_MAX_LENGTH, CASE_TASK_NAME_MAX_LENGTH, CASE_TASK_DEPENDENCIES_MAX, CASE_FIXED_TEXT_MAX_LENGTH, CASE_TYPE_DEFINITION_MAX_CHARS, CASE_TYPE_DEFINITION_ROWS_MAX, CASE_TYPE_VERSIONS_MAX, CASE_TYPES_PAGE_MAX, code, phaseCode, inputKey, caseAgendaGroupCodeSchema, decisionCode, label2, optionalText, itemLinkTarget, filePath, caseTypePartyRoleSchema, caseTypeOutcomeSchema, caseItemRequirementsSchema, caseItemLinksSchema, caseOutputItemSchema, casePhaseOutputSchema, casePhaseInputSchema, caseDecisionOptionSchema, decisionBound, caseAgendaDecisionSchema, caseAgendaGroupSchema, caseTypeTaskSchema, caseTypePhaseSchema, caseTypeDefinitionShape, caseValuesRepeated, caseTypeDefinitionSchema, caseTypeAbbreviationSchema, caseTypeNameSchema, createCaseTypeBody, publishCaseTypeVersionBody, setCaseTypeActiveBody, caseTypeParam, caseTypesPageQuery, caseTypeVersionQuery;
15724
- var init_chunk_KQSPA427 = __esm({
15725
- "../../packages/core/dist/chunk-KQSPA427.js"() {
15839
+ var init_chunk_GKXAUKRL = __esm({
15840
+ "../../packages/core/dist/chunk-GKXAUKRL.js"() {
15726
15841
  "use strict";
15727
15842
  init_chunk_FOFCV4SW();
15728
- init_chunk_VHPMMK6K();
15843
+ init_chunk_KYBVSEJ2();
15729
15844
  init_chunk_HZ6CADSY();
15730
15845
  init_chunk_ZTNFLGW5();
15731
15846
  init_zod();
@@ -15933,7 +16048,7 @@ var init_chunk_KQSPA427 = __esm({
15933
16048
  }
15934
16049
  });
15935
16050
 
15936
- // ../../packages/core/dist/chunk-5IQXVUZZ.js
16051
+ // ../../packages/core/dist/chunk-AIBWYEMW.js
15937
16052
  function openCaseProblem(body) {
15938
16053
  const pairs = /* @__PURE__ */ new Set();
15939
16054
  for (const [index, party] of body.parties.entries()) {
@@ -15945,12 +16060,12 @@ ${party.role}`;
15945
16060
  if (new Set(body.instrument_ids).size !== body.instrument_ids.length) return { reason: "instrument_repeated", at: "instrument_ids" };
15946
16061
  return null;
15947
16062
  }
15948
- var CASE_RECORD_CODE_PATTERN, CASE_RECORD_CODE_MAX_LENGTH, CASE_RECORD_PARTIES_MAX, CASE_RECORD_INSTRUMENTS_MAX, CASE_RECORD_ROLE_MAX_LENGTH, CASE_RECORDS_PAGE_MAX, CASE_RECORDS_QUERY_MAX_LENGTH, caseRecordPartySchema, openCaseShape, openCaseBody, previewOpenCaseShape, caseRecordParam, CASE_RECORD_STATUSES, caseRecordsQuery, CASE_STATE_SUMMARIES_MAX, caseStatesQuery, CASE_CLOSURE_REASON_MAX_LENGTH, closeCaseBody;
15949
- var init_chunk_5IQXVUZZ = __esm({
15950
- "../../packages/core/dist/chunk-5IQXVUZZ.js"() {
16063
+ var CASE_RECORD_CODE_PATTERN, CASE_RECORD_CODE_MAX_LENGTH, CASE_RECORD_PARTIES_MAX, CASE_RECORD_INSTRUMENTS_MAX, CASE_RECORD_ROLE_MAX_LENGTH, CASE_RECORDS_PAGE_MAX, CASE_RECORDS_QUERY_MAX_LENGTH, caseRecordPartySchema, openCaseShape, openCaseBody, previewOpenCaseShape, caseRecordParam, CASE_RECORD_STATUSES, caseRecordsQuery, CASE_STATE_SUMMARIES_MAX, caseStatesQuery, CASE_CLOSURE_REASON_MAX_LENGTH, closeCaseBody, setCaseConfidentialityBody;
16064
+ var init_chunk_AIBWYEMW = __esm({
16065
+ "../../packages/core/dist/chunk-AIBWYEMW.js"() {
15951
16066
  "use strict";
15952
- init_chunk_KQSPA427();
15953
- init_chunk_VHPMMK6K();
16067
+ init_chunk_GKXAUKRL();
16068
+ init_chunk_KYBVSEJ2();
15954
16069
  init_chunk_HZ6CADSY();
15955
16070
  init_chunk_ZTNFLGW5();
15956
16071
  init_zod();
@@ -16005,19 +16120,80 @@ var init_chunk_5IQXVUZZ = __esm({
16005
16120
  outcome_code: external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_CODE_PATTERN),
16006
16121
  reason: external_exports.string().trim().min(1).max(CASE_CLOSURE_REASON_MAX_LENGTH)
16007
16122
  }).strict();
16123
+ setCaseConfidentialityBody = external_exports.object({ confidential: external_exports.boolean() }).strict();
16124
+ }
16125
+ });
16126
+
16127
+ // ../../packages/core/dist/chunk-XCWEXZQE.js
16128
+ var CASE_RELATION_TYPE_CODE_PATTERN, CASE_RELATION_TYPE_CODE_MAX_LENGTH, CASE_RELATION_TYPE_NAME_MAX_LENGTH, CASE_RELATION_TYPES_PER_SPACE_MAX, CASE_RELATION_DESCRIPTION_MAX_LENGTH, CASE_RELATION_SIDES, CASE_EXTERNAL_SYSTEM_PATTERN, CASE_EXTERNAL_NUMBER_MAX_LENGTH, CASE_EXTERNAL_URL_MAX_LENGTH, trimmedName, relationTypeFields, createCaseRelationTypeBody, updateCaseRelationTypeBody, relateCasesBody, addCaseExternalReferenceBody, caseRelationTypeParam, caseRelationParam, caseExternalReferenceParam, caseRelationTypesQuery;
16129
+ var init_chunk_XCWEXZQE = __esm({
16130
+ "../../packages/core/dist/chunk-XCWEXZQE.js"() {
16131
+ "use strict";
16132
+ init_chunk_AIBWYEMW();
16133
+ init_chunk_KYBVSEJ2();
16134
+ init_chunk_HZ6CADSY();
16135
+ init_zod();
16136
+ CASE_RELATION_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
16137
+ CASE_RELATION_TYPE_CODE_MAX_LENGTH = 64;
16138
+ CASE_RELATION_TYPE_NAME_MAX_LENGTH = 200;
16139
+ CASE_RELATION_TYPES_PER_SPACE_MAX = 100;
16140
+ CASE_RELATION_DESCRIPTION_MAX_LENGTH = 500;
16141
+ CASE_RELATION_SIDES = ["origin", "destination"];
16142
+ CASE_EXTERNAL_SYSTEM_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,30}$/;
16143
+ CASE_EXTERNAL_NUMBER_MAX_LENGTH = 120;
16144
+ CASE_EXTERNAL_URL_MAX_LENGTH = 2048;
16145
+ trimmedName = external_exports.string().trim().min(1).max(CASE_RELATION_TYPE_NAME_MAX_LENGTH);
16146
+ relationTypeFields = { name: trimmedName, inverse_name: trimmedName, active: external_exports.boolean().default(true) };
16147
+ createCaseRelationTypeBody = external_exports.object({
16148
+ code: external_exports.string().trim().max(CASE_RELATION_TYPE_CODE_MAX_LENGTH).regex(CASE_RELATION_TYPE_CODE_PATTERN),
16149
+ ...relationTypeFields
16150
+ }).strict();
16151
+ updateCaseRelationTypeBody = external_exports.object({ ...relationTypeFields, expected_updated_at: timestampSchema.optional() }).strict();
16152
+ relateCasesBody = external_exports.object({
16153
+ relation_type_id: uuidSchema,
16154
+ other_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN),
16155
+ /** This case's side: `origin` reads the type's name ("continues"), `destination` its inverse. */
16156
+ side: external_exports.enum(CASE_RELATION_SIDES).default("origin"),
16157
+ description: external_exports.string().trim().min(1).max(CASE_RELATION_DESCRIPTION_MAX_LENGTH).nullable().default(null)
16158
+ }).strict();
16159
+ addCaseExternalReferenceBody = external_exports.object({
16160
+ system: external_exports.string().trim().regex(CASE_EXTERNAL_SYSTEM_PATTERN),
16161
+ number: external_exports.string().trim().min(1).max(CASE_EXTERNAL_NUMBER_MAX_LENGTH),
16162
+ url: external_exports.string().trim().max(CASE_EXTERNAL_URL_MAX_LENGTH).url().refine((url) => url.startsWith("https://"), "An https link").nullable().default(null)
16163
+ }).strict();
16164
+ caseRelationTypeParam = caseSpaceParam.extend({ relation_type_id: uuidSchema });
16165
+ caseRelationParam = caseRecordParam.extend({ relation_id: uuidSchema });
16166
+ caseExternalReferenceParam = caseRecordParam.extend({ reference_id: uuidSchema });
16167
+ caseRelationTypesQuery = casePageQuery.extend({
16168
+ limit: external_exports.coerce.number().int().min(1).max(CASE_RELATION_TYPES_PER_SPACE_MAX).optional()
16169
+ });
16170
+ }
16171
+ });
16172
+
16173
+ // ../../packages/core/dist/chunk-N6SE35OR.js
16174
+ var CASE_MEMBER_CASES_PAGE_MAX, caseMemberReachQuery;
16175
+ var init_chunk_N6SE35OR = __esm({
16176
+ "../../packages/core/dist/chunk-N6SE35OR.js"() {
16177
+ "use strict";
16178
+ init_chunk_KYBVSEJ2();
16179
+ init_zod();
16180
+ CASE_MEMBER_CASES_PAGE_MAX = 50;
16181
+ caseMemberReachQuery = casePageQuery.extend({
16182
+ limit: external_exports.coerce.number().int().min(1).max(CASE_MEMBER_CASES_PAGE_MAX).optional()
16183
+ }).strict();
16008
16184
  }
16009
16185
  });
16010
16186
 
16011
- // ../../packages/core/dist/chunk-YMNHLPJB.js
16187
+ // ../../packages/core/dist/chunk-5THMAK2R.js
16012
16188
  function addCaseNoteProblem(note) {
16013
16189
  return note.origin !== null && note.kind !== "contribution" ? { reason: "origin_not_contribution", at: "origin" } : null;
16014
16190
  }
16015
16191
  var CASE_NOTE_KINDS, CASE_NOTE_TEXT_MAX_LENGTH, CASE_NOTE_ORIGIN_MAX_LENGTH, CASE_NOTES_PAGE_MAX, addCaseNoteShape, addCaseNoteBody, caseNoteParam, caseTaskParam, caseNotesQuery;
16016
- var init_chunk_YMNHLPJB = __esm({
16017
- "../../packages/core/dist/chunk-YMNHLPJB.js"() {
16192
+ var init_chunk_5THMAK2R = __esm({
16193
+ "../../packages/core/dist/chunk-5THMAK2R.js"() {
16018
16194
  "use strict";
16019
- init_chunk_5IQXVUZZ();
16020
- init_chunk_VHPMMK6K();
16195
+ init_chunk_AIBWYEMW();
16196
+ init_chunk_KYBVSEJ2();
16021
16197
  init_chunk_HZ6CADSY();
16022
16198
  init_zod();
16023
16199
  CASE_NOTE_KINDS = ["observation", "next_step", "pending", "contribution"];
@@ -16046,7 +16222,7 @@ var init_chunk_YMNHLPJB = __esm({
16046
16222
  }
16047
16223
  });
16048
16224
 
16049
- // ../../packages/core/dist/chunk-OQMCZSR4.js
16225
+ // ../../packages/core/dist/chunk-SE6YMSWN.js
16050
16226
  function withProblem(shape, problemOf) {
16051
16227
  return shape.superRefine((value, ctx) => {
16052
16228
  const found = problemOf(value);
@@ -16082,12 +16258,12 @@ function caseInstrumentProblem(instrument) {
16082
16258
  ${party.role}`);
16083
16259
  return new Set(keys).size === keys.length ? null : { reason: "instrument_party_repeated", at: "parties" };
16084
16260
  }
16085
- var CASE_REGISTRY_TYPE_CODE_PATTERN, CASE_REGISTRY_TYPE_CODE_MAX_LENGTH, CASE_REGISTRY_NAME_MAX_LENGTH, CASE_REGISTRY_TYPE_SCHEMA_MAX_CHARS, CASE_PARTY_ABBREVIATION_PATTERN, CASE_PARTY_PERSON_KINDS, CASE_PARTY_DOCUMENT_KINDS, CASE_PARTY_DOCUMENT_MAX_LENGTH, CASE_PARTY_GROUP_MEMBERS_MAX, CASE_INSTRUMENT_NUMBER_MAX_LENGTH, CASE_INSTRUMENT_ROLE_MAX_LENGTH, CASE_INSTRUMENT_PARTIES_MAX, CASE_REGISTRY_PAGE_MAX, CASE_REGISTRY_QUERY_MAX_LENGTH, trimmedName, dateSchema, attributesValues, registryTypeFields, createCaseRegistryTypeShape, updateCaseRegistryTypeShape, createCaseRegistryTypeBody, updateCaseRegistryTypeBody, saveCasePartyShape, saveCasePartyBody, saveCasePartyGroupShape, saveCasePartyGroupBody, caseInstrumentPartyInput, saveCaseInstrumentShape, saveCaseInstrumentBody, registryPage, searchText, casePartiesQuery, casePartyGroupsQuery, caseInstrumentsQuery, caseRegistryTypeParam, casePartyParam, casePartyGroupParam, caseInstrumentParam;
16086
- var init_chunk_OQMCZSR4 = __esm({
16087
- "../../packages/core/dist/chunk-OQMCZSR4.js"() {
16261
+ var CASE_REGISTRY_TYPE_CODE_PATTERN, CASE_REGISTRY_TYPE_CODE_MAX_LENGTH, CASE_REGISTRY_NAME_MAX_LENGTH, CASE_REGISTRY_TYPE_SCHEMA_MAX_CHARS, CASE_PARTY_ABBREVIATION_PATTERN, CASE_PARTY_PERSON_KINDS, CASE_PARTY_DOCUMENT_KINDS, CASE_PARTY_DOCUMENT_MAX_LENGTH, CASE_PARTY_GROUP_MEMBERS_MAX, CASE_INSTRUMENT_NUMBER_MAX_LENGTH, CASE_INSTRUMENT_ROLE_MAX_LENGTH, CASE_INSTRUMENT_PARTIES_MAX, CASE_REGISTRY_PAGE_MAX, CASE_REGISTRY_QUERY_MAX_LENGTH, trimmedName2, dateSchema, attributesValues, registryTypeFields, createCaseRegistryTypeShape, updateCaseRegistryTypeShape, createCaseRegistryTypeBody, updateCaseRegistryTypeBody, saveCasePartyShape, saveCasePartyBody, saveCasePartyGroupShape, saveCasePartyGroupBody, caseInstrumentPartyInput, saveCaseInstrumentShape, saveCaseInstrumentBody, registryPage, searchText, casePartiesQuery, casePartyGroupsQuery, caseInstrumentsQuery, caseRegistryTypeParam, casePartyParam, casePartyGroupParam, caseInstrumentParam;
16262
+ var init_chunk_SE6YMSWN = __esm({
16263
+ "../../packages/core/dist/chunk-SE6YMSWN.js"() {
16088
16264
  "use strict";
16089
16265
  init_chunk_FOFCV4SW();
16090
- init_chunk_VHPMMK6K();
16266
+ init_chunk_KYBVSEJ2();
16091
16267
  init_chunk_HZ6CADSY();
16092
16268
  init_zod();
16093
16269
  CASE_REGISTRY_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
@@ -16104,11 +16280,11 @@ var init_chunk_OQMCZSR4 = __esm({
16104
16280
  CASE_INSTRUMENT_PARTIES_MAX = 50;
16105
16281
  CASE_REGISTRY_PAGE_MAX = 100;
16106
16282
  CASE_REGISTRY_QUERY_MAX_LENGTH = 200;
16107
- trimmedName = external_exports.string().trim().min(1).max(CASE_REGISTRY_NAME_MAX_LENGTH);
16283
+ trimmedName2 = external_exports.string().trim().min(1).max(CASE_REGISTRY_NAME_MAX_LENGTH);
16108
16284
  dateSchema = external_exports.string().refine(isCaseAttributeDate, "Not a date (YYYY-MM-DD)");
16109
16285
  attributesValues = external_exports.record(external_exports.string(), external_exports.unknown()).default({});
16110
16286
  registryTypeFields = {
16111
- name: trimmedName,
16287
+ name: trimmedName2,
16112
16288
  attributes: caseAttributesSchemaSchema.default(EMPTY_CASE_ATTRIBUTES_SCHEMA),
16113
16289
  active: external_exports.boolean().default(true)
16114
16290
  };
@@ -16124,7 +16300,7 @@ var init_chunk_OQMCZSR4 = __esm({
16124
16300
  updateCaseRegistryTypeBody = withProblem(updateCaseRegistryTypeShape, caseRegistryTypeProblem);
16125
16301
  saveCasePartyShape = external_exports.object({
16126
16302
  type_id: uuidSchema,
16127
- name: trimmedName,
16303
+ name: trimmedName2,
16128
16304
  abbreviation: external_exports.string().trim().transform((value) => value.toUpperCase()).pipe(external_exports.string().regex(CASE_PARTY_ABBREVIATION_PATTERN)).nullable().default(null),
16129
16305
  person_kind: external_exports.enum(CASE_PARTY_PERSON_KINDS),
16130
16306
  document_kind: external_exports.enum(CASE_PARTY_DOCUMENT_KINDS).nullable().default(null),
@@ -16135,7 +16311,7 @@ var init_chunk_OQMCZSR4 = __esm({
16135
16311
  }).strict();
16136
16312
  saveCasePartyBody = withProblem(saveCasePartyShape, casePartyProblem);
16137
16313
  saveCasePartyGroupShape = external_exports.object({
16138
- name: trimmedName,
16314
+ name: trimmedName2,
16139
16315
  party_ids: external_exports.array(uuidSchema).max(CASE_PARTY_GROUP_MEMBERS_MAX).default([]),
16140
16316
  expected_updated_at: timestampSchema.optional()
16141
16317
  }).strict();
@@ -16188,128 +16364,27 @@ var init_chunk_IGLHT6YP = __esm({
16188
16364
  }
16189
16365
  });
16190
16366
 
16191
- // ../../packages/core/dist/chunk-5XV7YVGX.js
16192
- var CASE_TIMELINE_PAGE_MAX, caseTimelineQuery;
16193
- var init_chunk_5XV7YVGX = __esm({
16194
- "../../packages/core/dist/chunk-5XV7YVGX.js"() {
16367
+ // ../../packages/core/dist/chunk-7ULJTQXZ.js
16368
+ var caseTeamPreviewBody;
16369
+ var init_chunk_7ULJTQXZ = __esm({
16370
+ "../../packages/core/dist/chunk-7ULJTQXZ.js"() {
16195
16371
  "use strict";
16196
- init_chunk_VHPMMK6K();
16197
- init_zod();
16198
- CASE_TIMELINE_PAGE_MAX = 100;
16199
- caseTimelineQuery = casePageQuery.extend({
16200
- limit: external_exports.coerce.number().int().min(1).max(CASE_TIMELINE_PAGE_MAX).optional()
16201
- });
16372
+ init_chunk_KYBVSEJ2();
16373
+ init_chunk_HZ6CADSY();
16374
+ caseTeamPreviewBody = createCaseTeamBody.pick({ active: true, scopes: true, members: true }).extend({ team_id: uuidSchema.optional() }).strict();
16202
16375
  }
16203
16376
  });
16204
16377
 
16205
- // ../../packages/core/dist/chunk-7CYHPF35.js
16206
- var appMessageSenderType, appMessageReceiverType, apiChannelMessage, apiChannelMessageBody, appMessageBody, appMessageResponse;
16207
- var init_chunk_7CYHPF35 = __esm({
16208
- "../../packages/core/dist/chunk-7CYHPF35.js"() {
16378
+ // ../../packages/core/dist/chunk-QBCR5ELA.js
16379
+ var CASE_TIMELINE_PAGE_MAX, caseTimelineQuery;
16380
+ var init_chunk_QBCR5ELA = __esm({
16381
+ "../../packages/core/dist/chunk-QBCR5ELA.js"() {
16209
16382
  "use strict";
16210
- init_chunk_HZ6CADSY();
16383
+ init_chunk_KYBVSEJ2();
16211
16384
  init_zod();
16212
- appMessageSenderType = external_exports.enum(["user", "team"]);
16213
- appMessageReceiverType = external_exports.enum(["user", "team", "agent", "assistant"]).transform((v) => v === "assistant" ? "agent" : v);
16214
- apiChannelMessage = external_exports.object({
16215
- text: clientOptionalString,
16216
- attachments: external_exports.array(messageAttachment).max(MAX_ATTACHMENTS_PER_MESSAGE).nullish().transform((v) => v ?? void 0)
16217
- }).refine((m) => m.text && m.text.length > 0 || m.attachments && m.attachments.length > 0, {
16218
- message: "message must have text or at least one attachment"
16219
- });
16220
- apiChannelMessageBody = external_exports.object({
16221
- // Correlation id (task hubs): new → new conversation, repeat → continue. min 1 so an
16222
- // empty string can't masquerade as a ref. Mutually exclusive with conversation_id.
16223
- external_ref: external_exports.string().min(1).max(256).optional(),
16224
- // Continue a specific WayAI conversation (authorized against the hub/channel + owner).
16225
- // UUID-validated here (unlike the app channel, whose client we control): allocation
16226
- // only treats a UUID-shaped id as a provided conversation, so a malformed id would
16227
- // otherwise skip the owner guard and silently MINT a new conversation instead of
16228
- // rejecting. A format 400 is shape-only — not an existence oracle (a valid-but-unknown
16229
- // UUID still collapses to the opaque authorization error downstream).
16230
- conversation_id: external_exports.string().uuid().optional(),
16231
- // On-behalf-of end-user identity. Absent → per-connection service principal (task-hub
16232
- // only; chat hub rejects with 422 in the route).
16233
- user: external_exports.object({
16234
- id: external_exports.string().min(1),
16235
- email: clientOptionalString,
16236
- name: clientOptionalString
16237
- }).optional(),
16238
- message: apiChannelMessage,
16239
- // Idempotency key: maps to channel_message_sid, deduped within one conversation
16240
- // (ConversationDO.storeMessage). A retried POST resolves to the same conversation (a chat
16241
- // hub's user, the external_ref, the conversation_id, or on a task hub with neither, this key
16242
- // scoped by the sender), so it echoes the original message_id and skips billing / turn
16243
- // dispatch. A failed store answers a retryable 503 only when this key is set; without it a
16244
- // retry could store the message twice, so it answers 400.
16245
- client_message_id: external_exports.string().min(1).max(256).optional()
16246
- }).refine((b) => !(b.external_ref && b.conversation_id), {
16247
- message: "provide external_ref or conversation_id, not both",
16248
- path: ["external_ref"]
16249
- });
16250
- appMessageBody = external_exports.object({
16251
- // Message content — three historical aliases. All optional: an attachment-only
16252
- // or voice-only message carries no text.
16253
- content: clientOptionalString,
16254
- message_text: clientOptionalString,
16255
- message_body: clientOptionalString,
16256
- // Conversation context. Ids are plain strings rather than `.uuid()` on purpose:
16257
- // they are AUTHORIZED downstream, which is the stronger guarantee — a well-formed
16258
- // uuid belonging to another tenant must fail just as hard as junk. `hub_id` is
16259
- // gated by `assertHubEndUserAccess` (gh #3286) and `conversation_id` by HubDO's
16260
- // conversation_index owner check (gh #2781, #3281). The route's own falsy guards
16261
- // ('hub_id is required') still reject an empty one.
16262
- hub_id: clientOptionalString,
16263
- channel_id: clientOptionalString,
16264
- conversation_id: clientOptionalString,
16265
- hub_type: external_exports.enum(["chat", "task"]).nullish().transform((v) => v ?? void 0),
16266
- // Stable idempotency key for one explicit task-hub launcher. HubDO scopes it
16267
- // to the authenticated user and resolves retries/tabs to one conversation.
16268
- task_start_id: external_exports.string().uuid().nullish().transform((v) => v ?? void 0),
16269
- // Routing.
16270
- sender_type: appMessageSenderType.nullish().transform((v) => v ?? void 0),
16271
- receiver_type: appMessageReceiverType.nullish().transform((v) => v ?? void 0),
16272
- // Only meaningful on a team send, where `validateAppTeamSendContext` proves the
16273
- // caller may send to this receiver. Absent on a team send to a conversation with no
16274
- // person, which names its `conversation_id` instead. The end-user branch ignores it —
16275
- // see the receiver derivation in the route.
16276
- user_receiver_id: clientOptionalString,
16277
- // ── Internal consult (consultant-agents PR 2 — H1.0) ──────────────────────
16278
- // A team member handling a customer conversation can tag a `consultant`-role
16279
- // agent for a PRIVATE, team-only exchange that never reaches the customer. A
16280
- // consult send is a team send with `receiver_type: 'agent'` targeting the
16281
- // consultant; `user_receiver_id` identifies the customer whose conversation this is
16282
- // (and is authorized by `validateAppTeamSendContext`, exactly as a team→user send is),
16283
- // and is absent, as on a team→user send, when the conversation has no person. The consultant is resolved from `agent_receiver_id`
16284
- // when supplied, else from an `@mention` parsed out of the message text against
16285
- // the hub's consultant agents. `consult_thread_id` continues an existing thread;
16286
- // absent, the route creates/reuses the single implicit thread. These fields are
16287
- // inert on every non-consult send (end-user send, team→user send).
16288
- agent_receiver_id: clientOptionalString,
16289
- consult_thread_id: clientOptionalString,
16290
- is_first_message: clientOptionalBoolean,
16291
- end_conversation: clientOptionalBoolean,
16292
- // Pre-generated by the client so the optimistic bubble and the stored row share
16293
- // a key (transcription live-updates land on the same row instead of duplicating).
16294
- message_id: clientOptionalString,
16295
- attachments: external_exports.array(messageAttachment).max(MAX_ATTACHMENTS_PER_MESSAGE).nullish().transform((v) => v ?? void 0),
16296
- // Base64-encoded audio for STT. Size-capped in the route (the cap is a byte
16297
- // budget tied to the /channels/* bodyLimit, not a shape rule).
16298
- audio_file: clientOptionalString
16299
- });
16300
- appMessageResponse = external_exports.object({
16301
- success: external_exports.boolean(),
16302
- message: external_exports.string(),
16303
- result: external_exports.object({
16304
- conversation_id: external_exports.string().optional(),
16305
- message_id: external_exports.string().optional(),
16306
- status: external_exports.string().optional(),
16307
- files: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).optional(),
16308
- // True when this request reused a task-start/message id already accepted by
16309
- // the server. Clients must replace their optimistic payload with a fresh
16310
- // authoritative read because another tab may have won with different text.
16311
- deduped: external_exports.boolean().optional()
16312
- }).optional()
16385
+ CASE_TIMELINE_PAGE_MAX = 100;
16386
+ caseTimelineQuery = casePageQuery.extend({
16387
+ limit: external_exports.coerce.number().int().min(1).max(CASE_TIMELINE_PAGE_MAX).optional()
16313
16388
  });
16314
16389
  }
16315
16390
  });
@@ -16381,12 +16456,23 @@ var init_chunk_YWZFB34T = __esm({
16381
16456
  }
16382
16457
  });
16383
16458
 
16384
- // ../../packages/core/dist/chunk-ZRQS7XQH.js
16459
+ // ../../packages/core/dist/chunk-Z3SV3XTC.js
16460
+ var caseAccessQuery;
16461
+ var init_chunk_Z3SV3XTC = __esm({
16462
+ "../../packages/core/dist/chunk-Z3SV3XTC.js"() {
16463
+ "use strict";
16464
+ init_chunk_HZ6CADSY();
16465
+ init_zod();
16466
+ caseAccessQuery = external_exports.object({ with_team_id: uuidSchema.optional() }).strict();
16467
+ }
16468
+ });
16469
+
16470
+ // ../../packages/core/dist/chunk-MVLW2KQB.js
16385
16471
  var CASE_ADJUSTMENT_REASON_MAX_LENGTH, CASE_ADJUSTMENT_DISPENSATION_KINDS, reason, activateCasePhaseBody, dispenseCaseBody, addCaseTaskBody, addCaseInputBody, caseOwnItemSchema, addCaseItemBody;
16386
- var init_chunk_ZRQS7XQH = __esm({
16387
- "../../packages/core/dist/chunk-ZRQS7XQH.js"() {
16472
+ var init_chunk_MVLW2KQB = __esm({
16473
+ "../../packages/core/dist/chunk-MVLW2KQB.js"() {
16388
16474
  "use strict";
16389
- init_chunk_KQSPA427();
16475
+ init_chunk_GKXAUKRL();
16390
16476
  init_chunk_HZ6CADSY();
16391
16477
  init_zod();
16392
16478
  CASE_ADJUSTMENT_REASON_MAX_LENGTH = 2e3;
@@ -16417,7 +16503,7 @@ var init_chunk_ZRQS7XQH = __esm({
16417
16503
  }
16418
16504
  });
16419
16505
 
16420
- // ../../packages/core/dist/chunk-QRAZ5PK7.js
16506
+ // ../../packages/core/dist/chunk-EPW6REOS.js
16421
16507
  function isCaseDueDate(value) {
16422
16508
  const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
16423
16509
  if (!match) return false;
@@ -16435,10 +16521,10 @@ function setCaseDeadlinesProblem(body) {
16435
16521
  return null;
16436
16522
  }
16437
16523
  var CASE_DUE_DATE_MIN_YEAR, CASE_DUE_DATE_MAX_YEAR, CASE_DEADLINES_PHASES_MAX, CASE_OVERDUE_CASES_MAX, caseDueDateSchema, setCaseDeadlinesShape, setCaseDeadlinesBody, setCaseTaskPlanBody, setCaseOwnerBody, caseOverdueQuery;
16438
- var init_chunk_QRAZ5PK7 = __esm({
16439
- "../../packages/core/dist/chunk-QRAZ5PK7.js"() {
16524
+ var init_chunk_EPW6REOS = __esm({
16525
+ "../../packages/core/dist/chunk-EPW6REOS.js"() {
16440
16526
  "use strict";
16441
- init_chunk_VHPMMK6K();
16527
+ init_chunk_KYBVSEJ2();
16442
16528
  init_chunk_HZ6CADSY();
16443
16529
  init_zod();
16444
16530
  CASE_DUE_DATE_MIN_YEAR = 2e3;
@@ -16466,52 +16552,6 @@ var init_chunk_QRAZ5PK7 = __esm({
16466
16552
  }
16467
16553
  });
16468
16554
 
16469
- // ../../packages/core/dist/chunk-YFDHUHJA.js
16470
- var CASE_RELATION_TYPE_CODE_PATTERN, CASE_RELATION_TYPE_CODE_MAX_LENGTH, CASE_RELATION_TYPE_NAME_MAX_LENGTH, CASE_RELATION_TYPES_PER_SPACE_MAX, CASE_RELATION_DESCRIPTION_MAX_LENGTH, CASE_RELATION_SIDES, CASE_EXTERNAL_SYSTEM_PATTERN, CASE_EXTERNAL_NUMBER_MAX_LENGTH, CASE_EXTERNAL_URL_MAX_LENGTH, trimmedName2, relationTypeFields, createCaseRelationTypeBody, updateCaseRelationTypeBody, relateCasesBody, addCaseExternalReferenceBody, caseRelationTypeParam, caseRelationParam, caseExternalReferenceParam, caseRelationTypesQuery;
16471
- var init_chunk_YFDHUHJA = __esm({
16472
- "../../packages/core/dist/chunk-YFDHUHJA.js"() {
16473
- "use strict";
16474
- init_chunk_5IQXVUZZ();
16475
- init_chunk_VHPMMK6K();
16476
- init_chunk_HZ6CADSY();
16477
- init_zod();
16478
- CASE_RELATION_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
16479
- CASE_RELATION_TYPE_CODE_MAX_LENGTH = 64;
16480
- CASE_RELATION_TYPE_NAME_MAX_LENGTH = 200;
16481
- CASE_RELATION_TYPES_PER_SPACE_MAX = 100;
16482
- CASE_RELATION_DESCRIPTION_MAX_LENGTH = 500;
16483
- CASE_RELATION_SIDES = ["origin", "destination"];
16484
- CASE_EXTERNAL_SYSTEM_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,30}$/;
16485
- CASE_EXTERNAL_NUMBER_MAX_LENGTH = 120;
16486
- CASE_EXTERNAL_URL_MAX_LENGTH = 2048;
16487
- trimmedName2 = external_exports.string().trim().min(1).max(CASE_RELATION_TYPE_NAME_MAX_LENGTH);
16488
- relationTypeFields = { name: trimmedName2, inverse_name: trimmedName2, active: external_exports.boolean().default(true) };
16489
- createCaseRelationTypeBody = external_exports.object({
16490
- code: external_exports.string().trim().max(CASE_RELATION_TYPE_CODE_MAX_LENGTH).regex(CASE_RELATION_TYPE_CODE_PATTERN),
16491
- ...relationTypeFields
16492
- }).strict();
16493
- updateCaseRelationTypeBody = external_exports.object({ ...relationTypeFields, expected_updated_at: timestampSchema.optional() }).strict();
16494
- relateCasesBody = external_exports.object({
16495
- relation_type_id: uuidSchema,
16496
- other_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN),
16497
- /** This case's side: `origin` reads the type's name ("continues"), `destination` its inverse. */
16498
- side: external_exports.enum(CASE_RELATION_SIDES).default("origin"),
16499
- description: external_exports.string().trim().min(1).max(CASE_RELATION_DESCRIPTION_MAX_LENGTH).nullable().default(null)
16500
- }).strict();
16501
- addCaseExternalReferenceBody = external_exports.object({
16502
- system: external_exports.string().trim().regex(CASE_EXTERNAL_SYSTEM_PATTERN),
16503
- number: external_exports.string().trim().min(1).max(CASE_EXTERNAL_NUMBER_MAX_LENGTH),
16504
- url: external_exports.string().trim().max(CASE_EXTERNAL_URL_MAX_LENGTH).url().refine((url) => url.startsWith("https://"), "An https link").nullable().default(null)
16505
- }).strict();
16506
- caseRelationTypeParam = caseSpaceParam.extend({ relation_type_id: uuidSchema });
16507
- caseRelationParam = caseRecordParam.extend({ relation_id: uuidSchema });
16508
- caseExternalReferenceParam = caseRecordParam.extend({ reference_id: uuidSchema });
16509
- caseRelationTypesQuery = casePageQuery.extend({
16510
- limit: external_exports.coerce.number().int().min(1).max(CASE_RELATION_TYPES_PER_SPACE_MAX).optional()
16511
- });
16512
- }
16513
- });
16514
-
16515
16555
  // ../../packages/core/dist/chunk-NVKU5PPQ.js
16516
16556
  var ADMIN_SKILL_NAME_REGEX, adminSkillNameParam;
16517
16557
  var init_chunk_NVKU5PPQ = __esm({
@@ -16675,7 +16715,7 @@ var init_chunk_OMPT4ZHR = __esm({
16675
16715
  }
16676
16716
  });
16677
16717
 
16678
- // ../../packages/core/dist/chunk-NWB4MECC.js
16718
+ // ../../packages/core/dist/chunk-5THT3WVS.js
16679
16719
  function refineScopedTarget(data, ctx) {
16680
16720
  if (data.scope === "org") {
16681
16721
  if (!data.org_id) {
@@ -16700,14 +16740,14 @@ function refineScopedTarget(data, ctx) {
16700
16740
  }
16701
16741
  }
16702
16742
  }
16703
- var adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, PRICING_PLAN_ID_RE, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, MAX_VOICE_CALL_MINUTE_OPS, voiceCallMinuteOps, AUTOMATION_GATE_EVALUATIONS_PER_OPERATION_BOUND, automationGateEvaluationsPerOperation, AUTOMATION_RUN_RETENTION_DAYS_MAX, automationRunRetentionDays, turnDeadlineSeconds, casesLimit, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetShape, adminScopedTargetBody, adminDryRunByDefaultTargetBody, WAYAI_HOST_TOKEN_TARGET_KINDS, WAYAI_HOST_TOKEN_MAX_TARGETS, adminClearWayaiHostTokensBody, BRANCHING_ORPHAN_ENTITY_TYPES, BRANCHING_ORPHAN_MAX_TARGETS, adminRepairBranchingOrphansBody, adminRepairLegacyOrgGrantsBody, adminRepairCompedPlansBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysBody, dataExplorerKvKeyBody, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteBody, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, dataExplorerDebugCountsDoType, dataExplorerDebugCountsParam, debugHubConvParam, debugMessageIdQuery;
16704
- var init_chunk_NWB4MECC = __esm({
16705
- "../../packages/core/dist/chunk-NWB4MECC.js"() {
16743
+ var adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, PRICING_PLAN_ID_RE, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, MAX_VOICE_CALL_MINUTE_OPS, voiceCallMinuteOps, AUTOMATION_GATE_EVALUATIONS_PER_OPERATION_BOUND, automationGateEvaluationsPerOperation, AUTOMATION_RUN_RETENTION_DAYS_MAX, automationRunRetentionDays, turnDeadlineSeconds, casesLimit, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetShape, adminScopedTargetBody, adminDryRunByDefaultTargetBody, WAYAI_HOST_TOKEN_TARGET_KINDS, WAYAI_HOST_TOKEN_MAX_TARGETS, adminClearWayaiHostTokensBody, BRANCHING_ORPHAN_ENTITY_TYPES, BRANCHING_ORPHAN_MAX_TARGETS, adminRepairBranchingOrphansBody, adminRepairLegacyOrgGrantsBody, adminRepairCredentialServicesBody, adminRepairCompedPlansBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysBody, dataExplorerKvKeyBody, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteBody, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, dataExplorerDebugCountsDoType, dataExplorerDebugCountsParam, debugHubConvParam, debugMessageIdQuery;
16744
+ var init_chunk_5THT3WVS = __esm({
16745
+ "../../packages/core/dist/chunk-5THT3WVS.js"() {
16706
16746
  "use strict";
16707
16747
  init_chunk_FECLIZTY();
16708
16748
  init_chunk_BFG4ZWR4();
16709
16749
  init_chunk_7VJ4SOFF();
16710
- init_chunk_5LACAGAY();
16750
+ init_chunk_L5KGJZQD();
16711
16751
  init_chunk_OMPT4ZHR();
16712
16752
  init_chunk_HZ6CADSY();
16713
16753
  init_chunk_MIWZOSPI();
@@ -16943,6 +16983,11 @@ var init_chunk_NWB4MECC = __esm({
16943
16983
  ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "scope=all must not include org_id", path: ["org_id"] });
16944
16984
  }
16945
16985
  });
16986
+ adminRepairCredentialServicesBody = external_exports.object({
16987
+ scope: external_exports.enum(["all", "org"]),
16988
+ org_id: external_exports.string().uuid().optional(),
16989
+ dry_run: external_exports.boolean().optional().default(true)
16990
+ }).strict().superRefine(refineScopedTarget);
16946
16991
  adminRepairCompedPlansBody = external_exports.object({
16947
16992
  org_id: external_exports.string().uuid().optional(),
16948
16993
  dry_run: external_exports.boolean().optional().default(true)
@@ -17495,83 +17540,86 @@ var init_chunk_B6PT7ZSX = __esm({
17495
17540
  var init_contracts = __esm({
17496
17541
  "../../packages/core/dist/contracts/index.js"() {
17497
17542
  "use strict";
17543
+ init_chunk_Q7KIQHAZ();
17544
+ init_chunk_NKLVUTFO();
17498
17545
  init_chunk_Q5M4VJ4W();
17499
17546
  init_chunk_YVY2TZK2();
17500
17547
  init_chunk_VXEAR36B();
17501
17548
  init_chunk_RACEDHG6();
17502
- init_chunk_Q7KIQHAZ();
17549
+ init_chunk_HIGKBEPF();
17503
17550
  init_chunk_HA7CRZMX();
17504
17551
  init_chunk_MF2VVXBR();
17505
17552
  init_chunk_IPXBFWUU();
17506
- init_chunk_NKLVUTFO();
17553
+ init_chunk_P5GJNS5R();
17554
+ init_chunk_BZVN5MG2();
17507
17555
  init_chunk_ZC6YGHNX();
17508
- init_chunk_HIGKBEPF();
17556
+ init_chunk_5DGHIY7L();
17557
+ init_chunk_HFEOIQF4();
17509
17558
  init_chunk_IPDOHAZ5();
17510
17559
  init_chunk_PFGVH2CX();
17511
17560
  init_chunk_WE4KMHZK();
17512
- init_chunk_P5GJNS5R();
17513
- init_chunk_5VGCQRPR();
17561
+ init_chunk_ZXK6N2HN();
17514
17562
  init_chunk_Y7CFCYX4();
17515
17563
  init_chunk_MGBAXT5Y();
17516
- init_chunk_5DGHIY7L();
17517
- init_chunk_2FWVCLBC();
17564
+ init_chunk_YUZFHVB2();
17565
+ init_chunk_I3O2RACG();
17518
17566
  init_chunk_CMRECH67();
17519
17567
  init_chunk_34LE6P7E();
17520
17568
  init_chunk_FPSDNS2E();
17521
- init_chunk_XPI4K6MX();
17522
- init_chunk_FN7WRXIP();
17523
- init_chunk_ZXK6N2HN();
17569
+ init_chunk_GBX5UNUO();
17570
+ init_chunk_U4FSUKVU();
17571
+ init_chunk_SY6PLCPK();
17524
17572
  init_chunk_KMAC3O3L();
17525
- init_chunk_YUZFHVB2();
17526
- init_chunk_I3O2RACG();
17573
+ init_chunk_KSTYTQ7I();
17574
+ init_chunk_LKBSHANA();
17527
17575
  init_chunk_FMB4KA3N();
17528
17576
  init_chunk_C4HEZ7ZI();
17529
17577
  init_chunk_IR2NOSI3();
17530
17578
  init_chunk_OPETF4GS();
17531
- init_chunk_SY6PLCPK();
17579
+ init_chunk_UCYWGWQT();
17580
+ init_chunk_YULHXJ5M();
17581
+ init_chunk_V4FRPRH5();
17532
17582
  init_chunk_LWMLR2WI();
17533
17583
  init_chunk_ACGAI25T();
17534
17584
  init_chunk_MH4O3YEX();
17535
17585
  init_chunk_WEV7ZGHP();
17536
- init_chunk_KSTYTQ7I();
17537
- init_chunk_LKBSHANA();
17586
+ init_chunk_7CYHPF35();
17538
17587
  init_chunk_NETRUHZF();
17539
- init_chunk_T65A4OFV();
17540
- init_chunk_EH45EEIA();
17541
- init_chunk_MFUQ2NQ5();
17542
- init_chunk_ACXXM7PI();
17588
+ init_chunk_RUFGXTXW();
17589
+ init_chunk_JSPSTJH4();
17590
+ init_chunk_XYKOUYXA();
17591
+ init_chunk_FQ6TZ2X4();
17543
17592
  init_chunk_2YEGUQR7();
17544
- init_chunk_SDOG6762();
17593
+ init_chunk_RLS7WBVR();
17545
17594
  init_chunk_JDJ4EUOL();
17546
- init_chunk_UCYWGWQT();
17547
17595
  init_chunk_6AYIXGDT();
17548
- init_chunk_YULHXJ5M();
17549
- init_chunk_V4FRPRH5();
17550
- init_chunk_YMNHLPJB();
17551
- init_chunk_OQMCZSR4();
17596
+ init_chunk_XCWEXZQE();
17597
+ init_chunk_N6SE35OR();
17598
+ init_chunk_5THMAK2R();
17599
+ init_chunk_AIBWYEMW();
17600
+ init_chunk_SE6YMSWN();
17552
17601
  init_chunk_IGLHT6YP();
17553
- init_chunk_5XV7YVGX();
17554
- init_chunk_7CYHPF35();
17602
+ init_chunk_7ULJTQXZ();
17603
+ init_chunk_QBCR5ELA();
17555
17604
  init_chunk_YWZFB34T();
17556
17605
  init_chunk_PZPOUXJR();
17557
17606
  init_chunk_LBDH7LCG();
17558
17607
  init_chunk_4LXDRTO4();
17559
17608
  init_chunk_E4DIIOOE();
17560
- init_chunk_ZRQS7XQH();
17561
- init_chunk_QRAZ5PK7();
17562
- init_chunk_YFDHUHJA();
17563
- init_chunk_5IQXVUZZ();
17564
- init_chunk_KQSPA427();
17609
+ init_chunk_Z3SV3XTC();
17610
+ init_chunk_MVLW2KQB();
17611
+ init_chunk_GKXAUKRL();
17565
17612
  init_chunk_FOFCV4SW();
17566
- init_chunk_VHPMMK6K();
17613
+ init_chunk_EPW6REOS();
17614
+ init_chunk_KYBVSEJ2();
17567
17615
  init_chunk_NVKU5PPQ();
17568
- init_chunk_NWB4MECC();
17616
+ init_chunk_5THT3WVS();
17569
17617
  init_chunk_FECLIZTY();
17570
17618
  init_chunk_BFG4ZWR4();
17571
17619
  init_chunk_7VJ4SOFF();
17572
- init_chunk_5LACAGAY();
17573
- init_chunk_D3EP4TDU();
17620
+ init_chunk_L5KGJZQD();
17574
17621
  init_chunk_X5PZZVTS();
17622
+ init_chunk_D3EP4TDU();
17575
17623
  init_chunk_PIZTARVG();
17576
17624
  init_chunk_OMPT4ZHR();
17577
17625
  init_chunk_2PZIF56U();
@@ -17583,7 +17631,7 @@ var init_contracts = __esm({
17583
17631
  init_chunk_UAOHHCW5();
17584
17632
  init_chunk_ULQGJUXZ();
17585
17633
  init_chunk_VYINA6YP();
17586
- init_chunk_EJRDF5B6();
17634
+ init_chunk_PC3774CE();
17587
17635
  init_chunk_SOJMWM63();
17588
17636
  init_chunk_MLNQUHG5();
17589
17637
  init_chunk_5FO3GNKP();
@@ -17747,7 +17795,7 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
17747
17795
  var init_dist = __esm({
17748
17796
  "../../packages/core/dist/index.js"() {
17749
17797
  "use strict";
17750
- init_chunk_EJRDF5B6();
17798
+ init_chunk_PC3774CE();
17751
17799
  init_chunk_SOJMWM63();
17752
17800
  init_chunk_MLNQUHG5();
17753
17801
  init_chunk_5FO3GNKP();
@@ -18792,9 +18840,9 @@ function entryFlagRefusal(command2, args2, dataNamespaces) {
18792
18840
  if (reads === void 0 || reads === "selectors") return null;
18793
18841
  return unreadArgumentRefusal(invocation, args2.slice(named - 1), reads, SPLITS_AT_FIRST_LONG_FLAG.has(command2));
18794
18842
  }
18795
- function isNewerVersion(latest, current) {
18843
+ function isNewerVersion(latest2, current) {
18796
18844
  const strip = (v) => v.replace(/[-+].*$/, "");
18797
- const l = strip(latest).split(".").map(Number);
18845
+ const l = strip(latest2).split(".").map(Number);
18798
18846
  const c = strip(current).split(".").map(Number);
18799
18847
  for (let i = 0; i < Math.max(l.length, c.length); i++) {
18800
18848
  const lv = l[i] ?? 0;
@@ -18994,9 +19042,11 @@ var init_utils = __esm({
18994
19042
  ["admin hubs repair-knowledge-blobs", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
18995
19043
  ["admin hubs clear-wayai-host-tokens", { positionals: 0, values: ["--org", "--hub", "--id"], dryRun: true }],
18996
19044
  ["admin orgs repair-legacy-grants", { positionals: 0, values: ["--org"], dryRun: true }],
19045
+ ["admin orgs repair-credential-services", { positionals: 0, values: ["--org"], dryRun: true }],
18997
19046
  ["admin vault import", { positionals: 0, values: ["--org", "--connector", "--max-puts", "--approved"] }],
18998
19047
  ["admin vault revert", { positionals: 0, values: ["--org", "--connector"] }],
18999
19048
  ["admin vault base-dry-run", { positionals: 0, values: ["--org", "--base", "--after"] }],
19049
+ ["admin vault mount-credential-count", { positionals: 0, values: ["--org", "--cursor"] }],
19000
19050
  ["admin harness mass-destroy", { positionals: 0, values: ["--org", "--hub"], dryRun: true }],
19001
19051
  ["admin harness disable", { positionals: 0 }],
19002
19052
  ["admin harness enable", { positionals: 0 }],
@@ -19545,6 +19595,11 @@ var init_api_client = __esm({
19545
19595
  async adminRepairLegacyOrgGrants(body) {
19546
19596
  return this.request("POST", "/api/admin/organizations/repair-legacy-grants", body);
19547
19597
  }
19598
+ // Name the service of each org credential created before credentials named one, from its live links (wayai#5644).
19599
+ // Used by `wayai admin orgs repair-credential-services` (platform-admin gated).
19600
+ async adminRepairCredentialServices(body) {
19601
+ return this.request("POST", "/api/admin/organizations/repair-credential-services", body);
19602
+ }
19548
19603
  // Read the platform config (platform-admin gated). Used by every `wayai admin <gate>
19549
19604
  // status` — grep `PlatformGate` in `commands/admin.ts` for the gates it serves.
19550
19605
  async adminGetConfig() {
@@ -20251,6 +20306,12 @@ var init_api_client = __esm({
20251
20306
  if (query.after) params.set("after", query.after);
20252
20307
  return this.request("GET", `/api/admin/data-explorer/debug/base-vault-dry-run?${params.toString()}`);
20253
20308
  }
20309
+ /** One page of the platform's S3 mount credential count: numbers per org, never a key. */
20310
+ async debugS3CredentialCount(query) {
20311
+ const params = new URLSearchParams({ org_id: query.org_id });
20312
+ if (query.cursor) params.set("cursor", query.cursor);
20313
+ return this.request("GET", `/api/admin/data-explorer/debug/s3-credential-count?${params.toString()}`);
20314
+ }
20254
20315
  async debugListAnalyticsTables() {
20255
20316
  return this.request("GET", "/api/admin/data-explorer/debug/analytics/tables");
20256
20317
  }
@@ -22133,11 +22194,11 @@ function buildSkillState() {
22133
22194
  }
22134
22195
  const version = lowestInstalledVersion(installs);
22135
22196
  const cached = readCachedLatest(SKILL_CACHE_FILE);
22136
- const latest = cached && version && isNewerVersion(cached, version) ? cached : null;
22197
+ const latest2 = cached && version && isNewerVersion(cached, version) ? cached : null;
22137
22198
  return {
22138
22199
  installed: true,
22139
22200
  version,
22140
- latest,
22201
+ latest: latest2,
22141
22202
  paths: installs.map((i) => i.path)
22142
22203
  };
22143
22204
  }
@@ -22983,9 +23044,9 @@ var init_pages2 = __esm({
22983
23044
  var init_evals = __esm({
22984
23045
  "../../packages/core/dist/contracts/evals.js"() {
22985
23046
  "use strict";
22986
- init_chunk_ACXXM7PI();
23047
+ init_chunk_FQ6TZ2X4();
22987
23048
  init_chunk_2YEGUQR7();
22988
- init_chunk_SDOG6762();
23049
+ init_chunk_RLS7WBVR();
22989
23050
  init_chunk_4LXDRTO4();
22990
23051
  init_chunk_MLNQUHG5();
22991
23052
  init_chunk_KB5RK3RP();
@@ -24011,17 +24072,17 @@ var init_hub_materializer = __esm({
24011
24072
  var init_ci = __esm({
24012
24073
  "../../packages/core/dist/contracts/ci.js"() {
24013
24074
  "use strict";
24014
- init_chunk_T65A4OFV();
24015
- init_chunk_EH45EEIA();
24016
- init_chunk_MFUQ2NQ5();
24017
- init_chunk_ACXXM7PI();
24075
+ init_chunk_RUFGXTXW();
24076
+ init_chunk_JSPSTJH4();
24077
+ init_chunk_XYKOUYXA();
24078
+ init_chunk_FQ6TZ2X4();
24018
24079
  init_chunk_2YEGUQR7();
24019
- init_chunk_SDOG6762();
24080
+ init_chunk_RLS7WBVR();
24020
24081
  init_chunk_LBDH7LCG();
24021
24082
  init_chunk_4LXDRTO4();
24022
- init_chunk_5LACAGAY();
24023
- init_chunk_D3EP4TDU();
24083
+ init_chunk_L5KGJZQD();
24024
24084
  init_chunk_X5PZZVTS();
24085
+ init_chunk_D3EP4TDU();
24025
24086
  init_chunk_PIZTARVG();
24026
24087
  init_chunk_3VHOXD5Y();
24027
24088
  init_chunk_MLNQUHG5();
@@ -24691,12 +24752,12 @@ function routeToSubtree(options) {
24691
24752
  }
24692
24753
  const repeated = repeatedFlagWithNoTargetRefusal(verb, tokens2);
24693
24754
  if (repeated) return { ok: false, refusal: repeated };
24694
- const empty = SUBTREE_FLAGS.find(({ flag: flag2, token }) => tokens2[token] === "" || tokens2.trailingFlag === flag2);
24695
- if (empty) {
24755
+ const empty2 = SUBTREE_FLAGS.find(({ flag: flag2, token }) => tokens2[token] === "" || tokens2.trailingFlag === flag2);
24756
+ if (empty2) {
24696
24757
  return {
24697
24758
  ok: false,
24698
- refusal: `\`wayai ${verb} ${empty.flag}\` needs ${empty.target}, and none followed it.
24699
- wayai ${verb} ${empty.flag} ${empty.value}`
24759
+ refusal: `\`wayai ${verb} ${empty2.flag}\` needs ${empty2.target}, and none followed it.
24760
+ wayai ${verb} ${empty2.flag} ${empty2.value}`
24700
24761
  };
24701
24762
  }
24702
24763
  const layout = gitRoot ? resolveLayout(gitRoot) : null;
@@ -30675,12 +30736,12 @@ async function useCommand(args2) {
30675
30736
  ].join("\n")
30676
30737
  );
30677
30738
  }
30678
- const add = addFlag !== void 0;
30739
+ const add2 = addFlag !== void 0;
30679
30740
  const selector = resolveScopeSelector("use", args2);
30680
30741
  if (!selector) throw expected(USAGE2);
30681
30742
  const { axis, id } = resolveScopeTarget(selector);
30682
30743
  const noun = axisNoun(axis);
30683
- if (add) {
30744
+ if (add2) {
30684
30745
  const widened = addToScope(axis, id);
30685
30746
  console.log(
30686
30747
  widened ? `Worktree scope widened \u2014 now ${describeAxis(axis, widened)}.` : `Worktree scope already includes ${noun} ${id}.`
@@ -38886,11 +38947,12 @@ var init_file_map = __esm({
38886
38947
  });
38887
38948
 
38888
38949
  // ../../packages/core/dist/contracts/vault-import.js
38889
- var VAULT_IMPORT_DEFAULT_PUTS, VAULT_IMPORT_MAX_PUTS, VAULT_IMPORT_MAX_APPROVED, vaultImportRunBody, vaultImportRevertBody, dryRunKey, dryRunCount, dryRunCounts, dryRunTable, baseVaultDryRunReport, BASE_VAULT_DRY_RUN_UNREADABLE, dryRunBaseId, baseVaultDryRunBase, BASE_VAULT_DRY_RUN_LISTINGS, baseVaultDryRunPage, baseVaultDryRunQuery;
38950
+ var VAULT_IMPORT_DEFAULT_PUTS, VAULT_IMPORT_MAX_PUTS, VAULT_IMPORT_MAX_APPROVED, vaultImportRunBody, vaultImportRevertBody, dryRunKey, dryRunCount, dryRunCounts, dryRunTable, baseVaultDryRunReport, BASE_VAULT_DRY_RUN_UNREADABLE, dryRunBaseId, baseVaultDryRunBase, BASE_VAULT_DRY_RUN_LISTINGS, baseVaultDryRunPage, baseVaultDryRunQuery, S3_CREDENTIAL_COUNT_PAGE_KEYS, s3CountInstant, s3CountCursor, s3CredentialCountOrg, s3CredentialCountPage, s3CredentialCountQuery;
38890
38951
  var init_vault_import = __esm({
38891
38952
  "../../packages/core/dist/contracts/vault-import.js"() {
38892
38953
  "use strict";
38893
38954
  init_chunk_HZ6CADSY();
38955
+ init_chunk_MIWZOSPI();
38894
38956
  init_zod();
38895
38957
  VAULT_IMPORT_DEFAULT_PUTS = 25;
38896
38958
  VAULT_IMPORT_MAX_PUTS = 100;
@@ -38937,6 +38999,29 @@ var init_vault_import = __esm({
38937
38999
  base_id: external_exports.string().regex(/^(?!\.\.?$)[A-Za-z0-9._-]{1,256}$/).optional(),
38938
39000
  after: dryRunBaseId.optional()
38939
39001
  }).refine((query) => !(query.base_id && query.after), { message: "base_id and after cannot be combined" });
39002
+ S3_CREDENTIAL_COUNT_PAGE_KEYS = 500;
39003
+ s3CountInstant = timestampSchema.refine(isIsoTimestamp).nullable();
39004
+ s3CountCursor = external_exports.string().min(1).max(4096);
39005
+ s3CredentialCountOrg = external_exports.strictObject({
39006
+ org_id: external_exports.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
39007
+ live: dryRunCount,
39008
+ expired: dryRunCount,
39009
+ no_expiry: dryRunCount,
39010
+ oldest_created_at: s3CountInstant,
39011
+ newest_created_at: s3CountInstant,
39012
+ last_expires_at: s3CountInstant
39013
+ });
39014
+ s3CredentialCountPage = external_exports.strictObject({
39015
+ listed: dryRunCount.max(S3_CREDENTIAL_COUNT_PAGE_KEYS),
39016
+ vanished: dryRunCount,
39017
+ unreadable: dryRunCount,
39018
+ orgs: external_exports.array(s3CredentialCountOrg).max(S3_CREDENTIAL_COUNT_PAGE_KEYS),
39019
+ next_cursor: s3CountCursor.nullable()
39020
+ });
39021
+ s3CredentialCountQuery = external_exports.object({
39022
+ org_id: uuidSchema,
39023
+ cursor: s3CountCursor.optional()
39024
+ });
38940
39025
  }
38941
39026
  });
38942
39027
 
@@ -39060,6 +39145,53 @@ var init_base_vault_dry_run = __esm({
39060
39145
  }
39061
39146
  });
39062
39147
 
39148
+ // src/lib/s3-credential-count.ts
39149
+ function add(into, from) {
39150
+ into.live += from.live;
39151
+ into.expired += from.expired;
39152
+ into.no_expiry += from.no_expiry;
39153
+ into.oldest_created_at = earliest(into.oldest_created_at, from.oldest_created_at);
39154
+ into.newest_created_at = latest(into.newest_created_at, from.newest_created_at);
39155
+ into.last_expires_at = latest(into.last_expires_at, from.last_expires_at);
39156
+ }
39157
+ function summarizeS3CredentialCount(input) {
39158
+ const orgs = /* @__PURE__ */ new Map();
39159
+ const total = { ...empty(), orgs: 0 };
39160
+ for (const row of input.pages.flatMap((page) => page.orgs)) {
39161
+ const into = orgs.get(row.org_id) ?? { org_id: row.org_id, ...empty() };
39162
+ orgs.set(row.org_id, into);
39163
+ add(into, row);
39164
+ add(total, row);
39165
+ }
39166
+ total.orgs = orgs.size;
39167
+ const nextCursor = input.pages.length === 0 ? input.resumedFrom ?? null : input.pages.at(-1).next_cursor;
39168
+ const sum = (field) => input.pages.reduce((n, page) => n + page[field], 0);
39169
+ const reasons = [];
39170
+ if (input.resumedFrom) reasons.push("resumed_from_cursor");
39171
+ if (nextCursor !== null) reasons.push("listing_truncated");
39172
+ if (input.stop) reasons.push(input.stop);
39173
+ return {
39174
+ complete: reasons.length === 0,
39175
+ incomplete_reasons: reasons,
39176
+ reads: input.pages.length,
39177
+ listed: sum("listed"),
39178
+ vanished: sum("vanished"),
39179
+ unreadable: sum("unreadable"),
39180
+ total,
39181
+ next_cursor: nextCursor,
39182
+ orgs: [...orgs.values()].sort((a, b) => a.org_id < b.org_id ? -1 : 1)
39183
+ };
39184
+ }
39185
+ var earliest, latest, empty;
39186
+ var init_s3_credential_count = __esm({
39187
+ "src/lib/s3-credential-count.ts"() {
39188
+ "use strict";
39189
+ earliest = (a, b) => a === null || b !== null && b < a ? b : a;
39190
+ latest = (a, b) => a === null || b !== null && b > a ? b : a;
39191
+ empty = () => ({ live: 0, expired: 0, no_expiry: 0, oldest_created_at: null, newest_created_at: null, last_expires_at: null });
39192
+ }
39193
+ });
39194
+
39063
39195
  // src/commands/admin.ts
39064
39196
  var admin_exports = {};
39065
39197
  __export(admin_exports, {
@@ -39268,6 +39400,9 @@ async function adminCommand(args2) {
39268
39400
  case "repair-legacy-grants":
39269
39401
  await runRepairLegacyOrgGrants(flagArgs);
39270
39402
  return;
39403
+ case "repair-credential-services":
39404
+ await runRepairCredentialServices(flagArgs);
39405
+ return;
39271
39406
  default:
39272
39407
  printHelp2();
39273
39408
  process.exit(1);
@@ -39288,6 +39423,9 @@ async function adminCommand(args2) {
39288
39423
  case "base-dry-run":
39289
39424
  await runVaultBaseDryRun(flagArgs);
39290
39425
  return;
39426
+ case "mount-credential-count":
39427
+ await runVaultS3CredentialCount(flagArgs);
39428
+ return;
39291
39429
  default:
39292
39430
  printHelp2();
39293
39431
  process.exit(1);
@@ -39836,9 +39974,9 @@ async function runRepairTeamOrphans(flagArgs) {
39836
39974
  console.log(`${d.hub_id} | ${d.dangling_team_ids.join(",")} | ${d.team_users_removed}`);
39837
39975
  }
39838
39976
  }
39839
- function parseApplyTargetFlags(flagArgs, usage3) {
39977
+ function parseApplyTargetFlags(flagArgs, usage3, opts = {}) {
39840
39978
  const apply = flagArgs.includes("--apply");
39841
- const target = parseScopedTargetFlags(flagArgs.filter((arg) => arg !== "--apply"), usage3);
39979
+ const target = parseScopedTargetFlags(flagArgs.filter((arg) => arg !== "--apply"), usage3, opts);
39842
39980
  if (apply && target.dryRun) {
39843
39981
  console.error("--apply and --dry-run contradict each other: a run is a dry run unless --apply is given.");
39844
39982
  console.error(usage3);
@@ -40168,6 +40306,26 @@ async function runVaultImport(flagArgs) {
40168
40306
  }
40169
40307
  printVaultReport(data);
40170
40308
  }
40309
+ async function readAdminPages(read, nextOf, start, paceMs = 0) {
40310
+ const pages = [];
40311
+ let cursor = start;
40312
+ do {
40313
+ if (pages.length > 0 && paceMs > 0) await new Promise((resolve13) => setTimeout(resolve13, paceMs));
40314
+ try {
40315
+ const page = await read(cursor);
40316
+ pages.push(page);
40317
+ cursor = nextOf(page) ?? void 0;
40318
+ } catch (err) {
40319
+ const limited = err instanceof ApiError && err.status === 429;
40320
+ if (pages.length === 0 && !limited) {
40321
+ exitOnApiError(err);
40322
+ throw err;
40323
+ }
40324
+ return { pages, stop: limited ? "rate_limited" : "request_failed" };
40325
+ }
40326
+ } while (cursor);
40327
+ return { pages };
40328
+ }
40171
40329
  async function runVaultBaseDryRun(flagArgs) {
40172
40330
  const USAGE8 = "wayai admin vault base-dry-run --org <org_id> [--base <base_id>] [--after <base_id>] [--json]";
40173
40331
  let orgId;
@@ -40194,24 +40352,11 @@ async function runVaultBaseDryRun(flagArgs) {
40194
40352
  }
40195
40353
  const { config, accessToken } = await requireAuth();
40196
40354
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
40197
- const pages = [];
40198
- let stop;
40199
- let cursor = after;
40200
- do {
40201
- try {
40202
- const { data } = await client.debugBaseVaultDryRun({ ...query.data, after: cursor });
40203
- pages.push(data);
40204
- cursor = data.next_after ?? void 0;
40205
- } catch (err) {
40206
- const limited = err instanceof ApiError && err.status === 429;
40207
- if (pages.length === 0 && !limited) {
40208
- exitOnApiError(err);
40209
- throw err;
40210
- }
40211
- stop = limited ? "rate_limited" : "request_failed";
40212
- break;
40213
- }
40214
- } while (cursor);
40355
+ const { pages, stop } = await readAdminPages(
40356
+ async (cursor) => (await client.debugBaseVaultDryRun({ ...query.data, after: cursor })).data,
40357
+ (page) => page.next_after,
40358
+ after
40359
+ );
40215
40360
  const summary = summarizeBaseVaultDryRun({ orgId: query.data.org_id, pages, resumedAfter: after, stop });
40216
40361
  const gotItsBase = summary.bases_read === 1 && summary.incomplete_reasons.every((reason2) => reason2 === "single_base");
40217
40362
  if (!summary.complete && !gotItsBase) process.exitCode = 1;
@@ -40235,6 +40380,56 @@ async function runVaultBaseDryRun(flagArgs) {
40235
40380
  if (base.status === "read") for (const line of nonZero(base.report)) console.log(` ${line}`);
40236
40381
  }
40237
40382
  }
40383
+ async function runVaultS3CredentialCount(flagArgs) {
40384
+ const USAGE8 = "wayai admin vault mount-credential-count --org <org_id> [--cursor <cursor>] [--json]";
40385
+ let orgId;
40386
+ let cursor;
40387
+ let jsonOutput = false;
40388
+ for (let i = 0; i < flagArgs.length; i++) {
40389
+ const flag = flagArgs[i];
40390
+ if (flag === "--org") orgId = requireFlagValue(flagArgs, ++i, "--org");
40391
+ else if (flag === "--cursor") cursor = requireFlagValue(flagArgs, ++i, "--cursor");
40392
+ else if (flag === "--json") jsonOutput = true;
40393
+ else {
40394
+ console.error(`Unknown flag: ${flag}`);
40395
+ console.error(USAGE8);
40396
+ process.exit(1);
40397
+ }
40398
+ }
40399
+ const query = s3CredentialCountQuery.safeParse({ org_id: orgId, cursor });
40400
+ if (!query.success) {
40401
+ console.error("--org must be an organization id, and --cursor the cursor a run printed.");
40402
+ console.error(USAGE8);
40403
+ process.exit(1);
40404
+ }
40405
+ const { config, accessToken } = await requireAuth();
40406
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
40407
+ const { pages, stop } = await readAdminPages(
40408
+ async (next) => (await client.debugS3CredentialCount({ org_id: query.data.org_id, cursor: next })).data,
40409
+ (page) => page.next_cursor,
40410
+ cursor,
40411
+ MOUNT_CREDENTIAL_COUNT_PACE_MS
40412
+ );
40413
+ const summary = summarizeS3CredentialCount({ pages, resumedFrom: cursor, stop });
40414
+ if (!summary.complete) process.exitCode = 1;
40415
+ if (jsonOutput) {
40416
+ console.log(JSON.stringify(summary, null, 2));
40417
+ return;
40418
+ }
40419
+ const { total } = summary;
40420
+ console.log(`S3 credential count \u2014 every org \u2014 ${summary.complete ? "complete" : `INCOMPLETE, not the platform's total (${summary.incomplete_reasons.join(", ")})`}`);
40421
+ console.log(`reads: ${summary.reads} of the 120/hour cap`);
40422
+ console.log(`keys: listed ${summary.listed}, gone by their read ${summary.vanished}, with no org ${summary.unreadable}`);
40423
+ console.log(`live: ${total.live} in ${total.orgs} org(s); expired, not yet evicted: ${total.expired}; with no expiry: ${total.no_expiry}`);
40424
+ const lastExpiry = (counts) => counts.no_expiry > 0 ? `never: ${counts.no_expiry} hold no expiry` : counts.last_expires_at ?? "never";
40425
+ if (total.live > 0) console.log(`created ${total.oldest_created_at ?? "?"} to ${total.newest_created_at ?? "?"}; the last expires ${lastExpiry(total)}`);
40426
+ if (stop || summary.next_cursor) {
40427
+ console.log(summary.next_cursor ? `To continue: --cursor ${summary.next_cursor}` : "Nothing read past the start; re-run later.");
40428
+ }
40429
+ for (const row of summary.orgs) {
40430
+ console.log(`${row.org_id}: live ${row.live}, expired ${row.expired}, no expiry ${row.no_expiry}, created ${row.oldest_created_at ?? "?"} to ${row.newest_created_at ?? "?"}, last expires ${lastExpiry(row)}`);
40431
+ }
40432
+ }
40238
40433
  async function runVaultRevert(flagArgs) {
40239
40434
  const USAGE8 = "wayai admin vault revert --org <org_id> --connector <connector_id> [--apply] [--yes] [--json]";
40240
40435
  const { orgId, connectorId, apply, yes, jsonOutput } = parseVaultFlags(flagArgs, USAGE8, false);
@@ -40406,6 +40601,51 @@ async function runRepairLegacyOrgGrants(flagArgs) {
40406
40601
  console.log(`${d.org_id} | ${d.user_email} | ${d.action} | ${d.user_id ?? "-"} | ${d.reason ?? "-"}`);
40407
40602
  }
40408
40603
  }
40604
+ async function runRepairCredentialServices(flagArgs) {
40605
+ const USAGE8 = "wayai admin orgs repair-credential-services --all | --org <org_id> [--apply] [--yes] [--json]";
40606
+ const scoped = parseApplyTargetFlags(flagArgs, USAGE8, { scopes: ["all", "org"], allLabel: "ALL organizations (platform-wide)" });
40607
+ const { targetLabel, apply, yes, jsonOutput } = scoped;
40608
+ const body = scoped.body.scope === "org" ? { scope: "org", org_id: scoped.body.org_id, dry_run: !apply } : { scope: "all", dry_run: !apply };
40609
+ if (apply && !yes && !jsonOutput) {
40610
+ console.log(`About to NAME the service of unnamed org credentials in: ${targetLabel}.`);
40611
+ console.log("A named credential links only to connections of that service, for its life. Run without --apply first to see each one.");
40612
+ const ok = await confirm("Proceed?");
40613
+ if (!ok) {
40614
+ console.log("Aborted.");
40615
+ return;
40616
+ }
40617
+ }
40618
+ const { config, accessToken } = await requireAuth();
40619
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
40620
+ let response;
40621
+ try {
40622
+ response = await client.adminRepairCredentialServices(body);
40623
+ } catch (err) {
40624
+ exitOnApiError(err);
40625
+ throw err;
40626
+ }
40627
+ const data = response.data;
40628
+ if (jsonOutput) {
40629
+ console.log(JSON.stringify(data, null, 2));
40630
+ return;
40631
+ }
40632
+ const mode = data.dry_run ? "DRY RUN \u2014 nothing written" : "written";
40633
+ console.log(
40634
+ `repair-credential-services (${data.scope}) \u2014 ${mode}: orgs_scanned=${data.orgs_scanned} named=${data.named} would_name=${data.would_name} skipped=${data.skipped} failed=${data.failed}`
40635
+ );
40636
+ if (data.orgs_errored > 0 || data.failed > 0) {
40637
+ console.log(`WARNING: ${data.orgs_errored} org(s) could not be read and ${data.failed} write(s) failed \u2014 re-run to cover them.`);
40638
+ }
40639
+ if (data.results.length === 0) {
40640
+ console.log("(no unnamed API Key or Bearer Token org credentials in scope)");
40641
+ return;
40642
+ }
40643
+ for (const r of data.results) {
40644
+ const service = r.connector_id ? ` ${r.connector_name ?? r.connector_id} (${r.connector_id})` : "";
40645
+ const reason2 = r.reason ? ` (${r.reason})` : "";
40646
+ console.log(` org=${r.org_id} credential=${r.credential_id} ${r.credential_type}: ${r.outcome}${service}${reason2} linked=[${r.linked_connector_ids.join(", ")}]`);
40647
+ }
40648
+ }
40409
40649
  async function runHarnessMassDestroy(flagArgs) {
40410
40650
  const USAGE8 = "wayai admin harness mass-destroy --all | --org <org_id> | --hub <hub_id> [--dry-run] [--yes] [--json]";
40411
40651
  const { body, targetLabel, dryRun, yes, jsonOutput } = parseScopedTargetFlags(flagArgs, USAGE8);
@@ -41582,6 +41822,9 @@ Usage:
41582
41822
  wayai admin orgs repair-legacy-grants --all | --org <org_id> [--dry-run] [--yes] [--json]
41583
41823
  Repair org-admin roster rows keyed by email with a NULL user_email (pre-#3922 platform-admin adds): grant the real access they never conferred, or drop the phantom seat. Idempotent \u2014 run --dry-run first
41584
41824
 
41825
+ wayai admin orgs repair-credential-services --all | --org <org_id> [--apply] [--yes] [--json]
41826
+ Name the service of each API Key or Bearer Token org credential created before credentials named one, from its live links (#5644), so a push can pick it again; a credential whose links show no one service, or of a service another credential is already named for, is left unnamed with its reason. A dry run by default; --apply writes. Idempotent
41827
+
41585
41828
  wayai admin vault import --org <org_id> --connector <connector_id> [--max-puts <n>] [--approved <dry-run.json>] [--apply] [--yes] [--json]
41586
41829
  Move one org's stored credentials of one connector into the credentials vault, no re-entry (#5644). A dry run by default (counts by field, link kind and form); --apply needs the connector's gate open, puts each distinct value once for the direct rows holding it, moves each org credential with the rows it supplies when all of them may move (else names why it stays), and keeps the old ciphertext 30 days for revert. Re-run until values_remaining and credentials_remaining are 0. Lists Telegram bots to enable again. WhatsApp and Instagram: trims each token as a send does (rows counted), puts it with its expiry, and counts the legacy api_key rows that stay. REST API, External Resources, MCP Server: prints each value's derived policy or why it stays and counts the connections; --apply moves only what --approved (the reviewed dry run's --json) lists, keeping the old ciphertext 7 days
41587
41830
 
@@ -41625,6 +41868,8 @@ Usage:
41625
41868
 
41626
41869
  wayai admin vault base-dry-run --org <org_id> [--base <base_id>] [--after <base_id>] [--json]
41627
41870
  What moving an org's base secrets to the vault would do: counts and reason codes per base, and the sum over the bases read. Reads only. One read per 50 bases (or one for --base), one sleeping base woken per base read: by hand, never scheduled. Marks and exits non-zero on any partial result (a base unreadable, the budget hit, a resumed run)
41871
+ wayai admin vault mount-credential-count --org <org_id> [--cursor <cursor>] [--json]
41872
+ How many S3 mount credentials every org holds: live, expired, with no expiry, and when created. Counts only, never a key. --org is the org the read is attested under. One read per 500 credentials: by hand, never scheduled. Marks and exits non-zero on any partial result
41628
41873
 
41629
41874
  wayai admin vault-gate status [--json] Print the connectors whose new credentials go to the credentials vault
41630
41875
  wayai admin vault-gate add <connector> [--yes] [--json]
@@ -41697,7 +41942,7 @@ Sources:
41697
41942
  binding, and a seed recording none is deleted; a production row goes only once
41698
41943
  no preview maps it and nothing points at it, and a production tool pointing at
41699
41944
  it (tool:<id>, listed under the row) can be named first to free it.
41700
- orgs Org roster repair. \`repair-legacy-grants\` fixes member_grant rows the
41945
+ orgs Org repairs. \`repair-legacy-grants\` fixes member_grant rows the
41701
41946
  platform-admin org-admin add wrote before #3922: the email landed in the
41702
41947
  user_id column with user_email NULL. Auth reads UserDO, never member_grant,
41703
41948
  so the row grants NOTHING \u2014 while still counting as a seat, which refuses
@@ -41707,6 +41952,14 @@ Sources:
41707
41952
  access, or dropped when no account matches. A repaired row is a REAL grant
41708
41953
  to a real person and sends no email, so read --dry-run output as the list of
41709
41954
  people about to get access. Idempotent.
41955
+ \`repair-credential-services\` names the service of each API Key or Bearer
41956
+ Token org credential created before credentials named one (#5644), from the
41957
+ connectors of the connections it is linked to: a push links a new connection
41958
+ only to a credential named for its service. A credential linked to more than
41959
+ one service, to none, to a REST API, External Resources, MCP Server or Base
41960
+ Toolset connection, or into a base, or of a service another credential is
41961
+ already named for, stays unnamed with its reason. It reports by default and
41962
+ writes only with --apply.
41710
41963
 
41711
41964
  harness Incident response for harness agents. \`disable\`/\`enable\` flip the single
41712
41965
  PLATFORM-wide harness_enabled flag; \`status\` prints it. That one flag both
@@ -41775,6 +42028,8 @@ Examples:
41775
42028
  wayai admin hubs clear-wayai-host-tokens --org <org-id> --id toolset:<connection-id> --id credential:<credential-id> --apply
41776
42029
  wayai admin orgs repair-legacy-grants --all --dry-run
41777
42030
  wayai admin orgs repair-legacy-grants --org <org-id> --yes
42031
+ wayai admin orgs repair-credential-services --all
42032
+ wayai admin orgs repair-credential-services --org <org-id> --apply
41778
42033
  wayai admin harness disable
41779
42034
  wayai admin harness mass-destroy --all --dry-run
41780
42035
  wayai admin harness mass-destroy --hub <hub-id> --yes
@@ -41786,7 +42041,7 @@ Audit + rate limit:
41786
42041
  across all sources. Platform-admin grant required.
41787
42042
  `.trim());
41788
42043
  }
41789
- var VALID_TYPES, VALID_ANALYTICS_TABLES, HARNESS_GATE, VOICE_CALLS_GATE, THREADS_GATE, COMMUNITIES_GATE, CASES_GATE, PLATFORM_CONFIG_PROPAGATION_NOTE, VAULT_GATE_CONNECTORS, VAULT_GATE_BY_ID_ONLY, VALID_NOTICE_SEVERITIES;
42044
+ var VALID_TYPES, VALID_ANALYTICS_TABLES, MOUNT_CREDENTIAL_COUNT_PACE_MS, HARNESS_GATE, VOICE_CALLS_GATE, THREADS_GATE, COMMUNITIES_GATE, CASES_GATE, PLATFORM_CONFIG_PROPAGATION_NOTE, VAULT_GATE_CONNECTORS, VAULT_GATE_BY_ID_ONLY, VALID_NOTICE_SEVERITIES;
41790
42045
  var init_admin = __esm({
41791
42046
  "src/commands/admin.ts"() {
41792
42047
  "use strict";
@@ -41803,8 +42058,10 @@ var init_admin = __esm({
41803
42058
  init_vault_import();
41804
42059
  init_vault();
41805
42060
  init_base_vault_dry_run();
42061
+ init_s3_credential_count();
41806
42062
  VALID_TYPES = dataExplorerDebugDoType.options;
41807
42063
  VALID_ANALYTICS_TABLES = dataExplorerDebugAnalyticsTable.options;
42064
+ MOUNT_CREDENTIAL_COUNT_PACE_MS = 12500;
41808
42065
  HARNESS_GATE = {
41809
42066
  group: "harness",
41810
42067
  key: "harness_enabled",
@@ -41878,8 +42135,8 @@ var init_admin = __esm({
41878
42135
  });
41879
42136
 
41880
42137
  // src/lib/version-status.ts
41881
- function componentStatus(current, latest) {
41882
- return { current, latest, behind: Boolean(current && latest && isNewerVersion(latest, current)) };
42138
+ function componentStatus(current, latest2) {
42139
+ return { current, latest: latest2, behind: Boolean(current && latest2 && isNewerVersion(latest2, current)) };
41883
42140
  }
41884
42141
  function resolveVersionStatus(cliVersion) {
41885
42142
  const cliLatest = readVersionCache(CLI_CACHE_FILE)?.latest ?? null;
@@ -42311,18 +42568,18 @@ async function updateCommand(pkg2) {
42311
42568
  console.log(`Current version: ${pkg2.version}`);
42312
42569
  console.log("Checking for updates...");
42313
42570
  try {
42314
- const latest = execSync("npm view @wayai/cli version", {
42571
+ const latest2 = execSync("npm view @wayai/cli version", {
42315
42572
  timeout: 1e4
42316
42573
  }).toString().trim();
42317
- if (latest === pkg2.version) {
42574
+ if (latest2 === pkg2.version) {
42318
42575
  console.log(`Already on the latest version (${pkg2.version}).`);
42319
42576
  } else {
42320
- console.log(`Updating ${pkg2.version} \u2192 ${latest}...`);
42577
+ console.log(`Updating ${pkg2.version} \u2192 ${latest2}...`);
42321
42578
  execSync("npm install -g @wayai/cli@latest", {
42322
42579
  timeout: 6e4,
42323
42580
  stdio: "inherit"
42324
42581
  });
42325
- console.log(`Updated to ${latest}.`);
42582
+ console.log(`Updated to ${latest2}.`);
42326
42583
  }
42327
42584
  } catch (err) {
42328
42585
  captureException2(err);
@@ -44968,10 +45225,10 @@ function refreshCliCache() {
44968
45225
  return new Promise((resolve13) => {
44969
45226
  exec("npm view @wayai/cli version", { timeout: REFRESH_TIMEOUT_MS }, (err, stdout) => {
44970
45227
  if (!err) {
44971
- const latest = stdout.trim();
44972
- if (latest) {
45228
+ const latest2 = stdout.trim();
45229
+ if (latest2) {
44973
45230
  try {
44974
- writeVersionCache(CLI_CACHE_FILE, { lastCheck: Date.now(), latest });
45231
+ writeVersionCache(CLI_CACHE_FILE, { lastCheck: Date.now(), latest: latest2 });
44975
45232
  } catch {
44976
45233
  }
44977
45234
  }
@@ -44987,10 +45244,10 @@ async function refreshSkillCache() {
44987
45244
  try {
44988
45245
  const res = await fetch(url, { signal: controller.signal });
44989
45246
  if (res.ok) {
44990
- const latest = parseFrontmatterVersion(await res.text());
44991
- if (latest) {
45247
+ const latest2 = parseFrontmatterVersion(await res.text());
45248
+ if (latest2) {
44992
45249
  try {
44993
- writeVersionCache(SKILL_CACHE_FILE, { lastCheck: Date.now(), latest });
45250
+ writeVersionCache(SKILL_CACHE_FILE, { lastCheck: Date.now(), latest: latest2 });
44994
45251
  } catch {
44995
45252
  }
44996
45253
  }
@@ -45020,10 +45277,10 @@ async function fetchAndCacheAdminSkillVersion() {
45020
45277
  const accessToken = await getAccessToken2(config);
45021
45278
  const client = new ApiClient2({ apiUrl: config.api_url, accessToken });
45022
45279
  const res = await client.adminSkillInstall(ADMIN_SKILL_NAME);
45023
- const latest = parseFrontmatterVersion(res.files[SKILL_FILENAME] ?? "");
45024
- if (latest) {
45280
+ const latest2 = parseFrontmatterVersion(res.files[SKILL_FILENAME] ?? "");
45281
+ if (latest2) {
45025
45282
  try {
45026
- writeVersionCache(ADMIN_SKILL_CACHE_FILE, { lastCheck: Date.now(), latest });
45283
+ writeVersionCache(ADMIN_SKILL_CACHE_FILE, { lastCheck: Date.now(), latest: latest2 });
45027
45284
  } catch {
45028
45285
  }
45029
45286
  }