@agentuity/claude-code 1.0.59 → 2.0.0-beta.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
CHANGED
|
@@ -66,7 +66,7 @@ Overview and routing guide for all Agentuity SDK packages and cloud services. Us
|
|
|
66
66
|
|
|
67
67
|
### Use Frontend Skill when:
|
|
68
68
|
|
|
69
|
-
- Questions about `@agentuity/react` hooks (`
|
|
69
|
+
- Questions about `@agentuity/react` hooks (`useAuth`, `useWebRTCCall`)
|
|
70
70
|
- Questions about `@agentuity/auth` (server or client)
|
|
71
71
|
- Questions about `@agentuity/frontend` utilities
|
|
72
72
|
- Questions about `@agentuity/workbench`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agentuity-frontend
|
|
3
|
-
description: When working with Agentuity SDK frontend packages including @agentuity/react, @agentuity/frontend, @agentuity/auth, or @agentuity/workbench. Activates when building React components that call agents, setting up authentication, using
|
|
3
|
+
description: When working with Agentuity SDK frontend packages including @agentuity/react, @agentuity/frontend, @agentuity/auth, or @agentuity/workbench. Activates when building React components that call agents, setting up authentication, using WebRTC hooks, or integrating the workbench dev UI.
|
|
4
4
|
version: 1.0.0
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ Deep reference material for the Agentuity SDK frontend packages used to build we
|
|
|
12
12
|
|
|
13
13
|
| Package | Purpose |
|
|
14
14
|
| ---------------------- | ----------------------------------------------------- |
|
|
15
|
-
| `@agentuity/react` | React hooks for
|
|
15
|
+
| `@agentuity/react` | React hooks for context, auth, WebRTC, and analytics |
|
|
16
16
|
| `@agentuity/frontend` | Framework-agnostic web utilities |
|
|
17
17
|
| `@agentuity/auth` | Authentication (server + client) |
|
|
18
18
|
| `@agentuity/workbench` | Dev UI for testing agents |
|
|
@@ -48,100 +48,38 @@ function App() {
|
|
|
48
48
|
|
|
49
49
|
NOTE: The `baseUrl="http://localhost:3000"` property is only needed if using outside an Agentuity full stack project.
|
|
50
50
|
|
|
51
|
-
###
|
|
51
|
+
### Type-Safe API Calls
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Use Hono's `hc()` client for type-safe API calls:
|
|
54
54
|
|
|
55
55
|
```tsx
|
|
56
|
-
import {
|
|
56
|
+
import { hc } from 'hono/client';
|
|
57
|
+
import type { AppType } from '../api/router';
|
|
58
|
+
|
|
59
|
+
const client = hc<AppType>('/');
|
|
57
60
|
|
|
58
61
|
function ChatComponent() {
|
|
59
|
-
|
|
60
|
-
const
|
|
62
|
+
const [data, setData] = useState(null);
|
|
63
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
61
64
|
|
|
62
65
|
const handleSubmit = async (message: string) => {
|
|
63
|
-
|
|
66
|
+
setIsLoading(true);
|
|
67
|
+
const res = await client.api.chat.$post({ json: { message } });
|
|
68
|
+
setData(await res.json());
|
|
69
|
+
setIsLoading(false);
|
|
64
70
|
};
|
|
65
71
|
|
|
66
72
|
return (
|
|
67
73
|
<div>
|
|
68
74
|
{isLoading && <p>Loading...</p>}
|
|
69
75
|
{data && <p>Response: {data.reply}</p>}
|
|
70
|
-
{error && <p>Error: {error.message}</p>}
|
|
71
76
|
<button onClick={() => handleSubmit('Hello!')}>Send</button>
|
|
72
77
|
</div>
|
|
73
78
|
);
|
|
74
79
|
}
|
|
75
|
-
|
|
76
|
-
// For GET routes (auto-fetches on mount)
|
|
77
|
-
function UserProfile() {
|
|
78
|
-
const { data, isLoading, isFetching, refetch } = useAPI('GET /api/user');
|
|
79
|
-
// data is fetched automatically on mount
|
|
80
|
-
// isFetching is true during refetches
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
**Options:**
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
const { data, invoke } = useAPI({
|
|
88
|
-
route: 'POST /agent/my-agent',
|
|
89
|
-
headers: { 'X-Custom': 'value' },
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// Streaming support
|
|
93
|
-
const { data, invoke } = useAPI('POST /agent/stream', {
|
|
94
|
-
delimiter: '\n',
|
|
95
|
-
onChunk: (chunk) => console.log('Received chunk:', chunk),
|
|
96
|
-
});
|
|
97
80
|
```
|
|
98
81
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Real-time bidirectional communication.
|
|
102
|
-
|
|
103
|
-
```tsx
|
|
104
|
-
import { useWebsocket } from '@agentuity/react';
|
|
105
|
-
|
|
106
|
-
function LiveChat() {
|
|
107
|
-
const {
|
|
108
|
-
isConnected,
|
|
109
|
-
send,
|
|
110
|
-
close,
|
|
111
|
-
data, // Latest message
|
|
112
|
-
messages, // All messages array
|
|
113
|
-
clearMessages, // Clear message history
|
|
114
|
-
error,
|
|
115
|
-
readyState,
|
|
116
|
-
} = useWebsocket('/ws/chat');
|
|
117
|
-
|
|
118
|
-
// Messages are accessed via data (latest) or messages (all)
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
if (data) {
|
|
121
|
-
console.log('Received:', data);
|
|
122
|
-
}
|
|
123
|
-
}, [data]);
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<div>
|
|
127
|
-
<p>Status: {isConnected ? 'Connected' : 'Disconnected'}</p>
|
|
128
|
-
<button onClick={() => send({ type: 'ping' })}>Ping</button>
|
|
129
|
-
<ul>
|
|
130
|
-
{messages.map((msg, i) => (
|
|
131
|
-
<li key={i}>{JSON.stringify(msg)}</li>
|
|
132
|
-
))}
|
|
133
|
-
</ul>
|
|
134
|
-
</div>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
**Features:**
|
|
140
|
-
|
|
141
|
-
- Auto-reconnection on connection loss
|
|
142
|
-
- Message queuing when disconnected
|
|
143
|
-
- Auth tokens auto-injected when AuthProvider is in tree
|
|
144
|
-
- Access latest message via `data` or all via `messages` array
|
|
82
|
+
For WebSocket and SSE, use `WebSocketManager` and `EventStreamManager` from `@agentuity/frontend`.
|
|
145
83
|
|
|
146
84
|
### useAuth Hook
|
|
147
85
|
|
|
@@ -160,7 +98,7 @@ function UserProfile() {
|
|
|
160
98
|
}
|
|
161
99
|
```
|
|
162
100
|
|
|
163
|
-
**Note:** Auth tokens
|
|
101
|
+
**Note:** Auth tokens can be accessed via `useAuth()` and passed to API calls manually.
|
|
164
102
|
|
|
165
103
|
---
|
|
166
104
|
|
|
@@ -289,7 +227,11 @@ src/
|
|
|
289
227
|
### Auth + Agent Call Pattern
|
|
290
228
|
|
|
291
229
|
```tsx
|
|
292
|
-
import { AuthProvider, AgentuityProvider,
|
|
230
|
+
import { AuthProvider, AgentuityProvider, useAuth } from '@agentuity/react';
|
|
231
|
+
import { hc } from 'hono/client';
|
|
232
|
+
import type { AppType } from '../api/router';
|
|
233
|
+
|
|
234
|
+
const client = hc<AppType>('/');
|
|
293
235
|
|
|
294
236
|
function App() {
|
|
295
237
|
return (
|
|
@@ -302,14 +244,22 @@ function App() {
|
|
|
302
244
|
}
|
|
303
245
|
|
|
304
246
|
function ProtectedChat() {
|
|
305
|
-
const { isAuthenticated } = useAuth();
|
|
306
|
-
const
|
|
247
|
+
const { isAuthenticated, authHeader } = useAuth();
|
|
248
|
+
const [data, setData] = useState(null);
|
|
307
249
|
|
|
308
250
|
if (!isAuthenticated) return <SignIn />;
|
|
309
251
|
|
|
252
|
+
const handleChat = async () => {
|
|
253
|
+
const res = await client.api.chat.$post(
|
|
254
|
+
{ json: { message: 'Hello' } },
|
|
255
|
+
{ headers: authHeader ? { Authorization: authHeader } : {} }
|
|
256
|
+
);
|
|
257
|
+
setData(await res.json());
|
|
258
|
+
};
|
|
259
|
+
|
|
310
260
|
return (
|
|
311
261
|
<div>
|
|
312
|
-
<button onClick={
|
|
262
|
+
<button onClick={handleChat}>Chat</button>
|
|
313
263
|
{data && <p>{data.reply}</p>}
|
|
314
264
|
</div>
|
|
315
265
|
);
|
|
@@ -318,9 +268,8 @@ function ProtectedChat() {
|
|
|
318
268
|
|
|
319
269
|
## Common Mistakes
|
|
320
270
|
|
|
321
|
-
| Mistake | Better Approach
|
|
322
|
-
| ----------------------------------------- |
|
|
323
|
-
| Adding `baseUrl` inside Agentuity project | Omit `baseUrl`
|
|
324
|
-
|
|
|
325
|
-
|
|
|
326
|
-
| Missing AuthProvider | Wrap app with AuthProvider | Required for auth token injection |
|
|
271
|
+
| Mistake | Better Approach | Why |
|
|
272
|
+
| ----------------------------------------- | ------------------------------ | ------------------------------------ |
|
|
273
|
+
| Adding `baseUrl` inside Agentuity project | Omit `baseUrl` | Auto-detected in full-stack projects |
|
|
274
|
+
| Missing AuthProvider | Wrap app with AuthProvider | Required for auth token injection |
|
|
275
|
+
| Not passing auth headers to hc() calls | Use `useAuth()` + headers opt | Auth tokens not auto-injected |
|