@wayai/cli 0.3.350 → 0.3.352

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
@@ -5363,6 +5363,13 @@ var init_chunk_Q7KIQHAZ = __esm({
5363
5363
  }
5364
5364
  });
5365
5365
 
5366
+ // ../../packages/core/dist/chunk-63UWXV4T.js
5367
+ var init_chunk_63UWXV4T = __esm({
5368
+ "../../packages/core/dist/chunk-63UWXV4T.js"() {
5369
+ "use strict";
5370
+ }
5371
+ });
5372
+
5366
5373
  // ../../packages/core/dist/chunk-AYLAGFAD.js
5367
5374
  var BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema;
5368
5375
  var init_chunk_AYLAGFAD = __esm({
@@ -6332,10 +6339,22 @@ var init_chunk_IPXBFWUU = __esm({
6332
6339
  }
6333
6340
  });
6334
6341
 
6335
- // ../../packages/core/dist/chunk-63UWXV4T.js
6336
- var init_chunk_63UWXV4T = __esm({
6337
- "../../packages/core/dist/chunk-63UWXV4T.js"() {
6342
+ // ../../packages/core/dist/chunk-TVUDMGWV.js
6343
+ var bootstrapQuery;
6344
+ var init_chunk_TVUDMGWV = __esm({
6345
+ "../../packages/core/dist/chunk-TVUDMGWV.js"() {
6338
6346
  "use strict";
6347
+ init_zod();
6348
+ bootstrapQuery = external_exports.object({
6349
+ active_hub_id: external_exports.string().uuid().optional(),
6350
+ active_conversation_id: external_exports.string().uuid().optional(),
6351
+ active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
6352
+ /**
6353
+ * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
6354
+ * preloads it as `people.active_thread` when the viewer is a member.
6355
+ */
6356
+ active_thread_id: external_exports.string().uuid().optional()
6357
+ });
6339
6358
  }
6340
6359
  });
6341
6360
 
@@ -6491,6 +6510,231 @@ var init_chunk_ZC6YGHNX = __esm({
6491
6510
  }
6492
6511
  });
6493
6512
 
6513
+ // ../../packages/core/dist/chunk-2YEGUQR7.js
6514
+ var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
6515
+ var init_chunk_2YEGUQR7 = __esm({
6516
+ "../../packages/core/dist/chunk-2YEGUQR7.js"() {
6517
+ "use strict";
6518
+ init_zod();
6519
+ PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
6520
+ CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
6521
+ PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
6522
+ userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
6523
+ personIdSchema = external_exports.string().refine(
6524
+ (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
6525
+ { message: PERSON_ID_FORM_MESSAGE }
6526
+ );
6527
+ }
6528
+ });
6529
+
6530
+ // ../../packages/core/dist/chunk-UAOHHCW5.js
6531
+ function normalizeContactPhone(raw) {
6532
+ const compact = raw.trim().replace(/[\s\-.()]/g, "");
6533
+ const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
6534
+ return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
6535
+ }
6536
+ function normalizeContactLabel(raw) {
6537
+ return raw.trim().replace(/\s+/g, " ").toLowerCase();
6538
+ }
6539
+ function importRowLabels(row, batchLabels) {
6540
+ return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
6541
+ }
6542
+ var CONTACT_ENVIRONMENTS, CONTACT_NAME_MAX, CONTACT_EMAIL_MAX, CONTACT_PHONE_INPUT_MAX, CONTACT_INSTAGRAM_SID_MAX, CONTACT_METADATA_MAX_BYTES, CONTACT_LABEL_MAX, CONTACT_LABELS_MAX, CONTACT_SCOPE_TAGS_MAX, CONTACT_PAGE_MAX, CONTACT_IMPORT_BATCH_MAX, CONTACT_SEARCH_MAX, CONTACT_LIST_NAME_MAX, CONTACT_LIST_NAME_REGEX, CONTACT_LIST_DESCRIPTION_MAX, CONTACT_LIST_FILTER_MAX, CONTACT_LIST_PINS_PER_REQUEST_MAX, SUPPRESSION_SCOPES, SUPPRESSION_ID_REGEX, contactName, contactPhone, contactEmail, contactInstagramSid, contactLabel, contactLabels, contactMetadata, scopeTagIds, contactVisibilitySchema, hasIdentity, IDENTITY_REQUIRED, contactBookOrgQuery, contactBookContactParam, contactBookListParam, contactBookHubParam, contactBookPageQuery, listContactBookContactsQuery, listHubContactBookContactsQuery, contactBookLinkCandidatesQuery, listContactBookListMembersQuery, contactRowFields, createContactBookContactBody, updateContactBookContactBody, contactImportRowSchema, importContactBookContactsBody, linkContactBookContactBody, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
6543
+ var init_chunk_UAOHHCW5 = __esm({
6544
+ "../../packages/core/dist/chunk-UAOHHCW5.js"() {
6545
+ "use strict";
6546
+ init_zod();
6547
+ CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
6548
+ CONTACT_NAME_MAX = 200;
6549
+ CONTACT_EMAIL_MAX = 320;
6550
+ CONTACT_PHONE_INPUT_MAX = 40;
6551
+ CONTACT_INSTAGRAM_SID_MAX = 64;
6552
+ CONTACT_METADATA_MAX_BYTES = 4096;
6553
+ CONTACT_LABEL_MAX = 64;
6554
+ CONTACT_LABELS_MAX = 20;
6555
+ CONTACT_SCOPE_TAGS_MAX = 20;
6556
+ CONTACT_PAGE_MAX = 100;
6557
+ CONTACT_IMPORT_BATCH_MAX = 500;
6558
+ CONTACT_SEARCH_MAX = 100;
6559
+ CONTACT_LIST_NAME_MAX = 64;
6560
+ CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
6561
+ CONTACT_LIST_DESCRIPTION_MAX = 1e3;
6562
+ CONTACT_LIST_FILTER_MAX = 20;
6563
+ CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
6564
+ SUPPRESSION_SCOPES = ["all", "marketing"];
6565
+ SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
6566
+ contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
6567
+ contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
6568
+ const phone = normalizeContactPhone(raw);
6569
+ if (phone === null) {
6570
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
6571
+ return external_exports.NEVER;
6572
+ }
6573
+ return phone;
6574
+ });
6575
+ contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
6576
+ contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
6577
+ contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label3) => label3.length > 0, "A label cannot be empty").refine((label3) => !label3.includes(","), "A label cannot contain a comma");
6578
+ contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
6579
+ contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
6580
+ try {
6581
+ return new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES;
6582
+ } catch {
6583
+ return false;
6584
+ }
6585
+ }, `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`);
6586
+ scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
6587
+ contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
6588
+ external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
6589
+ external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
6590
+ ]);
6591
+ hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
6592
+ IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
6593
+ contactBookOrgQuery = external_exports.object({
6594
+ organization_id: external_exports.string().uuid()
6595
+ });
6596
+ contactBookContactParam = external_exports.object({
6597
+ contactId: external_exports.string().uuid()
6598
+ });
6599
+ contactBookListParam = external_exports.object({
6600
+ listId: external_exports.string().uuid()
6601
+ });
6602
+ contactBookHubParam = external_exports.object({
6603
+ hubId: external_exports.string().uuid()
6604
+ });
6605
+ contactBookPageQuery = external_exports.object({
6606
+ cursor: external_exports.string().max(2048).optional(),
6607
+ limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
6608
+ });
6609
+ listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
6610
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
6611
+ label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
6612
+ scope_tag_id: external_exports.string().uuid().optional()
6613
+ });
6614
+ listHubContactBookContactsQuery = contactBookPageQuery.extend({
6615
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
6616
+ });
6617
+ contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
6618
+ email: contactEmail
6619
+ });
6620
+ listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6621
+ contactRowFields = {
6622
+ name: contactName,
6623
+ phone: contactPhone.nullish(),
6624
+ email: contactEmail.nullish(),
6625
+ instagram_sid: contactInstagramSid.nullish(),
6626
+ labels: contactLabels.optional(),
6627
+ metadata: contactMetadata.optional()
6628
+ };
6629
+ createContactBookContactBody = external_exports.object({
6630
+ organization_id: external_exports.string().uuid(),
6631
+ ...contactRowFields,
6632
+ visibility: contactVisibilitySchema,
6633
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6634
+ }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6635
+ updateContactBookContactBody = external_exports.object({
6636
+ name: contactName.optional(),
6637
+ phone: contactPhone.nullable().optional(),
6638
+ email: contactEmail.nullable().optional(),
6639
+ instagram_sid: contactInstagramSid.nullable().optional(),
6640
+ labels: contactLabels.optional(),
6641
+ metadata: contactMetadata.optional(),
6642
+ visibility: contactVisibilitySchema.optional(),
6643
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6644
+ }).strict();
6645
+ contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6646
+ importContactBookContactsBody = external_exports.object({
6647
+ organization_id: external_exports.string().uuid(),
6648
+ visibility: contactVisibilitySchema,
6649
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
6650
+ labels: contactLabels.optional(),
6651
+ rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
6652
+ }).strict().superRefine((batch, ctx) => {
6653
+ batch.rows.forEach((row, index) => {
6654
+ if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
6655
+ ctx.addIssue({
6656
+ code: external_exports.ZodIssueCode.custom,
6657
+ path: ["rows", index, "labels"],
6658
+ message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
6659
+ });
6660
+ }
6661
+ });
6662
+ });
6663
+ linkContactBookContactBody = external_exports.object({
6664
+ user_id: external_exports.string().min(1).max(128)
6665
+ }).strict();
6666
+ listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
6667
+ message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
6668
+ });
6669
+ contactListFilterSchema = external_exports.object({
6670
+ labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
6671
+ scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
6672
+ }).strict();
6673
+ createContactBookListBody = external_exports.object({
6674
+ organization_id: external_exports.string().uuid(),
6675
+ name: listName,
6676
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
6677
+ filter: contactListFilterSchema.optional()
6678
+ }).strict();
6679
+ updateContactBookListBody = external_exports.object({
6680
+ name: listName.optional(),
6681
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
6682
+ filter: contactListFilterSchema.optional()
6683
+ }).strict();
6684
+ updateContactBookListPinsBody = external_exports.object({
6685
+ add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
6686
+ remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
6687
+ }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
6688
+ suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
6689
+ external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
6690
+ external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
6691
+ external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
6692
+ ]);
6693
+ createContactBookSuppressionBody = external_exports.object({
6694
+ organization_id: external_exports.string().uuid(),
6695
+ identity: suppressionIdentitySchema,
6696
+ scope: external_exports.enum(SUPPRESSION_SCOPES)
6697
+ }).strict();
6698
+ contactBookSuppressionParam = external_exports.object({
6699
+ suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
6700
+ });
6701
+ listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6702
+ contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
6703
+ contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
6704
+ orgListReferenceSchema = listName;
6705
+ }
6706
+ });
6707
+
6708
+ // ../../packages/core/dist/chunk-MGBAXT5Y.js
6709
+ var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery, conversationCustomerPersonParam;
6710
+ var init_chunk_MGBAXT5Y = __esm({
6711
+ "../../packages/core/dist/chunk-MGBAXT5Y.js"() {
6712
+ "use strict";
6713
+ init_chunk_2YEGUQR7();
6714
+ init_chunk_UAOHHCW5();
6715
+ init_zod();
6716
+ PERSON_LINKS_MAX = 15;
6717
+ PERSON_DENY_PAGE_MAX = 100;
6718
+ personParam = external_exports.object({
6719
+ personId: userPersonIdSchema
6720
+ });
6721
+ personLinkParam = personParam.extend({
6722
+ targetId: personIdSchema
6723
+ });
6724
+ deniedPersonParam = external_exports.object({
6725
+ personId: personIdSchema
6726
+ });
6727
+ listDeniedPersonsQuery = contactBookOrgQuery.extend({
6728
+ cursor: personIdSchema.optional(),
6729
+ limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
6730
+ });
6731
+ conversationCustomerPersonParam = external_exports.object({
6732
+ hubId: external_exports.string().uuid(),
6733
+ conversationId: external_exports.string().uuid()
6734
+ });
6735
+ }
6736
+ });
6737
+
6494
6738
  // ../../packages/core/dist/chunk-5DGHIY7L.js
6495
6739
  var rekorBaseChangeMessageSchema;
6496
6740
  var init_chunk_5DGHIY7L = __esm({
@@ -7449,22 +7693,41 @@ var init_chunk_PFGVH2CX = __esm({
7449
7693
  }
7450
7694
  });
7451
7695
 
7452
- // ../../packages/core/dist/chunk-TVUDMGWV.js
7453
- var bootstrapQuery;
7454
- var init_chunk_TVUDMGWV = __esm({
7455
- "../../packages/core/dist/chunk-TVUDMGWV.js"() {
7696
+ // ../../packages/core/dist/chunk-FPSDNS2E.js
7697
+ var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
7698
+ var init_chunk_FPSDNS2E = __esm({
7699
+ "../../packages/core/dist/chunk-FPSDNS2E.js"() {
7456
7700
  "use strict";
7457
7701
  init_zod();
7458
- bootstrapQuery = external_exports.object({
7459
- active_hub_id: external_exports.string().uuid().optional(),
7460
- active_conversation_id: external_exports.string().uuid().optional(),
7461
- active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
7462
- /**
7463
- * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
7464
- * preloads it as `people.active_thread` when the viewer is a member.
7465
- */
7466
- active_thread_id: external_exports.string().uuid().optional()
7702
+ noticeSeveritySchema = external_exports.enum(["critical", "warn", "info"]);
7703
+ noticeStatusSchema = external_exports.enum(["active", "resolved"]);
7704
+ NOTICE_SCOPE_REGEX = /^(global|provider:[a-z0-9_-]{1,40}|service:[a-z0-9_-]{1,40})$/;
7705
+ noticeScopeSchema = external_exports.string().regex(NOTICE_SCOPE_REGEX, "scope must be 'global', 'provider:<x>', or 'service:<x>'");
7706
+ noticeLinkSchema = external_exports.string().url().refine((u) => /^https?:\/\//i.test(u), { message: "link must be an http(s) URL" });
7707
+ createNoticeBody = external_exports.object({
7708
+ severity: noticeSeveritySchema.default("info"),
7709
+ scope: noticeScopeSchema.default("global"),
7710
+ title: external_exports.string().trim().min(1).max(200),
7711
+ body: external_exports.string().max(2e3).optional(),
7712
+ link: noticeLinkSchema.optional(),
7713
+ starts_at: external_exports.string().datetime().optional(),
7714
+ ends_at: external_exports.string().datetime().optional()
7715
+ });
7716
+ updateNoticeBody = external_exports.object({
7717
+ severity: noticeSeveritySchema.optional(),
7718
+ scope: noticeScopeSchema.optional(),
7719
+ title: external_exports.string().trim().min(1).max(200).optional(),
7720
+ body: external_exports.string().max(2e3).nullable().optional(),
7721
+ link: noticeLinkSchema.nullable().optional(),
7722
+ starts_at: external_exports.string().datetime().optional(),
7723
+ ends_at: external_exports.string().datetime().nullable().optional()
7724
+ }).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be provided" });
7725
+ listNoticesQuery = external_exports.object({
7726
+ status: noticeStatusSchema.optional(),
7727
+ limit: external_exports.coerce.number().int().min(1).max(200).optional(),
7728
+ offset: external_exports.coerce.number().int().min(0).optional()
7467
7729
  });
7730
+ noticeIdParamSchema = external_exports.object({ id: external_exports.string().min(1) });
7468
7731
  }
7469
7732
  });
7470
7733
 
@@ -7974,231 +8237,6 @@ var init_chunk_Y7CFCYX4 = __esm({
7974
8237
  }
7975
8238
  });
7976
8239
 
7977
- // ../../packages/core/dist/chunk-2YEGUQR7.js
7978
- var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
7979
- var init_chunk_2YEGUQR7 = __esm({
7980
- "../../packages/core/dist/chunk-2YEGUQR7.js"() {
7981
- "use strict";
7982
- init_zod();
7983
- PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
7984
- CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
7985
- PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
7986
- userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
7987
- personIdSchema = external_exports.string().refine(
7988
- (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
7989
- { message: PERSON_ID_FORM_MESSAGE }
7990
- );
7991
- }
7992
- });
7993
-
7994
- // ../../packages/core/dist/chunk-UAOHHCW5.js
7995
- function normalizeContactPhone(raw) {
7996
- const compact = raw.trim().replace(/[\s\-.()]/g, "");
7997
- const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
7998
- return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
7999
- }
8000
- function normalizeContactLabel(raw) {
8001
- return raw.trim().replace(/\s+/g, " ").toLowerCase();
8002
- }
8003
- function importRowLabels(row, batchLabels) {
8004
- return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
8005
- }
8006
- var CONTACT_ENVIRONMENTS, CONTACT_NAME_MAX, CONTACT_EMAIL_MAX, CONTACT_PHONE_INPUT_MAX, CONTACT_INSTAGRAM_SID_MAX, CONTACT_METADATA_MAX_BYTES, CONTACT_LABEL_MAX, CONTACT_LABELS_MAX, CONTACT_SCOPE_TAGS_MAX, CONTACT_PAGE_MAX, CONTACT_IMPORT_BATCH_MAX, CONTACT_SEARCH_MAX, CONTACT_LIST_NAME_MAX, CONTACT_LIST_NAME_REGEX, CONTACT_LIST_DESCRIPTION_MAX, CONTACT_LIST_FILTER_MAX, CONTACT_LIST_PINS_PER_REQUEST_MAX, SUPPRESSION_SCOPES, SUPPRESSION_ID_REGEX, contactName, contactPhone, contactEmail, contactInstagramSid, contactLabel, contactLabels, contactMetadata, scopeTagIds, contactVisibilitySchema, hasIdentity, IDENTITY_REQUIRED, contactBookOrgQuery, contactBookContactParam, contactBookListParam, contactBookHubParam, contactBookPageQuery, listContactBookContactsQuery, listHubContactBookContactsQuery, contactBookLinkCandidatesQuery, listContactBookListMembersQuery, contactRowFields, createContactBookContactBody, updateContactBookContactBody, contactImportRowSchema, importContactBookContactsBody, linkContactBookContactBody, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
8007
- var init_chunk_UAOHHCW5 = __esm({
8008
- "../../packages/core/dist/chunk-UAOHHCW5.js"() {
8009
- "use strict";
8010
- init_zod();
8011
- CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
8012
- CONTACT_NAME_MAX = 200;
8013
- CONTACT_EMAIL_MAX = 320;
8014
- CONTACT_PHONE_INPUT_MAX = 40;
8015
- CONTACT_INSTAGRAM_SID_MAX = 64;
8016
- CONTACT_METADATA_MAX_BYTES = 4096;
8017
- CONTACT_LABEL_MAX = 64;
8018
- CONTACT_LABELS_MAX = 20;
8019
- CONTACT_SCOPE_TAGS_MAX = 20;
8020
- CONTACT_PAGE_MAX = 100;
8021
- CONTACT_IMPORT_BATCH_MAX = 500;
8022
- CONTACT_SEARCH_MAX = 100;
8023
- CONTACT_LIST_NAME_MAX = 64;
8024
- CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
8025
- CONTACT_LIST_DESCRIPTION_MAX = 1e3;
8026
- CONTACT_LIST_FILTER_MAX = 20;
8027
- CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
8028
- SUPPRESSION_SCOPES = ["all", "marketing"];
8029
- SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
8030
- contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
8031
- contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
8032
- const phone = normalizeContactPhone(raw);
8033
- if (phone === null) {
8034
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
8035
- return external_exports.NEVER;
8036
- }
8037
- return phone;
8038
- });
8039
- contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
8040
- contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
8041
- contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label3) => label3.length > 0, "A label cannot be empty").refine((label3) => !label3.includes(","), "A label cannot contain a comma");
8042
- contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
8043
- contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
8044
- try {
8045
- return new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES;
8046
- } catch {
8047
- return false;
8048
- }
8049
- }, `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`);
8050
- scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
8051
- contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
8052
- external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
8053
- external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
8054
- ]);
8055
- hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
8056
- IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
8057
- contactBookOrgQuery = external_exports.object({
8058
- organization_id: external_exports.string().uuid()
8059
- });
8060
- contactBookContactParam = external_exports.object({
8061
- contactId: external_exports.string().uuid()
8062
- });
8063
- contactBookListParam = external_exports.object({
8064
- listId: external_exports.string().uuid()
8065
- });
8066
- contactBookHubParam = external_exports.object({
8067
- hubId: external_exports.string().uuid()
8068
- });
8069
- contactBookPageQuery = external_exports.object({
8070
- cursor: external_exports.string().max(2048).optional(),
8071
- limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
8072
- });
8073
- listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
8074
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
8075
- label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
8076
- scope_tag_id: external_exports.string().uuid().optional()
8077
- });
8078
- listHubContactBookContactsQuery = contactBookPageQuery.extend({
8079
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
8080
- });
8081
- contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
8082
- email: contactEmail
8083
- });
8084
- listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
8085
- contactRowFields = {
8086
- name: contactName,
8087
- phone: contactPhone.nullish(),
8088
- email: contactEmail.nullish(),
8089
- instagram_sid: contactInstagramSid.nullish(),
8090
- labels: contactLabels.optional(),
8091
- metadata: contactMetadata.optional()
8092
- };
8093
- createContactBookContactBody = external_exports.object({
8094
- organization_id: external_exports.string().uuid(),
8095
- ...contactRowFields,
8096
- visibility: contactVisibilitySchema,
8097
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
8098
- }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
8099
- updateContactBookContactBody = external_exports.object({
8100
- name: contactName.optional(),
8101
- phone: contactPhone.nullable().optional(),
8102
- email: contactEmail.nullable().optional(),
8103
- instagram_sid: contactInstagramSid.nullable().optional(),
8104
- labels: contactLabels.optional(),
8105
- metadata: contactMetadata.optional(),
8106
- visibility: contactVisibilitySchema.optional(),
8107
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
8108
- }).strict();
8109
- contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
8110
- importContactBookContactsBody = external_exports.object({
8111
- organization_id: external_exports.string().uuid(),
8112
- visibility: contactVisibilitySchema,
8113
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
8114
- labels: contactLabels.optional(),
8115
- rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
8116
- }).strict().superRefine((batch, ctx) => {
8117
- batch.rows.forEach((row, index) => {
8118
- if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
8119
- ctx.addIssue({
8120
- code: external_exports.ZodIssueCode.custom,
8121
- path: ["rows", index, "labels"],
8122
- message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
8123
- });
8124
- }
8125
- });
8126
- });
8127
- linkContactBookContactBody = external_exports.object({
8128
- user_id: external_exports.string().min(1).max(128)
8129
- }).strict();
8130
- listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
8131
- message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
8132
- });
8133
- contactListFilterSchema = external_exports.object({
8134
- labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
8135
- scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
8136
- }).strict();
8137
- createContactBookListBody = external_exports.object({
8138
- organization_id: external_exports.string().uuid(),
8139
- name: listName,
8140
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
8141
- filter: contactListFilterSchema.optional()
8142
- }).strict();
8143
- updateContactBookListBody = external_exports.object({
8144
- name: listName.optional(),
8145
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
8146
- filter: contactListFilterSchema.optional()
8147
- }).strict();
8148
- updateContactBookListPinsBody = external_exports.object({
8149
- add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
8150
- remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
8151
- }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
8152
- suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
8153
- external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
8154
- external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
8155
- external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
8156
- ]);
8157
- createContactBookSuppressionBody = external_exports.object({
8158
- organization_id: external_exports.string().uuid(),
8159
- identity: suppressionIdentitySchema,
8160
- scope: external_exports.enum(SUPPRESSION_SCOPES)
8161
- }).strict();
8162
- contactBookSuppressionParam = external_exports.object({
8163
- suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
8164
- });
8165
- listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
8166
- contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
8167
- contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
8168
- orgListReferenceSchema = listName;
8169
- }
8170
- });
8171
-
8172
- // ../../packages/core/dist/chunk-MGBAXT5Y.js
8173
- var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery, conversationCustomerPersonParam;
8174
- var init_chunk_MGBAXT5Y = __esm({
8175
- "../../packages/core/dist/chunk-MGBAXT5Y.js"() {
8176
- "use strict";
8177
- init_chunk_2YEGUQR7();
8178
- init_chunk_UAOHHCW5();
8179
- init_zod();
8180
- PERSON_LINKS_MAX = 15;
8181
- PERSON_DENY_PAGE_MAX = 100;
8182
- personParam = external_exports.object({
8183
- personId: userPersonIdSchema
8184
- });
8185
- personLinkParam = personParam.extend({
8186
- targetId: personIdSchema
8187
- });
8188
- deniedPersonParam = external_exports.object({
8189
- personId: personIdSchema
8190
- });
8191
- listDeniedPersonsQuery = contactBookOrgQuery.extend({
8192
- cursor: personIdSchema.optional(),
8193
- limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
8194
- });
8195
- conversationCustomerPersonParam = external_exports.object({
8196
- hubId: external_exports.string().uuid(),
8197
- conversationId: external_exports.string().uuid()
8198
- });
8199
- }
8200
- });
8201
-
8202
8240
  // ../../packages/core/dist/chunk-YUZFHVB2.js
8203
8241
  var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
