@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
|
@@ -280,29 +280,6 @@ function described(name, schema) {
|
|
|
280
280
|
if (typeof schema.description === "string") return schema;
|
|
281
281
|
throw new Error(`Tool field ${name} has no semantic description at its schema owner`);
|
|
282
282
|
}
|
|
283
|
-
function declarationIdentity(schema) {
|
|
284
|
-
const { description: _description, ...semantic } = schema;
|
|
285
|
-
return JSON.stringify(semantic);
|
|
286
|
-
}
|
|
287
|
-
function openToolObjectFromUnion(schema) {
|
|
288
|
-
const declarations = /* @__PURE__ */ new Map();
|
|
289
|
-
for (const variant of schema.anyOf) {
|
|
290
|
-
for (const [name, declaration] of Object.entries(variant.properties ?? {})) {
|
|
291
|
-
const entries = declarations.get(name) ?? [];
|
|
292
|
-
const identity = declarationIdentity(declaration);
|
|
293
|
-
if (!entries.some((entry) => declarationIdentity(entry) === identity)) entries.push(declaration);
|
|
294
|
-
declarations.set(name, entries);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
const properties = Object.fromEntries([...declarations].map(([name, entries]) => {
|
|
298
|
-
const descriptions = [...new Set(entries.map((entry) => entry.description).filter((value) => typeof value === "string"))].join(" ");
|
|
299
|
-
const declaration = entries.length === 1 ? entries[0] : Type3.Union(entries, descriptions === "" ? {} : { description: descriptions });
|
|
300
|
-
return [name, Type3.Optional(described(name, declaration))];
|
|
301
|
-
}));
|
|
302
|
-
const object = Type3.Object(properties, { additionalProperties: true });
|
|
303
|
-
object.required = [];
|
|
304
|
-
return object;
|
|
305
|
-
}
|
|
306
283
|
function openToolObject(schema) {
|
|
307
284
|
const object = Type3.Object(
|
|
308
285
|
Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [
|
|
@@ -414,50 +391,36 @@ import { Type as Type6 } from "typebox";
|
|
|
414
391
|
function validateFixerOutput(value, _phase) {
|
|
415
392
|
return value;
|
|
416
393
|
}
|
|
417
|
-
var FIXER_OUTPUT_TOOL_NAME,
|
|
394
|
+
var FIXER_OUTPUT_TOOL_NAME, PARTIALLY_COMPLETED_DEFINITION, FIXER_STATUS_DESCRIPTION, fixerOutputObject, fixerOutputSchema;
|
|
418
395
|
var init_fixer_output = __esm({
|
|
419
396
|
"src/package-contracts/fixer-output.ts"() {
|
|
420
397
|
"use strict";
|
|
421
398
|
init_open_tool_schema();
|
|
422
399
|
init_terminating_infrastructure();
|
|
423
400
|
FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
|
|
424
|
-
transportString = Type6.String();
|
|
425
|
-
authorityBlockerSchema = Type6.Object({ cause: Type6.Optional(Type6.Literal("authority_violation")), evidence: Type6.Optional(transportString) });
|
|
426
|
-
prerequisiteBlockerSchema = Type6.Object({ cause: Type6.Optional(Type6.Literal("prerequisite_unmet")), prerequisiteId: Type6.Optional(transportString), evidence: Type6.Optional(transportString) });
|
|
427
|
-
blockerSchema = Type6.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
|
|
428
|
-
exceptionSchema = Type6.Object({ where: Type6.Optional(transportString), reason: Type6.Optional(transportString) });
|
|
429
|
-
testEvidenceSchema = Type6.Object({
|
|
430
|
-
contract: Type6.Optional(Type6.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" })),
|
|
431
|
-
minimumNecessaryCost: Type6.Optional(Type6.String({ description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" })),
|
|
432
|
-
measuredDuration: Type6.Optional(Type6.String({ description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" }))
|
|
433
|
-
}, { description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002" });
|
|
434
|
-
completedClassResultSchema = Type6.Object({
|
|
435
|
-
name: Type6.Optional(transportString),
|
|
436
|
-
disposition: Type6.Optional(Type6.Literal("completed")),
|
|
437
|
-
searchScope: Type6.Optional(transportString),
|
|
438
|
-
exceptions: Type6.Optional(Type6.Array(exceptionSchema)),
|
|
439
|
-
commitSha: Type6.Optional(transportString)
|
|
440
|
-
});
|
|
441
|
-
refusedClassResultSchema = Type6.Object({
|
|
442
|
-
name: Type6.Optional(transportString),
|
|
443
|
-
disposition: Type6.Optional(Type6.Literal("refused")),
|
|
444
|
-
remainingScope: Type6.Optional(transportString),
|
|
445
|
-
blocker: Type6.Optional(blockerSchema)
|
|
446
|
-
});
|
|
447
|
-
classResultSchema = Type6.Union([completedClassResultSchema, refusedClassResultSchema]);
|
|
448
|
-
completedClassResultsSchema = Type6.Array(completedClassResultSchema);
|
|
449
401
|
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";
|
|
450
402
|
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}`;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
403
|
+
fixerOutputObject = Type6.Object({
|
|
404
|
+
status: Type6.Unknown({ description: FIXER_STATUS_DESCRIPTION }),
|
|
405
|
+
report: Type6.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
406
|
+
remainingScope: Type6.Unknown({
|
|
407
|
+
description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C\uFF1B\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u8303\u56F4\u4E5F\u5199\u6B64\u5904\u3002"
|
|
408
|
+
}),
|
|
409
|
+
blocker: Type6.Unknown({
|
|
410
|
+
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"
|
|
411
|
+
}),
|
|
412
|
+
reason: Type6.Unknown({
|
|
413
|
+
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"
|
|
414
|
+
}),
|
|
415
|
+
classResults: Type6.Unknown({
|
|
416
|
+
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"
|
|
417
|
+
}),
|
|
418
|
+
testEvidence: Type6.Unknown({
|
|
419
|
+
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"
|
|
420
|
+
})
|
|
421
|
+
});
|
|
459
422
|
fixerOutputSchema = withTerminatingOutputDeclarations(
|
|
460
|
-
|
|
423
|
+
openToolObject(fixerOutputObject)
|
|
461
424
|
);
|
|
462
425
|
}
|
|
463
426
|
});
|
|
@@ -575,7 +538,7 @@ function validateDoctorSubmissionShape(value) {
|
|
|
575
538
|
function validateDoctorOutput(value, _patient, _store) {
|
|
576
539
|
return validateDoctorSubmissionShape(value);
|
|
577
540
|
}
|
|
578
|
-
var DOCTOR_EVIDENCE_TOOL_NAME, DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_AUDIT_TOOL_NAME, DOCTOR_OUTPUT_TOOL_DESCRIPTION, DOCTOR_TARGET_KINDS,
|
|
541
|
+
var DOCTOR_EVIDENCE_TOOL_NAME, DOCTOR_OUTPUT_TOOL_NAME, DOCTOR_AUDIT_TOOL_NAME, DOCTOR_OUTPUT_TOOL_DESCRIPTION, DOCTOR_TARGET_KINDS, DOCTOR_DISPOSITIONS, DOCTOR_PRESCRIPTION_KINDS, biteActual, biteNone, DOCTOR_BITE_KINDS, DOCTOR_STATUS_DESCRIPTION, doctorSubmissionObject, doctorSubmissionSchema, doctorEvidenceReadSchema, DoctorEvidenceStore;
|
|
579
542
|
var init_doctor_contracts = __esm({
|
|
580
543
|
"src/doctor-contracts.ts"() {
|
|
581
544
|
"use strict";
|
|
@@ -587,41 +550,29 @@ var init_doctor_contracts = __esm({
|
|
|
587
550
|
DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
|
|
588
551
|
DOCTOR_OUTPUT_TOOL_DESCRIPTION = "\u63D0\u4EA4\u552F\u4E00\u7EC8\u5C40\u5355\u6848\u8BC1\u8BCD\uFF1Bcompleted \u5141\u8BB8\u7A7A findings\u3002";
|
|
589
552
|
DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
Type8.Object({ kind: Type8.Optional(Type8.Literal("noRealBite")), targetKey: nonblank, eligibleEvidenceIds: evidenceIds }, { additionalProperties: true })
|
|
596
|
-
]);
|
|
597
|
-
assetKinds = DOCTOR_TARGET_KINDS;
|
|
598
|
-
findingBody = {
|
|
599
|
-
evidenceIds,
|
|
600
|
-
disposition: Type8.Optional(Type8.Union([Type8.Literal("keep"), Type8.Literal("thin"), Type8.Literal("delete")])),
|
|
601
|
-
guardrails: Type8.Optional(Type8.Object({ reproducibleFailure: guardrail, owningSeamOrInvariant: guardrail, deletionOrSimplificationSuffices: guardrail }, { additionalProperties: true })),
|
|
602
|
-
prescription: Type8.Optional(Type8.Object({ kind: Type8.Optional(Type8.Union([Type8.Literal("retain"), Type8.Literal("delete"), Type8.Literal("simplify"), Type8.Literal("patch"), Type8.Literal("addMechanism")])), recommendation: nonblank, necessityExplanation: nonblank }, { additionalProperties: true })),
|
|
603
|
-
lastRealBite: Type8.Optional(lastRealBite)
|
|
604
|
-
};
|
|
605
|
-
finding = Type8.Union([
|
|
606
|
-
Type8.Object({ targetKey: nonblank, observation: nonblank, evidenceIds }, { additionalProperties: true }),
|
|
607
|
-
Type8.Object({ targetKey: nonblank, targetKind: Type8.Optional(Type8.Union(assetKinds.map((kind) => Type8.Literal(kind)))), assetEvidence: Type8.Optional(Type8.Object({ targetKey: nonblank, targetKind: Type8.Optional(Type8.Union(assetKinds.map((kind) => Type8.Literal(kind)))), evidenceId: nonblank }, { additionalProperties: true })), ...findingBody }, { additionalProperties: true })
|
|
608
|
-
]);
|
|
609
|
-
caseIdentity = Type8.Object({ issueNumber: Type8.Optional(Type8.Integer()), runsPath: nonblank }, { additionalProperties: true });
|
|
553
|
+
DOCTOR_DISPOSITIONS = ["keep", "thin", "delete"];
|
|
554
|
+
DOCTOR_PRESCRIPTION_KINDS = ["retain", "delete", "simplify", "patch", "addMechanism"];
|
|
555
|
+
biteActual = "actual";
|
|
556
|
+
biteNone = "noRealBite";
|
|
557
|
+
DOCTOR_BITE_KINDS = [biteActual, biteNone];
|
|
610
558
|
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";
|
|
611
|
-
|
|
612
|
-
Type8.
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
},
|
|
622
|
-
|
|
559
|
+
doctorSubmissionObject = Type8.Object({
|
|
560
|
+
status: Type8.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
|
|
561
|
+
case: Type8.Unknown({
|
|
562
|
+
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"
|
|
563
|
+
}),
|
|
564
|
+
findings: Type8.Unknown({
|
|
565
|
+
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`
|
|
566
|
+
}),
|
|
567
|
+
reason: Type8.Unknown({
|
|
568
|
+
description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0\uFF1B\u4EC5 refused \u65F6\u7528\u3002"
|
|
569
|
+
}),
|
|
570
|
+
missingEvidence: Type8.Unknown({
|
|
571
|
+
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"
|
|
572
|
+
})
|
|
573
|
+
});
|
|
623
574
|
doctorSubmissionSchema = withTerminatingOutputDeclarations(
|
|
624
|
-
|
|
575
|
+
openToolObject(doctorSubmissionObject)
|
|
625
576
|
);
|
|
626
577
|
doctorEvidenceReadSchema = Type8.Object({ evidenceId: Type8.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: Type8.Optional(Type8.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: Type8.Optional(Type8.Integer({ minimum: 1, description: "\u8FD4\u56DE\u5B57\u8282\u6570\uFF08\u65E0\u4E0A\u9650\uFF09" })) }, { additionalProperties: true });
|
|
627
578
|
DoctorEvidenceStore = class {
|
|
@@ -715,7 +666,7 @@ function validateMergerInput(value) {
|
|
|
715
666
|
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) : [];
|
|
716
667
|
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 }));
|
|
717
668
|
}
|
|
718
|
-
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION,
|
|
669
|
+
var materialSchema, checkSchema, mergerInputSchema, MERGER_STATUS_DESCRIPTION, mergerOutputObject, mergerOutputSchema, MERGER_OUTPUT_TOOL_NAME, record, blank, MergerInputContractError, asString, asStringArray;
|
|
719
670
|
var init_merger_contracts = __esm({
|
|
720
671
|
"src/merger-contracts.ts"() {
|
|
721
672
|
"use strict";
|
|
@@ -734,11 +685,16 @@ var init_merger_contracts = __esm({
|
|
|
734
685
|
authorizedChecks: Type9.Array(checkSchema)
|
|
735
686
|
}, { additionalProperties: false });
|
|
736
687
|
MERGER_STATUS_DESCRIPTION = "completed | escalate";
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
688
|
+
mergerOutputObject = Type9.Object({
|
|
689
|
+
status: Type9.Unknown({ description: MERGER_STATUS_DESCRIPTION }),
|
|
690
|
+
attemptId: Type9.Unknown({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }),
|
|
691
|
+
report: Type9.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
692
|
+
mergeCommitId: Type9.Unknown({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }),
|
|
693
|
+
diagnosis: Type9.Unknown({
|
|
694
|
+
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"
|
|
695
|
+
})
|
|
696
|
+
});
|
|
697
|
+
mergerOutputSchema = withTerminatingOutputDeclarations(openToolObject(mergerOutputObject));
|
|
742
698
|
MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
|
|
743
699
|
record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
744
700
|
blank = (v) => typeof v !== "string" || v.trim().length === 0;
|
|
@@ -3044,6 +3000,7 @@ __export(config_exports, {
|
|
|
3044
3000
|
providerConfigured: () => providerConfigured,
|
|
3045
3001
|
publicCliConfigPath: () => publicCliConfigPath,
|
|
3046
3002
|
resolveEffectiveSeat: () => resolveEffectiveSeat,
|
|
3003
|
+
resolvePublicAgentDir: () => resolvePublicAgentDir,
|
|
3047
3004
|
resolvedSeatWithModel: () => resolvedSeatWithModel,
|
|
3048
3005
|
savePublicCliConfig: () => savePublicCliConfig,
|
|
3049
3006
|
setAutoResumeLimit: () => setAutoResumeLimit,
|
|
@@ -3523,6 +3480,9 @@ function credentialProvidersFromAuthData(data) {
|
|
|
3523
3480
|
xai: Object.prototype.hasOwnProperty.call(record4, "xai")
|
|
3524
3481
|
};
|
|
3525
3482
|
}
|
|
3483
|
+
function resolvePublicAgentDir(explicit, home) {
|
|
3484
|
+
return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join6(home, ".pi", "agent");
|
|
3485
|
+
}
|
|
3526
3486
|
async function loadCredentialProviders(agentDir) {
|
|
3527
3487
|
try {
|
|
3528
3488
|
const raw = await readFile4(join6(agentDir, "auth.json"), "utf8");
|
|
@@ -3683,6 +3643,9 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
3683
3643
|
function roleRunArtifactsDirectory(runDirectory) {
|
|
3684
3644
|
return join9(runDirectory, "artifacts");
|
|
3685
3645
|
}
|
|
3646
|
+
function isUnboundRunDirectory(runDirectory) {
|
|
3647
|
+
return runDirectory.replaceAll("\\", "/").includes("/unbound/runs/");
|
|
3648
|
+
}
|
|
3686
3649
|
function ensureRoleRunDirectory(ledgerHome, directory) {
|
|
3687
3650
|
return ensureRealDirectoryTree(ledgerHome, directory);
|
|
3688
3651
|
}
|
|
@@ -5023,6 +4986,170 @@ var init_role_turn_host = __esm({
|
|
|
5023
4986
|
}
|
|
5024
4987
|
});
|
|
5025
4988
|
|
|
4989
|
+
// src/public-cli/host-providers.ts
|
|
4990
|
+
import { readFileSync } from "node:fs";
|
|
4991
|
+
import { join as join16 } from "node:path";
|
|
4992
|
+
function hostProvidersPath(home) {
|
|
4993
|
+
if (typeof home !== "string" || home.trim() === "") {
|
|
4994
|
+
throw new Error("home must be explicitly provided");
|
|
4995
|
+
}
|
|
4996
|
+
return join16(home, ".ak-roles", "host-providers.json");
|
|
4997
|
+
}
|
|
4998
|
+
function hermesProviderModelsCachePath(home) {
|
|
4999
|
+
return join16(home, ".hermes", "provider_models_cache.json");
|
|
5000
|
+
}
|
|
5001
|
+
function parseHostProvidersTable(value) {
|
|
5002
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
5003
|
+
throw new Error("host-providers.json must be an object");
|
|
5004
|
+
}
|
|
5005
|
+
const out = {};
|
|
5006
|
+
for (const [host, byProvider] of Object.entries(value)) {
|
|
5007
|
+
if (host.trim() === "") {
|
|
5008
|
+
throw new Error("host-providers.json host key must be non-empty");
|
|
5009
|
+
}
|
|
5010
|
+
if (byProvider === null || typeof byProvider !== "object" || Array.isArray(byProvider)) {
|
|
5011
|
+
throw new Error(`host-providers.json[${host}] must be an object`);
|
|
5012
|
+
}
|
|
5013
|
+
const providers = {};
|
|
5014
|
+
for (const [seatProvider, hostProvider] of Object.entries(
|
|
5015
|
+
byProvider
|
|
5016
|
+
)) {
|
|
5017
|
+
if (seatProvider.trim() === "") {
|
|
5018
|
+
throw new Error(
|
|
5019
|
+
`host-providers.json[${host}] seat-provider key must be non-empty`
|
|
5020
|
+
);
|
|
5021
|
+
}
|
|
5022
|
+
if (typeof hostProvider !== "string" || hostProvider.trim() === "") {
|
|
5023
|
+
throw new Error(
|
|
5024
|
+
`host-providers.json[${host}][${seatProvider}] must be a non-empty string`
|
|
5025
|
+
);
|
|
5026
|
+
}
|
|
5027
|
+
providers[seatProvider] = hostProvider;
|
|
5028
|
+
}
|
|
5029
|
+
if (Object.keys(providers).length > 0) {
|
|
5030
|
+
out[host] = providers;
|
|
5031
|
+
}
|
|
5032
|
+
}
|
|
5033
|
+
return out;
|
|
5034
|
+
}
|
|
5035
|
+
function loadHostProvidersTable(home) {
|
|
5036
|
+
const path = hostProvidersPath(home);
|
|
5037
|
+
try {
|
|
5038
|
+
const raw = readFileSync(path, "utf8");
|
|
5039
|
+
return parseHostProvidersTable(JSON.parse(raw));
|
|
5040
|
+
} catch (error) {
|
|
5041
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
5042
|
+
return {};
|
|
5043
|
+
}
|
|
5044
|
+
throw error;
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
function hostCatalogOffersModel(catalogModels, seatModel) {
|
|
5048
|
+
return catalogModels.some(
|
|
5049
|
+
(entry) => entry === seatModel || entry.endsWith(`/${seatModel}`)
|
|
5050
|
+
);
|
|
5051
|
+
}
|
|
5052
|
+
function listHermesProvidersForModel(home, seatModel) {
|
|
5053
|
+
const path = hermesProviderModelsCachePath(home);
|
|
5054
|
+
let text;
|
|
5055
|
+
try {
|
|
5056
|
+
text = readFileSync(path, "utf8");
|
|
5057
|
+
} catch (error) {
|
|
5058
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
5059
|
+
return [];
|
|
5060
|
+
}
|
|
5061
|
+
throw error;
|
|
5062
|
+
}
|
|
5063
|
+
const raw = JSON.parse(text);
|
|
5064
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
5065
|
+
throw new Error(
|
|
5066
|
+
`hermes provider_models_cache.json must be an object: ${path}`
|
|
5067
|
+
);
|
|
5068
|
+
}
|
|
5069
|
+
const found = [];
|
|
5070
|
+
for (const [provider, entry] of Object.entries(raw)) {
|
|
5071
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
|
5072
|
+
continue;
|
|
5073
|
+
}
|
|
5074
|
+
const models = entry.models;
|
|
5075
|
+
if (!Array.isArray(models)) continue;
|
|
5076
|
+
const names = models.filter((m) => typeof m === "string");
|
|
5077
|
+
if (hostCatalogOffersModel(names, seatModel)) {
|
|
5078
|
+
found.push(provider);
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
return found.sort();
|
|
5082
|
+
}
|
|
5083
|
+
function listDirectoryProvidersForModel(home, host, seatModel) {
|
|
5084
|
+
if (host === "hermes") {
|
|
5085
|
+
return listHermesProvidersForModel(home, seatModel);
|
|
5086
|
+
}
|
|
5087
|
+
return void 0;
|
|
5088
|
+
}
|
|
5089
|
+
function projectHostFacingProvider(selection, host, table, home) {
|
|
5090
|
+
if (selection === void 0) return void 0;
|
|
5091
|
+
const mapped = table[host]?.[selection.provider];
|
|
5092
|
+
if (mapped !== void 0) {
|
|
5093
|
+
return mapped === selection.provider ? selection : { ...selection, provider: mapped };
|
|
5094
|
+
}
|
|
5095
|
+
const directory = listDirectoryProvidersForModel(home, host, selection.model);
|
|
5096
|
+
if (directory === void 0) {
|
|
5097
|
+
return selection;
|
|
5098
|
+
}
|
|
5099
|
+
if (directory.length === 1) {
|
|
5100
|
+
const only = directory[0];
|
|
5101
|
+
return only === selection.provider ? selection : { ...selection, provider: only };
|
|
5102
|
+
}
|
|
5103
|
+
if (directory.length === 0) {
|
|
5104
|
+
throw new HostProviderResolutionError({
|
|
5105
|
+
message: `host ${host} has no provider offering model ${selection.model}; seat provider was ${selection.provider}`,
|
|
5106
|
+
host,
|
|
5107
|
+
seatProvider: selection.provider,
|
|
5108
|
+
seatModel: selection.model
|
|
5109
|
+
});
|
|
5110
|
+
}
|
|
5111
|
+
throw new HostProviderResolutionError({
|
|
5112
|
+
message: `host ${host} has multiple providers for model ${selection.model}: ${directory.join(", ")}; set host-providers.json[${host}][${selection.provider}] to one of them`,
|
|
5113
|
+
host,
|
|
5114
|
+
seatProvider: selection.provider,
|
|
5115
|
+
seatModel: selection.model,
|
|
5116
|
+
candidates: directory
|
|
5117
|
+
});
|
|
5118
|
+
}
|
|
5119
|
+
function renderHostProvidersTable(table) {
|
|
5120
|
+
const lines = [];
|
|
5121
|
+
for (const host of Object.keys(table).sort()) {
|
|
5122
|
+
const byProvider = table[host];
|
|
5123
|
+
for (const seatProvider of Object.keys(byProvider).sort()) {
|
|
5124
|
+
lines.push(
|
|
5125
|
+
`hostProvider ${host} ${seatProvider} ${byProvider[seatProvider]}`
|
|
5126
|
+
);
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
return lines.length === 0 ? "" : `${lines.join("\n")}
|
|
5130
|
+
`;
|
|
5131
|
+
}
|
|
5132
|
+
var HostProviderResolutionError;
|
|
5133
|
+
var init_host_providers = __esm({
|
|
5134
|
+
"src/public-cli/host-providers.ts"() {
|
|
5135
|
+
"use strict";
|
|
5136
|
+
HostProviderResolutionError = class extends Error {
|
|
5137
|
+
host;
|
|
5138
|
+
seatProvider;
|
|
5139
|
+
seatModel;
|
|
5140
|
+
candidates;
|
|
5141
|
+
constructor(options) {
|
|
5142
|
+
super(options.message);
|
|
5143
|
+
this.name = "HostProviderResolutionError";
|
|
5144
|
+
this.host = options.host;
|
|
5145
|
+
this.seatProvider = options.seatProvider;
|
|
5146
|
+
this.seatModel = options.seatModel;
|
|
5147
|
+
this.candidates = options.candidates ?? [];
|
|
5148
|
+
}
|
|
5149
|
+
};
|
|
5150
|
+
}
|
|
5151
|
+
});
|
|
5152
|
+
|
|
5026
5153
|
// src/public-cli/github-remote.ts
|
|
5027
5154
|
function ownerRepoFromGitHubRemoteUrl(remoteUrl) {
|
|
5028
5155
|
const trimmed = remoteUrl.trim();
|
|
@@ -5486,13 +5613,13 @@ var init_session_dialogue = __esm({
|
|
|
5486
5613
|
|
|
5487
5614
|
// src/ticket-provenance.ts
|
|
5488
5615
|
import { readFile as readFile12, unlink as unlink2 } from "node:fs/promises";
|
|
5489
|
-
import { basename as basename5, dirname as dirname11, join as
|
|
5616
|
+
import { basename as basename5, dirname as dirname11, join as join17, resolve as resolve9 } from "node:path";
|
|
5490
5617
|
function dialogueSessionSourceRoots(home) {
|
|
5491
5618
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
5492
5619
|
return [
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5620
|
+
join17(machineHome, ".claude", "projects"),
|
|
5621
|
+
join17(machineHome, ".codex", "sessions"),
|
|
5622
|
+
join17(machineHome, ".pi", "agent", "sessions")
|
|
5496
5623
|
];
|
|
5497
5624
|
}
|
|
5498
5625
|
function isLedgerRoleSessionFile(absolute, home) {
|
|
@@ -5530,7 +5657,7 @@ function ticketProvenanceRecordInput(ticketNumber, cwd, home, runDirectory) {
|
|
|
5530
5657
|
};
|
|
5531
5658
|
}
|
|
5532
5659
|
async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, home) {
|
|
5533
|
-
const source =
|
|
5660
|
+
const source = join17(runDirectory, "records.jsonl");
|
|
5534
5661
|
let content;
|
|
5535
5662
|
try {
|
|
5536
5663
|
content = await readFile12(source, "utf8");
|
|
@@ -5715,7 +5842,7 @@ var init_ticket_provenance = __esm({
|
|
|
5715
5842
|
});
|
|
5716
5843
|
|
|
5717
5844
|
// src/notary-source-run.ts
|
|
5718
|
-
import { dirname as dirname12, isAbsolute as isAbsolute5, join as
|
|
5845
|
+
import { dirname as dirname12, isAbsolute as isAbsolute5, join as join18, resolve as resolve10, basename as basename6 } from "node:path";
|
|
5719
5846
|
import { lstat, realpath as realpath3 } from "node:fs/promises";
|
|
5720
5847
|
async function readRetainedIdentity(runDirectory) {
|
|
5721
5848
|
try {
|
|
@@ -5772,11 +5899,11 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5772
5899
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
5773
5900
|
const bookKey = resolveBookKeyFromGit(options.projectRoot);
|
|
5774
5901
|
const bookDirectory = activationBookDirectory(ledgerHome, bookKey);
|
|
5775
|
-
const bookRunsRoot =
|
|
5902
|
+
const bookRunsRoot = join18(bookDirectory, "runs");
|
|
5776
5903
|
let candidate;
|
|
5777
5904
|
const bare = parseRunDirectoryName(raw);
|
|
5778
5905
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
5779
|
-
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ??
|
|
5906
|
+
candidate = await findRunDirectoryById(options.home, bare.runId, bookKey, bare.role) ?? join18(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
5780
5907
|
} else {
|
|
5781
5908
|
candidate = isAbsolute5(raw) ? raw : resolve10(options.projectRoot, raw);
|
|
5782
5909
|
const identity2 = parseRunDirectoryName(basename6(candidate));
|
|
@@ -6917,7 +7044,7 @@ import {
|
|
|
6917
7044
|
writeFile as writeFile4
|
|
6918
7045
|
} from "node:fs/promises";
|
|
6919
7046
|
import { tmpdir } from "node:os";
|
|
6920
|
-
import { basename as basename7, dirname as dirname13, isAbsolute as isAbsolute6, join as
|
|
7047
|
+
import { basename as basename7, dirname as dirname13, isAbsolute as isAbsolute6, join as join19, resolve as resolve11, sep as sep3 } from "node:path";
|
|
6921
7048
|
function issueAdmissionPlacement(authority, request) {
|
|
6922
7049
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
6923
7050
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -6971,81 +7098,71 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
6971
7098
|
...effectiveModelLedgerFields(effectiveModel)
|
|
6972
7099
|
};
|
|
6973
7100
|
await writeFile4(
|
|
6974
|
-
|
|
7101
|
+
join19(source.runDirectory, "invocation.json"),
|
|
6975
7102
|
`${JSON.stringify(identity, null, 2)}
|
|
6976
7103
|
`,
|
|
6977
7104
|
"utf8"
|
|
6978
7105
|
);
|
|
6979
7106
|
}
|
|
6980
7107
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
7108
|
+
await updateDurableJsonPage(join19(runDirectory, "invocation.json"), (current) => {
|
|
7109
|
+
const next = { ...current };
|
|
7110
|
+
if (model !== void 0) {
|
|
7111
|
+
next.provider = model.provider;
|
|
7112
|
+
next.model = model.model;
|
|
7113
|
+
if (model.thinking === void 0) {
|
|
7114
|
+
delete next.thinking;
|
|
7115
|
+
} else {
|
|
7116
|
+
next.thinking = model.thinking;
|
|
7117
|
+
}
|
|
6991
7118
|
}
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
);
|
|
7119
|
+
if (engine === null) {
|
|
7120
|
+
delete next.engine;
|
|
7121
|
+
} else if (engine !== void 0) {
|
|
7122
|
+
next.engine = engine;
|
|
7123
|
+
}
|
|
7124
|
+
if (engineModel === null) {
|
|
7125
|
+
delete next.engineModel;
|
|
7126
|
+
} else if (engineModel !== void 0) {
|
|
7127
|
+
next.engineModel = engineModel;
|
|
7128
|
+
}
|
|
7129
|
+
if (host !== void 0) {
|
|
7130
|
+
next.host = host;
|
|
7131
|
+
}
|
|
7132
|
+
return next;
|
|
7133
|
+
});
|
|
7134
|
+
}
|
|
7135
|
+
async function updateDurableJsonPage(path, update) {
|
|
7136
|
+
const current = JSON.parse(await readFile13(path, "utf8"));
|
|
7137
|
+
const next = update(current);
|
|
7138
|
+
if (next === void 0) return;
|
|
7139
|
+
await writeFile4(path, `${JSON.stringify(next, null, 2)}
|
|
7140
|
+
`, "utf8");
|
|
7012
7141
|
}
|
|
7013
7142
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
`${JSON.stringify({
|
|
7019
|
-
...current,
|
|
7020
|
-
...fields
|
|
7021
|
-
}, null, 2)}
|
|
7022
|
-
`,
|
|
7023
|
-
"utf8"
|
|
7024
|
-
);
|
|
7143
|
+
await updateDurableJsonPage(join19(runDirectory, "invocation.json"), (current) => ({
|
|
7144
|
+
...current,
|
|
7145
|
+
...fields
|
|
7146
|
+
}));
|
|
7025
7147
|
}
|
|
7026
7148
|
async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
|
|
7027
7149
|
if (sourceRunPath.trim() === "") {
|
|
7028
7150
|
throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
|
|
7029
7151
|
}
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
await writeFile4(
|
|
7040
|
-
admittedPath,
|
|
7041
|
-
`${JSON.stringify({
|
|
7152
|
+
await updateDurableJsonPage(admitted.admittedRequestPath, (current) => {
|
|
7153
|
+
if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
7154
|
+
throw new Error(
|
|
7155
|
+
`persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
7156
|
+
);
|
|
7157
|
+
}
|
|
7158
|
+
const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
|
|
7159
|
+
if (current.sourceRunPath === sourceRunPath && sameSubject) return void 0;
|
|
7160
|
+
return {
|
|
7042
7161
|
...current,
|
|
7043
7162
|
sourceRunPath,
|
|
7044
7163
|
...auditorSubject === void 0 ? {} : { auditorSubject }
|
|
7045
|
-
}
|
|
7046
|
-
|
|
7047
|
-
"utf8"
|
|
7048
|
-
);
|
|
7164
|
+
};
|
|
7165
|
+
});
|
|
7049
7166
|
}
|
|
7050
7167
|
async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
7051
7168
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
@@ -7053,22 +7170,17 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
7053
7170
|
admitted.ticketNumber = ticketNumber;
|
|
7054
7171
|
}
|
|
7055
7172
|
async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
admitted.admittedRequestPath,
|
|
7068
|
-
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
7069
|
-
`,
|
|
7070
|
-
"utf8"
|
|
7071
|
-
);
|
|
7173
|
+
let correlationIds = [];
|
|
7174
|
+
await updateDurableJsonPage(admitted.admittedRequestPath, (current) => {
|
|
7175
|
+
const prior = [
|
|
7176
|
+
...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
|
|
7177
|
+
(value) => typeof value === "string" && value.trim() !== ""
|
|
7178
|
+
) : [],
|
|
7179
|
+
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
7180
|
+
];
|
|
7181
|
+
correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
7182
|
+
return { ...current, correlationId, correlationIds };
|
|
7183
|
+
});
|
|
7072
7184
|
await mergeInvocationIdentityPage(admitted.runDirectory, {
|
|
7073
7185
|
correlationId,
|
|
7074
7186
|
correlationIds
|
|
@@ -7078,7 +7190,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
7078
7190
|
mutable.correlationIds = correlationIds;
|
|
7079
7191
|
}
|
|
7080
7192
|
async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
7081
|
-
if (admitted.ticketNumber === void 0 || !admitted.runDirectory
|
|
7193
|
+
if (admitted.ticketNumber === void 0 || !isUnboundRunDirectory(admitted.runDirectory)) return void 0;
|
|
7082
7194
|
const oldRunDirectory = admitted.runDirectory;
|
|
7083
7195
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
|
|
7084
7196
|
const target = roleRunPlacement(ledgerHome, {
|
|
@@ -7094,7 +7206,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
7094
7206
|
const childRunIds = parentPage.childDiaristRunIds;
|
|
7095
7207
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
7096
7208
|
if (typeof childRunId !== "string") continue;
|
|
7097
|
-
const childDirectory =
|
|
7209
|
+
const childDirectory = join19(dirname13(oldRunDirectory), `${childRunId}@diarist`);
|
|
7098
7210
|
if (!existsSync4(childDirectory)) continue;
|
|
7099
7211
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
7100
7212
|
bookKey: admitted.bookKey,
|
|
@@ -7140,26 +7252,27 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
7140
7252
|
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
7141
7253
|
}
|
|
7142
7254
|
async function recordChildDiaristRun(parent, childRunId) {
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7255
|
+
await updateDurableJsonPage(parent.admittedRequestPath, (page) => {
|
|
7256
|
+
const existing = Array.isArray(page.childDiaristRunIds) ? page.childDiaristRunIds.filter((runId) => typeof runId === "string") : [];
|
|
7257
|
+
const childDiaristRunIds = existing.includes(childRunId) ? existing : [...existing, childRunId];
|
|
7258
|
+
return { ...page, childDiaristRunIds };
|
|
7259
|
+
});
|
|
7148
7260
|
}
|
|
7149
7261
|
async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
7150
7262
|
requireSafePositiveTicketNumber(
|
|
7151
7263
|
ticketNumber,
|
|
7152
7264
|
"bindTicketNumberOnRunDirectory"
|
|
7153
7265
|
);
|
|
7154
|
-
const admittedPath =
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
);
|
|
7266
|
+
const admittedPath = join19(runDirectory, "admitted-request.json");
|
|
7267
|
+
let unchanged = false;
|
|
7268
|
+
await updateDurableJsonPage(admittedPath, (admitted) => {
|
|
7269
|
+
if (admitted.ticketNumber === ticketNumber) {
|
|
7270
|
+
unchanged = true;
|
|
7271
|
+
return void 0;
|
|
7272
|
+
}
|
|
7273
|
+
return { ...admitted, ticketNumber };
|
|
7274
|
+
});
|
|
7275
|
+
if (unchanged) return;
|
|
7163
7276
|
await mergeInvocationIdentityPage(runDirectory, { ticketNumber });
|
|
7164
7277
|
}
|
|
7165
7278
|
async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
@@ -7171,7 +7284,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
7171
7284
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
7172
7285
|
const rolePackageRoot = packageRoot;
|
|
7173
7286
|
const raw = JSON.parse(
|
|
7174
|
-
await readFile13(
|
|
7287
|
+
await readFile13(join19(rolePackageRoot, "package.json"), "utf8")
|
|
7175
7288
|
);
|
|
7176
7289
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
7177
7290
|
throw new Error(
|
|
@@ -7381,18 +7494,22 @@ function requireOptionPath(flag, value) {
|
|
|
7381
7494
|
}
|
|
7382
7495
|
return value;
|
|
7383
7496
|
}
|
|
7497
|
+
function skillArgTokenFault(value) {
|
|
7498
|
+
if (value === void 0 || value.trim() === "") return "empty";
|
|
7499
|
+
if (/\s/.test(value)) return "whitespace";
|
|
7500
|
+
if (value.startsWith("-")) return "optionLike";
|
|
7501
|
+
return void 0;
|
|
7502
|
+
}
|
|
7384
7503
|
function requireSkillArgToken(value, messages) {
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
}
|
|
7388
|
-
if (/\s/.test(value)) {
|
|
7389
|
-
throw new CliUsageError(messages.whitespace);
|
|
7390
|
-
}
|
|
7391
|
-
if (value.startsWith("-")) {
|
|
7392
|
-
throw new CliUsageError(messages.optionLike);
|
|
7393
|
-
}
|
|
7504
|
+
const fault = skillArgTokenFault(value);
|
|
7505
|
+
if (fault !== void 0) throw new CliUsageError(messages[fault]);
|
|
7394
7506
|
return value;
|
|
7395
7507
|
}
|
|
7508
|
+
function admittedReviewerBaseFault(value) {
|
|
7509
|
+
const fault = skillArgTokenFault(value);
|
|
7510
|
+
if (fault === void 0) return void 0;
|
|
7511
|
+
return fault === "empty" ? "missing" : "damaged";
|
|
7512
|
+
}
|
|
7396
7513
|
function requireReviewerBaseRevision(value) {
|
|
7397
7514
|
return requireSkillArgToken(value, {
|
|
7398
7515
|
empty: "--base requires a nonempty revision",
|
|
@@ -7459,13 +7576,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
|
7459
7576
|
}
|
|
7460
7577
|
async function withPreparedAttachments(attachmentPaths, use) {
|
|
7461
7578
|
if (attachmentPaths.length === 0) return await use([]);
|
|
7462
|
-
const stagingDirectory = await mkdtemp(
|
|
7579
|
+
const stagingDirectory = await mkdtemp(join19(tmpdir(), "ak-role-attachments-"));
|
|
7463
7580
|
const prepared = [];
|
|
7464
7581
|
let result;
|
|
7465
7582
|
try {
|
|
7466
7583
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
7467
7584
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
7468
|
-
const snapshotPath =
|
|
7585
|
+
const snapshotPath = join19(stagingDirectory, String(index).padStart(6, "0"));
|
|
7469
7586
|
await writeFile4(snapshotPath, bytes);
|
|
7470
7587
|
prepared.push({ absolute, snapshotPath });
|
|
7471
7588
|
}
|
|
@@ -7486,7 +7603,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
7486
7603
|
return result;
|
|
7487
7604
|
}
|
|
7488
7605
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
7489
|
-
const frozenPath =
|
|
7606
|
+
const frozenPath = join19(
|
|
7490
7607
|
destinationDir,
|
|
7491
7608
|
`${String(index).padStart(2, "0")}-${basename7(provenancePath)}`
|
|
7492
7609
|
);
|
|
@@ -7529,14 +7646,14 @@ async function freezeAttachments(attachmentPaths, attachmentsDirectory) {
|
|
|
7529
7646
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
7530
7647
|
if (attachmentPaths.length === 0) return [];
|
|
7531
7648
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7532
|
-
const attachmentsDirectory =
|
|
7649
|
+
const attachmentsDirectory = join19(runDirectory, "attachments", summonsKey);
|
|
7533
7650
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7534
7651
|
return freezeAttachments(attachmentPaths, attachmentsDirectory);
|
|
7535
7652
|
}
|
|
7536
7653
|
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
7537
7654
|
if (prepared.length === 0) return [];
|
|
7538
7655
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7539
|
-
const attachmentsDirectory = summonsKey === void 0 ?
|
|
7656
|
+
const attachmentsDirectory = summonsKey === void 0 ? join19(runDirectory, "attachments") : join19(runDirectory, "attachments", summonsKey);
|
|
7540
7657
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7541
7658
|
const attachments = [];
|
|
7542
7659
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
@@ -7613,16 +7730,13 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7613
7730
|
attachmentPaths,
|
|
7614
7731
|
...project,
|
|
7615
7732
|
placedFields: async (placed) => {
|
|
7616
|
-
const taskPath =
|
|
7733
|
+
const taskPath = join19(placed.runDirectory, "task.md");
|
|
7617
7734
|
await writeFile4(taskPath, instruction, "utf8");
|
|
7618
7735
|
return { phase, taskPath };
|
|
7619
7736
|
}
|
|
7620
7737
|
});
|
|
7621
7738
|
}
|
|
7622
7739
|
case "worker-packet": {
|
|
7623
|
-
if (parsed.project !== void 0) {
|
|
7624
|
-
requireOptionPath("--project", parsed.project);
|
|
7625
|
-
}
|
|
7626
7740
|
if (instruction.trim() === "") {
|
|
7627
7741
|
throw new CliUsageError("fixer requires a nonblank repair instruction");
|
|
7628
7742
|
}
|
|
@@ -7659,7 +7773,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7659
7773
|
placedFields: async (placed) => {
|
|
7660
7774
|
let prerequisitesPath;
|
|
7661
7775
|
if (prerequisitesSource !== void 0) {
|
|
7662
|
-
prerequisitesPath =
|
|
7776
|
+
prerequisitesPath = join19(placed.runDirectory, "prerequisites.json");
|
|
7663
7777
|
await writeFile4(
|
|
7664
7778
|
prerequisitesPath,
|
|
7665
7779
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -7667,7 +7781,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7667
7781
|
"utf8"
|
|
7668
7782
|
);
|
|
7669
7783
|
}
|
|
7670
|
-
const packetPath =
|
|
7784
|
+
const packetPath = join19(placed.runDirectory, "fix-packet.md");
|
|
7671
7785
|
await writeFile4(packetPath, instruction, "utf8");
|
|
7672
7786
|
return {
|
|
7673
7787
|
phase,
|
|
@@ -7679,18 +7793,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7679
7793
|
});
|
|
7680
7794
|
}
|
|
7681
7795
|
case "collect-target": {
|
|
7682
|
-
|
|
7683
|
-
requireOptionPath("--project", parsed.project);
|
|
7684
|
-
}
|
|
7685
|
-
let explicitPrNumber;
|
|
7686
|
-
if (parsed.prNumber !== void 0) {
|
|
7687
|
-
try {
|
|
7688
|
-
explicitPrNumber = parseCollectorPrNumber(parsed.prNumber);
|
|
7689
|
-
} catch (error) {
|
|
7690
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
7691
|
-
throw new CliUsageError(detail, { cause: error });
|
|
7692
|
-
}
|
|
7693
|
-
}
|
|
7796
|
+
const explicitPrNumber = parsed.prNumber;
|
|
7694
7797
|
const projectRoot = resolve11(parsed.project ?? shared.cwd);
|
|
7695
7798
|
let repository;
|
|
7696
7799
|
if (parsed.repo !== void 0) {
|
|
@@ -7725,7 +7828,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7725
7828
|
placedFields: async (placed) => {
|
|
7726
7829
|
let requestManifestPath;
|
|
7727
7830
|
if (manifestCanonicalJson !== void 0) {
|
|
7728
|
-
requestManifestPath =
|
|
7831
|
+
requestManifestPath = join19(placed.runDirectory, "request-manifest.json");
|
|
7729
7832
|
await writeFile4(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
7730
7833
|
}
|
|
7731
7834
|
return {
|
|
@@ -7740,15 +7843,12 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7740
7843
|
return { ...admittedCollector, repository };
|
|
7741
7844
|
}
|
|
7742
7845
|
case "case-identity": {
|
|
7743
|
-
if (parsed.
|
|
7744
|
-
requireOptionPath("--project", parsed.project);
|
|
7745
|
-
}
|
|
7746
|
-
const issueNumber = parsed.issueNumber ?? Number.NaN;
|
|
7747
|
-
if (!Number.isInteger(issueNumber) || issueNumber < 1 || !DOCTOR_ISSUE_NUMBER_PATTERN.test(String(issueNumber))) {
|
|
7846
|
+
if (parsed.issueNumber === void 0) {
|
|
7748
7847
|
throw new CliUsageError(
|
|
7749
|
-
`doctor --issue must be a positive integer, got ${
|
|
7848
|
+
`doctor --issue must be a positive integer, got ${Number.NaN}`
|
|
7750
7849
|
);
|
|
7751
7850
|
}
|
|
7851
|
+
const issueNumber = parsed.issueNumber;
|
|
7752
7852
|
let frozenAttachments = [];
|
|
7753
7853
|
const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
|
|
7754
7854
|
...shared,
|
|
@@ -7774,7 +7874,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7774
7874
|
if (parsed.runs === void 0) {
|
|
7775
7875
|
ensureRealDirectoryTree(placed.ledgerHome, caseRunsPath);
|
|
7776
7876
|
}
|
|
7777
|
-
let
|
|
7877
|
+
let caseIdentity;
|
|
7778
7878
|
try {
|
|
7779
7879
|
const patient = await loadDoctorCase(caseRunsPath);
|
|
7780
7880
|
if (patient.identity.issueNumber !== issueNumber) {
|
|
@@ -7782,7 +7882,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7782
7882
|
`doctor case issue ${patient.identity.issueNumber} does not match --issue ${issueNumber}`
|
|
7783
7883
|
);
|
|
7784
7884
|
}
|
|
7785
|
-
|
|
7885
|
+
caseIdentity = patient.identity;
|
|
7786
7886
|
caseRunsPath = await realpath4(caseRunsPath);
|
|
7787
7887
|
} catch (error) {
|
|
7788
7888
|
if (error instanceof CliUsageError) throw error;
|
|
@@ -7796,7 +7896,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7796
7896
|
return {
|
|
7797
7897
|
issueNumber,
|
|
7798
7898
|
caseRunsPath,
|
|
7799
|
-
caseIdentity
|
|
7899
|
+
caseIdentity,
|
|
7800
7900
|
attachments: persistedAttachmentRefs(frozenAttachments)
|
|
7801
7901
|
};
|
|
7802
7902
|
}
|
|
@@ -7804,22 +7904,21 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7804
7904
|
return { ...admittedDoctor, attachments: frozenAttachments };
|
|
7805
7905
|
}
|
|
7806
7906
|
case "source-locator": {
|
|
7807
|
-
if (parsed.project !== void 0) {
|
|
7808
|
-
requireOptionPath("--project", parsed.project);
|
|
7809
|
-
}
|
|
7810
7907
|
const projectRoot = resolve11(parsed.project ?? shared.cwd);
|
|
7811
|
-
let sourceRun;
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7908
|
+
let sourceRun = override?.resolvedSourceRun;
|
|
7909
|
+
if (sourceRun === void 0) {
|
|
7910
|
+
try {
|
|
7911
|
+
sourceRun = await resolveNotarySourceRunLocator({
|
|
7912
|
+
projectRoot,
|
|
7913
|
+
sourceRun: parsed.sourceRun ?? "",
|
|
7914
|
+
home: shared.home
|
|
7915
|
+
});
|
|
7916
|
+
} catch (error) {
|
|
7917
|
+
if (error instanceof NotarySourceRunError) {
|
|
7918
|
+
throw new CliUsageError(error.message, { cause: error });
|
|
7919
|
+
}
|
|
7920
|
+
throw error;
|
|
7821
7921
|
}
|
|
7822
|
-
throw error;
|
|
7823
7922
|
}
|
|
7824
7923
|
const inheritedTicketNumber = await readBoardTicketNumber(sourceRun.runDirectory);
|
|
7825
7924
|
const knownTicketNumber = inheritedTicketNumber ?? shared.assertedTicketNumber;
|
|
@@ -7837,9 +7936,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7837
7936
|
});
|
|
7838
7937
|
}
|
|
7839
7938
|
case "gleaner": {
|
|
7840
|
-
if (parsed.project !== void 0) {
|
|
7841
|
-
requireOptionPath("--project", parsed.project);
|
|
7842
|
-
}
|
|
7843
7939
|
const baseRevision = parsed.baseRevision ?? "";
|
|
7844
7940
|
if (baseRevision.trim() === "") {
|
|
7845
7941
|
throw new CliUsageError("--base requires a nonempty revision");
|
|
@@ -7854,16 +7950,19 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7854
7950
|
});
|
|
7855
7951
|
}
|
|
7856
7952
|
case "review-basis": {
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7953
|
+
if (parsed.lens === void 0) {
|
|
7954
|
+
throw new CliUsageError("--lens requires completeness or correctness");
|
|
7955
|
+
}
|
|
7956
|
+
if (parsed.baseRevision === void 0) {
|
|
7957
|
+
throw new CliUsageError("--base requires a nonempty revision");
|
|
7860
7958
|
}
|
|
7861
|
-
const baseRevision = requireReviewerBaseRevision(parsed.baseRevision);
|
|
7862
7959
|
const rawRefs = parsed.authorityRefs ?? [];
|
|
7863
7960
|
if (rawRefs.length === 0) {
|
|
7864
7961
|
throw new CliUsageError("reviewer requires --authority-ref <ref>");
|
|
7865
7962
|
}
|
|
7866
|
-
const
|
|
7963
|
+
const lens = parsed.lens;
|
|
7964
|
+
const baseRevision = parsed.baseRevision;
|
|
7965
|
+
const authorityRefs = Object.freeze([...rawRefs]);
|
|
7867
7966
|
const admittedReviewer = await admitStandardMaterialInvocation("reviewer", {
|
|
7868
7967
|
...shared,
|
|
7869
7968
|
instruction,
|
|
@@ -7878,9 +7977,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7878
7977
|
return { ...admittedReviewer, authorityRefs };
|
|
7879
7978
|
}
|
|
7880
7979
|
case "merge-envelope": {
|
|
7881
|
-
if (parsed.project !== void 0) {
|
|
7882
|
-
requireOptionPath("--project", parsed.project);
|
|
7883
|
-
}
|
|
7884
7980
|
if (instruction.trim() === "") {
|
|
7885
7981
|
throw new CliUsageError("merger requires a nonblank task instruction");
|
|
7886
7982
|
}
|
|
@@ -7915,7 +8011,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7915
8011
|
resolutionScope: [...derived.resolutionScope],
|
|
7916
8012
|
authorizedChecks: []
|
|
7917
8013
|
});
|
|
7918
|
-
const mergerInputPath =
|
|
8014
|
+
const mergerInputPath = join19(placed.runDirectory, "merger-input.json");
|
|
7919
8015
|
await writeFile4(
|
|
7920
8016
|
mergerInputPath,
|
|
7921
8017
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -7942,9 +8038,6 @@ function admissionSubject(ticketNumber) {
|
|
|
7942
8038
|
return { ticketNumber: fields.ticketNumber };
|
|
7943
8039
|
}
|
|
7944
8040
|
async function placeRoleAdmission(options) {
|
|
7945
|
-
if (options.project !== void 0) {
|
|
7946
|
-
requireOptionPath("--project", options.project);
|
|
7947
|
-
}
|
|
7948
8041
|
const projectRoot = resolve11(options.project ?? options.cwd);
|
|
7949
8042
|
const runId = options.runId ?? (options.createRunId ?? uuidv7)();
|
|
7950
8043
|
const ticketFields = ticketAdmissionFields(options.assertedTicketNumber);
|
|
@@ -7989,7 +8082,7 @@ function persistedAttachmentRefs(attachments) {
|
|
|
7989
8082
|
}));
|
|
7990
8083
|
}
|
|
7991
8084
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
7992
|
-
const admittedRequestPath =
|
|
8085
|
+
const admittedRequestPath = join19(placed.runDirectory, "admitted-request.json");
|
|
7993
8086
|
await writeAdmittedRequestPersistence(admittedRequestPath, admitted, {
|
|
7994
8087
|
sessionDirectory: placed.sessionDirectory,
|
|
7995
8088
|
sessionFile: placed.sessionFile
|
|
@@ -8042,7 +8135,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
8042
8135
|
attachments: persistedAttachmentRefs(placed.attachments),
|
|
8043
8136
|
...placed.ticketFields
|
|
8044
8137
|
};
|
|
8045
|
-
const admittedRequestPath = defer ?
|
|
8138
|
+
const admittedRequestPath = defer ? join19(placed.runDirectory, "admitted-request.json") : await persistPlacedAdmission(admitted, placed, options.model);
|
|
8046
8139
|
return {
|
|
8047
8140
|
role,
|
|
8048
8141
|
runId: placed.runId,
|
|
@@ -8120,7 +8213,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
8120
8213
|
});
|
|
8121
8214
|
const placement = placed;
|
|
8122
8215
|
admitted.runDirectory = placement.runDirectory;
|
|
8123
|
-
admitted.admittedRequestPath =
|
|
8216
|
+
admitted.admittedRequestPath = join19(
|
|
8124
8217
|
placement.runDirectory,
|
|
8125
8218
|
"admitted-request.json"
|
|
8126
8219
|
);
|
|
@@ -8147,7 +8240,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
8147
8240
|
async function loadAdmittedJudgeRequest(runDirectory) {
|
|
8148
8241
|
try {
|
|
8149
8242
|
const raw = JSON.parse(
|
|
8150
|
-
await readFile13(
|
|
8243
|
+
await readFile13(join19(runDirectory, "admitted-request.json"), "utf8")
|
|
8151
8244
|
);
|
|
8152
8245
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
8153
8246
|
const record4 = raw;
|
|
@@ -8236,7 +8329,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
8236
8329
|
}
|
|
8237
8330
|
async function resolveDoctorCaseRunsPath(options) {
|
|
8238
8331
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
8239
|
-
const defaultRuns =
|
|
8332
|
+
const defaultRuns = join19(
|
|
8240
8333
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
8241
8334
|
String(options.issueNumber),
|
|
8242
8335
|
"runs"
|
|
@@ -8330,11 +8423,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
8330
8423
|
`${flag} requires a comma-separated list of N or book:N`
|
|
8331
8424
|
);
|
|
8332
8425
|
}
|
|
8333
|
-
const
|
|
8334
|
-
if (
|
|
8335
|
-
const rhs = trimmed.slice(
|
|
8426
|
+
const sep5 = trimmed.lastIndexOf(":");
|
|
8427
|
+
if (sep5 > 0) {
|
|
8428
|
+
const rhs = trimmed.slice(sep5 + 1);
|
|
8336
8429
|
if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
|
|
8337
|
-
const bookKey = trimmed.slice(0,
|
|
8430
|
+
const bookKey = trimmed.slice(0, sep5);
|
|
8338
8431
|
if (bookKey.trim() === "") {
|
|
8339
8432
|
throw new CliUsageError(
|
|
8340
8433
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -8557,15 +8650,15 @@ var init_invocation = __esm({
|
|
|
8557
8650
|
|
|
8558
8651
|
// src/public-cli/load-production-acp-host.ts
|
|
8559
8652
|
import { existsSync as existsSync5 } from "node:fs";
|
|
8560
|
-
import { join as
|
|
8653
|
+
import { join as join20 } from "node:path";
|
|
8561
8654
|
import { pathToFileURL } from "node:url";
|
|
8562
8655
|
async function loadProductionAcpHostFactory(packageRoot, host) {
|
|
8563
8656
|
const description = lookupHostDescription(host);
|
|
8564
8657
|
if (description === void 0) {
|
|
8565
8658
|
throw new Error(`unregistered host: ${host}`);
|
|
8566
8659
|
}
|
|
8567
|
-
const built =
|
|
8568
|
-
const source =
|
|
8660
|
+
const built = join20(packageRoot, "dist/acp-host/production-host.js");
|
|
8661
|
+
const source = join20(packageRoot, "src/acp-host/production-host.ts");
|
|
8569
8662
|
const target = existsSync5(built) ? built : source;
|
|
8570
8663
|
const href = pathToFileURL(target).href;
|
|
8571
8664
|
const mod = await import(href);
|
|
@@ -8581,15 +8674,15 @@ var init_load_production_acp_host = __esm({
|
|
|
8581
8674
|
|
|
8582
8675
|
// src/public-cli/load-production-headless-host.ts
|
|
8583
8676
|
import { existsSync as existsSync6 } from "node:fs";
|
|
8584
|
-
import { join as
|
|
8677
|
+
import { join as join21 } from "node:path";
|
|
8585
8678
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
8586
8679
|
async function loadProductionHeadlessHostFactory(packageRoot, host) {
|
|
8587
8680
|
const description = lookupHeadlessHostDescription(host);
|
|
8588
8681
|
if (description === void 0) {
|
|
8589
8682
|
throw new Error(`unregistered headless host: ${host}`);
|
|
8590
8683
|
}
|
|
8591
|
-
const built =
|
|
8592
|
-
const source =
|
|
8684
|
+
const built = join21(packageRoot, "dist/headless-host/production-host.js");
|
|
8685
|
+
const source = join21(packageRoot, "src/headless-host/production-host.ts");
|
|
8593
8686
|
const target = existsSync6(built) ? built : source;
|
|
8594
8687
|
const href = pathToFileURL2(target).href;
|
|
8595
8688
|
const mod = await import(href);
|
|
@@ -8714,179 +8807,45 @@ var init_role_turn_host_resolution = __esm({
|
|
|
8714
8807
|
}
|
|
8715
8808
|
});
|
|
8716
8809
|
|
|
8717
|
-
// src/public-cli/
|
|
8718
|
-
var
|
|
8719
|
-
__export(
|
|
8720
|
-
|
|
8721
|
-
hermesProviderModelsCachePath: () => hermesProviderModelsCachePath,
|
|
8722
|
-
hostCatalogOffersModel: () => hostCatalogOffersModel,
|
|
8723
|
-
hostProvidersPath: () => hostProvidersPath,
|
|
8724
|
-
listHermesProvidersForModel: () => listHermesProvidersForModel,
|
|
8725
|
-
loadHostProvidersTable: () => loadHostProvidersTable,
|
|
8726
|
-
parseHostProvidersTable: () => parseHostProvidersTable,
|
|
8727
|
-
projectHostFacingProvider: () => projectHostFacingProvider,
|
|
8728
|
-
renderHostProvidersTable: () => renderHostProvidersTable
|
|
8810
|
+
// src/public-cli/role-seat-runtime.ts
|
|
8811
|
+
var role_seat_runtime_exports = {};
|
|
8812
|
+
__export(role_seat_runtime_exports, {
|
|
8813
|
+
openRoleSeatRuntime: () => openRoleSeatRuntime
|
|
8729
8814
|
});
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
throw new Error("home must be explicitly provided");
|
|
8735
|
-
}
|
|
8736
|
-
return join21(home, ".ak-roles", "host-providers.json");
|
|
8737
|
-
}
|
|
8738
|
-
function hermesProviderModelsCachePath(home) {
|
|
8739
|
-
return join21(home, ".hermes", "provider_models_cache.json");
|
|
8740
|
-
}
|
|
8741
|
-
function parseHostProvidersTable(value) {
|
|
8742
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
8743
|
-
throw new Error("host-providers.json must be an object");
|
|
8744
|
-
}
|
|
8745
|
-
const out = {};
|
|
8746
|
-
for (const [host, byProvider] of Object.entries(value)) {
|
|
8747
|
-
if (host.trim() === "") {
|
|
8748
|
-
throw new Error("host-providers.json host key must be non-empty");
|
|
8749
|
-
}
|
|
8750
|
-
if (byProvider === null || typeof byProvider !== "object" || Array.isArray(byProvider)) {
|
|
8751
|
-
throw new Error(`host-providers.json[${host}] must be an object`);
|
|
8752
|
-
}
|
|
8753
|
-
const providers = {};
|
|
8754
|
-
for (const [seatProvider, hostProvider] of Object.entries(
|
|
8755
|
-
byProvider
|
|
8756
|
-
)) {
|
|
8757
|
-
if (seatProvider.trim() === "") {
|
|
8758
|
-
throw new Error(
|
|
8759
|
-
`host-providers.json[${host}] seat-provider key must be non-empty`
|
|
8760
|
-
);
|
|
8761
|
-
}
|
|
8762
|
-
if (typeof hostProvider !== "string" || hostProvider.trim() === "") {
|
|
8763
|
-
throw new Error(
|
|
8764
|
-
`host-providers.json[${host}][${seatProvider}] must be a non-empty string`
|
|
8765
|
-
);
|
|
8766
|
-
}
|
|
8767
|
-
providers[seatProvider] = hostProvider;
|
|
8768
|
-
}
|
|
8769
|
-
if (Object.keys(providers).length > 0) {
|
|
8770
|
-
out[host] = providers;
|
|
8771
|
-
}
|
|
8772
|
-
}
|
|
8773
|
-
return out;
|
|
8774
|
-
}
|
|
8775
|
-
function loadHostProvidersTable(home) {
|
|
8776
|
-
const path = hostProvidersPath(home);
|
|
8777
|
-
try {
|
|
8778
|
-
const raw = readFileSync(path, "utf8");
|
|
8779
|
-
return parseHostProvidersTable(JSON.parse(raw));
|
|
8780
|
-
} catch (error) {
|
|
8781
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
8782
|
-
return {};
|
|
8783
|
-
}
|
|
8784
|
-
throw error;
|
|
8785
|
-
}
|
|
8786
|
-
}
|
|
8787
|
-
function hostCatalogOffersModel(catalogModels, seatModel) {
|
|
8788
|
-
return catalogModels.some(
|
|
8789
|
-
(entry) => entry === seatModel || entry.endsWith(`/${seatModel}`)
|
|
8815
|
+
function openRoleSeatRuntime(input) {
|
|
8816
|
+
const hostAdapters = composeRoleTurnHostAdapters(
|
|
8817
|
+
input.resolution,
|
|
8818
|
+
input.principalAuthority
|
|
8790
8819
|
);
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
let text;
|
|
8795
|
-
try {
|
|
8796
|
-
text = readFileSync(path, "utf8");
|
|
8797
|
-
} catch (error) {
|
|
8798
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
8799
|
-
return [];
|
|
8800
|
-
}
|
|
8801
|
-
throw error;
|
|
8802
|
-
}
|
|
8803
|
-
const raw = JSON.parse(text);
|
|
8804
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
8805
|
-
throw new Error(
|
|
8806
|
-
`hermes provider_models_cache.json must be an object: ${path}`
|
|
8807
|
-
);
|
|
8808
|
-
}
|
|
8809
|
-
const found = [];
|
|
8810
|
-
for (const [provider, entry] of Object.entries(raw)) {
|
|
8811
|
-
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
|
8812
|
-
continue;
|
|
8813
|
-
}
|
|
8814
|
-
const models = entry.models;
|
|
8815
|
-
if (!Array.isArray(models)) continue;
|
|
8816
|
-
const names = models.filter((m) => typeof m === "string");
|
|
8817
|
-
if (hostCatalogOffersModel(names, seatModel)) {
|
|
8818
|
-
found.push(provider);
|
|
8819
|
-
}
|
|
8820
|
-
}
|
|
8821
|
-
return found.sort();
|
|
8822
|
-
}
|
|
8823
|
-
function listDirectoryProvidersForModel(home, host, seatModel) {
|
|
8824
|
-
if (host === "hermes") {
|
|
8825
|
-
return listHermesProvidersForModel(home, seatModel);
|
|
8826
|
-
}
|
|
8827
|
-
return void 0;
|
|
8828
|
-
}
|
|
8829
|
-
function projectHostFacingProvider(selection, host, table, home) {
|
|
8830
|
-
if (selection === void 0) return void 0;
|
|
8831
|
-
const mapped = table[host]?.[selection.provider];
|
|
8832
|
-
if (mapped !== void 0) {
|
|
8833
|
-
return mapped === selection.provider ? selection : { ...selection, provider: mapped };
|
|
8834
|
-
}
|
|
8835
|
-
const directory = listDirectoryProvidersForModel(home, host, selection.model);
|
|
8836
|
-
if (directory === void 0) {
|
|
8837
|
-
return selection;
|
|
8838
|
-
}
|
|
8839
|
-
if (directory.length === 1) {
|
|
8840
|
-
const only = directory[0];
|
|
8841
|
-
return only === selection.provider ? selection : { ...selection, provider: only };
|
|
8842
|
-
}
|
|
8843
|
-
if (directory.length === 0) {
|
|
8844
|
-
throw new HostProviderResolutionError({
|
|
8845
|
-
message: `host ${host} has no provider offering model ${selection.model}; seat provider was ${selection.provider}`,
|
|
8846
|
-
host,
|
|
8847
|
-
seatProvider: selection.provider,
|
|
8848
|
-
seatModel: selection.model
|
|
8849
|
-
});
|
|
8850
|
-
}
|
|
8851
|
-
throw new HostProviderResolutionError({
|
|
8852
|
-
message: `host ${host} has multiple providers for model ${selection.model}: ${directory.join(", ")}; set host-providers.json[${host}][${selection.provider}] to one of them`,
|
|
8853
|
-
host,
|
|
8854
|
-
seatProvider: selection.provider,
|
|
8855
|
-
seatModel: selection.model,
|
|
8856
|
-
candidates: directory
|
|
8820
|
+
const roleTurnHost = selectRoleTurnHost(hostAdapters, {
|
|
8821
|
+
role: input.role,
|
|
8822
|
+
seat: input.seat
|
|
8857
8823
|
});
|
|
8824
|
+
input.afterHost?.();
|
|
8825
|
+
const seatWithModel = resolvedSeatWithModel(input.seat);
|
|
8826
|
+
if (seatWithModel === void 0) return { ok: false };
|
|
8827
|
+
const projected = input.hostFacingModel ?? projectHostFacingProvider(
|
|
8828
|
+
seatWithModel.selection,
|
|
8829
|
+
seatWithModel.host,
|
|
8830
|
+
loadHostProvidersTable(input.home),
|
|
8831
|
+
input.home
|
|
8832
|
+
);
|
|
8833
|
+
return {
|
|
8834
|
+
ok: true,
|
|
8835
|
+
roleTurnHost,
|
|
8836
|
+
hostAdapters,
|
|
8837
|
+
...projected === void 0 ? {} : { model: projected },
|
|
8838
|
+
...pickEngineAxis(seatWithModel),
|
|
8839
|
+
host: seatWithModel.host
|
|
8840
|
+
};
|
|
8858
8841
|
}
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
for (const host of Object.keys(table).sort()) {
|
|
8862
|
-
const byProvider = table[host];
|
|
8863
|
-
for (const seatProvider of Object.keys(byProvider).sort()) {
|
|
8864
|
-
lines.push(
|
|
8865
|
-
`hostProvider ${host} ${seatProvider} ${byProvider[seatProvider]}`
|
|
8866
|
-
);
|
|
8867
|
-
}
|
|
8868
|
-
}
|
|
8869
|
-
return lines.length === 0 ? "" : `${lines.join("\n")}
|
|
8870
|
-
`;
|
|
8871
|
-
}
|
|
8872
|
-
var HostProviderResolutionError;
|
|
8873
|
-
var init_host_providers = __esm({
|
|
8874
|
-
"src/public-cli/host-providers.ts"() {
|
|
8842
|
+
var init_role_seat_runtime = __esm({
|
|
8843
|
+
"src/public-cli/role-seat-runtime.ts"() {
|
|
8875
8844
|
"use strict";
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
candidates;
|
|
8881
|
-
constructor(options) {
|
|
8882
|
-
super(options.message);
|
|
8883
|
-
this.name = "HostProviderResolutionError";
|
|
8884
|
-
this.host = options.host;
|
|
8885
|
-
this.seatProvider = options.seatProvider;
|
|
8886
|
-
this.seatModel = options.seatModel;
|
|
8887
|
-
this.candidates = options.candidates ?? [];
|
|
8888
|
-
}
|
|
8889
|
-
};
|
|
8845
|
+
init_engine_material();
|
|
8846
|
+
init_config();
|
|
8847
|
+
init_host_providers();
|
|
8848
|
+
init_role_turn_host_resolution();
|
|
8890
8849
|
}
|
|
8891
8850
|
});
|
|
8892
8851
|
|
|
@@ -12384,190 +12343,441 @@ var init_submission_gate = __esm({
|
|
|
12384
12343
|
}
|
|
12385
12344
|
});
|
|
12386
12345
|
|
|
12387
|
-
// src/
|
|
12388
|
-
import {
|
|
12389
|
-
import {
|
|
12390
|
-
|
|
12391
|
-
|
|
12392
|
-
|
|
12393
|
-
|
|
12394
|
-
return authority.decode(principal).sessionFile;
|
|
12395
|
-
},
|
|
12396
|
-
async load(principal) {
|
|
12397
|
-
try {
|
|
12398
|
-
const value = JSON.parse(await readFile17(bindingPath(principal), "utf8"));
|
|
12399
|
-
if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
|
|
12400
|
-
throw new Error("durable session binding is invalid");
|
|
12401
|
-
}
|
|
12402
|
-
return value.sessionId;
|
|
12403
|
-
} catch (error) {
|
|
12404
|
-
if (error.code === "ENOENT") return void 0;
|
|
12405
|
-
throw error;
|
|
12406
|
-
}
|
|
12407
|
-
},
|
|
12408
|
-
async bind(principal, sessionId) {
|
|
12409
|
-
const target = bindingPath(principal);
|
|
12410
|
-
await mkdir2(dirname18(target), { recursive: true });
|
|
12411
|
-
const temporary = `${target}.${process.pid}.tmp`;
|
|
12412
|
-
await writeFile6(temporary, `${JSON.stringify({ sessionId })}
|
|
12413
|
-
`, { encoding: "utf8", mode: 384 });
|
|
12414
|
-
await rename3(temporary, target);
|
|
12415
|
-
}
|
|
12416
|
-
};
|
|
12346
|
+
// src/public-cli/machine-method-skills.ts
|
|
12347
|
+
import { accessSync, constants as constants2, statSync as statSync3 } from "node:fs";
|
|
12348
|
+
import { lstat as lstat4, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
12349
|
+
import { join as join29 } from "node:path";
|
|
12350
|
+
import { spawnSync } from "node:child_process";
|
|
12351
|
+
function skillRoot(home) {
|
|
12352
|
+
return join29(home, ".agents/skills");
|
|
12417
12353
|
}
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
const description = lookupHostDescription(host) ?? lookupHeadlessHostDescription(host);
|
|
12421
|
-
if (description === void 0) return void 0;
|
|
12422
|
-
const sessionId = await createSessionIdentityAuthority(
|
|
12423
|
-
authority,
|
|
12424
|
-
description.sessionBindingFile
|
|
12425
|
-
).load(principal);
|
|
12426
|
-
if (sessionId === void 0 || sessionId === "") return void 0;
|
|
12427
|
-
return sessionId;
|
|
12354
|
+
function installedMethodSkillPath(home, name) {
|
|
12355
|
+
return installedSkillPath(skillRoot(home), name);
|
|
12428
12356
|
}
|
|
12429
|
-
|
|
12430
|
-
"
|
|
12431
|
-
|
|
12432
|
-
|
|
12357
|
+
function installedSkillPath(root, name) {
|
|
12358
|
+
const path = join29(root, name, "SKILL.md");
|
|
12359
|
+
try {
|
|
12360
|
+
if (!statSync3(path).isFile()) return void 0;
|
|
12361
|
+
accessSync(path, constants2.R_OK);
|
|
12362
|
+
return path;
|
|
12363
|
+
} catch (error) {
|
|
12364
|
+
const code = error.code;
|
|
12365
|
+
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM" || code === "ELOOP") return void 0;
|
|
12366
|
+
throw error;
|
|
12433
12367
|
}
|
|
12434
|
-
}
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
12439
|
-
const reason = signal.reason;
|
|
12440
|
-
if (reason === "SIGTERM" || reason === "SIGINT" || reason === "SIGHUP") {
|
|
12441
|
-
return reason;
|
|
12368
|
+
}
|
|
12369
|
+
function linkedSkillRoot(home, host) {
|
|
12370
|
+
if (host === "claude" || host === "claude-code") {
|
|
12371
|
+
return join29(process.env.CLAUDE_CONFIG_DIR?.trim() || join29(home, ".claude"), "skills");
|
|
12442
12372
|
}
|
|
12373
|
+
if (host === "hermes") return join29(home, ".hermes/skills");
|
|
12443
12374
|
return void 0;
|
|
12444
12375
|
}
|
|
12445
|
-
function
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
"
|
|
12376
|
+
async function occupied(path) {
|
|
12377
|
+
try {
|
|
12378
|
+
await lstat4(path);
|
|
12379
|
+
return true;
|
|
12380
|
+
} catch (error) {
|
|
12381
|
+
if (error.code !== "ENOENT") throw error;
|
|
12382
|
+
return false;
|
|
12451
12383
|
}
|
|
12452
|
-
}
|
|
12453
|
-
|
|
12454
|
-
|
|
12455
|
-
import { spawnSync } from "node:child_process";
|
|
12456
|
-
import {
|
|
12457
|
-
appendFileSync as appendFileSync2,
|
|
12458
|
-
copyFileSync,
|
|
12459
|
-
closeSync,
|
|
12460
|
-
existsSync as existsSync9,
|
|
12461
|
-
openSync,
|
|
12462
|
-
readFileSync as readFileSync3,
|
|
12463
|
-
mkdirSync as mkdirSync3,
|
|
12464
|
-
readdirSync as readdirSync2,
|
|
12465
|
-
rmSync,
|
|
12466
|
-
statSync as statSync3
|
|
12467
|
-
} from "node:fs";
|
|
12468
|
-
import { homedir } from "node:os";
|
|
12469
|
-
import { dirname as dirname19, join as join30 } from "node:path";
|
|
12470
|
-
function declareHostSessionFailure(error) {
|
|
12471
|
-
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
12472
|
-
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
12384
|
+
}
|
|
12385
|
+
function warnOccupied(path, stdout) {
|
|
12386
|
+
stdout(`Warning: ${path} is already occupied; left untouched.
|
|
12473
12387
|
`);
|
|
12474
12388
|
}
|
|
12475
|
-
function
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12389
|
+
async function warnMissingMethodSkills(home, host, role, skills, stdout) {
|
|
12390
|
+
const missing = [];
|
|
12391
|
+
const linkedRoot = linkedSkillRoot(home, host);
|
|
12392
|
+
for (const skill of skills) {
|
|
12393
|
+
if (installedMethodSkillPath(home, skill) === void 0 || linkedRoot !== void 0 && installedSkillPath(linkedRoot, skill) === void 0) missing.push(skill);
|
|
12394
|
+
}
|
|
12395
|
+
for (const skill of missing) {
|
|
12396
|
+
stdout(`Warning: required machine Skill "${skill}" is missing for ${role}; its method guidance may be unavailable and reduce work quality. Run \`ak-role setup\` to install required Skills.
|
|
12397
|
+
`);
|
|
12480
12398
|
}
|
|
12481
12399
|
}
|
|
12482
|
-
function
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12400
|
+
function runSkillsCli(args, home) {
|
|
12401
|
+
const result = spawnSync("npx", ["--yes", "skills", ...args], {
|
|
12402
|
+
stdio: "inherit",
|
|
12403
|
+
env: { ...process.env, HOME: home }
|
|
12404
|
+
});
|
|
12405
|
+
if (result.error !== void 0) throw result.error;
|
|
12406
|
+
return result.status === 0;
|
|
12407
|
+
}
|
|
12408
|
+
function addSkills(source, skills, home) {
|
|
12409
|
+
if (skills.length === 0) return true;
|
|
12410
|
+
return runSkillsCli([
|
|
12411
|
+
"add",
|
|
12412
|
+
source,
|
|
12413
|
+
...skills.flatMap((skill) => ["--skill", skill]),
|
|
12414
|
+
"--agent",
|
|
12415
|
+
"codex",
|
|
12416
|
+
"--global",
|
|
12417
|
+
"--yes"
|
|
12418
|
+
], home);
|
|
12419
|
+
}
|
|
12420
|
+
function updateRequiredSkills(home) {
|
|
12421
|
+
const names = packagedMethodSkillNames();
|
|
12422
|
+
if (names.length === 0) return true;
|
|
12423
|
+
return runSkillsCli(["update", "-g", "-y", ...names], home);
|
|
12424
|
+
}
|
|
12425
|
+
async function runMachineSkillSetup(home, stdout) {
|
|
12426
|
+
const canonical = skillRoot(home);
|
|
12427
|
+
const missingBySource = /* @__PURE__ */ new Map();
|
|
12428
|
+
let unsourced = false;
|
|
12429
|
+
for (const name of packagedMethodSkillNames()) {
|
|
12430
|
+
const path = join29(canonical, name);
|
|
12431
|
+
if (await occupied(path)) {
|
|
12432
|
+
warnOccupied(path, stdout);
|
|
12433
|
+
continue;
|
|
12434
|
+
}
|
|
12435
|
+
const source = SKILL_SOURCE[name];
|
|
12436
|
+
if (source === void 0) {
|
|
12437
|
+
unsourced = true;
|
|
12438
|
+
stdout(`Warning: required machine Skill "${name}" has no install source; setup did not install it.
|
|
12439
|
+
`);
|
|
12440
|
+
continue;
|
|
12441
|
+
}
|
|
12442
|
+
const missing = missingBySource.get(source) ?? [];
|
|
12443
|
+
missing.push(name);
|
|
12444
|
+
missingBySource.set(source, missing);
|
|
12445
|
+
}
|
|
12446
|
+
for (const [source, missing] of missingBySource) {
|
|
12447
|
+
if (!addSkills(source, missing, home)) return 1;
|
|
12448
|
+
}
|
|
12449
|
+
if (unsourced) return 1;
|
|
12450
|
+
for (const host of ["claude-code", "hermes"]) {
|
|
12451
|
+
const root = linkedSkillRoot(home, host);
|
|
12452
|
+
const description = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude : HOST_DESCRIPTIONS.hermes;
|
|
12488
12453
|
try {
|
|
12489
|
-
|
|
12490
|
-
} catch {
|
|
12491
|
-
|
|
12454
|
+
accessSync(resolveHostBinary(description, home), constants2.X_OK);
|
|
12455
|
+
} catch (error) {
|
|
12456
|
+
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
12457
|
+
throw error;
|
|
12492
12458
|
}
|
|
12493
|
-
for (const
|
|
12494
|
-
const
|
|
12495
|
-
if (
|
|
12496
|
-
|
|
12497
|
-
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
matches.push({ path: fullPath, mtime: stat2.mtimeMs });
|
|
12501
|
-
} catch {
|
|
12502
|
-
matches.push({ path: fullPath, mtime: 0 });
|
|
12503
|
-
}
|
|
12459
|
+
for (const name of packagedMethodSkillNames()) {
|
|
12460
|
+
const target = join29(canonical, name);
|
|
12461
|
+
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
12462
|
+
const link = join29(root, name);
|
|
12463
|
+
if (await occupied(link)) {
|
|
12464
|
+
warnOccupied(link, stdout);
|
|
12465
|
+
continue;
|
|
12504
12466
|
}
|
|
12467
|
+
await mkdir2(root, { recursive: true });
|
|
12468
|
+
await symlink(target, link, "dir");
|
|
12505
12469
|
}
|
|
12506
12470
|
}
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
12510
|
-
return matches[0]?.path;
|
|
12511
|
-
}
|
|
12512
|
-
function sanitizeClaudeCwd(cwd) {
|
|
12513
|
-
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
12471
|
+
if (!updateRequiredSkills(home)) return 1;
|
|
12472
|
+
stdout("Machine method Skills setup finished. Existing same-name Skills were left untouched.\n");
|
|
12473
|
+
return 0;
|
|
12514
12474
|
}
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12475
|
+
var SKILL_SOURCE;
|
|
12476
|
+
var init_machine_method_skills = __esm({
|
|
12477
|
+
"src/public-cli/machine-method-skills.ts"() {
|
|
12478
|
+
"use strict";
|
|
12479
|
+
init_host_descriptions();
|
|
12480
|
+
init_packaged_role_registry();
|
|
12481
|
+
SKILL_SOURCE = {
|
|
12482
|
+
tdd: "mattpocock/skills",
|
|
12483
|
+
"diagnosing-bugs": "mattpocock/skills",
|
|
12484
|
+
"resolving-merge-conflicts": "mattpocock/skills",
|
|
12485
|
+
"ak-cross-m-review": "Akagilnc/ak-cross-m-review"
|
|
12486
|
+
};
|
|
12524
12487
|
}
|
|
12525
|
-
|
|
12526
|
-
|
|
12527
|
-
|
|
12488
|
+
});
|
|
12489
|
+
|
|
12490
|
+
// src/public-cli/turn-request.ts
|
|
12491
|
+
function projectPublicTurnAxes(env) {
|
|
12492
|
+
return {
|
|
12493
|
+
packageRoot: env.packageRoot,
|
|
12494
|
+
home: env.home,
|
|
12495
|
+
agentDir: env.agentDir,
|
|
12496
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
12497
|
+
...pickEngineAxis(env),
|
|
12498
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs }
|
|
12499
|
+
};
|
|
12500
|
+
}
|
|
12501
|
+
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
12502
|
+
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
12503
|
+
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
12504
|
+
if (admitted.principal === void 0) throw new Error("admitted invocation missing principal");
|
|
12505
|
+
return {
|
|
12506
|
+
principal: admitted.principal,
|
|
12507
|
+
activation: roleDetails.activation,
|
|
12508
|
+
methods: roleDetails.methods ?? [],
|
|
12509
|
+
continuation: options.continuation,
|
|
12510
|
+
...options.model === void 0 ? {} : { model: options.model },
|
|
12511
|
+
...pickEngineAxis(options),
|
|
12512
|
+
cwd,
|
|
12513
|
+
home: options.home,
|
|
12514
|
+
agentDir: options.agentDir,
|
|
12515
|
+
runDirectory: admitted.runDirectory,
|
|
12516
|
+
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
12517
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
12518
|
+
...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
|
|
12519
|
+
...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
|
|
12520
|
+
...options.stationChild === void 0 ? {} : { stationChild: options.stationChild }
|
|
12521
|
+
};
|
|
12522
|
+
}
|
|
12523
|
+
function packagedSettleSkill(admitted) {
|
|
12524
|
+
const record4 = packagedRoleMetadata(admitted.role);
|
|
12525
|
+
if (record4 === void 0) return void 0;
|
|
12526
|
+
if ("applyMethod" in record4 && record4.applyMethod !== void 0) {
|
|
12527
|
+
return "phase" in admitted && admitted.phase === "apply" ? record4.applyMethod : void 0;
|
|
12528
12528
|
}
|
|
12529
|
+
if ("settleMethod" in record4 && record4.settleMethod !== void 0) return record4.settleMethod;
|
|
12529
12530
|
return void 0;
|
|
12530
12531
|
}
|
|
12531
|
-
function
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
appendFileSync2(join30(runDirectory, ".run-starts"), "\n");
|
|
12537
|
-
} catch (error) {
|
|
12538
|
-
declareHostSessionFailure(error);
|
|
12532
|
+
function readAdmittedPath2(admitted, path) {
|
|
12533
|
+
let current = admitted;
|
|
12534
|
+
for (const key of path.split(".")) {
|
|
12535
|
+
if (current === null || typeof current !== "object") return void 0;
|
|
12536
|
+
current = current[key];
|
|
12539
12537
|
}
|
|
12538
|
+
return current;
|
|
12540
12539
|
}
|
|
12541
|
-
function
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12549
|
-
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
|
|
12553
|
-
|
|
12554
|
-
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
} catch {
|
|
12540
|
+
function activationForAdmitted(admitted) {
|
|
12541
|
+
if (packagedRoleMetadata(admitted.role) === void 0) {
|
|
12542
|
+
throw new Error(`no turn projection for ${admitted.role}`);
|
|
12543
|
+
}
|
|
12544
|
+
const activation = { role: admitted.role };
|
|
12545
|
+
for (const spec of packagedRoleActivationFlags(admitted.role)) {
|
|
12546
|
+
let value = readAdmittedPath2(admitted, spec.from ?? spec.field);
|
|
12547
|
+
if (spec.fallback === "gate-pointer") {
|
|
12548
|
+
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
12549
|
+
value = trimmed !== "" ? trimmed : parentRunPathFromGatePointerInstruction(admitted.instruction);
|
|
12550
|
+
if (typeof value !== "string" || value === "") continue;
|
|
12551
|
+
}
|
|
12552
|
+
if (value === void 0) continue;
|
|
12553
|
+
if (spec.text === true) {
|
|
12554
|
+
if (typeof value !== "number") continue;
|
|
12555
|
+
value = String(value);
|
|
12558
12556
|
}
|
|
12557
|
+
activation[spec.field] = value;
|
|
12559
12558
|
}
|
|
12560
|
-
|
|
12561
|
-
let starts = 0;
|
|
12562
|
-
if (existsSync9(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
12563
|
-
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
12564
|
-
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
12565
|
-
const landingPath = options.host === "grok-build" ? join30(options.sessionDirectory, baseName) : join30(options.sessionDirectory, `${baseName}.jsonl`);
|
|
12566
|
-
return { landingPath, ordinal, sanitizedModel };
|
|
12559
|
+
return activation;
|
|
12567
12560
|
}
|
|
12568
|
-
function
|
|
12569
|
-
|
|
12570
|
-
|
|
12561
|
+
function requiredMethodSkills(admitted) {
|
|
12562
|
+
const record4 = packagedRoleMetadata(admitted.role);
|
|
12563
|
+
const names = [];
|
|
12564
|
+
if (record4 !== void 0 && "methodSkills" in record4 && record4.methodSkills !== void 0) {
|
|
12565
|
+
names.push(...record4.methodSkills);
|
|
12566
|
+
}
|
|
12567
|
+
const apply = packagedSettleSkill(admitted);
|
|
12568
|
+
if (apply !== void 0 && !names.includes(apply)) names.push(apply);
|
|
12569
|
+
return names;
|
|
12570
|
+
}
|
|
12571
|
+
function methodBindings(admitted, home, host) {
|
|
12572
|
+
if (host !== void 0 && host !== "pi") return [];
|
|
12573
|
+
return requiredMethodSkills(admitted).flatMap((name) => {
|
|
12574
|
+
const path = installedMethodSkillPath(home, name);
|
|
12575
|
+
return path === void 0 ? [] : [{
|
|
12576
|
+
kind: "skill",
|
|
12577
|
+
path
|
|
12578
|
+
}];
|
|
12579
|
+
});
|
|
12580
|
+
}
|
|
12581
|
+
function admittedSeatTurnDetails(admitted, home, host) {
|
|
12582
|
+
return {
|
|
12583
|
+
activation: activationForAdmitted(admitted),
|
|
12584
|
+
methods: methodBindings(admitted, home, host)
|
|
12585
|
+
};
|
|
12586
|
+
}
|
|
12587
|
+
var init_turn_request = __esm({
|
|
12588
|
+
"src/public-cli/turn-request.ts"() {
|
|
12589
|
+
"use strict";
|
|
12590
|
+
init_engine_material();
|
|
12591
|
+
init_packaged_role_registry();
|
|
12592
|
+
init_machine_method_skills();
|
|
12593
|
+
init_run_lifecycle();
|
|
12594
|
+
}
|
|
12595
|
+
});
|
|
12596
|
+
|
|
12597
|
+
// src/session-identity.ts
|
|
12598
|
+
import { mkdir as mkdir3, readFile as readFile17, rename as rename3, writeFile as writeFile6 } from "node:fs/promises";
|
|
12599
|
+
import { dirname as dirname18, join as join30 } from "node:path";
|
|
12600
|
+
function createSessionIdentityAuthority(authority, sessionBindingFile) {
|
|
12601
|
+
const bindingPath = (principal) => join30(authority.decode(principal).sessionDirectory, sessionBindingFile);
|
|
12602
|
+
return {
|
|
12603
|
+
resolveSessionFile(principal) {
|
|
12604
|
+
return authority.decode(principal).sessionFile;
|
|
12605
|
+
},
|
|
12606
|
+
async load(principal) {
|
|
12607
|
+
try {
|
|
12608
|
+
const value = JSON.parse(await readFile17(bindingPath(principal), "utf8"));
|
|
12609
|
+
if (typeof value !== "object" || value === null || typeof value.sessionId !== "string") {
|
|
12610
|
+
throw new Error("durable session binding is invalid");
|
|
12611
|
+
}
|
|
12612
|
+
return value.sessionId;
|
|
12613
|
+
} catch (error) {
|
|
12614
|
+
if (error.code === "ENOENT") return void 0;
|
|
12615
|
+
throw error;
|
|
12616
|
+
}
|
|
12617
|
+
},
|
|
12618
|
+
async bind(principal, sessionId) {
|
|
12619
|
+
const target = bindingPath(principal);
|
|
12620
|
+
await mkdir3(dirname18(target), { recursive: true });
|
|
12621
|
+
const temporary = `${target}.${process.pid}.tmp`;
|
|
12622
|
+
await writeFile6(temporary, `${JSON.stringify({ sessionId })}
|
|
12623
|
+
`, { encoding: "utf8", mode: 384 });
|
|
12624
|
+
await rename3(temporary, target);
|
|
12625
|
+
}
|
|
12626
|
+
};
|
|
12627
|
+
}
|
|
12628
|
+
async function readStoredHostSessionId(host, authority, principal) {
|
|
12629
|
+
if (host === void 0 || host === DEFAULT_ROLE_TURN_HOST) return void 0;
|
|
12630
|
+
const description = lookupHostDescription(host) ?? lookupHeadlessHostDescription(host);
|
|
12631
|
+
if (description === void 0) return void 0;
|
|
12632
|
+
const sessionId = await createSessionIdentityAuthority(
|
|
12633
|
+
authority,
|
|
12634
|
+
description.sessionBindingFile
|
|
12635
|
+
).load(principal);
|
|
12636
|
+
if (sessionId === void 0 || sessionId === "") return void 0;
|
|
12637
|
+
return sessionId;
|
|
12638
|
+
}
|
|
12639
|
+
var init_session_identity = __esm({
|
|
12640
|
+
"src/session-identity.ts"() {
|
|
12641
|
+
"use strict";
|
|
12642
|
+
init_host_descriptions();
|
|
12643
|
+
}
|
|
12644
|
+
});
|
|
12645
|
+
|
|
12646
|
+
// src/public-cli/process-cancel.ts
|
|
12647
|
+
function processCancelSignalName(signal) {
|
|
12648
|
+
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
12649
|
+
const reason = signal.reason;
|
|
12650
|
+
if (reason === "SIGTERM" || reason === "SIGINT" || reason === "SIGHUP") {
|
|
12651
|
+
return reason;
|
|
12652
|
+
}
|
|
12653
|
+
return void 0;
|
|
12654
|
+
}
|
|
12655
|
+
function processCancelDiagnostic(signalName) {
|
|
12656
|
+
return `ak-role terminated by ${signalName}`;
|
|
12657
|
+
}
|
|
12658
|
+
var init_process_cancel = __esm({
|
|
12659
|
+
"src/public-cli/process-cancel.ts"() {
|
|
12660
|
+
"use strict";
|
|
12661
|
+
}
|
|
12662
|
+
});
|
|
12663
|
+
|
|
12664
|
+
// src/host-session-record.ts
|
|
12665
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
12666
|
+
import {
|
|
12667
|
+
appendFileSync as appendFileSync2,
|
|
12668
|
+
copyFileSync,
|
|
12669
|
+
closeSync,
|
|
12670
|
+
existsSync as existsSync9,
|
|
12671
|
+
openSync,
|
|
12672
|
+
readFileSync as readFileSync3,
|
|
12673
|
+
mkdirSync as mkdirSync3,
|
|
12674
|
+
readdirSync as readdirSync2,
|
|
12675
|
+
rmSync,
|
|
12676
|
+
statSync as statSync4
|
|
12677
|
+
} from "node:fs";
|
|
12678
|
+
import { homedir } from "node:os";
|
|
12679
|
+
import { dirname as dirname19, join as join31 } from "node:path";
|
|
12680
|
+
function declareHostSessionFailure(error) {
|
|
12681
|
+
const message = error instanceof Error ? error.stack || error.message : String(error);
|
|
12682
|
+
process.stderr.write(`[host-session] Dossier record failure: ${message}
|
|
12683
|
+
`);
|
|
12684
|
+
}
|
|
12685
|
+
function sitianReportSafe(input) {
|
|
12686
|
+
try {
|
|
12687
|
+
sitianReport(input);
|
|
12688
|
+
} catch (error) {
|
|
12689
|
+
declareHostSessionFailure(error);
|
|
12690
|
+
}
|
|
12691
|
+
}
|
|
12692
|
+
function findCodexRollout(sessionsDir, sessionId) {
|
|
12693
|
+
if (!existsSync9(sessionsDir)) return void 0;
|
|
12694
|
+
const matches = [];
|
|
12695
|
+
function scan(dir, depth = 0) {
|
|
12696
|
+
if (depth > 6) return;
|
|
12697
|
+
let entries;
|
|
12698
|
+
try {
|
|
12699
|
+
entries = readdirSync2(dir, { withFileTypes: true });
|
|
12700
|
+
} catch {
|
|
12701
|
+
return;
|
|
12702
|
+
}
|
|
12703
|
+
for (const entry of entries) {
|
|
12704
|
+
const fullPath = join31(dir, entry.name);
|
|
12705
|
+
if (entry.isDirectory()) {
|
|
12706
|
+
scan(fullPath, depth + 1);
|
|
12707
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)) {
|
|
12708
|
+
try {
|
|
12709
|
+
const stat2 = statSync4(fullPath);
|
|
12710
|
+
matches.push({ path: fullPath, mtime: stat2.mtimeMs });
|
|
12711
|
+
} catch {
|
|
12712
|
+
matches.push({ path: fullPath, mtime: 0 });
|
|
12713
|
+
}
|
|
12714
|
+
}
|
|
12715
|
+
}
|
|
12716
|
+
}
|
|
12717
|
+
scan(sessionsDir);
|
|
12718
|
+
if (matches.length === 0 || matches[0] === void 0) return void 0;
|
|
12719
|
+
matches.sort((a, b) => b.mtime - a.mtime);
|
|
12720
|
+
return matches[0]?.path;
|
|
12721
|
+
}
|
|
12722
|
+
function sanitizeClaudeCwd(cwd) {
|
|
12723
|
+
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
12724
|
+
}
|
|
12725
|
+
function resolveNativeSessionPath(options) {
|
|
12726
|
+
const home = options.home || homedir();
|
|
12727
|
+
if (options.host === "claude") {
|
|
12728
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join31(home, ".claude");
|
|
12729
|
+
const sanitizedCwd = sanitizeClaudeCwd(options.cwd);
|
|
12730
|
+
return join31(configDir, "projects", sanitizedCwd, `${options.sessionId}.jsonl`);
|
|
12731
|
+
}
|
|
12732
|
+
if (options.host === "codex") {
|
|
12733
|
+
return findCodexRollout(codexSessionsDirectory(home), options.sessionId);
|
|
12734
|
+
}
|
|
12735
|
+
if (options.host === "grok-build") {
|
|
12736
|
+
const grokHome = process.env.GROK_HOME || join31(home, ".grok");
|
|
12737
|
+
return join31(grokHome, "sessions", encodeURIComponent(options.cwd), options.sessionId);
|
|
12738
|
+
}
|
|
12739
|
+
return void 0;
|
|
12740
|
+
}
|
|
12741
|
+
function codexSessionsDirectory(home) {
|
|
12742
|
+
return join31(process.env.CODEX_HOME || join31(home || homedir(), ".codex"), "sessions");
|
|
12743
|
+
}
|
|
12744
|
+
function recordRunStart(runDirectory) {
|
|
12745
|
+
try {
|
|
12746
|
+
appendFileSync2(join31(runDirectory, ".run-starts"), "\n");
|
|
12747
|
+
} catch (error) {
|
|
12748
|
+
declareHostSessionFailure(error);
|
|
12749
|
+
}
|
|
12750
|
+
}
|
|
12751
|
+
function resolveHostDossierLandingPath(options) {
|
|
12752
|
+
const sanitizedModel = (options.model?.model ?? "default").replace(/[\/\\]+/g, "-");
|
|
12753
|
+
let maxOrdinal = 0;
|
|
12754
|
+
if (existsSync9(options.sessionDirectory)) {
|
|
12755
|
+
try {
|
|
12756
|
+
const entries = readdirSync2(options.sessionDirectory);
|
|
12757
|
+
for (const entry of entries) {
|
|
12758
|
+
const match = entry.match(/-(\d+)(?:\.jsonl|\.failed)?$/);
|
|
12759
|
+
const first = match?.[1];
|
|
12760
|
+
if (first !== void 0) {
|
|
12761
|
+
const val = parseInt(first, 10);
|
|
12762
|
+
if (!isNaN(val) && val > maxOrdinal) {
|
|
12763
|
+
maxOrdinal = val;
|
|
12764
|
+
}
|
|
12765
|
+
}
|
|
12766
|
+
}
|
|
12767
|
+
} catch {
|
|
12768
|
+
}
|
|
12769
|
+
}
|
|
12770
|
+
const startsPath = join31(dirname19(options.sessionDirectory), ".run-starts");
|
|
12771
|
+
let starts = 0;
|
|
12772
|
+
if (existsSync9(startsPath)) starts = readFileSync3(startsPath, "utf8").length;
|
|
12773
|
+
const ordinal = Math.max(maxOrdinal + 1, starts, options.continuation.kind === "resume" ? 2 : 1);
|
|
12774
|
+
const baseName = `${options.host}-${sanitizedModel}-${ordinal}`;
|
|
12775
|
+
const landingPath = options.host === "grok-build" ? join31(options.sessionDirectory, baseName) : join31(options.sessionDirectory, `${baseName}.jsonl`);
|
|
12776
|
+
return { landingPath, ordinal, sanitizedModel };
|
|
12777
|
+
}
|
|
12778
|
+
function recordNativeSessionPointer(options) {
|
|
12779
|
+
if (options.host === "pi" || options.host === "hermes") {
|
|
12780
|
+
return void 0;
|
|
12571
12781
|
}
|
|
12572
12782
|
const nativePath = options.host === "codex" ? codexSessionsDirectory(options.home) : resolveNativeSessionPath(options);
|
|
12573
12783
|
if (nativePath === void 0) return void 0;
|
|
@@ -12588,25 +12798,25 @@ function recordNativeSessionPointer(options) {
|
|
|
12588
12798
|
}
|
|
12589
12799
|
function copyFileCloneOrFallback(src, dest) {
|
|
12590
12800
|
try {
|
|
12591
|
-
const res =
|
|
12801
|
+
const res = spawnSync2("cp", ["-c", src, dest]);
|
|
12592
12802
|
if (res.status === 0) return;
|
|
12593
12803
|
} catch {
|
|
12594
12804
|
}
|
|
12595
12805
|
copyFileSync(src, dest);
|
|
12596
12806
|
}
|
|
12597
12807
|
function copyGrokDossier(srcDir, destDir) {
|
|
12598
|
-
const chatHistorySrc =
|
|
12808
|
+
const chatHistorySrc = join31(srcDir, "chat_history.jsonl");
|
|
12599
12809
|
if (!existsSync9(chatHistorySrc)) {
|
|
12600
12810
|
throw new Error(`Grok native chat_history.jsonl missing at ${chatHistorySrc}`);
|
|
12601
12811
|
}
|
|
12602
12812
|
mkdirSync3(destDir, { recursive: true });
|
|
12603
|
-
const chatHistoryDest =
|
|
12813
|
+
const chatHistoryDest = join31(destDir, "chat_history.jsonl");
|
|
12604
12814
|
copyFileCloneOrFallback(chatHistorySrc, chatHistoryDest);
|
|
12605
|
-
const usageSrc =
|
|
12815
|
+
const usageSrc = join31(srcDir, "usage.json");
|
|
12606
12816
|
if (!existsSync9(usageSrc)) {
|
|
12607
12817
|
throw new Error(`Grok native usage.json missing at ${usageSrc}`);
|
|
12608
12818
|
}
|
|
12609
|
-
copyFileCloneOrFallback(usageSrc,
|
|
12819
|
+
copyFileCloneOrFallback(usageSrc, join31(destDir, "usage.json"));
|
|
12610
12820
|
}
|
|
12611
12821
|
function copyAndRecordHostDossier(options) {
|
|
12612
12822
|
if (options.host === "pi" || options.host === "hermes") {
|
|
@@ -12681,7 +12891,7 @@ function copyAndRecordHostDossier(options) {
|
|
|
12681
12891
|
}
|
|
12682
12892
|
try {
|
|
12683
12893
|
mkdirSync3(options.sessionDirectory, { recursive: true });
|
|
12684
|
-
closeSync(openSync(
|
|
12894
|
+
closeSync(openSync(join31(options.sessionDirectory, `${options.host}-${sanitizedModel}-${ordinal}.failed`), "a"));
|
|
12685
12895
|
} catch {
|
|
12686
12896
|
}
|
|
12687
12897
|
sitianReportSafe({
|
|
@@ -12714,8 +12924,8 @@ var init_host_session_record = __esm({
|
|
|
12714
12924
|
// src/public-cli/auto-resume.ts
|
|
12715
12925
|
import { constants as fsConstants2 } from "node:fs";
|
|
12716
12926
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
12717
|
-
import { lstat as
|
|
12718
|
-
import { join as
|
|
12927
|
+
import { lstat as lstat5, mkdir as mkdir4, open } from "node:fs/promises";
|
|
12928
|
+
import { join as join32 } from "node:path";
|
|
12719
12929
|
async function persistReturnedRunState(admitted, options) {
|
|
12720
12930
|
if (options?.lawful === true) {
|
|
12721
12931
|
await markRunTerminal(admitted.runDirectory);
|
|
@@ -12749,20 +12959,20 @@ async function finalizeExceptionRunBestEffort(runDirectory, io) {
|
|
|
12749
12959
|
}
|
|
12750
12960
|
}
|
|
12751
12961
|
async function ensureRealArtifactsDirectory(runDirectory) {
|
|
12752
|
-
const runStat = await
|
|
12962
|
+
const runStat = await lstat5(runDirectory);
|
|
12753
12963
|
if (runStat.isSymbolicLink() || !runStat.isDirectory()) {
|
|
12754
12964
|
throw new Error("run artifact retention: run directory is not a real directory");
|
|
12755
12965
|
}
|
|
12756
12966
|
const artifactsDir = roleRunArtifactsDirectory(runDirectory);
|
|
12757
12967
|
try {
|
|
12758
|
-
const existing = await
|
|
12968
|
+
const existing = await lstat5(artifactsDir);
|
|
12759
12969
|
if (existing.isSymbolicLink() || !existing.isDirectory()) {
|
|
12760
12970
|
throw new Error("run artifact retention: artifacts path is not a real directory");
|
|
12761
12971
|
}
|
|
12762
12972
|
} catch (error) {
|
|
12763
12973
|
if (!isMissingPathError5(error)) throw error;
|
|
12764
|
-
await
|
|
12765
|
-
const created = await
|
|
12974
|
+
await mkdir4(artifactsDir, { recursive: true });
|
|
12975
|
+
const created = await lstat5(artifactsDir);
|
|
12766
12976
|
if (created.isSymbolicLink() || !created.isDirectory()) {
|
|
12767
12977
|
throw new Error("run artifact retention: artifacts directory is not a real directory");
|
|
12768
12978
|
}
|
|
@@ -12784,7 +12994,7 @@ function jsonSafeReplacer() {
|
|
|
12784
12994
|
};
|
|
12785
12995
|
}
|
|
12786
12996
|
async function writeHardenedArtifactFile(artifactsDir, namePrefix, payload) {
|
|
12787
|
-
const filePath =
|
|
12997
|
+
const filePath = join32(artifactsDir, `${namePrefix}-${randomUUID6()}.json`);
|
|
12788
12998
|
const body = `${JSON.stringify(payload, jsonSafeReplacer(), 2)}
|
|
12789
12999
|
`;
|
|
12790
13000
|
const noFollowFlag = typeof fsConstants2.O_NOFOLLOW === "number" ? fsConstants2.O_NOFOLLOW : 0;
|
|
@@ -13039,7 +13249,7 @@ var init_auto_resume = __esm({
|
|
|
13039
13249
|
// src/public-cli/post-admission.ts
|
|
13040
13250
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
13041
13251
|
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
13042
|
-
import { isAbsolute as isAbsolute7, join as
|
|
13252
|
+
import { isAbsolute as isAbsolute7, join as join33, resolve as resolve13 } from "node:path";
|
|
13043
13253
|
function describeCaughtError(error) {
|
|
13044
13254
|
if (error instanceof Error) {
|
|
13045
13255
|
const code = error.code;
|
|
@@ -13134,12 +13344,10 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
13134
13344
|
} catch (appendError) {
|
|
13135
13345
|
try {
|
|
13136
13346
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
13137
|
-
await
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
{ encoding: "utf8", flag: "wx" }
|
|
13142
|
-
);
|
|
13347
|
+
await writeHardenedArtifactFile(artifactsDir, "post-admission-diagnostic", {
|
|
13348
|
+
version: 1,
|
|
13349
|
+
...payload
|
|
13350
|
+
});
|
|
13143
13351
|
} catch (artifactError) {
|
|
13144
13352
|
retentionFailure = `post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`;
|
|
13145
13353
|
}
|
|
@@ -13276,7 +13484,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13276
13484
|
const rows = await readRecordedSubmissionRows(
|
|
13277
13485
|
admitted.projectRoot,
|
|
13278
13486
|
admitted.runId,
|
|
13279
|
-
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent:
|
|
13487
|
+
{ home: homeFromRunDirectory(admitted.runDirectory), sessionParent: join33(admitted.runDirectory, "session", "session.jsonl") }
|
|
13280
13488
|
);
|
|
13281
13489
|
let ticketNumber;
|
|
13282
13490
|
for (const row of rows) {
|
|
@@ -13403,7 +13611,7 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
13403
13611
|
let stderrLogWriteFailure;
|
|
13404
13612
|
try {
|
|
13405
13613
|
await writeFile7(
|
|
13406
|
-
|
|
13614
|
+
join33(admitted.runDirectory, "stderr.log"),
|
|
13407
13615
|
result.stderr,
|
|
13408
13616
|
"utf8"
|
|
13409
13617
|
);
|
|
@@ -13637,13 +13845,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
13637
13845
|
prompt = "";
|
|
13638
13846
|
}
|
|
13639
13847
|
return {
|
|
13640
|
-
|
|
13641
|
-
home: env.home,
|
|
13848
|
+
...projectPublicTurnAxes(env),
|
|
13642
13849
|
...env.host === void 0 ? {} : { host: env.host },
|
|
13643
|
-
agentDir: env.agentDir,
|
|
13644
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
13645
|
-
...pickEngineAxis(env),
|
|
13646
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
13647
13850
|
...env.correlationId === void 0 && admitted.correlationId === void 0 ? {} : { correlationId: env.correlationId ?? admitted.correlationId },
|
|
13648
13851
|
continuation: {
|
|
13649
13852
|
kind: "resume",
|
|
@@ -13656,13 +13859,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
13656
13859
|
function roleTurnOptions(env, admitted, continuation) {
|
|
13657
13860
|
const correlationId = env.correlationId ?? admitted.correlationId;
|
|
13658
13861
|
return {
|
|
13659
|
-
|
|
13660
|
-
home: env.home,
|
|
13862
|
+
...projectPublicTurnAxes(env),
|
|
13661
13863
|
...env.host === void 0 ? {} : { host: env.host },
|
|
13662
|
-
agentDir: env.agentDir,
|
|
13663
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
13664
|
-
...pickEngineAxis(env),
|
|
13665
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
13666
13864
|
...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
|
|
13667
13865
|
continuation,
|
|
13668
13866
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
@@ -13680,9 +13878,46 @@ async function dispatchAfterWriterLease(input) {
|
|
|
13680
13878
|
}
|
|
13681
13879
|
}
|
|
13682
13880
|
}
|
|
13881
|
+
async function runSettledAutoResumeLoop(input) {
|
|
13882
|
+
const adapters = withOnceSuccessfulBeforeDispatch(input.adapters);
|
|
13883
|
+
const dispatchEnv = input.dispatchEnv ?? input.env;
|
|
13884
|
+
return runWithAutoResumeLoop({
|
|
13885
|
+
admitted: input.admitted,
|
|
13886
|
+
principalAuthority: input.env.principalAuthority,
|
|
13887
|
+
io: input.io,
|
|
13888
|
+
sessionAppender: input.env.sessionAppender,
|
|
13889
|
+
autoResumeLimit: input.env.autoResumeLimit,
|
|
13890
|
+
...input.env.signal === void 0 ? {} : { signal: input.env.signal },
|
|
13891
|
+
buildInitialPayload: input.buildInitialPayload,
|
|
13892
|
+
buildResumePayload: input.buildResumePayload,
|
|
13893
|
+
dispatch: async (payload, lease, _isFirst, attemptIo) => dispatchAfterWriterLease({
|
|
13894
|
+
...lease === void 0 ? {} : { lease },
|
|
13895
|
+
build: () => input.toRequest(payload),
|
|
13896
|
+
dispatch: async (request) => {
|
|
13897
|
+
const result = await dispatchPostAdmissionTurn({
|
|
13898
|
+
admitted: input.admitted,
|
|
13899
|
+
env: dispatchEnv,
|
|
13900
|
+
io: attemptIo,
|
|
13901
|
+
request,
|
|
13902
|
+
...lease === void 0 ? {} : { lease },
|
|
13903
|
+
adapters,
|
|
13904
|
+
persistRunState: false,
|
|
13905
|
+
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
13906
|
+
});
|
|
13907
|
+
return settleDeferredPersist(
|
|
13908
|
+
input.admitted,
|
|
13909
|
+
input.env.principalAuthority,
|
|
13910
|
+
adapters,
|
|
13911
|
+
attemptIo,
|
|
13912
|
+
result
|
|
13913
|
+
);
|
|
13914
|
+
}
|
|
13915
|
+
})
|
|
13916
|
+
});
|
|
13917
|
+
}
|
|
13683
13918
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
13684
13919
|
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve13(attachmentPath);
|
|
13685
|
-
return pathContainedIn(
|
|
13920
|
+
return pathContainedIn(join33(runDirectory, "attachments"), absolute);
|
|
13686
13921
|
}
|
|
13687
13922
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
13688
13923
|
if (summons === void 0) return void 0;
|
|
@@ -13793,60 +14028,34 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
13793
14028
|
try {
|
|
13794
14029
|
if (env.stationChild === true) {
|
|
13795
14030
|
let firstTurn;
|
|
13796
|
-
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
13797
14031
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
13798
14032
|
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
13799
14033
|
});
|
|
13800
|
-
return await
|
|
14034
|
+
return await runSettledAutoResumeLoop({
|
|
13801
14035
|
admitted: loaded.admitted,
|
|
13802
|
-
|
|
14036
|
+
env,
|
|
13803
14037
|
io: input.io,
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
14038
|
+
adapters,
|
|
14039
|
+
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
|
|
13807
14040
|
buildInitialPayload: () => ({ resumeTurn: false }),
|
|
13808
14041
|
buildResumePayload: () => ({ resumeTurn: true }),
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
kind: "resume",
|
|
13819
|
-
prompt: RESUME_TRANSPORT_ENVELOPE
|
|
13820
|
-
}
|
|
13821
|
-
};
|
|
13822
|
-
}
|
|
13823
|
-
const turnRequest = withEngineDetourInvocationScope(
|
|
13824
|
-
await buildRequestAfterLease(),
|
|
13825
|
-
invocationScopeId
|
|
13826
|
-
);
|
|
13827
|
-
firstTurn = turnRequest;
|
|
13828
|
-
return turnRequest;
|
|
13829
|
-
},
|
|
13830
|
-
dispatch: async (turnRequest) => {
|
|
13831
|
-
const result = await dispatchPostAdmissionTurn({
|
|
13832
|
-
admitted: loaded.admitted,
|
|
13833
|
-
env,
|
|
13834
|
-
io: attemptIo,
|
|
13835
|
-
request: turnRequest,
|
|
13836
|
-
...lease === void 0 ? {} : { lease },
|
|
13837
|
-
adapters: stationAdapters,
|
|
13838
|
-
persistRunState: false,
|
|
13839
|
-
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
13840
|
-
});
|
|
13841
|
-
return settleDeferredPersist(
|
|
13842
|
-
loaded.admitted,
|
|
13843
|
-
env.principalAuthority,
|
|
13844
|
-
stationAdapters,
|
|
13845
|
-
attemptIo,
|
|
13846
|
-
result
|
|
13847
|
-
);
|
|
14042
|
+
toRequest: async (payload) => {
|
|
14043
|
+
if (payload.resumeTurn && firstTurn !== void 0) {
|
|
14044
|
+
return {
|
|
14045
|
+
...firstTurn,
|
|
14046
|
+
continuation: {
|
|
14047
|
+
kind: "resume",
|
|
14048
|
+
prompt: RESUME_TRANSPORT_ENVELOPE
|
|
14049
|
+
}
|
|
14050
|
+
};
|
|
13848
14051
|
}
|
|
13849
|
-
|
|
14052
|
+
const turnRequest = withEngineDetourInvocationScope(
|
|
14053
|
+
await buildRequestAfterLease(),
|
|
14054
|
+
invocationScopeId
|
|
14055
|
+
);
|
|
14056
|
+
firstTurn = turnRequest;
|
|
14057
|
+
return turnRequest;
|
|
14058
|
+
}
|
|
13850
14059
|
});
|
|
13851
14060
|
}
|
|
13852
14061
|
const resumed = await runPostAdmissionManualResume({
|
|
@@ -13937,7 +14146,7 @@ async function presentResumeFailurePointer(io, thrown, publish) {
|
|
|
13937
14146
|
}
|
|
13938
14147
|
async function writeResumeDiagnosticFile(runDirectory, runId, failure, role) {
|
|
13939
14148
|
const dir = await ensureRealArtifactsDirectory(runDirectory);
|
|
13940
|
-
const path =
|
|
14149
|
+
const path = join33(dir, `resume-diagnostic-${randomUUID7()}.json`);
|
|
13941
14150
|
await writeFile7(
|
|
13942
14151
|
path,
|
|
13943
14152
|
`${JSON.stringify({
|
|
@@ -13978,368 +14187,115 @@ async function runPostAdmissionOneShot(input) {
|
|
|
13978
14187
|
}
|
|
13979
14188
|
async function runPostAdmissionResumable(input) {
|
|
13980
14189
|
const { admitted, env, io, buildInitialRequest, buildResumeRequest, effectiveEngine } = input;
|
|
13981
|
-
const adapters = withOnceSuccessfulBeforeDispatch(input.adapters);
|
|
13982
14190
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
13983
14191
|
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
13984
14192
|
});
|
|
13985
14193
|
const buildScopedInitial = () => withEngineDetourInvocationScope(buildInitialRequest(), invocationScopeId);
|
|
13986
14194
|
const buildScopedResume = () => withEngineDetourInvocationScope(buildResumeRequest(), invocationScopeId);
|
|
13987
|
-
return
|
|
14195
|
+
return runSettledAutoResumeLoop({
|
|
13988
14196
|
admitted,
|
|
13989
|
-
|
|
14197
|
+
env,
|
|
13990
14198
|
io,
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
buildResumePayload: buildScopedResume,
|
|
13996
|
-
dispatch: async (request, lease, _isFirst, attemptIo) => {
|
|
13997
|
-
const result = await dispatchPostAdmissionTurn({
|
|
13998
|
-
admitted,
|
|
13999
|
-
env: {
|
|
14000
|
-
...env,
|
|
14001
|
-
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
14002
|
-
},
|
|
14003
|
-
io: attemptIo,
|
|
14004
|
-
request,
|
|
14005
|
-
...lease === void 0 ? {} : { lease },
|
|
14006
|
-
adapters,
|
|
14007
|
-
persistRunState: false,
|
|
14008
|
-
// #600: every attempt (initial + auto-resume) writes seat engine when present.
|
|
14009
|
-
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
14010
|
-
});
|
|
14011
|
-
return settleDeferredPersist(admitted, env.principalAuthority, adapters, attemptIo, result);
|
|
14012
|
-
}
|
|
14013
|
-
});
|
|
14014
|
-
}
|
|
14015
|
-
async function runPostAdmissionManualResume(input) {
|
|
14016
|
-
const {
|
|
14017
|
-
admitted,
|
|
14018
|
-
env,
|
|
14019
|
-
io,
|
|
14020
|
-
adapters,
|
|
14021
|
-
effectiveEngine,
|
|
14022
|
-
buildRequestAfterLease
|
|
14023
|
-
} = input;
|
|
14024
|
-
let request = input.request;
|
|
14025
|
-
const effectiveModel = env.model;
|
|
14026
|
-
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
14027
|
-
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
14028
|
-
});
|
|
14029
|
-
if (request === void 0) {
|
|
14030
|
-
if (buildRequestAfterLease === void 0) {
|
|
14031
|
-
throw new Error(
|
|
14032
|
-
"runPostAdmissionManualResume requires request or buildRequestAfterLease"
|
|
14033
|
-
);
|
|
14034
|
-
}
|
|
14035
|
-
request = await buildRequestAfterLease();
|
|
14036
|
-
}
|
|
14037
|
-
request = withEngineDetourInvocationScope(request, invocationScopeId);
|
|
14038
|
-
const result = await dispatchPostAdmissionTurn({
|
|
14039
|
-
admitted,
|
|
14040
|
-
env: {
|
|
14199
|
+
adapters: input.adapters,
|
|
14200
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine },
|
|
14201
|
+
// Ordinary in-call retry keeps the admitted correlation when one was stored.
|
|
14202
|
+
dispatchEnv: {
|
|
14041
14203
|
...env,
|
|
14042
|
-
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
14043
14204
|
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
14044
14205
|
},
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
});
|
|
14050
|
-
if (result.terminal !== void 0 && isLawfulTypedTerminalOutcome(result.terminal.roleOutcome)) {
|
|
14051
|
-
io.stdout(formatTerminalResult(result.terminal));
|
|
14052
|
-
}
|
|
14053
|
-
if (result.terminal !== void 0) {
|
|
14054
|
-
result.terminal.autoResumeCount = 0;
|
|
14055
|
-
}
|
|
14056
|
-
return result;
|
|
14057
|
-
}
|
|
14058
|
-
var POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE;
|
|
14059
|
-
var init_post_admission = __esm({
|
|
14060
|
-
"src/public-cli/post-admission.ts"() {
|
|
14061
|
-
"use strict";
|
|
14062
|
-
init_run_lifecycle();
|
|
14063
|
-
init_cli_errors();
|
|
14064
|
-
init_invocation();
|
|
14065
|
-
init_submission_ledger();
|
|
14066
|
-
init_run_ticket_number();
|
|
14067
|
-
init_activation_ledger_topology();
|
|
14068
|
-
init_engine_material();
|
|
14069
|
-
init_session_identity();
|
|
14070
|
-
init_role_run_relocation();
|
|
14071
|
-
init_packaged_role_registry();
|
|
14072
|
-
init_engine_detour_usage();
|
|
14073
|
-
init_run_lifecycle();
|
|
14074
|
-
init_process_cancel();
|
|
14075
|
-
init_activation_ledger_topology();
|
|
14076
|
-
init_host_session_record();
|
|
14077
|
-
init_settlement();
|
|
14078
|
-
init_terminal();
|
|
14079
|
-
init_auto_resume();
|
|
14080
|
-
POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE = "ak_post_admission_cleanup_diagnostic";
|
|
14081
|
-
}
|
|
14082
|
-
});
|
|
14083
|
-
|
|
14084
|
-
// src/public-cli/seat-ticket-binding.ts
|
|
14085
|
-
async function tryResumeSameTicketSeatRun(input) {
|
|
14086
|
-
if (input.freshSummons === true) return void 0;
|
|
14087
|
-
if (input.parentRunPath.trim() === "") return void 0;
|
|
14088
|
-
const previousRunId = await findLatestRunIdForSeatTicket({
|
|
14089
|
-
home: input.home,
|
|
14090
|
-
bookKey: resolveBookKeyFromGit(input.projectRoot),
|
|
14091
|
-
role: input.role,
|
|
14092
|
-
parentRunPath: input.parentRunPath,
|
|
14093
|
-
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
|
|
14094
|
-
});
|
|
14095
|
-
if (previousRunId === void 0) return void 0;
|
|
14096
|
-
return await input.resume(previousRunId, input.summons);
|
|
14097
|
-
}
|
|
14098
|
-
var init_seat_ticket_binding = __esm({
|
|
14099
|
-
"src/public-cli/seat-ticket-binding.ts"() {
|
|
14100
|
-
"use strict";
|
|
14101
|
-
init_activation_ledger_git();
|
|
14102
|
-
init_run_lifecycle();
|
|
14103
|
-
}
|
|
14104
|
-
});
|
|
14105
|
-
|
|
14106
|
-
// src/public-cli/machine-method-skills.ts
|
|
14107
|
-
import { accessSync, constants as constants2, statSync as statSync4 } from "node:fs";
|
|
14108
|
-
import { lstat as lstat5, mkdir as mkdir4, symlink } from "node:fs/promises";
|
|
14109
|
-
import { join as join33 } from "node:path";
|
|
14110
|
-
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
14111
|
-
function skillRoot(home) {
|
|
14112
|
-
return join33(home, ".agents/skills");
|
|
14113
|
-
}
|
|
14114
|
-
function installedMethodSkillPath(home, name) {
|
|
14115
|
-
return installedSkillPath(skillRoot(home), name);
|
|
14116
|
-
}
|
|
14117
|
-
function installedSkillPath(root, name) {
|
|
14118
|
-
const path = join33(root, name, "SKILL.md");
|
|
14119
|
-
try {
|
|
14120
|
-
if (!statSync4(path).isFile()) return void 0;
|
|
14121
|
-
accessSync(path, constants2.R_OK);
|
|
14122
|
-
return path;
|
|
14123
|
-
} catch (error) {
|
|
14124
|
-
const code = error.code;
|
|
14125
|
-
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM" || code === "ELOOP") return void 0;
|
|
14126
|
-
throw error;
|
|
14127
|
-
}
|
|
14128
|
-
}
|
|
14129
|
-
function linkedSkillRoot(home, host) {
|
|
14130
|
-
if (host === "claude" || host === "claude-code") {
|
|
14131
|
-
return join33(process.env.CLAUDE_CONFIG_DIR?.trim() || join33(home, ".claude"), "skills");
|
|
14132
|
-
}
|
|
14133
|
-
if (host === "hermes") return join33(home, ".hermes/skills");
|
|
14134
|
-
return void 0;
|
|
14135
|
-
}
|
|
14136
|
-
async function occupied(path) {
|
|
14137
|
-
try {
|
|
14138
|
-
await lstat5(path);
|
|
14139
|
-
return true;
|
|
14140
|
-
} catch (error) {
|
|
14141
|
-
if (error.code !== "ENOENT") throw error;
|
|
14142
|
-
return false;
|
|
14143
|
-
}
|
|
14144
|
-
}
|
|
14145
|
-
function warnOccupied(path, stdout) {
|
|
14146
|
-
stdout(`Warning: ${path} is already occupied; left untouched.
|
|
14147
|
-
`);
|
|
14148
|
-
}
|
|
14149
|
-
async function warnMissingMethodSkills(home, host, role, skills, stdout) {
|
|
14150
|
-
const missing = [];
|
|
14151
|
-
const linkedRoot = linkedSkillRoot(home, host);
|
|
14152
|
-
for (const skill of skills) {
|
|
14153
|
-
if (installedMethodSkillPath(home, skill) === void 0 || linkedRoot !== void 0 && installedSkillPath(linkedRoot, skill) === void 0) missing.push(skill);
|
|
14154
|
-
}
|
|
14155
|
-
for (const skill of missing) {
|
|
14156
|
-
stdout(`Warning: required machine Skill "${skill}" is missing for ${role}; its method guidance may be unavailable and reduce work quality. Run \`ak-role setup\` to install required Skills.
|
|
14157
|
-
`);
|
|
14158
|
-
}
|
|
14159
|
-
}
|
|
14160
|
-
function runSkillsCli(args, home) {
|
|
14161
|
-
const result = spawnSync2("npx", ["--yes", "skills", ...args], {
|
|
14162
|
-
stdio: "inherit",
|
|
14163
|
-
env: { ...process.env, HOME: home }
|
|
14164
|
-
});
|
|
14165
|
-
if (result.error !== void 0) throw result.error;
|
|
14166
|
-
return result.status === 0;
|
|
14167
|
-
}
|
|
14168
|
-
function addSkills(source, skills, home) {
|
|
14169
|
-
if (skills.length === 0) return true;
|
|
14170
|
-
return runSkillsCli([
|
|
14171
|
-
"add",
|
|
14172
|
-
source,
|
|
14173
|
-
...skills.flatMap((skill) => ["--skill", skill]),
|
|
14174
|
-
"--agent",
|
|
14175
|
-
"codex",
|
|
14176
|
-
"--global",
|
|
14177
|
-
"--yes"
|
|
14178
|
-
], home);
|
|
14179
|
-
}
|
|
14180
|
-
function updateRequiredSkills(home) {
|
|
14181
|
-
const names = packagedMethodSkillNames();
|
|
14182
|
-
if (names.length === 0) return true;
|
|
14183
|
-
return runSkillsCli(["update", "-g", "-y", ...names], home);
|
|
14184
|
-
}
|
|
14185
|
-
async function runMachineSkillSetup(home, stdout) {
|
|
14186
|
-
const canonical = skillRoot(home);
|
|
14187
|
-
const missingBySource = /* @__PURE__ */ new Map();
|
|
14188
|
-
let unsourced = false;
|
|
14189
|
-
for (const name of packagedMethodSkillNames()) {
|
|
14190
|
-
const path = join33(canonical, name);
|
|
14191
|
-
if (await occupied(path)) {
|
|
14192
|
-
warnOccupied(path, stdout);
|
|
14193
|
-
continue;
|
|
14194
|
-
}
|
|
14195
|
-
const source = SKILL_SOURCE[name];
|
|
14196
|
-
if (source === void 0) {
|
|
14197
|
-
unsourced = true;
|
|
14198
|
-
stdout(`Warning: required machine Skill "${name}" has no install source; setup did not install it.
|
|
14199
|
-
`);
|
|
14200
|
-
continue;
|
|
14201
|
-
}
|
|
14202
|
-
const missing = missingBySource.get(source) ?? [];
|
|
14203
|
-
missing.push(name);
|
|
14204
|
-
missingBySource.set(source, missing);
|
|
14205
|
-
}
|
|
14206
|
-
for (const [source, missing] of missingBySource) {
|
|
14207
|
-
if (!addSkills(source, missing, home)) return 1;
|
|
14208
|
-
}
|
|
14209
|
-
if (unsourced) return 1;
|
|
14210
|
-
for (const host of ["claude-code", "hermes"]) {
|
|
14211
|
-
const root = linkedSkillRoot(home, host);
|
|
14212
|
-
const description = host === "claude-code" ? HEADLESS_HOST_DESCRIPTIONS.claude : HOST_DESCRIPTIONS.hermes;
|
|
14213
|
-
try {
|
|
14214
|
-
accessSync(resolveHostBinary(description, home), constants2.X_OK);
|
|
14215
|
-
} catch (error) {
|
|
14216
|
-
if (["ENOENT", "ENOTDIR", "EACCES"].includes(error.code ?? "")) continue;
|
|
14217
|
-
throw error;
|
|
14218
|
-
}
|
|
14219
|
-
for (const name of packagedMethodSkillNames()) {
|
|
14220
|
-
const target = join33(canonical, name);
|
|
14221
|
-
if (installedMethodSkillPath(home, name) === void 0) continue;
|
|
14222
|
-
const link = join33(root, name);
|
|
14223
|
-
if (await occupied(link)) {
|
|
14224
|
-
warnOccupied(link, stdout);
|
|
14225
|
-
continue;
|
|
14226
|
-
}
|
|
14227
|
-
await mkdir4(root, { recursive: true });
|
|
14228
|
-
await symlink(target, link, "dir");
|
|
14229
|
-
}
|
|
14230
|
-
}
|
|
14231
|
-
if (!updateRequiredSkills(home)) return 1;
|
|
14232
|
-
stdout("Machine method Skills setup finished. Existing same-name Skills were left untouched.\n");
|
|
14233
|
-
return 0;
|
|
14234
|
-
}
|
|
14235
|
-
var SKILL_SOURCE;
|
|
14236
|
-
var init_machine_method_skills = __esm({
|
|
14237
|
-
"src/public-cli/machine-method-skills.ts"() {
|
|
14238
|
-
"use strict";
|
|
14239
|
-
init_host_descriptions();
|
|
14240
|
-
init_packaged_role_registry();
|
|
14241
|
-
SKILL_SOURCE = {
|
|
14242
|
-
tdd: "mattpocock/skills",
|
|
14243
|
-
"diagnosing-bugs": "mattpocock/skills",
|
|
14244
|
-
"resolving-merge-conflicts": "mattpocock/skills",
|
|
14245
|
-
"ak-cross-m-review": "Akagilnc/ak-cross-m-review"
|
|
14246
|
-
};
|
|
14247
|
-
}
|
|
14248
|
-
});
|
|
14249
|
-
|
|
14250
|
-
// src/public-cli/turn-request.ts
|
|
14251
|
-
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
14252
|
-
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
14253
|
-
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
14254
|
-
if (admitted.principal === void 0) throw new Error("admitted invocation missing principal");
|
|
14255
|
-
return {
|
|
14256
|
-
principal: admitted.principal,
|
|
14257
|
-
activation: roleDetails.activation,
|
|
14258
|
-
methods: roleDetails.methods ?? [],
|
|
14259
|
-
continuation: options.continuation,
|
|
14260
|
-
...options.model === void 0 ? {} : { model: options.model },
|
|
14261
|
-
...pickEngineAxis(options),
|
|
14262
|
-
cwd,
|
|
14263
|
-
home: options.home,
|
|
14264
|
-
agentDir: options.agentDir,
|
|
14265
|
-
runDirectory: admitted.runDirectory,
|
|
14266
|
-
...options.correlationId === void 0 || options.correlationId.trim() === "" ? {} : { correlationId: options.correlationId },
|
|
14267
|
-
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
14268
|
-
...options.courtAttemptId === void 0 || options.courtAttemptId.length === 0 ? {} : { courtAttemptId: options.courtAttemptId },
|
|
14269
|
-
...options.invocationScopeId === void 0 || options.invocationScopeId.length === 0 ? {} : { invocationScopeId: options.invocationScopeId },
|
|
14270
|
-
...options.stationChild === void 0 ? {} : { stationChild: options.stationChild }
|
|
14271
|
-
};
|
|
14272
|
-
}
|
|
14273
|
-
function packagedSettleSkill(admitted) {
|
|
14274
|
-
const record4 = packagedRoleMetadata(admitted.role);
|
|
14275
|
-
if (record4 === void 0) return void 0;
|
|
14276
|
-
if ("applyMethod" in record4 && record4.applyMethod !== void 0) {
|
|
14277
|
-
return "phase" in admitted && admitted.phase === "apply" ? record4.applyMethod : void 0;
|
|
14278
|
-
}
|
|
14279
|
-
if ("settleMethod" in record4 && record4.settleMethod !== void 0) return record4.settleMethod;
|
|
14280
|
-
return void 0;
|
|
14281
|
-
}
|
|
14282
|
-
function readAdmittedPath2(admitted, path) {
|
|
14283
|
-
let current = admitted;
|
|
14284
|
-
for (const key of path.split(".")) {
|
|
14285
|
-
if (current === null || typeof current !== "object") return void 0;
|
|
14286
|
-
current = current[key];
|
|
14287
|
-
}
|
|
14288
|
-
return current;
|
|
14206
|
+
buildInitialPayload: buildScopedInitial,
|
|
14207
|
+
buildResumePayload: buildScopedResume,
|
|
14208
|
+
toRequest: async (request) => request
|
|
14209
|
+
});
|
|
14289
14210
|
}
|
|
14290
|
-
function
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14211
|
+
async function runPostAdmissionManualResume(input) {
|
|
14212
|
+
const {
|
|
14213
|
+
admitted,
|
|
14214
|
+
env,
|
|
14215
|
+
io,
|
|
14216
|
+
adapters,
|
|
14217
|
+
effectiveEngine,
|
|
14218
|
+
buildRequestAfterLease
|
|
14219
|
+
} = input;
|
|
14220
|
+
let request = input.request;
|
|
14221
|
+
const effectiveModel = env.model;
|
|
14222
|
+
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
14223
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
14224
|
+
});
|
|
14225
|
+
if (request === void 0) {
|
|
14226
|
+
if (buildRequestAfterLease === void 0) {
|
|
14227
|
+
throw new Error(
|
|
14228
|
+
"runPostAdmissionManualResume requires request or buildRequestAfterLease"
|
|
14229
|
+
);
|
|
14306
14230
|
}
|
|
14307
|
-
|
|
14308
|
-
}
|
|
14309
|
-
return activation;
|
|
14310
|
-
}
|
|
14311
|
-
function requiredMethodSkills(admitted) {
|
|
14312
|
-
const record4 = packagedRoleMetadata(admitted.role);
|
|
14313
|
-
const names = [];
|
|
14314
|
-
if (record4 !== void 0 && "methodSkills" in record4 && record4.methodSkills !== void 0) {
|
|
14315
|
-
names.push(...record4.methodSkills);
|
|
14231
|
+
request = await buildRequestAfterLease();
|
|
14316
14232
|
}
|
|
14317
|
-
|
|
14318
|
-
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
}
|
|
14233
|
+
request = withEngineDetourInvocationScope(request, invocationScopeId);
|
|
14234
|
+
const result = await dispatchPostAdmissionTurn({
|
|
14235
|
+
admitted,
|
|
14236
|
+
env: {
|
|
14237
|
+
...env,
|
|
14238
|
+
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
14239
|
+
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
14240
|
+
},
|
|
14241
|
+
io,
|
|
14242
|
+
request,
|
|
14243
|
+
adapters,
|
|
14244
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
14329
14245
|
});
|
|
14246
|
+
if (result.terminal !== void 0 && isLawfulTypedTerminalOutcome(result.terminal.roleOutcome)) {
|
|
14247
|
+
io.stdout(formatTerminalResult(result.terminal));
|
|
14248
|
+
}
|
|
14249
|
+
if (result.terminal !== void 0) {
|
|
14250
|
+
result.terminal.autoResumeCount = 0;
|
|
14251
|
+
}
|
|
14252
|
+
return result;
|
|
14330
14253
|
}
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
methods: methodBindings(admitted, home, host)
|
|
14335
|
-
};
|
|
14336
|
-
}
|
|
14337
|
-
var init_turn_request = __esm({
|
|
14338
|
-
"src/public-cli/turn-request.ts"() {
|
|
14254
|
+
var POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE;
|
|
14255
|
+
var init_post_admission = __esm({
|
|
14256
|
+
"src/public-cli/post-admission.ts"() {
|
|
14339
14257
|
"use strict";
|
|
14258
|
+
init_run_lifecycle();
|
|
14259
|
+
init_cli_errors();
|
|
14260
|
+
init_turn_request();
|
|
14261
|
+
init_invocation();
|
|
14262
|
+
init_submission_ledger();
|
|
14263
|
+
init_run_ticket_number();
|
|
14264
|
+
init_activation_ledger_topology();
|
|
14340
14265
|
init_engine_material();
|
|
14266
|
+
init_session_identity();
|
|
14267
|
+
init_role_run_relocation();
|
|
14341
14268
|
init_packaged_role_registry();
|
|
14342
|
-
|
|
14269
|
+
init_engine_detour_usage();
|
|
14270
|
+
init_run_lifecycle();
|
|
14271
|
+
init_process_cancel();
|
|
14272
|
+
init_activation_ledger_topology();
|
|
14273
|
+
init_host_session_record();
|
|
14274
|
+
init_settlement();
|
|
14275
|
+
init_terminal();
|
|
14276
|
+
init_auto_resume();
|
|
14277
|
+
POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE = "ak_post_admission_cleanup_diagnostic";
|
|
14278
|
+
}
|
|
14279
|
+
});
|
|
14280
|
+
|
|
14281
|
+
// src/public-cli/seat-ticket-binding.ts
|
|
14282
|
+
async function tryResumeSameTicketSeatRun(input) {
|
|
14283
|
+
if (input.freshSummons === true) return void 0;
|
|
14284
|
+
if (input.parentRunPath.trim() === "") return void 0;
|
|
14285
|
+
const previousRunId = await findLatestRunIdForSeatTicket({
|
|
14286
|
+
home: input.home,
|
|
14287
|
+
bookKey: resolveBookKeyFromGit(input.projectRoot),
|
|
14288
|
+
role: input.role,
|
|
14289
|
+
parentRunPath: input.parentRunPath,
|
|
14290
|
+
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber }
|
|
14291
|
+
});
|
|
14292
|
+
if (previousRunId === void 0) return void 0;
|
|
14293
|
+
return await input.resume(previousRunId, input.summons);
|
|
14294
|
+
}
|
|
14295
|
+
var init_seat_ticket_binding = __esm({
|
|
14296
|
+
"src/public-cli/seat-ticket-binding.ts"() {
|
|
14297
|
+
"use strict";
|
|
14298
|
+
init_activation_ledger_git();
|
|
14343
14299
|
init_run_lifecycle();
|
|
14344
14300
|
}
|
|
14345
14301
|
});
|
|
@@ -14454,7 +14410,7 @@ __export(instruction_seat_run_exports, {
|
|
|
14454
14410
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
14455
14411
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
14456
14412
|
});
|
|
14457
|
-
import { dirname as dirname20, resolve as resolve14
|
|
14413
|
+
import { dirname as dirname20, resolve as resolve14 } from "node:path";
|
|
14458
14414
|
function unreadablePostSubmissionStatus(admitted, terminal) {
|
|
14459
14415
|
if (terminal?.roleOutcome.kind !== "accepted") return void 0;
|
|
14460
14416
|
const route = POST_SUBMISSION_ROUTING[admitted.role];
|
|
@@ -14686,27 +14642,43 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
|
|
|
14686
14642
|
io.stdout(formatTerminalResult(terminal));
|
|
14687
14643
|
return { exitCode: failed ? 1 : 0, terminal };
|
|
14688
14644
|
}
|
|
14645
|
+
function resumeSameParentInstructionSeat(input) {
|
|
14646
|
+
return tryResumeSameTicketSeatRun({
|
|
14647
|
+
home: input.env.home,
|
|
14648
|
+
projectRoot: input.projectRoot,
|
|
14649
|
+
role: input.role,
|
|
14650
|
+
parentRunPath: input.parentRunPath,
|
|
14651
|
+
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
|
|
14652
|
+
freshSummons: input.env.freshSummons,
|
|
14653
|
+
summons: input.summons,
|
|
14654
|
+
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
14655
|
+
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
14656
|
+
input.env,
|
|
14657
|
+
input.io
|
|
14658
|
+
)
|
|
14659
|
+
});
|
|
14660
|
+
}
|
|
14661
|
+
function sameParentInstruction(env, fallback) {
|
|
14662
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
14663
|
+
if (resumeInstruction === void 0) return fallback;
|
|
14664
|
+
return { instruction: resumeInstruction, instructionEmpty: false };
|
|
14665
|
+
}
|
|
14689
14666
|
async function runCountersignBody(parsed, env, io) {
|
|
14690
14667
|
const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
|
|
14691
14668
|
if (gateParentRunPath !== void 0) {
|
|
14692
14669
|
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction ?? "";
|
|
14693
|
-
const resumed = await
|
|
14694
|
-
|
|
14670
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
14671
|
+
env,
|
|
14672
|
+
io,
|
|
14695
14673
|
projectRoot: resolve14(parsed.project ?? env.cwd),
|
|
14696
14674
|
role: "countersign",
|
|
14697
14675
|
parentRunPath: gateParentRunPath,
|
|
14698
14676
|
...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
|
|
14699
|
-
freshSummons: env.freshSummons,
|
|
14700
14677
|
summons: {
|
|
14701
14678
|
sourceRunPath: gateParentRunPath,
|
|
14702
14679
|
instruction: resumeInstruction,
|
|
14703
14680
|
instructionEmpty: resumeInstruction.trim() === ""
|
|
14704
|
-
}
|
|
14705
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
14706
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
14707
|
-
env,
|
|
14708
|
-
io
|
|
14709
|
-
)
|
|
14681
|
+
}
|
|
14710
14682
|
});
|
|
14711
14683
|
if (resumed != null) return resumed;
|
|
14712
14684
|
}
|
|
@@ -14738,12 +14710,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14738
14710
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
14739
14711
|
}
|
|
14740
14712
|
const turnProjection = {
|
|
14741
|
-
|
|
14742
|
-
home: env.home,
|
|
14743
|
-
agentDir: env.agentDir,
|
|
14744
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
14745
|
-
...pickEngineAxis(env),
|
|
14746
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
14713
|
+
...projectPublicTurnAxes(env),
|
|
14747
14714
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
14748
14715
|
continuation: {
|
|
14749
14716
|
kind: "initial",
|
|
@@ -14814,17 +14781,18 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14814
14781
|
let auditorSubject;
|
|
14815
14782
|
let auditorSource;
|
|
14816
14783
|
let auditorTicket;
|
|
14784
|
+
let resolvedNotarySource;
|
|
14817
14785
|
if (record4.sameParent === "subject-source") {
|
|
14818
|
-
if (
|
|
14786
|
+
if (parsed.subject === void 0) {
|
|
14819
14787
|
presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
|
|
14820
14788
|
return { exitCode: 2 };
|
|
14821
14789
|
}
|
|
14822
14790
|
auditorSubject = parsed.subject;
|
|
14823
|
-
|
|
14824
|
-
if (source === "") {
|
|
14791
|
+
if (parsed.sourceRun === void 0) {
|
|
14825
14792
|
presentStructuralRejection(new CliUsageError("auditor --source-run requires a run locator"), io);
|
|
14826
14793
|
return { exitCode: 2 };
|
|
14827
14794
|
}
|
|
14795
|
+
const source = parsed.sourceRun;
|
|
14828
14796
|
try {
|
|
14829
14797
|
const resolved = await resolveNotarySourceRunLocator({ projectRoot, sourceRun: source, home: env.home });
|
|
14830
14798
|
auditorSource = resolved.runDirectory;
|
|
@@ -14835,26 +14803,23 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14835
14803
|
}
|
|
14836
14804
|
if (auditorSource === void 0) return { exitCode: 2 };
|
|
14837
14805
|
const sourceDirectory = auditorSource;
|
|
14838
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
14839
14806
|
const summons = {
|
|
14840
|
-
...
|
|
14807
|
+
...sameParentInstruction(env, {
|
|
14808
|
+
instruction: parsed.instruction ?? "",
|
|
14809
|
+
instructionEmpty: (parsed.instruction ?? "").trim() === ""
|
|
14810
|
+
}),
|
|
14841
14811
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14842
14812
|
};
|
|
14843
14813
|
const resumed = await withAuditorSoulEnv({
|
|
14844
14814
|
subject: auditorSubject,
|
|
14845
14815
|
sourceRunDirectory: auditorSource,
|
|
14846
|
-
run: () =>
|
|
14847
|
-
|
|
14816
|
+
run: () => resumeSameParentInstructionSeat({
|
|
14817
|
+
env,
|
|
14818
|
+
io,
|
|
14848
14819
|
projectRoot,
|
|
14849
14820
|
role,
|
|
14850
14821
|
parentRunPath: sourceDirectory,
|
|
14851
|
-
|
|
14852
|
-
summons,
|
|
14853
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
14854
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
14855
|
-
env,
|
|
14856
|
-
io
|
|
14857
|
-
)
|
|
14822
|
+
summons
|
|
14858
14823
|
})
|
|
14859
14824
|
});
|
|
14860
14825
|
if (resumed != null) return resumed;
|
|
@@ -14862,24 +14827,21 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14862
14827
|
if (record4.sameParent === "gate-pointer") {
|
|
14863
14828
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
|
|
14864
14829
|
if (parentRunPath !== void 0) {
|
|
14865
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
14866
14830
|
const summons = {
|
|
14867
14831
|
sourceRunPath: parentRunPath,
|
|
14868
|
-
...
|
|
14832
|
+
...sameParentInstruction(env, {
|
|
14833
|
+
instruction: parsed.instruction ?? "",
|
|
14834
|
+
instructionEmpty: (parsed.instruction ?? "").trim() === ""
|
|
14835
|
+
}),
|
|
14869
14836
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14870
14837
|
};
|
|
14871
|
-
const resumed = await
|
|
14872
|
-
|
|
14838
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
14839
|
+
env,
|
|
14840
|
+
io,
|
|
14873
14841
|
projectRoot,
|
|
14874
14842
|
role,
|
|
14875
14843
|
parentRunPath,
|
|
14876
|
-
|
|
14877
|
-
summons,
|
|
14878
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
14879
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
14880
|
-
env,
|
|
14881
|
-
io
|
|
14882
|
-
)
|
|
14844
|
+
summons
|
|
14883
14845
|
});
|
|
14884
14846
|
if (resumed != null) return resumed;
|
|
14885
14847
|
}
|
|
@@ -14905,28 +14867,28 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14905
14867
|
sourceRun: source,
|
|
14906
14868
|
...resumeInstruction === void 0 ? {} : { instruction: resumeInstruction, instructionEmpty: false }
|
|
14907
14869
|
};
|
|
14908
|
-
|
|
14909
|
-
|
|
14870
|
+
resolvedNotarySource = source;
|
|
14871
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
14872
|
+
env,
|
|
14873
|
+
io,
|
|
14910
14874
|
projectRoot,
|
|
14911
14875
|
role,
|
|
14912
14876
|
parentRunPath: source.runDirectory,
|
|
14913
|
-
|
|
14914
|
-
summons,
|
|
14915
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
14916
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
14917
|
-
env,
|
|
14918
|
-
io
|
|
14919
|
-
)
|
|
14877
|
+
summons
|
|
14920
14878
|
});
|
|
14921
14879
|
if (resumed != null) return resumed;
|
|
14922
14880
|
}
|
|
14923
14881
|
let admitted;
|
|
14924
14882
|
try {
|
|
14883
|
+
const admissionOverride = {
|
|
14884
|
+
...auditorTicket === void 0 ? {} : { assertedTicketNumber: auditorTicket },
|
|
14885
|
+
...resolvedNotarySource === void 0 ? {} : { resolvedSourceRun: resolvedNotarySource }
|
|
14886
|
+
};
|
|
14925
14887
|
admitted = await admitPublicRole(
|
|
14926
14888
|
role,
|
|
14927
14889
|
parsed,
|
|
14928
14890
|
env,
|
|
14929
|
-
auditorTicket === void 0
|
|
14891
|
+
auditorTicket === void 0 && resolvedNotarySource === void 0 ? void 0 : admissionOverride
|
|
14930
14892
|
);
|
|
14931
14893
|
} catch (error) {
|
|
14932
14894
|
const rejected = usageExit(error, io);
|
|
@@ -14964,7 +14926,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14964
14926
|
thrown: error
|
|
14965
14927
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
14966
14928
|
}
|
|
14967
|
-
if (outcome.admitted
|
|
14929
|
+
if (outcome.admitted !== void 0 && isUnboundRunDirectory(outcome.admitted.runDirectory)) {
|
|
14968
14930
|
await recordChildDiaristRun(admitted, outcome.admitted.runId);
|
|
14969
14931
|
}
|
|
14970
14932
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
@@ -15313,6 +15275,7 @@ var AUDITED_ROLES, SECRETARIAT_STATUS_REASK, COUNTERSIGN_STATUS_REASK, WORKER_RO
|
|
|
15313
15275
|
var init_instruction_seat_run = __esm({
|
|
15314
15276
|
"src/public-cli/instruction-seat-run.ts"() {
|
|
15315
15277
|
"use strict";
|
|
15278
|
+
init_role_run_placement();
|
|
15316
15279
|
init_compliance_transport();
|
|
15317
15280
|
init_archivist_record_pointer();
|
|
15318
15281
|
init_doctor_auditor();
|
|
@@ -17510,7 +17473,6 @@ __export(cli_exports, {
|
|
|
17510
17473
|
runAkRole: () => runAkRole
|
|
17511
17474
|
});
|
|
17512
17475
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
17513
|
-
import { join as join37 } from "node:path";
|
|
17514
17476
|
function publicSeatArgv(owner) {
|
|
17515
17477
|
return {
|
|
17516
17478
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -17549,50 +17511,42 @@ function takePublicGlobalFlag(argv, index, options) {
|
|
|
17549
17511
|
return void 0;
|
|
17550
17512
|
}
|
|
17551
17513
|
function createRoleEnvironment(env, options, afterHost) {
|
|
17552
|
-
const role = options.role;
|
|
17553
17514
|
const extraPiArgs = env.extraPiArgs;
|
|
17554
17515
|
const timeoutMs = env.timeoutMs;
|
|
17555
|
-
const
|
|
17556
|
-
{
|
|
17516
|
+
const opened = openRoleSeatRuntime({
|
|
17517
|
+
resolution: {
|
|
17557
17518
|
packageRoot: env.packageRoot,
|
|
17558
17519
|
...env.roleTurnHost === void 0 ? {} : { roleTurnHost: env.roleTurnHost },
|
|
17559
17520
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters },
|
|
17560
17521
|
...extraPiArgs === void 0 ? {} : { extraPiArgs },
|
|
17561
17522
|
...timeoutMs === void 0 ? {} : { timeoutMs }
|
|
17562
17523
|
},
|
|
17563
|
-
env.principalAuthority
|
|
17564
|
-
|
|
17565
|
-
|
|
17566
|
-
|
|
17567
|
-
|
|
17524
|
+
principalAuthority: env.principalAuthority,
|
|
17525
|
+
role: options.role,
|
|
17526
|
+
seat: options.seat,
|
|
17527
|
+
home: options.home,
|
|
17528
|
+
...afterHost === void 0 ? {} : { afterHost }
|
|
17568
17529
|
});
|
|
17569
|
-
|
|
17570
|
-
const seatWithModel = resolvedSeatWithModel(options.seat);
|
|
17571
|
-
if (seatWithModel === void 0) {
|
|
17530
|
+
if (!opened.ok) {
|
|
17572
17531
|
throw new CliUsageError(
|
|
17573
17532
|
missingResolvedSeatModelMessage(options.seat.seat, "invocation-or-config")
|
|
17574
17533
|
);
|
|
17575
17534
|
}
|
|
17576
|
-
const hostFacingSelection = projectHostFacingProvider(
|
|
17577
|
-
seatWithModel.selection,
|
|
17578
|
-
seatWithModel.host,
|
|
17579
|
-
loadHostProvidersTable(options.home),
|
|
17580
|
-
options.home
|
|
17581
|
-
);
|
|
17582
17535
|
return {
|
|
17583
17536
|
home: options.home,
|
|
17584
17537
|
principalAuthority: env.principalAuthority,
|
|
17585
17538
|
agentDir: options.agentDir,
|
|
17586
17539
|
sessionAppender: appendPiSessionCustomEntry,
|
|
17587
17540
|
packageRoot: env.packageRoot,
|
|
17588
|
-
roleTurnHost,
|
|
17589
|
-
hostAdapters,
|
|
17541
|
+
roleTurnHost: opened.roleTurnHost,
|
|
17542
|
+
hostAdapters: opened.hostAdapters,
|
|
17590
17543
|
cwd: options.cwd,
|
|
17591
17544
|
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
17592
17545
|
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
17593
|
-
...
|
|
17594
|
-
...
|
|
17595
|
-
...
|
|
17546
|
+
...opened.model === void 0 ? {} : { model: opened.model },
|
|
17547
|
+
...opened.engine === void 0 ? {} : { engine: opened.engine },
|
|
17548
|
+
...opened.engineModel === void 0 ? {} : { engineModel: opened.engineModel },
|
|
17549
|
+
host: opened.host,
|
|
17596
17550
|
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
17597
17551
|
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
17598
17552
|
...options.config?.autoResumeLimit === void 0 ? {} : { autoResumeLimit: options.config.autoResumeLimit },
|
|
@@ -17601,15 +17555,19 @@ function createRoleEnvironment(env, options, afterHost) {
|
|
|
17601
17555
|
...env.signal === void 0 ? {} : { signal: env.signal }
|
|
17602
17556
|
};
|
|
17603
17557
|
}
|
|
17604
|
-
async function
|
|
17605
|
-
const agentDir =
|
|
17558
|
+
async function loadPublicRoleDispatchParts(env, home) {
|
|
17559
|
+
const agentDir = resolvePublicAgentDir(env.agentDir, home);
|
|
17606
17560
|
const cwd = env.cwd ?? process.cwd();
|
|
17607
17561
|
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
17608
17562
|
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
17563
|
+
return { agentDir, cwd, config, credentials };
|
|
17564
|
+
}
|
|
17565
|
+
async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run) {
|
|
17566
|
+
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
17609
17567
|
const seat = resolveEffectiveSeat(
|
|
17610
|
-
config,
|
|
17568
|
+
parts.config,
|
|
17611
17569
|
role,
|
|
17612
|
-
credentials,
|
|
17570
|
+
parts.credentials,
|
|
17613
17571
|
invocationFromParsed(parsed)
|
|
17614
17572
|
);
|
|
17615
17573
|
let parsedRoleArgv;
|
|
@@ -17617,7 +17575,15 @@ async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run
|
|
|
17617
17575
|
parsed.args,
|
|
17618
17576
|
createRoleEnvironment(
|
|
17619
17577
|
env,
|
|
17620
|
-
{
|
|
17578
|
+
{
|
|
17579
|
+
role,
|
|
17580
|
+
home,
|
|
17581
|
+
agentDir: parts.agentDir,
|
|
17582
|
+
cwd: parts.cwd,
|
|
17583
|
+
credentials: parts.credentials,
|
|
17584
|
+
seat,
|
|
17585
|
+
config: parts.config
|
|
17586
|
+
},
|
|
17621
17587
|
() => {
|
|
17622
17588
|
parsedRoleArgv = parse(parsed.args);
|
|
17623
17589
|
}
|
|
@@ -17648,9 +17614,6 @@ function defaultIo() {
|
|
|
17648
17614
|
function resolveHome(env) {
|
|
17649
17615
|
return env.home ?? packageMachineHome();
|
|
17650
17616
|
}
|
|
17651
|
-
function resolveAgentDir(env, home) {
|
|
17652
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join37(home, ".pi", "agent");
|
|
17653
|
-
}
|
|
17654
17617
|
function parseThinking(value) {
|
|
17655
17618
|
return value;
|
|
17656
17619
|
}
|
|
@@ -17769,12 +17732,6 @@ function requireCallableSeat(seat, axis, verb) {
|
|
|
17769
17732
|
throw new CliUsageError(`unknown ${axis}-axis seat: ${seat}`);
|
|
17770
17733
|
}
|
|
17771
17734
|
}
|
|
17772
|
-
function projectSeatEngine(seat) {
|
|
17773
|
-
return pickEngineAxis(seat);
|
|
17774
|
-
}
|
|
17775
|
-
function projectSeatHost(seat) {
|
|
17776
|
-
return { host: seat.host };
|
|
17777
|
-
}
|
|
17778
17735
|
function loadAndValidateConfig(home, packageRoot) {
|
|
17779
17736
|
return loadPublicCliConfig(home).then((config) => {
|
|
17780
17737
|
try {
|
|
@@ -18220,7 +18177,7 @@ async function runAkRole(argv, env) {
|
|
|
18220
18177
|
throw new CliUsageError("roles takes no arguments");
|
|
18221
18178
|
}
|
|
18222
18179
|
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
18223
|
-
const credentials = env.credentials ?? await loadCredentialProviders(
|
|
18180
|
+
const credentials = env.credentials ?? await loadCredentialProviders(resolvePublicAgentDir(env.agentDir, home));
|
|
18224
18181
|
const seats = effectiveSeatConfigurations(
|
|
18225
18182
|
config,
|
|
18226
18183
|
credentials,
|
|
@@ -18260,16 +18217,13 @@ async function runAkRole(argv, env) {
|
|
|
18260
18217
|
runId: resumeRequest.runId,
|
|
18261
18218
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
18262
18219
|
};
|
|
18263
|
-
const
|
|
18264
|
-
const cwd = env.cwd ?? process.cwd();
|
|
18265
|
-
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
18266
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
18220
|
+
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
18267
18221
|
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
|
|
18268
18222
|
const seatRole = resumeRole ?? "judge";
|
|
18269
18223
|
const seat = resolveEffectiveSeat(
|
|
18270
|
-
config,
|
|
18224
|
+
parts.config,
|
|
18271
18225
|
seatRole,
|
|
18272
|
-
credentials,
|
|
18226
|
+
parts.credentials,
|
|
18273
18227
|
invocationFromParsed(parsed)
|
|
18274
18228
|
);
|
|
18275
18229
|
const result = await runPublicInstructionSeatResume(
|
|
@@ -18277,11 +18231,11 @@ async function runAkRole(argv, env) {
|
|
|
18277
18231
|
createRoleEnvironment(env, {
|
|
18278
18232
|
role: seatRole,
|
|
18279
18233
|
home,
|
|
18280
|
-
agentDir,
|
|
18281
|
-
cwd,
|
|
18282
|
-
credentials,
|
|
18234
|
+
agentDir: parts.agentDir,
|
|
18235
|
+
cwd: parts.cwd,
|
|
18236
|
+
credentials: parts.credentials,
|
|
18283
18237
|
seat,
|
|
18284
|
-
config
|
|
18238
|
+
config: parts.config
|
|
18285
18239
|
}),
|
|
18286
18240
|
io
|
|
18287
18241
|
);
|
|
@@ -18295,15 +18249,20 @@ async function runAkRole(argv, env) {
|
|
|
18295
18249
|
};
|
|
18296
18250
|
const parentRole = await peekRoleRunRole(home, parentRunId);
|
|
18297
18251
|
if (parentRole === void 0) break;
|
|
18298
|
-
const parentSeat = resolveEffectiveSeat(
|
|
18252
|
+
const parentSeat = resolveEffectiveSeat(
|
|
18253
|
+
parts.config,
|
|
18254
|
+
parentRole,
|
|
18255
|
+
parts.credentials,
|
|
18256
|
+
invocationFromParsed(parsed)
|
|
18257
|
+
);
|
|
18299
18258
|
const parentEnv = createRoleEnvironment(env, {
|
|
18300
18259
|
role: parentRole,
|
|
18301
18260
|
home,
|
|
18302
|
-
agentDir,
|
|
18303
|
-
cwd,
|
|
18304
|
-
credentials,
|
|
18261
|
+
agentDir: parts.agentDir,
|
|
18262
|
+
cwd: parts.cwd,
|
|
18263
|
+
credentials: parts.credentials,
|
|
18305
18264
|
seat: parentSeat,
|
|
18306
|
-
config
|
|
18265
|
+
config: parts.config
|
|
18307
18266
|
});
|
|
18308
18267
|
current = await continueParentAfterChild(parentRunId, current.admitted, parentEnv, io);
|
|
18309
18268
|
}
|
|
@@ -18386,6 +18345,7 @@ var init_cli = __esm({
|
|
|
18386
18345
|
init_machine_method_skills();
|
|
18387
18346
|
init_post_admission();
|
|
18388
18347
|
init_role_turn_host();
|
|
18348
|
+
init_role_seat_runtime();
|
|
18389
18349
|
init_role_turn_host_resolution();
|
|
18390
18350
|
init_invocation();
|
|
18391
18351
|
init_option_definitions();
|
|
@@ -18421,7 +18381,7 @@ __export(public_role_summons_exports, {
|
|
|
18421
18381
|
import { execFile as execFile3 } from "node:child_process";
|
|
18422
18382
|
import { existsSync as existsSync10 } from "node:fs";
|
|
18423
18383
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18424
|
-
import { join as
|
|
18384
|
+
import { join as join37 } from "node:path";
|
|
18425
18385
|
import { promisify as promisify3 } from "node:util";
|
|
18426
18386
|
function createCapturingIo() {
|
|
18427
18387
|
const chunks = [];
|
|
@@ -18445,7 +18405,7 @@ function parentDir(path) {
|
|
|
18445
18405
|
function walkPackageRoot(start) {
|
|
18446
18406
|
let dir = start;
|
|
18447
18407
|
for (let i = 0; i < 12; i += 1) {
|
|
18448
|
-
if (existsSync10(
|
|
18408
|
+
if (existsSync10(join37(dir, "package.json")) && existsSync10(join37(dir, "souls"))) {
|
|
18449
18409
|
return dir;
|
|
18450
18410
|
}
|
|
18451
18411
|
const parent = parentDir(dir);
|
|
@@ -18486,12 +18446,6 @@ async function resolveSummonHome(options) {
|
|
|
18486
18446
|
if (fromCwd !== void 0 && fromCwd.length > 0) return fromCwd;
|
|
18487
18447
|
return packageMachineHome2();
|
|
18488
18448
|
}
|
|
18489
|
-
function projectSeatEngine2(seat) {
|
|
18490
|
-
return pickEngineAxis(seat);
|
|
18491
|
-
}
|
|
18492
|
-
function projectSeatHost2(seat) {
|
|
18493
|
-
return seat.host === void 0 ? {} : { host: seat.host };
|
|
18494
|
-
}
|
|
18495
18449
|
function hostSelectionFailureFromUnknown(error) {
|
|
18496
18450
|
if (typeof error !== "object" || error === null) return void 0;
|
|
18497
18451
|
if (error.name !== "HostSelectionError") return void 0;
|
|
@@ -18502,44 +18456,36 @@ async function createSummonEnv(options, afterHost) {
|
|
|
18502
18456
|
const [
|
|
18503
18457
|
{ piDurablePrincipalAuthority: piDurablePrincipalAuthority2 },
|
|
18504
18458
|
{ appendPiSessionCustomEntry: appendPiSessionCustomEntry2 },
|
|
18505
|
-
{
|
|
18506
|
-
{ missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2
|
|
18459
|
+
{ openRoleSeatRuntime: openRoleSeatRuntime2 },
|
|
18460
|
+
{ missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2 }
|
|
18507
18461
|
] = await Promise.all([
|
|
18508
18462
|
Promise.resolve().then(() => (init_durable_principal(), durable_principal_exports)),
|
|
18509
18463
|
Promise.resolve().then(() => (init_role_turn_host(), role_turn_host_exports)),
|
|
18510
|
-
Promise.resolve().then(() => (
|
|
18464
|
+
Promise.resolve().then(() => (init_role_seat_runtime(), role_seat_runtime_exports)),
|
|
18511
18465
|
Promise.resolve().then(() => (init_config(), config_exports))
|
|
18512
18466
|
]);
|
|
18513
18467
|
const principalAuthority = options.principalAuthority ?? piDurablePrincipalAuthority2;
|
|
18514
|
-
const
|
|
18515
|
-
{
|
|
18468
|
+
const opened = openRoleSeatRuntime2({
|
|
18469
|
+
resolution: {
|
|
18516
18470
|
packageRoot: options.packageRoot,
|
|
18517
18471
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
18518
18472
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
18519
18473
|
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
18520
18474
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
18521
18475
|
},
|
|
18522
|
-
|
|
18523
|
-
|
|
18524
|
-
|
|
18525
|
-
|
|
18526
|
-
|
|
18476
|
+
principalAuthority,
|
|
18477
|
+
role: options.role,
|
|
18478
|
+
seat: options.seat,
|
|
18479
|
+
home: options.home,
|
|
18480
|
+
...afterHost === void 0 ? {} : { afterHost },
|
|
18481
|
+
...options.hostFacingModel === void 0 ? {} : { hostFacingModel: options.hostFacingModel }
|
|
18482
|
+
});
|
|
18483
|
+
if (!opened.ok) {
|
|
18527
18484
|
return {
|
|
18528
18485
|
ok: false,
|
|
18529
18486
|
missingModelMessage: missingResolvedSeatModelMessage2(options.role)
|
|
18530
18487
|
};
|
|
18531
18488
|
}
|
|
18532
|
-
const hostName = seatWithModel.host ?? "pi";
|
|
18533
|
-
let hostFacingSelection = options.hostFacingModel;
|
|
18534
|
-
if (hostFacingSelection === void 0) {
|
|
18535
|
-
const { loadHostProvidersTable: loadHostProvidersTable2, projectHostFacingProvider: projectHostFacingProvider2 } = await Promise.resolve().then(() => (init_host_providers(), host_providers_exports));
|
|
18536
|
-
hostFacingSelection = projectHostFacingProvider2(
|
|
18537
|
-
seatWithModel.selection,
|
|
18538
|
-
hostName,
|
|
18539
|
-
loadHostProvidersTable2(options.home),
|
|
18540
|
-
options.home
|
|
18541
|
-
);
|
|
18542
|
-
}
|
|
18543
18489
|
return {
|
|
18544
18490
|
ok: true,
|
|
18545
18491
|
env: {
|
|
@@ -18548,12 +18494,13 @@ async function createSummonEnv(options, afterHost) {
|
|
|
18548
18494
|
agentDir: options.agentDir,
|
|
18549
18495
|
sessionAppender: appendPiSessionCustomEntry2,
|
|
18550
18496
|
packageRoot: options.packageRoot,
|
|
18551
|
-
roleTurnHost,
|
|
18497
|
+
roleTurnHost: opened.roleTurnHost,
|
|
18552
18498
|
cwd: options.cwd,
|
|
18553
18499
|
credentials: options.credentials,
|
|
18554
|
-
...
|
|
18555
|
-
...
|
|
18556
|
-
...
|
|
18500
|
+
...opened.model === void 0 ? {} : { model: opened.model },
|
|
18501
|
+
...opened.engine === void 0 ? {} : { engine: opened.engine },
|
|
18502
|
+
...opened.engineModel === void 0 ? {} : { engineModel: opened.engineModel },
|
|
18503
|
+
host: opened.host,
|
|
18557
18504
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
18558
18505
|
}
|
|
18559
18506
|
};
|
|
@@ -18561,13 +18508,14 @@ async function createSummonEnv(options, afterHost) {
|
|
|
18561
18508
|
async function summonPublicRole(options) {
|
|
18562
18509
|
const packageRoot = resolveSummonsPackageRoot(options.packageRoot);
|
|
18563
18510
|
const home = await resolveSummonHome(options);
|
|
18564
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join38(home, ".pi", "agent");
|
|
18565
18511
|
const {
|
|
18566
18512
|
loadCredentialProviders: loadCredentialProviders2,
|
|
18567
18513
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
18568
18514
|
resolveEffectiveSeat: resolveEffectiveSeat2,
|
|
18515
|
+
resolvePublicAgentDir: resolvePublicAgentDir2,
|
|
18569
18516
|
validatePublicCliConfigAxes: validatePublicCliConfigAxes2
|
|
18570
18517
|
} = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
18518
|
+
const agentDir = resolvePublicAgentDir2(options.agentDir, home);
|
|
18571
18519
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
18572
18520
|
const config = await loadPublicCliConfig2(home);
|
|
18573
18521
|
validatePublicCliConfigAxes2(config, packageRoot);
|
|
@@ -18924,7 +18872,6 @@ var AK_ROLE_PACKAGE_ROOT_ENV, execFileAsync3;
|
|
|
18924
18872
|
var init_public_role_summons = __esm({
|
|
18925
18873
|
"src/public-role-summons.ts"() {
|
|
18926
18874
|
"use strict";
|
|
18927
|
-
init_engine_material();
|
|
18928
18875
|
AK_ROLE_PACKAGE_ROOT_ENV = "AK_ROLE_PACKAGE_ROOT";
|
|
18929
18876
|
execFileAsync3 = promisify3(execFile3);
|
|
18930
18877
|
}
|
|
@@ -19069,11 +19016,11 @@ var init_compliance_transport = __esm({
|
|
|
19069
19016
|
});
|
|
19070
19017
|
|
|
19071
19018
|
// src/role-run-relocation.ts
|
|
19072
|
-
import { join as
|
|
19019
|
+
import { join as join38, sep as sep4 } from "node:path";
|
|
19073
19020
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
19074
19021
|
if (typeof value !== "string") return value;
|
|
19075
19022
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
19076
|
-
const prefix = `${oldRunDirectory}${
|
|
19023
|
+
const prefix = `${oldRunDirectory}${sep4}`;
|
|
19077
19024
|
if (value.startsWith(prefix)) {
|
|
19078
19025
|
return `${newRunDirectory}${value.slice(oldRunDirectory.length)}`;
|
|
19079
19026
|
}
|
|
@@ -19083,7 +19030,7 @@ function rewriteRunDirectoryPathValueAgainstRewrites(value, rewrites) {
|
|
|
19083
19030
|
if (typeof value !== "string" || rewrites.length === 0) return value;
|
|
19084
19031
|
let best;
|
|
19085
19032
|
for (const rewrite of rewrites) {
|
|
19086
|
-
if (value === rewrite.oldRunDirectory || value.startsWith(`${rewrite.oldRunDirectory}${
|
|
19033
|
+
if (value === rewrite.oldRunDirectory || value.startsWith(`${rewrite.oldRunDirectory}${sep4}`)) {
|
|
19087
19034
|
if (best === void 0 || rewrite.oldRunDirectory.length > best.oldRunDirectory.length) {
|
|
19088
19035
|
best = rewrite;
|
|
19089
19036
|
}
|
|
@@ -19197,7 +19144,7 @@ __export(run_lifecycle_exports, {
|
|
|
19197
19144
|
writeRoleRunState: () => writeRoleRunState
|
|
19198
19145
|
});
|
|
19199
19146
|
import { chmod, lstat as lstat6, open as open3, readdir as readdir7, readFile as readFile22, unlink as unlink5, writeFile as writeFile8 } from "node:fs/promises";
|
|
19200
|
-
import { basename as basename10, join as
|
|
19147
|
+
import { basename as basename10, join as join39 } from "node:path";
|
|
19201
19148
|
function buildAutoResumeContinuationPrompt(options) {
|
|
19202
19149
|
return appendEngineSessionMaterial(
|
|
19203
19150
|
[RESUME_TRANSPORT_ENVELOPE],
|
|
@@ -19223,7 +19170,7 @@ function renderResumeCommand(runId) {
|
|
|
19223
19170
|
async function writeRoleRunState(runDirectory, record4) {
|
|
19224
19171
|
const payload = { ...record4, runDirectory };
|
|
19225
19172
|
await writeFile8(
|
|
19226
|
-
|
|
19173
|
+
join39(runDirectory, RUN_STATE_FILE),
|
|
19227
19174
|
`${JSON.stringify(payload, null, 2)}
|
|
19228
19175
|
`,
|
|
19229
19176
|
"utf8"
|
|
@@ -19273,7 +19220,7 @@ function parseCurrentCourtState(raw) {
|
|
|
19273
19220
|
async function readRoleRunStateRaw(runDirectory) {
|
|
19274
19221
|
let raw;
|
|
19275
19222
|
try {
|
|
19276
|
-
raw = JSON.parse(await readFile22(
|
|
19223
|
+
raw = JSON.parse(await readFile22(join39(runDirectory, RUN_STATE_FILE), "utf8"));
|
|
19277
19224
|
} catch (error) {
|
|
19278
19225
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
19279
19226
|
throw error;
|
|
@@ -19367,7 +19314,7 @@ async function writeRoleRunStateDisk(runDirectory, disk) {
|
|
|
19367
19314
|
...disk.currentCourt === void 0 ? {} : { currentCourt: disk.currentCourt }
|
|
19368
19315
|
};
|
|
19369
19316
|
await writeFile8(
|
|
19370
|
-
|
|
19317
|
+
join39(runDirectory, RUN_STATE_FILE),
|
|
19371
19318
|
`${JSON.stringify(payload, null, 2)}
|
|
19372
19319
|
`,
|
|
19373
19320
|
"utf8"
|
|
@@ -19590,7 +19537,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19590
19537
|
},
|
|
19591
19538
|
relocate(nextRunDirectory) {
|
|
19592
19539
|
currentRunDirectory = nextRunDirectory;
|
|
19593
|
-
currentLockPath =
|
|
19540
|
+
currentLockPath = join39(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19594
19541
|
},
|
|
19595
19542
|
async release() {
|
|
19596
19543
|
if (released) return;
|
|
@@ -19629,10 +19576,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19629
19576
|
};
|
|
19630
19577
|
const reportReadFailure = (error) => {
|
|
19631
19578
|
reportDiagnostic(
|
|
19632
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
19579
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join39(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19633
19580
|
);
|
|
19634
19581
|
};
|
|
19635
|
-
const lockPath =
|
|
19582
|
+
const lockPath = join39(runDirectory, WRITER_LOCK_FILE);
|
|
19636
19583
|
let lastAutopsy = { verdict: "absent" };
|
|
19637
19584
|
let lastReclaimFailure;
|
|
19638
19585
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19687,7 +19634,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19687
19634
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19688
19635
|
if (runId.trim() === "") return void 0;
|
|
19689
19636
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19690
|
-
const booksRoot =
|
|
19637
|
+
const booksRoot = join39(ledgerHome, "books");
|
|
19691
19638
|
let bookKeys;
|
|
19692
19639
|
try {
|
|
19693
19640
|
bookKeys = await readdir7(booksRoot);
|
|
@@ -19728,7 +19675,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19728
19675
|
let raw;
|
|
19729
19676
|
try {
|
|
19730
19677
|
raw = JSON.parse(
|
|
19731
|
-
await readFile22(
|
|
19678
|
+
await readFile22(join39(runDirectory, "admitted-request.json"), "utf8")
|
|
19732
19679
|
);
|
|
19733
19680
|
} catch (error) {
|
|
19734
19681
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19749,7 +19696,7 @@ async function readRunParentPath(runDirectory) {
|
|
|
19749
19696
|
async function runHasFormedSessionPrincipal(runDirectory) {
|
|
19750
19697
|
const disk = await readRoleRunStateDisk(runDirectory);
|
|
19751
19698
|
if (disk === void 0) return false;
|
|
19752
|
-
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile :
|
|
19699
|
+
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : join39(disk.principalWire.sessionDirectory, "session.jsonl");
|
|
19753
19700
|
try {
|
|
19754
19701
|
const stat2 = await lstat6(sessionFile);
|
|
19755
19702
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
@@ -19767,7 +19714,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19767
19714
|
let runDirectories;
|
|
19768
19715
|
try {
|
|
19769
19716
|
runDirectories = await listBookRunDirectories(
|
|
19770
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
19717
|
+
input.ticketNumber === void 0 ? bookDir : join39(bookDir, String(input.ticketNumber))
|
|
19771
19718
|
);
|
|
19772
19719
|
} catch (error) {
|
|
19773
19720
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19838,7 +19785,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19838
19785
|
let waitWindowMs;
|
|
19839
19786
|
let issueNumber;
|
|
19840
19787
|
let caseRunsPath;
|
|
19841
|
-
let
|
|
19788
|
+
let caseIdentity;
|
|
19842
19789
|
let sourceRunPath;
|
|
19843
19790
|
let sourceRun;
|
|
19844
19791
|
try {
|
|
@@ -19909,7 +19856,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19909
19856
|
if (record4.caseIdentity !== null && typeof record4.caseIdentity === "object" && !Array.isArray(record4.caseIdentity)) {
|
|
19910
19857
|
const ci = record4.caseIdentity;
|
|
19911
19858
|
if (typeof ci.issueNumber === "number" && Number.isSafeInteger(ci.issueNumber) && ci.issueNumber >= 1 && typeof ci.runsPath === "string" && ci.runsPath.trim() !== "") {
|
|
19912
|
-
|
|
19859
|
+
caseIdentity = { issueNumber: ci.issueNumber, runsPath: ci.runsPath };
|
|
19913
19860
|
}
|
|
19914
19861
|
}
|
|
19915
19862
|
if (typeof record4.sourceRunPath === "string" && record4.sourceRunPath.trim() !== "") {
|
|
@@ -19965,7 +19912,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19965
19912
|
let model;
|
|
19966
19913
|
try {
|
|
19967
19914
|
const invocationRaw = JSON.parse(
|
|
19968
|
-
await readFile22(
|
|
19915
|
+
await readFile22(join39(run.runDirectory, "invocation.json"), "utf8")
|
|
19969
19916
|
);
|
|
19970
19917
|
if (invocationRaw !== null && typeof invocationRaw === "object" && !Array.isArray(invocationRaw)) {
|
|
19971
19918
|
const rec = invocationRaw;
|
|
@@ -20038,7 +19985,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
20038
19985
|
...waitWindowMs === void 0 ? {} : { waitWindowMs },
|
|
20039
19986
|
...issueNumber === void 0 ? {} : { issueNumber },
|
|
20040
19987
|
...caseRunsPath === void 0 ? {} : { caseRunsPath },
|
|
20041
|
-
...
|
|
19988
|
+
...caseIdentity === void 0 ? {} : { caseIdentity },
|
|
20042
19989
|
...sourceRunPath === void 0 ? {} : { sourceRunPath },
|
|
20043
19990
|
...sourceRun === void 0 ? {} : { sourceRun },
|
|
20044
19991
|
...model === void 0 ? {} : { model }
|
|
@@ -20157,14 +20104,10 @@ function admitResumedRole(loaded) {
|
|
|
20157
20104
|
}
|
|
20158
20105
|
case "review-basis": {
|
|
20159
20106
|
const rawBase = fields.baseRevision;
|
|
20160
|
-
|
|
20161
|
-
|
|
20162
|
-
`role run admitted reviewer base revision is missing: ${runId}`
|
|
20163
|
-
);
|
|
20164
|
-
}
|
|
20165
|
-
if (/\s/.test(rawBase) || rawBase.startsWith("-")) {
|
|
20107
|
+
const baseFault = admittedReviewerBaseFault(rawBase);
|
|
20108
|
+
if (baseFault !== void 0 || rawBase === void 0) {
|
|
20166
20109
|
throw new CliUsageError(
|
|
20167
|
-
`role run admitted reviewer base revision is damaged: ${runId}`
|
|
20110
|
+
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${runId}` : `role run admitted reviewer base revision is missing: ${runId}`
|
|
20168
20111
|
);
|
|
20169
20112
|
}
|
|
20170
20113
|
const lens = fields.lens;
|
|
@@ -20260,8 +20203,8 @@ function admitResumedRole(loaded) {
|
|
|
20260
20203
|
return admitted;
|
|
20261
20204
|
}
|
|
20262
20205
|
case "case-identity": {
|
|
20263
|
-
const { issueNumber, caseRunsPath, caseIdentity
|
|
20264
|
-
if (issueNumber === void 0 || caseRunsPath === void 0 ||
|
|
20206
|
+
const { issueNumber, caseRunsPath, caseIdentity } = fields;
|
|
20207
|
+
if (issueNumber === void 0 || caseRunsPath === void 0 || caseIdentity === void 0) {
|
|
20265
20208
|
throw new CliUsageError(
|
|
20266
20209
|
`role run admitted doctor case identity is missing: ${runId}`
|
|
20267
20210
|
);
|
|
@@ -20271,7 +20214,7 @@ function admitResumedRole(loaded) {
|
|
|
20271
20214
|
...base,
|
|
20272
20215
|
issueNumber,
|
|
20273
20216
|
caseRunsPath,
|
|
20274
|
-
caseIdentity
|
|
20217
|
+
caseIdentity
|
|
20275
20218
|
};
|
|
20276
20219
|
return admitted;
|
|
20277
20220
|
}
|
|
@@ -20334,7 +20277,7 @@ var init_run_lifecycle = __esm({
|
|
|
20334
20277
|
|
|
20335
20278
|
// src/archivist-record-topology.ts
|
|
20336
20279
|
import { createHash as createHash4 } from "node:crypto";
|
|
20337
|
-
import { join as
|
|
20280
|
+
import { join as join40 } from "node:path";
|
|
20338
20281
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
20339
20282
|
let ledgerHome;
|
|
20340
20283
|
if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
|
|
@@ -20347,7 +20290,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
20347
20290
|
const digest = createHash4("sha256").update(input.subject).digest("hex").slice(0, 32);
|
|
20348
20291
|
return {
|
|
20349
20292
|
ledgerHome,
|
|
20350
|
-
sessionDir:
|
|
20293
|
+
sessionDir: join40(
|
|
20351
20294
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
20352
20295
|
NAVIGATOR_RECORD_KIND,
|
|
20353
20296
|
digest
|
|
@@ -20419,10 +20362,10 @@ import {
|
|
|
20419
20362
|
statSync as statSync6,
|
|
20420
20363
|
writeFileSync as writeFileSync2
|
|
20421
20364
|
} from "node:fs";
|
|
20422
|
-
import { dirname as dirname23, resolve as resolve16, join as
|
|
20365
|
+
import { dirname as dirname23, resolve as resolve16, join as join41 } from "node:path";
|
|
20423
20366
|
import { StringDecoder } from "node:string_decoder";
|
|
20424
20367
|
function readCurrentSession(sessionDir) {
|
|
20425
|
-
const ledger =
|
|
20368
|
+
const ledger = join41(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20426
20369
|
try {
|
|
20427
20370
|
const value = JSON.parse(readFileSync4(ledger, "utf8"));
|
|
20428
20371
|
if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
|
|
@@ -20437,7 +20380,7 @@ function readCurrentSession(sessionDir) {
|
|
|
20437
20380
|
}
|
|
20438
20381
|
}
|
|
20439
20382
|
function writeCurrentSession(sessionDir, sessionFile) {
|
|
20440
|
-
const ledger =
|
|
20383
|
+
const ledger = join41(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20441
20384
|
try {
|
|
20442
20385
|
writeFileSync2(ledger, `${JSON.stringify({ sessionFile })}
|
|
20443
20386
|
`, { flag: "wx" });
|
|
@@ -20453,7 +20396,7 @@ function isCurrentSessionClaimRace(error) {
|
|
|
20453
20396
|
return errnoCode(error.cause) === "EEXIST";
|
|
20454
20397
|
}
|
|
20455
20398
|
function currentSessionLedgerPath(sessionDir) {
|
|
20456
|
-
return
|
|
20399
|
+
return join41(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20457
20400
|
}
|
|
20458
20401
|
function readBoundedSessionHeader(filePath) {
|
|
20459
20402
|
const fd = openSync2(filePath, "r");
|
|
@@ -20540,7 +20483,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20540
20483
|
const matched = [];
|
|
20541
20484
|
for (const name of names) {
|
|
20542
20485
|
if (!name.endsWith(".jsonl")) continue;
|
|
20543
|
-
const filePath =
|
|
20486
|
+
const filePath = join41(absoluteSessionDir, name);
|
|
20544
20487
|
let st;
|
|
20545
20488
|
try {
|
|
20546
20489
|
st = statSync6(filePath);
|
|
@@ -20652,7 +20595,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
20652
20595
|
if (!physicallyContainedIn(ledgerHome, parentResolved)) {
|
|
20653
20596
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20654
20597
|
}
|
|
20655
|
-
sessionDir =
|
|
20598
|
+
sessionDir = join41(dirname23(parentResolved), options.kind);
|
|
20656
20599
|
parentSession = parentFile;
|
|
20657
20600
|
mayResumeSameNest = options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
20658
20601
|
}
|
|
@@ -21791,7 +21734,7 @@ init_sitian_facade();
|
|
|
21791
21734
|
init_submission_ledger();
|
|
21792
21735
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
21793
21736
|
import { readFileSync as readFileSync6, writeSync as writeSync2 } from "node:fs";
|
|
21794
|
-
import { join as
|
|
21737
|
+
import { join as join43 } from "node:path";
|
|
21795
21738
|
import { Value as Value4 } from "typebox/value";
|
|
21796
21739
|
|
|
21797
21740
|
// src/activation-trace.ts
|
|
@@ -22465,16 +22408,9 @@ var gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
|
|
|
22465
22408
|
status: Type17.Unknown({
|
|
22466
22409
|
description: "completed"
|
|
22467
22410
|
}),
|
|
22468
|
-
findings: Type17.
|
|
22469
|
-
|
|
22470
|
-
|
|
22471
|
-
pointer: Type17.Optional(Type17.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" })),
|
|
22472
|
-
statement: Type17.Optional(Type17.String({ description: "\u7591\u70B9\u9648\u8FF0" }))
|
|
22473
|
-
},
|
|
22474
|
-
{ additionalProperties: true, description: "\u4E00\u6761\u5F39\u7AE0" }
|
|
22475
|
-
),
|
|
22476
|
-
{ description: "\u5F39\u7AE0\u5217\u8868\uFF1B\u7A7A\u5217\u8868\u5408\u6CD5\u5B8C\u5C40" }
|
|
22477
|
-
)
|
|
22411
|
+
findings: Type17.Unknown({
|
|
22412
|
+
description: "\u5F39\u7AE0\u5217\u8868\uFF1B\u6BCF\u6761\u53EF\u542B pointer\uFF08\u6587\u4EF6/\u884C\u6307\u9488\uFF09\u4E0E statement\uFF08\u7591\u70B9\u9648\u8FF0\uFF09\uFF0C\u539F\u6837\u7559\u5B58\u3002\u7A7A\u5217\u8868\u5408\u6CD5\u5B8C\u5C40\uFF1B\u673A\u5668\u4E0D\u5224\u5F39\u7AE0\u662F\u5426\u6210\u7ACB\u3002"
|
|
22413
|
+
})
|
|
22478
22414
|
})
|
|
22479
22415
|
)
|
|
22480
22416
|
);
|
|
@@ -22510,37 +22446,7 @@ init_terminating_infrastructure();
|
|
|
22510
22446
|
init_diarist_contracts();
|
|
22511
22447
|
init_diarist_contracts();
|
|
22512
22448
|
import { Type as Type18 } from "typebox";
|
|
22513
|
-
var
|
|
22514
|
-
Type18.Object(
|
|
22515
|
-
{
|
|
22516
|
-
path: Type18.Optional(Type18.String({ description: "\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84" })),
|
|
22517
|
-
ranges: Type18.Optional(
|
|
22518
|
-
Type18.Array(
|
|
22519
|
-
Type18.Object(
|
|
22520
|
-
{
|
|
22521
|
-
from: Type18.Optional(
|
|
22522
|
-
Type18.Object(
|
|
22523
|
-
{ id: Type18.Optional(Type18.String()), line: Type18.Optional(Type18.Unknown()) },
|
|
22524
|
-
{ additionalProperties: true, description: "\u8D77\u70B9\uFF1A\u539F\u751F id \u6216\u672C\u8F6E\u884C\u53F7\u4E8C\u9009\u4E00" }
|
|
22525
|
-
)
|
|
22526
|
-
),
|
|
22527
|
-
to: Type18.Optional(
|
|
22528
|
-
Type18.Object(
|
|
22529
|
-
{ id: Type18.Optional(Type18.String()), line: Type18.Optional(Type18.Unknown()) },
|
|
22530
|
-
{ additionalProperties: true, description: "\u7EC8\u70B9\uFF1A\u539F\u751F id \u6216\u672C\u8F6E\u884C\u53F7\u4E8C\u9009\u4E00" }
|
|
22531
|
-
)
|
|
22532
|
-
)
|
|
22533
|
-
},
|
|
22534
|
-
{ additionalProperties: true, description: "\u4E00\u6BB5\u5BF9\u8BDD\u533A\u95F4" }
|
|
22535
|
-
),
|
|
22536
|
-
{ description: "\u672C\u5377\u672C\u8F6E\u5404\u533A\u95F4\uFF1B\u81F3\u5C11\u4E00\u6BB5" }
|
|
22537
|
-
)
|
|
22538
|
-
)
|
|
22539
|
-
},
|
|
22540
|
-
{ additionalProperties: true, description: "\u4E00\u5377\u4F1A\u8BDD\u7684\u8FB9\u754C" }
|
|
22541
|
-
),
|
|
22542
|
-
{ description: "\u5BF9\u8BDD\u8FB9\u754C\uFF1B\u7A7A\u5217\u8868\uFF1D\u672C\u8F6E\u65E0\u5BF9\u8BDD\u53EF\u5212\u3002\u7AEF\u70B9\u65E0\u6CD5\u6307\u540D\u65F6\u8D70 reask\uFF0C\u4E0D\u4E2D\u6B62\u3002" }
|
|
22543
|
-
);
|
|
22449
|
+
var DIARIST_SESSIONS_DESCRIPTION = "\u5BF9\u8BDD\u8FB9\u754C\u3002\u6BCF\u5377\u542B path\uFF08\u4F1A\u8BDD\u5377\u7EDD\u5BF9\u6216\u53EF\u8BFB\u8DEF\u5F84\uFF09\u4E0E ranges\uFF08\u672C\u5377\u672C\u8F6E\u5404\u533A\u95F4\uFF09\u3002\u6BCF\u6BB5\u533A\u95F4\u542B from / to\uFF1B\u8D77\u70B9\u4E0E\u7EC8\u70B9\u5404\u5199 id\uFF08\u539F\u751F id\uFF09\u6216 line\uFF08\u672C\u8F6E\u884C\u53F7\uFF09\uFF0C\u4E8C\u9009\u4E00\u3002\u7A7A\u5217\u8868\uFF1D\u672C\u8F6E\u65E0\u5BF9\u8BDD\u53EF\u5212\u3002\u7AEF\u70B9\u65E0\u6CD5\u6307\u540D\u65F6\u8D70 reask\uFF0C\u4E0D\u4E2D\u6B62\u3002";
|
|
22544
22450
|
var diaristOutputSchema = withTerminatingOutputDeclarations(
|
|
22545
22451
|
openToolObject(
|
|
22546
22452
|
Type18.Object({
|
|
@@ -22552,24 +22458,13 @@ var diaristOutputSchema = withTerminatingOutputDeclarations(
|
|
|
22552
22458
|
description: "\u672C\u5EAD\u5BF9\u8C61\u7968\u53F7\uFF08\u6B63\u6574\u6570\uFF09\u6216 null/\u7701\u7565\uFF1D\u771F\u65E0\u7968\uFF1B\u4E0B\u6E38\u8D70 typed \u952E\uFF1B\u8BA4\u4E0D\u51FA\u7528 status=escalate\uFF0C\u4E0D\u6D17\u6210\u65E0\u5F55\u3002\u673A\u68B0\u5C42\u4E0D\u91CD\u5224\u3002"
|
|
22553
22459
|
})
|
|
22554
22460
|
),
|
|
22555
|
-
reason: Type18.
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
|
|
22561
|
-
|
|
22562
|
-
Type18.Array(
|
|
22563
|
-
Type18.Object(
|
|
22564
|
-
{
|
|
22565
|
-
ticketNumber: Type18.Unknown({ description: "\u672C\u6761\u8FB9\u754C\u6240\u5F52\u7968\u53F7\uFF08\u6B63\u6574\u6570\uFF09" }),
|
|
22566
|
-
sessions: diaristSessionsSchema
|
|
22567
|
-
},
|
|
22568
|
-
{ additionalProperties: true }
|
|
22569
|
-
),
|
|
22570
|
-
{ description: "\u591A\u7968\u5EAD\u9010\u7968\u5BF9\u8BDD\u8FB9\u754C\uFF1B\u4E00\u6B21\u4EA4\u5377\u5404\u7968\u5404\u81EA\u5206\u5F55\u3002\u4E0E\u5355\u7968 sessions \u4E8C\u9009\u4E00\u3002" }
|
|
22571
|
-
)
|
|
22572
|
-
)
|
|
22461
|
+
reason: Type18.Unknown({
|
|
22462
|
+
description: "status \u4E3A escalate \u65F6\uFF1A\u8BA4\u4E0D\u51FA\u672C\u5EAD\u5BF9\u8C61\u7684\u539F\u56E0"
|
|
22463
|
+
}),
|
|
22464
|
+
sessions: Type18.Optional(Type18.Unknown({ description: DIARIST_SESSIONS_DESCRIPTION })),
|
|
22465
|
+
ticketSessions: Type18.Unknown({
|
|
22466
|
+
description: `\u591A\u7968\u5EAD\u9010\u7968\u5BF9\u8BDD\u8FB9\u754C\uFF1B\u6BCF\u7968\u542B ticketNumber\uFF08\u672C\u6761\u8FB9\u754C\u6240\u5F52\u7968\u53F7\uFF0C\u6B63\u6574\u6570\uFF09\u4E0E sessions\uFF08${DIARIST_SESSIONS_DESCRIPTION}\uFF09\u3002\u4E00\u6B21\u4EA4\u5377\u5404\u7968\u5404\u81EA\u5206\u5F55\u3002\u4E0E\u5355\u7968 sessions \u4E8C\u9009\u4E00\u3002`
|
|
22467
|
+
})
|
|
22573
22468
|
})
|
|
22574
22469
|
)
|
|
22575
22470
|
);
|
|
@@ -22593,19 +22488,13 @@ var secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
|
22593
22488
|
description: "converged | escalate"
|
|
22594
22489
|
}),
|
|
22595
22490
|
ticketNumber: Type19.Optional(
|
|
22596
|
-
Type19.
|
|
22491
|
+
Type19.Unknown({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
|
|
22597
22492
|
),
|
|
22598
|
-
note: Type19.
|
|
22493
|
+
note: Type19.Unknown({ description: "\u9644\u6CE8" }),
|
|
22599
22494
|
evidence: Type19.Optional(Type19.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
|
|
22600
|
-
decisionGate: Type19.
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
question: Type19.Optional(Type19.String()),
|
|
22604
|
-
options: Type19.Optional(Type19.Array(Type19.String()))
|
|
22605
|
-
},
|
|
22606
|
-
{ additionalProperties: true, description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879" }
|
|
22607
|
-
)
|
|
22608
|
-
)
|
|
22495
|
+
decisionGate: Type19.Unknown({
|
|
22496
|
+
description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u5199 question \u4E0E options\uFF0C\u539F\u6837\u7559\u5B58\u3002"
|
|
22497
|
+
})
|
|
22609
22498
|
},
|
|
22610
22499
|
{ additionalProperties: true }
|
|
22611
22500
|
)
|
|
@@ -22666,31 +22555,17 @@ init_open_tool_schema();
|
|
|
22666
22555
|
init_terminating_infrastructure();
|
|
22667
22556
|
init_reviewer_output();
|
|
22668
22557
|
import { Type as Type20 } from "typebox";
|
|
22669
|
-
var
|
|
22670
|
-
completeness: Type20.Optional(Type20.String({
|
|
22671
|
-
description: "completeness lens \u5B8C\u6574\u62A5\u544A\uFF1Acandidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict\uFF1B\u975E\u4EC5 verdict \u4E00\u884C\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u82E5\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u4E8E\u6B64"
|
|
22672
|
-
})),
|
|
22673
|
-
correctness: Type20.Optional(Type20.String({
|
|
22674
|
-
description: "correctness lens \u5B8C\u6574\u62A5\u544A\uFF1Acandidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict\uFF1B\u975E\u4EC5 verdict \u4E00\u884C\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u82E5\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u4E8E\u6B64"
|
|
22675
|
-
}))
|
|
22676
|
-
}, {
|
|
22677
|
-
additionalProperties: true,
|
|
22678
|
-
description: "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002"
|
|
22679
|
-
});
|
|
22558
|
+
var REVIEWER_AMENDMENTS_DESCRIPTION = "\u5DF2\u8FD0\u884C lens \u7684 amendments \u627F\u8F7D candidates\u3001\u9010\u6761\u5904\u7F6E\u4E0E verdict \u7684\u5B8C\u6574\u62A5\u544A\uFF08\u975E\u4EC5 verdict \u884C\uFF09\uFF1B\u663E\u5F0F\u5355\u8F74\u65F6\u53E6\u4E00\u8F74\u53EF\u7701\u7565\uFF08completeness / correctness\uFF09\u3002hard-stop\uFF0Fusage error \u4E3A refused \u65F6\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u5BF9\u5E94 lens \u5B57\u6BB5\u3002";
|
|
22680
22559
|
var REVIEWER_STATUS_DESCRIPTION = "completed | refused\u3002\u4E24\u79CD\u6B63\u5E38 lens verdict\uFF08completeness / correctness\uFF09\u5747 completed\uFF1Bhard-stop \u4E0E usage error \u4E3A refused\uFF08\u5DF2\u4EA7\u51FA\u62A5\u544A\u4ECD\u7167\u5F55\u8FDB\u6240\u9009 lens amendments\uFF09\u3002";
|
|
22681
|
-
var
|
|
22682
|
-
Type20.
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
diagnostic: Type20.String({ description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E\uFF1Bhard-stop\uFF0Fusage error \u539F\u56E0\u8FDB\u6B64\u5B57\u6BB5\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u53E6\u7167\u5F55 amendments" }),
|
|
22689
|
-
amendments: Type20.Optional(reviewerAmendmentsSchema)
|
|
22690
|
-
}, { additionalProperties: false })
|
|
22691
|
-
]);
|
|
22560
|
+
var reviewerOutputObject = Type20.Object({
|
|
22561
|
+
status: Type20.Unknown({ description: REVIEWER_STATUS_DESCRIPTION }),
|
|
22562
|
+
amendments: Type20.Unknown({ description: REVIEWER_AMENDMENTS_DESCRIPTION }),
|
|
22563
|
+
diagnostic: Type20.Unknown({
|
|
22564
|
+
description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E\uFF1Bhard-stop\uFF0Fusage error \u539F\u56E0\u8FDB\u6B64\u5B57\u6BB5\uFF0C\u5DF2\u4EA7\u51FA\u62A5\u544A\u53E6\u7167\u5F55 amendments"
|
|
22565
|
+
})
|
|
22566
|
+
});
|
|
22692
22567
|
var reviewerOutputSchema = withTerminatingOutputDeclarations(
|
|
22693
|
-
|
|
22568
|
+
openToolObject(reviewerOutputObject)
|
|
22694
22569
|
);
|
|
22695
22570
|
function createReviewerRoleRuntime(pi, dependencies, _hostActions) {
|
|
22696
22571
|
let soul;
|
|
@@ -22844,10 +22719,19 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
22844
22719
|
function isRecord15(value) {
|
|
22845
22720
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22846
22721
|
}
|
|
22722
|
+
function containsWrittenReason(value) {
|
|
22723
|
+
if (typeof value === "string") return value.trim().length > 0;
|
|
22724
|
+
if (Array.isArray(value)) return value.some(containsWrittenReason);
|
|
22725
|
+
if (typeof value === "object" && value !== null) {
|
|
22726
|
+
return Object.entries(value).some(
|
|
22727
|
+
([key, item]) => containsWrittenReason(key) || containsWrittenReason(item)
|
|
22728
|
+
);
|
|
22729
|
+
}
|
|
22730
|
+
return false;
|
|
22731
|
+
}
|
|
22847
22732
|
function unfinishedReasonPresent(details) {
|
|
22848
|
-
if (typeof details !== "object" || details === null) return false;
|
|
22849
|
-
|
|
22850
|
-
return typeof reason === "string" && reason.trim().length > 0;
|
|
22733
|
+
if (typeof details !== "object" || details === null || Array.isArray(details)) return false;
|
|
22734
|
+
return containsWrittenReason(details.reason);
|
|
22851
22735
|
}
|
|
22852
22736
|
function readGateState(session) {
|
|
22853
22737
|
let baseline;
|
|
@@ -22883,11 +22767,11 @@ function reliableWindow(cwd, baseline, head) {
|
|
|
22883
22767
|
const raw = git2(cwd, ["log", "--format=%P%x1e%s", range]);
|
|
22884
22768
|
if (raw.length === 0) return [];
|
|
22885
22769
|
return raw.split("\n").flatMap((line2) => {
|
|
22886
|
-
const
|
|
22887
|
-
if (
|
|
22770
|
+
const sep5 = line2.indexOf("");
|
|
22771
|
+
if (sep5 < 0) return [];
|
|
22888
22772
|
return [{
|
|
22889
|
-
subject: line2.slice(
|
|
22890
|
-
merge: line2.slice(0,
|
|
22773
|
+
subject: line2.slice(sep5 + 1),
|
|
22774
|
+
merge: line2.slice(0, sep5).trim().includes(" ")
|
|
22891
22775
|
}];
|
|
22892
22776
|
});
|
|
22893
22777
|
}
|
|
@@ -23001,27 +22885,16 @@ function fixerBashSeatbeltDenyReason(matched) {
|
|
|
23001
22885
|
|
|
23002
22886
|
// src/worker-role.ts
|
|
23003
22887
|
var CODER_STATUS_DESCRIPTION = `planned | completed | refused | partially_completed | unfinished\u3002unfinished\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u3002${PARTIALLY_COMPLETED_DEFINITION}`;
|
|
23004
|
-
var
|
|
23005
|
-
Type21.
|
|
23006
|
-
|
|
23007
|
-
|
|
23008
|
-
|
|
23009
|
-
|
|
23010
|
-
|
|
23011
|
-
|
|
23012
|
-
}, { additionalProperties: false }),
|
|
23013
|
-
Type21.Object({
|
|
23014
|
-
status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
23015
|
-
report: Type21.String({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
23016
|
-
remainingScope: Type21.String({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
|
|
23017
|
-
reason: Type21.Optional(Type21.String({
|
|
23018
|
-
minLength: 1,
|
|
23019
|
-
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"
|
|
23020
|
-
}))
|
|
23021
|
-
}, { additionalProperties: false })
|
|
23022
|
-
]);
|
|
22888
|
+
var coderOutputObject = Type21.Object({
|
|
22889
|
+
status: Type21.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
22890
|
+
report: Type21.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
22891
|
+
remainingScope: Type21.Unknown({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
|
|
22892
|
+
reason: Type21.Unknown({
|
|
22893
|
+
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"
|
|
22894
|
+
})
|
|
22895
|
+
});
|
|
23023
22896
|
var coderOutputSchema = withTerminatingOutputDeclarations(
|
|
23024
|
-
|
|
22897
|
+
openToolObject(coderOutputObject)
|
|
23025
22898
|
);
|
|
23026
22899
|
var FIXER_FLAG_DEFINITIONS = {
|
|
23027
22900
|
packet: {
|
|
@@ -23747,7 +23620,7 @@ function readDiaristTicketAssertion(submitted) {
|
|
|
23747
23620
|
function readRoleRunCoordinates(ctx, label) {
|
|
23748
23621
|
const runDirectory = runDirectoryFromHostContext(ctx);
|
|
23749
23622
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23750
|
-
const admittedPath =
|
|
23623
|
+
const admittedPath = join43(runDirectory, "admitted-request.json");
|
|
23751
23624
|
const admitted = JSON.parse(readFileSync6(admittedPath, "utf8"));
|
|
23752
23625
|
if (typeof admitted.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23753
23626
|
throw new Error(`${label} admitted-request missing projectRoot (${admittedPath})`);
|
|
@@ -24677,7 +24550,7 @@ init_packaged_role_registry();
|
|
|
24677
24550
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
24678
24551
|
import { appendFile as appendFile3, mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
|
|
24679
24552
|
import { createServer } from "node:net";
|
|
24680
|
-
import { dirname as dirname25, join as
|
|
24553
|
+
import { dirname as dirname25, join as join44 } from "node:path";
|
|
24681
24554
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
24682
24555
|
init_role_activation_flags();
|
|
24683
24556
|
init_submission_correctable_error();
|
|
@@ -24723,7 +24596,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
24723
24596
|
const hostAbort = new AbortController();
|
|
24724
24597
|
const runId = request.runDirectory.split("/").filter(Boolean).at(-1) ?? randomUUID9();
|
|
24725
24598
|
await mkdir5(request.runDirectory, { recursive: true });
|
|
24726
|
-
let sessionFile = options.sessionFile ??
|
|
24599
|
+
let sessionFile = options.sessionFile ?? join44(request.runDirectory, "session", "session.jsonl");
|
|
24727
24600
|
await mkdir5(dirname25(sessionFile), { recursive: true });
|
|
24728
24601
|
if (request.continuation.kind !== "resume") {
|
|
24729
24602
|
try {
|
|
@@ -25247,7 +25120,7 @@ import { spawn as spawn3, spawnSync as spawnSync3 } from "node:child_process";
|
|
|
25247
25120
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
25248
25121
|
import { existsSync as existsSync15 } from "node:fs";
|
|
25249
25122
|
import { writeFile as writeFile10 } from "node:fs/promises";
|
|
25250
|
-
import { dirname as dirname26, isAbsolute as isAbsolute12, join as
|
|
25123
|
+
import { dirname as dirname26, isAbsolute as isAbsolute12, join as join45, resolve as resolve21 } from "node:path";
|
|
25251
25124
|
|
|
25252
25125
|
// src/external-host-turn-loop.ts
|
|
25253
25126
|
var EXTERNAL_ROLE_TURN_ROUND_LIMIT = 8;
|
|
@@ -25697,7 +25570,7 @@ function formatCodexFailurePayload(payload) {
|
|
|
25697
25570
|
function cwdIsGitWorkTree(cwd) {
|
|
25698
25571
|
let dir = cwd;
|
|
25699
25572
|
for (; ; ) {
|
|
25700
|
-
if (existsSync15(
|
|
25573
|
+
if (existsSync15(join45(dir, ".git"))) return true;
|
|
25701
25574
|
const parent = dirname26(dir);
|
|
25702
25575
|
if (parent === dir) return false;
|
|
25703
25576
|
dir = parent;
|
|
@@ -25908,13 +25781,13 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25908
25781
|
await config.sessionIdentity.bind(request.principal, sessionId);
|
|
25909
25782
|
}
|
|
25910
25783
|
const env = { ...process.env, ...config.env ?? {} };
|
|
25911
|
-
const systemPromptPath =
|
|
25784
|
+
const systemPromptPath = join45(request.runDirectory, "headless-system-prompt.txt");
|
|
25912
25785
|
await writeFile10(systemPromptPath, systemPrompt, "utf8");
|
|
25913
25786
|
let mcpConfigPath;
|
|
25914
25787
|
let outputSchemaPath;
|
|
25915
25788
|
if (codex) {
|
|
25916
25789
|
if (prepared.terminatingToolName !== NAVIGATOR_OUTPUT_TOOL_NAME) {
|
|
25917
|
-
outputSchemaPath =
|
|
25790
|
+
outputSchemaPath = join45(request.runDirectory, "headless-output-schema.json");
|
|
25918
25791
|
await writeFile10(
|
|
25919
25792
|
outputSchemaPath,
|
|
25920
25793
|
`${JSON.stringify(closeJsonSchemaForCodex(prepared.jsonSchema), null, 2)}
|
|
@@ -25923,7 +25796,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
25923
25796
|
);
|
|
25924
25797
|
}
|
|
25925
25798
|
} else {
|
|
25926
|
-
mcpConfigPath =
|
|
25799
|
+
mcpConfigPath = join45(request.runDirectory, "headless-mcp-config.json");
|
|
25927
25800
|
await writeFile10(
|
|
25928
25801
|
mcpConfigPath,
|
|
25929
25802
|
`${JSON.stringify(headlessMcpConfigDocument(prepared.mcpServers), null, 2)}
|
|
@@ -26187,7 +26060,7 @@ function createHeadlessRoleTurnHost(config) {
|
|
|
26187
26060
|
host: config.hostName,
|
|
26188
26061
|
sessionId: exitedSessionId,
|
|
26189
26062
|
cwd: request.cwd,
|
|
26190
|
-
sessionDirectory:
|
|
26063
|
+
sessionDirectory: join45(request.runDirectory, "session"),
|
|
26191
26064
|
sessionParent,
|
|
26192
26065
|
continuation: request.continuation,
|
|
26193
26066
|
...request.model !== void 0 ? { model: request.model } : {},
|