@principal-ai/subsystems-react 0.39.0 → 0.41.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 (35) hide show
  1. package/dist/components/maintain-events/MaintainEventLog.d.ts +35 -0
  2. package/dist/components/maintain-events/MaintainEventLog.d.ts.map +1 -0
  3. package/dist/components/maintain-events/MaintainEventLog.js +66 -0
  4. package/dist/components/maintain-events/MaintainEventLog.js.map +1 -0
  5. package/dist/components/maintain-events/MaintainLivePanel.d.ts +15 -0
  6. package/dist/components/maintain-events/MaintainLivePanel.d.ts.map +1 -0
  7. package/dist/components/maintain-events/MaintainLivePanel.js +49 -0
  8. package/dist/components/maintain-events/MaintainLivePanel.js.map +1 -0
  9. package/dist/components/maintain-events/index.d.ts +8 -0
  10. package/dist/components/maintain-events/index.d.ts.map +1 -0
  11. package/dist/components/maintain-events/index.js +6 -0
  12. package/dist/components/maintain-events/index.js.map +1 -0
  13. package/dist/index.d.ts +4 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +4 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/subsystem/AgentsPanel.d.ts +27 -0
  18. package/dist/subsystem/AgentsPanel.d.ts.map +1 -0
  19. package/dist/subsystem/AgentsPanel.js +66 -0
  20. package/dist/subsystem/AgentsPanel.js.map +1 -0
  21. package/dist/subsystem/SubsystemComponentGraph.d.ts +13 -0
  22. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  23. package/dist/subsystem/SubsystemComponentGraph.js +25 -3
  24. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/components/maintain-events/MaintainEventLog.tsx +152 -0
  27. package/src/components/maintain-events/MaintainLivePanel.tsx +99 -0
  28. package/src/components/maintain-events/index.ts +10 -0
  29. package/src/index.ts +15 -0
  30. package/src/stories/MaintainEvents/MaintainEventLog.stories.tsx +66 -0
  31. package/src/stories/MaintainEvents/MaintainLivePanel.stories.tsx +77 -0
  32. package/src/stories/Subsystem/AgentsPanel.stories.tsx +61 -0
  33. package/src/stories/data/maintain-live-events.json +554 -0
  34. package/src/subsystem/AgentsPanel.tsx +140 -0
  35. package/src/subsystem/SubsystemComponentGraph.tsx +87 -10
