@amaster.ai/client 1.1.17 → 1.1.19

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
@@ -562,6 +562,10 @@ const result = await client.function.invoke<{ result: string }>("sendEmail", {
562
562
  if (result.data) {
563
563
  console.log("Function result:", result.data.result);
564
564
  }
565
+
566
+ // Keep this id with bug reports or failed UI actions.
567
+ // It maps the response back to the exact edge-function console logs.
568
+ console.log("Invocation:", result.invocationId);
565
569
  ```
566
570
 
567
571
  ## ☁️ S3 Storage
package/dist/index.d.cts CHANGED
@@ -11,7 +11,7 @@ export { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig, ASRLang
11
11
  import { CopilotClient } from '@amaster.ai/copilot-client';
12
12
  export { AutoVoiceReplyController, AutoVoiceReplyConversation, AutoVoiceReplyMessage, AutoVoiceReplySnapshot, AutoVoiceReplySource, AutoVoiceReplySourceSnapshot, AutoVoiceReplySpeechDriver, AutoVoiceReplySpeechSnapshot, AutoVoiceReplyStorage, Conversation, ConversationController, ConversationControllerOptions, ConversationControllerSnapshot, ConversationRequestState, ConversationRuntimeError, CopilotClient, CopilotFileConstraints, CopilotFileManager, CopilotFileManagerSnapshot, CopilotManagedFile, Role as CopilotRole, CreateAutoVoiceReplyControllerOptions, ErrorMessage, FileContent, FileMessage, ImageContent, MessageContent, MessageFileAttachment, MessagesItem, SendMessageOptions, TextContent, TextMessage, ThoughtMessage, ToolMessage, UIRenderMessage, createAutoVoiceReplyController, createCopilotFileManager } from '@amaster.ai/copilot-client';
13
13
  import { FunctionClient } from '@amaster.ai/function-client';
14
- export { FunctionClient } from '@amaster.ai/function-client';
14
+ export { FunctionClient, FunctionInvocationResult } from '@amaster.ai/function-client';
15
15
  import { TTSClientConfig, TTSClient } from '@amaster.ai/tts-client';
16
16
  export { TTSClient, TTSClientConfig, TTSRuntime, TTSSnapshot, TTSSpeakController, TTSSpeakControllerOptions, TTSSpeakOptions, TTSStorageAdapter, createTTSSpeakController, preprocessTTSContent, splitTextIntoFragments } from '@amaster.ai/tts-client';
17
17
  import { S3Client } from '@amaster.ai/s3-client';
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig, ASRLang
11
11
  import { CopilotClient } from '@amaster.ai/copilot-client';
12
12
  export { AutoVoiceReplyController, AutoVoiceReplyConversation, AutoVoiceReplyMessage, AutoVoiceReplySnapshot, AutoVoiceReplySource, AutoVoiceReplySourceSnapshot, AutoVoiceReplySpeechDriver, AutoVoiceReplySpeechSnapshot, AutoVoiceReplyStorage, Conversation, ConversationController, ConversationControllerOptions, ConversationControllerSnapshot, ConversationRequestState, ConversationRuntimeError, CopilotClient, CopilotFileConstraints, CopilotFileManager, CopilotFileManagerSnapshot, CopilotManagedFile, Role as CopilotRole, CreateAutoVoiceReplyControllerOptions, ErrorMessage, FileContent, FileMessage, ImageContent, MessageContent, MessageFileAttachment, MessagesItem, SendMessageOptions, TextContent, TextMessage, ThoughtMessage, ToolMessage, UIRenderMessage, createAutoVoiceReplyController, createCopilotFileManager } from '@amaster.ai/copilot-client';
13
13
  import { FunctionClient } from '@amaster.ai/function-client';
14
- export { FunctionClient } from '@amaster.ai/function-client';
14
+ export { FunctionClient, FunctionInvocationResult } from '@amaster.ai/function-client';
15
15
  import { TTSClientConfig, TTSClient } from '@amaster.ai/tts-client';
16
16
  export { TTSClient, TTSClientConfig, TTSRuntime, TTSSnapshot, TTSSpeakController, TTSSpeakControllerOptions, TTSSpeakOptions, TTSStorageAdapter, createTTSSpeakController, preprocessTTSContent, splitTextIntoFragments } from '@amaster.ai/tts-client';
17
17
  import { S3Client } from '@amaster.ai/s3-client';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/client",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
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/auth-client": "1.1.17",
76
- "@amaster.ai/bpm-client": "1.1.17",
77
- "@amaster.ai/asr-client": "1.1.17",
78
- "@amaster.ai/copilot-client": "1.1.17",
79
- "@amaster.ai/function-client": "1.1.17",
80
- "@amaster.ai/http-client": "1.1.17",
81
- "@amaster.ai/s3-client": "1.1.17",
82
- "@amaster.ai/entity-client": "1.1.17",
83
- "@amaster.ai/tts-client": "1.1.17",
84
- "@amaster.ai/workflow-client": "1.1.17"
75
+ "@amaster.ai/asr-client": "1.1.19",
76
+ "@amaster.ai/auth-client": "1.1.19",
77
+ "@amaster.ai/bpm-client": "1.1.19",
78
+ "@amaster.ai/copilot-client": "1.1.19",
79
+ "@amaster.ai/entity-client": "1.1.19",
80
+ "@amaster.ai/http-client": "1.1.19",
81
+ "@amaster.ai/s3-client": "1.1.19",
82
+ "@amaster.ai/tts-client": "1.1.19",
83
+ "@amaster.ai/workflow-client": "1.1.19",
84
+ "@amaster.ai/function-client": "1.1.19"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "axios": "^1.11.0"
package/types/common.d.ts CHANGED
@@ -65,12 +65,17 @@ export interface ClientResult<T> {
65
65
  * HTTP response status code
66
66
  */
67
67
  status: number;
68
+
69
+ /**
70
+ * Raw response headers when the underlying adapter exposes them.
71
+ */
72
+ headers?: unknown;
68
73
  }
69
74
 
70
75
  /**
71
76
  * HTTP request methods
72
77
  */
73
- export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
78
+ export type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
74
79
 
75
80
  /**
76
81
  * Pagination parameters for list queries
@@ -1,41 +1,59 @@
1
1
  /**
2
2
  * * Invoke serverless functions deployed on the Amaster platform.
3
- *
3
+ *
4
4
  * @module function
5
5
  */
6
6
 
7
- import type { ClientResult } from './common';
7
+ import type { ClientResult } from "./common";
8
+
9
+ /**
10
+ * Function invocation result.
11
+ *
12
+ * Includes the standard client result fields and runtime metadata from
13
+ * response headers. Use `invocationId` to query edge-function invocation logs.
14
+ */
15
+ export type FunctionInvocationResult<T> = ClientResult<T> & {
16
+ /**
17
+ * Runtime invocation id for this function call.
18
+ */
19
+ invocationId: string | null;
20
+
21
+ /**
22
+ * Function version selected by the runtime for this call.
23
+ */
24
+ functionVersion: string | null;
25
+ };
8
26
 
9
27
  /**
10
28
  * Function Client API
11
- *
29
+ *
12
30
  * Execute serverless functions with type-safe parameters and results.
13
- *
31
+ *
14
32
  * @since 1.0.0
15
33
  */
16
34
  export interface FunctionClientAPI {
17
35
  /**
18
36
  * Invoke a serverless function
19
- *
37
+ *
20
38
  * @param funcName - Function name (corresponds to directory in src/functions/)
21
39
  * @param params - Function parameters (sent as JSON body)
22
40
  * @returns Function execution result
23
- *
41
+ *
24
42
  * @example
25
43
  * const result = await client.function.invoke<{ message: string }>('sendEmail', {
26
44
  * to: 'user@example.com',
27
45
  * subject: 'Hello',
28
46
  * body: 'Welcome!'
29
47
  * });
30
- *
48
+ *
31
49
  * if (result.data) {
32
50
  * console.log(result.data.message);
33
51
  * }
34
- *
52
+ *
35
53
  * @since 1.0.0
36
54
  */
37
55
  invoke<T = unknown>(
38
56
  funcName: string,
39
57
  params?: Record<string, unknown>
40
- ): Promise<ClientResult<T>>;
58
+ ): Promise<FunctionInvocationResult<T>>;
41
59
  }
package/types/http.d.ts CHANGED
@@ -1,91 +1,92 @@
1
- import { AxiosRequestConfig, AxiosInstance } from 'axios';
1
+ import { AxiosRequestConfig, AxiosInstance } from "axios";
2
2
 
3
3
  type ClientError = {
4
- message: string;
5
- status?: number;
6
- code?: string;
7
- details?: unknown;
4
+ message: string;
5
+ status?: number;
6
+ code?: string;
7
+ details?: unknown;
8
8
  };
9
9
  type ClientResult<T> = {
10
- data: T | null;
11
- error: ClientError | null;
12
- status: number;
10
+ data: T | null;
11
+ error: ClientError | null;
12
+ status: number;
13
+ headers?: unknown;
13
14
  };
14
15
  type RequestConfig = AxiosRequestConfig & {
15
- url: string;
16
- method: NonNullable<AxiosRequestConfig["method"]> | string;
16
+ url: string;
17
+ method: NonNullable<AxiosRequestConfig["method"]> | string;
17
18
  };
18
19
  type AdapterResponse = {
19
- status: number;
20
- data: unknown;
21
- headers?: unknown;
20
+ status: number;
21
+ data: unknown;
22
+ headers?: unknown;
22
23
  };
23
24
  type HttpAdapter = (_config: RequestConfig) => Promise<AdapterResponse>;
24
25
  type MiniProgramRequest = (_opts: any) => any;
25
26
  type MiniProgramRuntime = {
26
- Taro?: {
27
- request?: (_opts: any) => any;
28
- login?: (_opts?: any) => any;
29
- getEnv?: () => unknown;
30
- ENV_TYPE?: Record<string, unknown>;
31
- miniGlobal?: unknown;
32
- options?: {
33
- miniGlobal?: unknown;
34
- };
27
+ Taro?: {
28
+ request?: (_opts: any) => any;
29
+ login?: (_opts?: any) => any;
30
+ getEnv?: () => unknown;
31
+ ENV_TYPE?: Record<string, unknown>;
32
+ miniGlobal?: unknown;
33
+ options?: {
34
+ miniGlobal?: unknown;
35
35
  };
36
+ };
36
37
  };
37
38
  type HttpClientOptions = {
38
- /**
39
- * HTTP adapter to use:
40
- * - undefined: auto-detect (taro if mini-program APIs exist, otherwise axios)
41
- * - "taro": force mini-program request (wx/tt/my/...) or global Taro.request
42
- * - "axios": force axios
43
- * - AxiosInstance: use provided axios instance
44
- * - function: custom adapter
45
- */
46
- adapter?: "taro" | "axios" | AxiosInstance | HttpAdapter;
47
- /**
48
- * Base URL to prefix when `config.url` is relative (e.g. "/api/...").
49
- *
50
- * If not provided:
51
- * - Taro/mini-program: auto-reads from process.env.TARO_APP_API_BASE_URL or process.env.VITE_API_BASE_URL
52
- * - H5/Browser: no baseURL (expects dev proxy or absolute URLs)
53
- */
54
- baseURL?: string;
55
- /** Default headers merged into each request */
56
- headers?: Record<string, string>;
57
- /**
58
- * Custom response transform function to extract/modify data from backend response
59
- * If not provided, uses default transform logic for { status: 0/1, data: {...} }
60
- *
61
- * Similar to axios's transformResponse option
62
- *
63
- * @example
64
- * ```typescript
65
- * // For backend that returns: { statusCode: 200, data: {...} }
66
- * const client = createHttpClient({
67
- * transformResponse: (response) => {
68
- * if (response && typeof response === 'object' && 'data' in response) {
69
- * return response.data;
70
- * }
71
- * return response;
72
- * }
73
- * });
74
- * ```
75
- */
76
- transformResponse?: <T>(responseData: unknown) => T;
77
- /**
78
- * Whether to log errors to console (default: true)
79
- * Set to false to disable automatic error logging
80
- */
81
- logErrors?: boolean;
82
- /**
83
- * Explicitly provide the Taro runtime object when it is not exposed on `globalThis`.
84
- */
85
- runtime?: Partial<MiniProgramRuntime>;
39
+ /**
40
+ * HTTP adapter to use:
41
+ * - undefined: auto-detect (taro if mini-program APIs exist, otherwise axios)
42
+ * - "taro": force mini-program request (wx/tt/my/...) or global Taro.request
43
+ * - "axios": force axios
44
+ * - AxiosInstance: use provided axios instance
45
+ * - function: custom adapter
46
+ */
47
+ adapter?: "taro" | "axios" | AxiosInstance | HttpAdapter;
48
+ /**
49
+ * Base URL to prefix when `config.url` is relative (e.g. "/api/...").
50
+ *
51
+ * If not provided:
52
+ * - Taro/mini-program: auto-reads from process.env.TARO_APP_API_BASE_URL or process.env.VITE_API_BASE_URL
53
+ * - H5/Browser: no baseURL (expects dev proxy or absolute URLs)
54
+ */
55
+ baseURL?: string;
56
+ /** Default headers merged into each request */
57
+ headers?: Record<string, string>;
58
+ /**
59
+ * Custom response transform function to extract/modify data from backend response
60
+ * If not provided, uses default transform logic for { status: 0/1, data: {...} }
61
+ *
62
+ * Similar to axios's transformResponse option
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * // For backend that returns: { statusCode: 200, data: {...} }
67
+ * const client = createHttpClient({
68
+ * transformResponse: (response) => {
69
+ * if (response && typeof response === 'object' && 'data' in response) {
70
+ * return response.data;
71
+ * }
72
+ * return response;
73
+ * }
74
+ * });
75
+ * ```
76
+ */
77
+ transformResponse?: <T>(responseData: unknown) => T;
78
+ /**
79
+ * Whether to log errors to console (default: true)
80
+ * Set to false to disable automatic error logging
81
+ */
82
+ logErrors?: boolean;
83
+ /**
84
+ * Explicitly provide the Taro runtime object when it is not exposed on `globalThis`.
85
+ */
86
+ runtime?: Partial<MiniProgramRuntime>;
86
87
  };
87
88
  type HttpClient = {
88
- request<T>(_config: RequestConfig): Promise<ClientResult<T>>;
89
+ request<T>(_config: RequestConfig): Promise<ClientResult<T>>;
89
90
  };
90
91
  declare function resolveMiniProgramGlobals(): any;
91
92
  declare function getMiniProgramRequest(): MiniProgramRequest | null;
@@ -109,6 +110,21 @@ declare function getMiniProgramRequest(): MiniProgramRequest | null;
109
110
  * });
