@alexeiled/pi-fusion 0.1.2 → 0.2.0

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.
@@ -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 type FusionPhase = "panel" | "judge" | "done" | "failed" | "cancelled";
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
  }