reactbridge-sdk 0.2.2 → 0.2.4

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,6 +10,7 @@ A flexible React SDK for building intelligent conversational interfaces with LLM
10
10
  🤖 **Intelligent Context** - Automatic context diffing and injection
11
11
  ⚡ **Two-Step Orchestration** - Seamless action execution and feedback loop
12
12
  📦 **TypeScript First** - Full type safety and IntelliSense support
13
+ 📈 **Analytics Admin UI** - Widgets, reports, and dashboards for AI-generated insights
13
14
 
14
15
  ## Installation
15
16
 
@@ -187,6 +188,83 @@ function CustomChat() {
187
188
  }
188
189
  ```
189
190
 
191
+ ## Analytics Suite
192
+
193
+ The SDK ships with DirectivSys analytics components for visualizing AI-generated metrics, observations, and directives and for executing recommended actions.
194
+
195
+ ### Components
196
+
197
+ - `AnalyticsWidget` — Floating entry point that opens a drawer of analytics configs; best for adding analytics everywhere in your admin UI.
198
+ - `AnalyticsReport` — Full report view for a single `analyticsType` (metrics, observations, directives) with optional back/close controls.
199
+ - `AnalyticsDashboard` — Full-width dashboard that lists all analytics configs on the left and shows the selected report on the right. Supports manual refresh, optional `autoRefreshInterval`, and directive status filtering.
200
+
201
+ ```tsx
202
+ import {
203
+ ReactBridgeProvider,
204
+ AnalyticsWidget,
205
+ AnalyticsReport,
206
+ AnalyticsDashboard,
207
+ } from 'reactbridge-sdk';
208
+
209
+ const handleDirectiveAction = async (directive, action) => {
210
+ if (action === 'decline') return { success: true };
211
+
212
+ // Execute the directive in your system
213
+ const result = await api.executeDirective(directive);
214
+ return { success: result.ok, error: result.error };
215
+ };
216
+
217
+ function Admin() {
218
+ return (
219
+ <ReactBridgeProvider apiKey="your-api-key">
220
+ <AnalyticsWidget onDirectiveAction={handleDirectiveAction} />
221
+
222
+ <AnalyticsReport
223
+ analyticsType="InventoryHealth"
224
+ onDirectiveAction={handleDirectiveAction}
225
+ />
226
+
227
+ <AnalyticsDashboard
228
+ onDirectiveAction={handleDirectiveAction}
229
+ autoRefreshInterval={300}
230
+ />
231
+ </ReactBridgeProvider>
232
+ );
233
+ }
234
+ ```
235
+
236
+ **Directive actions:** The callback receives the directive plus the requested action (`execute` or `decline`) and should return `{ success: boolean, error?: string }`. On success, directive status becomes `executed`; failures become `failed`; declines become `declined`. Directive statuses are `proposed`, `executed`, `declined`, and `failed`. Priorities are numeric (higher = more urgent).
237
+
238
+ ### Analytics Hooks
239
+
240
+ - `useAnalyticsConfigs()` — Fetches all analytics configs (`configs`, `isLoading`, `error`, `refetch`).
241
+ - `useAnalyticsResult(analyticsType)` — Fetches the latest result for a given analytics type (`result`, `isLoading`, `error`, `refetch`).
242
+ - `useDirectiveAction(onDirectiveAction?)` — Wraps your handler, updates directive status in the backend, and exposes `handleAction`, `isProcessing`, and `error`.
243
+
244
+ ```tsx
245
+ import { useAnalyticsConfigs, useAnalyticsResult, useDirectiveAction } from 'reactbridge-sdk';
246
+
247
+ const { configs } = useAnalyticsConfigs();
248
+ const { result, refetch } = useAnalyticsResult('InventoryHealth');
249
+ const { handleAction, isProcessing } = useDirectiveAction(handleDirectiveAction);
250
+ ```
251
+
252
+ ### Analytics API Client
253
+
254
+ ```tsx
255
+ import { AnalyticsAPI } from 'reactbridge-sdk';
256
+
257
+ const api = new AnalyticsAPI({ apiKey: 'your-api-key' });
258
+ const configs = await api.getConfigs();
259
+ const result = await api.getLatestResult('InventoryHealth');
260
+ await api.updateDirectiveStatus(directiveId, 'executed');
261
+ ```
262
+
263
+ ### More Docs
264
+
265
+ - Detailed components and hooks: [ANALYTICS_README.md](ANALYTICS_README.md)
266
+ - Full dashboard guide: [ANALYTICS_DASHBOARD_README.md](ANALYTICS_DASHBOARD_README.md)
267
+
190
268
  ## Voice Input/Output
191
269
 
192
270
  The SDK supports voice input (Speech-to-Text) and voice output (Text-to-Speech) for a fully conversational experience.
@@ -1,11 +1,12 @@
1
- import React from 'react';
2
- import type { DirectiveActionCallback } from '../../types/analytics';
3
- import './AnalyticsDashboard.css';
1
+ import React from "react";
2
+ import type { DirectiveActionCallback } from "../../types/analytics";
3
+ import type { Theme } from "../../types";
4
4
  export interface AnalyticsDashboardProps {
5
5
  onDirectiveAction: DirectiveActionCallback;
6
6
  className?: string;
7
7
  showRefresh?: boolean;
8
8
  autoRefreshInterval?: number;
9
+ theme?: Theme;
9
10
  }
10
- export declare function AnalyticsDashboard({ onDirectiveAction, className, showRefresh, autoRefreshInterval, }: AnalyticsDashboardProps): React.JSX.Element;
11
+ export declare function AnalyticsDashboard({ onDirectiveAction, className, showRefresh, autoRefreshInterval, theme: customTheme, }: AnalyticsDashboardProps): React.JSX.Element;
11
12
  //# sourceMappingURL=AnalyticsDashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsDashboard.d.ts","sourceRoot":"","sources":["../../../src/components/analytics/AnalyticsDashboard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,0BAA0B,CAAC;AAElC,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,kBAAkB,CAAC,EACjC,iBAAiB,EACjB,SAAc,EACd,WAAkB,EAClB,mBAAuB,GACxB,EAAE,uBAAuB,qBAwTzB"}
1
+ {"version":3,"file":"AnalyticsDashboard.d.ts","sourceRoot":"","sources":["../../../src/components/analytics/AnalyticsDashboard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,wBAAgB,kBAAkB,CAAC,EACjC,iBAAiB,EACjB,SAAc,EACd,WAAkB,EAClB,mBAAuB,EACvB,KAAK,EAAE,WAAW,GACnB,EAAE,uBAAuB,qBA+vBzB"}