110
111
  * ```
111
112
  */
112
- declare function createHttpClient(axiosInstanceOrOptions?: AxiosInstance | HttpClientOptions): HttpClient;
113
+ declare function createHttpClient(
114
+ axiosInstanceOrOptions?: AxiosInstance | HttpClientOptions
115
+ ): HttpClient;
113
116
 
114
- export { type AdapterResponse, type ClientError, type ClientResult, type HttpAdapter, type HttpClient, type HttpClientOptions, type MiniProgramRequest, type MiniProgramRuntime, type RequestConfig, createHttpClient, getMiniProgramRequest, resolveMiniProgramGlobals };
117
+ export {
118
+ type AdapterResponse,
119
+ type ClientError,
120
+ type ClientResult,
121
+ type HttpAdapter,
122
+ type HttpClient,
123
+ type HttpClientOptions,
124
+ type MiniProgramRequest,
125
+ type MiniProgramRuntime,
126
+ type RequestConfig,
127
+ createHttpClient,
128
+ getMiniProgramRequest,
129
+ resolveMiniProgramGlobals,
130
+ };
package/types/index.d.ts CHANGED
@@ -9,11 +9,11 @@
9
9
  *
10
10
  * ## Quick Start
11
11
  * ```typescript
12
- * import { createClient } from '@amaster.ai/client';
13
- *
14
- * const client = createClient({
15
- * onUnauthorized: () => window.location.href = '/login'
16
- * });
12
+ * import { createClient } from '@amaster.ai/client';
13
+ *
14
+ * const client = createClient({
15
+ * onUnauthorized: () => window.location.href = '/login'
16
+ * });
17
17
  *
