@amaster.ai/client 1.1.0-beta.30 → 1.1.0-beta.31
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/index.cjs +63 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +63 -8
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/types/__tests__/type-checks.test-d.ts +163 -0
- package/types/asr.d.ts +10 -114
- package/types/auth/code-auth.d.ts +5 -154
- package/types/auth/index.d.ts +20 -166
- package/types/auth/oauth.d.ts +6 -143
- package/types/auth/password-auth.d.ts +38 -137
- package/types/auth/profile.d.ts +4 -103
- package/types/auth/user.d.ts +3 -33
- package/types/bpm.d.ts +53 -168
- package/types/common.d.ts +52 -44
- package/types/copilot.d.ts +50 -117
- package/types/entity.d.ts +65 -342
- package/types/function.d.ts +11 -88
- package/types/index.d.ts +52 -302
- package/types/s3.d.ts +25 -56
- package/types/tts.d.ts +10 -128
- package/types/workflow.d.ts +16 -165
package/types/bpm.d.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ============================================================================
|
|
3
|
-
* BPM Module - Type Definitions
|
|
4
|
-
* ============================================================================
|
|
5
|
-
*
|
|
6
|
-
* This module provides Business Process Management (BPM) capabilities
|
|
7
|
-
* based on Camunda BPMN engine.
|
|
8
|
-
*
|
|
9
|
-
* ## Key Features
|
|
10
|
-
* - Start and manage BPMN processes
|
|
11
|
-
* - Query and complete user tasks
|
|
12
|
-
* - Manage process variables
|
|
13
|
-
* - Query process history
|
|
14
|
-
* - Handle BPMN flows (approval, business processes, etc.)
|
|
15
2
|
*
|
|
16
3
|
* @module bpm
|
|
17
4
|
*/
|
|
@@ -47,14 +34,7 @@ export type CamundaVariableValue =
|
|
|
47
34
|
|
|
48
35
|
/**
|
|
49
36
|
* Camunda variable with type hint
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const variable: CamundaVariable = {
|
|
54
|
-
* value: 1000,
|
|
55
|
-
* type: 'Long'
|
|
56
|
-
* };
|
|
57
|
-
* ```
|
|
37
|
+
*
|
|
58
38
|
*/
|
|
59
39
|
export interface CamundaVariable {
|
|
60
40
|
value: CamundaVariableValue;
|
|
@@ -63,17 +43,7 @@ export interface CamundaVariable {
|
|
|
63
43
|
|
|
64
44
|
/**
|
|
65
45
|
* Variable submission format for process/task
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* const submission: VariableSubmission = {
|
|
70
|
-
* variables: {
|
|
71
|
-
* amount: { value: 1000, type: 'Long' },
|
|
72
|
-
* requester: { value: 'user-123', type: 'String' },
|
|
73
|
-
* approved: { value: false, type: 'Boolean' }
|
|
74
|
-
* }
|
|
75
|
-
* };
|
|
76
|
-
* ```
|
|
46
|
+
*
|
|
77
47
|
*/
|
|
78
48
|
export interface VariableSubmission {
|
|
79
49
|
variables: Record<string, CamundaVariable>;
|
|
@@ -203,33 +173,7 @@ export interface TaskCount {
|
|
|
203
173
|
*
|
|
204
174
|
* Provides methods for managing BPMN processes and tasks.
|
|
205
175
|
*
|
|
206
|
-
* @
|
|
207
|
-
* Complete BPM flow:
|
|
208
|
-
* ```typescript
|
|
209
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
210
|
-
*
|
|
211
|
-
* // 1. Start a process
|
|
212
|
-
* const process = await client.bpm.startProcess('approval', {
|
|
213
|
-
* amount: { value: 5000, type: 'Long' },
|
|
214
|
-
* requester: { value: 'user-123', type: 'String' },
|
|
215
|
-
* description: { value: 'Purchase request', type: 'String' }
|
|
216
|
-
* });
|
|
217
|
-
*
|
|
218
|
-
* console.log('Process started:', process.data.id);
|
|
219
|
-
*
|
|
220
|
-
* // 2. Get user's tasks
|
|
221
|
-
* const tasks = await client.bpm.getTasks({
|
|
222
|
-
* assignee: 'manager-456',
|
|
223
|
-
* processDefinitionKey: 'approval'
|
|
224
|
-
* });
|
|
225
|
-
*
|
|
226
|
-
* // 3. Complete a task
|
|
227
|
-
* const taskId = tasks.data[0].id;
|
|
228
|
-
* await client.bpm.completeTask(taskId, {
|
|
229
|
-
* approved: { value: true, type: 'Boolean' },
|
|
230
|
-
* comment: { value: 'Approved!', type: 'String' }
|
|
231
|
-
* });
|
|
232
|
-
* ```
|
|
176
|
+
* @since 1.0.0
|
|
233
177
|
*/
|
|
234
178
|
export interface BpmClientAPI {
|
|
235
179
|
// ==================== Process Management ====================
|
|
@@ -242,26 +186,24 @@ export interface BpmClientAPI {
|
|
|
242
186
|
* @returns New process instance information
|
|
243
187
|
*
|
|
244
188
|
* @example
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* const result = await client.bpm.startProcess('approval', {
|
|
189
|
+
* // Simple start
|
|
190
|
+
* const result = await client.bpm.startProcess('approval-process', {
|
|
248
191
|
* amount: 1000,
|
|
249
|
-
* requester: '
|
|
250
|
-
* urgent: true
|
|
192
|
+
* requester: 'john@example.com'
|
|
251
193
|
* });
|
|
252
|
-
*
|
|
194
|
+
*
|
|
195
|
+
* if (result.success) {
|
|
196
|
+
* console.log('Process started:', result.data.id);
|
|
197
|
+
* }
|
|
253
198
|
*
|
|
254
199
|
* @example
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* amount: { value: 5000, type: 'Long' },
|
|
260
|
-
* supplier: { value: 'ABC Corp', type: 'String' },
|
|
261
|
-
* requestDate: { value: new Date(), type: 'Date' }
|
|
262
|
-
* }
|
|
200
|
+
* // With business key
|
|
201
|
+
* const result = await client.bpm.startProcess('order-fulfillment', {
|
|
202
|
+
* orderId: 'ORDER-12345',
|
|
203
|
+
* items: [{ sku: 'ITEM-1', qty: 2 }]
|
|
263
204
|
* });
|
|
264
|
-
*
|
|
205
|
+
*
|
|
206
|
+
* @since 1.0.0
|
|
265
207
|
*/
|
|
266
208
|
startProcess(
|
|
267
209
|
processKey: string,
|
|
@@ -273,15 +215,7 @@ export interface BpmClientAPI {
|
|
|
273
215
|
*
|
|
274
216
|
* @param params - Query parameters
|
|
275
217
|
* @returns Array of process instances
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
* Get all active approval processes:
|
|
279
|
-
* ```typescript
|
|
280
|
-
* const result = await client.bpm.getProcessInstances({
|
|
281
|
-
* processDefinitionKey: 'approval',
|
|
282
|
-
* active: true
|
|
283
|
-
* });
|
|
284
|
-
* ```
|
|
218
|
+
*
|
|
285
219
|
*/
|
|
286
220
|
getProcessInstances(
|
|
287
221
|
params?: ProcessInstanceQueryParams
|
|
@@ -292,12 +226,7 @@ export interface BpmClientAPI {
|
|
|
292
226
|
*
|
|
293
227
|
* @param processInstanceId - Process instance ID
|
|
294
228
|
* @returns Process instance information
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
* ```typescript
|
|
298
|
-
* const result = await client.bpm.getProcessInstance('proc-123-456');
|
|
299
|
-
* console.log('Process:', result.data);
|
|
300
|
-
* ```
|
|
229
|
+
*
|
|
301
230
|
*/
|
|
302
231
|
getProcessInstance(
|
|
303
232
|
processInstanceId: string
|
|
@@ -309,11 +238,7 @@ export interface BpmClientAPI {
|
|
|
309
238
|
* @param processInstanceId - Process instance ID
|
|
310
239
|
* @param params - Optional parameters
|
|
311
240
|
* @returns null on success
|
|
312
|
-
*
|
|
313
|
-
* @example
|
|
314
|
-
* ```typescript
|
|
315
|
-
* await client.bpm.deleteProcessInstance('proc-123');
|
|
316
|
-
* ```
|
|
241
|
+
*
|
|
317
242
|
*/
|
|
318
243
|
deleteProcessInstance(
|
|
319
244
|
processInstanceId: string,
|
|
@@ -325,23 +250,7 @@ export interface BpmClientAPI {
|
|
|
325
250
|
*
|
|
326
251
|
* @param params - Process instance ID and optional variable name
|
|
327
252
|
* @returns Array of process variables
|
|
328
|
-
*
|
|
329
|
-
* @example
|
|
330
|
-
* Get all variables:
|
|
331
|
-
* ```typescript
|
|
332
|
-
* const result = await client.bpm.getProcessVariables({
|
|
333
|
-
* processInstanceId: 'proc-123'
|
|
334
|
-
* });
|
|
335
|
-
* ```
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
* Get specific variable:
|
|
339
|
-
* ```typescript
|
|
340
|
-
* const result = await client.bpm.getProcessVariables({
|
|
341
|
-
* processInstanceId: 'proc-123',
|
|
342
|
-
* variableName: 'amount'
|
|
343
|
-
* });
|
|
344
|
-
* ```
|
|
253
|
+
*
|
|
345
254
|
*/
|
|
346
255
|
getProcessVariables(params: {
|
|
347
256
|
processInstanceId: string;
|
|
@@ -357,25 +266,23 @@ export interface BpmClientAPI {
|
|
|
357
266
|
* @returns Array of tasks
|
|
358
267
|
*
|
|
359
268
|
* @example
|
|
360
|
-
* Get tasks
|
|
361
|
-
*
|
|
362
|
-
* const result = await client.bpm.getTasks({
|
|
363
|
-
* assignee: 'user-123'
|
|
364
|
-
* });
|
|
269
|
+
* // Get all tasks
|
|
270
|
+
* const result = await client.bpm.getTasks();
|
|
365
271
|
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
272
|
+
* @example
|
|
273
|
+
* // Get tasks for current user
|
|
274
|
+
* const result = await client.bpm.getTasks({
|
|
275
|
+
* assignee: 'currentUserId'
|
|
368
276
|
* });
|
|
369
|
-
* ```
|
|
370
277
|
*
|
|
371
278
|
* @example
|
|
372
|
-
* Get tasks for
|
|
373
|
-
* ```typescript
|
|
279
|
+
* // Get tasks for a process
|
|
374
280
|
* const result = await client.bpm.getTasks({
|
|
375
|
-
*
|
|
376
|
-
*
|
|
281
|
+
* processDefinitionKey: 'approval-process',
|
|
282
|
+
* maxResults: 10
|
|
377
283
|
* });
|
|
378
|
-
*
|
|
284
|
+
*
|
|
285
|
+
* @since 1.0.0
|
|
379
286
|
*/
|
|
380
287
|
getTasks(params?: TaskQueryParams): Promise<ClientResult<Task[]>>;
|
|
381
288
|
|
|
@@ -385,13 +292,7 @@ export interface BpmClientAPI {
|
|
|
385
292
|
* @param params - Query parameters
|
|
386
293
|
* @returns Task count
|
|
387
294
|
*
|
|
388
|
-
* @
|
|
389
|
-
* ```typescript
|
|
390
|
-
* const result = await client.bpm.getTaskCount({
|
|
391
|
-
* assignee: 'user-123'
|
|
392
|
-
* });
|
|
393
|
-
* console.log(`You have ${result.data.count} tasks`);
|
|
394
|
-
* ```
|
|
295
|
+
* @since 1.0.0
|
|
395
296
|
*/
|
|
396
297
|
getTaskCount(params?: TaskQueryParams): Promise<ClientResult<TaskCount>>;
|
|
397
298
|
|
|
@@ -402,10 +303,12 @@ export interface BpmClientAPI {
|
|
|
402
303
|
* @returns Task information
|
|
403
304
|
*
|
|
404
305
|
* @example
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
306
|
+
* const result = await client.bpm.getTask('task-123');
|
|
307
|
+
* if (result.success) {
|
|
308
|
+
* console.log('Task:', result.data.name);
|
|
309
|
+
* }
|
|
310
|
+
*
|
|
311
|
+
* @since 1.0.0
|
|
409
312
|
*/
|
|
410
313
|
getTask(taskId: string): Promise<ClientResult<Task>>;
|
|
411
314
|
|
|
@@ -417,24 +320,24 @@ export interface BpmClientAPI {
|
|
|
417
320
|
* @returns null on success
|
|
418
321
|
*
|
|
419
322
|
* @example
|
|
420
|
-
* Complete with
|
|
421
|
-
*
|
|
422
|
-
* await client.bpm.completeTask('task-123', {
|
|
323
|
+
* // Complete with approval
|
|
324
|
+
* const result = await client.bpm.completeTask('task-123', {
|
|
423
325
|
* approved: true,
|
|
424
|
-
*
|
|
326
|
+
* comments: 'Looks good!'
|
|
425
327
|
* });
|
|
426
|
-
*
|
|
328
|
+
*
|
|
329
|
+
* if (result.success) {
|
|
330
|
+
* console.log('Task completed');
|
|
331
|
+
* }
|
|
427
332
|
*
|
|
428
333
|
* @example
|
|
429
|
-
* Complete with
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
* approved: { value: false, type: 'Boolean' },
|
|
434
|
-
* reason: { value: 'Insufficient budget', type: 'String' }
|
|
435
|
-
* }
|
|
334
|
+
* // Complete with rejection
|
|
335
|
+
* const result = await client.bpm.completeTask('task-456', {
|
|
336
|
+
* approved: false,
|
|
337
|
+
* reason: 'Missing documentation'
|
|
436
338
|
* });
|
|
437
|
-
*
|
|
339
|
+
*
|
|
340
|
+
* @since 1.0.0
|
|
438
341
|
*/
|
|
439
342
|
completeTask(
|
|
440
343
|
taskId: string,
|
|
@@ -448,17 +351,7 @@ export interface BpmClientAPI {
|
|
|
448
351
|
*
|
|
449
352
|
* @param params - Query parameters
|
|
450
353
|
* @returns Array of historical process instances
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* Get completed processes:
|
|
454
|
-
* ```typescript
|
|
455
|
-
* const result = await client.bpm.getHistoryProcessInstances({
|
|
456
|
-
* finished: true,
|
|
457
|
-
* processDefinitionKey: 'approval',
|
|
458
|
-
* sortBy: 'startTime',
|
|
459
|
-
* sortOrder: 'desc'
|
|
460
|
-
* });
|
|
461
|
-
* ```
|
|
354
|
+
*
|
|
462
355
|
*/
|
|
463
356
|
getHistoryProcessInstances(
|
|
464
357
|
params?: HistoryProcessInstanceQueryParams
|
|
@@ -469,15 +362,7 @@ export interface BpmClientAPI {
|
|
|
469
362
|
*
|
|
470
363
|
* @param params - Query parameters
|
|
471
364
|
* @returns Process count
|
|
472
|
-
*
|
|
473
|
-
* @example
|
|
474
|
-
* ```typescript
|
|
475
|
-
* const result = await client.bpm.getHistoryProcessInstanceCount({
|
|
476
|
-
* startedBy: 'user-123',
|
|
477
|
-
* finished: true
|
|
478
|
-
* });
|
|
479
|
-
* console.log(`Completed: ${result.data.count} processes`);
|
|
480
|
-
* ```
|
|
365
|
+
*
|
|
481
366
|
*/
|
|
482
367
|
getHistoryProcessInstanceCount(
|
|
483
368
|
params?: HistoryProcessInstanceQueryParams
|
package/types/common.d.ts
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Common Types - Shared across all modules
|
|
4
|
-
* ============================================================================
|
|
2
|
+
* Error information structure
|
|
5
3
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
4
|
+
* @since 1.1.0
|
|
9
5
|
*/
|
|
6
|
+
export interface ClientError {
|
|
7
|
+
/**
|
|
8
|
+
* HTTP status code
|
|
9
|
+
*/
|
|
10
|
+
status: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Error message
|
|
14
|
+
*/
|
|
15
|
+
message: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Application-specific error code (e.g., 'INVALID_TOKEN', 'PERMISSION_DENIED')
|
|
19
|
+
*
|
|
20
|
+
* @since 1.1.0
|
|
21
|
+
*/
|
|
22
|
+
code?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Additional error details (optional)
|
|
26
|
+
*/
|
|
27
|
+
details?: unknown;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Error timestamp (ISO 8601 format)
|
|
31
|
+
*
|
|
32
|
+
* @since 1.1.0
|
|
33
|
+
*/
|
|
34
|
+
timestamp?: string;
|
|
35
|
+
}
|
|
10
36
|
|
|
11
37
|
/**
|
|
12
38
|
* Standard API response wrapper
|
|
@@ -17,33 +43,21 @@
|
|
|
17
43
|
* @template T - The type of the successful response data
|
|
18
44
|
*
|
|
19
45
|
* @example
|
|
20
|
-
* Success
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* console.log('User:', result.data); // Type: User
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* Error handling:
|
|
30
|
-
* ```typescript
|
|
31
|
-
* const result = await client.entity.get('default', 'users', '123');
|
|
32
|
-
* if (result.error) {
|
|
33
|
-
* console.error(`Error ${result.error.status}:`, result.error.message);
|
|
46
|
+
* // Success case
|
|
47
|
+
* const result = await client.entity.list('default', 'users');
|
|
48
|
+
* if (result.success) {
|
|
49
|
+
* console.log('Data:', result.data);
|
|
34
50
|
* }
|
|
35
|
-
* ```
|
|
36
51
|
*
|
|
37
52
|
* @example
|
|
38
|
-
*
|
|
39
|
-
* ```typescript
|
|
53
|
+
* // Error case
|
|
40
54
|
* const result = await client.auth.login({ email, password });
|
|
41
|
-
* if (result.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* // Unauthorized
|
|
55
|
+
* if (!result.success) {
|
|
56
|
+
* console.error('Error:', result.error.message);
|
|
57
|
+
* console.error('Code:', result.error.code);
|
|
45
58
|
* }
|
|
46
|
-
*
|
|
59
|
+
*
|
|
60
|
+
* @since 1.0.0
|
|
47
61
|
*/
|
|
48
62
|
export interface ClientResult<T> {
|
|
49
63
|
/**
|
|
@@ -54,27 +68,21 @@ export interface ClientResult<T> {
|
|
|
54
68
|
/**
|
|
55
69
|
* Error information (null if successful)
|
|
56
70
|
*/
|
|
57
|
-
error:
|
|
58
|
-
/**
|
|
59
|
-
* HTTP status code
|
|
60
|
-
*/
|
|
61
|
-
status: number;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Error message
|
|
65
|
-
*/
|
|
66
|
-
message: string;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Additional error details (optional)
|
|
70
|
-
*/
|
|
71
|
-
details?: unknown;
|
|
72
|
-
} | null;
|
|
71
|
+
error: ClientError | null;
|
|
73
72
|
|
|
74
73
|
/**
|
|
75
74
|
* HTTP response status code
|
|
76
75
|
*/
|
|
77
76
|
status: number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Convenience flag for checking if request was successful
|
|
80
|
+
*
|
|
81
|
+
* Equivalent to `error === null`
|
|
82
|
+
*
|
|
83
|
+
* @since 1.1.0
|
|
84
|
+
*/
|
|
85
|
+
success: boolean;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
/**
|
package/types/copilot.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Copilot AI Assistant - Type Definitions
|
|
4
|
-
* ============================================================================
|
|
5
|
-
*
|
|
6
|
-
* AI-powered assistant for interactive conversations and task assistance.
|
|
2
|
+
* * AI-powered assistant for interactive conversations and task assistance.
|
|
7
3
|
*
|
|
8
4
|
* @module copilot
|
|
9
5
|
*/
|
|
@@ -105,26 +101,7 @@ export interface DeleteSurfaceMessage {
|
|
|
105
101
|
*
|
|
106
102
|
* Used by the chat() streaming API to send UI updates.
|
|
107
103
|
* Each message can contain one of several update types.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```typescript
|
|
111
|
-
* const stream = client.copilot.chat([
|
|
112
|
-
* { role: 'user', content: 'Show me a chart' }
|
|
113
|
-
* ]);
|
|
114
|
-
*
|
|
115
|
-
* for await (const messages of stream) {
|
|
116
|
-
* for (const msg of messages) {
|
|
117
|
-
* if (msg.surfaceUpdate) {
|
|
118
|
-
* // Render UI components
|
|
119
|
-
* renderComponents(msg.surfaceUpdate.components);
|
|
120
|
-
* }
|
|
121
|
-
* if (msg.dataModelUpdate) {
|
|
122
|
-
* // Update data bindings
|
|
123
|
-
* updateData(msg.dataModelUpdate.contents);
|
|
124
|
-
* }
|
|
125
|
-
* }
|
|
126
|
-
* }
|
|
127
|
-
* ```
|
|
104
|
+
*
|
|
128
105
|
*/
|
|
129
106
|
export interface ServerToClientMessage {
|
|
130
107
|
beginRendering?: BeginRenderingMessage;
|
|
@@ -187,27 +164,7 @@ export type MessageContent = TextContent | ImageContent | FileContent;
|
|
|
187
164
|
|
|
188
165
|
/**
|
|
189
166
|
* Chat message
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* Text message:
|
|
193
|
-
* ```typescript
|
|
194
|
-
* const message: ChatMessage = {
|
|
195
|
-
* role: 'user',
|
|
196
|
-
* content: 'Hello, how can you help me?'
|
|
197
|
-
* };
|
|
198
|
-
* ```
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* Message with image:
|
|
202
|
-
* ```typescript
|
|
203
|
-
* const message: ChatMessage = {
|
|
204
|
-
* role: 'user',
|
|
205
|
-
* content: [
|
|
206
|
-
* { type: 'text', text: 'What is in this image?' },
|
|
207
|
-
* { type: 'image', imageUrl: 'https://example.com/image.jpg' }
|
|
208
|
-
* ]
|
|
209
|
-
* };
|
|
210
|
-
* ```
|
|
167
|
+
*
|
|
211
168
|
*/
|
|
212
169
|
export interface ChatMessage {
|
|
213
170
|
/** Message role */
|
|
@@ -241,51 +198,9 @@ export interface ChatOptions { /** Task ID for conversation continuity */
|
|
|
241
198
|
/**
|
|
242
199
|
* Copilot AI Assistant Client API
|
|
243
200
|
*
|
|
244
|
-
* @
|
|
245
|
-
* Basic chat:
|
|
246
|
-
* ```typescript
|
|
247
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
248
|
-
*
|
|
249
|
-
* const stream = client.copilot.chat([
|
|
250
|
-
* { role: 'user', content: 'Hello, how are you?' }
|
|
251
|
-
* ]);
|
|
252
|
-
*
|
|
253
|
-
* for await (const messages of stream) {
|
|
254
|
-
* // Process A2UI messages
|
|
255
|
-
* }
|
|
256
|
-
* ```
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* With task ID for conversation continuity:
|
|
260
|
-
* ```typescript
|
|
261
|
-
* const stream = client.copilot.chat(
|
|
262
|
-
* [{ role: 'user', content: 'Tell me a story' }],
|
|
263
|
-
* { taskId: 'conv-123' }
|
|
264
|
-
* );
|
|
265
|
-
*
|
|
266
|
-
* for await (const messages of stream) {
|
|
267
|
-
* for (const msg of messages) {
|
|
268
|
-
* if (msg.dataModelUpdate) {
|
|
269
|
-
* // Extract and display text content
|
|
270
|
-
* }
|
|
271
|
-
* }
|
|
272
|
-
* }
|
|
273
|
-
* ```
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* Multi-turn conversation:
|
|
277
|
-
* ```typescript
|
|
278
|
-
* const conversation: ChatMessage[] = [
|
|
279
|
-
* { role: 'system', content: 'You are a helpful assistant' },
|
|
280
|
-
* { role: 'user', content: 'What is TypeScript?' }
|
|
281
|
-
* ];
|
|
282
|
-
*
|
|
283
|
-
* for await (const messages of client.copilot.chat(conversation)) {
|
|
284
|
-
* // Process streaming response
|
|
285
|
-
* }
|
|
286
|
-
* ```
|
|
201
|
+
* @since 1.0.0
|
|
287
202
|
*/
|
|
288
|
-
export interface
|
|
203
|
+
export interface CopilotClientAPI {
|
|
289
204
|
/**
|
|
290
205
|
* Start a streaming chat session with the AI assistant
|
|
291
206
|
*
|
|
@@ -297,41 +212,43 @@ export interface CopilotA2UIClient {
|
|
|
297
212
|
* @returns AsyncGenerator yielding arrays of A2UI messages
|
|
298
213
|
*
|
|
299
214
|
* @example
|
|
300
|
-
* Simple chat
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* { role: 'user', content: 'What is the capital of France?' }
|
|
215
|
+
* // Simple chat
|
|
216
|
+
* const chatStream = client.copilot.chat([
|
|
217
|
+
* { role: 'user', content: 'Hello, how can you help me?' }
|
|
304
218
|
* ]);
|
|
305
219
|
*
|
|
306
|
-
* for await (const messages of
|
|
307
|
-
*
|
|
220
|
+
* for await (const messages of chatStream) {
|
|
221
|
+
* messages.forEach(msg => {
|
|
222
|
+
* if (msg.surfaceUpdate) {
|
|
223
|
+
* console.log('UI update:', msg.surfaceUpdate);
|
|
224
|
+
* }
|
|
225
|
+
* });
|
|
308
226
|
* }
|
|
309
|
-
* ```
|
|
310
227
|
*
|
|
311
228
|
* @example
|
|
312
|
-
* With
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
* { role: '
|
|
316
|
-
* { role: '
|
|
317
|
-
*
|
|
318
|
-
*
|
|
229
|
+
* // With conversation history
|
|
230
|
+
* const chatStream = client.copilot.chat([
|
|
231
|
+
* { role: 'system', content: 'You are a helpful assistant.' },
|
|
232
|
+
* { role: 'user', content: 'What is TypeScript?' },
|
|
233
|
+
* { role: 'assistant', content: 'TypeScript is...' },
|
|
234
|
+
* { role: 'user', content: 'Can you give an example?' }
|
|
235
|
+
* ], {
|
|
236
|
+
* taskId: 'conversation-123'
|
|
237
|
+
* });
|
|
319
238
|
*
|
|
320
239
|
* @example
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* }
|
|
330
|
-
* }
|
|
331
|
-
* }
|
|
240
|
+
* // With image content
|
|
241
|
+
* const chatStream = client.copilot.chat([
|
|
242
|
+
* {
|
|
243
|
+
* role: 'user',
|
|
244
|
+
* content: [
|
|
245
|
+
* { type: 'text', text: 'What is in this image?' },
|
|
246
|
+
* { type: 'image', imageUrl: 'https://example.com/image.jpg' }
|
|
247
|
+
* ]
|
|
332
248
|
* }
|
|
333
|
-
*
|
|
334
|
-
*
|
|
249
|
+
* ]);
|
|
250
|
+
*
|
|
251
|
+
* @since 1.0.0
|
|
335
252
|
*/
|
|
336
253
|
chat(
|
|
337
254
|
messages: ChatMessage[],
|
|
@@ -343,6 +260,14 @@ export interface CopilotA2UIClient {
|
|
|
343
260
|
*
|
|
344
261
|
* @param taskId - Task ID to cancel
|
|
345
262
|
* @returns Cancellation result
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* const result = await client.copilot.cancelChat('task-123');
|
|
266
|
+
* if (result.success) {
|
|
267
|
+
* console.log('Chat cancelled');
|
|
268
|
+
* }
|
|
269
|
+
*
|
|
270
|
+
* @since 1.0.0
|
|
346
271
|
*/
|
|
347
272
|
cancelChat(taskId: string): Promise<ClientResult<unknown>>;
|
|
348
273
|
|
|
@@ -351,6 +276,14 @@ export interface CopilotA2UIClient {
|
|
|
351
276
|
*
|
|
352
277
|
* @param taskId - Task ID to query
|
|
353
278
|
* @returns Task status information
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* const result = await client.copilot.getChatStatus('task-123');
|
|
282
|
+
* if (result.success) {
|
|
283
|
+
* console.log('Status:', result.data);
|
|
284
|
+
* }
|
|
285
|
+
*
|
|
286
|
+
* @since 1.0.0
|
|
354
287
|
*/
|
|
355
288
|
getChatStatus(taskId: string): Promise<ClientResult<unknown>>;
|
|
356
289
|
}
|