@akagilnc/pi-workflow-roles 0.1.4800 → 0.1.4870
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 +19434 -18218
- package/dist/analyst-book-key.js +63 -0
- package/dist/analyst-cohort.js +167 -0
- package/dist/analyst-entry.js +320 -0
- package/dist/analyst-index.js +247 -0
- package/dist/analyst-ledger.js +561 -0
- package/dist/analyst-median.js +16 -0
- package/dist/analyst-metric-families/acceptance-success-rework.js +249 -0
- package/dist/analyst-metric-families/b2-frame-buckets-actions.js +189 -0
- package/dist/analyst-metric-families/gate-cycles.js +77 -0
- package/dist/analyst-metric-families/leg-wall-clock.js +56 -0
- package/dist/analyst-metric-families/round-timeline.js +126 -0
- package/dist/analyst-metric-families.js +23 -0
- package/dist/analyst-metric-family.js +11 -0
- package/dist/analyst-model-groups.js +135 -0
- package/dist/analyst-page.js +182 -0
- package/dist/atomic-write.js +23 -0
- package/dist/auditor-soul.js +1 -1
- package/dist/countersign-contracts.js +0 -2
- package/dist/diarist-contracts.js +0 -1
- package/dist/doctor-contracts.js +2 -2
- package/dist/gatekeeper-role.js +15 -16
- package/dist/gleaner-left-contracts.js +0 -2
- package/dist/headless-host/production-host.js +16967 -15749
- package/dist/host-contracts.js +0 -4
- package/dist/inspector-contracts.js +0 -2
- package/dist/institutional-resolution.js +4 -2
- package/dist/merger-contracts.js +0 -2
- package/dist/migrate-book-topology.js +3908 -3089
- package/dist/navigator-public-session.js +4 -3
- package/dist/notary-contracts.js +0 -2
- package/dist/package-contracts/auditor-output.js +0 -1
- package/dist/package-contracts/collector-output.js +0 -2
- package/dist/package-contracts/fixer-output.js +0 -2
- package/dist/package-contracts/gatekeeper-output.js +0 -2
- package/dist/package-contracts/judge-output.js +0 -2
- package/dist/package-contracts/navigator-output.js +0 -2
- package/dist/package-contracts/reviewer-output.js +0 -2
- package/dist/package-contracts/terminating-tools.js +32 -92
- package/dist/package-contracts/worker-output.js +0 -4
- package/dist/packaged-role-registry.js +518 -36
- package/dist/pi/role-turn-host.js +2 -1
- package/dist/public-cli/analyst-run.js +185 -0
- package/dist/public-cli/cli.js +885 -0
- package/dist/public-cli/config.js +12 -9
- package/dist/public-cli/countersign-run.js +4 -311
- package/dist/public-cli/instruction-seat-run.js +628 -158
- package/dist/public-cli/invocation.js +806 -1550
- package/dist/public-cli/main.js +6962 -9882
- package/dist/public-cli/option-definitions.js +51 -99
- package/dist/public-cli/post-admission.js +30 -2
- package/dist/public-cli/run-lifecycle.js +234 -353
- package/dist/public-cli/seat-ticket-binding.js +6 -0
- package/dist/public-cli/settlement.js +261 -675
- package/dist/public-cli/turn-request.js +76 -0
- package/dist/public-role-summons.js +38 -112
- package/dist/role-activation-flags.js +23 -45
- package/dist/secretariat-contracts.js +0 -2
- package/dist/session-identity.js +17 -8
- package/dist/session-opening-materials.js +3 -2
- package/extensions/role-runtime.ts +6 -80
- package/package.json +1 -1
- package/souls/coder.md +1 -2
- package/src/acp-host/role-turn-host.ts +4 -1
- package/src/analyst-metric-families/acceptance-success-rework.ts +3 -2
- package/src/auditor-role.ts +1 -2
- package/src/auditor-soul.ts +1 -1
- package/src/collector-role.ts +2 -2
- package/src/countersign-contracts.ts +0 -1
- package/src/countersign-role.ts +1 -1
- package/src/diarist-contracts.ts +0 -1
- package/src/diarist-role.ts +0 -1
- package/src/doctor-auditor.ts +1 -2
- package/src/doctor-contracts.ts +1 -1
- package/src/doctor-role.ts +3 -2
- package/src/external-host-turn-loop.ts +1 -1
- package/src/factory-board.ts +10 -7
- package/src/gatekeeper-role.ts +16 -10
- package/src/gleaner-left-contracts.ts +0 -1
- package/src/gleaner-left-role.ts +0 -1
- package/src/headless-host/role-turn-host.ts +7 -1
- package/src/host-contracts.ts +10 -6
- package/src/inspector-contracts.ts +0 -1
- package/src/inspector-role.ts +0 -2
- package/src/institutional-resolution.ts +6 -4
- package/src/judge-role.ts +3 -3
- package/src/merger-contracts.ts +0 -1
- package/src/merger-role.ts +2 -2
- package/src/navigator-public-session.ts +7 -6
- package/src/navigator-work-context.ts +6 -8
- package/src/notary-contracts.ts +0 -1
- package/src/notary-role.ts +2 -3
- package/src/package-contracts/auditor-output.ts +0 -1
- package/src/package-contracts/collector-output.ts +0 -1
- package/src/package-contracts/fixer-output.ts +0 -1
- package/src/package-contracts/gatekeeper-output.ts +0 -1
- package/src/package-contracts/judge-output.ts +0 -1
- package/src/package-contracts/navigator-output.ts +0 -1
- package/src/package-contracts/reviewer-output.ts +0 -1
- package/src/package-contracts/terminating-tools.ts +27 -99
- package/src/package-contracts/worker-output.ts +0 -2
- package/src/packaged-role-registry.ts +604 -35
- package/src/pi/role-turn-host.ts +2 -1
- package/src/public-cli/cli.ts +64 -259
- package/src/public-cli/config.ts +18 -10
- package/src/public-cli/countersign-run.ts +14 -449
- package/src/public-cli/instruction-seat-run.ts +758 -277
- package/src/public-cli/invocation.ts +1097 -2051
- package/src/public-cli/option-definitions.ts +62 -127
- package/src/public-cli/post-admission.ts +47 -2
- package/src/public-cli/run-lifecycle.ts +303 -613
- package/src/public-cli/seat-ticket-binding.ts +6 -0
- package/src/public-cli/settlement.ts +399 -1185
- package/src/public-cli/turn-request.ts +92 -1
- package/src/public-role-summons.ts +44 -128
- package/src/reviewer-role.ts +3 -2
- package/src/role-activation-flags.ts +20 -41
- package/src/role-runtime-dependencies.ts +25 -26
- package/src/role-runtime.ts +121 -232
- package/src/secretariat-contracts.ts +0 -1
- package/src/secretariat-role.ts +0 -2
- package/src/session-identity.ts +23 -8
- package/src/session-opening-materials.ts +2 -1
- package/src/worker-role.ts +3 -4
- package/dist/doctor-auditor.js +0 -25
- package/dist/public-cli/diarist-run.js +0 -130
- package/dist/public-cli/doctor-run.js +0 -87
- package/dist/public-cli/inspector-run.js +0 -151
- package/dist/public-cli/judge-run.js +0 -114
- package/dist/public-cli/notary-run.js +0 -174
- package/dist/public-cli/reviewer-run.js +0 -339
- package/src/public-cli/coder-run.ts +0 -255
- package/src/public-cli/collector-run.ts +0 -189
- package/src/public-cli/diarist-run.ts +0 -233
- package/src/public-cli/doctor-run.ts +0 -167
- package/src/public-cli/fixer-run.ts +0 -265
- package/src/public-cli/gleaner-left-run.ts +0 -167
- package/src/public-cli/inspector-run.ts +0 -261
- package/src/public-cli/judge-run.ts +0 -196
- package/src/public-cli/merger-run.ts +0 -294
- package/src/public-cli/notary-run.ts +0 -279
- package/src/public-cli/reviewer-run.ts +0 -480
- package/src/public-cli/secretariat-run.ts +0 -265
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
export const SECRETARIAT_OUTPUT_TOOL_NAME = "ak_secretariat_output";
|
|
11
11
|
export const SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME =
|
|
12
12
|
"ak_secretariat_summon_countersign";
|
|
13
|
-
export const SECRETARIAT_ACCEPTED_TEXT = "中书省回执已接受";
|
|
14
13
|
/**
|
|
15
14
|
* #969 durable custom entry: 给事中 terminal (署|上呈) for seat settlement projection.
|
|
16
15
|
* Carries original receipt bytes + nested runId. Envelope persists custom entries
|
package/src/secretariat-role.ts
CHANGED
|
@@ -10,7 +10,6 @@ import { withTerminatingOutputDeclarations } from "./package-contracts/terminati
|
|
|
10
10
|
import type { NamedRoleTurnHostAdapter } from "./public-cli/role-turn-host-resolution.ts";
|
|
11
11
|
import type { PublicSummonResult } from "./public-role-summons.ts";
|
|
12
12
|
import {
|
|
13
|
-
SECRETARIAT_ACCEPTED_TEXT,
|
|
14
13
|
SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
15
14
|
SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME,
|
|
16
15
|
type SecretariatVerdict,
|
|
@@ -18,7 +17,6 @@ import {
|
|
|
18
17
|
import { runIdFromRunDirectory } from "./run-terminal-artifacts.ts";
|
|
19
18
|
|
|
20
19
|
export {
|
|
21
|
-
SECRETARIAT_ACCEPTED_TEXT,
|
|
22
20
|
SECRETARIAT_OUTPUT_TOOL_NAME,
|
|
23
21
|
SECRETARIAT_SUMMON_COUNTERSIGN_TOOL_NAME,
|
|
24
22
|
} from "./secretariat-contracts.ts";
|
package/src/session-identity.ts
CHANGED
|
@@ -60,13 +60,28 @@ export function resolveHostAwareSessionAvailability(
|
|
|
60
60
|
if (host === undefined || host === DEFAULT_ROLE_TURN_HOST) {
|
|
61
61
|
return (principal) => principalAuthority.isAvailable(principal);
|
|
62
62
|
}
|
|
63
|
+
// Unregistered names have no binding file: absence, not a guess at pi.
|
|
64
|
+
return async (principal) =>
|
|
65
|
+
(await readStoredHostSessionId(host, principalAuthority, principal)) !== undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Native session/thread id already stored for this principal on `host`.
|
|
70
|
+
* Public explicit resume reads it once and hands it to the host adapter.
|
|
71
|
+
* Pi has no separate binding file. A missing file is absence, not the package run id.
|
|
72
|
+
*/
|
|
73
|
+
export async function readStoredHostSessionId(
|
|
74
|
+
host: string | undefined,
|
|
75
|
+
authority: DurablePrincipalAuthority,
|
|
76
|
+
principal: DurablePrincipal,
|
|
77
|
+
): Promise<string | undefined> {
|
|
78
|
+
if (host === undefined || host === DEFAULT_ROLE_TURN_HOST) return undefined;
|
|
63
79
|
const description = lookupHostDescription(host) ?? lookupHeadlessHostDescription(host);
|
|
64
|
-
if (description === undefined)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return async (principal) => (await sessionIdentity.load(principal)) !== undefined;
|
|
80
|
+
if (description === undefined) return undefined;
|
|
81
|
+
const sessionId = await createSessionIdentityAuthority(
|
|
82
|
+
authority,
|
|
83
|
+
description.sessionBindingFile,
|
|
84
|
+
).load(principal);
|
|
85
|
+
if (sessionId === undefined || sessionId === "") return undefined;
|
|
86
|
+
return sessionId;
|
|
72
87
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
INSPECTOR_SESSION_MATERIALS,
|
|
15
15
|
NOTARY_SESSION_MATERIALS,
|
|
16
16
|
PUBLIC_ROLE_RECORDS,
|
|
17
|
+
packagedRoleSessionMaterials,
|
|
17
18
|
type PackagedRole,
|
|
18
19
|
} from "./packaged-role-registry.ts";
|
|
19
20
|
|
|
@@ -99,7 +100,7 @@ export function loadMainRoleReferenceMaterials(role: MainRoleSession): Promise<s
|
|
|
99
100
|
/** Gatekeeper province; notary reuses the public notary materials definition. */
|
|
100
101
|
export const GATEKEEPER_SESSION_MATERIALS = {
|
|
101
102
|
// #639: single authority — the public gatekeeper record owns the province list.
|
|
102
|
-
gatekeeper:
|
|
103
|
+
gatekeeper: packagedRoleSessionMaterials("gatekeeper")!,
|
|
103
104
|
inspector: INSPECTOR_SESSION_MATERIALS,
|
|
104
105
|
notary: NOTARY_SESSION_MATERIALS,
|
|
105
106
|
} as const;
|
package/src/worker-role.ts
CHANGED
|
@@ -8,10 +8,9 @@ import type {
|
|
|
8
8
|
AnyCanonicalSkillBinding,
|
|
9
9
|
CanonicalSkillBinding,
|
|
10
10
|
} from "./canonical-skill-binding.ts";
|
|
11
|
+
import { packagedRoleAcceptedText } from "./packaged-role-registry.ts";
|
|
11
12
|
import {
|
|
12
|
-
CODER_ACCEPTED_TEXT,
|
|
13
13
|
CODER_OUTPUT_TOOL_NAME,
|
|
14
|
-
FIXER_ACCEPTED_TEXT,
|
|
15
14
|
FIXER_OUTPUT_TOOL_NAME,
|
|
16
15
|
validateAcceptedWorkerDetails,
|
|
17
16
|
type CoderOutput,
|
|
@@ -296,7 +295,7 @@ export function createFixerRoleRuntime(
|
|
|
296
295
|
}
|
|
297
296
|
const acceptedDetails = output;
|
|
298
297
|
return {
|
|
299
|
-
content: [{ type: "text" as const, text:
|
|
298
|
+
content: [{ type: "text" as const, text: packagedRoleAcceptedText("fixer") }],
|
|
300
299
|
details: acceptedDetails,
|
|
301
300
|
terminate: true as const,
|
|
302
301
|
};
|
|
@@ -436,7 +435,7 @@ export function createCoderRoleRuntime(
|
|
|
436
435
|
}
|
|
437
436
|
const acceptedDetails = output;
|
|
438
437
|
return {
|
|
439
|
-
content: [{ type: "text" as const, text:
|
|
438
|
+
content: [{ type: "text" as const, text: packagedRoleAcceptedText("coder") }],
|
|
440
439
|
details: acceptedDetails,
|
|
441
440
|
terminate: true as const,
|
|
442
441
|
};
|
package/dist/doctor-auditor.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { auditorRunDirectory } from "./auditor-dossier-tool.js";
|
|
2
|
-
import { runComplianceAudit, } from "./compliance-transport.js";
|
|
3
|
-
import { readDoctorAuditSubjects, requireAuditMaterials, resolveAuditDossier, } from "./dossier-resolution.js";
|
|
4
|
-
export const DOCTOR_AUDIT_TOOL_NAME = "ak_doctor_audit_decision";
|
|
5
|
-
/**
|
|
6
|
-
* Doctor compliance via public auditor activation (#675 / ADR 0062 / owner r11).
|
|
7
|
-
* 审刑院 is an independent role; subject=doctor selects souls/doctor-auditor.md.
|
|
8
|
-
*/
|
|
9
|
-
export function createPiDoctorAuditor() {
|
|
10
|
-
return async (options) => {
|
|
11
|
-
const dossier = resolveAuditDossier(options.context);
|
|
12
|
-
requireAuditMaterials(dossier);
|
|
13
|
-
const subjects = readDoctorAuditSubjects(options.context);
|
|
14
|
-
requireAuditMaterials(subjects);
|
|
15
|
-
return runComplianceAudit({
|
|
16
|
-
subject: "doctor",
|
|
17
|
-
context: options.context,
|
|
18
|
-
...(auditorRunDirectory(options.context) === undefined
|
|
19
|
-
? {}
|
|
20
|
-
: { runDirectory: auditorRunDirectory(options.context) }),
|
|
21
|
-
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
22
|
-
...(options.summonAuditor === undefined ? {} : { summonAuditor: options.summonAuditor }),
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.js";
|
|
2
|
-
import { CliUsageError } from "./cli-errors.js";
|
|
3
|
-
import { admitDiaristInvocation, bindAdmittedTicketNumber, buildInstructionTransportPrompt, relocateAdmittedRunToTicket, recordAdmittedCorrelation, } from "./invocation.js";
|
|
4
|
-
import { prepareSummonsResumeMaterials, runPostAdmissionOneShot, runPostAdmissionSeatResume, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
|
|
5
|
-
import { loadResumableDiaristRun, markRunAdmitted, } from "./run-lifecycle.js";
|
|
6
|
-
import { presentStructuralRejection, trySettleDiaristTerminalResult, } from "./settlement.js";
|
|
7
|
-
import { projectRoleTurnRequest, } from "./turn-request.js";
|
|
8
|
-
import { readBoardTicketNumber } from "../run-ticket-number.js";
|
|
9
|
-
/** Project admitted invocation onto the host-neutral turn request. */
|
|
10
|
-
export function buildDiaristTurnRequest(admitted, options) {
|
|
11
|
-
return projectRoleTurnRequest(admitted, { activation: { role: "diarist" } }, options);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Board-bound ticket on pages → memory bind + unbound→ticket relocate under lease.
|
|
15
|
-
* Shared by resume (interrupted board-bound unbound) and post-turn first assert.
|
|
16
|
-
*/
|
|
17
|
-
async function bindAndRelocateDiaristIfBoardBound(admitted, authority, lease) {
|
|
18
|
-
const boardTicket = await readBoardTicketNumber(admitted.runDirectory);
|
|
19
|
-
if (boardTicket === undefined)
|
|
20
|
-
return;
|
|
21
|
-
if (admitted.ticketNumber === undefined) {
|
|
22
|
-
await bindAdmittedTicketNumber(admitted, boardTicket);
|
|
23
|
-
}
|
|
24
|
-
await relocateAdmittedRunToTicket(admitted, authority, lease);
|
|
25
|
-
}
|
|
26
|
-
function diaristAdapters(env) {
|
|
27
|
-
return {
|
|
28
|
-
trySettle: (admitted, authority, scope) => trySettleDiaristTerminalResult(admitted, authority, scope),
|
|
29
|
-
shouldPresentSettled: () => true,
|
|
30
|
-
// Resume interrupted state: board ticket already on pages, run still under unbound/.
|
|
31
|
-
beforeDispatch: async (admitted, lease) => {
|
|
32
|
-
if (env.correlationId !== undefined && env.correlationId.trim() !== "") {
|
|
33
|
-
await recordAdmittedCorrelation(admitted, env.correlationId);
|
|
34
|
-
}
|
|
35
|
-
await bindAndRelocateDiaristIfBoardBound(admitted, env.principalAuthority, lease);
|
|
36
|
-
},
|
|
37
|
-
// First post-turn assert: accept hook wrote board pages; relocate before lease release.
|
|
38
|
-
afterDispatch: async (admitted, lease) => {
|
|
39
|
-
await bindAndRelocateDiaristIfBoardBound(admitted, env.principalAuthority, lease);
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export async function runPublicDiarist(argv, env, io, parseDiaristArgv) {
|
|
44
|
-
let parsed;
|
|
45
|
-
try {
|
|
46
|
-
parsed = parseDiaristArgv(argv);
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
if (error instanceof CliUsageError) {
|
|
50
|
-
presentStructuralRejection(error, io);
|
|
51
|
-
return { exitCode: 2 };
|
|
52
|
-
}
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
// #637 / #771 / ADR 0075 / #779 / #987: ticket identity is the LLM's typed
|
|
56
|
-
// assertion on this turn, OR a typed handoff key already held by the caller
|
|
57
|
-
// (countersign refresh bind). Code never pre-judges the summons text and never
|
|
58
|
-
// freezes a candidate catalog. Public same-ticket resume-by-ticketNumber was
|
|
59
|
-
// deleted (#987 Result 7); callers continue an existing diarist run only via
|
|
60
|
-
// explicit `ak-role resume <runId>`. Handoff ticket remains a bind key only.
|
|
61
|
-
const handoffTicket = env.boundTicketNumber;
|
|
62
|
-
let admitted;
|
|
63
|
-
try {
|
|
64
|
-
admitted = await admitDiaristInvocation({
|
|
65
|
-
home: env.home,
|
|
66
|
-
principalAuthority: env.principalAuthority,
|
|
67
|
-
cwd: env.cwd,
|
|
68
|
-
instruction: parsed.instruction,
|
|
69
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
70
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
71
|
-
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
72
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
73
|
-
...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
|
|
74
|
-
...(handoffTicket === undefined ? {} : { assertedTicketNumber: handoffTicket }),
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
if (error instanceof CliUsageError) {
|
|
79
|
-
presentStructuralRejection(error, io);
|
|
80
|
-
return { exitCode: 2 };
|
|
81
|
-
}
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
85
|
-
const turnProjection = {
|
|
86
|
-
packageRoot: env.packageRoot,
|
|
87
|
-
home: env.home,
|
|
88
|
-
agentDir: env.agentDir,
|
|
89
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
90
|
-
...pickEngineAxis(env),
|
|
91
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
92
|
-
...(env.correlationId === undefined || env.correlationId.trim() === ""
|
|
93
|
-
? {}
|
|
94
|
-
: { correlationId: env.correlationId }),
|
|
95
|
-
continuation: {
|
|
96
|
-
kind: "initial",
|
|
97
|
-
prompt: buildInstructionTransportPrompt(admitted, engineSessionMaterialFromOptions({
|
|
98
|
-
...pickEngineAxis(env),
|
|
99
|
-
packageRoot: env.packageRoot,
|
|
100
|
-
})),
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
const turnRequest = buildDiaristTurnRequest(admitted, turnProjection);
|
|
104
|
-
return await runPostAdmissionOneShot({
|
|
105
|
-
admitted,
|
|
106
|
-
env,
|
|
107
|
-
io,
|
|
108
|
-
request: turnRequest,
|
|
109
|
-
adapters: diaristAdapters(env),
|
|
110
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Resume a previously admitted Diarist run (#708 / ADR 0079 同票传召 = resume).
|
|
115
|
-
* LLM re-finds materials; entry identity keeps the volume idempotent.
|
|
116
|
-
*/
|
|
117
|
-
export async function runPublicDiaristResume(request, env, io) {
|
|
118
|
-
return await runPostAdmissionSeatResume({
|
|
119
|
-
request,
|
|
120
|
-
env,
|
|
121
|
-
io,
|
|
122
|
-
load: (effective) => loadResumableDiaristRun(env.home, effective.runId, env.principalAuthority),
|
|
123
|
-
buildTurnRequest: async (admitted, effective) => {
|
|
124
|
-
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
125
|
-
return buildDiaristTurnRequest(admitted, resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared));
|
|
126
|
-
},
|
|
127
|
-
adapters: diaristAdapters(env),
|
|
128
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
129
|
-
});
|
|
130
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.js";
|
|
2
|
-
import { CliUsageError } from "./cli-errors.js";
|
|
3
|
-
import { admitDoctorInvocation, buildDoctorTransportPrompt } from "./invocation.js";
|
|
4
|
-
import { runPostAdmissionOneShot, runPostAdmissionSeatResume, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
|
|
5
|
-
import { loadResumableDoctorRun, markRunAdmitted, } from "./run-lifecycle.js";
|
|
6
|
-
import { presentStructuralRejection, trySettleDoctorTerminalResult, } from "./settlement.js";
|
|
7
|
-
import { isLawfulTypedTerminalOutcome, } from "./terminal.js";
|
|
8
|
-
import { projectRoleTurnRequest, } from "./turn-request.js";
|
|
9
|
-
/** Project admitted invocation onto the host-neutral turn request. */
|
|
10
|
-
export function buildDoctorTurnRequest(admitted, options) {
|
|
11
|
-
return projectRoleTurnRequest(admitted, {
|
|
12
|
-
activation: { role: "doctor", casePath: admitted.caseRunsPath },
|
|
13
|
-
}, options);
|
|
14
|
-
}
|
|
15
|
-
export async function runPublicDoctor(argv, env, io, parseDoctorArgv) {
|
|
16
|
-
let admitted;
|
|
17
|
-
try {
|
|
18
|
-
const parsed = parseDoctorArgv(argv);
|
|
19
|
-
admitted = await admitDoctorInvocation({
|
|
20
|
-
home: env.home,
|
|
21
|
-
principalAuthority: env.principalAuthority,
|
|
22
|
-
cwd: env.cwd,
|
|
23
|
-
issueNumber: parsed.issueNumber,
|
|
24
|
-
instruction: parsed.instruction,
|
|
25
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
26
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
27
|
-
...(parsed.runs === undefined ? {} : { runs: parsed.runs }),
|
|
28
|
-
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
29
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
if (error instanceof CliUsageError) {
|
|
34
|
-
presentStructuralRejection(error, io);
|
|
35
|
-
return { exitCode: 2 };
|
|
36
|
-
}
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
40
|
-
const turnRequest = buildDoctorTurnRequest(admitted, {
|
|
41
|
-
packageRoot: env.packageRoot,
|
|
42
|
-
home: env.home,
|
|
43
|
-
agentDir: env.agentDir,
|
|
44
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
45
|
-
...pickEngineAxis(env),
|
|
46
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
47
|
-
...(env.correlationId === undefined || env.correlationId.trim() === ""
|
|
48
|
-
? {}
|
|
49
|
-
: { correlationId: env.correlationId }),
|
|
50
|
-
continuation: {
|
|
51
|
-
kind: "initial",
|
|
52
|
-
prompt: buildDoctorTransportPrompt(admitted, engineSessionMaterialFromOptions({
|
|
53
|
-
...pickEngineAxis(env),
|
|
54
|
-
packageRoot: env.packageRoot,
|
|
55
|
-
})),
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
return await runPostAdmissionOneShot({
|
|
59
|
-
admitted,
|
|
60
|
-
env,
|
|
61
|
-
io,
|
|
62
|
-
request: turnRequest,
|
|
63
|
-
adapters: doctorAdapters(),
|
|
64
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
function doctorAdapters() {
|
|
68
|
-
return {
|
|
69
|
-
trySettle: (admitted, authority, scope) => trySettleDoctorTerminalResult(admitted, authority, scope),
|
|
70
|
-
shouldPresentSettled: (terminal) => isLawfulTypedTerminalOutcome(terminal.roleOutcome),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Resume a previously admitted Doctor run (#633). Issue + retained case
|
|
75
|
-
* identity restore from the durable admitted request; the session principal reopens.
|
|
76
|
-
*/
|
|
77
|
-
export async function runPublicDoctorResume(request, env, io) {
|
|
78
|
-
return await runPostAdmissionSeatResume({
|
|
79
|
-
request,
|
|
80
|
-
env,
|
|
81
|
-
io,
|
|
82
|
-
load: (effective) => loadResumableDoctorRun(env.home, effective.runId, env.principalAuthority),
|
|
83
|
-
buildTurnRequest: (admitted, effective) => buildDoctorTurnRequest(admitted, resumeTurnRequestProjectionOptions(admitted, effective, env)),
|
|
84
|
-
adapters: doctorAdapters(),
|
|
85
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
86
|
-
});
|
|
87
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.js";
|
|
2
|
-
import { CliUsageError } from "./cli-errors.js";
|
|
3
|
-
import { tryResumeSameTicketSeatRun } from "./seat-ticket-binding.js";
|
|
4
|
-
import { admitInspectorInvocation, buildInspectorTransportPrompt, persistAdmittedSourceRunPath, } from "./invocation.js";
|
|
5
|
-
import { prepareSummonsResumeMaterials, runPostAdmissionOneShot, runPostAdmissionSeatResume, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
|
|
6
|
-
import { loadResumableInspectorRun, markRunAdmitted, parentRunPathFromGatePointerInstruction, } from "./run-lifecycle.js";
|
|
7
|
-
import { presentStructuralRejection, trySettleInspectorTerminalResult, } from "./settlement.js";
|
|
8
|
-
import { projectRoleTurnRequest, } from "./turn-request.js";
|
|
9
|
-
function inspectorParentRunPath(admitted) {
|
|
10
|
-
if (typeof admitted.sourceRunPath === "string" && admitted.sourceRunPath.trim() !== "") {
|
|
11
|
-
return admitted.sourceRunPath;
|
|
12
|
-
}
|
|
13
|
-
return parentRunPathFromGatePointerInstruction(admitted.instruction);
|
|
14
|
-
}
|
|
15
|
-
/** Project admitted invocation onto the host-neutral turn request. */
|
|
16
|
-
export function buildInspectorTurnRequest(admitted, options) {
|
|
17
|
-
const sourceRun = inspectorParentRunPath(admitted);
|
|
18
|
-
return projectRoleTurnRequest(admitted, {
|
|
19
|
-
activation: {
|
|
20
|
-
role: "inspector",
|
|
21
|
-
...(sourceRun === undefined ? {} : { sourceRun }),
|
|
22
|
-
},
|
|
23
|
-
}, options);
|
|
24
|
-
}
|
|
25
|
-
export async function runPublicInspector(argv, env, io, parseInspectorArgv) {
|
|
26
|
-
let parsed;
|
|
27
|
-
try {
|
|
28
|
-
parsed = parseInspectorArgv(argv);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (error instanceof CliUsageError) {
|
|
32
|
-
presentStructuralRejection(error, io);
|
|
33
|
-
return { exitCode: 2 };
|
|
34
|
-
}
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
37
|
-
// #747: same parent (卷宗指针) → resume prior inspector run with this summons' materials.
|
|
38
|
-
// #771: no mechanical ticket match against instruction text; parent-run path only.
|
|
39
|
-
// No bare catch→fresh: lookup/resume failures surface; only true absence mints new.
|
|
40
|
-
const projectRoot = parsed.project ?? env.cwd;
|
|
41
|
-
// #747: parentRunPath is the pure 卷宗指针 path only — never reask/materials text.
|
|
42
|
-
// #753/#786: gate re-ask / verbatim submission body ride summons.instruction on resume.
|
|
43
|
-
const parentRunPath = parentRunPathFromGatePointerInstruction(parsed.instruction);
|
|
44
|
-
if (parentRunPath !== undefined) {
|
|
45
|
-
const resumeInstruction = env.reviewReask ?? env.gateReviewInstruction;
|
|
46
|
-
const summons = {
|
|
47
|
-
sourceRunPath: parentRunPath,
|
|
48
|
-
...(resumeInstruction === undefined
|
|
49
|
-
? {
|
|
50
|
-
instruction: parsed.instruction,
|
|
51
|
-
instructionEmpty: parsed.instruction.trim() === "",
|
|
52
|
-
}
|
|
53
|
-
: { instruction: resumeInstruction, instructionEmpty: false }),
|
|
54
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
55
|
-
};
|
|
56
|
-
const resumed = await tryResumeSameTicketSeatRun({
|
|
57
|
-
home: env.home,
|
|
58
|
-
projectRoot,
|
|
59
|
-
role: "inspector",
|
|
60
|
-
parentRunPath,
|
|
61
|
-
freshSummons: env.freshSummons,
|
|
62
|
-
summons,
|
|
63
|
-
resume: (runId, materials) => runPublicInspectorResume({ runId, ...(materials === undefined ? {} : { summons: materials }) }, env, io),
|
|
64
|
-
});
|
|
65
|
-
if (resumed !== undefined)
|
|
66
|
-
return resumed;
|
|
67
|
-
}
|
|
68
|
-
let admitted;
|
|
69
|
-
try {
|
|
70
|
-
admitted = await admitInspectorInvocation({
|
|
71
|
-
home: env.home,
|
|
72
|
-
principalAuthority: env.principalAuthority,
|
|
73
|
-
cwd: env.cwd,
|
|
74
|
-
instruction: parsed.instruction,
|
|
75
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
76
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
77
|
-
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
78
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
79
|
-
...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
if (error instanceof CliUsageError) {
|
|
84
|
-
presentStructuralRejection(error, io);
|
|
85
|
-
return { exitCode: 2 };
|
|
86
|
-
}
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
90
|
-
if (parentRunPath !== undefined) {
|
|
91
|
-
await persistAdmittedSourceRunPath(admitted, parentRunPath);
|
|
92
|
-
admitted = { ...admitted, sourceRunPath: parentRunPath };
|
|
93
|
-
}
|
|
94
|
-
const engineMaterial = engineSessionMaterialFromOptions({
|
|
95
|
-
...pickEngineAxis(env),
|
|
96
|
-
packageRoot: env.packageRoot,
|
|
97
|
-
});
|
|
98
|
-
const turnRequest = buildInspectorTurnRequest(admitted, {
|
|
99
|
-
packageRoot: env.packageRoot,
|
|
100
|
-
home: env.home,
|
|
101
|
-
agentDir: env.agentDir,
|
|
102
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
103
|
-
...pickEngineAxis(env),
|
|
104
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
105
|
-
...(env.correlationId === undefined || env.correlationId.trim() === ""
|
|
106
|
-
? {}
|
|
107
|
-
: { correlationId: env.correlationId }),
|
|
108
|
-
continuation: {
|
|
109
|
-
kind: "initial",
|
|
110
|
-
// #879: gate first mint uses parent payload as content; binding stays typed activation.
|
|
111
|
-
prompt: (env.reviewReask ?? env.gateReviewInstruction)
|
|
112
|
-
?? buildInspectorTransportPrompt(admitted, engineMaterial),
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
return await runPostAdmissionOneShot({
|
|
116
|
-
admitted,
|
|
117
|
-
env,
|
|
118
|
-
io,
|
|
119
|
-
request: turnRequest,
|
|
120
|
-
adapters: inspectorAdapters(),
|
|
121
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function inspectorAdapters(options) {
|
|
125
|
-
return {
|
|
126
|
-
trySettle: (admitted, authority, scope) => trySettleInspectorTerminalResult(admitted, authority, scope),
|
|
127
|
-
shouldPresentSettled: () => true,
|
|
128
|
-
...(options?.beforeDispatch === undefined
|
|
129
|
-
? {}
|
|
130
|
-
: { beforeDispatch: options.beforeDispatch }),
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Resume a previously admitted Inspector run (#633 / #637); the session principal reopens.
|
|
135
|
-
* Same-ticket summons deliver this turn's instruction + frozen attachments; manual
|
|
136
|
-
* resume forwards only caller-supplied message bytes.
|
|
137
|
-
*/
|
|
138
|
-
export async function runPublicInspectorResume(request, env, io) {
|
|
139
|
-
return await runPostAdmissionSeatResume({
|
|
140
|
-
request,
|
|
141
|
-
env,
|
|
142
|
-
io,
|
|
143
|
-
load: (effective) => loadResumableInspectorRun(env.home, effective.runId, env.principalAuthority),
|
|
144
|
-
buildTurnRequest: async (admitted, effective) => {
|
|
145
|
-
const summonsPrepared = await prepareSummonsResumeMaterials(admitted.runDirectory, effective.summons);
|
|
146
|
-
return buildInspectorTurnRequest(admitted, resumeTurnRequestProjectionOptions(admitted, effective, env, summonsPrepared));
|
|
147
|
-
},
|
|
148
|
-
adapters: inspectorAdapters(),
|
|
149
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.js";
|
|
2
|
-
import { CliUsageError } from "./cli-errors.js";
|
|
3
|
-
import { admitJudgeInvocation, buildJudgeTransportPrompt, } from "./invocation.js";
|
|
4
|
-
import { loadResumableJudgeRun, markRunAdmitted, buildAutoResumeContinuationPrompt, } from "./run-lifecycle.js";
|
|
5
|
-
import { presentStructuralRejection, readEngineDetourInfrastructureFailure, trySettleJudgeTerminalResult, } from "./settlement.js";
|
|
6
|
-
import { projectRoleTurnRequest, } from "./turn-request.js";
|
|
7
|
-
import { runPostAdmissionResumable, runPostAdmissionSeatResume, resumeTurnRequestProjectionOptions, } from "./post-admission.js";
|
|
8
|
-
/** Project admitted invocation onto the host-neutral turn request. */
|
|
9
|
-
export function buildJudgeTurnRequest(admitted, options) {
|
|
10
|
-
return projectRoleTurnRequest(admitted, { activation: { role: "judge" } }, options);
|
|
11
|
-
}
|
|
12
|
-
function judgeAdapters() {
|
|
13
|
-
return {
|
|
14
|
-
trySettle: (admitted, authority, scope) => trySettleJudgeTerminalResult(admitted, authority, scope),
|
|
15
|
-
resolveRunnerKnownFailure: async ({ result, sessionFile }) => {
|
|
16
|
-
const infrastructureFailure = await readEngineDetourInfrastructureFailure(sessionFile);
|
|
17
|
-
return (result.knownFailure ??
|
|
18
|
-
(infrastructureFailure === undefined
|
|
19
|
-
? undefined
|
|
20
|
-
: {
|
|
21
|
-
...(infrastructureFailure.cause === undefined
|
|
22
|
-
? {}
|
|
23
|
-
: { cause: infrastructureFailure.cause }),
|
|
24
|
-
diagnostic: infrastructureFailure.diagnostic,
|
|
25
|
-
...(infrastructureFailure.identity === undefined
|
|
26
|
-
? {}
|
|
27
|
-
: { identity: infrastructureFailure.identity }),
|
|
28
|
-
}));
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export async function runPublicJudge(argv, env, io, parseJudgeArgv) {
|
|
33
|
-
let admitted;
|
|
34
|
-
try {
|
|
35
|
-
const parsed = parseJudgeArgv(argv);
|
|
36
|
-
admitted = await admitJudgeInvocation({
|
|
37
|
-
home: env.home,
|
|
38
|
-
principalAuthority: env.principalAuthority,
|
|
39
|
-
cwd: env.cwd,
|
|
40
|
-
instruction: parsed.instruction,
|
|
41
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
42
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
43
|
-
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
44
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
if (error instanceof CliUsageError) {
|
|
49
|
-
presentStructuralRejection(error, io);
|
|
50
|
-
return { exitCode: 2 };
|
|
51
|
-
}
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
55
|
-
return await runPostAdmissionResumable({
|
|
56
|
-
admitted,
|
|
57
|
-
env,
|
|
58
|
-
io,
|
|
59
|
-
buildInitialRequest: () => buildJudgeTurnRequest(admitted, {
|
|
60
|
-
packageRoot: env.packageRoot,
|
|
61
|
-
home: env.home,
|
|
62
|
-
agentDir: env.agentDir,
|
|
63
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
64
|
-
...pickEngineAxis(env),
|
|
65
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
66
|
-
...(admitted.correlationId === undefined && env.correlationId === undefined
|
|
67
|
-
? {}
|
|
68
|
-
: { correlationId: admitted.correlationId ?? env.correlationId }),
|
|
69
|
-
continuation: {
|
|
70
|
-
kind: "initial",
|
|
71
|
-
prompt: buildJudgeTransportPrompt(admitted, engineSessionMaterialFromOptions({
|
|
72
|
-
...pickEngineAxis(env),
|
|
73
|
-
packageRoot: env.packageRoot,
|
|
74
|
-
})),
|
|
75
|
-
},
|
|
76
|
-
}),
|
|
77
|
-
buildResumeRequest: () => buildJudgeTurnRequest(admitted, {
|
|
78
|
-
packageRoot: env.packageRoot,
|
|
79
|
-
home: env.home,
|
|
80
|
-
agentDir: env.agentDir,
|
|
81
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
82
|
-
...pickEngineAxis(env),
|
|
83
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
84
|
-
...(admitted.correlationId === undefined && env.correlationId === undefined
|
|
85
|
-
? {}
|
|
86
|
-
: { correlationId: admitted.correlationId ?? env.correlationId }),
|
|
87
|
-
continuation: {
|
|
88
|
-
kind: "resume",
|
|
89
|
-
prompt: buildAutoResumeContinuationPrompt({
|
|
90
|
-
packageRoot: env.packageRoot,
|
|
91
|
-
...pickEngineAxis(env),
|
|
92
|
-
}),
|
|
93
|
-
},
|
|
94
|
-
}),
|
|
95
|
-
adapters: judgeAdapters(),
|
|
96
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Resume a previously admitted Role run after a typed HTTP 429 interruption.
|
|
101
|
-
* Restores role/project/instruction/attachments/session identity; model override
|
|
102
|
-
* is temporary for this invocation only.
|
|
103
|
-
*/
|
|
104
|
-
export async function runPublicResume(request, env, io) {
|
|
105
|
-
return await runPostAdmissionSeatResume({
|
|
106
|
-
request,
|
|
107
|
-
env,
|
|
108
|
-
io,
|
|
109
|
-
load: (effective) => loadResumableJudgeRun(env.home, effective.runId, env.principalAuthority),
|
|
110
|
-
buildTurnRequest: (admitted, effective) => buildJudgeTurnRequest(admitted, resumeTurnRequestProjectionOptions(admitted, effective, env)),
|
|
111
|
-
adapters: judgeAdapters(),
|
|
112
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
113
|
-
});
|
|
114
|
-
}
|