orcal-ui 0.2.1 → 0.4.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/README.md CHANGED
@@ -10,8 +10,7 @@ This library provides production-ready UI components for building and visualizin
10
10
 
11
11
  🔗 **[Live Demo](https://tay-global-ltd.github.io/orcal-ui/)**
12
12
 
13
-
14
- Check out the interactive demo to see the TeamBuilder component in action with a simulated multi-agent workflow.
13
+ Check out the interactive demo to see all components in action, including a simulated multi-agent workflow, knowledge graph explorer, decentralised agent pool, and dependency graph visualizer.
15
14
 
16
15
  ## Components
17
16
 
@@ -40,16 +39,43 @@ The TeamBuilder component is designed to **trigger events** rather than handle b
40
39
 
41
40
  **The actual handling of these events should be done by the owner of this component.** TeamBuilder is purely a UI component that emits events - it does not manage agents, persist data, or execute workflows.
42
41
 
43
- #### Demo
42
+ ### KnowledgeGraph
43
+
44
+ A tree-based knowledge visualization component with a radial layout for exploring hierarchical data.
45
+
46
+ #### Key Features
47
+
48
+ - **Radial Node Layout**: Expandable/collapsible nodes arranged in a radial tree
49
+ - **Pan & Zoom**: Navigate large knowledge trees with zoom controls and dragging
50
+ - **Sidebar Content Panel**: View selected node content with markdown rendering
51
+ - **Category Colors**: Optional color-coded categories with a legend
52
+ - **Reset View**: Snap back to the default viewport
53
+
54
+ ### DecentralisedTeam
55
+
56
+ Visualizes a decentralized pool of agents processing a shared task queue, as an alternative to the hierarchical TeamBuilder.
57
+
58
+ #### Key Features
44
59
 
45
- The included `index.html` demonstrates a **simulation button** that shows what the TeamBuilder would look like when used by a multi-agent LLM application. The simulation:
60
+ - **Task Queue Sidebar**: View pending, in-progress, and completed tasks with status badges
61
+ - **Agent Grid**: Visual layout of agents with animated activity indicators
62
+ - **Real-time Task Assignment**: Watch agents pick up and complete tasks
63
+ - **Show/Hide Completed**: Toggle visibility of completed tasks
46
64
 
47
- - Steps through a pre-defined workflow sequence
48
- - Highlights active agents
49
- - Displays markdown-formatted messages in speech bubbles
50
- - Shows parallel processing paths converging
65
+ ### NodeBrowser
51
66
 
52
- This is for demonstration purposes only - in a real application, you would connect the component events to your own agent management system.
67
+ An interactive dependency graph visualizer for exploring function call relationships within objects. Built on D3.js force simulation.
68
+
69
+ #### Key Features
70
+
71
+ - **Force-Directed Graph**: D3.js physics simulation for automatic node layout
72
+ - **Object Grouping**: Convex hull grouping of functions by parent object with color coding
73
+ - **Detail Panel**: View object details and click through to individual functions
74
+ - **Search**: Fuzzy search across all nodes with keyboard shortcut (`/`)
75
+ - **Path Finding**: Highlight the call path between any two nodes
76
+ - **Hover Info**: Overlay showing node details on hover
77
+ - **Zoom Controls**: Zoom in/out and home button to snap to root node
78
+ - **Collapsible Legend**: Object category legend panel
53
79
 
54
80
  ## Installation
55
81
 
@@ -91,15 +117,25 @@ This generates:
91
117
  .
92
118
  ├── src/
93
119
  │ ├── components/
94
- │ │ └── TeamBuilder.js # Main TeamBuilder component
95
- │ ├── index.js # Component exports
96
- └── tailwind.css # Tailwind styles
97
- ├── dist/ # Built assets (generated)
98
- ├── index.html # Demo page with simulation
99
- ├── rollup.config.mjs # Build configuration
100
- ├── tailwind.config.js # Tailwind configuration
101
- ├── postcss.config.js # PostCSS configuration
102
- └── package.json # Dependencies and scripts
120
+ │ │ ├── TeamBuilder.js # Hierarchical team graph editor
121
+ ├── KnowledgeGraph.js # Radial knowledge tree visualization
122
+ │ ├── DecentralisedTeam.js # Decentralized agent pool
123
+ │ │ ├── AgentNode.js # Individual agent node component
124
+ │ │ └── NodeBrowser/ # Dependency graph visualizer
125
+ │ │ ├── index.js # Main component
126
+ │ │ ├── hooks/ # useD3, useGraphData, useSearch, useSimulation
127
+ │ │ ├── interactions/ # D3 click/hover handlers
128
+ │ │ ├── ui/ # Header, Legend, DetailPanel, SearchModal, etc.
129
+ │ │ └── utils/ # Colors, labels, hull math, fuzzy search
130
+ │ ├── index.js # Component exports
131
+ │ └── tailwind.css # Tailwind styles
132
+ ├── dist/ # Built assets (generated)
133
+ ├── docs/ # GitHub Pages demo (generated)
134
+ ├── index.html # Demo page
135
+ ├── rollup.config.mjs # Build configuration
136
+ ├── tailwind.config.js # Tailwind configuration
137
+ ├── postcss.config.js # PostCSS configuration
138
+ └── package.json # Dependencies and scripts
103
139
  ```
104
140
 
105
141
  ## Usage Example
@@ -107,57 +143,119 @@ This generates:
107
143
  ```javascript
108
144
  import components from "./dist/orcal-ui.js";
109
145
 
110
- const { TeamBuilder } = components.v1;
111
-
112
- // Your component
113
- function MyApp() {
114
- const [teamData, setTeamData] = React.useState({
115
- nodes: [],
116
- edges: []
117
- });
118
-
119
- return (
120
- <TeamBuilder
121
- // Initial state
122
- initialNodes={teamData.nodes}
123
- initialEdges={teamData.edges}
124
- initialEditable={false}
125
-
126
- // Agent tree structure
127
- agentTree={{
128
- Shared: {
129
- "Content Creation": ["Writer", "Editor"],
130
- "Analysis": ["Analyzer", "Reviewer"]
131
- },
132
- Users: {
133
- "user_jdoe": ["Assistant", "Helper"]
134
- }
135
- }}
136
-
137
- // Event handlers (implement your own logic)
138
- handleSave={({ nodes, edges, rootNodeId }) => {
139
- // Save team structure to your backend
140
- console.log("Saving team:", nodes, edges, rootNodeId);
141
- }}
142
-
143
- handleViewAgent={({ agentPath }) => {
144
- // Navigate to agent details page
145
- console.log("View agent:", agentPath);
146
- }}
147
-
148
- handleEditAgent={({ agentPath }) => {
149
- // Open agent editor
150
- console.log("Edit agent:", agentPath);
151
- }}
152
-
153
- // Optional: Active agent tracking
154
- activeNode="Shared/Content Creation/Writer"
155
-
156
- // Optional: Display messages from active agent
157
- currentMessage="# Processing\nAnalyzing content..."
158
- />
159
- );
160
- }
146
+ const { TeamBuilder, KnowledgeGraph, DecentralisedTeam, NodeBrowser } = components.v1;
147
+ ```
148
+
149
+ ### TeamBuilder
150
+
151
+ ```jsx
152
+ <TeamBuilder
153
+ // Initial state
154
+ initialNodes={[]}
155
+ initialEdges={[]}
156
+ initialEditable={false}
157
+
158
+ // Agent tree structure
159
+ agentTree={{
160
+ Shared: {
161
+ "Content Creation": ["Writer", "Editor"],
162
+ "Analysis": ["Analyzer", "Reviewer"]
163
+ },
164
+ Users: {
165
+ "user_jdoe": ["Assistant", "Helper"]
166
+ }
167
+ }}
168
+
169
+ // Event handlers (implement your own logic)
170
+ handleSave={({ nodes, edges, rootNodeId }) => {
171
+ console.log("Saving team:", nodes, edges, rootNodeId);
172
+ }}
173
+ handleViewAgent={({ agentPath }) => {
174
+ console.log("View agent:", agentPath);
175
+ }}
176
+ handleEditAgent={({ agentPath }) => {
177
+ console.log("Edit agent:", agentPath);
178
+ }}
179
+
180
+ // Optional: Active agent tracking
181
+ activeNode="Shared/Content Creation/Writer"
182
+
183
+ // Optional: Display messages from active agent
184
+ currentMessage="# Processing\nAnalyzing content..."
185
+ />
186
+ ```
187
+
188
+ ### KnowledgeGraph
189
+
190
+ ```jsx
191
+ <KnowledgeGraph
192
+ title="Knowledge Explorer"
193
+ data={{
194
+ id: "root",
195
+ label: "Root Topic",
196
+ category: "root",
197
+ content: "Top-level overview.",
198
+ children: [
199
+ {
200
+ id: "child1",
201
+ label: "Subtopic",
202
+ category: "tech",
203
+ content: "Details about this subtopic.",
204
+ children: []
205
+ }
206
+ ]
207
+ }}
208
+ categoryColors={{
209
+ root: "#6366f1",
210
+ tech: "#3b82f6"
211
+ }}
212
+ />
213
+ ```
214
+
215
+ ### DecentralisedTeam
216
+
217
+ ```jsx
218
+ <DecentralisedTeam
219
+ teamName="Research Pool"
220
+ agents={[
221
+ { id: "a1", x: 100, y: 100, data: { agentPath: ["Shared", "Analysis", "Researcher"], colour: "#3b82f6" } }
222
+ ]}
223
+ taskQueue={[
224
+ { id: "t1", title: "Analyze dataset", status: "pending", assigneeId: null }
225
+ ]}
226
+ activeAgentId="a1"
227
+ onAgentUpdate={(agent) => console.log("Agent updated:", agent)}
228
+ onAgentView={(agent) => console.log("View agent:", agent)}
229
+ onTaskClick={(task) => console.log("Task clicked:", task)}
230
+ />
231
+ ```
232
+
233
+ ### NodeBrowser
234
+
235
+ ```jsx
236
+ <NodeBrowser
237
+ data={{
238
+ root: "myModule",
239
+ objects: [
240
+ { id: "obj1", label: "UserService", path: "api/services" }
241
+ ],
242
+ functions: [
243
+ { id: "fn1", label: "getUser", object: "obj1" }
244
+ ],
245
+ calls: [
246
+ { source: "fn1", target: "fn2" }
247
+ ]
248
+ }}
249
+ pathColors={{
250
+ "api": "#3b82f6",
251
+ "utils": "#10b981"
252
+ }}
253
+ onRefresh={() => console.log("Refresh graph")}
254
+ onNodeClick={(node) => {
255
+ console.log("Node clicked:", node);
256
+ return "## Details\nMore info about this node.";
257
+ }}
258
+ />
161
259
  ```
162
260
 
163
261
  ## Component Props
@@ -171,17 +269,50 @@ function MyApp() {
171
269
  | `initialEdges` | Array | `[]` | Initial connections between nodes |
172
270
  | `initialEditable` | Boolean | `false` | Start in edit mode |
173
271
  | `activeNode` | String | `null` | Path of currently active agent (e.g., "Shared/Content/Writer") |
174
- | `currentMessage` | String | `null` | Markdown message to display from active agent |
272
+ | `currentMessage` | String\|Object | `null` | Markdown message string, or `{ node, message }` object |
175
273
  | `handleSave` | Function | - | Called when saving: `({ nodes, edges, rootNodeId }) => {}` |
176
274
  | `handleViewAgent` | Function | - | Called when viewing: `({ agentPath }) => {}` |
177
275
  | `handleEditAgent` | Function | - | Called when editing: `({ agentPath }) => {}` |
178
276
 
277
+ ### KnowledgeGraph
278
+
279
+ | Prop | Type | Default | Description |
280
+ |------|------|---------|-------------|
281
+ | `data` | Object | - | Root node with `id`, `label`, `category`, `content`, `children` |
282
+ | `title` | String | `"Wikipedia LLM Explorer"` | Sidebar title |
283
+ | `categoryColors` | Object | Built-in colors | Map of category names to hex colors |
284
+
285
+ ### DecentralisedTeam
286
+
287
+ | Prop | Type | Default | Description |
288
+ |------|------|---------|-------------|
289
+ | `teamName` | String | - | Team display name |
290
+ | `agents` | Array | - | Agent objects with `id`, `x`, `y`, `data` |
291
+ | `taskQueue` | Array | - | Tasks with `id`, `title`, `status`, `assigneeId` |
292
+ | `agentTree` | Object | - | Optional hierarchical agent structure |
293
+ | `activeAgentId` | String | `null` | Currently active agent ID |
294
+ | `onAgentUpdate` | Function | - | Called when agent is updated |
295
+ | `onAgentView` | Function | - | Called when viewing an agent |
296
+ | `onTaskClick` | Function | - | Called when a task is clicked |
297
+
298
+ ### NodeBrowser
299
+
300
+ | Prop | Type | Default | Description |
301
+ |------|------|---------|-------------|
302
+ | `data` | Object | - | Graph data with `root`, `objects[]`, `functions[]`, `calls[]` |
303
+ | `pathColors` | Object | - | Map of root paths to hex colors |
304
+ | `onRefresh` | Function | - | Optional callback for regenerating the graph |
305
+ | `onNodeClick` | Function | - | Optional callback when a function node is clicked; can return markdown content |
306
+ | `specialLabels` | Object | - | Map of node IDs to `{ label, opacity }` for custom labels |
307
+
179
308
  ## Technology Stack
180
309
 
181
310
  - **React 18.2** - UI framework
311
+ - **D3.js** - Force simulation and graph visualization (dynamically loaded)
182
312
  - **Rollup** - Module bundler
183
313
  - **Tailwind CSS 4** - Utility-first CSS
184
314
  - **Lucide React** - Icon library
315
+ - **React Markdown** - Markdown rendering
185
316
  - **Babel** - JavaScript compiler
186
317
  - **PostCSS** - CSS processor
187
318
 
@@ -199,7 +330,7 @@ Components are exported under versioned namespaces:
199
330
 
200
331
  ```javascript
201
332
  import components from "./dist/orcal-ui.js";
202
- const { TeamBuilder } = components.v1;
333
+ const { TeamBuilder, KnowledgeGraph, DecentralisedTeam, NodeBrowser } = components.v1;
203
334
  ```
204
335
 
205
336
  This allows for future API changes while maintaining backward compatibility.