@amaster.ai/client 1.1.0-beta.30 → 1.1.0-beta.32

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/types/s3.d.ts CHANGED
@@ -1,14 +1,4 @@
1
1
  /**
2
- * ============================================================================
3
- * S3 Storage Module - Type Definitions
4
- * ============================================================================
5
- *
6
- * This module provides operations for interacting with S3-compatible object storage.
7
- *
8
- * ## Key Features
9
- * - File upload (multipart/form-data)
10
- * - File download
11
- * - Metadata retrieval
12
2
  *
13
3
  * @module s3
14
4
  */
@@ -19,14 +9,7 @@ import type { ClientResult } from './common';
19
9
 
20
10
  /**
21
11
  * Upload response data
22
- *
23
- * @example
24
- * ```typescript
25
- * {
26
- * key: "uploads/2024/image.png",
27
- * url: "https://cdn.example.com/uploads/2024/image.png"
28
- * }
29
- * ```
12
+ *
30
13
  */
31
14
  export interface UploadRes {
32
15
  /** File key in storage */
@@ -37,15 +20,7 @@ export interface UploadRes {
37
20
 
38
21
  /**
39
22
  * File metadata
40
- *
41
- * @example
42
- * ```typescript
43
- * {
44
- * contentType: "image/png",
45
- * contentLength: 1024,
46
- * lastModified: "2024-01-01T12:00:00Z"
47
- * }
48
- * ```
23
+ *
49
24
  */
50
25
  export interface S3Metadata {
51
26
  contentType?: string;
@@ -61,22 +36,9 @@ export interface S3Metadata {
61
36
  *
62
37
  * Provides methods for uploading, downloading, and managing files in object storage.
63
38
  *
64
- * @example
65
- * ```typescript
66
- * const client = createClient();
67
- *
68
- * // 1. Upload file
69
- * const uploadRes = await client.s3.upload(file);
70
- * console.log(uploadRes.data.url);
71
- *
72
- * // 2. Get metadata
73
- * const meta = await client.s3.getMetadata(uploadRes.data.key);
74
- *
75
- * // 3. Download file
76
- * const blob = await client.s3.download(uploadRes.data.key);
77
- * ```
39
+ * @since 1.0.0
78
40
  */
79
- export interface S3Client {
41
+ export interface S3ClientAPI {
80
42
  /**
81
43
  * Download a file
82
44
  *
@@ -84,13 +46,14 @@ export interface S3Client {
84
46
  * @returns Blob data of the file
85
47
  *
86
48
  * @example
87
- * ```typescript
88
- * const result = await client.s3.download('uploads/image.png');
89
- * if (result.data) {
90
- * const url = URL.createObjectURL(result.data);
49
+ * const result = await client.s3.download('documents/report.pdf');
50
+ * if (result.success) {
51
+ * const blob = result.data;
52
+ * const url = URL.createObjectURL(blob);
91
53
  * window.open(url);
92
54
  * }
93
- * ```
55
+ *
56
+ * @since 1.0.0
94
57
  */
95
58
  download(filename: string): Promise<ClientResult<Blob>>;
96
59
 
@@ -101,10 +64,13 @@ export interface S3Client {
101
64
  * @returns File metadata
102
65
  *
103
66
  * @example
104
- * ```typescript
105
- * const result = await client.s3.getMetadata('uploads/image.png');
106
- * console.log('Size:', result.data.contentLength);
107
- * ```
67
+ * const result = await client.s3.getMetadata('images/photo.jpg');
68
+ * if (result.success) {
69
+ * console.log('Size:', result.data.contentLength);
70
+ * console.log('Type:', result.data.contentType);
71
+ * }
72
+ *
73
+ * @since 1.0.0
108
74
  */
109
75
  getMetadata(key: string): Promise<ClientResult<S3Metadata>>;
110
76
 
@@ -115,13 +81,16 @@ export interface S3Client {
115
81
  * @returns Upload result containing key and URL
116
82
  *
117
83
  * @example
118
- * ```typescript
119
- * const file = event.target.files[0];
84
+ * const fileInput = document.querySelector('input[type="file"]');
85
+ * const file = fileInput.files[0];
86
+ *
120
87
  * const result = await client.s3.upload(file);
121
- * if (result.data) {
122
- * console.log('Uploaded to:', result.data.url);
88
+ * if (result.success) {
89
+ * console.log('File uploaded:', result.data.url);
90
+ * console.log('File key:', result.data.key);
123
91
  * }
124
- * ```
92
+ *
93
+ * @since 1.0.0
125
94
  */
126
95
  upload(file: File | Blob): Promise<ClientResult<UploadRes>>;
127
96
  }
package/types/tts.d.ts CHANGED
@@ -1,31 +1,12 @@
1
1
  /**
2
- * ============================================================================
3
- * TTS (Text-to-Speech) - Type Definitions
4
- * ============================================================================
5
- *
6
- * Real-time text-to-speech synthesis using WebSocket connection.
2
+ * * Real-time text-to-speech synthesis using WebSocket connection.
7
3
  *
8
4
  * @module tts
9
5
  */
10
6
 
11
7
  /**
12
8
  * TTS Client Configuration
13
- *
14
- * @example
15
- * Configure TTS with custom voice:
16
- * ```typescript
17
- * const client = createClient({ baseURL: 'https://api.amaster.ai' });
18
- *
19
- * // Reconfigure TTS client
20
- * client.tts = createTTSClient({
21
- * voice: 'Cherry',
22
- * audioFormat: 'pcm',
23
- * sampleRate: 24000,
24
- * autoPlay: true,
25
- * onAudioStart: () => console.log('Audio started'),
26
- * onAudioEnd: () => console.log('Audio ended')
27
- * });
28
- * ```
9
+ *
29
10
  */
30
11
  export interface TTSClientConfig {
31
12
  /** WebSocket path override */
@@ -63,75 +44,20 @@ export interface TTSClientConfig {
63
44
  }
64
45
 
65
46
  /**
66
- * TTS Client API
67
- *
68
- * Real-time text-to-speech synthesis client using WebSocket.
69
- *
70
- * @example
71
- * Basic usage:
72
- * ```typescript
73
- * const client = createClient({ baseURL: 'https://api.amaster.ai' });
74
- *
75
- * // Connect to TTS service
76
- * await client.tts.connect();
77
- *
78
- * // Synthesize and play speech
79
- * await client.tts.speak('Hello, welcome to Amaster!');
80
- *
81
- * // Close connection when done
82
- * client.tts.close();
83
- * ```
84
- *
85
- * @example
86
- * With custom voice and callbacks:
87
- * ```typescript
88
- * const client = createClient({ baseURL: 'https://api.amaster.ai' });
89
- *
90
- * client.tts = createTTSClient({
91
- * voice: 'Cherry',
92
- * autoPlay: true,
93
- * onReady: () => console.log('TTS ready'),
94
- * onAudioStart: () => console.log('Playing audio'),
95
- * onAudioEnd: () => console.log('Audio finished'),
96
- * onError: (error) => console.error('TTS error:', error)
97
- * });
47
+ * TTS (Text-to-Speech) Client API
98
48
  *
99
- * await client.tts.connect();
100
- * await client.tts.speak('This is a test message');
101
- * ```
49
+ * Provides real-time text-to-speech synthesis via WebSocket.
102
50
  *
103
- * @example
104
- * Manual audio playback:
105
- * ```typescript
106
- * const client = createClient({ baseURL: 'https://api.amaster.ai' });
107
- *
108
- * client.tts = createTTSClient({
109
- * autoPlay: false,
110
- * onAudioChunk: (chunks) => {
111
- * console.log(`Received ${chunks.length} audio chunks`);
112
- * }
113
- * });
114
- *
115
- * await client.tts.connect();
116
- * await client.tts.speak('Hello world');
117
- *
118
- * // Manually play collected audio
119
- * client.tts.play();
120
- * ```
51
+ * @since 1.0.0
121
52
  */
122
- export interface TTSClient {
53
+ export interface TTSClientAPI {
123
54
  /**
124
55
  * Connect to TTS service
125
56
  *
126
57
  * Establishes WebSocket connection to the text-to-speech service.
127
58
  *
128
59
  * @returns Promise that resolves when connected
129
- *
130
- * @example
131
- * ```typescript
132
- * await client.tts.connect();
133
- * console.log('Connected to TTS service');
134
- * ```
60
+ *
135
61
  */
136
62
  connect(): Promise<void>;
137
63
 
@@ -142,37 +68,7 @@ export interface TTSClient {
142
68
  *
143
69
  * @param text - Text to synthesize
144
70
  * @returns Promise that resolves when synthesis starts
145
- *
146
- * @example
147
- * Simple text:
148
- * ```typescript
149
- * await client.tts.speak('Hello, how can I help you today?');
150
- * ```
151
- *
152
- * @example
153
- * Multiple sentences:
154
- * ```typescript
155
- * await client.tts.speak(
156
- * 'Welcome to our service. ' +
157
- * 'We are glad to have you here. ' +
158
- * 'Let me know if you need any assistance.'
159
- * );
160
- * ```
161
- *
162
- * @example
163
- * Sequential playback:
164
- * ```typescript
165
- * await client.tts.speak('First message');
166
- * // Wait for first message to complete
167
- * await new Promise(resolve => {
168
- * const originalOnEnd = client.tts.onAudioEnd;
169
- * client.tts.onAudioEnd = () => {
170
- * resolve(undefined);
171
- * client.tts.onAudioEnd = originalOnEnd;
172
- * };
173
- * });
174
- * await client.tts.speak('Second message');
175
- * ```
71
+ *
176
72
  */
177
73
  speak(text: string): Promise<void>;
178
74
 
@@ -180,16 +76,7 @@ export interface TTSClient {
180
76
  * Play audio from chunks
181
77
  *
182
78
  * Manually plays audio chunks when autoPlay is disabled.
183
- *
184
- * @example
185
- * ```typescript
186
- * client.tts = createTTSClient({ autoPlay: false });
187
- * await client.tts.connect();
188
- * await client.tts.speak('Hello world');
189
- *
190
- * // Manually trigger playback
191
- * client.tts.play();
192
- * ```
79
+ *
193
80
  */
194
81
  play(): void;
195
82
 
@@ -197,12 +84,7 @@ export interface TTSClient {
197
84
  * Close connection
198
85
  *
199
86
  * Closes the WebSocket connection and releases resources.
200
- *
201
- * @example
202
- * ```typescript
203
- * // Cleanup when done
204
- * client.tts.close();
205
- * ```
87
+ *
206
88
  */
207
89
  close(): void;
208
90
  }
@@ -1,17 +1,4 @@
1
1
  /**
2
- * ============================================================================
3
- * Workflow Module - Type Definitions
4
- * ============================================================================
5
- *
6
- * This module provides workflow execution capabilities using Dify-style
7
- * workflow engine.
8
- *
9
- * ## Key Features
10
- * - Execute workflows with inputs
11
- * - Blocking or streaming execution modes
12
- * - File upload support
13
- * - Trace ID for debugging
14
- * - Auto-inject app_id from URL
15
2
  *
16
3
  * @module workflow
17
4
  */
@@ -39,15 +26,7 @@ export type WorkflowInputValue =
39
26
 
40
27
  /**
41
28
  * Workflow file attachment
42
- *
43
- * @example
44
- * ```typescript
45
- * const file: WorkflowFile = {
46
- * name: 'document.pdf',
47
- * type: 'application/pdf',
48
- * url: 'https://cdn.example.com/document.pdf'
49
- * };
50
- * ```
29
+ *
51
30
  */
52
31
  export interface WorkflowFile {
53
32
  /** File name */
@@ -63,31 +42,7 @@ export interface WorkflowFile {
63
42
  /**
64
43
  * Workflow execution request parameters
65
44
  *
66
- * @example
67
- * Simple execution:
68
- * ```typescript
69
- * const request: WorkflowRunRequest = {
70
- * inputs: {
71
- * query: 'What is the weather?',
72
- * location: 'New York'
73
- * }
74
- * };
75
- * ```
76
- *
77
- * @example
78
- * With files:
79
- * ```typescript
80
- * const request: WorkflowRunRequest = {
81
- * inputs: { action: 'analyze' },
82
- * files: [{
83
- * name: 'data.csv',
84
- * type: 'text/csv',
85
- * url: 'https://example.com/data.csv'
86
- * }],
87
- * user: 'user-123',
88
- * trace_id: 'trace-abc-456'
89
- * };
90
- * ```
45
+ * @since 1.0.0
91
46
  */
92
47
  export interface WorkflowRunRequest {
93
48
  /** Input variables for the workflow */
@@ -112,22 +67,7 @@ export interface WorkflowRunRequest {
112
67
  * Workflow execution response
113
68
  *
114
69
  * @template TOutput - The type of workflow outputs
115
- *
116
- * @example
117
- * ```typescript
118
- * interface AnalysisOutput {
119
- * summary: string;
120
- * sentiment: 'positive' | 'negative' | 'neutral';
121
- * keywords: string[];
122
- * }
123
- *
124
- * const result = await client.workflow.run<AnalysisOutput>('text-analysis', {
125
- * text: 'This is a great product!'
126
- * });
127
- *
128
- * console.log(result.data.outputs.summary);
129
- * console.log(result.data.outputs.sentiment); // 'positive'
130
- * ```
70
+ *
131
71
  */
132
72
  export interface WorkflowRunResponse<TOutput = Record<string, unknown>> {
133
73
  /** Task ID */
@@ -136,7 +76,6 @@ export interface WorkflowRunResponse<TOutput = Record<string, unknown>> {
136
76
  workflow_run_id: string;
137
77
  /**
138
78
  * Execution status
139
- * @example 'succeeded', 'failed', 'running'
140
79
  */
141
80
  status: string;
142
81
  /** Workflow output data */
@@ -162,38 +101,7 @@ export interface WorkflowRunResponse<TOutput = Record<string, unknown>> {
162
101
  *
163
102
  * Provides methods for executing Dify-style workflows.
164
103
  *
165
- * @example
166
- * Complete workflow execution:
167
- * ```typescript
168
- * const client = createClient({ baseURL: 'https://api.amaster.ai' });
169
- *
170
- * // 1. Simple text processing workflow
171
- * const result = await client.workflow.run('text-summarizer', {
172
- * text: 'Long article content here...',
173
- * max_words: 100
174
- * });
175
- *
176
- * if (result.data) {
177
- * console.log('Summary:', result.data.outputs.summary);
178
- * console.log('Time taken:', result.data.elapsed_time, 'ms');
179
- * console.log('Tokens used:', result.data.total_tokens);
180
- * }
181
- *
182
- * // 2. Data analysis workflow with type safety
183
- * interface AnalysisOutput {
184
- * insights: string[];
185
- * score: number;
186
- * recommendations: string[];
187
- * }
188
- *
189
- * const analysis = await client.workflow.run<AnalysisOutput>('data-analyzer', {
190
- * dataset: 'sales-2024',
191
- * metric: 'revenue'
192
- * });
193
- *
194
- * console.log('Insights:', analysis.data.outputs.insights);
195
- * console.log('Score:', analysis.data.outputs.score);
196
- * ```
104
+ * @since 1.0.0
197
105
  */
198
106
  export interface WorkflowClientAPI {
199
107
  /**
@@ -208,81 +116,24 @@ export interface WorkflowClientAPI {
208
116
  * @returns Workflow execution result
209
117
  *
210
118
  * @example
211
- * Simple execution with inputs:
212
- * ```typescript
213
- * const result = await client.workflow.run('greeting', {
214
- * name: 'Alice',
215
- * language: 'en'
119
+ * // Simple execution
120
+ * const result = await client.workflow.run('data-processor', {
121
+ * source: 'users',
122
+ * limit: 100
216
123
  * });
217
124
  *
218
- * console.log(result.data.outputs.message); // "Hello, Alice!"
219
- * ```
220
- *
221
- * @example
222
- * With full request configuration:
223
- * ```typescript
224
- * const result = await client.workflow.run('document-processor', {
225
- * inputs: {
226
- * action: 'extract',
227
- * format: 'json'
228
- * },
229
- * files: [{
230
- * name: 'invoice.pdf',
231
- * url: 'https://example.com/invoice.pdf'
232
- * }],
233
- * user: 'user-123',
234
- * trace_id: 'req-abc-456'
235
- * });
236
- * ```
237
- *
238
- * @example
239
- * Type-safe outputs:
240
- * ```typescript
241
- * interface SentimentOutput {
242
- * sentiment: 'positive' | 'negative' | 'neutral';
243
- * confidence: number;
244
- * keywords: string[];
245
- * }
246
- *
247
- * const result = await client.workflow.run<SentimentOutput>('sentiment-analysis', {
248
- * text: 'I love this product! It works great.'
249
- * });
250
- *
251
- * if (result.data) {
252
- * // TypeScript knows the structure of outputs
253
- * console.log(result.data.outputs.sentiment); // Type: 'positive' | 'negative' | 'neutral'
254
- * console.log(result.data.outputs.confidence); // Type: number
255
- * console.log(result.data.outputs.keywords); // Type: string[]
125
+ * if (result.success) {
126
+ * console.log('Output:', result.data.outputs);
256
127
  * }
257
- * ```
258
128
  *
259
129
  * @example
260
- * Error handling:
261
- * ```typescript
262
- * const result = await client.workflow.run('risky-workflow', { input: 'test' });
263
- *
264
- * if (result.error) {
265
- * console.error('Workflow failed:', result.error.message);
266
- * } else if (result.data.error) {
267
- * console.error('Workflow error:', result.data.error);
268
- * } else {
269
- * console.log('Success:', result.data.outputs);
270
- * }
271
- * ```
272
- *
273
- * @example
274
- * Performance monitoring:
275
- * ```typescript
276
- * const startTime = Date.now();
277
- * const result = await client.workflow.run('heavy-task', { data: largeDataset });
130
+ * // With type safety
131
+ * type Output = { processedCount: number; results: string[] };
132
+ * const result = await client.workflow.run<Output>('batch-processor', {
133
+ * batchSize: 50
134
+ * });
278
135
  *
279
- * if (result.data) {
280
- * console.log(`Network time: ${Date.now() - startTime}ms`);
281
- * console.log(`Execution time: ${result.data.elapsed_time}ms`);
282
- * console.log(`Steps: ${result.data.total_steps}`);
283
- * console.log(`Tokens: ${result.data.total_tokens}`);
284
- * }
285
- * ```
136
+ * @since 1.0.0
286
137
  */
287
138
  run<TOutput = Record<string, unknown>>(
288
139
  workflowName: string,