@wayai/cli 0.3.333 → 0.3.334
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 +354 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -459,8 +459,8 @@ function setSentryUser(accessToken) {
|
|
|
459
459
|
if (!initialized) return;
|
|
460
460
|
try {
|
|
461
461
|
if (accessToken.startsWith("way_")) {
|
|
462
|
-
const
|
|
463
|
-
Sentry.setUser({ id: `token:${
|
|
462
|
+
const hash2 = __require("crypto").createHash("sha256").update(accessToken).digest("hex").slice(0, 16);
|
|
463
|
+
Sentry.setUser({ id: `token:${hash2}` });
|
|
464
464
|
return;
|
|
465
465
|
}
|
|
466
466
|
const payloadBase64 = accessToken.split(".")[1];
|
|
@@ -14648,7 +14648,7 @@ function refineHubAsCodeEvalAttachments(config, ctx) {
|
|
|
14648
14648
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: path50, message: `${name}: ${error}` });
|
|
14649
14649
|
return;
|
|
14650
14650
|
}
|
|
14651
|
-
for (const
|
|
14651
|
+
for (const hash2 of collectTurnAttachmentHashes(turn)) referencedHashes.add(hash2);
|
|
14652
14652
|
};
|
|
14653
14653
|
if (Array.isArray(cfg.evals)) {
|
|
14654
14654
|
cfg.evals.forEach((entry, e) => {
|
|
@@ -14703,12 +14703,12 @@ function refineHubAsCodeEvalAttachments(config, ctx) {
|
|
|
14703
14703
|
});
|
|
14704
14704
|
}
|
|
14705
14705
|
}
|
|
14706
|
-
for (const
|
|
14707
|
-
if (!carriedHashes.has(
|
|
14706
|
+
for (const hash2 of referencedHashes) {
|
|
14707
|
+
if (!carriedHashes.has(hash2)) {
|
|
14708
14708
|
ctx.addIssue({
|
|
14709
14709
|
code: external_exports.ZodIssueCode.custom,
|
|
14710
14710
|
path: ["eval_attachment_files"],
|
|
14711
|
-
message: `attachment ${
|
|
14711
|
+
message: `attachment ${hash2.slice(0, 12)}\u2026 is referenced by a turn but its bytes are missing from eval_attachment_files`
|
|
14712
14712
|
});
|
|
14713
14713
|
}
|
|
14714
14714
|
}
|
|
@@ -16372,7 +16372,7 @@ ${party.role}`;
|
|
|
16372
16372
|
if (new Set(body.instrument_ids).size !== body.instrument_ids.length) return { reason: "instrument_repeated", at: "instrument_ids" };
|
|
16373
16373
|
return null;
|
|
16374
16374
|
}
|
|
16375
|
-
var CASE_RECORD_CODE_PATTERN, CASE_RECORD_CODE_MAX_LENGTH, CASE_RECORD_PARTIES_MAX, CASE_RECORD_INSTRUMENTS_MAX, CASE_RECORD_ROLE_MAX_LENGTH, CASE_RECORDS_PAGE_MAX, CASE_RECORDS_QUERY_MAX_LENGTH, caseRecordPartySchema, openCaseShape, openCaseBody, previewOpenCaseShape, caseRecordParam, CASE_RECORD_STATUSES, caseRecordsQuery, CASE_STATE_SUMMARIES_MAX, caseStatesQuery, CASE_CLOSURE_REASON_MAX_LENGTH, closeCaseBody, setCaseConfidentialityBody;
|
|
16375
|
+
var CASE_RECORD_CODE_PATTERN, CASE_RECORD_CODE_MAX_LENGTH, CASE_RECORD_PARTIES_MAX, CASE_RECORD_INSTRUMENTS_MAX, CASE_RECORD_ROLE_MAX_LENGTH, CASE_RECORDS_PAGE_MAX, CASE_RECORDS_QUERY_MAX_LENGTH, caseRecordPartySchema, openCaseShape, openCaseBody, previewOpenCaseShape, caseRecordParam, CASE_RECORD_STATUSES, caseRecordsQuery, CASE_STATE_SUMMARIES_MAX, caseStatesQuery, CASE_CLOSED_REASON, CASE_CLOSURE_REASON_MAX_LENGTH, closeCaseBody, setCaseConfidentialityBody;
|
|
16376
16376
|
var init_chunk_733K4J4G = __esm({
|
|
16377
16377
|
"../../packages/core/dist/chunk-733K4J4G.js"() {
|
|
16378
16378
|
"use strict";
|
|
@@ -16427,6 +16427,7 @@ var init_chunk_733K4J4G = __esm({
|
|
|
16427
16427
|
caseStatesQuery = external_exports.object({
|
|
16428
16428
|
codes: external_exports.string().max(CASE_STATE_SUMMARIES_MAX * (CASE_RECORD_CODE_MAX_LENGTH + 1)).transform((codes) => codes.split(",")).pipe(external_exports.array(external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN)).min(1).max(CASE_STATE_SUMMARIES_MAX))
|
|
16429
16429
|
});
|
|
16430
|
+
CASE_CLOSED_REASON = "case_closed";
|
|
16430
16431
|
CASE_CLOSURE_REASON_MAX_LENGTH = 2e3;
|
|
16431
16432
|
closeCaseBody = external_exports.object({
|
|
16432
16433
|
outcome_code: external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_CODE_PATTERN),
|
|
@@ -20036,9 +20037,9 @@ function oldLayoutEntries(root, skills, oldLayout) {
|
|
|
20036
20037
|
function assertOldLayoutConvertible(root, skills, oldLayout, pullCommand3) {
|
|
20037
20038
|
const { leftover } = oldLayoutEntries(root, skills, oldLayout);
|
|
20038
20039
|
if (leftover.length === 0) return;
|
|
20039
|
-
const
|
|
20040
|
+
const one4 = leftover.length === 1;
|
|
20040
20041
|
throw expected(
|
|
20041
|
-
`${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 ${
|
|
20042
|
+
`${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 ${one4 ? "it" : "them"} out of ${path8.basename(root)}/ (a knowledge backup belongs outside the workspace), then run \`${pullCommand3}\` again. Nothing was written.`
|
|
20042
20043
|
);
|
|
20043
20044
|
}
|
|
20044
20045
|
function removeConvertedOldResources(root, skills, log, opts = {}) {
|
|
@@ -20579,6 +20580,14 @@ var init_api_client = __esm({
|
|
|
20579
20580
|
const qs = outputId ? `?${new URLSearchParams({ output_id: outputId })}` : "";
|
|
20580
20581
|
return this.request("GET", `${casePath(ref)}/phases/${encodeURIComponent(phaseId)}/checks${qs}`);
|
|
20581
20582
|
}
|
|
20583
|
+
/** Graph review's graph (D12); confidential content only when `confidential` is asked, which only its caller decides. */
|
|
20584
|
+
async getCaseReview(ref, confidential) {
|
|
20585
|
+
return this.request("GET", `${casePath(ref)}/review${confidential ? "?confidential=true" : ""}`);
|
|
20586
|
+
}
|
|
20587
|
+
/** A verdict on one pair of the graph, named by the revision and hashes it was read at; the server derives its round. */
|
|
20588
|
+
async recordCaseItemReview(ref, body) {
|
|
20589
|
+
return this.request("POST", `${casePath(ref)}/review/verdicts`, body);
|
|
20590
|
+
}
|
|
20582
20591
|
/** Register a received document: its fields, its file under the name it is kept by, and its Markdown text, in one multipart request. */
|
|
20583
20592
|
async registerCaseReceivedDocument(ref, document, file, text5) {
|
|
20584
20593
|
const form2 = new FormData();
|
|
@@ -22387,8 +22396,8 @@ function generateCodeVerifier() {
|
|
|
22387
22396
|
return crypto3.randomBytes(32).toString("base64url");
|
|
22388
22397
|
}
|
|
22389
22398
|
async function generateCodeChallenge(verifier) {
|
|
22390
|
-
const
|
|
22391
|
-
return
|
|
22399
|
+
const hash2 = crypto3.createHash("sha256").update(verifier).digest();
|
|
22400
|
+
return hash2.toString("base64url");
|
|
22392
22401
|
}
|
|
22393
22402
|
function generateState() {
|
|
22394
22403
|
return crypto3.randomBytes(16).toString("base64url");
|
|
@@ -23712,13 +23721,13 @@ function resolveTurnAttachments(hubFolder, turn, label3, bytesByHash) {
|
|
|
23712
23721
|
);
|
|
23713
23722
|
}
|
|
23714
23723
|
const data = fs11.readFileSync(abs);
|
|
23715
|
-
const
|
|
23724
|
+
const hash2 = computeHash(data);
|
|
23716
23725
|
const fileName = path14.basename(abs);
|
|
23717
23726
|
const mimeType = guessMimeType(fileName) ?? "application/octet-stream";
|
|
23718
|
-
refs.push({ hash, file_name: fileName, mime_type: mimeType, file_size: stat2.size });
|
|
23719
|
-
if (!bytesByHash.has(
|
|
23720
|
-
bytesByHash.set(
|
|
23721
|
-
hash,
|
|
23727
|
+
refs.push({ hash: hash2, file_name: fileName, mime_type: mimeType, file_size: stat2.size });
|
|
23728
|
+
if (!bytesByHash.has(hash2)) {
|
|
23729
|
+
bytesByHash.set(hash2, {
|
|
23730
|
+
hash: hash2,
|
|
23722
23731
|
content_base64: data.toString("base64"),
|
|
23723
23732
|
file_name: fileName,
|
|
23724
23733
|
mime_type: mimeType,
|
|
@@ -23896,10 +23905,10 @@ function applyCallOpeningFiles(hubFolder, payload) {
|
|
|
23896
23905
|
throw expected(`${label3}: file "${opening.file}" is ${(stat2.size / 1024 / 1024).toFixed(1)} MB, over the ${CALL_OPENING_MAX_BYTES / 1024 / 1024} MB limit.`);
|
|
23897
23906
|
}
|
|
23898
23907
|
const bytes = fs12.readFileSync(abs);
|
|
23899
|
-
const
|
|
23908
|
+
const hash2 = computeHash(bytes);
|
|
23900
23909
|
const { file: _file, ...rest } = opening;
|
|
23901
|
-
openings[language] = { ...rest, hash };
|
|
23902
|
-
if (!carriers.has(
|
|
23910
|
+
openings[language] = { ...rest, hash: hash2 };
|
|
23911
|
+
if (!carriers.has(hash2)) carriers.set(hash2, { hash: hash2, content_base64: bytes.toString("base64") });
|
|
23903
23912
|
}
|
|
23904
23913
|
}
|
|
23905
23914
|
if (carriers.size > 0) payload.call_opening_files = [...carriers.values()];
|
|
@@ -23916,9 +23925,9 @@ function rewriteCallOpeningsToLocalPaths(payload) {
|
|
|
23916
23925
|
const carrier = byHash.get(opening.hash);
|
|
23917
23926
|
const ext = carrier?.content_type === "audio/mp4" ? ".m4a" : ".mp3";
|
|
23918
23927
|
const relPath = `${CALL_OPENINGS_DIR}/${slugify2(agent.name)}-${language}${ext}`;
|
|
23919
|
-
const { hash, ...rest } = opening;
|
|
23928
|
+
const { hash: hash2, ...rest } = opening;
|
|
23920
23929
|
openings[language] = { ...rest, file: relPath };
|
|
23921
|
-
if (carrier?.download_url) downloads.push({ relPath, url: carrier.download_url, hash });
|
|
23930
|
+
if (carrier?.download_url) downloads.push({ relPath, url: carrier.download_url, hash: hash2 });
|
|
23922
23931
|
}
|
|
23923
23932
|
}
|
|
23924
23933
|
delete payload.call_opening_files;
|
|
@@ -25294,8 +25303,8 @@ function readCss(source, attribute) {
|
|
|
25294
25303
|
stack.push({ prelude: text5.trim(), body: "" });
|
|
25295
25304
|
text5 = "";
|
|
25296
25305
|
} else if (ch === "}") {
|
|
25297
|
-
const
|
|
25298
|
-
if (
|
|
25306
|
+
const block2 = stack.pop();
|
|
25307
|
+
if (block2) declare(block2.body + text5, [...stack.map((b) => b.prelude), block2.prelude]);
|
|
25299
25308
|
text5 = "";
|
|
25300
25309
|
} else if (ch === ";") {
|
|
25301
25310
|
if (stack.length > 0) stack[stack.length - 1].body += `${text5};`;
|
|
@@ -38705,6 +38714,66 @@ var init_case_records = __esm({
|
|
|
38705
38714
|
}
|
|
38706
38715
|
});
|
|
38707
38716
|
|
|
38717
|
+
// ../../packages/core/dist/contracts/case-review.js
|
|
38718
|
+
var CASE_REVIEW_ROUNDS_MAX, CASE_REVIEW_REASON_MAX_LENGTH, CASE_REVIEW_PAIR_UNKNOWN_REASON, CASE_REVIEW_CHAIN_STOPPED_REASON, CASE_REVIEW_TOO_LARGE_REASON, CASE_REVIEW_VERDICTS_FULL_REASON, CASE_REVIEW_CONFIDENTIAL_OMITTED, caseReviewItemKeySchema, hash, caseReviewQuery, pairFields, recordCaseItemReviewBody, keepCaseItemBody, acceptCaseReviewChainBody;
|
|
38719
|
+
var init_case_review = __esm({
|
|
38720
|
+
"../../packages/core/dist/contracts/case-review.js"() {
|
|
38721
|
+
"use strict";
|
|
38722
|
+
init_chunk_VROZDNLV();
|
|
38723
|
+
init_chunk_PFPADFUC();
|
|
38724
|
+
init_chunk_KWRHZBGU();
|
|
38725
|
+
init_chunk_3T3D7LTE();
|
|
38726
|
+
init_chunk_M2T55BV6();
|
|
38727
|
+
init_chunk_VYINA6YP();
|
|
38728
|
+
init_chunk_ZVXO3XL6();
|
|
38729
|
+
init_chunk_FBV7NLKO();
|
|
38730
|
+
init_chunk_WEXVYJ5H();
|
|
38731
|
+
init_chunk_HZ6CADSY();
|
|
38732
|
+
init_chunk_ICYO56QW();
|
|
38733
|
+
init_chunk_WFQDSQJK();
|
|
38734
|
+
init_chunk_ZTNFLGW5();
|
|
38735
|
+
init_zod();
|
|
38736
|
+
CASE_REVIEW_ROUNDS_MAX = 5;
|
|
38737
|
+
CASE_REVIEW_REASON_MAX_LENGTH = 8 * 1024;
|
|
38738
|
+
CASE_REVIEW_PAIR_UNKNOWN_REASON = "review_pair_unknown";
|
|
38739
|
+
CASE_REVIEW_CHAIN_STOPPED_REASON = "review_chain_stopped";
|
|
38740
|
+
CASE_REVIEW_TOO_LARGE_REASON = "review_too_large";
|
|
38741
|
+
CASE_REVIEW_VERDICTS_FULL_REASON = "verdicts_full";
|
|
38742
|
+
CASE_REVIEW_CONFIDENTIAL_OMITTED = "confidential_omitted";
|
|
38743
|
+
caseReviewItemKeySchema = external_exports.string().max(CASE_CODE_MAX_LENGTH * 2 + 1).refine((key) => {
|
|
38744
|
+
const slash = key.indexOf("/");
|
|
38745
|
+
return slash > 0 && CASE_PHASE_FOLDER_PATTERN.test(key.slice(0, slash)) && CASE_CODE_PATTERN.test(key.slice(slash + 1));
|
|
38746
|
+
}, "An item is named by its phase folder and code");
|
|
38747
|
+
hash = caseFileShaSchema;
|
|
38748
|
+
caseReviewQuery = external_exports.object({
|
|
38749
|
+
confidential: external_exports.enum(["true", "false"]).optional().transform((value) => value === "true")
|
|
38750
|
+
});
|
|
38751
|
+
pairFields = {
|
|
38752
|
+
/** The revision the pair was computed at, as the graph read named it. */
|
|
38753
|
+
revision_id: uuidSchema,
|
|
38754
|
+
source: caseReviewItemKeySchema,
|
|
38755
|
+
source_hash: hash,
|
|
38756
|
+
neighbor: caseReviewItemKeySchema,
|
|
38757
|
+
neighbor_hash: hash,
|
|
38758
|
+
reason: external_exports.string().trim().min(1).max(CASE_REVIEW_REASON_MAX_LENGTH),
|
|
38759
|
+
/**
|
|
38760
|
+
* The writer's own mark: the verdict reaches only holders of the Confidential right asking for it. Taken only with
|
|
38761
|
+
* `confidential: true` (the right, asking); otherwise 400 `confidential_mark_refused`.
|
|
38762
|
+
*/
|
|
38763
|
+
mark_confidential: external_exports.boolean().default(false),
|
|
38764
|
+
/** The graph it was computed on was read with `confidential=true`. */
|
|
38765
|
+
confidential: external_exports.boolean().default(false)
|
|
38766
|
+
};
|
|
38767
|
+
recordCaseItemReviewBody = external_exports.object({ ...pairFields, verdict: external_exports.enum(["consistent", "needs_change"]) }).strict();
|
|
38768
|
+
keepCaseItemBody = external_exports.object(pairFields).strict();
|
|
38769
|
+
acceptCaseReviewChainBody = external_exports.object({
|
|
38770
|
+
item: caseReviewItemKeySchema,
|
|
38771
|
+
revision_id: uuidSchema,
|
|
38772
|
+
confidential: external_exports.boolean().default(false)
|
|
38773
|
+
}).strict();
|
|
38774
|
+
}
|
|
38775
|
+
});
|
|
38776
|
+
|
|
38708
38777
|
// src/cases/case-local-files.ts
|
|
38709
38778
|
import * as fs30 from "fs";
|
|
38710
38779
|
import * as path42 from "path";
|
|
@@ -39966,13 +40035,13 @@ var init_plan = __esm({
|
|
|
39966
40035
|
|
|
39967
40036
|
// src/data/files-sync/headers.ts
|
|
39968
40037
|
function ifMatchValue(raw) {
|
|
39969
|
-
const
|
|
39970
|
-
if (!/^[\x21\x23-\x7e]+$/.test(
|
|
40038
|
+
const hash2 = raw.trim().replace(/^W\//, "").replace(/^"(.*)"$/, "$1");
|
|
40039
|
+
if (!/^[\x21\x23-\x7e]+$/.test(hash2)) {
|
|
39971
40040
|
throw expected(
|
|
39972
40041
|
`--if-match must be the file's content hash (its ETag, or content_sha256 from \`wayai files get --meta\`), got ${JSON.stringify(raw)}.`
|
|
39973
40042
|
);
|
|
39974
40043
|
}
|
|
39975
|
-
return `"${
|
|
40044
|
+
return `"${hash2}"`;
|
|
39976
40045
|
}
|
|
39977
40046
|
function labelValue(raw) {
|
|
39978
40047
|
if (raw.length === 0 || !/^[\x20-\x7e]+$/.test(raw)) {
|
|
@@ -40178,9 +40247,9 @@ async function pullFiles(opts) {
|
|
|
40178
40247
|
conflicts.push({ rel: w.rel, reason: "edited_while_pulling" });
|
|
40179
40248
|
continue;
|
|
40180
40249
|
}
|
|
40181
|
-
const
|
|
40250
|
+
const hash2 = computeHash(bytes);
|
|
40182
40251
|
writeLocal(dir, w.rel, bytes);
|
|
40183
|
-
record.files[w.rel] = { version, content_sha256:
|
|
40252
|
+
record.files[w.rel] = { version, content_sha256: hash2 };
|
|
40184
40253
|
changes.push(`${local.has(w.rel) ? MARK.update : MARK.create} ${safe(w.rel)}`);
|
|
40185
40254
|
}
|
|
40186
40255
|
} finally {
|
|
@@ -40934,9 +41003,9 @@ var init_case_files2 = __esm({
|
|
|
40934
41003
|
}
|
|
40935
41004
|
pacer;
|
|
40936
41005
|
/** One call, paced; `raw` lets the caller read the `ApiError` itself. */
|
|
40937
|
-
async run(
|
|
41006
|
+
async run(call3, raw = false) {
|
|
40938
41007
|
try {
|
|
40939
|
-
return await this.pacer.run(
|
|
41008
|
+
return await this.pacer.run(call3);
|
|
40940
41009
|
} catch (err) {
|
|
40941
41010
|
throw raw ? err : caseCallFailure(err, this.session.connection);
|
|
40942
41011
|
}
|
|
@@ -40993,6 +41062,206 @@ var init_case_files2 = __esm({
|
|
|
40993
41062
|
}
|
|
40994
41063
|
});
|
|
40995
41064
|
|
|
41065
|
+
// src/cases/case-review.ts
|
|
41066
|
+
function reviewFailure(err, session) {
|
|
41067
|
+
if (err instanceof ApiError && err.status >= 400 && err.status < 500) {
|
|
41068
|
+
const code2 = session.connection.code;
|
|
41069
|
+
switch (extractApiErrorReason(err)) {
|
|
41070
|
+
case CASE_REVIEW_TOO_LARGE_REASON:
|
|
41071
|
+
return expected(`Case ${code2}'s review is larger than one review may read, so it cannot be computed.`);
|
|
41072
|
+
case CASE_REVIEW_PAIR_UNKNOWN_REASON:
|
|
41073
|
+
return expected(
|
|
41074
|
+
"The case's review holds no pair of those items with those hashes at that revision (a value not copied as the review printed it, or --confidential not as the review was read). Nothing was recorded. Run the command `wayai cases review` prints for the pair."
|
|
41075
|
+
);
|
|
41076
|
+
case CASE_REVIEW_CHAIN_STOPPED_REASON:
|
|
41077
|
+
return expected(`This pair's chain stopped after ${CASE_REVIEW_ROUNDS_MAX} rounds, so it takes no verdict. ${WEB_ONLY_NOTICE}`);
|
|
41078
|
+
case CASE_REVIEW_VERDICTS_FULL_REASON:
|
|
41079
|
+
return expected(`Case ${code2} holds as many verdicts as it may: nothing was recorded.`);
|
|
41080
|
+
case CASE_CLOSED_REASON:
|
|
41081
|
+
return expected(`Case ${code2} is closed: it takes no verdict.`);
|
|
41082
|
+
case "revision_unknown":
|
|
41083
|
+
return expected(`Case ${code2} has no revision of that id you may read. Read the review again: \`wayai cases review\`.`);
|
|
41084
|
+
case "reason_too_long":
|
|
41085
|
+
return expected("The reason is longer than the case takes.");
|
|
41086
|
+
}
|
|
41087
|
+
}
|
|
41088
|
+
return caseCallFailure(err, session.connection);
|
|
41089
|
+
}
|
|
41090
|
+
async function call2(session, run) {
|
|
41091
|
+
try {
|
|
41092
|
+
return await run();
|
|
41093
|
+
} catch (err) {
|
|
41094
|
+
throw reviewFailure(err, session);
|
|
41095
|
+
}
|
|
41096
|
+
}
|
|
41097
|
+
async function requireConfidential(session) {
|
|
41098
|
+
const detail = (await call2(session, () => session.api.getCase(session.connection))).data;
|
|
41099
|
+
if (!detail.access.capabilities.includes("read_confidential")) {
|
|
41100
|
+
throw expected(
|
|
41101
|
+
`This machine's authorization on case ${one3(detail.code)} does not hold the Confidential right, so --confidential reads nothing more. Run it without --confidential.`
|
|
41102
|
+
);
|
|
41103
|
+
}
|
|
41104
|
+
}
|
|
41105
|
+
function block(label3, text5, none) {
|
|
41106
|
+
if (text5 === null) {
|
|
41107
|
+
console.log(` ${label3}: ${none}`);
|
|
41108
|
+
return;
|
|
41109
|
+
}
|
|
41110
|
+
console.log(` ${label3}:`);
|
|
41111
|
+
for (const line of sanitizeTerminalText(text5).split("\n")) console.log(` | ${line}`);
|
|
41112
|
+
}
|
|
41113
|
+
function verdictCommand(connection, graph, pair) {
|
|
41114
|
+
return `wayai cases review verdict <${VERDICTS.join("|")}> ${one3(pair.source)} ${one3(pair.neighbor)} --revision ${one3(graph.revision_id ?? "")} --source-hash ${one3(pair.source_hash)} --neighbor-hash ${one3(pair.neighbor_hash)}${graph.confidential ? " --confidential" : ""} --case ${one3(connection.code)} --org ${one3(connection.org_id)} --space ${one3(connection.space_id)} --reason "<why>"`;
|
|
41115
|
+
}
|
|
41116
|
+
async function caseReview(session, opts) {
|
|
41117
|
+
if (opts.confidential) await requireConfidential(session);
|
|
41118
|
+
const graph = (await call2(session, () => session.api.getCaseReview(session.connection, opts.confidential))).data;
|
|
41119
|
+
if (graph.stopped.length > 0) process.exitCode = 1;
|
|
41120
|
+
if (opts.json) {
|
|
41121
|
+
console.log(JSON.stringify(graph, null, 2));
|
|
41122
|
+
return;
|
|
41123
|
+
}
|
|
41124
|
+
printReview(session.connection, graph);
|
|
41125
|
+
}
|
|
41126
|
+
function printReview(connection, graph) {
|
|
41127
|
+
const { code: code2 } = connection;
|
|
41128
|
+
const omitted = graph.warnings.some((w) => w.code === CASE_REVIEW_CONFIDENTIAL_OMITTED);
|
|
41129
|
+
const notice = () => {
|
|
41130
|
+
if (omitted) console.log("\nConfidential content is left out of this review unless you pass --confidential.");
|
|
41131
|
+
};
|
|
41132
|
+
if (graph.revision_id === null) {
|
|
41133
|
+
console.log(`Case ${code2} has no revision you read here: nothing to review.`);
|
|
41134
|
+
notice();
|
|
41135
|
+
return;
|
|
41136
|
+
}
|
|
41137
|
+
console.log(`Review of case ${code2} at revision ${one3(graph.revision_id)}${graph.confidential ? ", with confidential content" : ""}.`);
|
|
41138
|
+
console.log(graph.base_revision_id ? `Base: revision ${one3(graph.base_revision_id)}. Nothing you read here is pending.` : "Base: each item's own, below. Something you read here is pending.");
|
|
41139
|
+
const titles = new Map(graph.items.map((item) => [item.key, item.title]));
|
|
41140
|
+
if (graph.items.length) {
|
|
41141
|
+
console.log(`
|
|
41142
|
+
Changed items (${graph.items.length}):`);
|
|
41143
|
+
for (const item of graph.items) {
|
|
41144
|
+
console.log(` ${one3(item.key)}, "${one3(item.title)}" (${item.state}, round ${item.round}), in ${one3(item.path)}${item.base_revision_id ? `, since revision ${one3(item.base_revision_id)}` : ""}`);
|
|
41145
|
+
if (item.causes.length) console.log(` because: ${item.causes.map(one3).join("; ")}`);
|
|
41146
|
+
block("before", item.before, "not there at its base");
|
|
41147
|
+
block("now", item.text, "removed");
|
|
41148
|
+
}
|
|
41149
|
+
}
|
|
41150
|
+
if (graph.pairs.length) {
|
|
41151
|
+
console.log(`
|
|
41152
|
+
Pairs awaiting a verdict (${graph.pairs.length}):`);
|
|
41153
|
+
for (const pair of graph.pairs) {
|
|
41154
|
+
const source = titles.get(pair.source);
|
|
41155
|
+
console.log(` ${one3(pair.source)}${source ? ` "${one3(source)}"` : ""} \u2192 ${one3(pair.neighbor)} "${one3(pair.neighbor_title)}" (round ${pair.round} of ${CASE_REVIEW_ROUNDS_MAX}), in ${one3(pair.path)}`);
|
|
41156
|
+
if (pair.reasons.length) console.log(` connected: ${pair.reasons.map(one3).join("; ")}`);
|
|
41157
|
+
console.log(` ${verdictCommand(connection, graph, pair)}`);
|
|
41158
|
+
}
|
|
41159
|
+
}
|
|
41160
|
+
if (graph.waiting.length) {
|
|
41161
|
+
console.log(`
|
|
41162
|
+
Waiting for a change (${graph.waiting.length}):`);
|
|
41163
|
+
for (const w of graph.waiting) {
|
|
41164
|
+
console.log(` ${one3(w.source)} \u2192 ${one3(w.neighbor)} (round ${w.round}): needs a change: ${one3(w.reason)}`);
|
|
41165
|
+
console.log(` waits until ${one3(w.neighbor)} changes`);
|
|
41166
|
+
}
|
|
41167
|
+
}
|
|
41168
|
+
if (graph.stopped.length) {
|
|
41169
|
+
console.log(`
|
|
41170
|
+
Stopped chains (${graph.stopped.length}): each took more than ${CASE_REVIEW_ROUNDS_MAX} rounds, so it takes no verdict.`);
|
|
41171
|
+
for (const s of graph.stopped) {
|
|
41172
|
+
const waiting = s.waiting_sources.length ? `; waiting on it: ${s.waiting_sources.map(one3).join(", ")}` : "";
|
|
41173
|
+
console.log(` ${one3(s.key)}, "${one3(s.title)}" (round ${s.round})${s.base_revision_id ? `, since revision ${one3(s.base_revision_id)}` : ""}${waiting}`);
|
|
41174
|
+
}
|
|
41175
|
+
console.log(` ${WEB_ONLY_NOTICE}`);
|
|
41176
|
+
}
|
|
41177
|
+
const warnings = graph.warnings.filter((w) => w.code !== CASE_REVIEW_CONFIDENTIAL_OMITTED);
|
|
41178
|
+
if (warnings.length) {
|
|
41179
|
+
console.log(`
|
|
41180
|
+
For a person to look at (${warnings.length}):`);
|
|
41181
|
+
for (const w of warnings) {
|
|
41182
|
+
const where = [w.path && one3(w.path), w.subject && one3(w.subject)].filter(Boolean).join(": ");
|
|
41183
|
+
console.log(` ${WARNINGS[w.code] ?? one3(w.code)}${where ? ` [${where}]` : ""}`);
|
|
41184
|
+
}
|
|
41185
|
+
}
|
|
41186
|
+
if (!graph.items.length && !graph.pairs.length && !graph.waiting.length && !graph.stopped.length) console.log("Nothing awaits review.");
|
|
41187
|
+
notice();
|
|
41188
|
+
}
|
|
41189
|
+
function verdictBody(opts) {
|
|
41190
|
+
if (!VERDICTS.includes(opts.verdict)) {
|
|
41191
|
+
throw expected(opts.verdict === "keep" ? `Keep is a person's, in the WayAI web app: this CLI records ${VERDICTS.join(" or ")}.` : `A verdict is ${VERDICTS.join(" or ")}.`);
|
|
41192
|
+
}
|
|
41193
|
+
if (opts.markConfidential && !opts.confidential) {
|
|
41194
|
+
throw expected("--mark-confidential is taken only with --confidential, on a pair read with it.");
|
|
41195
|
+
}
|
|
41196
|
+
const parsed = recordCaseItemReviewBody.safeParse({
|
|
41197
|
+
verdict: opts.verdict,
|
|
41198
|
+
source: opts.source,
|
|
41199
|
+
neighbor: opts.neighbor,
|
|
41200
|
+
revision_id: opts.revision,
|
|
41201
|
+
source_hash: opts.sourceHash,
|
|
41202
|
+
neighbor_hash: opts.neighborHash,
|
|
41203
|
+
reason: opts.reason,
|
|
41204
|
+
mark_confidential: opts.markConfidential,
|
|
41205
|
+
confidential: opts.confidential
|
|
41206
|
+
});
|
|
41207
|
+
if (parsed.success) return parsed.data;
|
|
41208
|
+
const issue = parsed.error.issues[0];
|
|
41209
|
+
if (issue?.path[0] === "reason" && issue.code === "too_big") {
|
|
41210
|
+
throw expected(`--reason is longer than ${CASE_REVIEW_REASON_MAX_LENGTH} characters: shorten it.`);
|
|
41211
|
+
}
|
|
41212
|
+
const FIELDS = {
|
|
41213
|
+
source: "<source> is an item as the review names it: {phase folder}/{code}",
|
|
41214
|
+
neighbor: "<neighbor> is an item as the review names it: {phase folder}/{code}",
|
|
41215
|
+
revision_id: "--revision takes the revision the review was read at, as `wayai cases review` prints it",
|
|
41216
|
+
source_hash: "--source-hash takes the source's hash, as `wayai cases review` prints it",
|
|
41217
|
+
neighbor_hash: "--neighbor-hash takes the neighbor's hash, as `wayai cases review` prints it",
|
|
41218
|
+
reason: "--reason takes why, in words: it is required, and cannot be empty"
|
|
41219
|
+
};
|
|
41220
|
+
const field = String(issue?.path[0] ?? "");
|
|
41221
|
+
throw expected(FIELDS[field] ?? `The verdict is refused: ${issue?.message ?? "not of its shape"}.`);
|
|
41222
|
+
}
|
|
41223
|
+
async function caseReviewVerdict(session, body, opts) {
|
|
41224
|
+
if (body.confidential) await requireConfidential(session);
|
|
41225
|
+
const review = (await call2(session, () => session.api.recordCaseItemReview(session.connection, body))).data;
|
|
41226
|
+
if (opts.json) {
|
|
41227
|
+
console.log(JSON.stringify(review, null, 2));
|
|
41228
|
+
return;
|
|
41229
|
+
}
|
|
41230
|
+
console.log(`Recorded ${review.verdict === "needs_change" ? "needs change" : review.verdict} on ${one3(review.source)} \u2192 ${one3(review.neighbor)}, round ${review.round} of ${CASE_REVIEW_ROUNDS_MAX}${review.confidential ? ", confidential" : ""}: ${review.review_id}`);
|
|
41231
|
+
if (review.verdict === "needs_change") {
|
|
41232
|
+
console.log(`The pair waits until ${one3(review.neighbor)} changes: change it, push, then read the review again.`);
|
|
41233
|
+
}
|
|
41234
|
+
}
|
|
41235
|
+
var VERDICTS, WEB_ONLY_NOTICE, one3, WARNINGS;
|
|
41236
|
+
var init_case_review2 = __esm({
|
|
41237
|
+
"src/cases/case-review.ts"() {
|
|
41238
|
+
"use strict";
|
|
41239
|
+
init_api_client();
|
|
41240
|
+
init_errors3();
|
|
41241
|
+
init_expected();
|
|
41242
|
+
init_terminal_output();
|
|
41243
|
+
init_case_session();
|
|
41244
|
+
init_case_records();
|
|
41245
|
+
init_case_review();
|
|
41246
|
+
VERDICTS = recordCaseItemReviewBody.shape.verdict.options;
|
|
41247
|
+
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.";
|
|
41248
|
+
one3 = (value) => sanitizeTerminalText(value).replace(/\s*\n\s*/g, " ");
|
|
41249
|
+
WARNINGS = {
|
|
41250
|
+
outside_item: "text outside any item",
|
|
41251
|
+
new_document_outside_item: "a new document with text outside any item",
|
|
41252
|
+
front_matter_changed: "its header changed",
|
|
41253
|
+
document_removed: "a document was removed",
|
|
41254
|
+
title_changed: "a title changed",
|
|
41255
|
+
item_unknown: "it cites an item no document holds",
|
|
41256
|
+
documents_unreadable: "documents that could not be read",
|
|
41257
|
+
piece_changed: "a file piece changed",
|
|
41258
|
+
csv_unreadable: "a CSV that could not be read",
|
|
41259
|
+
name_without_item: "a CSV name no item cites",
|
|
41260
|
+
[CASE_REVIEW_CONFIDENTIAL_OMITTED]: "confidential content was left out"
|
|
41261
|
+
};
|
|
41262
|
+
}
|
|
41263
|
+
});
|
|
41264
|
+
|
|
40996
41265
|
// src/commands/cases.ts
|
|
40997
41266
|
var cases_exports = {};
|
|
40998
41267
|
__export(cases_exports, {
|
|
@@ -41024,9 +41293,10 @@ async function casesCommand(args2) {
|
|
|
41024
41293
|
const { values, positionals } = parsed;
|
|
41025
41294
|
const [sub, ...rest] = positionals;
|
|
41026
41295
|
if (sub === void 0) throw usageError4("No subcommand given.");
|
|
41027
|
-
const twoWords = sub === "note" && rest[0] === "done" || sub === "received" && rest[0] === "add";
|
|
41296
|
+
const twoWords = sub === "note" && rest[0] === "done" || sub === "received" && rest[0] === "add" || sub === "review" && rest[0] === "verdict";
|
|
41028
41297
|
const name = twoWords ? `${sub} ${rest[0]}` : sub;
|
|
41029
41298
|
const operands = twoWords ? rest.slice(1) : rest;
|
|
41299
|
+
if (sub === "review" && (rest[0] === "keep" || rest[0] === "accept")) throw expected(WEB_ONLY_NOTICE);
|
|
41030
41300
|
const admitted = ADMITS[name];
|
|
41031
41301
|
if (!admitted) throw usageError4(`Unknown subcommand ${JSON.stringify(sanitizeTerminalText(name))}.`);
|
|
41032
41302
|
const extra = Object.keys(values).filter((key) => values[key] !== void 0 && !admitted.includes(key));
|
|
@@ -41089,6 +41359,25 @@ async function casesCommand(args2) {
|
|
|
41089
41359
|
if (limit !== void 0 && !(limit >= 1 && limit <= LOG_MAX)) throw usageError4(`--limit takes 1 to ${LOG_MAX}.`);
|
|
41090
41360
|
return caseLog(selector, { limit, json, confidential: values.confidential === true });
|
|
41091
41361
|
}
|
|
41362
|
+
case "review":
|
|
41363
|
+
takesNone();
|
|
41364
|
+
return caseReview(await openCaseSession(selector), { json, confidential: values.confidential === true });
|
|
41365
|
+
case "review verdict": {
|
|
41366
|
+
if (operands.length !== 3) throw usageError4("review verdict takes consistent|needs_change, then <source> and <neighbor>.");
|
|
41367
|
+
const [verdict, source, neighbor] = operands;
|
|
41368
|
+
const body = verdictBody({
|
|
41369
|
+
verdict,
|
|
41370
|
+
source,
|
|
41371
|
+
neighbor,
|
|
41372
|
+
reason: values.reason,
|
|
41373
|
+
revision: values.revision,
|
|
41374
|
+
sourceHash: values["source-hash"],
|
|
41375
|
+
neighborHash: values["neighbor-hash"],
|
|
41376
|
+
markConfidential: values["mark-confidential"] === true,
|
|
41377
|
+
confidential: values.confidential === true
|
|
41378
|
+
});
|
|
41379
|
+
return caseReviewVerdict(await openCaseSession(selector), body, { json });
|
|
41380
|
+
}
|
|
41092
41381
|
case "note":
|
|
41093
41382
|
if (operands.length !== 1) throw usageError4("note takes its text as one argument: quote it.");
|
|
41094
41383
|
return caseNote(await openCaseSession(selector), operands[0], { kind: values.kind, phase: values.phase, task: values.task, origin: values.origin });
|
|
@@ -41296,6 +41585,7 @@ var init_cases = __esm({
|
|
|
41296
41585
|
"use strict";
|
|
41297
41586
|
init_case_agents();
|
|
41298
41587
|
init_case_records();
|
|
41588
|
+
init_case_review();
|
|
41299
41589
|
init_api_client();
|
|
41300
41590
|
init_auth();
|
|
41301
41591
|
init_errors3();
|
|
@@ -41307,6 +41597,7 @@ var init_cases = __esm({
|
|
|
41307
41597
|
init_case_session();
|
|
41308
41598
|
init_case_work();
|
|
41309
41599
|
init_case_files2();
|
|
41600
|
+
init_case_review2();
|
|
41310
41601
|
init_case_clone_record();
|
|
41311
41602
|
init_case_tokens();
|
|
41312
41603
|
PICKUP_POLL_INTERVAL_MS = 5e3;
|
|
@@ -41323,6 +41614,12 @@ Usage:
|
|
|
41323
41614
|
[--dir <clone>] [--confidential]
|
|
41324
41615
|
wayai cases log [--limit <n>] [--json] [--confidential]
|
|
41325
41616
|
|
|
41617
|
+
wayai cases review [--json] [--confidential]
|
|
41618
|
+
wayai cases review verdict consistent|needs_change <source> <neighbor>
|
|
41619
|
+
--reason "<why>" --revision <revision_id>
|
|
41620
|
+
--source-hash <hash> --neighbor-hash <hash>
|
|
41621
|
+
[--confidential [--mark-confidential]] [--json]
|
|
41622
|
+
|
|
41326
41623
|
wayai cases brief [--json]
|
|
41327
41624
|
wayai cases next [--json]
|
|
41328
41625
|
wayai cases explain [--phase <folder>] [--json]
|
|
@@ -41365,6 +41662,21 @@ push Send the clone's changes as one revision, all of it or none. Each
|
|
|
41365
41662
|
--prune. --dry-run shows what would be sent. A symlink is never
|
|
41366
41663
|
followed: one in the clone refuses the push.
|
|
41367
41664
|
log The case's revisions, newest first (--limit, default 20).
|
|
41665
|
+
review Graph review, as WayAI computes it over the case's files: each item
|
|
41666
|
+
changed, removed or affected since its base (its text before and
|
|
41667
|
+
now), each pair of it and a connected item awaiting a verdict, the
|
|
41668
|
+
pairs waiting for a change, and the stopped chains. Each pair
|
|
41669
|
+
prints the exact \`review verdict\` command that records a verdict
|
|
41670
|
+
on it. Exits 1 when a chain stopped: past ${CASE_REVIEW_ROUNDS_MAX} rounds it takes no
|
|
41671
|
+
verdict until a person accepts it, in the web app.
|
|
41672
|
+
review verdict Record consistent or needs_change on one pair, with a reason,
|
|
41673
|
+
naming the revision and hashes the review printed, so it holds
|
|
41674
|
+
for the text you read: if the case changed since, the changed
|
|
41675
|
+
pair awaits a verdict again in the next review. WayAI counts
|
|
41676
|
+
the round. --mark-confidential (with --confidential) lets
|
|
41677
|
+
only holders of the Confidential right read it. Keeping an item
|
|
41678
|
+
and accepting a stopped chain are a person's, in the web app:
|
|
41679
|
+
this CLI offers neither.
|
|
41368
41680
|
brief The case at a glance: status, phases under way, deadlines, open
|
|
41369
41681
|
tasks, open pending items and next steps.
|
|
41370
41682
|
next What to do next on the phases under way, then what waits on
|
|
@@ -41386,7 +41698,8 @@ received add Register a document a party sent, in one phase, with its
|
|
|
41386
41698
|
confidential, if the case lets you write one.
|
|
41387
41699
|
|
|
41388
41700
|
Confidential content is never asked for unless you pass --confidential:
|
|
41389
|
-
without it, clone, pull, push and log leave every confidential file alone
|
|
41701
|
+
without it, clone, pull, push and log leave every confidential file alone,
|
|
41702
|
+
and review leaves out confidential content.
|
|
41390
41703
|
The case's agents page in the web app shows the exact connect command.
|
|
41391
41704
|
After connecting, this machine still holds your \`wayai login\`:
|
|
41392
41705
|
\`wayai logout\` is the recommended next step, and the case token does not
|
|
@@ -41414,7 +41727,12 @@ need it.
|
|
|
41414
41727
|
"dry-run": { type: "boolean" },
|
|
41415
41728
|
message: { type: "string", short: "m" },
|
|
41416
41729
|
session: { type: "string" },
|
|
41417
|
-
limit: { type: "string" }
|
|
41730
|
+
limit: { type: "string" },
|
|
41731
|
+
reason: { type: "string" },
|
|
41732
|
+
revision: { type: "string" },
|
|
41733
|
+
"source-hash": { type: "string" },
|
|
41734
|
+
"neighbor-hash": { type: "string" },
|
|
41735
|
+
"mark-confidential": { type: "boolean" }
|
|
41418
41736
|
};
|
|
41419
41737
|
SELECT = ["case", "org", "space"];
|
|
41420
41738
|
ADMITS = {
|
|
@@ -41432,7 +41750,9 @@ need it.
|
|
|
41432
41750
|
// A clone names its case: pull and push take the clone (--dir), never a case.
|
|
41433
41751
|
pull: ["dir", "overwrite", "yes", "confidential"],
|
|
41434
41752
|
push: ["dir", "message", "session", "prune", "dry-run", "confidential"],
|
|
41435
|
-
log: [...SELECT, "limit", "json", "confidential"]
|
|
41753
|
+
log: [...SELECT, "limit", "json", "confidential"],
|
|
41754
|
+
review: [...SELECT, "json", "confidential"],
|
|
41755
|
+
"review verdict": [...SELECT, "reason", "revision", "source-hash", "neighbor-hash", "mark-confidential", "confidential", "json"]
|
|
41436
41756
|
};
|
|
41437
41757
|
casePagePath = (ref) => `/cases/${ref.org_id}/${ref.space_id}/${ref.code}`;
|
|
41438
41758
|
delay2 = (ms) => new Promise((resolve16) => setTimeout(resolve16, ms));
|