@agentuity/react 0.0.99 → 0.0.101

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.
Files changed (61) hide show
  1. package/dist/api.d.ts +1 -1
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +1 -2
  4. package/dist/api.js.map +1 -1
  5. package/dist/client.d.ts +90 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +102 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/context.d.ts +3 -2
  10. package/dist/context.d.ts.map +1 -1
  11. package/dist/context.js +21 -5
  12. package/dist/context.js.map +1 -1
  13. package/dist/eventstream.d.ts +8 -22
  14. package/dist/eventstream.d.ts.map +1 -1
  15. package/dist/eventstream.js +62 -136
  16. package/dist/eventstream.js.map +1 -1
  17. package/dist/index.d.ts +3 -3
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +4 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/memo.d.ts +2 -3
  22. package/dist/memo.d.ts.map +1 -1
  23. package/dist/memo.js +2 -20
  24. package/dist/memo.js.map +1 -1
  25. package/dist/websocket.d.ts +9 -22
  26. package/dist/websocket.d.ts.map +1 -1
  27. package/dist/websocket.js +80 -169
  28. package/dist/websocket.js.map +1 -1
  29. package/package.json +5 -2
  30. package/src/api.ts +1 -3
  31. package/src/client.ts +148 -0
  32. package/src/context.tsx +30 -6
  33. package/src/eventstream.ts +77 -177
  34. package/src/index.ts +43 -3
  35. package/src/memo.ts +2 -18
  36. package/src/websocket.ts +105 -225
  37. package/dist/env.d.ts +0 -2
  38. package/dist/env.d.ts.map +0 -1
  39. package/dist/env.js +0 -10
  40. package/dist/env.js.map +0 -1
  41. package/dist/reconnect.d.ts +0 -22
  42. package/dist/reconnect.d.ts.map +0 -1
  43. package/dist/reconnect.js +0 -47
  44. package/dist/reconnect.js.map +0 -1
  45. package/dist/serialization.d.ts +0 -6
  46. package/dist/serialization.d.ts.map +0 -1
  47. package/dist/serialization.js +0 -16
  48. package/dist/serialization.js.map +0 -1
  49. package/dist/types.d.ts +0 -19
  50. package/dist/types.d.ts.map +0 -1
  51. package/dist/types.js +0 -2
  52. package/dist/types.js.map +0 -1
  53. package/dist/url.d.ts +0 -3
  54. package/dist/url.d.ts.map +0 -1
  55. package/dist/url.js +0 -24
  56. package/dist/url.js.map +0 -1
  57. package/src/env.ts +0 -9
  58. package/src/reconnect.ts +0 -73
  59. package/src/serialization.ts +0 -14
  60. package/src/types.ts +0 -29
  61. package/src/url.ts +0 -32
package/src/websocket.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import type { InferInput, InferOutput } from '@agentuity/core';
3
+ import { buildUrl, WebSocketManager, type WebSocketRouteRegistry } from '@agentuity/frontend';
3
4
  import { AgentuityContext } from './context';
4
- import { buildUrl } from './url';
5
- import { deserializeData } from './serialization';
6
- import { createReconnectManager } from './reconnect';
7
- import type { WebSocketRouteRegistry } from './types';
8
-
9
- type onMessageHandler<T = unknown> = (data: T) => void;
10
5
 
