@wayai/cli 0.3.357 → 0.3.359

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"() {
@@ -5424,7 +5530,7 @@ function normalizeAuthType(raw) {
5424
5530
  function isCustomerFacingAgentRole(role) {
5425
5531
  return typeof role === "string" && CUSTOMER_FACING_AGENT_ROLES.includes(role);
5426
5532
  }
5427
- var AUTH_TYPE, ORG_CREDENTIAL_AUTH_TYPES, AUTH_TYPE_DISPLAY, LEGACY_AUTH_TYPE_MAP, VALID_AUTH_TYPES, AGENT_ROLES, PILOT_TRACK_ROLES, COPILOT_TRACK_ROLES, CUSTOMER_FACING_AGENT_ROLES, AGENT_ROLE_DISPLAY, SAFE_USER_ID_REGEX, SUPPORTED_LOCALES, SKILL_INSTALL_COMMAND, CASE_TYPE_ABBREVIATION_PATTERN;
5533
+ var AUTH_TYPE, ORG_CREDENTIAL_AUTH_TYPES, AUTH_TYPE_DISPLAY, LEGACY_AUTH_TYPE_MAP, VALID_AUTH_TYPES, AGENT_ROLES, PILOT_TRACK_ROLES, COPILOT_TRACK_ROLES, CUSTOMER_FACING_AGENT_ROLES, AGENT_ROLE_DISPLAY, AI_MODES, SAFE_USER_ID_REGEX, SUPPORTED_LOCALES, SKILL_INSTALL_COMMAND, CASE_TYPE_ABBREVIATION_PATTERN;
5428
5534
  var init_chunk_ZTNFLGW5 = __esm({
5429
5535
  "../../packages/core/dist/chunk-ZTNFLGW5.js"() {
5430
5536
  "use strict";
@@ -5488,6 +5594,7 @@ var init_chunk_ZTNFLGW5 = __esm({
5488
5594
  consultant: "Consultant",
5489
5595
  pilot_voice: "Pilot Voice"
5490
5596
  };
5597
+ AI_MODES = ["pilot", "copilot", "pilot+copilot", "turned_off"];
5491
5598
  SAFE_USER_ID_REGEX = /^[A-Za-z0-9_-]{1,64}$/;
5492
5599
  SUPPORTED_LOCALES = ["en", "pt", "es"];
5493
5600
  SKILL_INSTALL_COMMAND = "mkdir -p .claude && npx skills add wayai-pro/wayai-skill -y";
@@ -5642,38 +5749,6 @@ var init_chunk_YVY2TZK2 = __esm({
5642
5749
  }
5643
5750
  });
5644
5751
 
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
5752
  // ../../packages/core/dist/chunk-HIGKBEPF.js
5678
5753
  var accessExplainQuery;
5679
5754
  var init_chunk_HIGKBEPF = __esm({
@@ -6265,77 +6340,98 @@ var init_chunk_WONSSUXU = __esm({
6265
6340
  }
6266
6341
  });
6267
6342
 
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"() {
6343
+ // ../../packages/core/dist/chunk-KEN2DASI.js
6344
+ var SECOND_FACTOR_TIERS, secondFactorTier, META_ENTITY_ID_PATTERN, metaEntityId, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, normalizeEmail, REVIEW_ACCOUNT_EMAILS;
6345
+ var init_chunk_KEN2DASI = __esm({
6346
+ "../../packages/core/dist/chunk-KEN2DASI.js"() {
6272
6347
  "use strict";
6273
- init_chunk_6TSQ5HXC();
6274
6348
  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()
6349
+ SECOND_FACTOR_TIERS = ["off", "settings"];
6350
+ secondFactorTier = external_exports.enum(SECOND_FACTOR_TIERS);
6351
+ META_ENTITY_ID_PATTERN = /^\d{1,32}$/;
6352
+ metaEntityId = external_exports.string().regex(META_ENTITY_ID_PATTERN, "must be a numeric Meta entity id");
6353
+ whatsappCallbackBody = external_exports.object({
6354
+ state: external_exports.string().min(1, "state is required"),
6355
+ code: external_exports.string().optional(),
6356
+ access_token: external_exports.string().optional(),
6357
+ user_id: external_exports.string().optional(),
6358
+ /**
6359
+ * The phone number and WABA the operator actually picked in Meta's Embedded
6360
+ * Signup popup (posted to the opener as `WA_EMBEDDED_SIGNUP`). Optional:
6361
+ * older clients, and the redirect-based flow, never see that event and fall
6362
+ * back to discovery.
6363
+ */
6364
+ phone_number_id: metaEntityId.optional(),
6365
+ waba_id: metaEntityId.optional()
6366
+ }).refine(
6367
+ (data) => !!data.access_token || !!data.code,
6368
+ { message: "Missing required parameters: state and either access_token or code" }
6369
+ );
6370
+ authMeResponse = external_exports.object({
6371
+ user_id: external_exports.string(),
6372
+ email: external_exports.string(),
6373
+ org_id: external_exports.string().nullable(),
6374
+ is_platform_admin: external_exports.boolean()
6290
6375
  });
6291
- listOverridesQuery = external_exports.object({
6292
- hub_id: external_exports.string().uuid(),
6293
- variant_id: external_exports.string().uuid()
6376
+ wsTicketResponse = external_exports.object({
6377
+ ticket: external_exports.string(),
6378
+ /** Seconds until the ticket expires if unconsumed. */
6379
+ expires_in: external_exports.number()
6294
6380
  });
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()
6381
+ sessionCheckResponse = external_exports.object({
6382
+ valid: external_exports.literal(true)
6299
6383
  });
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")
6384
+ logoutResponse = external_exports.object({
6385
+ success: external_exports.literal(true)
6306
6386
  });
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()
6387
+ magicCodeSendBody = external_exports.object({
6388
+ email: external_exports.string().email("Invalid email").max(254)
6389
+ // RFC 5321 max; bounds the request payload
6312
6390
  });
6313
- setExperimentStatusBody = external_exports.object({
6314
- status: experimentStatusSchema
6391
+ magicCodeSendResponse = external_exports.object({
6392
+ success: external_exports.literal(true)
6315
6393
  });
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)
6394
+ magicCodeVerifyBody = external_exports.object({
6395
+ email: external_exports.string().email("Invalid email").max(254),
6396
+ // RFC 5321 max; bounds the request payload
6397
+ code: external_exports.string().min(1, "Code is required").max(12)
6398
+ // WorkOS sends a 6-digit code; bound the input
6323
6399
  });
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()
6400
+ magicCodeVerifyResponse = external_exports.object({
6401
+ access_token: external_exports.string(),
6402
+ refresh_token: external_exports.string()
6329
6403
  });
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
6404
+ passwordLoginBody = external_exports.object({
6405
+ email: external_exports.string().email("Invalid email").max(254),
6406
+ // RFC 5321 max; bounds the request payload
6407
+ password: external_exports.string().min(1, "Password is required").max(128)
6408
+ // bound the payload; WorkOS validates
6338
6409
  });
6410
+ normalizeEmail = (email) => email.trim().toLowerCase();
6411
+ REVIEW_ACCOUNT_EMAILS = new Set(
6412
+ ["apple.review@wayai.pro", "play.review@wayai.pro", "microsoft.review@wayai.pro", "meta.review@wayai.pro"].map(
6413
+ normalizeEmail
6414
+ )
6415
+ );
6416
+ }
6417
+ });
6418
+
6419
+ // ../../packages/core/dist/chunk-PFGVH2CX.js
6420
+ var secondFactorCode, secondFactorRecoveryCode, secondFactorCodeBody, secondFactorRecoveryBody, secondFactorDisableBody, setOrgSecondFactorBody;
6421
+ var init_chunk_PFGVH2CX = __esm({
6422
+ "../../packages/core/dist/chunk-PFGVH2CX.js"() {
6423
+ "use strict";
6424
+ init_chunk_KEN2DASI();
6425
+ init_zod();
6426
+ secondFactorCode = external_exports.string().regex(/^\d{6}$/, "Enter the 6-digit code");
6427
+ secondFactorRecoveryCode = external_exports.string().min(1, "Enter a recovery code").max(64);
6428
+ secondFactorCodeBody = external_exports.object({ code: secondFactorCode });
6429
+ secondFactorRecoveryBody = external_exports.object({ recovery_code: secondFactorRecoveryCode });
6430
+ secondFactorDisableBody = external_exports.union([
6431
+ external_exports.object({ code: secondFactorCode, recovery_code: external_exports.undefined().optional() }),
6432
+ external_exports.object({ recovery_code: secondFactorRecoveryCode, code: external_exports.undefined().optional() })
6433
+ ]);
6434
+ setOrgSecondFactorBody = external_exports.object({ tier: secondFactorTier });
6339
6435
  }
6340
6436
  });
6341
6437
 
@@ -7608,101 +7704,6 @@ var init_chunk_IPDOHAZ5 = __esm({
7608
7704
  }
7609
7705
  });
7610
7706
 
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
7707
  // ../../packages/core/dist/chunk-FPSDNS2E.js
7707
7708
  var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
7708
7709
  var init_chunk_FPSDNS2E = __esm({
@@ -8247,6 +8248,370 @@ var init_chunk_Y7CFCYX4 = __esm({
8247
8248
  }
8248
8249
  });
8249
8250
 
8251
+ // ../../packages/core/dist/chunk-ZIGA5RCU.js
8252
+ var BINDING_EACH_MAX_ITEMS, BINDING_TEXT_MAX_OUTPUT, BINDING_ROOTS, BINDING_NAME_SEGMENT_REGEX;
8253
+ var init_chunk_ZIGA5RCU = __esm({
8254
+ "../../packages/core/dist/chunk-ZIGA5RCU.js"() {
8255
+ "use strict";
8256
+ BINDING_EACH_MAX_ITEMS = 100;
8257
+ BINDING_TEXT_MAX_OUTPUT = 16 * 1024;
8258
+ BINDING_ROOTS = ["params", "state", "data", "form", "item", "this"];
8259
+ BINDING_NAME_SEGMENT_REGEX = /^[A-Za-z_][A-Za-z0-9_-]*$/;
8260
+ }
8261
+ });
8262
+
8263
+ // ../../packages/core/dist/chunk-BGNWWR6B.js
8264
+ 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;
8265
+ var init_chunk_BGNWWR6B = __esm({
8266
+ "../../packages/core/dist/chunk-BGNWWR6B.js"() {
8267
+ "use strict";
8268
+ init_chunk_ZIGA5RCU();
8269
+ init_chunk_6TSQ5HXC();
8270
+ init_chunk_WEXVYJ5H();
8271
+ init_chunk_HZ6CADSY();
8272
+ init_zod();
8273
+ INTERACTIVE_TEMPLATE_MAX_CHARS = 64 * 1024;
8274
+ INTERACTIVE_TEMPLATE_MAX_BLOCKS = 200;
8275
+ INTERACTIVE_TEMPLATE_MAX_ACTIONS = 30;
8276
+ INTERACTIVE_TEMPLATE_TEXT_MAX = 2e3;
8277
+ INTERACTIVE_TEMPLATE_FALLBACK_MAX = 4e3;
8278
+ INTERACTIVE_TEMPLATE_DESCRIPTION_MAX = 500;
8279
+ INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS = 16 * 1024;
8280
+ INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS = 4 * 1024;
8281
+ INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX = 20;
8282
+ INTERACTIVE_TEMPLATE_OPTIONS_MAX = 50;
8283
+ PATH_MAX = 256;
8284
+ TOOL_NAME_MAX = 128;
8285
+ interactiveTemplateNameSchema = external_exports.string().regex(SLUG_REGEX, {
8286
+ message: 'a template name is lowercase letters, digits and underscores, starting with a letter (e.g. "menu")'
8287
+ });
8288
+ actionNameSchema = external_exports.string().regex(SLUG_REGEX, {
8289
+ message: "an action name is lowercase letters, digits and underscores, starting with a letter"
8290
+ });
8291
+ INTERACTIVE_TEMPLATE_FIELD_NAME_REGEX = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
8292
+ RESERVED_FIELD_NAMES = new Set(BINDING_ROOTS);
8293
+ TEMPLATE_TONES = ["default", "secondary", "success", "danger", "warning", "info"];
8294
+ TEMPLATE_INPUT_TYPES = ["text", "number", "email", "tel", "date"];
8295
+ TEMPLATE_ALIGNS = ["start", "center", "end", "stretch"];
8296
+ TEMPLATE_JUSTIFIES = ["start", "center", "end", "between"];
8297
+ TEMPLATE_TITLE_SIZES = ["sm", "md", "lg"];
8298
+ TEMPLATE_TEXT_SIZES = ["xs", "sm", "md", "lg"];
8299
+ TEMPLATE_TEXT_WEIGHTS = ["normal", "medium", "bold"];
8300
+ TEMPLATE_BADGE_VARIANTS = ["solid", "soft", "outline"];
8301
+ TEMPLATE_BUTTON_STYLES = ["primary", "secondary"];
8302
+ TEMPLATE_LIST_DIRECTIONS = ["vertical", "horizontal"];
8303
+ text = external_exports.string().max(INTERACTIVE_TEMPLATE_TEXT_MAX);
8304
+ label = text.min(1);
8305
+ path2 = external_exports.string().min(1).max(PATH_MAX);
8306
+ binding = external_exports.string().min(1).max(PATH_MAX);
8307
+ common = { if: path2.optional() };
8308
+ fieldCommon = {
8309
+ ...common,
8310
+ name: label,
8311
+ label: text.optional(),
8312
+ required: external_exports.union([external_exports.boolean(), binding]).optional(),
8313
+ source: text.optional()
8314
+ };
8315
+ children = () => external_exports.array(blockSchema).min(1).max(INTERACTIVE_TEMPLATE_MAX_BLOCKS);
8316
+ containerProps = () => ({
8317
+ gap: external_exports.number().int().min(0).max(8).optional(),
8318
+ align: external_exports.enum(TEMPLATE_ALIGNS).optional(),
8319
+ justify: external_exports.enum(TEMPLATE_JUSTIFIES).optional()
8320
+ });
8321
+ optionSchema = external_exports.object({ value: text, label }).strict();
8322
+ templateBlockSchema = external_exports.lazy(
8323
+ () => external_exports.discriminatedUnion("type", [
8324
+ external_exports.object({ ...common, type: external_exports.literal("card"), children: children() }).strict(),
8325
+ external_exports.object({ ...common, ...containerProps(), type: external_exports.literal("row"), children: children() }).strict(),
8326
+ external_exports.object({ ...common, ...containerProps(), type: external_exports.literal("col"), children: children() }).strict(),
8327
+ external_exports.object({
8328
+ ...common,
8329
+ type: external_exports.literal("list"),
8330
+ each: path2,
8331
+ item: blockSchema,
8332
+ direction: external_exports.enum(TEMPLATE_LIST_DIRECTIONS).optional(),
8333
+ limit: external_exports.number().int().min(1).max(BINDING_EACH_MAX_ITEMS).optional(),
8334
+ key: external_exports.string().max(64).regex(BINDING_NAME_SEGMENT_REGEX).optional(),
8335
+ empty: text.optional()
8336
+ }).strict(),
8337
+ external_exports.object({ ...common, type: external_exports.literal("image"), src: label, alt: text.optional() }).strict(),
8338
+ external_exports.object({ ...common, type: external_exports.literal("title"), text: label, size: external_exports.enum(TEMPLATE_TITLE_SIZES).optional() }).strict(),
8339
+ external_exports.object({
8340
+ ...common,
8341
+ type: external_exports.literal("text"),
8342
+ text: label,
8343
+ size: external_exports.enum(TEMPLATE_TEXT_SIZES).optional(),
8344
+ weight: external_exports.enum(TEMPLATE_TEXT_WEIGHTS).optional(),
8345
+ color: external_exports.enum(TEMPLATE_TONES).optional()
8346
+ }).strict(),
8347
+ external_exports.object({
8348
+ ...common,
8349
+ type: external_exports.literal("badge"),
8350
+ text: label,
8351
+ color: external_exports.enum(TEMPLATE_TONES).optional(),
8352
+ variant: external_exports.enum(TEMPLATE_BADGE_VARIANTS).optional()
8353
+ }).strict(),
8354
+ external_exports.object({ ...common, type: external_exports.literal("divider") }).strict(),
8355
+ external_exports.object({
8356
+ ...common,
8357
+ type: external_exports.literal("button"),
8358
+ label,
8359
+ action: actionNameSchema,
8360
+ style: external_exports.enum(TEMPLATE_BUTTON_STYLES).optional()
8361
+ }).strict(),
8362
+ external_exports.object({
8363
+ ...fieldCommon,
8364
+ type: external_exports.literal("select"),
8365
+ options: external_exports.union([external_exports.array(optionSchema).min(1).max(INTERACTIVE_TEMPLATE_OPTIONS_MAX), binding]),
8366
+ placeholder: text.optional(),
8367
+ default_value: text.optional()
8368
+ }).strict(),
8369
+ external_exports.object({
8370
+ ...fieldCommon,
8371
+ type: external_exports.literal("input"),
8372
+ input_type: external_exports.union([external_exports.enum(TEMPLATE_INPUT_TYPES), binding]).optional(),
8373
+ placeholder: text.optional(),
8374
+ default_value: text.optional()
8375
+ }).strict(),
8376
+ external_exports.object({
8377
+ ...fieldCommon,
8378
+ type: external_exports.literal("checkbox"),
8379
+ label,
8380
+ default_checked: external_exports.union([external_exports.boolean(), binding]).optional()
8381
+ }).strict(),
8382
+ external_exports.object({
8383
+ ...common,
8384
+ type: external_exports.literal("form"),
8385
+ children: children(),
8386
+ submit: actionNameSchema,
8387
+ submit_label: text.optional()
8388
+ }).strict()
8389
+ ])
8390
+ );
8391
+ blockSchema = templateBlockSchema;
8392
+ unanchored = (regex) => regex.source.replace(/^\^/, "").replace(/\$$/, "");
8393
+ INTERACTIVE_TEMPLATE_STATE_PATH_REGEX = new RegExp(
8394
+ `^state\\.${unanchored(SLUG_REGEX)}(\\.${unanchored(BINDING_NAME_SEGMENT_REGEX)}){0,10}$`
8395
+ );
8396
+ valueTemplate = external_exports.unknown().superRefine((value, ctx) => {
8397
+ if (!withinJsonLength(value, INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS)) {
8398
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `a value is JSON of at most ${INTERACTIVE_TEMPLATE_VALUE_MAX_CHARS} characters` });
8399
+ }
8400
+ });
8401
+ statePath = external_exports.string().regex(INTERACTIVE_TEMPLATE_STATE_PATH_REGEX, {
8402
+ message: 'a state path is "state.<state slug>" then field names (e.g. "state.order.items")'
8403
+ });
8404
+ templateActionSchema = external_exports.discriminatedUnion("type", [
8405
+ external_exports.object({ type: external_exports.literal("send"), text: label.optional(), values: valueTemplate.optional() }).strict(),
8406
+ external_exports.object({ type: external_exports.literal("set_state"), path: statePath, value: valueTemplate }).strict(),
8407
+ external_exports.object({ type: external_exports.literal("append_state"), path: statePath, value: valueTemplate }).strict(),
8408
+ external_exports.object({ type: external_exports.literal("remove_state"), path: statePath, value: valueTemplate }).strict()
8409
+ ]).superRefine((action, ctx) => {
8410
+ if (action.type === "send" && action.text === void 0 && action.values === void 0) {
8411
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "a send action has text, values, or both" });
8412
+ }
8413
+ });
8414
+ paramsJsonSchema = external_exports.record(external_exports.unknown()).superRefine((schema, ctx) => {
8415
+ if (!withinJsonLength(schema, INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS)) {
8416
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `params is at most ${INTERACTIVE_TEMPLATE_PARAMS_SCHEMA_MAX_CHARS} characters of JSON` });
8417
+ return;
8418
+ }
8419
+ const result = validateToolInputSchema(schema);
8420
+ if (!result.ok) {
8421
+ for (const error of result.errors) {
8422
+ ctx.addIssue({
8423
+ code: external_exports.ZodIssueCode.custom,
8424
+ message: `params is not a valid JSON Schema${error.path ? ` at "${error.path}"` : ""}: ${error.message}`
8425
+ });
8426
+ }
8427
+ }
8428
+ });
8429
+ dataSchema = external_exports.object({
8430
+ /** The tool's name, as the agent holds it. The backend calls it; the model never types its data. */
8431
+ tool: external_exports.string().trim().min(1).max(TOOL_NAME_MAX),
8432
+ params: external_exports.union([
8433
+ external_exports.array(external_exports.string()).max(INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX),
8434
+ external_exports.record(valueTemplate).refine((r) => Object.keys(r).length <= INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX, {
8435
+ message: `data.params passes at most ${INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX} values`
8436
+ })
8437
+ ]).default({}).transform(
8438
+ (params) => Array.isArray(params) ? Object.fromEntries(params.map((name) => [name, `{{params.${name}}}`])) : params
8439
+ ),
8440
+ /** The result's top-level fields the template reads: what the message's data snapshot keeps. */
8441
+ fields: external_exports.array(external_exports.string().max(64).regex(BINDING_NAME_SEGMENT_REGEX)).min(1).max(INTERACTIVE_TEMPLATE_DATA_FIELDS_MAX)
8442
+ }).strict();
8443
+ interactiveTemplateDefinitionSchema = external_exports.object({
8444
+ name: interactiveTemplateNameSchema,
8445
+ description: external_exports.string().trim().min(1).max(INTERACTIVE_TEMPLATE_DESCRIPTION_MAX),
8446
+ params: paramsJsonSchema.default({ type: "object", properties: {} }),
8447
+ data: dataSchema.optional(),
8448
+ /** Phase 1: the one view, `main`. Phase 1b adds others beside it. */
8449
+ views: external_exports.object({ main: blockSchema }).strict(),
8450
+ actions: external_exports.record(actionNameSchema, templateActionSchema).default({}).refine((actions) => Object.keys(actions).length <= INTERACTIVE_TEMPLATE_MAX_ACTIONS, {
8451
+ message: `at most ${INTERACTIVE_TEMPLATE_MAX_ACTIONS} actions`
8452
+ }),
8453
+ fallback: external_exports.string().trim().min(1).max(INTERACTIVE_TEMPLATE_FALLBACK_MAX)
8454
+ }).strict();
8455
+ }
8456
+ });
8457
+
8458
+ // ../../packages/core/dist/chunk-2ZZZHXZR.js
8459
+ var OPTION_ITEM, choices, form;
8460
+ var init_chunk_2ZZZHXZR = __esm({
8461
+ "../../packages/core/dist/chunk-2ZZZHXZR.js"() {
8462
+ "use strict";
8463
+ init_chunk_BGNWWR6B();
8464
+ OPTION_ITEM = {
8465
+ type: "object",
8466
+ properties: {
8467
+ id: { type: "string", description: "What the agent receives when this one is picked" },
8468
+ label: { type: "string", description: "What the person sees" }
8469
+ },
8470
+ required: ["id", "label"]
8471
+ };
8472
+ choices = {
8473
+ name: "choices",
8474
+ description: "A question with up to 10 options, each with an optional description. The person picks one; the agent receives its id and label.",
8475
+ params: {
8476
+ type: "object",
8477
+ properties: {
8478
+ prompt: { type: "string", description: "The question, shown above the options" },
8479
+ options: {
8480
+ type: "array",
8481
+ minItems: 1,
8482
+ maxItems: 10,
8483
+ items: {
8484
+ ...OPTION_ITEM,
8485
+ properties: { ...OPTION_ITEM.properties, description: { type: "string", description: "A line under the label" } }
8486
+ }
8487
+ }
8488
+ },
8489
+ required: ["options"]
8490
+ },
8491
+ views: {
8492
+ main: {
8493
+ type: "card",
8494
+ children: [
8495
+ { type: "text", if: "params.prompt", text: "{{params.prompt}}" },
8496
+ {
8497
+ type: "list",
8498
+ each: "params.options",
8499
+ item: {
8500
+ type: "col",
8501
+ gap: 1,
8502
+ children: [
8503
+ { type: "button", label: "{{item.label}}", action: "choose" },
8504
+ { type: "text", if: "item.description", text: "{{item.description}}", size: "sm", color: "secondary" }
8505
+ ]
8506
+ }
8507
+ }
8508
+ ]
8509
+ }
8510
+ },
8511
+ actions: {
8512
+ choose: { type: "send", text: "{{item.label}}", values: { id: "{{item.id}}" } }
8513
+ },
8514
+ fallback: "{{#if params.prompt}}{{params.prompt}}\n{{/if}}{{#each params.options}}{{@n}}. {{label}}{{#if description}} \u2014 {{description}}{{/if}}\n{{/each}}"
8515
+ };
8516
+ form = {
8517
+ name: "form",
8518
+ 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.",
8519
+ params: {
8520
+ type: "object",
8521
+ properties: {
8522
+ title: { type: "string", description: "Shown above the fields" },
8523
+ submit_label: { type: "string", description: "The submit button's label" },
8524
+ fields: {
8525
+ type: "array",
8526
+ minItems: 1,
8527
+ maxItems: 20,
8528
+ items: {
8529
+ type: "object",
8530
+ properties: {
8531
+ name: { type: "string", pattern: INTERACTIVE_TEMPLATE_FIELD_NAME_REGEX.source, description: "The key the value is submitted under" },
8532
+ label: { type: "string" },
8533
+ input: {
8534
+ type: "string",
8535
+ enum: [...TEMPLATE_INPUT_TYPES],
8536
+ description: "A text input of this type. Give exactly one of input, select or checkbox."
8537
+ },
8538
+ select: { type: "array", minItems: 1, maxItems: INTERACTIVE_TEMPLATE_OPTIONS_MAX, items: { type: "object", properties: { value: { type: "string" }, label: { type: "string" } }, required: ["value", "label"] } },
8539
+ checkbox: { type: "boolean", enum: [true] },
8540
+ value: { type: ["string", "number", "boolean"], description: "The pre-filled value (a checkbox: true when checked)" },
8541
+ placeholder: { type: "string" },
8542
+ required: { type: "boolean" },
8543
+ source: { type: "string", description: "Where the pre-filled value came from, shown under the field" }
8544
+ },
8545
+ required: ["name", "label"],
8546
+ oneOf: [{ required: ["input"] }, { required: ["select"] }, { required: ["checkbox"] }]
8547
+ }
8548
+ }
8549
+ },
8550
+ required: ["fields"]
8551
+ },
8552
+ views: {
8553
+ main: {
8554
+ type: "card",
8555
+ children: [
8556
+ { type: "title", if: "params.title", text: "{{params.title}}" },
8557
+ {
8558
+ type: "form",
8559
+ submit: "submit",
8560
+ submit_label: "{{params.submit_label}}",
8561
+ children: [
8562
+ {
8563
+ type: "list",
8564
+ each: "params.fields",
8565
+ item: {
8566
+ type: "col",
8567
+ children: [
8568
+ {
8569
+ type: "input",
8570
+ if: "item.input",
8571
+ name: "{{item.name}}",
8572
+ label: "{{item.label}}",
8573
+ input_type: "{{item.input}}",
8574
+ placeholder: "{{item.placeholder}}",
8575
+ default_value: "{{item.value}}",
8576
+ required: "{{item.required}}",
8577
+ source: "{{item.source}}"
8578
+ },
8579
+ {
8580
+ type: "select",
8581
+ if: "item.select",
8582
+ name: "{{item.name}}",
8583
+ label: "{{item.label}}",
8584
+ options: "{{item.select}}",
8585
+ placeholder: "{{item.placeholder}}",
8586
+ default_value: "{{item.value}}",
8587
+ required: "{{item.required}}",
8588
+ source: "{{item.source}}"
8589
+ },
8590
+ {
8591
+ type: "checkbox",
8592
+ if: "item.checkbox",
8593
+ name: "{{item.name}}",
8594
+ label: "{{item.label}}",
8595
+ default_checked: "{{item.value}}",
8596
+ required: "{{item.required}}",
8597
+ source: "{{item.source}}"
8598
+ }
8599
+ ]
8600
+ }
8601
+ }
8602
+ ]
8603
+ }
8604
+ ]
8605
+ }
8606
+ },
8607
+ actions: {
8608
+ submit: { type: "send", values: "{{form}}" }
8609
+ },
8610
+ fallback: "{{#if params.title}}{{params.title}}\n{{/if}}{{#each params.fields}}- {{label}}{{#if value}}: {{value}}{{/if}}\n{{/each}}"
8611
+ };
8612
+ }
8613
+ });
8614
+
8250
8615
  // ../../packages/core/dist/chunk-YUZFHVB2.js
8251
8616
  var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
8252
8617
  var init_chunk_YUZFHVB2 = __esm({
@@ -8693,6 +9058,32 @@ var init_chunk_34LE6P7E = __esm({
8693
9058
  }
8694
9059
  });
8695
9060
 
9061
+ // ../../packages/core/dist/chunk-C4HEZ7ZI.js
9062
+ var downloadBody, uploadQuery, SIGN_URL_MAX_EXPIRES_IN_SECONDS, signUrlBody;
9063
+ var init_chunk_C4HEZ7ZI = __esm({
9064
+ "../../packages/core/dist/chunk-C4HEZ7ZI.js"() {
9065
+ "use strict";
9066
+ init_chunk_CJ3L46X6();
9067
+ init_zod();
9068
+ downloadBody = external_exports.object({
9069
+ type: external_exports.enum(["workspace", "agent_instructions"]),
9070
+ agent_id: external_exports.string().uuid().optional(),
9071
+ organization_name: external_exports.string().optional()
9072
+ });
9073
+ uploadQuery = external_exports.object({
9074
+ type: external_exports.enum(["agent_instructions"]),
9075
+ agent_id: external_exports.string().uuid(),
9076
+ hub_id: external_exports.string().uuid()
9077
+ });
9078
+ SIGN_URL_MAX_EXPIRES_IN_SECONDS = 3600;
9079
+ signUrlBody = external_exports.object({
9080
+ bucket: external_exports.string(),
9081
+ filePath: external_exports.string(),
9082
+ expiresIn: external_exports.number().int().positive().max(SIGN_URL_MAX_EXPIRES_IN_SECONDS).optional()
9083
+ });
9084
+ }
9085
+ });
9086
+
8696
9087
  // ../../packages/core/dist/chunk-IR2NOSI3.js
8697
9088
  var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
8698
9089
  var init_chunk_IR2NOSI3 = __esm({
@@ -8807,367 +9198,21 @@ var init_chunk_SY6PLCPK = __esm({
8807
9198
  }
8808
9199
  });
8809
9200
 
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"() {
9201
+ // ../../packages/core/dist/chunk-ACGAI25T.js
9202
+ var listPendingSchedulesQuery, listHubAggregateSchedulesQuery;
9203
+ var init_chunk_ACGAI25T = __esm({
9204
+ "../../packages/core/dist/chunk-ACGAI25T.js"() {
8826
9205
  "use strict";
8827
- init_chunk_ZIGA5RCU();
8828
- init_chunk_6TSQ5HXC();
8829
- init_chunk_WEXVYJ5H();
8830
- init_chunk_HZ6CADSY();
8831
9206
  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
- }
9207
+ listPendingSchedulesQuery = external_exports.object({
9208
+ hub_id: external_exports.string().uuid(),
9209
+ conversation_id: external_exports.string().uuid().optional(),
9210
+ user_id: external_exports.string().optional()
8972
9211
  });
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
- }
9212
+ listHubAggregateSchedulesQuery = external_exports.object({
9213
+ hub_id: external_exports.string().uuid(),
9214
+ limit: external_exports.coerce.number().int().min(1).max(1e3).optional()
8987
9215
  });
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
9216
  }
9172
9217
  });
9173
9218
 
@@ -12753,28 +12798,14 @@ var init_chunk_LX3D5LCB = __esm({
12753
12798
  }
12754
12799
  });
12755
12800
 
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"() {
12801
+ // ../../packages/core/dist/chunk-JDJ4EUOL.js
12802
+ var clickhouseReadyResponse;
12803
+ var init_chunk_JDJ4EUOL = __esm({
12804
+ "../../packages/core/dist/chunk-JDJ4EUOL.js"() {
12760
12805
  "use strict";
12761
- init_chunk_CJ3L46X6();
12762
12806
  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()
12807
+ clickhouseReadyResponse = external_exports.object({
12808
+ ready: external_exports.boolean()
12778
12809
  });
12779
12810
  }
12780
12811
  });
@@ -12864,24 +12895,6 @@ var init_chunk_LWMLR2WI = __esm({
12864
12895
  }
12865
12896
  });
