@blackbelt-technology/pi-dashboard-flows-plugin 0.8.0 → 0.10.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,230 @@
1
+ /**
2
+ * Idle (not-started) flow state for the attach-before-run panel.
3
+ *
4
+ * `buildIdleFlowState` maps a flow.yaml to the step payload pi-flows 0.5.0
5
+ * `onFlowStarted` would emit (per-kind field subset + parser coercions), wraps it
6
+ * in a fake `flow_started` event and replays it through the REAL reducer, so the
7
+ * idle graph + cards equal what a real start shows. Mirrors every 0.5.0 parser
8
+ * throw so a bad definition yields an error instead of a wrong panel.
9
+ *
10
+ * `resolveFlowSlot` decides what the flow slot renders (running → attached →
11
+ * completed → nothing); `isAttachmentConsumed` is the replay catch-up rule.
12
+ *
13
+ * `flow-yaml-parse.ts` (the shallow `flow_write` snapshot parser) is untouched.
14
+ * See change: attach-flow-before-run (D1, D3, D4).
15
+ */
16
+ import type { DashboardEvent, FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
17
+ import { parse as parseYaml } from "yaml";
18
+ import { reduceFlowEvent } from "../reducer.js";
19
+
20
+ /** One step of the pi-flows 0.5.0 `flow:flow-started` payload. */
21
+ interface StartedStep {
22
+ id: string;
23
+ stepType: string;
24
+ agent?: string;
25
+ blockedBy: string[];
26
+ branches?: Record<string, string>;
27
+ onError?: string;
28
+ }
29
+
30
+ type Raw = Record<string, unknown>;
31
+
32
+ function requireField(obj: Raw, key: string, where: string): string {
33
+ const v = obj[key];
34
+ if (v === undefined || v === null) throw new Error(`flow.yaml: ${where} missing required field "${key}"`);
35
+ return String(v);
36
+ }
37
+
38
+ function blockedByOf(raw: Raw): string[] {
39
+ if (!raw.blockedBy) return [];
40
+ return Array.isArray(raw.blockedBy) ? raw.blockedBy.map(String) : [String(raw.blockedBy)];
41
+ }
42
+
43
+ function branchesOf(raw: Raw): Record<string, string> {
44
+ const out: Record<string, string> = {};
45
+ if (raw.branches && typeof raw.branches === "object") {
46
+ for (const [k, v] of Object.entries(raw.branches as Raw)) out[k] = String(v);
47
+ }
48
+ return out;
49
+ }
50
+
51
+ /** 0.5.0 `toInt`: an optional integer field must parse. */
52
+ function checkInt(obj: Raw, key: string, where: string): void {
53
+ if (obj[key] === undefined) return;
54
+ if (Number.isNaN(Number.parseInt(String(obj[key]), 10))) {
55
+ throw new Error(`flow.yaml: ${where} "${key}" must be an integer`);
56
+ }
57
+ }
58
+
59
+ const INPUT_TYPES = new Set(["string", "number", "boolean", "object", "array"]);
60
+
61
+ /** 0.5.0 `parseFlowInputs`: optional mapping of name → { type }. */
62
+ function checkInputs(raw: unknown): void {
63
+ if (raw === undefined) return;
64
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Error('flow.yaml: "inputs" must be a mapping');
65
+ for (const [k, v] of Object.entries(raw as Raw)) {
66
+ const type = (v as Raw | null)?.type;
67
+ if (typeof type !== "string" || !INPUT_TYPES.has(type)) {
68
+ throw new Error(`flow.yaml: input "${k}" needs a valid "type"`);
69
+ }
70
+ }
71
+ }
72
+
73
+ function onErrorOf(raw: Raw): string | undefined {
74
+ return raw.on_error ? String(raw.on_error) : undefined;
75
+ }
76
+
77
+ /**
78
+ * Map one YAML step to its started-payload shape using the pi-flows 0.5.0
79
+ * per-kind field table (agent: blockedBy+on_error; code: blockedBy+on_error;
80
+ * code-decision: blockedBy+branches; fork: branches (+optional agent);
81
+ * agent-decision: agent+branches). Throws where the 0.5.0 parser throws.
82
+ */
83
+ function toStartedStep(raw: unknown, index: number): StartedStep {
84
+ if (!raw || typeof raw !== "object") throw new Error(`flow.yaml: step ${index} is not an object`);
85
+ const r = raw as Raw;
86
+ const id = r.id;
87
+ if (!id || typeof id !== "string") throw new Error(`flow.yaml: step ${index} missing "id" field`);
88
+ const type = r.type;
89
+ if (!type || typeof type !== "string") throw new Error(`flow.yaml: step "${id}" missing required "type" field`);
90
+ const where = `step "${id}"`;
91
+ checkInt(r, "timeout", where);
92
+ checkInt(r, "max_iterations", where);
93
+ switch (type) {
94
+ case "agent":
95
+ return { id, stepType: type, agent: requireField(r, "agent", where), blockedBy: blockedByOf(r), onError: onErrorOf(r) };
96
+ case "code":
97
+ return { id, stepType: type, blockedBy: blockedByOf(r), onError: onErrorOf(r) };
98
+ case "code-decision":
99
+ return { id, stepType: type, blockedBy: blockedByOf(r), branches: branchesOf(r) };
100
+ case "fork":
101
+ requireField(r, "question", where);
102
+ requireField(r, "options", where);
103
+ return { id, stepType: type, agent: r.agent ? String(r.agent) : undefined, blockedBy: [], branches: branchesOf(r) };
104
+ case "agent-decision": {
105
+ const agent = requireField(r, "agent", where);
106
+ requireField(r, "task", where);
107
+ return { id, stepType: type, agent, blockedBy: [], branches: branchesOf(r) };
108
+ }
109
+ default:
110
+ throw new Error(`flow.yaml: unknown step type "${type}" for step "${id}"`);
111
+ }
112
+ }
113
+
114
+ /** Parse a flow.yaml into the 0.5.0 started-step payload. Throws on any error. */
115
+ function flowYamlToStartedSteps(content: string): StartedStep[] {
116
+ const doc = parseYaml(content) as unknown;
117
+ if (!doc || typeof doc !== "object") throw new Error("flow.yaml: empty or not a mapping");
118
+ requireField(doc as Raw, "name", "flow");
119
+ requireField(doc as Raw, "description", "flow");
120
+ checkInt(doc as Raw, "max_concurrent", "flow");
121
+ checkInputs((doc as Raw).inputs);
122
+ const steps = (doc as Raw).steps;
123
+ if (!Array.isArray(steps)) throw new Error('flow.yaml: "steps" must be an array');
124
+ return steps.map(toStartedStep);
125
+ }
126
+
127
+ export type IdleBuildResult =
128
+ | { kind: "ready"; flowState: FlowState }
129
+ | { kind: "error"; message: string };
130
+
131
+ /** Build the idle FlowState by replaying a fake 0.5.0 `flow_started`. */
132
+ export function buildIdleFlowState(
133
+ content: string,
134
+ flow: { name: string; source?: string },
135
+ ): IdleBuildResult {
136
+ let steps: StartedStep[];
137
+ try {
138
+ steps = flowYamlToStartedSteps(content);
139
+ } catch (err) {
140
+ return { kind: "error", message: err instanceof Error ? err.message : String(err) };
141
+ }
142
+ const event = {
143
+ seq: 0,
144
+ timestamp: 0,
145
+ eventType: "flow_started",
146
+ data: { flowName: flow.name, task: "", source: flow.source, autonomousMode: true, steps },
147
+ } as unknown as DashboardEvent;
148
+ // flow_started always seeds a state from null.
149
+ return { kind: "ready", flowState: reduceFlowEvent(null, event) as FlowState };
150
+ }
151
+
152
+ /** Coerce an event timestamp (number or ISO string) to epoch ms; non-finite → 0. */
153
+ export function toEventTime(ts: unknown): number {
154
+ const n = typeof ts === "string" ? Date.parse(ts) : Number(ts);
155
+ return Number.isFinite(n) ? n : 0;
156
+ }
157
+
158
+ /** Replay catch-up: a `flow_started` strictly newer than the attach baseline. */
159
+ export function isAttachmentConsumed(baselineStartedAt: number | null, lastFlowStartedAt: unknown): boolean {
160
+ if (baselineStartedAt === null) return false;
161
+ if (lastFlowStartedAt === undefined || lastFlowStartedAt === null) return false;
162
+ return toEventTime(lastFlowStartedAt) > baselineStartedAt;
163
+ }
164
+
165
+ /** Stored per-session attachment (see flow-attach-store.ts). */
166
+ export interface FlowAttachment {
167
+ /** Random per-attach token (conditional delete). */
168
+ id: string;
169
+ name: string;
170
+ source?: string;
171
+ baselineStartedAt: number | null;
172
+ }
173
+
174
+ export type IdleLoad =
175
+ | { kind: "loading" }
176
+ | { kind: "error"; message: string }
177
+ | { kind: "ready"; flowState: FlowState };
178
+
179
+ type FlowSlotError = { kind: "unavailable" } | { kind: "load"; message: string };
180
+
181
+ export interface FlowSlot {
182
+ mode: "live" | "idle" | "loading" | "error" | "none";
183
+ flowState?: FlowState;
184
+ error?: FlowSlotError;
185
+ /** True when an attachment exists and has been consumed (caller deletes it). */
186
+ attachmentConsumed: boolean;
187
+ }
188
+
189
+ function findRunning(
190
+ live: FlowState | null,
191
+ liveStates: ReadonlyMap<string, FlowState>,
192
+ ): FlowState | undefined {
193
+ if (live?.status === "running") return live;
194
+ let running: FlowState | undefined;
195
+ for (const s of liveStates.values()) if (s.status === "running") running = s;
196
+ return running;
197
+ }
198
+
199
+ /**
200
+ * Slot priority: running flow → attached (unconsumed) flow → completed flow →
201
+ * nothing. The idle state is only ever returned in `idle` mode; it never enters
202
+ * the live path.
203
+ */
204
+ export function resolveFlowSlot(input: {
205
+ live: FlowState | null;
206
+ liveStates: ReadonlyMap<string, FlowState>;
207
+ attachment: FlowAttachment | null;
208
+ idle: IdleLoad;
209
+ lastFlowStartedAt?: unknown;
210
+ flowsList: ReadonlyArray<{ name: string }>;
211
+ }): FlowSlot {
212
+ const { live, liveStates, attachment, idle, lastFlowStartedAt, flowsList } = input;
213
+ const running = findRunning(live, liveStates);
214
+ if (running) return { mode: "live", flowState: running, attachmentConsumed: !!attachment };
215
+
216
+ if (attachment && !isAttachmentConsumed(attachment.baselineStartedAt, lastFlowStartedAt)) {
217
+ if (flowsList.length > 0 && !flowsList.some((f) => f.name === attachment.name)) {
218
+ return { mode: "error", error: { kind: "unavailable" }, attachmentConsumed: false };
219
+ }
220
+ if (idle.kind === "loading") return { mode: "loading", attachmentConsumed: false };
221
+ if (idle.kind === "error") {
222
+ return { mode: "error", error: { kind: "load", message: idle.message }, attachmentConsumed: false };
223
+ }
224
+ return { mode: "idle", flowState: idle.flowState, attachmentConsumed: false };
225
+ }
226
+
227
+ const consumed = !!attachment;
228
+ if (live) return { mode: "live", flowState: live, attachmentConsumed: consumed };
229
+ return { mode: "none", attachmentConsumed: consumed };
230
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Actions gate for flows-plugin's `session-card-action-bar` claim
3
+ * (`SessionFlowMenuClaim`). Distinct from the FLOWS-subcard gate in
4
+ * `shouldRender.ts` (flow events only).
5
+ *
6
+ * Open iff pi-flows is active in the session's cwd — a command named `flows` or
7
+ * starting with `flows:` in `commandsList`, the removed `flows:new` alone NOT
8
+ * counting — OR the session has any flow event (live or replayed). Never gates on
9
+ * `flowsList` length, so an active-but-empty cwd still offers New / Edit….
10
+ * Closed by default: no `commandsList` published yet → closed.
11
+ *
12
+ * Synchronous and side-effect-free; reads `getSessionData` directly like
13
+ * `shouldRender.ts`.
14
+ *
15
+ * See change: add-session-actions-flyout (D12).
16
+ */
17
+ import { getSessionData } from "@blackbelt-technology/dashboard-plugin-runtime";
18
+ import type { CommandInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
19
+ import { sessionHasFlowEvents } from "./flowsAvailability.js";
20
+
21
+ /** True when `commands` carries a `flows` / `flows:*` signal (`flows:new` ignored). */
22
+ export function hasFlowsCommand(commands: readonly CommandInfo[] | null | undefined): boolean {
23
+ if (!Array.isArray(commands)) return false;
24
+ return commands.some(
25
+ (c) => c.name !== "flows:new" && (c.name === "flows" || c.name.startsWith("flows:")),
26
+ );
27
+ }
28
+
29
+ /** Whether the flows actions (menu claim) are available for `sessionId`. */
30
+ export function flowsActionsAvailable(sessionId: string): boolean {
31
+ return (
32
+ hasFlowsCommand(getSessionData<CommandInfo[]>(sessionId, "commandsList")) ||
33
+ sessionHasFlowEvents(sessionId)
34
+ );
35
+ }
@@ -25,26 +25,27 @@ export { FlowAgentsToolRenderer } from "./FlowAgentsToolRenderer.js";
25
25
  // session-card-badge claim was dropped because the badge belongs in the
26
26
  // FLOWS subcard, not WORKSPACE. SessionFlowActions now renders the badge
27
27
  // directly via the FlowActivityBadge component.
28
- export { FlowDashboard, FlowDashboardClaim } from "./FlowDashboard.js";
29
28
  export { computeLayout, FlowGraph, flowStateToGraphSteps } from "./FlowGraph.js";
30
29
  // Input-wiring editor claimed into automation-plugin's `automation-action-editor`
31
30
  // slot for `flows.run`. See change: wire-flow-inputs-in-automation.
32
- export { FlowInputWiring, FlowInputWiringClaim } from "./FlowInputWiring.js";
33
31
  export { FlowLaunchDialog } from "./FlowLaunchDialog.js";
34
32
  export { FlowSummary, FlowSummaryClaim } from "./FlowSummary.js";
35
33
  export type { FlowsPluginConfig } from "./FlowsSettings.js";
36
34
 
37
35
  // Settings section (global edit-mode default) — manifest `settings-section` claim.
38
- export { FlowsSettings } from "./FlowsSettings.js";
39
36
  export { FlowTabBar } from "./FlowTabBar.js";
40
37
  // Authoring tool-renderers (main-session timeline) — referenced by the
41
38
  // manifest's `tool-renderer` claims. See change: rework-flows-plugin-for-new-pi-flows.
42
- export { FlowWriteToolRenderer } from "./FlowWriteToolRenderer.js";
43
- export { FlowYamlPreviewClaim } from "./FlowYamlPreview.js";
44
39
  export { SessionFlowActions, SessionFlowActionsClaim } from "./SessionFlowActions.js";
45
40
 
46
- // Manifest-level shouldRender predicate for the `session-card-flows` claim.
47
- // See change: add-flows-subcard.
41
+ // `session-card-action-bar` claim: flow actions (Run / Open / New-Edit / Delete)
42
+ // in the session actions menu + dialogs + edit-mode reconcile, and its
43
+ // availability gate. See change: add-session-actions-flyout.
44
+ export { flowsActionsAvailable, hasFlowsCommand } from "./flowsActionsGate.js";
45
+ export { SessionFlowMenuClaim } from "./SessionFlowMenuClaim.js";
46
+
47
+ // Manifest-level shouldRender predicate for the `session-card-flows` claim
48
+ // (any flow event). See change: add-flows-subcard, add-session-actions-flyout.
48
49
  export { shouldRenderFlowsSubcard } from "./shouldRender.js";
49
50
 
50
51
  // Flow slash commands (`/flows`, `/flows:new`, `/flows:edit`, `/flows:delete`)
@@ -2,37 +2,22 @@
2
2
  * Manifest-level `shouldRender` callback for flows-plugin's
3
3
  * `session-card-flows` claim (`SessionFlowActionsClaim`).
4
4
  *
5
- * Returns the SAME boolean the claim uses to decide it renders content:
6
- * `flowsList non-empty OR edit mode on OR a flow event exists`. This keeps the
7
- * subcard's visibility gate and the claim's render condition in lockstep, so the
8
- * shell's `FlowsSubcard` wrapper (which gates on `useSlotHasClaimsForSession`,
9
- * consulting this predicate) never paints an empty panel when the claim would
10
- * render `null`.
5
+ * The FLOWS subcard carries flow STATUS only, so it renders IFF the session has
6
+ * any flow event (live or replayed). It no longer depends on `flowsList`, edit
7
+ * mode or extension presence — those gate the flow ACTIONS, which live in the
8
+ * `session-card-action-bar` claim (see `flowsActionsGate.ts`).
11
9
  *
12
10
  * Must be synchronous and side-effect-free (manifest-level `shouldRender`
13
- * contract). Reads live per-session-data (`getSessionData`) + plugin config
14
- * (`getPluginConfig`) directly — the same synchronous sources the claim reads —
15
- * instead of a mirrored availability cache. Closed-by-default holds: on cold
16
- * boot `flowsList` is empty, edit mode off, no events → `false` → hidden, then
17
- * visible once flows populate (the acceptable hidden→visible direction).
11
+ * contract). Reads the live event stream directly via `sessionHasFlowEvents`.
18
12
  *
19
- * See change: fix-empty-flows-subcard.
13
+ * See change: fix-empty-flows-subcard, add-session-actions-flyout.
20
14
  */
21
- import { getSessionData } from "@blackbelt-technology/dashboard-plugin-runtime";
22
- import { getPluginConfig } from "@blackbelt-technology/dashboard-plugin-runtime/context";
23
15
  import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
24
- import type { FlowInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
25
16
  import { sessionHasFlowEvents } from "./flowsAvailability.js";
26
17
 
27
18
  export function shouldRenderFlowsSubcard(
28
19
  session: DashboardSession | null | undefined,
29
20
  ): boolean {
30
21
  if (!session) return false;
31
- const flows = getSessionData<FlowInfo[]>(session.id, "flowsList");
32
- const editMode = (getPluginConfig("flows") as { editFlow?: boolean }).editFlow ?? false;
33
- return (
34
- (Array.isArray(flows) && flows.length > 0) ||
35
- editMode ||
36
- sessionHasFlowEvents(session.id)
37
- );
22
+ return sessionHasFlowEvents(session.id);
38
23
  }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Contract between the flows-plugin bridge and server for reporting a session's
3
+ * flow files (see `bridge/flow-files-reporter.ts`, `server/flow-files.ts`).
4
+ * Import-free leaf so the bridge never pulls server code.
5
+ * See change: attach-flow-before-run.
6
+ */
7
+
8
+ export interface ReportedFile {
9
+ name: string;
10
+ source: string;
11
+ }
12
+
13
+ export interface FlowFilesReport {
14
+ flows?: ReportedFile[];
15
+ agents?: ReportedFile[];
16
+ }
17
+
18
+ /** Private bridge → server lane message carrying a {@link FlowFilesReport}. */
19
+ export const FLOW_FILES_REPORT = "flow-files/report";
20
+ /** pi event the server emits into a session to ask its bridge to (re)report. */
21
+ export const FLOW_FILES_REQUEST_EVENT = "dashboard-flows:report-files";
@@ -356,6 +356,10 @@ export function reduceFlowEvent(
356
356
 
357
357
  case "flow_complete": {
358
358
  if (!flowState) return null;
359
+ // A rejected start (pi-flows refused to run; no flow_started was emitted)
360
+ // never refers to the run held here — leave it untouched.
361
+ // See change: attach-flow-before-run (D10).
362
+ if (data.status === "rejected") return flowState;
359
363
  const status = ((data.status as string) || "success") as FlowState["status"];
360
364
  // When the flow ends non-successfully (error / aborted / interrupted),
361
365
  // downgrade any step left running/pending so its card does not spin
package/src/i18n.ts CHANGED
@@ -25,6 +25,9 @@ export const catalog = {
25
25
  dismiss: "关闭",
26
26
  flowsHeading: "流程",
27
27
  editModeLabel: "编辑模式",
28
+ settingsIntro: "多智能体工作流。这是所有会话的默认设置。",
29
+ editModeHintPre: "允许主会话创建和修改流程与智能体。启用",
30
+ editModeHintPost: "以及 edit-flow 技能。默认关闭。",
28
31
  runFlowTitle: "运行流程:{flowName}",
29
32
  taskPlaceholder: "描述任务(可选)…",
30
33
  summary: "摘要",
@@ -39,6 +42,20 @@ export const catalog = {
39
42
  newFlowOption: "+ 新建流程",
40
43
  newFlowOptionDesc: "使用 edit-flow 技能创建新流程",
41
44
  runFlowButton: "运行流程…",
45
+ openFlowButton: "打开流程…",
46
+ openFlowDialogTitle: "打开流程",
47
+ openFlowDisabledRunning: "有流程正在运行",
48
+ flowNotStarted: "未开始",
49
+ runFlow: "运行",
50
+ closeAttachedFlow: "关闭",
51
+ flowDefinitionLoadError: "流程定义文件不可用",
52
+ flowNoLongerAvailable: "已不可用",
53
+ flowLoading: "加载中…",
54
+ flowRunRejected: "启动被拒绝",
55
+ flowRunSendFailed: "无法启动流程",
56
+ openHandlerInEditor: "在编辑器中打开处理程序",
57
+ openSourceInEditor: "在编辑器中打开 {name} 源文件",
58
+ openFlowYamlInEditor: "在编辑器中打开 {name} YAML",
42
59
  newEditButton: "新建 / 编辑…",
43
60
  runFlowDialogTitle: "运行流程",
44
61
  searchFlows: "搜索流程…",
@@ -62,6 +79,9 @@ export const catalog = {
62
79
  dismiss: "Bezárás",
63
80
  flowsHeading: "Folyamatok",
64
81
  editModeLabel: "Szerkesztő mód",
82
+ settingsIntro: "Többügynökös munkafolyamatok. Ez az alapértelmezés minden munkamenetre.",
83
+ editModeHintPre: "Lehetővé teszi, hogy a fő munkamenet folyamatokat és ügynököket hozzon létre és módosítson. Bekapcsolja a",
84
+ editModeHintPost: "eszközöket és az edit-flow skillt. Alapértelmezetten kikapcsolva.",
65
85
  runFlowTitle: "Folyamat futtatása: {flowName}",
66
86
  taskPlaceholder: "Írd le a feladatot (opcionális)…",
67
87
  summary: "Összefoglaló",
@@ -76,6 +96,20 @@ export const catalog = {
76
96
  newFlowOption: "+ Új folyamat",
77
97
  newFlowOptionDesc: "Új folyamat készítése az edit-flow készséggel",
78
98
  runFlowButton: "Folyamat futtatása…",
99
+ openFlowButton: "Folyamat megnyitása…",
100
+ openFlowDialogTitle: "Folyamat megnyitása",
101
+ openFlowDisabledRunning: "Egy folyamat fut",
102
+ flowNotStarted: "nincs elindítva",
103
+ runFlow: "Futtatás",
104
+ closeAttachedFlow: "Bezárás",
105
+ flowDefinitionLoadError: "A folyamatdefiníciós fájl nem érhető el",
106
+ flowNoLongerAvailable: "már nem érhető el",
107
+ flowLoading: "betöltés…",
108
+ flowRunRejected: "Az indítás elutasítva",
109
+ flowRunSendFailed: "A folyamat nem indítható el",
110
+ openHandlerInEditor: "Kezelő megnyitása a szerkesztőben",
111
+ openSourceInEditor: "{name} forrásának megnyitása a szerkesztőben",
112
+ openFlowYamlInEditor: "{name} YAML megnyitása a szerkesztőben",
79
113
  newEditButton: "Új / Szerkesztés…",
80
114
  runFlowDialogTitle: "Folyamat futtatása",
81
115
  searchFlows: "Folyamatok keresése…",
@@ -46,6 +46,8 @@ export interface ActionContributionLike {
46
46
  * `agent_end`) without knowing anything action-specific.
47
47
  * See change: finalize-event-dispatched-automation-runs.
48
48
  */
49
+ /** Event types `buildEvent` may emit (required by the automation registry). */
50
+ emits?: string[];
49
51
  buildEvent?: (args: { payload: Record<string, unknown>; automation: unknown }) =>
50
52
  | {
51
53
  eventType: string;
@@ -130,6 +132,7 @@ export function flowsActionContributions(flowsForCwd: FlowsForCwd): ActionContri
130
132
  // which pi-flows consumes as `flowInput` → `${{flow.input.<name>}}`.
131
133
  // `task` stays optional and may coexist with `inputs`.
132
134
  // See change: finalize-event-dispatched-automation-runs, wire-flow-inputs-in-automation.
135
+ emits: ["flow:run"],
133
136
  buildEvent: ({ payload }) => {
134
137
  const flow = String(payload.flow ?? "").trim();
135
138
  if (!FLOW_ID_RE.test(flow)) return null;