@akagilnc/pi-workflow-roles 0.1.3625 → 0.1.3629
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +77 -35
- package/dist/public-cli/main.js +173 -125
- package/dist/public-cli/notary-run.js +20 -2
- package/dist/public-cli/post-admission.js +4 -4
- package/dist/public-cli/run-lifecycle.js +44 -5
- package/package.json +1 -1
- package/src/public-cli/notary-run.ts +18 -4
- package/src/public-cli/post-admission.ts +14 -7
- package/src/public-cli/run-lifecycle.ts +53 -5
|
@@ -4209,10 +4209,35 @@ var init_engine_material = __esm({
|
|
|
4209
4209
|
|
|
4210
4210
|
// src/public-cli/run-lifecycle.ts
|
|
4211
4211
|
import { chmod, open, readdir as readdir2, readFile as readFile8, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
4212
|
-
import { join as join11 } from "node:path";
|
|
4212
|
+
import { isAbsolute as isAbsolute4, join as join11 } from "node:path";
|
|
4213
|
+
function resumeRereadInstruction(materialPath, handbook) {
|
|
4214
|
+
return handbook ? `\u91CD\u65B0\u8BFB ${materialPath}\uFF0C\u518D\u7EC4\u88C5\u5916\u5305 argv` : `\u91CD\u65B0\u8BFB ${materialPath}`;
|
|
4215
|
+
}
|
|
4216
|
+
function instructResumeHandbookRead(prompt, engineMaterial) {
|
|
4217
|
+
const handbookPath = engineMaterial?.materialPath;
|
|
4218
|
+
return prompt.split("\n").map((line2) => {
|
|
4219
|
+
if (!line2.startsWith("- ")) return line2;
|
|
4220
|
+
const value = line2.slice(2);
|
|
4221
|
+
if (handbookPath !== void 0 && value === handbookPath) {
|
|
4222
|
+
return resumeRereadInstruction(handbookPath, true);
|
|
4223
|
+
}
|
|
4224
|
+
if (isAbsolute4(value)) return resumeRereadInstruction(value, false);
|
|
4225
|
+
return line2;
|
|
4226
|
+
}).join("\n");
|
|
4227
|
+
}
|
|
4228
|
+
function appendResumeMaterialReread(prompt, materialPath) {
|
|
4229
|
+
const instruction = resumeRereadInstruction(materialPath, false);
|
|
4230
|
+
const lines = prompt.split("\n");
|
|
4231
|
+
if (lines.includes(instruction)) return prompt;
|
|
4232
|
+
return prompt.length === 0 ? instruction : `${prompt}
|
|
4233
|
+
${instruction}`;
|
|
4234
|
+
}
|
|
4213
4235
|
function selectResumeContinuationPrompt(message, engineMaterial) {
|
|
4214
4236
|
const base = message !== void 0 ? message : RESUME_TRANSPORT_ENVELOPE;
|
|
4215
|
-
return
|
|
4237
|
+
return instructResumeHandbookRead(
|
|
4238
|
+
appendEngineSessionMaterial([base], engineMaterial).join("\n"),
|
|
4239
|
+
engineMaterial
|
|
4240
|
+
);
|
|
4216
4241
|
}
|
|
4217
4242
|
function buildResumeContinuationPrompt(options) {
|
|
4218
4243
|
return selectResumeContinuationPrompt(
|
|
@@ -5083,7 +5108,7 @@ __export(notary_source_run_exports, {
|
|
|
5083
5108
|
loadNotarySourceRunLocator: () => loadNotarySourceRunLocator,
|
|
5084
5109
|
resolveNotarySourceRunLocator: () => resolveNotarySourceRunLocator
|
|
5085
5110
|
});
|
|
5086
|
-
import { dirname as dirname7, isAbsolute as
|
|
5111
|
+
import { dirname as dirname7, isAbsolute as isAbsolute5, join as join12, resolve as resolve8, basename as basename4 } from "node:path";
|
|
5087
5112
|
import { lstat as lstat2, realpath as realpath4 } from "node:fs/promises";
|
|
5088
5113
|
function parseRunDirectoryName(name) {
|
|
5089
5114
|
const match = RUN_DIR_NAME.exec(name);
|
|
@@ -5135,7 +5160,7 @@ async function resolveNotarySourceRunLocator(options) {
|
|
|
5135
5160
|
if (bare !== void 0 && !raw.includes("/") && !raw.includes("\\")) {
|
|
5136
5161
|
candidate = join12(bookRunsRoot, `${bare.runId}@${bare.role}`);
|
|
5137
5162
|
} else {
|
|
5138
|
-
candidate =
|
|
5163
|
+
candidate = isAbsolute5(raw) ? raw : resolve8(options.projectRoot, raw);
|
|
5139
5164
|
}
|
|
5140
5165
|
const real = await requireRunDirectory(candidate, raw);
|
|
5141
5166
|
const identity = parseRunDirectoryName(basename4(real));
|
|
@@ -6278,7 +6303,7 @@ import {
|
|
|
6278
6303
|
realpath as realpath5,
|
|
6279
6304
|
writeFile as writeFile4
|
|
6280
6305
|
} from "node:fs/promises";
|
|
6281
|
-
import { basename as basename5, isAbsolute as
|
|
6306
|
+
import { basename as basename5, isAbsolute as isAbsolute6, join as join13, resolve as resolve9, sep as sep3 } from "node:path";
|
|
6282
6307
|
function issueAdmissionPlacement(authority, request) {
|
|
6283
6308
|
const principal = authority.issue(request);
|
|
6284
6309
|
const { sessionDirectory, sessionFile } = authority.decode(principal);
|
|
@@ -6676,7 +6701,7 @@ function parseFixerArgv(args) {
|
|
|
6676
6701
|
};
|
|
6677
6702
|
}
|
|
6678
6703
|
async function freezeRegularFileAttachment(sourcePath, destinationDir, index) {
|
|
6679
|
-
const absolute =
|
|
6704
|
+
const absolute = isAbsolute6(sourcePath) ? sourcePath : resolve9(sourcePath);
|
|
6680
6705
|
let st;
|
|
6681
6706
|
try {
|
|
6682
6707
|
st = await lstat3(absolute);
|
|
@@ -7026,7 +7051,7 @@ async function admitFixerInvocation(options) {
|
|
|
7026
7051
|
let prerequisites = Object.freeze([]);
|
|
7027
7052
|
let prerequisitesSource;
|
|
7028
7053
|
if (options.prerequisitesPath !== void 0) {
|
|
7029
|
-
const absolutePrereq =
|
|
7054
|
+
const absolutePrereq = isAbsolute6(options.prerequisitesPath) ? options.prerequisitesPath : resolve9(options.prerequisitesPath);
|
|
7030
7055
|
try {
|
|
7031
7056
|
prerequisitesSource = await readFile9(absolutePrereq, "utf8");
|
|
7032
7057
|
} catch (error) {
|
|
@@ -7451,7 +7476,7 @@ async function resolveDoctorCaseRunsPath(options) {
|
|
|
7451
7476
|
if (raw === "") {
|
|
7452
7477
|
throw new CliUsageError("doctor --runs requires a path");
|
|
7453
7478
|
}
|
|
7454
|
-
if (
|
|
7479
|
+
if (isAbsolute6(raw)) {
|
|
7455
7480
|
throw new CliUsageError(
|
|
7456
7481
|
"doctor --runs must be a project-relative path"
|
|
7457
7482
|
);
|
|
@@ -16297,7 +16322,7 @@ var init_auto_resume = __esm({
|
|
|
16297
16322
|
// src/public-cli/post-admission.ts
|
|
16298
16323
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
16299
16324
|
import { readFile as readFile16, writeFile as writeFile7 } from "node:fs/promises";
|
|
16300
|
-
import { isAbsolute as
|
|
16325
|
+
import { isAbsolute as isAbsolute7, join as join26, resolve as resolve12 } from "node:path";
|
|
16301
16326
|
async function readInvocationHost(runDirectory) {
|
|
16302
16327
|
try {
|
|
16303
16328
|
const raw = JSON.parse(await readFile16(join26(runDirectory, "invocation.json"), "utf8"));
|
|
@@ -16513,12 +16538,15 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
16513
16538
|
let prompt;
|
|
16514
16539
|
if (request.message !== void 0) {
|
|
16515
16540
|
if (summonsPrepared !== void 0 && summonsPrepared.attachments.length > 0) {
|
|
16516
|
-
prompt =
|
|
16517
|
-
|
|
16518
|
-
|
|
16519
|
-
|
|
16520
|
-
|
|
16521
|
-
|
|
16541
|
+
prompt = instructResumeHandbookRead(
|
|
16542
|
+
buildInstructionTransportPrompt(
|
|
16543
|
+
{
|
|
16544
|
+
instruction: request.message,
|
|
16545
|
+
instructionEmpty: false,
|
|
16546
|
+
attachments: summonsPrepared.attachments
|
|
16547
|
+
},
|
|
16548
|
+
engineMaterial
|
|
16549
|
+
),
|
|
16522
16550
|
engineMaterial
|
|
16523
16551
|
);
|
|
16524
16552
|
} else {
|
|
@@ -16529,7 +16557,10 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
16529
16557
|
});
|
|
16530
16558
|
}
|
|
16531
16559
|
} else if (summonsPrepared !== void 0) {
|
|
16532
|
-
prompt =
|
|
16560
|
+
prompt = instructResumeHandbookRead(
|
|
16561
|
+
buildInstructionTransportPrompt(summonsPrepared, engineMaterial),
|
|
16562
|
+
engineMaterial
|
|
16563
|
+
);
|
|
16533
16564
|
} else {
|
|
16534
16565
|
prompt = buildResumeContinuationPrompt({
|
|
16535
16566
|
packageRoot: env.packageRoot,
|
|
@@ -16551,7 +16582,7 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
16551
16582
|
};
|
|
16552
16583
|
}
|
|
16553
16584
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
16554
|
-
const absolute =
|
|
16585
|
+
const absolute = isAbsolute7(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
16555
16586
|
return pathContainedIn(join26(runDirectory, "attachments"), absolute);
|
|
16556
16587
|
}
|
|
16557
16588
|
async function prepareSummonsResumeMaterials(runDirectory, summons) {
|
|
@@ -16889,6 +16920,7 @@ __export(notary_run_exports, {
|
|
|
16889
16920
|
runPublicNotary: () => runPublicNotary,
|
|
16890
16921
|
runPublicNotaryResume: () => runPublicNotaryResume
|
|
16891
16922
|
});
|
|
16923
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
16892
16924
|
function buildNotaryTurnRequest(admitted, options) {
|
|
16893
16925
|
return projectRoleTurnRequest(
|
|
16894
16926
|
admitted,
|
|
@@ -17031,10 +17063,19 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
17031
17063
|
}
|
|
17032
17064
|
return loaded;
|
|
17033
17065
|
},
|
|
17034
|
-
buildTurnRequest: (admitted, effective) =>
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17066
|
+
buildTurnRequest: (admitted, effective) => {
|
|
17067
|
+
const projection = resumeTurnRequestProjectionOptions(
|
|
17068
|
+
admitted,
|
|
17069
|
+
effective,
|
|
17070
|
+
env
|
|
17071
|
+
);
|
|
17072
|
+
const candidatePath = gateSubmissionCandidatePath(admitted.sourceRunPath);
|
|
17073
|
+
const prompt = existsSync9(candidatePath) ? appendResumeMaterialReread(projection.continuation.prompt, candidatePath) : projection.continuation.prompt;
|
|
17074
|
+
return buildNotaryTurnRequest(admitted, {
|
|
17075
|
+
...projection,
|
|
17076
|
+
continuation: { kind: "resume", prompt }
|
|
17077
|
+
});
|
|
17078
|
+
},
|
|
17038
17079
|
adapters: notaryAdapters(),
|
|
17039
17080
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
17040
17081
|
});
|
|
@@ -17042,6 +17083,7 @@ async function runPublicNotaryResume(request, env, io) {
|
|
|
17042
17083
|
var init_notary_run = __esm({
|
|
17043
17084
|
"src/public-cli/notary-run.ts"() {
|
|
17044
17085
|
"use strict";
|
|
17086
|
+
init_auditor_dossier_tool();
|
|
17045
17087
|
init_notary_source_run();
|
|
17046
17088
|
init_engine_material();
|
|
17047
17089
|
init_run_ticket_number();
|
|
@@ -17719,7 +17761,7 @@ __export(public_role_summons_exports, {
|
|
|
17719
17761
|
summonGateOfficer: () => summonGateOfficer,
|
|
17720
17762
|
summonPublicRole: () => summonPublicRole
|
|
17721
17763
|
});
|
|
17722
|
-
import { existsSync as
|
|
17764
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
17723
17765
|
import { join as join27 } from "node:path";
|
|
17724
17766
|
function createCapturingIo() {
|
|
17725
17767
|
const chunks = [];
|
|
@@ -17743,7 +17785,7 @@ function parentDir(path) {
|
|
|
17743
17785
|
function walkPackageRoot(start) {
|
|
17744
17786
|
let dir = start;
|
|
17745
17787
|
for (let i = 0; i < 12; i += 1) {
|
|
17746
|
-
if (
|
|
17788
|
+
if (existsSync10(join27(dir, "package.json")) && existsSync10(join27(dir, "souls"))) {
|
|
17747
17789
|
return dir;
|
|
17748
17790
|
}
|
|
17749
17791
|
const parent = parentDir(dir);
|
|
@@ -18204,7 +18246,7 @@ __export(archivist_record_entry_exports, {
|
|
|
18204
18246
|
createRecordSessionOpen: () => createRecordSessionOpen,
|
|
18205
18247
|
subjectKeyedRecordDirectory: () => subjectKeyedRecordDirectory
|
|
18206
18248
|
});
|
|
18207
|
-
import { existsSync as
|
|
18249
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync5, realpathSync as realpathSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
18208
18250
|
import { dirname as dirname13, resolve as resolve13, join as join29 } from "node:path";
|
|
18209
18251
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
18210
18252
|
function readCurrentSession(sessionDir) {
|
|
@@ -18287,7 +18329,7 @@ function createRecordSessionOpen(options) {
|
|
|
18287
18329
|
sessionDir = physicallyContainedIn(ledgerHome, parentResolved) ? join29(dirname13(parentResolved), options.kind) : join29(activationBookDirectory(ledgerHome, resolveBookKeyFromGit(cwd)), options.kind);
|
|
18288
18330
|
parentSession = parentFile;
|
|
18289
18331
|
}
|
|
18290
|
-
const nestAlreadyExists =
|
|
18332
|
+
const nestAlreadyExists = existsSync11(sessionDir);
|
|
18291
18333
|
ensureRealDirectoryTree(ledgerHome, sessionDir);
|
|
18292
18334
|
const mayResumeSameNest = options.subject !== void 0 || options.kind === WORKER_SUBMISSION_GATE_KIND;
|
|
18293
18335
|
if (mayResumeSameNest && nestAlreadyExists) {
|
|
@@ -18305,7 +18347,7 @@ function createRecordSessionOpen(options) {
|
|
|
18305
18347
|
);
|
|
18306
18348
|
if (session.isPersisted()) {
|
|
18307
18349
|
const file = session.getSessionFile();
|
|
18308
|
-
if (file !== void 0 && !
|
|
18350
|
+
if (file !== void 0 && !existsSync11(file)) {
|
|
18309
18351
|
const header = session.getHeader();
|
|
18310
18352
|
if (header !== null && header.type === "session") {
|
|
18311
18353
|
writeFileSync5(file, `${JSON.stringify(header)}
|
|
@@ -19966,7 +20008,7 @@ import {
|
|
|
19966
20008
|
openSync,
|
|
19967
20009
|
writeSync
|
|
19968
20010
|
} from "node:fs";
|
|
19969
|
-
import { dirname as dirname16, isAbsolute as
|
|
20011
|
+
import { dirname as dirname16, isAbsolute as isAbsolute9, resolve as resolve17 } from "node:path";
|
|
19970
20012
|
|
|
19971
20013
|
// src/activation-ledger-session.ts
|
|
19972
20014
|
init_activation_ledger_topology();
|
|
@@ -19976,7 +20018,7 @@ import {
|
|
|
19976
20018
|
statSync as statSync3,
|
|
19977
20019
|
writeFileSync as writeFileSync6
|
|
19978
20020
|
} from "node:fs";
|
|
19979
|
-
import { isAbsolute as
|
|
20021
|
+
import { isAbsolute as isAbsolute8, resolve as resolve16 } from "node:path";
|
|
19980
20022
|
var ActivationSessionFileMissingError = class extends Error {
|
|
19981
20023
|
code = "AK_ACTIVATION_SESSION_FILE_MISSING";
|
|
19982
20024
|
path;
|
|
@@ -20016,7 +20058,7 @@ function durableSessionPointer(sessionManager) {
|
|
|
20016
20058
|
"Workflow role activation requires a durable Pi session file principal (getSessionFile); directory-only or --no-session invocations are rejected"
|
|
20017
20059
|
);
|
|
20018
20060
|
}
|
|
20019
|
-
if (!
|
|
20061
|
+
if (!isAbsolute8(file)) {
|
|
20020
20062
|
throw new Error(
|
|
20021
20063
|
`Workflow role activation requires an absolute durable session file path; got relative path: ${file}`
|
|
20022
20064
|
);
|
|
@@ -20108,7 +20150,7 @@ function serializeAcceptedActivationFact(fact) {
|
|
|
20108
20150
|
`;
|
|
20109
20151
|
}
|
|
20110
20152
|
function appendActivationLedgerLine(ledgerPath, line2, options) {
|
|
20111
|
-
if (!
|
|
20153
|
+
if (!isAbsolute9(options.ledgerHome)) {
|
|
20112
20154
|
throw new ActivationLedgerError(
|
|
20113
20155
|
`activation ledger home must be absolute: ${options.ledgerHome}`
|
|
20114
20156
|
);
|
|
@@ -21955,7 +21997,7 @@ init_sitian_facade();
|
|
|
21955
21997
|
init_submission_errors();
|
|
21956
21998
|
init_submission_errors();
|
|
21957
21999
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
21958
|
-
import { existsSync as
|
|
22000
|
+
import { existsSync as existsSync12, lstatSync as lstatSync3, readdirSync as readdirSync2, readFileSync as readFileSync6, rmdirSync, rmSync } from "node:fs";
|
|
21959
22001
|
import { resolve as resolve18 } from "node:path";
|
|
21960
22002
|
var WORKER_SUBMISSION_GATE_RECORD_KIND = WORKER_SUBMISSION_GATE_KIND;
|
|
21961
22003
|
var WORKER_COMMIT_BASELINE_ENTRY_TYPE = "commit-baseline";
|
|
@@ -21986,7 +22028,7 @@ function statusOf(error) {
|
|
|
21986
22028
|
return typeof error === "object" && error !== null && "status" in error ? error.status : void 0;
|
|
21987
22029
|
}
|
|
21988
22030
|
function tryGetAll(file, key) {
|
|
21989
|
-
if (!
|
|
22031
|
+
if (!existsSync12(file)) return [];
|
|
21990
22032
|
try {
|
|
21991
22033
|
const out = gitFile(file, ["--get-all", key]);
|
|
21992
22034
|
return out.length === 0 ? [] : out.split("\n");
|
|
@@ -21996,7 +22038,7 @@ function tryGetAll(file, key) {
|
|
|
21996
22038
|
}
|
|
21997
22039
|
}
|
|
21998
22040
|
function ownedHook(path) {
|
|
21999
|
-
if (!
|
|
22041
|
+
if (!existsSync12(path)) return false;
|
|
22000
22042
|
return readFileSync6(path, "utf8").includes(HOOK_MARKER);
|
|
22001
22043
|
}
|
|
22002
22044
|
function escapeGitConfigValueRegex(value) {
|
|
@@ -22023,11 +22065,11 @@ function rmOwnedDir(dir) {
|
|
|
22023
22065
|
const hookPath = resolve18(dir, HOOK_FILE);
|
|
22024
22066
|
if (!ownedHook(hookPath)) return;
|
|
22025
22067
|
rmSync(hookPath, { force: true });
|
|
22026
|
-
if (
|
|
22068
|
+
if (existsSync12(dir) && readdirSync2(dir).length === 0) rmdirSync(dir);
|
|
22027
22069
|
}
|
|
22028
22070
|
function linkedGitDirs(commonDir) {
|
|
22029
22071
|
const root = resolve18(commonDir, "worktrees");
|
|
22030
|
-
if (!
|
|
22072
|
+
if (!existsSync12(root)) return [];
|
|
22031
22073
|
return readdirSync2(root).map((name) => resolve18(root, name)).filter((dir) => lstatSync3(dir).isDirectory());
|
|
22032
22074
|
}
|
|
22033
22075
|
function uninstallPackageWorkerHooks(cwd) {
|