@wayai/cli 0.3.357 → 0.3.358

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
@@ -5113,6 +5113,38 @@ var init_fs_safety = __esm({
5113
5113
  }
5114
5114
  });
5115
5115
 
5116
+ // ../../packages/core/dist/chunk-VXEAR36B.js
5117
+ var orgTagIdParam, listOrgTagsQuery, ORG_TAG_NAME_REGEX, ORG_TAG_NAME_MAX_LENGTH, createOrgTagBody, updateOrgTagBody;
5118
+ var init_chunk_VXEAR36B = __esm({
5119
+ "../../packages/core/dist/chunk-VXEAR36B.js"() {
5120
+ "use strict";
5121
+ init_zod();
5122
+ orgTagIdParam = external_exports.object({
5123
+ id: external_exports.string().uuid()
5124
+ });
5125
+ listOrgTagsQuery = external_exports.object({
5126
+ organization_id: external_exports.string().uuid()
5127
+ });
5128
+ ORG_TAG_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
5129
+ ORG_TAG_NAME_MAX_LENGTH = 50;
5130
+ createOrgTagBody = external_exports.object({
5131
+ organization_id: external_exports.string().uuid(),
5132
+ name: external_exports.string().min(1).max(ORG_TAG_NAME_MAX_LENGTH).regex(ORG_TAG_NAME_REGEX, {
5133
+ message: 'Must be lowercase alphanumeric with hyphens (e.g. "my-tag")'
5134
+ }),
5135
+ display_name: external_exports.string().max(100).nullish(),
5136
+ color: external_exports.string().max(20).nullish()
5137
+ });
5138
+ updateOrgTagBody = external_exports.object({
5139
+ // Required so the route targets the org the UI is managing (which may differ
5140
+ // from the token's default `auth.org_id` for multi-org users) — mirrors create/list.
5141
+ organization_id: external_exports.string().uuid(),
5142
+ display_name: external_exports.string().max(100).nullish(),
5143
+ color: external_exports.string().max(20).nullish()
5144
+ });
5145
+ }
5146
+ });
5147
+
5116
5148
  // ../../packages/core/dist/chunk-HZ6CADSY.js
5117
5149
  function optionalTrimmedText(max) {
5118
5150
  return external_exports.string().trim().max(max).optional().transform((value) => value ? value : void 0);
@@ -5363,6 +5395,80 @@ var init_chunk_Q7KIQHAZ = __esm({
5363
5395
  }
5364
5396
  });
5365
5397
 
5398
+ // ../../packages/core/dist/chunk-IPXBFWUU.js
5399
+ var variantAiModeSchema, experimentStatusSchema, overlayUpdateSchema, experimentIdParam, variantIdParam, listExperimentsQuery, listVariantsQuery, listOverridesQuery, deleteOverrideQuery, createExperimentBody, updateExperimentBody, setExperimentStatusBody, createVariantBody, updateVariantBody, upsertOverrideBody;
5400
+ var init_chunk_IPXBFWUU = __esm({
5401
+ "../../packages/core/dist/chunk-IPXBFWUU.js"() {
5402
+ "use strict";
5403
+ init_chunk_6TSQ5HXC();
5404
+ init_zod();
5405
+ variantAiModeSchema = external_exports.enum(["pilot+copilot", "pilot", "copilot", "turned_off"]);
5406
+ experimentStatusSchema = external_exports.enum(["draft", "running", "stopped"]);
5407
+ overlayUpdateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v === void 0 ? void 0 : v && Object.keys(v).length > 0 ? v : null);
5408
+ experimentIdParam = external_exports.object({
5409
+ id: external_exports.string().uuid()
5410
+ });
5411
+ variantIdParam = external_exports.object({
5412
+ id: external_exports.string().uuid()
5413
+ });
5414
+ listExperimentsQuery = external_exports.object({
5415
+ hub_id: external_exports.string().uuid()
5416
+ });
5417
+ listVariantsQuery = external_exports.object({
5418
+ hub_id: external_exports.string().uuid(),
5419
+ experiment_id: external_exports.string().uuid().optional()
5420
+ });
5421
+ listOverridesQuery = external_exports.object({
5422
+ hub_id: external_exports.string().uuid(),
5423
+ variant_id: external_exports.string().uuid()
5424
+ });
5425
+ deleteOverrideQuery = external_exports.object({
5426
+ hub_id: external_exports.string().uuid(),
5427
+ variant_id: external_exports.string().uuid(),
5428
+ agent_id: external_exports.string().uuid()
5429
+ });
5430
+ createExperimentBody = external_exports.object({
5431
+ hub_id: external_exports.string().uuid(),
5432
+ experiment_slug: slugSchema.optional(),
5433
+ experiment_name: external_exports.string().min(1, "experiment_name is required").max(100, "experiment_name must be 100 characters or fewer"),
5434
+ primary_metric: external_exports.string().max(200).nullish(),
5435
+ status: experimentStatusSchema.default("draft")
5436
+ });
5437
+ updateExperimentBody = external_exports.object({
5438
+ // experiment_slug is immutable after first persist — not accepted here.
5439
+ experiment_name: external_exports.string().min(1).max(100).optional(),
5440
+ primary_metric: external_exports.string().max(200).nullish(),
5441
+ control_variant_id: external_exports.string().uuid().nullish()
5442
+ });
5443
+ setExperimentStatusBody = external_exports.object({
5444
+ status: experimentStatusSchema
5445
+ });
5446
+ createVariantBody = external_exports.object({
5447
+ hub_id: external_exports.string().uuid(),
5448
+ experiment_id: external_exports.string().uuid(),
5449
+ label: external_exports.string().min(1, "label is required").max(100, "label must be 100 characters or fewer"),
5450
+ weight: external_exports.number().positive().default(1),
5451
+ ai_mode: variantAiModeSchema.nullish(),
5452
+ is_control: external_exports.boolean().default(false)
5453
+ });
5454
+ updateVariantBody = external_exports.object({
5455
+ label: external_exports.string().min(1).max(100).optional(),
5456
+ weight: external_exports.number().positive().optional(),
5457
+ ai_mode: variantAiModeSchema.nullish(),
5458
+ is_control: external_exports.boolean().optional()
5459
+ });
5460
+ upsertOverrideBody = external_exports.object({
5461
+ hub_id: external_exports.string().uuid(),
5462
+ variant_id: external_exports.string().uuid(),
5463
+ agent_id: external_exports.string().uuid(),
5464
+ instructions: external_exports.string().nullish(),
5465
+ additional_context_template: external_exports.string().nullish(),
5466
+ connection_id: external_exports.string().uuid().nullish(),
5467
+ agent_settings_overlay: overlayUpdateSchema
5468
+ });
5469
+ }
5470
+ });
5471
+
5366
5472
  // ../../packages/core/dist/chunk-63UWXV4T.js
