@antipopp/agno-react 0.8.0 → 0.9.0
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 +34 -4
- package/dist/index.d.mts +23 -7
- package/dist/index.d.ts +23 -7
- package/dist/index.js +14 -14
- package/dist/index.mjs +14 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -33,6 +33,12 @@ function App() {
|
|
|
33
33
|
mode: 'agent',
|
|
34
34
|
agentId: 'your-agent-id',
|
|
35
35
|
userId: 'user-123', // Optional: Link sessions to a user
|
|
36
|
+
headers: { // Optional: Global headers for all requests
|
|
37
|
+
'X-API-Version': 'v2'
|
|
38
|
+
},
|
|
39
|
+
params: { // Optional: Global query params for all requests
|
|
40
|
+
locale: 'en-US'
|
|
41
|
+
}
|
|
36
42
|
}}
|
|
37
43
|
>
|
|
38
44
|
<YourComponents />
|
|
@@ -134,6 +140,17 @@ await sendMessage(formData);
|
|
|
134
140
|
await sendMessage('Hello!', {
|
|
135
141
|
headers: { 'X-Custom': 'value' }
|
|
136
142
|
});
|
|
143
|
+
|
|
144
|
+
// Send with query parameters
|
|
145
|
+
await sendMessage('Hello!', {
|
|
146
|
+
params: { temperature: '0.7', max_tokens: '500' }
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Send with both headers and params
|
|
150
|
+
await sendMessage('Hello!', {
|
|
151
|
+
headers: { 'X-Request-ID': '12345' },
|
|
152
|
+
params: { debug: 'true' }
|
|
153
|
+
});
|
|
137
154
|
```
|
|
138
155
|
|
|
139
156
|
#### `clearMessages()`
|
|
@@ -164,14 +181,20 @@ function SessionList() {
|
|
|
164
181
|
const { sessions, loadSession, fetchSessions } = useAgnoSession();
|
|
165
182
|
|
|
166
183
|
useEffect(() => {
|
|
167
|
-
|
|
184
|
+
// Fetch sessions with optional query params
|
|
185
|
+
fetchSessions({ params: { limit: '50', status: 'active' } });
|
|
168
186
|
}, [fetchSessions]);
|
|
169
187
|
|
|
188
|
+
const handleLoadSession = (sessionId: string) => {
|
|
189
|
+
// Load session with optional params
|
|
190
|
+
loadSession(sessionId, { params: { include_metadata: 'true' } });
|
|
191
|
+
};
|
|
192
|
+
|
|
170
193
|
return (
|
|
171
194
|
<ul>
|
|
172
195
|
{sessions.map((session) => (
|
|
173
196
|
<li key={session.session_id}>
|
|
174
|
-
<button onClick={() =>
|
|
197
|
+
<button onClick={() => handleLoadSession(session.session_id)}>
|
|
175
198
|
{session.session_name}
|
|
176
199
|
</button>
|
|
177
200
|
</li>
|
|
@@ -201,13 +224,19 @@ const {
|
|
|
201
224
|
|
|
202
225
|
```tsx
|
|
203
226
|
function InitComponent() {
|
|
204
|
-
const { initialize, updateConfig, isInitializing } = useAgnoActions();
|
|
227
|
+
const { initialize, fetchAgents, updateConfig, isInitializing } = useAgnoActions();
|
|
205
228
|
const { state } = useAgnoChat();
|
|
206
229
|
|
|
207
230
|
useEffect(() => {
|
|
208
|
-
|
|
231
|
+
// Initialize with optional params
|
|
232
|
+
initialize({ params: { filter: 'active' } });
|
|
209
233
|
}, [initialize]);
|
|
210
234
|
|
|
235
|
+
const loadMoreAgents = () => {
|
|
236
|
+
// Fetch agents with custom params
|
|
237
|
+
fetchAgents({ params: { page: '2', limit: '20' } });
|
|
238
|
+
};
|
|
239
|
+
|
|
211
240
|
const switchAgent = (agentId: string) => {
|
|
212
241
|
updateConfig({ agentId, mode: 'agent' });
|
|
213
242
|
};
|
|
@@ -222,6 +251,7 @@ function InitComponent() {
|
|
|
222
251
|
{agent.name}
|
|
223
252
|
</button>
|
|
224
253
|
))}
|
|
254
|
+
<button onClick={loadMoreAgents}>Load More</button>
|
|
225
255
|
</div>
|
|
226
256
|
);
|
|
227
257
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -71,7 +71,10 @@ declare function useAgnoToolExecution(handlers?: Record<string, ToolHandler>, au
|
|
|
71
71
|
/** Execute specific tools and return results without continuing */
|
|
72
72
|
executeTools: (tools: ToolCall[]) => Promise<ToolCall[]>;
|
|
73
73
|
/** Continue the run with manually provided tool results */
|
|
74
|
-
continueWithResults: (tools: ToolCall[]
|
|
74
|
+
continueWithResults: (tools: ToolCall[], options?: {
|
|
75
|
+
headers?: Record<string, string>;
|
|
76
|
+
params?: Record<string, string>;
|
|
77
|
+
}) => Promise<void>;
|
|
75
78
|
/** Error from tool execution, if any */
|
|
76
79
|
executionError: string | undefined;
|
|
77
80
|
};
|
|
@@ -374,6 +377,7 @@ declare function useAgnoChat(): {
|
|
|
374
377
|
messages: ChatMessage[];
|
|
375
378
|
sendMessage: (message: string | FormData, options?: {
|
|
376
379
|
headers?: Record<string, string>;
|
|
380
|
+
params?: Record<string, string>;
|
|
377
381
|
}) => Promise<void>;
|
|
378
382
|
clearMessages: () => void;
|
|
379
383
|
isStreaming: boolean;
|
|
@@ -389,8 +393,12 @@ declare function useAgnoChat(): {
|
|
|
389
393
|
declare function useAgnoSession(): {
|
|
390
394
|
sessions: SessionEntry[];
|
|
391
395
|
currentSessionId: string | undefined;
|
|
392
|
-
loadSession: (sessionId: string
|
|
393
|
-
|
|
396
|
+
loadSession: (sessionId: string, options?: {
|
|
397
|
+
params?: Record<string, string>;
|
|
398
|
+
}) => Promise<ChatMessage[]>;
|
|
399
|
+
fetchSessions: (options?: {
|
|
400
|
+
params?: Record<string, string>;
|
|
401
|
+
}) => Promise<SessionEntry[]>;
|
|
394
402
|
isLoading: boolean;
|
|
395
403
|
error: string | undefined;
|
|
396
404
|
};
|
|
@@ -399,13 +407,21 @@ declare function useAgnoSession(): {
|
|
|
399
407
|
* Hook for common actions like initialization, fetching agents/teams
|
|
400
408
|
*/
|
|
401
409
|
declare function useAgnoActions(): {
|
|
402
|
-
initialize: (
|
|
410
|
+
initialize: (options?: {
|
|
411
|
+
params?: Record<string, string>;
|
|
412
|
+
}) => Promise<{
|
|
403
413
|
agents: AgentDetails[];
|
|
404
414
|
teams: TeamDetails[];
|
|
405
415
|
}>;
|
|
406
|
-
checkStatus: (
|
|
407
|
-
|
|
408
|
-
|
|
416
|
+
checkStatus: (options?: {
|
|
417
|
+
params?: Record<string, string>;
|
|
418
|
+
}) => Promise<boolean>;
|
|
419
|
+
fetchAgents: (options?: {
|
|
420
|
+
params?: Record<string, string>;
|
|
421
|
+
}) => Promise<AgentDetails[]>;
|
|
422
|
+
fetchTeams: (options?: {
|
|
423
|
+
params?: Record<string, string>;
|
|
424
|
+
}) => Promise<TeamDetails[]>;
|
|
409
425
|
updateConfig: (updates: Partial<Parameters<(updates: Partial<_antipopp_agno_types.AgnoClientConfig>) => void>[0]>) => void;
|
|
410
426
|
isInitializing: boolean;
|
|
411
427
|
error: string | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,10 @@ declare function useAgnoToolExecution(handlers?: Record<string, ToolHandler>, au
|
|
|
71
71
|
/** Execute specific tools and return results without continuing */
|
|
72
72
|
executeTools: (tools: ToolCall[]) => Promise<ToolCall[]>;
|
|
73
73
|
/** Continue the run with manually provided tool results */
|
|
74
|
-
continueWithResults: (tools: ToolCall[]
|
|
74
|
+
continueWithResults: (tools: ToolCall[], options?: {
|
|
75
|
+
headers?: Record<string, string>;
|
|
76
|
+
params?: Record<string, string>;
|
|
77
|
+
}) => Promise<void>;
|
|
75
78
|
/** Error from tool execution, if any */
|
|
76
79
|
executionError: string | undefined;
|
|
77
80
|
};
|
|
@@ -374,6 +377,7 @@ declare function useAgnoChat(): {
|
|
|
374
377
|
messages: ChatMessage[];
|
|
375
378
|
sendMessage: (message: string | FormData, options?: {
|
|
376
379
|
headers?: Record<string, string>;
|
|
380
|
+
params?: Record<string, string>;
|
|
377
381
|
}) => Promise<void>;
|
|
378
382
|
clearMessages: () => void;
|
|
379
383
|
isStreaming: boolean;
|
|
@@ -389,8 +393,12 @@ declare function useAgnoChat(): {
|
|
|
389
393
|
declare function useAgnoSession(): {
|
|
390
394
|
sessions: SessionEntry[];
|
|
391
395
|
currentSessionId: string | undefined;
|
|
392
|
-
loadSession: (sessionId: string
|
|
393
|
-
|
|
396
|
+
loadSession: (sessionId: string, options?: {
|
|
397
|
+
params?: Record<string, string>;
|
|
398
|
+
}) => Promise<ChatMessage[]>;
|
|
399
|
+
fetchSessions: (options?: {
|
|
400
|
+
params?: Record<string, string>;
|
|
401
|
+
}) => Promise<SessionEntry[]>;
|
|
394
402
|
isLoading: boolean;
|
|
395
403
|
error: string | undefined;
|
|
396
404
|
};
|
|
@@ -399,13 +407,21 @@ declare function useAgnoSession(): {
|
|
|
399
407
|
* Hook for common actions like initialization, fetching agents/teams
|
|
400
408
|
*/
|
|
401
409
|
declare function useAgnoActions(): {
|
|
402
|
-
initialize: (
|
|
410
|
+
initialize: (options?: {
|
|
411
|
+
params?: Record<string, string>;
|
|
412
|
+
}) => Promise<{
|
|
403
413
|
agents: AgentDetails[];
|
|
404
414
|
teams: TeamDetails[];
|
|
405
415
|
}>;
|
|
406
|
-
checkStatus: (
|
|
407
|
-
|
|
408
|
-
|
|
416
|
+
checkStatus: (options?: {
|
|
417
|
+
params?: Record<string, string>;
|
|
418
|
+
}) => Promise<boolean>;
|
|
419
|
+
fetchAgents: (options?: {
|
|
420
|
+
params?: Record<string, string>;
|
|
421
|
+
}) => Promise<AgentDetails[]>;
|
|
422
|
+
fetchTeams: (options?: {
|
|
423
|
+
params?: Record<string, string>;
|
|
424
|
+
}) => Promise<TeamDetails[]>;
|
|
409
425
|
updateConfig: (updates: Partial<Parameters<(updates: Partial<_antipopp_agno_types.AgnoClientConfig>) => void>[0]>) => void;
|
|
410
426
|
isInitializing: boolean;
|
|
411
427
|
error: string | undefined;
|
package/dist/index.js
CHANGED
|
@@ -399,13 +399,13 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
|
|
|
399
399
|
[mergedHandlers]
|
|
400
400
|
);
|
|
401
401
|
const continueWithResults = (0, import_react3.useCallback)(
|
|
402
|
-
async (tools) => {
|
|
402
|
+
async (tools, options) => {
|
|
403
403
|
if (!isPaused) {
|
|
404
404
|
throw new Error("No paused run to continue");
|
|
405
405
|
}
|
|
406
406
|
setIsExecuting(true);
|
|
407
407
|
try {
|
|
408
|
-
await client.continueRun(tools);
|
|
408
|
+
await client.continueRun(tools, options);
|
|
409
409
|
} catch (error) {
|
|
410
410
|
setIsExecuting(false);
|
|
411
411
|
throw error;
|
|
@@ -887,11 +887,11 @@ function useAgnoSession() {
|
|
|
887
887
|
};
|
|
888
888
|
}, [client]);
|
|
889
889
|
const loadSession = (0, import_react6.useCallback)(
|
|
890
|
-
async (sessionId) => {
|
|
890
|
+
async (sessionId, options) => {
|
|
891
891
|
setIsLoading(true);
|
|
892
892
|
setError(void 0);
|
|
893
893
|
try {
|
|
894
|
-
const messages = await client.loadSession(sessionId);
|
|
894
|
+
const messages = await client.loadSession(sessionId, options);
|
|
895
895
|
setCurrentSessionId(sessionId);
|
|
896
896
|
return messages;
|
|
897
897
|
} catch (err) {
|
|
@@ -904,11 +904,11 @@ function useAgnoSession() {
|
|
|
904
904
|
},
|
|
905
905
|
[client]
|
|
906
906
|
);
|
|
907
|
-
const fetchSessions = (0, import_react6.useCallback)(async () => {
|
|
907
|
+
const fetchSessions = (0, import_react6.useCallback)(async (options) => {
|
|
908
908
|
setIsLoading(true);
|
|
909
909
|
setError(void 0);
|
|
910
910
|
try {
|
|
911
|
-
const fetchedSessions = await client.fetchSessions();
|
|
911
|
+
const fetchedSessions = await client.fetchSessions(options);
|
|
912
912
|
setSessions(fetchedSessions);
|
|
913
913
|
return fetchedSessions;
|
|
914
914
|
} catch (err) {
|
|
@@ -935,11 +935,11 @@ function useAgnoActions() {
|
|
|
935
935
|
const client = useAgnoClient();
|
|
936
936
|
const [isInitializing, setIsInitializing] = (0, import_react7.useState)(false);
|
|
937
937
|
const [error, setError] = (0, import_react7.useState)();
|
|
938
|
-
const initialize = (0, import_react7.useCallback)(async () => {
|
|
938
|
+
const initialize = (0, import_react7.useCallback)(async (options) => {
|
|
939
939
|
setIsInitializing(true);
|
|
940
940
|
setError(void 0);
|
|
941
941
|
try {
|
|
942
|
-
const result = await client.initialize();
|
|
942
|
+
const result = await client.initialize(options);
|
|
943
943
|
return result;
|
|
944
944
|
} catch (err) {
|
|
945
945
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
@@ -949,30 +949,30 @@ function useAgnoActions() {
|
|
|
949
949
|
setIsInitializing(false);
|
|
950
950
|
}
|
|
951
951
|
}, [client]);
|
|
952
|
-
const checkStatus = (0, import_react7.useCallback)(async () => {
|
|
952
|
+
const checkStatus = (0, import_react7.useCallback)(async (options) => {
|
|
953
953
|
setError(void 0);
|
|
954
954
|
try {
|
|
955
|
-
return await client.checkStatus();
|
|
955
|
+
return await client.checkStatus(options);
|
|
956
956
|
} catch (err) {
|
|
957
957
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
958
958
|
setError(errorMessage);
|
|
959
959
|
return false;
|
|
960
960
|
}
|
|
961
961
|
}, [client]);
|
|
962
|
-
const fetchAgents = (0, import_react7.useCallback)(async () => {
|
|
962
|
+
const fetchAgents = (0, import_react7.useCallback)(async (options) => {
|
|
963
963
|
setError(void 0);
|
|
964
964
|
try {
|
|
965
|
-
return await client.fetchAgents();
|
|
965
|
+
return await client.fetchAgents(options);
|
|
966
966
|
} catch (err) {
|
|
967
967
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
968
968
|
setError(errorMessage);
|
|
969
969
|
throw err;
|
|
970
970
|
}
|
|
971
971
|
}, [client]);
|
|
972
|
-
const fetchTeams = (0, import_react7.useCallback)(async () => {
|
|
972
|
+
const fetchTeams = (0, import_react7.useCallback)(async (options) => {
|
|
973
973
|
setError(void 0);
|
|
974
974
|
try {
|
|
975
|
-
return await client.fetchTeams();
|
|
975
|
+
return await client.fetchTeams(options);
|
|
976
976
|
} catch (err) {
|
|
977
977
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
978
978
|
setError(errorMessage);
|
package/dist/index.mjs
CHANGED
|
@@ -334,13 +334,13 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
|
|
|
334
334
|
[mergedHandlers]
|
|
335
335
|
);
|
|
336
336
|
const continueWithResults = useCallback2(
|
|
337
|
-
async (tools) => {
|
|
337
|
+
async (tools, options) => {
|
|
338
338
|
if (!isPaused) {
|
|
339
339
|
throw new Error("No paused run to continue");
|
|
340
340
|
}
|
|
341
341
|
setIsExecuting(true);
|
|
342
342
|
try {
|
|
343
|
-
await client.continueRun(tools);
|
|
343
|
+
await client.continueRun(tools, options);
|
|
344
344
|
} catch (error) {
|
|
345
345
|
setIsExecuting(false);
|
|
346
346
|
throw error;
|
|
@@ -822,11 +822,11 @@ function useAgnoSession() {
|
|
|
822
822
|
};
|
|
823
823
|
}, [client]);
|
|
824
824
|
const loadSession = useCallback4(
|
|
825
|
-
async (sessionId) => {
|
|
825
|
+
async (sessionId, options) => {
|
|
826
826
|
setIsLoading(true);
|
|
827
827
|
setError(void 0);
|
|
828
828
|
try {
|
|
829
|
-
const messages = await client.loadSession(sessionId);
|
|
829
|
+
const messages = await client.loadSession(sessionId, options);
|
|
830
830
|
setCurrentSessionId(sessionId);
|
|
831
831
|
return messages;
|
|
832
832
|
} catch (err) {
|
|
@@ -839,11 +839,11 @@ function useAgnoSession() {
|
|
|
839
839
|
},
|
|
840
840
|
[client]
|
|
841
841
|
);
|
|
842
|
-
const fetchSessions = useCallback4(async () => {
|
|
842
|
+
const fetchSessions = useCallback4(async (options) => {
|
|
843
843
|
setIsLoading(true);
|
|
844
844
|
setError(void 0);
|
|
845
845
|
try {
|
|
846
|
-
const fetchedSessions = await client.fetchSessions();
|
|
846
|
+
const fetchedSessions = await client.fetchSessions(options);
|
|
847
847
|
setSessions(fetchedSessions);
|
|
848
848
|
return fetchedSessions;
|
|
849
849
|
} catch (err) {
|
|
@@ -870,11 +870,11 @@ function useAgnoActions() {
|
|
|
870
870
|
const client = useAgnoClient();
|
|
871
871
|
const [isInitializing, setIsInitializing] = useState5(false);
|
|
872
872
|
const [error, setError] = useState5();
|
|
873
|
-
const initialize = useCallback5(async () => {
|
|
873
|
+
const initialize = useCallback5(async (options) => {
|
|
874
874
|
setIsInitializing(true);
|
|
875
875
|
setError(void 0);
|
|
876
876
|
try {
|
|
877
|
-
const result = await client.initialize();
|
|
877
|
+
const result = await client.initialize(options);
|
|
878
878
|
return result;
|
|
879
879
|
} catch (err) {
|
|
880
880
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
@@ -884,30 +884,30 @@ function useAgnoActions() {
|
|
|
884
884
|
setIsInitializing(false);
|
|
885
885
|
}
|
|
886
886
|
}, [client]);
|
|
887
|
-
const checkStatus = useCallback5(async () => {
|
|
887
|
+
const checkStatus = useCallback5(async (options) => {
|
|
888
888
|
setError(void 0);
|
|
889
889
|
try {
|
|
890
|
-
return await client.checkStatus();
|
|
890
|
+
return await client.checkStatus(options);
|
|
891
891
|
} catch (err) {
|
|
892
892
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
893
893
|
setError(errorMessage);
|
|
894
894
|
return false;
|
|
895
895
|
}
|
|
896
896
|
}, [client]);
|
|
897
|
-
const fetchAgents = useCallback5(async () => {
|
|
897
|
+
const fetchAgents = useCallback5(async (options) => {
|
|
898
898
|
setError(void 0);
|
|
899
899
|
try {
|
|
900
|
-
return await client.fetchAgents();
|
|
900
|
+
return await client.fetchAgents(options);
|
|
901
901
|
} catch (err) {
|
|
902
902
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
903
903
|
setError(errorMessage);
|
|
904
904
|
throw err;
|
|
905
905
|
}
|
|
906
906
|
}, [client]);
|
|
907
|
-
const fetchTeams = useCallback5(async () => {
|
|
907
|
+
const fetchTeams = useCallback5(async (options) => {
|
|
908
908
|
setError(void 0);
|
|
909
909
|
try {
|
|
910
|
-
return await client.fetchTeams();
|
|
910
|
+
return await client.fetchTeams(options);
|
|
911
911
|
} catch (err) {
|
|
912
912
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
913
913
|
setError(errorMessage);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antipopp/agno-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "React hooks for Agno client with frontend tool execution (HITL) support",
|
|
5
5
|
"author": "antipopp",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@antipopp/agno-client": "0.
|
|
38
|
-
"@antipopp/agno-types": "0.
|
|
37
|
+
"@antipopp/agno-client": "0.9.0",
|
|
38
|
+
"@antipopp/agno-types": "0.9.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": "^18.0.0 || ^19.0.0"
|