@agentuity/react 1.0.0 → 1.0.2
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/AGENTS.md +64 -61
- package/README.md +52 -0
- package/dist/eventstream.d.ts +20 -2
- package/dist/eventstream.d.ts.map +1 -1
- package/dist/eventstream.js +25 -1
- package/dist/eventstream.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/webrtc.d.ts +164 -0
- package/dist/webrtc.d.ts.map +1 -0
- package/dist/webrtc.js +301 -0
- package/dist/webrtc.js.map +1 -0
- package/package.json +5 -5
- package/src/eventstream.ts +29 -6
- package/src/index.ts +14 -0
- package/src/webrtc.tsx +483 -0
package/AGENTS.md
CHANGED
|
@@ -2,109 +2,112 @@
|
|
|
2
2
|
|
|
3
3
|
## Package Overview
|
|
4
4
|
|
|
5
|
-
React hooks
|
|
5
|
+
React hooks for building Agentuity web applications. Provides type-safe hooks for API calls, WebSocket, Server-Sent Events, and analytics.
|
|
6
6
|
|
|
7
7
|
## Commands
|
|
8
8
|
|
|
9
|
-
- **Build**: `bun run build`
|
|
10
|
-
- **Typecheck**: `bun run typecheck`
|
|
11
|
-
- **Clean**: `bun run clean`
|
|
9
|
+
- **Build**: `bun run build`
|
|
10
|
+
- **Typecheck**: `bun run typecheck`
|
|
11
|
+
- **Clean**: `bun run clean`
|
|
12
12
|
|
|
13
13
|
## Architecture
|
|
14
14
|
|
|
15
|
-
- **Runtime**: Browser only
|
|
16
|
-
- **
|
|
17
|
-
- **Dependencies**: Requires `@agentuity/core` (workspace dependency)
|
|
15
|
+
- **Runtime**: Browser only
|
|
16
|
+
- **Dependencies**: `@agentuity/core`, `@agentuity/frontend`
|
|
18
17
|
- **Peer dependencies**: React 18+ or 19+
|
|
19
18
|
|
|
20
19
|
## Structure
|
|
21
20
|
|
|
22
21
|
```text
|
|
23
22
|
src/
|
|
24
|
-
├── index.ts # Main
|
|
25
|
-
├──
|
|
26
|
-
├──
|
|
27
|
-
├──
|
|
28
|
-
├──
|
|
29
|
-
├──
|
|
30
|
-
|
|
23
|
+
├── index.ts # Main exports (client-side)
|
|
24
|
+
├── server.ts # Server-side entry point (SSR, server components, API routes)
|
|
25
|
+
├── context.tsx # AgentuityProvider, useAgentuity, useAuth
|
|
26
|
+
├── api.ts # useAPI hook
|
|
27
|
+
├── websocket.ts # useWebsocket hook
|
|
28
|
+
├── eventstream.ts # useEventStream hook
|
|
29
|
+
├── client.ts # createClient, createAPIClient
|
|
30
|
+
├── analytics.tsx # useAnalytics, useTrackOnMount, withPageTracking
|
|
31
|
+
└── memo.ts # useJsonMemo
|
|
31
32
|
```
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
**Entry points:**
|
|
34
35
|
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
- **Functional components** - All components are functional
|
|
38
|
-
- **Context API** - Use React Context for configuration
|
|
39
|
-
- **Error boundaries** - Throw errors that can be caught by error boundaries
|
|
36
|
+
- `@agentuity/react` - Client-side hooks (browser only)
|
|
37
|
+
- `@agentuity/react/server` - Server-safe exports (SSR, server components)
|
|
40
38
|
|
|
41
|
-
##
|
|
39
|
+
## Code Conventions
|
|
42
40
|
|
|
43
41
|
- **Provider required** - All hooks must be used within `AgentuityProvider`
|
|
44
|
-
- **Type inference** -
|
|
45
|
-
- **
|
|
46
|
-
- **WebSocket protocol** - Auto-converts http:// to ws:// and https:// to wss://
|
|
47
|
-
- **Serialization** - Automatically handles JSON serialization/deserialization
|
|
42
|
+
- **Type inference** - Types inferred from generated registries (RouteRegistry, etc.)
|
|
43
|
+
- **SSR safe** - All hooks include SSR guards
|
|
48
44
|
|
|
49
45
|
## Hooks API
|
|
50
46
|
|
|
51
|
-
###
|
|
47
|
+
### useAPI (main HTTP hook)
|
|
52
48
|
|
|
53
49
|
```typescript
|
|
54
|
-
|
|
50
|
+
// GET auto-executes, returns refetch()
|
|
51
|
+
const { data, isLoading, error, refetch } = useAPI('GET /users');
|
|
52
|
+
|
|
53
|
+
// POST/PUT/PATCH/DELETE manual via invoke()
|
|
54
|
+
const { data, invoke } = useAPI('POST /users');
|
|
55
|
+
await invoke({ name: 'Alice' });
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
- `authHeader` is automatically injected into agent/API calls
|
|
59
|
-
- Works with `@agentuity/auth`'s `AuthProvider`
|
|
58
|
+
Returns: `{ data, error, isLoading, isSuccess, isError, isFetching, reset, refetch|invoke }`
|
|
60
59
|
|
|
61
|
-
###
|
|
60
|
+
### useWebsocket
|
|
62
61
|
|
|
63
62
|
```typescript
|
|
64
|
-
const { data,
|
|
63
|
+
const { isConnected, data, messages, send, close, clearMessages } = useWebsocket('/ws');
|
|
64
|
+
send({ message: 'Hello' });
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
- Supports custom headers, query params, subpaths
|
|
70
|
-
- **Auth tokens auto-injected** when `AuthProvider` is in tree
|
|
67
|
+
- `data` = latest message, `messages` = all messages
|
|
68
|
+
- Auto-reconnection on connection loss
|
|
71
69
|
|
|
72
|
-
###
|
|
70
|
+
### useEventStream (SSE)
|
|
73
71
|
|
|
74
72
|
```typescript
|
|
75
|
-
const {
|
|
73
|
+
const { isConnected, data, close, error, isError, reset, readyState } = useEventStream('/events');
|
|
76
74
|
```
|
|
77
75
|
|
|
78
76
|
- Auto-reconnection on connection loss
|
|
79
|
-
-
|
|
80
|
-
- Type-safe message handlers
|
|
81
|
-
- **Auth tokens auto-injected** when `AuthProvider` is in tree
|
|
77
|
+
- `data` = latest event (with JSON memoization)
|
|
82
78
|
|
|
83
|
-
|
|
79
|
+
### useAuth
|
|
84
80
|
|
|
85
|
-
|
|
81
|
+
```typescript
|
|
82
|
+
const { isAuthenticated, authHeader, setAuthHeader, authLoading } = useAuth();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### useAnalytics
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const { track, trackClick, identify } = useAnalytics();
|
|
89
|
+
track('event_name', { prop: 'value' });
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Other Hooks
|
|
93
|
+
|
|
94
|
+
- `useAgentuity()` - Access baseUrl
|
|
95
|
+
- `useTrackOnMount(options)` - Track event on mount
|
|
96
|
+
- `useJsonMemo(value)` - Deep equality memoization
|
|
97
|
+
- `withPageTracking(Component, pageName)` - HOC for page tracking
|
|
98
|
+
|
|
99
|
+
## Client Functions
|
|
86
100
|
|
|
87
101
|
```typescript
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'my-agent': {
|
|
91
|
-
inputSchema: z.ZodObject<...>;
|
|
92
|
-
outputSchema: z.ZodObject<...>;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
102
|
+
const api = createAPIClient();
|
|
103
|
+
await api.hello.post({ name: 'World' });
|
|
95
104
|
```
|
|
96
105
|
|
|
97
|
-
##
|
|
106
|
+
## Generated Types
|
|
98
107
|
|
|
99
|
-
|
|
100
|
-
- Mock fetch and WebSocket APIs
|
|
101
|
-
- Test error boundaries
|
|
102
|
-
- Test with and without provider
|
|
103
|
-
- When running tests, prefer using a subagent (Task tool) to avoid context bloat from test output
|
|
108
|
+
Route registries are augmented via `declare module '@agentuity/frontend'`. See `@agentuity/frontend` for registry interfaces.
|
|
104
109
|
|
|
105
|
-
## Publishing
|
|
110
|
+
## Publishing
|
|
106
111
|
|
|
107
|
-
1. Run `bun run build`
|
|
108
|
-
2.
|
|
109
|
-
3. Ensure peer dependencies are correctly specified
|
|
110
|
-
4. Must publish **after** @agentuity/core
|
|
112
|
+
1. Run `bun run build`
|
|
113
|
+
2. Must publish **after** @agentuity/core and @agentuity/frontend
|
package/README.md
CHANGED
|
@@ -92,6 +92,58 @@ function ChatComponent() {
|
|
|
92
92
|
}
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
### 4. WebRTC Communication
|
|
96
|
+
|
|
97
|
+
For peer-to-peer video/audio calls and data channels:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { useWebRTCCall } from '@agentuity/react';
|
|
101
|
+
|
|
102
|
+
function VideoChat() {
|
|
103
|
+
const {
|
|
104
|
+
state,
|
|
105
|
+
localVideoRef,
|
|
106
|
+
remoteStreams,
|
|
107
|
+
remotePeerIds,
|
|
108
|
+
connect,
|
|
109
|
+
hangup,
|
|
110
|
+
muteAudio,
|
|
111
|
+
muteVideo,
|
|
112
|
+
sendJSON,
|
|
113
|
+
isAudioMuted,
|
|
114
|
+
isVideoMuted,
|
|
115
|
+
} = useWebRTCCall({
|
|
116
|
+
roomId: 'my-room',
|
|
117
|
+
signalUrl: '/api/webrtc/signal',
|
|
118
|
+
media: { video: true, audio: true },
|
|
119
|
+
dataChannels: [{ label: 'chat' }],
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div>
|
|
124
|
+
<div>Status: {state}</div>
|
|
125
|
+
<video ref={localVideoRef} autoPlay muted playsInline />
|
|
126
|
+
{remotePeerIds.map((peerId) => (
|
|
127
|
+
<video
|
|
128
|
+
key={peerId}
|
|
129
|
+
ref={(el) => el && (el.srcObject = remoteStreams.get(peerId) || null)}
|
|
130
|
+
autoPlay
|
|
131
|
+
playsInline
|
|
132
|
+
/>
|
|
133
|
+
))}
|
|
134
|
+
<button onClick={connect}>Join</button>
|
|
135
|
+
<button onClick={hangup}>Leave</button>
|
|
136
|
+
<button onClick={() => muteAudio(!isAudioMuted)}>
|
|
137
|
+
{isAudioMuted ? 'Unmute' : 'Mute'}
|
|
138
|
+
</button>
|
|
139
|
+
<button onClick={() => sendJSON('chat', { text: 'Hello!' })}>Send</button>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
For detailed architecture, see [docs/webrtc-architecture.md](../../docs/webrtc-architecture.md).
|
|
146
|
+
|
|
95
147
|
## API Reference
|
|
96
148
|
|
|
97
149
|
### AgentuityProvider
|
package/dist/eventstream.d.ts
CHANGED
|
@@ -34,6 +34,9 @@ export interface EventStreamOptions {
|
|
|
34
34
|
* the SSERouteRegistry generated from your routes.
|
|
35
35
|
*
|
|
36
36
|
* @template TRoute - SSE route key from SSERouteRegistry (e.g., '/events', '/notifications')
|
|
37
|
+
* @template TOutput - Optional type override for SSE event data. When provided, this type
|
|
38
|
+
* is used instead of the inferred type from the route registry. This is useful for SSE
|
|
39
|
+
* routes where outputSchema is `never` in the generated types.
|
|
37
40
|
*
|
|
38
41
|
* @example Simple SSE connection
|
|
39
42
|
* ```typescript
|
|
@@ -48,11 +51,26 @@ export interface EventStreamOptions {
|
|
|
48
51
|
* query: new URLSearchParams({ userId: '123' })
|
|
49
52
|
* });
|
|
50
53
|
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example SSE with custom output type (when registry has outputSchema: never)
|
|
56
|
+
* ```typescript
|
|
57
|
+
* interface StreamMessage {
|
|
58
|
+
* type: 'token' | 'complete';
|
|
59
|
+
* content?: string;
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* const { isConnected, data } = useEventStream<'/api/search', StreamMessage>('/api/search');
|
|
63
|
+
*
|
|
64
|
+
* // data is typed as StreamMessage | undefined
|
|
65
|
+
* if (data?.type === 'token') {
|
|
66
|
+
* console.log(data.content);
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
51
69
|
*/
|
|
52
|
-
export declare function useEventStream<TRoute extends SSERouteKey
|
|
70
|
+
export declare function useEventStream<TRoute extends SSERouteKey, TOutput = SSERouteOutput<TRoute>>(route: TRoute, options?: EventStreamOptions): {
|
|
53
71
|
isConnected: boolean;
|
|
54
72
|
close: () => void;
|
|
55
|
-
data?:
|
|
73
|
+
data?: TOutput;
|
|
56
74
|
error: Error | null;
|
|
57
75
|
isError: boolean;
|
|
58
76
|
reset: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventstream.d.ts","sourceRoot":"","sources":["../src/eventstream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,qBAAqB,CAAC;AAG7B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,gBAAgB,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,WAAW,IAAI,MAAM,SAAS,MAAM,gBAAgB,GAC3F,gBAAgB,CAAC,MAAM,CAAC,SAAS;IAAE,YAAY,EAAE,MAAM,OAAO,CAAA;CAAE,GAC/D,OAAO,SAAS,SAAS,GAAG,KAAK,GAChC,IAAI,GACJ,WAAW,CAAC,OAAO,CAAC,GACrB,IAAI,GACL,IAAI,CAAC;AAER;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"eventstream.d.ts","sourceRoot":"","sources":["../src/eventstream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,qBAAqB,CAAC;AAG7B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,gBAAgB,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,WAAW,IAAI,MAAM,SAAS,MAAM,gBAAgB,GAC3F,gBAAgB,CAAC,MAAM,CAAC,SAAS;IAAE,YAAY,EAAE,MAAM,OAAO,CAAA;CAAE,GAC/D,OAAO,SAAS,SAAS,GAAG,KAAK,GAChC,IAAI,GACJ,WAAW,CAAC,OAAO,CAAC,GACrB,IAAI,GACL,IAAI,CAAC;AAER;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,cAAc,CAAC,MAAM,SAAS,WAAW,EAAE,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,EAC1F,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,kBAAkB,GAC1B;IACF,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACnB,CA6FA"}
|
package/dist/eventstream.js
CHANGED
|
@@ -8,6 +8,9 @@ import { AgentuityContext } from './context';
|
|
|
8
8
|
* the SSERouteRegistry generated from your routes.
|
|
9
9
|
*
|
|
10
10
|
* @template TRoute - SSE route key from SSERouteRegistry (e.g., '/events', '/notifications')
|
|
11
|
+
* @template TOutput - Optional type override for SSE event data. When provided, this type
|
|
12
|
+
* is used instead of the inferred type from the route registry. This is useful for SSE
|
|
13
|
+
* routes where outputSchema is `never` in the generated types.
|
|
11
14
|
*
|
|
12
15
|
* @example Simple SSE connection
|
|
13
16
|
* ```typescript
|
|
@@ -22,6 +25,21 @@ import { AgentuityContext } from './context';
|
|
|
22
25
|
* query: new URLSearchParams({ userId: '123' })
|
|
23
26
|
* });
|
|
24
27
|
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example SSE with custom output type (when registry has outputSchema: never)
|
|
30
|
+
* ```typescript
|
|
31
|
+
* interface StreamMessage {
|
|
32
|
+
* type: 'token' | 'complete';
|
|
33
|
+
* content?: string;
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* const { isConnected, data } = useEventStream<'/api/search', StreamMessage>('/api/search');
|
|
37
|
+
*
|
|
38
|
+
* // data is typed as StreamMessage | undefined
|
|
39
|
+
* if (data?.type === 'token') {
|
|
40
|
+
* console.log(data.content);
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
25
43
|
*/
|
|
26
44
|
export function useEventStream(route, options) {
|
|
27
45
|
const context = useContext(AgentuityContext);
|
|
@@ -35,7 +53,13 @@ export function useEventStream(route, options) {
|
|
|
35
53
|
const [isConnected, setIsConnected] = useState(false);
|
|
36
54
|
const [readyState, setReadyState] = useState(2); // EventSource.CLOSED = 2
|
|
37
55
|
// Build EventStream URL
|
|
38
|
-
|
|
56
|
+
// Track both query object and its string representation to detect mutations.
|
|
57
|
+
// URLSearchParams can be mutated in-place without changing object identity,
|
|
58
|
+
// so we compare the string value to trigger recomputation when params change.
|
|
59
|
+
const queryString = options?.query?.toString();
|
|
60
|
+
const esUrl = useMemo(() => buildUrl(context.baseUrl, route, options?.subpath, options?.query),
|
|
61
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: queryString tracks URLSearchParams mutations that options?.query reference wouldn't catch
|
|
62
|
+
[context.baseUrl, route, options?.subpath, options?.query, queryString]);
|
|
39
63
|
// Initialize manager and connect
|
|
40
64
|
useEffect(() => {
|
|
41
65
|
const manager = new EventStreamManager({
|
package/dist/eventstream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventstream.js","sourceRoot":"","sources":["../src/eventstream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtF,OAAO,EACN,QAAQ,EACR,kBAAkB,EAClB,SAAS,GAET,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AE,CAAC;QAClB,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;QAE7B,OAAO,GAAG,EAAE;YACX,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;QAC3B,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,sBAAsB;IACtB,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;YACrB,MAAM,QAAQ,GAAG,GAAG,EAAE;gBACrB,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;YAC7B,CAAC,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACnD,OAAO,GAAG,EAAE;gBACX,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACxD,CAAC,CAAC;QACH,CAAC;IACF,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAEtB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,UAAU,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACN,WAAW;QACX,KAAK;QACL,IAAI;QACJ,KAAK;QACL,OAAO;QACP,KAAK;QACL,UAAU;KACV,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ export { AgentuityContext, AgentuityProvider, useAgentuity, useAuth, type Contex
|
|
|
2
2
|
export { createClient, createAPIClient, setGlobalBaseUrl, getGlobalBaseUrl, setGlobalAuthHeader, getGlobalAuthHeader, } from './client';
|
|
3
3
|
export { useWebsocket, type WebSocketRouteKey, type WebSocketRouteInput, type WebSocketRouteOutput, type WebsocketOptions, } from './websocket';
|
|
4
4
|
export { useEventStream, type SSERouteKey, type SSERouteOutput, type EventStreamOptions, } from './eventstream';
|
|
5
|
+
export { useWebRTCCall, type UseWebRTCCallOptions, type UseWebRTCCallResult, type WebRTCConnectionState, type WebRTCClientCallbacks, } from './webrtc';
|
|
5
6
|
export { useAPI, type RouteKey, type ExtractMethod, type RouteIsStream, type RouteInput, type RouteOutput, type RoutePathParams, type UseAPIOptions, type UseAPIResult, type InvokeOptions, } from './api';
|
|
6
7
|
export { useJsonMemo } from './memo';
|
|
7
8
|
export { useAnalytics, useTrackOnMount, withPageTracking, type UseAnalyticsResult, type TrackOnMountOptions, } from './analytics.js';
|
|
8
9
|
export type { RouteRegistry, WebSocketRouteRegistry, SSERouteRegistry, RPCRouteRegistry, } from '@agentuity/frontend';
|
|
9
|
-
export { buildUrl, defaultBaseUrl, deserializeData, createReconnectManager, jsonEqual, getProcessEnv, WebSocketManager, EventStreamManager, type ReconnectOptions, type ReconnectManager, type WebSocketMessageHandler, type WebSocketCallbacks, type WebSocketManagerOptions, type WebSocketManagerState, type EventStreamMessageHandler, type EventStreamCallbacks, type EventStreamManagerOptions, type EventStreamManagerState, type Client, type ClientOptions, type RouteEndpoint, type WebSocketClient, type EventStreamClient, type StreamClient, type EventHandler, } from '@agentuity/frontend';
|
|
10
|
+
export { buildUrl, defaultBaseUrl, deserializeData, createReconnectManager, jsonEqual, getProcessEnv, WebSocketManager, EventStreamManager, type ReconnectOptions, type ReconnectManager, type WebSocketMessageHandler, type WebSocketCallbacks, type WebSocketManagerOptions, type WebSocketManagerState, type EventStreamMessageHandler, type EventStreamCallbacks, type EventStreamManagerOptions, type EventStreamManagerState, WebRTCManager, UserMediaSource, DisplayMediaSource, CustomStreamSource, type WebRTCManagerOptions, type WebRTCManagerState, type WebRTCDisconnectReason, type Client, type ClientOptions, type RouteEndpoint, type WebSocketClient, type EventStreamClient, type StreamClient, type EventHandler, } from '@agentuity/frontend';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,MAAM,EACN,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,aAAa,GAClB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EACN,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACxB,MAAM,gBAAgB,CAAC;AAKxB,YAAY,EACX,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACN,QAAQ,EACR,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,MAAM,EACN,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,aAAa,GAClB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EACN,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACxB,MAAM,gBAAgB,CAAC;AAKxB,YAAY,EACX,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACN,QAAQ,EACR,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAE3B,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,YAAY,GACjB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,11 @@ export { AgentuityContext, AgentuityProvider, useAgentuity, useAuth, } from './c
|
|
|
2
2
|
export { createClient, createAPIClient, setGlobalBaseUrl, getGlobalBaseUrl, setGlobalAuthHeader, getGlobalAuthHeader, } from './client';
|
|
3
3
|
export { useWebsocket, } from './websocket';
|
|
4
4
|
export { useEventStream, } from './eventstream';
|
|
5
|
+
export { useWebRTCCall, } from './webrtc';
|
|
5
6
|
export { useAPI, } from './api';
|
|
6
7
|
export { useJsonMemo } from './memo';
|
|
7
8
|
// Analytics
|
|
8
9
|
export { useAnalytics, useTrackOnMount, withPageTracking, } from './analytics.js';
|
|
9
10
|
// Re-export web utilities for convenience (excluding registry types which come from ./types)
|
|
10
|
-
export { buildUrl, defaultBaseUrl, deserializeData, createReconnectManager, jsonEqual, getProcessEnv, WebSocketManager, EventStreamManager, } from '@agentuity/frontend';
|
|
11
|
+
export { buildUrl, defaultBaseUrl, deserializeData, createReconnectManager, jsonEqual, getProcessEnv, WebSocketManager, EventStreamManager, WebRTCManager, UserMediaSource, DisplayMediaSource, CustomStreamSource, } from '@agentuity/frontend';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,OAAO,GAKP,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,YAAY,GAKZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,cAAc,GAId,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,MAAM,GAUN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,YAAY;AACZ,OAAO,EACN,YAAY,EACZ,eAAe,EACf,gBAAgB,GAGhB,MAAM,gBAAgB,CAAC;AAYxB,6FAA6F;AAC7F,OAAO,EACN,QAAQ,EACR,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,OAAO,GAKP,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,YAAY,GAKZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,cAAc,GAId,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,aAAa,GAKb,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,MAAM,GAUN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,YAAY;AACZ,OAAO,EACN,YAAY,EACZ,eAAe,EACf,gBAAgB,GAGhB,MAAM,gBAAgB,CAAC;AAYxB,6FAA6F;AAC7F,OAAO,EACN,QAAQ,EACR,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAWlB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GAYlB,MAAM,qBAAqB,CAAC"}
|
package/dist/webrtc.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { type WebRTCClientCallbacks, type TrackSource } from '@agentuity/frontend';
|
|
2
|
+
import type { WebRTCConnectionState, DataChannelConfig, DataChannelState, ConnectionQualitySummary, RecordingHandle, RecordingOptions } from '@agentuity/core';
|
|
3
|
+
export type { WebRTCClientCallbacks, DataChannelConfig, DataChannelState, ConnectionQualitySummary, };
|
|
4
|
+
export type { WebRTCConnectionState };
|
|
5
|
+
/**
|
|
6
|
+
* Options for useWebRTCCall hook
|
|
7
|
+
*/
|
|
8
|
+
export interface UseWebRTCCallOptions {
|
|
9
|
+
/** Room ID to join */
|
|
10
|
+
roomId: string;
|
|
11
|
+
/** WebSocket signaling URL (e.g., '/call/signal' or full URL) */
|
|
12
|
+
signalUrl: string;
|
|
13
|
+
/** Whether this peer is "polite" in perfect negotiation */
|
|
14
|
+
polite?: boolean;
|
|
15
|
+
/** ICE servers configuration */
|
|
16
|
+
iceServers?: RTCIceServer[];
|
|
17
|
+
/**
|
|
18
|
+
* Media source configuration.
|
|
19
|
+
* - `false`: Data-only mode (no media)
|
|
20
|
+
* - `MediaStreamConstraints`: Use getUserMedia with these constraints
|
|
21
|
+
* - `TrackSource`: Use a custom track source
|
|
22
|
+
* Default: { video: true, audio: true }
|
|
23
|
+
*/
|
|
24
|
+
media?: MediaStreamConstraints | TrackSource | false;
|
|
25
|
+
/**
|
|
26
|
+
* Data channels to create when connection is established.
|
|
27
|
+
* Only the offerer (late joiner) creates channels; the answerer receives them.
|
|
28
|
+
*/
|
|
29
|
+
dataChannels?: DataChannelConfig[];
|
|
30
|
+
/**
|
|
31
|
+
* Whether to auto-reconnect on WebSocket/ICE failures (default: true)
|
|
32
|
+
*/
|
|
33
|
+
autoReconnect?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum reconnection attempts before giving up (default: 5)
|
|
36
|
+
*/
|
|
37
|
+
maxReconnectAttempts?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Connection timeout in ms for connecting/negotiating (default: 30000)
|
|
40
|
+
*/
|
|
41
|
+
connectionTimeout?: number;
|
|
42
|
+
/**
|
|
43
|
+
* ICE gathering timeout in ms (default: 10000)
|
|
44
|
+
*/
|
|
45
|
+
iceGatheringTimeout?: number;
|
|
46
|
+
/** Whether to auto-connect on mount (default: true) */
|
|
47
|
+
autoConnect?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Optional callbacks for WebRTC events.
|
|
50
|
+
* These are called in addition to the hook's internal state management.
|
|
51
|
+
*/
|
|
52
|
+
callbacks?: Partial<WebRTCClientCallbacks>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Return type for useWebRTCCall hook
|
|
56
|
+
*/
|
|
57
|
+
export interface UseWebRTCCallResult {
|
|
58
|
+
/** Ref to attach to local video element */
|
|
59
|
+
localVideoRef: React.RefObject<HTMLVideoElement | null>;
|
|
60
|
+
/** Current connection state */
|
|
61
|
+
state: WebRTCConnectionState;
|
|
62
|
+
/** Current error if any */
|
|
63
|
+
error: Error | null;
|
|
64
|
+
/** Local peer ID assigned by server */
|
|
65
|
+
peerId: string | null;
|
|
66
|
+
/** Remote peer IDs */
|
|
67
|
+
remotePeerIds: string[];
|
|
68
|
+
/** Remote streams keyed by peer ID */
|
|
69
|
+
remoteStreams: Map<string, MediaStream>;
|
|
70
|
+
/** Whether audio is muted */
|
|
71
|
+
isAudioMuted: boolean;
|
|
72
|
+
/** Whether video is muted */
|
|
73
|
+
isVideoMuted: boolean;
|
|
74
|
+
/** Whether this is a data-only connection (no media) */
|
|
75
|
+
isDataOnly: boolean;
|
|
76
|
+
/** Whether screen sharing is active */
|
|
77
|
+
isScreenSharing: boolean;
|
|
78
|
+
/** Manually start the connection (if autoConnect is false) */
|
|
79
|
+
connect: () => void;
|
|
80
|
+
/** End the call */
|
|
81
|
+
hangup: () => void;
|
|
82
|
+
/** Mute or unmute audio */
|
|
83
|
+
muteAudio: (muted: boolean) => void;
|
|
84
|
+
/** Mute or unmute video */
|
|
85
|
+
muteVideo: (muted: boolean) => void;
|
|
86
|
+
/** Start screen sharing */
|
|
87
|
+
startScreenShare: (options?: DisplayMediaStreamOptions) => Promise<void>;
|
|
88
|
+
/** Stop screen sharing */
|
|
89
|
+
stopScreenShare: () => Promise<void>;
|
|
90
|
+
/** Create a new data channel to all peers */
|
|
91
|
+
createDataChannel: (config: DataChannelConfig) => Map<string, RTCDataChannel>;
|
|
92
|
+
/** Get all open data channel labels */
|
|
93
|
+
getDataChannelLabels: () => string[];
|
|
94
|
+
/** Get the state of a data channel for a specific peer */
|
|
95
|
+
getDataChannelState: (peerId: string, label: string) => DataChannelState | null;
|
|
96
|
+
/** Send a string message to all peers */
|
|
97
|
+
sendString: (label: string, data: string) => boolean;
|
|
98
|
+
/** Send a string message to a specific peer */
|
|
99
|
+
sendStringTo: (peerId: string, label: string, data: string) => boolean;
|
|
100
|
+
/** Send binary data to all peers */
|
|
101
|
+
sendBinary: (label: string, data: ArrayBuffer | Uint8Array) => boolean;
|
|
102
|
+
/** Send binary data to a specific peer */
|
|
103
|
+
sendBinaryTo: (peerId: string, label: string, data: ArrayBuffer | Uint8Array) => boolean;
|
|
104
|
+
/** Send JSON data to all peers */
|
|
105
|
+
sendJSON: (label: string, data: unknown) => boolean;
|
|
106
|
+
/** Send JSON data to a specific peer */
|
|
107
|
+
sendJSONTo: (peerId: string, label: string, data: unknown) => boolean;
|
|
108
|
+
/** Close a specific data channel on all peers */
|
|
109
|
+
closeDataChannel: (label: string) => boolean;
|
|
110
|
+
/** Get quality summary for a peer */
|
|
111
|
+
getQualitySummary: (peerId: string) => Promise<ConnectionQualitySummary | null>;
|
|
112
|
+
/** Get quality summaries for all peers */
|
|
113
|
+
getAllQualitySummaries: () => Promise<Map<string, ConnectionQualitySummary>>;
|
|
114
|
+
/** Start recording a stream */
|
|
115
|
+
startRecording: (streamId: string, options?: RecordingOptions) => RecordingHandle | null;
|
|
116
|
+
/** Check if a stream is being recorded */
|
|
117
|
+
isRecording: (streamId: string) => boolean;
|
|
118
|
+
/** Stop all recordings */
|
|
119
|
+
stopAllRecordings: () => Promise<Map<string, Blob>>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* React hook for WebRTC peer-to-peer audio/video/data calls.
|
|
123
|
+
*
|
|
124
|
+
* Supports multi-peer mesh networking, screen sharing, recording, and stats.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
128
|
+
* function VideoCall({ roomId }: { roomId: string }) {
|
|
129
|
+
* const {
|
|
130
|
+
* localVideoRef,
|
|
131
|
+
* state,
|
|
132
|
+
* remotePeerIds,
|
|
133
|
+
* remoteStreams,
|
|
134
|
+
* hangup,
|
|
135
|
+
* muteAudio,
|
|
136
|
+
* isAudioMuted,
|
|
137
|
+
* startScreenShare,
|
|
138
|
+
* } = useWebRTCCall({
|
|
139
|
+
* roomId,
|
|
140
|
+
* signalUrl: '/call/signal',
|
|
141
|
+
* callbacks: {
|
|
142
|
+
* onStateChange: (from, to, reason) => console.log(`${from} → ${to}`, reason),
|
|
143
|
+
* onRemoteStream: (peerId, stream) => console.log(`Got stream from ${peerId}`),
|
|
144
|
+
* },
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* return (
|
|
148
|
+
* <div>
|
|
149
|
+
* <video ref={localVideoRef} autoPlay muted playsInline />
|
|
150
|
+
* {remotePeerIds.map((peerId) => (
|
|
151
|
+
* <RemoteVideo key={peerId} stream={remoteStreams.get(peerId)} />
|
|
152
|
+
* ))}
|
|
153
|
+
* <p>State: {state}</p>
|
|
154
|
+
* <button onClick={() => muteAudio(!isAudioMuted)}>
|
|
155
|
+
* {isAudioMuted ? 'Unmute' : 'Mute'}
|
|
156
|
+
* </button>
|
|
157
|
+
* <button onClick={hangup}>Hang Up</button>
|
|
158
|
+
* </div>
|
|
159
|
+
* );
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function useWebRTCCall(options: UseWebRTCCallOptions): UseWebRTCCallResult;
|
|
164
|
+
//# sourceMappingURL=webrtc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webrtc.d.ts","sourceRoot":"","sources":["../src/webrtc.tsx"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACX,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,GACxB,CAAC;AAGF,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,sBAAsB;IACtB,MAA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