@akagilnc/pi-workflow-roles 0.1.1751
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/LICENSE +202 -0
- package/README.md +104 -0
- package/README.zh-CN.md +133 -0
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/dist/activation-ledger-git.js +68 -0
- package/dist/activation-ledger-session.js +120 -0
- package/dist/activation-ledger-topology.js +239 -0
- package/dist/activation-reconciliation.js +61 -0
- package/dist/audit-escalation.js +108 -0
- package/dist/auditor-dossier-tool.js +35 -0
- package/dist/canonical-json.js +78 -0
- package/dist/compliance-transport.js +77 -0
- package/dist/doctor-contracts.js +172 -0
- package/dist/dossier-resolution.js +103 -0
- package/dist/evidence-child-executor.js +661 -0
- package/dist/exact-utf8.js +12 -0
- package/dist/git-object-id.js +7 -0
- package/dist/in-process-session.js +50 -0
- package/dist/merger-contracts.js +76 -0
- package/dist/navigator-attendance.js +995 -0
- package/dist/navigator-invocation-identity.js +220 -0
- package/dist/open-tool-schema.js +39 -0
- package/dist/package-contracts/collector-output.js +50 -0
- package/dist/package-contracts/fixer-output.js +72 -0
- package/dist/package-contracts/fixer-packet.js +77 -0
- package/dist/package-contracts/judge-output.js +17 -0
- package/dist/package-contracts/reviewer-output.js +82 -0
- package/dist/package-contracts/terminating-tools.js +173 -0
- package/dist/package-contracts/worker-output.js +13 -0
- package/dist/package-owned-tool-idle.js +104 -0
- package/dist/packaged-role-registry.js +34 -0
- package/dist/public-cli/main.js +23867 -0
- package/dist/public-command-renderer.js +20 -0
- package/dist/reviewer-agent.js +93 -0
- package/dist/reviewer-child-executor.js +23 -0
- package/dist/reviewer-construction.js +95 -0
- package/dist/reviewer-dispatch.js +77 -0
- package/dist/reviewer-execution-ledger.js +160 -0
- package/dist/reviewer-failure-diagnostic.js +17 -0
- package/dist/reviewer-git-snapshot.js +38 -0
- package/dist/reviewer-pinned-git.js +146 -0
- package/dist/reviewer-preflight-error.js +15 -0
- package/dist/reviewer-prompt-identity.js +10 -0
- package/dist/reviewer-scope-prompt.js +21 -0
- package/dist/reviewer-workspace.js +151 -0
- package/dist/sha256.js +5 -0
- package/dist/sitian-record-entry.js +33 -0
- package/dist/stderr-jsonl.js +26 -0
- package/dist/stream-idle-guard.js +75 -0
- package/dist/tool-execution-observation.js +141 -0
- package/dist/uuidv7.js +21 -0
- package/dist/work-subject-identity.js +53 -0
- package/extensions/role-runtime.ts +303 -0
- package/package.json +69 -0
- package/packets/fixer-prerequisites.json +6 -0
- package/packets/fixer-repair.md +5 -0
- package/packets/judge-apply.md +77 -0
- package/packets/judge-authority.md +64 -0
- package/packets/judge-plan.md +55 -0
- package/packets/judge-review.md +49 -0
- package/packets/judge-submission.md +34 -0
- package/resources/methods/code-review/SKILL.md +92 -0
- package/resources/methods/code-review/agents/openai.yaml +3 -0
- package/resources/methods/code-review/provenance.json +26 -0
- package/resources/methods/diagnosing-bugs/SKILL.md +134 -0
- package/resources/methods/diagnosing-bugs/agents/openai.yaml +3 -0
- package/resources/methods/diagnosing-bugs/provenance.json +31 -0
- package/resources/methods/diagnosing-bugs/scripts/hitl-loop.template.sh +41 -0
- package/resources/methods/resolving-merge-conflicts/SKILL.md +14 -0
- package/resources/methods/resolving-merge-conflicts/agents/openai.yaml +3 -0
- package/resources/methods/resolving-merge-conflicts/provenance.json +26 -0
- package/resources/methods/tdd/SKILL.md +38 -0
- package/resources/methods/tdd/agents/openai.yaml +3 -0
- package/resources/methods/tdd/mocking.md +59 -0
- package/resources/methods/tdd/provenance.json +36 -0
- package/resources/methods/tdd/tests.md +77 -0
- package/resources/navigator-route-playbook.md +32 -0
- package/schemas/tool-execution-observation.schema.json +107 -0
- package/scripts/build-package.mjs +65 -0
- package/scripts/generate-tool-execution-observation-schema.ts +7 -0
- package/souls/coder.md +10 -0
- package/souls/collector.md +11 -0
- package/souls/doctor-auditor.md +23 -0
- package/souls/doctor.md +8 -0
- package/souls/fixer-auditor.md +33 -0
- package/souls/fixer.md +13 -0
- package/souls/judge-auditor.md +33 -0
- package/souls/judge.md +74 -0
- package/souls/merger.md +5 -0
- package/souls/navigator.md +5 -0
- package/souls/reviewer-auditor.md +25 -0
- package/souls/reviewer.md +11 -0
- package/src/activation-ledger-git.ts +96 -0
- package/src/activation-ledger-session.ts +188 -0
- package/src/activation-ledger-topology.ts +301 -0
- package/src/activation-ledger.ts +240 -0
- package/src/activation-reconciliation.ts +163 -0
- package/src/activation-trace.ts +38 -0
- package/src/audit-escalation.ts +177 -0
- package/src/auditor-dossier-tool.ts +48 -0
- package/src/auditor-soul.ts +28 -0
- package/src/canonical-json.ts +74 -0
- package/src/canonical-skill-binding.ts +107 -0
- package/src/collector-config.ts +89 -0
- package/src/collector-evidence.ts +461 -0
- package/src/collector-github.ts +656 -0
- package/src/collector-identity.ts +161 -0
- package/src/collector-ledger.ts +827 -0
- package/src/collector-receipt.ts +87 -0
- package/src/collector-role.ts +592 -0
- package/src/collector-tool-schemas.ts +19 -0
- package/src/compliance-transport.ts +130 -0
- package/src/doctor-auditor.ts +53 -0
- package/src/doctor-contracts.ts +166 -0
- package/src/doctor-evidence.ts +47 -0
- package/src/doctor-role.ts +18 -0
- package/src/dossier-resolution.ts +137 -0
- package/src/evidence-child-executor.ts +775 -0
- package/src/exact-utf8.ts +9 -0
- package/src/factory-board.ts +1822 -0
- package/src/git-object-id.ts +11 -0
- package/src/human-format.ts +65 -0
- package/src/in-process-session.ts +78 -0
- package/src/judge-auditor.ts +55 -0
- package/src/judge-recording-anti-forge.ts +53 -0
- package/src/judge-role.ts +160 -0
- package/src/merger-contracts.ts +71 -0
- package/src/merger-git-state.ts +76 -0
- package/src/merger-role.ts +60 -0
- package/src/navigator-attendance.ts +1254 -0
- package/src/navigator-invocation-identity.ts +446 -0
- package/src/open-tool-schema.ts +46 -0
- package/src/package-contracts/collector-output.ts +109 -0
- package/src/package-contracts/fixer-output.ts +81 -0
- package/src/package-contracts/fixer-packet.ts +93 -0
- package/src/package-contracts/judge-output.ts +39 -0
- package/src/package-contracts/reviewer-output.ts +115 -0
- package/src/package-contracts/terminating-tools.ts +259 -0
- package/src/package-contracts/worker-output.ts +36 -0
- package/src/package-owned-tool-idle.ts +134 -0
- package/src/package-resources/method-skill-binding.ts +87 -0
- package/src/package-resources/method-skill.ts +358 -0
- package/src/packaged-role-registry.ts +36 -0
- package/src/public-cli/cli-errors.ts +11 -0
- package/src/public-cli/cli-io.ts +4 -0
- package/src/public-cli/cli.ts +912 -0
- package/src/public-cli/coder-run.ts +575 -0
- package/src/public-cli/collector-run.ts +375 -0
- package/src/public-cli/command-renderer.ts +8 -0
- package/src/public-cli/config.ts +346 -0
- package/src/public-cli/doctor-run.ts +355 -0
- package/src/public-cli/explicit-internal.ts +274 -0
- package/src/public-cli/fixer-run.ts +587 -0
- package/src/public-cli/host-pi-runtime.ts +112 -0
- package/src/public-cli/invocation.ts +1958 -0
- package/src/public-cli/judge-run.ts +507 -0
- package/src/public-cli/main.ts +15 -0
- package/src/public-cli/merger-run.ts +681 -0
- package/src/public-cli/public-run-credentials.ts +71 -0
- package/src/public-cli/registry.ts +153 -0
- package/src/public-cli/reviewer-run.ts +561 -0
- package/src/public-cli/run-lifecycle.ts +884 -0
- package/src/public-cli/settlement.ts +3765 -0
- package/src/public-cli/terminal.ts +325 -0
- package/src/public-command-renderer.ts +43 -0
- package/src/reviewer-agent.ts +94 -0
- package/src/reviewer-auditor.ts +53 -0
- package/src/reviewer-child-executor.ts +31 -0
- package/src/reviewer-construction.ts +137 -0
- package/src/reviewer-dispatch.ts +94 -0
- package/src/reviewer-execution-ledger.ts +206 -0
- package/src/reviewer-failure-diagnostic.ts +18 -0
- package/src/reviewer-git-snapshot.ts +53 -0
- package/src/reviewer-pinned-git.ts +144 -0
- package/src/reviewer-preflight-error.ts +14 -0
- package/src/reviewer-prompt-identity.ts +17 -0
- package/src/reviewer-role.ts +193 -0
- package/src/reviewer-scope-prompt.ts +24 -0
- package/src/reviewer-settlement.ts +63 -0
- package/src/reviewer-workspace.ts +111 -0
- package/src/role-runtime.ts +884 -0
- package/src/sha256.ts +6 -0
- package/src/sitian-record-entry.ts +57 -0
- package/src/stderr-jsonl.ts +28 -0
- package/src/stream-idle-guard.ts +98 -0
- package/src/ticket-snapshot.ts +662 -0
- package/src/ticket-trajectory.ts +1000 -0
- package/src/tool-execution-observation.ts +168 -0
- package/src/uuidv7.ts +1 -0
- package/src/work-subject-identity.ts +94 -0
- package/src/worker-role.ts +434 -0
- package/src/worker-submission-gates.ts +225 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public Collector Role run: admit a structured PR target → explicit Internal activate
|
|
3
|
+
* → settle Terminal result (#112). One-shot; no resume path (Collector rejects
|
|
4
|
+
* session resume/fork/reload). Failure settlement reuses the #107 shared owner.
|
|
5
|
+
*/
|
|
6
|
+
import { writeFile } from "node:fs/promises";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
runExplicitInternalActivation,
|
|
11
|
+
type ExplicitInternalKnownFailure,
|
|
12
|
+
type ExplicitInternalPiRunner,
|
|
13
|
+
type ExplicitInternalPiResult,
|
|
14
|
+
} from "./explicit-internal.ts";
|
|
15
|
+
import { CliUsageError } from "./cli-errors.ts";
|
|
16
|
+
import {
|
|
17
|
+
admitCollectorInvocation,
|
|
18
|
+
buildCollectorTransportPrompt,
|
|
19
|
+
type AdmittedCollectorInvocation,
|
|
20
|
+
type ParseCollectorArgvResult,
|
|
21
|
+
} from "./invocation.ts";
|
|
22
|
+
import {
|
|
23
|
+
type CredentialProviders,
|
|
24
|
+
type SeatModelConfig,
|
|
25
|
+
} from "./config.ts";
|
|
26
|
+
import {
|
|
27
|
+
missingCredentialPreDispatchFailure,
|
|
28
|
+
postRunMissingCredentialFailure,
|
|
29
|
+
} from "./public-run-credentials.ts";
|
|
30
|
+
import {
|
|
31
|
+
acquireRunWriterLease,
|
|
32
|
+
clearTypedProviderHttpObservation,
|
|
33
|
+
markRunAdmitted,
|
|
34
|
+
markRunRunning,
|
|
35
|
+
markRunTerminal,
|
|
36
|
+
RunWriterLeaseHeldError,
|
|
37
|
+
type RunWriterLease,
|
|
38
|
+
} from "./run-lifecycle.ts";
|
|
39
|
+
import {
|
|
40
|
+
classifyPostAdmissionFailure,
|
|
41
|
+
exitCodeForTerminalOutcome,
|
|
42
|
+
formatTerminalResult,
|
|
43
|
+
inspectJudgeSession,
|
|
44
|
+
presentFailureTerminal,
|
|
45
|
+
presentStructuralRejection,
|
|
46
|
+
explicitInternalKnownFailureClassificationInput,
|
|
47
|
+
readCollectorInfrastructureFailure,
|
|
48
|
+
resolveAuditedRunnerKnownFailure,
|
|
49
|
+
settleFailureTerminalResult,
|
|
50
|
+
trySettleCollectorTerminalResult,
|
|
51
|
+
} from "./settlement.ts";
|
|
52
|
+
import type { CliIo } from "./cli-io.ts";
|
|
53
|
+
import type {
|
|
54
|
+
ControlledFailureCause,
|
|
55
|
+
TerminalResult,
|
|
56
|
+
} from "./terminal.ts";
|
|
57
|
+
|
|
58
|
+
export type CollectorRunEnv = {
|
|
59
|
+
home: string;
|
|
60
|
+
agentDir: string;
|
|
61
|
+
packageRoot: string;
|
|
62
|
+
cwd: string;
|
|
63
|
+
correlationId?: string;
|
|
64
|
+
piRunner?: ExplicitInternalPiRunner;
|
|
65
|
+
model?: SeatModelConfig;
|
|
66
|
+
credentials?: CredentialProviders;
|
|
67
|
+
createRunId?: () => string;
|
|
68
|
+
extraPiArgs?: readonly string[];
|
|
69
|
+
timeoutMs?: number;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function buildModelArgs(model: SeatModelConfig | undefined): string[] {
|
|
73
|
+
if (model === undefined) return [];
|
|
74
|
+
return [
|
|
75
|
+
"--provider",
|
|
76
|
+
model.provider,
|
|
77
|
+
"--model",
|
|
78
|
+
model.model,
|
|
79
|
+
"--thinking",
|
|
80
|
+
model.thinking,
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Build Internal activation extra-args for an admitted Collector run.
|
|
86
|
+
* Always --no-skills (Collector forbids every Skill). Session under #78 book.
|
|
87
|
+
*/
|
|
88
|
+
export function buildCollectorActivationExtraArgs(
|
|
89
|
+
admitted: AdmittedCollectorInvocation,
|
|
90
|
+
options: {
|
|
91
|
+
model?: SeatModelConfig;
|
|
92
|
+
extraPiArgs?: readonly string[];
|
|
93
|
+
} = {},
|
|
94
|
+
): string[] {
|
|
95
|
+
const prompt = buildCollectorTransportPrompt(admitted);
|
|
96
|
+
return [
|
|
97
|
+
"--no-skills",
|
|
98
|
+
"--no-prompt-templates",
|
|
99
|
+
"--no-themes",
|
|
100
|
+
"--no-context-files",
|
|
101
|
+
"--session",
|
|
102
|
+
admitted.sessionFile,
|
|
103
|
+
"--session-dir",
|
|
104
|
+
admitted.sessionDirectory,
|
|
105
|
+
...(options.extraPiArgs ?? []),
|
|
106
|
+
"--ak-role",
|
|
107
|
+
"collector",
|
|
108
|
+
"--ak-collector-repo",
|
|
109
|
+
admitted.repository.display,
|
|
110
|
+
"--ak-collector-pr",
|
|
111
|
+
String(admitted.prNumber),
|
|
112
|
+
...(admitted.requestManifestPath === undefined
|
|
113
|
+
? []
|
|
114
|
+
: ["--ak-collector-request-manifest", admitted.requestManifestPath]),
|
|
115
|
+
"--mode",
|
|
116
|
+
"json",
|
|
117
|
+
...buildModelArgs(options.model),
|
|
118
|
+
prompt,
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function presentControlledFailure(
|
|
123
|
+
admitted: AdmittedCollectorInvocation,
|
|
124
|
+
failureInput: {
|
|
125
|
+
timedOut: boolean;
|
|
126
|
+
code: number | null;
|
|
127
|
+
stderr: string;
|
|
128
|
+
thrown?: unknown;
|
|
129
|
+
knownFailure?: ExplicitInternalKnownFailure;
|
|
130
|
+
knownCause?: ControlledFailureCause;
|
|
131
|
+
knownIdentity?: {
|
|
132
|
+
readonly name?: string;
|
|
133
|
+
readonly code?: string | number;
|
|
134
|
+
};
|
|
135
|
+
knownDiagnostic?: string;
|
|
136
|
+
},
|
|
137
|
+
io: CliIo,
|
|
138
|
+
): Promise<{
|
|
139
|
+
exitCode: number;
|
|
140
|
+
admitted: AdmittedCollectorInvocation;
|
|
141
|
+
terminal: TerminalResult;
|
|
142
|
+
}> {
|
|
143
|
+
const hasThrown = Object.hasOwn(failureInput, "thrown");
|
|
144
|
+
const session =
|
|
145
|
+
!hasThrown &&
|
|
146
|
+
!failureInput.timedOut &&
|
|
147
|
+
failureInput.knownFailure === undefined &&
|
|
148
|
+
failureInput.knownCause === undefined
|
|
149
|
+
? await inspectJudgeSession(admitted.sessionFile)
|
|
150
|
+
: undefined;
|
|
151
|
+
const failure = classifyPostAdmissionFailure({
|
|
152
|
+
timedOut: failureInput.timedOut,
|
|
153
|
+
code: failureInput.code,
|
|
154
|
+
stderr: failureInput.stderr,
|
|
155
|
+
...(hasThrown ? { thrown: failureInput.thrown } : {}),
|
|
156
|
+
...explicitInternalKnownFailureClassificationInput(failureInput.knownFailure),
|
|
157
|
+
...(failureInput.knownCause === undefined
|
|
158
|
+
? {}
|
|
159
|
+
: { knownCause: failureInput.knownCause }),
|
|
160
|
+
...(failureInput.knownIdentity === undefined
|
|
161
|
+
? {}
|
|
162
|
+
: { knownIdentity: failureInput.knownIdentity }),
|
|
163
|
+
...(failureInput.knownDiagnostic === undefined
|
|
164
|
+
? {}
|
|
165
|
+
: { knownDiagnostic: failureInput.knownDiagnostic }),
|
|
166
|
+
...(session === undefined ? {} : { session }),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Collector does not support resume/fork/reload — always terminal.
|
|
170
|
+
await markRunTerminal(admitted.runDirectory).catch(() => undefined);
|
|
171
|
+
|
|
172
|
+
const terminal = await settleFailureTerminalResult(admitted, failure);
|
|
173
|
+
presentFailureTerminal(terminal, io);
|
|
174
|
+
return {
|
|
175
|
+
exitCode: exitCodeForTerminalOutcome(terminal.roleOutcome),
|
|
176
|
+
admitted,
|
|
177
|
+
terminal,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async function dispatchAdmittedCollector(input: {
|
|
182
|
+
admitted: AdmittedCollectorInvocation;
|
|
183
|
+
env: CollectorRunEnv;
|
|
184
|
+
io: CliIo;
|
|
185
|
+
extraArgs: string[];
|
|
186
|
+
lease: RunWriterLease;
|
|
187
|
+
}): Promise<{
|
|
188
|
+
exitCode: number;
|
|
189
|
+
admitted: AdmittedCollectorInvocation;
|
|
190
|
+
terminal?: TerminalResult;
|
|
191
|
+
}> {
|
|
192
|
+
const { admitted, env, io, extraArgs, lease } = input;
|
|
193
|
+
try {
|
|
194
|
+
const missingCredential = missingCredentialPreDispatchFailure(
|
|
195
|
+
env.model,
|
|
196
|
+
env.credentials,
|
|
197
|
+
);
|
|
198
|
+
if (missingCredential !== undefined) {
|
|
199
|
+
return await presentControlledFailure(
|
|
200
|
+
admitted,
|
|
201
|
+
missingCredential,
|
|
202
|
+
io,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
await markRunRunning(admitted.runDirectory);
|
|
206
|
+
await clearTypedProviderHttpObservation(admitted.runDirectory);
|
|
207
|
+
|
|
208
|
+
const childEnv: NodeJS.ProcessEnv = {
|
|
209
|
+
...process.env,
|
|
210
|
+
HOME: env.home,
|
|
211
|
+
PI_CODING_AGENT_DIR: env.agentDir,
|
|
212
|
+
AK_ROLE_RUN_DIR: admitted.runDirectory,
|
|
213
|
+
};
|
|
214
|
+
if (env.correlationId !== undefined && env.correlationId.trim() !== "") {
|
|
215
|
+
childEnv.AK_CORRELATION_ID = env.correlationId;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
let result: ExplicitInternalPiResult;
|
|
219
|
+
try {
|
|
220
|
+
result = await runExplicitInternalActivation({
|
|
221
|
+
packageRoot: env.packageRoot,
|
|
222
|
+
extraArgs,
|
|
223
|
+
cwd: admitted.projectRoot,
|
|
224
|
+
home: env.home,
|
|
225
|
+
agentDir: env.agentDir,
|
|
226
|
+
env: childEnv,
|
|
227
|
+
timeoutMs: env.timeoutMs,
|
|
228
|
+
...(env.piRunner === undefined ? {} : { runner: env.piRunner }),
|
|
229
|
+
});
|
|
230
|
+
} catch (error) {
|
|
231
|
+
return await presentControlledFailure(
|
|
232
|
+
admitted,
|
|
233
|
+
{
|
|
234
|
+
timedOut: false,
|
|
235
|
+
code: null,
|
|
236
|
+
stderr: "",
|
|
237
|
+
thrown: error,
|
|
238
|
+
},
|
|
239
|
+
io,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
await writeFile(
|
|
245
|
+
join(admitted.runDirectory, "stderr.log"),
|
|
246
|
+
result.stderr,
|
|
247
|
+
"utf8",
|
|
248
|
+
);
|
|
249
|
+
} catch {
|
|
250
|
+
// continue to lawful / controlled-failure settlement
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let lawful: TerminalResult | undefined;
|
|
254
|
+
try {
|
|
255
|
+
lawful = await trySettleCollectorTerminalResult(admitted);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
return await presentControlledFailure(
|
|
258
|
+
admitted,
|
|
259
|
+
{
|
|
260
|
+
timedOut: false,
|
|
261
|
+
code: result.code,
|
|
262
|
+
stderr: result.stderr,
|
|
263
|
+
thrown: error,
|
|
264
|
+
},
|
|
265
|
+
io,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
if (lawful !== undefined) {
|
|
269
|
+
await markRunTerminal(admitted.runDirectory).catch(() => undefined);
|
|
270
|
+
io.stdout(formatTerminalResult(lawful));
|
|
271
|
+
return {
|
|
272
|
+
exitCode: exitCodeForTerminalOutcome(lawful.roleOutcome),
|
|
273
|
+
admitted,
|
|
274
|
+
terminal: lawful,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Prefer Collector infrastructure tool failure already on the session principal
|
|
279
|
+
// (e.g. observe HTTP 404) over a later secondary provider-stop after abort.
|
|
280
|
+
const infrastructureFailure = await readCollectorInfrastructureFailure(
|
|
281
|
+
admitted.sessionFile,
|
|
282
|
+
);
|
|
283
|
+
const credentialFailure = postRunMissingCredentialFailure(
|
|
284
|
+
result,
|
|
285
|
+
env.model,
|
|
286
|
+
env.credentials,
|
|
287
|
+
);
|
|
288
|
+
const knownFailure = await resolveAuditedRunnerKnownFailure({
|
|
289
|
+
runner:
|
|
290
|
+
result.knownFailure ??
|
|
291
|
+
(infrastructureFailure === undefined
|
|
292
|
+
? undefined
|
|
293
|
+
: {
|
|
294
|
+
cause: infrastructureFailure.cause,
|
|
295
|
+
diagnostic: infrastructureFailure.diagnostic,
|
|
296
|
+
...(infrastructureFailure.identity === undefined
|
|
297
|
+
? {}
|
|
298
|
+
: { identity: infrastructureFailure.identity }),
|
|
299
|
+
}),
|
|
300
|
+
sessionFile: admitted.sessionFile,
|
|
301
|
+
credential: credentialFailure,
|
|
302
|
+
});
|
|
303
|
+
return await presentControlledFailure(
|
|
304
|
+
admitted,
|
|
305
|
+
{
|
|
306
|
+
timedOut: result.timedOut,
|
|
307
|
+
code: result.code,
|
|
308
|
+
stderr: result.stderr,
|
|
309
|
+
...(knownFailure === undefined ? {} : { knownFailure }),
|
|
310
|
+
},
|
|
311
|
+
io,
|
|
312
|
+
);
|
|
313
|
+
} finally {
|
|
314
|
+
await lease.release();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export async function runPublicCollector(
|
|
319
|
+
argv: readonly string[],
|
|
320
|
+
env: CollectorRunEnv,
|
|
321
|
+
io: CliIo,
|
|
322
|
+
parseCollectorArgv: (args: readonly string[]) => ParseCollectorArgvResult,
|
|
323
|
+
): Promise<{
|
|
324
|
+
exitCode: number;
|
|
325
|
+
admitted?: AdmittedCollectorInvocation;
|
|
326
|
+
terminal?: TerminalResult;
|
|
327
|
+
}> {
|
|
328
|
+
let admitted: AdmittedCollectorInvocation;
|
|
329
|
+
try {
|
|
330
|
+
const parsed = parseCollectorArgv(argv);
|
|
331
|
+
admitted = await admitCollectorInvocation({
|
|
332
|
+
home: env.home,
|
|
333
|
+
cwd: env.cwd,
|
|
334
|
+
prNumber: parsed.prNumber,
|
|
335
|
+
instruction: parsed.instruction,
|
|
336
|
+
attachmentPaths: parsed.attachmentPaths,
|
|
337
|
+
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
338
|
+
...(parsed.repo === undefined ? {} : { repo: parsed.repo }),
|
|
339
|
+
...(parsed.requestManifestPath === undefined ? {} : { requestManifestPath: parsed.requestManifestPath }),
|
|
340
|
+
...(env.createRunId === undefined ? {} : { createRunId: env.createRunId }),
|
|
341
|
+
});
|
|
342
|
+
} catch (error) {
|
|
343
|
+
if (error instanceof CliUsageError) {
|
|
344
|
+
presentStructuralRejection(error, io);
|
|
345
|
+
return { exitCode: 2 };
|
|
346
|
+
}
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
await markRunAdmitted(admitted);
|
|
351
|
+
|
|
352
|
+
let lease: RunWriterLease;
|
|
353
|
+
try {
|
|
354
|
+
lease = await acquireRunWriterLease(admitted.runDirectory);
|
|
355
|
+
} catch (error) {
|
|
356
|
+
if (error instanceof RunWriterLeaseHeldError) {
|
|
357
|
+
presentStructuralRejection(error, io);
|
|
358
|
+
return { exitCode: 2 };
|
|
359
|
+
}
|
|
360
|
+
throw error;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const extraArgs = buildCollectorActivationExtraArgs(admitted, {
|
|
364
|
+
...(env.model === undefined ? {} : { model: env.model }),
|
|
365
|
+
...(env.extraPiArgs === undefined ? {} : { extraPiArgs: env.extraPiArgs }),
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
return await dispatchAdmittedCollector({
|
|
369
|
+
admitted,
|
|
370
|
+
env,
|
|
371
|
+
io,
|
|
372
|
+
extraArgs,
|
|
373
|
+
lease,
|
|
374
|
+
});
|
|
375
|
+
}
|