11
6
  /**
12
7
  * Extract WebSocket route keys (e.g., '/ws', '/chat')
@@ -61,63 +56,74 @@ export interface WebsocketOptions {
61
56
  maxMessages?: number;
62
57
  }
63
58
 
64
- const serializeWSData = (
65
- data: unknown
66
- ): string | ArrayBufferLike | Blob | ArrayBufferView<ArrayBufferLike> => {
67
- if (typeof data === 'string') {
68
- return data;
69
- }
70
- if (typeof data === 'object') {
71
- if (data instanceof ArrayBuffer || ArrayBuffer.isView(data) || data instanceof Blob) {
72
- return data;
73
- }
74
- return JSON.stringify(data);
75
- }
76
- throw new Error('unsupported data type for websocket: ' + typeof data);
77
- };
78
-
79
- interface WebsocketResponseInternal<TInput, TOutput> {
80
- /** Whether WebSocket is currently connected */
59
+ /**
60
+ * Type-safe WebSocket hook for connecting to WebSocket routes.
61
+ *
62
+ * Provides automatic type inference for route inputs and outputs based on
63
+ * the WebSocketRouteRegistry generated from your routes.
64
+ *
65
+ * @template TRoute - WebSocket route key from WebSocketRouteRegistry (e.g., '/ws', '/chat')
66
+ *
67
+ * @example Simple WebSocket connection
68
+ * ```typescript
69
+ * const { isConnected, data, send } = useWebsocket('/ws');
70
+ *
71
+ * // Send typed data
72
+ * send({ message: 'Hello' }); // Fully typed based on route schema!
73
+ * ```
74
+ *
75
+ * @example WebSocket with query parameters
76
+ * ```typescript
77
+ * const { isConnected, data, send } = useWebsocket('/chat', {
78
+ * query: new URLSearchParams({ room: 'general' })
79
+ * });
80
+ * ```
81
+ *
82
+ * @example Access all messages (prevents message loss in rapid succession)
83
+ * ```typescript
84
+ * const { messages, clearMessages } = useWebsocket('/chat');
85
+ *
86
+ * // messages array contains ALL received messages
87
+ * messages.forEach(msg => console.log(msg));
88
+ *
89
+ * // Clear messages when needed
90
+ * clearMessages();
91
+ * ```
92
+ */
93
+ export function useWebsocket<TRoute extends WebSocketRouteKey>(
94
+ route: TRoute,
95
+ options?: WebsocketOptions
96
+ ): {
81
97
  isConnected: boolean;
82
- /** Error if connection or message failed */
98
+ close: () => void;
99
+ data?: WebSocketRouteOutput<TRoute>;
100
+ messages: WebSocketRouteOutput<TRoute>[];
101
+ clearMessages: () => void;
83
102
  error: Error | null;
84
- /** Whether an error has occurred */
85
103
  isError: boolean;
86
- /** Send data through the WebSocket */
87
- send: (data: TInput) => void;
88
- /** Set handler for incoming messages */
89
- setHandler: (handler: onMessageHandler<TOutput>) => void;
90
- /** WebSocket connection state (CONNECTING=0, OPEN=1, CLOSING=2, CLOSED=3) */
91
- readyState: WebSocket['readyState'];
92
- /** Close the WebSocket connection */
93
- close: () => void;
94
- /** Reset state to initial values */
95
104
  reset: () => void;
96
- }
97
-
98
- const useWebsocketInternal = <TInput, TOutput>(
99
- path: string,
100
- options?: WebsocketOptions
101
- ): WebsocketResponseInternal<TInput, TOutput> => {
105
+ send: (data: WebSocketRouteInput<TRoute>) => void;
106
+ readyState: WebSocket['readyState'];
107
+ } {
102
108
  const context = useContext(AgentuityContext);
103
109
 
104
110
  if (!context) {
105
111
  throw new Error('useWebsocket must be used within a AgentuityProvider');
106
112
  }
107
113
 
108
- const manualClose = useRef(false);
109
- const wsRef = useRef<WebSocket | undefined>(undefined);
110
- const pending = useRef<TOutput[]>([]);
111
- const queued = useRef<TInput[]>([]);
112
- const handler = useRef<onMessageHandler<TOutput> | undefined>(undefined);
113
- const reconnectManagerRef = useRef<ReturnType<typeof createReconnectManager> | undefined>(
114
- undefined
115
- );
114
+ const managerRef = useRef<WebSocketManager<
115
+ WebSocketRouteInput<TRoute>,
116
+ WebSocketRouteOutput<TRoute>
117
+ > | null>(null);
116
118
 
119
+ const [data, setData] = useState<WebSocketRouteOutput<TRoute>>();
120
+ const [messages, setMessages] = useState<WebSocketRouteOutput<TRoute>[]>([]);
117
121
  const [error, setError] = useState<Error | null>(null);
118
122
  const [isError, setIsError] = useState(false);
119
123
  const [isConnected, setIsConnected] = useState(false);
124
+ const [readyState, setReadyState] = useState<WebSocket['readyState']>(WebSocket.CLOSED);
120
125
 
126
+ // Build WebSocket URL
121
127
  const wsUrl = useMemo(() => {
122
128
  const base = context.baseUrl!;
123
129
  const wsBase = base.replace(/^http(s?):/, 'ws$1:');
@@ -135,207 +141,81 @@ const useWebsocketInternal = <TInput, TOutput>(
135
141
  }
136
142
  }
137
143
 
138
- return buildUrl(wsBase, path, options?.subpath, queryParams);
139
- }, [context.baseUrl, context.authHeader, path, options?.subpath, options?.query?.toString()]);
140
-
141
- const connect = useCallback(() => {
142
- if (manualClose.current) return;
143
-
144
- wsRef.current = new WebSocket(wsUrl);
145
-
146
- wsRef.current.onopen = () => {
147
- reconnectManagerRef.current?.recordSuccess();
148
- setIsConnected(true);
149
- setError(null);
150
- setIsError(false);
151
- if (queued.current.length > 0) {
152
- queued.current.forEach((msg: unknown) => wsRef.current!.send(serializeWSData(msg)));
153
- queued.current = [];
154
- }
155
- };
156
-
157
- wsRef.current.onerror = () => {
158
- setError(new Error('WebSocket error'));
159
- setIsError(true);
160
- };
161
-
162
- wsRef.current.onclose = (evt) => {
163
- wsRef.current = undefined;
164
- setIsConnected(false);
165
- if (manualClose.current) {
166
- queued.current = [];
167
- return;
168
- }
169
- if (evt.code !== 1000) {
170
- setError(new Error(`WebSocket closed: ${evt.code} ${evt.reason || ''}`));
171
- setIsError(true);
172
- }
173
- reconnectManagerRef.current?.recordFailure();
174
- };
175
-
176
- wsRef.current.onmessage = (event: { data: string }) => {
177
- const payload = deserializeData<TOutput>(event.data);
178
- if (handler.current) {
179
- handler.current(payload);
180
- } else {
181
- pending.current.push(payload);
182
- }
183
- };
184
- }, [wsUrl]);
144
+ return buildUrl(wsBase, route as string, options?.subpath, queryParams);
145
+ }, [context.baseUrl, context.authHeader, route, options?.subpath, options?.query?.toString()]);
185
146
 
