@wayai/cli 0.3.256 → 0.3.257

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
@@ -16,44 +16,44 @@ var __export = (target, all) => {
16
16
  };
17
17
 
18
18
  // src/lib/mask-secrets.ts
19
- function valueEnd(text3, from, isEnd) {
20
- for (let i = from; i < text3.length; i++) {
21
- if (text3[i] === "\\") {
19
+ function valueEnd(text4, from, isEnd) {
20
+ for (let i = from; i < text4.length; i++) {
21
+ if (text4[i] === "\\") {
22
22
  i++;
23
23
  continue;
24
24
  }
25
- if (isEnd(text3[i])) return i;
25
+ if (isEnd(text4[i])) return i;
26
26
  }
27
- return text3.length;
27
+ return text4.length;
28
28
  }
29
- function maskCredentialValues(text3, keyRe, resolveValueEnd) {
29
+ function maskCredentialValues(text4, keyRe, resolveValueEnd) {
30
30
  keyRe.lastIndex = 0;
31
31
  let out = "";
32
32
  let copied = 0;
33
33
  let match;
34
- while ((match = keyRe.exec(text3)) !== null) {
34
+ while ((match = keyRe.exec(text4)) !== null) {
35
35
  const valueStart = match.index + match[0].length;
36
36
  keyRe.lastIndex = valueStart;
37
37
  if (!isCredentialKey(match[1])) continue;
38
- const end = resolveValueEnd(text3, valueStart);
39
- const value = text3.slice(valueStart, end);
38
+ const end = resolveValueEnd(text4, valueStart);
39
+ const value = text4.slice(valueStart, end);
40
40
  if (value.length === 0 || FULLY_MASKED_VALUE_RE.test(value)) continue;
41
- out += text3.slice(copied, valueStart) + "[REDACTED]";
41
+ out += text4.slice(copied, valueStart) + "[REDACTED]";
42
42
  copied = end;
43
43
  keyRe.lastIndex = end;
44
44
  }
45
- return out + text3.slice(copied);
45
+ return out + text4.slice(copied);
46
46
  }
47
- function maskJwts(text3) {
47
+ function maskJwts(text4) {
48
48
  let out = "";
49
49
  let copied = 0;
50
50
  let cursor = 0;
51
- while (cursor < text3.length) {
52
- while (cursor < text3.length && !isBase64UrlChar(text3[cursor])) cursor++;
51
+ while (cursor < text4.length) {
52
+ while (cursor < text4.length && !isBase64UrlChar(text4[cursor])) cursor++;
53
53
  const headerStart = cursor;
54
54
  let tokenStart = -1;
55
- while (cursor < text3.length && isBase64UrlChar(text3[cursor])) {
56
- if (tokenStart < 0 && text3[cursor] === "e" && text3[cursor + 1] === "y" && text3[cursor + 2] === "J") {
55
+ while (cursor < text4.length && isBase64UrlChar(text4[cursor])) {
56
+ if (tokenStart < 0 && text4[cursor] === "e" && text4[cursor + 1] === "y" && text4[cursor + 2] === "J") {
57
57
  tokenStart = cursor;
58
58
  }
59
59
  cursor++;
@@ -61,28 +61,28 @@ function maskJwts(text3) {
61
61
  const headerEnd = cursor;
62
62
  if (headerStart === headerEnd) continue;
63
63
  const hasJwtHeader = tokenStart >= headerStart && tokenStart + 3 < headerEnd;
64
- if (!hasJwtHeader || text3[headerEnd] !== ".") continue;
64
+ if (!hasJwtHeader || text4[headerEnd] !== ".") continue;
65
65
  const payloadStart = headerEnd + 1;
66
66
  cursor = payloadStart;
67
- while (cursor < text3.length && isBase64UrlChar(text3[cursor])) cursor++;
67
+ while (cursor < text4.length && isBase64UrlChar(text4[cursor])) cursor++;
68
68
  const payloadEnd = cursor;
69
- if (payloadEnd === payloadStart || text3[payloadEnd] !== ".") continue;
69
+ if (payloadEnd === payloadStart || text4[payloadEnd] !== ".") continue;
70
70
  const signatureStart = payloadEnd + 1;
71
71
  cursor = signatureStart;
72
- while (cursor < text3.length && isBase64UrlChar(text3[cursor])) cursor++;
72
+ while (cursor < text4.length && isBase64UrlChar(text4[cursor])) cursor++;
73
73
  if (cursor === signatureStart) continue;
74
- out += text3.slice(copied, tokenStart) + "[REDACTED_JWT]";
74
+ out += text4.slice(copied, tokenStart) + "[REDACTED_JWT]";
75
75
  copied = cursor;
76
76
  }
77
- return out + text3.slice(copied);
77
+ return out + text4.slice(copied);
78
78
  }
79
- function jsonContainerEnd(text3, from) {
80
- const opener = text3[from];
79
+ function jsonContainerEnd(text4, from) {
80
+ const opener = text4[from];
81
81
  if (opener !== "{" && opener !== "[") return null;
82
82
  const stack = [opener];
83
83
  let inString = false;
84
- for (let i = from + 1; i < text3.length; i++) {
85
- const char = text3[i];
84
+ for (let i = from + 1; i < text4.length; i++) {
85
+ const char = text4[i];
86
86
  if (inString) {
87
87
  if (char === "\\") {
88
88
  i++;
@@ -103,62 +103,62 @@ function jsonContainerEnd(text3, from) {
103
103
  }
104
104
  return null;
105
105
  }
106
- function jsonNumberEnd(text3, from) {
107
- const match = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(text3.slice(from));
106
+ function jsonNumberEnd(text4, from) {
107
+ const match = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(text4.slice(from));
108
108
  if (!match) return null;
109
109
  const end = from + match[0].length;
110
110
  let next = end;
111
- while (next < text3.length && /\s/.test(text3[next])) next++;
112
- return next === text3.length || text3[next] === "," || text3[next] === "}" || text3[next] === "]" ? end : null;
111
+ while (next < text4.length && /\s/.test(text4[next])) next++;
112
+ return next === text4.length || text4[next] === "," || text4[next] === "}" || text4[next] === "]" ? end : null;
113
113
  }
114
- function maskJsonCredentialValues(text3) {
114
+ function maskJsonCredentialValues(text4) {
115
115
  JSON_KEY_RE.lastIndex = 0;
116
116
  let out = "";
117
117
  let copied = 0;
118
118
  let match;
119
- while ((match = JSON_KEY_RE.exec(text3)) !== null) {
119
+ while ((match = JSON_KEY_RE.exec(text4)) !== null) {
120
120
  const valueStart = match.index + match[0].length;
121
121
  JSON_KEY_RE.lastIndex = valueStart;
122
122
  const key = match[1];
123
123
  const isNumericCredentialKey = NUMERIC_CREDENTIAL_KEY_RE.test(key);
124
124
  if (!isCredentialKey(key) && !isNumericCredentialKey) continue;
125
- if (text3[valueStart] === '"') {
125
+ if (text4[valueStart] === '"') {
126
126
  const contentStart = valueStart + 1;
127
- const end = valueEnd(text3, contentStart, isJsonValueEnd);
128
- const value = text3.slice(contentStart, end);
127
+ const end = valueEnd(text4, contentStart, isJsonValueEnd);
128
+ const value = text4.slice(contentStart, end);
129
129
  if (value.length === 0 || FULLY_MASKED_VALUE_RE.test(value)) continue;
130
- out += text3.slice(copied, contentStart) + "[REDACTED]";
130
+ out += text4.slice(copied, contentStart) + "[REDACTED]";
131
131
  copied = end;
132
132
  JSON_KEY_RE.lastIndex = end;
133
133
  continue;
134
134
  }
135
- if (text3[valueStart] === "{" || text3[valueStart] === "[") {
136
- const end = jsonContainerEnd(text3, valueStart) ?? text3.length;
137
- out += text3.slice(copied, valueStart) + '"[REDACTED]"';
135
+ if (text4[valueStart] === "{" || text4[valueStart] === "[") {
136
+ const end = jsonContainerEnd(text4, valueStart) ?? text4.length;
137
+ out += text4.slice(copied, valueStart) + '"[REDACTED]"';
138
138
  copied = end;
139
139
  JSON_KEY_RE.lastIndex = end;
140
140
  continue;
141
141
  }
142
142
  if (isNumericCredentialKey) {
143
- const end = jsonNumberEnd(text3, valueStart);
143
+ const end = jsonNumberEnd(text4, valueStart);
144
144
  if (end !== null) {
145
- out += text3.slice(copied, valueStart) + '"[REDACTED]"';
145
+ out += text4.slice(copied, valueStart) + '"[REDACTED]"';
146
146
  copied = end;
147
147
  JSON_KEY_RE.lastIndex = end;
148
148
  }
149
149
  }
150
150
  }
151
- return out + text3.slice(copied);
151
+ return out + text4.slice(copied);
152
152
  }
153
- function headerValueEnd(text3, from) {
154
- for (let i = from; i < text3.length; i++) {
155
- const char = text3[i];
153
+ function headerValueEnd(text4, from) {
154
+ for (let i = from; i < text4.length; i++) {
155
+ const char = text4[i];
156
156
  if (char === "\r" || char === "\n") return i;
157
157
  if (char === "\\") {
158
158
  let afterSlashes = i;
159
- while (text3[afterSlashes] === "\\") afterSlashes++;
159
+ while (text4[afterSlashes] === "\\") afterSlashes++;
160
160
  const slashCount = afterSlashes - i;
161
- if (slashCount % 2 === 1 && (text3[afterSlashes] === "r" || text3[afterSlashes] === "n")) {
161
+ if (slashCount % 2 === 1 && (text4[afterSlashes] === "r" || text4[afterSlashes] === "n")) {
162
162
  return i;
163
163
  }
164
164
  if (slashCount % 2 === 1) afterSlashes++;
@@ -167,16 +167,16 @@ function headerValueEnd(text3, from) {
167
167
  }
168
168
  if (char === '"') {
169
169
  let next = i + 1;
170
- while (next < text3.length && /\s/.test(text3[next])) next++;
171
- if (next === text3.length || text3[next] === "," || text3[next] === "}" || text3[next] === "]") {
170
+ while (next < text4.length && /\s/.test(text4[next])) next++;
171
+ if (next === text4.length || text4[next] === "," || text4[next] === "}" || text4[next] === "]") {
172
172
  return i;
173
173
  }
174
174
  }
175
175
  }
176
- return text3.length;
176
+ return text4.length;
177
177
  }
178
- function isSerializedJsonContainer(text3) {
179
- const trimmed = text3.trim();
178
+ function isSerializedJsonContainer(text4) {
179
+ const trimmed = text4.trim();
180
180
  if (trimmed[0] !== "{" && trimmed[0] !== "[") return false;
181
181
  try {
182
182
  const parsed = JSON.parse(trimmed);
@@ -185,21 +185,21 @@ function isSerializedJsonContainer(text3) {
185
185
  return false;
186
186
  }
187
187
  }
188
- function maskNestedJsonStringValues(text3, depth) {
188
+ function maskNestedJsonStringValues(text4, depth) {
189
189
  let out = "";
190
190
  let copied = 0;
191
- for (let i = 0; i < text3.length; i++) {
192
- if (text3[i] !== '"') continue;
191
+ for (let i = 0; i < text4.length; i++) {
192
+ if (text4[i] !== '"') continue;
193
193
  const contentStart = i + 1;
194
- const end = valueEnd(text3, contentStart, isJsonValueEnd);
195
- if (end === text3.length) break;
194
+ const end = valueEnd(text4, contentStart, isJsonValueEnd);
195
+ if (end === text4.length) break;
196
196
  let next = end + 1;
197
- while (next < text3.length && /\s/.test(text3[next])) next++;
198
- if (text3[next] === ":") {
197
+ while (next < text4.length && /\s/.test(text4[next])) next++;
198
+ if (text4[next] === ":") {
199
199
  i = end;
200
200
  continue;
201
201
  }
202
- const encoded = text3.slice(contentStart, end);
202
+ const encoded = text4.slice(contentStart, end);
203
203
  let decoded;
204
204
  try {
205
205
  decoded = JSON.parse(`"${encoded}"`);
@@ -210,15 +210,15 @@ function maskNestedJsonStringValues(text3, depth) {
210
210
  const masked = depth >= MAX_NESTED_JSON_STRING_DEPTH && isSerializedJsonContainer(decoded) ? "[REDACTED]" : maskSecretsInMessageAtDepth(decoded, depth + 1);
211
211
  if (masked !== decoded) {
212
212
  const reencoded = JSON.stringify(masked).slice(1, -1);
213
- out += text3.slice(copied, contentStart) + reencoded;
213
+ out += text4.slice(copied, contentStart) + reencoded;
214
214
  copied = end;
215
215
  }
216
216
  i = end;
217
217
  }
218
- return out + text3.slice(copied);
218
+ return out + text4.slice(copied);
219
219
  }
220
- function maskSecretsInMessageAtDepth(text3, depth) {
221
- let out = maskJwts(text3);
220
+ function maskSecretsInMessageAtDepth(text4, depth) {
221
+ let out = maskJwts(text4);
222
222
  for (const [pattern, replacement] of SHAPE_PATTERNS) out = out.replace(pattern, replacement);
223
223
  out = out.replace(BASIC_CREDENTIAL_RE, maskBasicCredential);
224
224
  out = maskJsonCredentialValues(out);
@@ -227,8 +227,8 @@ function maskSecretsInMessageAtDepth(text3, depth) {
227
227
  out = maskCredentialValues(out, HEADER_KEY_RE, headerValueEnd);
228
228
  return out.replace(BASE64_RE, maskBase64);
229
229
  }
230
- function maskSecretsInMessage(text3) {
231
- return maskSecretsInMessageAtDepth(text3, 0);
230
+ function maskSecretsInMessage(text4) {
231
+ return maskSecretsInMessageAtDepth(text4, 0);
232
232
  }
233
233
  var CREDENTIAL_KEY_RE, NUMERIC_CREDENTIAL_KEY_RE, FULLY_MASKED_VALUE_RE, isCredentialKey, isBase64UrlChar, SHAPE_PATTERNS, BASIC_CREDENTIAL_RE, maskBasicCredential, JSON_KEY_RE, isJsonValueEnd, QUERY_KEY_RE, isQueryValueEnd, queryValueEnd, HEADER_KEY_RE, BASE64_RE, maskBase64, MAX_NESTED_JSON_STRING_DEPTH;
234
234
  var init_mask_secrets = __esm({
@@ -287,7 +287,7 @@ var init_mask_secrets = __esm({
287
287
  isJsonValueEnd = (char) => char === '"';
288
288
  QUERY_KEY_RE = /(?:^|[?#&;,\s"'])([A-Za-z0-9_.-]+)=/g;
289
289
  isQueryValueEnd = (char) => char === "&" || char === ";" || char === '"' || /\s/.test(char);
290
- queryValueEnd = (text3, from) => valueEnd(text3, from, isQueryValueEnd);
290
+ queryValueEnd = (text4, from) => valueEnd(text4, from, isQueryValueEnd);
291
291
  HEADER_KEY_RE = /(?:^|[^A-Za-z0-9_.\/\\-])([A-Za-z0-9_.-]+):[ \t]*/g;
292
292
  BASE64_RE = // Padded base64 bodies (wrapped DEKs, HMAC secrets, service-account material)
293
293
  // appearing outside any credential-named key — the shape the rules above miss.
@@ -4888,6 +4888,99 @@ var init_fs_safety = __esm({
4888
4888
  }
4889
4889
  });
4890
4890
 
4891
+ // ../../packages/core/dist/chunk-YVY2TZK2.js
4892
+ var orgResourceIdParam, orgResourceFileIdParam, orgResourceFolderIdParam, hubOrgResourceParam, listOrgResourcesQuery, orgIdQuery, createOrgResourceBody, updateOrgResourceBody, createOrgResourceFolderBody, updateOrgResourceFolderBody, uploadOrgResourceFileBody, updateOrgResourceFileBody, uploadOrgSkillZipBody, linkOrgResourceBody;
4893
+ var init_chunk_YVY2TZK2 = __esm({
4894
+ "../../packages/core/dist/chunk-YVY2TZK2.js"() {
4895
+ "use strict";
4896
+ init_zod();
4897
+ orgResourceIdParam = external_exports.object({
4898
+ id: external_exports.string().uuid()
4899
+ });
4900
+ orgResourceFileIdParam = external_exports.object({
4901
+ file_id: external_exports.string().uuid()
4902
+ });
4903
+ orgResourceFolderIdParam = external_exports.object({
4904
+ folder_id: external_exports.string().uuid()
4905
+ });
4906
+ hubOrgResourceParam = external_exports.object({
4907
+ id: external_exports.string().uuid(),
4908
+ org_resource_id: external_exports.string().uuid()
4909
+ });
4910
+ listOrgResourcesQuery = external_exports.object({
4911
+ organization_id: external_exports.string().uuid(),
4912
+ hub_id: external_exports.string().uuid().optional()
4913
+ });
4914
+ orgIdQuery = external_exports.object({
4915
+ organization_id: external_exports.string().uuid()
4916
+ });
4917
+ createOrgResourceBody = external_exports.object({
4918
+ organization_id: external_exports.string().uuid(),
4919
+ resource_name: external_exports.string().min(1).max(255),
4920
+ resource_description: external_exports.string().max(1e3).nullish(),
4921
+ // Required (validated in the route layer, which names the field, since a refinement here
4922
+ // complicates the inferred input type for callers).
4923
+ skill_name: external_exports.string().min(1).max(255).nullish(),
4924
+ skill_version: external_exports.string().max(50).nullish(),
4925
+ enabled: external_exports.boolean().optional(),
4926
+ tags: external_exports.array(external_exports.string().uuid()).optional(),
4927
+ environment: external_exports.enum(["preview", "production", "all"]).optional()
4928
+ });
4929
+ updateOrgResourceBody = external_exports.object({
4930
+ resource_name: external_exports.string().min(1).max(255).optional(),
4931
+ resource_description: external_exports.string().max(1e3).nullish(),
4932
+ skill_name: external_exports.string().min(1).max(255).nullish(),
4933
+ skill_version: external_exports.string().max(50).nullish(),
4934
+ enabled: external_exports.boolean().optional(),
4935
+ tags: external_exports.array(external_exports.string().uuid()).optional(),
4936
+ environment: external_exports.enum(["preview", "production", "all"]).optional()
4937
+ });
4938
+ createOrgResourceFolderBody = external_exports.object({
4939
+ org_resource_id: external_exports.string().uuid(),
4940
+ folder_name: external_exports.string().min(1).max(255),
4941
+ folder_description: external_exports.string().max(1e3).nullish(),
4942
+ parent_folder_id: external_exports.string().uuid().nullish(),
4943
+ order_index: external_exports.number().int().nonnegative().optional(),
4944
+ enabled: external_exports.boolean().optional(),
4945
+ metadata: external_exports.record(external_exports.unknown()).optional()
4946
+ });
4947
+ updateOrgResourceFolderBody = external_exports.object({
4948
+ folder_name: external_exports.string().min(1).max(255).optional(),
4949
+ folder_description: external_exports.string().max(1e3).nullish(),
4950
+ parent_folder_id: external_exports.string().uuid().nullish(),
4951
+ order_index: external_exports.number().int().nonnegative().optional(),
4952
+ enabled: external_exports.boolean().optional(),
4953
+ metadata: external_exports.record(external_exports.unknown()).optional()
4954
+ });
4955
+ uploadOrgResourceFileBody = external_exports.object({
4956
+ org_resource_id: external_exports.string().uuid(),
4957
+ folder_id: external_exports.string().uuid().nullish(),
4958
+ file_name: external_exports.string().min(1).max(255),
4959
+ file_data: external_exports.string(),
4960
+ // base64
4961
+ mime_type: external_exports.string().optional(),
4962
+ file_size: external_exports.number().int().nonnegative().optional(),
4963
+ resource_file_tags: external_exports.array(external_exports.string()).optional(),
4964
+ metadata: external_exports.record(external_exports.unknown()).optional()
4965
+ });
4966
+ updateOrgResourceFileBody = external_exports.object({
4967
+ resource_file_title: external_exports.string().min(1).max(255).optional(),
4968
+ folder_id: external_exports.string().uuid().nullish(),
4969
+ order_index: external_exports.number().int().nonnegative().optional(),
4970
+ enabled: external_exports.boolean().optional(),
4971
+ resource_file_tags: external_exports.array(external_exports.string()).optional(),
4972
+ metadata: external_exports.record(external_exports.unknown()).optional()
4973
+ });
4974
+ uploadOrgSkillZipBody = external_exports.object({
4975
+ zip_data: external_exports.string().min(1),
4976
+ replace_existing: external_exports.boolean().optional()
4977
+ });
4978
+ linkOrgResourceBody = external_exports.object({
4979
+ org_resource_id: external_exports.string().uuid()
4980
+ });
4981
+ }
4982
+ });
4983
+
4891
4984
  // ../../packages/core/dist/chunk-VXEAR36B.js
4892
4985
  var orgTagIdParam, listOrgTagsQuery, ORG_TAG_NAME_REGEX, ORG_TAG_NAME_MAX_LENGTH, createOrgTagBody, updateOrgTagBody;
4893
4986
  var init_chunk_VXEAR36B = __esm({
@@ -5170,6 +5263,113 @@ var init_chunk_Q7KIQHAZ = __esm({
5170
5263
  }
5171
5264
  });
5172
5265
 
5266
+ // ../../packages/core/dist/chunk-MIWZOSPI.js
5267
+ function toIso(epochMs) {
5268
+ return new Date(epochMs).toISOString();
5269
+ }
5270
+ function fromIso(iso) {
5271
+ return new Date(iso).getTime();
5272
+ }
5273
+ function isIsoTimestamp(value) {
5274
+ return typeof value === "string" && ISO_UTC_RE.test(value);
5275
+ }
5276
+ var ISO_UTC_RE;
5277
+ var init_chunk_MIWZOSPI = __esm({
5278
+ "../../packages/core/dist/chunk-MIWZOSPI.js"() {
5279
+ "use strict";
5280
+ ISO_UTC_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
5281
+ }
5282
+ });
5283
+
5284
+ // ../../packages/core/dist/chunk-MF2VVXBR.js
5285
+ var credentialExpiresAtSchema, LINKED_EXPIRY_REFUSAL;
5286
+ var init_chunk_MF2VVXBR = __esm({
5287
+ "../../packages/core/dist/chunk-MF2VVXBR.js"() {
5288
+ "use strict";
5289
+ init_chunk_HZ6CADSY();
5290
+ init_chunk_MIWZOSPI();
5291
+ credentialExpiresAtSchema = timestampSchema.refine(isIsoTimestamp, "Expected a canonical ISO timestamp").nullable();
5292
+ LINKED_EXPIRY_REFUSAL = "A linked organization credential's expiry is set on the credential";
5293
+ }
5294
+ });
5295
+
5296
+ // ../../packages/core/dist/chunk-HA7CRZMX.js
5297
+ var connectionIdParam, connectorIdParam, listConnectionsQuery, deleteConnectionQuery, addConnectionBody, editConnectionBody, PRODUCTION_DIRECT_FIELDS, BESIDE_LINK_FIELDS, setProductionCredentialBody, registerWhatsappQuery, registerWhatsappBody, retryProvisioningQuery, resendDomainStatusQuery;
5298
+ var init_chunk_HA7CRZMX = __esm({
5299
+ "../../packages/core/dist/chunk-HA7CRZMX.js"() {
5300
+ "use strict";
5301
+ init_chunk_MF2VVXBR();
5302
+ init_chunk_HZ6CADSY();
5303
+ init_zod();
5304
+ connectionIdParam = external_exports.object({ id: uuidSchema });
5305
+ connectorIdParam = external_exports.object({ id: uuidSchema });
5306
+ listConnectionsQuery = external_exports.object({ hub_id: uuidSchema });
5307
+ deleteConnectionQuery = external_exports.object({ hub_id: uuidSchema });
5308
+ addConnectionBody = external_exports.object({
5309
+ hub_id: uuidSchema,
5310
+ connector_id: uuidSchema,
5311
+ authentication_type: external_exports.string().optional(),
5312
+ inbound_mode: external_exports.enum(["wayai", "resend"]).optional(),
5313
+ inbound_address: external_exports.string().email().optional(),
5314
+ // Opt out of copying this connection's credentials into production on publish/sync.
5315
+ // Defaults to true at the DB layer.
5316
+ sync_credentials_to_production: external_exports.boolean().optional(),
5317
+ // When the connection's own secret expires; null for none (`credential-expiry.ts`).
5318
+ expires_at: credentialExpiresAtSchema.optional()
5319
+ }).passthrough().superRefine((data, ctx) => {
5320
+ if (data.inbound_mode === "resend" && !data.inbound_address) {
5321
+ ctx.addIssue({
5322
+ code: external_exports.ZodIssueCode.custom,
5323
+ message: "Receiving email address is required when using Resend inbound mode",
5324
+ path: ["inbound_address"]
5325
+ });
5326
+ }
5327
+ });
5328
+ editConnectionBody = external_exports.object({
5329
+ hub_id: uuidSchema,
5330
+ sync_credentials_to_production: external_exports.boolean().optional(),
5331
+ expires_at: credentialExpiresAtSchema.optional()
5332
+ }).passthrough();
5333
+ PRODUCTION_DIRECT_FIELDS = ["username", "api_key", "access_token", "password", "refresh_token", "webhook_secret_token", "webhook_signing_secret", "github_app_id", "github_app_private_key"];
5334
+ BESIDE_LINK_FIELDS = /* @__PURE__ */ new Set(["webhook_secret_token", "github_app_id", "github_app_private_key"]);
5335
+ setProductionCredentialBody = external_exports.object({
5336
+ hub_id: uuidSchema,
5337
+ organization_credential_id: external_exports.string().nullable().optional(),
5338
+ organization_credential_token_id: external_exports.string().nullable().optional(),
5339
+ username: external_exports.string().optional(),
5340
+ api_key: external_exports.string().optional(),
5341
+ access_token: external_exports.string().optional(),
5342
+ password: external_exports.string().optional(),
5343
+ refresh_token: external_exports.string().optional(),
5344
+ webhook_secret_token: external_exports.string().optional(),
5345
+ webhook_signing_secret: external_exports.string().optional(),
5346
+ github_app_id: external_exports.string().optional(),
5347
+ github_app_private_key: external_exports.string().optional(),
5348
+ expires_at: credentialExpiresAtSchema.optional()
5349
+ }).strict().superRefine((data, ctx) => {
5350
+ const hasOrgLink = !!data.organization_credential_id || !!data.organization_credential_token_id;
5351
+ const sets = (f) => data[f] != null && data[f] !== `__USE_EXISTING_${f.toUpperCase()}__`;
5352
+ const hasDirect = PRODUCTION_DIRECT_FIELDS.some(sets);
5353
+ const hasDirectBesideLink = PRODUCTION_DIRECT_FIELDS.some((f) => !BESIDE_LINK_FIELDS.has(f) && sets(f));
5354
+ if (hasOrgLink && hasDirectBesideLink) {
5355
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Provide either an organization credential link or direct credential fields, not both" });
5356
+ }
5357
+ if (hasOrgLink && data.expires_at != null) {
5358
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: LINKED_EXPIRY_REFUSAL, path: ["expires_at"] });
5359
+ }
5360
+ if (!hasOrgLink && !hasDirect && data.expires_at === void 0) {
5361
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A credential is required: link an organization credential or provide a credential field" });
5362
+ }
5363
+ });
5364
+ registerWhatsappQuery = external_exports.object({ hub_id: uuidSchema });
5365
+ registerWhatsappBody = external_exports.object({
5366
+ pin: external_exports.string().optional()
5367
+ });
5368
+ retryProvisioningQuery = external_exports.object({ hub_id: uuidSchema });
5369
+ resendDomainStatusQuery = external_exports.object({ hub_id: uuidSchema });
5370
+ }
5371
+ });
5372
+
5173
5373
  // ../../packages/core/dist/chunk-IPXBFWUU.js
5174
5374
  var variantAiModeSchema, experimentStatusSchema, overlayUpdateSchema, experimentIdParam, variantIdParam, listExperimentsQuery, listVariantsQuery, listOverridesQuery, deleteOverrideQuery, createExperimentBody, updateExperimentBody, setExperimentStatusBody, createVariantBody, updateVariantBody, upsertOverrideBody;
5175
5375
  var init_chunk_IPXBFWUU = __esm({
@@ -5275,36 +5475,6 @@ var init_chunk_NKLVUTFO = __esm({
5275
5475
  }
5276
5476
  });
5277
5477
 
5278
- // ../../packages/core/dist/chunk-MIWZOSPI.js
5279
- function toIso(epochMs) {
5280
- return new Date(epochMs).toISOString();
5281
- }
5282
- function fromIso(iso) {
5283
- return new Date(iso).getTime();
5284
- }
5285
- function isIsoTimestamp(value) {
5286
- return typeof value === "string" && ISO_UTC_RE.test(value);
5287
- }
5288
- var ISO_UTC_RE;
5289
- var init_chunk_MIWZOSPI = __esm({
5290
- "../../packages/core/dist/chunk-MIWZOSPI.js"() {
5291
- "use strict";
5292
- ISO_UTC_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
5293
- }
5294
- });
5295
-
5296
- // ../../packages/core/dist/chunk-MF2VVXBR.js
5297
- var credentialExpiresAtSchema, LINKED_EXPIRY_REFUSAL;
5298
- var init_chunk_MF2VVXBR = __esm({
5299
- "../../packages/core/dist/chunk-MF2VVXBR.js"() {
5300
- "use strict";
5301
- init_chunk_HZ6CADSY();
5302
- init_chunk_MIWZOSPI();
5303
- credentialExpiresAtSchema = timestampSchema.refine(isIsoTimestamp, "Expected a canonical ISO timestamp").nullable();
5304
- LINKED_EXPIRY_REFUSAL = "A linked organization credential's expiry is set on the credential";
5305
- }
5306
- });
5307
-
5308
5478
  // ../../packages/core/dist/chunk-YROEDMVZ.js
5309
5479
  function normalizeAuthType(raw) {
5310
5480
  if (VALID_AUTH_TYPES.has(raw)) return raw;
@@ -5428,95 +5598,72 @@ var init_chunk_WL5QGKHN = __esm({
5428
5598
  }
5429
5599
  });
5430
5600
 
5431
- // ../../packages/core/dist/chunk-YVY2TZK2.js
5432
- var orgResourceIdParam, orgResourceFileIdParam, orgResourceFolderIdParam, hubOrgResourceParam, listOrgResourcesQuery, orgIdQuery, createOrgResourceBody, updateOrgResourceBody, createOrgResourceFolderBody, updateOrgResourceFolderBody, uploadOrgResourceFileBody, updateOrgResourceFileBody, uploadOrgSkillZipBody, linkOrgResourceBody;
5433
- var init_chunk_YVY2TZK2 = __esm({
5434
- "../../packages/core/dist/chunk-YVY2TZK2.js"() {
5601
+ // ../../packages/core/dist/chunk-ZC6YGHNX.js
5602
+ var updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, recordAiDisclosureAcceptanceBody, activityQuery, deletionModeSchema, deletionRequestBody;
5603
+ var init_chunk_ZC6YGHNX = __esm({
5604
+ "../../packages/core/dist/chunk-ZC6YGHNX.js"() {
5435
5605
  "use strict";
5436
5606
  init_zod();
5437
- orgResourceIdParam = external_exports.object({
5438
- id: external_exports.string().uuid()
5439
- });
5440
- orgResourceFileIdParam = external_exports.object({
5441
- file_id: external_exports.string().uuid()
5442
- });
5443
- orgResourceFolderIdParam = external_exports.object({
5444
- folder_id: external_exports.string().uuid()
5445
- });
5446
- hubOrgResourceParam = external_exports.object({
5447
- id: external_exports.string().uuid(),
5448
- org_resource_id: external_exports.string().uuid()
5449
- });
5450
- listOrgResourcesQuery = external_exports.object({
5451
- organization_id: external_exports.string().uuid(),
5452
- hub_id: external_exports.string().uuid().optional()
5453
- });
5454
- orgIdQuery = external_exports.object({
5455
- organization_id: external_exports.string().uuid()
5456
- });
5457
- createOrgResourceBody = external_exports.object({
5458
- organization_id: external_exports.string().uuid(),
5459
- resource_name: external_exports.string().min(1).max(255),
5460
- resource_description: external_exports.string().max(1e3).nullish(),
5461
- // Required (validated in the route layer, which names the field, since a refinement here
5462
- // complicates the inferred input type for callers).
5463
- skill_name: external_exports.string().min(1).max(255).nullish(),
5464
- skill_version: external_exports.string().max(50).nullish(),
5465
- enabled: external_exports.boolean().optional(),
5466
- tags: external_exports.array(external_exports.string().uuid()).optional(),
5467
- environment: external_exports.enum(["preview", "production", "all"]).optional()
5468
- });
5469
- updateOrgResourceBody = external_exports.object({
5470
- resource_name: external_exports.string().min(1).max(255).optional(),
5471
- resource_description: external_exports.string().max(1e3).nullish(),
5472
- skill_name: external_exports.string().min(1).max(255).nullish(),
5473
- skill_version: external_exports.string().max(50).nullish(),
5474
- enabled: external_exports.boolean().optional(),
5475
- tags: external_exports.array(external_exports.string().uuid()).optional(),
5476
- environment: external_exports.enum(["preview", "production", "all"]).optional()
5477
- });
5478
- createOrgResourceFolderBody = external_exports.object({
5479
- org_resource_id: external_exports.string().uuid(),
5480
- folder_name: external_exports.string().min(1).max(255),
5481
- folder_description: external_exports.string().max(1e3).nullish(),
5482
- parent_folder_id: external_exports.string().uuid().nullish(),
5483
- order_index: external_exports.number().int().nonnegative().optional(),
5484
- enabled: external_exports.boolean().optional(),
5485
- metadata: external_exports.record(external_exports.unknown()).optional()
5486
- });
5487
- updateOrgResourceFolderBody = external_exports.object({
5488
- folder_name: external_exports.string().min(1).max(255).optional(),
5489
- folder_description: external_exports.string().max(1e3).nullish(),
5490
- parent_folder_id: external_exports.string().uuid().nullish(),
5491
- order_index: external_exports.number().int().nonnegative().optional(),
5492
- enabled: external_exports.boolean().optional(),
5493
- metadata: external_exports.record(external_exports.unknown()).optional()
5607
+ updateUserBody = external_exports.object({
5608
+ user_language: external_exports.string().optional(),
5609
+ /** true: dark; false: light; null: follow each device's own setting (`AppearanceMode`). */
5610
+ ui_dark_mode: external_exports.boolean().nullable().optional(),
5611
+ profile_name: external_exports.string().optional(),
5612
+ link_email_to_identities: external_exports.boolean().optional()
5613
+ }).refine(
5614
+ (data) => Object.values(data).some((v) => v !== void 0),
5615
+ { message: "At least one field must be provided" }
5616
+ );
5617
+ updateProfileBody = external_exports.object({
5618
+ display_name: external_exports.string().optional(),
5619
+ avatar_url: external_exports.string().optional(),
5620
+ preferences: external_exports.record(external_exports.unknown()).optional()
5621
+ }).refine(
5622
+ (data) => Object.values(data).some((v) => v !== void 0),
5623
+ { message: "At least one field must be provided" }
5624
+ );
5625
+ pathnameRegex = /^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@/?%]*$/;
5626
+ updatePreferencesBody = external_exports.object({
5627
+ last_viewed_nav: external_exports.string().regex(pathnameRegex, "Must be a URL pathname").max(2048).optional(),
5628
+ dismissed_agentic_shortcut: external_exports.boolean().optional(),
5629
+ opened_guide: external_exports.boolean().optional()
5630
+ }).passthrough();
5631
+ registerPushTokenBody = external_exports.object({
5632
+ token: external_exports.string().min(1).max(512),
5633
+ platform: external_exports.enum(["ios", "android"]),
5634
+ /** Stable per-install id so re-registration replaces the prior token for the device. */
5635
+ device_id: external_exports.string().min(1).max(128).optional(),
5636
+ /**
5637
+ * The build opens a person-to-person thread from a push (gh #4661): only a token registered
5638
+ * with it receives thread pushes, whose `data` carries `thread_id` and no `conversation_id`.
5639
+ * Each registration states it afresh, so a build that sends none clears it.
5640
+ */
5641
+ supports_threads: external_exports.boolean().optional(),
5642
+ /**
5643
+ * The build opens a community from a push (gh #4872 Decision 8): only a token registered with it
5644
+ * receives a community's pushes (an announcement, a reply to the member's forum post), whose
5645
+ * `data` is `CommunityPushData` — never a `conversation_id` or a `thread_id`. Each registration
5646
+ * states it afresh, so a build that sends none clears it.
5647
+ */
5648
+ supports_communities: external_exports.boolean().optional()
5494
5649
  });
5495
- uploadOrgResourceFileBody = external_exports.object({
5496
- org_resource_id: external_exports.string().uuid(),
5497
- folder_id: external_exports.string().uuid().nullish(),
5498
- file_name: external_exports.string().min(1).max(255),
5499
- file_data: external_exports.string(),
5500
- // base64
5501
- mime_type: external_exports.string().optional(),
5502
- file_size: external_exports.number().int().nonnegative().optional(),
5503
- resource_file_tags: external_exports.array(external_exports.string()).optional(),
5504
- metadata: external_exports.record(external_exports.unknown()).optional()
5650
+ deletePushTokenQuery = external_exports.object({
5651
+ token: external_exports.string().min(1).max(512)
5505
5652
  });
5506
- updateOrgResourceFileBody = external_exports.object({
5507
- resource_file_title: external_exports.string().min(1).max(255).optional(),
5508
- folder_id: external_exports.string().uuid().nullish(),
5509
- order_index: external_exports.number().int().nonnegative().optional(),
5510
- enabled: external_exports.boolean().optional(),
5511
- resource_file_tags: external_exports.array(external_exports.string()).optional(),
5512
- metadata: external_exports.record(external_exports.unknown()).optional()
5653
+ recordAiDisclosureAcceptanceBody = external_exports.object({
5654
+ version: external_exports.number().int().positive(),
5655
+ withdrawn_at_seen: external_exports.string().datetime().nullable().optional()
5513
5656
  });
5514
- uploadOrgSkillZipBody = external_exports.object({
5515
- zip_data: external_exports.string().min(1),
5516
- replace_existing: external_exports.boolean().optional()
5657
+ activityQuery = external_exports.object({
5658
+ limit: external_exports.coerce.number().int().min(1).max(100).optional()
5517
5659
  });
5518
- linkOrgResourceBody = external_exports.object({
5519
- org_resource_id: external_exports.string().uuid()
5660
+ deletionModeSchema = external_exports.enum(["scheduled", "immediate"]);
5661
+ deletionRequestBody = external_exports.object({
5662
+ mode: deletionModeSchema,
5663
+ /** User-supplied reason captured in the audit log; bounded to bound logged PII. */
5664
+ reason: external_exports.string().max(500).optional(),
5665
+ /** Type-to-confirm value; must equal the user's email (constant-time compared). */
5666
+ email_confirmation: external_exports.string().min(1).max(320)
5520
5667
  });
5521
5668
  }
5522
5669
  });
@@ -5566,559 +5713,54 @@ var init_chunk_JOPEQ3WP = __esm({
5566
5713
  }
5567
5714
  });
5568
5715
 
5569
- // ../../packages/core/dist/chunk-HA7CRZMX.js
5570
- var connectionIdParam, connectorIdParam, listConnectionsQuery, deleteConnectionQuery, addConnectionBody, editConnectionBody, PRODUCTION_DIRECT_FIELDS, BESIDE_LINK_FIELDS, setProductionCredentialBody, registerWhatsappQuery, registerWhatsappBody, retryProvisioningQuery, resendDomainStatusQuery;
5571
- var init_chunk_HA7CRZMX = __esm({
5572
- "../../packages/core/dist/chunk-HA7CRZMX.js"() {
5716
+ // ../../packages/core/dist/chunk-5XEJSR22.js
5717
+ var DATA_PROXY_MOUNT, DATA_PROXY_PREFIX, BASE_DESTRUCTION_MOUNT, BASE_DESTRUCTION_PREFIX, BASE_DESTRUCTION_CONFIRM_PATH, COMMUNITY_EMAIL_UNSUBSCRIBE_PATH, CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH, AUTOMATION_WEBHOOK_MOUNT, MANAGED_AGENTS_WEBHOOK_MOUNT;
5718
+ var init_chunk_5XEJSR22 = __esm({
5719
+ "../../packages/core/dist/chunk-5XEJSR22.js"() {
5573
5720
  "use strict";
5574
- init_chunk_MF2VVXBR();
5575
- init_chunk_HZ6CADSY();
5576
- init_zod();
5577
- connectionIdParam = external_exports.object({ id: uuidSchema });
5578
- connectorIdParam = external_exports.object({ id: uuidSchema });
5579
- listConnectionsQuery = external_exports.object({ hub_id: uuidSchema });
5580
- deleteConnectionQuery = external_exports.object({ hub_id: uuidSchema });
5581
- addConnectionBody = external_exports.object({
5582
- hub_id: uuidSchema,
5583
- connector_id: uuidSchema,
5584
- authentication_type: external_exports.string().optional(),
5585
- inbound_mode: external_exports.enum(["wayai", "resend"]).optional(),
5586
- inbound_address: external_exports.string().email().optional(),
5587
- // Opt out of copying this connection's credentials into production on publish/sync.
5588
- // Defaults to true at the DB layer.
5589
- sync_credentials_to_production: external_exports.boolean().optional(),
5590
- // When the connection's own secret expires; null for none (`credential-expiry.ts`).
5591
- expires_at: credentialExpiresAtSchema.optional()
5592
- }).passthrough().superRefine((data, ctx) => {
5593
- if (data.inbound_mode === "resend" && !data.inbound_address) {
5594
- ctx.addIssue({
5595
- code: external_exports.ZodIssueCode.custom,
5596
- message: "Receiving email address is required when using Resend inbound mode",
5597
- path: ["inbound_address"]
5598
- });
5599
- }
5600
- });
5601
- editConnectionBody = external_exports.object({
5602
- hub_id: uuidSchema,
5603
- sync_credentials_to_production: external_exports.boolean().optional(),
5604
- expires_at: credentialExpiresAtSchema.optional()
5605
- }).passthrough();
5606
- PRODUCTION_DIRECT_FIELDS = ["username", "api_key", "access_token", "password", "refresh_token", "webhook_secret_token", "webhook_signing_secret", "github_app_id", "github_app_private_key"];
5607
- BESIDE_LINK_FIELDS = /* @__PURE__ */ new Set(["webhook_secret_token", "github_app_id", "github_app_private_key"]);
5608
- setProductionCredentialBody = external_exports.object({
5609
- hub_id: uuidSchema,
5610
- organization_credential_id: external_exports.string().nullable().optional(),
5611
- organization_credential_token_id: external_exports.string().nullable().optional(),
5612
- username: external_exports.string().optional(),
5613
- api_key: external_exports.string().optional(),
5614
- access_token: external_exports.string().optional(),
5615
- password: external_exports.string().optional(),
5616
- refresh_token: external_exports.string().optional(),
5617
- webhook_secret_token: external_exports.string().optional(),
5618
- webhook_signing_secret: external_exports.string().optional(),
5619
- github_app_id: external_exports.string().optional(),
5620
- github_app_private_key: external_exports.string().optional(),
5621
- expires_at: credentialExpiresAtSchema.optional()
5622
- }).strict().superRefine((data, ctx) => {
5623
- const hasOrgLink = !!data.organization_credential_id || !!data.organization_credential_token_id;
5624
- const sets = (f) => data[f] != null && data[f] !== `__USE_EXISTING_${f.toUpperCase()}__`;
5625
- const hasDirect = PRODUCTION_DIRECT_FIELDS.some(sets);
5626
- const hasDirectBesideLink = PRODUCTION_DIRECT_FIELDS.some((f) => !BESIDE_LINK_FIELDS.has(f) && sets(f));
5627
- if (hasOrgLink && hasDirectBesideLink) {
5628
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Provide either an organization credential link or direct credential fields, not both" });
5629
- }
5630
- if (hasOrgLink && data.expires_at != null) {
5631
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: LINKED_EXPIRY_REFUSAL, path: ["expires_at"] });
5632
- }
5633
- if (!hasOrgLink && !hasDirect && data.expires_at === void 0) {
5634
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A credential is required: link an organization credential or provide a credential field" });
5635
- }
5636
- });
5637
- registerWhatsappQuery = external_exports.object({ hub_id: uuidSchema });
5638
- registerWhatsappBody = external_exports.object({
5639
- pin: external_exports.string().optional()
5640
- });
5641
- retryProvisioningQuery = external_exports.object({ hub_id: uuidSchema });
5642
- resendDomainStatusQuery = external_exports.object({ hub_id: uuidSchema });
5721
+ DATA_PROXY_MOUNT = "/data";
5722
+ DATA_PROXY_PREFIX = `/api${DATA_PROXY_MOUNT}`;
5723
+ BASE_DESTRUCTION_MOUNT = "/bases";
5724
+ BASE_DESTRUCTION_PREFIX = `/api${BASE_DESTRUCTION_MOUNT}`;
5725
+ BASE_DESTRUCTION_CONFIRM_PATH = `${BASE_DESTRUCTION_PREFIX}/destruction/confirm`;
5726
+ COMMUNITY_EMAIL_UNSUBSCRIBE_PATH = "/api/communities/email-unsubscribe";
5727
+ CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH = "/api/contact-book/email-unsubscribe";
5728
+ AUTOMATION_WEBHOOK_MOUNT = "/webhooks/automations";
5729
+ MANAGED_AGENTS_WEBHOOK_MOUNT = "/webhooks/managed-agents";
5643
5730
  }
5644
5731
  });
5645
5732
 
5646
- // ../../packages/core/dist/chunk-IPDOHAZ5.js
5647
- 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;
5648
- var init_chunk_IPDOHAZ5 = __esm({
5649
- "../../packages/core/dist/chunk-IPDOHAZ5.js"() {
5650
- "use strict";
5651
- init_chunk_HZ6CADSY();
5652
- init_zod();
5653
- reportSourceSchema = external_exports.enum(["sentry", "cli", "review", "security_audit"]);
5654
- intakeReportSourceSchema = external_exports.enum(["cli", "review", "security_audit"]);
5655
- reportClassificationSchema = external_exports.enum(["bug", "flaky_test", "security", "enhancement"]);
5656
- reportStatusSchema = external_exports.enum([
5657
- "pending",
5658
- "grouped",
5659
- "escalated",
5660
- "shipped",
5661
- "contested",
5662
- "addressed",
5663
- "dismissed"
5664
- ]);
5665
- reportLocaleSchema = external_exports.enum(["en", "pt", "es"]);
5666
- reportMessageAuthorRoleSchema = external_exports.enum(["reporter", "triage", "fixer", "system"]);
5667
- reportMessageSchema = external_exports.object({
5668
- message_id: external_exports.string(),
5669
- author_role: reportMessageAuthorRoleSchema,
5670
- /** The status transition this note accompanied (e.g. 'shipped'); null for a free/system note. */
5671
- transition: external_exports.string().nullable(),
5672
- body: external_exports.string(),
5673
- created_at: timestampSchema,
5674
- /**
5675
- * Visibility: `false` = reporter-facing (the default for every narrative entry); `true` =
5676
- * triage-internal (e.g. a `hold` rationale) — surfaced to platform admins only and NEVER
5677
- * returned on the reporter read path. The reporter's `GET /api/reports/:id` filters these out.
5678
- */
5679
- internal: external_exports.boolean()
5680
- });
5681
- sentryRefStatusSchema = external_exports.enum(["valid", "not_found", "mismatch", "unverified"]);
5682
- createReportBody = external_exports.object({
5683
- title: external_exports.string().min(5).max(256),
5684
- description: external_exports.string().min(10).max(5e3),
5685
- steps_to_reproduce: external_exports.string().max(3e3).optional(),
5686
- error_message: external_exports.string().max(2e3).optional(),
5687
- // Taxonomy (server defaults: source=cli, classification=bug when absent).
5688
- source: intakeReportSourceSchema.optional(),
5689
- classification: reportClassificationSchema.optional(),
5690
- // Stable dedup key (e.g. "<file>::<test>" for flaky, "<file>:<line>" for
5691
- // security). When present, the fingerprint uses it instead of the body hash.
5692
- dedup_key: external_exports.string().min(1).max(256).optional(),
5693
- // Context fields (auto-captured by the CLI)
5694
- organization_id: external_exports.string().optional(),
5695
- hub_id: external_exports.string().uuid().optional(),
5696
- hub_name: external_exports.string().max(256).optional(),
5697
- conversation_id: external_exports.string().uuid().optional(),
5698
- agent_id: external_exports.string().uuid().optional(),
5699
- agent_name: external_exports.string().max(256).optional(),
5700
- client_version: external_exports.string().max(64).optional(),
5701
- additional_context: external_exports.string().max(2e3).optional()
5702
- });
5703
- editReportBody = external_exports.object({
5704
- title: external_exports.string().min(5).max(256).optional(),
5705
- description: external_exports.string().min(10).max(5e3).optional(),
5706
- steps_to_reproduce: external_exports.string().max(3e3).optional(),
5707
- error_message: external_exports.string().max(2e3).optional(),
5708
- additional_context: external_exports.string().max(2e3).optional()
5709
- }).strict().refine((b) => Object.keys(b).length > 0, {
5710
- message: "at least one field must be provided"
5711
- });
5712
- reporterReportSummarySchema = external_exports.object({
5713
- report_id: external_exports.string(),
5714
- title: external_exports.string(),
5715
- description: external_exports.string(),
5716
- classification: reportClassificationSchema,
5717
- status: reportStatusSchema,
5718
- created_at: timestampSchema,
5719
- triaged_at: timestampSchema.nullable(),
5720
- resolved_at: timestampSchema.nullable(),
5721
- /** How many times the reporter has contested (gates the hard cap). */
5722
- contest_count: external_exports.number(),
5723
- /** True once triage issued a non-contestable (final) dismissal. */
5724
- dismissal_final: external_exports.boolean()
5725
- });
5726
- reporterListResponseSchema = external_exports.object({
5727
- data: external_exports.array(reporterReportSummarySchema)
5728
- });
5729
- getReportResponseSchema = external_exports.object({
5730
- report: reporterReportSummarySchema,
5731
- messages: external_exports.array(reportMessageSchema)
5732
- });
5733
- reporterTransitionResponseSchema = external_exports.object({
5734
- report: reporterReportSummarySchema
5735
- });
5736
- contestReportBody = external_exports.object({
5737
- reason: external_exports.string().min(1).max(5e3)
5738
- });
5739
- reporterListQuery = external_exports.object({
5740
- status: reportStatusSchema.optional()
5741
- });
5742
- listReportsQuery = external_exports.object({
5743
- status: reportStatusSchema.optional(),
5744
- source: reportSourceSchema.optional(),
5745
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
5746
- offset: external_exports.coerce.number().int().min(0).optional(),
5747
- /** ISO 8601 lower bound on created_at. */
5748
- since: external_exports.string().datetime().optional(),
5749
- /**
5750
- * ISO 8601 lower bound on resolution time — "what did we resolve recently", which `since`
5751
- * (a created_at filter) cannot answer for a long-lived report resolved yesterday. Implies
5752
- * a terminal status (`addressed`/`dismissed`) and orders on that same axis.
5753
- */
5754
- resolved_since: external_exports.string().datetime().optional()
5755
- });
5756
- GITHUB_ISSUE_URL_REGEX = /^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+(?:[/?#]|$)/;
5757
- githubIssueUrlSchema = external_exports.string().url().refine((u) => GITHUB_ISSUE_URL_REGEX.test(u), {
5758
- message: "must be an https://github.com/<owner>/<repo>/issues/<number> URL"
5759
- });
5760
- transitionReportBody = external_exports.discriminatedUnion("target", [
5761
- external_exports.object({
5762
- target: external_exports.literal("escalated"),
5763
- gh_issue_url: githubIssueUrlSchema,
5764
- ai_verdict: external_exports.string().max(2e3).optional()
5765
- }),
5766
- external_exports.object({
5767
- target: external_exports.literal("shipped"),
5768
- note: external_exports.string().min(1).max(2e3).optional()
5769
- }),
5770
- external_exports.object({
5771
- target: external_exports.literal("addressed")
5772
- }),
5773
- external_exports.object({
5774
- target: external_exports.literal("dismissed"),
5775
- dismissal_reason: external_exports.string().min(1).max(5e3),
5776
- ai_verdict: external_exports.string().max(2e3).optional(),
5777
- final: external_exports.boolean().optional()
5778
- })
5779
- ]);
5780
- groupReportsBody = external_exports.object({
5781
- member_ids: external_exports.array(external_exports.string().uuid()).min(1).max(100)
5782
- });
5783
- holdReportBody = external_exports.object({
5784
- reason: external_exports.string().min(1).max(5e3)
5785
- });
5786
- }
5787
- });
5788
-
5789
- // ../../packages/core/dist/chunk-GPM7PE44.js
5790
- var bootstrapQuery;
5791
- var init_chunk_GPM7PE44 = __esm({
5792
- "../../packages/core/dist/chunk-GPM7PE44.js"() {
5793
- "use strict";
5794
- init_zod();
5795
- bootstrapQuery = external_exports.object({
5796
- active_hub_id: external_exports.string().uuid().optional(),
5797
- active_conversation_id: external_exports.string().uuid().optional(),
5798
- active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
5799
- /**
5800
- * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
5801
- * preloads it as `people.active_thread` when the viewer is a member.
5802
- */
5803
- active_thread_id: external_exports.string().uuid().optional()
5804
- });
5805
- }
5806
- });
5807
-
5808
- // ../../packages/core/dist/chunk-5VL6LBFD.js
5809
- var PERMISSIONS;
5810
- var init_chunk_5VL6LBFD = __esm({
5811
- "../../packages/core/dist/chunk-5VL6LBFD.js"() {
5812
- "use strict";
5813
- PERMISSIONS = [
5814
- "hub:read",
5815
- "hub:write",
5816
- "hub:admin",
5817
- "conversation:read",
5818
- "conversation:write",
5819
- "analytics:read",
5820
- "billing:read",
5821
- "billing:write",
5822
- "org:read",
5823
- "org:write",
5824
- "org:admin",
5825
- "contacts:write",
5826
- "platform:admin",
5827
- "*"
5828
- ];
5829
- }
5830
- });
5831
-
5832
- // ../../packages/core/dist/chunk-VEERWOZ6.js
5833
- var MAX_NAME_LENGTH2, MAX_HUBS_PER_GRANT, MAX_HUB_TAGS_PER_GRANT, MAX_GRANTS, permissionEnum, grantScopeSchema, grantSchema, createTokenBody, tokenOrgIdParam;
5834
- var init_chunk_VEERWOZ6 = __esm({
5835
- "../../packages/core/dist/chunk-VEERWOZ6.js"() {
5836
- "use strict";
5837
- init_chunk_5VL6LBFD();
5838
- init_chunk_HZ6CADSY();
5839
- init_zod();
5840
- MAX_NAME_LENGTH2 = 100;
5841
- MAX_HUBS_PER_GRANT = 50;
5842
- MAX_HUB_TAGS_PER_GRANT = 20;
5843
- MAX_GRANTS = 20;
5844
- permissionEnum = external_exports.enum(PERMISSIONS).refine(
5845
- (p) => p !== "platform:admin",
5846
- { message: "platform:admin cannot be delegated via token creation" }
5847
- );
5848
- grantScopeSchema = external_exports.object({
5849
- // Required: every token grant must declare its org tenancy. The handler
5850
- // also strict-checks this as defense-in-depth, but failing at the Zod
5851
- // boundary keeps the generated client type honest (org_id: string).
5852
- org_id: external_exports.string().min(1),
5853
- hubs: external_exports.array(external_exports.string().min(1)).min(1, "Each grant must have scope.hubs as a non-empty array").max(MAX_HUBS_PER_GRANT),
5854
- hub_tags: external_exports.array(external_exports.string().min(1)).min(1, "scope.hub_tags must be a non-empty array if provided").max(MAX_HUB_TAGS_PER_GRANT).optional(),
5855
- environments: external_exports.array(external_exports.enum(["production", "preview"])).min(1, "scope.environments must be a non-empty array if provided").optional()
5856
- }).strict();
5857
- grantSchema = external_exports.object({
5858
- scope: grantScopeSchema,
5859
- permissions: external_exports.array(permissionEnum).min(1, "Each grant must have permissions as a non-empty array")
5860
- }).strict();
5861
- createTokenBody = external_exports.object({
5862
- name: external_exports.string().trim().min(1, "name is required").max(MAX_NAME_LENGTH2, `name must be ${MAX_NAME_LENGTH2} characters or fewer`),
5863
- grants: external_exports.array(grantSchema).min(1, "grants must be a non-empty array").max(MAX_GRANTS),
5864
- expires_at: external_exports.string().datetime({ message: "expires_at must be a valid ISO 8601 date" }).refine(
5865
- (s) => new Date(s).getTime() > Date.now(),
5866
- { message: "expires_at must be in the future" }
5867
- ).optional()
5868
- });
5869
- tokenOrgIdParam = external_exports.object({ orgId: uuidSchema });
5870
- }
5871
- });
5872
-
5873
- // ../../packages/core/dist/chunk-ZC6YGHNX.js
5874
- var updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, recordAiDisclosureAcceptanceBody, activityQuery, deletionModeSchema, deletionRequestBody;
5875
- var init_chunk_ZC6YGHNX = __esm({
5876
- "../../packages/core/dist/chunk-ZC6YGHNX.js"() {
5877
- "use strict";
5878
- init_zod();
5879
- updateUserBody = external_exports.object({
5880
- user_language: external_exports.string().optional(),
5881
- /** true: dark; false: light; null: follow each device's own setting (`AppearanceMode`). */
5882
- ui_dark_mode: external_exports.boolean().nullable().optional(),
5883
- profile_name: external_exports.string().optional(),
5884
- link_email_to_identities: external_exports.boolean().optional()
5885
- }).refine(
5886
- (data) => Object.values(data).some((v) => v !== void 0),
5887
- { message: "At least one field must be provided" }
5888
- );
5889
- updateProfileBody = external_exports.object({
5890
- display_name: external_exports.string().optional(),
5891
- avatar_url: external_exports.string().optional(),
5892
- preferences: external_exports.record(external_exports.unknown()).optional()
5893
- }).refine(
5894
- (data) => Object.values(data).some((v) => v !== void 0),
5895
- { message: "At least one field must be provided" }
5896
- );
5897
- pathnameRegex = /^\/(?!\/)[A-Za-z0-9\-._~!$&'()*+,;=:@/?%]*$/;
5898
- updatePreferencesBody = external_exports.object({
5899
- last_viewed_nav: external_exports.string().regex(pathnameRegex, "Must be a URL pathname").max(2048).optional(),
5900
- dismissed_agentic_shortcut: external_exports.boolean().optional(),
5901
- opened_guide: external_exports.boolean().optional()
5902
- }).passthrough();
5903
- registerPushTokenBody = external_exports.object({
5904
- token: external_exports.string().min(1).max(512),
5905
- platform: external_exports.enum(["ios", "android"]),
5906
- /** Stable per-install id so re-registration replaces the prior token for the device. */
5907
- device_id: external_exports.string().min(1).max(128).optional(),
5908
- /**
5909
- * The build opens a person-to-person thread from a push (gh #4661): only a token registered
5910
- * with it receives thread pushes, whose `data` carries `thread_id` and no `conversation_id`.
5911
- * Each registration states it afresh, so a build that sends none clears it.
5912
- */
5913
- supports_threads: external_exports.boolean().optional(),
5914
- /**
5915
- * The build opens a community from a push (gh #4872 Decision 8): only a token registered with it
5916
- * receives a community's pushes (an announcement, a reply to the member's forum post), whose
5917
- * `data` is `CommunityPushData` — never a `conversation_id` or a `thread_id`. Each registration
5918
- * states it afresh, so a build that sends none clears it.
5919
- */
5920
- supports_communities: external_exports.boolean().optional()
5921
- });
5922
- deletePushTokenQuery = external_exports.object({
5923
- token: external_exports.string().min(1).max(512)
5924
- });
5925
- recordAiDisclosureAcceptanceBody = external_exports.object({
5926
- version: external_exports.number().int().positive(),
5927
- withdrawn_at_seen: external_exports.string().datetime().nullable().optional()
5928
- });
5929
- activityQuery = external_exports.object({
5930
- limit: external_exports.coerce.number().int().min(1).max(100).optional()
5931
- });
5932
- deletionModeSchema = external_exports.enum(["scheduled", "immediate"]);
5933
- deletionRequestBody = external_exports.object({
5934
- mode: deletionModeSchema,
5935
- /** User-supplied reason captured in the audit log; bounded to bound logged PII. */
5936
- reason: external_exports.string().max(500).optional(),
5937
- /** Type-to-confirm value; must equal the user's email (constant-time compared). */
5938
- email_confirmation: external_exports.string().min(1).max(320)
5939
- });
5940
- }
5941
- });
5942
-
5943
- // ../../packages/core/dist/chunk-ZVXO3XL6.js
5944
- 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;
5945
- var init_chunk_ZVXO3XL6 = __esm({
5946
- "../../packages/core/dist/chunk-ZVXO3XL6.js"() {
5947
- "use strict";
5948
- init_chunk_HZ6CADSY();
5949
- init_zod();
5950
- PEOPLE_CONTACT_PAGE_MAX = 100;
5951
- PEOPLE_CONTACT_PAGE_DEFAULT = 50;
5952
- PEOPLE_CONTACT_EMAIL_MAX_LENGTH = 254;
5953
- peopleUserIdSchema = external_exports.string().max(64).regex(USER_ID_REGEX, "must be a user id");
5954
- peopleInviteEmailSchema = external_exports.string().trim().max(PEOPLE_CONTACT_EMAIL_MAX_LENGTH).email();
5955
- peopleContactInviteBody = external_exports.object({
5956
- email: peopleInviteEmailSchema
5957
- }).strict();
5958
- peopleContactInviteIdParam = external_exports.object({ inviteId: uuidSchema });
5959
- peopleContactUserIdParam = external_exports.object({ userId: peopleUserIdSchema });
5960
- 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, {
5961
- message: "Name a thread or a community, not both",
5962
- path: ["community_id"]
5963
- });
5964
- peopleContactPageQuery = external_exports.object({
5965
- cursor: external_exports.string().min(1).max(256).optional(),
5966
- limit: external_exports.coerce.number().int().min(1).max(PEOPLE_CONTACT_PAGE_MAX).default(PEOPLE_CONTACT_PAGE_DEFAULT)
5967
- });
5968
- peopleOutgoingInviteSchema = external_exports.object({
5969
- invite_id: uuidSchema,
5970
- email: external_exports.string(),
5971
- status: external_exports.literal("sent"),
5972
- created_at: timestampSchema,
5973
- expires_at: timestampSchema
5974
- }).strict();
5975
- peopleContactPersonSchema = external_exports.object({
5976
- user_id: peopleUserIdSchema,
5977
- display_name: external_exports.string().nullable(),
5978
- email: external_exports.string().nullable()
5979
- }).strict();
5980
- peopleContactSchema = peopleContactPersonSchema.extend({ contact_since: timestampSchema, thread_id: uuidSchema }).strict();
5981
- peopleIncomingInviteSchema = external_exports.object({
5982
- invite_id: uuidSchema,
5983
- inviter: peopleContactPersonSchema,
5984
- created_at: timestampSchema,
5985
- expires_at: timestampSchema
5986
- }).strict();
5987
- peopleBlockedUserSchema = peopleContactPersonSchema.extend({ blocked_at: timestampSchema, deleted_user: external_exports.boolean() }).strict();
5988
- }
5989
- });
5990
-
5991
- // ../../packages/core/dist/chunk-ZXK6N2HN.js
5992
- 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;
5993
- var init_chunk_ZXK6N2HN = __esm({
5994
- "../../packages/core/dist/chunk-ZXK6N2HN.js"() {
5995
- "use strict";
5996
- init_chunk_ZVXO3XL6();
5997
- init_chunk_HZ6CADSY();
5998
- init_zod();
5999
- PEOPLE_MODERATION_NOTE_MAX_LENGTH = 500;
6000
- ADMIN_PEOPLE_REPORTS_PAGE_MAX = 100;
6001
- ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT = 50;
6002
- PEOPLE_SUSPENDED_REASON = "suspended";
6003
- peopleModerationActionSchema = external_exports.enum(["remove_message", "suspend", "unsuspend", "dismiss"]);
6004
- moderationNoteSchema = optionalTrimmedText(PEOPLE_MODERATION_NOTE_MAX_LENGTH);
6005
- adminPeopleReportListQuery = external_exports.object({
6006
- pending: external_exports.enum(["true", "false"]).optional().transform((value) => value === "true"),
6007
- /** Lower bound on `created_at`. */
6008
- since: timestampSchema.optional(),
6009
- limit: external_exports.coerce.number().int().min(1).max(ADMIN_PEOPLE_REPORTS_PAGE_MAX).default(ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT),
6010
- offset: external_exports.coerce.number().int().min(0).default(0)
6011
- });
6012
- adminPeopleReportIdParam = external_exports.object({ reportId: uuidSchema });
6013
- adminPeopleMessageRemovalBody = external_exports.object({ report_id: uuidSchema, message_id: uuidSchema.optional(), note: moderationNoteSchema }).strict();
6014
- adminPeopleSuspendBody = external_exports.object({ report_id: uuidSchema.optional(), note: moderationNoteSchema }).strict();
6015
- adminPeopleNoteBody = external_exports.object({ note: moderationNoteSchema }).strict();
6016
- }
6017
- });
6018
-
6019
- // ../../packages/core/dist/chunk-Y7CFCYX4.js
6020
- var PEOPLE_REPORT_DETAILS_MAX_LENGTH, peopleReportReasonSchema, reportDetailsSchema, reportFields, peopleReportBody;
6021
- var init_chunk_Y7CFCYX4 = __esm({
6022
- "../../packages/core/dist/chunk-Y7CFCYX4.js"() {
6023
- "use strict";
6024
- init_chunk_ZVXO3XL6();
6025
- init_chunk_HZ6CADSY();
6026
- init_zod();
6027
- PEOPLE_REPORT_DETAILS_MAX_LENGTH = 500;
6028
- peopleReportReasonSchema = external_exports.enum(["spam", "harassment", "hate", "sexual", "violence", "other"]);
6029
- reportDetailsSchema = optionalTrimmedText(PEOPLE_REPORT_DETAILS_MAX_LENGTH);
6030
- reportFields = { reason: peopleReportReasonSchema, details: reportDetailsSchema };
6031
- peopleReportBody = external_exports.discriminatedUnion("target", [
6032
- external_exports.object({ target: external_exports.literal("message"), thread_id: uuidSchema, message_id: uuidSchema, ...reportFields }).strict(),
6033
- external_exports.object({ target: external_exports.literal("thread"), thread_id: uuidSchema, ...reportFields }).strict(),
6034
- external_exports.object({ target: external_exports.literal("user"), user_id: peopleUserIdSchema, thread_id: uuidSchema.optional(), ...reportFields }).strict(),
6035
- external_exports.object({
6036
- target: external_exports.literal("community_message"),
6037
- community_id: uuidSchema,
6038
- room_id: uuidSchema,
6039
- message_id: uuidSchema,
6040
- ...reportFields
6041
- }).strict(),
6042
- external_exports.object({ target: external_exports.literal("community_member"), community_id: uuidSchema, user_id: peopleUserIdSchema, ...reportFields }).strict()
6043
- ]);
6044
- }
6045
- });
6046
-
6047
- // ../../packages/core/dist/chunk-5DGHIY7L.js
6048
- var rekorBaseChangeMessageSchema;
6049
- var init_chunk_5DGHIY7L = __esm({
6050
- "../../packages/core/dist/chunk-5DGHIY7L.js"() {
6051
- "use strict";
6052
- init_zod();
6053
- rekorBaseChangeMessageSchema = external_exports.object({
6054
- /** The WayAI org UUID — one id namespace. */
6055
- org_id: external_exports.string().uuid(),
6056
- /**
6057
- * Not a UUID: a preview base id is `{prod_base_id}--{slug}`. Immutable per base — a
6058
- * preview clone is its OWN base_id — so `(base_id, scope)` keys never collide across
6059
- * environments. Empty is never a real base id, so it is non-conforming rather than a
6060
- * frame keyed on nothing.
6061
- */
6062
- base_id: external_exports.string().min(1),
6063
- /**
6064
- * Rides along so the client scopes its refetch without a lookup; the inspector scopes
6065
- * by side.
6066
- */
6067
- environment: external_exports.enum(["production", "preview"]),
6068
- /** Which pane refetches. `base` covers create/delete/promote/config changes. */
6069
- scope: external_exports.enum(["records", "record_types", "files", "base"])
6070
- });
6071
- }
6072
- });
6073
-
6074
- // ../../packages/core/dist/chunk-5XEJSR22.js
6075
- var DATA_PROXY_MOUNT, DATA_PROXY_PREFIX, BASE_DESTRUCTION_MOUNT, BASE_DESTRUCTION_PREFIX, BASE_DESTRUCTION_CONFIRM_PATH, COMMUNITY_EMAIL_UNSUBSCRIBE_PATH, CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH, AUTOMATION_WEBHOOK_MOUNT, MANAGED_AGENTS_WEBHOOK_MOUNT;
6076
- var init_chunk_5XEJSR22 = __esm({
6077
- "../../packages/core/dist/chunk-5XEJSR22.js"() {
6078
- "use strict";
6079
- DATA_PROXY_MOUNT = "/data";
6080
- DATA_PROXY_PREFIX = `/api${DATA_PROXY_MOUNT}`;
6081
- BASE_DESTRUCTION_MOUNT = "/bases";
6082
- BASE_DESTRUCTION_PREFIX = `/api${BASE_DESTRUCTION_MOUNT}`;
6083
- BASE_DESTRUCTION_CONFIRM_PATH = `${BASE_DESTRUCTION_PREFIX}/destruction/confirm`;
6084
- COMMUNITY_EMAIL_UNSUBSCRIBE_PATH = "/api/communities/email-unsubscribe";
6085
- CONTACT_BOOK_EMAIL_UNSUBSCRIBE_PATH = "/api/contact-book/email-unsubscribe";
6086
- AUTOMATION_WEBHOOK_MOUNT = "/webhooks/automations";
6087
- MANAGED_AGENTS_WEBHOOK_MOUNT = "/webhooks/managed-agents";
6088
- }
6089
- });
6090
-
6091
- // ../../packages/core/dist/chunk-Z2SC7EVO.js
6092
- function matchPath(pattern, path45) {
6093
- const pathSegments2 = path45.replace(/\/$/, "").split("/");
6094
- const isPrefix = pattern.endsWith("/*");
6095
- const patternSegments = (isPrefix ? pattern.slice(0, -2) : pattern).split("/");
6096
- if (isPrefix ? pathSegments2.length < patternSegments.length : pathSegments2.length !== patternSegments.length) {
6097
- return false;
6098
- }
6099
- return patternSegments.every((segment, i) => segment === "*" ? pathSegments2[i] !== "" : segment === pathSegments2[i]);
6100
- }
6101
- function getEndpointConfig(path45) {
6102
- for (const excluded of EXCLUDED_PATHS) {
6103
- if (matchPath(excluded, path45)) {
6104
- return null;
6105
- }
6106
- }
6107
- const normalizedPath = path45.replace(/\/$/, "");
6108
- if (!normalizedPath.endsWith("/*") && Object.prototype.hasOwnProperty.call(ENDPOINT_CONFIGS, normalizedPath)) {
6109
- return ENDPOINT_CONFIGS[normalizedPath];
6110
- }
6111
- const sortedPatterns = Object.keys(ENDPOINT_CONFIGS).sort((a, b) => b.length - a.length);
6112
- for (const pattern of sortedPatterns) {
6113
- if (matchPath(pattern, path45)) {
6114
- return ENDPOINT_CONFIGS[pattern];
6115
- }
6116
- }
6117
- return { tier: "STANDARD" };
6118
- }
6119
- var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
6120
- var init_chunk_Z2SC7EVO = __esm({
6121
- "../../packages/core/dist/chunk-Z2SC7EVO.js"() {
5733
+ // ../../packages/core/dist/chunk-J3UZCMO6.js
5734
+ function matchPath(pattern, path45) {
5735
+ const pathSegments2 = path45.replace(/\/$/, "").split("/");
5736
+ const isPrefix = pattern.endsWith("/*");
5737
+ const patternSegments = (isPrefix ? pattern.slice(0, -2) : pattern).split("/");
5738
+ if (isPrefix ? pathSegments2.length < patternSegments.length : pathSegments2.length !== patternSegments.length) {
5739
+ return false;
5740
+ }
5741
+ return patternSegments.every((segment, i) => segment === "*" ? pathSegments2[i] !== "" : segment === pathSegments2[i]);
5742
+ }
5743
+ function getEndpointConfig(path45) {
5744
+ for (const excluded of EXCLUDED_PATHS) {
5745
+ if (matchPath(excluded, path45)) {
5746
+ return null;
5747
+ }
5748
+ }
5749
+ const normalizedPath = path45.replace(/\/$/, "");
5750
+ if (!normalizedPath.endsWith("/*") && Object.prototype.hasOwnProperty.call(ENDPOINT_CONFIGS, normalizedPath)) {
5751
+ return ENDPOINT_CONFIGS[normalizedPath];
5752
+ }
5753
+ const sortedPatterns = Object.keys(ENDPOINT_CONFIGS).sort((a, b) => b.length - a.length);
5754
+ for (const pattern of sortedPatterns) {
5755
+ if (matchPath(pattern, path45)) {
5756
+ return ENDPOINT_CONFIGS[pattern];
5757
+ }
5758
+ }
5759
+ return { tier: "STANDARD" };
5760
+ }
5761
+ var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
5762
+ var init_chunk_J3UZCMO6 = __esm({
5763
+ "../../packages/core/dist/chunk-J3UZCMO6.js"() {
6122
5764
  "use strict";
6123
5765
  init_chunk_5XEJSR22();
6124
5766
  ENDPOINT_CONFIGS = {
@@ -6596,7 +6238,7 @@ var init_chunk_Z2SC7EVO = __esm({
6596
6238
  }
6597
6239
  });
6598
6240
 
6599
- // ../../packages/core/dist/chunk-ZAFNUHAY.js
6241
+ // ../../packages/core/dist/chunk-EKMLVJJ7.js
6600
6242
  function fileSnapshotChanged(run) {
6601
6243
  return run.written + run.removed > 0;
6602
6244
  }
@@ -6637,10 +6279,10 @@ async function sendWithRetry(opts, cursor) {
6637
6279
  }
6638
6280
  }
6639
6281
  var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
6640
- var init_chunk_ZAFNUHAY = __esm({
6641
- "../../packages/core/dist/chunk-ZAFNUHAY.js"() {
6282
+ var init_chunk_EKMLVJJ7 = __esm({
6283
+ "../../packages/core/dist/chunk-EKMLVJJ7.js"() {
6642
6284
  "use strict";
6643
- init_chunk_Z2SC7EVO();
6285
+ init_chunk_J3UZCMO6();
6644
6286
  init_chunk_5XEJSR22();
6645
6287
  init_zod();
6646
6288
  rekorFileSnapshotAnswerSchema = external_exports.object({
@@ -6663,6 +6305,581 @@ var init_chunk_ZAFNUHAY = __esm({
6663
6305
  }
6664
6306
  });
6665
6307
 
6308
+ // ../../packages/core/dist/chunk-IPDOHAZ5.js
6309
+ var reportSourceSchema, intakeReportSourceSchema, reportClassificationSchema, reportStatusSchema, reportLocaleSchema, reportMessageAuthorRoleSchema, reportMessageSchema, sentryRefStatusSchema, createReportBody, editReportBody, reporterReportSummarySchema, reporterListResponseSchema, getReportResponseSchema, reporterTransitionResponseSchema, contestReportBody, reporterListQuery, listReportsQuery, GITHUB_ISSUE_URL_REGEX, githubIssueUrlSchema, transitionReportBody, groupReportsBody, holdReportBody;
6310
+ var init_chunk_IPDOHAZ5 = __esm({
6311
+ "../../packages/core/dist/chunk-IPDOHAZ5.js"() {
6312
+ "use strict";
6313
+ init_chunk_HZ6CADSY();
6314
+ init_zod();
6315
+ reportSourceSchema = external_exports.enum(["sentry", "cli", "review", "security_audit"]);
6316
+ intakeReportSourceSchema = external_exports.enum(["cli", "review", "security_audit"]);
6317
+ reportClassificationSchema = external_exports.enum(["bug", "flaky_test", "security", "enhancement"]);
6318
+ reportStatusSchema = external_exports.enum([
6319
+ "pending",
6320
+ "grouped",
6321
+ "escalated",
6322
+ "shipped",
6323
+ "contested",
6324
+ "addressed",
6325
+ "dismissed"
6326
+ ]);
6327
+ reportLocaleSchema = external_exports.enum(["en", "pt", "es"]);
6328
+ reportMessageAuthorRoleSchema = external_exports.enum(["reporter", "triage", "fixer", "system"]);
6329
+ reportMessageSchema = external_exports.object({
6330
+ message_id: external_exports.string(),
6331
+ author_role: reportMessageAuthorRoleSchema,
6332
+ /** The status transition this note accompanied (e.g. 'shipped'); null for a free/system note. */
6333
+ transition: external_exports.string().nullable(),
6334
+ body: external_exports.string(),
6335
+ created_at: timestampSchema,
6336
+ /**
6337
+ * Visibility: `false` = reporter-facing (the default for every narrative entry); `true` =
6338
+ * triage-internal (e.g. a `hold` rationale) — surfaced to platform admins only and NEVER
6339
+ * returned on the reporter read path. The reporter's `GET /api/reports/:id` filters these out.
6340
+ */
6341
+ internal: external_exports.boolean()
6342
+ });
6343
+ sentryRefStatusSchema = external_exports.enum(["valid", "not_found", "mismatch", "unverified"]);
6344
+ createReportBody = external_exports.object({
6345
+ title: external_exports.string().min(5).max(256),
6346
+ description: external_exports.string().min(10).max(5e3),
6347
+ steps_to_reproduce: external_exports.string().max(3e3).optional(),
6348
+ error_message: external_exports.string().max(2e3).optional(),
6349
+ // Taxonomy (server defaults: source=cli, classification=bug when absent).
6350
+ source: intakeReportSourceSchema.optional(),
6351
+ classification: reportClassificationSchema.optional(),
6352
+ // Stable dedup key (e.g. "<file>::<test>" for flaky, "<file>:<line>" for
6353
+ // security). When present, the fingerprint uses it instead of the body hash.
6354
+ dedup_key: external_exports.string().min(1).max(256).optional(),
6355
+ // Context fields (auto-captured by the CLI)
6356
+ organization_id: external_exports.string().optional(),
6357
+ hub_id: external_exports.string().uuid().optional(),
6358
+ hub_name: external_exports.string().max(256).optional(),
6359
+ conversation_id: external_exports.string().uuid().optional(),
6360
+ agent_id: external_exports.string().uuid().optional(),
6361
+ agent_name: external_exports.string().max(256).optional(),
6362
+ client_version: external_exports.string().max(64).optional(),
6363
+ additional_context: external_exports.string().max(2e3).optional()
6364
+ });
6365
+ editReportBody = external_exports.object({
6366
+ title: external_exports.string().min(5).max(256).optional(),
6367
+ description: external_exports.string().min(10).max(5e3).optional(),
6368
+ steps_to_reproduce: external_exports.string().max(3e3).optional(),
6369
+ error_message: external_exports.string().max(2e3).optional(),
6370
+ additional_context: external_exports.string().max(2e3).optional()
6371
+ }).strict().refine((b) => Object.keys(b).length > 0, {
6372
+ message: "at least one field must be provided"
6373
+ });
6374
+ reporterReportSummarySchema = external_exports.object({
6375
+ report_id: external_exports.string(),
6376
+ title: external_exports.string(),
6377
+ description: external_exports.string(),
6378
+ classification: reportClassificationSchema,
6379
+ status: reportStatusSchema,
6380
+ created_at: timestampSchema,
6381
+ triaged_at: timestampSchema.nullable(),
6382
+ resolved_at: timestampSchema.nullable(),
6383
+ /** How many times the reporter has contested (gates the hard cap). */
6384
+ contest_count: external_exports.number(),
6385
+ /** True once triage issued a non-contestable (final) dismissal. */
6386
+ dismissal_final: external_exports.boolean()
6387
+ });
6388
+ reporterListResponseSchema = external_exports.object({
6389
+ data: external_exports.array(reporterReportSummarySchema)
6390
+ });
6391
+ getReportResponseSchema = external_exports.object({
6392
+ report: reporterReportSummarySchema,
6393
+ messages: external_exports.array(reportMessageSchema)
6394
+ });
6395
+ reporterTransitionResponseSchema = external_exports.object({
6396
+ report: reporterReportSummarySchema
6397
+ });
6398
+ contestReportBody = external_exports.object({
6399
+ reason: external_exports.string().min(1).max(5e3)
6400
+ });
6401
+ reporterListQuery = external_exports.object({
6402
+ status: reportStatusSchema.optional()
6403
+ });
6404
+ listReportsQuery = external_exports.object({
6405
+ status: reportStatusSchema.optional(),
6406
+ source: reportSourceSchema.optional(),
6407
+ limit: external_exports.coerce.number().int().min(1).max(200).optional(),
6408
+ offset: external_exports.coerce.number().int().min(0).optional(),
6409
+ /** ISO 8601 lower bound on created_at. */
6410
+ since: external_exports.string().datetime().optional(),
6411
+ /**
6412
+ * ISO 8601 lower bound on resolution time — "what did we resolve recently", which `since`
6413
+ * (a created_at filter) cannot answer for a long-lived report resolved yesterday. Implies
6414
+ * a terminal status (`addressed`/`dismissed`) and orders on that same axis.
6415
+ */
6416
+ resolved_since: external_exports.string().datetime().optional()
6417
+ });
6418
+ GITHUB_ISSUE_URL_REGEX = /^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+(?:[/?#]|$)/;
6419
+ githubIssueUrlSchema = external_exports.string().url().refine((u) => GITHUB_ISSUE_URL_REGEX.test(u), {
6420
+ message: "must be an https://github.com/<owner>/<repo>/issues/<number> URL"
6421
+ });
6422
+ transitionReportBody = external_exports.discriminatedUnion("target", [
6423
+ external_exports.object({
6424
+ target: external_exports.literal("escalated"),
6425
+ gh_issue_url: githubIssueUrlSchema,
6426
+ ai_verdict: external_exports.string().max(2e3).optional()
6427
+ }),
6428
+ external_exports.object({
6429
+ target: external_exports.literal("shipped"),
6430
+ note: external_exports.string().min(1).max(2e3).optional()
6431
+ }),
6432
+ external_exports.object({
6433
+ target: external_exports.literal("addressed")
6434
+ }),
6435
+ external_exports.object({
6436
+ target: external_exports.literal("dismissed"),
6437
+ dismissal_reason: external_exports.string().min(1).max(5e3),
6438
+ ai_verdict: external_exports.string().max(2e3).optional(),
6439
+ final: external_exports.boolean().optional()
6440
+ })
6441
+ ]);
6442
+ groupReportsBody = external_exports.object({
6443
+ member_ids: external_exports.array(external_exports.string().uuid()).min(1).max(100)
6444
+ });
6445
+ holdReportBody = external_exports.object({
6446
+ reason: external_exports.string().min(1).max(5e3)
6447
+ });
6448
+ }
6449
+ });
6450
+
6451
+ // ../../packages/core/dist/chunk-GPM7PE44.js
6452
+ var bootstrapQuery;
6453
+ var init_chunk_GPM7PE44 = __esm({
6454
+ "../../packages/core/dist/chunk-GPM7PE44.js"() {
6455
+ "use strict";
6456
+ init_zod();
6457
+ bootstrapQuery = external_exports.object({
6458
+ active_hub_id: external_exports.string().uuid().optional(),
6459
+ active_conversation_id: external_exports.string().uuid().optional(),
6460
+ active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
6461
+ /**
6462
+ * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
6463
+ * preloads it as `people.active_thread` when the viewer is a member.
6464
+ */
6465
+ active_thread_id: external_exports.string().uuid().optional()
6466
+ });
6467
+ }
6468
+ });
6469
+
6470
+ // ../../packages/core/dist/chunk-5VL6LBFD.js
6471
+ var PERMISSIONS;
6472
+ var init_chunk_5VL6LBFD = __esm({
6473
+ "../../packages/core/dist/chunk-5VL6LBFD.js"() {
6474
+ "use strict";
6475
+ PERMISSIONS = [
6476
+ "hub:read",
6477
+ "hub:write",
6478
+ "hub:admin",
6479
+ "conversation:read",
6480
+ "conversation:write",
6481
+ "analytics:read",
6482
+ "billing:read",
6483
+ "billing:write",
6484
+ "org:read",
6485
+ "org:write",
6486
+ "org:admin",
6487
+ "contacts:write",
6488
+ "platform:admin",
6489
+ "*"
6490
+ ];
6491
+ }
6492
+ });
6493
+
6494
+ // ../../packages/core/dist/chunk-VEERWOZ6.js
6495
+ var MAX_NAME_LENGTH2, MAX_HUBS_PER_GRANT, MAX_HUB_TAGS_PER_GRANT, MAX_GRANTS, permissionEnum, grantScopeSchema, grantSchema, createTokenBody, tokenOrgIdParam;
6496
+ var init_chunk_VEERWOZ6 = __esm({
6497
+ "../../packages/core/dist/chunk-VEERWOZ6.js"() {
6498
+ "use strict";
6499
+ init_chunk_5VL6LBFD();
6500
+ init_chunk_HZ6CADSY();
6501
+ init_zod();
6502
+ MAX_NAME_LENGTH2 = 100;
6503
+ MAX_HUBS_PER_GRANT = 50;
6504
+ MAX_HUB_TAGS_PER_GRANT = 20;
6505
+ MAX_GRANTS = 20;
6506
+ permissionEnum = external_exports.enum(PERMISSIONS).refine(
6507
+ (p) => p !== "platform:admin",
6508
+ { message: "platform:admin cannot be delegated via token creation" }
6509
+ );
6510
+ grantScopeSchema = external_exports.object({
6511
+ // Required: every token grant must declare its org tenancy. The handler
6512
+ // also strict-checks this as defense-in-depth, but failing at the Zod
6513
+ // boundary keeps the generated client type honest (org_id: string).
6514
+ org_id: external_exports.string().min(1),
6515
+ hubs: external_exports.array(external_exports.string().min(1)).min(1, "Each grant must have scope.hubs as a non-empty array").max(MAX_HUBS_PER_GRANT),
6516
+ hub_tags: external_exports.array(external_exports.string().min(1)).min(1, "scope.hub_tags must be a non-empty array if provided").max(MAX_HUB_TAGS_PER_GRANT).optional(),
6517
+ environments: external_exports.array(external_exports.enum(["production", "preview"])).min(1, "scope.environments must be a non-empty array if provided").optional()
6518
+ }).strict();
6519
+ grantSchema = external_exports.object({
6520
+ scope: grantScopeSchema,
6521
+ permissions: external_exports.array(permissionEnum).min(1, "Each grant must have permissions as a non-empty array")
6522
+ }).strict();
6523
+ createTokenBody = external_exports.object({
6524
+ name: external_exports.string().trim().min(1, "name is required").max(MAX_NAME_LENGTH2, `name must be ${MAX_NAME_LENGTH2} characters or fewer`),
6525
+ grants: external_exports.array(grantSchema).min(1, "grants must be a non-empty array").max(MAX_GRANTS),
6526
+ expires_at: external_exports.string().datetime({ message: "expires_at must be a valid ISO 8601 date" }).refine(
6527
+ (s) => new Date(s).getTime() > Date.now(),
6528
+ { message: "expires_at must be in the future" }
6529
+ ).optional()
6530
+ });
6531
+ tokenOrgIdParam = external_exports.object({ orgId: uuidSchema });
6532
+ }
6533
+ });
6534
+
6535
+ // ../../packages/core/dist/chunk-ZVXO3XL6.js
6536
+ 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;
6537
+ var init_chunk_ZVXO3XL6 = __esm({
6538
+ "../../packages/core/dist/chunk-ZVXO3XL6.js"() {
6539
+ "use strict";
6540
+ init_chunk_HZ6CADSY();
6541
+ init_zod();
6542
+ PEOPLE_CONTACT_PAGE_MAX = 100;
6543
+ PEOPLE_CONTACT_PAGE_DEFAULT = 50;
6544
+ PEOPLE_CONTACT_EMAIL_MAX_LENGTH = 254;
6545
+ peopleUserIdSchema = external_exports.string().max(64).regex(USER_ID_REGEX, "must be a user id");
6546
+ peopleInviteEmailSchema = external_exports.string().trim().max(PEOPLE_CONTACT_EMAIL_MAX_LENGTH).email();
6547
+ peopleContactInviteBody = external_exports.object({
6548
+ email: peopleInviteEmailSchema
6549
+ }).strict();
6550
+ peopleContactInviteIdParam = external_exports.object({ inviteId: uuidSchema });
6551
+ peopleContactUserIdParam = external_exports.object({ userId: peopleUserIdSchema });
6552
+ 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, {
6553
+ message: "Name a thread or a community, not both",
6554
+ path: ["community_id"]
6555
+ });
6556
+ peopleContactPageQuery = external_exports.object({
6557
+ cursor: external_exports.string().min(1).max(256).optional(),
6558
+ limit: external_exports.coerce.number().int().min(1).max(PEOPLE_CONTACT_PAGE_MAX).default(PEOPLE_CONTACT_PAGE_DEFAULT)
6559
+ });
6560
+ peopleOutgoingInviteSchema = external_exports.object({
6561
+ invite_id: uuidSchema,
6562
+ email: external_exports.string(),
6563
+ status: external_exports.literal("sent"),
6564
+ created_at: timestampSchema,
6565
+ expires_at: timestampSchema
6566
+ }).strict();
6567
+ peopleContactPersonSchema = external_exports.object({
6568
+ user_id: peopleUserIdSchema,
6569
+ display_name: external_exports.string().nullable(),
6570
+ email: external_exports.string().nullable()
6571
+ }).strict();
6572
+ peopleContactSchema = peopleContactPersonSchema.extend({ contact_since: timestampSchema, thread_id: uuidSchema }).strict();
6573
+ peopleIncomingInviteSchema = external_exports.object({
6574
+ invite_id: uuidSchema,
6575
+ inviter: peopleContactPersonSchema,
6576
+ created_at: timestampSchema,
6577
+ expires_at: timestampSchema
6578
+ }).strict();
6579
+ peopleBlockedUserSchema = peopleContactPersonSchema.extend({ blocked_at: timestampSchema, deleted_user: external_exports.boolean() }).strict();
6580
+ }
6581
+ });
6582
+
6583
+ // ../../packages/core/dist/chunk-ZXK6N2HN.js
6584
+ 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;
6585
+ var init_chunk_ZXK6N2HN = __esm({
6586
+ "../../packages/core/dist/chunk-ZXK6N2HN.js"() {
6587
+ "use strict";
6588
+ init_chunk_ZVXO3XL6();
6589
+ init_chunk_HZ6CADSY();
6590
+ init_zod();
6591
+ PEOPLE_MODERATION_NOTE_MAX_LENGTH = 500;
6592
+ ADMIN_PEOPLE_REPORTS_PAGE_MAX = 100;
6593
+ ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT = 50;
6594
+ PEOPLE_SUSPENDED_REASON = "suspended";
6595
+ peopleModerationActionSchema = external_exports.enum(["remove_message", "suspend", "unsuspend", "dismiss"]);
6596
+ moderationNoteSchema = optionalTrimmedText(PEOPLE_MODERATION_NOTE_MAX_LENGTH);
6597
+ adminPeopleReportListQuery = external_exports.object({
6598
+ pending: external_exports.enum(["true", "false"]).optional().transform((value) => value === "true"),
6599
+ /** Lower bound on `created_at`. */
6600
+ since: timestampSchema.optional(),
6601
+ limit: external_exports.coerce.number().int().min(1).max(ADMIN_PEOPLE_REPORTS_PAGE_MAX).default(ADMIN_PEOPLE_REPORTS_PAGE_DEFAULT),
6602
+ offset: external_exports.coerce.number().int().min(0).default(0)
6603
+ });
6604
+ adminPeopleReportIdParam = external_exports.object({ reportId: uuidSchema });
6605
+ adminPeopleMessageRemovalBody = external_exports.object({ report_id: uuidSchema, message_id: uuidSchema.optional(), note: moderationNoteSchema }).strict();
6606
+ adminPeopleSuspendBody = external_exports.object({ report_id: uuidSchema.optional(), note: moderationNoteSchema }).strict();
6607
+ adminPeopleNoteBody = external_exports.object({ note: moderationNoteSchema }).strict();
6608
+ }
6609
+ });
6610
+
6611
+ // ../../packages/core/dist/chunk-Y7CFCYX4.js
6612
+ var PEOPLE_REPORT_DETAILS_MAX_LENGTH, peopleReportReasonSchema, reportDetailsSchema, reportFields, peopleReportBody;
6613
+ var init_chunk_Y7CFCYX4 = __esm({
6614
+ "../../packages/core/dist/chunk-Y7CFCYX4.js"() {
6615
+ "use strict";
6616
+ init_chunk_ZVXO3XL6();
6617
+ init_chunk_HZ6CADSY();
6618
+ init_zod();
6619
+ PEOPLE_REPORT_DETAILS_MAX_LENGTH = 500;
6620
+ peopleReportReasonSchema = external_exports.enum(["spam", "harassment", "hate", "sexual", "violence", "other"]);
6621
+ reportDetailsSchema = optionalTrimmedText(PEOPLE_REPORT_DETAILS_MAX_LENGTH);
6622
+ reportFields = { reason: peopleReportReasonSchema, details: reportDetailsSchema };
6623
+ peopleReportBody = external_exports.discriminatedUnion("target", [
6624
+ external_exports.object({ target: external_exports.literal("message"), thread_id: uuidSchema, message_id: uuidSchema, ...reportFields }).strict(),
6625
+ external_exports.object({ target: external_exports.literal("thread"), thread_id: uuidSchema, ...reportFields }).strict(),
6626
+ external_exports.object({ target: external_exports.literal("user"), user_id: peopleUserIdSchema, thread_id: uuidSchema.optional(), ...reportFields }).strict(),
6627
+ external_exports.object({
6628
+ target: external_exports.literal("community_message"),
6629
+ community_id: uuidSchema,
6630
+ room_id: uuidSchema,
6631
+ message_id: uuidSchema,
6632
+ ...reportFields
6633
+ }).strict(),
6634
+ external_exports.object({ target: external_exports.literal("community_member"), community_id: uuidSchema, user_id: peopleUserIdSchema, ...reportFields }).strict()
6635
+ ]);
6636
+ }
6637
+ });
6638
+
6639
+ // ../../packages/core/dist/chunk-LIDKVVXZ.js
6640
+ function normalizeContactPhone(raw) {
6641
+ const compact = raw.trim().replace(/[\s\-.()]/g, "");
6642
+ const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
6643
+ return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
6644
+ }
6645
+ function normalizeContactLabel(raw) {
6646
+ return raw.trim().replace(/\s+/g, " ").toLowerCase();
6647
+ }
6648
+ function importRowLabels(row, batchLabels) {
6649
+ return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
6650
+ }
6651
+ 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, CONTACT_CUSTOMER_BASE_ID_PATTERN, baseId, recordId, linkContactCustomerBody, unlinkContactCustomerQuery, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
6652
+ var init_chunk_LIDKVVXZ = __esm({
6653
+ "../../packages/core/dist/chunk-LIDKVVXZ.js"() {
6654
+ "use strict";
6655
+ init_zod();
6656
+ CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
6657
+ CONTACT_NAME_MAX = 200;
6658
+ CONTACT_EMAIL_MAX = 320;
6659
+ CONTACT_PHONE_INPUT_MAX = 40;
6660
+ CONTACT_INSTAGRAM_SID_MAX = 64;
6661
+ CONTACT_METADATA_MAX_BYTES = 4096;
6662
+ CONTACT_LABEL_MAX = 64;
6663
+ CONTACT_LABELS_MAX = 20;
6664
+ CONTACT_SCOPE_TAGS_MAX = 20;
6665
+ CONTACT_PAGE_MAX = 100;
6666
+ CONTACT_IMPORT_BATCH_MAX = 500;
6667
+ CONTACT_SEARCH_MAX = 100;
6668
+ CONTACT_LIST_NAME_MAX = 64;
6669
+ CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
6670
+ CONTACT_LIST_DESCRIPTION_MAX = 1e3;
6671
+ CONTACT_LIST_FILTER_MAX = 20;
6672
+ CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
6673
+ SUPPRESSION_SCOPES = ["all", "marketing"];
6674
+ SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
6675
+ contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
6676
+ contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
6677
+ const phone = normalizeContactPhone(raw);
6678
+ if (phone === null) {
6679
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
6680
+ return external_exports.NEVER;
6681
+ }
6682
+ return phone;
6683
+ });
6684
+ contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
6685
+ contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
6686
+ contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label2) => label2.length > 0, "A label cannot be empty").refine((label2) => !label2.includes(","), "A label cannot contain a comma");
6687
+ contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
6688
+ contactMetadata = external_exports.record(external_exports.unknown()).refine(
6689
+ (metadata) => new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES,
6690
+ `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`
6691
+ );
6692
+ scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
6693
+ contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
6694
+ external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
6695
+ external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
6696
+ ]);
6697
+ hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
6698
+ IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
6699
+ contactBookOrgQuery = external_exports.object({
6700
+ organization_id: external_exports.string().uuid()
6701
+ });
6702
+ contactBookContactParam = external_exports.object({
6703
+ contactId: external_exports.string().uuid()
6704
+ });
6705
+ contactBookListParam = external_exports.object({
6706
+ listId: external_exports.string().uuid()
6707
+ });
6708
+ contactBookHubParam = external_exports.object({
6709
+ hubId: external_exports.string().uuid()
6710
+ });
6711
+ contactBookPageQuery = external_exports.object({
6712
+ cursor: external_exports.string().max(2048).optional(),
6713
+ limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
6714
+ });
6715
+ listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
6716
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
6717
+ label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
6718
+ scope_tag_id: external_exports.string().uuid().optional()
6719
+ });
6720
+ listHubContactBookContactsQuery = contactBookPageQuery.extend({
6721
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
6722
+ });
6723
+ contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
6724
+ email: contactEmail
6725
+ });
6726
+ listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6727
+ contactRowFields = {
6728
+ name: contactName,
6729
+ phone: contactPhone.nullish(),
6730
+ email: contactEmail.nullish(),
6731
+ instagram_sid: contactInstagramSid.nullish(),
6732
+ labels: contactLabels.optional(),
6733
+ metadata: contactMetadata.optional()
6734
+ };
6735
+ createContactBookContactBody = external_exports.object({
6736
+ organization_id: external_exports.string().uuid(),
6737
+ ...contactRowFields,
6738
+ visibility: contactVisibilitySchema,
6739
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6740
+ }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6741
+ updateContactBookContactBody = external_exports.object({
6742
+ name: contactName.optional(),
6743
+ phone: contactPhone.nullable().optional(),
6744
+ email: contactEmail.nullable().optional(),
6745
+ instagram_sid: contactInstagramSid.nullable().optional(),
6746
+ labels: contactLabels.optional(),
6747
+ metadata: contactMetadata.optional(),
6748
+ visibility: contactVisibilitySchema.optional(),
6749
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6750
+ }).strict();
6751
+ contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6752
+ importContactBookContactsBody = external_exports.object({
6753
+ organization_id: external_exports.string().uuid(),
6754
+ visibility: contactVisibilitySchema,
6755
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
6756
+ labels: contactLabels.optional(),
6757
+ rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
6758
+ }).strict().superRefine((batch, ctx) => {
6759
+ batch.rows.forEach((row, index) => {
6760
+ if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
6761
+ ctx.addIssue({
6762
+ code: external_exports.ZodIssueCode.custom,
6763
+ path: ["rows", index, "labels"],
6764
+ message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
6765
+ });
6766
+ }
6767
+ });
6768
+ });
6769
+ linkContactBookContactBody = external_exports.object({
6770
+ user_id: external_exports.string().min(1).max(128)
6771
+ }).strict();
6772
+ CONTACT_CUSTOMER_BASE_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
6773
+ baseId = external_exports.string().regex(CONTACT_CUSTOMER_BASE_ID_PATTERN, { message: "Must be a base id" });
6774
+ recordId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_\-.:]{0,254}$/, { message: "Must be a record id" });
6775
+ linkContactCustomerBody = external_exports.object({
6776
+ base_id: baseId,
6777
+ record_id: recordId
6778
+ }).strict();
6779
+ unlinkContactCustomerQuery = contactBookOrgQuery.extend({
6780
+ base_id: baseId
6781
+ });
6782
+ listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
6783
+ message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
6784
+ });
6785
+ contactListFilterSchema = external_exports.object({
6786
+ labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
6787
+ scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
6788
+ }).strict();
6789
+ createContactBookListBody = external_exports.object({
6790
+ organization_id: external_exports.string().uuid(),
6791
+ name: listName,
6792
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
6793
+ filter: contactListFilterSchema.optional()
6794
+ }).strict();
6795
+ updateContactBookListBody = external_exports.object({
6796
+ name: listName.optional(),
6797
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
6798
+ filter: contactListFilterSchema.optional()
6799
+ }).strict();
6800
+ updateContactBookListPinsBody = external_exports.object({
6801
+ add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
6802
+ remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
6803
+ }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
6804
+ suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
6805
+ external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
6806
+ external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
6807
+ external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
6808
+ ]);
6809
+ createContactBookSuppressionBody = external_exports.object({
6810
+ organization_id: external_exports.string().uuid(),
6811
+ identity: suppressionIdentitySchema,
6812
+ scope: external_exports.enum(SUPPRESSION_SCOPES)
6813
+ }).strict();
6814
+ contactBookSuppressionParam = external_exports.object({
6815
+ suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
6816
+ });
6817
+ listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6818
+ contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
6819
+ contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
6820
+ orgListReferenceSchema = listName;
6821
+ }
6822
+ });
6823
+
6824
+ // ../../packages/core/dist/chunk-DGTJX3C4.js
6825
+ var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_DENY_PAGE_MAX, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery;
6826
+ var init_chunk_DGTJX3C4 = __esm({
6827
+ "../../packages/core/dist/chunk-DGTJX3C4.js"() {
6828
+ "use strict";
6829
+ init_chunk_LIDKVVXZ();
6830
+ init_zod();
6831
+ PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
6832
+ CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
6833
+ PERSON_DENY_PAGE_MAX = 100;
6834
+ PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
6835
+ userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
6836
+ personIdSchema = external_exports.string().refine(
6837
+ (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
6838
+ { message: PERSON_ID_FORM_MESSAGE }
6839
+ );
6840
+ personParam = external_exports.object({
6841
+ personId: userPersonIdSchema
6842
+ });
6843
+ personLinkParam = personParam.extend({
6844
+ targetId: personIdSchema
6845
+ });
6846
+ deniedPersonParam = external_exports.object({
6847
+ personId: personIdSchema
6848
+ });
6849
+ listDeniedPersonsQuery = contactBookOrgQuery.extend({
6850
+ cursor: personIdSchema.optional(),
6851
+ limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
6852
+ });
6853
+ }
6854
+ });
6855
+
6856
+ // ../../packages/core/dist/chunk-5DGHIY7L.js
6857
+ var rekorBaseChangeMessageSchema;
6858
+ var init_chunk_5DGHIY7L = __esm({
6859
+ "../../packages/core/dist/chunk-5DGHIY7L.js"() {
6860
+ "use strict";
6861
+ init_zod();
6862
+ rekorBaseChangeMessageSchema = external_exports.object({
6863
+ /** The WayAI org UUID — one id namespace. */
6864
+ org_id: external_exports.string().uuid(),
6865
+ /**
6866
+ * Not a UUID: a preview base id is `{prod_base_id}--{slug}`. Immutable per base — a
6867
+ * preview clone is its OWN base_id — so `(base_id, scope)` keys never collide across
6868
+ * environments. Empty is never a real base id, so it is non-conforming rather than a
6869
+ * frame keyed on nothing.
6870
+ */
6871
+ base_id: external_exports.string().min(1),
6872
+ /**
6873
+ * Rides along so the client scopes its refetch without a lookup; the inspector scopes
6874
+ * by side.
6875
+ */
6876
+ environment: external_exports.enum(["production", "preview"]),
6877
+ /** Which pane refetches. `base` covers create/delete/promote/config changes. */
6878
+ scope: external_exports.enum(["records", "record_types", "files", "base"])
6879
+ });
6880
+ }
6881
+ });
6882
+
6666
6883
  // ../../packages/core/dist/chunk-YUZFHVB2.js
6667
6884
  var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
6668
6885
  var init_chunk_YUZFHVB2 = __esm({
@@ -7456,14 +7673,14 @@ var init_chunk_WEXVYJ5H = __esm({
7456
7673
  });
7457
7674
 
7458
7675
  // ../../packages/core/dist/chunk-VFDRJV2E.js
7459
- function utf8ByteLength(text3) {
7676
+ function utf8ByteLength(text4) {
7460
7677
  let bytes = 0;
7461
- for (let i = 0; i < text3.length; i++) {
7462
- const code = text3.charCodeAt(i);
7678
+ for (let i = 0; i < text4.length; i++) {
7679
+ const code = text4.charCodeAt(i);
7463
7680
  if (code < 128) bytes += 1;
7464
7681
  else if (code < 2048) bytes += 2;
7465
- else if (code >= 55296 && code <= 56319 && i + 1 < text3.length) {
7466
- const next = text3.charCodeAt(i + 1);
7682
+ else if (code >= 55296 && code <= 56319 && i + 1 < text4.length) {
7683
+ const next = text4.charCodeAt(i + 1);
7467
7684
  if (next >= 56320 && next <= 57343) {
7468
7685
  bytes += 4;
7469
7686
  i += 1;
@@ -11656,191 +11873,6 @@ var init_chunk_IR2NOSI3 = __esm({
11656
11873
  }
11657
11874
  });
11658
11875
 
11659
- // ../../packages/core/dist/chunk-THM6ALTK.js
11660
- function normalizeContactPhone(raw) {
11661
- const compact = raw.trim().replace(/[\s\-.()]/g, "");
11662
- const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
11663
- return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
11664
- }
11665
- function normalizeContactLabel(raw) {
11666
- return raw.trim().replace(/\s+/g, " ").toLowerCase();
11667
- }
11668
- function importRowLabels(row, batchLabels) {
11669
- return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
11670
- }
11671
- 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, CONTACT_CUSTOMER_BASE_ID_PATTERN, baseId, recordId, linkContactCustomerBody, unlinkContactCustomerQuery, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
11672
- var init_chunk_THM6ALTK = __esm({
11673
- "../../packages/core/dist/chunk-THM6ALTK.js"() {
11674
- "use strict";
11675
- init_zod();
11676
- CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
11677
- CONTACT_NAME_MAX = 200;
11678
- CONTACT_EMAIL_MAX = 320;
11679
- CONTACT_PHONE_INPUT_MAX = 40;
11680
- CONTACT_INSTAGRAM_SID_MAX = 64;
11681
- CONTACT_METADATA_MAX_BYTES = 4096;
11682
- CONTACT_LABEL_MAX = 64;
11683
- CONTACT_LABELS_MAX = 20;
11684
- CONTACT_SCOPE_TAGS_MAX = 20;
11685
- CONTACT_PAGE_MAX = 100;
11686
- CONTACT_IMPORT_BATCH_MAX = 500;
11687
- CONTACT_SEARCH_MAX = 100;
11688
- CONTACT_LIST_NAME_MAX = 64;
11689
- CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
11690
- CONTACT_LIST_DESCRIPTION_MAX = 1e3;
11691
- CONTACT_LIST_FILTER_MAX = 20;
11692
- CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
11693
- SUPPRESSION_SCOPES = ["all", "marketing"];
11694
- SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
11695
- contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
11696
- contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
11697
- const phone = normalizeContactPhone(raw);
11698
- if (phone === null) {
11699
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
11700
- return external_exports.NEVER;
11701
- }
11702
- return phone;
11703
- });
11704
- contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
11705
- contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
11706
- contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label2) => label2.length > 0, "A label cannot be empty").refine((label2) => !label2.includes(","), "A label cannot contain a comma");
11707
- contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
11708
- contactMetadata = external_exports.record(external_exports.unknown()).refine(
11709
- (metadata) => new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES,
11710
- `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`
11711
- );
11712
- scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
11713
- contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
11714
- external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
11715
- external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
11716
- ]);
11717
- hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
11718
- IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
11719
- contactBookOrgQuery = external_exports.object({
11720
- organization_id: external_exports.string().uuid()
11721
- });
11722
- contactBookContactParam = external_exports.object({
11723
- contactId: external_exports.string().uuid()
11724
- });
11725
- contactBookListParam = external_exports.object({
11726
- listId: external_exports.string().uuid()
11727
- });
11728
- contactBookHubParam = external_exports.object({
11729
- hubId: external_exports.string().uuid()
11730
- });
11731
- contactBookPageQuery = external_exports.object({
11732
- cursor: external_exports.string().max(2048).optional(),
11733
- limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
11734
- });
11735
- listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
11736
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
11737
- label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
11738
- scope_tag_id: external_exports.string().uuid().optional()
11739
- });
11740
- listHubContactBookContactsQuery = contactBookPageQuery.extend({
11741
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
11742
- });
11743
- contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
11744
- email: contactEmail
11745
- });
11746
- listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
11747
- contactRowFields = {
11748
- name: contactName,
11749
- phone: contactPhone.nullish(),
11750
- email: contactEmail.nullish(),
11751
- instagram_sid: contactInstagramSid.nullish(),
11752
- labels: contactLabels.optional(),
11753
- metadata: contactMetadata.optional()
11754
- };
11755
- createContactBookContactBody = external_exports.object({
11756
- organization_id: external_exports.string().uuid(),
11757
- ...contactRowFields,
11758
- visibility: contactVisibilitySchema,
11759
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
11760
- }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
11761
- updateContactBookContactBody = external_exports.object({
11762
- name: contactName.optional(),
11763
- phone: contactPhone.nullable().optional(),
11764
- email: contactEmail.nullable().optional(),
11765
- instagram_sid: contactInstagramSid.nullable().optional(),
11766
- labels: contactLabels.optional(),
11767
- metadata: contactMetadata.optional(),
11768
- visibility: contactVisibilitySchema.optional(),
11769
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
11770
- }).strict();
11771
- contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
11772
- importContactBookContactsBody = external_exports.object({
11773
- organization_id: external_exports.string().uuid(),
11774
- visibility: contactVisibilitySchema,
11775
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
11776
- labels: contactLabels.optional(),
11777
- rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
11778
- }).strict().superRefine((batch, ctx) => {
11779
- batch.rows.forEach((row, index) => {
11780
- if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
11781
- ctx.addIssue({
11782
- code: external_exports.ZodIssueCode.custom,
11783
- path: ["rows", index, "labels"],
11784
- message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
11785
- });
11786
- }
11787
- });
11788
- });
11789
- linkContactBookContactBody = external_exports.object({
11790
- user_id: external_exports.string().min(1).max(128)
11791
- }).strict();
11792
- CONTACT_CUSTOMER_BASE_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
11793
- baseId = external_exports.string().regex(CONTACT_CUSTOMER_BASE_ID_PATTERN, { message: "Must be a base id" });
11794
- recordId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_\-.:]{0,254}$/, { message: "Must be a record id" });
11795
- linkContactCustomerBody = external_exports.object({
11796
- base_id: baseId,
11797
- record_id: recordId
11798
- }).strict();
11799
- unlinkContactCustomerQuery = contactBookOrgQuery.extend({
11800
- base_id: baseId
11801
- });
11802
- listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
11803
- message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
11804
- });
11805
- contactListFilterSchema = external_exports.object({
11806
- labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
11807
- scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
11808
- }).strict();
11809
- createContactBookListBody = external_exports.object({
11810
- organization_id: external_exports.string().uuid(),
11811
- name: listName,
11812
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
11813
- filter: contactListFilterSchema.optional()
11814
- }).strict();
11815
- updateContactBookListBody = external_exports.object({
11816
- name: listName.optional(),
11817
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
11818
- filter: contactListFilterSchema.optional()
11819
- }).strict();
11820
- updateContactBookListPinsBody = external_exports.object({
11821
- add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
11822
- remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
11823
- }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
11824
- suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
11825
- external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
11826
- external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
11827
- external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
11828
- ]);
11829
- createContactBookSuppressionBody = external_exports.object({
11830
- organization_id: external_exports.string().uuid(),
11831
- identity: suppressionIdentitySchema,
11832
- scope: external_exports.enum(SUPPRESSION_SCOPES)
11833
- }).strict();
11834
- contactBookSuppressionParam = external_exports.object({
11835
- suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
11836
- });
11837
- listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
11838
- contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
11839
- contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
11840
- orgListReferenceSchema = listName;
11841
- }
11842
- });
11843
-
11844
11876
  // ../../packages/core/dist/chunk-6J742GLA.js
11845
11877
  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;
11846
11878
  var init_chunk_6J742GLA = __esm({
@@ -11993,12 +12025,12 @@ var init_chunk_6J742GLA = __esm({
11993
12025
  }
11994
12026
  });
11995
12027
 
11996
- // ../../packages/core/dist/chunk-3LLEDXPM.js
12028
+ // ../../packages/core/dist/chunk-PIOPQ5UH.js
11997
12029
  var COMMUNITIES_PER_ORG_MAX, COMMUNITY_NAME_MAX_LENGTH, COMMUNITY_REGISTRY_CLOSED_REASON, COMMUNITY_MEMBERS_MAX, COMMUNITY_ADMISSIONS, COMMUNITY_ACCESS_MAX, COMMUNITY_ACCESS_ADD_MAX, COMMUNITY_ACCESS_FULL_REASON, COMMUNITY_JOIN_SOURCE_MAX_LENGTH, COMMUNITY_JOIN_FLOW_TOKEN_MAX_LENGTH, COMMUNITY_ROOMS_MAX, COMMUNITY_ROOM_NAME_MAX_LENGTH, COMMUNITY_MESSAGE_MAX_LENGTH, COMMUNITY_MESSAGES_PAGE_SIZE, COMMUNITY_ATTACHMENT_URLS_MAX, COMMUNITY_POST_TITLE_MAX_LENGTH, COMMUNITY_POST_SEARCH_MAX_LENGTH, COMMUNITY_MEMBER_STATUSES, COMMUNITY_RULES_MAX_LENGTH, COMMUNITY_SLOW_MODE_MAX_SECONDS, COMMUNITY_COURSES_LABEL_MAX_LENGTH, COMMUNITY_LIVE_TICKET_PREFIX, COMMUNITY_STATS_DAYS, communityNameSchema, adminCreateCommunityBody, communityIdParam, communityJoinTokenSchema, communityJoinSourceSchema, communityJoinPreviewQuery, communityJoinBody, communityRoomKindSchema, communityRoomNameSchema, communityRoomIdParam, communityMessageIdParam, communityRoomCreateBody, communityRoomUpdateBody, communityMessagesQuery, communityMessageBodySchema, communityPostTitleSchema, communityAttachmentUploadSchema, communitySendBody, communityEditBody, communityPostIdParam, communityPostsQuery, communityAnswerBody, communityReadBody, communityAttachmentUrlsBody, communityPersonParam, communityOrgParam, communityPeopleQuery, communityCoursesLabelSchema, communityAdmissionSchema, communitySettingsBody, communityAccessEmailSchema, communityAccessAddBody, communityAccessQuery, communityAccessIdParam, communityBanBody, communityLockBody, communityPinBody, communityModLogQuery, communityReportsQuery, communityReportIdParam, communityLiveTicketSchema, communityLiveQuery, communityMuteBody, communityEmailUnsubscribeTokenSchema, communityEmailUnsubscribeQuery;
11998
- var init_chunk_3LLEDXPM = __esm({
11999
- "../../packages/core/dist/chunk-3LLEDXPM.js"() {
12030
+ var init_chunk_PIOPQ5UH = __esm({
12031
+ "../../packages/core/dist/chunk-PIOPQ5UH.js"() {
12000
12032
  "use strict";
12001
- init_chunk_THM6ALTK();
12033
+ init_chunk_LIDKVVXZ();
12002
12034
  init_chunk_6J742GLA();
12003
12035
  init_chunk_ZVXO3XL6();
12004
12036
  init_chunk_HZ6CADSY();
@@ -12102,7 +12134,7 @@ var init_chunk_3LLEDXPM = __esm({
12102
12134
  }
12103
12135
  });
12104
12136
 
12105
- // ../../packages/core/dist/chunk-FUIWYKHJ.js
12137
+ // ../../packages/core/dist/chunk-7LLIQ4UF.js
12106
12138
  function parseCommunityLessonVideoUrl(url) {
12107
12139
  const parts = /^https?:\/\/([^/?#]+)([^?#]*)(?:\?([^#]*))?(?:#.*)?$/i.exec(url.trim());
12108
12140
  if (!parts) return null;
@@ -12128,10 +12160,10 @@ function communityLessonVideoWatchUrl(video) {
12128
12160
  }
12129
12161
  }
12130
12162
  var COMMUNITY_COURSES_MAX, COMMUNITY_COURSE_MODULES_MAX, COMMUNITY_COURSE_LESSONS_MAX, COMMUNITY_LESSONS_MAX, COMMUNITY_COURSE_TITLE_MAX_LENGTH, COMMUNITY_COURSE_DESCRIPTION_MAX_LENGTH, COMMUNITY_LESSON_BODY_MAX_LENGTH, COMMUNITY_LESSON_LINKS_MAX, COMMUNITY_LESSON_URL_MAX_LENGTH, YOUTUBE_ID, YOUTUBE_HOSTS, YOUTU_BE, YOUTUBE_ID_PATH, communityCourseIdParam, communityCourseModuleIdParam, communityLessonIdParam, communityCourseTitleSchema, communityCourseDescriptionSchema, communityCoursePositionSchema, communityLessonVideoUrlSchema, communityLessonLinkSchema, communityLessonLinksSchema, communityLessonBodySchema, communityCourseCreateBody, communityCourseUpdateBody, communityModuleCreateBody, communityModuleUpdateBody, communityLessonCreateBody, communityLessonUpdateBody;
12131
- var init_chunk_FUIWYKHJ = __esm({
12132
- "../../packages/core/dist/chunk-FUIWYKHJ.js"() {
12163
+ var init_chunk_7LLIQ4UF = __esm({
12164
+ "../../packages/core/dist/chunk-7LLIQ4UF.js"() {
12133
12165
  "use strict";
12134
- init_chunk_3LLEDXPM();
12166
+ init_chunk_PIOPQ5UH();
12135
12167
  init_chunk_HZ6CADSY();
12136
12168
  init_zod();
12137
12169
  COMMUNITY_COURSES_MAX = 20;
@@ -15630,15 +15662,15 @@ var init_chunk_JO53JB35 = __esm({
15630
15662
  }
15631
15663
  });
15632
15664
 
15633
- // ../../packages/core/dist/chunk-PBE4O572.js
15665
+ // ../../packages/core/dist/chunk-WJ7THIFJ.js
15634
15666
  function filterNamesAnything(filter) {
15635
15667
  return filter.labels.length + filter.scope_tag_ids.length > 0;
15636
15668
  }
15637
15669
  var hubListNameSchema, HUB_LIST_FILTER_REQUIRED, hubContactListFilterSchema, hubContactListIdParam, hubContactListHubQuery, description, createHubContactListBody, updateHubContactListBody;
15638
- var init_chunk_PBE4O572 = __esm({
15639
- "../../packages/core/dist/chunk-PBE4O572.js"() {
15670
+ var init_chunk_WJ7THIFJ = __esm({
15671
+ "../../packages/core/dist/chunk-WJ7THIFJ.js"() {
15640
15672
  "use strict";
15641
- init_chunk_THM6ALTK();
15673
+ init_chunk_LIDKVVXZ();
15642
15674
  init_zod();
15643
15675
  hubListNameSchema = orgListReferenceSchema;
15644
15676
  HUB_LIST_FILTER_REQUIRED = "A hub list names at least one label or scope tag";
@@ -15664,13 +15696,13 @@ var init_chunk_PBE4O572 = __esm({
15664
15696
  }
15665
15697
  });
15666
15698
 
15667
- // ../../packages/core/dist/chunk-5PEVI432.js
15699
+ // ../../packages/core/dist/chunk-F4MBPBZX.js
15668
15700
  var AUTOMATION_TRIGGER_TYPES, AUTOMATION_EVENT_TYPES, AUTOMATION_TARGET_TYPES, AUTOMATION_ACTION_TYPES, AUTOMATION_CHANNEL_TYPES, AUTOMATION_PURPOSES, AUTOMATION_NAME_MAX, AUTOMATION_DESCRIPTION_MAX, AUTOMATION_INSTRUCTIONS_MAX, AUTOMATION_TEXT_MAX, AUTOMATION_CRON_MAX, AUTOMATION_WEBHOOK_AUTHS, AUTOMATION_WEBHOOK_HEADERS, AUTOMATION_WEBHOOK_BODY_MAX_BYTES, AUTOMATION_WEBHOOK_HEADER_NAME_MAX, WEBHOOK_RESERVED_HEADERS, automationTriggerSchema, automationTargetSchema, automationActionSchema, automationGateSchema, automationName, automationDescription, automationIdParam, automationHubQuery, automationWebhookParams, AUTOMATION_RUNS_PAGE_MAX, listAutomationRunsQuery, createAutomationBody, updateAutomationBody, AUTOMATION_ALERT_CATEGORIES, AUTOMATION_BLOCKED_ALERT_CATEGORY, automationEventSubscriberParam;
15669
- var init_chunk_5PEVI432 = __esm({
15670
- "../../packages/core/dist/chunk-5PEVI432.js"() {
15701
+ var init_chunk_F4MBPBZX = __esm({
15702
+ "../../packages/core/dist/chunk-F4MBPBZX.js"() {
15671
15703
  "use strict";
15672
- init_chunk_PBE4O572();
15673
- init_chunk_THM6ALTK();
15704
+ init_chunk_WJ7THIFJ();
15705
+ init_chunk_LIDKVVXZ();
15674
15706
  init_chunk_DZNBZNK6();
15675
15707
  init_chunk_5XEJSR22();
15676
15708
  init_chunk_PI55UGBV();
@@ -16109,25 +16141,26 @@ var init_chunk_XXZ4MOE3 = __esm({
16109
16141
  var init_contracts = __esm({
16110
16142
  "../../packages/core/dist/contracts/index.js"() {
16111
16143
  "use strict";
16144
+ init_chunk_YVY2TZK2();
16112
16145
  init_chunk_VXEAR36B();
16113
16146
  init_chunk_RACEDHG6();
16114
16147
  init_chunk_Q7KIQHAZ();
16148
+ init_chunk_HA7CRZMX();
16115
16149
  init_chunk_IPXBFWUU();
16116
16150
  init_chunk_NKLVUTFO();
16117
16151
  init_chunk_WL5QGKHN();
16118
- init_chunk_YVY2TZK2();
16152
+ init_chunk_MF2VVXBR();
16153
+ init_chunk_ZC6YGHNX();
16119
16154
  init_chunk_ACKF2MVU();
16120
16155
  init_chunk_JOPEQ3WP();
16121
- init_chunk_HA7CRZMX();
16122
- init_chunk_MF2VVXBR();
16156
+ init_chunk_EKMLVJJ7();
16123
16157
  init_chunk_IPDOHAZ5();
16124
16158
  init_chunk_GPM7PE44();
16125
16159
  init_chunk_VEERWOZ6();
16126
- init_chunk_ZC6YGHNX();
16127
16160
  init_chunk_ZXK6N2HN();
16128
16161
  init_chunk_Y7CFCYX4();
16162
+ init_chunk_DGTJX3C4();
16129
16163
  init_chunk_5DGHIY7L();
16130
- init_chunk_ZAFNUHAY();
16131
16164
  init_chunk_YUZFHVB2();
16132
16165
  init_chunk_I3O2RACG();
16133
16166
  init_chunk_34LE6P7E();
@@ -16143,8 +16176,8 @@ var init_contracts = __esm({
16143
16176
  init_chunk_EJFKWH32();
16144
16177
  init_chunk_C4HEZ7ZI();
16145
16178
  init_chunk_IR2NOSI3();
16146
- init_chunk_FUIWYKHJ();
16147
- init_chunk_3LLEDXPM();
16179
+ init_chunk_7LLIQ4UF();
16180
+ init_chunk_PIOPQ5UH();
16148
16181
  init_chunk_YULHXJ5M();
16149
16182
  init_chunk_V4FRPRH5();
16150
16183
  init_chunk_LWMLR2WI();
@@ -16175,13 +16208,13 @@ var init_contracts = __esm({
16175
16208
  init_chunk_2PZIF56U();
16176
16209
  init_chunk_UEJOG2Q7();
16177
16210
  init_chunk_JO53JB35();
16178
- init_chunk_5PEVI432();
16179
- init_chunk_PBE4O572();
16180
- init_chunk_THM6ALTK();
16211
+ init_chunk_F4MBPBZX();
16212
+ init_chunk_WJ7THIFJ();
16213
+ init_chunk_LIDKVVXZ();
16181
16214
  init_chunk_DZNBZNK6();
16182
16215
  init_chunk_IG6QBZMA();
16183
16216
  init_chunk_OMPT4ZHR();
16184
- init_chunk_Z2SC7EVO();
16217
+ init_chunk_J3UZCMO6();
16185
16218
  init_chunk_SOJMWM63();
16186
16219
  init_chunk_WTOA3ANF();
16187
16220
  init_chunk_5XEJSR22();
@@ -16322,8 +16355,8 @@ async function uuidV5(namespace, name) {
16322
16355
  const out = digest.slice(0, 16);
16323
16356
  return bytesToUuid(setUuidVersion(out, 5));
16324
16357
  }
16325
- function markdownToPlainText(text3) {
16326
- let result = text3;
16358
+ function markdownToPlainText(text4) {
16359
+ let result = text4;
16327
16360
  result = result.replace(/```[\w]*\n?([\s\S]*?)```/g, "$1");
16328
16361
  result = result.replace(/`([^`]+)`/g, "$1");
16329
16362
  result = result.replace(/\*\*\*(.+?)\*\*\*/g, "$1");
@@ -16342,7 +16375,7 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
16342
16375
  var init_dist = __esm({
16343
16376
  "../../packages/core/dist/index.js"() {
16344
16377
  "use strict";
16345
- init_chunk_Z2SC7EVO();
16378
+ init_chunk_J3UZCMO6();
16346
16379
  init_chunk_SOJMWM63();
16347
16380
  init_chunk_WTOA3ANF();
16348
16381
  init_chunk_5XEJSR22();
@@ -18143,6 +18176,51 @@ var init_api_client = __esm({
18143
18176
  const qs = new URLSearchParams({ organization_id: orgId, base_id: baseId2 });
18144
18177
  return this.request("DELETE", `/api/contact-book/contacts/${encodeURIComponent(contactId)}/customer?${qs}`);
18145
18178
  }
18179
+ // Person links and the deny list (wayai-pro/wayai#5473 §1): a browser sign-in only — each route refuses
18180
+ // an API token. A link takes org:write over the organization; the rest an organization admin.
18181
+ /** Whom a person id names in the organization: the hub where a conversation carries it, and that hub's name and email for them. */
18182
+ async lookupPerson(orgId, personId) {
18183
+ const qs = new URLSearchParams({ organization_id: orgId });
18184
+ return this.request("GET", `/api/contact-book/persons/${encodeURIComponent(personId)}?${qs}`);
18185
+ }
18186
+ /** The person links of the user `personId` names. */
18187
+ async listPersonLinks(orgId, personId) {
18188
+ const qs = new URLSearchParams({ organization_id: orgId });
18189
+ return this.request("GET", `/api/contact-book/persons/${encodeURIComponent(personId)}/links?${qs}`);
18190
+ }
18191
+ /** Link the user `personId` names to `targetId` (a person id or a contact id), copying the target's own links. */
18192
+ async linkPerson(orgId, personId, targetId) {
18193
+ const qs = new URLSearchParams({ organization_id: orgId });
18194
+ return this.request(
18195
+ "PUT",
18196
+ `/api/contact-book/persons/${encodeURIComponent(personId)}/links/${encodeURIComponent(targetId)}?${qs}`
18197
+ );
18198
+ }
18199
+ /** Remove one of the user's person links. */
18200
+ async unlinkPerson(orgId, personId, targetId) {
18201
+ const qs = new URLSearchParams({ organization_id: orgId });
18202
+ return this.request(
18203
+ "DELETE",
18204
+ `/api/contact-book/persons/${encodeURIComponent(personId)}/links/${encodeURIComponent(targetId)}?${qs}`
18205
+ );
18206
+ }
18207
+ /** A page of the organization's deny list, by id. */
18208
+ async listDeniedPersons(orgId, opts = {}) {
18209
+ const qs = new URLSearchParams({ organization_id: orgId });
18210
+ if (opts.cursor !== void 0) qs.set("cursor", opts.cursor);
18211
+ if (opts.limit !== void 0) qs.set("limit", String(opts.limit));
18212
+ return this.request("GET", `/api/contact-book/denied-persons?${qs}`);
18213
+ }
18214
+ /** Deny a person id or contact id for the organization. */
18215
+ async denyPerson(orgId, personId) {
18216
+ const qs = new URLSearchParams({ organization_id: orgId });
18217
+ return this.request("PUT", `/api/contact-book/denied-persons/${encodeURIComponent(personId)}?${qs}`);
18218
+ }
18219
+ /** Lift a denial. */
18220
+ async undenyPerson(orgId, personId) {
18221
+ const qs = new URLSearchParams({ organization_id: orgId });
18222
+ return this.request("DELETE", `/api/contact-book/denied-persons/${encodeURIComponent(personId)}?${qs}`);
18223
+ }
18146
18224
  /**
18147
18225
  * The access set every hub toolset call of an agent sends for a person, or for none (the hub's ∩ the
18148
18226
  * agent's), and the layer that removed each value (#5358 PR 15). Another person's takes an org-admin
@@ -22630,20 +22708,20 @@ function readCss(source, attribute) {
22630
22708
  return { declarations, loads };
22631
22709
  }
22632
22710
  const stack = [];
22633
- let text3 = "";
22711
+ let text4 = "";
22634
22712
  for (const ch of css) {
22635
22713
  if (ch === "{") {
22636
- stack.push({ prelude: text3.trim(), body: "" });
22637
- text3 = "";
22714
+ stack.push({ prelude: text4.trim(), body: "" });
22715
+ text4 = "";
22638
22716
  } else if (ch === "}") {
22639
22717
  const block = stack.pop();
22640
- if (block) declare(block.body + text3, [...stack.map((b) => b.prelude), block.prelude]);
22641
- text3 = "";
22718
+ if (block) declare(block.body + text4, [...stack.map((b) => b.prelude), block.prelude]);
22719
+ text4 = "";
22642
22720
  } else if (ch === ";") {
22643
- if (stack.length > 0) stack[stack.length - 1].body += `${text3};`;
22644
- text3 = "";
22721
+ if (stack.length > 0) stack[stack.length - 1].body += `${text4};`;
22722
+ text4 = "";
22645
22723
  } else {
22646
- text3 += ch;
22724
+ text4 += ch;
22647
22725
  }
22648
22726
  }
22649
22727
  return { declarations, loads };
@@ -22788,7 +22866,7 @@ var init_page_design_lint = __esm({
22788
22866
  LIST_MARKUP = /<(?:ul|ol|table)\b|wayai-list|createElement\(\s*['"`](?:li|tr|ul|ol|table)['"`]/i;
22789
22867
  ZERO_ROWS_CHECK = /\.length\s*(?:===?|<=)\s*0\b|\.length\s*<\s*1\b|!\s*[\w$.[\]]+\.length\b/;
22790
22868
  plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
22791
- shown = (text3) => truncate(sanitizeTerminalText(text3).replace(/\s+/g, " "), 60);
22869
+ shown = (text4) => truncate(sanitizeTerminalText(text4).replace(/\s+/g, " "), 60);
22792
22870
  }
22793
22871
  });
22794
22872
 
@@ -23353,16 +23431,16 @@ function pathSegments(value, label2 = "path") {
23353
23431
  function parseData(data, flag) {
23354
23432
  const prefix = flag ? `${flag}: ` : "";
23355
23433
  const source = data.startsWith("@") ? data.slice(1) : void 0;
23356
- let text3 = data;
23434
+ let text4 = data;
23357
23435
  if (source !== void 0) {
23358
23436
  try {
23359
- text3 = readFileSync14(source, "utf-8");
23437
+ text4 = readFileSync14(source, "utf-8");
23360
23438
  } catch (e) {
23361
23439
  throw expected(`${prefix}${source}: ${e instanceof Error ? e.message : "could not be read"}`);
23362
23440
  }
23363
23441
  }
23364
23442
  try {
23365
- return JSON.parse(text3);
23443
+ return JSON.parse(text4);
23366
23444
  } catch (e) {
23367
23445
  const where = source !== void 0 ? ` in ${source}` : "";
23368
23446
  throw expected(`${prefix}invalid JSON${where}: ${e instanceof Error ? e.message : String(e)}`);
@@ -24360,8 +24438,8 @@ var init_pacer = __esm({
24360
24438
 
24361
24439
  // src/communities/model.ts
24362
24440
  import { createHash as createHash3 } from "crypto";
24363
- function toLf(text3) {
24364
- return text3.replace(/\r\n?/g, "\n");
24441
+ function toLf(text4) {
24442
+ return text4.replace(/\r\n?/g, "\n");
24365
24443
  }
24366
24444
  function normalizeRules(rules) {
24367
24445
  if (rules === null || rules === void 0) return null;
@@ -24581,14 +24659,14 @@ function readCourseFolders(communityFolder, slugs, problems2) {
24581
24659
  }
24582
24660
  function readCourseFolder(communityFolder, folder, slug, problems2) {
24583
24661
  const where = `${COURSES_DIR}/${slug}/${COURSE_FILE}`;
24584
- const text3 = readRealFileOrThrow(communityFolder, path26.join(folder, COURSE_FILE));
24585
- if (text3 === null) {
24662
+ const text4 = readRealFileOrThrow(communityFolder, path26.join(folder, COURSE_FILE));
24663
+ if (text4 === null) {
24586
24664
  problems2.push(`${COURSES_DIR}/${slug}/: no ${COURSE_FILE}`);
24587
24665
  return null;
24588
24666
  }
24589
24667
  let doc;
24590
24668
  try {
24591
- doc = yaml13.load(text3);
24669
+ doc = yaml13.load(text4);
24592
24670
  } catch (err) {
24593
24671
  problems2.push(`${where} is not valid YAML: ${err instanceof Error ? err.message : String(err)}`);
24594
24672
  return null;
@@ -24671,12 +24749,12 @@ function readModules(communityFolder, lessonsDir, raw, courseSlug, courseWhere,
24671
24749
  });
24672
24750
  return modules;
24673
24751
  }
24674
- function splitFrontmatter(text3) {
24675
- if (!text3.startsWith("---\n")) return null;
24676
- const close2 = text3.indexOf("\n---\n", 3);
24677
- if (close2 === -1) return text3.endsWith("\n---") ? { front: text3.slice(4, -3), body: "" } : null;
24678
- const rest = text3.slice(close2 + 5);
24679
- return { front: text3.slice(4, close2 + 1), body: rest.endsWith("\n") ? rest.slice(0, -1) : rest };
24752
+ function splitFrontmatter(text4) {
24753
+ if (!text4.startsWith("---\n")) return null;
24754
+ const close2 = text4.indexOf("\n---\n", 3);
24755
+ if (close2 === -1) return text4.endsWith("\n---") ? { front: text4.slice(4, -3), body: "" } : null;
24756
+ const rest = text4.slice(close2 + 5);
24757
+ return { front: text4.slice(4, close2 + 1), body: rest.endsWith("\n") ? rest.slice(0, -1) : rest };
24680
24758
  }
24681
24759
  function readLessonFile(communityFolder, lessonsDir, courseSlug, slug, problems2) {
24682
24760
  const name = `${slug}${LESSON_FILE_EXT}`;
@@ -24843,14 +24921,14 @@ import * as yaml14 from "js-yaml";
24843
24921
  function readCommunityFolder(folder) {
24844
24922
  const where = path27.basename(folder);
24845
24923
  const yamlPath = path27.join(folder, COMMUNITY_FILE);
24846
- const text3 = readRealFileOrThrow(folder, yamlPath);
24847
- if (text3 === null) {
24924
+ const text4 = readRealFileOrThrow(folder, yamlPath);
24925
+ if (text4 === null) {
24848
24926
  throw expected(`No ${COMMUNITY_FILE} in ${where}/: pull the community first (wayai pull communities/<community_id>).`);
24849
24927
  }
24850
24928
  const rules = toLf(readRealFileOrThrow(folder, path27.join(folder, RULES_FILE)) ?? "");
24851
24929
  let doc;
24852
24930
  try {
24853
- doc = yaml14.load(text3);
24931
+ doc = yaml14.load(text4);
24854
24932
  } catch (err) {
24855
24933
  throw expected(`${where}/${COMMUNITY_FILE} is not valid YAML: ${err instanceof Error ? err.message : String(err)}`);
24856
24934
  }
@@ -25021,8 +25099,8 @@ function renderCommunityYaml(files) {
25021
25099
  return yaml14.dump(doc, YAML_DUMP_OPTIONS);
25022
25100
  }
25023
25101
  function renderRules(rules) {
25024
- const text3 = toLf(rules).replace(/\n+$/, "");
25025
- return text3 === "" ? "" : `${text3}
25102
+ const text4 = toLf(rules).replace(/\n+$/, "");
25103
+ return text4 === "" ? "" : `${text4}
25026
25104
  `;
25027
25105
  }
25028
25106
  function renderCommunityFiles(files) {
@@ -25114,7 +25192,7 @@ var init_listing = __esm({
25114
25192
  "src/communities/listing.ts"() {
25115
25193
  "use strict";
25116
25194
  init_terminal_output();
25117
- show = (text3) => JSON.stringify(sanitizeTerminalText(text3));
25195
+ show = (text4) => JSON.stringify(sanitizeTerminalText(text4));
25118
25196
  emptyListing = () => ({ changes: [], serverChanged: [], conflicts: [], leftAsIs: [], kept: [] });
25119
25197
  }
25120
25198
  });
@@ -28021,8 +28099,8 @@ function titleOf(slug) {
28021
28099
  const words = slug.split("-").join(" ");
28022
28100
  return words.charAt(0).toUpperCase() + words.slice(1);
28023
28101
  }
28024
- function escapeHtml(text3) {
28025
- return text3.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
28102
+ function escapeHtml(text4) {
28103
+ return text4.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
28026
28104
  }
28027
28105
  function scaffoldPage(input) {
28028
28106
  const customers = input.audience === "customers";
@@ -28409,8 +28487,8 @@ async function pageCommand(args2) {
28409
28487
  throw expected(`${path33.basename(hubFolder)} already holds ${PAGES_PER_HUB_MAX} pages: a hub holds at most ${PAGES_PER_HUB_MAX} pages.`);
28410
28488
  }
28411
28489
  requireRealSubdirNoSymlink(hubFolder, dir, true);
28412
- for (const [file, text3] of [[PAGE_MANIFEST_FILE, files.manifestYaml], [PAGE_HTML_FILE, files.html]]) {
28413
- const outcome = createFileNoFollow(hubFolder, path33.join(dir, file), Buffer.from(text3));
28490
+ for (const [file, text4] of [[PAGE_MANIFEST_FILE, files.manifestYaml], [PAGE_HTML_FILE, files.html]]) {
28491
+ const outcome = createFileNoFollow(hubFolder, path33.join(dir, file), Buffer.from(text4));
28414
28492
  if (outcome !== "created") throw expected(`${rel}/${file} could not be written (${outcome}): \`wayai page new\` never overwrites a page.`);
28415
28493
  }
28416
28494
  const shown3 = path33.join(path33.basename(hubFolder), rel);
@@ -31332,10 +31410,10 @@ var init_caller_audio = __esm({
31332
31410
  /** Syntheses in flight, by cache file: two lines with the same words pay for one. */
31333
31411
  inFlight = /* @__PURE__ */ new Map();
31334
31412
  /** The cache file for a text: one per model, voice and exact text. */
31335
- cachePath(text3) {
31413
+ cachePath(text4) {
31336
31414
  const key = createHash4("sha256").update(`${this.model}
31337
31415
  ${this.voice}
31338
- ${text3}`).digest("hex");
31416
+ ${text4}`).digest("hex");
31339
31417
  return join33(this.cacheDir, `${key}.pcm`);
31340
31418
  }
31341
31419
  clipFor(line) {
@@ -31687,8 +31765,8 @@ function parseWrittenNumber(raw) {
31687
31765
  if (m) return { ...base, int: Number(m[1]), frac: m[2] };
31688
31766
  return { ...base, int: Number(base.digits || "0"), digitMode: true };
31689
31767
  }
31690
- function tokenize(text3) {
31691
- const norm = normalizeText(text3);
31768
+ function tokenize(text4) {
31769
+ const norm = normalizeText(text4);
31692
31770
  const out = [];
31693
31771
  const re = /r\$|\d[\d.,/:h-]*\d|\d|%|[a-z]+|[.\-/]/g;
31694
31772
  for (const m of norm.matchAll(re)) {
@@ -31806,8 +31884,8 @@ function num(tk) {
31806
31884
  function decimalString(n) {
31807
31885
  return n.frac ? `${n.int}.${n.frac.padEnd(2, "0")}` : String(n.int);
31808
31886
  }
31809
- function extractFacts(text3) {
31810
- const toks = tokenize(text3);
31887
+ function extractFacts(text4) {
31888
+ const toks = tokenize(text4);
31811
31889
  const facts = [];
31812
31890
  const used = /* @__PURE__ */ new Set();
31813
31891
  const push = (kind, key, from, to) => {
@@ -31935,10 +32013,10 @@ function extractFacts(text3) {
31935
32013
  }
31936
32014
  return facts;
31937
32015
  }
31938
- function digitRuns(text3) {
32016
+ function digitRuns(text4) {
31939
32017
  const runs = [];
31940
32018
  let cur = "";
31941
- for (const f of extractFacts(text3)) {
32019
+ for (const f of extractFacts(text4)) {
31942
32020
  if (f.kind === "digits" || f.kind === "cpf" || f.kind === "number" && /^\d+$/.test(f.key)) cur += f.key;
31943
32021
  else {
31944
32022
  if (cur) runs.push(cur);
@@ -32002,21 +32080,21 @@ function isVetted(fact, vetted) {
32002
32080
  if (fact.kind === "number") return vetted.derivedNumbers.has(String(Number(fact.key)));
32003
32081
  return false;
32004
32082
  }
32005
- function readbackCandidate(text3, kind) {
32083
+ function readbackCandidate(text4, kind) {
32006
32084
  if (kind === "cpf") {
32007
- const cpf = extractFacts(text3).find((f) => f.kind === "cpf");
32085
+ const cpf = extractFacts(text4).find((f) => f.kind === "cpf");
32008
32086
  if (cpf) return cpf.key;
32009
- return digitRuns(text3).find((r) => r.length >= 9 && r.length <= 13) ?? null;
32087
+ return digitRuns(text4).find((r) => r.length >= 9 && r.length <= 13) ?? null;
32010
32088
  }
32011
32089
  if (kind === "digits") {
32012
- const code = extractFacts(text3).find((f) => (f.kind === "digits" || f.kind === "cpf") && f.key.length >= 5);
32090
+ const code = extractFacts(text4).find((f) => (f.kind === "digits" || f.kind === "cpf") && f.key.length >= 5);
32013
32091
  if (code) return code.key;
32014
- return digitRuns(text3).find((r) => r.length >= 5) ?? null;
32092
+ return digitRuns(text4).find((r) => r.length >= 5) ?? null;
32015
32093
  }
32016
- return extractFacts(text3).find((f) => f.kind === kind)?.key ?? null;
32094
+ return extractFacts(text4).find((f) => f.kind === kind)?.key ?? null;
32017
32095
  }
32018
- function claimMarkers(text3) {
32019
- const n = normalizeText(text3);
32096
+ function claimMarkers(text4) {
32097
+ const n = normalizeText(text4);
32020
32098
  return {
32021
32099
  policy: POLICY_MARKERS.filter((m) => n.includes(m)),
32022
32100
  action: ACTION_MARKERS.filter((m) => n.includes(m))
@@ -32177,10 +32255,10 @@ function parseCallPlan(raw) {
32177
32255
  }
32178
32256
  return { lines: out };
32179
32257
  }
32180
- function dictatedIdentifier(text3) {
32181
- const fact = extractFacts(text3).find((f) => f.kind === "cpf" || f.kind === "digits" && f.key.length >= 5);
32258
+ function dictatedIdentifier(text4) {
32259
+ const fact = extractFacts(text4).find((f) => f.kind === "cpf" || f.kind === "digits" && f.key.length >= 5);
32182
32260
  if (fact) return { kind: fact.kind, key: fact.key };
32183
- const run = digitRuns(text3).find((r) => r.length >= 5);
32261
+ const run = digitRuns(text4).find((r) => r.length >= 5);
32184
32262
  return run ? { kind: run.length === 11 ? "cpf" : "digits", key: run } : null;
32185
32263
  }
32186
32264
  function readbackOf(value) {
@@ -32303,9 +32381,9 @@ var init_cost_cap = __esm({
32303
32381
  function factLabel(fact) {
32304
32382
  return `${fact.kind}:${fact.raw}`;
32305
32383
  }
32306
- function tokens(text3) {
32307
- const words = normalizeText(text3).split(/[^a-z0-9]+/).filter((w) => w.length > 1 && !/^\d+$/.test(w) && !isNumberWord(w));
32308
- const facts = extractFacts(text3).map((f) => `#${f.kind}:${f.key}`);
32384
+ function tokens(text4) {
32385
+ const words = normalizeText(text4).split(/[^a-z0-9]+/).filter((w) => w.length > 1 && !/^\d+$/.test(w) && !isNumberWord(w));
32386
+ const facts = extractFacts(text4).map((f) => `#${f.kind}:${f.key}`);
32309
32387
  return /* @__PURE__ */ new Set([...words, ...facts]);
32310
32388
  }
32311
32389
  function similarity(a, b) {
@@ -32840,7 +32918,7 @@ var init_report = __esm({
32840
32918
  style: "style",
32841
32919
  latency: "latency"
32842
32920
  };
32843
- shown2 = (text3) => text3 === null ? "nothing" : sanitizeTerminalText(text3);
32921
+ shown2 = (text4) => text4 === null ? "nothing" : sanitizeTerminalText(text4);
32844
32922
  }
32845
32923
  });
32846
32924
 
@@ -35491,6 +35569,9 @@ function parse2(args2) {
35491
35569
  org: { type: "string" },
35492
35570
  base: { type: "string" },
35493
35571
  record: { type: "string" },
35572
+ to: { type: "string" },
35573
+ cursor: { type: "string" },
35574
+ limit: { type: "string" },
35494
35575
  json: { type: "boolean" }
35495
35576
  },
35496
35577
  allowPositionals: true,
@@ -35514,43 +35595,135 @@ function failure(err, accessToken) {
35514
35595
  if (err.status === 403 && identifyTokenType(accessToken) === "way_token") {
35515
35596
  const override2 = envTokenOverride() ? " WAYAI_TOKEN is set in this shell and is sent instead of your sign-in: unset it first." : "";
35516
35597
  return expected(
35517
- `A contact's customer record is linked from a browser sign-in only, and this login is an API token. Run \`wayai login\` (without --token).${override2}`
35598
+ `These commands work from a browser sign-in only, and this login is an API token. Run \`wayai login\` (without --token).${override2}`
35518
35599
  );
35519
35600
  }
35520
35601
  if (err.status >= 400 && err.status < 500) return expected(sanitizeTerminalText(extractApiMessage(err)));
35521
35602
  return err;
35522
35603
  }
35523
- async function contactsCommand(args2) {
35524
- if (wantsHelp(args2) || args2.length === 0) {
35525
- console.log(USAGE4);
35526
- return;
35604
+ function userPersonId(sub, value) {
35605
+ if (value === void 0) throw usageError3(`${sub} takes one <person_id>.`);
35606
+ if (!userPersonIdSchema.safeParse(value).success) throw usageError3(`Invalid <person_id> ${JSON.stringify(value)}: expected a person id (prs_\u2026).`);
35607
+ return value;
35608
+ }
35609
+ function personOrContactId(what, value) {
35610
+ if (value === void 0) throw usageError3(`Missing ${what}.`);
35611
+ if (!personIdSchema.safeParse(value).success) {
35612
+ throw usageError3(`Invalid ${what} ${JSON.stringify(value)}. ${PERSON_ID_FORM_MESSAGE}.`);
35527
35613
  }
35528
- const { values, positionals } = parse2(args2);
35529
- const [sub, contactId, ...extra] = positionals;
35530
- if (!SUBCOMMANDS2.includes(sub)) throw usageError3(`Unknown subcommand ${JSON.stringify(sub)}.`);
35614
+ return value;
35615
+ }
35616
+ function refuseFlags(sub, values, flags) {
35617
+ for (const flag of flags) {
35618
+ if (values[flag] !== void 0) throw usageError3(`--${String(flag)} does not apply to ${sub}.`);
35619
+ }
35620
+ }
35621
+ function entryLine(entry) {
35622
+ return ` ${text2(entry.person_id)} since ${text2(entry.created_at)}, by ${text2(entry.created_by)}`;
35623
+ }
35624
+ function print(values, data, lines) {
35625
+ console.log(values.json ? JSON.stringify(data, null, 2) : lines.join("\n"));
35626
+ }
35627
+ async function customerRecord(sub, positionals, values) {
35628
+ const [contactId, ...extra] = positionals;
35531
35629
  if (contactId === void 0 || extra.length > 0) throw usageError3(`${sub} takes one <contact_id>.`);
35532
35630
  if (!UUID_RE3.test(contactId)) throw usageError3(`Invalid <contact_id> ${JSON.stringify(contactId)}: expected a contact id (a UUID).`);
35631
+ refuseFlags(sub, values, ["to", "cursor", "limit"]);
35533
35632
  if (!values.base) throw usageError3(`${sub} needs --base <base_id>.`);
35534
35633
  if (!isValidBaseId(values.base)) throw usageError3(`Invalid --base ${JSON.stringify(values.base)}: a base id is ${BASE_ID_RULE}.`);
35535
35634
  if (sub === "link-customer" && !values.record) throw usageError3("link-customer needs --record <record_id>.");
35536
35635
  if (sub === "unlink-customer" && values.record !== void 0) throw usageError3("--record applies only to link-customer.");
35537
35636
  const orgId = resolveOrgId2(values.org);
35637
+ await withApi(async (api) => {
35638
+ const { customer } = sub === "link-customer" ? await api.linkContactCustomer(orgId, contactId, { base_id: values.base, record_id: values.record }) : await api.unlinkContactCustomer(orgId, contactId, values.base);
35639
+ const where = `base ${text2(customer.base_id)} (${text2(customer.record_type)})`;
35640
+ print(values, customer, [sub === "link-customer" ? `Contact ${customer.contact_id} is linked to customer record ${text2(customer.record_id)} in ${where}.` : `Contact ${customer.contact_id} is unlinked from customer record ${text2(customer.record_id)} in ${where}; the record keeps the contact id under ${customer.external_source}.`]);
35641
+ });
35642
+ }
35643
+ async function persons(sub, positionals, values) {
35644
+ refuseFlags(sub, values, ["base", "record"]);
35645
+ const takesTo = sub === "link-person" || sub === "unlink-person";
35646
+ if (!takesTo) refuseFlags(sub, values, ["to"]);
35647
+ if (sub !== "denied-persons") refuseFlags(sub, values, ["cursor", "limit"]);
35648
+ const [first, ...extra] = positionals;
35649
+ if (sub === "denied-persons" ? positionals.length > 0 : extra.length > 0) {
35650
+ throw usageError3(sub === "denied-persons" ? "denied-persons takes no arguments." : `${sub} takes one id.`);
35651
+ }
35652
+ let limit;
35653
+ if (values.limit !== void 0) {
35654
+ limit = Number(values.limit);
35655
+ if (!Number.isInteger(limit) || limit < 1 || limit > PERSON_DENY_PAGE_MAX) {
35656
+ throw usageError3(`Invalid --limit ${JSON.stringify(values.limit)}: expected a whole number from 1 to ${PERSON_DENY_PAGE_MAX}.`);
35657
+ }
35658
+ }
35659
+ const cursor = values.cursor === void 0 ? void 0 : personOrContactId("--cursor", values.cursor);
35660
+ const subject = sub === "denied-persons" ? "" : sub === "deny-person" || sub === "undeny-person" ? personOrContactId("<person_id|contact_id>", first) : userPersonId(sub, first);
35661
+ const target = takesTo ? personOrContactId("--to <person_id|contact_id>", values.to) : "";
35662
+ const orgId = resolveOrgId2(values.org);
35663
+ await withApi(async (api) => {
35664
+ switch (sub) {
35665
+ case "lookup-person": {
35666
+ const { person } = await api.lookupPerson(orgId, subject);
35667
+ print(values, person, [person.status === "found" ? `Person ${person.person_id} is ${person.user_name ? text2(person.user_name) : "unnamed"}${person.user_email ? ` <${text2(person.user_email)}>` : ""}, in hub ${person.hub_name ? text2(person.hub_name) : "unnamed"} (${text2(person.hub_id)}).` : `No conversation of the organization's hubs carries person ${person.person_id}.`]);
35668
+ return;
35669
+ }
35670
+ case "person-links": {
35671
+ const data = await api.listPersonLinks(orgId, subject);
35672
+ print(values, data, data.links.length === 0 ? [`Person ${data.person_id} has no person links.`] : [`Person ${data.person_id} is linked to:`, ...data.links.map(entryLine)]);
35673
+ return;
35674
+ }
35675
+ case "link-person": {
35676
+ const data = await api.linkPerson(orgId, subject, target);
35677
+ print(values, data, [data.status === "linked" ? `Person ${data.person_id} is linked to ${target}${data.added ? `; added ${data.added.map(text2).join(", ")}` : ""}.` : `Person ${data.person_id} was already linked to ${target} and its own links.`]);
35678
+ return;
35679
+ }
35680
+ case "unlink-person": {
35681
+ const data = await api.unlinkPerson(orgId, subject, target);
35682
+ print(values, data, [`Person ${subject} is no longer linked to ${target}.`]);
35683
+ return;
35684
+ }
35685
+ case "denied-persons": {
35686
+ const data = await api.listDeniedPersons(orgId, { cursor, limit });
35687
+ const lines = data.denied.length === 0 ? ["Nothing is denied."] : ["Denied:", ...data.denied.map(entryLine)];
35688
+ if (data.next_cursor) lines.push(`More: --cursor ${text2(data.next_cursor)}`);
35689
+ print(values, data, lines);
35690
+ return;
35691
+ }
35692
+ case "deny-person": {
35693
+ const data = await api.denyPerson(orgId, subject);
35694
+ print(values, data, [data.status === "denied" ? `Denied ${data.person_id}.` : `${data.person_id} was already denied.`]);
35695
+ return;
35696
+ }
35697
+ case "undeny-person": {
35698
+ const data = await api.undenyPerson(orgId, subject);
35699
+ print(values, data, [`Lifted the denial of ${subject}.`]);
35700
+ return;
35701
+ }
35702
+ }
35703
+ });
35704
+ }
35705
+ async function withApi(act) {
35538
35706
  const { config, accessToken } = await requireAuth();
35539
35707
  const api = new ApiClient({ apiUrl: config.api_url, accessToken, onUnauthorized: () => getAccessToken(config) });
35540
- let customer;
35541
35708
  try {
35542
- ({ customer } = sub === "link-customer" ? await api.linkContactCustomer(orgId, contactId, { base_id: values.base, record_id: values.record }) : await api.unlinkContactCustomer(orgId, contactId, values.base));
35709
+ await act(api);
35543
35710
  } catch (err) {
35544
35711
  throw failure(err, accessToken);
35545
35712
  }
35546
- if (values.json) {
35547
- console.log(JSON.stringify(customer, null, 2));
35713
+ }
35714
+ async function contactsCommand(args2) {
35715
+ if (wantsHelp(args2) || args2.length === 0) {
35716
+ console.log(USAGE4);
35548
35717
  return;
35549
35718
  }
35550
- const where = `base ${sanitizeTerminalText(customer.base_id)} (${sanitizeTerminalText(customer.record_type)})`;
35551
- console.log(sub === "link-customer" ? `Contact ${customer.contact_id} is linked to customer record ${sanitizeTerminalText(customer.record_id)} in ${where}.` : `Contact ${customer.contact_id} is unlinked from customer record ${sanitizeTerminalText(customer.record_id)} in ${where}; the record keeps the contact id under ${customer.external_source}.`);
35719
+ const { values, positionals } = parse2(args2);
35720
+ const [sub, ...rest] = positionals;
35721
+ if (!SUBCOMMANDS2.includes(sub)) throw usageError3(`Unknown subcommand ${JSON.stringify(sub)}.`);
35722
+ const command2 = sub;
35723
+ if (command2 === "link-customer" || command2 === "unlink-customer") return customerRecord(command2, rest, values);
35724
+ return persons(command2, rest, values);
35552
35725
  }
35553
- var USAGE4, SUBCOMMANDS2;
35726
+ var USAGE4, SUBCOMMANDS2, text2;
35554
35727
  var init_contacts = __esm({
35555
35728
  "src/commands/contacts.ts"() {
35556
35729
  "use strict";
@@ -35563,12 +35736,20 @@ var init_contacts = __esm({
35563
35736
  init_token_store();
35564
35737
  init_base_id();
35565
35738
  init_utils();
35739
+ init_contracts();
35566
35740
  USAGE4 = `
35567
- wayai contacts \u2014 a contact's customer record in one of the organization's bases
35741
+ wayai contacts \u2014 a contact's customer record in a base, and the organization's person links and deny list
35568
35742
 
35569
35743
  Usage:
35570
35744
  wayai contacts link-customer <contact_id> --base <base_id> --record <record_id> [--org <org_id>] [--json]
35571
35745
  wayai contacts unlink-customer <contact_id> --base <base_id> [--org <org_id>] [--json]
35746
+ wayai contacts lookup-person <person_id> [--org <org_id>] [--json]
35747
+ wayai contacts person-links <person_id> [--org <org_id>] [--json]
35748
+ wayai contacts link-person <person_id> --to <person_id|contact_id> [--org <org_id>] [--json]
35749
+ wayai contacts unlink-person <person_id> --to <person_id|contact_id> [--org <org_id>] [--json]
35750
+ wayai contacts denied-persons [--cursor <id>] [--limit <n>] [--org <org_id>] [--json]
35751
+ wayai contacts deny-person <person_id|contact_id> [--org <org_id>] [--json]
35752
+ wayai contacts undeny-person <person_id|contact_id> [--org <org_id>] [--json]
35572
35753
 
35573
35754
  link-customer Make the record the contact's customer record: a conversation with the
35574
35755
  contact (its WhatsApp phone, Instagram id or app account) then serves that
@@ -35580,11 +35761,37 @@ unlink-customer Unlink the contact's customer record in the base. The record ke
35580
35761
  contact id under the source wayai_contact_unlinked, so its owned records stay
35581
35762
  its own, and link-customer on the same record links it again.
35582
35763
 
35583
- The organization is --org, else this repo's (wayai-ws/wayai.yaml). You must be an
35584
- organization admin. These commands need a browser sign-in (\`wayai login\`): an API
35585
- token (\`wayai login --token\`, or WAYAI_TOKEN) is refused.
35764
+ lookup-person Whom a person id (prs_\u2026) names: a hub of the organization where a
35765
+ conversation carries it, and that hub's name and email for the person. A
35766
+ person id no conversation carries is unknown.
35767
+ person-links The person ids and contacts a person is linked to, oldest first.
35768
+ link-person Link a person to another person id (their earlier identity, say an old
35769
+ number) or to a contact of the organization: the person is also that one.
35770
+ The target's own links are copied too. A person holds at most 16 links.
35771
+ unlink-person Remove one link. The links it copied stay.
35772
+ denied-persons The organization's deny list: person ids and contacts no person set holds.
35773
+ deny-person Deny a person id or a contact for the organization.
35774
+ undeny-person Lift a denial.
35775
+
35776
+ Person links and the deny list give and take no access yet: no call reads them.
35777
+
35778
+ The organization is --org, else this repo's (wayai-ws/wayai.yaml). Linking and unlinking
35779
+ a person needs org:write over the organization; everything else here an organization
35780
+ admin. These commands need a browser sign-in (\`wayai login\`): an API token
35781
+ (\`wayai login --token\`, or WAYAI_TOKEN) is refused.
35586
35782
  `.trim();
35587
- SUBCOMMANDS2 = ["link-customer", "unlink-customer"];
35783
+ SUBCOMMANDS2 = [
35784
+ "link-customer",
35785
+ "unlink-customer",
35786
+ "lookup-person",
35787
+ "person-links",
35788
+ "link-person",
35789
+ "unlink-person",
35790
+ "denied-persons",
35791
+ "deny-person",
35792
+ "undeny-person"
35793
+ ];
35794
+ text2 = (value) => sanitizeTerminalText(value);
35588
35795
  }
35589
35796
  });
35590
35797
 
@@ -35782,7 +35989,7 @@ function layerLines(values) {
35782
35989
  if (values === null) return ["narrows nothing (no values)"];
35783
35990
  const dimensions = Object.entries(values);
35784
35991
  if (dimensions.length === 0) return ["reaches nothing (unset, or no dimension)"];
35785
- return dimensions.map(([dimension, { read, write }]) => `${text2(dimension)}: read ${list(read)}; write ${list(write)}`);
35992
+ return dimensions.map(([dimension, { read, write }]) => `${text3(dimension)}: read ${list(read)}; write ${list(write)}`);
35786
35993
  }
35787
35994
  function partyLine(party) {
35788
35995
  const who = party.customer ? "the conversation's customer" : "the person";
@@ -35796,23 +36003,23 @@ function partyLine(party) {
35796
36003
  function personsLines(data) {
35797
36004
  if (!data.persons) return [];
35798
36005
  const lines = ["", "Persons each call is for (matched on record types with person entries):"];
35799
- for (const persons of data.persons) {
35800
- const audience = persons.audience === REKOR_PERSON_AUDIENCE_STAFF ? "a call for team members" : "customer-facing";
35801
- lines.push(` ${TURN_NAMES[persons.turn]}: ${audience}${persons.full_reach ? ", full reach" : ""}`);
35802
- if (persons.parties.length === 0) {
35803
- lines.push(persons.agent_all ? " no person; the agent holds $person: every person's records" : " no person; the agent does not hold $person: no person's records");
36006
+ for (const persons2 of data.persons) {
36007
+ const audience = persons2.audience === REKOR_PERSON_AUDIENCE_STAFF ? "a call for team members" : "customer-facing";
36008
+ lines.push(` ${TURN_NAMES[persons2.turn]}: ${audience}${persons2.full_reach ? ", full reach" : ""}`);
36009
+ if (persons2.parties.length === 0) {
36010
+ lines.push(persons2.agent_all ? " no person; the agent holds $person: every person's records" : " no person; the agent does not hold $person: no person's records");
35804
36011
  }
35805
- for (const party of persons.parties) lines.push(` ${partyLine(party)}`);
36012
+ for (const party of persons2.parties) lines.push(` ${partyLine(party)}`);
35806
36013
  }
35807
36014
  lines.push(" Person entries are matched on calls for team members and customer-facing calls alike; a customer-facing call also reaches only record types with person entries in enforce or marked shared.");
35808
36015
  return lines;
35809
36016
  }
35810
36017
  function formatExplanation(data) {
35811
36018
  const lines = [];
35812
- const who = data.user_id === null ? "no person: the hub's \u2229 the agent's" : `person ${text2(data.user_id)}, ${data.kind ? kindName(data.kind) : "unknown kind"}`;
35813
- lines.push(`Hub ${text2(data.hub_id)}, agent ${text2(data.agent_id)}, ${who}`);
36019
+ const who = data.user_id === null ? "no person: the hub's \u2229 the agent's" : `person ${text3(data.user_id)}, ${data.kind ? kindName(data.kind) : "unknown kind"}`;
36020
+ lines.push(`Hub ${text3(data.hub_id)}, agent ${text3(data.agent_id)}, ${who}`);
35814
36021
  if (data.values_hub_id === null) lines.push("This preview hub was never published: it has no hub values, so it reaches nothing.");
35815
- else if (data.values_hub_id !== data.hub_id) lines.push(`Hub values are those of its production hub ${text2(data.values_hub_id)}.`);
36022
+ else if (data.values_hub_id !== data.hub_id) lines.push(`Hub values are those of its production hub ${text3(data.values_hub_id)}.`);
35816
36023
  if (data.customer_only) {
35817
36024
  lines.push("Customer-only: held only on record types customer scope narrows to one customer, on a call naming its customer; every other scoped type reaches nothing.");
35818
36025
  }
@@ -35829,12 +36036,12 @@ function formatExplanation(data) {
35829
36036
  lines.push("", "Effective set:");
35830
36037
  if (data.dimensions.length === 0) lines.push(" no dimension: the set reaches nothing on any scoped record type");
35831
36038
  for (const dimension of data.dimensions) {
35832
- lines.push(` ${text2(dimension.dimension_id)}: read ${list(dimension.read)}; write ${list(dimension.write)}`);
36039
+ lines.push(` ${text3(dimension.dimension_id)}: read ${list(dimension.read)}; write ${list(dimension.write)}`);
35833
36040
  for (const removal of dimension.read_removed) {
35834
- lines.push(` ${text2(removal.value_id)} not read: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
36041
+ lines.push(` ${text3(removal.value_id)} not read: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
35835
36042
  }
35836
36043
  for (const removal of dimension.write_removed) {
35837
- lines.push(` ${text2(removal.value_id)} read, not written: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
36044
+ lines.push(` ${text3(removal.value_id)} read, not written: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
35838
36045
  }
35839
36046
  }
35840
36047
  lines.push("", "This set filters records only on record types a base enforces (x-access in enforce mode).");
@@ -35870,7 +36077,7 @@ async function accessCommand(args2) {
35870
36077
  }
35871
36078
  console.log(values.json ? JSON.stringify(data, null, 2) : formatExplanation(data).join("\n"));
35872
36079
  }
35873
- var USAGE6, LAYER_NAMES, kindName, text2, list, TURN_NAMES;
36080
+ var USAGE6, LAYER_NAMES, kindName, text3, list, TURN_NAMES;
35874
36081
  var init_access = __esm({
35875
36082
  "src/commands/access.ts"() {
35876
36083
  "use strict";
@@ -35933,8 +36140,8 @@ organization admin.
35933
36140
  agent: "agent"
35934
36141
  };
35935
36142
  kindName = (kind) => kind === "public" ? "everyone else" : LAYER_NAMES[kind];
35936
- text2 = (value) => sanitizeTerminalText(value);
35937
- list = (ids) => ids.length === 0 ? "nothing" : ids.map(text2).join(" ");
36143
+ text3 = (value) => sanitizeTerminalText(value);
36144
+ list = (ids) => ids.length === 0 ? "nothing" : ids.map(text3).join(" ");
35938
36145
  TURN_NAMES = {
35939
36146
  own_conversation: "Their message in their own conversation",
35940
36147
  team_send: "Their message with no customer in the turn (a team send or a consult they start)",
@@ -36092,11 +36299,11 @@ function ensureSyncDir(dir) {
36092
36299
  if (!fs30.lstatSync(dir).isDirectory()) throw symlinkRefusal(dir, "directory");
36093
36300
  }
36094
36301
  function readRecord(dir) {
36095
- const text3 = readRealFileOrThrow(dir, path42.join(dir, RECORD_FILE));
36096
- if (text3 === null) return null;
36302
+ const text4 = readRealFileOrThrow(dir, path42.join(dir, RECORD_FILE));
36303
+ if (text4 === null) return null;
36097
36304
  let parsed;
36098
36305
  try {
36099
- parsed = JSON.parse(text3);
36306
+ parsed = JSON.parse(text4);
36100
36307
  } catch {
36101
36308
  parsed = void 0;
36102
36309
  }
@@ -37504,8 +37711,8 @@ async function runArchiveRead(positional, flagArgs) {
37504
37711
  const id = String(m.message_id ?? "");
37505
37712
  const sender = String(m.sender_type ?? "");
37506
37713
  const ts = String(m.created_at ?? "");
37507
- const text3 = truncate2(String(m.message_text ?? ""), 80);
37508
- console.log(` ${id} | ${sender} | ${ts} | ${text3}`);
37714
+ const text4 = truncate2(String(m.message_text ?? ""), 80);
37715
+ console.log(` ${id} | ${sender} | ${ts} | ${text4}`);
37509
37716
  }
37510
37717
  }
37511
37718
  }
@@ -42611,7 +42818,7 @@ Commands:
42611
42818
  sync-mcp Re-discover an MCP connection's tools (refresh stale schemas)
42612
42819
  list List organizations and hubs
42613
42820
  communities An organization's communities: list, join link (get/rotate/off), stats, access list (list/add/remove) \u2014 \`wayai communities --help\`
42614
- contacts Link a contact to its customer record in a base, or unlink it (browser sign-in only) \u2014 \`wayai contacts --help\`
42821
+ contacts A contact's customer record in a base; person links, the deny list, person lookup (browser sign-in only) \u2014 \`wayai contacts --help\`
42615
42822
  dimensions An organization's access dimensions and their values: list, create, relabel, add/retire values \u2014 \`wayai dimensions --help\`
42616
42823
  access explain The access set a hub agent's toolset calls send for a person, and which layer removed each value \u2014 \`wayai access --help\`
42617
42824
  knowledge refresh-preview Make the knowledge base's preview hold its production base's files \u2014 \`wayai knowledge --help\`