@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,212 @@
1
+ /**
2
+ * In-memory key-value store scoped to a single workflow run.
3
+ *
4
+ * One `SharedStore` instance is created at run start and disposed when the run
5
+ * ends. Two MCP-compatible tool definitions (`store_put` / `store_get`) are
6
+ * injected into every agent's tool list so parallel agents can share
7
+ * intermediate state without coordinating through the script itself.
8
+ *
9
+ * Journal integration: callers capture `store.commitDelta(deltaKey)` alongside
10
+ * each agent result in the journal. On resume, `store.applyDelta(delta)` rebuilds
11
+ * the store state additively in callSeq order, so parallel-agent writes are
12
+ * replayed correctly without the last-complete-wins ordering bug that a
13
+ * whole-Map restore() would cause.
14
+ *
15
+ * `deltaKey` must be unique across every run that shares this store instance,
16
+ * not just within one run's callSeq. A nested `workflow()` call restarts its own
17
+ * callSeq at 0 while inheriting the parent's store (so parent and nested-run
18
+ * agents can share state), so a bare callIndex would collide between a parent
19
+ * agent and a concurrently-running nested-run agent that both got index 0 —
20
+ * whichever commits its delta last would clobber the other's entry in
21
+ * `agentDeltas`. Callers compose `deltaKey` as `${runId}:${callIndex}`, and
22
+ * since every run (including each nested run) gets its own distinct `runId`,
23
+ * the composite key is unique across the whole store's lifetime.
24
+ */
25
+ import { defineTool } from "@earendil-works/pi-coding-agent";
26
+ import { Type } from "typebox";
27
+ export class SharedStore {
28
+ map = new Map();
29
+ // Per-agent write deltas for delta-journaling; keyed by a run-unique
30
+ // `${runId}:${callIndex}` string (see class doc) so nested workflow() runs
31
+ // sharing this store can't collide on a bare callIndex.
32
+ agentDeltas = new Map();
33
+ // Pre-write shadow values for the CURRENT delta-key's in-progress writes,
34
+ // so a failed retry attempt's mutations can be rolled back (see
35
+ // `discardDelta`) instead of leaking into the live store or a later
36
+ // successful attempt's recorded delta. Populated lazily by `trackPut` (only
37
+ // the first write to a given key within the current delta window is
38
+ // shadowed — later writes to the same key within the same attempt are
39
+ // already covered by that first shadow) and cleared whenever the delta is
40
+ // finalized, either way, via `commitDelta`/`discardDelta`.
41
+ priorValues = new Map();
42
+ /** Store a value under `key`. Overwrites any existing value. */
43
+ put(key, value) {
44
+ this.map.set(key, value);
45
+ }
46
+ /**
47
+ * Store a value and record the write in the per-agent delta for `deltaKey`
48
+ * (a run-unique `${runId}:${callIndex}` string — see class doc). Used by
49
+ * per-agent tools created via `createAgentStoreTools` so that each agent's
50
+ * writes can be journaled and replayed independently.
51
+ */
52
+ trackPut(key, value, deltaKey) {
53
+ let priors = this.priorValues.get(deltaKey);
54
+ if (!priors) {
55
+ priors = new Map();
56
+ this.priorValues.set(deltaKey, priors);
57
+ }
58
+ // Only shadow the value from BEFORE this delta window started writing to
59
+ // this key — a second write to the same key within the same attempt must
60
+ // not overwrite the shadow with its own (already-in-window) value.
61
+ if (!priors.has(key)) {
62
+ priors.set(key, this.map.has(key) ? { existed: true, value: this.map.get(key) } : { existed: false, value: undefined });
63
+ }
64
+ this.map.set(key, value);
65
+ let delta = this.agentDeltas.get(deltaKey);
66
+ if (!delta) {
67
+ delta = {};
68
+ this.agentDeltas.set(deltaKey, delta);
69
+ }
70
+ delta[key] = value;
71
+ }
72
+ /** Retrieve the value for `key`, or `undefined` when absent. */
73
+ get(key) {
74
+ return this.map.get(key);
75
+ }
76
+ /** Whether `key` is present in the store. */
77
+ has(key) {
78
+ return this.map.has(key);
79
+ }
80
+ /** Return a deep-copied plain-object snapshot of all entries. */
81
+ snapshot() {
82
+ return structuredClone(Object.fromEntries(this.map));
83
+ }
84
+ /**
85
+ * Extract and clear the write delta accumulated for `deltaKey`.
86
+ * Called after an agent completes to get the set of keys it wrote.
87
+ */
88
+ commitDelta(deltaKey) {
89
+ const delta = this.agentDeltas.get(deltaKey) ?? {};
90
+ this.agentDeltas.delete(deltaKey);
91
+ this.priorValues.delete(deltaKey);
92
+ return delta;
93
+ }
94
+ /**
95
+ * Undo the writes recorded for `deltaKey` and discard its bookkeeping,
96
+ * without touching any other key. Used when a retry attempt fails: that
97
+ * attempt's writes must not remain visible in the live store (e.g. to a
98
+ * concurrently-running sibling agent's store_get, or to script code reading
99
+ * `store.get` directly) and must not merge into the delta eventually
100
+ * recorded when a later attempt of the SAME call succeeds — otherwise a
101
+ * failed attempt's mutations would silently survive into the run's live
102
+ * state while being absent from the journaled delta that resume replay
103
+ * reconstructs from, leaving live execution and replay permanently
104
+ * inconsistent. Each key touched during this delta window is restored to
105
+ * whatever it held immediately before the window started (or deleted, if
106
+ * it did not exist yet) — never to some other attempt's or caller's value.
107
+ *
108
+ * Per-key guard: a key is only rolled back if the store STILL holds this
109
+ * attempt's own last write to it (checked with `Object.is` against the
110
+ * value recorded in `delta`). If a concurrently-running sibling (a
111
+ * different `deltaKey`, e.g. another agent in the same parallel() batch)
112
+ * legitimately overwrote the same key AFTER this attempt wrote it but
113
+ * BEFORE it failed, that sibling's write is left untouched — rolling back
114
+ * unconditionally would silently erase a live, unrelated write that this
115
+ * attempt never made and has no business undoing.
116
+ *
117
+ * A no-op if `deltaKey` never wrote anything (nothing to roll back).
118
+ */
119
+ discardDelta(deltaKey) {
120
+ const delta = this.agentDeltas.get(deltaKey);
121
+ if (!delta)
122
+ return;
123
+ const priors = this.priorValues.get(deltaKey);
124
+ for (const key of Object.keys(delta)) {
125
+ // Someone else already overwrote this key since our last write to it —
126
+ // leave their write in place instead of clobbering it with our rollback.
127
+ if (!Object.is(this.map.get(key), delta[key]))
128
+ continue;
129
+ const prior = priors?.get(key);
130
+ if (prior?.existed)
131
+ this.map.set(key, prior.value);
132
+ else
133
+ this.map.delete(key);
134
+ }
135
+ this.agentDeltas.delete(deltaKey);
136
+ this.priorValues.delete(deltaKey);
137
+ }
138
+ /**
139
+ * Apply a write delta additively — sets each key without clearing others.
140
+ * Used during resume replay so parallel-agent deltas applied in callSeq
141
+ * order accumulate correctly regardless of original completion order.
142
+ */
143
+ applyDelta(delta) {
144
+ for (const [k, v] of Object.entries(delta)) {
145
+ this.map.set(k, v);
146
+ }
147
+ }
148
+ /**
149
+ * Replace all entries with a snapshot (for full resets).
150
+ * Prefer `applyDelta` for resume replay — see journal integration above.
151
+ */
152
+ restore(snap) {
153
+ this.map.clear();
154
+ for (const [k, v] of Object.entries(snap)) {
155
+ this.map.set(k, v);
156
+ }
157
+ }
158
+ /** Clear all entries (called when the run ends). */
159
+ dispose() {
160
+ this.map.clear();
161
+ this.agentDeltas.clear();
162
+ this.priorValues.clear();
163
+ }
164
+ }
165
+ /**
166
+ * Create per-agent store tools that attribute writes to `deltaKey`, a
167
+ * run-unique `${runId}:${callIndex}` string (see the `SharedStore` class doc
168
+ * for why the bare callIndex alone is not enough once a nested `workflow()`
169
+ * call shares this store).
170
+ * Used internally by `runWorkflow` so each agent's puts are tracked in the
171
+ * store's delta journal and can be replayed additively on resume.
172
+ */
173
+ export function createAgentStoreTools(store, deltaKey) {
174
+ const storePut = defineTool({
175
+ name: "store_put",
176
+ label: "Store Put",
177
+ description: "Write a value to the shared run store. Any other agent in this workflow run can read it with store_get. Overwrites any existing value for the key. Note: when two parallel agents write the same key, the last write wins — no merge is performed.",
178
+ promptSnippet: "Write a value to the shared store",
179
+ parameters: Type.Object({
180
+ key: Type.String({ description: "The key to store the value under." }),
181
+ value: Type.Any({ description: "The value to store (any JSON-serializable value)." }),
182
+ }),
183
+ async execute(_id, params) {
184
+ store.trackPut(params.key, params.value, deltaKey);
185
+ return {
186
+ content: [{ type: "text", text: `Stored value under key "${params.key}".` }],
187
+ details: { key: params.key },
188
+ };
189
+ },
190
+ });
191
+ const storeGet = defineTool({
192
+ name: "store_get",
193
+ label: "Store Get",
194
+ description: "Read a value from the shared run store previously written by store_put. Returns the stored value, or null when the key does not exist.",
195
+ promptSnippet: "Read a value from the shared store",
196
+ parameters: Type.Object({
197
+ key: Type.String({ description: "The key to read." }),
198
+ }),
199
+ async execute(_id, params) {
200
+ const found = store.has(params.key);
201
+ const value = store.get(params.key);
202
+ const text = found
203
+ ? `Value for key "${params.key}": ${JSON.stringify(value)}`
204
+ : `Key "${params.key}" not found in store.`;
205
+ return {
206
+ content: [{ type: "text", text }],
207
+ details: { key: params.key, value: found ? value : null, found },
208
+ };
209
+ },
210
+ });
211
+ return [storePut, storeGet];
212
+ }
@@ -0,0 +1,19 @@
1
+ import { defineTool } from "@earendil-works/pi-coding-agent";
2
+ import type { Static, TSchema } from "typebox";
3
+ export interface StructuredOutputCapture<T = unknown> {
4
+ value: T | undefined;
5
+ called: boolean;
6
+ }
7
+ export interface StructuredOutputToolOptions<TSchemaDef extends TSchema> {
8
+ schema: TSchemaDef;
9
+ capture: StructuredOutputCapture<Static<TSchemaDef>>;
10
+ name?: string;
11
+ }
12
+ /**
13
+ * Create a terminating tool that captures validated params as the subagent result.
14
+ *
15
+ * Pi validates `params` against `schema` before execute() is called. Returning
16
+ * `terminate: true` lets the subagent finish on this tool call without paying for
17
+ * an extra assistant follow-up turn.
18
+ */
19
+ export declare function createStructuredOutputTool<TSchemaDef extends TSchema>({ schema, capture, name, }: StructuredOutputToolOptions<TSchemaDef>): ReturnType<typeof defineTool<TSchemaDef, Static<TSchemaDef>>>;
@@ -0,0 +1,30 @@
1
+ import { defineTool } from "@earendil-works/pi-coding-agent";
2
+ /**
3
+ * Create a terminating tool that captures validated params as the subagent result.
4
+ *
5
+ * Pi validates `params` against `schema` before execute() is called. Returning
6
+ * `terminate: true` lets the subagent finish on this tool call without paying for
7
+ * an extra assistant follow-up turn.
8
+ */
9
+ export function createStructuredOutputTool({ schema, capture, name = "structured_output", }) {
10
+ return defineTool({
11
+ name,
12
+ label: "Structured Output",
13
+ description: "Return the final machine-readable result for this subagent task.",
14
+ promptSnippet: "Return final machine-readable output",
15
+ promptGuidelines: [
16
+ `${name} is the final answer channel for this task; call ${name} exactly once when done.`,
17
+ `Do not write a prose final answer after calling ${name}.`,
18
+ ],
19
+ parameters: schema,
20
+ async execute(_toolCallId, params) {
21
+ capture.value = params;
22
+ capture.called = true;
23
+ return {
24
+ content: [{ type: "text", text: "Structured output received." }],
25
+ details: params,
26
+ terminate: true,
27
+ };
28
+ },
29
+ });
30
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Background-run UX, mirroring Claude Code:
3
+ * - A live task panel below the input lists in-progress runs while you keep working.
4
+ * It is informational; run /workflows to open the full navigator.
5
+ * - When a background run finishes, its result is delivered back into the
6
+ * conversation so the paused task continues with the outcome.
7
+ */
8
+ import type { ExtensionAPI, ExtensionUIContext, Theme } from "@earendil-works/pi-coding-agent";
9
+ import type { ManagedRun, WorkflowManager } from "./workflow-manager.js";
10
+ import type { WorkflowStorage } from "./workflow-saved.js";
11
+ import type { WorkflowSettings } from "./workflow-settings.js";
12
+ export interface TaskPanelOptions {
13
+ storage?: WorkflowStorage;
14
+ cwd?: string;
15
+ /**
16
+ * Live settings loader. When provided, the panel reads it fresh (with a short
17
+ * TTL cache) on each render so `/workflows-progress` takes effect without a
18
+ * restart. Omitted in tests / minimal hosts → always compact.
19
+ */
20
+ loadSettings?: () => WorkflowSettings;
21
+ }
22
+ export declare function deliverText(run: ManagedRun, opts?: {
23
+ resultPath?: string;
24
+ maxChars?: number;
25
+ }): string;
26
+ /**
27
+ * When a background run finishes (or fails), deliver its result back into the
28
+ * conversation AND continue the turn so the assistant can act on it — without
29
+ * blocking the user meanwhile:
30
+ *
31
+ * - `triggerTurn: true` starts a fresh turn when the agent is idle, feeding the
32
+ * result to the model so the paused conversation continues.
33
+ * - `deliverAs: "followUp"` means that if the user is busy in another turn, the
34
+ * result is queued and picked up after that turn finishes — never interrupting.
35
+ *
36
+ * Set up once per extension; idempotent via an internal guard.
37
+ */
38
+ export declare function installResultDelivery(pi: ExtensionAPI, manager: WorkflowManager, opts?: {
39
+ loadSettings?: () => WorkflowSettings;
40
+ }): void;
41
+ export declare function renderPanel(manager: WorkflowManager, theme: Theme, width?: number): string[];
42
+ /** Record a token-total sample for `runId` at time `now` (ms). */
43
+ export declare function sampleTokens(runId: string, total: number, now: number): void;
44
+ /** Tokens/second over the rolling window; 0 when too few samples or totals plateau. */
45
+ export declare function tokensPerSecond(runId: string): number;
46
+ /** Forget a run's samples (call when it finishes) so the map can't grow unbounded. */
47
+ export declare function clearTokenSamples(runId: string): void;
48
+ /** Normalize the configured per-phase agent cap to a sane integer (default 8). */
49
+ export declare function clampMaxAgents(value: number | undefined): number;
50
+ /**
51
+ * Detailed variant of {@link renderPanel}: per-run header with aggregate tokens,
52
+ * cost, and a live token/s rate, followed by per-phase progress and per-agent rows
53
+ * (capped at `maxAgents` per phase). `now` is injected for testability.
54
+ */
55
+ export declare function renderPanelDetailed(manager: WorkflowManager, theme: Theme, width: number | undefined, maxAgents: number, now: number): string[];
56
+ /**
57
+ * Install the live "workflows running" panel below the editor. Re-rendered on
58
+ * every manager event. Informational only — the user opens the navigator with
59
+ * /workflows. (`_pi` is kept for signature stability.)
60
+ */
61
+ export declare function installTaskPanel(_pi: ExtensionAPI, manager: WorkflowManager, ui: ExtensionUIContext, opts?: TaskPanelOptions): void;