@wayai/cli 0.3.352 → 0.3.354

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
@@ -6780,7 +6780,7 @@ var init_chunk_5FO3GNKP = __esm({
6780
6780
  }
6781
6781
  });
6782
6782
 
6783
- // ../../packages/core/dist/chunk-7LULTR3U.js
6783
+ // ../../packages/core/dist/chunk-AUD5MVHU.js
6784
6784
  function matchPath(pattern, path55) {
6785
6785
  const pathSegments2 = path55.replace(/\/$/, "").split("/");
6786
6786
  const isPrefix = pattern.endsWith("/*");
@@ -6809,8 +6809,8 @@ function getEndpointConfig(path55) {
6809
6809
  return { tier: "STANDARD" };
6810
6810
  }
6811
6811
  var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
6812
- var init_chunk_7LULTR3U = __esm({
6813
- "../../packages/core/dist/chunk-7LULTR3U.js"() {
6812
+ var init_chunk_AUD5MVHU = __esm({
6813
+ "../../packages/core/dist/chunk-AUD5MVHU.js"() {
6814
6814
  "use strict";
6815
6815
  init_chunk_5FO3GNKP();
6816
6816
  ENDPOINT_CONFIGS = {
@@ -7266,7 +7266,7 @@ var init_chunk_7LULTR3U = __esm({
7266
7266
  // it wins over the wildcard above.
7267
7267
  [COMMUNITY_EMAIL_UNSUBSCRIBE_PATH]: { tier: "MODERATE" },
7268
7268
  // Case spaces (wayai#5921, `cases/routes.ts`): every route under the mount (the uploads, the received documents' upload,
7269
- // 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
7270
7270
  // one per-user budget. Each is one person's page or write, at most a few hundred Durable Object reads (the
7271
7271
  // list of their spaces); a space's own limits are counted in its CaseDO. Every caller is a web
7272
7272
  // session, so the per-IP tier is skipped; the key is pinned because the paths carry org, space,
@@ -7352,6 +7352,16 @@ var init_chunk_7LULTR3U = __esm({
7352
7352
  skipAuthenticatedUsers: true,
7353
7353
  userLimitKey: "/api/cases/*/*/cases/*/inputs/*/passages"
7354
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
+ },
7355
7365
  // The WayAI Guide's help entry (wayai#4948, `routes/api/guide.ts`): one POST per click by a viewer
7356
7366
  // the snapshot does not show enrolled, which reads the person's row on the Guide hub and writes only
7357
7367
  // what is missing (an enrolled viewer's click opens the hub without a request). Every caller is
@@ -7388,7 +7398,7 @@ var init_chunk_7LULTR3U = __esm({
7388
7398
  }
7389
7399
  });
7390
7400
 
7391
- // ../../packages/core/dist/chunk-TID3PAFF.js
7401
+ // ../../packages/core/dist/chunk-2IPHTFV5.js
7392
7402
  function fileSnapshotChanged(run) {
7393
7403
  return run.written + run.removed > 0;
7394
7404
  }
@@ -7429,10 +7439,10 @@ async function sendWithRetry(opts, cursor) {
7429
7439
  }
7430
7440
  }
7431
7441
  var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
7432
- var init_chunk_TID3PAFF = __esm({
7433
- "../../packages/core/dist/chunk-TID3PAFF.js"() {
7442
+ var init_chunk_2IPHTFV5 = __esm({
7443
+ "../../packages/core/dist/chunk-2IPHTFV5.js"() {
7434
7444
  "use strict";
7435
- init_chunk_7LULTR3U();
7445
+ init_chunk_AUD5MVHU();
7436
7446
  init_chunk_5FO3GNKP();
7437
7447
  init_zod();
7438
7448
  rekorFileSnapshotAnswerSchema = external_exports.object({
@@ -15603,17 +15613,17 @@ function isShortNameAlias(segment2) {
15603
15613
  function isCaseInstructions(segments) {
15604
15614
  return segments.length > 2 && segments[0] === "instructions" && segments[1] === "case";
15605
15615
  }
15606
- function contentArea(segments, phaseFolders) {
15616
+ function contentArea(segments, phaseFolders2) {
15607
15617
  if (segments.length < 2) return null;
15608
15618
  if (segments[0] === "analysis") return "analysis";
15609
- return phaseFolders.includes(segments[0]) ? "phase" : null;
15619
+ return phaseFolders2.includes(segments[0]) ? "phase" : null;
15610
15620
  }
15611
- function allowedArea(segments, phaseFolders) {
15612
- if (segments[0] === "conf") return contentArea(segments.slice(1), phaseFolders);
15621
+ function allowedArea(segments, phaseFolders2) {
15622
+ if (segments[0] === "conf") return contentArea(segments.slice(1), phaseFolders2);
15613
15623
  if (isCaseInstructions(segments)) return "case_instructions";
15614
- return contentArea(segments, phaseFolders);
15624
+ return contentArea(segments, phaseFolders2);
15615
15625
  }
15616
- function checkCaseFilePathUnder(rules, entry, phaseFolders) {
15626
+ function checkCaseFilePathUnder(rules, entry, phaseFolders2) {
15617
15627
  const entryRules = rules.filter((rule) => rule.on === "entry");
15618
15628
  for (const rule of entryRules) if (rule.refuses(entry)) return { ok: false, reason: rule.reason, segment: null };
15619
15629
  const segments = entry.path.split("/");
@@ -15623,7 +15633,7 @@ function checkCaseFilePathUnder(rules, entry, phaseFolders) {
15623
15633
  if (index >= 0) return { ok: false, reason: rule.reason, segment: index };
15624
15634
  }
15625
15635
  const confidential = segments[0] === "conf";
15626
- const area = allowedArea(segments, phaseFolders);
15636
+ const area = allowedArea(segments, phaseFolders2);
15627
15637
  if (area === null) return { ok: false, reason: "not_allowed", segment: confidential && segments.length > 1 ? 1 : 0 };
15628
15638
  const folded = segments.map(fold);
15629
15639
  return {
@@ -15636,8 +15646,8 @@ function checkCaseFilePathUnder(rules, entry, phaseFolders) {
15636
15646
  fold_key: folded.join("/")
15637
15647
  };
15638
15648
  }
15639
- function checkCaseFilePath(entry, phaseFolders) {
15640
- return checkCaseFilePathUnder(CASE_FILE_PATH_RULES, entry, phaseFolders);
15649
+ function checkCaseFilePath(entry, phaseFolders2) {
15650
+ return checkCaseFilePathUnder(CASE_FILE_PATH_RULES, entry, phaseFolders2);
15641
15651
  }
15642
15652
  var CASE_FILE_ENTRY_TYPES, CASE_FILE_PATH_MAX_BYTES, CASE_FILE_SEGMENT_MAX_BYTES, CONTROL, INVISIBLE, PERCENT_ESCAPE, WINDOWS_RESERVED_CHARACTER, WINDOWS_DEVICE_NAME, AGENT_INSTRUCTION_FILE, isLast, CASE_FILE_PATH_RULES;
15643
15653
  var init_chunk_KWRHZBGU = __esm({
@@ -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();
@@ -16524,12 +16534,12 @@ var init_chunk_XPOCPOMA = __esm({
16524
16534
  }
16525
16535
  });
16526
16536
 
16527
- // ../../packages/core/dist/chunk-6MNNZ3G4.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_6MNNZ3G4 = __esm({
16530
- "../../packages/core/dist/chunk-6MNNZ3G4.js"() {
16539
+ var init_chunk_ZBGTU6OM = __esm({
16540
+ "../../packages/core/dist/chunk-ZBGTU6OM.js"() {
16531
16541
  "use strict";
16532
- init_chunk_2YVCHUBL();
16542
+ init_chunk_W7KQS5C6();
16533
16543
  init_chunk_NMGRRGDR();
16534
16544
  init_chunk_XPOCPOMA();
16535
16545
  init_chunk_5Y2NNQHX();
@@ -17111,7 +17121,7 @@ function casePassageLines(text5) {
17111
17121
  if (lines2.at(-1) === "") lines2.pop();
17112
17122
  return lines2;
17113
17123
  }
17114
- var CASE_COMMENT_TEXT_MAX_LENGTH, CASE_COMMENTS_PAGE_MAX, CASE_COMMENT_LINE_MAX, casePassageLineSchema, lineNumber, addCaseCommentShape, CASE_COMMENT_REVERSED_REASON, addCaseCommentBody, caseCommentsQuery, CASE_COMMENT_OUT_OF_RANGE_REASON;
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, CASE_COMMENT_NOT_TEXT_REASON, CASE_COMMENT_DOCUMENT_TOO_LARGE_REASON;
17115
17125
  var init_chunk_S7UAXLHJ = __esm({
17116
17126
  "../../packages/core/dist/chunk-S7UAXLHJ.js"() {
17117
17127
  "use strict";
@@ -17149,11 +17159,13 @@ var init_chunk_S7UAXLHJ = __esm({
17149
17159
  limit: external_exports.coerce.number().int().min(1).max(CASE_COMMENTS_PAGE_MAX).optional()
17150
17160
  });
17151
17161
  CASE_COMMENT_OUT_OF_RANGE_REASON = "passage_out_of_range";
17162
+ CASE_COMMENT_NOT_TEXT_REASON = "not_text";
17163
+ CASE_COMMENT_DOCUMENT_TOO_LARGE_REASON = "document_too_large";
17152
17164
  }
17153
17165
  });
17154
17166
 
17155
17167
  // ../../packages/core/dist/chunk-U3L6QR6F.js
17156
- var CASE_VERSION_DECISION_REASON_MAX_LENGTH, CASE_VERSION_DECISIONS, caseVersionDecisionReason, reason, lineNumber2, recordCaseReferenceBody, CASE_PASSAGE_REVERSED_REASON, citeCasePassageBody, decideCaseVersionBody, CASE_PASSAGE_LINK_CHANGED_REASON, CASE_PASSAGE_NO_TEXT_REASON, CASE_PASSAGE_OUT_OF_RANGE_REASON;
17168
+ var CASE_VERSION_DECISION_REASON_MAX_LENGTH, CASE_VERSION_DECISIONS, caseVersionDecisionReason, reason, lineNumber2, recordCaseReferenceBody, CASE_PASSAGE_REVERSED_REASON, citeCasePassageBody, decideCaseVersionBody, CASE_PASSAGE_LINK_REQUIRED_REASON, CASE_PASSAGE_LINK_CHANGED_REASON, CASE_PASSAGE_NO_TEXT_REASON, CASE_PASSAGE_TEXT_TOO_LARGE_REASON, CASE_PASSAGE_NOT_TEXT_REASON, CASE_PASSAGE_OUT_OF_RANGE_REASON;
17157
17169
  var init_chunk_U3L6QR6F = __esm({
17158
17170
  "../../packages/core/dist/chunk-U3L6QR6F.js"() {
17159
17171
  "use strict";
@@ -17187,16 +17199,19 @@ var init_chunk_U3L6QR6F = __esm({
17187
17199
  }).strict().superRefine((body, ctx) => {
17188
17200
  if (body.decision === "keep" && body.reason === null) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A version kept needs its reason", path: ["reason"] });
17189
17201
  });
17202
+ CASE_PASSAGE_LINK_REQUIRED_REASON = "link_required";
17190
17203
  CASE_PASSAGE_LINK_CHANGED_REASON = "link_changed";
17191
17204
  CASE_PASSAGE_NO_TEXT_REASON = "version_no_text";
17205
+ CASE_PASSAGE_TEXT_TOO_LARGE_REASON = CASE_COMMENT_DOCUMENT_TOO_LARGE_REASON;
17206
+ CASE_PASSAGE_NOT_TEXT_REASON = CASE_COMMENT_NOT_TEXT_REASON;
17192
17207
  CASE_PASSAGE_OUT_OF_RANGE_REASON = CASE_COMMENT_OUT_OF_RANGE_REASON;
17193
17208
  }
17194
17209
  });
17195
17210
 
17196
- // ../../packages/core/dist/chunk-Q5LS3FKY.js
17211
+ // ../../packages/core/dist/chunk-S5FHM37X.js
17197
17212
  var lines, ordered, citeCaseOfficialVersionPassageBody, citeCaseReceivedPassageBody, citeCaseSourcePassageBody, citeCaseInputPassageBody, caseSourceRefSchema;
17198
- var init_chunk_Q5LS3FKY = __esm({
17199
- "../../packages/core/dist/chunk-Q5LS3FKY.js"() {
17213
+ var init_chunk_S5FHM37X = __esm({
17214
+ "../../packages/core/dist/chunk-S5FHM37X.js"() {
17200
17215
  "use strict";
17201
17216
  init_chunk_U3L6QR6F();
17202
17217
  init_chunk_S7UAXLHJ();
@@ -17357,10 +17372,10 @@ var init_chunk_UMAPAGFH = __esm({
17357
17372
  }
17358
17373
  });
17359
17374
 
17360
- // ../../packages/core/dist/chunk-6ISR4YNG.js
17375
+ // ../../packages/core/dist/chunk-J7LBOXQK.js
17361
17376
  var caseInputLinkParam, caseCollectionDocumentOfCaseParam, linkCaseCollectionInputBody, linkCasePreviousOutputInputBody, linkCaseReceivedInputBody, linkCaseInputBody, CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON, CASE_LINK_OUTPUT_NOT_PRIOR_REASON, CASE_LINK_RECEIVED_UNKNOWN_REASON, CASE_LINK_DOCUMENT_TYPE_MISMATCH_REASON, CASE_LINK_VERSION_NOT_CURRENT_REASON, CASE_COLLECTION_CASES_PAGE_MAX, caseCollectionCasesQuery, CASE_REFERENCES_PAGE_MAX, caseReferencesQuery;
17362
- var init_chunk_6ISR4YNG = __esm({
17363
- "../../packages/core/dist/chunk-6ISR4YNG.js"() {
17377
+ var init_chunk_J7LBOXQK = __esm({
17378
+ "../../packages/core/dist/chunk-J7LBOXQK.js"() {
17364
17379
  "use strict";
17365
17380
  init_chunk_6CHDJVQ6();
17366
17381
  init_chunk_U3L6QR6F();
@@ -18487,7 +18502,7 @@ var init_contracts = __esm({
18487
18502
  init_chunk_ZC6YGHNX();
18488
18503
  init_chunk_MGBAXT5Y();
18489
18504
  init_chunk_5DGHIY7L();
18490
- init_chunk_TID3PAFF();
18505
+ init_chunk_2IPHTFV5();
18491
18506
  init_chunk_IPDOHAZ5();
18492
18507
  init_chunk_PFGVH2CX();
18493
18508
  init_chunk_FPSDNS2E();
@@ -18525,23 +18540,23 @@ var init_contracts = __esm({
18525
18540
  init_chunk_AHISKXHA();
18526
18541
  init_chunk_2YEGUQR7();
18527
18542
  init_chunk_JDJ4EUOL();
18528
- init_chunk_6MNNZ3G4();
18543
+ init_chunk_ZBGTU6OM();
18529
18544
  init_chunk_K3PD6AOF();
18530
18545
  init_chunk_KVMROYDC();
18531
18546
  init_chunk_M2IF4G6X();
18532
18547
  init_chunk_UOPCLXCU();
18533
18548
  init_chunk_7CZSLDOE();
18534
- init_chunk_2YVCHUBL();
18549
+ init_chunk_W7KQS5C6();
18535
18550
  init_chunk_NMGRRGDR();
18536
18551
  init_chunk_WYCUCSD5();
18537
18552
  init_chunk_H6V7NEWR();
18538
18553
  init_chunk_ZVIMTUGZ();
18539
- init_chunk_Q5LS3FKY();
18554
+ init_chunk_S5FHM37X();
18540
18555
  init_chunk_BVQCYBU6();
18541
18556
  init_chunk_Z3SV3XTC();
18542
18557
  init_chunk_NHC27NIE();
18543
18558
  init_chunk_UMAPAGFH();
18544
- init_chunk_6ISR4YNG();
18559
+ init_chunk_J7LBOXQK();
18545
18560
  init_chunk_6CHDJVQ6();
18546
18561
  init_chunk_U3X3BIQH();
18547
18562
  init_chunk_EYOBPUDN();
@@ -18573,7 +18588,7 @@ var init_contracts = __esm({
18573
18588
  init_chunk_ZRXP6OOJ();
18574
18589
  init_chunk_BGNWWR6B();
18575
18590
  init_chunk_ZIGA5RCU();
18576
- init_chunk_7LULTR3U();
18591
+ init_chunk_AUD5MVHU();
18577
18592
  init_chunk_SOJMWM63();
18578
18593
  init_chunk_AMMLEB4T();
18579
18594
  init_chunk_5FO3GNKP();
@@ -18744,7 +18759,7 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
18744
18759
  var init_dist = __esm({
18745
18760
  "../../packages/core/dist/index.js"() {
18746
18761
  "use strict";
18747
- init_chunk_7LULTR3U();
18762
+ init_chunk_AUD5MVHU();
18748
18763
  init_chunk_SOJMWM63();
18749
18764
  init_chunk_AMMLEB4T();
18750
18765
  init_chunk_5FO3GNKP();
@@ -20557,7 +20572,7 @@ function dataErrorMessage(err) {
20557
20572
  const message = parsed?.error?.message;
20558
20573
  return typeof message === "string" && message ? message : null;
20559
20574
  }
20560
- var RETRYABLE_BACKOFF_MS, delay, accessDimensions, courseAuthoring, caseTypePath, casePath, ApiError, ApiClient;
20575
+ var RETRYABLE_BACKOFF_MS, delay, accessDimensions, courseAuthoring, caseTypePath, casePath, etagSha, ApiError, ApiClient;
20561
20576
  var init_api_client = __esm({
20562
20577
  "src/lib/api-client.ts"() {
20563
20578
  "use strict";
@@ -20574,6 +20589,7 @@ var init_api_client = __esm({
20574
20589
  courseAuthoring = (communityId, courseId) => `/api/communities/${encodeURIComponent(communityId)}/authoring/courses${courseId === void 0 ? "" : `/${encodeURIComponent(courseId)}`}`;
20575
20590
  caseTypePath = (ref) => `/api/cases/${encodeURIComponent(ref.org_id)}/${encodeURIComponent(ref.space_id)}/types/${encodeURIComponent(ref.type_id)}`;
20576
20591
  casePath = (ref) => `/api/cases/${encodeURIComponent(ref.org_id)}/${encodeURIComponent(ref.space_id)}/cases/${encodeURIComponent(ref.code)}`;
20592
+ etagSha = (etag) => etag === null ? null : /^(?:W\/)?"([0-9a-f]{64})"$/.exec(etag)?.[1] ?? null;
20577
20593
  ApiError = class extends Error {
20578
20594
  status;
20579
20595
  body;
@@ -20792,6 +20808,19 @@ var init_api_client = __esm({
20792
20808
  async getCaseInputSourceLink(ref, inputId) {
20793
20809
  return this.request("GET", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/source-link`);
20794
20810
  }
20811
+ /**
20812
+ * The text of the case's own source an input links, named as a passage's body names it: the bytes a passage's lines
20813
+ * number, with their SHA-256 as the server computed it from them (the answer's `ETag`); `sha` is null when no such tag is answered.
20814
+ */
20815
+ async getCaseInputSourceContent(ref, inputId, source) {
20816
+ const params = new URLSearchParams(source);
20817
+ const { bytes, etag } = await this.download(`${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/source-link/content?${params}`);
20818
+ return { bytes, sha: etagSha(etag) };
20819
+ }
20820
+ /** The official versions an input of origin `previous_output` may link: the current one of each output of an earlier phase it depends on, that the reader reads. */
20821
+ async listCaseInputOfficialVersions(ref, inputId) {
20822
+ return this.request("GET", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/official-versions`);
20823
+ }
20795
20824
  /** Link an input: to a collection document's version, an earlier phase's official version, or a received document, by the body's fields. */
20796
20825
  async linkCaseInput(ref, inputId, body) {
20797
20826
  return this.request("PUT", `${casePath(ref)}/inputs/${encodeURIComponent(inputId)}/link`, body);
@@ -20808,7 +20837,7 @@ var init_api_client = __esm({
20808
20837
  const params = new URLSearchParams({ part: query.part });
20809
20838
  if (query.version_id !== void 0) params.set("version_id", query.version_id);
20810
20839
  const { bytes, etag } = await this.download(`${casePath(ref)}/collection/${encodeURIComponent(documentId)}/content?${params}`);
20811
- return { bytes, sha: etag === null ? null : /^(?:W\/)?"([0-9a-f]{64})"$/.exec(etag)?.[1] ?? null };
20840
+ return { bytes, sha: etagSha(etag) };
20812
20841
  }
20813
20842
  /**
20814
20843
  * The case's package (`get_case_package`): the revision of the type version it opened on that reaches it, its files listed by path, SHA-256 and size;
@@ -32063,8 +32092,8 @@ import * as path33 from "path";
32063
32092
  function isClonePath(rel) {
32064
32093
  return isCasePath(rel, rel.split("/").filter((segment2) => CASE_PHASE_FOLDER_PATTERN.test(segment2)));
32065
32094
  }
32066
- function assertClonePaths(root, record, phaseFolders) {
32067
- if (!Object.keys(record.files).every((rel) => isCasePath(rel, phaseFolders))) throw notAMarker(path33.join(root, CASE_CLONE_RECORD_FILE));
32095
+ function assertClonePaths(root, record, phaseFolders2) {
32096
+ if (!Object.keys(record.files).every((rel) => isCasePath(rel, phaseFolders2))) throw notAMarker(path33.join(root, CASE_CLONE_RECORD_FILE));
32068
32097
  }
32069
32098
  function isCloneRecord(value) {
32070
32099
  if (typeof value !== "object" || value === null) return false;
@@ -32157,7 +32186,7 @@ var init_case_clone_record = __esm({
32157
32186
  init_case_types();
32158
32187
  init_case_local_files();
32159
32188
  CASE_CLONE_RECORD_FILE = ".wayai-case.json";
32160
- isCasePath = (rel, phaseFolders) => checkCaseFilePath({ path: rel, type: "file" }, phaseFolders).ok;
32189
+ isCasePath = (rel, phaseFolders2) => checkCaseFilePath({ path: rel, type: "file" }, phaseFolders2).ok;
32161
32190
  notAMarker = (file) => expected(`${sanitizeTerminalText(file)} is not a marker \`wayai cases clone\` wrote. Move it aside and clone the case again.`);
32162
32191
  sameCase = (a, b) => a.org_id === b.org_id && a.space_id === b.space_id && a.code === b.code;
32163
32192
  }
@@ -41814,6 +41843,58 @@ var init_case_comments = __esm({
41814
41843
  }
41815
41844
  });
41816
41845
 
41846
+ // ../../packages/core/dist/contracts/case-collection-citations.js
41847
+ var init_case_collection_citations = __esm({
41848
+ "../../packages/core/dist/contracts/case-collection-citations.js"() {
41849
+ "use strict";
41850
+ init_chunk_U3L6QR6F();
41851
+ init_chunk_S7UAXLHJ();
41852
+ init_chunk_7TQYAKCB();
41853
+ init_chunk_VROZDNLV();
41854
+ init_chunk_733K4J4G();
41855
+ init_chunk_PFPADFUC();
41856
+ init_chunk_KWRHZBGU();
41857
+ init_chunk_3T3D7LTE();
41858
+ init_chunk_M2T55BV6();
41859
+ init_chunk_VYINA6YP();
41860
+ init_chunk_ZVXO3XL6();
41861
+ init_chunk_FBV7NLKO();
41862
+ init_chunk_WEXVYJ5H();
41863
+ init_chunk_HZ6CADSY();
41864
+ init_chunk_ICYO56QW();
41865
+ init_chunk_WFQDSQJK();
41866
+ init_chunk_ZTNFLGW5();
41867
+ }
41868
+ });
41869
+
41870
+ // ../../packages/core/dist/contracts/case-collection-links.js
41871
+ var init_case_collection_links = __esm({
41872
+ "../../packages/core/dist/contracts/case-collection-links.js"() {
41873
+ "use strict";
41874
+ init_chunk_J7LBOXQK();
41875
+ init_chunk_6CHDJVQ6();
41876
+ init_chunk_U3X3BIQH();
41877
+ init_chunk_EYOBPUDN();
41878
+ init_chunk_U3L6QR6F();
41879
+ init_chunk_S7UAXLHJ();
41880
+ init_chunk_7TQYAKCB();
41881
+ init_chunk_VROZDNLV();
41882
+ init_chunk_733K4J4G();
41883
+ init_chunk_PFPADFUC();
41884
+ init_chunk_KWRHZBGU();
41885
+ init_chunk_3T3D7LTE();
41886
+ init_chunk_M2T55BV6();
41887
+ init_chunk_VYINA6YP();
41888
+ init_chunk_ZVXO3XL6();
41889
+ init_chunk_FBV7NLKO();
41890
+ init_chunk_WEXVYJ5H();
41891
+ init_chunk_HZ6CADSY();
41892
+ init_chunk_ICYO56QW();
41893
+ init_chunk_WFQDSQJK();
41894
+ init_chunk_ZTNFLGW5();
41895
+ }
41896
+ });
41897
+
41817
41898
  // src/cases/case-package.ts
41818
41899
  import * as fs37 from "fs";
41819
41900
  import * as path49 from "path";
@@ -42107,8 +42188,9 @@ async function readInputTexts(calls, folder, work, folders, listed3) {
42107
42188
  if (!view?.readable) return null;
42108
42189
  if (view.kind === "official_version") {
42109
42190
  const base2 = { ...named, origin: "previous_output", official_version_id: view.official_version_id, version: view.version };
42110
- const checked = checkedText(base2, file, null, view.passages.filter((p) => "official_version_id" in p && p.official_version_id === view.official_version_id));
42111
- return view.has_text ? { text: { ...checked.text, status: "no_read" }, data: null } : checked;
42191
+ const cited2 = view.passages.filter((p) => "official_version_id" in p && p.official_version_id === view.official_version_id);
42192
+ const answered = view.has_text ? await calls.run(() => sourceTextRefused(api.getCaseInputSourceContent(connection, input.id, { official_version_id: view.official_version_id }))) : null;
42193
+ return checkedText(base2, file, answered, cited2);
42112
42194
  }
42113
42195
  const base = { ...named, origin: "received", received_id: view.received_id };
42114
42196
  const cited = view.passages.filter((p) => "received_id" in p && p.received_id === view.received_id);
@@ -42230,11 +42312,11 @@ function unwrittenLines(work) {
42230
42312
  return (work?.phases ?? []).flatMap((p) => p.texts.flatMap(({ text: text5 }) => {
42231
42313
  const name = `${one(p.folder)}, input ${one(text5.key)} (${one(text5.name)})`;
42232
42314
  if (text5.status === "hash_mismatch") {
42233
- return [`${name}: not written, its bytes do not hash to the SHA-256 the space registered for it${text5.sha === null ? " (none was answered)" : ""}.`];
42315
+ const whose = text5.origin === "previous_output" ? "the space answered for them" : "the space registered for it";
42316
+ return [`${name}: not written, its bytes do not hash to the SHA-256 ${whose}${text5.sha === null ? " (none was answered)" : ""}.`];
42234
42317
  }
42235
- if (text5.status === "no_read") return [`${name}: not written, no read this authorization makes gives the text of an earlier phase's official version.`];
42236
42318
  if (text5.status !== "no_text") return [];
42237
- return [text5.origin === "collection" ? `${name}: the version it links holds no registered text, or is no longer readable here.` : `${name}: the source it links holds no text, or it is no longer readable here.`];
42319
+ 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 it can be read from (none, past its size limit, or not text), or it is no longer readable here.`];
42238
42320
  }));
42239
42321
  }
42240
42322
  function packageReadme(pkg2) {
@@ -42264,8 +42346,9 @@ function readme(detail, at, withheld, confidential, unwritten, pkg2) {
42264
42346
  " and its cited passages (lines and hash, and whether they match the text here).",
42265
42347
  `- \`${INPUTS_DIR}/<phase folder>/<input key>.md\`: each such input's registered text, of the version or source its`,
42266
42348
  " link names, byte for byte and checked against the SHA-256 the space registered for it: line N here is the line N a",
42267
- " citation names (each line ends at a line break). An earlier phase's official version's text is not here: no read",
42268
- " this authorization makes gives it.",
42349
+ " citation names (each line ends at a line break). An earlier phase's official version's text is its frozen piece",
42350
+ " (one Markdown file, or a document of chapters composed as WayAI composes it), checked against the SHA-256 WayAI",
42351
+ " computed for the bytes it served.",
42269
42352
  ...unwritten.length ? ["", "Linked inputs' texts not written:", ...unwritten.map((line) => `- ${line}`)] : []
42270
42353
  ];
42271
42354
  return [
@@ -42503,7 +42586,7 @@ Session-start hook: ${safe6(script)} refreshes the mirror (never with --confiden
42503
42586
  console.log(` ${safe6(settings)}`);
42504
42587
  console.log(`For another agent, run at the start of each session: ${safe6(command2)}`);
42505
42588
  }
42506
- var CASE_MIRROR_DIR, CASE_MIRROR_HOOK_FILE, RECORD_FILE2, SUMMARY_FILE, INPUTS_FILE, INPUTS_DIR, LOCK_FILE, LOCK_WAIT_MS, LOCK_STALE_MS, LOCK_POLL_MS, AGENDA_PAGES_READ, SUMMARY_REVISION_PAGES, MIRROR_CONFIDENTIAL_NOTICE, safe6, one, words, isConfPath, isObject2, isStringMap, isDeliveries, notFound, segment, NO_REVISIONS, within, HOOK_SCRIPT, json;
42589
+ var CASE_MIRROR_DIR, CASE_MIRROR_HOOK_FILE, RECORD_FILE2, SUMMARY_FILE, INPUTS_FILE, INPUTS_DIR, LOCK_FILE, LOCK_WAIT_MS, LOCK_STALE_MS, LOCK_POLL_MS, AGENDA_PAGES_READ, SUMMARY_REVISION_PAGES, MIRROR_CONFIDENTIAL_NOTICE, safe6, one, words, isConfPath, isObject2, isStringMap, isDeliveries, notFound, SOURCE_TEXT_REFUSALS, sourceTextRefused, segment, NO_REVISIONS, within, HOOK_SCRIPT, json;
42507
42590
  var init_case_mirror = __esm({
42508
42591
  "src/cases/case-mirror.ts"() {
42509
42592
  "use strict";
@@ -42511,7 +42594,10 @@ var init_case_mirror = __esm({
42511
42594
  init_case_files();
42512
42595
  init_case_comments();
42513
42596
  init_case_types();
42597
+ init_case_collection_citations();
42598
+ init_case_collection_links();
42514
42599
  init_api_client();
42600
+ init_errors3();
42515
42601
  init_resource_files();
42516
42602
  init_utils();
42517
42603
  init_expected();
@@ -42540,6 +42626,17 @@ var init_case_mirror = __esm({
42540
42626
  isStringMap = (v) => isObject2(v) && Object.values(v).every((x) => typeof x === "string");
42541
42627
  isDeliveries = (v) => isObject2(v) && Object.values(v).every((d) => d === null || isObject2(d) && typeof d.submission_id === "string" && typeof d.state === "string");
42542
42628
  notFound = (call4) => call4.catch((err) => err instanceof ApiError && err.status === 404 ? null : Promise.reject(err));
42629
+ SOURCE_TEXT_REFUSALS = {
42630
+ 400: [
42631
+ CASE_PASSAGE_NO_TEXT_REASON,
42632
+ CASE_PASSAGE_TEXT_TOO_LARGE_REASON,
42633
+ CASE_PASSAGE_NOT_TEXT_REASON,
42634
+ CASE_PASSAGE_LINK_REQUIRED_REASON,
42635
+ CASE_LINK_OFFICIAL_VERSION_UNKNOWN_REASON
42636
+ ],
42637
+ 409: [CASE_PASSAGE_LINK_CHANGED_REASON]
42638
+ };
42639
+ sourceTextRefused = (call4) => notFound(call4).catch((err) => err instanceof ApiError && (err.status === 403 || SOURCE_TEXT_REFUSALS[err.status]?.includes(extractApiErrorReason(err) ?? "")) ? null : Promise.reject(err));
42543
42640
  segment = (name, pattern, id) => pattern.test(name) ? name : UUID_RE3.test(id) ? id : computeHash(Buffer.from(id, "utf-8"));
42544
42641
  NO_REVISIONS = { revisions: [], more: false, newest_at: null };
42545
42642
  within = (prev, now) => Object.fromEntries(Object.entries(prev).filter(([key]) => key in now));
@@ -43075,58 +43172,6 @@ var init_case_skeleton = __esm({
43075
43172
  }
43076
43173
  });
43077
43174
 
43078
- // ../../packages/core/dist/contracts/case-collection-links.js
43079
- var init_case_collection_links = __esm({
43080
- "../../packages/core/dist/contracts/case-collection-links.js"() {
43081
- "use strict";
43082
- init_chunk_6ISR4YNG();
43083
- init_chunk_6CHDJVQ6();
43084
- init_chunk_U3X3BIQH();
43085
- init_chunk_EYOBPUDN();
43086
- init_chunk_U3L6QR6F();
43087
- init_chunk_S7UAXLHJ();
43088
- init_chunk_7TQYAKCB();
43089
- init_chunk_VROZDNLV();
43090
- init_chunk_733K4J4G();
43091
- init_chunk_PFPADFUC();
43092
- init_chunk_KWRHZBGU();
43093
- init_chunk_3T3D7LTE();
43094
- init_chunk_M2T55BV6();
43095
- init_chunk_VYINA6YP();
43096
- init_chunk_ZVXO3XL6();
43097
- init_chunk_FBV7NLKO();
43098
- init_chunk_WEXVYJ5H();
43099
- init_chunk_HZ6CADSY();
43100
- init_chunk_ICYO56QW();
43101
- init_chunk_WFQDSQJK();
43102
- init_chunk_ZTNFLGW5();
43103
- }
43104
- });
43105
-
43106
- // ../../packages/core/dist/contracts/case-collection-citations.js
43107
- var init_case_collection_citations = __esm({
43108
- "../../packages/core/dist/contracts/case-collection-citations.js"() {
43109
- "use strict";
43110
- init_chunk_U3L6QR6F();
43111
- init_chunk_S7UAXLHJ();
43112
- init_chunk_7TQYAKCB();
43113
- init_chunk_VROZDNLV();
43114
- init_chunk_733K4J4G();
43115
- init_chunk_PFPADFUC();
43116
- init_chunk_KWRHZBGU();
43117
- init_chunk_3T3D7LTE();
43118
- init_chunk_M2T55BV6();
43119
- init_chunk_VYINA6YP();
43120
- init_chunk_ZVXO3XL6();
43121
- init_chunk_FBV7NLKO();
43122
- init_chunk_WEXVYJ5H();
43123
- init_chunk_HZ6CADSY();
43124
- init_chunk_ICYO56QW();
43125
- init_chunk_WFQDSQJK();
43126
- init_chunk_ZTNFLGW5();
43127
- }
43128
- });
43129
-
43130
43175
  // src/cases/case-inputs.ts
43131
43176
  function inputLinkState(input) {
43132
43177
  const unlinked = input.dispensation ? { state: "dispensed" } : { state: "unlinked" };
@@ -43165,14 +43210,30 @@ function inputLinkState(input) {
43165
43210
  }
43166
43211
  function linkCommand(key, folder, origin, id) {
43167
43212
  const [flag, placeholder] = origin === "previous_output" ? ["--official-version", "<official_version_id>"] : ["--received", "<received_id>"];
43168
- return `wayai cases link ${one2(key)} --phase ${one2(folder)} ${flag} ${id ?? placeholder}`;
43213
+ return `${linkPrefix(key, folder)} ${flag} ${id ?? placeholder}`;
43214
+ }
43215
+ function candidateLine(version, key, folder, folders) {
43216
+ const { output } = version;
43217
+ const traits = [
43218
+ `phase ${one2(folders.get(version.phase_id) ?? version.phase_id)}`,
43219
+ `published ${one2(version.published_at)}`,
43220
+ ...output.format === "file" ? ["a file: no text to cite"] : [],
43221
+ ...version.confidential ? ["confidential"] : []
43222
+ ];
43223
+ return `version ${version.version} of output ${one2(output.code)} (${one2(output.document_type)}), ${traits.join(", ")}: \`${linkCommand(key, folder, "previous_output", version.official_version_id)}\``;
43169
43224
  }
43170
- function linkHint(key, folder, origin) {
43225
+ function linkHint(key, folder, origin, linkable, folders = /* @__PURE__ */ new Map(), indent = " ") {
43171
43226
  if (origin === "collection") return "a person links it, in the web app";
43172
43227
  if (origin === "received") {
43173
43228
  return `link it to a received document of the case: \`${linkCommand(key, folder, origin)}\` (the id is in its files' names under a phase's received/)`;
43174
43229
  }
43175
- return `link it to the current official version of an earlier phase's output: \`${linkCommand(key, folder, origin)}\` (no wayai cases command lists those: a person gives you the id, or links it in the web app)`;
43230
+ const current = "link it to the current official version of an earlier phase's output:";
43231
+ if (linkable === null) {
43232
+ return `${current} \`${linkCommand(key, folder, origin)}\` (this server lists none of them: a person gives you the id, or links it in the web app)`;
43233
+ }
43234
+ if (linkable === void 0) return `${current} \`${linkPrefix(key, folder)} --list\` lists those it may link`;
43235
+ if (linkable.length === 0) return NONE_LINKABLE;
43236
+ return `link it to one of the official versions it may link ${WHICH_LINKABLE}:${candidateBlock(linkable, key, folder, folders, indent)}`;
43176
43237
  }
43177
43238
  function undecidedWords(input, folder, link, folders) {
43178
43239
  const linked = sourceWords(link.source, folders);
@@ -43187,7 +43248,7 @@ function undecidedWords(input, folder, link, folders) {
43187
43248
  agent: true
43188
43249
  };
43189
43250
  }
43190
- function inputLine(input, folder, folders) {
43251
+ function inputLine(input, folder, folders, linkable) {
43191
43252
  const head = `${one2(input.key)} (${one2(input.name)}), ${input.origin.replaceAll("_", " ")}${input.required ? ", required" : ""}`;
43192
43253
  const state = inputLinkState(input);
43193
43254
  switch (state.state) {
@@ -43202,7 +43263,7 @@ function inputLine(input, folder, folders) {
43202
43263
  case "unknown":
43203
43264
  return `${head}: this server does not say whether it is linked`;
43204
43265
  case "unlinked":
43205
- return `${head}: not linked; ${linkHint(input.key, folder, input.origin)}`;
43266
+ return `${head}: not linked; ${linkHint(input.key, folder, input.origin, linkable, folders, " ")}`;
43206
43267
  }
43207
43268
  }
43208
43269
  function findInput(work, phase, name) {
@@ -43211,21 +43272,37 @@ function findInput(work, phase, name) {
43211
43272
  throw expected(`Phase ${phase.folder} has no input ${JSON.stringify(sanitizeTerminalText(name))} you may read. Its inputs: ${work.inputs.map((i) => one2(i.key)).join(", ") || "none"}.`);
43212
43273
  }
43213
43274
  function linkTarget(opts) {
43214
- if (opts.officialVersion === void 0 === (opts.received === void 0)) {
43215
- throw expected("link takes one of --official-version <id> (an input of origin previous_output) or --received <id> (an input of origin received).");
43275
+ if ([opts.officialVersion !== void 0, opts.received !== void 0, opts.list === true].filter(Boolean).length !== 1) {
43276
+ throw expected("link takes one of --official-version <id or output code> (an input of origin previous_output), --received <id> (an input of origin received) or --list (the official versions an input of origin previous_output may link).");
43216
43277
  }
43278
+ if (opts.list === true) return { kind: "list" };
43217
43279
  if (opts.officialVersion !== void 0) {
43218
- if (!UUID_RE3.test(opts.officialVersion)) throw expected("--official-version takes an official version's id (a UUID).");
43219
- return { official_version_id: opts.officialVersion };
43280
+ if (UUID_RE3.test(opts.officialVersion)) return { kind: "source", ref: { official_version_id: opts.officialVersion } };
43281
+ if (CASE_CODE_PATTERN.test(opts.officialVersion)) return { kind: "output", code: opts.officialVersion };
43282
+ throw expected("--official-version takes an official version's id (a UUID) or the code of the output it is of (as memo).");
43220
43283
  }
43221
43284
  if (!UUID_RE3.test(opts.received)) throw expected("--received takes a received document's id (a UUID).");
43222
- return { received_id: opts.received };
43285
+ return { kind: "source", ref: { received_id: opts.received } };
43223
43286
  }
43224
43287
  function linkMismatch(input, label3, target) {
43225
43288
  if (input.origin === "collection") return `The ${label3} links a collection document: a person links it, in the web app.`;
43226
- const wants = "official_version_id" in target ? "previous_output" : "received";
43289
+ const wants = target.kind !== "source" || "official_version_id" in target.ref ? "previous_output" : "received";
43227
43290
  if (input.origin === wants) return null;
43228
- return input.origin === "previous_output" ? `The ${label3} links an earlier phase's official version: pass --official-version <id>.` : `The ${label3} links a received document of the case: pass --received <id>.`;
43291
+ if (input.origin === "previous_output") return `The ${label3} links an earlier phase's official version: pass --official-version <id or output code>, or --list.`;
43292
+ return target.kind === "list" ? `The ${label3} links a received document of the case, which no read lists here: pass --received <id> (the id is in its files' names under a phase's received/).` : `The ${label3} links a received document of the case: pass --received <id>.`;
43293
+ }
43294
+ function chooseByOutput(linkable, code2, named, folders) {
43295
+ const chosen = linkable.filter((v) => v.output.code === code2);
43296
+ if (chosen.length === 1) return chosen[0];
43297
+ if (chosen.length > 1) {
43298
+ throw expected(`Several outputs of code ${code2} have an official version the ${named.label} may link, one per phase: name it by its id.` + candidateBlock(chosen, named.key, named.folder, folders, " "));
43299
+ }
43300
+ if (linkable.length === 0) throw expected(noneLinkable(named.label));
43301
+ throw expected(`No output of code ${code2} has an official version the ${named.label} may link. Those it may link:` + candidateBlock(linkable, named.key, named.folder, folders, " "));
43302
+ }
43303
+ function linkableLines(linkable, named, folders) {
43304
+ if (linkable.length === 0) return [noneLinkable(named.label)];
43305
+ return [`Official versions the ${named.label} may link ${WHICH_LINKABLE}:`, ...candidateLines(linkable, named.key, named.folder, folders, " ")];
43229
43306
  }
43230
43307
  function detailOf(err, field) {
43231
43308
  try {
@@ -43299,12 +43376,13 @@ function citeFailure(err, session, named) {
43299
43376
  if (err.status === 403) return expected(`Your access to case ${session.connection.code} does not cite passages: that takes Edit level.`);
43300
43377
  return caseCallFailure(err, session.connection, `The ${named.label} was not found`);
43301
43378
  }
43302
- var one2, sourceWords;
43379
+ var one2, linkPrefix, candidateLines, candidateBlock, NONE_LINKABLE, noneLinkable, WHICH_LINKABLE, agentLinks, sourceWords;
43303
43380
  var init_case_inputs = __esm({
43304
43381
  "src/cases/case-inputs.ts"() {
43305
43382
  "use strict";
43306
43383
  init_case_records();
43307
43384
  init_case_collection_links();
43385
+ init_case_types();
43308
43386
  init_case_collection_citations();
43309
43387
  init_api_client();
43310
43388
  init_errors3();
@@ -43313,6 +43391,14 @@ var init_case_inputs = __esm({
43313
43391
  init_utils();
43314
43392
  init_case_session();
43315
43393
  one2 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
43394
+ linkPrefix = (key, folder) => `wayai cases link ${one2(key)} --phase ${one2(folder)}`;
43395
+ candidateLines = (linkable, key, folder, folders, indent) => linkable.map((v) => `${indent}- ${candidateLine(v, key, folder, folders)}`);
43396
+ candidateBlock = (...args2) => candidateLines(...args2).map((line) => `
43397
+ ${line}`).join("");
43398
+ NONE_LINKABLE = "no earlier phase it depends on has a current official version of its type this authorization reads yet: it waits for one to be published";
43399
+ noneLinkable = (label3) => `The ${label3} may link no official version here: ${NONE_LINKABLE}.`;
43400
+ WHICH_LINKABLE = "(the current one of each output of an earlier phase it depends on)";
43401
+ agentLinks = (origin, linkable) => origin !== "collection" && !(origin === "previous_output" && Array.isArray(linkable) && linkable.length === 0);
43316
43402
  sourceWords = (source, folders) => {
43317
43403
  const folder = (phaseId) => one2(folders.get(phaseId) ?? phaseId);
43318
43404
  switch (source.kind) {
@@ -43331,7 +43417,7 @@ var init_case_inputs = __esm({
43331
43417
  var init_case_input_sources = __esm({
43332
43418
  "../../packages/core/dist/contracts/case-input-sources.js"() {
43333
43419
  "use strict";
43334
- init_chunk_Q5LS3FKY();
43420
+ init_chunk_S5FHM37X();
43335
43421
  init_chunk_U3L6QR6F();
43336
43422
  init_chunk_S7UAXLHJ();
43337
43423
  init_chunk_7TQYAKCB();
@@ -43393,6 +43479,14 @@ async function call2(session, run, notFound2) {
43393
43479
  throw caseCallFailure(err, session.connection, notFound2);
43394
43480
  }
43395
43481
  }
43482
+ async function readLinkable(s, inputId) {
43483
+ try {
43484
+ return (await s.api.listCaseInputOfficialVersions(s.connection, inputId)).data.versions;
43485
+ } catch (err) {
43486
+ if (err instanceof ApiError && (err.status === 403 || err.status === 404)) return null;
43487
+ throw caseCallFailure(err, s.connection);
43488
+ }
43489
+ }
43396
43490
  function findPhase(detail, name) {
43397
43491
  const phase = detail.phases.find((p) => p.folder === name) ?? detail.phases.find((p) => p.code === name);
43398
43492
  if (phase) return phase;
@@ -43422,7 +43516,7 @@ function blockerLine(b, names) {
43422
43516
  }
43423
43517
  async function namesFor(session, detail, phaseIds, opts = {}) {
43424
43518
  const names = new CaseNames(session, detail);
43425
- if (readsWork(detail)) for (const id of phaseIds) await names.readPhase(id, opts.agenda ?? true);
43519
+ if (readsWork(detail)) for (const id of phaseIds) await names.readPhase(id, opts.agenda ?? true, opts.linkableFor);
43426
43520
  return names;
43427
43521
  }
43428
43522
  function printPhasesView(detail, state) {
@@ -43495,8 +43589,9 @@ async function caseExplain(session, opts) {
43495
43589
  return;
43496
43590
  }
43497
43591
  if (opts.json) {
43498
- const inputs2 = asked && readsWork(detail) ? (await namesFor(session, detail, [asked.phase_id], { agenda: false })).phaseInputs.get(asked.phase_id) ?? [] : null;
43499
- console.log(JSON.stringify({ case: detail, state, ...inputs2 ? { inputs: inputs2.map(inputJson) } : {} }, null, 2));
43592
+ const names2 = asked && readsWork(detail) ? await namesFor(session, detail, [asked.phase_id], { agenda: false }) : null;
43593
+ const inputs2 = names2 ? (names2.phaseInputs.get(asked.phase_id) ?? []).map((i) => inputJson(i, names2)) : null;
43594
+ console.log(JSON.stringify({ case: detail, state, ...inputs2 ? { inputs: inputs2 } : {} }, null, 2));
43500
43595
  return;
43501
43596
  }
43502
43597
  const phases = asked ? state.phases.filter((p) => p.phase_id === asked.phase_id) : state.phases;
@@ -43510,7 +43605,7 @@ async function caseExplain(session, opts) {
43510
43605
  console.log(`Phase ${phaseLabel(asked)}: ${st ? statusWords(st.status) : "not shown"}. Nothing holds it.`);
43511
43606
  return;
43512
43607
  }
43513
- const names = await namesFor(session, detail, named);
43608
+ const names = await namesFor(session, detail, named, asked ? {} : { linkableFor: pendingInputs([...phases, ...state.tasks]) });
43514
43609
  if (phases.length === 0) console.log(`Every phase of ${detail.code} is delivered or dispensed.`);
43515
43610
  const fullyNamed = new Set(named);
43516
43611
  for (const p of phases) {
@@ -43531,7 +43626,7 @@ async function caseExplain(session, opts) {
43531
43626
  if (inputs.length) {
43532
43627
  console.log(`Inputs of ${asked.folder}:`);
43533
43628
  const folders = names.folders();
43534
- for (const i of inputs) console.log(` ${inputLine(i, asked.folder, folders)}`);
43629
+ for (const i of inputs) console.log(` ${inputLine(i, asked.folder, folders, names.linkable(i.id))}`);
43535
43630
  }
43536
43631
  }
43537
43632
  function agentWork(b, names) {
@@ -43539,7 +43634,7 @@ function agentWork(b, names) {
43539
43634
  case "output_pending":
43540
43635
  return b.submission === null;
43541
43636
  case "input_pending":
43542
- return names.inputOrigin(b.input_id) !== "collection";
43637
+ return names.agentLinks(b.input_id);
43543
43638
  case "task_pending":
43544
43639
  case "publication_pending":
43545
43640
  return true;
@@ -43563,7 +43658,8 @@ async function caseNext(session, opts) {
43563
43658
  const underWay = state.phases.filter((p) => p.status === "in_progress");
43564
43659
  const [notes, names] = await Promise.all([
43565
43660
  readsWork(detail) ? openNotes(session) : [],
43566
- namesFor(session, detail, underWay.map((p) => p.phase_id), { agenda: !opts.json })
43661
+ // The text names the pending inputs' links alone; --json carries every unlinked one's.
43662
+ namesFor(session, detail, underWay.map((p) => p.phase_id), { agenda: !opts.json, ...opts.json ? {} : { linkableFor: pendingInputs(underWay) } })
43567
43663
  ]);
43568
43664
  const yours = [];
43569
43665
  const others = [];
@@ -43584,8 +43680,18 @@ async function caseNext(session, opts) {
43584
43680
  return [{ phase_id: p.phase_id, input, ...undecidedWords(input, folder, link, folders) }];
43585
43681
  }));
43586
43682
  if (opts.json) {
43587
- const undecidedJson = undecided.map((u) => ({ phase_id: u.phase_id, ...inputJson(u.input), agent: u.agent }));
43588
- console.log(JSON.stringify({ to_do: yours, waiting_on_others: others, undecided_inputs: undecidedJson, open_notes: notes }, null, 2));
43683
+ const undecidedJson = undecided.map((u) => ({ phase_id: u.phase_id, ...inputJson(u.input, names), agent: u.agent }));
43684
+ const linkableJson = underWay.flatMap((p) => (names.phaseInputs.get(p.phase_id) ?? []).flatMap((i) => {
43685
+ const linkable = names.linkable(i.id);
43686
+ return linkable === void 0 ? [] : [{ phase_id: p.phase_id, input_id: i.id, key: i.key, linkable }];
43687
+ }));
43688
+ console.log(JSON.stringify({
43689
+ to_do: yours,
43690
+ waiting_on_others: others,
43691
+ undecided_inputs: undecidedJson,
43692
+ linkable_official_versions: linkableJson,
43693
+ open_notes: notes
43694
+ }, null, 2));
43589
43695
  return;
43590
43696
  }
43591
43697
  const undecidedLine = (u) => ` ${folders.get(u.phase_id) ?? ""}: ${names.input(u.input.id)} ${u.text}`;
@@ -43738,20 +43844,35 @@ async function caseReceivedAdd(session, file, opts) {
43738
43844
  if (received.text_origin === "agent") console.log("Its text is marked as converted by an agent, for whoever reviews it.");
43739
43845
  }
43740
43846
  async function locateInput(session, inputName, phaseName) {
43741
- const phase = findPhase(await loadCase(session), phaseName);
43847
+ const detail = await loadCase(session);
43848
+ const phase = findPhase(detail, phaseName);
43742
43849
  const work = (await call2(session, () => session.api.getCasePhaseWork(session.connection, phase.phase_id))).data;
43743
43850
  const input = findInput(work, phase, inputName);
43744
- return { phase, input, label: `input ${one3(input.key)} of ${phase.folder}` };
43851
+ return { detail, phase, input, label: `input ${one3(input.key)} of ${phase.folder}` };
43745
43852
  }
43746
43853
  async function caseLink(session, inputName, opts) {
43747
43854
  const target = linkTarget(opts);
43748
- const { phase, input, label: label3 } = await locateInput(session, inputName, opts.phase);
43855
+ const { detail, phase, input, label: label3 } = await locateInput(session, inputName, opts.phase);
43749
43856
  const mismatch = linkMismatch(input, label3, target);
43750
43857
  if (mismatch) throw expected(mismatch);
43751
- const [kind, id] = "official_version_id" in target ? ["official version", target.official_version_id] : ["received document", target.received_id];
43858
+ let ref;
43859
+ if (target.kind === "source") {
43860
+ ref = target.ref;
43861
+ } else {
43862
+ const listed3 = await readLinkable(session, input.id);
43863
+ if (listed3 === null) throw expected("This server lists no official version an input may link: name the one to link by its id (--official-version <id>).");
43864
+ const folders = phaseFolders(detail);
43865
+ const named = { label: label3, key: input.key, folder: phase.folder };
43866
+ if (target.kind === "list") {
43867
+ for (const line of linkableLines(listed3, named, folders)) console.log(line);
43868
+ return;
43869
+ }
43870
+ ref = { official_version_id: chooseByOutput(listed3, target.code, named, folders).official_version_id };
43871
+ }
43872
+ const [kind, id] = "official_version_id" in ref ? ["official version", ref.official_version_id] : ["received document", ref.received_id];
43752
43873
  let linked;
43753
43874
  try {
43754
- linked = (await session.api.linkCaseInput(session.connection, input.id, target)).data;
43875
+ linked = (await session.api.linkCaseInput(session.connection, input.id, ref)).data;
43755
43876
  } catch (err) {
43756
43877
  throw linkFailure(err, session, { label: label3, key: input.key, folder: phase.folder, origin: input.origin, id });
43757
43878
  }
@@ -43794,8 +43915,8 @@ async function caseSkeleton(session, clone, opts) {
43794
43915
  }
43795
43916
  const mirror = mirrorFolder(clone.root);
43796
43917
  if (!mirror) throw undelivered();
43797
- const phaseFolders = detail.phases.map((p) => p.folder);
43798
- assertClonePaths(clone.root, clone.record, phaseFolders);
43918
+ const phaseFolders2 = detail.phases.map((p) => p.folder);
43919
+ assertClonePaths(clone.root, clone.record, phaseFolders2);
43799
43920
  const phase = findPhase(detail, opts.phase);
43800
43921
  const work = (await call2(session, () => session.api.getCasePhaseWork(session.connection, phase.phase_id))).data;
43801
43922
  if (!opts.confidential && holdsRight && !markedThroughout(work)) throw expected(SKELETON_CONFIDENTIAL_REQUIRED);
@@ -43886,7 +44007,7 @@ async function caseSkeleton(session, clone, opts) {
43886
44007
  if (!opts.confidential) console.log(`
43887
44008
  ${SKELETON_CONFIDENTIAL_NOTICE}`);
43888
44009
  }
43889
- var NOTE_PAGES_READ, NOTES_PAGE, AGENDA_PAGES_READ2, one3, loadCase, loadState, phaseLabel, statusWords, CaseNames, AWAITING, readsWork, PHASES_VIEW_NOTE, noteLine, inputJson, blockerKey, SKELETON_CONFIDENTIAL_REQUIRED, SKELETON_CONFIDENTIAL_NOTICE;
44010
+ var NOTE_PAGES_READ, NOTES_PAGE, AGENDA_PAGES_READ2, one3, loadCase, loadState, phaseFolders, phaseLabel, statusWords, CaseNames, AWAITING, pendingInputs, readsWork, PHASES_VIEW_NOTE, noteLine, inputJson, blockerKey, SKELETON_CONFIDENTIAL_REQUIRED, SKELETON_CONFIDENTIAL_NOTICE;
43890
44011
  var init_case_work = __esm({
43891
44012
  "src/cases/case-work.ts"() {
43892
44013
  "use strict";
@@ -43900,6 +44021,7 @@ var init_case_work = __esm({
43900
44021
  init_case_package();
43901
44022
  init_case_skeleton();
43902
44023
  init_case_inputs();
44024
+ init_api_client();
43903
44025
  init_case_input_sources();
43904
44026
  init_case_item_reader();
43905
44027
  init_case_file_paths();
@@ -43913,12 +44035,14 @@ var init_case_work = __esm({
43913
44035
  one3 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
43914
44036
  loadCase = async (s) => (await call2(s, () => s.api.getCase(s.connection))).data;
43915
44037
  loadState = async (s) => (await call2(s, () => s.api.getCaseState(s.connection))).data;
44038
+ phaseFolders = (detail) => new Map(detail.phases.map((p) => [p.phase_id, p.folder]));
43916
44039
  phaseLabel = (p) => `${one3(p.folder)} (${one3(p.name)})`;
43917
44040
  statusWords = (status) => status.replaceAll("_", " ");
43918
44041
  CaseNames = class {
43919
44042
  constructor(session, detail) {
43920
44043
  this.session = session;
43921
44044
  this.phases = new Map(detail.phases.map((p) => [p.phase_id, p]));
44045
+ this.folderOf = phaseFolders(detail);
43922
44046
  this.tasks = new Map((detail.tasks ?? []).map((t) => [t.case_task_id, one3(t.name)]));
43923
44047
  }
43924
44048
  phases;
@@ -43926,23 +44050,35 @@ var init_case_work = __esm({
43926
44050
  outputs = /* @__PURE__ */ new Map();
43927
44051
  inputs = /* @__PURE__ */ new Map();
43928
44052
  groups = /* @__PURE__ */ new Map();
44053
+ /** The official versions each unlinked input of origin `previous_output` read may link (`./case-inputs.ts` `Linkable`). */
44054
+ linkableOf = /* @__PURE__ */ new Map();
44055
+ folderOf;
43929
44056
  /** Each phase read's inputs, in their order. */
43930
44057
  phaseInputs = /* @__PURE__ */ new Map();
43931
- /** Read one phase's outputs and inputs, and (unless `agenda` is false) its agenda groups, to name them. */
43932
- async readPhase(phaseId, agenda = true) {
44058
+ /**
44059
+ * Read one phase's outputs and inputs, and (unless `agenda` is false) its agenda groups, to name them; and what each
44060
+ * unlinked input of origin `previous_output` may link, of those `linkableFor` holds (all of them when it is undefined).
44061
+ */
44062
+ async readPhase(phaseId, agenda = true, linkableFor) {
43933
44063
  const s = this.session;
43934
44064
  const work = (await call2(s, () => s.api.getCasePhaseWork(s.connection, phaseId))).data;
43935
44065
  for (const o of work.outputs) this.outputs.set(o.id, `${one3(o.code)} (${one3(o.document_type)})`);
43936
44066
  const folder = this.phases.get(phaseId)?.folder ?? "";
43937
44067
  for (const i of work.inputs) this.inputs.set(i.id, { label: `${one3(i.key)} (${one3(i.name)})`, input: i, folder });
43938
44068
  this.phaseInputs.set(phaseId, work.inputs);
43939
- let cursor;
43940
- for (let page = 0; agenda && page < AGENDA_PAGES_READ2; page++) {
43941
- const { groups, next_cursor } = (await call2(s, () => s.api.getCaseAgenda(s.connection, phaseId, cursor))).data;
43942
- for (const g of groups) this.groups.set(g.agenda_group_id, `${one3(g.code)} (${one3(g.name)})`);
43943
- if (!next_cursor) break;
43944
- cursor = next_cursor;
43945
- }
44069
+ const unlinked = work.inputs.filter((i) => i.origin === "previous_output" && inputLinkState(i).state === "unlinked" && (linkableFor === void 0 || linkableFor.has(i.id)));
44070
+ const groups = async () => {
44071
+ let cursor;
44072
+ for (let page = 0; agenda && page < AGENDA_PAGES_READ2; page++) {
44073
+ const { groups: got, next_cursor } = (await call2(s, () => s.api.getCaseAgenda(s.connection, phaseId, cursor))).data;
44074
+ for (const g of got) this.groups.set(g.agenda_group_id, `${one3(g.code)} (${one3(g.name)})`);
44075
+ if (!next_cursor) break;
44076
+ cursor = next_cursor;
44077
+ }
44078
+ };
44079
+ await Promise.all([groups(), ...unlinked.map(async (i) => {
44080
+ this.linkableOf.set(i.id, await readLinkable(s, i.id));
44081
+ })]);
43946
44082
  }
43947
44083
  // Each name with its noun: `output memo (Technical memo)`, or `an output` for one not read.
43948
44084
  phase(id) {
@@ -43967,15 +44103,20 @@ var init_case_work = __esm({
43967
44103
  /** How an unlinked input is linked (`./case-inputs.ts` `linkHint`), after a colon; nothing for one not read. */
43968
44104
  inputHint(id) {
43969
44105
  const named = this.inputs.get(id);
43970
- return named ? `: ${linkHint(named.input.key, named.folder, named.input.origin)}` : "";
44106
+ return named ? `: ${linkHint(named.input.key, named.folder, named.input.origin, this.linkable(id), this.folderOf)}` : "";
44107
+ }
44108
+ /** Whether an unlinked input is the agent's to link (`./case-inputs.ts` `agentLinks`); not for one not read. */
44109
+ agentLinks(id) {
44110
+ const named = this.inputs.get(id);
44111
+ return named !== void 0 && agentLinks(named.input.origin, this.linkable(id));
43971
44112
  }
43972
- /** An input's origin, or undefined for one not read. */
43973
- inputOrigin(id) {
43974
- return this.inputs.get(id)?.input.origin;
44113
+ /** The official versions an unlinked input of origin `previous_output` may link, as read (`./case-inputs.ts` `Linkable`). */
44114
+ linkable(id) {
44115
+ return this.linkableOf.get(id);
43975
44116
  }
43976
44117
  /** Each phase's folder, by phase id. */
43977
44118
  folders() {
43978
- return new Map([...this.phases].map(([id, p]) => [id, p.folder]));
44119
+ return this.folderOf;
43979
44120
  }
43980
44121
  group(id) {
43981
44122
  return this.groups.has(id) ? `agenda group ${this.groups.get(id)}` : "an agenda group";
@@ -43987,10 +44128,14 @@ var init_case_work = __esm({
43987
44128
  approval: "approval",
43988
44129
  publication: "publication"
43989
44130
  };
44131
+ pendingInputs = (held) => new Set(held.flatMap((p) => p.blockers.flatMap((b) => b.reason === "input_pending" ? [b.input_id] : [])));
43990
44132
  readsWork = (detail) => detail.access.capabilities.includes("view_work");
43991
44133
  PHASES_VIEW_NOTE = "You see only the phases' status of this case: its work is not yours to read here.";
43992
44134
  noteLine = (n) => `${n.kind === "pending" ? "pending" : "next step"}: ${one3(n.text)} [${n.note_id}]`;
43993
- inputJson = (i) => ({ input_id: i.id, key: i.key, origin: i.origin, required: i.required, link: inputLinkState(i) });
44135
+ inputJson = (i, names) => {
44136
+ const linkable = names.linkable(i.id);
44137
+ return { input_id: i.id, key: i.key, origin: i.origin, required: i.required, link: inputLinkState(i), ...linkable !== void 0 ? { linkable } : {} };
44138
+ };
43994
44139
  blockerKey = (b) => {
43995
44140
  switch (b.reason) {
43996
44141
  case "output_pending":
@@ -44017,13 +44162,13 @@ function casesRequestsPerMinute() {
44017
44162
  const budget = getEndpointConfig("/api/cases/org/space/cases/code/files")?.userLimit;
44018
44163
  return budget ? Math.max(1, Math.floor(budget * 4 / 5)) : 48;
44019
44164
  }
44020
- function assertWritableCasePaths(paths, phaseFolders) {
44165
+ function assertWritableCasePaths(paths, phaseFolders2) {
44021
44166
  const problems2 = [];
44022
44167
  const spelled = /* @__PURE__ */ new Map();
44023
44168
  const keys = /* @__PURE__ */ new Set();
44024
44169
  const checked = [];
44025
44170
  for (const rel of paths) {
44026
- const check = checkCaseFilePath({ path: rel, type: "file" }, phaseFolders);
44171
+ const check = checkCaseFilePath({ path: rel, type: "file" }, phaseFolders2);
44027
44172
  if (!check.ok) {
44028
44173
  problems2.push(`${JSON.stringify(safe7(rel))}: a case path cannot be that (${check.reason})`);
44029
44174
  continue;
@@ -44063,7 +44208,7 @@ function linkRefusal2(rel) {
44063
44208
  `${safe7(rel)} is a symlink, or not a regular file or folder. The CLI never follows one in a clone: replace it with the file or folder itself, or move it out of the clone.`
44064
44209
  );
44065
44210
  }
44066
- function scanClone(root, phaseFolders, confidential = true) {
44211
+ function scanClone(root, phaseFolders2, confidential = true) {
44067
44212
  const out = /* @__PURE__ */ new Map();
44068
44213
  const walk = (abs, rel) => {
44069
44214
  for (const name of fs40.readdirSync(abs).sort()) {
@@ -44088,7 +44233,7 @@ function scanClone(root, phaseFolders, confidential = true) {
44088
44233
  };
44089
44234
  requireOwn(root);
44090
44235
  const top = new Set(fs40.readdirSync(root));
44091
- const areas = [.../* @__PURE__ */ new Set([...phaseFolders, "analysis", ...confidential ? ["conf"] : []])].filter((area) => top.has(area));
44236
+ const areas = [.../* @__PURE__ */ new Set([...phaseFolders2, "analysis", ...confidential ? ["conf"] : []])].filter((area) => top.has(area));
44092
44237
  if (top.has("instructions")) {
44093
44238
  if (!fs40.lstatSync(path52.join(root, "instructions")).isDirectory()) throw linkRefusal2("instructions");
44094
44239
  if (fs40.readdirSync(path52.join(root, "instructions")).includes("case")) areas.push("instructions/case");
@@ -44137,13 +44282,13 @@ function requireFiles(detail, confidential) {
44137
44282
  }
44138
44283
  }
44139
44284
  async function pullInto(calls, detail, record, opts) {
44140
- const phaseFolders = phaseFoldersOf(detail);
44285
+ const phaseFolders2 = phaseFoldersOf(detail);
44141
44286
  const files = await calls.files();
44142
- assertWritableCasePaths([...sidesOf(record, /* @__PURE__ */ new Map(), files, opts.confidential).listed.keys()], phaseFolders);
44287
+ assertWritableCasePaths([...sidesOf(record, /* @__PURE__ */ new Map(), files, opts.confidential).listed.keys()], phaseFolders2);
44143
44288
  const root = opts.root();
44144
- assertClonePaths(root, record, phaseFolders);
44289
+ assertClonePaths(root, record, phaseFolders2);
44145
44290
  mirrorFolder(root);
44146
- const local = scanClone(root, phaseFolders, opts.confidential);
44291
+ const local = scanClone(root, phaseFolders2, opts.confidential);
44147
44292
  const { synced: synced2, local: localIn, remote, listed: listed3, theirsListed } = sidesOf(record, local, files, opts.confidential);
44148
44293
  const plan = planPull({ synced: synced2, local: localIn, remote, overwrite: opts.overwrite });
44149
44294
  const outside = outsideRun(record, files, opts.confidential);
@@ -44319,8 +44464,8 @@ async function casePullMirror(opts) {
44319
44464
  });
44320
44465
  });
44321
44466
  }
44322
- function leftOutReason(rel, phaseFolders, detail) {
44323
- const check = checkCaseFilePath({ path: rel, type: "file" }, phaseFolders);
44467
+ function leftOutReason(rel, phaseFolders2, detail) {
44468
+ const check = checkCaseFilePath({ path: rel, type: "file" }, phaseFolders2);
44324
44469
  if (!check.ok) return `the case takes no such path (${check.reason})`;
44325
44470
  if (check.received) return "a received document, which is never replaced or removed: register a new one with `wayai cases received add`";
44326
44471
  if (check.level === "conduct" && detail.access.level !== "conduct") return "the case's own instructions, which need Conduct level";
@@ -44388,9 +44533,9 @@ async function casePush(opts) {
44388
44533
  if (!detail.access.capabilities.includes("upload_document")) {
44389
44534
  throw expected(`Your access to case ${safe7(detail.code)} does not write its files: that takes Edit level, on an open case.`);
44390
44535
  }
44391
- const phaseFolders = phaseFoldersOf(detail);
44392
- assertClonePaths(root, record, phaseFolders);
44393
- const scanned = scanClone(root, phaseFolders, opts.confidential);
44536
+ const phaseFolders2 = phaseFoldersOf(detail);
44537
+ assertClonePaths(root, record, phaseFolders2);
44538
+ const scanned = scanClone(root, phaseFolders2, opts.confidential);
44394
44539
  const listing = await calls.files();
44395
44540
  const outside = outsideRun(record, listing, opts.confidential);
44396
44541
  const theirs = [...scanned.keys()].filter((rel) => isTheirs(rel) && !outside(rel.slice(0, -THEIRS_SUFFIX.length)));
@@ -44408,7 +44553,7 @@ Nothing was pushed.`
44408
44553
  for (const rel of changedPaths) {
44409
44554
  if (outside(rel) || isTheirs(rel)) continue;
44410
44555
  const file = scanned.get(rel);
44411
- const reason3 = record.files[rel]?.sha === file?.content_sha256 ? null : leftOutReason(rel, phaseFolders, detail);
44556
+ const reason3 = record.files[rel]?.sha === file?.content_sha256 ? null : leftOutReason(rel, phaseFolders2, detail);
44412
44557
  if (reason3) {
44413
44558
  leftOut.push(`${safe7(rel)}: ${reason3}`);
44414
44559
  leftOutPaths.add(rel);
@@ -44996,11 +45141,12 @@ async function casesCommand(args2) {
44996
45141
  case "link": {
44997
45142
  if (operands.length !== 1) throw usageError4("link takes one <input>: its key, as `wayai cases explain --phase <folder>` names it.");
44998
45143
  if (values.phase === void 0) throw usageError4("link takes --phase <folder>.");
44999
- linkTarget({ officialVersion: values["official-version"], received: values.received });
45144
+ linkTarget({ officialVersion: values["official-version"], received: values.received, list: values.list });
45000
45145
  return caseLink(await openCaseSession(selector), operands[0], {
45001
45146
  phase: values.phase,
45002
45147
  officialVersion: values["official-version"],
45003
- received: values.received
45148
+ received: values.received,
45149
+ list: values.list
45004
45150
  });
45005
45151
  }
45006
45152
  case "cite": {
@@ -45238,7 +45384,8 @@ Usage:
45238
45384
  wayai cases received add <file> --text <markdown file> --phase <folder> --type <type>
45239
45385
  [--title <title>] [--confidential]
45240
45386
  wayai cases link <input> --phase <folder>
45241
- --official-version <official_version_id> | --received <received_id>
45387
+ --official-version <official_version_id | output code> | --received <received_id>
45388
+ | --list
45242
45389
  wayai cases cite <input> <start>[-<end>] --phase <folder>
45243
45390
 
45244
45391
  connect Ask to connect this machine to the case, wait while you approve it
@@ -45269,7 +45416,7 @@ pull Bring the clone up to date, keeping your local changes. A file
45269
45416
  Clone and every pull then rewrite the clone's read-only mirror,
45270
45417
  ${CASE_MIRROR_DIR}/: the case, its status, evidence, agenda and
45271
45418
  deliveries of the phases under way, their linked inputs'
45272
- registered texts (each checked against its registered hash),
45419
+ texts (each checked against the hash WayAI gives for it),
45273
45420
  what changed since the last pull, and the case's package
45274
45421
  (its instructions, templates, tools and sources, each checked
45275
45422
  against the published manifest, read-only; confidential
@@ -45339,10 +45486,13 @@ received add Register a document a party sent, in one phase, with its
45339
45486
  confidential, if the case lets you write one.
45340
45487
  link Link an input of one phase (its key, as explain --phase names it):
45341
45488
  one of origin previous_output to an earlier phase's current
45342
- official version (--official-version), one of origin received to
45343
- a received document of the case (--received; its id is in its
45344
- files' names under a phase's received/). A collection input is
45345
- linked in the web app.
45489
+ official version (--official-version: its id, or the code of its
45490
+ output, as memo), one of origin received to a received document
45491
+ of the case (--received; its id is in its files' names under a
45492
+ phase's received/). --list lists the official versions an input
45493
+ of origin previous_output may link, each with the command that
45494
+ links it, and links nothing. A collection input is linked in the
45495
+ web app.
45346
45496
  cite Cite a passage of what an input links now, by its lines (as
45347
45497
  12-18, numbered as the mirror's inputs/ texts number them): the
45348
45498
  case hashes them. Any origin.
@@ -45413,7 +45563,8 @@ need it.
45413
45563
  "mark-confidential": { type: "boolean" },
45414
45564
  "mirror-only": { type: "boolean" },
45415
45565
  "official-version": { type: "string" },
45416
- received: { type: "string" }
45566
+ received: { type: "string" },
45567
+ list: { type: "boolean" }
45417
45568
  };
45418
45569
  SELECT = ["case", "org", "space"];
45419
45570
  ADMITS = {
@@ -45429,7 +45580,7 @@ need it.
45429
45580
  note: [...SELECT, "kind", "phase", "task", "origin"],
45430
45581
  "note done": SELECT,
45431
45582
  "received add": [...SELECT, "text", "phase", "type", "title", "confidential"],
45432
- link: [...SELECT, "phase", "official-version", "received"],
45583
+ link: [...SELECT, "phase", "official-version", "received", "list"],
45433
45584
  cite: [...SELECT, "phase"],
45434
45585
  clone: [...SELECT, "dir", "confidential"],
45435
45586
  // A clone names its case: pull and push take the clone (--dir), never a case.