@cloudbase/js-sdk 3.8.2-beta.1 → 3.8.2-beta.2

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.
Files changed (149) hide show
  1. package/ai/dist/AI.d.ts +29 -0
  2. package/ai/dist/bot/index.d.ts +41 -0
  3. package/ai/dist/bot/types.d.ts +144 -0
  4. package/ai/dist/errors.d.ts +10 -0
  5. package/ai/dist/eventsource_parser/index.d.ts +2 -0
  6. package/ai/dist/eventsource_parser/parse.d.ts +2 -0
  7. package/ai/dist/eventsource_parser/stream.d.ts +5 -0
  8. package/ai/dist/eventsource_parser/types.d.ts +16 -0
  9. package/ai/dist/index.d.ts +42 -1
  10. package/ai/dist/models/Ark/index.d.ts +10 -0
  11. package/ai/dist/models/Ark/type.d.ts +71 -0
  12. package/ai/dist/models/DashScope/index.d.ts +10 -0
  13. package/ai/dist/models/DashScope/type.d.ts +74 -0
  14. package/ai/dist/models/DeepSeek/index.d.ts +10 -0
  15. package/ai/dist/models/Default/index.d.ts +10 -0
  16. package/ai/dist/models/HunYuan/index.d.ts +10 -0
  17. package/ai/dist/models/HunYuan/type.d.ts +74 -0
  18. package/ai/dist/models/HunYuan/util.d.ts +4 -0
  19. package/ai/dist/models/HunYuanBeta/index.d.ts +10 -0
  20. package/ai/dist/models/HunYuanExp/index.d.ts +10 -0
  21. package/ai/dist/models/HunYuanOpen/index.d.ts +10 -0
  22. package/ai/dist/models/Moonshot/index.d.ts +10 -0
  23. package/ai/dist/models/Moonshot/type.d.ts +85 -0
  24. package/ai/dist/models/Yi/index.d.ts +10 -0
  25. package/ai/dist/models/Yi/type.d.ts +75 -0
  26. package/ai/dist/models/ZhiPu/index.d.ts +10 -0
  27. package/ai/dist/models/ZhiPu/type.d.ts +71 -0
  28. package/ai/dist/models/image-model.d.ts +19 -0
  29. package/ai/dist/models/index.d.ts +26 -0
  30. package/ai/dist/models/model.d.ts +40 -0
  31. package/ai/dist/type.d.ts +192 -0
  32. package/ai/dist/utils.d.ts +38 -0
  33. package/apis/dist/callApis.d.ts +20 -0
  34. package/apis/dist/index.d.ts +5 -1
  35. package/apis/dist/type.d.ts +14 -0
  36. package/app/dist/constants/common.d.ts +38 -0
  37. package/app/dist/index.d.ts +66 -7
  38. package/app/dist/index.esm.js +1 -1
  39. package/app/dist/index.js +1 -1
  40. package/app/dist/index.js.map +1 -1
  41. package/app/dist/index.node.d.ts +6 -0
  42. package/app/dist/index.node.esm.js +1 -1
  43. package/app/dist/index.node.esm.js.map +1 -1
  44. package/app/dist/index.node.js +1 -1
  45. package/app/dist/index.node.js.map +1 -1
  46. package/app/dist/libs/adapter-node/constants.d.ts +33 -0
  47. package/app/dist/libs/adapter-node/context.d.ts +18 -0
  48. package/app/dist/libs/adapter-node/index.d.ts +26 -0
  49. package/app/dist/libs/adapter-node/metadata.d.ts +14 -0
  50. package/app/dist/libs/adapter-node/optional-require.d.ts +1 -0
  51. package/app/dist/libs/adapter-node/request.d.ts +44 -0
  52. package/app/dist/libs/adapter-node/tool.d.ts +2 -0
  53. package/app/dist/libs/adapter-node/types.d.ts +103 -0
  54. package/app/dist/libs/adapter-node/utils.d.ts +37 -0
  55. package/app/dist/libs/adapter-node/wx.d.ts +39 -0
  56. package/app/dist/libs/adapter.d.ts +3 -0
  57. package/app/dist/libs/cache.d.ts +6 -0
  58. package/app/dist/libs/component.d.ts +3 -0
  59. package/app/dist/libs/lang.d.ts +23 -0
  60. package/app/dist/libs/request.d.ts +62 -0
  61. package/auth/dist/adapter.d.ts +2 -0
  62. package/auth/dist/index.d.ts +271 -2
  63. package/auth/dist/type.d.ts +295 -0
  64. package/auth/dist/utilities.d.ts +7 -0
  65. package/auth/dist/utils.d.ts +5 -0
  66. package/auth/dist/v1-compat.d.ts +77 -0
  67. package/cloudrun/dist/index.d.ts +4 -1
  68. package/container/dist/constants/index.d.ts +1 -0
  69. package/container/dist/go_wams_exec.d.ts +2 -0
  70. package/container/dist/index.d.ts +13 -2
  71. package/container/dist/utils/index.d.ts +3 -0
  72. package/container/dist/utils/loader.d.ts +8 -0
  73. package/container/dist/utils/request.d.ts +12 -0
  74. package/core.d.ts +84 -81
  75. package/database/dist/index.d.ts +1 -1
  76. package/dist/index.cjs.js +1 -1
  77. package/dist/index.esm.js +1 -1
  78. package/dist/index.node.cjs.js +1 -1
  79. package/dist/index.node.esm.js +1 -1
  80. package/dist/index.node.esm.js.map +1 -1
  81. package/functions/dist/index.d.ts +2 -2
  82. package/miniprogram_dist/ai/index.d.ts +1 -1
  83. package/miniprogram_dist/apis/index.d.ts +1 -1
  84. package/miniprogram_dist/app/index.d.ts +5 -5
  85. package/miniprogram_dist/auth/index.d.ts +7 -7
  86. package/miniprogram_dist/cloudrun/index.d.ts +2 -2
  87. package/miniprogram_dist/container/index.d.ts +2 -2
  88. package/miniprogram_dist/database/index.d.ts +1 -1
  89. package/miniprogram_dist/functions/index.d.ts +1 -1
  90. package/miniprogram_dist/index.js +1 -1
  91. package/miniprogram_dist/model/index.d.ts +1 -1
  92. package/miniprogram_dist/mysql/index.d.ts +1 -1
  93. package/miniprogram_dist/realtime/index.d.ts +1 -1
  94. package/miniprogram_dist/storage/index.d.ts +1 -1
  95. package/model/dist/index.d.ts +5 -1
  96. package/mysql/dist/index.d.ts +4 -1
  97. package/oauth/dist/auth/apis.d.ts +143 -0
  98. package/oauth/dist/auth/auth-error.d.ts +32 -0
  99. package/oauth/dist/auth/consts.d.ts +165 -0
  100. package/oauth/dist/auth/models.d.ts +557 -0
  101. package/oauth/dist/captcha/captcha-dom.d.ts +3 -0
  102. package/oauth/dist/captcha/captcha.d.ts +42 -0
  103. package/oauth/dist/index.d.ts +22 -1
  104. package/oauth/dist/oauth2client/consts.d.ts +20 -0
  105. package/oauth/dist/oauth2client/interface.d.ts +15 -0
  106. package/oauth/dist/oauth2client/models.d.ts +75 -0
  107. package/oauth/dist/oauth2client/oauth2client.d.ts +154 -0
  108. package/oauth/dist/utils/base64.d.ts +9 -0
  109. package/oauth/dist/utils/encrypt.d.ts +4 -0
  110. package/oauth/dist/utils/encryptlong/index.d.ts +546 -0
  111. package/oauth/dist/utils/function/single-promise.d.ts +10 -0
  112. package/oauth/dist/utils/index.d.ts +2 -0
  113. package/oauth/dist/utils/mp.d.ts +2 -0
  114. package/oauth/dist/utils/urlSearchParams.d.ts +13 -0
  115. package/oauth/dist/utils/uuid.d.ts +1 -0
  116. package/package.json +20 -3
  117. package/realtime/dist/common.d.ts +4 -0
  118. package/realtime/dist/error.d.ts +36 -0
  119. package/realtime/dist/index.d.ts +4 -2
  120. package/realtime/dist/listener.d.ts +14 -0
  121. package/realtime/dist/message.d.ts +3 -0
  122. package/realtime/dist/snapshot.d.ts +17 -0
  123. package/realtime/dist/utils.d.ts +1 -0
  124. package/realtime/dist/virtual-websocket-client.d.ts +62 -0
  125. package/realtime/dist/websocket-client.d.ts +78 -0
  126. package/realtime/dist/ws-event.d.ts +126 -0
  127. package/storage/dist/cloudbase-storage.d.ts +58 -0
  128. package/storage/dist/download-builder.d.ts +24 -0
  129. package/storage/dist/encoding.d.ts +3 -0
  130. package/storage/dist/http.d.ts +38 -0
  131. package/storage/dist/index.d.ts +13 -2
  132. package/storage/dist/node-types.d.ts +6 -0
  133. package/storage/dist/storage-bucket-api-neo.d.ts +15 -0
  134. package/storage/dist/storage-file-api-classic.d.ts +80 -0
  135. package/storage/dist/storage-file-api-neo.d.ts +48 -0
  136. package/storage/dist/supabase/errors.d.ts +20 -0
  137. package/storage/dist/supabase/types.d.ts +63 -0
  138. package/storage/dist/types.d.ts +142 -0
  139. package/storage/dist/validation.d.ts +2 -0
  140. package/types/auth.d.ts +1 -1
  141. package/types/index.d.ts +3 -2
  142. package/types/package.json +1 -1
  143. package/utilities/dist/cjs/libs/cache.d.ts +2 -2
  144. package/utilities/dist/cjs/libs/events.d.ts +1 -1
  145. package/utilities/dist/cjs/libs/util.d.ts +1 -1
  146. package/utilities/dist/esm/libs/cache.d.ts +2 -2
  147. package/utilities/dist/esm/libs/events.d.ts +1 -1
  148. package/utilities/dist/esm/libs/util.d.ts +1 -1
  149. package/utilities/package.json +1 -1
