@agwab/pi-workflow 0.1.1 → 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.
- package/README.md +20 -15
- package/agents/researcher.md +17 -7
- package/dist/artifact-graph-runtime.js +1 -0
- package/dist/compiler.d.ts +2 -0
- package/dist/compiler.js +29 -4
- package/dist/dynamic-generated-task-runtime.js +4 -3
- package/dist/dynamic-runtime-bundle.js +3 -2
- package/dist/engine.d.ts +2 -0
- package/dist/engine.js +3 -2
- package/dist/extension.js +240 -16
- package/dist/store.js +1 -0
- package/dist/subagent-backend.js +82 -27
- package/dist/tool-metadata.d.ts +1 -0
- package/dist/tool-metadata.js +13 -1
- package/dist/types.d.ts +3 -0
- package/dist/workflow-artifact-extension.js +3 -2
- package/dist/workflow-artifact-tool.js +84 -4
- package/dist/workflow-progress-health.d.ts +37 -0
- package/dist/workflow-progress-health.js +296 -0
- package/dist/workflow-runtime.d.ts +6 -0
- package/dist/workflow-runtime.js +33 -10
- package/dist/workflow-view.d.ts +2 -0
- package/dist/workflow-view.js +97 -18
- package/dist/workflow-web-source-extension.d.ts +43 -0
- package/dist/workflow-web-source-extension.js +1194 -0
- package/dist/workflow-web-source.d.ts +171 -0
- package/dist/workflow-web-source.js +915 -0
- package/docs/usage.md +32 -18
- package/node_modules/@agwab/pi-subagent/package.json +1 -1
- package/node_modules/@agwab/pi-subagent/src/api.ts +245 -132
- package/node_modules/@agwab/pi-subagent/src/artifacts/result.ts +243 -163
- package/node_modules/@agwab/pi-subagent/src/core/constants.ts +117 -90
- package/node_modules/@agwab/pi-subagent/src/core/validation.ts +728 -475
- package/node_modules/@agwab/pi-subagent/src/orchestrate/run.ts +305 -209
- package/node_modules/@agwab/pi-subagent/src/runners/headless-model.ts +750 -439
- package/node_modules/@agwab/pi-subagent/src/runners/tmux.ts +422 -268
- package/package.json +7 -7
- package/skills/workflow-guide/scaffolds/object-tool-fallback/schemas/fetch-control.schema.json +1 -1
- package/skills/workflow-guide/scaffolds/object-tool-fallback/spec.json +4 -3
- package/src/artifact-graph-runtime.ts +1 -0
- package/src/compiler.ts +43 -3
- package/src/dynamic-generated-task-runtime.ts +4 -2
- package/src/dynamic-runtime-bundle.ts +3 -2
- package/src/engine.ts +7 -16
- package/src/extension.ts +299 -22
- package/src/store.ts +1 -0
- package/src/subagent-backend.ts +121 -37
- package/src/tool-metadata.ts +22 -1
- package/src/types.ts +4 -0
- package/src/workflow-artifact-extension.ts +3 -2
- package/src/workflow-artifact-tool.ts +96 -4
- package/src/workflow-progress-health.ts +461 -0
- package/src/workflow-runtime.ts +50 -13
- package/src/workflow-view.ts +186 -41
- package/src/workflow-web-source-extension.ts +1411 -0
- package/src/workflow-web-source.ts +1294 -0
- package/workflows/README.md +1 -1
- package/workflows/deep-research/helpers/claim-evidence-gate.mjs +552 -44
- package/workflows/deep-research/helpers/final-audit-packet.mjs +396 -0
- package/workflows/deep-research/helpers/normalize-input-packet.mjs +545 -0
- package/workflows/deep-research/helpers/render-executive.mjs +1199 -192
- package/workflows/deep-research/helpers/sanitize-verification-candidates.mjs +624 -0
- package/workflows/deep-research/schemas/deep-research-executive-render-control.schema.json +37 -8
- package/workflows/deep-research/schemas/deep-research-final-synthesis-control.schema.json +110 -0
- package/workflows/deep-research/schemas/deep-research-normalize-claims-control.schema.json +45 -4
- package/workflows/deep-research/schemas/deep-research-verify-claims-control.schema.json +0 -2
- package/workflows/deep-research/spec.json +71 -26
- package/workflows/deep-review/helpers/render-review-report.mjs +502 -0
- package/workflows/deep-review/schemas/deep-review-render-control.schema.json +50 -0
- package/workflows/deep-review/spec.json +22 -1
|
@@ -1,212 +1,292 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
FailureKind,
|
|
3
|
+
ResolvedBackend,
|
|
4
|
+
Status,
|
|
5
|
+
} from "../core/constants.ts";
|
|
2
6
|
|
|
3
7
|
export const RESULT_SCHEMA_VERSION = 2 as const;
|
|
4
|
-
export const ARTIFACT_TYPES = [
|
|
8
|
+
export const ARTIFACT_TYPES = [
|
|
9
|
+
"result",
|
|
10
|
+
"stdout",
|
|
11
|
+
"stderr",
|
|
12
|
+
"output",
|
|
13
|
+
"worker",
|
|
14
|
+
"worktree-status",
|
|
15
|
+
"worktree-diff",
|
|
16
|
+
"tool-calls",
|
|
17
|
+
"tool-calls-summary",
|
|
18
|
+
] as const;
|
|
5
19
|
export const WORKSPACE_MODES = ["shared", "worktree", "auto"] as const;
|
|
6
20
|
|
|
7
21
|
export type ArtifactType = (typeof ARTIFACT_TYPES)[number];
|
|
8
22
|
export type WorkspaceMode = (typeof WORKSPACE_MODES)[number];
|
|
9
23
|
|
|
10
24
|
export interface ArtifactRef {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
type: ArtifactType;
|
|
26
|
+
path: string;
|
|
27
|
+
bytes?: number;
|
|
14
28
|
}
|
|
15
29
|
|
|
16
|
-
export type WorktreeCleanupStatus =
|
|
30
|
+
export type WorktreeCleanupStatus =
|
|
31
|
+
| "not-needed"
|
|
32
|
+
| "removed"
|
|
33
|
+
| "kept"
|
|
34
|
+
| "failed";
|
|
17
35
|
|
|
18
36
|
export interface ResultWorkspace {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
mode: WorkspaceMode;
|
|
38
|
+
cwd: string;
|
|
39
|
+
worktreePath: string | null;
|
|
40
|
+
worktreeCleanupStatus?: WorktreeCleanupStatus;
|
|
41
|
+
worktreeStatusPath?: string;
|
|
42
|
+
worktreeDiffPath?: string;
|
|
43
|
+
worktreeCleanupError?: string;
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
export interface ResultSandbox {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
/** Network domains allowed inside the sandbox. Absent or empty means deny-all. */
|
|
49
|
+
allowedDomains?: string[];
|
|
32
50
|
}
|
|
33
51
|
|
|
34
52
|
export interface ResultTmuxMetadata {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
sessionName: string;
|
|
54
|
+
sessionId: string | null;
|
|
55
|
+
paneId: string | null;
|
|
38
56
|
}
|
|
39
57
|
|
|
40
58
|
export interface CompletionMetadata {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
onComplete: string | null;
|
|
60
|
+
notified: boolean;
|
|
61
|
+
updatesSent: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type ResultSessionDisposition =
|
|
65
|
+
| "created"
|
|
66
|
+
| "resumed"
|
|
67
|
+
| "ephemeral"
|
|
68
|
+
| "unavailable";
|
|
69
|
+
export type ResultSessionReason =
|
|
70
|
+
| "session_not_found"
|
|
71
|
+
| "resume_unsupported"
|
|
72
|
+
| "session_store_error";
|
|
73
|
+
|
|
74
|
+
export interface ResultSessionMetadata {
|
|
75
|
+
id?: string;
|
|
76
|
+
requested: boolean;
|
|
77
|
+
disposition: ResultSessionDisposition;
|
|
78
|
+
reason?: ResultSessionReason;
|
|
44
79
|
}
|
|
45
80
|
|
|
46
81
|
export interface ResultMetadata {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
contextLengthExceeded: boolean;
|
|
83
|
+
provider?: string;
|
|
84
|
+
model?: string;
|
|
85
|
+
usage?: unknown;
|
|
86
|
+
stopReason?: string;
|
|
87
|
+
parentSessionId?: string;
|
|
88
|
+
sessionId?: string;
|
|
89
|
+
session?: ResultSessionMetadata;
|
|
90
|
+
streamErrors?: string[];
|
|
91
|
+
nonFatalStreamErrors?: string[];
|
|
92
|
+
parseErrors?: string[];
|
|
52
93
|
}
|
|
53
94
|
|
|
54
95
|
export interface ResultEnvelopeInput {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
runId: string;
|
|
97
|
+
attemptId: string;
|
|
98
|
+
correlationId?: string;
|
|
99
|
+
backend: ResolvedBackend;
|
|
100
|
+
status: Status;
|
|
101
|
+
failureKind?: FailureKind | null;
|
|
102
|
+
cwd: string;
|
|
103
|
+
startedAt?: string | Date;
|
|
104
|
+
completedAt?: string | Date | null;
|
|
105
|
+
durationMs?: number | null;
|
|
106
|
+
workspace?: Partial<ResultWorkspace> | null;
|
|
107
|
+
sandbox?: Partial<ResultSandbox> | null;
|
|
108
|
+
exitCode?: number | null;
|
|
109
|
+
signal?: string | null;
|
|
110
|
+
artifacts?: ArtifactRef[];
|
|
111
|
+
tmux?: ResultTmuxMetadata;
|
|
112
|
+
completion?: CompletionMetadata;
|
|
113
|
+
metadata?: Partial<ResultMetadata> | null;
|
|
114
|
+
/** @deprecated v1 compatibility only. */
|
|
115
|
+
taskId?: string;
|
|
75
116
|
}
|
|
76
117
|
|
|
77
118
|
export interface ResultEnvelope {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
119
|
+
schemaVersion: typeof RESULT_SCHEMA_VERSION;
|
|
120
|
+
runId: string;
|
|
121
|
+
attemptId: string;
|
|
122
|
+
correlationId?: string;
|
|
123
|
+
backend: ResolvedBackend;
|
|
124
|
+
status: Status;
|
|
125
|
+
failureKind: FailureKind | null;
|
|
126
|
+
cwd: string;
|
|
127
|
+
startedAt: string;
|
|
128
|
+
completedAt: string | null;
|
|
129
|
+
durationMs: number | null;
|
|
130
|
+
workspace: ResultWorkspace;
|
|
131
|
+
sandbox: ResultSandbox;
|
|
132
|
+
exitCode: number | null;
|
|
133
|
+
signal: string | null;
|
|
134
|
+
artifacts: ArtifactRef[];
|
|
135
|
+
metadata: ResultMetadata;
|
|
136
|
+
tmux?: ResultTmuxMetadata;
|
|
137
|
+
completion?: CompletionMetadata;
|
|
138
|
+
/** @deprecated v1 compatibility only. */
|
|
139
|
+
taskId?: string;
|
|
99
140
|
}
|
|
100
141
|
|
|
101
142
|
function toIsoTimestamp(value: string | Date, fieldName: string): string {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
143
|
+
const date = typeof value === "string" ? new Date(value) : value;
|
|
144
|
+
if (Number.isNaN(date.getTime())) {
|
|
145
|
+
throw new Error(`${fieldName} must be a valid ISO timestamp or Date.`);
|
|
146
|
+
}
|
|
147
|
+
return date.toISOString();
|
|
107
148
|
}
|
|
108
149
|
|
|
109
|
-
function normalizeDuration(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
150
|
+
function normalizeDuration(
|
|
151
|
+
value: number | null | undefined,
|
|
152
|
+
): number | null | undefined {
|
|
153
|
+
if (value === undefined) return undefined;
|
|
154
|
+
if (value === null) return null;
|
|
155
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
156
|
+
throw new Error(
|
|
157
|
+
"durationMs must be a non-negative finite number when provided.",
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
return value;
|
|
116
161
|
}
|
|
117
162
|
|
|
118
163
|
function normalizeWorkspace(input: ResultEnvelopeInput): ResultWorkspace {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
164
|
+
const workspace = input.workspace ?? {};
|
|
165
|
+
return {
|
|
166
|
+
mode: workspace.mode ?? "shared",
|
|
167
|
+
cwd: workspace.cwd ?? input.cwd,
|
|
168
|
+
worktreePath: workspace.worktreePath ?? null,
|
|
169
|
+
...(workspace.worktreeCleanupStatus === undefined
|
|
170
|
+
? {}
|
|
171
|
+
: { worktreeCleanupStatus: workspace.worktreeCleanupStatus }),
|
|
172
|
+
...(workspace.worktreeStatusPath === undefined
|
|
173
|
+
? {}
|
|
174
|
+
: { worktreeStatusPath: workspace.worktreeStatusPath }),
|
|
175
|
+
...(workspace.worktreeDiffPath === undefined
|
|
176
|
+
? {}
|
|
177
|
+
: { worktreeDiffPath: workspace.worktreeDiffPath }),
|
|
178
|
+
...(workspace.worktreeCleanupError === undefined
|
|
179
|
+
? {}
|
|
180
|
+
: { worktreeCleanupError: workspace.worktreeCleanupError }),
|
|
181
|
+
};
|
|
129
182
|
}
|
|
130
183
|
|
|
131
184
|
function normalizeSandbox(input: ResultEnvelopeInput): ResultSandbox {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
185
|
+
if (input.sandbox === undefined || input.sandbox === null) {
|
|
186
|
+
return { enabled: false };
|
|
187
|
+
}
|
|
135
188
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
189
|
+
return {
|
|
190
|
+
enabled: input.sandbox.enabled ?? true,
|
|
191
|
+
...(input.sandbox.allowedDomains === undefined ||
|
|
192
|
+
input.sandbox.allowedDomains.length === 0
|
|
193
|
+
? {}
|
|
194
|
+
: { allowedDomains: input.sandbox.allowedDomains }),
|
|
195
|
+
};
|
|
140
196
|
}
|
|
141
197
|
|
|
142
198
|
function normalizeMetadata(input: ResultEnvelopeInput): ResultMetadata {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
199
|
+
const metadata = input.metadata ?? {};
|
|
200
|
+
return {
|
|
201
|
+
contextLengthExceeded: metadata.contextLengthExceeded ?? false,
|
|
202
|
+
...(metadata.provider === undefined ? {} : { provider: metadata.provider }),
|
|
203
|
+
...(metadata.model === undefined ? {} : { model: metadata.model }),
|
|
204
|
+
...(metadata.usage === undefined ? {} : { usage: metadata.usage }),
|
|
205
|
+
...(metadata.stopReason === undefined
|
|
206
|
+
? {}
|
|
207
|
+
: { stopReason: metadata.stopReason }),
|
|
208
|
+
...(metadata.parentSessionId === undefined
|
|
209
|
+
? {}
|
|
210
|
+
: { parentSessionId: metadata.parentSessionId }),
|
|
211
|
+
...(metadata.sessionId === undefined
|
|
212
|
+
? {}
|
|
213
|
+
: { sessionId: metadata.sessionId }),
|
|
214
|
+
...(metadata.session === undefined ? {} : { session: metadata.session }),
|
|
215
|
+
...(metadata.streamErrors === undefined
|
|
216
|
+
? {}
|
|
217
|
+
: { streamErrors: metadata.streamErrors }),
|
|
218
|
+
...(metadata.nonFatalStreamErrors === undefined
|
|
219
|
+
? {}
|
|
220
|
+
: { nonFatalStreamErrors: metadata.nonFatalStreamErrors }),
|
|
221
|
+
...(metadata.parseErrors === undefined
|
|
222
|
+
? {}
|
|
223
|
+
: { parseErrors: metadata.parseErrors }),
|
|
224
|
+
};
|
|
151
225
|
}
|
|
152
226
|
|
|
153
227
|
function dedupeArtifactRefs(refs: ArtifactRef[]): ArtifactRef[] {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export function mergeArtifactRefs(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
228
|
+
const seen = new Set<string>();
|
|
229
|
+
const deduped: ArtifactRef[] = [];
|
|
230
|
+
|
|
231
|
+
for (const ref of refs) {
|
|
232
|
+
const key = `${ref.type}:${ref.path}`;
|
|
233
|
+
if (seen.has(key)) continue;
|
|
234
|
+
seen.add(key);
|
|
235
|
+
deduped.push(ref);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return deduped;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function mergeArtifactRefs(
|
|
242
|
+
...groups: readonly ArtifactRef[][]
|
|
243
|
+
): ArtifactRef[] {
|
|
244
|
+
return dedupeArtifactRefs(groups.flat());
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function createResultEnvelope(
|
|
248
|
+
input: ResultEnvelopeInput,
|
|
249
|
+
): ResultEnvelope {
|
|
250
|
+
const startedAt = toIsoTimestamp(input.startedAt ?? new Date(), "startedAt");
|
|
251
|
+
const completedAt =
|
|
252
|
+
input.completedAt === undefined
|
|
253
|
+
? input.status === "pending" || input.status === "running"
|
|
254
|
+
? null
|
|
255
|
+
: new Date().toISOString()
|
|
256
|
+
: input.completedAt === null
|
|
257
|
+
? null
|
|
258
|
+
: toIsoTimestamp(input.completedAt, "completedAt");
|
|
259
|
+
|
|
260
|
+
const explicitDurationMs = normalizeDuration(input.durationMs);
|
|
261
|
+
const durationMs =
|
|
262
|
+
explicitDurationMs !== undefined
|
|
263
|
+
? explicitDurationMs
|
|
264
|
+
: completedAt === null
|
|
265
|
+
? null
|
|
266
|
+
: Math.max(0, Date.parse(completedAt) - Date.parse(startedAt));
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
schemaVersion: RESULT_SCHEMA_VERSION,
|
|
270
|
+
runId: input.runId,
|
|
271
|
+
attemptId: input.attemptId,
|
|
272
|
+
...(input.correlationId === undefined
|
|
273
|
+
? {}
|
|
274
|
+
: { correlationId: input.correlationId }),
|
|
275
|
+
backend: input.backend,
|
|
276
|
+
status: input.status,
|
|
277
|
+
failureKind: input.failureKind ?? null,
|
|
278
|
+
cwd: input.cwd,
|
|
279
|
+
startedAt,
|
|
280
|
+
completedAt,
|
|
281
|
+
durationMs,
|
|
282
|
+
workspace: normalizeWorkspace(input),
|
|
283
|
+
sandbox: normalizeSandbox(input),
|
|
284
|
+
exitCode: input.exitCode ?? null,
|
|
285
|
+
signal: input.signal ?? null,
|
|
286
|
+
artifacts: dedupeArtifactRefs(input.artifacts ?? []),
|
|
287
|
+
metadata: normalizeMetadata(input),
|
|
288
|
+
...(input.tmux === undefined ? {} : { tmux: input.tmux }),
|
|
289
|
+
...(input.completion === undefined ? {} : { completion: input.completion }),
|
|
290
|
+
...(input.taskId === undefined ? {} : { taskId: input.taskId }),
|
|
291
|
+
};
|
|
212
292
|
}
|