@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
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public Doctor Role run: admit Issue → retained case via #78 → shared post-admission
|
|
3
|
-
* coordinator → settle Terminal result (#113 / #517). Lifecycle is the shared
|
|
4
|
-
* post-admission seam; this module keeps only Doctor adapters.
|
|
5
|
-
*/
|
|
6
|
-
import type { DurablePrincipalAuthority, RoleTurnRequest } from "../host-contracts.ts";
|
|
7
|
-
import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.ts";
|
|
8
|
-
import { CliUsageError } from "./cli-errors.ts";
|
|
9
|
-
import {
|
|
10
|
-
admitDoctorInvocation,
|
|
11
|
-
buildDoctorTransportPrompt,
|
|
12
|
-
type AdmittedDoctorInvocation,
|
|
13
|
-
type ParseDoctorArgvResult
|
|
14
|
-
} from "./invocation.ts";
|
|
15
|
-
import {
|
|
16
|
-
runPostAdmissionOneShot,
|
|
17
|
-
type PostAdmissionAdapters,
|
|
18
|
-
type PostAdmissionEnv,
|
|
19
|
-
runPostAdmissionSeatResume,
|
|
20
|
-
resumeTurnRequestProjectionOptions,
|
|
21
|
-
} from "./post-admission.ts";
|
|
22
|
-
import {
|
|
23
|
-
loadResumableDoctorRun,
|
|
24
|
-
markRunAdmitted,
|
|
25
|
-
type PublicResumeRequest,
|
|
26
|
-
} from "./run-lifecycle.ts";
|
|
27
|
-
import {
|
|
28
|
-
presentStructuralRejection,
|
|
29
|
-
trySettleDoctorTerminalResult,
|
|
30
|
-
} from "./settlement.ts";
|
|
31
|
-
import type { CliIo } from "./cli-io.ts";
|
|
32
|
-
import {
|
|
33
|
-
isLawfulTypedTerminalOutcome,
|
|
34
|
-
type TerminalResult,
|
|
35
|
-
} from "./terminal.ts";
|
|
36
|
-
import {
|
|
37
|
-
projectRoleTurnRequest,
|
|
38
|
-
type RoleTurnRequestProjectionOptions,
|
|
39
|
-
} from "./turn-request.ts";
|
|
40
|
-
|
|
41
|
-
export type DoctorRunEnv = PostAdmissionEnv & {
|
|
42
|
-
principalAuthority: DurablePrincipalAuthority;
|
|
43
|
-
createRunId?: () => string;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/** Project admitted invocation onto the host-neutral turn request. */
|
|
47
|
-
export function buildDoctorTurnRequest(
|
|
48
|
-
admitted: AdmittedDoctorInvocation,
|
|
49
|
-
options: RoleTurnRequestProjectionOptions,
|
|
50
|
-
): RoleTurnRequest {
|
|
51
|
-
return projectRoleTurnRequest(
|
|
52
|
-
admitted,
|
|
53
|
-
{
|
|
54
|
-
activation: { role: "doctor" as const, casePath: admitted.caseRunsPath },
|
|
55
|
-
},
|
|
56
|
-
options,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export async function runPublicDoctor(
|
|
61
|
-
argv: readonly string[],
|
|
62
|
-
env: DoctorRunEnv,
|
|
63
|
-
io: CliIo,
|
|
64
|
-
parseDoctorArgv: (args: readonly string[]) => ParseDoctorArgvResult,
|
|
65
|
-
): Promise<{
|
|
66
|
-
exitCode: number;
|
|
67
|
-
admitted?: AdmittedDoctorInvocation;
|
|
68
|
-
terminal?: TerminalResult;
|
|
69
|
-
}> {
|
|
70
|
-
let admitted: AdmittedDoctorInvocation;
|
|
71
|
-
try {
|
|
72
|
-
const parsed = parseDoctorArgv(argv);
|
|
73
|
-
admitted = await admitDoctorInvocation({
|
|
74
|
-
home: env.home,
|
|
75
|
-
principalAuthority: env.principalAuthority,
|
|
76
|
-
cwd: env.cwd,
|
|
77
|
-
issueNumber: parsed.issueNumber,
|
|
78
|
-
instruction: parsed.instruction,
|
|
79
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
80
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
81
|
-
...(parsed.runs === undefined ? {} : { runs: parsed.runs }),
|
|
82
|
-
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
83
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
84
|
-
});
|
|
85
|
-
} catch (error) {
|
|
86
|
-
if (error instanceof CliUsageError) {
|
|
87
|
-
presentStructuralRejection(error, io);
|
|
88
|
-
return { exitCode: 2 };
|
|
89
|
-
}
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
94
|
-
|
|
95
|
-
const turnRequest = buildDoctorTurnRequest(admitted, {
|
|
96
|
-
packageRoot: env.packageRoot,
|
|
97
|
-
home: env.home,
|
|
98
|
-
agentDir: env.agentDir,
|
|
99
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
100
|
-
...pickEngineAxis(env),
|
|
101
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
102
|
-
...(env.correlationId === undefined || env.correlationId.trim() === ""
|
|
103
|
-
? {}
|
|
104
|
-
: { correlationId: env.correlationId }),
|
|
105
|
-
continuation: {
|
|
106
|
-
kind: "initial",
|
|
107
|
-
prompt: buildDoctorTransportPrompt(
|
|
108
|
-
admitted,
|
|
109
|
-
engineSessionMaterialFromOptions({
|
|
110
|
-
...pickEngineAxis(env),
|
|
111
|
-
packageRoot: env.packageRoot,
|
|
112
|
-
}),
|
|
113
|
-
),
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return await runPostAdmissionOneShot({
|
|
118
|
-
admitted,
|
|
119
|
-
env,
|
|
120
|
-
io,
|
|
121
|
-
request: turnRequest,
|
|
122
|
-
adapters: doctorAdapters(),
|
|
123
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function doctorAdapters(): PostAdmissionAdapters<AdmittedDoctorInvocation> {
|
|
128
|
-
return {
|
|
129
|
-
trySettle: (admitted, authority, scope) =>
|
|
130
|
-
trySettleDoctorTerminalResult(admitted, authority, scope),
|
|
131
|
-
shouldPresentSettled: (terminal) =>
|
|
132
|
-
isLawfulTypedTerminalOutcome(terminal.roleOutcome),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Resume a previously admitted Doctor run (#633). Issue + retained case
|
|
138
|
-
* identity restore from the durable admitted request; the session principal reopens.
|
|
139
|
-
*/
|
|
140
|
-
export async function runPublicDoctorResume(
|
|
141
|
-
request: PublicResumeRequest,
|
|
142
|
-
env: DoctorRunEnv,
|
|
143
|
-
io: CliIo,
|
|
144
|
-
): Promise<{
|
|
145
|
-
exitCode: number;
|
|
146
|
-
admitted?: AdmittedDoctorInvocation;
|
|
147
|
-
terminal?: TerminalResult;
|
|
148
|
-
}> {
|
|
149
|
-
return await runPostAdmissionSeatResume({
|
|
150
|
-
request,
|
|
151
|
-
env,
|
|
152
|
-
io,
|
|
153
|
-
load: (effective) =>
|
|
154
|
-
loadResumableDoctorRun(
|
|
155
|
-
env.home,
|
|
156
|
-
effective.runId,
|
|
157
|
-
env.principalAuthority,
|
|
158
|
-
),
|
|
159
|
-
buildTurnRequest: (admitted, effective) =>
|
|
160
|
-
buildDoctorTurnRequest(
|
|
161
|
-
admitted,
|
|
162
|
-
resumeTurnRequestProjectionOptions(admitted, effective, env),
|
|
163
|
-
),
|
|
164
|
-
adapters: doctorAdapters(),
|
|
165
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
166
|
-
});
|
|
167
|
-
}
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public Fixer Role run: admit → post-admission coordinator → settle Terminal result (#110 / #517).
|
|
3
|
-
* #110/#177: package-owned diagnosing-bugs and tdd methods (available, not forced),
|
|
4
|
-
* common Invocation + structural prerequisites, default apply / explicit plan,
|
|
5
|
-
* shared #106 success interface. Controlled-failure settlement reuses #107.
|
|
6
|
-
* #526: execution via RoleTurnHost; argv is Pi adapter internal.
|
|
7
|
-
*/
|
|
8
|
-
import type {
|
|
9
|
-
DurablePrincipalAuthority,
|
|
10
|
-
MethodBinding,
|
|
11
|
-
RoleTurnKnownFailure,
|
|
12
|
-
RoleTurnRequest,
|
|
13
|
-
} from "../host-contracts.ts";
|
|
14
|
-
import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.ts";
|
|
15
|
-
import {
|
|
16
|
-
loadPackagedMethodSkillMaterial,
|
|
17
|
-
resolvePackagedMethodSkillPath,
|
|
18
|
-
type PackagedMethodSkillMaterial,
|
|
19
|
-
type PackagedMethodSkillProvenance,
|
|
20
|
-
} from "../package-resources/method-skill.ts";
|
|
21
|
-
import { CliUsageError } from "./cli-errors.ts";
|
|
22
|
-
import {
|
|
23
|
-
admitFixerInvocation,
|
|
24
|
-
buildFixerTransportPrompt,
|
|
25
|
-
type AdmittedFixerInvocation,
|
|
26
|
-
} from "./invocation.ts";
|
|
27
|
-
import {
|
|
28
|
-
buildAutoResumeContinuationPrompt,
|
|
29
|
-
loadResumableFixerRun,
|
|
30
|
-
markRunAdmitted,
|
|
31
|
-
type PublicResumeRequest,
|
|
32
|
-
} from "./run-lifecycle.ts";
|
|
33
|
-
import {
|
|
34
|
-
presentStructuralRejection,
|
|
35
|
-
trySettleFixerTerminalResult,
|
|
36
|
-
} from "./settlement.ts";
|
|
37
|
-
import type { CliIo } from "./cli-io.ts";
|
|
38
|
-
import type { TerminalResult } from "./terminal.ts";
|
|
39
|
-
import {
|
|
40
|
-
projectRoleTurnRequest,
|
|
41
|
-
type RoleTurnRequestProjectionOptions,
|
|
42
|
-
} from "./turn-request.ts";
|
|
43
|
-
import {
|
|
44
|
-
presentControlledFailure,
|
|
45
|
-
resolveResumeMethodMaterialAdapters,
|
|
46
|
-
runPostAdmissionResumable,
|
|
47
|
-
runPostAdmissionSeatResume,
|
|
48
|
-
type PostAdmissionAdapters,
|
|
49
|
-
type PostAdmissionEnv,
|
|
50
|
-
resumeTurnRequestProjectionOptions,
|
|
51
|
-
} from "./post-admission.ts";
|
|
52
|
-
|
|
53
|
-
export type FixerRunEnv = PostAdmissionEnv & {
|
|
54
|
-
createRunId?: () => string;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function fixerMethods(packageRoot: string): readonly MethodBinding[] {
|
|
58
|
-
return [
|
|
59
|
-
{ kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot, "diagnosing-bugs") },
|
|
60
|
-
{ kind: "skill", path: resolvePackagedMethodSkillPath(packageRoot, "tdd") },
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Project admitted Fixer invocation onto the host-neutral turn request. */
|
|
65
|
-
export function buildFixerTurnRequest(
|
|
66
|
-
admitted: AdmittedFixerInvocation,
|
|
67
|
-
options: RoleTurnRequestProjectionOptions,
|
|
68
|
-
): RoleTurnRequest {
|
|
69
|
-
return projectRoleTurnRequest(
|
|
70
|
-
admitted,
|
|
71
|
-
{
|
|
72
|
-
activation: {
|
|
73
|
-
role: "fixer",
|
|
74
|
-
phase: admitted.phase,
|
|
75
|
-
packetPath: admitted.packetPath,
|
|
76
|
-
...(admitted.prerequisitesPath === undefined
|
|
77
|
-
? {}
|
|
78
|
-
: { prerequisitesPath: admitted.prerequisitesPath }),
|
|
79
|
-
},
|
|
80
|
-
methods: fixerMethods(options.packageRoot),
|
|
81
|
-
},
|
|
82
|
-
options,
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function fixerAdapters(
|
|
87
|
-
packageRoot: string,
|
|
88
|
-
methodMaterial?: PackagedMethodSkillMaterial,
|
|
89
|
-
): PostAdmissionAdapters<AdmittedFixerInvocation> {
|
|
90
|
-
return {
|
|
91
|
-
trySettle: (admitted, authority, scope) =>
|
|
92
|
-
methodMaterial === undefined
|
|
93
|
-
? Promise.resolve(undefined)
|
|
94
|
-
: trySettleFixerTerminalResult(
|
|
95
|
-
admitted,
|
|
96
|
-
authority,
|
|
97
|
-
{
|
|
98
|
-
methodProvenance: methodMaterial.provenance,
|
|
99
|
-
methodSkillPath: methodMaterial.skillPath,
|
|
100
|
-
methodSkillConfiguredPath: resolvePackagedMethodSkillPath(
|
|
101
|
-
packageRoot,
|
|
102
|
-
"diagnosing-bugs",
|
|
103
|
-
),
|
|
104
|
-
},
|
|
105
|
-
scope,
|
|
106
|
-
),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function loadFixerMethodMaterial(
|
|
111
|
-
packageRoot: string,
|
|
112
|
-
): Promise<PackagedMethodSkillMaterial> {
|
|
113
|
-
return await loadPackagedMethodSkillMaterial(packageRoot, "diagnosing-bugs");
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export async function runPublicFixer(
|
|
117
|
-
argv: readonly string[],
|
|
118
|
-
env: FixerRunEnv,
|
|
119
|
-
io: CliIo,
|
|
120
|
-
parseFixerArgv: (args: readonly string[]) => {
|
|
121
|
-
phase: "plan" | "apply";
|
|
122
|
-
instruction: string;
|
|
123
|
-
attachmentPaths: string[];
|
|
124
|
-
prerequisitesPath?: string;
|
|
125
|
-
project?: string;
|
|
126
|
-
},
|
|
127
|
-
): Promise<{
|
|
128
|
-
exitCode: number;
|
|
129
|
-
admitted?: AdmittedFixerInvocation;
|
|
130
|
-
terminal?: TerminalResult;
|
|
131
|
-
}> {
|
|
132
|
-
let admitted: AdmittedFixerInvocation;
|
|
133
|
-
try {
|
|
134
|
-
const parsed = parseFixerArgv(argv);
|
|
135
|
-
admitted = await admitFixerInvocation({
|
|
136
|
-
home: env.home,
|
|
137
|
-
principalAuthority: env.principalAuthority,
|
|
138
|
-
cwd: env.cwd,
|
|
139
|
-
phase: parsed.phase,
|
|
140
|
-
instruction: parsed.instruction,
|
|
141
|
-
attachmentPaths: parsed.attachmentPaths,
|
|
142
|
-
...(parsed.prerequisitesPath === undefined
|
|
143
|
-
? {}
|
|
144
|
-
: { prerequisitesPath: parsed.prerequisitesPath }),
|
|
145
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
146
|
-
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
147
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
148
|
-
});
|
|
149
|
-
} catch (error) {
|
|
150
|
-
if (error instanceof CliUsageError) {
|
|
151
|
-
presentStructuralRejection(error, io);
|
|
152
|
-
return { exitCode: 2 };
|
|
153
|
-
}
|
|
154
|
-
throw error;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
158
|
-
|
|
159
|
-
let methodMaterial: PackagedMethodSkillMaterial;
|
|
160
|
-
try {
|
|
161
|
-
methodMaterial = await loadFixerMethodMaterial(env.packageRoot);
|
|
162
|
-
} catch (error) {
|
|
163
|
-
return (await presentControlledFailure(
|
|
164
|
-
admitted,
|
|
165
|
-
{
|
|
166
|
-
timedOut: false,
|
|
167
|
-
code: null,
|
|
168
|
-
stderr: "",
|
|
169
|
-
thrown: error,
|
|
170
|
-
},
|
|
171
|
-
fixerAdapters(env.packageRoot),
|
|
172
|
-
env.principalAuthority,
|
|
173
|
-
io,
|
|
174
|
-
)) as { exitCode: number; admitted: AdmittedFixerInvocation; terminal: TerminalResult };
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return await runPostAdmissionResumable({
|
|
178
|
-
admitted,
|
|
179
|
-
env,
|
|
180
|
-
io,
|
|
181
|
-
buildInitialRequest: () =>
|
|
182
|
-
buildFixerTurnRequest(admitted, {
|
|
183
|
-
packageRoot: env.packageRoot,
|
|
184
|
-
home: env.home,
|
|
185
|
-
agentDir: env.agentDir,
|
|
186
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
187
|
-
...pickEngineAxis(env),
|
|
188
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
189
|
-
...(admitted.correlationId === undefined && env.correlationId === undefined
|
|
190
|
-
? {}
|
|
191
|
-
: { correlationId: admitted.correlationId ?? env.correlationId }),
|
|
192
|
-
continuation: {
|
|
193
|
-
kind: "initial",
|
|
194
|
-
prompt: buildFixerTransportPrompt(
|
|
195
|
-
admitted,
|
|
196
|
-
engineSessionMaterialFromOptions({
|
|
197
|
-
...pickEngineAxis(env),
|
|
198
|
-
packageRoot: env.packageRoot,
|
|
199
|
-
}),
|
|
200
|
-
),
|
|
201
|
-
},
|
|
202
|
-
}),
|
|
203
|
-
buildResumeRequest: () =>
|
|
204
|
-
buildFixerTurnRequest(admitted, {
|
|
205
|
-
packageRoot: env.packageRoot,
|
|
206
|
-
home: env.home,
|
|
207
|
-
agentDir: env.agentDir,
|
|
208
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
209
|
-
...pickEngineAxis(env),
|
|
210
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
211
|
-
...(admitted.correlationId === undefined && env.correlationId === undefined
|
|
212
|
-
? {}
|
|
213
|
-
: { correlationId: admitted.correlationId ?? env.correlationId }),
|
|
214
|
-
continuation: {
|
|
215
|
-
kind: "resume",
|
|
216
|
-
prompt: buildAutoResumeContinuationPrompt({
|
|
217
|
-
packageRoot: env.packageRoot,
|
|
218
|
-
...pickEngineAxis(env),
|
|
219
|
-
}),
|
|
220
|
-
},
|
|
221
|
-
}),
|
|
222
|
-
adapters: fixerAdapters(env.packageRoot, methodMaterial),
|
|
223
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Resume a previously admitted Fixer Role run after a typed HTTP 429.
|
|
229
|
-
* Restores role/phase/packet/prerequisites/session identity; model override is temporary.
|
|
230
|
-
*/
|
|
231
|
-
export async function runPublicFixerResume(
|
|
232
|
-
request: PublicResumeRequest,
|
|
233
|
-
env: FixerRunEnv,
|
|
234
|
-
io: CliIo,
|
|
235
|
-
): Promise<{
|
|
236
|
-
exitCode: number;
|
|
237
|
-
admitted?: AdmittedFixerInvocation;
|
|
238
|
-
terminal?: TerminalResult;
|
|
239
|
-
}> {
|
|
240
|
-
return await runPostAdmissionSeatResume({
|
|
241
|
-
request,
|
|
242
|
-
env,
|
|
243
|
-
io,
|
|
244
|
-
load: (effective) =>
|
|
245
|
-
loadResumableFixerRun(env.home, effective.runId, env.principalAuthority),
|
|
246
|
-
buildTurnRequest: (admitted, effective) =>
|
|
247
|
-
buildFixerTurnRequest(
|
|
248
|
-
admitted,
|
|
249
|
-
resumeTurnRequestProjectionOptions(admitted, effective, env),
|
|
250
|
-
),
|
|
251
|
-
adapters: fixerAdapters(env.packageRoot),
|
|
252
|
-
afterAdmittedLoad: (admitted) =>
|
|
253
|
-
resolveResumeMethodMaterialAdapters({
|
|
254
|
-
admitted,
|
|
255
|
-
authority: env.principalAuthority,
|
|
256
|
-
io,
|
|
257
|
-
loadMaterial: () => loadFixerMethodMaterial(env.packageRoot),
|
|
258
|
-
adaptersWith: (material) => fixerAdapters(env.packageRoot, material),
|
|
259
|
-
emptyAdapters: fixerAdapters(env.packageRoot),
|
|
260
|
-
}),
|
|
261
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export type { RoleTurnKnownFailure, PackagedMethodSkillProvenance };
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public Gleaner-Left Role run: admit (instruction may be empty; --base required)
|
|
3
|
-
* → shared post-admission coordinator → settle Terminal result (#502 / ADR 0067).
|
|
4
|
-
* #599: manual resume continues the exact session; 只上弹章.
|
|
5
|
-
*/
|
|
6
|
-
import type { DurablePrincipalAuthority, RoleTurnRequest } from "../host-contracts.ts";
|
|
7
|
-
import { engineSessionMaterialFromOptions, pickEngineAxis } from "../package-resources/engine-material.ts";
|
|
8
|
-
import { CliUsageError } from "./cli-errors.ts";
|
|
9
|
-
import {
|
|
10
|
-
admitGleanerLeftInvocation,
|
|
11
|
-
buildGleanerLeftTransportPrompt,
|
|
12
|
-
type AdmittedGleanerLeftInvocation,
|
|
13
|
-
type ParseGleanerLeftArgvResult,
|
|
14
|
-
} from "./invocation.ts";
|
|
15
|
-
import {
|
|
16
|
-
runPostAdmissionOneShot,
|
|
17
|
-
type PostAdmissionEnv,
|
|
18
|
-
runPostAdmissionSeatResume,
|
|
19
|
-
resumeTurnRequestProjectionOptions,
|
|
20
|
-
} from "./post-admission.ts";
|
|
21
|
-
import {
|
|
22
|
-
loadResumableGleanerLeftRun,
|
|
23
|
-
markRunAdmitted,
|
|
24
|
-
type PublicResumeRequest,
|
|
25
|
-
} from "./run-lifecycle.ts";
|
|
26
|
-
import {
|
|
27
|
-
presentStructuralRejection,
|
|
28
|
-
trySettleGleanerLeftTerminalResult,
|
|
29
|
-
} from "./settlement.ts";
|
|
30
|
-
import type { CliIo } from "./cli-io.ts";
|
|
31
|
-
import type { TerminalResult } from "./terminal.ts";
|
|
32
|
-
import {
|
|
33
|
-
projectRoleTurnRequest,
|
|
34
|
-
type RoleTurnRequestProjectionOptions,
|
|
35
|
-
} from "./turn-request.ts";
|
|
36
|
-
|
|
37
|
-
export type GleanerLeftRunEnv = PostAdmissionEnv & {
|
|
38
|
-
principalAuthority: DurablePrincipalAuthority;
|
|
39
|
-
createRunId?: () => string;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/** Project admitted invocation onto the host-neutral turn request. */
|
|
43
|
-
export function buildGleanerLeftTurnRequest(
|
|
44
|
-
admitted: AdmittedGleanerLeftInvocation,
|
|
45
|
-
options: RoleTurnRequestProjectionOptions,
|
|
46
|
-
): RoleTurnRequest {
|
|
47
|
-
return projectRoleTurnRequest(
|
|
48
|
-
admitted,
|
|
49
|
-
{
|
|
50
|
-
activation: {
|
|
51
|
-
role: "gleaner-left" as const,
|
|
52
|
-
baseRevision: admitted.baseRevision,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
options,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export async function runPublicGleanerLeft(
|
|
60
|
-
argv: readonly string[],
|
|
61
|
-
env: GleanerLeftRunEnv,
|
|
62
|
-
io: CliIo,
|
|
63
|
-
parseGleanerLeftArgv: (args: readonly string[]) => ParseGleanerLeftArgvResult,
|
|
64
|
-
): Promise<{
|
|
65
|
-
exitCode: number;
|
|
66
|
-
admitted?: AdmittedGleanerLeftInvocation;
|
|
67
|
-
terminal?: TerminalResult;
|
|
68
|
-
}> {
|
|
69
|
-
let admitted: AdmittedGleanerLeftInvocation;
|
|
70
|
-
try {
|
|
71
|
-
const parsed = parseGleanerLeftArgv(argv);
|
|
72
|
-
admitted = await admitGleanerLeftInvocation({
|
|
73
|
-
home: env.home,
|
|
74
|
-
principalAuthority: env.principalAuthority,
|
|
75
|
-
cwd: env.cwd,
|
|
76
|
-
instruction: parsed.instruction,
|
|
77
|
-
baseRevision: parsed.baseRevision,
|
|
78
|
-
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
79
|
-
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
80
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
81
|
-
...(env.correlationId === undefined ? {} : { correlationId: env.correlationId }),
|
|
82
|
-
});
|
|
83
|
-
} catch (error) {
|
|
84
|
-
if (error instanceof CliUsageError) {
|
|
85
|
-
presentStructuralRejection(error, io);
|
|
86
|
-
return { exitCode: 2 };
|
|
87
|
-
}
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
await markRunAdmitted(admitted, env.principalAuthority);
|
|
92
|
-
|
|
93
|
-
const turnRequest = buildGleanerLeftTurnRequest(admitted, {
|
|
94
|
-
packageRoot: env.packageRoot,
|
|
95
|
-
home: env.home,
|
|
96
|
-
agentDir: env.agentDir,
|
|
97
|
-
...(env.model === undefined ? {} : { model: env.model }),
|
|
98
|
-
...pickEngineAxis(env),
|
|
99
|
-
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
100
|
-
...(env.correlationId === undefined || env.correlationId.trim() === ""
|
|
101
|
-
? {}
|
|
102
|
-
: { correlationId: env.correlationId }),
|
|
103
|
-
continuation: {
|
|
104
|
-
kind: "initial",
|
|
105
|
-
prompt: buildGleanerLeftTransportPrompt(
|
|
106
|
-
admitted,
|
|
107
|
-
engineSessionMaterialFromOptions({
|
|
108
|
-
...pickEngineAxis(env),
|
|
109
|
-
packageRoot: env.packageRoot,
|
|
110
|
-
}),
|
|
111
|
-
),
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
return await runPostAdmissionOneShot({
|
|
116
|
-
admitted,
|
|
117
|
-
env,
|
|
118
|
-
io,
|
|
119
|
-
request: turnRequest,
|
|
120
|
-
adapters: gleanerLeftAdapters(),
|
|
121
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function gleanerLeftAdapters() {
|
|
126
|
-
return {
|
|
127
|
-
trySettle: (
|
|
128
|
-
admitted: AdmittedGleanerLeftInvocation,
|
|
129
|
-
authority: DurablePrincipalAuthority,
|
|
130
|
-
scope?: { readonly courtAttemptId?: string },
|
|
131
|
-
) => trySettleGleanerLeftTerminalResult(admitted, authority, scope),
|
|
132
|
-
shouldPresentSettled: () => true,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Resume a previously admitted Gleaner-Left run (#599 / DK-3).
|
|
138
|
-
* Restores role/base/session identity; model override is temporary.
|
|
139
|
-
*/
|
|
140
|
-
export async function runPublicGleanerLeftResume(
|
|
141
|
-
request: PublicResumeRequest,
|
|
142
|
-
env: GleanerLeftRunEnv,
|
|
143
|
-
io: CliIo,
|
|
144
|
-
): Promise<{
|
|
145
|
-
exitCode: number;
|
|
146
|
-
admitted?: AdmittedGleanerLeftInvocation;
|
|
147
|
-
terminal?: TerminalResult;
|
|
148
|
-
}> {
|
|
149
|
-
return await runPostAdmissionSeatResume({
|
|
150
|
-
request,
|
|
151
|
-
env,
|
|
152
|
-
io,
|
|
153
|
-
load: (effective) =>
|
|
154
|
-
loadResumableGleanerLeftRun(
|
|
155
|
-
env.home,
|
|
156
|
-
effective.runId,
|
|
157
|
-
env.principalAuthority,
|
|
158
|
-
),
|
|
159
|
-
buildTurnRequest: (admitted, effective) =>
|
|
160
|
-
buildGleanerLeftTurnRequest(
|
|
161
|
-
admitted,
|
|
162
|
-
resumeTurnRequestProjectionOptions(admitted, effective, env),
|
|
163
|
-
),
|
|
164
|
-
adapters: gleanerLeftAdapters(),
|
|
165
|
-
...(env.engine === undefined ? {} : { effectiveEngine: env.engine }),
|
|
166
|
-
});
|
|
167
|
-
}
|