@akagilnc/pi-workflow-roles 0.1.5583 → 0.1.5598
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/acp-host/production-host.js +393 -854
- package/dist/collector-config.js +0 -44
- package/dist/headless-host/production-host.js +361 -822
- package/dist/merger-contracts.js +6 -2
- package/dist/migrate-book-topology.js +4855 -10472
- package/dist/package-contracts/worker-output.js +1 -6
- package/dist/packaged-role-registry.js +5 -4
- package/dist/public-cli/instruction-seat-run.js +8 -8
- package/dist/public-cli/invocation.js +93 -236
- package/dist/public-cli/main.js +18409 -18786
- package/dist/public-cli/option-definitions.js +7 -7
- package/dist/public-cli/post-admission.js +11 -40
- package/dist/public-cli/run-lifecycle.js +11 -43
- package/dist/public-role-summons.js +1 -1
- package/dist/role-run-relocation.js +14 -23
- package/package.json +1 -1
- package/scripts/build-package.mjs +0 -1
- package/src/collector-config.ts +0 -42
- package/src/collector-role.ts +10 -20
- package/src/host-contracts.ts +0 -3
- package/src/merger-contracts.ts +6 -2
- package/src/merger-role.ts +11 -1
- package/src/navigator-attendance.ts +2 -2
- package/src/package-contracts/worker-output.ts +0 -8
- package/src/packaged-role-registry.ts +4 -3
- package/src/public-cli/instruction-seat-run.ts +7 -8
- package/src/public-cli/invocation.ts +113 -351
- package/src/public-cli/option-definitions.ts +7 -7
- package/src/public-cli/post-admission.ts +12 -56
- package/src/public-cli/run-lifecycle.ts +11 -55
- package/src/public-role-summons.ts +1 -1
- package/src/role-run-placement.ts +0 -1
- package/src/role-run-relocation.ts +14 -25
- package/src/role-runtime-dependencies.ts +0 -2
- package/src/role-runtime.ts +0 -16
- package/src/worker-role.ts +11 -78
- package/dist/package-contracts/fixer-packet.js +0 -77
- package/packets/fixer-prerequisites.json +0 -6
- package/src/package-contracts/fixer-packet.ts +0 -91
|
@@ -1200,7 +1200,7 @@ async function runEngineDetourOnce(input) {
|
|
|
1200
1200
|
}
|
|
1201
1201
|
const command = input.argv[0];
|
|
1202
1202
|
const args = input.argv.slice(1);
|
|
1203
|
-
return await new Promise((
|
|
1203
|
+
return await new Promise((resolve21, reject) => {
|
|
1204
1204
|
let settled = false;
|
|
1205
1205
|
const signal = input.signal;
|
|
1206
1206
|
const child = spawn(command, args, {
|
|
@@ -1216,7 +1216,7 @@ async function runEngineDetourOnce(input) {
|
|
|
1216
1216
|
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
1217
1217
|
stderr += chunk;
|
|
1218
1218
|
});
|
|
1219
|
-
const
|
|
1219
|
+
const fail3 = (error) => {
|
|
1220
1220
|
if (settled) return;
|
|
1221
1221
|
settled = true;
|
|
1222
1222
|
if (signal !== void 0) {
|
|
@@ -1230,10 +1230,10 @@ async function runEngineDetourOnce(input) {
|
|
|
1230
1230
|
if (signal !== void 0) {
|
|
1231
1231
|
signal.removeEventListener("abort", onAbort);
|
|
1232
1232
|
}
|
|
1233
|
-
|
|
1233
|
+
resolve21(result);
|
|
1234
1234
|
};
|
|
1235
1235
|
const onAbort = () => {
|
|
1236
|
-
|
|
1236
|
+
fail3(signal !== void 0 ? abortReasonError(signal) : new Error("aborted"));
|
|
1237
1237
|
try {
|
|
1238
1238
|
child.kill("SIGTERM");
|
|
1239
1239
|
} catch {
|
|
@@ -1246,7 +1246,7 @@ async function runEngineDetourOnce(input) {
|
|
|
1246
1246
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
|
-
child.on("error", (error) =>
|
|
1249
|
+
child.on("error", (error) => fail3(error));
|
|
1250
1250
|
child.on("close", (code) => {
|
|
1251
1251
|
succeed({ code: code ?? 1, stdout, stderr });
|
|
1252
1252
|
});
|
|
@@ -1608,85 +1608,8 @@ var init_fixer_output = __esm({
|
|
|
1608
1608
|
}
|
|
1609
1609
|
});
|
|
1610
1610
|
|
|
1611
|
-
// src/package-contracts/fixer-packet.ts
|
|
1612
|
-
import { Type as Type8 } from "typebox";
|
|
1613
|
-
import { Value } from "typebox/value";
|
|
1614
|
-
function causeMessage(cause) {
|
|
1615
|
-
if (cause instanceof Error) return cause.message;
|
|
1616
|
-
if (typeof cause === "string") return cause;
|
|
1617
|
-
try {
|
|
1618
|
-
return JSON.stringify(cause) ?? String(cause);
|
|
1619
|
-
} catch {
|
|
1620
|
-
return String(cause);
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
function fail(cause) {
|
|
1624
|
-
throw new FixerPacketValidationError(cause);
|
|
1625
|
-
}
|
|
1626
|
-
function parseFailure(value) {
|
|
1627
|
-
if (!Array.isArray(value)) fail(new Error("Fixer prerequisites must be a JSON array"));
|
|
1628
|
-
for (const entry of value) {
|
|
1629
|
-
if (!isRecord(entry)) {
|
|
1630
|
-
fail(new Error("Fixer prerequisite entry must be an object with id and requirement fields"));
|
|
1631
|
-
}
|
|
1632
|
-
if (typeof entry.id !== "string" || !new RegExp(FIXER_PREREQUISITE_ID_PATTERN).test(entry.id)) {
|
|
1633
|
-
fail(new Error(`Fixer prerequisite id violates pattern ${FIXER_PREREQUISITE_ID_PATTERN}`));
|
|
1634
|
-
}
|
|
1635
|
-
if (typeof entry.requirement !== "string" || !/\S/.test(entry.requirement)) {
|
|
1636
|
-
fail(new Error("Fixer prerequisite requirement must be nonblank"));
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
fail(new Error("Fixer prerequisites violate the attachment schema"));
|
|
1640
|
-
}
|
|
1641
|
-
function validateFixerPrerequisites(value) {
|
|
1642
|
-
if (!Value.Check(fixerPrerequisitesSchema, value)) parseFailure(value);
|
|
1643
|
-
const entries = value;
|
|
1644
|
-
const ids = /* @__PURE__ */ new Set();
|
|
1645
|
-
const prerequisites = entries.map((entry) => {
|
|
1646
|
-
if (ids.has(entry.id)) {
|
|
1647
|
-
fail(new Error(`Fixer prerequisites contain duplicate id: ${entry.id}`));
|
|
1648
|
-
}
|
|
1649
|
-
ids.add(entry.id);
|
|
1650
|
-
return Object.freeze({ id: entry.id, requirement: entry.requirement });
|
|
1651
|
-
});
|
|
1652
|
-
return Object.freeze(prerequisites);
|
|
1653
|
-
}
|
|
1654
|
-
function parseFixerPrerequisites(source) {
|
|
1655
|
-
let decoded;
|
|
1656
|
-
try {
|
|
1657
|
-
decoded = JSON.parse(source);
|
|
1658
|
-
} catch (error) {
|
|
1659
|
-
fail(error);
|
|
1660
|
-
}
|
|
1661
|
-
return validateFixerPrerequisites(decoded);
|
|
1662
|
-
}
|
|
1663
|
-
var FIXER_PREREQUISITE_ID_PATTERN, fixerPrerequisiteSchema, fixerPrerequisitesSchema, FixerPacketValidationError;
|
|
1664
|
-
var init_fixer_packet = __esm({
|
|
1665
|
-
"src/package-contracts/fixer-packet.ts"() {
|
|
1666
|
-
"use strict";
|
|
1667
|
-
init_unknown_value();
|
|
1668
|
-
FIXER_PREREQUISITE_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]*$";
|
|
1669
|
-
fixerPrerequisiteSchema = Type8.Object({
|
|
1670
|
-
id: Type8.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
|
|
1671
|
-
requirement: Type8.String({ pattern: "\\S" })
|
|
1672
|
-
});
|
|
1673
|
-
fixerPrerequisitesSchema = Type8.Array(fixerPrerequisiteSchema);
|
|
1674
|
-
FixerPacketValidationError = class extends Error {
|
|
1675
|
-
code = "AK_INVALID_FIX_PACKET";
|
|
1676
|
-
constructor(cause) {
|
|
1677
|
-
const prefix = "Fixer prerequisites or instructions violate the invocation contract";
|
|
1678
|
-
super(
|
|
1679
|
-
cause === void 0 ? prefix : `${prefix}: ${causeMessage(cause)}`,
|
|
1680
|
-
cause === void 0 ? void 0 : { cause }
|
|
1681
|
-
);
|
|
1682
|
-
this.name = "FixerPacketValidationError";
|
|
1683
|
-
}
|
|
1684
|
-
};
|
|
1685
|
-
}
|
|
1686
|
-
});
|
|
1687
|
-
|
|
1688
1611
|
// src/package-contracts/worker-output.ts
|
|
1689
|
-
import { Type as
|
|
1612
|
+
import { Type as Type8 } from "typebox";
|
|
1690
1613
|
function validateAcceptedCoderDetails(output) {
|
|
1691
1614
|
return output;
|
|
1692
1615
|
}
|
|
@@ -1699,15 +1622,14 @@ var init_worker_output = __esm({
|
|
|
1699
1622
|
"use strict";
|
|
1700
1623
|
init_open_tool_schema();
|
|
1701
1624
|
init_fixer_output();
|
|
1702
|
-
init_fixer_packet();
|
|
1703
1625
|
init_terminating_infrastructure();
|
|
1704
1626
|
CODER_OUTPUT_TOOL_NAME = "ak_coder_output";
|
|
1705
1627
|
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}`;
|
|
1706
|
-
coderOutputObject =
|
|
1707
|
-
status:
|
|
1708
|
-
report:
|
|
1709
|
-
remainingScope:
|
|
1710
|
-
reason:
|
|
1628
|
+
coderOutputObject = Type8.Object({
|
|
1629
|
+
status: Type8.Unknown({ description: CODER_STATUS_DESCRIPTION }),
|
|
1630
|
+
report: Type8.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
1631
|
+
remainingScope: Type8.Unknown({ description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
|
|
1632
|
+
reason: Type8.Unknown({
|
|
1711
1633
|
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"
|
|
1712
1634
|
})
|
|
1713
1635
|
});
|
|
@@ -1725,7 +1647,7 @@ var init_canonical_json = __esm({
|
|
|
1725
1647
|
});
|
|
1726
1648
|
|
|
1727
1649
|
// src/doctor-contracts.ts
|
|
1728
|
-
import { Type as
|
|
1650
|
+
import { Type as Type9 } from "typebox";
|
|
1729
1651
|
function validateDoctorSubmissionShape(value) {
|
|
1730
1652
|
return value;
|
|
1731
1653
|
}
|
|
@@ -1751,25 +1673,25 @@ var init_doctor_contracts = __esm({
|
|
|
1751
1673
|
biteNone = "noRealBite";
|
|
1752
1674
|
DOCTOR_BITE_KINDS = [biteActual, biteNone];
|
|
1753
1675
|
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";
|
|
1754
|
-
doctorSubmissionObject =
|
|
1755
|
-
status:
|
|
1756
|
-
case:
|
|
1676
|
+
doctorSubmissionObject = Type9.Object({
|
|
1677
|
+
status: Type9.Unknown({ description: DOCTOR_STATUS_DESCRIPTION }),
|
|
1678
|
+
case: Type9.Unknown({
|
|
1757
1679
|
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"
|
|
1758
1680
|
}),
|
|
1759
|
-
findings:
|
|
1681
|
+
findings: Type9.Unknown({
|
|
1760
1682
|
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`
|
|
1761
1683
|
}),
|
|
1762
|
-
reason:
|
|
1684
|
+
reason: Type9.Unknown({
|
|
1763
1685
|
description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0\uFF1B\u4EC5 refused \u65F6\u7528\u3002"
|
|
1764
1686
|
}),
|
|
1765
|
-
missingEvidence:
|
|
1687
|
+
missingEvidence: Type9.Unknown({
|
|
1766
1688
|
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"
|
|
1767
1689
|
})
|
|
1768
1690
|
});
|
|
1769
1691
|
doctorSubmissionSchema = withTerminatingOutputDeclarations(
|
|
1770
1692
|
openToolObject(doctorSubmissionObject)
|
|
1771
1693
|
);
|
|
1772
|
-
doctorEvidenceReadSchema =
|
|
1694
|
+
doctorEvidenceReadSchema = Type9.Object({ evidenceId: Type9.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: Type9.Optional(Type9.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: Type9.Optional(Type9.Integer({ minimum: 1, description: "\u8FD4\u56DE\u5B57\u8282\u6570\uFF08\u65E0\u4E0A\u9650\uFF09" })) }, { additionalProperties: true });
|
|
1773
1695
|
DoctorEvidenceStore = class {
|
|
1774
1696
|
constructor(patient) {
|
|
1775
1697
|
this.patient = patient;
|
|
@@ -1838,8 +1760,8 @@ var init_exact_utf8 = __esm({
|
|
|
1838
1760
|
});
|
|
1839
1761
|
|
|
1840
1762
|
// src/merger-contracts.ts
|
|
1841
|
-
import { Type as
|
|
1842
|
-
function
|
|
1763
|
+
import { Type as Type10 } from "typebox";
|
|
1764
|
+
function fail(message = "Merger input violates its exact contract") {
|
|
1843
1765
|
throw new MergerInputContractError(message);
|
|
1844
1766
|
}
|
|
1845
1767
|
function deepFreeze(value) {
|
|
@@ -1850,14 +1772,17 @@ function deepFreeze(value) {
|
|
|
1850
1772
|
return value;
|
|
1851
1773
|
}
|
|
1852
1774
|
function readMaterial(value, label) {
|
|
1853
|
-
if (!isRecord(value) || typeof value.bytesBase64 !== "string")
|
|
1775
|
+
if (!isRecord(value) || typeof value.bytesBase64 !== "string") fail(`Merger ${label} material is malformed`);
|
|
1854
1776
|
exactUtf8(Buffer.from(value.bytesBase64, "base64"), `Merger ${label} material`);
|
|
1855
1777
|
return { bytesBase64: value.bytesBase64, sha256: typeof value.sha256 === "string" ? value.sha256 : "" };
|
|
1856
1778
|
}
|
|
1857
1779
|
function validateMergerInput(value) {
|
|
1858
|
-
if (!isRecord(value) || blank(value.attemptId))
|
|
1859
|
-
if (!isRecord(value.materials))
|
|
1860
|
-
const materials = {
|
|
1780
|
+
if (!isRecord(value) || blank(value.attemptId)) fail("Merger input requires a non-empty attemptId for accounting");
|
|
1781
|
+
if (!isRecord(value.materials)) fail("Merger materials are missing");
|
|
1782
|
+
const materials = {
|
|
1783
|
+
targetIntent: readMaterial(value.materials.targetIntent, "targetIntent"),
|
|
1784
|
+
sourceIntent: readMaterial(value.materials.sourceIntent, "sourceIntent")
|
|
1785
|
+
};
|
|
1861
1786
|
const authorizedChecks = Array.isArray(value.authorizedChecks) ? value.authorizedChecks.filter((check) => isRecord(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) : [];
|
|
1862
1787
|
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 }));
|
|
1863
1788
|
}
|
|
@@ -1869,24 +1794,25 @@ var init_merger_contracts = __esm({
|
|
|
1869
1794
|
init_open_tool_schema();
|
|
1870
1795
|
init_terminating_infrastructure();
|
|
1871
1796
|
init_unknown_value();
|
|
1872
|
-
materialSchema =
|
|
1873
|
-
checkSchema =
|
|
1874
|
-
mergerInputSchema =
|
|
1875
|
-
attemptId:
|
|
1876
|
-
targetObjectId:
|
|
1877
|
-
sourceObjectId:
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1797
|
+
materialSchema = Type10.Object({ bytesBase64: Type10.String(), sha256: Type10.String() });
|
|
1798
|
+
checkSchema = Type10.Object({ name: Type10.String({ minLength: 1 }), argv: Type10.Array(Type10.String({ minLength: 1 }), { minItems: 1 }) });
|
|
1799
|
+
mergerInputSchema = Type10.Object({
|
|
1800
|
+
attemptId: Type10.String({ minLength: 1, description: "\u5BF9\u8D26 attempt \u8EAB\u4EFD\uFF08transport\uFF09" }),
|
|
1801
|
+
targetObjectId: Type10.String({ description: "\u6750\u6599\uFF1Atarget parent OID\uFF1B\u53EF\u7A7A" }),
|
|
1802
|
+
sourceObjectId: Type10.String({ description: "\u6750\u6599\uFF1Asource parent OID\uFF1B\u53EF\u7A7A" }),
|
|
1803
|
+
// #1168: task/authority dispatch copies removed; git-fact intents remain.
|
|
1804
|
+
materials: Type10.Object({ targetIntent: materialSchema, sourceIntent: materialSchema }),
|
|
1805
|
+
expectedConflictPaths: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u5F53\u524D\u672A\u5408\u5E76\u8DEF\u5F84\uFF1B\u53EF\u7A7A" }),
|
|
1806
|
+
resolutionScope: Type10.Array(Type10.String(), { description: "\u6750\u6599\uFF1A\u89E3\u6790\u8303\u56F4\u63D0\u793A\uFF1B\u53EF\u7A7A" }),
|
|
1807
|
+
authorizedChecks: Type10.Array(checkSchema)
|
|
1882
1808
|
});
|
|
1883
1809
|
MERGER_STATUS_DESCRIPTION = "completed | escalate";
|
|
1884
|
-
mergerOutputObject =
|
|
1885
|
-
status:
|
|
1886
|
-
attemptId:
|
|
1887
|
-
report:
|
|
1888
|
-
mergeCommitId:
|
|
1889
|
-
diagnosis:
|
|
1810
|
+
mergerOutputObject = Type10.Object({
|
|
1811
|
+
status: Type10.Unknown({ description: MERGER_STATUS_DESCRIPTION }),
|
|
1812
|
+
attemptId: Type10.Unknown({ description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }),
|
|
1813
|
+
report: Type10.Unknown({ description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
|
|
1814
|
+
mergeCommitId: Type10.Unknown({ description: "\u5B8C\u6210\u5408\u5E76 commit object ID" }),
|
|
1815
|
+
diagnosis: Type10.Unknown({
|
|
1890
1816
|
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"
|
|
1891
1817
|
})
|
|
1892
1818
|
});
|
|
@@ -1941,7 +1867,7 @@ var init_countersign_contracts = __esm({
|
|
|
1941
1867
|
});
|
|
1942
1868
|
|
|
1943
1869
|
// src/gleaner-left-contracts.ts
|
|
1944
|
-
import { Type as
|
|
1870
|
+
import { Type as Type11 } from "typebox";
|
|
1945
1871
|
var GLEANER_LEFT_OUTPUT_TOOL_NAME, gleanerLeftOutputSchema, GLEANER_LEFT_BASE_FLAG;
|
|
1946
1872
|
var init_gleaner_left_contracts = __esm({
|
|
1947
1873
|
"src/gleaner-left-contracts.ts"() {
|
|
@@ -1952,11 +1878,11 @@ var init_gleaner_left_contracts = __esm({
|
|
|
1952
1878
|
GLEANER_LEFT_OUTPUT_TOOL_NAME = "ak_gleaner_left_output";
|
|
1953
1879
|
gleanerLeftOutputSchema = withTerminatingOutputDeclarations(
|
|
1954
1880
|
openToolObject(
|
|
1955
|
-
|
|
1956
|
-
status:
|
|
1881
|
+
Type11.Object({
|
|
1882
|
+
status: Type11.Unknown({
|
|
1957
1883
|
description: "completed"
|
|
1958
1884
|
}),
|
|
1959
|
-
findings:
|
|
1885
|
+
findings: Type11.Unknown({
|
|
1960
1886
|
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"
|
|
1961
1887
|
})
|
|
1962
1888
|
})
|
|
@@ -2044,7 +1970,7 @@ var init_ticket_provenance_contracts = __esm({
|
|
|
2044
1970
|
});
|
|
2045
1971
|
|
|
2046
1972
|
// src/diarist-contracts.ts
|
|
2047
|
-
import { Type as
|
|
1973
|
+
import { Type as Type12 } from "typebox";
|
|
2048
1974
|
function projectDiaristSessions(value) {
|
|
2049
1975
|
const raw = value?.sessions;
|
|
2050
1976
|
if (raw === void 0) return [];
|
|
@@ -2077,20 +2003,20 @@ var init_diarist_contracts = __esm({
|
|
|
2077
2003
|
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";
|
|
2078
2004
|
diaristOutputSchema = withTerminatingOutputDeclarations(
|
|
2079
2005
|
openToolObject(
|
|
2080
|
-
|
|
2081
|
-
status:
|
|
2006
|
+
Type12.Object({
|
|
2007
|
+
status: Type12.Unknown({
|
|
2082
2008
|
description: "completed | escalate"
|
|
2083
2009
|
}),
|
|
2084
|
-
ticketNumber:
|
|
2085
|
-
|
|
2010
|
+
ticketNumber: Type12.Optional(
|
|
2011
|
+
Type12.Unknown({
|
|
2086
2012
|
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"
|
|
2087
2013
|
})
|
|
2088
2014
|
),
|
|
2089
|
-
reason:
|
|
2015
|
+
reason: Type12.Unknown({
|
|
2090
2016
|
description: "status \u4E3A escalate \u65F6\uFF1A\u8BA4\u4E0D\u51FA\u672C\u5EAD\u5BF9\u8C61\u7684\u539F\u56E0"
|
|
2091
2017
|
}),
|
|
2092
|
-
sessions:
|
|
2093
|
-
ticketSessions:
|
|
2018
|
+
sessions: Type12.Optional(Type12.Unknown({ description: DIARIST_SESSIONS_DESCRIPTION })),
|
|
2019
|
+
ticketSessions: Type12.Unknown({
|
|
2094
2020
|
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`
|
|
2095
2021
|
})
|
|
2096
2022
|
})
|
|
@@ -2100,7 +2026,7 @@ var init_diarist_contracts = __esm({
|
|
|
2100
2026
|
});
|
|
2101
2027
|
|
|
2102
2028
|
// src/secretariat-contracts.ts
|
|
2103
|
-
import { Type as
|
|
2029
|
+
import { Type as Type13 } from "typebox";
|
|
2104
2030
|
var SECRETARIAT_OUTPUT_TOOL_NAME, secretariatVerdictSchema, SECRETARIAT_GATE_OFFICER_ENTRY_TYPE, SECRETARIAT_COUNTERSIGN_TERMINAL_FACT_KEY;
|
|
2105
2031
|
var init_secretariat_contracts = __esm({
|
|
2106
2032
|
"src/secretariat-contracts.ts"() {
|
|
@@ -2108,17 +2034,17 @@ var init_secretariat_contracts = __esm({
|
|
|
2108
2034
|
init_terminating_infrastructure();
|
|
2109
2035
|
SECRETARIAT_OUTPUT_TOOL_NAME = "ak_secretariat_output";
|
|
2110
2036
|
secretariatVerdictSchema = withTerminatingOutputDeclarations(
|
|
2111
|
-
|
|
2037
|
+
Type13.Object(
|
|
2112
2038
|
{
|
|
2113
|
-
secretariatStatus:
|
|
2039
|
+
secretariatStatus: Type13.Unknown({
|
|
2114
2040
|
description: "converged | escalate"
|
|
2115
2041
|
}),
|
|
2116
|
-
ticketNumber:
|
|
2117
|
-
|
|
2042
|
+
ticketNumber: Type13.Optional(
|
|
2043
|
+
Type13.Unknown({ description: "\u672C\u7968\u53F7\uFF1B\u7F72\u65F6\u6307\u5411\u6700\u7EC8\u6B63\u6587\u6240\u5728\u7968" })
|
|
2118
2044
|
),
|
|
2119
|
-
note:
|
|
2120
|
-
evidence:
|
|
2121
|
-
decisionGate:
|
|
2045
|
+
note: Type13.Unknown({ description: "\u9644\u6CE8" }),
|
|
2046
|
+
evidence: Type13.Optional(Type13.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
|
|
2047
|
+
decisionGate: Type13.Unknown({
|
|
2122
2048
|
description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879\uFF1B\u53EF\u5199 question \u4E0E options\uFF0C\u539F\u6837\u7559\u5B58\u3002"
|
|
2123
2049
|
})
|
|
2124
2050
|
},
|
|
@@ -2426,10 +2352,10 @@ var init_packaged_role_registry = __esm({
|
|
|
2426
2352
|
reportPhase: true
|
|
2427
2353
|
},
|
|
2428
2354
|
boardPlacement: "marshal",
|
|
2355
|
+
/** #1168: dispatch is first message; navigator reads admitted instruction. */
|
|
2356
|
+
navigatorSubject: "public-instruction",
|
|
2429
2357
|
activationFlags: [
|
|
2430
|
-
{ field: "
|
|
2431
|
-
{ field: "phase", flag: "ak-fixer-phase", binds: "phase" },
|
|
2432
|
-
{ field: "prerequisitesPath", flag: "ak-fixer-prerequisites" }
|
|
2358
|
+
{ field: "phase", flag: "ak-fixer-phase", binds: "phase" }
|
|
2433
2359
|
],
|
|
2434
2360
|
activationStage: "load-and-install",
|
|
2435
2361
|
sessionMaterials: [
|
|
@@ -2456,8 +2382,9 @@ var init_packaged_role_registry = __esm({
|
|
|
2456
2382
|
artifactFace: {
|
|
2457
2383
|
reportPhase: true
|
|
2458
2384
|
},
|
|
2385
|
+
/** #1168: dispatch is first message; navigator reads admitted instruction. */
|
|
2386
|
+
navigatorSubject: "public-instruction",
|
|
2459
2387
|
activationFlags: [
|
|
2460
|
-
{ field: "taskPath", flag: "ak-coder-task", binds: "input" },
|
|
2461
2388
|
{ field: "phase", flag: "ak-coder-phase", binds: "phase" }
|
|
2462
2389
|
],
|
|
2463
2390
|
activationStage: "load-and-install",
|
|
@@ -2825,20 +2752,8 @@ var init_cli_errors = __esm({
|
|
|
2825
2752
|
}
|
|
2826
2753
|
});
|
|
2827
2754
|
|
|
2828
|
-
// src/sha256.ts
|
|
2829
|
-
import { createHash } from "node:crypto";
|
|
2830
|
-
function sha256Hex(bytes) {
|
|
2831
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
2832
|
-
}
|
|
2833
|
-
var init_sha256 = __esm({
|
|
2834
|
-
"src/sha256.ts"() {
|
|
2835
|
-
"use strict";
|
|
2836
|
-
}
|
|
2837
|
-
});
|
|
2838
|
-
|
|
2839
2755
|
// src/collector-config.ts
|
|
2840
|
-
|
|
2841
|
-
function fail3(message, cause) {
|
|
2756
|
+
function fail2(message, cause) {
|
|
2842
2757
|
throw new Error(message, cause === void 0 ? void 0 : { cause });
|
|
2843
2758
|
}
|
|
2844
2759
|
function conservativeAscii(input) {
|
|
@@ -2849,63 +2764,26 @@ function conservativeAscii(input) {
|
|
|
2849
2764
|
return true;
|
|
2850
2765
|
}
|
|
2851
2766
|
function parseCollectorRepository(raw) {
|
|
2852
|
-
if (typeof raw !== "string" || raw.trim() !== raw || raw.length === 0)
|
|
2853
|
-
if (!conservativeAscii(raw) || raw.includes("://") || /[?#@%\\ ]/.test(raw))
|
|
2767
|
+
if (typeof raw !== "string" || raw.trim() !== raw || raw.length === 0) fail2("Collector repository must be a string owner/repo");
|
|
2768
|
+
if (!conservativeAscii(raw) || raw.includes("://") || /[?#@%\\ ]/.test(raw)) fail2("Collector repository rejects URL syntax and non-identity bytes");
|
|
2854
2769
|
const parts = raw.split("/");
|
|
2855
|
-
if (parts.length !== 2)
|
|
2770
|
+
if (parts.length !== 2) fail2("Collector repository must contain exactly one '/' separating owner and repo");
|
|
2856
2771
|
const [ownerDisplay, repoDisplay] = parts;
|
|
2857
|
-
if (!COLLECTOR_OWNER_PATTERN.test(ownerDisplay) || !COLLECTOR_REPO_PATTERN.test(repoDisplay))
|
|
2772
|
+
if (!COLLECTOR_OWNER_PATTERN.test(ownerDisplay) || !COLLECTOR_REPO_PATTERN.test(repoDisplay)) fail2("Collector repository does not match the conservative owner/repo grammar");
|
|
2858
2773
|
const owner = ownerDisplay.toLowerCase();
|
|
2859
2774
|
const repo = repoDisplay.toLowerCase();
|
|
2860
2775
|
return { display: raw, canonical: `${owner}/${repo}`, owner, repo };
|
|
2861
2776
|
}
|
|
2862
2777
|
function parseCollectorPrNumber(raw) {
|
|
2863
|
-
if (typeof raw !== "string" && typeof raw !== "number")
|
|
2778
|
+
if (typeof raw !== "string" && typeof raw !== "number") fail2("Collector pull request number is required");
|
|
2864
2779
|
const value = parseTicketNumber(raw);
|
|
2865
|
-
if (value === void 0)
|
|
2780
|
+
if (value === void 0) fail2(typeof raw === "string" && !isTicketNumberString(raw) ? "Collector pull request number must be a positive safe integer string" : "Collector pull request number must be a positive safe integer");
|
|
2866
2781
|
return value;
|
|
2867
2782
|
}
|
|
2868
|
-
function canonicalManifest(requests) {
|
|
2869
|
-
return `${JSON.stringify({ requests: requests.map((request) => ({ id: request.id, body: request.requestBody })) })}
|
|
2870
|
-
`;
|
|
2871
|
-
}
|
|
2872
|
-
function emptyCollectorManifest() {
|
|
2873
|
-
const canonicalJson2 = canonicalManifest([]);
|
|
2874
|
-
return { requests: [], canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2) };
|
|
2875
|
-
}
|
|
2876
|
-
async function loadCollectorManifest(path) {
|
|
2877
|
-
let bytes;
|
|
2878
|
-
try {
|
|
2879
|
-
bytes = await readFile3(path);
|
|
2880
|
-
} catch (error) {
|
|
2881
|
-
fail3(`Collector request manifest is unreadable at ${path}`, error);
|
|
2882
|
-
}
|
|
2883
|
-
let parsed;
|
|
2884
|
-
try {
|
|
2885
|
-
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
2886
|
-
} catch (error) {
|
|
2887
|
-
fail3("Collector request manifest must be UTF-8 JSON", error);
|
|
2888
|
-
}
|
|
2889
|
-
if (!isRecord(parsed)) fail3("Collector request manifest must be an object");
|
|
2890
|
-
const rawRequests = parsed.requests ?? [];
|
|
2891
|
-
if (!Array.isArray(rawRequests)) fail3("Collector request manifest requests must be an array");
|
|
2892
|
-
const requests = [];
|
|
2893
|
-
const ids = /* @__PURE__ */ new Set();
|
|
2894
|
-
for (const [index, item] of rawRequests.entries()) {
|
|
2895
|
-
if (!isRecord(item) || typeof item.id !== "string" || item.id.length === 0 || typeof item.body !== "string" || item.body.trim() === "") fail3(`Collector request manifest requests[${index}] is invalid`);
|
|
2896
|
-
if (ids.has(item.id)) fail3(`Collector request manifest has duplicate request id "${item.id}"`);
|
|
2897
|
-
ids.add(item.id);
|
|
2898
|
-
requests.push({ id: item.id, requestBody: item.body });
|
|
2899
|
-
}
|
|
2900
|
-
const canonicalJson2 = canonicalManifest(requests);
|
|
2901
|
-
return { requests, canonicalJson: canonicalJson2, digest: sha256Hex(canonicalJson2), sourcePath: path };
|
|
2902
|
-
}
|
|
2903
2783
|
var COLLECTOR_OWNER_PATTERN, COLLECTOR_REPO_PATTERN;
|
|
2904
2784
|
var init_collector_config = __esm({
|
|
2905
2785
|
"src/collector-config.ts"() {
|
|
2906
2786
|
"use strict";
|
|
2907
|
-
init_sha256();
|
|
2908
|
-
init_unknown_value();
|
|
2909
2787
|
init_run_ticket_number();
|
|
2910
2788
|
COLLECTOR_OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
2911
2789
|
COLLECTOR_REPO_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/;
|
|
@@ -2920,7 +2798,7 @@ __export(auditor_dossier_tool_exports, {
|
|
|
2920
2798
|
createAuditorDossierTool: () => createAuditorDossierTool
|
|
2921
2799
|
});
|
|
2922
2800
|
import { join as join7, resolve as resolve3 } from "node:path";
|
|
2923
|
-
import { Type as
|
|
2801
|
+
import { Type as Type14 } from "typebox";
|
|
2924
2802
|
function auditorRunDirectory(context) {
|
|
2925
2803
|
const sessionFile = context.sessionManager?.getSessionFile?.();
|
|
2926
2804
|
if (sessionFile === void 0) return void 0;
|
|
@@ -2932,7 +2810,7 @@ function createAuditorDossierTool(runDirectory) {
|
|
|
2932
2810
|
description: "\u5B9A\u4F4D\u672C\u5BA1\u8BA1\u5E2D\u7ED1\u5B9A\u7684 run \u5377\u5B97\u53CA\u5176\u8BC1\u636E\u5165\u53E3\u3002",
|
|
2933
2811
|
// #836 r16 class 3: execute() ignores `_params` entirely — a closed root
|
|
2934
2812
|
// only rejects the role for saying more.
|
|
2935
|
-
parameters:
|
|
2813
|
+
parameters: Type14.Object({}, { additionalProperties: true }),
|
|
2936
2814
|
async execute(_id, _params) {
|
|
2937
2815
|
if (runDirectory === void 0) {
|
|
2938
2816
|
return {
|
|
@@ -3056,7 +2934,7 @@ var init_submission_errors = __esm({
|
|
|
3056
2934
|
});
|
|
3057
2935
|
|
|
3058
2936
|
// src/collector-tool-schemas.ts
|
|
3059
|
-
import { Type as
|
|
2937
|
+
import { Type as Type15 } from "typebox";
|
|
3060
2938
|
var collectorOutputBaseSchema, collectorOutputArgsSchema;
|
|
3061
2939
|
var init_collector_tool_schemas = __esm({
|
|
3062
2940
|
"src/collector-tool-schemas.ts"() {
|
|
@@ -3064,11 +2942,11 @@ var init_collector_tool_schemas = __esm({
|
|
|
3064
2942
|
init_open_tool_schema();
|
|
3065
2943
|
init_terminating_infrastructure();
|
|
3066
2944
|
collectorOutputBaseSchema = openToolObject(
|
|
3067
|
-
|
|
3068
|
-
groups:
|
|
2945
|
+
Type15.Object({
|
|
2946
|
+
groups: Type15.Unsafe({
|
|
3069
2947
|
description: "\u6309\u673A\u5668\u8EAB\u4EFD\u5F52\u7EC4\u7684\u51FA\u5E2D\u3001\u6750\u6599\u4E0E\u9010\u6761 findings\uFF08LLM \u81EA\u884C\u4ECE\u5BBF\u4E3B CLI \u53D6\u8BC1\u6574\u7406\uFF1B\u4EE3\u7801\u4E0D\u4EE3\u6536\u4E0D\u5F52\u5E76\uFF09\u3002"
|
|
3070
2948
|
}),
|
|
3071
|
-
unfinishedReasons:
|
|
2949
|
+
unfinishedReasons: Type15.Unknown({
|
|
3072
2950
|
description: "\u672A\u5B8C\u6210\u539F\u56E0\uFF1B\u53D6\u8BC1\u53D7\u9650\u65F6\u5982\u5B9E\u62A5\u544A\u3002"
|
|
3073
2951
|
})
|
|
3074
2952
|
})
|
|
@@ -3578,13 +3456,13 @@ var init_gatekeeper_role = __esm({
|
|
|
3578
3456
|
});
|
|
3579
3457
|
|
|
3580
3458
|
// src/ledger-session-read.ts
|
|
3581
|
-
import { readFile as
|
|
3459
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
3582
3460
|
async function readStrictPiSessionJsonl(path) {
|
|
3583
|
-
const text = await
|
|
3461
|
+
const text = await readFile3(path, "utf8");
|
|
3584
3462
|
return text.trim().split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
|
|
3585
3463
|
}
|
|
3586
3464
|
async function readLedgerSessionJsonlLines(path) {
|
|
3587
|
-
const text = await
|
|
3465
|
+
const text = await readFile3(path, "utf8");
|
|
3588
3466
|
const lines = text.split("\n");
|
|
3589
3467
|
const out = [];
|
|
3590
3468
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -4997,6 +4875,17 @@ var init_dossier_resolution = __esm({
|
|
|
4997
4875
|
}
|
|
4998
4876
|
});
|
|
4999
4877
|
|
|
4878
|
+
// src/sha256.ts
|
|
4879
|
+
import { createHash } from "node:crypto";
|
|
4880
|
+
function sha256Hex(bytes) {
|
|
4881
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
4882
|
+
}
|
|
4883
|
+
var init_sha256 = __esm({
|
|
4884
|
+
"src/sha256.ts"() {
|
|
4885
|
+
"use strict";
|
|
4886
|
+
}
|
|
4887
|
+
});
|
|
4888
|
+
|
|
5000
4889
|
// src/package-contracts/terminating-tools.ts
|
|
5001
4890
|
function isTerminatingToolName(name) {
|
|
5002
4891
|
return TERMINATING_TOOL_NAMES.includes(name);
|
|
@@ -5058,7 +4947,7 @@ var init_terminating_tools = __esm({
|
|
|
5058
4947
|
});
|
|
5059
4948
|
|
|
5060
4949
|
// src/doctor-evidence.ts
|
|
5061
|
-
import { readdir as readdir2, readFile as
|
|
4950
|
+
import { readdir as readdir2, readFile as readFile4, realpath, stat } from "node:fs/promises";
|
|
5062
4951
|
import { dirname as dirname6, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
|
|
5063
4952
|
async function discoverCaseFiles(root) {
|
|
5064
4953
|
const found = [];
|
|
@@ -5171,7 +5060,7 @@ async function loadDoctorCase(runsPath, projectRoot) {
|
|
|
5171
5060
|
const turns = { count: 0, sources: [] }, calls = { count: 0, sources: [] }, tokens = { count: 0, sources: [] };
|
|
5172
5061
|
for (const path of await discoverCaseFiles(root)) {
|
|
5173
5062
|
const id = relative2(root, path).split(sep2).join("/");
|
|
5174
|
-
const bytes = await
|
|
5063
|
+
const bytes = await readFile4(path);
|
|
5175
5064
|
const content = bytes.toString("utf8");
|
|
5176
5065
|
const kind = id.split("/").length === 2 && id.endsWith("/log.jsonl") ? "log" : "session";
|
|
5177
5066
|
evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
|
|
@@ -5249,7 +5138,7 @@ var init_git_object_id = __esm({
|
|
|
5249
5138
|
|
|
5250
5139
|
// src/merger-git-state.ts
|
|
5251
5140
|
import { execFile } from "node:child_process";
|
|
5252
|
-
import { access, readFile as
|
|
5141
|
+
import { access, readFile as readFile5 } from "node:fs/promises";
|
|
5253
5142
|
import { constants as fsConstants } from "node:fs";
|
|
5254
5143
|
import { isAbsolute as isAbsolute3, resolve as resolve6 } from "node:path";
|
|
5255
5144
|
import { promisify } from "node:util";
|
|
@@ -5319,7 +5208,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
|
|
|
5319
5208
|
const mergeHeadPath = isAbsolute3(mergeHeadReported) ? mergeHeadReported : resolve6(repositoryRoot, mergeHeadReported);
|
|
5320
5209
|
let sourceObjectId = "";
|
|
5321
5210
|
if (await pathExists(mergeHeadPath)) {
|
|
5322
|
-
const raw = exactUtf8(await
|
|
5211
|
+
const raw = exactUtf8(await readFile5(mergeHeadPath), "Git MERGE_HEAD");
|
|
5323
5212
|
const mergeHeads = raw.trim().split(/\r?\n/).map((row) => row.trim()).filter(Boolean);
|
|
5324
5213
|
if (mergeHeads.length === 0) throw new Error("Git MERGE_HEAD is empty");
|
|
5325
5214
|
if (mergeHeads.length !== 1) throw new Error("Assigned repository does not have one ordinary in-progress merge");
|
|
@@ -5465,7 +5354,7 @@ var init_session_dialogue = __esm({
|
|
|
5465
5354
|
});
|
|
5466
5355
|
|
|
5467
5356
|
// src/ticket-provenance.ts
|
|
5468
|
-
import { readFile as
|
|
5357
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
5469
5358
|
import { join as join9, resolve as resolve7 } from "node:path";
|
|
5470
5359
|
function dialogueSessionSourceRoots(home) {
|
|
5471
5360
|
const machineHome = typeof home === "string" && home.trim() !== "" ? home : packageMachineHome();
|
|
@@ -5513,7 +5402,7 @@ async function rehomeUnboundTicketProvenance(runDirectory, ticketNumber, cwd, ho
|
|
|
5513
5402
|
const ticketInput = ticketProvenanceRecordInput(ticketNumber, cwd, home);
|
|
5514
5403
|
let history;
|
|
5515
5404
|
try {
|
|
5516
|
-
history = await
|
|
5405
|
+
history = await readFile6(join9(runDirectory, RUN_HISTORY_FILE), "utf8");
|
|
5517
5406
|
} catch (error) {
|
|
5518
5407
|
if (errnoCode(error) === "ENOENT") return;
|
|
5519
5408
|
throw error;
|
|
@@ -6356,8 +6245,8 @@ var init_option_definitions = __esm({
|
|
|
6356
6245
|
repeatable: true,
|
|
6357
6246
|
form: "option",
|
|
6358
6247
|
description: {
|
|
6359
|
-
en: "
|
|
6360
|
-
zh: "\
|
|
6248
|
+
en: "Caller file path passed as-is to the role (repeatable). Package does not read, copy, or validate; use an absolute path when cwd differs from --project.",
|
|
6249
|
+
zh: "\u8C03\u7528\u65B9\u6587\u4EF6\u8DEF\u5F84\u539F\u6837\u9012\u7ED9\u8859\u95E8\uFF08\u53EF\u91CD\u590D\uFF09\u3002\u5305\u4E0D\u8BFB\u3001\u4E0D\u590D\u5236\u3001\u4E0D\u6821\u9A8C\uFF1B\u8C03\u7528\u65B9\u5F53\u524D\u76EE\u5F55\u4E0E --project \u4E0D\u540C\u65F6\u8BF7\u7ED9\u7EDD\u5BF9\u8DEF\u5F84\u3002"
|
|
6361
6250
|
}
|
|
6362
6251
|
};
|
|
6363
6252
|
SHARED_PHASE_SEMANTICS = {
|
|
@@ -6441,8 +6330,8 @@ var init_option_definitions = __esm({
|
|
|
6441
6330
|
repeatable: false,
|
|
6442
6331
|
form: "option",
|
|
6443
6332
|
description: {
|
|
6444
|
-
en: "
|
|
6445
|
-
zh: "
|
|
6333
|
+
en: "Caller prerequisites path passed as-is to the role. Package does not read, copy, or validate; use an absolute path when cwd differs from --project.",
|
|
6334
|
+
zh: "\u8C03\u7528\u65B9\u524D\u7F6E\u6761\u4EF6\u6587\u4EF6\u8DEF\u5F84\u539F\u6837\u9012\u7ED9\u8859\u95E8\u3002\u5305\u4E0D\u8BFB\u3001\u4E0D\u590D\u5236\u3001\u4E0D\u6821\u9A8C\uFF1B\u8C03\u7528\u65B9\u5F53\u524D\u76EE\u5F55\u4E0E --project \u4E0D\u540C\u65F6\u8BF7\u7ED9\u7EDD\u5BF9\u8DEF\u5F84\u3002"
|
|
6446
6335
|
}
|
|
6447
6336
|
}
|
|
6448
6337
|
];
|
|
@@ -6532,8 +6421,8 @@ var init_option_definitions = __esm({
|
|
|
6532
6421
|
repeatable: false,
|
|
6533
6422
|
form: "option",
|
|
6534
6423
|
description: {
|
|
6535
|
-
en: "
|
|
6536
|
-
zh: "\
|
|
6424
|
+
en: "Caller path to a request manifest JSON file, passed as-is. Package does not read, copy, or validate; use an absolute path when cwd differs from --project.",
|
|
6425
|
+
zh: "\u8C03\u7528\u65B9 request manifest JSON \u8DEF\u5F84\uFF0C\u539F\u6837\u4F20\u9012\u3002\u5305\u4E0D\u8BFB\u3001\u4E0D\u590D\u5236\u3001\u4E0D\u6821\u9A8C\uFF1B\u8C03\u7528\u65B9\u5F53\u524D\u76EE\u5F55\u4E0E --project \u4E0D\u540C\u65F6\u8BF7\u7ED9\u7EDD\u5BF9\u8DEF\u5F84\u3002"
|
|
6537
6426
|
}
|
|
6538
6427
|
}
|
|
6539
6428
|
];
|
|
@@ -6992,16 +6881,22 @@ var init_option_definitions = __esm({
|
|
|
6992
6881
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6993
6882
|
import { existsSync as existsSync3 } from "node:fs";
|
|
6994
6883
|
import {
|
|
6995
|
-
|
|
6996
|
-
mkdtemp,
|
|
6997
|
-
readFile as readFile8,
|
|
6884
|
+
readFile as readFile7,
|
|
6998
6885
|
realpath as realpath3,
|
|
6999
6886
|
rename,
|
|
7000
|
-
rm,
|
|
7001
6887
|
writeFile
|
|
7002
6888
|
} from "node:fs/promises";
|
|
7003
|
-
import {
|
|
7004
|
-
|
|
6889
|
+
import { dirname as dirname8, isAbsolute as isAbsolute5, join as join11, resolve as resolve9 } from "node:path";
|
|
6890
|
+
function normalizeAdmittedAttachment(raw) {
|
|
6891
|
+
if (typeof raw !== "object" || raw === null) return void 0;
|
|
6892
|
+
const record = raw;
|
|
6893
|
+
const path = record.path;
|
|
6894
|
+
if (typeof path === "string") return { path };
|
|
6895
|
+
return void 0;
|
|
6896
|
+
}
|
|
6897
|
+
function admitCallerAttachments(attachmentPaths) {
|
|
6898
|
+
return attachmentPaths.map((path) => ({ path }));
|
|
6899
|
+
}
|
|
7005
6900
|
function issueAdmissionPlacement(authority, request) {
|
|
7006
6901
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
7007
6902
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -7177,22 +7072,11 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
7177
7072
|
admittedRecord,
|
|
7178
7073
|
[
|
|
7179
7074
|
"runDirectory",
|
|
7180
|
-
"taskPath",
|
|
7181
|
-
"packetPath",
|
|
7182
|
-
"prerequisitesPath",
|
|
7183
|
-
"requestManifestPath",
|
|
7184
7075
|
"mergerInputPath"
|
|
7185
7076
|
],
|
|
7186
7077
|
oldRunDirectory,
|
|
7187
7078
|
target.runDirectory
|
|
7188
7079
|
);
|
|
7189
|
-
for (const attachment of admitted.attachments) {
|
|
7190
|
-
attachment.frozenPath = rewriteRunDirectoryPathValue(
|
|
7191
|
-
attachment.frozenPath,
|
|
7192
|
-
oldRunDirectory,
|
|
7193
|
-
target.runDirectory
|
|
7194
|
-
);
|
|
7195
|
-
}
|
|
7196
7080
|
admitted.principal = principal;
|
|
7197
7081
|
renderCurrentSync(target.runDirectory);
|
|
7198
7082
|
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
@@ -7229,7 +7113,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
7229
7113
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
7230
7114
|
const rolePackageRoot = packageRoot;
|
|
7231
7115
|
const raw = JSON.parse(
|
|
7232
|
-
await
|
|
7116
|
+
await readFile7(join11(rolePackageRoot, "package.json"), "utf8")
|
|
7233
7117
|
);
|
|
7234
7118
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
7235
7119
|
throw new Error(
|
|
@@ -7285,7 +7169,7 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
7285
7169
|
const value = taken.value;
|
|
7286
7170
|
switch (taken.def.id) {
|
|
7287
7171
|
case "attach":
|
|
7288
|
-
fields.attachmentPaths.push(
|
|
7172
|
+
fields.attachmentPaths.push(requireProvidedOptionValue(taken.def.canonical, value));
|
|
7289
7173
|
return;
|
|
7290
7174
|
case "project":
|
|
7291
7175
|
fields.project = requireOptionPath(taken.def.canonical, value);
|
|
@@ -7320,7 +7204,7 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
7320
7204
|
fields.authorityRefs.push(requireAuthorityRef(value));
|
|
7321
7205
|
return;
|
|
7322
7206
|
case "prerequisites":
|
|
7323
|
-
fields.prerequisitesPath =
|
|
7207
|
+
fields.prerequisitesPath = requireProvidedOptionValue(taken.def.canonical, value);
|
|
7324
7208
|
return;
|
|
7325
7209
|
case "pr":
|
|
7326
7210
|
fields.prNumber = parsePositivePrOption(value);
|
|
@@ -7329,7 +7213,7 @@ function assignPublicSeatOption(owner, taken, fields) {
|
|
|
7329
7213
|
fields.repo = parseRepoOption(value);
|
|
7330
7214
|
return;
|
|
7331
7215
|
case "request-manifest":
|
|
7332
|
-
fields.requestManifestPath =
|
|
7216
|
+
fields.requestManifestPath = requireProvidedOptionValue(taken.def.canonical, value);
|
|
7333
7217
|
return;
|
|
7334
7218
|
case "issue": {
|
|
7335
7219
|
if (value === void 0 || value.trim() === "") {
|
|
@@ -7444,6 +7328,12 @@ function requireOptionPath(flag, value) {
|
|
|
7444
7328
|
}
|
|
7445
7329
|
return value;
|
|
7446
7330
|
}
|
|
7331
|
+
function requireProvidedOptionValue(flag, value) {
|
|
7332
|
+
if (value === void 0) {
|
|
7333
|
+
throw new CliUsageError(`${flag} requires a path`);
|
|
7334
|
+
}
|
|
7335
|
+
return value;
|
|
7336
|
+
}
|
|
7447
7337
|
function skillArgTokenFault(value) {
|
|
7448
7338
|
if (value === void 0 || value.trim() === "") return "empty";
|
|
7449
7339
|
if (/\s/.test(value)) return "whitespace";
|
|
@@ -7496,124 +7386,6 @@ function requireAuthorityRef(value) {
|
|
|
7496
7386
|
optionLike: "--authority-ref requires a durable reference, not inline Spec prose"
|
|
7497
7387
|
});
|
|
7498
7388
|
}
|
|
7499
|
-
async function readRegularFileAttachment(sourcePath) {
|
|
7500
|
-
const absolute = isAbsolute5(sourcePath) ? sourcePath : resolve9(sourcePath);
|
|
7501
|
-
let st;
|
|
7502
|
-
try {
|
|
7503
|
-
st = await lstat2(absolute);
|
|
7504
|
-
} catch (error) {
|
|
7505
|
-
throw new CliUsageError(
|
|
7506
|
-
`attachment is not a readable regular file: ${sourcePath}`,
|
|
7507
|
-
{ cause: error }
|
|
7508
|
-
);
|
|
7509
|
-
}
|
|
7510
|
-
if (!st.isFile() || st.isSymbolicLink()) {
|
|
7511
|
-
throw new CliUsageError(
|
|
7512
|
-
`attachment must be a regular file (not a directory or symlink): ${sourcePath}`
|
|
7513
|
-
);
|
|
7514
|
-
}
|
|
7515
|
-
try {
|
|
7516
|
-
return { absolute, bytes: await readFile8(absolute) };
|
|
7517
|
-
} catch (error) {
|
|
7518
|
-
throw new CliUsageError(
|
|
7519
|
-
`attachment is not a readable regular file: ${sourcePath}`,
|
|
7520
|
-
{ cause: error }
|
|
7521
|
-
);
|
|
7522
|
-
}
|
|
7523
|
-
}
|
|
7524
|
-
async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
7525
|
-
await rm(stagingDirectory, { recursive: true, force: true });
|
|
7526
|
-
}
|
|
7527
|
-
async function withPreparedAttachments(attachmentPaths, use) {
|
|
7528
|
-
if (attachmentPaths.length === 0) return await use([]);
|
|
7529
|
-
const stagingDirectory = await mkdtemp(join11(tmpdir(), "ak-role-attachments-"));
|
|
7530
|
-
const prepared = [];
|
|
7531
|
-
let result;
|
|
7532
|
-
try {
|
|
7533
|
-
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
7534
|
-
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
7535
|
-
const snapshotPath = join11(stagingDirectory, String(index).padStart(6, "0"));
|
|
7536
|
-
await writeFile(snapshotPath, bytes);
|
|
7537
|
-
prepared.push({ absolute, snapshotPath });
|
|
7538
|
-
}
|
|
7539
|
-
result = await use(prepared);
|
|
7540
|
-
} catch (primary) {
|
|
7541
|
-
try {
|
|
7542
|
-
await removePreparedAttachmentDirectory(stagingDirectory);
|
|
7543
|
-
} catch (cleanup) {
|
|
7544
|
-
throw new AggregateError(
|
|
7545
|
-
[primary, cleanup],
|
|
7546
|
-
"attachment snapshot operation failed and cleanup also failed",
|
|
7547
|
-
{ cause: primary }
|
|
7548
|
-
);
|
|
7549
|
-
}
|
|
7550
|
-
throw primary;
|
|
7551
|
-
}
|
|
7552
|
-
await removePreparedAttachmentDirectory(stagingDirectory);
|
|
7553
|
-
return result;
|
|
7554
|
-
}
|
|
7555
|
-
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
7556
|
-
const frozenPath = join11(
|
|
7557
|
-
destinationDir,
|
|
7558
|
-
`${String(index).padStart(2, "0")}-${basename8(provenancePath)}`
|
|
7559
|
-
);
|
|
7560
|
-
await writeFile(frozenPath, bytes);
|
|
7561
|
-
return {
|
|
7562
|
-
provenancePath,
|
|
7563
|
-
frozenPath,
|
|
7564
|
-
byteLength: bytes.byteLength,
|
|
7565
|
-
sha256: sha256Hex(bytes),
|
|
7566
|
-
mediaKind: "regular-file"
|
|
7567
|
-
};
|
|
7568
|
-
}
|
|
7569
|
-
async function freezePreparedAttachment(prepared, destinationDir, index) {
|
|
7570
|
-
return freezeAttachmentBytes(
|
|
7571
|
-
prepared.absolute,
|
|
7572
|
-
await readFile8(prepared.snapshotPath),
|
|
7573
|
-
destinationDir,
|
|
7574
|
-
index
|
|
7575
|
-
);
|
|
7576
|
-
}
|
|
7577
|
-
async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
7578
|
-
const { absolute, bytes } = await readRegularFileAttachment(sourcePath);
|
|
7579
|
-
return {
|
|
7580
|
-
attachment: await freezeAttachmentBytes(absolute, bytes, destinationDir, index),
|
|
7581
|
-
body: bytes
|
|
7582
|
-
};
|
|
7583
|
-
}
|
|
7584
|
-
async function freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory) {
|
|
7585
|
-
const attachments = [];
|
|
7586
|
-
if (attachmentPaths.length > 0) {
|
|
7587
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7588
|
-
}
|
|
7589
|
-
for (let i = 0; i < attachmentPaths.length; i += 1) {
|
|
7590
|
-
const frozen = await freezeRegularFileAttachment(
|
|
7591
|
-
attachmentPaths[i],
|
|
7592
|
-
attachmentsDirectory,
|
|
7593
|
-
i
|
|
7594
|
-
);
|
|
7595
|
-
attachments.push(frozen.attachment);
|
|
7596
|
-
}
|
|
7597
|
-
return attachments;
|
|
7598
|
-
}
|
|
7599
|
-
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
7600
|
-
if (attachmentPaths.length === 0) return [];
|
|
7601
|
-
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7602
|
-
const attachmentsDirectory = join11(runDirectory, "attachments", summonsKey);
|
|
7603
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7604
|
-
return freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory);
|
|
7605
|
-
}
|
|
7606
|
-
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
7607
|
-
if (prepared.length === 0) return [];
|
|
7608
|
-
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7609
|
-
const attachmentsDirectory = summonsKey === void 0 ? join11(runDirectory, "attachments") : join11(runDirectory, "attachments", summonsKey);
|
|
7610
|
-
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7611
|
-
const attachments = [];
|
|
7612
|
-
for (let index = 0; index < prepared.length; index += 1) {
|
|
7613
|
-
attachments.push(await freezePreparedAttachment(prepared[index], attachmentsDirectory, index));
|
|
7614
|
-
}
|
|
7615
|
-
return attachments;
|
|
7616
|
-
}
|
|
7617
7389
|
function ticketAdmissionFields(ticketNumber) {
|
|
7618
7390
|
if (ticketNumber === void 0) return {};
|
|
7619
7391
|
return {
|
|
@@ -7682,11 +7454,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7682
7454
|
instruction,
|
|
7683
7455
|
attachmentPaths,
|
|
7684
7456
|
...project,
|
|
7685
|
-
placedFields: async (
|
|
7686
|
-
const taskPath = join11(placed.runDirectory, "task.md");
|
|
7687
|
-
await writeFile(taskPath, instruction, "utf8");
|
|
7688
|
-
return { phase, taskPath };
|
|
7689
|
-
}
|
|
7457
|
+
placedFields: async () => ({ phase })
|
|
7690
7458
|
});
|
|
7691
7459
|
}
|
|
7692
7460
|
case "worker-packet": {
|
|
@@ -7697,52 +7465,15 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7697
7465
|
if (!record.phases.some((item) => item === phase)) {
|
|
7698
7466
|
throw new CliUsageError("fixer phase must be plan or apply");
|
|
7699
7467
|
}
|
|
7700
|
-
let prerequisites = Object.freeze([]);
|
|
7701
|
-
let prerequisitesSource;
|
|
7702
|
-
if (parsed.prerequisitesPath !== void 0) {
|
|
7703
|
-
const absolutePrereq = isAbsolute5(parsed.prerequisitesPath) ? parsed.prerequisitesPath : resolve9(parsed.prerequisitesPath);
|
|
7704
|
-
try {
|
|
7705
|
-
prerequisitesSource = await readFile8(absolutePrereq, "utf8");
|
|
7706
|
-
} catch (error) {
|
|
7707
|
-
throw new CliUsageError(
|
|
7708
|
-
`fixer prerequisites path is unreadable: ${parsed.prerequisitesPath}`,
|
|
7709
|
-
{ cause: error }
|
|
7710
|
-
);
|
|
7711
|
-
}
|
|
7712
|
-
try {
|
|
7713
|
-
prerequisites = parseFixerPrerequisites(prerequisitesSource);
|
|
7714
|
-
} catch (error) {
|
|
7715
|
-
if (error instanceof FixerPacketValidationError) {
|
|
7716
|
-
throw new CliUsageError(error.message, { cause: error });
|
|
7717
|
-
}
|
|
7718
|
-
throw error;
|
|
7719
|
-
}
|
|
7720
|
-
}
|
|
7721
7468
|
return admitStandardMaterialInvocation("fixer", {
|
|
7722
7469
|
...shared,
|
|
7723
7470
|
instruction,
|
|
7724
7471
|
attachmentPaths,
|
|
7725
7472
|
...project,
|
|
7726
|
-
placedFields: async (
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
await writeFile(
|
|
7731
|
-
prerequisitesPath,
|
|
7732
|
-
`${JSON.stringify(prerequisites, null, 2)}
|
|
7733
|
-
`,
|
|
7734
|
-
"utf8"
|
|
7735
|
-
);
|
|
7736
|
-
}
|
|
7737
|
-
const packetPath = join11(placed.runDirectory, "fix-packet.md");
|
|
7738
|
-
await writeFile(packetPath, instruction, "utf8");
|
|
7739
|
-
return {
|
|
7740
|
-
phase,
|
|
7741
|
-
packetPath,
|
|
7742
|
-
prerequisites,
|
|
7743
|
-
...prerequisitesPath === void 0 ? {} : { prerequisitesPath }
|
|
7744
|
-
};
|
|
7745
|
-
}
|
|
7473
|
+
placedFields: async () => ({
|
|
7474
|
+
phase,
|
|
7475
|
+
...parsed.prerequisitesPath === void 0 ? {} : { prerequisitesPath: parsed.prerequisitesPath }
|
|
7476
|
+
})
|
|
7746
7477
|
});
|
|
7747
7478
|
}
|
|
7748
7479
|
case "collect-target": {
|
|
@@ -7759,37 +7490,17 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7759
7490
|
} else {
|
|
7760
7491
|
repository = resolveGitHubRemoteRepository(projectRoot);
|
|
7761
7492
|
}
|
|
7762
|
-
let manifest = emptyCollectorManifest();
|
|
7763
|
-
let manifestCanonicalJson;
|
|
7764
|
-
if (parsed.requestManifestPath !== void 0) {
|
|
7765
|
-
try {
|
|
7766
|
-
manifest = await loadCollectorManifest(parsed.requestManifestPath);
|
|
7767
|
-
manifestCanonicalJson = manifest.canonicalJson;
|
|
7768
|
-
} catch (error) {
|
|
7769
|
-
throw new CliUsageError(
|
|
7770
|
-
errorText(error),
|
|
7771
|
-
{ cause: error }
|
|
7772
|
-
);
|
|
7773
|
-
}
|
|
7774
|
-
}
|
|
7775
|
-
const manifestDigest = manifest.digest;
|
|
7776
7493
|
const admittedCollector = await admitStandardMaterialInvocation("collector", {
|
|
7777
7494
|
...shared,
|
|
7778
7495
|
instruction,
|
|
7779
7496
|
attachmentPaths,
|
|
7780
7497
|
...project,
|
|
7781
|
-
placedFields: async (
|
|
7782
|
-
let requestManifestPath;
|
|
7783
|
-
if (manifestCanonicalJson !== void 0) {
|
|
7784
|
-
requestManifestPath = join11(placed.runDirectory, "request-manifest.json");
|
|
7785
|
-
await writeFile(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
7786
|
-
}
|
|
7498
|
+
placedFields: async () => {
|
|
7787
7499
|
return {
|
|
7788
7500
|
...explicitPrNumber === void 0 ? {} : { prNumber: explicitPrNumber },
|
|
7789
7501
|
repository: repository.canonical,
|
|
7790
7502
|
repositoryDisplay: repository.display,
|
|
7791
|
-
...requestManifestPath === void 0 ? {} : { requestManifestPath }
|
|
7792
|
-
manifestDigest
|
|
7503
|
+
...parsed.requestManifestPath === void 0 ? {} : { requestManifestPath: parsed.requestManifestPath }
|
|
7793
7504
|
};
|
|
7794
7505
|
}
|
|
7795
7506
|
});
|
|
@@ -7802,12 +7513,10 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7802
7513
|
);
|
|
7803
7514
|
}
|
|
7804
7515
|
const issueNumber = parsed.issueNumber;
|
|
7805
|
-
|
|
7806
|
-
const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
|
|
7516
|
+
return admitStandardMaterialInvocation("doctor", {
|
|
7807
7517
|
...shared,
|
|
7808
7518
|
instruction,
|
|
7809
|
-
attachmentPaths
|
|
7810
|
-
freezeAttachments: false,
|
|
7519
|
+
attachmentPaths,
|
|
7811
7520
|
...project,
|
|
7812
7521
|
placedFields: async (placed) => {
|
|
7813
7522
|
let caseRunsPath;
|
|
@@ -7848,16 +7557,13 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7848
7557
|
{ cause: error }
|
|
7849
7558
|
);
|
|
7850
7559
|
}
|
|
7851
|
-
frozenAttachments = await freezeAttachments(placed.ledgerHome, attachmentPaths, placed.attachmentsDirectory);
|
|
7852
7560
|
return {
|
|
7853
7561
|
issueNumber,
|
|
7854
7562
|
caseRunsPath,
|
|
7855
|
-
caseIdentity
|
|
7856
|
-
attachments: persistedAttachmentRefs(frozenAttachments)
|
|
7563
|
+
caseIdentity
|
|
7857
7564
|
};
|
|
7858
7565
|
}
|
|
7859
7566
|
});
|
|
7860
|
-
return { ...admittedDoctor, attachments: frozenAttachments };
|
|
7861
7567
|
}
|
|
7862
7568
|
case "source-locator": {
|
|
7863
7569
|
const projectRoot = resolve9(parsed.project ?? shared.cwd);
|
|
@@ -7884,7 +7590,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7884
7590
|
instruction: "",
|
|
7885
7591
|
attachmentPaths: [],
|
|
7886
7592
|
...project,
|
|
7887
|
-
|
|
7593
|
+
recordAttachments: false,
|
|
7888
7594
|
admittedFields: {
|
|
7889
7595
|
sourceRunPath: sourceRun.runDirectory,
|
|
7890
7596
|
sourceRun
|
|
@@ -7901,7 +7607,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7901
7607
|
instruction,
|
|
7902
7608
|
attachmentPaths: [],
|
|
7903
7609
|
...project,
|
|
7904
|
-
|
|
7610
|
+
recordAttachments: false,
|
|
7905
7611
|
admittedFields: { baseRevision }
|
|
7906
7612
|
});
|
|
7907
7613
|
}
|
|
@@ -7954,8 +7660,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7954
7660
|
targetObjectId: derived.targetObjectId,
|
|
7955
7661
|
sourceObjectId: derived.sourceObjectId,
|
|
7956
7662
|
materials: {
|
|
7957
|
-
task: mergerMaterialFromUtf8(instruction),
|
|
7958
|
-
authority: mergerMaterialFromUtf8(instruction),
|
|
7959
7663
|
targetIntent: mergerMaterialFromUtf8(
|
|
7960
7664
|
`Investigate primary sources for target parent ${targetLabel}. Do not invent intent.`
|
|
7961
7665
|
),
|
|
@@ -8013,7 +7717,7 @@ async function placeRoleAdmission(options) {
|
|
|
8013
7717
|
home: options.home,
|
|
8014
7718
|
...options.materialize === void 0 ? {} : { materialize: options.materialize }
|
|
8015
7719
|
});
|
|
8016
|
-
const attachments = options.
|
|
7720
|
+
const attachments = options.recordAttachments === false ? [] : admitCallerAttachments(options.attachmentPaths);
|
|
8017
7721
|
return {
|
|
8018
7722
|
runId,
|
|
8019
7723
|
bookKey,
|
|
@@ -8029,13 +7733,7 @@ async function placeRoleAdmission(options) {
|
|
|
8029
7733
|
};
|
|
8030
7734
|
}
|
|
8031
7735
|
function persistedAttachmentRefs(attachments) {
|
|
8032
|
-
return attachments.map((attachment) => ({
|
|
8033
|
-
provenancePath: attachment.provenancePath,
|
|
8034
|
-
frozenPath: attachment.frozenPath,
|
|
8035
|
-
byteLength: attachment.byteLength,
|
|
8036
|
-
sha256: attachment.sha256,
|
|
8037
|
-
mediaKind: attachment.mediaKind
|
|
8038
|
-
}));
|
|
7736
|
+
return attachments.map((attachment) => ({ path: attachment.path }));
|
|
8039
7737
|
}
|
|
8040
7738
|
async function persistPlacedAdmission(admitted, placed, model) {
|
|
8041
7739
|
writeAdmittedRequestPersistence(placed.runDirectory, admitted, {
|
|
@@ -8054,14 +7752,14 @@ async function persistPlacedAdmission(admitted, placed, model) {
|
|
|
8054
7752
|
}
|
|
8055
7753
|
async function admitStandardMaterialInvocation(role, options) {
|
|
8056
7754
|
const defer = options.deferPersistence === true;
|
|
8057
|
-
const
|
|
7755
|
+
const skipAttachments = defer || options.recordAttachments === false;
|
|
8058
7756
|
const placed = await placeRoleAdmission({
|
|
8059
7757
|
role,
|
|
8060
7758
|
home: options.home,
|
|
8061
7759
|
principalAuthority: options.principalAuthority,
|
|
8062
7760
|
cwd: options.cwd,
|
|
8063
7761
|
attachmentPaths: options.attachmentPaths,
|
|
8064
|
-
...
|
|
7762
|
+
...skipAttachments ? { recordAttachments: false } : {},
|
|
8065
7763
|
...defer ? { materialize: false } : {},
|
|
8066
7764
|
...options.project === void 0 ? {} : { project: options.project },
|
|
8067
7765
|
...options.createRunId === void 0 ? {} : { createRunId: options.createRunId },
|
|
@@ -8069,7 +7767,7 @@ async function admitStandardMaterialInvocation(role, options) {
|
|
|
8069
7767
|
});
|
|
8070
7768
|
const correlationFields = options.correlationId === void 0 ? {} : { correlationId: options.correlationId };
|
|
8071
7769
|
const instruction = options.instruction;
|
|
8072
|
-
const instructionEmpty = instruction.
|
|
7770
|
+
const instructionEmpty = instruction.length === 0;
|
|
8073
7771
|
const placedExtra = options.placedFields === void 0 ? void 0 : await options.placedFields(placed);
|
|
8074
7772
|
const admittedFields = {
|
|
8075
7773
|
...options.admittedFields ?? {},
|
|
@@ -8124,7 +7822,7 @@ function buildInstructionTransportPrompt(admitted) {
|
|
|
8124
7822
|
throw new Error("baseline transport prompt is missing the bound revision");
|
|
8125
7823
|
}
|
|
8126
7824
|
const lines2 = [admitted.baseRevision];
|
|
8127
|
-
if (
|
|
7825
|
+
if (admitted.instruction.length > 0) {
|
|
8128
7826
|
lines2.push("", admitted.instruction);
|
|
8129
7827
|
}
|
|
8130
7828
|
return lines2.join("\n");
|
|
@@ -8138,17 +7836,22 @@ function buildInstructionTransportPrompt(admitted) {
|
|
|
8138
7836
|
lens: admitted.lens,
|
|
8139
7837
|
authorityRefs: admitted.authorityRefs
|
|
8140
7838
|
})];
|
|
8141
|
-
if (
|
|
7839
|
+
if (admitted.instruction.length > 0) {
|
|
8142
7840
|
lines2.push("", admitted.instruction);
|
|
8143
7841
|
}
|
|
8144
7842
|
return lines2.join("\n");
|
|
8145
7843
|
}
|
|
8146
|
-
const lines = [admitted.
|
|
8147
|
-
|
|
7844
|
+
const lines = [admitted.instruction];
|
|
7845
|
+
const flaggedPaths = [
|
|
7846
|
+
...admitted.attachments.map((attachment) => `--attach ${attachment.path}`),
|
|
7847
|
+
...admitted.requestManifestPath === void 0 ? [] : [`--request-manifest ${admitted.requestManifestPath}`],
|
|
7848
|
+
...admitted.prerequisitesPath === void 0 ? [] : [`--prerequisites ${admitted.prerequisitesPath}`]
|
|
7849
|
+
];
|
|
7850
|
+
if (flaggedPaths.length > 0) {
|
|
8148
7851
|
lines.push("");
|
|
8149
|
-
lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\
|
|
8150
|
-
for (const
|
|
8151
|
-
lines.push(`- ${
|
|
7852
|
+
lines.push("\u5DF2\u53D7\u7406\u9644\u4EF6\uFF1A");
|
|
7853
|
+
for (const entry of flaggedPaths) {
|
|
7854
|
+
lines.push(`- ${entry}`);
|
|
8152
7855
|
}
|
|
8153
7856
|
}
|
|
8154
7857
|
return lines.join("\n");
|
|
@@ -8159,8 +7862,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
8159
7862
|
home: options.home,
|
|
8160
7863
|
principalAuthority: options.principalAuthority,
|
|
8161
7864
|
cwd: admitted.projectRoot,
|
|
8162
|
-
attachmentPaths:
|
|
8163
|
-
freezeAttachments: false,
|
|
7865
|
+
attachmentPaths: options.attachmentPaths,
|
|
8164
7866
|
runId: admitted.runId,
|
|
8165
7867
|
...options.ticketNumber === void 0 ? {} : { assertedTicketNumber: options.ticketNumber }
|
|
8166
7868
|
});
|
|
@@ -8171,11 +7873,7 @@ async function materializeCountersignInvocation(admitted, options) {
|
|
|
8171
7873
|
if (ticketFields.ticketNumber !== void 0) {
|
|
8172
7874
|
admitted.ticketNumber = ticketFields.ticketNumber;
|
|
8173
7875
|
}
|
|
8174
|
-
|
|
8175
|
-
options.preparedAttachments,
|
|
8176
|
-
admitted.runDirectory
|
|
8177
|
-
);
|
|
8178
|
-
admitted.attachments = attachments;
|
|
7876
|
+
admitted.attachments = placement.attachments;
|
|
8179
7877
|
writeAdmittedRequestPersistence(admitted.runDirectory, admitted, {
|
|
8180
7878
|
sessionDirectory: placement.sessionDirectory,
|
|
8181
7879
|
sessionFile: placement.sessionFile
|
|
@@ -8194,10 +7892,11 @@ async function loadAdmittedJudgeRequest(runDirectory) {
|
|
|
8194
7892
|
if (typeof record.instruction !== "string") return void 0;
|
|
8195
7893
|
if (typeof record.instructionEmpty !== "boolean") return void 0;
|
|
8196
7894
|
if (!Array.isArray(record.attachments)) return void 0;
|
|
7895
|
+
const attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
|
|
8197
7896
|
return {
|
|
8198
7897
|
instruction: record.instruction,
|
|
8199
7898
|
instructionEmpty: record.instructionEmpty,
|
|
8200
|
-
attachments
|
|
7899
|
+
attachments
|
|
8201
7900
|
};
|
|
8202
7901
|
} catch {
|
|
8203
7902
|
return void 0;
|
|
@@ -8432,7 +8131,7 @@ function parseAnalystArgv(args) {
|
|
|
8432
8131
|
if (taken.def.id === "attach") {
|
|
8433
8132
|
pushValue(
|
|
8434
8133
|
"attach",
|
|
8435
|
-
|
|
8134
|
+
requireProvidedOptionValue(taken.def.canonical, taken.value)
|
|
8436
8135
|
);
|
|
8437
8136
|
return;
|
|
8438
8137
|
}
|
|
@@ -8546,7 +8245,6 @@ var init_invocation = __esm({
|
|
|
8546
8245
|
init_doctor_evidence();
|
|
8547
8246
|
init_collector_config();
|
|
8548
8247
|
init_github_remote();
|
|
8549
|
-
init_fixer_packet();
|
|
8550
8248
|
init_merger_git_state();
|
|
8551
8249
|
init_merger_contracts();
|
|
8552
8250
|
init_sha256();
|
|
@@ -9838,10 +9536,10 @@ function presentFailureTerminal(terminal, io) {
|
|
|
9838
9536
|
}
|
|
9839
9537
|
function defaultNavigatorGraceSleep() {
|
|
9840
9538
|
let timer;
|
|
9841
|
-
const sleep2 = ((ms) => new Promise((
|
|
9539
|
+
const sleep2 = ((ms) => new Promise((resolve21) => {
|
|
9842
9540
|
timer = setTimeout(() => {
|
|
9843
9541
|
timer = void 0;
|
|
9844
|
-
|
|
9542
|
+
resolve21();
|
|
9845
9543
|
}, ms);
|
|
9846
9544
|
}));
|
|
9847
9545
|
sleep2.cancel = () => {
|
|
@@ -9853,7 +9551,7 @@ function defaultNavigatorGraceSleep() {
|
|
|
9853
9551
|
return sleep2;
|
|
9854
9552
|
}
|
|
9855
9553
|
function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2 = defaultNavigatorGraceSleep()) {
|
|
9856
|
-
return new Promise((
|
|
9554
|
+
return new Promise((resolve21, reject) => {
|
|
9857
9555
|
let settled = false;
|
|
9858
9556
|
const finish = (action) => {
|
|
9859
9557
|
if (settled) return;
|
|
@@ -9862,11 +9560,11 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep2
|
|
|
9862
9560
|
action();
|
|
9863
9561
|
};
|
|
9864
9562
|
void work.then(
|
|
9865
|
-
(value) => finish(() =>
|
|
9563
|
+
(value) => finish(() => resolve21({ status: "done", value })),
|
|
9866
9564
|
(error) => finish(() => reject(error))
|
|
9867
9565
|
);
|
|
9868
9566
|
void sleep2(graceMs).then(() => {
|
|
9869
|
-
finish(() =>
|
|
9567
|
+
finish(() => resolve21({ status: "timeout" }));
|
|
9870
9568
|
});
|
|
9871
9569
|
});
|
|
9872
9570
|
}
|
|
@@ -10483,7 +10181,7 @@ __export(config_exports, {
|
|
|
10483
10181
|
setPersistentSeatHost: () => setPersistentSeatHost,
|
|
10484
10182
|
validatePublicCliConfigAxes: () => validatePublicCliConfigAxes
|
|
10485
10183
|
});
|
|
10486
|
-
import { mkdir, readFile as
|
|
10184
|
+
import { mkdir, readFile as readFile8, writeFile as writeFile2 } from "node:fs/promises";
|
|
10487
10185
|
import { dirname as dirname11, join as join15 } from "node:path";
|
|
10488
10186
|
function isGateOfficerSeat(value) {
|
|
10489
10187
|
return packagedProvinceConfig(value);
|
|
@@ -10497,7 +10195,7 @@ function publicCliConfigPath(home) {
|
|
|
10497
10195
|
async function loadPublicCliConfig(home) {
|
|
10498
10196
|
const path = publicCliConfigPath(home);
|
|
10499
10197
|
try {
|
|
10500
|
-
const raw = await
|
|
10198
|
+
const raw = await readFile8(path, "utf8");
|
|
10501
10199
|
return parsePublicCliConfig(JSON.parse(raw));
|
|
10502
10200
|
} catch (error) {
|
|
10503
10201
|
if (isEnoent(error)) return { seats: {} };
|
|
@@ -10956,7 +10654,7 @@ function resolvePublicAgentDir(explicit, home) {
|
|
|
10956
10654
|
}
|
|
10957
10655
|
async function loadCredentialProviders(agentDir) {
|
|
10958
10656
|
try {
|
|
10959
|
-
const raw = await
|
|
10657
|
+
const raw = await readFile8(join15(agentDir, "auth.json"), "utf8");
|
|
10960
10658
|
return credentialProvidersFromAuthData(JSON.parse(raw));
|
|
10961
10659
|
} catch (error) {
|
|
10962
10660
|
if (isEnoent(error)) return { "openai-codex": false, xai: false };
|
|
@@ -11340,7 +11038,7 @@ var init_role_seat_runtime = __esm({
|
|
|
11340
11038
|
});
|
|
11341
11039
|
|
|
11342
11040
|
// src/archivist-record-pointer.ts
|
|
11343
|
-
import { basename as
|
|
11041
|
+
import { basename as basename8, join as join19 } from "node:path";
|
|
11344
11042
|
function bookDirectOfficerRunPointer(options) {
|
|
11345
11043
|
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
11346
11044
|
const pointer = {
|
|
@@ -11366,7 +11064,7 @@ async function resolveOfficerPointer(raw, parentRunDirectory) {
|
|
|
11366
11064
|
let runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== "" ? raw.runDirectory : void 0;
|
|
11367
11065
|
let sessionFile = raw.sessionFile;
|
|
11368
11066
|
const recordedRunDirectory = runDirectory ?? runDirectoryOfSessionFile(sessionFile);
|
|
11369
|
-
const leaf = parseRunLeaf(
|
|
11067
|
+
const leaf = parseRunLeaf(basename8(recordedRunDirectory));
|
|
11370
11068
|
const parentIdentity = await readRoleRunIdentity(parentRunDirectory);
|
|
11371
11069
|
if (leaf !== void 0 && parentIdentity !== void 0) {
|
|
11372
11070
|
const currentRunDirectory = await findRunDirectoryById(
|
|
@@ -11727,7 +11425,7 @@ var init_submission_gate = __esm({
|
|
|
11727
11425
|
|
|
11728
11426
|
// src/session-opening-materials.ts
|
|
11729
11427
|
import { existsSync as existsSync7 } from "node:fs";
|
|
11730
|
-
import { readFile as
|
|
11428
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
11731
11429
|
import { dirname as dirname12, join as join20 } from "node:path";
|
|
11732
11430
|
import { fileURLToPath, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11733
11431
|
function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
@@ -11743,7 +11441,7 @@ function resolvePackageRootDir(moduleUrl = import.meta.url) {
|
|
|
11743
11441
|
return fileURLToPath(new URL("..", moduleUrl));
|
|
11744
11442
|
}
|
|
11745
11443
|
async function readPackageMaterial(relativePath) {
|
|
11746
|
-
return
|
|
11444
|
+
return readFile9(fileURLToPath(new URL(relativePath, packageRootUrl)), "utf8");
|
|
11747
11445
|
}
|
|
11748
11446
|
async function joinPackageMaterials(relativePaths) {
|
|
11749
11447
|
const chunks = [];
|
|
@@ -11801,7 +11499,7 @@ __export(auditor_soul_exports, {
|
|
|
11801
11499
|
readAuditorResumeBinding: () => readAuditorResumeBinding,
|
|
11802
11500
|
resolveAuditorSubject: () => resolveAuditorSubject
|
|
11803
11501
|
});
|
|
11804
|
-
import { basename as
|
|
11502
|
+
import { basename as basename9 } from "node:path";
|
|
11805
11503
|
function auditorSoulRelativePath(role) {
|
|
11806
11504
|
return `souls/${role}-auditor.md`;
|
|
11807
11505
|
}
|
|
@@ -11837,7 +11535,7 @@ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
|
|
|
11837
11535
|
return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
|
|
11838
11536
|
}
|
|
11839
11537
|
function subjectFromSourceDirectory(sourceRunDirectory) {
|
|
11840
|
-
const role = parseRunLeaf(
|
|
11538
|
+
const role = parseRunLeaf(basename9(sourceRunDirectory))?.role;
|
|
11841
11539
|
return isAuditorSoulRole(role) ? role : void 0;
|
|
11842
11540
|
}
|
|
11843
11541
|
async function readAuditorResumeBinding(runDirectory) {
|
|
@@ -11877,7 +11575,7 @@ var init_auditor_soul = __esm({
|
|
|
11877
11575
|
|
|
11878
11576
|
// src/public-cli/machine-method-skills.ts
|
|
11879
11577
|
import { accessSync, constants as constants2, statSync as statSync5 } from "node:fs";
|
|
11880
|
-
import { lstat as
|
|
11578
|
+
import { lstat as lstat2, mkdir as mkdir2, symlink } from "node:fs/promises";
|
|
11881
11579
|
import { join as join22 } from "node:path";
|
|
11882
11580
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
11883
11581
|
function skillRoot(home) {
|
|
@@ -11907,7 +11605,7 @@ function linkedSkillRoot(home, host) {
|
|
|
11907
11605
|
}
|
|
11908
11606
|
async function occupied(path) {
|
|
11909
11607
|
try {
|
|
11910
|
-
await
|
|
11608
|
+
await lstat2(path);
|
|
11911
11609
|
return true;
|
|
11912
11610
|
} catch (error) {
|
|
11913
11611
|
if (error.code !== "ENOENT") throw error;
|
|
@@ -12404,7 +12102,6 @@ var init_auto_resume = __esm({
|
|
|
12404
12102
|
|
|
12405
12103
|
// src/public-cli/post-admission.ts
|
|
12406
12104
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
12407
|
-
import { isAbsolute as isAbsolute7, join as join23, resolve as resolve12 } from "node:path";
|
|
12408
12105
|
function describeCaughtError(error) {
|
|
12409
12106
|
if (error instanceof Error) {
|
|
12410
12107
|
const code = error.code;
|
|
@@ -12426,7 +12123,7 @@ function projectRelocatedTurnIdentity(request, result, admitted, relocation) {
|
|
|
12426
12123
|
mutableRequest.principal = admitted.principal;
|
|
12427
12124
|
const activation = mutableRequest.activation;
|
|
12428
12125
|
if (isRecord(activation)) {
|
|
12429
|
-
for (const field of ["
|
|
12126
|
+
for (const field of ["inputPath"]) {
|
|
12430
12127
|
const record = activation;
|
|
12431
12128
|
if (field in record) record[field] = rewrite(record[field]);
|
|
12432
12129
|
}
|
|
@@ -13159,7 +12856,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
13159
12856
|
prompt = request.message;
|
|
13160
12857
|
}
|
|
13161
12858
|
} else if (summonsPrepared !== void 0) {
|
|
13162
|
-
prompt = officerDialogue ? summonsPrepared.
|
|
12859
|
+
prompt = officerDialogue ? summonsPrepared.instruction : buildInstructionTransportPrompt(summonsPrepared);
|
|
13163
12860
|
} else if (request.summons !== void 0) {
|
|
13164
12861
|
prompt = "";
|
|
13165
12862
|
} else {
|
|
@@ -13240,24 +12937,14 @@ async function runSettledAutoResumeLoop(input) {
|
|
|
13240
12937
|
})
|
|
13241
12938
|
});
|
|
13242
12939
|
}
|
|
13243
|
-
function
|
|
13244
|
-
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
13245
|
-
return pathContainedIn(join23(runDirectory, "attachments"), absolute);
|
|
13246
|
-
}
|
|
13247
|
-
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
12940
|
+
async function prepareSummonsResumeMaterials(_runDirectory, summons) {
|
|
13248
12941
|
if (summons === void 0) return void 0;
|
|
13249
12942
|
if (summons.instruction === void 0 && (summons.attachmentPaths?.length ?? 0) === 0) {
|
|
13250
12943
|
return void 0;
|
|
13251
12944
|
}
|
|
13252
12945
|
const instruction = summons.instruction ?? "";
|
|
13253
|
-
const instructionEmpty = summons.instructionEmpty ?? instruction.
|
|
13254
|
-
|
|
13255
|
-
if (summons.attachmentPaths !== void 0 && summons.attachmentPaths.length > 0) {
|
|
13256
|
-
const alreadyFrozen = summons.attachmentPaths.every(
|
|
13257
|
-
(path) => isAlreadyFrozenSummonsAttachment(runDirectory, path)
|
|
13258
|
-
);
|
|
13259
|
-
attachments = alreadyFrozen ? summons.attachmentPaths.map((frozenPath) => ({ frozenPath })) : await freezeAttachmentsIntoRun(summons.attachmentPaths, runDirectory);
|
|
13260
|
-
}
|
|
12946
|
+
const instructionEmpty = summons.instructionEmpty ?? instruction.length === 0;
|
|
12947
|
+
const attachments = (summons.attachmentPaths ?? []).map((path) => ({ path }));
|
|
13261
12948
|
return { instruction, instructionEmpty, attachments };
|
|
13262
12949
|
}
|
|
13263
12950
|
async function runPostAdmissionSeatResume(input) {
|
|
@@ -13306,23 +12993,6 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
13306
12993
|
openCourtAttemptId = openCourt.courtAttemptId;
|
|
13307
12994
|
}
|
|
13308
12995
|
}
|
|
13309
|
-
if (request.summons !== void 0) {
|
|
13310
|
-
const prepared = await prepareSummonsResumeMaterials(
|
|
13311
|
-
admittedForBuild.runDirectory,
|
|
13312
|
-
request.summons
|
|
13313
|
-
);
|
|
13314
|
-
if (prepared !== void 0 && (request.summons.attachmentPaths?.length ?? 0) > 0) {
|
|
13315
|
-
request = {
|
|
13316
|
-
...request,
|
|
13317
|
-
summons: {
|
|
13318
|
-
...request.summons,
|
|
13319
|
-
attachmentPaths: prepared.attachments.map(
|
|
13320
|
-
(attachment) => attachment.frozenPath
|
|
13321
|
-
)
|
|
13322
|
-
}
|
|
13323
|
-
};
|
|
13324
|
-
}
|
|
13325
|
-
}
|
|
13326
12996
|
let turnRequest = await input.buildTurnRequest(admittedForBuild, request);
|
|
13327
12997
|
if (turnRequest.continuation.kind === "resume" && turnRequest.continuation.hostSessionId === void 0) {
|
|
13328
12998
|
const hostSessionId = await readStoredHostSessionId(
|
|
@@ -13572,7 +13242,6 @@ var init_post_admission = __esm({
|
|
|
13572
13242
|
init_invocation();
|
|
13573
13243
|
init_submission_ledger();
|
|
13574
13244
|
init_run_ticket_number();
|
|
13575
|
-
init_activation_ledger_topology();
|
|
13576
13245
|
init_session_identity();
|
|
13577
13246
|
init_sitian_facade();
|
|
13578
13247
|
init_receipt_delivery_policy();
|
|
@@ -13712,7 +13381,7 @@ __export(instruction_seat_run_exports, {
|
|
|
13712
13381
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
13713
13382
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
13714
13383
|
});
|
|
13715
|
-
import { dirname as dirname13, resolve as
|
|
13384
|
+
import { dirname as dirname13, resolve as resolve12 } from "node:path";
|
|
13716
13385
|
function unreadablePostSubmissionStatus(admitted, terminal) {
|
|
13717
13386
|
if (terminal?.roleOutcome.kind !== "accepted") return void 0;
|
|
13718
13387
|
const route = POST_SUBMISSION_ROUTING[admitted.role];
|
|
@@ -13940,7 +13609,7 @@ async function runOmittedLensBatch(argv, parsed, env, io) {
|
|
|
13940
13609
|
const children = await summonParallelReviewerLenses2({
|
|
13941
13610
|
argv,
|
|
13942
13611
|
cwd: env.cwd,
|
|
13943
|
-
projectRoot:
|
|
13612
|
+
projectRoot: resolve12(parsed.project ?? env.cwd),
|
|
13944
13613
|
baseRevision: parsed.baseRevision ?? "",
|
|
13945
13614
|
home: env.home,
|
|
13946
13615
|
agentDir: env.agentDir,
|
|
@@ -14022,14 +13691,14 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14022
13691
|
const resumed = await resumeSameParentInstructionSeat({
|
|
14023
13692
|
env,
|
|
14024
13693
|
io,
|
|
14025
|
-
projectRoot:
|
|
13694
|
+
projectRoot: resolve12(parsed.project ?? env.cwd),
|
|
14026
13695
|
role: "countersign",
|
|
14027
13696
|
parentRunPath: gateParentRunPath,
|
|
14028
13697
|
...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
|
|
14029
13698
|
summons: {
|
|
14030
13699
|
sourceRunPath: gateParentRunPath,
|
|
14031
13700
|
instruction: resumeInstruction,
|
|
14032
|
-
instructionEmpty: resumeInstruction.
|
|
13701
|
+
instructionEmpty: resumeInstruction.length === 0
|
|
14033
13702
|
}
|
|
14034
13703
|
});
|
|
14035
13704
|
if (resumed != null) return resumed;
|
|
@@ -14043,12 +13712,12 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14043
13712
|
throw error;
|
|
14044
13713
|
}
|
|
14045
13714
|
try {
|
|
14046
|
-
|
|
13715
|
+
{
|
|
14047
13716
|
const materializeAdmission = async (ticketNumber) => {
|
|
14048
13717
|
await materializeCountersignInvocation(admitted, {
|
|
14049
13718
|
home: env.home,
|
|
14050
13719
|
principalAuthority: env.principalAuthority,
|
|
14051
|
-
|
|
13720
|
+
attachmentPaths: parsed.attachmentPaths ?? [],
|
|
14052
13721
|
...env.model === void 0 ? {} : { model: env.model },
|
|
14053
13722
|
...ticketNumber === void 0 ? {} : { ticketNumber }
|
|
14054
13723
|
});
|
|
@@ -14083,7 +13752,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14083
13752
|
});
|
|
14084
13753
|
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
14085
13754
|
return result;
|
|
14086
|
-
}
|
|
13755
|
+
}
|
|
14087
13756
|
} catch (error) {
|
|
14088
13757
|
const rejected = usageExit(error, io);
|
|
14089
13758
|
if (rejected !== void 0) return rejected;
|
|
@@ -14148,7 +13817,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14148
13817
|
const summons = {
|
|
14149
13818
|
...sameParentInstruction(env, {
|
|
14150
13819
|
instruction: parsed.instruction ?? "",
|
|
14151
|
-
instructionEmpty: (parsed.instruction ?? "").
|
|
13820
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14152
13821
|
}),
|
|
14153
13822
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14154
13823
|
};
|
|
@@ -14173,7 +13842,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14173
13842
|
sourceRunPath: parentRunPath,
|
|
14174
13843
|
...sameParentInstruction(env, {
|
|
14175
13844
|
instruction: parsed.instruction ?? "",
|
|
14176
|
-
instructionEmpty: (parsed.instruction ?? "").
|
|
13845
|
+
instructionEmpty: (parsed.instruction ?? "").length === 0
|
|
14177
13846
|
}),
|
|
14178
13847
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
14179
13848
|
};
|
|
@@ -14257,7 +13926,7 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
14257
13926
|
instruction: parsed.instruction ?? "",
|
|
14258
13927
|
projectRoot: admitted.projectRoot,
|
|
14259
13928
|
failureLabel: "secretariat unbound summons",
|
|
14260
|
-
attachmentPaths: admitted.attachments.map((attachment) => attachment.
|
|
13929
|
+
attachmentPaths: admitted.attachments.map((attachment) => attachment.path),
|
|
14261
13930
|
correlationId: admitted.runId
|
|
14262
13931
|
}, env, io);
|
|
14263
13932
|
} catch (error) {
|
|
@@ -14816,7 +14485,7 @@ var init_instruction_seat_run = __esm({
|
|
|
14816
14485
|
|
|
14817
14486
|
// src/analyst-book-key.ts
|
|
14818
14487
|
import { statSync as statSync6 } from "node:fs";
|
|
14819
|
-
import { isAbsolute as
|
|
14488
|
+
import { isAbsolute as isAbsolute7 } from "node:path";
|
|
14820
14489
|
function resolveAnalystBookKey(projectRoot) {
|
|
14821
14490
|
const identity = physicalPathIdentity(projectRoot);
|
|
14822
14491
|
let stats;
|
|
@@ -14838,7 +14507,7 @@ function resolveAnalystBookKey(projectRoot) {
|
|
|
14838
14507
|
}
|
|
14839
14508
|
}
|
|
14840
14509
|
function isSyntheticAnalystBookKey(bookKey) {
|
|
14841
|
-
return bookKey.startsWith("root:") &&
|
|
14510
|
+
return bookKey.startsWith("root:") && isAbsolute7(bookKey.slice("root:".length));
|
|
14842
14511
|
}
|
|
14843
14512
|
var init_analyst_book_key = __esm({
|
|
14844
14513
|
"src/analyst-book-key.ts"() {
|
|
@@ -14850,16 +14519,16 @@ var init_analyst_book_key = __esm({
|
|
|
14850
14519
|
|
|
14851
14520
|
// src/atomic-write.ts
|
|
14852
14521
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
14853
|
-
import { rename as rename2, rm
|
|
14854
|
-
import { dirname as dirname14, join as
|
|
14522
|
+
import { rename as rename2, rm, writeFile as writeFile3 } from "node:fs/promises";
|
|
14523
|
+
import { dirname as dirname14, join as join23 } from "node:path";
|
|
14855
14524
|
async function writeFileAtomically(destination, contents, options) {
|
|
14856
14525
|
const parent = dirname14(destination);
|
|
14857
|
-
const temporary =
|
|
14526
|
+
const temporary = join23(parent, `.atomic-write-${randomUUID6()}.tmp`);
|
|
14858
14527
|
try {
|
|
14859
14528
|
await writeFile3(temporary, contents, options);
|
|
14860
14529
|
await rename2(temporary, destination);
|
|
14861
14530
|
} catch (error) {
|
|
14862
|
-
await
|
|
14531
|
+
await rm(temporary, { force: true }).catch(() => void 0);
|
|
14863
14532
|
throw error;
|
|
14864
14533
|
}
|
|
14865
14534
|
}
|
|
@@ -14870,13 +14539,13 @@ var init_atomic_write = __esm({
|
|
|
14870
14539
|
});
|
|
14871
14540
|
|
|
14872
14541
|
// src/analyst-index.ts
|
|
14873
|
-
import { open, readFile as
|
|
14874
|
-
import { dirname as dirname15, join as
|
|
14542
|
+
import { open, readFile as readFile10, unlink } from "node:fs/promises";
|
|
14543
|
+
import { dirname as dirname15, join as join24 } from "node:path";
|
|
14875
14544
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
14876
14545
|
async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
14877
14546
|
const indexPath = analystLibraryIndexPath(ledgerHome);
|
|
14878
14547
|
ensureRealDirectoryTree(ledgerHome, dirname15(indexPath));
|
|
14879
|
-
const lockPath =
|
|
14548
|
+
const lockPath = join24(dirname15(indexPath), LIBRARY_INDEX_LOCK_NAME);
|
|
14880
14549
|
assertLedgerFileInsideHome(lockPath, ledgerHome);
|
|
14881
14550
|
const startedAt = Date.now();
|
|
14882
14551
|
while (true) {
|
|
@@ -14903,7 +14572,7 @@ async function withAnalystLibraryIndexLock(ledgerHome, fn) {
|
|
|
14903
14572
|
}
|
|
14904
14573
|
}
|
|
14905
14574
|
function analystLibraryIndexPath(ledgerHome) {
|
|
14906
|
-
return
|
|
14575
|
+
return join24(ledgerHome, "analyst", "library-index.json");
|
|
14907
14576
|
}
|
|
14908
14577
|
function rowFromIssueMetricsPage(page) {
|
|
14909
14578
|
return {
|
|
@@ -14994,7 +14663,7 @@ async function readAnalystLibraryIndexPage(ledgerHome) {
|
|
|
14994
14663
|
const path = analystLibraryIndexPath(ledgerHome);
|
|
14995
14664
|
let raw;
|
|
14996
14665
|
try {
|
|
14997
|
-
raw = await
|
|
14666
|
+
raw = await readFile10(path, "utf8");
|
|
14998
14667
|
} catch (error) {
|
|
14999
14668
|
if (isMissingPathError(error)) return void 0;
|
|
15000
14669
|
throw error;
|
|
@@ -15449,7 +15118,7 @@ var init_analyst_gate_cycles_read = __esm({
|
|
|
15449
15118
|
|
|
15450
15119
|
// src/analyst-ledger.ts
|
|
15451
15120
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
15452
|
-
import { basename as
|
|
15121
|
+
import { basename as basename10, join as join25 } from "node:path";
|
|
15453
15122
|
async function readExistingRunLifecycleState(runDirectory) {
|
|
15454
15123
|
return (await readRoleRunIdentity(runDirectory))?.state;
|
|
15455
15124
|
}
|
|
@@ -15469,7 +15138,7 @@ function ghostLeaseCheckFromAutopsy(autopsy) {
|
|
|
15469
15138
|
}
|
|
15470
15139
|
}
|
|
15471
15140
|
async function classifyGhostCandidate(input) {
|
|
15472
|
-
const autopsy = await autopsyWriterLock(
|
|
15141
|
+
const autopsy = await autopsyWriterLock(join25(input.runDirectory, "writer.lock"));
|
|
15473
15142
|
const leaseCheck = ghostLeaseCheckFromAutopsy(autopsy);
|
|
15474
15143
|
if (leaseCheck === void 0) return { kind: "live" };
|
|
15475
15144
|
return {
|
|
@@ -15759,7 +15428,7 @@ async function classifyScopedRun(input) {
|
|
|
15759
15428
|
async function scanAnalystIssueRuns(input) {
|
|
15760
15429
|
const ledgerHome = resolveActivationLedgerHome(input.home);
|
|
15761
15430
|
const scopeTicketNumber = input.ticketNumber;
|
|
15762
|
-
const booksRoot =
|
|
15431
|
+
const booksRoot = join25(ledgerHome, "books");
|
|
15763
15432
|
let wholeBook = false;
|
|
15764
15433
|
let scopeRootIdentity;
|
|
15765
15434
|
let bookNames;
|
|
@@ -15792,7 +15461,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
15792
15461
|
const ghostLegs = [];
|
|
15793
15462
|
const scopeConflicts = [];
|
|
15794
15463
|
for (const book of bookNames) {
|
|
15795
|
-
const bookDir =
|
|
15464
|
+
const bookDir = join25(booksRoot, book);
|
|
15796
15465
|
let runDirectories;
|
|
15797
15466
|
try {
|
|
15798
15467
|
runDirectories = await listBookRunDirectories(bookDir);
|
|
@@ -15801,7 +15470,7 @@ async function scanAnalystIssueRuns(input) {
|
|
|
15801
15470
|
throw error;
|
|
15802
15471
|
}
|
|
15803
15472
|
for (const runDirectory of runDirectories) {
|
|
15804
|
-
const runName =
|
|
15473
|
+
const runName = basename10(runDirectory);
|
|
15805
15474
|
const parsed = parseRunLeaf(runName);
|
|
15806
15475
|
if (parsed === void 0) continue;
|
|
15807
15476
|
let scopeFields;
|
|
@@ -16538,7 +16207,7 @@ var init_analyst_metric_family = __esm({
|
|
|
16538
16207
|
});
|
|
16539
16208
|
|
|
16540
16209
|
// src/analyst-page.ts
|
|
16541
|
-
import { dirname as dirname16, join as
|
|
16210
|
+
import { dirname as dirname16, join as join26 } from "node:path";
|
|
16542
16211
|
function analystIssuePageKey(address) {
|
|
16543
16212
|
const parts = ["book", address.bookKey];
|
|
16544
16213
|
if (address.issueNumber !== void 0) {
|
|
@@ -16549,7 +16218,7 @@ function analystIssuePageKey(address) {
|
|
|
16549
16218
|
return sha256Hex(parts.join("\0")).slice(0, 32);
|
|
16550
16219
|
}
|
|
16551
16220
|
function analystIssuePagePath(ledgerHome, address) {
|
|
16552
|
-
return
|
|
16221
|
+
return join26(ledgerHome, "analyst", "issues", `${analystIssuePageKey(address)}.json`);
|
|
16553
16222
|
}
|
|
16554
16223
|
function analystIssuePageAddressFromPage(page) {
|
|
16555
16224
|
return {
|
|
@@ -16785,8 +16454,8 @@ var init_analyst_model_groups = __esm({
|
|
|
16785
16454
|
});
|
|
16786
16455
|
|
|
16787
16456
|
// src/analyst-entry.ts
|
|
16788
|
-
import { readFile as
|
|
16789
|
-
import { Type as
|
|
16457
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
16458
|
+
import { Type as Type16 } from "typebox";
|
|
16790
16459
|
function cachedPageMatchesRequestedScope(page, input) {
|
|
16791
16460
|
if (page.bookKey !== input.bookKey) return false;
|
|
16792
16461
|
const requestedTicket = input.ticketNumber ?? input.issueNumber;
|
|
@@ -16813,7 +16482,7 @@ async function readOrComputeAnalystIssuePage(input, options) {
|
|
|
16813
16482
|
...issueNumber === void 0 && input.bookKey === void 0 ? { scopeRootIdentity: projectRoot } : {}
|
|
16814
16483
|
});
|
|
16815
16484
|
try {
|
|
16816
|
-
const raw = await
|
|
16485
|
+
const raw = await readFile12(pagePath, "utf8");
|
|
16817
16486
|
const page = JSON.parse(raw);
|
|
16818
16487
|
if (cachedPageMatchesRequestedScope(page, { bookKey, ...input })) {
|
|
16819
16488
|
const ghostScan = await scanAnalystIssueRuns({
|
|
@@ -16914,7 +16583,7 @@ async function runAnalystModelGroupsMode(input, home) {
|
|
|
16914
16583
|
scopeRootIdentity: projectRoot
|
|
16915
16584
|
});
|
|
16916
16585
|
try {
|
|
16917
|
-
const raw = await
|
|
16586
|
+
const raw = await readFile12(pagePath, "utf8");
|
|
16918
16587
|
JSON.parse(raw);
|
|
16919
16588
|
} catch (error) {
|
|
16920
16589
|
if (!isMissingPathError(error)) {
|
|
@@ -16991,16 +16660,16 @@ var init_analyst_entry = __esm({
|
|
|
16991
16660
|
}
|
|
16992
16661
|
}
|
|
16993
16662
|
};
|
|
16994
|
-
analystSweepModeInputSchema =
|
|
16663
|
+
analystSweepModeInputSchema = Type16.Object(
|
|
16995
16664
|
{
|
|
16996
|
-
mode:
|
|
16997
|
-
mergedPullRequests:
|
|
16998
|
-
|
|
16665
|
+
mode: Type16.Literal("sweep"),
|
|
16666
|
+
mergedPullRequests: Type16.Array(
|
|
16667
|
+
Type16.Object(
|
|
16999
16668
|
{
|
|
17000
|
-
projectRoot:
|
|
16669
|
+
projectRoot: Type16.String(),
|
|
17001
16670
|
/** 排除后改动行数 — omit or 0 → typed 空缺; finite ≥ 0 only. */
|
|
17002
|
-
changedLines:
|
|
17003
|
-
|
|
16671
|
+
changedLines: Type16.Optional(
|
|
16672
|
+
Type16.Number({ minimum: 0, maximum: Number.MAX_VALUE })
|
|
17004
16673
|
)
|
|
17005
16674
|
}
|
|
17006
16675
|
)
|
|
@@ -17011,9 +16680,9 @@ var init_analyst_entry = __esm({
|
|
|
17011
16680
|
});
|
|
17012
16681
|
|
|
17013
16682
|
// src/public-cli/analyst-run.ts
|
|
17014
|
-
import { readFile as
|
|
17015
|
-
import { isAbsolute as
|
|
17016
|
-
import { Value
|
|
16683
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
16684
|
+
import { isAbsolute as isAbsolute8, resolve as resolve13 } from "node:path";
|
|
16685
|
+
import { Value } from "typebox/value";
|
|
17017
16686
|
function resolveAnalystIssueBookKeyFromCwd(cwd = process.cwd()) {
|
|
17018
16687
|
try {
|
|
17019
16688
|
return resolveBookKeyFromGit(cwd);
|
|
@@ -17048,7 +16717,7 @@ async function buildAnalystIssueModeInputFromPublicArgv(parsed, _ledgerHome) {
|
|
|
17048
16717
|
};
|
|
17049
16718
|
}
|
|
17050
16719
|
function parseAnalystSweepModeInputFromJsonValue(value) {
|
|
17051
|
-
if (!
|
|
16720
|
+
if (!Value.Check(analystSweepModeInputSchema, value)) {
|
|
17052
16721
|
throw new CliUsageError(
|
|
17053
16722
|
"analyst sweep attachment must match AnalystSweepModeInput"
|
|
17054
16723
|
);
|
|
@@ -17062,10 +16731,10 @@ async function buildAnalystSweepModeInputFromAttachmentPaths(attachmentPaths) {
|
|
|
17062
16731
|
);
|
|
17063
16732
|
}
|
|
17064
16733
|
const sourcePath = attachmentPaths[0];
|
|
17065
|
-
const absolute =
|
|
16734
|
+
const absolute = isAbsolute8(sourcePath) ? sourcePath : resolve13(sourcePath);
|
|
17066
16735
|
let bytes;
|
|
17067
16736
|
try {
|
|
17068
|
-
bytes = await
|
|
16737
|
+
bytes = await readFile13(absolute);
|
|
17069
16738
|
} catch (error) {
|
|
17070
16739
|
throw new CliUsageError(
|
|
17071
16740
|
`analyst sweep attachment is not a readable regular file: ${sourcePath}`,
|
|
@@ -18095,7 +17764,7 @@ __export(public_role_summons_exports, {
|
|
|
18095
17764
|
import { execFile as execFile3 } from "node:child_process";
|
|
18096
17765
|
import { existsSync as existsSync8 } from "node:fs";
|
|
18097
17766
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
18098
|
-
import { join as
|
|
17767
|
+
import { join as join27 } from "node:path";
|
|
18099
17768
|
import { promisify as promisify3 } from "node:util";
|
|
18100
17769
|
function createCapturingIo() {
|
|
18101
17770
|
const chunks = [];
|
|
@@ -18119,7 +17788,7 @@ function parentDir(path) {
|
|
|
18119
17788
|
function walkPackageRoot(start) {
|
|
18120
17789
|
let dir = start;
|
|
18121
17790
|
for (let i = 0; i < 12; i += 1) {
|
|
18122
|
-
if (existsSync8(
|
|
17791
|
+
if (existsSync8(join27(dir, "package.json")) && existsSync8(join27(dir, "souls"))) {
|
|
18123
17792
|
return dir;
|
|
18124
17793
|
}
|
|
18125
17794
|
const parent = parentDir(dir);
|
|
@@ -18339,7 +18008,7 @@ async function summonPublicRole(options) {
|
|
|
18339
18008
|
runId: resumeRunId,
|
|
18340
18009
|
summons: {
|
|
18341
18010
|
instruction,
|
|
18342
|
-
instructionEmpty: instruction.
|
|
18011
|
+
instructionEmpty: instruction.length === 0
|
|
18343
18012
|
}
|
|
18344
18013
|
},
|
|
18345
18014
|
env,
|
|
@@ -18728,7 +18397,7 @@ var init_compliance_transport = __esm({
|
|
|
18728
18397
|
});
|
|
18729
18398
|
|
|
18730
18399
|
// src/role-run-relocation.ts
|
|
18731
|
-
import { dirname as dirname17, join as
|
|
18400
|
+
import { dirname as dirname17, join as join28, sep as sep4 } from "node:path";
|
|
18732
18401
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
18733
18402
|
if (typeof value !== "string") return value;
|
|
18734
18403
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
@@ -18808,13 +18477,6 @@ function rewriteSourceRunLocator(value, rewrites) {
|
|
|
18808
18477
|
function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
18809
18478
|
rewriteRunDirectoryPathFieldsAgainstRewrites(page, ADMITTED_PAGE_FIELDS, rewrites);
|
|
18810
18479
|
rewriteSourceRunLocator(page.sourceRun, rewrites);
|
|
18811
|
-
if (Array.isArray(page.attachments)) {
|
|
18812
|
-
for (const attachment of page.attachments) {
|
|
18813
|
-
if (isRecord(attachment)) {
|
|
18814
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(attachment, ["frozenPath"], rewrites);
|
|
18815
|
-
}
|
|
18816
|
-
}
|
|
18817
|
-
}
|
|
18818
18480
|
if (isRecord(page.principal)) {
|
|
18819
18481
|
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
18820
18482
|
page.principal,
|
|
@@ -18839,10 +18501,9 @@ var init_role_run_relocation = __esm({
|
|
|
18839
18501
|
// pre-#1161 pages only
|
|
18840
18502
|
"sessionDirectory",
|
|
18841
18503
|
"sessionFile",
|
|
18842
|
-
|
|
18843
|
-
|
|
18844
|
-
|
|
18845
|
-
"requestManifestPath",
|
|
18504
|
+
// #1165/#1168: caller file-flag paths (requestManifestPath, prerequisitesPath)
|
|
18505
|
+
// stay as given. Obsolete copy fields (taskPath/packetPath) are not rewritten —
|
|
18506
|
+
// stock volumes keep their bytes; live relocate no longer maintains them.
|
|
18846
18507
|
"mergerInputPath",
|
|
18847
18508
|
"sourceRunPath"
|
|
18848
18509
|
];
|
|
@@ -18877,8 +18538,8 @@ __export(run_lifecycle_exports, {
|
|
|
18877
18538
|
recordCurrentCourt: () => recordCurrentCourt,
|
|
18878
18539
|
writeRoleRunState: () => writeRoleRunState
|
|
18879
18540
|
});
|
|
18880
|
-
import { chmod, lstat as
|
|
18881
|
-
import { basename as
|
|
18541
|
+
import { chmod, lstat as lstat3, open as open2, readdir as readdir4, readFile as readFile14, unlink as unlink2 } from "node:fs/promises";
|
|
18542
|
+
import { basename as basename11, join as join29 } from "node:path";
|
|
18882
18543
|
function buildAutoResumeContinuationPrompt() {
|
|
18883
18544
|
return RESUME_TRANSPORT_ENVELOPE;
|
|
18884
18545
|
}
|
|
@@ -18891,7 +18552,7 @@ function parseSameTicketSummonsMaterials(raw) {
|
|
|
18891
18552
|
const record = raw;
|
|
18892
18553
|
const instruction = typeof record.instruction === "string" ? record.instruction : void 0;
|
|
18893
18554
|
const instructionEmpty = typeof record.instructionEmpty === "boolean" ? record.instructionEmpty : void 0;
|
|
18894
|
-
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string"
|
|
18555
|
+
const attachmentPaths = Array.isArray(record.attachmentPaths) ? record.attachmentPaths.filter((p) => typeof p === "string") : void 0;
|
|
18895
18556
|
const sourceRunPath = typeof record.sourceRunPath === "string" && record.sourceRunPath.trim() !== "" ? record.sourceRunPath : void 0;
|
|
18896
18557
|
let sourceRun;
|
|
18897
18558
|
if (isRecord(record.sourceRun)) {
|
|
@@ -19116,7 +18777,7 @@ function isProcessAlive(pid) {
|
|
|
19116
18777
|
async function autopsyWriterLock(lockPath) {
|
|
19117
18778
|
let content;
|
|
19118
18779
|
try {
|
|
19119
|
-
content = await
|
|
18780
|
+
content = await readFile14(lockPath, "utf8");
|
|
19120
18781
|
} catch (error) {
|
|
19121
18782
|
if (errorCodeOf(error) === "ENOENT") return { verdict: "absent" };
|
|
19122
18783
|
return { verdict: "unknown", reason: "unreadable", readFailure: error };
|
|
@@ -19175,7 +18836,7 @@ async function createWriterLease(lockPath, runDirectory, reportCleanupFailure) {
|
|
|
19175
18836
|
},
|
|
19176
18837
|
relocate(nextRunDirectory) {
|
|
19177
18838
|
currentRunDirectory = nextRunDirectory;
|
|
19178
|
-
currentLockPath =
|
|
18839
|
+
currentLockPath = join29(nextRunDirectory, WRITER_LOCK_FILE);
|
|
19179
18840
|
},
|
|
19180
18841
|
async release() {
|
|
19181
18842
|
if (released) return;
|
|
@@ -19214,10 +18875,10 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19214
18875
|
};
|
|
19215
18876
|
const reportReadFailure = (error) => {
|
|
19216
18877
|
reportDiagnostic(
|
|
19217
|
-
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${
|
|
18878
|
+
`writer lease lock read failed (holder liveness unverifiable; lock left in place) at ${join29(runDirectory, WRITER_LOCK_FILE)}: ${describeErrorIdentity(error)}`
|
|
19218
18879
|
);
|
|
19219
18880
|
};
|
|
19220
|
-
const lockPath =
|
|
18881
|
+
const lockPath = join29(runDirectory, WRITER_LOCK_FILE);
|
|
19221
18882
|
let lastAutopsy = { verdict: "absent" };
|
|
19222
18883
|
let lastReclaimFailure;
|
|
19223
18884
|
for (let reclaimsLeft = WRITER_LEASE_RECLAIM_ROUNDS; ; reclaimsLeft -= 1) {
|
|
@@ -19274,7 +18935,7 @@ async function acquireRunWriterLease(runDirectory, onCleanupFailure) {
|
|
|
19274
18935
|
async function findRunDirectoryById(home, runId, onlyBookKey, onlyRole) {
|
|
19275
18936
|
if (runId.trim() === "") return void 0;
|
|
19276
18937
|
const ledgerHome = resolveActivationLedgerHome(home);
|
|
19277
|
-
const booksRoot =
|
|
18938
|
+
const booksRoot = join29(ledgerHome, "books");
|
|
19278
18939
|
let bookKeys;
|
|
19279
18940
|
try {
|
|
19280
18941
|
bookKeys = await readdir4(booksRoot);
|
|
@@ -19309,7 +18970,7 @@ async function runHasFormedSessionPrincipal(runDirectory) {
|
|
|
19309
18970
|
if (disk === void 0) return false;
|
|
19310
18971
|
const sessionFile = typeof disk.principalWire.sessionFile === "string" && disk.principalWire.sessionFile.trim() !== "" ? disk.principalWire.sessionFile : sessionFileIn(disk.principalWire.sessionDirectory);
|
|
19311
18972
|
try {
|
|
19312
|
-
const stat2 = await
|
|
18973
|
+
const stat2 = await lstat3(sessionFile);
|
|
19313
18974
|
return stat2.isFile() && !stat2.isSymbolicLink();
|
|
19314
18975
|
} catch (error) {
|
|
19315
18976
|
if (errorCodeOf(error) === "ENOENT") return false;
|
|
@@ -19325,7 +18986,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19325
18986
|
let runDirectories;
|
|
19326
18987
|
try {
|
|
19327
18988
|
runDirectories = await listBookRunDirectories(
|
|
19328
|
-
input.ticketNumber === void 0 ? bookDir :
|
|
18989
|
+
input.ticketNumber === void 0 ? bookDir : join29(bookDir, String(input.ticketNumber))
|
|
19329
18990
|
);
|
|
19330
18991
|
} catch (error) {
|
|
19331
18992
|
if (errorCodeOf(error) === "ENOENT") return void 0;
|
|
@@ -19333,7 +18994,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
19333
18994
|
}
|
|
19334
18995
|
let best;
|
|
19335
18996
|
for (const runDirectory of runDirectories) {
|
|
19336
|
-
const parsed = parseRunLeaf(
|
|
18997
|
+
const parsed = parseRunLeaf(basename11(runDirectory));
|
|
19337
18998
|
if (parsed === void 0 || parsed.role !== input.role) continue;
|
|
19338
18999
|
const runId = parsed.runId;
|
|
19339
19000
|
const parentPath = await readRunParentPath(runDirectory);
|
|
@@ -19375,10 +19036,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19375
19036
|
let instructionEmpty = true;
|
|
19376
19037
|
let attachments = [];
|
|
19377
19038
|
let phase;
|
|
19378
|
-
let taskPath;
|
|
19379
|
-
let packetPath;
|
|
19380
19039
|
let prerequisitesPath;
|
|
19381
|
-
let prerequisites;
|
|
19382
19040
|
let baseRevision;
|
|
19383
19041
|
let lens;
|
|
19384
19042
|
let authorityRefs;
|
|
@@ -19390,7 +19048,6 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19390
19048
|
let repository;
|
|
19391
19049
|
let repositoryDisplay;
|
|
19392
19050
|
let requestManifestPath;
|
|
19393
|
-
let manifestDigest;
|
|
19394
19051
|
let waitWindowMs;
|
|
19395
19052
|
let issueNumber;
|
|
19396
19053
|
let caseRunsPath;
|
|
@@ -19413,23 +19070,14 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19413
19070
|
instructionEmpty = record.instructionEmpty;
|
|
19414
19071
|
}
|
|
19415
19072
|
if (Array.isArray(record.attachments)) {
|
|
19416
|
-
attachments = record.attachments;
|
|
19073
|
+
attachments = record.attachments.map((item) => normalizeAdmittedAttachment(item)).filter((item) => item !== void 0);
|
|
19417
19074
|
}
|
|
19418
19075
|
if (record.phase === "plan" || record.phase === "apply") {
|
|
19419
19076
|
phase = record.phase;
|
|
19420
19077
|
}
|
|
19421
|
-
if (typeof record.
|
|
19422
|
-
taskPath = record.taskPath;
|
|
19423
|
-
}
|
|
19424
|
-
if (typeof record.packetPath === "string" && record.packetPath.trim() !== "") {
|
|
19425
|
-
packetPath = record.packetPath;
|
|
19426
|
-
}
|
|
19427
|
-
if (typeof record.prerequisitesPath === "string" && record.prerequisitesPath.trim() !== "") {
|
|
19078
|
+
if (typeof record.prerequisitesPath === "string") {
|
|
19428
19079
|
prerequisitesPath = record.prerequisitesPath;
|
|
19429
19080
|
}
|
|
19430
|
-
if (Array.isArray(record.prerequisites)) {
|
|
19431
|
-
prerequisites = record.prerequisites;
|
|
19432
|
-
}
|
|
19433
19081
|
if (typeof record.baseRevision === "string" && record.baseRevision.trim() !== "") {
|
|
19434
19082
|
baseRevision = record.baseRevision;
|
|
19435
19083
|
}
|
|
@@ -19445,12 +19093,9 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19445
19093
|
if (typeof record.repositoryDisplay === "string" && record.repositoryDisplay.trim() !== "") {
|
|
19446
19094
|
repositoryDisplay = record.repositoryDisplay;
|
|
19447
19095
|
}
|
|
19448
|
-
if (typeof record.requestManifestPath === "string"
|
|
19096
|
+
if (typeof record.requestManifestPath === "string") {
|
|
19449
19097
|
requestManifestPath = record.requestManifestPath;
|
|
19450
19098
|
}
|
|
19451
|
-
if (typeof record.manifestDigest === "string" && record.manifestDigest.trim() !== "") {
|
|
19452
|
-
manifestDigest = record.manifestDigest;
|
|
19453
|
-
}
|
|
19454
19099
|
if (typeof record.waitWindowMs === "number" && Number.isSafeInteger(record.waitWindowMs) && record.waitWindowMs >= 1) {
|
|
19455
19100
|
waitWindowMs = record.waitWindowMs;
|
|
19456
19101
|
}
|
|
@@ -19544,7 +19189,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19544
19189
|
);
|
|
19545
19190
|
}
|
|
19546
19191
|
}
|
|
19547
|
-
const sourceRunLeaf = parseRunLeaf(
|
|
19192
|
+
const sourceRunLeaf = parseRunLeaf(basename11(sourceRunPath ?? ""));
|
|
19548
19193
|
const referencedRunId = sourceRun?.runId ?? sourceRunLeaf?.runId;
|
|
19549
19194
|
const referencedRole = sourceRun?.role ?? sourceRunLeaf?.role;
|
|
19550
19195
|
if (referencedRunId !== void 0 && referencedRunId !== "") {
|
|
@@ -19569,10 +19214,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19569
19214
|
instructionEmpty,
|
|
19570
19215
|
attachments,
|
|
19571
19216
|
...phase === void 0 ? {} : { phase },
|
|
19572
|
-
...taskPath === void 0 ? {} : { taskPath },
|
|
19573
|
-
...packetPath === void 0 ? {} : { packetPath },
|
|
19574
19217
|
...prerequisitesPath === void 0 ? {} : { prerequisitesPath },
|
|
19575
|
-
...prerequisites === void 0 ? {} : { prerequisites },
|
|
19576
19218
|
...baseRevision === void 0 ? {} : { baseRevision },
|
|
19577
19219
|
...lens === void 0 ? {} : { lens },
|
|
19578
19220
|
...authorityRefs === void 0 ? {} : { authorityRefs },
|
|
@@ -19584,7 +19226,6 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
19584
19226
|
...repository === void 0 ? {} : { repository },
|
|
19585
19227
|
...repositoryDisplay === void 0 ? {} : { repositoryDisplay },
|
|
19586
19228
|
...requestManifestPath === void 0 ? {} : { requestManifestPath },
|
|
19587
|
-
...manifestDigest === void 0 ? {} : { manifestDigest },
|
|
19588
19229
|
...waitWindowMs === void 0 ? {} : { waitWindowMs },
|
|
19589
19230
|
...issueNumber === void 0 ? {} : { issueNumber },
|
|
19590
19231
|
...caseRunsPath === void 0 ? {} : { caseRunsPath },
|
|
@@ -19658,12 +19299,6 @@ function admitResumedRole(loaded) {
|
|
|
19658
19299
|
}
|
|
19659
19300
|
case "worker-task": {
|
|
19660
19301
|
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
|
|
19661
|
-
const taskPath = fields.taskPath;
|
|
19662
|
-
if (taskPath === void 0) {
|
|
19663
|
-
throw new CliUsageError(
|
|
19664
|
-
`role run admitted coder task path is missing: ${runId}`
|
|
19665
|
-
);
|
|
19666
|
-
}
|
|
19667
19302
|
if (fields.instruction.trim() === "") {
|
|
19668
19303
|
throw new CliUsageError(
|
|
19669
19304
|
`role run admitted coder task is blank: ${runId}`
|
|
@@ -19673,33 +19308,23 @@ function admitResumedRole(loaded) {
|
|
|
19673
19308
|
role: "coder",
|
|
19674
19309
|
phase,
|
|
19675
19310
|
...base,
|
|
19676
|
-
instructionEmpty: false
|
|
19677
|
-
taskPath
|
|
19311
|
+
instructionEmpty: false
|
|
19678
19312
|
};
|
|
19679
19313
|
return admitted;
|
|
19680
19314
|
}
|
|
19681
19315
|
case "worker-packet": {
|
|
19682
19316
|
const phase = resumedWorkerPhase(fields.phase ?? loaded.run.phase, record.phases, role, runId);
|
|
19683
|
-
const packetPath = fields.packetPath;
|
|
19684
|
-
if (packetPath === void 0) {
|
|
19685
|
-
throw new CliUsageError(
|
|
19686
|
-
`role run admitted fixer packet path is missing: ${runId}`
|
|
19687
|
-
);
|
|
19688
|
-
}
|
|
19689
19317
|
if (fields.instruction.trim() === "") {
|
|
19690
19318
|
throw new CliUsageError(
|
|
19691
19319
|
`role run admitted fixer instruction is blank: ${runId}`
|
|
19692
19320
|
);
|
|
19693
19321
|
}
|
|
19694
|
-
const prerequisites = fields.prerequisites ?? Object.freeze([]);
|
|
19695
19322
|
const admitted = {
|
|
19696
19323
|
role: "fixer",
|
|
19697
19324
|
phase,
|
|
19698
19325
|
...base,
|
|
19699
19326
|
instructionEmpty: false,
|
|
19700
|
-
|
|
19701
|
-
...fields.prerequisitesPath === void 0 ? {} : { prerequisitesPath: fields.prerequisitesPath },
|
|
19702
|
-
prerequisites
|
|
19327
|
+
...fields.prerequisitesPath === void 0 ? {} : { prerequisitesPath: fields.prerequisitesPath }
|
|
19703
19328
|
};
|
|
19704
19329
|
return admitted;
|
|
19705
19330
|
}
|
|
@@ -19774,8 +19399,8 @@ function admitResumedRole(loaded) {
|
|
|
19774
19399
|
return admitted;
|
|
19775
19400
|
}
|
|
19776
19401
|
case "collect-target": {
|
|
19777
|
-
const { prNumber, repository, repositoryDisplay
|
|
19778
|
-
if (repository === void 0 || repositoryDisplay === void 0
|
|
19402
|
+
const { prNumber, repository, repositoryDisplay } = fields;
|
|
19403
|
+
if (repository === void 0 || repositoryDisplay === void 0) {
|
|
19779
19404
|
throw new CliUsageError(
|
|
19780
19405
|
`role run admitted collector repository identity is missing: ${runId}`
|
|
19781
19406
|
);
|
|
@@ -19798,8 +19423,7 @@ function admitResumedRole(loaded) {
|
|
|
19798
19423
|
...prNumber === void 0 ? {} : { prNumber },
|
|
19799
19424
|
repository: parsedRepository,
|
|
19800
19425
|
...fields.requestManifestPath === void 0 ? {} : { requestManifestPath: fields.requestManifestPath },
|
|
19801
|
-
...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
|
|
19802
|
-
manifestDigest
|
|
19426
|
+
...fields.waitWindowMs === void 0 ? {} : { waitWindowMs: fields.waitWindowMs }
|
|
19803
19427
|
};
|
|
19804
19428
|
return admitted;
|
|
19805
19429
|
}
|
|
@@ -20105,7 +19729,7 @@ var init_receipt_delivery_policy = __esm({
|
|
|
20105
19729
|
});
|
|
20106
19730
|
|
|
20107
19731
|
// src/archivist-record-topology.ts
|
|
20108
|
-
import { join as
|
|
19732
|
+
import { join as join31 } from "node:path";
|
|
20109
19733
|
function resolveNavigatorWorkSubjectPlacement(input) {
|
|
20110
19734
|
let ledgerHome;
|
|
20111
19735
|
if (input.parentSessionFile !== void 0 && input.parentSessionFile.length > 0) {
|
|
@@ -20118,7 +19742,7 @@ function resolveNavigatorWorkSubjectPlacement(input) {
|
|
|
20118
19742
|
const digest = sha256Hex(input.subject).slice(0, 32);
|
|
20119
19743
|
return {
|
|
20120
19744
|
ledgerHome,
|
|
20121
|
-
sessionDir:
|
|
19745
|
+
sessionDir: join31(
|
|
20122
19746
|
activationBookDirectory(ledgerHome, resolveBookKeyFromGit(input.cwd)),
|
|
20123
19747
|
NAVIGATOR_RECORD_KIND,
|
|
20124
19748
|
digest
|
|
@@ -20191,7 +19815,7 @@ import {
|
|
|
20191
19815
|
statSync as statSync8,
|
|
20192
19816
|
writeFileSync as writeFileSync3
|
|
20193
19817
|
} from "node:fs";
|
|
20194
|
-
import { dirname as dirname19, resolve as
|
|
19818
|
+
import { dirname as dirname19, resolve as resolve16, join as join32 } from "node:path";
|
|
20195
19819
|
import { StringDecoder } from "node:string_decoder";
|
|
20196
19820
|
function readCurrentSession(sessionDir) {
|
|
20197
19821
|
const ledger = currentSessionLedgerPath(sessionDir);
|
|
@@ -20225,7 +19849,7 @@ function isCurrentSessionClaimRace(error) {
|
|
|
20225
19849
|
return errnoCode(error.cause) === "EEXIST";
|
|
20226
19850
|
}
|
|
20227
19851
|
function currentSessionLedgerPath(sessionDir) {
|
|
20228
|
-
return
|
|
19852
|
+
return join32(sessionDir, CURRENT_SESSION_LEDGER);
|
|
20229
19853
|
}
|
|
20230
19854
|
function readBoundedSessionHeader(filePath) {
|
|
20231
19855
|
const fd = openSync(filePath, "r");
|
|
@@ -20298,8 +19922,8 @@ function parseSessionHeaderLine(line2) {
|
|
|
20298
19922
|
};
|
|
20299
19923
|
}
|
|
20300
19924
|
function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
20301
|
-
const absoluteSessionDir =
|
|
20302
|
-
const absoluteCwd =
|
|
19925
|
+
const absoluteSessionDir = resolve16(sessionDir);
|
|
19926
|
+
const absoluteCwd = resolve16(cwd);
|
|
20303
19927
|
let names;
|
|
20304
19928
|
try {
|
|
20305
19929
|
names = readdirSync3(absoluteSessionDir);
|
|
@@ -20312,7 +19936,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20312
19936
|
const matched = [];
|
|
20313
19937
|
for (const name of names) {
|
|
20314
19938
|
if (!name.endsWith(".jsonl")) continue;
|
|
20315
|
-
const filePath =
|
|
19939
|
+
const filePath = join32(absoluteSessionDir, name);
|
|
20316
19940
|
let st;
|
|
20317
19941
|
try {
|
|
20318
19942
|
st = statSync8(filePath);
|
|
@@ -20334,7 +19958,7 @@ function mostRecentNavigatorSessionFile(sessionDir, cwd) {
|
|
|
20334
19958
|
}
|
|
20335
19959
|
if (header === void 0) continue;
|
|
20336
19960
|
if (typeof header.cwd !== "string" || header.cwd.length === 0) continue;
|
|
20337
|
-
if (
|
|
19961
|
+
if (resolve16(header.cwd) !== absoluteCwd) continue;
|
|
20338
19962
|
matched.push({ path: filePath, mtimeMs: st.mtimeMs });
|
|
20339
19963
|
}
|
|
20340
19964
|
if (matched.length === 0) return void 0;
|
|
@@ -20364,8 +19988,8 @@ function resolveNavigatorNestContinuation(sessionDir, cwd) {
|
|
|
20364
19988
|
}
|
|
20365
19989
|
}
|
|
20366
19990
|
function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
|
|
20367
|
-
const absoluteSessionDir =
|
|
20368
|
-
const absoluteFile =
|
|
19991
|
+
const absoluteSessionDir = resolve16(sessionDir);
|
|
19992
|
+
const absoluteFile = resolve16(recentFile);
|
|
20369
19993
|
if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
|
|
20370
19994
|
throw new ActivationLedgerError(
|
|
20371
19995
|
`archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
|
|
@@ -20420,7 +20044,7 @@ function createRecordSessionOpen(options, host = piRecordSessionHost) {
|
|
|
20420
20044
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20421
20045
|
} else {
|
|
20422
20046
|
ledgerHome = resolveActivationLedgerHomeForPath(parentFile);
|
|
20423
|
-
const parentResolved =
|
|
20047
|
+
const parentResolved = resolve16(parentFile);
|
|
20424
20048
|
if (!physicallyContainedIn(ledgerHome, parentResolved)) {
|
|
20425
20049
|
throw new Error("Durable record ownership requires a parent session inside the ledger home");
|
|
20426
20050
|
}
|
|
@@ -20511,22 +20135,22 @@ init_submission_ledger();
|
|
|
20511
20135
|
init_filed_submission();
|
|
20512
20136
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
20513
20137
|
import { writeSync as writeSync2 } from "node:fs";
|
|
20514
|
-
import { join as
|
|
20515
|
-
import { Value as
|
|
20138
|
+
import { join as join34 } from "node:path";
|
|
20139
|
+
import { Value as Value3 } from "typebox/value";
|
|
20516
20140
|
|
|
20517
20141
|
// src/activation-trace.ts
|
|
20518
|
-
import { Type as
|
|
20519
|
-
var causeSchema =
|
|
20520
|
-
identity:
|
|
20521
|
-
name:
|
|
20522
|
-
message:
|
|
20523
|
-
evidenceId:
|
|
20142
|
+
import { Type as Type17 } from "typebox";
|
|
20143
|
+
var causeSchema = Type17.Object({
|
|
20144
|
+
identity: Type17.String({ minLength: 1 }),
|
|
20145
|
+
name: Type17.String({ minLength: 1 }),
|
|
20146
|
+
message: Type17.String(),
|
|
20147
|
+
evidenceId: Type17.Optional(Type17.String({ minLength: 1 }))
|
|
20524
20148
|
}, { additionalProperties: false });
|
|
20525
|
-
var activationTraceRecordSchema =
|
|
20526
|
-
role:
|
|
20527
|
-
stageId:
|
|
20528
|
-
status:
|
|
20529
|
-
timestamp:
|
|
20149
|
+
var activationTraceRecordSchema = Type17.Object({
|
|
20150
|
+
role: Type17.String({ minLength: 1 }),
|
|
20151
|
+
stageId: Type17.String({ pattern: "^[a-z][a-z0-9-]*$" }),
|
|
20152
|
+
status: Type17.Literal("failed"),
|
|
20153
|
+
timestamp: Type17.String({ format: "date-time" }),
|
|
20530
20154
|
cause: causeSchema
|
|
20531
20155
|
}, { additionalProperties: false });
|
|
20532
20156
|
var activationCauseEvidence = 0;
|
|
@@ -20563,7 +20187,7 @@ import {
|
|
|
20563
20187
|
statSync as statSync7,
|
|
20564
20188
|
writeFileSync as writeFileSync2
|
|
20565
20189
|
} from "node:fs";
|
|
20566
|
-
import { isAbsolute as
|
|
20190
|
+
import { isAbsolute as isAbsolute10, resolve as resolve14 } from "node:path";
|
|
20567
20191
|
var ActivationSessionFileMissingError = class extends Error {
|
|
20568
20192
|
code = "AK_ACTIVATION_SESSION_FILE_MISSING";
|
|
20569
20193
|
path;
|
|
@@ -20603,12 +20227,12 @@ function durableSessionPointer(sessionManager) {
|
|
|
20603
20227
|
"Workflow role activation requires a durable Pi session file principal (getSessionFile); directory-only or --no-session invocations are rejected"
|
|
20604
20228
|
);
|
|
20605
20229
|
}
|
|
20606
|
-
if (!
|
|
20230
|
+
if (!isAbsolute10(file)) {
|
|
20607
20231
|
throw new Error(
|
|
20608
20232
|
`Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
|
|
20609
20233
|
);
|
|
20610
20234
|
}
|
|
20611
|
-
const resolvedFile =
|
|
20235
|
+
const resolvedFile = resolve14(file);
|
|
20612
20236
|
try {
|
|
20613
20237
|
lstatSync2(resolvedFile);
|
|
20614
20238
|
} catch (error) {
|
|
@@ -20691,10 +20315,10 @@ init_engine_material();
|
|
|
20691
20315
|
init_engine_detour();
|
|
20692
20316
|
init_engine_detour_usage();
|
|
20693
20317
|
init_run_terminal_artifacts();
|
|
20694
|
-
import { Type as
|
|
20695
|
-
var engineDetourArgsSchema =
|
|
20318
|
+
import { Type as Type18 } from "typebox";
|
|
20319
|
+
var engineDetourArgsSchema = Type18.Object(
|
|
20696
20320
|
{
|
|
20697
|
-
argv:
|
|
20321
|
+
argv: Type18.Array(Type18.String({ minLength: 1 }), {
|
|
20698
20322
|
minItems: 1,
|
|
20699
20323
|
description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
|
|
20700
20324
|
})
|
|
@@ -20852,7 +20476,7 @@ var COLLECTOR_TRANSPORT_FLAGS = Object.freeze([
|
|
|
20852
20476
|
Object.freeze({
|
|
20853
20477
|
name: "ak-collector-request-manifest",
|
|
20854
20478
|
definition: Object.freeze({
|
|
20855
|
-
description: "
|
|
20479
|
+
description: "Caller path to a request manifest JSON file (passed as-is; package does not read or validate).",
|
|
20856
20480
|
type: "string"
|
|
20857
20481
|
})
|
|
20858
20482
|
})
|
|
@@ -20863,19 +20487,9 @@ function buildMethodContext(activation) {
|
|
|
20863
20487
|
`host: github.com`,
|
|
20864
20488
|
`repository: ${activation.repository.canonical}`,
|
|
20865
20489
|
`prNumber: ${activation.prNumber === void 0 ? "\u672A\u7ED1\u5B9A" : String(activation.prNumber)}`,
|
|
20866
|
-
|
|
20867
|
-
`manifestDigest: ${activation.manifest.digest}`,
|
|
20490
|
+
...activation.requestManifestPath === void 0 ? [] : [`requestManifestPath: ${activation.requestManifestPath}`],
|
|
20868
20491
|
"</collector_method>"
|
|
20869
20492
|
];
|
|
20870
|
-
if (activation.manifest.requests.length > 0) {
|
|
20871
|
-
const payload = JSON.stringify({
|
|
20872
|
-
requests: activation.manifest.requests.map((request) => ({
|
|
20873
|
-
id: request.id,
|
|
20874
|
-
body: request.requestBody
|
|
20875
|
-
}))
|
|
20876
|
-
}).replaceAll("<", "\\u003c");
|
|
20877
|
-
lines.push("", "<collector_request_manifest>", payload, "</collector_request_manifest>");
|
|
20878
|
-
}
|
|
20879
20493
|
return lines.join("\n");
|
|
20880
20494
|
}
|
|
20881
20495
|
function createCollectorRoleRuntime(pi, dependencies) {
|
|
@@ -20897,12 +20511,12 @@ function createCollectorRoleRuntime(pi, dependencies) {
|
|
|
20897
20511
|
} else if (typeof prFlag === "number") {
|
|
20898
20512
|
prNumber = parseCollectorPrNumber(prFlag);
|
|
20899
20513
|
}
|
|
20900
|
-
const
|
|
20514
|
+
const requestManifestPath = typeof requestManifestFlag === "string" ? requestManifestFlag : void 0;
|
|
20901
20515
|
return {
|
|
20902
20516
|
soul,
|
|
20903
20517
|
repository,
|
|
20904
20518
|
prNumber,
|
|
20905
|
-
|
|
20519
|
+
...requestManifestPath === void 0 ? {} : { requestManifestPath }
|
|
20906
20520
|
};
|
|
20907
20521
|
},
|
|
20908
20522
|
assembleMaterials(activation, baseSystemPrompt) {
|
|
@@ -21189,19 +20803,19 @@ var AUDITOR_TOOL_SPEC = roleSubmissionDeclaration("auditor");
|
|
|
21189
20803
|
init_navigator_invocation_identity();
|
|
21190
20804
|
init_packaged_role_registry();
|
|
21191
20805
|
init_activation_ledger_topology();
|
|
21192
|
-
import { resolve as
|
|
20806
|
+
import { resolve as resolve17 } from "node:path";
|
|
21193
20807
|
import "@earendil-works/pi-coding-agent";
|
|
21194
|
-
import { Type as
|
|
20808
|
+
import { Type as Type20 } from "typebox";
|
|
21195
20809
|
|
|
21196
20810
|
// src/navigator-public-session.ts
|
|
21197
20811
|
init_host_session_record();
|
|
21198
20812
|
import { existsSync as existsSync12 } from "node:fs";
|
|
21199
|
-
import { basename as
|
|
20813
|
+
import { basename as basename13 } from "node:path";
|
|
21200
20814
|
|
|
21201
20815
|
// src/navigator-session-contracts.ts
|
|
21202
20816
|
init_unknown_value();
|
|
21203
|
-
import { Type as
|
|
21204
|
-
import { Value as
|
|
20817
|
+
import { Type as Type19 } from "typebox";
|
|
20818
|
+
import { Value as Value2 } from "typebox/value";
|
|
21205
20819
|
var NAVIGATOR_PREPARE_TOOL_NAME = "ak_navigator_prepare";
|
|
21206
20820
|
var NAVIGATOR_UNAVAILABLE_KEYS = /* @__PURE__ */ new Set([
|
|
21207
20821
|
"context",
|
|
@@ -21305,26 +20919,26 @@ function navigatorProviderFailureFromPublicTerminal(outcome) {
|
|
|
21305
20919
|
if (typed !== void 0) return { source: typed, cause: typed };
|
|
21306
20920
|
return { source: "unknown", cause: "unknown" };
|
|
21307
20921
|
}
|
|
21308
|
-
var navigatorProviderFailureSchema =
|
|
21309
|
-
source:
|
|
21310
|
-
|
|
21311
|
-
|
|
21312
|
-
|
|
21313
|
-
|
|
21314
|
-
|
|
21315
|
-
|
|
21316
|
-
|
|
21317
|
-
|
|
20922
|
+
var navigatorProviderFailureSchema = Type19.Object({
|
|
20923
|
+
source: Type19.Union([
|
|
20924
|
+
Type19.Literal("context"),
|
|
20925
|
+
Type19.Literal("session"),
|
|
20926
|
+
Type19.Literal("model"),
|
|
20927
|
+
Type19.Literal("thinking"),
|
|
20928
|
+
Type19.Literal("auth"),
|
|
20929
|
+
Type19.Literal("quota"),
|
|
20930
|
+
Type19.Literal("transport"),
|
|
20931
|
+
Type19.Literal("unknown")
|
|
21318
20932
|
]),
|
|
21319
|
-
cause:
|
|
21320
|
-
|
|
21321
|
-
|
|
21322
|
-
|
|
21323
|
-
|
|
21324
|
-
|
|
21325
|
-
|
|
21326
|
-
|
|
21327
|
-
|
|
20933
|
+
cause: Type19.Union([
|
|
20934
|
+
Type19.Literal("context"),
|
|
20935
|
+
Type19.Literal("session"),
|
|
20936
|
+
Type19.Literal("model"),
|
|
20937
|
+
Type19.Literal("thinking"),
|
|
20938
|
+
Type19.Literal("auth"),
|
|
20939
|
+
Type19.Literal("quota"),
|
|
20940
|
+
Type19.Literal("transport"),
|
|
20941
|
+
Type19.Literal("unknown")
|
|
21328
20942
|
])
|
|
21329
20943
|
}, { additionalProperties: false });
|
|
21330
20944
|
function parseNavigatorModelSetting(value) {
|
|
@@ -21390,18 +21004,18 @@ init_packaged_role_registry();
|
|
|
21390
21004
|
init_atomic_write();
|
|
21391
21005
|
init_unknown_value();
|
|
21392
21006
|
import { existsSync as existsSync9, realpathSync as realpathSync3 } from "node:fs";
|
|
21393
|
-
import { readFile as
|
|
21394
|
-
import { basename as
|
|
21007
|
+
import { readFile as readFile15 } from "node:fs/promises";
|
|
21008
|
+
import { basename as basename12, dirname as dirname18, join as join30, resolve as resolve15 } from "node:path";
|
|
21395
21009
|
var NAVIGATOR_WORK_CONTEXT_BASENAME = "work-context.json";
|
|
21396
21010
|
function navigatorWorkContextFile(sessionDir) {
|
|
21397
|
-
return
|
|
21011
|
+
return join30(sessionDir, NAVIGATOR_WORK_CONTEXT_BASENAME);
|
|
21398
21012
|
}
|
|
21399
21013
|
function isNavigatorWorkContextFile(path) {
|
|
21400
|
-
const resolved =
|
|
21401
|
-
if (
|
|
21014
|
+
const resolved = resolve15(path);
|
|
21015
|
+
if (basename12(resolved) !== NAVIGATOR_WORK_CONTEXT_BASENAME) return false;
|
|
21402
21016
|
const nest = dirname18(resolved);
|
|
21403
|
-
if (!/^[0-9a-f]{32}$/.test(
|
|
21404
|
-
return
|
|
21017
|
+
if (!/^[0-9a-f]{32}$/.test(basename12(nest))) return false;
|
|
21018
|
+
return basename12(dirname18(nest)) === "navigator";
|
|
21405
21019
|
}
|
|
21406
21020
|
function canonicalNavigatorWorkContextFile(path) {
|
|
21407
21021
|
if (!isNavigatorWorkContextFile(path)) return void 0;
|
|
@@ -21419,7 +21033,7 @@ async function persistNavigatorWorkBase(sessionDir, body) {
|
|
|
21419
21033
|
const next = `${JSON.stringify({ subject: body.subject, authority: body.authority })}
|
|
21420
21034
|
`;
|
|
21421
21035
|
try {
|
|
21422
|
-
const current = await
|
|
21036
|
+
const current = await readFile15(path, "utf8");
|
|
21423
21037
|
if (current === next) return path;
|
|
21424
21038
|
} catch (error) {
|
|
21425
21039
|
if (!isEnoent(error)) throw error;
|
|
@@ -21432,7 +21046,7 @@ async function readNavigatorWorkBase(path) {
|
|
|
21432
21046
|
if (canonical === void 0) return void 0;
|
|
21433
21047
|
let text;
|
|
21434
21048
|
try {
|
|
21435
|
-
text = await
|
|
21049
|
+
text = await readFile15(canonical, "utf8");
|
|
21436
21050
|
} catch (error) {
|
|
21437
21051
|
if (isEnoent(error)) return void 0;
|
|
21438
21052
|
throw error;
|
|
@@ -21506,7 +21120,7 @@ async function resolveNavigatorLedgerHome(context) {
|
|
|
21506
21120
|
}
|
|
21507
21121
|
var NAVIGATOR_HOST_RUN_POINTER_ENTRY = "ak-navigator-host-run";
|
|
21508
21122
|
function runIdFromNavigatorDirectory(runDirectory) {
|
|
21509
|
-
const parsed = parseRunLeaf(
|
|
21123
|
+
const parsed = parseRunLeaf(basename13(runDirectory));
|
|
21510
21124
|
if (parsed === void 0 || parsed.role !== "navigator") return void 0;
|
|
21511
21125
|
return parsed.runId;
|
|
21512
21126
|
}
|
|
@@ -21702,8 +21316,8 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
|
|
|
21702
21316
|
return void 0;
|
|
21703
21317
|
}
|
|
21704
21318
|
var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
|
|
21705
|
-
var prepareSchema =
|
|
21706
|
-
prose:
|
|
21319
|
+
var prepareSchema = Type20.Object({
|
|
21320
|
+
prose: Type20.Optional(Type20.Unknown({
|
|
21707
21321
|
description: "\u6E38\u5955\u4F7F\u6563\u6587\u5EFA\u8BAE\uFF0C\u539F\u6837\u5448\u73B0\u3002\u4E0D\u8981\u6C42 candidates/next \u7ED3\u6784\u3002"
|
|
21708
21322
|
}))
|
|
21709
21323
|
}, { additionalProperties: true });
|
|
@@ -21743,7 +21357,7 @@ function navigatorSubjectKey(subjectRoot, subject, provenance = "role_input") {
|
|
|
21743
21357
|
}
|
|
21744
21358
|
function navigatorSubjectKeyForInput(subjectRoot, reference, cwd = process.cwd()) {
|
|
21745
21359
|
if (issueRoot(subjectRoot) !== void 0 || !subjectRoot.includes("/.ak/work/")) return subjectRoot;
|
|
21746
|
-
const resolvedReference =
|
|
21360
|
+
const resolvedReference = resolve17(cwd, reference);
|
|
21747
21361
|
const marker = "/runs/";
|
|
21748
21362
|
if (resolvedReference.includes(marker)) {
|
|
21749
21363
|
return subjectRoot;
|
|
@@ -22175,7 +21789,6 @@ init_worker_output();
|
|
|
22175
21789
|
init_fixer_output();
|
|
22176
21790
|
init_filed_submission();
|
|
22177
21791
|
init_role_submission_declarations();
|
|
22178
|
-
init_fixer_packet();
|
|
22179
21792
|
|
|
22180
21793
|
// src/worker-submission-gates.ts
|
|
22181
21794
|
init_archivist_record_entry();
|
|
@@ -22188,7 +21801,7 @@ init_submission_errors();
|
|
|
22188
21801
|
init_worker_submission_contracts();
|
|
22189
21802
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
22190
21803
|
import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync3 } from "node:fs";
|
|
22191
|
-
import { resolve as
|
|
21804
|
+
import { resolve as resolve18 } from "node:path";
|
|
22192
21805
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
22193
21806
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
22194
21807
|
var WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE = "commit-reminder-bounce";
|
|
@@ -22236,7 +21849,7 @@ function escapeGitConfigValueRegex(value) {
|
|
|
22236
21849
|
function unsetOwnedHooksPath(file) {
|
|
22237
21850
|
const owned = [];
|
|
22238
21851
|
for (const value of tryGetAll(file, "core.hooksPath")) {
|
|
22239
|
-
if (!ownedHook(
|
|
21852
|
+
if (!ownedHook(resolve18(value, HOOK_FILE))) continue;
|
|
22240
21853
|
try {
|
|
22241
21854
|
gitFile(file, [
|
|
22242
21855
|
"--unset-all",
|
|
@@ -22251,15 +21864,15 @@ function unsetOwnedHooksPath(file) {
|
|
|
22251
21864
|
return owned;
|
|
22252
21865
|
}
|
|
22253
21866
|
function rmOwnedDir(dir) {
|
|
22254
|
-
const hookPath =
|
|
21867
|
+
const hookPath = resolve18(dir, HOOK_FILE);
|
|
22255
21868
|
if (!ownedHook(hookPath)) return;
|
|
22256
21869
|
rmSync3(hookPath, { force: true });
|
|
22257
21870
|
if (existsSync13(dir) && readdirSync4(dir).length === 0) rmdirSync(dir);
|
|
22258
21871
|
}
|
|
22259
21872
|
function linkedGitDirs(commonDir) {
|
|
22260
|
-
const root =
|
|
21873
|
+
const root = resolve18(commonDir, "worktrees");
|
|
22261
21874
|
if (!existsSync13(root)) return [];
|
|
22262
|
-
return readdirSync4(root).map((name) =>
|
|
21875
|
+
return readdirSync4(root).map((name) => resolve18(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
22263
21876
|
}
|
|
22264
21877
|
function uninstallPackageWorkerHooks(cwd) {
|
|
22265
21878
|
let inside;
|
|
@@ -22273,14 +21886,14 @@ function uninstallPackageWorkerHooks(cwd) {
|
|
|
22273
21886
|
const clear = (configFile) => {
|
|
22274
21887
|
for (const hooks of unsetOwnedHooksPath(configFile)) rmOwnedDir(hooks);
|
|
22275
21888
|
};
|
|
22276
|
-
clear(
|
|
22277
|
-
clear(
|
|
22278
|
-
rmOwnedDir(
|
|
22279
|
-
const legacy =
|
|
21889
|
+
clear(resolve18(commonDir, "config"));
|
|
21890
|
+
clear(resolve18(commonDir, "config.worktree"));
|
|
21891
|
+
rmOwnedDir(resolve18(commonDir, HOOKS_DIR));
|
|
21892
|
+
const legacy = resolve18(commonDir, "hooks", HOOK_FILE);
|
|
22280
21893
|
if (ownedHook(legacy)) rmSync3(legacy, { force: true });
|
|
22281
21894
|
for (const gitDir of linkedGitDirs(commonDir)) {
|
|
22282
|
-
clear(
|
|
22283
|
-
rmOwnedDir(
|
|
21895
|
+
clear(resolve18(gitDir, "config.worktree"));
|
|
21896
|
+
rmOwnedDir(resolve18(gitDir, HOOKS_DIR));
|
|
22284
21897
|
}
|
|
22285
21898
|
}
|
|
22286
21899
|
function containsWrittenReason(value) {
|
|
@@ -22465,20 +22078,6 @@ function fixerBashSeatbeltDenyReason(matched) {
|
|
|
22465
22078
|
init_unknown_value();
|
|
22466
22079
|
init_worker_output();
|
|
22467
22080
|
var FIXER_FLAG_DEFINITIONS = {
|
|
22468
|
-
packet: {
|
|
22469
|
-
name: "ak-fix-packet",
|
|
22470
|
-
definition: {
|
|
22471
|
-
description: "Path to opaque prose instructions for the Fixer",
|
|
22472
|
-
type: "string"
|
|
22473
|
-
}
|
|
22474
|
-
},
|
|
22475
|
-
prerequisites: {
|
|
22476
|
-
name: "ak-fixer-prerequisites",
|
|
22477
|
-
definition: {
|
|
22478
|
-
description: "Optional path to a JSON array of typed Fixer prerequisites",
|
|
22479
|
-
type: "string"
|
|
22480
|
-
}
|
|
22481
|
-
},
|
|
22482
22081
|
phase: {
|
|
22483
22082
|
name: "ak-fixer-phase",
|
|
22484
22083
|
definition: {
|
|
@@ -22537,22 +22136,11 @@ function assertAcceptableThroughHost(submissionGate, status, details, hostAction
|
|
|
22537
22136
|
}
|
|
22538
22137
|
function createFixerRoleRuntime(pi, dependencies, hostActions, options) {
|
|
22539
22138
|
let soul;
|
|
22540
|
-
let packet;
|
|
22541
|
-
let packetPath;
|
|
22542
|
-
let prerequisitesPath;
|
|
22543
22139
|
let phase;
|
|
22544
22140
|
let lifecycleRegistered = false;
|
|
22545
22141
|
const submissionGate = createWorkerSubmissionGate({
|
|
22546
22142
|
unfinishedReasonBounceLimit: options?.unfinishedReasonBounceLimit ?? deliveryLimitFromEnv(process.env)
|
|
22547
22143
|
});
|
|
22548
|
-
pi.registerFlag(
|
|
22549
|
-
FIXER_FLAG_DEFINITIONS.packet.name,
|
|
22550
|
-
FIXER_FLAG_DEFINITIONS.packet.definition
|
|
22551
|
-
);
|
|
22552
|
-
pi.registerFlag(
|
|
22553
|
-
FIXER_FLAG_DEFINITIONS.prerequisites.name,
|
|
22554
|
-
FIXER_FLAG_DEFINITIONS.prerequisites.definition
|
|
22555
|
-
);
|
|
22556
22144
|
pi.registerFlag(
|
|
22557
22145
|
FIXER_FLAG_DEFINITIONS.phase.name,
|
|
22558
22146
|
FIXER_FLAG_DEFINITIONS.phase.definition
|
|
@@ -22568,29 +22156,11 @@ function createFixerRoleRuntime(pi, dependencies, hostActions, options) {
|
|
|
22568
22156
|
);
|
|
22569
22157
|
}
|
|
22570
22158
|
phase = selectedPhase;
|
|
22571
|
-
const resolvedPacketPath = pi.getFlag(FIXER_FLAG_DEFINITIONS.packet.name);
|
|
22572
|
-
if (typeof resolvedPacketPath !== "string" || resolvedPacketPath.trim().length === 0) {
|
|
22573
|
-
throw new Error("Fixer role requires --ak-fix-packet");
|
|
22574
|
-
}
|
|
22575
|
-
packetPath = resolvedPacketPath;
|
|
22576
|
-
const instructions = await dependencies.loadPacket(packetPath);
|
|
22577
|
-
if (instructions.trim().length === 0) {
|
|
22578
|
-
throw new FixerPacketValidationError(
|
|
22579
|
-
new Error("Fixer instructions must be nonblank")
|
|
22580
|
-
);
|
|
22581
|
-
}
|
|
22582
|
-
const resolvedPrerequisitesPath = pi.getFlag(FIXER_FLAG_DEFINITIONS.prerequisites.name);
|
|
22583
|
-
if (resolvedPrerequisitesPath !== void 0 && (typeof resolvedPrerequisitesPath !== "string" || resolvedPrerequisitesPath.trim().length === 0)) {
|
|
22584
|
-
throw new Error("Fixer --ak-fixer-prerequisites path must be nonblank when supplied");
|
|
22585
|
-
}
|
|
22586
|
-
prerequisitesPath = typeof resolvedPrerequisitesPath === "string" ? resolvedPrerequisitesPath : void 0;
|
|
22587
|
-
const prerequisites = prerequisitesPath !== void 0 ? parseFixerPrerequisites(await dependencies.loadPacket(prerequisitesPath)) : Object.freeze([]);
|
|
22588
|
-
packet = Object.freeze({ instructions, prerequisites });
|
|
22589
22159
|
if (!lifecycleRegistered) {
|
|
22590
22160
|
lifecycleRegistered = true;
|
|
22591
22161
|
registerWorkerSubmission(pi, "fixer", {
|
|
22592
|
-
notReady: "\u4FEE\u5185\u53F8\
|
|
22593
|
-
ready: () =>
|
|
22162
|
+
notReady: "\u4FEE\u5185\u53F8\u9636\u6BB5\u672A\u88C5\u8F7D",
|
|
22163
|
+
ready: () => phase !== void 0,
|
|
22594
22164
|
phase: () => phase,
|
|
22595
22165
|
project: (parameters, current) => deepFreeze2(validateFixerOutput(parameters, current)),
|
|
22596
22166
|
submissionGate,
|
|
@@ -22609,12 +22179,6 @@ function createFixerRoleRuntime(pi, dependencies, hostActions, options) {
|
|
|
22609
22179
|
});
|
|
22610
22180
|
pi.on("before_agent_start", (event) => {
|
|
22611
22181
|
if (soul === void 0) throw new Error("\u4FEE\u5185\u53F8\u804C\u5206\u672A\u88C5\u8F7D");
|
|
22612
|
-
if (packetPath === void 0) throw new Error("\u4FEE\u5185\u53F8\u4FEE\u7406\u5305\u8DEF\u5F84\u672A\u88C5\u8F7D");
|
|
22613
|
-
const prerequisitesBlock = prerequisitesPath === void 0 ? "" : `
|
|
22614
|
-
|
|
22615
|
-
<fixer_prerequisites_path>
|
|
22616
|
-
${prerequisitesPath}
|
|
22617
|
-
</fixer_prerequisites_path>`;
|
|
22618
22182
|
return {
|
|
22619
22183
|
systemPrompt: `${event.systemPrompt}
|
|
22620
22184
|
|
|
@@ -22624,11 +22188,7 @@ ${soul}
|
|
|
22624
22188
|
|
|
22625
22189
|
<fixer_phase>
|
|
22626
22190
|
${phase ?? ""}
|
|
22627
|
-
</fixer_phase
|
|
22628
|
-
|
|
22629
|
-
<fix_packet_path>
|
|
22630
|
-
${packetPath}
|
|
22631
|
-
</fix_packet_path>${prerequisitesBlock}`
|
|
22191
|
+
</fixer_phase>`
|
|
22632
22192
|
};
|
|
22633
22193
|
});
|
|
22634
22194
|
}
|
|
@@ -22640,22 +22200,17 @@ ${packetPath}
|
|
|
22640
22200
|
}
|
|
22641
22201
|
function createCoderRoleRuntime(pi, dependencies, hostActions, options) {
|
|
22642
22202
|
let soul;
|
|
22643
|
-
let task;
|
|
22644
22203
|
let phase;
|
|
22645
22204
|
let lifecycleRegistered = false;
|
|
22646
22205
|
const submissionGate = createWorkerSubmissionGate({
|
|
22647
22206
|
unfinishedReasonBounceLimit: options?.unfinishedReasonBounceLimit ?? deliveryLimitFromEnv(process.env)
|
|
22648
22207
|
});
|
|
22649
|
-
pi.registerFlag("ak-coder-task", {
|
|
22650
|
-
description: "Markdown task assigned to the coder role",
|
|
22651
|
-
type: "string"
|
|
22652
|
-
});
|
|
22653
22208
|
pi.registerFlag("ak-coder-phase", {
|
|
22654
22209
|
description: "Coder phase: plan (inspect and propose an implementation plan; no edits or commits) or apply (execute the approved plan and verify the first implementation)",
|
|
22655
22210
|
type: "string"
|
|
22656
22211
|
});
|
|
22657
22212
|
return {
|
|
22658
|
-
async activate(
|
|
22213
|
+
async activate() {
|
|
22659
22214
|
soul = (await dependencies.loadSoul()).trim();
|
|
22660
22215
|
if (soul.length === 0) throw new Error("Coder soul is empty");
|
|
22661
22216
|
const selectedPhase = pi.getFlag("ak-coder-phase");
|
|
@@ -22665,23 +22220,17 @@ function createCoderRoleRuntime(pi, dependencies, hostActions, options) {
|
|
|
22665
22220
|
);
|
|
22666
22221
|
}
|
|
22667
22222
|
phase = selectedPhase;
|
|
22668
|
-
const taskPath = pi.getFlag("ak-coder-task");
|
|
22669
|
-
if (typeof taskPath !== "string" || taskPath.trim().length === 0) {
|
|
22670
|
-
throw new Error("Coder role requires --ak-coder-task");
|
|
22671
|
-
}
|
|
22672
|
-
task = (await dependencies.loadTask(taskPath)).trim();
|
|
22673
|
-
if (task.length === 0) throw new Error("Coder task is empty");
|
|
22674
22223
|
if (!lifecycleRegistered) {
|
|
22675
22224
|
lifecycleRegistered = true;
|
|
22676
22225
|
registerWorkerSubmission(pi, "coder", {
|
|
22677
|
-
notReady: "\u5C06\u4F5C\u76D1\
|
|
22678
|
-
ready: () =>
|
|
22226
|
+
notReady: "\u5C06\u4F5C\u76D1\u9636\u6BB5\u672A\u88C5\u8F7D",
|
|
22227
|
+
ready: () => phase !== void 0,
|
|
22679
22228
|
phase: () => phase,
|
|
22680
22229
|
project: (parameters, current) => validateWorkerOutput(parameters, current, "Coder"),
|
|
22681
22230
|
submissionGate,
|
|
22682
22231
|
hostActions
|
|
22683
22232
|
});
|
|
22684
|
-
pi.on("before_agent_start", (event
|
|
22233
|
+
pi.on("before_agent_start", (event) => {
|
|
22685
22234
|
if (soul === void 0) throw new Error("\u5C06\u4F5C\u76D1\u804C\u5206\u672A\u88C5\u8F7D");
|
|
22686
22235
|
return {
|
|
22687
22236
|
systemPrompt: `${event.systemPrompt}
|
|
@@ -22692,11 +22241,7 @@ ${soul}
|
|
|
22692
22241
|
|
|
22693
22242
|
<coder_phase>
|
|
22694
22243
|
${phase ?? ""}
|
|
22695
|
-
</coder_phase
|
|
22696
|
-
|
|
22697
|
-
<coder_task>
|
|
22698
|
-
${task ?? ""}
|
|
22699
|
-
</coder_task>`
|
|
22244
|
+
</coder_phase>`
|
|
22700
22245
|
};
|
|
22701
22246
|
});
|
|
22702
22247
|
}
|
|
@@ -22741,7 +22286,16 @@ function createMergerRoleRuntime(pi, dependencies) {
|
|
|
22741
22286
|
});
|
|
22742
22287
|
pi.on("before_agent_start", (event) => {
|
|
22743
22288
|
if (!activation) throw new Error("\u6821\u4E66\u90CE\u672A\u6FC0\u6D3B");
|
|
22744
|
-
const admitted = {
|
|
22289
|
+
const admitted = {
|
|
22290
|
+
attemptId: activation.input.attemptId,
|
|
22291
|
+
targetObjectId: activation.input.targetObjectId,
|
|
22292
|
+
sourceObjectId: activation.input.sourceObjectId,
|
|
22293
|
+
targetIntent: materialText(activation.input, "targetIntent"),
|
|
22294
|
+
sourceIntent: materialText(activation.input, "sourceIntent"),
|
|
22295
|
+
expectedConflictPaths: activation.input.expectedConflictPaths,
|
|
22296
|
+
resolutionScope: activation.input.resolutionScope,
|
|
22297
|
+
authorizedChecks: activation.input.authorizedChecks
|
|
22298
|
+
};
|
|
22745
22299
|
return { systemPrompt: `${event.systemPrompt}
|
|
22746
22300
|
|
|
22747
22301
|
<merger_soul>
|
|
@@ -22772,7 +22326,6 @@ init_doctor_evidence();
|
|
|
22772
22326
|
init_judge_role();
|
|
22773
22327
|
init_engine_detour();
|
|
22774
22328
|
init_fixer_output();
|
|
22775
|
-
init_fixer_packet();
|
|
22776
22329
|
init_auditor_soul();
|
|
22777
22330
|
init_judge_auditor();
|
|
22778
22331
|
init_doctor_auditor();
|
|
@@ -22884,7 +22437,7 @@ function activationStage(role, activate) {
|
|
|
22884
22437
|
};
|
|
22885
22438
|
}
|
|
22886
22439
|
function validateActivationTraceRecord(record) {
|
|
22887
|
-
if (!
|
|
22440
|
+
if (!Value3.Check(activationTraceRecordSchema, record)) {
|
|
22888
22441
|
throw new TypeError("Activation trace record does not match its closed contract");
|
|
22889
22442
|
}
|
|
22890
22443
|
return record;
|
|
@@ -23152,7 +22705,7 @@ function readRoleRunCoordinates(ctx, label) {
|
|
|
23152
22705
|
if (runDirectory === void 0) throw new Error(`${label} requires AK_ROLE_RUN_DIR`);
|
|
23153
22706
|
const admitted = readPageSync(runDirectory, "admitted");
|
|
23154
22707
|
if (typeof admitted?.projectRoot !== "string" || admitted.projectRoot.trim() === "") {
|
|
23155
|
-
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${
|
|
22708
|
+
throw new Error(`${label} state.jsonl admitted-request row missing projectRoot (${join34(runDirectory, RUN_STATE_FILE)})`);
|
|
23156
22709
|
}
|
|
23157
22710
|
return {
|
|
23158
22711
|
runDirectory,
|
|
@@ -23667,13 +23220,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23667
23220
|
const fixer = createFixerRoleRuntime(
|
|
23668
23221
|
roleHost,
|
|
23669
23222
|
{
|
|
23670
|
-
loadSoul: () => requireRoleSoul("fixer")
|
|
23671
|
-
async loadPacket(path) {
|
|
23672
|
-
if (dependencies.loadFixPacket === void 0) {
|
|
23673
|
-
throw new Error("Fixer packet loader is not configured");
|
|
23674
|
-
}
|
|
23675
|
-
return dependencies.loadFixPacket(path);
|
|
23676
|
-
}
|
|
23223
|
+
loadSoul: () => requireRoleSoul("fixer")
|
|
23677
23224
|
},
|
|
23678
23225
|
hostActions,
|
|
23679
23226
|
{ unfinishedReasonBounceLimit: deliveryLimit }
|
|
@@ -23681,13 +23228,7 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23681
23228
|
const coder = createCoderRoleRuntime(
|
|
23682
23229
|
roleHost,
|
|
23683
23230
|
{
|
|
23684
|
-
loadSoul: () => requireRoleSoul("coder")
|
|
23685
|
-
async loadTask(path) {
|
|
23686
|
-
if (dependencies.loadCoderTask === void 0) {
|
|
23687
|
-
throw new Error("Coder task loader is not configured");
|
|
23688
|
-
}
|
|
23689
|
-
return dependencies.loadCoderTask(path);
|
|
23690
|
-
}
|
|
23231
|
+
loadSoul: () => requireRoleSoul("coder")
|
|
23691
23232
|
},
|
|
23692
23233
|
hostActions,
|
|
23693
23234
|
{ unfinishedReasonBounceLimit: deliveryLimit }
|
|
@@ -23991,11 +23532,11 @@ init_settlement();
|
|
|
23991
23532
|
init_run_lifecycle();
|
|
23992
23533
|
init_unknown_value();
|
|
23993
23534
|
async function listen(server, path) {
|
|
23994
|
-
await new Promise((
|
|
23535
|
+
await new Promise((resolve21, reject) => {
|
|
23995
23536
|
server.once("error", reject);
|
|
23996
23537
|
server.listen(path, () => {
|
|
23997
23538
|
server.off("error", reject);
|
|
23998
|
-
|
|
23539
|
+
resolve21();
|
|
23999
23540
|
});
|
|
24000
23541
|
});
|
|
24001
23542
|
}
|
|
@@ -24420,8 +23961,8 @@ async function prepareRoleEnvelope(options) {
|
|
|
24420
23961
|
try {
|
|
24421
23962
|
const closeAll = server.closeAllConnections;
|
|
24422
23963
|
if (typeof closeAll === "function") closeAll.call(server);
|
|
24423
|
-
await new Promise((
|
|
24424
|
-
server.close((error) => error ? reject(error) :
|
|
23964
|
+
await new Promise((resolve21, reject) => {
|
|
23965
|
+
server.close((error) => error ? reject(error) : resolve21());
|
|
24425
23966
|
});
|
|
24426
23967
|
} catch (error) {
|
|
24427
23968
|
await retainPackageFault({
|
|
@@ -24554,7 +24095,7 @@ async function prepareRoleEnvelope(options) {
|
|
|
24554
24095
|
}
|
|
24555
24096
|
|
|
24556
24097
|
// src/role-runtime-dependencies.ts
|
|
24557
|
-
import { readFile as
|
|
24098
|
+
import { readFile as readFile17 } from "node:fs/promises";
|
|
24558
24099
|
init_doctor_evidence();
|
|
24559
24100
|
|
|
24560
24101
|
// src/navigator-work-context.ts
|
|
@@ -24562,8 +24103,8 @@ init_role_run_placement();
|
|
|
24562
24103
|
init_doctor_evidence();
|
|
24563
24104
|
init_unknown_value();
|
|
24564
24105
|
init_host_contracts();
|
|
24565
|
-
import { readFile as
|
|
24566
|
-
import { resolve as
|
|
24106
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
24107
|
+
import { resolve as resolve19 } from "node:path";
|
|
24567
24108
|
init_notary_source_run();
|
|
24568
24109
|
init_packaged_role_registry();
|
|
24569
24110
|
init_invocation();
|
|
@@ -24571,12 +24112,12 @@ function navigatorInputReference(getFlag, role) {
|
|
|
24571
24112
|
if (getFlag === void 0) return void 0;
|
|
24572
24113
|
const name = packagedRoleInputFlag(role);
|
|
24573
24114
|
const value = name === void 0 ? void 0 : getFlag(name);
|
|
24574
|
-
return typeof value === "string" && value !== "" ?
|
|
24115
|
+
return typeof value === "string" && value !== "" ? resolve19(value) : void 0;
|
|
24575
24116
|
}
|
|
24576
24117
|
async function loadNavigatorWorkContext(options) {
|
|
24577
24118
|
const reference = navigatorInputReference(options.getFlag, options.role);
|
|
24578
24119
|
const subjectMode = packagedNavigatorSubject(options.role);
|
|
24579
|
-
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await
|
|
24120
|
+
const input = reference === void 0 || subjectMode === "case" || subjectMode === "source-run" ? void 0 : await readFile16(reference, "utf8");
|
|
24580
24121
|
const subjectRoot = subjectPath(reference ?? options.context.sessionManager.getSessionDir(), options.context.cwd);
|
|
24581
24122
|
let subjectKey = reference === void 0 ? subjectRoot : navigatorSubjectKeyForInput(subjectRoot, reference, options.context.cwd);
|
|
24582
24123
|
let subject = input ?? `work subject: ${subjectKey}`;
|
|
@@ -24593,7 +24134,7 @@ async function loadNavigatorWorkContext(options) {
|
|
|
24593
24134
|
}
|
|
24594
24135
|
const publicRunDir = runDirectoryFromHostContext(options.context);
|
|
24595
24136
|
const currentSessionDir = options.context.sessionManager.getSessionDir();
|
|
24596
|
-
const isBoundPublicRun = publicRunDir !== void 0 &&
|
|
24137
|
+
const isBoundPublicRun = publicRunDir !== void 0 && resolve19(currentSessionDir) === resolve19(sessionDirectoryOf(publicRunDir));
|
|
24597
24138
|
if (subjectMode === "public-instruction" && isBoundPublicRun) {
|
|
24598
24139
|
let admitted;
|
|
24599
24140
|
try {
|
|
@@ -24626,14 +24167,14 @@ async function loadNavigatorWorkContext(options) {
|
|
|
24626
24167
|
}
|
|
24627
24168
|
const workRoot = subjectRoot.includes("/.ak/work/") ? subjectRoot : void 0;
|
|
24628
24169
|
const authorityFiles = workRoot === void 0 ? [] : [
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24170
|
+
resolve19(workRoot, "authority.md"),
|
|
24171
|
+
resolve19(workRoot, "authority.txt"),
|
|
24172
|
+
resolve19(workRoot, "design-v2/owner-direction.md")
|
|
24632
24173
|
];
|
|
24633
24174
|
let authorityMaterial;
|
|
24634
24175
|
for (const path of authorityFiles) {
|
|
24635
24176
|
try {
|
|
24636
|
-
const content = await
|
|
24177
|
+
const content = await readFile16(path, "utf8");
|
|
24637
24178
|
if (content.trim() !== "") {
|
|
24638
24179
|
authorityMaterial = content;
|
|
24639
24180
|
break;
|
|
@@ -24675,11 +24216,9 @@ function createRoleRuntimeDependencies(packageRoot) {
|
|
|
24675
24216
|
packageRoot,
|
|
24676
24217
|
loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
|
|
24677
24218
|
loadRoleSoul: loadRegisteredRoleSoul,
|
|
24678
|
-
loadFixPacket: (path) => readFile18(path, "utf8"),
|
|
24679
|
-
loadCoderTask: (path) => readFile18(path, "utf8"),
|
|
24680
24219
|
loadDoctorCase,
|
|
24681
24220
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
24682
|
-
loadMergerInput: async (path) => JSON.parse(await
|
|
24221
|
+
loadMergerInput: async (path) => JSON.parse(await readFile17(path, "utf8")),
|
|
24683
24222
|
loadNavigatorWorkContext: (options) => loadNavigatorWorkContext({
|
|
24684
24223
|
context: options.context,
|
|
24685
24224
|
role: options.role,
|
|
@@ -24762,7 +24301,7 @@ function hostAbortedError(message = "host aborted") {
|
|
|
24762
24301
|
function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
24763
24302
|
if (abortSignal?.aborted) return Promise.reject(hostAbortedError(message));
|
|
24764
24303
|
if (abortSignal === void 0) return work;
|
|
24765
|
-
return new Promise((
|
|
24304
|
+
return new Promise((resolve21, reject) => {
|
|
24766
24305
|
let settled = false;
|
|
24767
24306
|
const onAbort = () => {
|
|
24768
24307
|
if (settled) return;
|
|
@@ -24777,7 +24316,7 @@ function raceAgainstHostAbort(work, abortSignal, message = "host aborted") {
|
|
|
24777
24316
|
if (settled) return;
|
|
24778
24317
|
settled = true;
|
|
24779
24318
|
abortSignal.removeEventListener("abort", onAbort);
|
|
24780
|
-
|
|
24319
|
+
resolve21(value);
|
|
24781
24320
|
},
|
|
24782
24321
|
(error) => {
|
|
24783
24322
|
if (settled) return;
|
|
@@ -25039,19 +24578,19 @@ function connectAcpStdio(options) {
|
|
|
25039
24578
|
terminate(error);
|
|
25040
24579
|
}
|
|
25041
24580
|
});
|
|
25042
|
-
const processClosed = new Promise((
|
|
24581
|
+
const processClosed = new Promise((resolve21) => {
|
|
25043
24582
|
child.once("close", (code, signal) => {
|
|
25044
24583
|
if (spawned) nativeExit = { code, timedOut: false, ...signal === null ? {} : { signal } };
|
|
25045
24584
|
settleClosed(acpError("acp-closed", "ACP process closed"));
|
|
25046
|
-
|
|
24585
|
+
resolve21();
|
|
25047
24586
|
});
|
|
25048
24587
|
});
|
|
25049
24588
|
return Promise.resolve({
|
|
25050
24589
|
request(method, params) {
|
|
25051
24590
|
if (closed) return Promise.reject(terminalError);
|
|
25052
24591
|
const id = ++nextId;
|
|
25053
|
-
return new Promise((
|
|
25054
|
-
pending.set(id, { resolve:
|
|
24592
|
+
return new Promise((resolve21, reject) => {
|
|
24593
|
+
pending.set(id, { resolve: resolve21, reject });
|
|
25055
24594
|
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
25056
24595
|
`, (error) => {
|
|
25057
24596
|
if (error === null || error === void 0) return;
|
|
@@ -25332,13 +24871,13 @@ function createAcpRoleTurnHost(config) {
|
|
|
25332
24871
|
|
|
25333
24872
|
// src/acp-host/seat-profile-soul.ts
|
|
25334
24873
|
import { constants as constants3 } from "node:fs";
|
|
25335
|
-
import { access as access3, copyFile, lstat as
|
|
25336
|
-
import { dirname as dirname22, join as
|
|
24874
|
+
import { access as access3, copyFile, lstat as lstat4, mkdir as mkdir4, readlink, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
|
|
24875
|
+
import { dirname as dirname22, join as join35, relative as relative3, resolve as resolve20 } from "node:path";
|
|
25337
24876
|
function seatProfileName(spec, role) {
|
|
25338
24877
|
return `${spec.namePrefix}${role}`;
|
|
25339
24878
|
}
|
|
25340
24879
|
function packageRoleSoulPath(packageRoot, role) {
|
|
25341
|
-
return
|
|
24880
|
+
return join35(packageRoot, "souls", `${role}.md`);
|
|
25342
24881
|
}
|
|
25343
24882
|
async function pathExists2(path) {
|
|
25344
24883
|
try {
|
|
@@ -25351,20 +24890,20 @@ async function pathExists2(path) {
|
|
|
25351
24890
|
async function ensureSeatProfileSoul(options) {
|
|
25352
24891
|
const { spec, operatorHome, packageRoot, role } = options;
|
|
25353
24892
|
const profileName = seatProfileName(spec, role);
|
|
25354
|
-
const soulTarget =
|
|
24893
|
+
const soulTarget = resolve20(packageRoleSoulPath(packageRoot, role));
|
|
25355
24894
|
if (!await pathExists2(soulTarget)) {
|
|
25356
24895
|
throw new Error(`packaged role soul missing: ${soulTarget}`);
|
|
25357
24896
|
}
|
|
25358
|
-
const profilesRoot =
|
|
25359
|
-
const profileDir =
|
|
24897
|
+
const profilesRoot = join35(operatorHome, ...spec.profilesRootFromHome);
|
|
24898
|
+
const profileDir = join35(profilesRoot, profileName);
|
|
25360
24899
|
const hostRoot = dirname22(profilesRoot);
|
|
25361
|
-
const soulPath =
|
|
24900
|
+
const soulPath = join35(profileDir, spec.soulFileName);
|
|
25362
24901
|
if (!await pathExists2(profileDir)) {
|
|
25363
24902
|
await mkdir4(profileDir, { recursive: true });
|
|
25364
24903
|
for (const name of ["auth.json", ".env", "config.yaml"]) {
|
|
25365
|
-
const source =
|
|
24904
|
+
const source = join35(hostRoot, name);
|
|
25366
24905
|
if (!await pathExists2(source)) continue;
|
|
25367
|
-
await copyFile(source,
|
|
24906
|
+
await copyFile(source, join35(profileDir, name));
|
|
25368
24907
|
}
|
|
25369
24908
|
} else {
|
|
25370
24909
|
await mkdir4(profileDir, { recursive: true });
|
|
@@ -25372,7 +24911,7 @@ async function ensureSeatProfileSoul(options) {
|
|
|
25372
24911
|
const desiredLink = relative3(profileDir, soulTarget);
|
|
25373
24912
|
let current;
|
|
25374
24913
|
try {
|
|
25375
|
-
const st = await
|
|
24914
|
+
const st = await lstat4(soulPath);
|
|
25376
24915
|
if (st.isSymbolicLink()) {
|
|
25377
24916
|
current = await readlink(soulPath);
|
|
25378
24917
|
}
|