@@ -0,0 +1,99 @@
1
+ /**
2
+ * MaintainLivePanel — a collapsible, half-height panel that overlays the graph
3
+ * canvas and streams a live agent run's events. Subsystems Studio supplies the
4
+ * state (status/events/total/error) and renders it through
5
+ * `SubsystemComponentGraph`'s `liveEvents` prop; collapsing leaves just the
6
+ * header bar so the graph stays readable.
7
+ */
8
+
9
+ import { useState } from 'react';
10
+ import { useTheme } from '@principal-ade/industry-theme';
11
+ import { ChevronDown, ChevronUp } from 'lucide-react';
12
+ import { MaintainEventLog, type MaintainEventLogProps } from './MaintainEventLog';
13
+
14
+ export interface MaintainLivePanelProps extends MaintainEventLogProps {
15
+ /** Start collapsed (header only). @default false */
16
+ defaultCollapsed?: boolean;
17
+ }
18
+
19
+ const HEADER_HEIGHT = 36;
20
+
21
+ export function MaintainLivePanel({
22
+ title,
23
+ agent,
24
+ sessionId,
25
+ status,
26
+ events,
27
+ total,
28
+ error,
29
+ defaultCollapsed = false,
30
+ }: MaintainLivePanelProps) {
31
+ const { theme } = useTheme();
32
+ const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
33
+ const border = theme.colors.border ?? 'rgba(255,255,255,0.12)';
34
+ const [collapsed, setCollapsed] = useState(defaultCollapsed);
35
+
36
+ return (
37
+ <div
38
+ style={{
39
+ position: 'absolute',
40
+ left: 0,
41
+ right: 0,
42
+ bottom: 0,
43
+ height: collapsed ? HEADER_HEIGHT : '50%',
44
+ zIndex: 5,
45
+ display: 'flex',
46
+ flexDirection: 'column',
47
+ background: theme.colors.backgroundSecondary ?? theme.colors.background,
48
+ borderTop: `1px solid ${border}`,
49
+ boxShadow: '0 -8px 24px rgba(0,0,0,0.35)',
50
+ overflow: 'hidden',
51
+ }}
52
+ >
53
+ <button
54
+ type="button"
55
+ onClick={() => setCollapsed((c) => !c)}
56
+ style={{
57
+ display: 'flex',
58
+ alignItems: 'center',
59
+ gap: 8,
60
+ height: HEADER_HEIGHT,
61
+ flexShrink: 0,
62
+ padding: '0 12px',
63
+ border: 'none',
64
+ borderBottom: collapsed ? 'none' : `1px solid ${border}`,
65
+ background: 'transparent',
66
+ color: theme.colors.text,
67
+ fontFamily: theme.fonts.body,
68
+ fontSize: theme.fontSizes[0],
69
+ cursor: 'pointer',
70
+ textAlign: 'left',
71
+ }}
72
+ >
73
+ {collapsed ? <ChevronUp size={14} /> : <ChevronDown size={14} />}
74
+ <span style={{ fontWeight: 600 }}>Live events</span>
75
+ {agent ? <span style={{ color: muted }}>{agent}</span> : null}
76
+ {status ? <span style={{ color: muted }}>· {status}</span> : null}
77
+ {total > 0 ? <span style={{ color: muted }}>· {total} events</span> : null}
78
+ <span style={{ flex: 1 }} />
79
+ {sessionId ? (
80
+ <span style={{ color: muted, fontFamily: theme.fonts.monospace }}>{sessionId}</span>
81
+ ) : null}
82
+ </button>
83
+ {!collapsed ? (
84
+ <div style={{ flex: 1, minHeight: 0 }}>
85
+ <MaintainEventLog
86
+ title={title}
87
+ agent={agent}
88
+ sessionId={sessionId}
89
+ status={status}
90
+ events={events}
91
+ total={total}
92
+ error={error}
93
+ showHeader={false}
94
+ />
95
+ </div>
96
+ ) : null}
97
+ </div>
98
+ );
99
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Maintain event log — presentational live OpenCode agent-run event feed.
3
+ */
4
+ export { MaintainEventLog } from './MaintainEventLog';
5
+ export type {
6
+ MaintainEventLogEvent,
7
+ MaintainEventLogProps,
8
+ } from './MaintainEventLog';
9
+ export { MaintainLivePanel } from './MaintainLivePanel';
10
+ export type { MaintainLivePanelProps } from './MaintainLivePanel';
package/src/index.ts CHANGED
@@ -16,6 +16,14 @@ export type {
16
16
  SessionEventFeedRow,
17
17
  } from './components/session-events';
18
18
 
19
+ // Maintain event log — presentational live OpenCode agent-run event feed
20
+ export { MaintainEventLog, MaintainLivePanel } from './components/maintain-events';
21
+ export type {
22
+ MaintainEventLogEvent,
23
+ MaintainEventLogProps,
24
+ MaintainLivePanelProps,
25
+ } from './components/maintain-events';
26
+
19
27
  // Graphify integration types (graph.json data model)
20
28
  export type {
21
29
  JsonValue,
@@ -158,6 +166,13 @@ export type {
158
166
  SubsystemIssueCardProps,
159
167
  SubsystemIssueListProps,
160
168
  } from './subsystem/IssueList';
169
+
170
+ // Maintain agent pipeline panel (graph sidebar diagnostics → Agents tab)
171
+ export { SubsystemAgentsPanel } from './subsystem/AgentsPanel';
172
+ export type {
173
+ SubsystemAgent,
174
+ SubsystemAgentsPanelProps,
175
+ } from './subsystem/AgentsPanel';
161
176
  export {
162
177
  MECHANISM_COLOR,
163
178
  MECHANISM_STYLE,
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Maintain Event Log — presentational live agent-run event feed.
3
+ *
4
+ * The `Live` story replays a fixture derived from a real OpenCode V2 agent
5
+ * session (`packages/subsystems-core/src/opencode/__fixtures__/session-events.json`),
6
+ * mapped to the live-feed vocabulary (`session.next.*` / `session.status`) and
7
+ * summarized the same way the host's `/api/event` subscription is
8
+ * (`summarizeEvent` in `subsystems-studio/src/bun/opencode-v2-live.ts`).
9
+ */
10
+ import React from 'react';
11
+ import type { Meta, StoryObj } from '@storybook/react';
12
+ import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
13
+ import {
14
+ MaintainEventLog,
15
+ type MaintainEventLogEvent,
16
+ } from '../../components/maintain-events';
17
+ import liveEvents from '../data/maintain-live-events.json';
18
+
19
+ const events = liveEvents as MaintainEventLogEvent[];
20
+
21
+ const meta = {
22
+ title: 'Agent Sessions/Maintain Event Log',
23
+ component: MaintainEventLog,
24
+ parameters: { layout: 'fullscreen' },
25
+ tags: ['autodocs'],
26
+ decorators: [
27
+ (Story) => (
28
+ <ThemeProvider theme={defaultEditorTheme}>
29
+ <div
30
+ style={{
31
+ height: '100vh',
32
+ background: defaultEditorTheme.colors.background,
33
+ color: defaultEditorTheme.colors.text,
34
+ }}
35
+ >
36
+ <Story />
37
+ </div>
38
+ </ThemeProvider>
39
+ ),
40
+ ],
41
+ args: {
42
+ title: 'Maintain events',
43
+ agent: 'construct-verifier',
44
+ sessionId: 'ses_056b1f037ffeu1d00DzvJBrHq9',
45
+ status: 'running',
46
+ events,
47
+ total: events.length,
48
+ },
49
+ } satisfies Meta<typeof MaintainEventLog>;
50
+
51
+ export default meta;
52
+ type Story = StoryObj<typeof meta>;
53
+
54
+ export const Live: Story = {};
55
+
56
+ export const WaitingForSession: Story = {
57
+ args: { sessionId: undefined, events: [], total: 0, status: 'starting' },
58
+ };
59
+
60
+ export const WaitingForEvents: Story = {
61
+ args: { events: [], total: 0 },
62
+ };
63
+
64
+ export const WithError: Story = {
65
+ args: { error: 'live event stream dropped — reconnecting and reconciling with server state' },
66
+ };
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Maintain Live Panel — the collapsible half-height live-agent-run panel that
3
+ * `SubsystemComponentGraph` renders over its canvas via the `liveEvents` prop.
4
+ *
5
+ * The fixture replays a real OpenCode V2 agent session
6
+ * (`packages/subsystems-core/src/opencode/__fixtures__/session-events.json`),
7
+ * mapped to the live-feed vocabulary and summarized like the host's
8
+ * `/api/event` subscription.
9
+ */
10
+ import React from 'react';
11
+ import type { Meta, StoryObj } from '@storybook/react';
12
+ import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
13
+ import {
14
+ MaintainLivePanel,
15
+ type MaintainEventLogEvent,
16
+ } from '../../components/maintain-events';
17
+ import liveEvents from '../data/maintain-live-events.json';
18
+
19
+ const events = liveEvents as MaintainEventLogEvent[];
20
+
21
+ const meta = {
22
+ title: 'Agent Sessions/Maintain Live Panel',
23
+ component: MaintainLivePanel,
24
+ parameters: { layout: 'fullscreen' },
25
+ tags: ['autodocs'],
26
+ decorators: [
27
+ (Story) => (
28
+ <ThemeProvider theme={defaultEditorTheme}>
29
+ <div
30
+ style={{
31
+ position: 'relative',
32
+ height: '100vh',
33
+ overflow: 'hidden',
34
+ background: defaultEditorTheme.colors.background,
35
+ color: defaultEditorTheme.colors.text,
36
+ }}
37
+ >
38
+ <div
39
+ style={{
40
+ position: 'absolute',
41
+ inset: 0,
42
+ display: 'grid',
43
+ placeItems: 'center',
44
+ color: defaultEditorTheme.colors.textMuted,
45
+ fontFamily: defaultEditorTheme.fonts.monospace,
46
+ fontSize: 13,
47
+ }}
48
+ >
49
+ graph canvas
50
+ </div>
51
+ <Story />
52
+ </div>
53
+ </ThemeProvider>
54
+ ),
55
+ ],
56
+ args: {
57
+ title: 'Maintain events',
58
+ agent: 'construct-verifier',
59
+ sessionId: 'ses_056b1f037ffeu1d00DzvJBrHq9',
60
+ status: 'running',
61
+ events,
62
+ total: events.length,
63
+ },
64
+ } satisfies Meta<typeof MaintainLivePanel>;
65
+
66
+ export default meta;
67
+ type Story = StoryObj<typeof meta>;
68
+
69
+ export const Expanded: Story = {};
70
+
71
+ export const Collapsed: Story = {
72
+ args: { defaultCollapsed: true },
73
+ };
74
+
75
+ export const WaitingForEvents: Story = {
76
+ args: { events: [], total: 0 },
77
+ };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Agents Panel — the graph sidebar's Agents view: the Maintain pipeline with
3
+ * the router's next stage runnable. The host supplies the rows and the pick.
4
+ */
5
+ import React from 'react';
6
+ import type { Meta, StoryObj } from '@storybook/react';
7
+ import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
8
+ import { SubsystemAgentsPanel, type SubsystemAgent } from '../../subsystem/AgentsPanel';
9
+
10
+ const AGENTS: SubsystemAgent[] = [
11
+ { id: 'construct-fixer', label: 'construct-fixer', lane: 'construct', mode: 'issues' },
12
+ { id: 'static-topology-fixer', label: 'static-topology-fixer', lane: 'static-topology', mode: 'issues' },
13
+ { id: 'package-module-fixer', label: 'package-module-fixer', lane: 'dynamic-topology', mode: 'issues' },
14
+ { id: 'construct-verifier', label: 'construct-verifier', lane: 'construct', mode: 'verify' },
15
+ { id: 'static-topology-verifier', label: 'static-topology-verifier', lane: 'static-topology', mode: 'verify' },
16
+ { id: 'package-module-verifier', label: 'package-module-verifier', lane: 'dynamic-topology', mode: 'verify' },
17
+ { id: 'runtime-topology-verifier', label: 'runtime-topology-verifier', lane: 'dynamic-topology', mode: 'verify' },
18
+ ];
19
+
20
+ const meta = {
21
+ title: 'Subsystem/Agents Panel',
22
+ component: SubsystemAgentsPanel,
23
+ parameters: { layout: 'fullscreen' },
24
+ tags: ['autodocs'],
25
+ decorators: [
26
+ (Story) => (
27
+ <ThemeProvider theme={defaultEditorTheme}>
28
+ <div
29
+ style={{
30
+ height: '60vh',
31
+ display: 'flex',
32
+ flexDirection: 'column',
33
+ background: defaultEditorTheme.colors.background,
34
+ color: defaultEditorTheme.colors.text,
35
+ }}
36
+ >
37
+ <Story />
38
+ </div>
39
+ </ThemeProvider>
40
+ ),
41
+ ],
42
+ args: {
43
+ agents: AGENTS,
44
+ nextAgentId: 'static-topology-fixer',
45
+ running: false,
46
+ onRun: () => {},
47
+ },
48
+ } satisfies Meta<typeof SubsystemAgentsPanel>;
49
+
50
+ export default meta;
51
+ type Story = StoryObj<typeof meta>;
52
+
53
+ export const NextStageRunnable: Story = {};
54
+
55
+ export const Running: Story = {
56
+ args: { running: true },
57
+ };
58
+
59
+ export const FullyVerified: Story = {
60
+ args: { nextAgentId: null },
61
+ };