@yycholla/pi-dynamic-workflows 3.3.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.
Files changed (179) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +325 -0
  3. package/assets/readme/hero.png +0 -0
  4. package/assets/readme/hero.svg +70 -0
  5. package/assets/readme/package-cover.png +0 -0
  6. package/assets/readme/package-cover.svg +66 -0
  7. package/assets/readme/workflow.png +0 -0
  8. package/assets/readme/workflow.svg +77 -0
  9. package/dist/accept-workflow-guidance.d.ts +14 -0
  10. package/dist/accept-workflow-guidance.js +53 -0
  11. package/dist/adversarial-review.d.ts +30 -0
  12. package/dist/adversarial-review.js +107 -0
  13. package/dist/agent-history.d.ts +20 -0
  14. package/dist/agent-history.js +122 -0
  15. package/dist/agent-registry.d.ts +83 -0
  16. package/dist/agent-registry.js +190 -0
  17. package/dist/agent.d.ts +364 -0
  18. package/dist/agent.js +714 -0
  19. package/dist/builtin-commands.d.ts +19 -0
  20. package/dist/builtin-commands.js +251 -0
  21. package/dist/builtin-workflows.d.ts +45 -0
  22. package/dist/builtin-workflows.js +121 -0
  23. package/dist/code-review.d.ts +26 -0
  24. package/dist/code-review.js +181 -0
  25. package/dist/config.d.ts +37 -0
  26. package/dist/config.js +44 -0
  27. package/dist/deep-research.d.ts +30 -0
  28. package/dist/deep-research.js +124 -0
  29. package/dist/display.d.ts +134 -0
  30. package/dist/display.js +248 -0
  31. package/dist/effort-command.d.ts +28 -0
  32. package/dist/effort-command.js +68 -0
  33. package/dist/enums.d.ts +69 -0
  34. package/dist/enums.js +78 -0
  35. package/dist/errors.d.ts +113 -0
  36. package/dist/errors.js +140 -0
  37. package/dist/extension-reload.d.ts +37 -0
  38. package/dist/extension-reload.js +78 -0
  39. package/dist/fs-persistence.d.ts +63 -0
  40. package/dist/fs-persistence.js +102 -0
  41. package/dist/index.d.ts +57 -0
  42. package/dist/index.js +35 -0
  43. package/dist/logger.d.ts +21 -0
  44. package/dist/logger.js +66 -0
  45. package/dist/model-routing.d.ts +30 -0
  46. package/dist/model-routing.js +50 -0
  47. package/dist/model-spec.d.ts +29 -0
  48. package/dist/model-spec.js +252 -0
  49. package/dist/model-tier-config.d.ts +133 -0
  50. package/dist/model-tier-config.js +249 -0
  51. package/dist/run-persistence.d.ts +180 -0
  52. package/dist/run-persistence.js +294 -0
  53. package/dist/saved-commands.d.ts +28 -0
  54. package/dist/saved-commands.js +100 -0
  55. package/dist/shared-store.d.ts +98 -0
  56. package/dist/shared-store.js +212 -0
  57. package/dist/structured-output.d.ts +19 -0
  58. package/dist/structured-output.js +30 -0
  59. package/dist/task-panel.d.ts +61 -0
  60. package/dist/task-panel.js +422 -0
  61. package/dist/usage-limit-scheduler.d.ts +145 -0
  62. package/dist/usage-limit-scheduler.js +368 -0
  63. package/dist/web-tools.d.ts +20 -0
  64. package/dist/web-tools.js +120 -0
  65. package/dist/workflow-authoring-coverage.d.ts +70 -0
  66. package/dist/workflow-authoring-coverage.js +421 -0
  67. package/dist/workflow-authoring-reference.d.ts +20 -0
  68. package/dist/workflow-authoring-reference.js +156 -0
  69. package/dist/workflow-capability-contract.d.ts +131 -0
  70. package/dist/workflow-capability-contract.js +604 -0
  71. package/dist/workflow-commands.d.ts +18 -0
  72. package/dist/workflow-commands.js +260 -0
  73. package/dist/workflow-comprehension.d.ts +133 -0
  74. package/dist/workflow-comprehension.js +1321 -0
  75. package/dist/workflow-context-measurement.d.ts +72 -0
  76. package/dist/workflow-context-measurement.js +213 -0
  77. package/dist/workflow-control-tool.d.ts +30 -0
  78. package/dist/workflow-control-tool.js +176 -0
  79. package/dist/workflow-delivery-choice.d.ts +20 -0
  80. package/dist/workflow-delivery-choice.js +48 -0
  81. package/dist/workflow-editor.d.ts +93 -0
  82. package/dist/workflow-editor.js +363 -0
  83. package/dist/workflow-manager.d.ts +492 -0
  84. package/dist/workflow-manager.js +1124 -0
  85. package/dist/workflow-paths.d.ts +22 -0
  86. package/dist/workflow-paths.js +46 -0
  87. package/dist/workflow-release-gate.d.ts +39 -0
  88. package/dist/workflow-release-gate.js +309 -0
  89. package/dist/workflow-saved.d.ts +38 -0
  90. package/dist/workflow-saved.js +126 -0
  91. package/dist/workflow-settings.d.ts +70 -0
  92. package/dist/workflow-settings.js +131 -0
  93. package/dist/workflow-tool.d.ts +71 -0
  94. package/dist/workflow-tool.js +367 -0
  95. package/dist/workflow-ui.d.ts +182 -0
  96. package/dist/workflow-ui.js +1587 -0
  97. package/dist/workflow.d.ts +333 -0
  98. package/dist/workflow.js +1151 -0
  99. package/dist/workflows-models-command.d.ts +31 -0
  100. package/dist/workflows-models-command.js +156 -0
  101. package/dist/worktree.d.ts +25 -0
  102. package/dist/worktree.js +61 -0
  103. package/extensions/workflow.ts +151 -0
  104. package/package.json +104 -0
  105. package/skills/workflow-authoring/SKILL.md +30 -0
  106. package/skills/workflow-authoring/examples/adversarial-verification.js +63 -0
  107. package/skills/workflow-authoring/examples/bounded-semantic-retry.js +56 -0
  108. package/skills/workflow-authoring/examples/classify-and-act.js +67 -0
  109. package/skills/workflow-authoring/examples/fan-out-and-synthesize.js +47 -0
  110. package/skills/workflow-authoring/examples/generate-and-filter.js +68 -0
  111. package/skills/workflow-authoring/examples/loop-until-done.js +68 -0
  112. package/skills/workflow-authoring/examples/phased-budgets.js +75 -0
  113. package/skills/workflow-authoring/examples/saved-nested-workflows.js +44 -0
  114. package/skills/workflow-authoring/examples/structured-output.js +37 -0
  115. package/skills/workflow-authoring/examples/tournament.js +81 -0
  116. package/skills/workflow-authoring/examples/validated-gate.js +63 -0
  117. package/skills/workflow-authoring/references/capabilities.md +41 -0
  118. package/skills/workflow-authoring/references/capability-details.md +357 -0
  119. package/skills/workflow-authoring/references/common-helpers.md +4 -0
  120. package/skills/workflow-authoring/references/debugging.md +27 -0
  121. package/skills/workflow-authoring/references/focused-recipes.md +11 -0
  122. package/skills/workflow-authoring/references/helpers.md +9 -0
  123. package/skills/workflow-authoring/references/lifecycle.md +33 -0
  124. package/skills/workflow-authoring/references/pattern-selection.md +15 -0
  125. package/skills/workflow-authoring/references/quality-helpers.md +8 -0
  126. package/skills/workflow-authoring/references/registry-ownership.md +15 -0
  127. package/skills/workflow-authoring/references/retry-helper.md +5 -0
  128. package/skills/workflow-authoring/references/review.md +43 -0
  129. package/skills/workflow-authoring/references/runtime.md +27 -0
  130. package/skills/workflow-authoring/references/specialized-helpers.md +19 -0
  131. package/skills/workflow-authoring/references/versions.md +13 -0
  132. package/skills/workflow-patterns/SKILL.md +51 -0
  133. package/src/accept-workflow-guidance.ts +71 -0
  134. package/src/adversarial-review.ts +120 -0
  135. package/src/agent-history.ts +157 -0
  136. package/src/agent-registry.ts +221 -0
  137. package/src/agent.ts +929 -0
  138. package/src/builtin-commands.ts +286 -0
  139. package/src/builtin-workflows.ts +155 -0
  140. package/src/code-review.ts +183 -0
  141. package/src/config.ts +55 -0
  142. package/src/deep-research.ts +135 -0
  143. package/src/display.ts +367 -0
  144. package/src/effort-command.ts +87 -0
  145. package/src/enums.ts +77 -0
  146. package/src/errors.ts +199 -0
  147. package/src/extension-reload.ts +100 -0
  148. package/src/fs-persistence.ts +124 -0
  149. package/src/index.ts +176 -0
  150. package/src/logger.ts +88 -0
  151. package/src/model-routing.ts +73 -0
  152. package/src/model-spec.ts +309 -0
  153. package/src/model-tier-config.ts +296 -0
  154. package/src/run-persistence.ts +484 -0
  155. package/src/saved-commands.ts +115 -0
  156. package/src/shared-store.ts +228 -0
  157. package/src/structured-output.ts +47 -0
  158. package/src/task-panel.ts +490 -0
  159. package/src/usage-limit-scheduler.ts +432 -0
  160. package/src/web-tools.ts +124 -0
  161. package/src/workflow-authoring-coverage.ts +486 -0
  162. package/src/workflow-authoring-reference.ts +186 -0
  163. package/src/workflow-capability-contract.ts +806 -0
  164. package/src/workflow-commands.ts +287 -0
  165. package/src/workflow-comprehension.ts +1673 -0
  166. package/src/workflow-context-measurement.ts +262 -0
  167. package/src/workflow-control-tool.ts +238 -0
  168. package/src/workflow-delivery-choice.ts +69 -0
  169. package/src/workflow-editor.ts +444 -0
  170. package/src/workflow-manager.ts +1405 -0
  171. package/src/workflow-paths.ts +63 -0
  172. package/src/workflow-release-gate.ts +529 -0
  173. package/src/workflow-saved.ts +180 -0
  174. package/src/workflow-settings.ts +194 -0
  175. package/src/workflow-tool.ts +464 -0
  176. package/src/workflow-ui.ts +1789 -0
  177. package/src/workflow.ts +1615 -0
  178. package/src/workflows-models-command.ts +211 -0
  179. package/src/worktree.ts +76 -0
