@blackbelt-technology/pi-dashboard-flows-plugin 0.5.4 → 0.6.1
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 +25 -16
- package/src/AGENTS.md +8 -0
- package/src/__tests__/FlowGraph.test.ts +151 -5
- package/src/__tests__/FlowInputWiring.test.tsx +97 -0
- package/src/__tests__/FlowSummary.test.tsx +331 -0
- package/src/__tests__/FlowYamlPreview.test.tsx +75 -0
- package/src/__tests__/FlowsSessionStateContext.test.tsx +2 -39
- package/src/__tests__/authoring-renderers.test.tsx +190 -0
- package/src/__tests__/automation-actions.test.ts +117 -0
- package/src/__tests__/flow-agent-card-code-source.test.tsx +154 -0
- package/src/__tests__/flow-agent-cost.test.tsx +160 -0
- package/src/__tests__/flow-agent-error.test.ts +60 -0
- package/src/__tests__/flow-collapse-storage.test.ts +90 -0
- package/src/__tests__/flow-edges.test.ts +195 -0
- package/src/__tests__/flow-inputs.test.ts +69 -0
- package/src/__tests__/flow-reducer-bridge-contract.test.ts +108 -0
- package/src/__tests__/flow-reducer-seed-on-start.test.ts +61 -0
- package/src/__tests__/flow-yaml-parse.test.ts +124 -0
- package/src/__tests__/flows-for-cwd.test.ts +51 -0
- package/src/__tests__/flowsAvailability.test.ts +51 -64
- package/src/__tests__/node-kind-reducer.test.ts +135 -0
- package/src/__tests__/plugin-action-handler.test.ts +54 -0
- package/src/__tests__/session-flow-actions-edit.test.tsx +98 -0
- package/src/bridge/AGENTS.md +8 -0
- package/src/client/AGENTS.md +32 -0
- package/src/client/FlowActivityBadge.tsx +8 -5
- package/src/client/FlowAgentCard.tsx +231 -110
- package/src/client/FlowAgentDetail.tsx +20 -12
- package/src/client/FlowAgentsToolRenderer.tsx +228 -0
- package/src/client/FlowAuthorPromptDialog.tsx +92 -0
- package/src/client/FlowDashboard.tsx +88 -23
- package/src/client/FlowGraph.tsx +420 -275
- package/src/client/FlowInputWiring.tsx +243 -0
- package/src/client/FlowLaunchDialog.tsx +48 -54
- package/src/client/FlowQuestionCard.tsx +6 -3
- package/src/client/FlowSummary.tsx +252 -69
- package/src/client/FlowWriteToolRenderer.tsx +127 -0
- package/src/client/FlowYamlPopoverButton.tsx +26 -25
- package/src/client/FlowYamlPreview.tsx +9 -7
- package/src/client/FlowsSessionStateContext.tsx +14 -33
- package/src/client/FlowsSettings.tsx +68 -0
- package/src/client/SessionFlowActions.tsx +92 -76
- package/src/client/flow-collapse-storage.ts +79 -0
- package/src/client/flow-edges.ts +173 -0
- package/src/client/flow-yaml-parse.ts +140 -0
- package/src/client/flowsAvailability.ts +28 -87
- package/src/client/index.tsx +27 -32
- package/src/client/shouldRender.ts +24 -12
- package/src/configSchema.json +14 -0
- package/src/flow-reducer.ts +94 -13
- package/src/i18n.ts +90 -0
- package/src/reducer.ts +5 -5
- package/src/server/AGENTS.md +10 -0
- package/src/server/automation-actions.ts +162 -0
- package/src/server/flow-inputs.ts +58 -0
- package/src/server/index.ts +93 -9
- package/src/server/state-store.ts +3 -14
- package/src/__tests__/ArchitectInputPrompt.test.tsx +0 -81
- package/src/__tests__/architect-reducer.test.ts +0 -307
- package/src/architect-reducer.ts +0 -386
- package/src/client/FlowAgentPopoutClaim.tsx +0 -66
- package/src/client/FlowAgentPopoutPage.tsx +0 -177
- package/src/client/FlowArchitect.tsx +0 -699
- package/src/client/FlowArchitectPopoutClaim.tsx +0 -52
- package/src/client/FlowArchitectPopoutPage.tsx +0 -133
- package/src/client/popout-url.ts +0 -59
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FlowArchitectPopoutClaim — slot-claim wrapper for the
|
|
3
|
-
* `shell-overlay-route` registration `/session/:sid/architect`.
|
|
4
|
-
*
|
|
5
|
-
* Reads architect state via the plugin's `useFlowsSessionState`,
|
|
6
|
-
* cold-open subscribes, renders `FlowArchitectPopoutPage`.
|
|
7
|
-
*
|
|
8
|
-
* See change: fix-flows-plugin-polish (A4).
|
|
9
|
-
*/
|
|
10
|
-
import React, { useEffect, useRef } from "react";
|
|
11
|
-
import {
|
|
12
|
-
usePluginSend,
|
|
13
|
-
useShellConnectionStatus,
|
|
14
|
-
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
15
|
-
import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
16
|
-
import { useFlowsSessionState } from "./FlowsSessionStateContext.js";
|
|
17
|
-
import { FlowArchitectPopoutPage } from "./FlowArchitectPopoutPage.js";
|
|
18
|
-
|
|
19
|
-
export interface FlowArchitectPopoutClaimProps {
|
|
20
|
-
params: Record<string, string>;
|
|
21
|
-
session?: DashboardSession;
|
|
22
|
-
onBack: () => void;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function FlowArchitectPopoutClaim({ params, session, onBack }: FlowArchitectPopoutClaimProps) {
|
|
26
|
-
const sessionId = params.sid ?? "";
|
|
27
|
-
const send = usePluginSend();
|
|
28
|
-
const { architectState } = useFlowsSessionState(sessionId);
|
|
29
|
-
const connectionStatus = useShellConnectionStatus();
|
|
30
|
-
|
|
31
|
-
// Cold-open subscribe exactly once, AFTER the WebSocket is open.
|
|
32
|
-
// See change: fix-flows-plugin-polish (popout cold-open subscribe).
|
|
33
|
-
const subscribedRef = useRef(false);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!sessionId || subscribedRef.current) return;
|
|
36
|
-
if (connectionStatus !== "connected") return;
|
|
37
|
-
subscribedRef.current = true;
|
|
38
|
-
send({ type: "subscribe", sessionId, lastSeq: 0 });
|
|
39
|
-
}, [sessionId, send, connectionStatus]);
|
|
40
|
-
|
|
41
|
-
const subscriptionResolved = !!session || architectState !== null;
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<FlowArchitectPopoutPage
|
|
45
|
-
sessionId={sessionId}
|
|
46
|
-
architectState={architectState ?? undefined}
|
|
47
|
-
subscriptionResolved={subscriptionResolved}
|
|
48
|
-
parentLabel={session?.cwd}
|
|
49
|
-
onBack={onBack}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FlowArchitectPopoutPage — fullscreen route content for
|
|
3
|
-
* `/session/:sid/architect`.
|
|
4
|
-
*
|
|
5
|
-
* Mounts `FlowArchitectDetail` in popout mode plus a chrome header.
|
|
6
|
-
* Graceful empty-state ladder mirrors `FlowAgentPopoutPage`:
|
|
7
|
-
* 1. Subscription not yet resolved → "Loading parent session…"
|
|
8
|
-
* 2. Parent session not found → close-tab CTA
|
|
9
|
-
* 3. No architect active → "No architect active"
|
|
10
|
-
* 4. Resolved → FlowArchitectDetail render
|
|
11
|
-
*
|
|
12
|
-
* See change: fix-flows-plugin-polish (A4).
|
|
13
|
-
*/
|
|
14
|
-
import React, { useEffect } from "react";
|
|
15
|
-
import { Icon } from "@mdi/react";
|
|
16
|
-
import { mdiArrowLeft, mdiClose } from "@mdi/js";
|
|
17
|
-
import type { ArchitectState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
18
|
-
import { FlowArchitectDetail } from "./FlowArchitect.js";
|
|
19
|
-
|
|
20
|
-
export interface FlowArchitectPopoutPageProps {
|
|
21
|
-
sessionId: string;
|
|
22
|
-
/** The resolved architect state (or undefined if not yet subscribed / not active). */
|
|
23
|
-
architectState: ArchitectState | undefined;
|
|
24
|
-
/** True once the parent session's subscription has resolved. */
|
|
25
|
-
subscriptionResolved: boolean;
|
|
26
|
-
/** Optional parent-session display label (e.g. cwd) for the breadcrumb. */
|
|
27
|
-
parentLabel?: string;
|
|
28
|
-
onBack?: () => void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function FlowArchitectPopoutPage({
|
|
32
|
-
sessionId,
|
|
33
|
-
architectState,
|
|
34
|
-
subscriptionResolved,
|
|
35
|
-
parentLabel,
|
|
36
|
-
onBack,
|
|
37
|
-
}: FlowArchitectPopoutPageProps) {
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
document.title = `Flow Architect · ${parentLabel ?? sessionId} · pi`;
|
|
40
|
-
return () => {
|
|
41
|
-
document.title = "pi";
|
|
42
|
-
};
|
|
43
|
-
}, [parentLabel, sessionId]);
|
|
44
|
-
|
|
45
|
-
// (1) Loading
|
|
46
|
-
if (!subscriptionResolved) {
|
|
47
|
-
return (
|
|
48
|
-
<div
|
|
49
|
-
data-testid="flow-architect-popout-loading"
|
|
50
|
-
className="flex flex-col h-full items-center justify-center text-sm text-[var(--text-muted)] gap-2"
|
|
51
|
-
>
|
|
52
|
-
<div>Loading parent session…</div>
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// (2) Parent session not found (cannot derive parentLabel and architect is
|
|
58
|
-
// absent — best heuristic available since the runtime DashboardSession is
|
|
59
|
-
// not threaded down).
|
|
60
|
-
if (!parentLabel && !architectState) {
|
|
61
|
-
return (
|
|
62
|
-
<div
|
|
63
|
-
data-testid="flow-architect-popout-no-session"
|
|
64
|
-
className="flex flex-col h-full items-center justify-center text-sm text-[var(--text-muted)] gap-3 px-6 text-center"
|
|
65
|
-
>
|
|
66
|
-
<div className="text-base text-[var(--text-primary)]">Parent session not found</div>
|
|
67
|
-
<div className="max-w-md">
|
|
68
|
-
It may have been archived or deleted. Close this tab — the session
|
|
69
|
-
this architect was launched from is no longer available.
|
|
70
|
-
</div>
|
|
71
|
-
<button
|
|
72
|
-
onClick={() => window.close()}
|
|
73
|
-
className="text-xs text-[var(--text-tertiary)] hover:text-[var(--text-primary)] inline-flex items-center gap-1 mt-2 px-3 py-1 border border-[var(--border-primary)] rounded"
|
|
74
|
-
>
|
|
75
|
-
<Icon path={mdiClose} size={0.5} /> Close tab
|
|
76
|
-
</button>
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// (3) No architect active
|
|
82
|
-
if (!architectState) {
|
|
83
|
-
return (
|
|
84
|
-
<div data-testid="flow-architect-popout-no-architect" className="flex flex-col h-full overflow-hidden">
|
|
85
|
-
<div className="px-3 py-2 border-b border-[var(--border-subtle)] bg-[var(--bg-secondary)] flex items-center gap-2 flex-shrink-0">
|
|
86
|
-
{onBack && (
|
|
87
|
-
<button
|
|
88
|
-
onClick={onBack}
|
|
89
|
-
className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors"
|
|
90
|
-
title="Back"
|
|
91
|
-
>
|
|
92
|
-
<Icon path={mdiArrowLeft} size={0.7} />
|
|
93
|
-
</button>
|
|
94
|
-
)}
|
|
95
|
-
<span className="text-sm text-[var(--text-primary)]">
|
|
96
|
-
Flow Architect · {parentLabel ?? sessionId}
|
|
97
|
-
</span>
|
|
98
|
-
</div>
|
|
99
|
-
<div className="flex-1 flex items-center justify-center text-sm text-[var(--text-muted)] px-6 text-center">
|
|
100
|
-
No architect active on this session.
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// (4) Found
|
|
107
|
-
return (
|
|
108
|
-
<div data-testid="flow-architect-popout" className="flex flex-col h-full overflow-hidden">
|
|
109
|
-
<div className="px-3 py-2 border-b border-[var(--border-primary)] bg-[var(--bg-primary)] flex items-center gap-2 flex-shrink-0">
|
|
110
|
-
{onBack && (
|
|
111
|
-
<button
|
|
112
|
-
onClick={onBack}
|
|
113
|
-
className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors"
|
|
114
|
-
title="Back"
|
|
115
|
-
>
|
|
116
|
-
<Icon path={mdiArrowLeft} size={0.7} />
|
|
117
|
-
</button>
|
|
118
|
-
)}
|
|
119
|
-
<span className="text-[11px] text-[var(--text-tertiary)] truncate flex-shrink-0">
|
|
120
|
-
{parentLabel ?? sessionId} ›
|
|
121
|
-
</span>
|
|
122
|
-
<span className="text-sm font-medium text-[var(--text-primary)] truncate flex-1 min-w-0">
|
|
123
|
-
Flow Architect
|
|
124
|
-
</span>
|
|
125
|
-
</div>
|
|
126
|
-
{/* `min-h-0` required so body scrolls instead of overflowing.
|
|
127
|
-
See change: fix-flows-plugin-polish (scrollbar fix). */}
|
|
128
|
-
<div className="flex-1 min-h-0 overflow-hidden">
|
|
129
|
-
<FlowArchitectDetail state={architectState} sessionId={sessionId} />
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
);
|
|
133
|
-
}
|
package/src/client/popout-url.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure helper for building `shell-overlay-route` popout URLs.
|
|
3
|
-
*
|
|
4
|
-
* Encodes every variable segment via `encodeURIComponent`, resolves the
|
|
5
|
-
* URL against `window.location.origin` so `window.open` receives a
|
|
6
|
-
* fully-qualified URL (some browsers/configurations fall back to
|
|
7
|
-
* `about:blank` when handed a path-only string).
|
|
8
|
-
*
|
|
9
|
-
* Console-warns when any segment is empty, so devs see a hint when an
|
|
10
|
-
* agent or flow id is undefined.
|
|
11
|
-
*
|
|
12
|
-
* See change: fix-flows-plugin-polish (A3).
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export function buildPopoutUrl(path: string, origin: string = ""): string {
|
|
16
|
-
// `new URL` requires a base when path is relative. Fall back to
|
|
17
|
-
// `window.location.origin` if available (browser context). For tests
|
|
18
|
-
// and SSR (no window) we pass through the path as-is.
|
|
19
|
-
const base = origin || (typeof window !== "undefined" ? window.location.origin : "");
|
|
20
|
-
if (!base) return path;
|
|
21
|
-
try {
|
|
22
|
-
return new URL(path, base).toString();
|
|
23
|
-
} catch {
|
|
24
|
-
return path;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function buildFlowAgentPopoutUrl(
|
|
29
|
-
sessionId: string | null | undefined,
|
|
30
|
-
flowId: string | null | undefined,
|
|
31
|
-
stepId: string | null | undefined,
|
|
32
|
-
): string | null {
|
|
33
|
-
if (!sessionId || !flowId || !stepId) {
|
|
34
|
-
if (typeof console !== "undefined") {
|
|
35
|
-
console.warn(
|
|
36
|
-
"[flows-plugin] buildFlowAgentPopoutUrl: missing identifier",
|
|
37
|
-
{ sessionId, flowId, stepId },
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
const path = `/session/${encodeURIComponent(sessionId)}/flow/${encodeURIComponent(flowId)}/agent/${encodeURIComponent(stepId)}`;
|
|
43
|
-
return buildPopoutUrl(path);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function buildFlowArchitectPopoutUrl(
|
|
47
|
-
sessionId: string | null | undefined,
|
|
48
|
-
): string | null {
|
|
49
|
-
if (!sessionId) {
|
|
50
|
-
if (typeof console !== "undefined") {
|
|
51
|
-
console.warn(
|
|
52
|
-
"[flows-plugin] buildFlowArchitectPopoutUrl: missing sessionId",
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
const path = `/session/${encodeURIComponent(sessionId)}/architect`;
|
|
58
|
-
return buildPopoutUrl(path);
|
|
59
|
-
}
|