@akagilnc/pi-workflow-roles 0.1.5241 → 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/README.md +2 -3
- package/README.zh-CN.md +2 -3
- package/dist/acp-host/production-host.js +442 -3070
- package/dist/collector-config.js +0 -1
- package/dist/headless-host/production-host.js +443 -3071
- 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 +252 -698
- package/dist/public-cli/option-definitions.js +4 -19
- package/dist/public-cli/settlement.js +2 -79
- 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/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/invocation.ts +3 -27
- package/src/public-cli/option-definitions.ts +4 -19
- package/src/public-cli/settlement.ts +3 -102
- package/src/role-runtime-dependencies.ts +0 -4
- package/src/role-runtime.ts +16 -98
- 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/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/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})`
|
|
@@ -17996,7 +17778,7 @@ var init_sitian_appender = __esm({
|
|
|
17996
17778
|
// src/sitian-reader.ts
|
|
17997
17779
|
import { existsSync as existsSync3 } from "node:fs";
|
|
17998
17780
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
17999
|
-
function
|
|
17781
|
+
function isRecord2(value) {
|
|
18000
17782
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18001
17783
|
}
|
|
18002
17784
|
async function readSitianRecords(recordFile) {
|
|
@@ -18012,7 +17794,7 @@ async function readSitianRecords(recordFile) {
|
|
|
18012
17794
|
if (!line2.trim()) continue;
|
|
18013
17795
|
try {
|
|
18014
17796
|
const parsed = JSON.parse(line2);
|
|
18015
|
-
if (
|
|
17797
|
+
if (isRecord2(parsed)) {
|
|
18016
17798
|
records.push(parsed);
|
|
18017
17799
|
} else {
|
|
18018
17800
|
const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
|
|
@@ -18065,7 +17847,7 @@ __export(role_turn_host_exports, {
|
|
|
18065
17847
|
createPiRoleTurnHost: () => createPiRoleTurnHost,
|
|
18066
17848
|
resolveInternalRoleEntrypoint: () => resolveInternalRoleEntrypoint
|
|
18067
17849
|
});
|
|
18068
|
-
import { execFile, spawn
|
|
17850
|
+
import { execFile, spawn } from "node:child_process";
|
|
18069
17851
|
import { constants as constants2 } from "node:fs";
|
|
18070
17852
|
import { access, appendFile, readFile as readFile7, realpath } from "node:fs/promises";
|
|
18071
17853
|
import { delimiter as delimiter2, dirname as dirname8, isAbsolute as isAbsolute3, join as join15, resolve as resolve4 } from "node:path";
|
|
@@ -18175,7 +17957,7 @@ function createDefaultPiSpawnRunner(options) {
|
|
|
18175
17957
|
const command = spawnOptions.env.PI_BINARY ?? "pi";
|
|
18176
17958
|
const piIdentity = await selectedPiIdentity(command, spawnOptions.cwd, spawnOptions.env);
|
|
18177
17959
|
return await new Promise((resolveResult, reject) => {
|
|
18178
|
-
const child =
|
|
17960
|
+
const child = spawn(piIdentity.executable, [...args], {
|
|
18179
17961
|
cwd: spawnOptions.cwd,
|
|
18180
17962
|
env: spawnOptions.env,
|
|
18181
17963
|
stdio: ["pipe", "ignore", "pipe"]
|
|
@@ -18380,6 +18162,19 @@ var init_sha256 = __esm({
|
|
|
18380
18162
|
}
|
|
18381
18163
|
});
|
|
18382
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
|
+
|
|
18383
18178
|
// src/package-contracts/terminating-tools.ts
|
|
18384
18179
|
function isTerminatingToolName(name) {
|
|
18385
18180
|
return TERMINATING_TOOL_NAMES.includes(name);
|
|
@@ -18585,11 +18380,6 @@ var init_doctor_evidence = __esm({
|
|
|
18585
18380
|
});
|
|
18586
18381
|
|
|
18587
18382
|
// src/public-cli/github-remote.ts
|
|
18588
|
-
function ownerFromGitHubRemoteUrl(remoteUrl) {
|
|
18589
|
-
const ownerRepo = ownerRepoFromGitHubRemoteUrl(remoteUrl);
|
|
18590
|
-
if (ownerRepo === void 0) return void 0;
|
|
18591
|
-
return ownerRepo.split("/")[0].toLowerCase();
|
|
18592
|
-
}
|
|
18593
18383
|
function ownerRepoFromGitHubRemoteUrl(remoteUrl) {
|
|
18594
18384
|
const trimmed = remoteUrl.trim();
|
|
18595
18385
|
const scp = /^git@github\.com:([^/\s]+)\/([^/\s]+?)(?:\.git)?$/i.exec(trimmed);
|
|
@@ -18623,143 +18413,6 @@ var init_github_remote = __esm({
|
|
|
18623
18413
|
}
|
|
18624
18414
|
});
|
|
18625
18415
|
|
|
18626
|
-
// src/collector-target.ts
|
|
18627
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
18628
|
-
function ambiguousTarget(detail, cause) {
|
|
18629
|
-
throw new CliUsageError(
|
|
18630
|
-
`collector target is ambiguous: ${detail}; pass an explicit --pr`,
|
|
18631
|
-
cause === void 0 ? void 0 : { cause }
|
|
18632
|
-
);
|
|
18633
|
-
}
|
|
18634
|
-
function gitFailure(detail, cause) {
|
|
18635
|
-
throw new Error(`collector git failed: ${detail}`, {
|
|
18636
|
-
cause: cause instanceof Error ? cause : new Error(String(cause))
|
|
18637
|
-
});
|
|
18638
|
-
}
|
|
18639
|
-
function gitText(projectRoot, args) {
|
|
18640
|
-
return execFileSync2("git", [...args], {
|
|
18641
|
-
cwd: projectRoot,
|
|
18642
|
-
encoding: "utf8",
|
|
18643
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
18644
|
-
}).trim();
|
|
18645
|
-
}
|
|
18646
|
-
function isGitConfigMissing(error) {
|
|
18647
|
-
if (typeof error !== "object" || error === null) return false;
|
|
18648
|
-
const status = error.status;
|
|
18649
|
-
return status === 1;
|
|
18650
|
-
}
|
|
18651
|
-
function readCurrentBranch(projectRoot) {
|
|
18652
|
-
try {
|
|
18653
|
-
return gitText(projectRoot, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
18654
|
-
} catch (error) {
|
|
18655
|
-
gitFailure("cannot read current git branch", error);
|
|
18656
|
-
}
|
|
18657
|
-
}
|
|
18658
|
-
function readHeadSha(projectRoot) {
|
|
18659
|
-
try {
|
|
18660
|
-
return gitText(projectRoot, ["rev-parse", "HEAD"]);
|
|
18661
|
-
} catch (error) {
|
|
18662
|
-
gitFailure("cannot read current HEAD", error);
|
|
18663
|
-
}
|
|
18664
|
-
}
|
|
18665
|
-
function headRefFromMerge(merge) {
|
|
18666
|
-
const trimmed = merge.trim();
|
|
18667
|
-
if (trimmed.length === 0) return void 0;
|
|
18668
|
-
if (trimmed.startsWith("refs/heads/")) {
|
|
18669
|
-
const ref = trimmed.slice("refs/heads/".length);
|
|
18670
|
-
return ref.length > 0 ? ref : void 0;
|
|
18671
|
-
}
|
|
18672
|
-
if (trimmed.startsWith("refs/")) return void 0;
|
|
18673
|
-
return trimmed;
|
|
18674
|
-
}
|
|
18675
|
-
function readUpstreamHeadBinding(projectRoot, branch) {
|
|
18676
|
-
let remote;
|
|
18677
|
-
try {
|
|
18678
|
-
remote = gitText(projectRoot, ["config", "--get", `branch.${branch}.remote`]);
|
|
18679
|
-
} catch (error) {
|
|
18680
|
-
if (isGitConfigMissing(error)) remote = void 0;
|
|
18681
|
-
else gitFailure(`cannot read branch.${branch}.remote`, error);
|
|
18682
|
-
}
|
|
18683
|
-
if (remote === void 0 || remote.length === 0) return void 0;
|
|
18684
|
-
let merge;
|
|
18685
|
-
try {
|
|
18686
|
-
merge = gitText(projectRoot, ["config", "--get", `branch.${branch}.merge`]);
|
|
18687
|
-
} catch (error) {
|
|
18688
|
-
if (isGitConfigMissing(error)) merge = void 0;
|
|
18689
|
-
else gitFailure(`cannot read branch.${branch}.merge`, error);
|
|
18690
|
-
}
|
|
18691
|
-
if (merge === void 0 || merge.length === 0) return void 0;
|
|
18692
|
-
const headRef = headRefFromMerge(merge);
|
|
18693
|
-
if (headRef === void 0) return void 0;
|
|
18694
|
-
let remoteUrl;
|
|
18695
|
-
try {
|
|
18696
|
-
remoteUrl = gitText(projectRoot, ["remote", "get-url", remote]);
|
|
18697
|
-
} catch (error) {
|
|
18698
|
-
gitFailure(`cannot read remote URL for ${remote}`, error);
|
|
18699
|
-
}
|
|
18700
|
-
const headOwner = ownerFromGitHubRemoteUrl(remoteUrl);
|
|
18701
|
-
if (headOwner === void 0) return void 0;
|
|
18702
|
-
return { headOwner, headRef };
|
|
18703
|
-
}
|
|
18704
|
-
async function resolveCollectorTarget(input) {
|
|
18705
|
-
if (input.explicitPrNumber !== void 0) {
|
|
18706
|
-
return { kind: "bound", prNumber: input.explicitPrNumber };
|
|
18707
|
-
}
|
|
18708
|
-
const branch = readCurrentBranch(input.projectRoot);
|
|
18709
|
-
const detached = branch.length === 0 || branch === "HEAD";
|
|
18710
|
-
const runner = createGhApiRunner();
|
|
18711
|
-
const { owner, repo } = input.repository;
|
|
18712
|
-
const numbers = [];
|
|
18713
|
-
if (!detached) {
|
|
18714
|
-
const headSha = readHeadSha(input.projectRoot);
|
|
18715
|
-
const upstream = readUpstreamHeadBinding(input.projectRoot, branch);
|
|
18716
|
-
if (upstream !== void 0) {
|
|
18717
|
-
numbers.push(
|
|
18718
|
-
...await listPullRequestNumbersByHead(runner, {
|
|
18719
|
-
owner,
|
|
18720
|
-
repo,
|
|
18721
|
-
headOwner: upstream.headOwner,
|
|
18722
|
-
headRef: upstream.headRef
|
|
18723
|
-
})
|
|
18724
|
-
);
|
|
18725
|
-
}
|
|
18726
|
-
numbers.push(
|
|
18727
|
-
...await listPullRequestNumbersByCommit(runner, {
|
|
18728
|
-
owner,
|
|
18729
|
-
repo,
|
|
18730
|
-
commitSha: headSha
|
|
18731
|
-
})
|
|
18732
|
-
);
|
|
18733
|
-
} else {
|
|
18734
|
-
const headSha = readHeadSha(input.projectRoot);
|
|
18735
|
-
numbers.push(
|
|
18736
|
-
...await listPullRequestNumbersByCommit(runner, {
|
|
18737
|
-
owner,
|
|
18738
|
-
repo,
|
|
18739
|
-
commitSha: headSha
|
|
18740
|
-
})
|
|
18741
|
-
);
|
|
18742
|
-
}
|
|
18743
|
-
const unique = [...new Set(numbers)];
|
|
18744
|
-
if (unique.length === 1) {
|
|
18745
|
-
return { kind: "bound", prNumber: unique[0] };
|
|
18746
|
-
}
|
|
18747
|
-
if (unique.length > 1) {
|
|
18748
|
-
ambiguousTarget(
|
|
18749
|
-
`multiple PRs associated with context: ${unique.join(", ")}`
|
|
18750
|
-
);
|
|
18751
|
-
}
|
|
18752
|
-
return { kind: "unbound" };
|
|
18753
|
-
}
|
|
18754
|
-
var init_collector_target = __esm({
|
|
18755
|
-
"src/collector-target.ts"() {
|
|
18756
|
-
"use strict";
|
|
18757
|
-
init_collector_github();
|
|
18758
|
-
init_cli_errors();
|
|
18759
|
-
init_github_remote();
|
|
18760
|
-
}
|
|
18761
|
-
});
|
|
18762
|
-
|
|
18763
18416
|
// src/git-object-id.ts
|
|
18764
18417
|
function isFullGitObjectId(value) {
|
|
18765
18418
|
return typeof value === "string" && FULL_GIT_OBJECT_ID_RE.test(value);
|
|
@@ -18872,7 +18525,7 @@ var init_merger_git_state = __esm({
|
|
|
18872
18525
|
|
|
18873
18526
|
// src/ledger-session-read.ts
|
|
18874
18527
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
18875
|
-
function
|
|
18528
|
+
function isRecord3(value) {
|
|
18876
18529
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18877
18530
|
}
|
|
18878
18531
|
async function readLedgerSessionJsonlLines(path) {
|
|
@@ -18897,7 +18550,7 @@ async function readLedgerSessionJsonlLines(path) {
|
|
|
18897
18550
|
});
|
|
18898
18551
|
continue;
|
|
18899
18552
|
}
|
|
18900
|
-
if (!
|
|
18553
|
+
if (!isRecord3(row)) {
|
|
18901
18554
|
const kind = row === null ? "null" : Array.isArray(row) ? "array" : typeof row;
|
|
18902
18555
|
out.push({
|
|
18903
18556
|
line: lineNumber,
|
|
@@ -18950,7 +18603,7 @@ function extractSessionModelSequence(rows) {
|
|
|
18950
18603
|
if (row.type === "model_change" && typeof row.modelId === "string") {
|
|
18951
18604
|
push(row.modelId);
|
|
18952
18605
|
}
|
|
18953
|
-
const message =
|
|
18606
|
+
const message = isRecord3(row.message) ? row.message : void 0;
|
|
18954
18607
|
if (message?.role === "assistant" && typeof message.model === "string") {
|
|
18955
18608
|
push(message.model);
|
|
18956
18609
|
}
|
|
@@ -18966,11 +18619,11 @@ function extractSessionToolIntervals(rows) {
|
|
|
18966
18619
|
const openById = /* @__PURE__ */ new Map();
|
|
18967
18620
|
for (const row of rows) {
|
|
18968
18621
|
const rowTimestamp = typeof row.timestamp === "string" ? row.timestamp : void 0;
|
|
18969
|
-
const message =
|
|
18622
|
+
const message = isRecord3(row.message) ? row.message : void 0;
|
|
18970
18623
|
if (message?.role === "assistant" && Array.isArray(message.content)) {
|
|
18971
18624
|
const callTimestamp = typeof message.timestamp === "string" && message.timestamp ? message.timestamp : rowTimestamp;
|
|
18972
18625
|
for (const part of message.content) {
|
|
18973
|
-
if (!
|
|
18626
|
+
if (!isRecord3(part) || part.type !== "toolCall") continue;
|
|
18974
18627
|
if (typeof part.id !== "string" || part.id.length === 0) {
|
|
18975
18628
|
throw new Error("toolCall frame missing string id");
|
|
18976
18629
|
}
|
|
@@ -18983,7 +18636,7 @@ function extractSessionToolIntervals(rows) {
|
|
|
18983
18636
|
if (openById.has(part.id)) {
|
|
18984
18637
|
throw new Error(`duplicate toolCall id ${part.id}`);
|
|
18985
18638
|
}
|
|
18986
|
-
const args =
|
|
18639
|
+
const args = isRecord3(part.arguments) ? part.arguments : void 0;
|
|
18987
18640
|
const command = part.name === "bash" && args !== void 0 && typeof args.command === "string" ? bashCommandFirstLine(args.command) : void 0;
|
|
18988
18641
|
const interval = {
|
|
18989
18642
|
toolCallId: part.id,
|
|
@@ -19820,13 +19473,12 @@ var init_option_definitions = __esm({
|
|
|
19820
19473
|
canonical: "--pr",
|
|
19821
19474
|
aliases: [],
|
|
19822
19475
|
valueMetavar: "number",
|
|
19823
|
-
// #676 D1: optional when context uniquely determines the PR; ambiguous → require explicit.
|
|
19824
19476
|
required: false,
|
|
19825
19477
|
repeatable: false,
|
|
19826
19478
|
form: "option",
|
|
19827
19479
|
description: {
|
|
19828
|
-
en: "Positive GitHub pull request number. Optional when
|
|
19829
|
-
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"
|
|
19830
19482
|
}
|
|
19831
19483
|
},
|
|
19832
19484
|
{
|
|
@@ -19853,22 +19505,8 @@ var init_option_definitions = __esm({
|
|
|
19853
19505
|
repeatable: false,
|
|
19854
19506
|
form: "option",
|
|
19855
19507
|
description: {
|
|
19856
|
-
en: "Optional request manifest JSON path ({requests:[{id,body}]}).
|
|
19857
|
-
zh: "\u53EF\u9009 request manifest JSON \u8DEF\u5F84\uFF08{requests:[{id,body}]}\uFF09\u3002\
|
|
19858
|
-
}
|
|
19859
|
-
},
|
|
19860
|
-
{
|
|
19861
|
-
id: "wait-ms",
|
|
19862
|
-
owner: "collector",
|
|
19863
|
-
canonical: "--wait-ms",
|
|
19864
|
-
aliases: [],
|
|
19865
|
-
valueMetavar: "ms",
|
|
19866
|
-
required: false,
|
|
19867
|
-
repeatable: false,
|
|
19868
|
-
form: "option",
|
|
19869
|
-
description: {
|
|
19870
|
-
en: "Wait-window duration in milliseconds after the work step opens (default 600000 = 10 minutes). Does not require a code change to adjust.",
|
|
19871
|
-
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"
|
|
19872
19510
|
}
|
|
19873
19511
|
}
|
|
19874
19512
|
];
|
|
@@ -20324,7 +19962,7 @@ var init_option_definitions = __esm({
|
|
|
20324
19962
|
});
|
|
20325
19963
|
|
|
20326
19964
|
// src/public-cli/invocation.ts
|
|
20327
|
-
import { execFileSync as
|
|
19965
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
20328
19966
|
import { existsSync as existsSync4 } from "node:fs";
|
|
20329
19967
|
import {
|
|
20330
19968
|
lstat as lstat4,
|
|
@@ -20724,17 +20362,6 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
20724
20362
|
case "request-manifest":
|
|
20725
20363
|
fields.requestManifestPath = requireOptionPath(taken.def.canonical, value);
|
|
20726
20364
|
return;
|
|
20727
|
-
case "wait-ms": {
|
|
20728
|
-
if (value === void 0 || !/^[1-9]\d*$/.test(value.trim())) {
|
|
20729
|
-
throw new CliUsageError("--wait-ms requires a positive safe-integer millisecond value");
|
|
20730
|
-
}
|
|
20731
|
-
const parsed = Number(value.trim());
|
|
20732
|
-
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
20733
|
-
throw new CliUsageError("--wait-ms requires a positive safe-integer millisecond value");
|
|
20734
|
-
}
|
|
20735
|
-
fields.waitWindowMs = parsed;
|
|
20736
|
-
return;
|
|
20737
|
-
}
|
|
20738
20365
|
case "issue": {
|
|
20739
20366
|
if (value === void 0 || value.trim() === "") {
|
|
20740
20367
|
throw new CliUsageError("doctor --issue requires a positive integer");
|
|
@@ -20831,7 +20458,6 @@ function parsePublicSeatArgv(owner, args) {
|
|
|
20831
20458
|
...fields.prNumber === void 0 ? {} : { prNumber: fields.prNumber },
|
|
20832
20459
|
...fields.repo === void 0 ? {} : { repo: fields.repo },
|
|
20833
20460
|
...fields.requestManifestPath === void 0 ? {} : { requestManifestPath: fields.requestManifestPath },
|
|
20834
|
-
...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs },
|
|
20835
20461
|
...fields.issueNumber === void 0 ? {} : { issueNumber: fields.issueNumber },
|
|
20836
20462
|
...fields.runs === void 0 ? {} : { runs: fields.runs },
|
|
20837
20463
|
...fields.sourceRun === void 0 ? {} : { sourceRun: fields.sourceRun },
|
|
@@ -21191,23 +20817,16 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
21191
20817
|
attachmentPaths,
|
|
21192
20818
|
...project,
|
|
21193
20819
|
placedFields: async (placed) => {
|
|
21194
|
-
const target = await resolveCollectorTarget({
|
|
21195
|
-
projectRoot,
|
|
21196
|
-
repository,
|
|
21197
|
-
...explicitPrNumber === void 0 ? {} : { explicitPrNumber }
|
|
21198
|
-
});
|
|
21199
|
-
const prNumber = target.kind === "bound" ? target.prNumber : void 0;
|
|
21200
20820
|
let requestManifestPath;
|
|
21201
20821
|
if (manifestCanonicalJson !== void 0) {
|
|
21202
20822
|
requestManifestPath = join18(placed.runDirectory, "request-manifest.json");
|
|
21203
20823
|
await writeFile3(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
21204
20824
|
}
|
|
21205
20825
|
return {
|
|
21206
|
-
...
|
|
20826
|
+
...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
|
|
21207
20827
|
repository: repository.canonical,
|
|
21208
20828
|
repositoryDisplay: repository.display,
|
|
21209
20829
|
...requestManifestPath === void 0 ? {} : { requestManifestPath },
|
|
21210
|
-
...parsed.waitWindowMs === void 0 ? {} : { waitWindowMs: parsed.waitWindowMs },
|
|
21211
20830
|
manifestDigest
|
|
21212
20831
|
};
|
|
21213
20832
|
}
|
|
@@ -21641,7 +21260,7 @@ function parseRepoOption(raw) {
|
|
|
21641
21260
|
function resolveGitHubRemoteRepository(projectRoot) {
|
|
21642
21261
|
let remoteUrl;
|
|
21643
21262
|
try {
|
|
21644
|
-
remoteUrl =
|
|
21263
|
+
remoteUrl = execFileSync2("git", ["remote", "get-url", "origin"], {
|
|
21645
21264
|
cwd: projectRoot,
|
|
21646
21265
|
encoding: "utf8",
|
|
21647
21266
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -21993,7 +21612,6 @@ var init_invocation = __esm({
|
|
|
21993
21612
|
init_doctor_evidence();
|
|
21994
21613
|
init_diarist_contracts();
|
|
21995
21614
|
init_collector_config();
|
|
21996
|
-
init_collector_target();
|
|
21997
21615
|
init_github_remote();
|
|
21998
21616
|
init_fixer_packet();
|
|
21999
21617
|
init_merger_git_state();
|
|
@@ -22174,7 +21792,7 @@ var init_role_turn_host_resolution = __esm({
|
|
|
22174
21792
|
// src/analyst-gate-cycles-read.ts
|
|
22175
21793
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
22176
21794
|
import { join as join21 } from "node:path";
|
|
22177
|
-
function
|
|
21795
|
+
function isRecord4(value) {
|
|
22178
21796
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22179
21797
|
}
|
|
22180
21798
|
function isParentAttemptBindingRow(row) {
|
|
@@ -22204,7 +21822,7 @@ function isGateTerminatingToolName(toolName) {
|
|
|
22204
21822
|
function acceptedGateReceiptIds(rows) {
|
|
22205
21823
|
const accepted = /* @__PURE__ */ new Set();
|
|
22206
21824
|
for (const row of rows) {
|
|
22207
|
-
const message =
|
|
21825
|
+
const message = isRecord4(row.message) ? row.message : void 0;
|
|
22208
21826
|
if (message?.role !== "toolResult") continue;
|
|
22209
21827
|
if (typeof message.toolCallId !== "string" || message.toolCallId.length === 0) continue;
|
|
22210
21828
|
if (message.isError === false) accepted.add(message.toolCallId);
|
|
@@ -22239,7 +21857,7 @@ function nearestAttemptBindingBefore(rows, beforeIndex) {
|
|
|
22239
21857
|
for (let i = beforeIndex - 1; i >= 0; i -= 1) {
|
|
22240
21858
|
const row = rows[i];
|
|
22241
21859
|
if (!isParentAttemptBindingRow(row)) continue;
|
|
22242
|
-
if (!
|
|
21860
|
+
if (!isRecord4(row.data) || !isRecord4(row.data.parent)) continue;
|
|
22243
21861
|
const id = row.data.parent.attemptEntryId;
|
|
22244
21862
|
const sessionFile = row.data.parent.sessionFile;
|
|
22245
21863
|
return {
|
|
@@ -22254,10 +21872,10 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22254
21872
|
const out = [];
|
|
22255
21873
|
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
22256
21874
|
const row = rows[rowIndex];
|
|
22257
|
-
const message =
|
|
21875
|
+
const message = isRecord4(row.message) ? row.message : void 0;
|
|
22258
21876
|
if (message?.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
22259
21877
|
for (const part of message.content) {
|
|
22260
|
-
if (!
|
|
21878
|
+
if (!isRecord4(part) || part.type !== "toolCall") continue;
|
|
22261
21879
|
if (typeof part.id !== "string" || part.id.length === 0) continue;
|
|
22262
21880
|
if (typeof part.name !== "string" || part.name.length === 0) continue;
|
|
22263
21881
|
if (!isGateTerminatingToolName(part.name)) continue;
|
|
@@ -22265,7 +21883,7 @@ function extractAllAcceptedGateToolCalls(rows) {
|
|
|
22265
21883
|
const binding = nearestAttemptBindingBefore(rows, rowIndex);
|
|
22266
21884
|
out.push({
|
|
22267
21885
|
toolName: part.name,
|
|
22268
|
-
args:
|
|
21886
|
+
args: isRecord4(part.arguments) ? part.arguments : void 0,
|
|
22269
21887
|
accepted: true,
|
|
22270
21888
|
rowIndex,
|
|
22271
21889
|
...binding
|
|
@@ -22398,7 +22016,7 @@ async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
|
22398
22016
|
{ cause: error }
|
|
22399
22017
|
);
|
|
22400
22018
|
}
|
|
22401
|
-
if (!
|
|
22019
|
+
if (!isRecord4(raw) || raw.kind !== "direct-officer-run-pointer" || raw.version !== 1) {
|
|
22402
22020
|
throw new Error(`direct officer run pointer has unknown shape in ${pointerPath}`);
|
|
22403
22021
|
}
|
|
22404
22022
|
const sessionFile = raw.sessionFile;
|
|
@@ -22884,11 +22502,11 @@ var init_serialize_thrown_value = __esm({
|
|
|
22884
22502
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
22885
22503
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
22886
22504
|
import { dirname as dirname14, join as join25 } from "node:path";
|
|
22887
|
-
function
|
|
22505
|
+
function isRecord5(value) {
|
|
22888
22506
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22889
22507
|
}
|
|
22890
22508
|
function callFactFromSitianPayload(payload, pointer) {
|
|
22891
|
-
if (!
|
|
22509
|
+
if (!isRecord5(payload)) return void 0;
|
|
22892
22510
|
if (payload.tool !== ENGINE_DETOUR_TOOL_NAME) return void 0;
|
|
22893
22511
|
if (typeof payload.toolCallId !== "string" || payload.toolCallId.length === 0) {
|
|
22894
22512
|
return void 0;
|
|
@@ -22905,11 +22523,11 @@ function callFactFromSitianPayload(payload, pointer) {
|
|
|
22905
22523
|
};
|
|
22906
22524
|
}
|
|
22907
22525
|
function invocationScopeIdOfRecord(record4) {
|
|
22908
|
-
if (
|
|
22526
|
+
if (isRecord5(record4.subject)) {
|
|
22909
22527
|
const fromSubject = record4.subject.invocationScopeId;
|
|
22910
22528
|
if (typeof fromSubject === "string" && fromSubject.length > 0) return fromSubject;
|
|
22911
22529
|
}
|
|
22912
|
-
if (
|
|
22530
|
+
if (isRecord5(record4.payload)) {
|
|
22913
22531
|
const fromPayload = record4.payload.invocationScopeId;
|
|
22914
22532
|
if (typeof fromPayload === "string" && fromPayload.length > 0) return fromPayload;
|
|
22915
22533
|
}
|
|
@@ -22970,7 +22588,7 @@ function readInvocationRecord(runDirectory) {
|
|
|
22970
22588
|
const raw = JSON.parse(
|
|
22971
22589
|
readFileSync2(join25(runDirectory, "invocation.json"), "utf8")
|
|
22972
22590
|
);
|
|
22973
|
-
return
|
|
22591
|
+
return isRecord5(raw) ? raw : void 0;
|
|
22974
22592
|
} catch (error) {
|
|
22975
22593
|
if (error?.code === "ENOENT") return void 0;
|
|
22976
22594
|
throw error;
|
|
@@ -22983,7 +22601,7 @@ async function readInvocationEngineMounted(runDirectory) {
|
|
|
22983
22601
|
}
|
|
22984
22602
|
function withEngineDetourToolUsageFact(outcome, usage) {
|
|
22985
22603
|
if (usage === void 0) return outcome;
|
|
22986
|
-
const prior =
|
|
22604
|
+
const prior = isRecord5(outcome.decisiveFacts) ? outcome.decisiveFacts : {};
|
|
22987
22605
|
return {
|
|
22988
22606
|
...outcome,
|
|
22989
22607
|
decisiveFacts: {
|
|
@@ -23053,13 +22671,13 @@ function resolveAuditDossier(source) {
|
|
|
23053
22671
|
}
|
|
23054
22672
|
return { status: "ok", runDirectory };
|
|
23055
22673
|
}
|
|
23056
|
-
function
|
|
22674
|
+
function isRecord6(value) {
|
|
23057
22675
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23058
22676
|
}
|
|
23059
22677
|
function readDoctorAuditSubjects(context) {
|
|
23060
22678
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
23061
22679
|
for (const entry of entries) {
|
|
23062
|
-
if (
|
|
22680
|
+
if (isRecord6(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
23063
22681
|
return { status: "ok" };
|
|
23064
22682
|
}
|
|
23065
22683
|
}
|
|
@@ -23204,11 +22822,11 @@ var init_navigator_invocation_identity = __esm({
|
|
|
23204
22822
|
});
|
|
23205
22823
|
|
|
23206
22824
|
// src/receipt-delivery-policy.ts
|
|
23207
|
-
function
|
|
22825
|
+
function isRecord7(value) {
|
|
23208
22826
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23209
22827
|
}
|
|
23210
22828
|
function parseNoReceiptLifecycleFacts(input) {
|
|
23211
|
-
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")) {
|
|
23212
22830
|
throw new TypeError("malformed no-receipt lifecycle facts");
|
|
23213
22831
|
}
|
|
23214
22832
|
return {
|
|
@@ -23264,7 +22882,6 @@ __export(settlement_exports, {
|
|
|
23264
22882
|
controlledFailureInputFromResolution: () => controlledFailureInputFromResolution,
|
|
23265
22883
|
exitCodeForTerminalOutcome: () => exitCodeForTerminalOutcome,
|
|
23266
22884
|
explicitInternalKnownFailureClassificationInput: () => explicitInternalKnownFailureClassificationInput,
|
|
23267
|
-
extractCollectorInfrastructureFailure: () => extractCollectorInfrastructureFailure,
|
|
23268
22885
|
extractEngineDetourInfrastructureFailure: () => extractEngineDetourInfrastructureFailure,
|
|
23269
22886
|
extractGateFactFromSessionDirectory: () => extractGateFactFromSessionDirectory,
|
|
23270
22887
|
extractNavigatorFact: () => extractNavigatorFact,
|
|
@@ -23285,7 +22902,6 @@ __export(settlement_exports, {
|
|
|
23285
22902
|
publishedFailureErrorPath: () => publishedFailureErrorPath,
|
|
23286
22903
|
raceNavigatorGrace: () => raceNavigatorGrace,
|
|
23287
22904
|
readBoundSessionEntries: () => readBoundSessionEntries,
|
|
23288
|
-
readCollectorInfrastructureFailure: () => readCollectorInfrastructureFailure,
|
|
23289
22905
|
readEngineDetourInfrastructureFailure: () => readEngineDetourInfrastructureFailure,
|
|
23290
22906
|
readSessionProviderStop: () => readSessionProviderStop,
|
|
23291
22907
|
recordedSubmissionPayloads: () => recordedSubmissionPayloads,
|
|
@@ -23783,7 +23399,7 @@ async function readSitianRetainedAuditorProviderStop(sessionFile) {
|
|
|
23783
23399
|
const { records } = await readSitianRecords(recordFile);
|
|
23784
23400
|
for (let i = records.length - 1; i >= 0; i -= 1) {
|
|
23785
23401
|
const payload = records[i]?.payload;
|
|
23786
|
-
if (!
|
|
23402
|
+
if (!isRecord8(payload) || !isRecord8(payload.response)) continue;
|
|
23787
23403
|
if (typeof payload.type === "string") continue;
|
|
23788
23404
|
const stop = sessionProviderStopFromAssistant(payload.response);
|
|
23789
23405
|
if (stop !== void 0) return stop;
|
|
@@ -23833,7 +23449,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
23833
23449
|
throw sessionReadFailure(error, "failed to read discovered auditor session");
|
|
23834
23450
|
}
|
|
23835
23451
|
const header = entries.find((entry) => entry.type === "session");
|
|
23836
|
-
if (!
|
|
23452
|
+
if (!isRecord8(header)) continue;
|
|
23837
23453
|
const bindingIndexes = [];
|
|
23838
23454
|
for (let i = 0; i < entries.length; i += 1) {
|
|
23839
23455
|
const entry = entries[i];
|
|
@@ -23847,7 +23463,7 @@ async function loadBoundAuditorVolumes(sessionFile) {
|
|
|
23847
23463
|
end: idx + 1 < bindingIndexes.length ? bindingIndexes[idx + 1] : entries.length
|
|
23848
23464
|
})) : [{ entry: void 0, start: 0, end: entries.length }];
|
|
23849
23465
|
for (const { entry: bindingEntry, start, end } of bindingPasses) {
|
|
23850
|
-
const bindingParent = bindingEntry !== void 0 &&
|
|
23466
|
+
const bindingParent = bindingEntry !== void 0 && isRecord8(bindingEntry.data) && isRecord8(bindingEntry.data.parent) ? bindingEntry.data.parent : void 0;
|
|
23851
23467
|
const attemptEntryId = typeof bindingParent?.attemptEntryId === "string" ? bindingParent.attemptEntryId : void 0;
|
|
23852
23468
|
const boundSessionFile = typeof bindingParent?.sessionFile === "string" ? bindingParent.sessionFile : typeof header.parentSession === "string" ? header.parentSession : void 0;
|
|
23853
23469
|
if (boundSessionFile !== sessionFile) continue;
|
|
@@ -23871,12 +23487,12 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
23871
23487
|
if (stop === void 0) continue;
|
|
23872
23488
|
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
23873
23489
|
const entry = entries[i];
|
|
23874
|
-
if (entry?.type !== "custom" || entry.customType !== AUDITOR_COMPLIANCE_FAILURE_ENTRY_TYPE || !
|
|
23875
|
-
const parent =
|
|
23876
|
-
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;
|
|
23877
23493
|
if (parent?.sessionId !== parentId || parent.sessionFile !== sessionFile || parent.attemptEntryId !== attemptEntryId) continue;
|
|
23878
23494
|
if (failure === void 0) continue;
|
|
23879
|
-
const identity =
|
|
23495
|
+
const identity = isRecord8(failure.identity) ? failure.identity : void 0;
|
|
23880
23496
|
const typedCause = failure.cause === "provider" || failure.cause === "activation" || failure.cause === "session" || failure.cause === "output" || failure.cause === "timeout" ? failure.cause : void 0;
|
|
23881
23497
|
return {
|
|
23882
23498
|
...typedCause === void 0 ? {} : { cause: typedCause },
|
|
@@ -23885,7 +23501,7 @@ function complianceFailureFromAuditorVolumes(volumes) {
|
|
|
23885
23501
|
...typeof identity.code === "string" || typeof identity.code === "number" ? { code: identity.code } : {}
|
|
23886
23502
|
} },
|
|
23887
23503
|
...typeof failure.diagnostic === "string" ? { diagnostic: failure.diagnostic } : {},
|
|
23888
|
-
...
|
|
23504
|
+
...isRecord8(failure.details) ? { details: failure.details } : {}
|
|
23889
23505
|
};
|
|
23890
23506
|
}
|
|
23891
23507
|
}
|
|
@@ -23932,9 +23548,9 @@ function typedFailedTerminatingToolKnownFailure(entries) {
|
|
|
23932
23548
|
if (classification.kind !== "infrastructure") continue;
|
|
23933
23549
|
if (typeof message.toolCallId !== "string" || typeof message.toolName !== "string") continue;
|
|
23934
23550
|
if (boundRoleToolCallForResult(attemptEntries, i, message, message.toolName) === void 0) continue;
|
|
23935
|
-
const textPart = Array.isArray(message.content) ? message.content.find((part) =>
|
|
23936
|
-
const diagnostic =
|
|
23937
|
-
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;
|
|
23938
23554
|
return {
|
|
23939
23555
|
cause: "activation",
|
|
23940
23556
|
identity: { name: message.toolName, code: message.toolCallId },
|
|
@@ -24071,7 +23687,7 @@ function controlledFailureInputFromResolution(resolution) {
|
|
|
24071
23687
|
} : {}
|
|
24072
23688
|
};
|
|
24073
23689
|
}
|
|
24074
|
-
function
|
|
23690
|
+
function isRecord8(value) {
|
|
24075
23691
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24076
23692
|
}
|
|
24077
23693
|
function toolResultText(message) {
|
|
@@ -24085,22 +23701,6 @@ function toolResultText(message) {
|
|
|
24085
23701
|
return "";
|
|
24086
23702
|
}).join("").trim();
|
|
24087
23703
|
}
|
|
24088
|
-
function extractCollectorTargetBindRejection(entries) {
|
|
24089
|
-
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
24090
|
-
const entry = entries[i];
|
|
24091
|
-
if (entry?.type !== "message") continue;
|
|
24092
|
-
const message = entry.message;
|
|
24093
|
-
if (message?.role !== "toolResult") continue;
|
|
24094
|
-
if (message.toolName !== COLLECTOR_BIND_TARGET_TOOL) continue;
|
|
24095
|
-
if (message.isError !== true) return void 0;
|
|
24096
|
-
const diagnostic = toolResultText(message);
|
|
24097
|
-
if (diagnostic.length === 0) return void 0;
|
|
24098
|
-
const details = message.details;
|
|
24099
|
-
const code = isRecord9(details) && typeof details.code === "string" && details.code.trim() !== "" ? details.code : void 0;
|
|
24100
|
-
return code === void 0 ? { diagnostic } : { diagnostic, code };
|
|
24101
|
-
}
|
|
24102
|
-
return void 0;
|
|
24103
|
-
}
|
|
24104
23704
|
function boundErroredToolCandidate(entries, resultIndex, message, toolName) {
|
|
24105
23705
|
if (message.toolName !== toolName || message.isError !== true) return void 0;
|
|
24106
23706
|
const bound = boundRoleToolCallForResult(entries, resultIndex, message, toolName);
|
|
@@ -24141,21 +23741,6 @@ async function readInfrastructureToolFailure(sessionFile, spec, options = {}) {
|
|
|
24141
23741
|
return void 0;
|
|
24142
23742
|
}
|
|
24143
23743
|
}
|
|
24144
|
-
function extractCollectorInfrastructureFailure(entries) {
|
|
24145
|
-
return extractInfrastructureToolFailure(
|
|
24146
|
-
entries,
|
|
24147
|
-
COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC
|
|
24148
|
-
);
|
|
24149
|
-
}
|
|
24150
|
-
async function readCollectorInfrastructureFailure(sessionFile) {
|
|
24151
|
-
return readInfrastructureToolFailure(
|
|
24152
|
-
sessionFile,
|
|
24153
|
-
COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC,
|
|
24154
|
-
// Multi-attempt resume: only a current-attempt infrastructure failure
|
|
24155
|
-
// may preempt the current failure cause (#633).
|
|
24156
|
-
{ currentAttemptOnly: true }
|
|
24157
|
-
);
|
|
24158
|
-
}
|
|
24159
23744
|
function extractEngineDetourInfrastructureFailure(entries) {
|
|
24160
23745
|
return extractInfrastructureToolFailure(
|
|
24161
23746
|
entries,
|
|
@@ -24197,7 +23782,7 @@ function boundRoleToolCallForResult(entries, resultIndex, message, outputToolNam
|
|
|
24197
23782
|
const candidateMessage = entries[index]?.message;
|
|
24198
23783
|
if (candidateMessage?.role === "assistant" && Array.isArray(candidateMessage.content)) {
|
|
24199
23784
|
for (const part of candidateMessage.content) {
|
|
24200
|
-
if (!
|
|
23785
|
+
if (!isRecord8(part) || part.type !== "toolCall" || part.id !== callId) {
|
|
24201
23786
|
continue;
|
|
24202
23787
|
}
|
|
24203
23788
|
if (part.name !== outputToolName) return void 0;
|
|
@@ -24268,7 +23853,7 @@ function parseNavigatorAttendanceDetails(details) {
|
|
|
24268
23853
|
if (typeof details.prose === "string" && details.prose.trim() !== "") {
|
|
24269
23854
|
prose = details.prose;
|
|
24270
23855
|
} else {
|
|
24271
|
-
const next =
|
|
23856
|
+
const next = isRecord8(details.next) && typeof details.next.role === "string" ? details.next.role : void 0;
|
|
24272
23857
|
const reason = typeof details.reason === "string" && details.reason.trim() !== "" ? details.reason : void 0;
|
|
24273
23858
|
const command = typeof details.command === "string" && details.command.trim() !== "" ? details.command : void 0;
|
|
24274
23859
|
if (reason !== void 0 && next !== void 0) {
|
|
@@ -24377,7 +23962,7 @@ function detourGateContext(admitted, scope) {
|
|
|
24377
23962
|
}
|
|
24378
23963
|
async function withOptionalGateProjection(base, sessionDirectory, gateContext = {}) {
|
|
24379
23964
|
const secondaryEvidence = base.roleOutcome.kind === "failure" ? base.roleOutcome.decisiveFacts.secondaryEvidence : void 0;
|
|
24380
|
-
const skipGate =
|
|
23965
|
+
const skipGate = isRecord8(secondaryEvidence) && secondaryEvidence.kind === "role_infrastructure_failure" && packagedSkipsGateOnInfrastructureStage(secondaryEvidence.stage);
|
|
24381
23966
|
let next = base;
|
|
24382
23967
|
if (!skipGate) {
|
|
24383
23968
|
const gate = await extractGateFactFromSessionDirectory(sessionDirectory, gateContext);
|
|
@@ -24390,7 +23975,7 @@ function routePlaybookFailureMessage(entries) {
|
|
|
24390
23975
|
const entry = entries[i];
|
|
24391
23976
|
if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
|
|
24392
23977
|
const data = entry.data;
|
|
24393
|
-
if (!
|
|
23978
|
+
if (!isRecord8(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
|
|
24394
23979
|
return data.message;
|
|
24395
23980
|
}
|
|
24396
23981
|
return void 0;
|
|
@@ -24437,7 +24022,7 @@ function extractNavigatorAttendanceFact(entries) {
|
|
|
24437
24022
|
const entry = entries[i];
|
|
24438
24023
|
if (entry?.type === "custom_message" && entry.customType === "ak-navigator-attendance") {
|
|
24439
24024
|
const details = entry.message?.details ?? entry.details;
|
|
24440
|
-
if (!
|
|
24025
|
+
if (!isRecord8(details)) {
|
|
24441
24026
|
return {
|
|
24442
24027
|
disposition: "unavailable",
|
|
24443
24028
|
source: "unknown",
|
|
@@ -24588,7 +24173,7 @@ async function settleSealedAcceptedOrToolResidual(admitted, authority, scope, ro
|
|
|
24588
24173
|
const residual = boundErroredToolCandidate(entries, index, message, residualToolName);
|
|
24589
24174
|
if (residual === void 0) continue;
|
|
24590
24175
|
const candidate = residual.candidate;
|
|
24591
|
-
const details =
|
|
24176
|
+
const details = isRecord8(candidate) ? candidate : { candidate };
|
|
24592
24177
|
const failed = await settleFailureTerminalResult(
|
|
24593
24178
|
admitted,
|
|
24594
24179
|
{
|
|
@@ -24663,7 +24248,7 @@ function extractDoctorCandidateFacts(entries) {
|
|
|
24663
24248
|
continue;
|
|
24664
24249
|
}
|
|
24665
24250
|
const data = entry.data;
|
|
24666
|
-
if (!
|
|
24251
|
+
if (!isRecord8(data)) return {};
|
|
24667
24252
|
return {
|
|
24668
24253
|
...data.cost === void 0 ? {} : { cost: data.cost },
|
|
24669
24254
|
...data.auditNoReceipt === void 0 ? {} : { auditNoReceipt: data.auditNoReceipt }
|
|
@@ -24748,7 +24333,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
24748
24333
|
let residual;
|
|
24749
24334
|
for (let index = entries.length - 1; index >= scanStart; index -= 1) {
|
|
24750
24335
|
const entry = entries[index];
|
|
24751
|
-
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") {
|
|
24752
24337
|
thisAttemptHasSeatSuccess = true;
|
|
24753
24338
|
}
|
|
24754
24339
|
const message = entries[index]?.message;
|
|
@@ -24788,7 +24373,7 @@ async function settleLawfulSeatAcceptedTerminalResult(admitted, authority, spec,
|
|
|
24788
24373
|
);
|
|
24789
24374
|
}
|
|
24790
24375
|
if (residual !== void 0) {
|
|
24791
|
-
const details =
|
|
24376
|
+
const details = isRecord8(residual.candidate) ? residual.candidate : { candidate: residual.candidate };
|
|
24792
24377
|
const failed = await settleFailureTerminalResult(
|
|
24793
24378
|
admitted,
|
|
24794
24379
|
{
|
|
@@ -24838,7 +24423,7 @@ function countersignTerminalFromEntries(entries) {
|
|
|
24838
24423
|
return void 0;
|
|
24839
24424
|
}
|
|
24840
24425
|
function withCountersignTerminalFact(roleOutcome, officer) {
|
|
24841
|
-
const prior = roleOutcome.decisiveFacts !== void 0 &&
|
|
24426
|
+
const prior = roleOutcome.decisiveFacts !== void 0 && isRecord8(roleOutcome.decisiveFacts) ? roleOutcome.decisiveFacts : {};
|
|
24842
24427
|
return {
|
|
24843
24428
|
...roleOutcome,
|
|
24844
24429
|
decisiveFacts: {
|
|
@@ -24851,7 +24436,7 @@ function acceptedSecretariatDefinesOfficerProjection(roleOutcome) {
|
|
|
24851
24436
|
const payloads = roleOutcome.payloads ?? [];
|
|
24852
24437
|
for (let index = payloads.length - 1; index >= 0; index -= 1) {
|
|
24853
24438
|
const payload = payloads[index];
|
|
24854
|
-
if (!
|
|
24439
|
+
if (!isRecord8(payload)) continue;
|
|
24855
24440
|
const status = payload.secretariatStatus;
|
|
24856
24441
|
if (typeof status !== "string") continue;
|
|
24857
24442
|
return status === "converged";
|
|
@@ -25079,17 +24664,6 @@ async function settleFailureTerminalResult(admitted, failure, authority, options
|
|
|
25079
24664
|
}
|
|
25080
24665
|
if (facts !== void 0 && facts.runPointer === admitted.runDirectory && facts.attemptPointer === `current:${admitted.runDirectory}`) {
|
|
25081
24666
|
let decisiveFacts2 = facts;
|
|
25082
|
-
if (packagedProjectsTargetBindRejection(admitted.role)) {
|
|
25083
|
-
const bindRejection = extractCollectorTargetBindRejection(entries.slice(attemptStart));
|
|
25084
|
-
if (bindRejection !== void 0) {
|
|
25085
|
-
decisiveFacts2 = {
|
|
25086
|
-
...facts,
|
|
25087
|
-
targetBindRejected: true,
|
|
25088
|
-
targetBindDiagnostic: bindRejection.diagnostic,
|
|
25089
|
-
...bindRejection.code === void 0 ? {} : { targetBindCode: bindRejection.code }
|
|
25090
|
-
};
|
|
25091
|
-
}
|
|
25092
|
-
}
|
|
25093
24667
|
await clearOppositeTerminalArtifactFace(admitted.runDirectory);
|
|
25094
24668
|
return withOptionalGateProjection(
|
|
25095
24669
|
{
|
|
@@ -25224,7 +24798,7 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
25224
24798
|
});
|
|
25225
24799
|
});
|
|
25226
24800
|
}
|
|
25227
|
-
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;
|
|
25228
24802
|
var init_settlement = __esm({
|
|
25229
24803
|
"src/public-cli/settlement.ts"() {
|
|
25230
24804
|
"use strict";
|
|
@@ -25237,11 +24811,9 @@ var init_settlement = __esm({
|
|
|
25237
24811
|
init_serialize_thrown_value();
|
|
25238
24812
|
init_run_lifecycle();
|
|
25239
24813
|
init_compliance_transport();
|
|
25240
|
-
init_collector_ledger();
|
|
25241
24814
|
init_engine_detour();
|
|
25242
24815
|
init_engine_detour_usage();
|
|
25243
24816
|
init_judge_output();
|
|
25244
|
-
init_collector_output();
|
|
25245
24817
|
init_worker_output();
|
|
25246
24818
|
init_doctor_contracts();
|
|
25247
24819
|
init_dossier_resolution();
|
|
@@ -25257,20 +24829,6 @@ var init_settlement = __esm({
|
|
|
25257
24829
|
init_terminal();
|
|
25258
24830
|
privateFailureErrorPaths = /* @__PURE__ */ new WeakMap();
|
|
25259
24831
|
NAVIGATOR_POST_ROLE_GRACE_MS = 1e4;
|
|
25260
|
-
COLLECTOR_INFRASTRUCTURE_TOOLS = /* @__PURE__ */ new Set([
|
|
25261
|
-
COLLECTOR_OBSERVE_TOOL,
|
|
25262
|
-
COLLECTOR_READ_TOOL,
|
|
25263
|
-
COLLECTOR_REQUEST_TOOL,
|
|
25264
|
-
COLLECTOR_WAIT_TOOL
|
|
25265
|
-
]);
|
|
25266
|
-
COLLECTOR_INFRASTRUCTURE_FAILURE_SPEC = {
|
|
25267
|
-
matchTool: (toolName) => COLLECTOR_INFRASTRUCTURE_TOOLS.has(toolName),
|
|
25268
|
-
cause: "activation",
|
|
25269
|
-
identityName: "CollectorInfrastructureError",
|
|
25270
|
-
// read alone has a correctable rejection mode (unknown/non-openable pointers);
|
|
25271
|
-
// only its typed infrastructure-failure fact counts as a real host failure.
|
|
25272
|
-
requireInfrastructureFact: (toolName) => toolName === COLLECTOR_READ_TOOL
|
|
25273
|
-
};
|
|
25274
24832
|
ENGINE_DETOUR_INFRASTRUCTURE_FAILURE_SPEC = {
|
|
25275
24833
|
matchTool: (toolName) => toolName === ENGINE_DETOUR_TOOL_NAME,
|
|
25276
24834
|
cause: "output",
|
|
@@ -25284,10 +24842,6 @@ var init_settlement = __esm({
|
|
|
25284
24842
|
"engine-detour-record-first": {
|
|
25285
24843
|
read: readEngineDetourInfrastructureFailure,
|
|
25286
24844
|
rank: "record-first"
|
|
25287
|
-
},
|
|
25288
|
-
"collector-known-first": {
|
|
25289
|
-
read: readCollectorInfrastructureFailure,
|
|
25290
|
-
rank: "known-first"
|
|
25291
24845
|
}
|
|
25292
24846
|
};
|
|
25293
24847
|
ATTEMPT_HISTORY_ENTRY_TYPE = "ak_run_attempt_history";
|
|
@@ -25651,11 +25205,11 @@ var init_turn_request = __esm({
|
|
|
25651
25205
|
});
|
|
25652
25206
|
|
|
25653
25207
|
// src/public-cli/countersign-run.ts
|
|
25654
|
-
function
|
|
25208
|
+
function isRecord9(value) {
|
|
25655
25209
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25656
25210
|
}
|
|
25657
25211
|
function isEscalatePayload(payload) {
|
|
25658
|
-
if (!
|
|
25212
|
+
if (!isRecord9(payload)) return false;
|
|
25659
25213
|
return payload.status === "escalate";
|
|
25660
25214
|
}
|
|
25661
25215
|
function courtDiaristPayloadRows(roleOutcome, submissions) {
|
|
@@ -30817,7 +30371,7 @@ function isMissingPathError6(error) {
|
|
|
30817
30371
|
function errorText3(error) {
|
|
30818
30372
|
return error instanceof Error ? error.message : String(error);
|
|
30819
30373
|
}
|
|
30820
|
-
function
|
|
30374
|
+
function isRecord10(value) {
|
|
30821
30375
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30822
30376
|
}
|
|
30823
30377
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
@@ -30874,7 +30428,7 @@ async function readInvocationScopeFields(runDirectory) {
|
|
|
30874
30428
|
throw error;
|
|
30875
30429
|
}
|
|
30876
30430
|
const parsed = JSON.parse(raw);
|
|
30877
|
-
if (!
|
|
30431
|
+
if (!isRecord10(parsed)) return void 0;
|
|
30878
30432
|
if (typeof parsed.projectRoot !== "string" || parsed.projectRoot.trim() === "") {
|
|
30879
30433
|
return void 0;
|
|
30880
30434
|
}
|
|
@@ -30903,7 +30457,7 @@ async function resolveSessionFile(runDirectory) {
|
|
|
30903
30457
|
try {
|
|
30904
30458
|
const raw = await readFile19(join37(runDirectory, "invocation.json"), "utf8");
|
|
30905
30459
|
const parsed = JSON.parse(raw);
|
|
30906
|
-
if (
|
|
30460
|
+
if (isRecord10(parsed) && typeof parsed.sessionFile === "string" && parsed.sessionFile.trim() !== "") {
|
|
30907
30461
|
return parsed.sessionFile;
|
|
30908
30462
|
}
|
|
30909
30463
|
} catch (error) {
|
|
@@ -31241,7 +30795,7 @@ var init_analyst_ledger = __esm({
|
|
|
31241
30795
|
});
|
|
31242
30796
|
|
|
31243
30797
|
// src/analyst-metric-families/acceptance-success-rework.ts
|
|
31244
|
-
function
|
|
30798
|
+
function isRecord11(value) {
|
|
31245
30799
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31246
30800
|
}
|
|
31247
30801
|
function wallMsFromSpan(span) {
|
|
@@ -31250,21 +30804,21 @@ function wallMsFromSpan(span) {
|
|
|
31250
30804
|
function findCollectorGroups(body) {
|
|
31251
30805
|
if (Array.isArray(body.groups)) return body.groups;
|
|
31252
30806
|
const receipt = body.receipt;
|
|
31253
|
-
if (
|
|
30807
|
+
if (isRecord11(receipt) && Array.isArray(receipt.groups)) return receipt.groups;
|
|
31254
30808
|
const outcome = body.outcome;
|
|
31255
|
-
if (
|
|
30809
|
+
if (isRecord11(outcome)) {
|
|
31256
30810
|
const facts = outcome.decisiveFacts;
|
|
31257
|
-
if (
|
|
30811
|
+
if (isRecord11(facts) && Array.isArray(facts.groups)) return facts.groups;
|
|
31258
30812
|
}
|
|
31259
30813
|
return void 0;
|
|
31260
30814
|
}
|
|
31261
30815
|
function extractStatus(body) {
|
|
31262
30816
|
const outcome = body.outcome;
|
|
31263
|
-
if (
|
|
30817
|
+
if (isRecord11(outcome) && typeof outcome.status === "string" && outcome.status.trim() !== "") {
|
|
31264
30818
|
return outcome.status;
|
|
31265
30819
|
}
|
|
31266
30820
|
const receipt = body.receipt;
|
|
31267
|
-
if (
|
|
30821
|
+
if (isRecord11(receipt) && typeof receipt.status === "string" && receipt.status.trim() !== "") {
|
|
31268
30822
|
return receipt.status;
|
|
31269
30823
|
}
|
|
31270
30824
|
if (typeof body.status === "string" && body.status.trim() !== "") {
|
|
@@ -31890,15 +31444,15 @@ var init_leg_wall_clock = __esm({
|
|
|
31890
31444
|
});
|
|
31891
31445
|
|
|
31892
31446
|
// src/analyst-metric-families/round-timeline.ts
|
|
31893
|
-
function
|
|
31447
|
+
function isRecord12(value) {
|
|
31894
31448
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31895
31449
|
}
|
|
31896
31450
|
function wallMsFromSpan2(startedAt, endedAt) {
|
|
31897
31451
|
return Date.parse(endedAt) - Date.parse(startedAt);
|
|
31898
31452
|
}
|
|
31899
31453
|
function readClassCount(body) {
|
|
31900
|
-
if (!
|
|
31901
|
-
if (!
|
|
31454
|
+
if (!isRecord12(body.outcome)) return void 0;
|
|
31455
|
+
if (!isRecord12(body.outcome.decisiveFacts)) return void 0;
|
|
31902
31456
|
const classCount = body.outcome.decisiveFacts.classCount;
|
|
31903
31457
|
if (typeof classCount !== "number" || !Number.isFinite(classCount)) {
|
|
31904
31458
|
return void 0;
|