@akagilnc/pi-workflow-roles 0.1.5365 → 0.1.5368
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-host/production-host.js +4985 -4998
- package/dist/headless-host/production-host.js +1006 -1019
- package/dist/migrate-book-topology.js +3 -3
- package/dist/public-cli/auto-resume.js +1 -1
- package/dist/public-cli/cli.js +57 -56
- package/dist/public-cli/config.js +4 -0
- package/dist/public-cli/instruction-seat-run.js +65 -40
- package/dist/public-cli/invocation.js +132 -128
- package/dist/public-cli/main.js +386 -399
- package/dist/public-cli/post-admission.js +85 -86
- package/dist/public-cli/role-seat-runtime.js +29 -0
- package/dist/public-cli/run-lifecycle.js +6 -6
- package/dist/public-cli/turn-request.js +14 -0
- package/dist/public-role-summons.js +20 -33
- package/dist/role-run-placement.js +4 -0
- package/package.json +1 -1
- package/src/book-topology-migration-placement.ts +3 -5
- package/src/public-cli/auto-resume.ts +1 -1
- package/src/public-cli/cli.ts +67 -73
- package/src/public-cli/config.ts +8 -0
- package/src/public-cli/instruction-seat-run.ts +82 -55
- package/src/public-cli/invocation.ts +148 -162
- package/src/public-cli/post-admission.ts +110 -100
- package/src/public-cli/role-seat-runtime.ts +72 -0
- package/src/public-cli/run-lifecycle.ts +7 -26
- package/src/public-cli/terminal.ts +2 -17
- package/src/public-cli/turn-request.ts +26 -0
- package/src/public-role-summons.ts +20 -45
- package/src/role-run-placement.ts +5 -0
package/dist/public-cli/main.js
CHANGED
|
@@ -513,6 +513,9 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
513
513
|
function roleRunArtifactsDirectory(runDirectory) {
|
|
514
514
|
return join4(runDirectory, "artifacts");
|
|
515
515
|
}
|
|
516
|
+
function isUnboundRunDirectory(runDirectory) {
|
|
517
|
+
return runDirectory.replaceAll("\\", "/").includes("/unbound/runs/");
|
|
518
|
+
}
|
|
516
519
|
function ensureRoleRunDirectory(ledgerHome, directory) {
|
|
517
520
|
return ensureRealDirectoryTree(ledgerHome, directory);
|
|
518
521
|
}
|
|
@@ -15789,6 +15792,7 @@ __export(config_exports, {
|
|
|
15789
15792
|
providerConfigured: () => providerConfigured,
|
|
15790
15793
|
publicCliConfigPath: () => publicCliConfigPath,
|
|
15791
15794
|
resolveEffectiveSeat: () => resolveEffectiveSeat,
|
|
15795
|
+
resolvePublicAgentDir: () => resolvePublicAgentDir,
|
|
15792
15796
|
resolvedSeatWithModel: () => resolvedSeatWithModel,
|
|
15793
15797
|
savePublicCliConfig: () => savePublicCliConfig,
|
|
15794
15798
|
setAutoResumeLimit: () => setAutoResumeLimit,
|
|
@@ -16268,6 +16272,9 @@ function credentialProvidersFromAuthData(data) {
|
|
|
16268
16272
|
xai: Object.prototype.hasOwnProperty.call(record4, "xai")
|
|
16269
16273
|
};
|
|
16270
16274
|
}
|
|
16275
|
+
function resolvePublicAgentDir(explicit, home) {
|
|
16276
|
+
return explicit ?? process.env.PI_CODING_AGENT_DIR ?? join8(home, ".pi", "agent");
|
|
16277
|
+
}
|
|
16271
16278
|
async function loadCredentialProviders(agentDir) {
|
|
16272
16279
|
try {
|
|
16273
16280
|
const raw = await readFile2(join8(agentDir, "auth.json"), "utf8");
|
|
@@ -16295,18 +16302,6 @@ var init_config2 = __esm({
|
|
|
16295
16302
|
});
|
|
16296
16303
|
|
|
16297
16304
|
// src/public-cli/host-providers.ts
|
|
16298
|
-
var host_providers_exports = {};
|
|
16299
|
-
__export(host_providers_exports, {
|
|
16300
|
-
HostProviderResolutionError: () => HostProviderResolutionError,
|
|
16301
|
-
hermesProviderModelsCachePath: () => hermesProviderModelsCachePath,
|
|
16302
|
-
hostCatalogOffersModel: () => hostCatalogOffersModel,
|
|
16303
|
-
hostProvidersPath: () => hostProvidersPath,
|
|
16304
|
-
listHermesProvidersForModel: () => listHermesProvidersForModel,
|
|
16305
|
-
loadHostProvidersTable: () => loadHostProvidersTable,
|
|
16306
|
-
parseHostProvidersTable: () => parseHostProvidersTable,
|
|
16307
|
-
projectHostFacingProvider: () => projectHostFacingProvider,
|
|
16308
|
-
renderHostProvidersTable: () => renderHostProvidersTable
|
|
16309
|
-
});
|
|
16310
16305
|
import { readFileSync } from "node:fs";
|
|
16311
16306
|
import { join as join9 } from "node:path";
|
|
16312
16307
|
function hostProvidersPath(home) {
|
|
@@ -19911,74 +19906,64 @@ async function writeRoleInvocationLedger(source, role, effectiveModel) {
|
|
|
19911
19906
|
);
|
|
19912
19907
|
}
|
|
19913
19908
|
async function recordEffectiveInvocationModel(runDirectory, model, engine, host, engineModel) {
|
|
19914
|
-
|
|
19915
|
-
|
|
19916
|
-
|
|
19917
|
-
|
|
19918
|
-
|
|
19919
|
-
|
|
19920
|
-
|
|
19921
|
-
|
|
19922
|
-
|
|
19923
|
-
|
|
19909
|
+
await updateDurableJsonPage(join19(runDirectory, "invocation.json"), (current) => {
|
|
19910
|
+
const next = { ...current };
|
|
19911
|
+
if (model !== void 0) {
|
|
19912
|
+
next.provider = model.provider;
|
|
19913
|
+
next.model = model.model;
|
|
19914
|
+
if (model.thinking === void 0) {
|
|
19915
|
+
delete next.thinking;
|
|
19916
|
+
} else {
|
|
19917
|
+
next.thinking = model.thinking;
|
|
19918
|
+
}
|
|
19924
19919
|
}
|
|
19925
|
-
|
|
19926
|
-
|
|
19927
|
-
|
|
19928
|
-
|
|
19929
|
-
|
|
19930
|
-
|
|
19931
|
-
|
|
19932
|
-
|
|
19933
|
-
|
|
19934
|
-
|
|
19935
|
-
|
|
19936
|
-
|
|
19937
|
-
|
|
19938
|
-
|
|
19939
|
-
|
|
19940
|
-
|
|
19941
|
-
|
|
19942
|
-
|
|
19943
|
-
|
|
19944
|
-
);
|
|
19920
|
+
if (engine === null) {
|
|
19921
|
+
delete next.engine;
|
|
19922
|
+
} else if (engine !== void 0) {
|
|
19923
|
+
next.engine = engine;
|
|
19924
|
+
}
|
|
19925
|
+
if (engineModel === null) {
|
|
19926
|
+
delete next.engineModel;
|
|
19927
|
+
} else if (engineModel !== void 0) {
|
|
19928
|
+
next.engineModel = engineModel;
|
|
19929
|
+
}
|
|
19930
|
+
if (host !== void 0) {
|
|
19931
|
+
next.host = host;
|
|
19932
|
+
}
|
|
19933
|
+
return next;
|
|
19934
|
+
});
|
|
19935
|
+
}
|
|
19936
|
+
async function updateDurableJsonPage(path, update) {
|
|
19937
|
+
const current = JSON.parse(await readFile12(path, "utf8"));
|
|
19938
|
+
const next = update(current);
|
|
19939
|
+
if (next === void 0) return;
|
|
19940
|
+
await writeFile3(path, `${JSON.stringify(next, null, 2)}
|
|
19941
|
+
`, "utf8");
|
|
19945
19942
|
}
|
|
19946
19943
|
async function mergeInvocationIdentityPage(runDirectory, fields) {
|
|
19947
|
-
|
|
19948
|
-
|
|
19949
|
-
|
|
19950
|
-
|
|
19951
|
-
`${JSON.stringify({
|
|
19952
|
-
...current,
|
|
19953
|
-
...fields
|
|
19954
|
-
}, null, 2)}
|
|
19955
|
-
`,
|
|
19956
|
-
"utf8"
|
|
19957
|
-
);
|
|
19944
|
+
await updateDurableJsonPage(join19(runDirectory, "invocation.json"), (current) => ({
|
|
19945
|
+
...current,
|
|
19946
|
+
...fields
|
|
19947
|
+
}));
|
|
19958
19948
|
}
|
|
19959
19949
|
async function persistAdmittedSourceRunPath(admitted, sourceRunPath, auditorSubject) {
|
|
19960
19950
|
if (sourceRunPath.trim() === "") {
|
|
19961
19951
|
throw new Error("persistAdmittedSourceRunPath requires a non-empty sourceRunPath");
|
|
19962
19952
|
}
|
|
19963
|
-
|
|
19964
|
-
|
|
19965
|
-
|
|
19966
|
-
|
|
19967
|
-
|
|
19968
|
-
|
|
19969
|
-
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
await writeFile3(
|
|
19973
|
-
admittedPath,
|
|
19974
|
-
`${JSON.stringify({
|
|
19953
|
+
await updateDurableJsonPage(admitted.admittedRequestPath, (current) => {
|
|
19954
|
+
if (typeof current.sourceRunPath === "string" && current.sourceRunPath !== sourceRunPath) {
|
|
19955
|
+
throw new Error(
|
|
19956
|
+
`persistAdmittedSourceRunPath refuses to replace ${current.sourceRunPath} with ${sourceRunPath}`
|
|
19957
|
+
);
|
|
19958
|
+
}
|
|
19959
|
+
const sameSubject = auditorSubject === void 0 || current.auditorSubject === auditorSubject;
|
|
19960
|
+
if (current.sourceRunPath === sourceRunPath && sameSubject) return void 0;
|
|
19961
|
+
return {
|
|
19975
19962
|
...current,
|
|
19976
19963
|
sourceRunPath,
|
|
19977
19964
|
...auditorSubject === void 0 ? {} : { auditorSubject }
|
|
19978
|
-
}
|
|
19979
|
-
|
|
19980
|
-
"utf8"
|
|
19981
|
-
);
|
|
19965
|
+
};
|
|
19966
|
+
});
|
|
19982
19967
|
}
|
|
19983
19968
|
async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
19984
19969
|
if (admitted.ticketNumber === ticketNumber) return;
|
|
@@ -19986,22 +19971,17 @@ async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
|
19986
19971
|
admitted.ticketNumber = ticketNumber;
|
|
19987
19972
|
}
|
|
19988
19973
|
async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
19989
|
-
|
|
19990
|
-
|
|
19991
|
-
|
|
19992
|
-
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
|
|
19996
|
-
|
|
19997
|
-
|
|
19998
|
-
|
|
19999
|
-
|
|
20000
|
-
admitted.admittedRequestPath,
|
|
20001
|
-
`${JSON.stringify({ ...current, correlationId, correlationIds }, null, 2)}
|
|
20002
|
-
`,
|
|
20003
|
-
"utf8"
|
|
20004
|
-
);
|
|
19974
|
+
let correlationIds = [];
|
|
19975
|
+
await updateDurableJsonPage(admitted.admittedRequestPath, (current) => {
|
|
19976
|
+
const prior = [
|
|
19977
|
+
...Array.isArray(current.correlationIds) ? current.correlationIds.filter(
|
|
19978
|
+
(value) => typeof value === "string" && value.trim() !== ""
|
|
19979
|
+
) : [],
|
|
19980
|
+
...typeof current.correlationId === "string" && current.correlationId.trim() !== "" ? [current.correlationId] : []
|
|
19981
|
+
];
|
|
19982
|
+
correlationIds = [.../* @__PURE__ */ new Set([...prior, correlationId])];
|
|
19983
|
+
return { ...current, correlationId, correlationIds };
|
|
19984
|
+
});
|
|
20005
19985
|
await mergeInvocationIdentityPage(admitted.runDirectory, {
|
|
20006
19986
|
correlationId,
|
|
20007
19987
|
correlationIds
|
|
@@ -20011,7 +19991,7 @@ async function recordAdmittedCorrelation(admitted, correlationId) {
|
|
|
20011
19991
|
mutable.correlationIds = correlationIds;
|
|
20012
19992
|
}
|
|
20013
19993
|
async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
20014
|
-
if (admitted.ticketNumber === void 0 || !admitted.runDirectory
|
|
19994
|
+
if (admitted.ticketNumber === void 0 || !isUnboundRunDirectory(admitted.runDirectory)) return void 0;
|
|
20015
19995
|
const oldRunDirectory = admitted.runDirectory;
|
|
20016
19996
|
const ledgerHome = resolveActivationLedgerHome(homeFromRunDirectory(oldRunDirectory));
|
|
20017
19997
|
const target = roleRunPlacement(ledgerHome, {
|
|
@@ -20073,11 +20053,11 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
20073
20053
|
return { oldRunDirectory, newRunDirectory: target.runDirectory };
|
|
20074
20054
|
}
|
|
20075
20055
|
async function recordChildDiaristRun(parent, childRunId) {
|
|
20076
|
-
|
|
20077
|
-
|
|
20078
|
-
|
|
20079
|
-
|
|
20080
|
-
|
|
20056
|
+
await updateDurableJsonPage(parent.admittedRequestPath, (page) => {
|
|
20057
|
+
const existing = Array.isArray(page.childDiaristRunIds) ? page.childDiaristRunIds.filter((runId) => typeof runId === "string") : [];
|
|
20058
|
+
const childDiaristRunIds = existing.includes(childRunId) ? existing : [...existing, childRunId];
|
|
20059
|
+
return { ...page, childDiaristRunIds };
|
|
20060
|
+
});
|
|
20081
20061
|
}
|
|
20082
20062
|
async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
20083
20063
|
requireSafePositiveTicketNumber(
|
|
@@ -20085,14 +20065,15 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
20085
20065
|
"bindTicketNumberOnRunDirectory"
|
|
20086
20066
|
);
|
|
20087
20067
|
const admittedPath = join19(runDirectory, "admitted-request.json");
|
|
20088
|
-
|
|
20089
|
-
|
|
20090
|
-
|
|
20091
|
-
|
|
20092
|
-
|
|
20093
|
-
|
|
20094
|
-
|
|
20095
|
-
);
|
|
20068
|
+
let unchanged = false;
|
|
20069
|
+
await updateDurableJsonPage(admittedPath, (admitted) => {
|
|
20070
|
+
if (admitted.ticketNumber === ticketNumber) {
|
|
20071
|
+
unchanged = true;
|
|
20072
|
+
return void 0;
|
|
20073
|
+
}
|
|
20074
|
+
return { ...admitted, ticketNumber };
|
|
20075
|
+
});
|
|
20076
|
+
if (unchanged) return;
|
|
20096
20077
|
await mergeInvocationIdentityPage(runDirectory, { ticketNumber });
|
|
20097
20078
|
}
|
|
20098
20079
|
async function recordLaunchedPiIdentity(runDirectory, identity) {
|
|
@@ -20314,18 +20295,22 @@ function requireOptionPath(flag, value) {
|
|
|
20314
20295
|
}
|
|
20315
20296
|
return value;
|
|
20316
20297
|
}
|
|
20298
|
+
function skillArgTokenFault(value) {
|
|
20299
|
+
if (value === void 0 || value.trim() === "") return "empty";
|
|
20300
|
+
if (/\s/.test(value)) return "whitespace";
|
|
20301
|
+
if (value.startsWith("-")) return "optionLike";
|
|
20302
|
+
return void 0;
|
|
20303
|
+
}
|
|
20317
20304
|
function requireSkillArgToken(value, messages) {
|
|
20318
|
-
|
|
20319
|
-
|
|
20320
|
-
}
|
|
20321
|
-
if (/\s/.test(value)) {
|
|
20322
|
-
throw new CliUsageError(messages.whitespace);
|
|
20323
|
-
}
|
|
20324
|
-
if (value.startsWith("-")) {
|
|
20325
|
-
throw new CliUsageError(messages.optionLike);
|
|
20326
|
-
}
|
|
20305
|
+
const fault = skillArgTokenFault(value);
|
|
20306
|
+
if (fault !== void 0) throw new CliUsageError(messages[fault]);
|
|
20327
20307
|
return value;
|
|
20328
20308
|
}
|
|
20309
|
+
function admittedReviewerBaseFault(value) {
|
|
20310
|
+
const fault = skillArgTokenFault(value);
|
|
20311
|
+
if (fault === void 0) return void 0;
|
|
20312
|
+
return fault === "empty" ? "missing" : "damaged";
|
|
20313
|
+
}
|
|
20329
20314
|
function requireReviewerBaseRevision(value) {
|
|
20330
20315
|
return requireSkillArgToken(value, {
|
|
20331
20316
|
empty: "--base requires a nonempty revision",
|
|
@@ -20553,9 +20538,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20553
20538
|
});
|
|
20554
20539
|
}
|
|
20555
20540
|
case "worker-packet": {
|
|
20556
|
-
if (parsed.project !== void 0) {
|
|
20557
|
-
requireOptionPath("--project", parsed.project);
|
|
20558
|
-
}
|
|
20559
20541
|
if (instruction.trim() === "") {
|
|
20560
20542
|
throw new CliUsageError("fixer requires a nonblank repair instruction");
|
|
20561
20543
|
}
|
|
@@ -20612,18 +20594,7 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20612
20594
|
});
|
|
20613
20595
|
}
|
|
20614
20596
|
case "collect-target": {
|
|
20615
|
-
|
|
20616
|
-
requireOptionPath("--project", parsed.project);
|
|
20617
|
-
}
|
|
20618
|
-
let explicitPrNumber;
|
|
20619
|
-
if (parsed.prNumber !== void 0) {
|
|
20620
|
-
try {
|
|
20621
|
-
explicitPrNumber = parseCollectorPrNumber(parsed.prNumber);
|
|
20622
|
-
} catch (error) {
|
|
20623
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
20624
|
-
throw new CliUsageError(detail, { cause: error });
|
|
20625
|
-
}
|
|
20626
|
-
}
|
|
20597
|
+
const explicitPrNumber = parsed.prNumber;
|
|
20627
20598
|
const projectRoot = resolve9(parsed.project ?? shared.cwd);
|
|
20628
20599
|
let repository;
|
|
20629
20600
|
if (parsed.repo !== void 0) {
|
|
@@ -20673,15 +20644,12 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20673
20644
|
return { ...admittedCollector, repository };
|
|
20674
20645
|
}
|
|
20675
20646
|
case "case-identity": {
|
|
20676
|
-
if (parsed.
|
|
20677
|
-
requireOptionPath("--project", parsed.project);
|
|
20678
|
-
}
|
|
20679
|
-
const issueNumber = parsed.issueNumber ?? Number.NaN;
|
|
20680
|
-
if (!Number.isInteger(issueNumber) || issueNumber < 1 || !DOCTOR_ISSUE_NUMBER_PATTERN.test(String(issueNumber))) {
|
|
20647
|
+
if (parsed.issueNumber === void 0) {
|
|
20681
20648
|
throw new CliUsageError(
|
|
20682
|
-
`doctor --issue must be a positive integer, got ${
|
|
20649
|
+
`doctor --issue must be a positive integer, got ${Number.NaN}`
|
|
20683
20650
|
);
|
|
20684
20651
|
}
|
|
20652
|
+
const issueNumber = parsed.issueNumber;
|
|
20685
20653
|
let frozenAttachments = [];
|
|
20686
20654
|
const admittedDoctor = await admitStandardMaterialInvocation("doctor", {
|
|
20687
20655
|
...shared,
|
|
@@ -20737,22 +20705,21 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20737
20705
|
return { ...admittedDoctor, attachments: frozenAttachments };
|
|
20738
20706
|
}
|
|
20739
20707
|
case "source-locator": {
|
|
20740
|
-
if (parsed.project !== void 0) {
|
|
20741
|
-
requireOptionPath("--project", parsed.project);
|
|
20742
|
-
}
|
|
20743
20708
|
const projectRoot = resolve9(parsed.project ?? shared.cwd);
|
|
20744
|
-
let sourceRun;
|
|
20745
|
-
|
|
20746
|
-
|
|
20747
|
-
|
|
20748
|
-
|
|
20749
|
-
|
|
20750
|
-
|
|
20751
|
-
|
|
20752
|
-
|
|
20753
|
-
|
|
20709
|
+
let sourceRun = override?.resolvedSourceRun;
|
|
20710
|
+
if (sourceRun === void 0) {
|
|
20711
|
+
try {
|
|
20712
|
+
sourceRun = await resolveNotarySourceRunLocator({
|
|
20713
|
+
projectRoot,
|
|
20714
|
+
sourceRun: parsed.sourceRun ?? "",
|
|
20715
|
+
home: shared.home
|
|
20716
|
+
});
|
|
20717
|
+
} catch (error) {
|
|
20718
|
+
if (error instanceof NotarySourceRunError) {
|
|
20719
|
+
throw new CliUsageError(error.message, { cause: error });
|
|
20720
|
+
}
|
|
20721
|
+
throw error;
|
|
20754
20722
|
}
|
|
20755
|
-
throw error;
|
|
20756
20723
|
}
|
|
20757
20724
|
const inheritedTicketNumber = await readBoardTicketNumber(sourceRun.runDirectory);
|
|
20758
20725
|
const knownTicketNumber = inheritedTicketNumber ?? shared.assertedTicketNumber;
|
|
@@ -20770,9 +20737,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20770
20737
|
});
|
|
20771
20738
|
}
|
|
20772
20739
|
case "gleaner": {
|
|
20773
|
-
if (parsed.project !== void 0) {
|
|
20774
|
-
requireOptionPath("--project", parsed.project);
|
|
20775
|
-
}
|
|
20776
20740
|
const baseRevision = parsed.baseRevision ?? "";
|
|
20777
20741
|
if (baseRevision.trim() === "") {
|
|
20778
20742
|
throw new CliUsageError("--base requires a nonempty revision");
|
|
@@ -20787,16 +20751,19 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20787
20751
|
});
|
|
20788
20752
|
}
|
|
20789
20753
|
case "review-basis": {
|
|
20790
|
-
|
|
20791
|
-
|
|
20792
|
-
|
|
20754
|
+
if (parsed.lens === void 0) {
|
|
20755
|
+
throw new CliUsageError("--lens requires completeness or correctness");
|
|
20756
|
+
}
|
|
20757
|
+
if (parsed.baseRevision === void 0) {
|
|
20758
|
+
throw new CliUsageError("--base requires a nonempty revision");
|
|
20793
20759
|
}
|
|
20794
|
-
const baseRevision = requireReviewerBaseRevision(parsed.baseRevision);
|
|
20795
20760
|
const rawRefs = parsed.authorityRefs ?? [];
|
|
20796
20761
|
if (rawRefs.length === 0) {
|
|
20797
20762
|
throw new CliUsageError("reviewer requires --authority-ref <ref>");
|
|
20798
20763
|
}
|
|
20799
|
-
const
|
|
20764
|
+
const lens = parsed.lens;
|
|
20765
|
+
const baseRevision = parsed.baseRevision;
|
|
20766
|
+
const authorityRefs = Object.freeze([...rawRefs]);
|
|
20800
20767
|
const admittedReviewer = await admitStandardMaterialInvocation("reviewer", {
|
|
20801
20768
|
...shared,
|
|
20802
20769
|
instruction,
|
|
@@ -20811,9 +20778,6 @@ async function admitPublicRole(role, parsed, env, override) {
|
|
|
20811
20778
|
return { ...admittedReviewer, authorityRefs };
|
|
20812
20779
|
}
|
|
20813
20780
|
case "merge-envelope": {
|
|
20814
|
-
if (parsed.project !== void 0) {
|
|
20815
|
-
requireOptionPath("--project", parsed.project);
|
|
20816
|
-
}
|
|
20817
20781
|
if (instruction.trim() === "") {
|
|
20818
20782
|
throw new CliUsageError("merger requires a nonblank task instruction");
|
|
20819
20783
|
}
|
|
@@ -20875,9 +20839,6 @@ function admissionSubject(ticketNumber) {
|
|
|
20875
20839
|
return { ticketNumber: fields.ticketNumber };
|
|
20876
20840
|
}
|
|
20877
20841
|
async function placeRoleAdmission(options) {
|
|
20878
|
-
if (options.project !== void 0) {
|
|
20879
|
-
requireOptionPath("--project", options.project);
|
|
20880
|
-
}
|
|
20881
20842
|
const projectRoot = resolve9(options.project ?? options.cwd);
|
|
20882
20843
|
const runId = options.runId ?? (options.createRunId ?? uuidv7)();
|
|
20883
20844
|
const ticketFields = ticketAdmissionFields(options.assertedTicketNumber);
|
|
@@ -21243,11 +21204,11 @@ function parseAnalystCohortIssueToken(raw, flag) {
|
|
|
21243
21204
|
`${flag} requires a comma-separated list of N or book:N`
|
|
21244
21205
|
);
|
|
21245
21206
|
}
|
|
21246
|
-
const
|
|
21247
|
-
if (
|
|
21248
|
-
const rhs = trimmed.slice(
|
|
21207
|
+
const sep5 = trimmed.lastIndexOf(":");
|
|
21208
|
+
if (sep5 > 0) {
|
|
21209
|
+
const rhs = trimmed.slice(sep5 + 1);
|
|
21249
21210
|
if (ANALYST_TICKET_NUMBER_PATTERN.test(rhs)) {
|
|
21250
|
-
const bookKey = trimmed.slice(0,
|
|
21211
|
+
const bookKey = trimmed.slice(0, sep5);
|
|
21251
21212
|
if (bookKey.trim() === "") {
|
|
21252
21213
|
throw new CliUsageError(
|
|
21253
21214
|
`${flag} book:N requires a non-empty book key, got ${raw}`
|
|
@@ -21627,6 +21588,48 @@ var init_role_turn_host_resolution = __esm({
|
|
|
21627
21588
|
}
|
|
21628
21589
|
});
|
|
21629
21590
|
|
|
21591
|
+
// src/public-cli/role-seat-runtime.ts
|
|
21592
|
+
var role_seat_runtime_exports = {};
|
|
21593
|
+
__export(role_seat_runtime_exports, {
|
|
21594
|
+
openRoleSeatRuntime: () => openRoleSeatRuntime
|
|
21595
|
+
});
|
|
21596
|
+
function openRoleSeatRuntime(input) {
|
|
21597
|
+
const hostAdapters = composeRoleTurnHostAdapters(
|
|
21598
|
+
input.resolution,
|
|
21599
|
+
input.principalAuthority
|
|
21600
|
+
);
|
|
21601
|
+
const roleTurnHost = selectRoleTurnHost(hostAdapters, {
|
|
21602
|
+
role: input.role,
|
|
21603
|
+
seat: input.seat
|
|
21604
|
+
});
|
|
21605
|
+
input.afterHost?.();
|
|
21606
|
+
const seatWithModel = resolvedSeatWithModel(input.seat);
|
|
21607
|
+
if (seatWithModel === void 0) return { ok: false };
|
|
21608
|
+
const projected = input.hostFacingModel ?? projectHostFacingProvider(
|
|
21609
|
+
seatWithModel.selection,
|
|
21610
|
+
seatWithModel.host,
|
|
21611
|
+
loadHostProvidersTable(input.home),
|
|
21612
|
+
input.home
|
|
21613
|
+
);
|
|
21614
|
+
return {
|
|
21615
|
+
ok: true,
|
|
21616
|
+
roleTurnHost,
|
|
21617
|
+
hostAdapters,
|
|
21618
|
+
...projected === void 0 ? {} : { model: projected },
|
|
21619
|
+
...pickEngineAxis(seatWithModel),
|
|
21620
|
+
host: seatWithModel.host
|
|
21621
|
+
};
|
|
21622
|
+
}
|
|
21623
|
+
var init_role_seat_runtime = __esm({
|
|
21624
|
+
"src/public-cli/role-seat-runtime.ts"() {
|
|
21625
|
+
"use strict";
|
|
21626
|
+
init_engine_material();
|
|
21627
|
+
init_config2();
|
|
21628
|
+
init_host_providers();
|
|
21629
|
+
init_role_turn_host_resolution();
|
|
21630
|
+
}
|
|
21631
|
+
});
|
|
21632
|
+
|
|
21630
21633
|
// src/analyst-gate-cycles-read.ts
|
|
21631
21634
|
import { readdir as readdir4 } from "node:fs/promises";
|
|
21632
21635
|
import { join as join22 } from "node:path";
|
|
@@ -24899,6 +24902,16 @@ var init_seat_ticket_binding = __esm({
|
|
|
24899
24902
|
});
|
|
24900
24903
|
|
|
24901
24904
|
// src/public-cli/turn-request.ts
|
|
24905
|
+
function projectPublicTurnAxes(env) {
|
|
24906
|
+
return {
|
|
24907
|
+
packageRoot: env.packageRoot,
|
|
24908
|
+
home: env.home,
|
|
24909
|
+
agentDir: env.agentDir,
|
|
24910
|
+
...env.model === void 0 ? {} : { model: env.model },
|
|
24911
|
+
...pickEngineAxis(env),
|
|
24912
|
+
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs }
|
|
24913
|
+
};
|
|
24914
|
+
}
|
|
24902
24915
|
function projectRoleTurnRequest(admitted, roleDetails, options) {
|
|
24903
24916
|
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
24904
24917
|
if (cwd === void 0) throw new Error("admitted invocation missing working directory");
|
|
@@ -25105,7 +25118,7 @@ __export(instruction_seat_run_exports, {
|
|
|
25105
25118
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
25106
25119
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
25107
25120
|
});
|
|
25108
|
-
import { dirname as dirname17, resolve as resolve11
|
|
25121
|
+
import { dirname as dirname17, resolve as resolve11 } from "node:path";
|
|
25109
25122
|
function unreadablePostSubmissionStatus(admitted, terminal) {
|
|
25110
25123
|
if (terminal?.roleOutcome.kind !== "accepted") return void 0;
|
|
25111
25124
|
const route = POST_SUBMISSION_ROUTING[admitted.role];
|
|
@@ -25337,27 +25350,43 @@ async function runOmittedLensBatch(argv2, parsed, env, io) {
|
|
|
25337
25350
|
io.stdout(formatTerminalResult(terminal));
|
|
25338
25351
|
return { exitCode: failed ? 1 : 0, terminal };
|
|
25339
25352
|
}
|
|
25353
|
+
function resumeSameParentInstructionSeat(input) {
|
|
25354
|
+
return tryResumeSameTicketSeatRun({
|
|
25355
|
+
home: input.env.home,
|
|
25356
|
+
projectRoot: input.projectRoot,
|
|
25357
|
+
role: input.role,
|
|
25358
|
+
parentRunPath: input.parentRunPath,
|
|
25359
|
+
...input.ticketNumber === void 0 ? {} : { ticketNumber: input.ticketNumber },
|
|
25360
|
+
freshSummons: input.env.freshSummons,
|
|
25361
|
+
summons: input.summons,
|
|
25362
|
+
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25363
|
+
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25364
|
+
input.env,
|
|
25365
|
+
input.io
|
|
25366
|
+
)
|
|
25367
|
+
});
|
|
25368
|
+
}
|
|
25369
|
+
function sameParentInstruction(env, fallback) {
|
|
25370
|
+
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
25371
|
+
if (resumeInstruction === void 0) return fallback;
|
|
25372
|
+
return { instruction: resumeInstruction, instructionEmpty: false };
|
|
25373
|
+
}
|
|
25340
25374
|
async function runCountersignBody(parsed, env, io) {
|
|
25341
25375
|
const gateParentRunPath = typeof env.parentRunPath === "string" && env.parentRunPath.trim() !== "" ? env.parentRunPath : void 0;
|
|
25342
25376
|
if (gateParentRunPath !== void 0) {
|
|
25343
25377
|
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction ?? parsed.instruction ?? "";
|
|
25344
|
-
const resumed = await
|
|
25345
|
-
|
|
25378
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
25379
|
+
env,
|
|
25380
|
+
io,
|
|
25346
25381
|
projectRoot: resolve11(parsed.project ?? env.cwd),
|
|
25347
25382
|
role: "countersign",
|
|
25348
25383
|
parentRunPath: gateParentRunPath,
|
|
25349
25384
|
...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
|
|
25350
|
-
freshSummons: env.freshSummons,
|
|
25351
25385
|
summons: {
|
|
25352
25386
|
sourceRunPath: gateParentRunPath,
|
|
25353
25387
|
instruction: resumeInstruction,
|
|
25354
25388
|
instructionEmpty: resumeInstruction.trim() === ""
|
|
25355
|
-
}
|
|
25356
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25357
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25358
|
-
env,
|
|
25359
|
-
io
|
|
25360
|
-
)
|
|
25389
|
+
}
|
|
25361
25390
|
});
|
|
25362
25391
|
if (resumed != null) return resumed;
|
|
25363
25392
|
}
|
|
@@ -25389,12 +25418,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
25389
25418
|
admitted = { ...admitted, sourceRunPath: gateParentRunPath };
|
|
25390
25419
|
}
|
|
25391
25420
|
const turnProjection = {
|
|
25392
|
-
|
|
25393
|
-
home: env.home,
|
|
25394
|
-
agentDir: env.agentDir,
|
|
25395
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
25396
|
-
...pickEngineAxis(env),
|
|
25397
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
25421
|
+
...projectPublicTurnAxes(env),
|
|
25398
25422
|
...env.correlationId === void 0 || env.correlationId.trim() === "" ? {} : { correlationId: env.correlationId },
|
|
25399
25423
|
continuation: {
|
|
25400
25424
|
kind: "initial",
|
|
@@ -25465,17 +25489,18 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25465
25489
|
let auditorSubject;
|
|
25466
25490
|
let auditorSource;
|
|
25467
25491
|
let auditorTicket;
|
|
25492
|
+
let resolvedNotarySource;
|
|
25468
25493
|
if (record4.sameParent === "subject-source") {
|
|
25469
|
-
if (
|
|
25494
|
+
if (parsed.subject === void 0) {
|
|
25470
25495
|
presentStructuralRejection(new CliUsageError("auditor --subject requires judge|doctor"), io);
|
|
25471
25496
|
return { exitCode: 2 };
|
|
25472
25497
|
}
|
|
25473
25498
|
auditorSubject = parsed.subject;
|
|
25474
|
-
|
|
25475
|
-
if (source === "") {
|
|
25499
|
+
if (parsed.sourceRun === void 0) {
|
|
25476
25500
|
presentStructuralRejection(new CliUsageError("auditor --source-run requires a run locator"), io);
|
|
25477
25501
|
return { exitCode: 2 };
|
|
25478
25502
|
}
|
|
25503
|
+
const source = parsed.sourceRun;
|
|
25479
25504
|
try {
|
|
25480
25505
|
const resolved = await resolveNotarySourceRunLocator({ projectRoot, sourceRun: source, home: env.home });
|
|
25481
25506
|
auditorSource = resolved.runDirectory;
|
|
@@ -25486,26 +25511,23 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25486
25511
|
}
|
|
25487
25512
|
if (auditorSource === void 0) return { exitCode: 2 };
|
|
25488
25513
|
const sourceDirectory = auditorSource;
|
|
25489
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
25490
25514
|
const summons = {
|
|
25491
|
-
...
|
|
25515
|
+
...sameParentInstruction(env, {
|
|
25516
|
+
instruction: parsed.instruction ?? "",
|
|
25517
|
+
instructionEmpty: (parsed.instruction ?? "").trim() === ""
|
|
25518
|
+
}),
|
|
25492
25519
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
25493
25520
|
};
|
|
25494
25521
|
const resumed = await withAuditorSoulEnv({
|
|
25495
25522
|
subject: auditorSubject,
|
|
25496
25523
|
sourceRunDirectory: auditorSource,
|
|
25497
|
-
run: () =>
|
|
25498
|
-
|
|
25524
|
+
run: () => resumeSameParentInstructionSeat({
|
|
25525
|
+
env,
|
|
25526
|
+
io,
|
|
25499
25527
|
projectRoot,
|
|
25500
25528
|
role,
|
|
25501
25529
|
parentRunPath: sourceDirectory,
|
|
25502
|
-
|
|
25503
|
-
summons,
|
|
25504
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25505
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25506
|
-
env,
|
|
25507
|
-
io
|
|
25508
|
-
)
|
|
25530
|
+
summons
|
|
25509
25531
|
})
|
|
25510
25532
|
});
|
|
25511
25533
|
if (resumed != null) return resumed;
|
|
@@ -25513,24 +25535,21 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25513
25535
|
if (record4.sameParent === "gate-pointer") {
|
|
25514
25536
|
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction ?? "");
|
|
25515
25537
|
if (parentRunPath !== void 0) {
|
|
25516
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
25517
25538
|
const summons = {
|
|
25518
25539
|
sourceRunPath: parentRunPath,
|
|
25519
|
-
...
|
|
25540
|
+
...sameParentInstruction(env, {
|
|
25541
|
+
instruction: parsed.instruction ?? "",
|
|
25542
|
+
instructionEmpty: (parsed.instruction ?? "").trim() === ""
|
|
25543
|
+
}),
|
|
25520
25544
|
attachmentPaths: parsed.attachmentPaths ?? []
|
|
25521
25545
|
};
|
|
25522
|
-
const resumed = await
|
|
25523
|
-
|
|
25546
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
25547
|
+
env,
|
|
25548
|
+
io,
|
|
25524
25549
|
projectRoot,
|
|
25525
25550
|
role,
|
|
25526
25551
|
parentRunPath,
|
|
25527
|
-
|
|
25528
|
-
summons,
|
|
25529
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25530
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25531
|
-
env,
|
|
25532
|
-
io
|
|
25533
|
-
)
|
|
25552
|
+
summons
|
|
25534
25553
|
});
|
|
25535
25554
|
if (resumed != null) return resumed;
|
|
25536
25555
|
}
|
|
@@ -25556,28 +25575,28 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25556
25575
|
sourceRun: source,
|
|
25557
25576
|
...resumeInstruction === void 0 ? {} : { instruction: resumeInstruction, instructionEmpty: false }
|
|
25558
25577
|
};
|
|
25559
|
-
|
|
25560
|
-
|
|
25578
|
+
resolvedNotarySource = source;
|
|
25579
|
+
const resumed = await resumeSameParentInstructionSeat({
|
|
25580
|
+
env,
|
|
25581
|
+
io,
|
|
25561
25582
|
projectRoot,
|
|
25562
25583
|
role,
|
|
25563
25584
|
parentRunPath: source.runDirectory,
|
|
25564
|
-
|
|
25565
|
-
summons,
|
|
25566
|
-
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
25567
|
-
{ runId, ...materials === void 0 ? {} : { summons: materials } },
|
|
25568
|
-
env,
|
|
25569
|
-
io
|
|
25570
|
-
)
|
|
25585
|
+
summons
|
|
25571
25586
|
});
|
|
25572
25587
|
if (resumed != null) return resumed;
|
|
25573
25588
|
}
|
|
25574
25589
|
let admitted;
|
|
25575
25590
|
try {
|
|
25591
|
+
const admissionOverride = {
|
|
25592
|
+
...auditorTicket === void 0 ? {} : { assertedTicketNumber: auditorTicket },
|
|
25593
|
+
...resolvedNotarySource === void 0 ? {} : { resolvedSourceRun: resolvedNotarySource }
|
|
25594
|
+
};
|
|
25576
25595
|
admitted = await admitPublicRole(
|
|
25577
25596
|
role,
|
|
25578
25597
|
parsed,
|
|
25579
25598
|
env,
|
|
25580
|
-
auditorTicket === void 0
|
|
25599
|
+
auditorTicket === void 0 && resolvedNotarySource === void 0 ? void 0 : admissionOverride
|
|
25581
25600
|
);
|
|
25582
25601
|
} catch (error) {
|
|
25583
25602
|
const rejected = usageExit(error, io);
|
|
@@ -25615,7 +25634,7 @@ async function runPublicInstructionSeat(argv2, env, io, role, parseArgv2) {
|
|
|
25615
25634
|
thrown: error
|
|
25616
25635
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
25617
25636
|
}
|
|
25618
|
-
if (outcome.admitted
|
|
25637
|
+
if (outcome.admitted !== void 0 && isUnboundRunDirectory(outcome.admitted.runDirectory)) {
|
|
25619
25638
|
await recordChildDiaristRun(admitted, outcome.admitted.runId);
|
|
25620
25639
|
}
|
|
25621
25640
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
@@ -25964,6 +25983,7 @@ var AUDITED_ROLES, SECRETARIAT_STATUS_REASK, COUNTERSIGN_STATUS_REASK, WORKER_RO
|
|
|
25964
25983
|
var init_instruction_seat_run = __esm({
|
|
25965
25984
|
"src/public-cli/instruction-seat-run.ts"() {
|
|
25966
25985
|
"use strict";
|
|
25986
|
+
init_role_run_placement();
|
|
25967
25987
|
init_compliance_transport();
|
|
25968
25988
|
init_archivist_record_pointer();
|
|
25969
25989
|
init_doctor_auditor();
|
|
@@ -26112,12 +26132,6 @@ async function resolveSummonHome(options) {
|
|
|
26112
26132
|
if (fromCwd !== void 0 && fromCwd.length > 0) return fromCwd;
|
|
26113
26133
|
return packageMachineHome2();
|
|
26114
26134
|
}
|
|
26115
|
-
function projectSeatEngine(seat) {
|
|
26116
|
-
return pickEngineAxis(seat);
|
|
26117
|
-
}
|
|
26118
|
-
function projectSeatHost(seat) {
|
|
26119
|
-
return seat.host === void 0 ? {} : { host: seat.host };
|
|
26120
|
-
}
|
|
26121
26135
|
function hostSelectionFailureFromUnknown(error) {
|
|
26122
26136
|
if (typeof error !== "object" || error === null) return void 0;
|
|
26123
26137
|
if (error.name !== "HostSelectionError") return void 0;
|
|
@@ -26128,44 +26142,36 @@ async function createSummonEnv(options, afterHost) {
|
|
|
26128
26142
|
const [
|
|
26129
26143
|
{ piDurablePrincipalAuthority: piDurablePrincipalAuthority2 },
|
|
26130
26144
|
{ appendPiSessionCustomEntry: appendPiSessionCustomEntry2 },
|
|
26131
|
-
{
|
|
26132
|
-
{ missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2
|
|
26145
|
+
{ openRoleSeatRuntime: openRoleSeatRuntime2 },
|
|
26146
|
+
{ missingResolvedSeatModelMessage: missingResolvedSeatModelMessage2 }
|
|
26133
26147
|
] = await Promise.all([
|
|
26134
26148
|
Promise.resolve().then(() => (init_durable_principal(), durable_principal_exports)),
|
|
26135
26149
|
Promise.resolve().then(() => (init_role_turn_host(), role_turn_host_exports)),
|
|
26136
|
-
Promise.resolve().then(() => (
|
|
26150
|
+
Promise.resolve().then(() => (init_role_seat_runtime(), role_seat_runtime_exports)),
|
|
26137
26151
|
Promise.resolve().then(() => (init_config2(), config_exports))
|
|
26138
26152
|
]);
|
|
26139
26153
|
const principalAuthority = options.principalAuthority ?? piDurablePrincipalAuthority2;
|
|
26140
|
-
const
|
|
26141
|
-
{
|
|
26154
|
+
const opened = openRoleSeatRuntime2({
|
|
26155
|
+
resolution: {
|
|
26142
26156
|
packageRoot: options.packageRoot,
|
|
26143
26157
|
...options.roleTurnHost === void 0 ? {} : { roleTurnHost: options.roleTurnHost },
|
|
26144
26158
|
...options.hostAdapters === void 0 ? {} : { hostAdapters: options.hostAdapters },
|
|
26145
26159
|
...options.extraPiArgs === void 0 || options.extraPiArgs.length === 0 ? {} : { extraPiArgs: options.extraPiArgs },
|
|
26146
26160
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
26147
26161
|
},
|
|
26148
|
-
|
|
26149
|
-
|
|
26150
|
-
|
|
26151
|
-
|
|
26152
|
-
|
|
26162
|
+
principalAuthority,
|
|
26163
|
+
role: options.role,
|
|
26164
|
+
seat: options.seat,
|
|
26165
|
+
home: options.home,
|
|
26166
|
+
...afterHost === void 0 ? {} : { afterHost },
|
|
26167
|
+
...options.hostFacingModel === void 0 ? {} : { hostFacingModel: options.hostFacingModel }
|
|
26168
|
+
});
|
|
26169
|
+
if (!opened.ok) {
|
|
26153
26170
|
return {
|
|
26154
26171
|
ok: false,
|
|
26155
26172
|
missingModelMessage: missingResolvedSeatModelMessage2(options.role)
|
|
26156
26173
|
};
|
|
26157
26174
|
}
|
|
26158
|
-
const hostName = seatWithModel.host ?? "pi";
|
|
26159
|
-
let hostFacingSelection = options.hostFacingModel;
|
|
26160
|
-
if (hostFacingSelection === void 0) {
|
|
26161
|
-
const { loadHostProvidersTable: loadHostProvidersTable2, projectHostFacingProvider: projectHostFacingProvider2 } = await Promise.resolve().then(() => (init_host_providers(), host_providers_exports));
|
|
26162
|
-
hostFacingSelection = projectHostFacingProvider2(
|
|
26163
|
-
seatWithModel.selection,
|
|
26164
|
-
hostName,
|
|
26165
|
-
loadHostProvidersTable2(options.home),
|
|
26166
|
-
options.home
|
|
26167
|
-
);
|
|
26168
|
-
}
|
|
26169
26175
|
return {
|
|
26170
26176
|
ok: true,
|
|
26171
26177
|
env: {
|
|
@@ -26174,12 +26180,13 @@ async function createSummonEnv(options, afterHost) {
|
|
|
26174
26180
|
agentDir: options.agentDir,
|
|
26175
26181
|
sessionAppender: appendPiSessionCustomEntry2,
|
|
26176
26182
|
packageRoot: options.packageRoot,
|
|
26177
|
-
roleTurnHost,
|
|
26183
|
+
roleTurnHost: opened.roleTurnHost,
|
|
26178
26184
|
cwd: options.cwd,
|
|
26179
26185
|
credentials: options.credentials,
|
|
26180
|
-
...
|
|
26181
|
-
...
|
|
26182
|
-
...
|
|
26186
|
+
...opened.model === void 0 ? {} : { model: opened.model },
|
|
26187
|
+
...opened.engine === void 0 ? {} : { engine: opened.engine },
|
|
26188
|
+
...opened.engineModel === void 0 ? {} : { engineModel: opened.engineModel },
|
|
26189
|
+
host: opened.host,
|
|
26183
26190
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
26184
26191
|
}
|
|
26185
26192
|
};
|
|
@@ -26187,13 +26194,14 @@ async function createSummonEnv(options, afterHost) {
|
|
|
26187
26194
|
async function summonPublicRole(options) {
|
|
26188
26195
|
const packageRoot2 = resolveSummonsPackageRoot(options.packageRoot);
|
|
26189
26196
|
const home = await resolveSummonHome(options);
|
|
26190
|
-
const agentDir = options.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join29(home, ".pi", "agent");
|
|
26191
26197
|
const {
|
|
26192
26198
|
loadCredentialProviders: loadCredentialProviders2,
|
|
26193
26199
|
loadPublicCliConfig: loadPublicCliConfig2,
|
|
26194
26200
|
resolveEffectiveSeat: resolveEffectiveSeat2,
|
|
26201
|
+
resolvePublicAgentDir: resolvePublicAgentDir2,
|
|
26195
26202
|
validatePublicCliConfigAxes: validatePublicCliConfigAxes2
|
|
26196
26203
|
} = await Promise.resolve().then(() => (init_config2(), config_exports));
|
|
26204
|
+
const agentDir = resolvePublicAgentDir2(options.agentDir, home);
|
|
26197
26205
|
const credentials = options.credentials ?? await loadCredentialProviders2(agentDir);
|
|
26198
26206
|
const config = await loadPublicCliConfig2(home);
|
|
26199
26207
|
validatePublicCliConfigAxes2(config, packageRoot2);
|
|
@@ -26550,7 +26558,6 @@ var AK_ROLE_PACKAGE_ROOT_ENV, execFileAsync3;
|
|
|
26550
26558
|
var init_public_role_summons = __esm({
|
|
26551
26559
|
"src/public-role-summons.ts"() {
|
|
26552
26560
|
"use strict";
|
|
26553
|
-
init_engine_material();
|
|
26554
26561
|
AK_ROLE_PACKAGE_ROOT_ENV = "AK_ROLE_PACKAGE_ROOT";
|
|
26555
26562
|
execFileAsync3 = promisify3(execFile3);
|
|
26556
26563
|
}
|
|
@@ -26689,11 +26696,11 @@ var init_compliance_transport = __esm({
|
|
|
26689
26696
|
});
|
|
26690
26697
|
|
|
26691
26698
|
// src/role-run-relocation.ts
|
|
26692
|
-
import { join as join30, sep as
|
|
26699
|
+
import { join as join30, sep as sep4 } from "node:path";
|
|
26693
26700
|
function rewriteRunDirectoryPathValue(value, oldRunDirectory, newRunDirectory) {
|
|
26694
26701
|
if (typeof value !== "string") return value;
|
|
26695
26702
|
if (value === oldRunDirectory) return newRunDirectory;
|
|
26696
|
-
const prefix = `${oldRunDirectory}${
|
|
26703
|
+
const prefix = `${oldRunDirectory}${sep4}`;
|
|
26697
26704
|
if (value.startsWith(prefix)) {
|
|
26698
26705
|
return `${newRunDirectory}${value.slice(oldRunDirectory.length)}`;
|
|
26699
26706
|
}
|
|
@@ -26703,7 +26710,7 @@ function rewriteRunDirectoryPathValueAgainstRewrites(value, rewrites) {
|
|
|
26703
26710
|
if (typeof value !== "string" || rewrites.length === 0) return value;
|
|
26704
26711
|
let best;
|
|
26705
26712
|
for (const rewrite of rewrites) {
|
|
26706
|
-
if (value === rewrite.oldRunDirectory || value.startsWith(`${rewrite.oldRunDirectory}${
|
|
26713
|
+
if (value === rewrite.oldRunDirectory || value.startsWith(`${rewrite.oldRunDirectory}${sep4}`)) {
|
|
26707
26714
|
if (best === void 0 || rewrite.oldRunDirectory.length > best.oldRunDirectory.length) {
|
|
26708
26715
|
best = rewrite;
|
|
26709
26716
|
}
|
|
@@ -27777,14 +27784,10 @@ function admitResumedRole(loaded) {
|
|
|
27777
27784
|
}
|
|
27778
27785
|
case "review-basis": {
|
|
27779
27786
|
const rawBase = fields.baseRevision;
|
|
27780
|
-
|
|
27787
|
+
const baseFault = admittedReviewerBaseFault(rawBase);
|
|
27788
|
+
if (baseFault !== void 0 || rawBase === void 0) {
|
|
27781
27789
|
throw new CliUsageError(
|
|
27782
|
-
`role run admitted reviewer base revision is missing: ${runId}`
|
|
27783
|
-
);
|
|
27784
|
-
}
|
|
27785
|
-
if (/\s/.test(rawBase) || rawBase.startsWith("-")) {
|
|
27786
|
-
throw new CliUsageError(
|
|
27787
|
-
`role run admitted reviewer base revision is damaged: ${runId}`
|
|
27790
|
+
baseFault === "damaged" ? `role run admitted reviewer base revision is damaged: ${runId}` : `role run admitted reviewer base revision is missing: ${runId}`
|
|
27788
27791
|
);
|
|
27789
27792
|
}
|
|
27790
27793
|
const lens = fields.lens;
|
|
@@ -28510,12 +28513,10 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
28510
28513
|
} catch (appendError) {
|
|
28511
28514
|
try {
|
|
28512
28515
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
28513
|
-
await
|
|
28514
|
-
|
|
28515
|
-
|
|
28516
|
-
|
|
28517
|
-
{ encoding: "utf8", flag: "wx" }
|
|
28518
|
-
);
|
|
28516
|
+
await writeHardenedArtifactFile(artifactsDir, "post-admission-diagnostic", {
|
|
28517
|
+
version: 1,
|
|
28518
|
+
...payload
|
|
28519
|
+
});
|
|
28519
28520
|
} catch (artifactError) {
|
|
28520
28521
|
retentionFailure = `post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`;
|
|
28521
28522
|
}
|
|
@@ -29013,13 +29014,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
29013
29014
|
prompt = "";
|
|
29014
29015
|
}
|
|
29015
29016
|
return {
|
|
29016
|
-
|
|
29017
|
-
home: env.home,
|
|
29017
|
+
...projectPublicTurnAxes(env),
|
|
29018
29018
|
...env.host === void 0 ? {} : { host: env.host },
|
|
29019
|
-
agentDir: env.agentDir,
|
|
29020
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
29021
|
-
...pickEngineAxis(env),
|
|
29022
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
29023
29019
|
...env.correlationId === void 0 && admitted.correlationId === void 0 ? {} : { correlationId: env.correlationId ?? admitted.correlationId },
|
|
29024
29020
|
continuation: {
|
|
29025
29021
|
kind: "resume",
|
|
@@ -29032,13 +29028,8 @@ function resumeTurnRequestProjectionOptions(admitted, request, env, summonsPrepa
|
|
|
29032
29028
|
function roleTurnOptions(env, admitted, continuation) {
|
|
29033
29029
|
const correlationId = env.correlationId ?? admitted.correlationId;
|
|
29034
29030
|
return {
|
|
29035
|
-
|
|
29036
|
-
home: env.home,
|
|
29031
|
+
...projectPublicTurnAxes(env),
|
|
29037
29032
|
...env.host === void 0 ? {} : { host: env.host },
|
|
29038
|
-
agentDir: env.agentDir,
|
|
29039
|
-
...env.model === void 0 ? {} : { model: env.model },
|
|
29040
|
-
...pickEngineAxis(env),
|
|
29041
|
-
...env.timeoutMs === void 0 ? {} : { timeoutMs: env.timeoutMs },
|
|
29042
29033
|
...correlationId === void 0 || correlationId.trim() === "" ? {} : { correlationId },
|
|
29043
29034
|
continuation,
|
|
29044
29035
|
...env.stationChild === void 0 ? {} : { stationChild: env.stationChild }
|
|
@@ -29056,6 +29047,43 @@ async function dispatchAfterWriterLease(input) {
|
|
|
29056
29047
|
}
|
|
29057
29048
|
}
|
|
29058
29049
|
}
|
|
29050
|
+
async function runSettledAutoResumeLoop(input) {
|
|
29051
|
+
const adapters = withOnceSuccessfulBeforeDispatch(input.adapters);
|
|
29052
|
+
const dispatchEnv = input.dispatchEnv ?? input.env;
|
|
29053
|
+
return runWithAutoResumeLoop({
|
|
29054
|
+
admitted: input.admitted,
|
|
29055
|
+
principalAuthority: input.env.principalAuthority,
|
|
29056
|
+
io: input.io,
|
|
29057
|
+
sessionAppender: input.env.sessionAppender,
|
|
29058
|
+
autoResumeLimit: input.env.autoResumeLimit,
|
|
29059
|
+
...input.env.signal === void 0 ? {} : { signal: input.env.signal },
|
|
29060
|
+
buildInitialPayload: input.buildInitialPayload,
|
|
29061
|
+
buildResumePayload: input.buildResumePayload,
|
|
29062
|
+
dispatch: async (payload, lease, _isFirst, attemptIo) => dispatchAfterWriterLease({
|
|
29063
|
+
...lease === void 0 ? {} : { lease },
|
|
29064
|
+
build: () => input.toRequest(payload),
|
|
29065
|
+
dispatch: async (request) => {
|
|
29066
|
+
const result = await dispatchPostAdmissionTurn({
|
|
29067
|
+
admitted: input.admitted,
|
|
29068
|
+
env: dispatchEnv,
|
|
29069
|
+
io: attemptIo,
|
|
29070
|
+
request,
|
|
29071
|
+
...lease === void 0 ? {} : { lease },
|
|
29072
|
+
adapters,
|
|
29073
|
+
persistRunState: false,
|
|
29074
|
+
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
29075
|
+
});
|
|
29076
|
+
return settleDeferredPersist(
|
|
29077
|
+
input.admitted,
|
|
29078
|
+
input.env.principalAuthority,
|
|
29079
|
+
adapters,
|
|
29080
|
+
attemptIo,
|
|
29081
|
+
result
|
|
29082
|
+
);
|
|
29083
|
+
}
|
|
29084
|
+
})
|
|
29085
|
+
});
|
|
29086
|
+
}
|
|
29059
29087
|
function isAlreadyFrozenSummonsAttachment(runDirectory, attachmentPath) {
|
|
29060
29088
|
const absolute = isAbsolute8(attachmentPath) ? attachmentPath : resolve12(attachmentPath);
|
|
29061
29089
|
return pathContainedIn(join35(runDirectory, "attachments"), absolute);
|
|
@@ -29169,60 +29197,34 @@ async function runPostAdmissionSeatResume(input) {
|
|
|
29169
29197
|
try {
|
|
29170
29198
|
if (env.stationChild === true) {
|
|
29171
29199
|
let firstTurn;
|
|
29172
|
-
const stationAdapters = withOnceSuccessfulBeforeDispatch(adapters);
|
|
29173
29200
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
29174
29201
|
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
29175
29202
|
});
|
|
29176
|
-
return await
|
|
29203
|
+
return await runSettledAutoResumeLoop({
|
|
29177
29204
|
admitted: loaded.admitted,
|
|
29178
|
-
|
|
29205
|
+
env,
|
|
29179
29206
|
io: input.io,
|
|
29180
|
-
|
|
29181
|
-
|
|
29182
|
-
...env.signal === void 0 ? {} : { signal: env.signal },
|
|
29207
|
+
adapters,
|
|
29208
|
+
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine },
|
|
29183
29209
|
buildInitialPayload: () => ({ resumeTurn: false }),
|
|
29184
29210
|
buildResumePayload: () => ({ resumeTurn: true }),
|
|
29185
|
-
|
|
29186
|
-
|
|
29187
|
-
|
|
29188
|
-
|
|
29189
|
-
|
|
29190
|
-
|
|
29191
|
-
|
|
29192
|
-
|
|
29193
|
-
|
|
29194
|
-
kind: "resume",
|
|
29195
|
-
prompt: RESUME_TRANSPORT_ENVELOPE
|
|
29196
|
-
}
|
|
29197
|
-
};
|
|
29198
|
-
}
|
|
29199
|
-
const turnRequest = withEngineDetourInvocationScope(
|
|
29200
|
-
await buildRequestAfterLease(),
|
|
29201
|
-
invocationScopeId
|
|
29202
|
-
);
|
|
29203
|
-
firstTurn = turnRequest;
|
|
29204
|
-
return turnRequest;
|
|
29205
|
-
},
|
|
29206
|
-
dispatch: async (turnRequest) => {
|
|
29207
|
-
const result = await dispatchPostAdmissionTurn({
|
|
29208
|
-
admitted: loaded.admitted,
|
|
29209
|
-
env,
|
|
29210
|
-
io: attemptIo,
|
|
29211
|
-
request: turnRequest,
|
|
29212
|
-
...lease === void 0 ? {} : { lease },
|
|
29213
|
-
adapters: stationAdapters,
|
|
29214
|
-
persistRunState: false,
|
|
29215
|
-
...input.effectiveEngine === void 0 ? {} : { effectiveEngine: input.effectiveEngine }
|
|
29216
|
-
});
|
|
29217
|
-
return settleDeferredPersist(
|
|
29218
|
-
loaded.admitted,
|
|
29219
|
-
env.principalAuthority,
|
|
29220
|
-
stationAdapters,
|
|
29221
|
-
attemptIo,
|
|
29222
|
-
result
|
|
29223
|
-
);
|
|
29211
|
+
toRequest: async (payload) => {
|
|
29212
|
+
if (payload.resumeTurn && firstTurn !== void 0) {
|
|
29213
|
+
return {
|
|
29214
|
+
...firstTurn,
|
|
29215
|
+
continuation: {
|
|
29216
|
+
kind: "resume",
|
|
29217
|
+
prompt: RESUME_TRANSPORT_ENVELOPE
|
|
29218
|
+
}
|
|
29219
|
+
};
|
|
29224
29220
|
}
|
|
29225
|
-
|
|
29221
|
+
const turnRequest = withEngineDetourInvocationScope(
|
|
29222
|
+
await buildRequestAfterLease(),
|
|
29223
|
+
invocationScopeId
|
|
29224
|
+
);
|
|
29225
|
+
firstTurn = turnRequest;
|
|
29226
|
+
return turnRequest;
|
|
29227
|
+
}
|
|
29226
29228
|
});
|
|
29227
29229
|
}
|
|
29228
29230
|
const resumed = await runPostAdmissionManualResume({
|
|
@@ -29354,38 +29356,25 @@ async function runPostAdmissionOneShot(input) {
|
|
|
29354
29356
|
}
|
|
29355
29357
|
async function runPostAdmissionResumable(input) {
|
|
29356
29358
|
const { admitted, env, io, buildInitialRequest, buildResumeRequest, effectiveEngine } = input;
|
|
29357
|
-
const adapters = withOnceSuccessfulBeforeDispatch(input.adapters);
|
|
29358
29359
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
29359
29360
|
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
29360
29361
|
});
|
|
29361
29362
|
const buildScopedInitial = () => withEngineDetourInvocationScope(buildInitialRequest(), invocationScopeId);
|
|
29362
29363
|
const buildScopedResume = () => withEngineDetourInvocationScope(buildResumeRequest(), invocationScopeId);
|
|
29363
|
-
return
|
|
29364
|
+
return runSettledAutoResumeLoop({
|
|
29364
29365
|
admitted,
|
|
29365
|
-
|
|
29366
|
+
env,
|
|
29366
29367
|
io,
|
|
29367
|
-
|
|
29368
|
-
|
|
29369
|
-
|
|
29368
|
+
adapters: input.adapters,
|
|
29369
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine },
|
|
29370
|
+
// Ordinary in-call retry keeps the admitted correlation when one was stored.
|
|
29371
|
+
dispatchEnv: {
|
|
29372
|
+
...env,
|
|
29373
|
+
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
29374
|
+
},
|
|
29370
29375
|
buildInitialPayload: buildScopedInitial,
|
|
29371
29376
|
buildResumePayload: buildScopedResume,
|
|
29372
|
-
|
|
29373
|
-
const result = await dispatchPostAdmissionTurn({
|
|
29374
|
-
admitted,
|
|
29375
|
-
env: {
|
|
29376
|
-
...env,
|
|
29377
|
-
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
29378
|
-
},
|
|
29379
|
-
io: attemptIo,
|
|
29380
|
-
request,
|
|
29381
|
-
...lease === void 0 ? {} : { lease },
|
|
29382
|
-
adapters,
|
|
29383
|
-
persistRunState: false,
|
|
29384
|
-
// #600: every attempt (initial + auto-resume) writes seat engine when present.
|
|
29385
|
-
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
29386
|
-
});
|
|
29387
|
-
return settleDeferredPersist(admitted, env.principalAuthority, adapters, attemptIo, result);
|
|
29388
|
-
}
|
|
29377
|
+
toRequest: async (request) => request
|
|
29389
29378
|
});
|
|
29390
29379
|
}
|
|
29391
29380
|
async function runPostAdmissionManualResume(input) {
|
|
@@ -29437,6 +29426,7 @@ var init_post_admission = __esm({
|
|
|
29437
29426
|
"use strict";
|
|
29438
29427
|
init_run_lifecycle();
|
|
29439
29428
|
init_cli_errors();
|
|
29429
|
+
init_turn_request();
|
|
29440
29430
|
init_invocation();
|
|
29441
29431
|
init_submission_ledger();
|
|
29442
29432
|
init_run_ticket_number();
|
|
@@ -31604,7 +31594,6 @@ __export(cli_exports, {
|
|
|
31604
31594
|
runAkRole: () => runAkRole
|
|
31605
31595
|
});
|
|
31606
31596
|
import { realpath as realpath6 } from "node:fs/promises";
|
|
31607
|
-
import { join as join40 } from "node:path";
|
|
31608
31597
|
function publicSeatArgv(owner) {
|
|
31609
31598
|
return {
|
|
31610
31599
|
parse: (args) => parsePublicSeatArgv(owner, args),
|
|
@@ -31643,50 +31632,42 @@ function takePublicGlobalFlag(argv2, index, options) {
|
|
|
31643
31632
|
return void 0;
|
|
31644
31633
|
}
|
|
31645
31634
|
function createRoleEnvironment(env, options, afterHost) {
|
|
31646
|
-
const role = options.role;
|
|
31647
31635
|
const extraPiArgs = env.extraPiArgs;
|
|
31648
31636
|
const timeoutMs = env.timeoutMs;
|
|
31649
|
-
const
|
|
31650
|
-
{
|
|
31637
|
+
const opened = openRoleSeatRuntime({
|
|
31638
|
+
resolution: {
|
|
31651
31639
|
packageRoot: env.packageRoot,
|
|
31652
31640
|
...env.roleTurnHost === void 0 ? {} : { roleTurnHost: env.roleTurnHost },
|
|
31653
31641
|
...env.hostAdapters === void 0 ? {} : { hostAdapters: env.hostAdapters },
|
|
31654
31642
|
...extraPiArgs === void 0 ? {} : { extraPiArgs },
|
|
31655
31643
|
...timeoutMs === void 0 ? {} : { timeoutMs }
|
|
31656
31644
|
},
|
|
31657
|
-
env.principalAuthority
|
|
31658
|
-
|
|
31659
|
-
|
|
31660
|
-
|
|
31661
|
-
|
|
31645
|
+
principalAuthority: env.principalAuthority,
|
|
31646
|
+
role: options.role,
|
|
31647
|
+
seat: options.seat,
|
|
31648
|
+
home: options.home,
|
|
31649
|
+
...afterHost === void 0 ? {} : { afterHost }
|
|
31662
31650
|
});
|
|
31663
|
-
|
|
31664
|
-
const seatWithModel = resolvedSeatWithModel(options.seat);
|
|
31665
|
-
if (seatWithModel === void 0) {
|
|
31651
|
+
if (!opened.ok) {
|
|
31666
31652
|
throw new CliUsageError(
|
|
31667
31653
|
missingResolvedSeatModelMessage(options.seat.seat, "invocation-or-config")
|
|
31668
31654
|
);
|
|
31669
31655
|
}
|
|
31670
|
-
const hostFacingSelection = projectHostFacingProvider(
|
|
31671
|
-
seatWithModel.selection,
|
|
31672
|
-
seatWithModel.host,
|
|
31673
|
-
loadHostProvidersTable(options.home),
|
|
31674
|
-
options.home
|
|
31675
|
-
);
|
|
31676
31656
|
return {
|
|
31677
31657
|
home: options.home,
|
|
31678
31658
|
principalAuthority: env.principalAuthority,
|
|
31679
31659
|
agentDir: options.agentDir,
|
|
31680
31660
|
sessionAppender: appendPiSessionCustomEntry,
|
|
31681
31661
|
packageRoot: env.packageRoot,
|
|
31682
|
-
roleTurnHost,
|
|
31683
|
-
hostAdapters,
|
|
31662
|
+
roleTurnHost: opened.roleTurnHost,
|
|
31663
|
+
hostAdapters: opened.hostAdapters,
|
|
31684
31664
|
cwd: options.cwd,
|
|
31685
31665
|
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
31686
31666
|
...env.correlationId === void 0 ? {} : { correlationId: env.correlationId },
|
|
31687
|
-
...
|
|
31688
|
-
...
|
|
31689
|
-
...
|
|
31667
|
+
...opened.model === void 0 ? {} : { model: opened.model },
|
|
31668
|
+
...opened.engine === void 0 ? {} : { engine: opened.engine },
|
|
31669
|
+
...opened.engineModel === void 0 ? {} : { engineModel: opened.engineModel },
|
|
31670
|
+
host: opened.host,
|
|
31690
31671
|
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
31691
31672
|
...env.createRunId === void 0 ? {} : { createRunId: env.createRunId },
|
|
31692
31673
|
...options.config?.autoResumeLimit === void 0 ? {} : { autoResumeLimit: options.config.autoResumeLimit },
|
|
@@ -31695,15 +31676,19 @@ function createRoleEnvironment(env, options, afterHost) {
|
|
|
31695
31676
|
...env.signal === void 0 ? {} : { signal: env.signal }
|
|
31696
31677
|
};
|
|
31697
31678
|
}
|
|
31698
|
-
async function
|
|
31699
|
-
const agentDir =
|
|
31679
|
+
async function loadPublicRoleDispatchParts(env, home) {
|
|
31680
|
+
const agentDir = resolvePublicAgentDir(env.agentDir, home);
|
|
31700
31681
|
const cwd = env.cwd ?? process.cwd();
|
|
31701
31682
|
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
31702
31683
|
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
31684
|
+
return { agentDir, cwd, config, credentials };
|
|
31685
|
+
}
|
|
31686
|
+
async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run) {
|
|
31687
|
+
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
31703
31688
|
const seat = resolveEffectiveSeat(
|
|
31704
|
-
config,
|
|
31689
|
+
parts.config,
|
|
31705
31690
|
role,
|
|
31706
|
-
credentials,
|
|
31691
|
+
parts.credentials,
|
|
31707
31692
|
invocationFromParsed(parsed)
|
|
31708
31693
|
);
|
|
31709
31694
|
let parsedRoleArgv;
|
|
@@ -31711,7 +31696,15 @@ async function dispatchPublicRoleCommand(env, home, io, parsed, role, parse, run
|
|
|
31711
31696
|
parsed.args,
|
|
31712
31697
|
createRoleEnvironment(
|
|
31713
31698
|
env,
|
|
31714
|
-
{
|
|
31699
|
+
{
|
|
31700
|
+
role,
|
|
31701
|
+
home,
|
|
31702
|
+
agentDir: parts.agentDir,
|
|
31703
|
+
cwd: parts.cwd,
|
|
31704
|
+
credentials: parts.credentials,
|
|
31705
|
+
seat,
|
|
31706
|
+
config: parts.config
|
|
31707
|
+
},
|
|
31715
31708
|
() => {
|
|
31716
31709
|
parsedRoleArgv = parse(parsed.args);
|
|
31717
31710
|
}
|
|
@@ -31742,9 +31735,6 @@ function defaultIo() {
|
|
|
31742
31735
|
function resolveHome(env) {
|
|
31743
31736
|
return env.home ?? packageMachineHome();
|
|
31744
31737
|
}
|
|
31745
|
-
function resolveAgentDir(env, home) {
|
|
31746
|
-
return env.agentDir ?? process.env.PI_CODING_AGENT_DIR ?? join40(home, ".pi", "agent");
|
|
31747
|
-
}
|
|
31748
31738
|
function parseThinking(value) {
|
|
31749
31739
|
return value;
|
|
31750
31740
|
}
|
|
@@ -31863,12 +31853,6 @@ function requireCallableSeat(seat, axis, verb) {
|
|
|
31863
31853
|
throw new CliUsageError(`unknown ${axis}-axis seat: ${seat}`);
|
|
31864
31854
|
}
|
|
31865
31855
|
}
|
|
31866
|
-
function projectSeatEngine2(seat) {
|
|
31867
|
-
return pickEngineAxis(seat);
|
|
31868
|
-
}
|
|
31869
|
-
function projectSeatHost2(seat) {
|
|
31870
|
-
return { host: seat.host };
|
|
31871
|
-
}
|
|
31872
31856
|
function loadAndValidateConfig(home, packageRoot2) {
|
|
31873
31857
|
return loadPublicCliConfig(home).then((config) => {
|
|
31874
31858
|
try {
|
|
@@ -32314,7 +32298,7 @@ async function runAkRole(argv2, env) {
|
|
|
32314
32298
|
throw new CliUsageError("roles takes no arguments");
|
|
32315
32299
|
}
|
|
32316
32300
|
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
32317
|
-
const credentials = env.credentials ?? await loadCredentialProviders(
|
|
32301
|
+
const credentials = env.credentials ?? await loadCredentialProviders(resolvePublicAgentDir(env.agentDir, home));
|
|
32318
32302
|
const seats = effectiveSeatConfigurations(
|
|
32319
32303
|
config,
|
|
32320
32304
|
credentials,
|
|
@@ -32354,16 +32338,13 @@ async function runAkRole(argv2, env) {
|
|
|
32354
32338
|
runId: resumeRequest.runId,
|
|
32355
32339
|
authority: env.principalAuthority ?? piDurablePrincipalAuthority
|
|
32356
32340
|
};
|
|
32357
|
-
const
|
|
32358
|
-
const cwd = env.cwd ?? process.cwd();
|
|
32359
|
-
const config = await loadAndValidateConfig(home, env.packageRoot);
|
|
32360
|
-
const credentials = env.credentials ?? await loadCredentialProviders(agentDir);
|
|
32341
|
+
const parts = await loadPublicRoleDispatchParts(env, home);
|
|
32361
32342
|
const resumeRole = await peekRoleRunRole(home, resumeRequest.runId);
|
|
32362
32343
|
const seatRole = resumeRole ?? "judge";
|
|
32363
32344
|
const seat = resolveEffectiveSeat(
|
|
32364
|
-
config,
|
|
32345
|
+
parts.config,
|
|
32365
32346
|
seatRole,
|
|
32366
|
-
credentials,
|
|
32347
|
+
parts.credentials,
|
|
32367
32348
|
invocationFromParsed(parsed)
|
|
32368
32349
|
);
|
|
32369
32350
|
const result = await runPublicInstructionSeatResume(
|
|
@@ -32371,11 +32352,11 @@ async function runAkRole(argv2, env) {
|
|
|
32371
32352
|
createRoleEnvironment(env, {
|
|
32372
32353
|
role: seatRole,
|
|
32373
32354
|
home,
|
|
32374
|
-
agentDir,
|
|
32375
|
-
cwd,
|
|
32376
|
-
credentials,
|
|
32355
|
+
agentDir: parts.agentDir,
|
|
32356
|
+
cwd: parts.cwd,
|
|
32357
|
+
credentials: parts.credentials,
|
|
32377
32358
|
seat,
|
|
32378
|
-
config
|
|
32359
|
+
config: parts.config
|
|
32379
32360
|
}),
|
|
32380
32361
|
io
|
|
32381
32362
|
);
|
|
@@ -32389,15 +32370,20 @@ async function runAkRole(argv2, env) {
|
|
|
32389
32370
|
};
|
|
32390
32371
|
const parentRole = await peekRoleRunRole(home, parentRunId);
|
|
32391
32372
|
if (parentRole === void 0) break;
|
|
32392
|
-
const parentSeat = resolveEffectiveSeat(
|
|
32373
|
+
const parentSeat = resolveEffectiveSeat(
|
|
32374
|
+
parts.config,
|
|
32375
|
+
parentRole,
|
|
32376
|
+
parts.credentials,
|
|
32377
|
+
invocationFromParsed(parsed)
|
|
32378
|
+
);
|
|
32393
32379
|
const parentEnv = createRoleEnvironment(env, {
|
|
32394
32380
|
role: parentRole,
|
|
32395
32381
|
home,
|
|
32396
|
-
agentDir,
|
|
32397
|
-
cwd,
|
|
32398
|
-
credentials,
|
|
32382
|
+
agentDir: parts.agentDir,
|
|
32383
|
+
cwd: parts.cwd,
|
|
32384
|
+
credentials: parts.credentials,
|
|
32399
32385
|
seat: parentSeat,
|
|
32400
|
-
config
|
|
32386
|
+
config: parts.config
|
|
32401
32387
|
});
|
|
32402
32388
|
current = await continueParentAfterChild(parentRunId, current.admitted, parentEnv, io);
|
|
32403
32389
|
}
|
|
@@ -32480,6 +32466,7 @@ var init_cli = __esm({
|
|
|
32480
32466
|
init_machine_method_skills();
|
|
32481
32467
|
init_post_admission();
|
|
32482
32468
|
init_role_turn_host();
|
|
32469
|
+
init_role_seat_runtime();
|
|
32483
32470
|
init_role_turn_host_resolution();
|
|
32484
32471
|
init_invocation();
|
|
32485
32472
|
init_option_definitions();
|
|
@@ -32505,7 +32492,7 @@ var init_cli = __esm({
|
|
|
32505
32492
|
|
|
32506
32493
|
// src/public-cli/main.ts
|
|
32507
32494
|
import { existsSync as existsSync11 } from "node:fs";
|
|
32508
|
-
import { dirname as dirname23, join as
|
|
32495
|
+
import { dirname as dirname23, join as join40 } from "node:path";
|
|
32509
32496
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32510
32497
|
|
|
32511
32498
|
// src/public-cli/host-pi-runtime.ts
|
|
@@ -32594,8 +32581,8 @@ function linkPackage(packageRoot2, name, targetDir) {
|
|
|
32594
32581
|
// src/public-cli/main.ts
|
|
32595
32582
|
var here = dirname23(fileURLToPath2(import.meta.url));
|
|
32596
32583
|
function resolvePackageRoot(binDir) {
|
|
32597
|
-
const canonical =
|
|
32598
|
-
if (existsSync11(
|
|
32584
|
+
const canonical = join40(binDir, "..", "..");
|
|
32585
|
+
if (existsSync11(join40(canonical, "package.json"))) {
|
|
32599
32586
|
return canonical;
|
|
32600
32587
|
}
|
|
32601
32588
|
return binDir;
|