@akagilnc/pi-workflow-roles 0.1.5235 → 0.1.5245
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/CLAUDE.md +3 -0
- package/README.md +2 -3
- package/README.zh-CN.md +2 -3
- package/dist/acp-host/production-host.js +528 -3266
- package/dist/collector-config.js +0 -1
- package/dist/headless-host/production-host.js +671 -3409
- package/dist/migrate-book-topology.js +40 -107
- package/dist/package-contracts/collector-output.js +1 -90
- package/dist/package-contracts/terminating-tools.js +2 -2
- package/dist/packaged-role-registry.js +8 -11
- package/dist/public-cli/invocation.js +2 -22
- package/dist/public-cli/main.js +302 -827
- package/dist/public-cli/option-definitions.js +4 -19
- package/dist/public-cli/post-admission.js +4 -17
- package/dist/public-cli/settlement.js +2 -79
- package/dist/sitian-appender.js +0 -9
- package/package.json +1 -1
- package/resources/collector-bot-handbook.md +4 -2
- package/src/collector-config.ts +0 -1
- package/src/collector-role.ts +40 -535
- package/src/collector-tool-schemas.ts +7 -117
- package/src/gh-api-runner.ts +102 -0
- package/src/notary-role.ts +0 -1
- package/src/package-contracts/collector-output.ts +15 -174
- package/src/package-contracts/terminating-tools.ts +0 -2
- package/src/packaged-role-registry.ts +7 -10
- package/src/public-cli/countersign-run.ts +4 -3
- package/src/public-cli/invocation.ts +3 -27
- package/src/public-cli/option-definitions.ts +4 -19
- package/src/public-cli/post-admission.ts +4 -18
- package/src/public-cli/settlement.ts +3 -102
- package/src/role-envelope.ts +2 -2
- package/src/role-runtime-dependencies.ts +0 -4
- package/src/role-runtime.ts +16 -112
- package/src/sitian-appender.ts +0 -14
- package/src/ticket-snapshot.ts +1 -1
- package/dist/collector-evidence.js +0 -319
- package/dist/collector-github.js +0 -725
- package/dist/collector-identity.js +0 -92
- package/dist/collector-ledger.js +0 -888
- package/dist/collector-target.js +0 -169
- package/dist/public-cli/case-dossier-delivery.js +0 -109
- package/src/collector-evidence.ts +0 -466
- package/src/collector-github.ts +0 -1032
- package/src/collector-handbook.ts +0 -194
- package/src/collector-identity.ts +0 -151
- package/src/collector-ledger.ts +0 -1186
- package/src/collector-target.ts +0 -207
- package/src/public-cli/case-dossier-delivery.ts +0 -147
package/dist/public-cli/main.js
CHANGED
|
@@ -692,357 +692,6 @@ var init_collector_output = __esm({
|
|
|
692
692
|
}
|
|
693
693
|
});
|
|
694
694
|
|
|
695
|
-
// src/collector-evidence.ts
|
|
696
|
-
var COLLECTOR_DEFAULT_WAIT_WINDOW_MS;
|
|
697
|
-
var init_collector_evidence = __esm({
|
|
698
|
-
"src/collector-evidence.ts"() {
|
|
699
|
-
"use strict";
|
|
700
|
-
COLLECTOR_DEFAULT_WAIT_WINDOW_MS = 10 * 60 * 1e3;
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
|
|
704
|
-
// src/collector-config.ts
|
|
705
|
-
import { createHash } from "node:crypto";
|
|
706
|
-
import { readFile as readFile2 } from "node:fs/promises";
|
|
707
|
-
function fail(message, cause) {
|
|
708
|
-
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
709
|
-
}
|
|
710
|
-
function conservativeAscii(input) {
|
|
711
|
-
for (let i = 0; i < input.length; i += 1) {
|
|
712
|
-
const code = input.charCodeAt(i);
|
|
713
|
-
if (code <= 31 || code === 127 || code > 127) return false;
|
|
714
|
-
}
|
|
715
|
-
return true;
|
|
716
|
-
}
|
|
717
|
-
function parseCollectorRepository(raw) {
|
|
718
|
-
if (typeof raw !== "string" || raw.trim() !== raw || raw.length === 0) fail("Collector repository must be a string owner/repo");
|
|
719
|
-
if (!conservativeAscii(raw) || raw.includes("://") || /[?#@%\\ ]/.test(raw)) fail("Collector repository rejects URL syntax and non-identity bytes");
|
|
720
|
-
const parts = raw.split("/");
|
|
721
|
-
if (parts.length !== 2) fail("Collector repository must contain exactly one '/' separating owner and repo");
|
|
722
|
-
const [ownerDisplay, repoDisplay] = parts;
|
|
723
|
-
if (!COLLECTOR_OWNER_PATTERN.test(ownerDisplay) || !COLLECTOR_REPO_PATTERN.test(repoDisplay)) fail("Collector repository does not match the conservative owner/repo grammar");
|
|
724
|
-
const owner = ownerDisplay.toLowerCase();
|
|
725
|
-
const repo = repoDisplay.toLowerCase();
|
|
726
|
-
return { display: raw, canonical: `${owner}/${repo}`, owner, repo };
|
|
727
|
-
}
|
|
728
|
-
function parseCollectorPrNumber(raw) {
|
|
729
|
-
if (typeof raw === "string" && !/^[1-9][0-9]*$/.test(raw)) fail("Collector pull request number must be a positive safe integer string");
|
|
730
|
-
if (typeof raw !== "string" && typeof raw !== "number") fail("Collector pull request number is required");
|
|
731
|
-
const value = Number(raw);
|
|
732
|
-
if (!Number.isSafeInteger(value) || value < 1) fail("Collector pull request number must be a positive safe integer");
|
|
733
|
-
return value;
|
|
734
|
-
}
|
|
735
|
-
function record(value) {
|
|
736
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
737
|
-
}
|
|
738
|
-
function canonicalManifest(requests) {
|
|
739
|
-
return `${JSON.stringify({ requests: requests.map((request) => ({ id: request.id, body: request.requestBody })) })}
|
|
740
|
-
`;
|
|
741
|
-
}
|
|
742
|
-
function emptyCollectorManifest() {
|
|
743
|
-
const canonicalJson2 = canonicalManifest([]);
|
|
744
|
-
return { requests: [], canonicalJson: canonicalJson2, digest: createHash("sha256").update(canonicalJson2).digest("hex") };
|
|
745
|
-
}
|
|
746
|
-
async function loadCollectorManifest(path) {
|
|
747
|
-
let bytes;
|
|
748
|
-
try {
|
|
749
|
-
bytes = await readFile2(path);
|
|
750
|
-
} catch (error) {
|
|
751
|
-
fail(`Collector request manifest is unreadable at ${path}`, error);
|
|
752
|
-
}
|
|
753
|
-
let parsed;
|
|
754
|
-
try {
|
|
755
|
-
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
756
|
-
} catch (error) {
|
|
757
|
-
fail("Collector request manifest must be UTF-8 JSON", error);
|
|
758
|
-
}
|
|
759
|
-
if (!record(parsed)) fail("Collector request manifest must be an object");
|
|
760
|
-
const rawRequests = parsed.requests ?? [];
|
|
761
|
-
if (!Array.isArray(rawRequests)) fail("Collector request manifest requests must be an array");
|
|
762
|
-
const requests = [];
|
|
763
|
-
const ids = /* @__PURE__ */ new Set();
|
|
764
|
-
for (const [index, item] of rawRequests.entries()) {
|
|
765
|
-
if (!record(item) || typeof item.id !== "string" || item.id.length === 0 || typeof item.body !== "string" || item.body.trim() === "") fail(`Collector request manifest requests[${index}] is invalid`);
|
|
766
|
-
if (ids.has(item.id)) fail(`Collector request manifest has duplicate request id "${item.id}"`);
|
|
767
|
-
ids.add(item.id);
|
|
768
|
-
requests.push({ id: item.id, requestBody: item.body });
|
|
769
|
-
}
|
|
770
|
-
const canonicalJson2 = canonicalManifest(requests);
|
|
771
|
-
return { requests, canonicalJson: canonicalJson2, digest: createHash("sha256").update(canonicalJson2).digest("hex"), sourcePath: path };
|
|
772
|
-
}
|
|
773
|
-
var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
|
|
774
|
-
var init_collector_config = __esm({
|
|
775
|
-
"src/collector-config.ts"() {
|
|
776
|
-
"use strict";
|
|
777
|
-
COLLECTOR_OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
778
|
-
COLLECTOR_REPO_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/;
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
// src/collector-github.ts
|
|
783
|
-
import { spawn } from "node:child_process";
|
|
784
|
-
function isRecord(value) {
|
|
785
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
786
|
-
}
|
|
787
|
-
function parseJson(text, label) {
|
|
788
|
-
try {
|
|
789
|
-
return JSON.parse(text);
|
|
790
|
-
} catch (error) {
|
|
791
|
-
throw new Error(`GitHub ${label} returned malformed JSON`, { cause: error });
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
function parsePullRequestNumberList(raw, label) {
|
|
795
|
-
if (!Array.isArray(raw)) {
|
|
796
|
-
throw new Error(`GitHub ${label} payload is not a list`);
|
|
797
|
-
}
|
|
798
|
-
const numbers = [];
|
|
799
|
-
for (const item of raw) {
|
|
800
|
-
if (!isRecord(item)) {
|
|
801
|
-
throw new Error(`GitHub ${label} payload contains a non-object pull request entry`);
|
|
802
|
-
}
|
|
803
|
-
try {
|
|
804
|
-
numbers.push(parseCollectorPrNumber(item["number"]));
|
|
805
|
-
} catch (error) {
|
|
806
|
-
throw new Error(`GitHub ${label} payload contains an invalid pull request number`, {
|
|
807
|
-
cause: error
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
return numbers;
|
|
812
|
-
}
|
|
813
|
-
async function listPullRequestNumbersByHead(runner, input) {
|
|
814
|
-
const head = `${input.headOwner}:${input.headRef}`;
|
|
815
|
-
const path = `/repos/${input.owner}/${input.repo}/pulls?head=${encodeURIComponent(head)}&state=all&per_page=100`;
|
|
816
|
-
const response = await runner(
|
|
817
|
-
["api", "--hostname", "github.com", "--include", "-X", "GET", path],
|
|
818
|
-
input.signal === void 0 ? {} : { signal: input.signal }
|
|
819
|
-
);
|
|
820
|
-
if (response.status < 200 || response.status >= 300) {
|
|
821
|
-
throw new Error(`GitHub ${path} failed with HTTP ${response.status}`, {
|
|
822
|
-
cause: {
|
|
823
|
-
endpoint: path,
|
|
824
|
-
status: response.status,
|
|
825
|
-
headers: response.headers,
|
|
826
|
-
body: response.bodyText
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
return parsePullRequestNumberList(parseJson(response.bodyText, path), path);
|
|
831
|
-
}
|
|
832
|
-
async function listPullRequestNumbersByCommit(runner, input) {
|
|
833
|
-
const path = `/repos/${input.owner}/${input.repo}/commits/${encodeURIComponent(input.commitSha)}/pulls`;
|
|
834
|
-
const response = await runner(
|
|
835
|
-
["api", "--hostname", "github.com", "--include", "-X", "GET", path],
|
|
836
|
-
input.signal === void 0 ? {} : { signal: input.signal }
|
|
837
|
-
);
|
|
838
|
-
if (response.status < 200 || response.status >= 300) {
|
|
839
|
-
throw new Error(`GitHub ${path} failed with HTTP ${response.status}`, {
|
|
840
|
-
cause: {
|
|
841
|
-
endpoint: path,
|
|
842
|
-
status: response.status,
|
|
843
|
-
headers: response.headers,
|
|
844
|
-
body: response.bodyText
|
|
845
|
-
}
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
return parsePullRequestNumberList(parseJson(response.bodyText, path), path);
|
|
849
|
-
}
|
|
850
|
-
function createGhApiRunner(options = {}) {
|
|
851
|
-
const spawnImpl = options.spawnImpl ?? spawn;
|
|
852
|
-
return async (args, runOptions = {}) => {
|
|
853
|
-
return await new Promise((resolve14, reject) => {
|
|
854
|
-
const signal = runOptions.signal;
|
|
855
|
-
if (signal?.aborted) {
|
|
856
|
-
reject(signal.reason ?? new Error("aborted"));
|
|
857
|
-
return;
|
|
858
|
-
}
|
|
859
|
-
const child = spawnImpl("gh", args, {
|
|
860
|
-
env: options.env ?? process.env,
|
|
861
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
862
|
-
});
|
|
863
|
-
let stdout = "";
|
|
864
|
-
let stderr = "";
|
|
865
|
-
let settled = false;
|
|
866
|
-
const settle = (fn) => {
|
|
867
|
-
if (settled) return;
|
|
868
|
-
settled = true;
|
|
869
|
-
if (signal !== void 0) {
|
|
870
|
-
signal.removeEventListener("abort", onAbort);
|
|
871
|
-
}
|
|
872
|
-
fn();
|
|
873
|
-
};
|
|
874
|
-
const onAbort = () => {
|
|
875
|
-
try {
|
|
876
|
-
child.kill("SIGTERM");
|
|
877
|
-
} catch (error) {
|
|
878
|
-
settle(() => reject(error));
|
|
879
|
-
return;
|
|
880
|
-
}
|
|
881
|
-
settle(() => {
|
|
882
|
-
reject(signal?.reason ?? new Error("aborted"));
|
|
883
|
-
});
|
|
884
|
-
};
|
|
885
|
-
if (signal !== void 0) {
|
|
886
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
887
|
-
}
|
|
888
|
-
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
889
|
-
stdout += chunk;
|
|
890
|
-
});
|
|
891
|
-
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
892
|
-
stderr += chunk;
|
|
893
|
-
});
|
|
894
|
-
child.on("error", (error) => {
|
|
895
|
-
settle(() => reject(error));
|
|
896
|
-
});
|
|
897
|
-
child.stdin.on("error", (error) => {
|
|
898
|
-
settle(() => {
|
|
899
|
-
if (signal?.aborted) {
|
|
900
|
-
reject(signal.reason ?? new Error("aborted"));
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
904
|
-
reject(Object.assign(err, { ambiguousGhFailure: true }));
|
|
905
|
-
});
|
|
906
|
-
});
|
|
907
|
-
if (runOptions.stdin !== void 0) {
|
|
908
|
-
child.stdin.write(runOptions.stdin);
|
|
909
|
-
}
|
|
910
|
-
child.stdin.end();
|
|
911
|
-
child.on("close", (code, signal2) => {
|
|
912
|
-
settle(() => {
|
|
913
|
-
const match = stdout.match(/^HTTP\/[\d.]+\s+(\d+)[^\n]*\r?\n([\s\S]*?)\r?\n\r?\n([\s\S]*)$/);
|
|
914
|
-
if (match) {
|
|
915
|
-
const status = Number(match[1]);
|
|
916
|
-
const headerText = match[2] ?? "";
|
|
917
|
-
const bodyText = match[3] ?? "";
|
|
918
|
-
const headers = {};
|
|
919
|
-
for (const line2 of headerText.split(/\r?\n/)) {
|
|
920
|
-
const idx = line2.indexOf(":");
|
|
921
|
-
if (idx === -1) continue;
|
|
922
|
-
const name = line2.slice(0, idx).trim().toLowerCase();
|
|
923
|
-
const value = line2.slice(idx + 1).trim();
|
|
924
|
-
headers[name] = value;
|
|
925
|
-
}
|
|
926
|
-
resolve14({ status, headers, bodyText });
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
if (code === 0) {
|
|
930
|
-
resolve14({ status: 200, headers: {}, bodyText: stdout });
|
|
931
|
-
return;
|
|
932
|
-
}
|
|
933
|
-
const failure = new Error(
|
|
934
|
-
`gh api failed without a parseable HTTP response (code=${String(code)}): ${stderr || stdout}`,
|
|
935
|
-
{ cause: { code, signal: signal2, stderr, stdout } }
|
|
936
|
-
);
|
|
937
|
-
reject(Object.assign(failure, { ambiguousGhFailure: true, stderr, stdout, code, signal: signal2 }));
|
|
938
|
-
});
|
|
939
|
-
});
|
|
940
|
-
});
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
var init_collector_github = __esm({
|
|
944
|
-
"src/collector-github.ts"() {
|
|
945
|
-
"use strict";
|
|
946
|
-
init_collector_config();
|
|
947
|
-
}
|
|
948
|
-
});
|
|
949
|
-
|
|
950
|
-
// src/readable-gate-item.ts
|
|
951
|
-
var readable_gate_item_exports = {};
|
|
952
|
-
__export(readable_gate_item_exports, {
|
|
953
|
-
joinReadableGateItems: () => joinReadableGateItems,
|
|
954
|
-
readableGateItem: () => readableGateItem
|
|
955
|
-
});
|
|
956
|
-
function readableGateItem(value) {
|
|
957
|
-
return typeof value === "string" ? value : JSON.stringify(value);
|
|
958
|
-
}
|
|
959
|
-
function joinReadableGateItems(items, separator = "; ") {
|
|
960
|
-
return items.map(readableGateItem).join(separator);
|
|
961
|
-
}
|
|
962
|
-
var init_readable_gate_item = __esm({
|
|
963
|
-
"src/readable-gate-item.ts"() {
|
|
964
|
-
"use strict";
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
// src/submission-errors.ts
|
|
969
|
-
function serializeReceipt(receipt) {
|
|
970
|
-
return readableGateItem(receipt);
|
|
971
|
-
}
|
|
972
|
-
function gatekeeperNonPassMessage(result) {
|
|
973
|
-
if (result.status === "continue") {
|
|
974
|
-
return serializeReceipt(result.receipt);
|
|
975
|
-
}
|
|
976
|
-
if (result.status === "transport_failure") {
|
|
977
|
-
const head = `\u95E8\u4E0B\u7701 ${result.status}\uFF08${result.stage}\uFF09\uFF1A${result.reason}`;
|
|
978
|
-
return result.submission === void 0 ? head : `${head}
|
|
979
|
-
${serializeReceipt(result.submission)}`;
|
|
980
|
-
}
|
|
981
|
-
return `\u95E8\u4E0B\u7701 ${result.status}\uFF08${result.stage}\uFF09\uFF1A${result.reason}`;
|
|
982
|
-
}
|
|
983
|
-
function unreadableDiscriminatorNotice(field, received) {
|
|
984
|
-
if (received === void 0) return `\u8BFB\u4E0D\u51FA ${field}`;
|
|
985
|
-
return `\u8BFB\u4E0D\u51FA ${field}\uFF1A${readableGateItem(received)}`;
|
|
986
|
-
}
|
|
987
|
-
function receivedDiscriminator(receipt, field) {
|
|
988
|
-
if (receipt === null || typeof receipt !== "object" || Array.isArray(receipt)) return void 0;
|
|
989
|
-
if (!Object.hasOwn(receipt, field)) return void 0;
|
|
990
|
-
return receipt[field];
|
|
991
|
-
}
|
|
992
|
-
var GatekeeperDecisionError;
|
|
993
|
-
var init_submission_errors = __esm({
|
|
994
|
-
"src/submission-errors.ts"() {
|
|
995
|
-
"use strict";
|
|
996
|
-
init_readable_gate_item();
|
|
997
|
-
GatekeeperDecisionError = class extends Error {
|
|
998
|
-
result;
|
|
999
|
-
constructor(result, message) {
|
|
1000
|
-
super(message ?? gatekeeperNonPassMessage(result));
|
|
1001
|
-
this.name = "GatekeeperDecisionError";
|
|
1002
|
-
this.result = result;
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
|
|
1008
|
-
// src/submission-correctable-error.ts
|
|
1009
|
-
var correctableSubmissionErrorBrand, CorrectableSubmissionError;
|
|
1010
|
-
var init_submission_correctable_error = __esm({
|
|
1011
|
-
"src/submission-correctable-error.ts"() {
|
|
1012
|
-
"use strict";
|
|
1013
|
-
init_submission_errors();
|
|
1014
|
-
correctableSubmissionErrorBrand = /* @__PURE__ */ Symbol("ak-roles.correctable-submission-error");
|
|
1015
|
-
CorrectableSubmissionError = class extends Error {
|
|
1016
|
-
[correctableSubmissionErrorBrand] = true;
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
});
|
|
1020
|
-
|
|
1021
|
-
// src/collector-identity.ts
|
|
1022
|
-
var init_collector_identity = __esm({
|
|
1023
|
-
"src/collector-identity.ts"() {
|
|
1024
|
-
"use strict";
|
|
1025
|
-
init_submission_correctable_error();
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
|
|
1029
|
-
// src/collector-ledger.ts
|
|
1030
|
-
var COLLECTOR_OBSERVE_TOOL, COLLECTOR_READ_TOOL, COLLECTOR_REQUEST_TOOL, COLLECTOR_WAIT_TOOL, COLLECTOR_BIND_TARGET_TOOL;
|
|
1031
|
-
var init_collector_ledger = __esm({
|
|
1032
|
-
"src/collector-ledger.ts"() {
|
|
1033
|
-
"use strict";
|
|
1034
|
-
init_collector_evidence();
|
|
1035
|
-
init_collector_github();
|
|
1036
|
-
init_collector_identity();
|
|
1037
|
-
init_collector_output();
|
|
1038
|
-
COLLECTOR_OBSERVE_TOOL = "ak_collector_observe";
|
|
1039
|
-
COLLECTOR_READ_TOOL = "ak_collector_read";
|
|
1040
|
-
COLLECTOR_REQUEST_TOOL = "ak_collector_request";
|
|
1041
|
-
COLLECTOR_WAIT_TOOL = "ak_collector_wait";
|
|
1042
|
-
COLLECTOR_BIND_TARGET_TOOL = "ak_collector_bind_target";
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
|
|
1046
695
|
// node_modules/.pnpm/typebox@1.3.8/node_modules/typebox/build/system/memory/metrics.mjs
|
|
1047
696
|
var Metrics;
|
|
1048
697
|
var init_metrics = __esm({
|
|
@@ -14953,27 +14602,27 @@ function causeMessage(cause) {
|
|
|
14953
14602
|
return String(cause);
|
|
14954
14603
|
}
|
|
14955
14604
|
}
|
|
14956
|
-
function
|
|
14605
|
+
function fail(cause) {
|
|
14957
14606
|
throw new FixerPacketValidationError(cause);
|
|
14958
14607
|
}
|
|
14959
14608
|
function parseFailure(value) {
|
|
14960
|
-
if (!Array.isArray(value))
|
|
14609
|
+
if (!Array.isArray(value)) fail(new Error("Fixer prerequisites must be a JSON array"));
|
|
14961
14610
|
for (const entry of value) {
|
|
14962
14611
|
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
|
|
14963
|
-
|
|
14612
|
+
fail(new Error("Fixer prerequisite entry must be an object with id and requirement fields"));
|
|
14964
14613
|
}
|
|
14965
14614
|
const keys = Object.keys(entry);
|
|
14966
14615
|
if (keys.length !== 2 || !keys.includes("id") || !keys.includes("requirement")) {
|
|
14967
|
-
|
|
14616
|
+
fail(new Error("Fixer prerequisite entry fields must be exactly id and requirement"));
|
|
14968
14617
|
}
|
|
14969
14618
|
if (typeof entry.id !== "string" || !new RegExp(FIXER_PREREQUISITE_ID_PATTERN).test(entry.id)) {
|
|
14970
|
-
|
|
14619
|
+
fail(new Error(`Fixer prerequisite id violates pattern ${FIXER_PREREQUISITE_ID_PATTERN}`));
|
|
14971
14620
|
}
|
|
14972
14621
|
if (typeof entry.requirement !== "string" || !/\S/.test(entry.requirement)) {
|
|
14973
|
-
|
|
14622
|
+
fail(new Error("Fixer prerequisite requirement must be nonblank"));
|
|
14974
14623
|
}
|
|
14975
14624
|
}
|
|
14976
|
-
|
|
14625
|
+
fail(new Error("Fixer prerequisites violate the attachment schema"));
|
|
14977
14626
|
}
|
|
14978
14627
|
function validateFixerPrerequisites(value) {
|
|
14979
14628
|
if (!value_exports.Check(fixerPrerequisitesSchema, value)) parseFailure(value);
|
|
@@ -14981,7 +14630,7 @@ function validateFixerPrerequisites(value) {
|
|
|
14981
14630
|
const ids = /* @__PURE__ */ new Set();
|
|
14982
14631
|
const prerequisites = entries.map((entry) => {
|
|
14983
14632
|
if (ids.has(entry.id)) {
|
|
14984
|
-
|
|
14633
|
+
fail(new Error(`Fixer prerequisites contain duplicate id: ${entry.id}`));
|
|
14985
14634
|
}
|
|
14986
14635
|
ids.add(entry.id);
|
|
14987
14636
|
return Object.freeze({ id: entry.id, requirement: entry.requirement });
|
|
@@ -14993,7 +14642,7 @@ function parseFixerPrerequisites(source) {
|
|
|
14993
14642
|
try {
|
|
14994
14643
|
decoded = JSON.parse(source);
|
|
14995
14644
|
} catch (error) {
|
|
14996
|
-
|
|
14645
|
+
fail(error);
|
|
14997
14646
|
}
|
|
14998
14647
|
return validateFixerPrerequisites(decoded);
|
|
14999
14648
|
}
|
|
@@ -15113,7 +14762,7 @@ var init_exact_utf8 = __esm({
|
|
|
15113
14762
|
});
|
|
15114
14763
|
|
|
15115
14764
|
// src/merger-contracts.ts
|
|
15116
|
-
function
|
|
14765
|
+
function fail2(message = "Merger input violates its exact contract") {
|
|
15117
14766
|
throw new MergerInputContractError(message);
|
|
15118
14767
|
}
|
|
15119
14768
|
function deepFreeze(value) {
|
|
@@ -15124,18 +14773,18 @@ function deepFreeze(value) {
|
|
|
15124
14773
|
return value;
|
|
15125
14774
|
}
|
|
15126
14775
|
function readMaterial(value, label) {
|
|
15127
|
-
if (!
|
|
14776
|
+
if (!record(value) || typeof value.bytesBase64 !== "string") fail2(`Merger ${label} material is malformed`);
|
|
15128
14777
|
exactUtf8(Buffer.from(value.bytesBase64, "base64"), `Merger ${label} material`);
|
|
15129
14778
|
return { bytesBase64: value.bytesBase64, sha256: typeof value.sha256 === "string" ? value.sha256 : "" };
|
|
15130
14779
|
}
|
|
15131
14780
|
function validateMergerInput(value) {
|
|
15132
|
-
if (!
|
|
15133
|
-
if (!
|
|
14781
|
+
if (!record(value) || blank(value.attemptId)) fail2("Merger input requires a non-empty attemptId for accounting");
|
|
14782
|
+
if (!record(value.materials)) fail2("Merger materials are missing");
|
|
15134
14783
|
const materials = { task: readMaterial(value.materials.task, "task"), authority: readMaterial(value.materials.authority, "authority"), targetIntent: readMaterial(value.materials.targetIntent, "targetIntent"), sourceIntent: readMaterial(value.materials.sourceIntent, "sourceIntent") };
|
|
15135
|
-
const authorizedChecks = Array.isArray(value.authorizedChecks) ? value.authorizedChecks.filter((check) =>
|
|
14784
|
+
const authorizedChecks = Array.isArray(value.authorizedChecks) ? value.authorizedChecks.filter((check) => record(check)).map((c) => ({ name: asString(c.name), argv: asStringArray(c.argv).filter((a) => a.trim().length > 0) })).filter((c) => c.name.trim().length > 0 && c.argv.length > 0) : [];
|
|
15136
14785
|
return deepFreeze(structuredClone({ attemptId: value.attemptId.trim(), targetObjectId: asString(value.targetObjectId), sourceObjectId: asString(value.sourceObjectId), materials, expectedConflictPaths: asStringArray(value.expectedConflictPaths), resolutionScope: asStringArray(value.resolutionScope), authorizedChecks }));
|
|
15137
14786
|
}
|
|
15138
|
-
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION, mergerOutputVariants, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME,
|
|
14787
|
+
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION, mergerOutputVariants, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME, record, blank, MergerInputContractError, asString, asStringArray;
|
|
15139
14788
|
var init_merger_contracts = __esm({
|
|
15140
14789
|
"src/merger-contracts.ts"() {
|
|
15141
14790
|
"use strict";
|
|
@@ -15161,7 +14810,7 @@ var init_merger_contracts = __esm({
|
|
|
15161
14810
|
]);
|
|
15162
14811
|
mergerOutputSchema = withTerminatingOutputDeclarations(openToolObjectFromUnion(mergerOutputVariants));
|
|
15163
14812
|
MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
|
|
15164
|
-
|
|
14813
|
+
record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
15165
14814
|
blank = (v) => typeof v !== "string" || v.trim().length === 0;
|
|
15166
14815
|
MergerInputContractError = class extends Error {
|
|
15167
14816
|
constructor(message = "Merger input violates its exact contract") {
|
|
@@ -15536,7 +15185,6 @@ var init_packaged_role_registry = __esm({
|
|
|
15536
15185
|
"src/packaged-role-registry.ts"() {
|
|
15537
15186
|
"use strict";
|
|
15538
15187
|
init_collector_output();
|
|
15539
|
-
init_collector_ledger();
|
|
15540
15188
|
init_gatekeeper_output();
|
|
15541
15189
|
init_navigator_output();
|
|
15542
15190
|
init_judge_output();
|
|
@@ -15732,23 +15380,18 @@ var init_packaged_role_registry = __esm({
|
|
|
15732
15380
|
]
|
|
15733
15381
|
},
|
|
15734
15382
|
// ak-collector-repo is GitHub owner/repo identity, not a local material path (#438).
|
|
15383
|
+
// #1088: seat + request-manifest kept; code no longer collects — LLM uses host CLI.
|
|
15735
15384
|
{
|
|
15736
15385
|
role: "collector",
|
|
15737
15386
|
inCallAutoResume: false,
|
|
15738
15387
|
presentSettled: "always",
|
|
15739
15388
|
summonResume: false,
|
|
15740
15389
|
admission: "collect-target",
|
|
15741
|
-
/** Public no_receipt projects a durable bind-target rejection. */
|
|
15742
|
-
projectTargetBindRejection: true,
|
|
15743
15390
|
sameParent: "none",
|
|
15744
15391
|
phases: [null],
|
|
15745
15392
|
bareCommand: false,
|
|
15746
15393
|
outputTool: COLLECTOR_OUTPUT_TOOL,
|
|
15747
|
-
settlement: "
|
|
15748
|
-
/** #633: a prior wait-tool residual must not mask this attempt. */
|
|
15749
|
-
residualScan: "current-attempt",
|
|
15750
|
-
residualTool: COLLECTOR_WAIT_TOOL,
|
|
15751
|
-
runnerFailure: "collector-known-first",
|
|
15394
|
+
settlement: "sealed",
|
|
15752
15395
|
artifactFace: {
|
|
15753
15396
|
evidenceRole: true,
|
|
15754
15397
|
leaves: [
|
|
@@ -15763,11 +15406,14 @@ var init_packaged_role_registry = __esm({
|
|
|
15763
15406
|
activationFlags: [
|
|
15764
15407
|
{ field: "repo", from: "repository.display", flag: "ak-collector-repo" },
|
|
15765
15408
|
{ field: "pr", from: "prNumber", text: true, flag: "ak-collector-pr" },
|
|
15766
|
-
{ field: "requestManifestPath", flag: "ak-collector-request-manifest" }
|
|
15767
|
-
{ field: "waitMs", from: "waitWindowMs", text: true, flag: "ak-collector-wait-ms" }
|
|
15409
|
+
{ field: "requestManifestPath", flag: "ak-collector-request-manifest" }
|
|
15768
15410
|
],
|
|
15769
15411
|
activationStage: "load-and-install",
|
|
15770
|
-
sessionMaterials: [
|
|
15412
|
+
sessionMaterials: [
|
|
15413
|
+
"CLAUDE.md",
|
|
15414
|
+
"souls/collector.md",
|
|
15415
|
+
"resources/collector-bot-handbook.md"
|
|
15416
|
+
]
|
|
15771
15417
|
},
|
|
15772
15418
|
{
|
|
15773
15419
|
role: "doctor",
|
|
@@ -16276,7 +15922,7 @@ __export(config_exports, {
|
|
|
16276
15922
|
setPersistentSeatHost: () => setPersistentSeatHost,
|
|
16277
15923
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
16278
15924
|
});
|
|
16279
|
-
import { mkdir, readFile as
|
|
15925
|
+
import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
16280
15926
|
import { dirname as dirname4, join as join7 } from "node:path";
|
|
16281
15927
|
function isGateOfficerSeat(value) {
|
|
16282
15928
|
return packagedProvinceConfig(value);
|
|
@@ -16290,7 +15936,7 @@ function publicCliConfigPath(home) {
|
|
|
16290
15936
|
async function loadPublicCliConfig(home) {
|
|
16291
15937
|
const path = publicCliConfigPath(home);
|
|
16292
15938
|
try {
|
|
16293
|
-
const raw = await
|
|
15939
|
+
const raw = await readFile2(path, "utf8");
|
|
16294
15940
|
return parsePublicCliConfig(JSON.parse(raw));
|
|
16295
15941
|
} catch (error) {
|
|
16296
15942
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -16748,7 +16394,7 @@ function credentialProvidersFromAuthData(data) {
|
|
|
16748
16394
|
}
|
|
16749
16395
|
async function loadCredentialProviders(agentDir) {
|
|
16750
16396
|
try {
|
|
16751
|
-
const raw = await
|
|
16397
|
+
const raw = await readFile2(join7(agentDir, "auth.json"), "utf8");
|
|
16752
16398
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
16753
16399
|
} catch (error) {
|
|
16754
16400
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -17115,7 +16761,7 @@ var init_machine_method_skills = __esm({
|
|
|
17115
16761
|
});
|
|
17116
16762
|
|
|
17117
16763
|
// src/typed-provider-http.ts
|
|
17118
|
-
import { readFile as
|
|
16764
|
+
import { readFile as readFile3, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
17119
16765
|
import { join as join10 } from "node:path";
|
|
17120
16766
|
function typedProviderHttpPath(runDirectory) {
|
|
17121
16767
|
return join10(runDirectory, TYPED_HTTP_FILE);
|
|
@@ -17149,7 +16795,7 @@ async function recordTypedProviderHttpStatus(runDirectory, observation) {
|
|
|
17149
16795
|
async function readLatestTypedProviderHttpObservation(runDirectory) {
|
|
17150
16796
|
let text;
|
|
17151
16797
|
try {
|
|
17152
|
-
text = await
|
|
16798
|
+
text = await readFile3(typedProviderHttpPath(runDirectory), "utf8");
|
|
17153
16799
|
} catch (error) {
|
|
17154
16800
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
17155
16801
|
return void 0;
|
|
@@ -17177,6 +16823,84 @@ var init_typed_provider_http = __esm({
|
|
|
17177
16823
|
}
|
|
17178
16824
|
});
|
|
17179
16825
|
|
|
16826
|
+
// src/collector-config.ts
|
|
16827
|
+
import { createHash } from "node:crypto";
|
|
16828
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
16829
|
+
function fail3(message, cause) {
|
|
16830
|
+
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
16831
|
+
}
|
|
16832
|
+
function conservativeAscii(input) {
|
|
16833
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
16834
|
+
const code = input.charCodeAt(i);
|
|
16835
|
+
if (code <= 31 || code === 127 || code > 127) return false;
|
|
16836
|
+
}
|
|
16837
|
+
return true;
|
|
16838
|
+
}
|
|
16839
|
+
function parseCollectorRepository(raw) {
|
|
16840
|
+
if (typeof raw !== "string" || raw.trim() !== raw || raw.length === 0) fail3("Collector repository must be a string owner/repo");
|
|
16841
|
+
if (!conservativeAscii(raw) || raw.includes("://") || /[?#@%\\ ]/.test(raw)) fail3("Collector repository rejects URL syntax and non-identity bytes");
|
|
16842
|
+
const parts = raw.split("/");
|
|
16843
|
+
if (parts.length !== 2) fail3("Collector repository must contain exactly one '/' separating owner and repo");
|
|
16844
|
+
const [ownerDisplay, repoDisplay] = parts;
|
|
16845
|
+
if (!COLLECTOR_OWNER_PATTERN.test(ownerDisplay) || !COLLECTOR_REPO_PATTERN.test(repoDisplay)) fail3("Collector repository does not match the conservative owner/repo grammar");
|
|
16846
|
+
const owner = ownerDisplay.toLowerCase();
|
|
16847
|
+
const repo = repoDisplay.toLowerCase();
|
|
16848
|
+
return { display: raw, canonical: `${owner}/${repo}`, owner, repo };
|
|
16849
|
+
}
|
|
16850
|
+
function parseCollectorPrNumber(raw) {
|
|
16851
|
+
if (typeof raw === "string" && !/^[1-9][0-9]*$/.test(raw)) fail3("Collector pull request number must be a positive safe integer string");
|
|
16852
|
+
if (typeof raw !== "string" && typeof raw !== "number") fail3("Collector pull request number is required");
|
|
16853
|
+
const value = Number(raw);
|
|
16854
|
+
if (!Number.isSafeInteger(value) || value < 1) fail3("Collector pull request number must be a positive safe integer");
|
|
16855
|
+
return value;
|
|
16856
|
+
}
|
|
16857
|
+
function record2(value) {
|
|
16858
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16859
|
+
}
|
|
16860
|
+
function canonicalManifest(requests) {
|
|
16861
|
+
return `${JSON.stringify({ requests: requests.map((request) => ({ id: request.id, body: request.requestBody })) })}
|
|
16862
|
+
`;
|
|
16863
|
+
}
|
|
16864
|
+
function emptyCollectorManifest() {
|
|
16865
|
+
const canonicalJson2 = canonicalManifest([]);
|
|
16866
|
+
return { requests: [], canonicalJson: canonicalJson2, digest: createHash("sha256").update(canonicalJson2).digest("hex") };
|
|
16867
|
+
}
|
|
16868
|
+
async function loadCollectorManifest(path) {
|
|
16869
|
+
let bytes;
|
|
16870
|
+
try {
|
|
16871
|
+
bytes = await readFile4(path);
|
|
16872
|
+
} catch (error) {
|
|
16873
|
+
fail3(`Collector request manifest is unreadable at ${path}`, error);
|
|
16874
|
+
}
|
|
16875
|
+
let parsed;
|
|
16876
|
+
try {
|
|
16877
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
16878
|
+
} catch (error) {
|
|
16879
|
+
fail3("Collector request manifest must be UTF-8 JSON", error);
|
|
16880
|
+
}
|
|
16881
|
+
if (!record2(parsed)) fail3("Collector request manifest must be an object");
|
|
16882
|
+
const rawRequests = parsed.requests ?? [];
|
|
16883
|
+
if (!Array.isArray(rawRequests)) fail3("Collector request manifest requests must be an array");
|
|
16884
|
+
const requests = [];
|
|
16885
|
+
const ids = /* @__PURE__ */ new Set();
|
|
16886
|
+
for (const [index, item] of rawRequests.entries()) {
|
|
16887
|
+
if (!record2(item) || typeof item.id !== "string" || item.id.length === 0 || typeof item.body !== "string" || item.body.trim() === "") fail3(`Collector request manifest requests[${index}] is invalid`);
|
|
16888
|
+
if (ids.has(item.id)) fail3(`Collector request manifest has duplicate request id "${item.id}"`);
|
|
16889
|
+
ids.add(item.id);
|
|
16890
|
+
requests.push({ id: item.id, requestBody: item.body });
|
|
16891
|
+
}
|
|
16892
|
+
const canonicalJson2 = canonicalManifest(requests);
|
|
16893
|
+
return { requests, canonicalJson: canonicalJson2, digest: createHash("sha256").update(canonicalJson2).digest("hex"), sourcePath: path };
|
|
16894
|
+
}
|
|
16895
|
+
var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
|
|
16896
|
+
var init_collector_config = __esm({
|
|
16897
|
+
"src/collector-config.ts"() {
|
|
16898
|
+
"use strict";
|
|
16899
|
+
COLLECTOR_OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
16900
|
+
COLLECTOR_REPO_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/;
|
|
16901
|
+
}
|
|
16902
|
+
});
|
|
16903
|
+
|
|
17180
16904
|
// src/auditor-dossier-tool.ts
|
|
17181
16905
|
import { dirname as dirname5, join as join11, resolve as resolve3 } from "node:path";
|
|
17182
16906
|
function auditorRunDirectory(context) {
|
|
@@ -17192,6 +16916,64 @@ var init_auditor_dossier_tool = __esm({
|
|
|
17192
16916
|
}
|
|
17193
16917
|
});
|
|
17194
16918
|
|
|
16919
|
+
// src/readable-gate-item.ts
|
|
16920
|
+
var readable_gate_item_exports = {};
|
|
16921
|
+
__export(readable_gate_item_exports, {
|
|
16922
|
+
joinReadableGateItems: () => joinReadableGateItems,
|
|
16923
|
+
readableGateItem: () => readableGateItem
|
|
16924
|
+
});
|
|
16925
|
+
function readableGateItem(value) {
|
|
16926
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
16927
|
+
}
|
|
16928
|
+
function joinReadableGateItems(items, separator = "; ") {
|
|
16929
|
+
return items.map(readableGateItem).join(separator);
|
|
16930
|
+
}
|
|
16931
|
+
var init_readable_gate_item = __esm({
|
|
16932
|
+
"src/readable-gate-item.ts"() {
|
|
16933
|
+
"use strict";
|
|
16934
|
+
}
|
|
16935
|
+
});
|
|
16936
|
+
|
|
16937
|
+
// src/submission-errors.ts
|
|
16938
|
+
function serializeReceipt(receipt) {
|
|
16939
|
+
return readableGateItem(receipt);
|
|
16940
|
+
}
|
|
16941
|
+
function gatekeeperNonPassMessage(result) {
|
|
16942
|
+
if (result.status === "continue") {
|
|
16943
|
+
return serializeReceipt(result.receipt);
|
|
16944
|
+
}
|
|
16945
|
+
if (result.status === "transport_failure") {
|
|
16946
|
+
const head = `\u95E8\u4E0B\u7701 ${result.status}\uFF08${result.stage}\uFF09\uFF1A${result.reason}`;
|
|
16947
|
+
return result.submission === void 0 ? head : `${head}
|
|
16948
|
+
${serializeReceipt(result.submission)}`;
|
|
16949
|
+
}
|
|
16950
|
+
return `\u95E8\u4E0B\u7701 ${result.status}\uFF08${result.stage}\uFF09\uFF1A${result.reason}`;
|
|
16951
|
+
}
|
|
16952
|
+
function unreadableDiscriminatorNotice(field, received) {
|
|
16953
|
+
if (received === void 0) return `\u8BFB\u4E0D\u51FA ${field}`;
|
|
16954
|
+
return `\u8BFB\u4E0D\u51FA ${field}\uFF1A${readableGateItem(received)}`;
|
|
16955
|
+
}
|
|
16956
|
+
function receivedDiscriminator(receipt, field) {
|
|
16957
|
+
if (receipt === null || typeof receipt !== "object" || Array.isArray(receipt)) return void 0;
|
|
16958
|
+
if (!Object.hasOwn(receipt, field)) return void 0;
|
|
16959
|
+
return receipt[field];
|
|
16960
|
+
}
|
|
16961
|
+
var GatekeeperDecisionError;
|
|
16962
|
+
var init_submission_errors = __esm({
|
|
16963
|
+
"src/submission-errors.ts"() {
|
|
16964
|
+
"use strict";
|
|
16965
|
+
init_readable_gate_item();
|
|
16966
|
+
GatekeeperDecisionError = class extends Error {
|
|
16967
|
+
result;
|
|
16968
|
+
constructor(result, message) {
|
|
16969
|
+
super(message ?? gatekeeperNonPassMessage(result));
|
|
16970
|
+
this.name = "GatekeeperDecisionError";
|
|
16971
|
+
this.result = result;
|
|
16972
|
+
}
|
|
16973
|
+
};
|
|
16974
|
+
}
|
|
16975
|
+
});
|
|
16976
|
+
|
|
17195
16977
|
// src/run-terminal-artifacts.ts
|
|
17196
16978
|
var run_terminal_artifacts_exports = {};
|
|
17197
16979
|
__export(run_terminal_artifacts_exports, {
|
|
@@ -17210,14 +16992,14 @@ function isMissingPathError2(error) {
|
|
|
17210
16992
|
function errorText2(error) {
|
|
17211
16993
|
return error instanceof Error ? error.message : String(error);
|
|
17212
16994
|
}
|
|
17213
|
-
function
|
|
16995
|
+
function isRecord(value) {
|
|
17214
16996
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17215
16997
|
}
|
|
17216
16998
|
function readUsableTerminalArtifactBody(body) {
|
|
17217
16999
|
if (body === null) {
|
|
17218
17000
|
return { ok: false, reason: "terminal artifact JSON value is null" };
|
|
17219
17001
|
}
|
|
17220
|
-
if (!
|
|
17002
|
+
if (!isRecord(body)) {
|
|
17221
17003
|
return {
|
|
17222
17004
|
ok: false,
|
|
17223
17005
|
reason: `terminal artifact JSON value is not a typed object (${Array.isArray(body) ? "array" : typeof body})`
|
|
@@ -17672,10 +17454,10 @@ __export(session_assistant_usage_exports, {
|
|
|
17672
17454
|
});
|
|
17673
17455
|
import { join as join13 } from "node:path";
|
|
17674
17456
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
17675
|
-
const { readFile:
|
|
17457
|
+
const { readFile: readFile22 } = await import("node:fs/promises");
|
|
17676
17458
|
let text;
|
|
17677
17459
|
try {
|
|
17678
|
-
text = await
|
|
17460
|
+
text = await readFile22(sessionFile, "utf8");
|
|
17679
17461
|
} catch (error) {
|
|
17680
17462
|
if (error?.code === "ENOENT") return void 0;
|
|
17681
17463
|
throw error;
|
|
@@ -17934,14 +17716,6 @@ function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
|
17934
17716
|
}
|
|
17935
17717
|
return { sessionDir, recordFile, ledgerHome };
|
|
17936
17718
|
}
|
|
17937
|
-
function projectTicketRecordsPathShape() {
|
|
17938
|
-
const { recordFile } = ticketProvenanceUnderBookPaths(
|
|
17939
|
-
join14("~", ".ak-roles"),
|
|
17940
|
-
"<\u7C3F>",
|
|
17941
|
-
"<\u7968\u53F7>"
|
|
17942
|
-
);
|
|
17943
|
-
return recordFile.replace(/\\/g, "/");
|
|
17944
|
-
}
|
|
17945
17719
|
function resolveSitianRecordPath(input) {
|
|
17946
17720
|
const ledgerHome = input.home !== void 0 && input.home.length > 0 ? resolveActivationLedgerHome(input.home) : resolveActivationLedgerHomeForPath(input.runDirectory ?? input.sessionParent);
|
|
17947
17721
|
return resolveSitianRecordPathInLedger(input, ledgerHome);
|
|
@@ -18004,7 +17778,7 @@ var init_sitian_appender = __esm({
|
|
|
18004
17778
|
// src/sitian-reader.ts
|
|
18005
17779
|
import { existsSync as existsSync3 } from "node:fs";
|
|
18006
17780
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
18007
|
-
function
|
|
17781
|
+
function isRecord2(value) {
|
|
18008
17782
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18009
17783
|
}
|
|
18010
17784
|
async function readSitianRecords(recordFile) {
|
|
@@ -18020,7 +17794,7 @@ async function readSitianRecords(recordFile) {
|
|
|
18020
17794
|
if (!line2.trim()) continue;
|
|
18021
17795
|
try {
|
|
18022
17796
|
const parsed = JSON.parse(line2);
|
|
18023
|
-
if (
|
|
17797
|
+
if (isRecord2(parsed)) {
|
|
18024
17798
|
records.push(parsed);
|
|
18025
17799
|
} else {
|
|
18026
17800
|
const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
|
|
@@ -18073,7 +17847,7 @@ __export(role_turn_host_exports, {
|
|
|
18073
17847
|
createPiRoleTurnHost: () => createPiRoleTurnHost,
|
|
18074
17848
|
resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint
|
|
18075
17849
|
});
|
|
18076
|
-
import { execFile, spawn
|
|
17850
|
+
import { execFile, spawn } from "node:child_process";
|
|
18077
17851
|
import { constants as constants2 } from "node:fs";
|
|
18078
17852
|
import { access, appendFile, readFile as readFile7, realpath } from "node:fs/promises";
|
|
18079
17853
|
import { delimiter as delimiter2, dirname as dirname8, isAbsolute as isAbsolute3, join as join15, resolve as resolve4 } from "node:path";
|
|
@@ -18183,7 +17957,7 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
18183
17957
|
const command = spawnOptions.env.PI_BINARY ?? "pi";
|
|
18184
17958
|
const piIdentity = await selectedPiIdentity(command, spawnOptions.cwd, spawnOptions.env);
|
|
18185
17959
|
return await new Promise((resolveResult, reject) => {
|
|
18186
|
-
const child =
|
|
17960
|
+
const child = spawn(piIdentity.executable, [...args], {
|
|
18187
17961
|
cwd: spawnOptions.cwd,
|
|
18188
17962
|
env: spawnOptions.env,
|
|
18189
17963
|
stdio: ["pipe", "ignore", "pipe"]
|
|
@@ -18388,6 +18162,19 @@ var init_sha256 = __esm({
|
|
|
18388
18162
|
}
|
|
18389
18163
|
});
|
|
18390
18164
|
|
|
18165
|
+
// src/submission-correctable-error.ts
|
|
18166
|
+
var correctableSubmissionErrorBrand, CorrectableSubmissionError;
|
|
18167
|
+
var init_submission_correctable_error = __esm({
|
|
18168
|
+
"src/submission-correctable-error.ts"() {
|
|
18169
|
+
"use strict";
|
|
18170
|
+
init_submission_errors();
|
|
18171
|
+
correctableSubmissionErrorBrand = /* @__PURE__ */ Symbol("ak-roles.correctable-submission-error");
|
|
18172
|
+
CorrectableSubmissionError = class extends Error {
|
|
18173
|
+
[correctableSubmissionErrorBrand] = true;
|
|
18174
|
+
};
|
|
18175
|
+
}
|
|
18176
|
+
});
|
|
18177
|
+
|
|
18391
18178
|
// src/package-contracts/terminating-tools.ts
|
|
18392
18179
|
function isTerminatingToolName(name) {
|
|
18393
18180
|
return TERMINATING_TOOL_NAMES.includes(name);
|
|
@@ -18593,11 +18380,6 @@ var init_doctor_evidence = __esm({
|
|
|
18593
18380
|
});
|
|
18594
18381
|
|
|
18595
18382
|
// src/public-cli/github-remote.ts
|
|
18596
|
-
function ownerFromGitHubRemoteUrl(remoteUrl) {
|
|
18597
|
-
const ownerRepo = ownerRepoFromGitHubRemoteUrl(remoteUrl);
|
|
18598
|
-
if (ownerRepo === void 0) return void 0;
|
|
18599
|
-
return ownerRepo.split("/")[0].toLowerCase();
|
|
18600
|
-
}
|
|
18601
18383
|
function ownerRepoFromGitHubRemoteUrl(remoteUrl) {
|
|
18602
18384
|
const trimmed = remoteUrl.trim();
|
|
18603
18385
|
const scp = /^git@github\.com:([^/\s]+)\/([^/\s]+?)(?:\.git)?$/i.exec(trimmed);
|
|
@@ -18631,143 +18413,6 @@ var init_github_remote = __esm({
|
|
|
18631
18413
|
}
|
|
18632
18414
|
});
|
|
18633
18415
|
|
|
18634
|
-
// src/collector-target.ts
|
|
18635
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
18636
|
-
function ambiguousTarget(detail, cause) {
|
|
18637
|
-
throw new CliUsageError(
|
|
18638
|
-
`collector target is ambiguous: ${detail}; pass an explicit --pr`,
|
|
18639
|
-
cause === void 0 ? void 0 : { cause }
|
|
18640
|
-
);
|
|
18641
|
-
}
|
|
18642
|
-
function gitFailure(detail, cause) {
|
|
18643
|
-
throw new Error(`collector git failed: ${detail}`, {
|
|
18644
|
-
cause: cause instanceof Error ? cause : new Error(String(cause))
|
|
18645
|
-
});
|
|
18646
|
-
}
|
|
18647
|
-
function gitText(projectRoot, args) {
|
|
18648
|
-
return execFileSync2("git", [...args], {
|
|
18649
|
-
cwd: projectRoot,
|
|
18650
|
-
encoding: "utf8",
|
|
18651
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
18652
|
-
}).trim();
|
|
18653
|
-
}
|
|
18654
|
-
function isGitConfigMissing(error) {
|
|
18655
|
-
if (typeof error !== "object" || error === null) return false;
|
|
18656
|
-
const status = error.status;
|
|
18657
|
-
return status === 1;
|
|
18658
|
-
}
|
|
18659
|
-
function readCurrentBranch(projectRoot) {
|
|
18660
|
-
try {
|
|
18661
|
-
return gitText(projectRoot, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
18662
|
-
} catch (error) {
|
|
18663
|
-
gitFailure("cannot read current git branch", error);
|
|
18664
|
-
}
|
|
18665
|
-
}
|
|
18666
|
-
function readHeadSha(projectRoot) {
|
|
18667
|
-
try {
|
|
18668
|
-
return gitText(projectRoot, ["rev-parse", "HEAD"]);
|
|
18669
|
-
} catch (error) {
|
|
18670
|
-
gitFailure("cannot read current HEAD", error);
|
|
18671
|
-
}
|
|
18672
|
-
}
|
|
18673
|
-
function headRefFromMerge(merge) {
|
|
18674
|
-
const trimmed = merge.trim();
|
|
18675
|
-
if (trimmed.length === 0) return void 0;
|
|
18676
|
-
if (trimmed.startsWith("refs/heads/")) {
|
|
18677
|
-
const ref = trimmed.slice("refs/heads/".length);
|
|
18678
|
-
return ref.length > 0 ? ref : void 0;
|
|
18679
|
-
}
|
|
18680
|
-
if (trimmed.startsWith("refs/")) return void 0;
|
|
18681
|
-
return trimmed;
|
|
18682
|
-
}
|
|
18683
|
-
function readUpstreamHeadBinding(projectRoot, branch) {
|
|
18684
|
-
let remote;
|
|
18685
|
-
try {
|
|
18686
|
-
remote = gitText(projectRoot, ["config", "--get", `branch.${branch}.remote`]);
|
|
18687
|
-
} catch (error) {
|
|
18688
|
-
if (isGitConfigMissing(error)) remote = void 0;
|
|
18689
|
-
else gitFailure(`cannot read branch.${branch}.remote`, error);
|
|
18690
|
-
}
|
|
18691
|
-
if (remote === void 0 || remote.length === 0) return void 0;
|
|
18692
|
-
let merge;
|
|
18693
|
-
try {
|
|
18694
|
-
merge = gitText(projectRoot, ["config", "--get", `branch.${branch}.merge`]);
|
|
18695
|
-
} catch (error) {
|
|
18696
|
-
if (isGitConfigMissing(error)) merge = void 0;
|
|
18697
|
-
else gitFailure(`cannot read branch.${branch}.merge`, error);
|
|
18698
|
-
}
|
|
18699
|
-
if (merge === void 0 || merge.length === 0) return void 0;
|
|
18700
|
-
const headRef = headRefFromMerge(merge);
|
|
18701
|
-
if (headRef === void 0) return void 0;
|
|
18702
|
-
let remoteUrl;
|
|
18703
|
-
try {
|
|
18704
|
-
remoteUrl = gitText(projectRoot, ["remote", "get-url", remote]);
|
|
18705
|
-
} catch (error) {
|
|
18706
|
-
gitFailure(`cannot read remote URL for ${remote}`, error);
|
|
18707
|
-
}
|
|
18708
|
-
const headOwner = ownerFromGitHubRemoteUrl(remoteUrl);
|
|
18709
|
-
if (headOwner === void 0) return void 0;
|
|
18710
|
-
return { headOwner, headRef };
|
|
18711
|
-
}
|
|
18712
|
-
async function resolveCollectorTarget(input) {
|
|
18713
|
-
if (input.explicitPrNumber !== void 0) {
|
|
18714
|
-
return { kind: "bound", prNumber: input.explicitPrNumber };
|
|
18715
|
-
}
|
|
18716
|
-
const branch = readCurrentBranch(input.projectRoot);
|
|
18717
|
-
const detached = branch.length === 0 || branch === "HEAD";
|
|
18718
|
-
const runner = createGhApiRunner();
|
|
18719
|
-
const { owner, repo } = input.repository;
|
|
18720
|
-
const numbers = [];
|
|
18721
|
-
if (!detached) {
|
|
18722
|
-
const headSha = readHeadSha(input.projectRoot);
|
|
18723
|
-
const upstream = readUpstreamHeadBinding(input.projectRoot, branch);
|
|
18724
|
-
if (upstream !== void 0) {
|
|
18725
|
-
numbers.push(
|
|
18726
|
-
...await listPullRequestNumbersByHead(runner, {
|
|
18727
|
-
owner,
|
|
18728
|
-
repo,
|
|
18729
|
-
headOwner: upstream.headOwner,
|
|
18730
|
-
headRef: upstream.headRef
|
|
18731
|
-
})
|
|
18732
|
-
);
|
|
18733
|
-
}
|
|
18734
|
-
numbers.push(
|
|
18735
|
-
...await listPullRequestNumbersByCommit(runner, {
|
|
18736
|
-
owner,
|
|
18737
|
-
repo,
|
|
18738
|
-
commitSha: headSha
|
|
18739
|
-
})
|
|
18740
|
-
);
|
|
18741
|
-
} else {
|
|
18742
|
-
const headSha = readHeadSha(input.projectRoot);
|
|
18743
|
-
numbers.push(
|
|
18744
|
-
...await listPullRequestNumbersByCommit(runner, {
|
|
18745
|
-
owner,
|
|
18746
|
-
repo,
|
|
18747
|
-
commitSha: headSha
|
|
18748
|
-
})
|
|
18749
|
-
);
|
|
18750
|
-
}
|
|
18751
|
-
const unique = [...new Set(numbers)];
|
|
18752
|
-
if (unique.length === 1) {
|
|
18753
|
-
return { kind: "bound", prNumber: unique[0] };
|
|
18754
|
-
}
|
|
18755
|
-
if (unique.length > 1) {
|
|
18756
|
-
ambiguousTarget(
|
|
18757
|
-
`multiple PRs associated with context: ${unique.join(", ")}`
|
|
18758
|
-
);
|
|
18759
|
-
}
|
|
18760
|
-
return { kind: "unbound" };
|
|
18761
|
-
}
|
|
18762
|
-
var init_collector_target = __esm({
|
|
18763
|
-
"src/collector-target.ts"() {
|
|
18764
|
-
"use strict";
|
|
18765
|
-
init_collector_github();
|
|
18766
|
-
init_cli_errors();
|
|
18767
|
-
init_github_remote();
|
|
18768
|
-
}
|
|
18769
|
-
});
|
|
18770
|
-
|
|
18771
18416
|
// src/git-object-id.ts
|
|
18772
18417
|
function isFullGitObjectId(value) {
|
|
18773
18418
|
return typeof value === "string" && FULL_GIT_OBJECT_ID_RE.test(value);
|
|
@@ -18880,7 +18525,7 @@ var init_merger_git_state = __esm({
|
|
|
18880
18525
|
|
|
18881
18526
|
// src/ledger-session-read.ts
|
|
18882
18527
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
18883
|
-
function
|
|
18528
|
+
function isRecord3(value) {
|
|
18884
18529
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18885
18530
|
}
|
|
18886
18531
|
async function readLedgerSessionJsonlLines(path) {
|
|
@@ -18905,7 +18550,7 @@ async function readLedgerSessionJsonlLines(path) {
|
|
|
18905
18550
|
});
|
|
18906
18551
|
continue;
|
|
18907
18552
|
}
|
|
18908
|
-
if (!
|
|
18553
|
+
if (!isRecord3(row)) {
|
|
18909
18554
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
18910
18555
|
out.push({
|
|
18911
18556
|
line: lineNumber,
|
|
@@ -18958,7 +18603,7 @@ function extractSessionModelSequence(rows) {
|
|
|
18958
18603
|
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
18959
18604
|
push(row.modelId);
|
|
18960
18605
|
}
|
|
18961
|
-
const message =
|
|
18606
|
+
const message = isRecord3(row.message) ? row.message : void 0;
|
|
18962
18607
|
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
18963
18608
|
push(message.model);
|
|
18964
18609
|
}
|
|
@@ -18974,11 +18619,11 @@ function extractSessionToolIntervals(rows) {
|
|
|
18974
18619
|
const openById = /* @__PURE__ */ new Map();
|
|
18975
18620
|
for (const row of rows) {
|
|
18976
18621
|
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
18977
|
-
const message =
|
|
18622
|
+
const message = isRecord3(row.message) ? row.message : void 0;
|
|
18978
18623
|
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
18979
18624
|
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
18980
18625
|
for (const part of message.content) {
|
|
18981
|
-
if (!
|
|
18626
|
+
if (!isRecord3(part) || part.type !== "toolCall") continue;
|
|
18982
18627
|
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
18983
18628
|
throw new Error("toolCall frame missing string id");
|
|
18984
18629
|
}
|
|
@@ -18991,7 +18636,7 @@ function extractSessionToolIntervals(rows) {
|
|
|
18991
18636
|
if (openById.has(part.id)) {
|
|
18992
18637
|
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
18993
18638
|
}
|
|
18994
|
-
const args =
|
|
18639
|
+
const args = isRecord3(part.arguments) ? part.arguments : void 0;
|
|
18995
18640
|
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
18996
18641
|
const interval = {
|
|
18997
18642
|
toolCallId: part.id,
|
|
@@ -19102,12 +18747,6 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
19102
18747
|
...home === void 0 ? {} : { home }
|
|
19103
18748
|
};
|
|
19104
18749
|
}
|
|
19105
|
-
function resolveTicketProvenanceVolume(ticketNumber, cwd, home) {
|
|
19106
|
-
const path = resolveSitianRecordPath(
|
|
19107
|
-
ticketProvenanceRecordInput(ticketNumber, cwd, home)
|
|
19108
|
-
);
|
|
19109
|
-
return { recordFile: path.recordFile, volumeDir: path.sessionDir };
|
|
19110
|
-
}
|
|
19111
18750
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
19112
18751
|
const source = join16(runDirectory, "records.jsonl");
|
|
19113
18752
|
let content;
|
|
@@ -19834,13 +19473,12 @@ var init_option_definitions = __esm({
|
|
|
19834
19473
|
canonical: "--pr",
|
|
19835
19474
|
aliases: [],
|
|
19836
19475
|
valueMetavar: "number",
|
|
19837
|
-
// #676 D1: optional when context uniquely determines the PR; ambiguous → require explicit.
|
|
19838
19476
|
required: false,
|
|
19839
19477
|
repeatable: false,
|
|
19840
19478
|
form: "option",
|
|
19841
19479
|
description: {
|
|
19842
|
-
en: "Positive GitHub pull request number. Optional when
|
|
19843
|
-
zh: "\u6B63\u6574\u6570 GitHub PR \u53F7\u3002\
|
|
19480
|
+
en: "Positive GitHub pull request number. Optional when the Collector role locates the PR via host CLI from task materials.",
|
|
19481
|
+
zh: "\u6B63\u6574\u6570 GitHub PR \u53F7\u3002\u53EF\u9009\uFF1B\u7701\u7565\u65F6\u7531\u901A\u8FDB\u53F8\u7ECF\u5BBF\u4E3B CLI \u4ECE\u4EFB\u52A1\u6750\u6599\u81EA\u884C\u5B9A\u4F4D\u3002"
|
|
19844
19482
|
}
|
|
19845
19483
|
},
|
|
19846
19484
|
{
|
|
@@ -19867,22 +19505,8 @@ var init_option_definitions = __esm({
|
|
|
19867
19505
|
repeatable: false,
|
|
19868
19506
|
form: "option",
|
|
19869
19507
|
description: {
|
|
19870
|
-
en: "Optional request manifest JSON path ({requests:[{id,body}]}).
|
|
19871
|
-
zh: "\u53EF\u9009 request manifest JSON \u8DEF\u5F84\uFF08{requests:[{id,body}]}\uFF09\u3002\
|
|
19872
|
-
}
|
|
19873
|
-
},
|
|
19874
|
-
{
|
|
19875
|
-
id: "wait-ms",
|
|
19876
|
-
owner: "collector",
|
|
19877
|
-
canonical: "--wait-ms",
|
|
19878
|
-
aliases: [],
|
|
19879
|
-
valueMetavar: "ms",
|
|
19880
|
-
required: false,
|
|
19881
|
-
repeatable: false,
|
|
19882
|
-
form: "option",
|
|
19883
|
-
description: {
|
|
19884
|
-
en: "Wait-window duration in milliseconds after the work step opens (default 600000 = 10 minutes). Does not require a code change to adjust.",
|
|
19885
|
-
zh: "\u5DE5\u4F5C\u6B65\u9AA4\u5F00\u542F\u540E\u7684\u7B49\u5F85\u7A97\u65F6\u957F\uFF08\u6BEB\u79D2\uFF1B\u9ED8\u8BA4 600000\uFF1D\u5341\u5206\u949F\uFF09\u3002\u6539\u914D\u7F6E\u5373\u53EF\uFF0C\u65E0\u9700\u6539\u4EE3\u7801\u3002"
|
|
19508
|
+
en: "Optional request manifest JSON path ({requests:[{id,body}]}). Parsed for semantics and passed to the Collector as materials \u2014 not a machine collection directive.",
|
|
19509
|
+
zh: "\u53EF\u9009 request manifest JSON \u8DEF\u5F84\uFF08{requests:[{id,body}]}\uFF09\u3002\u6309\u8BED\u4E49\u89E3\u6790\u540E\u4F5C\u4E3A\u6750\u6599\u9012\u7ED9\u901A\u8FDB\u53F8\uFF0C\u4E0D\u662F\u673A\u5668\u4EE3\u6536 finding \u7684\u6307\u4EE4\u3002"
|
|
19886
19510
|
}
|
|
19887
19511
|
}
|
|
19888
19512
|
];
|
|
@@ -20338,7 +19962,7 @@ var init_option_definitions = __esm({
|
|
|
20338
19962
|
});
|
|
20339
19963
|
|
|
20340
19964
|
// src/public-cli/invocation.ts
|
|
20341
|
-
import { execFileSync as
|
|
19965
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
20342
19966
|
import { existsSync as existsSync4 } from "node:fs";
|
|
20343
19967
|
import {
|
|
20344
19968
|
lstat as lstat4,
|
|
@@ -20738,17 +20362,6 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
20738
20362
|
case "request-manifest":
|
|
20739
20363
|
fields.requestManifestPath = requireOptionPath(taken.def.canonical, value);
|
|
20740
20364
|
return;
|
|
20741
|
-
case "wait-ms": {
|
|
20742
|
-
if (value === void 0 || !/^[1-9]\d*$/.test(value.trim())) {
|
|
20743
|
-
throw new CliUsageError("--wait-ms requires a positive safe-integer millisecond value");
|
|
20744
|
-
}
|
|
20745
|
-
const parsed = Number(value.trim());
|
|
20746
|
-
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
20747
|
-
throw new CliUsageError("--wait-ms requires a positive safe-integer millisecond value");
|
|
20748
|
-
}
|
|
20749
|
-
fields.waitWindowMs = parsed;
|
|
20750
|
-
return;
|
|
20751
|
-
}
|
|
20752
20365
|
case "issue": {
|
|
20753
20366
|
if (value === void 0 || value.trim() === "") {
|
|
20754
20367
|
throw new CliUsageError("doctor --issue requires a positive integer");
|
|
@@ -20845,7 +20458,6 @@ function parsePublicSeatArgv(owner, args) {
|
|
|
20845
20458
|
...fields.prNumber === void 0 ? {} : { prNumber: fields.prNumber },
|
|
20846
20459
|
...fields.repo === void 0 ? {} : { repo: fields.repo },
|
|
20847
20460
|
...fields.requestManifestPath === void 0 ? {} : { requestManifestPath: fields.requestManifestPath },
|
|
20848
|
-
...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs },
|
|
20849
20461
|
...fields.issueNumber === void 0 ? {} : { issueNumber: fields.issueNumber },
|
|
20850
20462
|
...fields.runs === void 0 ? {} : { runs: fields.runs },
|
|
20851
20463
|
...fields.sourceRun === void 0 ? {} : { sourceRun: fields.sourceRun },
|
|
@@ -21205,23 +20817,16 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
21205
20817
|
attachmentPaths,
|
|
21206
20818
|
...project,
|
|
21207
20819
|
placedFields: async (placed) => {
|
|
21208
|
-
const target = await resolveCollectorTarget({
|
|
21209
|
-
projectRoot,
|
|
21210
|
-
repository,
|
|
21211
|
-
...explicitPrNumber === void 0 ? {} : { explicitPrNumber }
|
|
21212
|
-
});
|
|
21213
|
-
const prNumber = target.kind === "bound" ? target.prNumber : void 0;
|
|
21214
20820
|
let requestManifestPath;
|
|
21215
20821
|
if (manifestCanonicalJson !== void 0) {
|
|
21216
20822
|
requestManifestPath = join18(placed.runDirectory, "request-manifest.json");
|
|
21217
20823
|
await writeFile3(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
21218
20824
|
}
|
|
21219
20825
|
return {
|
|
21220
|
-
...
|
|
20826
|
+
...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
|
|
21221
20827
|
repository: repository.canonical,
|
|
21222
20828
|
repositoryDisplay: repository.display,
|
|
21223
20829
|
...requestManifestPath === void 0 ? {} : { requestManifestPath },
|
|
21224
|
-
...parsed.waitWindowMs === void 0 ? {} : { waitWindowMs: parsed.waitWindowMs },
|
|
21225
20830
|
manifestDigest
|
|
21226
20831
|
};
|
|
21227
20832
|
}
|
|
@@ -21655,7 +21260,7 @@ function parseRepoOption(raw) {
|
|
|
21655
21260
|
function resolveGitHubRemoteRepository(projectRoot) {
|
|
21656
21261
|
let remoteUrl;
|
|
21657
21262
|
try {
|
|
21658
|
-
remoteUrl =
|
|
21263
|
+
remoteUrl = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
21659
21264
|
cwd: projectRoot,
|
|
21660
21265
|
encoding: "utf8",
|
|
21661
21266
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -22007,7 +21612,6 @@ var init_invocation = __esm({
|
|
|
22007
21612
|
init_doctor_evidence();
|
|
22008
21613
|
init_diarist_contracts();
|
|
22009
21614
|
init_collector_config();
|
|
22010
|
-
init_collector_target();
|
|
22011
21615
|
init_github_remote();
|
|
22012
21616
|
init_fixer_packet();
|
|
22013
21617
|
init_merger_git_state();
|
|
@@ -22188,7 +21792,7 @@ var init_role_turn_host_resolution = __esm({
|
|
|
22188
21792
|
// src/analyst-gate-cycles-read.ts
|
|
22189
21793
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
22190
21794
|
import { join as join21 } from "node:path";
|
|
22191
|
-
function
|
|
21795
|
+
function isRecord4(value) {
|
|
22192
21796
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22193
21797
|
}
|
|
22194
21798
|
function isParentAttemptBindingRow(row) {
|
|
@@ -22218,7 +21822,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
22218
21822
|
function acceptedGateReceiptIds(rows) {
|
|
22219
21823
|
const accepted = /* @__PURE__ */ new Set();
|
|
22220
21824
|
for (const row of rows) {
|
|
22221
|
-
const message =
|
|
21825
|
+
const message = isRecord4(row.message) ? row.message : void 0;
|
|
22222
21826
|
if (message?.role !== "toolResult") continue;
|
|
22223
21827
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
22224
21828
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -22253,7 +21857,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
22253
21857
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
22254
21858
|
const row = rows[i];
|
|
22255
21859
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
22256
|
-
if (!
|
|
21860
|
+
if (!isRecord4(row.data) || !isRecord4(row.data.parent)) continue;
|
|
22257
21861
|
const id = row.data.parent.attemptEntryId;
|
|
22258
21862
|
const sessionFile = row.data.parent.sessionFile;
|
|
22259
21863
|
return {
|
|
@@ -22268,10 +21872,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22268
21872
|
const out = [];
|
|
22269
21873
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
22270
21874
|
const row = rows[rowIndex];
|
|
22271
|
-
const message =
|
|
21875
|
+
const message = isRecord4(row.message) ? row.message : void 0;
|
|
22272
21876
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
22273
21877
|
for (const part of message.content) {
|
|
22274
|
-
if (!
|
|
21878
|
+
if (!isRecord4(part) || part.type !== "toolCall") continue;
|
|
22275
21879
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
22276
21880
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
22277
21881
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -22279,7 +21883,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22279
21883
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
22280
21884
|
out.push({
|
|
22281
21885
|
toolName: part.name,
|
|
22282
|
-
args:
|
|
21886
|
+
args: isRecord4(part.arguments) ? part.arguments : void 0,
|
|
22283
21887
|
accepted: true,
|
|
22284
21888
|
rowIndex,
|
|
22285
21889
|
...binding
|
|
@@ -22402,17 +22006,17 @@ function pairGateRounds(volumes) {
|
|
|
22402
22006
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
22403
22007
|
}
|
|
22404
22008
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
22405
|
-
const { readFile:
|
|
22009
|
+
const { readFile: readFile22 } = await import("node:fs/promises");
|
|
22406
22010
|
let raw;
|
|
22407
22011
|
try {
|
|
22408
|
-
raw = JSON.parse(await
|
|
22012
|
+
raw = JSON.parse(await readFile22(pointerPath, "utf8"));
|
|
22409
22013
|
} catch (error) {
|
|
22410
22014
|
throw new Error(
|
|
22411
22015
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
22412
22016
|
{ cause: error }
|
|
22413
22017
|
);
|
|
22414
22018
|
}
|
|
22415
|
-
if (!
|
|
22019
|
+
if (!isRecord4(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
22416
22020
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
22417
22021
|
}
|
|
22418
22022
|
const sessionFile = raw.sessionFile;
|
|
@@ -22898,11 +22502,11 @@ var init_serialize_thrown_value = __esm({
|
|
|
22898
22502
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
22899
22503
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
22900
22504
|
import { dirname as dirname14, join as join25 } from "node:path";
|
|
22901
|
-
function
|
|
22505
|
+
function isRecord5(value) {
|
|
22902
22506
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22903
22507
|
}
|
|
22904
22508
|
function callFactFromSitianPayload(payload, pointer) {
|
|
22905
|
-
if (!
|
|
22509
|
+
if (!isRecord5(payload)) return void 0;
|
|
22906
22510
|
if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
|
|
22907
22511
|
if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
|
|
22908
22512
|
return void 0;
|
|
@@ -22919,11 +22523,11 @@ function callFactFromSitianPayload(payload, pointer) {
|
|
|
22919
22523
|
};
|
|
22920
22524
|
}
|
|
22921
22525
|
function invocationScopeIdOfRecord(record4) {
|
|
22922
|
-
if (
|
|
22526
|
+
if (isRecord5(record4.subject)) {
|
|
22923
22527
|
const fromSubject = record4.subject.invocationScopeId;
|
|
22924
22528
|
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
22925
22529
|
}
|
|
22926
|
-
if (
|
|
22530
|
+
if (isRecord5(record4.payload)) {
|
|
22927
22531
|
const fromPayload = record4.payload.invocationScopeId;
|
|
22928
22532
|
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
22929
22533
|
}
|
|
@@ -22984,7 +22588,7 @@ function readInvocationRecord(runDirectory) {
|
|
|
22984
22588
|
const raw = JSON.parse(
|
|
22985
22589
|
readFileSync2(join25(runDirectory, "invocation.json"), "utf8")
|
|
22986
22590
|
);
|
|
22987
|
-
return
|
|
22591
|
+
return isRecord5(raw) ? raw : void 0;
|
|
22988
22592
|
} catch (error) {
|
|
22989
22593
|
if (error?.code === "ENOENT") return void 0;
|
|
22990
22594
|
throw error;
|
|
@@ -22997,7 +22601,7 @@ async function readInvocationEngineMounted(runDirectory) {
|
|
|
22997
22601
|
}
|
|
22998
22602
|
function withEngineDetourToolUsageFact(outcome, usage) {
|
|
22999
22603
|
if (usage === void 0) return outcome;
|
|
23000
|
-
const prior =
|
|
22604
|
+
const prior = isRecord5(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
|
|
23001
22605
|
return {
|
|
23002
22606
|
...outcome,
|
|
23003
22607
|
decisiveFacts: {
|
|
@@ -23067,13 +22671,13 @@ function resolveAuditDossier(source) {
|
|
|
23067
22671
|
}
|
|
23068
22672
|
return { status: "ok", runDirectory };
|
|
23069
22673
|
}
|
|
23070
|
-
function
|
|
22674
|
+
function isRecord6(value) {
|
|
23071
22675
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23072
22676
|
}
|
|
23073
22677
|
function readDoctorAuditSubjects(context) {
|
|
23074
22678
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
23075
22679
|
for (const entry of entries) {
|
|
23076
|
-
if (
|
|
22680
|
+
if (isRecord6(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
23077
22681
|
return { status: "ok" };
|
|
23078
22682
|
}
|
|
23079
22683
|
}
|
|
@@ -23218,11 +22822,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
23218
22822
|
});
|
|
23219
22823
|
|
|
23220
22824
|
// src/receipt-delivery-policy.ts
|
|
23221
|
-
function
|
|
22825
|
+
function isRecord7(value) {
|
|
23222
22826
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23223
22827
|
}
|
|
23224
22828
|
function parseNoReceiptLifecycleFacts(input) {
|
|
23225
|
-
if (!
|
|
22829
|
+
if (!isRecord7(input) || typeof input.terminalToolCalled !== "boolean" || input.deliveryTurns !== RECEIPT_DELIVERY_TURN_LIMIT || input.sessionCompletion !== "settled-without-accepted-receipt" || input.acceptedReceipt !== false || typeof input.runPointer !== "string" || input.runPointer.trim() === "" || typeof input.attemptPointer !== "string" || input.attemptPointer.trim() === "" || !Array.isArray(input.rejectedReceipts) || !input.rejectedReceipts.every((item) => isRecord7(item) && typeof item.reason === "string")) {
|
|
23226
22830
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
23227
22831
|
}
|
|
23228
22832
|
return {
|
|
@@ -23278,7 +22882,6 @@ __export(settlement_exports, {
|
|
|
23278
22882
|
controlledFailureInputFromResolution: () => controlledFailureInputFromResolution,
|
|
23279
22883
|
exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
|
|
23280
22884
|
explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
|
|
23281
|
-
extractCollectorInfrastructureFailure: () => extractCollectorInfrastructureFailure,
|
|
23282
22885
|
extractEngineDetourInfrastructureFailure: () => extractEngineDetourInfrastructureFailure,
|
|
23283
22886
|
extractGateFactFromSessionDirectory: () => extractGateFactFromSessionDirectory,
|
|
23284
22887
|
extractNavigatorFact: () => extractNavigatorFact,
|
|
@@ -23299,7 +22902,6 @@ __export(settlement_exports, {
|
|
|
23299
22902
|
publishedFailureErrorPath: () => publishedFailureErrorPath,
|
|
23300
22903
|
raceNavigatorGrace: () => raceNavigatorGrace,
|
|
23301
22904
|
readBoundSessionEntries: () => readBoundSessionEntries,
|
|
23302
|
-
readCollectorInfrastructureFailure: () => readCollectorInfrastructureFailure,
|
|
23303
22905
|
readEngineDetourInfrastructureFailure: () => readEngineDetourInfrastructureFailure,
|
|
23304
22906
|
readSessionProviderStop: () => readSessionProviderStop,
|
|
23305
22907
|
recordedSubmissionPayloads: () => recordedSubmissionPayloads,
|
|
@@ -23797,7 +23399,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
23797
23399
|
const { records } = await readSitianRecords(recordFile);
|
|
23798
23400
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
23799
23401
|
const payload = records[i]?.payload;
|
|
23800
|
-
if (!
|
|
23402
|
+
if (!isRecord8(payload) || !isRecord8(payload.response)) continue;
|
|
23801
23403
|
if (typeof payload.type === "string") continue;
|
|
23802
23404
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
23803
23405
|
if (stop !== void 0) return stop;
|
|
@@ -23847,7 +23449,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
23847
23449
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
23848
23450
|
}
|
|
23849
23451
|
const header = entries.find((entry) => entry.type === "session");
|
|
23850
|
-
if (!
|
|
23452
|
+
if (!isRecord8(header)) continue;
|
|
23851
23453
|
const bindingIndexes = [];
|
|
23852
23454
|
for (let i = 0; i < entries.length; i += 1) {
|
|
23853
23455
|
const entry = entries[i];
|
|
@@ -23861,7 +23463,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
23861
23463
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
23862
23464
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
23863
23465
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
23864
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
23466
|
+
const bindingParent = bindingEntry !== void 0 && isRecord8(bindingEntry.data) && isRecord8(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
23865
23467
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
23866
23468
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
23867
23469
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -23885,12 +23487,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
23885
23487
|
if (stop === void 0) continue;
|
|
23886
23488
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
23887
23489
|
const entry = entries[i];
|
|
23888
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
23889
|
-
const parent =
|
|
23890
|
-
const failure =
|
|
23490
|
+
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !isRecord8(entry.data)) continue;
|
|
23491
|
+
const parent = isRecord8(entry.data.parent) ? entry.data.parent : void 0;
|
|
23492
|
+
const failure = isRecord8(entry.data.failure) ? entry.data.failure : void 0;
|
|
23891
23493
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
23892
23494
|
if (failure === void 0) continue;
|
|
23893
|
-
const identity =
|
|
23495
|
+
const identity = isRecord8(failure.identity) ? failure.identity : void 0;
|
|
23894
23496
|
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
23895
23497
|
return {
|
|
23896
23498
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -23899,7 +23501,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
23899
23501
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
23900
23502
|
} },
|
|
23901
23503
|
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
23902
|
-
...
|
|
23504
|
+
...isRecord8(failure.details) ? { details: failure.details } : {}
|
|
23903
23505
|
};
|
|
23904
23506
|
}
|
|
23905
23507
|
}
|
|
@@ -23946,9 +23548,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
23946
23548
|
if (classification.kind !== "infrastructure") continue;
|
|
23947
23549
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
23948
23550
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
23949
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
23950
|
-
const diagnostic =
|
|
23951
|
-
const details =
|
|
23551
|
+
const textPart = Array.isArray(message.content) ? message.content.find((part) => isRecord8(part) && part.type === "text" && typeof part.text === "string") : void 0;
|
|
23552
|
+
const diagnostic = isRecord8(textPart) ? textPart.text : void 0;
|
|
23553
|
+
const details = isRecord8(message.details) ? message.details : classification.fact;
|
|
23952
23554
|
return {
|
|
23953
23555
|
cause: "activation",
|
|
23954
23556
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -24085,7 +23687,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
24085
23687
|
} : {}
|
|
24086
23688
|
};
|
|
24087
23689
|
}
|
|
24088
|
-
function
|
|
23690
|
+
function isRecord8(value) {
|
|
24089
23691
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24090
23692
|
}
|
|
24091
23693
|
function toolResultText(message) {
|
|
@@ -24099,22 +23701,6 @@ function toolResultText(message) {
|
|
|
24099
23701
|
return "";
|
|
24100
23702
|
}).join("").trim();
|
|
24101
23703
|
}
|
|
24102
|
-
function extractCollectorTargetBindRejection(entries) {
|
|
24103
|
-
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
24104
|
-
const entry = entries[i];
|
|
24105
|
-
if (entry?.type !== "message") continue;
|
|
24106
|
-
const message = entry.message;
|
|
24107
|
-
if (message?.role !== "toolResult") continue;
|
|
24108
|
-
if (message.toolName !== COLLECTOR_BIND_TARGET_TOOL) continue;
|
|
24109
|
-
if (message.isError !== true) return void 0;
|
|
24110
|
-
const diagnostic = toolResultText(message);
|
|
24111
|
-
if (diagnostic.length === 0) return void 0;
|
|
24112
|
-
const details = message.details;
|
|
24113
|
-
const code = isRecord9(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
24114
|
-
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
24115
|
-
}
|
|
24116
|
-
return void 0;
|
|
24117
|
-
}
|
|
24118
23704
|
function boundErroredToolCandidate(entries, resultIndex, message, toolName) {
|
|
24119
23705
|
if (message.toolName !== toolName || message.isError !== true) return void 0;
|
|
24120
23706
|
const bound = boundRoleToolCallForResult(entries, resultIndex, message, toolName);
|
|
@@ -24155,21 +23741,6 @@ async function readInfrastructureToolFailure(sessionFile, spec, options = {}) {
|
|
|
24155
23741
|
return void 0;
|
|
24156
23742
|
}
|
|
24157
23743
|
}
|
|
24158
|
-
function extractCollectorInfrastructureFailure(entries) {
|
|
24159
|
-
return extractInfrastructureToolFailure(
|
|
24160
|
-
entries,
|
|
24161
|
-
COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC
|
|
24162
|
-
);
|
|
24163
|
-
}
|
|
24164
|
-
async function readCollectorInfrastructureFailure(sessionFile) {
|
|
24165
|
-
return readInfrastructureToolFailure(
|
|
24166
|
-
sessionFile,
|
|
24167
|
-
COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC,
|
|
24168
|
-
// Multi-attempt resume: only a current-attempt infrastructure failure
|
|
24169
|
-
// may preempt the current failure cause (#633).
|
|
24170
|
-
{ currentAttemptOnly: true }
|
|
24171
|
-
);
|
|
24172
|
-
}
|
|
24173
23744
|
function extractEngineDetourInfrastructureFailure(entries) {
|
|
24174
23745
|
return extractInfrastructureToolFailure(
|
|
24175
23746
|
entries,
|
|
@@ -24211,7 +23782,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
24211
23782
|
const candidateMessage = entries[index]?.message;
|
|
24212
23783
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
24213
23784
|
for (const part of candidateMessage.content) {
|
|
24214
|
-
if (!
|
|
23785
|
+
if (!isRecord8(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
24215
23786
|
continue;
|
|
24216
23787
|
}
|
|
24217
23788
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -24282,7 +23853,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
24282
23853
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
24283
23854
|
prose = details.prose;
|
|
24284
23855
|
} else {
|
|
24285
|
-
const next =
|
|
23856
|
+
const next = isRecord8(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
24286
23857
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
24287
23858
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
24288
23859
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -24391,7 +23962,7 @@ function detourGateContext(admitted, scope) {
|
|
|
24391
23962
|
}
|
|
24392
23963
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
24393
23964
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
24394
|
-
const skipGate =
|
|
23965
|
+
const skipGate = isRecord8(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
24395
23966
|
let next = base;
|
|
24396
23967
|
if (!skipGate) {
|
|
24397
23968
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -24404,7 +23975,7 @@ function routePlaybookFailureMessage(entries) {
|
|
|
24404
23975
|
const entry = entries[i];
|
|
24405
23976
|
if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
|
|
24406
23977
|
const data = entry.data;
|
|
24407
|
-
if (!
|
|
23978
|
+
if (!isRecord8(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
|
|
24408
23979
|
return data.message;
|
|
24409
23980
|
}
|
|
24410
23981
|
return void 0;
|
|
@@ -24451,7 +24022,7 @@ function extractNavigatorAttendanceFact(entries) {
|
|
|
24451
24022
|
const entry = entries[i];
|
|
24452
24023
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
24453
24024
|
const details = entry.message?.details ?? entry.details;
|
|
24454
|
-
if (!
|
|
24025
|
+
if (!isRecord8(details)) {
|
|
24455
24026
|
return {
|
|
24456
24027
|
disposition: "unavailable",
|
|
24457
24028
|
source: "unknown",
|
|
@@ -24602,7 +24173,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
24602
24173
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
24603
24174
|
if (residual === void 0) continue;
|
|
24604
24175
|
const candidate = residual.candidate;
|
|
24605
|
-
const details =
|
|
24176
|
+
const details = isRecord8(candidate) ? candidate : { candidate };
|
|
24606
24177
|
const failed = await settleFailureTerminalResult(
|
|
24607
24178
|
admitted,
|
|
24608
24179
|
{
|
|
@@ -24677,7 +24248,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
24677
24248
|
continue;
|
|
24678
24249
|
}
|
|
24679
24250
|
const data = entry.data;
|
|
24680
|
-
if (!
|
|
24251
|
+
if (!isRecord8(data)) return {};
|
|
24681
24252
|
return {
|
|
24682
24253
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
24683
24254
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -24762,7 +24333,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
24762
24333
|
let residual;
|
|
24763
24334
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
24764
24335
|
const entry = entries[index];
|
|
24765
|
-
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" &&
|
|
24336
|
+
if (entry?.type === "custom" && entry.customType === "ak-role-submission-closure" && isRecord8(entry.data) && entry.data.toolName === spec.toolName && classifyPackagedRoleTerminalResult(entry.data).kind === "accepted") {
|
|
24766
24337
|
thisAttemptHasSeatSuccess = true;
|
|
24767
24338
|
}
|
|
24768
24339
|
const message = entries[index]?.message;
|
|
@@ -24802,7 +24373,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
24802
24373
|
);
|
|
24803
24374
|
}
|
|
24804
24375
|
if (residual !== void 0) {
|
|
24805
|
-
const details =
|
|
24376
|
+
const details = isRecord8(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
24806
24377
|
const failed = await settleFailureTerminalResult(
|
|
24807
24378
|
admitted,
|
|
24808
24379
|
{
|
|
@@ -24852,7 +24423,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
24852
24423
|
return void 0;
|
|
24853
24424
|
}
|
|
24854
24425
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
24855
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
24426
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord8(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
24856
24427
|
return {
|
|
24857
24428
|
...roleOutcome,
|
|
24858
24429
|
decisiveFacts: {
|
|
@@ -24865,7 +24436,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
24865
24436
|
const payloads = roleOutcome.payloads ?? [];
|
|
24866
24437
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
24867
24438
|
const payload = payloads[index];
|
|
24868
|
-
if (!
|
|
24439
|
+
if (!isRecord8(payload)) continue;
|
|
24869
24440
|
const status = payload.secretariatStatus;
|
|
24870
24441
|
if (typeof status !== "string") continue;
|
|
24871
24442
|
return status === "converged";
|
|
@@ -25093,17 +24664,6 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
25093
24664
|
}
|
|
25094
24665
|
if (facts !== void 0 && facts.runPointer === admitted.runDirectory && facts.attemptPointer === `current:${admitted.runDirectory}`) {
|
|
25095
24666
|
let decisiveFacts2 = facts;
|
|
25096
|
-
if (packagedProjectsTargetBindRejection(admitted.role)) {
|
|
25097
|
-
const bindRejection = extractCollectorTargetBindRejection(entries.slice(attemptStart));
|
|
25098
|
-
if (bindRejection !== void 0) {
|
|
25099
|
-
decisiveFacts2 = {
|
|
25100
|
-
...facts,
|
|
25101
|
-
targetBindRejected: true,
|
|
25102
|
-
targetBindDiagnostic: bindRejection.diagnostic,
|
|
25103
|
-
...bindRejection.code === void 0 ? {} : { targetBindCode: bindRejection.code }
|
|
25104
|
-
};
|
|
25105
|
-
}
|
|
25106
|
-
}
|
|
25107
24667
|
await clearOppositeTerminalArtifactFace(admitted.runDirectory);
|
|
25108
24668
|
return withOptionalGateProjection(
|
|
25109
24669
|
{
|
|
@@ -25238,7 +24798,7 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
25238
24798
|
});
|
|
25239
24799
|
});
|
|
25240
24800
|
}
|
|
25241
|
-
var privateFailureErrorPaths, NAVIGATOR_POST_ROLE_GRACE_MS,
|
|
24801
|
+
var privateFailureErrorPaths, NAVIGATOR_POST_ROLE_GRACE_MS, ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC, RUNNER_FAILURE_POLICY, ATTEMPT_HISTORY_ENTRY_TYPE, EMPTY_ARTIFACT_FACE;
|
|
25242
24802
|
var init_settlement = __esm({
|
|
25243
24803
|
"src/public-cli/settlement.ts"() {
|
|
25244
24804
|
"use strict";
|
|
@@ -25251,11 +24811,9 @@ var init_settlement = __esm({
|
|
|
25251
24811
|
init_serialize_thrown_value();
|
|
25252
24812
|
init_run_lifecycle();
|
|
25253
24813
|
init_compliance_transport();
|
|
25254
|
-
init_collector_ledger();
|
|
25255
24814
|
init_engine_detour();
|
|
25256
24815
|
init_engine_detour_usage();
|
|
25257
24816
|
init_judge_output();
|
|
25258
|
-
init_collector_output();
|
|
25259
24817
|
init_worker_output();
|
|
25260
24818
|
init_doctor_contracts();
|
|
25261
24819
|
init_dossier_resolution();
|
|
@@ -25271,20 +24829,6 @@ var init_settlement = __esm({
|
|
|
25271
24829
|
init_terminal();
|
|
25272
24830
|
privateFailureErrorPaths = /* @__PURE__ */ new WeakMap();
|
|
25273
24831
|
NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
|
|
25274
|
-
COLLECTOR_INFRASTRUCTURE_TOOLS = /* @__PURE__ */ new Set([
|
|
25275
|
-
COLLECTOR_OBSERVE_TOOL,
|
|
25276
|
-
COLLECTOR_READ_TOOL,
|
|
25277
|
-
COLLECTOR_REQUEST_TOOL,
|
|
25278
|
-
COLLECTOR_WAIT_TOOL
|
|
25279
|
-
]);
|
|
25280
|
-
COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC = {
|
|
25281
|
-
matchTool: (toolName) => COLLECTOR_INFRASTRUCTURE_TOOLS.has(toolName),
|
|
25282
|
-
cause: "activation",
|
|
25283
|
-
identityName: "CollectorInfrastructureError",
|
|
25284
|
-
// read alone has a correctable rejection mode (unknown/non-openable pointers);
|
|
25285
|
-
// only its typed infrastructure-failure fact counts as a real host failure.
|
|
25286
|
-
requireInfrastructureFact: (toolName) => toolName === COLLECTOR_READ_TOOL
|
|
25287
|
-
};
|
|
25288
24832
|
ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC = {
|
|
25289
24833
|
matchTool: (toolName) => toolName === ENGINE_DETOUR_TOOL_NAME,
|
|
25290
24834
|
cause: "output",
|
|
@@ -25298,10 +24842,6 @@ var init_settlement = __esm({
|
|
|
25298
24842
|
"engine-detour-record-first": {
|
|
25299
24843
|
read: readEngineDetourInfrastructureFailure,
|
|
25300
24844
|
rank: "record-first"
|
|
25301
|
-
},
|
|
25302
|
-
"collector-known-first": {
|
|
25303
|
-
read: readCollectorInfrastructureFailure,
|
|
25304
|
-
rank: "known-first"
|
|
25305
24845
|
}
|
|
25306
24846
|
};
|
|
25307
24847
|
ATTEMPT_HISTORY_ENTRY_TYPE = "ak_run_attempt_history";
|
|
@@ -25665,11 +25205,11 @@ var init_turn_request = __esm({
|
|
|
25665
25205
|
});
|
|
25666
25206
|
|
|
25667
25207
|
// src/public-cli/countersign-run.ts
|
|
25668
|
-
function
|
|
25208
|
+
function isRecord9(value) {
|
|
25669
25209
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25670
25210
|
}
|
|
25671
25211
|
function isEscalatePayload(payload) {
|
|
25672
|
-
if (!
|
|
25212
|
+
if (!isRecord9(payload)) return false;
|
|
25673
25213
|
return payload.status === "escalate";
|
|
25674
25214
|
}
|
|
25675
25215
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -28927,64 +28467,6 @@ var init_session_identity = __esm({
|
|
|
28927
28467
|
}
|
|
28928
28468
|
});
|
|
28929
28469
|
|
|
28930
|
-
// src/public-cli/case-dossier-delivery.ts
|
|
28931
|
-
import { mkdtemp as mkdtemp2, readFile as readFile18, rm as rm3, writeFile as writeFile7 } from "node:fs/promises";
|
|
28932
|
-
import { tmpdir as tmpdir2 } from "node:os";
|
|
28933
|
-
import { join as join32 } from "node:path";
|
|
28934
|
-
async function projectCaseDossierPointerSection(input) {
|
|
28935
|
-
if (input.ticketNumber === void 0) {
|
|
28936
|
-
return [
|
|
28937
|
-
UNBOUND_DOSSIER_PATH_HEADING,
|
|
28938
|
-
"",
|
|
28939
|
-
`\u8BB0\u5F55\u5377\u5B97\uFF1A${projectTicketRecordsPathShape()}`
|
|
28940
|
-
].join("\n");
|
|
28941
|
-
}
|
|
28942
|
-
const volume = resolveTicketProvenanceVolume(
|
|
28943
|
-
input.ticketNumber,
|
|
28944
|
-
input.projectRoot,
|
|
28945
|
-
input.home
|
|
28946
|
-
);
|
|
28947
|
-
return [
|
|
28948
|
-
CASE_DOSSIER_SECTION_HEADING,
|
|
28949
|
-
"",
|
|
28950
|
-
`\u7968\u53F7\uFF1A#${input.ticketNumber}`,
|
|
28951
|
-
`\u8BB0\u5F55\u5377\u5B97\uFF1A${volume.recordFile}`
|
|
28952
|
-
].join("\n");
|
|
28953
|
-
}
|
|
28954
|
-
async function deliverCaseDossierAsAttachment(input) {
|
|
28955
|
-
const section = await projectCaseDossierPointerSection({
|
|
28956
|
-
ticketNumber: input.ticketNumber,
|
|
28957
|
-
projectRoot: input.projectRoot,
|
|
28958
|
-
home: input.home
|
|
28959
|
-
});
|
|
28960
|
-
const stagingDir = await mkdtemp2(join32(tmpdir2(), "ak-case-dossier-"));
|
|
28961
|
-
try {
|
|
28962
|
-
const stagingPath = join32(stagingDir, CASE_DOSSIER_ATTACH_FILE);
|
|
28963
|
-
await writeFile7(stagingPath, `${section}
|
|
28964
|
-
`, "utf8");
|
|
28965
|
-
return await freezeAttachmentsIntoRun(
|
|
28966
|
-
[stagingPath],
|
|
28967
|
-
input.runDirectory,
|
|
28968
|
-
CASE_DOSSIER_ATTACH_KEY
|
|
28969
|
-
);
|
|
28970
|
-
} finally {
|
|
28971
|
-
await rm3(stagingDir, { recursive: true, force: true });
|
|
28972
|
-
}
|
|
28973
|
-
}
|
|
28974
|
-
var CASE_DOSSIER_SECTION_HEADING, UNBOUND_DOSSIER_PATH_HEADING, CASE_DOSSIER_ATTACH_KEY, CASE_DOSSIER_ATTACH_FILE;
|
|
28975
|
-
var init_case_dossier_delivery = __esm({
|
|
28976
|
-
"src/public-cli/case-dossier-delivery.ts"() {
|
|
28977
|
-
"use strict";
|
|
28978
|
-
init_sitian_facade();
|
|
28979
|
-
init_ticket_provenance();
|
|
28980
|
-
init_invocation();
|
|
28981
|
-
CASE_DOSSIER_SECTION_HEADING = "## \u672C\u7968\u8D77\u5C45\u5F55\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
28982
|
-
UNBOUND_DOSSIER_PATH_HEADING = "## \u8D77\u5C45\u5F55\u8DEF\u5F84\uFF08\u7CFB\u7EDF\u968F\u6848\u63D0\u4F9B\uFF09";
|
|
28983
|
-
CASE_DOSSIER_ATTACH_KEY = "case-dossier";
|
|
28984
|
-
CASE_DOSSIER_ATTACH_FILE = "case-dossier-pointer.md";
|
|
28985
|
-
}
|
|
28986
|
-
});
|
|
28987
|
-
|
|
28988
28470
|
// src/public-cli/process-cancel.ts
|
|
28989
28471
|
var process_cancel_exports = {};
|
|
28990
28472
|
__export(process_cancel_exports, {
|
|
@@ -29051,7 +28533,7 @@ import {
|
|
|
29051
28533
|
rmSync as rmSync2,
|
|
29052
28534
|
statSync as statSync4
|
|
29053
28535
|
} from "node:fs";
|
|
29054
|
-
import { dirname as dirname19, join as
|
|
28536
|
+
import { dirname as dirname19, join as join32 } from "node:path";
|
|
29055
28537
|
function declareHostSessionFailure(error) {
|
|
29056
28538
|
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
29057
28539
|
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
@@ -29059,7 +28541,7 @@ function declareHostSessionFailure(error) {
|
|
|
29059
28541
|
}
|
|
29060
28542
|
function recordRunStart(runDirectory) {
|
|
29061
28543
|
try {
|
|
29062
|
-
appendFileSync2(
|
|
28544
|
+
appendFileSync2(join32(runDirectory, ".run-starts"), "\n");
|
|
29063
28545
|
} catch (error) {
|
|
29064
28546
|
declareHostSessionFailure(error);
|
|
29065
28547
|
}
|
|
@@ -29075,7 +28557,7 @@ var init_host_session_record = __esm({
|
|
|
29075
28557
|
import { constants as fsConstants2 } from "node:fs";
|
|
29076
28558
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
29077
28559
|
import { lstat as lstat7, mkdir as mkdir4, open as open2 } from "node:fs/promises";
|
|
29078
|
-
import { join as
|
|
28560
|
+
import { join as join33 } from "node:path";
|
|
29079
28561
|
async function persistReturnedRunState(admitted, authority, options) {
|
|
29080
28562
|
if (options?.lawful === true) {
|
|
29081
28563
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -29146,7 +28628,7 @@ function jsonSafeReplacer() {
|
|
|
29146
28628
|
};
|
|
29147
28629
|
}
|
|
29148
28630
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
29149
|
-
const filePath =
|
|
28631
|
+
const filePath = join33(artifactsDir, `${namePrefix}-${randomUUID5()}.json`);
|
|
29150
28632
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
29151
28633
|
`;
|
|
29152
28634
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -29434,8 +28916,8 @@ var init_auto_resume = __esm({
|
|
|
29434
28916
|
|
|
29435
28917
|
// src/public-cli/post-admission.ts
|
|
29436
28918
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
29437
|
-
import { writeFile as
|
|
29438
|
-
import { isAbsolute as isAbsolute8, join as
|
|
28919
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
28920
|
+
import { isAbsolute as isAbsolute8, join as join34, resolve as resolve12 } from "node:path";
|
|
29439
28921
|
function describeCaughtError(error) {
|
|
29440
28922
|
if (error instanceof Error) {
|
|
29441
28923
|
const code = error.code;
|
|
@@ -29530,8 +29012,8 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
29530
29012
|
} catch (appendError) {
|
|
29531
29013
|
try {
|
|
29532
29014
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
29533
|
-
await
|
|
29534
|
-
|
|
29015
|
+
await writeFile7(
|
|
29016
|
+
join34(artifactsDir, `post-admission-diagnostic-${randomUUID6()}.json`),
|
|
29535
29017
|
`${JSON.stringify({ version: 1, ...payload }, null, 2)}
|
|
29536
29018
|
`,
|
|
29537
29019
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -29677,7 +29159,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29677
29159
|
const rows = await readRecordedSubmissionRows(
|
|
29678
29160
|
admitted.projectRoot,
|
|
29679
29161
|
admitted.runId,
|
|
29680
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
29162
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join34(admitted.runDirectory, "session", "session.jsonl") }
|
|
29681
29163
|
);
|
|
29682
29164
|
let ticketNumber;
|
|
29683
29165
|
for (const row of rows) {
|
|
@@ -29771,12 +29253,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29771
29253
|
if (typeof env.host === "string" && env.host.trim() !== "") {
|
|
29772
29254
|
turnRequest = { ...turnRequest, host: env.host.trim() };
|
|
29773
29255
|
}
|
|
29774
|
-
await deliverCaseDossierAsAttachment({
|
|
29775
|
-
ticketNumber: admitted.ticketNumber,
|
|
29776
|
-
projectRoot: admitted.projectRoot,
|
|
29777
|
-
home: env.home,
|
|
29778
|
-
runDirectory: admitted.runDirectory
|
|
29779
|
-
});
|
|
29780
29256
|
await markRunRunning(
|
|
29781
29257
|
admitted.runDirectory,
|
|
29782
29258
|
env.model,
|
|
@@ -29812,8 +29288,8 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
29812
29288
|
}
|
|
29813
29289
|
let stderrLogWriteFailure;
|
|
29814
29290
|
try {
|
|
29815
|
-
await
|
|
29816
|
-
|
|
29291
|
+
await writeFile7(
|
|
29292
|
+
join34(admitted.runDirectory, "stderr.log"),
|
|
29817
29293
|
result.stderr,
|
|
29818
29294
|
"utf8"
|
|
29819
29295
|
);
|
|
@@ -30092,7 +29568,7 @@ async function dispatchAfterWriterLease(input) {
|
|
|
30092
29568
|
}
|
|
30093
29569
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
30094
29570
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
30095
|
-
return pathContainedIn(
|
|
29571
|
+
return pathContainedIn(join34(runDirectory, "attachments"), absolute);
|
|
30096
29572
|
}
|
|
30097
29573
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
30098
29574
|
if (summons === void 0) return void 0;
|
|
@@ -30351,8 +29827,8 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
30351
29827
|
}
|
|
30352
29828
|
async function writeResumeDiagnosticFile(runDirectory, runId, failure, role) {
|
|
30353
29829
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
30354
|
-
const path =
|
|
30355
|
-
await
|
|
29830
|
+
const path = join34(dir, `resume-diagnostic-${randomUUID6()}.json`);
|
|
29831
|
+
await writeFile7(
|
|
30356
29832
|
path,
|
|
30357
29833
|
`${JSON.stringify({
|
|
30358
29834
|
runId,
|
|
@@ -30484,7 +29960,6 @@ var init_post_admission = __esm({
|
|
|
30484
29960
|
init_session_identity();
|
|
30485
29961
|
init_role_run_relocation();
|
|
30486
29962
|
init_packaged_role_registry();
|
|
30487
|
-
init_case_dossier_delivery();
|
|
30488
29963
|
init_engine_detour_usage();
|
|
30489
29964
|
init_run_lifecycle();
|
|
30490
29965
|
init_process_cancel();
|
|
@@ -30536,16 +30011,16 @@ var init_analyst_book_key = __esm({
|
|
|
30536
30011
|
|
|
30537
30012
|
// src/atomic-write.ts
|
|
30538
30013
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
30539
|
-
import { rename as rename3, rm as
|
|
30540
|
-
import { dirname as dirname20, join as
|
|
30014
|
+
import { rename as rename3, rm as rm3, writeFile as writeFile8 } from "node:fs/promises";
|
|
30015
|
+
import { dirname as dirname20, join as join35 } from "node:path";
|
|
30541
30016
|
async function writeFileAtomically(destination, contents) {
|
|
30542
30017
|
const parent = dirname20(destination);
|
|
30543
|
-
const temporary =
|
|
30018
|
+
const temporary = join35(parent, `.atomic-write-${randomUUID7()}.tmp`);
|
|
30544
30019
|
try {
|
|
30545
|
-
await
|
|
30020
|
+
await writeFile8(temporary, contents);
|
|
30546
30021
|
await rename3(temporary, destination);
|
|
30547
30022
|
} catch (error) {
|
|
30548
|
-
await
|
|
30023
|
+
await rm3(temporary, { force: true }).catch(() => void 0);
|
|
30549
30024
|
throw error;
|
|
30550
30025
|
}
|
|
30551
30026
|
}
|
|
@@ -30556,8 +30031,8 @@ var init_atomic_write = __esm({
|
|
|
30556
30031
|
});
|
|
30557
30032
|
|
|
30558
30033
|
// src/analyst-index.ts
|
|
30559
|
-
import { open as open3, readFile as
|
|
30560
|
-
import { dirname as dirname21, join as
|
|
30034
|
+
import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
|
|
30035
|
+
import { dirname as dirname21, join as join36 } from "node:path";
|
|
30561
30036
|
function sleep(ms) {
|
|
30562
30037
|
return new Promise((resolve14) => {
|
|
30563
30038
|
setTimeout(resolve14, ms);
|
|
@@ -30566,7 +30041,7 @@ function sleep(ms) {
|
|
|
30566
30041
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
30567
30042
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
30568
30043
|
ensureRealDirectoryTree(ledgerHome, dirname21(indexPath));
|
|
30569
|
-
const lockPath =
|
|
30044
|
+
const lockPath = join36(dirname21(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
30570
30045
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
30571
30046
|
const startedAt = Date.now();
|
|
30572
30047
|
while (true) {
|
|
@@ -30593,7 +30068,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
30593
30068
|
}
|
|
30594
30069
|
}
|
|
30595
30070
|
function analystLibraryIndexPath(ledgerHome) {
|
|
30596
|
-
return
|
|
30071
|
+
return join36(ledgerHome, "analyst", "library-index.json");
|
|
30597
30072
|
}
|
|
30598
30073
|
function rowFromIssueMetricsPage(page) {
|
|
30599
30074
|
return {
|
|
@@ -30684,7 +30159,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
30684
30159
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
30685
30160
|
let raw;
|
|
30686
30161
|
try {
|
|
30687
|
-
raw = await
|
|
30162
|
+
raw = await readFile18(path, "utf8");
|
|
30688
30163
|
} catch (error) {
|
|
30689
30164
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
30690
30165
|
return void 0;
|
|
@@ -30888,15 +30363,15 @@ var init_analyst_cohort = __esm({
|
|
|
30888
30363
|
});
|
|
30889
30364
|
|
|
30890
30365
|
// src/analyst-ledger.ts
|
|
30891
|
-
import { readdir as readdir7, readFile as
|
|
30892
|
-
import { basename as basename9, join as
|
|
30366
|
+
import { readdir as readdir7, readFile as readFile19 } from "node:fs/promises";
|
|
30367
|
+
import { basename as basename9, join as join37 } from "node:path";
|
|
30893
30368
|
function isMissingPathError6(error) {
|
|
30894
30369
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
30895
30370
|
}
|
|
30896
30371
|
function errorText3(error) {
|
|
30897
30372
|
return error instanceof Error ? error.message : String(error);
|
|
30898
30373
|
}
|
|
30899
|
-
function
|
|
30374
|
+
function isRecord10(value) {
|
|
30900
30375
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30901
30376
|
}
|
|
30902
30377
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -30918,7 +30393,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
30918
30393
|
}
|
|
30919
30394
|
}
|
|
30920
30395
|
async function classifyGhostCandidate(input) {
|
|
30921
|
-
const autopsy = await autopsyWriterLock(
|
|
30396
|
+
const autopsy = await autopsyWriterLock(join37(input.runDirectory, "writer.lock"));
|
|
30922
30397
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
30923
30398
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
30924
30399
|
return {
|
|
@@ -30947,13 +30422,13 @@ async function listLedgerBookNames(booksRoot) {
|
|
|
30947
30422
|
async function readInvocationScopeFields(runDirectory) {
|
|
30948
30423
|
let raw;
|
|
30949
30424
|
try {
|
|
30950
|
-
raw = await
|
|
30425
|
+
raw = await readFile19(join37(runDirectory, "invocation.json"), "utf8");
|
|
30951
30426
|
} catch (error) {
|
|
30952
30427
|
if (isMissingPathError6(error)) return void 0;
|
|
30953
30428
|
throw error;
|
|
30954
30429
|
}
|
|
30955
30430
|
const parsed = JSON.parse(raw);
|
|
30956
|
-
if (!
|
|
30431
|
+
if (!isRecord10(parsed)) return void 0;
|
|
30957
30432
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
30958
30433
|
return void 0;
|
|
30959
30434
|
}
|
|
@@ -30980,15 +30455,15 @@ function decideIssueScope(input) {
|
|
|
30980
30455
|
}
|
|
30981
30456
|
async function resolveSessionFile(runDirectory) {
|
|
30982
30457
|
try {
|
|
30983
|
-
const raw = await
|
|
30458
|
+
const raw = await readFile19(join37(runDirectory, "invocation.json"), "utf8");
|
|
30984
30459
|
const parsed = JSON.parse(raw);
|
|
30985
|
-
if (
|
|
30460
|
+
if (isRecord10(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
30986
30461
|
return parsed.sessionFile;
|
|
30987
30462
|
}
|
|
30988
30463
|
} catch (error) {
|
|
30989
30464
|
if (!isMissingPathError6(error)) throw error;
|
|
30990
30465
|
}
|
|
30991
|
-
return
|
|
30466
|
+
return join37(runDirectory, "session", "session.jsonl");
|
|
30992
30467
|
}
|
|
30993
30468
|
function attributeSessionRowsForRun(input) {
|
|
30994
30469
|
if (pathContainedIn(input.runDirectory, input.sessionFile)) {
|
|
@@ -31180,9 +30655,9 @@ async function classifyScopedRun(input) {
|
|
|
31180
30655
|
}
|
|
31181
30656
|
let gateCycles;
|
|
31182
30657
|
try {
|
|
31183
|
-
const parentSessionFile =
|
|
30658
|
+
const parentSessionFile = join37(input.runDirectory, "session", "session.jsonl");
|
|
31184
30659
|
gateCycles = await readAnalystGateCyclesFromAuditorRoles(
|
|
31185
|
-
|
|
30660
|
+
join37(input.runDirectory, "session", "auditor-roles"),
|
|
31186
30661
|
{ parentSessionFile }
|
|
31187
30662
|
);
|
|
31188
30663
|
} catch (error) {
|
|
@@ -31217,7 +30692,7 @@ async function classifyScopedRun(input) {
|
|
|
31217
30692
|
async function scanAnalystIssueRuns(input) {
|
|
31218
30693
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
31219
30694
|
const scopeTicketNumber = input.ticketNumber;
|
|
31220
|
-
const booksRoot =
|
|
30695
|
+
const booksRoot = join37(ledgerHome, "books");
|
|
31221
30696
|
let wholeBook = false;
|
|
31222
30697
|
let scopeRootIdentity;
|
|
31223
30698
|
let bookNames;
|
|
@@ -31250,7 +30725,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
31250
30725
|
const ghostLegs = [];
|
|
31251
30726
|
const scopeConflicts = [];
|
|
31252
30727
|
for (const book of bookNames) {
|
|
31253
|
-
const bookDir =
|
|
30728
|
+
const bookDir = join37(booksRoot, book);
|
|
31254
30729
|
let runDirectories;
|
|
31255
30730
|
try {
|
|
31256
30731
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -31320,7 +30795,7 @@ var init_analyst_ledger = __esm({
|
|
|
31320
30795
|
});
|
|
31321
30796
|
|
|
31322
30797
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
31323
|
-
function
|
|
30798
|
+
function isRecord11(value) {
|
|
31324
30799
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31325
30800
|
}
|
|
31326
30801
|
function wallMsFromSpan(span) {
|
|
@@ -31329,21 +30804,21 @@ function wallMsFromSpan(span) {
|
|
|
31329
30804
|
function findCollectorGroups(body) {
|
|
31330
30805
|
if (Array.isArray(body.groups)) return body.groups;
|
|
31331
30806
|
const receipt = body.receipt;
|
|
31332
|
-
if (
|
|
30807
|
+
if (isRecord11(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
31333
30808
|
const outcome = body.outcome;
|
|
31334
|
-
if (
|
|
30809
|
+
if (isRecord11(outcome)) {
|
|
31335
30810
|
const facts = outcome.decisiveFacts;
|
|
31336
|
-
if (
|
|
30811
|
+
if (isRecord11(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
31337
30812
|
}
|
|
31338
30813
|
return void 0;
|
|
31339
30814
|
}
|
|
31340
30815
|
function extractStatus(body) {
|
|
31341
30816
|
const outcome = body.outcome;
|
|
31342
|
-
if (
|
|
30817
|
+
if (isRecord11(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
31343
30818
|
return outcome.status;
|
|
31344
30819
|
}
|
|
31345
30820
|
const receipt = body.receipt;
|
|
31346
|
-
if (
|
|
30821
|
+
if (isRecord11(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
31347
30822
|
return receipt.status;
|
|
31348
30823
|
}
|
|
31349
30824
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -31969,15 +31444,15 @@ var init_leg_wall_clock = __esm({
|
|
|
31969
31444
|
});
|
|
31970
31445
|
|
|
31971
31446
|
// src/analyst-metric-families/round-timeline.ts
|
|
31972
|
-
function
|
|
31447
|
+
function isRecord12(value) {
|
|
31973
31448
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31974
31449
|
}
|
|
31975
31450
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
31976
31451
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
31977
31452
|
}
|
|
31978
31453
|
function readClassCount(body) {
|
|
31979
|
-
if (!
|
|
31980
|
-
if (!
|
|
31454
|
+
if (!isRecord12(body.outcome)) return void 0;
|
|
31455
|
+
if (!isRecord12(body.outcome.decisiveFacts)) return void 0;
|
|
31981
31456
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
31982
31457
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
31983
31458
|
return void 0;
|
|
@@ -32122,7 +31597,7 @@ var init_analyst_metric_family = __esm({
|
|
|
32122
31597
|
|
|
32123
31598
|
// src/analyst-page.ts
|
|
32124
31599
|
import { createHash as createHash3 } from "node:crypto";
|
|
32125
|
-
import { dirname as dirname22, join as
|
|
31600
|
+
import { dirname as dirname22, join as join38 } from "node:path";
|
|
32126
31601
|
function analystIssuePageKey(address) {
|
|
32127
31602
|
const parts = ["book", address.bookKey];
|
|
32128
31603
|
if (address.issueNumber !== void 0) {
|
|
@@ -32133,7 +31608,7 @@ function analystIssuePageKey(address) {
|
|
|
32133
31608
|
return createHash3("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
32134
31609
|
}
|
|
32135
31610
|
function analystIssuePagePath(ledgerHome, address) {
|
|
32136
|
-
return
|
|
31611
|
+
return join38(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
32137
31612
|
}
|
|
32138
31613
|
function analystIssuePageAddressFromPage(page) {
|
|
32139
31614
|
return {
|
|
@@ -32269,7 +31744,7 @@ var init_analyst_page = __esm({
|
|
|
32269
31744
|
});
|
|
32270
31745
|
|
|
32271
31746
|
// src/analyst-entry.ts
|
|
32272
|
-
import { readFile as
|
|
31747
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
32273
31748
|
function isMissingPathError7(error) {
|
|
32274
31749
|
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
32275
31750
|
}
|
|
@@ -32299,7 +31774,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
32299
31774
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
32300
31775
|
});
|
|
32301
31776
|
try {
|
|
32302
|
-
const raw = await
|
|
31777
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
32303
31778
|
const page = JSON.parse(raw);
|
|
32304
31779
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
32305
31780
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -32400,7 +31875,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
32400
31875
|
scopeRootIdentity: projectRoot
|
|
32401
31876
|
});
|
|
32402
31877
|
try {
|
|
32403
|
-
const raw = await
|
|
31878
|
+
const raw = await readFile20(pagePath, "utf8");
|
|
32404
31879
|
JSON.parse(raw);
|
|
32405
31880
|
} catch (error) {
|
|
32406
31881
|
if (!isMissingPathError7(error)) {
|
|
@@ -32499,7 +31974,7 @@ var init_analyst_entry = __esm({
|
|
|
32499
31974
|
});
|
|
32500
31975
|
|
|
32501
31976
|
// src/public-cli/analyst-run.ts
|
|
32502
|
-
import { readFile as
|
|
31977
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
32503
31978
|
import { isAbsolute as isAbsolute10, resolve as resolve13 } from "node:path";
|
|
32504
31979
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
32505
31980
|
try {
|
|
@@ -32552,7 +32027,7 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
32552
32027
|
const absolute = isAbsolute10(sourcePath) ? sourcePath : resolve13(sourcePath);
|
|
32553
32028
|
let bytes;
|
|
32554
32029
|
try {
|
|
32555
|
-
bytes = await
|
|
32030
|
+
bytes = await readFile21(absolute);
|
|
32556
32031
|
} catch (error) {
|
|
32557
32032
|
throw new CliUsageError(
|
|
32558
32033
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -32673,7 +32148,7 @@ __export(cli_exports, {
|
|
|
32673
32148
|
runAkRole: () => runAkRole
|
|
32674
32149
|
});
|
|
32675
32150
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
32676
|
-
import { join as
|
|
32151
|
+
import { join as join39 } from "node:path";
|
|
32677
32152
|
function publicSeatArgv(owner) {
|
|
32678
32153
|
return {
|
|
32679
32154
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -32812,7 +32287,7 @@ function resolveHome(env) {
|
|
|
32812
32287
|
return env.home ?? packageMachineHome();
|
|
32813
32288
|
}
|
|
32814
32289
|
function resolveAgentDir(env, home) {
|
|
32815
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ??
|
|
32290
|
+
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join39(home, ".pi", "agent");
|
|
32816
32291
|
}
|
|
32817
32292
|
function parseThinking(value) {
|
|
32818
32293
|
return value;
|
|
@@ -33574,7 +33049,7 @@ var init_cli = __esm({
|
|
|
33574
33049
|
|
|
33575
33050
|
// src/public-cli/main.ts
|
|
33576
33051
|
import { existsSync as existsSync11 } from "node:fs";
|
|
33577
|
-
import { dirname as dirname23, join as
|
|
33052
|
+
import { dirname as dirname23, join as join40 } from "node:path";
|
|
33578
33053
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33579
33054
|
|
|
33580
33055
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -33663,8 +33138,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
33663
33138
|
// src/public-cli/main.ts
|
|
33664
33139
|
var here = dirname23(fileURLToPath2(import.meta.url));
|
|
33665
33140
|
function resolvePackageRoot(binDir) {
|
|
33666
|
-
const canonical =
|
|
33667
|
-
if (existsSync11(
|
|
33141
|
+
const canonical = join40(binDir, "..", "..");
|
|
33142
|
+
if (existsSync11(join40(canonical, "package.json"))) {
|
|
33668
33143
|
return canonical;
|
|
33669
33144
|
}
|
|
33670
33145
|
return binDir;
|