147
+ // Initialize manager and connect
186
148
  useEffect(() => {
187
- reconnectManagerRef.current = createReconnectManager({
188
- onReconnect: connect,
189
- threshold: 0,
190
- baseDelay: 500,
191
- factor: 2,
192
- maxDelay: 30000,
193
- jitter: 500,
194
- enabled: () => !manualClose.current,
149
+ const manager = new WebSocketManager<
150
+ WebSocketRouteInput<TRoute>,
151
+ WebSocketRouteOutput<TRoute>
152
+ >({
153
+ url: wsUrl,
154
+ callbacks: {
155
+ onConnect: () => {
156
+ setIsConnected(true);
157
+ setError(null);
158
+ setIsError(false);
159
+ setReadyState(WebSocket.OPEN);
160
+ },
161
+ onDisconnect: () => {
162
+ setIsConnected(false);
163
+ setReadyState(WebSocket.CLOSED);
164
+ },
165
+ onError: (err) => {
166
+ setError(err);
167
+ setIsError(true);
168
+ },
169
+ },
195
170
  });
196
- return () => reconnectManagerRef.current?.dispose();
197
- }, [connect]);
198
171
 
199
- const cleanup = useCallback(() => {
200
- manualClose.current = true;
201
- reconnectManagerRef.current?.dispose();
202
- const ws = wsRef.current;
203
- if (ws) {
204
- ws.onopen = null;
205
- ws.onerror = null;
206
- ws.onclose = null;
207
- ws.onmessage = null;
208
- ws.close();
209
- }
210
- wsRef.current = undefined;
211
- handler.current = undefined;
212
- pending.current = [];
213
- queued.current = [];
214
- setIsConnected(false);
215
- }, []);
172
+ // Set message handler
173
+ manager.setMessageHandler((message) => {
174
+ setData(message);
175
+ setMessages((prev) => {
176
+ const newMessages = [...prev, message];
177
+ // Enforce maxMessages limit if specified
178
+ if (options?.maxMessages && newMessages.length > options.maxMessages) {
179
+ return newMessages.slice(-options.maxMessages);
180
+ }
181
+ return newMessages;
182
+ });
183
+ });
216
184
 
217
- useEffect(() => {
218
- manualClose.current = false;
219
- connect();
185
+ manager.connect();
186
+ managerRef.current = manager;
220
187
 
221
188
  return () => {
222
- cleanup();
189
+ manager.dispose();
190
+ managerRef.current = null;
223
191
  };
224
- }, [connect, cleanup]);
192
+ }, [wsUrl, options?.maxMessages]);
225
193
 
194
+ // Handle abort signal
226
195
  useEffect(() => {
227
196
  if (options?.signal) {
228
197
  const listener = () => {
229
- cleanup();
198
+ managerRef.current?.close();
230
199
  };
231
200
  options.signal.addEventListener('abort', listener);
232
201
  return () => {
233
202
  options.signal?.removeEventListener('abort', listener);
234
203
  };
235
204
  }
236
- }, [options?.signal, cleanup]);
205
+ }, [options?.signal]);
237
206
 
