@amaster.ai/client 1.1.0-beta.3 → 1.1.0-beta.5

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 CHANGED
@@ -487,13 +487,10 @@ const result = await client.copilot.sendMessage([
487
487
  console.log(result.data.content);
488
488
 
489
489
  // Streaming response
490
- await client.copilot.sendMessage(
491
- [{ role: "user", content: "Tell me a story" }],
492
- {
493
- stream: true,
494
- onChunk: (chunk) => console.log(chunk),
495
- }
496
- );
490
+ await client.copilot.sendMessage([{ role: "user", content: "Tell me a story" }], {
491
+ stream: true,
492
+ onChunk: (chunk) => console.log(chunk),
493
+ });
497
494
  ```
498
495
 
499
496
  ### `client.function`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/client",
3
- "version": "1.1.0-beta.3",
3
+ "version": "1.1.0-beta.5",
4
4
  "description": "Unified API client for Amaster platform - All services in one package",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -69,16 +69,16 @@
69
69
  "registry": "https://registry.npmjs.org/"
70
70
  },
71
71
  "dependencies": {
72
- "@amaster.ai/bpm-client": "1.1.0-beta.3",
72
+ "@amaster.ai/asr-http-client": "1.1.0-beta.3",
73
73
  "@amaster.ai/copilot-client": "1.1.0-beta.3",
74
+ "@amaster.ai/entity-client": "1.1.0-beta.3",
75
+ "@amaster.ai/bpm-client": "1.1.0-beta.3",
76
+ "@amaster.ai/http-client": "1.1.0-beta.3",
77
+ "@amaster.ai/tts-client": "1.1.0-beta.3",
74
78
  "@amaster.ai/function-client": "1.1.0-beta.3",
75
79
  "@amaster.ai/auth-client": "1.1.0-beta.3",
76
80
  "@amaster.ai/asr-client": "1.1.0-beta.3",
77
- "@amaster.ai/http-client": "1.1.0-beta.3",
78
- "@amaster.ai/workflow-client": "1.1.0-beta.3",
79
- "@amaster.ai/tts-client": "1.1.0-beta.3",
80
- "@amaster.ai/entity-client": "1.1.0-beta.3",
81
- "@amaster.ai/asr-http-client": "1.1.0-beta.3"
81
+ "@amaster.ai/workflow-client": "1.1.0-beta.3"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "axios": "^1.11.0"
@@ -10,6 +10,150 @@
10
10
 
11
11
  import type { ClientResult } from './common';
12
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
+
13
157
  /**
14
158
  * Text content in a message
15
159
  */
package/types/index.d.ts CHANGED
@@ -54,6 +54,10 @@ import type { AuthClientAPI } from './auth/index';
54
54
  import type { EntityClientAPI } from './entity';
55
55
  import type { BpmClientAPI } from './bpm';
56
56
  import type { WorkflowClientAPI } from './workflow';
57
+ import type { ASRClient } from './asr';
58
+ import type { CopilotA2UIClient } from './copilot';
59
+ import type { FunctionClient } from './function';
60
+ import type { TTSClient } from './tts';
57
61
 
58
62
  /**
59
63
  * Configuration options for creating an Amaster client
@@ -335,6 +339,54 @@ export interface AmasterClient {
335
339
  */
336
340
  workflow: WorkflowClientAPI;
337
341
 
342
+ /**
343
+ * ASR (Automatic Speech Recognition) module
344
+ *
345
+ * Provides methods for real-time speech-to-text conversion via WebSocket.
346
+ *
347
+ * For detailed documentation, see {@link ./asr.d.ts}
348
+ */
349
+ asr: ASRClient;
350
+
351
+ /**
352
+ * Copilot AI Assistant module
353
+ *
354
+ * Provides methods for interactive AI conversations with A2UI streaming.
355
+ *
356
+ * For detailed documentation, see {@link ./copilot.d.ts}
357
+ *
358
+ * @example
359
+ * Chat with AI:
360
+ * ```typescript
361
+ * const stream = client.copilot.chat([
362
+ * { role: 'user', content: 'Hello' }
363
+ * ]);
364
+ *
365
+ * for await (const messages of stream) {
366
+ * // Process A2UI messages
367
+ * }
368
+ * ```
369
+ */
370
+ copilot: CopilotA2UIClient;
371
+
372
+ /**
373
+ * Serverless Function module
374
+ *
375
+ * Provides methods for invoking serverless functions.
376
+ *
377
+ * For detailed documentation, see {@link ./function.d.ts}
378
+ */
379
+ function: FunctionClient;
380
+
381
+ /**
382
+ * TTS (Text-to-Speech) module
383
+ *
384
+ * Provides methods for real-time text-to-speech conversion via WebSocket.
385
+ *
386
+ * For detailed documentation, see {@link ./tts.d.ts}
387
+ */
388
+ tts: TTSClient;
389
+
338
390
  /**
339
391
  * Check if the user is currently authenticated
340
392
  *
@@ -491,9 +543,14 @@ export type { AuthClientAPI } from './auth';
491
543
  export type { EntityClientAPI } from './entity';
492
544
  export type { BpmClientAPI } from './bpm';
493
545
  export type { WorkflowClientAPI } from './workflow';
546
+ export type { ASRClient } from './asr';
547
+ export type { CopilotA2UIClient } from './copilot';
548
+ export type { FunctionClient } from './function';
549
+ export type { TTSClient } from './tts';
494
550
 
495
551
  // For detailed types, import directly from submodules:
496
552
  // import type { LoginParams, User } from '@amaster.ai/client/auth'
497
553
  // import type { EntityQueryParams } from '@amaster.ai/client/entity'
498
554
  // import type { Task, ProcessInstance } from '@amaster.ai/client/bpm'
499
555
  // import type { WorkflowRunRequest } from '@amaster.ai/client/workflow'
556
+ // import type { ServerToClientMessage } from '@amaster.ai/client/copilot'