@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/public-cli/main.js
CHANGED
|
@@ -513,6 +513,9 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
513
513
|
function roleRunArtifactsDirectory(runDirectory) {
|
|
514
514
|
return join4(runDirectory, "artifacts");
|
|
515
515
|
}
|
|
516
|
+
function isUnboundRunDirectory(runDirectory) {
|
|
517
|
+
return runDirectory.replaceAll("\\", "/").includes("/unbound/runs/");
|
|
518
|
+
}
|
|
516
519
|
function ensureRoleRunDirectory(ledgerHome, directory) {
|
|
517
520
|
return ensureRealDirectoryTree(ledgerHome, directory);
|
|
518
521
|
}
|
|
@@ -8431,29 +8434,6 @@ function described(name, schema) {
|
|
|
8431
8434
|
if (typeof schema.description === "string") return schema;
|
|
8432
8435
|
throw new Error(`Tool field ${name} has no semantic description at its schema owner`);
|
|
8433
8436
|
}
|
|
8434
|
-
function declarationIdentity(schema) {
|
|
8435
|
-
const { description: _description, ...semantic } = schema;
|
|
8436
|
-
return JSON.stringify(semantic);
|
|
8437
|
-
}
|
|
8438
|
-
function openToolObjectFromUnion(schema) {
|
|
8439
|
-
const declarations = /* @__PURE__ */ new Map();
|
|
8440
|
-
for (const variant of schema.anyOf) {
|
|
8441
|
-
for (const [name, declaration] of Object.entries(variant.properties ?? {})) {
|
|
8442
|
-
const entries = declarations.get(name) ?? [];
|
|
8443
|
-
const identity = declarationIdentity(declaration);
|
|
8444
|
-
if (!entries.some((entry) => declarationIdentity(entry) === identity)) entries.push(declaration);
|
|
8445
|
-
declarations.set(name, entries);
|
|
8446
|
-
}
|
|
8447
|
-
}
|
|
8448
|
-
const properties = Object.fromEntries([...declarations].map(([name, entries]) => {
|
|
8449
|
-
const descriptions = [...new Set(entries.map((entry) => entry.description).filter((value) => typeof value === "string"))].join(" ");
|
|
8450
|
-
const declaration = entries.length === 1 ? entries[0] : typebox_exports.Union(entries, descriptions === "" ? {} : { description: descriptions });
|
|
8451
|
-
return [name, typebox_exports.Optional(described(name, declaration))];
|
|
8452
|
-
}));
|
|
8453
|
-
const object = typebox_exports.Object(properties, { additionalProperties: true });
|
|
8454
|
-
object.required = [];
|
|
8455
|
-
return object;
|
|
8456
|
-
}
|
|
8457
8437
|
function openToolObject(schema) {
|
|
8458
8438
|
const object = typebox_exports.Object(
|
|
8459
8439
|
Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [
|
|
@@ -8623,7 +8603,7 @@ var init_reviewer_output = __esm({
|
|
|
8623
8603
|
});
|
|
8624
8604
|
|
|
8625
8605
|
// src/package-contracts/fixer-output.ts
|
|
8626
|
-
var FIXER_OUTPUT_TOOL_NAME,
|
|
8606
|
+
var FIXER_OUTPUT_TOOL_NAME, PARTIALLY_COMPLETED_DEFINITION, FIXER_STATUS_DESCRIPTION, fixerOutputObject, fixerOutputSchema;
|
|
8627
8607
|
var init_fixer_output = __esm({
|
|
8628
8608
|
"src/package-contracts/fixer-output.ts"() {
|
|
8629
8609
|
"use strict";
|
|
@@ -8631,43 +8611,29 @@ var init_fixer_output = __esm({
|
|
|
8631
8611
|
init_open_tool_schema();
|
|
8632
8612
|
init_terminating_infrastructure();
|
|
8633
8613
|
FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
|
|
8634
|
-
transportString = typebox_exports.String();
|
|
8635
|
-
authorityBlockerSchema = typebox_exports.Object({ cause: typebox_exports.Optional(typebox_exports.Literal("authority_violation")), evidence: typebox_exports.Optional(transportString) });
|
|
8636
|
-
prerequisiteBlockerSchema = typebox_exports.Object({ cause: typebox_exports.Optional(typebox_exports.Literal("prerequisite_unmet")), prerequisiteId: typebox_exports.Optional(transportString), evidence: typebox_exports.Optional(transportString) });
|
|
8637
|
-
blockerSchema = typebox_exports.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
|
|
8638
|
-
exceptionSchema = typebox_exports.Object({ where: typebox_exports.Optional(transportString), reason: typebox_exports.Optional(transportString) });
|
|
8639
|
-
testEvidenceSchema = typebox_exports.Object({
|
|
8640
|
-
contract: typebox_exports.Optional(typebox_exports.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" })),
|
|
8641
|
-
minimumNecessaryCost: typebox_exports.Optional(typebox_exports.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" })),
|
|
8642
|
-
measuredDuration: typebox_exports.Optional(typebox_exports.String({ description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" }))
|
|
8643
|
-
}, { description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002" });
|
|
8644
|
-
completedClassResultSchema = typebox_exports.Object({
|
|
8645
|
-
name: typebox_exports.Optional(transportString),
|
|
8646
|
-
disposition: typebox_exports.Optional(typebox_exports.Literal("completed")),
|
|
8647
|
-
searchScope: typebox_exports.Optional(transportString),
|
|
8648
|
-
exceptions: typebox_exports.Optional(typebox_exports.Array(exceptionSchema)),
|
|
8649
|
-
commitSha: typebox_exports.Optional(transportString)
|
|
8650
|
-
});
|
|
8651
|
-
refusedClassResultSchema = typebox_exports.Object({
|
|
8652
|
-
name: typebox_exports.Optional(transportString),
|
|
8653
|
-
disposition: typebox_exports.Optional(typebox_exports.Literal("refused")),
|
|
8654
|
-
remainingScope: typebox_exports.Optional(transportString),
|
|
8655
|
-
blocker: typebox_exports.Optional(blockerSchema)
|
|
8656
|
-
});
|
|
8657
|
-
classResultSchema = typebox_exports.Union([completedClassResultSchema, refusedClassResultSchema]);
|
|
8658
|
-
completedClassResultsSchema = typebox_exports.Array(completedClassResultSchema);
|
|
8659
8614
|
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";
|
|
8660
8615
|
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}`;
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8616
|
+
fixerOutputObject = typebox_exports.Object({
|
|
8617
|
+
status: typebox_exports.Unknown({ description: FIXER_STATUS_DESCRIPTION }),
|
|
8618
|
+
report: typebox_exports.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
8619
|
+
remainingScope: typebox_exports.Unknown({
|
|
8620
|
+
description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C\uFF1B\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u8303\u56F4\u4E5F\u5199\u6B64\u5904\u3002"
|
|
8621
|
+
}),
|
|
8622
|
+
blocker: typebox_exports.Unknown({
|
|
8623
|
+
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"
|
|
8624
|
+
}),
|
|
8625
|
+
reason: typebox_exports.Unknown({
|
|
8626
|
+
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"
|
|
8627
|
+
}),
|
|
8628
|
+
classResults: typebox_exports.Unknown({
|
|
8629
|
+
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"
|
|
8630
|
+
}),
|
|
8631
|
+
testEvidence: typebox_exports.Unknown({
|
|
8632
|
+
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"
|
|
8633
|
+
})
|
|
8634
|
+
});
|
|
8669
8635
|
fixerOutputSchema = withTerminatingOutputDeclarations(
|
|
8670
|
-
|
|
8636
|
+
openToolObject(fixerOutputObject)
|
|
8671
8637
|
);
|
|
8672
8638
|
}
|
|
8673
8639
|
});
|
|
@@ -14683,7 +14649,7 @@ var init_canonical_json = __esm({
|
|
|
14683
14649
|
});
|
|
14684
14650
|
|
|
14685
14651
|
// src/doctor-contracts.ts
|
|
14686
|
-
var DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_AUDIT_TOOL_NAME, DOCTOR_TARGET_KINDS,
|
|
14652
|
+
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;
|
|
14687
14653
|
var init_doctor_contracts = __esm({
|
|
14688
14654
|
"src/doctor-contracts.ts"() {
|
|
14689
14655
|
"use strict";
|
|
@@ -14694,41 +14660,29 @@ var init_doctor_contracts = __esm({
|
|
|
14694
14660
|
DOCTOR_OUTPUT_TOOL_NAME = "ak_doctor_output";
|
|
14695
14661
|
DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
|
|
14696
14662
|
DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
|
|
14697
|
-
|
|
14698
|
-
|
|
14699
|
-
|
|
14700
|
-
|
|
14701
|
-
|
|
14702
|
-
typebox_exports.Object({ kind: typebox_exports.Optional(typebox_exports.Literal("noRealBite")), targetKey: nonblank, eligibleEvidenceIds: evidenceIds }, { additionalProperties: true })
|
|
14703
|
-
]);
|
|
14704
|
-
assetKinds = DOCTOR_TARGET_KINDS;
|
|
14705
|
-
findingBody = {
|
|
14706
|
-
evidenceIds,
|
|
14707
|
-
disposition: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("keep"), typebox_exports.Literal("thin"), typebox_exports.Literal("delete")])),
|
|
14708
|
-
guardrails: typebox_exports.Optional(typebox_exports.Object({ reproducibleFailure: guardrail, owningSeamOrInvariant: guardrail, deletionOrSimplificationSuffices: guardrail }, { additionalProperties: true })),
|
|
14709
|
-
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 })),
|
|
14710
|
-
lastRealBite: typebox_exports.Optional(lastRealBite)
|
|
14711
|
-
};
|
|
14712
|
-
finding = typebox_exports.Union([
|
|
14713
|
-
typebox_exports.Object({ targetKey: nonblank, observation: nonblank, evidenceIds }, { additionalProperties: true }),
|
|
14714
|
-
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 })
|
|
14715
|
-
]);
|
|
14716
|
-
caseIdentity = typebox_exports.Object({ issueNumber: typebox_exports.Optional(typebox_exports.Integer()), runsPath: nonblank }, { additionalProperties: true });
|
|
14663
|
+
DOCTOR_DISPOSITIONS = ["keep", "thin", "delete"];
|
|
14664
|
+
DOCTOR_PRESCRIPTION_KINDS = ["retain", "delete", "simplify", "patch", "addMechanism"];
|
|
14665
|
+
biteActual = "actual";
|
|
14666
|
+
biteNone = "noRealBite";
|
|
14667
|
+
DOCTOR_BITE_KINDS = [biteActual, biteNone];
|
|
14717
14668
|
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";
|
|
14718
|
-
|
|
14719
|
-
typebox_exports.
|
|
14720
|
-
|
|
14721
|
-
|
|
14722
|
-
|
|
14723
|
-
|
|
14724
|
-
|
|
14725
|
-
|
|
14726
|
-
|
|
14727
|
-
|
|
14728
|
-
},
|
|
14729
|
-
|
|
14669
|
+
doctorSubmissionObject = typebox_exports.Object({
|
|
14670
|
+
status: typebox_exports.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
|
|
14671
|
+
case: typebox_exports.Unknown({
|
|
14672
|
+
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"
|
|
14673
|
+
}),
|
|
14674
|
+
findings: typebox_exports.Unknown({
|
|
14675
|
+
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`
|
|
14676
|
+
}),
|
|
14677
|
+
reason: typebox_exports.Unknown({
|
|
14678
|
+
description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0\uFF1B\u4EC5 refused \u65F6\u7528\u3002"
|
|
14679
|
+
}),
|
|
14680
|
+
missingEvidence: typebox_exports.Unknown({
|
|
14681
|
+
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"
|
|
14682
|
+
})
|
|
14683
|
+
});
|
|
14730
14684
|
doctorSubmissionSchema = withTerminatingOutputDeclarations(
|
|
14731
|
-
|
|
14685
|
+
openToolObject(doctorSubmissionObject)
|
|
14732
14686
|
);
|
|
14733
14687
|
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 });
|
|
14734
14688
|
}
|
|
@@ -14775,7 +14729,7 @@ function validateMergerInput(value) {
|
|
|
14775
14729
|
const authorizedChecks = Array.isArray(value.authorizedChecks) ? value.authorizedChecks.filter((check) => record(check)).map((c) => ({ name: asString(c.name), argv: asStringArray(c.argv).filter((a) => a.trim().length > 0) })).filter((c) => c.name.trim().length > 0 && c.argv.length > 0) : [];
|
|
14776
14730
|
return deepFreeze(structuredClone({ attemptId: value.attemptId.trim(), targetObjectId: asString(value.targetObjectId), sourceObjectId: asString(value.sourceObjectId), materials, expectedConflictPaths: asStringArray(value.expectedConflictPaths), resolutionScope: asStringArray(value.resolutionScope), authorizedChecks }));
|
|
14777
14731
|
}
|
|
14778
|
-
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION,
|
|
14732
|
+
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION, mergerOutputObject, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME, record, blank, MergerInputContractError, asString, asStringArray;
|
|
14779
14733
|
var init_merger_contracts = __esm({
|
|
14780
14734
|
"src/merger-contracts.ts"() {
|
|
14781
14735
|
"use strict";
|
|
@@ -14795,11 +14749,16 @@ var init_merger_contracts = __esm({
|
|
|
14795
14749
|
authorizedChecks: typebox_exports.Array(checkSchema)
|
|
14796
14750
|
}, { additionalProperties: false });
|
|
14797
14751
|
MERGER_STATUS_DESCRIPTION = "completed | escalate";
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14752
|
+
mergerOutputObject = typebox_exports.Object({
|
|
14753
|
+
status: typebox_exports.Unknown({ description: MERGER_STATUS_DESCRIPTION }),
|
|
14754
|
+
attemptId: typebox_exports.Unknown({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }),
|
|
14755
|
+
report: typebox_exports.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
14756
|
+
mergeCommitId: typebox_exports.Unknown({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }),
|
|
14757
|
+
diagnosis: typebox_exports.Unknown({
|
|
14758
|
+
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"
|
|
14759
|
+
})
|
|
14760
|
+
});
|
|
14761
|
+
mergerOutputSchema = withTerminatingOutputDeclarations(openToolObject(mergerOutputObject));
|
|
14803
14762
|
MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
|
|
14804
14763
|
record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
14805
14764
|
blank = (v) => typeof v !== "string" || v.trim().length === 0;
|
|
@@ -15833,6 +15792,7 @@ __export(config_exports, {
|
|
|
15833
15792
|
providerConfigured: () => providerConfigured,
|
|
15834
15793
|
publicCliConfigPath: () => publicCliConfigPath,
|
|
15835
15794
|
resolveEffectiveSeat: () => resolveEffectiveSeat,
|
|
15795
|
+
resolvePublicAgentDir: () => resolvePublicAgentDir,
|
|
15836
15796
|
resolvedSeatWithModel: () => resolvedSeatWithModel,
|
|
15837
15797
|
savePublicCliConfig: () => savePublicCliConfig,
|
|
15838
15798
|
setAutoResumeLimit: () => setAutoResumeLimit,
|
|
@@ -16312,6 +16272,9 @@ function credentialProvidersFromAuthData(data) {
|
|
|
16312
16272
|
xai: Object.prototype.hasOwnProperty.call(record4, "xai")
|
|
16313
16273
|
};
|
|
16314
16274
|
}
|
|
16275
|
+
function resolvePublicAgentDir(explicit, home) {
|
|
16276
|
+
return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join8(home, ".pi", "agent");
|
|
16277
|
+
}
|
|
16315
16278
|
async function loadCredentialProviders(agentDir) {
|
|
16316
16279
|
try {
|
|
16317
16280
|
const raw = await readFile2(join8(agentDir, "auth.json"), "utf8");
|
|
@@ -16339,18 +16302,6 @@ var init_config2 = __esm({
|
|
|
16339
16302
|
});
|
|
16340
16303
|
|
|
16341
16304
|
// src/public-cli/host-providers.ts
|
|
16342
|
-
var host_providers_exports = {};
|
|
16343
|
-
__export(host_providers_exports, {
|
|
16344
|
-
HostProviderResolutionError: () => HostProviderResolutionError,
|
|
16345
|
-
hermesProviderModelsCachePath: () => hermesProviderModelsCachePath,
|
|
16346
|
-
hostCatalogOffersModel: () => hostCatalogOffersModel,
|
|
16347
|
-
hostProvidersPath: () => hostProvidersPath,
|
|
16348
|
-
listHermesProvidersForModel: () => listHermesProvidersForModel,
|
|
16349
|
-
loadHostProvidersTable: () => loadHostProvidersTable,
|
|
16350
|
-
parseHostProvidersTable: () => parseHostProvidersTable,
|
|
16351
|
-
projectHostFacingProvider: () => projectHostFacingProvider,
|
|
16352
|
-
renderHostProvidersTable: () => renderHostProvidersTable
|
|
16353
|
-
});
|
|
16354
16305
|
import { readFileSync } from "node:fs";
|
|
16355
16306
|
import { join as join9 } from "node:path";
|
|
16356
16307
|
function hostProvidersPath(home) {
|
|
@@ -19955,74 +19906,64 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
19955
19906
|
);
|
|
19956
19907
|
}
|
|
19957
19908
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
19958
|
-
|
|
19959
|
-
|
|
19960
|
-
|
|
19961
|
-
|
|
19962
|
-
|
|
19963
|
-
|
|
19964
|
-
|
|
19965
|
-
|
|
19966
|
-
|
|
19967
|
-
|
|
19909
|
+
await updateDurableJsonPage(join19(runDirectory, "invocation.json"), (current) => {
|
|
19910
|
+
const next = { ...current };
|
|
19911
|
+
if (model !== void 0) {
|
|
19912
|
+
next.provider = model.provider;
|
|
19913
|
+
next.model = model.model;
|
|
19914
|
+
if (model.thinking === void 0) {
|
|
19915
|
+
delete next.thinking;
|
|
19916
|
+
} else {
|
|
19917
|
+
next.thinking = model.thinking;
|
|
19918
|
+
}
|
|
19968
19919
|
}
|
|
19969
|
-
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
|
|
19973
|
-
|
|
19974
|
-
|
|
19975
|
-
|
|
19976
|
-
|
|
19977
|
-
|
|
19978
|
-
|
|
19979
|
-
|
|
19980
|
-
|
|
19981
|
-
|
|
19982
|
-
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
);
|
|
19920
|
+
if (engine === null) {
|
|
19921
|
+
delete next.engine;
|
|
19922
|
+
} else if (engine !== void 0) {
|
|
19923
|
+
next.engine = engine;
|
|
19924
|
+
}
|
|
19925
|
+
if (engineModel === null) {
|
|
19926
|
+
delete next.engineModel;
|
|
19927
|
+
} else if (engineModel !== void 0) {
|
|
19928
|
+
next.engineModel = engineModel;
|
|
19929
|
+
}
|
|
19930
|
+
if (host !== void 0) {
|
|
19931
|
+
next.host = host;
|
|
19932
|
+
}
|
|
19933
|
+
return next;
|
|
19934
|
+
});
|
|
19935
|
+
}
|
|
19936
|
+
async function updateDurableJsonPage(path, update) {
|
|
19937
|
+
const current = JSON.parse(await readFile12(path, "utf8"));
|
|
19938
|
+
const next = update(current);
|
|
19939
|
+
if (next === void 0) return;
|
|
19940
|
+
await writeFile3(path, `${JSON.stringify(next, null, 2)}
|
|
19941
|
+
`, "utf8");
|
|
19989
19942
|
}
|
|
19990
19943
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
19991
|
-
|
|
19992
|
-
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
`${JSON.stringify({
|
|
19996
|
-
...current,
|
|
19997
|
-
...fields
|
|
19998
|
-
}, null, 2)}
|
|
19999
|
-
`,
|
|
20000
|
-
"utf8"
|
|
20001
|
-
);
|
|
19944
|
+
await updateDurableJsonPage(join19(runDirectory, "invocation.json"), (current) => ({
|
|
19945
|
+
...current,
|
|
19946
|
+
...fields
|
|
19947
|
+
}));
|
|
20002
19948
|
}
|
|
20003
19949
|
async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
|
|
20004
19950
|
if (sourceRunPath.trim() === "") {
|
|
20005
19951
|
throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
|
|
20006
19952
|
}
|
|
20007
|
-
|
|
20008
|
-
|
|
20009
|
-
|
|
20010
|
-
|
|
20011
|
-
|
|
20012
|
-
|
|
20013
|
-
|
|
20014
|
-
|
|
20015
|
-
|
|
20016
|
-
await writeFile3(
|
|
20017
|
-
admittedPath,
|
|
20018
|
-
`${JSON.stringify({
|
|
19953
|
+
await updateDurableJsonPage(admitted.admittedRequestPath, (current) => {
|
|
19954
|
+
if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
19955
|
+
throw new Error(
|
|
19956
|
+
`persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
19957
|
+
);
|
|
19958
|
+
}
|
|
19959
|
+
const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
|
|
19960
|
+
if (current.sourceRunPath === sourceRunPath && sameSubject) return void 0;
|
|
19961
|
+
return {
|
|
20019
19962
|
...current,
|
|
20020
19963
|
sourceRunPath,
|
|
20021
19964
|
...auditorSubject === void 0 ? {} : { auditorSubject }
|
|
20022
|
-
}
|
|
20023
|
-
|
|
20024
|
-
"utf8"
|
|
20025
|
-
);
|
|
19965
|
+
};
|
|
19966
|
+
});
|
|
20026
19967
|
}
|
|
20027
19968
|
async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
20028
19969
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
@@ -20030,22 +19971,17 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
20030
19971
|
admitted.ticketNumber = ticketNumber;
|
|
20031
19972
|
}
|
|
20032
19973
|
async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
20033
|
-
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20044
|
-
admitted.admittedRequestPath,
|
|
20045
|
-
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
20046
|
-
`,
|
|
20047
|
-
"utf8"
|
|
20048
|
-
);
|
|
19974
|
+
let correlationIds = [];
|
|
19975
|
+
await updateDurableJsonPage(admitted.admittedRequestPath, (current) => {
|
|
19976
|
+
const prior = [
|
|
19977
|
+
...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
|
|
19978
|
+
(value) => typeof value === "string" && value.trim() !== ""
|
|
19979
|
+
) : [],
|
|
19980
|
+
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
19981
|
+
];
|
|
19982
|
+
correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
19983
|
+
return { ...current, correlationId, correlationIds };
|
|
19984
|
+
});
|
|
20049
19985
|
await mergeInvocationIdentityPage(admitted.runDirectory, {
|
|
20050
19986
|
correlationId,
|
|
20051
19987
|
correlationIds
|
|
@@ -20055,7 +19991,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
20055
19991
|
mutable.correlationIds = correlationIds;
|
|
20056
19992
|
}
|
|
20057
19993
|
async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
20058
|
-
if (admitted.ticketNumber === void 0 || !admitted.runDirectory
|
|
19994
|
+
if (admitted.ticketNumber === void 0 || !isUnboundRunDirectory(admitted.runDirectory)) return void 0;
|
|
20059
19995
|
const oldRunDirectory = admitted.runDirectory;
|
|
20060
19996
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
|
|
20061
19997
|
const target = roleRunPlacement(ledgerHome, {
|
|
@@ -20117,11 +20053,11 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
20117
20053
|
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
20118
20054
|
}
|
|
20119
20055
|
async function recordChildDiaristRun(parent, childRunId) {
|
|
20120
|
-
|
|
20121
|
-
|
|
20122
|
-
|
|
20123
|
-
|
|
20124
|
-
|
|
20056
|
+
await updateDurableJsonPage(parent.admittedRequestPath, (page) => {
|
|
20057
|
+
const existing = Array.isArray(page.childDiaristRunIds) ? page.childDiaristRunIds.filter((runId) => typeof runId === "string") : [];
|
|
20058
|
+
const childDiaristRunIds = existing.includes(childRunId) ? existing : [...existing, childRunId];
|
|
20059
|
+
return { ...page, childDiaristRunIds };
|
|
20060
|
+
});
|
|
20125
20061
|
}
|
|
20126
20062
|
async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
20127
20063
|
requireSafePositiveTicketNumber(
|
|
@@ -20129,14 +20065,15 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
20129
20065
|
"bindTicketNumberOnRunDirectory"
|
|
20130
20066
|
);
|
|
20131
20067
|
const admittedPath = join19(runDirectory, "admitted-request.json");
|
|
20132
|
-
|
|
20133
|
-
|
|
20134
|
-
|
|
20135
|
-
|
|
20136
|
-
|
|
20137
|
-
|
|
20138
|
-
|
|
20139
|
-
);
|
|
20068
|
+
let unchanged = false;
|
|
20069
|
+
await updateDurableJsonPage(admittedPath, (admitted) => {
|
|
20070
|
+
if (admitted.ticketNumber === ticketNumber) {
|
|
20071
|
+
unchanged = true;
|
|
20072
|
+
return void 0;
|
|
20073
|
+
}
|
|
20074
|
+
return { ...admitted, ticketNumber };
|
|
20075
|
+
});
|
|
20076
|
+
if (unchanged) return;
|
|
20140
20077
|
await mergeInvocationIdentityPage(runDirectory, { ticketNumber });
|
|
20141
20078
|
}
|
|
20142
20079
|
async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
@@ -20358,18 +20295,22 @@ function requireOptionPath(flag, value) {
|
|
|
20358
20295
|
}
|
|
20359
20296
|
return value;
|
|
20360
20297
|
}
|
|
20298
|
+
function skillArgTokenFault(value) {
|
|
20299
|
+
if (value === void 0 || value.trim() === "") return "empty";
|
|
20300
|
+
if (/\s/.test(value)) return "whitespace";
|
|
20301
|
+
if (value.startsWith("-")) return "optionLike";
|
|
20302
|
+
return void 0;
|
|
20303
|
+
}
|
|
20361
20304
|
function requireSkillArgToken(value, messages) {
|
|
20362
|
-
|
|
20363
|
-
|
|
20364
|
-
}
|
|
20365
|
-
if (/\s/.test(value)) {
|
|
20366
|
-
throw new CliUsageError(messages.whitespace);
|
|
20367
|
-
}
|
|
20368
|
-
if (value.startsWith("-")) {
|
|
20369
|
-
throw new CliUsageError(messages.optionLike);
|
|
20370
|
-
}
|
|
20305
|
+
const fault = skillArgTokenFault(value);
|
|
20306
|
+
if (fault !== void 0) throw new CliUsageError(messages[fault]);
|
|
20371
20307
|
return value;
|
|
20372
20308
|
}
|
|
20309
|
+
function admittedReviewerBaseFault(value) {
|
|
20310
|
+
const fault = skillArgTokenFault(value);
|
|
20311
|
+
if (fault === void 0) return void 0;
|
|
20312
|
+
return fault === "empty" ? "missing" : "damaged";
|
|
20313
|
+
}
|
|
20373
20314
|
function requireReviewerBaseRevision(value) {
|
|
20374
20315
|
return requireSkillArgToken(value, {
|
|
20375
20316
|
empty: "--base requires a nonempty revision",
|
|
@@ -20597,9 +20538,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20597
20538
|
});
|
|
20598
20539
|
}
|
|
20599
20540
|
case "worker-packet": {
|
|
20600
|
-
if (parsed.project !== void 0) {
|
|
20601
|
-
requireOptionPath("--project", parsed.project);
|
|
20602
|
-
}
|
|
20603
20541
|
if (instruction.trim() === "") {
|
|
20604
20542
|
throw new CliUsageError("fixer requires a nonblank repair instruction");
|
|
20605
20543
|
}
|
|
@@ -20656,18 +20594,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20656
20594
|
});
|
|
20657
20595
|
}
|
|
20658
20596
|
case "collect-target": {
|
|
20659
|
-
|
|
20660
|
-
requireOptionPath("--project", parsed.project);
|
|
20661
|
-
}
|
|
20662
|
-
let explicitPrNumber;
|
|
20663
|
-
if (parsed.prNumber !== void 0) {
|
|
20664
|
-
try {
|
|
20665
|
-
explicitPrNumber = parseCollectorPrNumber(parsed.prNumber);
|
|
20666
|
-
} catch (error) {
|
|
20667
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
20668
|
-
throw new CliUsageError(detail, { cause: error });
|
|
20669
|
-
}
|
|
20670
|
-
}
|
|
20597
|
+
const explicitPrNumber = parsed.prNumber;
|
|
20671
20598
|
const projectRoot = resolve9(parsed.project ?? shared.cwd);
|
|
20672
20599
|
let repository;
|
|
20673
20600
|
if (parsed.repo !== void 0) {
|
|
@@ -20717,15 +20644,12 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20717
20644
|
return { ...admittedCollector, repository };
|
|
20718
20645
|
}
|
|
20719
20646
|
case "case-identity": {
|
|
20720
|
-
if (parsed.
|
|
20721
|
-
requireOptionPath("--project", parsed.project);
|
|
20722
|
-
}
|
|
20723
|
-
const issueNumber = parsed.issueNumber ?? Number.NaN;
|
|
20724
|
-
if (!Number.isInteger(issueNumber) || issueNumber < 1 || !DOCTOR_ISSUE_NUMBER_PATTERN.test(String(issueNumber))) {
|
|
20647
|
+
if (parsed.issueNumber === void 0) {
|
|
20725
20648
|
throw new CliUsageError(
|
|
20726
|
-
`doctor --issue must be a positive integer, got ${
|
|
20649
|
+
`doctor --issue must be a positive integer, got ${Number.NaN}`
|
|
20727
20650
|
);
|
|
20728
20651
|
}
|
|
20652
|
+
const issueNumber = parsed.issueNumber;
|
|
20729
20653
|
let frozenAttachments = [];
|
|
20730
20654
|
const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
|
|
20731
20655
|
...shared,
|
|
@@ -20751,7 +20675,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20751
20675
|
if (parsed.runs === void 0) {
|
|
20752
20676
|
ensureRealDirectoryTree(placed.ledgerHome, caseRunsPath);
|
|
20753
20677
|
}
|
|
20754
|
-
let
|
|
20678
|
+
let caseIdentity;
|
|
20755
20679
|
try {
|
|
20756
20680
|
const patient = await loadDoctorCase(caseRunsPath);
|
|
20757
20681
|
if (patient.identity.issueNumber !== issueNumber) {
|
|
@@ -20759,7 +20683,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20759
20683
|
`doctor case issue ${patient.identity.issueNumber} does not match --issue ${issueNumber}`
|
|
20760
20684
|
);
|
|
20761
20685
|
}
|
|
20762
|
-
|
|
20686
|
+
caseIdentity = patient.identity;
|
|
20763
20687
|
caseRunsPath = await realpath4(caseRunsPath);
|
|
20764
20688
|
} catch (error) {
|
|
20765
20689
|
if (error instanceof CliUsageError) throw error;
|
|
@@ -20773,7 +20697,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20773
20697
|
return {
|
|
20774
20698
|
issueNumber,
|
|
20775
20699
|
caseRunsPath,
|
|
20776
|
-
caseIdentity
|
|
20700
|
+
caseIdentity,
|
|
20777
20701
|
attachments: persistedAttachmentRefs(frozenAttachments)
|
|
20778
20702
|
};
|
|
20779
20703
|
}
|
|
@@ -20781,22 +20705,21 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20781
20705
|
return { ...admittedDoctor, attachments: frozenAttachments };
|
|
20782
20706
|
}
|
|
20783
20707
|
case "source-locator": {
|
|
20784
|
-
if (parsed.project !== void 0) {
|
|
20785
|
-
requireOptionPath("--project", parsed.project);
|
|
20786
|
-
}
|
|
20787
20708
|
const projectRoot = resolve9(parsed.project ?? shared.cwd);
|
|
20788
|
-
let sourceRun;
|
|
20789
|
-
|
|
20790
|
-
|
|
20791
|
-
|
|
20792
|
-
|
|
20793
|
-
|
|
20794
|
-
|
|
20795
|
-
|
|
20796
|
-
|
|
20797
|
-
|
|
20709
|
+
let sourceRun = override?.resolvedSourceRun;
|
|
20710
|
+
if (sourceRun === void 0) {
|
|
20711
|
+
try {
|
|
20712
|
+
sourceRun = await resolveNotarySourceRunLocator({
|
|
20713
|
+
projectRoot,
|
|
20714
|
+
sourceRun: parsed.sourceRun ?? "",
|
|
20715
|
+
home: shared.home
|
|
20716
|
+
});
|
|
20717
|
+
} catch (error) {
|
|
20718
|
+
if (error instanceof NotarySourceRunError) {
|
|
20719
|
+
throw new CliUsageError(error.message, { cause: error });
|
|
20720
|
+
}
|
|
20721
|
+
throw error;
|
|
20798
20722
|
}
|
|
20799
|
-
throw error;
|
|
20800
20723
|
}
|
|
20801
20724
|
const inheritedTicketNumber = await readBoardTicketNumber(sourceRun.runDirectory);
|
|
20802
20725
|
const knownTicketNumber = inheritedTicketNumber ?? shared.assertedTicketNumber;
|
|
@@ -20814,9 +20737,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20814
20737
|
});
|
|
20815
20738
|
}
|
|
20816
20739
|
case "gleaner": {
|
|
20817
|
-
if (parsed.project !== void 0) {
|
|
20818
|
-
requireOptionPath("--project", parsed.project);
|
|
20819
|
-
}
|
|
20820
20740
|
const baseRevision = parsed.baseRevision ?? "";
|
|
20821
20741
|
if (baseRevision.trim() === "") {
|
|
20822
20742
|
throw new CliUsageError("--base requires a nonempty revision");
|
|
@@ -20831,16 +20751,19 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20831
20751
|
});
|
|
20832
20752
|
}
|
|
20833
20753
|
case "review-basis": {
|
|
20834
|
-
|
|
20835
|
-
|
|
20836
|
-
|
|
20754
|
+
if (parsed.lens === void 0) {
|
|
20755
|
+
throw new CliUsageError("--lens requires completeness or correctness");
|
|
20756
|
+
}
|
|
20757
|
+
if (parsed.baseRevision === void 0) {
|
|
20758
|
+
throw new CliUsageError("--base requires a nonempty revision");
|
|
20837
20759
|
}
|
|
20838
|
-
const baseRevision = requireReviewerBaseRevision(parsed.baseRevision);
|
|
20839
20760
|
const rawRefs = parsed.authorityRefs ?? [];
|
|
20840
20761
|
if (rawRefs.length === 0) {
|
|
20841
20762
|
throw new CliUsageError("reviewer requires --authority-ref <ref>");
|
|
20842
20763
|
}
|
|
20843
|
-
const
|
|
20764
|
+
const lens = parsed.lens;
|
|
20765
|
+
const baseRevision = parsed.baseRevision;
|
|
20766
|
+
const authorityRefs = Object.freeze([...rawRefs]);
|
|
20844
20767
|
const admittedReviewer = await admitStandardMaterialInvocation("reviewer", {
|
|
20845
20768
|
...shared,
|
|
20846
20769
|
instruction,
|
|
@@ -20855,9 +20778,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20855
20778
|
return { ...admittedReviewer, authorityRefs };
|
|
20856
20779
|
}
|
|
20857
20780
|
case "merge-envelope": {
|
|
20858
|
-
if (parsed.project !== void 0) {
|
|
20859
|
-
requireOptionPath("--project", parsed.project);
|
|
20860
|
-
}
|
|
20861
20781
|
if (instruction.trim() === "") {
|
|
20862
20782
|
throw new CliUsageError("merger requires a nonblank task instruction");
|
|
20863
20783
|
}
|
|
@@ -20919,9 +20839,6 @@ function admissionSubject(ticketNumber) {
|
|
|
20919
20839
|
return { ticketNumber: fields.ticketNumber };
|
|
20920
20840
|
}
|
|
20921
20841
|
async function placeRoleAdmission(options) {
|
|
20922
|
-
if (options.project !== void 0) {
|
|
20923
|
-
requireOptionPath("--project", options.project);
|
|
20924
|
-
}
|
|
20925
20842
|
const projectRoot = resolve9(options.project ?? options.cwd);
|
|
20926
20843
|
const runId = options.runId ?? (options.createRunId ?? uuidv7)();
|
|
20927
20844
|
const ticketFields = ticketAdmissionFields(options.assertedTicketNumber);
|
|
@@ -21287,11 +21204,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
21287
21204
|
`${flag} requires a comma-separated list of N or book:N`
|
|
21288
21205
|
);
|
|
21289
21206
|
}
|
|
21290
|
-
const
|
|
21291
|
-
if (
|
|
21292
|
-
const rhs = trimmed.slice(
|
|
21207
|
+
const sep5 = trimmed.lastIndexOf(":");
|
|
21208
|
+
if (sep5 > 0) {
|
|
21209
|
+
const rhs = trimmed.slice(sep5 + 1);
|
|
21293
21210
|
if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
|
|
21294
|
-
const bookKey = trimmed.slice(0,
|
|
21211
|
+
const bookKey = trimmed.slice(0, sep5);
|
|
21295
21212
|
if (bookKey.trim() === "") {
|
|
21296
21213
|
throw new CliUsageError(
|
|
21297
21214
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -21671,6 +21588,48 @@ var init_role_turn_host_resolution = __esm({
|
|
|
21671
21588
|
}
|
|
21672
21589
|
});
|
|
21673
21590
|
|
|
21591
|
+
// src/public-cli/role-seat-runtime.ts
|
|
21592
|
+
var role_seat_runtime_exports = {};
|
|
21593
|
+
__export(role_seat_runtime_exports, {
|
|
21594
|
+
openRoleSeatRuntime: () => openRoleSeatRuntime
|
|
21595
|
+
});
|
|
21596
|
+
function openRoleSeatRuntime(input) {
|
|
21597
|
+
const hostAdapters = composeRoleTurnHostAdapters(
|
|
21598
|
+
input.resolution,
|
|
21599
|
+
input.principalAuthority
|
|
21600
|
+
);
|
|
21601
|
+
const roleTurnHost = selectRoleTurnHost(hostAdapters, {
|
|
21602
|
+
role: input.role,
|
|
21603
|
+
seat: input.seat
|
|
21604
|
+
});
|
|
21605
|
+
input.afterHost?.();
|
|
21606
|
+
const seatWithModel = resolvedSeatWithModel(input.seat);
|
|
21607
|
+
if (seatWithModel === void 0) return { ok: false };
|
|
21608
|
+
const projected = input.hostFacingModel ?? projectHostFacingProvider(
|
|
21609
|
+
seatWithModel.selection,
|
|
21610
|
+
seatWithModel.host,
|
|
21611
|
+
loadHostProvidersTable(input.home),
|
|
21612
|
+
input.home
|
|
21613
|
+
);
|
|
21614
|
+
return {
|
|
21615
|
+
ok: true,
|
|
21616
|
+
roleTurnHost,
|
|
21617
|
+
hostAdapters,
|
|
21618
|
+
...projected === void 0 ? {} : { model: projected },
|
|
21619
|
+
...pickEngineAxis(seatWithModel),
|
|
21620
|
+
host: seatWithModel.host
|
|
21621
|
+
};
|
|
21622
|
+
}
|
|
21623
|
+
var init_role_seat_runtime = __esm({
|
|
21624
|
+
"src/public-cli/role-seat-runtime.ts"() {
|
|
21625
|
+
"use strict";
|
|
21626
|
+
init_engine_material();
|
|
21627
|
+
init_config2();
|
|
21628
|
+
init_host_providers();
|
|
21629
|
+
init_role_turn_host_resolution();
|
|
21630
|
+
}
|
|
21631
|
+
});
|
|
21632
|
+
|
|
21674
21633
|
// src/analyst-gate-cycles-read.ts
|
|
21675
21634
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
21676
21635
|
import { join as join22 } from "node:path";
|
|
@@ -24943,6 +24902,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
24943
24902
|
});
|
|
24944
24903
|
|
|
24945
24904
|
// src/public-cli/turn-request.ts
|
|
24905
|
+
function projectPublicTurnAxes(env) {
|
|
24906
|
+
return {
|
|
24907
|
+
packageRoot: env.packageRoot,
|
|
24908
|
+
home: env.home,
|
|
24909
|
+
agentDir: env.agentDir,
|
|
24910
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
24911
|
+
...pickEngineAxis(env),
|
|
24912
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs }
|
|
24913
|
+
};
|
|
24914
|
+
}
|
|
24946
24915
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
24947
24916
|
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
24948
24917
|
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
@@ -25149,7 +25118,7 @@ __export(instruction_seat_run_exports, {
|
|
|
25149
25118
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
25150
25119
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
25151
25120
|
});
|
|
25152
|
-
import { dirname as dirname17, resolve as resolve11
|
|
25121
|
+
import { dirname as dirname17, resolve as resolve11 } from "node:path";
|
|
25153
25122
|
function unreadablePostSubmissionStatus(admitted, terminal) {
|
|
25154
25123
|
if (terminal?.roleOutcome.kind !== "accepted") return void 0;
|
|
25155
25124
|
const route = POST_SUBMISSION_ROUTING[admitted.role];
|
|
@@ -25381,27 +25350,43 @@ async function runOmittedLensBatch(argv2, parsed, env, io) {
|
|
|
25381
25350
|
io.stdout(formatTerminalResult(terminal));
|
|
25382
25351
|
return { exitCode: failed ? 1 : 0, terminal };
|
|
25383
25352
|
}
|
|
25353
|
+
function resumeSameParentInstructionSeat(input) {
|
|
25354
|
+
return tryResumeSameTicketSeatRun({
|
|
25355
|
+
home: input.env.home,
|
|
25356
|
+
projectRoot: input.projectRoot,
|
|
25357
|
+
role: input.role,
|
|
25358
|
+
parentRunPath: input.parentRunPath,
|
|
25359
|
+
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
|
|
25360
|
+
freshSummons: input.env.freshSummons,
|
|
25361
|
+
summons: input.summons,
|
|
25362
|
+
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25363
|
+
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25364
|
+
input.env,
|
|
25365
|
+
input.io
|
|
25366
|
+
)
|
|
25367
|
+
});
|
|
25368
|
+
}
|
|
25369
|
+
function sameParentInstruction(env, fallback) {
|
|
25370
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
25371
|
+
if (resumeInstruction === void 0) return fallback;
|
|
25372
|
+
return { instruction: resumeInstruction, instructionEmpty: false };
|
|
25373
|
+
}
|
|
25384
25374
|
async function runCountersignBody(parsed, env, io) {
|
|
25385
25375
|
const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
|
|
25386
25376
|
if (gateParentRunPath !== void 0) {
|
|
25387
25377
|
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction ?? "";
|
|
25388
|
-
const resumed = await
|
|
25389
|
-
|
|
25378
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
25379
|
+
env,
|
|
25380
|
+
io,
|
|
25390
25381
|
projectRoot: resolve11(parsed.project ?? env.cwd),
|
|
25391
25382
|
role: "countersign",
|
|
25392
25383
|
parentRunPath: gateParentRunPath,
|
|
25393
25384
|
...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
|
|
25394
|
-
freshSummons: env.freshSummons,
|
|
25395
25385
|
summons: {
|
|
25396
25386
|
sourceRunPath: gateParentRunPath,
|
|
25397
25387
|
instruction: resumeInstruction,
|
|
25398
25388
|
instructionEmpty: resumeInstruction.trim() === ""
|
|
25399
|
-
}
|
|
25400
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25401
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25402
|
-
env,
|
|
25403
|
-
io
|
|
25404
|
-
)
|
|
25389
|
+
}
|
|
25405
25390
|
});
|
|
25406
25391
|
if (resumed != null) return resumed;
|
|
25407
25392
|
}
|
|
@@ -25433,12 +25418,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
25433
25418
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
25434
25419
|
}
|
|
25435
25420
|
const turnProjection = {
|
|
25436
|
-
|
|
25437
|
-
home: env.home,
|
|
25438
|
-
agentDir: env.agentDir,
|
|
25439
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
25440
|
-
...pickEngineAxis(env),
|
|
25441
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
25421
|
+
...projectPublicTurnAxes(env),
|
|
25442
25422
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
25443
25423
|
continuation: {
|
|
25444
25424
|
kind: "initial",
|
|
@@ -25509,17 +25489,18 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25509
25489
|
let auditorSubject;
|
|
25510
25490
|
let auditorSource;
|
|
25511
25491
|
let auditorTicket;
|
|
25492
|
+
let resolvedNotarySource;
|
|
25512
25493
|
if (record4.sameParent === "subject-source") {
|
|
25513
|
-
if (
|
|
25494
|
+
if (parsed.subject === void 0) {
|
|
25514
25495
|
presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
|
|
25515
25496
|
return { exitCode: 2 };
|
|
25516
25497
|
}
|
|
25517
25498
|
auditorSubject = parsed.subject;
|
|
25518
|
-
|
|
25519
|
-
if (source === "") {
|
|
25499
|
+
if (parsed.sourceRun === void 0) {
|
|
25520
25500
|
presentStructuralRejection(new CliUsageError("auditor --source-run requires a run locator"), io);
|
|
25521
25501
|
return { exitCode: 2 };
|
|
25522
25502
|
}
|
|
25503
|
+
const source = parsed.sourceRun;
|
|
25523
25504
|
try {
|
|
25524
25505
|
const resolved = await resolveNotarySourceRunLocator({ projectRoot, sourceRun: source, home: env.home });
|
|
25525
25506
|
auditorSource = resolved.runDirectory;
|
|
@@ -25530,26 +25511,23 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25530
25511
|
}
|
|
25531
25512
|
if (auditorSource === void 0) return { exitCode: 2 };
|
|
25532
25513
|
const sourceDirectory = auditorSource;
|
|
25533
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
25534
25514
|
const summons = {
|
|
25535
|
-
...
|
|
25515
|
+
...sameParentInstruction(env, {
|
|
25516
|
+
instruction: parsed.instruction ?? "",
|
|
25517
|
+
instructionEmpty: (parsed.instruction ?? "").trim() === ""
|
|
25518
|
+
}),
|
|
25536
25519
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
25537
25520
|
};
|
|
25538
25521
|
const resumed = await withAuditorSoulEnv({
|
|
25539
25522
|
subject: auditorSubject,
|
|
25540
25523
|
sourceRunDirectory: auditorSource,
|
|
25541
|
-
run: () =>
|
|
25542
|
-
|
|
25524
|
+
run: () => resumeSameParentInstructionSeat({
|
|
25525
|
+
env,
|
|
25526
|
+
io,
|
|
25543
25527
|
projectRoot,
|
|
25544
25528
|
role,
|
|
25545
25529
|
parentRunPath: sourceDirectory,
|
|
25546
|
-
|
|
25547
|
-
summons,
|
|
25548
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25549
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25550
|
-
env,
|
|
25551
|
-
io
|
|
25552
|
-
)
|
|
25530
|
+
summons
|
|
25553
25531
|
})
|
|
25554
25532
|
});
|
|
25555
25533
|
if (resumed != null) return resumed;
|
|
@@ -25557,24 +25535,21 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25557
25535
|
if (record4.sameParent === "gate-pointer") {
|
|
25558
25536
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
|
|
25559
25537
|
if (parentRunPath !== void 0) {
|
|
25560
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
25561
25538
|
const summons = {
|
|
25562
25539
|
sourceRunPath: parentRunPath,
|
|
25563
|
-
...
|
|
25540
|
+
...sameParentInstruction(env, {
|
|
25541
|
+
instruction: parsed.instruction ?? "",
|
|
25542
|
+
instructionEmpty: (parsed.instruction ?? "").trim() === ""
|
|
25543
|
+
}),
|
|
25564
25544
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
25565
25545
|
};
|
|
25566
|
-
const resumed = await
|
|
25567
|
-
|
|
25546
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
25547
|
+
env,
|
|
25548
|
+
io,
|
|
25568
25549
|
projectRoot,
|
|
25569
25550
|
role,
|
|
25570
25551
|
parentRunPath,
|
|
25571
|
-
|
|
25572
|
-
summons,
|
|
25573
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25574
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25575
|
-
env,
|
|
25576
|
-
io
|
|
25577
|
-
)
|
|
25552
|
+
summons
|
|
25578
25553
|
});
|
|
25579
25554
|
if (resumed != null) return resumed;
|
|
25580
25555
|
}
|
|
@@ -25600,28 +25575,28 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25600
25575
|
sourceRun: source,
|
|
25601
25576
|
...resumeInstruction === void 0 ? {} : { instruction: resumeInstruction, instructionEmpty: false }
|
|
25602
25577
|
};
|
|
25603
|
-
|
|
25604
|
-
|
|
25578
|
+
resolvedNotarySource = source;
|
|
25579
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
25580
|
+
env,
|
|
25581
|
+
io,
|
|
25605
25582
|
projectRoot,
|
|
25606
25583
|
role,
|
|
25607
25584
|
parentRunPath: source.runDirectory,
|
|
25608
|
-
|
|
25609
|
-
summons,
|
|
25610
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25611
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25612
|
-
env,
|
|
25613
|
-
io
|
|
25614
|
-
)
|
|
25585
|
+
summons
|
|
25615
25586
|
});
|
|
25616
25587
|
if (resumed != null) return resumed;
|
|
25617
25588
|
}
|
|
25618
25589
|
let admitted;
|
|
25619
25590
|
try {
|
|
25591
|
+
const admissionOverride = {
|
|
25592
|
+
...auditorTicket === void 0 ? {} : { assertedTicketNumber: auditorTicket },
|
|
25593
|
+
...resolvedNotarySource === void 0 ? {} : { resolvedSourceRun: resolvedNotarySource }
|
|
25594
|
+
};
|
|
25620
25595
|
admitted = await admitPublicRole(
|
|
25621
25596
|
role,
|
|
25622
25597
|
parsed,
|
|
25623
25598
|
env,
|
|
25624
|
-
auditorTicket === void 0
|
|
25599
|
+
auditorTicket === void 0 && resolvedNotarySource === void 0 ? void 0 : admissionOverride
|
|
25625
25600
|
);
|
|
25626
25601
|
} catch (error) {
|
|
25627
25602
|
const rejected = usageExit(error, io);
|
|
@@ -25659,7 +25634,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25659
25634
|
thrown: error
|
|
25660
25635
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
25661
25636
|
}
|
|
25662
|
-
if (outcome.admitted
|
|
25637
|
+
if (outcome.admitted !== void 0 && isUnboundRunDirectory(outcome.admitted.runDirectory)) {
|
|
25663
25638
|
await recordChildDiaristRun(admitted, outcome.admitted.runId);
|
|
25664
25639
|
}
|
|
25665
25640
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
@@ -26008,6 +25983,7 @@ var AUDITED_ROLES, SECRETARIAT_STATUS_REASK, COUNTERSIGN_STATUS_REASK, WORKER_RO
|
|
|
26008
25983
|
var init_instruction_seat_run = __esm({
|
|
26009
25984
|
"src/public-cli/instruction-seat-run.ts"() {
|
|
26010
25985
|
"use strict";
|
|
25986
|
+
init_role_run_placement();
|
|
26011
25987
|
init_compliance_transport();
|
|
26012
25988
|
init_archivist_record_pointer();
|
|
26013
25989
|
init_doctor_auditor();
|
|
@@ -26156,12 +26132,6 @@ async function resolveSummonHome(options) {
|
|
|
26156
26132
|
if (fromCwd !== void 0 && fromCwd.length > 0) return fromCwd;
|
|
26157
26133
|
return packageMachineHome2();
|
|
26158
26134
|
}
|
|
26159
|
-
function projectSeatEngine(seat) {
|
|
26160
|
-
return pickEngineAxis(seat);
|
|
26161
|
-
}
|
|
26162
|
-
function projectSeatHost(seat) {
|
|
26163
|
-
return seat.host === void 0 ? {} : { host: seat.host };
|
|
26164
|
-
}
|
|
26165
26135
|
function hostSelectionFailureFromUnknown(error) {
|
|
26166
26136
|
if (typeof error !== "object" || error === null) return void 0;
|
|
26167
26137
|
if (error.name !== "HostSelectionError") return void 0;
|
|
@@ -26172,44 +26142,36 @@ async function createSummonEnv(options, afterHost) {
|
|
|
26172
26142
|
const [
|
|
26173
26143
|
{ piDurablePrincipalAuthority: piDurablePrincipalAuthority2 },
|
|
26174
26144
|
{ appendPiSessionCustomEntry: appendPiSessionCustomEntry2 },
|
|
26175
|
-
{
|
|
26176
|
-
{ missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2
|
|
26145
|
+
{ openRoleSeatRuntime: openRoleSeatRuntime2 },
|
|
26146
|
+
{ missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2 }
|
|
26177
26147
|
] = await Promise.all([
|
|
26178
26148
|
Promise.resolve().then(() => (init_durable_principal(), durable_principal_exports)),
|
|
26179
26149
|
Promise.resolve().then(() => (init_role_turn_host(), role_turn_host_exports)),
|
|
26180
|
-
Promise.resolve().then(() => (
|
|
26150
|
+
Promise.resolve().then(() => (init_role_seat_runtime(), role_seat_runtime_exports)),
|
|
26181
26151
|
Promise.resolve().then(() => (init_config2(), config_exports))
|
|
26182
26152
|
]);
|
|
26183
26153
|
const principalAuthority = options.principalAuthority ?? piDurablePrincipalAuthority2;
|
|
26184
|
-
const
|
|
26185
|
-
{
|
|
26154
|
+
const opened = openRoleSeatRuntime2({
|
|
26155
|
+
resolution: {
|
|
26186
26156
|
packageRoot: options.packageRoot,
|
|
26187
26157
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
26188
26158
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
26189
26159
|
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
26190
26160
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
26191
26161
|
},
|
|
26192
|
-
|
|
26193
|
-
|
|
26194
|
-
|
|
26195
|
-
|
|
26196
|
-
|
|
26162
|
+
principalAuthority,
|
|
26163
|
+
role: options.role,
|
|
26164
|
+
seat: options.seat,
|
|
26165
|
+
home: options.home,
|
|
26166
|
+
...afterHost === void 0 ? {} : { afterHost },
|
|
26167
|
+
...options.hostFacingModel === void 0 ? {} : { hostFacingModel: options.hostFacingModel }
|
|
26168
|
+
});
|
|
26169
|
+
if (!opened.ok) {
|
|
26197
26170
|
return {
|
|
26198
26171
|
ok: false,
|
|
26199
26172
|
missingModelMessage: missingResolvedSeatModelMessage2(options.role)
|
|
26200
26173
|
};
|
|
26201
26174
|
}
|
|
26202
|
-
const hostName = seatWithModel.host ?? "pi";
|
|
26203
|
-
let hostFacingSelection = options.hostFacingModel;
|
|
26204
|
-
if (hostFacingSelection === void 0) {
|
|
26205
|
-
const { loadHostProvidersTable: loadHostProvidersTable2, projectHostFacingProvider: projectHostFacingProvider2 } = await Promise.resolve().then(() => (init_host_providers(), host_providers_exports));
|
|
26206
|
-
hostFacingSelection = projectHostFacingProvider2(
|
|
26207
|
-
seatWithModel.selection,
|
|
26208
|
-
hostName,
|
|
26209
|
-
loadHostProvidersTable2(options.home),
|
|
26210
|
-
options.home
|
|
26211
|
-
);
|
|
26212
|
-
}
|
|
26213
26175
|
return {
|
|
26214
26176
|
ok: true,
|
|
26215
26177
|
env: {
|
|
@@ -26218,12 +26180,13 @@ async function createSummonEnv(options, afterHost) {
|
|
|
26218
26180
|
agentDir: options.agentDir,
|
|
26219
26181
|
sessionAppender: appendPiSessionCustomEntry2,
|
|
26220
26182
|
packageRoot: options.packageRoot,
|
|
26221
|
-
roleTurnHost,
|
|
26183
|
+
roleTurnHost: opened.roleTurnHost,
|
|
26222
26184
|
cwd: options.cwd,
|
|
26223
26185
|
credentials: options.credentials,
|
|
26224
|
-
...
|
|
26225
|
-
...
|
|
26226
|
-
...
|
|
26186
|
+
...opened.model === void 0 ? {} : { model: opened.model },
|
|
26187
|
+
...opened.engine === void 0 ? {} : { engine: opened.engine },
|
|
26188
|
+
...opened.engineModel === void 0 ? {} : { engineModel: opened.engineModel },
|
|
26189
|
+
host: opened.host,
|
|
26227
26190
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
26228
26191
|
}
|
|
26229
26192
|
};
|
|
@@ -26231,13 +26194,14 @@ async function createSummonEnv(options, afterHost) {
|
|
|
26231
26194
|
async function summonPublicRole(options) {
|
|
26232
26195
|
const packageRoot2 = resolveSummonsPackageRoot(options.packageRoot);
|
|
26233
26196
|
const home = await resolveSummonHome(options);
|
|
26234
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join29(home, ".pi", "agent");
|
|
26235
26197
|
const {
|
|
26236
26198
|
loadCredentialProviders: loadCredentialProviders2,
|
|
26237
26199
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
26238
26200
|
resolveEffectiveSeat: resolveEffectiveSeat2,
|
|
26201
|
+
resolvePublicAgentDir: resolvePublicAgentDir2,
|
|
26239
26202
|
validatePublicCliConfigAxes: validatePublicCliConfigAxes2
|
|
26240
26203
|
} = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
26204
|
+
const agentDir = resolvePublicAgentDir2(options.agentDir, home);
|
|
26241
26205
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
26242
26206
|
const config = await loadPublicCliConfig2(home);
|
|
26243
26207
|
validatePublicCliConfigAxes2(config, packageRoot2);
|
|
@@ -26594,7 +26558,6 @@ var AK_ROLE_PACKAGE_ROOT_ENV, execFileAsync3;
|
|
|
26594
26558
|
var init_public_role_summons = __esm({
|
|
26595
26559
|
"src/public-role-summons.ts"() {
|
|
26596
26560
|
"use strict";
|
|
26597
|
-
init_engine_material();
|
|
26598
26561
|
AK_ROLE_PACKAGE_ROOT_ENV = "AK_ROLE_PACKAGE_ROOT";
|
|
26599
26562
|
execFileAsync3 = promisify3(execFile3);
|
|
26600
26563
|
}
|
|
@@ -26733,11 +26696,11 @@ var init_compliance_transport = __esm({
|
|
|
26733
26696
|
});
|
|
26734
26697
|
|
|
26735
26698
|
// src/role-run-relocation.ts
|
|
26736
|
-
import { join as join30, sep as
|
|
26699
|
+
import { join as join30, sep as sep4 } from "node:path";
|
|
26737
26700
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
26738
26701
|
if (typeof value !== "string") return value;
|
|
26739
26702
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
26740
|
-
const prefix = `${oldRunDirectory}${
|
|
26703
|
+
const prefix = `${oldRunDirectory}${sep4}`;
|
|
26741
26704
|
if (value.startsWith(prefix)) {
|
|
26742
26705
|
return `${newRunDirectory}${value.slice(oldRunDirectory.length)}`;
|
|
26743
26706
|
}
|
|
@@ -26747,7 +26710,7 @@ function rewriteRunDirectoryPathValueAgainstRewrites(value, rewrites) {
|
|
|
26747
26710
|
if (typeof value !== "string" || rewrites.length === 0) return value;
|
|
26748
26711
|
let best;
|
|
26749
26712
|
for (const rewrite of rewrites) {
|
|
26750
|
-
if (value === rewrite.oldRunDirectory || value.startsWith(`${rewrite.oldRunDirectory}${
|
|
26713
|
+
if (value === rewrite.oldRunDirectory || value.startsWith(`${rewrite.oldRunDirectory}${sep4}`)) {
|
|
26751
26714
|
if (best === void 0 || rewrite.oldRunDirectory.length > best.oldRunDirectory.length) {
|
|
26752
26715
|
best = rewrite;
|
|
26753
26716
|
}
|
|
@@ -27502,7 +27465,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27502
27465
|
let waitWindowMs;
|
|
27503
27466
|
let issueNumber;
|
|
27504
27467
|
let caseRunsPath;
|
|
27505
|
-
let
|
|
27468
|
+
let caseIdentity;
|
|
27506
27469
|
let sourceRunPath;
|
|
27507
27470
|
let sourceRun;
|
|
27508
27471
|
try {
|
|
@@ -27573,7 +27536,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27573
27536
|
if (record4.caseIdentity !== null && typeof record4.caseIdentity === "object" && !Array.isArray(record4.caseIdentity)) {
|
|
27574
27537
|
const ci = record4.caseIdentity;
|
|
27575
27538
|
if (typeof ci.issueNumber === "number" && Number.isSafeInteger(ci.issueNumber) && ci.issueNumber >= 1 && typeof ci.runsPath === "string" && ci.runsPath.trim() !== "") {
|
|
27576
|
-
|
|
27539
|
+
caseIdentity = { issueNumber: ci.issueNumber, runsPath: ci.runsPath };
|
|
27577
27540
|
}
|
|
27578
27541
|
}
|
|
27579
27542
|
if (typeof record4.sourceRunPath === "string" && record4.sourceRunPath.trim() !== "") {
|
|
@@ -27702,7 +27665,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
27702
27665
|
...waitWindowMs === void 0 ? {} : { waitWindowMs },
|
|
27703
27666
|
...issueNumber === void 0 ? {} : { issueNumber },
|
|
27704
27667
|
...caseRunsPath === void 0 ? {} : { caseRunsPath },
|
|
27705
|
-
...
|
|
27668
|
+
...caseIdentity === void 0 ? {} : { caseIdentity },
|
|
27706
27669
|
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
27707
27670
|
...sourceRun === void 0 ? {} : { sourceRun },
|
|
27708
27671
|
...model === void 0 ? {} : { model }
|
|
@@ -27821,14 +27784,10 @@ function admitResumedRole(loaded) {
|
|
|
27821
27784
|
}
|
|
27822
27785
|
case "review-basis": {
|
|
27823
27786
|
const rawBase = fields.baseRevision;
|
|
27824
|
-
|
|
27787
|
+
const baseFault = admittedReviewerBaseFault(rawBase);
|
|
27788
|
+
if (baseFault !== void 0 || rawBase === void 0) {
|
|
27825
27789
|
throw new CliUsageError(
|
|
27826
|
-
`role run admitted reviewer base revision is missing: ${runId}`
|
|
27827
|
-
);
|
|
27828
|
-
}
|
|
27829
|
-
if (/\s/.test(rawBase) || rawBase.startsWith("-")) {
|
|
27830
|
-
throw new CliUsageError(
|
|
27831
|
-
`role run admitted reviewer base revision is damaged: ${runId}`
|
|
27790
|
+
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${runId}` : `role run admitted reviewer base revision is missing: ${runId}`
|
|
27832
27791
|
);
|
|
27833
27792
|
}
|
|
27834
27793
|
const lens = fields.lens;
|
|
@@ -27924,8 +27883,8 @@ function admitResumedRole(loaded) {
|
|
|
27924
27883
|
return admitted;
|
|
27925
27884
|
}
|
|
27926
27885
|
case "case-identity": {
|
|
27927
|
-
const { issueNumber, caseRunsPath, caseIdentity
|
|
27928
|
-
if (issueNumber === void 0 || caseRunsPath === void 0 ||
|
|
27886
|
+
const { issueNumber, caseRunsPath, caseIdentity } = fields;
|
|
27887
|
+
if (issueNumber === void 0 || caseRunsPath === void 0 || caseIdentity === void 0) {
|
|
27929
27888
|
throw new CliUsageError(
|
|
27930
27889
|
`role run admitted doctor case identity is missing: ${runId}`
|
|
27931
27890
|
);
|
|
@@ -27935,7 +27894,7 @@ function admitResumedRole(loaded) {
|
|
|
27935
27894
|
...base,
|
|
27936
27895
|
issueNumber,
|
|
27937
27896
|
caseRunsPath,
|
|
27938
|
-
caseIdentity
|
|
27897
|
+
caseIdentity
|
|
27939
27898
|
};
|
|
27940
27899
|
return admitted;
|
|
27941
27900
|
}
|
|
@@ -28554,12 +28513,10 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
28554
28513
|
} catch (appendError) {
|
|
28555
28514
|
try {
|
|
28556
28515
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
28557
|
-
await
|
|
28558
|
-
|
|
28559
|
-
|
|
28560
|
-
|
|
28561
|
-
{ encoding: "utf8", flag: "wx" }
|
|
28562
|
-
);
|
|
28516
|
+
await writeHardenedArtifactFile(artifactsDir, "post-admission-diagnostic", {
|
|
28517
|
+
version: 1,
|
|
28518
|
+
...payload
|
|
28519
|
+
});
|
|
28563
28520
|
} catch (artifactError) {
|
|
28564
28521
|
retentionFailure = `post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`;
|
|
28565
28522
|
}
|
|
@@ -29057,13 +29014,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
29057
29014
|
prompt = "";
|
|
29058
29015
|
}
|
|
29059
29016
|
return {
|
|
29060
|
-
|
|
29061
|
-
home: env.home,
|
|
29017
|
+
...projectPublicTurnAxes(env),
|
|
29062
29018
|
...env.host === void 0 ? {} : { host: env.host },
|
|
29063
|
-
agentDir: env.agentDir,
|
|
29064
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
29065
|
-
...pickEngineAxis(env),
|
|
29066
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
29067
29019
|
...env.correlationId === void 0 && admitted.correlationId === void 0 ? {} : { correlationId: env.correlationId ?? admitted.correlationId },
|
|
29068
29020
|
continuation: {
|
|
29069
29021
|
kind: "resume",
|
|
@@ -29076,13 +29028,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
29076
29028
|
function roleTurnOptions(env, admitted, continuation) {
|
|
29077
29029
|
const correlationId = env.correlationId ?? admitted.correlationId;
|
|
29078
29030
|
return {
|
|
29079
|
-
|
|
29080
|
-
home: env.home,
|
|
29031
|
+
...projectPublicTurnAxes(env),
|
|
29081
29032
|
...env.host === void 0 ? {} : { host: env.host },
|
|
29082
|
-
agentDir: env.agentDir,
|
|
29083
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
29084
|
-
...pickEngineAxis(env),
|
|
29085
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
29086
29033
|
...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
|
|
29087
29034
|
continuation,
|
|
29088
29035
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
@@ -29100,6 +29047,43 @@ async function dispatchAfterWriterLease(input) {
|
|
|
29100
29047
|
}
|
|
29101
29048
|
}
|
|
29102
29049
|
}
|
|
29050
|
+
async function runSettledAutoResumeLoop(input) {
|
|
29051
|
+
const adapters = withOnceSuccessfulBeforeDispatch(input.adapters);
|
|
29052
|
+
const dispatchEnv = input.dispatchEnv ?? input.env;
|
|
29053
|
+
return runWithAutoResumeLoop({
|
|
29054
|
+
admitted: input.admitted,
|
|
29055
|
+
principalAuthority: input.env.principalAuthority,
|
|
29056
|
+
io: input.io,
|
|
29057
|
+
sessionAppender: input.env.sessionAppender,
|
|
29058
|
+
autoResumeLimit: input.env.autoResumeLimit,
|
|
29059
|
+
...input.env.signal === void 0 ? {} : { signal: input.env.signal },
|
|
29060
|
+
buildInitialPayload: input.buildInitialPayload,
|
|
29061
|
+
buildResumePayload: input.buildResumePayload,
|
|
29062
|
+
dispatch: async (payload, lease, _isFirst, attemptIo) => dispatchAfterWriterLease({
|
|
29063
|
+
...lease === void 0 ? {} : { lease },
|
|
29064
|
+
build: () => input.toRequest(payload),
|
|
29065
|
+
dispatch: async (request) => {
|
|
29066
|
+
const result = await dispatchPostAdmissionTurn({
|
|
29067
|
+
admitted: input.admitted,
|
|
29068
|
+
env: dispatchEnv,
|
|
29069
|
+
io: attemptIo,
|
|
29070
|
+
request,
|
|
29071
|
+
...lease === void 0 ? {} : { lease },
|
|
29072
|
+
adapters,
|
|
29073
|
+
persistRunState: false,
|
|
29074
|
+
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
29075
|
+
});
|
|
29076
|
+
return settleDeferredPersist(
|
|
29077
|
+
input.admitted,
|
|
29078
|
+
input.env.principalAuthority,
|
|
29079
|
+
adapters,
|
|
29080
|
+
attemptIo,
|
|
29081
|
+
result
|
|
29082
|
+
);
|
|
29083
|
+
}
|
|
29084
|
+
})
|
|
29085
|
+
});
|
|
29086
|
+
}
|
|
29103
29087
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
29104
29088
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
29105
29089
|
return pathContainedIn(join35(runDirectory, "attachments"), absolute);
|
|
@@ -29213,60 +29197,34 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
29213
29197
|
try {
|
|
29214
29198
|
if (env.stationChild === true) {
|
|
29215
29199
|
let firstTurn;
|
|
29216
|
-
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
29217
29200
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
29218
29201
|
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
29219
29202
|
});
|
|
29220
|
-
return await
|
|
29203
|
+
return await runSettledAutoResumeLoop({
|
|
29221
29204
|
admitted: loaded.admitted,
|
|
29222
|
-
|
|
29205
|
+
env,
|
|
29223
29206
|
io: input.io,
|
|
29224
|
-
|
|
29225
|
-
|
|
29226
|
-
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
29207
|
+
adapters,
|
|
29208
|
+
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
|
|
29227
29209
|
buildInitialPayload: () => ({ resumeTurn: false }),
|
|
29228
29210
|
buildResumePayload: () => ({ resumeTurn: true }),
|
|
29229
|
-
|
|
29230
|
-
|
|
29231
|
-
|
|
29232
|
-
|
|
29233
|
-
|
|
29234
|
-
|
|
29235
|
-
|
|
29236
|
-
|
|
29237
|
-
|
|
29238
|
-
kind: "resume",
|
|
29239
|
-
prompt: RESUME_TRANSPORT_ENVELOPE
|
|
29240
|
-
}
|
|
29241
|
-
};
|
|
29242
|
-
}
|
|
29243
|
-
const turnRequest = withEngineDetourInvocationScope(
|
|
29244
|
-
await buildRequestAfterLease(),
|
|
29245
|
-
invocationScopeId
|
|
29246
|
-
);
|
|
29247
|
-
firstTurn = turnRequest;
|
|
29248
|
-
return turnRequest;
|
|
29249
|
-
},
|
|
29250
|
-
dispatch: async (turnRequest) => {
|
|
29251
|
-
const result = await dispatchPostAdmissionTurn({
|
|
29252
|
-
admitted: loaded.admitted,
|
|
29253
|
-
env,
|
|
29254
|
-
io: attemptIo,
|
|
29255
|
-
request: turnRequest,
|
|
29256
|
-
...lease === void 0 ? {} : { lease },
|
|
29257
|
-
adapters: stationAdapters,
|
|
29258
|
-
persistRunState: false,
|
|
29259
|
-
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
29260
|
-
});
|
|
29261
|
-
return settleDeferredPersist(
|
|
29262
|
-
loaded.admitted,
|
|
29263
|
-
env.principalAuthority,
|
|
29264
|
-
stationAdapters,
|
|
29265
|
-
attemptIo,
|
|
29266
|
-
result
|
|
29267
|
-
);
|
|
29211
|
+
toRequest: async (payload) => {
|
|
29212
|
+
if (payload.resumeTurn && firstTurn !== void 0) {
|
|
29213
|
+
return {
|
|
29214
|
+
...firstTurn,
|
|
29215
|
+
continuation: {
|
|
29216
|
+
kind: "resume",
|
|
29217
|
+
prompt: RESUME_TRANSPORT_ENVELOPE
|
|
29218
|
+
}
|
|
29219
|
+
};
|
|
29268
29220
|
}
|
|
29269
|
-
|
|
29221
|
+
const turnRequest = withEngineDetourInvocationScope(
|
|
29222
|
+
await buildRequestAfterLease(),
|
|
29223
|
+
invocationScopeId
|
|
29224
|
+
);
|
|
29225
|
+
firstTurn = turnRequest;
|
|
29226
|
+
return turnRequest;
|
|
29227
|
+
}
|
|
29270
29228
|
});
|
|
29271
29229
|
}
|
|
29272
29230
|
const resumed = await runPostAdmissionManualResume({
|
|
@@ -29398,38 +29356,25 @@ async function runPostAdmissionOneShot(input) {
|
|
|
29398
29356
|
}
|
|
29399
29357
|
async function runPostAdmissionResumable(input) {
|
|
29400
29358
|
const { admitted, env, io, buildInitialRequest, buildResumeRequest, effectiveEngine } = input;
|
|
29401
|
-
const adapters = withOnceSuccessfulBeforeDispatch(input.adapters);
|
|
29402
29359
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
29403
29360
|
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
29404
29361
|
});
|
|
29405
29362
|
const buildScopedInitial = () => withEngineDetourInvocationScope(buildInitialRequest(), invocationScopeId);
|
|
29406
29363
|
const buildScopedResume = () => withEngineDetourInvocationScope(buildResumeRequest(), invocationScopeId);
|
|
29407
|
-
return
|
|
29364
|
+
return runSettledAutoResumeLoop({
|
|
29408
29365
|
admitted,
|
|
29409
|
-
|
|
29366
|
+
env,
|
|
29410
29367
|
io,
|
|
29411
|
-
|
|
29412
|
-
|
|
29413
|
-
|
|
29368
|
+
adapters: input.adapters,
|
|
29369
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine },
|
|
29370
|
+
// Ordinary in-call retry keeps the admitted correlation when one was stored.
|
|
29371
|
+
dispatchEnv: {
|
|
29372
|
+
...env,
|
|
29373
|
+
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
29374
|
+
},
|
|
29414
29375
|
buildInitialPayload: buildScopedInitial,
|
|
29415
29376
|
buildResumePayload: buildScopedResume,
|
|
29416
|
-
|
|
29417
|
-
const result = await dispatchPostAdmissionTurn({
|
|
29418
|
-
admitted,
|
|
29419
|
-
env: {
|
|
29420
|
-
...env,
|
|
29421
|
-
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
29422
|
-
},
|
|
29423
|
-
io: attemptIo,
|
|
29424
|
-
request,
|
|
29425
|
-
...lease === void 0 ? {} : { lease },
|
|
29426
|
-
adapters,
|
|
29427
|
-
persistRunState: false,
|
|
29428
|
-
// #600: every attempt (initial + auto-resume) writes seat engine when present.
|
|
29429
|
-
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
29430
|
-
});
|
|
29431
|
-
return settleDeferredPersist(admitted, env.principalAuthority, adapters, attemptIo, result);
|
|
29432
|
-
}
|
|
29377
|
+
toRequest: async (request) => request
|
|
29433
29378
|
});
|
|
29434
29379
|
}
|
|
29435
29380
|
async function runPostAdmissionManualResume(input) {
|
|
@@ -29481,6 +29426,7 @@ var init_post_admission = __esm({
|
|
|
29481
29426
|
"use strict";
|
|
29482
29427
|
init_run_lifecycle();
|
|
29483
29428
|
init_cli_errors();
|
|
29429
|
+
init_turn_request();
|
|
29484
29430
|
init_invocation();
|
|
29485
29431
|
init_submission_ledger();
|
|
29486
29432
|
init_run_ticket_number();
|
|
@@ -31648,7 +31594,6 @@ __export(cli_exports, {
|
|
|
31648
31594
|
runAkRole: () => runAkRole
|
|
31649
31595
|
});
|
|
31650
31596
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
31651
|
-
import { join as join40 } from "node:path";
|
|
31652
31597
|
function publicSeatArgv(owner) {
|
|
31653
31598
|
return {
|
|
31654
31599
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -31687,50 +31632,42 @@ function takePublicGlobalFlag(argv2, index, options) {
|
|
|
31687
31632
|
return void 0;
|
|
31688
31633
|
}
|
|
31689
31634
|
function createRoleEnvironment(env, options, afterHost) {
|
|
31690
|
-
const role = options.role;
|
|
31691
31635
|
const extraPiArgs = env.extraPiArgs;
|
|
31692
31636
|
const timeoutMs = env.timeoutMs;
|
|
31693
|
-
const
|
|
31694
|
-
{
|
|
31637
|
+
const opened = openRoleSeatRuntime({
|
|
31638
|
+
resolution: {
|
|
31695
31639
|
packageRoot: env.packageRoot,
|
|
31696
31640
|
...env.roleTurnHost === void 0 ? {} : { roleTurnHost: env.roleTurnHost },
|
|
31697
31641
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters },
|
|
31698
31642
|
...extraPiArgs === void 0 ? {} : { extraPiArgs },
|
|
31699
31643
|
...timeoutMs === void 0 ? {} : { timeoutMs }
|
|
31700
31644
|
},
|
|
31701
|
-
env.principalAuthority
|
|
31702
|
-
|
|
31703
|
-
|
|
31704
|
-
|
|
31705
|
-
|
|
31645
|
+
principalAuthority: env.principalAuthority,
|
|
31646
|
+
role: options.role,
|
|
31647
|
+
seat: options.seat,
|
|
31648
|
+
home: options.home,
|
|
31649
|
+
...afterHost === void 0 ? {} : { afterHost }
|
|
31706
31650
|
});
|
|
31707
|
-
|
|
31708
|
-
const seatWithModel = resolvedSeatWithModel(options.seat);
|
|
31709
|
-
if (seatWithModel === void 0) {
|
|
31651
|
+
if (!opened.ok) {
|
|
31710
31652
|
throw new CliUsageError(
|
|
31711
31653
|
missingResolvedSeatModelMessage(options.seat.seat, "invocation-or-config")
|
|
31712
31654
|
);
|
|
31713
31655
|
}
|
|
31714
|
-
const hostFacingSelection = projectHostFacingProvider(
|
|
31715
|
-
seatWithModel.selection,
|
|
31716
|
-
seatWithModel.host,
|
|
31717
|
-
loadHostProvidersTable(options.home),
|
|
31718
|
-
options.home
|
|
31719
|
-
);
|
|
31720
31656
|
return {
|
|
31721
31657
|
home: options.home,
|
|
31722
31658
|
principalAuthority: env.principalAuthority,
|
|
31723
31659
|
agentDir: options.agentDir,
|
|
31724
31660
|
sessionAppender: appendPiSessionCustomEntry,
|
|
31725
31661
|
packageRoot: env.packageRoot,
|
|
31726
|
-
roleTurnHost,
|
|
31727
|
-
hostAdapters,
|
|
31662
|
+
roleTurnHost: opened.roleTurnHost,
|
|
31663
|
+
hostAdapters: opened.hostAdapters,
|
|
31728
31664
|
cwd: options.cwd,
|
|
31729
31665
|
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
31730
31666
|
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
31731
|
-
...
|
|
31732
|
-
...
|
|
31733
|
-
...
|
|
31667
|
+
...opened.model === void 0 ? {} : { model: opened.model },
|
|
31668
|
+
...opened.engine === void 0 ? {} : { engine: opened.engine },
|
|
31669
|
+
...opened.engineModel === void 0 ? {} : { engineModel: opened.engineModel },
|
|
31670
|
+
host: opened.host,
|
|
31734
31671
|
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
31735
31672
|
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
31736
31673
|
...options.config?.autoResumeLimit === void 0 ? {} : { autoResumeLimit: options.config.autoResumeLimit },
|
|
@@ -31739,15 +31676,19 @@ function createRoleEnvironment(env, options, afterHost) {
|
|
|
31739
31676
|
...env.signal === void 0 ? {} : { signal: env.signal }
|
|
31740
31677
|
};
|
|
31741
31678
|
}
|
|
31742
|
-
async function
|
|
31743
|
-
const agentDir =
|
|
31679
|
+
async function loadPublicRoleDispatchParts(env, home) {
|
|
31680
|
+
const agentDir = resolvePublicAgentDir(env.agentDir, home);
|
|
31744
31681
|
const cwd = env.cwd ?? process.cwd();
|
|
31745
31682
|
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
31746
31683
|
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
31684
|
+
return { agentDir, cwd, config, credentials };
|
|
31685
|
+
}
|
|
31686
|
+
async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run) {
|
|
31687
|
+
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
31747
31688
|
const seat = resolveEffectiveSeat(
|
|
31748
|
-
config,
|
|
31689
|
+
parts.config,
|
|
31749
31690
|
role,
|
|
31750
|
-
credentials,
|
|
31691
|
+
parts.credentials,
|
|
31751
31692
|
invocationFromParsed(parsed)
|
|
31752
31693
|
);
|
|
31753
31694
|
let parsedRoleArgv;
|
|
@@ -31755,7 +31696,15 @@ async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run
|
|
|
31755
31696
|
parsed.args,
|
|
31756
31697
|
createRoleEnvironment(
|
|
31757
31698
|
env,
|
|
31758
|
-
{
|
|
31699
|
+
{
|
|
31700
|
+
role,
|
|
31701
|
+
home,
|
|
31702
|
+
agentDir: parts.agentDir,
|
|
31703
|
+
cwd: parts.cwd,
|
|
31704
|
+
credentials: parts.credentials,
|
|
31705
|
+
seat,
|
|
31706
|
+
config: parts.config
|
|
31707
|
+
},
|
|
31759
31708
|
() => {
|
|
31760
31709
|
parsedRoleArgv = parse(parsed.args);
|
|
31761
31710
|
}
|
|
@@ -31786,9 +31735,6 @@ function defaultIo() {
|
|
|
31786
31735
|
function resolveHome(env) {
|
|
31787
31736
|
return env.home ?? packageMachineHome();
|
|
31788
31737
|
}
|
|
31789
|
-
function resolveAgentDir(env, home) {
|
|
31790
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join40(home, ".pi", "agent");
|
|
31791
|
-
}
|
|
31792
31738
|
function parseThinking(value) {
|
|
31793
31739
|
return value;
|
|
31794
31740
|
}
|
|
@@ -31907,12 +31853,6 @@ function requireCallableSeat(seat, axis, verb) {
|
|
|
31907
31853
|
throw new CliUsageError(`unknown ${axis}-axis seat: ${seat}`);
|
|
31908
31854
|
}
|
|
31909
31855
|
}
|
|
31910
|
-
function projectSeatEngine2(seat) {
|
|
31911
|
-
return pickEngineAxis(seat);
|
|
31912
|
-
}
|
|
31913
|
-
function projectSeatHost2(seat) {
|
|
31914
|
-
return { host: seat.host };
|
|
31915
|
-
}
|
|
31916
31856
|
function loadAndValidateConfig(home, packageRoot2) {
|
|
31917
31857
|
return loadPublicCliConfig(home).then((config) => {
|
|
31918
31858
|
try {
|
|
@@ -32358,7 +32298,7 @@ async function runAkRole(argv2, env) {
|
|
|
32358
32298
|
throw new CliUsageError("roles takes no arguments");
|
|
32359
32299
|
}
|
|
32360
32300
|
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
32361
|
-
const credentials = env.credentials ?? await loadCredentialProviders(
|
|
32301
|
+
const credentials = env.credentials ?? await loadCredentialProviders(resolvePublicAgentDir(env.agentDir, home));
|
|
32362
32302
|
const seats = effectiveSeatConfigurations(
|
|
32363
32303
|
config,
|
|
32364
32304
|
credentials,
|
|
@@ -32398,16 +32338,13 @@ async function runAkRole(argv2, env) {
|
|
|
32398
32338
|
runId: resumeRequest.runId,
|
|
32399
32339
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
32400
32340
|
};
|
|
32401
|
-
const
|
|
32402
|
-
const cwd = env.cwd ?? process.cwd();
|
|
32403
|
-
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
32404
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
32341
|
+
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
32405
32342
|
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
|
|
32406
32343
|
const seatRole = resumeRole ?? "judge";
|
|
32407
32344
|
const seat = resolveEffectiveSeat(
|
|
32408
|
-
config,
|
|
32345
|
+
parts.config,
|
|
32409
32346
|
seatRole,
|
|
32410
|
-
credentials,
|
|
32347
|
+
parts.credentials,
|
|
32411
32348
|
invocationFromParsed(parsed)
|
|
32412
32349
|
);
|
|
32413
32350
|
const result = await runPublicInstructionSeatResume(
|
|
@@ -32415,11 +32352,11 @@ async function runAkRole(argv2, env) {
|
|
|
32415
32352
|
createRoleEnvironment(env, {
|
|
32416
32353
|
role: seatRole,
|
|
32417
32354
|
home,
|
|
32418
|
-
agentDir,
|
|
32419
|
-
cwd,
|
|
32420
|
-
credentials,
|
|
32355
|
+
agentDir: parts.agentDir,
|
|
32356
|
+
cwd: parts.cwd,
|
|
32357
|
+
credentials: parts.credentials,
|
|
32421
32358
|
seat,
|
|
32422
|
-
config
|
|
32359
|
+
config: parts.config
|
|
32423
32360
|
}),
|
|
32424
32361
|
io
|
|
32425
32362
|
);
|
|
@@ -32433,15 +32370,20 @@ async function runAkRole(argv2, env) {
|
|
|
32433
32370
|
};
|
|
32434
32371
|
const parentRole = await peekRoleRunRole(home, parentRunId);
|
|
32435
32372
|
if (parentRole === void 0) break;
|
|
32436
|
-
const parentSeat = resolveEffectiveSeat(
|
|
32373
|
+
const parentSeat = resolveEffectiveSeat(
|
|
32374
|
+
parts.config,
|
|
32375
|
+
parentRole,
|
|
32376
|
+
parts.credentials,
|
|
32377
|
+
invocationFromParsed(parsed)
|
|
32378
|
+
);
|
|
32437
32379
|
const parentEnv = createRoleEnvironment(env, {
|
|
32438
32380
|
role: parentRole,
|
|
32439
32381
|
home,
|
|
32440
|
-
agentDir,
|
|
32441
|
-
cwd,
|
|
32442
|
-
credentials,
|
|
32382
|
+
agentDir: parts.agentDir,
|
|
32383
|
+
cwd: parts.cwd,
|
|
32384
|
+
credentials: parts.credentials,
|
|
32443
32385
|
seat: parentSeat,
|
|
32444
|
-
config
|
|
32386
|
+
config: parts.config
|
|
32445
32387
|
});
|
|
32446
32388
|
current = await continueParentAfterChild(parentRunId, current.admitted, parentEnv, io);
|
|
32447
32389
|
}
|
|
@@ -32524,6 +32466,7 @@ var init_cli = __esm({
|
|
|
32524
32466
|
init_machine_method_skills();
|
|
32525
32467
|
init_post_admission();
|
|
32526
32468
|
init_role_turn_host();
|
|
32469
|
+
init_role_seat_runtime();
|
|
32527
32470
|
init_role_turn_host_resolution();
|
|
32528
32471
|
init_invocation();
|
|
32529
32472
|
init_option_definitions();
|
|
@@ -32549,7 +32492,7 @@ var init_cli = __esm({
|
|
|
32549
32492
|
|
|
32550
32493
|
// src/public-cli/main.ts
|
|
32551
32494
|
import { existsSync as existsSync11 } from "node:fs";
|
|
32552
|
-
import { dirname as dirname23, join as
|
|
32495
|
+
import { dirname as dirname23, join as join40 } from "node:path";
|
|
32553
32496
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32554
32497
|
|
|
32555
32498
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -32638,8 +32581,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
32638
32581
|
// src/public-cli/main.ts
|
|
32639
32582
|
var here = dirname23(fileURLToPath2(import.meta.url));
|
|
32640
32583
|
function resolvePackageRoot(binDir) {
|
|
32641
|
-
const canonical =
|
|
32642
|
-
if (existsSync11(
|
|
32584
|
+
const canonical = join40(binDir, "..", "..");
|
|
32585
|
+
if (existsSync11(join40(canonical, "package.json"))) {
|
|
32643
32586
|
return canonical;
|
|
32644
32587
|
}
|
|
32645
32588
|
return binDir;
|