@agentified/react 0.0.3 → 0.0.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 +125 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# @agentified/react
|
|
2
|
+
|
|
3
|
+
React bindings for [Agentified](../../README.md) — Provider, hooks, and a built-in Inspector debug panel.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @agentified/react @agentified/fe-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Peer dependencies:** `react >= 18`
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { AgentifiedProvider, useAgentified, useAgentifiedTool, Inspector } from "@agentified/react";
|
|
17
|
+
|
|
18
|
+
function App() {
|
|
19
|
+
return (
|
|
20
|
+
<AgentifiedProvider agentUrl="http://localhost:3003/api/chat">
|
|
21
|
+
<Chat />
|
|
22
|
+
<Inspector defaultOpen />
|
|
23
|
+
</AgentifiedProvider>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function Chat() {
|
|
28
|
+
const { messages, sendMessage, isLoading } = useAgentified();
|
|
29
|
+
|
|
30
|
+
useAgentifiedTool("navigate_to_page", async (args) => {
|
|
31
|
+
window.location.href = args.path;
|
|
32
|
+
return { success: true };
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
{messages.map((m, i) => <p key={i}><b>{m.role}:</b> {m.content}</p>)}
|
|
38
|
+
<button onClick={() => sendMessage("Hello!")} disabled={isLoading}>
|
|
39
|
+
Send
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API Reference
|
|
47
|
+
|
|
48
|
+
### `<AgentifiedProvider>`
|
|
49
|
+
|
|
50
|
+
Wraps your app and provides the Agentified client context.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
interface AgentifiedProviderProps {
|
|
54
|
+
agentUrl: string; // AG-UI agent backend URL
|
|
55
|
+
headers?: Record<string, string>; // custom HTTP headers
|
|
56
|
+
children: React.ReactNode;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
<AgentifiedProvider agentUrl="http://localhost:3003/api/chat">
|
|
60
|
+
{children}
|
|
61
|
+
</AgentifiedProvider>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### `useAgentified()`
|
|
65
|
+
|
|
66
|
+
Main hook — returns messages, actions, and state.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const {
|
|
70
|
+
state, // InspectorState — full client state
|
|
71
|
+
messages, // Message[] — conversation history
|
|
72
|
+
sendMessage, // (content: string) => Promise<void>
|
|
73
|
+
isLoading, // boolean
|
|
74
|
+
error, // string | null
|
|
75
|
+
reset, // () => void — clear all state
|
|
76
|
+
} = useAgentified();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### `useAgentifiedTool(name, handler)`
|
|
80
|
+
|
|
81
|
+
Registers a frontend tool handler. Automatically unregisters on unmount.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
useAgentifiedTool("open_modal", async (args) => {
|
|
85
|
+
setModalOpen(args.id);
|
|
86
|
+
return { opened: true };
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `useAgentifiedClient()`
|
|
91
|
+
|
|
92
|
+
Returns the raw `AgentifiedClient` instance for advanced use cases.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const client = useAgentifiedClient();
|
|
96
|
+
client.setSharedContext({ page: "/dashboard", openModals: [] });
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### `<Inspector>`
|
|
100
|
+
|
|
101
|
+
Floating debug panel with three tabs: **Timeline**, **Session**, and **Log**.
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
interface InspectorProps {
|
|
105
|
+
defaultOpen?: boolean; // default: false
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
<Inspector defaultOpen />
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Timeline tab** — run status, interaction timeline (prefetch, discover, tool calls, messages), active tools, frontend tools, shared context.
|
|
112
|
+
|
|
113
|
+
**Session tab** — metrics grid (messages, tool calls, TTFT, duration, tokens), token breakdown, prefetch/discovery history.
|
|
114
|
+
|
|
115
|
+
**Log tab** — filterable event log (all / agentified / tool_calls / messages) with expandable event details.
|
|
116
|
+
|
|
117
|
+
The Inspector is draggable and resizable.
|
|
118
|
+
|
|
119
|
+
## Links
|
|
120
|
+
|
|
121
|
+
- [Root README](../../../README.md)
|
|
122
|
+
- [Frontend Client](../fe-client/README.md) — underlying client library
|
|
123
|
+
- [TypeScript SDK](../sdk/README.md)
|
|
124
|
+
- [Mastra Adapter](../mastra/README.md)
|
|
125
|
+
- [QuickHR Example](../../../examples/quickhr/) — full-stack app using all React bindings
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentified/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react": ">=18.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agentified/fe-client": "0.0.
|
|
28
|
+
"@agentified/fe-client": "0.0.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@testing-library/react": "^16.0.0",
|