@wayai/cli 0.3.351 → 0.3.353

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({
@@ -6536,7 +6780,7 @@ var init_chunk_5FO3GNKP = __esm({
6536
6780
  }
6537
6781
  });
6538
6782
 
6539
- // ../../packages/core/dist/chunk-7LULTR3U.js
6783
+ // ../../packages/core/dist/chunk-AUD5MVHU.js
6540
6784
  function matchPath(pattern, path55) {
6541
6785
  const pathSegments2 = path55.replace(/\/$/, "").split("/");
6542
6786
  const isPrefix = pattern.endsWith("/*");
@@ -6565,8 +6809,8 @@ function getEndpointConfig(path55) {
6565
6809
  return { tier: "STANDARD" };
6566
6810
  }
6567
6811
  var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
6568
- var init_chunk_7LULTR3U = __esm({
6569
- "../../packages/core/dist/chunk-7LULTR3U.js"() {
6812
+ var init_chunk_AUD5MVHU = __esm({
6813
+ "../../packages/core/dist/chunk-AUD5MVHU.js"() {
6570
6814
  "use strict";
6571
6815
  init_chunk_5FO3GNKP();
6572
6816
  ENDPOINT_CONFIGS = {
@@ -7022,7 +7266,7 @@ var init_chunk_7LULTR3U = __esm({
7022
7266
  // it wins over the wildcard above.
7023
7267
  [COMMUNITY_EMAIL_UNSUBSCRIBE_PATH]: { tier: "MODERATE" },
7024
7268
  // Case spaces (wayai#5921, `cases/routes.ts`): every route under the mount (the uploads, the received documents' upload,
7025
- // the compare, the comments and the cited passages below excepted) shares
7269
+ // the compare, the comments, the cited passages and an input's source text below excepted) shares
7026
7270
  // one per-user budget. Each is one person's page or write, at most a few hundred Durable Object reads (the
7027
7271
  // list of their spaces); a space's own limits are counted in its CaseDO. Every caller is a web
7028
7272
  // session, so the per-IP tier is skipped; the key is pinned because the paths carry org, space,
@@ -7108,6 +7352,16 @@ var init_chunk_7LULTR3U = __esm({
7108
7352
  skipAuthenticatedUsers: true,
7109
7353
  userLimitKey: "/api/cases/*/*/cases/*/inputs/*/passages"
7110
7354
  },
7355
+ // The text of the case's own source an input links (`GET …/cases/:code/inputs/:input_id/source-link/content`): reads up
7356
+ // to 4 MiB of an official version's frozen Markdown or a received document's text into the Worker, composes a folder's
7357
+ // parts and hashes the whole, as a cited passage of it does, so it takes that budget's size, keyed once for every case
7358
+ // and input.
7359
+ "/api/cases/*/*/cases/*/inputs/*/source-link/content": {
7360
+ tier: "STANDARD",
7361
+ userLimit: 30,
7362
+ skipAuthenticatedUsers: true,
7363
+ userLimitKey: "/api/cases/*/*/cases/*/inputs/*/source-link/content"
7364
+ },
7111
7365
  // The WayAI Guide's help entry (wayai#4948, `routes/api/guide.ts`): one POST per click by a viewer
7112
7366
  // the snapshot does not show enrolled, which reads the person's row on the Guide hub and writes only
7113
7367
  // what is missing (an enrolled viewer's click opens the hub without a request). Every caller is
@@ -7144,7 +7398,7 @@ var init_chunk_7LULTR3U = __esm({
7144
7398
  }
7145
7399
  });
7146
7400
 
7147
- // ../../packages/core/dist/chunk-TID3PAFF.js
7401
+ // ../../packages/core/dist/chunk-2IPHTFV5.js
7148
7402
  function fileSnapshotChanged(run) {
7149
7403
  return run.written + run.removed > 0;
7150
7404
  }
@@ -7185,10 +7439,10 @@ async function sendWithRetry(opts, cursor) {
7185
7439
  }
7186
7440
  }
7187
7441
  var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
7188
- var init_chunk_TID3PAFF = __esm({
7189
- "../../packages/core/dist/chunk-TID3PAFF.js"() {
7442
+ var init_chunk_2IPHTFV5 = __esm({
7443
+ "../../packages/core/dist/chunk-2IPHTFV5.js"() {
7190
7444
  "use strict";
7191
- init_chunk_7LULTR3U();
7445
+ init_chunk_AUD5MVHU();
7192
7446
  init_chunk_5FO3GNKP();
7193
7447
  init_zod();
7194
7448
  rekorFileSnapshotAnswerSchema = external_exports.object({
@@ -7449,22 +7703,41 @@ var init_chunk_PFGVH2CX = __esm({
7449
7703
  }
7450
7704
  });
7451
7705
 
7452
- // ../../packages/core/dist/chunk-TVUDMGWV.js
7453
- var bootstrapQuery;
7454
- var init_chunk_TVUDMGWV = __esm({
7455
- "../../packages/core/dist/chunk-TVUDMGWV.js"() {
7706
+ // ../../packages/core/dist/chunk-FPSDNS2E.js
7707
+ var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
7708
+ var init_chunk_FPSDNS2E = __esm({
7709
+ "../../packages/core/dist/chunk-FPSDNS2E.js"() {
7456
7710
  "use strict";
7457
7711
  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()
7712
+ noticeSeveritySchema = external_exports.enum(["critical", "warn", "info"]);
7713
+ noticeStatusSchema = external_exports.enum(["active", "resolved"]);
7714
+ NOTICE_SCOPE_REGEX = /^(global|provider:[a-z0-9_-]{1,40}|service:[a-z0-9_-]{1,40})$/;
7715
+ noticeScopeSchema = external_exports.string().regex(NOTICE_SCOPE_REGEX, "scope must be 'global', 'provider:<x>', or 'service:<x>'");
7716
+ noticeLinkSchema = external_exports.string().url().refine((u) => /^https?:\/\//i.test(u), { message: "link must be an http(s) URL" });
7717
+ createNoticeBody = external_exports.object({
7718
+ severity: noticeSeveritySchema.default("info"),
7719
+ scope: noticeScopeSchema.default("global"),
7720
+ title: external_exports.string().trim().min(1).max(200),
7721
+ body: external_exports.string().max(2e3).optional(),
7722
+ link: noticeLinkSchema.optional(),
7723
+ starts_at: external_exports.string().datetime().optional(),
7724
+ ends_at: external_exports.string().datetime().optional()
7725
+ });
7726
+ updateNoticeBody = external_exports.object({
7727
+ severity: noticeSeveritySchema.optional(),
7728
+ scope: noticeScopeSchema.optional(),
7729
+ title: external_exports.string().trim().min(1).max(200).optional(),
7730
+ body: external_exports.string().max(2e3).nullable().optional(),
7731
+ link: noticeLinkSchema.nullable().optional(),
7732
+ starts_at: external_exports.string().datetime().optional(),
7733
+ ends_at: external_exports.string().datetime().nullable().optional()
7734
+ }).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be provided" });
7735
+ listNoticesQuery = external_exports.object({
7736
+ status: noticeStatusSchema.optional(),
7737
+ limit: external_exports.coerce.number().int().min(1).max(200).optional(),
7738
+ offset: external_exports.coerce.number().int().min(0).optional()
7467
7739
  });
7740
+ noticeIdParamSchema = external_exports.object({ id: external_exports.string().min(1) });
7468
7741
  }
7469
7742
  });
7470
7743
 
@@ -7974,231 +8247,6 @@ var init_chunk_Y7CFCYX4 = __esm({
7974
8247
  }
7975
8248
  });
7976
8249
 
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
8250
  // ../../packages/core/dist/chunk-YUZFHVB2.js
8203
8251
  var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
8204
8252
  var init_chunk_YUZFHVB2 = __esm({
@@ -8645,41 +8693,18 @@ var init_chunk_34LE6P7E = __esm({
8645
8693
  }
8646
8694
  });
8647
8695
 
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"() {
8696
+ // ../../packages/core/dist/chunk-IR2NOSI3.js
8697
+ var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
8698
+ var init_chunk_IR2NOSI3 = __esm({
8699
+ "../../packages/core/dist/chunk-IR2NOSI3.js"() {
8652
8700
  "use strict";
8701
+ init_chunk_HZ6CADSY();
8653
8702
  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) });
8703
+ adminSetGuideHubBody = external_exports.object({
8704
+ hub_id: uuidSchema,
8705
+ dry_run: external_exports.boolean().optional()
8706
+ }).strict();
8707
+ GUIDE_HUB_INELIGIBLE_REASON = "guide_hub_ineligible";
8683
8708
  }
8684
8709
  });
8685
8710
 
@@ -9146,6 +9171,29 @@ var init_chunk_2ZZZHXZR = __esm({
9146
9171
  }
9147
9172
  });
9148
9173
 
9174
+ // ../../packages/core/dist/chunk-MH4O3YEX.js
9175
+ var stateOperationBody;
9176
+ var init_chunk_MH4O3YEX = __esm({
9177
+ "../../packages/core/dist/chunk-MH4O3YEX.js"() {
9178
+ "use strict";
9179
+ init_chunk_6TSQ5HXC();
9180
+ init_zod();
9181
+ stateOperationBody = external_exports.object({
9182
+ hub_id: external_exports.string().uuid(),
9183
+ operation: external_exports.enum(["get", "update", "set_path", "reset"]),
9184
+ state_slug: slugSchema,
9185
+ /**
9186
+ * Deprecated and ignored. Scope is derived from the hub's state definition.
9187
+ * Kept on the schema so legacy bodies still validate.
9188
+ */
9189
+ state_scope: external_exports.enum(["conversation", "user"]).optional(),
9190
+ updates: external_exports.record(external_exports.unknown()).optional(),
9191
+ path: external_exports.array(external_exports.string()).optional(),
9192
+ value: external_exports.unknown().optional()
9193
+ });
9194
+ }
9195
+ });
9196
+
9149
9197
  // ../../packages/core/dist/chunk-IBL7FANV.js
9150
9198
  var SUMMARIZATION_THRESHOLD_MIN, SUMMARIZATION_THRESHOLD_MAX;
9151
9199
  var init_chunk_IBL7FANV = __esm({
@@ -12731,21 +12779,6 @@ var init_chunk_C4HEZ7ZI = __esm({
12731
12779
  }
12732
12780
  });
12733
12781
 
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
12782
  // ../../packages/core/dist/chunk-YULHXJ5M.js
12750
12783
  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
12784
  var init_chunk_YULHXJ5M = __esm({
@@ -12849,29 +12882,6 @@ var init_chunk_ACGAI25T = __esm({
12849
12882
  }
12850
12883
  });
12851
12884
 
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
12885
  // ../../packages/core/dist/chunk-5Y2NNQHX.js
12876
12886
  var CASE_SUBMISSION_ISSUED_KINDS, CASE_SUBMISSION_RENDER_STUCK_MS, CASE_SUBMISSION_MARK_ID_PATTERN, CASE_CORRECTION_REASON_MAX_LENGTH, submitCaseBody, correctCaseSubmissionBody, caseDeliveryQuery;
12877
12887
  var init_chunk_5Y2NNQHX = __esm({
@@ -13802,6 +13812,57 @@ var init_chunk_LBDH7LCG = __esm({
13802
13812
  }
13803
13813
  });
13804
13814
 
13815
+ // ../../packages/core/dist/chunk-D3EP4TDU.js
13816
+ var primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody;
13817
+ var init_chunk_D3EP4TDU = __esm({
13818
+ "../../packages/core/dist/chunk-D3EP4TDU.js"() {
13819
+ "use strict";
13820
+ init_chunk_HZ6CADSY();
13821
+ init_zod();
13822
+ primaryRegionSchema = external_exports.enum([
13823
+ "wnam",
13824
+ "enam",
13825
+ "sam",
13826
+ "weur",
13827
+ "eeur",
13828
+ "apac",
13829
+ "oc",
13830
+ "afr",
13831
+ "me"
13832
+ ]);
13833
+ placementSourceSchema = external_exports.enum([
13834
+ "hub_config",
13835
+ "org_config",
13836
+ "parent_cascade",
13837
+ "cf_colo",
13838
+ "country",
13839
+ "fallback",
13840
+ "unpinned"
13841
+ ]);
13842
+ orgIdParam = external_exports.object({
13843
+ id: uuidSchema
13844
+ });
13845
+ orgAdminIdParam = external_exports.object({
13846
+ id: uuidSchema,
13847
+ adminId: external_exports.string().min(1)
13848
+ });
13849
+ createOrganizationBody = external_exports.object({
13850
+ organization_name: external_exports.string().min(1, "organization_name is required"),
13851
+ // Write-once at creation; updateOrganizationBody does not accept this.
13852
+ primary_region: primaryRegionSchema.optional()
13853
+ });
13854
+ updateOrganizationBody = external_exports.object({
13855
+ organization_name: external_exports.string().min(1).optional(),
13856
+ organization_avatar_url: external_exports.string().url().nullable().optional(),
13857
+ timezone: external_exports.string().optional(),
13858
+ business_hours: external_exports.unknown().optional()
13859
+ }).passthrough();
13860
+ addOrgAdminBody = external_exports.object({
13861
+ user_email: external_exports.string().email("valid email is required")
13862
+ });
13863
+ }
13864
+ });
13865
+
13805
13866
  // ../../packages/core/dist/chunk-X5PZZVTS.js
13806
13867
  function isEventRelativeFollowupType(type) {
13807
13868
  return typeof type === "string" && EVENT_RELATIVE_FOLLOWUP_TYPES.includes(type);
@@ -14200,57 +14261,6 @@ var init_chunk_X5PZZVTS = __esm({
14200
14261
  }
14201
14262
  });
14202
14263
 
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
14264
  // ../../packages/core/dist/chunk-PIZTARVG.js
14255
14265
  function byLocale(entry) {
14256
14266
  const shape = Object.fromEntries(SUPPORTED_LOCALES.map((locale) => [locale, entry.optional()]));
@@ -14289,7 +14299,7 @@ var init_chunk_PIZTARVG = __esm({
14289
14299
  }
14290
14300
  });
14291
14301
 
14292
- // ../../packages/core/dist/chunk-7NFNYPTF.js
14302
+ // ../../packages/core/dist/chunk-ARK3766Q.js
14293
14303
  function refineLaneReferences(val, ctx) {
14294
14304
  const lanes = val.lanes;
14295
14305
  const statuses = val.kanban_statuses;
@@ -14313,11 +14323,11 @@ function describeSyncWarning(warning) {
14313
14323
  return `${label3}: ${parts.join("; ")}. Promote the base so production's tools match the preview's.`;
14314
14324
  }
14315
14325
  var hubIdParam, hubAdminIdParam, hubUserIdParam, hubAgentIdParam, hubIdentityIdParam, hubTeamIdParam, hubTeamUserDeleteParam, hubSchemaQuery, HUB_USERS_PAGE_SIZE_MAX, HUB_USERS_SEARCH_MAX, HUB_USERS_CHANNEL_TYPES, getHubUsersQuery, PREVIEW_LABEL_MAX_LENGTH, MAX_ENDED_INDEX_RETENTION_DAYS, MAX_EVAL_RETENTION_DAYS, MAX_END_USER_DAILY_MESSAGE_LIMIT, endUserDailyMessageLimitField, previewLabelField, hubTagsField, createHubBody, updateHubBody, HUB_TAG_CHANGE_REFUSED, hubTagChangeRefusalSchema, addHubAdminBody, addHubIdentityAuthorizationBody, contactDecisionBody, approveContactBody, CONTACT_ACCESS_PAGE_SIZE_MAX, listContactAccessQuery, createHubTeamBody, updateHubTeamBody, addHubTeamUserBody, reassignHubUserBody, replicatePreviewBody, HUB_DIFF_SECTION_SET, HUB_DIFF_SECTIONS, updateChannelTestIdentitiesBody, claimCodeChannelParam, claimCodeDeleteParam;
14316
- var init_chunk_7NFNYPTF = __esm({
14317
- "../../packages/core/dist/chunk-7NFNYPTF.js"() {
14326
+ var init_chunk_ARK3766Q = __esm({
14327
+ "../../packages/core/dist/chunk-ARK3766Q.js"() {
14318
14328
  "use strict";
14319
- init_chunk_X5PZZVTS();
14320
14329
  init_chunk_D3EP4TDU();
14330
+ init_chunk_X5PZZVTS();
14321
14331
  init_chunk_PIZTARVG();
14322
14332
  init_chunk_HZ6CADSY();
14323
14333
  init_zod();
@@ -14513,7 +14523,7 @@ var init_chunk_7NFNYPTF = __esm({
14513
14523
  }
14514
14524
  });
14515
14525
 
14516
- // ../../packages/core/dist/chunk-W3WJCAUF.js
14526
+ // ../../packages/core/dist/chunk-LZHLURLT.js
14517
14527
  function declaresNoConnection(agent) {
14518
14528
  return agent.connection === null && !agent.connection_id;
14519
14529
  }
@@ -15245,8 +15255,8 @@ function skillSectionsAsResources(scope) {
15245
15255
  };
15246
15256
  }
15247
15257
  var MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, MAX_HUB_AS_CODE_PAGE_MANIFEST_CHARS, hubAsCodePagesSchema, MAX_CALL_OPENING_CARRIERS, MAX_CALL_OPENING_AGGREGATE_ENCODED_BYTES, HUB_AS_CODE_AGENT_TOOL_KEYS, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, flagEntriesOf, boundedHubAsCodeResourcesSchema, isPlainObject, MIN_SKILLS_LAYOUT_CLI, MAX_HUB_AS_CODE_DEPTH, NAMED_DEPTH_SEGMENTS, NAMED_DEPTH_KEY_CHARS, fieldName, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, CI_APPLY_ENTITY_KINDS, CI_APPLY_OPERATIONS, ciApplyErrorBaseSchema, ciApplyErrorSchema, ciSyncCountSchema, ciSyncChangesSchema, ciSyncWarningSchema, ciSyncResponseSchema;
15248
- var init_chunk_W3WJCAUF = __esm({
15249
- "../../packages/core/dist/chunk-W3WJCAUF.js"() {
15258
+ var init_chunk_LZHLURLT = __esm({
15259
+ "../../packages/core/dist/chunk-LZHLURLT.js"() {
15250
15260
  "use strict";
15251
15261
  init_chunk_QG3XMUEN();
15252
15262
  init_chunk_EBUWHIFV();
@@ -15254,7 +15264,7 @@ var init_chunk_W3WJCAUF = __esm({
15254
15264
  init_chunk_QMQGGR7Q();
15255
15265
  init_chunk_LBDH7LCG();
15256
15266
  init_chunk_4LXDRTO4();
15257
- init_chunk_7NFNYPTF();
15267
+ init_chunk_ARK3766Q();
15258
15268
  init_chunk_X5PZZVTS();
15259
15269
  init_chunk_PIZTARVG();
15260
15270
  init_chunk_S4VDZ7PZ();
@@ -16014,11 +16024,11 @@ function cycleIn(nodes, edges) {
16014
16024
  function fixedTextProblem(text5) {
16015
16025
  if (text5.includes("<!--")) return "item_fixed_text_comment";
16016
16026
  if (/\{\{\s*fill\s*:/.test(text5)) return "item_fixed_text_fill";
16017
- const lines = text5.replace(/\r\n?/g, "\n").split("\n");
16027
+ const lines2 = text5.replace(/\r\n?/g, "\n").split("\n");
16018
16028
  let fence = null;
16019
16029
  let closedAt = -1;
16020
- for (let i = 0; i < lines.length; i++) {
16021
- const line = lines[i];
16030
+ for (let i = 0; i < lines2.length; i++) {
16031
+ const line = lines2[i];
16022
16032
  const mark = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
16023
16033
  if (fence !== null) {
16024
16034
  if (mark && mark[0] === fence[0] && mark.length >= fence.length && line.trim() === mark) {
@@ -16031,7 +16041,7 @@ function fixedTextProblem(text5) {
16031
16041
  fence = mark;
16032
16042
  continue;
16033
16043
  }
16034
- const setext = i > 0 && /^ {0,3}(=+|-+)[ \t]*$/.test(line) && lines[i - 1].trim() !== "" && closedAt !== i - 1 && (i === 1 || lines[i - 2].trim() === "");
16044
+ const setext = i > 0 && /^ {0,3}(=+|-+)[ \t]*$/.test(line) && lines2[i - 1].trim() !== "" && closedAt !== i - 1 && (i === 1 || lines2[i - 2].trim() === "");
16035
16045
  if (/^ {0,3}#{1,6}([ \t]|$)/.test(line) || setext) return "item_fixed_text_heading";
16036
16046
  }
16037
16047
  return null;
@@ -16475,10 +16485,10 @@ var init_chunk_733K4J4G = __esm({
16475
16485
  }
16476
16486
  });
16477
16487
 
16478
- // ../../packages/core/dist/chunk-2YVCHUBL.js
16488
+ // ../../packages/core/dist/chunk-W7KQS5C6.js
16479
16489
  var CASE_OFFICIAL_FILE_KINDS, CASE_OFFICIAL_FILE_NAME_PATTERN, publishCaseSubmissionBody, caseOfficialVersionParam, caseOfficialFileQuery;
16480
- var init_chunk_2YVCHUBL = __esm({
16481
- "../../packages/core/dist/chunk-2YVCHUBL.js"() {
16490
+ var init_chunk_W7KQS5C6 = __esm({
16491
+ "../../packages/core/dist/chunk-W7KQS5C6.js"() {
16482
16492
  "use strict";
16483
16493
  init_chunk_5Y2NNQHX();
16484
16494
  init_chunk_VROZDNLV();
@@ -16496,10 +16506,10 @@ var init_chunk_2YVCHUBL = __esm({
16496
16506
  }
16497
16507
  });
16498
16508
 
16499
- // ../../packages/core/dist/chunk-RRU36I2I.js
16509
+ // ../../packages/core/dist/chunk-NMGRRGDR.js
16500
16510
  var casePhaseParam;
16501
- var init_chunk_RRU36I2I = __esm({
16502
- "../../packages/core/dist/chunk-RRU36I2I.js"() {
16511
+ var init_chunk_NMGRRGDR = __esm({
16512
+ "../../packages/core/dist/chunk-NMGRRGDR.js"() {
16503
16513
  "use strict";
16504
16514
  init_chunk_733K4J4G();
16505
16515
  init_chunk_HZ6CADSY();
@@ -16507,10 +16517,10 @@ var init_chunk_RRU36I2I = __esm({
16507
16517
  }
16508
16518
  });
16509
16519
 
16510
- // ../../packages/core/dist/chunk-RHXF6X2Y.js
16520
+ // ../../packages/core/dist/chunk-XPOCPOMA.js
16511
16521
  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"() {
16522
+ var init_chunk_XPOCPOMA = __esm({
16523
+ "../../packages/core/dist/chunk-XPOCPOMA.js"() {
16514
16524
  "use strict";
16515
16525
  init_chunk_5Y2NNQHX();
16516
16526
  init_chunk_HZ6CADSY();
@@ -16524,14 +16534,14 @@ var init_chunk_RHXF6X2Y = __esm({
16524
16534
  }
16525
16535
  });
16526
16536
 
16527
- // ../../packages/core/dist/chunk-XUPUXNGM.js
16537
+ // ../../packages/core/dist/chunk-ZBGTU6OM.js
16528
16538
  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"() {
16539
+ var init_chunk_ZBGTU6OM = __esm({
16540
+ "../../packages/core/dist/chunk-ZBGTU6OM.js"() {
16531
16541
  "use strict";
16532
- init_chunk_2YVCHUBL();
16533
- init_chunk_RRU36I2I();
16534
- init_chunk_RHXF6X2Y();
16542
+ init_chunk_W7KQS5C6();
16543
+ init_chunk_NMGRRGDR();
16544
+ init_chunk_XPOCPOMA();
16535
16545
  init_chunk_5Y2NNQHX();
16536
16546
  init_chunk_VROZDNLV();
16537
16547
  init_chunk_733K4J4G();
@@ -16608,6 +16618,25 @@ var init_chunk_M2IF4G6X = __esm({
16608
16618
  }
16609
16619
  });
16610
16620
 
16621
+ // ../../packages/core/dist/chunk-UOPCLXCU.js
16622
+ var CASE_CHANGE_TOPICS, caseChangedFrameSchema;
16623
+ var init_chunk_UOPCLXCU = __esm({
16624
+ "../../packages/core/dist/chunk-UOPCLXCU.js"() {
16625
+ "use strict";
16626
+ init_chunk_733K4J4G();
16627
+ init_chunk_HZ6CADSY();
16628
+ init_zod();
16629
+ CASE_CHANGE_TOPICS = ["submission", "agenda", "access"];
16630
+ caseChangedFrameSchema = external_exports.object({
16631
+ org_id: uuidSchema,
16632
+ space_id: uuidSchema,
16633
+ /** The case, by its code; null for an `access` change, which names none. */
16634
+ code: caseRecordParam.shape.code.nullable(),
16635
+ topic: external_exports.enum(CASE_CHANGE_TOPICS)
16636
+ }).strict();
16637
+ }
16638
+ });
16639
+
16611
16640
  // ../../packages/core/dist/chunk-7CZSLDOE.js
16612
16641
  var CASE_MEMBER_CASES_PAGE_MAX, caseMemberReachQuery;
16613
16642
  var init_chunk_7CZSLDOE = __esm({
@@ -17048,6 +17077,156 @@ var init_chunk_ZVIMTUGZ = __esm({
17048
17077
  }
17049
17078
  });
17050
17079
 
17080
+ // ../../packages/core/dist/chunk-7TQYAKCB.js
17081
+ function addCaseNoteProblem(note) {
17082
+ return note.origin !== null && note.kind !== "contribution" ? { reason: "origin_not_contribution", at: "origin" } : null;
17083
+ }
17084
+ var CASE_NOTE_KINDS, CASE_NOTE_TEXT_MAX_LENGTH, CASE_NOTE_ORIGIN_MAX_LENGTH, CASE_NOTES_PAGE_MAX, addCaseNoteShape, addCaseNoteBody, caseNoteParam, caseTaskParam, caseNotesQuery;
17085
+ var init_chunk_7TQYAKCB = __esm({
17086
+ "../../packages/core/dist/chunk-7TQYAKCB.js"() {
17087
+ "use strict";
17088
+ init_chunk_733K4J4G();
17089
+ init_chunk_3T3D7LTE();
17090
+ init_chunk_HZ6CADSY();
17091
+ init_zod();
17092
+ CASE_NOTE_KINDS = ["observation", "next_step", "pending", "contribution"];
17093
+ CASE_NOTE_TEXT_MAX_LENGTH = 64 * 1024;
17094
+ CASE_NOTE_ORIGIN_MAX_LENGTH = 200;
17095
+ CASE_NOTES_PAGE_MAX = 100;
17096
+ addCaseNoteShape = external_exports.object({
17097
+ kind: external_exports.enum(CASE_NOTE_KINDS),
17098
+ text: external_exports.string().trim().min(1).max(CASE_NOTE_TEXT_MAX_LENGTH),
17099
+ /** A contribution's external author. */
17100
+ origin: external_exports.string().trim().min(1).max(CASE_NOTE_ORIGIN_MAX_LENGTH).nullable().default(null),
17101
+ /** A phase of the case (its version's phase id). */
17102
+ phase_id: uuidSchema.nullable().default(null),
17103
+ /** A task of the case, whose phase the note takes. */
17104
+ case_task_id: uuidSchema.nullable().default(null)
17105
+ }).strict();
17106
+ addCaseNoteBody = addCaseNoteShape.superRefine((note, ctx) => {
17107
+ const found = addCaseNoteProblem(note);
17108
+ if (found) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: [found.at], params: { case_note_reason: found.reason } });
17109
+ });
17110
+ caseNoteParam = caseRecordParam.extend({ note_id: uuidSchema });
17111
+ caseTaskParam = caseRecordParam.extend({ case_task_id: uuidSchema });
17112
+ caseNotesQuery = casePageQuery.extend({
17113
+ limit: external_exports.coerce.number().int().min(1).max(CASE_NOTES_PAGE_MAX).optional()
17114
+ });
17115
+ }
17116
+ });
17117
+
17118
+ // ../../packages/core/dist/chunk-S7UAXLHJ.js
17119
+ function casePassageLines(text5) {
17120
+ const lines2 = text5.replace(/\r\n/g, "\n").split("\n");
17121
+ if (lines2.at(-1) === "") lines2.pop();
17122
+ return lines2;
17123
+ }
17124
+ 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;
17125
+ var init_chunk_S7UAXLHJ = __esm({
17126
+ "../../packages/core/dist/chunk-S7UAXLHJ.js"() {
17127
+ "use strict";
17128
+ init_chunk_7TQYAKCB();
17129
+ init_chunk_VROZDNLV();
17130
+ init_chunk_3T3D7LTE();
17131
+ init_chunk_HZ6CADSY();
17132
+ init_zod();
17133
+ CASE_COMMENT_TEXT_MAX_LENGTH = CASE_NOTE_TEXT_MAX_LENGTH;
17134
+ CASE_COMMENTS_PAGE_MAX = 100;
17135
+ CASE_COMMENT_LINE_MAX = CASE_FILE_COMPARE_MAX_BYTES;
17136
+ casePassageLineSchema = external_exports.number().int().min(1).max(CASE_COMMENT_LINE_MAX);
17137
+ lineNumber = casePassageLineSchema;
17138
+ addCaseCommentShape = external_exports.object({
17139
+ path: caseFileReadPath,
17140
+ /** The version: the revision that wrote it to `path`. */
17141
+ revision_id: uuidSchema,
17142
+ /** The passage's first and last lines, from 1, of the version's text ({@link casePassageLines}). */
17143
+ line_start: lineNumber,
17144
+ line_end: lineNumber,
17145
+ text: external_exports.string().trim().min(1).max(CASE_COMMENT_TEXT_MAX_LENGTH),
17146
+ /** Hidden from every reader without the Confidential right; only a holder of it may set it. */
17147
+ confidential: external_exports.boolean().default(false)
17148
+ }).strict();
17149
+ CASE_COMMENT_REVERSED_REASON = "passage_reversed";
17150
+ addCaseCommentBody = addCaseCommentShape.superRefine((comment2, ctx) => {
17151
+ if (comment2.line_end < comment2.line_start) {
17152
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: CASE_COMMENT_REVERSED_REASON, path: ["line_end"] });
17153
+ }
17154
+ });
17155
+ caseCommentsQuery = casePageQuery.extend({
17156
+ path: caseFileReadPath,
17157
+ /** Absent: every version's comments on the path. */
17158
+ revision_id: uuidSchema.optional(),
17159
+ limit: external_exports.coerce.number().int().min(1).max(CASE_COMMENTS_PAGE_MAX).optional()
17160
+ });
17161
+ CASE_COMMENT_OUT_OF_RANGE_REASON = "passage_out_of_range";
17162
+ }
17163
+ });
17164
+
17165
+ // ../../packages/core/dist/chunk-U3L6QR6F.js
17166
+ 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;
17167
+ var init_chunk_U3L6QR6F = __esm({
17168
+ "../../packages/core/dist/chunk-U3L6QR6F.js"() {
17169
+ "use strict";
17170
+ init_chunk_S7UAXLHJ();
17171
+ init_chunk_HZ6CADSY();
17172
+ init_zod();
17173
+ CASE_VERSION_DECISION_REASON_MAX_LENGTH = 2e3;
17174
+ CASE_VERSION_DECISIONS = ["adopt", "keep"];
17175
+ caseVersionDecisionReason = external_exports.string().trim().min(1).max(CASE_VERSION_DECISION_REASON_MAX_LENGTH);
17176
+ reason = caseVersionDecisionReason;
17177
+ lineNumber2 = casePassageLineSchema;
17178
+ recordCaseReferenceBody = external_exports.object({
17179
+ document_id: uuidSchema,
17180
+ /** The document's version its writer read as current. */
17181
+ version_id: uuidSchema
17182
+ }).strict();
17183
+ CASE_PASSAGE_REVERSED_REASON = CASE_COMMENT_REVERSED_REASON;
17184
+ citeCasePassageBody = external_exports.object({
17185
+ document_id: uuidSchema,
17186
+ version_id: uuidSchema,
17187
+ line_start: lineNumber2,
17188
+ line_end: lineNumber2
17189
+ }).strict().superRefine((body, ctx) => {
17190
+ if (body.line_end < body.line_start) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: CASE_PASSAGE_REVERSED_REASON, path: ["line_end"] });
17191
+ });
17192
+ decideCaseVersionBody = external_exports.object({
17193
+ decision: external_exports.enum(CASE_VERSION_DECISIONS),
17194
+ /** The newer version its decider read as current. */
17195
+ expect_version_id: uuidSchema,
17196
+ reason: reason.nullable().default(null)
17197
+ }).strict().superRefine((body, ctx) => {
17198
+ if (body.decision === "keep" && body.reason === null) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A version kept needs its reason", path: ["reason"] });
17199
+ });
17200
+ CASE_PASSAGE_LINK_CHANGED_REASON = "link_changed";
17201
+ CASE_PASSAGE_NO_TEXT_REASON = "version_no_text";
17202
+ CASE_PASSAGE_OUT_OF_RANGE_REASON = CASE_COMMENT_OUT_OF_RANGE_REASON;
17203
+ }
17204
+ });
17205
+
17206
+ // ../../packages/core/dist/chunk-S5FHM37X.js
17207
+ var lines, ordered, citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody, citeCaseSourcePassageBody, citeCaseInputPassageBody, caseSourceRefSchema;
17208
+ var init_chunk_S5FHM37X = __esm({
17209
+ "../../packages/core/dist/chunk-S5FHM37X.js"() {
17210
+ "use strict";
17211
+ init_chunk_U3L6QR6F();
17212
+ init_chunk_S7UAXLHJ();
17213
+ init_chunk_HZ6CADSY();
17214
+ init_zod();
17215
+ lines = { line_start: casePassageLineSchema, line_end: casePassageLineSchema };
17216
+ ordered = (body, ctx) => {
17217
+ if (body.line_end < body.line_start) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: CASE_PASSAGE_REVERSED_REASON, path: ["line_end"] });
17218
+ };
17219
+ citeCaseOfficialVersionPassageBody = external_exports.object({ official_version_id: uuidSchema, ...lines }).strict().superRefine(ordered);
17220
+ citeCaseReceivedPassageBody = external_exports.object({ received_id: uuidSchema, ...lines }).strict().superRefine(ordered);
17221
+ citeCaseSourcePassageBody = external_exports.union([citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody]);
17222
+ citeCaseInputPassageBody = external_exports.union([citeCasePassageBody, citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody]);
17223
+ caseSourceRefSchema = external_exports.union([
17224
+ external_exports.object({ official_version_id: uuidSchema }).strict(),
17225
+ external_exports.object({ received_id: uuidSchema }).strict()
17226
+ ]);
17227
+ }
17228
+ });
17229
+
17051
17230
  // ../../packages/core/dist/chunk-BVQCYBU6.js
17052
17231
  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
17232
  var init_chunk_BVQCYBU6 = __esm({
@@ -17094,25 +17273,6 @@ var init_chunk_BVQCYBU6 = __esm({
17094
17273
  }
17095
17274
  });
17096
17275
 
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
17276
  // ../../packages/core/dist/chunk-Z3SV3XTC.js
17117
17277
  var caseAccessQuery;
17118
17278
  var init_chunk_Z3SV3XTC = __esm({
@@ -17125,7 +17285,7 @@ var init_chunk_Z3SV3XTC = __esm({
17125
17285
  });
17126
17286
 
17127
17287
  // ../../packages/core/dist/chunk-NHC27NIE.js
17128
- var CASE_ADJUSTMENT_REASON_MAX_LENGTH, CASE_ADJUSTMENT_DISPENSATION_KINDS, reason, activateCasePhaseBody, dispenseCaseBody, addCaseTaskBody, addCaseInputBody, caseOwnItemSchema, addCaseItemBody;
17288
+ var CASE_ADJUSTMENT_REASON_MAX_LENGTH, CASE_ADJUSTMENT_DISPENSATION_KINDS, reason2, activateCasePhaseBody, dispenseCaseBody, addCaseTaskBody, addCaseInputBody, caseOwnItemSchema, addCaseItemBody;
17129
17289
  var init_chunk_NHC27NIE = __esm({
17130
17290
  "../../packages/core/dist/chunk-NHC27NIE.js"() {
17131
17291
  "use strict";
@@ -17134,9 +17294,9 @@ var init_chunk_NHC27NIE = __esm({
17134
17294
  init_zod();
17135
17295
  CASE_ADJUSTMENT_REASON_MAX_LENGTH = 2e3;
17136
17296
  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();
17297
+ reason2 = external_exports.string().trim().min(1).max(CASE_ADJUSTMENT_REASON_MAX_LENGTH);
17298
+ activateCasePhaseBody = external_exports.object({ phase_id: uuidSchema, reason: reason2 }).strict();
17299
+ dispenseCaseBody = external_exports.object({ kind: external_exports.enum(CASE_ADJUSTMENT_DISPENSATION_KINDS), target_id: uuidSchema, reason: reason2 }).strict();
17140
17300
  addCaseTaskBody = external_exports.object({
17141
17301
  phase_id: uuidSchema,
17142
17302
  name: external_exports.string().trim().min(1).max(CASE_TASK_NAME_MAX_LENGTH),
@@ -17147,7 +17307,7 @@ var init_chunk_NHC27NIE = __esm({
17147
17307
  addCaseInputBody = external_exports.object({
17148
17308
  phase_id: uuidSchema,
17149
17309
  input: casePhaseInputSchema.extend({ agenda_group: caseAgendaGroupCodeSchema.nullable().default(null) }),
17150
- reason
17310
+ reason: reason2
17151
17311
  }).strict();
17152
17312
  caseOwnItemSchema = caseOutputItemSchema.omit({ waivable: true, template_mode: true, fixed_text: true }).extend({ agenda_group: caseAgendaGroupCodeSchema.nullable().default(null) });
17153
17313
  addCaseItemBody = external_exports.object({
@@ -17155,7 +17315,7 @@ var init_chunk_NHC27NIE = __esm({
17155
17315
  /** The phase's output it goes in. */
17156
17316
  output_id: uuidSchema,
17157
17317
  item: caseOwnItemSchema,
17158
- reason
17318
+ reason: reason2
17159
17319
  }).strict();
17160
17320
  }
17161
17321
  });
@@ -17207,148 +17367,34 @@ var init_chunk_UMAPAGFH = __esm({
17207
17367
  }
17208
17368
  });
17209
17369
 
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"() {
17370
+ // ../../packages/core/dist/chunk-J7LBOXQK.js
17371
+ 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;
17372
+ var init_chunk_J7LBOXQK = __esm({
17373
+ "../../packages/core/dist/chunk-J7LBOXQK.js"() {
17336
17374
  "use strict";
17337
17375
  init_chunk_6CHDJVQ6();
17338
- init_chunk_S4NDHW3Q();
17376
+ init_chunk_U3L6QR6F();
17339
17377
  init_chunk_733K4J4G();
17340
17378
  init_chunk_3T3D7LTE();
17341
17379
  init_chunk_HZ6CADSY();
17342
17380
  init_zod();
17343
17381
  caseInputLinkParam = caseRecordParam.extend({ input_id: uuidSchema });
17344
17382
  caseCollectionDocumentOfCaseParam = caseRecordParam.extend({ document_id: uuidSchema });
17345
- linkCaseInputBody = external_exports.object({
17383
+ linkCaseCollectionInputBody = external_exports.object({
17346
17384
  document_id: uuidSchema,
17347
17385
  /** The document's version its writer read as current, or an earlier one it keeps, with its `reason`. */
17348
17386
  version_id: uuidSchema,
17349
17387
  /** Why an earlier version is kept: a version decision. Unread when `version_id` is the current one. */
17350
17388
  reason: caseVersionDecisionReason.optional()
17351
17389
  }).strict();
17390
+ linkCasePreviousOutputInputBody = external_exports.object({ official_version_id: uuidSchema }).strict();
17391
+ linkCaseReceivedInputBody = external_exports.object({ received_id: uuidSchema }).strict();
17392
+ linkCaseInputBody = external_exports.union([linkCaseCollectionInputBody, linkCasePreviousOutputInputBody, linkCaseReceivedInputBody]);
17393
+ CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON = "official_version_unknown";
17394
+ CASE_LINK_OUTPUT_NOT_PRIOR_REASON = "output_not_prior";
17395
+ CASE_LINK_RECEIVED_UNKNOWN_REASON = "received_unknown";
17396
+ CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON = "document_type_mismatch";
17397
+ CASE_LINK_VERSION_NOT_CURRENT_REASON = "link_version_not_current";
17352
17398
  CASE_COLLECTION_CASES_PAGE_MAX = 100;
17353
17399
  caseCollectionCasesQuery = casePageQuery.extend({
17354
17400
  limit: external_exports.coerce.number().int().min(1).max(CASE_COLLECTION_CASES_PAGE_MAX).optional()
@@ -17840,7 +17886,7 @@ var init_chunk_OMPT4ZHR = __esm({
17840
17886
  }
17841
17887
  });
17842
17888
 
17843
- // ../../packages/core/dist/chunk-OG7KTWHD.js
17889
+ // ../../packages/core/dist/chunk-5XMPWEVS.js
17844
17890
  function refineScopedTarget(data, ctx) {
17845
17891
  if (data.scope === "org") {
17846
17892
  if (!data.org_id) {
@@ -17866,13 +17912,13 @@ function refineScopedTarget(data, ctx) {
17866
17912
  }
17867
17913
  }
17868
17914
  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_OG7KTWHD = __esm({
17870
- "../../packages/core/dist/chunk-OG7KTWHD.js"() {
17915
+ var init_chunk_5XMPWEVS = __esm({
17916
+ "../../packages/core/dist/chunk-5XMPWEVS.js"() {
17871
17917
  "use strict";
17872
17918
  init_chunk_FECLIZTY();
17873
17919
  init_chunk_BFG4ZWR4();
17874
17920
  init_chunk_UY32MQHG();
17875
- init_chunk_7NFNYPTF();
17921
+ init_chunk_ARK3766Q();
17876
17922
  init_chunk_OMPT4ZHR();
17877
17923
  init_chunk_MIWZOSPI();
17878
17924
  init_chunk_HZ6CADSY();
@@ -18028,9 +18074,10 @@ var init_chunk_OG7KTWHD = __esm({
18028
18074
  cases_collection_bytes_quota: casesLimit(1024 ** 4).optional(),
18029
18075
  /** How many days a case's agent authorization lasts before it must be approved again (`./case-agents.ts`). */
18030
18076
  cases_agent_authorization_max_days: casesLimit(365).optional(),
18031
- /** One graph review read's file versions and bytes (`./case-review.ts`). */
18077
+ /** One graph review read's file versions and bytes, and the pairs its computation finds (`./case-review.ts`). */
18032
18078
  cases_review_files_max: casesLimit(5e4).optional(),
18033
18079
  cases_review_bytes_max: casesLimit(64 * 1024 * 1024).optional(),
18080
+ cases_review_pairs_max: casesLimit(1e5).optional(),
18034
18081
  /** How many automation gate evaluations bill one operation (`automationGateEvaluationsPerOperation`). */
18035
18082
  automation_gate_evaluations_per_operation: automationGateEvaluationsPerOperation.optional(),
18036
18083
  /** How many days a hub keeps an automation's runs (`automationRunRetentionDays`). */
@@ -18435,6 +18482,7 @@ var init_contracts = __esm({
18435
18482
  "use strict";
18436
18483
  init_chunk_RACEDHG6();
18437
18484
  init_chunk_Q7KIQHAZ();
18485
+ init_chunk_63UWXV4T();
18438
18486
  init_chunk_AYLAGFAD();
18439
18487
  init_chunk_OPJ5OACS();
18440
18488
  init_chunk_YVY2TZK2();
@@ -18443,71 +18491,71 @@ var init_contracts = __esm({
18443
18491
  init_chunk_WONSSUXU();
18444
18492
  init_chunk_C7UAGRXF();
18445
18493
  init_chunk_IPXBFWUU();
18446
- init_chunk_63UWXV4T();
18494
+ init_chunk_TVUDMGWV();
18447
18495
  init_chunk_WTIGECE5();
18448
18496
  init_chunk_WDAXZDJO();
18449
18497
  init_chunk_ZC6YGHNX();
18498
+ init_chunk_MGBAXT5Y();
18450
18499
  init_chunk_5DGHIY7L();
18451
- init_chunk_TID3PAFF();
18500
+ init_chunk_2IPHTFV5();
18452
18501
  init_chunk_IPDOHAZ5();
18453
18502
  init_chunk_PFGVH2CX();
18454
- init_chunk_TVUDMGWV();
18503
+ init_chunk_FPSDNS2E();
18455
18504
  init_chunk_TZH6DKKJ();
18456
18505
  init_chunk_SSPK6ISL();
18457
18506
  init_chunk_ZXK6N2HN();
18458
18507
  init_chunk_Y7CFCYX4();
18459
- init_chunk_MGBAXT5Y();
18460
18508
  init_chunk_YUZFHVB2();
18461
18509
  init_chunk_I3O2RACG();
18462
18510
  init_chunk_CMRECH67();
18463
18511
  init_chunk_34LE6P7E();
18464
- init_chunk_FPSDNS2E();
18512
+ init_chunk_IR2NOSI3();
18465
18513
  init_chunk_OPETF4GS();
18466
18514
  init_chunk_SY6PLCPK();
18467
18515
  init_chunk_2ZZZHXZR();
18516
+ init_chunk_MH4O3YEX();
18468
18517
  init_chunk_QEEQN2NE();
18469
18518
  init_chunk_KSTYTQ7I();
18470
18519
  init_chunk_LKBSHANA();
18471
18520
  init_chunk_LX3D5LCB();
18472
18521
  init_chunk_C4HEZ7ZI();
18473
- init_chunk_IR2NOSI3();
18474
18522
  init_chunk_UCYWGWQT();
18475
18523
  init_chunk_6AYIXGDT();
18476
18524
  init_chunk_YULHXJ5M();
18477
18525
  init_chunk_V4FRPRH5();
18478
18526
  init_chunk_LWMLR2WI();
18479
18527
  init_chunk_ACGAI25T();
18480
- init_chunk_MH4O3YEX();
18481
18528
  init_chunk_NNC2ZECG();
18482
18529
  init_chunk_7CYHPF35();
18483
18530
  init_chunk_NETRUHZF();
18484
- init_chunk_W3WJCAUF();
18531
+ init_chunk_LZHLURLT();
18485
18532
  init_chunk_QG3XMUEN();
18486
18533
  init_chunk_EBUWHIFV();
18487
18534
  init_chunk_PCQIFFYO();
18488
18535
  init_chunk_AHISKXHA();
18489
18536
  init_chunk_2YEGUQR7();
18490
18537
  init_chunk_JDJ4EUOL();
18491
- init_chunk_XUPUXNGM();
18538
+ init_chunk_ZBGTU6OM();
18492
18539
  init_chunk_K3PD6AOF();
18493
18540
  init_chunk_KVMROYDC();
18494
18541
  init_chunk_M2IF4G6X();
18542
+ init_chunk_UOPCLXCU();
18495
18543
  init_chunk_7CZSLDOE();
18496
- init_chunk_2YVCHUBL();
18497
- init_chunk_RRU36I2I();
18544
+ init_chunk_W7KQS5C6();
18545
+ init_chunk_NMGRRGDR();
18498
18546
  init_chunk_WYCUCSD5();
18499
18547
  init_chunk_H6V7NEWR();
18500
18548
  init_chunk_ZVIMTUGZ();
18549
+ init_chunk_S5FHM37X();
18501
18550
  init_chunk_BVQCYBU6();
18502
- init_chunk_UOPCLXCU();
18503
18551
  init_chunk_Z3SV3XTC();
18504
18552
  init_chunk_NHC27NIE();
18505
18553
  init_chunk_UMAPAGFH();
18506
- init_chunk_UZ72OHQN();
18554
+ init_chunk_J7LBOXQK();
18507
18555
  init_chunk_6CHDJVQ6();
18508
18556
  init_chunk_U3X3BIQH();
18509
18557
  init_chunk_EYOBPUDN();
18510
- init_chunk_S4NDHW3Q();
18558
+ init_chunk_U3L6QR6F();
18511
18559
  init_chunk_UEJOG2Q7();
18512
18560
  init_chunk_KEN2DASI();
18513
18561
  init_chunk_L5GC53VI();
@@ -18521,13 +18569,13 @@ var init_contracts = __esm({
18521
18569
  init_chunk_4LXDRTO4();
18522
18570
  init_chunk_5PKKFSSF();
18523
18571
  init_chunk_NVKU5PPQ();
18524
- init_chunk_OG7KTWHD();
18572
+ init_chunk_5XMPWEVS();
18525
18573
  init_chunk_FECLIZTY();
18526
18574
  init_chunk_BFG4ZWR4();
18527
18575
  init_chunk_UY32MQHG();
18528
- init_chunk_7NFNYPTF();
18529
- init_chunk_X5PZZVTS();
18576
+ init_chunk_ARK3766Q();
18530
18577
  init_chunk_D3EP4TDU();
18578
+ init_chunk_X5PZZVTS();
18531
18579
  init_chunk_PIZTARVG();
18532
18580
  init_chunk_OMPT4ZHR();
18533
18581
  init_chunk_2PZIF56U();
@@ -18535,7 +18583,7 @@ var init_contracts = __esm({
18535
18583
  init_chunk_ZRXP6OOJ();
18536
18584
  init_chunk_BGNWWR6B();
18537
18585
  init_chunk_ZIGA5RCU();
18538
- init_chunk_7LULTR3U();
18586
+ init_chunk_AUD5MVHU();
18539
18587
  init_chunk_SOJMWM63();
18540
18588
  init_chunk_AMMLEB4T();
18541
18589
  init_chunk_5FO3GNKP();
@@ -18552,7 +18600,7 @@ var init_contracts = __esm({
18552
18600
  init_chunk_MIWZOSPI();
18553
18601
  init_chunk_2ISUBJG7();
18554
18602
  init_chunk_C2UEA2KW();
18555
- init_chunk_RHXF6X2Y();
18603
+ init_chunk_XPOCPOMA();
18556
18604
  init_chunk_5Y2NNQHX();
18557
18605
  init_chunk_S7UAXLHJ();
18558
18606
  init_chunk_7TQYAKCB();
@@ -18706,7 +18754,7 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
18706
18754
  var init_dist = __esm({
18707
18755
  "../../packages/core/dist/index.js"() {
18708
18756
  "use strict";
18709
- init_chunk_7LULTR3U();
18757
+ init_chunk_AUD5MVHU();
18710
18758
  init_chunk_SOJMWM63();
18711
18759
  init_chunk_AMMLEB4T();
18712
18760
  init_chunk_5FO3GNKP();
@@ -20104,9 +20152,9 @@ function oldLayoutEntries(root, skills, oldLayout) {
20104
20152
  function assertOldLayoutConvertible(root, skills, oldLayout, pullCommand3) {
20105
20153
  const { leftover } = oldLayoutEntries(root, skills, oldLayout);
20106
20154
  if (leftover.length === 0) return;
20107
- const one5 = leftover.length === 1;
20155
+ const one6 = leftover.length === 1;
20108
20156
  throw expected(
20109
- `${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.`
20157
+ `${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.`
20110
20158
  );
20111
20159
  }
20112
20160
  function removeConvertedOldResources(root, skills, log, opts = {}) {
@@ -20750,6 +20798,18 @@ var init_api_client = __esm({
20750
20798
  async getCaseInputLink(ref, inputId) {
20751
20799
  return this.request("GET", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/link`);
20752
20800
  }
20801
+ /** An input's link to the case's own source (an earlier phase's official version, or a received document), with its cited passages. */
20802
+ async getCaseInputSourceLink(ref, inputId) {
20803
+ return this.request("GET", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/source-link`);
20804
+ }
20805
+ /** Link an input: to a collection document's version, an earlier phase's official version, or a received document, by the body's fields. */
20806
+ async linkCaseInput(ref, inputId, body) {
20807
+ return this.request("PUT", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/link`, body);
20808
+ }
20809
+ /** Cite a passage of what an input links, by its lines: the server hashes them and answers the passage it holds. */
20810
+ async citeCaseInputPassage(ref, inputId, body) {
20811
+ return this.request("POST", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/passages`, body);
20812
+ }
20753
20813
  /**
20754
20814
  * One part of a collection document's version, through the case's own path, with the SHA-256 the space registered for
20755
20815
  * it when the part was stored (the answer's `ETag`, `"<sha>"`); `sha` is null when no such tag is answered.
@@ -24782,8 +24842,8 @@ var init_parser = __esm({
24782
24842
 
24783
24843
  // src/lib/diff-display.ts
24784
24844
  function printDiff(summary) {
24785
- const lines = summary.split("\n");
24786
- for (const line of lines) {
24845
+ const lines2 = summary.split("\n");
24846
+ for (const line of lines2) {
24787
24847
  if (line.startsWith("**") && line.endsWith("**")) {
24788
24848
  console.log(`
24789
24849
  \x1B[1m${line.replace(/\*\*/g, "")}\x1B[0m`);
@@ -25310,7 +25370,7 @@ var init_hub_materializer = __esm({
25310
25370
  var init_ci = __esm({
25311
25371
  "../../packages/core/dist/contracts/ci.js"() {
25312
25372
  "use strict";
25313
- init_chunk_W3WJCAUF();
25373
+ init_chunk_LZHLURLT();
25314
25374
  init_chunk_QG3XMUEN();
25315
25375
  init_chunk_EBUWHIFV();
25316
25376
  init_chunk_PCQIFFYO();
@@ -25319,9 +25379,9 @@ var init_ci = __esm({
25319
25379
  init_chunk_QMQGGR7Q();
25320
25380
  init_chunk_LBDH7LCG();
25321
25381
  init_chunk_4LXDRTO4();
25322
- init_chunk_7NFNYPTF();
25323
- init_chunk_X5PZZVTS();
25382
+ init_chunk_ARK3766Q();
25324
25383
  init_chunk_D3EP4TDU();
25384
+ init_chunk_X5PZZVTS();
25325
25385
  init_chunk_PIZTARVG();
25326
25386
  init_chunk_AMMLEB4T();
25327
25387
  init_chunk_IBL7FANV();
@@ -26740,30 +26800,30 @@ function countChanges(diff) {
26740
26800
  return { added, modified, removed };
26741
26801
  }
26742
26802
  function renderDiff(diff) {
26743
- const lines = [];
26803
+ const lines2 = [];
26744
26804
  for (const kind of ENTITY_KINDS) {
26745
26805
  const b = bucket(diff, kind);
26746
26806
  if (!b || isEmptyBucket(b)) continue;
26747
- lines.push(`${BOLD}${ENTITY_LABELS[kind]}s${RESET}`);
26748
- for (const e of b.added) lines.push(`${GREEN} + ${sanitizeTerminalText(e.id)}${RESET}`);
26749
- for (const m of b.modified) lines.push(`${YELLOW} ~ ${sanitizeTerminalText(m.after.id)}${RESET}`);
26807
+ lines2.push(`${BOLD}${ENTITY_LABELS[kind]}s${RESET}`);
26808
+ for (const e of b.added) lines2.push(`${GREEN} + ${sanitizeTerminalText(e.id)}${RESET}`);
26809
+ for (const m of b.modified) lines2.push(`${YELLOW} ~ ${sanitizeTerminalText(m.after.id)}${RESET}`);
26750
26810
  for (const e of b.removed) {
26751
- lines.push(
26811
+ lines2.push(
26752
26812
  isPrunable(e.id) ? `${RED} - ${sanitizeTerminalText(e.id)}${RESET}` : `${YELLOW} = ${sanitizeTerminalText(e.id)} (kept: pull cannot write its id to a file)${RESET}`
26753
26813
  );
26754
26814
  }
26755
26815
  }
26756
26816
  const { added, modified, removed } = countChanges(diff);
26757
- lines.push("");
26758
- lines.push(
26817
+ lines2.push("");
26818
+ lines2.push(
26759
26819
  `${GREEN}${added} added${RESET}, ${YELLOW}${modified} modified${RESET}, ${RED}${removed} removed${RESET}`
26760
26820
  );
26761
26821
  if (removed > 0) {
26762
- lines.push(
26822
+ lines2.push(
26763
26823
  `${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}`
26764
26824
  );
26765
26825
  }
26766
- return lines.join("\n");
26826
+ return lines2.join("\n");
26767
26827
  }
26768
26828
  var ENTITY_LABELS, GREEN, YELLOW, RED, BOLD, RESET;
26769
26829
  var init_diff_format = __esm({
@@ -28450,11 +28510,11 @@ function lineDiffOf(a, b) {
28450
28510
  }
28451
28511
  return out;
28452
28512
  }
28453
- function printSection(title2, lines) {
28454
- if (lines.length === 0) return;
28513
+ function printSection(title2, lines2) {
28514
+ if (lines2.length === 0) return;
28455
28515
  console.log(`
28456
28516
  ${title2}`);
28457
- for (const line of lines) console.log(` ${line}`);
28517
+ for (const line of lines2) console.log(` ${line}`);
28458
28518
  }
28459
28519
  function printListing(listing) {
28460
28520
  printSection("Changes:", listing.changes);
@@ -30615,10 +30675,10 @@ function headingsOf(text5) {
30615
30675
  return found;
30616
30676
  }
30617
30677
  function frontMatterOf(text5) {
30618
- const lines = text5.split(/\r?\n/);
30619
- if (lines[0] !== "---") return {};
30678
+ const lines2 = text5.split(/\r?\n/);
30679
+ if (lines2[0] !== "---") return {};
30620
30680
  const fields = {};
30621
- for (const line of lines.slice(1)) {
30681
+ for (const line of lines2.slice(1)) {
30622
30682
  if (line === "---") return fields;
30623
30683
  const colon = line.indexOf(":");
30624
30684
  if (colon > 0) fields[line.slice(0, colon).trim()] = line.slice(colon + 1).trim();
@@ -31808,17 +31868,17 @@ function changedLines(before, after) {
31808
31868
  return lineDiffOf(a.slice(start, a.length - end), b.slice(start, b.length - end));
31809
31869
  }
31810
31870
  async function describeSteps(client, t, dir, steps) {
31811
- const lines = [];
31871
+ const lines2 = [];
31812
31872
  for (const step of steps) {
31813
31873
  const rel = safe2(step.rel);
31814
31874
  if (step.op === "create") {
31815
- lines.push(`${MARK.create} ${rel} (new, ${step.local.size} bytes)`);
31875
+ lines2.push(`${MARK.create} ${rel} (new, ${step.local.size} bytes)`);
31816
31876
  } else if (step.op === "delete") {
31817
- lines.push(`${MARK.delete} ${rel} (delete)`);
31877
+ lines2.push(`${MARK.delete} ${rel} (delete)`);
31818
31878
  } else {
31819
- lines.push(`${MARK.update} ${rel}`);
31879
+ lines2.push(`${MARK.update} ${rel}`);
31820
31880
  if (!isTextType(step.remote.content_type) || step.remote.size > MAX_DIFF_BYTES || step.local.size > MAX_DIFF_BYTES) {
31821
- lines.push(` (content changed: ${step.remote.size} \u2192 ${step.local.size} bytes)`);
31881
+ lines2.push(` (content changed: ${step.remote.size} \u2192 ${step.local.size} bytes)`);
31822
31882
  continue;
31823
31883
  }
31824
31884
  let bytes;
@@ -31826,15 +31886,15 @@ async function describeSteps(client, t, dir, steps) {
31826
31886
  bytes = (await client.download(filePath2(t, step.rel))).bytes;
31827
31887
  } catch (err) {
31828
31888
  if (!isNotFound(err)) throw err;
31829
- lines.push(" (deleted on the base since it was listed)");
31889
+ lines2.push(" (deleted on the base since it was listed)");
31830
31890
  continue;
31831
31891
  }
31832
31892
  const before = Buffer.from(bytes).toString("utf-8");
31833
31893
  const after = readLocal(dir, step.rel).toString("utf-8");
31834
- for (const line of changedLines(before, after)) lines.push(` ${line}`);
31894
+ for (const line of changedLines(before, after)) lines2.push(` ${line}`);
31835
31895
  }
31836
31896
  }
31837
- return lines;
31897
+ return lines2;
31838
31898
  }
31839
31899
  function printPushNotes(plan) {
31840
31900
  printSection("Changed on the base since your last pull \u2014 left as is; pull to take it:", plan.changedOnBase.map(safe2));
@@ -36047,7 +36107,7 @@ function activeAlerts(alerts) {
36047
36107
  function summarizeActiveAlertsForReport(alerts) {
36048
36108
  const active = activeAlerts(alerts);
36049
36109
  if (active.length === 0) return null;
36050
- const lines = active.map((a) => {
36110
+ const lines2 = active.map((a) => {
36051
36111
  const { label: label3 } = describeCategory(a.category);
36052
36112
  const target = formatAlertTarget(a);
36053
36113
  const providerBits = formatProviderBits(a);
@@ -36055,7 +36115,7 @@ function summarizeActiveAlertsForReport(alerts) {
36055
36115
  return `- [${a.severity}] ${a.category} (${label3}) \xB7 ${target}${providerBits ? ` \xB7 ${providerBits}` : ""}${detailBit} \xB7 seen ${a.count}\xD7`;
36056
36116
  });
36057
36117
  return `Active hub alerts at report time (${active.length}):
36058
- ${lines.join("\n")}`;
36118
+ ${lines2.join("\n")}`;
36059
36119
  }
36060
36120
  var init_hub_alerts = __esm({
36061
36121
  "src/lib/hub-alerts.ts"() {
@@ -38007,10 +38067,10 @@ var init_facts = __esm({
38007
38067
  // src/lib/call-eval/script.ts
38008
38068
  function parseCallPlan(raw) {
38009
38069
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Error('A call plan is a JSON object with a "lines" object.');
38010
- const lines = raw.lines ?? {};
38011
- if (!lines || typeof lines !== "object" || Array.isArray(lines)) throw new Error(`The call plan's "lines" must be an object keyed by line number.`);
38070
+ const lines2 = raw.lines ?? {};
38071
+ if (!lines2 || typeof lines2 !== "object" || Array.isArray(lines2)) throw new Error(`The call plan's "lines" must be an object keyed by line number.`);
38012
38072
  const out = {};
38013
- for (const [key, value] of Object.entries(lines)) {
38073
+ for (const [key, value] of Object.entries(lines2)) {
38014
38074
  if (!/^[1-9]\d*$/.test(key)) throw new Error(`Call plan line "${key}" is not a line number (1, 2, \u2026).`);
38015
38075
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Call plan line ${key} must be an object.`);
38016
38076
  const entry = value;
@@ -38044,16 +38104,16 @@ function readbackOf(value) {
38044
38104
  return read;
38045
38105
  }
38046
38106
  function buildCallScript(journey, plan = { lines: {} }) {
38047
- const lines = [];
38107
+ const lines2 = [];
38048
38108
  let current = null;
38049
38109
  const flush = () => {
38050
38110
  if (!current) return;
38051
- const n = lines.length + 1;
38111
+ const n = lines2.length + 1;
38052
38112
  const expectedReply = current.replies.join("\n").trim();
38053
38113
  const expectedFacts = extractFacts(expectedReply);
38054
38114
  const override2 = plan.lines[String(n)] ?? {};
38055
38115
  const readback = override2.readback === void 0 ? dictatedIdentifier(current.say) : override2.readback === null ? null : readbackOf(override2.readback);
38056
- lines.push({
38116
+ lines2.push({
38057
38117
  n,
38058
38118
  say: current.say,
38059
38119
  expected_reply: expectedReply,
@@ -38075,15 +38135,15 @@ function buildCallScript(journey, plan = { lines: {} }) {
38075
38135
  }
38076
38136
  }
38077
38137
  flush();
38078
- if (lines.length === 0) throw new Error(`Journey "${journey.journey_name}" has no caller line to say.`);
38079
- if (lines[0].interrupt) throw new Error("Line 1 cannot interrupt: the voice has said nothing to interrupt yet.");
38138
+ if (lines2.length === 0) throw new Error(`Journey "${journey.journey_name}" has no caller line to say.`);
38139
+ if (lines2[0].interrupt) throw new Error("Line 1 cannot interrupt: the voice has said nothing to interrupt yet.");
38080
38140
  for (const key of Object.keys(plan.lines)) {
38081
- 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"}.`);
38141
+ 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"}.`);
38082
38142
  }
38083
38143
  return {
38084
38144
  journey_id: journey.journey_id,
38085
38145
  journey_name: journey.journey_name,
38086
- lines
38146
+ lines: lines2
38087
38147
  };
38088
38148
  }
38089
38149
  var PLAN_LINE_KEYS;
@@ -38168,11 +38228,11 @@ function similarity(a, b) {
38168
38228
  for (const t of ta) if (tb.has(t)) shared += 1;
38169
38229
  return shared / (ta.size + tb.size - shared);
38170
38230
  }
38171
- function alignLines(lines, utterances) {
38231
+ function alignLines(lines2, utterances) {
38172
38232
  const caller = utterances.filter((u) => u.speaker === "user");
38173
38233
  const out = /* @__PURE__ */ new Map();
38174
38234
  let next = 0;
38175
- for (const line of lines) {
38235
+ for (const line of lines2) {
38176
38236
  let best = null;
38177
38237
  for (let start = next; start <= Math.min(caller.length - 1, next + MAX_SKIP); start++) {
38178
38238
  for (let end = start; end < Math.min(caller.length, start + MAX_GROUP); end++) {
@@ -38206,17 +38266,17 @@ function timelineMs(record, iso) {
38206
38266
  return fromIso(iso) - fromIso(record.call.started_at);
38207
38267
  }
38208
38268
  function scoreRun(script, record, timings, thresholds = DEFAULT_THRESHOLDS) {
38209
- const lines = alignLines(script.lines, record.utterances);
38269
+ const lines2 = alignLines(script.lines, record.utterances);
38210
38270
  const turnsByAnchor = /* @__PURE__ */ new Map();
38211
38271
  for (const turn of record.turns) {
38212
38272
  if (!turn.anchor_message_id) continue;
38213
38273
  turnsByAnchor.set(turn.anchor_message_id, [...turnsByAnchor.get(turn.anchor_message_id) ?? [], turn]);
38214
38274
  }
38215
- const turnsOf = (n) => (lines.get(n) ?? []).flatMap((u) => turnsByAnchor.get(u.message_id) ?? []);
38275
+ const turnsOf = (n) => (lines2.get(n) ?? []).flatMap((u) => turnsByAnchor.get(u.message_id) ?? []);
38216
38276
  const voice = record.utterances.filter((u) => u.speaker === "voice_agent");
38217
38277
  const recognition = { expected: 0, recognized: 0, misses: [] };
38218
38278
  for (const line of script.lines) {
38219
- const heard = (lines.get(line.n) ?? []).map((u) => u.text).join(" ");
38279
+ const heard = (lines2.get(line.n) ?? []).map((u) => u.text).join(" ");
38220
38280
  const vetted = buildVettedSet(heard ? [heard] : []);
38221
38281
  for (const fact of extractFacts(line.say)) {
38222
38282
  recognition.expected += 1;
@@ -38269,8 +38329,8 @@ function scoreRun(script, record, timings, thresholds = DEFAULT_THRESHOLDS) {
38269
38329
  script.lines.forEach((line, i) => {
38270
38330
  if (!line.readback) return;
38271
38331
  readback.expected += 1;
38272
- const own = lines.get(line.n) ?? [];
38273
- const nextOwn = script.lines.slice(i + 1).map((l) => lines.get(l.n) ?? []).find((u) => u.length > 0);
38332
+ const own = lines2.get(line.n) ?? [];
38333
+ const nextOwn = script.lines.slice(i + 1).map((l) => lines2.get(l.n) ?? []).find((u) => u.length > 0);
38274
38334
  const from = own.length > 0 ? own[own.length - 1].end_ms : Number.POSITIVE_INFINITY;
38275
38335
  const until = nextOwn ? nextOwn[0].start_ms : Number.POSITIVE_INFINITY;
38276
38336
  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;
@@ -38641,40 +38701,40 @@ function problems(run) {
38641
38701
  return out;
38642
38702
  }
38643
38703
  function formatSuiteReport(report2) {
38644
- const lines = [];
38645
- lines.push(`Call eval \u2014 journey "${shown3(report2.journey.name)}" (${report2.journey.id})`);
38646
- lines.push(`Caller audio: ${report2.audio}`);
38647
- 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`);
38648
- lines.push("");
38649
- for (const run of report2.runs) lines.push(runLine(run));
38650
- if (report2.skipped_runs > 0) lines.push(` ${report2.skipped_runs} run(s) not started: the suite's budget would not hold another`);
38651
- if (report2.interrupted) lines.push(" Interrupted: the call in progress was hung up and closed, and no further run was started");
38652
- lines.push("");
38653
- lines.push(`Pass rate: ${report2.pass_rate.passed}/${report2.pass_rate.scored}`);
38704
+ const lines2 = [];
38705
+ lines2.push(`Call eval \u2014 journey "${shown3(report2.journey.name)}" (${report2.journey.id})`);
38706
+ lines2.push(`Caller audio: ${report2.audio}`);
38707
+ 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`);
38708
+ lines2.push("");
38709
+ for (const run of report2.runs) lines2.push(runLine(run));
38710
+ if (report2.skipped_runs > 0) lines2.push(` ${report2.skipped_runs} run(s) not started: the suite's budget would not hold another`);
38711
+ if (report2.interrupted) lines2.push(" Interrupted: the call in progress was hung up and closed, and no further run was started");
38712
+ lines2.push("");
38713
+ lines2.push(`Pass rate: ${report2.pass_rate.passed}/${report2.pass_rate.scored}`);
38654
38714
  for (const name of SCORE_DIMENSIONS) {
38655
- lines.push(` ${DIMENSION_LABELS[name].padEnd(28)} ${report2.dimensions[name].passed}/${report2.dimensions[name].scored}`);
38715
+ lines2.push(` ${DIMENSION_LABELS[name].padEnd(28)} ${report2.dimensions[name].passed}/${report2.dimensions[name].scored}`);
38656
38716
  }
38657
- 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)`);
38658
- lines.push(`Cost: provider ${usd(report2.cost.provider_usd)}, WayAI operations ${report2.cost.operations}`);
38717
+ 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)`);
38718
+ lines2.push(`Cost: provider ${usd(report2.cost.provider_usd)}, WayAI operations ${report2.cost.operations}`);
38659
38719
  const failing = report2.runs.filter((r) => !runPassed(r));
38660
38720
  if (failing.length > 0) {
38661
- lines.push("");
38662
- lines.push("Failures:");
38721
+ lines2.push("");
38722
+ lines2.push("Failures:");
38663
38723
  for (const run of failing) {
38664
38724
  const found = problems(run);
38665
- lines.push(` run ${run.run}: ${found.length === 0 ? `ended ${run.status}${run.stopped_by ? ` (${run.stopped_by})` : ""}` : found[0]}`);
38666
- for (const more of found.slice(1)) lines.push(` ${more}`);
38725
+ lines2.push(` run ${run.run}: ${found.length === 0 ? `ended ${run.status}${run.stopped_by ? ` (${run.stopped_by})` : ""}` : found[0]}`);
38726
+ for (const more of found.slice(1)) lines2.push(` ${more}`);
38667
38727
  }
38668
38728
  }
38669
38729
  const review = report2.runs.flatMap((r) => (r.score?.unvetted.review ?? []).map((item) => ({ run: r.run, ...item })));
38670
38730
  if (review.length > 0) {
38671
- lines.push("");
38672
- lines.push("For review (policy or action wording no delegation result carried; not counted):");
38673
- for (const item of review) lines.push(` run ${item.run}: "${shown3(item.utterance)}" [${item.markers.join(", ")}]`);
38731
+ lines2.push("");
38732
+ lines2.push("For review (policy or action wording no delegation result carried; not counted):");
38733
+ for (const item of review) lines2.push(` run ${item.run}: "${shown3(item.utterance)}" [${item.markers.join(", ")}]`);
38674
38734
  }
38675
- lines.push("");
38676
- 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");
38677
- return lines.join("\n");
38735
+ lines2.push("");
38736
+ 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");
38737
+ return lines2.join("\n");
38678
38738
  }
38679
38739
  var DIMENSION_LABELS, shown3;
38680
38740
  var init_report = __esm({
@@ -41404,8 +41464,8 @@ function refuseFlags(sub, values, flags) {
41404
41464
  function entryLine(entry) {
41405
41465
  return ` ${text3(entry.person_id)} since ${text3(entry.created_at)}, by ${text3(entry.created_by)}`;
41406
41466
  }
41407
- function print(values, data, lines) {
41408
- console.log(values.json ? JSON.stringify(data, null, 2) : lines.join("\n"));
41467
+ function print(values, data, lines2) {
41468
+ console.log(values.json ? JSON.stringify(data, null, 2) : lines2.join("\n"));
41409
41469
  }
41410
41470
  async function persons(sub, positionals, values) {
41411
41471
  const takesTo = sub === "link-person" || sub === "unlink-person";
@@ -41450,9 +41510,9 @@ async function persons(sub, positionals, values) {
41450
41510
  }
41451
41511
  case "denied-persons": {
41452
41512
  const data = await api.listDeniedPersons(orgId, { cursor, limit });
41453
- const lines = data.denied.length === 0 ? ["Nothing is denied."] : ["Denied:", ...data.denied.map(entryLine)];
41454
- if (data.next_cursor) lines.push(`More: --cursor ${text3(data.next_cursor)}`);
41455
- print(values, data, lines);
41513
+ const lines2 = data.denied.length === 0 ? ["Nothing is denied."] : ["Denied:", ...data.denied.map(entryLine)];
41514
+ if (data.next_cursor) lines2.push(`More: --cursor ${text3(data.next_cursor)}`);
41515
+ print(values, data, lines2);
41456
41516
  return;
41457
41517
  }
41458
41518
  case "deny-person": {
@@ -42019,44 +42079,62 @@ async function readAgenda(calls, phaseId) {
42019
42079
  }
42020
42080
  return { groups, more: true };
42021
42081
  }
42022
- async function readInputTexts(calls, folder, work) {
42082
+ function checkedText(base, file, answered, cited) {
42083
+ 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 }));
42084
+ const unwritten = (status, sha) => ({ text: { ...base, status, file: null, sha, passages: unmatched }, data: null });
42085
+ if (!answered) return unwritten("no_text", null);
42086
+ if (answered.sha === null || computeHash(answered.bytes) !== answered.sha) return unwritten("hash_mismatch", answered.sha);
42087
+ const lines2 = unmatched.length ? casePassageLines(new TextDecoder("utf-8").decode(answered.bytes)) : [];
42088
+ return {
42089
+ text: {
42090
+ ...base,
42091
+ status: "written",
42092
+ file,
42093
+ sha: answered.sha,
42094
+ passages: unmatched.map((p) => {
42095
+ const inRange = p.line_start >= 1 && p.line_end >= p.line_start && p.line_end <= lines2.length;
42096
+ const text5 = Buffer.from(lines2.slice(p.line_start - 1, p.line_end).join("\n"), "utf-8");
42097
+ return { ...p, matches: inRange && computeHash(text5) === p.passage_sha };
42098
+ })
42099
+ },
42100
+ data: Buffer.from(answered.bytes.buffer, answered.bytes.byteOffset, answered.bytes.byteLength)
42101
+ };
42102
+ }
42103
+ async function readInputTexts(calls, folder, work, folders, listed3) {
42023
42104
  const { api, connection } = calls.session;
42024
- const linked = work.inputs.filter((input) => input.link?.readable === true);
42025
- const read = await Promise.all(linked.map(async (input) => {
42026
- const view = (await calls.run(() => api.getCaseInputLink(connection, input.id))).data;
42027
- if (!view?.readable) return null;
42028
- const answered = await calls.run(() => notFound(api.getCaseCollectionContent(connection, view.document_id, { part: "text", version_id: view.version_id })));
42029
- const passages = view.passages.filter((p) => p.version_id === view.version_id);
42030
- const base = { input_id: input.id, key: input.key, name: input.name, document_id: view.document_id, version_id: view.version_id };
42031
- 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 }));
42032
- if (!answered) return { text: { ...base, status: "no_text", file: null, sha: null, passages: unmatched }, data: null };
42033
- if (answered.sha === null || computeHash(answered.bytes) !== answered.sha) {
42034
- return { text: { ...base, status: "hash_mismatch", file: null, sha: answered.sha, passages: unmatched }, data: null };
42035
- }
42036
- const lines = unmatched.length ? casePassageLines(new TextDecoder("utf-8").decode(answered.bytes)) : [];
42105
+ const read = await Promise.all(work.inputs.map(async (input) => {
42037
42106
  const file = `${INPUTS_DIR}/${folder}/${segment(input.key, CASE_INPUT_KEY_PATTERN, input.id)}.md`;
42038
- return {
42039
- text: {
42040
- ...base,
42041
- status: "written",
42042
- file,
42043
- sha: answered.sha,
42044
- passages: unmatched.map((p) => {
42045
- const inRange = p.line_start >= 1 && p.line_end >= p.line_start && p.line_end <= lines.length;
42046
- const cited = Buffer.from(lines.slice(p.line_start - 1, p.line_end).join("\n"), "utf-8");
42047
- return { ...p, matches: inRange && computeHash(cited) === p.passage_sha };
42048
- })
42049
- },
42050
- data: Buffer.from(answered.bytes.buffer, answered.bytes.byteOffset, answered.bytes.byteLength)
42051
- };
42107
+ const named = { input_id: input.id, key: input.key, name: input.name };
42108
+ if (input.link?.readable === true) {
42109
+ const view2 = (await calls.run(() => api.getCaseInputLink(connection, input.id))).data;
42110
+ if (!view2?.readable) return null;
42111
+ const answered = await calls.run(() => notFound(api.getCaseCollectionContent(connection, view2.document_id, { part: "text", version_id: view2.version_id })));
42112
+ const base2 = { ...named, origin: "collection", document_id: view2.document_id, version_id: view2.version_id };
42113
+ return checkedText(base2, file, answered, view2.passages.filter((p) => p.version_id === view2.version_id));
42114
+ }
42115
+ if (input.source_link?.readable !== true) return null;
42116
+ const view = (await calls.run(() => api.getCaseInputSourceLink(connection, input.id))).data;
42117
+ if (!view?.readable) return null;
42118
+ if (view.kind === "official_version") {
42119
+ const base2 = { ...named, origin: "previous_output", official_version_id: view.official_version_id, version: view.version };
42120
+ const checked = checkedText(base2, file, null, view.passages.filter((p) => "official_version_id" in p && p.official_version_id === view.official_version_id));
42121
+ return view.has_text ? { text: { ...checked.text, status: "no_read" }, data: null } : checked;
42122
+ }
42123
+ const base = { ...named, origin: "received", received_id: view.received_id };
42124
+ const cited = view.passages.filter((p) => "received_id" in p && p.received_id === view.received_id);
42125
+ const phaseFolder = folders.get(view.phase_id);
42126
+ 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));
42127
+ const bytes = rel === void 0 ? null : await calls.run(() => notFound(api.getCaseFileContent(connection, rel)));
42128
+ return checkedText(base, file, bytes === null ? null : { bytes, sha: listed3.get(rel) }, cited);
42052
42129
  }));
42053
42130
  return read.filter((r) => r !== null);
42054
42131
  }
42055
- async function readWork(calls, detail, confidential) {
42132
+ async function readWork(calls, detail, confidential, listing) {
42056
42133
  const { api, connection } = calls.session;
42057
42134
  const state = (await calls.run(() => api.getCaseState(connection))).data;
42058
42135
  if (state.view !== "work") return { state, phases: [], approved: [] };
42059
42136
  const folders = new Map(detail.phases.map((p) => [p.phase_id, p.folder]));
42137
+ const listed3 = new Map(listing.files.filter((f) => listing.inRun(f.path)).map((f) => [f.path, f.sha]));
42060
42138
  const underWay = state.state.phases.filter((p) => p.status === "in_progress").map((p) => p.phase_id);
42061
42139
  const [phases, approved] = await Promise.all([
42062
42140
  Promise.all(underWay.map(async (phaseId) => {
@@ -42064,7 +42142,7 @@ async function readWork(calls, detail, confidential) {
42064
42142
  const [{ work, texts }, agenda, delivery] = await Promise.all([
42065
42143
  calls.run(() => api.getCasePhaseWork(connection, phaseId)).then(async ({ data }) => ({
42066
42144
  work: data,
42067
- texts: await readInputTexts(calls, segment(folder, CASE_PHASE_FOLDER_PATTERN, phaseId), data)
42145
+ texts: await readInputTexts(calls, segment(folder, CASE_PHASE_FOLDER_PATTERN, phaseId), data, folders, listed3)
42068
42146
  })),
42069
42147
  readAgenda(calls, phaseId),
42070
42148
  calls.run(() => api.getCaseDelivery(connection, phaseId))
@@ -42138,22 +42216,22 @@ function statusSections(detail, work, before, now) {
42138
42216
  function filesSection(input) {
42139
42217
  const now = new Map(input.files.filter((f) => input.inRun(f.path)).map((f) => [f.path, f.sha]));
42140
42218
  const before = new Map(Object.entries(input.record.files).filter(([rel]) => input.inRun(rel)).map(([rel, f]) => [rel, f.sha]));
42141
- const lines = [];
42219
+ const lines2 = [];
42142
42220
  for (const [rel, sha] of now) {
42143
- if (!before.has(rel)) lines.push(`+ ${safe6(rel)}`);
42144
- else if (before.get(rel) !== sha) lines.push(`~ ${safe6(rel)}`);
42221
+ if (!before.has(rel)) lines2.push(`+ ${safe6(rel)}`);
42222
+ else if (before.get(rel) !== sha) lines2.push(`~ ${safe6(rel)}`);
42145
42223
  }
42146
- for (const rel of before.keys()) if (!now.has(rel)) lines.push(`- ${safe6(rel)} (removed, or no longer readable here)`);
42147
- 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) };
42224
+ for (const rel of before.keys()) if (!now.has(rel)) lines2.push(`- ${safe6(rel)} (removed, or no longer readable here)`);
42225
+ 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) };
42148
42226
  }
42149
42227
  function revisionsSection(since, hideMessages) {
42150
- const lines = since.revisions.flatMap((r) => {
42228
+ const lines2 = since.revisions.flatMap((r) => {
42151
42229
  const author = r.author?.display_name ? one(r.author.display_name) : "a person no longer named";
42152
42230
  const message = r.message !== null && !hideMessages ? `: ${one(r.message)}` : "";
42153
42231
  return [`revision ${r.revision_id}, ${r.created_at}, ${author} (${r.channel})${message}`, ...r.entries.map((e) => ` ${safe6(e.path)}${e.sha === null ? " (removed)" : ""}`)];
42154
42232
  });
42155
- if (since.more) lines.push("\u2026 and older ones: `wayai cases log` lists them all.");
42156
- return { title: "Revisions", lines };
42233
+ if (since.more) lines2.push("\u2026 and older ones: `wayai cases log` lists them all.");
42234
+ return { title: "Revisions", lines: lines2 };
42157
42235
  }
42158
42236
  function renderSections(sections) {
42159
42237
  return sections.filter((s) => s.lines.length > 0).flatMap((s) => [`${s.title}:`, ...s.lines.map((l) => ` ${l}`)]);
@@ -42164,7 +42242,9 @@ function unwrittenLines(work) {
42164
42242
  if (text5.status === "hash_mismatch") {
42165
42243
  return [`${name}: not written, its bytes do not hash to the SHA-256 the space registered for it${text5.sha === null ? " (none was answered)" : ""}.`];
42166
42244
  }
42167
- return text5.status === "no_text" ? [`${name}: the version it links holds no registered text, or is no longer readable here.`] : [];
42245
+ if (text5.status === "no_read") return [`${name}: not written, this CLI does not read the text of an earlier phase's official version yet.`];
42246
+ if (text5.status !== "no_text") return [];
42247
+ 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.`];
42168
42248
  }));
42169
42249
  }
42170
42250
  function packageReadme(pkg2) {
@@ -42189,11 +42269,13 @@ function readme(detail, at, withheld, confidential, unwritten, pkg2) {
42189
42269
  "- `evidence.json`: each phase under way: its inputs with their links, its outputs and its items.",
42190
42270
  "- `agenda.json`: each phase under way: its agenda groups and decisions; and the approved decisions.",
42191
42271
  "- `deliveries.json`: each phase under way: its newest submission and manifest.",
42192
- `- \`${INPUTS_FILE}\`: each phase under way: each input whose link you may read, the version it links, where its text`,
42193
- " is here, and its cited passages (lines and hash, and whether they match the text here).",
42194
- `- \`${INPUTS_DIR}/<phase folder>/<input key>.md\`: each such input's registered text, of the version its link names,`,
42195
- " byte for byte and checked against the SHA-256 the space registered for it: line N here is the line N a citation",
42196
- " names (each line ends at a line break).",
42272
+ `- \`${INPUTS_FILE}\`: each phase under way: each input whose link you may read, the version or source it links (a`,
42273
+ " collection document's version, an earlier phase's official version, a received document), where its text is here,",
42274
+ " and its cited passages (lines and hash, and whether they match the text here).",
42275
+ `- \`${INPUTS_DIR}/<phase folder>/<input key>.md\`: each such input's registered text, of the version or source its`,
42276
+ " link names, byte for byte and checked against the SHA-256 the space registered for it: line N here is the line N a",
42277
+ " citation names (each line ends at a line break). An earlier phase's official version's text is not here: this",
42278
+ " CLI does not read it yet.",
42197
42279
  ...unwritten.length ? ["", "Linked inputs' texts not written:", ...unwritten.map((line) => `- ${line}`)] : []
42198
42280
  ];
42199
42281
  return [
@@ -42345,7 +42427,7 @@ async function writeCaseMirror(calls, input) {
42345
42427
  const readsRevisions = before !== null || mode !== "mirror-only";
42346
42428
  const { api, connection } = calls.session;
42347
42429
  const [work, since, pkg2] = await Promise.all([
42348
- withheld ? null : readWork(calls, detail, confidential),
42430
+ withheld ? null : readWork(calls, detail, confidential, input),
42349
42431
  readsRevisions ? revisionsSince(calls, before ? before.revision_at : void 0, confidential) : NO_REVISIONS,
42350
42432
  // Asked with --confidential alone: unasked, the space leaves its marked files out, whatever right the reader holds.
42351
42433
  readPackageDelivery({
@@ -42375,9 +42457,9 @@ async function writeCaseMirror(calls, input) {
42375
42457
  if (before) sections.push(revisionsSection(since, withheld));
42376
42458
  if (mode !== "clone") sections.push(filesSection(input));
42377
42459
  if (before && work) sections.push(...statusSections(detail, work, before, now));
42378
- const lines = renderSections(sections);
42460
+ const lines2 = renderSections(sections);
42379
42461
  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.";
42380
- const summary = [heading, ...lines.length ? lines : before ? ["Nothing changed."] : []];
42462
+ const summary = [heading, ...lines2.length ? lines2 : before ? ["Nothing changed."] : []];
42381
42463
  const notice = confidential ? [] : ["", MIRROR_CONFIDENTIAL_NOTICE];
42382
42464
  const unwritten = unwrittenLines(work);
42383
42465
  const files = [
@@ -42481,7 +42563,7 @@ exec wayai cases pull --mirror-only --dir "$(dirname "$0")/.."
42481
42563
  }
42482
42564
  });
42483
42565
 
42484
- // ../../packages/core/dist/chunk-KAO33OFE.js
42566
+ // ../../packages/core/dist/chunk-GOGIAA5K.js
42485
42567
  function firstAtOrAfter(sorted, from) {
42486
42568
  let lo = 0;
42487
42569
  let hi = sorted.length;
@@ -42492,7 +42574,7 @@ function firstAtOrAfter(sorted, from) {
42492
42574
  }
42493
42575
  return lo < sorted.length ? sorted[lo] : -1;
42494
42576
  }
42495
- function caseMarkdownSegments(text5) {
42577
+ function segmentsOf(text5, state) {
42496
42578
  const blankStarts = [];
42497
42579
  for (let i = text5.indexOf("\n"); i >= 0; i = text5.indexOf("\n", i + 1)) {
42498
42580
  BLANK_AFTER.lastIndex = i + 1;
@@ -42520,7 +42602,10 @@ function caseMarkdownSegments(text5) {
42520
42602
  const close3 = new RegExp(`^ {0,3}${m[1][0]}{${m[1].length},}[ \\t]*\\r?$`, "gm");
42521
42603
  close3.lastIndex = start;
42522
42604
  const found = close3.exec(text5);
42523
- if (!found) return text5.length;
42605
+ if (!found) {
42606
+ if (state) state.open = true;
42607
+ return text5.length;
42608
+ }
42524
42609
  const end = found.index + found[0].length;
42525
42610
  return text5[end] === "\n" ? end + 1 : end;
42526
42611
  };
@@ -42558,6 +42643,7 @@ function caseMarkdownSegments(text5) {
42558
42643
  continue;
42559
42644
  }
42560
42645
  commentNeverCloses = true;
42646
+ if (state) state.open = true;
42561
42647
  }
42562
42648
  if (text5[i] === "`") {
42563
42649
  let j = i;
@@ -42701,31 +42787,32 @@ function anchorOf(text5) {
42701
42787
  }
42702
42788
  return null;
42703
42789
  }
42704
- function tableEnd(lines, i) {
42705
- let columns = COLUMNS.test(lines[i]) ? i : -1;
42706
- if (columns < 0 && DASHES.test(lines[i])) {
42707
- for (let n = i + 1; n < lines.length && lines[n].trim() !== ""; n++) {
42708
- if (COLUMNS.test(lines[n])) {
42790
+ function tableEnd(lines2, i, state) {
42791
+ let columns = COLUMNS.test(lines2[i]) ? i : -1;
42792
+ if (columns < 0 && DASHES.test(lines2[i])) {
42793
+ for (let n = i + 1; n < lines2.length && lines2[n].trim() !== ""; n++) {
42794
+ if (COLUMNS.test(lines2[n])) {
42709
42795
  columns = n;
42710
42796
  break;
42711
42797
  }
42712
42798
  }
42713
42799
  }
42714
42800
  if (columns < 0) return -1;
42715
- for (let n = columns + 1; n < lines.length; n++) {
42716
- if (atxHeading(lines[n]) || FENCE.test(lines[n])) return -1;
42717
- if (DASHES.test(lines[n]) || COLUMNS.test(lines[n])) return n;
42801
+ for (let n = columns + 1; n < lines2.length; n++) {
42802
+ if (atxHeading(lines2[n]) || FENCE.test(lines2[n])) return -1;
42803
+ if (DASHES.test(lines2[n]) || COLUMNS.test(lines2[n])) return n;
42718
42804
  }
42805
+ if (state) state.open = true;
42719
42806
  return -1;
42720
42807
  }
42721
- function readHeadings(lines) {
42808
+ function readHeadings(lines2, state) {
42722
42809
  const headings = [];
42723
42810
  let fence = null;
42724
42811
  let closedAt = -1;
42725
42812
  let tableUntil = -1;
42726
- for (let i = 0; i < lines.length; i++) {
42813
+ for (let i = 0; i < lines2.length; i++) {
42727
42814
  if (i <= tableUntil) continue;
42728
- const line = lines[i];
42815
+ const line = lines2[i];
42729
42816
  const mark = FENCE.exec(line);
42730
42817
  if (fence !== null) {
42731
42818
  if (mark && mark[1][0] === fence[0] && mark[1].length >= fence.length && line.trim() === mark[1]) {
@@ -42738,8 +42825,8 @@ function readHeadings(lines) {
42738
42825
  fence = mark[1];
42739
42826
  continue;
42740
42827
  }
42741
- if (i === 0 || lines[i - 1].trim() === "") {
42742
- const end = tableEnd(lines, i);
42828
+ if (i === 0 || lines2[i - 1].trim() === "") {
42829
+ const end = tableEnd(lines2, i, state);
42743
42830
  if (end > i) {
42744
42831
  tableUntil = end;
42745
42832
  continue;
@@ -42750,23 +42837,24 @@ function readHeadings(lines) {
42750
42837
  headings.push({ start: i, end: i + 1, ...atx });
42751
42838
  continue;
42752
42839
  }
42753
- const previous = lines[i - 1];
42754
- if (i > 0 && SETEXT_UNDERLINE.test(line) && previous.trim() !== "" && closedAt !== i - 1 && (i === 1 || lines[i - 2].trim() === "") && headings.at(-1)?.end !== i) {
42840
+ const previous = lines2[i - 1];
42841
+ if (i > 0 && SETEXT_UNDERLINE.test(line) && previous.trim() !== "" && closedAt !== i - 1 && (i === 1 || lines2[i - 2].trim() === "") && headings.at(-1)?.end !== i) {
42755
42842
  headings.push({ start: i - 1, end: i + 1, level: line.includes("=") ? 1 : 2, text: previous.trim() });
42756
42843
  }
42757
42844
  }
42845
+ if (state && fence !== null) state.open = true;
42758
42846
  return headings.map((h) => {
42759
42847
  const anchor = anchorOf(h.text);
42760
42848
  return { ...h, code: anchor?.code ?? null, title: anchor?.title ?? h.text };
42761
42849
  });
42762
42850
  }
42763
- function bodyWithLines(text5) {
42851
+ function bodyWithLines(text5, state) {
42764
42852
  const original = withoutBom(text5).replace(/\r\n/g, "\n");
42765
42853
  const frontMatter = CASE_FRONT_MATTER.exec(original)?.[0] ?? "";
42766
42854
  let line = 1 + (frontMatter.match(/\n/g)?.length ?? 0);
42767
42855
  let body = "";
42768
42856
  const origin = [line];
42769
- for (const segment2 of caseMarkdownSegments(original.slice(frontMatter.length))) {
42857
+ for (const segment2 of segmentsOf(original.slice(frontMatter.length), state)) {
42770
42858
  if (segment2.kind === "comment") {
42771
42859
  line += segment2.content.match(/\n/g)?.length ?? 0;
42772
42860
  continue;
@@ -42790,13 +42878,16 @@ function lastAtOrBefore(sorted, at) {
42790
42878
  return lo;
42791
42879
  }
42792
42880
  function readCaseItems(text5) {
42793
- const { body, frontMatter, origin } = bodyWithLines(text5);
42794
- const lines = body.split("\n");
42881
+ return readItems(text5);
42882
+ }
42883
+ function readItems(text5, state) {
42884
+ const { body, frontMatter, origin } = bodyWithLines(text5, state);
42885
+ const lines2 = body.split("\n");
42795
42886
  const lastLine = Math.max(1, casePassageLines(text5).length);
42796
- const headings = readHeadings(lines);
42887
+ const headings = readHeadings(lines2, state);
42797
42888
  const lineMarks = [];
42798
42889
  const malformed = [];
42799
- lines.forEach((content, n) => {
42890
+ lines2.forEach((content, n) => {
42800
42891
  const marks = [];
42801
42892
  for (const { raw, content: inner } of lineMarkers(content)) {
42802
42893
  const marker = inner === null ? null : readMarker(inner, origin[n]);
@@ -42806,8 +42897,8 @@ function readCaseItems(text5) {
42806
42897
  lineMarks.push(marks);
42807
42898
  });
42808
42899
  const ends = new Array(headings.length);
42809
- let nextAnchor = lines.length;
42810
- const nextAtLevel = new Array(7).fill(lines.length);
42900
+ let nextAnchor = lines2.length;
42901
+ const nextAtLevel = new Array(7).fill(lines2.length);
42811
42902
  for (let h = headings.length - 1; h >= 0; h--) {
42812
42903
  const heading = headings[h];
42813
42904
  let end = nextAnchor;
@@ -42816,9 +42907,9 @@ function readCaseItems(text5) {
42816
42907
  nextAtLevel[heading.level] = heading.start;
42817
42908
  if (heading.code !== null) nextAnchor = heading.start;
42818
42909
  }
42819
- const headingLine = new Array(lines.length).fill(false);
42910
+ const headingLine = new Array(lines2.length).fill(false);
42820
42911
  for (const heading of headings) for (let n = heading.start; n < heading.end; n++) headingLine[n] = true;
42821
- const inItem = new Array(lines.length).fill(false);
42912
+ const inItem = new Array(lines2.length).fill(false);
42822
42913
  const items = [];
42823
42914
  headings.forEach((heading, h) => {
42824
42915
  if (heading.code === null) return;
@@ -42828,7 +42919,7 @@ function readCaseItems(text5) {
42828
42919
  const images = [];
42829
42920
  for (let n = heading.end; n < end; n++) {
42830
42921
  for (const marker of lineMarks[n]) markers2.push(marker);
42831
- for (const target of lineImages(lines[n])) images.push({ target, line: origin[n] });
42922
+ for (const target of lineImages(lines2[n])) images.push({ target, line: origin[n] });
42832
42923
  }
42833
42924
  const internal = [];
42834
42925
  for (let o = h + 1; o < headings.length && headings[o].start < end; o++) {
@@ -42836,7 +42927,7 @@ function readCaseItems(text5) {
42836
42927
  if (other.start >= heading.end) internal.push({ level: other.level, text: other.title, line: origin[other.start] });
42837
42928
  }
42838
42929
  const prose = [];
42839
- for (let n = heading.end; n < end; n++) if (!headingLine[n]) prose.push(lines[n]);
42930
+ for (let n = heading.end; n < end; n++) if (!headingLine[n]) prose.push(lines2[n]);
42840
42931
  const proseText = prose.join("\n");
42841
42932
  let withoutFills = "";
42842
42933
  let from = 0;
@@ -42850,7 +42941,7 @@ function readCaseItems(text5) {
42850
42941
  title: heading.title,
42851
42942
  level: heading.level,
42852
42943
  lines: { start: origin[heading.start], end: Math.max(origin[heading.start], Math.min(origin[end - 1], lastLine)) },
42853
- text: lines.slice(heading.end, end).join("\n"),
42944
+ text: lines2.slice(heading.end, end).join("\n"),
42854
42945
  has_text: withoutFills.trim() !== "",
42855
42946
  headings: internal,
42856
42947
  markers: markers2,
@@ -42865,17 +42956,30 @@ function readCaseItems(text5) {
42865
42956
  const fills = fillsOf(body).map((fill) => ({ text: fill.text, line: origin[lastAtOrBefore(lineStarts, fill.start)] }));
42866
42957
  const markers = [];
42867
42958
  for (const marks of lineMarks) for (const marker of marks) markers.push(marker);
42959
+ const outside = lines2.filter((_, n) => !inItem[n]);
42960
+ if (state) {
42961
+ let last = headings.length - 1;
42962
+ while (last >= 0 && headings[last].code === null) last--;
42963
+ state.open_level = last >= 0 && ends[last] === lines2.length ? headings[last].level : null;
42964
+ const anchored = headings.find((heading) => heading.code !== null)?.start ?? lines2.length;
42965
+ state.lead = {
42966
+ lines: lines2.slice(0, anchored),
42967
+ marks: lineMarks.slice(0, anchored),
42968
+ headings: headings.filter((heading) => heading.start < anchored).map((heading) => ({ start: heading.start, level: heading.level }))
42969
+ };
42970
+ state.outside = outside;
42971
+ }
42868
42972
  return {
42869
42973
  items,
42870
42974
  markers,
42871
42975
  fills,
42872
- outside: { front_matter: frontMatter, body: lines.filter((_, n) => !inItem[n]).join("\n") },
42976
+ outside: { front_matter: frontMatter, body: outside.join("\n") },
42873
42977
  malformed_markers: malformed
42874
42978
  };
42875
42979
  }
42876
- 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;
42877
- var init_chunk_KAO33OFE = __esm({
42878
- "../../packages/core/dist/chunk-KAO33OFE.js"() {
42980
+ 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;
42981
+ var init_chunk_GOGIAA5K = __esm({
42982
+ "../../packages/core/dist/chunk-GOGIAA5K.js"() {
42879
42983
  "use strict";
42880
42984
  init_chunk_S7UAXLHJ();
42881
42985
  init_chunk_PFPADFUC();
@@ -42884,6 +42988,7 @@ var init_chunk_KAO33OFE = __esm({
42884
42988
  FENCE_OPEN = / {0,3}(`{3,}|~{3,})([^\n]*)(?:\n|$)/y;
42885
42989
  BLANK_AFTER = /[ \t]*\r?\n/y;
42886
42990
  CASE_FRONT_MATTER = /^---\r?\n(?![ \t]*\r?\n)([\s\S]*?)\r?\n---/;
42991
+ FRONT_MATTER_OPENING = CASE_FRONT_MATTER.source.slice(0, CASE_FRONT_MATTER.source.indexOf("(["));
42887
42992
  withoutBom = (text5) => text5.replace(/^\uFEFF/, "");
42888
42993
  FENCE = /^ {0,3}(`{3,}|~{3,})/;
42889
42994
  SETEXT_UNDERLINE = /^ {0,3}(=+|-+)[ \t]*$/;
@@ -42899,6 +43004,7 @@ var init_chunk_KAO33OFE = __esm({
42899
43004
  isSpace = (c) => c !== void 0 && /\s/.test(c);
42900
43005
  isTabOrSpace = (c) => c === " " || c === " ";
42901
43006
  once = (values) => [...new Set(values)];
43007
+ OPENS_FRONT_MATTER = new RegExp(FRONT_MATTER_OPENING);
42902
43008
  }
42903
43009
  });
42904
43010
 
@@ -42906,7 +43012,7 @@ var init_chunk_KAO33OFE = __esm({
42906
43012
  var init_case_item_reader = __esm({
42907
43013
  "../../packages/core/dist/case-item-reader.js"() {
42908
43014
  "use strict";
42909
- init_chunk_KAO33OFE();
43015
+ init_chunk_GOGIAA5K();
42910
43016
  init_chunk_S7UAXLHJ();
42911
43017
  init_chunk_7TQYAKCB();
42912
43018
  init_chunk_VROZDNLV();
@@ -42944,12 +43050,12 @@ function skeletonParts(input) {
42944
43050
  let underGrouping = false;
42945
43051
  for (const item of input.items) {
42946
43052
  const nested = !item.grouping && underGrouping;
42947
- const lines = [`${nested ? "###" : "##"} ${oneLine(item.title)} {#${item.code}}`, ""];
43053
+ const lines2 = [`${nested ? "###" : "##"} ${oneLine(item.title)} {#${item.code}}`, ""];
42948
43054
  if (item.grouping) underGrouping = true;
42949
43055
  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)}}}`;
42950
- if (body) lines.push(body, "");
42951
- if (nested) sections[sections.length - 1].lines.push(...lines);
42952
- else sections.push({ code: item.code, lines });
43056
+ if (body) lines2.push(body, "");
43057
+ if (nested) sections[sections.length - 1].lines.push(...lines2);
43058
+ else sections.push({ code: item.code, lines: lines2 });
42953
43059
  }
42954
43060
  return { cover, sections, missing: [...missing].sort() };
42955
43061
  }
@@ -42973,12 +43079,289 @@ var init_case_skeleton = __esm({
42973
43079
  MARK2 = /\{\{\s*([^{}:]+?)\s*(?::[^{}]*)?\}\}/g;
42974
43080
  FILL = "fill";
42975
43081
  oneLine = (text5) => text5.replace(/\s*\r?\n\s*/g, " ").trim();
42976
- close2 = (lines) => `${lines.join("\n").trimEnd()}
43082
+ close2 = (lines2) => `${lines2.join("\n").trimEnd()}
42977
43083
  `;
42978
43084
  fillsIn = (text5) => readCaseItems(text5).fills.length;
42979
43085
  }
42980
43086
  });
42981
43087
 
43088
+ // ../../packages/core/dist/contracts/case-collection-links.js
43089
+ var init_case_collection_links = __esm({
43090
+ "../../packages/core/dist/contracts/case-collection-links.js"() {
43091
+ "use strict";
43092
+ init_chunk_J7LBOXQK();
43093
+ init_chunk_6CHDJVQ6();
43094
+ init_chunk_U3X3BIQH();
43095
+ init_chunk_EYOBPUDN();
43096
+ init_chunk_U3L6QR6F();
43097
+ init_chunk_S7UAXLHJ();
43098
+ init_chunk_7TQYAKCB();
43099
+ init_chunk_VROZDNLV();
43100
+ init_chunk_733K4J4G();
43101
+ init_chunk_PFPADFUC();
43102
+ init_chunk_KWRHZBGU();
43103
+ init_chunk_3T3D7LTE();
43104
+ init_chunk_M2T55BV6();
43105
+ init_chunk_VYINA6YP();
43106
+ init_chunk_ZVXO3XL6();
43107
+ init_chunk_FBV7NLKO();
43108
+ init_chunk_WEXVYJ5H();
43109
+ init_chunk_HZ6CADSY();
43110
+ init_chunk_ICYO56QW();
43111
+ init_chunk_WFQDSQJK();
43112
+ init_chunk_ZTNFLGW5();
43113
+ }
43114
+ });
43115
+
43116
+ // ../../packages/core/dist/contracts/case-collection-citations.js
43117
+ var init_case_collection_citations = __esm({
43118
+ "../../packages/core/dist/contracts/case-collection-citations.js"() {
43119
+ "use strict";
43120
+ init_chunk_U3L6QR6F();
43121
+ init_chunk_S7UAXLHJ();
43122
+ init_chunk_7TQYAKCB();
43123
+ init_chunk_VROZDNLV();
43124
+ init_chunk_733K4J4G();
43125
+ init_chunk_PFPADFUC();
43126
+ init_chunk_KWRHZBGU();
43127
+ init_chunk_3T3D7LTE();
43128
+ init_chunk_M2T55BV6();
43129
+ init_chunk_VYINA6YP();
43130
+ init_chunk_ZVXO3XL6();
43131
+ init_chunk_FBV7NLKO();
43132
+ init_chunk_WEXVYJ5H();
43133
+ init_chunk_HZ6CADSY();
43134
+ init_chunk_ICYO56QW();
43135
+ init_chunk_WFQDSQJK();
43136
+ init_chunk_ZTNFLGW5();
43137
+ }
43138
+ });
43139
+
43140
+ // src/cases/case-inputs.ts
43141
+ function inputLinkState(input) {
43142
+ const unlinked = input.dispensation ? { state: "dispensed" } : { state: "unlinked" };
43143
+ if (input.origin === "collection") {
43144
+ const link2 = input.link;
43145
+ if (!link2) return unlinked;
43146
+ if (!link2.readable) return { state: "unreadable", linked_at: link2.linked_at };
43147
+ const source2 = {
43148
+ kind: "collection",
43149
+ document_id: link2.document_id,
43150
+ version_id: link2.version_id,
43151
+ document_title: link2.document_title,
43152
+ version_title: link2.version_title
43153
+ };
43154
+ 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 };
43155
+ }
43156
+ const link = input.source_link;
43157
+ if (link === void 0) return input.dispensation ? { state: "dispensed" } : { state: "unknown" };
43158
+ if (link === null) return unlinked;
43159
+ if (!link.readable) return { state: "unreadable", linked_at: link.linked_at };
43160
+ if (link.kind === "received") {
43161
+ return {
43162
+ state: "linked",
43163
+ linked_at: link.linked_at,
43164
+ source: { kind: "received", received_id: link.received_id, title: link.title, type: link.type, phase_id: link.phase_id }
43165
+ };
43166
+ }
43167
+ const source = {
43168
+ kind: "official_version",
43169
+ official_version_id: link.official_version_id,
43170
+ output_code: link.output_code,
43171
+ phase_id: link.phase_id,
43172
+ version: link.version
43173
+ };
43174
+ 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 };
43175
+ }
43176
+ function linkCommand(key, folder, origin, id) {
43177
+ const [flag, placeholder] = origin === "previous_output" ? ["--official-version", "<official_version_id>"] : ["--received", "<received_id>"];
43178
+ return `wayai cases link ${one2(key)} --phase ${one2(folder)} ${flag} ${id ?? placeholder}`;
43179
+ }
43180
+ function linkHint(key, folder, origin) {
43181
+ if (origin === "collection") return "a person links it, in the web app";
43182
+ if (origin === "received") {
43183
+ 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/)`;
43184
+ }
43185
+ 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)`;
43186
+ }
43187
+ function undecidedWords(input, folder, link, folders) {
43188
+ const linked = sourceWords(link.source, folders);
43189
+ if (link.source.kind === "collection") {
43190
+ return { text: `links ${linked}, and a newer version awaits a decision: a person decides on it, in the web app`, agent: false };
43191
+ }
43192
+ if (link.current_id === null) {
43193
+ return { text: `links ${linked}, which a correction superseded by a version not readable here: a person who reads it relinks it`, agent: false };
43194
+ }
43195
+ return {
43196
+ text: `links ${linked}, which a correction superseded: relink it to the current one: \`${linkCommand(input.key, folder, input.origin, link.current_id)}\``,
43197
+ agent: true
43198
+ };
43199
+ }
43200
+ function inputLine(input, folder, folders) {
43201
+ const head = `${one2(input.key)} (${one2(input.name)}), ${input.origin.replaceAll("_", " ")}${input.required ? ", required" : ""}`;
43202
+ const state = inputLinkState(input);
43203
+ switch (state.state) {
43204
+ case "linked":
43205
+ return `${head}: linked to ${sourceWords(state.source, folders)}`;
43206
+ case "undecided":
43207
+ return `${head}: ${undecidedWords(input, folder, state, folders).text}`;
43208
+ case "unreadable":
43209
+ return `${head}: linked, to a source not readable here`;
43210
+ case "dispensed":
43211
+ return `${head}: dispensed`;
43212
+ case "unknown":
43213
+ return `${head}: this server does not say whether it is linked`;
43214
+ case "unlinked":
43215
+ return `${head}: not linked; ${linkHint(input.key, folder, input.origin)}`;
43216
+ }
43217
+ }
43218
+ function findInput(work, phase, name) {
43219
+ const input = work.inputs.find((i) => i.key === name) ?? work.inputs.find((i) => i.id === name);
43220
+ if (input) return input;
43221
+ 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"}.`);
43222
+ }
43223
+ function linkTarget(opts) {
43224
+ if (opts.officialVersion === void 0 === (opts.received === void 0)) {
43225
+ throw expected("link takes one of --official-version <id> (an input of origin previous_output) or --received <id> (an input of origin received).");
43226
+ }
43227
+ if (opts.officialVersion !== void 0) {
43228
+ if (!UUID_RE3.test(opts.officialVersion)) throw expected("--official-version takes an official version's id (a UUID).");
43229
+ return { official_version_id: opts.officialVersion };
43230
+ }
43231
+ if (!UUID_RE3.test(opts.received)) throw expected("--received takes a received document's id (a UUID).");
43232
+ return { received_id: opts.received };
43233
+ }
43234
+ function linkMismatch(input, label3, target) {
43235
+ if (input.origin === "collection") return `The ${label3} links a collection document: a person links it, in the web app.`;
43236
+ const wants = "official_version_id" in target ? "previous_output" : "received";
43237
+ if (input.origin === wants) return null;
43238
+ 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>.`;
43239
+ }
43240
+ function detailOf(err, field) {
43241
+ try {
43242
+ const value = JSON.parse(err.body).details?.[field];
43243
+ return typeof value === "string" || value === null ? value : void 0;
43244
+ } catch {
43245
+ return void 0;
43246
+ }
43247
+ }
43248
+ function linkFailure(err, session, named) {
43249
+ if (!(err instanceof ApiError)) return err;
43250
+ const reason3 = extractApiErrorReason(err);
43251
+ const { label: label3 } = named;
43252
+ if (err.status === 409 && reason3 === CASE_LINK_VERSION_NOT_CURRENT_REASON) {
43253
+ const current = detailOf(err, "current_version_id");
43254
+ 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.`);
43255
+ }
43256
+ if (err.status === 400) {
43257
+ switch (reason3) {
43258
+ case CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON:
43259
+ return expected(`The case holds no official version ${named.id} this authorization may read.`);
43260
+ case CASE_LINK_OUTPUT_NOT_PRIOR_REASON:
43261
+ 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.`);
43262
+ case CASE_LINK_RECEIVED_UNKNOWN_REASON:
43263
+ return expected(`The case holds no received document ${named.id} this authorization may read.`);
43264
+ case CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON:
43265
+ return expected(`${named.id} is not of the document type the ${label3} asks for.`);
43266
+ case CASE_CLOSED_REASON:
43267
+ return expected(`Case ${session.connection.code} is closed: it takes no link.`);
43268
+ default:
43269
+ break;
43270
+ }
43271
+ }
43272
+ if (err.status === 403) return expected(`Your access to case ${session.connection.code} does not link its inputs: that takes Edit level.`);
43273
+ return caseCallFailure(err, session.connection, `The ${label3} was not found`);
43274
+ }
43275
+ function passageLines(text5) {
43276
+ const m = /^([1-9][0-9]*)(?:-([1-9][0-9]*))?$/.exec(text5);
43277
+ if (!m) throw expected("cite takes its lines as <start> or <start>-<end> (as 12-18), from 1.");
43278
+ const lines2 = { line_start: Number(m[1]), line_end: Number(m[2] ?? m[1]) };
43279
+ if (lines2.line_end < lines2.line_start) throw expected("cite takes its lines with the last at or after the first.");
43280
+ return lines2;
43281
+ }
43282
+ function passageSource(input, label3) {
43283
+ const state = inputLinkState(input);
43284
+ if (state.state === "unreadable") throw expected(`The ${label3} links a source not readable here: no passage of it can be cited with this authorization.`);
43285
+ if (state.state === "unknown") throw expected(`This server does not say what the ${label3} links: no passage can be cited from here.`);
43286
+ if (state.state !== "linked" && state.state !== "undecided") throw expected(`The ${label3} is not linked: link it first.`);
43287
+ const { source } = state;
43288
+ if (source.kind === "collection") return { document_id: source.document_id, version_id: source.version_id };
43289
+ return source.kind === "official_version" ? { official_version_id: source.official_version_id } : { received_id: source.received_id };
43290
+ }
43291
+ function citeFailure(err, session, named) {
43292
+ if (!(err instanceof ApiError)) return err;
43293
+ const reason3 = extractApiErrorReason(err);
43294
+ if (err.status === 409 && reason3 === CASE_PASSAGE_LINK_CHANGED_REASON) {
43295
+ return expected(`The ${named.label} links another source since it was read: read it again (\`wayai cases explain --phase ${named.folder}\`), then cite.`);
43296
+ }
43297
+ if (err.status === 400) {
43298
+ switch (reason3) {
43299
+ case CASE_PASSAGE_OUT_OF_RANGE_REASON:
43300
+ return expected(`Lines ${named.lines.line_start}-${named.lines.line_end} run past the last line of what the ${named.label} links.`);
43301
+ case CASE_PASSAGE_NO_TEXT_REASON:
43302
+ return expected(`What the ${named.label} links holds no text to cite (a file piece, or a version with none).`);
43303
+ case CASE_CLOSED_REASON:
43304
+ return expected(`Case ${session.connection.code} is closed: it takes no passage.`);
43305
+ default:
43306
+ break;
43307
+ }
43308
+ }
43309
+ if (err.status === 403) return expected(`Your access to case ${session.connection.code} does not cite passages: that takes Edit level.`);
43310
+ return caseCallFailure(err, session.connection, `The ${named.label} was not found`);
43311
+ }
43312
+ var one2, sourceWords;
43313
+ var init_case_inputs = __esm({
43314
+ "src/cases/case-inputs.ts"() {
43315
+ "use strict";
43316
+ init_case_records();
43317
+ init_case_collection_links();
43318
+ init_case_collection_citations();
43319
+ init_api_client();
43320
+ init_errors3();
43321
+ init_expected();
43322
+ init_terminal_output();
43323
+ init_utils();
43324
+ init_case_session();
43325
+ one2 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
43326
+ sourceWords = (source, folders) => {
43327
+ const folder = (phaseId) => one2(folders.get(phaseId) ?? phaseId);
43328
+ switch (source.kind) {
43329
+ case "collection":
43330
+ return `version "${one2(source.version_title)}" of document "${one2(source.document_title)}"`;
43331
+ case "official_version":
43332
+ return `version ${source.version} of output ${one2(source.output_code)} (phase ${folder(source.phase_id)}) [${source.official_version_id}]`;
43333
+ case "received":
43334
+ return `received document "${one2(source.title)}" (${one2(source.type)}), registered in ${folder(source.phase_id)} [${source.received_id}]`;
43335
+ }
43336
+ };
43337
+ }
43338
+ });
43339
+
43340
+ // ../../packages/core/dist/contracts/case-input-sources.js
43341
+ var init_case_input_sources = __esm({
43342
+ "../../packages/core/dist/contracts/case-input-sources.js"() {
43343
+ "use strict";
43344
+ init_chunk_S5FHM37X();
43345
+ init_chunk_U3L6QR6F();
43346
+ init_chunk_S7UAXLHJ();
43347
+ init_chunk_7TQYAKCB();
43348
+ init_chunk_VROZDNLV();
43349
+ init_chunk_733K4J4G();
43350
+ init_chunk_PFPADFUC();
43351
+ init_chunk_KWRHZBGU();
43352
+ init_chunk_3T3D7LTE();
43353
+ init_chunk_M2T55BV6();
43354
+ init_chunk_VYINA6YP();
43355
+ init_chunk_ZVXO3XL6();
43356
+ init_chunk_FBV7NLKO();
43357
+ init_chunk_WEXVYJ5H();
43358
+ init_chunk_HZ6CADSY();
43359
+ init_chunk_ICYO56QW();
43360
+ init_chunk_WFQDSQJK();
43361
+ init_chunk_ZTNFLGW5();
43362
+ }
43363
+ });
43364
+
42982
43365
  // ../../packages/core/dist/contracts/case-notes.js
42983
43366
  var init_case_notes = __esm({
42984
43367
  "../../packages/core/dist/contracts/case-notes.js"() {
@@ -43004,7 +43387,7 @@ var init_case_notes = __esm({
43004
43387
  var init_case_checks = __esm({
43005
43388
  "../../packages/core/dist/contracts/case-checks.js"() {
43006
43389
  "use strict";
43007
- init_chunk_RHXF6X2Y();
43390
+ init_chunk_XPOCPOMA();
43008
43391
  init_chunk_5Y2NNQHX();
43009
43392
  init_chunk_HZ6CADSY();
43010
43393
  }
@@ -43038,7 +43421,7 @@ function blockerLine(b, names) {
43038
43421
  case "task_pending":
43039
43422
  return `${names.task(b.case_task_id)} is open`;
43040
43423
  case "input_pending":
43041
- return `${names.input(b.input_id)} is neither linked nor dispensed`;
43424
+ return `${names.input(b.input_id)} is neither linked nor dispensed${names.inputHint(b.input_id)}`;
43042
43425
  case "agenda_group_pending":
43043
43426
  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`;
43044
43427
  case "task_dependency_pending":
@@ -43047,9 +43430,9 @@ function blockerLine(b, names) {
43047
43430
  return `something confidential is pending (${b.actor})`;
43048
43431
  }
43049
43432
  }
43050
- async function namesFor(session, detail, phaseIds) {
43433
+ async function namesFor(session, detail, phaseIds, opts = {}) {
43051
43434
  const names = new CaseNames(session, detail);
43052
- if (readsWork(detail)) for (const id of phaseIds) await names.readPhase(id);
43435
+ if (readsWork(detail)) for (const id of phaseIds) await names.readPhase(id, opts.agenda ?? true);
43053
43436
  return names;
43054
43437
  }
43055
43438
  function printPhasesView(detail, state) {
@@ -43079,13 +43462,13 @@ async function caseBrief(session, opts) {
43079
43462
  console.log(JSON.stringify({ case: detail, state, open_notes: notes }, null, 2));
43080
43463
  return;
43081
43464
  }
43082
- const head = `${detail.code}, ${one2(detail.type_name)} (version ${detail.version})${detail.confidential ? ", confidential" : ""}`;
43465
+ const head = `${detail.code}, ${one3(detail.type_name)} (version ${detail.version})${detail.confidential ? ", confidential" : ""}`;
43083
43466
  console.log(head);
43084
43467
  if (detail.closure) {
43085
- console.log(`Closed on ${detail.closure.closed_at}${detail.closure.outcome_name ? `: ${one2(detail.closure.outcome_name)}` : ""}.`);
43468
+ console.log(`Closed on ${detail.closure.closed_at}${detail.closure.outcome_name ? `: ${one3(detail.closure.outcome_name)}` : ""}.`);
43086
43469
  }
43087
- if (detail.owner?.display_name) console.log(`Owner: ${one2(detail.owner.display_name)}.`);
43088
- if (detail.parties?.length) console.log(`Parties: ${detail.parties.map((p) => `${one2(p.role)}: ${one2(p.name)}`).join("; ")}.`);
43470
+ if (detail.owner?.display_name) console.log(`Owner: ${one3(detail.owner.display_name)}.`);
43471
+ if (detail.parties?.length) console.log(`Parties: ${detail.parties.map((p) => `${one3(p.role)}: ${one3(p.name)}`).join("; ")}.`);
43089
43472
  if (state.view === "phases") {
43090
43473
  printPhasesView(detail, state);
43091
43474
  return;
@@ -43105,7 +43488,7 @@ async function caseBrief(session, opts) {
43105
43488
  console.log(`Open tasks (${open.length}):`);
43106
43489
  for (const t of open) {
43107
43490
  const st = taskState.get(t.case_task_id);
43108
- 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}]`);
43491
+ 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}]`);
43109
43492
  }
43110
43493
  }
43111
43494
  if (notes.length) {
@@ -43122,7 +43505,8 @@ async function caseExplain(session, opts) {
43122
43505
  return;
43123
43506
  }
43124
43507
  if (opts.json) {
43125
- console.log(JSON.stringify({ case: detail, state }, null, 2));
43508
+ const inputs2 = asked && readsWork(detail) ? (await namesFor(session, detail, [asked.phase_id], { agenda: false })).phaseInputs.get(asked.phase_id) ?? [] : null;
43509
+ console.log(JSON.stringify({ case: detail, state, ...inputs2 ? { inputs: inputs2.map(inputJson) } : {} }, null, 2));
43126
43510
  return;
43127
43511
  }
43128
43512
  const phases = asked ? state.phases.filter((p) => p.phase_id === asked.phase_id) : state.phases;
@@ -43145,7 +43529,7 @@ async function caseExplain(session, opts) {
43145
43529
  const shown4 = fullyNamed.has(p.phase_id) ? p.blockers : p.blockers.filter((b) => b.reason === "phase_dependency_pending" || b.reason === "phase_not_activated");
43146
43530
  for (const b of shown4) console.log(` - ${blockerLine(b, names)}`);
43147
43531
  const rest = p.blockers.length - shown4.length;
43148
- 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 ?? "")}\`)`);
43532
+ 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 ?? "")}\`)`);
43149
43533
  }
43150
43534
  const taskPhase = new Map((detail.tasks ?? []).map((t) => [t.case_task_id, t.phase_id]));
43151
43535
  const tasks = state.tasks.filter((t) => fullyNamed.has(taskPhase.get(t.case_task_id) ?? ""));
@@ -43153,12 +43537,19 @@ async function caseExplain(session, opts) {
43153
43537
  console.log("Open tasks:");
43154
43538
  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("; ")}`);
43155
43539
  }
43540
+ const inputs = asked ? names.phaseInputs.get(asked.phase_id) ?? [] : [];
43541
+ if (inputs.length) {
43542
+ console.log(`Inputs of ${asked.folder}:`);
43543
+ const folders = names.folders();
43544
+ for (const i of inputs) console.log(` ${inputLine(i, asked.folder, folders)}`);
43545
+ }
43156
43546
  }
43157
- function agentWork(b) {
43547
+ function agentWork(b, names) {
43158
43548
  switch (b.reason) {
43159
43549
  case "output_pending":
43160
43550
  return b.submission === null;
43161
43551
  case "input_pending":
43552
+ return names.inputOrigin(b.input_id) !== "collection";
43162
43553
  case "task_pending":
43163
43554
  case "publication_pending":
43164
43555
  return true;
@@ -43180,7 +43571,10 @@ async function caseNext(session, opts) {
43180
43571
  return;
43181
43572
  }
43182
43573
  const underWay = state.phases.filter((p) => p.status === "in_progress");
43183
- const notes = readsWork(detail) ? await openNotes(session) : [];
43574
+ const [notes, names] = await Promise.all([
43575
+ readsWork(detail) ? openNotes(session) : [],
43576
+ namesFor(session, detail, underWay.map((p) => p.phase_id), { agenda: !opts.json })
43577
+ ]);
43184
43578
  const yours = [];
43185
43579
  const others = [];
43186
43580
  const seen = /* @__PURE__ */ new Set();
@@ -43189,28 +43583,38 @@ async function caseNext(session, opts) {
43189
43583
  const key = blockerKey(b);
43190
43584
  if (key && seen.has(key)) continue;
43191
43585
  if (key) seen.add(key);
43192
- (agentWork(b) ? yours : others).push({ phase_id: p.phase_id, blocker: b });
43586
+ (agentWork(b, names) ? yours : others).push({ phase_id: p.phase_id, blocker: b });
43193
43587
  }
43194
43588
  }
43589
+ const folders = names.folders();
43590
+ const undecided = underWay.flatMap((p) => (names.phaseInputs.get(p.phase_id) ?? []).flatMap((input) => {
43591
+ const link = inputLinkState(input);
43592
+ if (link.state !== "undecided") return [];
43593
+ const folder = folders.get(p.phase_id) ?? "";
43594
+ return [{ phase_id: p.phase_id, input, ...undecidedWords(input, folder, link, folders) }];
43595
+ }));
43195
43596
  if (opts.json) {
43196
- console.log(JSON.stringify({ to_do: yours, waiting_on_others: others, open_notes: notes }, null, 2));
43597
+ const undecidedJson = undecided.map((u) => ({ phase_id: u.phase_id, ...inputJson(u.input), agent: u.agent }));
43598
+ console.log(JSON.stringify({ to_do: yours, waiting_on_others: others, undecided_inputs: undecidedJson, open_notes: notes }, null, 2));
43197
43599
  return;
43198
43600
  }
43199
- const names = await namesFor(session, detail, underWay.map((p) => p.phase_id));
43601
+ const undecidedLine = (u) => ` ${folders.get(u.phase_id) ?? ""}: ${names.input(u.input.id)} ${u.text}`;
43200
43602
  if (underWay.length === 0) console.log(`No phase of ${detail.code} is under way.`);
43201
- if (yours.length) {
43603
+ if (yours.length || undecided.some((u) => u.agent)) {
43202
43604
  console.log("To do:");
43203
43605
  for (const { phase_id, blocker } of yours) console.log(` ${names.phaseRow(phase_id)?.folder ?? ""}: ${blockerLine(blocker, names)}`);
43606
+ for (const u of undecided.filter((u2) => u2.agent)) console.log(undecidedLine(u));
43204
43607
  }
43205
43608
  if (notes.length) {
43206
43609
  console.log("Open pending items and next steps:");
43207
43610
  for (const n of notes) console.log(` ${noteLine(n)}`);
43208
43611
  }
43209
- if (others.length) {
43612
+ if (others.length || undecided.some((u) => !u.agent)) {
43210
43613
  console.log("Waiting on someone else:");
43211
43614
  for (const { phase_id, blocker } of others) console.log(` ${names.phaseRow(phase_id)?.folder ?? ""}: ${blockerLine(blocker, names)}`);
43615
+ for (const u of undecided.filter((u2) => !u2.agent)) console.log(undecidedLine(u));
43212
43616
  }
43213
- if (underWay.length && !yours.length && !notes.length && !others.length) console.log("Nothing is pending on the phases under way.");
43617
+ if (underWay.length && !yours.length && !notes.length && !others.length && !undecided.length) console.log("Nothing is pending on the phases under way.");
43214
43618
  }
43215
43619
  function clonePackageCheck(session) {
43216
43620
  const clone = findCaseClone(process.cwd());
@@ -43232,7 +43636,7 @@ async function caseCheck(session, opts) {
43232
43636
  const work = (await call2(session, () => session.api.getCasePhaseWork(session.connection, phase.phase_id))).data;
43233
43637
  const output = work.outputs.find((o) => o.code === opts.output);
43234
43638
  if (!output) {
43235
- throw expected(`Phase ${phase.folder} has no output ${JSON.stringify(sanitizeTerminalText(opts.output))}. Its outputs: ${work.outputs.map((o) => one2(o.code)).join(", ") || "none"}.`);
43639
+ throw expected(`Phase ${phase.folder} has no output ${JSON.stringify(sanitizeTerminalText(opts.output))}. Its outputs: ${work.outputs.map((o) => one3(o.code)).join(", ") || "none"}.`);
43236
43640
  }
43237
43641
  outputId = output.id;
43238
43642
  }
@@ -43248,13 +43652,13 @@ async function caseCheck(session, opts) {
43248
43652
  const warnings = checks.problems.length - errors;
43249
43653
  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"}.`);
43250
43654
  for (const p of checks.problems) {
43251
- const where = [p.output_code && one2(p.output_code), p.path && `${one2(p.path)}${p.line ? `:${p.line}` : ""}`].filter(Boolean).join(" ");
43252
- 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(", ");
43655
+ const where = [p.output_code && one3(p.output_code), p.path && `${one3(p.path)}${p.line ? `:${p.line}` : ""}`].filter(Boolean).join(" ");
43656
+ 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(", ");
43253
43657
  console.log(` ${p.severity} ${p.code}${where ? ` [${where}]` : ""}${what ? `: ${what}` : ""}`);
43254
43658
  }
43255
43659
  if (checks.truncated) console.log(" (more problems were found than one answer carries)");
43256
43660
  for (const c of checks.coverage) {
43257
- console.log(`Coverage of ${one2(c.output_code)}: ${c.ready} of ${c.total} items ready${c.dispensed ? `, ${c.dispensed} dispensed` : ""}.`);
43661
+ console.log(`Coverage of ${one3(c.output_code)}: ${c.ready} of ${c.total} items ready${c.dispensed ? `, ${c.dispensed} dispensed` : ""}.`);
43258
43662
  }
43259
43663
  if (pkg2) for (const line of packageCheckLines(pkg2, CASE_MIRROR_DIR)) console.log(line);
43260
43664
  }
@@ -43286,7 +43690,7 @@ async function caseDecisions(session, opts) {
43286
43690
  }
43287
43691
  }
43288
43692
  for (const r of results) {
43289
- const listed3 = r.rows.length ? `: ${r.rows.map((d) => one2(d.code)).join(", ")}` : ", with its header alone: no decision is approved yet";
43693
+ const listed3 = r.rows.length ? `: ${r.rows.map((d) => one3(d.code)).join(", ")}` : ", with its header alone: no decision is approved yet";
43290
43694
  console.log(`${r.rel} ${r.outcome === "written" ? "written" : "already up to date"}${listed3}.`);
43291
43695
  }
43292
43696
  }
@@ -43305,7 +43709,7 @@ async function caseNote(session, text5, opts) {
43305
43709
  async function caseNoteDone(session, noteId) {
43306
43710
  if (!UUID_RE3.test(noteId)) throw expected("note done takes a note's id, as `wayai cases next` shows it.");
43307
43711
  const note = (await call2(session, () => session.api.completeCaseNote(session.connection, noteId), `Note ${noteId} was not found`)).data;
43308
- console.log(`Done: ${one2(note.text)}`);
43712
+ console.log(`Done: ${one3(note.text)}`);
43309
43713
  }
43310
43714
  function sizeOf(file) {
43311
43715
  try {
@@ -43340,9 +43744,41 @@ async function caseReceivedAdd(session, file, opts) {
43340
43744
  { name, bytes },
43341
43745
  text5
43342
43746
  ))).data;
43343
- console.log(`${one2(received.title)} registered in ${phase.folder}/received/ of ${session.connection.code}: ${received.received_id}`);
43747
+ console.log(`${one3(received.title)} registered in ${phase.folder}/received/ of ${session.connection.code}: ${received.received_id}`);
43344
43748
  if (received.text_origin === "agent") console.log("Its text is marked as converted by an agent, for whoever reviews it.");
43345
43749
  }
43750
+ async function locateInput(session, inputName, phaseName) {
43751
+ const phase = findPhase(await loadCase(session), phaseName);
43752
+ const work = (await call2(session, () => session.api.getCasePhaseWork(session.connection, phase.phase_id))).data;
43753
+ const input = findInput(work, phase, inputName);
43754
+ return { phase, input, label: `input ${one3(input.key)} of ${phase.folder}` };
43755
+ }
43756
+ async function caseLink(session, inputName, opts) {
43757
+ const target = linkTarget(opts);
43758
+ const { phase, input, label: label3 } = await locateInput(session, inputName, opts.phase);
43759
+ const mismatch = linkMismatch(input, label3, target);
43760
+ if (mismatch) throw expected(mismatch);
43761
+ const [kind, id] = "official_version_id" in target ? ["official version", target.official_version_id] : ["received document", target.received_id];
43762
+ let linked;
43763
+ try {
43764
+ linked = (await session.api.linkCaseInput(session.connection, input.id, target)).data;
43765
+ } catch (err) {
43766
+ throw linkFailure(err, session, { label: label3, key: input.key, folder: phase.folder, origin: input.origin, id });
43767
+ }
43768
+ console.log(`Linked the ${label3} to ${kind} ${id} (linked since ${linked.linked_at}).`);
43769
+ }
43770
+ async function caseCite(session, inputName, lines2, opts) {
43771
+ const { phase, input, label: label3 } = await locateInput(session, inputName, opts.phase);
43772
+ const parsed = citeCaseInputPassageBody.safeParse({ ...passageSource(input, label3), ...lines2 });
43773
+ if (!parsed.success) throw expected(`The passage is refused: ${parsed.error.issues[0]?.message ?? "not of its shape"}.`);
43774
+ let passage;
43775
+ try {
43776
+ passage = (await session.api.citeCaseInputPassage(session.connection, input.id, parsed.data)).data;
43777
+ } catch (err) {
43778
+ throw citeFailure(err, session, { label: label3, folder: phase.folder, lines: lines2 });
43779
+ }
43780
+ console.log(`Cited lines ${passage.line_start}-${passage.line_end} of what the ${label3} links (SHA-256 ${passage.passage_sha}): ${passage.passage_id}`);
43781
+ }
43346
43782
  function markedThroughout(work) {
43347
43783
  const rows = [...work.inputs, ...work.items, ...work.items.flatMap((i) => i.item_links.depends_on)];
43348
43784
  return rows.every((row) => typeof row.confidential === "boolean");
@@ -43376,7 +43812,7 @@ async function caseSkeleton(session, clone, opts) {
43376
43812
  const workItems = opts.confidential ? work.items : work.items.filter((i) => i.confidential !== true);
43377
43813
  const outputs = opts.output === void 0 ? work.outputs : work.outputs.filter((o) => o.code === opts.output);
43378
43814
  if (opts.output !== void 0 && outputs.length === 0) {
43379
- throw expected(`Phase ${phase.folder} has no output ${JSON.stringify(sanitizeTerminalText(opts.output))}. Its outputs: ${work.outputs.map((o) => one2(o.code)).join(", ") || "none"}.`);
43815
+ throw expected(`Phase ${phase.folder} has no output ${JSON.stringify(sanitizeTerminalText(opts.output))}. Its outputs: ${work.outputs.map((o) => one3(o.code)).join(", ") || "none"}.`);
43380
43816
  }
43381
43817
  const plans = await withMirrorLock(clone.root, async () => {
43382
43818
  const pkg2 = deliveredPackage(clone.root, mirror);
@@ -43391,7 +43827,7 @@ async function caseSkeleton(session, clone, opts) {
43391
43827
  };
43392
43828
  if (!CASE_PHASE_FOLDER_PATTERN.test(phase.folder)) problems2.push(`the phase's folder ${JSON.stringify(sanitizeTerminalText(phase.folder))} is no phase folder`);
43393
43829
  const planned = outputs.map((output) => {
43394
- const code2 = one2(output.code);
43830
+ const code2 = one3(output.code);
43395
43831
  const bad = output.file_paths.filter((p) => !casePath2(p.endsWith("/") ? `${p}${CASE_COMPOSED_COVER}` : p, false));
43396
43832
  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`);
43397
43833
  if (bad.length) return null;
@@ -43412,7 +43848,7 @@ async function caseSkeleton(session, clone, opts) {
43412
43848
  const rel = `templates/${phase.folder}/${item.code}.md`;
43413
43849
  const file = pkg2.file(rel);
43414
43850
  if (file.state !== "unlisted" && file.confidential && !opts.confidential) {
43415
- problems2.push(`item ${one2(item.code)} of output ${code2}: its template is confidential, used only with --confidential`);
43851
+ problems2.push(`item ${one3(item.code)} of output ${code2}: its template is confidential, used only with --confidential`);
43416
43852
  } else if (file.state === "ok") {
43417
43853
  template = file.bytes.toString("utf-8");
43418
43854
  } else if (file.state !== "unlisted") {
@@ -43437,7 +43873,7 @@ async function caseSkeleton(session, clone, opts) {
43437
43873
  }
43438
43874
  return planned.filter((p) => p !== null);
43439
43875
  });
43440
- console.log(`Skeleton of ${phase.folder}${opts.output ? `, output ${one2(opts.output)}` : ""}:`);
43876
+ console.log(`Skeleton of ${phase.folder}${opts.output ? `, output ${one3(opts.output)}` : ""}:`);
43441
43877
  let wrote = false;
43442
43878
  for (const plan of plans) {
43443
43879
  if ("skipped" in plan) {
@@ -43454,13 +43890,13 @@ async function caseSkeleton(session, clone, opts) {
43454
43890
  const chapters = plan.path.endsWith("/") ? `, in ${written.length - 1} chapter${written.length === 2 ? "" : "s"}` : "";
43455
43891
  console.log(` ${plan.code}: wrote ${sanitizeTerminalText(plan.path)}, ${plan.items} item${plan.items === 1 ? "" : "s"}${chapters}, ${fills} to fill.`);
43456
43892
  for (const f of plan.files.filter((f2) => !written.includes(f2))) console.log(` ${sanitizeTerminalText(f.rel)} appeared while this ran: left as it is.`);
43457
- if (plan.missing.length) console.log(` Attributes the case holds no value for, left as {{fill: \u2026}}: ${plan.missing.map(one2).join(", ")}.`);
43893
+ if (plan.missing.length) console.log(` Attributes the case holds no value for, left as {{fill: \u2026}}: ${plan.missing.map(one3).join(", ")}.`);
43458
43894
  }
43459
43895
  if (wrote) console.log("Replace each {{fill: \u2026}} with its text, then push.");
43460
43896
  if (!opts.confidential) console.log(`
43461
43897
  ${SKELETON_CONFIDENTIAL_NOTICE}`);
43462
43898
  }
43463
- 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;
43899
+ 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;
43464
43900
  var init_case_work = __esm({
43465
43901
  "src/cases/case-work.ts"() {
43466
43902
  "use strict";
@@ -43473,6 +43909,8 @@ var init_case_work = __esm({
43473
43909
  init_case_mirror();
43474
43910
  init_case_package();
43475
43911
  init_case_skeleton();
43912
+ init_case_inputs();
43913
+ init_case_input_sources();
43476
43914
  init_case_item_reader();
43477
43915
  init_case_file_paths();
43478
43916
  init_case_types();
@@ -43482,32 +43920,36 @@ var init_case_work = __esm({
43482
43920
  NOTE_PAGES_READ = 3;
43483
43921
  NOTES_PAGE = CASE_NOTES_PAGE_MAX;
43484
43922
  AGENDA_PAGES_READ2 = 5;
43485
- one2 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
43923
+ one3 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
43486
43924
  loadCase = async (s) => (await call2(s, () => s.api.getCase(s.connection))).data;
43487
43925
  loadState = async (s) => (await call2(s, () => s.api.getCaseState(s.connection))).data;
43488
- phaseLabel = (p) => `${one2(p.folder)} (${one2(p.name)})`;
43926
+ phaseLabel = (p) => `${one3(p.folder)} (${one3(p.name)})`;
43489
43927
  statusWords = (status) => status.replaceAll("_", " ");
43490
43928
  CaseNames = class {
43491
43929
  constructor(session, detail) {
43492
43930
  this.session = session;
43493
43931
  this.phases = new Map(detail.phases.map((p) => [p.phase_id, p]));
43494
- this.tasks = new Map((detail.tasks ?? []).map((t) => [t.case_task_id, one2(t.name)]));
43932
+ this.tasks = new Map((detail.tasks ?? []).map((t) => [t.case_task_id, one3(t.name)]));
43495
43933
  }
43496
43934
  phases;
43497
43935
  tasks;
43498
43936
  outputs = /* @__PURE__ */ new Map();
43499
43937
  inputs = /* @__PURE__ */ new Map();
43500
43938
  groups = /* @__PURE__ */ new Map();
43501
- /** Read one phase's outputs, inputs and agenda groups, to name them. */
43502
- async readPhase(phaseId) {
43939
+ /** Each phase read's inputs, in their order. */
43940
+ phaseInputs = /* @__PURE__ */ new Map();
43941
+ /** Read one phase's outputs and inputs, and (unless `agenda` is false) its agenda groups, to name them. */
43942
+ async readPhase(phaseId, agenda = true) {
43503
43943
  const s = this.session;
43504
43944
  const work = (await call2(s, () => s.api.getCasePhaseWork(s.connection, phaseId))).data;
43505
- for (const o of work.outputs) this.outputs.set(o.id, `${one2(o.code)} (${one2(o.document_type)})`);
43506
- for (const i of work.inputs) this.inputs.set(i.id, `${one2(i.key)} (${one2(i.name)})`);
43945
+ for (const o of work.outputs) this.outputs.set(o.id, `${one3(o.code)} (${one3(o.document_type)})`);
43946
+ const folder = this.phases.get(phaseId)?.folder ?? "";
43947
+ for (const i of work.inputs) this.inputs.set(i.id, { label: `${one3(i.key)} (${one3(i.name)})`, input: i, folder });
43948
+ this.phaseInputs.set(phaseId, work.inputs);
43507
43949
  let cursor;
43508
- for (let page = 0; page < AGENDA_PAGES_READ2; page++) {
43950
+ for (let page = 0; agenda && page < AGENDA_PAGES_READ2; page++) {
43509
43951
  const { groups, next_cursor } = (await call2(s, () => s.api.getCaseAgenda(s.connection, phaseId, cursor))).data;
43510
- for (const g of groups) this.groups.set(g.agenda_group_id, `${one2(g.code)} (${one2(g.name)})`);
43952
+ for (const g of groups) this.groups.set(g.agenda_group_id, `${one3(g.code)} (${one3(g.name)})`);
43511
43953
  if (!next_cursor) break;
43512
43954
  cursor = next_cursor;
43513
43955
  }
@@ -43530,7 +43972,20 @@ var init_case_work = __esm({
43530
43972
  return this.outputs.has(id) ? `output ${this.outputs.get(id)}` : "an output";
43531
43973
  }
43532
43974
  input(id) {
43533
- return this.inputs.has(id) ? `input ${this.inputs.get(id)}` : "an input";
43975
+ return this.inputs.has(id) ? `input ${this.inputs.get(id).label}` : "an input";
43976
+ }
43977
+ /** How an unlinked input is linked (`./case-inputs.ts` `linkHint`), after a colon; nothing for one not read. */
43978
+ inputHint(id) {
43979
+ const named = this.inputs.get(id);
43980
+ return named ? `: ${linkHint(named.input.key, named.folder, named.input.origin)}` : "";
43981
+ }
43982
+ /** An input's origin, or undefined for one not read. */
43983
+ inputOrigin(id) {
43984
+ return this.inputs.get(id)?.input.origin;
43985
+ }
43986
+ /** Each phase's folder, by phase id. */
43987
+ folders() {
43988
+ return new Map([...this.phases].map(([id, p]) => [id, p.folder]));
43534
43989
  }
43535
43990
  group(id) {
43536
43991
  return this.groups.has(id) ? `agenda group ${this.groups.get(id)}` : "an agenda group";
@@ -43544,7 +43999,8 @@ var init_case_work = __esm({
43544
43999
  };
43545
44000
  readsWork = (detail) => detail.access.capabilities.includes("view_work");
43546
44001
  PHASES_VIEW_NOTE = "You see only the phases' status of this case: its work is not yours to read here.";
43547
- noteLine = (n) => `${n.kind === "pending" ? "pending" : "next step"}: ${one2(n.text)} [${n.note_id}]`;
44002
+ noteLine = (n) => `${n.kind === "pending" ? "pending" : "next step"}: ${one3(n.text)} [${n.note_id}]`;
44003
+ inputJson = (i) => ({ input_id: i.id, key: i.key, origin: i.origin, required: i.required, link: inputLinkState(i) });
43548
44004
  blockerKey = (b) => {
43549
44005
  switch (b.reason) {
43550
44006
  case "output_pending":
@@ -44071,11 +44527,11 @@ async function caseLog(selector, opts) {
44071
44527
  }
44072
44528
  if (shown4.length === 0) console.log(`Case ${safe7(detail.code)} has no revision you read here.`);
44073
44529
  for (const r of shown4) {
44074
- const author = r.author?.display_name ? one3(r.author.display_name) : "a person no longer named";
44530
+ const author = r.author?.display_name ? one4(r.author.display_name) : "a person no longer named";
44075
44531
  console.log(`revision ${r.revision_id} ${r.created_at} ${author} (${r.channel})`);
44076
- if (r.message !== null) console.log(` ${one3(r.message)}`);
44532
+ if (r.message !== null) console.log(` ${one4(r.message)}`);
44077
44533
  else console.log(hideMessages ? " (message not shown without --confidential)" : " (message hidden)");
44078
- if (r.session) console.log(` session: ${one3(r.session)}`);
44534
+ if (r.session) console.log(` session: ${one4(r.session)}`);
44079
44535
  for (const e of r.entries) console.log(` ${safe7(e.path)}${e.sha === null ? " (removed)" : ""}`);
44080
44536
  }
44081
44537
  if (more && shown4.length > 0) console.log(`
@@ -44083,7 +44539,7 @@ Older revisions follow: --limit ${Math.min(LOG_MAX, limit * 2)} shows more.`);
44083
44539
  if (!opts.confidential) console.log(`
44084
44540
  ${CONFIDENTIAL_NOTICE}`);
44085
44541
  }
44086
- 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;
44542
+ 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;
44087
44543
  var init_case_files2 = __esm({
44088
44544
  "src/cases/case-files.ts"() {
44089
44545
  "use strict";
@@ -44113,7 +44569,7 @@ var init_case_files2 = __esm({
44113
44569
  PART_OVERHEAD_BYTES = 512;
44114
44570
  CONFIDENTIAL_NOTICE = "Confidential files are left out unless you pass --confidential.";
44115
44571
  safe7 = (text5) => sanitizeTerminalText(text5);
44116
- one3 = (text5) => sanitizeTerminalText(text5).replace(/\s*\n\s*/g, " ");
44572
+ one4 = (text5) => sanitizeTerminalText(text5).replace(/\s*\n\s*/g, " ");
44117
44573
  CaseCalls = class {
44118
44574
  constructor(session) {
44119
44575
  this.session = session;
@@ -44220,7 +44676,7 @@ async function requireConfidential(session) {
44220
44676
  const detail = (await call3(session, () => session.api.getCase(session.connection))).data;
44221
44677
  if (!detail.access.capabilities.includes("read_confidential")) {
44222
44678
  throw expected(
44223
- `This machine's authorization on case ${one4(detail.code)} does not hold the Confidential right, so --confidential reads nothing more. Run it without --confidential.`
44679
+ `This machine's authorization on case ${one5(detail.code)} does not hold the Confidential right, so --confidential reads nothing more. Run it without --confidential.`
44224
44680
  );
44225
44681
  }
44226
44682
  }
@@ -44233,7 +44689,7 @@ function block(label3, text5, none) {
44233
44689
  for (const line of sanitizeTerminalText(text5).split("\n")) console.log(` | ${line}`);
44234
44690
  }
44235
44691
  function verdictCommand(connection, graph, pair) {
44236
- 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>"`;
44692
+ 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>"`;
44237
44693
  }
44238
44694
  async function caseReview(session, opts) {
44239
44695
  if (opts.confidential) await requireConfidential(session);
@@ -44256,15 +44712,15 @@ function printReview(connection, graph) {
44256
44712
  notice();
44257
44713
  return;
44258
44714
  }
44259
- console.log(`Review of case ${code2} at revision ${one4(graph.revision_id)}${graph.confidential ? ", with confidential content" : ""}.`);
44260
- 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.");
44715
+ console.log(`Review of case ${code2} at revision ${one5(graph.revision_id)}${graph.confidential ? ", with confidential content" : ""}.`);
44716
+ 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.");
44261
44717
  const titles = new Map(graph.items.map((item) => [item.key, item.title]));
44262
44718
  if (graph.items.length) {
44263
44719
  console.log(`
44264
44720
  Changed items (${graph.items.length}):`);
44265
44721
  for (const item of graph.items) {
44266
- 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)}` : ""}`);
44267
- if (item.causes.length) console.log(` because: ${item.causes.map(one4).join("; ")}`);
44722
+ 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)}` : ""}`);
44723
+ if (item.causes.length) console.log(` because: ${item.causes.map(one5).join("; ")}`);
44268
44724
  block("before", item.before, "not there at its base");
44269
44725
  block("now", item.text, "removed");
44270
44726
  }
@@ -44274,8 +44730,8 @@ Changed items (${graph.items.length}):`);
44274
44730
  Pairs awaiting a verdict (${graph.pairs.length}):`);
44275
44731
  for (const pair of graph.pairs) {
44276
44732
  const source = titles.get(pair.source);
44277
- 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)}`);
44278
- if (pair.reasons.length) console.log(` connected: ${pair.reasons.map(one4).join("; ")}`);
44733
+ 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)}`);
44734
+ if (pair.reasons.length) console.log(` connected: ${pair.reasons.map(one5).join("; ")}`);
44279
44735
  console.log(` ${verdictCommand(connection, graph, pair)}`);
44280
44736
  }
44281
44737
  }
@@ -44283,16 +44739,16 @@ Pairs awaiting a verdict (${graph.pairs.length}):`);
44283
44739
  console.log(`
44284
44740
  Waiting for a change (${graph.waiting.length}):`);
44285
44741
  for (const w of graph.waiting) {
44286
- console.log(` ${one4(w.source)} \u2192 ${one4(w.neighbor)} (round ${w.round}): needs a change: ${one4(w.reason)}`);
44287
- console.log(` waits until ${one4(w.neighbor)} changes`);
44742
+ console.log(` ${one5(w.source)} \u2192 ${one5(w.neighbor)} (round ${w.round}): needs a change: ${one5(w.reason)}`);
44743
+ console.log(` waits until ${one5(w.neighbor)} changes`);
44288
44744
  }
44289
44745
  }
44290
44746
  if (graph.stopped.length) {
44291
44747
  console.log(`
44292
44748
  Stopped chains (${graph.stopped.length}): each took more than ${CASE_REVIEW_ROUNDS_MAX} rounds, so it takes no verdict.`);
44293
44749
  for (const s of graph.stopped) {
44294
- const waiting = s.waiting_sources.length ? `; waiting on it: ${s.waiting_sources.map(one4).join(", ")}` : "";
44295
- console.log(` ${one4(s.key)}, "${one4(s.title)}" (round ${s.round})${s.base_revision_id ? `, since revision ${one4(s.base_revision_id)}` : ""}${waiting}`);
44750
+ const waiting = s.waiting_sources.length ? `; waiting on it: ${s.waiting_sources.map(one5).join(", ")}` : "";
44751
+ console.log(` ${one5(s.key)}, "${one5(s.title)}" (round ${s.round})${s.base_revision_id ? `, since revision ${one5(s.base_revision_id)}` : ""}${waiting}`);
44296
44752
  }
44297
44753
  console.log(` ${WEB_ONLY_NOTICE}`);
44298
44754
  }
@@ -44301,8 +44757,8 @@ Stopped chains (${graph.stopped.length}): each took more than ${CASE_REVIEW_ROUN
44301
44757
  console.log(`
44302
44758
  For a person to look at (${warnings.length}):`);
44303
44759
  for (const w of warnings) {
44304
- const where = [w.path && one4(w.path), w.subject && one4(w.subject)].filter(Boolean).join(": ");
44305
- console.log(` ${WARNINGS[w.code] ?? one4(w.code)}${where ? ` [${where}]` : ""}`);
44760
+ const where = [w.path && one5(w.path), w.subject && one5(w.subject)].filter(Boolean).join(": ");
44761
+ console.log(` ${WARNINGS[w.code] ?? one5(w.code)}${where ? ` [${where}]` : ""}`);
44306
44762
  }
44307
44763
  }
44308
44764
  if (!graph.items.length && !graph.pairs.length && !graph.waiting.length && !graph.stopped.length) console.log("Nothing awaits review.");
@@ -44349,12 +44805,12 @@ async function caseReviewVerdict(session, body, opts) {
44349
44805
  console.log(JSON.stringify(review, null, 2));
44350
44806
  return;
44351
44807
  }
44352
- 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}`);
44808
+ 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}`);
44353
44809
  if (review.verdict === "needs_change") {
44354
- console.log(`The pair waits until ${one4(review.neighbor)} changes: change it, push, then read the review again.`);
44810
+ console.log(`The pair waits until ${one5(review.neighbor)} changes: change it, push, then read the review again.`);
44355
44811
  }
44356
44812
  }
44357
- var VERDICTS, WEB_ONLY_NOTICE, one4, WARNINGS;
44813
+ var VERDICTS, WEB_ONLY_NOTICE, one5, WARNINGS;
44358
44814
  var init_case_review2 = __esm({
44359
44815
  "src/cases/case-review.ts"() {
44360
44816
  "use strict";
@@ -44367,7 +44823,7 @@ var init_case_review2 = __esm({
44367
44823
  init_case_review();
44368
44824
  VERDICTS = recordCaseItemReviewBody.shape.verdict.options;
44369
44825
  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.";
44370
- one4 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
44826
+ one5 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
44371
44827
  WARNINGS = {
44372
44828
  outside_item: "text outside any item",
44373
44829
  new_document_outside_item: "a new document with text outside any item",
@@ -44547,6 +45003,22 @@ async function casesCommand(args2) {
44547
45003
  confidential: values.confidential === true
44548
45004
  });
44549
45005
  }
45006
+ case "link": {
45007
+ if (operands.length !== 1) throw usageError4("link takes one <input>: its key, as `wayai cases explain --phase <folder>` names it.");
45008
+ if (values.phase === void 0) throw usageError4("link takes --phase <folder>.");
45009
+ linkTarget({ officialVersion: values["official-version"], received: values.received });
45010
+ return caseLink(await openCaseSession(selector), operands[0], {
45011
+ phase: values.phase,
45012
+ officialVersion: values["official-version"],
45013
+ received: values.received
45014
+ });
45015
+ }
45016
+ case "cite": {
45017
+ if (operands.length !== 2) throw usageError4("cite takes <input> and its lines, as <start> or <start>-<end>.");
45018
+ if (values.phase === void 0) throw usageError4("cite takes --phase <folder>.");
45019
+ const lines2 = passageLines(operands[1]);
45020
+ return caseCite(await openCaseSession(selector), operands[0], lines2, { phase: values.phase });
45021
+ }
44550
45022
  default:
44551
45023
  throw usageError4(`Unknown subcommand ${JSON.stringify(sanitizeTerminalText(name))}.`);
44552
45024
  }
@@ -44730,6 +45202,7 @@ var init_cases = __esm({
44730
45202
  init_web_origin();
44731
45203
  init_case_session();
44732
45204
  init_case_work();
45205
+ init_case_inputs();
44733
45206
  init_case_files2();
44734
45207
  init_case_mirror();
44735
45208
  init_case_review2();
@@ -44774,6 +45247,9 @@ Usage:
44774
45247
  wayai cases note done <note_id>
44775
45248
  wayai cases received add <file> --text <markdown file> --phase <folder> --type <type>
44776
45249
  [--title <title>] [--confidential]
45250
+ wayai cases link <input> --phase <folder>
45251
+ --official-version <official_version_id> | --received <received_id>
45252
+ wayai cases cite <input> <start>[-<end>] --phase <folder>
44777
45253
 
44778
45254
  connect Ask to connect this machine to the case, wait while you approve it
44779
45255
  in the WayAI web app, then keep the case's token in this machine's
@@ -44837,9 +45313,11 @@ review verdict Record consistent or needs_change on one pair, with a reason,
44837
45313
  brief The case at a glance: status, phases under way, deadlines, open
44838
45314
  tasks, open pending items and next steps.
44839
45315
  next What to do next on the phases under way, then what waits on
44840
- someone else.
45316
+ someone else: an input to link (with the command that links it),
45317
+ and a linked one whose version a newer one replaced.
44841
45318
  explain Why each phase and task is not done, and who can move it. --phase
44842
- names everything holding one phase.
45319
+ names everything holding one phase, and each of its inputs'
45320
+ links.
44843
45321
  check A delivery's checks over the case's files as WayAI holds them:
44844
45322
  a joint phase's, or one output's (--output). Inside a clone, it
44845
45323
  also compares the case's package in the mirror with the published
@@ -44869,6 +45347,15 @@ note done Mark a pending item or next step done.
44869
45347
  received add Register a document a party sent, in one phase, with its
44870
45348
  Markdown text, read from the file --text names. --confidential registers it as
44871
45349
  confidential, if the case lets you write one.
45350
+ link Link an input of one phase (its key, as explain --phase names it):
45351
+ one of origin previous_output to an earlier phase's current
45352
+ official version (--official-version), one of origin received to
45353
+ a received document of the case (--received; its id is in its
45354
+ files' names under a phase's received/). A collection input is
45355
+ linked in the web app.
45356
+ cite Cite a passage of what an input links now, by its lines (as
45357
+ 12-18, numbered as the mirror's inputs/ texts number them): the
45358
+ case hashes them. Any origin.
44872
45359
 
44873
45360
  The type commands are a space administrator's, with your own sign-in
44874
45361
  (\`wayai login\`), never a case token: they write and read a case type as
@@ -44934,7 +45421,9 @@ need it.
44934
45421
  "source-hash": { type: "string" },
44935
45422
  "neighbor-hash": { type: "string" },
44936
45423
  "mark-confidential": { type: "boolean" },
44937
- "mirror-only": { type: "boolean" }
45424
+ "mirror-only": { type: "boolean" },
45425
+ "official-version": { type: "string" },
45426
+ received: { type: "string" }
44938
45427
  };
44939
45428
  SELECT = ["case", "org", "space"];
44940
45429
  ADMITS = {
@@ -44950,6 +45439,8 @@ need it.
44950
45439
  note: [...SELECT, "kind", "phase", "task", "origin"],
44951
45440
  "note done": SELECT,
44952
45441
  "received add": [...SELECT, "text", "phase", "type", "title", "confidential"],
45442
+ link: [...SELECT, "phase", "official-version", "received"],
45443
+ cite: [...SELECT, "phase"],
44953
45444
  clone: [...SELECT, "dir", "confidential"],
44954
45445
  // A clone names its case: pull and push take the clone (--dir), never a case.
44955
45446
  pull: ["dir", "overwrite", "yes", "confidential", "mirror-only"],
@@ -45174,51 +45665,51 @@ function partyLine(party) {
45174
45665
  }
45175
45666
  function personsLines(data) {
45176
45667
  if (!data.persons) return [];
45177
- const lines = ["", "Persons each call is for (matched on record types with person entries):"];
45668
+ const lines2 = ["", "Persons each call is for (matched on record types with person entries):"];
45178
45669
  for (const persons2 of data.persons) {
45179
45670
  const audience = persons2.audience === REKOR_PERSON_AUDIENCE_STAFF ? "a call for team members" : "customer-facing";
45180
- lines.push(` ${TURN_NAMES[persons2.turn]}: ${audience}${persons2.full_reach ? ", full reach" : ""}`);
45671
+ lines2.push(` ${TURN_NAMES[persons2.turn]}: ${audience}${persons2.full_reach ? ", full reach" : ""}`);
45181
45672
  if (persons2.parties.length === 0) {
45182
- 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");
45673
+ 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");
45183
45674
  }
45184
- for (const party of persons2.parties) lines.push(` ${partyLine(party)}`);
45675
+ for (const party of persons2.parties) lines2.push(` ${partyLine(party)}`);
45185
45676
  }
45186
- 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.");
45187
- return lines;
45677
+ 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.");
45678
+ return lines2;
45188
45679
  }
45189
45680
  function formatExplanation(data) {
45190
- const lines = [];
45681
+ const lines2 = [];
45191
45682
  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"}`;
45192
- lines.push(`Hub ${text4(data.hub_id)}, agent ${text4(data.agent_id)}, ${who}`);
45193
- if (data.values_hub_id === null) lines.push("This preview hub was never published: it has no hub values, so it reaches nothing.");
45194
- else if (data.values_hub_id !== data.hub_id) lines.push(`Hub values are those of its production hub ${text4(data.values_hub_id)}.`);
45683
+ lines2.push(`Hub ${text4(data.hub_id)}, agent ${text4(data.agent_id)}, ${who}`);
45684
+ if (data.values_hub_id === null) lines2.push("This preview hub was never published: it has no hub values, so it reaches nothing.");
45685
+ else if (data.values_hub_id !== data.hub_id) lines2.push(`Hub values are those of its production hub ${text4(data.values_hub_id)}.`);
45195
45686
  if (data.customer_only) {
45196
- 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.");
45687
+ 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.");
45197
45688
  }
45198
45689
  if (data.conversations_reach_nothing) {
45199
- 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.");
45690
+ 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.");
45200
45691
  }
45201
- lines.push("", "Layers, intersected in order:");
45692
+ lines2.push("", "Layers, intersected in order:");
45202
45693
  const width = Math.max(...data.layers.map((layer) => LAYER_NAMES[layer.layer].length));
45203
45694
  for (const layer of data.layers) {
45204
45695
  const [first, ...rest] = layerLines(layer.values);
45205
- lines.push(` ${LAYER_NAMES[layer.layer].padEnd(width)} ${first}`);
45206
- for (const line of rest) lines.push(` ${"".padEnd(width)} ${line}`);
45696
+ lines2.push(` ${LAYER_NAMES[layer.layer].padEnd(width)} ${first}`);
45697
+ for (const line of rest) lines2.push(` ${"".padEnd(width)} ${line}`);
45207
45698
  }
45208
- lines.push("", "Effective set:");
45209
- if (data.dimensions.length === 0) lines.push(" no dimension: the set reaches nothing on any scoped record type");
45699
+ lines2.push("", "Effective set:");
45700
+ if (data.dimensions.length === 0) lines2.push(" no dimension: the set reaches nothing on any scoped record type");
45210
45701
  for (const dimension of data.dimensions) {
45211
- lines.push(` ${text4(dimension.dimension_id)}: read ${list(dimension.read)}; write ${list(dimension.write)}`);
45702
+ lines2.push(` ${text4(dimension.dimension_id)}: read ${list(dimension.read)}; write ${list(dimension.write)}`);
45212
45703
  for (const removal of dimension.read_removed) {
45213
- lines.push(` ${text4(removal.value_id)} not read: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
45704
+ lines2.push(` ${text4(removal.value_id)} not read: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
45214
45705
  }
45215
45706
  for (const removal of dimension.write_removed) {
45216
- lines.push(` ${text4(removal.value_id)} read, not written: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
45707
+ lines2.push(` ${text4(removal.value_id)} read, not written: removed by ${removal.layers.map((layer) => LAYER_NAMES[layer]).join(", ")}`);
45217
45708
  }
45218
45709
  }
45219
- lines.push("", "This set filters records only on record types a base enforces (x-access in enforce mode).");
45220
- lines.push(...personsLines(data));
45221
- return lines;
45710
+ lines2.push("", "This set filters records only on record types a base enforces (x-access in enforce mode).");
45711
+ lines2.push(...personsLines(data));
45712
+ return lines2;
45222
45713
  }
45223
45714
  function failure3(err) {
45224
45715
  if (err instanceof ApiError && err.isExpected) return expected(sanitizeTerminalText(extractApiMessage(err)));
@@ -48367,17 +48858,17 @@ function formatClientVersion(status) {
48367
48858
  return withSkill.length <= 64 ? withSkill : cli.slice(0, 64);
48368
48859
  }
48369
48860
  function buildStaleToolingWarning(status) {
48370
- const lines = [];
48861
+ const lines2 = [];
48371
48862
  if (status.cli.behind) {
48372
- lines.push(` CLI ${status.cli.current} \u2192 ${status.cli.latest} (run: wayai update)`);
48863
+ lines2.push(` CLI ${status.cli.current} \u2192 ${status.cli.latest} (run: wayai update)`);
48373
48864
  }
48374
48865
  if (status.skill.behind) {
48375
- lines.push(` Skill ${status.skill.current} \u2192 ${status.skill.latest} (run: npx skills add wayai-pro/wayai-skill -y)`);
48866
+ lines2.push(` Skill ${status.skill.current} \u2192 ${status.skill.latest} (run: npx skills add wayai-pro/wayai-skill -y)`);
48376
48867
  }
48377
- if (lines.length === 0) return null;
48868
+ if (lines2.length === 0) return null;
48378
48869
  return [
48379
48870
  "Your WayAI tooling is behind the latest release:",
48380
- ...lines,
48871
+ ...lines2,
48381
48872
  "",
48382
48873
  "A stale CLI or skill is the most common cause of a false bug report \u2014 the issue may",
48383
48874
  "already be fixed upstream. Update, then reproduce before reporting."