@amaster.ai/client 1.1.0-beta.50 → 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/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +11 -11
- package/types/asr.d.ts +202 -79
- package/types/index.d.ts +75 -66
package/dist/index.d.cts
CHANGED
|
@@ -7,7 +7,7 @@ export { ActivityInstanceTree, CamundaVariable, HistoryActivityInstance, History
|
|
|
7
7
|
import { WorkflowClient } from '@amaster.ai/workflow-client';
|
|
8
8
|
export { WorkflowFile, WorkflowInputValue, WorkflowRunRequest, WorkflowRunResponse } from '@amaster.ai/workflow-client';
|
|
9
9
|
import { ASRClientConfig, ASRClient, ASRHttpClientConfig, ASRHttpClient } from '@amaster.ai/asr-client';
|
|
10
|
-
export { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig } from '@amaster.ai/asr-client';
|
|
10
|
+
export { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig, ASRLanguage } from '@amaster.ai/asr-client';
|
|
11
11
|
import { CopilotClient } from '@amaster.ai/copilot-client';
|
|
12
12
|
export { ChatMessage, ChatOptions, CopilotClient, FileContent, ImageContent, MessageContent, TextContent } from '@amaster.ai/copilot-client';
|
|
13
13
|
import { FunctionClient } from '@amaster.ai/function-client';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { ActivityInstanceTree, CamundaVariable, HistoryActivityInstance, History
|
|
|
7
7
|
import { WorkflowClient } from '@amaster.ai/workflow-client';
|
|
8
8
|
export { WorkflowFile, WorkflowInputValue, WorkflowRunRequest, WorkflowRunResponse } from '@amaster.ai/workflow-client';
|
|
9
9
|
import { ASRClientConfig, ASRClient, ASRHttpClientConfig, ASRHttpClient } from '@amaster.ai/asr-client';
|
|
10
|
-
export { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig } from '@amaster.ai/asr-client';
|
|
10
|
+
export { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig, ASRLanguage } from '@amaster.ai/asr-client';
|
|
11
11
|
import { CopilotClient } from '@amaster.ai/copilot-client';
|
|
12
12
|
export { ChatMessage, ChatOptions, CopilotClient, FileContent, ImageContent, MessageContent, TextContent } from '@amaster.ai/copilot-client';
|
|
13
13
|
import { FunctionClient } from '@amaster.ai/function-client';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amaster.ai/client",
|
|
3
|
-
"version": "1.1.0-beta.
|
|
3
|
+
"version": "1.1.0-beta.51",
|
|
4
4
|
"description": "Unified API client for Amaster platform - All services in one package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"registry": "https://registry.npmjs.org/"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@amaster.ai/
|
|
76
|
-
"@amaster.ai/
|
|
77
|
-
"@amaster.ai/
|
|
78
|
-
"@amaster.ai/
|
|
79
|
-
"@amaster.ai/
|
|
80
|
-
"@amaster.ai/http-client": "1.1.0-beta.
|
|
81
|
-
"@amaster.ai/
|
|
82
|
-
"@amaster.ai/
|
|
83
|
-
"@amaster.ai/
|
|
84
|
-
"@amaster.ai/
|
|
75
|
+
"@amaster.ai/copilot-client": "1.1.0-beta.51",
|
|
76
|
+
"@amaster.ai/auth-client": "1.1.0-beta.51",
|
|
77
|
+
"@amaster.ai/bpm-client": "1.1.0-beta.51",
|
|
78
|
+
"@amaster.ai/asr-client": "1.1.0-beta.51",
|
|
79
|
+
"@amaster.ai/s3-client": "1.1.0-beta.51",
|
|
80
|
+
"@amaster.ai/http-client": "1.1.0-beta.51",
|
|
81
|
+
"@amaster.ai/function-client": "1.1.0-beta.51",
|
|
82
|
+
"@amaster.ai/tts-client": "1.1.0-beta.51",
|
|
83
|
+
"@amaster.ai/workflow-client": "1.1.0-beta.51",
|
|
84
|
+
"@amaster.ai/entity-client": "1.1.0-beta.51"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"axios": "^1.11.0"
|
package/types/asr.d.ts
CHANGED
|
@@ -1,88 +1,211 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* ASR Client Configuration
|
|
2
|
+
* ASR Realtime WebSocket Client for Qwen-ASR Realtime API
|
|
3
|
+
*
|
|
4
|
+
* WebSocket-based real-time speech recognition for streaming transcription.
|
|
5
|
+
* Follows the Qwen-ASR Realtime API protocol with proper event handling.
|
|
9
6
|
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const asrClient = client.asr({
|
|
10
|
+
* language: "zh",
|
|
11
|
+
* enableVAD: true,
|
|
12
|
+
* onReady() {
|
|
13
|
+
* console.log("ASR connected");
|
|
14
|
+
* },
|
|
15
|
+
* onTranscript(text, isFinal) {
|
|
16
|
+
* console.log(isFinal ? "[Final]" : "[Interim]", text);
|
|
17
|
+
* },
|
|
18
|
+
* onError(err) {
|
|
19
|
+
* console.error("ASR error:", err);
|
|
20
|
+
* },
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* await asrClient.connect();
|
|
24
|
+
* await asrClient.startRecording();
|
|
25
|
+
* // ... stop ...
|
|
26
|
+
* await asrClient.stopRecording();
|
|
27
|
+
* await asrClient.close();
|
|
28
|
+
* ```
|
|
10
29
|
*/
|
|
30
|
+
export type ASRLanguage = "zh" | "yue" | "en" | "ja" | "de" | "ko" | "ru" | "fr" | "pt" | "ar" | "it" | "es" | "hi" | "id" | "th" | "tr" | "uk" | "vi" | "cs" | "da" | "fil" | "fi" | "is" | "ms" | "no" | "pl" | "sv";
|
|
31
|
+
export type ClientEventType = "session.update" | "input_audio_buffer.append" | "input_audio_buffer.commit" | "session.finish";
|
|
32
|
+
export type ServerEventType = "session.created" | "session.updated" | "input_audio_buffer.speech_started" | "input_audio_buffer.speech_stopped" | "input_audio_buffer.committed" | "conversation.item.input_audio_transcription.text" | "conversation.item.input_audio_transcription.completed" | "session.finished" | "error";
|
|
33
|
+
export interface BaseEvent {
|
|
34
|
+
event_id: string;
|
|
35
|
+
type: ClientEventType | ServerEventType;
|
|
36
|
+
}
|
|
37
|
+
export interface SessionUpdateEvent extends BaseEvent {
|
|
38
|
+
type: "session.update";
|
|
39
|
+
session: SessionConfig;
|
|
40
|
+
}
|
|
41
|
+
export interface InputAudioBufferAppendEvent extends BaseEvent {
|
|
42
|
+
type: "input_audio_buffer.append";
|
|
43
|
+
audio: string;
|
|
44
|
+
}
|
|
45
|
+
export interface InputAudioBufferCommitEvent extends BaseEvent {
|
|
46
|
+
type: "input_audio_buffer.commit";
|
|
47
|
+
}
|
|
48
|
+
export interface SessionFinishEvent extends BaseEvent {
|
|
49
|
+
type: "session.finish";
|
|
50
|
+
}
|
|
51
|
+
type ClientEvent = SessionUpdateEvent | InputAudioBufferAppendEvent | InputAudioBufferCommitEvent | SessionFinishEvent;
|
|
52
|
+
export interface SessionCreatedEvent extends BaseEvent {
|
|
53
|
+
type: "session.created";
|
|
54
|
+
session: {
|
|
55
|
+
id: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface SessionUpdatedEvent extends BaseEvent {
|
|
59
|
+
type: "session.updated";
|
|
60
|
+
session: SessionConfig;
|
|
61
|
+
}
|
|
62
|
+
export interface SpeechStartedEvent extends BaseEvent {
|
|
63
|
+
type: "input_audio_buffer.speech_started";
|
|
64
|
+
}
|
|
65
|
+
export interface SpeechStoppedEvent extends BaseEvent {
|
|
66
|
+
type: "input_audio_buffer.speech_stopped";
|
|
67
|
+
}
|
|
68
|
+
export interface InputAudioBufferCommittedEvent extends BaseEvent {
|
|
69
|
+
type: "input_audio_buffer.committed";
|
|
70
|
+
}
|
|
71
|
+
export interface TranscriptionTextEvent extends BaseEvent {
|
|
72
|
+
type: "conversation.item.input_audio_transcription.text";
|
|
73
|
+
text?: string;
|
|
74
|
+
stash?: string;
|
|
75
|
+
transcript?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface TranscriptionCompletedEvent extends BaseEvent {
|
|
78
|
+
type: "conversation.item.input_audio_transcription.completed";
|
|
79
|
+
text?: string;
|
|
80
|
+
transcript?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface SessionFinishedEvent extends BaseEvent {
|
|
83
|
+
type: "session.finished";
|
|
84
|
+
}
|
|
85
|
+
export interface ErrorEvent extends BaseEvent {
|
|
86
|
+
type: "error";
|
|
87
|
+
error: {
|
|
88
|
+
message: string;
|
|
89
|
+
code?: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export type ServerEvent = SessionCreatedEvent | SessionUpdatedEvent | SpeechStartedEvent | SpeechStoppedEvent | InputAudioBufferCommittedEvent | TranscriptionTextEvent | TranscriptionCompletedEvent | SessionFinishedEvent | ErrorEvent;
|
|
93
|
+
export interface TurnDetectionConfig {
|
|
94
|
+
type: "server_vad";
|
|
95
|
+
/** VAD检测阈值,推荐设为 0.0,默认值 0.2,范围 [-1, 1] */
|
|
96
|
+
threshold?: number;
|
|
97
|
+
/** VAD断句检测阈值(ms),推荐设为 400,默认值 800,范围 [200, 6000] */
|
|
98
|
+
silence_duration_ms?: number;
|
|
99
|
+
}
|
|
100
|
+
export interface InputAudioTranscriptionConfig {
|
|
101
|
+
language?: ASRLanguage;
|
|
102
|
+
}
|
|
103
|
+
export interface SessionConfig {
|
|
104
|
+
input_audio_format?: "pcm" | "opus";
|
|
105
|
+
sample_rate?: 16000 | 8000;
|
|
106
|
+
input_audio_transcription?: InputAudioTranscriptionConfig;
|
|
107
|
+
turn_detection?: TurnDetectionConfig | null;
|
|
108
|
+
}
|
|
11
109
|
export interface ASRClientConfig {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Audio format
|
|
112
|
+
* @default "pcm"
|
|
113
|
+
*/
|
|
114
|
+
audioFormat?: "pcm" | "opus";
|
|
115
|
+
/**
|
|
116
|
+
* Sample rate in Hz
|
|
117
|
+
* @default 16000
|
|
118
|
+
* @description 支持 16000 和 8000。设置为 8000 时,服务端会先升采样到16000Hz再进行识别,可能引入微小延迟。
|
|
119
|
+
*/
|
|
120
|
+
sampleRate?: 16000 | 8000;
|
|
121
|
+
/**
|
|
122
|
+
* Audio source language
|
|
123
|
+
* @default "zh"
|
|
124
|
+
* @description 支持多种语言,包括 zh(中文)、yue(粤语)、en(英文)、ja(日语)等
|
|
125
|
+
*/
|
|
126
|
+
language?: ASRLanguage;
|
|
127
|
+
/**
|
|
128
|
+
* Enable VAD (Voice Activity Detection) mode
|
|
129
|
+
* @default true
|
|
130
|
+
* @description true = VAD模式(服务端自动检测语音开始/结束),false = Manual模式(客户端手动控制)
|
|
131
|
+
*/
|
|
132
|
+
enableVAD?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* VAD detection threshold
|
|
135
|
+
* @default 0.2
|
|
136
|
+
* @description 推荐设为 0.0。取值范围 [-1, 1]。较低的阈值会提高 VAD 的灵敏度。
|
|
137
|
+
*/
|
|
138
|
+
vadThreshold?: number;
|
|
139
|
+
/**
|
|
140
|
+
* VAD silence duration threshold in milliseconds
|
|
141
|
+
* @default 800
|
|
142
|
+
* @description 推荐设为 400。取值范围 [200, 6000]。静音持续时长超过该阈值将被认为是语句结束。
|
|
143
|
+
*/
|
|
144
|
+
vadSilenceDurationMs?: number;
|
|
145
|
+
/**
|
|
146
|
+
* Get access token for WebSocket authentication
|
|
147
|
+
*/
|
|
148
|
+
getAccessToken?: () => string | null;
|
|
149
|
+
/**
|
|
150
|
+
* Called when connection is ready (session.created received and session.update sent)
|
|
151
|
+
*/
|
|
152
|
+
onReady?: () => void;
|
|
153
|
+
/**
|
|
154
|
+
* Called when speech is detected (VAD mode only)
|
|
155
|
+
*/
|
|
156
|
+
onSpeechStart?: () => void;
|
|
157
|
+
/**
|
|
158
|
+
* Called when speech stops (VAD mode only)
|
|
159
|
+
*/
|
|
160
|
+
onSpeechEnd?: () => void;
|
|
161
|
+
/**
|
|
162
|
+
* Called on transcript result
|
|
163
|
+
* @param text - Transcribed text
|
|
164
|
+
* @param isFinal - Whether this is the final result
|
|
165
|
+
*/
|
|
166
|
+
onTranscript?: (text: string, isFinal: boolean) => void;
|
|
167
|
+
/**
|
|
168
|
+
* Called when audio buffer is committed (non-VAD mode only)
|
|
169
|
+
*/
|
|
170
|
+
onAudioBufferCommitted?: () => void;
|
|
171
|
+
/**
|
|
172
|
+
* Called when session is finished
|
|
173
|
+
*/
|
|
174
|
+
onSessionFinished?: () => void;
|
|
175
|
+
/**
|
|
176
|
+
* Called on error
|
|
177
|
+
*/
|
|
178
|
+
onError?: (error: Error) => void;
|
|
179
|
+
/**
|
|
180
|
+
* Called on close
|
|
181
|
+
*/
|
|
182
|
+
onClose?: () => void;
|
|
39
183
|
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* Requires microphone permission from the user.
|
|
64
|
-
*
|
|
65
|
-
* @returns Promise that resolves when recording starts
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
startRecording(): Promise<void>;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Stop recording
|
|
72
|
-
*
|
|
73
|
-
* Stops capturing audio from the microphone but keeps the WebSocket connection open.
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
stopRecording(): void;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Close connection
|
|
80
|
-
*
|
|
81
|
-
* Closes the WebSocket connection and releases resources.
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
close(): void;
|
|
184
|
+
export interface ASRClient {
|
|
185
|
+
/** Connect to ASR service and establish session */
|
|
186
|
+
connect(): Promise<void>;
|
|
187
|
+
/** Start recording from microphone */
|
|
188
|
+
startRecording(): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* Stop recording
|
|
191
|
+
* @description In non-VAD mode, this triggers recognition by sending input_audio_buffer.commit
|
|
192
|
+
*/
|
|
193
|
+
stopRecording(): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Close connection gracefully
|
|
196
|
+
* @description Sends session.finish and waits for session.finished before closing
|
|
197
|
+
*/
|
|
198
|
+
close(): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Check if currently recording
|
|
201
|
+
*/
|
|
202
|
+
isRecording(): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Check if connected to server
|
|
205
|
+
*/
|
|
206
|
+
isConnected(): boolean;
|
|
85
207
|
}
|
|
208
|
+
declare const _default$1: (authConfig: Pick<ASRClientConfig, "getAccessToken">) => (config: ASRClientConfig) => ASRClient;
|
|
86
209
|
|
|
87
210
|
export interface ASRHttpClientConfig {
|
|
88
211
|
/** Get access token */
|
package/types/index.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* * A Supabase-inspired unified client for the Amaster platform.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* ## Features
|
|
5
5
|
* - Single client instance for all services (auth, entity, bpm, workflow)
|
|
6
6
|
* - Automatic token management and refresh
|
|
7
7
|
* - Auto-attach authentication to all requests
|
|
8
8
|
* - Centralized error handling
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
* ## Quick Start
|
|
11
11
|
* ```typescript
|
|
12
12
|
* import { createClient } from '@amaster.ai/client';
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
14
|
* const client = createClient({
|
|
15
15
|
* baseURL: 'https://api.amaster.ai',
|
|
16
16
|
* onUnauthorized: () => window.location.href = '/login'
|
|
17
17
|
* });
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
19
|
* // Login
|
|
20
20
|
* await client.auth.login({ email, password });
|
|
21
|
-
*
|
|
21
|
+
*
|
|
22
22
|
* // All subsequent requests automatically include auth token
|
|
23
23
|
* await client.entity.list('default', 'users');
|
|
24
24
|
* await client.bpm.startProcess('approval', {});
|
|
25
25
|
* ```
|
|
26
|
-
*
|
|
26
|
+
*
|
|
27
27
|
* ## Module Documentation
|
|
28
28
|
* For detailed API documentation, see individual module type definitions:
|
|
29
29
|
* - **Authentication**: {@link ./auth/index.d.ts} (split into user, password-auth, code-auth, oauth, permissions, profile)
|
|
30
30
|
* - **Entity Operations**: {@link ./entity.d.ts}
|
|
31
31
|
* - **BPM (Business Process)**: {@link ./bpm.d.ts}
|
|
32
32
|
* - **Workflow Execution**: {@link ./workflow.d.ts}
|
|
33
|
-
*
|
|
33
|
+
*
|
|
34
34
|
* ## AI-Friendly Type Structure
|
|
35
35
|
* This package provides modular type definitions optimized for AI tools and large language models.
|
|
36
36
|
* Types are split into focused modules that can be loaded on-demand:
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* **Authentication Types** (70-88% token savings):
|
|
39
39
|
* - `@amaster.ai/client/auth/user` - User types (100 lines)
|
|
40
40
|
* - `@amaster.ai/client/auth/password-auth` - Login/register (200 lines)
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
* - `@amaster.ai/client/auth/profile` - Profile management (100 lines)
|
|
45
45
|
* */
|
|
46
46
|
|
|
47
|
-
import type { AuthClientAPI } from
|
|
48
|
-
import type { EntityClientAPI } from
|
|
49
|
-
import type { BpmClientAPI } from
|
|
50
|
-
import type { WorkflowClientAPI } from
|
|
51
|
-
import type {
|
|
52
|
-
import type { CopilotClientAPI } from
|
|
53
|
-
import type { FunctionClientAPI } from
|
|
54
|
-
import type { TTSClientAPI } from
|
|
55
|
-
import type { S3ClientAPI } from
|
|
47
|
+
import type { AuthClientAPI } from "./auth/index";
|
|
48
|
+
import type { EntityClientAPI } from "./entity";
|
|
49
|
+
import type { BpmClientAPI } from "./bpm";
|
|
50
|
+
import type { WorkflowClientAPI } from "./workflow";
|
|
51
|
+
import type { ASRClientConfig, ASRClient, ASRHttpClientConfig, ASRHttpClient } from "./asr";
|
|
52
|
+
import type { CopilotClientAPI } from "./copilot";
|
|
53
|
+
import type { FunctionClientAPI } from "./function";
|
|
54
|
+
import type { TTSClientAPI } from "./tts";
|
|
55
|
+
import type { S3ClientAPI } from "./s3";
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Configuration options for creating an Amaster client
|
|
@@ -67,7 +67,7 @@ export interface AmasterClientOptions {
|
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Optional custom headers to include in ALL requests
|
|
70
|
-
*
|
|
70
|
+
*
|
|
71
71
|
* These headers will be merged with authentication headers.
|
|
72
72
|
* Useful for tenant IDs, API keys, or application metadata.
|
|
73
73
|
*
|
|
@@ -76,7 +76,7 @@ export interface AmasterClientOptions {
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Callback triggered when a 401 Unauthorized response is received
|
|
79
|
-
*
|
|
79
|
+
*
|
|
80
80
|
* Use this to redirect to login page or show authentication modal.
|
|
81
81
|
* This callback is invoked BEFORE the request promise rejects.
|
|
82
82
|
*
|
|
@@ -85,7 +85,7 @@ export interface AmasterClientOptions {
|
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Callback triggered when the access token expires
|
|
88
|
-
*
|
|
88
|
+
*
|
|
89
89
|
* Note: Token refresh is handled automatically by the client.
|
|
90
90
|
* This callback is for additional actions like logging or analytics.
|
|
91
91
|
*
|
|
@@ -94,31 +94,31 @@ export interface AmasterClientOptions {
|
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Enable automatic token refresh (default: true)
|
|
97
|
-
*
|
|
97
|
+
*
|
|
98
98
|
* When enabled, tokens are automatically refreshed before expiry.
|
|
99
|
-
*
|
|
99
|
+
*
|
|
100
100
|
* @default true
|
|
101
101
|
*/
|
|
102
102
|
autoRefresh?: boolean;
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Token refresh threshold in seconds (default: 300)
|
|
106
|
-
*
|
|
106
|
+
*
|
|
107
107
|
* Tokens will be refreshed this many seconds before expiry.
|
|
108
108
|
* For example, if set to 300 (5 minutes), a token expiring at
|
|
109
109
|
* 10:00:00 will be refreshed at 9:55:00.
|
|
110
|
-
*
|
|
110
|
+
*
|
|
111
111
|
* @default 300
|
|
112
112
|
*/
|
|
113
113
|
refreshThreshold?: number;
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* Auto-handle OAuth callback on page load (default: true)
|
|
117
|
-
*
|
|
117
|
+
*
|
|
118
118
|
* Automatically detects and processes `#access_token` in URL hash,
|
|
119
119
|
* then clears the hash for security. Set to `false` to manually
|
|
120
120
|
* call `client.auth.handleOAuthCallback()`.
|
|
121
|
-
*
|
|
121
|
+
*
|
|
122
122
|
* @default true
|
|
123
123
|
*/
|
|
124
124
|
autoHandleOAuthCallback?: boolean;
|
|
@@ -126,16 +126,16 @@ export interface AmasterClientOptions {
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* Unified Amaster Client interface
|
|
129
|
-
*
|
|
129
|
+
*
|
|
130
130
|
* This is the main client object returned by `createClient()`.
|
|
131
131
|
* It provides access to all Amaster services through a unified interface.
|
|
132
|
-
*
|
|
132
|
+
*
|
|
133
133
|
* ## Core Modules
|
|
134
134
|
* - {@link auth} - Authentication and user management
|
|
135
135
|
* - {@link entity} - CRUD operations for entities
|
|
136
136
|
* - {@link bpm} - Business process management
|
|
137
137
|
* - {@link workflow} - Workflow execution
|
|
138
|
-
*
|
|
138
|
+
*
|
|
139
139
|
* ## Token Management
|
|
140
140
|
* - {@link isAuthenticated} - Check if user is authenticated
|
|
141
141
|
* - {@link getAccessToken} - Get current access token
|
|
@@ -146,9 +146,9 @@ export interface AmasterClientOptions {
|
|
|
146
146
|
export interface AmasterClient {
|
|
147
147
|
/**
|
|
148
148
|
* Authentication module
|
|
149
|
-
*
|
|
149
|
+
*
|
|
150
150
|
* Provides methods for user authentication, registration, and management.
|
|
151
|
-
*
|
|
151
|
+
*
|
|
152
152
|
* For detailed documentation, see {@link ./auth.d.ts}
|
|
153
153
|
*
|
|
154
154
|
*/
|
|
@@ -156,9 +156,9 @@ export interface AmasterClient {
|
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* Entity CRUD operations module
|
|
159
|
-
*
|
|
159
|
+
*
|
|
160
160
|
* Provides methods for creating, reading, updating, and deleting entities.
|
|
161
|
-
*
|
|
161
|
+
*
|
|
162
162
|
* For detailed documentation, see {@link ./entity.d.ts}
|
|
163
163
|
*
|
|
164
164
|
*/
|
|
@@ -166,9 +166,9 @@ export interface AmasterClient {
|
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* Business Process Management (BPM) module
|
|
169
|
-
*
|
|
169
|
+
*
|
|
170
170
|
* Provides methods for managing BPMN processes and tasks.
|
|
171
|
-
*
|
|
171
|
+
*
|
|
172
172
|
* For detailed documentation, see {@link ./bpm.d.ts}
|
|
173
173
|
*
|
|
174
174
|
*/
|
|
@@ -176,9 +176,9 @@ export interface AmasterClient {
|
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
178
|
* Workflow execution module
|
|
179
|
-
*
|
|
179
|
+
*
|
|
180
180
|
* Provides methods for executing Dify-style workflows.
|
|
181
|
-
*
|
|
181
|
+
*
|
|
182
182
|
* For detailed documentation, see {@link ./workflow.d.ts}
|
|
183
183
|
*
|
|
184
184
|
*/
|
|
@@ -186,18 +186,27 @@ export interface AmasterClient {
|
|
|
186
186
|
|
|
187
187
|
/**
|
|
188
188
|
* ASR (Automatic Speech Recognition) module
|
|
189
|
-
*
|
|
189
|
+
*
|
|
190
190
|
* Provides methods for real-time speech-to-text conversion via WebSocket.
|
|
191
|
-
*
|
|
191
|
+
*
|
|
192
192
|
* For detailed documentation, see {@link ./asr.d.ts}
|
|
193
193
|
*/
|
|
194
|
-
asr:
|
|
194
|
+
asr: (config: ASRClientConfig) => ASRClient;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* ASR HTTP module
|
|
198
|
+
*
|
|
199
|
+
* Provides methods for speech-to-text conversion via HTTP API.
|
|
200
|
+
*
|
|
201
|
+
* For detailed documentation, see
|
|
202
|
+
*/
|
|
203
|
+
asrHttp: (config: ASRHttpClientConfig) => ASRHttpClient;
|
|
195
204
|
|
|
196
205
|
/**
|
|
197
206
|
* Copilot AI Assistant module
|
|
198
|
-
*
|
|
207
|
+
*
|
|
199
208
|
* Provides methods for interactive AI conversations with a2a streaming.
|
|
200
|
-
*
|
|
209
|
+
*
|
|
201
210
|
* For detailed documentation, see {@link ./copilot.d.ts}
|
|
202
211
|
*
|
|
203
212
|
*/
|
|
@@ -205,34 +214,34 @@ export interface AmasterClient {
|
|
|
205
214
|
|
|
206
215
|
/**
|
|
207
216
|
* Serverless Function module
|
|
208
|
-
*
|
|
217
|
+
*
|
|
209
218
|
* Provides methods for invoking serverless functions.
|
|
210
|
-
*
|
|
219
|
+
*
|
|
211
220
|
* For detailed documentation, see {@link ./function.d.ts}
|
|
212
221
|
*/
|
|
213
222
|
function: FunctionClientAPI;
|
|
214
223
|
|
|
215
224
|
/**
|
|
216
225
|
* TTS (Text-to-Speech) module
|
|
217
|
-
*
|
|
226
|
+
*
|
|
218
227
|
* Provides methods for real-time text-to-speech conversion via WebSocket.
|
|
219
|
-
*
|
|
228
|
+
*
|
|
220
229
|
* For detailed documentation, see {@link ./tts.d.ts}
|
|
221
230
|
*/
|
|
222
231
|
tts: TTSClientAPI;
|
|
223
232
|
|
|
224
233
|
/**
|
|
225
234
|
* S3 Storage module
|
|
226
|
-
*
|
|
235
|
+
*
|
|
227
236
|
* Provides methods for file upload, download, and management.
|
|
228
|
-
*
|
|
237
|
+
*
|
|
229
238
|
* For detailed documentation, see {@link ./s3.d.ts}
|
|
230
239
|
*/
|
|
231
240
|
s3: S3ClientAPI;
|
|
232
241
|
|
|
233
242
|
/**
|
|
234
243
|
* Check if the user is currently authenticated
|
|
235
|
-
*
|
|
244
|
+
*
|
|
236
245
|
* @returns `true` if a valid access token exists, `false` otherwise
|
|
237
246
|
*
|
|
238
247
|
*/
|
|
@@ -240,7 +249,7 @@ export interface AmasterClient {
|
|
|
240
249
|
|
|
241
250
|
/**
|
|
242
251
|
* Get the current access token
|
|
243
|
-
*
|
|
252
|
+
*
|
|
244
253
|
* @returns The access token string, or `null` if not authenticated
|
|
245
254
|
*
|
|
246
255
|
*/
|
|
@@ -248,10 +257,10 @@ export interface AmasterClient {
|
|
|
248
257
|
|
|
249
258
|
/**
|
|
250
259
|
* Manually set the access token
|
|
251
|
-
*
|
|
260
|
+
*
|
|
252
261
|
* Useful when you have a token from another source (e.g., SSO, OAuth).
|
|
253
262
|
* After setting the token, all requests will use it automatically.
|
|
254
|
-
*
|
|
263
|
+
*
|
|
255
264
|
* @param token - The JWT access token to set
|
|
256
265
|
*
|
|
257
266
|
*/
|
|
@@ -259,12 +268,12 @@ export interface AmasterClient {
|
|
|
259
268
|
|
|
260
269
|
/**
|
|
261
270
|
* Clear all authentication state
|
|
262
|
-
*
|
|
271
|
+
*
|
|
263
272
|
* This removes:
|
|
264
273
|
* - Access token
|
|
265
274
|
* - User information
|
|
266
275
|
* - Auto-refresh timers
|
|
267
|
-
*
|
|
276
|
+
*
|
|
268
277
|
* After calling this, `isAuthenticated()` will return `false`
|
|
269
278
|
* and all requests will be unauthenticated.
|
|
270
279
|
*
|
|
@@ -274,10 +283,10 @@ export interface AmasterClient {
|
|
|
274
283
|
|
|
275
284
|
/**
|
|
276
285
|
* Factory function to create a unified Amaster client
|
|
277
|
-
*
|
|
286
|
+
*
|
|
278
287
|
* This is the main entry point for using the Amaster client library.
|
|
279
288
|
* It returns a client instance that provides access to all Amaster services.
|
|
280
|
-
*
|
|
289
|
+
*
|
|
281
290
|
* @param options - Configuration options for the client
|
|
282
291
|
* @returns A configured Amaster client instance
|
|
283
292
|
*
|
|
@@ -285,18 +294,18 @@ export interface AmasterClient {
|
|
|
285
294
|
export declare function createClient(options: AmasterClientOptions): AmasterClient;
|
|
286
295
|
|
|
287
296
|
// Re-export shared common types
|
|
288
|
-
export type { ClientResult } from
|
|
297
|
+
export type { ClientResult } from "./common";
|
|
289
298
|
|
|
290
299
|
// Re-export main client interfaces
|
|
291
|
-
export type { AuthClientAPI } from
|
|
292
|
-
export type { EntityClientAPI } from
|
|
293
|
-
export type { BpmClientAPI } from
|
|
294
|
-
export type { WorkflowClientAPI } from
|
|
295
|
-
export type {
|
|
296
|
-
export type { CopilotClientAPI } from
|
|
297
|
-
export type { FunctionClientAPI } from
|
|
298
|
-
export type { TTSClientAPI } from
|
|
299
|
-
export type { S3ClientAPI } from
|
|
300
|
+
export type { AuthClientAPI } from "./auth";
|
|
301
|
+
export type { EntityClientAPI } from "./entity";
|
|
302
|
+
export type { BpmClientAPI } from "./bpm";
|
|
303
|
+
export type { WorkflowClientAPI } from "./workflow";
|
|
304
|
+
export type { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig } from "./asr";
|
|
305
|
+
export type { CopilotClientAPI } from "./copilot";
|
|
306
|
+
export type { FunctionClientAPI } from "./function";
|
|
307
|
+
export type { TTSClientAPI } from "./tts";
|
|
308
|
+
export type { S3ClientAPI } from "./s3";
|
|
300
309
|
|
|
301
310
|
// For detailed types, import directly from submodules:
|
|
302
311
|
// import type { LoginParams, User } from '@amaster.ai/client/auth'
|