@antipopp/agno-client 0.9.0 → 0.11.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 +30 -1
- package/dist/index.d.mts +43 -19
- package/dist/index.d.ts +43 -19
- package/dist/index.js +1135 -478
- package/dist/index.mjs +1137 -478
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ new AgnoClient(config: AgnoClientConfig)
|
|
|
70
70
|
- `userId` (string, optional) - User ID to link sessions to a specific user
|
|
71
71
|
- `headers` (Record<string, string>, optional) - Global custom headers for all API requests
|
|
72
72
|
- `params` (Record<string, string>, optional) - Global query parameters for all API requests
|
|
73
|
+
- `dependencies` (Record<string, unknown>, optional) - Global run dependencies merged into all `sendMessage` requests
|
|
73
74
|
|
|
74
75
|
### Methods
|
|
75
76
|
|
|
@@ -83,9 +84,33 @@ await client.sendMessage('Hello!');
|
|
|
83
84
|
// With FormData (for file uploads)
|
|
84
85
|
const formData = new FormData();
|
|
85
86
|
formData.append('message', 'Hello!');
|
|
86
|
-
formData.append('
|
|
87
|
+
formData.append('files', fileBlob);
|
|
87
88
|
await client.sendMessage(formData);
|
|
88
89
|
|
|
90
|
+
// With per-request files option
|
|
91
|
+
await client.sendMessage('Hello!', {
|
|
92
|
+
files: [fileBlob]
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// With global dependencies from config
|
|
96
|
+
const dependencyClient = new AgnoClient({
|
|
97
|
+
endpoint: 'http://localhost:7777',
|
|
98
|
+
agentId: 'agent-123',
|
|
99
|
+
dependencies: {
|
|
100
|
+
tenantId: 'tenant-1',
|
|
101
|
+
locale: 'en-US'
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
await dependencyClient.sendMessage('Hello!');
|
|
105
|
+
|
|
106
|
+
// Override/extend dependencies per request
|
|
107
|
+
await dependencyClient.sendMessage('Hello!', {
|
|
108
|
+
dependencies: {
|
|
109
|
+
locale: 'fr-FR', // overrides global
|
|
110
|
+
feature: 'rag' // merged new key
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
89
114
|
// With custom headers
|
|
90
115
|
await client.sendMessage('Hello!', {
|
|
91
116
|
headers: { 'X-Custom-Header': 'value' }
|
|
@@ -314,6 +339,10 @@ await client.continueRun(tools, {
|
|
|
314
339
|
1. Global params from `config.params` (lowest precedence)
|
|
315
340
|
2. Per-request params (highest precedence - overrides global)
|
|
316
341
|
|
|
342
|
+
**Dependencies (`sendMessage` only):**
|
|
343
|
+
1. Global dependencies from `config.dependencies` (lowest precedence)
|
|
344
|
+
2. Per-request dependencies from `sendMessage(..., { dependencies })` (highest precedence - overrides global)
|
|
345
|
+
|
|
317
346
|
```typescript
|
|
318
347
|
const client = new AgnoClient({
|
|
319
348
|
endpoint: 'http://localhost:7777',
|
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AgnoClientConfig, ChatMessage, ClientState, SessionEntry, ToolCall, AgentDetails, TeamDetails } from '@antipopp/agno-types';
|
|
1
|
+
import { AgnoClientConfig, ChatMessage, ClientState, SendMessageOptions, SessionEntry, ToolCall, UIComponentSpec, AgentDetails, TeamDetails } from '@antipopp/agno-types';
|
|
3
2
|
export { AgentDetails, AgnoClientConfig, AudioData, ChatMessage, ClientState, ImageData, MessageExtraData, ResponseAudioData, RunEvent, RunResponse, RunResponseContent, SessionEntry, TeamDetails, ToolCall, VideoData } from '@antipopp/agno-types';
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Main Agno client class
|
|
7
7
|
* Provides stateful management of agent/team interactions with streaming support
|
|
8
8
|
*/
|
|
9
9
|
declare class AgnoClient extends EventEmitter {
|
|
10
|
-
private messageStore;
|
|
11
|
-
private configManager;
|
|
12
|
-
private sessionManager;
|
|
13
|
-
private eventProcessor;
|
|
14
|
-
private state;
|
|
15
|
-
private pendingUISpecs;
|
|
10
|
+
private readonly messageStore;
|
|
11
|
+
private readonly configManager;
|
|
12
|
+
private readonly sessionManager;
|
|
13
|
+
private readonly eventProcessor;
|
|
14
|
+
private readonly state;
|
|
15
|
+
private readonly pendingUISpecs;
|
|
16
|
+
private readonly localAttachmentUrls;
|
|
16
17
|
private runCompletedSuccessfully;
|
|
18
|
+
private currentRunId;
|
|
19
|
+
private currentAbortController;
|
|
17
20
|
constructor(config: AgnoClientConfig);
|
|
18
21
|
/**
|
|
19
22
|
* Get current messages
|
|
@@ -35,13 +38,22 @@ declare class AgnoClient extends EventEmitter {
|
|
|
35
38
|
* Clear all messages
|
|
36
39
|
*/
|
|
37
40
|
clearMessages(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Cancel an active or paused run
|
|
43
|
+
*/
|
|
44
|
+
cancelRun(): Promise<void>;
|
|
45
|
+
private logMissingRunIdForCancel;
|
|
46
|
+
private requestBackendCancel;
|
|
47
|
+
/**
|
|
48
|
+
* Abort the active stream without calling the backend cancel endpoint.
|
|
49
|
+
* Since streamResponse handles AbortError by returning silently
|
|
50
|
+
* (no onComplete/onError called), state cleanup is done here.
|
|
51
|
+
*/
|
|
52
|
+
abortStream(): void;
|
|
38
53
|
/**
|
|
39
54
|
* Send a message to the agent/team (streaming)
|
|
40
55
|
*/
|
|
41
|
-
sendMessage(message: string | FormData, options?:
|
|
42
|
-
headers?: Record<string, string>;
|
|
43
|
-
params?: Record<string, string>;
|
|
44
|
-
}): Promise<void>;
|
|
56
|
+
sendMessage(message: string | FormData, options?: SendMessageOptions): Promise<void>;
|
|
45
57
|
/**
|
|
46
58
|
* Handle streaming chunk
|
|
47
59
|
*/
|
|
@@ -50,6 +62,12 @@ declare class AgnoClient extends EventEmitter {
|
|
|
50
62
|
* Handle error
|
|
51
63
|
*/
|
|
52
64
|
private handleError;
|
|
65
|
+
private trackAttachmentUrls;
|
|
66
|
+
private collectAttachmentUrls;
|
|
67
|
+
private revokeAttachmentUrls;
|
|
68
|
+
private revokeAttachmentUrlsFromMessages;
|
|
69
|
+
private collectExistingUIComponents;
|
|
70
|
+
private restoreUIComponents;
|
|
53
71
|
/**
|
|
54
72
|
* Refresh messages from the session API after run completion.
|
|
55
73
|
* Replaces streamed messages with authoritative session data.
|
|
@@ -84,7 +102,7 @@ declare class AgnoClient extends EventEmitter {
|
|
|
84
102
|
* Hydrate a specific tool call with its UI component
|
|
85
103
|
* If tool call doesn't exist yet, stores UI spec as pending
|
|
86
104
|
*/
|
|
87
|
-
hydrateToolCallUI(toolCallId: string, uiSpec:
|
|
105
|
+
hydrateToolCallUI(toolCallId: string, uiSpec: UIComponentSpec): void;
|
|
88
106
|
/**
|
|
89
107
|
* Apply any pending UI specs to tool calls that have just been added
|
|
90
108
|
* Called after message updates to attach UI to newly arrived tool calls
|
|
@@ -134,6 +152,12 @@ declare class AgnoClient extends EventEmitter {
|
|
|
134
152
|
agents: AgentDetails[];
|
|
135
153
|
teams: TeamDetails[];
|
|
136
154
|
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Dispose of the client and clean up all resources.
|
|
157
|
+
* Call this method when the client is no longer needed to prevent memory leaks.
|
|
158
|
+
* After calling dispose(), the client instance should not be reused.
|
|
159
|
+
*/
|
|
160
|
+
dispose(): void;
|
|
137
161
|
}
|
|
138
162
|
|
|
139
163
|
/**
|
|
@@ -143,23 +167,23 @@ declare class AgnoClient extends EventEmitter {
|
|
|
143
167
|
/**
|
|
144
168
|
* Logger class with sanitization and environment-aware logging
|
|
145
169
|
*/
|
|
146
|
-
declare
|
|
170
|
+
declare const Logger: {
|
|
147
171
|
/**
|
|
148
172
|
* Log debug information (only in development)
|
|
149
173
|
*/
|
|
150
|
-
|
|
174
|
+
debug(message: string, data?: unknown): void;
|
|
151
175
|
/**
|
|
152
176
|
* Log informational messages (only in development)
|
|
153
177
|
*/
|
|
154
|
-
|
|
178
|
+
info(message: string, data?: unknown): void;
|
|
155
179
|
/**
|
|
156
180
|
* Log warnings (always logs)
|
|
157
181
|
*/
|
|
158
|
-
|
|
182
|
+
warn(message: string, data?: unknown): void;
|
|
159
183
|
/**
|
|
160
184
|
* Log errors (always logs)
|
|
161
185
|
*/
|
|
162
|
-
|
|
163
|
-
}
|
|
186
|
+
error(message: string, data?: unknown): void;
|
|
187
|
+
};
|
|
164
188
|
|
|
165
189
|
export { AgnoClient, Logger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AgnoClientConfig, ChatMessage, ClientState, SessionEntry, ToolCall, AgentDetails, TeamDetails } from '@antipopp/agno-types';
|
|
1
|
+
import { AgnoClientConfig, ChatMessage, ClientState, SendMessageOptions, SessionEntry, ToolCall, UIComponentSpec, AgentDetails, TeamDetails } from '@antipopp/agno-types';
|
|
3
2
|
export { AgentDetails, AgnoClientConfig, AudioData, ChatMessage, ClientState, ImageData, MessageExtraData, ResponseAudioData, RunEvent, RunResponse, RunResponseContent, SessionEntry, TeamDetails, ToolCall, VideoData } from '@antipopp/agno-types';
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Main Agno client class
|
|
7
7
|
* Provides stateful management of agent/team interactions with streaming support
|
|
8
8
|
*/
|
|
9
9
|
declare class AgnoClient extends EventEmitter {
|
|
10
|
-
private messageStore;
|
|
11
|
-
private configManager;
|
|
12
|
-
private sessionManager;
|
|
13
|
-
private eventProcessor;
|
|
14
|
-
private state;
|
|
15
|
-
private pendingUISpecs;
|
|
10
|
+
private readonly messageStore;
|
|
11
|
+
private readonly configManager;
|
|
12
|
+
private readonly sessionManager;
|
|
13
|
+
private readonly eventProcessor;
|
|
14
|
+
private readonly state;
|
|
15
|
+
private readonly pendingUISpecs;
|
|
16
|
+
private readonly localAttachmentUrls;
|
|
16
17
|
private runCompletedSuccessfully;
|
|
18
|
+
private currentRunId;
|
|
19
|
+
private currentAbortController;
|
|
17
20
|
constructor(config: AgnoClientConfig);
|
|
18
21
|
/**
|
|
19
22
|
* Get current messages
|
|
@@ -35,13 +38,22 @@ declare class AgnoClient extends EventEmitter {
|
|
|
35
38
|
* Clear all messages
|
|
36
39
|
*/
|
|
37
40
|
clearMessages(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Cancel an active or paused run
|
|
43
|
+
*/
|
|
44
|
+
cancelRun(): Promise<void>;
|
|
45
|
+
private logMissingRunIdForCancel;
|
|
46
|
+
private requestBackendCancel;
|
|
47
|
+
/**
|
|
48
|
+
* Abort the active stream without calling the backend cancel endpoint.
|
|
49
|
+
* Since streamResponse handles AbortError by returning silently
|
|
50
|
+
* (no onComplete/onError called), state cleanup is done here.
|
|
51
|
+
*/
|
|
52
|
+
abortStream(): void;
|
|
38
53
|
/**
|
|
39
54
|
* Send a message to the agent/team (streaming)
|
|
40
55
|
*/
|
|
41
|
-
sendMessage(message: string | FormData, options?:
|
|
42
|
-
headers?: Record<string, string>;
|
|
43
|
-
params?: Record<string, string>;
|
|
44
|
-
}): Promise<void>;
|
|
56
|
+
sendMessage(message: string | FormData, options?: SendMessageOptions): Promise<void>;
|
|
45
57
|
/**
|
|
46
58
|
* Handle streaming chunk
|
|
47
59
|
*/
|
|
@@ -50,6 +62,12 @@ declare class AgnoClient extends EventEmitter {
|
|
|
50
62
|
* Handle error
|
|
51
63
|
*/
|
|
52
64
|
private handleError;
|
|
65
|
+
private trackAttachmentUrls;
|
|
66
|
+
private collectAttachmentUrls;
|
|
67
|
+
private revokeAttachmentUrls;
|
|
68
|
+
private revokeAttachmentUrlsFromMessages;
|
|
69
|
+
private collectExistingUIComponents;
|
|
70
|
+
private restoreUIComponents;
|
|
53
71
|
/**
|
|
54
72
|
* Refresh messages from the session API after run completion.
|
|
55
73
|
* Replaces streamed messages with authoritative session data.
|
|
@@ -84,7 +102,7 @@ declare class AgnoClient extends EventEmitter {
|
|
|
84
102
|
* Hydrate a specific tool call with its UI component
|
|
85
103
|
* If tool call doesn't exist yet, stores UI spec as pending
|
|
86
104
|
*/
|
|
87
|
-
hydrateToolCallUI(toolCallId: string, uiSpec:
|
|
105
|
+
hydrateToolCallUI(toolCallId: string, uiSpec: UIComponentSpec): void;
|
|
88
106
|
/**
|
|
89
107
|
* Apply any pending UI specs to tool calls that have just been added
|
|
90
108
|
* Called after message updates to attach UI to newly arrived tool calls
|
|
@@ -134,6 +152,12 @@ declare class AgnoClient extends EventEmitter {
|
|
|
134
152
|
agents: AgentDetails[];
|
|
135
153
|
teams: TeamDetails[];
|
|
136
154
|
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Dispose of the client and clean up all resources.
|
|
157
|
+
* Call this method when the client is no longer needed to prevent memory leaks.
|
|
158
|
+
* After calling dispose(), the client instance should not be reused.
|
|
159
|
+
*/
|
|
160
|
+
dispose(): void;
|
|
137
161
|
}
|
|
138
162
|
|
|
139
163
|
/**
|
|
@@ -143,23 +167,23 @@ declare class AgnoClient extends EventEmitter {
|
|
|
143
167
|
/**
|
|
144
168
|
* Logger class with sanitization and environment-aware logging
|
|
145
169
|
*/
|
|
146
|
-
declare
|
|
170
|
+
declare const Logger: {
|
|
147
171
|
/**
|
|
148
172
|
* Log debug information (only in development)
|
|
149
173
|
*/
|
|
150
|
-
|
|
174
|
+
debug(message: string, data?: unknown): void;
|
|
151
175
|
/**
|
|
152
176
|
* Log informational messages (only in development)
|
|
153
177
|
*/
|
|
154
|
-
|
|
178
|
+
info(message: string, data?: unknown): void;
|
|
155
179
|
/**
|
|
156
180
|
* Log warnings (always logs)
|
|
157
181
|
*/
|
|
158
|
-
|
|
182
|
+
warn(message: string, data?: unknown): void;
|
|
159
183
|
/**
|
|
160
184
|
* Log errors (always logs)
|
|
161
185
|
*/
|
|
162
|
-
|
|
163
|
-
}
|
|
186
|
+
error(message: string, data?: unknown): void;
|
|
187
|
+
};
|
|
164
188
|
|
|
165
189
|
export { AgnoClient, Logger };
|