@amaster.ai/client 1.1.0-beta.6 → 1.1.0-beta.61
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 +340 -76
- package/dist/index.cjs +95 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -23
- package/dist/index.d.ts +145 -23
- package/dist/index.js +97 -8
- package/dist/index.js.map +1 -1
- package/package.json +15 -11
- package/types/__tests__/type-checks.test-d.ts +163 -0
- package/types/asr.d.ts +297 -164
- package/types/auth/code-auth.d.ts +8 -157
- package/types/auth/index.d.ts +54 -96
- 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 +8 -32
- package/types/bpm.d.ts +182 -92
- package/types/common.d.ts +52 -44
- package/types/copilot.d.ts +63 -338
- package/types/entity.d.ts +65 -342
- package/types/function.d.ts +11 -88
- package/types/http.d.ts +95 -0
- package/types/index.d.ts +136 -354
- package/types/s3.d.ts +96 -0
- package/types/tts.d.ts +16 -130
- package/types/workflow.d.ts +16 -165
- package/types/auth/permissions.d.ts +0 -254
package/types/copilot.d.ts
CHANGED
|
@@ -1,355 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import type { ClientResult } from './common';
|
|
12
|
-
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// A2UI Protocol Types (for streaming UI)
|
|
15
|
-
// ============================================================================
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* String value with data binding support
|
|
19
|
-
*/
|
|
20
|
-
export interface StringValue {
|
|
21
|
-
path?: string;
|
|
22
|
-
literalString?: string;
|
|
23
|
-
literal?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Number value with data binding support
|
|
28
|
-
*/
|
|
29
|
-
export interface NumberValue {
|
|
30
|
-
path?: string;
|
|
31
|
-
literalNumber?: number;
|
|
32
|
-
literal?: number;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Boolean value with data binding support
|
|
37
|
-
*/
|
|
38
|
-
export interface BooleanValue {
|
|
39
|
-
path?: string;
|
|
40
|
-
literalBoolean?: boolean;
|
|
41
|
-
literal?: boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Component properties in A2UI protocol
|
|
46
|
-
*/
|
|
47
|
-
export type ComponentProperties = Record<string, unknown>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Component instance from server
|
|
51
|
-
*/
|
|
52
|
-
export interface ComponentInstance {
|
|
53
|
-
id: string;
|
|
54
|
-
weight?: number;
|
|
55
|
-
component?: ComponentProperties;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Value map for data model updates
|
|
60
|
-
*/
|
|
61
|
-
export interface ValueMap {
|
|
62
|
-
key: string;
|
|
63
|
-
valueString?: string;
|
|
64
|
-
valueNumber?: number;
|
|
65
|
-
valueBoolean?: boolean;
|
|
66
|
-
valueMap?: ValueMap[];
|
|
67
|
-
[k: string]: unknown;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Begin rendering message - initializes a new UI surface
|
|
72
|
-
*/
|
|
73
|
-
export interface BeginRenderingMessage {
|
|
74
|
-
surfaceId: string;
|
|
75
|
-
root: string;
|
|
76
|
-
styles?: Record<string, string>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Surface update message - updates UI components
|
|
81
|
-
*/
|
|
82
|
-
export interface SurfaceUpdateMessage {
|
|
83
|
-
surfaceId: string;
|
|
84
|
-
components: ComponentInstance[];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Data model update message - updates data bindings
|
|
89
|
-
*/
|
|
90
|
-
export interface DataModelUpdate {
|
|
91
|
-
surfaceId: string;
|
|
92
|
-
path?: string;
|
|
93
|
-
contents: ValueMap[];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Delete surface message - removes a UI surface
|
|
98
|
-
*/
|
|
99
|
-
export interface DeleteSurfaceMessage {
|
|
100
|
-
surfaceId: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Server-to-client message in A2UI protocol
|
|
105
|
-
*
|
|
106
|
-
* Used by the chat() streaming API to send UI updates.
|
|
107
|
-
* 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
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
export interface ServerToClientMessage {
|
|
130
|
-
beginRendering?: BeginRenderingMessage;
|
|
131
|
-
surfaceUpdate?: SurfaceUpdateMessage;
|
|
132
|
-
dataModelUpdate?: DataModelUpdate;
|
|
133
|
-
deleteSurface?: DeleteSurfaceMessage;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Complete UI surface state
|
|
138
|
-
*/
|
|
139
|
-
export interface Surface {
|
|
140
|
-
rootComponentId: string | null;
|
|
141
|
-
componentTree: unknown | null;
|
|
142
|
-
dataModel: Record<string, unknown>;
|
|
143
|
-
components: Map<string, ComponentInstance>;
|
|
144
|
-
styles: Record<string, string>;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Message processor for handling A2UI updates
|
|
149
|
-
*/
|
|
150
|
-
export interface MessageProcessor {
|
|
151
|
-
getSurfaces(): ReadonlyMap<string, Surface>;
|
|
152
|
-
clearSurfaces(): void;
|
|
153
|
-
processMessages(messages: ServerToClientMessage[]): void;
|
|
154
|
-
resolvePath(path: string, dataContextPath?: string): string;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Text content in a message
|
|
159
|
-
*/
|
|
160
|
-
export interface TextContent {
|
|
161
|
-
type: 'text';
|
|
1
|
+
import type {
|
|
2
|
+
SendStreamingMessageResponse,
|
|
3
|
+
CancelTaskResponse,
|
|
4
|
+
GetTaskResponse,
|
|
5
|
+
} from "@a2a-js/sdk";
|
|
6
|
+
import type { ClientResult } from "./common";
|
|
7
|
+
|
|
8
|
+
interface TextContent {
|
|
9
|
+
type: "text";
|
|
162
10
|
text: string;
|
|
163
11
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
type: 'image';
|
|
170
|
-
imageUrl: string;
|
|
12
|
+
interface ImageContent {
|
|
13
|
+
type: "image";
|
|
14
|
+
data?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
mimeType?: string;
|
|
171
17
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
export interface FileContent {
|
|
177
|
-
type: 'file';
|
|
178
|
-
fileUrl: string;
|
|
179
|
-
fileName?: string;
|
|
18
|
+
interface FileContent {
|
|
19
|
+
type: "file";
|
|
20
|
+
data?: string;
|
|
21
|
+
url?: string;
|
|
180
22
|
mimeType?: string;
|
|
23
|
+
name?: string;
|
|
181
24
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*/
|
|
186
|
-
export type MessageContent = TextContent | ImageContent | FileContent;
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* 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
|
-
* ```
|
|
211
|
-
*/
|
|
212
|
-
export interface ChatMessage {
|
|
213
|
-
/** Message role */
|
|
214
|
-
role: 'system' | 'user' | 'assistant';
|
|
215
|
-
|
|
216
|
-
/** Message content (string or structured content) */
|
|
25
|
+
type MessageContent = TextContent | ImageContent | FileContent;
|
|
26
|
+
interface ChatMessage {
|
|
27
|
+
role: "system" | "user" | "assistant";
|
|
217
28
|
content: string | MessageContent[];
|
|
218
29
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
* Chat options
|
|
222
|
-
*/
|
|
223
|
-
export interface ChatOptions {
|
|
224
|
-
/** Stream response */
|
|
225
|
-
stream?: boolean;
|
|
226
|
-
|
|
227
|
-
/** Temperature (0-1) */
|
|
228
|
-
temperature?: number;
|
|
229
|
-
|
|
230
|
-
/** Maximum tokens to generate */
|
|
231
|
-
maxTokens?: number;
|
|
232
|
-
|
|
233
|
-
/** Callback for streamed chunks */
|
|
234
|
-
onChunk?: (chunk: string) => void;
|
|
235
|
-
|
|
236
|
-
/** Callback when streaming completes */
|
|
237
|
-
onComplete?: (fullResponse: string) => void;
|
|
30
|
+
interface ChatOptions {
|
|
31
|
+
taskId?: string;
|
|
238
32
|
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Copilot AI Assistant Client API
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* Basic chat:
|
|
245
|
-
* ```typescript
|
|
246
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
247
|
-
*
|
|
248
|
-
* const stream = client.copilot.chat([
|
|
249
|
-
* { role: 'user', content: 'Hello, how are you?' }
|
|
250
|
-
* ]);
|
|
251
|
-
*
|
|
252
|
-
* for await (const messages of stream) {
|
|
253
|
-
* // Process A2UI messages
|
|
254
|
-
* }
|
|
255
|
-
* ```
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* With task ID for conversation continuity:
|
|
259
|
-
* ```typescript
|
|
260
|
-
* const stream = client.copilot.chat(
|
|
261
|
-
* [{ role: 'user', content: 'Tell me a story' }],
|
|
262
|
-
* { taskId: 'conv-123' }
|
|
263
|
-
* );
|
|
264
|
-
*
|
|
265
|
-
* for await (const messages of stream) {
|
|
266
|
-
* for (const msg of messages) {
|
|
267
|
-
* if (msg.dataModelUpdate) {
|
|
268
|
-
* // Extract and display text content
|
|
269
|
-
* }
|
|
270
|
-
* }
|
|
271
|
-
* }
|
|
272
|
-
* ```
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* Multi-turn conversation:
|
|
276
|
-
* ```typescript
|
|
277
|
-
* const conversation: ChatMessage[] = [
|
|
278
|
-
* { role: 'system', content: 'You are a helpful assistant' },
|
|
279
|
-
* { role: 'user', content: 'What is TypeScript?' }
|
|
280
|
-
* ];
|
|
281
|
-
*
|
|
282
|
-
* for await (const messages of client.copilot.chat(conversation)) {
|
|
283
|
-
* // Process streaming response
|
|
284
|
-
* }
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
export interface CopilotA2UIClient {
|
|
33
|
+
type CopilotClientAPI = {
|
|
288
34
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* Returns an async generator that yields A2UI ServerToClientMessage arrays.
|
|
292
|
-
* Each yielded array contains UI updates that should be processed by an A2UI renderer.
|
|
293
|
-
*
|
|
294
|
-
* @param messages - Conversation messages (system, user, assistant)
|
|
295
|
-
* @param options - Chat options (taskId for conversation continuity)
|
|
296
|
-
* @returns AsyncGenerator yielding arrays of A2UI messages
|
|
297
|
-
*
|
|
298
|
-
* @example
|
|
299
|
-
* Simple chat:
|
|
300
|
-
* ```typescript
|
|
301
|
-
* const stream = client.copilot.chat([
|
|
302
|
-
* { role: 'user', content: 'What is the capital of France?' }
|
|
303
|
-
* ]);
|
|
304
|
-
*
|
|
305
|
-
* for await (const messages of stream) {
|
|
306
|
-
* // Process A2UI updates
|
|
307
|
-
* }
|
|
308
|
-
* ```
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
* With system prompt:
|
|
312
|
-
* ```typescript
|
|
313
|
-
* const stream = client.copilot.chat([
|
|
314
|
-
* { role: 'system', content: 'You are a helpful coding assistant' },
|
|
315
|
-
* { role: 'user', content: 'How do I reverse a string in JavaScript?' }
|
|
316
|
-
* ]);
|
|
317
|
-
* ```
|
|
318
|
-
*
|
|
35
|
+
* Stream messages from Copilot Agent.
|
|
36
|
+
*
|
|
319
37
|
* @example
|
|
320
|
-
* Extracting text content from A2UI messages:
|
|
321
38
|
* ```typescript
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* }
|
|
329
|
-
* }
|
|
330
|
-
* }
|
|
331
|
-
* }
|
|
39
|
+
* import { createCopilotClient, Data } from "@amaster.ai/copilot-client";
|
|
40
|
+
*
|
|
41
|
+
* const client = createCopilotClient();
|
|
42
|
+
*
|
|
43
|
+
* for await (const response of client.chat([{ role: "user", content: "Hello" }])) {
|
|
44
|
+
* // deal response
|
|
332
45
|
* }
|
|
333
46
|
* ```
|
|
334
47
|
*/
|
|
335
48
|
chat(
|
|
336
49
|
messages: ChatMessage[],
|
|
337
50
|
options?: ChatOptions
|
|
338
|
-
): AsyncGenerator<
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
51
|
+
): AsyncGenerator<SendStreamingMessageResponse, void, unknown>;
|
|
52
|
+
cancelChat(taskId: string): Promise<ClientResult<CancelTaskResponse>>;
|
|
53
|
+
getChatStatus(taskId?: string): Promise<{
|
|
54
|
+
working: boolean;
|
|
55
|
+
taskId?: string;
|
|
56
|
+
error?: string;
|
|
57
|
+
}>;
|
|
58
|
+
getHistory(
|
|
59
|
+
limit?: number,
|
|
60
|
+
next?: string
|
|
61
|
+
): Promise<
|
|
62
|
+
| {
|
|
63
|
+
messages: SendStreamingMessageResponse[];
|
|
64
|
+
next: string;
|
|
65
|
+
hasMore: boolean;
|
|
66
|
+
}
|
|
67
|
+
| undefined
|
|
68
|
+
>;
|
|
69
|
+
newConversation(): Promise<void>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
type ChatMessage,
|
|
74
|
+
type ChatOptions,
|
|
75
|
+
type CopilotClientAPI,
|
|
76
|
+
type FileContent,
|
|
77
|
+
type ImageContent,
|
|
78
|
+
type MessageContent,
|
|
79
|
+
type TextContent,
|
|
80
|
+
};
|