12866
12897
 
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
12898
  // ../../packages/core/dist/chunk-YR7QALGP.js
12886
12899
  var CASE_SUBMISSION_ISSUED_KINDS, CASE_SUBMISSION_RENDER_STUCK_MS, CASE_SUBMISSION_MARK_ID_PATTERN, CASE_CORRECTION_REASON_MAX_LENGTH, submitCaseBody, correctCaseSubmissionBody, caseDeliveryQuery;
12887
12900
  var init_chunk_YR7QALGP = __esm({
@@ -13266,7 +13279,7 @@ var init_chunk_2ISUBJG7 = __esm({
13266
13279
  }
13267
13280
  });
13268
13281
 
13269
- // ../../packages/core/dist/chunk-PCQIFFYO.js
13282
+ // ../../packages/core/dist/chunk-5YZ3R7KF.js
13270
13283
  function describeRole(role) {
13271
13284
  if (typeof role === "string") {
13272
13285
  return JSON.stringify(role.length > ROLE_ECHO_MAX ? `${role.slice(0, ROLE_ECHO_MAX)}\u2026` : role);
@@ -13445,11 +13458,11 @@ function terminalRunCount(counts) {
13445
13458
  return counts.successful_runs + counts.failed_runs;
13446
13459
  }
13447
13460
  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"() {
13461
+ var init_chunk_5YZ3R7KF = __esm({
13462
+ "../../packages/core/dist/chunk-5YZ3R7KF.js"() {
13450
13463
  "use strict";
13451
- init_chunk_AHISKXHA();
13452
13464
  init_chunk_2YEGUQR7();
13465
+ init_chunk_AHISKXHA();
13453
13466
  init_chunk_4LXDRTO4();
13454
13467
  init_chunk_AMMLEB4T();
13455
13468
  init_chunk_2ISUBJG7();
@@ -13863,7 +13876,7 @@ var init_chunk_D3EP4TDU = __esm({
13863
13876
  }
13864
13877
  });
13865
13878
 
13866
- // ../../packages/core/dist/chunk-X5PZZVTS.js
13879
+ // ../../packages/core/dist/chunk-JP42Y3U2.js
13867
13880
  function isEventRelativeFollowupType(type) {
13868
13881
  return typeof type === "string" && EVENT_RELATIVE_FOLLOWUP_TYPES.includes(type);
13869
13882
  }
@@ -13956,9 +13969,9 @@ function validateLaneReferences(lanes, statuses) {
13956
13969
  });
13957
13970
  return issues;
13958
13971
  }
13959
- var MAX_KANBAN_STATUSES, MAX_FOLLOWUPS_PER_STATUS, MAX_LANES, MAX_ADDITIONAL_CONTEXT_SCHEMA_BYTES, RESERVED_TEMPLATE_DUMP_NAME, kanbanStatusSlugSchema, followupTypeSchema, EVENT_RELATIVE_FOLLOWUP_TYPES, followupTimeUnitSchema, followupIdSchema, SELECTABLE_FOLLOWUP_TYPES, MAX_LINKED_FOLLOWUP_TARGETS_PER_STATUS, followupSchema, MAX_OUTCOMES_PER_STATUS, kanbanOutcomeSchema, EXCLUSIVE_FLAG_PAIRS, kanbanStatusSchema, kanbanStatusesArraySchema, laneSchema, lanesArraySchema;
13960
- var init_chunk_X5PZZVTS = __esm({
13961
- "../../packages/core/dist/chunk-X5PZZVTS.js"() {
13972
+ var MAX_KANBAN_STATUSES, MAX_FOLLOWUPS_PER_STATUS, MAX_LANES, MAX_ADDITIONAL_CONTEXT_SCHEMA_BYTES, RESERVED_TEMPLATE_DUMP_NAME, kanbanStatusSlugSchema, followupTypeSchema, EVENT_RELATIVE_FOLLOWUP_TYPES, followupTimeUnitSchema, followupIdSchema, SELECTABLE_FOLLOWUP_TYPES, MAX_LINKED_FOLLOWUP_TARGETS_PER_STATUS, followupSchema, MAX_OUTCOMES_PER_STATUS, kanbanOutcomeSchema, EXCLUSIVE_FLAG_PAIRS, kanbanStatusSchema, kanbanStatusesArraySchema, laneSchema, lanesArraySchema, kanbanLintWarningSchema;
13973
+ var init_chunk_JP42Y3U2 = __esm({
13974
+ "../../packages/core/dist/chunk-JP42Y3U2.js"() {
13962
13975
  "use strict";
13963
13976
  init_chunk_6TSQ5HXC();
13964
13977
  init_chunk_HZ6CADSY();
@@ -14258,10 +14271,23 @@ var init_chunk_X5PZZVTS = __esm({
14258
14271
  }
14259
14272
  }
14260
14273
  });
14274
+ kanbanLintWarningSchema = external_exports.object({
14275
+ code: external_exports.enum([
14276
+ "unreachable",
14277
+ "placeholder_unresolved",
14278
+ "unused_lane",
14279
+ "no_eligible_outcome",
14280
+ "terminal_outcomes_all_restricted",
14281
+ "duplicate_followup_id"
14282
+ ]),
14283
+ slug: external_exports.string(),
14284
+ name: external_exports.string(),
14285
+ message: external_exports.string()
14286
+ });
14261
14287
  }
14262
14288
  });
14263
14289
 
14264
- // ../../packages/core/dist/chunk-PIZTARVG.js
14290
+ // ../../packages/core/dist/chunk-QT7R3TGR.js
14265
14291
  function byLocale(entry) {
14266
14292
  const shape = Object.fromEntries(SUPPORTED_LOCALES.map((locale) => [locale, entry.optional()]));
14267
14293
  return external_exports.object(shape).strict();
@@ -14271,9 +14297,9 @@ function writeField(map) {
14271
14297
  (value) => value && Object.keys(value).length === 0 ? null : value
14272
14298
  );
14273
14299
  }
14274
- var HUB_DISPLAY_NAME_MAX_CHARS, HUB_WELCOME_MESSAGE_MAX_CHARS, HUB_STARTER_QUESTIONS_MAX, HUB_STARTER_QUESTION_MAX_CHARS, displayName, welcomeMessage, starterQuestions, hubDisplayNamesSchema, hubWelcomeMessagesSchema, hubStarterQuestionsSchema, hubDisplayNamesField, hubWelcomeMessagesField, hubStarterQuestionsField, HUB_PRESENTATION_FIELDS, HUB_PRESENTATION_SCHEMAS;
14275
- var init_chunk_PIZTARVG = __esm({
14276
- "../../packages/core/dist/chunk-PIZTARVG.js"() {
14300
+ var HUB_DISPLAY_NAME_MAX_CHARS, HUB_WELCOME_MESSAGE_MAX_CHARS, HUB_STARTER_QUESTIONS_MAX, HUB_STARTER_QUESTION_MAX_CHARS, displayName, welcomeMessage, starterQuestions, hubDisplayNamesSchema, hubWelcomeMessagesSchema, hubStarterQuestionsSchema, hubDisplayNamesField, hubWelcomeMessagesField, hubStarterQuestionsField, HUB_PRESENTATION_FIELDS, hubPresentationColumnsSchema, HUB_PRESENTATION_SCHEMAS;
14301
+ var init_chunk_QT7R3TGR = __esm({
14302
+ "../../packages/core/dist/chunk-QT7R3TGR.js"() {
14277
14303
  "use strict";
14278
14304
  init_chunk_ZTNFLGW5();
14279
14305
  init_zod();
@@ -14291,6 +14317,11 @@ var init_chunk_PIZTARVG = __esm({
14291
14317
  hubWelcomeMessagesField = writeField(hubWelcomeMessagesSchema);
14292
14318
  hubStarterQuestionsField = writeField(hubStarterQuestionsSchema);
14293
14319
  HUB_PRESENTATION_FIELDS = ["display_names", "welcome_messages", "starter_questions"];
14320
+ hubPresentationColumnsSchema = external_exports.object({
14321
+ display_names: byLocale(external_exports.string()).nullable(),
14322
+ welcome_messages: byLocale(external_exports.string()).nullable(),
14323
+ starter_questions: byLocale(external_exports.array(external_exports.string())).nullable()
14324
+ });
14294
14325
  HUB_PRESENTATION_SCHEMAS = {
14295
14326
  display_names: hubDisplayNamesSchema,
14296
14327
  welcome_messages: hubWelcomeMessagesSchema,
@@ -14299,7 +14330,7 @@ var init_chunk_PIZTARVG = __esm({
14299
14330
  }
14300
14331
  });
14301
14332
 
14302
- // ../../packages/core/dist/chunk-ARK3766Q.js
14333
+ // ../../packages/core/dist/chunk-4NZTCAY5.js
14303
14334
  function refineLaneReferences(val, ctx) {
14304
14335
  const lanes = val.lanes;
14305
14336
  const statuses = val.kanban_statuses;
@@ -14322,14 +14353,15 @@ function describeSyncWarning(warning) {
14322
14353
  }
14323
14354
  return `${label3}: ${parts.join("; ")}. Promote the base so production's tools match the preview's.`;
14324
14355
  }
14325
- var hubIdParam, hubAdminIdParam, hubUserIdParam, hubAgentIdParam, hubIdentityIdParam, hubTeamIdParam, hubTeamUserDeleteParam, hubSchemaQuery, HUB_USERS_PAGE_SIZE_MAX, HUB_USERS_SEARCH_MAX, HUB_USERS_CHANNEL_TYPES, getHubUsersQuery, PREVIEW_LABEL_MAX_LENGTH, MAX_ENDED_INDEX_RETENTION_DAYS, MAX_EVAL_RETENTION_DAYS, MAX_END_USER_DAILY_MESSAGE_LIMIT, endUserDailyMessageLimitField, previewLabelField, hubTagsField, createHubBody, updateHubBody, HUB_TAG_CHANGE_REFUSED, hubTagChangeRefusalSchema, addHubAdminBody, addHubIdentityAuthorizationBody, contactDecisionBody, approveContactBody, CONTACT_ACCESS_PAGE_SIZE_MAX, listContactAccessQuery, createHubTeamBody, updateHubTeamBody, addHubTeamUserBody, reassignHubUserBody, replicatePreviewBody, HUB_DIFF_SECTION_SET, HUB_DIFF_SECTIONS, updateChannelTestIdentitiesBody, claimCodeChannelParam, claimCodeDeleteParam;
14326
- var init_chunk_ARK3766Q = __esm({
14327
- "../../packages/core/dist/chunk-ARK3766Q.js"() {
14356
+ var hubIdParam, hubAdminIdParam, hubUserIdParam, hubAgentIdParam, hubIdentityIdParam, hubTeamIdParam, hubTeamUserDeleteParam, hubSchemaQuery, HUB_USERS_PAGE_SIZE_MAX, HUB_USERS_SEARCH_MAX, HUB_USERS_CHANNEL_TYPES, getHubUsersQuery, PREVIEW_LABEL_MAX_LENGTH, MAX_ENDED_INDEX_RETENTION_DAYS, MAX_EVAL_RETENTION_DAYS, MAX_END_USER_DAILY_MESSAGE_LIMIT, endUserDailyMessageLimitField, previewLabelField, hubTagsField, hubTypeSchema, supportModelSchema, unassignedPolicySchema, hubLanguageSchema, accessApprovalRoleSchema, createHubBody, updateHubBody, HUB_TAG_CHANGE_REFUSED, hubTagChangeRefusalSchema, addHubAdminBody, addHubIdentityAuthorizationBody, contactDecisionBody, approveContactBody, CONTACT_ACCESS_PAGE_SIZE_MAX, listContactAccessQuery, createHubTeamBody, updateHubTeamBody, addHubTeamUserBody, reassignHubUserBody, replicatePreviewBody, hubRowObjectListSchema, createdHubRowSchema, createHubResponseSchema, diffEntrySchema, diffEntriesSchema, hubDiffResultSchema, HUB_DIFF_SECTION_SET, HUB_DIFF_SECTIONS, getHubDiffResponseSchema, publishHubResponseSchema, syncWarningSchema, syncHubResponseSchema, replicatePreviewHubResponseSchema, updateChannelTestIdentitiesBody, claimCodeChannelParam, claimCodeDeleteParam;
14357
+ var init_chunk_4NZTCAY5 = __esm({
14358
+ "../../packages/core/dist/chunk-4NZTCAY5.js"() {
14328
14359
  "use strict";
14329
14360
  init_chunk_D3EP4TDU();
14330
- init_chunk_X5PZZVTS();
14331
- init_chunk_PIZTARVG();
14361
+ init_chunk_JP42Y3U2();
14362
+ init_chunk_QT7R3TGR();
14332
14363
  init_chunk_HZ6CADSY();
14364
+ init_chunk_ZTNFLGW5();
14333
14365
  init_zod();
14334
14366
  hubIdParam = external_exports.object({ id: uuidSchema });
14335
14367
  hubAdminIdParam = external_exports.object({ id: uuidSchema, adminId: uuidSchema });
@@ -14359,11 +14391,16 @@ var init_chunk_ARK3766Q = __esm({
14359
14391
  return trimmed || null;
14360
14392
  });
14361
14393
  hubTagsField = external_exports.array(external_exports.string()).nullable().optional();
14394
+ hubTypeSchema = external_exports.enum(["chat", "task"]);
14395
+ supportModelSchema = external_exports.enum(["conversation", "account"]);
14396
+ unassignedPolicySchema = external_exports.enum(["default_team", "auto_assign_random", "auto_assign_round_robin", "pull_queue"]);
14397
+ hubLanguageSchema = external_exports.enum(SUPPORTED_LOCALES);
14398
+ accessApprovalRoleSchema = external_exports.enum(["admin", "team"]);
14362
14399
  createHubBody = external_exports.object({
14363
14400
  organization_id: uuidSchema,
14364
14401
  hub_name: external_exports.string().min(1, "hub_name is required"),
14365
14402
  hub_description: external_exports.string().optional(),
14366
- hub_type: external_exports.enum(["chat", "task"]).optional(),
14403
+ hub_type: hubTypeSchema.optional(),
14367
14404
  kanban_statuses: kanbanStatusesArraySchema.nullable().optional(),
14368
14405
  lanes: lanesArraySchema.nullable().optional(),
14369
14406
  // Optional preview label for the first preview. Server-owned thereafter
@@ -14381,8 +14418,8 @@ var init_chunk_ARK3766Q = __esm({
14381
14418
  end_user_daily_message_limit: endUserDailyMessageLimitField
14382
14419
  }).strict().superRefine(refineLaneReferences);
14383
14420
  updateHubBody = external_exports.object({
14384
- support_model: external_exports.enum(["conversation", "account"]).optional(),
14385
- unassigned_policy: external_exports.enum(["default_team", "auto_assign_random", "auto_assign_round_robin", "pull_queue"]).optional(),
14421
+ support_model: supportModelSchema.optional(),
14422
+ unassigned_policy: unassignedPolicySchema.optional(),
14386
14423
  default_hub_team_id: uuidSchema.nullable().optional(),
14387
14424
  kanban_statuses: kanbanStatusesArraySchema.nullable().optional(),
14388
14425
  lanes: lanesArraySchema.nullable().optional(),
@@ -14404,9 +14441,9 @@ var init_chunk_ARK3766Q = __esm({
14404
14441
  eval_retention_days: external_exports.number().int().min(0).max(MAX_EVAL_RETENTION_DAYS).nullable().optional(),
14405
14442
  // Channel contact access control. Enum-validated explicitly (not via passthrough)
14406
14443
  // so `language`/`access_approval_role` can't reach the DB with an invalid value.
14407
- language: external_exports.enum(["en", "pt", "es"]).optional(),
14444
+ language: hubLanguageSchema.optional(),
14408
14445
  access_request_message: external_exports.string().max(1e3).nullable().optional(),
14409
- access_approval_role: external_exports.enum(["admin", "team"]).optional(),
14446
+ access_approval_role: accessApprovalRoleSchema.optional(),
14410
14447
  // AI-failure escalation. When an LLM provider outage persists past this many
14411
14448
  // minutes the conversation escalates to the team; null → code default. The two
14412
14449
  // message fields override the localized (hub.language) delay / hand-off notices;
@@ -14488,6 +14525,96 @@ var init_chunk_ARK3766Q = __esm({
14488
14525
  replicatePreviewBody = external_exports.object({
14489
14526
  preview_label: previewLabelField
14490
14527
  });
14528
+ hubRowObjectListSchema = external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown()));
14529
+ createdHubRowSchema = external_exports.object({
14530
+ hub_id: external_exports.string().min(1),
14531
+ hub_name: external_exports.string(),
14532
+ hub_type: hubTypeSchema,
14533
+ hub_description: external_exports.string().nullable(),
14534
+ ai_mode: external_exports.enum(AI_MODES),
14535
+ non_app_permission: external_exports.enum(["everyone", "require_permission", "not_allowed"]),
14536
+ hub_environment: external_exports.enum(["preview", "production"]),
14537
+ production_hub_id: external_exports.string().nullable(),
14538
+ branch_name: external_exports.string().nullable(),
14539
+ preview_label: external_exports.string().nullable(),
14540
+ tags: external_exports.array(external_exports.string()),
14541
+ org_id: external_exports.string(),
14542
+ created_by: external_exports.string(),
14543
+ kanban_statuses: hubRowObjectListSchema.nullable(),
14544
+ timezone: external_exports.string().nullable(),
14545
+ support_model: supportModelSchema,
14546
+ unassigned_policy: unassignedPolicySchema,
14547
+ default_hub_team_id: external_exports.string().nullable(),
14548
+ last_assigned_team_index: external_exports.number(),
14549
+ storage_retention_months: external_exports.number().nullable(),
14550
+ holidays: external_exports.array(external_exports.string()).nullable(),
14551
+ template_id: external_exports.string().nullable(),
14552
+ last_ci_activity_at: external_exports.string().nullable(),
14553
+ ci_commit_sha: external_exports.string().nullable(),
14554
+ config_version: external_exports.number(),
14555
+ created_at: external_exports.string(),
14556
+ updated_at: external_exports.string(),
14557
+ deleted_at: external_exports.string().nullable(),
14558
+ auto_close_inactive_days: external_exports.number(),
14559
+ primary_region: primaryRegionSchema.nullable(),
14560
+ placement_region: primaryRegionSchema.nullable(),
14561
+ placement_source: placementSourceSchema.nullable(),
14562
+ language: hubLanguageSchema,
14563
+ access_request_message: external_exports.string().nullable(),
14564
+ access_approval_role: accessApprovalRoleSchema,
14565
+ lanes: hubRowObjectListSchema.nullable(),
14566
+ conversation_retention_days: external_exports.number(),
14567
+ harness_enabled: external_exports.number(),
14568
+ fallback_connection_id: external_exports.string().nullable(),
14569
+ seed_connection_id: external_exports.string().nullable(),
14570
+ ended_index_retention_days: external_exports.number().nullable(),
14571
+ ai_failure_escalation_minutes: external_exports.number().nullable(),
14572
+ ai_delay_message: external_exports.string().nullable(),
14573
+ ai_handoff_message: external_exports.string().nullable(),
14574
+ eval_retention_days: external_exports.number().nullable(),
14575
+ end_user_daily_message_limit: external_exports.number().nullable()
14576
+ }).merge(hubPresentationColumnsSchema);
14577
+ createHubResponseSchema = external_exports.object({
14578
+ data: external_exports.array(createdHubRowSchema),
14579
+ /** Non-blocking lint warnings (e.g. unreachable kanban statuses). */
14580
+ warnings: external_exports.array(kanbanLintWarningSchema)
14581
+ });
14582
+ diffEntrySchema = external_exports.object({
14583
+ name: external_exports.string(),
14584
+ type: external_exports.string().optional(),
14585
+ status: external_exports.enum(["added", "removed", "updated"])
14586
+ });
14587
+ diffEntriesSchema = external_exports.array(diffEntrySchema);
14588
+ hubDiffResultSchema = external_exports.object({
14589
+ has_changes: external_exports.boolean(),
14590
+ is_first_publish: external_exports.boolean(),
14591
+ hub_changed: external_exports.boolean(),
14592
+ agents: diffEntriesSchema,
14593
+ connections: diffEntriesSchema,
14594
+ tools: diffEntriesSchema,
14595
+ channels: diffEntriesSchema,
14596
+ states: diffEntriesSchema,
14597
+ resources: diffEntriesSchema,
14598
+ /** A connection's message templates, which publish and sync copy too. Absent from a server older than wayai#4931 PR 4a. */
14599
+ message_templates: diffEntriesSchema.optional(),
14600
+ // Every other type publish and sync copy. Each is absent from a server older than wayai#4931 PR 1d.
14601
+ /** An agent's parameters; `type` names their agent. */
14602
+ agent_parameters: diffEntriesSchema.optional(),
14603
+ mcp_tools: diffEntriesSchema.optional(),
14604
+ teams: diffEntriesSchema.optional(),
14605
+ /** `type` names the resource a folder belongs to. */
14606
+ resource_folders: diffEntriesSchema.optional(),
14607
+ /** `type` names the resource a file belongs to. */
14608
+ resource_files: diffEntriesSchema.optional(),
14609
+ /** An agent's link to a resource: `name` is the resource, `type` the agent. */
14610
+ agent_resources: diffEntriesSchema.optional(),
14611
+ evals: diffEntriesSchema.optional(),
14612
+ /** The hub's own contact lists (wayai#4931 PR 2c). */
14613
+ contact_lists: diffEntriesSchema.optional(),
14614
+ automations: diffEntriesSchema.optional(),
14615
+ /** The hub's pages (wayai#5333), named by slug: a page is the same page in both hubs. Absent from a server older than its pages section. */
14616
+ pages: diffEntriesSchema.optional()
14617
+ });
14491
14618
  HUB_DIFF_SECTION_SET = {
14492
14619
  agents: true,
14493
14620
  agent_parameters: true,
@@ -14508,6 +14635,37 @@ var init_chunk_ARK3766Q = __esm({
14508
14635
  evals: true
14509
14636
  };
14510
14637
  HUB_DIFF_SECTIONS = Object.keys(HUB_DIFF_SECTION_SET);
14638
+ getHubDiffResponseSchema = external_exports.object({ data: hubDiffResultSchema });
14639
+ publishHubResponseSchema = external_exports.object({
14640
+ data: external_exports.object({ production_hub_id: external_exports.string().min(1) })
14641
+ });
14642
+ syncWarningSchema = external_exports.discriminatedUnion("kind", [
14643
+ external_exports.object({
14644
+ kind: external_exports.literal("toolset_tools_differ"),
14645
+ connection_name: external_exports.string(),
14646
+ toolset: external_exports.string(),
14647
+ /** Tools the preview's toolset publishes and production's does not, sorted. */
14648
+ missing_in_production: external_exports.array(external_exports.string()),
14649
+ /** Tools only production's toolset publishes, sorted. */
14650
+ only_in_production: external_exports.array(external_exports.string())
14651
+ }),
14652
+ external_exports.object({
14653
+ /** The tools could not be compared (the data service unreachable, or refusing a token). */
14654
+ kind: external_exports.literal("toolset_tools_unverified"),
14655
+ connection_name: external_exports.string(),
14656
+ toolset: external_exports.string()
14657
+ })
14658
+ ]);
14659
+ syncHubResponseSchema = external_exports.object({
14660
+ data: external_exports.object({
14661
+ synced: external_exports.boolean(),
14662
+ /** Absent when there is nothing to say. */
14663
+ warnings: external_exports.array(syncWarningSchema).optional()
14664
+ })
14665
+ });
14666
+ replicatePreviewHubResponseSchema = external_exports.object({
14667
+ data: external_exports.object({ preview_hub_id: external_exports.string().min(1) })
14668
+ });
14511
14669
  updateChannelTestIdentitiesBody = external_exports.object({
14512
14670
  test_identities: external_exports.array(external_exports.string().max(320)).max(1e3)
14513
14671
  });
@@ -14523,7 +14681,7 @@ var init_chunk_ARK3766Q = __esm({
14523
14681
  }
14524
14682
  });
14525
14683
 
14526
- // ../../packages/core/dist/chunk-LZHLURLT.js
14684
+ // ../../packages/core/dist/chunk-A3KD6FK4.js
14527
14685
  function declaresNoConnection(agent) {
14528
14686
  return agent.connection === null && !agent.connection_id;
14529
14687
  }
@@ -15254,19 +15412,19 @@ function skillSectionsAsResources(scope) {
15254
15412
  return out;
15255
15413
  };
15256
15414
  }
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"() {
15415
+ 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;
15416
+ var init_chunk_A3KD6FK4 = __esm({
15417
+ "../../packages/core/dist/chunk-A3KD6FK4.js"() {
15260
15418
  "use strict";
15261
15419
  init_chunk_QG3XMUEN();
15262
15420
  init_chunk_EBUWHIFV();
15263
- init_chunk_PCQIFFYO();
15421
+ init_chunk_5YZ3R7KF();
15264
15422
  init_chunk_QMQGGR7Q();
15265
15423
  init_chunk_LBDH7LCG();
15266
15424
  init_chunk_4LXDRTO4();
15267
- init_chunk_ARK3766Q();
15268
- init_chunk_X5PZZVTS();
15269
- init_chunk_PIZTARVG();
15425
+ init_chunk_4NZTCAY5();
15426
+ init_chunk_JP42Y3U2();
15427
+ init_chunk_QT7R3TGR();
15270
15428
  init_chunk_S4VDZ7PZ();
15271
15429
  init_chunk_ZDTX3DG5();
15272
15430
  init_chunk_C2UEA2KW();
@@ -15431,6 +15589,7 @@ var init_chunk_LZHLURLT = __esm({
15431
15589
  ciBranchesQuery = external_exports.object({
15432
15590
  hub_id: ciUuidSchema
15433
15591
  });
15592
+ ciDiffDirectionSchema = external_exports.enum(["push", "pull"]);
15434
15593
  ciSyncBody = external_exports.object({
15435
15594
  hub_id: ciUuidSchema,
15436
15595
  branch_name: external_exports.string().min(1, "branch_name is required"),
@@ -15445,7 +15604,7 @@ var init_chunk_LZHLURLT = __esm({
15445
15604
  ciDiffBody = external_exports.object({
15446
15605
  hub_id: ciUuidSchema,
15447
15606
  config: hubAsCodeConfigSchema,
15448
- direction: external_exports.enum(["push", "pull"]).default("push"),
15607
+ direction: ciDiffDirectionSchema.default("push"),
15449
15608
  organization_id: ciUuidSchema.optional()
15450
15609
  });
15451
15610
  ciPublishBody = external_exports.object({
@@ -15477,7 +15636,62 @@ var init_chunk_LZHLURLT = __esm({
15477
15636
  ciOrgResourcesDiffBody = external_exports.object({
15478
15637
  organization_id: ciUuidSchema,
15479
15638
  config: orgResourcesConfigSchema,
15480
- direction: external_exports.enum(["push", "pull"]).default("push")
15639
+ direction: ciDiffDirectionSchema.default("push")
15640
+ });
15641
+ ciDiffResponseSchema = external_exports.object({
15642
+ has_changes: external_exports.boolean(),
15643
+ direction: ciDiffDirectionSchema,
15644
+ summary: external_exports.string(),
15645
+ /**
15646
+ * The diff engine's own result (`DiffResult` for a hub, the org skills diff for an org), as
15647
+ * computed. Not part of the contract yet: no client reads it, and its shape is the engine's.
15648
+ */
15649
+ diff: external_exports.unknown(),
15650
+ /**
15651
+ * Non-fatal skip reasons surfaced by the diff engine (e.g. native/delegation
15652
+ * tools dropped because their connector has no connection on the hub).
15653
+ * Populated independently of `has_changes` so the CLI can display them even
15654
+ * when every change was silently dropped. Always present (possibly empty),
15655
+ * symmetric with `DiffResult.warnings`. See gh #1538.
15656
+ */
15657
+ warnings: external_exports.array(external_exports.string()),
15658
+ /**
15659
+ * The hub's current server-owned `preview_label`. Surfaced so the CLI can warn
15660
+ * when a hand-edited `hub.yaml` label differs from the server — the diff engine
15661
+ * ignores `preview_label` (it's set via `wayai relabel`/replicate, not push), so
15662
+ * without this the silent no-op is invisible. Optional for back-compat with
15663
+ * older backends, and absent from the org skills diff. See gh hub-branching.
15664
+ */
15665
+ preview_label: external_exports.string().nullable().optional()
15666
+ });
15667
+ ciHubIdentitySchema = external_exports.object({
15668
+ hub_id: external_exports.string().min(1),
15669
+ hub_name: external_exports.string(),
15670
+ hub_environment: external_exports.string(),
15671
+ preview_label: external_exports.string().nullable(),
15672
+ branch_name: external_exports.string().nullable()
15673
+ });
15674
+ ciLookupResponseSchema = ciHubIdentitySchema.partial({ preview_label: true, branch_name: true });
15675
+ ciOrganizationsResponseSchema = external_exports.object({
15676
+ organizations: external_exports.array(external_exports.object({ id: external_exports.string().min(1), name: external_exports.string() }))
15677
+ });
15678
+ ciCreateOrganizationResponseSchema = external_exports.object({
15679
+ organization: external_exports.object({
15680
+ id: external_exports.string().min(1),
15681
+ name: external_exports.string(),
15682
+ /** Resolved DO placement region (auto-detected from the request edge, or the
15683
+ * caller's explicit `primary_region`). Surfaced so the CLI can show it. */
15684
+ region: external_exports.string().nullable(),
15685
+ /** True when the caller passed an explicit region; false when auto-detected
15686
+ * (closest Cloudflare PoP). Lets the CLI phrase "closest to you" vs "as requested". */
15687
+ region_explicit: external_exports.boolean()
15688
+ })
15689
+ });
15690
+ ciHubListItemSchema = ciHubIdentitySchema.extend({
15691
+ production_hub_id: external_exports.string().nullable()
15692
+ });
15693
+ ciHubListResponseSchema = external_exports.object({
15694
+ hubs: external_exports.array(ciHubListItemSchema)
15481
15695
  });
15482
15696
  CI_APPLY_ENTITY_KINDS = [
15483
15697
  "agent",
@@ -15575,17 +15789,19 @@ var init_chunk_LZHLURLT = __esm({
15575
15789
  apply_errors: external_exports.array(ciApplyErrorSchema).optional(),
15576
15790
  warnings: external_exports.array(ciSyncWarningSchema).optional()
15577
15791
  });
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()
15792
+ ciOrgResourcesPushResponseSchema = external_exports.object({
15793
+ changes: external_exports.object({
15794
+ resources_created: ciSyncCountSchema,
15795
+ resources_updated: ciSyncCountSchema,
15796
+ resources_deleted: ciSyncCountSchema,
15797
+ resource_files_uploaded: ciSyncCountSchema,
15798
+ resource_files_deleted: ciSyncCountSchema,
15799
+ resource_folders_created: ciSyncCountSchema,
15800
+ resource_folders_deleted: ciSyncCountSchema
15801
+ }),
15802
+ /** Aggregate awaited fan-out to linked hub shadows across all changed resources. */
15803
+ fanout: external_exports.object({ hubs: ciSyncCountSchema, failures: ciSyncCountSchema }),
15804
+ errors: external_exports.array(external_exports.string()).optional()
15589
15805
  });
15590
15806
  }
15591
15807
  });
@@ -16485,10 +16701,10 @@ var init_chunk_S2LXF4LF = __esm({
16485
16701
  }
16486
16702
  });
16487
16703
 
16488
- // ../../packages/core/dist/chunk-UWJJF7PZ.js
16704
+ // ../../packages/core/dist/chunk-VHA3AQE4.js
16489
16705
  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"() {
16706
+ var init_chunk_VHA3AQE4 = __esm({
16707
+ "../../packages/core/dist/chunk-VHA3AQE4.js"() {
16492
16708
  "use strict";
16493
16709
  init_chunk_YR7QALGP();
16494
16710
  init_chunk_AMKBCOOH();
@@ -16506,10 +16722,10 @@ var init_chunk_UWJJF7PZ = __esm({
16506
16722
  }
16507
16723
  });
16508
16724
 
16509
- // ../../packages/core/dist/chunk-56WMNWMX.js
16725
+ // ../../packages/core/dist/chunk-2S6LIRGD.js
16510
16726
  var casePhaseParam;
16511
- var init_chunk_56WMNWMX = __esm({
16512
- "../../packages/core/dist/chunk-56WMNWMX.js"() {
16727
+ var init_chunk_2S6LIRGD = __esm({
16728
+ "../../packages/core/dist/chunk-2S6LIRGD.js"() {
16513
16729
  "use strict";
16514
16730
  init_chunk_S2LXF4LF();
16515
16731
  init_chunk_HZ6CADSY();
@@ -16517,10 +16733,10 @@ var init_chunk_56WMNWMX = __esm({
16517
16733
  }
16518
16734
  });
16519
16735
 
16520
- // ../../packages/core/dist/chunk-CBPHDU3I.js
16736
+ // ../../packages/core/dist/chunk-K6O2P77D.js
16521
16737
  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"() {
16738
+ var init_chunk_K6O2P77D = __esm({
16739
+ "../../packages/core/dist/chunk-K6O2P77D.js"() {
16524
16740
  "use strict";
16525
16741
  init_chunk_YR7QALGP();
16526
16742
  init_chunk_HZ6CADSY();
@@ -16534,14 +16750,14 @@ var init_chunk_CBPHDU3I = __esm({
16534
16750
  }
16535
16751
  });
16536
16752
 
16537
- // ../../packages/core/dist/chunk-5LTMGGTR.js
16753
+ // ../../packages/core/dist/chunk-UAFAJNZ6.js
16538
16754
  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"() {
16755
+ var init_chunk_UAFAJNZ6 = __esm({
16756
+ "../../packages/core/dist/chunk-UAFAJNZ6.js"() {
16541
16757
  "use strict";
16542
- init_chunk_UWJJF7PZ();
16543
- init_chunk_56WMNWMX();
16544
- init_chunk_CBPHDU3I();
16758
+ init_chunk_VHA3AQE4();
16759
+ init_chunk_2S6LIRGD();
16760
+ init_chunk_K6O2P77D();
16545
16761
  init_chunk_YR7QALGP();
16546
16762
  init_chunk_AMKBCOOH();
16547
16763
  init_chunk_S2LXF4LF();
@@ -16618,6 +16834,52 @@ var init_chunk_ZTRVP4OT = __esm({
16618
16834
  }
16619
16835
  });
16620
16836
 
16837
+ // ../../packages/core/dist/chunk-5WMOQ5NC.js
16838
+ 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;
16839
+ var init_chunk_5WMOQ5NC = __esm({
16840
+ "../../packages/core/dist/chunk-5WMOQ5NC.js"() {
16841
+ "use strict";
16842
+ init_chunk_S2LXF4LF();
16843
+ init_chunk_TYI6QVPX();
16844
+ init_chunk_HZ6CADSY();
16845
+ init_zod();
16846
+ CASE_RELATION_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
16847
+ CASE_RELATION_TYPE_CODE_MAX_LENGTH = 64;
16848
+ CASE_RELATION_TYPE_NAME_MAX_LENGTH = 200;
16849
+ CASE_RELATION_TYPES_PER_SPACE_MAX = 100;
16850
+ CASE_RELATION_DESCRIPTION_MAX_LENGTH = 500;
16851
+ CASE_RELATION_SIDES = ["origin", "destination"];
16852
+ CASE_EXTERNAL_SYSTEM_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,30}$/;
16853
+ CASE_EXTERNAL_NUMBER_MAX_LENGTH = 120;
16854
+ CASE_EXTERNAL_URL_MAX_LENGTH = 2048;
16855
+ trimmedName = external_exports.string().trim().min(1).max(CASE_RELATION_TYPE_NAME_MAX_LENGTH);
16856
+ relationTypeFields = { name: trimmedName, inverse_name: trimmedName, active: external_exports.boolean().default(true) };
16857
+ createCaseRelationTypeBody = external_exports.object({
16858
+ code: external_exports.string().trim().max(CASE_RELATION_TYPE_CODE_MAX_LENGTH).regex(CASE_RELATION_TYPE_CODE_PATTERN),
16859
+ ...relationTypeFields
16860
+ }).strict();
16861
+ updateCaseRelationTypeBody = external_exports.object({ ...relationTypeFields, expected_updated_at: timestampSchema.optional() }).strict();
16862
+ relateCasesBody = external_exports.object({
16863
+ relation_type_id: uuidSchema,
16864
+ other_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN),
16865
+ /** This case's side: `origin` reads the type's name ("continues"), `destination` its inverse. */
16866
+ side: external_exports.enum(CASE_RELATION_SIDES).default("origin"),
16867
+ description: external_exports.string().trim().min(1).max(CASE_RELATION_DESCRIPTION_MAX_LENGTH).nullable().default(null)
16868
+ }).strict();
16869
+ addCaseExternalReferenceBody = external_exports.object({
16870
+ system: external_exports.string().trim().regex(CASE_EXTERNAL_SYSTEM_PATTERN),
16871
+ number: external_exports.string().trim().min(1).max(CASE_EXTERNAL_NUMBER_MAX_LENGTH),
16872
+ url: external_exports.string().trim().max(CASE_EXTERNAL_URL_MAX_LENGTH).url().refine((url) => url.startsWith("https://"), "An https link").nullable().default(null)
16873
+ }).strict();
16874
+ caseRelationTypeParam = caseSpaceParam.extend({ relation_type_id: uuidSchema });
16875
+ caseRelationParam = caseRecordParam.extend({ relation_id: uuidSchema });
16876
+ caseExternalReferenceParam = caseRecordParam.extend({ reference_id: uuidSchema });
16877
+ caseRelationTypesQuery = casePageQuery.extend({
16878
+ limit: external_exports.coerce.number().int().min(1).max(CASE_RELATION_TYPES_PER_SPACE_MAX).optional()
16879
+ });
16880
+ }
16881
+ });
16882
+
16621
16883
  // ../../packages/core/dist/chunk-UPGAWPE2.js
16622
16884
  var CASE_CHANGE_TOPICS, caseChangedFrameSchema;
16623
16885
  var init_chunk_UPGAWPE2 = __esm({
@@ -16651,33 +16913,6 @@ var init_chunk_3EEL6BQ7 = __esm({
16651
16913
  }
16652
16914
  });
16653
16915
 
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
16916
  // ../../packages/core/dist/chunk-ATX6AHPZ.js
16682
16917
  function withProblem(shape, problemOf) {
16683
16918
  return shape.superRefine((value, ctx) => {
@@ -16714,7 +16949,7 @@ function caseInstrumentProblem(instrument) {
16714
16949
  ${party.role}`);
16715
16950
  return new Set(keys).size === keys.length ? null : { reason: "instrument_party_repeated", at: "parties" };
16716
16951
  }
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;
16952
+ 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
16953
  var init_chunk_ATX6AHPZ = __esm({
16719
16954
  "../../packages/core/dist/chunk-ATX6AHPZ.js"() {
16720
16955
  "use strict";
@@ -16736,11 +16971,11 @@ var init_chunk_ATX6AHPZ = __esm({
16736
16971
  CASE_INSTRUMENT_PARTIES_MAX = 50;
16737
16972
  CASE_REGISTRY_PAGE_MAX = 100;
16738
16973
  CASE_REGISTRY_QUERY_MAX_LENGTH = 200;
16739
- trimmedName = external_exports.string().trim().min(1).max(CASE_REGISTRY_NAME_MAX_LENGTH);
16974
+ trimmedName2 = external_exports.string().trim().min(1).max(CASE_REGISTRY_NAME_MAX_LENGTH);
16740
16975
  dateSchema = caseDateSchema;
16741
16976
  attributesValues = external_exports.record(external_exports.string(), external_exports.unknown()).default({});
16742
16977
  registryTypeFields = {
16743
- name: trimmedName,
16978
+ name: trimmedName2,
16744
16979
  attributes: caseAttributesSchemaSchema.default(EMPTY_CASE_ATTRIBUTES_SCHEMA),
16745
16980
  active: external_exports.boolean().default(true)
16746
16981
  };
@@ -16756,7 +16991,7 @@ var init_chunk_ATX6AHPZ = __esm({
16756
16991
  updateCaseRegistryTypeBody = withProblem(updateCaseRegistryTypeShape, caseRegistryTypeProblem);
16757
16992
  saveCasePartyShape = external_exports.object({
16758
16993
  type_id: uuidSchema,
16759
- name: trimmedName,
16994
+ name: trimmedName2,
16760
16995
  abbreviation: external_exports.string().trim().transform((value) => value.toUpperCase()).pipe(external_exports.string().regex(CASE_PARTY_ABBREVIATION_PATTERN)).nullable().default(null),
16761
16996
  person_kind: external_exports.enum(CASE_PARTY_PERSON_KINDS),
16762
16997
  document_kind: external_exports.enum(CASE_PARTY_DOCUMENT_KINDS).nullable().default(null),
@@ -16767,7 +17002,7 @@ var init_chunk_ATX6AHPZ = __esm({
16767
17002
  }).strict();
16768
17003
  saveCasePartyBody = withProblem(saveCasePartyShape, casePartyProblem);
16769
17004
  saveCasePartyGroupShape = external_exports.object({
16770
- name: trimmedName,
17005
+ name: trimmedName2,
16771
17006
  party_ids: external_exports.array(uuidSchema).max(CASE_PARTY_GROUP_MEMBERS_MAX).default([]),
16772
17007
  expected_updated_at: timestampSchema.optional()
16773
17008
  }).strict();
@@ -16810,7 +17045,34 @@ var init_chunk_ATX6AHPZ = __esm({
16810
17045
  }
16811
17046
  });
16812
17047
 
16813
- // ../../packages/core/dist/chunk-O6OMUGGZ.js
17048
+ // ../../packages/core/dist/chunk-NKJ2DQCV.js
17049
+ 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;
17050
+ var init_chunk_NKJ2DQCV = __esm({
17051
+ "../../packages/core/dist/chunk-NKJ2DQCV.js"() {
17052
+ "use strict";
17053
+ init_chunk_AMKBCOOH();
17054
+ init_chunk_TYI6QVPX();
17055
+ init_chunk_HZ6CADSY();
17056
+ init_zod();
17057
+ CASE_STYLE_KINDS = ["pdf_stylesheet", "word_reference"];
17058
+ caseStyleParam = caseSpaceParam.extend({ kind: external_exports.enum(CASE_STYLE_KINDS) });
17059
+ CASE_STYLE_VERSIONS_PAGE_MAX = 100;
17060
+ caseStyleVersionsQuery = casePageQuery.extend({
17061
+ limit: external_exports.coerce.number().int().min(1).max(CASE_STYLE_VERSIONS_PAGE_MAX).optional()
17062
+ });
17063
+ caseStyleContentQuery = external_exports.object({ version_id: uuidSchema.optional() });
17064
+ CASE_STYLE_UPLOAD_BODY_MAX_BYTES = 20 * 1024 * 1024;
17065
+ CASE_STYLE_FILE_FIELD = "file";
17066
+ CASE_STYLE_EXPECT_FIELD = "expect_version_id";
17067
+ caseStyleUploadForm = external_exports.object({
17068
+ [CASE_STYLE_FILE_FIELD]: external_exports.custom(isBlob, "The file is required"),
17069
+ /** Empty: the uploader read no current version. */
17070
+ [CASE_STYLE_EXPECT_FIELD]: external_exports.union([uuidSchema, external_exports.literal("")]).transform((value) => value || null)
17071
+ });
17072
+ }
17073
+ });
17074
+
17075
+ // ../../packages/core/dist/chunk-ZZZ65EIA.js
16814
17076
  function collectionUploadForm(field, shape) {
16815
17077
  return external_exports.record(external_exports.string(), external_exports.unknown()).transform((form2, ctx) => {
16816
17078
  const refuse2 = (message, path55) => {
@@ -16850,11 +17112,11 @@ function caseCollectionFileName(sent) {
16850
17112
  return name || "document";
16851
17113
  }
16852
17114
  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"() {
17115
+ var init_chunk_ZZZ65EIA = __esm({
17116
+ "../../packages/core/dist/chunk-ZZZ65EIA.js"() {
16855
17117
  "use strict";
16856
- init_chunk_NKJ2DQCV();
16857
17118
  init_chunk_ATX6AHPZ();
17119
+ init_chunk_NKJ2DQCV();
16858
17120
  init_chunk_AMKBCOOH();
16859
17121
  init_chunk_TYI6QVPX();
16860
17122
  init_chunk_M2T55BV6();
@@ -16916,7 +17178,7 @@ var init_chunk_O6OMUGGZ = __esm({
16916
17178
  }
16917
17179
  });
16918
17180
 
16919
- // ../../packages/core/dist/chunk-IK7IREH7.js
17181
+ // ../../packages/core/dist/chunk-WJJJFHIA.js
16920
17182
  function caseReceivedFormat(fileName) {
16921
17183
  const dot = fileName.lastIndexOf(".");
16922
17184
  if (dot < 0) return null;
@@ -16924,10 +17186,10 @@ function caseReceivedFormat(fileName) {
16924
17186
  return isCaseReceivedFormat(extension) ? extension : null;
16925
17187
  }
16926
17188
  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"() {
17189
+ var init_chunk_WJJJFHIA = __esm({
17190
+ "../../packages/core/dist/chunk-WJJJFHIA.js"() {
16929
17191
  "use strict";
16930
- init_chunk_O6OMUGGZ();
17192
+ init_chunk_ZZZ65EIA();
16931
17193
  init_chunk_NKJ2DQCV();
16932
17194
  init_chunk_AMKBCOOH();
16933
17195
  init_chunk_S2LXF4LF();
@@ -17005,78 +17267,6 @@ var init_chunk_IK7IREH7 = __esm({
17005
17267
  }
17006
17268
  });
17007
17269
 
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
17270
  // ../../packages/core/dist/chunk-74HGW6HA.js
17081
17271
  function addCaseNoteProblem(note) {
17082
17272
  return note.origin !== null && note.kind !== "contribution" ? { reason: "origin_not_contribution", at: "origin" } : null;
@@ -17208,6 +17398,117 @@ var init_chunk_I6CZPDXO = __esm({
17208
17398
  }
17209
17399
  });
17210
17400
 
17401
+ // ../../packages/core/dist/chunk-FPFUDA22.js
17402
+ 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;
17403
+ var init_chunk_FPFUDA22 = __esm({
17404
+ "../../packages/core/dist/chunk-FPFUDA22.js"() {
17405
+ "use strict";
17406
+ init_chunk_ZZZ65EIA();
17407
+ init_chunk_I6CZPDXO();
17408
+ init_chunk_S2LXF4LF();
17409
+ init_chunk_TYI6QVPX();
17410
+ init_chunk_HZ6CADSY();
17411
+ init_zod();
17412
+ caseInputLinkParam = caseRecordParam.extend({ input_id: uuidSchema });
17413
+ caseCollectionDocumentOfCaseParam = caseRecordParam.extend({ document_id: uuidSchema });
17414
+ linkCaseCollectionInputBody = external_exports.object({
17415
+ document_id: uuidSchema,
17416
+ /** The document's version its writer read as current, or an earlier one it keeps, with its `reason`. */
17417
+ version_id: uuidSchema,
17418
+ /** Why an earlier version is kept: a version decision. Unread when `version_id` is the current one. */
17419
+ reason: caseVersionDecisionReason.optional()
17420
+ }).strict();
17421
+ linkCasePreviousOutputInputBody = external_exports.object({ official_version_id: uuidSchema }).strict();
17422
+ linkCaseReceivedInputBody = external_exports.object({ received_id: uuidSchema }).strict();
17423
+ linkCaseInputBody = external_exports.union([linkCaseCollectionInputBody, linkCasePreviousOutputInputBody, linkCaseReceivedInputBody]);
17424
+ CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON = "official_version_unknown";
17425
+ CASE_LINK_OUTPUT_NOT_PRIOR_REASON = "output_not_prior";
17426
+ CASE_LINK_RECEIVED_UNKNOWN_REASON = "received_unknown";
17427
+ CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON = "document_type_mismatch";
17428
+ CASE_LINK_VERSION_NOT_CURRENT_REASON = "link_version_not_current";
17429
+ CASE_COLLECTION_CASES_PAGE_MAX = 100;
17430
+ caseCollectionCasesQuery = casePageQuery.extend({
17431
+ limit: external_exports.coerce.number().int().min(1).max(CASE_COLLECTION_CASES_PAGE_MAX).optional()
17432
+ });
17433
+ CASE_REFERENCES_PAGE_MAX = 100;
17434
+ caseReferencesQuery = casePageQuery.extend({
17435
+ limit: external_exports.coerce.number().int().min(1).max(CASE_REFERENCES_PAGE_MAX).optional()
17436
+ });
17437
+ }
17438
+ });
17439
+
17440
+ // ../../packages/core/dist/chunk-NVZB33EA.js
17441
+ function isCaseDueDate(value) {
17442
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
17443
+ if (!match) return false;
17444
+ const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
17445
+ if (year < CASE_DUE_DATE_MIN_YEAR || year > CASE_DUE_DATE_MAX_YEAR) return false;
17446
+ const date = new Date(Date.UTC(year, month - 1, day));
17447
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
17448
+ }
17449
+ function setCaseDeadlinesProblem(body) {
17450
+ const seen = /* @__PURE__ */ new Set();
17451
+ for (const [index, phase] of body.phases.entries()) {
17452
+ if (seen.has(phase.phase_id)) return { reason: "phase_repeated", at: `phases.${index}.phase_id` };
17453
+ seen.add(phase.phase_id);
17454
+ }
17455
+ return null;
17456
+ }
17457
+ 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;
17458
+ var init_chunk_NVZB33EA = __esm({
17459
+ "../../packages/core/dist/chunk-NVZB33EA.js"() {
17460
+ "use strict";
17461
+ init_chunk_TYI6QVPX();
17462
+ init_chunk_HZ6CADSY();
17463
+ init_zod();
17464
+ CASE_DUE_DATE_MIN_YEAR = 2e3;
17465
+ CASE_DUE_DATE_MAX_YEAR = 2100;
17466
+ CASE_DEADLINES_PHASES_MAX = 50;
17467
+ CASE_OVERDUE_CASES_MAX = 50;
17468
+ caseDueDateSchema = external_exports.string().refine(isCaseDueDate, "Not a calendar date (YYYY-MM-DD)");
17469
+ setCaseDeadlinesShape = external_exports.object({
17470
+ phases: external_exports.array(external_exports.object({ phase_id: uuidSchema, due_on: caseDueDateSchema.nullable() }).strict()).min(1).max(CASE_DEADLINES_PHASES_MAX)
17471
+ }).strict();
17472
+ setCaseDeadlinesBody = setCaseDeadlinesShape.superRefine((body, ctx) => {
17473
+ const found = setCaseDeadlinesProblem(body);
17474
+ if (found) {
17475
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: found.at.split("."), params: { case_deadlines_reason: found.reason } });
17476
+ }
17477
+ });
17478
+ setCaseTaskPlanBody = external_exports.object({
17479
+ owner_person_id: uuidSchema.nullable(),
17480
+ due_on: caseDueDateSchema.nullable()
17481
+ }).strict();
17482
+ setCaseOwnerBody = external_exports.object({ owner_person_id: uuidSchema.nullable() }).strict();
17483
+ caseOverdueQuery = casePageQuery.extend({
17484
+ limit: external_exports.coerce.number().int().min(1).max(CASE_OVERDUE_CASES_MAX).optional()
17485
+ });
17486
+ }
17487
+ });
17488
+
17489
+ // ../../packages/core/dist/chunk-7QN6QYGN.js
17490
+ var CASE_GUEST_EMAIL_MAX, CASE_GUEST_INVITATIONS_PAGE_MAX, CASE_GUEST_INVITE_TOKEN_LENGTH, caseGuestEmailSchema, caseGuestInviteTokenSchema, inviteCaseGuestBody, caseGuestInvitationParam, caseGuestInvitationsQuery, joinCaseSpaceBody, caseJoinSearchParams;
17491
+ var init_chunk_7QN6QYGN = __esm({
17492
+ "../../packages/core/dist/chunk-7QN6QYGN.js"() {
17493
+ "use strict";
17494
+ init_chunk_TYI6QVPX();
17495
+ init_chunk_HZ6CADSY();
17496
+ init_zod();
17497
+ CASE_GUEST_EMAIL_MAX = 320;
17498
+ CASE_GUEST_INVITATIONS_PAGE_MAX = 100;
17499
+ CASE_GUEST_INVITE_TOKEN_LENGTH = 43;
17500
+ caseGuestEmailSchema = external_exports.string().trim().toLowerCase().max(CASE_GUEST_EMAIL_MAX).email();
17501
+ caseGuestInviteTokenSchema = external_exports.string().regex(new RegExp(`^[A-Za-z0-9_-]{${CASE_GUEST_INVITE_TOKEN_LENGTH}}$`));
17502
+ inviteCaseGuestBody = external_exports.object({ email: caseGuestEmailSchema }).strict();
17503
+ caseGuestInvitationParam = caseSpaceParam.extend({ invitation_id: uuidSchema });
17504
+ caseGuestInvitationsQuery = casePageQuery.extend({
17505
+ limit: external_exports.coerce.number().int().min(1).max(CASE_GUEST_INVITATIONS_PAGE_MAX).optional()
17506
+ });
17507
+ joinCaseSpaceBody = external_exports.object({ invite: caseGuestInviteTokenSchema }).strict();
17508
+ caseJoinSearchParams = external_exports.object({ org: uuidSchema, space: uuidSchema, invite: caseGuestInviteTokenSchema });
17509
+ }
17510
+ });
17511
+
17211
17512
  // ../../packages/core/dist/chunk-7RWVVW7T.js
17212
17513
  var lines, ordered, citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody, citeCaseSourcePassageBody, citeCaseInputPassageBody, caseSourceRefSchema;
17213
17514
  var init_chunk_7RWVVW7T = __esm({
@@ -17232,56 +17533,10 @@ var init_chunk_7RWVVW7T = __esm({
17232
17533
  }
17233
17534
  });
17234
17535
 
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
17536
+ // ../../packages/core/dist/chunk-AF2RCYPB.js
17282
17537
  var caseAccessQuery;
17283
- var init_chunk_Z3SV3XTC = __esm({
17284
- "../../packages/core/dist/chunk-Z3SV3XTC.js"() {
17538
+ var init_chunk_AF2RCYPB = __esm({
17539
+ "../../packages/core/dist/chunk-AF2RCYPB.js"() {
17285
17540
  "use strict";
17286
17541
  init_chunk_HZ6CADSY();
17287
17542
  init_zod();
@@ -17372,45 +17627,6 @@ var init_chunk_E66NXU3F = __esm({
17372
17627
  }
17373
17628
  });
17374
17629
 
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
17630
  // ../../packages/core/dist/chunk-UEJOG2Q7.js
17415
17631
  var archiveHubIdParam, archiveConversationParams, archiveListQuery, archiveMessageObservabilityParams;
17416
17632
  var init_chunk_UEJOG2Q7 = __esm({
@@ -17891,7 +18107,7 @@ var init_chunk_OMPT4ZHR = __esm({
17891
18107
  }
17892
18108
  });
17893
18109
 
17894
- // ../../packages/core/dist/chunk-347WE2N4.js
18110
+ // ../../packages/core/dist/chunk-HLSE7OOG.js
17895
18111
  function refineScopedTarget(data, ctx) {
17896
18112
  if (data.scope === "org") {
17897
18113
  if (!data.org_id) {
@@ -17917,13 +18133,13 @@ function refineScopedTarget(data, ctx) {
17917
18133
  }
17918
18134
  }
17919
18135
  var adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, PRICING_PLAN_ID_RE, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, MAX_VOICE_CALL_MINUTE_OPS, voiceCallMinuteOps, AUTOMATION_GATE_EVALUATIONS_PER_OPERATION_BOUND, automationGateEvaluationsPerOperation, AUTOMATION_RUN_RETENTION_DAYS_MAX, automationRunRetentionDays, turnDeadlineSeconds, casesLimit, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetShape, adminScopedTargetBody, adminDryRunByDefaultTargetBody, WAYAI_HOST_TOKEN_TARGET_KINDS, WAYAI_HOST_TOKEN_MAX_TARGETS, adminClearWayaiHostTokensBody, BRANCHING_ORPHAN_ENTITY_TYPES, BRANCHING_ORPHAN_MAX_TARGETS, adminRepairBranchingOrphansBody, adminRepairLegacyOrgGrantsBody, adminRepairCredentialServicesBody, adminRepairCompedPlansBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysBody, dataExplorerKvKeyBody, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteBody, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, dataExplorerDebugCountsDoType, dataExplorerDebugCountsParam, debugHubConvParam, debugMessageIdQuery;
17920
- var init_chunk_347WE2N4 = __esm({
17921
- "../../packages/core/dist/chunk-347WE2N4.js"() {
18136
+ var init_chunk_HLSE7OOG = __esm({
18137
+ "../../packages/core/dist/chunk-HLSE7OOG.js"() {
17922
18138
  "use strict";
17923
18139
  init_chunk_FECLIZTY();
17924
18140
  init_chunk_BFG4ZWR4();
17925
18141
  init_chunk_UY32MQHG();
17926
- init_chunk_ARK3766Q();
18142
+ init_chunk_4NZTCAY5();
17927
18143
  init_chunk_OMPT4ZHR();
17928
18144
  init_chunk_MIWZOSPI();
17929
18145
  init_chunk_HZ6CADSY();
@@ -18485,17 +18701,18 @@ var init_chunk_SOJMWM63 = __esm({
18485
18701
  var init_contracts = __esm({
18486
18702
  "../../packages/core/dist/contracts/index.js"() {
18487
18703
  "use strict";
18704
+ init_chunk_VXEAR36B();
18488
18705
  init_chunk_RACEDHG6();
18489
18706
  init_chunk_Q7KIQHAZ();
18707
+ init_chunk_IPXBFWUU();
18490
18708
  init_chunk_63UWXV4T();
18491
18709
  init_chunk_AYLAGFAD();
18492
18710
  init_chunk_OPJ5OACS();
18493
18711
  init_chunk_YVY2TZK2();
18494
- init_chunk_VXEAR36B();
18495
18712
  init_chunk_HIGKBEPF();
18496
18713
  init_chunk_WONSSUXU();
18497
18714
  init_chunk_C7UAGRXF();
18498
- init_chunk_IPXBFWUU();
18715
+ init_chunk_PFGVH2CX();
18499
18716
  init_chunk_TVUDMGWV();
18500
18717
  init_chunk_WTIGECE5();
18501
18718
  init_chunk_WDAXZDJO();
@@ -18504,62 +18721,62 @@ var init_contracts = __esm({
18504
18721
  init_chunk_5DGHIY7L();
18505
18722
  init_chunk_2IPHTFV5();
18506
18723
  init_chunk_IPDOHAZ5();
18507
- init_chunk_PFGVH2CX();
18508
18724
  init_chunk_FPSDNS2E();
18509
18725
  init_chunk_TZH6DKKJ();
18510
18726
  init_chunk_SSPK6ISL();
18511
18727
  init_chunk_ZXK6N2HN();
18512
18728
  init_chunk_Y7CFCYX4();
18729
+ init_chunk_2ZZZHXZR();
18513
18730
  init_chunk_YUZFHVB2();
18514
18731
  init_chunk_I3O2RACG();
18515
18732
  init_chunk_CMRECH67();
18516
18733
  init_chunk_34LE6P7E();
18734
+ init_chunk_C4HEZ7ZI();
18517
18735
  init_chunk_IR2NOSI3();
18518
18736
  init_chunk_OPETF4GS();
18519
18737
  init_chunk_SY6PLCPK();
18520
- init_chunk_2ZZZHXZR();
18738
+ init_chunk_ACGAI25T();
18521
18739
  init_chunk_MH4O3YEX();
18522
18740
  init_chunk_QEEQN2NE();
18523
18741
  init_chunk_KSTYTQ7I();
18524
18742
  init_chunk_LKBSHANA();
18525
18743
  init_chunk_LX3D5LCB();
18526
- init_chunk_C4HEZ7ZI();
18744
+ init_chunk_JDJ4EUOL();
18527
18745
  init_chunk_UCYWGWQT();
18528
18746
  init_chunk_6AYIXGDT();
18529
18747
  init_chunk_YULHXJ5M();
18530
18748
  init_chunk_V4FRPRH5();
18531
18749
  init_chunk_LWMLR2WI();
18532
- init_chunk_ACGAI25T();
18533
18750
  init_chunk_ME6NL7FI();
18534
18751
  init_chunk_7CYHPF35();
18535
18752
  init_chunk_NETRUHZF();
18536
- init_chunk_LZHLURLT();
18753
+ init_chunk_A3KD6FK4();
18537
18754
  init_chunk_QG3XMUEN();
18538
18755
  init_chunk_EBUWHIFV();
18539
- init_chunk_PCQIFFYO();
18540
- init_chunk_AHISKXHA();
18756
+ init_chunk_5YZ3R7KF();
18541
18757
  init_chunk_2YEGUQR7();
18542
- init_chunk_JDJ4EUOL();
18543
- init_chunk_5LTMGGTR();
18758
+ init_chunk_AHISKXHA();
18759
+ init_chunk_UAFAJNZ6();
18544
18760
  init_chunk_K3PD6AOF();
18545
18761
  init_chunk_F4264AMK();
18546
18762
  init_chunk_ZTRVP4OT();
18763
+ init_chunk_5WMOQ5NC();
18547
18764
  init_chunk_UPGAWPE2();
18548
18765
  init_chunk_3EEL6BQ7();
18549
- init_chunk_UWJJF7PZ();
18550
- init_chunk_56WMNWMX();
18551
- init_chunk_IK7IREH7();
18766
+ init_chunk_VHA3AQE4();
18767
+ init_chunk_2S6LIRGD();
18768
+ init_chunk_WJJJFHIA();
18769
+ init_chunk_FPFUDA22();
18770
+ init_chunk_ZZZ65EIA();
18771
+ init_chunk_ATX6AHPZ();
18772
+ init_chunk_NKJ2DQCV();
18552
18773
  init_chunk_NVZB33EA();
18553
18774
  init_chunk_7QN6QYGN();
18554
18775
  init_chunk_7RWVVW7T();
18555
- init_chunk_5WMOQ5NC();
18556
- init_chunk_Z3SV3XTC();
18776
+ init_chunk_5PKKFSSF();
18777
+ init_chunk_AF2RCYPB();
18557
18778
  init_chunk_2KOYNTE2();
18558
18779
  init_chunk_E66NXU3F();
18559
- init_chunk_W2VXSBO2();
18560
- init_chunk_O6OMUGGZ();
18561
- init_chunk_NKJ2DQCV();
18562
- init_chunk_ATX6AHPZ();
18563
18780
  init_chunk_I6CZPDXO();
18564
18781
  init_chunk_UEJOG2Q7();
18565
18782
  init_chunk_KEN2DASI();
@@ -18572,16 +18789,15 @@ var init_contracts = __esm({
18572
18789
  init_chunk_PZPOUXJR();
18573
18790
  init_chunk_LBDH7LCG();
18574
18791
  init_chunk_4LXDRTO4();
18575
- init_chunk_5PKKFSSF();
18576
18792
  init_chunk_NVKU5PPQ();
18577
- init_chunk_347WE2N4();
18793
+ init_chunk_HLSE7OOG();
18578
18794
  init_chunk_FECLIZTY();
18579
18795
  init_chunk_BFG4ZWR4();
18580
18796
  init_chunk_UY32MQHG();
18581
- init_chunk_ARK3766Q();
18797
+ init_chunk_4NZTCAY5();
18582
18798
  init_chunk_D3EP4TDU();
18583
- init_chunk_X5PZZVTS();
18584
- init_chunk_PIZTARVG();
18799
+ init_chunk_JP42Y3U2();
18800
+ init_chunk_QT7R3TGR();
18585
18801
  init_chunk_OMPT4ZHR();
18586
18802
  init_chunk_2PZIF56U();
18587
18803
  init_chunk_6J742GLA();
@@ -18605,7 +18821,7 @@ var init_contracts = __esm({
18605
18821
  init_chunk_MIWZOSPI();
18606
18822
  init_chunk_2ISUBJG7();
18607
18823
  init_chunk_C2UEA2KW();
18608
- init_chunk_CBPHDU3I();
18824
+ init_chunk_K6O2P77D();
18609
18825
  init_chunk_YR7QALGP();
18610
18826
  init_chunk_LU4T7K5F();
18611
18827
  init_chunk_74HGW6HA();
@@ -20492,10 +20708,10 @@ var init_case_type_drafts = __esm({
20492
20708
  var init_case_received_documents = __esm({
20493
20709
  "../../packages/core/dist/contracts/case-received-documents.js"() {
20494
20710
  "use strict";
20495
- init_chunk_IK7IREH7();
20496
- init_chunk_O6OMUGGZ();
20497
- init_chunk_NKJ2DQCV();
20711
+ init_chunk_WJJJFHIA();
20712
+ init_chunk_ZZZ65EIA();
20498
20713
  init_chunk_ATX6AHPZ();
20714
+ init_chunk_NKJ2DQCV();
20499
20715
  init_chunk_AMKBCOOH();
20500
20716
  init_chunk_S2LXF4LF();
20501
20717
  init_chunk_WLKYA2B2();
@@ -24361,9 +24577,9 @@ var init_pages2 = __esm({
24361
24577
  var init_evals = __esm({
24362
24578
  "../../packages/core/dist/contracts/evals.js"() {
24363
24579
  "use strict";
24364
- init_chunk_PCQIFFYO();
24365
- init_chunk_AHISKXHA();
24580
+ init_chunk_5YZ3R7KF();
24366
24581
  init_chunk_2YEGUQR7();
24582
+ init_chunk_AHISKXHA();
24367
24583
  init_chunk_4LXDRTO4();
24368
24584
  init_chunk_AMMLEB4T();
24369
24585
  init_chunk_KB5RK3RP();
@@ -25389,19 +25605,19 @@ var init_hub_materializer = __esm({
25389
25605
  var init_ci = __esm({
25390
25606
  "../../packages/core/dist/contracts/ci.js"() {
25391
25607
  "use strict";
25392
- init_chunk_LZHLURLT();
25608
+ init_chunk_A3KD6FK4();
25393
25609
  init_chunk_QG3XMUEN();
25394
25610
  init_chunk_EBUWHIFV();
25395
- init_chunk_PCQIFFYO();
25396
- init_chunk_AHISKXHA();
25611
+ init_chunk_5YZ3R7KF();
25397
25612
  init_chunk_2YEGUQR7();
25613
+ init_chunk_AHISKXHA();
25398
25614
  init_chunk_QMQGGR7Q();
25399
25615
  init_chunk_LBDH7LCG();
25400
25616
  init_chunk_4LXDRTO4();
25401
- init_chunk_ARK3766Q();
25617
+ init_chunk_4NZTCAY5();
25402
25618
  init_chunk_D3EP4TDU();
25403
- init_chunk_X5PZZVTS();
25404
- init_chunk_PIZTARVG();
25619
+ init_chunk_JP42Y3U2();
25620
+ init_chunk_QT7R3TGR();
25405
25621
  init_chunk_AMMLEB4T();
25406
25622
  init_chunk_IBL7FANV();
25407
25623
  init_chunk_S4VDZ7PZ();
@@ -26423,14 +26639,13 @@ function parseDuration(input, flag = "duration") {
26423
26639
  }
26424
26640
  return value * unitMs;
26425
26641
  }
26426
- var BASE_SECRET_STORAGE_WHY, DURATION_RE, DURATION_UNIT_MS;
26642
+ var DURATION_RE, DURATION_UNIT_MS;
26427
26643
  var init_helpers = __esm({
26428
26644
  "src/data/helpers.ts"() {
26429
26645
  "use strict";
26430
26646
  init_base_id();
26431
26647
  init_expected();
26432
26648
  init_utils();
26433
- BASE_SECRET_STORAGE_WHY = "the credentials vault does not hold this kind of secret yet";
26434
26649
  DURATION_RE = /^(\d+)([smhd])$/;
26435
26650
  DURATION_UNIT_MS = {
26436
26651
  s: 1e3,
@@ -26969,109 +27184,8 @@ var init_output = __esm({
26969
27184
  }
26970
27185
  });
26971
27186
 
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
27187
  // src/data/commands/credentials.ts
27074
- import { Command as Command2 } from "commander";
27188
+ import { Command } from "commander";
27075
27189
  import { readFileSync as readFileSync15 } from "fs";
27076
27190
  function withValueSourceOptions(cmd, what) {
27077
27191
  return cmd.option(
@@ -27108,9 +27222,9 @@ function refusalReason(err) {
27108
27222
  const reason3 = dataErrorDetails(err)?.reason;
27109
27223
  return typeof reason3 === "string" ? reason3 : null;
27110
27224
  }
27111
- async function assertStorageOn(client, path55, body) {
27225
+ async function assertStorageOn(client, path55, body, method = "POST") {
27112
27226
  try {
27113
- await client.request("POST", path55, body);
27227
+ await client.request(method, path55, body);
27114
27228
  } catch (err) {
27115
27229
  if (refusalReason(err) === VALUE_MISSING) return;
27116
27230
  const reason3 = refusalReason(err);
@@ -27199,7 +27313,7 @@ async function reenterRefusedCredentials(client, base, message, pushedSources) {
27199
27313
  }
27200
27314
  function buildBasesCredentialsCommand() {
27201
27315
  const credentials = withBaseOption(
27202
- new Command2("credentials").description("Manage a base's integration credentials")
27316
+ new Command("credentials").description("Manage a base's integration credentials")
27203
27317
  );
27204
27318
  withValueSourceOptions(
27205
27319
  credentials.command("create").description(
@@ -27316,6 +27430,124 @@ var init_credentials = __esm({
27316
27430
  }
27317
27431
  });
27318
27432
 
27433
+ // src/data/commands/webhook-secrets.ts
27434
+ function secretPath(kind, base, id) {
27435
+ return `/v1/${pathSegment(base, "--base")}/${kind.family}/${pathSegment(id, `${kind.noun} id`)}/secret`;
27436
+ }
27437
+ function warnHoldersWithoutSecret(kind, ids, base) {
27438
+ if (!ids || ids.length === 0) return;
27439
+ console.warn(
27440
+ `
27441
+ ${kind.manyLacking}: ${ids.map((id) => sanitizeTerminalText(id)).join(", ")}. ${kind.manyLackingThen}Set one with ${setSecretCommand(kind, "<id>", base)}.`
27442
+ );
27443
+ }
27444
+ async function assertSecretStorageOn(client, kind, base, id) {
27445
+ await assertStorageOn(client, secretPath(kind, base, id), {}, "PUT");
27446
+ }
27447
+ function readSecretValue(kind, opts) {
27448
+ return readSecret(
27449
+ { stdin: opts.secretStdin, prompt: opts.secretPrompt, stdinFlag: "--secret-stdin", promptHint: "--secret-prompt" },
27450
+ `The ${kind.noun}'s ${kind.secret}`
27451
+ );
27452
+ }
27453
+ function setSecret(client, kind, base, id, value) {
27454
+ return client.request("PUT", secretPath(kind, base, id), { value });
27455
+ }
27456
+ function withSecretSourceOptions(cmd, kind, promptByDefault) {
27457
+ 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)" : ""}`);
27458
+ }
27459
+ async function createHolder(client, kind, base, id, body, opts, format) {
27460
+ let value;
27461
+ if (opts.secretStdin || opts.secretPrompt) {
27462
+ await assertSecretStorageOn(client, kind, base, id);
27463
+ value = await readSecretValue(kind, opts);
27464
+ }
27465
+ const created = await client.request(
27466
+ "PUT",
27467
+ `/v1/${pathSegment(base, "--base")}/${kind.family}/${pathSegment(id, "--id")}`,
27468
+ body
27469
+ );
27470
+ if (value === void 0) {
27471
+ printOutput(created, format);
27472
+ if (kind.leftWithout(created)) warnHoldersWithoutSecret(kind, [id], base);
27473
+ return;
27474
+ }
27475
+ try {
27476
+ printOutput(await setSecret(client, kind, base, id, value), format);
27477
+ } catch (err) {
27478
+ const name = sanitizeTerminalText(id);
27479
+ throw expected(
27480
+ `${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)}.`
27481
+ );
27482
+ }
27483
+ }
27484
+ function addSecretCommands(namespace, kind) {
27485
+ withSecretSourceOptions(
27486
+ namespace.command("set-secret <id>").description(`Set the ${kind.noun}'s ${kind.secret}, ${kind.does}; replaces one it holds`),
27487
+ kind,
27488
+ true
27489
+ ).action(async function(id, opts) {
27490
+ const base = requireBase(this);
27491
+ const client = await createDataClient();
27492
+ await assertSecretStorageOn(client, kind, base, id);
27493
+ printOutput(await setSecret(client, kind, base, id, await readSecretValue(kind, opts)), outputFormat(this));
27494
+ });
27495
+ namespace.command("delete-secret <id>").description(`Delete the ${kind.noun}'s ${kind.secret}`).option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
27496
+ const base = requireBase(this);
27497
+ if (!opts.yes) {
27498
+ if (!isInteractive()) throw expected("Refusing to delete without confirmation \u2014 pass --yes to delete non-interactively.");
27499
+ const ok = await confirm(`Delete the ${kind.secret} of ${kind.noun} ${sanitizeTerminalText(id)} on base ${sanitizeTerminalText(base)}? ${kind.without}`);
27500
+ if (!ok) {
27501
+ console.log("Aborted");
27502
+ return;
27503
+ }
27504
+ }
27505
+ const client = await createDataClient();
27506
+ printOutput(await client.request("DELETE", secretPath(kind, base, id)), outputFormat(this));
27507
+ });
27508
+ }
27509
+ var INBOUND_WEBHOOK_SECRET, TRIGGER_SIGNING_SECRET, setSecretCommand;
27510
+ var init_webhook_secrets = __esm({
27511
+ "src/data/commands/webhook-secrets.ts"() {
27512
+ "use strict";
27513
+ init_expected();
27514
+ init_utils();
27515
+ init_terminal_output();
27516
+ init_client();
27517
+ init_output();
27518
+ init_helpers();
27519
+ init_credentials();
27520
+ INBOUND_WEBHOOK_SECRET = {
27521
+ family: "inbound-webhooks",
27522
+ noun: "inbound webhook",
27523
+ secret: "secret",
27524
+ does: "which verifies its deliveries (the Signing v1 shared secret, or the static header's value)",
27525
+ without: "It then verifies no delivery: each is refused.",
27526
+ lacking: "It verifies no delivery",
27527
+ manyLacking: "Inbound webhooks with no secret, which verify no delivery (each is refused)",
27528
+ manyLackingThen: "",
27529
+ // The webhook's read says whether it holds one: an upsert of an existing webhook keeps its secret.
27530
+ leftWithout: (answer) => answer?.secret_stored !== true
27531
+ };
27532
+ TRIGGER_SIGNING_SECRET = {
27533
+ family: "triggers",
27534
+ noun: "trigger",
27535
+ secret: "signing secret",
27536
+ does: "which signs its deliveries (a webhook trigger only)",
27537
+ without: "Its deliveries then go out unsigned.",
27538
+ lacking: "It delivers unsigned",
27539
+ manyLacking: "Webhook triggers that deliver unsigned, with no X-Data-Signature or X-Data-Timestamp header (they hold no signing secret)",
27540
+ manyLackingThen: "A receiver that verifies signatures will reject their deliveries. ",
27541
+ // The service names a webhook trigger that delivers unsigned; an internal or external write is not one.
27542
+ leftWithout: (answer) => {
27543
+ const warnings = answer?.warnings;
27544
+ return Array.isArray(warnings) && warnings.includes("unsigned_delivery");
27545
+ }
27546
+ };
27547
+ setSecretCommand = (kind, id, base) => `\`wayai ${kind.family} set-secret ${id} --base ${sanitizeTerminalText(base)}\``;
27548
+ }
27549
+ });
27550
+
27319
27551
  // src/data/config-as-code/sync.ts
27320
27552
  var sync_exports = {};
27321
27553
  __export(sync_exports, {
@@ -27513,7 +27745,8 @@ Apply these changes to preview "${sanitizeTerminalText(baseId)}"?`);
27513
27745
  }
27514
27746
  }
27515
27747
  const result = await applyRefusedCredentialsAgain(client, baseId, config);
27516
- warnUnsignedTriggers(result.unsigned_triggers);
27748
+ warnHoldersWithoutSecret(TRIGGER_SIGNING_SECRET, result.unsigned_triggers, baseId);
27749
+ warnHoldersWithoutSecret(INBOUND_WEBHOOK_SECRET, result.inbound_webhooks_without_secret, baseId);
27517
27750
  const removals = collectRemovals(diff);
27518
27751
  if (removals.length > 0) {
27519
27752
  const word = removals.length === 1 ? "entity" : "entities";
@@ -27555,7 +27788,7 @@ var init_sync = __esm({
27555
27788
  init_diff_format();
27556
27789
  init_base_workspace();
27557
27790
  init_types2();
27558
- init_triggers();
27791
+ init_webhook_secrets();
27559
27792
  init_credentials();
27560
27793
  }
27561
27794
  });
@@ -41887,10 +42120,10 @@ var init_case_collection_citations = __esm({
41887
42120
  var init_case_collection_links = __esm({
41888
42121
  "../../packages/core/dist/contracts/case-collection-links.js"() {
41889
42122
  "use strict";
41890
- init_chunk_W2VXSBO2();
41891
- init_chunk_O6OMUGGZ();
41892
- init_chunk_NKJ2DQCV();
42123
+ init_chunk_FPFUDA22();
42124
+ init_chunk_ZZZ65EIA();
41893
42125
  init_chunk_ATX6AHPZ();
42126
+ init_chunk_NKJ2DQCV();
41894
42127
  init_chunk_I6CZPDXO();
41895
42128
  init_chunk_LU4T7K5F();
41896
42129
  init_chunk_74HGW6HA();
@@ -43479,7 +43712,7 @@ var init_case_notes = __esm({
43479
43712
  var init_case_checks = __esm({
43480
43713
  "../../packages/core/dist/contracts/case-checks.js"() {
43481
43714
  "use strict";
43482
- init_chunk_CBPHDU3I();
43715
+ init_chunk_K6O2P77D();
43483
43716
  init_chunk_YR7QALGP();
43484
43717
  init_chunk_HZ6CADSY();
43485
43718
  }
@@ -49473,9 +49706,9 @@ var init_update = __esm({
49473
49706
  });
49474
49707
 
49475
49708
  // src/data/commands/actions.ts
49476
- import { Command as Command3 } from "commander";
49709
+ import { Command as Command2 } from "commander";
49477
49710
  function buildActionsCommand() {
49478
- const actions = new Command3("actions").description(
49711
+ const actions = new Command2("actions").description(
49479
49712
  "Manage Actions \u2014 reusable, named definitions: one record_type + one operation, or a composite of atomic write steps (--config with `steps`)"
49480
49713
  );
49481
49714
  actions.command("upsert <id>").description(
@@ -49544,7 +49777,7 @@ var init_actions = __esm({
49544
49777
  });
49545
49778
 
49546
49779
  // src/data/commands/attachments.ts
49547
- import { Command as Command4 } from "commander";
49780
+ import { Command as Command3 } from "commander";
49548
49781
  import { readFileSync as readFileSync23 } from "fs";
49549
49782
  function findAttachmentByFilename(attachments, filename) {
49550
49783
  return attachments.find((a) => a.key.endsWith(`/${filename}`)) ?? null;
@@ -49571,7 +49804,7 @@ function uploadPathFrom(uploadUrl) {
49571
49804
  return uploadUrl;
49572
49805
  }
49573
49806
  function buildAttachmentsCommand() {
49574
- const attachments = new Command4("attachments").description("Manage record attachments");
49807
+ const attachments = new Command3("attachments").description("Manage record attachments");
49575
49808
  attachments.command("upload <record_type> <id>").description(
49576
49809
  "Get a presigned upload URL for a record attachment. With --file, uploads the file content in one step."
49577
49810
  ).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 +49884,9 @@ var init_attachments = __esm({
49651
49884
  });
49652
49885
 
49653
49886
  // src/data/commands/batch.ts
49654
- import { Command as Command5 } from "commander";
49887
+ import { Command as Command4 } from "commander";
49655
49888
  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) {
49889
+ 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
49890
  const base = pathSegment(requireBase(this), "--base");
49658
49891
  const operations = parseData(opts.operations, "--operations");
49659
49892
  const client = await createDataClient();
@@ -49681,8 +49914,8 @@ var init_batch = __esm({
49681
49914
  import { createReadStream } from "fs";
49682
49915
  import { access, constants as constants2, stat } from "fs/promises";
49683
49916
  import { createInterface as createInterface3 } from "readline";
49684
- import { randomUUID as randomUUID2 } from "crypto";
49685
- import { Command as Command6 } from "commander";
49917
+ import { randomUUID } from "crypto";
49918
+ import { Command as Command5 } from "commander";
49686
49919
  function isRetryable(err) {
49687
49920
  if (isNetworkError(err)) return true;
49688
49921
  if (!(err instanceof ApiError)) return false;
@@ -49758,7 +49991,7 @@ async function beginSession(state, client, base, recordType2, requestKey) {
49758
49991
  return res.session;
49759
49992
  }
49760
49993
  function buildBasesImportCommand() {
49761
- const importCmd = withBaseOption(new Command6("import")).description(
49994
+ const importCmd = withBaseOption(new Command5("import")).description(
49762
49995
  "Bulk historical import: load an NDJSON backfill, list sessions, or undo one"
49763
49996
  );
49764
49997
  importCmd.command("run <record_type>").description(
@@ -49797,7 +50030,7 @@ function buildBasesImportCommand() {
49797
50030
  throw expected(`--file ${opts.file}: not a readable file.`);
49798
50031
  }
49799
50032
  const client = await createDataClient();
49800
- const requestKey = opts.requestKey ?? `cli-${randomUUID2()}`;
50033
+ const requestKey = opts.requestKey ?? `cli-${randomUUID()}`;
49801
50034
  if (!opts.requestKey) {
49802
50035
  console.error(`request_key: ${requestKey} (pass --request-key to resume this run)`);
49803
50036
  }
@@ -50002,7 +50235,7 @@ var init_import = __esm({
50002
50235
  });
50003
50236
 
50004
50237
  // src/data/commands/providers.ts
50005
- import { Command as Command7 } from "commander";
50238
+ import { Command as Command6 } from "commander";
50006
50239
  import { writeFileSync as writeFileSync13 } from "fs";
50007
50240
  function providerSegment(provider) {
50008
50241
  if (!VALID_PROVIDERS.includes(provider)) {
@@ -50011,7 +50244,7 @@ function providerSegment(provider) {
50011
50244
  return pathSegment(provider, "provider");
50012
50245
  }
50013
50246
  function buildBasesProvidersCommand() {
50014
- const providers = withBaseOption(new Command7("providers")).description(
50247
+ const providers = withBaseOption(new Command6("providers")).description(
50015
50248
  "Import/export tool definitions between LLM providers and record types"
50016
50249
  );
50017
50250
  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 +50315,10 @@ var init_providers = __esm({
50082
50315
  });
50083
50316
 
50084
50317
  // src/data/commands/sql.ts
50085
- import { Command as Command8 } from "commander";
50318
+ import { Command as Command7 } from "commander";
50086
50319
  import { readFileSync as readFileSync24 } from "fs";
50087
50320
  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(
50321
+ 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
50322
  "--param <kv...>",
50090
50323
  "Named parameters as key=value pairs (e.g. --param status=issued)"
50091
50324
  ).action(async function(queryArg, opts) {
@@ -50128,7 +50361,7 @@ var init_sql = __esm({
50128
50361
  });
50129
50362
 
50130
50363
  // src/data/commands/tokens.ts
50131
- import { Command as Command9 } from "commander";
50364
+ import { Command as Command8 } from "commander";
50132
50365
  function rawTokenFrom(data) {
50133
50366
  const token = typeof data === "object" && data !== null && "token" in data ? data.token : void 0;
50134
50367
  if (typeof token !== "string" || !RAW_TOKEN_PATTERN.test(token)) {
@@ -50186,7 +50419,7 @@ function pruneRow(t, reason3) {
50186
50419
  };
50187
50420
  }
50188
50421
  function buildBasesTokensCommand() {
50189
- const tokens2 = new Command9("tokens").description("Manage API tokens");
50422
+ const tokens2 = new Command8("tokens").description("Manage API tokens");
50190
50423
  addTokenLifecycleOptions(
50191
50424
  tokens2.command("create").description("Create a scoped API token").requiredOption("--name <name>", "Token name").requiredOption("--grants <json>", "Grant definitions as JSON array").option(
50192
50425
  "--token-only",
@@ -50428,7 +50661,7 @@ var init_base_tags = __esm({
50428
50661
  });
50429
50662
 
50430
50663
  // src/data/commands/bases.ts
50431
- import { Command as Command10 } from "commander";
50664
+ import { Command as Command9 } from "commander";
50432
50665
  function pageOf(path55, cursor) {
50433
50666
  if (!cursor) return path55;
50434
50667
  return `${path55}${path55.includes("?") ? "&" : "?"}cursor=${encodeURIComponent(cursor)}`;
@@ -50441,7 +50674,7 @@ function parseEnum(flag, value, allowed) {
50441
50674
  return value;
50442
50675
  }
50443
50676
  function buildBasesCommand() {
50444
- const bases = new Command10("bases").description("Manage bases");
50677
+ const bases = new Command9("bases").description("Manage bases");
50445
50678
  bases.command("list").description("List all bases").option("--tag <tag>", "Filter by tag").action(async function(opts) {
50446
50679
  const client = await createDataClient();
50447
50680
  const qs = opts.tag ? `?tag=${encodeURIComponent(opts.tag)}` : "";
@@ -50615,7 +50848,8 @@ function buildBasesCommand() {
50615
50848
  console.warn("\nReferenced credentials production cannot use:");
50616
50849
  for (const w of unresolved) console.warn(` - ${sanitizeTerminalText(w.message)}`);
50617
50850
  }
50618
- warnUnsignedTriggers(data?.unsigned_triggers);
50851
+ warnHoldersWithoutSecret(TRIGGER_SIGNING_SECRET, data?.unsigned_triggers, productionId);
50852
+ warnHoldersWithoutSecret(INBOUND_WEBHOOK_SECRET, data?.inbound_webhooks_without_secret, productionId);
50619
50853
  });
50620
50854
  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
50855
  const client = await createDataClient();
@@ -50625,7 +50859,8 @@ function buildBasesCommand() {
50625
50859
  { promotion_id: opts.promotion }
50626
50860
  );
50627
50861
  printOutput(data, outputFormat(this));
50628
- warnUnsignedTriggers(data?.unsigned_triggers);
50862
+ warnHoldersWithoutSecret(TRIGGER_SIGNING_SECRET, data?.unsigned_triggers, productionId);
50863
+ warnHoldersWithoutSecret(INBOUND_WEBHOOK_SECRET, data?.inbound_webhooks_without_secret, productionId);
50629
50864
  });
50630
50865
  bases.command("promotions <production-id>").description("List promotion history for a production base").action(async function(productionId) {
50631
50866
  const client = await createDataClient();
@@ -50700,7 +50935,7 @@ var init_bases = __esm({
50700
50935
  init_helpers();
50701
50936
  init_utils();
50702
50937
  init_terminal_output();
50703
- init_triggers();
50938
+ init_webhook_secrets();
50704
50939
  init_workspace();
50705
50940
  init_base_workspace();
50706
50941
  init_worktree_scope();
@@ -50709,9 +50944,9 @@ var init_bases = __esm({
50709
50944
  });
50710
50945
 
50711
50946
  // src/data/commands/file-types.ts
50712
- import { Command as Command11 } from "commander";
50947
+ import { Command as Command10 } from "commander";
50713
50948
  function buildFileTypesCommand() {
50714
- const fileTypes = new Command11("file-types").description(
50949
+ const fileTypes = new Command10("file-types").description(
50715
50950
  "Manage file types (Buckets) \u2014 storage policy + optional metadata schema for files"
50716
50951
  );
50717
50952
  fileTypes.command("list").description("List all file types in a base").action(async function() {
@@ -50771,7 +51006,7 @@ var init_file_types = __esm({
50771
51006
  });
50772
51007
 
50773
51008
  // src/data/commands/files.ts
50774
- import { Command as Command12 } from "commander";
51009
+ import { Command as Command11 } from "commander";
50775
51010
  import { readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "fs";
50776
51011
  import { basename as basename31 } from "path";
50777
51012
  function renderFileDiff(fileType, filePath3, from, to, d) {
@@ -50814,7 +51049,7 @@ function downloadTarget(remotePath2, to) {
50814
51049
  return derived;
50815
51050
  }
50816
51051
  function buildFilesCommand() {
50817
- const files = new Command12("files").description(
51052
+ const files = new Command11("files").description(
50818
51053
  "Manage files (path-addressed, versioned content) within a file type"
50819
51054
  );
50820
51055
  files.command("put <file_type> <path>").description(
@@ -51021,25 +51256,38 @@ var init_files2 = __esm({
51021
51256
  });
51022
51257
 
51023
51258
  // src/data/commands/inbound-webhooks.ts
51024
- import { Command as Command13 } from "commander";
51259
+ import { randomUUID as randomUUID2 } from "crypto";
51260
+ import { Command as Command12 } from "commander";
51025
51261
  function buildInboundWebhooksCommand() {
51026
- const inboundWebhooks = new Command13("inbound-webhooks").description(
51262
+ const inboundWebhooks = new Command12("inbound-webhooks").description(
51027
51263
  "Manage inbound webhook endpoints"
51028
51264
  );
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);
51265
+ withSecretSourceOptions(
51266
+ 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(
51267
+ "--field-mapping <json>",
51268
+ '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.'
51269
+ ).option(
51270
+ "--source-binding <json>",
51271
+ `Reuse a record_type source's field_mapping for the inbound translation \u2014 {"record_type":"<id>","source":"<name>"}. Mutually exclusive with --field-mapping.`
51272
+ ).option(
51273
+ "--ingest-auth <json>",
51274
+ '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.'
51275
+ ).option(
51276
+ "--hydration <json>",
51277
+ `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.`
51278
+ ),
51279
+ INBOUND_WEBHOOK_SECRET,
51280
+ false
51281
+ ).action(async function(opts) {
51282
+ const body = { name: opts.name, enabled: true };
51283
+ if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
51284
+ if (opts.fieldMapping) body.field_mapping = parseData(opts.fieldMapping);
51285
+ if (opts.sourceBinding) body.source_binding = parseData(opts.sourceBinding);
51286
+ if (opts.ingestAuth) body.ingest_auth = parseData(opts.ingestAuth);
51287
+ if (opts.hydration) body.hydration = parseData(opts.hydration);
51288
+ const base = requireBase(this);
51289
+ const client = await createDataClient();
51290
+ await createHolder(client, INBOUND_WEBHOOK_SECRET, base, opts.id ?? randomUUID2(), body, opts, outputFormat(this));
51043
51291
  });
51044
51292
  inboundWebhooks.command("get <id>").description("Get an inbound webhook").action(async function(id) {
51045
51293
  const base = pathSegment(requireBase(this), "--base");
@@ -51078,25 +51326,24 @@ function buildInboundWebhooksCommand() {
51078
51326
  await client.request("DELETE", `/v1/${base}/inbound-webhooks/${pathSegment(id, "inbound webhook id")}`);
51079
51327
  console.log("Deleted");
51080
51328
  });
51329
+ addSecretCommands(inboundWebhooks, INBOUND_WEBHOOK_SECRET);
51081
51330
  return inboundWebhooks;
51082
51331
  }
51083
- var CREATE_UNAVAILABLE;
51084
51332
  var init_inbound_webhooks = __esm({
51085
51333
  "src/data/commands/inbound-webhooks.ts"() {
51086
51334
  "use strict";
51087
- init_expected();
51088
51335
  init_client();
51089
51336
  init_output();
51090
51337
  init_helpers();
51091
51338
  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.`;
51339
+ init_webhook_secrets();
51093
51340
  }
51094
51341
  });
51095
51342
 
51096
51343
  // src/data/commands/query-relationships.ts
51097
- import { Command as Command14 } from "commander";
51344
+ import { Command as Command13 } from "commander";
51098
51345
  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) {
51346
+ 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
51347
  const base = pathSegment(requireBase(this), "--base");
51101
51348
  const client = await createDataClient();
51102
51349
  const params = new URLSearchParams();
@@ -51129,9 +51376,9 @@ var init_query_relationships = __esm({
51129
51376
  });
51130
51377
 
51131
51378
  // src/data/commands/record-types.ts
51132
- import { Command as Command15 } from "commander";
51379
+ import { Command as Command14 } from "commander";
51133
51380
  function buildRecordTypesCommand() {
51134
- const recordTypes = new Command15("record-types").description("Manage record_types");
51381
+ const recordTypes = new Command14("record-types").description("Manage record_types");
51135
51382
  recordTypes.command("list").description("List all record_types in a base").action(async function() {
51136
51383
  const base = pathSegment(requireBase(this), "--base");
51137
51384
  const client = await createDataClient();
@@ -51189,12 +51436,12 @@ var init_record_types = __esm({
51189
51436
  });
51190
51437
 
51191
51438
  // src/data/commands/records.ts
51192
- import { Command as Command16 } from "commander";
51439
+ import { Command as Command15 } from "commander";
51193
51440
  function recordKey(id, externalSource) {
51194
51441
  return externalSource ? foreignSegment(id, "external id") : pathSegment(id, "record id");
51195
51442
  }
51196
51443
  function buildRecordsCommand() {
51197
- const records = new Command16("records").description("Manage records");
51444
+ const records = new Command15("records").description("Manage records");
51198
51445
  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
51446
  const base = pathSegment(requireBase(this), "--base");
51200
51447
  const client = await createDataClient();
@@ -51283,9 +51530,9 @@ var init_records = __esm({
51283
51530
  });
51284
51531
 
51285
51532
  // src/data/commands/relationship-types.ts
51286
- import { Command as Command17 } from "commander";
51533
+ import { Command as Command16 } from "commander";
51287
51534
  function buildRelationshipTypesCommand() {
51288
- const relationshipTypes = new Command17("relationship-types").description(
51535
+ const relationshipTypes = new Command16("relationship-types").description(
51289
51536
  "Manage relationship types (the schema for a relationship's metadata)"
51290
51537
  );
51291
51538
  relationshipTypes.command("list").description("List all relationship types in a base").action(async function() {
@@ -51362,7 +51609,7 @@ var init_relationship_types = __esm({
51362
51609
  });
51363
51610
 
51364
51611
  // src/data/commands/relationships.ts
51365
- import { Command as Command18 } from "commander";
51612
+ import { Command as Command17 } from "commander";
51366
51613
  function relationshipKey(id, relType) {
51367
51614
  return relType ? foreignSegment(id, "external id") : pathSegment(id, "relationship id");
51368
51615
  }
@@ -51398,7 +51645,7 @@ function byKeyQuery(relType, externalSource) {
51398
51645
  return q ? `?${q}` : "";
51399
51646
  }
51400
51647
  function buildRelationshipsCommand() {
51401
- const relationships = new Command18("relationships").description(
51648
+ const relationships = new Command17("relationships").description(
51402
51649
  "Manage relationships between records"
51403
51650
  );
51404
51651
  relationships.command("upsert").description("Create or update a relationship").option("--source <record_type/id>", "Source record by internal id").option(
@@ -51483,9 +51730,9 @@ var init_relationships = __esm({
51483
51730
  });
51484
51731
 
51485
51732
  // src/data/commands/seed.ts
51486
- import { Command as Command19 } from "commander";
51733
+ import { Command as Command18 } from "commander";
51487
51734
  function buildSeedCommand() {
51488
- const seed = new Command19("seed").description(
51735
+ const seed = new Command18("seed").description(
51489
51736
  "Apply, reset, or clear a seed fixture on a preview base (hermetic eval data)"
51490
51737
  );
51491
51738
  seed.command("apply <name>").description(
@@ -51577,7 +51824,7 @@ var init_seed = __esm({
51577
51824
  });
51578
51825
 
51579
51826
  // src/data/commands/toolsets.ts
51580
- import { Command as Command20 } from "commander";
51827
+ import { Command as Command19 } from "commander";
51581
51828
  function collect(value, previous) {
51582
51829
  return [...previous, value];
51583
51830
  }
@@ -51600,7 +51847,7 @@ function parseRelSpec(spec) {
51600
51847
  return { rel_type: key, operations: ops };
51601
51848
  }
51602
51849
  function buildToolsetsCommand() {
51603
- const toolsets = new Command20("toolsets").description("Manage MCP toolsets");
51850
+ const toolsets = new Command19("toolsets").description("Manage MCP toolsets");
51604
51851
  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
51852
  "--action <ref>",
51606
51853
  "Reference an Action by id, optionally renamed: <action_id> or <action_id>=<surface_name> (repeatable). Create Actions first with `wayai actions upsert`.",
@@ -51690,6 +51937,99 @@ var init_toolsets = __esm({
51690
51937
  }
51691
51938
  });
51692
51939
 
51940
+ // src/data/commands/triggers.ts
51941
+ import { randomUUID as randomUUID3 } from "crypto";
51942
+ import { Command as Command20 } from "commander";
51943
+ function buildTriggersCommand() {
51944
+ const triggers = new Command20("triggers").description(
51945
+ "Manage triggers (outbound webhooks, internal writes, external writes)"
51946
+ );
51947
+ withSecretSourceOptions(
51948
+ triggers.command("create").description(
51949
+ "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)"
51950
+ ).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(
51951
+ "--action <json>",
51952
+ `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)`
51953
+ ).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(
51954
+ "--skip-cascade-writes <bool>",
51955
+ "Skip firing on cascade-originated (internal_write) writes (default true)"
51956
+ ),
51957
+ TRIGGER_SIGNING_SECRET,
51958
+ false
51959
+ ).action(async function(opts) {
51960
+ if (!opts.action && !opts.url) {
51961
+ throw expected("Provide --url (webhook) or --action <json> (e.g. an internal_write action).");
51962
+ }
51963
+ const body = {
51964
+ name: opts.name,
51965
+ events: splitList(opts.events),
51966
+ enabled: true
51967
+ };
51968
+ if (opts.action) {
51969
+ body.action = parseData(opts.action);
51970
+ } else {
51971
+ body.url = opts.url;
51972
+ }
51973
+ if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
51974
+ if (opts.filter) body.filter = parseData(opts.filter);
51975
+ if (opts.skipCascadeWrites !== void 0) {
51976
+ body.skip_cascade_writes = opts.skipCascadeWrites !== "false";
51977
+ }
51978
+ const type = body.action?.type;
51979
+ if ((opts.secretStdin || opts.secretPrompt) && type !== void 0 && type !== "webhook") {
51980
+ throw expected("Only a webhook trigger takes a signing secret: omit --secret-stdin and --secret-prompt. Nothing was read or stored.");
51981
+ }
51982
+ const base = requireBase(this);
51983
+ const client = await createDataClient();
51984
+ await createHolder(client, TRIGGER_SIGNING_SECRET, base, opts.id ?? randomUUID3(), body, opts, outputFormat(this));
51985
+ });
51986
+ triggers.command("get <id>").description("Get a trigger").action(async function(id) {
51987
+ const base = pathSegment(requireBase(this), "--base");
51988
+ const client = await createDataClient();
51989
+ printOutput(await client.request("GET", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`), outputFormat(this));
51990
+ });
51991
+ triggers.command("list").description("List all triggers").action(async function() {
51992
+ const base = pathSegment(requireBase(this), "--base");
51993
+ const client = await createDataClient();
51994
+ printOutput(await client.request("GET", `/v1/${base}/triggers`), outputFormat(this));
51995
+ });
51996
+ 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) {
51997
+ const base = pathSegment(requireBase(this), "--base");
51998
+ const client = await createDataClient();
51999
+ const params = new URLSearchParams();
52000
+ if (opts.status) params.set("status", opts.status);
52001
+ if (opts.triggerId) params.set("trigger_id", opts.triggerId);
52002
+ const qs = params.toString();
52003
+ printOutput(
52004
+ await client.request("GET", `/v1/${base}/triggers/deliveries${qs ? `?${qs}` : ""}`),
52005
+ outputFormat(this)
52006
+ );
52007
+ });
52008
+ triggers.command("delete <id>").description("Delete a trigger").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
52009
+ if (!opts.yes && !await confirm(`Delete trigger ${id}? This cannot be undone.`)) {
52010
+ console.log("Aborted");
52011
+ return;
52012
+ }
52013
+ const base = pathSegment(requireBase(this), "--base");
52014
+ const client = await createDataClient();
52015
+ await client.request("DELETE", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`);
52016
+ console.log("Deleted");
52017
+ });
52018
+ addSecretCommands(triggers, TRIGGER_SIGNING_SECRET);
52019
+ return triggers;
52020
+ }
52021
+ var init_triggers = __esm({
52022
+ "src/data/commands/triggers.ts"() {
52023
+ "use strict";
52024
+ init_expected();
52025
+ init_client();
52026
+ init_output();
52027
+ init_helpers();
52028
+ init_utils();
52029
+ init_webhook_secrets();
52030
+ }
52031
+ });
52032
+
51693
52033
  // src/data/program.ts
51694
52034
  var program_exports = {};
51695
52035
  __export(program_exports, {