@akagilnc/pi-workflow-roles 0.1.2521 → 0.1.2653-next.71811ca
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/README.md +129 -39
- package/README.zh-CN.md +128 -39
- package/dist/activation-ledger-topology.js +1 -1
- package/dist/archivist-record-entry.js +47 -26
- package/dist/auditor-dossier-tool.js +3 -1
- package/dist/compliance-transport.js +17 -26
- package/dist/doctor-contracts.js +1 -2
- package/dist/dossier-resolution.js +4 -8
- package/dist/engine-detour-tool.js +33 -8
- package/dist/engine-detour.js +1 -0
- package/dist/evidence-child-executor.js +277 -424
- package/dist/host-contracts.js +22 -0
- package/dist/institutional-resolution.js +88 -0
- package/dist/merger-contracts.js +1 -2
- package/dist/navigator-attendance.js +16 -0
- package/dist/notary-contracts.js +2 -3
- package/dist/package-contracts/fixer-output.js +1 -2
- package/dist/packaged-role-registry.js +102 -9
- package/dist/pi/in-process-session.js +671 -0
- package/dist/public-cli/config.js +7 -5
- package/dist/public-cli/main.js +3767 -4113
- package/dist/reviewer-child-executor.js +6 -1
- package/dist/session-opening-materials.js +10 -38
- package/dist/sitian-appender.js +146 -0
- package/dist/sitian-contracts.js +21 -0
- package/dist/sitian-facade.js +15 -0
- package/dist/sitian-reader.js +52 -0
- package/extensions/role-runtime.ts +9 -7
- package/package.json +5 -5
- package/resources/engines/cursor.md +12 -26
- package/resources/engines/hermes.md +2 -23
- package/resources/engines/opus.md +1 -16
- package/resources/navigator-route-playbook.md +2 -2
- package/scripts/build-package.mjs +0 -1
- package/souls/quality-law.md +1 -1
- package/src/activation-ledger-topology.ts +1 -1
- package/src/archivist-record-entry.ts +57 -45
- package/src/auditor-dossier-tool.ts +4 -2
- package/src/canonical-skill-binding.ts +37 -27
- package/src/collector-role.ts +11 -20
- package/src/collector-tool-schemas.ts +1 -4
- package/src/compliance-transport.ts +19 -44
- package/src/doctor-auditor.ts +1 -5
- package/src/doctor-contracts.ts +1 -4
- package/src/doctor-role.ts +31 -8
- package/src/dossier-resolution.ts +8 -8
- package/src/engine-detour-tool.ts +48 -19
- package/src/engine-detour.ts +3 -0
- package/src/evidence-child-executor.ts +277 -485
- package/src/factory-board.ts +3 -3
- package/src/gatekeeper-role.ts +21 -10
- package/src/host-contracts.ts +386 -0
- package/src/in-process-session.ts +1 -115
- package/src/institutional-resolution.ts +135 -0
- package/src/judge-auditor.ts +1 -5
- package/src/judge-role.ts +37 -51
- package/src/merger-contracts.ts +1 -4
- package/src/merger-role.ts +7 -11
- package/src/navigator-attendance.ts +20 -1
- package/src/notary-contracts.ts +8 -11
- package/src/notary-role.ts +7 -23
- package/src/notary-source-run.ts +4 -3
- package/src/package-contracts/fixer-output.ts +1 -4
- package/src/package-resources/method-skill-binding.ts +10 -34
- package/src/packaged-role-registry.ts +122 -12
- package/src/pi/adapter.ts +192 -0
- package/src/pi/durable-principal.ts +98 -0
- package/src/pi/in-process-session.ts +819 -0
- package/src/pi/known-failure.ts +77 -0
- package/src/pi/pi-normalization.ts +284 -0
- package/src/pi/role-turn-host.ts +459 -0
- package/src/public-cli/auto-resume.ts +42 -44
- package/src/public-cli/cli.ts +171 -257
- package/src/public-cli/coder-run.ts +115 -433
- package/src/public-cli/collector-run.ts +62 -314
- package/src/public-cli/config.ts +7 -5
- package/src/public-cli/doctor-run.ts +41 -52
- package/src/public-cli/fixer-run.ts +122 -427
- package/src/public-cli/invocation.ts +287 -96
- package/src/public-cli/judge-run.ts +92 -422
- package/src/public-cli/merger-run.ts +167 -429
- package/src/public-cli/notary-run.ts +41 -47
- package/src/public-cli/option-definitions.ts +136 -3
- package/src/public-cli/post-admission.ts +497 -0
- package/src/public-cli/public-run-credentials.ts +4 -4
- package/src/public-cli/reviewer-dispatch-rejection.ts +106 -0
- package/src/public-cli/reviewer-run.ts +132 -449
- package/src/public-cli/run-lifecycle.ts +339 -327
- package/src/public-cli/settlement.ts +251 -134
- package/src/public-cli/terminal.ts +3 -9
- package/src/public-cli/turn-request.ts +87 -0
- package/src/reviewer-child-executor.ts +9 -1
- package/src/reviewer-role.ts +11 -20
- package/src/role-runtime.ts +129 -78
- package/src/session-opening-materials.ts +25 -39
- package/src/sitian-appender.ts +171 -0
- package/src/sitian-contracts.ts +106 -0
- package/src/sitian-facade.ts +18 -0
- package/src/sitian-reader.ts +62 -0
- package/src/worker-role.ts +42 -40
- package/src/worker-submission-gates.ts +33 -0
- package/dist/archivist-role-run-coordinates.js +0 -28
- package/dist/package-contracts/terminating-infrastructure.js +0 -90
- package/resources/engines/sonnet.md +0 -27
- package/resources/engines/zcode.md +0 -63
- package/src/archivist-role-run-coordinates.ts +0 -45
- package/src/package-contracts/terminating-infrastructure.ts +0 -132
- package/src/public-cli/explicit-internal.ts +0 -427
- package/src/public-cli/one-shot-dispatch.ts +0 -300
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
import { existsSync, statSync } from "node:fs";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
7
|
|
|
8
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
9
|
-
|
|
10
8
|
import { JUDGE_OUTPUT_TOOL_NAME as JUDGE_OUTPUT_TOOL } from "./package-contracts/judge-output.ts";
|
|
11
9
|
|
|
12
10
|
export const JUDGE_OUTPUT_TOOL_NAME = JUDGE_OUTPUT_TOOL;
|
|
@@ -71,24 +69,26 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
71
69
|
* Judge subjects must already be on the parent session books before audit starts:
|
|
72
70
|
* assignment (user message) + candidate verdict (sole judge output tool call).
|
|
73
71
|
*/
|
|
74
|
-
|
|
72
|
+
type AuditSubjectContext = { sessionManager: { getEntries?(): Iterable<unknown> } };
|
|
73
|
+
|
|
74
|
+
export function readJudgeAuditSubjects(context: AuditSubjectContext): SubjectResolution {
|
|
75
75
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
76
76
|
let hasAssignment = false;
|
|
77
77
|
let hasCandidate = false;
|
|
78
78
|
for (const entry of entries) {
|
|
79
|
-
if (entry.type !== "message") continue;
|
|
79
|
+
if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message)) continue;
|
|
80
80
|
const message = entry.message;
|
|
81
81
|
if (message.role === "user") {
|
|
82
82
|
const text = typeof message.content === "string"
|
|
83
83
|
? message.content
|
|
84
84
|
: Array.isArray(message.content)
|
|
85
|
-
? message.content.map((part) => (part.type === "text" ? part.text : "")).join("")
|
|
85
|
+
? message.content.map((part) => (isRecord(part) && part.type === "text" && typeof part.text === "string" ? part.text : "")).join("")
|
|
86
86
|
: "";
|
|
87
87
|
if (text.trim().length > 0) hasAssignment = true;
|
|
88
88
|
}
|
|
89
89
|
if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
90
90
|
for (const part of message.content) {
|
|
91
|
-
if (part.type === "toolCall" && part.name === JUDGE_OUTPUT_TOOL_NAME && isRecord(part.arguments)) {
|
|
91
|
+
if (isRecord(part) && part.type === "toolCall" && part.name === JUDGE_OUTPUT_TOOL_NAME && isRecord(part.arguments)) {
|
|
92
92
|
hasCandidate = true;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -106,10 +106,10 @@ export function readJudgeAuditSubjects(context: ExtensionContext): SubjectResolu
|
|
|
106
106
|
/**
|
|
107
107
|
* Doctor candidate testimony must be recorded before audit.
|
|
108
108
|
*/
|
|
109
|
-
export function readDoctorAuditSubjects(context:
|
|
109
|
+
export function readDoctorAuditSubjects(context: AuditSubjectContext): SubjectResolution {
|
|
110
110
|
const entries = context.sessionManager.getEntries?.() ?? [];
|
|
111
111
|
for (const entry of entries) {
|
|
112
|
-
if (entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
112
|
+
if (isRecord(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
|
|
113
113
|
return { status: "ok" };
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -5,15 +5,11 @@
|
|
|
5
5
|
* Engine process failures stop through the host infrastructure-failure seam.
|
|
6
6
|
* Caller AbortSignal cancellation propagates unchanged.
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
9
|
-
AgentToolResult,
|
|
10
|
-
ExtensionAPI,
|
|
11
|
-
ExtensionContext,
|
|
12
|
-
ToolDefinition,
|
|
13
|
-
} from "@earendil-works/pi-coding-agent";
|
|
14
8
|
import { Type, type Static } from "typebox";
|
|
9
|
+
import type { HostContext, HostToolDefinition, HostToolResult, RoleHost } from "./host-contracts.ts";
|
|
15
10
|
|
|
16
11
|
import {
|
|
12
|
+
ENGINE_DETOUR_ALREADY_USED_DIAGNOSTIC,
|
|
17
13
|
ENGINE_DETOUR_TOOL_NAME,
|
|
18
14
|
engineDetourFailureDiagnostic,
|
|
19
15
|
engineNameFromEnv,
|
|
@@ -33,14 +29,23 @@ const engineDetourArgsSchema = Type.Object(
|
|
|
33
29
|
|
|
34
30
|
type EngineDetourArgs = Static<typeof engineDetourArgsSchema>;
|
|
35
31
|
|
|
32
|
+
type EngineDetourContext = Pick<HostContext, "cwd" | "mode" | "abort">;
|
|
33
|
+
|
|
36
34
|
export type EngineDetourHostActions = {
|
|
37
35
|
failInfrastructure(
|
|
38
36
|
error: unknown,
|
|
39
|
-
ctx:
|
|
37
|
+
ctx: EngineDetourContext,
|
|
40
38
|
toolCallId?: string,
|
|
41
39
|
): never;
|
|
42
40
|
};
|
|
43
41
|
|
|
42
|
+
export type EngineDetourToolRegistration = {
|
|
43
|
+
/** True when the tool definition was installed on this ExtensionAPI. */
|
|
44
|
+
readonly registered: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type EngineDetourLatch = { used: boolean };
|
|
48
|
+
|
|
44
49
|
/** Caller/upper-layer cancellation must propagate unchanged. */
|
|
45
50
|
function isCallerCancellation(
|
|
46
51
|
error: unknown,
|
|
@@ -58,21 +63,24 @@ function isCallerCancellation(
|
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
/**
|
|
61
|
-
* Build one detour tool definition for a configured engine name.
|
|
66
|
+
* Build one once-latch detour tool definition for a configured engine name.
|
|
67
|
+
* `latch` is shared so parent registration can reset between activations.
|
|
62
68
|
* `fail` owns host abort (parent) vs throw (evidence child) for tool misuse only.
|
|
63
69
|
* Engine process failures (nonzero/empty/spawn) stop via `fail` with their cause.
|
|
64
70
|
* Caller AbortSignal cancellation propagates unchanged.
|
|
65
71
|
*/
|
|
66
72
|
export function createEngineDetourToolDefinition(input: {
|
|
67
73
|
engineName: string;
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
latch?: EngineDetourLatch;
|
|
75
|
+
fail: (error: Error, toolCallId: string, ctx: EngineDetourContext) => never;
|
|
76
|
+
}): HostToolDefinition<typeof engineDetourArgsSchema, unknown, EngineDetourContext> {
|
|
77
|
+
const latch = input.latch ?? { used: false };
|
|
70
78
|
const engineName = input.engineName;
|
|
71
79
|
return {
|
|
72
80
|
name: ENGINE_DETOUR_TOOL_NAME,
|
|
73
81
|
label: "劳务引擎",
|
|
74
82
|
description:
|
|
75
|
-
`运行一次劳务引擎子进程(engine=${engineName}),stdout 返回本 session
|
|
83
|
+
`运行一次劳务引擎子进程(engine=${engineName}),stdout 返回本 session;每次激活至多一次。`,
|
|
76
84
|
promptSnippet: "运行配置的劳务引擎一次并返回 stdout",
|
|
77
85
|
parameters: engineDetourArgsSchema,
|
|
78
86
|
async execute(
|
|
@@ -81,7 +89,16 @@ export function createEngineDetourToolDefinition(input: {
|
|
|
81
89
|
signal,
|
|
82
90
|
_onUpdate,
|
|
83
91
|
ctx,
|
|
84
|
-
): Promise<
|
|
92
|
+
): Promise<HostToolResult> {
|
|
93
|
+
if (latch.used) {
|
|
94
|
+
input.fail(
|
|
95
|
+
new Error(ENGINE_DETOUR_ALREADY_USED_DIAGNOSTIC),
|
|
96
|
+
toolCallId,
|
|
97
|
+
ctx,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
latch.used = true;
|
|
101
|
+
|
|
85
102
|
const args = params as EngineDetourArgs;
|
|
86
103
|
const argv = Array.isArray(args.argv) ? args.argv : [];
|
|
87
104
|
if (argv.length === 0 || argv.some((part) => typeof part !== "string" || part.length === 0)) {
|
|
@@ -120,33 +137,45 @@ export function createEngineDetourToolDefinition(input: {
|
|
|
120
137
|
details: {
|
|
121
138
|
tool: ENGINE_DETOUR_TOOL_NAME,
|
|
122
139
|
code: result.code,
|
|
123
|
-
stderr: result.stderr,
|
|
124
140
|
},
|
|
125
141
|
};
|
|
126
142
|
},
|
|
127
|
-
}
|
|
143
|
+
};
|
|
128
144
|
}
|
|
129
145
|
|
|
130
146
|
/**
|
|
131
147
|
* Register the engine-generic detour tool once for this process when any role has
|
|
132
148
|
* an engine activation signal. Returns whether registration occurred.
|
|
149
|
+
* Once-latch is activation-scoped via the returned reset handle.
|
|
133
150
|
*/
|
|
134
151
|
export function registerEngineDetourTool(
|
|
135
|
-
|
|
152
|
+
roleHost: RoleHost,
|
|
136
153
|
hostActions: EngineDetourHostActions,
|
|
137
|
-
):
|
|
154
|
+
): EngineDetourToolRegistration & { resetLatch(): void } {
|
|
138
155
|
const engineName = engineNameFromEnv();
|
|
139
156
|
if (engineName === undefined) {
|
|
140
|
-
return
|
|
157
|
+
return {
|
|
158
|
+
registered: false,
|
|
159
|
+
resetLatch() {
|
|
160
|
+
/* no-op when unregistered */
|
|
161
|
+
},
|
|
162
|
+
};
|
|
141
163
|
}
|
|
142
164
|
|
|
165
|
+
const latch: EngineDetourLatch = { used: false };
|
|
143
166
|
const definition = createEngineDetourToolDefinition({
|
|
144
167
|
engineName,
|
|
168
|
+
latch,
|
|
145
169
|
fail(error, toolCallId, ctx) {
|
|
146
170
|
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
147
171
|
},
|
|
148
172
|
});
|
|
149
|
-
|
|
173
|
+
roleHost.registerTool(definition);
|
|
150
174
|
|
|
151
|
-
return
|
|
175
|
+
return {
|
|
176
|
+
registered: true,
|
|
177
|
+
resetLatch() {
|
|
178
|
+
latch.used = false;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
152
181
|
}
|
package/src/engine-detour.ts
CHANGED
|
@@ -30,6 +30,9 @@ export function applyEngineChildEnv(
|
|
|
30
30
|
export const ENGINE_DETOUR_EMPTY_STDOUT_DIAGNOSTIC =
|
|
31
31
|
"劳务引擎 stdout 为空" as const;
|
|
32
32
|
|
|
33
|
+
export const ENGINE_DETOUR_ALREADY_USED_DIAGNOSTIC =
|
|
34
|
+
"本激活内劳务引擎已使用" as const;
|
|
35
|
+
|
|
33
36
|
export type EngineDetourResult = Readonly<{
|
|
34
37
|
code: number;
|
|
35
38
|
stdout: string;
|