@akagilnc/pi-workflow-roles 0.1.5015 → 0.1.5037
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 +116 -101
- package/dist/headless-host/production-host.js +116 -101
- package/dist/migrate-book-topology.js +3 -2
- package/dist/packaged-role-registry.js +3 -2
- package/dist/public-cli/cli.js +17 -2
- package/dist/public-cli/countersign-run.js +13 -8
- package/dist/public-cli/instruction-seat-run.js +63 -67
- package/dist/public-cli/invocation.js +13 -32
- package/dist/public-cli/main.js +172 -101
- package/dist/public-cli/post-admission.js +8 -5
- package/dist/public-cli/run-lifecycle.js +12 -15
- package/dist/public-cli/seat-ticket-binding.js +5 -8
- package/dist/public-role-summons.js +8 -3
- package/package.json +1 -1
- package/resources/countersign-ticket-issue.md +5 -0
- package/resources/diarist-collect.md +1 -0
- package/resources/secretariat-ticket-identity.md +15 -0
- package/src/packaged-role-registry.ts +3 -2
- package/src/public-cli/cli.ts +18 -2
- package/src/public-cli/countersign-run.ts +17 -10
- package/src/public-cli/instruction-seat-run.ts +66 -63
- package/src/public-cli/invocation.ts +10 -38
- package/src/public-cli/post-admission.ts +10 -6
- package/src/public-cli/run-lifecycle.ts +12 -13
- package/src/public-cli/seat-ticket-binding.ts +5 -8
- package/src/public-role-summons.ts +16 -3
|
@@ -4568,7 +4568,7 @@ var init_packaged_role_registry = __esm({
|
|
|
4568
4568
|
activationStage: "load-and-install",
|
|
4569
4569
|
receiptStatusKey: "status",
|
|
4570
4570
|
// #924: 公用《票面法》三席同装
|
|
4571
|
-
sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md"]
|
|
4571
|
+
sessionMaterials: ["CLAUDE.md", "souls/countersign.md", "souls/ticket-law.md", "resources/countersign-ticket-issue.md"]
|
|
4572
4572
|
},
|
|
4573
4573
|
{
|
|
4574
4574
|
role: "secretariat",
|
|
@@ -4576,7 +4576,7 @@ var init_packaged_role_registry = __esm({
|
|
|
4576
4576
|
presentSettled: "always",
|
|
4577
4577
|
summonResume: false,
|
|
4578
4578
|
admission: "instruction",
|
|
4579
|
-
sameParent: "
|
|
4579
|
+
sameParent: "none",
|
|
4580
4580
|
phases: [null],
|
|
4581
4581
|
outputTool: SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
4582
4582
|
settlement: "accepted",
|
|
@@ -4592,6 +4592,7 @@ var init_packaged_role_registry = __esm({
|
|
|
4592
4592
|
"CLAUDE.md",
|
|
4593
4593
|
"souls/secretariat.md",
|
|
4594
4594
|
"souls/ticket-law.md",
|
|
4595
|
+
"resources/secretariat-ticket-identity.md",
|
|
4595
4596
|
"souls/countersign.md",
|
|
4596
4597
|
"souls/notary.md"
|
|
4597
4598
|
]
|
|
@@ -8694,7 +8695,7 @@ async function findLatestRunIdForSeatTicket(input) {
|
|
|
8694
8695
|
const runId = entry.slice(0, entry.length - suffix.length);
|
|
8695
8696
|
if (runId.length === 0) continue;
|
|
8696
8697
|
const parentPath = await readRunParentPath(runDirectory);
|
|
8697
|
-
if (parentPath !== input.parentRunPath) continue;
|
|
8698
|
+
if (parentPath !== input.parentRunPath && basename6(parentPath ?? "") !== basename6(input.parentRunPath)) continue;
|
|
8698
8699
|
if (!await runHasFormedSessionPrincipal(runDirectory)) continue;
|
|
8699
8700
|
if (best === void 0 || runId > best) best = runId;
|
|
8700
8701
|
}
|
|
@@ -8756,7 +8757,7 @@ function restoredTicketFields(fields) {
|
|
|
8756
8757
|
...fields.courtTicketNumbers === void 0 ? {} : { courtTicketNumbers: fields.courtTicketNumbers }
|
|
8757
8758
|
};
|
|
8758
8759
|
}
|
|
8759
|
-
async function loadResumableRunRecord(home, runId, authority) {
|
|
8760
|
+
async function loadResumableRunRecord(home, runId, authority, allowUnformedAdmitted = false) {
|
|
8760
8761
|
const runDirectory = await findRunDirectoryById(home, runId);
|
|
8761
8762
|
if (runDirectory === void 0) {
|
|
8762
8763
|
throw new CliUsageError(`unknown role run id: ${runId}`);
|
|
@@ -8770,7 +8771,7 @@ async function loadResumableRunRecord(home, runId, authority) {
|
|
|
8770
8771
|
throw new CliUsageError(`unknown role run id: ${runId}`);
|
|
8771
8772
|
}
|
|
8772
8773
|
const { run, principal } = materialized;
|
|
8773
|
-
if (!await isDurablePrincipalAvailable(principal, authority)) {
|
|
8774
|
+
if (!(allowUnformedAdmitted && run.state === "admitted") && !await isDurablePrincipalAvailable(principal, authority)) {
|
|
8774
8775
|
throw new CliUsageError(
|
|
8775
8776
|
`role run Pi session principal is unavailable: ${runId}`
|
|
8776
8777
|
);
|
|
@@ -9051,8 +9052,8 @@ async function peekRoleRunRole(home, runId) {
|
|
|
9051
9052
|
const run = await readRoleRunIdentity(runDirectory);
|
|
9052
9053
|
return run?.role;
|
|
9053
9054
|
}
|
|
9054
|
-
async function loadResumablePublicRole(home, runId, authority) {
|
|
9055
|
-
const loaded = await loadResumableRunRecord(home, runId, authority);
|
|
9055
|
+
async function loadResumablePublicRole(home, runId, authority, allowUnformedAdmitted = false) {
|
|
9056
|
+
const loaded = await loadResumableRunRecord(home, runId, authority, allowUnformedAdmitted);
|
|
9056
9057
|
return seatLoadedResult(loaded, admitResumedRole(loaded));
|
|
9057
9058
|
}
|
|
9058
9059
|
function admitResumedRole(loaded) {
|
|
@@ -10730,12 +10731,7 @@ async function persistAdmittedSourceRunPath(admitted, sourceRunPath) {
|
|
|
10730
10731
|
);
|
|
10731
10732
|
}
|
|
10732
10733
|
async function bindAdmittedTicketNumber(admitted, ticketNumber) {
|
|
10733
|
-
if (admitted.ticketNumber
|
|
10734
|
-
if (admitted.ticketNumber === ticketNumber) return;
|
|
10735
|
-
throw new Error(
|
|
10736
|
-
`bindAdmittedTicketNumber refuses to replace existing ticket #${admitted.ticketNumber} with #${ticketNumber}`
|
|
10737
|
-
);
|
|
10738
|
-
}
|
|
10734
|
+
if (admitted.ticketNumber === ticketNumber) return;
|
|
10739
10735
|
await bindTicketNumberOnRunDirectory(admitted.runDirectory, ticketNumber);
|
|
10740
10736
|
admitted.ticketNumber = ticketNumber;
|
|
10741
10737
|
}
|
|
@@ -10819,6 +10815,7 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
10819
10815
|
for (const childRunId of Array.isArray(childRunIds) ? childRunIds : []) {
|
|
10820
10816
|
if (typeof childRunId !== "string") continue;
|
|
10821
10817
|
const childDirectory = join19(dirname11(oldRunDirectory), `${childRunId}@diarist`);
|
|
10818
|
+
if (!existsSync6(childDirectory)) continue;
|
|
10822
10819
|
const childTarget = roleRunPlacement(ledgerHome, {
|
|
10823
10820
|
bookKey: admitted.bookKey,
|
|
10824
10821
|
subject: { ticketNumber: admitted.ticketNumber },
|
|
@@ -10826,7 +10823,6 @@ async function relocateAdmittedRunToTicket(admitted, authority, heldLease) {
|
|
|
10826
10823
|
role: "diarist"
|
|
10827
10824
|
});
|
|
10828
10825
|
authority.seal(childTarget);
|
|
10829
|
-
if (!existsSync6(childDirectory) && existsSync6(childTarget.runDirectory)) continue;
|
|
10830
10826
|
await bindTicketNumberOnRunDirectory(childDirectory, admitted.ticketNumber);
|
|
10831
10827
|
await rehomeUnboundTicketProvenance(childDirectory, admitted.ticketNumber, admitted.projectRoot, homeFromRunDirectory(oldRunDirectory));
|
|
10832
10828
|
ensureRoleRunDirectory(ledgerHome, dirname11(childTarget.runDirectory));
|
|
@@ -10876,25 +10872,8 @@ async function bindTicketNumberOnRunDirectory(runDirectory, ticketNumber) {
|
|
|
10876
10872
|
"bindTicketNumberOnRunDirectory"
|
|
10877
10873
|
);
|
|
10878
10874
|
const admittedPath = join19(runDirectory, "admitted-request.json");
|
|
10879
|
-
const invocationPath = join19(runDirectory, "invocation.json");
|
|
10880
10875
|
const admitted = JSON.parse(await readFile12(admittedPath, "utf8"));
|
|
10881
|
-
|
|
10882
|
-
if (typeof existing === "number") {
|
|
10883
|
-
if (existing === ticketNumber) return;
|
|
10884
|
-
throw new Error(
|
|
10885
|
-
`bindTicketNumberOnRunDirectory refuses to replace existing ticket #${existing} with #${ticketNumber}`
|
|
10886
|
-
);
|
|
10887
|
-
}
|
|
10888
|
-
if (existsSync6(invocationPath)) {
|
|
10889
|
-
const invocation = JSON.parse(
|
|
10890
|
-
await readFile12(invocationPath, "utf8")
|
|
10891
|
-
);
|
|
10892
|
-
if (typeof invocation.ticketNumber === "number" && invocation.ticketNumber !== ticketNumber) {
|
|
10893
|
-
throw new Error(
|
|
10894
|
-
`bindTicketNumberOnRunDirectory refuses to replace invocation ticket #${invocation.ticketNumber} with #${ticketNumber}`
|
|
10895
|
-
);
|
|
10896
|
-
}
|
|
10897
|
-
}
|
|
10876
|
+
if (admitted.ticketNumber === ticketNumber) return;
|
|
10898
10877
|
await writeFile4(
|
|
10899
10878
|
admittedPath,
|
|
10900
10879
|
`${JSON.stringify({ ...admitted, ticketNumber }, null, 2)}
|
|
@@ -17751,8 +17730,9 @@ function withOnceSuccessfulBeforeDispatch(adapters) {
|
|
|
17751
17730
|
...adapters,
|
|
17752
17731
|
beforeDispatch: async (admitted, lease) => {
|
|
17753
17732
|
if (succeeded) return;
|
|
17754
|
-
await hook(admitted, lease);
|
|
17733
|
+
const result = await hook(admitted, lease);
|
|
17755
17734
|
succeeded = true;
|
|
17735
|
+
return result;
|
|
17756
17736
|
}
|
|
17757
17737
|
};
|
|
17758
17738
|
}
|
|
@@ -18014,7 +17994,10 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18014
17994
|
await clearTypedProviderHttpObservation(admitted.runDirectory);
|
|
18015
17995
|
if (adapters.beforeDispatch !== void 0) {
|
|
18016
17996
|
try {
|
|
18017
|
-
await adapters.beforeDispatch(admitted, lease);
|
|
17997
|
+
const paused = await adapters.beforeDispatch(admitted, lease);
|
|
17998
|
+
if (paused !== void 0) {
|
|
17999
|
+
return { exitCode: 0, admitted, terminal: paused, skipAutoResume: true };
|
|
18000
|
+
}
|
|
18018
18001
|
} catch (error) {
|
|
18019
18002
|
const settled2 = await presentControlledFailure2(
|
|
18020
18003
|
admitted,
|
|
@@ -18787,11 +18770,6 @@ var init_turn_request = __esm({
|
|
|
18787
18770
|
});
|
|
18788
18771
|
|
|
18789
18772
|
// src/public-cli/countersign-run.ts
|
|
18790
|
-
var countersign_run_exports = {};
|
|
18791
|
-
__export(countersign_run_exports, {
|
|
18792
|
-
invokeCourtDiarist: () => invokeCourtDiarist,
|
|
18793
|
-
runCountersignCourtDiaristStation: () => runCountersignCourtDiaristStation
|
|
18794
|
-
});
|
|
18795
18773
|
function isRecord14(value) {
|
|
18796
18774
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18797
18775
|
}
|
|
@@ -18891,7 +18869,8 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
18891
18869
|
kind: "escalate",
|
|
18892
18870
|
diagnostic: courtDiaristEscalateDiagnostic(roleOutcome, submissions)
|
|
18893
18871
|
},
|
|
18894
|
-
...result.admitted === void 0 ? {} : { admitted: result.admitted }
|
|
18872
|
+
...result.admitted === void 0 ? {} : { admitted: result.admitted },
|
|
18873
|
+
...result.terminal === void 0 ? {} : { terminal: result.terminal }
|
|
18895
18874
|
};
|
|
18896
18875
|
}
|
|
18897
18876
|
if (result.exitCode !== 0) {
|
|
@@ -18925,7 +18904,7 @@ async function invokeCourtDiarist(input, env, io) {
|
|
|
18925
18904
|
...result.admitted === void 0 ? {} : { admitted: result.admitted }
|
|
18926
18905
|
};
|
|
18927
18906
|
}
|
|
18928
|
-
async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
18907
|
+
async function runCountersignCourtDiaristStation(admitted, env, io, afterTicketNumber) {
|
|
18929
18908
|
if (env.runCourtDiaristStation !== void 0) {
|
|
18930
18909
|
await env.runCourtDiaristStation(admitted);
|
|
18931
18910
|
return;
|
|
@@ -18942,7 +18921,8 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
18942
18921
|
} else {
|
|
18943
18922
|
refreshTickets = [admitted.ticketNumber];
|
|
18944
18923
|
}
|
|
18945
|
-
|
|
18924
|
+
const completedIndex = afterTicketNumber === void 0 ? -1 : refreshTickets.indexOf(afterTicketNumber);
|
|
18925
|
+
for (const ticketNumber of refreshTickets.slice(completedIndex + 1)) {
|
|
18946
18926
|
const outcome = await invokeCourtDiarist(
|
|
18947
18927
|
{
|
|
18948
18928
|
instruction: `\u6574\u7406 #${ticketNumber} \u7684\u672C\u6848\u4F9D\u636E\u3002`,
|
|
@@ -18955,14 +18935,17 @@ async function runCountersignCourtDiaristStation(admitted, env, io) {
|
|
|
18955
18935
|
env,
|
|
18956
18936
|
io
|
|
18957
18937
|
);
|
|
18958
|
-
if (outcome.identity.kind === "escalate") {
|
|
18959
|
-
throw new StationChildExhaustedError(outcome.identity.diagnostic);
|
|
18960
|
-
}
|
|
18961
18938
|
if (outcome.failedWithoutEscalate !== void 0) {
|
|
18962
18939
|
throw new StationChildExhaustedError(
|
|
18963
18940
|
outcome.failedWithoutEscalate.diagnostic
|
|
18964
18941
|
);
|
|
18965
18942
|
}
|
|
18943
|
+
if (outcome.identity.kind === "escalate" && outcome.terminal !== void 0) {
|
|
18944
|
+
return {
|
|
18945
|
+
terminal: outcome.terminal,
|
|
18946
|
+
...outcome.admitted === void 0 ? {} : { childRunId: outcome.admitted.runId }
|
|
18947
|
+
};
|
|
18948
|
+
}
|
|
18966
18949
|
}
|
|
18967
18950
|
}
|
|
18968
18951
|
var init_countersign_run = __esm({
|
|
@@ -18979,6 +18962,7 @@ var init_countersign_run = __esm({
|
|
|
18979
18962
|
var instruction_seat_run_exports = {};
|
|
18980
18963
|
__export(instruction_seat_run_exports, {
|
|
18981
18964
|
buildInstructionSeatTurnRequest: () => buildInstructionSeatTurnRequest,
|
|
18965
|
+
continueParentAfterChild: () => continueParentAfterChild,
|
|
18982
18966
|
runPublicInstructionSeat: () => runPublicInstructionSeat,
|
|
18983
18967
|
runPublicInstructionSeatResume: () => runPublicInstructionSeatResume
|
|
18984
18968
|
});
|
|
@@ -19204,7 +19188,7 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
19204
19188
|
projectRoot: resolve14(parsed.project ?? env.cwd),
|
|
19205
19189
|
role: "countersign",
|
|
19206
19190
|
parentRunPath: gateParentRunPath,
|
|
19207
|
-
...env.boundTicketNumber
|
|
19191
|
+
...isSafePositiveTicketNumber(env.boundTicketNumber) ? { ticketNumber: env.boundTicketNumber } : {},
|
|
19208
19192
|
freshSummons: env.freshSummons,
|
|
19209
19193
|
summons: {
|
|
19210
19194
|
sourceRunPath: gateParentRunPath,
|
|
@@ -19241,14 +19225,16 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
19241
19225
|
let typedTicket;
|
|
19242
19226
|
let typedCourtTicketNumbers;
|
|
19243
19227
|
let identityDiaristRan = false;
|
|
19244
|
-
let
|
|
19245
|
-
|
|
19228
|
+
let childDiaristRunId;
|
|
19229
|
+
let pausedDiaristTerminal;
|
|
19230
|
+
if (gateParentRunPath === void 0 && env.runCourtDiaristStation === void 0) {
|
|
19246
19231
|
let outcome;
|
|
19247
19232
|
try {
|
|
19248
19233
|
outcome = await invokeCourtDiarist({
|
|
19249
19234
|
instruction: parsed.instruction ?? "",
|
|
19250
19235
|
projectRoot: admitted.projectRoot,
|
|
19251
19236
|
failureLabel: "unbound summons",
|
|
19237
|
+
correlationId: admitted.runId,
|
|
19252
19238
|
...env.boundTicketNumber === void 0 ? {} : { boundTicketNumber: env.boundTicketNumber }
|
|
19253
19239
|
}, env, io);
|
|
19254
19240
|
} catch (error) {
|
|
@@ -19264,15 +19250,16 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
19264
19250
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
19265
19251
|
}
|
|
19266
19252
|
identityDiaristRan = true;
|
|
19253
|
+
if (outcome.identity.kind === "escalate") pausedDiaristTerminal = outcome.terminal;
|
|
19267
19254
|
if (outcome.admitted?.runDirectory.includes(`${sep5}unbound${sep5}runs${sep5}`)) {
|
|
19268
|
-
|
|
19255
|
+
childDiaristRunId = outcome.admitted.runId;
|
|
19269
19256
|
}
|
|
19270
|
-
if (outcome.
|
|
19271
|
-
const diagnostic = outcome.
|
|
19257
|
+
if (outcome.failedWithoutEscalate !== void 0) {
|
|
19258
|
+
const diagnostic = outcome.failedWithoutEscalate.diagnostic;
|
|
19272
19259
|
await materializeAdmission(
|
|
19273
19260
|
isSafePositiveTicketNumber(env.boundTicketNumber) ? env.boundTicketNumber : void 0
|
|
19274
19261
|
);
|
|
19275
|
-
if (
|
|
19262
|
+
if (childDiaristRunId !== void 0) await recordChildDiaristRun(admitted, childDiaristRunId);
|
|
19276
19263
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
19277
19264
|
return await presentControlledFailure2(admitted, {
|
|
19278
19265
|
timedOut: false,
|
|
@@ -19282,16 +19269,18 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
19282
19269
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
19283
19270
|
}
|
|
19284
19271
|
if (outcome.identity.kind === "ticket") {
|
|
19285
|
-
typedTicket =
|
|
19272
|
+
typedTicket = outcome.identity.ticketNumber;
|
|
19286
19273
|
typedCourtTicketNumbers = outcome.identity.courtTicketNumbers;
|
|
19287
|
-
} else if (isSafePositiveTicketNumber(env.boundTicketNumber)) {
|
|
19288
|
-
typedTicket = env.boundTicketNumber;
|
|
19289
19274
|
}
|
|
19290
19275
|
}
|
|
19291
19276
|
await materializeAdmission(typedTicket);
|
|
19292
19277
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
19293
|
-
if (
|
|
19294
|
-
await recordChildDiaristRun(admitted,
|
|
19278
|
+
if (childDiaristRunId !== void 0) {
|
|
19279
|
+
await recordChildDiaristRun(admitted, childDiaristRunId);
|
|
19280
|
+
}
|
|
19281
|
+
if (pausedDiaristTerminal !== void 0) {
|
|
19282
|
+
io.stdout(formatTerminalResult(pausedDiaristTerminal));
|
|
19283
|
+
return { exitCode: 0, admitted, terminal: pausedDiaristTerminal };
|
|
19295
19284
|
}
|
|
19296
19285
|
if (gateParentRunPath !== void 0) {
|
|
19297
19286
|
await persistAdmittedSourceRunPath(admitted, gateParentRunPath);
|
|
@@ -19341,7 +19330,11 @@ async function runCountersignBody(parsed, env, io) {
|
|
|
19341
19330
|
beforeDispatch: async (admittedSeat, lease) => {
|
|
19342
19331
|
if (!packagedAdmitsCountersign(admittedSeat.role)) return;
|
|
19343
19332
|
if (!identityDiaristRan || typedTicket !== void 0) {
|
|
19344
|
-
await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
19333
|
+
const refresh = await runCountersignCourtDiaristStation(admittedSeat, env, io);
|
|
19334
|
+
if (refresh !== void 0) {
|
|
19335
|
+
io.stdout(formatTerminalResult(refresh.terminal));
|
|
19336
|
+
return refresh.terminal;
|
|
19337
|
+
}
|
|
19345
19338
|
}
|
|
19346
19339
|
await relocateAdmittedRunToTicket(admittedSeat, env.principalAuthority, lease);
|
|
19347
19340
|
Object.assign(turnRequest, buildInstructionSeatTurnRequest(admittedSeat, turnProjection));
|
|
@@ -19418,7 +19411,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
19418
19411
|
projectRoot,
|
|
19419
19412
|
role,
|
|
19420
19413
|
parentRunPath: sourceDirectory,
|
|
19421
|
-
...auditorTicket === void 0 ? {} : { ticketNumber: auditorTicket },
|
|
19422
19414
|
freshSummons: env.freshSummons,
|
|
19423
19415
|
summons,
|
|
19424
19416
|
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
@@ -19444,7 +19436,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
19444
19436
|
projectRoot,
|
|
19445
19437
|
role,
|
|
19446
19438
|
parentRunPath,
|
|
19447
|
-
...env.boundTicketNumber === void 0 ? {} : { ticketNumber: env.boundTicketNumber },
|
|
19448
19439
|
freshSummons: env.freshSummons,
|
|
19449
19440
|
summons,
|
|
19450
19441
|
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
@@ -19472,7 +19463,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
19472
19463
|
throw error;
|
|
19473
19464
|
}
|
|
19474
19465
|
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
19475
|
-
const knownTicket = await readBoardTicketNumber(source.runDirectory) ?? env.boundTicketNumber;
|
|
19476
19466
|
const summons = {
|
|
19477
19467
|
sourceRunPath: source.runDirectory,
|
|
19478
19468
|
sourceRun: source,
|
|
@@ -19483,7 +19473,6 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
19483
19473
|
projectRoot,
|
|
19484
19474
|
role,
|
|
19485
19475
|
parentRunPath: source.runDirectory,
|
|
19486
|
-
...knownTicket === void 0 ? {} : { ticketNumber: knownTicket },
|
|
19487
19476
|
freshSummons: env.freshSummons,
|
|
19488
19477
|
summons,
|
|
19489
19478
|
resume: (runId, materials) => runPublicInstructionSeatResume(
|
|
@@ -19520,50 +19509,38 @@ async function runPublicInstructionSeat(argv, env, io, role, parseArgv2) {
|
|
|
19520
19509
|
}
|
|
19521
19510
|
const runAdmitted = async () => {
|
|
19522
19511
|
await markRunAdmitted(admitted, env.principalAuthority);
|
|
19523
|
-
if (
|
|
19524
|
-
|
|
19525
|
-
|
|
19526
|
-
|
|
19527
|
-
|
|
19528
|
-
|
|
19529
|
-
|
|
19530
|
-
|
|
19531
|
-
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
|
|
19538
|
-
|
|
19539
|
-
|
|
19512
|
+
if (role === "secretariat") {
|
|
19513
|
+
let outcome;
|
|
19514
|
+
try {
|
|
19515
|
+
outcome = await invokeCourtDiarist({
|
|
19516
|
+
instruction: parsed.instruction ?? "",
|
|
19517
|
+
projectRoot: admitted.projectRoot,
|
|
19518
|
+
failureLabel: "secretariat unbound summons",
|
|
19519
|
+
attachmentPaths: admitted.attachments.map((attachment) => attachment.frozenPath),
|
|
19520
|
+
correlationId: admitted.runId
|
|
19521
|
+
}, env, io);
|
|
19522
|
+
} catch (error) {
|
|
19523
|
+
return await presentControlledFailure2(admitted, {
|
|
19524
|
+
timedOut: false,
|
|
19525
|
+
code: null,
|
|
19526
|
+
stderr: "",
|
|
19527
|
+
thrown: error
|
|
19528
|
+
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
19529
|
+
}
|
|
19540
19530
|
if (outcome.admitted?.runDirectory.includes(`${sep5}unbound${sep5}runs${sep5}`)) {
|
|
19541
19531
|
await recordChildDiaristRun(admitted, outcome.admitted.runId);
|
|
19542
19532
|
}
|
|
19543
|
-
if (outcome.
|
|
19544
|
-
const diagnostic = outcome.identity.kind === "escalate" ? outcome.identity.diagnostic : outcome.failedWithoutEscalate?.diagnostic ?? "";
|
|
19533
|
+
if (outcome.failedWithoutEscalate !== void 0) {
|
|
19545
19534
|
return await presentControlledFailure2(admitted, {
|
|
19546
19535
|
timedOut: false,
|
|
19547
19536
|
code: null,
|
|
19548
19537
|
stderr: "",
|
|
19549
|
-
thrown: new Error(diagnostic)
|
|
19538
|
+
thrown: new Error(outcome.failedWithoutEscalate.diagnostic)
|
|
19550
19539
|
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
19551
19540
|
}
|
|
19552
|
-
if (outcome.identity.kind === "
|
|
19553
|
-
|
|
19554
|
-
|
|
19555
|
-
await bindAdmittedTicketNumber(outcome.admitted, outcome.identity.ticketNumber);
|
|
19556
|
-
await relocateAdmittedRunToTicket(outcome.admitted, env.principalAuthority);
|
|
19557
|
-
await bindAdmittedTicketNumber(admitted, outcome.identity.ticketNumber);
|
|
19558
|
-
await relocateAdmittedRunToTicket(admitted, env.principalAuthority);
|
|
19559
|
-
} catch (error) {
|
|
19560
|
-
return await presentControlledFailure2(admitted, {
|
|
19561
|
-
timedOut: false,
|
|
19562
|
-
code: null,
|
|
19563
|
-
stderr: "",
|
|
19564
|
-
thrown: error
|
|
19565
|
-
}, seatAdapters(admitted, env), env.principalAuthority, io);
|
|
19566
|
-
}
|
|
19541
|
+
if (outcome.identity.kind === "escalate" && outcome.terminal !== void 0) {
|
|
19542
|
+
io.stdout(formatTerminalResult(outcome.terminal));
|
|
19543
|
+
return { exitCode: 0, admitted, terminal: outcome.terminal };
|
|
19567
19544
|
}
|
|
19568
19545
|
}
|
|
19569
19546
|
return dispatchAdmitted(admitted, env, io);
|
|
@@ -19627,6 +19604,21 @@ async function runPublicInstructionSeatResume(request, env, io) {
|
|
|
19627
19604
|
...env.engine === void 0 ? {} : { effectiveEngine: env.engine }
|
|
19628
19605
|
});
|
|
19629
19606
|
}
|
|
19607
|
+
async function continueParentAfterChild(parentRunId, child, env, io) {
|
|
19608
|
+
const loaded = await loadResumablePublicRole(env.home, parentRunId, env.principalAuthority, true);
|
|
19609
|
+
if (loaded.run.state !== "admitted") {
|
|
19610
|
+
return runPublicInstructionSeatResume({ runId: parentRunId }, env, io);
|
|
19611
|
+
}
|
|
19612
|
+
const admitted = loaded.admitted;
|
|
19613
|
+
if (admitted.role === "countersign" && admitted.ticketNumber !== void 0) {
|
|
19614
|
+
const refresh = await runCountersignCourtDiaristStation(admitted, env, io, child.ticketNumber);
|
|
19615
|
+
if (refresh !== void 0) {
|
|
19616
|
+
io.stdout(formatTerminalResult(refresh.terminal));
|
|
19617
|
+
return { exitCode: 0, admitted, terminal: refresh.terminal };
|
|
19618
|
+
}
|
|
19619
|
+
}
|
|
19620
|
+
return dispatchAdmitted(admitted, env, io);
|
|
19621
|
+
}
|
|
19630
19622
|
var init_instruction_seat_run = __esm({
|
|
19631
19623
|
"src/public-cli/instruction-seat-run.ts"() {
|
|
19632
19624
|
"use strict";
|
|
@@ -22586,7 +22578,24 @@ async function runAkRole(argv, env) {
|
|
|
22586
22578
|
}),
|
|
22587
22579
|
io
|
|
22588
22580
|
);
|
|
22589
|
-
|
|
22581
|
+
let current = result;
|
|
22582
|
+
while (current.exitCode === 0 && current.admitted?.correlationId !== void 0 && current.terminal?.roleOutcome.kind === "accepted" && !courtDiaristEscalated(current.terminal.roleOutcome)) {
|
|
22583
|
+
const parentRunId = current.admitted.correlationId;
|
|
22584
|
+
const parentRole = await peekRoleRunRole(home, parentRunId);
|
|
22585
|
+
if (parentRole === void 0) break;
|
|
22586
|
+
const parentSeat = resolveEffectiveSeat(config, parentRole, credentials, invocationFromParsed(parsed));
|
|
22587
|
+
const parentEnv = createRoleEnvironment(env, {
|
|
22588
|
+
role: parentRole,
|
|
22589
|
+
home,
|
|
22590
|
+
agentDir,
|
|
22591
|
+
cwd,
|
|
22592
|
+
credentials,
|
|
22593
|
+
seat: parentSeat,
|
|
22594
|
+
config
|
|
22595
|
+
});
|
|
22596
|
+
current = await continueParentAfterChild(parentRunId, current.admitted, parentEnv, io);
|
|
22597
|
+
}
|
|
22598
|
+
return cliResultFromRoleRun(current);
|
|
22590
22599
|
}
|
|
22591
22600
|
if (parsed.command !== void 0 && isPublicCliSupportCommand(parsed.command)) {
|
|
22592
22601
|
throw new CliUsageError(`unhandled support command: ${parsed.command}`);
|
|
@@ -22655,6 +22664,7 @@ var init_cli = __esm({
|
|
|
22655
22664
|
init_invocation();
|
|
22656
22665
|
init_option_definitions();
|
|
22657
22666
|
init_instruction_seat_run();
|
|
22667
|
+
init_countersign_run();
|
|
22658
22668
|
init_analyst_run();
|
|
22659
22669
|
init_run_lifecycle();
|
|
22660
22670
|
init_registry();
|
|
@@ -22954,7 +22964,10 @@ async function summonPublicRole(options) {
|
|
|
22954
22964
|
result = stepped.ok;
|
|
22955
22965
|
}
|
|
22956
22966
|
const stderr = captured?.stderrText();
|
|
22957
|
-
const runDirectory = result.
|
|
22967
|
+
const runDirectory = result.terminal !== void 0 && result.terminal.roleOutcome.role !== options.role && typeof result.terminal.runId === "string" ? await (await Promise.resolve().then(() => (init_run_lifecycle(), run_lifecycle_exports))).findRunDirectoryById(
|
|
22968
|
+
home,
|
|
22969
|
+
result.terminal.runId
|
|
22970
|
+
) : result.admitted?.runDirectory;
|
|
22958
22971
|
return {
|
|
22959
22972
|
exitCode: result.exitCode,
|
|
22960
22973
|
...result.terminal === void 0 ? {} : { terminal: result.terminal },
|
|
@@ -23158,8 +23171,10 @@ async function summonGateOfficer(options) {
|
|
|
23158
23171
|
`countersign gate summon requires parent runId from sourceRunDirectory: ${options.sourceRunDirectory}`
|
|
23159
23172
|
);
|
|
23160
23173
|
}
|
|
23161
|
-
const { readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
|
|
23174
|
+
const { isSafePositiveTicketNumber: isSafePositiveTicketNumber2, readBoardTicketNumber: readBoardTicketNumber2 } = await Promise.resolve().then(() => (init_run_ticket_number(), run_ticket_number_exports));
|
|
23162
23175
|
const parentTicket = await readBoardTicketNumber2(options.sourceRunDirectory);
|
|
23176
|
+
const submittedTicket = options.submission !== null && typeof options.submission === "object" && !Array.isArray(options.submission) ? options.submission.ticketNumber : void 0;
|
|
23177
|
+
const courtTicket = isSafePositiveTicketNumber2(submittedTicket) ? submittedTicket : parentTicket;
|
|
23163
23178
|
const instruction = options.reask ?? gateReviewInstruction ?? "";
|
|
23164
23179
|
return summonPublicRole({
|
|
23165
23180
|
role: options.officer,
|
|
@@ -23167,7 +23182,7 @@ async function summonGateOfficer(options) {
|
|
|
23167
23182
|
...common,
|
|
23168
23183
|
correlationId,
|
|
23169
23184
|
parentRunPath: options.sourceRunDirectory,
|
|
23170
|
-
...
|
|
23185
|
+
...courtTicket === void 0 ? {} : { boundTicketNumber: courtTicket }
|
|
23171
23186
|
});
|
|
23172
23187
|
}
|
|
23173
23188
|
return summonPublicRole({
|