@amaster.ai/client 1.0.0-alpha.2 → 1.0.0-beta.72
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.cjs +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/types/asr.d.ts +257 -167
- package/types/auth/code-auth.d.ts +3 -3
- package/types/auth/index.d.ts +27 -0
- package/types/auth/user.d.ts +2 -2
- package/types/bpm.d.ts +123 -0
- package/types/copilot.d.ts +156 -37
- package/types/http.d.ts +7 -1
- package/types/index.d.ts +7 -2
- package/types/tts.d.ts +6 -0
package/types/bpm.d.ts
CHANGED
|
@@ -228,6 +228,46 @@ export interface TaskCount {
|
|
|
228
228
|
count: number;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Task form field metadata
|
|
233
|
+
*/
|
|
234
|
+
export interface TaskFormField {
|
|
235
|
+
id: string;
|
|
236
|
+
label?: string;
|
|
237
|
+
type?: string;
|
|
238
|
+
defaultValue?: CamundaVariableValue;
|
|
239
|
+
properties?: Record<string, unknown>;
|
|
240
|
+
validationConstraints?: Array<{
|
|
241
|
+
name: string;
|
|
242
|
+
config?: unknown;
|
|
243
|
+
}>;
|
|
244
|
+
[key: string]: unknown;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Task form schema metadata
|
|
249
|
+
*/
|
|
250
|
+
export interface TaskFormSchema {
|
|
251
|
+
key?: string;
|
|
252
|
+
contextPath?: string;
|
|
253
|
+
fields?: TaskFormField[];
|
|
254
|
+
[key: string]: unknown;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Task form variable value
|
|
259
|
+
*/
|
|
260
|
+
export interface TaskFormVariable {
|
|
261
|
+
type: string;
|
|
262
|
+
value: CamundaVariableValue;
|
|
263
|
+
valueInfo?: Record<string, unknown>;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Task form variables keyed by variable name
|
|
268
|
+
*/
|
|
269
|
+
export type TaskFormVariables = Record<string, TaskFormVariable>;
|
|
270
|
+
|
|
231
271
|
/**
|
|
232
272
|
* Historical task information
|
|
233
273
|
*/
|
|
@@ -502,6 +542,19 @@ export interface BpmClientAPI {
|
|
|
502
542
|
*/
|
|
503
543
|
getTask(taskId: string): Promise<ClientResult<Task>>;
|
|
504
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Get task form schema metadata
|
|
547
|
+
*/
|
|
548
|
+
getTaskFormSchema(
|
|
549
|
+
taskId: string,
|
|
550
|
+
opts?: { redirect?: string }
|
|
551
|
+
): Promise<ClientResult<TaskFormSchema>>;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Get task form variables
|
|
555
|
+
*/
|
|
556
|
+
getTaskFormVariables(taskId: string): Promise<ClientResult<TaskFormVariables>>;
|
|
557
|
+
|
|
505
558
|
/**
|
|
506
559
|
* Complete a user task
|
|
507
560
|
*
|
|
@@ -531,6 +584,20 @@ export interface BpmClientAPI {
|
|
|
531
584
|
inputs: Record<string, CamundaVariableValue> | VariableSubmission
|
|
532
585
|
): Promise<ClientResult<null>>;
|
|
533
586
|
|
|
587
|
+
/**
|
|
588
|
+
* Query historical tasks
|
|
589
|
+
*/
|
|
590
|
+
getHistoryTasks(
|
|
591
|
+
params?: HistoryTaskQueryParams
|
|
592
|
+
): Promise<ClientResult<HistoryTask[]>>;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Get historical task count
|
|
596
|
+
*/
|
|
597
|
+
getHistoryTaskCount(
|
|
598
|
+
params?: HistoryTaskQueryParams
|
|
599
|
+
): Promise<ClientResult<TaskCount>>;
|
|
600
|
+
|
|
534
601
|
// ==================== History & Reporting ====================
|
|
535
602
|
|
|
536
603
|
/**
|
|
@@ -572,6 +639,13 @@ export interface BpmClientAPI {
|
|
|
572
639
|
getHistoryProcessInstanceCount(
|
|
573
640
|
params?: HistoryProcessInstanceQueryParams
|
|
574
641
|
): Promise<ClientResult<{ count: number }>>;
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Get deployed Camunda form definition for a task
|
|
645
|
+
*/
|
|
646
|
+
getTaskDeployedForm(
|
|
647
|
+
taskId: string
|
|
648
|
+
): Promise<ClientResult<CamundaFormDefinition>>;
|
|
575
649
|
}
|
|
576
650
|
|
|
577
651
|
/**
|
|
@@ -619,3 +693,52 @@ export interface HistoryProcessInstanceQueryParams {
|
|
|
619
693
|
/** Pagination: max results to return */
|
|
620
694
|
maxResults?: number;
|
|
621
695
|
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Historical task query parameters
|
|
699
|
+
*/
|
|
700
|
+
export interface HistoryTaskQueryParams {
|
|
701
|
+
/** Filter by task assignee */
|
|
702
|
+
taskAssignee?: string;
|
|
703
|
+
/** Filter by process instance ID */
|
|
704
|
+
processInstanceId?: string;
|
|
705
|
+
/** Filter finished tasks */
|
|
706
|
+
finished?: boolean;
|
|
707
|
+
/** Filter unfinished tasks */
|
|
708
|
+
unfinished?: boolean;
|
|
709
|
+
/** Pagination: first result index */
|
|
710
|
+
firstResult?: number;
|
|
711
|
+
/** Pagination: max results to return */
|
|
712
|
+
maxResults?: number;
|
|
713
|
+
/** Sort field */
|
|
714
|
+
sortBy?: string;
|
|
715
|
+
/** Sort order */
|
|
716
|
+
sortOrder?: "asc" | "desc";
|
|
717
|
+
[key: string]: string | number | boolean | undefined;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Camunda deployed form definition
|
|
722
|
+
*/
|
|
723
|
+
export interface CamundaFormDefinition {
|
|
724
|
+
components?: CamundaFormComponent[];
|
|
725
|
+
type?: string;
|
|
726
|
+
id?: string;
|
|
727
|
+
schemaVersion?: number;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Camunda form component definition
|
|
732
|
+
*/
|
|
733
|
+
export interface CamundaFormComponent {
|
|
734
|
+
key: string;
|
|
735
|
+
label?: string;
|
|
736
|
+
type: string;
|
|
737
|
+
validate?: {
|
|
738
|
+
required?: boolean;
|
|
739
|
+
readonly?: boolean;
|
|
740
|
+
};
|
|
741
|
+
defaultValue?: CamundaVariableValue;
|
|
742
|
+
values?: Array<{ label: string; value: string }>;
|
|
743
|
+
properties?: Record<string, unknown>;
|
|
744
|
+
}
|
package/types/copilot.d.ts
CHANGED
|
@@ -1,49 +1,168 @@
|
|
|
1
|
-
import type { SendStreamingMessageResponse, CancelTaskResponse, GetTaskResponse } from '@a2a-js/sdk';
|
|
2
|
-
import type { ClientResult } from './common';
|
|
3
|
-
|
|
4
1
|
interface TextContent {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
type: "text";
|
|
3
|
+
text: string;
|
|
7
4
|
}
|
|
5
|
+
|
|
8
6
|
interface ImageContent {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
type: "image";
|
|
8
|
+
data?: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
mimeType?: string;
|
|
13
11
|
}
|
|
12
|
+
|
|
14
13
|
interface FileContent {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
type: "file";
|
|
15
|
+
data?: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
mimeType?: string;
|
|
18
|
+
name?: string;
|
|
20
19
|
}
|
|
20
|
+
|
|
21
21
|
type MessageContent = TextContent | ImageContent | FileContent;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
|
|
23
|
+
type Role = "user" | "assistant" | "system";
|
|
24
|
+
|
|
25
|
+
interface BaseMessage {
|
|
26
|
+
messageId: string;
|
|
27
|
+
role?: Role;
|
|
28
|
+
kind: string;
|
|
29
|
+
timestamp?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface TextMessage extends BaseMessage {
|
|
33
|
+
kind: "text-content" | "message";
|
|
34
|
+
content: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ErrorMessage extends BaseMessage {
|
|
38
|
+
kind: "error";
|
|
39
|
+
content: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface ThoughtMessage extends BaseMessage {
|
|
43
|
+
kind: "thought";
|
|
44
|
+
thought: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ToolMessage extends BaseMessage {
|
|
48
|
+
kind: "tool";
|
|
49
|
+
toolName?: string;
|
|
50
|
+
toolStatus?: string;
|
|
51
|
+
toolDescription?: string;
|
|
52
|
+
response?: unknown;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface UIRenderMessage extends BaseMessage {
|
|
56
|
+
kind: "ui-render";
|
|
57
|
+
spec: {
|
|
58
|
+
root: string;
|
|
59
|
+
elements: Record<
|
|
60
|
+
string,
|
|
61
|
+
{
|
|
62
|
+
type: string;
|
|
63
|
+
props?: Record<string, unknown>;
|
|
64
|
+
children?: string[];
|
|
65
|
+
}
|
|
66
|
+
>;
|
|
67
|
+
};
|
|
25
68
|
}
|
|
26
|
-
|
|
27
|
-
|
|
69
|
+
|
|
70
|
+
type MessagesItem =
|
|
71
|
+
| TextMessage
|
|
72
|
+
| ErrorMessage
|
|
73
|
+
| ThoughtMessage
|
|
74
|
+
| ToolMessage
|
|
75
|
+
| UIRenderMessage
|
|
76
|
+
| BaseMessage;
|
|
77
|
+
|
|
78
|
+
interface Conversation {
|
|
79
|
+
taskId: string;
|
|
80
|
+
status: "submitted" | "working" | "completed" | "error";
|
|
81
|
+
messages: MessagesItem[];
|
|
82
|
+
lastUpdated: string;
|
|
83
|
+
historyId?: string;
|
|
84
|
+
system?: {
|
|
85
|
+
level: "newConversation";
|
|
86
|
+
content?: string;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface HistoryState {
|
|
91
|
+
next: string | null;
|
|
92
|
+
hasMore: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface UpdateMessageInput {
|
|
96
|
+
taskId: string;
|
|
97
|
+
messageId: string;
|
|
98
|
+
content?: string;
|
|
99
|
+
partial?: boolean;
|
|
100
|
+
status?: string;
|
|
101
|
+
response?: unknown;
|
|
102
|
+
metadata?: Record<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface ConversationControllerSnapshot {
|
|
106
|
+
starting: boolean;
|
|
107
|
+
isLoading: boolean;
|
|
108
|
+
isLoadingHistory: boolean;
|
|
109
|
+
historyState: HistoryState;
|
|
110
|
+
conversations: Conversation[];
|
|
28
111
|
}
|
|
112
|
+
|
|
113
|
+
interface ConversationStrings {
|
|
114
|
+
thinking: string;
|
|
115
|
+
errorMessage: string;
|
|
116
|
+
cancelled: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface ConversationControllerOptions {
|
|
120
|
+
strings: ConversationStrings;
|
|
121
|
+
mode?: "conversation" | "single-turn";
|
|
122
|
+
getContextId?: () => string;
|
|
123
|
+
loadHistoryOnInit?: boolean;
|
|
124
|
+
resumeOnInit?: boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface ConversationController {
|
|
128
|
+
getSnapshot(): ConversationControllerSnapshot;
|
|
129
|
+
subscribe(listener: (snapshot: ConversationControllerSnapshot) => void): () => void;
|
|
130
|
+
init(): Promise<void>;
|
|
131
|
+
destroy(): void;
|
|
132
|
+
sendMessage(userContent: string): Promise<void>;
|
|
133
|
+
abort(): void;
|
|
134
|
+
cancelChat(taskId?: string): Promise<void>;
|
|
135
|
+
resetConversation(greeting?: string): void;
|
|
136
|
+
startNewConversation(): Promise<void>;
|
|
137
|
+
loadHistory(limit?: number, next?: string): Promise<void>;
|
|
138
|
+
loadMoreHistory(): Promise<void>;
|
|
139
|
+
getConversation(taskId: string): Conversation | undefined;
|
|
140
|
+
clearConversation(taskId: string): void;
|
|
141
|
+
removeMessage(taskId: string, messageId: string): void;
|
|
142
|
+
updateMessage(input: UpdateMessageInput): void;
|
|
143
|
+
}
|
|
144
|
+
|
|
29
145
|
type CopilotClientAPI = {
|
|
30
|
-
|
|
31
|
-
* Stream messages from Copilot Agent.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* import { createCopilotClient, Data } from "@amaster.ai/copilot-client";
|
|
36
|
-
*
|
|
37
|
-
* const client = createCopilotClient();
|
|
38
|
-
*
|
|
39
|
-
* for await (const response of client.chat([{ role: "user", content: "Hello" }])) {
|
|
40
|
-
* // deal response
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
chat(messages: ChatMessage[], options?: ChatOptions): AsyncGenerator<SendStreamingMessageResponse, void, unknown>;
|
|
45
|
-
cancelChat(taskId: string): Promise<ClientResult<CancelTaskResponse>>;
|
|
46
|
-
getChatStatus(taskId: string): Promise<ClientResult<GetTaskResponse>>;
|
|
146
|
+
createConversationController(options: ConversationControllerOptions): ConversationController;
|
|
47
147
|
};
|
|
48
148
|
|
|
49
|
-
export {
|
|
149
|
+
export {
|
|
150
|
+
type CopilotClientAPI,
|
|
151
|
+
type ConversationController,
|
|
152
|
+
type ConversationControllerOptions,
|
|
153
|
+
type ConversationControllerSnapshot,
|
|
154
|
+
type ConversationStrings,
|
|
155
|
+
type Conversation,
|
|
156
|
+
type MessagesItem,
|
|
157
|
+
type TextMessage,
|
|
158
|
+
type ErrorMessage,
|
|
159
|
+
type ThoughtMessage,
|
|
160
|
+
type ToolMessage,
|
|
161
|
+
type UIRenderMessage,
|
|
162
|
+
type Role,
|
|
163
|
+
type UpdateMessageInput,
|
|
164
|
+
type FileContent,
|
|
165
|
+
type ImageContent,
|
|
166
|
+
type MessageContent,
|
|
167
|
+
type TextContent,
|
|
168
|
+
};
|
package/types/http.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ type AdapterResponse = {
|
|
|
21
21
|
headers?: unknown;
|
|
22
22
|
};
|
|
23
23
|
type HttpAdapter = (_config: RequestConfig) => Promise<AdapterResponse>;
|
|
24
|
+
type MiniProgramRequest = (_options: any) => any;
|
|
24
25
|
type HttpClientOptions = {
|
|
25
26
|
/**
|
|
26
27
|
* HTTP adapter to use:
|
|
@@ -31,6 +32,10 @@ type HttpClientOptions = {
|
|
|
31
32
|
* - function: custom adapter
|
|
32
33
|
*/
|
|
33
34
|
adapter?: "taro" | "axios" | AxiosInstance | HttpAdapter;
|
|
35
|
+
/**
|
|
36
|
+
* Explicit mini-program request implementation, for example `Taro.request`.
|
|
37
|
+
*/
|
|
38
|
+
miniProgramRequest?: MiniProgramRequest;
|
|
34
39
|
/**
|
|
35
40
|
* Base URL to prefix when `config.url` is relative (e.g. "/api/...").
|
|
36
41
|
*
|
|
@@ -69,6 +74,7 @@ type HttpClientOptions = {
|
|
|
69
74
|
};
|
|
70
75
|
type HttpClient = {
|
|
71
76
|
request<T>(_config: RequestConfig): Promise<ClientResult<T>>;
|
|
77
|
+
miniProgramRequest?: MiniProgramRequest;
|
|
72
78
|
};
|
|
73
79
|
/**
|
|
74
80
|
* Create an HTTP client instance
|
|
@@ -92,4 +98,4 @@ type HttpClient = {
|
|
|
92
98
|
*/
|
|
93
99
|
declare function createHttpClient(axiosInstanceOrOptions?: AxiosInstance | HttpClientOptions): HttpClient;
|
|
94
100
|
|
|
95
|
-
export { type AdapterResponse, type ClientError, type ClientResult, type HttpAdapter, type HttpClient, type HttpClientOptions, type RequestConfig, createHttpClient };
|
|
101
|
+
export { type AdapterResponse, type ClientError, type ClientResult, type HttpAdapter, type HttpClient, type HttpClientOptions, type MiniProgramRequest, type RequestConfig, createHttpClient };
|
package/types/index.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export interface AmasterClientOptions {
|
|
|
64
64
|
* Base URL for the Amaster API
|
|
65
65
|
*
|
|
66
66
|
*/
|
|
67
|
-
baseURL
|
|
67
|
+
baseURL?: string;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Optional custom headers to include in ALL requests
|
|
@@ -75,6 +75,11 @@ export interface AmasterClientOptions {
|
|
|
75
75
|
*/
|
|
76
76
|
headers?: Record<string, string>;
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Explicit mini-program request implementation, for example `Taro.request`.
|
|
80
|
+
*/
|
|
81
|
+
miniProgramRequest?: import("./http").MiniProgramRequest;
|
|
82
|
+
|
|
78
83
|
/**
|
|
79
84
|
* Callback triggered when a 401 Unauthorized response is received
|
|
80
85
|
*
|
|
@@ -323,7 +328,7 @@ export type { AuthClientAPI } from "./auth";
|
|
|
323
328
|
export type { EntityClientAPI } from "./entity";
|
|
324
329
|
export type { BpmClientAPI } from "./bpm";
|
|
325
330
|
export type { WorkflowClientAPI } from "./workflow";
|
|
326
|
-
export type { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig } from "./asr";
|
|
331
|
+
export type { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig, Recorder, RecorderOptions } from "./asr";
|
|
327
332
|
export type { CopilotClientAPI } from "./copilot";
|
|
328
333
|
export type { FunctionClientAPI } from "./function";
|
|
329
334
|
export type { TTSClientAPI } from "./tts";
|