@agwab/pi-workflow 0.2.1 → 0.4.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 +3 -1
- package/dist/artifact-graph-runtime.d.ts +1 -1
- package/dist/artifact-graph-runtime.js +10 -5
- package/dist/artifact-graph-schema.js +127 -5
- package/dist/compiler.js +52 -19
- package/dist/dynamic-generated-task-runtime.js +3 -1
- package/dist/dynamic-profiles.d.ts +1 -1
- package/dist/engine-run-graph.d.ts +3 -0
- package/dist/engine-run-graph.js +194 -4
- package/dist/engine.d.ts +5 -0
- package/dist/engine.js +389 -41
- package/dist/extension.d.ts +2 -1
- package/dist/extension.js +30 -8
- package/dist/index.d.ts +11 -3
- package/dist/index.js +6 -1
- package/dist/prompt-json.d.ts +7 -0
- package/dist/prompt-json.js +13 -0
- package/dist/roles.d.ts +1 -1
- package/dist/roles.js +5 -8
- package/dist/store.d.ts +20 -1
- package/dist/store.js +139 -35
- package/dist/strings.d.ts +11 -0
- package/dist/strings.js +24 -0
- package/dist/subagent-backend.js +710 -40
- package/dist/types.d.ts +107 -1
- package/dist/verification-ontology.d.ts +31 -0
- package/dist/verification-ontology.js +66 -0
- package/dist/workflow-artifact-tool.js +5 -6
- package/dist/workflow-artifacts.d.ts +7 -0
- package/dist/workflow-artifacts.js +55 -4
- package/dist/workflow-fetch-cache-extension.d.ts +1 -0
- package/dist/workflow-fetch-cache-extension.js +57 -9
- package/dist/workflow-metrics.d.ts +113 -0
- package/dist/workflow-metrics.js +272 -0
- package/dist/workflow-output-artifacts.js +5 -3
- package/dist/workflow-partial-output.d.ts +45 -0
- package/dist/workflow-partial-output.js +205 -0
- package/dist/workflow-progress-health.js +42 -10
- package/dist/workflow-runtime.js +10 -1
- package/dist/workflow-view.js +3 -1
- package/dist/workflow-web-source-extension.js +194 -52
- package/dist/workflow-web-source.d.ts +2 -1
- package/dist/workflow-web-source.js +109 -30
- package/docs/usage.md +76 -29
- package/node_modules/@agwab/pi-subagent/README.md +3 -3
- package/node_modules/@agwab/pi-subagent/api.mjs +1 -0
- package/node_modules/@agwab/pi-subagent/docs/usage.md +63 -12
- package/node_modules/@agwab/pi-subagent/package.json +2 -2
- package/node_modules/@agwab/pi-subagent/src/api.ts +54 -1
- package/node_modules/@agwab/pi-subagent/src/artifacts/registry.ts +9 -4
- package/node_modules/@agwab/pi-subagent/src/artifacts/result.ts +8 -0
- package/node_modules/@agwab/pi-subagent/src/core/constants.ts +9 -0
- package/node_modules/@agwab/pi-subagent/src/core/validation.ts +21 -0
- package/node_modules/@agwab/pi-subagent/src/index.ts +1046 -576
- package/node_modules/@agwab/pi-subagent/src/orchestrate/async.ts +279 -156
- package/node_modules/@agwab/pi-subagent/src/orchestrate/interrupt.ts +165 -89
- package/node_modules/@agwab/pi-subagent/src/orchestrate/reconcile.ts +111 -65
- package/node_modules/@agwab/pi-subagent/src/orchestrate/run-ref.ts +219 -0
- package/node_modules/@agwab/pi-subagent/src/orchestrate/run.ts +88 -8
- package/node_modules/@agwab/pi-subagent/src/orchestrate/status.ts +614 -298
- package/node_modules/@agwab/pi-subagent/src/panel.ts +1356 -560
- package/node_modules/@agwab/pi-subagent/src/runners/headless-model.ts +53 -5
- package/node_modules/@agwab/pi-subagent/src/runners/tmux.ts +13 -6
- package/package.json +2 -2
- package/skills/workflow-guide/SKILL.md +1 -0
- package/src/artifact-graph-runtime.ts +19 -13
- package/src/artifact-graph-schema.ts +143 -3
- package/src/cli.mjs +52 -0
- package/src/compiler.ts +63 -18
- package/src/dynamic-generated-task-runtime.ts +3 -1
- package/src/dynamic-profiles.ts +1 -1
- package/src/engine-run-graph.ts +246 -4
- package/src/engine.ts +545 -38
- package/src/extension.ts +36 -6
- package/src/index.ts +52 -1
- package/src/prompt-json.ts +13 -0
- package/src/roles.ts +6 -9
- package/src/store.ts +194 -42
- package/src/strings.ts +38 -0
- package/src/subagent-backend.ts +921 -62
- package/src/types.ts +116 -2
- package/src/verification-ontology.ts +88 -0
- package/src/workflow-artifact-tool.ts +5 -7
- package/src/workflow-artifacts.ts +83 -3
- package/src/workflow-fetch-cache-extension.ts +78 -13
- package/src/workflow-metrics.ts +478 -0
- package/src/workflow-output-artifacts.ts +5 -3
- package/src/workflow-partial-output.ts +299 -0
- package/src/workflow-progress-health.ts +47 -15
- package/src/workflow-runtime.ts +18 -2
- package/src/workflow-view.ts +2 -1
- package/src/workflow-web-source-extension.ts +654 -232
- package/src/workflow-web-source.ts +153 -39
- package/workflows/README.md +7 -25
- package/workflows/deep-research/batched-verification.spec.json +253 -0
- package/workflows/deep-research/helpers/batch-verification-candidates.mjs +136 -0
- package/workflows/deep-research/helpers/claim-evidence-gate.mjs +229 -36
- package/workflows/deep-research/helpers/final-audit-packet.mjs +1 -4
- package/workflows/deep-research/helpers/normalize-input-packet.mjs +81 -2
- package/workflows/deep-research/helpers/render-executive.mjs +40 -26
- package/workflows/deep-research/helpers/sanitize-verification-candidates.mjs +89 -15
- package/workflows/deep-research/helpers/shadow-select-verification.mjs +229 -0
- package/workflows/deep-research/helpers/verification-ontology.mjs +77 -0
- package/workflows/deep-research/schemas/deep-research-executive-render-control.schema.json +3 -3
- package/workflows/deep-research/schemas/deep-research-research-questions-control.schema.json +38 -0
- package/workflows/deep-research/schemas/deep-research-sanitize-claims-control.schema.json +63 -0
- package/workflows/deep-research/schemas/deep-research-verify-claims-batch-control.schema.json +47 -0
- package/workflows/deep-research/schemas/deep-research-verify-claims-control.schema.json +13 -3
- package/workflows/deep-research/spec.json +32 -12
- package/workflows/impact-review/spec.json +3 -3
- package/workflows/spec-review/helpers/spec-review-pipeline.mjs +1 -8
- package/dist/dynamic-loader.d.ts +0 -25
- package/dist/dynamic-loader.js +0 -13
- package/skills/workflow-guide/scaffolds/dag-required-reads/spec.json.validate.stderr +0 -0
- package/skills/workflow-guide/scaffolds/dag-required-reads/spec.json.validate.stdout +0 -13
- package/src/dynamic-loader.ts +0 -49
- package/workflows/impact-review/schemas/docs-release-impact-control.schema.json +0 -42
- package/workflows/impact-review/schemas/security-performance-impact-control.schema.json +0 -42
- package/workflows/impact-review/schemas/state-data-impact-control.schema.json +0 -42
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { loadAgentByName, type AgentDefinition } from "./agents.ts";
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
|
+
appendRunEvent,
|
|
5
|
+
type ResultEnvelope,
|
|
6
|
+
type RunEvent,
|
|
7
|
+
} from "./artifacts/index.ts";
|
|
4
8
|
import type {
|
|
5
9
|
ExecutionMode,
|
|
10
|
+
FailureKind,
|
|
6
11
|
ResolveInput,
|
|
7
12
|
ResolvedBackend,
|
|
13
|
+
Status,
|
|
8
14
|
} from "./core/constants.ts";
|
|
9
15
|
import { resolveBackend } from "./core/resolver.ts";
|
|
10
16
|
import { validateResolveInput } from "./core/validation.ts";
|
|
@@ -22,6 +28,7 @@ import {
|
|
|
22
28
|
type ReconcileSubagentRunOptions as ReconcileRunOptions,
|
|
23
29
|
type ReconcileSubagentRunResult,
|
|
24
30
|
} from "./orchestrate/reconcile.ts";
|
|
31
|
+
import { resolveRunRef } from "./orchestrate/run-ref.ts";
|
|
25
32
|
import {
|
|
26
33
|
runParallelSubagentTasks,
|
|
27
34
|
runSubagentTask,
|
|
@@ -50,6 +57,16 @@ export type WaitForSubagentOptions = WaitForRunOptions;
|
|
|
50
57
|
export type InterruptSubagentOptions = InterruptRunOptions;
|
|
51
58
|
export type ReconcileSubagentOptions = ReconcileRunOptions;
|
|
52
59
|
|
|
60
|
+
export interface RecordSubagentChildEventOptions extends RunStatusRef {
|
|
61
|
+
event: "started" | "updated" | "completed" | "failed" | "cancelled";
|
|
62
|
+
childRunId: string;
|
|
63
|
+
workflowRunId?: string;
|
|
64
|
+
childTaskId?: string;
|
|
65
|
+
status?: Status;
|
|
66
|
+
failureKind?: FailureKind | string | null;
|
|
67
|
+
message?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
53
70
|
export class SubagentValidationError extends Error {
|
|
54
71
|
readonly failureKind = "validation" as const;
|
|
55
72
|
readonly backend?: ResolvedBackend;
|
|
@@ -269,6 +286,40 @@ export async function reconcileSubagentRun(
|
|
|
269
286
|
return await reconcileRun(options);
|
|
270
287
|
}
|
|
271
288
|
|
|
289
|
+
function defaultChildStatus(
|
|
290
|
+
event: RecordSubagentChildEventOptions["event"],
|
|
291
|
+
): Status {
|
|
292
|
+
if (event === "started" || event === "updated") return "running";
|
|
293
|
+
if (event === "completed") return "completed";
|
|
294
|
+
if (event === "cancelled") return "cancelled";
|
|
295
|
+
return "failed";
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export async function recordSubagentChildEvent(
|
|
299
|
+
options: RecordSubagentChildEventOptions,
|
|
300
|
+
): Promise<RunEvent> {
|
|
301
|
+
const {
|
|
302
|
+
event,
|
|
303
|
+
childRunId,
|
|
304
|
+
workflowRunId,
|
|
305
|
+
childTaskId,
|
|
306
|
+
failureKind,
|
|
307
|
+
message,
|
|
308
|
+
} = options;
|
|
309
|
+
const ref = await resolveRunRef(options);
|
|
310
|
+
return await appendRunEvent(ref, {
|
|
311
|
+
type: `child.${event}`,
|
|
312
|
+
status: options.status ?? defaultChildStatus(event),
|
|
313
|
+
...(message === undefined ? {} : { message }),
|
|
314
|
+
data: {
|
|
315
|
+
childRunId,
|
|
316
|
+
...(workflowRunId === undefined ? {} : { workflowRunId }),
|
|
317
|
+
...(childTaskId === undefined ? {} : { taskId: childTaskId }),
|
|
318
|
+
...(failureKind === undefined ? {} : { failureKind }),
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
272
323
|
export type {
|
|
273
324
|
ArtifactRef,
|
|
274
325
|
CompletionMetadata,
|
|
@@ -294,6 +345,8 @@ export type { InterruptRunResult } from "./orchestrate/interrupt.ts";
|
|
|
294
345
|
export type { ReconcileSubagentRunResult } from "./orchestrate/reconcile.ts";
|
|
295
346
|
export type { ParallelRunResult } from "./orchestrate/run.ts";
|
|
296
347
|
export type {
|
|
348
|
+
RunChildFailureSummary,
|
|
349
|
+
RunChildSummary,
|
|
297
350
|
RunLogRef,
|
|
298
351
|
RunLogsSnapshot,
|
|
299
352
|
RunStatusRef,
|
|
@@ -18,6 +18,11 @@ export type RunEventType =
|
|
|
18
18
|
| "run.cancelled"
|
|
19
19
|
| "run.interrupt_requested"
|
|
20
20
|
| "run.mark_background"
|
|
21
|
+
| "child.started"
|
|
22
|
+
| "child.updated"
|
|
23
|
+
| "child.completed"
|
|
24
|
+
| "child.failed"
|
|
25
|
+
| "child.cancelled"
|
|
21
26
|
| "attempt.started"
|
|
22
27
|
| "attempt.process_started"
|
|
23
28
|
| "attempt.heartbeat"
|
|
@@ -716,11 +721,11 @@ export async function readRunEvents(ref: RunRef, limit = 50): Promise<RunEvent[]
|
|
|
716
721
|
const paths = runPaths(ref);
|
|
717
722
|
try {
|
|
718
723
|
const text = await readFile(paths.eventsPath, "utf8");
|
|
719
|
-
|
|
724
|
+
const lines = text
|
|
720
725
|
.split(/\r?\n/)
|
|
721
|
-
.filter(Boolean)
|
|
722
|
-
|
|
723
|
-
|
|
726
|
+
.filter(Boolean);
|
|
727
|
+
const selected = Number.isFinite(limit) ? lines.slice(-limit) : lines;
|
|
728
|
+
return selected.map((line) => JSON.parse(line) as RunEvent);
|
|
724
729
|
} catch (error) {
|
|
725
730
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return [];
|
|
726
731
|
throw error;
|
|
@@ -80,6 +80,7 @@ export interface ResultSessionMetadata {
|
|
|
80
80
|
|
|
81
81
|
export interface ResultMetadata {
|
|
82
82
|
contextLengthExceeded: boolean;
|
|
83
|
+
contextOverflowRecovered?: boolean;
|
|
83
84
|
provider?: string;
|
|
84
85
|
model?: string;
|
|
85
86
|
usage?: unknown;
|
|
@@ -89,6 +90,7 @@ export interface ResultMetadata {
|
|
|
89
90
|
session?: ResultSessionMetadata;
|
|
90
91
|
streamErrors?: string[];
|
|
91
92
|
nonFatalStreamErrors?: string[];
|
|
93
|
+
recoveredStreamErrors?: string[];
|
|
92
94
|
parseErrors?: string[];
|
|
93
95
|
}
|
|
94
96
|
|
|
@@ -199,6 +201,9 @@ function normalizeMetadata(input: ResultEnvelopeInput): ResultMetadata {
|
|
|
199
201
|
const metadata = input.metadata ?? {};
|
|
200
202
|
return {
|
|
201
203
|
contextLengthExceeded: metadata.contextLengthExceeded ?? false,
|
|
204
|
+
...(metadata.contextOverflowRecovered === undefined
|
|
205
|
+
? {}
|
|
206
|
+
: { contextOverflowRecovered: metadata.contextOverflowRecovered }),
|
|
202
207
|
...(metadata.provider === undefined ? {} : { provider: metadata.provider }),
|
|
203
208
|
...(metadata.model === undefined ? {} : { model: metadata.model }),
|
|
204
209
|
...(metadata.usage === undefined ? {} : { usage: metadata.usage }),
|
|
@@ -218,6 +223,9 @@ function normalizeMetadata(input: ResultEnvelopeInput): ResultMetadata {
|
|
|
218
223
|
...(metadata.nonFatalStreamErrors === undefined
|
|
219
224
|
? {}
|
|
220
225
|
: { nonFatalStreamErrors: metadata.nonFatalStreamErrors }),
|
|
226
|
+
...(metadata.recoveredStreamErrors === undefined
|
|
227
|
+
? {}
|
|
228
|
+
: { recoveredStreamErrors: metadata.recoveredStreamErrors }),
|
|
221
229
|
...(metadata.parseErrors === undefined
|
|
222
230
|
? {}
|
|
223
231
|
: { parseErrors: metadata.parseErrors }),
|
|
@@ -16,6 +16,11 @@ export const FAILURE_KINDS = [
|
|
|
16
16
|
"sandbox",
|
|
17
17
|
"rpc",
|
|
18
18
|
"model",
|
|
19
|
+
"provider_error",
|
|
20
|
+
"model_error",
|
|
21
|
+
"output_schema_error",
|
|
22
|
+
"guard_failure",
|
|
23
|
+
"user_cancelled",
|
|
19
24
|
"tool",
|
|
20
25
|
"exit",
|
|
21
26
|
"parse",
|
|
@@ -109,6 +114,10 @@ export interface ResolveInput {
|
|
|
109
114
|
mode?: ExecutionMode;
|
|
110
115
|
tasks?: SubagentTaskInput[];
|
|
111
116
|
concurrency?: number;
|
|
117
|
+
/** Stop scheduling additional parallel siblings after the first failed result. */
|
|
118
|
+
failFast?: boolean;
|
|
119
|
+
/** Abort already-running parallel siblings after the first failed result. Implies fail-fast scheduling. */
|
|
120
|
+
cancelSiblingsOnFailure?: boolean;
|
|
112
121
|
asyncDependency?: AsyncDependency;
|
|
113
122
|
workspace?: WorkspaceInput | WorkspaceMode;
|
|
114
123
|
worktree?: boolean | string;
|
|
@@ -572,6 +572,27 @@ export function validateResolveInput(
|
|
|
572
572
|
input.concurrency = concurrency;
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
+
if (raw.failFast !== undefined) {
|
|
576
|
+
const failFast = validateBoolean(
|
|
577
|
+
raw.failFast,
|
|
578
|
+
"failFast",
|
|
579
|
+
backendForKnownFailure,
|
|
580
|
+
);
|
|
581
|
+
if (typeof failFast !== "boolean") return failFast;
|
|
582
|
+
input.failFast = failFast;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (raw.cancelSiblingsOnFailure !== undefined) {
|
|
586
|
+
const cancelSiblingsOnFailure = validateBoolean(
|
|
587
|
+
raw.cancelSiblingsOnFailure,
|
|
588
|
+
"cancelSiblingsOnFailure",
|
|
589
|
+
backendForKnownFailure,
|
|
590
|
+
);
|
|
591
|
+
if (typeof cancelSiblingsOnFailure !== "boolean")
|
|
592
|
+
return cancelSiblingsOnFailure;
|
|
593
|
+
input.cancelSiblingsOnFailure = cancelSiblingsOnFailure;
|
|
594
|
+
}
|
|
595
|
+
|
|
575
596
|
if (raw.chain !== undefined) {
|
|
576
597
|
return failure(
|
|
577
598
|
'chain mode is not supported by pi-subagent; use mode:"parallel" for fanout or have the parent orchestrate sequencing.',
|