@antipopp/agno-client 0.10.0 → 0.12.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 +25 -12
- package/dist/index.d.ts +25 -12
- package/dist/index.js +890 -332
- package/dist/index.mjs +890 -332
- package/package.json +2 -2
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,4 +1,4 @@
|
|
|
1
|
-
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';
|
|
2
2
|
export { AgentDetails, AgnoClientConfig, AudioData, ChatMessage, ClientState, ImageData, MessageExtraData, ResponseAudioData, RunEvent, RunResponse, RunResponseContent, SessionEntry, TeamDetails, ToolCall, VideoData } from '@antipopp/agno-types';
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
4
|
|
|
@@ -13,8 +13,10 @@ declare class AgnoClient extends EventEmitter {
|
|
|
13
13
|
private readonly eventProcessor;
|
|
14
14
|
private readonly state;
|
|
15
15
|
private readonly pendingUISpecs;
|
|
16
|
+
private readonly localAttachmentUrls;
|
|
16
17
|
private runCompletedSuccessfully;
|
|
17
18
|
private currentRunId;
|
|
19
|
+
private currentAbortController;
|
|
18
20
|
constructor(config: AgnoClientConfig);
|
|
19
21
|
/**
|
|
20
22
|
* Get current messages
|
|
@@ -40,13 +42,18 @@ declare class AgnoClient extends EventEmitter {
|
|
|
40
42
|
* Cancel an active or paused run
|
|
41
43
|
*/
|
|
42
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;
|
|
43
53
|
/**
|
|
44
54
|
* Send a message to the agent/team (streaming)
|
|
45
55
|
*/
|
|
46
|
-
sendMessage(message: string | FormData, options?:
|
|
47
|
-
headers?: Record<string, string>;
|
|
48
|
-
params?: Record<string, string>;
|
|
49
|
-
}): Promise<void>;
|
|
56
|
+
sendMessage(message: string | FormData, options?: SendMessageOptions): Promise<void>;
|
|
50
57
|
/**
|
|
51
58
|
* Handle streaming chunk
|
|
52
59
|
*/
|
|
@@ -55,6 +62,12 @@ declare class AgnoClient extends EventEmitter {
|
|
|
55
62
|
* Handle error
|
|
56
63
|
*/
|
|
57
64
|
private handleError;
|
|
65
|
+
private trackAttachmentUrls;
|
|
66
|
+
private collectAttachmentUrls;
|
|
67
|
+
private revokeAttachmentUrls;
|
|
68
|
+
private revokeAttachmentUrlsFromMessages;
|
|
69
|
+
private collectExistingUIComponents;
|
|
70
|
+
private restoreUIComponents;
|
|
58
71
|
/**
|
|
59
72
|
* Refresh messages from the session API after run completion.
|
|
60
73
|
* Replaces streamed messages with authoritative session data.
|
|
@@ -89,7 +102,7 @@ declare class AgnoClient extends EventEmitter {
|
|
|
89
102
|
* Hydrate a specific tool call with its UI component
|
|
90
103
|
* If tool call doesn't exist yet, stores UI spec as pending
|
|
91
104
|
*/
|
|
92
|
-
hydrateToolCallUI(toolCallId: string, uiSpec:
|
|
105
|
+
hydrateToolCallUI(toolCallId: string, uiSpec: UIComponentSpec): void;
|
|
93
106
|
/**
|
|
94
107
|
* Apply any pending UI specs to tool calls that have just been added
|
|
95
108
|
* Called after message updates to attach UI to newly arrived tool calls
|
|
@@ -154,23 +167,23 @@ declare class AgnoClient extends EventEmitter {
|
|
|
154
167
|
/**
|
|
155
168
|
* Logger class with sanitization and environment-aware logging
|
|
156
169
|
*/
|
|
157
|
-
declare
|
|
170
|
+
declare const Logger: {
|
|
158
171
|
/**
|
|
159
172
|
* Log debug information (only in development)
|
|
160
173
|
*/
|
|
161
|
-
|
|
174
|
+
debug(message: string, data?: unknown): void;
|
|
162
175
|
/**
|
|
163
176
|
* Log informational messages (only in development)
|
|
164
177
|
*/
|
|
165
|
-
|
|
178
|
+
info(message: string, data?: unknown): void;
|
|
166
179
|
/**
|
|
167
180
|
* Log warnings (always logs)
|
|
168
181
|
*/
|
|
169
|
-
|
|
182
|
+
warn(message: string, data?: unknown): void;
|
|
170
183
|
/**
|
|
171
184
|
* Log errors (always logs)
|
|
172
185
|
*/
|
|
173
|
-
|
|
174
|
-
}
|
|
186
|
+
error(message: string, data?: unknown): void;
|
|
187
|
+
};
|
|
175
188
|
|
|
176
189
|
export { AgnoClient, Logger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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';
|
|
2
2
|
export { AgentDetails, AgnoClientConfig, AudioData, ChatMessage, ClientState, ImageData, MessageExtraData, ResponseAudioData, RunEvent, RunResponse, RunResponseContent, SessionEntry, TeamDetails, ToolCall, VideoData } from '@antipopp/agno-types';
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
4
|
|
|
@@ -13,8 +13,10 @@ declare class AgnoClient extends EventEmitter {
|
|
|
13
13
|
private readonly eventProcessor;
|
|
14
14
|
private readonly state;
|
|
15
15
|
private readonly pendingUISpecs;
|
|
16
|
+
private readonly localAttachmentUrls;
|
|
16
17
|
private runCompletedSuccessfully;
|
|
17
18
|
private currentRunId;
|
|
19
|
+
private currentAbortController;
|
|
18
20
|
constructor(config: AgnoClientConfig);
|
|
19
21
|
/**
|
|
20
22
|
* Get current messages
|
|
@@ -40,13 +42,18 @@ declare class AgnoClient extends EventEmitter {
|
|
|
40
42
|
* Cancel an active or paused run
|
|
41
43
|
*/
|
|
42
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;
|
|
43
53
|
/**
|
|
44
54
|
* Send a message to the agent/team (streaming)
|
|
45
55
|
*/
|
|
46
|
-
sendMessage(message: string | FormData, options?:
|
|
47
|
-
headers?: Record<string, string>;
|
|
48
|
-
params?: Record<string, string>;
|
|
49
|
-
}): Promise<void>;
|
|
56
|
+
sendMessage(message: string | FormData, options?: SendMessageOptions): Promise<void>;
|
|
50
57
|
/**
|
|
51
58
|
* Handle streaming chunk
|
|
52
59
|
*/
|
|
@@ -55,6 +62,12 @@ declare class AgnoClient extends EventEmitter {
|
|
|
55
62
|
* Handle error
|
|
56
63
|
*/
|
|
57
64
|
private handleError;
|
|
65
|
+
private trackAttachmentUrls;
|
|
66
|
+
private collectAttachmentUrls;
|
|
67
|
+
private revokeAttachmentUrls;
|
|
68
|
+
private revokeAttachmentUrlsFromMessages;
|
|
69
|
+
private collectExistingUIComponents;
|
|
70
|
+
private restoreUIComponents;
|
|
58
71
|
/**
|
|
59
72
|
* Refresh messages from the session API after run completion.
|
|
60
73
|
* Replaces streamed messages with authoritative session data.
|
|
@@ -89,7 +102,7 @@ declare class AgnoClient extends EventEmitter {
|
|
|
89
102
|
* Hydrate a specific tool call with its UI component
|
|
90
103
|
* If tool call doesn't exist yet, stores UI spec as pending
|
|
91
104
|
*/
|
|
92
|
-
hydrateToolCallUI(toolCallId: string, uiSpec:
|
|
105
|
+
hydrateToolCallUI(toolCallId: string, uiSpec: UIComponentSpec): void;
|
|
93
106
|
/**
|
|
94
107
|
* Apply any pending UI specs to tool calls that have just been added
|
|
95
108
|
* Called after message updates to attach UI to newly arrived tool calls
|
|
@@ -154,23 +167,23 @@ declare class AgnoClient extends EventEmitter {
|
|
|
154
167
|
/**
|
|
155
168
|
* Logger class with sanitization and environment-aware logging
|
|
156
169
|
*/
|
|
157
|
-
declare
|
|
170
|
+
declare const Logger: {
|
|
158
171
|
/**
|
|
159
172
|
* Log debug information (only in development)
|
|
160
173
|
*/
|
|
161
|
-
|
|
174
|
+
debug(message: string, data?: unknown): void;
|
|
162
175
|
/**
|
|
163
176
|
* Log informational messages (only in development)
|
|
164
177
|
*/
|
|
165
|
-
|
|
178
|
+
info(message: string, data?: unknown): void;
|
|
166
179
|
/**
|
|
167
180
|
* Log warnings (always logs)
|
|
168
181
|
*/
|
|
169
|
-
|
|
182
|
+
warn(message: string, data?: unknown): void;
|
|
170
183
|
/**
|
|
171
184
|
* Log errors (always logs)
|
|
172
185
|
*/
|
|
173
|
-
|
|
174
|
-
}
|
|
186
|
+
error(message: string, data?: unknown): void;
|
|
187
|
+
};
|
|
175
188
|
|
|
176
189
|
export { AgnoClient, Logger };
|