@akagilnc/pi-workflow-roles 0.1.5079 → 0.1.5096
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/acp-host/production-host.js +348 -301
- package/dist/atomic-write.js +13 -19
- package/dist/auditor-soul.js +2 -1
- package/dist/doctor-contracts.js +1 -1
- package/dist/gatekeeper-role.js +2 -16
- package/dist/headless-host/production-host.js +380 -333
- package/dist/merger-contracts.js +1 -1
- package/dist/migrate-book-topology.js +18 -14
- package/dist/navigator-attendance.js +28 -143
- package/dist/navigator-invocation-identity.js +2 -0
- package/dist/navigator-public-session.js +13 -1
- package/dist/navigator-work-base.js +113 -0
- package/dist/notary-contracts.js +0 -2
- package/dist/package-contracts/fixer-output.js +1 -1
- package/dist/package-contracts/gatekeeper-output.js +1 -1
- package/dist/package-contracts/navigator-output.js +1 -1
- package/dist/package-contracts/terminating-infrastructure.js +3 -3
- package/dist/packaged-role-registry.js +9 -5
- package/dist/public-cli/countersign-run.js +1 -1
- package/dist/public-cli/invocation.js +6 -3
- package/dist/public-cli/main.js +46 -22
- package/dist/public-cli/settlement.js +20 -1
- package/dist/receipt-delivery-policy.js +9 -2
- package/dist/review-submission.js +3 -3
- package/docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md +9 -0
- package/extensions/role-runtime.ts +0 -27
- package/package.json +2 -1
- package/resources/836-deleted-machine-instruction-inventory.md +3 -3
- package/resources/collector-bot-handbook.md +4 -0
- package/resources/navigator-route-playbook.md +4 -6
- package/scripts/build-package.mjs +4 -0
- package/souls/coder-output-guide.md +1 -0
- package/src/auditor-soul.ts +2 -1
- package/src/collector-role.ts +6 -7
- package/src/collector-tool-schemas.ts +5 -5
- package/src/diarist-role.ts +2 -2
- package/src/doctor-contracts.ts +1 -1
- package/src/gatekeeper-role.ts +1 -18
- package/src/gleaner-left-role.ts +2 -2
- package/src/inspector-role.ts +1 -1
- package/src/judge-role.ts +1 -1
- package/src/merger-contracts.ts +1 -1
- package/src/navigator-attendance.ts +38 -164
- package/src/navigator-invocation-identity.ts +2 -0
- package/src/navigator-public-session.ts +17 -1
- package/src/navigator-role.ts +4 -0
- package/src/navigator-session-contracts.ts +2 -0
- package/src/navigator-work-base.ts +123 -0
- package/src/notary-contracts.ts +0 -4
- package/src/package-contracts/fixer-output.ts +1 -1
- package/src/package-contracts/gatekeeper-output.ts +3 -3
- package/src/package-contracts/navigator-output.ts +1 -1
- package/src/package-contracts/terminating-infrastructure.ts +3 -6
- package/src/packaged-role-registry.ts +5 -1
- package/src/public-cli/countersign-run.ts +1 -1
- package/src/public-cli/invocation.ts +6 -3
- package/src/public-cli/settlement.ts +21 -0
- package/src/receipt-delivery-policy.ts +9 -1
- package/src/review-submission.ts +3 -3
- package/src/reviewer-role.ts +3 -3
- package/src/role-runtime-dependencies.ts +1 -5
- package/src/role-runtime.ts +52 -38
- package/src/secretariat-role.ts +3 -3
- package/src/worker-role.ts +3 -3
|
@@ -62,7 +62,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
62
62
|
}
|
|
63
63
|
const command = input.argv[0];
|
|
64
64
|
const args = input.argv.slice(1);
|
|
65
|
-
return await new Promise((
|
|
65
|
+
return await new Promise((resolve22, reject) => {
|
|
66
66
|
let settled = false;
|
|
67
67
|
const signal = input.signal;
|
|
68
68
|
const child = spawn(command, args, {
|
|
@@ -92,7 +92,7 @@ async function spawnEngineDetourOnce(input) {
|
|
|
92
92
|
if (signal !== void 0) {
|
|
93
93
|
signal.removeEventListener("abort", onAbort);
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
resolve22(result);
|
|
96
96
|
};
|
|
97
97
|
const onAbort = () => {
|
|
98
98
|
fail4(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
@@ -1172,12 +1172,12 @@ function createSystemCollectorClock() {
|
|
|
1172
1172
|
return {
|
|
1173
1173
|
wallNow: () => /* @__PURE__ */ new Date(),
|
|
1174
1174
|
monoNow: () => Number(process.hrtime.bigint() - start) / 1e6,
|
|
1175
|
-
sleep: (ms, signal) => new Promise((
|
|
1175
|
+
sleep: (ms, signal) => new Promise((resolve22, reject) => {
|
|
1176
1176
|
if (signal?.aborted) {
|
|
1177
1177
|
reject(signal.reason ?? new Error("aborted"));
|
|
1178
1178
|
return;
|
|
1179
1179
|
}
|
|
1180
|
-
const timer = setTimeout(
|
|
1180
|
+
const timer = setTimeout(resolve22, ms);
|
|
1181
1181
|
const onAbort = () => {
|
|
1182
1182
|
clearTimeout(timer);
|
|
1183
1183
|
reject(signal?.reason ?? new Error("aborted"));
|
|
@@ -1863,7 +1863,7 @@ function normalizeReviewComment(raw) {
|
|
|
1863
1863
|
function createGhApiRunner(options = {}) {
|
|
1864
1864
|
const spawnImpl = options.spawnImpl ?? spawn2;
|
|
1865
1865
|
return async (args, runOptions = {}) => {
|
|
1866
|
-
return await new Promise((
|
|
1866
|
+
return await new Promise((resolve22, reject) => {
|
|
1867
1867
|
const signal = runOptions.signal;
|
|
1868
1868
|
if (signal?.aborted) {
|
|
1869
1869
|
reject(signal.reason ?? new Error("aborted"));
|
|
@@ -1936,11 +1936,11 @@ function createGhApiRunner(options = {}) {
|
|
|
1936
1936
|
const value = line2.slice(idx + 1).trim();
|
|
1937
1937
|
headers[name] = value;
|
|
1938
1938
|
}
|
|
1939
|
-
|
|
1939
|
+
resolve22({ status, headers, bodyText });
|
|
1940
1940
|
return;
|
|
1941
1941
|
}
|
|
1942
1942
|
if (code === 0) {
|
|
1943
|
-
|
|
1943
|
+
resolve22({ status: 200, headers: {}, bodyText: stdout });
|
|
1944
1944
|
return;
|
|
1945
1945
|
}
|
|
1946
1946
|
const failure2 = new Error(
|
|
@@ -3173,7 +3173,7 @@ function withTerminatingOutputDeclarations(schema) {
|
|
|
3173
3173
|
...baseProperties ?? {},
|
|
3174
3174
|
...baseProperties?.ticketNumber === void 0 ? {
|
|
3175
3175
|
ticketNumber: Type3.Unknown({
|
|
3176
|
-
description: "\u53EF\u9009\u672C\u7968\u53F7\
|
|
3176
|
+
description: "\u53EF\u9009\u672C\u7968\u53F7\u3002\u5C1A\u672A\u7ED1\u5B9A\u65F6\u7531\u89D2\u8272\u5728\u65E2\u6709\u56DE\u6267\u4E2D\u7533\u62A5\u3002"
|
|
3177
3177
|
})
|
|
3178
3178
|
} : {},
|
|
3179
3179
|
[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
|
|
@@ -3230,12 +3230,12 @@ var init_terminating_infrastructure = __esm({
|
|
|
3230
3230
|
infrastructureFailureNested = Type3.Object(
|
|
3231
3231
|
{
|
|
3232
3232
|
[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY]: Type3.Unknown({
|
|
3233
|
-
description: "\
|
|
3233
|
+
description: "\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8BCA\u65AD\u5B57\u7B26\u4E32\u3002"
|
|
3234
3234
|
})
|
|
3235
3235
|
},
|
|
3236
3236
|
{
|
|
3237
3237
|
additionalProperties: true,
|
|
3238
|
-
description: "\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\
|
|
3238
|
+
description: "\u4EC5\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\u65F6\u51FA\u73B0\u3002"
|
|
3239
3239
|
}
|
|
3240
3240
|
);
|
|
3241
3241
|
infrastructureFailureNested.required = [];
|
|
@@ -3260,7 +3260,7 @@ var init_gatekeeper_output = __esm({
|
|
|
3260
3260
|
gatekeeperDecisionSchema = openToolObject(
|
|
3261
3261
|
Type4.Object({
|
|
3262
3262
|
status: Type4.Unknown({
|
|
3263
|
-
description: "dispatch | pass
|
|
3263
|
+
description: "dispatch | pass"
|
|
3264
3264
|
}),
|
|
3265
3265
|
officer: Type4.Unknown({
|
|
3266
3266
|
description: "status \u4E3A dispatch \u65F6\u4E3A inspector | notary"
|
|
@@ -3329,7 +3329,7 @@ var init_navigator_output = __esm({
|
|
|
3329
3329
|
openToolObject(
|
|
3330
3330
|
Type5.Object({
|
|
3331
3331
|
prose: Type5.Unknown({
|
|
3332
|
-
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7B49\u7ED3\u6784\u5316\u5B57\u6BB5\u3002
|
|
3332
|
+
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7B49\u7ED3\u6784\u5316\u5B57\u6BB5\u3002"
|
|
3333
3333
|
})
|
|
3334
3334
|
})
|
|
3335
3335
|
)
|
|
@@ -3356,7 +3356,7 @@ var init_review_submission = __esm({
|
|
|
3356
3356
|
Type6.Literal(REVIEW_QUEUE_WORDS[2])
|
|
3357
3357
|
],
|
|
3358
3358
|
{
|
|
3359
|
-
description: "\u5BA1\u6838\
|
|
3359
|
+
description: "\u5BA1\u6838\u5E2D\u672C\u8F6E\u88C1\u51B3\u7684\u5224\u522B\u72B6\u6001\u3002"
|
|
3360
3360
|
}
|
|
3361
3361
|
),
|
|
3362
3362
|
findings: Type6.Optional(Type6.Unknown({ description: "\u5BA1\u6838\u53D1\u73B0\uFF0C\u539F\u6837\u7559\u5B58" })),
|
|
@@ -3429,7 +3429,7 @@ var init_fixer_output = __esm({
|
|
|
3429
3429
|
});
|
|
3430
3430
|
classResultSchema = Type7.Union([completedClassResultSchema, refusedClassResultSchema]);
|
|
3431
3431
|
completedClassResultsSchema = Type7.Array(completedClassResultSchema);
|
|
3432
|
-
FIXER_STATUS_DESCRIPTION = "planned | completed | refused | unfinished | partially_completed
|
|
3432
|
+
FIXER_STATUS_DESCRIPTION = "planned | completed | refused | unfinished | partially_completed\u3002unfinished \u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\uFF0C\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002";
|
|
3433
3433
|
fixerOutputVariants = Type7.Union([
|
|
3434
3434
|
Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
|
|
3435
3435
|
Type7.Object({ status: Type7.Unknown({ description: FIXER_STATUS_DESCRIPTION }), report: Type7.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type7.String({ description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type7.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
|
|
@@ -3589,7 +3589,7 @@ var init_doctor_contracts = __esm({
|
|
|
3589
3589
|
Type9.Object({ targetKey: nonblank, targetKind: Type9.Optional(Type9.Union(assetKinds.map((kind) => Type9.Literal(kind)))), assetEvidence: Type9.Optional(Type9.Object({ targetKey: nonblank, targetKind: Type9.Optional(Type9.Union(assetKinds.map((kind) => Type9.Literal(kind)))), evidenceId: nonblank }, { additionalProperties: true })), ...findingBody }, { additionalProperties: true })
|
|
3590
3590
|
]);
|
|
3591
3591
|
caseIdentity = Type9.Object({ issueNumber: Type9.Optional(Type9.Integer()), runsPath: nonblank }, { additionalProperties: true });
|
|
3592
|
-
DOCTOR_STATUS_DESCRIPTION = "completed | refused
|
|
3592
|
+
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";
|
|
3593
3593
|
doctorSubmissionVariants = Type9.Union([
|
|
3594
3594
|
Type9.Object({
|
|
3595
3595
|
status: Type9.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
|
|
@@ -3715,7 +3715,7 @@ var init_merger_contracts = __esm({
|
|
|
3715
3715
|
resolutionScope: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
|
|
3716
3716
|
authorizedChecks: Type10.Array(checkSchema)
|
|
3717
3717
|
}, { additionalProperties: false });
|
|
3718
|
-
MERGER_STATUS_DESCRIPTION = "completed | escalate
|
|
3718
|
+
MERGER_STATUS_DESCRIPTION = "completed | escalate";
|
|
3719
3719
|
mergerOutputVariants = Type10.Union([
|
|
3720
3720
|
Type10.Object({ status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type10.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type10.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type10.String({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
|
|
3721
3721
|
Type10.Object({ status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }), attemptId: Type10.String({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type10.String({ 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" }), report: Type10.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
|
|
@@ -3736,7 +3736,7 @@ var init_merger_contracts = __esm({
|
|
|
3736
3736
|
});
|
|
3737
3737
|
|
|
3738
3738
|
// src/notary-contracts.ts
|
|
3739
|
-
var NOTARY_OUTPUT_TOOL_NAME, NOTARY_SOURCE_RUN_FLAG, NOTARY_TICKET_FLAG,
|
|
3739
|
+
var NOTARY_OUTPUT_TOOL_NAME, NOTARY_SOURCE_RUN_FLAG, NOTARY_TICKET_FLAG, notaryOutputSchema;
|
|
3740
3740
|
var init_notary_contracts = __esm({
|
|
3741
3741
|
"src/notary-contracts.ts"() {
|
|
3742
3742
|
"use strict";
|
|
@@ -3756,7 +3756,6 @@ var init_notary_contracts = __esm({
|
|
|
3756
3756
|
type: "string"
|
|
3757
3757
|
}
|
|
3758
3758
|
};
|
|
3759
|
-
NOTARY_FIXED_KICKOFF = "\u7B26\u5B9D\u90CE\u6848\u5377\u5DF2\u53D7\u7406\uFF1B\u6765\u6E90 run \u5B9A\u4F4D\u89C1\u4F1A\u8BDD\u6750\u6599\u3002";
|
|
3760
3759
|
notaryOutputSchema = reviewSubmissionSchema;
|
|
3761
3760
|
}
|
|
3762
3761
|
});
|
|
@@ -4253,21 +4252,24 @@ var init_packaged_role_registry = __esm({
|
|
|
4253
4252
|
"souls/notary.md",
|
|
4254
4253
|
"souls/audit-law.md",
|
|
4255
4254
|
"souls/ticket-law.md",
|
|
4256
|
-
"souls/gate-output-guide.md"
|
|
4255
|
+
"souls/gate-output-guide.md",
|
|
4256
|
+
"docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
|
|
4257
4257
|
];
|
|
4258
4258
|
INSPECTOR_SESSION_MATERIALS = [
|
|
4259
4259
|
"CLAUDE.md",
|
|
4260
4260
|
"souls/inspector.md",
|
|
4261
4261
|
"souls/audit-law.md",
|
|
4262
4262
|
"souls/quality-law.md",
|
|
4263
|
-
"souls/gate-output-guide.md"
|
|
4263
|
+
"souls/gate-output-guide.md",
|
|
4264
|
+
"docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
|
|
4264
4265
|
];
|
|
4265
4266
|
AUDITOR_PUBLIC_SESSION_MATERIALS = [
|
|
4266
4267
|
"CLAUDE.md",
|
|
4267
4268
|
"souls/judge-auditor.md",
|
|
4268
4269
|
"souls/doctor-auditor.md",
|
|
4269
4270
|
"souls/audit-law.md",
|
|
4270
|
-
"souls/quality-law.md"
|
|
4271
|
+
"souls/quality-law.md",
|
|
4272
|
+
"docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
|
|
4271
4273
|
];
|
|
4272
4274
|
PUBLIC_ROLE_RECORDS = [
|
|
4273
4275
|
{
|
|
@@ -4295,7 +4297,8 @@ var init_packaged_role_registry = __esm({
|
|
|
4295
4297
|
"souls/judge.md",
|
|
4296
4298
|
"souls/audit-law.md",
|
|
4297
4299
|
"souls/quality-law.md",
|
|
4298
|
-
"souls/judge-output-guide.md"
|
|
4300
|
+
"souls/judge-output-guide.md",
|
|
4301
|
+
"docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
|
|
4299
4302
|
]
|
|
4300
4303
|
},
|
|
4301
4304
|
{
|
|
@@ -4573,7 +4576,7 @@ var init_packaged_role_registry = __esm({
|
|
|
4573
4576
|
activationStage: "load-and-install",
|
|
4574
4577
|
receiptStatusKey: "status",
|
|
4575
4578
|
// #924: 公用《票面法》三席同装
|
|
4576
|
-
sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md"]
|
|
4579
|
+
sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md", "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"]
|
|
4577
4580
|
},
|
|
4578
4581
|
{
|
|
4579
4582
|
role: "secretariat",
|
|
@@ -5109,7 +5112,7 @@ var init_gatekeeper_role = __esm({
|
|
|
5109
5112
|
GATEKEEPER_TOOL_SPEC = {
|
|
5110
5113
|
name: GATEKEEPER_OUTPUT_TOOL_NAME,
|
|
5111
5114
|
label: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
|
|
5112
|
-
description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\
|
|
5115
|
+
description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\u3002status \u4E3A dispatch \u6216 pass\u3002",
|
|
5113
5116
|
promptSnippet: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
|
|
5114
5117
|
parameters: gatekeeperOutputSchema
|
|
5115
5118
|
};
|
|
@@ -5125,10 +5128,10 @@ __export(session_assistant_usage_exports, {
|
|
|
5125
5128
|
});
|
|
5126
5129
|
import { join as join9 } from "node:path";
|
|
5127
5130
|
async function readAssistantUsageFromSessionFile(sessionFile) {
|
|
5128
|
-
const { readFile:
|
|
5131
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
5129
5132
|
let text;
|
|
5130
5133
|
try {
|
|
5131
|
-
text = await
|
|
5134
|
+
text = await readFile26(sessionFile, "utf8");
|
|
5132
5135
|
} catch (error) {
|
|
5133
5136
|
if (error?.code === "ENOENT") return void 0;
|
|
5134
5137
|
throw error;
|
|
@@ -11798,13 +11801,16 @@ function admittedTransportPromptKind(admitted) {
|
|
|
11798
11801
|
function buildInstructionTransportPrompt(admitted, engineMaterial) {
|
|
11799
11802
|
const kind = admittedTransportPromptKind(admitted);
|
|
11800
11803
|
if (kind === "fixed-kickoff") {
|
|
11801
|
-
|
|
11804
|
+
if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
|
|
11805
|
+
throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
|
|
11806
|
+
}
|
|
11807
|
+
return appendEngineSessionMaterial([admitted.sourceRunPath], engineMaterial).join("\n");
|
|
11802
11808
|
}
|
|
11803
11809
|
if (kind === "baseline") {
|
|
11804
11810
|
if (admitted.baseRevision === void 0) {
|
|
11805
11811
|
throw new Error("baseline transport prompt is missing the bound revision");
|
|
11806
11812
|
}
|
|
11807
|
-
const lines2 = [
|
|
11813
|
+
const lines2 = [admitted.baseRevision];
|
|
11808
11814
|
if (!admitted.instructionEmpty) {
|
|
11809
11815
|
lines2.push("", admitted.instruction);
|
|
11810
11816
|
}
|
|
@@ -13385,10 +13391,10 @@ function pairGateRounds(volumes) {
|
|
|
13385
13391
|
return rounds.sort((a, b) => a.officerStartedAt.localeCompare(b.officerStartedAt)).map((round, index) => ({ ...round, roundIndex: index + 1 }));
|
|
13386
13392
|
}
|
|
13387
13393
|
async function resolveOfficerSessionFromPointerFile(pointerPath) {
|
|
13388
|
-
const { readFile:
|
|
13394
|
+
const { readFile: readFile26 } = await import("node:fs/promises");
|
|
13389
13395
|
let raw;
|
|
13390
13396
|
try {
|
|
13391
|
-
raw = JSON.parse(await
|
|
13397
|
+
raw = JSON.parse(await readFile26(pointerPath, "utf8"));
|
|
13392
13398
|
} catch (error) {
|
|
13393
13399
|
throw new Error(
|
|
13394
13400
|
`direct officer run pointer unreadable in ${pointerPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -14143,9 +14149,10 @@ var init_auditor_soul = __esm({
|
|
|
14143
14149
|
"CLAUDE.md",
|
|
14144
14150
|
"souls/judge-auditor.md",
|
|
14145
14151
|
"souls/audit-law.md",
|
|
14146
|
-
"souls/quality-law.md"
|
|
14152
|
+
"souls/quality-law.md",
|
|
14153
|
+
"docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"
|
|
14147
14154
|
],
|
|
14148
|
-
doctor: ["CLAUDE.md", "souls/doctor-auditor.md"]
|
|
14155
|
+
doctor: ["CLAUDE.md", "souls/doctor-auditor.md", "docs/adr/0057-schema-narrowing-cuts-the-required-set-not-the-declared-set.md"]
|
|
14149
14156
|
};
|
|
14150
14157
|
}
|
|
14151
14158
|
});
|
|
@@ -14674,7 +14681,7 @@ function resolveLifecycleInvocationPrincipal(entries, expected) {
|
|
|
14674
14681
|
}
|
|
14675
14682
|
return { invocationId: marker.invocationId, resume: true };
|
|
14676
14683
|
}
|
|
14677
|
-
var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS, PACKAGED_ROLE_OUTPUT_TOOLS;
|
|
14684
|
+
var NAVIGATOR_INVOCATION_ENTRY, NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY, NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND, NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS, NAVIGATOR_INFRASTRUCTURE_FAILURE_EVIDENCE_KEYS, PACKAGED_ROLE_OUTPUT_TOOLS;
|
|
14678
14685
|
var init_navigator_invocation_identity = __esm({
|
|
14679
14686
|
"src/navigator-invocation-identity.ts"() {
|
|
14680
14687
|
"use strict";
|
|
@@ -14682,6 +14689,7 @@ var init_navigator_invocation_identity = __esm({
|
|
|
14682
14689
|
init_uuidv7();
|
|
14683
14690
|
init_work_subject_identity();
|
|
14684
14691
|
NAVIGATOR_INVOCATION_ENTRY = "ak-navigator-invocation";
|
|
14692
|
+
NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY = "ak-navigator-route-playbook-failure";
|
|
14685
14693
|
NAVIGATOR_INFRASTRUCTURE_FAILURE_KIND = "role_infrastructure_failure";
|
|
14686
14694
|
NAVIGATOR_INFRASTRUCTURE_FAILURE_KEYS = [
|
|
14687
14695
|
"kind",
|
|
@@ -14775,17 +14783,25 @@ function createReceiptDeliveryPolicy() {
|
|
|
14775
14783
|
if (accepted) return "accepted";
|
|
14776
14784
|
return deliveryTurns < RECEIPT_DELIVERY_TURN_LIMIT ? "request-delivery" : "no-receipt";
|
|
14777
14785
|
},
|
|
14786
|
+
/** Current typed delivery facts. No prose. */
|
|
14787
|
+
deliveryState() {
|
|
14788
|
+
return {
|
|
14789
|
+
terminalToolCalled,
|
|
14790
|
+
rejectedReceipts: rejectedReceipts.map((item) => ({ ...item })),
|
|
14791
|
+
deliveryTurns,
|
|
14792
|
+
acceptedReceipt: false
|
|
14793
|
+
};
|
|
14794
|
+
},
|
|
14778
14795
|
facts(binding) {
|
|
14779
14796
|
return noReceiptLifecycleFacts({ terminalToolCalled, rejectedReceipts: [...rejectedReceipts], deliveryTurns, ...binding });
|
|
14780
14797
|
}
|
|
14781
14798
|
};
|
|
14782
14799
|
}
|
|
14783
|
-
var RECEIPT_DELIVERY_TURN_LIMIT,
|
|
14800
|
+
var RECEIPT_DELIVERY_TURN_LIMIT, NO_RECEIPT_LIFECYCLE_ENTRY_TYPE;
|
|
14784
14801
|
var init_receipt_delivery_policy = __esm({
|
|
14785
14802
|
"src/receipt-delivery-policy.ts"() {
|
|
14786
14803
|
"use strict";
|
|
14787
14804
|
RECEIPT_DELIVERY_TURN_LIMIT = 2;
|
|
14788
|
-
RECEIPT_DELIVERY_PROMPT = "\u672C\u4F1A\u8BDD\u5C1A\u65E0\u5DF2\u63A5\u53D7\u7684 typed \u56DE\u6267\u3002";
|
|
14789
14805
|
NO_RECEIPT_LIFECYCLE_ENTRY_TYPE = "ak-no-receipt-lifecycle";
|
|
14790
14806
|
}
|
|
14791
14807
|
});
|
|
@@ -15906,7 +15922,23 @@ async function withOptionalGateProjection(base, sessionDirectory, gateContext =
|
|
|
15906
15922
|
}
|
|
15907
15923
|
return attachEngineDetourToolUsage(next, sessionDirectory, gateContext);
|
|
15908
15924
|
}
|
|
15925
|
+
function routePlaybookFailureMessage(entries) {
|
|
15926
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
15927
|
+
const entry = entries[i];
|
|
15928
|
+
if (entry?.type !== "custom" || entry.customType !== NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY) continue;
|
|
15929
|
+
const data = entry.data;
|
|
15930
|
+
if (!isRecord12(data) || typeof data.message !== "string" || data.message.trim() === "") return void 0;
|
|
15931
|
+
return data.message;
|
|
15932
|
+
}
|
|
15933
|
+
return void 0;
|
|
15934
|
+
}
|
|
15909
15935
|
function extractNavigatorFact(entries) {
|
|
15936
|
+
const fact = extractNavigatorAttendanceFact(entries);
|
|
15937
|
+
if (fact.advisoryDiagnostic !== void 0) return fact;
|
|
15938
|
+
const message = routePlaybookFailureMessage(entries);
|
|
15939
|
+
return message === void 0 ? fact : { ...fact, advisoryDiagnostic: message };
|
|
15940
|
+
}
|
|
15941
|
+
function extractNavigatorAttendanceFact(entries) {
|
|
15910
15942
|
const terminal = findLatestDurablePackagedRoleTerminal(entries);
|
|
15911
15943
|
if (terminal === void 0) {
|
|
15912
15944
|
return {
|
|
@@ -16682,10 +16714,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
16682
16714
|
}
|
|
16683
16715
|
function defaultNavigatorGraceSleep() {
|
|
16684
16716
|
let timer;
|
|
16685
|
-
const sleep2 = ((ms) => new Promise((
|
|
16717
|
+
const sleep2 = ((ms) => new Promise((resolve22) => {
|
|
16686
16718
|
timer = setTimeout(() => {
|
|
16687
16719
|
timer = void 0;
|
|
16688
|
-
|
|
16720
|
+
resolve22();
|
|
16689
16721
|
}, ms);
|
|
16690
16722
|
}));
|
|
16691
16723
|
sleep2.cancel = () => {
|
|
@@ -16697,7 +16729,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
16697
16729
|
return sleep2;
|
|
16698
16730
|
}
|
|
16699
16731
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
16700
|
-
return new Promise((
|
|
16732
|
+
return new Promise((resolve22, reject) => {
|
|
16701
16733
|
let settled = false;
|
|
16702
16734
|
const finish = (action) => {
|
|
16703
16735
|
if (settled) return;
|
|
@@ -16706,11 +16738,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
16706
16738
|
action();
|
|
16707
16739
|
};
|
|
16708
16740
|
void work.then(
|
|
16709
|
-
(value) => finish(() =>
|
|
16741
|
+
(value) => finish(() => resolve22({ status: "done", value })),
|
|
16710
16742
|
(error) => finish(() => reject(error))
|
|
16711
16743
|
);
|
|
16712
16744
|
void sleep2(graceMs).then(() => {
|
|
16713
|
-
finish(() =>
|
|
16745
|
+
finish(() => resolve22({ status: "timeout" }));
|
|
16714
16746
|
});
|
|
16715
16747
|
});
|
|
16716
16748
|
}
|
|
@@ -18753,7 +18785,7 @@ async function runCountersignCourtDiaristStation(admitted, env, io, afterTicketN
|
|
|
18753
18785
|
for (const ticketNumber of refreshTickets.slice(completedIndex + 1)) {
|
|
18754
18786
|
const outcome = await invokeCourtDiarist(
|
|
18755
18787
|
{
|
|
18756
|
-
instruction:
|
|
18788
|
+
instruction: admitted.instruction,
|
|
18757
18789
|
projectRoot: admitted.projectRoot,
|
|
18758
18790
|
failureLabel: `ticket #${ticketNumber}`,
|
|
18759
18791
|
correlationId: admitted.runId,
|
|
@@ -19500,8 +19532,8 @@ var init_atomic_write = __esm({
|
|
|
19500
19532
|
import { open as open3, readFile as readFile18, unlink as unlink5 } from "node:fs/promises";
|
|
19501
19533
|
import { dirname as dirname19, join as join36 } from "node:path";
|
|
19502
19534
|
function sleep(ms) {
|
|
19503
|
-
return new Promise((
|
|
19504
|
-
setTimeout(
|
|
19535
|
+
return new Promise((resolve22) => {
|
|
19536
|
+
setTimeout(resolve22, ms);
|
|
19505
19537
|
});
|
|
19506
19538
|
}
|
|
19507
19539
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
@@ -23015,7 +23047,7 @@ init_engine_detour();
|
|
|
23015
23047
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
23016
23048
|
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile11 } from "node:fs/promises";
|
|
23017
23049
|
import { createServer } from "node:net";
|
|
23018
|
-
import { dirname as
|
|
23050
|
+
import { dirname as dirname23, join as join45 } from "node:path";
|
|
23019
23051
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
23020
23052
|
|
|
23021
23053
|
// src/submission-gate.ts
|
|
@@ -23130,7 +23162,7 @@ init_submission_ledger();
|
|
|
23130
23162
|
init_collector_ledger();
|
|
23131
23163
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
23132
23164
|
import { readFileSync as readFileSync6, writeSync as writeSync3 } from "node:fs";
|
|
23133
|
-
import { join as
|
|
23165
|
+
import { join as join44 } from "node:path";
|
|
23134
23166
|
import { Value as Value5 } from "typebox/value";
|
|
23135
23167
|
|
|
23136
23168
|
// src/activation-trace.ts
|
|
@@ -23276,6 +23308,9 @@ function durableSessionPointer(sessionManager) {
|
|
|
23276
23308
|
// src/activation-ledger.ts
|
|
23277
23309
|
init_activation_ledger_topology();
|
|
23278
23310
|
|
|
23311
|
+
// src/role-runtime.ts
|
|
23312
|
+
init_session_opening_materials();
|
|
23313
|
+
|
|
23279
23314
|
// src/stderr-jsonl.ts
|
|
23280
23315
|
import { writeSync } from "node:fs";
|
|
23281
23316
|
var STDERR_JSONL_WRITE_RETRY_LIMIT = 100;
|
|
@@ -23609,10 +23644,10 @@ var collectorOpenWaitWindowArgsSchema = Type15.Object({
|
|
|
23609
23644
|
}, { additionalProperties: true });
|
|
23610
23645
|
var collectorBindTargetArgsSchema = Type15.Object({
|
|
23611
23646
|
prNumber: Type15.Optional(Type15.Unknown({
|
|
23612
|
-
description: "\
|
|
23647
|
+
description: "\u672C\u4ED3 PR \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
|
|
23613
23648
|
})),
|
|
23614
23649
|
issueNumber: Type15.Optional(Type15.Unknown({
|
|
23615
|
-
description: "\
|
|
23650
|
+
description: "\u672C\u4ED3 issue \u53F7\uFF08\u6B63\u6574\u6570\uFF09\u3002"
|
|
23616
23651
|
}))
|
|
23617
23652
|
}, { additionalProperties: true });
|
|
23618
23653
|
var collectorFindingItemDeclaration = (() => {
|
|
@@ -23630,7 +23665,7 @@ var collectorFindingItemDeclaration = (() => {
|
|
|
23630
23665
|
},
|
|
23631
23666
|
{
|
|
23632
23667
|
additionalProperties: true,
|
|
23633
|
-
description: "\u5355\u6761 finding \u6307\u9488\uFF1AevidenceId
|
|
23668
|
+
description: "\u5355\u6761 finding \u6307\u9488\uFF1AevidenceId\uFF0C\u4EE5\u53CA\u53EF\u9009 category\u3001summary\u3002"
|
|
23634
23669
|
}
|
|
23635
23670
|
);
|
|
23636
23671
|
item.required = [];
|
|
@@ -23641,11 +23676,11 @@ var collectorOutputBaseSchema = openToolObject(
|
|
|
23641
23676
|
// No root type:array — host must not shape-reject non-array findings (#676 C).
|
|
23642
23677
|
// Nested item declarations ride `items` for registration preservation (ADR 0057).
|
|
23643
23678
|
findings: Type15.Unsafe({
|
|
23644
|
-
description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings\
|
|
23679
|
+
description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings \u6307\u9488\u3002",
|
|
23645
23680
|
items: collectorFindingItemDeclaration
|
|
23646
23681
|
}),
|
|
23647
23682
|
unfinishedReasons: Type15.Unknown({
|
|
23648
|
-
description: "\u672A\u5B8C\u6210\u539F\u56E0\
|
|
23683
|
+
description: "\u672A\u5B8C\u6210\u539F\u56E0\u3002"
|
|
23649
23684
|
})
|
|
23650
23685
|
})
|
|
23651
23686
|
);
|
|
@@ -23960,7 +23995,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
|
23960
23995
|
pi.registerTool({
|
|
23961
23996
|
name: COLLECTOR_BIND_TARGET_TOOL,
|
|
23962
23997
|
label: "\u901A\u8FDB\u53F8\u8BA4\u7968\u7ED1\u5B9A",
|
|
23963
|
-
description: "\
|
|
23998
|
+
description: "\u7ED1\u5B9A\u672C\u4ED3\u552F\u4E00 PR \u76EE\u6807\u3002",
|
|
23964
23999
|
promptSnippet: "\u7ED1\u5B9A\u89D2\u8272\u5224\u5B9A\u7684 issue/PR \u76EE\u6807",
|
|
23965
24000
|
parameters: bindSchema,
|
|
23966
24001
|
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
@@ -24037,7 +24072,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
|
24037
24072
|
pi.registerTool({
|
|
24038
24073
|
name: COLLECTOR_OBSERVE_TOOL,
|
|
24039
24074
|
label: "\u901A\u8FDB\u53F8\u89C2\u5BDF",
|
|
24040
|
-
description: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807\u7684
|
|
24075
|
+
description: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807\u7684 GitHub PR \u8BC1\u636E\u3002",
|
|
24041
24076
|
promptSnippet: "\u6293\u53D6\u914D\u7F6E\u76EE\u6807 PR \u8BC1\u636E",
|
|
24042
24077
|
parameters: observeSchema,
|
|
24043
24078
|
async execute(toolCallId, _params, signal, _onUpdate, ctx) {
|
|
@@ -24067,7 +24102,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
|
24067
24102
|
pi.registerTool({
|
|
24068
24103
|
name: COLLECTOR_READ_TOOL,
|
|
24069
24104
|
label: "\u901A\u8FDB\u53F8\u5F00\u5377",
|
|
24070
|
-
description: "\u6309 evidenceId \u5F00\u5377\u8BFB\u53D6\u4E00\u6761\u5DF2\u89C2\u6D4B\u6750\u6599\u7684\u5168\u91CF\u6B63\u6587\u4E0E\u6307\u9488\
|
|
24105
|
+
description: "\u6309 evidenceId \u5F00\u5377\u8BFB\u53D6\u4E00\u6761\u5DF2\u89C2\u6D4B\u6750\u6599\u7684\u5168\u91CF\u6B63\u6587\u4E0E\u6307\u9488\u3002",
|
|
24071
24106
|
promptSnippet: "\u6309\u6307\u9488\u5F00\u5377\u8BFB\u6750\u6599",
|
|
24072
24107
|
parameters: readSchema,
|
|
24073
24108
|
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
@@ -24097,7 +24132,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
|
24097
24132
|
pi.registerTool({
|
|
24098
24133
|
name: COLLECTOR_REQUEST_TOOL,
|
|
24099
24134
|
label: "\u901A\u8FDB\u53F8\u8BF7\u6C42",
|
|
24100
|
-
description: "\
|
|
24135
|
+
description: "\u53D1\u4E00\u6B21\u8BF7\u6C42\u3002",
|
|
24101
24136
|
promptSnippet: "\u53D1\u4E00\u6B21\u8BC4\u5BA1\u8BF7\u6C42",
|
|
24102
24137
|
parameters: requestSchema,
|
|
24103
24138
|
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
@@ -24216,7 +24251,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
|
24216
24251
|
pi.registerTool({
|
|
24217
24252
|
name: COLLECTOR_WAIT_TOOL,
|
|
24218
24253
|
label: "\u901A\u8FDB\u53F8\u7B49\u5F85",
|
|
24219
|
-
description: "\
|
|
24254
|
+
description: "\u7B49\u5F85\u3002\u5B9E\u9645\u7761\u7720\u4E0D\u8D85\u8FC7\u5269\u4F59\u7B49\u5F85\u7A97\u3002",
|
|
24220
24255
|
promptSnippet: "\u7B49\u5F85\u7A97\u5185\u7B49\u5F85",
|
|
24221
24256
|
parameters: waitSchema,
|
|
24222
24257
|
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
@@ -24246,7 +24281,7 @@ function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
|
24246
24281
|
pi.registerTool({
|
|
24247
24282
|
name: COLLECTOR_OUTPUT_TOOL,
|
|
24248
24283
|
label: "\u901A\u8FDB\u53F8\u8F93\u51FA",
|
|
24249
|
-
description: "\
|
|
24284
|
+
description: "\u63D0\u4EA4\u901A\u8FDB\u53F8\u56DE\u6267\u3002",
|
|
24250
24285
|
promptSnippet: "\u63D0\u4EA4\u901A\u8FDB\u53F8\u56DE\u6267",
|
|
24251
24286
|
parameters: outputSchema,
|
|
24252
24287
|
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
@@ -24511,7 +24546,7 @@ var gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
|
|
|
24511
24546
|
openToolObject(
|
|
24512
24547
|
Type16.Object({
|
|
24513
24548
|
status: Type16.Unknown({
|
|
24514
|
-
description: "completed
|
|
24549
|
+
description: "completed"
|
|
24515
24550
|
}),
|
|
24516
24551
|
findings: Type16.Array(
|
|
24517
24552
|
Type16.Object(
|
|
@@ -24562,7 +24597,7 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
|
|
|
24562
24597
|
openToolObject(
|
|
24563
24598
|
Type17.Object({
|
|
24564
24599
|
status: Type17.Unknown({
|
|
24565
|
-
description: "completed | escalate
|
|
24600
|
+
description: "completed | escalate"
|
|
24566
24601
|
}),
|
|
24567
24602
|
ticketNumber: Type17.Optional(
|
|
24568
24603
|
Type17.Unknown({
|
|
@@ -24648,7 +24683,7 @@ var secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
|
24648
24683
|
Type18.Object(
|
|
24649
24684
|
{
|
|
24650
24685
|
secretariatStatus: Type18.Unknown({
|
|
24651
|
-
description: "converged | escalate
|
|
24686
|
+
description: "converged | escalate"
|
|
24652
24687
|
}),
|
|
24653
24688
|
ticketNumber: Type18.Optional(
|
|
24654
24689
|
Type18.Number({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
|
|
@@ -24672,7 +24707,7 @@ secretariatVerdictSchema.required = [];
|
|
|
24672
24707
|
var SECRETARIAT_OUTPUT_TOOL_SPEC = {
|
|
24673
24708
|
name: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
24674
24709
|
label: "\u4E2D\u4E66\u7701\u8F93\u51FA",
|
|
24675
|
-
description: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267\
|
|
24710
|
+
description: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267\u3002",
|
|
24676
24711
|
promptSnippet: "\u4E2D\u4E66\u7701\u7EC8\u5C40\u56DE\u6267",
|
|
24677
24712
|
parameters: secretariatVerdictSchema
|
|
24678
24713
|
};
|
|
@@ -24728,13 +24763,14 @@ import { createHash as createHash9 } from "node:crypto";
|
|
|
24728
24763
|
init_navigator_invocation_identity();
|
|
24729
24764
|
init_packaged_role_registry();
|
|
24730
24765
|
init_activation_ledger_topology();
|
|
24731
|
-
import { resolve as
|
|
24766
|
+
import { resolve as resolve18 } from "node:path";
|
|
24732
24767
|
import "@earendil-works/pi-coding-agent";
|
|
24733
24768
|
import { Type as Type20 } from "typebox";
|
|
24734
24769
|
|
|
24735
24770
|
// src/navigator-public-session.ts
|
|
24736
24771
|
init_sitian_facade();
|
|
24737
|
-
import {
|
|
24772
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
24773
|
+
import { basename as basename10 } from "node:path";
|
|
24738
24774
|
|
|
24739
24775
|
// src/navigator-session-contracts.ts
|
|
24740
24776
|
import { Type as Type19 } from "typebox";
|
|
@@ -24924,6 +24960,113 @@ async function resolveNavigatorSeatSelection(context) {
|
|
|
24924
24960
|
init_host_contracts();
|
|
24925
24961
|
init_cli_errors();
|
|
24926
24962
|
init_packaged_role_registry();
|
|
24963
|
+
|
|
24964
|
+
// src/navigator-work-base.ts
|
|
24965
|
+
init_atomic_write();
|
|
24966
|
+
import { existsSync as existsSync12, realpathSync as realpathSync4 } from "node:fs";
|
|
24967
|
+
import { readFile as readFile23 } from "node:fs/promises";
|
|
24968
|
+
import { basename as basename9, dirname as dirname21, join as join42, resolve as resolve17 } from "node:path";
|
|
24969
|
+
var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
|
|
24970
|
+
function navigatorWorkContextFile(sessionDir) {
|
|
24971
|
+
return join42(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
|
|
24972
|
+
}
|
|
24973
|
+
function isNavigatorWorkContextFile(path) {
|
|
24974
|
+
const resolved = resolve17(path);
|
|
24975
|
+
if (basename9(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
|
|
24976
|
+
const nest = dirname21(resolved);
|
|
24977
|
+
if (!/^[0-9a-f]{32}$/.test(basename9(nest))) return false;
|
|
24978
|
+
return basename9(dirname21(nest)) === "navigator";
|
|
24979
|
+
}
|
|
24980
|
+
function canonicalNavigatorWorkContextFile(path) {
|
|
24981
|
+
if (!isNavigatorWorkContextFile(path)) return void 0;
|
|
24982
|
+
try {
|
|
24983
|
+
const real = realpathSync4(path);
|
|
24984
|
+
return isNavigatorWorkContextFile(real) ? real : void 0;
|
|
24985
|
+
} catch {
|
|
24986
|
+
return void 0;
|
|
24987
|
+
}
|
|
24988
|
+
}
|
|
24989
|
+
async function persistNavigatorWorkBase(sessionDir, body) {
|
|
24990
|
+
if (sessionDir.trim() === "" || !existsSync12(sessionDir)) return void 0;
|
|
24991
|
+
if (body.authority.trim() === "") return void 0;
|
|
24992
|
+
const path = navigatorWorkContextFile(sessionDir);
|
|
24993
|
+
const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}
|
|
24994
|
+
`;
|
|
24995
|
+
try {
|
|
24996
|
+
const current = await readFile23(path, "utf8");
|
|
24997
|
+
if (current === next) return path;
|
|
24998
|
+
} catch (error) {
|
|
24999
|
+
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
|
|
25000
|
+
throw error;
|
|
25001
|
+
}
|
|
25002
|
+
}
|
|
25003
|
+
await writeFileAtomically(path, next);
|
|
25004
|
+
return path;
|
|
25005
|
+
}
|
|
25006
|
+
async function readNavigatorWorkBase(path) {
|
|
25007
|
+
const canonical = canonicalNavigatorWorkContextFile(path);
|
|
25008
|
+
if (canonical === void 0) return void 0;
|
|
25009
|
+
let text;
|
|
25010
|
+
try {
|
|
25011
|
+
text = await readFile23(canonical, "utf8");
|
|
25012
|
+
} catch (error) {
|
|
25013
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
25014
|
+
return void 0;
|
|
25015
|
+
}
|
|
25016
|
+
throw error;
|
|
25017
|
+
}
|
|
25018
|
+
let parsed;
|
|
25019
|
+
try {
|
|
25020
|
+
parsed = JSON.parse(text);
|
|
25021
|
+
} catch {
|
|
25022
|
+
return void 0;
|
|
25023
|
+
}
|
|
25024
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
|
|
25025
|
+
const record4 = parsed;
|
|
25026
|
+
if (typeof record4.subject !== "string" || typeof record4.authority !== "string") return void 0;
|
|
25027
|
+
if (record4.authority.trim() === "") return void 0;
|
|
25028
|
+
return { subject: record4.subject, authority: record4.authority };
|
|
25029
|
+
}
|
|
25030
|
+
function jsonObjectFromPrompt(prompt) {
|
|
25031
|
+
const head = prompt.trimStart().split("\n\n", 1)[0] ?? "";
|
|
25032
|
+
if (!head.startsWith("{")) return void 0;
|
|
25033
|
+
try {
|
|
25034
|
+
const parsed = JSON.parse(head);
|
|
25035
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
|
|
25036
|
+
return parsed;
|
|
25037
|
+
} catch {
|
|
25038
|
+
return void 0;
|
|
25039
|
+
}
|
|
25040
|
+
}
|
|
25041
|
+
function workContextPathFromPrompt(prompt) {
|
|
25042
|
+
const record4 = jsonObjectFromPrompt(prompt);
|
|
25043
|
+
const path = record4?.workContextPath;
|
|
25044
|
+
if (typeof path !== "string" || path.trim() === "") return void 0;
|
|
25045
|
+
return isNavigatorWorkContextFile(path) ? path : void 0;
|
|
25046
|
+
}
|
|
25047
|
+
function attachWorkContextPointer(text, workContextPath) {
|
|
25048
|
+
const record4 = jsonObjectFromPrompt(text);
|
|
25049
|
+
if (record4 === void 0) return text;
|
|
25050
|
+
if (typeof record4.workContextPath === "string" && record4.workContextPath.trim() !== "") return text;
|
|
25051
|
+
const head = text.trimStart().split("\n\n", 1)[0] ?? "";
|
|
25052
|
+
const rest = text.trimStart().slice(head.length);
|
|
25053
|
+
return `${JSON.stringify({ ...record4, workContextPath })}${rest}`;
|
|
25054
|
+
}
|
|
25055
|
+
async function loadNavigatorWorkBaseSuffix(prompt) {
|
|
25056
|
+
const path = workContextPathFromPrompt(prompt);
|
|
25057
|
+
if (path === void 0) return void 0;
|
|
25058
|
+
const body = await readNavigatorWorkBase(path);
|
|
25059
|
+
if (body === void 0) return void 0;
|
|
25060
|
+
return `<work_subject>
|
|
25061
|
+
${body.subject}
|
|
25062
|
+
</work_subject>
|
|
25063
|
+
|
|
25064
|
+
<controlling_authority>
|
|
25065
|
+
${body.authority}
|
|
25066
|
+
</controlling_authority>`;
|
|
25067
|
+
}
|
|
25068
|
+
|
|
25069
|
+
// src/navigator-public-session.ts
|
|
24927
25070
|
async function resolveNavigatorLedgerHome(context) {
|
|
24928
25071
|
const { tryHomeFromAkRolesPath: tryHomeFromAkRolesPath2 } = await Promise.resolve().then(() => (init_activation_ledger_topology(), activation_ledger_topology_exports));
|
|
24929
25072
|
const runDirectory = runDirectoryFromHostContext(context);
|
|
@@ -24943,7 +25086,7 @@ function exactRecord2(value) {
|
|
|
24943
25086
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24944
25087
|
}
|
|
24945
25088
|
function runIdFromNavigatorDirectory(runDirectory) {
|
|
24946
|
-
const entry =
|
|
25089
|
+
const entry = basename10(runDirectory);
|
|
24947
25090
|
const suffix = "@navigator";
|
|
24948
25091
|
if (!entry.endsWith(suffix)) return void 0;
|
|
24949
25092
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
@@ -24987,6 +25130,7 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
24987
25130
|
});
|
|
24988
25131
|
let providerFailure;
|
|
24989
25132
|
let noReceipt;
|
|
25133
|
+
let routePlaybookReadFailure;
|
|
24990
25134
|
let disposed = false;
|
|
24991
25135
|
let hostRunId = readNavigatorHostRunPointer(sessionManager.getEntries());
|
|
24992
25136
|
const summon = deps?.summonPublicRole ?? (async (options) => {
|
|
@@ -25000,13 +25144,16 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
25000
25144
|
}
|
|
25001
25145
|
providerFailure = void 0;
|
|
25002
25146
|
noReceipt = void 0;
|
|
25147
|
+
routePlaybookReadFailure = void 0;
|
|
25003
25148
|
try {
|
|
25004
25149
|
const summonHome = await resolveNavigatorLedgerHome(context);
|
|
25005
25150
|
if (disposed) return;
|
|
25006
25151
|
const resumeRunId = hostRunId;
|
|
25152
|
+
const workContextPath = navigatorWorkContextFile(sessionManager.getSessionDir());
|
|
25153
|
+
const argvText = existsSync13(workContextPath) ? attachWorkContextPointer(text, workContextPath) : text;
|
|
25007
25154
|
const baseSummon = {
|
|
25008
25155
|
role: "navigator",
|
|
25009
|
-
argv: [
|
|
25156
|
+
argv: [argvText],
|
|
25010
25157
|
cwd: context.cwd,
|
|
25011
25158
|
...summonHome === void 0 ? {} : { home: summonHome },
|
|
25012
25159
|
...context.signal === void 0 ? {} : { signal: context.signal }
|
|
@@ -25027,6 +25174,8 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
25027
25174
|
}
|
|
25028
25175
|
}
|
|
25029
25176
|
if (disposed) return;
|
|
25177
|
+
const playbookFailure = summoned.terminal?.navigator?.advisoryDiagnostic;
|
|
25178
|
+
routePlaybookReadFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
|
|
25030
25179
|
const outcome = summoned.terminal?.roleOutcome;
|
|
25031
25180
|
if (outcome === void 0) {
|
|
25032
25181
|
const detail = summoned.stderr?.trim() || `exit ${summoned.exitCode}`;
|
|
@@ -25085,6 +25234,7 @@ function createNativeNavigatorSessionFactory(deps) {
|
|
|
25085
25234
|
},
|
|
25086
25235
|
providerFailure: () => providerFailure,
|
|
25087
25236
|
noReceipt: () => noReceipt,
|
|
25237
|
+
routePlaybookReadFailure: () => routePlaybookReadFailure,
|
|
25088
25238
|
appendEntry: (customType, data) => {
|
|
25089
25239
|
sessionManager.appendCustomEntry(customType, data);
|
|
25090
25240
|
try {
|
|
@@ -25124,7 +25274,6 @@ init_work_subject_identity();
|
|
|
25124
25274
|
init_receipt_delivery_policy();
|
|
25125
25275
|
init_navigator_output();
|
|
25126
25276
|
var NAVIGATOR_EVENT_TYPE = "ak-navigator-attendance";
|
|
25127
|
-
var NAVIGATOR_PREPARE_ACCEPTED_TEXT = "\u6E38\u5955\u4F7F\u51C6\u5907\u5DF2\u63A5\u53D7";
|
|
25128
25277
|
function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
|
|
25129
25278
|
if (roleInput !== void 0 && roleInput.trim() !== "") return roleInput;
|
|
25130
25279
|
if (fileAuthority !== void 0 && fileAuthority.trim() !== "") return fileAuthority;
|
|
@@ -25133,10 +25282,9 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
|
|
|
25133
25282
|
var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
|
|
25134
25283
|
var prepareSchema = Type20.Object({
|
|
25135
25284
|
prose: Type20.Optional(Type20.Unknown({
|
|
25136
|
-
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002
|
|
25285
|
+
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
|
|
25137
25286
|
}))
|
|
25138
25287
|
}, { additionalProperties: true });
|
|
25139
|
-
var CONTEXT_ENTRY = "ak-navigator-context";
|
|
25140
25288
|
var INVOCATION_ENTRY = NAVIGATOR_INVOCATION_ENTRY;
|
|
25141
25289
|
var SETTLEMENT_ENTRY = "ak-navigator-settlement";
|
|
25142
25290
|
function exactRecord3(value) {
|
|
@@ -25176,7 +25324,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
25176
25324
|
}
|
|
25177
25325
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
25178
25326
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
25179
|
-
const resolvedReference =
|
|
25327
|
+
const resolvedReference = resolve18(cwd, reference);
|
|
25180
25328
|
const marker = "/runs/";
|
|
25181
25329
|
if (resolvedReference.includes(marker)) {
|
|
25182
25330
|
return subjectRoot;
|
|
@@ -25191,12 +25339,12 @@ function createNavigatorPrepareTool(onOutput) {
|
|
|
25191
25339
|
parameters: prepareSchema,
|
|
25192
25340
|
async execute(_id, value) {
|
|
25193
25341
|
onOutput(value);
|
|
25194
|
-
return { content: [
|
|
25342
|
+
return { content: [], details: value, terminate: true };
|
|
25195
25343
|
}
|
|
25196
25344
|
};
|
|
25197
25345
|
}
|
|
25198
25346
|
function formatNavigatorReport(report) {
|
|
25199
|
-
const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [
|
|
25347
|
+
const playbookFailure = report.routePlaybookReadFailure === void 0 ? [] : [report.routePlaybookReadFailure];
|
|
25200
25348
|
if (report.disposition === "no-advice") return playbookFailure.join("\n");
|
|
25201
25349
|
if (report.disposition === "unavailable") {
|
|
25202
25350
|
return [...playbookFailure, ...report.unavailableReason ? [report.unavailableReason] : []].join("\n");
|
|
@@ -25222,28 +25370,15 @@ function createNavigatorAttendance(options) {
|
|
|
25222
25370
|
let settlementTail = Promise.resolve();
|
|
25223
25371
|
let settlementFailure;
|
|
25224
25372
|
let preparationFailure;
|
|
25225
|
-
let
|
|
25373
|
+
let observedRoutePlaybookFailure;
|
|
25226
25374
|
let disposed = false;
|
|
25227
25375
|
let closing;
|
|
25228
25376
|
const nestCancel = new AbortController();
|
|
25229
|
-
let warmedHelp;
|
|
25230
25377
|
const sessionHostContext = () => {
|
|
25231
25378
|
const parentSignal = options.context.signal;
|
|
25232
25379
|
const signal = parentSignal === void 0 ? nestCancel.signal : AbortSignal.any([nestCancel.signal, parentSignal]);
|
|
25233
25380
|
return { ...options.context, signal };
|
|
25234
25381
|
};
|
|
25235
|
-
const loadLiveHelp = async () => {
|
|
25236
|
-
try {
|
|
25237
|
-
return await Promise.all(
|
|
25238
|
-
NAVIGATOR_TARGETS.map(async ({ role }) => ({
|
|
25239
|
-
role,
|
|
25240
|
-
help: await options.loadRoleHelp(role)
|
|
25241
|
-
}))
|
|
25242
|
-
);
|
|
25243
|
-
} catch (error) {
|
|
25244
|
-
throw navigatorUnavailableError("transport", error);
|
|
25245
|
-
}
|
|
25246
|
-
};
|
|
25247
25382
|
const unavailable = (invocationId, reason) => {
|
|
25248
25383
|
const failure2 = reason instanceof NavigatorUnavailableError ? reason : navigatorUnavailableError("unknown", reason);
|
|
25249
25384
|
return {
|
|
@@ -25253,7 +25388,6 @@ function createNavigatorAttendance(options) {
|
|
|
25253
25388
|
unavailableCause: failure2.unavailableCause
|
|
25254
25389
|
};
|
|
25255
25390
|
};
|
|
25256
|
-
let routePlaybookSettlement;
|
|
25257
25391
|
let prepareBoundSettlement;
|
|
25258
25392
|
const loadMaterialsAndSession = async (invocationId) => {
|
|
25259
25393
|
if (contextError !== void 0) throw navigatorUnavailableError("context", contextError);
|
|
@@ -25263,30 +25397,6 @@ function createNavigatorAttendance(options) {
|
|
|
25263
25397
|
new Error("controlling authority content was not supplied as typed work context")
|
|
25264
25398
|
);
|
|
25265
25399
|
}
|
|
25266
|
-
let soul;
|
|
25267
|
-
let modelSetting;
|
|
25268
|
-
let help;
|
|
25269
|
-
let routePlaybook = "";
|
|
25270
|
-
routePlaybookReadFailure = void 0;
|
|
25271
|
-
const soulPromise = (async () => {
|
|
25272
|
-
try {
|
|
25273
|
-
const text = (await options.loadSoul()).trim();
|
|
25274
|
-
if (!text) throw new Error("Navigator soul is empty");
|
|
25275
|
-
return text;
|
|
25276
|
-
} catch (error) {
|
|
25277
|
-
throw navigatorUnavailableError("context", error);
|
|
25278
|
-
}
|
|
25279
|
-
})();
|
|
25280
|
-
const routePlaybookPromise = (async () => {
|
|
25281
|
-
if (options.loadRoutePlaybook === void 0) return "";
|
|
25282
|
-
try {
|
|
25283
|
-
return await options.loadRoutePlaybook();
|
|
25284
|
-
} catch (error) {
|
|
25285
|
-
routePlaybookReadFailure = error instanceof Error ? error.message : String(error);
|
|
25286
|
-
return "";
|
|
25287
|
-
}
|
|
25288
|
-
})();
|
|
25289
|
-
routePlaybookSettlement = routePlaybookPromise.then(() => void 0);
|
|
25290
25400
|
const modelPromise = (async () => {
|
|
25291
25401
|
try {
|
|
25292
25402
|
const resolved = await resolveNavigatorSeatSelection(options.context);
|
|
@@ -25296,23 +25406,13 @@ function createNavigatorAttendance(options) {
|
|
|
25296
25406
|
throw navigatorUnavailableError("model", error);
|
|
25297
25407
|
}
|
|
25298
25408
|
})();
|
|
25299
|
-
const
|
|
25300
|
-
warmedHelp = void 0;
|
|
25301
|
-
[soul, routePlaybook, modelSetting, help] = await Promise.all([
|
|
25302
|
-
soulPromise,
|
|
25303
|
-
routePlaybookPromise,
|
|
25304
|
-
modelPromise,
|
|
25305
|
-
helpPromise
|
|
25306
|
-
]);
|
|
25409
|
+
const modelSetting = await modelPromise;
|
|
25307
25410
|
let model;
|
|
25308
25411
|
try {
|
|
25309
25412
|
model = parseNavigatorModelSetting(modelSetting);
|
|
25310
25413
|
} catch (error) {
|
|
25311
25414
|
throw navigatorUnavailableError("model", error);
|
|
25312
25415
|
}
|
|
25313
|
-
const helpContext = help.map(({ role, help: text }) => `<role_help role="${role}">
|
|
25314
|
-
${text}
|
|
25315
|
-
</role_help>`).join("\n");
|
|
25316
25416
|
const tool = createNavigatorPrepareTool((value) => {
|
|
25317
25417
|
outputSink?.(value);
|
|
25318
25418
|
});
|
|
@@ -25357,9 +25457,9 @@ ${text}
|
|
|
25357
25457
|
}
|
|
25358
25458
|
if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
|
|
25359
25459
|
if (session === void 0) throw new Error("Navigator session was not created");
|
|
25360
|
-
return
|
|
25460
|
+
return session;
|
|
25361
25461
|
};
|
|
25362
|
-
const prepare = async (
|
|
25462
|
+
const prepare = async (existingSession) => {
|
|
25363
25463
|
const boundSettlement = prepareBoundSettlement;
|
|
25364
25464
|
prepareBoundSettlement = void 0;
|
|
25365
25465
|
const invocationId = invocationPrincipal;
|
|
@@ -25376,73 +25476,19 @@ ${text}
|
|
|
25376
25476
|
const merged = [prior, next].filter((part) => part.trim() !== "").join("\n\n");
|
|
25377
25477
|
output = { prose: merged };
|
|
25378
25478
|
};
|
|
25379
|
-
const
|
|
25380
|
-
|
|
25381
|
-
const
|
|
25382
|
-
|
|
25383
|
-
|
|
25384
|
-
|
|
25385
|
-
|
|
25386
|
-
...boundSettlement === void 0 ? {} : { currentSettlement: boundSettlement },
|
|
25387
|
-
publicSettlementHistory,
|
|
25388
|
-
liveRoleHelp: help
|
|
25389
|
-
};
|
|
25390
|
-
activeSession.appendEntry(CONTEXT_ENTRY, projection);
|
|
25391
|
-
const request = boundSettlement === void 0 ? [
|
|
25392
|
-
"\u672C\u8F6E\u4E3A\u5F85\u547D\u8F6E\u3002",
|
|
25393
|
-
`<navigator_soul>
|
|
25394
|
-
${soul}
|
|
25395
|
-
</navigator_soul>`,
|
|
25396
|
-
...routePlaybookReadFailure === void 0 ? [`<route_playbook>
|
|
25397
|
-
${routePlaybook}
|
|
25398
|
-
</route_playbook>`] : ["\u53EF\u9009\u8DEF\u7EBF\u624B\u518C\u672A\u80FD\u8BFB\u53D6\u3002"],
|
|
25399
|
-
`<work_subject>
|
|
25400
|
-
${subject}
|
|
25401
|
-
</work_subject>`,
|
|
25402
|
-
`<controlling_authority>
|
|
25403
|
-
${authority}
|
|
25404
|
-
</controlling_authority>`,
|
|
25405
|
-
`<current_role>
|
|
25406
|
-
${JSON.stringify({ role: options.role, phase: options.phase })}
|
|
25407
|
-
</current_role>`,
|
|
25408
|
-
`<public_settlement_history>
|
|
25409
|
-
${JSON.stringify(projection.publicSettlementHistory)}
|
|
25410
|
-
</public_settlement_history>`,
|
|
25411
|
-
`<live_role_help>
|
|
25412
|
-
${helpContext}
|
|
25413
|
-
</live_role_help>`
|
|
25414
|
-
].join("\n\n") : [
|
|
25415
|
-
"\u672C\u8F6E\u4E3A\u7ED3\u7B97\u6295\u5582\u8F6E\u3002",
|
|
25416
|
-
`<navigator_soul>
|
|
25417
|
-
${soul}
|
|
25418
|
-
</navigator_soul>`,
|
|
25419
|
-
...routePlaybookReadFailure === void 0 ? [`<route_playbook>
|
|
25420
|
-
${routePlaybook}
|
|
25421
|
-
</route_playbook>`] : ["\u53EF\u9009\u8DEF\u7EBF\u624B\u518C\u672A\u80FD\u8BFB\u53D6\u3002"],
|
|
25422
|
-
`<work_subject>
|
|
25423
|
-
${subject}
|
|
25424
|
-
</work_subject>`,
|
|
25425
|
-
`<controlling_authority>
|
|
25426
|
-
${authority}
|
|
25427
|
-
</controlling_authority>`,
|
|
25428
|
-
`<current_role>
|
|
25429
|
-
${JSON.stringify({ role: options.role, phase: options.phase })}
|
|
25430
|
-
</current_role>`,
|
|
25431
|
-
`<current_settlement>
|
|
25432
|
-
${JSON.stringify(boundSettlement)}
|
|
25433
|
-
</current_settlement>`,
|
|
25434
|
-
`<public_settlement_history>
|
|
25435
|
-
${JSON.stringify(projection.publicSettlementHistory)}
|
|
25436
|
-
</public_settlement_history>`,
|
|
25437
|
-
`<live_role_help>
|
|
25438
|
-
${helpContext}
|
|
25439
|
-
</live_role_help>`
|
|
25440
|
-
].join("\n\n");
|
|
25479
|
+
const activeSession = existingSession ?? await loadMaterialsAndSession(invocationId);
|
|
25480
|
+
if (boundSettlement === void 0) return void 0;
|
|
25481
|
+
const request = JSON.stringify({
|
|
25482
|
+
...boundSettlement,
|
|
25483
|
+
invocationId,
|
|
25484
|
+
subjectKey
|
|
25485
|
+
});
|
|
25441
25486
|
try {
|
|
25442
25487
|
try {
|
|
25443
25488
|
if (disposed) throw navigatorUnavailableError("session", new Error("Navigator attendance was disposed"));
|
|
25444
25489
|
const delivery = createReceiptDeliveryPolicy();
|
|
25445
25490
|
const promptAllowingRejectedPrepare = async (text, deliveryRequest) => {
|
|
25491
|
+
await persistNavigatorWorkBase(activeSession.recordPointer(), { subject, authority });
|
|
25446
25492
|
const entryStart = activeSession.entries().length;
|
|
25447
25493
|
prepareBatchRejected = false;
|
|
25448
25494
|
let promptFailure;
|
|
@@ -25473,7 +25519,7 @@ ${helpContext}
|
|
|
25473
25519
|
await promptAllowingRejectedPrepare(request, false);
|
|
25474
25520
|
if (boundSettlement !== void 0) {
|
|
25475
25521
|
while (output === void 0 && prepareBatchRejected && delivery.nextAction() === "request-delivery") {
|
|
25476
|
-
await promptAllowingRejectedPrepare(
|
|
25522
|
+
await promptAllowingRejectedPrepare(JSON.stringify(delivery.deliveryState()), true);
|
|
25477
25523
|
}
|
|
25478
25524
|
if (output === void 0 && delivery.nextAction() === "request-delivery") {
|
|
25479
25525
|
while (delivery.nextAction() === "request-delivery") {
|
|
@@ -25513,6 +25559,8 @@ ${helpContext}
|
|
|
25513
25559
|
preparedProse = normalizePrepareProse(output);
|
|
25514
25560
|
return preparedProse;
|
|
25515
25561
|
} finally {
|
|
25562
|
+
const playbookFailure = activeSession.routePlaybookReadFailure?.();
|
|
25563
|
+
observedRoutePlaybookFailure = typeof playbookFailure === "string" && playbookFailure.trim() !== "" ? playbookFailure : void 0;
|
|
25516
25564
|
outputSink = void 0;
|
|
25517
25565
|
}
|
|
25518
25566
|
};
|
|
@@ -25530,16 +25578,6 @@ ${helpContext}
|
|
|
25530
25578
|
contextError = next.contextError;
|
|
25531
25579
|
return closing2;
|
|
25532
25580
|
},
|
|
25533
|
-
/**
|
|
25534
|
-
* Start live-help subprocesses during activation without beginning full
|
|
25535
|
-
* preparation. Next prepare() consumes the warm result; a later prepare
|
|
25536
|
-
* reloads so live help edits remain visible.
|
|
25537
|
-
*/
|
|
25538
|
-
warmHelp() {
|
|
25539
|
-
if (disposed || warmedHelp !== void 0 || preparation !== void 0) return;
|
|
25540
|
-
warmedHelp = loadLiveHelp();
|
|
25541
|
-
void warmedHelp.catch(() => void 0);
|
|
25542
|
-
},
|
|
25543
25581
|
prepare() {
|
|
25544
25582
|
if (disposed || preparation !== void 0) return;
|
|
25545
25583
|
preparationFailure = void 0;
|
|
@@ -25554,9 +25592,6 @@ ${helpContext}
|
|
|
25554
25592
|
isPreparing() {
|
|
25555
25593
|
return preparationInFlight;
|
|
25556
25594
|
},
|
|
25557
|
-
knownRoutePlaybookReadFailure() {
|
|
25558
|
-
return routePlaybookReadFailure;
|
|
25559
|
-
},
|
|
25560
25595
|
settle(settlement) {
|
|
25561
25596
|
const next = settlementTail.then(() => settleOnce(settlement));
|
|
25562
25597
|
settlementTail = next.catch((error) => {
|
|
@@ -25583,6 +25618,7 @@ ${helpContext}
|
|
|
25583
25618
|
};
|
|
25584
25619
|
async function settleOnce(settlement) {
|
|
25585
25620
|
if (disposed) return;
|
|
25621
|
+
observedRoutePlaybookFailure = void 0;
|
|
25586
25622
|
const invocationId = activeInvocationId ?? invocationPrincipal;
|
|
25587
25623
|
let report;
|
|
25588
25624
|
if (sessionReady !== void 0) {
|
|
@@ -25621,10 +25657,10 @@ ${helpContext}
|
|
|
25621
25657
|
}
|
|
25622
25658
|
} else {
|
|
25623
25659
|
if (session !== void 0) preparationFailure = void 0;
|
|
25624
|
-
let
|
|
25660
|
+
let coldSession;
|
|
25625
25661
|
if (session === void 0 && preparationFailure === void 0) {
|
|
25626
25662
|
try {
|
|
25627
|
-
|
|
25663
|
+
coldSession = await loadMaterialsAndSession(invocationId);
|
|
25628
25664
|
} catch (error) {
|
|
25629
25665
|
preparationFailure = error;
|
|
25630
25666
|
}
|
|
@@ -25632,7 +25668,7 @@ ${helpContext}
|
|
|
25632
25668
|
session?.appendEntry(SETTLEMENT_ENTRY, settlementFact);
|
|
25633
25669
|
if (preparationFailure === void 0) {
|
|
25634
25670
|
prepareBoundSettlement = settlement;
|
|
25635
|
-
preparation = prepare(
|
|
25671
|
+
preparation = prepare(coldSession);
|
|
25636
25672
|
void preparation.catch((error) => {
|
|
25637
25673
|
preparationFailure = error;
|
|
25638
25674
|
});
|
|
@@ -25651,9 +25687,8 @@ ${helpContext}
|
|
|
25651
25687
|
report = { disposition: "no-advice" };
|
|
25652
25688
|
}
|
|
25653
25689
|
}
|
|
25654
|
-
|
|
25655
|
-
|
|
25656
|
-
report = { ...report, routePlaybookReadFailure };
|
|
25690
|
+
if (observedRoutePlaybookFailure !== void 0) {
|
|
25691
|
+
report = { ...report, routePlaybookReadFailure: observedRoutePlaybookFailure };
|
|
25657
25692
|
}
|
|
25658
25693
|
const event = {
|
|
25659
25694
|
version: 1,
|
|
@@ -25680,8 +25715,6 @@ ${helpContext}
|
|
|
25680
25715
|
sessionReady = void 0;
|
|
25681
25716
|
preparedProse = void 0;
|
|
25682
25717
|
preparationFailure = void 0;
|
|
25683
|
-
routePlaybookSettlement = void 0;
|
|
25684
|
-
routePlaybookReadFailure = void 0;
|
|
25685
25718
|
}
|
|
25686
25719
|
}
|
|
25687
25720
|
|
|
@@ -25711,7 +25744,7 @@ function createJudgeRoleRuntime(pi, dependencies, hostActions) {
|
|
|
25711
25744
|
pi.registerTool({
|
|
25712
25745
|
name: JUDGE_OUTPUT_TOOL_NAME,
|
|
25713
25746
|
label: "\u5927\u7406\u5BFA\u8F93\u51FA",
|
|
25714
|
-
description: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD\
|
|
25747
|
+
description: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD\u3002",
|
|
25715
25748
|
promptSnippet: "\u63D0\u4EA4\u5927\u7406\u5BFA\u7EC8\u5C40\u5224\u8BCD",
|
|
25716
25749
|
parameters: judgeVerdictSchema,
|
|
25717
25750
|
async execute(toolCallId, parameters, signal, _onUpdate, ctx) {
|
|
@@ -25806,9 +25839,9 @@ var reviewerAmendmentsSchema = Type21.Object({
|
|
|
25806
25839
|
}))
|
|
25807
25840
|
}, {
|
|
25808
25841
|
additionalProperties: true,
|
|
25809
|
-
description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002
|
|
25842
|
+
description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002"
|
|
25810
25843
|
});
|
|
25811
|
-
var REVIEWER_STATUS_DESCRIPTION = "completed | refused
|
|
25844
|
+
var REVIEWER_STATUS_DESCRIPTION = "completed | refused\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
|
|
25812
25845
|
var reviewerOutputVariants = Type21.Union([
|
|
25813
25846
|
Type21.Object({
|
|
25814
25847
|
status: Type21.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
|
|
@@ -25837,7 +25870,7 @@ function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
|
25837
25870
|
pi.registerTool({
|
|
25838
25871
|
name: REVIEWER_OUTPUT_TOOL_NAME,
|
|
25839
25872
|
label: "\u5FA1\u53F2\u53F0\u8F93\u51FA",
|
|
25840
|
-
description: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267\u3002
|
|
25873
|
+
description: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267\u3002",
|
|
25841
25874
|
promptSnippet: "\u63D0\u4EA4\u5FA1\u53F2\u53F0\u7EC8\u5C40\u56DE\u6267",
|
|
25842
25875
|
parameters: reviewerOutputSchema,
|
|
25843
25876
|
async execute(_id, parameters) {
|
|
@@ -25877,8 +25910,8 @@ init_sitian_facade();
|
|
|
25877
25910
|
init_submission_errors();
|
|
25878
25911
|
init_submission_errors();
|
|
25879
25912
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
25880
|
-
import { existsSync as
|
|
25881
|
-
import { resolve as
|
|
25913
|
+
import { existsSync as existsSync14, lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5, rmdirSync, rmSync } from "node:fs";
|
|
25914
|
+
import { resolve as resolve19 } from "node:path";
|
|
25882
25915
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
25883
25916
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
25884
25917
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -25908,7 +25941,7 @@ function statusOf(error) {
|
|
|
25908
25941
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
25909
25942
|
}
|
|
25910
25943
|
function tryGetAll(file, key) {
|
|
25911
|
-
if (!
|
|
25944
|
+
if (!existsSync14(file)) return [];
|
|
25912
25945
|
try {
|
|
25913
25946
|
const out = gitFile(file, ["--get-all", key]);
|
|
25914
25947
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -25918,7 +25951,7 @@ function tryGetAll(file, key) {
|
|
|
25918
25951
|
}
|
|
25919
25952
|
}
|
|
25920
25953
|
function ownedHook(path) {
|
|
25921
|
-
if (!
|
|
25954
|
+
if (!existsSync14(path)) return false;
|
|
25922
25955
|
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
25923
25956
|
}
|
|
25924
25957
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -25927,7 +25960,7 @@ function escapeGitConfigValueRegex(value) {
|
|
|
25927
25960
|
function unsetOwnedHooksPath(file) {
|
|
25928
25961
|
const owned = [];
|
|
25929
25962
|
for (const value of tryGetAll(file, "core.hooksPath")) {
|
|
25930
|
-
if (!ownedHook(
|
|
25963
|
+
if (!ownedHook(resolve19(value, HOOK_FILE))) continue;
|
|
25931
25964
|
try {
|
|
25932
25965
|
gitFile(file, [
|
|
25933
25966
|
"--unset-all",
|
|
@@ -25942,15 +25975,15 @@ function unsetOwnedHooksPath(file) {
|
|
|
25942
25975
|
return owned;
|
|
25943
25976
|
}
|
|
25944
25977
|
function rmOwnedDir(dir) {
|
|
25945
|
-
const hookPath =
|
|
25978
|
+
const hookPath = resolve19(dir, HOOK_FILE);
|
|
25946
25979
|
if (!ownedHook(hookPath)) return;
|
|
25947
25980
|
rmSync(hookPath, { force: true });
|
|
25948
|
-
if (
|
|
25981
|
+
if (existsSync14(dir) && readdirSync3(dir).length === 0) rmdirSync(dir);
|
|
25949
25982
|
}
|
|
25950
25983
|
function linkedGitDirs(commonDir) {
|
|
25951
|
-
const root =
|
|
25952
|
-
if (!
|
|
25953
|
-
return readdirSync3(root).map((name) =>
|
|
25984
|
+
const root = resolve19(commonDir, "worktrees");
|
|
25985
|
+
if (!existsSync14(root)) return [];
|
|
25986
|
+
return readdirSync3(root).map((name) => resolve19(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
25954
25987
|
}
|
|
25955
25988
|
function uninstallPackageWorkerHooks(cwd) {
|
|
25956
25989
|
let inside;
|
|
@@ -25964,14 +25997,14 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
25964
25997
|
const clear = (configFile) => {
|
|
25965
25998
|
for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
|
|
25966
25999
|
};
|
|
25967
|
-
clear(
|
|
25968
|
-
clear(
|
|
25969
|
-
rmOwnedDir(
|
|
25970
|
-
const legacy =
|
|
26000
|
+
clear(resolve19(commonDir, "config"));
|
|
26001
|
+
clear(resolve19(commonDir, "config.worktree"));
|
|
26002
|
+
rmOwnedDir(resolve19(commonDir, HOOKS_DIR));
|
|
26003
|
+
const legacy = resolve19(commonDir, "hooks", HOOK_FILE);
|
|
25971
26004
|
if (ownedHook(legacy)) rmSync(legacy, { force: true });
|
|
25972
26005
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
25973
|
-
clear(
|
|
25974
|
-
rmOwnedDir(
|
|
26006
|
+
clear(resolve19(gitDir, "config.worktree"));
|
|
26007
|
+
rmOwnedDir(resolve19(gitDir, HOOKS_DIR));
|
|
25975
26008
|
}
|
|
25976
26009
|
}
|
|
25977
26010
|
function isRecord17(value) {
|
|
@@ -26133,7 +26166,7 @@ function fixerBashSeatbeltDenyReason(matched) {
|
|
|
26133
26166
|
}
|
|
26134
26167
|
|
|
26135
26168
|
// src/worker-role.ts
|
|
26136
|
-
var CODER_STATUS_DESCRIPTION = "planned | completed | refused | partially_completed | unfinished
|
|
26169
|
+
var 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";
|
|
26137
26170
|
var coderOutputVariants = Type22.Union([
|
|
26138
26171
|
Type22.Object({
|
|
26139
26172
|
status: Type22.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
@@ -26276,7 +26309,7 @@ function createFixerRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26276
26309
|
pi.registerTool({
|
|
26277
26310
|
name: FIXER_OUTPUT_TOOL_NAME,
|
|
26278
26311
|
label: "\u4FEE\u5185\u53F8\u8F93\u51FA",
|
|
26279
|
-
description: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267\
|
|
26312
|
+
description: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267\u3002",
|
|
26280
26313
|
promptSnippet: "\u63D0\u4EA4\u4FEE\u5185\u53F8\u7EC8\u5C40\u56DE\u6267",
|
|
26281
26314
|
parameters: fixerOutputSchema,
|
|
26282
26315
|
async execute(toolCallId, parameters, _signal, _onUpdate, ctx) {
|
|
@@ -26403,7 +26436,7 @@ function createCoderRoleRuntime(pi, dependencies, hostActions) {
|
|
|
26403
26436
|
pi.registerTool({
|
|
26404
26437
|
name: CODER_OUTPUT_TOOL_NAME,
|
|
26405
26438
|
label: "\u5C06\u4F5C\u76D1\u8F93\u51FA",
|
|
26406
|
-
description: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267\
|
|
26439
|
+
description: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267\u3002",
|
|
26407
26440
|
promptSnippet: "\u63D0\u4EA4\u5C06\u4F5C\u76D1\u7EC8\u5C40\u56DE\u6267",
|
|
26408
26441
|
parameters: coderOutputSchema,
|
|
26409
26442
|
async execute(toolCallId, parameters, _signal, _onUpdate, ctx2) {
|
|
@@ -26730,25 +26763,6 @@ var ROLE_FLAG = {
|
|
|
26730
26763
|
type: "string"
|
|
26731
26764
|
}
|
|
26732
26765
|
};
|
|
26733
|
-
function formatNavigatorRoleHelp(role) {
|
|
26734
|
-
const metadata = packagedRoleMetadata(role);
|
|
26735
|
-
const lines = [
|
|
26736
|
-
`Usage: ak-role ${role}`,
|
|
26737
|
-
ROLE_FLAG.definition.description
|
|
26738
|
-
];
|
|
26739
|
-
const inputFlag = packagedRoleInputFlag(role);
|
|
26740
|
-
if (inputFlag !== void 0) {
|
|
26741
|
-
lines.push(` --${inputFlag} <value> ${role} input material`);
|
|
26742
|
-
}
|
|
26743
|
-
const phaseFlag = packagedRolePhaseFlag(role);
|
|
26744
|
-
if (phaseFlag !== void 0 && metadata !== void 0) {
|
|
26745
|
-
lines.push(
|
|
26746
|
-
` --${phaseFlag} <value> ${role} phase: ${metadata.phases.filter((p) => p !== null).join(" | ")}`
|
|
26747
|
-
);
|
|
26748
|
-
}
|
|
26749
|
-
lines.push(`Public next-command form: ak-role ${role}`);
|
|
26750
|
-
return lines.join("\n");
|
|
26751
|
-
}
|
|
26752
26766
|
function abortContext(ctx) {
|
|
26753
26767
|
ctx.abort();
|
|
26754
26768
|
}
|
|
@@ -26909,7 +26923,7 @@ function createGatekeeperRoleRuntime(roleHost, dependencies) {
|
|
|
26909
26923
|
);
|
|
26910
26924
|
}
|
|
26911
26925
|
function createNavigatorRoleRuntime(roleHost, dependencies) {
|
|
26912
|
-
|
|
26926
|
+
const base = createFiledOfficerRuntime(
|
|
26913
26927
|
roleHost,
|
|
26914
26928
|
{
|
|
26915
26929
|
role: "navigator",
|
|
@@ -26918,6 +26932,42 @@ function createNavigatorRoleRuntime(roleHost, dependencies) {
|
|
|
26918
26932
|
},
|
|
26919
26933
|
dependencies
|
|
26920
26934
|
);
|
|
26935
|
+
let playbookBound = false;
|
|
26936
|
+
return {
|
|
26937
|
+
async activate() {
|
|
26938
|
+
await base.activate();
|
|
26939
|
+
if (playbookBound) return;
|
|
26940
|
+
playbookBound = true;
|
|
26941
|
+
const loadRoutePlaybook = dependencies.loadRoutePlaybook ?? (() => readPackageMaterial("resources/navigator-route-playbook.md"));
|
|
26942
|
+
let playbookRead;
|
|
26943
|
+
roleHost.on("before_agent_start", async (event) => {
|
|
26944
|
+
const basePrompt = typeof event.systemPrompt === "string" ? event.systemPrompt : "";
|
|
26945
|
+
const parts = [];
|
|
26946
|
+
try {
|
|
26947
|
+
playbookRead ??= loadRoutePlaybook();
|
|
26948
|
+
const content = await playbookRead;
|
|
26949
|
+
dependencies.recordRoutePlaybookReadFailure?.(void 0);
|
|
26950
|
+
if (content.trim() !== "") parts.push(content);
|
|
26951
|
+
} catch (error) {
|
|
26952
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
26953
|
+
if (message.trim() !== "") {
|
|
26954
|
+
dependencies.recordRoutePlaybookReadFailure?.(message);
|
|
26955
|
+
parts.push(message);
|
|
26956
|
+
}
|
|
26957
|
+
}
|
|
26958
|
+
const prompt = typeof event.prompt === "string" ? event.prompt : "";
|
|
26959
|
+
const work = await loadNavigatorWorkBaseSuffix(prompt);
|
|
26960
|
+
if (work !== void 0 && work.trim() !== "") parts.push(work);
|
|
26961
|
+
if (parts.length === 0) return;
|
|
26962
|
+
const text = parts.join("\n\n");
|
|
26963
|
+
return {
|
|
26964
|
+
systemPrompt: basePrompt.trim() === "" ? text : `${basePrompt}
|
|
26965
|
+
|
|
26966
|
+
${text}`
|
|
26967
|
+
};
|
|
26968
|
+
});
|
|
26969
|
+
}
|
|
26970
|
+
};
|
|
26921
26971
|
}
|
|
26922
26972
|
function createAuditorRoleRuntime(roleHost, dependencies) {
|
|
26923
26973
|
const base = createFiledOfficerRuntime(
|
|
@@ -26961,7 +27011,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
26961
27011
|
function readRoleRunCoordinates(ctx, label) {
|
|
26962
27012
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
26963
27013
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
26964
|
-
const admittedPath =
|
|
27014
|
+
const admittedPath = join44(runDirectory, "admitted-request.json");
|
|
26965
27015
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
26966
27016
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
26967
27017
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -27301,13 +27351,11 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27301
27351
|
const raced = await raceNavigatorGrace(settlePromise, NAVIGATOR_POST_ROLE_GRACE_MS);
|
|
27302
27352
|
if (raced.status !== "timeout") return;
|
|
27303
27353
|
if (pendingNavigatorPresentation === void 0) {
|
|
27304
|
-
const routePlaybookReadFailure = attendance.knownRoutePlaybookReadFailure?.();
|
|
27305
27354
|
const report = {
|
|
27306
27355
|
disposition: "unavailable",
|
|
27307
27356
|
unavailableReason: "Navigator exceeded post-role delivery grace",
|
|
27308
27357
|
unavailableSource: "unknown",
|
|
27309
|
-
unavailableCause: "unknown"
|
|
27310
|
-
...routePlaybookReadFailure === void 0 ? {} : { routePlaybookReadFailure }
|
|
27358
|
+
unavailableCause: "unknown"
|
|
27311
27359
|
};
|
|
27312
27360
|
const event = {
|
|
27313
27361
|
version: 1,
|
|
@@ -27318,8 +27366,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27318
27366
|
subjectKey: workContext?.subjectKey ?? "",
|
|
27319
27367
|
unavailableReason: "Navigator exceeded post-role delivery grace",
|
|
27320
27368
|
unavailableSource: "unknown",
|
|
27321
|
-
unavailableCause: "unknown"
|
|
27322
|
-
...routePlaybookReadFailure === void 0 ? {} : { routePlaybookReadFailure }
|
|
27369
|
+
unavailableCause: "unknown"
|
|
27323
27370
|
};
|
|
27324
27371
|
pendingNavigatorPresentation = { event, report };
|
|
27325
27372
|
}
|
|
@@ -27530,7 +27577,7 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27530
27577
|
}
|
|
27531
27578
|
envelopeHost.sendMessage({
|
|
27532
27579
|
customType: "ak-receipt-delivery-prompt",
|
|
27533
|
-
content:
|
|
27580
|
+
content: JSON.stringify(receiptDelivery.deliveryState()),
|
|
27534
27581
|
display: false
|
|
27535
27582
|
}, { triggerTurn: true, deliverAs: "followUp" });
|
|
27536
27583
|
} else if (receiptDelivery.nextAction() === "no-receipt" && !noReceiptRecorded) {
|
|
@@ -27694,7 +27741,12 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
27694
27741
|
loadSoul: () => requireRoleSoul("gatekeeper")
|
|
27695
27742
|
});
|
|
27696
27743
|
const navigator = createNavigatorRoleRuntime(roleHost, {
|
|
27697
|
-
loadSoul: () => requireRoleSoul("navigator")
|
|
27744
|
+
loadSoul: () => requireRoleSoul("navigator"),
|
|
27745
|
+
recordRoutePlaybookReadFailure: (message) => {
|
|
27746
|
+
envelopeHost.appendEntry(NAVIGATOR_ROUTE_PLAYBOOK_FAILURE_ENTRY, {
|
|
27747
|
+
message: message ?? ""
|
|
27748
|
+
});
|
|
27749
|
+
}
|
|
27698
27750
|
});
|
|
27699
27751
|
const auditor = createAuditorRoleRuntime(roleHost, {
|
|
27700
27752
|
loadSoul: () => requireRoleSoul("auditor")
|
|
@@ -28001,7 +28053,6 @@ function createRoleRuntimeExtension(dependencies) {
|
|
|
28001
28053
|
pendingNavigatorPresentation = { event: navigatorEvent, report };
|
|
28002
28054
|
}
|
|
28003
28055
|
});
|
|
28004
|
-
navigatorAttendance.warmHelp?.();
|
|
28005
28056
|
if (navigatorWorkContext.contextError === void 0 && navigatorWorkContext.subjectProvenance !== "placeholder") {
|
|
28006
28057
|
navigatorAttendance.prepare();
|
|
28007
28058
|
}
|
|
@@ -28034,11 +28085,11 @@ init_submission_correctable_error();
|
|
|
28034
28085
|
init_navigator_invocation_identity();
|
|
28035
28086
|
init_serialize_thrown_value();
|
|
28036
28087
|
async function listen(server, path) {
|
|
28037
|
-
await new Promise((
|
|
28088
|
+
await new Promise((resolve22, reject) => {
|
|
28038
28089
|
server.once("error", reject);
|
|
28039
28090
|
server.listen(path, () => {
|
|
28040
28091
|
server.off("error", reject);
|
|
28041
|
-
|
|
28092
|
+
resolve22();
|
|
28042
28093
|
});
|
|
28043
28094
|
});
|
|
28044
28095
|
}
|
|
@@ -28073,8 +28124,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
28073
28124
|
const hostAbort = new AbortController();
|
|
28074
28125
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
28075
28126
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
28076
|
-
let sessionFile = options.sessionFile ??
|
|
28077
|
-
await mkdir5(
|
|
28127
|
+
let sessionFile = options.sessionFile ?? join45(request.runDirectory, "session", "session.jsonl");
|
|
28128
|
+
await mkdir5(dirname23(sessionFile), { recursive: true });
|
|
28078
28129
|
if (request.continuation.kind !== "resume") {
|
|
28079
28130
|
try {
|
|
28080
28131
|
await writeFile11(
|
|
@@ -28124,7 +28175,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
28124
28175
|
getLeafEntry: () => sessionEntries.at(-1),
|
|
28125
28176
|
getLeafId: () => runId,
|
|
28126
28177
|
getEntries: () => sessionEntries,
|
|
28127
|
-
getSessionDir: () =>
|
|
28178
|
+
getSessionDir: () => dirname23(sessionFile),
|
|
28128
28179
|
getSessionFile: () => sessionFile,
|
|
28129
28180
|
getHeader: () => ({ type: "session", id: runId }),
|
|
28130
28181
|
setSessionFile(path) {
|
|
@@ -28482,8 +28533,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
28482
28533
|
try {
|
|
28483
28534
|
const closeAll = server.closeAllConnections;
|
|
28484
28535
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
28485
|
-
await new Promise((
|
|
28486
|
-
server.close((error) => error ? reject(error) :
|
|
28536
|
+
await new Promise((resolve22, reject) => {
|
|
28537
|
+
server.close((error) => error ? reject(error) : resolve22());
|
|
28487
28538
|
});
|
|
28488
28539
|
} catch (error) {
|
|
28489
28540
|
cleanupFailures.push(error);
|
|
@@ -28613,15 +28664,15 @@ async function prepareRoleEnvelope(options) {
|
|
|
28613
28664
|
|
|
28614
28665
|
// src/role-runtime-dependencies.ts
|
|
28615
28666
|
init_collector_github();
|
|
28616
|
-
import { readFile as
|
|
28617
|
-
import { join as
|
|
28667
|
+
import { readFile as readFile25 } from "node:fs/promises";
|
|
28668
|
+
import { join as join46 } from "node:path";
|
|
28618
28669
|
init_doctor_evidence();
|
|
28619
28670
|
|
|
28620
28671
|
// src/navigator-work-context.ts
|
|
28621
28672
|
init_doctor_evidence();
|
|
28622
28673
|
init_host_contracts();
|
|
28623
|
-
import { readFile as
|
|
28624
|
-
import { resolve as
|
|
28674
|
+
import { readFile as readFile24 } from "node:fs/promises";
|
|
28675
|
+
import { resolve as resolve20 } from "node:path";
|
|
28625
28676
|
init_notary_source_run();
|
|
28626
28677
|
init_packaged_role_registry();
|
|
28627
28678
|
init_invocation();
|
|
@@ -28629,12 +28680,12 @@ function navigatorInputReference(getFlag, role) {
|
|
|
28629
28680
|
if (getFlag === void 0) return void 0;
|
|
28630
28681
|
const name = packagedRoleInputFlag(role);
|
|
28631
28682
|
const value = name === void 0 ? void 0 : getFlag(name);
|
|
28632
|
-
return typeof value === "string" && value !== "" ?
|
|
28683
|
+
return typeof value === "string" && value !== "" ? resolve20(value) : void 0;
|
|
28633
28684
|
}
|
|
28634
28685
|
async function loadNavigatorWorkContext(options) {
|
|
28635
28686
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
28636
28687
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
28637
|
-
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await
|
|
28688
|
+
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile24(reference, "utf8");
|
|
28638
28689
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
28639
28690
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
28640
28691
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -28651,7 +28702,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
28651
28702
|
}
|
|
28652
28703
|
const publicRunDir = runDirectoryFromHostContext(options.context);
|
|
28653
28704
|
const currentSessionDir = options.context.sessionManager.getSessionDir();
|
|
28654
|
-
const isBoundPublicRun = publicRunDir !== void 0 &&
|
|
28705
|
+
const isBoundPublicRun = publicRunDir !== void 0 && resolve20(currentSessionDir) === resolve20(publicRunDir, "session");
|
|
28655
28706
|
if (subjectMode === "public-instruction" && isBoundPublicRun) {
|
|
28656
28707
|
let admitted;
|
|
28657
28708
|
try {
|
|
@@ -28684,14 +28735,14 @@ async function loadNavigatorWorkContext(options) {
|
|
|
28684
28735
|
}
|
|
28685
28736
|
const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
|
|
28686
28737
|
const authorityFiles = workRoot === void 0 ? [] : [
|
|
28687
|
-
|
|
28688
|
-
|
|
28689
|
-
|
|
28738
|
+
resolve20(workRoot, "authority.md"),
|
|
28739
|
+
resolve20(workRoot, "authority.txt"),
|
|
28740
|
+
resolve20(workRoot, "design-v2/owner-direction.md")
|
|
28690
28741
|
];
|
|
28691
28742
|
let authorityMaterial;
|
|
28692
28743
|
for (const path of authorityFiles) {
|
|
28693
28744
|
try {
|
|
28694
|
-
const content = await
|
|
28745
|
+
const content = await readFile24(path, "utf8");
|
|
28695
28746
|
if (content.trim() !== "") {
|
|
28696
28747
|
authorityMaterial = content;
|
|
28697
28748
|
break;
|
|
@@ -28728,21 +28779,20 @@ function loadRegisteredRoleSoul(role) {
|
|
|
28728
28779
|
return usesSubjectSoul(role) ? loadAuditorSoulFromSubjectInput() : loadMainRoleSessionMaterials(role);
|
|
28729
28780
|
}
|
|
28730
28781
|
function createRoleRuntimeDependencies(packageRoot) {
|
|
28731
|
-
const
|
|
28732
|
-
const collectorHandbookSeedPath = join45(packageRoot, "resources/collector-bot-handbook.md");
|
|
28782
|
+
const collectorHandbookSeedPath = join46(packageRoot, "resources/collector-bot-handbook.md");
|
|
28733
28783
|
const doctorAuditor = createPiDoctorAuditor();
|
|
28734
28784
|
const navigatorSessionFactory = createNativeNavigatorSessionFactory();
|
|
28735
28785
|
return {
|
|
28736
28786
|
packageRoot,
|
|
28737
28787
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
28738
28788
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
28739
|
-
loadFixPacket: (path) =>
|
|
28740
|
-
loadCoderTask: (path) =>
|
|
28741
|
-
loadCollectorHandbookSeed: () =>
|
|
28789
|
+
loadFixPacket: (path) => readFile25(path, "utf8"),
|
|
28790
|
+
loadCoderTask: (path) => readFile25(path, "utf8"),
|
|
28791
|
+
loadCollectorHandbookSeed: () => readFile25(collectorHandbookSeedPath, "utf8"),
|
|
28742
28792
|
createCollectorTransport: () => createGhCollectorGitHubTransport(),
|
|
28743
28793
|
loadDoctorCase,
|
|
28744
28794
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
28745
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
28795
|
+
loadMergerInput: async (path) => JSON.parse(await readFile25(path, "utf8")),
|
|
28746
28796
|
// #590: doctor compliance still on disposeCompliance path; judge→auditor is gate queue (#756).
|
|
28747
28797
|
auditDoctorCompliance: (options) => doctorAuditor(options),
|
|
28748
28798
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
@@ -28758,9 +28808,6 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28758
28808
|
subject: options.subject,
|
|
28759
28809
|
authority: options.authority,
|
|
28760
28810
|
invocationId: options.invocationId,
|
|
28761
|
-
loadSoul: () => loadRegisteredRoleSoul("navigator"),
|
|
28762
|
-
loadRoutePlaybook: () => readFile24(navigatorRoutePlaybookPath, "utf8"),
|
|
28763
|
-
loadRoleHelp: async (role) => formatNavigatorRoleHelp(role),
|
|
28764
28811
|
createSession: navigatorSessionFactory,
|
|
28765
28812
|
...options.contextError === void 0 ? {} : { contextError: options.contextError },
|
|
28766
28813
|
onEvent: options.onEvent
|
|
@@ -28772,9 +28819,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
28772
28819
|
init_session_identity();
|
|
28773
28820
|
|
|
28774
28821
|
// src/acp-host/description.ts
|
|
28775
|
-
import { join as
|
|
28822
|
+
import { join as join47 } from "node:path";
|
|
28776
28823
|
function resolveAcpBinary(description, operatorHome) {
|
|
28777
|
-
return
|
|
28824
|
+
return join47(operatorHome, ...description.binaryFromHome);
|
|
28778
28825
|
}
|
|
28779
28826
|
function acpStdioArgs(description, model, seat) {
|
|
28780
28827
|
const { prefix, suffix, modelFlag, thinkingFlag } = description.argv;
|
|
@@ -28823,7 +28870,7 @@ function hostAbortedError(message = "host aborted") {
|
|
|
28823
28870
|
function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
28824
28871
|
if (abortSignal?.aborted) return Promise.reject(hostAbortedError(message));
|
|
28825
28872
|
if (abortSignal === void 0) return work;
|
|
28826
|
-
return new Promise((
|
|
28873
|
+
return new Promise((resolve22, reject) => {
|
|
28827
28874
|
let settled = false;
|
|
28828
28875
|
const onAbort = () => {
|
|
28829
28876
|
if (settled) return;
|
|
@@ -28838,7 +28885,7 @@ function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
|
28838
28885
|
if (settled) return;
|
|
28839
28886
|
settled = true;
|
|
28840
28887
|
abortSignal.removeEventListener("abort", onAbort);
|
|
28841
|
-
|
|
28888
|
+
resolve22(value);
|
|
28842
28889
|
},
|
|
28843
28890
|
(error) => {
|
|
28844
28891
|
if (settled) return;
|
|
@@ -29090,8 +29137,8 @@ function connectAcpStdio(options) {
|
|
|
29090
29137
|
request(method, params) {
|
|
29091
29138
|
if (closed) return Promise.reject(terminalError ?? acpError("acp-connection-closed", "ACP connection is closed"));
|
|
29092
29139
|
const id = ++nextId;
|
|
29093
|
-
return new Promise((
|
|
29094
|
-
pending.set(id, { resolve:
|
|
29140
|
+
return new Promise((resolve22, reject) => {
|
|
29141
|
+
pending.set(id, { resolve: resolve22, reject });
|
|
29095
29142
|
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
29096
29143
|
`, (error) => {
|
|
29097
29144
|
if (error === null || error === void 0) return;
|
|
@@ -29118,7 +29165,7 @@ function connectAcpStdio(options) {
|
|
|
29118
29165
|
settleClosed(acpError("acp-connection-closed", "ACP connection is closed"));
|
|
29119
29166
|
child.stdin.end();
|
|
29120
29167
|
child.kill("SIGTERM");
|
|
29121
|
-
await new Promise((
|
|
29168
|
+
await new Promise((resolve22) => child.once("close", () => resolve22()));
|
|
29122
29169
|
}
|
|
29123
29170
|
});
|
|
29124
29171
|
}
|
|
@@ -29340,12 +29387,12 @@ function createAcpRoleTurnHost(config) {
|
|
|
29340
29387
|
// src/acp-host/seat-profile-soul.ts
|
|
29341
29388
|
import { constants as constants3 } from "node:fs";
|
|
29342
29389
|
import { access as access4, copyFile, lstat as lstat8, mkdir as mkdir6, readlink, symlink as symlink2, unlink as unlink6 } from "node:fs/promises";
|
|
29343
|
-
import { dirname as
|
|
29390
|
+
import { dirname as dirname24, join as join48, relative as relative3, resolve as resolve21 } from "node:path";
|
|
29344
29391
|
function seatProfileName(spec, role) {
|
|
29345
29392
|
return `${spec.namePrefix}${role}`;
|
|
29346
29393
|
}
|
|
29347
29394
|
function packageRoleSoulPath(packageRoot, role) {
|
|
29348
|
-
return
|
|
29395
|
+
return join48(packageRoot, "souls", `${role}.md`);
|
|
29349
29396
|
}
|
|
29350
29397
|
async function pathExists2(path) {
|
|
29351
29398
|
try {
|
|
@@ -29358,20 +29405,20 @@ async function pathExists2(path) {
|
|
|
29358
29405
|
async function ensureSeatProfileSoul(options) {
|
|
29359
29406
|
const { spec, operatorHome, packageRoot, role } = options;
|
|
29360
29407
|
const profileName = seatProfileName(spec, role);
|
|
29361
|
-
const soulTarget =
|
|
29408
|
+
const soulTarget = resolve21(packageRoleSoulPath(packageRoot, role));
|
|
29362
29409
|
if (!await pathExists2(soulTarget)) {
|
|
29363
29410
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
29364
29411
|
}
|
|
29365
|
-
const profilesRoot =
|
|
29366
|
-
const profileDir =
|
|
29367
|
-
const hostRoot =
|
|
29368
|
-
const soulPath =
|
|
29412
|
+
const profilesRoot = join48(operatorHome, ...spec.profilesRootFromHome);
|
|
29413
|
+
const profileDir = join48(profilesRoot, profileName);
|
|
29414
|
+
const hostRoot = dirname24(profilesRoot);
|
|
29415
|
+
const soulPath = join48(profileDir, spec.soulFileName);
|
|
29369
29416
|
if (!await pathExists2(profileDir)) {
|
|
29370
29417
|
await mkdir6(profileDir, { recursive: true });
|
|
29371
29418
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
29372
|
-
const source =
|
|
29419
|
+
const source = join48(hostRoot, name);
|
|
29373
29420
|
if (!await pathExists2(source)) continue;
|
|
29374
|
-
await copyFile(source,
|
|
29421
|
+
await copyFile(source, join48(profileDir, name));
|
|
29375
29422
|
}
|
|
29376
29423
|
} else {
|
|
29377
29424
|
await mkdir6(profileDir, { recursive: true });
|