@amaster.ai/client 1.1.0-beta.5 → 1.1.0-beta.51
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 +94 -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 +96 -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 +225 -180
- package/types/auth/code-auth.d.ts +5 -154
- 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 +47 -333
- package/types/entity.d.ts +65 -342
- package/types/function.d.ts +11 -88
- package/types/index.d.ts +113 -354
- package/types/s3.d.ts +96 -0
- package/types/tts.d.ts +10 -130
- package/types/workflow.d.ts +16 -165
- package/types/auth/permissions.d.ts +0 -254
package/types/s3.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @module s3
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ClientResult } from './common';
|
|
7
|
+
|
|
8
|
+
// ==================== Response Types ====================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Upload response data
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export interface UploadRes {
|
|
15
|
+
/** File key in storage */
|
|
16
|
+
key: string;
|
|
17
|
+
/** Full access URL */
|
|
18
|
+
url: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* File metadata
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export interface S3Metadata {
|
|
26
|
+
contentType?: string;
|
|
27
|
+
contentLength?: number;
|
|
28
|
+
lastModified?: string;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ==================== S3 Client API ====================
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* S3 Storage Client API
|
|
36
|
+
*
|
|
37
|
+
* Provides methods for uploading, downloading, and managing files in object storage.
|
|
38
|
+
*
|
|
39
|
+
* @since 1.0.0
|
|
40
|
+
*/
|
|
41
|
+
export interface S3ClientAPI {
|
|
42
|
+
/**
|
|
43
|
+
* Download a file
|
|
44
|
+
*
|
|
45
|
+
* @param filename - The name/key of the file to download
|
|
46
|
+
* @returns Blob data of the file
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
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);
|
|
53
|
+
* window.open(url);
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* @since 1.0.0
|
|
57
|
+
*/
|
|
58
|
+
download(filename: string): Promise<ClientResult<Blob>>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get metadata for a file
|
|
62
|
+
*
|
|
63
|
+
* @param key - The key of the file
|
|
64
|
+
* @returns File metadata
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
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
|
|
74
|
+
*/
|
|
75
|
+
getMetadata(key: string): Promise<ClientResult<S3Metadata>>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Upload a file
|
|
79
|
+
*
|
|
80
|
+
* @param file - The file to upload (File or Blob)
|
|
81
|
+
* @returns Upload result containing key and URL
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const fileInput = document.querySelector('input[type="file"]');
|
|
85
|
+
* const file = fileInput.files[0];
|
|
86
|
+
*
|
|
87
|
+
* const result = await client.s3.upload(file);
|
|
88
|
+
* if (result.success) {
|
|
89
|
+
* console.log('File uploaded:', result.data.url);
|
|
90
|
+
* console.log('File key:', result.data.key);
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* @since 1.0.0
|
|
94
|
+
*/
|
|
95
|
+
upload(file: File | Blob): Promise<ClientResult<UploadRes>>;
|
|
96
|
+
}
|
package/types/tts.d.ts
CHANGED
|
@@ -1,35 +1,14 @@
|
|
|
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
|
-
/** WebSocket path override */
|
|
32
|
-
path?: string;
|
|
33
12
|
|
|
34
13
|
/** Voice name, default 'Cherry' */
|
|
35
14
|
voice?: string;
|
|
@@ -63,75 +42,20 @@ export interface TTSClientConfig {
|
|
|
63
42
|
}
|
|
64
43
|
|
|
65
44
|
/**
|
|
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
|
-
* });
|
|
45
|
+
* TTS (Text-to-Speech) Client API
|
|
98
46
|
*
|
|
99
|
-
*
|
|
100
|
-
* await client.tts.speak('This is a test message');
|
|
101
|
-
* ```
|
|
47
|
+
* Provides real-time text-to-speech synthesis via WebSocket.
|
|
102
48
|
*
|
|
103
|
-
* @
|
|
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
|
-
* ```
|
|
49
|
+
* @since 1.0.0
|
|
121
50
|
*/
|
|
122
|
-
export interface
|
|
51
|
+
export interface TTSClientAPI {
|
|
123
52
|
/**
|
|
124
53
|
* Connect to TTS service
|
|
125
54
|
*
|
|
126
55
|
* Establishes WebSocket connection to the text-to-speech service.
|
|
127
56
|
*
|
|
128
57
|
* @returns Promise that resolves when connected
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```typescript
|
|
132
|
-
* await client.tts.connect();
|
|
133
|
-
* console.log('Connected to TTS service');
|
|
134
|
-
* ```
|
|
58
|
+
*
|
|
135
59
|
*/
|
|
136
60
|
connect(): Promise<void>;
|
|
137
61
|
|
|
@@ -142,37 +66,7 @@ export interface TTSClient {
|
|
|
142
66
|
*
|
|
143
67
|
* @param text - Text to synthesize
|
|
144
68
|
* @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
|
-
* ```
|
|
69
|
+
*
|
|
176
70
|
*/
|
|
177
71
|
speak(text: string): Promise<void>;
|
|
178
72
|
|
|
@@ -180,16 +74,7 @@ export interface TTSClient {
|
|
|
180
74
|
* Play audio from chunks
|
|
181
75
|
*
|
|
182
76
|
* 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
|
-
* ```
|
|
77
|
+
*
|
|
193
78
|
*/
|
|
194
79
|
play(): void;
|
|
195
80
|
|
|
@@ -197,12 +82,7 @@ export interface TTSClient {
|
|
|
197
82
|
* Close connection
|
|
198
83
|
*
|
|
199
84
|
* Closes the WebSocket connection and releases resources.
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```typescript
|
|
203
|
-
* // Cleanup when done
|
|
204
|
-
* client.tts.close();
|
|
205
|
-
* ```
|
|
85
|
+
*
|
|
206
86
|
*/
|
|
207
87
|
close(): void;
|
|
208
88
|
}
|
package/types/workflow.d.ts
CHANGED
|
@@ -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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* const result = await client.workflow.run('
|
|
263
|
-
*
|
|
264
|
-
*
|
|
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
|
-
*
|
|
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,
|