@cadraos/sdk 0.1.2 → 0.1.4
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 +1 -1
- package/dist/chat/index.cjs +2874 -102
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +2616 -478
- package/dist/chat/index.d.ts +2616 -478
- package/dist/chat/index.js +2874 -102
- package/dist/chat/index.js.map +1 -1
- package/dist/index.cjs +267 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +195 -3
- package/dist/index.d.ts +195 -3
- package/dist/index.js +267 -24
- package/dist/index.js.map +1 -1
- package/package.json +14 -9
package/dist/chat/index.d.ts
CHANGED
|
@@ -1,256 +1,28 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import { Components } from 'react-markdown';
|
|
3
|
+
import * as React$1 from 'react';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* Implement this interface to:
|
|
8
|
-
* - Connect to different backends
|
|
9
|
-
* - Use direct DB access (in ai-saas-v2)
|
|
10
|
-
* - Mock for testing
|
|
11
|
-
*
|
|
12
|
-
* @module @cadraos/sdk/chat
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Input for starting an agent execution
|
|
16
|
-
*/
|
|
17
|
-
interface StartExecutionInput {
|
|
18
|
-
/** UUID of the agent to execute */
|
|
19
|
-
agentId: string;
|
|
20
|
-
/** Optional session ID for continuing a conversation */
|
|
21
|
-
sessionId?: string;
|
|
22
|
-
/** User message content */
|
|
23
|
-
content: string;
|
|
24
|
-
/** UUIDs of attached files */
|
|
25
|
-
attachmentUuids?: string[];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Input for sending a message in an existing session
|
|
29
|
-
*/
|
|
30
|
-
interface SendMessageInput {
|
|
31
|
-
/** Session ID */
|
|
32
|
-
sessionId: string;
|
|
33
|
-
/** Message content */
|
|
34
|
-
content: string;
|
|
35
|
-
/** UUIDs of attached files */
|
|
36
|
-
attachmentUuids?: string[];
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Input for getting an upload URL
|
|
40
|
-
*/
|
|
41
|
-
interface UploadUrlInput {
|
|
42
|
-
/** Session ID */
|
|
43
|
-
sessionId: string;
|
|
44
|
-
/** Filename */
|
|
45
|
-
filename: string;
|
|
46
|
-
/** MIME type */
|
|
47
|
-
mimeType: string;
|
|
48
|
-
/** File size in bytes */
|
|
49
|
-
size: number;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Result from starting an execution
|
|
53
|
-
*/
|
|
54
|
-
interface ExecutionResult {
|
|
55
|
-
/** UUID of the created execution */
|
|
56
|
-
executionId: string;
|
|
57
|
-
/** UUID of the session (new or existing) */
|
|
58
|
-
sessionId: string;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Result from getting an upload URL
|
|
62
|
-
*/
|
|
63
|
-
interface UploadUrlResult {
|
|
64
|
-
/** Pre-signed upload URL */
|
|
65
|
-
uploadUrl: string;
|
|
66
|
-
/** UUID for the attachment */
|
|
67
|
-
attachmentUuid: string;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Execution status and result
|
|
71
|
-
*/
|
|
72
|
-
interface Execution {
|
|
73
|
-
/** Execution UUID */
|
|
74
|
-
uuid: string;
|
|
75
|
-
/** Current status */
|
|
76
|
-
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
77
|
-
/** Final result (when completed) */
|
|
78
|
-
result?: string;
|
|
79
|
-
/** Error message (when failed) */
|
|
80
|
-
error?: string;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Artifact generated during execution
|
|
84
|
-
*/
|
|
85
|
-
interface Artifact {
|
|
86
|
-
/** Artifact UUID */
|
|
87
|
-
uuid: string;
|
|
88
|
-
/** Artifact type */
|
|
89
|
-
type: "image" | "document" | "code" | "audio";
|
|
90
|
-
/** Filename */
|
|
91
|
-
filename: string;
|
|
92
|
-
/** MIME type */
|
|
93
|
-
mimeType: string;
|
|
94
|
-
/** Download URL */
|
|
95
|
-
url: string;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Attachment metadata for history messages
|
|
99
|
-
*/
|
|
100
|
-
interface HistoryAttachment {
|
|
101
|
-
/** Attachment UUID */
|
|
102
|
-
uuid: string;
|
|
103
|
-
/** Original filename */
|
|
104
|
-
filename: string;
|
|
105
|
-
/** MIME type */
|
|
106
|
-
mimeType: string;
|
|
107
|
-
/** File size in bytes */
|
|
108
|
-
size: number;
|
|
109
|
-
/** Category classification */
|
|
110
|
-
category: "document" | "image" | "audio";
|
|
111
|
-
/** Preview URL (for images) */
|
|
112
|
-
previewUrl?: string;
|
|
113
|
-
/** Thumbnail URL */
|
|
114
|
-
thumbnailUrl?: string;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Tool call data for history messages
|
|
118
|
-
*/
|
|
119
|
-
interface HistoryToolCall {
|
|
120
|
-
/** Tool call ID */
|
|
121
|
-
id: string;
|
|
122
|
-
/** Tool name */
|
|
123
|
-
name: string;
|
|
124
|
-
/** Tool arguments */
|
|
125
|
-
args?: Record<string, unknown>;
|
|
126
|
-
/** Tool result */
|
|
127
|
-
result?: unknown;
|
|
128
|
-
/** Execution status */
|
|
129
|
-
status: "pending" | "running" | "completed" | "failed";
|
|
130
|
-
/** Execution duration in ms */
|
|
131
|
-
durationMs?: number;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* A message in the session history
|
|
135
|
-
*/
|
|
136
|
-
interface HistoryMessage {
|
|
137
|
-
/** Message UUID */
|
|
138
|
-
uuid: string;
|
|
139
|
-
/** Message role */
|
|
140
|
-
role: "user" | "assistant";
|
|
141
|
-
/** Message content */
|
|
5
|
+
interface MarkdownContentProps {
|
|
6
|
+
/** Markdown content to render */
|
|
142
7
|
content: string;
|
|
143
|
-
/**
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
* Session with chat history
|
|
152
|
-
*/
|
|
153
|
-
interface SessionHistory {
|
|
154
|
-
/** Session UUID */
|
|
155
|
-
sessionId: string;
|
|
156
|
-
/** Agent UUID */
|
|
157
|
-
agentId: string;
|
|
158
|
-
/** Messages in chronological order */
|
|
159
|
-
messages: HistoryMessage[];
|
|
160
|
-
/** When the session was created */
|
|
161
|
-
createdAt: string;
|
|
162
|
-
/** When the session was last updated */
|
|
163
|
-
updatedAt: string;
|
|
8
|
+
/** Additional CSS classes */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Custom React-Markdown component overrides (merged with defaults, user wins) */
|
|
11
|
+
components?: Partial<Components>;
|
|
12
|
+
/** Custom URL transform for React-Markdown (e.g., to preserve custom protocols like artifact:) */
|
|
13
|
+
urlTransform?: (url: string) => string;
|
|
14
|
+
/** Transform content string before rendering (e.g., strip certain patterns) */
|
|
15
|
+
contentTransform?: (content: string) => string;
|
|
164
16
|
}
|
|
165
17
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* This interface decouples the UI from the API implementation,
|
|
169
|
-
* allowing:
|
|
170
|
-
* - Built-in HTTP adapter for external API consumers
|
|
171
|
-
* - Custom adapter for ai-saas-v2 (direct tRPC/DB access)
|
|
172
|
-
* - Testing with mock adapters
|
|
18
|
+
* Renders markdown content with chat-appropriate styling
|
|
173
19
|
*
|
|
174
20
|
* @example
|
|
175
|
-
* ```
|
|
176
|
-
*
|
|
177
|
-
* const adapter = createDefaultAdapter({
|
|
178
|
-
* baseUrl: 'https://api.example.com/api/v1/external',
|
|
179
|
-
* apiKey: 'your-api-key',
|
|
180
|
-
* orgId: 123,
|
|
181
|
-
* });
|
|
182
|
-
*
|
|
183
|
-
* // Using custom tRPC adapter
|
|
184
|
-
* const adapter: ChatAdapter = {
|
|
185
|
-
* startExecution: (input) => api.agents.execute.mutate(input),
|
|
186
|
-
* // ... other methods
|
|
187
|
-
* };
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <MarkdownContent content="# Hello\n\nThis is **bold** text." />
|
|
188
23
|
* ```
|
|
189
24
|
*/
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Start a new agent execution
|
|
193
|
-
* @param input - Execution input
|
|
194
|
-
* @returns Execution and session IDs
|
|
195
|
-
*/
|
|
196
|
-
startExecution(input: StartExecutionInput): Promise<ExecutionResult>;
|
|
197
|
-
/**
|
|
198
|
-
* Send a message in an existing session
|
|
199
|
-
* @param input - Message input
|
|
200
|
-
* @returns Execution and session IDs
|
|
201
|
-
*/
|
|
202
|
-
sendMessage(input: SendMessageInput): Promise<ExecutionResult>;
|
|
203
|
-
/**
|
|
204
|
-
* Cancel a running execution
|
|
205
|
-
* @param uuid - Execution UUID
|
|
206
|
-
*/
|
|
207
|
-
cancelExecution(uuid: string): Promise<void>;
|
|
208
|
-
/**
|
|
209
|
-
* Get execution status and result
|
|
210
|
-
* @param uuid - Execution UUID
|
|
211
|
-
* @returns Execution details
|
|
212
|
-
*/
|
|
213
|
-
getExecution(uuid: string): Promise<Execution>;
|
|
214
|
-
/**
|
|
215
|
-
* Get a pre-signed URL for uploading a file
|
|
216
|
-
* @param input - Upload URL input
|
|
217
|
-
* @returns Upload URL and attachment UUID
|
|
218
|
-
*/
|
|
219
|
-
getUploadUrl(input: UploadUrlInput): Promise<UploadUrlResult>;
|
|
220
|
-
/**
|
|
221
|
-
* Confirm that a file upload has completed
|
|
222
|
-
* @param uuid - Attachment UUID
|
|
223
|
-
*/
|
|
224
|
-
confirmUpload(uuid: string): Promise<void>;
|
|
225
|
-
/**
|
|
226
|
-
* Get a download URL for an attachment
|
|
227
|
-
* @param uuid - Attachment UUID
|
|
228
|
-
* @returns Signed download URL
|
|
229
|
-
*/
|
|
230
|
-
getDownloadUrl(uuid: string): Promise<string>;
|
|
231
|
-
/**
|
|
232
|
-
* Get artifacts generated in a session
|
|
233
|
-
* @param sessionId - Session UUID
|
|
234
|
-
* @returns List of artifacts
|
|
235
|
-
*/
|
|
236
|
-
getSessionArtifacts?(sessionId: string): Promise<Artifact[]>;
|
|
237
|
-
/**
|
|
238
|
-
* Load chat history for an existing session
|
|
239
|
-
*
|
|
240
|
-
* This method is optional. If not implemented, session loading will not be available.
|
|
241
|
-
* The returned data is designed to be cacheable with React Query, SWR, or Next.js caching.
|
|
242
|
-
*
|
|
243
|
-
* @param sessionId - Session UUID
|
|
244
|
-
* @returns Session with message history
|
|
245
|
-
*/
|
|
246
|
-
getSessionHistory?(sessionId: string): Promise<SessionHistory>;
|
|
247
|
-
/**
|
|
248
|
-
* Get the SSE stream URL for an execution
|
|
249
|
-
* @param executionId - Execution UUID
|
|
250
|
-
* @returns Full URL for SSE connection
|
|
251
|
-
*/
|
|
252
|
-
getStreamUrl(executionId: string): string;
|
|
253
|
-
}
|
|
25
|
+
declare function MarkdownContent({ content, className, components: customComponents, urlTransform, contentTransform, }: MarkdownContentProps): react_jsx_runtime.JSX.Element;
|
|
254
26
|
|
|
255
27
|
/**
|
|
256
28
|
* Type definitions for @cadraos/sdk/chat
|
|
@@ -332,168 +104,2566 @@ interface ThinkingBlock {
|
|
|
332
104
|
/**
|
|
333
105
|
* Chat error information
|
|
334
106
|
*/
|
|
335
|
-
interface ChatError {
|
|
336
|
-
/** Error code for programmatic handling */
|
|
337
|
-
code: string;
|
|
338
|
-
/** Human-readable error message */
|
|
339
|
-
message: string;
|
|
340
|
-
/** Additional error details */
|
|
341
|
-
details?: Record<string, unknown>;
|
|
342
|
-
/** Whether the error is retryable */
|
|
343
|
-
retryable?: boolean;
|
|
344
|
-
}
|
|
107
|
+
interface ChatError {
|
|
108
|
+
/** Error code for programmatic handling */
|
|
109
|
+
code: string;
|
|
110
|
+
/** Human-readable error message */
|
|
111
|
+
message: string;
|
|
112
|
+
/** Additional error details */
|
|
113
|
+
details?: Record<string, unknown>;
|
|
114
|
+
/** Whether the error is retryable */
|
|
115
|
+
retryable?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Data for agent clarification requests (ask_user tool)
|
|
119
|
+
*/
|
|
120
|
+
interface ClarificationData {
|
|
121
|
+
/** The question being asked */
|
|
122
|
+
question: string;
|
|
123
|
+
/** Optional reason for asking */
|
|
124
|
+
reason?: string;
|
|
125
|
+
/** Suggested response options */
|
|
126
|
+
suggestedOptions?: string[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Todo item for agent task lists
|
|
130
|
+
*/
|
|
131
|
+
interface TodoItem {
|
|
132
|
+
/** Task description (imperative form) */
|
|
133
|
+
content: string;
|
|
134
|
+
/** Current status */
|
|
135
|
+
status: "pending" | "in_progress" | "completed";
|
|
136
|
+
/** Present continuous form for active display */
|
|
137
|
+
activeForm: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* SSE stream event from agent execution
|
|
141
|
+
*/
|
|
142
|
+
interface ExecutionStreamEvent {
|
|
143
|
+
/** Event type */
|
|
144
|
+
type: string;
|
|
145
|
+
/** Unique event ID for deduplication */
|
|
146
|
+
id: string;
|
|
147
|
+
/** ISO timestamp */
|
|
148
|
+
timestamp: string;
|
|
149
|
+
/** Event data payload */
|
|
150
|
+
data: {
|
|
151
|
+
type?: string;
|
|
152
|
+
log?: {
|
|
153
|
+
stepIndex: number;
|
|
154
|
+
logType: string;
|
|
155
|
+
message: string;
|
|
156
|
+
metadata: Record<string, unknown>;
|
|
157
|
+
timestamp: string;
|
|
158
|
+
durationMs?: number;
|
|
159
|
+
};
|
|
160
|
+
executionId?: string;
|
|
161
|
+
toolName?: string;
|
|
162
|
+
args?: unknown;
|
|
163
|
+
iteration?: number;
|
|
164
|
+
tokenUsage?: {
|
|
165
|
+
prompt: number;
|
|
166
|
+
completion: number;
|
|
167
|
+
total: number;
|
|
168
|
+
};
|
|
169
|
+
cost?: number;
|
|
170
|
+
error?: string;
|
|
171
|
+
question?: string;
|
|
172
|
+
reason?: string;
|
|
173
|
+
suggestedOptions?: string[];
|
|
174
|
+
redisAvailable?: boolean;
|
|
175
|
+
[key: string]: unknown;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Theme mode options
|
|
180
|
+
*/
|
|
181
|
+
type ThemeMode = "light" | "dark" | "system";
|
|
182
|
+
/**
|
|
183
|
+
* Attachment file for upload
|
|
184
|
+
*/
|
|
185
|
+
interface AttachmentFile {
|
|
186
|
+
/** File UUID after upload */
|
|
187
|
+
uuid: string;
|
|
188
|
+
/** Original file object */
|
|
189
|
+
file: File;
|
|
190
|
+
/** Upload status */
|
|
191
|
+
status: "pending" | "uploading" | "ready" | "failed";
|
|
192
|
+
/** Preview URL for local display */
|
|
193
|
+
previewUrl?: string;
|
|
194
|
+
/** Progress percentage (0-100) */
|
|
195
|
+
progress?: number;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface ChatMessageProps {
|
|
199
|
+
/** Message data */
|
|
200
|
+
message: ChatMessage$1;
|
|
201
|
+
/** Whether to enable markdown rendering */
|
|
202
|
+
enableMarkdown?: boolean;
|
|
203
|
+
/** Whether to show tool calls */
|
|
204
|
+
showToolCalls?: boolean;
|
|
205
|
+
/** Additional CSS classes */
|
|
206
|
+
className?: string;
|
|
207
|
+
/** Custom markdown component overrides */
|
|
208
|
+
markdownComponents?: Parameters<typeof MarkdownContent>[0]["components"];
|
|
209
|
+
/** Custom URL transform for markdown */
|
|
210
|
+
markdownUrlTransform?: (url: string) => string;
|
|
211
|
+
/** Custom content transform for markdown */
|
|
212
|
+
markdownContentTransform?: (content: string) => string;
|
|
213
|
+
/** Optional callback when an image in a tool call result is clicked */
|
|
214
|
+
onImageClick?: (image: {
|
|
215
|
+
url: string;
|
|
216
|
+
alt?: string;
|
|
217
|
+
filename?: string;
|
|
218
|
+
}) => void;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Renders a single chat message with appropriate styling
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```tsx
|
|
225
|
+
* <ChatMessage
|
|
226
|
+
* message={{
|
|
227
|
+
* id: "1",
|
|
228
|
+
* role: "assistant",
|
|
229
|
+
* content: "Hello! How can I help?",
|
|
230
|
+
* timestamp: new Date(),
|
|
231
|
+
* }}
|
|
232
|
+
* enableMarkdown
|
|
233
|
+
* showToolCalls
|
|
234
|
+
* />
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
declare function ChatMessage({ message, enableMarkdown, showToolCalls, className, markdownComponents, markdownUrlTransform, markdownContentTransform, onImageClick, }: ChatMessageProps): react_jsx_runtime.JSX.Element;
|
|
238
|
+
|
|
239
|
+
interface MessageListProps {
|
|
240
|
+
/** Array of messages to display */
|
|
241
|
+
messages: ChatMessage$1[];
|
|
242
|
+
/** Welcome message shown when chat is empty */
|
|
243
|
+
welcomeMessage?: string;
|
|
244
|
+
/**
|
|
245
|
+
* Custom welcome UI rendered when chat is empty (no messages).
|
|
246
|
+
* When provided, replaces the default centered text welcome message.
|
|
247
|
+
* Takes precedence over `welcomeMessage` string prop.
|
|
248
|
+
*
|
|
249
|
+
* Can be a ReactNode or a render function receiving `{ sendMessage }`
|
|
250
|
+
* to allow interactive elements (e.g., suggestion chips) to send messages.
|
|
251
|
+
*/
|
|
252
|
+
renderWelcome?: React.ReactNode | ((props: {
|
|
253
|
+
sendMessage: (text: string) => void;
|
|
254
|
+
}) => React.ReactNode);
|
|
255
|
+
/** Whether a new message is loading */
|
|
256
|
+
isLoading?: boolean;
|
|
257
|
+
/** Whether the assistant is currently streaming a response */
|
|
258
|
+
isStreaming?: boolean;
|
|
259
|
+
/** Whether session history is being loaded */
|
|
260
|
+
isLoadingHistory?: boolean;
|
|
261
|
+
/** Whether to enable markdown rendering */
|
|
262
|
+
enableMarkdown?: boolean;
|
|
263
|
+
/** Whether to show tool calls */
|
|
264
|
+
showToolCalls?: boolean;
|
|
265
|
+
/** Additional CSS classes */
|
|
266
|
+
className?: string;
|
|
267
|
+
/** Custom markdown component overrides */
|
|
268
|
+
markdownComponents?: ChatMessageProps["markdownComponents"];
|
|
269
|
+
/** Custom URL transform for markdown */
|
|
270
|
+
markdownUrlTransform?: (url: string) => string;
|
|
271
|
+
/** Custom content transform for markdown */
|
|
272
|
+
markdownContentTransform?: (content: string) => string;
|
|
273
|
+
/** Optional callback when an image in a tool call result is clicked */
|
|
274
|
+
onImageClick?: (image: {
|
|
275
|
+
url: string;
|
|
276
|
+
alt?: string;
|
|
277
|
+
filename?: string;
|
|
278
|
+
}) => void;
|
|
279
|
+
/**
|
|
280
|
+
* Send message function passed from parent (AgentChat).
|
|
281
|
+
* Used to forward to renderWelcome render function for suggestion chips.
|
|
282
|
+
* @internal
|
|
283
|
+
*/
|
|
284
|
+
sendMessage?: (text: string) => void;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Renders a scrollable list of chat messages with auto-scroll
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```tsx
|
|
291
|
+
* <MessageList
|
|
292
|
+
* messages={messages}
|
|
293
|
+
* welcomeMessage="Hello! How can I help you today?"
|
|
294
|
+
* isLoading={isLoading}
|
|
295
|
+
* isStreaming={isStreaming}
|
|
296
|
+
* enableMarkdown
|
|
297
|
+
* showToolCalls
|
|
298
|
+
* />
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
declare function MessageList({ messages, welcomeMessage, renderWelcome, isLoading, isStreaming, isLoadingHistory, enableMarkdown, showToolCalls, className, markdownComponents, markdownUrlTransform, markdownContentTransform, onImageClick, sendMessage, }: MessageListProps): react_jsx_runtime.JSX.Element;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Common types shared across all resources
|
|
305
|
+
*/
|
|
306
|
+
/**
|
|
307
|
+
* JSON Schema type for tool input/output schemas
|
|
308
|
+
*/
|
|
309
|
+
type JSONSchema = {
|
|
310
|
+
type: string;
|
|
311
|
+
properties?: Record<string, JSONSchema>;
|
|
312
|
+
required?: string[];
|
|
313
|
+
items?: JSONSchema;
|
|
314
|
+
description?: string;
|
|
315
|
+
[key: string]: unknown;
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* Pagination options for list operations
|
|
319
|
+
*/
|
|
320
|
+
interface ListOptions {
|
|
321
|
+
/** Maximum number of items to return (default: 20) */
|
|
322
|
+
limit?: number;
|
|
323
|
+
/** Number of items to skip (pagination offset) */
|
|
324
|
+
offset?: number;
|
|
325
|
+
/** Field to sort by (e.g., 'createdAt') */
|
|
326
|
+
sort?: string;
|
|
327
|
+
/** Sort order */
|
|
328
|
+
order?: 'asc' | 'desc';
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Pagination metadata in list responses
|
|
332
|
+
*/
|
|
333
|
+
interface PaginationInfo {
|
|
334
|
+
/** Total number of items */
|
|
335
|
+
total: number;
|
|
336
|
+
/** Number of items returned */
|
|
337
|
+
limit: number;
|
|
338
|
+
/** Number of items skipped */
|
|
339
|
+
offset: number;
|
|
340
|
+
/** Whether there are more items */
|
|
341
|
+
hasMore: boolean;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Paginated list response
|
|
345
|
+
*/
|
|
346
|
+
interface PaginatedResponse<T> {
|
|
347
|
+
data: T[];
|
|
348
|
+
pagination: PaginationInfo;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Execute operation options
|
|
352
|
+
*/
|
|
353
|
+
interface ExecuteOptions {
|
|
354
|
+
/** Maximum number of agent iterations */
|
|
355
|
+
maxIterations?: number;
|
|
356
|
+
/** Maximum tokens for the response */
|
|
357
|
+
maxTokens?: number;
|
|
358
|
+
/** Execution timeout in milliseconds */
|
|
359
|
+
timeout?: number;
|
|
360
|
+
/** Idempotency key for retry safety */
|
|
361
|
+
idempotencyKey?: string;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Execute input for agent/skill operations
|
|
365
|
+
*/
|
|
366
|
+
interface ExecuteInput {
|
|
367
|
+
/** The task or prompt to execute */
|
|
368
|
+
task: string;
|
|
369
|
+
/** Additional context for the execution */
|
|
370
|
+
context?: Record<string, unknown>;
|
|
371
|
+
/** Attachment UUIDs to include with the message (for images, documents, etc.) */
|
|
372
|
+
attachmentIds?: string[];
|
|
373
|
+
/** Team UUID for team-based execution (routes to team's lead orchestrator) */
|
|
374
|
+
teamUuid?: string;
|
|
375
|
+
/** Execution options */
|
|
376
|
+
options?: ExecuteOptions;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Execution status
|
|
380
|
+
*/
|
|
381
|
+
type ExecutionStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused' | 'waiting_user_input';
|
|
382
|
+
/**
|
|
383
|
+
* Token usage information
|
|
384
|
+
*/
|
|
385
|
+
interface TokenUsage {
|
|
386
|
+
/** Input tokens consumed */
|
|
387
|
+
input: number;
|
|
388
|
+
/** Output tokens generated */
|
|
389
|
+
output: number;
|
|
390
|
+
/** Total tokens */
|
|
391
|
+
total: number;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Agent types
|
|
396
|
+
*/
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Agent type
|
|
400
|
+
*/
|
|
401
|
+
type AgentType = 'simple' | 'workflow' | 'orchestrator';
|
|
402
|
+
/**
|
|
403
|
+
* Agent status
|
|
404
|
+
*/
|
|
405
|
+
type AgentStatus = 'active' | 'inactive' | 'draft';
|
|
406
|
+
/**
|
|
407
|
+
* Agent configuration
|
|
408
|
+
*/
|
|
409
|
+
interface AgentConfig {
|
|
410
|
+
/** LLM model to use */
|
|
411
|
+
model?: string;
|
|
412
|
+
/** Temperature for generation */
|
|
413
|
+
temperature?: number;
|
|
414
|
+
/** Maximum iterations for agent loop */
|
|
415
|
+
maxIterations?: number;
|
|
416
|
+
/** System prompt for the agent */
|
|
417
|
+
systemPrompt?: string;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Agent resource
|
|
421
|
+
*/
|
|
422
|
+
interface Agent {
|
|
423
|
+
/** Unique identifier */
|
|
424
|
+
uuid: string;
|
|
425
|
+
/** Agent name */
|
|
426
|
+
name: string;
|
|
427
|
+
/** Agent description */
|
|
428
|
+
description: string | null;
|
|
429
|
+
/** Agent type */
|
|
430
|
+
type: AgentType;
|
|
431
|
+
/** Agent status */
|
|
432
|
+
status: AgentStatus;
|
|
433
|
+
/** Creation timestamp */
|
|
434
|
+
createdAt: string;
|
|
435
|
+
/** Last update timestamp */
|
|
436
|
+
updatedAt: string;
|
|
437
|
+
/** Agent configuration (included in get, not list) */
|
|
438
|
+
config?: AgentConfig;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Agent list options
|
|
442
|
+
*/
|
|
443
|
+
interface AgentListOptions extends ListOptions {
|
|
444
|
+
/** Filter by status */
|
|
445
|
+
status?: AgentStatus;
|
|
446
|
+
/** Filter by type */
|
|
447
|
+
type?: AgentType;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Log types that can be generated during execution
|
|
451
|
+
* Matches the LogType from cadra-api's log-collector service
|
|
452
|
+
*/
|
|
453
|
+
type LogType = 'info' | 'llm_request' | 'llm_response' | 'tool_call' | 'tool_result' | 'error' | 'system' | 'think' | 'rag' | 'skill' | 'delegation' | 'plan' | 'message';
|
|
454
|
+
/**
|
|
455
|
+
* Execution log entry
|
|
456
|
+
*/
|
|
457
|
+
interface ExecutionLog {
|
|
458
|
+
/** Unique identifier */
|
|
459
|
+
uuid: string;
|
|
460
|
+
/** Log type */
|
|
461
|
+
type: LogType;
|
|
462
|
+
/** Log title/summary */
|
|
463
|
+
title: string;
|
|
464
|
+
/** Log content/details */
|
|
465
|
+
content?: string;
|
|
466
|
+
/** Additional metadata */
|
|
467
|
+
metadata?: Record<string, unknown>;
|
|
468
|
+
/** Timestamp */
|
|
469
|
+
timestamp: string;
|
|
470
|
+
/** Duration in milliseconds (if applicable) */
|
|
471
|
+
durationMs?: number;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Agent execution result
|
|
475
|
+
*/
|
|
476
|
+
interface AgentExecution {
|
|
477
|
+
/** Execution ID */
|
|
478
|
+
uuid: string;
|
|
479
|
+
/** Agent ID */
|
|
480
|
+
agentUuid: string;
|
|
481
|
+
/** Session ID for conversation continuity */
|
|
482
|
+
sessionId?: string;
|
|
483
|
+
/** Execution status */
|
|
484
|
+
status: ExecutionStatus;
|
|
485
|
+
/** Input provided */
|
|
486
|
+
input: {
|
|
487
|
+
task: string;
|
|
488
|
+
context?: Record<string, unknown>;
|
|
489
|
+
};
|
|
490
|
+
/** Output result */
|
|
491
|
+
output?: string;
|
|
492
|
+
/** Error message if failed */
|
|
493
|
+
error?: string;
|
|
494
|
+
/** Execution logs */
|
|
495
|
+
logs: ExecutionLog[];
|
|
496
|
+
/** Token usage */
|
|
497
|
+
tokenUsage?: TokenUsage;
|
|
498
|
+
/** Cost in USD */
|
|
499
|
+
cost?: number;
|
|
500
|
+
/** Number of iterations */
|
|
501
|
+
iterations?: number;
|
|
502
|
+
/** When execution was queued */
|
|
503
|
+
queuedAt: string;
|
|
504
|
+
/** When execution started */
|
|
505
|
+
startedAt?: string;
|
|
506
|
+
/** When execution completed */
|
|
507
|
+
completedAt?: string;
|
|
508
|
+
/** Total duration in milliseconds */
|
|
509
|
+
durationMs?: number;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Agent update input
|
|
513
|
+
*/
|
|
514
|
+
interface AgentUpdateInput {
|
|
515
|
+
/** New name */
|
|
516
|
+
name?: string;
|
|
517
|
+
/** New description */
|
|
518
|
+
description?: string;
|
|
519
|
+
/** New status */
|
|
520
|
+
status?: AgentStatus;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Agent config update input
|
|
524
|
+
*/
|
|
525
|
+
interface AgentConfigUpdateInput {
|
|
526
|
+
/** LLM model */
|
|
527
|
+
model?: string;
|
|
528
|
+
/** Temperature */
|
|
529
|
+
temperature?: number;
|
|
530
|
+
/** Max iterations */
|
|
531
|
+
maxIterations?: number;
|
|
532
|
+
/** System prompt */
|
|
533
|
+
systemPrompt?: string;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Execute response (async)
|
|
537
|
+
*/
|
|
538
|
+
interface ExecuteResponse {
|
|
539
|
+
/** Execution ID */
|
|
540
|
+
executionId: string;
|
|
541
|
+
/** Session ID for conversation continuity */
|
|
542
|
+
sessionId?: string;
|
|
543
|
+
/** Initial status */
|
|
544
|
+
status: ExecutionStatus;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Streaming types
|
|
549
|
+
*/
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Tool call event
|
|
553
|
+
*/
|
|
554
|
+
interface ToolCallEvent {
|
|
555
|
+
/** Tool call ID */
|
|
556
|
+
toolCallId: string;
|
|
557
|
+
/** Tool name */
|
|
558
|
+
toolName: string;
|
|
559
|
+
/** Tool inputs */
|
|
560
|
+
inputs: Record<string, unknown>;
|
|
561
|
+
/** Step/iteration index */
|
|
562
|
+
stepIndex: number;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Tool result event
|
|
566
|
+
*/
|
|
567
|
+
interface ToolResultEvent {
|
|
568
|
+
/** Tool call ID */
|
|
569
|
+
toolCallId: string;
|
|
570
|
+
/** Tool name */
|
|
571
|
+
toolName: string;
|
|
572
|
+
/** Tool result */
|
|
573
|
+
result: unknown;
|
|
574
|
+
/** Duration in milliseconds */
|
|
575
|
+
durationMs: number;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Plan event
|
|
579
|
+
*/
|
|
580
|
+
interface PlanEvent {
|
|
581
|
+
/** Planned tasks */
|
|
582
|
+
tasks: Array<{
|
|
583
|
+
title: string;
|
|
584
|
+
status: 'pending' | 'in_progress' | 'completed' | 'failed';
|
|
585
|
+
}>;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Complete event
|
|
589
|
+
*/
|
|
590
|
+
interface CompleteEvent {
|
|
591
|
+
/** Final execution result */
|
|
592
|
+
execution: AgentExecution;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Error event
|
|
596
|
+
*/
|
|
597
|
+
interface ErrorEvent {
|
|
598
|
+
/** Error message */
|
|
599
|
+
error: string;
|
|
600
|
+
/** Error code */
|
|
601
|
+
errorCode?: string;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Connection change event
|
|
605
|
+
*/
|
|
606
|
+
interface ConnectionChangeEvent {
|
|
607
|
+
/** Whether connected */
|
|
608
|
+
connected: boolean;
|
|
609
|
+
/** Whether using fallback polling */
|
|
610
|
+
usingFallback?: boolean;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Paused event (ask_user waiting for user input)
|
|
614
|
+
*/
|
|
615
|
+
interface PausedEvent {
|
|
616
|
+
/** The question to ask the user */
|
|
617
|
+
question: string;
|
|
618
|
+
/** Optional predefined choices */
|
|
619
|
+
options?: string[];
|
|
620
|
+
/** Reason for pausing */
|
|
621
|
+
reason: 'waiting_user_input';
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Delegation started event (handoff_to_agent initiated)
|
|
625
|
+
*/
|
|
626
|
+
interface DelegationStartedEvent {
|
|
627
|
+
/** Event type */
|
|
628
|
+
type: 'delegation_started';
|
|
629
|
+
/** Unique handoff ID */
|
|
630
|
+
handoffId: string;
|
|
631
|
+
/** Target agent UUID */
|
|
632
|
+
targetAgentUuid: string;
|
|
633
|
+
/** Target agent name */
|
|
634
|
+
targetAgentName?: string;
|
|
635
|
+
/** Preview of the delegated task */
|
|
636
|
+
taskPreview: string;
|
|
637
|
+
/** Event timestamp */
|
|
638
|
+
timestamp: string;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Delegation completed event (handoff_to_agent finished)
|
|
642
|
+
*/
|
|
643
|
+
interface DelegationCompletedEvent {
|
|
644
|
+
/** Event type */
|
|
645
|
+
type: 'delegation_completed';
|
|
646
|
+
/** Unique handoff ID */
|
|
647
|
+
handoffId: string;
|
|
648
|
+
/** Completion status */
|
|
649
|
+
status: 'completed' | 'failed';
|
|
650
|
+
/** Preview of the result (if completed) */
|
|
651
|
+
resultPreview?: string;
|
|
652
|
+
/** Error message (if failed) */
|
|
653
|
+
error?: string;
|
|
654
|
+
/** Duration in milliseconds */
|
|
655
|
+
durationMs: number;
|
|
656
|
+
/** Event timestamp */
|
|
657
|
+
timestamp: string;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Text delta event - token-by-token streaming text
|
|
661
|
+
*/
|
|
662
|
+
interface TextDeltaEvent {
|
|
663
|
+
/** Text delta chunk */
|
|
664
|
+
delta: string;
|
|
665
|
+
/** Execution ID */
|
|
666
|
+
executionId: string;
|
|
667
|
+
/** Event timestamp */
|
|
668
|
+
timestamp: string;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Started event - execution has begun
|
|
672
|
+
*/
|
|
673
|
+
interface StartedEvent {
|
|
674
|
+
/** Execution ID */
|
|
675
|
+
executionId: string;
|
|
676
|
+
/** Agent UUID */
|
|
677
|
+
agentUuid: string;
|
|
678
|
+
/** Initial status */
|
|
679
|
+
status: 'initializing';
|
|
680
|
+
/** Current step description */
|
|
681
|
+
currentStep?: string;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Progress event - execution status update
|
|
685
|
+
*/
|
|
686
|
+
interface ProgressEvent {
|
|
687
|
+
/** Current status */
|
|
688
|
+
status: 'initializing' | 'thinking' | 'acting' | 'observing' | 'planning' | 'paused';
|
|
689
|
+
/** Current iteration number */
|
|
690
|
+
iteration: number;
|
|
691
|
+
/** Description of current step */
|
|
692
|
+
currentStep?: string;
|
|
693
|
+
/** Current token usage */
|
|
694
|
+
tokenUsage?: {
|
|
695
|
+
prompt: number;
|
|
696
|
+
completion: number;
|
|
697
|
+
total: number;
|
|
698
|
+
};
|
|
699
|
+
/** Current cost */
|
|
700
|
+
cost?: number;
|
|
701
|
+
/** Number of tool calls made */
|
|
702
|
+
toolCalls?: number;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Task status for task list updates
|
|
706
|
+
*/
|
|
707
|
+
type TaskStatus = 'pending' | 'in_progress' | 'completed';
|
|
708
|
+
/**
|
|
709
|
+
* Task item in task list
|
|
710
|
+
*/
|
|
711
|
+
interface TaskItem {
|
|
712
|
+
/** Unique task ID */
|
|
713
|
+
id: string;
|
|
714
|
+
/** Task content/description */
|
|
715
|
+
content: string;
|
|
716
|
+
/** Active form text shown during in_progress */
|
|
717
|
+
activeForm?: string | null;
|
|
718
|
+
/** Task status */
|
|
719
|
+
status: TaskStatus;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Task list update event - agent creating/updating task list
|
|
723
|
+
*/
|
|
724
|
+
interface TaskListUpdateEvent {
|
|
725
|
+
/** Execution ID */
|
|
726
|
+
executionId: string;
|
|
727
|
+
/** Current task list */
|
|
728
|
+
tasks: TaskItem[];
|
|
729
|
+
/** Timestamp */
|
|
730
|
+
timestamp: string;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Stream controller interface
|
|
734
|
+
*/
|
|
735
|
+
interface StreamController {
|
|
736
|
+
/** Listen for log events */
|
|
737
|
+
on(event: 'log', callback: (log: ExecutionLog) => void): void;
|
|
738
|
+
/** Listen for tool call events */
|
|
739
|
+
on(event: 'toolCall', callback: (data: ToolCallEvent) => void): void;
|
|
740
|
+
/** Listen for tool result events */
|
|
741
|
+
on(event: 'toolResult', callback: (data: ToolResultEvent) => void): void;
|
|
742
|
+
/** Listen for plan updates */
|
|
743
|
+
on(event: 'plan', callback: (data: PlanEvent) => void): void;
|
|
744
|
+
/** Listen for paused events (ask_user waiting for input) */
|
|
745
|
+
on(event: 'paused', callback: (data: PausedEvent) => void): void;
|
|
746
|
+
/** Listen for execution started (immediate feedback) */
|
|
747
|
+
on(event: 'started', callback: (data: StartedEvent) => void): void;
|
|
748
|
+
/** Listen for progress updates (status changes during execution) */
|
|
749
|
+
on(event: 'progress', callback: (data: ProgressEvent) => void): void;
|
|
750
|
+
/** Listen for task list updates */
|
|
751
|
+
on(event: 'taskListUpdate', callback: (data: TaskListUpdateEvent) => void): void;
|
|
752
|
+
/** Listen for delegation started events */
|
|
753
|
+
on(event: 'delegationStarted', callback: (data: DelegationStartedEvent) => void): void;
|
|
754
|
+
/** Listen for delegation completed events */
|
|
755
|
+
on(event: 'delegationCompleted', callback: (data: DelegationCompletedEvent) => void): void;
|
|
756
|
+
/** Listen for text delta events (token-by-token streaming) */
|
|
757
|
+
on(event: 'textDelta', callback: (data: TextDeltaEvent) => void): void;
|
|
758
|
+
/** Listen for completion */
|
|
759
|
+
on(event: 'complete', callback: (data: CompleteEvent) => void): void;
|
|
760
|
+
/** Listen for errors */
|
|
761
|
+
on(event: 'error', callback: (error: ErrorEvent) => void): void;
|
|
762
|
+
/** Listen for connection state changes */
|
|
763
|
+
on(event: 'connectionChange', callback: (data: ConnectionChangeEvent) => void): void;
|
|
764
|
+
/** Cancel the stream */
|
|
765
|
+
cancel(): void;
|
|
766
|
+
/** Wait for completion, returns final execution result */
|
|
767
|
+
wait(): Promise<AgentExecution>;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Stream Controller
|
|
772
|
+
*
|
|
773
|
+
* Manages execution streaming with automatic reconnection and fallback to polling.
|
|
774
|
+
* Implements the StreamController interface for type-safe event handling.
|
|
775
|
+
*/
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Execution Stream Controller
|
|
779
|
+
*
|
|
780
|
+
* Manages the lifecycle of an execution stream, including:
|
|
781
|
+
* - SSE connection management
|
|
782
|
+
* - Automatic reconnection with exponential backoff
|
|
783
|
+
* - Fallback to polling on connection failure
|
|
784
|
+
* - Event deduplication
|
|
785
|
+
*/
|
|
786
|
+
interface ExecutionStreamController extends StreamController {
|
|
787
|
+
/** Connect to the stream */
|
|
788
|
+
connect(): Promise<void>;
|
|
789
|
+
/** Get the execution ID */
|
|
790
|
+
readonly executionId: string;
|
|
791
|
+
/** Get the session ID (if available) */
|
|
792
|
+
readonly sessionId: string | undefined;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* ChatAdapter interface for customizable API integration
|
|
797
|
+
*
|
|
798
|
+
* Implement this interface to:
|
|
799
|
+
* - Connect to different backends
|
|
800
|
+
* - Use direct DB access (in ai-saas-v2)
|
|
801
|
+
* - Mock for testing
|
|
802
|
+
*
|
|
803
|
+
* @module @cadraos/sdk/chat
|
|
804
|
+
*/
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Input for starting an agent execution
|
|
808
|
+
*/
|
|
809
|
+
interface StartExecutionInput {
|
|
810
|
+
/** UUID of the agent to execute */
|
|
811
|
+
agentId: string;
|
|
812
|
+
/** Optional team UUID for team-based execution (routes to team's lead orchestrator) */
|
|
813
|
+
teamId?: string;
|
|
814
|
+
/** Optional session ID for continuing a conversation */
|
|
815
|
+
sessionId?: string;
|
|
816
|
+
/** User message content */
|
|
817
|
+
content: string;
|
|
818
|
+
/** UUIDs of attached files */
|
|
819
|
+
attachmentUuids?: string[];
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Input for sending a message in an existing session
|
|
823
|
+
*/
|
|
824
|
+
interface SendMessageInput$1 {
|
|
825
|
+
/** Session ID */
|
|
826
|
+
sessionId: string;
|
|
827
|
+
/** Message content */
|
|
828
|
+
content: string;
|
|
829
|
+
/** UUIDs of attached files */
|
|
830
|
+
attachmentUuids?: string[];
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Input for getting an upload URL
|
|
834
|
+
*/
|
|
835
|
+
interface UploadUrlInput {
|
|
836
|
+
/** Session ID */
|
|
837
|
+
sessionId: string;
|
|
838
|
+
/** Filename */
|
|
839
|
+
filename: string;
|
|
840
|
+
/** MIME type */
|
|
841
|
+
mimeType: string;
|
|
842
|
+
/** File size in bytes */
|
|
843
|
+
size: number;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Input for listing sessions
|
|
847
|
+
*/
|
|
848
|
+
interface ListSessionsInput {
|
|
849
|
+
/** Filter by agent UUID */
|
|
850
|
+
agentId?: string;
|
|
851
|
+
/** Maximum number of sessions to return */
|
|
852
|
+
limit?: number;
|
|
853
|
+
/** Pagination offset */
|
|
854
|
+
offset?: number;
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Result from starting an execution
|
|
858
|
+
*/
|
|
859
|
+
interface ExecutionResult {
|
|
860
|
+
/** UUID of the created execution */
|
|
861
|
+
executionId: string;
|
|
862
|
+
/** UUID of the session (new or existing) */
|
|
863
|
+
sessionId: string;
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Result from getting an upload URL
|
|
867
|
+
*/
|
|
868
|
+
interface UploadUrlResult {
|
|
869
|
+
/** Pre-signed upload URL */
|
|
870
|
+
uploadUrl: string;
|
|
871
|
+
/** UUID for the attachment */
|
|
872
|
+
attachmentUuid: string;
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Execution status and result
|
|
876
|
+
*/
|
|
877
|
+
interface Execution {
|
|
878
|
+
/** Execution UUID */
|
|
879
|
+
uuid: string;
|
|
880
|
+
/** Current status */
|
|
881
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
882
|
+
/** Final result (when completed) */
|
|
883
|
+
result?: string;
|
|
884
|
+
/** Error message (when failed) */
|
|
885
|
+
error?: string;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Artifact generated during execution
|
|
889
|
+
*/
|
|
890
|
+
interface Artifact$1 {
|
|
891
|
+
/** Artifact UUID */
|
|
892
|
+
uuid: string;
|
|
893
|
+
/** Artifact type */
|
|
894
|
+
type: "image" | "document" | "code" | "audio";
|
|
895
|
+
/** Filename */
|
|
896
|
+
filename: string;
|
|
897
|
+
/** MIME type */
|
|
898
|
+
mimeType: string;
|
|
899
|
+
/** Download URL */
|
|
900
|
+
url: string;
|
|
901
|
+
/** When the artifact was created (ISO string) */
|
|
902
|
+
createdAt?: string;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Session summary for list display
|
|
906
|
+
*/
|
|
907
|
+
interface SessionListItem {
|
|
908
|
+
/** Session UUID */
|
|
909
|
+
id: string;
|
|
910
|
+
/** Agent UUID */
|
|
911
|
+
agentId: string;
|
|
912
|
+
/** When the session was created */
|
|
913
|
+
createdAt: string;
|
|
914
|
+
/** When the last message was sent */
|
|
915
|
+
lastMessageAt: string;
|
|
916
|
+
/** Total message count */
|
|
917
|
+
messageCount: number;
|
|
918
|
+
/** Preview of the last user message */
|
|
919
|
+
lastUserMessage?: string | null;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Paginated session list result
|
|
923
|
+
*/
|
|
924
|
+
interface SessionList {
|
|
925
|
+
/** Sessions in the current page */
|
|
926
|
+
sessions: SessionListItem[];
|
|
927
|
+
/** Total number of sessions */
|
|
928
|
+
total: number;
|
|
929
|
+
/** Whether there are more sessions beyond this page */
|
|
930
|
+
hasMore: boolean;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Attachment metadata for history messages
|
|
934
|
+
*/
|
|
935
|
+
interface HistoryAttachment {
|
|
936
|
+
/** Attachment UUID */
|
|
937
|
+
uuid: string;
|
|
938
|
+
/** Original filename */
|
|
939
|
+
filename: string;
|
|
940
|
+
/** MIME type */
|
|
941
|
+
mimeType: string;
|
|
942
|
+
/** File size in bytes */
|
|
943
|
+
size: number;
|
|
944
|
+
/** Category classification */
|
|
945
|
+
category: "document" | "image" | "audio";
|
|
946
|
+
/** Preview URL (for images) */
|
|
947
|
+
previewUrl?: string;
|
|
948
|
+
/** Thumbnail URL */
|
|
949
|
+
thumbnailUrl?: string;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Tool call data for history messages
|
|
953
|
+
*/
|
|
954
|
+
interface HistoryToolCall {
|
|
955
|
+
/** Tool call ID */
|
|
956
|
+
id: string;
|
|
957
|
+
/** Tool name */
|
|
958
|
+
name: string;
|
|
959
|
+
/** Tool arguments */
|
|
960
|
+
args?: Record<string, unknown>;
|
|
961
|
+
/** Tool result */
|
|
962
|
+
result?: unknown;
|
|
963
|
+
/** Execution status */
|
|
964
|
+
status: "pending" | "running" | "completed" | "failed";
|
|
965
|
+
/** Execution duration in ms */
|
|
966
|
+
durationMs?: number;
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* A message in the session history
|
|
970
|
+
*/
|
|
971
|
+
interface HistoryMessage {
|
|
972
|
+
/** Message UUID */
|
|
973
|
+
uuid: string;
|
|
974
|
+
/** Message role */
|
|
975
|
+
role: "user" | "assistant";
|
|
976
|
+
/** Message content */
|
|
977
|
+
content: string;
|
|
978
|
+
/** Message timestamp */
|
|
979
|
+
timestamp: string;
|
|
980
|
+
/** File attachments (for user messages) */
|
|
981
|
+
attachments?: HistoryAttachment[];
|
|
982
|
+
/** Tool calls (for assistant messages) */
|
|
983
|
+
toolCalls?: HistoryToolCall[];
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Session with chat history
|
|
987
|
+
*/
|
|
988
|
+
interface SessionHistory$1 {
|
|
989
|
+
/** Session UUID */
|
|
990
|
+
sessionId: string;
|
|
991
|
+
/** Agent UUID */
|
|
992
|
+
agentId: string;
|
|
993
|
+
/** Messages in chronological order */
|
|
994
|
+
messages: HistoryMessage[];
|
|
995
|
+
/** When the session was created */
|
|
996
|
+
createdAt: string;
|
|
997
|
+
/** When the session was last updated */
|
|
998
|
+
updatedAt: string;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* ChatAdapter interface for API integration
|
|
1002
|
+
*
|
|
1003
|
+
* This interface decouples the UI from the API implementation,
|
|
1004
|
+
* allowing:
|
|
1005
|
+
* - Built-in HTTP adapter for external API consumers
|
|
1006
|
+
* - Custom adapter for ai-saas-v2 (direct tRPC/DB access)
|
|
1007
|
+
* - Testing with mock adapters
|
|
1008
|
+
*
|
|
1009
|
+
* @example
|
|
1010
|
+
* ```typescript
|
|
1011
|
+
* // Using default HTTP adapter
|
|
1012
|
+
* const adapter = createDefaultAdapter({
|
|
1013
|
+
* baseUrl: 'https://api.example.com/api/v1/external',
|
|
1014
|
+
* apiKey: 'your-api-key',
|
|
1015
|
+
* orgId: 123,
|
|
1016
|
+
* });
|
|
1017
|
+
*
|
|
1018
|
+
* // Using custom tRPC adapter
|
|
1019
|
+
* const adapter: ChatAdapter = {
|
|
1020
|
+
* startExecution: (input) => api.agents.execute.mutate(input),
|
|
1021
|
+
* // ... other methods
|
|
1022
|
+
* };
|
|
1023
|
+
* ```
|
|
1024
|
+
*/
|
|
1025
|
+
interface ChatAdapter {
|
|
1026
|
+
/**
|
|
1027
|
+
* Start a new agent execution
|
|
1028
|
+
* @param input - Execution input
|
|
1029
|
+
* @returns Execution and session IDs
|
|
1030
|
+
*/
|
|
1031
|
+
startExecution(input: StartExecutionInput): Promise<ExecutionResult>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Send a message in an existing session
|
|
1034
|
+
* @param input - Message input
|
|
1035
|
+
* @returns Execution and session IDs
|
|
1036
|
+
*/
|
|
1037
|
+
sendMessage(input: SendMessageInput$1): Promise<ExecutionResult>;
|
|
1038
|
+
/**
|
|
1039
|
+
* Cancel a running execution
|
|
1040
|
+
* @param uuid - Execution UUID
|
|
1041
|
+
*/
|
|
1042
|
+
cancelExecution(uuid: string): Promise<void>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Get execution status and result
|
|
1045
|
+
* @param uuid - Execution UUID
|
|
1046
|
+
* @returns Execution details
|
|
1047
|
+
*/
|
|
1048
|
+
getExecution(uuid: string): Promise<Execution>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Get a pre-signed URL for uploading a file
|
|
1051
|
+
* @param input - Upload URL input
|
|
1052
|
+
* @returns Upload URL and attachment UUID
|
|
1053
|
+
*/
|
|
1054
|
+
getUploadUrl(input: UploadUrlInput): Promise<UploadUrlResult>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Confirm that a file upload has completed
|
|
1057
|
+
* @param uuid - Attachment UUID
|
|
1058
|
+
*/
|
|
1059
|
+
confirmUpload(uuid: string): Promise<void>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Get a download URL for an attachment
|
|
1062
|
+
* @param uuid - Attachment UUID
|
|
1063
|
+
* @returns Signed download URL
|
|
1064
|
+
*/
|
|
1065
|
+
getDownloadUrl(uuid: string): Promise<string>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Get artifacts generated in a session
|
|
1068
|
+
* @param sessionId - Session UUID
|
|
1069
|
+
* @returns List of artifacts
|
|
1070
|
+
*/
|
|
1071
|
+
getSessionArtifacts?(sessionId: string): Promise<Artifact$1[]>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Load chat history for an existing session
|
|
1074
|
+
*
|
|
1075
|
+
* This method is optional. If not implemented, session loading will not be available.
|
|
1076
|
+
* The returned data is designed to be cacheable with React Query, SWR, or Next.js caching.
|
|
1077
|
+
*
|
|
1078
|
+
* @param sessionId - Session UUID
|
|
1079
|
+
* @returns Session with message history
|
|
1080
|
+
*/
|
|
1081
|
+
getSessionHistory?(sessionId: string): Promise<SessionHistory$1>;
|
|
1082
|
+
/**
|
|
1083
|
+
* List sessions for the current user/agent
|
|
1084
|
+
*
|
|
1085
|
+
* @param input - List options (agent filter, pagination)
|
|
1086
|
+
* @returns Paginated session list
|
|
1087
|
+
*/
|
|
1088
|
+
listSessions?(input: ListSessionsInput): Promise<SessionList>;
|
|
1089
|
+
/**
|
|
1090
|
+
* Create an ExecutionStreamController for an execution.
|
|
1091
|
+
*
|
|
1092
|
+
* When implemented, useAgentChat will use this instead of the legacy
|
|
1093
|
+
* EventSource-based useExecutionStream hook. The stream controller
|
|
1094
|
+
* provides automatic reconnection, polling fallback, and event deduplication.
|
|
1095
|
+
*
|
|
1096
|
+
* @param executionId - Execution UUID to stream
|
|
1097
|
+
* @param sessionId - Optional session ID for context
|
|
1098
|
+
* @returns ExecutionStreamController instance (call .connect() to start)
|
|
1099
|
+
*/
|
|
1100
|
+
createStream?(executionId: string, sessionId?: string): ExecutionStreamController;
|
|
1101
|
+
/**
|
|
1102
|
+
* Get the SSE stream URL for an execution.
|
|
1103
|
+
*
|
|
1104
|
+
* @deprecated Prefer implementing `createStream` which provides
|
|
1105
|
+
* fetch-based SSE with auth headers. This is kept for backward
|
|
1106
|
+
* compatibility with EventSource-based streaming.
|
|
1107
|
+
*
|
|
1108
|
+
* @param executionId - Execution UUID
|
|
1109
|
+
* @returns Full URL for SSE connection
|
|
1110
|
+
*/
|
|
1111
|
+
getStreamUrl?(executionId: string): string;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
interface AgentChatProps {
|
|
1115
|
+
/** The UUID of the agent to chat with */
|
|
1116
|
+
agentId: string;
|
|
1117
|
+
/** Optional team UUID for team-based execution (routes to team's lead orchestrator) */
|
|
1118
|
+
teamId?: string;
|
|
1119
|
+
/**
|
|
1120
|
+
* Session ID to resume an existing conversation
|
|
1121
|
+
* When provided, the component will load the session's chat history
|
|
1122
|
+
*/
|
|
1123
|
+
sessionId?: string;
|
|
1124
|
+
/** Custom adapter (optional - uses context if not provided) */
|
|
1125
|
+
adapter?: ChatAdapter;
|
|
1126
|
+
/** Callback fired when a new message is added */
|
|
1127
|
+
onMessage?: (message: ChatMessage$1) => void;
|
|
1128
|
+
/** Callback fired when an error occurs */
|
|
1129
|
+
onError?: (error: ChatError) => void;
|
|
1130
|
+
/**
|
|
1131
|
+
* Callback fired when a new session is created
|
|
1132
|
+
* Called with the sessionId when starting a new chat (no existing sessionId)
|
|
1133
|
+
* Useful for updating external state like session lists
|
|
1134
|
+
*/
|
|
1135
|
+
onSessionCreated?: (sessionId: string) => void;
|
|
1136
|
+
/** @deprecated Use onSessionCreated instead */
|
|
1137
|
+
onSessionStart?: (sessionId: string) => void;
|
|
1138
|
+
/** Callback fired when a tool is called */
|
|
1139
|
+
onToolCall?: (toolName: string, args: unknown) => void;
|
|
1140
|
+
/** Callback fired when a tool result is received */
|
|
1141
|
+
onToolResult?: (toolName: string, result: unknown, durationMs?: number) => void;
|
|
1142
|
+
/** Callback fired when clarification is needed */
|
|
1143
|
+
onClarification?: (data: ClarificationData) => void;
|
|
1144
|
+
/** Initial messages to populate the chat */
|
|
1145
|
+
initialMessages?: ChatMessage$1[];
|
|
1146
|
+
/** Placeholder text for the input */
|
|
1147
|
+
placeholder?: string;
|
|
1148
|
+
/** Welcome message shown when chat is empty */
|
|
1149
|
+
welcomeMessage?: string;
|
|
1150
|
+
/**
|
|
1151
|
+
* Custom welcome UI rendered when chat is empty (no messages).
|
|
1152
|
+
* When provided, replaces the default centered text welcome message.
|
|
1153
|
+
* Takes precedence over `welcomeMessage` string prop.
|
|
1154
|
+
*
|
|
1155
|
+
* Can be a ReactNode or a render function receiving `{ sendMessage }`
|
|
1156
|
+
* to allow interactive elements (e.g., suggestion chips) to send messages.
|
|
1157
|
+
*/
|
|
1158
|
+
renderWelcome?: React.ReactNode | ((props: {
|
|
1159
|
+
sendMessage: (text: string) => void;
|
|
1160
|
+
}) => React.ReactNode);
|
|
1161
|
+
/** Maximum height of the chat container */
|
|
1162
|
+
maxHeight?: string | number;
|
|
1163
|
+
/** Additional CSS class for the container */
|
|
1164
|
+
className?: string;
|
|
1165
|
+
/** Theme mode */
|
|
1166
|
+
theme?: ThemeMode;
|
|
1167
|
+
/** Enable file attachments (future feature) */
|
|
1168
|
+
enableAttachments?: boolean;
|
|
1169
|
+
/** Enable markdown rendering */
|
|
1170
|
+
enableMarkdown?: boolean;
|
|
1171
|
+
/** Show tool call visualization */
|
|
1172
|
+
showToolCalls?: boolean;
|
|
1173
|
+
/** Custom markdown component overrides (e.g., for artifact rendering) */
|
|
1174
|
+
markdownComponents?: MessageListProps["markdownComponents"];
|
|
1175
|
+
/** Custom URL transform for markdown (e.g., to preserve artifact: protocol) */
|
|
1176
|
+
markdownUrlTransform?: (url: string) => string;
|
|
1177
|
+
/** Custom content transform for markdown */
|
|
1178
|
+
markdownContentTransform?: (content: string) => string;
|
|
1179
|
+
/** Optional callback when an image in a tool call result is clicked */
|
|
1180
|
+
onImageClick?: (image: {
|
|
1181
|
+
url: string;
|
|
1182
|
+
alt?: string;
|
|
1183
|
+
filename?: string;
|
|
1184
|
+
}) => void;
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Complete chat interface for interacting with AI agents
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* ```tsx
|
|
1191
|
+
* // With ChatConfigProvider (recommended for API key users)
|
|
1192
|
+
* <ChatConfigProvider config={{ baseUrl: '...', apiKey: '...' }}>
|
|
1193
|
+
* <AgentChat
|
|
1194
|
+
* agentId="agent-uuid"
|
|
1195
|
+
* onMessage={(msg) => console.log('New message:', msg)}
|
|
1196
|
+
* />
|
|
1197
|
+
* </ChatConfigProvider>
|
|
1198
|
+
*
|
|
1199
|
+
* // With custom adapter
|
|
1200
|
+
* <AgentChat
|
|
1201
|
+
* agentId="agent-uuid"
|
|
1202
|
+
* adapter={myCustomAdapter}
|
|
1203
|
+
* />
|
|
1204
|
+
* ```
|
|
1205
|
+
*/
|
|
1206
|
+
declare function AgentChat({ agentId, teamId, sessionId, adapter, onMessage, onError, onSessionCreated, onSessionStart, onToolCall, onToolResult, onClarification, initialMessages, placeholder, welcomeMessage, renderWelcome, maxHeight, className, theme, enableAttachments, enableMarkdown, showToolCalls, markdownComponents, markdownUrlTransform, markdownContentTransform, onImageClick, }: AgentChatProps): react_jsx_runtime.JSX.Element;
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* Retry utility with exponential backoff
|
|
1210
|
+
*/
|
|
1211
|
+
/**
|
|
1212
|
+
* Retry configuration
|
|
1213
|
+
*/
|
|
1214
|
+
interface RetryConfig {
|
|
1215
|
+
/** Maximum number of retry attempts (default: 3) */
|
|
1216
|
+
maxRetries: number;
|
|
1217
|
+
/** Base delay in milliseconds (default: 1000) */
|
|
1218
|
+
baseDelayMs: number;
|
|
1219
|
+
/** Maximum delay in milliseconds (default: 30000) */
|
|
1220
|
+
maxDelayMs: number;
|
|
1221
|
+
/** Jitter factor (0-1, default: 0.1) */
|
|
1222
|
+
jitterFactor: number;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* HTTP Client
|
|
1227
|
+
*
|
|
1228
|
+
* Handles all HTTP requests with authentication, retry logic, and error handling.
|
|
1229
|
+
*/
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* HTTP Client configuration
|
|
1233
|
+
*/
|
|
1234
|
+
interface HttpClientConfig {
|
|
1235
|
+
/** Base URL for API requests */
|
|
1236
|
+
baseUrl: string;
|
|
1237
|
+
/** API key for authentication */
|
|
1238
|
+
apiKey?: string;
|
|
1239
|
+
/** OAuth token for authentication */
|
|
1240
|
+
token?: string;
|
|
1241
|
+
/** Token provider callback (called before each request) */
|
|
1242
|
+
tokenProvider?: () => Promise<string>;
|
|
1243
|
+
/** Organization ID */
|
|
1244
|
+
orgId: number;
|
|
1245
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
1246
|
+
timeout: number;
|
|
1247
|
+
/** Retry configuration */
|
|
1248
|
+
retry: RetryConfig;
|
|
1249
|
+
/** Custom headers */
|
|
1250
|
+
headers?: Record<string, string>;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Request options
|
|
1254
|
+
*/
|
|
1255
|
+
interface RequestOptions {
|
|
1256
|
+
/** HTTP method */
|
|
1257
|
+
method: 'GET' | 'POST' | 'PATCH' | 'DELETE' | 'PUT';
|
|
1258
|
+
/** Request path (appended to base URL) */
|
|
1259
|
+
path: string;
|
|
1260
|
+
/** Request body */
|
|
1261
|
+
body?: unknown;
|
|
1262
|
+
/** Query parameters */
|
|
1263
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
1264
|
+
/** Additional headers */
|
|
1265
|
+
headers?: Record<string, string>;
|
|
1266
|
+
/** Skip retry (for non-idempotent operations) */
|
|
1267
|
+
skipRetry?: boolean;
|
|
1268
|
+
/** Idempotency key */
|
|
1269
|
+
idempotencyKey?: string;
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* HTTP Client class
|
|
1273
|
+
*/
|
|
1274
|
+
declare class HttpClient {
|
|
1275
|
+
private config;
|
|
1276
|
+
private tokenRefreshAttempts;
|
|
1277
|
+
private readonly maxTokenRefreshAttempts;
|
|
1278
|
+
constructor(config: HttpClientConfig);
|
|
1279
|
+
/**
|
|
1280
|
+
* Get authorization header value
|
|
1281
|
+
*/
|
|
1282
|
+
private getAuthHeader;
|
|
1283
|
+
/**
|
|
1284
|
+
* Build full URL with query parameters
|
|
1285
|
+
*/
|
|
1286
|
+
private buildUrl;
|
|
1287
|
+
/**
|
|
1288
|
+
* Make an HTTP request
|
|
1289
|
+
*/
|
|
1290
|
+
request<T>(options: RequestOptions): Promise<T>;
|
|
1291
|
+
/**
|
|
1292
|
+
* GET request
|
|
1293
|
+
*/
|
|
1294
|
+
get<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
1295
|
+
/**
|
|
1296
|
+
* POST request
|
|
1297
|
+
*/
|
|
1298
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
1299
|
+
idempotencyKey?: string;
|
|
1300
|
+
skipRetry?: boolean;
|
|
1301
|
+
}): Promise<T>;
|
|
1302
|
+
/**
|
|
1303
|
+
* PATCH request
|
|
1304
|
+
*/
|
|
1305
|
+
patch<T>(path: string, body?: unknown, options?: {
|
|
1306
|
+
idempotencyKey?: string;
|
|
1307
|
+
}): Promise<T>;
|
|
1308
|
+
/**
|
|
1309
|
+
* DELETE request
|
|
1310
|
+
*/
|
|
1311
|
+
delete<T>(path: string): Promise<T>;
|
|
1312
|
+
/**
|
|
1313
|
+
* Update configuration
|
|
1314
|
+
*/
|
|
1315
|
+
updateConfig(config: Partial<HttpClientConfig>): void;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Skill types
|
|
1320
|
+
*/
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* Skill tool reference
|
|
1324
|
+
*/
|
|
1325
|
+
interface SkillTool {
|
|
1326
|
+
/** Tool UUID */
|
|
1327
|
+
uuid: string;
|
|
1328
|
+
/** Tool name */
|
|
1329
|
+
name: string;
|
|
1330
|
+
/** Tool description */
|
|
1331
|
+
description: string;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Skill variable definition
|
|
1335
|
+
*/
|
|
1336
|
+
interface SkillVariable {
|
|
1337
|
+
/** Variable name */
|
|
1338
|
+
name: string;
|
|
1339
|
+
/** Variable type */
|
|
1340
|
+
type: 'string' | 'number' | 'boolean' | 'object';
|
|
1341
|
+
/** Variable description */
|
|
1342
|
+
description: string;
|
|
1343
|
+
/** Whether the variable is required */
|
|
1344
|
+
required: boolean;
|
|
1345
|
+
/** Default value */
|
|
1346
|
+
default?: unknown;
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Skill resource (list view)
|
|
1350
|
+
*/
|
|
1351
|
+
interface Skill {
|
|
1352
|
+
/** Unique identifier */
|
|
1353
|
+
uuid: string;
|
|
1354
|
+
/** Skill name */
|
|
1355
|
+
name: string;
|
|
1356
|
+
/** Skill description */
|
|
1357
|
+
description: string | null;
|
|
1358
|
+
/** Category */
|
|
1359
|
+
category: string | null;
|
|
1360
|
+
/** Tags */
|
|
1361
|
+
tags: string[];
|
|
1362
|
+
/** Version string */
|
|
1363
|
+
version: string;
|
|
1364
|
+
/** Whether skill is public */
|
|
1365
|
+
isPublic: boolean;
|
|
1366
|
+
/** Creation timestamp */
|
|
1367
|
+
createdAt: string;
|
|
1368
|
+
/** Last update timestamp */
|
|
1369
|
+
updatedAt: string;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Skill details (get view, includes prompt template)
|
|
1373
|
+
*/
|
|
1374
|
+
interface SkillDetails extends Skill {
|
|
1375
|
+
/** Prompt template */
|
|
1376
|
+
promptTemplate: string;
|
|
1377
|
+
/** Associated tools */
|
|
1378
|
+
tools: SkillTool[];
|
|
1379
|
+
/** Variable definitions */
|
|
1380
|
+
variables: SkillVariable[];
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Skill list options
|
|
1384
|
+
*/
|
|
1385
|
+
interface SkillListOptions extends ListOptions {
|
|
1386
|
+
/** Filter by category */
|
|
1387
|
+
category?: string;
|
|
1388
|
+
/** Filter by tags (any match) */
|
|
1389
|
+
tags?: string[];
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Skill execute input
|
|
1393
|
+
*/
|
|
1394
|
+
interface SkillExecuteInput {
|
|
1395
|
+
/** Variable values for the prompt template */
|
|
1396
|
+
variables?: Record<string, unknown>;
|
|
1397
|
+
/** Additional context */
|
|
1398
|
+
context?: Record<string, unknown>;
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Skill execution result
|
|
1402
|
+
*/
|
|
1403
|
+
interface SkillExecution {
|
|
1404
|
+
/** Execution ID */
|
|
1405
|
+
uuid: string;
|
|
1406
|
+
/** Skill ID */
|
|
1407
|
+
skillUuid: string;
|
|
1408
|
+
/** Execution status */
|
|
1409
|
+
status: 'success' | 'error';
|
|
1410
|
+
/** Input variables */
|
|
1411
|
+
input: Record<string, unknown>;
|
|
1412
|
+
/** Generated prompt output */
|
|
1413
|
+
output?: string;
|
|
1414
|
+
/** Error message */
|
|
1415
|
+
error?: string;
|
|
1416
|
+
/** Execution timestamp */
|
|
1417
|
+
executedAt: string;
|
|
1418
|
+
/** Duration in milliseconds */
|
|
1419
|
+
durationMs: number;
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Skill update input
|
|
1423
|
+
*/
|
|
1424
|
+
interface SkillUpdateInput {
|
|
1425
|
+
/** New name */
|
|
1426
|
+
name?: string;
|
|
1427
|
+
/** New description */
|
|
1428
|
+
description?: string;
|
|
1429
|
+
/** New category */
|
|
1430
|
+
category?: string;
|
|
1431
|
+
/** New tags */
|
|
1432
|
+
tags?: string[];
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Tool types
|
|
1437
|
+
*/
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Tool resource
|
|
1441
|
+
*/
|
|
1442
|
+
interface Tool {
|
|
1443
|
+
/** Unique identifier */
|
|
1444
|
+
uuid: string;
|
|
1445
|
+
/** Tool name */
|
|
1446
|
+
name: string;
|
|
1447
|
+
/** Tool description */
|
|
1448
|
+
description: string;
|
|
1449
|
+
/** Category */
|
|
1450
|
+
category: string | null;
|
|
1451
|
+
/** Input JSON schema */
|
|
1452
|
+
inputSchema: JSONSchema;
|
|
1453
|
+
/** Output JSON schema */
|
|
1454
|
+
outputSchema?: JSONSchema;
|
|
1455
|
+
/** Whether tool is enabled */
|
|
1456
|
+
isEnabled: boolean;
|
|
1457
|
+
/** Creation timestamp */
|
|
1458
|
+
createdAt: string;
|
|
1459
|
+
/** Last update timestamp */
|
|
1460
|
+
updatedAt: string;
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Tool list options
|
|
1464
|
+
*/
|
|
1465
|
+
interface ToolListOptions extends ListOptions {
|
|
1466
|
+
/** Filter by category */
|
|
1467
|
+
category?: string;
|
|
1468
|
+
/** Filter by enabled status */
|
|
1469
|
+
isEnabled?: boolean;
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Tool execution result
|
|
1473
|
+
*/
|
|
1474
|
+
interface ToolExecution {
|
|
1475
|
+
/** Execution ID */
|
|
1476
|
+
uuid: string;
|
|
1477
|
+
/** Tool ID */
|
|
1478
|
+
toolUuid: string;
|
|
1479
|
+
/** Execution status */
|
|
1480
|
+
status: 'success' | 'error';
|
|
1481
|
+
/** Input provided */
|
|
1482
|
+
input: Record<string, unknown>;
|
|
1483
|
+
/** Output result */
|
|
1484
|
+
output?: unknown;
|
|
1485
|
+
/** Error message */
|
|
1486
|
+
error?: string;
|
|
1487
|
+
/** Duration in milliseconds */
|
|
1488
|
+
durationMs: number;
|
|
1489
|
+
/** Execution timestamp */
|
|
1490
|
+
executedAt: string;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Tool input validation result
|
|
1494
|
+
*/
|
|
1495
|
+
interface ToolValidationResult {
|
|
1496
|
+
/** Whether the input is valid */
|
|
1497
|
+
valid: boolean;
|
|
1498
|
+
/** Validation errors (if invalid) */
|
|
1499
|
+
errors?: Array<{
|
|
1500
|
+
field: string;
|
|
1501
|
+
message: string;
|
|
1502
|
+
}>;
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Tool update input
|
|
1506
|
+
*/
|
|
1507
|
+
interface ToolUpdateInput {
|
|
1508
|
+
/** New name */
|
|
1509
|
+
name?: string;
|
|
1510
|
+
/** New description */
|
|
1511
|
+
description?: string;
|
|
1512
|
+
/** New category */
|
|
1513
|
+
category?: string;
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Tool config update input
|
|
1517
|
+
*/
|
|
1518
|
+
interface ToolConfigUpdateInput {
|
|
1519
|
+
/** Tool-specific configuration */
|
|
1520
|
+
config?: Record<string, unknown>;
|
|
1521
|
+
/** Enable/disable tool */
|
|
1522
|
+
isEnabled?: boolean;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* Artifact types
|
|
1527
|
+
*/
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Artifact type
|
|
1531
|
+
*/
|
|
1532
|
+
type ArtifactType = 'file' | 'data' | 'log';
|
|
1533
|
+
/**
|
|
1534
|
+
* Artifact resource
|
|
1535
|
+
*/
|
|
1536
|
+
interface Artifact {
|
|
1537
|
+
/** Unique identifier */
|
|
1538
|
+
uuid: string;
|
|
1539
|
+
/** Associated execution ID */
|
|
1540
|
+
executionUuid: string;
|
|
1541
|
+
/** Artifact name */
|
|
1542
|
+
name: string;
|
|
1543
|
+
/** Artifact type */
|
|
1544
|
+
type: ArtifactType;
|
|
1545
|
+
/** MIME type */
|
|
1546
|
+
mimeType: string;
|
|
1547
|
+
/** Size in bytes */
|
|
1548
|
+
size: number;
|
|
1549
|
+
/** Creation timestamp */
|
|
1550
|
+
createdAt: string;
|
|
1551
|
+
/** Additional metadata */
|
|
1552
|
+
metadata?: Record<string, unknown>;
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Artifact list options
|
|
1556
|
+
*/
|
|
1557
|
+
interface ArtifactListOptions extends ListOptions {
|
|
1558
|
+
/** Filter by type */
|
|
1559
|
+
type?: ArtifactType;
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Artifact download options
|
|
1563
|
+
*/
|
|
1564
|
+
interface ArtifactDownloadOptions {
|
|
1565
|
+
/** Response format (only for getSignedUrl) */
|
|
1566
|
+
format?: 'buffer' | 'stream' | 'url';
|
|
1567
|
+
/** Expiration time in seconds for signed URL (default: 3600) */
|
|
1568
|
+
expiresIn?: number;
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Signed URL response
|
|
1572
|
+
*/
|
|
1573
|
+
interface SignedUrlResponse {
|
|
1574
|
+
/** The signed URL */
|
|
1575
|
+
url: string;
|
|
1576
|
+
/** When the URL expires */
|
|
1577
|
+
expiresAt: string;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Artifact upload input
|
|
1581
|
+
*/
|
|
1582
|
+
interface ArtifactUploadInput {
|
|
1583
|
+
/** File name */
|
|
1584
|
+
name: string;
|
|
1585
|
+
/** File content (Buffer in Node.js, Blob in browser) */
|
|
1586
|
+
content: Buffer | Blob | ReadableStream<Uint8Array>;
|
|
1587
|
+
/** MIME type */
|
|
1588
|
+
mimeType?: string;
|
|
1589
|
+
/** Artifact type */
|
|
1590
|
+
type?: ArtifactType;
|
|
1591
|
+
/** Additional metadata */
|
|
1592
|
+
metadata?: Record<string, unknown>;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* Session types
|
|
1597
|
+
*/
|
|
1598
|
+
|
|
1599
|
+
/**
|
|
1600
|
+
* Session resource
|
|
1601
|
+
*/
|
|
1602
|
+
interface Session {
|
|
1603
|
+
/** Session ID */
|
|
1604
|
+
id: string;
|
|
1605
|
+
/** Associated agent ID */
|
|
1606
|
+
agentUuid: string;
|
|
1607
|
+
/** Creation timestamp */
|
|
1608
|
+
createdAt: string;
|
|
1609
|
+
/** Last message timestamp */
|
|
1610
|
+
lastMessageAt: string;
|
|
1611
|
+
/** Number of messages in session */
|
|
1612
|
+
messageCount: number;
|
|
1613
|
+
/** Last user message (for session list preview) */
|
|
1614
|
+
lastUserMessage?: string | null;
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Session message
|
|
1618
|
+
*/
|
|
1619
|
+
interface SessionMessage {
|
|
1620
|
+
/** Message ID */
|
|
1621
|
+
id: string;
|
|
1622
|
+
/** Message role */
|
|
1623
|
+
role: 'user' | 'assistant' | 'system';
|
|
1624
|
+
/** Message content */
|
|
1625
|
+
content: string;
|
|
1626
|
+
/** Associated execution ID (for assistant messages) */
|
|
1627
|
+
executionUuid?: string;
|
|
1628
|
+
/** Message timestamp */
|
|
1629
|
+
timestamp: string;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Session history with messages
|
|
1633
|
+
*/
|
|
1634
|
+
interface SessionHistory {
|
|
1635
|
+
/** Session info */
|
|
1636
|
+
session: Session;
|
|
1637
|
+
/** Messages in chronological order */
|
|
1638
|
+
messages: SessionMessage[];
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Session list options
|
|
1642
|
+
*/
|
|
1643
|
+
interface SessionListOptions extends ListOptions {
|
|
1644
|
+
/** Filter by agent */
|
|
1645
|
+
agentUuid?: string;
|
|
1646
|
+
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Session create input
|
|
1649
|
+
*/
|
|
1650
|
+
interface SessionCreateInput {
|
|
1651
|
+
/** Agent to associate with the session */
|
|
1652
|
+
agentUuid: string;
|
|
1653
|
+
/** Initial system message (optional) */
|
|
1654
|
+
systemMessage?: string;
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Send message input
|
|
1658
|
+
*/
|
|
1659
|
+
interface SendMessageInput {
|
|
1660
|
+
/** Message content */
|
|
1661
|
+
message: string;
|
|
1662
|
+
/** Additional context */
|
|
1663
|
+
context?: Record<string, unknown>;
|
|
1664
|
+
/** Attachment UUIDs to include with the message (for images, documents, etc.) */
|
|
1665
|
+
attachmentIds?: string[];
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Session artifact type
|
|
1669
|
+
*/
|
|
1670
|
+
type SessionArtifactType = 'file' | 'image' | 'code' | 'data' | 'log' | 'report';
|
|
1671
|
+
/**
|
|
1672
|
+
* Session artifact variant type
|
|
1673
|
+
*/
|
|
1674
|
+
type SessionArtifactVariantType = 'original' | 'thumbnail';
|
|
1675
|
+
/**
|
|
1676
|
+
* Session artifact resource
|
|
1677
|
+
* Represents an artifact generated during a session execution
|
|
1678
|
+
*/
|
|
1679
|
+
interface SessionArtifact {
|
|
1680
|
+
/** Unique identifier */
|
|
1681
|
+
uuid: string;
|
|
1682
|
+
/** Associated execution ID */
|
|
1683
|
+
executionId: string;
|
|
1684
|
+
/** Artifact type */
|
|
1685
|
+
type: SessionArtifactType;
|
|
1686
|
+
/** Variant type (original or thumbnail) */
|
|
1687
|
+
variantType: SessionArtifactVariantType;
|
|
1688
|
+
/** Original filename */
|
|
1689
|
+
filename: string;
|
|
1690
|
+
/** MIME type */
|
|
1691
|
+
mimeType: string;
|
|
1692
|
+
/** Size in bytes */
|
|
1693
|
+
size: number;
|
|
1694
|
+
/** Pre-signed URL for accessing the artifact */
|
|
1695
|
+
url: string;
|
|
1696
|
+
/** Thumbnail URL (for images) */
|
|
1697
|
+
thumbnailUrl?: string;
|
|
1698
|
+
/** Image dimensions (for images) */
|
|
1699
|
+
dimensions?: {
|
|
1700
|
+
width: number;
|
|
1701
|
+
height: number;
|
|
1702
|
+
};
|
|
1703
|
+
/** Description */
|
|
1704
|
+
description?: string | null;
|
|
1705
|
+
/** Additional metadata */
|
|
1706
|
+
metadata?: Record<string, unknown> | null;
|
|
1707
|
+
/** Creation timestamp */
|
|
1708
|
+
createdAt: string;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Session artifact list options
|
|
1712
|
+
*/
|
|
1713
|
+
interface SessionArtifactListOptions extends ListOptions {
|
|
1714
|
+
/** Filter by artifact type */
|
|
1715
|
+
type?: SessionArtifactType;
|
|
1716
|
+
/** Include thumbnail variants (default: false) */
|
|
1717
|
+
includeVariants?: boolean;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* Base Resource API
|
|
1722
|
+
*
|
|
1723
|
+
* Abstract base class for all resource APIs.
|
|
1724
|
+
* Provides common HTTP methods and path handling.
|
|
1725
|
+
*/
|
|
1726
|
+
|
|
1727
|
+
/**
|
|
1728
|
+
* Base Resource API class
|
|
1729
|
+
*/
|
|
1730
|
+
declare abstract class BaseResourceAPI {
|
|
1731
|
+
protected readonly http: HttpClient;
|
|
1732
|
+
protected readonly basePath: string;
|
|
1733
|
+
constructor(http: HttpClient, basePath: string);
|
|
1734
|
+
/**
|
|
1735
|
+
* Build query parameters from list options
|
|
1736
|
+
*/
|
|
1737
|
+
protected buildListQuery(options?: ListOptions): Record<string, string | number | boolean | undefined>;
|
|
1738
|
+
/**
|
|
1739
|
+
* HTTP GET request helper
|
|
1740
|
+
*/
|
|
1741
|
+
protected httpGet<T>(path: string, query?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
1742
|
+
/**
|
|
1743
|
+
* HTTP POST request helper
|
|
1744
|
+
*/
|
|
1745
|
+
protected httpPost<T>(path: string, body?: unknown, options?: {
|
|
1746
|
+
idempotencyKey?: string;
|
|
1747
|
+
skipRetry?: boolean;
|
|
1748
|
+
}): Promise<T>;
|
|
1749
|
+
/**
|
|
1750
|
+
* HTTP PATCH request helper
|
|
1751
|
+
*/
|
|
1752
|
+
protected httpPatch<T>(path: string, body?: unknown, options?: {
|
|
1753
|
+
idempotencyKey?: string;
|
|
1754
|
+
}): Promise<T>;
|
|
1755
|
+
/**
|
|
1756
|
+
* HTTP DELETE request helper
|
|
1757
|
+
*/
|
|
1758
|
+
protected httpDelete<T>(path: string): Promise<T>;
|
|
1759
|
+
/**
|
|
1760
|
+
* List resources with pagination
|
|
1761
|
+
*/
|
|
1762
|
+
protected listResources<T>(path: string, options?: ListOptions): Promise<PaginatedResponse<T>>;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* Agents Resource API
|
|
1767
|
+
*
|
|
1768
|
+
* Provides all agent-related operations:
|
|
1769
|
+
* - List: list(), get()
|
|
1770
|
+
* - Execute: execute(), executeSync(), stream()
|
|
1771
|
+
* - Receive: getExecution()
|
|
1772
|
+
* - Edit: update(), updateConfig(), cancelExecution()
|
|
1773
|
+
*/
|
|
1774
|
+
|
|
1775
|
+
/**
|
|
1776
|
+
* Agents API class
|
|
1777
|
+
*/
|
|
1778
|
+
declare class AgentsAPI extends BaseResourceAPI {
|
|
1779
|
+
private readonly getStreamConfig;
|
|
1780
|
+
constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
|
|
1781
|
+
/**
|
|
1782
|
+
* List all agents in the organization
|
|
1783
|
+
*
|
|
1784
|
+
* @param options - List options (pagination, filtering)
|
|
1785
|
+
* @returns Paginated list of agents
|
|
1786
|
+
*
|
|
1787
|
+
* @example
|
|
1788
|
+
* ```typescript
|
|
1789
|
+
* const { data: agents, pagination } = await client.agents.list({ limit: 10 });
|
|
1790
|
+
* ```
|
|
1791
|
+
*/
|
|
1792
|
+
list(options?: AgentListOptions): Promise<PaginatedResponse<Agent>>;
|
|
1793
|
+
/**
|
|
1794
|
+
* Get a single agent by UUID
|
|
1795
|
+
*
|
|
1796
|
+
* @param uuid - Agent UUID
|
|
1797
|
+
* @returns Agent with configuration
|
|
1798
|
+
*
|
|
1799
|
+
* @example
|
|
1800
|
+
* ```typescript
|
|
1801
|
+
* const agent = await client.agents.get('agent-uuid');
|
|
1802
|
+
* console.log(agent.config);
|
|
1803
|
+
* ```
|
|
1804
|
+
*/
|
|
1805
|
+
get(uuid: string): Promise<Agent>;
|
|
1806
|
+
/**
|
|
1807
|
+
* Start an agent execution (async)
|
|
1808
|
+
*
|
|
1809
|
+
* Returns immediately with execution ID. Use getExecution() to poll
|
|
1810
|
+
* for results, or use stream() for real-time updates.
|
|
1811
|
+
*
|
|
1812
|
+
* @param uuid - Agent UUID
|
|
1813
|
+
* @param input - Execution input (task, context, options)
|
|
1814
|
+
* @returns Execution ID and initial status
|
|
1815
|
+
*
|
|
1816
|
+
* @example
|
|
1817
|
+
* ```typescript
|
|
1818
|
+
* const { executionId, status } = await client.agents.execute('agent-uuid', {
|
|
1819
|
+
* task: 'Summarize the latest news about AI',
|
|
1820
|
+
* });
|
|
1821
|
+
* ```
|
|
1822
|
+
*/
|
|
1823
|
+
execute(uuid: string, input: ExecuteInput): Promise<ExecuteResponse>;
|
|
1824
|
+
/**
|
|
1825
|
+
* Execute an agent and wait for completion (sync)
|
|
1826
|
+
*
|
|
1827
|
+
* Polls the execution status until completion or failure.
|
|
1828
|
+
*
|
|
1829
|
+
* @param uuid - Agent UUID
|
|
1830
|
+
* @param input - Execution input
|
|
1831
|
+
* @param pollInterval - Polling interval in ms (default: 1000)
|
|
1832
|
+
* @returns Final execution result
|
|
1833
|
+
*
|
|
1834
|
+
* @example
|
|
1835
|
+
* ```typescript
|
|
1836
|
+
* const execution = await client.agents.executeSync('agent-uuid', {
|
|
1837
|
+
* task: 'Write a haiku about coding',
|
|
1838
|
+
* });
|
|
1839
|
+
* console.log(execution.output);
|
|
1840
|
+
* ```
|
|
1841
|
+
*/
|
|
1842
|
+
executeSync(uuid: string, input: ExecuteInput, pollInterval?: number): Promise<AgentExecution>;
|
|
1843
|
+
/**
|
|
1844
|
+
* Stream an agent execution
|
|
1845
|
+
*
|
|
1846
|
+
* Returns a StreamController for real-time event handling.
|
|
1847
|
+
*
|
|
1848
|
+
* @param uuid - Agent UUID
|
|
1849
|
+
* @param input - Execution input
|
|
1850
|
+
* @returns Stream controller for event handling
|
|
1851
|
+
*
|
|
1852
|
+
* @example
|
|
1853
|
+
* ```typescript
|
|
1854
|
+
* const stream = await client.agents.stream('agent-uuid', {
|
|
1855
|
+
* task: 'Research climate change',
|
|
1856
|
+
* });
|
|
1857
|
+
*
|
|
1858
|
+
* stream.on('log', (log) => console.log(log.title));
|
|
1859
|
+
* stream.on('toolCall', ({ toolName }) => console.log(`Calling ${toolName}`));
|
|
1860
|
+
* stream.on('complete', ({ execution }) => console.log(execution.output));
|
|
1861
|
+
*
|
|
1862
|
+
* const result = await stream.wait();
|
|
1863
|
+
* ```
|
|
1864
|
+
*/
|
|
1865
|
+
stream(uuid: string, input: ExecuteInput): Promise<ExecutionStreamController>;
|
|
1866
|
+
/**
|
|
1867
|
+
* Connect to an existing execution's stream
|
|
1868
|
+
*
|
|
1869
|
+
* Use this when the execution was started externally (e.g., via tRPC for team executions)
|
|
1870
|
+
* and you need to connect to its SSE stream for real-time updates.
|
|
1871
|
+
*
|
|
1872
|
+
* @param executionId - Execution UUID (already running)
|
|
1873
|
+
* @param sessionId - Optional session ID for conversation continuity
|
|
1874
|
+
* @returns Stream controller for the execution
|
|
1875
|
+
*
|
|
1876
|
+
* @example
|
|
1877
|
+
* ```typescript
|
|
1878
|
+
* // Execution started via tRPC
|
|
1879
|
+
* const executionId = await trpc.executions.start.mutate({ teamUuid, task });
|
|
1880
|
+
*
|
|
1881
|
+
* // Connect to SSE stream for real-time updates
|
|
1882
|
+
* const stream = client.agents.streamExecution(executionId);
|
|
1883
|
+
*
|
|
1884
|
+
* stream.on('log', (log) => console.log(log.title));
|
|
1885
|
+
* stream.on('delegationStarted', (data) => console.log('Subagent:', data.targetAgentName));
|
|
1886
|
+
* stream.on('complete', ({ execution }) => console.log(execution.output));
|
|
1887
|
+
*
|
|
1888
|
+
* await stream.connect();
|
|
1889
|
+
* const result = await stream.wait();
|
|
1890
|
+
* ```
|
|
1891
|
+
*/
|
|
1892
|
+
streamExecution(executionId: string, sessionId?: string): ExecutionStreamController;
|
|
1893
|
+
/**
|
|
1894
|
+
* Get execution result by ID
|
|
1895
|
+
*
|
|
1896
|
+
* @param executionId - Execution UUID
|
|
1897
|
+
* @returns Execution details including status, output, logs
|
|
1898
|
+
*
|
|
1899
|
+
* @example
|
|
1900
|
+
* ```typescript
|
|
1901
|
+
* const execution = await client.agents.getExecution('exec-uuid');
|
|
1902
|
+
* if (execution.status === 'completed') {
|
|
1903
|
+
* console.log(execution.output);
|
|
1904
|
+
* }
|
|
1905
|
+
* ```
|
|
1906
|
+
*/
|
|
1907
|
+
getExecution(executionId: string): Promise<AgentExecution>;
|
|
1908
|
+
/**
|
|
1909
|
+
* Update agent details
|
|
1910
|
+
*
|
|
1911
|
+
* @param uuid - Agent UUID
|
|
1912
|
+
* @param data - Fields to update
|
|
1913
|
+
* @returns Updated agent
|
|
1914
|
+
*
|
|
1915
|
+
* @example
|
|
1916
|
+
* ```typescript
|
|
1917
|
+
* const agent = await client.agents.update('agent-uuid', {
|
|
1918
|
+
* name: 'My Updated Agent',
|
|
1919
|
+
* description: 'New description',
|
|
1920
|
+
* });
|
|
1921
|
+
* ```
|
|
1922
|
+
*/
|
|
1923
|
+
update(uuid: string, data: AgentUpdateInput): Promise<Agent>;
|
|
1924
|
+
/**
|
|
1925
|
+
* Update agent configuration
|
|
1926
|
+
*
|
|
1927
|
+
* @param uuid - Agent UUID
|
|
1928
|
+
* @param config - Configuration fields to update
|
|
1929
|
+
* @returns Updated agent
|
|
1930
|
+
*
|
|
1931
|
+
* @example
|
|
1932
|
+
* ```typescript
|
|
1933
|
+
* const agent = await client.agents.updateConfig('agent-uuid', {
|
|
1934
|
+
* temperature: 0.7,
|
|
1935
|
+
* maxIterations: 5,
|
|
1936
|
+
* });
|
|
1937
|
+
* ```
|
|
1938
|
+
*/
|
|
1939
|
+
updateConfig(uuid: string, config: AgentConfigUpdateInput): Promise<Agent>;
|
|
1940
|
+
/**
|
|
1941
|
+
* Cancel a running execution
|
|
1942
|
+
*
|
|
1943
|
+
* @param executionId - Execution UUID
|
|
1944
|
+
* @returns Updated execution with cancelled status
|
|
1945
|
+
*
|
|
1946
|
+
* @example
|
|
1947
|
+
* ```typescript
|
|
1948
|
+
* const execution = await client.agents.cancelExecution('exec-uuid');
|
|
1949
|
+
* console.log(execution.status); // 'cancelled'
|
|
1950
|
+
* ```
|
|
1951
|
+
*/
|
|
1952
|
+
cancelExecution(executionId: string): Promise<AgentExecution>;
|
|
1953
|
+
/**
|
|
1954
|
+
* Poll execution until completion
|
|
1955
|
+
*/
|
|
1956
|
+
private pollExecution;
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Stream configuration passed from client
|
|
1960
|
+
*/
|
|
1961
|
+
interface StreamConfig {
|
|
1962
|
+
baseUrl: string;
|
|
1963
|
+
apiKey?: string;
|
|
1964
|
+
token?: string;
|
|
1965
|
+
tokenProvider?: () => Promise<string>;
|
|
1966
|
+
orgId: number;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* Skills Resource API
|
|
1971
|
+
*
|
|
1972
|
+
* Provides all skill-related operations:
|
|
1973
|
+
* - List: list(), get(), getTools()
|
|
1974
|
+
* - Execute: execute()
|
|
1975
|
+
* - Receive: getExecution()
|
|
1976
|
+
* - Edit: update(), updatePrompt()
|
|
1977
|
+
*/
|
|
1978
|
+
|
|
1979
|
+
/**
|
|
1980
|
+
* Skills API class
|
|
1981
|
+
*/
|
|
1982
|
+
declare class SkillsAPI extends BaseResourceAPI {
|
|
1983
|
+
constructor(http: HttpClient);
|
|
1984
|
+
/**
|
|
1985
|
+
* List all skills in the organization
|
|
1986
|
+
*
|
|
1987
|
+
* @param options - List options (pagination, filtering by category/tags)
|
|
1988
|
+
* @returns Paginated list of skills
|
|
1989
|
+
*
|
|
1990
|
+
* @example
|
|
1991
|
+
* ```typescript
|
|
1992
|
+
* const { data: skills } = await client.skills.list({
|
|
1993
|
+
* category: 'writing',
|
|
1994
|
+
* tags: ['seo', 'blog'],
|
|
1995
|
+
* });
|
|
1996
|
+
* ```
|
|
1997
|
+
*/
|
|
1998
|
+
list(options?: SkillListOptions): Promise<PaginatedResponse<Skill>>;
|
|
1999
|
+
/**
|
|
2000
|
+
* Get a single skill by UUID with full details
|
|
2001
|
+
*
|
|
2002
|
+
* @param uuid - Skill UUID
|
|
2003
|
+
* @returns Skill with prompt template and tools
|
|
2004
|
+
*
|
|
2005
|
+
* @example
|
|
2006
|
+
* ```typescript
|
|
2007
|
+
* const skill = await client.skills.get('skill-uuid');
|
|
2008
|
+
* console.log(skill.promptTemplate);
|
|
2009
|
+
* ```
|
|
2010
|
+
*/
|
|
2011
|
+
get(uuid: string): Promise<SkillDetails>;
|
|
2012
|
+
/**
|
|
2013
|
+
* Get tools associated with a skill
|
|
2014
|
+
*
|
|
2015
|
+
* @param uuid - Skill UUID
|
|
2016
|
+
* @returns Array of tools used by the skill
|
|
2017
|
+
*
|
|
2018
|
+
* @example
|
|
2019
|
+
* ```typescript
|
|
2020
|
+
* const tools = await client.skills.getTools('skill-uuid');
|
|
2021
|
+
* tools.forEach(tool => console.log(tool.name));
|
|
2022
|
+
* ```
|
|
2023
|
+
*/
|
|
2024
|
+
getTools(uuid: string): Promise<SkillTool[]>;
|
|
2025
|
+
/**
|
|
2026
|
+
* Execute a skill with variables
|
|
2027
|
+
*
|
|
2028
|
+
* @param uuid - Skill UUID
|
|
2029
|
+
* @param input - Variables and context for execution
|
|
2030
|
+
* @returns Skill execution result
|
|
2031
|
+
*
|
|
2032
|
+
* @example
|
|
2033
|
+
* ```typescript
|
|
2034
|
+
* const result = await client.skills.execute('skill-uuid', {
|
|
2035
|
+
* variables: {
|
|
2036
|
+
* topic: 'AI in healthcare',
|
|
2037
|
+
* tone: 'professional',
|
|
2038
|
+
* },
|
|
2039
|
+
* });
|
|
2040
|
+
* console.log(result.output);
|
|
2041
|
+
* ```
|
|
2042
|
+
*/
|
|
2043
|
+
execute(uuid: string, input: SkillExecuteInput): Promise<SkillExecution>;
|
|
2044
|
+
/**
|
|
2045
|
+
* Get skill execution result by ID
|
|
2046
|
+
*
|
|
2047
|
+
* @param executionId - Execution UUID
|
|
2048
|
+
* @returns Skill execution details
|
|
2049
|
+
*
|
|
2050
|
+
* @example
|
|
2051
|
+
* ```typescript
|
|
2052
|
+
* const execution = await client.skills.getExecution('exec-uuid');
|
|
2053
|
+
* ```
|
|
2054
|
+
*/
|
|
2055
|
+
getExecution(executionId: string): Promise<SkillExecution>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Update skill details
|
|
2058
|
+
*
|
|
2059
|
+
* @param uuid - Skill UUID
|
|
2060
|
+
* @param data - Fields to update
|
|
2061
|
+
* @returns Updated skill
|
|
2062
|
+
*
|
|
2063
|
+
* @example
|
|
2064
|
+
* ```typescript
|
|
2065
|
+
* const skill = await client.skills.update('skill-uuid', {
|
|
2066
|
+
* name: 'Updated Skill Name',
|
|
2067
|
+
* tags: ['new-tag'],
|
|
2068
|
+
* });
|
|
2069
|
+
* ```
|
|
2070
|
+
*/
|
|
2071
|
+
update(uuid: string, data: SkillUpdateInput): Promise<Skill>;
|
|
2072
|
+
/**
|
|
2073
|
+
* Update skill prompt template
|
|
2074
|
+
*
|
|
2075
|
+
* @param uuid - Skill UUID
|
|
2076
|
+
* @param prompt - New prompt template
|
|
2077
|
+
* @returns Updated skill with new version
|
|
2078
|
+
*
|
|
2079
|
+
* @example
|
|
2080
|
+
* ```typescript
|
|
2081
|
+
* const skill = await client.skills.updatePrompt('skill-uuid',
|
|
2082
|
+
* 'Write a {{tone}} article about {{topic}}...'
|
|
2083
|
+
* );
|
|
2084
|
+
* console.log(skill.version); // Version incremented
|
|
2085
|
+
* ```
|
|
2086
|
+
*/
|
|
2087
|
+
updatePrompt(uuid: string, prompt: string): Promise<SkillDetails>;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Tools Resource API
|
|
2092
|
+
*
|
|
2093
|
+
* Provides all tool-related operations:
|
|
2094
|
+
* - List: list(), get()
|
|
2095
|
+
* - Execute: execute(), validateInput()
|
|
2096
|
+
* - Receive: getExecution()
|
|
2097
|
+
* - Edit: update(), updateConfig()
|
|
2098
|
+
*/
|
|
2099
|
+
|
|
2100
|
+
/**
|
|
2101
|
+
* Tools API class
|
|
2102
|
+
*/
|
|
2103
|
+
declare class ToolsAPI extends BaseResourceAPI {
|
|
2104
|
+
constructor(http: HttpClient);
|
|
2105
|
+
/**
|
|
2106
|
+
* List all tools in the organization
|
|
2107
|
+
*
|
|
2108
|
+
* @param options - List options (pagination, filtering)
|
|
2109
|
+
* @returns Paginated list of tools
|
|
2110
|
+
*
|
|
2111
|
+
* @example
|
|
2112
|
+
* ```typescript
|
|
2113
|
+
* const { data: tools } = await client.tools.list({
|
|
2114
|
+
* category: 'data',
|
|
2115
|
+
* isEnabled: true,
|
|
2116
|
+
* });
|
|
2117
|
+
* ```
|
|
2118
|
+
*/
|
|
2119
|
+
list(options?: ToolListOptions): Promise<PaginatedResponse<Tool>>;
|
|
2120
|
+
/**
|
|
2121
|
+
* Get a single tool by UUID with schema
|
|
2122
|
+
*
|
|
2123
|
+
* @param uuid - Tool UUID
|
|
2124
|
+
* @returns Tool with input/output schemas
|
|
2125
|
+
*
|
|
2126
|
+
* @example
|
|
2127
|
+
* ```typescript
|
|
2128
|
+
* const tool = await client.tools.get('tool-uuid');
|
|
2129
|
+
* console.log(tool.inputSchema);
|
|
2130
|
+
* ```
|
|
2131
|
+
*/
|
|
2132
|
+
get(uuid: string): Promise<Tool>;
|
|
2133
|
+
/**
|
|
2134
|
+
* Execute a tool directly
|
|
2135
|
+
*
|
|
2136
|
+
* @param uuid - Tool UUID
|
|
2137
|
+
* @param input - Tool input (validated against inputSchema)
|
|
2138
|
+
* @returns Tool execution result
|
|
2139
|
+
*
|
|
2140
|
+
* @example
|
|
2141
|
+
* ```typescript
|
|
2142
|
+
* const result = await client.tools.execute('tool-uuid', {
|
|
2143
|
+
* query: 'weather in London',
|
|
2144
|
+
* limit: 5,
|
|
2145
|
+
* });
|
|
2146
|
+
* console.log(result.output);
|
|
2147
|
+
* ```
|
|
2148
|
+
*/
|
|
2149
|
+
execute(uuid: string, input: Record<string, unknown>): Promise<ToolExecution>;
|
|
2150
|
+
/**
|
|
2151
|
+
* Validate input against tool schema
|
|
2152
|
+
*
|
|
2153
|
+
* @param uuid - Tool UUID
|
|
2154
|
+
* @param input - Input to validate
|
|
2155
|
+
* @returns Validation result with errors if invalid
|
|
2156
|
+
*
|
|
2157
|
+
* @example
|
|
2158
|
+
* ```typescript
|
|
2159
|
+
* const validation = await client.tools.validateInput('tool-uuid', {
|
|
2160
|
+
* query: 'test',
|
|
2161
|
+
* });
|
|
2162
|
+
* if (!validation.valid) {
|
|
2163
|
+
* console.log(validation.errors);
|
|
2164
|
+
* }
|
|
2165
|
+
* ```
|
|
2166
|
+
*/
|
|
2167
|
+
validateInput(uuid: string, input: Record<string, unknown>): Promise<ToolValidationResult>;
|
|
2168
|
+
/**
|
|
2169
|
+
* Get tool execution result by ID
|
|
2170
|
+
*
|
|
2171
|
+
* @param executionId - Execution UUID
|
|
2172
|
+
* @returns Tool execution details
|
|
2173
|
+
*
|
|
2174
|
+
* @example
|
|
2175
|
+
* ```typescript
|
|
2176
|
+
* const execution = await client.tools.getExecution('exec-uuid');
|
|
2177
|
+
* ```
|
|
2178
|
+
*/
|
|
2179
|
+
getExecution(executionId: string): Promise<ToolExecution>;
|
|
2180
|
+
/**
|
|
2181
|
+
* Update tool details
|
|
2182
|
+
*
|
|
2183
|
+
* @param uuid - Tool UUID
|
|
2184
|
+
* @param data - Fields to update
|
|
2185
|
+
* @returns Updated tool
|
|
2186
|
+
*
|
|
2187
|
+
* @example
|
|
2188
|
+
* ```typescript
|
|
2189
|
+
* const tool = await client.tools.update('tool-uuid', {
|
|
2190
|
+
* name: 'Updated Tool Name',
|
|
2191
|
+
* description: 'New description',
|
|
2192
|
+
* });
|
|
2193
|
+
* ```
|
|
2194
|
+
*/
|
|
2195
|
+
update(uuid: string, data: ToolUpdateInput): Promise<Tool>;
|
|
2196
|
+
/**
|
|
2197
|
+
* Update tool configuration
|
|
2198
|
+
*
|
|
2199
|
+
* @param uuid - Tool UUID
|
|
2200
|
+
* @param config - Configuration to update
|
|
2201
|
+
* @returns Updated tool
|
|
2202
|
+
*
|
|
2203
|
+
* @example
|
|
2204
|
+
* ```typescript
|
|
2205
|
+
* const tool = await client.tools.updateConfig('tool-uuid', {
|
|
2206
|
+
* isEnabled: false,
|
|
2207
|
+
* config: { apiKey: 'new-key' },
|
|
2208
|
+
* });
|
|
2209
|
+
* ```
|
|
2210
|
+
*/
|
|
2211
|
+
updateConfig(uuid: string, config: ToolConfigUpdateInput): Promise<Tool>;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
/**
|
|
2215
|
+
* Artifacts Resource API
|
|
2216
|
+
*
|
|
2217
|
+
* Provides all artifact-related operations:
|
|
2218
|
+
* - List: list(), get()
|
|
2219
|
+
* - Receive: download(), downloadStream(), getSignedUrl()
|
|
2220
|
+
* - Edit: upload(), delete()
|
|
2221
|
+
*/
|
|
2222
|
+
|
|
2223
|
+
/**
|
|
2224
|
+
* Artifacts API class
|
|
2225
|
+
*/
|
|
2226
|
+
declare class ArtifactsAPI extends BaseResourceAPI {
|
|
2227
|
+
constructor(http: HttpClient);
|
|
2228
|
+
/**
|
|
2229
|
+
* List artifacts for an execution
|
|
2230
|
+
*
|
|
2231
|
+
* @param executionId - Execution UUID
|
|
2232
|
+
* @param options - List options (pagination, filtering by type)
|
|
2233
|
+
* @returns Paginated list of artifacts
|
|
2234
|
+
*
|
|
2235
|
+
* @example
|
|
2236
|
+
* ```typescript
|
|
2237
|
+
* const { data: artifacts } = await client.artifacts.list('exec-uuid', {
|
|
2238
|
+
* type: 'file',
|
|
2239
|
+
* });
|
|
2240
|
+
* ```
|
|
2241
|
+
*/
|
|
2242
|
+
list(executionId: string, options?: ArtifactListOptions): Promise<PaginatedResponse<Artifact>>;
|
|
2243
|
+
/**
|
|
2244
|
+
* Get artifact metadata by UUID
|
|
2245
|
+
*
|
|
2246
|
+
* @param uuid - Artifact UUID
|
|
2247
|
+
* @returns Artifact metadata
|
|
2248
|
+
*
|
|
2249
|
+
* @example
|
|
2250
|
+
* ```typescript
|
|
2251
|
+
* const artifact = await client.artifacts.get('artifact-uuid');
|
|
2252
|
+
* console.log(artifact.name, artifact.size);
|
|
2253
|
+
* ```
|
|
2254
|
+
*/
|
|
2255
|
+
get(uuid: string): Promise<Artifact>;
|
|
2256
|
+
/**
|
|
2257
|
+
* Download artifact content
|
|
2258
|
+
*
|
|
2259
|
+
* In Node.js returns Buffer, in browser returns Blob.
|
|
2260
|
+
*
|
|
2261
|
+
* @param uuid - Artifact UUID
|
|
2262
|
+
* @returns Artifact content as Buffer (Node.js) or Blob (browser)
|
|
2263
|
+
*
|
|
2264
|
+
* @example
|
|
2265
|
+
* ```typescript
|
|
2266
|
+
* const content = await client.artifacts.download('artifact-uuid');
|
|
2267
|
+
* // Node.js: Buffer
|
|
2268
|
+
* // Browser: Blob
|
|
2269
|
+
* ```
|
|
2270
|
+
*/
|
|
2271
|
+
download(uuid: string): Promise<Buffer | Blob>;
|
|
2272
|
+
/**
|
|
2273
|
+
* Download artifact as a stream
|
|
2274
|
+
*
|
|
2275
|
+
* In Node.js returns Readable stream, in browser returns ReadableStream.
|
|
2276
|
+
*
|
|
2277
|
+
* @param uuid - Artifact UUID
|
|
2278
|
+
* @returns Readable stream
|
|
2279
|
+
*
|
|
2280
|
+
* @example
|
|
2281
|
+
* ```typescript
|
|
2282
|
+
* const stream = await client.artifacts.downloadStream('artifact-uuid');
|
|
2283
|
+
* // Pipe to file or process incrementally
|
|
2284
|
+
* ```
|
|
2285
|
+
*/
|
|
2286
|
+
downloadStream(uuid: string): Promise<ReadableStream<Uint8Array>>;
|
|
2287
|
+
/**
|
|
2288
|
+
* Get a signed URL for direct download
|
|
2289
|
+
*
|
|
2290
|
+
* @param uuid - Artifact UUID
|
|
2291
|
+
* @param options - Options including expiration time
|
|
2292
|
+
* @returns Signed URL and expiration time
|
|
2293
|
+
*
|
|
2294
|
+
* @example
|
|
2295
|
+
* ```typescript
|
|
2296
|
+
* const { url, expiresAt } = await client.artifacts.getSignedUrl('artifact-uuid', {
|
|
2297
|
+
* expiresIn: 3600, // 1 hour
|
|
2298
|
+
* });
|
|
2299
|
+
* // Use URL for direct download
|
|
2300
|
+
* ```
|
|
2301
|
+
*/
|
|
2302
|
+
getSignedUrl(uuid: string, options?: ArtifactDownloadOptions): Promise<SignedUrlResponse>;
|
|
2303
|
+
/**
|
|
2304
|
+
* Upload a new artifact for an execution
|
|
2305
|
+
*
|
|
2306
|
+
* @param executionId - Execution UUID
|
|
2307
|
+
* @param input - Upload input (name, content, mime type)
|
|
2308
|
+
* @returns Created artifact metadata
|
|
2309
|
+
*
|
|
2310
|
+
* @example
|
|
2311
|
+
* ```typescript
|
|
2312
|
+
* const artifact = await client.artifacts.upload('exec-uuid', {
|
|
2313
|
+
* name: 'report.pdf',
|
|
2314
|
+
* content: fileBuffer,
|
|
2315
|
+
* mimeType: 'application/pdf',
|
|
2316
|
+
* });
|
|
2317
|
+
* ```
|
|
2318
|
+
*/
|
|
2319
|
+
upload(executionId: string, input: ArtifactUploadInput): Promise<Artifact>;
|
|
2320
|
+
/**
|
|
2321
|
+
* Delete an artifact
|
|
2322
|
+
*
|
|
2323
|
+
* @param uuid - Artifact UUID
|
|
2324
|
+
*
|
|
2325
|
+
* @example
|
|
2326
|
+
* ```typescript
|
|
2327
|
+
* await client.artifacts.delete('artifact-uuid');
|
|
2328
|
+
* ```
|
|
2329
|
+
*/
|
|
2330
|
+
delete(uuid: string): Promise<void>;
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
/**
|
|
2334
|
+
* Sessions Resource API
|
|
2335
|
+
*
|
|
2336
|
+
* Provides all session-related operations:
|
|
2337
|
+
* - List: list(), get()
|
|
2338
|
+
* - Execute: sendMessage(), stream()
|
|
2339
|
+
* - Receive: getHistory(), listArtifacts()
|
|
2340
|
+
* - Edit: create(), delete()
|
|
2341
|
+
*/
|
|
2342
|
+
|
|
2343
|
+
/**
|
|
2344
|
+
* Sessions API class
|
|
2345
|
+
*/
|
|
2346
|
+
declare class SessionsAPI extends BaseResourceAPI {
|
|
2347
|
+
private readonly getStreamConfig;
|
|
2348
|
+
constructor(http: HttpClient, getStreamConfig: () => StreamConfig);
|
|
2349
|
+
/**
|
|
2350
|
+
* List all sessions in the organization
|
|
2351
|
+
*
|
|
2352
|
+
* @param options - List options (pagination, filtering by agent)
|
|
2353
|
+
* @returns Paginated list of sessions
|
|
2354
|
+
*
|
|
2355
|
+
* @example
|
|
2356
|
+
* ```typescript
|
|
2357
|
+
* const { data: sessions } = await client.sessions.list({
|
|
2358
|
+
* agentUuid: 'agent-uuid',
|
|
2359
|
+
* });
|
|
2360
|
+
* ```
|
|
2361
|
+
*/
|
|
2362
|
+
list(options?: SessionListOptions): Promise<PaginatedResponse<Session>>;
|
|
2363
|
+
/**
|
|
2364
|
+
* Get session details by ID
|
|
2365
|
+
*
|
|
2366
|
+
* @param sessionId - Session ID
|
|
2367
|
+
* @returns Session details
|
|
2368
|
+
*
|
|
2369
|
+
* @example
|
|
2370
|
+
* ```typescript
|
|
2371
|
+
* const session = await client.sessions.get('session-id');
|
|
2372
|
+
* console.log(session.messageCount);
|
|
2373
|
+
* ```
|
|
2374
|
+
*/
|
|
2375
|
+
get(sessionId: string): Promise<Session>;
|
|
2376
|
+
/**
|
|
2377
|
+
* Send a message to a session
|
|
2378
|
+
*
|
|
2379
|
+
* Triggers an agent execution in the context of the session.
|
|
2380
|
+
* Returns immediately with execution ID. Use getHistory() to get
|
|
2381
|
+
* the response, or use stream() for real-time updates.
|
|
2382
|
+
*
|
|
2383
|
+
* @param sessionId - Session ID
|
|
2384
|
+
* @param input - Message content and optional context
|
|
2385
|
+
* @returns Execution ID and status
|
|
2386
|
+
*
|
|
2387
|
+
* @example
|
|
2388
|
+
* ```typescript
|
|
2389
|
+
* const { executionId } = await client.sessions.sendMessage('session-id', {
|
|
2390
|
+
* message: 'What is the capital of France?',
|
|
2391
|
+
* });
|
|
2392
|
+
* ```
|
|
2393
|
+
*/
|
|
2394
|
+
sendMessage(sessionId: string, input: SendMessageInput): Promise<ExecuteResponse>;
|
|
2395
|
+
/**
|
|
2396
|
+
* Send a message and wait for response (sync)
|
|
2397
|
+
*
|
|
2398
|
+
* @param sessionId - Session ID
|
|
2399
|
+
* @param input - Message content and optional context
|
|
2400
|
+
* @param pollInterval - Polling interval in ms (default: 1000)
|
|
2401
|
+
* @returns Final execution result
|
|
2402
|
+
*
|
|
2403
|
+
* @example
|
|
2404
|
+
* ```typescript
|
|
2405
|
+
* const execution = await client.sessions.sendMessageSync('session-id', {
|
|
2406
|
+
* message: 'What is the capital of France?',
|
|
2407
|
+
* });
|
|
2408
|
+
* console.log(execution.output);
|
|
2409
|
+
* ```
|
|
2410
|
+
*/
|
|
2411
|
+
sendMessageSync(sessionId: string, input: SendMessageInput, pollInterval?: number): Promise<AgentExecution>;
|
|
2412
|
+
/**
|
|
2413
|
+
* Stream a message response
|
|
2414
|
+
*
|
|
2415
|
+
* Returns a StreamController for real-time event handling.
|
|
2416
|
+
*
|
|
2417
|
+
* @param sessionId - Session ID
|
|
2418
|
+
* @param input - Message content and optional context
|
|
2419
|
+
* @returns Stream controller
|
|
2420
|
+
*
|
|
2421
|
+
* @example
|
|
2422
|
+
* ```typescript
|
|
2423
|
+
* const stream = await client.sessions.stream('session-id', {
|
|
2424
|
+
* message: 'Tell me more about that',
|
|
2425
|
+
* });
|
|
2426
|
+
*
|
|
2427
|
+
* stream.on('log', (log) => console.log(log.title));
|
|
2428
|
+
* stream.on('complete', ({ execution }) => console.log(execution.output));
|
|
2429
|
+
*
|
|
2430
|
+
* const result = await stream.wait();
|
|
2431
|
+
* ```
|
|
2432
|
+
*/
|
|
2433
|
+
stream(sessionId: string, input: SendMessageInput): Promise<ExecutionStreamController>;
|
|
2434
|
+
/**
|
|
2435
|
+
* Get session conversation history
|
|
2436
|
+
*
|
|
2437
|
+
* @param sessionId - Session ID
|
|
2438
|
+
* @returns Session with all messages
|
|
2439
|
+
*
|
|
2440
|
+
* @example
|
|
2441
|
+
* ```typescript
|
|
2442
|
+
* const history = await client.sessions.getHistory('session-id');
|
|
2443
|
+
* history.messages.forEach(msg => {
|
|
2444
|
+
* console.log(`${msg.role}: ${msg.content}`);
|
|
2445
|
+
* });
|
|
2446
|
+
* ```
|
|
2447
|
+
*/
|
|
2448
|
+
getHistory(sessionId: string): Promise<SessionHistory>;
|
|
2449
|
+
/**
|
|
2450
|
+
* List artifacts for a session
|
|
2451
|
+
*
|
|
2452
|
+
* Returns all artifacts generated across all executions in the session.
|
|
2453
|
+
* Useful for retrieving images, files, and other outputs created during
|
|
2454
|
+
* agent interactions.
|
|
2455
|
+
*
|
|
2456
|
+
* @param sessionId - Session ID
|
|
2457
|
+
* @param options - List options (filtering by type, pagination)
|
|
2458
|
+
* @returns Paginated list of session artifacts
|
|
2459
|
+
*
|
|
2460
|
+
* @example
|
|
2461
|
+
* ```typescript
|
|
2462
|
+
* // Get all images from a session
|
|
2463
|
+
* const { data: artifacts } = await client.sessions.listArtifacts('session-id', {
|
|
2464
|
+
* type: 'image',
|
|
2465
|
+
* });
|
|
2466
|
+
*
|
|
2467
|
+
* artifacts.forEach(artifact => {
|
|
2468
|
+
* console.log(artifact.filename, artifact.url);
|
|
2469
|
+
* });
|
|
2470
|
+
* ```
|
|
2471
|
+
*/
|
|
2472
|
+
listArtifacts(sessionId: string, options?: SessionArtifactListOptions): Promise<PaginatedResponse<SessionArtifact>>;
|
|
2473
|
+
/**
|
|
2474
|
+
* Get execution result
|
|
2475
|
+
*/
|
|
2476
|
+
private getExecution;
|
|
2477
|
+
/**
|
|
2478
|
+
* Create a new session for an agent
|
|
2479
|
+
*
|
|
2480
|
+
* @param agentUuid - Agent UUID to associate with session
|
|
2481
|
+
* @param options - Optional system message
|
|
2482
|
+
* @returns Created session
|
|
2483
|
+
*
|
|
2484
|
+
* @example
|
|
2485
|
+
* ```typescript
|
|
2486
|
+
* const session = await client.sessions.create({
|
|
2487
|
+
* agentUuid: 'agent-uuid',
|
|
2488
|
+
* systemMessage: 'You are a helpful assistant.',
|
|
2489
|
+
* });
|
|
2490
|
+
* console.log(session.id);
|
|
2491
|
+
* ```
|
|
2492
|
+
*/
|
|
2493
|
+
create(input: SessionCreateInput): Promise<Session>;
|
|
2494
|
+
/**
|
|
2495
|
+
* Delete a session and all its messages
|
|
2496
|
+
*
|
|
2497
|
+
* @param sessionId - Session ID
|
|
2498
|
+
*
|
|
2499
|
+
* @example
|
|
2500
|
+
* ```typescript
|
|
2501
|
+
* await client.sessions.delete('session-id');
|
|
2502
|
+
* ```
|
|
2503
|
+
*/
|
|
2504
|
+
delete(sessionId: string): Promise<void>;
|
|
2505
|
+
/**
|
|
2506
|
+
* Poll execution until completion
|
|
2507
|
+
*/
|
|
2508
|
+
private pollExecution;
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
/**
|
|
2512
|
+
* AI SaaS Client
|
|
2513
|
+
*
|
|
2514
|
+
* Main entry point for the SDK. Provides access to all resource APIs.
|
|
2515
|
+
*
|
|
2516
|
+
* @example
|
|
2517
|
+
* ```typescript
|
|
2518
|
+
* import { AISaaSClient } from '@cadraos/sdk';
|
|
2519
|
+
*
|
|
2520
|
+
* const client = new AISaaSClient({
|
|
2521
|
+
* apiKey: process.env.AISAAS_API_KEY,
|
|
2522
|
+
* orgId: Number(process.env.AISAAS_ORG_ID),
|
|
2523
|
+
* });
|
|
2524
|
+
*
|
|
2525
|
+
* // List agents
|
|
2526
|
+
* const { data: agents } = await client.agents.list();
|
|
2527
|
+
*
|
|
2528
|
+
* // Execute an agent
|
|
2529
|
+
* const execution = await client.agents.executeSync(agents[0].uuid, {
|
|
2530
|
+
* task: 'Summarize the latest news',
|
|
2531
|
+
* });
|
|
2532
|
+
*
|
|
2533
|
+
* // Stream an agent execution
|
|
2534
|
+
* const stream = await client.agents.stream(agents[0].uuid, {
|
|
2535
|
+
* task: 'Research climate change',
|
|
2536
|
+
* });
|
|
2537
|
+
*
|
|
2538
|
+
* stream.on('log', (log) => console.log(log.title));
|
|
2539
|
+
* stream.on('complete', ({ execution }) => console.log(execution.output));
|
|
2540
|
+
*
|
|
2541
|
+
* const result = await stream.wait();
|
|
2542
|
+
* ```
|
|
2543
|
+
*/
|
|
2544
|
+
|
|
345
2545
|
/**
|
|
346
|
-
*
|
|
2546
|
+
* Client options for API key authentication
|
|
347
2547
|
*/
|
|
348
|
-
interface
|
|
349
|
-
/**
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
|
|
2548
|
+
interface AISaaSClientOptionsApiKey {
|
|
2549
|
+
/** API key for authentication */
|
|
2550
|
+
apiKey: string;
|
|
2551
|
+
/** Organization ID */
|
|
2552
|
+
orgId: number;
|
|
2553
|
+
/** Base URL for API (default: https://api.aisaas.com/v1) */
|
|
2554
|
+
baseUrl?: string;
|
|
2555
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
2556
|
+
timeout?: number;
|
|
2557
|
+
/** Maximum retry attempts (default: 3) */
|
|
2558
|
+
maxRetries?: number;
|
|
2559
|
+
/** Custom headers to include in all requests */
|
|
2560
|
+
headers?: Record<string, string>;
|
|
355
2561
|
}
|
|
356
2562
|
/**
|
|
357
|
-
*
|
|
2563
|
+
* Client options for OAuth token authentication
|
|
358
2564
|
*/
|
|
359
|
-
interface
|
|
360
|
-
/**
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
|
|
2565
|
+
interface AISaaSClientOptionsToken {
|
|
2566
|
+
/** OAuth token for authentication */
|
|
2567
|
+
token: string;
|
|
2568
|
+
/** Organization ID */
|
|
2569
|
+
orgId: number;
|
|
2570
|
+
/** Base URL for API (default: https://api.aisaas.com/v1) */
|
|
2571
|
+
baseUrl?: string;
|
|
2572
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
2573
|
+
timeout?: number;
|
|
2574
|
+
/** Maximum retry attempts (default: 3) */
|
|
2575
|
+
maxRetries?: number;
|
|
2576
|
+
/** Custom headers to include in all requests */
|
|
2577
|
+
headers?: Record<string, string>;
|
|
366
2578
|
}
|
|
367
2579
|
/**
|
|
368
|
-
*
|
|
2580
|
+
* Client options for token provider authentication
|
|
369
2581
|
*/
|
|
370
|
-
interface
|
|
371
|
-
/**
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
message: string;
|
|
384
|
-
metadata: Record<string, unknown>;
|
|
385
|
-
timestamp: string;
|
|
386
|
-
durationMs?: number;
|
|
387
|
-
};
|
|
388
|
-
executionId?: string;
|
|
389
|
-
toolName?: string;
|
|
390
|
-
args?: unknown;
|
|
391
|
-
iteration?: number;
|
|
392
|
-
tokenUsage?: {
|
|
393
|
-
prompt: number;
|
|
394
|
-
completion: number;
|
|
395
|
-
total: number;
|
|
396
|
-
};
|
|
397
|
-
cost?: number;
|
|
398
|
-
error?: string;
|
|
399
|
-
question?: string;
|
|
400
|
-
reason?: string;
|
|
401
|
-
suggestedOptions?: string[];
|
|
402
|
-
redisAvailable?: boolean;
|
|
403
|
-
[key: string]: unknown;
|
|
404
|
-
};
|
|
2582
|
+
interface AISaaSClientOptionsTokenProvider {
|
|
2583
|
+
/** Token provider callback (called before each request) */
|
|
2584
|
+
tokenProvider: () => Promise<string>;
|
|
2585
|
+
/** Organization ID */
|
|
2586
|
+
orgId: number;
|
|
2587
|
+
/** Base URL for API (default: https://api.aisaas.com/v1) */
|
|
2588
|
+
baseUrl?: string;
|
|
2589
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
2590
|
+
timeout?: number;
|
|
2591
|
+
/** Maximum retry attempts (default: 3) */
|
|
2592
|
+
maxRetries?: number;
|
|
2593
|
+
/** Custom headers to include in all requests */
|
|
2594
|
+
headers?: Record<string, string>;
|
|
405
2595
|
}
|
|
406
2596
|
/**
|
|
407
|
-
*
|
|
2597
|
+
* All client options
|
|
408
2598
|
*/
|
|
409
|
-
type
|
|
2599
|
+
type AISaaSClientOptions = AISaaSClientOptionsApiKey | AISaaSClientOptionsToken | AISaaSClientOptionsTokenProvider;
|
|
410
2600
|
/**
|
|
411
|
-
*
|
|
2601
|
+
* AI SaaS Client
|
|
2602
|
+
*
|
|
2603
|
+
* Main class for interacting with the AI SaaS API.
|
|
2604
|
+
* Provides access to all resource APIs (agents, skills, tools, artifacts, sessions).
|
|
412
2605
|
*/
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
/** Original file object */
|
|
417
|
-
file: File;
|
|
418
|
-
/** Upload status */
|
|
419
|
-
status: "pending" | "uploading" | "ready" | "failed";
|
|
420
|
-
/** Preview URL for local display */
|
|
421
|
-
previewUrl?: string;
|
|
422
|
-
/** Progress percentage (0-100) */
|
|
423
|
-
progress?: number;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
interface AgentChatProps {
|
|
427
|
-
/** The UUID of the agent to chat with */
|
|
428
|
-
agentId: string;
|
|
2606
|
+
declare class AISaaSClient {
|
|
2607
|
+
private readonly httpClient;
|
|
2608
|
+
private readonly config;
|
|
429
2609
|
/**
|
|
430
|
-
*
|
|
431
|
-
* When provided, the component will load the session's chat history
|
|
2610
|
+
* Agent operations (list, execute, stream, update)
|
|
432
2611
|
*/
|
|
433
|
-
|
|
434
|
-
/** Custom adapter (optional - uses context if not provided) */
|
|
435
|
-
adapter?: ChatAdapter;
|
|
436
|
-
/** Callback fired when a new message is added */
|
|
437
|
-
onMessage?: (message: ChatMessage$1) => void;
|
|
438
|
-
/** Callback fired when an error occurs */
|
|
439
|
-
onError?: (error: ChatError) => void;
|
|
2612
|
+
readonly agents: AgentsAPI;
|
|
440
2613
|
/**
|
|
441
|
-
*
|
|
442
|
-
* Called with the sessionId when starting a new chat (no existing sessionId)
|
|
443
|
-
* Useful for updating external state like session lists
|
|
2614
|
+
* Skill operations (list, get, execute, update)
|
|
444
2615
|
*/
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
2616
|
+
readonly skills: SkillsAPI;
|
|
2617
|
+
/**
|
|
2618
|
+
* Tool operations (list, get, execute, validate, update)
|
|
2619
|
+
*/
|
|
2620
|
+
readonly tools: ToolsAPI;
|
|
2621
|
+
/**
|
|
2622
|
+
* Artifact operations (list, get, download, upload, delete)
|
|
2623
|
+
*/
|
|
2624
|
+
readonly artifacts: ArtifactsAPI;
|
|
2625
|
+
/**
|
|
2626
|
+
* Session operations (list, get, create, message, delete)
|
|
2627
|
+
*/
|
|
2628
|
+
readonly sessions: SessionsAPI;
|
|
2629
|
+
/**
|
|
2630
|
+
* Create a new AI SaaS client
|
|
2631
|
+
*
|
|
2632
|
+
* @param options - Client configuration options
|
|
2633
|
+
*
|
|
2634
|
+
* @example
|
|
2635
|
+
* ```typescript
|
|
2636
|
+
* // API key authentication
|
|
2637
|
+
* const client = new AISaaSClient({
|
|
2638
|
+
* apiKey: 'sk_...',
|
|
2639
|
+
* orgId: 123,
|
|
2640
|
+
* });
|
|
2641
|
+
*
|
|
2642
|
+
* // OAuth token authentication
|
|
2643
|
+
* const client = new AISaaSClient({
|
|
2644
|
+
* token: 'eyJ...',
|
|
2645
|
+
* orgId: 123,
|
|
2646
|
+
* });
|
|
2647
|
+
*
|
|
2648
|
+
* // Token provider (for automatic refresh)
|
|
2649
|
+
* const client = new AISaaSClient({
|
|
2650
|
+
* tokenProvider: async () => myAuth.getAccessToken(),
|
|
2651
|
+
* orgId: 123,
|
|
2652
|
+
* });
|
|
2653
|
+
* ```
|
|
2654
|
+
*/
|
|
2655
|
+
constructor(options: AISaaSClientOptions);
|
|
2656
|
+
/**
|
|
2657
|
+
* Validate client options
|
|
2658
|
+
*/
|
|
2659
|
+
private validateOptions;
|
|
470
2660
|
}
|
|
471
|
-
/**
|
|
472
|
-
* Complete chat interface for interacting with AI agents
|
|
473
|
-
*
|
|
474
|
-
* @example
|
|
475
|
-
* ```tsx
|
|
476
|
-
* // With ChatConfigProvider (recommended for API key users)
|
|
477
|
-
* <ChatConfigProvider config={{ baseUrl: '...', apiKey: '...' }}>
|
|
478
|
-
* <AgentChat
|
|
479
|
-
* agentId="agent-uuid"
|
|
480
|
-
* onMessage={(msg) => console.log('New message:', msg)}
|
|
481
|
-
* />
|
|
482
|
-
* </ChatConfigProvider>
|
|
483
|
-
*
|
|
484
|
-
* // With custom adapter
|
|
485
|
-
* <AgentChat
|
|
486
|
-
* agentId="agent-uuid"
|
|
487
|
-
* adapter={myCustomAdapter}
|
|
488
|
-
* />
|
|
489
|
-
* ```
|
|
490
|
-
*/
|
|
491
|
-
declare function AgentChat({ agentId, sessionId, adapter, onMessage, onError, onSessionCreated, onSessionStart, onToolCall, onClarification, initialMessages, placeholder, welcomeMessage, maxHeight, className, theme, enableAttachments, enableMarkdown, showToolCalls, }: AgentChatProps): react_jsx_runtime.JSX.Element;
|
|
492
2661
|
|
|
493
2662
|
/**
|
|
494
|
-
* Default
|
|
2663
|
+
* Default adapter for ChatAdapter — thin wrapper around AISaaSClient
|
|
495
2664
|
*
|
|
496
|
-
* Uses the
|
|
2665
|
+
* Uses the AISaaSClient for all operations, providing proper auth,
|
|
2666
|
+
* retries, and streaming support out of the box.
|
|
497
2667
|
*
|
|
498
2668
|
* @module @cadraos/sdk/chat
|
|
499
2669
|
*/
|
|
@@ -502,37 +2672,49 @@ declare function AgentChat({ agentId, sessionId, adapter, onMessage, onError, on
|
|
|
502
2672
|
* Configuration for the default HTTP adapter
|
|
503
2673
|
*/
|
|
504
2674
|
interface DefaultAdapterConfig {
|
|
2675
|
+
/**
|
|
2676
|
+
* Pre-constructed AISaaSClient (takes priority over individual options)
|
|
2677
|
+
*/
|
|
2678
|
+
client?: AISaaSClient;
|
|
505
2679
|
/**
|
|
506
2680
|
* Base URL for the API
|
|
507
|
-
* @example "https://api.example.com/
|
|
2681
|
+
* @example "https://api.example.com/v1"
|
|
508
2682
|
*/
|
|
509
|
-
baseUrl
|
|
2683
|
+
baseUrl?: string;
|
|
510
2684
|
/**
|
|
511
2685
|
* API key for authentication
|
|
512
2686
|
*/
|
|
513
2687
|
apiKey?: string;
|
|
514
2688
|
/**
|
|
515
|
-
*
|
|
2689
|
+
* OAuth token for authentication
|
|
516
2690
|
*/
|
|
517
|
-
|
|
2691
|
+
token?: string;
|
|
2692
|
+
/**
|
|
2693
|
+
* Token provider callback for dynamic auth
|
|
2694
|
+
*/
|
|
2695
|
+
tokenProvider?: () => Promise<string>;
|
|
518
2696
|
/**
|
|
519
|
-
*
|
|
2697
|
+
* Organization ID for multi-tenant access
|
|
520
2698
|
*/
|
|
521
|
-
|
|
2699
|
+
orgId?: number;
|
|
522
2700
|
}
|
|
523
2701
|
/**
|
|
524
|
-
* Create a default
|
|
2702
|
+
* Create a default adapter that wraps AISaaSClient
|
|
525
2703
|
*
|
|
526
2704
|
* @param config - Adapter configuration
|
|
527
|
-
* @returns ChatAdapter implementation
|
|
2705
|
+
* @returns ChatAdapter implementation backed by AISaaSClient
|
|
528
2706
|
*
|
|
529
2707
|
* @example
|
|
530
2708
|
* ```typescript
|
|
2709
|
+
* // With individual options
|
|
531
2710
|
* const adapter = createDefaultAdapter({
|
|
532
|
-
* baseUrl: 'https://api.example.com/
|
|
2711
|
+
* baseUrl: 'https://api.example.com/v1',
|
|
533
2712
|
* apiKey: 'your-api-key',
|
|
534
2713
|
* orgId: 123,
|
|
535
2714
|
* });
|
|
2715
|
+
*
|
|
2716
|
+
* // With pre-constructed client
|
|
2717
|
+
* const adapter = createDefaultAdapter({ client: myClient });
|
|
536
2718
|
* ```
|
|
537
2719
|
*/
|
|
538
2720
|
declare function createDefaultAdapter(config: DefaultAdapterConfig): ChatAdapter;
|
|
@@ -549,7 +2731,7 @@ interface ChatConfigProviderProps {
|
|
|
549
2731
|
/**
|
|
550
2732
|
* Child components
|
|
551
2733
|
*/
|
|
552
|
-
children: React.ReactNode;
|
|
2734
|
+
children: React$1.ReactNode;
|
|
553
2735
|
}
|
|
554
2736
|
/**
|
|
555
2737
|
* Provider component that configures the default adapter for all child AgentChat components
|
|
@@ -589,6 +2771,8 @@ declare function useChatConfigOptional(): ChatConfigContextValue | null;
|
|
|
589
2771
|
interface UseAgentChatOptions {
|
|
590
2772
|
/** UUID of the agent to chat with */
|
|
591
2773
|
agentId: string;
|
|
2774
|
+
/** Optional team UUID for team-based execution (routes to team's lead orchestrator) */
|
|
2775
|
+
teamId?: string;
|
|
592
2776
|
/**
|
|
593
2777
|
* Session ID to resume an existing conversation
|
|
594
2778
|
* If provided, the hook will attempt to load the session history on mount
|
|
@@ -612,6 +2796,8 @@ interface UseAgentChatOptions {
|
|
|
612
2796
|
onSessionStart?: (sessionId: string) => void;
|
|
613
2797
|
/** Callback fired when a tool is called */
|
|
614
2798
|
onToolCall?: (toolName: string, args: unknown) => void;
|
|
2799
|
+
/** Callback fired when a tool result is received */
|
|
2800
|
+
onToolResult?: (toolName: string, result: unknown, durationMs?: number) => void;
|
|
615
2801
|
/** Callback fired when clarification is needed */
|
|
616
2802
|
onClarification?: (data: ClarificationData) => void;
|
|
617
2803
|
}
|
|
@@ -649,6 +2835,27 @@ interface UseAgentChatResult {
|
|
|
649
2835
|
*/
|
|
650
2836
|
loadSession: (sessionId: string) => Promise<void>;
|
|
651
2837
|
}
|
|
2838
|
+
/**
|
|
2839
|
+
* Main hook for managing chat state and interactions
|
|
2840
|
+
*
|
|
2841
|
+
* @example
|
|
2842
|
+
* ```typescript
|
|
2843
|
+
* const {
|
|
2844
|
+
* messages,
|
|
2845
|
+
* isLoading,
|
|
2846
|
+
* isStreaming,
|
|
2847
|
+
* sendMessage,
|
|
2848
|
+
* error,
|
|
2849
|
+
* } = useAgentChat({
|
|
2850
|
+
* agentId: 'agent-uuid',
|
|
2851
|
+
* adapter: myAdapter,
|
|
2852
|
+
* onMessage: (msg) => console.log('New message:', msg),
|
|
2853
|
+
* });
|
|
2854
|
+
*
|
|
2855
|
+
* // Send a message
|
|
2856
|
+
* await sendMessage('Hello, agent!');
|
|
2857
|
+
* ```
|
|
2858
|
+
*/
|
|
652
2859
|
declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatResult;
|
|
653
2860
|
|
|
654
2861
|
interface UseExecutionStreamOptions {
|
|
@@ -700,6 +2907,11 @@ interface UseExecutionStreamResult {
|
|
|
700
2907
|
/**
|
|
701
2908
|
* Hook for streaming agent execution events via SSE
|
|
702
2909
|
*
|
|
2910
|
+
* @deprecated Prefer using `adapter.createStream()` which provides
|
|
2911
|
+
* fetch-based SSE with auth headers, automatic reconnection, and
|
|
2912
|
+
* polling fallback. This hook is kept for backward compatibility
|
|
2913
|
+
* with adapters that only implement `getStreamUrl`.
|
|
2914
|
+
*
|
|
703
2915
|
* @example
|
|
704
2916
|
* ```typescript
|
|
705
2917
|
* const { isConnected, disconnect } = useExecutionStream({
|
|
@@ -714,7 +2926,7 @@ declare function useExecutionStream(options: UseExecutionStreamOptions): UseExec
|
|
|
714
2926
|
|
|
715
2927
|
interface ChatContainerProps {
|
|
716
2928
|
/** Child components (MessageList, ChatInput, etc.) */
|
|
717
|
-
children: React.ReactNode;
|
|
2929
|
+
children: React$1.ReactNode;
|
|
718
2930
|
/** Maximum height of the container */
|
|
719
2931
|
maxHeight?: string | number;
|
|
720
2932
|
/** Additional CSS classes */
|
|
@@ -767,86 +2979,6 @@ interface ChatInputProps {
|
|
|
767
2979
|
*/
|
|
768
2980
|
declare function ChatInput({ onSend, onStop, placeholder, disabled, isLoading, enableAttachments, className, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
769
2981
|
|
|
770
|
-
interface MessageListProps {
|
|
771
|
-
/** Array of messages to display */
|
|
772
|
-
messages: ChatMessage$1[];
|
|
773
|
-
/** Welcome message shown when chat is empty */
|
|
774
|
-
welcomeMessage?: string;
|
|
775
|
-
/** Whether a new message is loading */
|
|
776
|
-
isLoading?: boolean;
|
|
777
|
-
/** Whether the assistant is currently streaming a response */
|
|
778
|
-
isStreaming?: boolean;
|
|
779
|
-
/** Whether session history is being loaded */
|
|
780
|
-
isLoadingHistory?: boolean;
|
|
781
|
-
/** Whether to enable markdown rendering */
|
|
782
|
-
enableMarkdown?: boolean;
|
|
783
|
-
/** Whether to show tool calls */
|
|
784
|
-
showToolCalls?: boolean;
|
|
785
|
-
/** Additional CSS classes */
|
|
786
|
-
className?: string;
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* Renders a scrollable list of chat messages with auto-scroll
|
|
790
|
-
*
|
|
791
|
-
* @example
|
|
792
|
-
* ```tsx
|
|
793
|
-
* <MessageList
|
|
794
|
-
* messages={messages}
|
|
795
|
-
* welcomeMessage="Hello! How can I help you today?"
|
|
796
|
-
* isLoading={isLoading}
|
|
797
|
-
* isStreaming={isStreaming}
|
|
798
|
-
* enableMarkdown
|
|
799
|
-
* showToolCalls
|
|
800
|
-
* />
|
|
801
|
-
* ```
|
|
802
|
-
*/
|
|
803
|
-
declare function MessageList({ messages, welcomeMessage, isLoading, isStreaming, isLoadingHistory, enableMarkdown, showToolCalls, className, }: MessageListProps): react_jsx_runtime.JSX.Element;
|
|
804
|
-
|
|
805
|
-
interface ChatMessageProps {
|
|
806
|
-
/** Message data */
|
|
807
|
-
message: ChatMessage$1;
|
|
808
|
-
/** Whether to enable markdown rendering */
|
|
809
|
-
enableMarkdown?: boolean;
|
|
810
|
-
/** Whether to show tool calls */
|
|
811
|
-
showToolCalls?: boolean;
|
|
812
|
-
/** Additional CSS classes */
|
|
813
|
-
className?: string;
|
|
814
|
-
}
|
|
815
|
-
/**
|
|
816
|
-
* Renders a single chat message with appropriate styling
|
|
817
|
-
*
|
|
818
|
-
* @example
|
|
819
|
-
* ```tsx
|
|
820
|
-
* <ChatMessage
|
|
821
|
-
* message={{
|
|
822
|
-
* id: "1",
|
|
823
|
-
* role: "assistant",
|
|
824
|
-
* content: "Hello! How can I help?",
|
|
825
|
-
* timestamp: new Date(),
|
|
826
|
-
* }}
|
|
827
|
-
* enableMarkdown
|
|
828
|
-
* showToolCalls
|
|
829
|
-
* />
|
|
830
|
-
* ```
|
|
831
|
-
*/
|
|
832
|
-
declare function ChatMessage({ message, enableMarkdown, showToolCalls, className, }: ChatMessageProps): react_jsx_runtime.JSX.Element;
|
|
833
|
-
|
|
834
|
-
interface MarkdownContentProps {
|
|
835
|
-
/** Markdown content to render */
|
|
836
|
-
content: string;
|
|
837
|
-
/** Additional CSS classes */
|
|
838
|
-
className?: string;
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Renders markdown content with chat-appropriate styling
|
|
842
|
-
*
|
|
843
|
-
* @example
|
|
844
|
-
* ```tsx
|
|
845
|
-
* <MarkdownContent content="# Hello\n\nThis is **bold** text." />
|
|
846
|
-
* ```
|
|
847
|
-
*/
|
|
848
|
-
declare function MarkdownContent({ content, className }: MarkdownContentProps): react_jsx_runtime.JSX.Element;
|
|
849
|
-
|
|
850
2982
|
interface ToolCallEntryProps {
|
|
851
2983
|
/** Tool call data */
|
|
852
2984
|
toolCall: ToolCall;
|
|
@@ -854,6 +2986,12 @@ interface ToolCallEntryProps {
|
|
|
854
2986
|
className?: string;
|
|
855
2987
|
/** Whether to show the full JSON in expanded view */
|
|
856
2988
|
showFullJson?: boolean;
|
|
2989
|
+
/** Optional callback when an image is clicked. If provided, overrides default browser-open behavior. */
|
|
2990
|
+
onImageClick?: (image: {
|
|
2991
|
+
url: string;
|
|
2992
|
+
alt?: string;
|
|
2993
|
+
filename?: string;
|
|
2994
|
+
}) => void;
|
|
857
2995
|
}
|
|
858
2996
|
/**
|
|
859
2997
|
* Displays a single tool call with status and expandable details
|
|
@@ -872,7 +3010,7 @@ interface ToolCallEntryProps {
|
|
|
872
3010
|
* />
|
|
873
3011
|
* ```
|
|
874
3012
|
*/
|
|
875
|
-
declare function ToolCallEntry({ toolCall, className, showFullJson, }: ToolCallEntryProps): react_jsx_runtime.JSX.Element;
|
|
3013
|
+
declare function ToolCallEntry({ toolCall, className, showFullJson, onImageClick, }: ToolCallEntryProps): react_jsx_runtime.JSX.Element;
|
|
876
3014
|
|
|
877
3015
|
interface AskUserPromptProps {
|
|
878
3016
|
/** The question to display to the user */
|
|
@@ -971,4 +3109,4 @@ declare function HelpCircleIcon({ className, ...props }: IconProps): react_jsx_r
|
|
|
971
3109
|
declare function DatabaseIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
|
|
972
3110
|
declare function ClockIcon({ className, ...props }: IconProps): react_jsx_runtime.JSX.Element;
|
|
973
3111
|
|
|
974
|
-
export { AgentChat, type AgentChatProps, AlertCircleIcon, type Artifact, AskUserPrompt, type AskUserPromptProps, type AttachmentData, type AttachmentFile, BotIcon, type ChatAdapter, ChatConfigProvider, type ChatConfigProviderProps, ChatContainer, type ChatContainerProps, type ChatError, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, type ClarificationData, ClockIcon, CodeIcon, CopyIcon, DatabaseIcon, type DefaultAdapterConfig, DownloadIcon, type Execution, type ExecutionResult, type ExecutionStreamEvent, ExternalLinkIcon, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, type IconProps, ImageIcon, ImagesIcon, ListTodoIcon, LoadingSpinner, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput, type SessionHistory, SparklesIcon, type StartExecutionInput, StopCircleIcon, type ThemeMode, type ThinkingBlock, type TodoItem, TodoList, type TodoListProps, type ToolCall, ToolCallEntry, type ToolCallEntryProps, type UploadUrlInput, type UploadUrlResult, type UseAgentChatOptions, type UseAgentChatResult, type UseExecutionStreamOptions, type UseExecutionStreamResult, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, createDefaultAdapter, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream };
|
|
3112
|
+
export { AgentChat, type AgentChatProps, AlertCircleIcon, type Artifact$1 as Artifact, AskUserPrompt, type AskUserPromptProps, type AttachmentData, type AttachmentFile, BotIcon, type ChatAdapter, ChatConfigProvider, type ChatConfigProviderProps, ChatContainer, type ChatContainerProps, type ChatError, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, type ClarificationData, ClockIcon, CodeIcon, CopyIcon, DatabaseIcon, type DefaultAdapterConfig, DownloadIcon, type Execution, type ExecutionResult, type ExecutionStreamEvent, ExternalLinkIcon, FileIcon, FileTextIcon, HelpCircleIcon, type HistoryMessage, type IconProps, ImageIcon, ImagesIcon, type ListSessionsInput, ListTodoIcon, LoadingSpinner, MarkdownContent, type MarkdownContentProps, Maximize2Icon, MessageCircleIcon, MessageList, type MessageListProps, Minimize2Icon, PaperclipIcon, SendIcon, type SendMessageInput$1 as SendMessageInput, type SessionHistory$1 as SessionHistory, type SessionList, type SessionListItem, SparklesIcon, type StartExecutionInput, StopCircleIcon, type ThemeMode, type ThinkingBlock, type TodoItem, TodoList, type TodoListProps, type ToolCall, ToolCallEntry, type ToolCallEntryProps, type UploadUrlInput, type UploadUrlResult, type UseAgentChatOptions, type UseAgentChatResult, type UseExecutionStreamOptions, type UseExecutionStreamResult, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, createDefaultAdapter, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream };
|