8204
8242
  var init_chunk_YUZFHVB2 = __esm({
@@ -8645,41 +8683,18 @@ var init_chunk_34LE6P7E = __esm({
8645
8683
  }
8646
8684
  });
8647
8685
 
8648
- // ../../packages/core/dist/chunk-FPSDNS2E.js
8649
- var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
8650
- var init_chunk_FPSDNS2E = __esm({
8651
- "../../packages/core/dist/chunk-FPSDNS2E.js"() {
8686
+ // ../../packages/core/dist/chunk-IR2NOSI3.js
8687
+ var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
8688
+ var init_chunk_IR2NOSI3 = __esm({
8689
+ "../../packages/core/dist/chunk-IR2NOSI3.js"() {
8652
8690
  "use strict";
8691
+ init_chunk_HZ6CADSY();
8653
8692
  init_zod();
8654
- noticeSeveritySchema = external_exports.enum(["critical", "warn", "info"]);
8655
- noticeStatusSchema = external_exports.enum(["active", "resolved"]);
8656
- NOTICE_SCOPE_REGEX = /^(global|provider:[a-z0-9_-]{1,40}|service:[a-z0-9_-]{1,40})$/;
8657
- noticeScopeSchema = external_exports.string().regex(NOTICE_SCOPE_REGEX, "scope must be 'global', 'provider:<x>', or 'service:<x>'");
8658
- noticeLinkSchema = external_exports.string().url().refine((u) => /^https?:\/\//i.test(u), { message: "link must be an http(s) URL" });
8659
- createNoticeBody = external_exports.object({
8660
- severity: noticeSeveritySchema.default("info"),
8661
- scope: noticeScopeSchema.default("global"),
8662
- title: external_exports.string().trim().min(1).max(200),
8663
- body: external_exports.string().max(2e3).optional(),
8664
- link: noticeLinkSchema.optional(),
8665
- starts_at: external_exports.string().datetime().optional(),
8666
- ends_at: external_exports.string().datetime().optional()
8667
- });
8668
- updateNoticeBody = external_exports.object({
8669
- severity: noticeSeveritySchema.optional(),
8670
- scope: noticeScopeSchema.optional(),
8671
- title: external_exports.string().trim().min(1).max(200).optional(),
8672
- body: external_exports.string().max(2e3).nullable().optional(),
8673
- link: noticeLinkSchema.nullable().optional(),
8674
- starts_at: external_exports.string().datetime().optional(),
8675
- ends_at: external_exports.string().datetime().nullable().optional()
8676
- }).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be provided" });
8677
- listNoticesQuery = external_exports.object({
8678
- status: noticeStatusSchema.optional(),
8679
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
8680
- offset: external_exports.coerce.number().int().min(0).optional()
8681
- });
8682
- noticeIdParamSchema = external_exports.object({ id: external_exports.string().min(1) });
8693
+ adminSetGuideHubBody = external_exports.object({
8694
+ hub_id: uuidSchema,
8695
+ dry_run: external_exports.boolean().optional()
8696
+ }).strict();
8697
+ GUIDE_HUB_INELIGIBLE_REASON = "guide_hub_ineligible";
8683
8698
  }
8684
8699
  });
8685
8700
 
@@ -9146,6 +9161,29 @@ var init_chunk_2ZZZHXZR = __esm({
9146
9161
  }
9147
9162
  });
9148
9163
 
9164
+ // ../../packages/core/dist/chunk-MH4O3YEX.js
9165
+ var stateOperationBody;
9166
+ var init_chunk_MH4O3YEX = __esm({
9167
+ "../../packages/core/dist/chunk-MH4O3YEX.js"() {
9168
+ "use strict";
9169
+ init_chunk_6TSQ5HXC();
9170
+ init_zod();
9171
+ stateOperationBody = external_exports.object({
9172
+ hub_id: external_exports.string().uuid(),
9173
+ operation: external_exports.enum(["get", "update", "set_path", "reset"]),
9174
+ state_slug: slugSchema,
9175
+ /**
9176
+ * Deprecated and ignored. Scope is derived from the hub's state definition.
9177
+ * Kept on the schema so legacy bodies still validate.
9178
+ */
9179
+ state_scope: external_exports.enum(["conversation", "user"]).optional(),
9180
+ updates: external_exports.record(external_exports.unknown()).optional(),
9181
+ path: external_exports.array(external_exports.string()).optional(),
9182
+ value: external_exports.unknown().optional()
9183
+ });
9184
+ }
9185
+ });
9186
+
9149
9187
  // ../../packages/core/dist/chunk-IBL7FANV.js
9150
9188
  var SUMMARIZATION_THRESHOLD_MIN, SUMMARIZATION_THRESHOLD_MAX;
9151
9189
  var init_chunk_IBL7FANV = __esm({
@@ -12731,21 +12769,6 @@ var init_chunk_C4HEZ7ZI = __esm({
12731
12769
  }
12732
12770
  });
12733
12771
 
12734
- // ../../packages/core/dist/chunk-IR2NOSI3.js
12735
- var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
12736
- var init_chunk_IR2NOSI3 = __esm({
12737
- "../../packages/core/dist/chunk-IR2NOSI3.js"() {
12738
- "use strict";
12739
- init_chunk_HZ6CADSY();
12740
- init_zod();
12741
- adminSetGuideHubBody = external_exports.object({
12742
- hub_id: uuidSchema,
12743
- dry_run: external_exports.boolean().optional()
12744
- }).strict();
12745
- GUIDE_HUB_INELIGIBLE_REASON = "guide_hub_ineligible";
12746
- }
12747
- });
12748
-
12749
12772
  // ../../packages/core/dist/chunk-YULHXJ5M.js
12750
12773
  var COMMUNITY_LESSON_TREE_MAX_BYTES, COMMUNITY_LESSON_LINK_PROTOCOLS, COMMUNITY_LESSON_TREE_TOO_LARGE_REASON, COMMUNITY_LESSON_TREE_TOO_DEEP_REASON, COMMUNITY_LESSON_LINE_PREFIX_TOO_WIDE_REASON, LINK_SCHEME;
12751
12774
  var init_chunk_YULHXJ5M = __esm({
@@ -12849,29 +12872,6 @@ var init_chunk_ACGAI25T = __esm({
12849
12872
  }
12850
12873
  });
12851
12874
 
12852
- // ../../packages/core/dist/chunk-MH4O3YEX.js
12853
- var stateOperationBody;
12854
- var init_chunk_MH4O3YEX = __esm({
12855
- "../../packages/core/dist/chunk-MH4O3YEX.js"() {
12856
- "use strict";
12857
- init_chunk_6TSQ5HXC();
12858
- init_zod();
12859
- stateOperationBody = external_exports.object({
12860
- hub_id: external_exports.string().uuid(),
12861
- operation: external_exports.enum(["get", "update", "set_path", "reset"]),
12862
- state_slug: slugSchema,
12863
- /**
12864
- * Deprecated and ignored. Scope is derived from the hub's state definition.
12865
- * Kept on the schema so legacy bodies still validate.
12866
- */
12867
- state_scope: external_exports.enum(["conversation", "user"]).optional(),
12868
- updates: external_exports.record(external_exports.unknown()).optional(),
12869
- path: external_exports.array(external_exports.string()).optional(),
12870
- value: external_exports.unknown().optional()
12871
- });
12872
- }
12873
- });
12874
-
12875
12875
  // ../../packages/core/dist/chunk-5Y2NNQHX.js
12876
12876
  var CASE_SUBMISSION_ISSUED_KINDS, CASE_SUBMISSION_RENDER_STUCK_MS, CASE_SUBMISSION_MARK_ID_PATTERN, CASE_CORRECTION_REASON_MAX_LENGTH, submitCaseBody, correctCaseSubmissionBody, caseDeliveryQuery;
12877
12877
  var init_chunk_5Y2NNQHX = __esm({
@@ -13802,6 +13802,57 @@ var init_chunk_LBDH7LCG = __esm({
13802
13802
  }
13803
13803
  });
13804
13804
 
13805
+ // ../../packages/core/dist/chunk-D3EP4TDU.js
13806
+ var primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody;
13807
+ var init_chunk_D3EP4TDU = __esm({
13808
+ "../../packages/core/dist/chunk-D3EP4TDU.js"() {
13809
+ "use strict";
13810
+ init_chunk_HZ6CADSY();
13811
+ init_zod();
13812
+ primaryRegionSchema = external_exports.enum([
13813
+ "wnam",
13814
+ "enam",
13815
+ "sam",
13816
+ "weur",
13817
+ "eeur",
13818
+ "apac",
13819
+ "oc",
13820
+ "afr",
13821
+ "me"
13822
+ ]);
13823
+ placementSourceSchema = external_exports.enum([
13824
+ "hub_config",
13825
+ "org_config",
13826
+ "parent_cascade",
13827
+ "cf_colo",
13828
+ "country",
13829
+ "fallback",
13830
+ "unpinned"
13831
+ ]);
13832
+ orgIdParam = external_exports.object({
13833
+ id: uuidSchema
13834
+ });
13835
+ orgAdminIdParam = external_exports.object({
13836
+ id: uuidSchema,
13837
+ adminId: external_exports.string().min(1)
13838
+ });
13839
+ createOrganizationBody = external_exports.object({
13840
+ organization_name: external_exports.string().min(1, "organization_name is required"),
13841
+ // Write-once at creation; updateOrganizationBody does not accept this.
13842
+ primary_region: primaryRegionSchema.optional()
13843
+ });
13844
+ updateOrganizationBody = external_exports.object({
13845
+ organization_name: external_exports.string().min(1).optional(),
13846
+ organization_avatar_url: external_exports.string().url().nullable().optional(),
13847
+ timezone: external_exports.string().optional(),
13848
+ business_hours: external_exports.unknown().optional()
13849
+ }).passthrough();
13850
+ addOrgAdminBody = external_exports.object({
13851
+ user_email: external_exports.string().email("valid email is required")
13852
+ });
13853
+ }
13854
+ });
13855
+
13805
13856
  // ../../packages/core/dist/chunk-X5PZZVTS.js
13806
13857
  function isEventRelativeFollowupType(type) {
13807
13858
  return typeof type === "string" && EVENT_RELATIVE_FOLLOWUP_TYPES.includes(type);
@@ -14200,57 +14251,6 @@ var init_chunk_X5PZZVTS = __esm({
14200
14251
  }
14201
14252
  });
14202
14253
 
14203
- // ../../packages/core/dist/chunk-D3EP4TDU.js
14204
- var primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody;
14205
- var init_chunk_D3EP4TDU = __esm({
14206
- "../../packages/core/dist/chunk-D3EP4TDU.js"() {
14207
- "use strict";
14208
- init_chunk_HZ6CADSY();
14209
- init_zod();
14210
- primaryRegionSchema = external_exports.enum([
14211
- "wnam",
14212
- "enam",
14213
- "sam",
14214
- "weur",
14215
- "eeur",
14216
- "apac",
14217
- "oc",
14218
- "afr",
14219
- "me"
14220
- ]);
14221
- placementSourceSchema = external_exports.enum([
14222
- "hub_config",
14223
- "org_config",
14224
- "parent_cascade",
14225
- "cf_colo",
14226
- "country",
14227
- "fallback",
14228
- "unpinned"
14229
- ]);
14230
- orgIdParam = external_exports.object({
14231
- id: uuidSchema
14232
- });
14233
- orgAdminIdParam = external_exports.object({
14234
- id: uuidSchema,
14235
- adminId: external_exports.string().min(1)
14236
- });
14237
- createOrganizationBody = external_exports.object({
14238
- organization_name: external_exports.string().min(1, "organization_name is required"),
14239
- // Write-once at creation; updateOrganizationBody does not accept this.
14240
- primary_region: primaryRegionSchema.optional()
14241
- });
14242
- updateOrganizationBody = external_exports.object({
14243
- organization_name: external_exports.string().min(1).optional(),
14244
- organization_avatar_url: external_exports.string().url().nullable().optional(),
14245
- timezone: external_exports.string().optional(),
14246
- business_hours: external_exports.unknown().optional()
14247
- }).passthrough();
14248
- addOrgAdminBody = external_exports.object({
14249
- user_email: external_exports.string().email("valid email is required")
14250
- });
14251
- }
14252
- });
14253
-
14254
14254
  // ../../packages/core/dist/chunk-PIZTARVG.js
14255
14255
  function byLocale(entry) {
14256
14256
  const shape = Object.fromEntries(SUPPORTED_LOCALES.map((locale) => [locale, entry.optional()]));
@@ -14289,7 +14289,7 @@ var init_chunk_PIZTARVG = __esm({
14289
14289
  }
14290
14290
  });
14291
14291
 
14292
- // ../../packages/core/dist/chunk-7NFNYPTF.js
14292
+ // ../../packages/core/dist/chunk-ARK3766Q.js
14293
14293
  function refineLaneReferences(val, ctx) {
14294
14294
  const lanes = val.lanes;
14295
14295
  const statuses = val.kanban_statuses;
@@ -14313,11 +14313,11 @@ function describeSyncWarning(warning) {
14313
14313
  return `${label3}: ${parts.join("; ")}. Promote the base so production's tools match the preview's.`;
14314
14314
  }
14315
14315
  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;
14316
- var init_chunk_7NFNYPTF = __esm({
14317
- "../../packages/core/dist/chunk-7NFNYPTF.js"() {
14316
+ var init_chunk_ARK3766Q = __esm({
14317
+ "../../packages/core/dist/chunk-ARK3766Q.js"() {
14318
14318
  "use strict";
14319
- init_chunk_X5PZZVTS();
14320
14319
  init_chunk_D3EP4TDU();
14320
+ init_chunk_X5PZZVTS();
14321
14321
  init_chunk_PIZTARVG();
14322
14322
  init_chunk_HZ6CADSY();
14323
14323
  init_zod();
@@ -14513,7 +14513,7 @@ var init_chunk_7NFNYPTF = __esm({
14513
14513
  }
14514
14514
  });
14515
14515
 
14516
- // ../../packages/core/dist/chunk-W3WJCAUF.js
14516
+ // ../../packages/core/dist/chunk-LZHLURLT.js
14517
14517
  function declaresNoConnection(agent) {
14518
14518
  return agent.connection === null && !agent.connection_id;
14519
14519
  }
@@ -15245,8 +15245,8 @@ function skillSectionsAsResources(scope) {
15245
15245
  };
15246
15246
  }
15247
15247
  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;
15248
- var init_chunk_W3WJCAUF = __esm({
15249
- "../../packages/core/dist/chunk-W3WJCAUF.js"() {
15248
+ var init_chunk_LZHLURLT = __esm({
15249
+ "../../packages/core/dist/chunk-LZHLURLT.js"() {
15250
15250
  "use strict";
15251
15251
  init_chunk_QG3XMUEN();
15252
15252
  init_chunk_EBUWHIFV();
@@ -15254,7 +15254,7 @@ var init_chunk_W3WJCAUF = __esm({
15254
15254
  init_chunk_QMQGGR7Q();
15255
15255
  init_chunk_LBDH7LCG();
15256
15256
  init_chunk_4LXDRTO4();
15257
- init_chunk_7NFNYPTF();
15257
+ init_chunk_ARK3766Q();
15258
15258
  init_chunk_X5PZZVTS();
15259
15259
  init_chunk_PIZTARVG();
15260
15260
  init_chunk_S4VDZ7PZ();
@@ -16014,11 +16014,11 @@ function cycleIn(nodes, edges) {
16014
16014
  function fixedTextProblem(text5) {
16015
16015
  if (text5.includes("<!--")) return "item_fixed_text_comment";
16016
16016
  if (/\{\{\s*fill\s*:/.test(text5)) return "item_fixed_text_fill";
16017
- const lines = text5.replace(/\r\n?/g, "\n").split("\n");
16017
+ const lines2 = text5.replace(/\r\n?/g, "\n").split("\n");
16018
16018
  let fence = null;
16019
16019
  let closedAt = -1;
16020
- for (let i = 0; i < lines.length; i++) {
16021
- const line = lines[i];
16020
+ for (let i = 0; i < lines2.length; i++) {
16021
+ const line = lines2[i];
16022
16022
  const mark = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
16023
16023
  if (fence !== null) {
16024
16024
  if (mark && mark[0] === fence[0] && mark.length >= fence.length && line.trim() === mark) {
@@ -16031,7 +16031,7 @@ function fixedTextProblem(text5) {
16031
16031
  fence = mark;
16032
16032
  continue;
16033
16033
  }
16034
- const setext = i > 0 && /^ {0,3}(=+|-+)[ \t]*$/.test(line) && lines[i - 1].trim() !== "" && closedAt !== i - 1 && (i === 1 || lines[i - 2].trim() === "");
16034
+ const setext = i > 0 && /^ {0,3}(=+|-+)[ \t]*$/.test(line) && lines2[i - 1].trim() !== "" && closedAt !== i - 1 && (i === 1 || lines2[i - 2].trim() === "");
16035
16035
  if (/^ {0,3}#{1,6}([ \t]|$)/.test(line) || setext) return "item_fixed_text_heading";
16036
16036
  }
16037
16037
  return null;
@@ -16496,10 +16496,10 @@ var init_chunk_2YVCHUBL = __esm({
16496
16496
  }
16497
16497
  });
16498
16498
 
16499
- // ../../packages/core/dist/chunk-RRU36I2I.js
16499
+ // ../../packages/core/dist/chunk-NMGRRGDR.js
16500
16500
  var casePhaseParam;
16501
- var init_chunk_RRU36I2I = __esm({
16502
- "../../packages/core/dist/chunk-RRU36I2I.js"() {
16501
+ var init_chunk_NMGRRGDR = __esm({
16502
+ "../../packages/core/dist/chunk-NMGRRGDR.js"() {
16503
16503
  "use strict";
16504
16504
  init_chunk_733K4J4G();
16505
16505
  init_chunk_HZ6CADSY();
@@ -16507,10 +16507,10 @@ var init_chunk_RRU36I2I = __esm({
16507
16507
  }
16508
16508
  });
16509
16509
 
16510
- // ../../packages/core/dist/chunk-RHXF6X2Y.js
16510
+ // ../../packages/core/dist/chunk-XPOCPOMA.js
16511
16511
  var CASE_CHECK_CSV_MAX_BYTES, CASE_DECISIONS_CSV_PATH, CASE_CONFIDENTIAL_DECISIONS_CSV_PATH, caseChecksQuery;
16512
- var init_chunk_RHXF6X2Y = __esm({
16513
- "../../packages/core/dist/chunk-RHXF6X2Y.js"() {
16512
+ var init_chunk_XPOCPOMA = __esm({
16513
+ "../../packages/core/dist/chunk-XPOCPOMA.js"() {
16514
16514
  "use strict";
16515
16515
  init_chunk_5Y2NNQHX();
16516
16516
  init_chunk_HZ6CADSY();
@@ -16524,14 +16524,14 @@ var init_chunk_RHXF6X2Y = __esm({
16524
16524
  }
16525
16525
  });
16526
16526
 
16527
- // ../../packages/core/dist/chunk-XUPUXNGM.js
16527
+ // ../../packages/core/dist/chunk-6MNNZ3G4.js
16528
16528
  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;
16529
- var init_chunk_XUPUXNGM = __esm({
16530
- "../../packages/core/dist/chunk-XUPUXNGM.js"() {
16529
+ var init_chunk_6MNNZ3G4 = __esm({
16530
+ "../../packages/core/dist/chunk-6MNNZ3G4.js"() {
16531
16531
  "use strict";
16532
16532
  init_chunk_2YVCHUBL();
16533
- init_chunk_RRU36I2I();
16534
- init_chunk_RHXF6X2Y();
16533
+ init_chunk_NMGRRGDR();
16534
+ init_chunk_XPOCPOMA();
16535
16535
  init_chunk_5Y2NNQHX();
16536
16536
  init_chunk_VROZDNLV();
16537
16537
  init_chunk_733K4J4G();
@@ -16608,6 +16608,25 @@ var init_chunk_M2IF4G6X = __esm({
16608
16608
  }
16609
16609
  });
16610
16610
 
16611
+ // ../../packages/core/dist/chunk-UOPCLXCU.js
16612
+ var CASE_CHANGE_TOPICS, caseChangedFrameSchema;
16613
+ var init_chunk_UOPCLXCU = __esm({
16614
+ "../../packages/core/dist/chunk-UOPCLXCU.js"() {
16615
+ "use strict";
16616
+ init_chunk_733K4J4G();
16617
+ init_chunk_HZ6CADSY();
16618
+ init_zod();
16619
+ CASE_CHANGE_TOPICS = ["submission", "agenda", "access"];
16620
+ caseChangedFrameSchema = external_exports.object({
16621
+ org_id: uuidSchema,
16622
+ space_id: uuidSchema,
16623
+ /** The case, by its code; null for an `access` change, which names none. */
16624
+ code: caseRecordParam.shape.code.nullable(),
16625
+ topic: external_exports.enum(CASE_CHANGE_TOPICS)
16626
+ }).strict();
16627
+ }
16628
+ });
16629
+
16611
16630
  // ../../packages/core/dist/chunk-7CZSLDOE.js
16612
16631
  var CASE_MEMBER_CASES_PAGE_MAX, caseMemberReachQuery;
16613
16632
  var init_chunk_7CZSLDOE = __esm({
@@ -17048,6 +17067,156 @@ var init_chunk_ZVIMTUGZ = __esm({
17048
17067
  }
17049
17068
  });
17050
17069
 
17070
+ // ../../packages/core/dist/chunk-7TQYAKCB.js
17071
+ function addCaseNoteProblem(note) {
17072
+ return note.origin !== null && note.kind !== "contribution" ? { reason: "origin_not_contribution", at: "origin" } : null;
17073
+ }
17074
+ var CASE_NOTE_KINDS, CASE_NOTE_TEXT_MAX_LENGTH, CASE_NOTE_ORIGIN_MAX_LENGTH, CASE_NOTES_PAGE_MAX, addCaseNoteShape, addCaseNoteBody, caseNoteParam, caseTaskParam, caseNotesQuery;
17075
+ var init_chunk_7TQYAKCB = __esm({
17076
+ "../../packages/core/dist/chunk-7TQYAKCB.js"() {
17077
+ "use strict";
17078
+ init_chunk_733K4J4G();
17079
+ init_chunk_3T3D7LTE();
17080
+ init_chunk_HZ6CADSY();
17081
+ init_zod();
17082
+ CASE_NOTE_KINDS = ["observation", "next_step", "pending", "contribution"];
17083
+ CASE_NOTE_TEXT_MAX_LENGTH = 64 * 1024;
17084
+ CASE_NOTE_ORIGIN_MAX_LENGTH = 200;
17085
+ CASE_NOTES_PAGE_MAX = 100;
17086
+ addCaseNoteShape = external_exports.object({
17087
+ kind: external_exports.enum(CASE_NOTE_KINDS),
17088
+ text: external_exports.string().trim().min(1).max(CASE_NOTE_TEXT_MAX_LENGTH),
17089
+ /** A contribution's external author. */
17090
+ origin: external_exports.string().trim().min(1).max(CASE_NOTE_ORIGIN_MAX_LENGTH).nullable().default(null),
17091
+ /** A phase of the case (its version's phase id). */
17092
+ phase_id: uuidSchema.nullable().default(null),
17093
+ /** A task of the case, whose phase the note takes. */
17094
+ case_task_id: uuidSchema.nullable().default(null)
17095
+ }).strict();
17096
+ addCaseNoteBody = addCaseNoteShape.superRefine((note, ctx) => {
17097
+ const found = addCaseNoteProblem(note);
17098
+ if (found) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: [found.at], params: { case_note_reason: found.reason } });
17099
+ });
17100
+ caseNoteParam = caseRecordParam.extend({ note_id: uuidSchema });
17101
+ caseTaskParam = caseRecordParam.extend({ case_task_id: uuidSchema });
17102
+ caseNotesQuery = casePageQuery.extend({
17103
+ limit: external_exports.coerce.number().int().min(1).max(CASE_NOTES_PAGE_MAX).optional()
17104
+ });
17105
+ }
17106
+ });
17107
+
17108
+ // ../../packages/core/dist/chunk-S7UAXLHJ.js
17109
+ function casePassageLines(text5) {
17110
+ const lines2 = text5.replace(/\r\n/g, "\n").split("\n");
17111
+ if (lines2.at(-1) === "") lines2.pop();
17112
+ return lines2;
17113
+ }
17114
+ var CASE_COMMENT_TEXT_MAX_LENGTH, CASE_COMMENTS_PAGE_MAX, CASE_COMMENT_LINE_MAX, casePassageLineSchema, lineNumber, addCaseCommentShape, CASE_COMMENT_REVERSED_REASON, addCaseCommentBody, caseCommentsQuery, CASE_COMMENT_OUT_OF_RANGE_REASON;
17115
+ var init_chunk_S7UAXLHJ = __esm({
17116
+ "../../packages/core/dist/chunk-S7UAXLHJ.js"() {
17117
+ "use strict";
17118
+ init_chunk_7TQYAKCB();
17119
+ init_chunk_VROZDNLV();
17120
+ init_chunk_3T3D7LTE();
17121
+ init_chunk_HZ6CADSY();
17122
+ init_zod();
17123
+ CASE_COMMENT_TEXT_MAX_LENGTH = CASE_NOTE_TEXT_MAX_LENGTH;
17124
+ CASE_COMMENTS_PAGE_MAX = 100;
17125
+ CASE_COMMENT_LINE_MAX = CASE_FILE_COMPARE_MAX_BYTES;
17126
+ casePassageLineSchema = external_exports.number().int().min(1).max(CASE_COMMENT_LINE_MAX);
17127
+ lineNumber = casePassageLineSchema;
17128
+ addCaseCommentShape = external_exports.object({
17129
+ path: caseFileReadPath,
17130
+ /** The version: the revision that wrote it to `path`. */
17131
+ revision_id: uuidSchema,
17132
+ /** The passage's first and last lines, from 1, of the version's text ({@link casePassageLines}). */
17133
+ line_start: lineNumber,
17134
+ line_end: lineNumber,
17135
+ text: external_exports.string().trim().min(1).max(CASE_COMMENT_TEXT_MAX_LENGTH),
17136
+ /** Hidden from every reader without the Confidential right; only a holder of it may set it. */
17137
+ confidential: external_exports.boolean().default(false)
17138
+ }).strict();
17139
+ CASE_COMMENT_REVERSED_REASON = "passage_reversed";
17140
+ addCaseCommentBody = addCaseCommentShape.superRefine((comment2, ctx) => {
17141
+ if (comment2.line_end < comment2.line_start) {
17142
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: CASE_COMMENT_REVERSED_REASON, path: ["line_end"] });
17143
+ }
17144
+ });
17145
+ caseCommentsQuery = casePageQuery.extend({
17146
+ path: caseFileReadPath,
17147
+ /** Absent: every version's comments on the path. */
17148
+ revision_id: uuidSchema.optional(),
17149
+ limit: external_exports.coerce.number().int().min(1).max(CASE_COMMENTS_PAGE_MAX).optional()
17150
+ });
17151
+ CASE_COMMENT_OUT_OF_RANGE_REASON = "passage_out_of_range";
17152
+ }
17153
+ });
17154
+
17155
+ // ../../packages/core/dist/chunk-U3L6QR6F.js
17156
+ var CASE_VERSION_DECISION_REASON_MAX_LENGTH, CASE_VERSION_DECISIONS, caseVersionDecisionReason, reason, lineNumber2, recordCaseReferenceBody, CASE_PASSAGE_REVERSED_REASON, citeCasePassageBody, decideCaseVersionBody, CASE_PASSAGE_LINK_CHANGED_REASON, CASE_PASSAGE_NO_TEXT_REASON, CASE_PASSAGE_OUT_OF_RANGE_REASON;
17157
+ var init_chunk_U3L6QR6F = __esm({
17158
+ "../../packages/core/dist/chunk-U3L6QR6F.js"() {
17159
+ "use strict";
17160
+ init_chunk_S7UAXLHJ();
17161
+ init_chunk_HZ6CADSY();
17162
+ init_zod();
17163
+ CASE_VERSION_DECISION_REASON_MAX_LENGTH = 2e3;
17164
+ CASE_VERSION_DECISIONS = ["adopt", "keep"];
17165
+ caseVersionDecisionReason = external_exports.string().trim().min(1).max(CASE_VERSION_DECISION_REASON_MAX_LENGTH);
17166
+ reason = caseVersionDecisionReason;
17167
+ lineNumber2 = casePassageLineSchema;
17168
+ recordCaseReferenceBody = external_exports.object({
17169
+ document_id: uuidSchema,
17170
+ /** The document's version its writer read as current. */
17171
+ version_id: uuidSchema
17172
+ }).strict();
17173
+ CASE_PASSAGE_REVERSED_REASON = CASE_COMMENT_REVERSED_REASON;
17174
+ citeCasePassageBody = external_exports.object({
17175
+ document_id: uuidSchema,
17176
+ version_id: uuidSchema,
17177
+ line_start: lineNumber2,
17178
+ line_end: lineNumber2
17179
+ }).strict().superRefine((body, ctx) => {
17180
+ if (body.line_end < body.line_start) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: CASE_PASSAGE_REVERSED_REASON, path: ["line_end"] });
17181
+ });
17182
+ decideCaseVersionBody = external_exports.object({
17183
+ decision: external_exports.enum(CASE_VERSION_DECISIONS),
17184
+ /** The newer version its decider read as current. */
17185
+ expect_version_id: uuidSchema,
17186
+ reason: reason.nullable().default(null)
17187
+ }).strict().superRefine((body, ctx) => {
17188
+ if (body.decision === "keep" && body.reason === null) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A version kept needs its reason", path: ["reason"] });
17189
+ });
17190
+ CASE_PASSAGE_LINK_CHANGED_REASON = "link_changed";
17191
+ CASE_PASSAGE_NO_TEXT_REASON = "version_no_text";
17192
+ CASE_PASSAGE_OUT_OF_RANGE_REASON = CASE_COMMENT_OUT_OF_RANGE_REASON;
17193
+ }
17194
+ });
17195
+
17196
+ // ../../packages/core/dist/chunk-Q5LS3FKY.js
17197
+ var lines, ordered, citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody, citeCaseSourcePassageBody, citeCaseInputPassageBody, caseSourceRefSchema;
17198
+ var init_chunk_Q5LS3FKY = __esm({
17199
+ "../../packages/core/dist/chunk-Q5LS3FKY.js"() {
17200
+ "use strict";
17201
+ init_chunk_U3L6QR6F();
17202
+ init_chunk_S7UAXLHJ();
17203
+ init_chunk_HZ6CADSY();
17204
+ init_zod();
17205
+ lines = { line_start: casePassageLineSchema, line_end: casePassageLineSchema };
17206
+ ordered = (body, ctx) => {
17207
+ if (body.line_end < body.line_start) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: CASE_PASSAGE_REVERSED_REASON, path: ["line_end"] });
17208
+ };
17209
+ citeCaseOfficialVersionPassageBody = external_exports.object({ official_version_id: uuidSchema, ...lines }).strict().superRefine(ordered);
17210
+ citeCaseReceivedPassageBody = external_exports.object({ received_id: uuidSchema, ...lines }).strict().superRefine(ordered);
17211
+ citeCaseSourcePassageBody = external_exports.union([citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody]);
17212
+ citeCaseInputPassageBody = external_exports.union([citeCasePassageBody, citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody]);
17213
+ caseSourceRefSchema = external_exports.union([
17214
+ external_exports.object({ official_version_id: uuidSchema }).strict(),
17215
+ external_exports.object({ received_id: uuidSchema }).strict()
17216
+ ]);
17217
+ }
17218
+ });
17219
+
17051
17220
  // ../../packages/core/dist/chunk-BVQCYBU6.js
17052
17221
  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;
17053
17222
  var init_chunk_BVQCYBU6 = __esm({
@@ -17094,25 +17263,6 @@ var init_chunk_BVQCYBU6 = __esm({
17094
17263
  }
17095
17264
  });
17096
17265
 
17097
- // ../../packages/core/dist/chunk-UOPCLXCU.js
17098
- var CASE_CHANGE_TOPICS, caseChangedFrameSchema;
17099
- var init_chunk_UOPCLXCU = __esm({
17100
- "../../packages/core/dist/chunk-UOPCLXCU.js"() {
17101
- "use strict";
17102
- init_chunk_733K4J4G();
17103
- init_chunk_HZ6CADSY();
17104
- init_zod();
17105
- CASE_CHANGE_TOPICS = ["submission", "agenda", "access"];
17106
- caseChangedFrameSchema = external_exports.object({
17107
- org_id: uuidSchema,
17108
- space_id: uuidSchema,
17109
- /** The case, by its code; null for an `access` change, which names none. */
17110
- code: caseRecordParam.shape.code.nullable(),
17111
- topic: external_exports.enum(CASE_CHANGE_TOPICS)
17112
- }).strict();
17113
- }
17114
- });
17115
-
17116
17266
  // ../../packages/core/dist/chunk-Z3SV3XTC.js
17117
17267
  var caseAccessQuery;
17118
17268
  var init_chunk_Z3SV3XTC = __esm({
@@ -17125,7 +17275,7 @@ var init_chunk_Z3SV3XTC = __esm({
17125
17275
  });
17126
17276
 
17127
17277
  // ../../packages/core/dist/chunk-NHC27NIE.js
17128
- var CASE_ADJUSTMENT_REASON_MAX_LENGTH, CASE_ADJUSTMENT_DISPENSATION_KINDS, reason, activateCasePhaseBody, dispenseCaseBody, addCaseTaskBody, addCaseInputBody, caseOwnItemSchema, addCaseItemBody;
17278
+ var CASE_ADJUSTMENT_REASON_MAX_LENGTH, CASE_ADJUSTMENT_DISPENSATION_KINDS, reason2, activateCasePhaseBody, dispenseCaseBody, addCaseTaskBody, addCaseInputBody, caseOwnItemSchema, addCaseItemBody;
17129
17279
  var init_chunk_NHC27NIE = __esm({
17130
17280
  "../../packages/core/dist/chunk-NHC27NIE.js"() {
17131
17281
  "use strict";
@@ -17134,9 +17284,9 @@ var init_chunk_NHC27NIE = __esm({
17134
17284
  init_zod();
17135
17285
  CASE_ADJUSTMENT_REASON_MAX_LENGTH = 2e3;
17136
17286
  CASE_ADJUSTMENT_DISPENSATION_KINDS = ["phase", "item", "output", "input"];
17137
- reason = external_exports.string().trim().min(1).max(CASE_ADJUSTMENT_REASON_MAX_LENGTH);
17138
- activateCasePhaseBody = external_exports.object({ phase_id: uuidSchema, reason }).strict();
17139
- dispenseCaseBody = external_exports.object({ kind: external_exports.enum(CASE_ADJUSTMENT_DISPENSATION_KINDS), target_id: uuidSchema, reason }).strict();
17287
+ reason2 = external_exports.string().trim().min(1).max(CASE_ADJUSTMENT_REASON_MAX_LENGTH);
17288
+ activateCasePhaseBody = external_exports.object({ phase_id: uuidSchema, reason: reason2 }).strict();
17289
+ dispenseCaseBody = external_exports.object({ kind: external_exports.enum(CASE_ADJUSTMENT_DISPENSATION_KINDS), target_id: uuidSchema, reason: reason2 }).strict();
17140
17290
  addCaseTaskBody = external_exports.object({
17141
17291
  phase_id: uuidSchema,
17142
17292
  name: external_exports.string().trim().min(1).max(CASE_TASK_NAME_MAX_LENGTH),
@@ -17147,7 +17297,7 @@ var init_chunk_NHC27NIE = __esm({
17147
17297
  addCaseInputBody = external_exports.object({
17148
17298
  phase_id: uuidSchema,
17149
17299
  input: casePhaseInputSchema.extend({ agenda_group: caseAgendaGroupCodeSchema.nullable().default(null) }),
17150
- reason
17300
+ reason: reason2
17151
17301
  }).strict();
17152
17302
  caseOwnItemSchema = caseOutputItemSchema.omit({ waivable: true, template_mode: true, fixed_text: true }).extend({ agenda_group: caseAgendaGroupCodeSchema.nullable().default(null) });
17153
17303
  addCaseItemBody = external_exports.object({
@@ -17155,7 +17305,7 @@ var init_chunk_NHC27NIE = __esm({
17155
17305
  /** The phase's output it goes in. */
17156
17306
  output_id: uuidSchema,
17157
17307
  item: caseOwnItemSchema,
17158
- reason
17308
+ reason: reason2
17159
17309
  }).strict();
17160
17310
  }
17161
17311
  });
@@ -17207,148 +17357,34 @@ var init_chunk_UMAPAGFH = __esm({
17207
17357
  }
17208
17358
  });
17209
17359
 
17210
- // ../../packages/core/dist/chunk-7TQYAKCB.js
17211
- function addCaseNoteProblem(note) {
17212
- return note.origin !== null && note.kind !== "contribution" ? { reason: "origin_not_contribution", at: "origin" } : null;
17213
- }
17214
- var CASE_NOTE_KINDS, CASE_NOTE_TEXT_MAX_LENGTH, CASE_NOTE_ORIGIN_MAX_LENGTH, CASE_NOTES_PAGE_MAX, addCaseNoteShape, addCaseNoteBody, caseNoteParam, caseTaskParam, caseNotesQuery;
17215
- var init_chunk_7TQYAKCB = __esm({
17216
- "../../packages/core/dist/chunk-7TQYAKCB.js"() {
17217
- "use strict";
17218
- init_chunk_733K4J4G();
17219
- init_chunk_3T3D7LTE();
17220
- init_chunk_HZ6CADSY();
17221
- init_zod();
17222
- CASE_NOTE_KINDS = ["observation", "next_step", "pending", "contribution"];
17223
- CASE_NOTE_TEXT_MAX_LENGTH = 64 * 1024;
17224
- CASE_NOTE_ORIGIN_MAX_LENGTH = 200;
17225
- CASE_NOTES_PAGE_MAX = 100;
17226
- addCaseNoteShape = external_exports.object({
17227
- kind: external_exports.enum(CASE_NOTE_KINDS),
17228
- text: external_exports.string().trim().min(1).max(CASE_NOTE_TEXT_MAX_LENGTH),
17229
- /** A contribution's external author. */
17230
- origin: external_exports.string().trim().min(1).max(CASE_NOTE_ORIGIN_MAX_LENGTH).nullable().default(null),
17231
- /** A phase of the case (its version's phase id). */
17232
- phase_id: uuidSchema.nullable().default(null),
17233
- /** A task of the case, whose phase the note takes. */
17234
- case_task_id: uuidSchema.nullable().default(null)
17235
- }).strict();
17236
- addCaseNoteBody = addCaseNoteShape.superRefine((note, ctx) => {
17237
- const found = addCaseNoteProblem(note);
17238
- if (found) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: [found.at], params: { case_note_reason: found.reason } });
17239
- });
17240
- caseNoteParam = caseRecordParam.extend({ note_id: uuidSchema });
17241
- caseTaskParam = caseRecordParam.extend({ case_task_id: uuidSchema });
17242
- caseNotesQuery = casePageQuery.extend({
17243
- limit: external_exports.coerce.number().int().min(1).max(CASE_NOTES_PAGE_MAX).optional()
17244
- });
17245
- }
17246
- });
17247
-
17248
- // ../../packages/core/dist/chunk-S7UAXLHJ.js
17249
- function casePassageLines(text5) {
17250
- const lines = text5.replace(/\r\n/g, "\n").split("\n");
17251
- if (lines.at(-1) === "") lines.pop();
17252
- return lines;
17253
- }
17254
- var CASE_COMMENT_TEXT_MAX_LENGTH, CASE_COMMENTS_PAGE_MAX, CASE_COMMENT_LINE_MAX, casePassageLineSchema, lineNumber, addCaseCommentShape, CASE_COMMENT_REVERSED_REASON, addCaseCommentBody, caseCommentsQuery;
17255
- var init_chunk_S7UAXLHJ = __esm({
17256
- "../../packages/core/dist/chunk-S7UAXLHJ.js"() {
17257
- "use strict";
17258
- init_chunk_7TQYAKCB();
17259
- init_chunk_VROZDNLV();
17260
- init_chunk_3T3D7LTE();
17261
- init_chunk_HZ6CADSY();
17262
- init_zod();
17263
- CASE_COMMENT_TEXT_MAX_LENGTH = CASE_NOTE_TEXT_MAX_LENGTH;
17264
- CASE_COMMENTS_PAGE_MAX = 100;
17265
- CASE_COMMENT_LINE_MAX = CASE_FILE_COMPARE_MAX_BYTES;
17266
- casePassageLineSchema = external_exports.number().int().min(1).max(CASE_COMMENT_LINE_MAX);
17267
- lineNumber = casePassageLineSchema;
17268
- addCaseCommentShape = external_exports.object({
17269
- path: caseFileReadPath,
17270
- /** The version: the revision that wrote it to `path`. */
17271
- revision_id: uuidSchema,
17272
- /** The passage's first and last lines, from 1, of the version's text ({@link casePassageLines}). */
17273
- line_start: lineNumber,
17274
- line_end: lineNumber,
17275
- text: external_exports.string().trim().min(1).max(CASE_COMMENT_TEXT_MAX_LENGTH),
17276
- /** Hidden from every reader without the Confidential right; only a holder of it may set it. */
17277
- confidential: external_exports.boolean().default(false)
17278
- }).strict();
17279
- CASE_COMMENT_REVERSED_REASON = "passage_reversed";
17280
- addCaseCommentBody = addCaseCommentShape.superRefine((comment2, ctx) => {
17281
- if (comment2.line_end < comment2.line_start) {
17282
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: CASE_COMMENT_REVERSED_REASON, path: ["line_end"] });
17283
- }
17284
- });
17285
- caseCommentsQuery = casePageQuery.extend({
17286
- path: caseFileReadPath,
17287
- /** Absent: every version's comments on the path. */
17288
- revision_id: uuidSchema.optional(),
17289
- limit: external_exports.coerce.number().int().min(1).max(CASE_COMMENTS_PAGE_MAX).optional()
17290
- });
17291
- }
17292
- });
17293
-
17294
- // ../../packages/core/dist/chunk-S4NDHW3Q.js
17295
- var CASE_VERSION_DECISION_REASON_MAX_LENGTH, CASE_VERSION_DECISIONS, caseVersionDecisionReason, reason2, lineNumber2, recordCaseReferenceBody, CASE_PASSAGE_REVERSED_REASON, citeCasePassageBody, decideCaseVersionBody;
17296
- var init_chunk_S4NDHW3Q = __esm({
17297
- "../../packages/core/dist/chunk-S4NDHW3Q.js"() {
17298
- "use strict";
17299
- init_chunk_S7UAXLHJ();
17300
- init_chunk_HZ6CADSY();
17301
- init_zod();
17302
- CASE_VERSION_DECISION_REASON_MAX_LENGTH = 2e3;
17303
- CASE_VERSION_DECISIONS = ["adopt", "keep"];
17304
- caseVersionDecisionReason = external_exports.string().trim().min(1).max(CASE_VERSION_DECISION_REASON_MAX_LENGTH);
17305
- reason2 = caseVersionDecisionReason;
17306
- lineNumber2 = casePassageLineSchema;
17307
- recordCaseReferenceBody = external_exports.object({
17308
- document_id: uuidSchema,
17309
- /** The document's version its writer read as current. */
17310
- version_id: uuidSchema
17311
- }).strict();
17312
- CASE_PASSAGE_REVERSED_REASON = CASE_COMMENT_REVERSED_REASON;
17313
- citeCasePassageBody = external_exports.object({
17314
- document_id: uuidSchema,
17315
- version_id: uuidSchema,
17316
- line_start: lineNumber2,
17317
- line_end: lineNumber2
17318
- }).strict().superRefine((body, ctx) => {
17319
- if (body.line_end < body.line_start) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: CASE_PASSAGE_REVERSED_REASON, path: ["line_end"] });
17320
- });
17321
- decideCaseVersionBody = external_exports.object({
17322
- decision: external_exports.enum(CASE_VERSION_DECISIONS),
17323
- /** The newer version its decider read as current. */
17324
- expect_version_id: uuidSchema,
17325
- reason: reason2.nullable().default(null)
17326
- }).strict().superRefine((body, ctx) => {
17327
- if (body.decision === "keep" && body.reason === null) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A version kept needs its reason", path: ["reason"] });
17328
- });
17329
- }
17330
- });
17331
-
17332
- // ../../packages/core/dist/chunk-UZ72OHQN.js
17333
- var caseInputLinkParam, caseCollectionDocumentOfCaseParam, linkCaseInputBody, CASE_COLLECTION_CASES_PAGE_MAX, caseCollectionCasesQuery, CASE_REFERENCES_PAGE_MAX, caseReferencesQuery;
17334
- var init_chunk_UZ72OHQN = __esm({
17335
- "../../packages/core/dist/chunk-UZ72OHQN.js"() {
17360
+ // ../../packages/core/dist/chunk-6ISR4YNG.js
17361
+ 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;
17362
+ var init_chunk_6ISR4YNG = __esm({
17363
+ "../../packages/core/dist/chunk-6ISR4YNG.js"() {
17336
17364
  "use strict";
17337
17365
  init_chunk_6CHDJVQ6();
17338
- init_chunk_S4NDHW3Q();
17366
+ init_chunk_U3L6QR6F();
17339
17367
  init_chunk_733K4J4G();
17340
17368
  init_chunk_3T3D7LTE();
17341
17369
  init_chunk_HZ6CADSY();
17342
17370
  init_zod();
17343
17371
  caseInputLinkParam = caseRecordParam.extend({ input_id: uuidSchema });
17344
17372
  caseCollectionDocumentOfCaseParam = caseRecordParam.extend({ document_id: uuidSchema });
17345
- linkCaseInputBody = external_exports.object({
17373
+ linkCaseCollectionInputBody = external_exports.object({
17346
17374
  document_id: uuidSchema,
17347
17375
  /** The document's version its writer read as current, or an earlier one it keeps, with its `reason`. */
17348
17376
  version_id: uuidSchema,
17349
17377
  /** Why an earlier version is kept: a version decision. Unread when `version_id` is the current one. */
17350
17378
  reason: caseVersionDecisionReason.optional()
17351
17379
  }).strict();
17380
+ linkCasePreviousOutputInputBody = external_exports.object({ official_version_id: uuidSchema }).strict();
17381
+ linkCaseReceivedInputBody = external_exports.object({ received_id: uuidSchema }).strict();
17382
+ linkCaseInputBody = external_exports.union([linkCaseCollectionInputBody, linkCasePreviousOutputInputBody, linkCaseReceivedInputBody]);
17383
+ CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON = "official_version_unknown";
17384
+ CASE_LINK_OUTPUT_NOT_PRIOR_REASON = "output_not_prior";
17385
+ CASE_LINK_RECEIVED_UNKNOWN_REASON = "received_unknown";
17386
+ CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON = "document_type_mismatch";
17387
+ CASE_LINK_VERSION_NOT_CURRENT_REASON = "link_version_not_current";
17352
17388
  CASE_COLLECTION_CASES_PAGE_MAX = 100;
17353
17389
  caseCollectionCasesQuery = casePageQuery.extend({
17354
17390
  limit: external_exports.coerce.number().int().min(1).max(CASE_COLLECTION_CASES_PAGE_MAX).optional()
@@ -17840,7 +17876,7 @@ var init_chunk_OMPT4ZHR = __esm({
17840
17876
  }
17841
17877
  });
17842
17878
 
17843
- // ../../packages/core/dist/chunk-Q5SZRRLP.js
17879
+ // ../../packages/core/dist/chunk-5XMPWEVS.js
17844
17880
  function refineScopedTarget(data, ctx) {
17845
17881
  if (data.scope === "org") {
17846
17882
  if (!data.org_id) {
@@ -17866,13 +17902,13 @@ function refineScopedTarget(data, ctx) {
17866
17902
  }
17867
17903
  }
17868
17904
  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;
17869
- var init_chunk_Q5SZRRLP = __esm({
17870
- "../../packages/core/dist/chunk-Q5SZRRLP.js"() {
17905
+ var init_chunk_5XMPWEVS = __esm({
17906
+ "../../packages/core/dist/chunk-5XMPWEVS.js"() {
17871
17907
  "use strict";
17872
17908
  init_chunk_FECLIZTY();
17873
17909
  init_chunk_BFG4ZWR4();
17874
17910
  init_chunk_UY32MQHG();
17875
- init_chunk_7NFNYPTF();
17911
+ init_chunk_ARK3766Q();
17876
17912
  init_chunk_OMPT4ZHR();
17877
17913
  init_chunk_MIWZOSPI();
17878
17914
  init_chunk_HZ6CADSY();
@@ -18028,9 +18064,10 @@ var init_chunk_Q5SZRRLP = __esm({
18028
18064
  cases_collection_bytes_quota: casesLimit(1024 ** 4).optional(),
18029
18065
  /** How many days a case's agent authorization lasts before it must be approved again (`./case-agents.ts`). */
18030
18066
  cases_agent_authorization_max_days: casesLimit(365).optional(),
18031
- /** One graph review read's file versions and bytes (`./case-review.ts`). */
18067
+ /** One graph review read's file versions and bytes, and the pairs its computation finds (`./case-review.ts`). */
18032
18068
  cases_review_files_max: casesLimit(5e4).optional(),
18033
18069
  cases_review_bytes_max: casesLimit(64 * 1024 * 1024).optional(),
18070
+ cases_review_pairs_max: casesLimit(1e5).optional(),
18034
18071
  /** How many automation gate evaluations bill one operation (`automationGateEvaluationsPerOperation`). */
18035
18072
  automation_gate_evaluations_per_operation: automationGateEvaluationsPerOperation.optional(),
18036
18073
  /** How many days a hub keeps an automation's runs (`automationRunRetentionDays`). */
@@ -18045,6 +18082,13 @@ var init_chunk_Q5SZRRLP = __esm({
18045
18082
  * it as JSON. An id no connector has matches nothing, so it leaves that connector off.
18046
18083
  */
18047
18084
  vault_connector_ids: external_exports.array(uuidSchema).max(200).optional(),
18085
+ /**
18086
+ * The organizations that may store a base credential (wayai#6142, owner decisions 8 and 27): org ids, replacing the
18087
+ * whole list; empty, the default, admits none. Read only by a base credential's create and rotation, after base
18088
+ * credentials' vault gate (`apps/backend/src/durable-objects/platform-do/base-credential-orgs.ts`); a credential
18089
+ * already stored keeps working when its org leaves the list. The route stores it as JSON.
18090
+ */
18091
+ base_credential_org_ids: external_exports.array(uuidSchema).max(200).optional(),
18048
18092
  /**
18049
18093
  * The mobile app version policy (`MOBILE_VERSION_POLICY_COLUMNS`), per platform: an install
18050
18094
  * below the minimum is blocked until it updates from the store; one below the recommended
@@ -18428,6 +18472,7 @@ var init_contracts = __esm({
18428
18472
  "use strict";
18429
18473
  init_chunk_RACEDHG6();
18430
18474
  init_chunk_Q7KIQHAZ();
18475
+ init_chunk_63UWXV4T();
18431
18476
  init_chunk_AYLAGFAD();
18432
18477
  init_chunk_OPJ5OACS();
18433
18478
  init_chunk_YVY2TZK2();
@@ -18436,71 +18481,71 @@ var init_contracts = __esm({
18436
18481
  init_chunk_WONSSUXU();
18437
18482
  init_chunk_C7UAGRXF();
18438
18483
  init_chunk_IPXBFWUU();
18439
- init_chunk_63UWXV4T();
18484
+ init_chunk_TVUDMGWV();
18440
18485
  init_chunk_WTIGECE5();
18441
18486
  init_chunk_WDAXZDJO();
18442
18487
  init_chunk_ZC6YGHNX();
18488
+ init_chunk_MGBAXT5Y();
18443
18489
  init_chunk_5DGHIY7L();
18444
18490
  init_chunk_TID3PAFF();
18445
18491
  init_chunk_IPDOHAZ5();
18446
18492
  init_chunk_PFGVH2CX();
18447
- init_chunk_TVUDMGWV();
18493
+ init_chunk_FPSDNS2E();
18448
18494
  init_chunk_TZH6DKKJ();
18449
18495
  init_chunk_SSPK6ISL();
18450
18496
  init_chunk_ZXK6N2HN();
18451
18497
  init_chunk_Y7CFCYX4();
18452
- init_chunk_MGBAXT5Y();
18453
18498
  init_chunk_YUZFHVB2();
18454
18499
  init_chunk_I3O2RACG();
18455
18500
  init_chunk_CMRECH67();
18456
18501
  init_chunk_34LE6P7E();
18457
- init_chunk_FPSDNS2E();
18502
+ init_chunk_IR2NOSI3();
18458
18503
  init_chunk_OPETF4GS();
18459
18504
  init_chunk_SY6PLCPK();
18460
18505
  init_chunk_2ZZZHXZR();
18506
+ init_chunk_MH4O3YEX();
18461
18507
  init_chunk_QEEQN2NE();
18462
18508
  init_chunk_KSTYTQ7I();
18463
18509
  init_chunk_LKBSHANA();
18464
18510
  init_chunk_LX3D5LCB();
18465
18511
  init_chunk_C4HEZ7ZI();
18466
- init_chunk_IR2NOSI3();
18467
18512
  init_chunk_UCYWGWQT();
18468
18513
  init_chunk_6AYIXGDT();
18469
18514
  init_chunk_YULHXJ5M();
18470
18515
  init_chunk_V4FRPRH5();
18471
18516
  init_chunk_LWMLR2WI();
18472
18517
  init_chunk_ACGAI25T();
18473
- init_chunk_MH4O3YEX();
18474
18518
  init_chunk_NNC2ZECG();
18475
18519
  init_chunk_7CYHPF35();
18476
18520
  init_chunk_NETRUHZF();
18477
- init_chunk_W3WJCAUF();
18521
+ init_chunk_LZHLURLT();
18478
18522
  init_chunk_QG3XMUEN();
18479
18523
  init_chunk_EBUWHIFV();
18480
18524
  init_chunk_PCQIFFYO();
18481
18525
  init_chunk_AHISKXHA();
18482
18526
  init_chunk_2YEGUQR7();
18483
18527
  init_chunk_JDJ4EUOL();
18484
- init_chunk_XUPUXNGM();
18528
+ init_chunk_6MNNZ3G4();
18485
18529
  init_chunk_K3PD6AOF();
18486
18530
  init_chunk_KVMROYDC();
18487
18531
  init_chunk_M2IF4G6X();
18532
+ init_chunk_UOPCLXCU();
18488
18533
  init_chunk_7CZSLDOE();
18489
18534
  init_chunk_2YVCHUBL();
18490
- init_chunk_RRU36I2I();
18535
+ init_chunk_NMGRRGDR();
18491
18536
  init_chunk_WYCUCSD5();
18492
18537
  init_chunk_H6V7NEWR();
18493
18538
  init_chunk_ZVIMTUGZ();
18539
+ init_chunk_Q5LS3FKY();
18494
18540
  init_chunk_BVQCYBU6();
18495
- init_chunk_UOPCLXCU();
18496
18541
  init_chunk_Z3SV3XTC();
18497
18542
  init_chunk_NHC27NIE();
18498
18543
  init_chunk_UMAPAGFH();
18499
- init_chunk_UZ72OHQN();
18544
+ init_chunk_6ISR4YNG();
18500
18545
  init_chunk_6CHDJVQ6();
18501
18546
  init_chunk_U3X3BIQH();
18502
18547
  init_chunk_EYOBPUDN();
18503
- init_chunk_S4NDHW3Q();
18548
+ init_chunk_U3L6QR6F();
18504
18549
  init_chunk_UEJOG2Q7();
18505
18550
  init_chunk_KEN2DASI();
18506
18551
  init_chunk_L5GC53VI();
@@ -18514,13 +18559,13 @@ var init_contracts = __esm({
18514
18559
  init_chunk_4LXDRTO4();
18515
18560
  init_chunk_5PKKFSSF();
18516
18561
  init_chunk_NVKU5PPQ();
18517
- init_chunk_Q5SZRRLP();
18562
+ init_chunk_5XMPWEVS();
18518
18563
  init_chunk_FECLIZTY();
18519
18564
  init_chunk_BFG4ZWR4();
18520
18565
  init_chunk_UY32MQHG();
18521
- init_chunk_7NFNYPTF();
18522
- init_chunk_X5PZZVTS();
18566
+ init_chunk_ARK3766Q();
18523
18567
  init_chunk_D3EP4TDU();
18568
+ init_chunk_X5PZZVTS();
18524
18569
  init_chunk_PIZTARVG();
18525
18570
  init_chunk_OMPT4ZHR();
18526
18571
  init_chunk_2PZIF56U();
@@ -18545,7 +18590,7 @@ var init_contracts = __esm({
18545
18590
  init_chunk_MIWZOSPI();
18546
18591
  init_chunk_2ISUBJG7();
18547
18592
  init_chunk_C2UEA2KW();
18548
- init_chunk_RHXF6X2Y();
18593
+ init_chunk_XPOCPOMA();
18549
18594
  init_chunk_5Y2NNQHX();
18550
18595
  init_chunk_S7UAXLHJ();
18551
18596
  init_chunk_7TQYAKCB();
@@ -19996,6 +20041,9 @@ var init_utils = __esm({
19996
20041
  ["admin vault-gate status", { positionals: 0 }],
19997
20042
  ["admin vault-gate add", { positionals: 1 }],
19998
20043
  ["admin vault-gate remove", { positionals: 1 }],
20044
+ ["admin base-credential-orgs status", { positionals: 0 }],
20045
+ ["admin base-credential-orgs add", { positionals: 1 }],
20046
+ ["admin base-credential-orgs remove", { positionals: 1 }],
19999
20047
  ["admin voice-calls enable", { positionals: 0 }],
20000
20048
  ["admin voice-calls disable", { positionals: 0 }],
20001
20049
  ["admin voice-calls status", { positionals: 0 }],
@@ -20094,9 +20142,9 @@ function oldLayoutEntries(root, skills, oldLayout) {
20094
20142
  function assertOldLayoutConvertible(root, skills, oldLayout, pullCommand3) {
20095
20143
  const { leftover } = oldLayoutEntries(root, skills, oldLayout);
20096
20144
  if (leftover.length === 0) return;
20097
- const one5 = leftover.length === 1;
20145
+ const one6 = leftover.length === 1;
20098
20146
  throw expected(
20099
- `${leftover.sort().join(", ")} would be removed or overwritten unseen. Converting a folder an older CLI wrote, \`${pullCommand3}\` writes ${SKILLS_DIR}/ from the platform and removes from ${OLD_RESOURCES_DIR}/ only the folders named after the skills it writes. Move ${one5 ? "it" : "them"} out of ${path8.basename(root)}/ (a knowledge backup belongs outside the workspace), then run \`${pullCommand3}\` again. Nothing was written.`
20147
+ `${leftover.sort().join(", ")} would be removed or overwritten unseen. Converting a folder an older CLI wrote, \`${pullCommand3}\` writes ${SKILLS_DIR}/ from the platform and removes from ${OLD_RESOURCES_DIR}/ only the folders named after the skills it writes. Move ${one6 ? "it" : "them"} out of ${path8.basename(root)}/ (a knowledge backup belongs outside the workspace), then run \`${pullCommand3}\` again. Nothing was written.`
20100
20148
  );
20101
20149
  }
20102
20150
  function removeConvertedOldResources(root, skills, log, opts = {}) {
@@ -20740,6 +20788,18 @@ var init_api_client = __esm({
20740
20788
  async getCaseInputLink(ref, inputId) {
20741
20789
  return this.request("GET", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/link`);
20742
20790
  }
20791
+ /** An input's link to the case's own source (an earlier phase's official version, or a received document), with its cited passages. */
20792
+ async getCaseInputSourceLink(ref, inputId) {
20793
+ return this.request("GET", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/source-link`);
20794
+ }
20795
+ /** Link an input: to a collection document's version, an earlier phase's official version, or a received document, by the body's fields. */
20796
+ async linkCaseInput(ref, inputId, body) {
20797
+ return this.request("PUT", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/link`, body);
20798
+ }
20799
+ /** Cite a passage of what an input links, by its lines: the server hashes them and answers the passage it holds. */
20800
+ async citeCaseInputPassage(ref, inputId, body) {
20801
+ return this.request("POST", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/passages`, body);
20802
+ }
20743
20803
  /**
20744
20804
  * One part of a collection document's version, through the case's own path, with the SHA-256 the space registered for
20745
20805
  * it when the part was stored (the answer's `ETag`, `"<sha>"`); `sha` is null when no such tag is answered.
@@ -24772,8 +24832,8 @@ var init_parser = __esm({
24772
24832
 
24773
24833
  // src/lib/diff-display.ts
24774
24834
  function printDiff(summary) {
24775
- const lines = summary.split("\n");
24776
- for (const line of lines) {
24835
+ const lines2 = summary.split("\n");
24836
+ for (const line of lines2) {
24777
24837
  if (line.startsWith("**") && line.endsWith("**")) {
24778
24838
  console.log(`
24779
24839
  \x1B[1m${line.replace(/\*\*/g, "")}\x1B[0m`);
@@ -25300,7 +25360,7 @@ var init_hub_materializer = __esm({
25300
25360
  var init_ci = __esm({
25301
25361
  "../../packages/core/dist/contracts/ci.js"() {
25302
25362
  "use strict";
25303
- init_chunk_W3WJCAUF();
25363
+ init_chunk_LZHLURLT();
25304
25364
  init_chunk_QG3XMUEN();
25305
25365
  init_chunk_EBUWHIFV();
25306
25366
  init_chunk_PCQIFFYO();
@@ -25309,9 +25369,9 @@ var init_ci = __esm({
25309
25369
  init_chunk_QMQGGR7Q();
25310
25370
  init_chunk_LBDH7LCG();
25311
25371
  init_chunk_4LXDRTO4();
25312
- init_chunk_7NFNYPTF();
25313
- init_chunk_X5PZZVTS();
25372
+ init_chunk_ARK3766Q();
25314
25373
  init_chunk_D3EP4TDU();
25374
+ init_chunk_X5PZZVTS();
25315
25375
  init_chunk_PIZTARVG();
25316
25376
  init_chunk_AMMLEB4T();
25317
25377
  init_chunk_IBL7FANV();
@@ -26730,30 +26790,30 @@ function countChanges(diff) {
26730
26790
  return { added, modified, removed };
26731
26791
  }
26732
26792
  function renderDiff(diff) {
26733
- const lines = [];
26793
+ const lines2 = [];
26734
26794
  for (const kind of ENTITY_KINDS) {
26735
26795
  const b = bucket(diff, kind);
26736
26796
  if (!b || isEmptyBucket(b)) continue;
26737
- lines.push(`${BOLD}${ENTITY_LABELS[kind]}s${RESET}`);
26738
- for (const e of b.added) lines.push(`${GREEN} + ${sanitizeTerminalText(e.id)}${RESET}`);
26739
- for (const m of b.modified) lines.push(`${YELLOW} ~ ${sanitizeTerminalText(m.after.id)}${RESET}`);
26797
+ lines2.push(`${BOLD}${ENTITY_LABELS[kind]}s${RESET}`);
26798
+ for (const e of b.added) lines2.push(`${GREEN} + ${sanitizeTerminalText(e.id)}${RESET}`);
26799
+ for (const m of b.modified) lines2.push(`${YELLOW} ~ ${sanitizeTerminalText(m.after.id)}${RESET}`);
26740
26800
  for (const e of b.removed) {
26741
- lines.push(
26801
+ lines2.push(
26742
26802
  isPrunable(e.id) ? `${RED} - ${sanitizeTerminalText(e.id)}${RESET}` : `${YELLOW} = ${sanitizeTerminalText(e.id)} (kept: pull cannot write its id to a file)${RESET}`
26743
26803
  );
26744
26804
  }
26745
26805
  }
26746
26806
  const { added, modified, removed } = countChanges(diff);
26747
- lines.push("");
26748
- lines.push(
26807
+ lines2.push("");
26808
+ lines2.push(
26749
26809
  `${GREEN}${added} added${RESET}, ${YELLOW}${modified} modified${RESET}, ${RED}${removed} removed${RESET}`
26750
26810
  );
26751
26811
  if (removed > 0) {
26752
- lines.push(
26812
+ lines2.push(
26753
26813
  `${RED} ${removed} entit${removed === 1 ? "y" : "ies"} exist on the base but not in your files \u2014 re-run with --prune to delete (record types cascade to their records, file types to their files).${RESET}`
26754
26814
  );
26755
26815
  }
26756
- return lines.join("\n");
26816
+ return lines2.join("\n");
26757
26817
  }
26758
26818
  var ENTITY_LABELS, GREEN, YELLOW, RED, BOLD, RESET;
26759
26819
  var init_diff_format = __esm({
@@ -27024,7 +27084,8 @@ async function assertStorageOn(client, path55, body) {
27024
27084
  await client.request("POST", path55, body);
27025
27085
  } catch (err) {
27026
27086
  if (refusalReason(err) === VALUE_MISSING) return;
27027
- if (refusalReason(err) === STORAGE_OFF) {
27087
+ const reason3 = refusalReason(err);
27088
+ if (reason3 === STORAGE_OFF || reason3 === ORG_NOT_ADMITTED) {
27028
27089
  throw expected(`${refusalMessage(err)} Nothing was read or stored.`);
27029
27090
  }
27030
27091
  throw err;
@@ -27206,7 +27267,7 @@ function buildBasesCredentialsCommand() {
27206
27267
  });
27207
27268
  return credentials;
27208
27269
  }
27209
- var STORAGE_OFF, VALUE_MISSING, RULE_NOT_COVERING, RULE_REFUSED, CREDENTIAL_REF;
27270
+ var STORAGE_OFF, ORG_NOT_ADMITTED, VALUE_MISSING, RULE_NOT_COVERING, RULE_REFUSED, CREDENTIAL_REF;
27210
27271
  var init_credentials = __esm({
27211
27272
  "src/data/commands/credentials.ts"() {
27212
27273
  "use strict";
@@ -27218,6 +27279,7 @@ var init_credentials = __esm({
27218
27279
  init_expected();
27219
27280
  init_terminal_output();
27220
27281
  STORAGE_OFF = "secret_storage_unavailable";
27282
+ ORG_NOT_ADMITTED = "org_not_admitted";
27221
27283
  VALUE_MISSING = "credential_value_not_storable";
27222
27284
  RULE_NOT_COVERING = "credential_rule_not_covering";
27223
27285
  RULE_REFUSED = "credential_rule_refused";
@@ -28438,11 +28500,11 @@ function lineDiffOf(a, b) {
28438
28500
  }
28439
28501
  return out;
28440
28502
  }
28441
- function printSection(title2, lines) {
28442
- if (lines.length === 0) return;
28503
+ function printSection(title2, lines2) {
28504
+ if (lines2.length === 0) return;
28443
28505
  console.log(`
28444
28506
  ${title2}`);
28445
- for (const line of lines) console.log(` ${line}`);
28507
+ for (const line of lines2) console.log(` ${line}`);
28446
28508
  }
28447
28509
  function printListing(listing) {
28448
28510
  printSection("Changes:", listing.changes);
@@ -30603,10 +30665,10 @@ function headingsOf(text5) {
30603
30665
  return found;
30604
30666
  }
30605
30667
  function frontMatterOf(text5) {
30606
- const lines = text5.split(/\r?\n/);
30607
- if (lines[0] !== "---") return {};
30668
+ const lines2 = text5.split(/\r?\n/);
30669
+ if (lines2[0] !== "---") return {};
30608
30670
  const fields = {};
30609
- for (const line of lines.slice(1)) {
30671
+ for (const line of lines2.slice(1)) {
30610
30672
  if (line === "---") return fields;
30611
30673
  const colon = line.indexOf(":");
30612
30674
  if (colon > 0) fields[line.slice(0, colon).trim()] = line.slice(colon + 1).trim();
@@ -31796,17 +31858,17 @@ function changedLines(before, after) {
31796
31858
  return lineDiffOf(a.slice(start, a.length - end), b.slice(start, b.length - end));
31797
31859
  }
31798
31860
  async function describeSteps(client, t, dir, steps) {
31799
- const lines = [];
31861
+ const lines2 = [];
31800
31862
  for (const step of steps) {
31801
31863
  const rel = safe2(step.rel);
31802
31864
  if (step.op === "create") {
31803
- lines.push(`${MARK.create} ${rel} (new, ${step.local.size} bytes)`);
31865
+ lines2.push(`${MARK.create} ${rel} (new, ${step.local.size} bytes)`);
31804
31866
  } else if (step.op === "delete") {
31805
- lines.push(`${MARK.delete} ${rel} (delete)`);
31867
+ lines2.push(`${MARK.delete} ${rel} (delete)`);
31806
31868
  } else {
31807
- lines.push(`${MARK.update} ${rel}`);
31869
+ lines2.push(`${MARK.update} ${rel}`);
31808
31870
  if (!isTextType(step.remote.content_type) || step.remote.size > MAX_DIFF_BYTES || step.local.size > MAX_DIFF_BYTES) {
31809
- lines.push(` (content changed: ${step.remote.size} \u2192 ${step.local.size} bytes)`);
31871
+ lines2.push(` (content changed: ${step.remote.size} \u2192 ${step.local.size} bytes)`);
31810
31872
  continue;
31811
31873
  }
31812
31874
  let bytes;
@@ -31814,15 +31876,15 @@ async function describeSteps(client, t, dir, steps) {
31814
31876
  bytes = (await client.download(filePath2(t, step.rel))).bytes;
31815
31877
  } catch (err) {
31816
31878
  if (!isNotFound(err)) throw err;
31817
- lines.push(" (deleted on the base since it was listed)");
31879
+ lines2.push(" (deleted on the base since it was listed)");
31818
31880
  continue;
31819
31881
  }
31820
31882
  const before = Buffer.from(bytes).toString("utf-8");
31821
31883
  const after = readLocal(dir, step.rel).toString("utf-8");
31822
- for (const line of changedLines(before, after)) lines.push(` ${line}`);
31884
+ for (const line of changedLines(before, after)) lines2.push(` ${line}`);
31823
31885
  }
31824
31886
  }
31825
- return lines;
31887
+ return lines2;
31826
31888
  }
31827
31889
  function printPushNotes(plan) {
31828
31890
  printSection("Changed on the base since your last pull \u2014 left as is; pull to take it:", plan.changedOnBase.map(safe2));
@@ -36035,7 +36097,7 @@ function activeAlerts(alerts) {
36035
36097
  function summarizeActiveAlertsForReport(alerts) {
36036
36098
  const active = activeAlerts(alerts);
36037
36099
  if (active.length === 0) return null;
36038
- const lines = active.map((a) => {
36100
+ const lines2 = active.map((a) => {
36039
36101
  const { label: label3 } = describeCategory(a.category);
36040
36102
  const target = formatAlertTarget(a);
36041
36103
  const providerBits = formatProviderBits(a);
@@ -36043,7 +36105,7 @@ function summarizeActiveAlertsForReport(alerts) {
36043
36105
  return `- [${a.severity}] ${a.category} (${label3}) \xB7 ${target}${providerBits ? ` \xB7 ${providerBits}` : ""}${detailBit} \xB7 seen ${a.count}\xD7`;
36044
36106
  });
36045
36107
  return `Active hub alerts at report time (${active.length}):
36046
- ${lines.join("\n")}`;
36108
+ ${lines2.join("\n")}`;
36047
36109
  }
36048
36110
  var init_hub_alerts = __esm({
36049
36111
  "src/lib/hub-alerts.ts"() {
@@ -37995,10 +38057,10 @@ var init_facts = __esm({
37995
38057
  // src/lib/call-eval/script.ts
37996
38058
  function parseCallPlan(raw) {
37997
38059
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Error('A call plan is a JSON object with a "lines" object.');
37998
- const lines = raw.lines ?? {};
37999
- if (!lines || typeof lines !== "object" || Array.isArray(lines)) throw new Error(`The call plan's "lines" must be an object keyed by line number.`);
38060
+ const lines2 = raw.lines ?? {};
38061
+ if (!lines2 || typeof lines2 !== "object" || Array.isArray(lines2)) throw new Error(`The call plan's "lines" must be an object keyed by line number.`);
38000
38062
  const out = {};
38001
- for (const [key, value] of Object.entries(lines)) {
38063
+ for (const [key, value] of Object.entries(lines2)) {
38002
38064
  if (!/^[1-9]\d*$/.test(key)) throw new Error(`Call plan line "${key}" is not a line number (1, 2, \u2026).`);
38003
38065
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Call plan line ${key} must be an object.`);
38004
38066
  const entry = value;
@@ -38032,16 +38094,16 @@ function readbackOf(value) {
38032
38094
  return read;
38033
38095
  }
38034
38096
  function buildCallScript(journey, plan = { lines: {} }) {
38035
- const lines = [];
38097
+ const lines2 = [];
38036
38098
  let current = null;
38037
38099
  const flush = () => {
38038
38100
  if (!current) return;
38039
- const n = lines.length + 1;
38101
+ const n = lines2.length + 1;
38040
38102
  const expectedReply = current.replies.join("\n").trim();
38041
38103
  const expectedFacts = extractFacts(expectedReply);
38042
38104
  const override2 = plan.lines[String(n)] ?? {};
38043
38105
  const readback = override2.readback === void 0 ? dictatedIdentifier(current.say) : override2.readback === null ? null : readbackOf(override2.readback);
38044
- lines.push({
38106
+ lines2.push({
38045
38107
  n,
38046
38108
  say: current.say,
38047
38109
  expected_reply: expectedReply,
@@ -38063,15 +38125,15 @@ function buildCallScript(journey, plan = { lines: {} }) {
38063
38125
  }
38064
38126
  }
38065
38127
  flush();
38066
- if (lines.length === 0) throw new Error(`Journey "${journey.journey_name}" has no caller line to say.`);
38067
- if (lines[0].interrupt) throw new Error("Line 1 cannot interrupt: the voice has said nothing to interrupt yet.");
38128
+ if (lines2.length === 0) throw new Error(`Journey "${journey.journey_name}" has no caller line to say.`);
38129
+ if (lines2[0].interrupt) throw new Error("Line 1 cannot interrupt: the voice has said nothing to interrupt yet.");
38068
38130
  for (const key of Object.keys(plan.lines)) {
38069
- if (Number(key) > lines.length) throw new Error(`The call plan names line ${key}, but the journey has ${lines.length} caller line${lines.length === 1 ? "" : "s"}.`);
38131
+ if (Number(key) > lines2.length) throw new Error(`The call plan names line ${key}, but the journey has ${lines2.length} caller line${lines2.length === 1 ? "" : "s"}.`);
38070
38132
  }
38071
38133
  return {
38072
38134
  journey_id: journey.journey_id,
38073
38135
  journey_name: journey.journey_name,
38074
- lines
38136
+ lines: lines2
38075
38137
  };
38076
38138
  }
38077
38139
  var PLAN_LINE_KEYS;
@@ -38156,11 +38218,11 @@ function similarity(a, b) {
38156
38218
  for (const t of ta) if (tb.has(t)) shared += 1;
38157
38219
  return shared / (ta.size + tb.size - shared);
38158
38220
  }
38159
- function alignLines(lines, utterances) {
38221
+ function alignLines(lines2, utterances) {
38160
38222
  const caller = utterances.filter((u) => u.speaker === "user");
38161
38223
  const out = /* @__PURE__ */ new Map();
38162
38224
  let next = 0;
38163
- for (const line of lines) {
38225
+ for (const line of lines2) {
38164
38226
  let best = null;
38165
38227
  for (let start = next; start <= Math.min(caller.length - 1, next + MAX_SKIP); start++) {
38166
38228
  for (let end = start; end < Math.min(caller.length, start + MAX_GROUP); end++) {
@@ -38194,17 +38256,17 @@ function timelineMs(record, iso) {
38194
38256
  return fromIso(iso) - fromIso(record.call.started_at);
38195
38257
  }
38196
38258
  function scoreRun(script, record, timings, thresholds = DEFAULT_THRESHOLDS) {
38197
- const lines = alignLines(script.lines, record.utterances);
38259
+ const lines2 = alignLines(script.lines, record.utterances);
38198
38260
  const turnsByAnchor = /* @__PURE__ */ new Map();
38199
38261
  for (const turn of record.turns) {
38200
38262
  if (!turn.anchor_message_id) continue;
38201
38263
  turnsByAnchor.set(turn.anchor_message_id, [...turnsByAnchor.get(turn.anchor_message_id) ?? [], turn]);
38202
38264
  }
38203
- const turnsOf = (n) => (lines.get(n) ?? []).flatMap((u) => turnsByAnchor.get(u.message_id) ?? []);
38265
+ const turnsOf = (n) => (lines2.get(n) ?? []).flatMap((u) => turnsByAnchor.get(u.message_id) ?? []);
38204
38266
  const voice = record.utterances.filter((u) => u.speaker === "voice_agent");
38205
38267
  const recognition = { expected: 0, recognized: 0, misses: [] };
38206
38268
  for (const line of script.lines) {
38207
- const heard = (lines.get(line.n) ?? []).map((u) => u.text).join(" ");
38269
+ const heard = (lines2.get(line.n) ?? []).map((u) => u.text).join(" ");
38208
38270
  const vetted = buildVettedSet(heard ? [heard] : []);
38209
38271
  for (const fact of extractFacts(line.say)) {
38210
38272
  recognition.expected += 1;
@@ -38257,8 +38319,8 @@ function scoreRun(script, record, timings, thresholds = DEFAULT_THRESHOLDS) {
38257
38319
  script.lines.forEach((line, i) => {
38258
38320
  if (!line.readback) return;
38259
38321
  readback.expected += 1;
38260
- const own = lines.get(line.n) ?? [];
38261
- const nextOwn = script.lines.slice(i + 1).map((l) => lines.get(l.n) ?? []).find((u) => u.length > 0);
38322
+ const own = lines2.get(line.n) ?? [];
38323
+ const nextOwn = script.lines.slice(i + 1).map((l) => lines2.get(l.n) ?? []).find((u) => u.length > 0);
38262
38324
  const from = own.length > 0 ? own[own.length - 1].end_ms : Number.POSITIVE_INFINITY;
38263
38325
  const until = nextOwn ? nextOwn[0].start_ms : Number.POSITIVE_INFINITY;
38264
38326
  const attempt = voice.filter((u) => u.start_ms >= from && u.start_ms < until).map((u) => readbackCandidate(u.text, line.readback.kind)).find((heard) => heard !== null) ?? null;
@@ -38629,40 +38691,40 @@ function problems(run) {
38629
38691
  return out;
38630
38692
  }
38631
38693
  function formatSuiteReport(report2) {
38632
- const lines = [];
38633
- lines.push(`Call eval \u2014 journey "${shown3(report2.journey.name)}" (${report2.journey.id})`);
38634
- lines.push(`Caller audio: ${report2.audio}`);
38635
- lines.push(`Cap per run: ${report2.cap.maxCallSeconds} s of call, ${report2.cap.maxOperations} WayAI operations; suite: ${usd(report2.cap.maxSuiteUsd)} of provider time at ${usd(report2.cap.providerUsdPerMinute)}/min`);
38636
- lines.push("");
38637
- for (const run of report2.runs) lines.push(runLine(run));
38638
- if (report2.skipped_runs > 0) lines.push(` ${report2.skipped_runs} run(s) not started: the suite's budget would not hold another`);
38639
- if (report2.interrupted) lines.push(" Interrupted: the call in progress was hung up and closed, and no further run was started");
38640
- lines.push("");
38641
- lines.push(`Pass rate: ${report2.pass_rate.passed}/${report2.pass_rate.scored}`);
38694
+ const lines2 = [];
38695
+ lines2.push(`Call eval \u2014 journey "${shown3(report2.journey.name)}" (${report2.journey.id})`);
38696
+ lines2.push(`Caller audio: ${report2.audio}`);
38697
+ lines2.push(`Cap per run: ${report2.cap.maxCallSeconds} s of call, ${report2.cap.maxOperations} WayAI operations; suite: ${usd(report2.cap.maxSuiteUsd)} of provider time at ${usd(report2.cap.providerUsdPerMinute)}/min`);
38698
+ lines2.push("");
38699
+ for (const run of report2.runs) lines2.push(runLine(run));
38700
+ if (report2.skipped_runs > 0) lines2.push(` ${report2.skipped_runs} run(s) not started: the suite's budget would not hold another`);
38701
+ if (report2.interrupted) lines2.push(" Interrupted: the call in progress was hung up and closed, and no further run was started");
38702
+ lines2.push("");
38703
+ lines2.push(`Pass rate: ${report2.pass_rate.passed}/${report2.pass_rate.scored}`);
38642
38704
  for (const name of SCORE_DIMENSIONS) {
38643
- lines.push(` ${DIMENSION_LABELS[name].padEnd(28)} ${report2.dimensions[name].passed}/${report2.dimensions[name].scored}`);
38705
+ lines2.push(` ${DIMENSION_LABELS[name].padEnd(28)} ${report2.dimensions[name].passed}/${report2.dimensions[name].scored}`);
38644
38706
  }
38645
- lines.push(`Latency (caller end of speech \u2192 voice's first audio): p50 ${seconds(report2.latency.p50_ms)}, p95 ${seconds(report2.latency.p95_ms)} over ${report2.latency.samples} line(s)`);
38646
- lines.push(`Cost: provider ${usd(report2.cost.provider_usd)}, WayAI operations ${report2.cost.operations}`);
38707
+ lines2.push(`Latency (caller end of speech \u2192 voice's first audio): p50 ${seconds(report2.latency.p50_ms)}, p95 ${seconds(report2.latency.p95_ms)} over ${report2.latency.samples} line(s)`);
38708
+ lines2.push(`Cost: provider ${usd(report2.cost.provider_usd)}, WayAI operations ${report2.cost.operations}`);
38647
38709
  const failing = report2.runs.filter((r) => !runPassed(r));
38648
38710
  if (failing.length > 0) {
38649
- lines.push("");
38650
- lines.push("Failures:");
38711
+ lines2.push("");
38712
+ lines2.push("Failures:");
38651
38713
  for (const run of failing) {
38652
38714
  const found = problems(run);
38653
- lines.push(` run ${run.run}: ${found.length === 0 ? `ended ${run.status}${run.stopped_by ? ` (${run.stopped_by})` : ""}` : found[0]}`);
38654
- for (const more of found.slice(1)) lines.push(` ${more}`);
38715
+ lines2.push(` run ${run.run}: ${found.length === 0 ? `ended ${run.status}${run.stopped_by ? ` (${run.stopped_by})` : ""}` : found[0]}`);
38716
+ for (const more of found.slice(1)) lines2.push(` ${more}`);
38655
38717
  }
38656
38718
  }
38657
38719
  const review = report2.runs.flatMap((r) => (r.score?.unvetted.review ?? []).map((item) => ({ run: r.run, ...item })));
38658
38720
  if (review.length > 0) {
38659
- lines.push("");
38660
- lines.push("For review (policy or action wording no delegation result carried; not counted):");
38661
- for (const item of review) lines.push(` run ${item.run}: "${shown3(item.utterance)}" [${item.markers.join(", ")}]`);
38721
+ lines2.push("");
38722
+ lines2.push("For review (policy or action wording no delegation result carried; not counted):");
38723
+ for (const item of review) lines2.push(` run ${item.run}: "${shown3(item.utterance)}" [${item.markers.join(", ")}]`);
38662
38724
  }
38663
- lines.push("");
38664
- lines.push("The judged half \u2014 style and unvetted claims as the hub's evaluator sees them \u2014 is the call-mode text run: wayai run-eval --call-mode");
38665
- return lines.join("\n");
38725
+ lines2.push("");
38726
+ lines2.push("The judged half \u2014 style and unvetted claims as the hub's evaluator sees them \u2014 is the call-mode text run: wayai run-eval --call-mode");
38727
+ return lines2.join("\n");
38666
38728
  }
38667
38729
  var DIMENSION_LABELS, shown3;
38668
38730
  var init_report = __esm({
@@ -41392,8 +41454,8 @@ function refuseFlags(sub, values, flags) {
41392
41454
  function entryLine(entry) {
41393
41455
  return ` ${text3(entry.person_id)} since ${text3(entry.created_at)}, by ${text3(entry.created_by)}`;
41394
41456
  }
41395
- function print(values, data, lines) {
41396
- console.log(values.json ? JSON.stringify(data, null, 2) : lines.join("\n"));
41457
+ function print(values, data, lines2) {
41458
+ console.log(values.json ? JSON.stringify(data, null, 2) : lines2.join("\n"));
41397
41459
  }
41398
41460
  async function persons(sub, positionals, values) {
41399
41461
  const takesTo = sub === "link-person" || sub === "unlink-person";
@@ -41438,9 +41500,9 @@ async function persons(sub, positionals, values) {
41438
41500
  }
41439
41501
  case "denied-persons": {
41440
41502
  const data = await api.listDeniedPersons(orgId, { cursor, limit });
41441
- const lines = data.denied.length === 0 ? ["Nothing is denied."] : ["Denied:", ...data.denied.map(entryLine)];
41442
- if (data.next_cursor) lines.push(`More: --cursor ${text3(data.next_cursor)}`);
41443
- print(values, data, lines);
41503
+ const lines2 = data.denied.length === 0 ? ["Nothing is denied."] : ["Denied:", ...data.denied.map(entryLine)];
41504
+ if (data.next_cursor) lines2.push(`More: --cursor ${text3(data.next_cursor)}`);
41505
+ print(values, data, lines2);
41444
41506
  return;
41445
41507
  }
41446
41508
  case "deny-person": {
@@ -42007,44 +42069,62 @@ async function readAgenda(calls, phaseId) {
42007
42069
  }
42008
42070
  return { groups, more: true };
42009
42071
  }
42010
- async function readInputTexts(calls, folder, work) {
42072
+ function checkedText(base, file, answered, cited) {
42073
+ const unmatched = cited.map((p) => ({ passage_id: p.passage_id, line_start: p.line_start, line_end: p.line_end, passage_sha: p.passage_sha, matches: false }));
42074
+ const unwritten = (status, sha) => ({ text: { ...base, status, file: null, sha, passages: unmatched }, data: null });
42075
+ if (!answered) return unwritten("no_text", null);
42076
+ if (answered.sha === null || computeHash(answered.bytes) !== answered.sha) return unwritten("hash_mismatch", answered.sha);
42077
+ const lines2 = unmatched.length ? casePassageLines(new TextDecoder("utf-8").decode(answered.bytes)) : [];
42078
+ return {
42079
+ text: {
42080
+ ...base,
42081
+ status: "written",
42082
+ file,
42083
+ sha: answered.sha,
42084
+ passages: unmatched.map((p) => {
42085
+ const inRange = p.line_start >= 1 && p.line_end >= p.line_start && p.line_end <= lines2.length;
42086
+ const text5 = Buffer.from(lines2.slice(p.line_start - 1, p.line_end).join("\n"), "utf-8");
42087
+ return { ...p, matches: inRange && computeHash(text5) === p.passage_sha };
42088
+ })
42089
+ },
42090
+ data: Buffer.from(answered.bytes.buffer, answered.bytes.byteOffset, answered.bytes.byteLength)
42091
+ };
42092
+ }
42093
+ async function readInputTexts(calls, folder, work, folders, listed3) {
42011
42094
  const { api, connection } = calls.session;
42012
- const linked = work.inputs.filter((input) => input.link?.readable === true);
42013
- const read = await Promise.all(linked.map(async (input) => {
42014
- const view = (await calls.run(() => api.getCaseInputLink(connection, input.id))).data;
42015
- if (!view?.readable) return null;
42016
- const answered = await calls.run(() => notFound(api.getCaseCollectionContent(connection, view.document_id, { part: "text", version_id: view.version_id })));
42017
- const passages = view.passages.filter((p) => p.version_id === view.version_id);
42018
- const base = { input_id: input.id, key: input.key, name: input.name, document_id: view.document_id, version_id: view.version_id };
42019
- const unmatched = passages.map((p) => ({ passage_id: p.passage_id, line_start: p.line_start, line_end: p.line_end, passage_sha: p.passage_sha, matches: false }));
42020
- if (!answered) return { text: { ...base, status: "no_text", file: null, sha: null, passages: unmatched }, data: null };
42021
- if (answered.sha === null || computeHash(answered.bytes) !== answered.sha) {
42022
- return { text: { ...base, status: "hash_mismatch", file: null, sha: answered.sha, passages: unmatched }, data: null };
42023
- }
42024
- const lines = unmatched.length ? casePassageLines(new TextDecoder("utf-8").decode(answered.bytes)) : [];
42095
+ const read = await Promise.all(work.inputs.map(async (input) => {
42025
42096
  const file = `${INPUTS_DIR}/${folder}/${segment(input.key, CASE_INPUT_KEY_PATTERN, input.id)}.md`;
42026
- return {
42027
- text: {
42028
- ...base,
42029
- status: "written",
42030
- file,
42031
- sha: answered.sha,
42032
- passages: unmatched.map((p) => {
42033
- const inRange = p.line_start >= 1 && p.line_end >= p.line_start && p.line_end <= lines.length;
42034
- const cited = Buffer.from(lines.slice(p.line_start - 1, p.line_end).join("\n"), "utf-8");
42035
- return { ...p, matches: inRange && computeHash(cited) === p.passage_sha };
42036
- })
42037
- },
42038
- data: Buffer.from(answered.bytes.buffer, answered.bytes.byteOffset, answered.bytes.byteLength)
42039
- };
42097
+ const named = { input_id: input.id, key: input.key, name: input.name };
42098
+ if (input.link?.readable === true) {
42099
+ const view2 = (await calls.run(() => api.getCaseInputLink(connection, input.id))).data;
42100
+ if (!view2?.readable) return null;
42101
+ const answered = await calls.run(() => notFound(api.getCaseCollectionContent(connection, view2.document_id, { part: "text", version_id: view2.version_id })));
42102
+ const base2 = { ...named, origin: "collection", document_id: view2.document_id, version_id: view2.version_id };
42103
+ return checkedText(base2, file, answered, view2.passages.filter((p) => p.version_id === view2.version_id));
42104
+ }
42105
+ if (input.source_link?.readable !== true) return null;
42106
+ const view = (await calls.run(() => api.getCaseInputSourceLink(connection, input.id))).data;
42107
+ if (!view?.readable) return null;
42108
+ if (view.kind === "official_version") {
42109
+ const base2 = { ...named, origin: "previous_output", official_version_id: view.official_version_id, version: view.version };
42110
+ const checked = checkedText(base2, file, null, view.passages.filter((p) => "official_version_id" in p && p.official_version_id === view.official_version_id));
42111
+ return view.has_text ? { text: { ...checked.text, status: "no_read" }, data: null } : checked;
42112
+ }
42113
+ const base = { ...named, origin: "received", received_id: view.received_id };
42114
+ const cited = view.passages.filter((p) => "received_id" in p && p.received_id === view.received_id);
42115
+ const phaseFolder = folders.get(view.phase_id);
42116
+ const rel = phaseFolder === void 0 ? void 0 : [`${phaseFolder}/received/${view.received_id}.text.md`, `conf/${phaseFolder}/received/${view.received_id}.text.md`].find((p) => listed3.has(p));
42117
+ const bytes = rel === void 0 ? null : await calls.run(() => notFound(api.getCaseFileContent(connection, rel)));
42118
+ return checkedText(base, file, bytes === null ? null : { bytes, sha: listed3.get(rel) }, cited);
42040
42119
  }));
42041
42120
  return read.filter((r) => r !== null);
42042
42121
  }
42043
- async function readWork(calls, detail, confidential) {
42122
+ async function readWork(calls, detail, confidential, listing) {
42044
42123
  const { api, connection } = calls.session;
42045
42124
  const state = (await calls.run(() => api.getCaseState(connection))).data;
42046
42125
  if (state.view !== "work") return { state, phases: [], approved: [] };
42047
42126
  const folders = new Map(detail.phases.map((p) => [p.phase_id, p.folder]));
42127
+ const listed3 = new Map(listing.files.filter((f) => listing.inRun(f.path)).map((f) => [f.path, f.sha]));
42048
42128
  const underWay = state.state.phases.filter((p) => p.status === "in_progress").map((p) => p.phase_id);
42049
42129
  const [phases, approved] = await Promise.all([
42050
42130
  Promise.all(underWay.map(async (phaseId) => {
@@ -42052,7 +42132,7 @@ async function readWork(calls, detail, confidential) {
42052
42132
  const [{ work, texts }, agenda, delivery] = await Promise.all([
42053
42133
  calls.run(() => api.getCasePhaseWork(connection, phaseId)).then(async ({ data }) => ({
42054
42134
  work: data,
42055
- texts: await readInputTexts(calls, segment(folder, CASE_PHASE_FOLDER_PATTERN, phaseId), data)
42135
+ texts: await readInputTexts(calls, segment(folder, CASE_PHASE_FOLDER_PATTERN, phaseId), data, folders, listed3)
42056
42136
  })),
42057
42137
  readAgenda(calls, phaseId),
42058
42138
  calls.run(() => api.getCaseDelivery(connection, phaseId))
@@ -42126,22 +42206,22 @@ function statusSections(detail, work, before, now) {
42126
42206
  function filesSection(input) {
42127
42207
  const now = new Map(input.files.filter((f) => input.inRun(f.path)).map((f) => [f.path, f.sha]));
42128
42208
  const before = new Map(Object.entries(input.record.files).filter(([rel]) => input.inRun(rel)).map(([rel, f]) => [rel, f.sha]));
42129
- const lines = [];
42209
+ const lines2 = [];
42130
42210
  for (const [rel, sha] of now) {
42131
- if (!before.has(rel)) lines.push(`+ ${safe6(rel)}`);
42132
- else if (before.get(rel) !== sha) lines.push(`~ ${safe6(rel)}`);
42211
+ if (!before.has(rel)) lines2.push(`+ ${safe6(rel)}`);
42212
+ else if (before.get(rel) !== sha) lines2.push(`~ ${safe6(rel)}`);
42133
42213
  }
42134
- for (const rel of before.keys()) if (!now.has(rel)) lines.push(`- ${safe6(rel)} (removed, or no longer readable here)`);
42135
- return { title: "Files on the case that differ from what this clone last pulled", lines: lines.sort((a, b) => a.slice(2) < b.slice(2) ? -1 : 1) };
42214
+ for (const rel of before.keys()) if (!now.has(rel)) lines2.push(`- ${safe6(rel)} (removed, or no longer readable here)`);
42215
+ return { title: "Files on the case that differ from what this clone last pulled", lines: lines2.sort((a, b) => a.slice(2) < b.slice(2) ? -1 : 1) };
42136
42216
  }
42137
42217
  function revisionsSection(since, hideMessages) {
42138
- const lines = since.revisions.flatMap((r) => {
42218
+ const lines2 = since.revisions.flatMap((r) => {
42139
42219
  const author = r.author?.display_name ? one(r.author.display_name) : "a person no longer named";
42140
42220
  const message = r.message !== null && !hideMessages ? `: ${one(r.message)}` : "";
42141
42221
  return [`revision ${r.revision_id}, ${r.created_at}, ${author} (${r.channel})${message}`, ...r.entries.map((e) => ` ${safe6(e.path)}${e.sha === null ? " (removed)" : ""}`)];
42142
42222
  });
42143
- if (since.more) lines.push("\u2026 and older ones: `wayai cases log` lists them all.");
42144
- return { title: "Revisions", lines };
42223
+ if (since.more) lines2.push("\u2026 and older ones: `wayai cases log` lists them all.");
42224
+ return { title: "Revisions", lines: lines2 };
42145
42225
  }
42146
42226
  function renderSections(sections) {
42147
42227
  return sections.filter((s) => s.lines.length > 0).flatMap((s) => [`${s.title}:`, ...s.lines.map((l) => ` ${l}`)]);
@@ -42152,7 +42232,9 @@ function unwrittenLines(work) {
42152
42232
  if (text5.status === "hash_mismatch") {
42153
42233
  return [`${name}: not written, its bytes do not hash to the SHA-256 the space registered for it${text5.sha === null ? " (none was answered)" : ""}.`];
42154
42234
  }
42155
- return text5.status === "no_text" ? [`${name}: the version it links holds no registered text, or is no longer readable here.`] : [];
42235
+ if (text5.status === "no_read") return [`${name}: not written, no read this authorization makes gives the text of an earlier phase's official version.`];
42236
+ if (text5.status !== "no_text") return [];
42237
+ return [text5.origin === "collection" ? `${name}: the version it links holds no registered text, or is no longer readable here.` : `${name}: the source it links holds no text, or it is no longer readable here.`];
42156
42238
  }));
42157
42239
  }
42158
42240
  function packageReadme(pkg2) {
@@ -42177,11 +42259,13 @@ function readme(detail, at, withheld, confidential, unwritten, pkg2) {
42177
42259
  "- `evidence.json`: each phase under way: its inputs with their links, its outputs and its items.",
42178
42260
  "- `agenda.json`: each phase under way: its agenda groups and decisions; and the approved decisions.",
42179
42261
  "- `deliveries.json`: each phase under way: its newest submission and manifest.",
42180
- `- \`${INPUTS_FILE}\`: each phase under way: each input whose link you may read, the version it links, where its text`,
42181
- " is here, and its cited passages (lines and hash, and whether they match the text here).",
42182
- `- \`${INPUTS_DIR}/<phase folder>/<input key>.md\`: each such input's registered text, of the version its link names,`,
42183
- " byte for byte and checked against the SHA-256 the space registered for it: line N here is the line N a citation",
42184
- " names (each line ends at a line break).",
42262
+ `- \`${INPUTS_FILE}\`: each phase under way: each input whose link you may read, the version or source it links (a`,
42263
+ " collection document's version, an earlier phase's official version, a received document), where its text is here,",
42264
+ " and its cited passages (lines and hash, and whether they match the text here).",
42265
+ `- \`${INPUTS_DIR}/<phase folder>/<input key>.md\`: each such input's registered text, of the version or source its`,
42266
+ " link names, byte for byte and checked against the SHA-256 the space registered for it: line N here is the line N a",
42267
+ " citation names (each line ends at a line break). An earlier phase's official version's text is not here: no read",
42268
+ " this authorization makes gives it.",
42185
42269
  ...unwritten.length ? ["", "Linked inputs' texts not written:", ...unwritten.map((line) => `- ${line}`)] : []
42186
42270
  ];
42187
42271
  return [
@@ -42333,7 +42417,7 @@ async function writeCaseMirror(calls, input) {
42333
42417
  const readsRevisions = before !== null || mode !== "mirror-only";
42334
42418
  const { api, connection } = calls.session;
42335
42419
  const [work, since, pkg2] = await Promise.all([
42336
- withheld ? null : readWork(calls, detail, confidential),
42420
+ withheld ? null : readWork(calls, detail, confidential, input),
42337
42421
  readsRevisions ? revisionsSince(calls, before ? before.revision_at : void 0, confidential) : NO_REVISIONS,
42338
42422
  // Asked with --confidential alone: unasked, the space leaves its marked files out, whatever right the reader holds.
42339
42423
  readPackageDelivery({
@@ -42363,9 +42447,9 @@ async function writeCaseMirror(calls, input) {
42363
42447
  if (before) sections.push(revisionsSection(since, withheld));
42364
42448
  if (mode !== "clone") sections.push(filesSection(input));
42365
42449
  if (before && work) sections.push(...statusSections(detail, work, before, now));
42366
- const lines = renderSections(sections);
42450
+ const lines2 = renderSections(sections);
42367
42451
  const heading = mode === "clone" ? "This is the clone's first pull: there is nothing earlier to compare with." : before ? `Since the last pull (${before.at}):` : "No record of an earlier pull is in this clone's mirror: only its files are compared.";
42368
- const summary = [heading, ...lines.length ? lines : before ? ["Nothing changed."] : []];
42452
+ const summary = [heading, ...lines2.length ? lines2 : before ? ["Nothing changed."] : []];
42369
42453
  const notice = confidential ? [] : ["", MIRROR_CONFIDENTIAL_NOTICE];
42370
42454
  const unwritten = unwrittenLines(work);
42371
42455
  const files = [
@@ -42469,7 +42553,7 @@ exec wayai cases pull --mirror-only --dir "$(dirname "$0")/.."
42469
42553
  }
42470
42554
  });
42471
42555
 
42472
- // ../../packages/core/dist/chunk-KAO33OFE.js
42556
+ // ../../packages/core/dist/chunk-GOGIAA5K.js
42473
42557
  function firstAtOrAfter(sorted, from) {
42474
42558
  let lo = 0;
42475
42559
  let hi = sorted.length;
@@ -42480,7 +42564,7 @@ function firstAtOrAfter(sorted, from) {
42480
42564
  }
42481
42565
  return lo < sorted.length ? sorted[lo] : -1;
42482
42566
  }
42483
- function caseMarkdownSegments(text5) {
42567
+ function segmentsOf(text5, state) {
42484
42568
  const blankStarts = [];
42485
42569
  for (let i = text5.indexOf("\n"); i >= 0; i = text5.indexOf("\n", i + 1)) {
42486
42570
  BLANK_AFTER.lastIndex = i + 1;
@@ -42508,7 +42592,10 @@ function caseMarkdownSegments(text5) {
42508
42592
  const close3 = new RegExp(`^ {0,3}${m[1][0]}{${m[1].length},}[ \\t]*\\r?$`, "gm");
42509
42593
  close3.lastIndex = start;
42510
42594
  const found = close3.exec(text5);
42511
- if (!found) return text5.length;
42595
+ if (!found) {
42596
+ if (state) state.open = true;
42597
+ return text5.length;
42598
+ }
42512
42599
  const end = found.index + found[0].length;
42513
42600
  return text5[end] === "\n" ? end + 1 : end;
42514
42601
  };
@@ -42546,6 +42633,7 @@ function caseMarkdownSegments(text5) {
42546
42633
  continue;
42547
42634
  }
42548
42635
  commentNeverCloses = true;
42636
+ if (state) state.open = true;
42549
42637
  }
42550
42638
  if (text5[i] === "`") {
42551
42639
  let j = i;
@@ -42689,31 +42777,32 @@ function anchorOf(text5) {
42689
42777
  }
42690
42778
  return null;
42691
42779
  }
42692
- function tableEnd(lines, i) {
42693
- let columns = COLUMNS.test(lines[i]) ? i : -1;
42694
- if (columns < 0 && DASHES.test(lines[i])) {
42695
- for (let n = i + 1; n < lines.length && lines[n].trim() !== ""; n++) {
42696
- if (COLUMNS.test(lines[n])) {
42780
+ function tableEnd(lines2, i, state) {
42781
+ let columns = COLUMNS.test(lines2[i]) ? i : -1;
42782
+ if (columns < 0 && DASHES.test(lines2[i])) {
42783
+ for (let n = i + 1; n < lines2.length && lines2[n].trim() !== ""; n++) {
42784
+ if (COLUMNS.test(lines2[n])) {
42697
42785
  columns = n;
42698
42786
  break;
42699
42787
  }
42700
42788
  }
42701
42789
  }
42702
42790
  if (columns < 0) return -1;
42703
- for (let n = columns + 1; n < lines.length; n++) {
42704
- if (atxHeading(lines[n]) || FENCE.test(lines[n])) return -1;
42705
- if (DASHES.test(lines[n]) || COLUMNS.test(lines[n])) return n;
42791
+ for (let n = columns + 1; n < lines2.length; n++) {
42792
+ if (atxHeading(lines2[n]) || FENCE.test(lines2[n])) return -1;
42793
+ if (DASHES.test(lines2[n]) || COLUMNS.test(lines2[n])) return n;
42706
42794
  }
42795
+ if (state) state.open = true;
42707
42796
  return -1;
42708
42797
  }
42709
- function readHeadings(lines) {
42798
+ function readHeadings(lines2, state) {
42710
42799
  const headings = [];
42711
42800
  let fence = null;
42712
42801
  let closedAt = -1;
42713
42802
  let tableUntil = -1;
42714
- for (let i = 0; i < lines.length; i++) {
42803
+ for (let i = 0; i < lines2.length; i++) {
42715
42804
  if (i <= tableUntil) continue;
42716
- const line = lines[i];
42805
+ const line = lines2[i];
42717
42806
  const mark = FENCE.exec(line);
42718
42807
  if (fence !== null) {
42719
42808
  if (mark && mark[1][0] === fence[0] && mark[1].length >= fence.length && line.trim() === mark[1]) {
@@ -42726,8 +42815,8 @@ function readHeadings(lines) {
42726
42815
  fence = mark[1];
42727
42816
  continue;
42728
42817
  }
42729
- if (i === 0 || lines[i - 1].trim() === "") {
42730
- const end = tableEnd(lines, i);
42818
+ if (i === 0 || lines2[i - 1].trim() === "") {
42819
+ const end = tableEnd(lines2, i, state);
42731
42820
  if (end > i) {
42732
42821
  tableUntil = end;
42733
42822
  continue;
@@ -42738,23 +42827,24 @@ function readHeadings(lines) {
42738
42827
  headings.push({ start: i, end: i + 1, ...atx });
42739
42828
  continue;
42740
42829
  }
42741
- const previous = lines[i - 1];
42742
- if (i > 0 && SETEXT_UNDERLINE.test(line) && previous.trim() !== "" && closedAt !== i - 1 && (i === 1 || lines[i - 2].trim() === "") && headings.at(-1)?.end !== i) {
42830
+ const previous = lines2[i - 1];
42831
+ if (i > 0 && SETEXT_UNDERLINE.test(line) && previous.trim() !== "" && closedAt !== i - 1 && (i === 1 || lines2[i - 2].trim() === "") && headings.at(-1)?.end !== i) {
42743
42832
  headings.push({ start: i - 1, end: i + 1, level: line.includes("=") ? 1 : 2, text: previous.trim() });
42744
42833
  }
42745
42834
  }
42835
+ if (state && fence !== null) state.open = true;
42746
42836
  return headings.map((h) => {
42747
42837
  const anchor = anchorOf(h.text);
42748
42838
  return { ...h, code: anchor?.code ?? null, title: anchor?.title ?? h.text };
42749
42839
  });
42750
42840
  }
42751
- function bodyWithLines(text5) {
42841
+ function bodyWithLines(text5, state) {
42752
42842
  const original = withoutBom(text5).replace(/\r\n/g, "\n");
42753
42843
  const frontMatter = CASE_FRONT_MATTER.exec(original)?.[0] ?? "";
42754
42844
  let line = 1 + (frontMatter.match(/\n/g)?.length ?? 0);
42755
42845
  let body = "";
42756
42846
  const origin = [line];
42757
- for (const segment2 of caseMarkdownSegments(original.slice(frontMatter.length))) {
42847
+ for (const segment2 of segmentsOf(original.slice(frontMatter.length), state)) {
42758
42848
  if (segment2.kind === "comment") {
42759
42849
  line += segment2.content.match(/\n/g)?.length ?? 0;
42760
42850
  continue;
@@ -42778,13 +42868,16 @@ function lastAtOrBefore(sorted, at) {
42778
42868
  return lo;
42779
42869
  }
42780
42870
  function readCaseItems(text5) {
42781
- const { body, frontMatter, origin } = bodyWithLines(text5);
42782
- const lines = body.split("\n");
42871
+ return readItems(text5);
42872
+ }
42873
+ function readItems(text5, state) {
42874
+ const { body, frontMatter, origin } = bodyWithLines(text5, state);
42875
+ const lines2 = body.split("\n");
42783
42876
  const lastLine = Math.max(1, casePassageLines(text5).length);
42784
- const headings = readHeadings(lines);
42877
+ const headings = readHeadings(lines2, state);
42785
42878
  const lineMarks = [];
42786
42879
  const malformed = [];
42787
- lines.forEach((content, n) => {
42880
+ lines2.forEach((content, n) => {
42788
42881
  const marks = [];
42789
42882
  for (const { raw, content: inner } of lineMarkers(content)) {
42790
42883
  const marker = inner === null ? null : readMarker(inner, origin[n]);
@@ -42794,8 +42887,8 @@ function readCaseItems(text5) {
42794
42887
  lineMarks.push(marks);
42795
42888
  });
42796
42889
  const ends = new Array(headings.length);
42797
- let nextAnchor = lines.length;
42798
- const nextAtLevel = new Array(7).fill(lines.length);
42890
+ let nextAnchor = lines2.length;
42891
+ const nextAtLevel = new Array(7).fill(lines2.length);
42799
42892
  for (let h = headings.length - 1; h >= 0; h--) {
42800
42893
  const heading = headings[h];
42801
42894
  let end = nextAnchor;
@@ -42804,9 +42897,9 @@ function readCaseItems(text5) {
42804
42897
  nextAtLevel[heading.level] = heading.start;
42805
42898
  if (heading.code !== null) nextAnchor = heading.start;
42806
42899
  }
42807
- const headingLine = new Array(lines.length).fill(false);
42900
+ const headingLine = new Array(lines2.length).fill(false);
42808
42901
  for (const heading of headings) for (let n = heading.start; n < heading.end; n++) headingLine[n] = true;
42809
- const inItem = new Array(lines.length).fill(false);
42902
+ const inItem = new Array(lines2.length).fill(false);
42810
42903
  const items = [];
42811
42904
  headings.forEach((heading, h) => {
42812
42905
  if (heading.code === null) return;
@@ -42816,7 +42909,7 @@ function readCaseItems(text5) {
42816
42909
  const images = [];
42817
42910
  for (let n = heading.end; n < end; n++) {
42818
42911
  for (const marker of lineMarks[n]) markers2.push(marker);
42819
- for (const target of lineImages(lines[n])) images.push({ target, line: origin[n] });
42912
+ for (const target of lineImages(lines2[n])) images.push({ target, line: origin[n] });
42820
42913
  }
42821
42914
  const internal = [];
42822
42915
  for (let o = h + 1; o < headings.length && headings[o].start < end; o++) {
@@ -42824,7 +42917,7 @@ function readCaseItems(text5) {
42824
42917
  if (other.start >= heading.end) internal.push({ level: other.level, text: other.title, line: origin[other.start] });
42825
42918
  }
42826
42919
  const prose = [];
42827
- for (let n = heading.end; n < end; n++) if (!headingLine[n]) prose.push(lines[n]);
42920
+ for (let n = heading.end; n < end; n++) if (!headingLine[n]) prose.push(lines2[n]);
42828
42921
  const proseText = prose.join("\n");
42829
42922
  let withoutFills = "";
42830
42923
  let from = 0;
@@ -42838,7 +42931,7 @@ function readCaseItems(text5) {
42838
42931
  title: heading.title,
42839
42932
  level: heading.level,
42840
42933
  lines: { start: origin[heading.start], end: Math.max(origin[heading.start], Math.min(origin[end - 1], lastLine)) },
42841
- text: lines.slice(heading.end, end).join("\n"),
42934
+ text: lines2.slice(heading.end, end).join("\n"),
42842
42935
  has_text: withoutFills.trim() !== "",
42843
42936
  headings: internal,
42844
42937
  markers: markers2,
@@ -42853,17 +42946,30 @@ function readCaseItems(text5) {
42853
42946
  const fills = fillsOf(body).map((fill) => ({ text: fill.text, line: origin[lastAtOrBefore(lineStarts, fill.start)] }));
42854
42947
  const markers = [];
42855
42948
  for (const marks of lineMarks) for (const marker of marks) markers.push(marker);
42949
+ const outside = lines2.filter((_, n) => !inItem[n]);
42950
+ if (state) {
42951
+ let last = headings.length - 1;
42952
+ while (last >= 0 && headings[last].code === null) last--;
42953
+ state.open_level = last >= 0 && ends[last] === lines2.length ? headings[last].level : null;
42954
+ const anchored = headings.find((heading) => heading.code !== null)?.start ?? lines2.length;
42955
+ state.lead = {
42956
+ lines: lines2.slice(0, anchored),
42957
+ marks: lineMarks.slice(0, anchored),
42958
+ headings: headings.filter((heading) => heading.start < anchored).map((heading) => ({ start: heading.start, level: heading.level }))
42959
+ };
42960
+ state.outside = outside;
42961
+ }
42856
42962
  return {
42857
42963
  items,
42858
42964
  markers,
42859
42965
  fills,
42860
- outside: { front_matter: frontMatter, body: lines.filter((_, n) => !inItem[n]).join("\n") },
42966
+ outside: { front_matter: frontMatter, body: outside.join("\n") },
42861
42967
  malformed_markers: malformed
42862
42968
  };
42863
42969
  }
42864
- var CASE_COMPOSED_COVER, CASE_ITEM_READER_MAX_CHARS, FENCE_OPEN, BLANK_AFTER, CASE_FRONT_MATTER, withoutBom, FENCE, SETEXT_UNDERLINE, DASHES, COLUMNS, patternBody, CALCULATION_MARKER, DECISION_MARKER, DOCUMENT_MARKER, INPUT_MARKER, isSpace, isTabOrSpace, once;
42865
- var init_chunk_KAO33OFE = __esm({
42866
- "../../packages/core/dist/chunk-KAO33OFE.js"() {
42970
+ var CASE_COMPOSED_COVER, CASE_ITEM_READER_MAX_CHARS, FENCE_OPEN, BLANK_AFTER, CASE_FRONT_MATTER, FRONT_MATTER_OPENING, withoutBom, FENCE, SETEXT_UNDERLINE, DASHES, COLUMNS, patternBody, CALCULATION_MARKER, DECISION_MARKER, DOCUMENT_MARKER, INPUT_MARKER, isSpace, isTabOrSpace, once, OPENS_FRONT_MATTER;
42971
+ var init_chunk_GOGIAA5K = __esm({
42972
+ "../../packages/core/dist/chunk-GOGIAA5K.js"() {
42867
42973
  "use strict";
42868
42974
  init_chunk_S7UAXLHJ();
42869
42975
  init_chunk_PFPADFUC();
@@ -42872,6 +42978,7 @@ var init_chunk_KAO33OFE = __esm({
42872
42978
  FENCE_OPEN = / {0,3}(`{3,}|~{3,})([^\n]*)(?:\n|$)/y;
42873
42979
  BLANK_AFTER = /[ \t]*\r?\n/y;
42874
42980
  CASE_FRONT_MATTER = /^---\r?\n(?![ \t]*\r?\n)([\s\S]*?)\r?\n---/;
42981
+ FRONT_MATTER_OPENING = CASE_FRONT_MATTER.source.slice(0, CASE_FRONT_MATTER.source.indexOf("(["));
42875
42982
  withoutBom = (text5) => text5.replace(/^\uFEFF/, "");
42876
42983
  FENCE = /^ {0,3}(`{3,}|~{3,})/;
42877
42984
  SETEXT_UNDERLINE = /^ {0,3}(=+|-+)[ \t]*$/;
@@ -42887,6 +42994,7 @@ var init_chunk_KAO33OFE = __esm({
42887
42994
  isSpace = (c) => c !== void 0 && /\s/.test(c);
42888
42995
  isTabOrSpace = (c) => c === " " || c === " ";
42889
42996
  once = (values) => [...new Set(values)];
42997
+ OPENS_FRONT_MATTER = new RegExp(FRONT_MATTER_OPENING);
42890
42998
  }
42891
42999
  });
42892
43000
 
@@ -42894,7 +43002,7 @@ var init_chunk_KAO33OFE = __esm({
42894
43002
  var init_case_item_reader = __esm({
42895
43003
  "../../packages/core/dist/case-item-reader.js"() {
42896
43004
  "use strict";
42897
- init_chunk_KAO33OFE();
43005
+ init_chunk_GOGIAA5K();
42898
43006
  init_chunk_S7UAXLHJ();
42899
43007
  init_chunk_7TQYAKCB();
42900
43008
  init_chunk_VROZDNLV();
@@ -42932,12 +43040,12 @@ function skeletonParts(input) {
42932
43040
  let underGrouping = false;
42933
43041
  for (const item of input.items) {
42934
43042
  const nested = !item.grouping && underGrouping;
42935
- const lines = [`${nested ? "###" : "##"} ${oneLine(item.title)} {#${item.code}}`, ""];
43043
+ const lines2 = [`${nested ? "###" : "##"} ${oneLine(item.title)} {#${item.code}}`, ""];
42936
43044
  if (item.grouping) underGrouping = true;
42937
43045
  const body = item.grouping ? null : item.template_mode === "fixed" && item.fixed_text !== null ? item.fixed_text.trim() : item.template !== null ? fillAttributes(item.template.trim(), input.attributes, missing) : `{{fill: ${oneLine(item.title)}}}`;
42938
- if (body) lines.push(body, "");
42939
- if (nested) sections[sections.length - 1].lines.push(...lines);
42940
- else sections.push({ code: item.code, lines });
43046
+ if (body) lines2.push(body, "");
43047
+ if (nested) sections[sections.length - 1].lines.push(...lines2);
43048
+ else sections.push({ code: item.code, lines: lines2 });
42941
43049
  }
42942
43050
  return { cover, sections, missing: [...missing].sort() };
42943
43051
  }
@@ -42961,12 +43069,289 @@ var init_case_skeleton = __esm({
42961
43069
  MARK2 = /\{\{\s*([^{}:]+?)\s*(?::[^{}]*)?\}\}/g;
42962
43070
  FILL = "fill";
42963
43071
  oneLine = (text5) => text5.replace(/\s*\r?\n\s*/g, " ").trim();
42964
- close2 = (lines) => `${lines.join("\n").trimEnd()}
43072
+ close2 = (lines2) => `${lines2.join("\n").trimEnd()}
42965
43073
  `;
42966
43074
  fillsIn = (text5) => readCaseItems(text5).fills.length;
42967
43075
  }
42968
43076
  });
42969
43077
 
43078
+ // ../../packages/core/dist/contracts/case-collection-links.js
43079
+ var init_case_collection_links = __esm({
43080
+ "../../packages/core/dist/contracts/case-collection-links.js"() {
43081
+ "use strict";
43082
+ init_chunk_6ISR4YNG();
43083
+ init_chunk_6CHDJVQ6();
43084
+ init_chunk_U3X3BIQH();
43085
+ init_chunk_EYOBPUDN();
43086
+ init_chunk_U3L6QR6F();
43087
+ init_chunk_S7UAXLHJ();
43088
+ init_chunk_7TQYAKCB();
43089
+ init_chunk_VROZDNLV();
43090
+ init_chunk_733K4J4G();
43091
+ init_chunk_PFPADFUC();
43092
+ init_chunk_KWRHZBGU();
43093
+ init_chunk_3T3D7LTE();
43094
+ init_chunk_M2T55BV6();
43095
+ init_chunk_VYINA6YP();
43096
+ init_chunk_ZVXO3XL6();
43097
+ init_chunk_FBV7NLKO();
43098
+ init_chunk_WEXVYJ5H();
43099
+ init_chunk_HZ6CADSY();
43100
+ init_chunk_ICYO56QW();
43101
+ init_chunk_WFQDSQJK();
43102
+ init_chunk_ZTNFLGW5();
43103
+ }
43104
+ });
43105
+
43106
+ // ../../packages/core/dist/contracts/case-collection-citations.js
43107
+ var init_case_collection_citations = __esm({
43108
+ "../../packages/core/dist/contracts/case-collection-citations.js"() {
43109
+ "use strict";
43110
+ init_chunk_U3L6QR6F();
43111
+ init_chunk_S7UAXLHJ();
43112
+ init_chunk_7TQYAKCB();
43113
+ init_chunk_VROZDNLV();
43114
+ init_chunk_733K4J4G();
43115
+ init_chunk_PFPADFUC();
43116
+ init_chunk_KWRHZBGU();
43117
+ init_chunk_3T3D7LTE();
43118
+ init_chunk_M2T55BV6();
43119
+ init_chunk_VYINA6YP();
43120
+ init_chunk_ZVXO3XL6();
43121
+ init_chunk_FBV7NLKO();
43122
+ init_chunk_WEXVYJ5H();
43123
+ init_chunk_HZ6CADSY();
43124
+ init_chunk_ICYO56QW();
43125
+ init_chunk_WFQDSQJK();
43126
+ init_chunk_ZTNFLGW5();
43127
+ }
43128
+ });
43129
+
43130
+ // src/cases/case-inputs.ts
43131
+ function inputLinkState(input) {
43132
+ const unlinked = input.dispensation ? { state: "dispensed" } : { state: "unlinked" };
43133
+ if (input.origin === "collection") {
43134
+ const link2 = input.link;
43135
+ if (!link2) return unlinked;
43136
+ if (!link2.readable) return { state: "unreadable", linked_at: link2.linked_at };
43137
+ const source2 = {
43138
+ kind: "collection",
43139
+ document_id: link2.document_id,
43140
+ version_id: link2.version_id,
43141
+ document_title: link2.document_title,
43142
+ version_title: link2.version_title
43143
+ };
43144
+ return link2.pending_version_id ? { state: "undecided", linked_at: link2.linked_at, source: source2, current_id: link2.pending_version_id } : { state: "linked", linked_at: link2.linked_at, source: source2 };
43145
+ }
43146
+ const link = input.source_link;
43147
+ if (link === void 0) return input.dispensation ? { state: "dispensed" } : { state: "unknown" };
43148
+ if (link === null) return unlinked;
43149
+ if (!link.readable) return { state: "unreadable", linked_at: link.linked_at };
43150
+ if (link.kind === "received") {
43151
+ return {
43152
+ state: "linked",
43153
+ linked_at: link.linked_at,
43154
+ source: { kind: "received", received_id: link.received_id, title: link.title, type: link.type, phase_id: link.phase_id }
43155
+ };
43156
+ }
43157
+ const source = {
43158
+ kind: "official_version",
43159
+ official_version_id: link.official_version_id,
43160
+ output_code: link.output_code,
43161
+ phase_id: link.phase_id,
43162
+ version: link.version
43163
+ };
43164
+ return link.current_version_id === link.official_version_id ? { state: "linked", linked_at: link.linked_at, source } : { state: "undecided", linked_at: link.linked_at, source, current_id: link.current_version_id };
43165
+ }
43166
+ function linkCommand(key, folder, origin, id) {
43167
+ const [flag, placeholder] = origin === "previous_output" ? ["--official-version", "<official_version_id>"] : ["--received", "<received_id>"];
43168
+ return `wayai cases link ${one2(key)} --phase ${one2(folder)} ${flag} ${id ?? placeholder}`;
43169
+ }
43170
+ function linkHint(key, folder, origin) {
43171
+ if (origin === "collection") return "a person links it, in the web app";
43172
+ if (origin === "received") {
43173
+ return `link it to a received document of the case: \`${linkCommand(key, folder, origin)}\` (the id is in its files' names under a phase's received/)`;
43174
+ }
43175
+ return `link it to the current official version of an earlier phase's output: \`${linkCommand(key, folder, origin)}\` (no wayai cases command lists those: a person gives you the id, or links it in the web app)`;
43176
+ }
43177
+ function undecidedWords(input, folder, link, folders) {
43178
+ const linked = sourceWords(link.source, folders);
43179
+ if (link.source.kind === "collection") {
43180
+ return { text: `links ${linked}, and a newer version awaits a decision: a person decides on it, in the web app`, agent: false };
43181
+ }
43182
+ if (link.current_id === null) {
43183
+ return { text: `links ${linked}, which a correction superseded by a version not readable here: a person who reads it relinks it`, agent: false };
43184
+ }
43185
+ return {
43186
+ text: `links ${linked}, which a correction superseded: relink it to the current one: \`${linkCommand(input.key, folder, input.origin, link.current_id)}\``,
43187
+ agent: true
43188
+ };
43189
+ }
43190
+ function inputLine(input, folder, folders) {
43191
+ const head = `${one2(input.key)} (${one2(input.name)}), ${input.origin.replaceAll("_", " ")}${input.required ? ", required" : ""}`;
43192
+ const state = inputLinkState(input);
43193
+ switch (state.state) {
43194
+ case "linked":
43195
+ return `${head}: linked to ${sourceWords(state.source, folders)}`;
43196
+ case "undecided":
43197
+ return `${head}: ${undecidedWords(input, folder, state, folders).text}`;
43198
+ case "unreadable":
43199
+ return `${head}: linked, to a source not readable here`;
43200
+ case "dispensed":
43201
+ return `${head}: dispensed`;
43202
+ case "unknown":
43203
+ return `${head}: this server does not say whether it is linked`;
43204
+ case "unlinked":
43205
+ return `${head}: not linked; ${linkHint(input.key, folder, input.origin)}`;
43206
+ }
43207
+ }
43208
+ function findInput(work, phase, name) {
43209
+ const input = work.inputs.find((i) => i.key === name) ?? work.inputs.find((i) => i.id === name);
43210
+ if (input) return input;
43211
+ throw expected(`Phase ${phase.folder} has no input ${JSON.stringify(sanitizeTerminalText(name))} you may read. Its inputs: ${work.inputs.map((i) => one2(i.key)).join(", ") || "none"}.`);
43212
+ }
43213
+ function linkTarget(opts) {
43214
+ if (opts.officialVersion === void 0 === (opts.received === void 0)) {
43215
+ throw expected("link takes one of --official-version <id> (an input of origin previous_output) or --received <id> (an input of origin received).");
43216
+ }
43217
+ if (opts.officialVersion !== void 0) {
43218
+ if (!UUID_RE3.test(opts.officialVersion)) throw expected("--official-version takes an official version's id (a UUID).");
43219
+ return { official_version_id: opts.officialVersion };
43220
+ }
43221
+ if (!UUID_RE3.test(opts.received)) throw expected("--received takes a received document's id (a UUID).");
43222
+ return { received_id: opts.received };
43223
+ }
43224
+ function linkMismatch(input, label3, target) {
43225
+ if (input.origin === "collection") return `The ${label3} links a collection document: a person links it, in the web app.`;
43226
+ const wants = "official_version_id" in target ? "previous_output" : "received";
43227
+ if (input.origin === wants) return null;
43228
+ return input.origin === "previous_output" ? `The ${label3} links an earlier phase's official version: pass --official-version <id>.` : `The ${label3} links a received document of the case: pass --received <id>.`;
43229
+ }
43230
+ function detailOf(err, field) {
43231
+ try {
43232
+ const value = JSON.parse(err.body).details?.[field];
43233
+ return typeof value === "string" || value === null ? value : void 0;
43234
+ } catch {
43235
+ return void 0;
43236
+ }
43237
+ }
43238
+ function linkFailure(err, session, named) {
43239
+ if (!(err instanceof ApiError)) return err;
43240
+ const reason3 = extractApiErrorReason(err);
43241
+ const { label: label3 } = named;
43242
+ if (err.status === 409 && reason3 === CASE_LINK_VERSION_NOT_CURRENT_REASON) {
43243
+ const current = detailOf(err, "current_version_id");
43244
+ return expected(typeof current === "string" && UUID_RE3.test(current) ? `A correction superseded official version ${named.id}: link the current one: \`${linkCommand(named.key, named.folder, named.origin, current)}\`.` : `A correction superseded official version ${named.id}, and the current one is not readable here: a person who reads it links it.`);
43245
+ }
43246
+ if (err.status === 400) {
43247
+ switch (reason3) {
43248
+ case CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON:
43249
+ return expected(`The case holds no official version ${named.id} this authorization may read.`);
43250
+ case CASE_LINK_OUTPUT_NOT_PRIOR_REASON:
43251
+ return expected(`Official version ${named.id} is of an output of no phase ${named.folder} depends on: the ${label3} links one of an earlier phase's.`);
43252
+ case CASE_LINK_RECEIVED_UNKNOWN_REASON:
43253
+ return expected(`The case holds no received document ${named.id} this authorization may read.`);
43254
+ case CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON:
43255
+ return expected(`${named.id} is not of the document type the ${label3} asks for.`);
43256
+ case CASE_CLOSED_REASON:
43257
+ return expected(`Case ${session.connection.code} is closed: it takes no link.`);
43258
+ default:
43259
+ break;
43260
+ }
43261
+ }
43262
+ if (err.status === 403) return expected(`Your access to case ${session.connection.code} does not link its inputs: that takes Edit level.`);
43263
+ return caseCallFailure(err, session.connection, `The ${label3} was not found`);
43264
+ }
43265
+ function passageLines(text5) {
43266
+ const m = /^([1-9][0-9]*)(?:-([1-9][0-9]*))?$/.exec(text5);
43267
+ if (!m) throw expected("cite takes its lines as <start> or <start>-<end> (as 12-18), from 1.");
43268
+ const lines2 = { line_start: Number(m[1]), line_end: Number(m[2] ?? m[1]) };
43269
+ if (lines2.line_end < lines2.line_start) throw expected("cite takes its lines with the last at or after the first.");
43270
+ return lines2;
43271
+ }
43272
+ function passageSource(input, label3) {
43273
+ const state = inputLinkState(input);
43274
+ if (state.state === "unreadable") throw expected(`The ${label3} links a source not readable here: no passage of it can be cited with this authorization.`);
43275
+ if (state.state === "unknown") throw expected(`This server does not say what the ${label3} links: no passage can be cited from here.`);
43276
+ if (state.state !== "linked" && state.state !== "undecided") throw expected(`The ${label3} is not linked: link it first.`);
43277
+ const { source } = state;
43278
+ if (source.kind === "collection") return { document_id: source.document_id, version_id: source.version_id };
43279
+ return source.kind === "official_version" ? { official_version_id: source.official_version_id } : { received_id: source.received_id };
43280
+ }
43281
+ function citeFailure(err, session, named) {
43282
+ if (!(err instanceof ApiError)) return err;
43283
+ const reason3 = extractApiErrorReason(err);
43284
+ if (err.status === 409 && reason3 === CASE_PASSAGE_LINK_CHANGED_REASON) {
43285
+ return expected(`The ${named.label} links another source since it was read: read it again (\`wayai cases explain --phase ${named.folder}\`), then cite.`);
43286
+ }
43287
+ if (err.status === 400) {
43288
+ switch (reason3) {
43289
+ case CASE_PASSAGE_OUT_OF_RANGE_REASON:
43290
+ return expected(`Lines ${named.lines.line_start}-${named.lines.line_end} run past the last line of what the ${named.label} links.`);
43291
+ case CASE_PASSAGE_NO_TEXT_REASON:
43292
+ return expected(`What the ${named.label} links holds no text to cite (a file piece, or a version with none).`);
43293
+ case CASE_CLOSED_REASON:
43294
+ return expected(`Case ${session.connection.code} is closed: it takes no passage.`);
43295
+ default:
43296
+ break;
43297
+ }
43298
+ }
43299
+ if (err.status === 403) return expected(`Your access to case ${session.connection.code} does not cite passages: that takes Edit level.`);
43300
+ return caseCallFailure(err, session.connection, `The ${named.label} was not found`);
43301
+ }
43302
+ var one2, sourceWords;
43303
+ var init_case_inputs = __esm({
43304
+ "src/cases/case-inputs.ts"() {
43305
+ "use strict";
43306
+ init_case_records();
43307
+ init_case_collection_links();
43308
+ init_case_collection_citations();
43309
+ init_api_client();
43310
+ init_errors3();
43311
+ init_expected();
43312
+ init_terminal_output();
43313
+ init_utils();
43314
+ init_case_session();
43315
+ one2 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
43316
+ sourceWords = (source, folders) => {
43317
+ const folder = (phaseId) => one2(folders.get(phaseId) ?? phaseId);
43318
+ switch (source.kind) {
43319
+ case "collection":
43320
+ return `version "${one2(source.version_title)}" of document "${one2(source.document_title)}"`;
43321
+ case "official_version":
43322
+ return `version ${source.version} of output ${one2(source.output_code)} (phase ${folder(source.phase_id)}) [${source.official_version_id}]`;
43323
+ case "received":
43324
+ return `received document "${one2(source.title)}" (${one2(source.type)}), registered in ${folder(source.phase_id)} [${source.received_id}]`;
43325
+ }
43326
+ };
43327
+ }
43328
+ });
43329
+
43330
+ // ../../packages/core/dist/contracts/case-input-sources.js
43331
+ var init_case_input_sources = __esm({
43332
+ "../../packages/core/dist/contracts/case-input-sources.js"() {
43333
+ "use strict";
43334
+ init_chunk_Q5LS3FKY();
43335
+ init_chunk_U3L6QR6F();
43336
+ init_chunk_S7UAXLHJ();
43337
+ init_chunk_7TQYAKCB();
43338
+ init_chunk_VROZDNLV();
43339
+ init_chunk_733K4J4G();
43340
+ init_chunk_PFPADFUC();
43341
+ init_chunk_KWRHZBGU();
43342
+ init_chunk_3T3D7LTE();
43343
+ init_chunk_M2T55BV6();
43344
+ init_chunk_VYINA6YP();
43345
+ init_chunk_ZVXO3XL6();
43346
+ init_chunk_FBV7NLKO();
43347
+ init_chunk_WEXVYJ5H();
43348
+ init_chunk_HZ6CADSY();
43349
+ init_chunk_ICYO56QW();
43350
+ init_chunk_WFQDSQJK();
43351
+ init_chunk_ZTNFLGW5();
43352
+ }
43353
+ });
43354
+
42970
43355
  // ../../packages/core/dist/contracts/case-notes.js
42971
43356
  var init_case_notes = __esm({
42972
43357
  "../../packages/core/dist/contracts/case-notes.js"() {
@@ -42992,7 +43377,7 @@ var init_case_notes = __esm({
42992
43377
  var init_case_checks = __esm({
42993
43378
  "../../packages/core/dist/contracts/case-checks.js"() {
42994
43379
  "use strict";
42995
- init_chunk_RHXF6X2Y();
43380
+ init_chunk_XPOCPOMA();
42996
43381
  init_chunk_5Y2NNQHX();
42997
43382
  init_chunk_HZ6CADSY();
42998
43383
  }
@@ -43026,7 +43411,7 @@ function blockerLine(b, names) {
43026
43411
  case "task_pending":
43027
43412
  return `${names.task(b.case_task_id)} is open`;
43028
43413
  case "input_pending":
43029
- return `${names.input(b.input_id)} is neither linked nor dispensed`;
43414
+ return `${names.input(b.input_id)} is neither linked nor dispensed${names.inputHint(b.input_id)}`;
43030
43415
  case "agenda_group_pending":
43031
43416
  return b.actor === "approver" ? `${names.group(b.agenda_group_id)} awaits approval by its teams` : `${names.group(b.agenda_group_id)} is ${statusWords(b.group_status)}: propose its values; a person at Conduct level sends it`;
43032
43417
  case "task_dependency_pending":
@@ -43035,9 +43420,9 @@ function blockerLine(b, names) {
43035
43420
  return `something confidential is pending (${b.actor})`;
43036
43421
  }
43037
43422
  }
43038
- async function namesFor(session, detail, phaseIds) {
43423
+ async function namesFor(session, detail, phaseIds, opts = {}) {
43039
43424
  const names = new CaseNames(session, detail);
43040
- if (readsWork(detail)) for (const id of phaseIds) await names.readPhase(id);
43425
+ if (readsWork(detail)) for (const id of phaseIds) await names.readPhase(id, opts.agenda ?? true);
43041
43426
  return names;
43042
43427
  }
43043
43428
  function printPhasesView(detail, state) {
@@ -43067,13 +43452,13 @@ async function caseBrief(session, opts) {
43067
43452
  console.log(JSON.stringify({ case: detail, state, open_notes: notes }, null, 2));
43068
43453
  return;
43069
43454
  }
43070
- const head = `${detail.code}, ${one2(detail.type_name)} (version ${detail.version})${detail.confidential ? ", confidential" : ""}`;
43455
+ const head = `${detail.code}, ${one3(detail.type_name)} (version ${detail.version})${detail.confidential ? ", confidential" : ""}`;
43071
43456
  console.log(head);
43072
43457
  if (detail.closure) {
43073
- console.log(`Closed on ${detail.closure.closed_at}${detail.closure.outcome_name ? `: ${one2(detail.closure.outcome_name)}` : ""}.`);
43458
+ console.log(`Closed on ${detail.closure.closed_at}${detail.closure.outcome_name ? `: ${one3(detail.closure.outcome_name)}` : ""}.`);
43074
43459
  }
43075
- if (detail.owner?.display_name) console.log(`Owner: ${one2(detail.owner.display_name)}.`);
43076
- if (detail.parties?.length) console.log(`Parties: ${detail.parties.map((p) => `${one2(p.role)}: ${one2(p.name)}`).join("; ")}.`);
43460
+ if (detail.owner?.display_name) console.log(`Owner: ${one3(detail.owner.display_name)}.`);
43461
+ if (detail.parties?.length) console.log(`Parties: ${detail.parties.map((p) => `${one3(p.role)}: ${one3(p.name)}`).join("; ")}.`);
43077
43462
  if (state.view === "phases") {
43078
43463
  printPhasesView(detail, state);
43079
43464
  return;
@@ -43093,7 +43478,7 @@ async function caseBrief(session, opts) {
43093
43478
  console.log(`Open tasks (${open.length}):`);
43094
43479
  for (const t of open) {
43095
43480
  const st = taskState.get(t.case_task_id);
43096
- console.log(` ${byId.get(t.phase_id)?.folder ?? ""}: ${one2(t.name)}${t.required ? " (required)" : ""}${st?.status === "waiting" ? ", waits for another task" : ""}${st?.late ? ", late" : ""} [${t.case_task_id}]`);
43481
+ console.log(` ${byId.get(t.phase_id)?.folder ?? ""}: ${one3(t.name)}${t.required ? " (required)" : ""}${st?.status === "waiting" ? ", waits for another task" : ""}${st?.late ? ", late" : ""} [${t.case_task_id}]`);
43097
43482
  }
43098
43483
  }
43099
43484
  if (notes.length) {
@@ -43110,7 +43495,8 @@ async function caseExplain(session, opts) {
43110
43495
  return;
43111
43496
  }
43112
43497
  if (opts.json) {
43113
- console.log(JSON.stringify({ case: detail, state }, null, 2));
43498
+ const inputs2 = asked && readsWork(detail) ? (await namesFor(session, detail, [asked.phase_id], { agenda: false })).phaseInputs.get(asked.phase_id) ?? [] : null;
43499
+ console.log(JSON.stringify({ case: detail, state, ...inputs2 ? { inputs: inputs2.map(inputJson) } : {} }, null, 2));
43114
43500
  return;
43115
43501
  }
43116
43502
  const phases = asked ? state.phases.filter((p) => p.phase_id === asked.phase_id) : state.phases;
@@ -43133,7 +43519,7 @@ async function caseExplain(session, opts) {
43133
43519
  const shown4 = fullyNamed.has(p.phase_id) ? p.blockers : p.blockers.filter((b) => b.reason === "phase_dependency_pending" || b.reason === "phase_not_activated");
43134
43520
  for (const b of shown4) console.log(` - ${blockerLine(b, names)}`);
43135
43521
  const rest = p.blockers.length - shown4.length;
43136
- if (rest > 0) console.log(` - and ${rest} requirement${rest === 1 ? "" : "s"} of its own (\`wayai cases explain --phase ${one2(names.phaseRow(p.phase_id)?.folder ?? "")}\`)`);
43522
+ if (rest > 0) console.log(` - and ${rest} requirement${rest === 1 ? "" : "s"} of its own (\`wayai cases explain --phase ${one3(names.phaseRow(p.phase_id)?.folder ?? "")}\`)`);
43137
43523
  }
43138
43524
  const taskPhase = new Map((detail.tasks ?? []).map((t) => [t.case_task_id, t.phase_id]));
43139
43525
  const tasks = state.tasks.filter((t) => fullyNamed.has(taskPhase.get(t.case_task_id) ?? ""));
@@ -43141,12 +43527,19 @@ async function caseExplain(session, opts) {
43141
43527
  console.log("Open tasks:");
43142
43528
  for (const t of tasks) console.log(` ${names.taskName(t.case_task_id)} [${t.case_task_id}]: ${t.blockers.map((b) => blockerLine(b, names)).join("; ")}`);
43143
43529
  }
43530
+ const inputs = asked ? names.phaseInputs.get(asked.phase_id) ?? [] : [];
43531
+ if (inputs.length) {
43532
+ console.log(`Inputs of ${asked.folder}:`);
43533
+ const folders = names.folders();
43534
+ for (const i of inputs) console.log(` ${inputLine(i, asked.folder, folders)}`);
43535
+ }
43144
43536
  }
43145
- function agentWork(b) {
43537
+ function agentWork(b, names) {
43146
43538
  switch (b.reason) {
43147
43539
  case "output_pending":
43148
43540
  return b.submission === null;
43149
43541
  case "input_pending":
43542
+ return names.inputOrigin(b.input_id) !== "collection";
43150
43543
  case "task_pending":
43151
43544
  case "publication_pending":
43152
43545
  return true;
@@ -43168,7 +43561,10 @@ async function caseNext(session, opts) {
43168
43561
  return;
43169
43562
  }
43170
43563
  const underWay = state.phases.filter((p) => p.status === "in_progress");
43171
- const notes = readsWork(detail) ? await openNotes(session) : [];
43564
+ const [notes, names] = await Promise.all([
43565
+ readsWork(detail) ? openNotes(session) : [],
43566
+ namesFor(session, detail, underWay.map((p) => p.phase_id), { agenda: !opts.json })
43567
+ ]);
43172
43568
  const yours = [];
43173
43569
  const others = [];
43174
43570
  const seen = /* @__PURE__ */ new Set();
@@ -43177,28 +43573,38 @@ async function caseNext(session, opts) {
43177
43573
  const key = blockerKey(b);
43178
43574
  if (key && seen.has(key)) continue;
43179
43575
  if (key) seen.add(key);
43180
- (agentWork(b) ? yours : others).push({ phase_id: p.phase_id, blocker: b });
43576
+ (agentWork(b, names) ? yours : others).push({ phase_id: p.phase_id, blocker: b });
43181
43577
  }
43182
43578
  }
43579
+ const folders = names.folders();
43580
+ const undecided = underWay.flatMap((p) => (names.phaseInputs.get(p.phase_id) ?? []).flatMap((input) => {
43581
+ const link = inputLinkState(input);
43582
+ if (link.state !== "undecided") return [];
43583
+ const folder = folders.get(p.phase_id) ?? "";
43584
+ return [{ phase_id: p.phase_id, input, ...undecidedWords(input, folder, link, folders) }];
43585
+ }));
43183
43586
  if (opts.json) {
43184
- console.log(JSON.stringify({ to_do: yours, waiting_on_others: others, open_notes: notes }, null, 2));
43587
+ const undecidedJson = undecided.map((u) => ({ phase_id: u.phase_id, ...inputJson(u.input), agent: u.agent }));
43588
+ console.log(JSON.stringify({ to_do: yours, waiting_on_others: others, undecided_inputs: undecidedJson, open_notes: notes }, null, 2));
43185
43589
  return;
43186
43590
  }
43187
- const names = await namesFor(session, detail, underWay.map((p) => p.phase_id));
43591
+ const undecidedLine = (u) => ` ${folders.get(u.phase_id) ?? ""}: ${names.input(u.input.id)} ${u.text}`;
43188
43592
  if (underWay.length === 0) console.log(`No phase of ${detail.code} is under way.`);
43189
- if (yours.length) {
43593
+ if (yours.length || undecided.some((u) => u.agent)) {
43190
43594
  console.log("To do:");
43191
43595
  for (const { phase_id, blocker } of yours) console.log(` ${names.phaseRow(phase_id)?.folder ?? ""}: ${blockerLine(blocker, names)}`);
43596
+ for (const u of undecided.filter((u2) => u2.agent)) console.log(undecidedLine(u));
43192
43597
  }
43193
43598
  if (notes.length) {
43194
43599
  console.log("Open pending items and next steps:");
43195
43600
  for (const n of notes) console.log(` ${noteLine(n)}`);
43196
43601
  }
43197
- if (others.length) {
43602
+ if (others.length || undecided.some((u) => !u.agent)) {
43198
43603
  console.log("Waiting on someone else:");
43199
43604
  for (const { phase_id, blocker } of others) console.log(` ${names.phaseRow(phase_id)?.folder ?? ""}: ${blockerLine(blocker, names)}`);
43605
+ for (const u of undecided.filter((u2) => !u2.agent)) console.log(undecidedLine(u));
43200
43606
  }
43201
- if (underWay.length && !yours.length && !notes.length && !others.length) console.log("Nothing is pending on the phases under way.");
43607
+ if (underWay.length && !yours.length && !notes.length && !others.length && !undecided.length) console.log("Nothing is pending on the phases under way.");
43202
43608
  }
43203
43609
  function clonePackageCheck(session) {
43204
43610
  const clone = findCaseClone(process.cwd());
@@ -43220,7 +43626,7 @@ async function caseCheck(session, opts) {
43220
43626
  const work = (await call2(session, () => session.api.getCasePhaseWork(session.connection, phase.phase_id))).data;
43221
43627
  const output = work.outputs.find((o) => o.code === opts.output);
43222
43628
  if (!output) {
43223
- throw expected(`Phase ${phase.folder} has no output ${JSON.stringify(sanitizeTerminalText(opts.output))}. Its outputs: ${work.outputs.map((o) => one2(o.code)).join(", ") || "none"}.`);
43629
+ throw expected(`Phase ${phase.folder} has no output ${JSON.stringify(sanitizeTerminalText(opts.output))}. Its outputs: ${work.outputs.map((o) => one3(o.code)).join(", ") || "none"}.`);
43224
43630
  }
43225
43631
  outputId = output.id;
43226
43632
  }
@@ -43236,13 +43642,13 @@ async function caseCheck(session, opts) {
43236
43642
  const warnings = checks.problems.length - errors;
43237
43643
  console.log(`Checks of ${phase.folder}${opts.output ? `, output ${opts.output}` : ""}, over the case's files as WayAI holds them: ${errors} error${errors === 1 ? "" : "s"}, ${warnings} warning${warnings === 1 ? "" : "s"}. A submit now would be ${checks.refused ? "refused" : "accepted by the checks"}.`);
43238
43644
  for (const p of checks.problems) {
43239
- const where = [p.output_code && one2(p.output_code), p.path && `${one2(p.path)}${p.line ? `:${p.line}` : ""}`].filter(Boolean).join(" ");
43240
- const what = p.confidential ? "about something confidential" : [p.subject && one2(p.subject), p.expected !== null && `expected ${one2(p.expected)}`, p.found !== null && `found ${one2(p.found)}`, p.count !== null && `${p.count}\xD7`].filter(Boolean).join(", ");
43645
+ const where = [p.output_code && one3(p.output_code), p.path && `${one3(p.path)}${p.line ? `:${p.line}` : ""}`].filter(Boolean).join(" ");
43646
+ const what = p.confidential ? "about something confidential" : [p.subject && one3(p.subject), p.expected !== null && `expected ${one3(p.expected)}`, p.found !== null && `found ${one3(p.found)}`, p.count !== null && `${p.count}\xD7`].filter(Boolean).join(", ");
43241
43647
  console.log(` ${p.severity} ${p.code}${where ? ` [${where}]` : ""}${what ? `: ${what}` : ""}`);
43242
43648
  }
43243
43649
  if (checks.truncated) console.log(" (more problems were found than one answer carries)");
43244
43650
  for (const c of checks.coverage) {
43245
- console.log(`Coverage of ${one2(c.output_code)}: ${c.ready} of ${c.total} items ready${c.dispensed ? `, ${c.dispensed} dispensed` : ""}.`);
43651
+ console.log(`Coverage of ${one3(c.output_code)}: ${c.ready} of ${c.total} items ready${c.dispensed ? `, ${c.dispensed} dispensed` : ""}.`);
43246
43652
  }
43247
43653
  if (pkg2) for (const line of packageCheckLines(pkg2, CASE_MIRROR_DIR)) console.log(line);
43248
43654
  }
@@ -43274,7 +43680,7 @@ async function caseDecisions(session, opts) {
43274
43680
  }
43275
43681
  }
43276
43682
  for (const r of results) {
43277
- const listed3 = r.rows.length ? `: ${r.rows.map((d) => one2(d.code)).join(", ")}` : ", with its header alone: no decision is approved yet";
43683
+ const listed3 = r.rows.length ? `: ${r.rows.map((d) => one3(d.code)).join(", ")}` : ", with its header alone: no decision is approved yet";
43278
43684
  console.log(`${r.rel} ${r.outcome === "written" ? "written" : "already up to date"}${listed3}.`);
43279
43685
  }
43280
43686
  }
@@ -43293,7 +43699,7 @@ async function caseNote(session, text5, opts) {
43293
43699
  async function caseNoteDone(session, noteId) {
43294
43700
  if (!UUID_RE3.test(noteId)) throw expected("note done takes a note's id, as `wayai cases next` shows it.");
43295
43701
  const note = (await call2(session, () => session.api.completeCaseNote(session.connection, noteId), `Note ${noteId} was not found`)).data;
43296
- console.log(`Done: ${one2(note.text)}`);
43702
+ console.log(`Done: ${one3(note.text)}`);
43297
43703
  }
43298
43704
  function sizeOf(file) {
43299
43705
  try {
@@ -43328,9 +43734,41 @@ async function caseReceivedAdd(session, file, opts) {
43328
43734
  { name, bytes },
43329
43735
  text5
43330
43736
  ))).data;
43331
- console.log(`${one2(received.title)} registered in ${phase.folder}/received/ of ${session.connection.code}: ${received.received_id}`);
43737
+ console.log(`${one3(received.title)} registered in ${phase.folder}/received/ of ${session.connection.code}: ${received.received_id}`);
43332
43738
  if (received.text_origin === "agent") console.log("Its text is marked as converted by an agent, for whoever reviews it.");
43333
43739
  }
43740
+ async function locateInput(session, inputName, phaseName) {
43741
+ const phase = findPhase(await loadCase(session), phaseName);
43742
+ const work = (await call2(session, () => session.api.getCasePhaseWork(session.connection, phase.phase_id))).data;
43743
+ const input = findInput(work, phase, inputName);
43744
+ return { phase, input, label: `input ${one3(input.key)} of ${phase.folder}` };
43745
+ }
43746
+ async function caseLink(session, inputName, opts) {
43747
+ const target = linkTarget(opts);
43748
+ const { phase, input, label: label3 } = await locateInput(session, inputName, opts.phase);
43749
+ const mismatch = linkMismatch(input, label3, target);
43750
+ if (mismatch) throw expected(mismatch);
43751
+ const [kind, id] = "official_version_id" in target ? ["official version", target.official_version_id] : ["received document", target.received_id];
43752
+ let linked;
43753
+ try {
43754
+ linked = (await session.api.linkCaseInput(session.connection, input.id, target)).data;
43755
+ } catch (err) {
43756
+ throw linkFailure(err, session, { label: label3, key: input.key, folder: phase.folder, origin: input.origin, id });
43757
+ }
43758
+ console.log(`Linked the ${label3} to ${kind} ${id} (linked since ${linked.linked_at}).`);
43759
+ }
43760
+ async function caseCite(session, inputName, lines2, opts) {
43761
+ const { phase, input, label: label3 } = await locateInput(session, inputName, opts.phase);
43762
+ const parsed = citeCaseInputPassageBody.safeParse({ ...passageSource(input, label3), ...lines2 });
43763
+ if (!parsed.success) throw expected(`The passage is refused: ${parsed.error.issues[0]?.message ?? "not of its shape"}.`);
43764
+ let passage;
43765
+ try {
43766
+ passage = (await session.api.citeCaseInputPassage(session.connection, input.id, parsed.data)).data;
43767
+ } catch (err) {
43768
+ throw citeFailure(err, session, { label: label3, folder: phase.folder, lines: lines2 });
43769
+ }
43770
+ console.log(`Cited lines ${passage.line_start}-${passage.line_end} of what the ${label3} links (SHA-256 ${passage.passage_sha}): ${passage.passage_id}`);
43771
+ }
43334
43772
  function markedThroughout(work) {
43335
43773
  const rows = [...work.inputs, ...work.items, ...work.items.flatMap((i) => i.item_links.depends_on)];
43336
43774
  return rows.every((row) => typeof row.confidential === "boolean");
@@ -43364,7 +43802,7 @@ async function caseSkeleton(session, clone, opts) {
43364
43802
  const workItems = opts.confidential ? work.items : work.items.filter((i) => i.confidential !== true);
43365
43803
  const outputs = opts.output === void 0 ? work.outputs : work.outputs.filter((o) => o.code === opts.output);
43366
43804
  if (opts.output !== void 0 && outputs.length === 0) {
43367
- throw expected(`Phase ${phase.folder} has no output ${JSON.stringify(sanitizeTerminalText(opts.output))}. Its outputs: ${work.outputs.map((o) => one2(o.code)).join(", ") || "none"}.`);
43805
+ throw expected(`Phase ${phase.folder} has no output ${JSON.stringify(sanitizeTerminalText(opts.output))}. Its outputs: ${work.outputs.map((o) => one3(o.code)).join(", ") || "none"}.`);
43368
43806
  }
43369
43807
  const plans = await withMirrorLock(clone.root, async () => {
43370
43808
  const pkg2 = deliveredPackage(clone.root, mirror);
@@ -43379,7 +43817,7 @@ async function caseSkeleton(session, clone, opts) {
43379
43817
  };
43380
43818
  if (!CASE_PHASE_FOLDER_PATTERN.test(phase.folder)) problems2.push(`the phase's folder ${JSON.stringify(sanitizeTerminalText(phase.folder))} is no phase folder`);
43381
43819
  const planned = outputs.map((output) => {
43382
- const code2 = one2(output.code);
43820
+ const code2 = one3(output.code);
43383
43821
  const bad = output.file_paths.filter((p) => !casePath2(p.endsWith("/") ? `${p}${CASE_COMPOSED_COVER}` : p, false));
43384
43822
  for (const p of bad) problems2.push(`output ${code2}: ${JSON.stringify(sanitizeTerminalText(p))} is no path of this phase a document can be written at`);
43385
43823
  if (bad.length) return null;
@@ -43400,7 +43838,7 @@ async function caseSkeleton(session, clone, opts) {
43400
43838
  const rel = `templates/${phase.folder}/${item.code}.md`;
43401
43839
  const file = pkg2.file(rel);
43402
43840
  if (file.state !== "unlisted" && file.confidential && !opts.confidential) {
43403
- problems2.push(`item ${one2(item.code)} of output ${code2}: its template is confidential, used only with --confidential`);
43841
+ problems2.push(`item ${one3(item.code)} of output ${code2}: its template is confidential, used only with --confidential`);
43404
43842
  } else if (file.state === "ok") {
43405
43843
  template = file.bytes.toString("utf-8");
43406
43844
  } else if (file.state !== "unlisted") {
@@ -43425,7 +43863,7 @@ async function caseSkeleton(session, clone, opts) {
43425
43863
  }
43426
43864
  return planned.filter((p) => p !== null);
43427
43865
  });
43428
- console.log(`Skeleton of ${phase.folder}${opts.output ? `, output ${one2(opts.output)}` : ""}:`);
43866
+ console.log(`Skeleton of ${phase.folder}${opts.output ? `, output ${one3(opts.output)}` : ""}:`);
43429
43867
  let wrote = false;
43430
43868
  for (const plan of plans) {
43431
43869
  if ("skipped" in plan) {
@@ -43442,13 +43880,13 @@ async function caseSkeleton(session, clone, opts) {
43442
43880
  const chapters = plan.path.endsWith("/") ? `, in ${written.length - 1} chapter${written.length === 2 ? "" : "s"}` : "";
43443
43881
  console.log(` ${plan.code}: wrote ${sanitizeTerminalText(plan.path)}, ${plan.items} item${plan.items === 1 ? "" : "s"}${chapters}, ${fills} to fill.`);
43444
43882
  for (const f of plan.files.filter((f2) => !written.includes(f2))) console.log(` ${sanitizeTerminalText(f.rel)} appeared while this ran: left as it is.`);
43445
- if (plan.missing.length) console.log(` Attributes the case holds no value for, left as {{fill: \u2026}}: ${plan.missing.map(one2).join(", ")}.`);
43883
+ if (plan.missing.length) console.log(` Attributes the case holds no value for, left as {{fill: \u2026}}: ${plan.missing.map(one3).join(", ")}.`);
43446
43884
  }
43447
43885
  if (wrote) console.log("Replace each {{fill: \u2026}} with its text, then push.");
43448
43886
  if (!opts.confidential) console.log(`
43449
43887
  ${SKELETON_CONFIDENTIAL_NOTICE}`);
43450
43888
  }
43451
- var NOTE_PAGES_READ, NOTES_PAGE, AGENDA_PAGES_READ2, one2, loadCase, loadState, phaseLabel, statusWords, CaseNames, AWAITING, readsWork, PHASES_VIEW_NOTE, noteLine, blockerKey, SKELETON_CONFIDENTIAL_REQUIRED, SKELETON_CONFIDENTIAL_NOTICE;
43889
+ var NOTE_PAGES_READ, NOTES_PAGE, AGENDA_PAGES_READ2, one3, loadCase, loadState, phaseLabel, statusWords, CaseNames, AWAITING, readsWork, PHASES_VIEW_NOTE, noteLine, inputJson, blockerKey, SKELETON_CONFIDENTIAL_REQUIRED, SKELETON_CONFIDENTIAL_NOTICE;
43452
43890
  var init_case_work = __esm({
43453
43891
  "src/cases/case-work.ts"() {
43454
43892
  "use strict";
@@ -43461,6 +43899,8 @@ var init_case_work = __esm({
43461
43899
  init_case_mirror();
43462
43900
  init_case_package();
43463
43901
  init_case_skeleton();
43902
+ init_case_inputs();
43903
+ init_case_input_sources();
43464
43904
  init_case_item_reader();
43465
43905
  init_case_file_paths();
43466
43906
  init_case_types();
@@ -43470,32 +43910,36 @@ var init_case_work = __esm({
43470
43910
  NOTE_PAGES_READ = 3;
43471
43911
  NOTES_PAGE = CASE_NOTES_PAGE_MAX;
43472
43912
  AGENDA_PAGES_READ2 = 5;
43473
- one2 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
43913
+ one3 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
43474
43914
  loadCase = async (s) => (await call2(s, () => s.api.getCase(s.connection))).data;
43475
43915
  loadState = async (s) => (await call2(s, () => s.api.getCaseState(s.connection))).data;
43476
- phaseLabel = (p) => `${one2(p.folder)} (${one2(p.name)})`;
43916
+ phaseLabel = (p) => `${one3(p.folder)} (${one3(p.name)})`;
43477
43917
  statusWords = (status) => status.replaceAll("_", " ");
43478
43918
  CaseNames = class {
43479
43919
  constructor(session, detail) {
43480
43920
  this.session = session;
43481
43921
  this.phases = new Map(detail.phases.map((p) => [p.phase_id, p]));
43482
- this.tasks = new Map((detail.tasks ?? []).map((t) => [t.case_task_id, one2(t.name)]));
43922
+ this.tasks = new Map((detail.tasks ?? []).map((t) => [t.case_task_id, one3(t.name)]));
43483
43923
  }
43484
43924
  phases;
43485
43925
  tasks;
43486
43926
  outputs = /* @__PURE__ */ new Map();
43487
43927
  inputs = /* @__PURE__ */ new Map();
43488
43928
  groups = /* @__PURE__ */ new Map();
43489
- /** Read one phase's outputs, inputs and agenda groups, to name them. */
43490
- async readPhase(phaseId) {
43929
+ /** Each phase read's inputs, in their order. */
43930
+ phaseInputs = /* @__PURE__ */ new Map();
43931
+ /** Read one phase's outputs and inputs, and (unless `agenda` is false) its agenda groups, to name them. */
43932
+ async readPhase(phaseId, agenda = true) {
43491
43933
  const s = this.session;
43492
43934
  const work = (await call2(s, () => s.api.getCasePhaseWork(s.connection, phaseId))).data;
43493
- for (const o of work.outputs) this.outputs.set(o.id, `${one2(o.code)} (${one2(o.document_type)})`);
43494
- for (const i of work.inputs) this.inputs.set(i.id, `${one2(i.key)} (${one2(i.name)})`);
43935
+ for (const o of work.outputs) this.outputs.set(o.id, `${one3(o.code)} (${one3(o.document_type)})`);
43936
+ const folder = this.phases.get(phaseId)?.folder ?? "";
43937
+ for (const i of work.inputs) this.inputs.set(i.id, { label: `${one3(i.key)} (${one3(i.name)})`, input: i, folder });
43938
+ this.phaseInputs.set(phaseId, work.inputs);
43495
43939
  let cursor;
43496
- for (let page = 0; page < AGENDA_PAGES_READ2; page++) {
43940
+ for (let page = 0; agenda && page < AGENDA_PAGES_READ2; page++) {
43497
43941
  const { groups, next_cursor } = (await call2(s, () => s.api.getCaseAgenda(s.connection, phaseId, cursor))).data;
43498
- for (const g of groups) this.groups.set(g.agenda_group_id, `${one2(g.code)} (${one2(g.name)})`);
43942
+ for (const g of groups) this.groups.set(g.agenda_group_id, `${one3(g.code)} (${one3(g.name)})`);
43499
43943
  if (!next_cursor) break;
43500
43944
  cursor = next_cursor;
43501
43945
  }
@@ -43518,7 +43962,20 @@ var init_case_work = __esm({
43518
43962
  return this.outputs.has(id) ? `output ${this.outputs.get(id)}` : "an output";
43519
43963
  }
43520
43964
  input(id) {
43521
- return this.inputs.has(id) ? `input ${this.inputs.get(id)}` : "an input";
43965
+ return this.inputs.has(id) ? `input ${this.inputs.get(id).label}` : "an input";
43966
+ }
43967
+ /** How an unlinked input is linked (`./case-inputs.ts` `linkHint`), after a colon; nothing for one not read. */
43968
+ inputHint(id) {
43969
+ const named = this.inputs.get(id);
43970
+ return named ? `: ${linkHint(named.input.key, named.folder, named.input.origin)}` : "";
43971
+ }
43972
+ /** An input's origin, or undefined for one not read. */
43973
+ inputOrigin(id) {
43974
+ return this.inputs.get(id)?.input.origin;
43975
+ }
43976
+ /** Each phase's folder, by phase id. */
43977
+ folders() {
43978
+ return new Map([...this.phases].map(([id, p]) => [id, p.folder]));
43522
43979
  }
43523
43980
  group(id) {
43524
43981
  return this.groups.has(id) ? `agenda group ${this.groups.get(id)}` : "an agenda group";
@@ -43532,7 +43989,8 @@ var init_case_work = __esm({
43532
43989
  };
43533
43990
  readsWork = (detail) => detail.access.capabilities.includes("view_work");
43534
43991
  PHASES_VIEW_NOTE = "You see only the phases' status of this case: its work is not yours to read here.";
43535
- noteLine = (n) => `${n.kind === "pending" ? "pending" : "next step"}: ${one2(n.text)} [${n.note_id}]`;
43992
+ noteLine = (n) => `${n.kind === "pending" ? "pending" : "next step"}: ${one3(n.text)} [${n.note_id}]`;
43993
+ inputJson = (i) => ({ input_id: i.id, key: i.key, origin: i.origin, required: i.required, link: inputLinkState(i) });
43536
43994
  blockerKey = (b) => {
43537
43995
  switch (b.reason) {
43538
43996
  case "output_pending":
@@ -44059,11 +44517,11 @@ async function caseLog(selector, opts) {
44059
44517
  }
44060
44518
  if (shown4.length === 0) console.log(`Case ${safe7(detail.code)} has no revision you read here.`);
44061
44519
  for (const r of shown4) {
44062
- const author = r.author?.display_name ? one3(r.author.display_name) : "a person no longer named";
44520
+ const author = r.author?.display_name ? one4(r.author.display_name) : "a person no longer named";
44063
44521
  console.log(`revision ${r.revision_id} ${r.created_at} ${author} (${r.channel})`);
44064
- if (r.message !== null) console.log(` ${one3(r.message)}`);
44522
+ if (r.message !== null) console.log(` ${one4(r.message)}`);
44065
44523
  else console.log(hideMessages ? " (message not shown without --confidential)" : " (message hidden)");
44066
- if (r.session) console.log(` session: ${one3(r.session)}`);
44524
+ if (r.session) console.log(` session: ${one4(r.session)}`);
44067
44525
  for (const e of r.entries) console.log(` ${safe7(e.path)}${e.sha === null ? " (removed)" : ""}`);
44068
44526
  }
44069
44527
  if (more && shown4.length > 0) console.log(`
@@ -44071,7 +44529,7 @@ Older revisions follow: --limit ${Math.min(LOG_MAX, limit * 2)} shows more.`);
44071
44529
  if (!opts.confidential) console.log(`
44072
44530
  ${CONFIDENTIAL_NOTICE}`);
44073
44531
  }
44074
- var THEIRS_SUFFIX, MAX_LIST_PAGES2, LOG_DEFAULT, LOG_MAX, MAX_LOG_PAGES, PART_OVERHEAD_BYTES, CONFIDENTIAL_NOTICE, safe7, one3, CaseCalls, phaseFoldersOf, isTheirs, recordedFile, PULL_CONFLICT2, inRunOf, PUSH_CONFLICT2;
44532
+ var THEIRS_SUFFIX, MAX_LIST_PAGES2, LOG_DEFAULT, LOG_MAX, MAX_LOG_PAGES, PART_OVERHEAD_BYTES, CONFIDENTIAL_NOTICE, safe7, one4, CaseCalls, phaseFoldersOf, isTheirs, recordedFile, PULL_CONFLICT2, inRunOf, PUSH_CONFLICT2;
44075
44533
  var init_case_files2 = __esm({
44076
44534
  "src/cases/case-files.ts"() {
44077
44535
  "use strict";
@@ -44101,7 +44559,7 @@ var init_case_files2 = __esm({
44101
44559
  PART_OVERHEAD_BYTES = 512;
44102
44560
  CONFIDENTIAL_NOTICE = "Confidential files are left out unless you pass --confidential.";
44103
44561
  safe7 = (text5) => sanitizeTerminalText(text5);
44104
- one3 = (text5) => sanitizeTerminalText(text5).replace(/\s*\n\s*/g, " ");
44562
+ one4 = (text5) => sanitizeTerminalText(text5).replace(/\s*\n\s*/g, " ");
44105
44563
  CaseCalls = class {
44106
44564
  constructor(session) {
44107
44565
  this.session = session;
@@ -44208,7 +44666,7 @@ async function requireConfidential(session) {
44208
44666
  const detail = (await call3(session, () => session.api.getCase(session.connection))).data;
44209
44667
  if (!detail.access.capabilities.includes("read_confidential")) {
44210
44668
  throw expected(
44211
- `This machine's authorization on case ${one4(detail.code)} does not hold the Confidential right, so --confidential reads nothing more. Run it without --confidential.`
44669
+ `This machine's authorization on case ${one5(detail.code)} does not hold the Confidential right, so --confidential reads nothing more. Run it without --confidential.`
44212
44670
  );
44213
44671
  }
44214
44672
  }
@@ -44221,7 +44679,7 @@ function block(label3, text5, none) {
44221
44679
  for (const line of sanitizeTerminalText(text5).split("\n")) console.log(` | ${line}`);
44222
44680
  }
44223
44681
  function verdictCommand(connection, graph, pair) {
44224
- return `wayai cases review verdict <${VERDICTS.join("|")}> ${one4(pair.source)} ${one4(pair.neighbor)} --revision ${one4(graph.revision_id ?? "")} --source-hash ${one4(pair.source_hash)} --neighbor-hash ${one4(pair.neighbor_hash)}${graph.confidential ? " --confidential" : ""} --case ${one4(connection.code)} --org ${one4(connection.org_id)} --space ${one4(connection.space_id)} --reason "<why>"`;
44682
+ return `wayai cases review verdict <${VERDICTS.join("|")}> ${one5(pair.source)} ${one5(pair.neighbor)} --revision ${one5(graph.revision_id ?? "")} --source-hash ${one5(pair.source_hash)} --neighbor-hash ${one5(pair.neighbor_hash)}${graph.confidential ? " --confidential" : ""} --case ${one5(connection.code)} --org ${one5(connection.org_id)} --space ${one5(connection.space_id)} --reason "<why>"`;
44225
44683
  }
44226
44684
  async function caseReview(session, opts) {
44227
44685
  if (opts.confidential) await requireConfidential(session);
@@ -44244,15 +44702,15 @@ function printReview(connection, graph) {
44244
44702
  notice();
44245
44703
  return;
44246
44704
  }
44247
- console.log(`Review of case ${code2} at revision ${one4(graph.revision_id)}${graph.confidential ? ", with confidential content" : ""}.`);
44248
- console.log(graph.base_revision_id ? `Base: revision ${one4(graph.base_revision_id)}. Nothing you read here is pending.` : "Base: each item's own, below. Something you read here is pending.");
44705
+ console.log(`Review of case ${code2} at revision ${one5(graph.revision_id)}${graph.confidential ? ", with confidential content" : ""}.`);
44706
+ console.log(graph.base_revision_id ? `Base: revision ${one5(graph.base_revision_id)}. Nothing you read here is pending.` : "Base: each item's own, below. Something you read here is pending.");
44249
44707
  const titles = new Map(graph.items.map((item) => [item.key, item.title]));
44250
44708
  if (graph.items.length) {
44251
44709
  console.log(`
44252
44710
  Changed items (${graph.items.length}):`);
44253
44711
  for (const item of graph.items) {
44254
- console.log(` ${one4(item.key)}, "${one4(item.title)}" (${item.state}, round ${item.round}), in ${one4(item.path)}${item.base_revision_id ? `, since revision ${one4(item.base_revision_id)}` : ""}`);
44255
- if (item.causes.length) console.log(` because: ${item.causes.map(one4).join("; ")}`);
44712
+ console.log(` ${one5(item.key)}, "${one5(item.title)}" (${item.state}, round ${item.round}), in ${one5(item.path)}${item.base_revision_id ? `, since revision ${one5(item.base_revision_id)}` : ""}`);
44713
+ if (item.causes.length) console.log(` because: ${item.causes.map(one5).join("; ")}`);
44256
44714
  block("before", item.before, "not there at its base");
44257
44715
  block("now", item.text, "removed");
44258
44716
  }
@@ -44262,8 +44720,8 @@ Changed items (${graph.items.length}):`);
44262
44720
  Pairs awaiting a verdict (${graph.pairs.length}):`);
44263
44721
  for (const pair of graph.pairs) {
44264
44722
  const source = titles.get(pair.source);
44265
- console.log(` ${one4(pair.source)}${source ? ` "${one4(source)}"` : ""} \u2192 ${one4(pair.neighbor)} "${one4(pair.neighbor_title)}" (round ${pair.round} of ${CASE_REVIEW_ROUNDS_MAX}), in ${one4(pair.path)}`);
44266
- if (pair.reasons.length) console.log(` connected: ${pair.reasons.map(one4).join("; ")}`);
44723
+ console.log(` ${one5(pair.source)}${source ? ` "${one5(source)}"` : ""} \u2192 ${one5(pair.neighbor)} "${one5(pair.neighbor_title)}" (round ${pair.round} of ${CASE_REVIEW_ROUNDS_MAX}), in ${one5(pair.path)}`);
44724
+ if (pair.reasons.length) console.log(` connected: ${pair.reasons.map(one5).join("; ")}`);
44267
44725
  console.log(` ${verdictCommand(connection, graph, pair)}`);
44268
44726
  }
44269
44727
  }
@@ -44271,16 +44729,16 @@ Pairs awaiting a verdict (${graph.pairs.length}):`);
44271
44729
  console.log(`
44272
44730
  Waiting for a change (${graph.waiting.length}):`);
44273
44731
  for (const w of graph.waiting) {
44274
- console.log(` ${one4(w.source)} \u2192 ${one4(w.neighbor)} (round ${w.round}): needs a change: ${one4(w.reason)}`);
44275
- console.log(` waits until ${one4(w.neighbor)} changes`);
44732
+ console.log(` ${one5(w.source)} \u2192 ${one5(w.neighbor)} (round ${w.round}): needs a change: ${one5(w.reason)}`);
44733
+ console.log(` waits until ${one5(w.neighbor)} changes`);
44276
44734
  }
44277
44735
  }
44278
44736
  if (graph.stopped.length) {
44279
44737
  console.log(`
44280
44738
  Stopped chains (${graph.stopped.length}): each took more than ${CASE_REVIEW_ROUNDS_MAX} rounds, so it takes no verdict.`);
44281
44739
  for (const s of graph.stopped) {
44282
- const waiting = s.waiting_sources.length ? `; waiting on it: ${s.waiting_sources.map(one4).join(", ")}` : "";
44283
- console.log(` ${one4(s.key)}, "${one4(s.title)}" (round ${s.round})${s.base_revision_id ? `, since revision ${one4(s.base_revision_id)}` : ""}${waiting}`);
44740
+ const waiting = s.waiting_sources.length ? `; waiting on it: ${s.waiting_sources.map(one5).join(", ")}` : "";
44741
+ console.log(` ${one5(s.key)}, "${one5(s.title)}" (round ${s.round})${s.base_revision_id ? `, since revision ${one5(s.base_revision_id)}` : ""}${waiting}`);
44284
44742
  }
44285
44743
  console.log(` ${WEB_ONLY_NOTICE}`);
44286
44744
  }
@@ -44289,8 +44747,8 @@ Stopped chains (${graph.stopped.length}): each took more than ${CASE_REVIEW_ROUN
44289
44747
  console.log(`
44290
44748
  For a person to look at (${warnings.length}):`);
44291
44749
  for (const w of warnings) {
44292
- const where = [w.path && one4(w.path), w.subject && one4(w.subject)].filter(Boolean).join(": ");
44293
- console.log(` ${WARNINGS[w.code] ?? one4(w.code)}${where ? ` [${where}]` : ""}`);
44750
+ const where = [w.path && one5(w.path), w.subject && one5(w.subject)].filter(Boolean).join(": ");
44751
+ console.log(` ${WARNINGS[w.code] ?? one5(w.code)}${where ? ` [${where}]` : ""}`);
44294
44752
  }
44295
44753
  }
44296
44754
  if (!graph.items.length && !graph.pairs.length && !graph.waiting.length && !graph.stopped.length) console.log("Nothing awaits review.");
@@ -44337,12 +44795,12 @@ async function caseReviewVerdict(session, body, opts) {
44337
44795
  console.log(JSON.stringify(review, null, 2));
44338
44796
  return;
44339
44797
  }
44340
- console.log(`Recorded ${review.verdict === "needs_change" ? "needs change" : review.verdict} on ${one4(review.source)} \u2192 ${one4(review.neighbor)}, round ${review.round} of ${CASE_REVIEW_ROUNDS_MAX}${review.confidential ? ", confidential" : ""}: ${review.review_id}`);
44798
+ console.log(`Recorded ${review.verdict === "needs_change" ? "needs change" : review.verdict} on ${one5(review.source)} \u2192 ${one5(review.neighbor)}, round ${review.round} of ${CASE_REVIEW_ROUNDS_MAX}${review.confidential ? ", confidential" : ""}: ${review.review_id}`);
44341
44799
  if (review.verdict === "needs_change") {
44342
- console.log(`The pair waits until ${one4(review.neighbor)} changes: change it, push, then read the review again.`);
44800
+ console.log(`The pair waits until ${one5(review.neighbor)} changes: change it, push, then read the review again.`);
44343
44801
  }
44344
44802
  }
44345
- var VERDICTS, WEB_ONLY_NOTICE, one4, WARNINGS;
44803
+ var VERDICTS, WEB_ONLY_NOTICE, one5, WARNINGS;
44346
44804
  var init_case_review2 = __esm({
44347
44805
  "src/cases/case-review.ts"() {
44348
44806
  "use strict";
@@ -44355,7 +44813,7 @@ var init_case_review2 = __esm({
44355
44813
  init_case_review();
44356
44814
  VERDICTS = recordCaseItemReviewBody.shape.verdict.options;
44357
44815
  WEB_ONLY_NOTICE = "Keep and accepting a stopped chain are a person's, in the WayAI web app (the phase page's review): this CLI offers neither.";
44358
- one4 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
44816
+ one5 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
44359
44817
  WARNINGS = {
44360
44818
  outside_item: "text outside any item",
44361
44819
  new_document_outside_item: "a new document with text outside any item",
@@ -44535,6 +44993,22 @@ async function casesCommand(args2) {
44535
44993
  confidential: values.confidential === true
44536
44994
  });
44537
44995
  }
44996
+ case "link": {
44997
+ if (operands.length !== 1) throw usageError4("link takes one <input>: its key, as `wayai cases explain --phase <folder>` names it.");
44998
+ if (values.phase === void 0) throw usageError4("link takes --phase <folder>.");
44999
+ linkTarget({ officialVersion: values["official-version"], received: values.received });
45000
+ return caseLink(await openCaseSession(selector), operands[0], {
45001
+ phase: values.phase,
45002
+ officialVersion: values["official-version"],
45003
+ received: values.received
45004
+ });
45005
+ }
45006
+ case "cite": {
45007
+ if (operands.length !== 2) throw usageError4("cite takes <input> and its lines, as <start> or <start>-<end>.");
45008
+ if (values.phase === void 0) throw usageError4("cite takes --phase <folder>.");
45009
+ const lines2 = passageLines(operands[1]);
45010
+ return caseCite(await openCaseSession(selector), operands[0], lines2, { phase: values.phase });
45011
+ }
44538
45012
  default:
44539
45013
  throw usageError4(`Unknown subcommand ${JSON.stringify(sanitizeTerminalText(name))}.`);
44540
45014
  }
@@ -44718,6 +45192,7 @@ var init_cases = __esm({
44718
45192
  init_web_origin();
44719
45193
  init_case_session();
44720
45194
  init_case_work();
45195
+ init_case_inputs();
44721
45196
  init_case_files2();
44722
45197
  init_case_mirror();
44723
45198
  init_case_review2();
@@ -44762,6 +45237,9 @@ Usage:
44762
45237
  wayai cases note done <note_id>
44763
45238
  wayai cases received add <file> --text <markdown file> --phase <folder> --type <type>
44764
45239
  [--title <title>] [--confidential]
45240
+ wayai cases link <input> --phase <folder>
45241
+ --official-version <official_version_id> | --received <received_id>
45242
+ wayai cases cite <input> <start>[-<end>] --phase <folder>
44765
45243
 
44766
45244
  connect Ask to connect this machine to the case, wait while you approve it
44767
45245
  in the WayAI web app, then keep the case's token in this machine's
@@ -44825,9 +45303,11 @@ review verdict Record consistent or needs_change on one pair, with a reason,
44825
45303
  brief The case at a glance: status, phases under way, deadlines, open
44826
45304
  tasks, open pending items and next steps.
44827
45305
  next What to do next on the phases under way, then what waits on
44828
- someone else.
45306
+ someone else: an input to link (with the command that links it),
45307
+ and a linked one whose version a newer one replaced.
44829
45308
  explain Why each phase and task is not done, and who can move it. --phase
44830
- names everything holding one phase.
45309
+ names everything holding one phase, and each of its inputs'
45310
+ links.
44831
45311
  check A delivery's checks over the case's files as WayAI holds them:
44832
45312
  a joint phase's, or one output's (--output). Inside a clone, it
44833
45313
  also compares the case's package in the mirror with the published
@@ -44857,6 +45337,15 @@ note done Mark a pending item or next step done.
44857
45337
  received add Register a document a party sent, in one phase, with its
44858
45338
  Markdown text, read from the file --text names. --confidential registers it as
44859
45339
  confidential, if the case lets you write one.
45340
+ link Link an input of one phase (its key, as explain --phase names it):
45341
+ one of origin previous_output to an earlier phase's current
45342
+ official version (--official-version), one of origin received to
45343
+ a received document of the case (--received; its id is in its
45344
+ files' names under a phase's received/). A collection input is
45345
+ linked in the web app.
45346
+ cite Cite a passage of what an input links now, by its lines (as
45347
+ 12-18, numbered as the mirror's inputs/ texts number them): the
45348
+ case hashes them. Any origin.
44860
45349
 
44861
45350
  The type commands are a space administrator's, with your own sign-in
44862
45351
  (\`wayai login\`), never a case token: they write and read a case type as
@@ -44922,7 +45411,9 @@ need it.
44922
45411
  "source-hash": { type: "string" },
44923
45412
  "neighbor-hash": { type: "string" },
44924
45413
  "mark-confidential": { type: "boolean" },
44925
- "mirror-only": { type: "boolean" }
45414
+ "mirror-only": { type: "boolean" },
45415
+ "official-version": { type: "string" },
45416
+ received: { type: "string" }
44926
45417
  };
44927
45418
  SELECT = ["case", "org", "space"];
44928
45419
  ADMITS = {
@@ -44938,6 +45429,8 @@ need it.
44938
45429
  note: [...SELECT, "kind", "phase", "task", "origin"],
44939
45430
  "note done": SELECT,
44940
45431
  "received add": [...SELECT, "text", "phase", "type", "title", "confidential"],
45432
+ link: [...SELECT, "phase", "official-version", "received"],
45433
+ cite: [...SELECT, "phase"],
44941
45434
  clone: [...SELECT, "dir", "confidential"],
44942
45435
  // A clone names its case: pull and push take the clone (--dir), never a case.
44943
45436
  pull: ["dir", "overwrite", "yes", "confidential", "mirror-only"],
@@ -45162,51 +45655,51 @@ function partyLine(party) {
45162
45655
  }
45163
45656
  function personsLines(data) {
45164
45657
  if (!data.persons) return [];
45165
- const lines = ["", "Persons each call is for (matched on record types with person entries):"];
45658
+ const lines2 = ["", "Persons each call is for (matched on record types with person entries):"];
45166
45659
  for (const persons2 of data.persons) {
45167
45660
  const audience = persons2.audience === REKOR_PERSON_AUDIENCE_STAFF ? "a call for team members" : "customer-facing";
45168
- lines.push(` ${TURN_NAMES[persons2.turn]}: ${audience}${persons2.full_reach ? ", full reach" : ""}`);
45661
+ lines2.push(` ${TURN_NAMES[persons2.turn]}: ${audience}${persons2.full_reach ? ", full reach" : ""}`);
45169
45662
  if (persons2.parties.length === 0) {
45170
- lines.push(persons2.agent_all ? " no person; the agent holds $person: every person's records" : " no person; the agent does not hold $person: no person's records");
45663
+ lines2.push(persons2.agent_all ? " no person; the agent holds $person: every person's records" : " no person; the agent does not hold $person: no person's records");
45171
45664
  }
45172
- for (const party of persons2.parties) lines.push(` ${partyLine(party)}`);
45665
+ for (const party of persons2.parties) lines2.push(` ${partyLine(party)}`);
45173
45666
  }
45174
- lines.push(" Person entries are matched on calls for team members and customer-facing calls alike; a customer-facing call also reaches only record types with person entries in enforce or marked shared.");
45175
- return lines;
45667
+ lines2.push(" Person entries are matched on calls for team members and customer-facing calls alike; a customer-facing call also reaches only record types with person entries in enforce or marked shared.");
45668
+ return lines2;
45176
45669
  }
45177
45670
  function formatExplanation(data) {
45178
- const lines = [];
45671
+ const lines2 = [];
45179
45672
  const who = data.user_id === null ? "no person: the hub's \u2229 the agent's" : `person ${text4(data.user_id)}, ${data.kind ? kindName(data.kind) : "unknown kind"}`;
45180
- lines.push(`Hub ${text4(data.hub_id)}, agent ${text4(data.agent_id)}, ${who}`);
45181
- if (data.values_hub_id === null) lines.push("This preview hub was never published: it has no hub values, so it reaches nothing.");
45182
- else if (data.values_hub_id !== data.hub_id) lines.push(`Hub values are those of its production hub ${text4(data.values_hub_id)}.`);
45673
+ lines2.push(`Hub ${text4(data.hub_id)}, agent ${text4(data.agent_id)}, ${who}`);
45674
+ if (data.values_hub_id === null) lines2.push("This preview hub was never published: it has no hub values, so it reaches nothing.");
45675
+ else if (data.values_hub_id !== data.hub_id) lines2.push(`Hub values are those of its production hub ${text4(data.values_hub_id)}.`);
45183
45676
  if (data.customer_only) {
45184
- lines.push("Customer-only: on an agent's call, held only on record types open to customer-facing calls (person rules or shared access). Every other type that enforces a dimension reaches nothing.");
45677
+ lines2.push("Customer-only: on an agent's call, held only on record types open to customer-facing calls (person rules or shared access). Every other type that enforces a dimension reaches nothing.");
45185
45678
  }
45186
45679
  if (data.conversations_reach_nothing) {
45187
- lines.push("This person's own set reaches nothing, whatever the agent: every turn in their conversations, a team member's send or consult there included, reaches nothing either.");
45680
+ lines2.push("This person's own set reaches nothing, whatever the agent: every turn in their conversations, a team member's send or consult there included, reaches nothing either.");
45188
45681
  }
45189
- lines.push("", "Layers, intersected in order:");
45682
+ lines2.push("", "Layers, intersected in order:");
45190
45683
  const width = Math.max(...data.layers.map((layer) => LAYER_NAMES[layer.layer].length));
45191
45684
  for (const layer of data.layers) {
45192
45685
  const [first, ...rest] = layerLines(layer.values);
45193
- lines.push(` ${LAYER_NAMES[layer.layer].padEnd(width)} ${first}`);
45194
- for (const line of rest) lines.push(` ${"".padEnd(width)} ${line}`);
45686
+ lines2.push(` ${LAYER_NAMES[layer.layer].padEnd(width)} ${first}`);
45687
+ for (const line of rest) lines2.push(` ${"".padEnd(width)} ${line}`);
45195
45688
  }
45196
- lines.push("", "Effective set:");
45197
- if (data.dimensions.length === 0) lines.push(" no dimension: the set reaches nothing on any scoped record type");
45689
+ lines2.push("", "Effective set:");
45690
+ if (data.dimensions.length === 0) lines2.push(" no dimension: the set reaches nothing on any scoped record type");
45198
45691
  for (const dimension of data.dimensions) {
45199
- lines.push(` ${text4(dimension.dimension_id)}: read ${list(dimension.read)}; write ${list(dimension.write)}`);
45692
+ lines2.push(` ${text4(dimension.dimension_id)}: read ${list(dimension.read)}; write ${list(dimension.write)}`);
45200
45693
  for (const removal of dimension.read_removed) {
45201
- lines.push(` ${text4(removal.value_id)} not read: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
45694
+ lines2.push(` ${text4(removal.value_id)} not read: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
45202
45695
  }
45203
45696
  for (const removal of dimension.write_removed) {
45204
- lines.push(` ${text4(removal.value_id)} read, not written: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
45697
+ lines2.push(` ${text4(removal.value_id)} read, not written: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
45205
45698
  }
45206
45699
  }
45207
- lines.push("", "This set filters records only on record types a base enforces (x-access in enforce mode).");
45208
- lines.push(...personsLines(data));
45209
- return lines;
45700
+ lines2.push("", "This set filters records only on record types a base enforces (x-access in enforce mode).");
45701
+ lines2.push(...personsLines(data));
45702
+ return lines2;
45210
45703
  }
45211
45704
  function failure3(err) {
45212
45705
  if (err instanceof ApiError && err.isExpected) return expected(sanitizeTerminalText(extractApiMessage(err)));
@@ -45959,6 +46452,26 @@ async function adminCommand(args2) {
45959
46452
  process.exit(1);
45960
46453
  }
45961
46454
  }
46455
+ if (group === "base-credential-orgs") {
46456
+ if (!sub) {
46457
+ printHelp2();
46458
+ process.exit(1);
46459
+ }
46460
+ switch (sub) {
46461
+ case "status":
46462
+ await runBaseCredentialOrgsStatus(positional, flagArgs);
46463
+ return;
46464
+ case "add":
46465
+ await runBaseCredentialOrgsChange("add", positional, flagArgs);
46466
+ return;
46467
+ case "remove":
46468
+ await runBaseCredentialOrgsChange("remove", positional, flagArgs);
46469
+ return;
46470
+ default:
46471
+ printHelp2();
46472
+ process.exit(1);
46473
+ }
46474
+ }
45962
46475
  if (group === "voice-calls") {
45963
46476
  if (!sub) {
45964
46477
  printHelp2();
@@ -47197,8 +47710,8 @@ function describeVaultGateEntry(connectorId) {
47197
47710
  function describeVaultGateList(ids) {
47198
47711
  return ids.length === 0 ? "(none listed)" : ids.map(describeVaultGateEntry).join(", ");
47199
47712
  }
47200
- function readVaultGateList(data) {
47201
- const raw = data.vault_connector_ids;
47713
+ function readUuidListColumn(data, column, noun) {
47714
+ const raw = data[column];
47202
47715
  if (raw === void 0 || raw === null) return [];
47203
47716
  let parsed;
47204
47717
  try {
@@ -47207,11 +47720,14 @@ function readVaultGateList(data) {
47207
47720
  parsed = void 0;
47208
47721
  }
47209
47722
  if (!Array.isArray(parsed) || !parsed.every((id) => uuidSchema.safeParse(id).success)) {
47210
- console.error(`vault_connector_ids cannot be read as a list of connector ids: ${JSON.stringify(raw)}`);
47723
+ console.error(`${column} cannot be read as a list of ${noun}: ${JSON.stringify(raw)}`);
47211
47724
  process.exit(1);
47212
47725
  }
47213
47726
  return parsed;
47214
47727
  }
47728
+ function readVaultGateList(data) {
47729
+ return readUuidListColumn(data, "vault_connector_ids", "connector ids");
47730
+ }
47215
47731
  function resolveVaultGateConnector(arg, usage4) {
47216
47732
  const wanted = (arg ?? "").trim().toLowerCase();
47217
47733
  const ids = VAULT_GATE_CONNECTORS.get(wanted) ?? (vaultGateConnectorName(wanted) ? [wanted] : null);
@@ -47298,6 +47814,92 @@ async function runVaultGateChange(change, positional, flagArgs) {
47298
47814
  console.log(`After: ${describeVaultGateList(after)}`);
47299
47815
  console.log(PLATFORM_CONFIG_PROPAGATION_NOTE);
47300
47816
  }
47817
+ function readBaseCredentialOrgList(data) {
47818
+ return readUuidListColumn(data, "base_credential_org_ids", "org ids");
47819
+ }
47820
+ function describeBaseCredentialOrgList(ids) {
47821
+ return ids.length === 0 ? "(none listed: no org may store a base credential)" : ids.join(", ");
47822
+ }
47823
+ async function readBaseCredentialOrgConfig(client) {
47824
+ try {
47825
+ return readBaseCredentialOrgList((await client.adminGetConfig()).data);
47826
+ } catch (err) {
47827
+ exitOnApiError(err);
47828
+ throw err;
47829
+ }
47830
+ }
47831
+ async function runBaseCredentialOrgsStatus(positional, flagArgs) {
47832
+ const usage4 = "wayai admin base-credential-orgs status [--json]";
47833
+ if (positional.length > 0) {
47834
+ console.error(usage4);
47835
+ process.exit(1);
47836
+ }
47837
+ const { jsonOutput } = parseBooleanFlags(flagArgs, usage4, ["--json"]);
47838
+ const { config, accessToken } = await requireAuth();
47839
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
47840
+ const ids = await readBaseCredentialOrgConfig(client);
47841
+ if (jsonOutput) {
47842
+ console.log(JSON.stringify({ base_credential_org_ids: ids }, null, 2));
47843
+ return;
47844
+ }
47845
+ console.log(`base_credential_org_ids (platform): ${describeBaseCredentialOrgList(ids)}`);
47846
+ }
47847
+ async function runBaseCredentialOrgsChange(change, positional, flagArgs) {
47848
+ const usage4 = `wayai admin base-credential-orgs ${change} <org_id> [--yes] [--json]`;
47849
+ const { yes, jsonOutput } = parseBooleanFlags(flagArgs, usage4, ["--yes", "--json"]);
47850
+ if (positional.length !== 1) {
47851
+ console.error("Name one org id.");
47852
+ console.error(usage4);
47853
+ process.exit(1);
47854
+ }
47855
+ const orgId = positional[0].trim().toLowerCase();
47856
+ if (!uuidSchema.safeParse(orgId).success) {
47857
+ console.error(`Refused: "${positional[0]}" is not an org id (a UUID).`);
47858
+ console.error(usage4);
47859
+ process.exit(1);
47860
+ }
47861
+ const { config, accessToken } = await requireAuth();
47862
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
47863
+ const before = await readBaseCredentialOrgConfig(client);
47864
+ const listed3 = before.some((id) => id.toLowerCase() === orgId);
47865
+ if (listed3 === (change === "add")) {
47866
+ if (jsonOutput) {
47867
+ console.log(JSON.stringify({ before, after: before, changed: false }, null, 2));
47868
+ return;
47869
+ }
47870
+ console.log(`Before: ${describeBaseCredentialOrgList(before)}`);
47871
+ console.log(`${orgId} is ${change === "add" ? "already" : "not"} listed; nothing was written.`);
47872
+ return;
47873
+ }
47874
+ const next = change === "add" ? [...before, orgId] : before.filter((id) => id.toLowerCase() !== orgId);
47875
+ if (!jsonOutput) console.log(`Before: ${describeBaseCredentialOrgList(before)}`);
47876
+ if (!yes && !jsonOutput) {
47877
+ console.log(change === "add" ? `About to add ${orgId}: its bases may store base credentials in the credentials vault while base credentials' vault gate is open.` : `About to remove ${orgId}: its bases can no longer store or rotate a base credential; the credentials they stored keep working and can be deleted.`);
47878
+ const ok = await confirm("Proceed?");
47879
+ if (!ok) {
47880
+ console.log("Aborted.");
47881
+ return;
47882
+ }
47883
+ }
47884
+ let after;
47885
+ try {
47886
+ after = readBaseCredentialOrgList((await client.adminUpdateConfig({ base_credential_org_ids: next })).data);
47887
+ } catch (err) {
47888
+ exitOnApiError(err);
47889
+ throw err;
47890
+ }
47891
+ const stored = after.some((id) => id.toLowerCase() === orgId) === (change === "add");
47892
+ if (jsonOutput) {
47893
+ console.log(JSON.stringify({ before, after, changed: stored }, null, 2));
47894
+ } else {
47895
+ console.log(`After: ${describeBaseCredentialOrgList(after)}`);
47896
+ }
47897
+ if (!stored) {
47898
+ console.error(`The platform config answered without the change: ${orgId} was not ${change === "add" ? "added" : "removed"}. A deploy may be in progress; run the command again in a few minutes.`);
47899
+ process.exit(1);
47900
+ }
47901
+ if (!jsonOutput) console.log(PLATFORM_CONFIG_PROPAGATION_NOTE);
47902
+ }
47301
47903
  function conflictReasonOf(err) {
47302
47904
  try {
47303
47905
  const reason3 = JSON.parse(err.body).details?.reason;
@@ -47957,6 +48559,12 @@ Usage:
47957
48559
  wayai admin vault-gate remove <connector> [--yes] [--json]
47958
48560
  Stop listing it: its new credentials no longer go to the vault (on production only Instagram's and base credentials' gates read the list)
47959
48561
 
48562
+ wayai admin base-credential-orgs status [--json] Print the orgs that may store a base credential (base_credential_org_ids)
48563
+ wayai admin base-credential-orgs add <org_id> [--yes] [--json]
48564
+ Admit an org: its bases may store base credentials while base credentials' vault gate is open; prints before and after, confirms unless --yes
48565
+ wayai admin base-credential-orgs remove <org_id> [--yes] [--json]
48566
+ Stop admitting it: no new value or rotation; what it stored keeps working and can be deleted
48567
+
47960
48568
  Sources:
47961
48569
  do Live DO SQLite (existing conversation, hub config, etc.).
47962
48570
  analytics ClickHouse projections (conversation, message, schedule_event).
@@ -48082,6 +48690,12 @@ Sources:
48082
48690
  whichever way the gate is set. Only connectors the vault holds anything of are
48083
48691
  taken: ${[...VAULT_GATE_CONNECTORS.keys()].join(", ")}, and GPT-Live (openai) by its
48084
48692
  catalog id only. Changes land within about 60 s.
48693
+ base-credential-orgs
48694
+ The orgs whose bases may store a base credential: the PLATFORM-wide
48695
+ base_credential_org_ids list, read after base credentials' vault gate
48696
+ (vault-gate add base_source) by every create and rotation, on every environment.
48697
+ Empty, the default, admits none. An org removed keeps the credentials it stored:
48698
+ they still send and can be deleted. Changes land within about 60 s.
48085
48699
 
48086
48700
  Types (do): ${VALID_TYPES.join(" | ")}
48087
48701
  Tables (analytics): ${VALID_ANALYTICS_TABLES.join(" | ")}
@@ -48234,17 +48848,17 @@ function formatClientVersion(status) {
48234
48848
  return withSkill.length <= 64 ? withSkill : cli.slice(0, 64);
48235
48849
  }
48236
48850
  function buildStaleToolingWarning(status) {
48237
- const lines = [];
48851
+ const lines2 = [];
48238
48852
  if (status.cli.behind) {
48239
- lines.push(` CLI ${status.cli.current} \u2192 ${status.cli.latest} (run: wayai update)`);
48853
+ lines2.push(` CLI ${status.cli.current} \u2192 ${status.cli.latest} (run: wayai update)`);
48240
48854
  }
48241
48855
  if (status.skill.behind) {
48242
- lines.push(` Skill ${status.skill.current} \u2192 ${status.skill.latest} (run: npx skills add wayai-pro/wayai-skill -y)`);
48856
+ lines2.push(` Skill ${status.skill.current} \u2192 ${status.skill.latest} (run: npx skills add wayai-pro/wayai-skill -y)`);
48243
48857
  }
48244
- if (lines.length === 0) return null;
48858
+ if (lines2.length === 0) return null;
48245
48859
  return [
48246
48860
  "Your WayAI tooling is behind the latest release:",
48247
- ...lines,
48861
+ ...lines2,
48248
48862
  "",
48249
48863
  "A stale CLI or skill is the most common cause of a false bug report \u2014 the issue may",
48250
48864
  "already be fixed upstream. Update, then reproduce before reporting."