238
- const reset = () => {
207
+ const reset = useCallback(() => {
239
208
  setError(null);
240
209
  setIsError(false);
241
- };
242
-
243
- const send = (data: TInput) => {
244
- if (wsRef.current?.readyState === WebSocket.OPEN) {
245
- wsRef.current.send(serializeWSData(data));
246
- } else {
247
- queued.current.push(data);
248
- }
249
- };
250
-
251
- const setHandler = useCallback((h: onMessageHandler<TOutput>) => {
252
- handler.current = h;
253
- pending.current.forEach(h);
254
- pending.current = [];
255
210
  }, []);
256
211
 
257
- const close = () => {
258
- cleanup();
259
- };
260
-
261
- return {
262
- isConnected,
263
- close,
264
- error,
265
- isError,
266
- send,
267
- setHandler,
268
- reset,
269
- readyState: wsRef.current?.readyState ?? WebSocket.CLOSED,
270
- };
271
- };
272
-
273
- /**
274
- * Type-safe WebSocket hook for connecting to WebSocket routes.
275
- *
276
- * Provides automatic type inference for route inputs and outputs based on
277
- * the WebSocketRouteRegistry generated from your routes.
278
- *
279
- * @template TRoute - WebSocket route key from WebSocketRouteRegistry (e.g., '/ws', '/chat')
280
- *
281
- * @example Simple WebSocket connection
282
- * ```typescript
283
- * const { isConnected, data, send } = useWebsocket('/ws');
284
- *
285
- * // Send typed data
286
- * send({ message: 'Hello' }); // Fully typed based on route schema!
287
- * ```
288
- *
289
- * @example WebSocket with query parameters
290
- * ```typescript
291
- * const { isConnected, data, send } = useWebsocket('/chat', {
292
- * query: new URLSearchParams({ room: 'general' })
293
- * });
294
- * ```
295
- *
296
- * @example Access all messages (prevents message loss in rapid succession)
297
- * ```typescript
298
- * const { messages, clearMessages } = useWebsocket('/chat');
299
- *
300
- * // messages array contains ALL received messages
301
- * messages.forEach(msg => console.log(msg));
302
- *
303
- * // Clear messages when needed
304
- * clearMessages();
305
- * ```
306
- */
307
- export function useWebsocket<TRoute extends WebSocketRouteKey>(
308
- route: TRoute,
309
- options?: WebsocketOptions
310
- ): Omit<
311
- WebsocketResponseInternal<WebSocketRouteInput<TRoute>, WebSocketRouteOutput<TRoute>>,
312
- 'setHandler'
313
- > & {
314
- data?: WebSocketRouteOutput<TRoute>;
315
- messages: WebSocketRouteOutput<TRoute>[];
316
- clearMessages: () => void;
317
- } {
318
- const [data, setData] = useState<WebSocketRouteOutput<TRoute>>();
319
- const [messages, setMessages] = useState<WebSocketRouteOutput<TRoute>[]>([]);
320
- const { isConnected, close, send, setHandler, readyState, error, isError, reset } =
321
- useWebsocketInternal<WebSocketRouteInput<TRoute>, WebSocketRouteOutput<TRoute>>(
322
- route as string,
323
- options
324
- );
212
+ const send = useCallback((sendData: WebSocketRouteInput<TRoute>) => {
213
+ managerRef.current?.send(sendData);
214
+ }, []);
325
215
 
326
- useEffect(() => {
327
- setHandler((message) => {
328
- setData(message);
329
- setMessages((prev) => {
330
- const newMessages = [...prev, message];
331
- // Enforce maxMessages limit if specified
332
- if (options?.maxMessages && newMessages.length > options.maxMessages) {
333
- return newMessages.slice(-options.maxMessages);
334
- }
335
- return newMessages;
336
- });
337
- });
338
- }, [route, setHandler, options?.maxMessages]);
216
+ const close = useCallback(() => {
217
+ managerRef.current?.close();
218
+ }, []);
339
219
 
340
220
  const clearMessages = useCallback(() => {
341
221
  setMessages([]);
package/dist/env.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const getProcessEnv: (key: string) => string | undefined;
2
- //# sourceMappingURL=env.d.ts.map
package/dist/env.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAQpD,CAAC"}
package/dist/env.js DELETED
@@ -1,10 +0,0 @@
1
- export const getProcessEnv = (key) => {
2
- if (typeof process !== 'undefined' && process.env) {
3
- return process.env[key];
4
- }
5
- if (typeof import.meta.env !== 'undefined') {
6
- return import.meta.env[key];
7
- }
8
- return undefined;
9
- };
10
- //# sourceMappingURL=env.js.map
package/dist/env.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAsB,EAAE;IAChE,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACnD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,WAAW,EAAE,CAAC;QAC5C,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC"}
@@ -1,22 +0,0 @@
1
- export interface ReconnectOptions {
2
- onReconnect: () => void;
3
- threshold?: number;
4
- baseDelay?: number;
5
- factor?: number;
6
- maxDelay?: number;
7
- jitter?: number;
8
- enabled?: () => boolean;
9
- }
10
- export interface ReconnectManager {
11
- recordFailure: () => {
12
- scheduled: boolean;
13
- delay: number | null;
14
- };
15
- recordSuccess: () => void;
16
- cancel: () => void;
17
- reset: () => void;
18
- dispose: () => void;
19
- getAttempts: () => number;
20
- }
21
- export declare function createReconnectManager(opts: ReconnectOptions): ReconnectManager;
22
- //# sourceMappingURL=reconnect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconnect.d.ts","sourceRoot":"","sources":["../src/reconnect.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAChC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAChC,aAAa,EAAE,MAAM;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAClE,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,MAAM,CAAC;CAC1B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAqD/E"}
package/dist/reconnect.js DELETED
@@ -1,47 +0,0 @@
1
- export function createReconnectManager(opts) {
2
- let attempts = 0;
3
- let timer = null;
4
- const cancel = () => {
5
- if (timer) {
6
- clearTimeout(timer);
7
- timer = null;
8
- }
9
- };
10
- const reset = () => {
11
- attempts = 0;
12
- cancel();
13
- };
14
- const recordSuccess = () => reset();
15
- const computeDelay = (attemptAfterThreshold) => {
16
- const base = opts.baseDelay ?? 500;
17
- const factor = opts.factor ?? 2;
18
- const max = opts.maxDelay ?? 30000;
19
- const jitterMax = opts.jitter ?? 250;
20
- const backoff = Math.min(base * Math.pow(factor, attemptAfterThreshold), max);
21
- const jitter = jitterMax > 0 ? Math.random() * jitterMax : 0;
22
- return backoff + jitter;
23
- };
24
- const recordFailure = () => {
25
- attempts += 1;
26
- const threshold = opts.threshold ?? 0;
27
- if (opts.enabled && !opts.enabled()) {
28
- return { scheduled: false, delay: null };
29
- }
30
- if (attempts - threshold >= 0) {
31
- const after = Math.max(0, attempts - threshold);
32
- const delay = computeDelay(after);
33
- cancel();
34
- timer = setTimeout(() => {
35
- if (opts.enabled && !opts.enabled())
36
- return;
37
- opts.onReconnect();
38
- }, delay);
39
- return { scheduled: true, delay };
40
- }
41
- return { scheduled: false, delay: null };
42
- };
43
- const dispose = () => cancel();
44
- const getAttempts = () => attempts;
45
- return { recordFailure, recordSuccess, cancel, reset, dispose, getAttempts };
46
- }
47
- //# sourceMappingURL=reconnect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconnect.js","sourceRoot":"","sources":["../src/reconnect.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,sBAAsB,CAAC,IAAsB;IAC5D,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,KAAK,GAAyC,IAAI,CAAC;IAEvD,MAAM,MAAM,GAAG,GAAG,EAAE;QACnB,IAAI,KAAK,EAAE,CAAC;YACX,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,GAAG,IAAI,CAAC;QACd,CAAC;IACF,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,GAAG,EAAE;QAClB,QAAQ,GAAG,CAAC,CAAC;QACb,MAAM,EAAE,CAAC;IACV,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;IAEpC,MAAM,YAAY,GAAG,CAAC,qBAA6B,EAAE,EAAE;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;QACnC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAAE,GAAG,CAAC,CAAC;QAC9E,MAAM,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,OAAO,OAAO,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,GAAG,EAAE;QAC1B,QAAQ,IAAI,CAAC,CAAC;QACd,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;QACtC,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACrC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC1C,CAAC;QAED,IAAI,QAAQ,GAAG,SAAS,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YAClC,MAAM,EAAE,CAAC;YACT,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBACvB,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;oBAAE,OAAO;gBAC5C,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,CAAC,EAAE,KAAK,CAAC,CAAC;YACV,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACnC,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;IAE/B,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC;IAEnC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAC9E,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Deserialize data received from WebSocket or EventStream.
3
- * Attempts to parse as JSON if the data looks like JSON, otherwise returns as-is.
4
- */
5
- export declare const deserializeData: <T>(data: string) => T;
6
- //# sourceMappingURL=serialization.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,MAAM,MAAM,KAAG,CASjD,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Deserialize data received from WebSocket or EventStream.
3
- * Attempts to parse as JSON if the data looks like JSON, otherwise returns as-is.
4
- */
5
- export const deserializeData = (data) => {
6
- if (data) {
7
- try {
8
- return JSON.parse(data);
9
- }
10
- catch {
11
- /* */
12
- }
13
- }
14
- return data;
15
- };
16
- //# sourceMappingURL=serialization.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAI,IAAY,EAAK,EAAE;IACrD,IAAI,IAAI,EAAE,CAAC;QACV,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACR,KAAK;QACN,CAAC;IACF,CAAC;IACD,OAAO,IAAS,CAAC;AAClB,CAAC,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * Route registry containing all typed API routes in the application.
3
- * Auto-generated by the build tool from routes that use validator() middleware.
4
- */
5
- export interface RouteRegistry {
6
- }
7
- /**
8
- * WebSocket route registry containing all typed WebSocket routes in the application.
9
- * Auto-generated by the build tool from routes that use validator() middleware.
10
- */
11
- export interface WebSocketRouteRegistry {
12
- }
13
- /**
14
- * SSE route registry containing all typed SSE routes in the application.
15
- * Auto-generated by the build tool from routes that use validator() middleware.
16
- */
17
- export interface SSERouteRegistry {
18
- }
19
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;CAG7B;AAED;;;GAGG;AAEH,MAAM,WAAW,sBAAsB;CAGtC;AAED;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;CAGhC"}
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/dist/url.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare const buildUrl: (base: string, path: string, subpath?: string, query?: URLSearchParams) => string;
2
- export declare const defaultBaseUrl: string;
3
- //# sourceMappingURL=url.d.ts.map
package/dist/url.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,GACpB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,QAAQ,eAAe,KACrB,MAWF,CAAC;AAQF,eAAO,MAAM,cAAc,EAAE,MAKL,CAAC"}
package/dist/url.js DELETED
@@ -1,24 +0,0 @@
1
- import { getProcessEnv } from './env';
2
- export const buildUrl = (base, path, subpath, query) => {
3
- path = path.startsWith('/') ? path : `/${path}`;
4
- let url = base.replace(/\/$/, '') + path;
5
- if (subpath) {
6
- subpath = subpath.startsWith('/') ? subpath : `/${subpath}`;
7
- url += `/${subpath}`;
8
- }
9
- if (query) {
10
- url += `?${query.toString()}`;
11
- }
12
- return url;
13
- };
14
- const tryOrigin = () => {
15
- if (typeof window !== 'undefined') {
16
- return window.location.origin;
17
- }
18
- };
19
- export const defaultBaseUrl = getProcessEnv('NEXT_PUBLIC_AGENTUITY_URL') ||
20
- getProcessEnv('VITE_AGENTUITY_URL') ||
21
- getProcessEnv('AGENTUITY_URL') ||
22
- tryOrigin() ||
23
- 'http://localhost:3500';
24
- //# sourceMappingURL=url.js.map
package/dist/url.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACvB,IAAY,EACZ,IAAY,EACZ,OAAgB,EAChB,KAAuB,EACd,EAAE;IACX,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAChD,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC;IACzC,IAAI,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;QAC5D,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC;IACtB,CAAC;IACD,IAAI,KAAK,EAAE,CAAC;QACX,GAAG,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACtB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC/B,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAC1B,aAAa,CAAC,2BAA2B,CAAC;IAC1C,aAAa,CAAC,oBAAoB,CAAC;IACnC,aAAa,CAAC,eAAe,CAAC;IAC9B,SAAS,EAAE;IACX,uBAAuB,CAAC"}
package/src/env.ts DELETED
@@ -1,9 +0,0 @@
1
- export const getProcessEnv = (key: string): string | undefined => {
2
- if (typeof process !== 'undefined' && process.env) {
3
- return process.env[key];
4
- }
5
- if (typeof import.meta.env !== 'undefined') {
6
- return import.meta.env[key];
7
- }
8
- return undefined;
9
- };