18
18
  * // Login
19
19
  * await client.auth.login({ email, password });
@@ -268,7 +268,7 @@ export interface AmasterClient {
268
268
  * It automatically includes authentication headers and base URL.
269
269
  * You can use this client to make custom requests to the Amaster API
270
270
  * or your own backend while still benefiting from automatic token management.
271
- * For example:
271
+ * For example:
272
272
  * ```typescript
273
273
  * const response = await client.http.request({
274
274
  * url: '/api/custom-endpoint',
@@ -277,7 +277,7 @@ export interface AmasterClient {
277
277
  * });
278
278
  * console.log(response.data);
279
279
  * ```
280
- * Note: The `http` client is an instance of the same HTTP client used internally by the Amaster client.
280
+ * Note: The `http` client is an instance of the same HTTP client used internally by the Amaster client.
281
281
  * It automatically includes the base URL and authentication headers configured in `createClient()`.
282
282
  */
283
283
  http: HttpClient;
@@ -337,11 +337,7 @@ export interface AmasterClient {
337
337
  export declare function createClient(options?: AmasterClientOptions): AmasterClient;
338
338
 
339
339
  export { createAutoVoiceReplyController, createCopilotFileManager } from "./copilot";
340
- export {
341
- createTTSSpeakController,
342
- preprocessTTSContent,
343
- splitTextIntoFragments,
344
- } from "./tts";
340
+ export { createTTSSpeakController, preprocessTTSContent, splitTextIntoFragments } from "./tts";
345
341
 
346
342
  // Re-export shared common types
347
343
  export type { ClientError, ClientResult } from "./common";
@@ -378,13 +374,99 @@ export type {
378
374
  RoleDetail,
379
375
  PermissionDetail,
380
376
  } from "./auth";
381
- export type { EntityClientAPI, EntityQueryParams, EntityListResponse, FilterOperator, FilterItem, FilterGroup } from "./entity";
382
- export type { BpmClientAPI, ProcessInstance, Task, TaskQueryParams, ProcessVariable, HistoryTask, HistoryProcessInstance, HistoryActivityInstance, ActivityInstanceTree, UserOperationLog, CamundaVariable, TaskFormSchema } from "./bpm";
383
- export type { WorkflowClientAPI, WorkflowRunRequest, WorkflowRunResponse, WorkflowInputValue, WorkflowFile } from "./workflow";
384
- export type { ASRClient, ASRClientConfig, ASRHttpClient, ASRHttpClientConfig, Recorder, RecorderOptions } from "./asr";
385
- export type { CopilotClientAPI, CopilotClientAPI as CopilotClient, MessageContent, TextContent, ImageContent, FileContent, MessageFileAttachment, SendMessageOptions, CopilotFileConstraints, CopilotFileManager, CopilotFileManagerSnapshot, CopilotManagedFile, ConversationController, ConversationControllerOptions, ConversationControllerSnapshot, AutoVoiceReplyController, AutoVoiceReplyConversation, AutoVoiceReplyMessage, AutoVoiceReplySnapshot, AutoVoiceReplySource, AutoVoiceReplySourceSnapshot, AutoVoiceReplySpeechDriver, AutoVoiceReplySpeechSnapshot, AutoVoiceReplyStorage, CreateAutoVoiceReplyControllerOptions, ConversationRequestState, ConversationRuntimeError, Conversation, MessagesItem, TextMessage, FileMessage, ErrorMessage, ThoughtMessage, ToolMessage, UIRenderMessage, Role as CopilotRole } from "./copilot";
386
- export type { FunctionClientAPI, FunctionClientAPI as FunctionClient } from "./function";
387
- export type { TTSClientAPI, TTSClientAPI as TTSClient, TTSClientConfig, TTSAudioFormat, TTSSnapshot, TTSSpeakController, TTSSpeakControllerOptions, TTSSpeakOptions, TTSStreamOptions, TTSRuntime, TTSStorageAdapter } from "./tts";
377
+ export type {
378
+ EntityClientAPI,
379
+ EntityQueryParams,
380
+ EntityListResponse,
381
+ FilterOperator,
382
+ FilterItem,
383
+ FilterGroup,
384
+ } from "./entity";
385
+ export type {
386
+ BpmClientAPI,
387
+ ProcessInstance,
388
+ Task,
389
+ TaskQueryParams,
390
+ ProcessVariable,
391
+ HistoryTask,
392
+ HistoryProcessInstance,
393
+ HistoryActivityInstance,
394
+ ActivityInstanceTree,
395
+ UserOperationLog,
396
+ CamundaVariable,
397
+ TaskFormSchema,
398
+ } from "./bpm";
399
+ export type {
400
+ WorkflowClientAPI,
401
+ WorkflowRunRequest,
402
+ WorkflowRunResponse,
403
+ WorkflowInputValue,
404
+ WorkflowFile,
405
+ } from "./workflow";
406
+ export type {
407
+ ASRClient,
408
+ ASRClientConfig,
409
+ ASRHttpClient,
410
+ ASRHttpClientConfig,
411
+ Recorder,
412
+ RecorderOptions,
413
+ } from "./asr";
414
+ export type {
415
+ CopilotClientAPI,
416
+ CopilotClientAPI as CopilotClient,
417
+ MessageContent,
418
+ TextContent,
419
+ ImageContent,
420
+ FileContent,
421
+ MessageFileAttachment,
422
+ SendMessageOptions,
423
+ CopilotFileConstraints,
424
+ CopilotFileManager,
425
+ CopilotFileManagerSnapshot,
426
+ CopilotManagedFile,
427
+ ConversationController,
428
+ ConversationControllerOptions,
429
+ ConversationControllerSnapshot,
430
+ AutoVoiceReplyController,
431
+ AutoVoiceReplyConversation,
432
+ AutoVoiceReplyMessage,
433
+ AutoVoiceReplySnapshot,
434
+ AutoVoiceReplySource,
435
+ AutoVoiceReplySourceSnapshot,
436
+ AutoVoiceReplySpeechDriver,
437
+ AutoVoiceReplySpeechSnapshot,
438
+ AutoVoiceReplyStorage,
439
+ CreateAutoVoiceReplyControllerOptions,
440
+ ConversationRequestState,
441
+ ConversationRuntimeError,
442
+ Conversation,
443
+ MessagesItem,
444
+ TextMessage,
445
+ FileMessage,
446
+ ErrorMessage,
447
+ ThoughtMessage,
448
+ ToolMessage,
449
+ UIRenderMessage,
450
+ Role as CopilotRole,
451
+ } from "./copilot";
452
+ export type {
453
+ FunctionClientAPI,
454
+ FunctionClientAPI as FunctionClient,
455
+ FunctionInvocationResult,
456
+ } from "./function";
457
+ export type {
458
+ TTSClientAPI,
459
+ TTSClientAPI as TTSClient,
460
+ TTSClientConfig,
461
+ TTSAudioFormat,
462
+ TTSSnapshot,
463
+ TTSSpeakController,
464
+ TTSSpeakControllerOptions,
465
+ TTSSpeakOptions,
466
+ TTSStreamOptions,
467
+ TTSRuntime,
468
+ TTSStorageAdapter,
469
+ } from "./tts";
388
470
  export type { S3ClientAPI, UploadRes, S3Metadata, S3ClientAPI as S3Client } from "./s3";
389
471
  export type { HttpClient, MiniProgramRuntime, RequestConfig } from "./http";
390
472