5367
5473
  var init_chunk_63UWXV4T = __esm({
5368
5474
  "../../packages/core/dist/chunk-63UWXV4T.js"() {
@@ -5642,38 +5748,6 @@ var init_chunk_YVY2TZK2 = __esm({
5642
5748
  }
5643
5749
  });
5644
5750
 
5645
- // ../../packages/core/dist/chunk-VXEAR36B.js
5646
- var orgTagIdParam, listOrgTagsQuery, ORG_TAG_NAME_REGEX, ORG_TAG_NAME_MAX_LENGTH, createOrgTagBody, updateOrgTagBody;
5647
- var init_chunk_VXEAR36B = __esm({
5648
- "../../packages/core/dist/chunk-VXEAR36B.js"() {
5649
- "use strict";
5650
- init_zod();
5651
- orgTagIdParam = external_exports.object({
5652
- id: external_exports.string().uuid()
5653
- });
5654
- listOrgTagsQuery = external_exports.object({
5655
- organization_id: external_exports.string().uuid()
5656
- });
5657
- ORG_TAG_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
5658
- ORG_TAG_NAME_MAX_LENGTH = 50;
5659
- createOrgTagBody = external_exports.object({
5660
- organization_id: external_exports.string().uuid(),
5661
- name: external_exports.string().min(1).max(ORG_TAG_NAME_MAX_LENGTH).regex(ORG_TAG_NAME_REGEX, {
5662
- message: 'Must be lowercase alphanumeric with hyphens (e.g. "my-tag")'
5663
- }),
5664
- display_name: external_exports.string().max(100).nullish(),
5665
- color: external_exports.string().max(20).nullish()
5666
- });
5667
- updateOrgTagBody = external_exports.object({
5668
- // Required so the route targets the org the UI is managing (which may differ
5669
- // from the token's default `auth.org_id` for multi-org users) — mirrors create/list.
5670
- organization_id: external_exports.string().uuid(),
5671
- display_name: external_exports.string().max(100).nullish(),
5672
- color: external_exports.string().max(20).nullish()
5673
- });
5674
- }
5675
- });
5676
-
5677
5751
  // ../../packages/core/dist/chunk-HIGKBEPF.js
5678
5752
  var accessExplainQuery;
5679
5753
  var init_chunk_HIGKBEPF = __esm({
@@ -6265,77 +6339,98 @@ var init_chunk_WONSSUXU = __esm({
6265
6339
  }
6266
6340
  });
6267
6341
 
6268
- // ../../packages/core/dist/chunk-IPXBFWUU.js
6269
- var variantAiModeSchema, experimentStatusSchema, overlayUpdateSchema, experimentIdParam, variantIdParam, listExperimentsQuery, listVariantsQuery, listOverridesQuery, deleteOverrideQuery, createExperimentBody, updateExperimentBody, setExperimentStatusBody, createVariantBody, updateVariantBody, upsertOverrideBody;
6270
- var init_chunk_IPXBFWUU = __esm({
6271
- "../../packages/core/dist/chunk-IPXBFWUU.js"() {
6342
+ // ../../packages/core/dist/chunk-KEN2DASI.js
6343
+ var SECOND_FACTOR_TIERS, secondFactorTier, META_ENTITY_ID_PATTERN, metaEntityId, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, normalizeEmail, REVIEW_ACCOUNT_EMAILS;
6344
+ var init_chunk_KEN2DASI = __esm({
6345
+ "../../packages/core/dist/chunk-KEN2DASI.js"() {
6272
6346
  "use strict";
6273
- init_chunk_6TSQ5HXC();
6274
6347
  init_zod();
6275
- variantAiModeSchema = external_exports.enum(["pilot+copilot", "pilot", "copilot", "turned_off"]);
6276
- experimentStatusSchema = external_exports.enum(["draft", "running", "stopped"]);
6277
- overlayUpdateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v === void 0 ? void 0 : v && Object.keys(v).length > 0 ? v : null);
6278
- experimentIdParam = external_exports.object({
6279
- id: external_exports.string().uuid()
6280
- });
6281
- variantIdParam = external_exports.object({
6282
- id: external_exports.string().uuid()
6283
- });
6284
- listExperimentsQuery = external_exports.object({
6285
- hub_id: external_exports.string().uuid()
6286
- });
6287
- listVariantsQuery = external_exports.object({
6288
- hub_id: external_exports.string().uuid(),
6289
- experiment_id: external_exports.string().uuid().optional()
6348
+ SECOND_FACTOR_TIERS = ["off", "settings"];
6349
+ secondFactorTier = external_exports.enum(SECOND_FACTOR_TIERS);
6350
+ META_ENTITY_ID_PATTERN = /^\d{1,32}$/;
6351
+ metaEntityId = external_exports.string().regex(META_ENTITY_ID_PATTERN, "must be a numeric Meta entity id");
6352
+ whatsappCallbackBody = external_exports.object({
6353
+ state: external_exports.string().min(1, "state is required"),
6354
+ code: external_exports.string().optional(),
6355
+ access_token: external_exports.string().optional(),
6356
+ user_id: external_exports.string().optional(),
6357
+ /**
6358
+ * The phone number and WABA the operator actually picked in Meta's Embedded
6359
+ * Signup popup (posted to the opener as `WA_EMBEDDED_SIGNUP`). Optional:
6360
+ * older clients, and the redirect-based flow, never see that event and fall
6361
+ * back to discovery.
6362
+ */
6363
+ phone_number_id: metaEntityId.optional(),
6364
+ waba_id: metaEntityId.optional()
6365
+ }).refine(
6366
+ (data) => !!data.access_token || !!data.code,
6367
+ { message: "Missing required parameters: state and either access_token or code" }
6368
+ );
6369
+ authMeResponse = external_exports.object({
6370
+ user_id: external_exports.string(),
6371
+ email: external_exports.string(),
6372
+ org_id: external_exports.string().nullable(),
6373
+ is_platform_admin: external_exports.boolean()
6290
6374
  });
6291
- listOverridesQuery = external_exports.object({
6292
- hub_id: external_exports.string().uuid(),
6293
- variant_id: external_exports.string().uuid()
6375
+ wsTicketResponse = external_exports.object({
6376
+ ticket: external_exports.string(),
6377
+ /** Seconds until the ticket expires if unconsumed. */
6378
+ expires_in: external_exports.number()
6294
6379
  });
6295
- deleteOverrideQuery = external_exports.object({
6296
- hub_id: external_exports.string().uuid(),
6297
- variant_id: external_exports.string().uuid(),
6298
- agent_id: external_exports.string().uuid()
6380
+ sessionCheckResponse = external_exports.object({
6381
+ valid: external_exports.literal(true)
6299
6382
  });
6300
- createExperimentBody = external_exports.object({
6301
- hub_id: external_exports.string().uuid(),
6302
- experiment_slug: slugSchema.optional(),
6303
- experiment_name: external_exports.string().min(1, "experiment_name is required").max(100, "experiment_name must be 100 characters or fewer"),
6304
- primary_metric: external_exports.string().max(200).nullish(),
6305
- status: experimentStatusSchema.default("draft")
6383
+ logoutResponse = external_exports.object({
6384
+ success: external_exports.literal(true)
6306
6385
  });
6307
- updateExperimentBody = external_exports.object({
6308
- // experiment_slug is immutable after first persist — not accepted here.
6309
- experiment_name: external_exports.string().min(1).max(100).optional(),
6310
- primary_metric: external_exports.string().max(200).nullish(),
6311
- control_variant_id: external_exports.string().uuid().nullish()
6386
+ magicCodeSendBody = external_exports.object({
6387
+ email: external_exports.string().email("Invalid email").max(254)
6388
+ // RFC 5321 max; bounds the request payload
6312
6389
  });
6313
- setExperimentStatusBody = external_exports.object({
6314
- status: experimentStatusSchema
6390
+ magicCodeSendResponse = external_exports.object({
6391
+ success: external_exports.literal(true)
6315
6392
  });
6316
- createVariantBody = external_exports.object({
6317
- hub_id: external_exports.string().uuid(),
6318
- experiment_id: external_exports.string().uuid(),
6319
- label: external_exports.string().min(1, "label is required").max(100, "label must be 100 characters or fewer"),
6320
- weight: external_exports.number().positive().default(1),
6321
- ai_mode: variantAiModeSchema.nullish(),
6322
- is_control: external_exports.boolean().default(false)
6393
+ magicCodeVerifyBody = external_exports.object({
6394
+ email: external_exports.string().email("Invalid email").max(254),
6395
+ // RFC 5321 max; bounds the request payload
6396
+ code: external_exports.string().min(1, "Code is required").max(12)
6397
+ // WorkOS sends a 6-digit code; bound the input
6323
6398
  });
6324
- updateVariantBody = external_exports.object({
6325
- label: external_exports.string().min(1).max(100).optional(),
6326
- weight: external_exports.number().positive().optional(),
6327
- ai_mode: variantAiModeSchema.nullish(),
6328
- is_control: external_exports.boolean().optional()
6399
+ magicCodeVerifyResponse = external_exports.object({
6400
+ access_token: external_exports.string(),
6401
+ refresh_token: external_exports.string()
6329
6402
  });
6330
- upsertOverrideBody = external_exports.object({
6331
- hub_id: external_exports.string().uuid(),
6332
- variant_id: external_exports.string().uuid(),
6333
- agent_id: external_exports.string().uuid(),
6334
- instructions: external_exports.string().nullish(),
6335
- additional_context_template: external_exports.string().nullish(),
6336
- connection_id: external_exports.string().uuid().nullish(),
6337
- agent_settings_overlay: overlayUpdateSchema
6403
+ passwordLoginBody = external_exports.object({
6404
+ email: external_exports.string().email("Invalid email").max(254),
6405
+ // RFC 5321 max; bounds the request payload
6406
+ password: external_exports.string().min(1, "Password is required").max(128)
6407
+ // bound the payload; WorkOS validates
6338
6408
  });
6409
+ normalizeEmail = (email) => email.trim().toLowerCase();
6410
+ REVIEW_ACCOUNT_EMAILS = new Set(
6411
+ ["apple.review@wayai.pro", "play.review@wayai.pro", "microsoft.review@wayai.pro", "meta.review@wayai.pro"].map(
6412
+ normalizeEmail
6413
+ )
6414
+ );
6415
+ }
6416
+ });
6417
+
6418
+ // ../../packages/core/dist/chunk-PFGVH2CX.js
6419
+ var secondFactorCode, secondFactorRecoveryCode, secondFactorCodeBody, secondFactorRecoveryBody, secondFactorDisableBody, setOrgSecondFactorBody;
6420
+ var init_chunk_PFGVH2CX = __esm({
6421
+ "../../packages/core/dist/chunk-PFGVH2CX.js"() {
6422
+ "use strict";
6423
+ init_chunk_KEN2DASI();
6424
+ init_zod();
6425
+ secondFactorCode = external_exports.string().regex(/^\d{6}$/, "Enter the 6-digit code");
6426
+ secondFactorRecoveryCode = external_exports.string().min(1, "Enter a recovery code").max(64);
6427
+ secondFactorCodeBody = external_exports.object({ code: secondFactorCode });
6428
+ secondFactorRecoveryBody = external_exports.object({ recovery_code: secondFactorRecoveryCode });
6429
+ secondFactorDisableBody = external_exports.union([
6430
+ external_exports.object({ code: secondFactorCode, recovery_code: external_exports.undefined().optional() }),
6431
+ external_exports.object({ recovery_code: secondFactorRecoveryCode, code: external_exports.undefined().optional() })
6432
+ ]);
6433
+ setOrgSecondFactorBody = external_exports.object({ tier: secondFactorTier });
6339
6434
  }
6340
6435
  });
6341
6436
 
@@ -7608,101 +7703,6 @@ var init_chunk_IPDOHAZ5 = __esm({
7608
7703
  }
7609
7704
  });
7610
7705
 
7611
- // ../../packages/core/dist/chunk-KEN2DASI.js
7612
- var SECOND_FACTOR_TIERS, secondFactorTier, META_ENTITY_ID_PATTERN, metaEntityId, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, normalizeEmail, REVIEW_ACCOUNT_EMAILS;
7613
- var init_chunk_KEN2DASI = __esm({
7614
- "../../packages/core/dist/chunk-KEN2DASI.js"() {
7615
- "use strict";
7616
- init_zod();
7617
- SECOND_FACTOR_TIERS = ["off", "settings"];
7618
- secondFactorTier = external_exports.enum(SECOND_FACTOR_TIERS);
7619
- META_ENTITY_ID_PATTERN = /^\d{1,32}$/;
7620
- metaEntityId = external_exports.string().regex(META_ENTITY_ID_PATTERN, "must be a numeric Meta entity id");
7621
- whatsappCallbackBody = external_exports.object({
7622
- state: external_exports.string().min(1, "state is required"),
7623
- code: external_exports.string().optional(),
7624
- access_token: external_exports.string().optional(),
7625
- user_id: external_exports.string().optional(),
7626
- /**
7627
- * The phone number and WABA the operator actually picked in Meta's Embedded
7628
- * Signup popup (posted to the opener as `WA_EMBEDDED_SIGNUP`). Optional:
7629
- * older clients, and the redirect-based flow, never see that event and fall
7630
- * back to discovery.
7631
- */
7632
- phone_number_id: metaEntityId.optional(),
7633
- waba_id: metaEntityId.optional()
7634
- }).refine(
7635
- (data) => !!data.access_token || !!data.code,
7636
- { message: "Missing required parameters: state and either access_token or code" }
7637
- );
7638
- authMeResponse = external_exports.object({
7639
- user_id: external_exports.string(),
7640
- email: external_exports.string(),
7641
- org_id: external_exports.string().nullable(),
7642
- is_platform_admin: external_exports.boolean()
7643
- });
7644
- wsTicketResponse = external_exports.object({
7645
- ticket: external_exports.string(),
7646
- /** Seconds until the ticket expires if unconsumed. */
7647
- expires_in: external_exports.number()
7648
- });
7649
- sessionCheckResponse = external_exports.object({
7650
- valid: external_exports.literal(true)
7651
- });
7652
- logoutResponse = external_exports.object({
7653
- success: external_exports.literal(true)
7654
- });
7655
- magicCodeSendBody = external_exports.object({
7656
- email: external_exports.string().email("Invalid email").max(254)
7657
- // RFC 5321 max; bounds the request payload
7658
- });
7659
- magicCodeSendResponse = external_exports.object({
7660
- success: external_exports.literal(true)
7661
- });
7662
- magicCodeVerifyBody = external_exports.object({
7663
- email: external_exports.string().email("Invalid email").max(254),
7664
- // RFC 5321 max; bounds the request payload
7665
- code: external_exports.string().min(1, "Code is required").max(12)
7666
- // WorkOS sends a 6-digit code; bound the input
7667
- });
7668
- magicCodeVerifyResponse = external_exports.object({
7669
- access_token: external_exports.string(),
7670
- refresh_token: external_exports.string()
7671
- });
7672
- passwordLoginBody = external_exports.object({
7673
- email: external_exports.string().email("Invalid email").max(254),
7674
- // RFC 5321 max; bounds the request payload
7675
- password: external_exports.string().min(1, "Password is required").max(128)
7676
- // bound the payload; WorkOS validates
7677
- });
7678
- normalizeEmail = (email) => email.trim().toLowerCase();
7679
- REVIEW_ACCOUNT_EMAILS = new Set(
7680
- ["apple.review@wayai.pro", "play.review@wayai.pro", "microsoft.review@wayai.pro", "meta.review@wayai.pro"].map(
7681
- normalizeEmail
7682
- )
7683
- );
7684
- }
7685
- });
7686
-
7687
- // ../../packages/core/dist/chunk-PFGVH2CX.js
7688
- var secondFactorCode, secondFactorRecoveryCode, secondFactorCodeBody, secondFactorRecoveryBody, secondFactorDisableBody, setOrgSecondFactorBody;
7689
- var init_chunk_PFGVH2CX = __esm({
7690
- "../../packages/core/dist/chunk-PFGVH2CX.js"() {
7691
- "use strict";
7692
- init_chunk_KEN2DASI();
7693
- init_zod();
7694
- secondFactorCode = external_exports.string().regex(/^\d{6}$/, "Enter the 6-digit code");
7695
- secondFactorRecoveryCode = external_exports.string().min(1, "Enter a recovery code").max(64);
7696
- secondFactorCodeBody = external_exports.object({ code: secondFactorCode });
7697
- secondFactorRecoveryBody = external_exports.object({ recovery_code: secondFactorRecoveryCode });
7698
- secondFactorDisableBody = external_exports.union([
7699
- external_exports.object({ code: secondFactorCode, recovery_code: external_exports.undefined().optional() }),
7700
- external_exports.object({ recovery_code: secondFactorRecoveryCode, code: external_exports.undefined().optional() })
7701
- ]);
7702
- setOrgSecondFactorBody = external_exports.object({ tier: secondFactorTier });
7703
- }
7704
- });
7705
-
7706
7706
  // ../../packages/core/dist/chunk-FPSDNS2E.js
7707
7707
  var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
7708
7708
  var init_chunk_FPSDNS2E = __esm({
@@ -8247,6 +8247,370 @@ var init_chunk_Y7CFCYX4 = __esm({
8247
8247
  }
8248
8248
  });
8249
8249
 
8250
+ // ../../packages/core/dist/chunk-ZIGA5RCU.js
8251
+ var BINDING_EACH_MAX_ITEMS, BINDING_TEXT_MAX_OUTPUT, BINDING_ROOTS, BINDING_NAME_SEGMENT_REGEX;
8252
+ var init_chunk_ZIGA5RCU = __esm({
8253
+ "../../packages/core/dist/chunk-ZIGA5RCU.js"() {
8254
+ "use strict";
8255
+ BINDING_EACH_MAX_ITEMS = 100;
8256
+ BINDING_TEXT_MAX_OUTPUT = 16 * 1024;
8257
+ BINDING_ROOTS = ["params", "state", "data", "form", "item", "this"];
8258
+ BINDING_NAME_SEGMENT_REGEX = /^[A-Za-z_][A-Za-z0-9_-]*$/;
8259
+ }
8260
+ });
8261
+
8262
+ // ../../packages/core/dist/chunk-BGNWWR6B.js
8263
+ var INTERACTIVE_TEMPLATE_MAX_CHARS, INTERACTIVE_TEMPLATE_MAX_BLOCKS, INTERACTIVE_TEMPLATE_MAX_ACTIONS, INTERACTIVE_TEMPLATE_TEXT_MAX, INTERACTIVE_TEMPLATE_FALLBACK_MAX, INTERACTIVE_TEMPLATE_DESCRIPTION_MAX, INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS, INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS, INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX, INTERACTIVE_TEMPLATE_OPTIONS_MAX, PATH_MAX, TOOL_NAME_MAX, interactiveTemplateNameSchema, actionNameSchema, INTERACTIVE_TEMPLATE_FIELD_NAME_REGEX, RESERVED_FIELD_NAMES, TEMPLATE_TONES, TEMPLATE_INPUT_TYPES, TEMPLATE_ALIGNS, TEMPLATE_JUSTIFIES, TEMPLATE_TITLE_SIZES, TEMPLATE_TEXT_SIZES, TEMPLATE_TEXT_WEIGHTS, TEMPLATE_BADGE_VARIANTS, TEMPLATE_BUTTON_STYLES, TEMPLATE_LIST_DIRECTIONS, text, label, path2, binding, common, fieldCommon, children, containerProps, optionSchema, templateBlockSchema, blockSchema, unanchored, INTERACTIVE_TEMPLATE_STATE_PATH_REGEX, valueTemplate, statePath, templateActionSchema, paramsJsonSchema, dataSchema, interactiveTemplateDefinitionSchema;
8264
+ var init_chunk_BGNWWR6B = __esm({
8265
+ "../../packages/core/dist/chunk-BGNWWR6B.js"() {
8266
+ "use strict";
8267
+ init_chunk_ZIGA5RCU();
8268
+ init_chunk_6TSQ5HXC();
8269
+ init_chunk_WEXVYJ5H();
8270
+ init_chunk_HZ6CADSY();
8271
+ init_zod();
8272
+ INTERACTIVE_TEMPLATE_MAX_CHARS = 64 * 1024;
8273
+ INTERACTIVE_TEMPLATE_MAX_BLOCKS = 200;
8274
+ INTERACTIVE_TEMPLATE_MAX_ACTIONS = 30;
8275
+ INTERACTIVE_TEMPLATE_TEXT_MAX = 2e3;
8276
+ INTERACTIVE_TEMPLATE_FALLBACK_MAX = 4e3;
8277
+ INTERACTIVE_TEMPLATE_DESCRIPTION_MAX = 500;
8278
+ INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS = 16 * 1024;
8279
+ INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS = 4 * 1024;
8280
+ INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX = 20;
8281
+ INTERACTIVE_TEMPLATE_OPTIONS_MAX = 50;
8282
+ PATH_MAX = 256;
8283
+ TOOL_NAME_MAX = 128;
8284
+ interactiveTemplateNameSchema = external_exports.string().regex(SLUG_REGEX, {
8285
+ message: 'a template name is lowercase letters, digits and underscores, starting with a letter (e.g. "menu")'
8286
+ });
8287
+ actionNameSchema = external_exports.string().regex(SLUG_REGEX, {
8288
+ message: "an action name is lowercase letters, digits and underscores, starting with a letter"
8289
+ });
8290
+ INTERACTIVE_TEMPLATE_FIELD_NAME_REGEX = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
8291
+ RESERVED_FIELD_NAMES = new Set(BINDING_ROOTS);
8292
+ TEMPLATE_TONES = ["default", "secondary", "success", "danger", "warning", "info"];
8293
+ TEMPLATE_INPUT_TYPES = ["text", "number", "email", "tel", "date"];
8294
+ TEMPLATE_ALIGNS = ["start", "center", "end", "stretch"];
8295
+ TEMPLATE_JUSTIFIES = ["start", "center", "end", "between"];
8296
+ TEMPLATE_TITLE_SIZES = ["sm", "md", "lg"];
8297
+ TEMPLATE_TEXT_SIZES = ["xs", "sm", "md", "lg"];
8298
+ TEMPLATE_TEXT_WEIGHTS = ["normal", "medium", "bold"];
8299
+ TEMPLATE_BADGE_VARIANTS = ["solid", "soft", "outline"];
8300
+ TEMPLATE_BUTTON_STYLES = ["primary", "secondary"];
8301
+ TEMPLATE_LIST_DIRECTIONS = ["vertical", "horizontal"];
8302
+ text = external_exports.string().max(INTERACTIVE_TEMPLATE_TEXT_MAX);
8303
+ label = text.min(1);
8304
+ path2 = external_exports.string().min(1).max(PATH_MAX);
8305
+ binding = external_exports.string().min(1).max(PATH_MAX);
8306
+ common = { if: path2.optional() };
8307
+ fieldCommon = {
8308
+ ...common,
8309
+ name: label,
8310
+ label: text.optional(),
8311
+ required: external_exports.union([external_exports.boolean(), binding]).optional(),
8312
+ source: text.optional()
8313
+ };
8314
+ children = () => external_exports.array(blockSchema).min(1).max(INTERACTIVE_TEMPLATE_MAX_BLOCKS);
8315
+ containerProps = () => ({
8316
+ gap: external_exports.number().int().min(0).max(8).optional(),
8317
+ align: external_exports.enum(TEMPLATE_ALIGNS).optional(),
8318
+ justify: external_exports.enum(TEMPLATE_JUSTIFIES).optional()
8319
+ });
8320
+ optionSchema = external_exports.object({ value: text, label }).strict();
8321
+ templateBlockSchema = external_exports.lazy(
8322
+ () => external_exports.discriminatedUnion("type", [
8323
+ external_exports.object({ ...common, type: external_exports.literal("card"), children: children() }).strict(),
8324
+ external_exports.object({ ...common, ...containerProps(), type: external_exports.literal("row"), children: children() }).strict(),
8325
+ external_exports.object({ ...common, ...containerProps(), type: external_exports.literal("col"), children: children() }).strict(),
8326
+ external_exports.object({
8327
+ ...common,
8328
+ type: external_exports.literal("list"),
8329
+ each: path2,
8330
+ item: blockSchema,
8331
+ direction: external_exports.enum(TEMPLATE_LIST_DIRECTIONS).optional(),
8332
+ limit: external_exports.number().int().min(1).max(BINDING_EACH_MAX_ITEMS).optional(),
8333
+ key: external_exports.string().max(64).regex(BINDING_NAME_SEGMENT_REGEX).optional(),
8334
+ empty: text.optional()
8335
+ }).strict(),
8336
+ external_exports.object({ ...common, type: external_exports.literal("image"), src: label, alt: text.optional() }).strict(),
8337
+ external_exports.object({ ...common, type: external_exports.literal("title"), text: label, size: external_exports.enum(TEMPLATE_TITLE_SIZES).optional() }).strict(),
8338
+ external_exports.object({
8339
+ ...common,
8340
+ type: external_exports.literal("text"),
8341
+ text: label,
8342
+ size: external_exports.enum(TEMPLATE_TEXT_SIZES).optional(),
8343
+ weight: external_exports.enum(TEMPLATE_TEXT_WEIGHTS).optional(),
8344
+ color: external_exports.enum(TEMPLATE_TONES).optional()
8345
+ }).strict(),
8346
+ external_exports.object({
8347
+ ...common,
8348
+ type: external_exports.literal("badge"),
8349
+ text: label,
8350
+ color: external_exports.enum(TEMPLATE_TONES).optional(),
8351
+ variant: external_exports.enum(TEMPLATE_BADGE_VARIANTS).optional()
8352
+ }).strict(),
8353
+ external_exports.object({ ...common, type: external_exports.literal("divider") }).strict(),
8354
+ external_exports.object({
8355
+ ...common,
8356
+ type: external_exports.literal("button"),
8357
+ label,
8358
+ action: actionNameSchema,
8359
+ style: external_exports.enum(TEMPLATE_BUTTON_STYLES).optional()
8360
+ }).strict(),
8361
+ external_exports.object({
8362
+ ...fieldCommon,
8363
+ type: external_exports.literal("select"),
8364
+ options: external_exports.union([external_exports.array(optionSchema).min(1).max(INTERACTIVE_TEMPLATE_OPTIONS_MAX), binding]),
8365
+ placeholder: text.optional(),
8366
+ default_value: text.optional()
8367
+ }).strict(),
8368
+ external_exports.object({
8369
+ ...fieldCommon,
8370
+ type: external_exports.literal("input"),
8371
+ input_type: external_exports.union([external_exports.enum(TEMPLATE_INPUT_TYPES), binding]).optional(),
8372
+ placeholder: text.optional(),
8373
+ default_value: text.optional()
8374
+ }).strict(),
8375
+ external_exports.object({
8376
+ ...fieldCommon,
8377
+ type: external_exports.literal("checkbox"),
8378
+ label,
8379
+ default_checked: external_exports.union([external_exports.boolean(), binding]).optional()
8380
+ }).strict(),
8381
+ external_exports.object({
8382
+ ...common,
8383
+ type: external_exports.literal("form"),
8384
+ children: children(),
8385
+ submit: actionNameSchema,
8386
+ submit_label: text.optional()
8387
+ }).strict()
8388
+ ])
8389
+ );
8390
+ blockSchema = templateBlockSchema;
8391
+ unanchored = (regex) => regex.source.replace(/^\^/, "").replace(/\$$/, "");
8392
+ INTERACTIVE_TEMPLATE_STATE_PATH_REGEX = new RegExp(
8393
+ `^state\\.${unanchored(SLUG_REGEX)}(\\.${unanchored(BINDING_NAME_SEGMENT_REGEX)}){0,10}$`
8394
+ );
8395
+ valueTemplate = external_exports.unknown().superRefine((value, ctx) => {
8396
+ if (!withinJsonLength(value, INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS)) {
8397
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `a value is JSON of at most ${INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS} characters` });
8398
+ }
8399
+ });
8400
+ statePath = external_exports.string().regex(INTERACTIVE_TEMPLATE_STATE_PATH_REGEX, {
8401
+ message: 'a state path is "state.<state slug>" then field names (e.g. "state.order.items")'
8402
+ });
8403
+ templateActionSchema = external_exports.discriminatedUnion("type", [
8404
+ external_exports.object({ type: external_exports.literal("send"), text: label.optional(), values: valueTemplate.optional() }).strict(),
8405
+ external_exports.object({ type: external_exports.literal("set_state"), path: statePath, value: valueTemplate }).strict(),
8406
+ external_exports.object({ type: external_exports.literal("append_state"), path: statePath, value: valueTemplate }).strict(),
8407
+ external_exports.object({ type: external_exports.literal("remove_state"), path: statePath, value: valueTemplate }).strict()
8408
+ ]).superRefine((action, ctx) => {
8409
+ if (action.type === "send" && action.text === void 0 && action.values === void 0) {
8410
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "a send action has text, values, or both" });
8411
+ }
8412
+ });
8413
+ paramsJsonSchema = external_exports.record(external_exports.unknown()).superRefine((schema, ctx) => {
8414
+ if (!withinJsonLength(schema, INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS)) {
8415
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `params is at most ${INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS} characters of JSON` });
8416
+ return;
8417
+ }
8418
+ const result = validateToolInputSchema(schema);
8419
+ if (!result.ok) {
8420
+ for (const error of result.errors) {
8421
+ ctx.addIssue({
8422
+ code: external_exports.ZodIssueCode.custom,
8423
+ message: `params is not a valid JSON Schema${error.path ? ` at "${error.path}"` : ""}: ${error.message}`
8424
+ });
8425
+ }
8426
+ }
8427
+ });
8428
+ dataSchema = external_exports.object({
8429
+ /** The tool's name, as the agent holds it. The backend calls it; the model never types its data. */
8430
+ tool: external_exports.string().trim().min(1).max(TOOL_NAME_MAX),
8431
+ params: external_exports.union([
8432
+ external_exports.array(external_exports.string()).max(INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX),
8433
+ external_exports.record(valueTemplate).refine((r) => Object.keys(r).length <= INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX, {
8434
+ message: `data.params passes at most ${INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX} values`
8435
+ })
8436
+ ]).default({}).transform(
8437
+ (params) => Array.isArray(params) ? Object.fromEntries(params.map((name) => [name, `{{params.${name}}}`])) : params
8438
+ ),
8439
+ /** The result's top-level fields the template reads: what the message's data snapshot keeps. */
8440
+ fields: external_exports.array(external_exports.string().max(64).regex(BINDING_NAME_SEGMENT_REGEX)).min(1).max(INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX)
8441
+ }).strict();
8442
+ interactiveTemplateDefinitionSchema = external_exports.object({
8443
+ name: interactiveTemplateNameSchema,
8444
+ description: external_exports.string().trim().min(1).max(INTERACTIVE_TEMPLATE_DESCRIPTION_MAX),
8445
+ params: paramsJsonSchema.default({ type: "object", properties: {} }),
8446
+ data: dataSchema.optional(),
8447
+ /** Phase 1: the one view, `main`. Phase 1b adds others beside it. */
8448
+ views: external_exports.object({ main: blockSchema }).strict(),
8449
+ actions: external_exports.record(actionNameSchema, templateActionSchema).default({}).refine((actions) => Object.keys(actions).length <= INTERACTIVE_TEMPLATE_MAX_ACTIONS, {
8450
+ message: `at most ${INTERACTIVE_TEMPLATE_MAX_ACTIONS} actions`
8451
+ }),
8452
+ fallback: external_exports.string().trim().min(1).max(INTERACTIVE_TEMPLATE_FALLBACK_MAX)
8453
+ }).strict();
8454
+ }
8455
+ });
8456
+
8457
+ // ../../packages/core/dist/chunk-2ZZZHXZR.js
8458
+ var OPTION_ITEM, choices, form;
8459
+ var init_chunk_2ZZZHXZR = __esm({
8460
+ "../../packages/core/dist/chunk-2ZZZHXZR.js"() {
8461
+ "use strict";
8462
+ init_chunk_BGNWWR6B();
8463
+ OPTION_ITEM = {
8464
+ type: "object",
8465
+ properties: {
8466
+ id: { type: "string", description: "What the agent receives when this one is picked" },
8467
+ label: { type: "string", description: "What the person sees" }
8468
+ },
8469
+ required: ["id", "label"]
8470
+ };
8471
+ choices = {
8472
+ name: "choices",
8473
+ description: "A question with up to 10 options, each with an optional description. The person picks one; the agent receives its id and label.",
8474
+ params: {
8475
+ type: "object",
8476
+ properties: {
8477
+ prompt: { type: "string", description: "The question, shown above the options" },
8478
+ options: {
8479
+ type: "array",
8480
+ minItems: 1,
8481
+ maxItems: 10,
8482
+ items: {
8483
+ ...OPTION_ITEM,
8484
+ properties: { ...OPTION_ITEM.properties, description: { type: "string", description: "A line under the label" } }
8485
+ }
8486
+ }
8487
+ },
8488
+ required: ["options"]
8489
+ },
8490
+ views: {
8491
+ main: {
8492
+ type: "card",
8493
+ children: [
8494
+ { type: "text", if: "params.prompt", text: "{{params.prompt}}" },
8495
+ {
8496
+ type: "list",
8497
+ each: "params.options",
8498
+ item: {
8499
+ type: "col",
8500
+ gap: 1,
8501
+ children: [
8502
+ { type: "button", label: "{{item.label}}", action: "choose" },
8503
+ { type: "text", if: "item.description", text: "{{item.description}}", size: "sm", color: "secondary" }
8504
+ ]
8505
+ }
8506
+ }
8507
+ ]
8508
+ }
8509
+ },
8510
+ actions: {
8511
+ choose: { type: "send", text: "{{item.label}}", values: { id: "{{item.id}}" } }
8512
+ },
8513
+ fallback: "{{#if params.prompt}}{{params.prompt}}\n{{/if}}{{#each params.options}}{{@n}}. {{label}}{{#if description}} \u2014 {{description}}{{/if}}\n{{/each}}"
8514
+ };
8515
+ form = {
8516
+ name: "form",
8517
+ description: "A form of up to 20 fields, each a text input, a select or a checkbox, optionally pre-filled and annotated with where its value came from. The person submits it; the agent receives the values.",
8518
+ params: {
8519
+ type: "object",
8520
+ properties: {
8521
+ title: { type: "string", description: "Shown above the fields" },
8522
+ submit_label: { type: "string", description: "The submit button's label" },
8523
+ fields: {
8524
+ type: "array",
8525
+ minItems: 1,
8526
+ maxItems: 20,
8527
+ items: {
8528
+ type: "object",
8529
+ properties: {
8530
+ name: { type: "string", pattern: INTERACTIVE_TEMPLATE_FIELD_NAME_REGEX.source, description: "The key the value is submitted under" },
8531
+ label: { type: "string" },
8532
+ input: {
8533
+ type: "string",
8534
+ enum: [...TEMPLATE_INPUT_TYPES],
8535
+ description: "A text input of this type. Give exactly one of input, select or checkbox."
8536
+ },
8537
+ select: { type: "array", minItems: 1, maxItems: INTERACTIVE_TEMPLATE_OPTIONS_MAX, items: { type: "object", properties: { value: { type: "string" }, label: { type: "string" } }, required: ["value", "label"] } },
8538
+ checkbox: { type: "boolean", enum: [true] },
8539
+ value: { type: ["string", "number", "boolean"], description: "The pre-filled value (a checkbox: true when checked)" },
8540
+ placeholder: { type: "string" },
8541
+ required: { type: "boolean" },
8542
+ source: { type: "string", description: "Where the pre-filled value came from, shown under the field" }
8543
+ },
8544
+ required: ["name", "label"],
8545
+ oneOf: [{ required: ["input"] }, { required: ["select"] }, { required: ["checkbox"] }]
8546
+ }
8547
+ }
8548
+ },
8549
+ required: ["fields"]
8550
+ },
8551
+ views: {
8552
+ main: {
8553
+ type: "card",
8554
+ children: [
8555
+ { type: "title", if: "params.title", text: "{{params.title}}" },
8556
+ {
8557
+ type: "form",
8558
+ submit: "submit",
8559
+ submit_label: "{{params.submit_label}}",
8560
+ children: [
8561
+ {
8562
+ type: "list",
8563
+ each: "params.fields",
8564
+ item: {
8565
+ type: "col",
8566
+ children: [
8567
+ {
8568
+ type: "input",
8569
+ if: "item.input",
8570
+ name: "{{item.name}}",
8571
+ label: "{{item.label}}",
8572
+ input_type: "{{item.input}}",
8573
+ placeholder: "{{item.placeholder}}",
8574
+ default_value: "{{item.value}}",
8575
+ required: "{{item.required}}",
8576
+ source: "{{item.source}}"
8577
+ },
8578
+ {
8579
+ type: "select",
8580
+ if: "item.select",
8581
+ name: "{{item.name}}",
8582
+ label: "{{item.label}}",
8583
+ options: "{{item.select}}",
8584
+ placeholder: "{{item.placeholder}}",
8585
+ default_value: "{{item.value}}",
8586
+ required: "{{item.required}}",
8587
+ source: "{{item.source}}"
8588
+ },
8589
+ {
8590
+ type: "checkbox",
8591
+ if: "item.checkbox",
8592
+ name: "{{item.name}}",
8593
+ label: "{{item.label}}",
8594
+ default_checked: "{{item.value}}",
8595
+ required: "{{item.required}}",
8596
+ source: "{{item.source}}"
8597
+ }
8598
+ ]
8599
+ }
8600
+ }
8601
+ ]
8602
+ }
8603
+ ]
8604
+ }
8605
+ },
8606
+ actions: {
8607
+ submit: { type: "send", values: "{{form}}" }
8608
+ },
8609
+ fallback: "{{#if params.title}}{{params.title}}\n{{/if}}{{#each params.fields}}- {{label}}{{#if value}}: {{value}}{{/if}}\n{{/each}}"
8610
+ };
8611
+ }
8612
+ });
8613
+
8250
8614
  // ../../packages/core/dist/chunk-YUZFHVB2.js
8251
8615
  var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
8252
8616
  var init_chunk_YUZFHVB2 = __esm({
@@ -8693,6 +9057,32 @@ var init_chunk_34LE6P7E = __esm({
8693
9057
  }
8694
9058
  });
8695
9059
 
9060
+ // ../../packages/core/dist/chunk-C4HEZ7ZI.js
9061
+ var downloadBody, uploadQuery, SIGN_URL_MAX_EXPIRES_IN_SECONDS, signUrlBody;
9062
+ var init_chunk_C4HEZ7ZI = __esm({
9063
+ "../../packages/core/dist/chunk-C4HEZ7ZI.js"() {
9064
+ "use strict";
9065
+ init_chunk_CJ3L46X6();
9066
+ init_zod();
9067
+ downloadBody = external_exports.object({
9068
+ type: external_exports.enum(["workspace", "agent_instructions"]),
9069
+ agent_id: external_exports.string().uuid().optional(),
9070
+ organization_name: external_exports.string().optional()
9071
+ });
9072
+ uploadQuery = external_exports.object({
9073
+ type: external_exports.enum(["agent_instructions"]),
9074
+ agent_id: external_exports.string().uuid(),
9075
+ hub_id: external_exports.string().uuid()
9076
+ });
9077
+ SIGN_URL_MAX_EXPIRES_IN_SECONDS = 3600;
9078
+ signUrlBody = external_exports.object({
9079
+ bucket: external_exports.string(),
9080
+ filePath: external_exports.string(),
9081
+ expiresIn: external_exports.number().int().positive().max(SIGN_URL_MAX_EXPIRES_IN_SECONDS).optional()
9082
+ });
9083
+ }
9084
+ });
9085
+
8696
9086
  // ../../packages/core/dist/chunk-IR2NOSI3.js
8697
9087
  var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
8698
9088
  var init_chunk_IR2NOSI3 = __esm({
@@ -8807,367 +9197,21 @@ var init_chunk_SY6PLCPK = __esm({
8807
9197
  }
8808
9198
  });
8809
9199
 
8810
- // ../../packages/core/dist/chunk-ZIGA5RCU.js
8811
- var BINDING_EACH_MAX_ITEMS, BINDING_TEXT_MAX_OUTPUT, BINDING_ROOTS, BINDING_NAME_SEGMENT_REGEX;
8812
- var init_chunk_ZIGA5RCU = __esm({
8813
- "../../packages/core/dist/chunk-ZIGA5RCU.js"() {
8814
- "use strict";
8815
- BINDING_EACH_MAX_ITEMS = 100;
8816
- BINDING_TEXT_MAX_OUTPUT = 16 * 1024;
8817
- BINDING_ROOTS = ["params", "state", "data", "form", "item", "this"];
8818
- BINDING_NAME_SEGMENT_REGEX = /^[A-Za-z_][A-Za-z0-9_-]*$/;
8819
- }
8820
- });
8821
-
8822
- // ../../packages/core/dist/chunk-BGNWWR6B.js
8823
- var INTERACTIVE_TEMPLATE_MAX_CHARS, INTERACTIVE_TEMPLATE_MAX_BLOCKS, INTERACTIVE_TEMPLATE_MAX_ACTIONS, INTERACTIVE_TEMPLATE_TEXT_MAX, INTERACTIVE_TEMPLATE_FALLBACK_MAX, INTERACTIVE_TEMPLATE_DESCRIPTION_MAX, INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS, INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS, INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX, INTERACTIVE_TEMPLATE_OPTIONS_MAX, PATH_MAX, TOOL_NAME_MAX, interactiveTemplateNameSchema, actionNameSchema, INTERACTIVE_TEMPLATE_FIELD_NAME_REGEX, RESERVED_FIELD_NAMES, TEMPLATE_TONES, TEMPLATE_INPUT_TYPES, TEMPLATE_ALIGNS, TEMPLATE_JUSTIFIES, TEMPLATE_TITLE_SIZES, TEMPLATE_TEXT_SIZES, TEMPLATE_TEXT_WEIGHTS, TEMPLATE_BADGE_VARIANTS, TEMPLATE_BUTTON_STYLES, TEMPLATE_LIST_DIRECTIONS, text, label, path2, binding, common, fieldCommon, children, containerProps, optionSchema, templateBlockSchema, blockSchema, unanchored, INTERACTIVE_TEMPLATE_STATE_PATH_REGEX, valueTemplate, statePath, templateActionSchema, paramsJsonSchema, dataSchema, interactiveTemplateDefinitionSchema;
8824
- var init_chunk_BGNWWR6B = __esm({
8825
- "../../packages/core/dist/chunk-BGNWWR6B.js"() {
9200
+ // ../../packages/core/dist/chunk-ACGAI25T.js
9201
+ var listPendingSchedulesQuery, listHubAggregateSchedulesQuery;
9202
+ var init_chunk_ACGAI25T = __esm({
9203
+ "../../packages/core/dist/chunk-ACGAI25T.js"() {
8826
9204
  "use strict";
8827
- init_chunk_ZIGA5RCU();
8828
- init_chunk_6TSQ5HXC();
8829
- init_chunk_WEXVYJ5H();
8830
- init_chunk_HZ6CADSY();
8831
9205
  init_zod();
8832
- INTERACTIVE_TEMPLATE_MAX_CHARS = 64 * 1024;
8833
- INTERACTIVE_TEMPLATE_MAX_BLOCKS = 200;
8834
- INTERACTIVE_TEMPLATE_MAX_ACTIONS = 30;
8835
- INTERACTIVE_TEMPLATE_TEXT_MAX = 2e3;
8836
- INTERACTIVE_TEMPLATE_FALLBACK_MAX = 4e3;
8837
- INTERACTIVE_TEMPLATE_DESCRIPTION_MAX = 500;
8838
- INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS = 16 * 1024;
8839
- INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS = 4 * 1024;
8840
- INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX = 20;
8841
- INTERACTIVE_TEMPLATE_OPTIONS_MAX = 50;
8842
- PATH_MAX = 256;
8843
- TOOL_NAME_MAX = 128;
8844
- interactiveTemplateNameSchema = external_exports.string().regex(SLUG_REGEX, {
8845
- message: 'a template name is lowercase letters, digits and underscores, starting with a letter (e.g. "menu")'
8846
- });
8847
- actionNameSchema = external_exports.string().regex(SLUG_REGEX, {
8848
- message: "an action name is lowercase letters, digits and underscores, starting with a letter"
8849
- });
8850
- INTERACTIVE_TEMPLATE_FIELD_NAME_REGEX = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
8851
- RESERVED_FIELD_NAMES = new Set(BINDING_ROOTS);
8852
- TEMPLATE_TONES = ["default", "secondary", "success", "danger", "warning", "info"];
8853
- TEMPLATE_INPUT_TYPES = ["text", "number", "email", "tel", "date"];
8854
- TEMPLATE_ALIGNS = ["start", "center", "end", "stretch"];
8855
- TEMPLATE_JUSTIFIES = ["start", "center", "end", "between"];
8856
- TEMPLATE_TITLE_SIZES = ["sm", "md", "lg"];
8857
- TEMPLATE_TEXT_SIZES = ["xs", "sm", "md", "lg"];
8858
- TEMPLATE_TEXT_WEIGHTS = ["normal", "medium", "bold"];
8859
- TEMPLATE_BADGE_VARIANTS = ["solid", "soft", "outline"];
8860
- TEMPLATE_BUTTON_STYLES = ["primary", "secondary"];
8861
- TEMPLATE_LIST_DIRECTIONS = ["vertical", "horizontal"];
8862
- text = external_exports.string().max(INTERACTIVE_TEMPLATE_TEXT_MAX);
8863
- label = text.min(1);
8864
- path2 = external_exports.string().min(1).max(PATH_MAX);
8865
- binding = external_exports.string().min(1).max(PATH_MAX);
8866
- common = { if: path2.optional() };
8867
- fieldCommon = {
8868
- ...common,
8869
- name: label,
8870
- label: text.optional(),
8871
- required: external_exports.union([external_exports.boolean(), binding]).optional(),
8872
- source: text.optional()
8873
- };
8874
- children = () => external_exports.array(blockSchema).min(1).max(INTERACTIVE_TEMPLATE_MAX_BLOCKS);
8875
- containerProps = () => ({
8876
- gap: external_exports.number().int().min(0).max(8).optional(),
8877
- align: external_exports.enum(TEMPLATE_ALIGNS).optional(),
8878
- justify: external_exports.enum(TEMPLATE_JUSTIFIES).optional()
8879
- });
8880
- optionSchema = external_exports.object({ value: text, label }).strict();
8881
- templateBlockSchema = external_exports.lazy(
8882
- () => external_exports.discriminatedUnion("type", [
8883
- external_exports.object({ ...common, type: external_exports.literal("card"), children: children() }).strict(),
8884
- external_exports.object({ ...common, ...containerProps(), type: external_exports.literal("row"), children: children() }).strict(),
8885
- external_exports.object({ ...common, ...containerProps(), type: external_exports.literal("col"), children: children() }).strict(),
8886
- external_exports.object({
8887
- ...common,
8888
- type: external_exports.literal("list"),
8889
- each: path2,
8890
- item: blockSchema,
8891
- direction: external_exports.enum(TEMPLATE_LIST_DIRECTIONS).optional(),
8892
- limit: external_exports.number().int().min(1).max(BINDING_EACH_MAX_ITEMS).optional(),
8893
- key: external_exports.string().max(64).regex(BINDING_NAME_SEGMENT_REGEX).optional(),
8894
- empty: text.optional()
8895
- }).strict(),
8896
- external_exports.object({ ...common, type: external_exports.literal("image"), src: label, alt: text.optional() }).strict(),
8897
- external_exports.object({ ...common, type: external_exports.literal("title"), text: label, size: external_exports.enum(TEMPLATE_TITLE_SIZES).optional() }).strict(),
8898
- external_exports.object({
8899
- ...common,
8900
- type: external_exports.literal("text"),
8901
- text: label,
8902
- size: external_exports.enum(TEMPLATE_TEXT_SIZES).optional(),
8903
- weight: external_exports.enum(TEMPLATE_TEXT_WEIGHTS).optional(),
8904
- color: external_exports.enum(TEMPLATE_TONES).optional()
8905
- }).strict(),
8906
- external_exports.object({
8907
- ...common,
8908
- type: external_exports.literal("badge"),
8909
- text: label,
8910
- color: external_exports.enum(TEMPLATE_TONES).optional(),
8911
- variant: external_exports.enum(TEMPLATE_BADGE_VARIANTS).optional()
8912
- }).strict(),
8913
- external_exports.object({ ...common, type: external_exports.literal("divider") }).strict(),
8914
- external_exports.object({
8915
- ...common,
8916
- type: external_exports.literal("button"),
8917
- label,
8918
- action: actionNameSchema,
8919
- style: external_exports.enum(TEMPLATE_BUTTON_STYLES).optional()
8920
- }).strict(),
8921
- external_exports.object({
8922
- ...fieldCommon,
8923
- type: external_exports.literal("select"),
8924
- options: external_exports.union([external_exports.array(optionSchema).min(1).max(INTERACTIVE_TEMPLATE_OPTIONS_MAX), binding]),
8925
- placeholder: text.optional(),
8926
- default_value: text.optional()
8927
- }).strict(),
8928
- external_exports.object({
8929
- ...fieldCommon,
8930
- type: external_exports.literal("input"),
8931
- input_type: external_exports.union([external_exports.enum(TEMPLATE_INPUT_TYPES), binding]).optional(),
8932
- placeholder: text.optional(),
8933
- default_value: text.optional()
8934
- }).strict(),
8935
- external_exports.object({
8936
- ...fieldCommon,
8937
- type: external_exports.literal("checkbox"),
8938
- label,
8939
- default_checked: external_exports.union([external_exports.boolean(), binding]).optional()
8940
- }).strict(),
8941
- external_exports.object({
8942
- ...common,
8943
- type: external_exports.literal("form"),
8944
- children: children(),
8945
- submit: actionNameSchema,
8946
- submit_label: text.optional()
8947
- }).strict()
8948
- ])
8949
- );
8950
- blockSchema = templateBlockSchema;
8951
- unanchored = (regex) => regex.source.replace(/^\^/, "").replace(/\$$/, "");
8952
- INTERACTIVE_TEMPLATE_STATE_PATH_REGEX = new RegExp(
8953
- `^state\\.${unanchored(SLUG_REGEX)}(\\.${unanchored(BINDING_NAME_SEGMENT_REGEX)}){0,10}$`
8954
- );
8955
- valueTemplate = external_exports.unknown().superRefine((value, ctx) => {
8956
- if (!withinJsonLength(value, INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS)) {
8957
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `a value is JSON of at most ${INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS} characters` });
8958
- }
8959
- });
8960
- statePath = external_exports.string().regex(INTERACTIVE_TEMPLATE_STATE_PATH_REGEX, {
8961
- message: 'a state path is "state.<state slug>" then field names (e.g. "state.order.items")'
8962
- });
8963
- templateActionSchema = external_exports.discriminatedUnion("type", [
8964
- external_exports.object({ type: external_exports.literal("send"), text: label.optional(), values: valueTemplate.optional() }).strict(),
8965
- external_exports.object({ type: external_exports.literal("set_state"), path: statePath, value: valueTemplate }).strict(),
8966
- external_exports.object({ type: external_exports.literal("append_state"), path: statePath, value: valueTemplate }).strict(),
8967
- external_exports.object({ type: external_exports.literal("remove_state"), path: statePath, value: valueTemplate }).strict()
8968
- ]).superRefine((action, ctx) => {
8969
- if (action.type === "send" && action.text === void 0 && action.values === void 0) {
8970
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "a send action has text, values, or both" });
8971
- }
9206
+ listPendingSchedulesQuery = external_exports.object({
9207
+ hub_id: external_exports.string().uuid(),
9208
+ conversation_id: external_exports.string().uuid().optional(),
9209
+ user_id: external_exports.string().optional()
8972
9210
  });
8973
- paramsJsonSchema = external_exports.record(external_exports.unknown()).superRefine((schema, ctx) => {
8974
- if (!withinJsonLength(schema, INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS)) {
8975
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `params is at most ${INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS} characters of JSON` });
8976
- return;
8977
- }
8978
- const result = validateToolInputSchema(schema);
8979
- if (!result.ok) {
8980
- for (const error of result.errors) {
8981
- ctx.addIssue({
8982
- code: external_exports.ZodIssueCode.custom,
8983
- message: `params is not a valid JSON Schema${error.path ? ` at "${error.path}"` : ""}: ${error.message}`
8984
- });
8985
- }
8986
- }
9211
+ listHubAggregateSchedulesQuery = external_exports.object({
9212
+ hub_id: external_exports.string().uuid(),
9213
+ limit: external_exports.coerce.number().int().min(1).max(1e3).optional()
8987
9214
  });
8988
- dataSchema = external_exports.object({
8989
- /** The tool's name, as the agent holds it. The backend calls it; the model never types its data. */
8990
- tool: external_exports.string().trim().min(1).max(TOOL_NAME_MAX),
8991
- params: external_exports.union([
8992
- external_exports.array(external_exports.string()).max(INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX),
8993
- external_exports.record(valueTemplate).refine((r) => Object.keys(r).length <= INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX, {
8994
- message: `data.params passes at most ${INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX} values`
8995
- })
8996
- ]).default({}).transform(
8997
- (params) => Array.isArray(params) ? Object.fromEntries(params.map((name) => [name, `{{params.${name}}}`])) : params
8998
- ),
8999
- /** The result's top-level fields the template reads: what the message's data snapshot keeps. */
9000
- fields: external_exports.array(external_exports.string().max(64).regex(BINDING_NAME_SEGMENT_REGEX)).min(1).max(INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX)
9001
- }).strict();
9002
- interactiveTemplateDefinitionSchema = external_exports.object({
9003
- name: interactiveTemplateNameSchema,
9004
- description: external_exports.string().trim().min(1).max(INTERACTIVE_TEMPLATE_DESCRIPTION_MAX),
9005
- params: paramsJsonSchema.default({ type: "object", properties: {} }),
9006
- data: dataSchema.optional(),
9007
- /** Phase 1: the one view, `main`. Phase 1b adds others beside it. */
9008
- views: external_exports.object({ main: blockSchema }).strict(),
9009
- actions: external_exports.record(actionNameSchema, templateActionSchema).default({}).refine((actions) => Object.keys(actions).length <= INTERACTIVE_TEMPLATE_MAX_ACTIONS, {
9010
- message: `at most ${INTERACTIVE_TEMPLATE_MAX_ACTIONS} actions`
9011
- }),
9012
- fallback: external_exports.string().trim().min(1).max(INTERACTIVE_TEMPLATE_FALLBACK_MAX)
9013
- }).strict();
9014
- }
9015
- });
9016
-
9017
- // ../../packages/core/dist/chunk-2ZZZHXZR.js
9018
- var OPTION_ITEM, choices, form;
9019
- var init_chunk_2ZZZHXZR = __esm({
9020
- "../../packages/core/dist/chunk-2ZZZHXZR.js"() {
9021
- "use strict";
9022
- init_chunk_BGNWWR6B();
9023
- OPTION_ITEM = {
9024
- type: "object",
9025
- properties: {
9026
- id: { type: "string", description: "What the agent receives when this one is picked" },
9027
- label: { type: "string", description: "What the person sees" }
9028
- },
9029
- required: ["id", "label"]
9030
- };
9031
- choices = {
9032
- name: "choices",
9033
- description: "A question with up to 10 options, each with an optional description. The person picks one; the agent receives its id and label.",
9034
- params: {
9035
- type: "object",
9036
- properties: {
9037
- prompt: { type: "string", description: "The question, shown above the options" },
9038
- options: {
9039
- type: "array",
9040
- minItems: 1,
9041
- maxItems: 10,
9042
- items: {
9043
- ...OPTION_ITEM,
9044
- properties: { ...OPTION_ITEM.properties, description: { type: "string", description: "A line under the label" } }
9045
- }
9046
- }
9047
- },
9048
- required: ["options"]
9049
- },
9050
- views: {
9051
- main: {
9052
- type: "card",
9053
- children: [
9054
- { type: "text", if: "params.prompt", text: "{{params.prompt}}" },
9055
- {
9056
- type: "list",
9057
- each: "params.options",
9058
- item: {
9059
- type: "col",
9060
- gap: 1,
9061
- children: [
9062
- { type: "button", label: "{{item.label}}", action: "choose" },
9063
- { type: "text", if: "item.description", text: "{{item.description}}", size: "sm", color: "secondary" }
9064
- ]
9065
- }
9066
- }
9067
- ]
9068
- }
9069
- },
9070
- actions: {
9071
- choose: { type: "send", text: "{{item.label}}", values: { id: "{{item.id}}" } }
9072
- },
9073
- fallback: "{{#if params.prompt}}{{params.prompt}}\n{{/if}}{{#each params.options}}{{@n}}. {{label}}{{#if description}} \u2014 {{description}}{{/if}}\n{{/each}}"
9074
- };
9075
- form = {
9076
- name: "form",
9077
- description: "A form of up to 20 fields, each a text input, a select or a checkbox, optionally pre-filled and annotated with where its value came from. The person submits it; the agent receives the values.",
9078
- params: {
9079
- type: "object",
9080
- properties: {
9081
- title: { type: "string", description: "Shown above the fields" },
9082
- submit_label: { type: "string", description: "The submit button's label" },
9083
- fields: {
9084
- type: "array",
9085
- minItems: 1,
9086
- maxItems: 20,
9087
- items: {
9088
- type: "object",
9089
- properties: {
9090
- name: { type: "string", pattern: INTERACTIVE_TEMPLATE_FIELD_NAME_REGEX.source, description: "The key the value is submitted under" },
9091
- label: { type: "string" },
9092
- input: {
9093
- type: "string",
9094
- enum: [...TEMPLATE_INPUT_TYPES],
9095
- description: "A text input of this type. Give exactly one of input, select or checkbox."
9096
- },
9097
- select: { type: "array", minItems: 1, maxItems: INTERACTIVE_TEMPLATE_OPTIONS_MAX, items: { type: "object", properties: { value: { type: "string" }, label: { type: "string" } }, required: ["value", "label"] } },
9098
- checkbox: { type: "boolean", enum: [true] },
9099
- value: { type: ["string", "number", "boolean"], description: "The pre-filled value (a checkbox: true when checked)" },
9100
- placeholder: { type: "string" },
9101
- required: { type: "boolean" },
9102
- source: { type: "string", description: "Where the pre-filled value came from, shown under the field" }
9103
- },
9104
- required: ["name", "label"],
9105
- oneOf: [{ required: ["input"] }, { required: ["select"] }, { required: ["checkbox"] }]
9106
- }
9107
- }
9108
- },
9109
- required: ["fields"]
9110
- },
9111
- views: {
9112
- main: {
9113
- type: "card",
9114
- children: [
9115
- { type: "title", if: "params.title", text: "{{params.title}}" },
9116
- {
9117
- type: "form",
9118
- submit: "submit",
9119
- submit_label: "{{params.submit_label}}",
9120
- children: [
9121
- {
9122
- type: "list",
9123
- each: "params.fields",
9124
- item: {
9125
- type: "col",
9126
- children: [
9127
- {
9128
- type: "input",
9129
- if: "item.input",
9130
- name: "{{item.name}}",
9131
- label: "{{item.label}}",
9132
- input_type: "{{item.input}}",
9133
- placeholder: "{{item.placeholder}}",
9134
- default_value: "{{item.value}}",
9135
- required: "{{item.required}}",
9136
- source: "{{item.source}}"
9137
- },
9138
- {
9139
- type: "select",
9140
- if: "item.select",
9141
- name: "{{item.name}}",
9142
- label: "{{item.label}}",
9143
- options: "{{item.select}}",
9144
- placeholder: "{{item.placeholder}}",
9145
- default_value: "{{item.value}}",
9146
- required: "{{item.required}}",
9147
- source: "{{item.source}}"
9148
- },
9149
- {
9150
- type: "checkbox",
9151
- if: "item.checkbox",
9152
- name: "{{item.name}}",
9153
- label: "{{item.label}}",
9154
- default_checked: "{{item.value}}",
9155
- required: "{{item.required}}",
9156
- source: "{{item.source}}"
9157
- }
9158
- ]
9159
- }
9160
- }
9161
- ]
9162
- }
9163
- ]
9164
- }
9165
- },
9166
- actions: {
9167
- submit: { type: "send", values: "{{form}}" }
9168
- },
9169
- fallback: "{{#if params.title}}{{params.title}}\n{{/if}}{{#each params.fields}}- {{label}}{{#if value}}: {{value}}{{/if}}\n{{/each}}"
9170
- };
9171
9215
  }
9172
9216
  });
9173
9217
 
@@ -12753,28 +12797,14 @@ var init_chunk_LX3D5LCB = __esm({
12753
12797
  }
12754
12798
  });
12755
12799
 
12756
- // ../../packages/core/dist/chunk-C4HEZ7ZI.js
12757
- var downloadBody, uploadQuery, SIGN_URL_MAX_EXPIRES_IN_SECONDS, signUrlBody;
12758
- var init_chunk_C4HEZ7ZI = __esm({
12759
- "../../packages/core/dist/chunk-C4HEZ7ZI.js"() {
12800
+ // ../../packages/core/dist/chunk-JDJ4EUOL.js
12801
+ var clickhouseReadyResponse;
12802
+ var init_chunk_JDJ4EUOL = __esm({
12803
+ "../../packages/core/dist/chunk-JDJ4EUOL.js"() {
12760
12804
  "use strict";
12761
- init_chunk_CJ3L46X6();
12762
12805
  init_zod();
12763
- downloadBody = external_exports.object({
12764
- type: external_exports.enum(["workspace", "agent_instructions"]),
12765
- agent_id: external_exports.string().uuid().optional(),
12766
- organization_name: external_exports.string().optional()
12767
- });
12768
- uploadQuery = external_exports.object({
12769
- type: external_exports.enum(["agent_instructions"]),
12770
- agent_id: external_exports.string().uuid(),
12771
- hub_id: external_exports.string().uuid()
12772
- });
12773
- SIGN_URL_MAX_EXPIRES_IN_SECONDS = 3600;
12774
- signUrlBody = external_exports.object({
12775
- bucket: external_exports.string(),
12776
- filePath: external_exports.string(),
12777
- expiresIn: external_exports.number().int().positive().max(SIGN_URL_MAX_EXPIRES_IN_SECONDS).optional()
12806
+ clickhouseReadyResponse = external_exports.object({
12807
+ ready: external_exports.boolean()
12778
12808
  });
12779
12809
  }
12780
12810
  });
@@ -12864,24 +12894,6 @@ var init_chunk_LWMLR2WI = __esm({
12864
12894
  }
12865
12895
  });
12866
12896
 
12867
- // ../../packages/core/dist/chunk-ACGAI25T.js
12868
- var listPendingSchedulesQuery, listHubAggregateSchedulesQuery;
12869
- var init_chunk_ACGAI25T = __esm({
12870
- "../../packages/core/dist/chunk-ACGAI25T.js"() {
12871
- "use strict";
12872
- init_zod();
12873
- listPendingSchedulesQuery = external_exports.object({
12874
- hub_id: external_exports.string().uuid(),
12875
- conversation_id: external_exports.string().uuid().optional(),
12876
- user_id: external_exports.string().optional()
12877
- });
12878
- listHubAggregateSchedulesQuery = external_exports.object({
12879
- hub_id: external_exports.string().uuid(),
12880
- limit: external_exports.coerce.number().int().min(1).max(1e3).optional()
12881
- });
12882
- }
12883
- });
12884
-
12885
12897
  // ../../packages/core/dist/chunk-YR7QALGP.js
12886
12898
  var CASE_SUBMISSION_ISSUED_KINDS, CASE_SUBMISSION_RENDER_STUCK_MS, CASE_SUBMISSION_MARK_ID_PATTERN, CASE_CORRECTION_REASON_MAX_LENGTH, submitCaseBody, correctCaseSubmissionBody, caseDeliveryQuery;
12887
12899
  var init_chunk_YR7QALGP = __esm({
@@ -13266,7 +13278,7 @@ var init_chunk_2ISUBJG7 = __esm({
13266
13278
  }
13267
13279
  });
13268
13280
 
13269
- // ../../packages/core/dist/chunk-PCQIFFYO.js
13281
+ // ../../packages/core/dist/chunk-5YZ3R7KF.js
13270
13282
  function describeRole(role) {
13271
13283
  if (typeof role === "string") {
13272
13284
  return JSON.stringify(role.length > ROLE_ECHO_MAX ? `${role.slice(0, ROLE_ECHO_MAX)}\u2026` : role);
@@ -13445,11 +13457,11 @@ function terminalRunCount(counts) {
13445
13457
  return counts.successful_runs + counts.failed_runs;
13446
13458
  }
13447
13459
  var evalIdParam, sessionIdParam, scenarioSetIdParam, hubIdQuery, EVAL_FIXTURE_NAME_MAX_LENGTH, evalFixtureOverrideSchema, runSessionQuery, runJourneyQuery, EVAL_INPUT_ROLES, EVAL_INPUT_ROLE_LIST, ROLE_ECHO_MAX, EVAL_INITIAL_STATE_SCOPES, MAX_INITIAL_STATE_ENTRIES, evalInitialStateEntry, EVAL_PERSON_MAX, evalPersonSchema, EVAL_PERSON_ALIAS_RETIRED, EVAL_PERSON_ALIAS_REFUSED, evalBody, EVAL_LIST_MAX_LIMIT, evalListLimit, getEvalsQuery, toggleEvalBody, bulkToggleEvalsBody, pacingConfigSchema, EVAL_MAX_SELECTED_SCENARIOS, evalScenarioSelectionEntrySchema, evalScenarioSelectionSchema, sessionConfigSchema, createSessionBody, getSessionsQuery, getSessionResultsQuery, getSessionRunsQuery, evalAnalyticsQuery, getSessionCostQuery, compareSessionsQuery, evalsSqlBody, evalsSqlSchemaQuery, exportResultsQuery, validateEvalBody, hubAgentsQuery, createScenarioSetBody, updateScenarioSetBody, scenarioSetsHubQuery, createScenarioFromConversationBody, createJourneyFromConversationBody, evalAttachmentRef, turnMayCarryAttachments, ATTACHMENTS_USER_ONLY_MESSAGE, journeyIdParam, journeyToolCallSchema, journeyTurnSchema, journeyStepOverrideSchema, fixtureField, createJourneyBody, updateJourneyBody, evalSessionConfigResponseSchema, evalSessionResponseSchema, evalSessionListConfigSchema, evalSessionListItemSchema, seedReleaseStatusSchema, EVAL_SESSION_NOT_QUIESCENT;
13448
- var init_chunk_PCQIFFYO = __esm({
13449
- "../../packages/core/dist/chunk-PCQIFFYO.js"() {
13460
+ var init_chunk_5YZ3R7KF = __esm({
13461
+ "../../packages/core/dist/chunk-5YZ3R7KF.js"() {
13450
13462
  "use strict";
13451
- init_chunk_AHISKXHA();
13452
13463
  init_chunk_2YEGUQR7();
13464
+ init_chunk_AHISKXHA();
13453
13465
  init_chunk_4LXDRTO4();
13454
13466
  init_chunk_AMMLEB4T();
13455
13467
  init_chunk_2ISUBJG7();
@@ -14523,7 +14535,7 @@ var init_chunk_ARK3766Q = __esm({
14523
14535
  }
14524
14536
  });
14525
14537
 
14526
- // ../../packages/core/dist/chunk-LZHLURLT.js
14538
+ // ../../packages/core/dist/chunk-S24FZRPG.js
14527
14539
  function declaresNoConnection(agent) {
14528
14540
  return agent.connection === null && !agent.connection_id;
14529
14541
  }
@@ -15254,13 +15266,13 @@ function skillSectionsAsResources(scope) {
15254
15266
  return out;
15255
15267
  };
15256
15268
  }
15257
- var MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, MAX_HUB_AS_CODE_PAGE_MANIFEST_CHARS, hubAsCodePagesSchema, MAX_CALL_OPENING_CARRIERS, MAX_CALL_OPENING_AGGREGATE_ENCODED_BYTES, HUB_AS_CODE_AGENT_TOOL_KEYS, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, flagEntriesOf, boundedHubAsCodeResourcesSchema, isPlainObject, MIN_SKILLS_LAYOUT_CLI, MAX_HUB_AS_CODE_DEPTH, NAMED_DEPTH_SEGMENTS, NAMED_DEPTH_KEY_CHARS, fieldName, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, CI_APPLY_ENTITY_KINDS, CI_APPLY_OPERATIONS, ciApplyErrorBaseSchema, ciApplyErrorSchema, ciSyncCountSchema, ciSyncChangesSchema, ciSyncWarningSchema, ciSyncResponseSchema;
15258
- var init_chunk_LZHLURLT = __esm({
15259
- "../../packages/core/dist/chunk-LZHLURLT.js"() {
15269
+ var MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, MAX_HUB_AS_CODE_PAGE_MANIFEST_CHARS, hubAsCodePagesSchema, MAX_CALL_OPENING_CARRIERS, MAX_CALL_OPENING_AGGREGATE_ENCODED_BYTES, HUB_AS_CODE_AGENT_TOOL_KEYS, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, flagEntriesOf, boundedHubAsCodeResourcesSchema, isPlainObject, MIN_SKILLS_LAYOUT_CLI, MAX_HUB_AS_CODE_DEPTH, NAMED_DEPTH_SEGMENTS, NAMED_DEPTH_KEY_CHARS, fieldName, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciDiffDirectionSchema, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, ciDiffResponseSchema, ciHubIdentitySchema, ciLookupResponseSchema, ciOrganizationsResponseSchema, ciCreateOrganizationResponseSchema, ciHubListItemSchema, ciHubListResponseSchema, CI_APPLY_ENTITY_KINDS, CI_APPLY_OPERATIONS, ciApplyErrorBaseSchema, ciApplyErrorSchema, ciSyncCountSchema, ciSyncChangesSchema, ciSyncWarningSchema, ciSyncResponseSchema, ciOrgResourcesPushResponseSchema;
15270
+ var init_chunk_S24FZRPG = __esm({
15271
+ "../../packages/core/dist/chunk-S24FZRPG.js"() {
15260
15272
  "use strict";
15261
15273
  init_chunk_QG3XMUEN();
15262
15274
  init_chunk_EBUWHIFV();
15263
- init_chunk_PCQIFFYO();
15275
+ init_chunk_5YZ3R7KF();
15264
15276
  init_chunk_QMQGGR7Q();
15265
15277
  init_chunk_LBDH7LCG();
15266
15278
  init_chunk_4LXDRTO4();
@@ -15431,6 +15443,7 @@ var init_chunk_LZHLURLT = __esm({
15431
15443
  ciBranchesQuery = external_exports.object({
15432
15444
  hub_id: ciUuidSchema
15433
15445
  });
15446
+ ciDiffDirectionSchema = external_exports.enum(["push", "pull"]);
15434
15447
  ciSyncBody = external_exports.object({
15435
15448
  hub_id: ciUuidSchema,
15436
15449
  branch_name: external_exports.string().min(1, "branch_name is required"),
@@ -15445,7 +15458,7 @@ var init_chunk_LZHLURLT = __esm({
15445
15458
  ciDiffBody = external_exports.object({
15446
15459
  hub_id: ciUuidSchema,
15447
15460
  config: hubAsCodeConfigSchema,
15448
- direction: external_exports.enum(["push", "pull"]).default("push"),
15461
+ direction: ciDiffDirectionSchema.default("push"),
15449
15462
  organization_id: ciUuidSchema.optional()
15450
15463
  });
15451
15464
  ciPublishBody = external_exports.object({
@@ -15477,7 +15490,62 @@ var init_chunk_LZHLURLT = __esm({
15477
15490
  ciOrgResourcesDiffBody = external_exports.object({
15478
15491
  organization_id: ciUuidSchema,
15479
15492
  config: orgResourcesConfigSchema,
15480
- direction: external_exports.enum(["push", "pull"]).default("push")
15493
+ direction: ciDiffDirectionSchema.default("push")
15494
+ });
15495
+ ciDiffResponseSchema = external_exports.object({
15496
+ has_changes: external_exports.boolean(),
15497
+ direction: ciDiffDirectionSchema,
15498
+ summary: external_exports.string(),
15499
+ /**
15500
+ * The diff engine's own result (`DiffResult` for a hub, the org skills diff for an org), as
15501
+ * computed. Not part of the contract yet: no client reads it, and its shape is the engine's.
15502
+ */
15503
+ diff: external_exports.unknown(),
15504
+ /**
15505
+ * Non-fatal skip reasons surfaced by the diff engine (e.g. native/delegation
15506
+ * tools dropped because their connector has no connection on the hub).
15507
+ * Populated independently of `has_changes` so the CLI can display them even
15508
+ * when every change was silently dropped. Always present (possibly empty),
15509
+ * symmetric with `DiffResult.warnings`. See gh #1538.
15510
+ */
15511
+ warnings: external_exports.array(external_exports.string()),
15512
+ /**
15513
+ * The hub's current server-owned `preview_label`. Surfaced so the CLI can warn
15514
+ * when a hand-edited `hub.yaml` label differs from the server — the diff engine
15515
+ * ignores `preview_label` (it's set via `wayai relabel`/replicate, not push), so
15516
+ * without this the silent no-op is invisible. Optional for back-compat with
15517
+ * older backends, and absent from the org skills diff. See gh hub-branching.
15518
+ */
15519
+ preview_label: external_exports.string().nullable().optional()
15520
+ });
15521
+ ciHubIdentitySchema = external_exports.object({
15522
+ hub_id: external_exports.string().min(1),
15523
+ hub_name: external_exports.string(),
15524
+ hub_environment: external_exports.string(),
15525
+ preview_label: external_exports.string().nullable(),
15526
+ branch_name: external_exports.string().nullable()
15527
+ });
15528
+ ciLookupResponseSchema = ciHubIdentitySchema.partial({ preview_label: true, branch_name: true });
15529
+ ciOrganizationsResponseSchema = external_exports.object({
15530
+ organizations: external_exports.array(external_exports.object({ id: external_exports.string().min(1), name: external_exports.string() }))
15531
+ });
15532
+ ciCreateOrganizationResponseSchema = external_exports.object({
15533
+ organization: external_exports.object({
15534
+ id: external_exports.string().min(1),
15535
+ name: external_exports.string(),
15536
+ /** Resolved DO placement region (auto-detected from the request edge, or the
15537
+ * caller's explicit `primary_region`). Surfaced so the CLI can show it. */
15538
+ region: external_exports.string().nullable(),
15539
+ /** True when the caller passed an explicit region; false when auto-detected
15540
+ * (closest Cloudflare PoP). Lets the CLI phrase "closest to you" vs "as requested". */
15541
+ region_explicit: external_exports.boolean()
15542
+ })
15543
+ });
15544
+ ciHubListItemSchema = ciHubIdentitySchema.extend({
15545
+ production_hub_id: external_exports.string().nullable()
15546
+ });
15547
+ ciHubListResponseSchema = external_exports.object({
15548
+ hubs: external_exports.array(ciHubListItemSchema)
15481
15549
  });
15482
15550
  CI_APPLY_ENTITY_KINDS = [
15483
15551
  "agent",
@@ -15575,17 +15643,19 @@ var init_chunk_LZHLURLT = __esm({
15575
15643
  apply_errors: external_exports.array(ciApplyErrorSchema).optional(),
15576
15644
  warnings: external_exports.array(ciSyncWarningSchema).optional()
15577
15645
  });
15578
- }
15579
- });
15580
-
15581
- // ../../packages/core/dist/chunk-JDJ4EUOL.js
15582
- var clickhouseReadyResponse;
15583
- var init_chunk_JDJ4EUOL = __esm({
15584
- "../../packages/core/dist/chunk-JDJ4EUOL.js"() {
15585
- "use strict";
15586
- init_zod();
15587
- clickhouseReadyResponse = external_exports.object({
15588
- ready: external_exports.boolean()
15646
+ ciOrgResourcesPushResponseSchema = external_exports.object({
15647
+ changes: external_exports.object({
15648
+ resources_created: ciSyncCountSchema,
15649
+ resources_updated: ciSyncCountSchema,
15650
+ resources_deleted: ciSyncCountSchema,
15651
+ resource_files_uploaded: ciSyncCountSchema,
15652
+ resource_files_deleted: ciSyncCountSchema,
15653
+ resource_folders_created: ciSyncCountSchema,
15654
+ resource_folders_deleted: ciSyncCountSchema
15655
+ }),
15656
+ /** Aggregate awaited fan-out to linked hub shadows across all changed resources. */
15657
+ fanout: external_exports.object({ hubs: ciSyncCountSchema, failures: ciSyncCountSchema }),
15658
+ errors: external_exports.array(external_exports.string()).optional()
15589
15659
  });
15590
15660
  }
15591
15661
  });
@@ -16485,10 +16555,10 @@ var init_chunk_S2LXF4LF = __esm({
16485
16555
  }
16486
16556
  });
16487
16557
 
16488
- // ../../packages/core/dist/chunk-UWJJF7PZ.js
16558
+ // ../../packages/core/dist/chunk-VHA3AQE4.js
16489
16559
  var CASE_OFFICIAL_FILE_KINDS, CASE_OFFICIAL_FILE_NAME_PATTERN, publishCaseSubmissionBody, caseOfficialVersionParam, caseOfficialFileQuery;
16490
- var init_chunk_UWJJF7PZ = __esm({
16491
- "../../packages/core/dist/chunk-UWJJF7PZ.js"() {
16560
+ var init_chunk_VHA3AQE4 = __esm({
16561
+ "../../packages/core/dist/chunk-VHA3AQE4.js"() {
16492
16562
  "use strict";
16493
16563
  init_chunk_YR7QALGP();
16494
16564
  init_chunk_AMKBCOOH();
@@ -16506,10 +16576,10 @@ var init_chunk_UWJJF7PZ = __esm({
16506
16576
  }
16507
16577
  });
16508
16578
 
16509
- // ../../packages/core/dist/chunk-56WMNWMX.js
16579
+ // ../../packages/core/dist/chunk-2S6LIRGD.js
16510
16580
  var casePhaseParam;
16511
- var init_chunk_56WMNWMX = __esm({
16512
- "../../packages/core/dist/chunk-56WMNWMX.js"() {
16581
+ var init_chunk_2S6LIRGD = __esm({
16582
+ "../../packages/core/dist/chunk-2S6LIRGD.js"() {
16513
16583
  "use strict";
16514
16584
  init_chunk_S2LXF4LF();
16515
16585
  init_chunk_HZ6CADSY();
@@ -16517,10 +16587,10 @@ var init_chunk_56WMNWMX = __esm({
16517
16587
  }
16518
16588
  });
16519
16589
 
16520
- // ../../packages/core/dist/chunk-CBPHDU3I.js
16590
+ // ../../packages/core/dist/chunk-K6O2P77D.js
16521
16591
  var CASE_CHECK_CSV_MAX_BYTES, CASE_DECISIONS_CSV_PATH, CASE_CONFIDENTIAL_DECISIONS_CSV_PATH, caseChecksQuery;
16522
- var init_chunk_CBPHDU3I = __esm({
16523
- "../../packages/core/dist/chunk-CBPHDU3I.js"() {
16592
+ var init_chunk_K6O2P77D = __esm({
16593
+ "../../packages/core/dist/chunk-K6O2P77D.js"() {
16524
16594
  "use strict";
16525
16595
  init_chunk_YR7QALGP();
16526
16596
  init_chunk_HZ6CADSY();
@@ -16534,14 +16604,14 @@ var init_chunk_CBPHDU3I = __esm({
16534
16604
  }
16535
16605
  });
16536
16606
 
16537
- // ../../packages/core/dist/chunk-5LTMGGTR.js
16607
+ // ../../packages/core/dist/chunk-UAFAJNZ6.js
16538
16608
  var CASE_REVIEW_DECISIONS, CASE_ISSUED_FORMATS, CASE_REVIEW_COMMENT_MAX_LENGTH, CASE_REVIEW_JUSTIFICATION_MAX_LENGTH, text2, caseSubmissionParam, decideCaseSubmissionBody, caseIssuedQuery, CASE_APPROVALS_STATES, caseApprovalsQuery, caseCompareDefaultQuery, caseApprovalsAgendaQuery;
16539
- var init_chunk_5LTMGGTR = __esm({
16540
- "../../packages/core/dist/chunk-5LTMGGTR.js"() {
16609
+ var init_chunk_UAFAJNZ6 = __esm({
16610
+ "../../packages/core/dist/chunk-UAFAJNZ6.js"() {
16541
16611
  "use strict";
16542
- init_chunk_UWJJF7PZ();
16543
- init_chunk_56WMNWMX();
16544
- init_chunk_CBPHDU3I();
16612
+ init_chunk_VHA3AQE4();
16613
+ init_chunk_2S6LIRGD();
16614
+ init_chunk_K6O2P77D();
16545
16615
  init_chunk_YR7QALGP();
16546
16616
  init_chunk_AMKBCOOH();
16547
16617
  init_chunk_S2LXF4LF();
@@ -16618,6 +16688,52 @@ var init_chunk_ZTRVP4OT = __esm({
16618
16688
  }
16619
16689
  });
16620
16690
 
16691
+ // ../../packages/core/dist/chunk-5WMOQ5NC.js
16692
+ var CASE_RELATION_TYPE_CODE_PATTERN, CASE_RELATION_TYPE_CODE_MAX_LENGTH, CASE_RELATION_TYPE_NAME_MAX_LENGTH, CASE_RELATION_TYPES_PER_SPACE_MAX, CASE_RELATION_DESCRIPTION_MAX_LENGTH, CASE_RELATION_SIDES, CASE_EXTERNAL_SYSTEM_PATTERN, CASE_EXTERNAL_NUMBER_MAX_LENGTH, CASE_EXTERNAL_URL_MAX_LENGTH, trimmedName, relationTypeFields, createCaseRelationTypeBody, updateCaseRelationTypeBody, relateCasesBody, addCaseExternalReferenceBody, caseRelationTypeParam, caseRelationParam, caseExternalReferenceParam, caseRelationTypesQuery;
16693
+ var init_chunk_5WMOQ5NC = __esm({
16694
+ "../../packages/core/dist/chunk-5WMOQ5NC.js"() {
16695
+ "use strict";
16696
+ init_chunk_S2LXF4LF();
16697
+ init_chunk_TYI6QVPX();
16698
+ init_chunk_HZ6CADSY();
16699
+ init_zod();
16700
+ CASE_RELATION_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
16701
+ CASE_RELATION_TYPE_CODE_MAX_LENGTH = 64;
16702
+ CASE_RELATION_TYPE_NAME_MAX_LENGTH = 200;
16703
+ CASE_RELATION_TYPES_PER_SPACE_MAX = 100;
16704
+ CASE_RELATION_DESCRIPTION_MAX_LENGTH = 500;
16705
+ CASE_RELATION_SIDES = ["origin", "destination"];
16706
+ CASE_EXTERNAL_SYSTEM_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,30}$/;
16707
+ CASE_EXTERNAL_NUMBER_MAX_LENGTH = 120;
16708
+ CASE_EXTERNAL_URL_MAX_LENGTH = 2048;
16709
+ trimmedName = external_exports.string().trim().min(1).max(CASE_RELATION_TYPE_NAME_MAX_LENGTH);
16710
+ relationTypeFields = { name: trimmedName, inverse_name: trimmedName, active: external_exports.boolean().default(true) };
16711
+ createCaseRelationTypeBody = external_exports.object({
16712
+ code: external_exports.string().trim().max(CASE_RELATION_TYPE_CODE_MAX_LENGTH).regex(CASE_RELATION_TYPE_CODE_PATTERN),
16713
+ ...relationTypeFields
16714
+ }).strict();
16715
+ updateCaseRelationTypeBody = external_exports.object({ ...relationTypeFields, expected_updated_at: timestampSchema.optional() }).strict();
16716
+ relateCasesBody = external_exports.object({
16717
+ relation_type_id: uuidSchema,
16718
+ other_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN),
16719
+ /** This case's side: `origin` reads the type's name ("continues"), `destination` its inverse. */
16720
+ side: external_exports.enum(CASE_RELATION_SIDES).default("origin"),
16721
+ description: external_exports.string().trim().min(1).max(CASE_RELATION_DESCRIPTION_MAX_LENGTH).nullable().default(null)
16722
+ }).strict();
16723
+ addCaseExternalReferenceBody = external_exports.object({
16724
+ system: external_exports.string().trim().regex(CASE_EXTERNAL_SYSTEM_PATTERN),
16725
+ number: external_exports.string().trim().min(1).max(CASE_EXTERNAL_NUMBER_MAX_LENGTH),
16726
+ url: external_exports.string().trim().max(CASE_EXTERNAL_URL_MAX_LENGTH).url().refine((url) => url.startsWith("https://"), "An https link").nullable().default(null)
16727
+ }).strict();
16728
+ caseRelationTypeParam = caseSpaceParam.extend({ relation_type_id: uuidSchema });
16729
+ caseRelationParam = caseRecordParam.extend({ relation_id: uuidSchema });
16730
+ caseExternalReferenceParam = caseRecordParam.extend({ reference_id: uuidSchema });
16731
+ caseRelationTypesQuery = casePageQuery.extend({
16732
+ limit: external_exports.coerce.number().int().min(1).max(CASE_RELATION_TYPES_PER_SPACE_MAX).optional()
16733
+ });
16734
+ }
16735
+ });
16736
+
16621
16737
  // ../../packages/core/dist/chunk-UPGAWPE2.js
16622
16738
  var CASE_CHANGE_TOPICS, caseChangedFrameSchema;
16623
16739
  var init_chunk_UPGAWPE2 = __esm({
@@ -16651,33 +16767,6 @@ var init_chunk_3EEL6BQ7 = __esm({
16651
16767
  }
16652
16768
  });
16653
16769
 
16654
- // ../../packages/core/dist/chunk-NKJ2DQCV.js
16655
- var CASE_STYLE_KINDS, caseStyleParam, CASE_STYLE_VERSIONS_PAGE_MAX, caseStyleVersionsQuery, caseStyleContentQuery, CASE_STYLE_UPLOAD_BODY_MAX_BYTES, CASE_STYLE_FILE_FIELD, CASE_STYLE_EXPECT_FIELD, caseStyleUploadForm;
16656
- var init_chunk_NKJ2DQCV = __esm({
16657
- "../../packages/core/dist/chunk-NKJ2DQCV.js"() {
16658
- "use strict";
16659
- init_chunk_AMKBCOOH();
16660
- init_chunk_TYI6QVPX();
16661
- init_chunk_HZ6CADSY();
16662
- init_zod();
16663
- CASE_STYLE_KINDS = ["pdf_stylesheet", "word_reference"];
16664
- caseStyleParam = caseSpaceParam.extend({ kind: external_exports.enum(CASE_STYLE_KINDS) });
16665
- CASE_STYLE_VERSIONS_PAGE_MAX = 100;
16666
- caseStyleVersionsQuery = casePageQuery.extend({
16667
- limit: external_exports.coerce.number().int().min(1).max(CASE_STYLE_VERSIONS_PAGE_MAX).optional()
16668
- });
16669
- caseStyleContentQuery = external_exports.object({ version_id: uuidSchema.optional() });
16670
- CASE_STYLE_UPLOAD_BODY_MAX_BYTES = 20 * 1024 * 1024;
16671
- CASE_STYLE_FILE_FIELD = "file";
16672
- CASE_STYLE_EXPECT_FIELD = "expect_version_id";
16673
- caseStyleUploadForm = external_exports.object({
16674
- [CASE_STYLE_FILE_FIELD]: external_exports.custom(isBlob, "The file is required"),
16675
- /** Empty: the uploader read no current version. */
16676
- [CASE_STYLE_EXPECT_FIELD]: external_exports.union([uuidSchema, external_exports.literal("")]).transform((value) => value || null)
16677
- });
16678
- }
16679
- });
16680
-
16681
16770
  // ../../packages/core/dist/chunk-ATX6AHPZ.js
16682
16771
  function withProblem(shape, problemOf) {
16683
16772
  return shape.superRefine((value, ctx) => {
@@ -16714,7 +16803,7 @@ function caseInstrumentProblem(instrument) {
16714
16803
  ${party.role}`);
16715
16804
  return new Set(keys).size === keys.length ? null : { reason: "instrument_party_repeated", at: "parties" };
16716
16805
  }
16717
- var CASE_REGISTRY_TYPE_CODE_PATTERN, CASE_REGISTRY_TYPE_CODE_MAX_LENGTH, CASE_REGISTRY_NAME_MAX_LENGTH, CASE_REGISTRY_TYPE_SCHEMA_MAX_CHARS, CASE_PARTY_ABBREVIATION_PATTERN, CASE_PARTY_PERSON_KINDS, CASE_PARTY_DOCUMENT_KINDS, CASE_PARTY_DOCUMENT_MAX_LENGTH, CASE_PARTY_GROUP_MEMBERS_MAX, CASE_INSTRUMENT_NUMBER_MAX_LENGTH, CASE_INSTRUMENT_ROLE_MAX_LENGTH, CASE_INSTRUMENT_PARTIES_MAX, CASE_REGISTRY_PAGE_MAX, CASE_REGISTRY_QUERY_MAX_LENGTH, trimmedName, dateSchema, attributesValues, registryTypeFields, createCaseRegistryTypeShape, updateCaseRegistryTypeShape, createCaseRegistryTypeBody, updateCaseRegistryTypeBody, saveCasePartyShape, saveCasePartyBody, saveCasePartyGroupShape, saveCasePartyGroupBody, caseInstrumentPartyInput, saveCaseInstrumentShape, saveCaseInstrumentBody, registryPage, searchText, casePartiesQuery, casePartyGroupsQuery, caseInstrumentsQuery, caseRegistryTypeParam, casePartyParam, casePartyGroupParam, caseInstrumentParam;
16806
+ var CASE_REGISTRY_TYPE_CODE_PATTERN, CASE_REGISTRY_TYPE_CODE_MAX_LENGTH, CASE_REGISTRY_NAME_MAX_LENGTH, CASE_REGISTRY_TYPE_SCHEMA_MAX_CHARS, CASE_PARTY_ABBREVIATION_PATTERN, CASE_PARTY_PERSON_KINDS, CASE_PARTY_DOCUMENT_KINDS, CASE_PARTY_DOCUMENT_MAX_LENGTH, CASE_PARTY_GROUP_MEMBERS_MAX, CASE_INSTRUMENT_NUMBER_MAX_LENGTH, CASE_INSTRUMENT_ROLE_MAX_LENGTH, CASE_INSTRUMENT_PARTIES_MAX, CASE_REGISTRY_PAGE_MAX, CASE_REGISTRY_QUERY_MAX_LENGTH, trimmedName2, dateSchema, attributesValues, registryTypeFields, createCaseRegistryTypeShape, updateCaseRegistryTypeShape, createCaseRegistryTypeBody, updateCaseRegistryTypeBody, saveCasePartyShape, saveCasePartyBody, saveCasePartyGroupShape, saveCasePartyGroupBody, caseInstrumentPartyInput, saveCaseInstrumentShape, saveCaseInstrumentBody, registryPage, searchText, casePartiesQuery, casePartyGroupsQuery, caseInstrumentsQuery, caseRegistryTypeParam, casePartyParam, casePartyGroupParam, caseInstrumentParam;
16718
16807
  var init_chunk_ATX6AHPZ = __esm({
16719
16808
  "../../packages/core/dist/chunk-ATX6AHPZ.js"() {
16720
16809
  "use strict";
@@ -16736,11 +16825,11 @@ var init_chunk_ATX6AHPZ = __esm({
16736
16825
  CASE_INSTRUMENT_PARTIES_MAX = 50;
16737
16826
  CASE_REGISTRY_PAGE_MAX = 100;
16738
16827
  CASE_REGISTRY_QUERY_MAX_LENGTH = 200;
16739
- trimmedName = external_exports.string().trim().min(1).max(CASE_REGISTRY_NAME_MAX_LENGTH);
16828
+ trimmedName2 = external_exports.string().trim().min(1).max(CASE_REGISTRY_NAME_MAX_LENGTH);
16740
16829
  dateSchema = caseDateSchema;
16741
16830
  attributesValues = external_exports.record(external_exports.string(), external_exports.unknown()).default({});
16742
16831
  registryTypeFields = {
16743
- name: trimmedName,
16832
+ name: trimmedName2,
16744
16833
  attributes: caseAttributesSchemaSchema.default(EMPTY_CASE_ATTRIBUTES_SCHEMA),
16745
16834
  active: external_exports.boolean().default(true)
16746
16835
  };
@@ -16756,7 +16845,7 @@ var init_chunk_ATX6AHPZ = __esm({
16756
16845
  updateCaseRegistryTypeBody = withProblem(updateCaseRegistryTypeShape, caseRegistryTypeProblem);
16757
16846
  saveCasePartyShape = external_exports.object({
16758
16847
  type_id: uuidSchema,
16759
- name: trimmedName,
16848
+ name: trimmedName2,
16760
16849
  abbreviation: external_exports.string().trim().transform((value) => value.toUpperCase()).pipe(external_exports.string().regex(CASE_PARTY_ABBREVIATION_PATTERN)).nullable().default(null),
16761
16850
  person_kind: external_exports.enum(CASE_PARTY_PERSON_KINDS),
16762
16851
  document_kind: external_exports.enum(CASE_PARTY_DOCUMENT_KINDS).nullable().default(null),
@@ -16767,7 +16856,7 @@ var init_chunk_ATX6AHPZ = __esm({
16767
16856
  }).strict();
16768
16857
  saveCasePartyBody = withProblem(saveCasePartyShape, casePartyProblem);
16769
16858
  saveCasePartyGroupShape = external_exports.object({
16770
- name: trimmedName,
16859
+ name: trimmedName2,
16771
16860
  party_ids: external_exports.array(uuidSchema).max(CASE_PARTY_GROUP_MEMBERS_MAX).default([]),
16772
16861
  expected_updated_at: timestampSchema.optional()
16773
16862
  }).strict();
@@ -16810,7 +16899,34 @@ var init_chunk_ATX6AHPZ = __esm({
16810
16899
  }
16811
16900
  });
16812
16901
 
16813
- // ../../packages/core/dist/chunk-O6OMUGGZ.js
16902
+ // ../../packages/core/dist/chunk-NKJ2DQCV.js
16903
+ var CASE_STYLE_KINDS, caseStyleParam, CASE_STYLE_VERSIONS_PAGE_MAX, caseStyleVersionsQuery, caseStyleContentQuery, CASE_STYLE_UPLOAD_BODY_MAX_BYTES, CASE_STYLE_FILE_FIELD, CASE_STYLE_EXPECT_FIELD, caseStyleUploadForm;
16904
+ var init_chunk_NKJ2DQCV = __esm({
16905
+ "../../packages/core/dist/chunk-NKJ2DQCV.js"() {
16906
+ "use strict";
16907
+ init_chunk_AMKBCOOH();
16908
+ init_chunk_TYI6QVPX();
16909
+ init_chunk_HZ6CADSY();
16910
+ init_zod();
16911
+ CASE_STYLE_KINDS = ["pdf_stylesheet", "word_reference"];
16912
+ caseStyleParam = caseSpaceParam.extend({ kind: external_exports.enum(CASE_STYLE_KINDS) });
16913
+ CASE_STYLE_VERSIONS_PAGE_MAX = 100;
16914
+ caseStyleVersionsQuery = casePageQuery.extend({
16915
+ limit: external_exports.coerce.number().int().min(1).max(CASE_STYLE_VERSIONS_PAGE_MAX).optional()
16916
+ });
16917
+ caseStyleContentQuery = external_exports.object({ version_id: uuidSchema.optional() });
16918
+ CASE_STYLE_UPLOAD_BODY_MAX_BYTES = 20 * 1024 * 1024;
16919
+ CASE_STYLE_FILE_FIELD = "file";
16920
+ CASE_STYLE_EXPECT_FIELD = "expect_version_id";
16921
+ caseStyleUploadForm = external_exports.object({
16922
+ [CASE_STYLE_FILE_FIELD]: external_exports.custom(isBlob, "The file is required"),
16923
+ /** Empty: the uploader read no current version. */
16924
+ [CASE_STYLE_EXPECT_FIELD]: external_exports.union([uuidSchema, external_exports.literal("")]).transform((value) => value || null)
16925
+ });
16926
+ }
16927
+ });
16928
+
16929
+ // ../../packages/core/dist/chunk-ZZZ65EIA.js
16814
16930
  function collectionUploadForm(field, shape) {
16815
16931
  return external_exports.record(external_exports.string(), external_exports.unknown()).transform((form2, ctx) => {
16816
16932
  const refuse2 = (message, path55) => {
@@ -16850,11 +16966,11 @@ function caseCollectionFileName(sent) {
16850
16966
  return name || "document";
16851
16967
  }
16852
16968
  var CASE_COLLECTION_FOLDERS, CASE_COLLECTION_PARTS, isCaseCollectionPart, CASE_COLLECTION_TITLE_MAX_LENGTH, CASE_COLLECTION_TYPE_MAX_LENGTH, CASE_COLLECTION_REASON_MAX_LENGTH, CASE_COLLECTION_FILE_NAME_MAX_LENGTH, caseCollectionDocumentParam, dateOnly, title, registerCaseCollectionDocumentShape, addCaseCollectionVersionShape, CASE_COLLECTION_UPLOAD_BODY_MAX_BYTES, CASE_COLLECTION_DOCUMENT_FIELD, CASE_COLLECTION_VERSION_FIELD, caseCollectionDocumentUploadForm, caseCollectionVersionUploadForm, CASE_COLLECTION_PAGE_MAX, CASE_COLLECTION_CURSOR_MAX_LENGTH, caseCollectionQuery, CASE_COLLECTION_VERSIONS_PAGE_MAX, caseCollectionVersionsQuery, caseCollectionContentQuery;
16853
- var init_chunk_O6OMUGGZ = __esm({
16854
- "../../packages/core/dist/chunk-O6OMUGGZ.js"() {
16969
+ var init_chunk_ZZZ65EIA = __esm({
16970
+ "../../packages/core/dist/chunk-ZZZ65EIA.js"() {
16855
16971
  "use strict";
16856
- init_chunk_NKJ2DQCV();
16857
16972
  init_chunk_ATX6AHPZ();
16973
+ init_chunk_NKJ2DQCV();
16858
16974
  init_chunk_AMKBCOOH();
16859
16975
  init_chunk_TYI6QVPX();
16860
16976
  init_chunk_M2T55BV6();
@@ -16916,7 +17032,7 @@ var init_chunk_O6OMUGGZ = __esm({
16916
17032
  }
16917
17033
  });
16918
17034
 
16919
- // ../../packages/core/dist/chunk-IK7IREH7.js
17035
+ // ../../packages/core/dist/chunk-WJJJFHIA.js
16920
17036
  function caseReceivedFormat(fileName) {
16921
17037
  const dot = fileName.lastIndexOf(".");
16922
17038
  if (dot < 0) return null;
@@ -16924,10 +17040,10 @@ function caseReceivedFormat(fileName) {
16924
17040
  return isCaseReceivedFormat(extension) ? extension : null;
16925
17041
  }
16926
17042
  var ZIP_SIGNATURE, CASE_RECEIVED_FORMATS, isCaseReceivedFormat, CASE_RECEIVED_PARTS, CASE_RECEIVED_TITLE_MAX_LENGTH, CASE_RECEIVED_TYPE_MAX_LENGTH, CASE_RECEIVED_TEXT_MAX_BYTES, CASE_RECEIVED_UPLOAD_BODY_MAX_BYTES, CASE_RECEIVED_DOCUMENT_FIELD, caseReceivedParam, registerCaseReceivedDocumentShape, caseReceivedUploadForm, caseReceivedFileName, ZIP_DIRECTORY_MAX_BYTES, CONTENT_TYPES_MAX_BYTES, CONTENT_TYPES_INFLATED_MAX_BYTES, CASE_RECEIVED_PAGE_MAX, caseReceivedQuery, caseReceivedContentQuery;
16927
- var init_chunk_IK7IREH7 = __esm({
16928
- "../../packages/core/dist/chunk-IK7IREH7.js"() {
17043
+ var init_chunk_WJJJFHIA = __esm({
17044
+ "../../packages/core/dist/chunk-WJJJFHIA.js"() {
16929
17045
  "use strict";
16930
- init_chunk_O6OMUGGZ();
17046
+ init_chunk_ZZZ65EIA();
16931
17047
  init_chunk_NKJ2DQCV();
16932
17048
  init_chunk_AMKBCOOH();
16933
17049
  init_chunk_S2LXF4LF();
@@ -17005,78 +17121,6 @@ var init_chunk_IK7IREH7 = __esm({
17005
17121
  }
17006
17122
  });
17007
17123
 
17008
- // ../../packages/core/dist/chunk-NVZB33EA.js
17009
- function isCaseDueDate(value) {
17010
- const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
17011
- if (!match) return false;
17012
- const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
17013
- if (year < CASE_DUE_DATE_MIN_YEAR || year > CASE_DUE_DATE_MAX_YEAR) return false;
17014
- const date = new Date(Date.UTC(year, month - 1, day));
17015
- return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
17016
- }
17017
- function setCaseDeadlinesProblem(body) {
17018
- const seen = /* @__PURE__ */ new Set();
17019
- for (const [index, phase] of body.phases.entries()) {
17020
- if (seen.has(phase.phase_id)) return { reason: "phase_repeated", at: `phases.${index}.phase_id` };
17021
- seen.add(phase.phase_id);
17022
- }
17023
- return null;
17024
- }
17025
- var CASE_DUE_DATE_MIN_YEAR, CASE_DUE_DATE_MAX_YEAR, CASE_DEADLINES_PHASES_MAX, CASE_OVERDUE_CASES_MAX, caseDueDateSchema, setCaseDeadlinesShape, setCaseDeadlinesBody, setCaseTaskPlanBody, setCaseOwnerBody, caseOverdueQuery;
17026
- var init_chunk_NVZB33EA = __esm({
17027
- "../../packages/core/dist/chunk-NVZB33EA.js"() {
17028
- "use strict";
17029
- init_chunk_TYI6QVPX();
17030
- init_chunk_HZ6CADSY();
17031
- init_zod();
17032
- CASE_DUE_DATE_MIN_YEAR = 2e3;
17033
- CASE_DUE_DATE_MAX_YEAR = 2100;
17034
- CASE_DEADLINES_PHASES_MAX = 50;
17035
- CASE_OVERDUE_CASES_MAX = 50;
17036
- caseDueDateSchema = external_exports.string().refine(isCaseDueDate, "Not a calendar date (YYYY-MM-DD)");
17037
- setCaseDeadlinesShape = external_exports.object({
17038
- phases: external_exports.array(external_exports.object({ phase_id: uuidSchema, due_on: caseDueDateSchema.nullable() }).strict()).min(1).max(CASE_DEADLINES_PHASES_MAX)
17039
- }).strict();
17040
- setCaseDeadlinesBody = setCaseDeadlinesShape.superRefine((body, ctx) => {
17041
- const found = setCaseDeadlinesProblem(body);
17042
- if (found) {
17043
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: found.at.split("."), params: { case_deadlines_reason: found.reason } });
17044
- }
17045
- });
17046
- setCaseTaskPlanBody = external_exports.object({
17047
- owner_person_id: uuidSchema.nullable(),
17048
- due_on: caseDueDateSchema.nullable()
17049
- }).strict();
17050
- setCaseOwnerBody = external_exports.object({ owner_person_id: uuidSchema.nullable() }).strict();
17051
- caseOverdueQuery = casePageQuery.extend({
17052
- limit: external_exports.coerce.number().int().min(1).max(CASE_OVERDUE_CASES_MAX).optional()
17053
- });
17054
- }
17055
- });
17056
-
17057
- // ../../packages/core/dist/chunk-7QN6QYGN.js
17058
- var CASE_GUEST_EMAIL_MAX, CASE_GUEST_INVITATIONS_PAGE_MAX, CASE_GUEST_INVITE_TOKEN_LENGTH, caseGuestEmailSchema, caseGuestInviteTokenSchema, inviteCaseGuestBody, caseGuestInvitationParam, caseGuestInvitationsQuery, joinCaseSpaceBody, caseJoinSearchParams;
17059
- var init_chunk_7QN6QYGN = __esm({
17060
- "../../packages/core/dist/chunk-7QN6QYGN.js"() {
17061
- "use strict";
17062
- init_chunk_TYI6QVPX();
17063
- init_chunk_HZ6CADSY();
17064
- init_zod();
17065
- CASE_GUEST_EMAIL_MAX = 320;
17066
- CASE_GUEST_INVITATIONS_PAGE_MAX = 100;
17067
- CASE_GUEST_INVITE_TOKEN_LENGTH = 43;
17068
- caseGuestEmailSchema = external_exports.string().trim().toLowerCase().max(CASE_GUEST_EMAIL_MAX).email();
17069
- caseGuestInviteTokenSchema = external_exports.string().regex(new RegExp(`^[A-Za-z0-9_-]{${CASE_GUEST_INVITE_TOKEN_LENGTH}}$`));
17070
- inviteCaseGuestBody = external_exports.object({ email: caseGuestEmailSchema }).strict();
17071
- caseGuestInvitationParam = caseSpaceParam.extend({ invitation_id: uuidSchema });
17072
- caseGuestInvitationsQuery = casePageQuery.extend({
17073
- limit: external_exports.coerce.number().int().min(1).max(CASE_GUEST_INVITATIONS_PAGE_MAX).optional()
17074
- });
17075
- joinCaseSpaceBody = external_exports.object({ invite: caseGuestInviteTokenSchema }).strict();
17076
- caseJoinSearchParams = external_exports.object({ org: uuidSchema, space: uuidSchema, invite: caseGuestInviteTokenSchema });
17077
- }
17078
- });
17079
-
17080
17124
  // ../../packages/core/dist/chunk-74HGW6HA.js
17081
17125
  function addCaseNoteProblem(note) {
17082
17126
  return note.origin !== null && note.kind !== "contribution" ? { reason: "origin_not_contribution", at: "origin" } : null;
@@ -17208,6 +17252,117 @@ var init_chunk_I6CZPDXO = __esm({
17208
17252
  }
17209
17253
  });
17210
17254
 
17255
+ // ../../packages/core/dist/chunk-FPFUDA22.js
17256
+ var caseInputLinkParam, caseCollectionDocumentOfCaseParam, linkCaseCollectionInputBody, linkCasePreviousOutputInputBody, linkCaseReceivedInputBody, linkCaseInputBody, CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON, CASE_LINK_OUTPUT_NOT_PRIOR_REASON, CASE_LINK_RECEIVED_UNKNOWN_REASON, CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON, CASE_LINK_VERSION_NOT_CURRENT_REASON, CASE_COLLECTION_CASES_PAGE_MAX, caseCollectionCasesQuery, CASE_REFERENCES_PAGE_MAX, caseReferencesQuery;
17257
+ var init_chunk_FPFUDA22 = __esm({
17258
+ "../../packages/core/dist/chunk-FPFUDA22.js"() {
17259
+ "use strict";
17260
+ init_chunk_ZZZ65EIA();
17261
+ init_chunk_I6CZPDXO();
17262
+ init_chunk_S2LXF4LF();
17263
+ init_chunk_TYI6QVPX();
17264
+ init_chunk_HZ6CADSY();
17265
+ init_zod();
17266
+ caseInputLinkParam = caseRecordParam.extend({ input_id: uuidSchema });
17267
+ caseCollectionDocumentOfCaseParam = caseRecordParam.extend({ document_id: uuidSchema });
17268
+ linkCaseCollectionInputBody = external_exports.object({
17269
+ document_id: uuidSchema,
17270
+ /** The document's version its writer read as current, or an earlier one it keeps, with its `reason`. */
17271
+ version_id: uuidSchema,
17272
+ /** Why an earlier version is kept: a version decision. Unread when `version_id` is the current one. */
17273
+ reason: caseVersionDecisionReason.optional()
17274
+ }).strict();
17275
+ linkCasePreviousOutputInputBody = external_exports.object({ official_version_id: uuidSchema }).strict();
17276
+ linkCaseReceivedInputBody = external_exports.object({ received_id: uuidSchema }).strict();
17277
+ linkCaseInputBody = external_exports.union([linkCaseCollectionInputBody, linkCasePreviousOutputInputBody, linkCaseReceivedInputBody]);
17278
+ CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON = "official_version_unknown";
17279
+ CASE_LINK_OUTPUT_NOT_PRIOR_REASON = "output_not_prior";
17280
+ CASE_LINK_RECEIVED_UNKNOWN_REASON = "received_unknown";
17281
+ CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON = "document_type_mismatch";
17282
+ CASE_LINK_VERSION_NOT_CURRENT_REASON = "link_version_not_current";
17283
+ CASE_COLLECTION_CASES_PAGE_MAX = 100;
17284
+ caseCollectionCasesQuery = casePageQuery.extend({
17285
+ limit: external_exports.coerce.number().int().min(1).max(CASE_COLLECTION_CASES_PAGE_MAX).optional()
17286
+ });
17287
+ CASE_REFERENCES_PAGE_MAX = 100;
17288
+ caseReferencesQuery = casePageQuery.extend({
17289
+ limit: external_exports.coerce.number().int().min(1).max(CASE_REFERENCES_PAGE_MAX).optional()
17290
+ });
17291
+ }
17292
+ });
17293
+
17294
+ // ../../packages/core/dist/chunk-NVZB33EA.js
17295
+ function isCaseDueDate(value) {
17296
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
17297
+ if (!match) return false;
17298
+ const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
17299
+ if (year < CASE_DUE_DATE_MIN_YEAR || year > CASE_DUE_DATE_MAX_YEAR) return false;
17300
+ const date = new Date(Date.UTC(year, month - 1, day));
17301
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
17302
+ }
17303
+ function setCaseDeadlinesProblem(body) {
17304
+ const seen = /* @__PURE__ */ new Set();
17305
+ for (const [index, phase] of body.phases.entries()) {
17306
+ if (seen.has(phase.phase_id)) return { reason: "phase_repeated", at: `phases.${index}.phase_id` };
17307
+ seen.add(phase.phase_id);
17308
+ }
17309
+ return null;
17310
+ }
17311
+ var CASE_DUE_DATE_MIN_YEAR, CASE_DUE_DATE_MAX_YEAR, CASE_DEADLINES_PHASES_MAX, CASE_OVERDUE_CASES_MAX, caseDueDateSchema, setCaseDeadlinesShape, setCaseDeadlinesBody, setCaseTaskPlanBody, setCaseOwnerBody, caseOverdueQuery;
17312
+ var init_chunk_NVZB33EA = __esm({
17313
+ "../../packages/core/dist/chunk-NVZB33EA.js"() {
17314
+ "use strict";
17315
+ init_chunk_TYI6QVPX();
17316
+ init_chunk_HZ6CADSY();
17317
+ init_zod();
17318
+ CASE_DUE_DATE_MIN_YEAR = 2e3;
17319
+ CASE_DUE_DATE_MAX_YEAR = 2100;
17320
+ CASE_DEADLINES_PHASES_MAX = 50;
17321
+ CASE_OVERDUE_CASES_MAX = 50;
17322
+ caseDueDateSchema = external_exports.string().refine(isCaseDueDate, "Not a calendar date (YYYY-MM-DD)");
17323
+ setCaseDeadlinesShape = external_exports.object({
17324
+ phases: external_exports.array(external_exports.object({ phase_id: uuidSchema, due_on: caseDueDateSchema.nullable() }).strict()).min(1).max(CASE_DEADLINES_PHASES_MAX)
17325
+ }).strict();
17326
+ setCaseDeadlinesBody = setCaseDeadlinesShape.superRefine((body, ctx) => {
17327
+ const found = setCaseDeadlinesProblem(body);
17328
+ if (found) {
17329
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: found.at.split("."), params: { case_deadlines_reason: found.reason } });
17330
+ }
17331
+ });
17332
+ setCaseTaskPlanBody = external_exports.object({
17333
+ owner_person_id: uuidSchema.nullable(),
17334
+ due_on: caseDueDateSchema.nullable()
17335
+ }).strict();
17336
+ setCaseOwnerBody = external_exports.object({ owner_person_id: uuidSchema.nullable() }).strict();
17337
+ caseOverdueQuery = casePageQuery.extend({
17338
+ limit: external_exports.coerce.number().int().min(1).max(CASE_OVERDUE_CASES_MAX).optional()
17339
+ });
17340
+ }
17341
+ });
17342
+
17343
+ // ../../packages/core/dist/chunk-7QN6QYGN.js
17344
+ var CASE_GUEST_EMAIL_MAX, CASE_GUEST_INVITATIONS_PAGE_MAX, CASE_GUEST_INVITE_TOKEN_LENGTH, caseGuestEmailSchema, caseGuestInviteTokenSchema, inviteCaseGuestBody, caseGuestInvitationParam, caseGuestInvitationsQuery, joinCaseSpaceBody, caseJoinSearchParams;
17345
+ var init_chunk_7QN6QYGN = __esm({
17346
+ "../../packages/core/dist/chunk-7QN6QYGN.js"() {
17347
+ "use strict";
17348
+ init_chunk_TYI6QVPX();
17349
+ init_chunk_HZ6CADSY();
17350
+ init_zod();
17351
+ CASE_GUEST_EMAIL_MAX = 320;
17352
+ CASE_GUEST_INVITATIONS_PAGE_MAX = 100;
17353
+ CASE_GUEST_INVITE_TOKEN_LENGTH = 43;
17354
+ caseGuestEmailSchema = external_exports.string().trim().toLowerCase().max(CASE_GUEST_EMAIL_MAX).email();
17355
+ caseGuestInviteTokenSchema = external_exports.string().regex(new RegExp(`^[A-Za-z0-9_-]{${CASE_GUEST_INVITE_TOKEN_LENGTH}}$`));
17356
+ inviteCaseGuestBody = external_exports.object({ email: caseGuestEmailSchema }).strict();
17357
+ caseGuestInvitationParam = caseSpaceParam.extend({ invitation_id: uuidSchema });
17358
+ caseGuestInvitationsQuery = casePageQuery.extend({
17359
+ limit: external_exports.coerce.number().int().min(1).max(CASE_GUEST_INVITATIONS_PAGE_MAX).optional()
17360
+ });
17361
+ joinCaseSpaceBody = external_exports.object({ invite: caseGuestInviteTokenSchema }).strict();
17362
+ caseJoinSearchParams = external_exports.object({ org: uuidSchema, space: uuidSchema, invite: caseGuestInviteTokenSchema });
17363
+ }
17364
+ });
17365
+
17211
17366
  // ../../packages/core/dist/chunk-7RWVVW7T.js
17212
17367
  var lines, ordered, citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody, citeCaseSourcePassageBody, citeCaseInputPassageBody, caseSourceRefSchema;
17213
17368
  var init_chunk_7RWVVW7T = __esm({
@@ -17232,56 +17387,10 @@ var init_chunk_7RWVVW7T = __esm({
17232
17387
  }
17233
17388
  });
17234
17389
 
17235
- // ../../packages/core/dist/chunk-5WMOQ5NC.js
17236
- var CASE_RELATION_TYPE_CODE_PATTERN, CASE_RELATION_TYPE_CODE_MAX_LENGTH, CASE_RELATION_TYPE_NAME_MAX_LENGTH, CASE_RELATION_TYPES_PER_SPACE_MAX, CASE_RELATION_DESCRIPTION_MAX_LENGTH, CASE_RELATION_SIDES, CASE_EXTERNAL_SYSTEM_PATTERN, CASE_EXTERNAL_NUMBER_MAX_LENGTH, CASE_EXTERNAL_URL_MAX_LENGTH, trimmedName2, relationTypeFields, createCaseRelationTypeBody, updateCaseRelationTypeBody, relateCasesBody, addCaseExternalReferenceBody, caseRelationTypeParam, caseRelationParam, caseExternalReferenceParam, caseRelationTypesQuery;
17237
- var init_chunk_5WMOQ5NC = __esm({
17238
- "../../packages/core/dist/chunk-5WMOQ5NC.js"() {
17239
- "use strict";
17240
- init_chunk_S2LXF4LF();
17241
- init_chunk_TYI6QVPX();
17242
- init_chunk_HZ6CADSY();
17243
- init_zod();
17244
- CASE_RELATION_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
17245
- CASE_RELATION_TYPE_CODE_MAX_LENGTH = 64;
17246
- CASE_RELATION_TYPE_NAME_MAX_LENGTH = 200;
17247
- CASE_RELATION_TYPES_PER_SPACE_MAX = 100;
17248
- CASE_RELATION_DESCRIPTION_MAX_LENGTH = 500;
17249
- CASE_RELATION_SIDES = ["origin", "destination"];
17250
- CASE_EXTERNAL_SYSTEM_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,30}$/;
17251
- CASE_EXTERNAL_NUMBER_MAX_LENGTH = 120;
17252
- CASE_EXTERNAL_URL_MAX_LENGTH = 2048;
17253
- trimmedName2 = external_exports.string().trim().min(1).max(CASE_RELATION_TYPE_NAME_MAX_LENGTH);
17254
- relationTypeFields = { name: trimmedName2, inverse_name: trimmedName2, active: external_exports.boolean().default(true) };
17255
- createCaseRelationTypeBody = external_exports.object({
17256
- code: external_exports.string().trim().max(CASE_RELATION_TYPE_CODE_MAX_LENGTH).regex(CASE_RELATION_TYPE_CODE_PATTERN),
17257
- ...relationTypeFields
17258
- }).strict();
17259
- updateCaseRelationTypeBody = external_exports.object({ ...relationTypeFields, expected_updated_at: timestampSchema.optional() }).strict();
17260
- relateCasesBody = external_exports.object({
17261
- relation_type_id: uuidSchema,
17262
- other_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN),
17263
- /** This case's side: `origin` reads the type's name ("continues"), `destination` its inverse. */
17264
- side: external_exports.enum(CASE_RELATION_SIDES).default("origin"),
17265
- description: external_exports.string().trim().min(1).max(CASE_RELATION_DESCRIPTION_MAX_LENGTH).nullable().default(null)
17266
- }).strict();
17267
- addCaseExternalReferenceBody = external_exports.object({
17268
- system: external_exports.string().trim().regex(CASE_EXTERNAL_SYSTEM_PATTERN),
17269
- number: external_exports.string().trim().min(1).max(CASE_EXTERNAL_NUMBER_MAX_LENGTH),
17270
- url: external_exports.string().trim().max(CASE_EXTERNAL_URL_MAX_LENGTH).url().refine((url) => url.startsWith("https://"), "An https link").nullable().default(null)
17271
- }).strict();
17272
- caseRelationTypeParam = caseSpaceParam.extend({ relation_type_id: uuidSchema });
17273
- caseRelationParam = caseRecordParam.extend({ relation_id: uuidSchema });
17274
- caseExternalReferenceParam = caseRecordParam.extend({ reference_id: uuidSchema });
17275
- caseRelationTypesQuery = casePageQuery.extend({
17276
- limit: external_exports.coerce.number().int().min(1).max(CASE_RELATION_TYPES_PER_SPACE_MAX).optional()
17277
- });
17278
- }
17279
- });
17280
-
17281
- // ../../packages/core/dist/chunk-Z3SV3XTC.js
17390
+ // ../../packages/core/dist/chunk-AF2RCYPB.js
17282
17391
  var caseAccessQuery;
17283
- var init_chunk_Z3SV3XTC = __esm({
17284
- "../../packages/core/dist/chunk-Z3SV3XTC.js"() {
17392
+ var init_chunk_AF2RCYPB = __esm({
17393
+ "../../packages/core/dist/chunk-AF2RCYPB.js"() {
17285
17394
  "use strict";
17286
17395
  init_chunk_HZ6CADSY();
17287
17396
  init_zod();
@@ -17372,45 +17481,6 @@ var init_chunk_E66NXU3F = __esm({
17372
17481
  }
17373
17482
  });
17374
17483
 
17375
- // ../../packages/core/dist/chunk-W2VXSBO2.js
17376
- var caseInputLinkParam, caseCollectionDocumentOfCaseParam, linkCaseCollectionInputBody, linkCasePreviousOutputInputBody, linkCaseReceivedInputBody, linkCaseInputBody, CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON, CASE_LINK_OUTPUT_NOT_PRIOR_REASON, CASE_LINK_RECEIVED_UNKNOWN_REASON, CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON, CASE_LINK_VERSION_NOT_CURRENT_REASON, CASE_COLLECTION_CASES_PAGE_MAX, caseCollectionCasesQuery, CASE_REFERENCES_PAGE_MAX, caseReferencesQuery;
17377
- var init_chunk_W2VXSBO2 = __esm({
17378
- "../../packages/core/dist/chunk-W2VXSBO2.js"() {
17379
- "use strict";
17380
- init_chunk_O6OMUGGZ();
17381
- init_chunk_I6CZPDXO();
17382
- init_chunk_S2LXF4LF();
17383
- init_chunk_TYI6QVPX();
17384
- init_chunk_HZ6CADSY();
17385
- init_zod();
17386
- caseInputLinkParam = caseRecordParam.extend({ input_id: uuidSchema });
17387
- caseCollectionDocumentOfCaseParam = caseRecordParam.extend({ document_id: uuidSchema });
17388
- linkCaseCollectionInputBody = external_exports.object({
17389
- document_id: uuidSchema,
17390
- /** The document's version its writer read as current, or an earlier one it keeps, with its `reason`. */
17391
- version_id: uuidSchema,
17392
- /** Why an earlier version is kept: a version decision. Unread when `version_id` is the current one. */
17393
- reason: caseVersionDecisionReason.optional()
17394
- }).strict();
17395
- linkCasePreviousOutputInputBody = external_exports.object({ official_version_id: uuidSchema }).strict();
17396
- linkCaseReceivedInputBody = external_exports.object({ received_id: uuidSchema }).strict();
17397
- linkCaseInputBody = external_exports.union([linkCaseCollectionInputBody, linkCasePreviousOutputInputBody, linkCaseReceivedInputBody]);
17398
- CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON = "official_version_unknown";
17399
- CASE_LINK_OUTPUT_NOT_PRIOR_REASON = "output_not_prior";
17400
- CASE_LINK_RECEIVED_UNKNOWN_REASON = "received_unknown";
17401
- CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON = "document_type_mismatch";
17402
- CASE_LINK_VERSION_NOT_CURRENT_REASON = "link_version_not_current";
17403
- CASE_COLLECTION_CASES_PAGE_MAX = 100;
17404
- caseCollectionCasesQuery = casePageQuery.extend({
17405
- limit: external_exports.coerce.number().int().min(1).max(CASE_COLLECTION_CASES_PAGE_MAX).optional()
17406
- });
17407
- CASE_REFERENCES_PAGE_MAX = 100;
17408
- caseReferencesQuery = casePageQuery.extend({
17409
- limit: external_exports.coerce.number().int().min(1).max(CASE_REFERENCES_PAGE_MAX).optional()
17410
- });
17411
- }
17412
- });
17413
-
17414
17484
  // ../../packages/core/dist/chunk-UEJOG2Q7.js
17415
17485
  var archiveHubIdParam, archiveConversationParams, archiveListQuery, archiveMessageObservabilityParams;
17416
17486
  var init_chunk_UEJOG2Q7 = __esm({
@@ -18485,17 +18555,18 @@ var init_chunk_SOJMWM63 = __esm({
18485
18555
  var init_contracts = __esm({
18486
18556
  "../../packages/core/dist/contracts/index.js"() {
18487
18557
  "use strict";
18558
+ init_chunk_VXEAR36B();
18488
18559
  init_chunk_RACEDHG6();
18489
18560
  init_chunk_Q7KIQHAZ();
18561
+ init_chunk_IPXBFWUU();
18490
18562
  init_chunk_63UWXV4T();
18491
18563
  init_chunk_AYLAGFAD();
18492
18564
  init_chunk_OPJ5OACS();
18493
18565
  init_chunk_YVY2TZK2();
18494
- init_chunk_VXEAR36B();
18495
18566
  init_chunk_HIGKBEPF();
18496
18567
  init_chunk_WONSSUXU();
18497
18568
  init_chunk_C7UAGRXF();
18498
- init_chunk_IPXBFWUU();
18569
+ init_chunk_PFGVH2CX();
18499
18570
  init_chunk_TVUDMGWV();
18500
18571
  init_chunk_WTIGECE5();
18501
18572
  init_chunk_WDAXZDJO();
@@ -18504,62 +18575,62 @@ var init_contracts = __esm({
18504
18575
  init_chunk_5DGHIY7L();
18505
18576
  init_chunk_2IPHTFV5();
18506
18577
  init_chunk_IPDOHAZ5();
18507
- init_chunk_PFGVH2CX();
18508
18578
  init_chunk_FPSDNS2E();
18509
18579
  init_chunk_TZH6DKKJ();
18510
18580
  init_chunk_SSPK6ISL();
18511
18581
  init_chunk_ZXK6N2HN();
18512
18582
  init_chunk_Y7CFCYX4();
18583
+ init_chunk_2ZZZHXZR();
18513
18584
  init_chunk_YUZFHVB2();
18514
18585
  init_chunk_I3O2RACG();
18515
18586
  init_chunk_CMRECH67();
18516
18587
  init_chunk_34LE6P7E();
18588
+ init_chunk_C4HEZ7ZI();
18517
18589
  init_chunk_IR2NOSI3();
18518
18590
  init_chunk_OPETF4GS();
18519
18591
  init_chunk_SY6PLCPK();
18520
- init_chunk_2ZZZHXZR();
18592
+ init_chunk_ACGAI25T();
18521
18593
  init_chunk_MH4O3YEX();
18522
18594
  init_chunk_QEEQN2NE();
18523
18595
  init_chunk_KSTYTQ7I();
18524
18596
  init_chunk_LKBSHANA();
18525
18597
  init_chunk_LX3D5LCB();
18526
- init_chunk_C4HEZ7ZI();
18598
+ init_chunk_JDJ4EUOL();
18527
18599
  init_chunk_UCYWGWQT();
18528
18600
  init_chunk_6AYIXGDT();
18529
18601
  init_chunk_YULHXJ5M();
18530
18602
  init_chunk_V4FRPRH5();
18531
18603
  init_chunk_LWMLR2WI();
18532
- init_chunk_ACGAI25T();
18533
18604
  init_chunk_ME6NL7FI();
18534
18605
  init_chunk_7CYHPF35();
18535
18606
  init_chunk_NETRUHZF();
18536
- init_chunk_LZHLURLT();
18607
+ init_chunk_S24FZRPG();
18537
18608
  init_chunk_QG3XMUEN();
18538
18609
  init_chunk_EBUWHIFV();
18539
- init_chunk_PCQIFFYO();
18540
- init_chunk_AHISKXHA();
18610
+ init_chunk_5YZ3R7KF();
18541
18611
  init_chunk_2YEGUQR7();
18542
- init_chunk_JDJ4EUOL();
18543
- init_chunk_5LTMGGTR();
18612
+ init_chunk_AHISKXHA();
18613
+ init_chunk_UAFAJNZ6();
18544
18614
  init_chunk_K3PD6AOF();
18545
18615
  init_chunk_F4264AMK();
18546
18616
  init_chunk_ZTRVP4OT();
18617
+ init_chunk_5WMOQ5NC();
18547
18618
  init_chunk_UPGAWPE2();
18548
18619
  init_chunk_3EEL6BQ7();
18549
- init_chunk_UWJJF7PZ();
18550
- init_chunk_56WMNWMX();
18551
- init_chunk_IK7IREH7();
18620
+ init_chunk_VHA3AQE4();
18621
+ init_chunk_2S6LIRGD();
18622
+ init_chunk_WJJJFHIA();
18623
+ init_chunk_FPFUDA22();
18624
+ init_chunk_ZZZ65EIA();
18625
+ init_chunk_ATX6AHPZ();
18626
+ init_chunk_NKJ2DQCV();
18552
18627
  init_chunk_NVZB33EA();
18553
18628
  init_chunk_7QN6QYGN();
18554
18629
  init_chunk_7RWVVW7T();
18555
- init_chunk_5WMOQ5NC();
18556
- init_chunk_Z3SV3XTC();
18630
+ init_chunk_5PKKFSSF();
18631
+ init_chunk_AF2RCYPB();
18557
18632
  init_chunk_2KOYNTE2();
18558
18633
  init_chunk_E66NXU3F();
18559
- init_chunk_W2VXSBO2();
18560
- init_chunk_O6OMUGGZ();
18561
- init_chunk_NKJ2DQCV();
18562
- init_chunk_ATX6AHPZ();
18563
18634
  init_chunk_I6CZPDXO();
18564
18635
  init_chunk_UEJOG2Q7();
18565
18636
  init_chunk_KEN2DASI();
@@ -18572,7 +18643,6 @@ var init_contracts = __esm({
18572
18643
  init_chunk_PZPOUXJR();
18573
18644
  init_chunk_LBDH7LCG();
18574
18645
  init_chunk_4LXDRTO4();
18575
- init_chunk_5PKKFSSF();
18576
18646
  init_chunk_NVKU5PPQ();
18577
18647
  init_chunk_347WE2N4();
18578
18648
  init_chunk_FECLIZTY();
@@ -18605,7 +18675,7 @@ var init_contracts = __esm({
18605
18675
  init_chunk_MIWZOSPI();
18606
18676
  init_chunk_2ISUBJG7();
18607
18677
  init_chunk_C2UEA2KW();
18608
- init_chunk_CBPHDU3I();
18678
+ init_chunk_K6O2P77D();
18609
18679
  init_chunk_YR7QALGP();
18610
18680
  init_chunk_LU4T7K5F();
18611
18681
  init_chunk_74HGW6HA();
@@ -20492,10 +20562,10 @@ var init_case_type_drafts = __esm({
20492
20562
  var init_case_received_documents = __esm({
20493
20563
  "../../packages/core/dist/contracts/case-received-documents.js"() {
20494
20564
  "use strict";
20495
- init_chunk_IK7IREH7();
20496
- init_chunk_O6OMUGGZ();
20497
- init_chunk_NKJ2DQCV();
20565
+ init_chunk_WJJJFHIA();
20566
+ init_chunk_ZZZ65EIA();
20498
20567
  init_chunk_ATX6AHPZ();
20568
+ init_chunk_NKJ2DQCV();
20499
20569
  init_chunk_AMKBCOOH();
20500
20570
  init_chunk_S2LXF4LF();
20501
20571
  init_chunk_WLKYA2B2();
@@ -24361,9 +24431,9 @@ var init_pages2 = __esm({
24361
24431
  var init_evals = __esm({
24362
24432
  "../../packages/core/dist/contracts/evals.js"() {
24363
24433
  "use strict";
24364
- init_chunk_PCQIFFYO();
24365
- init_chunk_AHISKXHA();
24434
+ init_chunk_5YZ3R7KF();
24366
24435
  init_chunk_2YEGUQR7();
24436
+ init_chunk_AHISKXHA();
24367
24437
  init_chunk_4LXDRTO4();
24368
24438
  init_chunk_AMMLEB4T();
24369
24439
  init_chunk_KB5RK3RP();
@@ -25389,12 +25459,12 @@ var init_hub_materializer = __esm({
25389
25459
  var init_ci = __esm({
25390
25460
  "../../packages/core/dist/contracts/ci.js"() {
25391
25461
  "use strict";
25392
- init_chunk_LZHLURLT();
25462
+ init_chunk_S24FZRPG();
25393
25463
  init_chunk_QG3XMUEN();
25394
25464
  init_chunk_EBUWHIFV();
25395
- init_chunk_PCQIFFYO();
25396
- init_chunk_AHISKXHA();
25465
+ init_chunk_5YZ3R7KF();
25397
25466
  init_chunk_2YEGUQR7();
25467
+ init_chunk_AHISKXHA();
25398
25468
  init_chunk_QMQGGR7Q();
25399
25469
  init_chunk_LBDH7LCG();
25400
25470
  init_chunk_4LXDRTO4();
@@ -26423,14 +26493,13 @@ function parseDuration(input, flag = "duration") {
26423
26493
  }
26424
26494
  return value * unitMs;
26425
26495
  }
26426
- var BASE_SECRET_STORAGE_WHY, DURATION_RE, DURATION_UNIT_MS;
26496
+ var DURATION_RE, DURATION_UNIT_MS;
26427
26497
  var init_helpers = __esm({
26428
26498
  "src/data/helpers.ts"() {
26429
26499
  "use strict";
26430
26500
  init_base_id();
26431
26501
  init_expected();
26432
26502
  init_utils();
26433
- BASE_SECRET_STORAGE_WHY = "the credentials vault does not hold this kind of secret yet";
26434
26503
  DURATION_RE = /^(\d+)([smhd])$/;
26435
26504
  DURATION_UNIT_MS = {
26436
26505
  s: 1e3,
@@ -26969,109 +27038,8 @@ var init_output = __esm({
26969
27038
  }
26970
27039
  });
26971
27040
 
26972
- // src/data/commands/triggers.ts
26973
- import { randomUUID } from "crypto";
26974
- import { Command } from "commander";
26975
- function warnUnsignedTriggers(ids) {
26976
- if (!ids || ids.length === 0) return;
26977
- console.warn(
26978
- `
26979
- Webhook triggers that deliver unsigned, with no X-Data-Signature or X-Data-Timestamp header (no signing secret can be stored for now): ${ids.map((id) => sanitizeTerminalText(id)).join(", ")}. A receiver that verifies signatures will reject their deliveries.`
26980
- );
26981
- }
26982
- function buildTriggersCommand() {
26983
- const triggers = new Command("triggers").description(
26984
- "Manage triggers (outbound webhooks, internal writes, external writes)"
26985
- );
26986
- triggers.command("create").description(
26987
- "Create a trigger (a webhook, an internal_write that patches a referenced record, or an external_write that mirrors the record to an external source)"
26988
- ).requiredOption("--name <name>", "Trigger name").requiredOption("--events <events>", "Comma-separated event types").option("--url <url>", "Webhook target URL (webhook actions; delivered unsigned for now)").option("--secret-stdin", "Read the webhook signing secret from stdin (unavailable for now)").option("--secret-prompt", "Prompt for the webhook signing secret, masked (unavailable for now)").option(
26989
- "--action <json>",
26990
- `Action JSON. webhook {"type":"webhook","url":...}; internal_write {"type":"internal_write","target":"slots","match":{"source_field":"data.slot_id"},"patch":{"status":"busy"},"precondition":{"field":"data.status","op":"eq","value":"free"},"mode":"async"} (mode: "async" applies after the write, "transactional" applies atomically so a precondition miss rolls the write back); external_write {"type":"external_write","record_type":"upstream_appointments","source":"legacy","op":"create","watched_fields":"mapped"} (writes the triggering record through that source's write path \u2014 translation, endpoint, auth \u2014 and links the upstream-assigned id back as external_id; "record_type" defaults to the triggering record_type, "op" defaults from the event; "watched_fields" scopes UPDATE dispatch to writes that changed an upstream-mapped field \u2014 "mapped" = the source's to_external keys, or an explicit array of data fields \u2014 so an overlay-only write skips the redundant upstream push; omit to fire on every update)`
26991
- ).option("--id <id>", "Trigger ID (auto-generated if omitted)").option("--record-type-scope <record_types>", "Comma-separated record_type scope").option("--filter <json>", "Filter expression (JSON)").option(
26992
- "--skip-cascade-writes <bool>",
26993
- "Skip firing on cascade-originated (internal_write) writes (default true)"
26994
- ).action(async function(opts) {
26995
- if (opts.secretStdin || opts.secretPrompt) throw expected(SIGNING_SECRET_UNAVAILABLE);
26996
- if (!opts.action && !opts.url) {
26997
- throw expected("Provide --url (webhook) or --action <json> (e.g. an internal_write action).");
26998
- }
26999
- const body = {
27000
- name: opts.name,
27001
- events: splitList(opts.events),
27002
- enabled: true
27003
- };
27004
- if (opts.action) {
27005
- body.action = parseData(opts.action);
27006
- } else {
27007
- body.url = opts.url;
27008
- }
27009
- if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
27010
- if (opts.filter) body.filter = parseData(opts.filter);
27011
- if (opts.skipCascadeWrites !== void 0) {
27012
- body.skip_cascade_writes = opts.skipCascadeWrites !== "false";
27013
- }
27014
- const base = pathSegment(requireBase(this), "--base");
27015
- const client = await createDataClient();
27016
- const triggerId = opts.id ?? randomUUID();
27017
- const trigger = await client.request(
27018
- "PUT",
27019
- `/v1/${base}/triggers/${pathSegment(triggerId, "--id")}`,
27020
- body
27021
- );
27022
- printOutput(trigger, outputFormat(this));
27023
- if (trigger?.warnings?.includes("unsigned_delivery")) warnUnsignedTriggers([triggerId]);
27024
- });
27025
- triggers.command("get <id>").description("Get a trigger").action(async function(id) {
27026
- const base = pathSegment(requireBase(this), "--base");
27027
- const client = await createDataClient();
27028
- printOutput(await client.request("GET", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`), outputFormat(this));
27029
- });
27030
- triggers.command("list").description("List all triggers").action(async function() {
27031
- const base = pathSegment(requireBase(this), "--base");
27032
- const client = await createDataClient();
27033
- printOutput(await client.request("GET", `/v1/${base}/triggers`), outputFormat(this));
27034
- });
27035
- triggers.command("deliveries").description("List trigger delivery attempts (status, retries, errors)").option("--status <status>", "Filter by status (pending | delivered | failed | dead)").option("--trigger-id <id>", "Filter by trigger id").action(async function(opts) {
27036
- const base = pathSegment(requireBase(this), "--base");
27037
- const client = await createDataClient();
27038
- const params = new URLSearchParams();
27039
- if (opts.status) params.set("status", opts.status);
27040
- if (opts.triggerId) params.set("trigger_id", opts.triggerId);
27041
- const qs = params.toString();
27042
- printOutput(
27043
- await client.request("GET", `/v1/${base}/triggers/deliveries${qs ? `?${qs}` : ""}`),
27044
- outputFormat(this)
27045
- );
27046
- });
27047
- triggers.command("delete <id>").description("Delete a trigger").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
27048
- if (!opts.yes && !await confirm(`Delete trigger ${id}? This cannot be undone.`)) {
27049
- console.log("Aborted");
27050
- return;
27051
- }
27052
- const base = pathSegment(requireBase(this), "--base");
27053
- const client = await createDataClient();
27054
- await client.request("DELETE", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`);
27055
- console.log("Deleted");
27056
- });
27057
- return triggers;
27058
- }
27059
- var SIGNING_SECRET_UNAVAILABLE;
27060
- var init_triggers = __esm({
27061
- "src/data/commands/triggers.ts"() {
27062
- "use strict";
27063
- init_expected();
27064
- init_client();
27065
- init_output();
27066
- init_helpers();
27067
- init_utils();
27068
- init_terminal_output();
27069
- SIGNING_SECRET_UNAVAILABLE = `Setting a webhook trigger's signing secret is unavailable for now: ${BASE_SECRET_STORAGE_WHY}. Nothing was read or stored. Omit --secret-stdin and --secret-prompt to create the trigger; it delivers unsigned.`;
27070
- }
27071
- });
27072
-
27073
27041
  // src/data/commands/credentials.ts
27074
- import { Command as Command2 } from "commander";
27042
+ import { Command } from "commander";
27075
27043
  import { readFileSync as readFileSync15 } from "fs";
27076
27044
  function withValueSourceOptions(cmd, what) {
27077
27045
  return cmd.option(
@@ -27108,9 +27076,9 @@ function refusalReason(err) {
27108
27076
  const reason3 = dataErrorDetails(err)?.reason;
27109
27077
  return typeof reason3 === "string" ? reason3 : null;
27110
27078
  }
27111
- async function assertStorageOn(client, path55, body) {
27079
+ async function assertStorageOn(client, path55, body, method = "POST") {
27112
27080
  try {
27113
- await client.request("POST", path55, body);
27081
+ await client.request(method, path55, body);
27114
27082
  } catch (err) {
27115
27083
  if (refusalReason(err) === VALUE_MISSING) return;
27116
27084
  const reason3 = refusalReason(err);
@@ -27199,7 +27167,7 @@ async function reenterRefusedCredentials(client, base, message, pushedSources) {
27199
27167
  }
27200
27168
  function buildBasesCredentialsCommand() {
27201
27169
  const credentials = withBaseOption(
27202
- new Command2("credentials").description("Manage a base's integration credentials")
27170
+ new Command("credentials").description("Manage a base's integration credentials")
27203
27171
  );
27204
27172
  withValueSourceOptions(
27205
27173
  credentials.command("create").description(
@@ -27316,6 +27284,124 @@ var init_credentials = __esm({
27316
27284
  }
27317
27285
  });
27318
27286
 
27287
+ // src/data/commands/webhook-secrets.ts
27288
+ function secretPath(kind, base, id) {
27289
+ return `/v1/${pathSegment(base, "--base")}/${kind.family}/${pathSegment(id, `${kind.noun} id`)}/secret`;
27290
+ }
27291
+ function warnHoldersWithoutSecret(kind, ids, base) {
27292
+ if (!ids || ids.length === 0) return;
27293
+ console.warn(
27294
+ `
27295
+ ${kind.manyLacking}: ${ids.map((id) => sanitizeTerminalText(id)).join(", ")}. ${kind.manyLackingThen}Set one with ${setSecretCommand(kind, "<id>", base)}.`
27296
+ );
27297
+ }
27298
+ async function assertSecretStorageOn(client, kind, base, id) {
27299
+ await assertStorageOn(client, secretPath(kind, base, id), {}, "PUT");
27300
+ }
27301
+ function readSecretValue(kind, opts) {
27302
+ return readSecret(
27303
+ { stdin: opts.secretStdin, prompt: opts.secretPrompt, stdinFlag: "--secret-stdin", promptHint: "--secret-prompt" },
27304
+ `The ${kind.noun}'s ${kind.secret}`
27305
+ );
27306
+ }
27307
+ function setSecret(client, kind, base, id, value) {
27308
+ return client.request("PUT", secretPath(kind, base, id), { value });
27309
+ }
27310
+ function withSecretSourceOptions(cmd, kind, promptByDefault) {
27311
+ return cmd.option("--secret-stdin", `Read the ${kind.secret} from stdin (recommended for CI)`).option("--secret-prompt", `Prompt for the ${kind.secret}, masked${promptByDefault ? " (the default in a terminal)" : ""}`);
27312
+ }
27313
+ async function createHolder(client, kind, base, id, body, opts, format) {
27314
+ let value;
27315
+ if (opts.secretStdin || opts.secretPrompt) {
27316
+ await assertSecretStorageOn(client, kind, base, id);
27317
+ value = await readSecretValue(kind, opts);
27318
+ }
27319
+ const created = await client.request(
27320
+ "PUT",
27321
+ `/v1/${pathSegment(base, "--base")}/${kind.family}/${pathSegment(id, "--id")}`,
27322
+ body
27323
+ );
27324
+ if (value === void 0) {
27325
+ printOutput(created, format);
27326
+ if (kind.leftWithout(created)) warnHoldersWithoutSecret(kind, [id], base);
27327
+ return;
27328
+ }
27329
+ try {
27330
+ printOutput(await setSecret(client, kind, base, id, value), format);
27331
+ } catch (err) {
27332
+ const name = sanitizeTerminalText(id);
27333
+ throw expected(
27334
+ `${kind.noun[0].toUpperCase()}${kind.noun.slice(1)} '${name}' was created, but its ${kind.secret} was not stored: ${refusalMessage(err)} ${kind.lacking} until one is set: ${setSecretCommand(kind, name, base)}.`
27335
+ );
27336
+ }
27337
+ }
27338
+ function addSecretCommands(namespace, kind) {
27339
+ withSecretSourceOptions(
27340
+ namespace.command("set-secret <id>").description(`Set the ${kind.noun}'s ${kind.secret}, ${kind.does}; replaces one it holds`),
27341
+ kind,
27342
+ true
27343
+ ).action(async function(id, opts) {
27344
+ const base = requireBase(this);
27345
+ const client = await createDataClient();
27346
+ await assertSecretStorageOn(client, kind, base, id);
27347
+ printOutput(await setSecret(client, kind, base, id, await readSecretValue(kind, opts)), outputFormat(this));
27348
+ });
27349
+ namespace.command("delete-secret <id>").description(`Delete the ${kind.noun}'s ${kind.secret}`).option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
27350
+ const base = requireBase(this);
27351
+ if (!opts.yes) {
27352
+ if (!isInteractive()) throw expected("Refusing to delete without confirmation \u2014 pass --yes to delete non-interactively.");
27353
+ const ok = await confirm(`Delete the ${kind.secret} of ${kind.noun} ${sanitizeTerminalText(id)} on base ${sanitizeTerminalText(base)}? ${kind.without}`);
27354
+ if (!ok) {
27355
+ console.log("Aborted");
27356
+ return;
27357
+ }
27358
+ }
27359
+ const client = await createDataClient();
27360
+ printOutput(await client.request("DELETE", secretPath(kind, base, id)), outputFormat(this));
27361
+ });
27362
+ }
27363
+ var INBOUND_WEBHOOK_SECRET, TRIGGER_SIGNING_SECRET, setSecretCommand;
27364
+ var init_webhook_secrets = __esm({
27365
+ "src/data/commands/webhook-secrets.ts"() {
27366
+ "use strict";
27367
+ init_expected();
27368
+ init_utils();
27369
+ init_terminal_output();
27370
+ init_client();
27371
+ init_output();
27372
+ init_helpers();
27373
+ init_credentials();
27374
+ INBOUND_WEBHOOK_SECRET = {
27375
+ family: "inbound-webhooks",
27376
+ noun: "inbound webhook",
27377
+ secret: "secret",
27378
+ does: "which verifies its deliveries (the Signing v1 shared secret, or the static header's value)",
27379
+ without: "It then verifies no delivery: each is refused.",
27380
+ lacking: "It verifies no delivery",
27381
+ manyLacking: "Inbound webhooks with no secret, which verify no delivery (each is refused)",
27382
+ manyLackingThen: "",
27383
+ // The webhook's read says whether it holds one: an upsert of an existing webhook keeps its secret.
27384
+ leftWithout: (answer) => answer?.secret_stored !== true
27385
+ };
27386
+ TRIGGER_SIGNING_SECRET = {
27387
+ family: "triggers",
27388
+ noun: "trigger",
27389
+ secret: "signing secret",
27390
+ does: "which signs its deliveries (a webhook trigger only)",
27391
+ without: "Its deliveries then go out unsigned.",
27392
+ lacking: "It delivers unsigned",
27393
+ manyLacking: "Webhook triggers that deliver unsigned, with no X-Data-Signature or X-Data-Timestamp header (they hold no signing secret)",
27394
+ manyLackingThen: "A receiver that verifies signatures will reject their deliveries. ",
27395
+ // The service names a webhook trigger that delivers unsigned; an internal or external write is not one.
27396
+ leftWithout: (answer) => {
27397
+ const warnings = answer?.warnings;
27398
+ return Array.isArray(warnings) && warnings.includes("unsigned_delivery");
27399
+ }
27400
+ };
27401
+ setSecretCommand = (kind, id, base) => `\`wayai ${kind.family} set-secret ${id} --base ${sanitizeTerminalText(base)}\``;
27402
+ }
27403
+ });
27404
+
27319
27405
  // src/data/config-as-code/sync.ts
27320
27406
  var sync_exports = {};
27321
27407
  __export(sync_exports, {
@@ -27513,7 +27599,8 @@ Apply these changes to preview "${sanitizeTerminalText(baseId)}"?`);
27513
27599
  }
27514
27600
  }
27515
27601
  const result = await applyRefusedCredentialsAgain(client, baseId, config);
27516
- warnUnsignedTriggers(result.unsigned_triggers);
27602
+ warnHoldersWithoutSecret(TRIGGER_SIGNING_SECRET, result.unsigned_triggers, baseId);
27603
+ warnHoldersWithoutSecret(INBOUND_WEBHOOK_SECRET, result.inbound_webhooks_without_secret, baseId);
27517
27604
  const removals = collectRemovals(diff);
27518
27605
  if (removals.length > 0) {
27519
27606
  const word = removals.length === 1 ? "entity" : "entities";
@@ -27555,7 +27642,7 @@ var init_sync = __esm({
27555
27642
  init_diff_format();
27556
27643
  init_base_workspace();
27557
27644
  init_types2();
27558
- init_triggers();
27645
+ init_webhook_secrets();
27559
27646
  init_credentials();
27560
27647
  }
27561
27648
  });
@@ -41887,10 +41974,10 @@ var init_case_collection_citations = __esm({
41887
41974
  var init_case_collection_links = __esm({
41888
41975
  "../../packages/core/dist/contracts/case-collection-links.js"() {
41889
41976
  "use strict";
41890
- init_chunk_W2VXSBO2();
41891
- init_chunk_O6OMUGGZ();
41892
- init_chunk_NKJ2DQCV();
41977
+ init_chunk_FPFUDA22();
41978
+ init_chunk_ZZZ65EIA();
41893
41979
  init_chunk_ATX6AHPZ();
41980
+ init_chunk_NKJ2DQCV();
41894
41981
  init_chunk_I6CZPDXO();
41895
41982
  init_chunk_LU4T7K5F();
41896
41983
  init_chunk_74HGW6HA();
@@ -43479,7 +43566,7 @@ var init_case_notes = __esm({
43479
43566
  var init_case_checks = __esm({
43480
43567
  "../../packages/core/dist/contracts/case-checks.js"() {
43481
43568
  "use strict";
43482
- init_chunk_CBPHDU3I();
43569
+ init_chunk_K6O2P77D();
43483
43570
  init_chunk_YR7QALGP();
43484
43571
  init_chunk_HZ6CADSY();
43485
43572
  }
@@ -49473,9 +49560,9 @@ var init_update = __esm({
49473
49560
  });
49474
49561
 
49475
49562
  // src/data/commands/actions.ts
49476
- import { Command as Command3 } from "commander";
49563
+ import { Command as Command2 } from "commander";
49477
49564
  function buildActionsCommand() {
49478
- const actions = new Command3("actions").description(
49565
+ const actions = new Command2("actions").description(
49479
49566
  "Manage Actions \u2014 reusable, named definitions: one record_type + one operation, or a composite of atomic write steps (--config with `steps`)"
49480
49567
  );
49481
49568
  actions.command("upsert <id>").description(
@@ -49544,7 +49631,7 @@ var init_actions = __esm({
49544
49631
  });
49545
49632
 
49546
49633
  // src/data/commands/attachments.ts
49547
- import { Command as Command4 } from "commander";
49634
+ import { Command as Command3 } from "commander";
49548
49635
  import { readFileSync as readFileSync23 } from "fs";
49549
49636
  function findAttachmentByFilename(attachments, filename) {
49550
49637
  return attachments.find((a) => a.key.endsWith(`/${filename}`)) ?? null;
@@ -49571,7 +49658,7 @@ function uploadPathFrom(uploadUrl) {
49571
49658
  return uploadUrl;
49572
49659
  }
49573
49660
  function buildAttachmentsCommand() {
49574
- const attachments = new Command4("attachments").description("Manage record attachments");
49661
+ const attachments = new Command3("attachments").description("Manage record attachments");
49575
49662
  attachments.command("upload <record_type> <id>").description(
49576
49663
  "Get a presigned upload URL for a record attachment. With --file, uploads the file content in one step."
49577
49664
  ).requiredOption("--filename <name>", "File name or path (e.g. docs/guide.md)").option("--content-type <type>", "MIME type", "application/octet-stream").option("--file <path>", "Local file to upload (skips presigned URL output, uploads directly)").action(async function(recordType2, id, opts) {
@@ -49651,9 +49738,9 @@ var init_attachments = __esm({
49651
49738
  });
49652
49739
 
49653
49740
  // src/data/commands/batch.ts
49654
- import { Command as Command5 } from "commander";
49741
+ import { Command as Command4 } from "commander";
49655
49742
  function buildBasesBatchCommand() {
49656
- return withBaseOption(new Command5("batch")).description("Execute atomic batch operations (up to 1,000 operations)").requiredOption("--operations <json>", "Operations array (inline JSON or @filename)").action(async function(opts) {
49743
+ return withBaseOption(new Command4("batch")).description("Execute atomic batch operations (up to 1,000 operations)").requiredOption("--operations <json>", "Operations array (inline JSON or @filename)").action(async function(opts) {
49657
49744
  const base = pathSegment(requireBase(this), "--base");
49658
49745
  const operations = parseData(opts.operations, "--operations");
49659
49746
  const client = await createDataClient();
@@ -49681,8 +49768,8 @@ var init_batch = __esm({
49681
49768
  import { createReadStream } from "fs";
49682
49769
  import { access, constants as constants2, stat } from "fs/promises";
49683
49770
  import { createInterface as createInterface3 } from "readline";
49684
- import { randomUUID as randomUUID2 } from "crypto";
49685
- import { Command as Command6 } from "commander";
49771
+ import { randomUUID } from "crypto";
49772
+ import { Command as Command5 } from "commander";
49686
49773
  function isRetryable(err) {
49687
49774
  if (isNetworkError(err)) return true;
49688
49775
  if (!(err instanceof ApiError)) return false;
@@ -49758,7 +49845,7 @@ async function beginSession(state, client, base, recordType2, requestKey) {
49758
49845
  return res.session;
49759
49846
  }
49760
49847
  function buildBasesImportCommand() {
49761
- const importCmd = withBaseOption(new Command6("import")).description(
49848
+ const importCmd = withBaseOption(new Command5("import")).description(
49762
49849
  "Bulk historical import: load an NDJSON backfill, list sessions, or undo one"
49763
49850
  );
49764
49851
  importCmd.command("run <record_type>").description(
@@ -49797,7 +49884,7 @@ function buildBasesImportCommand() {
49797
49884
  throw expected(`--file ${opts.file}: not a readable file.`);
49798
49885
  }
49799
49886
  const client = await createDataClient();
49800
- const requestKey = opts.requestKey ?? `cli-${randomUUID2()}`;
49887
+ const requestKey = opts.requestKey ?? `cli-${randomUUID()}`;
49801
49888
  if (!opts.requestKey) {
49802
49889
  console.error(`request_key: ${requestKey} (pass --request-key to resume this run)`);
49803
49890
  }
@@ -50002,7 +50089,7 @@ var init_import = __esm({
50002
50089
  });
50003
50090
 
50004
50091
  // src/data/commands/providers.ts
50005
- import { Command as Command7 } from "commander";
50092
+ import { Command as Command6 } from "commander";
50006
50093
  import { writeFileSync as writeFileSync13 } from "fs";
50007
50094
  function providerSegment(provider) {
50008
50095
  if (!VALID_PROVIDERS.includes(provider)) {
@@ -50011,7 +50098,7 @@ function providerSegment(provider) {
50011
50098
  return pathSegment(provider, "provider");
50012
50099
  }
50013
50100
  function buildBasesProvidersCommand() {
50014
- const providers = withBaseOption(new Command7("providers")).description(
50101
+ const providers = withBaseOption(new Command6("providers")).description(
50015
50102
  "Import/export tool definitions between LLM providers and record types"
50016
50103
  );
50017
50104
  providers.command("import <provider>").description(`Import tool definitions as record types. Providers: ${VALID_PROVIDERS_HELP}`).requiredOption("--tools <json>", "Tool definitions (inline JSON or @filename)").action(async function(provider, opts) {
@@ -50082,10 +50169,10 @@ var init_providers = __esm({
50082
50169
  });
50083
50170
 
50084
50171
  // src/data/commands/sql.ts
50085
- import { Command as Command8 } from "commander";
50172
+ import { Command as Command7 } from "commander";
50086
50173
  import { readFileSync as readFileSync24 } from "fs";
50087
50174
  function buildBasesSqlCommand() {
50088
- return withBaseOption(new Command8("sql")).description("Execute a read-only SQL query against base data").argument("[query]", "SQL query (SELECT only)").option("--file <path>", "Read SQL from a file instead of the argument").option(
50175
+ return withBaseOption(new Command7("sql")).description("Execute a read-only SQL query against base data").argument("[query]", "SQL query (SELECT only)").option("--file <path>", "Read SQL from a file instead of the argument").option(
50089
50176
  "--param <kv...>",
50090
50177
  "Named parameters as key=value pairs (e.g. --param status=issued)"
50091
50178
  ).action(async function(queryArg, opts) {
@@ -50128,7 +50215,7 @@ var init_sql = __esm({
50128
50215
  });
50129
50216
 
50130
50217
  // src/data/commands/tokens.ts
50131
- import { Command as Command9 } from "commander";
50218
+ import { Command as Command8 } from "commander";
50132
50219
  function rawTokenFrom(data) {
50133
50220
  const token = typeof data === "object" && data !== null && "token" in data ? data.token : void 0;
50134
50221
  if (typeof token !== "string" || !RAW_TOKEN_PATTERN.test(token)) {
@@ -50186,7 +50273,7 @@ function pruneRow(t, reason3) {
50186
50273
  };
50187
50274
  }
50188
50275
  function buildBasesTokensCommand() {
50189
- const tokens2 = new Command9("tokens").description("Manage API tokens");
50276
+ const tokens2 = new Command8("tokens").description("Manage API tokens");
50190
50277
  addTokenLifecycleOptions(
50191
50278
  tokens2.command("create").description("Create a scoped API token").requiredOption("--name <name>", "Token name").requiredOption("--grants <json>", "Grant definitions as JSON array").option(
50192
50279
  "--token-only",
@@ -50428,7 +50515,7 @@ var init_base_tags = __esm({
50428
50515
  });
50429
50516
 
50430
50517
  // src/data/commands/bases.ts
50431
- import { Command as Command10 } from "commander";
50518
+ import { Command as Command9 } from "commander";
50432
50519
  function pageOf(path55, cursor) {
50433
50520
  if (!cursor) return path55;
50434
50521
  return `${path55}${path55.includes("?") ? "&" : "?"}cursor=${encodeURIComponent(cursor)}`;
@@ -50441,7 +50528,7 @@ function parseEnum(flag, value, allowed) {
50441
50528
  return value;
50442
50529
  }
50443
50530
  function buildBasesCommand() {
50444
- const bases = new Command10("bases").description("Manage bases");
50531
+ const bases = new Command9("bases").description("Manage bases");
50445
50532
  bases.command("list").description("List all bases").option("--tag <tag>", "Filter by tag").action(async function(opts) {
50446
50533
  const client = await createDataClient();
50447
50534
  const qs = opts.tag ? `?tag=${encodeURIComponent(opts.tag)}` : "";
@@ -50615,7 +50702,8 @@ function buildBasesCommand() {
50615
50702
  console.warn("\nReferenced credentials production cannot use:");
50616
50703
  for (const w of unresolved) console.warn(` - ${sanitizeTerminalText(w.message)}`);
50617
50704
  }
50618
- warnUnsignedTriggers(data?.unsigned_triggers);
50705
+ warnHoldersWithoutSecret(TRIGGER_SIGNING_SECRET, data?.unsigned_triggers, productionId);
50706
+ warnHoldersWithoutSecret(INBOUND_WEBHOOK_SECRET, data?.inbound_webhooks_without_secret, productionId);
50619
50707
  });
50620
50708
  bases.command("rollback <production-id>").description("Roll back a promotion (human-only)").requiredOption("--promotion <promotion-id>", "Promotion id to roll back").action(async function(productionId, opts) {
50621
50709
  const client = await createDataClient();
@@ -50625,7 +50713,8 @@ function buildBasesCommand() {
50625
50713
  { promotion_id: opts.promotion }
50626
50714
  );
50627
50715
  printOutput(data, outputFormat(this));
50628
- warnUnsignedTriggers(data?.unsigned_triggers);
50716
+ warnHoldersWithoutSecret(TRIGGER_SIGNING_SECRET, data?.unsigned_triggers, productionId);
50717
+ warnHoldersWithoutSecret(INBOUND_WEBHOOK_SECRET, data?.inbound_webhooks_without_secret, productionId);
50629
50718
  });
50630
50719
  bases.command("promotions <production-id>").description("List promotion history for a production base").action(async function(productionId) {
50631
50720
  const client = await createDataClient();
@@ -50700,7 +50789,7 @@ var init_bases = __esm({
50700
50789
  init_helpers();
50701
50790
  init_utils();
50702
50791
  init_terminal_output();
50703
- init_triggers();
50792
+ init_webhook_secrets();
50704
50793
  init_workspace();
50705
50794
  init_base_workspace();
50706
50795
  init_worktree_scope();
@@ -50709,9 +50798,9 @@ var init_bases = __esm({
50709
50798
  });
50710
50799
 
50711
50800
  // src/data/commands/file-types.ts
50712
- import { Command as Command11 } from "commander";
50801
+ import { Command as Command10 } from "commander";
50713
50802
  function buildFileTypesCommand() {
50714
- const fileTypes = new Command11("file-types").description(
50803
+ const fileTypes = new Command10("file-types").description(
50715
50804
  "Manage file types (Buckets) \u2014 storage policy + optional metadata schema for files"
50716
50805
  );
50717
50806
  fileTypes.command("list").description("List all file types in a base").action(async function() {
@@ -50771,7 +50860,7 @@ var init_file_types = __esm({
50771
50860
  });
50772
50861
 
50773
50862
  // src/data/commands/files.ts
50774
- import { Command as Command12 } from "commander";
50863
+ import { Command as Command11 } from "commander";
50775
50864
  import { readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "fs";
50776
50865
  import { basename as basename31 } from "path";
50777
50866
  function renderFileDiff(fileType, filePath3, from, to, d) {
@@ -50814,7 +50903,7 @@ function downloadTarget(remotePath2, to) {
50814
50903
  return derived;
50815
50904
  }
50816
50905
  function buildFilesCommand() {
50817
- const files = new Command12("files").description(
50906
+ const files = new Command11("files").description(
50818
50907
  "Manage files (path-addressed, versioned content) within a file type"
50819
50908
  );
50820
50909
  files.command("put <file_type> <path>").description(
@@ -51021,25 +51110,38 @@ var init_files2 = __esm({
51021
51110
  });
51022
51111
 
51023
51112
  // src/data/commands/inbound-webhooks.ts
51024
- import { Command as Command13 } from "commander";
51113
+ import { randomUUID as randomUUID2 } from "crypto";
51114
+ import { Command as Command12 } from "commander";
51025
51115
  function buildInboundWebhooksCommand() {
51026
- const inboundWebhooks = new Command13("inbound-webhooks").description(
51116
+ const inboundWebhooks = new Command12("inbound-webhooks").description(
51027
51117
  "Manage inbound webhook endpoints"
51028
51118
  );
51029
- inboundWebhooks.command("create").description("Create a new inbound webhook \u2014 unavailable for now").option("--name <name>", "Inbound webhook name").option("--secret-stdin", "Read the HMAC shared secret from stdin (unavailable for now)").option("--id <id>", "Inbound webhook ID (auto-generated if omitted)").option("--record-type-scope <record_types>", "Comma-separated record_type scope").option(
51030
- "--field-mapping <json>",
51031
- 'Inline mapping applied to the payload before write \u2014 a field_mapping JSON, e.g. {"to_external":{"status":"state"}} (to_external renames auto-invert on read); an explicit inbound-rename block and {"computed":{...}} are also accepted. Mutually exclusive with --source-binding.'
51032
- ).option(
51033
- "--source-binding <json>",
51034
- `Reuse a record_type source's field_mapping for the inbound translation \u2014 {"record_type":"<id>","source":"<name>"}. Mutually exclusive with --field-mapping.`
51035
- ).option(
51036
- "--ingest-auth <json>",
51037
- 'Inbound auth scheme. Default (omitted) = HMAC signature. Static-header senders: {"type":"static_header","header":"X-Account-Key"} \u2014 the configured header is compared to the shared secret (constant-time) instead of an HMAC.'
51038
- ).option(
51039
- "--hydration <json>",
51040
- `Make this a reference-style ("notification + fetch") webhook: a thin delivery names a record id; the base fetches the full record via the bound source's read endpoint and stores it. Requires --source-binding and a single native --record-type-scope. JSON: {"id_path":"record_id","event_path":"event","event_map":{"ResourceDeleted":"delete"},"default_op":"upsert","merge":true}. Set "merge":true to refresh only the mapped (upstream-owned) fields on re-sync and preserve the locally-owned fields (status/tags/scores) on the same record.`
51041
- ).action(() => {
51042
- throw expected(CREATE_UNAVAILABLE);
51119
+ withSecretSourceOptions(
51120
+ inboundWebhooks.command("create").description("Create an inbound webhook (preview bases only), and set its secret when given one").requiredOption("--name <name>", "Inbound webhook name").option("--id <id>", "Inbound webhook ID (auto-generated if omitted)").option("--record-type-scope <record_types>", "Comma-separated record_type scope").option(
51121
+ "--field-mapping <json>",
51122
+ 'Inline mapping applied to the payload before write \u2014 a field_mapping JSON, e.g. {"to_external":{"status":"state"}} (to_external renames auto-invert on read); an explicit inbound-rename block and {"computed":{...}} are also accepted. Mutually exclusive with --source-binding.'
51123
+ ).option(
51124
+ "--source-binding <json>",
51125
+ `Reuse a record_type source's field_mapping for the inbound translation \u2014 {"record_type":"<id>","source":"<name>"}. Mutually exclusive with --field-mapping.`
51126
+ ).option(
51127
+ "--ingest-auth <json>",
51128
+ 'Inbound auth scheme. Default (omitted) = a Signing v1 signature. Static-header senders: {"type":"static_header","header":"X-Account-Key"} \u2014 the configured header is compared to the secret (constant-time) instead of a signature.'
51129
+ ).option(
51130
+ "--hydration <json>",
51131
+ `Make this a reference-style ("notification + fetch") webhook: a thin delivery names a record id; the base fetches the full record via the bound source's read endpoint and stores it. Requires --source-binding and a single native --record-type-scope. JSON: {"id_path":"record_id","event_path":"event","event_map":{"ResourceDeleted":"delete"},"default_op":"upsert","merge":true}. Set "merge":true to refresh only the mapped (upstream-owned) fields on re-sync and preserve the locally-owned fields (status/tags/scores) on the same record.`
51132
+ ),
51133
+ INBOUND_WEBHOOK_SECRET,
51134
+ false
51135
+ ).action(async function(opts) {
51136
+ const body = { name: opts.name, enabled: true };
51137
+ if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
51138
+ if (opts.fieldMapping) body.field_mapping = parseData(opts.fieldMapping);
51139
+ if (opts.sourceBinding) body.source_binding = parseData(opts.sourceBinding);
51140
+ if (opts.ingestAuth) body.ingest_auth = parseData(opts.ingestAuth);
51141
+ if (opts.hydration) body.hydration = parseData(opts.hydration);
51142
+ const base = requireBase(this);
51143
+ const client = await createDataClient();
51144
+ await createHolder(client, INBOUND_WEBHOOK_SECRET, base, opts.id ?? randomUUID2(), body, opts, outputFormat(this));
51043
51145
  });
51044
51146
  inboundWebhooks.command("get <id>").description("Get an inbound webhook").action(async function(id) {
51045
51147
  const base = pathSegment(requireBase(this), "--base");
@@ -51078,25 +51180,24 @@ function buildInboundWebhooksCommand() {
51078
51180
  await client.request("DELETE", `/v1/${base}/inbound-webhooks/${pathSegment(id, "inbound webhook id")}`);
51079
51181
  console.log("Deleted");
51080
51182
  });
51183
+ addSecretCommands(inboundWebhooks, INBOUND_WEBHOOK_SECRET);
51081
51184
  return inboundWebhooks;
51082
51185
  }
51083
- var CREATE_UNAVAILABLE;
51084
51186
  var init_inbound_webhooks = __esm({
51085
51187
  "src/data/commands/inbound-webhooks.ts"() {
51086
51188
  "use strict";
51087
- init_expected();
51088
51189
  init_client();
51089
51190
  init_output();
51090
51191
  init_helpers();
51091
51192
  init_utils();
51092
- CREATE_UNAVAILABLE = `Creating an inbound webhook is unavailable for now: it is verified against a secret, and ${BASE_SECRET_STORAGE_WHY}. Nothing was read or stored.`;
51193
+ init_webhook_secrets();
51093
51194
  }
51094
51195
  });
51095
51196
 
51096
51197
  // src/data/commands/query-relationships.ts
51097
- import { Command as Command14 } from "commander";
51198
+ import { Command as Command13 } from "commander";
51098
51199
  function buildQueryRelationshipsCommand() {
51099
- return new Command14("query-relationships").description("Query related records").argument("<record_type>", "RecordType of the source record").argument("<id>", "Source record ID").option("--type <type>", "Filter by relationship type").option("--direction <dir>", "Direction: outgoing, incoming, or both", "both").option("--limit <n>", "Max results", "50").option("--offset <n>", "Skip results", "0").action(async function(recordType2, id, opts) {
51200
+ return new Command13("query-relationships").description("Query related records").argument("<record_type>", "RecordType of the source record").argument("<id>", "Source record ID").option("--type <type>", "Filter by relationship type").option("--direction <dir>", "Direction: outgoing, incoming, or both", "both").option("--limit <n>", "Max results", "50").option("--offset <n>", "Skip results", "0").action(async function(recordType2, id, opts) {
51100
51201
  const base = pathSegment(requireBase(this), "--base");
51101
51202
  const client = await createDataClient();
51102
51203
  const params = new URLSearchParams();
@@ -51129,9 +51230,9 @@ var init_query_relationships = __esm({
51129
51230
  });
51130
51231
 
51131
51232
  // src/data/commands/record-types.ts
51132
- import { Command as Command15 } from "commander";
51233
+ import { Command as Command14 } from "commander";
51133
51234
  function buildRecordTypesCommand() {
51134
- const recordTypes = new Command15("record-types").description("Manage record_types");
51235
+ const recordTypes = new Command14("record-types").description("Manage record_types");
51135
51236
  recordTypes.command("list").description("List all record_types in a base").action(async function() {
51136
51237
  const base = pathSegment(requireBase(this), "--base");
51137
51238
  const client = await createDataClient();
@@ -51189,12 +51290,12 @@ var init_record_types = __esm({
51189
51290
  });
51190
51291
 
51191
51292
  // src/data/commands/records.ts
51192
- import { Command as Command16 } from "commander";
51293
+ import { Command as Command15 } from "commander";
51193
51294
  function recordKey(id, externalSource) {
51194
51295
  return externalSource ? foreignSegment(id, "external id") : pathSegment(id, "record id");
51195
51296
  }
51196
51297
  function buildRecordsCommand() {
51197
- const records = new Command16("records").description("Manage records");
51298
+ const records = new Command15("records").description("Manage records");
51198
51299
  records.command("upsert <record_type>").description("Create or update a record").requiredOption("--data <json>", "Record data (inline JSON or @filename)").option("--id <id>", "Internal record ID (UUID) to update a known record").option("--external-id <id>", "External/agent-supplied ID for idempotent upsert").option("--external-source <source>", "Source system for external_id (e.g. stripe)").action(async function(recordType2, opts) {
51199
51300
  const base = pathSegment(requireBase(this), "--base");
51200
51301
  const client = await createDataClient();
@@ -51283,9 +51384,9 @@ var init_records = __esm({
51283
51384
  });
51284
51385
 
51285
51386
  // src/data/commands/relationship-types.ts
51286
- import { Command as Command17 } from "commander";
51387
+ import { Command as Command16 } from "commander";
51287
51388
  function buildRelationshipTypesCommand() {
51288
- const relationshipTypes = new Command17("relationship-types").description(
51389
+ const relationshipTypes = new Command16("relationship-types").description(
51289
51390
  "Manage relationship types (the schema for a relationship's metadata)"
51290
51391
  );
51291
51392
  relationshipTypes.command("list").description("List all relationship types in a base").action(async function() {
@@ -51362,7 +51463,7 @@ var init_relationship_types = __esm({
51362
51463
  });
51363
51464
 
51364
51465
  // src/data/commands/relationships.ts
51365
- import { Command as Command18 } from "commander";
51466
+ import { Command as Command17 } from "commander";
51366
51467
  function relationshipKey(id, relType) {
51367
51468
  return relType ? foreignSegment(id, "external id") : pathSegment(id, "relationship id");
51368
51469
  }
@@ -51398,7 +51499,7 @@ function byKeyQuery(relType, externalSource) {
51398
51499
  return q ? `?${q}` : "";
51399
51500
  }
51400
51501
  function buildRelationshipsCommand() {
51401
- const relationships = new Command18("relationships").description(
51502
+ const relationships = new Command17("relationships").description(
51402
51503
  "Manage relationships between records"
51403
51504
  );
51404
51505
  relationships.command("upsert").description("Create or update a relationship").option("--source <record_type/id>", "Source record by internal id").option(
@@ -51483,9 +51584,9 @@ var init_relationships = __esm({
51483
51584
  });
51484
51585
 
51485
51586
  // src/data/commands/seed.ts
51486
- import { Command as Command19 } from "commander";
51587
+ import { Command as Command18 } from "commander";
51487
51588
  function buildSeedCommand() {
51488
- const seed = new Command19("seed").description(
51589
+ const seed = new Command18("seed").description(
51489
51590
  "Apply, reset, or clear a seed fixture on a preview base (hermetic eval data)"
51490
51591
  );
51491
51592
  seed.command("apply <name>").description(
@@ -51577,7 +51678,7 @@ var init_seed = __esm({
51577
51678
  });
51578
51679
 
51579
51680
  // src/data/commands/toolsets.ts
51580
- import { Command as Command20 } from "commander";
51681
+ import { Command as Command19 } from "commander";
51581
51682
  function collect(value, previous) {
51582
51683
  return [...previous, value];
51583
51684
  }
@@ -51600,7 +51701,7 @@ function parseRelSpec(spec) {
51600
51701
  return { rel_type: key, operations: ops };
51601
51702
  }
51602
51703
  function buildToolsetsCommand() {
51603
- const toolsets = new Command20("toolsets").description("Manage MCP toolsets");
51704
+ const toolsets = new Command19("toolsets").description("Manage MCP toolsets");
51604
51705
  toolsets.command("upsert <slug>").description("Create or update an MCP toolset").option("--name <name>", "Toolset display name (required unless using --config)").option("--description <desc>", "Toolset description").option(
51605
51706
  "--action <ref>",
51606
51707
  "Reference an Action by id, optionally renamed: <action_id> or <action_id>=<surface_name> (repeatable). Create Actions first with `wayai actions upsert`.",
@@ -51690,6 +51791,99 @@ var init_toolsets = __esm({
51690
51791
  }
51691
51792
  });
51692
51793
 
51794
+ // src/data/commands/triggers.ts
51795
+ import { randomUUID as randomUUID3 } from "crypto";
51796
+ import { Command as Command20 } from "commander";
51797
+ function buildTriggersCommand() {
51798
+ const triggers = new Command20("triggers").description(
51799
+ "Manage triggers (outbound webhooks, internal writes, external writes)"
51800
+ );
51801
+ withSecretSourceOptions(
51802
+ triggers.command("create").description(
51803
+ "Create a trigger (a webhook, an internal_write that patches a referenced record, or an external_write that mirrors the record to an external source)"
51804
+ ).requiredOption("--name <name>", "Trigger name").requiredOption("--events <events>", "Comma-separated event types").option("--url <url>", "Webhook target URL (webhook actions; signed once it holds a signing secret)").option(
51805
+ "--action <json>",
51806
+ `Action JSON. webhook {"type":"webhook","url":...}; internal_write {"type":"internal_write","target":"slots","match":{"source_field":"data.slot_id"},"patch":{"status":"busy"},"precondition":{"field":"data.status","op":"eq","value":"free"},"mode":"async"} (mode: "async" applies after the write, "transactional" applies atomically so a precondition miss rolls the write back); external_write {"type":"external_write","record_type":"upstream_appointments","source":"legacy","op":"create","watched_fields":"mapped"} (writes the triggering record through that source's write path \u2014 translation, endpoint, auth \u2014 and links the upstream-assigned id back as external_id; "record_type" defaults to the triggering record_type, "op" defaults from the event; "watched_fields" scopes UPDATE dispatch to writes that changed an upstream-mapped field \u2014 "mapped" = the source's to_external keys, or an explicit array of data fields \u2014 so an overlay-only write skips the redundant upstream push; omit to fire on every update)`
51807
+ ).option("--id <id>", "Trigger ID (auto-generated if omitted)").option("--record-type-scope <record_types>", "Comma-separated record_type scope").option("--filter <json>", "Filter expression (JSON)").option(
51808
+ "--skip-cascade-writes <bool>",
51809
+ "Skip firing on cascade-originated (internal_write) writes (default true)"
51810
+ ),
51811
+ TRIGGER_SIGNING_SECRET,
51812
+ false
51813
+ ).action(async function(opts) {
51814
+ if (!opts.action && !opts.url) {
51815
+ throw expected("Provide --url (webhook) or --action <json> (e.g. an internal_write action).");
51816
+ }
51817
+ const body = {
51818
+ name: opts.name,
51819
+ events: splitList(opts.events),
51820
+ enabled: true
51821
+ };
51822
+ if (opts.action) {
51823
+ body.action = parseData(opts.action);
51824
+ } else {
51825
+ body.url = opts.url;
51826
+ }
51827
+ if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
51828
+ if (opts.filter) body.filter = parseData(opts.filter);
51829
+ if (opts.skipCascadeWrites !== void 0) {
51830
+ body.skip_cascade_writes = opts.skipCascadeWrites !== "false";
51831
+ }
51832
+ const type = body.action?.type;
51833
+ if ((opts.secretStdin || opts.secretPrompt) && type !== void 0 && type !== "webhook") {
51834
+ throw expected("Only a webhook trigger takes a signing secret: omit --secret-stdin and --secret-prompt. Nothing was read or stored.");
51835
+ }
51836
+ const base = requireBase(this);
51837
+ const client = await createDataClient();
51838
+ await createHolder(client, TRIGGER_SIGNING_SECRET, base, opts.id ?? randomUUID3(), body, opts, outputFormat(this));
51839
+ });
51840
+ triggers.command("get <id>").description("Get a trigger").action(async function(id) {
51841
+ const base = pathSegment(requireBase(this), "--base");
51842
+ const client = await createDataClient();
51843
+ printOutput(await client.request("GET", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`), outputFormat(this));
51844
+ });
51845
+ triggers.command("list").description("List all triggers").action(async function() {
51846
+ const base = pathSegment(requireBase(this), "--base");
51847
+ const client = await createDataClient();
51848
+ printOutput(await client.request("GET", `/v1/${base}/triggers`), outputFormat(this));
51849
+ });
51850
+ triggers.command("deliveries").description("List trigger delivery attempts (status, retries, errors)").option("--status <status>", "Filter by status (pending | delivered | failed | dead)").option("--trigger-id <id>", "Filter by trigger id").action(async function(opts) {
51851
+ const base = pathSegment(requireBase(this), "--base");
51852
+ const client = await createDataClient();
51853
+ const params = new URLSearchParams();
51854
+ if (opts.status) params.set("status", opts.status);
51855
+ if (opts.triggerId) params.set("trigger_id", opts.triggerId);
51856
+ const qs = params.toString();
51857
+ printOutput(
51858
+ await client.request("GET", `/v1/${base}/triggers/deliveries${qs ? `?${qs}` : ""}`),
51859
+ outputFormat(this)
51860
+ );
51861
+ });
51862
+ triggers.command("delete <id>").description("Delete a trigger").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
51863
+ if (!opts.yes && !await confirm(`Delete trigger ${id}? This cannot be undone.`)) {
51864
+ console.log("Aborted");
51865
+ return;
51866
+ }
51867
+ const base = pathSegment(requireBase(this), "--base");
51868
+ const client = await createDataClient();
51869
+ await client.request("DELETE", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`);
51870
+ console.log("Deleted");
51871
+ });
51872
+ addSecretCommands(triggers, TRIGGER_SIGNING_SECRET);
51873
+ return triggers;
51874
+ }
51875
+ var init_triggers = __esm({
51876
+ "src/data/commands/triggers.ts"() {
51877
+ "use strict";
51878
+ init_expected();
51879
+ init_client();
51880
+ init_output();
51881
+ init_helpers();
51882
+ init_utils();
51883
+ init_webhook_secrets();
51884
+ }
51885
+ });
51886
+
51693
51887
  // src/data/program.ts
51694
51888
  var program_exports = {};
51695
51889
  __export(program_exports, {