@blackbelt-technology/pi-dashboard-flows-plugin 0.10.0 → 0.11.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/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-flows-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Flow rendering plugin for pi-dashboard — pi-flows event reaction (FlowDashboard, FlowAgentCard, FlowArchitect, etc.)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-dashboard-plugin"
|
|
7
|
+
],
|
|
5
8
|
"license": "MIT",
|
|
6
9
|
"publishConfig": {
|
|
7
10
|
"access": "public"
|
|
@@ -37,6 +40,13 @@
|
|
|
37
40
|
"pi-dashboard-plugin": {
|
|
38
41
|
"id": "flows",
|
|
39
42
|
"displayName": "Flows",
|
|
43
|
+
"eventTypes": [
|
|
44
|
+
"flow_*"
|
|
45
|
+
],
|
|
46
|
+
"emits": [
|
|
47
|
+
"flow:run",
|
|
48
|
+
"dashboard-flows:report-files"
|
|
49
|
+
],
|
|
40
50
|
"i18nCatalog": "catalog",
|
|
41
51
|
"priority": 100,
|
|
42
52
|
"configSchema": "./src/configSchema.json",
|
|
@@ -98,9 +108,9 @@
|
|
|
98
108
|
},
|
|
99
109
|
"//deps-rationale": "client-utils retained for hooks (useMobile, useZoomPan) and Phase-2 extension-ui slot consumers (AgentMetricSlot, BreadcrumbSlot, GateSlot, aggregateGateState helper). All UI primitive components (AgentCardShell, MarkdownContent, ConfirmDialog, DialogPortal, SearchableSelectDialog, ZoomControls, format-tokens, format-duration) flow through the UI primitive registry per add-plugin-ui-primitive-registry.",
|
|
100
110
|
"dependencies": {
|
|
101
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
102
|
-
"@blackbelt-technology/pi-dashboard-client-utils": "^0.
|
|
103
|
-
"@blackbelt-technology/pi-dashboard-shared": "^0.
|
|
111
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.11.0",
|
|
112
|
+
"@blackbelt-technology/pi-dashboard-client-utils": "^0.11.0",
|
|
113
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.11.0",
|
|
104
114
|
"@fastify/rate-limit": "^11.2.0",
|
|
105
115
|
"@mdi/js": "^7.4.47",
|
|
106
116
|
"@mdi/react": "^1.6.1",
|
|
@@ -17,10 +17,10 @@ import { Icon } from "@mdi/react";
|
|
|
17
17
|
import React, { type ReactNode } from "react";
|
|
18
18
|
|
|
19
19
|
const statusConfig: Record<string, { icon: ReactNode; color: string }> = {
|
|
20
|
-
running: { icon: <Icon path={mdiLoading} size={0.45} className="animate-spin" />, color: "text-blue-
|
|
21
|
-
success: { icon: <Icon path={mdiCheckCircle} size={0.45} />, color: "text-green-
|
|
22
|
-
error: { icon: <Icon path={mdiAlertCircle} size={0.45} />, color: "text-red-
|
|
23
|
-
aborted: { icon: <Icon path={mdiStopCircle} size={0.45} />, color: "text-orange-
|
|
20
|
+
running: { icon: <Icon path={mdiLoading} size={0.45} className="animate-spin" />, color: "text-[var(--accent-blue-text)]" },
|
|
21
|
+
success: { icon: <Icon path={mdiCheckCircle} size={0.45} />, color: "text-[var(--accent-green-text)]" },
|
|
22
|
+
error: { icon: <Icon path={mdiAlertCircle} size={0.45} />, color: "text-[var(--accent-red-text)]" },
|
|
23
|
+
aborted: { icon: <Icon path={mdiStopCircle} size={0.45} />, color: "text-[var(--accent-orange-text)]" },
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export interface FlowActivityBadgeProps {
|
|
@@ -59,7 +59,7 @@ export function FlowActivityBadge({
|
|
|
59
59
|
<button
|
|
60
60
|
type="button"
|
|
61
61
|
onClick={(e) => { e.stopPropagation(); onAbort(); }}
|
|
62
|
-
className="inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[
|
|
62
|
+
className="inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[12px] rounded border border-[var(--tint-red-border)] text-[var(--tint-red-fg)] bg-[var(--tint-red-bg)] hover:brightness-110 transition-colors flex-shrink-0"
|
|
63
63
|
title={t("abortRunningFlow", undefined, "Abort running flow")}
|
|
64
64
|
>
|
|
65
65
|
<Icon path={mdiStop} size={0.4} />
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* panel's Save). See change: rework-flows-plugin-for-new-pi-flows.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { ToggleField, useSettingsDraftSource, useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
14
|
-
import { usePluginConfig, usePluginSend } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
13
|
+
import { ToggleField, usePluginConfig, usePluginSend, useSettingsDraftSource, useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
15
14
|
import type React from "react";
|
|
16
15
|
import { useCallback, useRef, useState } from "react";
|
|
17
16
|
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
usePluginSend,
|
|
3
|
-
useSessionData,
|
|
4
|
-
useSessionEvents,
|
|
5
|
-
useT,
|
|
6
|
-
useUiPrimitive,
|
|
7
|
-
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
8
|
-
import { usePluginConfig } from "@blackbelt-technology/dashboard-plugin-runtime/context";
|
|
1
|
+
import { usePluginConfig, usePluginSend, useSessionData, useSessionEvents, useT, useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
9
2
|
import { ActionList } from "@blackbelt-technology/pi-dashboard-client-utils/ActionList";
|
|
10
3
|
import type { UiSelectOption as SelectOption } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
11
4
|
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import fs from "node:fs";
|
|
15
15
|
import path from "node:path";
|
|
16
|
+
import type { ServerPluginContext } from "@blackbelt-technology/dashboard-plugin-runtime/server";
|
|
17
|
+
import type { AdmitCwdOptions } from "@blackbelt-technology/pi-dashboard-shared/cwd-guard.js";
|
|
18
|
+
import {
|
|
19
|
+
admitRouteCwdParam,
|
|
20
|
+
sendRouteCwdRefusal,
|
|
21
|
+
} from "@blackbelt-technology/pi-dashboard-shared/plugin-route-cwd.js";
|
|
16
22
|
import { parse as parseYaml } from "yaml";
|
|
17
23
|
|
|
18
24
|
export type FlowInputType = "string" | "number" | "boolean" | "object" | "array";
|
|
@@ -24,10 +30,24 @@ export interface FlowInputField {
|
|
|
24
30
|
required: boolean;
|
|
25
31
|
}
|
|
26
32
|
|
|
33
|
+
/** A path segment that would climb or stay put (`.` / `..`) — never a flow namespace or name. */
|
|
34
|
+
const isDotSegment = (s: string): boolean => s === "." || s === "..";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether a flow id could escape the flows dir: exactly `.` / `..`, or any path separator.
|
|
38
|
+
* Only EXACT dot segments count — `team.review`, `a..b`, `...`, `.hidden`, `x.` stay valid.
|
|
39
|
+
* For the `<ns>:<name>` form each segment is checked, since `..:x` would climb.
|
|
40
|
+
* See change: harden-git-terminal-plugin-boundaries (S1r).
|
|
41
|
+
*/
|
|
42
|
+
function isTraversalFlowId(flowId: string): boolean {
|
|
43
|
+
if (flowId.includes("/") || flowId.includes("\\")) return true;
|
|
44
|
+
return flowId.split(":").some(isDotSegment);
|
|
45
|
+
}
|
|
46
|
+
|
|
27
47
|
/** Resolve a `<ns>:<name>` flow id to its `flow.yaml` path under `cwd`. */
|
|
28
48
|
export function flowYamlPath(cwd: string, flowId: string): string | null {
|
|
29
49
|
const m = /^([\w.-]+):([\w.-]+)$/.exec(flowId);
|
|
30
|
-
if (!m) return null;
|
|
50
|
+
if (!m || isDotSegment(m[1]) || isDotSegment(m[2])) return null;
|
|
31
51
|
return path.join(cwd, ".pi", "flows", "flows", m[1], m[2], "flow.yaml");
|
|
32
52
|
}
|
|
33
53
|
|
|
@@ -56,3 +76,38 @@ export function readFlowInputs(cwd: string, flowId: string): FlowInputField[] {
|
|
|
56
76
|
}
|
|
57
77
|
return out;
|
|
58
78
|
}
|
|
79
|
+
|
|
80
|
+
export interface FlowInputsRouteDeps {
|
|
81
|
+
/** Live admit set (host known folders), read per request. Fail-closed default: nothing known. */
|
|
82
|
+
knownCwds?: () => string[];
|
|
83
|
+
/** `admitCwd` options (the host's throttled `onIndeterminate` logger; test seams). */
|
|
84
|
+
admitOptions?: AdmitCwdOptions;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* `GET /api/plugins/flows/flow-inputs?cwd=&flow=` — read-only. The cwd is REQUIRED and admitted
|
|
89
|
+
* (400 `invalid_cwd` / `cwd_required`, 403, 503) before any flow file is read — there is no
|
|
90
|
+
* `process.cwd()` fallback — and a traversal-shaped flow id is 400 `invalid_flow_id`.
|
|
91
|
+
* See change: wire-flow-inputs-in-automation; harden-git-terminal-plugin-boundaries (S1r).
|
|
92
|
+
*/
|
|
93
|
+
export function mountFlowInputsRoute(fastify: ServerPluginContext["fastify"], deps: FlowInputsRouteDeps = {}): void {
|
|
94
|
+
fastify.get("/api/plugins/flows/flow-inputs", async (req, reply) => {
|
|
95
|
+
const q = (req.query ?? {}) as Record<string, unknown>;
|
|
96
|
+
const adm = await admitRouteCwdParam(q.cwd, {
|
|
97
|
+
required: true,
|
|
98
|
+
...(deps.knownCwds ? { knownCwds: deps.knownCwds } : {}),
|
|
99
|
+
...(deps.admitOptions ? { admitOptions: deps.admitOptions } : {}),
|
|
100
|
+
});
|
|
101
|
+
if (!adm.ok) return sendRouteCwdRefusal(reply, adm);
|
|
102
|
+
try {
|
|
103
|
+
const flow = typeof q.flow === "string" ? q.flow : "";
|
|
104
|
+
if (flow && isTraversalFlowId(flow)) {
|
|
105
|
+
reply.code(400);
|
|
106
|
+
return { error: "invalid_flow_id", message: "flow id must not contain path separators or dot segments" };
|
|
107
|
+
}
|
|
108
|
+
return { inputs: flow && adm.cwd ? readFlowInputs(adm.cwd, flow) : [] };
|
|
109
|
+
} finally {
|
|
110
|
+
adm.release();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
package/src/server/index.ts
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* See change: adopt-server-driven-intent-rendering.
|
|
9
9
|
*/
|
|
10
10
|
import type { ServerPluginContext } from "@blackbelt-technology/dashboard-plugin-runtime/server";
|
|
11
|
+
import type { AdmitCwdOptions } from "@blackbelt-technology/pi-dashboard-shared/cwd-guard.js";
|
|
11
12
|
import { provideFlowsActions } from "./automation-actions.js";
|
|
12
|
-
import { readFlowInputs } from "./flow-inputs.js";
|
|
13
13
|
import { registerFlowFileRoutes } from "./flow-files.js";
|
|
14
|
+
import { mountFlowInputsRoute } from "./flow-inputs.js";
|
|
14
15
|
import { renderSessionFlowActions } from "./render-actions.js";
|
|
15
16
|
import { stateStore } from "./state-store.js";
|
|
16
17
|
|
|
@@ -61,11 +62,15 @@ export async function registerPlugin(ctx: ServerPluginContext): Promise<void> {
|
|
|
61
62
|
// Read-only endpoint: a flow's declared `inputs:` schema, for the automation
|
|
62
63
|
// input-wiring UI. Never writes a flow file. See change:
|
|
63
64
|
// wire-flow-inputs-in-automation.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
// The cwd is required + admitted against the host known folders (no `process.cwd()`
|
|
66
|
+
// fallback); a traversal-shaped flow id is refused. See change:
|
|
67
|
+
// harden-git-terminal-plugin-boundaries (S1r).
|
|
68
|
+
const admitOnIndeterminate = ctx.consume<NonNullable<AdmitCwdOptions["onIndeterminate"]>>(
|
|
69
|
+
"host.cwdAdmissionOnIndeterminate",
|
|
70
|
+
);
|
|
71
|
+
mountFlowInputsRoute(ctx.fastify, {
|
|
72
|
+
knownCwds: ctx.consume<() => string[]>("host.knownFolderCwds") ?? (() => []),
|
|
73
|
+
...(admitOnIndeterminate ? { admitOptions: { onIndeterminate: admitOnIndeterminate } } : {}),
|
|
69
74
|
});
|
|
70
75
|
|
|
71
76
|
// Flow YAML / agent / code-handler files reported by this plugin's bridge,
|