@alexeiled/pi-fusion 0.1.2 → 0.2.1
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 +119 -35
- package/docs/user-guide.md +16 -6
- package/package.json +5 -8
- package/src/index.ts +1 -0
- package/src/orchestrator.ts +801 -89
- package/src/report.ts +21 -3
- package/src/result-extract.ts +21 -2
- package/src/run-builder.ts +131 -19
- package/src/run-store.ts +121 -1
- package/src/status.ts +34 -14
- package/src/subagent-artifacts.ts +40 -0
- package/src/types.ts +31 -1
- package/AGENTS.md +0 -7
- package/tsconfig.json +0 -19
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
|
|
4
|
+
const STATUS_FILE = "status.json";
|
|
5
|
+
const ASYNC_RESULTS_DIR = "async-subagent-results";
|
|
6
|
+
const ASYNC_RUNS_DIR = "async-subagent-runs";
|
|
7
|
+
|
|
8
|
+
export function deriveSubagentResultPath(
|
|
9
|
+
asyncDir: string,
|
|
10
|
+
runId: string,
|
|
11
|
+
): string | undefined {
|
|
12
|
+
const runsDir = dirname(asyncDir);
|
|
13
|
+
if (!runsDir.endsWith(ASYNC_RUNS_DIR)) return undefined;
|
|
14
|
+
return join(dirname(runsDir), ASYNC_RESULTS_DIR, `${runId}.json`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function readSubagentStatusArtifact(
|
|
18
|
+
asyncDir: string | undefined,
|
|
19
|
+
): unknown {
|
|
20
|
+
if (!asyncDir) return undefined;
|
|
21
|
+
return readJsonArtifact(join(asyncDir, STATUS_FILE));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function readSubagentResultArtifact(input: {
|
|
25
|
+
runId?: string;
|
|
26
|
+
asyncDir?: string;
|
|
27
|
+
}): unknown {
|
|
28
|
+
if (!input.runId || !input.asyncDir) return undefined;
|
|
29
|
+
const resultPath = deriveSubagentResultPath(input.asyncDir, input.runId);
|
|
30
|
+
return resultPath ? readJsonArtifact(resultPath) : undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function readJsonArtifact(path: string): unknown {
|
|
34
|
+
if (!existsSync(path)) return undefined;
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(readFileSync(path, "utf8")) as unknown;
|
|
37
|
+
} catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -38,7 +38,32 @@ export interface FusionConfig {
|
|
|
38
38
|
profiles: Record<string, FusionProfile>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export
|
|
41
|
+
export interface PanelOutput {
|
|
42
|
+
index: number;
|
|
43
|
+
agent: string;
|
|
44
|
+
output: string;
|
|
45
|
+
id?: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
role?: string;
|
|
48
|
+
model?: string;
|
|
49
|
+
artifactPath?: string;
|
|
50
|
+
sessionPath?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface FailedPanelSummary {
|
|
54
|
+
index: number;
|
|
55
|
+
agent: string;
|
|
56
|
+
summary: string;
|
|
57
|
+
id?: string;
|
|
58
|
+
label?: string;
|
|
59
|
+
role?: string;
|
|
60
|
+
model?: string;
|
|
61
|
+
artifactPath?: string;
|
|
62
|
+
sessionPath?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type FusionPhase =
|
|
66
|
+
"panel" | "chain" | "judge" | "done" | "failed" | "cancelled";
|
|
42
67
|
|
|
43
68
|
export interface FusionRun {
|
|
44
69
|
id: string;
|
|
@@ -47,8 +72,13 @@ export interface FusionRun {
|
|
|
47
72
|
phase: FusionPhase;
|
|
48
73
|
createdAt: number;
|
|
49
74
|
updatedAt: number;
|
|
75
|
+
chainRunId?: string;
|
|
76
|
+
chainAsyncDir?: string;
|
|
50
77
|
panelRunId?: string;
|
|
51
78
|
judgeRunId?: string;
|
|
79
|
+
judgeAsyncDir?: string;
|
|
80
|
+
panelOutputs?: PanelOutput[];
|
|
81
|
+
panelFailures?: FailedPanelSummary[];
|
|
52
82
|
report?: string;
|
|
53
83
|
error?: string;
|
|
54
84
|
}
|
package/AGENTS.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Contributor notes
|
|
2
|
-
|
|
3
|
-
- Keep the extension small, typed, and testable.
|
|
4
|
-
- Do not own or replace the Pi footer. Publish only the `fusion` status key.
|
|
5
|
-
- Use `pi-subagents` RPC for panel and judge execution. Do not import its internals.
|
|
6
|
-
- Keep bundled panel agents read-only by default.
|
|
7
|
-
- Do not add runtime dependencies unless the task needs them.
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2023",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"noUncheckedIndexedAccess": true,
|
|
8
|
-
"exactOptionalPropertyTypes": true,
|
|
9
|
-
"useUnknownInCatchVariables": true,
|
|
10
|
-
"noImplicitOverride": true,
|
|
11
|
-
"noImplicitReturns": true,
|
|
12
|
-
"noFallthroughCasesInSwitch": true,
|
|
13
|
-
"skipLibCheck": true
|
|
14
|
-
},
|
|
15
|
-
"include": [
|
|
16
|
-
"src/**/*.ts",
|
|
17
|
-
"test/**/*.ts"
|
|
18
|
-
]
|
|
19
|
-
}
|