@akagilnc/pi-workflow-roles 0.1.5575 → 0.1.5583
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/CLAUDE.md +1 -1
- package/dist/acp-host/production-host.js +115 -159
- package/dist/headless-host/production-host.js +42 -86
- package/dist/migrate-book-topology.js +0 -2
- package/dist/package-resources/engine-material.js +22 -25
- package/dist/public-cli/instruction-seat-run.js +3 -13
- package/dist/public-cli/invocation.js +6 -6
- package/dist/public-cli/main.js +115 -192
- package/dist/public-cli/post-admission.js +1 -8
- package/dist/public-cli/run-lifecycle.js +4 -7
- package/package.json +1 -1
- package/src/package-resources/engine-material.ts +42 -35
- package/src/public-cli/instruction-seat-run.ts +3 -19
- package/src/public-cli/invocation.ts +5 -9
- package/src/public-cli/post-admission.ts +1 -8
- package/src/public-cli/run-lifecycle.ts +4 -18
- package/src/role-runtime.ts +18 -16
package/CLAUDE.md
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
|
|
54
54
|
## 起居录位置(#1092)
|
|
55
55
|
|
|
56
|
-
本票记录在 `~/.ak-roles/books
|
|
56
|
+
本票记录在 `~/.ak-roles/books/<簿>/<票号>/`,没有票号的在 `~/.ak-roles/books/<簿>/unbound/`。各腿的记录在其下 `runs/<runId>@<席>/`。角色凭已知票号自行定位与读取;代码不计算、不冻结、不向提示或附件递送本票指针。
|
|
57
57
|
|
|
58
58
|
## 锚定宪法
|
|
59
59
|
|
|
@@ -5880,84 +5880,6 @@ var init_notary_source_run = __esm({
|
|
|
5880
5880
|
}
|
|
5881
5881
|
});
|
|
5882
5882
|
|
|
5883
|
-
// src/package-resources/engine-material.ts
|
|
5884
|
-
import { existsSync as existsSync3, readdirSync as readdirSync2 } from "node:fs";
|
|
5885
|
-
import { join as join11 } from "node:path";
|
|
5886
|
-
function pickEngineAxis(source) {
|
|
5887
|
-
return {
|
|
5888
|
-
...source.engine === void 0 ? {} : { engine: source.engine },
|
|
5889
|
-
...source.engineModel === void 0 ? {} : { engineModel: source.engineModel }
|
|
5890
|
-
};
|
|
5891
|
-
}
|
|
5892
|
-
function assertLegalEngineModel(model) {
|
|
5893
|
-
if (typeof model !== "string" || model.trim() === "" || model.trim() !== model) {
|
|
5894
|
-
throw new Error(`illegal engine model: ${JSON.stringify(model)}`);
|
|
5895
|
-
}
|
|
5896
|
-
return model;
|
|
5897
|
-
}
|
|
5898
|
-
function isEngineNameSyntax(name) {
|
|
5899
|
-
if (typeof name !== "string") return false;
|
|
5900
|
-
if (name.length === 0 || name.trim() !== name) return false;
|
|
5901
|
-
if (name === "." || name === "..") return false;
|
|
5902
|
-
if (name.includes("/") || name.includes("\\") || name.includes("\0")) return false;
|
|
5903
|
-
return true;
|
|
5904
|
-
}
|
|
5905
|
-
function resolveEngineMaterialDirectory(packageRoot) {
|
|
5906
|
-
return join11(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
5907
|
-
}
|
|
5908
|
-
function resolveEngineMaterialPath(packageRoot, name) {
|
|
5909
|
-
const legal = assertLegalEngineName(name);
|
|
5910
|
-
return join11(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
|
|
5911
|
-
}
|
|
5912
|
-
function assertLegalEngineName(name) {
|
|
5913
|
-
if (!isEngineNameSyntax(name)) {
|
|
5914
|
-
throw new Error(`illegal engine name: ${name}`);
|
|
5915
|
-
}
|
|
5916
|
-
return name;
|
|
5917
|
-
}
|
|
5918
|
-
function engineSessionMaterialFromOptions(options) {
|
|
5919
|
-
if (options.engine === void 0) return void 0;
|
|
5920
|
-
if (options.packageRoot === void 0 || options.packageRoot.trim() === "") {
|
|
5921
|
-
throw new Error("packageRoot is required when engine is configured");
|
|
5922
|
-
}
|
|
5923
|
-
const name = assertLegalEngineName(options.engine);
|
|
5924
|
-
const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
|
|
5925
|
-
const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
|
|
5926
|
-
const modelField = model === void 0 ? {} : { model };
|
|
5927
|
-
if (existsSync3(materialPath)) {
|
|
5928
|
-
return Object.freeze({ name, materialPath, ...modelField });
|
|
5929
|
-
}
|
|
5930
|
-
return Object.freeze({ name, ...modelField });
|
|
5931
|
-
}
|
|
5932
|
-
function appendEngineSessionMaterial(lines, engineMaterial) {
|
|
5933
|
-
if (engineMaterial === void 0) {
|
|
5934
|
-
return [...lines];
|
|
5935
|
-
}
|
|
5936
|
-
const out = [...lines];
|
|
5937
|
-
out.push("");
|
|
5938
|
-
if (engineMaterial.materialPath !== void 0) {
|
|
5939
|
-
out.push("\u672C\u6B21\u914D\u7F6E\u7684\u52B3\u52A1\u5F15\u64CE\u53CA\u5176\u624B\u518C\uFF1A");
|
|
5940
|
-
out.push(`- engine: ${engineMaterial.name}`);
|
|
5941
|
-
if (engineMaterial.model !== void 0) {
|
|
5942
|
-
out.push(`- engineModel: ${engineMaterial.model}`);
|
|
5943
|
-
}
|
|
5944
|
-
out.push(`- ${engineMaterial.materialPath}`);
|
|
5945
|
-
} else {
|
|
5946
|
-
out.push(`- engine: ${engineMaterial.name}`);
|
|
5947
|
-
if (engineMaterial.model !== void 0) {
|
|
5948
|
-
out.push(`- engineModel: ${engineMaterial.model}`);
|
|
5949
|
-
}
|
|
5950
|
-
}
|
|
5951
|
-
return out;
|
|
5952
|
-
}
|
|
5953
|
-
var ENGINE_MATERIAL_RELATIVE_ROOT;
|
|
5954
|
-
var init_engine_material = __esm({
|
|
5955
|
-
"src/package-resources/engine-material.ts"() {
|
|
5956
|
-
"use strict";
|
|
5957
|
-
ENGINE_MATERIAL_RELATIVE_ROOT = "resources/engines";
|
|
5958
|
-
}
|
|
5959
|
-
});
|
|
5960
|
-
|
|
5961
5883
|
// src/public-cli/registry.ts
|
|
5962
5884
|
var registry_exports = {};
|
|
5963
5885
|
__export(registry_exports, {
|
|
@@ -7068,7 +6990,7 @@ var init_option_definitions = __esm({
|
|
|
7068
6990
|
|
|
7069
6991
|
// src/public-cli/invocation.ts
|
|
7070
6992
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
7071
|
-
import { existsSync as
|
|
6993
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
7072
6994
|
import {
|
|
7073
6995
|
lstat as lstat2,
|
|
7074
6996
|
mkdtemp,
|
|
@@ -7079,7 +7001,7 @@ import {
|
|
|
7079
7001
|
writeFile
|
|
7080
7002
|
} from "node:fs/promises";
|
|
7081
7003
|
import { tmpdir } from "node:os";
|
|
7082
|
-
import { basename as basename8, dirname as dirname8, isAbsolute as isAbsolute5, join as
|
|
7004
|
+
import { basename as basename8, dirname as dirname8, isAbsolute as isAbsolute5, join as join11, resolve as resolve9 } from "node:path";
|
|
7083
7005
|
function issueAdmissionPlacement(authority, request) {
|
|
7084
7006
|
const ledgerHome = resolveActivationLedgerHome(request.home);
|
|
7085
7007
|
const bookKey = resolveBookKeyFromGit(request.cwd);
|
|
@@ -7222,8 +7144,8 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
7222
7144
|
const childRunIds = readPageSync(oldRunDirectory, "admitted")?.childDiaristRunIds;
|
|
7223
7145
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
7224
7146
|
if (typeof childRunId !== "string") continue;
|
|
7225
|
-
const childDirectory =
|
|
7226
|
-
if (!
|
|
7147
|
+
const childDirectory = join11(dirname8(oldRunDirectory), formatRunLeaf(childRunId, "diarist"));
|
|
7148
|
+
if (!existsSync3(childDirectory)) continue;
|
|
7227
7149
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
7228
7150
|
bookKey: admitted.bookKey,
|
|
7229
7151
|
subject: { ticketNumber: admitted.ticketNumber },
|
|
@@ -7307,7 +7229,7 @@ async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
|
7307
7229
|
async function observeLaunchedRolePackageIdentity(packageRoot, selectedRoleEntry) {
|
|
7308
7230
|
const rolePackageRoot = packageRoot;
|
|
7309
7231
|
const raw = JSON.parse(
|
|
7310
|
-
await readFile8(
|
|
7232
|
+
await readFile8(join11(rolePackageRoot, "package.json"), "utf8")
|
|
7311
7233
|
);
|
|
7312
7234
|
if (typeof raw.version !== "string" || raw.version.trim() === "") {
|
|
7313
7235
|
throw new Error(
|
|
@@ -7604,13 +7526,13 @@ async function removePreparedAttachmentDirectory(stagingDirectory) {
|
|
|
7604
7526
|
}
|
|
7605
7527
|
async function withPreparedAttachments(attachmentPaths, use) {
|
|
7606
7528
|
if (attachmentPaths.length === 0) return await use([]);
|
|
7607
|
-
const stagingDirectory = await mkdtemp(
|
|
7529
|
+
const stagingDirectory = await mkdtemp(join11(tmpdir(), "ak-role-attachments-"));
|
|
7608
7530
|
const prepared = [];
|
|
7609
7531
|
let result;
|
|
7610
7532
|
try {
|
|
7611
7533
|
for (let index = 0; index < attachmentPaths.length; index += 1) {
|
|
7612
7534
|
const { absolute, bytes } = await readRegularFileAttachment(attachmentPaths[index]);
|
|
7613
|
-
const snapshotPath =
|
|
7535
|
+
const snapshotPath = join11(stagingDirectory, String(index).padStart(6, "0"));
|
|
7614
7536
|
await writeFile(snapshotPath, bytes);
|
|
7615
7537
|
prepared.push({ absolute, snapshotPath });
|
|
7616
7538
|
}
|
|
@@ -7631,7 +7553,7 @@ async function withPreparedAttachments(attachmentPaths, use) {
|
|
|
7631
7553
|
return result;
|
|
7632
7554
|
}
|
|
7633
7555
|
async function freezeAttachmentBytes(provenancePath, bytes, destinationDir, index) {
|
|
7634
|
-
const frozenPath =
|
|
7556
|
+
const frozenPath = join11(
|
|
7635
7557
|
destinationDir,
|
|
7636
7558
|
`${String(index).padStart(2, "0")}-${basename8(provenancePath)}`
|
|
7637
7559
|
);
|
|
@@ -7677,14 +7599,14 @@ async function freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirecto
|
|
|
7677
7599
|
async function freezeAttachmentsIntoRun(attachmentPaths, runDirectory, summonsKey = `s-${Date.now().toString(36)}`) {
|
|
7678
7600
|
if (attachmentPaths.length === 0) return [];
|
|
7679
7601
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7680
|
-
const attachmentsDirectory =
|
|
7602
|
+
const attachmentsDirectory = join11(runDirectory, "attachments", summonsKey);
|
|
7681
7603
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7682
7604
|
return freezeAttachments(ledgerHome, attachmentPaths, attachmentsDirectory);
|
|
7683
7605
|
}
|
|
7684
7606
|
async function freezePreparedAttachmentsIntoRun(prepared, runDirectory, summonsKey) {
|
|
7685
7607
|
if (prepared.length === 0) return [];
|
|
7686
7608
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(runDirectory));
|
|
7687
|
-
const attachmentsDirectory = summonsKey === void 0 ?
|
|
7609
|
+
const attachmentsDirectory = summonsKey === void 0 ? join11(runDirectory, "attachments") : join11(runDirectory, "attachments", summonsKey);
|
|
7688
7610
|
ensureRealDirectoryTree(ledgerHome, attachmentsDirectory);
|
|
7689
7611
|
const attachments = [];
|
|
7690
7612
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
@@ -7761,7 +7683,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7761
7683
|
attachmentPaths,
|
|
7762
7684
|
...project,
|
|
7763
7685
|
placedFields: async (placed) => {
|
|
7764
|
-
const taskPath =
|
|
7686
|
+
const taskPath = join11(placed.runDirectory, "task.md");
|
|
7765
7687
|
await writeFile(taskPath, instruction, "utf8");
|
|
7766
7688
|
return { phase, taskPath };
|
|
7767
7689
|
}
|
|
@@ -7804,7 +7726,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7804
7726
|
placedFields: async (placed) => {
|
|
7805
7727
|
let prerequisitesPath;
|
|
7806
7728
|
if (prerequisitesSource !== void 0) {
|
|
7807
|
-
prerequisitesPath =
|
|
7729
|
+
prerequisitesPath = join11(placed.runDirectory, "prerequisites.json");
|
|
7808
7730
|
await writeFile(
|
|
7809
7731
|
prerequisitesPath,
|
|
7810
7732
|
`${JSON.stringify(prerequisites, null, 2)}
|
|
@@ -7812,7 +7734,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7812
7734
|
"utf8"
|
|
7813
7735
|
);
|
|
7814
7736
|
}
|
|
7815
|
-
const packetPath =
|
|
7737
|
+
const packetPath = join11(placed.runDirectory, "fix-packet.md");
|
|
7816
7738
|
await writeFile(packetPath, instruction, "utf8");
|
|
7817
7739
|
return {
|
|
7818
7740
|
phase,
|
|
@@ -7859,7 +7781,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
7859
7781
|
placedFields: async (placed) => {
|
|
7860
7782
|
let requestManifestPath;
|
|
7861
7783
|
if (manifestCanonicalJson !== void 0) {
|
|
7862
|
-
requestManifestPath =
|
|
7784
|
+
requestManifestPath = join11(placed.runDirectory, "request-manifest.json");
|
|
7863
7785
|
await writeFile(requestManifestPath, manifestCanonicalJson, "utf8");
|
|
7864
7786
|
}
|
|
7865
7787
|
return {
|
|
@@ -8045,7 +7967,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
8045
7967
|
resolutionScope: [...derived.resolutionScope],
|
|
8046
7968
|
authorizedChecks: []
|
|
8047
7969
|
});
|
|
8048
|
-
const mergerInputPath =
|
|
7970
|
+
const mergerInputPath = join11(placed.runDirectory, "merger-input.json");
|
|
8049
7971
|
await writeFile(
|
|
8050
7972
|
mergerInputPath,
|
|
8051
7973
|
`${JSON.stringify(mergerInput, null, 2)}
|
|
@@ -8189,13 +8111,13 @@ function admittedTransportPromptKind(admitted) {
|
|
|
8189
8111
|
if (record !== void 0 && "transportPrompt" in record) return record.transportPrompt;
|
|
8190
8112
|
return "instruction";
|
|
8191
8113
|
}
|
|
8192
|
-
function buildInstructionTransportPrompt(admitted
|
|
8114
|
+
function buildInstructionTransportPrompt(admitted) {
|
|
8193
8115
|
const kind = admittedTransportPromptKind(admitted);
|
|
8194
8116
|
if (kind === "fixed-kickoff") {
|
|
8195
8117
|
if (admitted.sourceRunPath === void 0 || admitted.sourceRunPath.trim() === "") {
|
|
8196
8118
|
throw new Error("fixed-kickoff transport prompt is missing the source run pointer");
|
|
8197
8119
|
}
|
|
8198
|
-
return
|
|
8120
|
+
return admitted.sourceRunPath;
|
|
8199
8121
|
}
|
|
8200
8122
|
if (kind === "baseline") {
|
|
8201
8123
|
if (admitted.baseRevision === void 0) {
|
|
@@ -8205,7 +8127,7 @@ function buildInstructionTransportPrompt(admitted, engineMaterial) {
|
|
|
8205
8127
|
if (!admitted.instructionEmpty) {
|
|
8206
8128
|
lines2.push("", admitted.instruction);
|
|
8207
8129
|
}
|
|
8208
|
-
return
|
|
8130
|
+
return lines2.join("\n");
|
|
8209
8131
|
}
|
|
8210
8132
|
if (kind === "skill-args") {
|
|
8211
8133
|
if (admitted.baseRevision === void 0 || admitted.lens === void 0 || admitted.authorityRefs === void 0) {
|
|
@@ -8219,7 +8141,7 @@ function buildInstructionTransportPrompt(admitted, engineMaterial) {
|
|
|
8219
8141
|
if (!admitted.instructionEmpty && admitted.instruction.trim() !== "") {
|
|
8220
8142
|
lines2.push("", admitted.instruction);
|
|
8221
8143
|
}
|
|
8222
|
-
return
|
|
8144
|
+
return lines2.join("\n");
|
|
8223
8145
|
}
|
|
8224
8146
|
const lines = [admitted.instructionEmpty ? "" : admitted.instruction];
|
|
8225
8147
|
if (admitted.attachments.length > 0) {
|
|
@@ -8229,7 +8151,7 @@ function buildInstructionTransportPrompt(admitted, engineMaterial) {
|
|
|
8229
8151
|
lines.push(`- ${attachment.frozenPath}`);
|
|
8230
8152
|
}
|
|
8231
8153
|
}
|
|
8232
|
-
return
|
|
8154
|
+
return lines.join("\n");
|
|
8233
8155
|
}
|
|
8234
8156
|
async function materializeCountersignInvocation(admitted, options) {
|
|
8235
8157
|
const placed = await placeRoleAdmission({
|
|
@@ -8343,7 +8265,7 @@ function parseDoctorIssueNumber(raw) {
|
|
|
8343
8265
|
}
|
|
8344
8266
|
async function resolveDoctorCaseRunsPath(options) {
|
|
8345
8267
|
const ledgerHome = resolveActivationLedgerHome(options.home);
|
|
8346
|
-
const defaultRuns =
|
|
8268
|
+
const defaultRuns = join11(
|
|
8347
8269
|
activationBookDirectory(ledgerHome, options.bookKey),
|
|
8348
8270
|
String(options.issueNumber),
|
|
8349
8271
|
"runs"
|
|
@@ -8632,7 +8554,6 @@ var init_invocation = __esm({
|
|
|
8632
8554
|
init_uuidv7();
|
|
8633
8555
|
init_notary_contracts();
|
|
8634
8556
|
init_notary_source_run();
|
|
8635
|
-
init_engine_material();
|
|
8636
8557
|
init_cli_errors();
|
|
8637
8558
|
init_option_definitions();
|
|
8638
8559
|
init_unknown_value();
|
|
@@ -9989,7 +9910,7 @@ var init_settlement = __esm({
|
|
|
9989
9910
|
});
|
|
9990
9911
|
|
|
9991
9912
|
// src/session-identity.ts
|
|
9992
|
-
import { dirname as dirname9, join as
|
|
9913
|
+
import { dirname as dirname9, join as join12 } from "node:path";
|
|
9993
9914
|
function createSessionIdentityAuthority(authority, hostName) {
|
|
9994
9915
|
const runDirectoryOf = (principal) => dirname9(authority.decode(principal).sessionDirectory);
|
|
9995
9916
|
return {
|
|
@@ -9998,7 +9919,7 @@ function createSessionIdentityAuthority(authority, hostName) {
|
|
|
9998
9919
|
},
|
|
9999
9920
|
async load(principal) {
|
|
10000
9921
|
const runDirectory = runDirectoryOf(principal);
|
|
10001
|
-
const { records, diagnostics } = await readSitianRecords(
|
|
9922
|
+
const { records, diagnostics } = await readSitianRecords(join12(runDirectory, RUN_STATE_FILE));
|
|
10002
9923
|
if (diagnostics.length > 0) {
|
|
10003
9924
|
throw new Error(
|
|
10004
9925
|
`${RUN_STATE_FILE} has ${diagnostics.length} malformed row(s); refusing stale session binding: ${runDirectory}`
|
|
@@ -10068,12 +9989,12 @@ __export(role_turn_host_exports, {
|
|
|
10068
9989
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
10069
9990
|
import { constants } from "node:fs";
|
|
10070
9991
|
import { access as access2, appendFile, realpath as realpath4 } from "node:fs/promises";
|
|
10071
|
-
import { delimiter, dirname as dirname10, isAbsolute as isAbsolute6, join as
|
|
9992
|
+
import { delimiter, dirname as dirname10, isAbsolute as isAbsolute6, join as join13, resolve as resolve11 } from "node:path";
|
|
10072
9993
|
import { platform } from "node:process";
|
|
10073
9994
|
import { promisify as promisify2 } from "node:util";
|
|
10074
9995
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
10075
9996
|
function resolveInternalRoleEntrypoint(packageRoot) {
|
|
10076
|
-
return
|
|
9997
|
+
return join13(packageRoot, INTERNAL_ROLE_ENTRYPOINT_RELATIVE2);
|
|
10077
9998
|
}
|
|
10078
9999
|
function buildExplicitInternalActivationArgs(selectedRoleEntry, extraArgs = []) {
|
|
10079
10000
|
return ["--no-extensions", "-e", selectedRoleEntry, ...extraArgs];
|
|
@@ -10434,6 +10355,80 @@ var init_role_turn_host = __esm({
|
|
|
10434
10355
|
}
|
|
10435
10356
|
});
|
|
10436
10357
|
|
|
10358
|
+
// src/package-resources/engine-material.ts
|
|
10359
|
+
import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
10360
|
+
import { join as join14 } from "node:path";
|
|
10361
|
+
function pickEngineAxis(source) {
|
|
10362
|
+
return {
|
|
10363
|
+
...source.engine === void 0 ? {} : { engine: source.engine },
|
|
10364
|
+
...source.engineModel === void 0 ? {} : { engineModel: source.engineModel }
|
|
10365
|
+
};
|
|
10366
|
+
}
|
|
10367
|
+
function assertLegalEngineModel(model) {
|
|
10368
|
+
if (typeof model !== "string" || model.trim() === "" || model.trim() !== model) {
|
|
10369
|
+
throw new Error(`illegal engine model: ${JSON.stringify(model)}`);
|
|
10370
|
+
}
|
|
10371
|
+
return model;
|
|
10372
|
+
}
|
|
10373
|
+
function isEngineNameSyntax(name) {
|
|
10374
|
+
if (typeof name !== "string") return false;
|
|
10375
|
+
if (name.length === 0 || name.trim() !== name) return false;
|
|
10376
|
+
if (name === "." || name === "..") return false;
|
|
10377
|
+
if (name.includes("/") || name.includes("\\") || name.includes("\0")) return false;
|
|
10378
|
+
return true;
|
|
10379
|
+
}
|
|
10380
|
+
function resolveEngineMaterialDirectory(packageRoot) {
|
|
10381
|
+
return join14(packageRoot, ENGINE_MATERIAL_RELATIVE_ROOT);
|
|
10382
|
+
}
|
|
10383
|
+
function resolveEngineDispatchMaterialPath(packageRoot) {
|
|
10384
|
+
return join14(packageRoot, ENGINE_DISPATCH_RELATIVE_PATH);
|
|
10385
|
+
}
|
|
10386
|
+
function resolveEngineMaterialPath(packageRoot, name) {
|
|
10387
|
+
const legal = assertLegalEngineName(name);
|
|
10388
|
+
return join14(resolveEngineMaterialDirectory(packageRoot), `${legal}.md`);
|
|
10389
|
+
}
|
|
10390
|
+
function assertLegalEngineName(name) {
|
|
10391
|
+
if (!isEngineNameSyntax(name)) {
|
|
10392
|
+
throw new Error(`illegal engine name: ${name}`);
|
|
10393
|
+
}
|
|
10394
|
+
return name;
|
|
10395
|
+
}
|
|
10396
|
+
function engineSessionMaterialFromOptions(options) {
|
|
10397
|
+
if (options.engine === void 0) return void 0;
|
|
10398
|
+
if (options.packageRoot === void 0 || options.packageRoot.trim() === "") {
|
|
10399
|
+
throw new Error("packageRoot is required when engine is configured");
|
|
10400
|
+
}
|
|
10401
|
+
const name = assertLegalEngineName(options.engine);
|
|
10402
|
+
const model = options.engineModel === void 0 ? void 0 : assertLegalEngineModel(options.engineModel);
|
|
10403
|
+
const materialPath = resolveEngineMaterialPath(options.packageRoot, name);
|
|
10404
|
+
const modelField = model === void 0 ? {} : { model };
|
|
10405
|
+
if (!existsSync4(materialPath)) {
|
|
10406
|
+
return Object.freeze({ name, ...modelField });
|
|
10407
|
+
}
|
|
10408
|
+
const handbook = readFileSync2(materialPath, "utf8");
|
|
10409
|
+
const dispatchPath = resolveEngineDispatchMaterialPath(options.packageRoot);
|
|
10410
|
+
const dispatchField = existsSync4(dispatchPath) ? { dispatchHandbook: readFileSync2(dispatchPath, "utf8") } : {};
|
|
10411
|
+
return Object.freeze({ name, handbook, ...dispatchField, ...modelField });
|
|
10412
|
+
}
|
|
10413
|
+
function engineSessionReadingMaterial(engineMaterial) {
|
|
10414
|
+
if (engineMaterial === void 0) return void 0;
|
|
10415
|
+
return {
|
|
10416
|
+
kind: "engine-session-material",
|
|
10417
|
+
name: engineMaterial.name,
|
|
10418
|
+
...engineMaterial.model === void 0 ? {} : { model: engineMaterial.model },
|
|
10419
|
+
...engineMaterial.handbook === void 0 ? {} : { handbook: engineMaterial.handbook },
|
|
10420
|
+
...engineMaterial.dispatchHandbook === void 0 ? {} : { dispatchHandbook: engineMaterial.dispatchHandbook }
|
|
10421
|
+
};
|
|
10422
|
+
}
|
|
10423
|
+
var ENGINE_MATERIAL_RELATIVE_ROOT, ENGINE_DISPATCH_RELATIVE_PATH;
|
|
10424
|
+
var init_engine_material = __esm({
|
|
10425
|
+
"src/package-resources/engine-material.ts"() {
|
|
10426
|
+
"use strict";
|
|
10427
|
+
ENGINE_MATERIAL_RELATIVE_ROOT = "resources/engines";
|
|
10428
|
+
ENGINE_DISPATCH_RELATIVE_PATH = "resources/engine-dispatch.md";
|
|
10429
|
+
}
|
|
10430
|
+
});
|
|
10431
|
+
|
|
10437
10432
|
// src/institutional-resolution.ts
|
|
10438
10433
|
function resolveConfiguredProvinceOfficer(config, officer) {
|
|
10439
10434
|
const ownModel = seatModelOnly(config.seats[officer]);
|
|
@@ -10985,7 +10980,7 @@ var init_config = __esm({
|
|
|
10985
10980
|
});
|
|
10986
10981
|
|
|
10987
10982
|
// src/public-cli/host-providers.ts
|
|
10988
|
-
import { readFileSync as
|
|
10983
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
10989
10984
|
import { join as join16 } from "node:path";
|
|
10990
10985
|
function hostProvidersPath(home) {
|
|
10991
10986
|
if (typeof home !== "string" || home.trim() === "") {
|
|
@@ -11031,7 +11026,7 @@ function parseHostProvidersTable(value) {
|
|
|
11031
11026
|
function loadHostProvidersTable(home) {
|
|
11032
11027
|
const path = hostProvidersPath(home);
|
|
11033
11028
|
try {
|
|
11034
|
-
const raw =
|
|
11029
|
+
const raw = readFileSync3(path, "utf8");
|
|
11035
11030
|
return parseHostProvidersTable(JSON.parse(raw));
|
|
11036
11031
|
} catch (error) {
|
|
11037
11032
|
if (isEnoent(error)) return {};
|
|
@@ -11047,7 +11042,7 @@ function listHermesProvidersForModel(home, seatModel) {
|
|
|
11047
11042
|
const path = hermesProviderModelsCachePath(home);
|
|
11048
11043
|
let text;
|
|
11049
11044
|
try {
|
|
11050
|
-
text =
|
|
11045
|
+
text = readFileSync3(path, "utf8");
|
|
11051
11046
|
} catch (error) {
|
|
11052
11047
|
if (isEnoent(error)) return [];
|
|
11053
11048
|
throw error;
|
|
@@ -13494,13 +13489,7 @@ async function runPostAdmissionOneShot(input) {
|
|
|
13494
13489
|
...input.request,
|
|
13495
13490
|
continuation: {
|
|
13496
13491
|
kind: "resume",
|
|
13497
|
-
prompt: buildAutoResumeContinuationPrompt(
|
|
13498
|
-
packageRoot: input.env.packageRoot,
|
|
13499
|
-
...pickEngineAxis({
|
|
13500
|
-
engine: input.effectiveEngine ?? input.env.engine,
|
|
13501
|
-
engineModel: input.env.engineModel
|
|
13502
|
-
})
|
|
13503
|
-
})
|
|
13492
|
+
prompt: buildAutoResumeContinuationPrompt()
|
|
13504
13493
|
}
|
|
13505
13494
|
}),
|
|
13506
13495
|
adapters: input.adapters,
|
|
@@ -13584,7 +13573,6 @@ var init_post_admission = __esm({
|
|
|
13584
13573
|
init_submission_ledger();
|
|
13585
13574
|
init_run_ticket_number();
|
|
13586
13575
|
init_activation_ledger_topology();
|
|
13587
|
-
init_engine_material();
|
|
13588
13576
|
init_session_identity();
|
|
13589
13577
|
init_sitian_facade();
|
|
13590
13578
|
init_receipt_delivery_policy();
|
|
@@ -13815,13 +13803,7 @@ function initialPrompt(admitted, env) {
|
|
|
13815
13803
|
if (reask !== void 0 && "reaskPrompt" in record && record.reaskPrompt === true) {
|
|
13816
13804
|
return reask;
|
|
13817
13805
|
}
|
|
13818
|
-
return buildInstructionTransportPrompt(
|
|
13819
|
-
admitted,
|
|
13820
|
-
engineSessionMaterialFromOptions({
|
|
13821
|
-
...pickEngineAxis(env),
|
|
13822
|
-
packageRoot: env.packageRoot
|
|
13823
|
-
})
|
|
13824
|
-
);
|
|
13806
|
+
return buildInstructionTransportPrompt(admitted);
|
|
13825
13807
|
}
|
|
13826
13808
|
function isBoardTicketSeat(seat) {
|
|
13827
13809
|
return packagedBindsBoardTicket(seat.role);
|
|
@@ -13915,10 +13897,7 @@ async function dispatchAdmitted(admitted, env, io) {
|
|
|
13915
13897
|
admitted,
|
|
13916
13898
|
roleTurnOptions(activeEnv, admitted, {
|
|
13917
13899
|
kind: "resume",
|
|
13918
|
-
prompt: buildAutoResumeContinuationPrompt(
|
|
13919
|
-
packageRoot: activeEnv.packageRoot,
|
|
13920
|
-
...pickEngineAxis(activeEnv)
|
|
13921
|
-
})
|
|
13900
|
+
prompt: buildAutoResumeContinuationPrompt()
|
|
13922
13901
|
})
|
|
13923
13902
|
),
|
|
13924
13903
|
adapters,
|
|
@@ -14084,13 +14063,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
14084
14063
|
}
|
|
14085
14064
|
const turnProjection = roleTurnOptions(env, admitted, {
|
|
14086
14065
|
kind: "initial",
|
|
14087
|
-
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(
|
|
14088
|
-
admitted,
|
|
14089
|
-
engineSessionMaterialFromOptions({
|
|
14090
|
-
...pickEngineAxis(env),
|
|
14091
|
-
packageRoot: env.packageRoot
|
|
14092
|
-
})
|
|
14093
|
-
)
|
|
14066
|
+
prompt: env.reviewReask ?? env.gateReviewInstruction ?? buildInstructionTransportPrompt(admitted)
|
|
14094
14067
|
});
|
|
14095
14068
|
const turnRequest = buildInstructionSeatTurnRequest(admitted, turnProjection);
|
|
14096
14069
|
const result = await runPostAdmissionOneShot({
|
|
@@ -14787,7 +14760,6 @@ var init_instruction_seat_run = __esm({
|
|
|
14787
14760
|
init_submission_gate();
|
|
14788
14761
|
init_run_ticket_number();
|
|
14789
14762
|
init_notary_source_run();
|
|
14790
|
-
init_engine_material();
|
|
14791
14763
|
init_packaged_role_registry();
|
|
14792
14764
|
init_auditor_soul();
|
|
14793
14765
|
init_cli_errors();
|
|
@@ -18907,14 +18879,8 @@ __export(run_lifecycle_exports, {
|
|
|
18907
18879
|
});
|
|
18908
18880
|
import { chmod, lstat as lstat4, open as open2, readdir as readdir4, readFile as readFile15, unlink as unlink2 } from "node:fs/promises";
|
|
18909
18881
|
import { basename as basename12, join as join30 } from "node:path";
|
|
18910
|
-
function buildAutoResumeContinuationPrompt(
|
|
18911
|
-
return
|
|
18912
|
-
[RESUME_TRANSPORT_ENVELOPE],
|
|
18913
|
-
engineSessionMaterialFromOptions({
|
|
18914
|
-
packageRoot: options.packageRoot,
|
|
18915
|
-
...pickEngineAxis(options)
|
|
18916
|
-
})
|
|
18917
|
-
).join("\n");
|
|
18882
|
+
function buildAutoResumeContinuationPrompt() {
|
|
18883
|
+
return RESUME_TRANSPORT_ENVELOPE;
|
|
18918
18884
|
}
|
|
18919
18885
|
async function writeRoleRunState(runDirectory, record) {
|
|
18920
18886
|
const payload = { ...record, runDirectory };
|
|
@@ -19888,7 +19854,6 @@ var init_run_lifecycle = __esm({
|
|
|
19888
19854
|
init_cli_errors();
|
|
19889
19855
|
init_collector_config();
|
|
19890
19856
|
init_role_run_relocation();
|
|
19891
|
-
init_engine_material();
|
|
19892
19857
|
init_packaged_role_registry();
|
|
19893
19858
|
init_invocation();
|
|
19894
19859
|
init_run_dossier();
|
|
@@ -20220,7 +20185,7 @@ import {
|
|
|
20220
20185
|
existsSync as existsSync11,
|
|
20221
20186
|
openSync,
|
|
20222
20187
|
readdirSync as readdirSync3,
|
|
20223
|
-
readFileSync as
|
|
20188
|
+
readFileSync as readFileSync4,
|
|
20224
20189
|
readSync,
|
|
20225
20190
|
realpathSync as realpathSync4,
|
|
20226
20191
|
statSync as statSync8,
|
|
@@ -20231,7 +20196,7 @@ import { StringDecoder } from "node:string_decoder";
|
|
|
20231
20196
|
function readCurrentSession(sessionDir) {
|
|
20232
20197
|
const ledger = currentSessionLedgerPath(sessionDir);
|
|
20233
20198
|
try {
|
|
20234
|
-
const value = JSON.parse(
|
|
20199
|
+
const value = JSON.parse(readFileSync4(ledger, "utf8"));
|
|
20235
20200
|
if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
|
|
20236
20201
|
throw new Error("sessionFile is missing");
|
|
20237
20202
|
}
|
|
@@ -22222,7 +22187,7 @@ init_unknown_value();
|
|
|
22222
22187
|
init_submission_errors();
|
|
22223
22188
|
init_worker_submission_contracts();
|
|
22224
22189
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
22225
|
-
import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as
|
|
22190
|
+
import { existsSync as existsSync13, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, rmdirSync, rmSync as rmSync3 } from "node:fs";
|
|
22226
22191
|
import { resolve as resolve19 } from "node:path";
|
|
22227
22192
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
22228
22193
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
@@ -22263,7 +22228,7 @@ function tryGetAll(file, key) {
|
|
|
22263
22228
|
}
|
|
22264
22229
|
function ownedHook(path) {
|
|
22265
22230
|
if (!existsSync13(path)) return false;
|
|
22266
|
-
return
|
|
22231
|
+
return readFileSync5(path, "utf8").includes(HOOK_MARKER);
|
|
22267
22232
|
}
|
|
22268
22233
|
function escapeGitConfigValueRegex(value) {
|
|
22269
22234
|
return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
@@ -23500,9 +23465,6 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23500
23465
|
}
|
|
23501
23466
|
});
|
|
23502
23467
|
roleHost.on("before_agent_start", () => {
|
|
23503
|
-
const role = selectedRole ?? roleHost.getFlag(ROLE_FLAG.name);
|
|
23504
|
-
if (typeof role !== "string" || !isOfficerReviewSeat(role)) return;
|
|
23505
|
-
if (roleHost.getFlag(STATION_CHILD_FLAG.name) !== true) return;
|
|
23506
23468
|
const engine = resolveEngineName((name) => roleHost.getFlag(name));
|
|
23507
23469
|
if (engine === void 0 || dependencies.packageRoot === void 0) return;
|
|
23508
23470
|
const engineModel = resolveEngineModel((name) => roleHost.getFlag(name));
|
|
@@ -23511,15 +23473,9 @@ function createRoleRuntimeExtension(dependencies, deliveryRequestLimit) {
|
|
|
23511
23473
|
...engineModel === void 0 ? {} : { engineModel },
|
|
23512
23474
|
packageRoot: dependencies.packageRoot
|
|
23513
23475
|
});
|
|
23514
|
-
|
|
23515
|
-
return
|
|
23516
|
-
|
|
23517
|
-
kind: "engine-session-material",
|
|
23518
|
-
name: material.name,
|
|
23519
|
-
...material.model === void 0 ? {} : { model: material.model },
|
|
23520
|
-
...material.materialPath === void 0 ? {} : { materialPath: material.materialPath }
|
|
23521
|
-
}
|
|
23522
|
-
};
|
|
23476
|
+
const reading = engineSessionReadingMaterial(material);
|
|
23477
|
+
if (reading === void 0) return;
|
|
23478
|
+
return { readingMaterial: reading };
|
|
23523
23479
|
});
|
|
23524
23480
|
roleHost.on("before_agent_start", () => {
|
|
23525
23481
|
const path = roleHost.getFlag(INSPECTOR_SOURCE_RUN_FLAG.name);
|