@akagilnc/pi-workflow-roles 0.1.5357 → 0.1.5368
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 +5353 -5480
- package/dist/doctor-contracts.js +22 -34
- package/dist/headless-host/production-host.js +1215 -1342
- package/dist/merger-contracts.js +11 -6
- package/dist/migrate-book-topology.js +57 -101
- package/dist/open-tool-schema.js +1 -25
- package/dist/package-contracts/fixer-output.js +21 -35
- package/dist/public-cli/auto-resume.js +1 -1
- package/dist/public-cli/cli.js +57 -56
- package/dist/public-cli/config.js +4 -0
- package/dist/public-cli/instruction-seat-run.js +65 -40
- package/dist/public-cli/invocation.js +132 -128
- package/dist/public-cli/main.js +449 -506
- package/dist/public-cli/post-admission.js +85 -86
- package/dist/public-cli/role-seat-runtime.js +29 -0
- package/dist/public-cli/run-lifecycle.js +6 -6
- package/dist/public-cli/turn-request.js +14 -0
- package/dist/public-role-summons.js +20 -33
- package/dist/role-run-placement.js +4 -0
- package/package.json +1 -1
- package/src/book-topology-migration-placement.ts +3 -5
- package/src/diarist-role.ts +12 -49
- package/src/doctor-contracts.ts +38 -49
- package/src/gleaner-left-role.ts +10 -11
- package/src/merger-contracts.ts +19 -12
- package/src/open-tool-schema.ts +8 -32
- package/src/package-contracts/fixer-output.ts +49 -52
- package/src/public-cli/auto-resume.ts +1 -1
- package/src/public-cli/cli.ts +67 -73
- package/src/public-cli/config.ts +8 -0
- package/src/public-cli/instruction-seat-run.ts +82 -55
- package/src/public-cli/invocation.ts +148 -162
- package/src/public-cli/post-admission.ts +110 -100
- package/src/public-cli/role-seat-runtime.ts +72 -0
- package/src/public-cli/run-lifecycle.ts +7 -26
- package/src/public-cli/terminal.ts +2 -17
- package/src/public-cli/turn-request.ts +26 -0
- package/src/public-role-summons.ts +20 -45
- package/src/reviewer-role.ts +16 -35
- package/src/role-run-placement.ts +5 -0
- package/src/secretariat-role.ts +16 -12
- package/src/worker-role.ts +14 -29
- package/src/worker-submission-gates.ts +14 -3
package/dist/merger-contracts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import { exactUtf8 } from "./exact-utf8.js";
|
|
3
|
-
import {
|
|
3
|
+
import { openToolObject } from "./open-tool-schema.js";
|
|
4
4
|
import { withTerminatingOutputDeclarations } from "./package-contracts/terminating-infrastructure.js";
|
|
5
5
|
const materialSchema = Type.Object({ bytesBase64: Type.String(), sha256: Type.String() }, { additionalProperties: false });
|
|
6
6
|
const checkSchema = Type.Object({ name: Type.String({ minLength: 1 }), argv: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }) }, { additionalProperties: false });
|
|
@@ -14,11 +14,16 @@ const mergerInputSchema = Type.Object({
|
|
|
14
14
|
authorizedChecks: Type.Array(checkSchema)
|
|
15
15
|
}, { additionalProperties: false });
|
|
16
16
|
const MERGER_STATUS_DESCRIPTION = "completed | escalate";
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const mergerOutputObject = Type.Object({
|
|
18
|
+
status: Type.Unknown({ description: MERGER_STATUS_DESCRIPTION }),
|
|
19
|
+
attemptId: Type.Unknown({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }),
|
|
20
|
+
report: Type.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
21
|
+
mergeCommitId: Type.Unknown({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }),
|
|
22
|
+
diagnosis: Type.Unknown({
|
|
23
|
+
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"
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
const mergerOutputSchema = withTerminatingOutputDeclarations(openToolObject(mergerOutputObject));
|
|
22
27
|
const MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
|
|
23
28
|
const record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
24
29
|
const blank = (v) => typeof v !== "string" || v.trim().length === 0;
|
|
@@ -214,6 +214,9 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
214
214
|
function roleRunArtifactsDirectory(runDirectory) {
|
|
215
215
|
return join3(runDirectory, "artifacts");
|
|
216
216
|
}
|
|
217
|
+
function isUnboundRunDirectory(runDirectory) {
|
|
218
|
+
return runDirectory.replaceAll("\\", "/").includes("/unbound/runs/");
|
|
219
|
+
}
|
|
217
220
|
var init_role_run_placement = __esm({
|
|
218
221
|
"src/role-run-placement.ts"() {
|
|
219
222
|
"use strict";
|
|
@@ -8010,29 +8013,6 @@ function described(name, schema) {
|
|
|
8010
8013
|
if (typeof schema.description === "string") return schema;
|
|
8011
8014
|
throw new Error(`Tool field ${name} has no semantic description at its schema owner`);
|
|
8012
8015
|
}
|
|
8013
|
-
function declarationIdentity(schema) {
|
|
8014
|
-
const { description: _description, ...semantic } = schema;
|
|
8015
|
-
return JSON.stringify(semantic);
|
|
8016
|
-
}
|
|
8017
|
-
function openToolObjectFromUnion(schema) {
|
|
8018
|
-
const declarations = /* @__PURE__ */ new Map();
|
|
8019
|
-
for (const variant of schema.anyOf) {
|
|
8020
|
-
for (const [name, declaration] of Object.entries(variant.properties ?? {})) {
|
|
8021
|
-
const entries = declarations.get(name) ?? [];
|
|
8022
|
-
const identity = declarationIdentity(declaration);
|
|
8023
|
-
if (!entries.some((entry) => declarationIdentity(entry) === identity)) entries.push(declaration);
|
|
8024
|
-
declarations.set(name, entries);
|
|
8025
|
-
}
|
|
8026
|
-
}
|
|
8027
|
-
const properties = Object.fromEntries([...declarations].map(([name, entries]) => {
|
|
8028
|
-
const descriptions = [...new Set(entries.map((entry) => entry.description).filter((value2) => typeof value2 === "string"))].join(" ");
|
|
8029
|
-
const declaration = entries.length === 1 ? entries[0] : typebox_exports.Union(entries, descriptions === "" ? {} : { description: descriptions });
|
|
8030
|
-
return [name, typebox_exports.Optional(described(name, declaration))];
|
|
8031
|
-
}));
|
|
8032
|
-
const object2 = typebox_exports.Object(properties, { additionalProperties: true });
|
|
8033
|
-
object2.required = [];
|
|
8034
|
-
return object2;
|
|
8035
|
-
}
|
|
8036
8016
|
function openToolObject(schema) {
|
|
8037
8017
|
const object2 = typebox_exports.Object(
|
|
8038
8018
|
Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [
|
|
@@ -8202,7 +8182,7 @@ var init_reviewer_output = __esm({
|
|
|
8202
8182
|
});
|
|
8203
8183
|
|
|
8204
8184
|
// src/package-contracts/fixer-output.ts
|
|
8205
|
-
var FIXER_OUTPUT_TOOL_NAME,
|
|
8185
|
+
var FIXER_OUTPUT_TOOL_NAME, PARTIALLY_COMPLETED_DEFINITION, FIXER_STATUS_DESCRIPTION, fixerOutputObject, fixerOutputSchema;
|
|
8206
8186
|
var init_fixer_output = __esm({
|
|
8207
8187
|
"src/package-contracts/fixer-output.ts"() {
|
|
8208
8188
|
"use strict";
|
|
@@ -8210,43 +8190,29 @@ var init_fixer_output = __esm({
|
|
|
8210
8190
|
init_open_tool_schema();
|
|
8211
8191
|
init_terminating_infrastructure();
|
|
8212
8192
|
FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
|
|
8213
|
-
transportString = typebox_exports.String();
|
|
8214
|
-
authorityBlockerSchema = typebox_exports.Object({ cause: typebox_exports.Optional(typebox_exports.Literal("authority_violation")), evidence: typebox_exports.Optional(transportString) });
|
|
8215
|
-
prerequisiteBlockerSchema = typebox_exports.Object({ cause: typebox_exports.Optional(typebox_exports.Literal("prerequisite_unmet")), prerequisiteId: typebox_exports.Optional(transportString), evidence: typebox_exports.Optional(transportString) });
|
|
8216
|
-
blockerSchema = typebox_exports.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
|
|
8217
|
-
exceptionSchema = typebox_exports.Object({ where: typebox_exports.Optional(transportString), reason: typebox_exports.Optional(transportString) });
|
|
8218
|
-
testEvidenceSchema = typebox_exports.Object({
|
|
8219
|
-
contract: typebox_exports.Optional(typebox_exports.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" })),
|
|
8220
|
-
minimumNecessaryCost: typebox_exports.Optional(typebox_exports.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" })),
|
|
8221
|
-
measuredDuration: typebox_exports.Optional(typebox_exports.String({ description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" }))
|
|
8222
|
-
}, { description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002" });
|
|
8223
|
-
completedClassResultSchema = typebox_exports.Object({
|
|
8224
|
-
name: typebox_exports.Optional(transportString),
|
|
8225
|
-
disposition: typebox_exports.Optional(typebox_exports.Literal("completed")),
|
|
8226
|
-
searchScope: typebox_exports.Optional(transportString),
|
|
8227
|
-
exceptions: typebox_exports.Optional(typebox_exports.Array(exceptionSchema)),
|
|
8228
|
-
commitSha: typebox_exports.Optional(transportString)
|
|
8229
|
-
});
|
|
8230
|
-
refusedClassResultSchema = typebox_exports.Object({
|
|
8231
|
-
name: typebox_exports.Optional(transportString),
|
|
8232
|
-
disposition: typebox_exports.Optional(typebox_exports.Literal("refused")),
|
|
8233
|
-
remainingScope: typebox_exports.Optional(transportString),
|
|
8234
|
-
blocker: typebox_exports.Optional(blockerSchema)
|
|
8235
|
-
});
|
|
8236
|
-
classResultSchema = typebox_exports.Union([completedClassResultSchema, refusedClassResultSchema]);
|
|
8237
|
-
completedClassResultsSchema = typebox_exports.Array(completedClassResultSchema);
|
|
8238
8193
|
PARTIALLY_COMPLETED_DEFINITION = "partially_completed \u53EA\u80FD\u5728\u6709\u5408\u6CD5\u62D2\u7EDD\u9879\uFF08\u5B8C\u6210\u9879\u4E0E\u5408\u6CD5\u62D2\u7EDD\u9879\u5E76\u5B58\uFF09\u65F6\u7528\uFF0C\u522B\u7684\u60C5\u51B5\u4E0D\u51C6\u7528\u3002";
|
|
8239
8194
|
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${PARTIALLY_COMPLETED_DEFINITION}`;
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8195
|
+
fixerOutputObject = typebox_exports.Object({
|
|
8196
|
+
status: typebox_exports.Unknown({ description: FIXER_STATUS_DESCRIPTION }),
|
|
8197
|
+
report: typebox_exports.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
8198
|
+
remainingScope: typebox_exports.Unknown({
|
|
8199
|
+
description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C\uFF1B\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u8303\u56F4\u4E5F\u5199\u6B64\u5904\u3002"
|
|
8200
|
+
}),
|
|
8201
|
+
blocker: typebox_exports.Unknown({
|
|
8202
|
+
description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker\uFF0C\u539F\u6837\u7559\u5B58\u3002\u53EF\u5199 cause\uFF08authority_violation \u6216 prerequisite_unmet\uFF09\u3001evidence\uFF1Bprerequisite_unmet \u8FD8\u53EF\u5199 prerequisiteId\u3002"
|
|
8203
|
+
}),
|
|
8204
|
+
reason: typebox_exports.Unknown({
|
|
8205
|
+
description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002"
|
|
8206
|
+
}),
|
|
8207
|
+
classResults: typebox_exports.Unknown({
|
|
8208
|
+
description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 name\u3001searchScope\u3001exceptions\uFF08where\u3001reason\uFF09\u3001commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 name\u3001remainingScope\u3001blocker\u3002"
|
|
8209
|
+
}),
|
|
8210
|
+
testEvidence: typebox_exports.Unknown({
|
|
8211
|
+
description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
|
|
8212
|
+
})
|
|
8213
|
+
});
|
|
8248
8214
|
fixerOutputSchema = withTerminatingOutputDeclarations(
|
|
8249
|
-
|
|
8215
|
+
openToolObject(fixerOutputObject)
|
|
8250
8216
|
);
|
|
8251
8217
|
}
|
|
8252
8218
|
});
|
|
@@ -13665,7 +13631,7 @@ var init_canonical_json = __esm({
|
|
|
13665
13631
|
});
|
|
13666
13632
|
|
|
13667
13633
|
// src/doctor-contracts.ts
|
|
13668
|
-
var DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_AUDIT_TOOL_NAME, DOCTOR_TARGET_KINDS,
|
|
13634
|
+
var DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_AUDIT_TOOL_NAME, DOCTOR_TARGET_KINDS, DOCTOR_DISPOSITIONS, DOCTOR_PRESCRIPTION_KINDS, biteActual, biteNone, DOCTOR_BITE_KINDS, DOCTOR_STATUS_DESCRIPTION, doctorSubmissionObject, doctorSubmissionSchema, doctorEvidenceReadSchema;
|
|
13669
13635
|
var init_doctor_contracts = __esm({
|
|
13670
13636
|
"src/doctor-contracts.ts"() {
|
|
13671
13637
|
"use strict";
|
|
@@ -13676,41 +13642,29 @@ var init_doctor_contracts = __esm({
|
|
|
13676
13642
|
DOCTOR_OUTPUT_TOOL_NAME = "ak_doctor_output";
|
|
13677
13643
|
DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
|
|
13678
13644
|
DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
typebox_exports.Object({ kind: typebox_exports.Optional(typebox_exports.Literal("noRealBite")), targetKey: nonblank, eligibleEvidenceIds: evidenceIds }, { additionalProperties: true })
|
|
13685
|
-
]);
|
|
13686
|
-
assetKinds = DOCTOR_TARGET_KINDS;
|
|
13687
|
-
findingBody = {
|
|
13688
|
-
evidenceIds,
|
|
13689
|
-
disposition: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("keep"), typebox_exports.Literal("thin"), typebox_exports.Literal("delete")])),
|
|
13690
|
-
guardrails: typebox_exports.Optional(typebox_exports.Object({ reproducibleFailure: guardrail, owningSeamOrInvariant: guardrail, deletionOrSimplificationSuffices: guardrail }, { additionalProperties: true })),
|
|
13691
|
-
prescription: typebox_exports.Optional(typebox_exports.Object({ kind: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("retain"), typebox_exports.Literal("delete"), typebox_exports.Literal("simplify"), typebox_exports.Literal("patch"), typebox_exports.Literal("addMechanism")])), recommendation: nonblank, necessityExplanation: nonblank }, { additionalProperties: true })),
|
|
13692
|
-
lastRealBite: typebox_exports.Optional(lastRealBite)
|
|
13693
|
-
};
|
|
13694
|
-
finding = typebox_exports.Union([
|
|
13695
|
-
typebox_exports.Object({ targetKey: nonblank, observation: nonblank, evidenceIds }, { additionalProperties: true }),
|
|
13696
|
-
typebox_exports.Object({ targetKey: nonblank, targetKind: typebox_exports.Optional(typebox_exports.Union(assetKinds.map((kind) => typebox_exports.Literal(kind)))), assetEvidence: typebox_exports.Optional(typebox_exports.Object({ targetKey: nonblank, targetKind: typebox_exports.Optional(typebox_exports.Union(assetKinds.map((kind) => typebox_exports.Literal(kind)))), evidenceId: nonblank }, { additionalProperties: true })), ...findingBody }, { additionalProperties: true })
|
|
13697
|
-
]);
|
|
13698
|
-
caseIdentity = typebox_exports.Object({ issueNumber: typebox_exports.Optional(typebox_exports.Integer()), runsPath: nonblank }, { additionalProperties: true });
|
|
13645
|
+
DOCTOR_DISPOSITIONS = ["keep", "thin", "delete"];
|
|
13646
|
+
DOCTOR_PRESCRIPTION_KINDS = ["retain", "delete", "simplify", "patch", "addMechanism"];
|
|
13647
|
+
biteActual = "actual";
|
|
13648
|
+
biteNone = "noRealBite";
|
|
13649
|
+
DOCTOR_BITE_KINDS = [biteActual, biteNone];
|
|
13699
13650
|
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";
|
|
13700
|
-
|
|
13701
|
-
typebox_exports.
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
},
|
|
13711
|
-
|
|
13651
|
+
doctorSubmissionObject = typebox_exports.Object({
|
|
13652
|
+
status: typebox_exports.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
|
|
13653
|
+
case: typebox_exports.Unknown({
|
|
13654
|
+
description: "\u7559\u5B58\u592A\u533B\u7F72\u6848\u8EAB\u4EFD\uFF0C\u539F\u6837\u7559\u5B58\uFF08\u5982 issueNumber\u3001runsPath\uFF09\u3002\u673A\u68B0\u5C42\u53E6\u6309\u7ED1\u5B9A run \u6295\u5F71\u6848\u8EAB\u4EFD\uFF0C\u4E0D\u5728\u672C\u5B57\u6BB5\u91CD\u5224\u3002"
|
|
13655
|
+
}),
|
|
13656
|
+
findings: typebox_exports.Unknown({
|
|
13657
|
+
description: `\u9010\u6761\u8D44\u4EA7\u89C2\u5BDF\u4E0E\u5904\u65B9\uFF0C\u539F\u6837\u7559\u5B58\u3002\u4E00\u6761\u53EF\u542B targetKey\u3001targetKind\uFF08${DOCTOR_TARGET_KINDS.join(" | ")}\uFF09\u3001observation\u3001evidenceIds\u3001disposition\uFF08${DOCTOR_DISPOSITIONS.join(" | ")}\uFF09\u3001assetEvidence\uFF08targetKey\u3001targetKind\u3001evidenceId\uFF09\u3001guardrails\uFF08reproducibleFailure\u3001owningSeamOrInvariant\u3001deletionOrSimplificationSuffices\uFF0C\u5404\u9879\u53EF\u542B answer\u3001evidenceIds\u3001explanation\uFF09\u3001prescription\uFF08kind \u4E3A ${DOCTOR_PRESCRIPTION_KINDS.join(" | ")}\uFF0C\u53E6\u53EF\u5199 recommendation\u3001necessityExplanation\uFF09\u3001lastRealBite\uFF08kind \u4E3A ${DOCTOR_BITE_KINDS.join(" | ")}\uFF0C\u53E6\u53EF\u5199 targetKey\u3001evidenceId\u3001eligibleEvidenceIds\uFF09\u3002\u4E0D\u8981\u6C42\u4EFB\u4F55\u5904\u65B9\u6216\u53EF\u590D\u7528 finding\uFF1B\u7F3A\u53EF\u590D\u7528\u8D44\u4EA7\u6216 bounded-bite \u8BC1\u636E\u53EA\u6392\u9664\u5BF9\u5E94\u8D44\u4EA7\u5904\u65B9\u3002\u673A\u5668\u4E0D\u6838\u9A8C\u3002`
|
|
13658
|
+
}),
|
|
13659
|
+
reason: typebox_exports.Unknown({
|
|
13660
|
+
description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0\uFF1B\u4EC5 refused \u65F6\u7528\u3002"
|
|
13661
|
+
}),
|
|
13662
|
+
missingEvidence: typebox_exports.Unknown({
|
|
13663
|
+
description: "\u5982\u5B9E\u8BC1\u8BCD\u6240\u9700\u800C\u5C1A\u7F3A\u7684\u8BC1\u636E\uFF0C\u539F\u6837\u7559\u5B58\uFF08\u5982\u6BCF\u9879 need\u3001targetKeys\uFF09\u3002"
|
|
13664
|
+
})
|
|
13665
|
+
});
|
|
13712
13666
|
doctorSubmissionSchema = withTerminatingOutputDeclarations(
|
|
13713
|
-
|
|
13667
|
+
openToolObject(doctorSubmissionObject)
|
|
13714
13668
|
);
|
|
13715
13669
|
doctorEvidenceReadSchema = typebox_exports.Object({ evidenceId: typebox_exports.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: typebox_exports.Optional(typebox_exports.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "\u8FD4\u56DE\u5B57\u8282\u6570\uFF08\u65E0\u4E0A\u9650\uFF09" })) }, { additionalProperties: true });
|
|
13716
13670
|
}
|
|
@@ -13726,7 +13680,7 @@ var init_exact_utf8 = __esm({
|
|
|
13726
13680
|
});
|
|
13727
13681
|
|
|
13728
13682
|
// src/merger-contracts.ts
|
|
13729
|
-
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION,
|
|
13683
|
+
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION, mergerOutputObject, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME;
|
|
13730
13684
|
var init_merger_contracts = __esm({
|
|
13731
13685
|
"src/merger-contracts.ts"() {
|
|
13732
13686
|
"use strict";
|
|
@@ -13746,11 +13700,16 @@ var init_merger_contracts = __esm({
|
|
|
13746
13700
|
authorizedChecks: typebox_exports.Array(checkSchema)
|
|
13747
13701
|
}, { additionalProperties: false });
|
|
13748
13702
|
MERGER_STATUS_DESCRIPTION = "completed | escalate";
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13703
|
+
mergerOutputObject = typebox_exports.Object({
|
|
13704
|
+
status: typebox_exports.Unknown({ description: MERGER_STATUS_DESCRIPTION }),
|
|
13705
|
+
attemptId: typebox_exports.Unknown({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }),
|
|
13706
|
+
report: typebox_exports.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
13707
|
+
mergeCommitId: typebox_exports.Unknown({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }),
|
|
13708
|
+
diagnosis: typebox_exports.Unknown({
|
|
13709
|
+
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"
|
|
13710
|
+
})
|
|
13711
|
+
});
|
|
13712
|
+
mergerOutputSchema = withTerminatingOutputDeclarations(openToolObject(mergerOutputObject));
|
|
13754
13713
|
MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
|
|
13755
13714
|
}
|
|
13756
13715
|
});
|
|
@@ -195184,9 +195143,6 @@ async function resolveMigratingRunTicket(runDirectory) {
|
|
|
195184
195143
|
}
|
|
195185
195144
|
};
|
|
195186
195145
|
}
|
|
195187
|
-
function isUnboundRunDirectory(runDirectory) {
|
|
195188
|
-
return runDirectory.replaceAll("\\", "/").includes("/unbound/runs/");
|
|
195189
|
-
}
|
|
195190
195146
|
function bookHistoricalRoots(booksDirectory, backupBooksDirectory, bookKey) {
|
|
195191
195147
|
return [join17(booksDirectory, bookKey), join17(backupBooksDirectory, bookKey)];
|
|
195192
195148
|
}
|
package/dist/open-tool-schema.js
CHANGED
|
@@ -3,29 +3,6 @@ function described(name, schema) {
|
|
|
3
3
|
if (typeof schema.description === "string") return schema;
|
|
4
4
|
throw new Error(`Tool field ${name} has no semantic description at its schema owner`);
|
|
5
5
|
}
|
|
6
|
-
function declarationIdentity(schema) {
|
|
7
|
-
const { description: _description, ...semantic } = schema;
|
|
8
|
-
return JSON.stringify(semantic);
|
|
9
|
-
}
|
|
10
|
-
function openToolObjectFromUnion(schema) {
|
|
11
|
-
const declarations = /* @__PURE__ */ new Map();
|
|
12
|
-
for (const variant of schema.anyOf) {
|
|
13
|
-
for (const [name, declaration] of Object.entries(variant.properties ?? {})) {
|
|
14
|
-
const entries = declarations.get(name) ?? [];
|
|
15
|
-
const identity = declarationIdentity(declaration);
|
|
16
|
-
if (!entries.some((entry) => declarationIdentity(entry) === identity)) entries.push(declaration);
|
|
17
|
-
declarations.set(name, entries);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const properties = Object.fromEntries([...declarations].map(([name, entries]) => {
|
|
21
|
-
const descriptions = [...new Set(entries.map((entry) => entry.description).filter((value) => typeof value === "string"))].join(" ");
|
|
22
|
-
const declaration = entries.length === 1 ? entries[0] : Type.Union(entries, descriptions === "" ? {} : { description: descriptions });
|
|
23
|
-
return [name, Type.Optional(described(name, declaration))];
|
|
24
|
-
}));
|
|
25
|
-
const object = Type.Object(properties, { additionalProperties: true });
|
|
26
|
-
object.required = [];
|
|
27
|
-
return object;
|
|
28
|
-
}
|
|
29
6
|
function openToolObject(schema) {
|
|
30
7
|
const object = Type.Object(
|
|
31
8
|
Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [
|
|
@@ -38,6 +15,5 @@ function openToolObject(schema) {
|
|
|
38
15
|
return object;
|
|
39
16
|
}
|
|
40
17
|
export {
|
|
41
|
-
openToolObject
|
|
42
|
-
openToolObjectFromUnion
|
|
18
|
+
openToolObject
|
|
43
19
|
};
|
|
@@ -1,44 +1,30 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
import {
|
|
2
|
+
import { openToolObject } from "../open-tool-schema.js";
|
|
3
3
|
import { withTerminatingOutputDeclarations } from "./terminating-infrastructure.js";
|
|
4
4
|
const FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
|
|
5
|
-
const transportString = Type.String();
|
|
6
|
-
const authorityBlockerSchema = Type.Object({ cause: Type.Optional(Type.Literal("authority_violation")), evidence: Type.Optional(transportString) });
|
|
7
|
-
const prerequisiteBlockerSchema = Type.Object({ cause: Type.Optional(Type.Literal("prerequisite_unmet")), prerequisiteId: Type.Optional(transportString), evidence: Type.Optional(transportString) });
|
|
8
|
-
const blockerSchema = Type.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
|
|
9
|
-
const exceptionSchema = Type.Object({ where: Type.Optional(transportString), reason: Type.Optional(transportString) });
|
|
10
|
-
const testEvidenceSchema = Type.Object({
|
|
11
|
-
contract: Type.Optional(Type.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" })),
|
|
12
|
-
minimumNecessaryCost: Type.Optional(Type.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" })),
|
|
13
|
-
measuredDuration: Type.Optional(Type.String({ description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" }))
|
|
14
|
-
}, { description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002" });
|
|
15
|
-
const completedClassResultSchema = Type.Object({
|
|
16
|
-
name: Type.Optional(transportString),
|
|
17
|
-
disposition: Type.Optional(Type.Literal("completed")),
|
|
18
|
-
searchScope: Type.Optional(transportString),
|
|
19
|
-
exceptions: Type.Optional(Type.Array(exceptionSchema)),
|
|
20
|
-
commitSha: Type.Optional(transportString)
|
|
21
|
-
});
|
|
22
|
-
const refusedClassResultSchema = Type.Object({
|
|
23
|
-
name: Type.Optional(transportString),
|
|
24
|
-
disposition: Type.Optional(Type.Literal("refused")),
|
|
25
|
-
remainingScope: Type.Optional(transportString),
|
|
26
|
-
blocker: Type.Optional(blockerSchema)
|
|
27
|
-
});
|
|
28
|
-
const classResultSchema = Type.Union([completedClassResultSchema, refusedClassResultSchema]);
|
|
29
|
-
const completedClassResultsSchema = Type.Array(completedClassResultSchema);
|
|
30
5
|
const PARTIALLY_COMPLETED_DEFINITION = "partially_completed \u53EA\u80FD\u5728\u6709\u5408\u6CD5\u62D2\u7EDD\u9879\uFF08\u5B8C\u6210\u9879\u4E0E\u5408\u6CD5\u62D2\u7EDD\u9879\u5E76\u5B58\uFF09\u65F6\u7528\uFF0C\u522B\u7684\u60C5\u51B5\u4E0D\u51C6\u7528\u3002";
|
|
31
6
|
const 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${PARTIALLY_COMPLETED_DEFINITION}`;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
7
|
+
const fixerOutputObject = Type.Object({
|
|
8
|
+
status: Type.Unknown({ description: FIXER_STATUS_DESCRIPTION }),
|
|
9
|
+
report: Type.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
10
|
+
remainingScope: Type.Unknown({
|
|
11
|
+
description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C\uFF1B\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u8303\u56F4\u4E5F\u5199\u6B64\u5904\u3002"
|
|
12
|
+
}),
|
|
13
|
+
blocker: Type.Unknown({
|
|
14
|
+
description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker\uFF0C\u539F\u6837\u7559\u5B58\u3002\u53EF\u5199 cause\uFF08authority_violation \u6216 prerequisite_unmet\uFF09\u3001evidence\uFF1Bprerequisite_unmet \u8FD8\u53EF\u5199 prerequisiteId\u3002"
|
|
15
|
+
}),
|
|
16
|
+
reason: Type.Unknown({
|
|
17
|
+
description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002"
|
|
18
|
+
}),
|
|
19
|
+
classResults: Type.Unknown({
|
|
20
|
+
description: "\u5404\u7C7B class \u7ED3\u7B97\uFF0C\u539F\u6837\u7559\u5B58\u3002\u5B8C\u6210\u9879\u7684 disposition \u4E3A completed\uFF0C\u53EF\u5199 name\u3001searchScope\u3001exceptions\uFF08where\u3001reason\uFF09\u3001commitSha\u3002\u62D2\u7EDD\u9879\u7684 disposition \u4E3A refused\uFF0C\u53EF\u5199 name\u3001remainingScope\u3001blocker\u3002"
|
|
21
|
+
}),
|
|
22
|
+
testEvidence: Type.Unknown({
|
|
23
|
+
description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002\u53EF\u5199 contract\uFF08\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6\uFF09\u3001minimumNecessaryCost\uFF08\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C\uFF09\u3001measuredDuration\uFF08\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F\uFF09\u3002"
|
|
24
|
+
})
|
|
25
|
+
});
|
|
40
26
|
const fixerOutputSchema = withTerminatingOutputDeclarations(
|
|
41
|
-
|
|
27
|
+
openToolObject(fixerOutputObject)
|
|
42
28
|
);
|
|
43
29
|
function validateFixerOutput(value, _phase) {
|
|
44
30
|
return value;
|
|
@@ -155,7 +155,7 @@ function jsonSafeReplacer() {
|
|
|
155
155
|
* + O_NOFOLLOW where the platform provides it (a planted symlink is never
|
|
156
156
|
* followed) — mirrors settlement.ts's own hardened artifact writers.
|
|
157
157
|
*/
|
|
158
|
-
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
158
|
+
export async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
159
159
|
const filePath = join(artifactsDir, `${namePrefix}-${randomUUID()}.json`);
|
|
160
160
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}\n`;
|
|
161
161
|
const noFollowFlag = typeof fsConstants.O_NOFOLLOW === "number" ? fsConstants.O_NOFOLLOW : 0;
|
package/dist/public-cli/cli.js
CHANGED
|
@@ -3,19 +3,19 @@ import { piDurablePrincipalAuthority } from "../pi/durable-principal.js";
|
|
|
3
3
|
* Public ak-role CLI dispatcher (roles / config / layered help / Judge run).
|
|
4
4
|
*/
|
|
5
5
|
import { realpath } from "node:fs/promises";
|
|
6
|
-
import { join } from "node:path";
|
|
7
6
|
import { packageMachineHome } from "../activation-ledger-topology.js";
|
|
8
7
|
import { assertLegalEngineModel, assertLegalEngineName, pickEngineAxis, } from "../package-resources/engine-material.js";
|
|
9
8
|
import { resolveConfiguredProvinceOfficer, } from "../institutional-resolution.js";
|
|
10
|
-
import { clearPersistentSeatConfig, effectiveSeatConfigurations, formatModelSpec, isGateOfficerSeat, loadCredentialProviders, loadPublicCliConfig, missingResolvedSeatModelMessage, parseModelSpec, resolveEffectiveSeat,
|
|
11
|
-
import { loadHostProvidersTable,
|
|
9
|
+
import { clearPersistentSeatConfig, effectiveSeatConfigurations, formatModelSpec, isGateOfficerSeat, loadCredentialProviders, loadPublicCliConfig, missingResolvedSeatModelMessage, parseModelSpec, resolveEffectiveSeat, savePublicCliConfig, setAutoResumeLimit, setPersistentSeatConfig, setPersistentSeatEngine, setPersistentSeatEngineModel, setPersistentSeatHost, resolvePublicAgentDir, validatePublicCliConfigAxes, } from "./config.js";
|
|
10
|
+
import { loadHostProvidersTable, renderHostProvidersTable, } from "./host-providers.js";
|
|
12
11
|
import { packagedModelParent } from "../packaged-role-registry.js";
|
|
13
12
|
import { seatModelOnly } from "./registry.js";
|
|
14
13
|
import { CliUsageError } from "./cli-errors.js";
|
|
15
14
|
import { runMachineSkillSetup } from "./machine-method-skills.js";
|
|
16
15
|
import { presentLocatedResumeFailure, } from "./post-admission.js";
|
|
17
16
|
import { appendPiSessionCustomEntry } from "../pi/role-turn-host.js";
|
|
18
|
-
import {
|
|
17
|
+
import { openRoleSeatRuntime } from "./role-seat-runtime.js";
|
|
18
|
+
import { formatHostSelectionFailure, HostSelectionError, } from "./role-turn-host-resolution.js";
|
|
19
19
|
import { parseAnalystArgv, parsePublicSeatArgv, } from "./invocation.js";
|
|
20
20
|
import { createTypedOptionConsumer, optionsForOwner, projectCommandHelp, projectOwnerOptions, PUBLIC_NAVIGATOR_HELP_NOTE, PUBLIC_ROLE_OPTION_OWNERS, renderHumanOwnerOptionLines, } from "./option-definitions.js";
|
|
21
21
|
import { TurnDispatchedFailure } from "./auto-resume.js";
|
|
@@ -89,43 +89,41 @@ function takePublicGlobalFlag(argv, index, options) {
|
|
|
89
89
|
function createRoleEnvironment(env, options,
|
|
90
90
|
/** #178: after host selection, before missing-model — structural argv parse once. */
|
|
91
91
|
afterHost) {
|
|
92
|
-
const role = options.role;
|
|
93
92
|
const extraPiArgs = env.extraPiArgs;
|
|
94
93
|
const timeoutMs = env.timeoutMs;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
role,
|
|
94
|
+
const opened = openRoleSeatRuntime({
|
|
95
|
+
resolution: {
|
|
96
|
+
packageRoot: env.packageRoot,
|
|
97
|
+
...(env.roleTurnHost === undefined ? {} : { roleTurnHost: env.roleTurnHost }),
|
|
98
|
+
...(env.hostAdapters === undefined ? {} : { hostAdapters: env.hostAdapters }),
|
|
99
|
+
...(extraPiArgs === undefined ? {} : { extraPiArgs }),
|
|
100
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
101
|
+
},
|
|
102
|
+
principalAuthority: env.principalAuthority,
|
|
103
|
+
role: options.role,
|
|
105
104
|
seat: options.seat,
|
|
105
|
+
home: options.home,
|
|
106
|
+
...(afterHost === undefined ? {} : { afterHost }),
|
|
106
107
|
});
|
|
107
|
-
|
|
108
|
-
afterHost?.();
|
|
109
|
-
const seatWithModel = resolvedSeatWithModel(options.seat);
|
|
110
|
-
if (seatWithModel === undefined) {
|
|
108
|
+
if (!opened.ok) {
|
|
111
109
|
// Direct CLI has --model; dual remediation is intentional here (#178 / #916).
|
|
112
110
|
throw new CliUsageError(missingResolvedSeatModelMessage(options.seat.seat, "invocation-or-config"));
|
|
113
111
|
}
|
|
114
|
-
const hostFacingSelection = projectHostFacingProvider(seatWithModel.selection, seatWithModel.host, loadHostProvidersTable(options.home), options.home);
|
|
115
112
|
return {
|
|
116
113
|
home: options.home,
|
|
117
114
|
principalAuthority: env.principalAuthority,
|
|
118
115
|
agentDir: options.agentDir,
|
|
119
116
|
sessionAppender: appendPiSessionCustomEntry,
|
|
120
117
|
packageRoot: env.packageRoot,
|
|
121
|
-
roleTurnHost,
|
|
122
|
-
hostAdapters,
|
|
118
|
+
roleTurnHost: opened.roleTurnHost,
|
|
119
|
+
hostAdapters: opened.hostAdapters,
|
|
123
120
|
cwd: options.cwd,
|
|
124
121
|
...(options.credentials === undefined ? {} : { credentials: options.credentials }),
|
|
125
122
|
...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
|
|
126
|
-
...(
|
|
127
|
-
...
|
|
128
|
-
...
|
|
123
|
+
...(opened.model === undefined ? {} : { model: opened.model }),
|
|
124
|
+
...(opened.engine === undefined ? {} : { engine: opened.engine }),
|
|
125
|
+
...(opened.engineModel === undefined ? {} : { engineModel: opened.engineModel }),
|
|
126
|
+
host: opened.host,
|
|
129
127
|
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
130
128
|
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
131
129
|
...(options.config?.autoResumeLimit === undefined
|
|
@@ -138,18 +136,31 @@ afterHost) {
|
|
|
138
136
|
...(env.signal === undefined ? {} : { signal: env.signal }),
|
|
139
137
|
};
|
|
140
138
|
}
|
|
139
|
+
/** Shared preamble for a new public role command and an explicit resume. */
|
|
140
|
+
async function loadPublicRoleDispatchParts(env, home) {
|
|
141
|
+
const agentDir = resolvePublicAgentDir(env.agentDir, home);
|
|
142
|
+
const cwd = env.cwd ?? process.cwd();
|
|
143
|
+
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
144
|
+
const credentials = env.credentials ?? (await loadCredentialProviders(agentDir));
|
|
145
|
+
return { agentDir, cwd, config, credentials };
|
|
146
|
+
}
|
|
141
147
|
/**
|
|
142
148
|
* #178 single spine: resolve seat → host select → argv parse once → missing-model → run.
|
|
143
149
|
* Keeps host-unregistered ahead of bad argv and missing-model.
|
|
144
150
|
*/
|
|
145
151
|
async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run) {
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
149
|
-
const credentials = env.credentials ?? (await loadCredentialProviders(agentDir));
|
|
150
|
-
const seat = resolveEffectiveSeat(config, role, credentials, invocationFromParsed(parsed));
|
|
152
|
+
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
153
|
+
const seat = resolveEffectiveSeat(parts.config, role, parts.credentials, invocationFromParsed(parsed));
|
|
151
154
|
let parsedRoleArgv;
|
|
152
|
-
const result = await run(parsed.args, createRoleEnvironment(env, {
|
|
155
|
+
const result = await run(parsed.args, createRoleEnvironment(env, {
|
|
156
|
+
role,
|
|
157
|
+
home,
|
|
158
|
+
agentDir: parts.agentDir,
|
|
159
|
+
cwd: parts.cwd,
|
|
160
|
+
credentials: parts.credentials,
|
|
161
|
+
seat,
|
|
162
|
+
config: parts.config,
|
|
163
|
+
}, () => {
|
|
153
164
|
parsedRoleArgv = parse(parsed.args);
|
|
154
165
|
}), () => parsedRoleArgv);
|
|
155
166
|
return {
|
|
@@ -176,11 +187,6 @@ function defaultIo() {
|
|
|
176
187
|
function resolveHome(env) {
|
|
177
188
|
return env.home ?? packageMachineHome();
|
|
178
189
|
}
|
|
179
|
-
function resolveAgentDir(env, home) {
|
|
180
|
-
return (env.agentDir ??
|
|
181
|
-
process.env.PI_CODING_AGENT_DIR ??
|
|
182
|
-
join(home, ".pi", "agent"));
|
|
183
|
-
}
|
|
184
190
|
function parseThinking(value) {
|
|
185
191
|
// #683: opaque pass-through — no local whitelist.
|
|
186
192
|
return value;
|
|
@@ -316,14 +322,6 @@ function requireCallableSeat(seat, axis, verb) {
|
|
|
316
322
|
throw new CliUsageError(`unknown ${axis}-axis seat: ${seat}`);
|
|
317
323
|
}
|
|
318
324
|
}
|
|
319
|
-
/** Single seat engine axis → run-options projection (#391 E2 / #883). */
|
|
320
|
-
function projectSeatEngine(seat) {
|
|
321
|
-
return pickEngineAxis(seat);
|
|
322
|
-
}
|
|
323
|
-
/** Single seat.host → run-options projection (#595 / #617). */
|
|
324
|
-
function projectSeatHost(seat) {
|
|
325
|
-
return { host: seat.host };
|
|
326
|
-
}
|
|
327
325
|
function loadAndValidateConfig(home, packageRoot) {
|
|
328
326
|
return loadPublicCliConfig(home).then((config) => {
|
|
329
327
|
try {
|
|
@@ -787,7 +785,7 @@ export async function runAkRole(argv, env) {
|
|
|
787
785
|
}
|
|
788
786
|
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
789
787
|
const credentials = env.credentials ??
|
|
790
|
-
(await loadCredentialProviders(
|
|
788
|
+
(await loadCredentialProviders(resolvePublicAgentDir(env.agentDir, home)));
|
|
791
789
|
const seats = effectiveSeatConfigurations(config, credentials, invocationFromParsed(parsed));
|
|
792
790
|
io.stdout(renderRoles(seats));
|
|
793
791
|
return { exitCode: 0 };
|
|
@@ -829,23 +827,20 @@ export async function runAkRole(argv, env) {
|
|
|
829
827
|
runId: resumeRequest.runId,
|
|
830
828
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority,
|
|
831
829
|
};
|
|
832
|
-
const
|
|
833
|
-
const cwd = env.cwd ?? process.cwd();
|
|
834
|
-
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
835
|
-
const credentials = env.credentials ?? (await loadCredentialProviders(agentDir));
|
|
830
|
+
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
836
831
|
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
|
|
837
832
|
// Missing durable role keeps the judge seat table. The resume entry
|
|
838
833
|
// itself is one function; it reads the stored run.
|
|
839
834
|
const seatRole = resumeRole ?? "judge";
|
|
840
|
-
const seat = resolveEffectiveSeat(config, seatRole, credentials, invocationFromParsed(parsed));
|
|
835
|
+
const seat = resolveEffectiveSeat(parts.config, seatRole, parts.credentials, invocationFromParsed(parsed));
|
|
841
836
|
const result = await runPublicInstructionSeatResume(resumeRequest, createRoleEnvironment(env, {
|
|
842
837
|
role: seatRole,
|
|
843
838
|
home,
|
|
844
|
-
agentDir,
|
|
845
|
-
cwd,
|
|
846
|
-
credentials,
|
|
839
|
+
agentDir: parts.agentDir,
|
|
840
|
+
cwd: parts.cwd,
|
|
841
|
+
credentials: parts.credentials,
|
|
847
842
|
seat,
|
|
848
|
-
config,
|
|
843
|
+
config: parts.config,
|
|
849
844
|
}), io);
|
|
850
845
|
let current = result;
|
|
851
846
|
while (current.exitCode === 0 && current.admitted?.correlationId !== undefined
|
|
@@ -860,9 +855,15 @@ export async function runAkRole(argv, env) {
|
|
|
860
855
|
const parentRole = await peekRoleRunRole(home, parentRunId);
|
|
861
856
|
if (parentRole === undefined)
|
|
862
857
|
break;
|
|
863
|
-
const parentSeat = resolveEffectiveSeat(config, parentRole, credentials, invocationFromParsed(parsed));
|
|
858
|
+
const parentSeat = resolveEffectiveSeat(parts.config, parentRole, parts.credentials, invocationFromParsed(parsed));
|
|
864
859
|
const parentEnv = createRoleEnvironment(env, {
|
|
865
|
-
role: parentRole,
|
|
860
|
+
role: parentRole,
|
|
861
|
+
home,
|
|
862
|
+
agentDir: parts.agentDir,
|
|
863
|
+
cwd: parts.cwd,
|
|
864
|
+
credentials: parts.credentials,
|
|
865
|
+
seat: parentSeat,
|
|
866
|
+
config: parts.config,
|
|
866
867
|
});
|
|
867
868
|
current = await continueParentAfterChild(parentRunId, current.admitted, parentEnv, io);
|
|
868
869
|
}
|
|
@@ -490,6 +490,9 @@ function credentialProvidersFromAuthData(data) {
|
|
|
490
490
|
xai: Object.prototype.hasOwnProperty.call(record, "xai")
|
|
491
491
|
};
|
|
492
492
|
}
|
|
493
|
+
function resolvePublicAgentDir(explicit, home) {
|
|
494
|
+
return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join(home, ".pi", "agent");
|
|
495
|
+
}
|
|
493
496
|
async function loadCredentialProviders(agentDir) {
|
|
494
497
|
try {
|
|
495
498
|
const raw = await readFile(join(agentDir, "auth.json"), "utf8");
|
|
@@ -519,6 +522,7 @@ export {
|
|
|
519
522
|
providerConfigured,
|
|
520
523
|
publicCliConfigPath,
|
|
521
524
|
resolveEffectiveSeat,
|
|
525
|
+
resolvePublicAgentDir,
|
|
522
526
|
resolvedSeatWithModel,
|
|
523
527
|
savePublicCliConfig,
|
|
524
528
|
setAutoResumeLimit,
|