@@ -0,0 +1,260 @@
1
+ /**
2
+ * `/workflows` slash command: list, inspect, and control background workflow runs.
3
+ * Shares the extension's single WorkflowManager so background runs are reachable.
4
+ */
5
+ import { fmtFull, fmtTokenSegment, recomputeWorkflowSnapshot, renderWorkflowText, tokenFigures, } from "./display.js";
6
+ import { effortDirective } from "./effort-command.js";
7
+ import { registerSavedWorkflow } from "./saved-commands.js";
8
+ import { buildForcedWorkflowPrompt, WORKFLOW_TOOL_NAME } from "./workflow-editor.js";
9
+ import { openWorkflowNavigator } from "./workflow-ui.js";
10
+ const STATUS_ICON = {
11
+ pending: "·",
12
+ running: "◆",
13
+ paused: "⏸",
14
+ completed: "✓",
15
+ failed: "✗",
16
+ aborted: "⊘",
17
+ };
18
+ const USAGE = "Usage: /workflows [list] | run <prompt> | status <id> | watch <id> | stop <id> | pause <id> | resume <id> | rm <id> | save <name> [runId]";
19
+ const RUN_USAGE = "Usage: /workflows run <prompt> — force a dynamic workflow from the prompt";
20
+ function summarizeRun(run) {
21
+ const icon = STATUS_ICON[run.status] ?? "?";
22
+ const done = run.agents.filter((a) => a.status === "done").length;
23
+ const total = run.agents.length;
24
+ const segment = fmtTokenSegment(tokenFigures(run.tokenUsage), fmtFull);
25
+ const tokens = segment ? ` · ${segment}` : "";
26
+ return `${icon} ${run.runId} ${run.workflowName} [${run.status}] ${done}/${total} agents${tokens}`;
27
+ }
28
+ function oneLineProgress(snapshot) {
29
+ const total = snapshot.agents.length;
30
+ const done = snapshot.agents.filter((a) => a.status === "done").length;
31
+ const running = snapshot.agents.filter((a) => a.status === "running").length;
32
+ const errs = snapshot.agents.filter((a) => a.status === "error").length;
33
+ const phase = snapshot.currentPhase ? ` · ${snapshot.currentPhase}` : "";
34
+ return `◆ ${snapshot.name}: ${done}/${total} done${running ? `, ${running} running` : ""}${errs ? `, ${errs} err` : ""}${phase}`;
35
+ }
36
+ /**
37
+ * Subscribe to a running run's events and stream live progress to the status bar,
38
+ * printing the final snapshot when it finishes. Non-blocking: returns true if the
39
+ * run was active and is now being watched, false otherwise. Listeners clean up on
40
+ * completion so nothing leaks.
41
+ */
42
+ function watchRun(manager, pi, ctx, id) {
43
+ const active = manager.getRun(id);
44
+ if (active?.status !== "running")
45
+ return false;
46
+ const key = `wf:${id}`;
47
+ const update = () => {
48
+ const run = manager.getRun(id);
49
+ if (run)
50
+ ctx.ui.setStatus(key, oneLineProgress(run.snapshot));
51
+ };
52
+ const onEvent = (e) => {
53
+ if (!e || e.runId === id)
54
+ update();
55
+ };
56
+ let settled = false;
57
+ const progressEvents = ["agentStart", "agentEnd", "phase", "log"];
58
+ const finalEvents = ["complete", "error", "stopped", "paused"];
59
+ const finish = (e) => {
60
+ if (e && e.runId !== id)
61
+ return;
62
+ if (settled)
63
+ return;
64
+ settled = true;
65
+ for (const ev of progressEvents)
66
+ manager.off(ev, onEvent);
67
+ for (const ev of finalEvents)
68
+ manager.off(ev, finish);
69
+ ctx.ui.setStatus(key, undefined);
70
+ const run = manager.getRun(id);
71
+ if (run) {
72
+ void pi.sendMessage({
73
+ customType: "workflows",
74
+ content: renderWorkflowText(recomputeWorkflowSnapshot(run.snapshot), true),
75
+ display: true,
76
+ });
77
+ }
78
+ };
79
+ for (const ev of progressEvents)
80
+ manager.on(ev, onEvent);
81
+ for (const ev of finalEvents)
82
+ manager.on(ev, finish);
83
+ update();
84
+ return true;
85
+ }
86
+ function renderPersistedStatus(run) {
87
+ const lines = [`${STATUS_ICON[run.status] ?? "?"} ${run.workflowName} (${run.runId}) — ${run.status}`];
88
+ if (run.currentPhase)
89
+ lines.push(` phase: ${run.currentPhase}`);
90
+ for (const agent of run.agents) {
91
+ const icon = agent.status === "done" ? "✓" : agent.status === "error" ? "✗" : agent.status === "running" ? "◆" : "·";
92
+ lines.push(` ${icon} ${agent.label}`);
93
+ }
94
+ const tokenSegment = fmtTokenSegment(tokenFigures(run.tokenUsage), fmtFull);
95
+ if (tokenSegment)
96
+ lines.push(` tokens: ${tokenSegment}`);
97
+ if (run.durationMs)
98
+ lines.push(` duration: ${(run.durationMs / 1000).toFixed(1)}s`);
99
+ return lines.join("\n");
100
+ }
101
+ /** Register the `/workflows` command against the shared manager. Idempotent. */
102
+ export function registerWorkflowCommands(pi, manager, opts = {}) {
103
+ try {
104
+ const taken = (pi.getCommands?.() ?? []).some((c) => c.name === "workflows");
105
+ if (taken)
106
+ return;
107
+ }
108
+ catch {
109
+ // getCommands may be unavailable in some hosts; fall through and try to register.
110
+ }
111
+ pi.registerCommand("workflows", {
112
+ description: "Manage workflow runs — no args (opens navigator) | run <prompt> | status/stop/pause/resume <id> | rm <id> | save <name> [runId]",
113
+ async handler(args, ctx) {
114
+ const parts = args.trim().split(/\s+/).filter(Boolean);
115
+ const sub = (parts[0] ?? "list").toLowerCase();
116
+ const id = parts[1];
117
+ const print = (text) => pi.sendMessage({ customType: "workflows", content: text, display: true });
118
+ switch (sub) {
119
+ case "run": {
120
+ const prompt = args
121
+ .trim()
122
+ .slice(parts[0]?.length ?? 0)
123
+ .trim();
124
+ if (!prompt) {
125
+ ctx.ui.notify(RUN_USAGE, "warning");
126
+ return;
127
+ }
128
+ // Best-effort: ensure the workflow tool is active (session_start usually has).
129
+ // Add-only so this does not interfere with the keyword hook's save/restore state.
130
+ try {
131
+ const active = pi.getActiveTools?.() ?? [];
132
+ if (!active.includes(WORKFLOW_TOOL_NAME))
133
+ pi.setActiveTools?.([...active, WORKFLOW_TOOL_NAME]);
134
+ }
135
+ catch {
136
+ // ignore — the forced directive is the real forcing primitive
137
+ }
138
+ const effort = opts.effort;
139
+ const extra = effort && effort.level !== "off" ? effortDirective(effort.level) : undefined;
140
+ // `/workflows run` is an explicit, maximal-intent command — use the
141
+ // forcing directive (no "if it's a question just answer" escape),
142
+ // distinct from the heuristic keyword/effort arming.
143
+ const armed = buildForcedWorkflowPrompt(prompt, extra);
144
+ ctx.ui.notify(`Running workflow: ${prompt.slice(0, 60)}${prompt.length > 60 ? "…" : ""}`, "info");
145
+ try {
146
+ await pi.sendMessage({ customType: "workflow-run", content: armed, display: true }, { triggerTurn: true, deliverAs: "followUp" });
147
+ }
148
+ catch {
149
+ ctx.ui.notify("Could not start the workflow turn.", "error");
150
+ }
151
+ return;
152
+ }
153
+ case "ui":
154
+ case "list": {
155
+ // Interactive navigator when a UI is available; plain text otherwise
156
+ // (print/RPC mode) or when the user explicitly asks for `list`.
157
+ if (sub !== "list" && ctx.hasUI) {
158
+ await openWorkflowNavigator(pi, manager, ctx.ui, { storage: opts.storage, cwd: opts.cwd });
159
+ return;
160
+ }
161
+ if (parts.length === 0 && ctx.hasUI) {
162
+ await openWorkflowNavigator(pi, manager, ctx.ui, { storage: opts.storage, cwd: opts.cwd });
163
+ return;
164
+ }
165
+ const runs = manager.listRuns();
166
+ if (!runs.length) {
167
+ await print("No workflow runs yet. Start one with a background workflow (background: true).");
168
+ return;
169
+ }
170
+ await print(["Workflow runs:", ...runs.map(summarizeRun), "", USAGE].join("\n"));
171
+ return;
172
+ }
173
+ case "watch":
174
+ case "status": {
175
+ if (!id) {
176
+ ctx.ui.notify(USAGE, "warning");
177
+ return;
178
+ }
179
+ // A running run streams live progress to the status bar and prints the
180
+ // final snapshot when it finishes — no need to re-run the command.
181
+ if (watchRun(manager, pi, ctx, id)) {
182
+ ctx.ui.notify(`Watching ${id} — live progress in the status bar; result prints when it finishes.`, "info");
183
+ return;
184
+ }
185
+ const live = manager.getSnapshot(id);
186
+ if (live) {
187
+ await print(renderWorkflowText(recomputeWorkflowSnapshot(live), false));
188
+ return;
189
+ }
190
+ const run = manager.listRuns().find((r) => r.runId === id);
191
+ if (!run) {
192
+ ctx.ui.notify(`No workflow run "${id}"`, "error");
193
+ return;
194
+ }
195
+ await print(renderPersistedStatus(run));
196
+ return;
197
+ }
198
+ case "stop": {
199
+ if (!id)
200
+ return ctx.ui.notify(USAGE, "warning");
201
+ ctx.ui.notify(manager.stop(id) ? `Stopped ${id}` : `Cannot stop ${id} (not running)`, manager.getRun(id) ? "info" : "warning");
202
+ return;
203
+ }
204
+ case "pause": {
205
+ if (!id)
206
+ return ctx.ui.notify(USAGE, "warning");
207
+ ctx.ui.notify(manager.pause(id) ? `Paused ${id}` : `Cannot pause ${id} (not running)`, "info");
208
+ return;
209
+ }
210
+ case "resume": {
211
+ if (!id)
212
+ return ctx.ui.notify(USAGE, "warning");
213
+ const ok = await manager.resume(id);
214
+ ctx.ui.notify(ok ? `Resumed ${id}` : `Resume not available for ${id} yet`, ok ? "info" : "warning");
215
+ return;
216
+ }
217
+ case "rm": {
218
+ if (!id)
219
+ return ctx.ui.notify(USAGE, "warning");
220
+ ctx.ui.notify(manager.deleteRun(id) ? `Removed ${id}` : `No run ${id}`, "info");
221
+ return;
222
+ }
223
+ case "save": {
224
+ const name = id;
225
+ if (!name)
226
+ return ctx.ui.notify("Usage: /workflows save <name> [runId]", "warning");
227
+ if (!opts.storage)
228
+ return ctx.ui.notify("Saving is not available (no storage configured)", "error");
229
+ const storage = opts.storage;
230
+ const runs = manager.listRuns();
231
+ const runIdArg = parts[2];
232
+ // Pick the named run, else the most recent run that still has its script.
233
+ const run = runIdArg ? runs.find((r) => r.runId === runIdArg) : runs.find((r) => r.script);
234
+ if (!run?.script) {
235
+ ctx.ui.notify(runIdArg ? `No run ${runIdArg} with a script` : "No saved run to save", "error");
236
+ return;
237
+ }
238
+ let saved;
239
+ try {
240
+ saved = storage.save({
241
+ name,
242
+ description: run.workflowName,
243
+ script: run.script,
244
+ location: "project",
245
+ });
246
+ }
247
+ catch (error) {
248
+ ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
249
+ return;
250
+ }
251
+ registerSavedWorkflow(pi, opts.cwd ?? process.cwd(), saved, undefined, () => storage.list().some((w) => w.name === saved.name));
252
+ ctx.ui.notify(`Saved /${name} (from ${run.runId})`, "info");
253
+ return;
254
+ }
255
+ default:
256
+ ctx.ui.notify(`Unknown subcommand "${sub}". ${USAGE}`, "warning");
257
+ }
258
+ },
259
+ });
260
+ }
@@ -0,0 +1,133 @@
1
+ import type { ModelThinkingLevel } from "@earendil-works/pi-ai";
2
+ import { ComprehensionSuite, ComprehensionTaskKind } from "./enums.js";
3
+ import { type WorkflowRuntimeEvent } from "./workflow.js";
4
+ /** Re-exported scenario groups and authoring operations used by the optional comprehension CLI. */
5
+ export { ComprehensionSuite, ComprehensionTaskKind } from "./enums.js";
6
+ /** Prompt and expected authoring branch for one optional model scenario. */
7
+ export interface ComprehensionScenario {
8
+ id: string;
9
+ suite: ComprehensionSuite;
10
+ kind: ComprehensionTaskKind;
11
+ prompt: string;
12
+ }
13
+ /** Stable quick, core, and coverage scenarios available to provider and replay runs. */
14
+ export declare const COMPREHENSION_SCENARIOS: readonly ComprehensionScenario[];
15
+ /** Skill discovery and read calls observed while the parent model authored a workflow. */
16
+ export interface SkillLoadingEvidence {
17
+ discovered: boolean;
18
+ loaded: boolean;
19
+ toolCalls: Array<{
20
+ tool: string;
21
+ path?: string;
22
+ }>;
23
+ }
24
+ /** Provider-reported usage attached to one generated workflow. */
25
+ export interface ComprehensionTokenUsage {
26
+ input: number;
27
+ output: number;
28
+ total: number;
29
+ cost: number;
30
+ cacheRead: number;
31
+ cacheWrite: number;
32
+ }
33
+ /** Workflow source and generation evidence supplied to the deterministic replay seam. */
34
+ export interface ModelGeneration {
35
+ workflow: string;
36
+ skillLoadingEvidence: SkillLoadingEvidence;
37
+ tokenUsage: ComprehensionTokenUsage;
38
+ }
39
+ /** Re-exported generation failure that retains loading and usage evidence. */
40
+ export { ModelGenerationError } from "./errors.js";
41
+ interface RuntimeCall {
42
+ index: number;
43
+ completedIndex: number | null;
44
+ label: string;
45
+ prompt: string;
46
+ phase: string | null;
47
+ structured: boolean;
48
+ scenarioRole: "generator" | "filter" | null;
49
+ status: "returned" | "null";
50
+ result: unknown;
51
+ }
52
+ type RuntimeEvent = WorkflowRuntimeEvent & {
53
+ index: number;
54
+ };
55
+ /** Exact requested and resolved model settings recorded for reproducible comparison. */
56
+ export interface ComprehensionModelSelection {
57
+ requested: string;
58
+ resolved: string;
59
+ thinkingLevel: ModelThinkingLevel | null;
60
+ }
61
+ type ComprehensionFailureStage = "generation" | "parse" | "runtime" | "assertion";
62
+ /** Versioned evidence from one generated workflow executed against its scenario contract. */
63
+ export interface ComprehensionEvidence {
64
+ formatVersion: 2;
65
+ provider: string;
66
+ modelSelection: ComprehensionModelSelection;
67
+ extensionVersion: string;
68
+ contractVersions: {
69
+ format: string;
70
+ content: string;
71
+ };
72
+ skillVersion: string;
73
+ task: {
74
+ id: string;
75
+ suite: ComprehensionSuite;
76
+ kind: ComprehensionTaskKind;
77
+ prompt: string;
78
+ };
79
+ generatedWorkflow: string | null;
80
+ skillLoadingEvidence: SkillLoadingEvidence;
81
+ tokenUsage: ComprehensionTokenUsage | null;
82
+ runtime: {
83
+ calls: RuntimeCall[];
84
+ events: RuntimeEvent[];
85
+ topology: {
86
+ maxConcurrent: number;
87
+ phases: string[];
88
+ };
89
+ failures: Array<{
90
+ callIndex: number;
91
+ label: string;
92
+ message: string;
93
+ errorCode: string | null;
94
+ recoverable: boolean | null;
95
+ }>;
96
+ result: unknown;
97
+ assertions: Array<{
98
+ name: string;
99
+ passed: boolean;
100
+ details: string;
101
+ }>;
102
+ };
103
+ passed: boolean;
104
+ failure: {
105
+ stage: ComprehensionFailureStage;
106
+ message: string;
107
+ stack?: string;
108
+ } | null;
109
+ }
110
+ interface RunComprehensionScenarioBaseOptions {
111
+ scenario: ComprehensionScenario;
112
+ provider: string;
113
+ extensionVersion: string;
114
+ contractVersions: {
115
+ format: string;
116
+ content: string;
117
+ };
118
+ skillVersion: string;
119
+ generate: (scenario: ComprehensionScenario) => Promise<ModelGeneration>;
120
+ }
121
+ /** Dependencies and version facts needed to generate and execute one comprehension scenario. */
122
+ export type RunComprehensionScenarioOptions = RunComprehensionScenarioBaseOptions & ({
123
+ modelSelection: ComprehensionModelSelection;
124
+ model?: never;
125
+ } | {
126
+ /** @deprecated Use modelSelection. Retained for provider-free callers created before evidence format 2. */
127
+ model: string;
128
+ modelSelection?: never;
129
+ });
130
+ /** Select scenarios in stable declaration order for one suite. */
131
+ export declare function selectComprehensionScenarios(suite: ComprehensionSuite | `${ComprehensionSuite}`): readonly ComprehensionScenario[];
132
+ /** Generate, parse, execute, and behaviorally score one scenario without making scoring-stage provider calls. */
133
+ export declare function runComprehensionScenario(options: RunComprehensionScenarioOptions): Promise<ComprehensionEvidence>;