@akagilnc/pi-workflow-roles 0.1.3377 → 0.1.3384
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auditor-dossier-tool.js +51 -2
- package/dist/gatekeeper-role.js +11 -11
- package/dist/grok/production-host.js +119 -182
- package/dist/public-cli/main.js +2 -5
- package/package.json +1 -1
- package/src/auditor-dossier-tool.ts +72 -2
- package/src/gatekeeper-role.ts +23 -15
- package/src/grok/role-envelope.ts +6 -7
- package/src/host-contracts.ts +1 -2
- package/src/judge-role.ts +1 -1
- package/src/pi/role-turn-host.ts +2 -7
- package/src/role-runtime.ts +4 -143
- package/src/worker-role.ts +19 -8
|
@@ -97,7 +97,7 @@ var init_activation_ledger_git = __esm({
|
|
|
97
97
|
// src/activation-ledger-topology.ts
|
|
98
98
|
import {
|
|
99
99
|
lstatSync,
|
|
100
|
-
mkdirSync,
|
|
100
|
+
mkdirSync as mkdirSync2,
|
|
101
101
|
realpathSync,
|
|
102
102
|
statSync
|
|
103
103
|
} from "node:fs";
|
|
@@ -185,7 +185,7 @@ function assertPhysicalLedgerRoot(absoluteRoot) {
|
|
|
185
185
|
}
|
|
186
186
|
if (st === void 0) {
|
|
187
187
|
try {
|
|
188
|
-
|
|
188
|
+
mkdirSync2(absoluteRoot, { recursive: true });
|
|
189
189
|
} catch (error) {
|
|
190
190
|
if (errnoCode(error) !== "EEXIST") {
|
|
191
191
|
throw new ActivationLedgerError(
|
|
@@ -261,7 +261,7 @@ function ensureRealDirectoryTree(root, targetDir) {
|
|
|
261
261
|
);
|
|
262
262
|
}
|
|
263
263
|
try {
|
|
264
|
-
|
|
264
|
+
mkdirSync2(lexicalCursor);
|
|
265
265
|
} catch (mkdirError) {
|
|
266
266
|
if (errnoCode(mkdirError) !== "EEXIST") {
|
|
267
267
|
throw new ActivationLedgerError(
|
|
@@ -376,7 +376,7 @@ __export(archivist_record_entry_exports, {
|
|
|
376
376
|
createRecordSession: () => createRecordSession
|
|
377
377
|
});
|
|
378
378
|
import { createHash as createHash4 } from "node:crypto";
|
|
379
|
-
import { existsSync as existsSync5, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync as
|
|
379
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2, realpathSync as realpathSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
380
380
|
import { dirname as dirname8, resolve as resolve6, join as join10 } from "node:path";
|
|
381
381
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
382
382
|
function readCurrentSession(sessionDir) {
|
|
@@ -397,7 +397,7 @@ function readCurrentSession(sessionDir) {
|
|
|
397
397
|
function writeCurrentSession(sessionDir, sessionFile) {
|
|
398
398
|
const ledger = join10(sessionDir, CURRENT_SESSION_LEDGER);
|
|
399
399
|
try {
|
|
400
|
-
|
|
400
|
+
writeFileSync3(ledger, `${JSON.stringify({ sessionFile })}
|
|
401
401
|
`, { flag: "wx" });
|
|
402
402
|
} catch (error) {
|
|
403
403
|
throw new ActivationLedgerError(
|
|
@@ -477,7 +477,7 @@ function createRecordSession(options) {
|
|
|
477
477
|
if (file !== void 0 && !existsSync5(file)) {
|
|
478
478
|
const header = session.getHeader();
|
|
479
479
|
if (header !== null && header.type === "session") {
|
|
480
|
-
|
|
480
|
+
writeFileSync3(file, `${JSON.stringify(header)}
|
|
481
481
|
`, { flag: "wx" });
|
|
482
482
|
session.setSessionFile(file);
|
|
483
483
|
}
|
|
@@ -1771,15 +1771,47 @@ ${marker}
|
|
|
1771
1771
|
}
|
|
1772
1772
|
|
|
1773
1773
|
// src/auditor-dossier-tool.ts
|
|
1774
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
1774
1775
|
import { dirname as dirname2, join, resolve as resolve2 } from "node:path";
|
|
1775
1776
|
import { Type } from "typebox";
|
|
1776
1777
|
var AUDITOR_DOSSIER_TOOL_NAME = "ak_get_run_dossier";
|
|
1778
|
+
var GATE_SUBMISSION_CANDIDATE_FILE = "gate-submission-candidate.json";
|
|
1779
|
+
function isRecord2(value) {
|
|
1780
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1781
|
+
}
|
|
1777
1782
|
function auditorRunDirectory(context) {
|
|
1778
1783
|
const sessionFile = context.sessionManager?.getSessionFile?.();
|
|
1779
1784
|
if (sessionFile === void 0) return void 0;
|
|
1780
1785
|
return resolve2(dirname2(dirname2(sessionFile)));
|
|
1781
1786
|
}
|
|
1782
|
-
function
|
|
1787
|
+
function readLatestToolCallLeaf(context) {
|
|
1788
|
+
const entries = [...context.sessionManager?.getEntries?.() ?? []];
|
|
1789
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
1790
|
+
const entry = entries[i];
|
|
1791
|
+
if (!isRecord2(entry) || entry.type !== "message" || !isRecord2(entry.message)) continue;
|
|
1792
|
+
const message = entry.message;
|
|
1793
|
+
if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
1794
|
+
for (const part of message.content) {
|
|
1795
|
+
if (isRecord2(part) && part.type === "toolCall") {
|
|
1796
|
+
return entry;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
return void 0;
|
|
1801
|
+
}
|
|
1802
|
+
function gateSubmissionCandidatePath(runDirectory) {
|
|
1803
|
+
return join(runDirectory, "artifacts", GATE_SUBMISSION_CANDIDATE_FILE);
|
|
1804
|
+
}
|
|
1805
|
+
function persistGateSubmissionCandidate(runDirectory, context) {
|
|
1806
|
+
const leaf = readLatestToolCallLeaf(context);
|
|
1807
|
+
if (leaf === void 0) return void 0;
|
|
1808
|
+
const path = gateSubmissionCandidatePath(runDirectory);
|
|
1809
|
+
mkdirSync(dirname2(path), { recursive: true });
|
|
1810
|
+
writeFileSync(path, `${JSON.stringify(leaf)}
|
|
1811
|
+
`, "utf8");
|
|
1812
|
+
return path;
|
|
1813
|
+
}
|
|
1814
|
+
function createAuditorDossierTool(runDirectory, options) {
|
|
1783
1815
|
return {
|
|
1784
1816
|
name: AUDITOR_DOSSIER_TOOL_NAME,
|
|
1785
1817
|
description: "\u5B9A\u4F4D\u672C\u5BA1\u8BA1\u5E2D\u7ED1\u5B9A\u7684 run \u5377\u5B97\u53CA\u5176\u8BC1\u636E\u5165\u53E3\u3002",
|
|
@@ -1791,12 +1823,15 @@ function createAuditorDossierTool(runDirectory) {
|
|
|
1791
1823
|
details: void 0
|
|
1792
1824
|
};
|
|
1793
1825
|
}
|
|
1826
|
+
const sessionPath = join(runDirectory, "session", "session.jsonl");
|
|
1827
|
+
const submissionCandidate = options?.submissionCandidate;
|
|
1794
1828
|
const details = {
|
|
1795
1829
|
runDirectory,
|
|
1796
1830
|
admittedRequest: join(runDirectory, "admitted-request.json"),
|
|
1797
|
-
parentSessionCandidate:
|
|
1831
|
+
parentSessionCandidate: submissionCandidate ?? sessionPath,
|
|
1798
1832
|
attachments: join(runDirectory, "attachments"),
|
|
1799
|
-
artifacts: join(runDirectory, "artifacts")
|
|
1833
|
+
artifacts: join(runDirectory, "artifacts"),
|
|
1834
|
+
...submissionCandidate === void 0 ? {} : { submissionCandidate }
|
|
1800
1835
|
};
|
|
1801
1836
|
return {
|
|
1802
1837
|
content: [{ type: "text", text: JSON.stringify(details) }],
|
|
@@ -1999,7 +2034,7 @@ var gatekeeperDecisionSchema = openToolObject(
|
|
|
1999
2034
|
var gatekeeperOutputSchema = withInfrastructureFailureDeclaration(
|
|
2000
2035
|
gatekeeperDecisionSchema
|
|
2001
2036
|
);
|
|
2002
|
-
function
|
|
2037
|
+
function isRecord3(value) {
|
|
2003
2038
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2004
2039
|
}
|
|
2005
2040
|
function asStringArray(value) {
|
|
@@ -2007,7 +2042,7 @@ function asStringArray(value) {
|
|
|
2007
2042
|
return value.filter((item) => typeof item === "string");
|
|
2008
2043
|
}
|
|
2009
2044
|
function projectLawfulGatekeeperOutput(value) {
|
|
2010
|
-
if (!
|
|
2045
|
+
if (!isRecord3(value)) return void 0;
|
|
2011
2046
|
if (value.status === "pass") {
|
|
2012
2047
|
return Array.isArray(value.findings) ? { status: "pass", findings: asStringArray(value.findings) } : { status: "pass" };
|
|
2013
2048
|
}
|
|
@@ -2040,13 +2075,13 @@ var navigatorOutputSchema = withInfrastructureFailureDeclaration(
|
|
|
2040
2075
|
})
|
|
2041
2076
|
)
|
|
2042
2077
|
);
|
|
2043
|
-
function
|
|
2078
|
+
function isRecord4(value) {
|
|
2044
2079
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2045
2080
|
}
|
|
2046
2081
|
function projectLawfulNavigatorOutput(value) {
|
|
2047
|
-
if (!
|
|
2082
|
+
if (!isRecord4(value) || !Array.isArray(value.candidates)) return void 0;
|
|
2048
2083
|
if (value.status !== "advice") return void 0;
|
|
2049
|
-
return { status: "advice", candidates: value.candidates.filter(
|
|
2084
|
+
return { status: "advice", candidates: value.candidates.filter(isRecord4) };
|
|
2050
2085
|
}
|
|
2051
2086
|
function validateRecordedNavigatorOutput(value) {
|
|
2052
2087
|
const projected = projectLawfulNavigatorOutput(value);
|
|
@@ -2080,11 +2115,11 @@ function validateAcceptedJudgeDetails(verdict) {
|
|
|
2080
2115
|
// src/package-contracts/reviewer-output.ts
|
|
2081
2116
|
var REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
|
|
2082
2117
|
var REVIEWER_ACCEPTED_TEXT = "\u5FA1\u53F2\u53F0\u56DE\u6267\u5DF2\u63A5\u53D7";
|
|
2083
|
-
function
|
|
2118
|
+
function isRecord5(value) {
|
|
2084
2119
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2085
2120
|
}
|
|
2086
2121
|
function read(value, key) {
|
|
2087
|
-
if (!
|
|
2122
|
+
if (!isRecord5(value)) return void 0;
|
|
2088
2123
|
try {
|
|
2089
2124
|
return value[key];
|
|
2090
2125
|
} catch {
|
|
@@ -2093,7 +2128,7 @@ function read(value, key) {
|
|
|
2093
2128
|
}
|
|
2094
2129
|
function readAmendments(output) {
|
|
2095
2130
|
const amendments = read(output, "amendments");
|
|
2096
|
-
if (!
|
|
2131
|
+
if (!isRecord5(amendments)) return void 0;
|
|
2097
2132
|
const slots = {};
|
|
2098
2133
|
for (const axis of ["standards", "spec"]) {
|
|
2099
2134
|
const value = read(amendments, axis);
|
|
@@ -2123,25 +2158,25 @@ function validateRuntimeReviewerReceipt(output) {
|
|
|
2123
2158
|
const outcomes = read(output, "outcomes");
|
|
2124
2159
|
const legs = read(acceptedBatch, "legs");
|
|
2125
2160
|
if (acceptedBatch !== void 0 || construction !== void 0 || target !== void 0) {
|
|
2126
|
-
if (!
|
|
2161
|
+
if (!isRecord5(acceptedBatch) || !isRecord5(construction) || !isRecord5(target) || !Array.isArray(legs))
|
|
2127
2162
|
throw new Error("Incomplete Reviewer accepted-batch identity");
|
|
2128
2163
|
const objectFormat = read(target, "objectFormat");
|
|
2129
2164
|
const objectId = (value) => typeof value === "string" && new RegExp(objectFormat === "sha1" ? "^[0-9a-f]{40}$" : "^[0-9a-f]{64}$").test(value);
|
|
2130
2165
|
const refs = read(target, "refs");
|
|
2131
2166
|
const skillText = read(read(identities, "canonicalSkill"), "text");
|
|
2132
|
-
if (typeof skillText !== "string" || read(construction, "recipe") !== "reviewer-common-bundle-v1" || objectFormat !== "sha1" && objectFormat !== "sha256" || !objectId(read(target, "targetHead")) || !
|
|
2167
|
+
if (typeof skillText !== "string" || read(construction, "recipe") !== "reviewer-common-bundle-v1" || objectFormat !== "sha1" && objectFormat !== "sha256" || !objectId(read(target, "targetHead")) || !isRecord5(refs) || Object.values(refs).some((ref) => !isRecord5(ref) || !objectId(read(ref, "objectId")) || read(ref, "peeledCommitId") !== null && !objectId(read(ref, "peeledCommitId"))))
|
|
2133
2168
|
throw new Error("Invalid Reviewer construction or target identity");
|
|
2134
2169
|
const expectedAxes = legs.map((leg) => read(leg, "axis"));
|
|
2135
2170
|
if (expectedAxes[0] !== "standards" || expectedAxes.length === 2 && expectedAxes[1] !== "spec" || expectedAxes.length < 1 || expectedAxes.length > 2)
|
|
2136
2171
|
throw new Error("Invalid Reviewer accepted-leg projection");
|
|
2137
|
-
if (!
|
|
2172
|
+
if (!isRecord5(outcomes) || !isRecord5(reports)) throw new Error("Accepted Reviewer batch lacks outcomes or reports");
|
|
2138
2173
|
const outcomeAxes = Object.keys(outcomes).filter((axis) => axis === "standards" || axis === "spec");
|
|
2139
2174
|
if (outcomeAxes.length !== expectedAxes.length || outcomeAxes.some((axis, index) => axis !== expectedAxes[index]))
|
|
2140
2175
|
throw new Error("Reviewer outcomes must exactly cover accepted legs in canonical order");
|
|
2141
2176
|
for (const [index, axisValue] of expectedAxes.entries()) {
|
|
2142
2177
|
const axis = axisValue;
|
|
2143
2178
|
const outcome = read(outcomes, axis);
|
|
2144
|
-
if (!
|
|
2179
|
+
if (!isRecord5(outcome)) throw new Error("Reviewer accepted leg lacks outcome");
|
|
2145
2180
|
const expectedPrompt = read(read(legs[index], "prompt"), "text");
|
|
2146
2181
|
const actualPrompt = read(read(outcome, "prompt"), "text");
|
|
2147
2182
|
if (expectedPrompt !== actualPrompt) throw new Error("Reviewer outcome prompt disagrees with accepted leg");
|
|
@@ -2457,11 +2492,11 @@ var doctorEvidenceReadSchema = Type8.Object({ evidenceId: Type8.String({ minLeng
|
|
|
2457
2492
|
var DoctorSubmissionContractError = class extends Error {
|
|
2458
2493
|
name = "DoctorSubmissionContractError";
|
|
2459
2494
|
};
|
|
2460
|
-
function
|
|
2495
|
+
function isRecord6(value) {
|
|
2461
2496
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2462
2497
|
}
|
|
2463
2498
|
function read2(value, key) {
|
|
2464
|
-
if (!
|
|
2499
|
+
if (!isRecord6(value)) return void 0;
|
|
2465
2500
|
try {
|
|
2466
2501
|
return value[key];
|
|
2467
2502
|
} catch {
|
|
@@ -2540,7 +2575,7 @@ function validateDoctorOutput(value, patient, store) {
|
|
|
2540
2575
|
const targetKey = read2(finding2, "targetKey");
|
|
2541
2576
|
readCitations(read2(finding2, "evidenceIds"), "finding");
|
|
2542
2577
|
const assetEvidence = read2(finding2, "assetEvidence");
|
|
2543
|
-
if (!
|
|
2578
|
+
if (!isRecord6(assetEvidence)) {
|
|
2544
2579
|
assertTarget(targetKey);
|
|
2545
2580
|
continue;
|
|
2546
2581
|
}
|
|
@@ -2708,7 +2743,7 @@ var notaryOutputSchema = withInfrastructureFailureDeclaration(
|
|
|
2708
2743
|
})
|
|
2709
2744
|
)
|
|
2710
2745
|
);
|
|
2711
|
-
function
|
|
2746
|
+
function isRecord7(value) {
|
|
2712
2747
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2713
2748
|
}
|
|
2714
2749
|
function asStringArray2(value) {
|
|
@@ -2716,7 +2751,7 @@ function asStringArray2(value) {
|
|
|
2716
2751
|
return value.filter((item) => typeof item === "string");
|
|
2717
2752
|
}
|
|
2718
2753
|
function projectLawfulNotaryOutput(value) {
|
|
2719
|
-
if (!
|
|
2754
|
+
if (!isRecord7(value)) return void 0;
|
|
2720
2755
|
const status = typeof value.status === "string" ? value.status : void 0;
|
|
2721
2756
|
if (status === "bounce") {
|
|
2722
2757
|
const clone = structuredClone(value);
|
|
@@ -3082,7 +3117,7 @@ import {
|
|
|
3082
3117
|
existsSync as existsSync2,
|
|
3083
3118
|
readFileSync,
|
|
3084
3119
|
unlinkSync,
|
|
3085
|
-
writeFileSync
|
|
3120
|
+
writeFileSync as writeFileSync2
|
|
3086
3121
|
} from "node:fs";
|
|
3087
3122
|
import { basename as basename3, dirname as dirname6, join as join4, resolve as resolve5 } from "node:path";
|
|
3088
3123
|
|
|
@@ -3102,7 +3137,7 @@ var SitianInfrastructureError = class extends Error {
|
|
|
3102
3137
|
};
|
|
3103
3138
|
|
|
3104
3139
|
// src/sitian-appender.ts
|
|
3105
|
-
function
|
|
3140
|
+
function isRecord8(value) {
|
|
3106
3141
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3107
3142
|
}
|
|
3108
3143
|
function errorCodeOf(error) {
|
|
@@ -3113,7 +3148,7 @@ function identityClaimPath(recordFile, identity) {
|
|
|
3113
3148
|
return `${recordFile}.id-${digest}`;
|
|
3114
3149
|
}
|
|
3115
3150
|
function createExclusiveFile(path, contents) {
|
|
3116
|
-
|
|
3151
|
+
writeFileSync2(path, contents, { encoding: "utf8", flag: "wx" });
|
|
3117
3152
|
}
|
|
3118
3153
|
function sealTornTail(recordFile) {
|
|
3119
3154
|
if (!existsSync2(recordFile)) return;
|
|
@@ -3130,7 +3165,7 @@ function findIdentityPointer(recordFile, identity, kind, level) {
|
|
|
3130
3165
|
if (!trimmed) continue;
|
|
3131
3166
|
try {
|
|
3132
3167
|
const parsed = JSON.parse(trimmed);
|
|
3133
|
-
if (
|
|
3168
|
+
if (isRecord8(parsed) && parsed.identity === identity) {
|
|
3134
3169
|
return { identity, recordFile, kind, level };
|
|
3135
3170
|
}
|
|
3136
3171
|
} catch {
|
|
@@ -3309,7 +3344,7 @@ function appendSitianRecord(input) {
|
|
|
3309
3344
|
// src/sitian-reader.ts
|
|
3310
3345
|
import { existsSync as existsSync3 } from "node:fs";
|
|
3311
3346
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
3312
|
-
function
|
|
3347
|
+
function isRecord9(value) {
|
|
3313
3348
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3314
3349
|
}
|
|
3315
3350
|
async function readSitianRecords(recordFile) {
|
|
@@ -3325,7 +3360,7 @@ async function readSitianRecords(recordFile) {
|
|
|
3325
3360
|
if (!line2.trim()) continue;
|
|
3326
3361
|
try {
|
|
3327
3362
|
const parsed = JSON.parse(line2);
|
|
3328
|
-
if (
|
|
3363
|
+
if (isRecord9(parsed)) {
|
|
3329
3364
|
records2.push(parsed);
|
|
3330
3365
|
} else {
|
|
3331
3366
|
const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
|
|
@@ -4891,7 +4926,7 @@ function resolveAuditDossier(env = process.env) {
|
|
|
4891
4926
|
}
|
|
4892
4927
|
return { status: "ok", runDirectory };
|
|
4893
4928
|
}
|
|
4894
|
-
function
|
|
4929
|
+
function isRecord10(value) {
|
|
4895
4930
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4896
4931
|
}
|
|
4897
4932
|
function readJudgeAuditSubjects(context) {
|
|
@@ -4899,15 +4934,15 @@ function readJudgeAuditSubjects(context) {
|
|
|
4899
4934
|
let hasAssignment = false;
|
|
4900
4935
|
let hasCandidate = false;
|
|
4901
4936
|
for (const entry of entries) {
|
|
4902
|
-
if (!
|
|
4937
|
+
if (!isRecord10(entry) || entry.type !== "message" || !isRecord10(entry.message)) continue;
|
|
4903
4938
|
const message = entry.message;
|
|
4904
4939
|
if (message.role === "user") {
|
|
4905
|
-
const text = typeof message.content === "string" ? message.content : Array.isArray(message.content) ? message.content.map((part) =>
|
|
4940
|
+
const text = typeof message.content === "string" ? message.content : Array.isArray(message.content) ? message.content.map((part) => isRecord10(part) && part.type === "text" && typeof part.text === "string" ? part.text : "").join("") : "";
|
|
4906
4941
|
if (text.trim().length > 0) hasAssignment = true;
|
|
4907
4942
|
}
|
|
4908
4943
|
if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
4909
4944
|
for (const part of message.content) {
|
|
4910
|
-
if (
|
|
4945
|
+
if (isRecord10(part) && part.type === "toolCall" && part.name === JUDGE_OUTPUT_TOOL_NAME2 && isRecord10(part.arguments)) {
|
|
4911
4946
|
hasCandidate = true;
|
|
4912
4947
|
}
|
|
4913
4948
|
}
|
|
@@ -4924,7 +4959,7 @@ function readJudgeAuditSubjects(context) {
|
|
|
4924
4959
|
function readDoctorAuditSubjects(context) {
|
|
4925
4960
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
4926
4961
|
for (const entry of entries) {
|
|
4927
|
-
if (
|
|
4962
|
+
if (isRecord10(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
4928
4963
|
return { status: "ok" };
|
|
4929
4964
|
}
|
|
4930
4965
|
}
|
|
@@ -7267,11 +7302,11 @@ function resolvePackagedMethodSkillRoot(packageRoot, name) {
|
|
|
7267
7302
|
function resolvePackagedMethodSkillPath(packageRoot, name) {
|
|
7268
7303
|
return join17(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
|
|
7269
7304
|
}
|
|
7270
|
-
function
|
|
7305
|
+
function isRecord11(value) {
|
|
7271
7306
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7272
7307
|
}
|
|
7273
7308
|
function parseProvenance(raw, expectedName) {
|
|
7274
|
-
if (!
|
|
7309
|
+
if (!isRecord11(raw)) {
|
|
7275
7310
|
throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
|
|
7276
7311
|
}
|
|
7277
7312
|
if (raw.name !== expectedName) {
|
|
@@ -7285,7 +7320,7 @@ function parseProvenance(raw, expectedName) {
|
|
|
7285
7320
|
if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
|
|
7286
7321
|
throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
|
|
7287
7322
|
}
|
|
7288
|
-
if (!
|
|
7323
|
+
if (!isRecord11(raw.upstream)) {
|
|
7289
7324
|
throw new Error(`Packaged method provenance upstream must be an object`);
|
|
7290
7325
|
}
|
|
7291
7326
|
const upstream = raw.upstream;
|
|
@@ -7312,12 +7347,12 @@ function parseProvenance(raw, expectedName) {
|
|
|
7312
7347
|
`Packaged method provenance upstream must include nonblank tag or version`
|
|
7313
7348
|
);
|
|
7314
7349
|
}
|
|
7315
|
-
if (!
|
|
7350
|
+
if (!isRecord11(raw.files)) {
|
|
7316
7351
|
throw new Error(`Packaged method provenance files must be an object`);
|
|
7317
7352
|
}
|
|
7318
7353
|
const files = {};
|
|
7319
7354
|
for (const [rel, entry] of Object.entries(raw.files)) {
|
|
7320
|
-
if (!
|
|
7355
|
+
if (!isRecord11(entry)) {
|
|
7321
7356
|
throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
|
|
7322
7357
|
}
|
|
7323
7358
|
if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
|
|
@@ -7766,8 +7801,7 @@ function createPerDispatchReviewerAgent(dependencies = {}) {
|
|
|
7766
7801
|
}
|
|
7767
7802
|
|
|
7768
7803
|
// src/role-runtime.ts
|
|
7769
|
-
import {
|
|
7770
|
-
import { join as pathJoin } from "node:path";
|
|
7804
|
+
import { writeSync as writeSync4 } from "node:fs";
|
|
7771
7805
|
|
|
7772
7806
|
// src/host-contracts.ts
|
|
7773
7807
|
import { Type as Type15 } from "typebox";
|
|
@@ -7791,7 +7825,7 @@ function stringEnum(values, options = {}) {
|
|
|
7791
7825
|
}
|
|
7792
7826
|
|
|
7793
7827
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
7794
|
-
import { writeFileSync as
|
|
7828
|
+
import { writeFileSync as writeFileSync4 } from "node:fs";
|
|
7795
7829
|
import { join as join19 } from "node:path";
|
|
7796
7830
|
|
|
7797
7831
|
// src/adr-path-refs.ts
|
|
@@ -8394,7 +8428,7 @@ function reviewerDispatchRejectionPath(runDirectory) {
|
|
|
8394
8428
|
return join19(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
8395
8429
|
}
|
|
8396
8430
|
function recordReviewerDispatchRejectionSync(runDirectory, rejection) {
|
|
8397
|
-
|
|
8431
|
+
writeFileSync4(
|
|
8398
8432
|
reviewerDispatchRejectionPath(runDirectory),
|
|
8399
8433
|
`${JSON.stringify(rejection)}
|
|
8400
8434
|
`,
|
|
@@ -8412,7 +8446,6 @@ init_activation_ledger_topology();
|
|
|
8412
8446
|
import { Type as Type16 } from "typebox";
|
|
8413
8447
|
var INSPECTOR_OUTPUT_TOOL = INSPECTOR_OUTPUT_TOOL_NAME;
|
|
8414
8448
|
var NOTARY_OUTPUT_TOOL = "ak_notary_output";
|
|
8415
|
-
var SUBJECT_TOOL = "ak_gatekeeper_subject";
|
|
8416
8449
|
function gateSeatLabel(stage) {
|
|
8417
8450
|
return stage === "inspector" ? "\u5BDF\u9662" : "\u7B26\u5B9D\u90CE";
|
|
8418
8451
|
}
|
|
@@ -8439,16 +8472,6 @@ var GATEKEEPER_TOOL_SPEC = {
|
|
|
8439
8472
|
function result(content, details) {
|
|
8440
8473
|
return { content: [{ type: "text", text: content }], details };
|
|
8441
8474
|
}
|
|
8442
|
-
function subjectTool(subject) {
|
|
8443
|
-
return {
|
|
8444
|
-
name: SUBJECT_TOOL,
|
|
8445
|
-
description: "\u8BFB\u53D6\u5DF2\u53D7\u7406\u5377\u5B97\uFF1B\u53EA\u4F9B\u53D6\u9605\uFF0C\u4E0D\u8BC4\u5224\u4E0D\u6539\u52A8\u3002",
|
|
8446
|
-
parameters: Type16.Object({}, { additionalProperties: false }),
|
|
8447
|
-
async execute() {
|
|
8448
|
-
return result(JSON.stringify(subject), subject);
|
|
8449
|
-
}
|
|
8450
|
-
};
|
|
8451
|
-
}
|
|
8452
8475
|
function createOfficerDecisionTool(name) {
|
|
8453
8476
|
return {
|
|
8454
8477
|
name,
|
|
@@ -8471,11 +8494,11 @@ function asStringArray3(value) {
|
|
|
8471
8494
|
return value.filter((item) => typeof item === "string");
|
|
8472
8495
|
}
|
|
8473
8496
|
var MISSING_ARGUMENTS_SUBMISSION = Object.freeze({ missing: "arguments" });
|
|
8474
|
-
function
|
|
8497
|
+
function isRecord12(value) {
|
|
8475
8498
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8476
8499
|
}
|
|
8477
8500
|
function retainedSubmission(decision) {
|
|
8478
|
-
return decision === void 0 ||
|
|
8501
|
+
return decision === void 0 || isRecord12(decision) && Object.keys(decision).length === 0 ? MISSING_ARGUMENTS_SUBMISSION : decision;
|
|
8479
8502
|
}
|
|
8480
8503
|
function noUsableReleaseFailure(stage, decision) {
|
|
8481
8504
|
return {
|
|
@@ -8522,6 +8545,8 @@ function projectOfficerDecision(officer, decision) {
|
|
|
8522
8545
|
async function runGatekeeper(options) {
|
|
8523
8546
|
const loadSoul = options.loadSoul ?? defaultLoadSoul;
|
|
8524
8547
|
const officer = options.subject.kind === "worker_completion" ? "inspector" : "notary";
|
|
8548
|
+
const runDirectory = options.runDirectory ?? auditorRunDirectory(options.context);
|
|
8549
|
+
const submissionCandidate = runDirectory === void 0 ? void 0 : persistGateSubmissionCandidate(runDirectory, options.context);
|
|
8525
8550
|
try {
|
|
8526
8551
|
const officerRun = await executeAuditorChild({
|
|
8527
8552
|
context: options.context,
|
|
@@ -8530,9 +8555,13 @@ async function runGatekeeper(options) {
|
|
|
8530
8555
|
systemPrompt: await loadSoul(officer),
|
|
8531
8556
|
prompt: "\u5377\u5B97\u5DF2\u53D7\u7406\u3002",
|
|
8532
8557
|
tool: createOfficerDecisionTool(officer === "inspector" ? INSPECTOR_OUTPUT_TOOL : NOTARY_OUTPUT_TOOL),
|
|
8533
|
-
|
|
8558
|
+
// Same locator as 审刑院 — run directory + path identifiers only; no receipt body (#632).
|
|
8559
|
+
dossierTool: createAuditorDossierTool(
|
|
8560
|
+
runDirectory,
|
|
8561
|
+
submissionCandidate === void 0 ? void 0 : { submissionCandidate }
|
|
8562
|
+
),
|
|
8534
8563
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
8535
|
-
...
|
|
8564
|
+
...runDirectory === void 0 ? {} : { runDirectory }
|
|
8536
8565
|
});
|
|
8537
8566
|
if (officerRun.noReceiptLifecycle !== void 0) {
|
|
8538
8567
|
return { status: "no_receipt", stage: officer, reason: `${gateSeatLabel(officer)}\u672A\u4EA7\u751F\u5DF2\u63A5\u53D7\u56DE\u6267\u5373\u6563\u5C40`, facts: officerRun.noReceiptLifecycle };
|
|
@@ -9964,7 +9993,7 @@ import {
|
|
|
9964
9993
|
lstatSync as lstatSync2,
|
|
9965
9994
|
realpathSync as realpathSync3,
|
|
9966
9995
|
statSync as statSync3,
|
|
9967
|
-
writeFileSync as
|
|
9996
|
+
writeFileSync as writeFileSync5
|
|
9968
9997
|
} from "node:fs";
|
|
9969
9998
|
import { isAbsolute as isAbsolute5, resolve as resolve14 } from "node:path";
|
|
9970
9999
|
var ActivationSessionFileMissingError = class extends Error {
|
|
@@ -9985,7 +10014,7 @@ function materializeDeferredSessionFile(sessionManager, resolvedFile) {
|
|
|
9985
10014
|
throw new ActivationSessionFileMissingError(resolvedFile);
|
|
9986
10015
|
}
|
|
9987
10016
|
try {
|
|
9988
|
-
|
|
10017
|
+
writeFileSync5(resolvedFile, `${JSON.stringify(header)}
|
|
9989
10018
|
`, { flag: "wx" });
|
|
9990
10019
|
} catch (error) {
|
|
9991
10020
|
if (errnoCode(error) !== "EEXIST") {
|
|
@@ -11338,7 +11367,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
|
|
|
11338
11367
|
const verdict = validateVerdict(parameters);
|
|
11339
11368
|
await pi.requireGatekeeperPass({
|
|
11340
11369
|
context: ctx,
|
|
11341
|
-
subject: { kind: "judge_draft"
|
|
11370
|
+
subject: { kind: "judge_draft" },
|
|
11342
11371
|
...signal === void 0 ? {} : { signal },
|
|
11343
11372
|
hostActions,
|
|
11344
11373
|
toolCallId
|
|
@@ -11843,7 +11872,7 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
11843
11872
|
rmOwnedDir(resolve16(gitDir, HOOKS_DIR));
|
|
11844
11873
|
}
|
|
11845
11874
|
}
|
|
11846
|
-
function
|
|
11875
|
+
function isRecord13(value) {
|
|
11847
11876
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11848
11877
|
}
|
|
11849
11878
|
function unfinishedReasonPresent(details) {
|
|
@@ -11859,7 +11888,7 @@ function readGateState(session) {
|
|
|
11859
11888
|
if (entry.type !== "custom") continue;
|
|
11860
11889
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
11861
11890
|
const data = entry.data;
|
|
11862
|
-
if (
|
|
11891
|
+
if (isRecord13(data) && (data.head === null || typeof data.head === "string")) {
|
|
11863
11892
|
baseline = data.head;
|
|
11864
11893
|
}
|
|
11865
11894
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -12087,6 +12116,8 @@ function assertAcceptableThroughHost(submissionGate, status, details, hostAction
|
|
|
12087
12116
|
function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
12088
12117
|
let soul;
|
|
12089
12118
|
let packet;
|
|
12119
|
+
let packetPath;
|
|
12120
|
+
let prerequisitesPath;
|
|
12090
12121
|
let phase;
|
|
12091
12122
|
let lifecycleRegistered = false;
|
|
12092
12123
|
const submissionGate = createWorkerSubmissionGate();
|
|
@@ -12113,21 +12144,23 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
12113
12144
|
);
|
|
12114
12145
|
}
|
|
12115
12146
|
phase = selectedPhase;
|
|
12116
|
-
const
|
|
12117
|
-
if (typeof
|
|
12147
|
+
const resolvedPacketPath = pi.getFlag(FIXER_FLAG_DEFINITIONS.packet.name);
|
|
12148
|
+
if (typeof resolvedPacketPath !== "string" || resolvedPacketPath.trim().length === 0) {
|
|
12118
12149
|
throw new Error("Fixer role requires --ak-fix-packet");
|
|
12119
12150
|
}
|
|
12151
|
+
packetPath = resolvedPacketPath;
|
|
12120
12152
|
const instructions = await dependencies.loadPacket(packetPath);
|
|
12121
12153
|
if (instructions.trim().length === 0) {
|
|
12122
12154
|
throw new FixerPacketValidationError(
|
|
12123
12155
|
new Error("Fixer instructions must be nonblank")
|
|
12124
12156
|
);
|
|
12125
12157
|
}
|
|
12126
|
-
const
|
|
12127
|
-
if (
|
|
12158
|
+
const resolvedPrerequisitesPath = pi.getFlag(FIXER_FLAG_DEFINITIONS.prerequisites.name);
|
|
12159
|
+
if (resolvedPrerequisitesPath !== void 0 && (typeof resolvedPrerequisitesPath !== "string" || resolvedPrerequisitesPath.trim().length === 0)) {
|
|
12128
12160
|
throw new Error("Fixer --ak-fixer-prerequisites path must be nonblank when supplied");
|
|
12129
12161
|
}
|
|
12130
|
-
|
|
12162
|
+
prerequisitesPath = typeof resolvedPrerequisitesPath === "string" ? resolvedPrerequisitesPath : void 0;
|
|
12163
|
+
const prerequisites = prerequisitesPath !== void 0 ? parseFixerPrerequisites(await dependencies.loadPacket(prerequisitesPath)) : Object.freeze([]);
|
|
12131
12164
|
packet = Object.freeze({ instructions, prerequisites });
|
|
12132
12165
|
if (!lifecycleRegistered) {
|
|
12133
12166
|
lifecycleRegistered = true;
|
|
@@ -12153,7 +12186,7 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
12153
12186
|
if (WORKER_DONE_STATUSES.has(output.status)) {
|
|
12154
12187
|
await pi.requireGatekeeperPass({
|
|
12155
12188
|
context: ctx,
|
|
12156
|
-
subject: { kind: "worker_completion"
|
|
12189
|
+
subject: { kind: "worker_completion" },
|
|
12157
12190
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
12158
12191
|
hostActions,
|
|
12159
12192
|
toolCallId
|
|
@@ -12180,6 +12213,12 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
12180
12213
|
});
|
|
12181
12214
|
pi.on("before_agent_start", (event) => {
|
|
12182
12215
|
if (soul === void 0) throw new Error("\u4FEE\u5185\u53F8\u804C\u5206\u672A\u88C5\u8F7D");
|
|
12216
|
+
if (packetPath === void 0) throw new Error("\u4FEE\u5185\u53F8\u4FEE\u7406\u5305\u8DEF\u5F84\u672A\u88C5\u8F7D");
|
|
12217
|
+
const prerequisitesBlock = prerequisitesPath === void 0 ? "" : `
|
|
12218
|
+
|
|
12219
|
+
<fixer_prerequisites_path>
|
|
12220
|
+
${prerequisitesPath}
|
|
12221
|
+
</fixer_prerequisites_path>`;
|
|
12183
12222
|
return {
|
|
12184
12223
|
systemPrompt: `${event.systemPrompt}
|
|
12185
12224
|
|
|
@@ -12191,13 +12230,9 @@ ${soul}
|
|
|
12191
12230
|
${phase ?? ""}
|
|
12192
12231
|
</fixer_phase>
|
|
12193
12232
|
|
|
12194
|
-
<
|
|
12195
|
-
${
|
|
12196
|
-
</
|
|
12197
|
-
|
|
12198
|
-
<fixer_prerequisites>
|
|
12199
|
-
${JSON.stringify(packet?.prerequisites ?? [])}
|
|
12200
|
-
</fixer_prerequisites>`
|
|
12233
|
+
<fix_packet_path>
|
|
12234
|
+
${packetPath}
|
|
12235
|
+
</fix_packet_path>${prerequisitesBlock}`
|
|
12201
12236
|
};
|
|
12202
12237
|
});
|
|
12203
12238
|
}
|
|
@@ -12290,7 +12325,7 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
12290
12325
|
if (WORKER_DONE_STATUSES.has(output.status)) {
|
|
12291
12326
|
await pi.requireGatekeeperPass({
|
|
12292
12327
|
context: ctx2,
|
|
12293
|
-
subject: { kind: "worker_completion"
|
|
12328
|
+
subject: { kind: "worker_completion" },
|
|
12294
12329
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
12295
12330
|
hostActions,
|
|
12296
12331
|
toolCallId
|
|
@@ -12472,15 +12507,6 @@ var REVIEWER_TRANSPORT_FLAGS = Object.freeze([
|
|
|
12472
12507
|
})
|
|
12473
12508
|
})
|
|
12474
12509
|
]);
|
|
12475
|
-
var COUNTERSIGN_TRANSPORT_FLAGS = Object.freeze([
|
|
12476
|
-
Object.freeze({
|
|
12477
|
-
name: "ak-countersign-ticket-number",
|
|
12478
|
-
definition: Object.freeze({
|
|
12479
|
-
description: "Admitted ticketNumber for countersign Notary inner-gate material",
|
|
12480
|
-
type: "string"
|
|
12481
|
-
})
|
|
12482
|
-
})
|
|
12483
|
-
]);
|
|
12484
12510
|
var NOTARY_TRANSPORT_FLAGS = Object.freeze([
|
|
12485
12511
|
Object.freeze({
|
|
12486
12512
|
name: NOTARY_TICKET_FLAG.name,
|
|
@@ -12729,84 +12755,6 @@ async function projectClosedSubmissionLifecycle(projection, context, phase, reco
|
|
|
12729
12755
|
context.sessionManager.appendCustomEntry?.("ak-role-submission-closure", closure);
|
|
12730
12756
|
await settle(publicNavigatorSettlement(projection.role, phase, closure));
|
|
12731
12757
|
}
|
|
12732
|
-
var CountersignInvocationBindingError = class extends Error {
|
|
12733
|
-
code = "countersign-invocation-binding";
|
|
12734
|
-
reason;
|
|
12735
|
-
constructor(reason, message, options) {
|
|
12736
|
-
super(message, options);
|
|
12737
|
-
this.name = "CountersignInvocationBindingError";
|
|
12738
|
-
this.reason = reason;
|
|
12739
|
-
}
|
|
12740
|
-
};
|
|
12741
|
-
function readBoundTicketNumberForNotaryGate(roleHost) {
|
|
12742
|
-
const fromFlag = roleHost.getFlag("ak-countersign-ticket-number");
|
|
12743
|
-
if (fromFlag !== void 0) {
|
|
12744
|
-
if (typeof fromFlag === "string" && /^[1-9]\d*$/.test(fromFlag)) {
|
|
12745
|
-
const n = Number(fromFlag);
|
|
12746
|
-
if (Number.isSafeInteger(n) && n >= 1) return n;
|
|
12747
|
-
}
|
|
12748
|
-
throw new CountersignInvocationBindingError(
|
|
12749
|
-
"flag-invalid",
|
|
12750
|
-
"countersign Notary gate: ak-countersign-ticket-number is present but not a safe positive integer string"
|
|
12751
|
-
);
|
|
12752
|
-
}
|
|
12753
|
-
const runDir = process.env.AK_ROLE_RUN_DIR;
|
|
12754
|
-
if (typeof runDir !== "string" || runDir.trim() === "") return void 0;
|
|
12755
|
-
const invocationPath = pathJoin(runDir, "invocation.json");
|
|
12756
|
-
let rawText;
|
|
12757
|
-
try {
|
|
12758
|
-
rawText = readFileSync4(invocationPath, "utf8");
|
|
12759
|
-
} catch (error) {
|
|
12760
|
-
const err = error;
|
|
12761
|
-
if (err && err.code === "ENOENT") return void 0;
|
|
12762
|
-
throw new CountersignInvocationBindingError(
|
|
12763
|
-
"unreadable",
|
|
12764
|
-
`countersign Notary gate: invocation.json unreadable (${invocationPath})`,
|
|
12765
|
-
{ cause: error }
|
|
12766
|
-
);
|
|
12767
|
-
}
|
|
12768
|
-
let raw;
|
|
12769
|
-
try {
|
|
12770
|
-
raw = JSON.parse(rawText);
|
|
12771
|
-
} catch (error) {
|
|
12772
|
-
throw new CountersignInvocationBindingError(
|
|
12773
|
-
"unparseable",
|
|
12774
|
-
`countersign Notary gate: invocation.json unparseable (${invocationPath})`,
|
|
12775
|
-
{ cause: error }
|
|
12776
|
-
);
|
|
12777
|
-
}
|
|
12778
|
-
if (typeof raw === "object" && raw !== null && typeof raw.ticketNumber === "number" && Number.isSafeInteger(raw.ticketNumber) && raw.ticketNumber >= 1) {
|
|
12779
|
-
return raw.ticketNumber;
|
|
12780
|
-
}
|
|
12781
|
-
return void 0;
|
|
12782
|
-
}
|
|
12783
|
-
async function buildCountersignNotaryGateMaterial(input) {
|
|
12784
|
-
const ticketNumber = readBoundTicketNumberForNotaryGate(input.roleHost);
|
|
12785
|
-
if (ticketNumber !== void 0) {
|
|
12786
|
-
return JSON.stringify({ verdict: input.parameters, ticketNumber });
|
|
12787
|
-
}
|
|
12788
|
-
const runDir = process.env.AK_ROLE_RUN_DIR;
|
|
12789
|
-
if (typeof runDir !== "string" || runDir.trim() === "") {
|
|
12790
|
-
throw new CountersignInvocationBindingError(
|
|
12791
|
-
"unreadable",
|
|
12792
|
-
"countersign Notary gate: true-unbound material requires AK_ROLE_RUN_DIR source-run locator"
|
|
12793
|
-
);
|
|
12794
|
-
}
|
|
12795
|
-
let sourceRun;
|
|
12796
|
-
try {
|
|
12797
|
-
sourceRun = await loadNotarySourceRunLocator(runDir);
|
|
12798
|
-
} catch (error) {
|
|
12799
|
-
if (error instanceof NotarySourceRunError) {
|
|
12800
|
-
throw new CountersignInvocationBindingError(
|
|
12801
|
-
"unreadable",
|
|
12802
|
-
`countersign Notary gate: source-run locator unusable (${error.message})`,
|
|
12803
|
-
{ cause: error }
|
|
12804
|
-
);
|
|
12805
|
-
}
|
|
12806
|
-
throw error;
|
|
12807
|
-
}
|
|
12808
|
-
return JSON.stringify({ verdict: input.parameters, sourceRun });
|
|
12809
|
-
}
|
|
12810
12758
|
function createFiledOfficerRuntime(roleHost, spec, dependencies) {
|
|
12811
12759
|
let soul;
|
|
12812
12760
|
let registered = false;
|
|
@@ -12908,14 +12856,10 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
|
|
|
12908
12856
|
);
|
|
12909
12857
|
}
|
|
12910
12858
|
function createCountersignRoleRuntime(roleHost, dependencies, hostActions) {
|
|
12911
|
-
const beforeAccept = hostActions !== void 0 && roleHost.requireGatekeeperPass !== void 0 ? async ({ toolCallId,
|
|
12912
|
-
const material = await buildCountersignNotaryGateMaterial({
|
|
12913
|
-
roleHost,
|
|
12914
|
-
parameters
|
|
12915
|
-
});
|
|
12859
|
+
const beforeAccept = hostActions !== void 0 && roleHost.requireGatekeeperPass !== void 0 ? async ({ toolCallId, signal, ctx }) => {
|
|
12916
12860
|
await roleHost.requireGatekeeperPass({
|
|
12917
12861
|
context: ctx,
|
|
12918
|
-
subject: { kind: "countersign_verdict"
|
|
12862
|
+
subject: { kind: "countersign_verdict" },
|
|
12919
12863
|
...signal === void 0 ? {} : { signal },
|
|
12920
12864
|
hostActions,
|
|
12921
12865
|
toolCallId
|
|
@@ -12948,9 +12892,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
12948
12892
|
for (const flag of REVIEWER_TRANSPORT_FLAGS) {
|
|
12949
12893
|
roleHost.registerFlag(flag.name, flag.definition);
|
|
12950
12894
|
}
|
|
12951
|
-
for (const flag of COUNTERSIGN_TRANSPORT_FLAGS) {
|
|
12952
|
-
roleHost.registerFlag(flag.name, flag.definition);
|
|
12953
|
-
}
|
|
12954
12895
|
for (const flag of NOTARY_TRANSPORT_FLAGS) {
|
|
12955
12896
|
roleHost.registerFlag(flag.name, flag.definition);
|
|
12956
12897
|
}
|
|
@@ -14242,9 +14183,6 @@ function projectGrokActivationFlags(request) {
|
|
|
14242
14183
|
flags.set("ak-review-authority-refs", JSON.stringify(activation.authorityRefs));
|
|
14243
14184
|
if (activation.ticketNumber !== void 0) flags.set("ak-review-ticket-number", String(activation.ticketNumber));
|
|
14244
14185
|
}
|
|
14245
|
-
if (activation.role === "countersign" && activation.ticketNumber !== void 0) {
|
|
14246
|
-
flags.set("ak-countersign-ticket-number", String(activation.ticketNumber));
|
|
14247
|
-
}
|
|
14248
14186
|
if (activation.role === "notary" && activation.ticketNumber !== void 0) {
|
|
14249
14187
|
flags.set("ak-notary-ticket-number", String(activation.ticketNumber));
|
|
14250
14188
|
}
|
|
@@ -14712,14 +14650,13 @@ async function prepareGrokRoleEnvelope(options) {
|
|
|
14712
14650
|
message: { role: "user", content: prompt }
|
|
14713
14651
|
});
|
|
14714
14652
|
}
|
|
14715
|
-
const basePrompt = await loadMainRoleSessionMaterials(request.activation.role);
|
|
14716
14653
|
const methodPrompt = (await Promise.all(request.methods.map(({ path }) => readFile13(path, "utf8")))).join("\n\n");
|
|
14717
14654
|
const promptResults = await emit("before_agent_start", {
|
|
14718
14655
|
prompt,
|
|
14719
|
-
systemPrompt:
|
|
14656
|
+
systemPrompt: methodPrompt,
|
|
14720
14657
|
systemPromptOptions: {}
|
|
14721
14658
|
});
|
|
14722
|
-
const systemPromptBody = [...promptResults].reverse().find((value) => typeof value === "object" && value !== null && "systemPrompt" in value && typeof value.systemPrompt === "string")?.systemPrompt ??
|
|
14659
|
+
const systemPromptBody = [...promptResults].reverse().find((value) => typeof value === "object" && value !== null && "systemPrompt" in value && typeof value.systemPrompt === "string")?.systemPrompt ?? methodPrompt;
|
|
14723
14660
|
const readingMaterials = [];
|
|
14724
14661
|
for (const value of promptResults) {
|
|
14725
14662
|
if (typeof value !== "object" || value === null) continue;
|