@akagilnc/pi-workflow-roles 0.1.3377 → 0.1.3391
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 +6 -5
- package/README.zh-CN.md +3 -4
- package/dist/auditor-dossier-tool.js +51 -2
- package/dist/gatekeeper-role.js +11 -11
- package/dist/grok/production-host.js +122 -213
- package/dist/public-cli/main.js +6710 -6810
- 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 +2 -3
- package/src/judge-role.ts +1 -1
- package/src/pi/role-turn-host.ts +2 -7
- package/src/public-cli/coder-run.ts +7 -1
- package/src/public-cli/countersign-run.ts +3 -42
- package/src/public-cli/fixer-run.ts +7 -1
- package/src/public-cli/invocation.ts +94 -111
- package/src/public-cli/judge-run.ts +7 -1
- package/src/public-cli/notary-run.ts +1 -2
- package/src/public-cli/option-definitions.ts +2 -30
- package/src/public-cli/run-lifecycle.ts +27 -4
- package/src/public-cli/seat-ticket-binding.ts +56 -0
- package/src/role-runtime.ts +4 -143
- package/src/worker-role.ts +19 -8
- package/src/ticket-frontmatter.ts +0 -94
|
@@ -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
|
}
|
|
@@ -6551,21 +6586,7 @@ var NAVIGATOR_OPTIONS = [
|
|
|
6551
6586
|
];
|
|
6552
6587
|
var COUNTERSIGN_OPTIONS = [
|
|
6553
6588
|
bindOwner("countersign", SHARED_PROJECT_SEMANTICS),
|
|
6554
|
-
bindOwner("countersign", SHARED_ATTACH_SEMANTICS)
|
|
6555
|
-
{
|
|
6556
|
-
id: "ticket",
|
|
6557
|
-
owner: "countersign",
|
|
6558
|
-
canonical: "--ticket",
|
|
6559
|
-
aliases: [],
|
|
6560
|
-
valueMetavar: "number",
|
|
6561
|
-
required: false,
|
|
6562
|
-
repeatable: false,
|
|
6563
|
-
form: "option",
|
|
6564
|
-
description: {
|
|
6565
|
-
en: "Ticket/issue number for court diary (diarist) and ticket-keyed provenance. Overrides attachment frontmatter when both present.",
|
|
6566
|
-
zh: "\u7968\u53F7\uFF1A\u8D77\u5C45\u90CE\u6D41\u6C34\u7EBF\u4E0E\u8D77\u5C45\u5F55\u7968\u952E\u3002\u4E0E\u9644\u4EF6 frontmatter \u5E76\u5B58\u65F6\u4EE5\u672C\u65D7\u4E3A\u51C6\u3002"
|
|
6567
|
-
}
|
|
6568
|
-
}
|
|
6589
|
+
bindOwner("countersign", SHARED_ATTACH_SEMANTICS)
|
|
6569
6590
|
];
|
|
6570
6591
|
var CODER_OPTIONS = [
|
|
6571
6592
|
{
|
|
@@ -6746,20 +6767,6 @@ var NOTARY_OPTIONS = [
|
|
|
6746
6767
|
en: "Required source run locator (runId@role under the book home, or path to that run directory). Zero prompt/attachment projection.",
|
|
6747
6768
|
zh: "\u5FC5\u586B\u6E90 run \u5B9A\u4F4D\u7B26\uFF08\u7C3F\u5185 runId@role\uFF0C\u6216\u8BE5 run \u76EE\u5F55\u8DEF\u5F84\uFF09\u3002\u96F6 prompt/\u9644\u4EF6\u6295\u5F71\u3002"
|
|
6748
6769
|
}
|
|
6749
|
-
},
|
|
6750
|
-
{
|
|
6751
|
-
id: "ticket",
|
|
6752
|
-
owner: "notary",
|
|
6753
|
-
canonical: "--ticket",
|
|
6754
|
-
aliases: [],
|
|
6755
|
-
valueMetavar: "number",
|
|
6756
|
-
required: false,
|
|
6757
|
-
repeatable: false,
|
|
6758
|
-
form: "option",
|
|
6759
|
-
description: {
|
|
6760
|
-
en: "Optional ticket/issue number when Notary reads the court diary (ticket-provenance) for a ticket.",
|
|
6761
|
-
zh: "\u53EF\u9009\u7968\u53F7\uFF1A\u7B26\u5B9D\u90CE\u6309\u7968\u952E\u8C03\u53D6\u8D77\u5C45\u5F55\u65F6\u4F7F\u7528\u3002"
|
|
6762
|
-
}
|
|
6763
6770
|
}
|
|
6764
6771
|
];
|
|
6765
6772
|
var MERGER_OPTIONS = [
|
|
@@ -6807,7 +6814,7 @@ var ROLE_COMMAND_HELP = {
|
|
|
6807
6814
|
summary: "Ticket-court review before work starts; five questions, \u7F72/\u5C01\u9A73/\u4E0A\u5448.",
|
|
6808
6815
|
usage: ["ak-role countersign [options] [instruction]"],
|
|
6809
6816
|
examples: [
|
|
6810
|
-
'ak-role countersign --
|
|
6817
|
+
'ak-role countersign --attach ./ticket.md "\u88C1\uFF1A\u672C\u7968 #582 \u662F\u5426\u8DB3\u4EE5\u5F00\u5DE5\u3002"',
|
|
6811
6818
|
'ak-role countersign --attach ./plan.md --attach ./adr.md "\u88C1\uFF1A\u65B9\u6848\u4E94\u95EE\u3002"'
|
|
6812
6819
|
]
|
|
6813
6820
|
},
|
|
@@ -6901,7 +6908,7 @@ var ROLE_COMMAND_HELP = {
|
|
|
6901
6908
|
usage: ["ak-role notary --source-run <runId@role|path> [options]"],
|
|
6902
6909
|
examples: [
|
|
6903
6910
|
"ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@judge",
|
|
6904
|
-
"ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@countersign
|
|
6911
|
+
"ak-role notary --source-run 01a034f1-75bf-71a6-bcf5-d1299145b1a5@countersign"
|
|
6905
6912
|
]
|
|
6906
6913
|
},
|
|
6907
6914
|
analyst: {
|
|
@@ -7267,11 +7274,11 @@ function resolvePackagedMethodSkillRoot(packageRoot, name) {
|
|
|
7267
7274
|
function resolvePackagedMethodSkillPath(packageRoot, name) {
|
|
7268
7275
|
return join17(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
|
|
7269
7276
|
}
|
|
7270
|
-
function
|
|
7277
|
+
function isRecord11(value) {
|
|
7271
7278
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7272
7279
|
}
|
|
7273
7280
|
function parseProvenance(raw, expectedName) {
|
|
7274
|
-
if (!
|
|
7281
|
+
if (!isRecord11(raw)) {
|
|
7275
7282
|
throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
|
|
7276
7283
|
}
|
|
7277
7284
|
if (raw.name !== expectedName) {
|
|
@@ -7285,7 +7292,7 @@ function parseProvenance(raw, expectedName) {
|
|
|
7285
7292
|
if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
|
|
7286
7293
|
throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
|
|
7287
7294
|
}
|
|
7288
|
-
if (!
|
|
7295
|
+
if (!isRecord11(raw.upstream)) {
|
|
7289
7296
|
throw new Error(`Packaged method provenance upstream must be an object`);
|
|
7290
7297
|
}
|
|
7291
7298
|
const upstream = raw.upstream;
|
|
@@ -7312,12 +7319,12 @@ function parseProvenance(raw, expectedName) {
|
|
|
7312
7319
|
`Packaged method provenance upstream must include nonblank tag or version`
|
|
7313
7320
|
);
|
|
7314
7321
|
}
|
|
7315
|
-
if (!
|
|
7322
|
+
if (!isRecord11(raw.files)) {
|
|
7316
7323
|
throw new Error(`Packaged method provenance files must be an object`);
|
|
7317
7324
|
}
|
|
7318
7325
|
const files = {};
|
|
7319
7326
|
for (const [rel, entry] of Object.entries(raw.files)) {
|
|
7320
|
-
if (!
|
|
7327
|
+
if (!isRecord11(entry)) {
|
|
7321
7328
|
throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
|
|
7322
7329
|
}
|
|
7323
7330
|
if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
|
|
@@ -7766,8 +7773,7 @@ function createPerDispatchReviewerAgent(dependencies = {}) {
|
|
|
7766
7773
|
}
|
|
7767
7774
|
|
|
7768
7775
|
// src/role-runtime.ts
|
|
7769
|
-
import {
|
|
7770
|
-
import { join as pathJoin } from "node:path";
|
|
7776
|
+
import { writeSync as writeSync4 } from "node:fs";
|
|
7771
7777
|
|
|
7772
7778
|
// src/host-contracts.ts
|
|
7773
7779
|
import { Type as Type15 } from "typebox";
|
|
@@ -7791,7 +7797,7 @@ function stringEnum(values, options = {}) {
|
|
|
7791
7797
|
}
|
|
7792
7798
|
|
|
7793
7799
|
// src/public-cli/reviewer-dispatch-rejection.ts
|
|
7794
|
-
import { writeFileSync as
|
|
7800
|
+
import { writeFileSync as writeFileSync4 } from "node:fs";
|
|
7795
7801
|
import { join as join19 } from "node:path";
|
|
7796
7802
|
|
|
7797
7803
|
// src/adr-path-refs.ts
|
|
@@ -8394,7 +8400,7 @@ function reviewerDispatchRejectionPath(runDirectory) {
|
|
|
8394
8400
|
return join19(runDirectory, REVIEWER_DISPATCH_REJECTION_FILE);
|
|
8395
8401
|
}
|
|
8396
8402
|
function recordReviewerDispatchRejectionSync(runDirectory, rejection) {
|
|
8397
|
-
|
|
8403
|
+
writeFileSync4(
|
|
8398
8404
|
reviewerDispatchRejectionPath(runDirectory),
|
|
8399
8405
|
`${JSON.stringify(rejection)}
|
|
8400
8406
|
`,
|
|
@@ -8412,7 +8418,6 @@ init_activation_ledger_topology();
|
|
|
8412
8418
|
import { Type as Type16 } from "typebox";
|
|
8413
8419
|
var INSPECTOR_OUTPUT_TOOL = INSPECTOR_OUTPUT_TOOL_NAME;
|
|
8414
8420
|
var NOTARY_OUTPUT_TOOL = "ak_notary_output";
|
|
8415
|
-
var SUBJECT_TOOL = "ak_gatekeeper_subject";
|
|
8416
8421
|
function gateSeatLabel(stage) {
|
|
8417
8422
|
return stage === "inspector" ? "\u5BDF\u9662" : "\u7B26\u5B9D\u90CE";
|
|
8418
8423
|
}
|
|
@@ -8439,16 +8444,6 @@ var GATEKEEPER_TOOL_SPEC = {
|
|
|
8439
8444
|
function result(content, details) {
|
|
8440
8445
|
return { content: [{ type: "text", text: content }], details };
|
|
8441
8446
|
}
|
|
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
8447
|
function createOfficerDecisionTool(name) {
|
|
8453
8448
|
return {
|
|
8454
8449
|
name,
|
|
@@ -8471,11 +8466,11 @@ function asStringArray3(value) {
|
|
|
8471
8466
|
return value.filter((item) => typeof item === "string");
|
|
8472
8467
|
}
|
|
8473
8468
|
var MISSING_ARGUMENTS_SUBMISSION = Object.freeze({ missing: "arguments" });
|
|
8474
|
-
function
|
|
8469
|
+
function isRecord12(value) {
|
|
8475
8470
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8476
8471
|
}
|
|
8477
8472
|
function retainedSubmission(decision) {
|
|
8478
|
-
return decision === void 0 ||
|
|
8473
|
+
return decision === void 0 || isRecord12(decision) && Object.keys(decision).length === 0 ? MISSING_ARGUMENTS_SUBMISSION : decision;
|
|
8479
8474
|
}
|
|
8480
8475
|
function noUsableReleaseFailure(stage, decision) {
|
|
8481
8476
|
return {
|
|
@@ -8522,6 +8517,8 @@ function projectOfficerDecision(officer, decision) {
|
|
|
8522
8517
|
async function runGatekeeper(options) {
|
|
8523
8518
|
const loadSoul = options.loadSoul ?? defaultLoadSoul;
|
|
8524
8519
|
const officer = options.subject.kind === "worker_completion" ? "inspector" : "notary";
|
|
8520
|
+
const runDirectory = options.runDirectory ?? auditorRunDirectory(options.context);
|
|
8521
|
+
const submissionCandidate = runDirectory === void 0 ? void 0 : persistGateSubmissionCandidate(runDirectory, options.context);
|
|
8525
8522
|
try {
|
|
8526
8523
|
const officerRun = await executeAuditorChild({
|
|
8527
8524
|
context: options.context,
|
|
@@ -8530,9 +8527,13 @@ async function runGatekeeper(options) {
|
|
|
8530
8527
|
systemPrompt: await loadSoul(officer),
|
|
8531
8528
|
prompt: "\u5377\u5B97\u5DF2\u53D7\u7406\u3002",
|
|
8532
8529
|
tool: createOfficerDecisionTool(officer === "inspector" ? INSPECTOR_OUTPUT_TOOL : NOTARY_OUTPUT_TOOL),
|
|
8533
|
-
|
|
8530
|
+
// Same locator as 审刑院 — run directory + path identifiers only; no receipt body (#632).
|
|
8531
|
+
dossierTool: createAuditorDossierTool(
|
|
8532
|
+
runDirectory,
|
|
8533
|
+
submissionCandidate === void 0 ? void 0 : { submissionCandidate }
|
|
8534
|
+
),
|
|
8534
8535
|
...options.signal === void 0 ? {} : { signal: options.signal },
|
|
8535
|
-
...
|
|
8536
|
+
...runDirectory === void 0 ? {} : { runDirectory }
|
|
8536
8537
|
});
|
|
8537
8538
|
if (officerRun.noReceiptLifecycle !== void 0) {
|
|
8538
8539
|
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 +9965,7 @@ import {
|
|
|
9964
9965
|
lstatSync as lstatSync2,
|
|
9965
9966
|
realpathSync as realpathSync3,
|
|
9966
9967
|
statSync as statSync3,
|
|
9967
|
-
writeFileSync as
|
|
9968
|
+
writeFileSync as writeFileSync5
|
|
9968
9969
|
} from "node:fs";
|
|
9969
9970
|
import { isAbsolute as isAbsolute5, resolve as resolve14 } from "node:path";
|
|
9970
9971
|
var ActivationSessionFileMissingError = class extends Error {
|
|
@@ -9985,7 +9986,7 @@ function materializeDeferredSessionFile(sessionManager, resolvedFile) {
|
|
|
9985
9986
|
throw new ActivationSessionFileMissingError(resolvedFile);
|
|
9986
9987
|
}
|
|
9987
9988
|
try {
|
|
9988
|
-
|
|
9989
|
+
writeFileSync5(resolvedFile, `${JSON.stringify(header)}
|
|
9989
9990
|
`, { flag: "wx" });
|
|
9990
9991
|
} catch (error) {
|
|
9991
9992
|
if (errnoCode(error) !== "EEXIST") {
|
|
@@ -11338,7 +11339,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
|
|
|
11338
11339
|
const verdict = validateVerdict(parameters);
|
|
11339
11340
|
await pi.requireGatekeeperPass({
|
|
11340
11341
|
context: ctx,
|
|
11341
|
-
subject: { kind: "judge_draft"
|
|
11342
|
+
subject: { kind: "judge_draft" },
|
|
11342
11343
|
...signal === void 0 ? {} : { signal },
|
|
11343
11344
|
hostActions,
|
|
11344
11345
|
toolCallId
|
|
@@ -11843,7 +11844,7 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
11843
11844
|
rmOwnedDir(resolve16(gitDir, HOOKS_DIR));
|
|
11844
11845
|
}
|
|
11845
11846
|
}
|
|
11846
|
-
function
|
|
11847
|
+
function isRecord13(value) {
|
|
11847
11848
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11848
11849
|
}
|
|
11849
11850
|
function unfinishedReasonPresent(details) {
|
|
@@ -11859,7 +11860,7 @@ function readGateState(session) {
|
|
|
11859
11860
|
if (entry.type !== "custom") continue;
|
|
11860
11861
|
if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
|
|
11861
11862
|
const data = entry.data;
|
|
11862
|
-
if (
|
|
11863
|
+
if (isRecord13(data) && (data.head === null || typeof data.head === "string")) {
|
|
11863
11864
|
baseline = data.head;
|
|
11864
11865
|
}
|
|
11865
11866
|
} else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
|
|
@@ -12087,6 +12088,8 @@ function assertAcceptableThroughHost(submissionGate, status, details, hostAction
|
|
|
12087
12088
|
function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
12088
12089
|
let soul;
|
|
12089
12090
|
let packet;
|
|
12091
|
+
let packetPath;
|
|
12092
|
+
let prerequisitesPath;
|
|
12090
12093
|
let phase;
|
|
12091
12094
|
let lifecycleRegistered = false;
|
|
12092
12095
|
const submissionGate = createWorkerSubmissionGate();
|
|
@@ -12113,21 +12116,23 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
12113
12116
|
);
|
|
12114
12117
|
}
|
|
12115
12118
|
phase = selectedPhase;
|
|
12116
|
-
const
|
|
12117
|
-
if (typeof
|
|
12119
|
+
const resolvedPacketPath = pi.getFlag(FIXER_FLAG_DEFINITIONS.packet.name);
|
|
12120
|
+
if (typeof resolvedPacketPath !== "string" || resolvedPacketPath.trim().length === 0) {
|
|
12118
12121
|
throw new Error("Fixer role requires --ak-fix-packet");
|
|
12119
12122
|
}
|
|
12123
|
+
packetPath = resolvedPacketPath;
|
|
12120
12124
|
const instructions = await dependencies.loadPacket(packetPath);
|
|
12121
12125
|
if (instructions.trim().length === 0) {
|
|
12122
12126
|
throw new FixerPacketValidationError(
|
|
12123
12127
|
new Error("Fixer instructions must be nonblank")
|
|
12124
12128
|
);
|
|
12125
12129
|
}
|
|
12126
|
-
const
|
|
12127
|
-
if (
|
|
12130
|
+
const resolvedPrerequisitesPath = pi.getFlag(FIXER_FLAG_DEFINITIONS.prerequisites.name);
|
|
12131
|
+
if (resolvedPrerequisitesPath !== void 0 && (typeof resolvedPrerequisitesPath !== "string" || resolvedPrerequisitesPath.trim().length === 0)) {
|
|
12128
12132
|
throw new Error("Fixer --ak-fixer-prerequisites path must be nonblank when supplied");
|
|
12129
12133
|
}
|
|
12130
|
-
|
|
12134
|
+
prerequisitesPath = typeof resolvedPrerequisitesPath === "string" ? resolvedPrerequisitesPath : void 0;
|
|
12135
|
+
const prerequisites = prerequisitesPath !== void 0 ? parseFixerPrerequisites(await dependencies.loadPacket(prerequisitesPath)) : Object.freeze([]);
|
|
12131
12136
|
packet = Object.freeze({ instructions, prerequisites });
|
|
12132
12137
|
if (!lifecycleRegistered) {
|
|
12133
12138
|
lifecycleRegistered = true;
|
|
@@ -12153,7 +12158,7 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
12153
12158
|
if (WORKER_DONE_STATUSES.has(output.status)) {
|
|
12154
12159
|
await pi.requireGatekeeperPass({
|
|
12155
12160
|
context: ctx,
|
|
12156
|
-
subject: { kind: "worker_completion"
|
|
12161
|
+
subject: { kind: "worker_completion" },
|
|
12157
12162
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
12158
12163
|
hostActions,
|
|
12159
12164
|
toolCallId
|
|
@@ -12180,6 +12185,12 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
12180
12185
|
});
|
|
12181
12186
|
pi.on("before_agent_start", (event) => {
|
|
12182
12187
|
if (soul === void 0) throw new Error("\u4FEE\u5185\u53F8\u804C\u5206\u672A\u88C5\u8F7D");
|
|
12188
|
+
if (packetPath === void 0) throw new Error("\u4FEE\u5185\u53F8\u4FEE\u7406\u5305\u8DEF\u5F84\u672A\u88C5\u8F7D");
|
|
12189
|
+
const prerequisitesBlock = prerequisitesPath === void 0 ? "" : `
|
|
12190
|
+
|
|
12191
|
+
<fixer_prerequisites_path>
|
|
12192
|
+
${prerequisitesPath}
|
|
12193
|
+
</fixer_prerequisites_path>`;
|
|
12183
12194
|
return {
|
|
12184
12195
|
systemPrompt: `${event.systemPrompt}
|
|
12185
12196
|
|
|
@@ -12191,13 +12202,9 @@ ${soul}
|
|
|
12191
12202
|
${phase ?? ""}
|
|
12192
12203
|
</fixer_phase>
|
|
12193
12204
|
|
|
12194
|
-
<
|
|
12195
|
-
${
|
|
12196
|
-
</
|
|
12197
|
-
|
|
12198
|
-
<fixer_prerequisites>
|
|
12199
|
-
${JSON.stringify(packet?.prerequisites ?? [])}
|
|
12200
|
-
</fixer_prerequisites>`
|
|
12205
|
+
<fix_packet_path>
|
|
12206
|
+
${packetPath}
|
|
12207
|
+
</fix_packet_path>${prerequisitesBlock}`
|
|
12201
12208
|
};
|
|
12202
12209
|
});
|
|
12203
12210
|
}
|
|
@@ -12290,7 +12297,7 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
12290
12297
|
if (WORKER_DONE_STATUSES.has(output.status)) {
|
|
12291
12298
|
await pi.requireGatekeeperPass({
|
|
12292
12299
|
context: ctx2,
|
|
12293
|
-
subject: { kind: "worker_completion"
|
|
12300
|
+
subject: { kind: "worker_completion" },
|
|
12294
12301
|
..._signal === void 0 ? {} : { signal: _signal },
|
|
12295
12302
|
hostActions,
|
|
12296
12303
|
toolCallId
|
|
@@ -12472,15 +12479,6 @@ var REVIEWER_TRANSPORT_FLAGS = Object.freeze([
|
|
|
12472
12479
|
})
|
|
12473
12480
|
})
|
|
12474
12481
|
]);
|
|
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
12482
|
var NOTARY_TRANSPORT_FLAGS = Object.freeze([
|
|
12485
12483
|
Object.freeze({
|
|
12486
12484
|
name: NOTARY_TICKET_FLAG.name,
|
|
@@ -12729,84 +12727,6 @@ async function projectClosedSubmissionLifecycle(projection, context, phase, reco
|
|
|
12729
12727
|
context.sessionManager.appendCustomEntry?.("ak-role-submission-closure", closure);
|
|
12730
12728
|
await settle(publicNavigatorSettlement(projection.role, phase, closure));
|
|
12731
12729
|
}
|
|
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
12730
|
function createFiledOfficerRuntime(roleHost, spec, dependencies) {
|
|
12811
12731
|
let soul;
|
|
12812
12732
|
let registered = false;
|
|
@@ -12908,14 +12828,10 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
|
|
|
12908
12828
|
);
|
|
12909
12829
|
}
|
|
12910
12830
|
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
|
-
});
|
|
12831
|
+
const beforeAccept = hostActions !== void 0 && roleHost.requireGatekeeperPass !== void 0 ? async ({ toolCallId, signal, ctx }) => {
|
|
12916
12832
|
await roleHost.requireGatekeeperPass({
|
|
12917
12833
|
context: ctx,
|
|
12918
|
-
subject: { kind: "countersign_verdict"
|
|
12834
|
+
subject: { kind: "countersign_verdict" },
|
|
12919
12835
|
...signal === void 0 ? {} : { signal },
|
|
12920
12836
|
hostActions,
|
|
12921
12837
|
toolCallId
|
|
@@ -12948,9 +12864,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
12948
12864
|
for (const flag of REVIEWER_TRANSPORT_FLAGS) {
|
|
12949
12865
|
roleHost.registerFlag(flag.name, flag.definition);
|
|
12950
12866
|
}
|
|
12951
|
-
for (const flag of COUNTERSIGN_TRANSPORT_FLAGS) {
|
|
12952
|
-
roleHost.registerFlag(flag.name, flag.definition);
|
|
12953
|
-
}
|
|
12954
12867
|
for (const flag of NOTARY_TRANSPORT_FLAGS) {
|
|
12955
12868
|
roleHost.registerFlag(flag.name, flag.definition);
|
|
12956
12869
|
}
|
|
@@ -14242,9 +14155,6 @@ function projectGrokActivationFlags(request) {
|
|
|
14242
14155
|
flags.set("ak-review-authority-refs", JSON.stringify(activation.authorityRefs));
|
|
14243
14156
|
if (activation.ticketNumber !== void 0) flags.set("ak-review-ticket-number", String(activation.ticketNumber));
|
|
14244
14157
|
}
|
|
14245
|
-
if (activation.role === "countersign" && activation.ticketNumber !== void 0) {
|
|
14246
|
-
flags.set("ak-countersign-ticket-number", String(activation.ticketNumber));
|
|
14247
|
-
}
|
|
14248
14158
|
if (activation.role === "notary" && activation.ticketNumber !== void 0) {
|
|
14249
14159
|
flags.set("ak-notary-ticket-number", String(activation.ticketNumber));
|
|
14250
14160
|
}
|
|
@@ -14712,14 +14622,13 @@ async function prepareGrokRoleEnvelope(options) {
|
|
|
14712
14622
|
message: { role: "user", content: prompt }
|
|
14713
14623
|
});
|
|
14714
14624
|
}
|
|
14715
|
-
const basePrompt = await loadMainRoleSessionMaterials(request.activation.role);
|
|
14716
14625
|
const methodPrompt = (await Promise.all(request.methods.map(({ path }) => readFile13(path, "utf8")))).join("\n\n");
|
|
14717
14626
|
const promptResults = await emit("before_agent_start", {
|
|
14718
14627
|
prompt,
|
|
14719
|
-
systemPrompt:
|
|
14628
|
+
systemPrompt: methodPrompt,
|
|
14720
14629
|
systemPromptOptions: {}
|
|
14721
14630
|
});
|
|
14722
|
-
const systemPromptBody = [...promptResults].reverse().find((value) => typeof value === "object" && value !== null && "systemPrompt" in value && typeof value.systemPrompt === "string")?.systemPrompt ??
|
|
14631
|
+
const systemPromptBody = [...promptResults].reverse().find((value) => typeof value === "object" && value !== null && "systemPrompt" in value && typeof value.systemPrompt === "string")?.systemPrompt ?? methodPrompt;
|
|
14723
14632
|
const readingMaterials = [];
|
|
14724
14633
|
for (const value of promptResults) {
|
|
14725
14634
|
if (typeof value !== "object" || value === null) continue;
|