@@ -0,0 +1,85 @@
1
+ type SystemMessage = {
2
+ role: 'system';
3
+ content: string;
4
+ };
5
+ type UserMessage = {
6
+ role: 'user';
7
+ content: string;
8
+ };
9
+ type AssistantMessage = {
10
+ role: 'assistant';
11
+ content?: string;
12
+ tool_calls?: Array<{
13
+ id: string;
14
+ type: string;
15
+ function?: {
16
+ name: string;
17
+ arguments: string;
18
+ };
19
+ }>;
20
+ };
21
+ type ToolMessage = {
22
+ role: 'tool';
23
+ content: string;
24
+ tool_call_id: string;
25
+ };
26
+ type MoonshotMessage = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
27
+ export type MoonshotInputData = {
28
+ messages: Array<MoonshotMessage>;
29
+ model: string;
30
+ max_tokens?: number;
31
+ temperature?: number;
32
+ top_p?: number;
33
+ n?: number;
34
+ tools?: Array<{
35
+ type: string;
36
+ function: {
37
+ name: string;
38
+ description: string;
39
+ parameters: object;
40
+ };
41
+ }>;
42
+ presence_penalty?: number;
43
+ frequency_penalty?: number;
44
+ response_format?: object;
45
+ stop?: string | Array<string>;
46
+ };
47
+ export type MoonshotGenerateTextOutput = {
48
+ choices: Array<{
49
+ finish_reason: string;
50
+ message: {
51
+ content: string;
52
+ role: 'assistant';
53
+ tool_calls?: Array<ToolCall>;
54
+ };
55
+ }>;
56
+ usage: {
57
+ prompt_tokens: number;
58
+ completion_tokens: number;
59
+ total_tokens: number;
60
+ };
61
+ };
62
+ export type MoonshotStreamTextOutput = {
63
+ choices: Array<{
64
+ delta: {
65
+ content: string;
66
+ tool_calls?: Array<ToolCall>;
67
+ role: 'assistant';
68
+ };
69
+ finish_reason: string;
70
+ }>;
71
+ usage?: {
72
+ prompt_tokens: number;
73
+ completion_tokens: number;
74
+ total_tokens: number;
75
+ };
76
+ };
77
+ type ToolCall = {
78
+ id: string;
79
+ type: string;
80
+ function: {
81
+ name: string;
82
+ arguments: string;
83
+ };
84
+ };
85
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ModelReq, BaseChatModelInput, DoGenerateOutput, DoStreamOutput, SimpleChatModel, ReqOptions } from '../../type';
2
+ export declare class YiSimpleModel implements SimpleChatModel {
3
+ private req;
4
+ baseUrl: string;
5
+ subUrl: string;
6
+ constructor(req: ModelReq, baseUrl: string, subUrl?: string);
7
+ private get url();
8
+ doGenerate(data: BaseChatModelInput, options?: ReqOptions): Promise<DoGenerateOutput>;
9
+ doStream(data: BaseChatModelInput, options?: ReqOptions): Promise<DoStreamOutput>;
10
+ }
@@ -0,0 +1,75 @@
1
+ type SystemMessage = {
2
+ role: 'system';
3
+ content: string;
4
+ };
5
+ type UserMessage = {
6
+ role: 'user';
7
+ content: string;
8
+ };
9
+ type AssistantMessage = {
10
+ role: 'assistant';
11
+ content: string;
12
+ } | {
13
+ role: 'assistant';
14
+ tool_calls: Array<ToolCall>;
15
+ content?: string;
16
+ };
17
+ type ToolMessage = {
18
+ role: 'tool';
19
+ content: string;
20
+ tool_call_id: string;
21
+ };
22
+ type YiMessage = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
23
+ export type YiInput = {
24
+ model: string;
25
+ messages: Array<YiMessage>;
26
+ temperature?: number;
27
+ top_p?: number;
28
+ tools?: Array<{
29
+ type: string;
30
+ function: {
31
+ name: string;
32
+ description: string;
33
+ parameters: object;
34
+ };
35
+ }>;
36
+ };
37
+ type ToolCall = {
38
+ id: string;
39
+ type: string;
40
+ function: {
41
+ name: string;
42
+ arguments: string;
43
+ };
44
+ };
45
+ export type YiGenerateOutput = {
46
+ choices: Array<{
47
+ finish_reason: string;
48
+ message: {
49
+ content: string;
50
+ role: 'assistant';
51
+ tool_calls?: Array<ToolCall>;
52
+ };
53
+ }>;
54
+ usage: {
55
+ prompt_tokens: number;
56
+ completion_tokens: number;
57
+ total_tokens: number;
58
+ };
59
+ };
60
+ export type YiStreamOutput = {
61
+ choices: Array<{
62
+ delta: {
63
+ content: string;
64
+ tool_calls?: Array<ToolCall>;
65
+ role?: 'assistant';
66
+ };
67
+ finish_reason: string;
68
+ }>;
69
+ usage?: {
70
+ prompt_tokens: number;
71
+ completion_tokens: number;
72
+ total_tokens: number;
73
+ };
74
+ };
75
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ModelReq, BaseChatModelInput, SimpleChatModel, DoStreamOutput, DoGenerateOutput, ReqOptions } from '../../type';
2
+ export declare class ZhiPuSimpleModel implements SimpleChatModel {
3
+ private req;
4
+ baseUrl: string;
5
+ subUrl: string;
6
+ constructor(req: ModelReq, baseUrl: string, subUrl?: string);
7
+ private get url();
8
+ doGenerate(_data: BaseChatModelInput, options?: ReqOptions): Promise<DoGenerateOutput>;
9
+ doStream(_data: BaseChatModelInput, options?: ReqOptions): Promise<DoStreamOutput>;
10
+ }
@@ -0,0 +1,71 @@
1
+ import { ChatModelMessage } from '../../type';
2
+ type SystemMessage = {
3
+ role: 'system';
4
+ content: string;
5
+ };
6
+ type UserMessage = {
7
+ role: 'user';
8
+ content: string;
9
+ };
10
+ type AssistantMessage = {
11
+ role: 'assistant';
12
+ content?: string;
13
+ tool_calls?: Array<{
14
+ id: string;
15
+ type: string;
16
+ function?: {
17
+ name: string;
18
+ arguments: string;
19
+ };
20
+ }>;
21
+ };
22
+ type ToolMessage = {
23
+ role: 'tool';
24
+ content: string;
25
+ tool_call_id: string;
26
+ };
27
+ type ZhiPuMessage = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
28
+ export type ZhiPuInputData = {
29
+ model: string;
30
+ messages: Array<ZhiPuMessage>;
31
+ request_id?: string;
32
+ do_sample?: boolean;
33
+ temperature?: number;
34
+ top_p?: number;
35
+ max_tokens?: number;
36
+ stop?: Array<string>;
37
+ tools?: Array<{
38
+ type: string;
39
+ function: {
40
+ name: string;
41
+ description: string;
42
+ parameters: object;
43
+ };
44
+ }>;
45
+ tool_choice?: 'auto';
46
+ user_id?: string;
47
+ };
48
+ export type ZhiPuGenerateTextOutput = {
49
+ choices?: Array<{
50
+ finish_reason?: 'stop' | 'tool_calls' | 'length' | 'sensitive' | 'network_error';
51
+ message?: ChatModelMessage;
52
+ }>;
53
+ usage?: {
54
+ completion_tokens: number;
55
+ prompt_tokens: number;
56
+ total_tokens: number;
57
+ };
58
+ };
59
+ export type ZhiPuStreamTextOutput = {
60
+ choices?: Array<{
61
+ index: number;
62
+ finish_reason?: 'stop' | 'tool_calls' | 'length' | 'sensitive' | 'network_error';
63
+ delta?: ChatModelMessage;
64
+ }>;
65
+ usage?: {
66
+ completion_tokens: number;
67
+ prompt_tokens: number;
68
+ total_tokens: number;
69
+ };
70
+ };
71
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { ModelReq, HunyuanGenerateImageInput, HunyuanGenerateImageOutput, HunyuanARGenerateImageInput, HunyuanARGenerateImageOutput } from '../type';
2
+ interface HunyuanImageGenerateFn {
3
+ (input: HunyuanARGenerateImageInput): Promise<HunyuanARGenerateImageOutput>;
4
+ (input: HunyuanGenerateImageInput): Promise<HunyuanGenerateImageOutput>;
5
+ }
6
+ type GenerateImageFn<TProvider> = TProvider extends 'hunyuan-image' ? HunyuanImageGenerateFn : (input: unknown) => Promise<unknown>;
7
+ export declare class DefaultImageModel<TProvider extends string> {
8
+ private req;
9
+ baseUrl: string;
10
+ provider: TProvider;
11
+ defaultGenerateImageSubUrl: string;
12
+ generateImageSubUrlConfig: Record<string, Array<[RegExp, string]>>;
13
+ generateImage: GenerateImageFn<TProvider>;
14
+ constructor(req: ModelReq, baseUrl: string, provider: TProvider);
15
+ private generateImageImpl;
16
+ private getGenerateUrl;
17
+ private getGenerateImageSubUrl;
18
+ }
19
+ export {};
@@ -0,0 +1,26 @@
1
+ import { ZhiPuSimpleModel } from './ZhiPu/index';
2
+ import { HunYuanBetaSimpleModel } from './HunYuanBeta/index';
3
+ import { HunYuanSimpleModel } from './HunYuan/index';
4
+ import { ArkSimpleModel } from './Ark/index';
5
+ import { DSSimpleModel } from './DashScope/index';
6
+ import { YiSimpleModel } from './Yi/index';
7
+ import { MoonshotSimpleModel } from './Moonshot/index';
8
+ import { HunYuanExpSimpleModel } from './HunYuanExp/index';
9
+ import { HunYuanOpenSimpleModel } from './HunYuanOpen/index';
10
+ import { DeepSeekSimpleModel } from './DeepSeek';
11
+ import { DefaultSimpleModel } from './Default';
12
+ import { DefaultImageModel } from './image-model';
13
+ export declare const MODELS: {
14
+ hunyuan: typeof HunYuanSimpleModel;
15
+ 'hunyuan-beta': typeof HunYuanBetaSimpleModel;
16
+ ark: typeof ArkSimpleModel;
17
+ dashscope: typeof DSSimpleModel;
18
+ '01-ai': typeof YiSimpleModel;
19
+ moonshot: typeof MoonshotSimpleModel;
20
+ zhipu: typeof ZhiPuSimpleModel;
21
+ 'hunyuan-exp': typeof HunYuanExpSimpleModel;
22
+ 'hunyuan-open': typeof HunYuanOpenSimpleModel;
23
+ deepseek: typeof DeepSeekSimpleModel;
24
+ };
25
+ export { ZhiPuSimpleModel, HunYuanBetaSimpleModel, HunYuanSimpleModel, ArkSimpleModel, DSSimpleModel, YiSimpleModel, MoonshotSimpleModel, HunYuanExpSimpleModel, HunYuanOpenSimpleModel, DefaultSimpleModel, DefaultImageModel, };
26
+ export { ReactModel, toolMap } from './model';
@@ -0,0 +1,40 @@
1
+ import { BaseChatModelInput, DoStreamOutput, SimpleChatModel, ToolCall, ChatModelMessage, AsyncIterableReadableStream, Usage, ModelTool, FunctionTool, ReqOptions } from '../type';
2
+ type ReactModelInput = ReactProps & Omit<BaseChatModelInput, 'tools'> & {
3
+ tools?: Array<ModelTool | FunctionTool>;
4
+ topP?: number;
5
+ toolChoice?: 'none' | 'auto' | 'custom';
6
+ };
7
+ interface IOnStepFinish {
8
+ messages: Array<ChatModelMessage>;
9
+ text?: string;
10
+ toolCall?: ToolCall;
11
+ toolResult?: unknown;
12
+ finishReason?: string;
13
+ stepUsage?: Usage;
14
+ totalUsage?: Usage;
15
+ }
16
+ interface ReactProps {
17
+ maxSteps?: number;
18
+ onStepFinish?: (prop: IOnStepFinish) => unknown;
19
+ abortSignal?: AbortSignal;
20
+ }
21
+ export declare class ReactModel {
22
+ private model;
23
+ constructor(model: SimpleChatModel);
24
+ generateText(_input: ReactModelInput, options?: ReqOptions): Promise<{
25
+ text: string;
26
+ messages: Array<ChatModelMessage>;
27
+ usage: Usage;
28
+ rawResponses: Array<unknown>;
29
+ error?: any;
30
+ }>;
31
+ streamText(_input: ReactModelInput, options?: ReqOptions): Promise<{
32
+ dataStream: DoStreamOutput;
33
+ textStream: AsyncIterableReadableStream<string>;
34
+ messages: Promise<Array<ChatModelMessage>>;
35
+ usage: Promise<Usage>;
36
+ error?: any;
37
+ }>;
38
+ }
39
+ export declare const toolMap: Map<string, CallableFunction>;
40
+ export {};
@@ -0,0 +1,192 @@
1
+ export declare abstract class SimpleChatModel {
2
+ abstract doGenerate(data: BaseChatModelInput, options?: ReqOptions): Promise<DoGenerateOutput>;
3
+ abstract doStream(data: BaseChatModelInput, options?: ReqOptions): Promise<DoStreamOutput>;
4
+ }
5
+ type RawResponse = {
6
+ rawResponse?: any;
7
+ };
8
+ export type DoGenerateOutput = BaseDoGenerateOutput & RawResponse;
9
+ export type DoStreamOutput = AsyncIterableReadableStream<BaseDoStreamOutputChunk & RawResponse>;
10
+ export type ChatModelConstructor = typeof SimpleChatModel;
11
+ export type AsyncIterableReadableStream<T> = ReadableStream<T> & {
12
+ [Symbol.asyncIterator]: () => {
13
+ next(): Promise<IteratorResult<T>>;
14
+ };
15
+ };
16
+ export interface IModelReqInput {
17
+ url: string;
18
+ headers?: Record<string, string>;
19
+ data?: Object;
20
+ stream?: boolean;
21
+ timeout?: number;
22
+ }
23
+ export type ModelReq = <T extends IModelReqInput>(props: T) => T['stream'] extends true ? Promise<ReadableStream<Uint8Array>> : Promise<Object>;
24
+ export interface IBotReqInput {
25
+ url: string;
26
+ method: string;
27
+ headers?: Record<string, string>;
28
+ data?: Object;
29
+ stream?: boolean;
30
+ timeout?: number;
31
+ }
32
+ export interface ReqOptions {
33
+ timeout?: number;
34
+ }
35
+ export type BotReq = <T extends IBotReqInput>(props: T) => T['stream'] extends true ? Promise<ReadableStream<Uint8Array>> : Promise<Object>;
36
+ export type UserMessage = {
37
+ role: 'user';
38
+ content: string;
39
+ };
40
+ export type SystemMessage = {
41
+ role: 'system';
42
+ content: string;
43
+ };
44
+ export type AssistantMessage = PlainAssistantMessage | ToolCallAssistantMessage;
45
+ export type PlainAssistantMessage = {
46
+ role: 'assistant';
47
+ content: string;
48
+ };
49
+ export type ToolCallAssistantMessage = {
50
+ role: 'assistant';
51
+ tool_calls: Array<ToolCall>;
52
+ content?: string;
53
+ };
54
+ export type ToolMessage = {
55
+ role: 'tool';
56
+ tool_call_id: string;
57
+ content: string;
58
+ };
59
+ export type ChatModelMessage = UserMessage | SystemMessage | AssistantMessage | ToolMessage;
60
+ export type FunctionTool = {
61
+ name: string;
62
+ description: string;
63
+ fn: CallableFunction;
64
+ parameters: object;
65
+ };
66
+ export interface BaseChatModelInput {
67
+ model: string;
68
+ messages: Array<ChatModelMessage>;
69
+ temperature?: number;
70
+ top_p?: number;
71
+ tools?: Array<ModelTool>;
72
+ tool_choice?: 'none' | 'auto' | 'custom';
73
+ }
74
+ export type ModelTool = {
75
+ type: string;
76
+ function: ModelToolFunction;
77
+ };
78
+ export type ModelToolFunction = {
79
+ name: string;
80
+ description: string;
81
+ parameters: object;
82
+ };
83
+ export type ToolCall = {
84
+ id: string;
85
+ type: string;
86
+ function: {
87
+ name: string;
88
+ arguments: string;
89
+ };
90
+ };
91
+ type FinishReason = 'tool_calls' | (string & {});
92
+ export type Usage = {
93
+ completion_tokens: number;
94
+ prompt_tokens: number;
95
+ total_tokens: number;
96
+ };
97
+ export interface BaseDoGenerateOutput {
98
+ choices?: Array<{
99
+ finish_reason?: FinishReason;
100
+ message?: ChatModelMessage;
101
+ }>;
102
+ usage?: Usage;
103
+ }
104
+ export interface BaseDoStreamOutputChunk {
105
+ choices?: Array<{
106
+ finish_reason?: FinishReason;
107
+ delta?: ChatModelMessage;
108
+ }>;
109
+ usage?: Usage;
110
+ }
111
+ export interface ImageGenerateInput {
112
+ model: string;
113
+ prompt: string;
114
+ size?: string;
115
+ n?: number;
116
+ [key: string]: unknown;
117
+ }
118
+ export interface ImageEditInput {
119
+ model: string;
120
+ prompt: string;
121
+ size?: string;
122
+ n?: number;
123
+ [key: string]: unknown;
124
+ }
125
+ export interface HunyuanGenerateImageInput {
126
+ model: 'hunyuan-image';
127
+ prompt: string;
128
+ version?: 'v1.8.1' | 'v1.9' | (string & {});
129
+ size?: string;
130
+ negative_prompt?: string;
131
+ style?: '古风二次元风格' | '都市二次元风格' | '悬疑风格' | '校园风格' | '都市异能风格' | (string & {});
132
+ revise?: boolean;
133
+ n?: number;
134
+ footnote?: string;
135
+ seed?: number;
136
+ }
137
+ export interface HunyuanARGenerateImageInput {
138
+ model: 'HY-Image-3.0-Plus-4090-Tob-v1.0' | 'HY-Image-v3.0-I2I-ToB-v1.0.1' | 'hunyuan-image-v3.0-v1.0.4' | 'hunyuan-image-v3.0-v1.0.1' | 'hunyuan-image-v3.0-v1.0.5';
139
+ prompt: string;
140
+ size?: string;
141
+ seed?: number;
142
+ footnote?: string;
143
+ revise?: {
144
+ value: boolean;
145
+ };
146
+ enable_thinking?: {
147
+ value: boolean;
148
+ };
149
+ image_urls?: string[];
150
+ images?: string[];
151
+ }
152
+ export interface HunyuanARGenerateImageOutput {
153
+ id: string;
154
+ created: number;
155
+ data: Array<{
156
+ url: string;
157
+ revised_prompt?: string;
158
+ }>;
159
+ }
160
+ export type HunyuanEditImageInput = {
161
+ model: 'hunyuan-image' | (string & {});
162
+ prompt: string;
163
+ version?: string;
164
+ size?: string;
165
+ n?: number;
166
+ seed?: number;
167
+ footnote?: string;
168
+ image?: string;
169
+ image_url?: string;
170
+ } & ({
171
+ mask: string;
172
+ mask_url?: never;
173
+ } | {
174
+ mask?: never;
175
+ mask_url: string;
176
+ });
177
+ export interface HunyuanGenerateImageOutput {
178
+ id: string;
179
+ created: number;
180
+ data: Array<{
181
+ url: string;
182
+ revised_prompt?: string;
183
+ }>;
184
+ }
185
+ export interface HunyuanEditImageOutput {
186
+ id: string;
187
+ created: number;
188
+ data: Array<{
189
+ url: string;
190
+ }>;
191
+ }
192
+ export {};
@@ -0,0 +1,38 @@
1
+ import { type ParsedEvent } from './eventsource_parser';
2
+ import type { AsyncIterableReadableStream, ChatModelMessage, ToolCallAssistantMessage, ModelTool, FunctionTool } from './type';
3
+ export declare const ReadableStream: {
4
+ new (underlyingSource: UnderlyingByteSource, strategy?: {
5
+ highWaterMark?: number;
6
+ }): ReadableStream<Uint8Array>;
7
+ new <R = any>(underlyingSource: UnderlyingDefaultSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
8
+ new <R_1 = any>(underlyingSource?: UnderlyingSource<R_1>, strategy?: QueuingStrategy<R_1>): ReadableStream<R_1>;
9
+ prototype: ReadableStream;
10
+ };
11
+ export declare const TransformStream: {
12
+ new <I = any, O = any>(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>): TransformStream<I, O>;
13
+ prototype: TransformStream;
14
+ };
15
+ export declare const createEventSourceParserTransformStream: () => TransformStream<string, ParsedEvent>;
16
+ export declare const toPolyfillReadable: (readable: any) => any;
17
+ export declare class TextDecoderStream {
18
+ private handle;
19
+ private transform;
20
+ constructor(encoding?: string, options?: TextDecoderOptions);
21
+ get encoding(): string;
22
+ get fatal(): boolean;
23
+ get ignoreBOM(): boolean;
24
+ get readable(): ReadableStream<any>;
25
+ get writable(): WritableStream<any>;
26
+ get [Symbol.toStringTag](): string;
27
+ }
28
+ export declare function createAsyncIterable<T>(stream: ReadableStream<T>): AsyncIterableReadableStream<T>;
29
+ export declare function intoStandardStream<T>(stream: ReadableStream<Uint8Array>): ReadableStream<T>;
30
+ export declare function intoTextStream(stream: ReadableStream<Uint8Array>): AsyncIterableReadableStream<string>;
31
+ export declare function readableStream2JsonObject(stream: ReadableStream): Promise<any>;
32
+ export declare function createPromise<T = unknown>(): {
33
+ promise: Promise<T>;
34
+ res: (value: T | PromiseLike<T>) => void;
35
+ rej: (reason?: any) => void;
36
+ };
37
+ export declare function isToolCallAssistantMessage(message: ChatModelMessage): message is ToolCallAssistantMessage;
38
+ export declare function functionToolToModelTool(tool: FunctionTool): ModelTool;
@@ -0,0 +1,20 @@
1
+ import { ICallApiOptions, KV } from '@cloudbase/js-sdk/types';
2
+ import { ResponseObject, SDKRequestInterface } from '@cloudbase/adapter-interface';
3
+ export declare function callApi(callApiOptions: ICallApiOptions, opts?: KV<any>): Promise<ResponseObject['data']>;
4
+ declare type MethodType = 'request' | 'post' | 'get' | 'head' | 'patch' | 'delete' | 'put';
5
+ export declare function generateCallApis(apiName: string): {
6
+ [method in MethodType]: typeof callApi;
7
+ };
8
+ export declare function generateApis(params?: {
9
+ env?: string;
10
+ request?: SDKRequestInterface;
11
+ gatewayOrigin?: string;
12
+ getAccessToken?: () => Promise<{
13
+ accessToken: string;
14
+ }>;
15
+ }): {
16
+ [apiName: string]: {
17
+ [method in MethodType]: typeof callApi;
18
+ };
19
+ };
20
+ export {};
@@ -1 +1,5 @@
1
- export * from '@cloudbase/apis';
1
+ import type { ICloudbase } from '@cloudbase/js-sdk/types';
2
+ import { generateApis } from './callApis';
3
+ declare function registerApis(app: ICloudbase): void;
4
+ export { generateApis, registerApis };
5
+ export * from './type';
@@ -0,0 +1,14 @@
1
+ import { KV } from '@cloudbase/js-sdk/types';
2
+ export interface IGenericError<T extends string, P = any> extends Error {
3
+ type: T;
4
+ payload: P;
5
+ generic: boolean;
6
+ }
7
+ export interface ICallApiOptions {
8
+ name?: string;
9
+ path?: string;
10
+ method?: string;
11
+ headers?: KV<any>;
12
+ body?: KV<any> | string;
13
+ token?: string;
14
+ }
@@ -0,0 +1,38 @@
1
+ import { EndPointKey } from '@cloudbase/js-sdk/types';
2
+ export declare function setSdkVersion(version: string): void;
3
+ export declare function getSdkVersion(): string;
4
+ export declare function setSdkName(name: string): void;
5
+ export declare function getSdkName(): string;
6
+ export declare const DATA_VERSION = "2020-01-10";
7
+ interface EndPointInfo {
8
+ env: string;
9
+ endPointKey: EndPointKey;
10
+ region?: string;
11
+ baseUrl?: string;
12
+ protocol?: Protocol;
13
+ }
14
+ type Protocol = 'http' | 'https' | 'http:' | 'https:';
15
+ export declare const DEFAULT_PROTOCOL: 'http:' | 'https:';
16
+ export declare function setEndPointInfo(newInfo: EndPointInfo): void;
17
+ export declare function getEndPointInfo(env: string, endPointKey: EndPointKey, region?: string): EndPointInfo;
18
+ export interface ISetEndPointWithKey {
19
+ key: EndPointKey;
20
+ url?: string;
21
+ protocol?: 'http' | 'https';
22
+ }
23
+ export declare function setGatewayEndPointWithEnv(env: string, protocol?: Protocol, intl?: boolean): void;
24
+ export declare function setRegionLevelEndpoint(env: string, region: string, protocol?: Protocol): void;
25
+ export declare function getBaseEndPoint(env: string, endPointKey?: EndPointKey): string;
26
+ export declare enum LOGINTYPE {
27
+ NULL = "NULL",
28
+ ANONYMOUS = "ANONYMOUS",
29
+ WECHAT = "WECHAT",
30
+ WECHAT_PUBLIC = "WECHAT-PUBLIC",
31
+ WECHAT_OPEN = "WECHAT-OPEN",
32
+ CUSTOM = "CUSTOM",
33
+ EMAIL = "EMAIL",
34
+ USERNAME = "USERNAME",
35
+ PHONE = "PHONE"
36
+ }
37
+ export declare const OAUTH2_LOGINTYPE_PREFIX = "OAUTH2";
38
+ export {};