@akagilnc/pi-workflow-roles 0.1.5593 → 0.1.5614
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/acp-host/production-host.js +521 -707
- package/dist/compliance-transport.js +2 -5
- package/dist/doctor-auditor.js +1 -1
- package/dist/gatekeeper-role.js +1 -1
- package/dist/headless-host/production-host.js +505 -691
- package/dist/merger-contracts.js +6 -2
- package/dist/migrate-book-topology.js +5142 -10735
- package/dist/navigator-public-session.js +4 -4
- package/dist/navigator-work-base.js +5 -30
- package/dist/package-contracts/worker-output.js +1 -6
- package/dist/packaged-role-registry.js +9 -6
- package/dist/pi/role-turn-host.js +10 -1
- package/dist/public-cli/instruction-seat-run.js +133 -38
- package/dist/public-cli/invocation.js +38 -74
- package/dist/public-cli/main.js +18155 -18235
- package/dist/public-cli/option-definitions.js +21 -2
- package/dist/public-cli/post-admission.js +25 -24
- package/dist/public-cli/run-lifecycle.js +4 -43
- package/dist/public-cli/turn-request.js +4 -9
- package/dist/public-role-summons.js +5 -3
- package/dist/role-run-placement.js +7 -1
- package/dist/role-run-relocation.js +3 -4
- package/package.json +1 -1
- package/scripts/build-package.mjs +2 -4
- package/src/audited-run-identity.ts +30 -0
- package/src/compliance-transport.ts +1 -4
- package/src/doctor-auditor.ts +1 -1
- package/src/gatekeeper-role.ts +1 -1
- package/src/host-contracts.ts +6 -4
- package/src/merger-contracts.ts +6 -2
- package/src/merger-role.ts +11 -1
- package/src/navigator-attendance.ts +2 -2
- package/src/navigator-public-session.ts +9 -5
- package/src/navigator-work-base.ts +19 -34
- package/src/notary-role.ts +12 -21
- package/src/package-contracts/worker-output.ts +0 -8
- package/src/packaged-role-registry.ts +8 -7
- package/src/pi/role-turn-host.ts +11 -1
- package/src/public-cli/instruction-seat-run.ts +162 -42
- package/src/public-cli/invocation.ts +55 -93
- package/src/public-cli/option-definitions.ts +22 -2
- package/src/public-cli/post-admission.ts +30 -24
- package/src/public-cli/run-lifecycle.ts +4 -56
- package/src/public-cli/turn-request.ts +9 -8
- package/src/public-role-summons.ts +17 -6
- package/src/role-envelope.ts +4 -0
- package/src/role-run-placement.ts +10 -1
- package/src/role-run-relocation.ts +3 -4
- package/src/role-runtime-dependencies.ts +0 -2
- package/src/role-runtime.ts +54 -47
- package/src/worker-role.ts +11 -78
- package/dist/auditor-dossier-tool.js +0 -47
- package/dist/package-contracts/fixer-packet.js +0 -77
- package/packets/fixer-prerequisites.json +0 -6
- package/src/auditor-dossier-tool.ts +0 -63
- package/src/package-contracts/fixer-packet.ts +0 -91
|
@@ -733,85 +733,8 @@ var init_fixer_output = __esm({
|
|
|
733
733
|
}
|
|
734
734
|
});
|
|
735
735
|
|
|
736
|
-
// src/package-contracts/fixer-packet.ts
|
|
737
|
-
import { Type as Type8 } from "typebox";
|
|
738
|
-
import { Value } from "typebox/value";
|
|
739
|
-
function causeMessage(cause) {
|
|
740
|
-
if (cause instanceof Error) return cause.message;
|
|
741
|
-
if (typeof cause === "string") return cause;
|
|
742
|
-
try {
|
|
743
|
-
return JSON.stringify(cause) ?? String(cause);
|
|
744
|
-
} catch {
|
|
745
|
-
return String(cause);
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
function fail(cause) {
|
|
749
|
-
throw new FixerPacketValidationError(cause);
|
|
750
|
-
}
|
|
751
|
-
function parseFailure(value) {
|
|
752
|
-
if (!Array.isArray(value)) fail(new Error("Fixer prerequisites must be a JSON array"));
|
|
753
|
-
for (const entry of value) {
|
|
754
|
-
if (!isRecord(entry)) {
|
|
755
|
-
fail(new Error("Fixer prerequisite entry must be an object with id and requirement fields"));
|
|
756
|
-
}
|
|
757
|
-
if (typeof entry.id !== "string" || !new RegExp(FIXER_PREREQUISITE_ID_PATTERN).test(entry.id)) {
|
|
758
|
-
fail(new Error(`Fixer prerequisite id violates pattern ${FIXER_PREREQUISITE_ID_PATTERN}`));
|
|
759
|
-
}
|
|
760
|
-
if (typeof entry.requirement !== "string" || !/\S/.test(entry.requirement)) {
|
|
761
|
-
fail(new Error("Fixer prerequisite requirement must be nonblank"));
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
fail(new Error("Fixer prerequisites violate the attachment schema"));
|
|
765
|
-
}
|
|
766
|
-
function validateFixerPrerequisites(value) {
|
|
767
|
-
if (!Value.Check(fixerPrerequisitesSchema, value)) parseFailure(value);
|
|
768
|
-
const entries = value;
|
|
769
|
-
const ids = /* @__PURE__ */ new Set();
|
|
770
|
-
const prerequisites = entries.map((entry) => {
|
|
771
|
-
if (ids.has(entry.id)) {
|
|
772
|
-
fail(new Error(`Fixer prerequisites contain duplicate id: ${entry.id}`));
|
|
773
|
-
}
|
|
774
|
-
ids.add(entry.id);
|
|
775
|
-
return Object.freeze({ id: entry.id, requirement: entry.requirement });
|
|
776
|
-
});
|
|
777
|
-
return Object.freeze(prerequisites);
|
|
778
|
-
}
|
|
779
|
-
function parseFixerPrerequisites(source) {
|
|
780
|
-
let decoded;
|
|
781
|
-
try {
|
|
782
|
-
decoded = JSON.parse(source);
|
|
783
|
-
} catch (error) {
|
|
784
|
-
fail(error);
|
|
785
|
-
}
|
|
786
|
-
return validateFixerPrerequisites(decoded);
|
|
787
|
-
}
|
|
788
|
-
var FIXER_PREREQUISITE_ID_PATTERN, fixerPrerequisiteSchema, fixerPrerequisitesSchema, FixerPacketValidationError;
|
|
789
|
-
var init_fixer_packet = __esm({
|
|
790
|
-
"src/package-contracts/fixer-packet.ts"() {
|
|
791
|
-
"use strict";
|
|
792
|
-
init_unknown_value();
|
|
793
|
-
FIXER_PREREQUISITE_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]*$";
|
|
794
|
-
fixerPrerequisiteSchema = Type8.Object({
|
|
795
|
-
id: Type8.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
|
|
796
|
-
requirement: Type8.String({ pattern: "\\S" })
|
|
797
|
-
});
|
|
798
|
-
fixerPrerequisitesSchema = Type8.Array(fixerPrerequisiteSchema);
|
|
799
|
-
FixerPacketValidationError = class extends Error {
|
|
800
|
-
code = "AK_INVALID_FIX_PACKET";
|
|
801
|
-
constructor(cause) {
|
|
802
|
-
const prefix = "Fixer prerequisites or instructions violate the invocation contract";
|
|
803
|
-
super(
|
|
804
|
-
cause === void 0 ? prefix : `${prefix}: ${causeMessage(cause)}`,
|
|
805
|
-
cause === void 0 ? void 0 : { cause }
|
|
806
|
-
);
|
|
807
|
-
this.name = "FixerPacketValidationError";
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
}
|
|
811
|
-
});
|
|
812
|
-
|
|
813
736
|
// src/package-contracts/worker-output.ts
|
|
814
|
-
import { Type as
|
|
737
|
+
import { Type as Type8 } from "typebox";
|
|
815
738
|
function validateAcceptedCoderDetails(output) {
|
|
816
739
|
return output;
|
|
817
740
|
}
|
|
@@ -824,15 +747,14 @@ var init_worker_output = __esm({
|
|
|
824
747
|
"use strict";
|
|
825
748
|
init_open_tool_schema();
|
|
826
749
|
init_fixer_output();
|
|
827
|
-
init_fixer_packet();
|
|
828
750
|
init_terminating_infrastructure();
|
|
829
751
|
CODER_OUTPUT_TOOL_NAME = "ak_coder_output";
|
|
830
752
|
CODER_STATUS_DESCRIPTION = `planned | completed | refused | partially_completed | unfinished\u3002unfinished\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u3002${PARTIALLY_COMPLETED_DEFINITION}`;
|
|
831
|
-
coderOutputObject =
|
|
832
|
-
status:
|
|
833
|
-
report:
|
|
834
|
-
remainingScope:
|
|
835
|
-
reason:
|
|
753
|
+
coderOutputObject = Type8.Object({
|
|
754
|
+
status: Type8.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
755
|
+
report: Type8.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
756
|
+
remainingScope: Type8.Unknown({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
|
|
757
|
+
reason: Type8.Unknown({
|
|
836
758
|
description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002"
|
|
837
759
|
})
|
|
838
760
|
});
|
|
@@ -850,7 +772,7 @@ var init_canonical_json = __esm({
|
|
|
850
772
|
});
|
|
851
773
|
|
|
852
774
|
// src/doctor-contracts.ts
|
|
853
|
-
import { Type as
|
|
775
|
+
import { Type as Type9 } from "typebox";
|
|
854
776
|
function validateDoctorSubmissionShape(value) {
|
|
855
777
|
return value;
|
|
856
778
|
}
|
|
@@ -876,25 +798,25 @@ var init_doctor_contracts = __esm({
|
|
|
876
798
|
biteNone = "noRealBite";
|
|
877
799
|
DOCTOR_BITE_KINDS = [biteActual, biteNone];
|
|
878
800
|
DOCTOR_STATUS_DESCRIPTION = "completed | refused\u3002completed \u5141\u8BB8\u7A7A findings\uFF1Brefused \u4EC5\u5F53\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD";
|
|
879
|
-
doctorSubmissionObject =
|
|
880
|
-
status:
|
|
881
|
-
case:
|
|
801
|
+
doctorSubmissionObject = Type9.Object({
|
|
802
|
+
status: Type9.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
|
|
803
|
+
case: Type9.Unknown({
|
|
882
804
|
description: "\u7559\u5B58\u592A\u533B\u7F72\u6848\u8EAB\u4EFD\uFF0C\u539F\u6837\u7559\u5B58\uFF08\u5982 issueNumber\u3001runsPath\uFF09\u3002\u673A\u68B0\u5C42\u53E6\u6309\u7ED1\u5B9A run \u6295\u5F71\u6848\u8EAB\u4EFD\uFF0C\u4E0D\u5728\u672C\u5B57\u6BB5\u91CD\u5224\u3002"
|
|
883
805
|
}),
|
|
884
|
-
findings:
|
|
806
|
+
findings: Type9.Unknown({
|
|
885
807
|
description: `\u9010\u6761\u8D44\u4EA7\u89C2\u5BDF\u4E0E\u5904\u65B9\uFF0C\u539F\u6837\u7559\u5B58\u3002\u4E00\u6761\u53EF\u542B targetKey\u3001targetKind\uFF08${DOCTOR_TARGET_KINDS.join(" | ")}\uFF09\u3001observation\u3001evidenceIds\u3001disposition\uFF08${DOCTOR_DISPOSITIONS.join(" | ")}\uFF09\u3001assetEvidence\uFF08targetKey\u3001targetKind\u3001evidenceId\uFF09\u3001guardrails\uFF08reproducibleFailure\u3001owningSeamOrInvariant\u3001deletionOrSimplificationSuffices\uFF0C\u5404\u9879\u53EF\u542B answer\u3001evidenceIds\u3001explanation\uFF09\u3001prescription\uFF08kind \u4E3A ${DOCTOR_PRESCRIPTION_KINDS.join(" | ")}\uFF0C\u53E6\u53EF\u5199 recommendation\u3001necessityExplanation\uFF09\u3001lastRealBite\uFF08kind \u4E3A ${DOCTOR_BITE_KINDS.join(" | ")}\uFF0C\u53E6\u53EF\u5199 targetKey\u3001evidenceId\u3001eligibleEvidenceIds\uFF09\u3002\u4E0D\u8981\u6C42\u4EFB\u4F55\u5904\u65B9\u6216\u53EF\u590D\u7528 finding\uFF1B\u7F3A\u53EF\u590D\u7528\u8D44\u4EA7\u6216 bounded-bite \u8BC1\u636E\u53EA\u6392\u9664\u5BF9\u5E94\u8D44\u4EA7\u5904\u65B9\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002`
|
|
886
808
|
}),
|
|
887
|
-
reason:
|
|
809
|
+
reason: Type9.Unknown({
|
|
888
810
|
description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0\uFF1B\u4EC5 refused \u65F6\u7528\u3002"
|
|
889
811
|
}),
|
|
890
|
-
missingEvidence:
|
|
812
|
+
missingEvidence: Type9.Unknown({
|
|
891
813
|
description: "\u5982\u5B9E\u8BC1\u8BCD\u6240\u9700\u800C\u5C1A\u7F3A\u7684\u8BC1\u636E\uFF0C\u539F\u6837\u7559\u5B58\uFF08\u5982\u6BCF\u9879 need\u3001targetKeys\uFF09\u3002"
|
|
892
814
|
})
|
|
893
815
|
});
|
|
894
816
|
doctorSubmissionSchema = withTerminatingOutputDeclarations(
|
|
895
817
|
openToolObject(doctorSubmissionObject)
|
|
896
818
|
);
|
|
897
|
-
doctorEvidenceReadSchema =
|
|
819
|
+
doctorEvidenceReadSchema = Type9.Object({ evidenceId: Type9.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: Type9.Optional(Type9.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: Type9.Optional(Type9.Integer({ minimum: 1, description: "\u8FD4\u56DE\u5B57\u8282\u6570\uFF08\u65E0\u4E0A\u9650\uFF09" })) }, { additionalProperties: true });
|
|
898
820
|
DoctorEvidenceStore = class {
|
|
899
821
|
constructor(patient) {
|
|
900
822
|
this.patient = patient;
|
|
@@ -963,8 +885,8 @@ var init_exact_utf8 = __esm({
|
|
|
963
885
|
});
|
|
964
886
|
|
|
965
887
|
// src/merger-contracts.ts
|
|
966
|
-
import { Type as
|
|
967
|
-
function
|
|
888
|
+
import { Type as Type10 } from "typebox";
|
|
889
|
+
function fail(message = "Merger input violates its exact contract") {
|
|
968
890
|
throw new MergerInputContractError(message);
|
|
969
891
|
}
|
|
970
892
|
function deepFreeze(value) {
|
|
@@ -975,14 +897,17 @@ function deepFreeze(value) {
|
|
|
975
897
|
return value;
|
|
976
898
|
}
|
|
977
899
|
function readMaterial(value, label) {
|
|
978
|
-
if (!isRecord(value) || typeof value.bytesBase64 !== "string")
|
|
900
|
+
if (!isRecord(value) || typeof value.bytesBase64 !== "string") fail(`Merger ${label} material is malformed`);
|
|
979
901
|
exactUtf8(Buffer.from(value.bytesBase64, "base64"), `Merger ${label} material`);
|
|
980
902
|
return { bytesBase64: value.bytesBase64, sha256: typeof value.sha256 === "string" ? value.sha256 : "" };
|
|
981
903
|
}
|
|
982
904
|
function validateMergerInput(value) {
|
|
983
|
-
if (!isRecord(value) || blank(value.attemptId))
|
|
984
|
-
if (!isRecord(value.materials))
|
|
985
|
-
const materials = {
|
|
905
|
+
if (!isRecord(value) || blank(value.attemptId)) fail("Merger input requires a non-empty attemptId for accounting");
|
|
906
|
+
if (!isRecord(value.materials)) fail("Merger materials are missing");
|
|
907
|
+
const materials = {
|
|
908
|
+
targetIntent: readMaterial(value.materials.targetIntent, "targetIntent"),
|
|
909
|
+
sourceIntent: readMaterial(value.materials.sourceIntent, "sourceIntent")
|
|
910
|
+
};
|
|
986
911
|
const authorizedChecks = Array.isArray(value.authorizedChecks) ? value.authorizedChecks.filter((check) => isRecord(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) : [];
|
|
987
912
|
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 }));
|
|
988
913
|
}
|
|
@@ -994,24 +919,25 @@ var init_merger_contracts = __esm({
|
|
|
994
919
|
init_open_tool_schema();
|
|
995
920
|
init_terminating_infrastructure();
|
|
996
921
|
init_unknown_value();
|
|
997
|
-
materialSchema =
|
|
998
|
-
checkSchema =
|
|
999
|
-
mergerInputSchema =
|
|
1000
|
-
attemptId:
|
|
1001
|
-
targetObjectId:
|
|
1002
|
-
sourceObjectId:
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
922
|
+
materialSchema = Type10.Object({ bytesBase64: Type10.String(), sha256: Type10.String() });
|
|
923
|
+
checkSchema = Type10.Object({ name: Type10.String({ minLength: 1 }), argv: Type10.Array(Type10.String({ minLength: 1 }), { minItems: 1 }) });
|
|
924
|
+
mergerInputSchema = Type10.Object({
|
|
925
|
+
attemptId: Type10.String({ minLength: 1, description: "\u5BF9\u8D26 attempt \u8EAB\u4EFD\uFF08transport\uFF09" }),
|
|
926
|
+
targetObjectId: Type10.String({ description: "\u6750\u6599\uFF1Atarget parent OID\uFF1B\u53EF\u7A7A" }),
|
|
927
|
+
sourceObjectId: Type10.String({ description: "\u6750\u6599\uFF1Asource parent OID\uFF1B\u53EF\u7A7A" }),
|
|
928
|
+
// #1168: task/authority dispatch copies removed; git-fact intents remain.
|
|
929
|
+
materials: Type10.Object({ targetIntent: materialSchema, sourceIntent: materialSchema }),
|
|
930
|
+
expectedConflictPaths: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u5F53\u524D\u672A\u5408\u5E76\u8DEF\u5F84\uFF1B\u53EF\u7A7A" }),
|
|
931
|
+
resolutionScope: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
|
|
932
|
+
authorizedChecks: Type10.Array(checkSchema)
|
|
1007
933
|
});
|
|
1008
934
|
MERGER_STATUS_DESCRIPTION = "completed | escalate";
|
|
1009
|
-
mergerOutputObject =
|
|
1010
|
-
status:
|
|
1011
|
-
attemptId:
|
|
1012
|
-
report:
|
|
1013
|
-
mergeCommitId:
|
|
1014
|
-
diagnosis:
|
|
935
|
+
mergerOutputObject = Type10.Object({
|
|
936
|
+
status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }),
|
|
937
|
+
attemptId: Type10.Unknown({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }),
|
|
938
|
+
report: Type10.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
939
|
+
mergeCommitId: Type10.Unknown({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }),
|
|
940
|
+
diagnosis: Type10.Unknown({
|
|
1015
941
|
description: "\u5408\u5E76\u65E0\u6CD5\u6216\u4E0D\u5E94\u7531\u672C\u5E2D\u5B8C\u6210\u7684\u539F\u56E0\uFF08\u542B\u65E0\u8FDB\u884C\u4E2D\u5408\u5E76\u3001\u65E0\u6D3B\u53EF\u5E72\u3001\u9700\u65B0\u7684\u4EA7\u54C1/\u6743\u529B\u51B3\u5B9A\uFF09"
|
|
1016
942
|
})
|
|
1017
943
|
});
|
|
@@ -1066,7 +992,7 @@ var init_countersign_contracts = __esm({
|
|
|
1066
992
|
});
|
|
1067
993
|
|
|
1068
994
|
// src/gleaner-left-contracts.ts
|
|
1069
|
-
import { Type as
|
|
995
|
+
import { Type as Type11 } from "typebox";
|
|
1070
996
|
var GLEANER_LEFT_OUTPUT_TOOL_NAME, gleanerLeftOutputSchema, GLEANER_LEFT_BASE_FLAG;
|
|
1071
997
|
var init_gleaner_left_contracts = __esm({
|
|
1072
998
|
"src/gleaner-left-contracts.ts"() {
|
|
@@ -1077,11 +1003,11 @@ var init_gleaner_left_contracts = __esm({
|
|
|
1077
1003
|
GLEANER_LEFT_OUTPUT_TOOL_NAME = "ak_gleaner_left_output";
|
|
1078
1004
|
gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
|
|
1079
1005
|
openToolObject(
|
|
1080
|
-
|
|
1081
|
-
status:
|
|
1006
|
+
Type11.Object({
|
|
1007
|
+
status: Type11.Unknown({
|
|
1082
1008
|
description: "completed"
|
|
1083
1009
|
}),
|
|
1084
|
-
findings:
|
|
1010
|
+
findings: Type11.Unknown({
|
|
1085
1011
|
description: "\u5F39\u7AE0\u5217\u8868\uFF1B\u6BCF\u6761\u53EF\u542B pointer\uFF08\u6587\u4EF6/\u884C\u6307\u9488\uFF09\u4E0E statement\uFF08\u7591\u70B9\u9648\u8FF0\uFF09\uFF0C\u539F\u6837\u7559\u5B58\u3002\u7A7A\u5217\u8868\u5408\u6CD5\u5B8C\u5C40\uFF1B\u673A\u5668\u4E0D\u5224\u5F39\u7AE0\u662F\u5426\u6210\u7ACB\u3002"
|
|
1086
1012
|
})
|
|
1087
1013
|
})
|
|
@@ -1128,7 +1054,7 @@ var init_auditor_output = __esm({
|
|
|
1128
1054
|
|
|
1129
1055
|
// src/role-run-placement.ts
|
|
1130
1056
|
import { readdir } from "node:fs/promises";
|
|
1131
|
-
import { basename as basename2, dirname as dirname2, join as join3 } from "node:path";
|
|
1057
|
+
import { basename as basename2, dirname as dirname2, join as join3, resolve as resolve2 } from "node:path";
|
|
1132
1058
|
function formatRunLeaf(runId, role) {
|
|
1133
1059
|
return `${runId}@${role}`;
|
|
1134
1060
|
}
|
|
@@ -1149,6 +1075,11 @@ function sessionFileOf(runDirectory) {
|
|
|
1149
1075
|
function runDirectoryOfSessionFile(sessionFile) {
|
|
1150
1076
|
return dirname2(dirname2(sessionFile));
|
|
1151
1077
|
}
|
|
1078
|
+
function auditorRunDirectory(context) {
|
|
1079
|
+
const sessionFile = context.sessionManager?.getSessionFile?.();
|
|
1080
|
+
if (sessionFile === void 0) return void 0;
|
|
1081
|
+
return resolve2(runDirectoryOfSessionFile(sessionFile));
|
|
1082
|
+
}
|
|
1152
1083
|
function runDirectoryFromSessionDirectory(sessionDirectory) {
|
|
1153
1084
|
return dirname2(sessionDirectory);
|
|
1154
1085
|
}
|
|
@@ -1270,7 +1201,7 @@ var init_run_dossier_files = __esm({
|
|
|
1270
1201
|
|
|
1271
1202
|
// src/activation-ledger-git.ts
|
|
1272
1203
|
import { execFileSync } from "node:child_process";
|
|
1273
|
-
import { basename as basename3, dirname as dirname3, isAbsolute as isAbsolute2, resolve as
|
|
1204
|
+
import { basename as basename3, dirname as dirname3, isAbsolute as isAbsolute2, resolve as resolve3 } from "node:path";
|
|
1274
1205
|
function envWithoutGitDiscovery(base = process.env) {
|
|
1275
1206
|
const env = { ...base, LC_ALL: "C" };
|
|
1276
1207
|
for (const key of GIT_DISCOVERY_ENV_KEYS) {
|
|
@@ -1313,7 +1244,7 @@ function resolveBookKeyFromGit(cwd) {
|
|
|
1313
1244
|
if (commonDir.length === 0) {
|
|
1314
1245
|
throw new Error("git rev-parse --git-common-dir returned an empty path");
|
|
1315
1246
|
}
|
|
1316
|
-
const absoluteCommon = isAbsolute2(commonDir) ? commonDir :
|
|
1247
|
+
const absoluteCommon = isAbsolute2(commonDir) ? commonDir : resolve3(cwd, commonDir);
|
|
1317
1248
|
const hostDirectory = basename3(absoluteCommon) === ".git" ? dirname3(absoluteCommon) : absoluteCommon;
|
|
1318
1249
|
const bookKey = basename3(hostDirectory);
|
|
1319
1250
|
if (bookKey.length === 0 || bookKey === "." || bookKey === "/") {
|
|
@@ -1925,7 +1856,7 @@ var init_ticket_provenance_contracts = __esm({
|
|
|
1925
1856
|
});
|
|
1926
1857
|
|
|
1927
1858
|
// src/diarist-contracts.ts
|
|
1928
|
-
import { Type as
|
|
1859
|
+
import { Type as Type12 } from "typebox";
|
|
1929
1860
|
function projectDiaristSessions(value) {
|
|
1930
1861
|
const raw = value?.sessions;
|
|
1931
1862
|
if (raw === void 0) return [];
|
|
@@ -1958,20 +1889,20 @@ var init_diarist_contracts = __esm({
|
|
|
1958
1889
|
DIARIST_SESSIONS_DESCRIPTION = "\u5BF9\u8BDD\u8FB9\u754C\u3002\u6BCF\u5377\u542B path\uFF08\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84\uFF09\u4E0E ranges\uFF08\u672C\u5377\u672C\u8F6E\u5404\u533A\u95F4\uFF09\u3002\u6BCF\u6BB5\u533A\u95F4\u542B from / to\uFF1B\u8D77\u70B9\u4E0E\u7EC8\u70B9\u5404\u5199 id\uFF08\u539F\u751F id\uFF09\u6216 line\uFF08\u672C\u8F6E\u884C\u53F7\uFF09\uFF0C\u4E8C\u9009\u4E00\u3002\u7A7A\u5217\u8868\uFF1D\u672C\u8F6E\u65E0\u5BF9\u8BDD\u53EF\u5212\u3002\u7AEF\u70B9\u65E0\u6CD5\u6307\u540D\u65F6\u8D70 reask\uFF0C\u4E0D\u4E2D\u6B62\u3002";
|
|
1959
1890
|
diaristOutputSchema = withTerminatingOutputDeclarations(
|
|
1960
1891
|
openToolObject(
|
|
1961
|
-
|
|
1962
|
-
status:
|
|
1892
|
+
Type12.Object({
|
|
1893
|
+
status: Type12.Unknown({
|
|
1963
1894
|
description: "completed | escalate"
|
|
1964
1895
|
}),
|
|
1965
|
-
ticketNumber:
|
|
1966
|
-
|
|
1896
|
+
ticketNumber: Type12.Optional(
|
|
1897
|
+
Type12.Unknown({
|
|
1967
1898
|
description: "\u672C\u5EAD\u5BF9\u8C61\u7968\u53F7\uFF08\u6B63\u6574\u6570\uFF09\u6216 null/\u7701\u7565\uFF1D\u771F\u65E0\u7968\uFF1B\u4E0B\u6E38\u8D70 typed \u952E\uFF1B\u8BA4\u4E0D\u51FA\u7528 status=escalate\uFF0C\u4E0D\u6D17\u6210\u65E0\u5F55\u3002\u673A\u68B0\u5C42\u4E0D\u91CD\u5224\u3002"
|
|
1968
1899
|
})
|
|
1969
1900
|
),
|
|
1970
|
-
reason:
|
|
1901
|
+
reason: Type12.Unknown({
|
|
1971
1902
|
description: "status \u4E3A escalate \u65F6\uFF1A\u8BA4\u4E0D\u51FA\u672C\u5EAD\u5BF9\u8C61\u7684\u539F\u56E0"
|
|
1972
1903
|
}),
|
|
1973
|
-
sessions:
|
|
1974
|
-
ticketSessions:
|
|
1904
|
+
sessions: Type12.Optional(Type12.Unknown({ description: DIARIST_SESSIONS_DESCRIPTION })),
|
|
1905
|
+
ticketSessions: Type12.Unknown({
|
|
1975
1906
|
description: `\u591A\u7968\u5EAD\u9010\u7968\u5BF9\u8BDD\u8FB9\u754C\uFF1B\u6BCF\u7968\u542B ticketNumber\uFF08\u672C\u6761\u8FB9\u754C\u6240\u5F52\u7968\u53F7\uFF0C\u6B63\u6574\u6570\uFF09\u4E0E sessions\uFF08${DIARIST_SESSIONS_DESCRIPTION}\uFF09\u3002\u4E00\u6B21\u4EA4\u5377\u5404\u7968\u5404\u81EA\u5206\u5F55\u3002\u4E0E\u5355\u7968 sessions \u4E8C\u9009\u4E00\u3002`
|
|
1976
1907
|
})
|
|
1977
1908
|
})
|
|
@@ -1981,7 +1912,7 @@ var init_diarist_contracts = __esm({
|
|
|
1981
1912
|
});
|
|
1982
1913
|
|
|
1983
1914
|
// src/secretariat-contracts.ts
|
|
1984
|
-
import { Type as
|
|
1915
|
+
import { Type as Type13 } from "typebox";
|
|
1985
1916
|
var SECRETARIAT_OUTPUT_TOOL_NAME, secretariatVerdictSchema, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY;
|
|
1986
1917
|
var init_secretariat_contracts = __esm({
|
|
1987
1918
|
"src/secretariat-contracts.ts"() {
|
|
@@ -1989,17 +1920,17 @@ var init_secretariat_contracts = __esm({
|
|
|
1989
1920
|
init_terminating_infrastructure();
|
|
1990
1921
|
SECRETARIAT_OUTPUT_TOOL_NAME = "ak_secretariat_output";
|
|
1991
1922
|
secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
1992
|
-
|
|
1923
|
+
Type13.Object(
|
|
1993
1924
|
{
|
|
1994
|
-
secretariatStatus:
|
|
1925
|
+
secretariatStatus: Type13.Unknown({
|
|
1995
1926
|
description: "converged | escalate"
|
|
1996
1927
|
}),
|
|
1997
|
-
ticketNumber:
|
|
1998
|
-
|
|
1928
|
+
ticketNumber: Type13.Optional(
|
|
1929
|
+
Type13.Unknown({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
|
|
1999
1930
|
),
|
|
2000
|
-
note:
|
|
2001
|
-
evidence:
|
|
2002
|
-
decisionGate:
|
|
1931
|
+
note: Type13.Unknown({ description: "\u9644\u6CE8" }),
|
|
1932
|
+
evidence: Type13.Optional(Type13.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
|
|
1933
|
+
decisionGate: Type13.Unknown({
|
|
2003
1934
|
description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u5199 question \u4E0E options\uFF0C\u539F\u6837\u7559\u5B58\u3002"
|
|
2004
1935
|
})
|
|
2005
1936
|
},
|
|
@@ -2307,10 +2238,10 @@ var init_packaged_role_registry = __esm({
|
|
|
2307
2238
|
reportPhase: true
|
|
2308
2239
|
},
|
|
2309
2240
|
boardPlacement: "marshal",
|
|
2241
|
+
/** #1168: dispatch is first message; navigator reads admitted instruction. */
|
|
2242
|
+
navigatorSubject: "public-instruction",
|
|
2310
2243
|
activationFlags: [
|
|
2311
|
-
{ field: "
|
|
2312
|
-
{ field: "phase", flag: "ak-fixer-phase", binds: "phase" },
|
|
2313
|
-
{ field: "prerequisitesPath", flag: "ak-fixer-prerequisites" }
|
|
2244
|
+
{ field: "phase", flag: "ak-fixer-phase", binds: "phase" }
|
|
2314
2245
|
],
|
|
2315
2246
|
activationStage: "load-and-install",
|
|
2316
2247
|
sessionMaterials: [
|
|
@@ -2337,8 +2268,9 @@ var init_packaged_role_registry = __esm({
|
|
|
2337
2268
|
artifactFace: {
|
|
2338
2269
|
reportPhase: true
|
|
2339
2270
|
},
|
|
2271
|
+
/** #1168: dispatch is first message; navigator reads admitted instruction. */
|
|
2272
|
+
navigatorSubject: "public-instruction",
|
|
2340
2273
|
activationFlags: [
|
|
2341
|
-
{ field: "taskPath", flag: "ak-coder-task", binds: "input" },
|
|
2342
2274
|
{ field: "phase", flag: "ak-coder-phase", binds: "phase" }
|
|
2343
2275
|
],
|
|
2344
2276
|
activationStage: "load-and-install",
|
|
@@ -2578,7 +2510,8 @@ var init_packaged_role_registry = __esm({
|
|
|
2578
2510
|
presentSettled: "always",
|
|
2579
2511
|
summonResume: false,
|
|
2580
2512
|
admission: "instruction",
|
|
2581
|
-
|
|
2513
|
+
/** Structured --source-run only; instruction stays opaque caller/peer bytes (#1166). */
|
|
2514
|
+
sameParent: "source-run",
|
|
2582
2515
|
/** Resume restores an optional source-run path onto the admitted face. */
|
|
2583
2516
|
resumeSourcePath: true,
|
|
2584
2517
|
/** 台院 is a review officer and inherits the gatekeeper model. */
|
|
@@ -2591,11 +2524,12 @@ var init_packaged_role_registry = __esm({
|
|
|
2591
2524
|
/** Court reask replaces the initial prompt. */
|
|
2592
2525
|
reaskPrompt: true,
|
|
2593
2526
|
gateStageLabel: "\u53F0\u9662",
|
|
2527
|
+
/** Gate summon binds --source-run; identity is startup material (#1166). */
|
|
2528
|
+
gateSummon: "source-run",
|
|
2594
2529
|
activationFlags: [
|
|
2595
2530
|
{
|
|
2596
2531
|
field: "sourceRun",
|
|
2597
2532
|
from: "sourceRunPath",
|
|
2598
|
-
fallback: "gate-pointer",
|
|
2599
2533
|
flag: "ak-inspector-source-run",
|
|
2600
2534
|
binds: "input"
|
|
2601
2535
|
}
|
|
@@ -2874,12 +2808,12 @@ var init_terminating_tools = __esm({
|
|
|
2874
2808
|
|
|
2875
2809
|
// src/doctor-evidence.ts
|
|
2876
2810
|
import { readdir as readdir2, readFile as readFile3, realpath, stat } from "node:fs/promises";
|
|
2877
|
-
import { dirname as dirname5, relative as relative2, resolve as
|
|
2811
|
+
import { dirname as dirname5, relative as relative2, resolve as resolve4, sep as sep2 } from "node:path";
|
|
2878
2812
|
async function discoverCaseFiles(root) {
|
|
2879
2813
|
const found = [];
|
|
2880
2814
|
async function walk(dir, depth) {
|
|
2881
2815
|
for (const item of await readdir2(dir, { withFileTypes: true })) {
|
|
2882
|
-
const path =
|
|
2816
|
+
const path = resolve4(dir, item.name);
|
|
2883
2817
|
if (item.isDirectory()) {
|
|
2884
2818
|
await walk(path, depth + 1);
|
|
2885
2819
|
} else if (item.isFile() && (item.name.endsWith(".jsonl") && item.name !== "state.jsonl" && !(item.name === "log.jsonl" && depth === 1) || item.name === "log.jsonl" && depth === 1)) found.push(path);
|
|
@@ -2902,7 +2836,7 @@ async function stableRunsIdentity(root) {
|
|
|
2902
2836
|
let cursor = root;
|
|
2903
2837
|
while (true) {
|
|
2904
2838
|
try {
|
|
2905
|
-
const git3 = await stat(
|
|
2839
|
+
const git3 = await stat(resolve4(cursor, ".git"));
|
|
2906
2840
|
if (git3.isDirectory() || git3.isFile()) return relative2(cursor, root).split(sep2).join("/");
|
|
2907
2841
|
} catch (error) {
|
|
2908
2842
|
if (!isMissingPathError(error)) throw error;
|
|
@@ -3042,7 +2976,7 @@ var init_uuidv7 = __esm({
|
|
|
3042
2976
|
});
|
|
3043
2977
|
|
|
3044
2978
|
// src/work-subject-identity.ts
|
|
3045
|
-
import { resolve as
|
|
2979
|
+
import { resolve as resolve5 } from "node:path";
|
|
3046
2980
|
function issueRoot(value) {
|
|
3047
2981
|
const normalized = value.replaceAll("\\", "/");
|
|
3048
2982
|
const marker = ".ak/work/issues/";
|
|
@@ -3052,7 +2986,7 @@ function issueRoot(value) {
|
|
|
3052
2986
|
return issue === void 0 || issue === "" ? void 0 : normalized.slice(0, index + marker.length) + issue;
|
|
3053
2987
|
}
|
|
3054
2988
|
function workIdentityFromCwd(cwd) {
|
|
3055
|
-
const resolvedCwd =
|
|
2989
|
+
const resolvedCwd = resolve5(cwd, ".");
|
|
3056
2990
|
const cwdIssue = issueRoot(resolvedCwd);
|
|
3057
2991
|
if (cwdIssue !== void 0) return cwdIssue;
|
|
3058
2992
|
if (resolvedCwd.includes("/.ak/work/")) return resolvedCwd;
|
|
@@ -3063,11 +2997,11 @@ function isMachineLedgerSessionPath(sessionPath) {
|
|
|
3063
2997
|
}
|
|
3064
2998
|
function subjectPath(sessionDir, cwd = process.cwd()) {
|
|
3065
2999
|
if (sessionDir === "") {
|
|
3066
|
-
return workIdentityFromCwd(cwd) ??
|
|
3000
|
+
return workIdentityFromCwd(cwd) ?? resolve5(cwd, ".ak/work");
|
|
3067
3001
|
}
|
|
3068
|
-
const resolvedSession =
|
|
3002
|
+
const resolvedSession = resolve5(cwd, sessionDir || ".ak/work");
|
|
3069
3003
|
if (isMachineLedgerSessionPath(resolvedSession)) {
|
|
3070
|
-
return workIdentityFromCwd(cwd) ??
|
|
3004
|
+
return workIdentityFromCwd(cwd) ?? resolve5(cwd, ".ak/work");
|
|
3071
3005
|
}
|
|
3072
3006
|
const issue = issueRoot(resolvedSession);
|
|
3073
3007
|
if (issue !== void 0) return issue;
|
|
@@ -4436,7 +4370,7 @@ var init_durable_principal = __esm({
|
|
|
4436
4370
|
});
|
|
4437
4371
|
|
|
4438
4372
|
// src/collector-config.ts
|
|
4439
|
-
function
|
|
4373
|
+
function fail2(message, cause) {
|
|
4440
4374
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
4441
4375
|
}
|
|
4442
4376
|
function conservativeAscii(input) {
|
|
@@ -4447,20 +4381,20 @@ function conservativeAscii(input) {
|
|
|
4447
4381
|
return true;
|
|
4448
4382
|
}
|
|
4449
4383
|
function parseCollectorRepository(raw) {
|
|
4450
|
-
if (typeof raw !== "string" || raw.trim() !== raw || raw.length === 0)
|
|
4451
|
-
if (!conservativeAscii(raw) || raw.includes("://") || /[?#@%\\ ]/.test(raw))
|
|
4384
|
+
if (typeof raw !== "string" || raw.trim() !== raw || raw.length === 0) fail2("Collector repository must be a string owner/repo");
|
|
4385
|
+
if (!conservativeAscii(raw) || raw.includes("://") || /[?#@%\\ ]/.test(raw)) fail2("Collector repository rejects URL syntax and non-identity bytes");
|
|
4452
4386
|
const parts = raw.split("/");
|
|
4453
|
-
if (parts.length !== 2)
|
|
4387
|
+
if (parts.length !== 2) fail2("Collector repository must contain exactly one '/' separating owner and repo");
|
|
4454
4388
|
const [ownerDisplay, repoDisplay] = parts;
|
|
4455
|
-
if (!COLLECTOR_OWNER_PATTERN.test(ownerDisplay) || !COLLECTOR_REPO_PATTERN.test(repoDisplay))
|
|
4389
|
+
if (!COLLECTOR_OWNER_PATTERN.test(ownerDisplay) || !COLLECTOR_REPO_PATTERN.test(repoDisplay)) fail2("Collector repository does not match the conservative owner/repo grammar");
|
|
4456
4390
|
const owner = ownerDisplay.toLowerCase();
|
|
4457
4391
|
const repo = repoDisplay.toLowerCase();
|
|
4458
4392
|
return { display: raw, canonical: `${owner}/${repo}`, owner, repo };
|
|
4459
4393
|
}
|
|
4460
4394
|
function parseCollectorPrNumber(raw) {
|
|
4461
|
-
if (typeof raw !== "string" && typeof raw !== "number")
|
|
4395
|
+
if (typeof raw !== "string" && typeof raw !== "number") fail2("Collector pull request number is required");
|
|
4462
4396
|
const value = parseTicketNumber(raw);
|
|
4463
|
-
if (value === void 0)
|
|
4397
|
+
if (value === void 0) fail2(typeof raw === "string" && !isTicketNumberString(raw) ? "Collector pull request number must be a positive safe integer string" : "Collector pull request number must be a positive safe integer");
|
|
4464
4398
|
return value;
|
|
4465
4399
|
}
|
|
4466
4400
|
var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
|
|
@@ -4473,61 +4407,8 @@ var init_collector_config = __esm({
|
|
|
4473
4407
|
}
|
|
4474
4408
|
});
|
|
4475
4409
|
|
|
4476
|
-
// src/auditor-dossier-tool.ts
|
|
4477
|
-
var auditor_dossier_tool_exports = {};
|
|
4478
|
-
__export(auditor_dossier_tool_exports, {
|
|
4479
|
-
AUDITOR_DOSSIER_TOOL_NAME: () => AUDITOR_DOSSIER_TOOL_NAME,
|
|
4480
|
-
auditorRunDirectory: () => auditorRunDirectory,
|
|
4481
|
-
createAuditorDossierTool: () => createAuditorDossierTool
|
|
4482
|
-
});
|
|
4483
|
-
import { join as join12, resolve as resolve6 } from "node:path";
|
|
4484
|
-
import { Type as Type16 } from "typebox";
|
|
4485
|
-
function auditorRunDirectory(context) {
|
|
4486
|
-
const sessionFile = context.sessionManager?.getSessionFile?.();
|
|
4487
|
-
if (sessionFile === void 0) return void 0;
|
|
4488
|
-
return resolve6(runDirectoryOfSessionFile(sessionFile));
|
|
4489
|
-
}
|
|
4490
|
-
function createAuditorDossierTool(runDirectory) {
|
|
4491
|
-
return {
|
|
4492
|
-
name: AUDITOR_DOSSIER_TOOL_NAME,
|
|
4493
|
-
description: "\u5B9A\u4F4D\u672C\u5BA1\u8BA1\u5E2D\u7ED1\u5B9A\u7684 run \u5377\u5B97\u53CA\u5176\u8BC1\u636E\u5165\u53E3\u3002",
|
|
4494
|
-
// #836 r16 class 3: execute() ignores `_params` entirely — a closed root
|
|
4495
|
-
// only rejects the role for saying more.
|
|
4496
|
-
parameters: Type16.Object({}, { additionalProperties: true }),
|
|
4497
|
-
async execute(_id, _params) {
|
|
4498
|
-
if (runDirectory === void 0) {
|
|
4499
|
-
return {
|
|
4500
|
-
content: [{ type: "text", text: "\u672C\u5BA1\u8BA1\u5E2D\u65E0\u7ED1\u5B9A run \u5377\u5B97\u8BB0\u5F55\u3002" }],
|
|
4501
|
-
details: void 0
|
|
4502
|
-
};
|
|
4503
|
-
}
|
|
4504
|
-
const details = {
|
|
4505
|
-
runDirectory,
|
|
4506
|
-
current: runCurrentPath(runDirectory),
|
|
4507
|
-
parentSessionCandidate: sessionFileOf(runDirectory),
|
|
4508
|
-
attachments: join12(runDirectory, "attachments"),
|
|
4509
|
-
log: join12(runDirectory, RUN_LOG_FILE),
|
|
4510
|
-
history: join12(runDirectory, RUN_HISTORY_FILE)
|
|
4511
|
-
};
|
|
4512
|
-
return {
|
|
4513
|
-
content: [{ type: "text", text: JSON.stringify(details) }],
|
|
4514
|
-
details
|
|
4515
|
-
};
|
|
4516
|
-
}
|
|
4517
|
-
};
|
|
4518
|
-
}
|
|
4519
|
-
var AUDITOR_DOSSIER_TOOL_NAME;
|
|
4520
|
-
var init_auditor_dossier_tool = __esm({
|
|
4521
|
-
"src/auditor-dossier-tool.ts"() {
|
|
4522
|
-
"use strict";
|
|
4523
|
-
init_run_dossier();
|
|
4524
|
-
init_role_run_placement();
|
|
4525
|
-
AUDITOR_DOSSIER_TOOL_NAME = "ak_get_run_dossier";
|
|
4526
|
-
}
|
|
4527
|
-
});
|
|
4528
|
-
|
|
4529
4410
|
// src/collector-tool-schemas.ts
|
|
4530
|
-
import { Type as
|
|
4411
|
+
import { Type as Type15 } from "typebox";
|
|
4531
4412
|
var collectorOutputBaseSchema, collectorOutputArgsSchema;
|
|
4532
4413
|
var init_collector_tool_schemas = __esm({
|
|
4533
4414
|
"src/collector-tool-schemas.ts"() {
|
|
@@ -4535,11 +4416,11 @@ var init_collector_tool_schemas = __esm({
|
|
|
4535
4416
|
init_open_tool_schema();
|
|
4536
4417
|
init_terminating_infrastructure();
|
|
4537
4418
|
collectorOutputBaseSchema = openToolObject(
|
|
4538
|
-
|
|
4539
|
-
groups:
|
|
4419
|
+
Type15.Object({
|
|
4420
|
+
groups: Type15.Unsafe({
|
|
4540
4421
|
description: "\u6309\u673A\u5668\u8EAB\u4EFD\u5F52\u7EC4\u7684\u51FA\u5E2D\u3001\u6750\u6599\u4E0E\u9010\u6761 findings\uFF08LLM \u81EA\u884C\u4ECE\u5BBF\u4E3B CLI \u53D6\u8BC1\u6574\u7406\uFF1B\u4EE3\u7801\u4E0D\u4EE3\u6536\u4E0D\u5F52\u5E76\uFF09\u3002"
|
|
4541
4422
|
}),
|
|
4542
|
-
unfinishedReasons:
|
|
4423
|
+
unfinishedReasons: Type15.Unknown({
|
|
4543
4424
|
description: "\u672A\u5B8C\u6210\u539F\u56E0\uFF1B\u53D6\u8BC1\u53D7\u9650\u65F6\u5982\u5B9E\u62A5\u544A\u3002"
|
|
4544
4425
|
})
|
|
4545
4426
|
})
|
|
@@ -5025,7 +4906,7 @@ var GATE_OFFICER_BY_SUBJECT, GATEKEEPER_TOOL_SPEC;
|
|
|
5025
4906
|
var init_gatekeeper_role = __esm({
|
|
5026
4907
|
"src/gatekeeper-role.ts"() {
|
|
5027
4908
|
"use strict";
|
|
5028
|
-
|
|
4909
|
+
init_role_run_placement();
|
|
5029
4910
|
init_packaged_role_registry();
|
|
5030
4911
|
init_submission_errors();
|
|
5031
4912
|
init_inspector_contracts();
|
|
@@ -5614,7 +5495,7 @@ async function runEngineDetourOnce(input) {
|
|
|
5614
5495
|
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
5615
5496
|
stderr += chunk;
|
|
5616
5497
|
});
|
|
5617
|
-
const
|
|
5498
|
+
const fail3 = (error) => {
|
|
5618
5499
|
if (settled) return;
|
|
5619
5500
|
settled = true;
|
|
5620
5501
|
if (signal !== void 0) {
|
|
@@ -5631,7 +5512,7 @@ async function runEngineDetourOnce(input) {
|
|
|
5631
5512
|
resolve21(result);
|
|
5632
5513
|
};
|
|
5633
5514
|
const onAbort = () => {
|
|
5634
|
-
|
|
5515
|
+
fail3(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
5635
5516
|
try {
|
|
5636
5517
|
child.kill("SIGTERM");
|
|
5637
5518
|
} catch {
|
|
@@ -5644,7 +5525,7 @@ async function runEngineDetourOnce(input) {
|
|
|
5644
5525
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
5645
5526
|
}
|
|
5646
5527
|
}
|
|
5647
|
-
child.on("error", (error) =>
|
|
5528
|
+
child.on("error", (error) => fail3(error));
|
|
5648
5529
|
child.on("close", (code) => {
|
|
5649
5530
|
succeed({ code: code ?? 1, stdout, stderr });
|
|
5650
5531
|
});
|
|
@@ -6624,13 +6505,13 @@ var init_session_dialogue = __esm({
|
|
|
6624
6505
|
|
|
6625
6506
|
// src/ticket-provenance.ts
|
|
6626
6507
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
6627
|
-
import { join as
|
|
6508
|
+
import { join as join12, resolve as resolve9 } from "node:path";
|
|
6628
6509
|
function dialogueSessionSourceRoots(home) {
|
|
6629
6510
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
6630
6511
|
return [
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6512
|
+
join12(machineHome, ".claude", "projects"),
|
|
6513
|
+
join12(machineHome, ".codex", "sessions"),
|
|
6514
|
+
join12(machineHome, ".pi", "agent", "sessions")
|
|
6634
6515
|
];
|
|
6635
6516
|
}
|
|
6636
6517
|
function isLedgerRoleSessionFile(absolute, home) {
|
|
@@ -6671,7 +6552,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
|
|
|
6671
6552
|
const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
|
|
6672
6553
|
let history;
|
|
6673
6554
|
try {
|
|
6674
|
-
history = await readFile8(
|
|
6555
|
+
history = await readFile8(join12(runDirectory, RUN_HISTORY_FILE), "utf8");
|
|
6675
6556
|
} catch (error) {
|
|
6676
6557
|
if (errnoCode(error) === "ENOENT") return;
|
|
6677
6558
|
throw error;
|
|
@@ -6863,7 +6744,7 @@ var init_ticket_provenance = __esm({
|
|
|
6863
6744
|
});
|
|
6864
6745
|
|
|
6865
6746
|
// src/notary-source-run.ts
|
|
6866
|
-
import { dirname as dirname10, isAbsolute as isAbsolute4, join as
|
|
6747
|
+
import { dirname as dirname10, isAbsolute as isAbsolute4, join as join13, resolve as resolve10, basename as basename8 } from "node:path";
|
|
6867
6748
|
import { lstat, realpath as realpath2 } from "node:fs/promises";
|
|
6868
6749
|
async function readRetainedIdentity(runDirectory) {
|
|
6869
6750
|
try {
|
|
@@ -6915,11 +6796,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
6915
6796
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
6916
6797
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
6917
6798
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
6918
|
-
const bookRunsRoot =
|
|
6799
|
+
const bookRunsRoot = join13(bookDirectory, "runs");
|
|
6919
6800
|
let candidate;
|
|
6920
6801
|
const bare = parseRunLeaf(raw);
|
|
6921
6802
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
6922
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
6803
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join13(bookRunsRoot, formatRunLeaf(bare.runId, bare.role));
|
|
6923
6804
|
} else {
|
|
6924
6805
|
candidate = isAbsolute4(raw) ? raw : resolve10(options.projectRoot, raw);
|
|
6925
6806
|
const identity2 = parseRunLeaf(basename8(candidate));
|
|
@@ -7279,7 +7160,7 @@ function renderHumanOwnerOptionLines(owner, locale = "en") {
|
|
|
7279
7160
|
}
|
|
7280
7161
|
return lines;
|
|
7281
7162
|
}
|
|
7282
|
-
var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, SHARED_PHASE_SEMANTICS, GLEANER_LEFT_OPTIONS, AUDITOR_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, SEAT_OPTION_ROWS, PUBLIC_OPTION_TABLE, PUBLIC_ROLE_OPTION_OWNERS, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
|
|
7163
|
+
var ANALYST_REQUIRE_ANY_OF, ANALYST_DEFAULT_MODE, REJECTED_PUBLIC_SPELLINGS, GLOBAL_OPTIONS, SHARED_PROJECT_SEMANTICS, SHARED_ATTACH_SEMANTICS, SHARED_PHASE_SEMANTICS, GLEANER_LEFT_OPTIONS, AUDITOR_OPTIONS, CODER_OPTIONS, FIXER_OPTIONS, REVIEWER_OPTIONS, COLLECTOR_OPTIONS, DOCTOR_OPTIONS, NOTARY_OPTIONS, INSPECTOR_OPTIONS, MERGER_OPTIONS, ANALYST_OPTIONS, SEAT_OPTION_ROWS, PUBLIC_OPTION_TABLE, PUBLIC_ROLE_OPTION_OWNERS, PUBLIC_NAVIGATOR_HELP_NOTE, TOP_LEVEL_HELP, ROLE_COMMAND_HELP, SUPPORT_COMMAND_HELP, PUBLIC_COMMAND_HELP;
|
|
7283
7164
|
var init_option_definitions = __esm({
|
|
7284
7165
|
"src/public-cli/option-definitions.ts"() {
|
|
7285
7166
|
"use strict";
|
|
@@ -7500,8 +7381,8 @@ var init_option_definitions = __esm({
|
|
|
7500
7381
|
repeatable: false,
|
|
7501
7382
|
form: "option",
|
|
7502
7383
|
description: {
|
|
7503
|
-
en: "
|
|
7504
|
-
zh: "
|
|
7384
|
+
en: "Caller prerequisites path passed as-is to the role. Package does not read, copy, or validate; use an absolute path when cwd differs from --project.",
|
|
7385
|
+
zh: "\u8C03\u7528\u65B9\u524D\u7F6E\u6761\u4EF6\u6587\u4EF6\u8DEF\u5F84\u539F\u6837\u9012\u7ED9\u8859\u95E8\u3002\u5305\u4E0D\u8BFB\u3001\u4E0D\u590D\u5236\u3001\u4E0D\u6821\u9A8C\uFF1B\u8C03\u7528\u65B9\u5F53\u524D\u76EE\u5F55\u4E0E --project \u4E0D\u540C\u65F6\u8BF7\u7ED9\u7EDD\u5BF9\u8DEF\u5F84\u3002"
|
|
7505
7386
|
}
|
|
7506
7387
|
}
|
|
7507
7388
|
];
|
|
@@ -7644,6 +7525,23 @@ var init_option_definitions = __esm({
|
|
|
7644
7525
|
}
|
|
7645
7526
|
}
|
|
7646
7527
|
];
|
|
7528
|
+
INSPECTOR_OPTIONS = [
|
|
7529
|
+
...projectAndAttach("inspector"),
|
|
7530
|
+
{
|
|
7531
|
+
id: "source-run",
|
|
7532
|
+
owner: "inspector",
|
|
7533
|
+
canonical: "--source-run",
|
|
7534
|
+
aliases: [],
|
|
7535
|
+
valueMetavar: "runId@role|path",
|
|
7536
|
+
required: false,
|
|
7537
|
+
repeatable: false,
|
|
7538
|
+
form: "option",
|
|
7539
|
+
description: {
|
|
7540
|
+
en: "Optional audited source-run locator (runId@role or path). Gate summons always supply it; identity rides startup materials.",
|
|
7541
|
+
zh: "\u53EF\u9009\u88AB\u5BA1\u817F\u5B9A\u4F4D\u7B26\uFF08runId@role \u6216\u8DEF\u5F84\uFF09\u3002\u95F8\u4F20\u53EC\u5FC5\u5E26\uFF1B\u8EAB\u4EFD\u5728\u542F\u52A8\u6750\u6599\u91CC\u3002"
|
|
7542
|
+
}
|
|
7543
|
+
}
|
|
7544
|
+
];
|
|
7647
7545
|
MERGER_OPTIONS = [
|
|
7648
7546
|
// Merger project face: worktree whose Git materials are handed to the role.
|
|
7649
7547
|
{
|
|
@@ -7802,7 +7700,8 @@ var init_option_definitions = __esm({
|
|
|
7802
7700
|
doctor: DOCTOR_OPTIONS,
|
|
7803
7701
|
merger: MERGER_OPTIONS,
|
|
7804
7702
|
notary: NOTARY_OPTIONS,
|
|
7805
|
-
auditor: AUDITOR_OPTIONS
|
|
7703
|
+
auditor: AUDITOR_OPTIONS,
|
|
7704
|
+
inspector: INSPECTOR_OPTIONS
|
|
7806
7705
|
};
|
|
7807
7706
|
PUBLIC_OPTION_TABLE = publicOptionTable();
|
|
7808
7707
|
PUBLIC_ROLE_OPTION_OWNERS = [
|
|
@@ -8056,7 +7955,7 @@ import {
|
|
|
8056
7955
|
rename as rename2,
|
|
8057
7956
|
writeFile as writeFile3
|
|
8058
7957
|
} from "node:fs/promises";
|
|
8059
|
-
import { dirname as dirname11, isAbsolute as isAbsolute5, join as
|
|
7958
|
+
import { dirname as dirname11, isAbsolute as isAbsolute5, join as join14, resolve as resolve11 } from "node:path";
|
|
8060
7959
|
function normalizeAdmittedAttachment(raw) {
|
|
8061
7960
|
if (typeof raw !== "object" || raw === null) return void 0;
|
|
8062
7961
|
const record = raw;
|
|
@@ -8209,7 +8108,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8209
8108
|
const childRunIds = readPageSync(oldRunDirectory, "admitted")?.childDiaristRunIds;
|
|
8210
8109
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
8211
8110
|
if (typeof childRunId !== "string") continue;
|
|
8212
|
-
const childDirectory =
|
|
8111
|
+
const childDirectory = join14(dirname11(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
|
|
8213
8112
|
if (!existsSync5(childDirectory)) continue;
|
|
8214
8113
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
8215
8114
|
bookKey: admitted.bookKey,
|
|
@@ -8242,9 +8141,6 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
8242
8141
|
admittedRecord,
|
|
8243
8142
|
[
|
|
8244
8143
|
"runDirectory",
|
|
8245
|
-
"taskPath",
|
|
8246
|
-
"packetPath",
|
|
8247
|
-
"prerequisitesPath",
|
|
8248
8144
|
"mergerInputPath"
|
|
8249
8145
|
],
|
|
8250
8146
|
oldRunDirectory,
|
|
@@ -8286,7 +8182,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
8286
8182
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
8287
8183
|
const rolePackageRoot = packageRoot;
|
|
8288
8184
|
const raw = JSON.parse(
|
|
8289
|
-
await readFile9(
|
|
8185
|
+
await readFile9(join14(rolePackageRoot, "package.json"), "utf8")
|
|
8290
8186
|
);
|
|
8291
8187
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
8292
8188
|
throw new Error(
|
|
@@ -8377,7 +8273,7 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
8377
8273
|
fields.authorityRefs.push(requireAuthorityRef(value));
|
|
8378
8274
|
return;
|
|
8379
8275
|
case "prerequisites":
|
|
8380
|
-
fields.prerequisitesPath =
|
|
8276
|
+
fields.prerequisitesPath = requireProvidedOptionValue(taken.def.canonical, value);
|
|
8381
8277
|
return;
|
|
8382
8278
|
case "pr":
|
|
8383
8279
|
fields.prNumber = parsePositivePrOption(value);
|
|
@@ -8627,11 +8523,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8627
8523
|
instruction,
|
|
8628
8524
|
attachmentPaths,
|
|
8629
8525
|
...project,
|
|
8630
|
-
placedFields: async (
|
|
8631
|
-
const taskPath = join15(placed.runDirectory, "task.md");
|
|
8632
|
-
await writeFile3(taskPath, instruction, "utf8");
|
|
8633
|
-
return { phase, taskPath };
|
|
8634
|
-
}
|
|
8526
|
+
placedFields: async () => ({ phase })
|
|
8635
8527
|
});
|
|
8636
8528
|
}
|
|
8637
8529
|
case "worker-packet": {
|
|
@@ -8642,52 +8534,15 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8642
8534
|
if (!record.phases.some((item) => item === phase)) {
|
|
8643
8535
|
throw new CliUsageError("fixer phase must be plan or apply");
|
|
8644
8536
|
}
|
|
8645
|
-
let prerequisites = Object.freeze([]);
|
|
8646
|
-
let prerequisitesSource;
|
|
8647
|
-
if (parsed.prerequisitesPath !== void 0) {
|
|
8648
|
-
const absolutePrereq = isAbsolute5(parsed.prerequisitesPath) ? parsed.prerequisitesPath : resolve11(parsed.prerequisitesPath);
|
|
8649
|
-
try {
|
|
8650
|
-
prerequisitesSource = await readFile9(absolutePrereq, "utf8");
|
|
8651
|
-
} catch (error) {
|
|
8652
|
-
throw new CliUsageError(
|
|
8653
|
-
`fixer prerequisites path is unreadable: ${parsed.prerequisitesPath}`,
|
|
8654
|
-
{ cause: error }
|
|
8655
|
-
);
|
|
8656
|
-
}
|
|
8657
|
-
try {
|
|
8658
|
-
prerequisites = parseFixerPrerequisites(prerequisitesSource);
|
|
8659
|
-
} catch (error) {
|
|
8660
|
-
if (error instanceof FixerPacketValidationError) {
|
|
8661
|
-
throw new CliUsageError(error.message, { cause: error });
|
|
8662
|
-
}
|
|
8663
|
-
throw error;
|
|
8664
|
-
}
|
|
8665
|
-
}
|
|
8666
8537
|
return admitStandardMaterialInvocation("fixer", {
|
|
8667
8538
|
...shared,
|
|
8668
8539
|
instruction,
|
|
8669
8540
|
attachmentPaths,
|
|
8670
8541
|
...project,
|
|
8671
|
-
placedFields: async (
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
await writeFile3(
|
|
8676
|
-
prerequisitesPath,
|
|
8677
|
-
`${JSON.stringify(prerequisites, null, 2)}
|
|
8678
|
-
`,
|
|
8679
|
-
"utf8"
|
|
8680
|
-
);
|
|
8681
|
-
}
|
|
8682
|
-
const packetPath = join15(placed.runDirectory, "fix-packet.md");
|
|
8683
|
-
await writeFile3(packetPath, instruction, "utf8");
|
|
8684
|
-
return {
|
|
8685
|
-
phase,
|
|
8686
|
-
packetPath,
|
|
8687
|
-
prerequisites,
|
|
8688
|
-
...prerequisitesPath === void 0 ? {} : { prerequisitesPath }
|
|
8689
|
-
};
|
|
8690
|
-
}
|
|
8542
|
+
placedFields: async () => ({
|
|
8543
|
+
phase,
|
|
8544
|
+
...parsed.prerequisitesPath === void 0 ? {} : { prerequisitesPath: parsed.prerequisitesPath }
|
|
8545
|
+
})
|
|
8691
8546
|
});
|
|
8692
8547
|
}
|
|
8693
8548
|
case "collect-target": {
|
|
@@ -8874,8 +8729,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8874
8729
|
targetObjectId: derived.targetObjectId,
|
|
8875
8730
|
sourceObjectId: derived.sourceObjectId,
|
|
8876
8731
|
materials: {
|
|
8877
|
-
task: mergerMaterialFromUtf8(instruction),
|
|
8878
|
-
authority: mergerMaterialFromUtf8(instruction),
|
|
8879
8732
|
targetIntent: mergerMaterialFromUtf8(
|
|
8880
8733
|
`Investigate primary sources for target parent ${targetLabel}. Do not invent intent.`
|
|
8881
8734
|
),
|
|
@@ -8887,7 +8740,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8887
8740
|
resolutionScope: [...derived.resolutionScope],
|
|
8888
8741
|
authorizedChecks: []
|
|
8889
8742
|
});
|
|
8890
|
-
const mergerInputPath =
|
|
8743
|
+
const mergerInputPath = join14(placed.runDirectory, "merger-input.json");
|
|
8891
8744
|
await writeFile3(
|
|
8892
8745
|
mergerInputPath,
|
|
8893
8746
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -9025,51 +8878,50 @@ function admittedTransportPromptKind(admitted) {
|
|
|
9025
8878
|
if (record !== void 0 && "transportPrompt" in record) return record.transportPrompt;
|
|
9026
8879
|
return "instruction";
|
|
9027
8880
|
}
|
|
8881
|
+
function appendCallerFileFlagPaths(body, attachments, requestManifestPath, prerequisitesPath) {
|
|
8882
|
+
const flaggedPaths = [
|
|
8883
|
+
...attachments.map((attachment) => `--attach ${attachment.path}`),
|
|
8884
|
+
...requestManifestPath === void 0 ? [] : [`--request-manifest ${requestManifestPath}`],
|
|
8885
|
+
...prerequisitesPath === void 0 ? [] : [`--prerequisites ${prerequisitesPath}`]
|
|
8886
|
+
];
|
|
8887
|
+
if (flaggedPaths.length === 0) return body;
|
|
8888
|
+
return [body, "", ...flaggedPaths].join("\n");
|
|
8889
|
+
}
|
|
9028
8890
|
function buildInstructionTransportPrompt(admitted) {
|
|
9029
8891
|
const kind = admittedTransportPromptKind(admitted);
|
|
9030
8892
|
if (kind === "fixed-kickoff") {
|
|
9031
|
-
|
|
9032
|
-
throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
|
|
9033
|
-
}
|
|
9034
|
-
return admitted.sourceRunPath;
|
|
8893
|
+
return "";
|
|
9035
8894
|
}
|
|
9036
8895
|
if (kind === "baseline") {
|
|
9037
8896
|
if (admitted.baseRevision === void 0) {
|
|
9038
8897
|
throw new Error("baseline transport prompt is missing the bound revision");
|
|
9039
8898
|
}
|
|
9040
|
-
const
|
|
8899
|
+
const lines = [admitted.baseRevision];
|
|
9041
8900
|
if (admitted.instruction.length > 0) {
|
|
9042
|
-
|
|
8901
|
+
lines.push("", admitted.instruction);
|
|
9043
8902
|
}
|
|
9044
|
-
return
|
|
8903
|
+
return lines.join("\n");
|
|
9045
8904
|
}
|
|
9046
8905
|
if (kind === "skill-args") {
|
|
9047
8906
|
if (admitted.baseRevision === void 0 || admitted.lens === void 0 || admitted.authorityRefs === void 0) {
|
|
9048
8907
|
throw new Error("skill-args transport prompt is missing frozen skill args");
|
|
9049
8908
|
}
|
|
9050
|
-
const
|
|
8909
|
+
const lines = [buildReviewerSkillArgProjection({
|
|
9051
8910
|
baseRevision: admitted.baseRevision,
|
|
9052
8911
|
lens: admitted.lens,
|
|
9053
8912
|
authorityRefs: admitted.authorityRefs
|
|
9054
8913
|
})];
|
|
9055
8914
|
if (admitted.instruction.length > 0) {
|
|
9056
|
-
|
|
9057
|
-
}
|
|
9058
|
-
return lines2.join("\n");
|
|
9059
|
-
}
|
|
9060
|
-
const lines = [admitted.instruction];
|
|
9061
|
-
const flaggedPaths = [
|
|
9062
|
-
...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
|
|
9063
|
-
...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`]
|
|
9064
|
-
];
|
|
9065
|
-
if (flaggedPaths.length > 0) {
|
|
9066
|
-
lines.push("");
|
|
9067
|
-
lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
|
|
9068
|
-
for (const entry of flaggedPaths) {
|
|
9069
|
-
lines.push(`- ${entry}`);
|
|
8915
|
+
lines.push("", admitted.instruction);
|
|
9070
8916
|
}
|
|
8917
|
+
return lines.join("\n");
|
|
9071
8918
|
}
|
|
9072
|
-
return
|
|
8919
|
+
return appendCallerFileFlagPaths(
|
|
8920
|
+
admitted.instruction,
|
|
8921
|
+
admitted.attachments,
|
|
8922
|
+
admitted.requestManifestPath,
|
|
8923
|
+
admitted.prerequisitesPath
|
|
8924
|
+
);
|
|
9073
8925
|
}
|
|
9074
8926
|
async function materializeCountersignInvocation(admitted, options) {
|
|
9075
8927
|
const placed = await placeRoleAdmission({
|
|
@@ -9179,7 +9031,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
9179
9031
|
}
|
|
9180
9032
|
async function resolveDoctorCaseRunsPath(options) {
|
|
9181
9033
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
9182
|
-
const defaultRuns =
|
|
9034
|
+
const defaultRuns = join14(
|
|
9183
9035
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
9184
9036
|
String(options.issueNumber),
|
|
9185
9037
|
"runs"
|
|
@@ -9460,7 +9312,6 @@ var init_invocation = __esm({
|
|
|
9460
9312
|
init_doctor_evidence();
|
|
9461
9313
|
init_collector_config();
|
|
9462
9314
|
init_github_remote();
|
|
9463
|
-
init_fixer_packet();
|
|
9464
9315
|
init_merger_git_state();
|
|
9465
9316
|
init_merger_contracts();
|
|
9466
9317
|
init_sha256();
|
|
@@ -10595,7 +10446,7 @@ var init_settlement = __esm({
|
|
|
10595
10446
|
});
|
|
10596
10447
|
|
|
10597
10448
|
// src/session-identity.ts
|
|
10598
|
-
import { dirname as dirname12, join as
|
|
10449
|
+
import { dirname as dirname12, join as join15 } from "node:path";
|
|
10599
10450
|
function createSessionIdentityAuthority(authority, hostName) {
|
|
10600
10451
|
const runDirectoryOf = (principal) => dirname12(authority.decode(principal).sessionDirectory);
|
|
10601
10452
|
return {
|
|
@@ -10604,7 +10455,7 @@ function createSessionIdentityAuthority(authority, hostName) {
|
|
|
10604
10455
|
},
|
|
10605
10456
|
async load(principal) {
|
|
10606
10457
|
const runDirectory = runDirectoryOf(principal);
|
|
10607
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
10458
|
+
const { records, diagnostics } = await readSitianRecords(join15(runDirectory, RUN_STATE_FILE));
|
|
10608
10459
|
if (diagnostics.length > 0) {
|
|
10609
10460
|
throw new Error(
|
|
10610
10461
|
`${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
|
|
@@ -10674,12 +10525,12 @@ __export(role_turn_host_exports, {
|
|
|
10674
10525
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
10675
10526
|
import { constants } from "node:fs";
|
|
10676
10527
|
import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
|
|
10677
|
-
import { delimiter, dirname as dirname13, isAbsolute as isAbsolute6, join as
|
|
10528
|
+
import { delimiter, dirname as dirname13, isAbsolute as isAbsolute6, join as join16, resolve as resolve12 } from "node:path";
|
|
10678
10529
|
import { platform } from "node:process";
|
|
10679
10530
|
import { promisify as promisify2 } from "node:util";
|
|
10680
10531
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
10681
10532
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
10682
|
-
return
|
|
10533
|
+
return join16(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
10683
10534
|
}
|
|
10684
10535
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
10685
10536
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -10920,6 +10771,11 @@ function createPiRoleTurnHost(config) {
|
|
|
10920
10771
|
if (typeof process.env.AK_ROLE_AUDITOR_SUBJECT === "string" && process.env.AK_ROLE_AUDITOR_SUBJECT.trim() !== "") {
|
|
10921
10772
|
env.AK_ROLE_AUDITOR_SUBJECT = process.env.AK_ROLE_AUDITOR_SUBJECT;
|
|
10922
10773
|
}
|
|
10774
|
+
if (typeof request.navigatorWorkContextPath === "string" && request.navigatorWorkContextPath.trim() !== "") {
|
|
10775
|
+
env.AK_ROLE_NAVIGATOR_WORK_CONTEXT = request.navigatorWorkContextPath.trim();
|
|
10776
|
+
} else {
|
|
10777
|
+
delete env.AK_ROLE_NAVIGATOR_WORK_CONTEXT;
|
|
10778
|
+
}
|
|
10923
10779
|
if (config.recordLaunchedRolePackageIdentity !== void 0 && config.observeLaunchedRolePackageIdentity !== void 0) {
|
|
10924
10780
|
await config.recordLaunchedRolePackageIdentity(
|
|
10925
10781
|
request.runDirectory,
|
|
@@ -11042,15 +10898,15 @@ var init_role_turn_host = __esm({
|
|
|
11042
10898
|
|
|
11043
10899
|
// src/public-cli/host-providers.ts
|
|
11044
10900
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
11045
|
-
import { join as
|
|
10901
|
+
import { join as join17 } from "node:path";
|
|
11046
10902
|
function hostProvidersPath(home) {
|
|
11047
10903
|
if (typeof home !== "string" || home.trim() === "") {
|
|
11048
10904
|
throw new Error("home must be explicitly provided");
|
|
11049
10905
|
}
|
|
11050
|
-
return
|
|
10906
|
+
return join17(home, ".ak-roles", "host-providers.json");
|
|
11051
10907
|
}
|
|
11052
10908
|
function hermesProviderModelsCachePath(home) {
|
|
11053
|
-
return
|
|
10909
|
+
return join17(home, ".hermes", "provider_models_cache.json");
|
|
11054
10910
|
}
|
|
11055
10911
|
function parseHostProvidersTable(value) {
|
|
11056
10912
|
if (!isRecord(value)) {
|
|
@@ -11201,15 +11057,15 @@ var init_host_providers = __esm({
|
|
|
11201
11057
|
|
|
11202
11058
|
// src/public-cli/load-production-acp-host.ts
|
|
11203
11059
|
import { existsSync as existsSync6 } from "node:fs";
|
|
11204
|
-
import { join as
|
|
11060
|
+
import { join as join18 } from "node:path";
|
|
11205
11061
|
import { pathToFileURL } from "node:url";
|
|
11206
11062
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
11207
11063
|
const description = lookupHostDescription(host);
|
|
11208
11064
|
if (description === void 0) {
|
|
11209
11065
|
throw new Error(`unregistered host: ${host}`);
|
|
11210
11066
|
}
|
|
11211
|
-
const built =
|
|
11212
|
-
const source =
|
|
11067
|
+
const built = join18(packageRoot, "dist/acp-host/production-host.js");
|
|
11068
|
+
const source = join18(packageRoot, "src/acp-host/production-host.ts");
|
|
11213
11069
|
const target = existsSync6(built) ? built : source;
|
|
11214
11070
|
const href = pathToFileURL(target).href;
|
|
11215
11071
|
const mod = await import(href);
|
|
@@ -11225,15 +11081,15 @@ var init_load_production_acp_host = __esm({
|
|
|
11225
11081
|
|
|
11226
11082
|
// src/public-cli/load-production-headless-host.ts
|
|
11227
11083
|
import { existsSync as existsSync7 } from "node:fs";
|
|
11228
|
-
import { join as
|
|
11084
|
+
import { join as join19 } from "node:path";
|
|
11229
11085
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
11230
11086
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
11231
11087
|
const description = lookupHeadlessHostDescription(host);
|
|
11232
11088
|
if (description === void 0) {
|
|
11233
11089
|
throw new Error(`unregistered headless host: ${host}`);
|
|
11234
11090
|
}
|
|
11235
|
-
const built =
|
|
11236
|
-
const source =
|
|
11091
|
+
const built = join19(packageRoot, "dist/headless-host/production-host.js");
|
|
11092
|
+
const source = join19(packageRoot, "src/headless-host/production-host.ts");
|
|
11237
11093
|
const target = existsSync7(built) ? built : source;
|
|
11238
11094
|
const href = pathToFileURL2(target).href;
|
|
11239
11095
|
const mod = await import(href);
|
|
@@ -11401,7 +11257,7 @@ var init_role_seat_runtime = __esm({
|
|
|
11401
11257
|
});
|
|
11402
11258
|
|
|
11403
11259
|
// src/archivist-record-pointer.ts
|
|
11404
|
-
import { basename as basename9, join as
|
|
11260
|
+
import { basename as basename9, join as join20 } from "node:path";
|
|
11405
11261
|
function bookDirectOfficerRunPointer(options) {
|
|
11406
11262
|
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
11407
11263
|
const pointer = {
|
|
@@ -11450,7 +11306,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
11450
11306
|
};
|
|
11451
11307
|
}
|
|
11452
11308
|
async function readBookedOfficerPointers(parentRunDirectory) {
|
|
11453
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
11309
|
+
const { records, diagnostics } = await readSitianRecords(join20(parentRunDirectory, RUN_HISTORY_FILE));
|
|
11454
11310
|
if (diagnostics.length > 0) {
|
|
11455
11311
|
throw new Error(
|
|
11456
11312
|
`${RUN_HISTORY_FILE} has ${diagnostics.length} malformed row(s); officer pointers unreadable: ${parentRunDirectory}`
|
|
@@ -11514,7 +11370,7 @@ function createPiDoctorAuditor() {
|
|
|
11514
11370
|
var init_doctor_auditor = __esm({
|
|
11515
11371
|
"src/doctor-auditor.ts"() {
|
|
11516
11372
|
"use strict";
|
|
11517
|
-
|
|
11373
|
+
init_role_run_placement();
|
|
11518
11374
|
init_compliance_transport();
|
|
11519
11375
|
init_dossier_resolution();
|
|
11520
11376
|
init_doctor_contracts();
|
|
@@ -11789,12 +11645,12 @@ var init_submission_gate = __esm({
|
|
|
11789
11645
|
// src/session-opening-materials.ts
|
|
11790
11646
|
import { existsSync as existsSync8 } from "node:fs";
|
|
11791
11647
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
11792
|
-
import { dirname as dirname14, join as
|
|
11648
|
+
import { dirname as dirname14, join as join21 } from "node:path";
|
|
11793
11649
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11794
11650
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
11795
11651
|
let dir = dirname14(fileURLToPath(moduleUrl));
|
|
11796
11652
|
for (let i = 0; i < 8; i += 1) {
|
|
11797
|
-
if (existsSync8(
|
|
11653
|
+
if (existsSync8(join21(dir, "package.json")) && existsSync8(join21(dir, "souls"))) {
|
|
11798
11654
|
return dir;
|
|
11799
11655
|
}
|
|
11800
11656
|
const parent = dirname14(dir);
|
|
@@ -11939,16 +11795,16 @@ var init_auditor_soul = __esm({
|
|
|
11939
11795
|
// src/public-cli/machine-method-skills.ts
|
|
11940
11796
|
import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
|
|
11941
11797
|
import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
11942
|
-
import { join as
|
|
11798
|
+
import { join as join23 } from "node:path";
|
|
11943
11799
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
11944
11800
|
function skillRoot(home) {
|
|
11945
|
-
return
|
|
11801
|
+
return join23(home, ".agents/skills");
|
|
11946
11802
|
}
|
|
11947
11803
|
function installedMethodSkillPath(home, name) {
|
|
11948
11804
|
return installedSkillPath(skillRoot(home), name);
|
|
11949
11805
|
}
|
|
11950
11806
|
function installedSkillPath(root, name) {
|
|
11951
|
-
const path =
|
|
11807
|
+
const path = join23(root, name, "SKILL.md");
|
|
11952
11808
|
try {
|
|
11953
11809
|
if (!statSync5(path).isFile()) return void 0;
|
|
11954
11810
|
accessSync(path, constants2.R_OK);
|
|
@@ -11961,9 +11817,9 @@ function installedSkillPath(root, name) {
|
|
|
11961
11817
|
}
|
|
11962
11818
|
function linkedSkillRoot(home, host) {
|
|
11963
11819
|
if (host === "claude" || host === "claude-code") {
|
|
11964
|
-
return
|
|
11820
|
+
return join23(process.env.CLAUDE_CONFIG_DIR?.trim() || join23(home, ".claude"), "skills");
|
|
11965
11821
|
}
|
|
11966
|
-
if (host === "hermes") return
|
|
11822
|
+
if (host === "hermes") return join23(home, ".hermes/skills");
|
|
11967
11823
|
return void 0;
|
|
11968
11824
|
}
|
|
11969
11825
|
async function occupied(path) {
|
|
@@ -12020,7 +11876,7 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12020
11876
|
const missingBySource = /* @__PURE__ */ new Map();
|
|
12021
11877
|
let unsourced = false;
|
|
12022
11878
|
for (const name of packagedMethodSkillNames()) {
|
|
12023
|
-
const path =
|
|
11879
|
+
const path = join23(canonical, name);
|
|
12024
11880
|
if (await occupied(path)) {
|
|
12025
11881
|
warnOccupied(path, stdout);
|
|
12026
11882
|
continue;
|
|
@@ -12050,9 +11906,9 @@ async function runMachineSkillSetup(home, stdout) {
|
|
|
12050
11906
|
throw error;
|
|
12051
11907
|
}
|
|
12052
11908
|
for (const name of packagedMethodSkillNames()) {
|
|
12053
|
-
const target =
|
|
11909
|
+
const target = join23(canonical, name);
|
|
12054
11910
|
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
12055
|
-
const link =
|
|
11911
|
+
const link = join23(root, name);
|
|
12056
11912
|
if (await occupied(link)) {
|
|
12057
11913
|
warnOccupied(link, stdout);
|
|
12058
11914
|
continue;
|
|
@@ -12111,7 +11967,8 @@ function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
|
12111
11967
|
...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
|
|
12112
11968
|
...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
|
|
12113
11969
|
...options.stationChild === void 0 ? {} : { stationChild: options.stationChild },
|
|
12114
|
-
...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit }
|
|
11970
|
+
...options.deliveryRequestLimit === void 0 ? {} : { deliveryRequestLimit: options.deliveryRequestLimit },
|
|
11971
|
+
...options.navigatorWorkContextPath === void 0 || options.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: options.navigatorWorkContextPath }
|
|
12115
11972
|
};
|
|
12116
11973
|
}
|
|
12117
11974
|
function packagedSettleSkill(admitted) {
|
|
@@ -12138,11 +11995,6 @@ function activationForAdmitted(admitted) {
|
|
|
12138
11995
|
const activation = { role: admitted.role };
|
|
12139
11996
|
for (const spec of packagedRoleActivationFlags(admitted.role)) {
|
|
12140
11997
|
let value = readAdmittedPath(admitted, spec.from ?? spec.field);
|
|
12141
|
-
if (spec.fallback === "gate-pointer") {
|
|
12142
|
-
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
12143
|
-
value = trimmed !== "" ? trimmed : parentRunPathFromGatePointerInstruction(admitted.instruction);
|
|
12144
|
-
if (typeof value !== "string" || value === "") continue;
|
|
12145
|
-
}
|
|
12146
11998
|
if (value === void 0) continue;
|
|
12147
11999
|
if (spec.text === true) {
|
|
12148
12000
|
if (typeof value !== "number") continue;
|
|
@@ -12184,7 +12036,6 @@ var init_turn_request = __esm({
|
|
|
12184
12036
|
init_engine_material();
|
|
12185
12037
|
init_packaged_role_registry();
|
|
12186
12038
|
init_machine_method_skills();
|
|
12187
|
-
init_run_lifecycle();
|
|
12188
12039
|
}
|
|
12189
12040
|
});
|
|
12190
12041
|
|
|
@@ -12486,7 +12337,7 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
|
12486
12337
|
mutableRequest.principal = admitted.principal;
|
|
12487
12338
|
const activation = mutableRequest.activation;
|
|
12488
12339
|
if (isRecord(activation)) {
|
|
12489
|
-
for (const field of ["
|
|
12340
|
+
for (const field of ["inputPath"]) {
|
|
12490
12341
|
const record = activation;
|
|
12491
12342
|
if (field in record) record[field] = rewrite(record[field]);
|
|
12492
12343
|
}
|
|
@@ -13205,21 +13056,19 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13205
13056
|
}
|
|
13206
13057
|
function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepared) {
|
|
13207
13058
|
const officerDialogue = isStationChildOfficerDialogue(admitted.role, env);
|
|
13059
|
+
const fileFlags = summonsPrepared?.attachments ?? [];
|
|
13208
13060
|
let prompt;
|
|
13209
13061
|
if (request.message !== void 0) {
|
|
13210
13062
|
if (summonsPrepared !== void 0) {
|
|
13211
|
-
prompt = officerDialogue ? request.message :
|
|
13212
|
-
instruction: request.message,
|
|
13213
|
-
instructionEmpty: false,
|
|
13214
|
-
attachments: summonsPrepared.attachments
|
|
13215
|
-
});
|
|
13063
|
+
prompt = officerDialogue && fileFlags.length === 0 ? request.message : appendCallerFileFlagPaths(request.message, fileFlags);
|
|
13216
13064
|
} else if (request.summons !== void 0) {
|
|
13217
13065
|
prompt = request.message;
|
|
13218
13066
|
} else {
|
|
13219
13067
|
prompt = request.message;
|
|
13220
13068
|
}
|
|
13221
13069
|
} else if (summonsPrepared !== void 0) {
|
|
13222
|
-
|
|
13070
|
+
const body = summonsPrepared.instruction;
|
|
13071
|
+
prompt = officerDialogue && fileFlags.length === 0 ? body : appendCallerFileFlagPaths(body, fileFlags);
|
|
13223
13072
|
} else if (request.summons !== void 0) {
|
|
13224
13073
|
prompt = "";
|
|
13225
13074
|
} else {
|
|
@@ -13235,7 +13084,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
13235
13084
|
},
|
|
13236
13085
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
|
|
13237
13086
|
// #1132: one configured ceiling, already resolved by the caller (#422).
|
|
13238
|
-
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
|
|
13087
|
+
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit),
|
|
13088
|
+
...env.navigatorWorkContextPath === void 0 || env.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: env.navigatorWorkContextPath }
|
|
13239
13089
|
};
|
|
13240
13090
|
}
|
|
13241
13091
|
function roleTurnOptions(env, admitted, continuation) {
|
|
@@ -13247,7 +13097,8 @@ function roleTurnOptions(env, admitted, continuation) {
|
|
|
13247
13097
|
continuation,
|
|
13248
13098
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild },
|
|
13249
13099
|
// #1132: one configured ceiling, already resolved by the caller (#422).
|
|
13250
|
-
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit)
|
|
13100
|
+
deliveryRequestLimit: deliveryLimitFromConfig(env.autoResumeLimit),
|
|
13101
|
+
...env.navigatorWorkContextPath === void 0 || env.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: env.navigatorWorkContextPath }
|
|
13251
13102
|
};
|
|
13252
13103
|
}
|
|
13253
13104
|
async function dispatchAfterWriterLease(input) {
|
|
@@ -13829,11 +13680,44 @@ function buildInstructionSeatTurnRequest(admitted, options) {
|
|
|
13829
13680
|
options
|
|
13830
13681
|
);
|
|
13831
13682
|
}
|
|
13832
|
-
function
|
|
13683
|
+
async function loadLedgerPeerBody(sourceRunDirectory, projectRoot, home) {
|
|
13684
|
+
const runId = runIdFromRunDirectory(sourceRunDirectory);
|
|
13685
|
+
if (runId === void 0) return void 0;
|
|
13686
|
+
const rows = await readRecordedSubmissionRows(projectRoot, runId, {
|
|
13687
|
+
home,
|
|
13688
|
+
sessionParent: sessionFileOf(sourceRunDirectory)
|
|
13689
|
+
});
|
|
13690
|
+
const latest = rows.at(-1);
|
|
13691
|
+
if (latest === void 0) return void 0;
|
|
13692
|
+
return readableGateItem(latest.accepted);
|
|
13693
|
+
}
|
|
13694
|
+
async function resolveReviewSeatDialogueBody(input) {
|
|
13695
|
+
const reask = input.reask;
|
|
13696
|
+
if (reask !== void 0 && reask.length > 0) return reask;
|
|
13697
|
+
const caller = input.callerInstruction ?? "";
|
|
13698
|
+
if (caller.length > 0) return caller;
|
|
13699
|
+
const sourceRunPath = input.sourceRunPath?.trim() ?? "";
|
|
13700
|
+
if (sourceRunPath === "") return void 0;
|
|
13701
|
+
return await loadLedgerPeerBody(sourceRunPath, input.projectRoot, input.home);
|
|
13702
|
+
}
|
|
13703
|
+
function admittedSourceRunPath(admitted) {
|
|
13704
|
+
return "sourceRunPath" in admitted && typeof admitted.sourceRunPath === "string" ? admitted.sourceRunPath.trim() : "";
|
|
13705
|
+
}
|
|
13706
|
+
async function resolveInitialPrompt(admitted, env) {
|
|
13833
13707
|
const record = roleRecord(admitted.role);
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
13708
|
+
if ("reaskPrompt" in record && record.reaskPrompt === true) {
|
|
13709
|
+
const sourceRunPath = admittedSourceRunPath(admitted);
|
|
13710
|
+
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
13711
|
+
const body = await resolveReviewSeatDialogueBody({
|
|
13712
|
+
...reask === void 0 ? {} : { reask },
|
|
13713
|
+
callerInstruction: admitted.instruction,
|
|
13714
|
+
...sourceRunPath === "" ? {} : { sourceRunPath },
|
|
13715
|
+
projectRoot: admitted.projectRoot,
|
|
13716
|
+
home: env.home
|
|
13717
|
+
});
|
|
13718
|
+
if (body !== void 0) {
|
|
13719
|
+
return appendCallerFileFlagPaths(body, admitted.attachments);
|
|
13720
|
+
}
|
|
13837
13721
|
}
|
|
13838
13722
|
return buildInstructionTransportPrompt(admitted);
|
|
13839
13723
|
}
|
|
@@ -13915,6 +13799,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
13915
13799
|
if (activeEnv.correlationId !== void 0 && activeEnv.correlationId.trim() !== "") {
|
|
13916
13800
|
await recordAdmittedCorrelation(admitted, activeEnv.correlationId);
|
|
13917
13801
|
}
|
|
13802
|
+
const initialPromptText = await resolveInitialPrompt(admitted, activeEnv);
|
|
13918
13803
|
const auto = "inCallAutoResume" in record && record.inCallAutoResume === true;
|
|
13919
13804
|
if (auto) {
|
|
13920
13805
|
return await runPostAdmissionResumable({
|
|
@@ -13923,7 +13808,10 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
13923
13808
|
io: turnIo,
|
|
13924
13809
|
buildInitialRequest: () => buildInstructionSeatTurnRequest(
|
|
13925
13810
|
admitted,
|
|
13926
|
-
roleTurnOptions(activeEnv, admitted, {
|
|
13811
|
+
roleTurnOptions(activeEnv, admitted, {
|
|
13812
|
+
kind: "initial",
|
|
13813
|
+
prompt: initialPromptText
|
|
13814
|
+
})
|
|
13927
13815
|
),
|
|
13928
13816
|
buildResumeRequest: () => buildInstructionSeatTurnRequest(
|
|
13929
13817
|
admitted,
|
|
@@ -13942,7 +13830,10 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
13942
13830
|
io: turnIo,
|
|
13943
13831
|
request: buildInstructionSeatTurnRequest(
|
|
13944
13832
|
admitted,
|
|
13945
|
-
roleTurnOptions(activeEnv, admitted, {
|
|
13833
|
+
roleTurnOptions(activeEnv, admitted, {
|
|
13834
|
+
kind: "initial",
|
|
13835
|
+
prompt: initialPromptText
|
|
13836
|
+
})
|
|
13946
13837
|
),
|
|
13947
13838
|
adapters,
|
|
13948
13839
|
...activeEnv.engine === void 0 ? {} : { effectiveEngine: activeEnv.engine }
|
|
@@ -14042,10 +13933,19 @@ function resumeSameParentInstructionSeat(input) {
|
|
|
14042
13933
|
)
|
|
14043
13934
|
});
|
|
14044
13935
|
}
|
|
14045
|
-
function
|
|
14046
|
-
const
|
|
14047
|
-
|
|
14048
|
-
|
|
13936
|
+
async function sameParentDialogue(env, fallback, sourceRunPath, projectRoot) {
|
|
13937
|
+
const reask = env.reviewReask ?? env.gateReviewInstruction;
|
|
13938
|
+
const body = await resolveReviewSeatDialogueBody({
|
|
13939
|
+
...reask === void 0 ? {} : { reask },
|
|
13940
|
+
callerInstruction: fallback.instruction,
|
|
13941
|
+
sourceRunPath,
|
|
13942
|
+
projectRoot,
|
|
13943
|
+
home: env.home
|
|
13944
|
+
});
|
|
13945
|
+
if (body !== void 0) {
|
|
13946
|
+
return { instruction: body, instructionEmpty: false };
|
|
13947
|
+
}
|
|
13948
|
+
return fallback;
|
|
14049
13949
|
}
|
|
14050
13950
|
async function runCountersignBody(parsed, env, io) {
|
|
14051
13951
|
const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
|
|
@@ -14061,7 +13961,10 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14061
13961
|
summons: {
|
|
14062
13962
|
sourceRunPath: gateParentRunPath,
|
|
14063
13963
|
instruction: resumeInstruction,
|
|
14064
|
-
instructionEmpty: resumeInstruction.length === 0
|
|
13964
|
+
instructionEmpty: resumeInstruction.length === 0,
|
|
13965
|
+
// #1166 J11: same-parent resume delivers this call's file-flag paths
|
|
13966
|
+
// through the shared summons → appendCallerFileFlagPaths rule.
|
|
13967
|
+
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14065
13968
|
}
|
|
14066
13969
|
});
|
|
14067
13970
|
if (resumed != null) return resumed;
|
|
@@ -14093,9 +13996,10 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14093
13996
|
await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
|
|
14094
13997
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
14095
13998
|
}
|
|
13999
|
+
const reviewBody = env.reviewReask ?? env.gateReviewInstruction;
|
|
14096
14000
|
const turnProjection = roleTurnOptions(env, admitted, {
|
|
14097
14001
|
kind: "initial",
|
|
14098
|
-
prompt:
|
|
14002
|
+
prompt: reviewBody !== void 0 ? appendCallerFileFlagPaths(reviewBody, admitted.attachments) : buildInstructionTransportPrompt(admitted)
|
|
14099
14003
|
});
|
|
14100
14004
|
const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
|
|
14101
14005
|
const result = await runPostAdmissionOneShot({
|
|
@@ -14178,10 +14082,15 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14178
14082
|
if (auditorSource === void 0) return { exitCode: 2 };
|
|
14179
14083
|
const sourceDirectory = auditorSource;
|
|
14180
14084
|
const summons = {
|
|
14181
|
-
...
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14085
|
+
...await sameParentDialogue(
|
|
14086
|
+
env,
|
|
14087
|
+
{
|
|
14088
|
+
instruction: parsed.instruction ?? "",
|
|
14089
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14090
|
+
},
|
|
14091
|
+
sourceDirectory,
|
|
14092
|
+
projectRoot
|
|
14093
|
+
),
|
|
14185
14094
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14186
14095
|
};
|
|
14187
14096
|
const resumed = await withAuditorSoulEnv({
|
|
@@ -14198,15 +14107,33 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14198
14107
|
});
|
|
14199
14108
|
if (resumed != null) return resumed;
|
|
14200
14109
|
}
|
|
14201
|
-
if (record.sameParent === "
|
|
14202
|
-
|
|
14203
|
-
|
|
14110
|
+
if (record.sameParent === "source-run") {
|
|
14111
|
+
if (parsed.sourceRun !== void 0) {
|
|
14112
|
+
let parentRunPath;
|
|
14113
|
+
try {
|
|
14114
|
+
parentRunPath = (await resolveNotarySourceRunLocator({
|
|
14115
|
+
projectRoot,
|
|
14116
|
+
sourceRun: parsed.sourceRun,
|
|
14117
|
+
home: env.home
|
|
14118
|
+
})).runDirectory;
|
|
14119
|
+
} catch (error) {
|
|
14120
|
+
if (error instanceof NotarySourceRunError) {
|
|
14121
|
+
presentStructuralRejection(new CliUsageError(error.message, { cause: error }), io);
|
|
14122
|
+
return { exitCode: 2 };
|
|
14123
|
+
}
|
|
14124
|
+
throw error;
|
|
14125
|
+
}
|
|
14204
14126
|
const summons = {
|
|
14205
14127
|
sourceRunPath: parentRunPath,
|
|
14206
|
-
...
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14128
|
+
...await sameParentDialogue(
|
|
14129
|
+
env,
|
|
14130
|
+
{
|
|
14131
|
+
instruction: parsed.instruction ?? "",
|
|
14132
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14133
|
+
},
|
|
14134
|
+
parentRunPath,
|
|
14135
|
+
projectRoot
|
|
14136
|
+
),
|
|
14210
14137
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14211
14138
|
};
|
|
14212
14139
|
const resumed = await resumeSameParentInstructionSeat({
|
|
@@ -14235,11 +14162,15 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14235
14162
|
}
|
|
14236
14163
|
throw error;
|
|
14237
14164
|
}
|
|
14238
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
14239
14165
|
const summons = {
|
|
14240
14166
|
sourceRunPath: source.runDirectory,
|
|
14241
14167
|
sourceRun: source,
|
|
14242
|
-
...
|
|
14168
|
+
...await sameParentDialogue(
|
|
14169
|
+
env,
|
|
14170
|
+
{ instruction: "", instructionEmpty: true },
|
|
14171
|
+
source.runDirectory,
|
|
14172
|
+
projectRoot
|
|
14173
|
+
)
|
|
14243
14174
|
};
|
|
14244
14175
|
resolvedNotarySource = source;
|
|
14245
14176
|
const resumed = await resumeSameParentInstructionSeat({
|
|
@@ -14269,16 +14200,18 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14269
14200
|
if (rejected !== void 0) return rejected;
|
|
14270
14201
|
throw error;
|
|
14271
14202
|
}
|
|
14272
|
-
if (record.sameParent === "
|
|
14273
|
-
const parentRunPath =
|
|
14274
|
-
|
|
14275
|
-
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
|
|
14203
|
+
if (record.sameParent === "source-run" && parsed.sourceRun !== void 0) {
|
|
14204
|
+
const parentRunPath = (await resolveNotarySourceRunLocator({
|
|
14205
|
+
projectRoot,
|
|
14206
|
+
sourceRun: parsed.sourceRun,
|
|
14207
|
+
home: env.home
|
|
14208
|
+
})).runDirectory;
|
|
14209
|
+
await persistAdmittedSourceRunPath(admitted, parentRunPath);
|
|
14210
|
+
admitted = { ...admitted, sourceRunPath: parentRunPath };
|
|
14279
14211
|
}
|
|
14280
14212
|
if (record.sameParent === "subject-source" && auditorSource !== void 0) {
|
|
14281
14213
|
await persistAdmittedSourceRunPath(admitted, auditorSource, auditorSubject);
|
|
14214
|
+
admitted = { ...admitted, sourceRunPath: auditorSource };
|
|
14282
14215
|
}
|
|
14283
14216
|
const runAdmitted = async () => {
|
|
14284
14217
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
@@ -14607,13 +14540,7 @@ async function auditSubmittedRole(turn, env, io, resumedOfficer, passedReceipt)
|
|
|
14607
14540
|
summonAuditor: async (subject, sourceRunDirectory, signal, reask, submission) => {
|
|
14608
14541
|
const summoned = await summonPublicRole({
|
|
14609
14542
|
role: "auditor",
|
|
14610
|
-
argv: [
|
|
14611
|
-
"--subject",
|
|
14612
|
-
subject,
|
|
14613
|
-
"--source-run",
|
|
14614
|
-
sourceRunDirectory,
|
|
14615
|
-
`${AUDITOR_DOSSIER_PROMPT}${sourceRunDirectory}`
|
|
14616
|
-
],
|
|
14543
|
+
argv: ["--subject", subject, "--source-run", sourceRunDirectory],
|
|
14617
14544
|
cwd: admitted.projectRoot,
|
|
14618
14545
|
home: env.home,
|
|
14619
14546
|
packageRoot: env.packageRoot,
|
|
@@ -14773,7 +14700,6 @@ var init_instruction_seat_run = __esm({
|
|
|
14773
14700
|
"src/public-cli/instruction-seat-run.ts"() {
|
|
14774
14701
|
"use strict";
|
|
14775
14702
|
init_role_run_placement();
|
|
14776
|
-
init_compliance_transport();
|
|
14777
14703
|
init_archivist_record_pointer();
|
|
14778
14704
|
init_doctor_auditor();
|
|
14779
14705
|
init_gatekeeper_role();
|
|
@@ -14882,12 +14808,12 @@ var init_analyst_book_key = __esm({
|
|
|
14882
14808
|
|
|
14883
14809
|
// src/analyst-index.ts
|
|
14884
14810
|
import { open, readFile as readFile11, unlink } from "node:fs/promises";
|
|
14885
|
-
import { dirname as dirname16, join as
|
|
14811
|
+
import { dirname as dirname16, join as join24 } from "node:path";
|
|
14886
14812
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
14887
14813
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
14888
14814
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
14889
14815
|
ensureRealDirectoryTree(ledgerHome, dirname16(indexPath));
|
|
14890
|
-
const lockPath =
|
|
14816
|
+
const lockPath = join24(dirname16(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
14891
14817
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
14892
14818
|
const startedAt = Date.now();
|
|
14893
14819
|
while (true) {
|
|
@@ -14914,7 +14840,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
14914
14840
|
}
|
|
14915
14841
|
}
|
|
14916
14842
|
function analystLibraryIndexPath(ledgerHome) {
|
|
14917
|
-
return
|
|
14843
|
+
return join24(ledgerHome, "analyst", "library-index.json");
|
|
14918
14844
|
}
|
|
14919
14845
|
function rowFromIssueMetricsPage(page) {
|
|
14920
14846
|
return {
|
|
@@ -15460,7 +15386,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
15460
15386
|
|
|
15461
15387
|
// src/analyst-ledger.ts
|
|
15462
15388
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
15463
|
-
import { basename as basename11, join as
|
|
15389
|
+
import { basename as basename11, join as join25 } from "node:path";
|
|
15464
15390
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
15465
15391
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
15466
15392
|
}
|
|
@@ -15480,7 +15406,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
15480
15406
|
}
|
|
15481
15407
|
}
|
|
15482
15408
|
async function classifyGhostCandidate(input) {
|
|
15483
|
-
const autopsy = await autopsyWriterLock(
|
|
15409
|
+
const autopsy = await autopsyWriterLock(join25(input.runDirectory, "writer.lock"));
|
|
15484
15410
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
15485
15411
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
15486
15412
|
return {
|
|
@@ -15770,7 +15696,7 @@ async function classifyScopedRun(input) {
|
|
|
15770
15696
|
async function scanAnalystIssueRuns(input) {
|
|
15771
15697
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
15772
15698
|
const scopeTicketNumber = input.ticketNumber;
|
|
15773
|
-
const booksRoot =
|
|
15699
|
+
const booksRoot = join25(ledgerHome, "books");
|
|
15774
15700
|
let wholeBook = false;
|
|
15775
15701
|
let scopeRootIdentity;
|
|
15776
15702
|
let bookNames;
|
|
@@ -15803,7 +15729,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
15803
15729
|
const ghostLegs = [];
|
|
15804
15730
|
const scopeConflicts = [];
|
|
15805
15731
|
for (const book of bookNames) {
|
|
15806
|
-
const bookDir =
|
|
15732
|
+
const bookDir = join25(booksRoot, book);
|
|
15807
15733
|
let runDirectories;
|
|
15808
15734
|
try {
|
|
15809
15735
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -16549,7 +16475,7 @@ var init_analyst_metric_family = __esm({
|
|
|
16549
16475
|
});
|
|
16550
16476
|
|
|
16551
16477
|
// src/analyst-page.ts
|
|
16552
|
-
import { dirname as dirname17, join as
|
|
16478
|
+
import { dirname as dirname17, join as join26 } from "node:path";
|
|
16553
16479
|
function analystIssuePageKey(address) {
|
|
16554
16480
|
const parts = ["book", address.bookKey];
|
|
16555
16481
|
if (address.issueNumber !== void 0) {
|
|
@@ -16560,7 +16486,7 @@ function analystIssuePageKey(address) {
|
|
|
16560
16486
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
16561
16487
|
}
|
|
16562
16488
|
function analystIssuePagePath(ledgerHome, address) {
|
|
16563
|
-
return
|
|
16489
|
+
return join26(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
16564
16490
|
}
|
|
16565
16491
|
function analystIssuePageAddressFromPage(page) {
|
|
16566
16492
|
return {
|
|
@@ -16797,7 +16723,7 @@ var init_analyst_model_groups = __esm({
|
|
|
16797
16723
|
|
|
16798
16724
|
// src/analyst-entry.ts
|
|
16799
16725
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
16800
|
-
import { Type as
|
|
16726
|
+
import { Type as Type16 } from "typebox";
|
|
16801
16727
|
function cachedPageMatchesRequestedScope(page, input) {
|
|
16802
16728
|
if (page.bookKey !== input.bookKey) return false;
|
|
16803
16729
|
const requestedTicket = input.ticketNumber ?? input.issueNumber;
|
|
@@ -17002,16 +16928,16 @@ var init_analyst_entry = __esm({
|
|
|
17002
16928
|
}
|
|
17003
16929
|
}
|
|
17004
16930
|
};
|
|
17005
|
-
analystSweepModeInputSchema =
|
|
16931
|
+
analystSweepModeInputSchema = Type16.Object(
|
|
17006
16932
|
{
|
|
17007
|
-
mode:
|
|
17008
|
-
mergedPullRequests:
|
|
17009
|
-
|
|
16933
|
+
mode: Type16.Literal("sweep"),
|
|
16934
|
+
mergedPullRequests: Type16.Array(
|
|
16935
|
+
Type16.Object(
|
|
17010
16936
|
{
|
|
17011
|
-
projectRoot:
|
|
16937
|
+
projectRoot: Type16.String(),
|
|
17012
16938
|
/** 排除后改动行数 — omit or 0 → typed 空缺; finite ≥ 0 only. */
|
|
17013
|
-
changedLines:
|
|
17014
|
-
|
|
16939
|
+
changedLines: Type16.Optional(
|
|
16940
|
+
Type16.Number({ minimum: 0, maximum: Number.MAX_VALUE })
|
|
17015
16941
|
)
|
|
17016
16942
|
}
|
|
17017
16943
|
)
|
|
@@ -17024,7 +16950,7 @@ var init_analyst_entry = __esm({
|
|
|
17024
16950
|
// src/public-cli/analyst-run.ts
|
|
17025
16951
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
17026
16952
|
import { isAbsolute as isAbsolute8, resolve as resolve14 } from "node:path";
|
|
17027
|
-
import { Value as
|
|
16953
|
+
import { Value as Value2 } from "typebox/value";
|
|
17028
16954
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
17029
16955
|
try {
|
|
17030
16956
|
return resolveBookKeyFromGit(cwd);
|
|
@@ -17059,7 +16985,7 @@ async function buildAnalystIssueModeInputFromPublicArgv(parsed, _ledgerHome) {
|
|
|
17059
16985
|
};
|
|
17060
16986
|
}
|
|
17061
16987
|
function parseAnalystSweepModeInputFromJsonValue(value) {
|
|
17062
|
-
if (!
|
|
16988
|
+
if (!Value2.Check(analystSweepModeInputSchema, value)) {
|
|
17063
16989
|
throw new CliUsageError(
|
|
17064
16990
|
"analyst sweep attachment must match AnalystSweepModeInput"
|
|
17065
16991
|
);
|
|
@@ -18106,7 +18032,7 @@ __export(public_role_summons_exports, {
|
|
|
18106
18032
|
import { execFile as execFile3 } from "node:child_process";
|
|
18107
18033
|
import { existsSync as existsSync9 } from "node:fs";
|
|
18108
18034
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18109
|
-
import { join as
|
|
18035
|
+
import { join as join27 } from "node:path";
|
|
18110
18036
|
import { promisify as promisify3 } from "node:util";
|
|
18111
18037
|
function createCapturingIo() {
|
|
18112
18038
|
const chunks = [];
|
|
@@ -18130,7 +18056,7 @@ function parentDir(path) {
|
|
|
18130
18056
|
function walkPackageRoot(start) {
|
|
18131
18057
|
let dir = start;
|
|
18132
18058
|
for (let i = 0; i < 12; i += 1) {
|
|
18133
|
-
if (existsSync9(
|
|
18059
|
+
if (existsSync9(join27(dir, "package.json")) && existsSync9(join27(dir, "souls"))) {
|
|
18134
18060
|
return dir;
|
|
18135
18061
|
}
|
|
18136
18062
|
const parent = parentDir(dir);
|
|
@@ -18298,7 +18224,8 @@ async function summonPublicRole(options) {
|
|
|
18298
18224
|
...options.boundTicketNumber === void 0 ? {} : { boundTicketNumber: options.boundTicketNumber },
|
|
18299
18225
|
...options.parentRunPath === void 0 || options.parentRunPath.trim() === "" ? {} : { parentRunPath: options.parentRunPath },
|
|
18300
18226
|
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
18301
|
-
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId }
|
|
18227
|
+
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
|
|
18228
|
+
...options.navigatorWorkContextPath === void 0 || options.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: options.navigatorWorkContextPath }
|
|
18302
18229
|
}
|
|
18303
18230
|
};
|
|
18304
18231
|
} catch (error) {
|
|
@@ -18555,7 +18482,8 @@ async function summonGateOfficer(options) {
|
|
|
18555
18482
|
"judge",
|
|
18556
18483
|
"--source-run",
|
|
18557
18484
|
options.sourceRunDirectory,
|
|
18558
|
-
|
|
18485
|
+
"--project",
|
|
18486
|
+
options.cwd
|
|
18559
18487
|
],
|
|
18560
18488
|
...common
|
|
18561
18489
|
});
|
|
@@ -18583,7 +18511,7 @@ async function summonGateOfficer(options) {
|
|
|
18583
18511
|
}
|
|
18584
18512
|
return summonPublicRole({
|
|
18585
18513
|
role: options.officer,
|
|
18586
|
-
argv: [
|
|
18514
|
+
argv: ["--source-run", options.sourceRunDirectory, "--project", options.cwd],
|
|
18587
18515
|
...common
|
|
18588
18516
|
});
|
|
18589
18517
|
}
|
|
@@ -18691,8 +18619,7 @@ async function runComplianceAudit(options) {
|
|
|
18691
18619
|
"--subject",
|
|
18692
18620
|
auditSubject,
|
|
18693
18621
|
"--source-run",
|
|
18694
|
-
sourceRunDirectory
|
|
18695
|
-
`${AUDITOR_DOSSIER_PROMPT}${sourceRunDirectory}`
|
|
18622
|
+
sourceRunDirectory
|
|
18696
18623
|
],
|
|
18697
18624
|
cwd: options.context.cwd ?? process.cwd(),
|
|
18698
18625
|
home,
|
|
@@ -18716,18 +18643,17 @@ async function runComplianceAudit(options) {
|
|
|
18716
18643
|
return decision;
|
|
18717
18644
|
}
|
|
18718
18645
|
}
|
|
18719
|
-
var
|
|
18646
|
+
var AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE, ComplianceResponseRetentionError;
|
|
18720
18647
|
var init_compliance_transport = __esm({
|
|
18721
18648
|
"src/compliance-transport.ts"() {
|
|
18722
18649
|
"use strict";
|
|
18723
|
-
|
|
18650
|
+
init_role_run_placement();
|
|
18724
18651
|
init_gatekeeper_role();
|
|
18725
18652
|
init_submission_errors();
|
|
18726
18653
|
init_terminal();
|
|
18727
18654
|
init_readable_gate_item();
|
|
18728
18655
|
init_receipt_delivery_policy();
|
|
18729
18656
|
init_unknown_value();
|
|
18730
|
-
AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
|
|
18731
18657
|
AUDITOR_PARENT_ATTEMPT_BINDING_ENTRY_TYPE = "ak_auditor_parent_attempt_binding";
|
|
18732
18658
|
ComplianceResponseRetentionError = class extends Error {
|
|
18733
18659
|
constructor(message, options) {
|
|
@@ -18739,7 +18665,7 @@ var init_compliance_transport = __esm({
|
|
|
18739
18665
|
});
|
|
18740
18666
|
|
|
18741
18667
|
// src/role-run-relocation.ts
|
|
18742
|
-
import { dirname as dirname18, join as
|
|
18668
|
+
import { dirname as dirname18, join as join28, sep as sep4 } from "node:path";
|
|
18743
18669
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
18744
18670
|
if (typeof value !== "string") return value;
|
|
18745
18671
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -18843,10 +18769,9 @@ var init_role_run_relocation = __esm({
|
|
|
18843
18769
|
// pre-#1161 pages only
|
|
18844
18770
|
"sessionDirectory",
|
|
18845
18771
|
"sessionFile",
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
// #1165: requestManifestPath is a caller path — never rewrite.
|
|
18772
|
+
// #1165/#1168: caller file-flag paths (requestManifestPath, prerequisitesPath)
|
|
18773
|
+
// stay as given. Obsolete copy fields (taskPath/packetPath) are not rewritten —
|
|
18774
|
+
// stock volumes keep their bytes; live relocate no longer maintains them.
|
|
18850
18775
|
"mergerInputPath",
|
|
18851
18776
|
"sourceRunPath"
|
|
18852
18777
|
];
|
|
@@ -18858,7 +18783,6 @@ var init_role_run_relocation = __esm({
|
|
|
18858
18783
|
var run_lifecycle_exports = {};
|
|
18859
18784
|
__export(run_lifecycle_exports, {
|
|
18860
18785
|
AUTO_RESUME_LIMIT: () => AUTO_RESUME_LIMIT,
|
|
18861
|
-
GATE_DOSSIER_POINTER_PREFIX: () => GATE_DOSSIER_POINTER_PREFIX,
|
|
18862
18786
|
RESUME_TRANSPORT_ENVELOPE: () => RESUME_TRANSPORT_ENVELOPE,
|
|
18863
18787
|
RunWriterLeaseHeldError: () => RunWriterLeaseHeldError,
|
|
18864
18788
|
acquireRunWriterLease: () => acquireRunWriterLease,
|
|
@@ -18872,7 +18796,6 @@ __export(run_lifecycle_exports, {
|
|
|
18872
18796
|
markRunAdmitted: () => markRunAdmitted,
|
|
18873
18797
|
markRunRunning: () => markRunRunning,
|
|
18874
18798
|
markRunTerminal: () => markRunTerminal,
|
|
18875
|
-
parentRunPathFromGatePointerInstruction: () => parentRunPathFromGatePointerInstruction,
|
|
18876
18799
|
peekRoleRunRole: () => peekRoleRunRole,
|
|
18877
18800
|
readCurrentCourt: () => readCurrentCourt,
|
|
18878
18801
|
readRoleRunIdentity: () => readRoleRunIdentity,
|
|
@@ -18882,7 +18805,7 @@ __export(run_lifecycle_exports, {
|
|
|
18882
18805
|
writeRoleRunState: () => writeRoleRunState
|
|
18883
18806
|
});
|
|
18884
18807
|
import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile15, unlink as unlink2 } from "node:fs/promises";
|
|
18885
|
-
import { basename as basename12, join as
|
|
18808
|
+
import { basename as basename12, join as join29 } from "node:path";
|
|
18886
18809
|
function buildAutoResumeContinuationPrompt() {
|
|
18887
18810
|
return RESUME_TRANSPORT_ENVELOPE;
|
|
18888
18811
|
}
|
|
@@ -19179,7 +19102,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19179
19102
|
},
|
|
19180
19103
|
relocate(nextRunDirectory) {
|
|
19181
19104
|
currentRunDirectory = nextRunDirectory;
|
|
19182
|
-
currentLockPath =
|
|
19105
|
+
currentLockPath = join29(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19183
19106
|
},
|
|
19184
19107
|
async release() {
|
|
19185
19108
|
if (released) return;
|
|
@@ -19218,10 +19141,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19218
19141
|
};
|
|
19219
19142
|
const reportReadFailure = (error) => {
|
|
19220
19143
|
reportDiagnostic(
|
|
19221
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
19144
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join29(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19222
19145
|
);
|
|
19223
19146
|
};
|
|
19224
|
-
const lockPath =
|
|
19147
|
+
const lockPath = join29(runDirectory, WRITER_LOCK_FILE);
|
|
19225
19148
|
let lastAutopsy = { verdict: "absent" };
|
|
19226
19149
|
let lastReclaimFailure;
|
|
19227
19150
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19278,7 +19201,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19278
19201
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19279
19202
|
if (runId.trim() === "") return void 0;
|
|
19280
19203
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19281
|
-
const booksRoot =
|
|
19204
|
+
const booksRoot = join29(ledgerHome, "books");
|
|
19282
19205
|
let bookKeys;
|
|
19283
19206
|
try {
|
|
19284
19207
|
bookKeys = await readdir4(booksRoot);
|
|
@@ -19292,20 +19215,12 @@ async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
|
19292
19215
|
onlyRole
|
|
19293
19216
|
);
|
|
19294
19217
|
}
|
|
19295
|
-
function parentRunPathFromGatePointerInstruction(instruction) {
|
|
19296
|
-
if (!instruction.startsWith(GATE_DOSSIER_POINTER_PREFIX)) return void 0;
|
|
19297
|
-
const path = instruction.slice(GATE_DOSSIER_POINTER_PREFIX.length).trim();
|
|
19298
|
-
return path === "" ? void 0 : path;
|
|
19299
|
-
}
|
|
19300
19218
|
async function readRunParentPath(runDirectory) {
|
|
19301
19219
|
const record = readPageSync(runDirectory, "admitted");
|
|
19302
19220
|
if (record === void 0) return void 0;
|
|
19303
19221
|
if (typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "") {
|
|
19304
19222
|
return record.sourceRunPath;
|
|
19305
19223
|
}
|
|
19306
|
-
if (typeof record.instruction === "string") {
|
|
19307
|
-
return parentRunPathFromGatePointerInstruction(record.instruction);
|
|
19308
|
-
}
|
|
19309
19224
|
return void 0;
|
|
19310
19225
|
}
|
|
19311
19226
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
@@ -19329,7 +19244,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19329
19244
|
let runDirectories;
|
|
19330
19245
|
try {
|
|
19331
19246
|
runDirectories = await listBookRunDirectories(
|
|
19332
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
19247
|
+
input.ticketNumber === void 0 ? bookDir : join29(bookDir, String(input.ticketNumber))
|
|
19333
19248
|
);
|
|
19334
19249
|
} catch (error) {
|
|
19335
19250
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19379,10 +19294,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19379
19294
|
let instructionEmpty = true;
|
|
19380
19295
|
let attachments = [];
|
|
19381
19296
|
let phase;
|
|
19382
|
-
let taskPath;
|
|
19383
|
-
let packetPath;
|
|
19384
19297
|
let prerequisitesPath;
|
|
19385
|
-
let prerequisites;
|
|
19386
19298
|
let baseRevision;
|
|
19387
19299
|
let lens;
|
|
19388
19300
|
let authorityRefs;
|
|
@@ -19421,18 +19333,9 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19421
19333
|
if (record.phase === "plan" || record.phase === "apply") {
|
|
19422
19334
|
phase = record.phase;
|
|
19423
19335
|
}
|
|
19424
|
-
if (typeof record.
|
|
19425
|
-
taskPath = record.taskPath;
|
|
19426
|
-
}
|
|
19427
|
-
if (typeof record.packetPath === "string" && record.packetPath.trim() !== "") {
|
|
19428
|
-
packetPath = record.packetPath;
|
|
19429
|
-
}
|
|
19430
|
-
if (typeof record.prerequisitesPath === "string" && record.prerequisitesPath.trim() !== "") {
|
|
19336
|
+
if (typeof record.prerequisitesPath === "string") {
|
|
19431
19337
|
prerequisitesPath = record.prerequisitesPath;
|
|
19432
19338
|
}
|
|
19433
|
-
if (Array.isArray(record.prerequisites)) {
|
|
19434
|
-
prerequisites = record.prerequisites;
|
|
19435
|
-
}
|
|
19436
19339
|
if (typeof record.baseRevision === "string" && record.baseRevision.trim() !== "") {
|
|
19437
19340
|
baseRevision = record.baseRevision;
|
|
19438
19341
|
}
|
|
@@ -19569,10 +19472,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19569
19472
|
instructionEmpty,
|
|
19570
19473
|
attachments,
|
|
19571
19474
|
...phase === void 0 ? {} : { phase },
|
|
19572
|
-
...taskPath === void 0 ? {} : { taskPath },
|
|
19573
|
-
...packetPath === void 0 ? {} : { packetPath },
|
|
19574
19475
|
...prerequisitesPath === void 0 ? {} : { prerequisitesPath },
|
|
19575
|
-
...prerequisites === void 0 ? {} : { prerequisites },
|
|
19576
19476
|
...baseRevision === void 0 ? {} : { baseRevision },
|
|
19577
19477
|
...lens === void 0 ? {} : { lens },
|
|
19578
19478
|
...authorityRefs === void 0 ? {} : { authorityRefs },
|
|
@@ -19657,12 +19557,6 @@ function admitResumedRole(loaded) {
|
|
|
19657
19557
|
}
|
|
19658
19558
|
case "worker-task": {
|
|
19659
19559
|
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
|
|
19660
|
-
const taskPath = fields.taskPath;
|
|
19661
|
-
if (taskPath === void 0) {
|
|
19662
|
-
throw new CliUsageError(
|
|
19663
|
-
`role run admitted coder task path is missing: ${runId}`
|
|
19664
|
-
);
|
|
19665
|
-
}
|
|
19666
19560
|
if (fields.instruction.trim() === "") {
|
|
19667
19561
|
throw new CliUsageError(
|
|
19668
19562
|
`role run admitted coder task is blank: ${runId}`
|
|
@@ -19672,33 +19566,23 @@ function admitResumedRole(loaded) {
|
|
|
19672
19566
|
role: "coder",
|
|
19673
19567
|
phase,
|
|
19674
19568
|
...base,
|
|
19675
|
-
instructionEmpty: false
|
|
19676
|
-
taskPath
|
|
19569
|
+
instructionEmpty: false
|
|
19677
19570
|
};
|
|
19678
19571
|
return admitted;
|
|
19679
19572
|
}
|
|
19680
19573
|
case "worker-packet": {
|
|
19681
19574
|
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
|
|
19682
|
-
const packetPath = fields.packetPath;
|
|
19683
|
-
if (packetPath === void 0) {
|
|
19684
|
-
throw new CliUsageError(
|
|
19685
|
-
`role run admitted fixer packet path is missing: ${runId}`
|
|
19686
|
-
);
|
|
19687
|
-
}
|
|
19688
19575
|
if (fields.instruction.trim() === "") {
|
|
19689
19576
|
throw new CliUsageError(
|
|
19690
19577
|
`role run admitted fixer instruction is blank: ${runId}`
|
|
19691
19578
|
);
|
|
19692
19579
|
}
|
|
19693
|
-
const prerequisites = fields.prerequisites ?? Object.freeze([]);
|
|
19694
19580
|
const admitted = {
|
|
19695
19581
|
role: "fixer",
|
|
19696
19582
|
phase,
|
|
19697
19583
|
...base,
|
|
19698
19584
|
instructionEmpty: false,
|
|
19699
|
-
|
|
19700
|
-
...fields.prerequisitesPath === void 0 ? {} : { prerequisitesPath: fields.prerequisitesPath },
|
|
19701
|
-
prerequisites
|
|
19585
|
+
...fields.prerequisitesPath === void 0 ? {} : { prerequisitesPath: fields.prerequisitesPath }
|
|
19702
19586
|
};
|
|
19703
19587
|
return admitted;
|
|
19704
19588
|
}
|
|
@@ -19842,7 +19726,7 @@ function resumedWorkerPhase(phase, phases, role, runId) {
|
|
|
19842
19726
|
}
|
|
19843
19727
|
throw new CliUsageError(`role run admitted ${role} phase is missing: ${runId}`);
|
|
19844
19728
|
}
|
|
19845
|
-
var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS
|
|
19729
|
+
var AUTO_RESUME_LIMIT, RESUME_TRANSPORT_ENVELOPE, WRITER_LOCK_FILE, RunWriterLeaseHeldError, WRITER_LEASE_RECLAIM_ROUNDS;
|
|
19846
19730
|
var init_run_lifecycle = __esm({
|
|
19847
19731
|
"src/public-cli/run-lifecycle.ts"() {
|
|
19848
19732
|
"use strict";
|
|
@@ -19875,12 +19759,11 @@ var init_run_lifecycle = __esm({
|
|
|
19875
19759
|
}
|
|
19876
19760
|
};
|
|
19877
19761
|
WRITER_LEASE_RECLAIM_ROUNDS = 3;
|
|
19878
|
-
GATE_DOSSIER_POINTER_PREFIX = "\u5377\u5B97\u6307\u9488\uFF1A";
|
|
19879
19762
|
}
|
|
19880
19763
|
});
|
|
19881
19764
|
|
|
19882
19765
|
// src/archivist-record-topology.ts
|
|
19883
|
-
import { join as
|
|
19766
|
+
import { join as join30 } from "node:path";
|
|
19884
19767
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
19885
19768
|
let ledgerHome;
|
|
19886
19769
|
if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
|
|
@@ -19893,7 +19776,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
19893
19776
|
const digest = sha256Hex(input.subject).slice(0, 32);
|
|
19894
19777
|
return {
|
|
19895
19778
|
ledgerHome,
|
|
19896
|
-
sessionDir:
|
|
19779
|
+
sessionDir: join30(
|
|
19897
19780
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
19898
19781
|
NAVIGATOR_RECORD_KIND,
|
|
19899
19782
|
digest
|
|
@@ -19966,7 +19849,7 @@ import {
|
|
|
19966
19849
|
statSync as statSync7,
|
|
19967
19850
|
writeFileSync as writeFileSync2
|
|
19968
19851
|
} from "node:fs";
|
|
19969
|
-
import { dirname as dirname19, resolve as resolve15, join as
|
|
19852
|
+
import { dirname as dirname19, resolve as resolve15, join as join31 } from "node:path";
|
|
19970
19853
|
import { StringDecoder } from "node:string_decoder";
|
|
19971
19854
|
function readCurrentSession(sessionDir) {
|
|
19972
19855
|
const ledger = currentSessionLedgerPath(sessionDir);
|
|
@@ -20000,7 +19883,7 @@ function isCurrentSessionClaimRace(error) {
|
|
|
20000
19883
|
return errnoCode(error.cause) === "EEXIST";
|
|
20001
19884
|
}
|
|
20002
19885
|
function currentSessionLedgerPath(sessionDir) {
|
|
20003
|
-
return
|
|
19886
|
+
return join31(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20004
19887
|
}
|
|
20005
19888
|
function readBoundedSessionHeader(filePath) {
|
|
20006
19889
|
const fd = openSync(filePath, "r");
|
|
@@ -20087,7 +19970,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20087
19970
|
const matched = [];
|
|
20088
19971
|
for (const name of names) {
|
|
20089
19972
|
if (!name.endsWith(".jsonl")) continue;
|
|
20090
|
-
const filePath =
|
|
19973
|
+
const filePath = join31(absoluteSessionDir, name);
|
|
20091
19974
|
let st;
|
|
20092
19975
|
try {
|
|
20093
19976
|
st = statSync7(filePath);
|
|
@@ -20276,7 +20159,7 @@ init_packaged_role_registry();
|
|
|
20276
20159
|
init_activation_ledger_topology();
|
|
20277
20160
|
import { resolve as resolve16 } from "node:path";
|
|
20278
20161
|
import "@earendil-works/pi-coding-agent";
|
|
20279
|
-
import { Type as
|
|
20162
|
+
import { Type as Type17 } from "typebox";
|
|
20280
20163
|
|
|
20281
20164
|
// src/navigator-public-session.ts
|
|
20282
20165
|
init_host_session_record();
|
|
@@ -20285,8 +20168,8 @@ import { basename as basename13 } from "node:path";
|
|
|
20285
20168
|
|
|
20286
20169
|
// src/navigator-session-contracts.ts
|
|
20287
20170
|
init_unknown_value();
|
|
20288
|
-
import { Type as
|
|
20289
|
-
import { Value
|
|
20171
|
+
import { Type as Type14 } from "typebox";
|
|
20172
|
+
import { Value } from "typebox/value";
|
|
20290
20173
|
var NAVIGATOR_PREPARE_TOOL_NAME = "ak_navigator_prepare";
|
|
20291
20174
|
var NAVIGATOR_UNAVAILABLE_KEYS = /* @__PURE__ */ new Set([
|
|
20292
20175
|
"context",
|
|
@@ -20390,26 +20273,26 @@ function navigatorProviderFailureFromPublicTerminal(outcome) {
|
|
|
20390
20273
|
if (typed !== void 0) return { source: typed, cause: typed };
|
|
20391
20274
|
return { source: "unknown", cause: "unknown" };
|
|
20392
20275
|
}
|
|
20393
|
-
var navigatorProviderFailureSchema =
|
|
20394
|
-
source:
|
|
20395
|
-
|
|
20396
|
-
|
|
20397
|
-
|
|
20398
|
-
|
|
20399
|
-
|
|
20400
|
-
|
|
20401
|
-
|
|
20402
|
-
|
|
20276
|
+
var navigatorProviderFailureSchema = Type14.Object({
|
|
20277
|
+
source: Type14.Union([
|
|
20278
|
+
Type14.Literal("context"),
|
|
20279
|
+
Type14.Literal("session"),
|
|
20280
|
+
Type14.Literal("model"),
|
|
20281
|
+
Type14.Literal("thinking"),
|
|
20282
|
+
Type14.Literal("auth"),
|
|
20283
|
+
Type14.Literal("quota"),
|
|
20284
|
+
Type14.Literal("transport"),
|
|
20285
|
+
Type14.Literal("unknown")
|
|
20403
20286
|
]),
|
|
20404
|
-
cause:
|
|
20405
|
-
|
|
20406
|
-
|
|
20407
|
-
|
|
20408
|
-
|
|
20409
|
-
|
|
20410
|
-
|
|
20411
|
-
|
|
20412
|
-
|
|
20287
|
+
cause: Type14.Union([
|
|
20288
|
+
Type14.Literal("context"),
|
|
20289
|
+
Type14.Literal("session"),
|
|
20290
|
+
Type14.Literal("model"),
|
|
20291
|
+
Type14.Literal("thinking"),
|
|
20292
|
+
Type14.Literal("auth"),
|
|
20293
|
+
Type14.Literal("quota"),
|
|
20294
|
+
Type14.Literal("transport"),
|
|
20295
|
+
Type14.Literal("unknown")
|
|
20413
20296
|
])
|
|
20414
20297
|
}, { additionalProperties: false });
|
|
20415
20298
|
function parseNavigatorModelSetting(value) {
|
|
@@ -20476,13 +20359,14 @@ init_atomic_write();
|
|
|
20476
20359
|
init_unknown_value();
|
|
20477
20360
|
import { existsSync as existsSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
20478
20361
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
20479
|
-
import { basename as basename6, dirname as dirname9, join as join11, resolve as
|
|
20362
|
+
import { basename as basename6, dirname as dirname9, join as join11, resolve as resolve6 } from "node:path";
|
|
20480
20363
|
var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
|
|
20364
|
+
var AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV = "AK_ROLE_NAVIGATOR_WORK_CONTEXT";
|
|
20481
20365
|
function navigatorWorkContextFile(sessionDir) {
|
|
20482
20366
|
return join11(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
|
|
20483
20367
|
}
|
|
20484
20368
|
function isNavigatorWorkContextFile(path) {
|
|
20485
|
-
const resolved =
|
|
20369
|
+
const resolved = resolve6(path);
|
|
20486
20370
|
if (basename6(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
|
|
20487
20371
|
const nest = dirname9(resolved);
|
|
20488
20372
|
if (!/^[0-9a-f]{32}$/.test(basename6(nest))) return false;
|
|
@@ -20534,33 +20418,8 @@ async function readNavigatorWorkBase(path) {
|
|
|
20534
20418
|
if (record.authority.trim() === "") return void 0;
|
|
20535
20419
|
return { subject: record.subject, authority: record.authority };
|
|
20536
20420
|
}
|
|
20537
|
-
function
|
|
20538
|
-
const
|
|
20539
|
-
if (!head.startsWith("{")) return void 0;
|
|
20540
|
-
try {
|
|
20541
|
-
const parsed = JSON.parse(head);
|
|
20542
|
-
if (!isRecord(parsed)) return void 0;
|
|
20543
|
-
return parsed;
|
|
20544
|
-
} catch {
|
|
20545
|
-
return void 0;
|
|
20546
|
-
}
|
|
20547
|
-
}
|
|
20548
|
-
function workContextPathFromPrompt(prompt) {
|
|
20549
|
-
const record = jsonObjectFromPrompt(prompt);
|
|
20550
|
-
const path = record?.workContextPath;
|
|
20551
|
-
if (typeof path !== "string" || path.trim() === "") return void 0;
|
|
20552
|
-
return isNavigatorWorkContextFile(path) ? path : void 0;
|
|
20553
|
-
}
|
|
20554
|
-
function attachWorkContextPointer(text, workContextPath) {
|
|
20555
|
-
const record = jsonObjectFromPrompt(text);
|
|
20556
|
-
if (record === void 0) return text;
|
|
20557
|
-
if (typeof record.workContextPath === "string" && record.workContextPath.trim() !== "") return text;
|
|
20558
|
-
const head = text.trimStart().split("\n\n", 1)[0] ?? "";
|
|
20559
|
-
const rest = text.trimStart().slice(head.length);
|
|
20560
|
-
return `${JSON.stringify({ ...record, workContextPath })}${rest}`;
|
|
20561
|
-
}
|
|
20562
|
-
async function loadNavigatorWorkBaseSuffix(prompt) {
|
|
20563
|
-
const path = workContextPathFromPrompt(prompt);
|
|
20421
|
+
async function loadNavigatorWorkBaseSuffix(sessionDir, locatorPath) {
|
|
20422
|
+
const path = typeof locatorPath === "string" && locatorPath.trim() !== "" ? locatorPath.trim() : typeof process.env[AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV] === "string" && process.env[AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV].trim() !== "" ? process.env[AK_ROLE_NAVIGATOR_WORK_CONTEXT_ENV].trim() : sessionDir !== void 0 && sessionDir.trim() !== "" ? navigatorWorkContextFile(sessionDir) : void 0;
|
|
20564
20423
|
if (path === void 0) return void 0;
|
|
20565
20424
|
const body = await readNavigatorWorkBase(path);
|
|
20566
20425
|
if (body === void 0) return void 0;
|
|
@@ -20653,13 +20512,14 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
20653
20512
|
if (disposed) return;
|
|
20654
20513
|
const resumeRunId = hostRunId;
|
|
20655
20514
|
const workContextPath = navigatorWorkContextFile(sessionManager.getSessionDir());
|
|
20656
|
-
const
|
|
20515
|
+
const workContextLocator = existsSync12(workContextPath) ? workContextPath : void 0;
|
|
20657
20516
|
const baseSummon = {
|
|
20658
20517
|
role: "navigator",
|
|
20659
|
-
argv: [
|
|
20518
|
+
argv: [text],
|
|
20660
20519
|
cwd: context.cwd,
|
|
20661
20520
|
...summonHome === void 0 ? {} : { home: summonHome },
|
|
20662
|
-
...context.signal === void 0 ? {} : { signal: context.signal }
|
|
20521
|
+
...context.signal === void 0 ? {} : { signal: context.signal },
|
|
20522
|
+
...workContextLocator === void 0 ? {} : { navigatorWorkContextPath: workContextLocator }
|
|
20663
20523
|
};
|
|
20664
20524
|
const resumable = deps?.hostRunResumable ?? navigatorHostRunResumable;
|
|
20665
20525
|
let summoned;
|
|
@@ -20787,8 +20647,8 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
|
|
|
20787
20647
|
return void 0;
|
|
20788
20648
|
}
|
|
20789
20649
|
var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
|
|
20790
|
-
var prepareSchema =
|
|
20791
|
-
prose:
|
|
20650
|
+
var prepareSchema = Type17.Object({
|
|
20651
|
+
prose: Type17.Optional(Type17.Unknown({
|
|
20792
20652
|
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
|
|
20793
20653
|
}))
|
|
20794
20654
|
}, { additionalProperties: true });
|
|
@@ -21329,22 +21189,22 @@ init_submission_ledger();
|
|
|
21329
21189
|
init_filed_submission();
|
|
21330
21190
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
21331
21191
|
import { writeSync as writeSync2 } from "node:fs";
|
|
21332
|
-
import { join as
|
|
21333
|
-
import { Value as
|
|
21192
|
+
import { join as join33 } from "node:path";
|
|
21193
|
+
import { Value as Value3 } from "typebox/value";
|
|
21334
21194
|
|
|
21335
21195
|
// src/activation-trace.ts
|
|
21336
|
-
import { Type as
|
|
21337
|
-
var causeSchema =
|
|
21338
|
-
identity:
|
|
21339
|
-
name:
|
|
21340
|
-
message:
|
|
21341
|
-
evidenceId:
|
|
21196
|
+
import { Type as Type18 } from "typebox";
|
|
21197
|
+
var causeSchema = Type18.Object({
|
|
21198
|
+
identity: Type18.String({ minLength: 1 }),
|
|
21199
|
+
name: Type18.String({ minLength: 1 }),
|
|
21200
|
+
message: Type18.String(),
|
|
21201
|
+
evidenceId: Type18.Optional(Type18.String({ minLength: 1 }))
|
|
21342
21202
|
}, { additionalProperties: false });
|
|
21343
|
-
var activationTraceRecordSchema =
|
|
21344
|
-
role:
|
|
21345
|
-
stageId:
|
|
21346
|
-
status:
|
|
21347
|
-
timestamp:
|
|
21203
|
+
var activationTraceRecordSchema = Type18.Object({
|
|
21204
|
+
role: Type18.String({ minLength: 1 }),
|
|
21205
|
+
stageId: Type18.String({ pattern: "^[a-z][a-z0-9-]*$" }),
|
|
21206
|
+
status: Type18.Literal("failed"),
|
|
21207
|
+
timestamp: Type18.String({ format: "date-time" }),
|
|
21348
21208
|
cause: causeSchema
|
|
21349
21209
|
}, { additionalProperties: false });
|
|
21350
21210
|
var activationCauseEvidence = 0;
|
|
@@ -21509,10 +21369,10 @@ init_engine_material();
|
|
|
21509
21369
|
init_engine_detour();
|
|
21510
21370
|
init_engine_detour_usage();
|
|
21511
21371
|
init_run_terminal_artifacts();
|
|
21512
|
-
import { Type as
|
|
21513
|
-
var engineDetourArgsSchema =
|
|
21372
|
+
import { Type as Type19 } from "typebox";
|
|
21373
|
+
var engineDetourArgsSchema = Type19.Object(
|
|
21514
21374
|
{
|
|
21515
|
-
argv:
|
|
21375
|
+
argv: Type19.Array(Type19.String({ minLength: 1 }), {
|
|
21516
21376
|
minItems: 1,
|
|
21517
21377
|
description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
|
|
21518
21378
|
})
|
|
@@ -21833,6 +21693,24 @@ ${JSON.stringify(catalog)}
|
|
|
21833
21693
|
init_filed_submission();
|
|
21834
21694
|
init_role_submission_declarations();
|
|
21835
21695
|
init_run_ticket_number();
|
|
21696
|
+
|
|
21697
|
+
// src/audited-run-identity.ts
|
|
21698
|
+
init_role_run_placement();
|
|
21699
|
+
import { basename as basename14 } from "node:path";
|
|
21700
|
+
var AUDITED_RUN_IDENTITY_KIND = "audited-run-identity";
|
|
21701
|
+
function auditedRunIdentityFromDirectory(runDirectory) {
|
|
21702
|
+
const parsed = parseRunLeaf(basename14(runDirectory));
|
|
21703
|
+
if (parsed === void 0) return void 0;
|
|
21704
|
+
return formatRunLeaf(parsed.runId, parsed.role);
|
|
21705
|
+
}
|
|
21706
|
+
function auditedRunIdentityMaterial(identity) {
|
|
21707
|
+
return { kind: AUDITED_RUN_IDENTITY_KIND, identity };
|
|
21708
|
+
}
|
|
21709
|
+
function auditedRunIdentityFromParts(runId, role) {
|
|
21710
|
+
return formatRunLeaf(runId, role);
|
|
21711
|
+
}
|
|
21712
|
+
|
|
21713
|
+
// src/notary-role.ts
|
|
21836
21714
|
init_notary_contracts();
|
|
21837
21715
|
function readNotaryTicketFlag(flag) {
|
|
21838
21716
|
if (flag === void 0) return void 0;
|
|
@@ -21850,11 +21728,10 @@ function readNotaryTicketFlag(flag) {
|
|
|
21850
21728
|
}
|
|
21851
21729
|
return n;
|
|
21852
21730
|
}
|
|
21853
|
-
function
|
|
21854
|
-
return
|
|
21855
|
-
sourceRun
|
|
21856
|
-
|
|
21857
|
-
};
|
|
21731
|
+
function projectNotaryAuditedRunIdentity(input) {
|
|
21732
|
+
return auditedRunIdentityMaterial(
|
|
21733
|
+
auditedRunIdentityFromParts(input.sourceRun.runId, input.sourceRun.role)
|
|
21734
|
+
);
|
|
21858
21735
|
}
|
|
21859
21736
|
var NOTARY_SESSION_BOUND_ENTRY = "notary-session-bound";
|
|
21860
21737
|
function projectNotaryBoundFromFlags(getFlag) {
|
|
@@ -21912,9 +21789,8 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
|
|
|
21912
21789
|
baseSystemPrompt: event.systemPrompt,
|
|
21913
21790
|
soul: activation.soul
|
|
21914
21791
|
}),
|
|
21915
|
-
readingMaterial:
|
|
21916
|
-
sourceRun: activation.sourceRun
|
|
21917
|
-
...activation.ticketNumber === void 0 ? {} : { ticketNumber: activation.ticketNumber }
|
|
21792
|
+
readingMaterial: projectNotaryAuditedRunIdentity({
|
|
21793
|
+
sourceRun: activation.sourceRun
|
|
21918
21794
|
})
|
|
21919
21795
|
};
|
|
21920
21796
|
});
|
|
@@ -21994,6 +21870,7 @@ init_role_submission_declarations();
|
|
|
21994
21870
|
var AUDITOR_TOOL_SPEC = roleSubmissionDeclaration("auditor");
|
|
21995
21871
|
|
|
21996
21872
|
// src/role-runtime.ts
|
|
21873
|
+
init_auditor_soul();
|
|
21997
21874
|
init_navigator_invocation_identity();
|
|
21998
21875
|
init_settlement();
|
|
21999
21876
|
init_packaged_role_registry();
|
|
@@ -22033,7 +21910,6 @@ init_worker_output();
|
|
|
22033
21910
|
init_fixer_output();
|
|
22034
21911
|
init_filed_submission();
|
|
22035
21912
|
init_role_submission_declarations();
|
|
22036
|
-
init_fixer_packet();
|
|
22037
21913
|
|
|
22038
21914
|
// src/worker-submission-gates.ts
|
|
22039
21915
|
init_archivist_record_entry();
|
|
@@ -22323,20 +22199,6 @@ function fixerBashSeatbeltDenyReason(matched) {
|
|
|
22323
22199
|
init_unknown_value();
|
|
22324
22200
|
init_worker_output();
|
|
22325
22201
|
var FIXER_FLAG_DEFINITIONS = {
|
|
22326
|
-
packet: {
|
|
22327
|
-
name: "ak-fix-packet",
|
|
22328
|
-
definition: {
|
|
22329
|
-
description: "Path to opaque prose instructions for the Fixer",
|
|
22330
|
-
type: "string"
|
|
22331
|
-
}
|
|
22332
|
-
},
|
|
22333
|
-
prerequisites: {
|
|
22334
|
-
name: "ak-fixer-prerequisites",
|
|
22335
|
-
definition: {
|
|
22336
|
-
description: "Optional path to a JSON array of typed Fixer prerequisites",
|
|
22337
|
-
type: "string"
|
|
22338
|
-
}
|
|
22339
|
-
},
|
|
22340
22202
|
phase: {
|
|
22341
22203
|
name: "ak-fixer-phase",
|
|
22342
22204
|
definition: {
|
|
@@ -22395,22 +22257,11 @@ function assertAcceptableThroughHost(submissionGate, status, details, hostAction
|
|
|
22395
22257
|
}
|
|
22396
22258
|
function createFixerRoleRuntime(pi, dependencies, hostActions, options) {
|
|
22397
22259
|
let soul;
|
|
22398
|
-
let packet;
|
|
22399
|
-
let packetPath;
|
|
22400
|
-
let prerequisitesPath;
|
|
22401
22260
|
let phase;
|
|
22402
22261
|
let lifecycleRegistered = false;
|
|
22403
22262
|
const submissionGate = createWorkerSubmissionGate({
|
|
22404
22263
|
unfinishedReasonBounceLimit: options?.unfinishedReasonBounceLimit ?? deliveryLimitFromEnv(process.env)
|
|
22405
22264
|
});
|
|
22406
|
-
pi.registerFlag(
|
|
22407
|
-
FIXER_FLAG_DEFINITIONS.packet.name,
|
|
22408
|
-
FIXER_FLAG_DEFINITIONS.packet.definition
|
|
22409
|
-
);
|
|
22410
|
-
pi.registerFlag(
|
|
22411
|
-
FIXER_FLAG_DEFINITIONS.prerequisites.name,
|
|
22412
|
-
FIXER_FLAG_DEFINITIONS.prerequisites.definition
|
|
22413
|
-
);
|
|
22414
22265
|
pi.registerFlag(
|
|
22415
22266
|
FIXER_FLAG_DEFINITIONS.phase.name,
|
|
22416
22267
|
FIXER_FLAG_DEFINITIONS.phase.definition
|
|
@@ -22426,29 +22277,11 @@ function createFixerRoleRuntime(pi, dependencies, hostActions, options) {
|
|
|
22426
22277
|
);
|
|
22427
22278
|
}
|
|
22428
22279
|
phase = selectedPhase;
|
|
22429
|
-
const resolvedPacketPath = pi.getFlag(FIXER_FLAG_DEFINITIONS.packet.name);
|
|
22430
|
-
if (typeof resolvedPacketPath !== "string" || resolvedPacketPath.trim().length === 0) {
|
|
22431
|
-
throw new Error("Fixer role requires --ak-fix-packet");
|
|
22432
|
-
}
|
|
22433
|
-
packetPath = resolvedPacketPath;
|
|
22434
|
-
const instructions = await dependencies.loadPacket(packetPath);
|
|
22435
|
-
if (instructions.trim().length === 0) {
|
|
22436
|
-
throw new FixerPacketValidationError(
|
|
22437
|
-
new Error("Fixer instructions must be nonblank")
|
|
22438
|
-
);
|
|
22439
|
-
}
|
|
22440
|
-
const resolvedPrerequisitesPath = pi.getFlag(FIXER_FLAG_DEFINITIONS.prerequisites.name);
|
|
22441
|
-
if (resolvedPrerequisitesPath !== void 0 && (typeof resolvedPrerequisitesPath !== "string" || resolvedPrerequisitesPath.trim().length === 0)) {
|
|
22442
|
-
throw new Error("Fixer --ak-fixer-prerequisites path must be nonblank when supplied");
|
|
22443
|
-
}
|
|
22444
|
-
prerequisitesPath = typeof resolvedPrerequisitesPath === "string" ? resolvedPrerequisitesPath : void 0;
|
|
22445
|
-
const prerequisites = prerequisitesPath !== void 0 ? parseFixerPrerequisites(await dependencies.loadPacket(prerequisitesPath)) : Object.freeze([]);
|
|
22446
|
-
packet = Object.freeze({ instructions, prerequisites });
|
|
22447
22280
|
if (!lifecycleRegistered) {
|
|
22448
22281
|
lifecycleRegistered = true;
|
|
22449
22282
|
registerWorkerSubmission(pi, "fixer", {
|
|
22450
|
-
notReady: "\u4FEE\u5185\u53F8\
|
|
22451
|
-
ready: () =>
|
|
22283
|
+
notReady: "\u4FEE\u5185\u53F8\u9636\u6BB5\u672A\u88C5\u8F7D",
|
|
22284
|
+
ready: () => phase !== void 0,
|
|
22452
22285
|
phase: () => phase,
|
|
22453
22286
|
project: (parameters, current) => deepFreeze2(validateFixerOutput(parameters, current)),
|
|
22454
22287
|
submissionGate,
|
|
@@ -22467,12 +22300,6 @@ function createFixerRoleRuntime(pi, dependencies, hostActions, options) {
|
|
|
22467
22300
|
});
|
|
22468
22301
|
pi.on("before_agent_start", (event) => {
|
|
22469
22302
|
if (soul === void 0) throw new Error("\u4FEE\u5185\u53F8\u804C\u5206\u672A\u88C5\u8F7D");
|
|
22470
|
-
if (packetPath === void 0) throw new Error("\u4FEE\u5185\u53F8\u4FEE\u7406\u5305\u8DEF\u5F84\u672A\u88C5\u8F7D");
|
|
22471
|
-
const prerequisitesBlock = prerequisitesPath === void 0 ? "" : `
|
|
22472
|
-
|
|
22473
|
-
<fixer_prerequisites_path>
|
|
22474
|
-
${prerequisitesPath}
|
|
22475
|
-
</fixer_prerequisites_path>`;
|
|
22476
22303
|
return {
|
|
22477
22304
|
systemPrompt: `${event.systemPrompt}
|
|
22478
22305
|
|
|
@@ -22482,11 +22309,7 @@ ${soul}
|
|
|
22482
22309
|
|
|
22483
22310
|
<fixer_phase>
|
|
22484
22311
|
${phase ?? ""}
|
|
22485
|
-
</fixer_phase
|
|
22486
|
-
|
|
22487
|
-
<fix_packet_path>
|
|
22488
|
-
${packetPath}
|
|
22489
|
-
</fix_packet_path>${prerequisitesBlock}`
|
|
22312
|
+
</fixer_phase>`
|
|
22490
22313
|
};
|
|
22491
22314
|
});
|
|
22492
22315
|
}
|
|
@@ -22498,22 +22321,17 @@ ${packetPath}
|
|
|
22498
22321
|
}
|
|
22499
22322
|
function createCoderRoleRuntime(pi, dependencies, hostActions, options) {
|
|
22500
22323
|
let soul;
|
|
22501
|
-
let task;
|
|
22502
22324
|
let phase;
|
|
22503
22325
|
let lifecycleRegistered = false;
|
|
22504
22326
|
const submissionGate = createWorkerSubmissionGate({
|
|
22505
22327
|
unfinishedReasonBounceLimit: options?.unfinishedReasonBounceLimit ?? deliveryLimitFromEnv(process.env)
|
|
22506
22328
|
});
|
|
22507
|
-
pi.registerFlag("ak-coder-task", {
|
|
22508
|
-
description: "Markdown task assigned to the coder role",
|
|
22509
|
-
type: "string"
|
|
22510
|
-
});
|
|
22511
22329
|
pi.registerFlag("ak-coder-phase", {
|
|
22512
22330
|
description: "Coder phase: plan (inspect and propose an implementation plan; no edits or commits) or apply (execute the approved plan and verify the first implementation)",
|
|
22513
22331
|
type: "string"
|
|
22514
22332
|
});
|
|
22515
22333
|
return {
|
|
22516
|
-
async activate(
|
|
22334
|
+
async activate() {
|
|
22517
22335
|
soul = (await dependencies.loadSoul()).trim();
|
|
22518
22336
|
if (soul.length === 0) throw new Error("Coder soul is empty");
|
|
22519
22337
|
const selectedPhase = pi.getFlag("ak-coder-phase");
|
|
@@ -22523,23 +22341,17 @@ function createCoderRoleRuntime(pi, dependencies, hostActions, options) {
|
|
|
22523
22341
|
);
|
|
22524
22342
|
}
|
|
22525
22343
|
phase = selectedPhase;
|
|
22526
|
-
const taskPath = pi.getFlag("ak-coder-task");
|
|
22527
|
-
if (typeof taskPath !== "string" || taskPath.trim().length === 0) {
|
|
22528
|
-
throw new Error("Coder role requires --ak-coder-task");
|
|
22529
|
-
}
|
|
22530
|
-
task = (await dependencies.loadTask(taskPath)).trim();
|
|
22531
|
-
if (task.length === 0) throw new Error("Coder task is empty");
|
|
22532
22344
|
if (!lifecycleRegistered) {
|
|
22533
22345
|
lifecycleRegistered = true;
|
|
22534
22346
|
registerWorkerSubmission(pi, "coder", {
|
|
22535
|
-
notReady: "\u5C06\u4F5C\u76D1\
|
|
22536
|
-
ready: () =>
|
|
22347
|
+
notReady: "\u5C06\u4F5C\u76D1\u9636\u6BB5\u672A\u88C5\u8F7D",
|
|
22348
|
+
ready: () => phase !== void 0,
|
|
22537
22349
|
phase: () => phase,
|
|
22538
22350
|
project: (parameters, current) => validateWorkerOutput(parameters, current, "Coder"),
|
|
22539
22351
|
submissionGate,
|
|
22540
22352
|
hostActions
|
|
22541
22353
|
});
|
|
22542
|
-
pi.on("before_agent_start", (event
|
|
22354
|
+
pi.on("before_agent_start", (event) => {
|
|
22543
22355
|
if (soul === void 0) throw new Error("\u5C06\u4F5C\u76D1\u804C\u5206\u672A\u88C5\u8F7D");
|
|
22544
22356
|
return {
|
|
22545
22357
|
systemPrompt: `${event.systemPrompt}
|
|
@@ -22550,11 +22362,7 @@ ${soul}
|
|
|
22550
22362
|
|
|
22551
22363
|
<coder_phase>
|
|
22552
22364
|
${phase ?? ""}
|
|
22553
|
-
</coder_phase
|
|
22554
|
-
|
|
22555
|
-
<coder_task>
|
|
22556
|
-
${task ?? ""}
|
|
22557
|
-
</coder_task>`
|
|
22365
|
+
</coder_phase>`
|
|
22558
22366
|
};
|
|
22559
22367
|
});
|
|
22560
22368
|
}
|
|
@@ -22599,7 +22407,16 @@ function createMergerRoleRuntime(pi, dependencies) {
|
|
|
22599
22407
|
});
|
|
22600
22408
|
pi.on("before_agent_start", (event) => {
|
|
22601
22409
|
if (!activation) throw new Error("\u6821\u4E66\u90CE\u672A\u6FC0\u6D3B");
|
|
22602
|
-
const admitted = {
|
|
22410
|
+
const admitted = {
|
|
22411
|
+
attemptId: activation.input.attemptId,
|
|
22412
|
+
targetObjectId: activation.input.targetObjectId,
|
|
22413
|
+
sourceObjectId: activation.input.sourceObjectId,
|
|
22414
|
+
targetIntent: materialText(activation.input, "targetIntent"),
|
|
22415
|
+
sourceIntent: materialText(activation.input, "sourceIntent"),
|
|
22416
|
+
expectedConflictPaths: activation.input.expectedConflictPaths,
|
|
22417
|
+
resolutionScope: activation.input.resolutionScope,
|
|
22418
|
+
authorizedChecks: activation.input.authorizedChecks
|
|
22419
|
+
};
|
|
22603
22420
|
return { systemPrompt: `${event.systemPrompt}
|
|
22604
22421
|
|
|
22605
22422
|
<merger_soul>
|
|
@@ -22630,7 +22447,6 @@ init_doctor_evidence();
|
|
|
22630
22447
|
init_judge_role();
|
|
22631
22448
|
init_engine_detour();
|
|
22632
22449
|
init_fixer_output();
|
|
22633
|
-
init_fixer_packet();
|
|
22634
22450
|
init_auditor_soul();
|
|
22635
22451
|
init_judge_auditor();
|
|
22636
22452
|
init_doctor_auditor();
|
|
@@ -22742,7 +22558,7 @@ function activationStage(role, activate) {
|
|
|
22742
22558
|
};
|
|
22743
22559
|
}
|
|
22744
22560
|
function validateActivationTraceRecord(record) {
|
|
22745
|
-
if (!
|
|
22561
|
+
if (!Value3.Check(activationTraceRecordSchema, record)) {
|
|
22746
22562
|
throw new TypeError("Activation trace record does not match its closed contract");
|
|
22747
22563
|
}
|
|
22748
22564
|
return record;
|
|
@@ -22944,7 +22760,7 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
|
|
|
22944
22760
|
playbookBound = true;
|
|
22945
22761
|
const loadRoutePlaybook = dependencies.loadRoutePlaybook ?? (() => readPackageMaterial("resources/navigator-route-playbook.md"));
|
|
22946
22762
|
let playbookRead;
|
|
22947
|
-
roleHost.on("before_agent_start", async (event) => {
|
|
22763
|
+
roleHost.on("before_agent_start", async (event, ctx) => {
|
|
22948
22764
|
const basePrompt = typeof event.systemPrompt === "string" ? event.systemPrompt : "";
|
|
22949
22765
|
const parts = [];
|
|
22950
22766
|
try {
|
|
@@ -22959,8 +22775,10 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
|
|
|
22959
22775
|
parts.push(message);
|
|
22960
22776
|
}
|
|
22961
22777
|
}
|
|
22962
|
-
const
|
|
22963
|
-
|
|
22778
|
+
const work = await loadNavigatorWorkBaseSuffix(
|
|
22779
|
+
ctx.sessionManager?.getSessionDir?.(),
|
|
22780
|
+
ctx.navigatorWorkContextPath
|
|
22781
|
+
);
|
|
22964
22782
|
if (work !== void 0 && work.trim() !== "") parts.push(work);
|
|
22965
22783
|
if (parts.length === 0) return;
|
|
22966
22784
|
const text = parts.join("\n\n");
|
|
@@ -22974,7 +22792,7 @@ ${text}`
|
|
|
22974
22792
|
};
|
|
22975
22793
|
}
|
|
22976
22794
|
function createAuditorRoleRuntime(roleHost, dependencies) {
|
|
22977
|
-
|
|
22795
|
+
return createFiledOfficerRuntime(
|
|
22978
22796
|
roleHost,
|
|
22979
22797
|
{
|
|
22980
22798
|
role: "auditor",
|
|
@@ -22983,17 +22801,27 @@ function createAuditorRoleRuntime(roleHost, dependencies) {
|
|
|
22983
22801
|
},
|
|
22984
22802
|
dependencies
|
|
22985
22803
|
);
|
|
22986
|
-
|
|
22987
|
-
|
|
22988
|
-
|
|
22989
|
-
|
|
22990
|
-
|
|
22991
|
-
|
|
22992
|
-
|
|
22993
|
-
|
|
22994
|
-
|
|
22804
|
+
}
|
|
22805
|
+
function isAuditedIdentitySeat(role) {
|
|
22806
|
+
return role === "notary" || role === "inspector" || role === "auditor" || role === "countersign";
|
|
22807
|
+
}
|
|
22808
|
+
function resolveAuditedSourceRunDirectory(roleHost, ctx, role) {
|
|
22809
|
+
const notary = roleHost.getFlag(NOTARY_SOURCE_RUN_FLAG.name);
|
|
22810
|
+
if (typeof notary === "string" && notary.trim() !== "") return notary.trim();
|
|
22811
|
+
const inspector = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
|
|
22812
|
+
if (typeof inspector === "string" && inspector.trim() !== "") return inspector.trim();
|
|
22813
|
+
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
22814
|
+
if (runDirectory !== void 0) {
|
|
22815
|
+
const admitted = readPageSync(runDirectory, "admitted");
|
|
22816
|
+
if (typeof admitted?.sourceRunPath === "string" && admitted.sourceRunPath.trim() !== "") {
|
|
22817
|
+
return admitted.sourceRunPath.trim();
|
|
22995
22818
|
}
|
|
22996
|
-
}
|
|
22819
|
+
}
|
|
22820
|
+
if (role === "auditor") {
|
|
22821
|
+
const auditor = typeof process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV] === "string" ? process.env[AK_ROLE_AUDITOR_SOURCE_RUN_ENV].trim() : "";
|
|
22822
|
+
if (auditor !== "") return auditor;
|
|
22823
|
+
}
|
|
22824
|
+
return void 0;
|
|
22997
22825
|
}
|
|
22998
22826
|
function readDiaristTicketAssertion(submitted) {
|
|
22999
22827
|
if (submitted === void 0 || !("ticketNumber" in submitted)) {
|
|
@@ -23010,7 +22838,7 @@ function readRoleRunCoordinates(ctx, label) {
|
|
|
23010
22838
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23011
22839
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
23012
22840
|
if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23013
|
-
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${
|
|
22841
|
+
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join33(runDirectory, RUN_STATE_FILE)})`);
|
|
23014
22842
|
}
|
|
23015
22843
|
return {
|
|
23016
22844
|
runDirectory,
|
|
@@ -23335,15 +23163,14 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23335
23163
|
if (reading === void 0) return;
|
|
23336
23164
|
return { readingMaterial: reading };
|
|
23337
23165
|
});
|
|
23338
|
-
roleHost.on("before_agent_start", () => {
|
|
23339
|
-
const
|
|
23340
|
-
if (typeof
|
|
23341
|
-
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
|
|
23345
|
-
|
|
23346
|
-
};
|
|
23166
|
+
roleHost.on("before_agent_start", (_event, ctx) => {
|
|
23167
|
+
const role = selectedRole ?? roleHost.getFlag(ROLE_FLAG.name);
|
|
23168
|
+
if (typeof role !== "string" || !isAuditedIdentitySeat(role) || role === "notary") return;
|
|
23169
|
+
const sourceDirectory = resolveAuditedSourceRunDirectory(roleHost, ctx, role);
|
|
23170
|
+
if (sourceDirectory === void 0) return;
|
|
23171
|
+
const identity = auditedRunIdentityFromDirectory(sourceDirectory);
|
|
23172
|
+
if (identity === void 0) return;
|
|
23173
|
+
return { readingMaterial: auditedRunIdentityMaterial(identity) };
|
|
23347
23174
|
});
|
|
23348
23175
|
roleHost.on("tool_result", async (event, ctx) => {
|
|
23349
23176
|
const role = selectedRole;
|
|
@@ -23525,13 +23352,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23525
23352
|
const fixer = createFixerRoleRuntime(
|
|
23526
23353
|
roleHost,
|
|
23527
23354
|
{
|
|
23528
|
-
loadSoul: () => requireRoleSoul("fixer")
|
|
23529
|
-
async loadPacket(path) {
|
|
23530
|
-
if (dependencies.loadFixPacket === void 0) {
|
|
23531
|
-
throw new Error("Fixer packet loader is not configured");
|
|
23532
|
-
}
|
|
23533
|
-
return dependencies.loadFixPacket(path);
|
|
23534
|
-
}
|
|
23355
|
+
loadSoul: () => requireRoleSoul("fixer")
|
|
23535
23356
|
},
|
|
23536
23357
|
hostActions,
|
|
23537
23358
|
{ unfinishedReasonBounceLimit: deliveryLimit }
|
|
@@ -23539,13 +23360,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23539
23360
|
const coder = createCoderRoleRuntime(
|
|
23540
23361
|
roleHost,
|
|
23541
23362
|
{
|
|
23542
|
-
loadSoul: () => requireRoleSoul("coder")
|
|
23543
|
-
async loadTask(path) {
|
|
23544
|
-
if (dependencies.loadCoderTask === void 0) {
|
|
23545
|
-
throw new Error("Coder task loader is not configured");
|
|
23546
|
-
}
|
|
23547
|
-
return dependencies.loadCoderTask(path);
|
|
23548
|
-
}
|
|
23363
|
+
loadSoul: () => requireRoleSoul("coder")
|
|
23549
23364
|
},
|
|
23550
23365
|
hostActions,
|
|
23551
23366
|
{ unfinishedReasonBounceLimit: deliveryLimit }
|
|
@@ -23860,8 +23675,6 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
23860
23675
|
packageRoot,
|
|
23861
23676
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
23862
23677
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
23863
|
-
loadFixPacket: (path) => readFile17(path, "utf8"),
|
|
23864
|
-
loadCoderTask: (path) => readFile17(path, "utf8"),
|
|
23865
23678
|
loadDoctorCase,
|
|
23866
23679
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
23867
23680
|
loadMergerInput: async (path) => JSON.parse(await readFile17(path, "utf8")),
|
|
@@ -23990,6 +23803,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
23990
23803
|
...request.courtAttemptId === void 0 ? {} : { courtAttemptId: request.courtAttemptId },
|
|
23991
23804
|
...request.invocationScopeId === void 0 ? {} : { invocationScopeId: request.invocationScopeId },
|
|
23992
23805
|
...request.host === void 0 || request.host.trim() === "" ? {} : { host: request.host.trim() },
|
|
23806
|
+
...request.navigatorWorkContextPath === void 0 || request.navigatorWorkContextPath.trim() === "" ? {} : { navigatorWorkContextPath: request.navigatorWorkContextPath },
|
|
23993
23807
|
sessionManager: {
|
|
23994
23808
|
getLeafEntry: () => sessionEntries.at(-1),
|
|
23995
23809
|
getLeafId: () => runId,
|
|
@@ -24476,7 +24290,7 @@ import { randomUUID as randomUUID9 } from "node:crypto";
|
|
|
24476
24290
|
import { existsSync as existsSync14 } from "node:fs";
|
|
24477
24291
|
import { mkdtemp, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
|
|
24478
24292
|
import { tmpdir } from "node:os";
|
|
24479
|
-
import { dirname as dirname22, isAbsolute as isAbsolute11, join as
|
|
24293
|
+
import { dirname as dirname22, isAbsolute as isAbsolute11, join as join34, resolve as resolve20 } from "node:path";
|
|
24480
24294
|
|
|
24481
24295
|
// src/external-host-turn-loop.ts
|
|
24482
24296
|
init_settlement();
|
|
@@ -25015,7 +24829,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
25015
24829
|
function cwdIsGitWorkTree(cwd) {
|
|
25016
24830
|
let dir = cwd;
|
|
25017
24831
|
for (; ; ) {
|
|
25018
|
-
if (existsSync14(
|
|
24832
|
+
if (existsSync14(join34(dir, ".git"))) return true;
|
|
25019
24833
|
const parent = dirname22(dir);
|
|
25020
24834
|
if (parent === dir) return false;
|
|
25021
24835
|
dir = parent;
|
|
@@ -25233,8 +25047,8 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25233
25047
|
}
|
|
25234
25048
|
const env = { ...process.env, ...config.env ?? {} };
|
|
25235
25049
|
const sessionParent = config.sessionIdentity.resolveSessionFile(request.principal);
|
|
25236
|
-
const inputsDirectory = await mkdtemp(
|
|
25237
|
-
const systemPromptPath =
|
|
25050
|
+
const inputsDirectory = await mkdtemp(join34(tmpdir(), "ak-role-headless-"));
|
|
25051
|
+
const systemPromptPath = join34(inputsDirectory, "system-prompt.txt");
|
|
25238
25052
|
let mcpConfigPath;
|
|
25239
25053
|
let outputSchemaPath;
|
|
25240
25054
|
let startedWithSchema;
|
|
@@ -25243,13 +25057,13 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25243
25057
|
let deliveredSchema;
|
|
25244
25058
|
if (codex) {
|
|
25245
25059
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
25246
|
-
outputSchemaPath =
|
|
25060
|
+
outputSchemaPath = join34(inputsDirectory, "output-schema.json");
|
|
25247
25061
|
deliveredSchema = closeJsonSchemaForCodex(prepared.jsonSchema);
|
|
25248
25062
|
await writeFile6(outputSchemaPath, `${JSON.stringify(deliveredSchema, null, 2)}
|
|
25249
25063
|
`, "utf8");
|
|
25250
25064
|
}
|
|
25251
25065
|
} else {
|
|
25252
|
-
mcpConfigPath =
|
|
25066
|
+
mcpConfigPath = join34(inputsDirectory, "mcp-config.json");
|
|
25253
25067
|
await writeFile6(
|
|
25254
25068
|
mcpConfigPath,
|
|
25255
25069
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|