@usecrow/client 0.1.24 → 0.1.26
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/dist/PageController-GcMFZYwU.cjs +9 -0
- package/dist/PageController-KoeqDxMP.js +1377 -0
- package/dist/SimulatorMask-CgaoHOve.js +120 -0
- package/dist/SimulatorMask-DoBLczoQ.cjs +2 -0
- package/dist/browser.cjs +1 -284
- package/dist/browser.d.ts +342 -52
- package/dist/browser.js +18 -276
- package/dist/browserUse-BOc9kyBK.cjs +1 -0
- package/dist/browserUse-BbPG4pH1.js +205 -0
- package/dist/index.cjs +3 -1107
- package/dist/index.d.ts +474 -311
- package/dist/index.js +254 -614
- package/package.json +8 -6
- package/dist/browser.cjs.map +0 -1
- package/dist/browser.d.cts +0 -52
- package/dist/browser.js.map +0 -1
- package/dist/browserUse-CZNpayEF.d.cts +0 -188
- package/dist/browserUse-CZNpayEF.d.ts +0 -188
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -311
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,311 +1,474 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
private
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
*
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
private
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
*
|
|
247
|
-
*/
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
*
|
|
251
|
-
*/
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
*
|
|
255
|
-
*/
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
*
|
|
259
|
-
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
declare
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
1
|
+
export declare interface ActiveWorkflow {
|
|
2
|
+
name: string;
|
|
3
|
+
todos: WorkflowTodo[];
|
|
4
|
+
isComplete?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare interface BrowserUseConfig {
|
|
8
|
+
productId: string;
|
|
9
|
+
apiUrl: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export declare interface Citation {
|
|
13
|
+
document_id: string;
|
|
14
|
+
filename: string;
|
|
15
|
+
similarity?: number;
|
|
16
|
+
image_url?: string;
|
|
17
|
+
page?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare interface ContextData {
|
|
21
|
+
/** Current page URL or path */
|
|
22
|
+
page?: string;
|
|
23
|
+
/** Custom context data */
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare interface Conversation {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string | null;
|
|
30
|
+
created_at: string;
|
|
31
|
+
updated_at: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export declare class ConversationManager {
|
|
35
|
+
private productId;
|
|
36
|
+
private apiUrl;
|
|
37
|
+
private currentId;
|
|
38
|
+
constructor(productId: string, apiUrl: string);
|
|
39
|
+
/**
|
|
40
|
+
* Get localStorage key for this product
|
|
41
|
+
*/
|
|
42
|
+
private getStorageKey;
|
|
43
|
+
/**
|
|
44
|
+
* Load conversation ID from localStorage
|
|
45
|
+
*/
|
|
46
|
+
private loadFromStorage;
|
|
47
|
+
/**
|
|
48
|
+
* Save conversation ID to localStorage
|
|
49
|
+
*/
|
|
50
|
+
private saveToStorage;
|
|
51
|
+
/**
|
|
52
|
+
* Clear conversation ID from localStorage
|
|
53
|
+
*/
|
|
54
|
+
private clearStorage;
|
|
55
|
+
/**
|
|
56
|
+
* Get current conversation ID
|
|
57
|
+
*/
|
|
58
|
+
getCurrentId(): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Set current conversation ID
|
|
61
|
+
*/
|
|
62
|
+
setCurrentId(id: string | null): void;
|
|
63
|
+
/**
|
|
64
|
+
* Check if there's a restored conversation
|
|
65
|
+
*/
|
|
66
|
+
hasRestoredConversation(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Clear current conversation (start new)
|
|
69
|
+
*/
|
|
70
|
+
clear(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Fetch list of conversations for verified user
|
|
73
|
+
*/
|
|
74
|
+
getConversations(identityToken: string): Promise<Conversation[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Load conversation history for verified user
|
|
77
|
+
*/
|
|
78
|
+
loadHistory(conversationId: string, identityToken: string): Promise<Message[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Load conversation history for anonymous user
|
|
81
|
+
*/
|
|
82
|
+
loadAnonymousHistory(conversationId: string): Promise<Message[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Parse history messages from API format
|
|
85
|
+
*/
|
|
86
|
+
private parseHistoryMessages;
|
|
87
|
+
/**
|
|
88
|
+
* Parse structured content (with thinking/text blocks) and extract just text
|
|
89
|
+
*/
|
|
90
|
+
private parseContent;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export declare class CrowBrowserUse {
|
|
94
|
+
private config;
|
|
95
|
+
private pageController;
|
|
96
|
+
private sessionId;
|
|
97
|
+
private maxSteps;
|
|
98
|
+
constructor(config: BrowserUseConfig);
|
|
99
|
+
/**
|
|
100
|
+
* Initialize PageController with non-blocking pointer
|
|
101
|
+
*/
|
|
102
|
+
private initPageController;
|
|
103
|
+
/**
|
|
104
|
+
* Execute a browser automation task
|
|
105
|
+
*/
|
|
106
|
+
execute(task: string): Promise<ToolResult>;
|
|
107
|
+
/**
|
|
108
|
+
* Start a browser-use session on the server
|
|
109
|
+
*/
|
|
110
|
+
private startSession;
|
|
111
|
+
/**
|
|
112
|
+
* Process a step on the server
|
|
113
|
+
*/
|
|
114
|
+
private processStep;
|
|
115
|
+
/**
|
|
116
|
+
* Execute an action using PageController
|
|
117
|
+
*/
|
|
118
|
+
private executeAction;
|
|
119
|
+
/**
|
|
120
|
+
* Cleanup resources
|
|
121
|
+
*/
|
|
122
|
+
private cleanup;
|
|
123
|
+
/**
|
|
124
|
+
* Stop the current task
|
|
125
|
+
*/
|
|
126
|
+
stop(): Promise<void>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export declare class CrowClient {
|
|
130
|
+
private config;
|
|
131
|
+
private identity;
|
|
132
|
+
private tools;
|
|
133
|
+
private conversations;
|
|
134
|
+
private context;
|
|
135
|
+
private abortController;
|
|
136
|
+
private callbacks;
|
|
137
|
+
private _messages;
|
|
138
|
+
private messageListeners;
|
|
139
|
+
private _isLoading;
|
|
140
|
+
private loadingListeners;
|
|
141
|
+
constructor(config: CrowClientConfig);
|
|
142
|
+
/**
|
|
143
|
+
* Get current product ID
|
|
144
|
+
*/
|
|
145
|
+
get productId(): string;
|
|
146
|
+
/**
|
|
147
|
+
* Get current API URL
|
|
148
|
+
*/
|
|
149
|
+
get apiUrl(): string;
|
|
150
|
+
/**
|
|
151
|
+
* Get/set current model
|
|
152
|
+
*/
|
|
153
|
+
get model(): string;
|
|
154
|
+
set model(value: string);
|
|
155
|
+
/**
|
|
156
|
+
* Register event callbacks
|
|
157
|
+
*/
|
|
158
|
+
on(callbacks: CrowEventCallbacks): void;
|
|
159
|
+
/**
|
|
160
|
+
* Identify the current user with a JWT token
|
|
161
|
+
*/
|
|
162
|
+
identify(options: IdentifyOptions): void;
|
|
163
|
+
/**
|
|
164
|
+
* Reset user identity (call on logout)
|
|
165
|
+
*/
|
|
166
|
+
resetUser(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Check if user is identified
|
|
169
|
+
*/
|
|
170
|
+
isIdentified(): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Check if user is verified by server
|
|
173
|
+
*/
|
|
174
|
+
isVerified(): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Register client-side tool handlers
|
|
177
|
+
*/
|
|
178
|
+
registerTools(tools: ToolHandlers): void;
|
|
179
|
+
/**
|
|
180
|
+
* Unregister a tool handler
|
|
181
|
+
*/
|
|
182
|
+
unregisterTool(name: string): void;
|
|
183
|
+
/**
|
|
184
|
+
* Get list of registered tool names
|
|
185
|
+
*/
|
|
186
|
+
getRegisteredTools(): string[];
|
|
187
|
+
/**
|
|
188
|
+
* Set context data to be sent with messages
|
|
189
|
+
*/
|
|
190
|
+
setContext(data: ContextData): void;
|
|
191
|
+
/**
|
|
192
|
+
* Clear context data
|
|
193
|
+
*/
|
|
194
|
+
clearContext(): void;
|
|
195
|
+
/**
|
|
196
|
+
* Get current messages
|
|
197
|
+
*/
|
|
198
|
+
get messages(): Message[];
|
|
199
|
+
/**
|
|
200
|
+
* Check if currently loading/streaming
|
|
201
|
+
*/
|
|
202
|
+
get isLoading(): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Subscribe to message changes
|
|
205
|
+
*/
|
|
206
|
+
onMessages(callback: (messages: Message[]) => void): () => void;
|
|
207
|
+
/**
|
|
208
|
+
* Subscribe to loading state changes
|
|
209
|
+
*/
|
|
210
|
+
onLoading(callback: (isLoading: boolean) => void): () => void;
|
|
211
|
+
/**
|
|
212
|
+
* Clear all messages and start new conversation
|
|
213
|
+
*/
|
|
214
|
+
clearMessages(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Load messages from history
|
|
217
|
+
*/
|
|
218
|
+
loadMessages(messages: Message[]): void;
|
|
219
|
+
private notifyMessages;
|
|
220
|
+
private setLoading;
|
|
221
|
+
private addMessage;
|
|
222
|
+
private updateMessage;
|
|
223
|
+
private generateMessageId;
|
|
224
|
+
/**
|
|
225
|
+
* Get current conversation ID
|
|
226
|
+
*/
|
|
227
|
+
get conversationId(): string | null;
|
|
228
|
+
/**
|
|
229
|
+
* Set current conversation ID
|
|
230
|
+
*/
|
|
231
|
+
set conversationId(id: string | null);
|
|
232
|
+
/**
|
|
233
|
+
* Get list of conversations for verified user
|
|
234
|
+
*/
|
|
235
|
+
getConversations(): Promise<Conversation[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Load conversation history
|
|
238
|
+
*/
|
|
239
|
+
loadHistory(conversationId: string): Promise<Message[]>;
|
|
240
|
+
/**
|
|
241
|
+
* Switch to a different conversation
|
|
242
|
+
*/
|
|
243
|
+
switchConversation(conversationId: string): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Send a message and receive streaming response
|
|
246
|
+
* Returns an async generator of stream events
|
|
247
|
+
*/
|
|
248
|
+
sendMessage(content: string): AsyncGenerator<StreamEvent>;
|
|
249
|
+
/**
|
|
250
|
+
* Send a message and wait for complete response (non-streaming)
|
|
251
|
+
*/
|
|
252
|
+
send(content: string): Promise<Message | null>;
|
|
253
|
+
/**
|
|
254
|
+
* Stop current generation
|
|
255
|
+
*/
|
|
256
|
+
stop(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Destroy the client and clean up resources
|
|
259
|
+
*/
|
|
260
|
+
destroy(): void;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Core types for @usecrow/client
|
|
265
|
+
*/
|
|
266
|
+
export declare interface CrowClientConfig {
|
|
267
|
+
/** Your Crow product ID from the dashboard */
|
|
268
|
+
productId: string;
|
|
269
|
+
/** API URL (defaults to https://api.usecrow.org) */
|
|
270
|
+
apiUrl?: string;
|
|
271
|
+
/** Default model to use */
|
|
272
|
+
model?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export declare interface CrowEventCallbacks {
|
|
276
|
+
onMessage?: (message: Message) => void;
|
|
277
|
+
onMessageUpdate?: (messageId: string, updates: Partial<Message>) => void;
|
|
278
|
+
onToolCall?: (event: StreamEvent & {
|
|
279
|
+
type: 'tool_call_start' | 'tool_call_complete' | 'client_tool_call';
|
|
280
|
+
}) => void;
|
|
281
|
+
onWorkflow?: (event: StreamEvent & {
|
|
282
|
+
type: 'workflow_started' | 'workflow_todo_updated' | 'workflow_ended' | 'workflow_complete_prompt';
|
|
283
|
+
}) => void;
|
|
284
|
+
onVerificationStatus?: (isVerified: boolean) => void;
|
|
285
|
+
onError?: (error: Error) => void;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export declare const DEFAULT_TOOL_NAMES: DefaultToolName[];
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* SDK Default Tools - automatically registered, zero configuration
|
|
292
|
+
*/
|
|
293
|
+
export declare const DEFAULT_TOOLS: {
|
|
294
|
+
/**
|
|
295
|
+
* Refresh the current page in the user's browser
|
|
296
|
+
*/
|
|
297
|
+
readonly refreshPage: () => Promise<ToolResult>;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export declare type DefaultToolName = keyof typeof DEFAULT_TOOLS;
|
|
301
|
+
|
|
302
|
+
export declare interface IdentifyOptions {
|
|
303
|
+
/** JWT token from your backend for user verification */
|
|
304
|
+
token: string;
|
|
305
|
+
/** Optional user display name */
|
|
306
|
+
name?: string;
|
|
307
|
+
/** Optional user email */
|
|
308
|
+
email?: string;
|
|
309
|
+
/** Any additional metadata */
|
|
310
|
+
[key: string]: unknown;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export declare class IdentityManager {
|
|
314
|
+
private state;
|
|
315
|
+
private listeners;
|
|
316
|
+
/**
|
|
317
|
+
* Identify the current user with a JWT token
|
|
318
|
+
*/
|
|
319
|
+
identify(options: IdentifyOptions): void;
|
|
320
|
+
/**
|
|
321
|
+
* Update verification status (called when server confirms)
|
|
322
|
+
*/
|
|
323
|
+
setVerified(isVerified: boolean): void;
|
|
324
|
+
/**
|
|
325
|
+
* Reset user identity (call on logout)
|
|
326
|
+
*/
|
|
327
|
+
reset(): void;
|
|
328
|
+
/**
|
|
329
|
+
* Get current identity token
|
|
330
|
+
*/
|
|
331
|
+
getToken(): string | null;
|
|
332
|
+
/**
|
|
333
|
+
* Get current identity state
|
|
334
|
+
*/
|
|
335
|
+
getState(): IdentityState;
|
|
336
|
+
/**
|
|
337
|
+
* Check if user is identified
|
|
338
|
+
*/
|
|
339
|
+
isIdentified(): boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Check if user is verified
|
|
342
|
+
*/
|
|
343
|
+
isVerified(): boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Subscribe to identity changes
|
|
346
|
+
*/
|
|
347
|
+
subscribe(callback: (state: IdentityState) => void): () => void;
|
|
348
|
+
private notify;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export declare interface IdentityState {
|
|
352
|
+
token: string | null;
|
|
353
|
+
metadata: Record<string, unknown>;
|
|
354
|
+
isVerified: boolean;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export declare interface Message {
|
|
358
|
+
id: string;
|
|
359
|
+
content: string;
|
|
360
|
+
role: 'user' | 'assistant';
|
|
361
|
+
timestamp: Date;
|
|
362
|
+
/** Citations from knowledge base */
|
|
363
|
+
citations?: Citation[];
|
|
364
|
+
/** Claude's reasoning/thinking trace */
|
|
365
|
+
thinking?: string;
|
|
366
|
+
/** Whether thinking is complete */
|
|
367
|
+
thinkingComplete?: boolean;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Parse SSE chunk into lines and extract data
|
|
372
|
+
*/
|
|
373
|
+
export declare function parseSSEChunk(chunk: string): Generator<string>;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Parse a single SSE data line into a StreamEvent
|
|
377
|
+
*/
|
|
378
|
+
export declare function parseSSEData(data: string): StreamEvent | null;
|
|
379
|
+
|
|
380
|
+
export declare type StreamEvent = {
|
|
381
|
+
type: 'content';
|
|
382
|
+
text: string;
|
|
383
|
+
accumulated: string;
|
|
384
|
+
} | {
|
|
385
|
+
type: 'thinking';
|
|
386
|
+
content: string;
|
|
387
|
+
} | {
|
|
388
|
+
type: 'thinking_complete';
|
|
389
|
+
} | {
|
|
390
|
+
type: 'citations';
|
|
391
|
+
citations: Citation[];
|
|
392
|
+
} | {
|
|
393
|
+
type: 'tool_call_start';
|
|
394
|
+
toolName: string;
|
|
395
|
+
arguments: Record<string, unknown>;
|
|
396
|
+
} | {
|
|
397
|
+
type: 'tool_call_complete';
|
|
398
|
+
toolName: string;
|
|
399
|
+
success: boolean;
|
|
400
|
+
} | {
|
|
401
|
+
type: 'client_tool_call';
|
|
402
|
+
toolName: string;
|
|
403
|
+
arguments: Record<string, unknown>;
|
|
404
|
+
} | {
|
|
405
|
+
type: 'workflow_started';
|
|
406
|
+
name: string;
|
|
407
|
+
todos: WorkflowTodo[];
|
|
408
|
+
} | {
|
|
409
|
+
type: 'workflow_todo_updated';
|
|
410
|
+
todoId: string;
|
|
411
|
+
status: 'pending' | 'completed';
|
|
412
|
+
} | {
|
|
413
|
+
type: 'workflow_ended';
|
|
414
|
+
} | {
|
|
415
|
+
type: 'workflow_complete_prompt';
|
|
416
|
+
} | {
|
|
417
|
+
type: 'verification_status';
|
|
418
|
+
isVerified: boolean;
|
|
419
|
+
} | {
|
|
420
|
+
type: 'conversation_id';
|
|
421
|
+
conversationId: string;
|
|
422
|
+
} | {
|
|
423
|
+
type: 'error';
|
|
424
|
+
message: string;
|
|
425
|
+
} | {
|
|
426
|
+
type: 'done';
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Create an async generator that streams events from a Response
|
|
431
|
+
*/
|
|
432
|
+
export declare function streamResponse(response: Response, signal?: AbortSignal): AsyncGenerator<StreamEvent>;
|
|
433
|
+
|
|
434
|
+
export declare type ToolHandler = (args: Record<string, unknown>) => Promise<ToolResult> | ToolResult;
|
|
435
|
+
|
|
436
|
+
export declare type ToolHandlers = Record<string, ToolHandler>;
|
|
437
|
+
|
|
438
|
+
export declare class ToolManager {
|
|
439
|
+
private handlers;
|
|
440
|
+
/**
|
|
441
|
+
* Register client-side tool handlers
|
|
442
|
+
*/
|
|
443
|
+
register(tools: ToolHandlers): void;
|
|
444
|
+
/**
|
|
445
|
+
* Unregister a tool handler
|
|
446
|
+
*/
|
|
447
|
+
unregister(name: string): void;
|
|
448
|
+
/**
|
|
449
|
+
* Check if a tool is registered
|
|
450
|
+
*/
|
|
451
|
+
has(name: string): boolean;
|
|
452
|
+
/**
|
|
453
|
+
* Get all registered tool names
|
|
454
|
+
*/
|
|
455
|
+
getRegisteredTools(): string[];
|
|
456
|
+
/**
|
|
457
|
+
* Execute a client-side tool
|
|
458
|
+
*/
|
|
459
|
+
execute(name: string, args: Record<string, unknown>): Promise<ToolResult>;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export declare interface ToolResult {
|
|
463
|
+
status: 'success' | 'error';
|
|
464
|
+
data?: unknown;
|
|
465
|
+
error?: string;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export declare interface WorkflowTodo {
|
|
469
|
+
id: string;
|
|
470
|
+
text: string;
|
|
471
|
+
status: 'pending' | 'completed';
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export { }
|