seacloud-sdk 0.10.0 → 0.10.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.
- package/README.md +168 -0
- package/dist/cli.js +30 -339
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +5 -211
- package/dist/index.js +31 -147
- package/dist/index.js.map +1 -1
- package/package.json +4 -19
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface SeacloudConfig {
|
|
|
13
13
|
fetch?: typeof fetch;
|
|
14
14
|
/** 请求超时时间(毫秒),默认 30000 */
|
|
15
15
|
timeout?: number;
|
|
16
|
+
/** X-Project header 值,用于 Agent API 访问标识,默认为 'SeaVerse' */
|
|
17
|
+
xProject?: string;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* 任务状态
|
|
@@ -115,6 +117,7 @@ interface InitOptions {
|
|
|
115
117
|
intervalMs?: number;
|
|
116
118
|
maxAttempts?: number;
|
|
117
119
|
timeout?: number;
|
|
120
|
+
xProject?: string;
|
|
118
121
|
}
|
|
119
122
|
/**
|
|
120
123
|
* 初始化 SDK(可选)
|
|
@@ -199,34 +202,6 @@ declare function pollTaskUntilComplete(client: SeacloudClient, endpoint: string,
|
|
|
199
202
|
*/
|
|
200
203
|
declare function createAndWaitTask(client: SeacloudClient, endpoint: string, body: Record<string, any>, options?: PollingOptions): Promise<TaskResult>;
|
|
201
204
|
|
|
202
|
-
/**
|
|
203
|
-
* SeaCloud SDK 核心模块
|
|
204
|
-
*/
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* 查询任务状态
|
|
208
|
-
*
|
|
209
|
-
* 用于查询已创建任务的当前状态和结果。
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* ```typescript
|
|
213
|
-
* import { initSeacloud, getTaskStatus } from 'seacloud-sdk';
|
|
214
|
-
*
|
|
215
|
-
* initSeacloud('your-api-key');
|
|
216
|
-
*
|
|
217
|
-
* const result = await getTaskStatus('/model/v1/generation', 'task-123');
|
|
218
|
-
* console.log(result.status); // 'pending' | 'processing' | 'completed' | 'failed'
|
|
219
|
-
* if (result.status === 'completed') {
|
|
220
|
-
* console.log(result.output); // 任务输出结果
|
|
221
|
-
* }
|
|
222
|
-
* ```
|
|
223
|
-
*
|
|
224
|
-
* @param endpoint API 端点路径(例如:/model/v1/generation)
|
|
225
|
-
* @param taskId 任务 ID
|
|
226
|
-
* @returns 任务结果,包含状态、输出等信息
|
|
227
|
-
*/
|
|
228
|
-
declare function getTaskStatus(endpoint: string, taskId: string): Promise<TaskResult>;
|
|
229
|
-
|
|
230
205
|
/**
|
|
231
206
|
* 参数示例:
|
|
232
207
|
* ```typescript
|
|
@@ -12116,7 +12091,7 @@ declare function llmChatCompletions(params: LlmChatCompletionsParams & {
|
|
|
12116
12091
|
* - For tool calls (image/video generation), streaming is RECOMMENDED
|
|
12117
12092
|
*
|
|
12118
12093
|
* 4. AUTHENTICATION:
|
|
12119
|
-
* - Requires 'X-Project
|
|
12094
|
+
* - Requires 'X-Project' header (configured via initSeacloud({ xProject: 'SeaArt' }))
|
|
12120
12095
|
* - Uses Bearer token authentication
|
|
12121
12096
|
*
|
|
12122
12097
|
* 5. SESSION MANAGEMENT:
|
|
@@ -13019,185 +12994,4 @@ interface AppGenerationResult {
|
|
|
13019
12994
|
*/
|
|
13020
12995
|
declare function appGeneration(params: AppGenerationParams): Promise<AppGenerationResult>;
|
|
13021
12996
|
|
|
13022
|
-
/**
|
|
13023
|
-
* 风险类型枚举
|
|
13024
|
-
*/
|
|
13025
|
-
type RiskType = 'POLITY' | 'EROTIC' | 'VIOLENT' | 'CHILD';
|
|
13026
|
-
/**
|
|
13027
|
-
* 标签项
|
|
13028
|
-
*/
|
|
13029
|
-
interface LabelItem {
|
|
13030
|
-
/**
|
|
13031
|
-
* 标签名称,格式: 场景:类别:具体标签
|
|
13032
|
-
*/
|
|
13033
|
-
name: string;
|
|
13034
|
-
/**
|
|
13035
|
-
* 标签对应的风险级别 (0-6)
|
|
13036
|
-
*/
|
|
13037
|
-
score: number;
|
|
13038
|
-
/**
|
|
13039
|
-
* 标签所属的风险类型
|
|
13040
|
-
*/
|
|
13041
|
-
risk_type: RiskType;
|
|
13042
|
-
}
|
|
13043
|
-
/**
|
|
13044
|
-
* 视频帧检测结果
|
|
13045
|
-
*/
|
|
13046
|
-
interface FrameResult {
|
|
13047
|
-
/**
|
|
13048
|
-
* 帧索引号
|
|
13049
|
-
*/
|
|
13050
|
-
frame_index: number;
|
|
13051
|
-
/**
|
|
13052
|
-
* 风险级别
|
|
13053
|
-
*/
|
|
13054
|
-
nsfw_level: number;
|
|
13055
|
-
/**
|
|
13056
|
-
* 标签列表
|
|
13057
|
-
*/
|
|
13058
|
-
label_items: LabelItem[];
|
|
13059
|
-
/**
|
|
13060
|
-
* 风险类型列表
|
|
13061
|
-
*/
|
|
13062
|
-
risk_types: RiskType[];
|
|
13063
|
-
}
|
|
13064
|
-
/**
|
|
13065
|
-
* 内容安全检测请求参数
|
|
13066
|
-
*
|
|
13067
|
-
* 参数示例:
|
|
13068
|
-
* ```typescript
|
|
13069
|
-
* {
|
|
13070
|
-
* "uri": "https://example.com/image.jpg",
|
|
13071
|
-
* "risk_types": ["POLITY", "EROTIC", "VIOLENT", "CHILD"],
|
|
13072
|
-
* "detected_age": 0,
|
|
13073
|
-
* "is_video": 0
|
|
13074
|
-
* }
|
|
13075
|
-
* ```
|
|
13076
|
-
*/
|
|
13077
|
-
interface ScanParams {
|
|
13078
|
-
/**
|
|
13079
|
-
* 图片或视频的URL地址
|
|
13080
|
-
* 注意:视频检测必须使用 uri,不支持 img_base64
|
|
13081
|
-
*/
|
|
13082
|
-
uri?: string;
|
|
13083
|
-
/**
|
|
13084
|
-
* 图片的Base64编码字符串
|
|
13085
|
-
* 注意:视频检测不支持 base64 输入
|
|
13086
|
-
*/
|
|
13087
|
-
img_base64?: string;
|
|
13088
|
-
/**
|
|
13089
|
-
* 需要检测的风险类型列表
|
|
13090
|
-
* 可选值:POLITY(政治敏感)、EROTIC(色情内容)、VIOLENT(暴力血腥)、CHILD(儿童安全)
|
|
13091
|
-
*/
|
|
13092
|
-
risk_types: RiskType[];
|
|
13093
|
-
/**
|
|
13094
|
-
* 是否进行年龄检测,0或1
|
|
13095
|
-
* @default 0
|
|
13096
|
-
*/
|
|
13097
|
-
detected_age: number;
|
|
13098
|
-
/**
|
|
13099
|
-
* 是否为视频文件,0或1
|
|
13100
|
-
* @default 0
|
|
13101
|
-
*/
|
|
13102
|
-
is_video: number;
|
|
13103
|
-
}
|
|
13104
|
-
/**
|
|
13105
|
-
* 内容安全检测响应结果
|
|
13106
|
-
*/
|
|
13107
|
-
interface ScanResponse {
|
|
13108
|
-
/**
|
|
13109
|
-
* 请求是否成功
|
|
13110
|
-
*/
|
|
13111
|
-
ok: boolean;
|
|
13112
|
-
/**
|
|
13113
|
-
* 风险级别,范围 0-6
|
|
13114
|
-
*/
|
|
13115
|
-
nsfw_level?: number;
|
|
13116
|
-
/**
|
|
13117
|
-
* 检测到的标签列表
|
|
13118
|
-
*/
|
|
13119
|
-
label_items?: LabelItem[];
|
|
13120
|
-
/**
|
|
13121
|
-
* 实际检测到的风险类型列表
|
|
13122
|
-
*/
|
|
13123
|
-
risk_types?: RiskType[];
|
|
13124
|
-
/**
|
|
13125
|
-
* 年龄组信息 [年龄段代码, 置信度]
|
|
13126
|
-
*/
|
|
13127
|
-
age_group?: any[];
|
|
13128
|
-
/**
|
|
13129
|
-
* 错误信息
|
|
13130
|
-
*/
|
|
13131
|
-
error?: string;
|
|
13132
|
-
/**
|
|
13133
|
-
* 视频时长(秒)
|
|
13134
|
-
*/
|
|
13135
|
-
video_duration?: number;
|
|
13136
|
-
/**
|
|
13137
|
-
* 最高风险帧的索引号
|
|
13138
|
-
*/
|
|
13139
|
-
max_risk_frame?: number;
|
|
13140
|
-
/**
|
|
13141
|
-
* 总抽帧数量
|
|
13142
|
-
*/
|
|
13143
|
-
frame_count?: number;
|
|
13144
|
-
/**
|
|
13145
|
-
* 实际检测的帧数
|
|
13146
|
-
*/
|
|
13147
|
-
frames_checked?: number;
|
|
13148
|
-
/**
|
|
13149
|
-
* 是否因检测到6级风险而提前退出
|
|
13150
|
-
*/
|
|
13151
|
-
early_exit?: boolean;
|
|
13152
|
-
/**
|
|
13153
|
-
* 每一帧的详细检测结果
|
|
13154
|
-
*/
|
|
13155
|
-
frame_results?: FrameResult[];
|
|
13156
|
-
}
|
|
13157
|
-
/**
|
|
13158
|
-
* scan - 内容安全检测
|
|
13159
|
-
*
|
|
13160
|
-
* 云服务内容安全检测接口,支持图片和视频的风险检测。
|
|
13161
|
-
*
|
|
13162
|
-
* Features:
|
|
13163
|
-
* - 支持图片和视频检测
|
|
13164
|
-
* - 多种风险类型检测(政治敏感、色情、暴力、儿童安全)
|
|
13165
|
-
* - 风险级别评分(0-6)
|
|
13166
|
-
* - 视频逐帧检测
|
|
13167
|
-
* - 可选年龄检测
|
|
13168
|
-
*
|
|
13169
|
-
* @example
|
|
13170
|
-
* ```typescript
|
|
13171
|
-
* import { initSeacloud, scan } from 'seacloud-sdk';
|
|
13172
|
-
*
|
|
13173
|
-
* initSeacloud('your-api-key');
|
|
13174
|
-
*
|
|
13175
|
-
* // 图片检测
|
|
13176
|
-
* const imageResult = await scan({
|
|
13177
|
-
* uri: "https://example.com/image.jpg",
|
|
13178
|
-
* risk_types: ["POLITY", "EROTIC", "VIOLENT", "CHILD"],
|
|
13179
|
-
* detected_age: 0,
|
|
13180
|
-
* is_video: 0
|
|
13181
|
-
* });
|
|
13182
|
-
*
|
|
13183
|
-
* console.log(imageResult.nsfw_level); // 风险级别 0-6
|
|
13184
|
-
* console.log(imageResult.label_items); // 检测到的标签
|
|
13185
|
-
*
|
|
13186
|
-
* // 视频检测
|
|
13187
|
-
* const videoResult = await scan({
|
|
13188
|
-
* uri: "https://example.com/video.mp4",
|
|
13189
|
-
* risk_types: ["EROTIC", "VIOLENT"],
|
|
13190
|
-
* detected_age: 0,
|
|
13191
|
-
* is_video: 1
|
|
13192
|
-
* });
|
|
13193
|
-
*
|
|
13194
|
-
* console.log(videoResult.frame_results); // 每一帧的检测结果
|
|
13195
|
-
* ```
|
|
13196
|
-
*
|
|
13197
|
-
* @param params 请求参数,详见 ScanParams 接口定义
|
|
13198
|
-
* @returns 检测结果,包含风险级别、标签等信息
|
|
13199
|
-
* @throws {SeacloudError} 当请求失败或参数不合法时抛出错误
|
|
13200
|
-
*/
|
|
13201
|
-
declare function scan(params: ScanParams): Promise<ScanResponse>;
|
|
13202
|
-
|
|
13203
|
-
export { type AgentArtifact, type AgentChatCompletionChoice, type AgentChatCompletionChunk, type AgentChatCompletionChunkChoice, type AgentChatCompletionDelta, type AgentChatCompletionResponse, type AgentChatCompletionsParams, type AgentContentFilterResult, type AgentMessage, type AgentMessageContent, type AgentMessageContentType, type AgentMessageRole, type AgentResponseMessage, type AgentTool, type AgentToolCall, type AgentToolFunction, type AgentUsage, type AlibabaAnimateAnyoneDetectParams, type AlibabaAnimateAnyoneDetectResource, type AlibabaAnimateAnyoneTemplateParams, type AlibabaAnimateAnyoneTemplateResource, type AlibabaAnimateAnyoneVideoParams, type AlibabaAnimateAnyoneVideoResource, type AlibabaQianwenImageParams, type AlibabaQianwenImageResource, type AlibabaWan22T2iFlashParams, type AlibabaWan22T2iFlashResource, type AlibabaWan22T2iPlusParams, type AlibabaWan22T2iPlusResource, type AlibabaWan25I2iPreviewParams, type AlibabaWan25I2iPreviewResource, type AlibabaWan25T2iPreviewParams, type AlibabaWan25T2iPreviewResource, type AlibabaWanx20T2iTurboParams, type AlibabaWanx20T2iTurboResource, type AlibabaWanx21I2vPlusParams, type AlibabaWanx21I2vPlusResource, type AlibabaWanx21I2vTurboParams, type AlibabaWanx21I2vTurboResource, type AlibabaWanx21T2iPlusParams, type AlibabaWanx21T2iPlusResource, type AlibabaWanx21T2iTurboParams, type AlibabaWanx21T2iTurboResource, type AlibabaWanx21T2vPlusParams, type AlibabaWanx21T2vPlusResource, type AlibabaWanx21T2vTurboParams, type AlibabaWanx21T2vTurboResource, type AlibabaWanx22I2vFlashParams, type AlibabaWanx22I2vFlashResource, type AlibabaWanx22I2vPlusParams, type AlibabaWanx22I2vPlusResource, type AlibabaWanx22T2vPlusParams, type AlibabaWanx22T2vPlusResource, type AlibabaWanx25I2vPreviewParams, type AlibabaWanx25I2vPreviewResource, type AlibabaWanx25T2vPreviewParams, type AlibabaWanx25T2vPreviewResource, type AlibabaWanx26I2vParams, type AlibabaWanx26I2vResource, type AlibabaWanx26ReferenceParams, type AlibabaWanx26ReferenceResource, type AlibabaWanx26T2vParams, type AlibabaWanx26T2vResource, type AppGenerationInput, type AppGenerationParams, type AppGenerationResource, type AppGenerationResult, type AppSearchParams, type AppSearchResponse, type BlackforestlabsFlux11ProParams, type BlackforestlabsFlux11ProResource, type BlackforestlabsFlux1ProParams, type BlackforestlabsFlux1ProResource, type BlackforestlabsFlux2FlexEditParams, type BlackforestlabsFlux2FlexEditResource, type BlackforestlabsFlux2FlexParams, type BlackforestlabsFlux2FlexResource, type BlackforestlabsFlux2ProEditParams, type BlackforestlabsFlux2ProEditResource, type BlackforestlabsFlux2ProParams, type BlackforestlabsFlux2ProResource, type BlackforestlabsFluxKontextMaxParams, type BlackforestlabsFluxKontextMaxResource, type BlackforestlabsFluxKontextProParams, type BlackforestlabsFluxKontextProResource, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionChunkChoice, type ChatCompletionChunkDelta, type ChatCompletionResponse, type ChatCompletionUsage, type ChatMessage, type ChatMessageRole, type ElevenlabsTtsGeneratorParams, type ElevenlabsTtsGeneratorResource, type FrameResult, type GoogleGemini3ProImageParams, type GoogleGemini3ProImageResource, type GoogleGeminiImageParams, type GoogleGeminiImageResource, type GoogleImagen4FastGenerateParams, type GoogleImagen4FastGenerateResource, type GoogleImagen4GenerateParams, type GoogleImagen4GenerateResource, type GoogleImagen4UltraGenerateParams, type GoogleImagen4UltraGenerateResource, type GoogleVeo20Generate001Params, type GoogleVeo20Generate001Resource, type GoogleVeo20GenerateExpParams, type GoogleVeo20GenerateExpResource, type GoogleVeo20GeneratePreviewParams, type GoogleVeo20GeneratePreviewResource, type GoogleVeo30FastGenerate001Params, type GoogleVeo30FastGenerate001Resource, type GoogleVeo30Generate001Params, type GoogleVeo30Generate001Resource, type GoogleVeo31Params, type GoogleVeo31Resource, type InitOptions, type KlingAvatarParams, type KlingAvatarResource, type KlingDurationExtensionParams, type KlingDurationExtensionResource, type KlingEffectsMultiV15Params, type KlingEffectsMultiV15Resource, type KlingEffectsMultiV16Params, type KlingEffectsMultiV16Resource, type KlingEffectsMultiV1Params, type KlingEffectsMultiV1Resource, type KlingEffectsSingleParams, type KlingEffectsSingleResource, type KlingLipsyncParams, type KlingLipsyncResource, type KlingOmniImageParams, type KlingOmniImageResource, type KlingOmniVideoParams, type KlingOmniVideoResource, type KlingV15I2vParams, type KlingV15I2vResource, type KlingV15Params, type KlingV15Resource, type KlingV16I2vParams, type KlingV16I2vResource, type KlingV16Params, type KlingV16Resource, type KlingV1I2vParams, type KlingV1I2vResource, type KlingV1Params, type KlingV1Resource, type KlingV21I2vParams, type KlingV21I2vResource, type KlingV21MasterI2vParams, type KlingV21MasterI2vResource, type KlingV21MasterParams, type KlingV21MasterResource, type KlingV25TurboI2vParams, type KlingV25TurboI2vResource, type KlingV25TurboParams, type KlingV25TurboResource, type KlingV26I2vParams, type KlingV26I2vResource, type KlingV26Params, type KlingV26Resource, type KlingV2MasterI2vParams, type KlingV2MasterI2vResource, type KlingV2MasterParams, type KlingV2MasterResource, type LabelItem, type LlmChatCompletionsParams, type MicrosoftGptImage15Params, type MicrosoftGptImage15Resource, type MicrosoftGptImage1Params, type MicrosoftGptImage1Resource, type MicrosoftSora2Params, type MicrosoftSora2Resource, type MinimaxHailuo02I2vParams, type MinimaxHailuo02I2vResource, type MinimaxHailuo02Params, type MinimaxHailuo02Resource, type MinimaxHailuo23FastI2vParams, type MinimaxHailuo23FastI2vResource, type MinimaxHailuo23I2vParams, type MinimaxHailuo23I2vResource, type MinimaxI2v01DirectorParams, type MinimaxI2v01DirectorResource, type MinimaxI2v01LiveParams, type MinimaxI2v01LiveResource, type MinimaxI2v01Params, type MinimaxI2v01Resource, type MinimaxT2aParams, type MinimaxT2aResource, type MinimaxT2v01DirectorParams, type MinimaxT2v01DirectorResource, type MinimaxT2v01Params, type MinimaxT2v01Resource, type PixverseV35I2vParams, type PixverseV35I2vResource, type PixverseV35T2vParams, type PixverseV35T2vResource, type PixverseV35TransitionParams, type PixverseV35TransitionResource, type PixverseV45I2vParams, type PixverseV45I2vResource, type PixverseV45T2vParams, type PixverseV45T2vResource, type PixverseV45TransitionParams, type PixverseV45TransitionResource, type PixverseV4I2vParams, type PixverseV4I2vResource, type PixverseV4T2vParams, type PixverseV4T2vResource, type PixverseV4TransitionParams, type PixverseV4TransitionResource, type PixverseV55I2vParams, type PixverseV55I2vResource, type PixverseV55T2vParams, type PixverseV55T2vResource, type PixverseV55TransitionParams, type PixverseV55TransitionResource, type PixverseV5I2vParams, type PixverseV5I2vResource, type PixverseV5T2vParams, type PixverseV5T2vResource, type PixverseV5TransitionParams, type PixverseV5TransitionResource, type PollingOptions, type RiskType, type RunwayGen3aTurboI2vParams, type RunwayGen3aTurboI2vResource, type ScanParams, type ScanResponse, SeacloudClient, type SeacloudConfig, SeacloudError, type TaskError, type TaskResult, type TaskStatus, type TemplateSpec, type TemplateSpecConstraint, type TemplateSpecInput, type TemplateSpecOutput, type TemplateSpecsParams, type TemplateSpecsResponse, type TencentHunyuan3dParams, type TencentHunyuan3dProParams, type TencentHunyuan3dProResource, type TencentHunyuan3dRapidParams, type TencentHunyuan3dRapidResource, type TencentHunyuan3dResource, type TencentImageCreation3Params, type TencentImageCreation3Resource, type TencentMpsSuperResolutionParams, type TencentMpsSuperResolutionResource, type Vidu15I2vParams, type Vidu15I2vResource, type Vidu15Params, type Vidu15Resource, type Vidu20I2vParams, type Vidu20I2vResource, type ViduQ1I2vParams, type ViduQ1I2vResource, type ViduQ1Params, type ViduQ1Resource, type ViduQ2Params, type ViduQ2Resource, type ViduTemplateParams, type ViduTemplateResource, type ViduTemplateV2Params, type ViduTemplateV2Resource, type VolcesJimeng30Params, type VolcesJimeng30Resource, type VolcesJimeng31Params, type VolcesJimeng31Resource, type VolcesJimengDreamActorM1Params, type VolcesJimengDreamActorM1Resource, type VolcesJimengI2i30Params, type VolcesJimengI2i30Resource, type VolcesRealmanAvatarImitatorV2vParams, type VolcesRealmanAvatarImitatorV2vResource, type VolcesRealmanAvatarPictureOmniV15Params, type VolcesRealmanAvatarPictureOmniV15Resource, type VolcesRealmanAvatarPictureOmniV2Params, type VolcesRealmanAvatarPictureOmniV2Resource, type VolcesSeed3dParams, type VolcesSeed3dResource, type VolcesSeedance30I2vParams, type VolcesSeedance30I2vResource, type VolcesSeedance30Params, type VolcesSeedance30ProParams, type VolcesSeedance30ProResource, type VolcesSeedance30Resource, type VolcesSeedanceProFastParams, type VolcesSeedanceProFastResource, type VolcesSeededit20Params, type VolcesSeededit20Resource, type VolcesSeededit30I2iParams, type VolcesSeededit30I2iResource, type VolcesSeededit30Params, type VolcesSeededit30Resource, type VolcesSeededit3dStyleParams, type VolcesSeededit3dStyleResource, type VolcesSeededitMultiIpParams, type VolcesSeededitMultiIpResource, type VolcesSeededitMultiStyleParams, type VolcesSeededitMultiStyleResource, type VolcesSeededitPortraitParams, type VolcesSeededitPortraitResource, type VolcesSeededitSingleIpParams, type VolcesSeededitSingleIpResource, type VolcesSeedream30Params, type VolcesSeedream30Resource, type VolcesSeedream40Params, type VolcesSeedream40Resource, type VolcesSeedream45I2iParams, type VolcesSeedream45I2iResource, type VolcesSeedream45MultiBlendParams, type VolcesSeedream45MultiBlendResource, type VolcesSeedream45Params, type VolcesSeedream45Resource, type VolcesSubjectDetectionParams, type VolcesSubjectDetectionResource, type VolcesSubjectRecognitionParams, type VolcesSubjectRecognitionResource, agentChatCompletions, alibabaAnimateAnyoneDetect, alibabaAnimateAnyoneTemplate, alibabaAnimateAnyoneVideo, alibabaQianwenImage, alibabaWan22T2iFlash, alibabaWan22T2iPlus, alibabaWan25I2iPreview, alibabaWan25T2iPreview, alibabaWanx20T2iTurbo, alibabaWanx21I2vPlus, alibabaWanx21I2vTurbo, alibabaWanx21T2iPlus, alibabaWanx21T2iTurbo, alibabaWanx21T2vPlus, alibabaWanx21T2vTurbo, alibabaWanx22I2vFlash, alibabaWanx22I2vPlus, alibabaWanx22T2vPlus, alibabaWanx25I2vPreview, alibabaWanx25T2vPreview, alibabaWanx26I2v, alibabaWanx26Reference, alibabaWanx26T2v, appGeneration, appSearch, blackforestlabsFlux11Pro, blackforestlabsFlux1Pro, blackforestlabsFlux2Flex, blackforestlabsFlux2FlexEdit, blackforestlabsFlux2Pro, blackforestlabsFlux2ProEdit, blackforestlabsFluxKontextMax, blackforestlabsFluxKontextPro, createAndWaitTask, createAudioMessage, createConfig, createImageMessage, createTextMessage, createTool, createVideoMessage, elevenlabsTtsGenerator, getClient, getDefaultPollingOptions, getTaskStatus, googleGemini3ProImage, googleGeminiImage, googleImagen4FastGenerate, googleImagen4Generate, googleImagen4UltraGenerate, googleVeo20Generate001, googleVeo20GenerateExp, googleVeo20GeneratePreview, googleVeo30FastGenerate001, googleVeo30Generate001, googleVeo31, initSeacloud, klingAvatar, klingDurationExtension, klingEffectsMultiV1, klingEffectsMultiV15, klingEffectsMultiV16, klingEffectsSingle, klingLipsync, klingOmniImage, klingOmniVideo, klingV1, klingV15, klingV15I2v, klingV16, klingV16I2v, klingV1I2v, klingV21I2v, klingV21Master, klingV21MasterI2v, klingV25Turbo, klingV25TurboI2v, klingV26, klingV26I2v, klingV2Master, klingV2MasterI2v, llmChatCompletions, microsoftGptImage1, microsoftGptImage15, microsoftSora2, minimaxHailuo02, minimaxHailuo02I2v, minimaxHailuo23FastI2v, minimaxHailuo23I2v, minimaxI2v01, minimaxI2v01Director, minimaxI2v01Live, minimaxT2a, minimaxT2v01, minimaxT2v01Director, pixverseV35I2v, pixverseV35T2v, pixverseV35Transition, pixverseV45I2v, pixverseV45T2v, pixverseV45Transition, pixverseV4I2v, pixverseV4T2v, pixverseV4Transition, pixverseV55I2v, pixverseV55T2v, pixverseV55Transition, pixverseV5I2v, pixverseV5T2v, pixverseV5Transition, pollTaskUntilComplete, resetConfig, runwayGen3aTurboI2v, scan, setDefaultPollingOptions, templateSpecs, tencentHunyuan3d, tencentHunyuan3dPro, tencentHunyuan3dRapid, tencentImageCreation3, tencentMpsSuperResolution, validateConfig, vidu15, vidu15I2v, vidu20I2v, viduQ1, viduQ1I2v, viduQ2, viduTemplate, viduTemplateV2, volcesJimeng30, volcesJimeng31, volcesJimengDreamActorM1, volcesJimengI2i30, volcesRealmanAvatarImitatorV2v, volcesRealmanAvatarPictureOmniV15, volcesRealmanAvatarPictureOmniV2, volcesSeed3d, volcesSeedance30, volcesSeedance30I2v, volcesSeedance30Pro, volcesSeedanceProFast, volcesSeededit20, volcesSeededit30, volcesSeededit30I2i, volcesSeededit3dStyle, volcesSeededitMultiIp, volcesSeededitMultiStyle, volcesSeededitPortrait, volcesSeededitSingleIp, volcesSeedream30, volcesSeedream40, volcesSeedream45, volcesSeedream45I2i, volcesSeedream45MultiBlend, volcesSubjectDetection, volcesSubjectRecognition };
|
|
12997
|
+
export { type AgentArtifact, type AgentChatCompletionChoice, type AgentChatCompletionChunk, type AgentChatCompletionChunkChoice, type AgentChatCompletionDelta, type AgentChatCompletionResponse, type AgentChatCompletionsParams, type AgentContentFilterResult, type AgentMessage, type AgentMessageContent, type AgentMessageContentType, type AgentMessageRole, type AgentResponseMessage, type AgentTool, type AgentToolCall, type AgentToolFunction, type AgentUsage, type AlibabaAnimateAnyoneDetectParams, type AlibabaAnimateAnyoneDetectResource, type AlibabaAnimateAnyoneTemplateParams, type AlibabaAnimateAnyoneTemplateResource, type AlibabaAnimateAnyoneVideoParams, type AlibabaAnimateAnyoneVideoResource, type AlibabaQianwenImageParams, type AlibabaQianwenImageResource, type AlibabaWan22T2iFlashParams, type AlibabaWan22T2iFlashResource, type AlibabaWan22T2iPlusParams, type AlibabaWan22T2iPlusResource, type AlibabaWan25I2iPreviewParams, type AlibabaWan25I2iPreviewResource, type AlibabaWan25T2iPreviewParams, type AlibabaWan25T2iPreviewResource, type AlibabaWanx20T2iTurboParams, type AlibabaWanx20T2iTurboResource, type AlibabaWanx21I2vPlusParams, type AlibabaWanx21I2vPlusResource, type AlibabaWanx21I2vTurboParams, type AlibabaWanx21I2vTurboResource, type AlibabaWanx21T2iPlusParams, type AlibabaWanx21T2iPlusResource, type AlibabaWanx21T2iTurboParams, type AlibabaWanx21T2iTurboResource, type AlibabaWanx21T2vPlusParams, type AlibabaWanx21T2vPlusResource, type AlibabaWanx21T2vTurboParams, type AlibabaWanx21T2vTurboResource, type AlibabaWanx22I2vFlashParams, type AlibabaWanx22I2vFlashResource, type AlibabaWanx22I2vPlusParams, type AlibabaWanx22I2vPlusResource, type AlibabaWanx22T2vPlusParams, type AlibabaWanx22T2vPlusResource, type AlibabaWanx25I2vPreviewParams, type AlibabaWanx25I2vPreviewResource, type AlibabaWanx25T2vPreviewParams, type AlibabaWanx25T2vPreviewResource, type AlibabaWanx26I2vParams, type AlibabaWanx26I2vResource, type AlibabaWanx26ReferenceParams, type AlibabaWanx26ReferenceResource, type AlibabaWanx26T2vParams, type AlibabaWanx26T2vResource, type AppGenerationInput, type AppGenerationParams, type AppGenerationResource, type AppGenerationResult, type AppSearchParams, type AppSearchResponse, type BlackforestlabsFlux11ProParams, type BlackforestlabsFlux11ProResource, type BlackforestlabsFlux1ProParams, type BlackforestlabsFlux1ProResource, type BlackforestlabsFlux2FlexEditParams, type BlackforestlabsFlux2FlexEditResource, type BlackforestlabsFlux2FlexParams, type BlackforestlabsFlux2FlexResource, type BlackforestlabsFlux2ProEditParams, type BlackforestlabsFlux2ProEditResource, type BlackforestlabsFlux2ProParams, type BlackforestlabsFlux2ProResource, type BlackforestlabsFluxKontextMaxParams, type BlackforestlabsFluxKontextMaxResource, type BlackforestlabsFluxKontextProParams, type BlackforestlabsFluxKontextProResource, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionChunkChoice, type ChatCompletionChunkDelta, type ChatCompletionResponse, type ChatCompletionUsage, type ChatMessage, type ChatMessageRole, type ElevenlabsTtsGeneratorParams, type ElevenlabsTtsGeneratorResource, type GoogleGemini3ProImageParams, type GoogleGemini3ProImageResource, type GoogleGeminiImageParams, type GoogleGeminiImageResource, type GoogleImagen4FastGenerateParams, type GoogleImagen4FastGenerateResource, type GoogleImagen4GenerateParams, type GoogleImagen4GenerateResource, type GoogleImagen4UltraGenerateParams, type GoogleImagen4UltraGenerateResource, type GoogleVeo20Generate001Params, type GoogleVeo20Generate001Resource, type GoogleVeo20GenerateExpParams, type GoogleVeo20GenerateExpResource, type GoogleVeo20GeneratePreviewParams, type GoogleVeo20GeneratePreviewResource, type GoogleVeo30FastGenerate001Params, type GoogleVeo30FastGenerate001Resource, type GoogleVeo30Generate001Params, type GoogleVeo30Generate001Resource, type GoogleVeo31Params, type GoogleVeo31Resource, type InitOptions, type KlingAvatarParams, type KlingAvatarResource, type KlingDurationExtensionParams, type KlingDurationExtensionResource, type KlingEffectsMultiV15Params, type KlingEffectsMultiV15Resource, type KlingEffectsMultiV16Params, type KlingEffectsMultiV16Resource, type KlingEffectsMultiV1Params, type KlingEffectsMultiV1Resource, type KlingEffectsSingleParams, type KlingEffectsSingleResource, type KlingLipsyncParams, type KlingLipsyncResource, type KlingOmniImageParams, type KlingOmniImageResource, type KlingOmniVideoParams, type KlingOmniVideoResource, type KlingV15I2vParams, type KlingV15I2vResource, type KlingV15Params, type KlingV15Resource, type KlingV16I2vParams, type KlingV16I2vResource, type KlingV16Params, type KlingV16Resource, type KlingV1I2vParams, type KlingV1I2vResource, type KlingV1Params, type KlingV1Resource, type KlingV21I2vParams, type KlingV21I2vResource, type KlingV21MasterI2vParams, type KlingV21MasterI2vResource, type KlingV21MasterParams, type KlingV21MasterResource, type KlingV25TurboI2vParams, type KlingV25TurboI2vResource, type KlingV25TurboParams, type KlingV25TurboResource, type KlingV26I2vParams, type KlingV26I2vResource, type KlingV26Params, type KlingV26Resource, type KlingV2MasterI2vParams, type KlingV2MasterI2vResource, type KlingV2MasterParams, type KlingV2MasterResource, type LlmChatCompletionsParams, type MicrosoftGptImage15Params, type MicrosoftGptImage15Resource, type MicrosoftGptImage1Params, type MicrosoftGptImage1Resource, type MicrosoftSora2Params, type MicrosoftSora2Resource, type MinimaxHailuo02I2vParams, type MinimaxHailuo02I2vResource, type MinimaxHailuo02Params, type MinimaxHailuo02Resource, type MinimaxHailuo23FastI2vParams, type MinimaxHailuo23FastI2vResource, type MinimaxHailuo23I2vParams, type MinimaxHailuo23I2vResource, type MinimaxI2v01DirectorParams, type MinimaxI2v01DirectorResource, type MinimaxI2v01LiveParams, type MinimaxI2v01LiveResource, type MinimaxI2v01Params, type MinimaxI2v01Resource, type MinimaxT2aParams, type MinimaxT2aResource, type MinimaxT2v01DirectorParams, type MinimaxT2v01DirectorResource, type MinimaxT2v01Params, type MinimaxT2v01Resource, type PixverseV35I2vParams, type PixverseV35I2vResource, type PixverseV35T2vParams, type PixverseV35T2vResource, type PixverseV35TransitionParams, type PixverseV35TransitionResource, type PixverseV45I2vParams, type PixverseV45I2vResource, type PixverseV45T2vParams, type PixverseV45T2vResource, type PixverseV45TransitionParams, type PixverseV45TransitionResource, type PixverseV4I2vParams, type PixverseV4I2vResource, type PixverseV4T2vParams, type PixverseV4T2vResource, type PixverseV4TransitionParams, type PixverseV4TransitionResource, type PixverseV55I2vParams, type PixverseV55I2vResource, type PixverseV55T2vParams, type PixverseV55T2vResource, type PixverseV55TransitionParams, type PixverseV55TransitionResource, type PixverseV5I2vParams, type PixverseV5I2vResource, type PixverseV5T2vParams, type PixverseV5T2vResource, type PixverseV5TransitionParams, type PixverseV5TransitionResource, type PollingOptions, type RunwayGen3aTurboI2vParams, type RunwayGen3aTurboI2vResource, SeacloudClient, type SeacloudConfig, SeacloudError, type TaskError, type TaskResult, type TaskStatus, type TemplateSpec, type TemplateSpecConstraint, type TemplateSpecInput, type TemplateSpecOutput, type TemplateSpecsParams, type TemplateSpecsResponse, type TencentHunyuan3dParams, type TencentHunyuan3dProParams, type TencentHunyuan3dProResource, type TencentHunyuan3dRapidParams, type TencentHunyuan3dRapidResource, type TencentHunyuan3dResource, type TencentImageCreation3Params, type TencentImageCreation3Resource, type TencentMpsSuperResolutionParams, type TencentMpsSuperResolutionResource, type Vidu15I2vParams, type Vidu15I2vResource, type Vidu15Params, type Vidu15Resource, type Vidu20I2vParams, type Vidu20I2vResource, type ViduQ1I2vParams, type ViduQ1I2vResource, type ViduQ1Params, type ViduQ1Resource, type ViduQ2Params, type ViduQ2Resource, type ViduTemplateParams, type ViduTemplateResource, type ViduTemplateV2Params, type ViduTemplateV2Resource, type VolcesJimeng30Params, type VolcesJimeng30Resource, type VolcesJimeng31Params, type VolcesJimeng31Resource, type VolcesJimengDreamActorM1Params, type VolcesJimengDreamActorM1Resource, type VolcesJimengI2i30Params, type VolcesJimengI2i30Resource, type VolcesRealmanAvatarImitatorV2vParams, type VolcesRealmanAvatarImitatorV2vResource, type VolcesRealmanAvatarPictureOmniV15Params, type VolcesRealmanAvatarPictureOmniV15Resource, type VolcesRealmanAvatarPictureOmniV2Params, type VolcesRealmanAvatarPictureOmniV2Resource, type VolcesSeed3dParams, type VolcesSeed3dResource, type VolcesSeedance30I2vParams, type VolcesSeedance30I2vResource, type VolcesSeedance30Params, type VolcesSeedance30ProParams, type VolcesSeedance30ProResource, type VolcesSeedance30Resource, type VolcesSeedanceProFastParams, type VolcesSeedanceProFastResource, type VolcesSeededit20Params, type VolcesSeededit20Resource, type VolcesSeededit30I2iParams, type VolcesSeededit30I2iResource, type VolcesSeededit30Params, type VolcesSeededit30Resource, type VolcesSeededit3dStyleParams, type VolcesSeededit3dStyleResource, type VolcesSeededitMultiIpParams, type VolcesSeededitMultiIpResource, type VolcesSeededitMultiStyleParams, type VolcesSeededitMultiStyleResource, type VolcesSeededitPortraitParams, type VolcesSeededitPortraitResource, type VolcesSeededitSingleIpParams, type VolcesSeededitSingleIpResource, type VolcesSeedream30Params, type VolcesSeedream30Resource, type VolcesSeedream40Params, type VolcesSeedream40Resource, type VolcesSeedream45I2iParams, type VolcesSeedream45I2iResource, type VolcesSeedream45MultiBlendParams, type VolcesSeedream45MultiBlendResource, type VolcesSeedream45Params, type VolcesSeedream45Resource, type VolcesSubjectDetectionParams, type VolcesSubjectDetectionResource, type VolcesSubjectRecognitionParams, type VolcesSubjectRecognitionResource, agentChatCompletions, alibabaAnimateAnyoneDetect, alibabaAnimateAnyoneTemplate, alibabaAnimateAnyoneVideo, alibabaQianwenImage, alibabaWan22T2iFlash, alibabaWan22T2iPlus, alibabaWan25I2iPreview, alibabaWan25T2iPreview, alibabaWanx20T2iTurbo, alibabaWanx21I2vPlus, alibabaWanx21I2vTurbo, alibabaWanx21T2iPlus, alibabaWanx21T2iTurbo, alibabaWanx21T2vPlus, alibabaWanx21T2vTurbo, alibabaWanx22I2vFlash, alibabaWanx22I2vPlus, alibabaWanx22T2vPlus, alibabaWanx25I2vPreview, alibabaWanx25T2vPreview, alibabaWanx26I2v, alibabaWanx26Reference, alibabaWanx26T2v, appGeneration, appSearch, blackforestlabsFlux11Pro, blackforestlabsFlux1Pro, blackforestlabsFlux2Flex, blackforestlabsFlux2FlexEdit, blackforestlabsFlux2Pro, blackforestlabsFlux2ProEdit, blackforestlabsFluxKontextMax, blackforestlabsFluxKontextPro, createAndWaitTask, createAudioMessage, createConfig, createImageMessage, createTextMessage, createTool, createVideoMessage, elevenlabsTtsGenerator, getClient, getDefaultPollingOptions, googleGemini3ProImage, googleGeminiImage, googleImagen4FastGenerate, googleImagen4Generate, googleImagen4UltraGenerate, googleVeo20Generate001, googleVeo20GenerateExp, googleVeo20GeneratePreview, googleVeo30FastGenerate001, googleVeo30Generate001, googleVeo31, initSeacloud, klingAvatar, klingDurationExtension, klingEffectsMultiV1, klingEffectsMultiV15, klingEffectsMultiV16, klingEffectsSingle, klingLipsync, klingOmniImage, klingOmniVideo, klingV1, klingV15, klingV15I2v, klingV16, klingV16I2v, klingV1I2v, klingV21I2v, klingV21Master, klingV21MasterI2v, klingV25Turbo, klingV25TurboI2v, klingV26, klingV26I2v, klingV2Master, klingV2MasterI2v, llmChatCompletions, microsoftGptImage1, microsoftGptImage15, microsoftSora2, minimaxHailuo02, minimaxHailuo02I2v, minimaxHailuo23FastI2v, minimaxHailuo23I2v, minimaxI2v01, minimaxI2v01Director, minimaxI2v01Live, minimaxT2a, minimaxT2v01, minimaxT2v01Director, pixverseV35I2v, pixverseV35T2v, pixverseV35Transition, pixverseV45I2v, pixverseV45T2v, pixverseV45Transition, pixverseV4I2v, pixverseV4T2v, pixverseV4Transition, pixverseV55I2v, pixverseV55T2v, pixverseV55Transition, pixverseV5I2v, pixverseV5T2v, pixverseV5Transition, pollTaskUntilComplete, resetConfig, runwayGen3aTurboI2v, setDefaultPollingOptions, templateSpecs, tencentHunyuan3d, tencentHunyuan3dPro, tencentHunyuan3dRapid, tencentImageCreation3, tencentMpsSuperResolution, validateConfig, vidu15, vidu15I2v, vidu20I2v, viduQ1, viduQ1I2v, viduQ2, viduTemplate, viduTemplateV2, volcesJimeng30, volcesJimeng31, volcesJimengDreamActorM1, volcesJimengI2i30, volcesRealmanAvatarImitatorV2v, volcesRealmanAvatarPictureOmniV15, volcesRealmanAvatarPictureOmniV2, volcesSeed3d, volcesSeedance30, volcesSeedance30I2v, volcesSeedance30Pro, volcesSeedanceProFast, volcesSeededit20, volcesSeededit30, volcesSeededit30I2i, volcesSeededit3dStyle, volcesSeededitMultiIp, volcesSeededitMultiStyle, volcesSeededitPortrait, volcesSeededitSingleIp, volcesSeedream30, volcesSeedream40, volcesSeedream45, volcesSeedream45I2i, volcesSeedream45MultiBlend, volcesSubjectDetection, volcesSubjectRecognition };
|
package/dist/index.js
CHANGED
|
@@ -9,51 +9,7 @@ var SeacloudError = class extends Error {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
// src/core/config.ts
|
|
12
|
-
function
|
|
13
|
-
try {
|
|
14
|
-
return typeof globalThis.window !== "undefined" && globalThis.window.self !== globalThis.window.top;
|
|
15
|
-
} catch (e) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async function getTokenFromParent(timeout = 5e3) {
|
|
20
|
-
if (!isInIframe()) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return new Promise((resolve) => {
|
|
24
|
-
const messageHandler = (event) => {
|
|
25
|
-
if (event.data && event.data.type === "seaverse:token") {
|
|
26
|
-
cleanup();
|
|
27
|
-
const token = event.data.payload?.accessToken;
|
|
28
|
-
resolve(token || null);
|
|
29
|
-
} else if (event.data && event.data.type === "seaverse:error") {
|
|
30
|
-
cleanup();
|
|
31
|
-
console.warn("[SeaCloud SDK] Error getting token from parent:", event.data.error);
|
|
32
|
-
resolve(null);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const timeoutId = setTimeout(() => {
|
|
36
|
-
cleanup();
|
|
37
|
-
resolve(null);
|
|
38
|
-
}, timeout);
|
|
39
|
-
const cleanup = () => {
|
|
40
|
-
clearTimeout(timeoutId);
|
|
41
|
-
globalThis.window.removeEventListener("message", messageHandler);
|
|
42
|
-
};
|
|
43
|
-
globalThis.window.addEventListener("message", messageHandler);
|
|
44
|
-
try {
|
|
45
|
-
globalThis.window.parent.postMessage(
|
|
46
|
-
{ type: "seaverse:get_token" },
|
|
47
|
-
"*"
|
|
48
|
-
// 允许任何源,支持跨域场景
|
|
49
|
-
);
|
|
50
|
-
} catch (e) {
|
|
51
|
-
cleanup();
|
|
52
|
-
resolve(null);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
async function getApiToken(providedApiKey) {
|
|
12
|
+
function getApiToken(providedApiKey) {
|
|
57
13
|
if (providedApiKey) {
|
|
58
14
|
return providedApiKey;
|
|
59
15
|
}
|
|
@@ -69,27 +25,23 @@ async function getApiToken(providedApiKey) {
|
|
|
69
25
|
if (typeof process !== "undefined" && process.env?.API_SERVICE_TOKEN) {
|
|
70
26
|
return process.env.API_SERVICE_TOKEN;
|
|
71
27
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return parentToken;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return "";
|
|
28
|
+
throw new Error(
|
|
29
|
+
'SeaCloud SDK: No API token found. Please ensure token is available in localStorage.getItem("auth_token") (browser) or process.env.API_SERVICE_TOKEN (Node.js), or initialize with initSeacloud({ apiKey: "your-token" }).'
|
|
30
|
+
);
|
|
79
31
|
}
|
|
80
32
|
function createConfig(options = {}) {
|
|
81
|
-
const apiKey = options.apiKey;
|
|
33
|
+
const apiKey = getApiToken(options.apiKey);
|
|
82
34
|
const baseUrl = options.baseUrl || (typeof process !== "undefined" ? process.env?.SEACLOUD_BASE_URL : void 0) || "https://proxy-rs.seaverse.ai";
|
|
83
35
|
const fetchImpl = options.fetch || (globalThis.fetch ? globalThis.fetch.bind(globalThis) : void 0);
|
|
84
36
|
if (!fetchImpl) {
|
|
85
37
|
throw new Error("fetch is not available. Please provide a fetch implementation in config or upgrade to Node.js 18+");
|
|
86
38
|
}
|
|
87
39
|
return {
|
|
88
|
-
apiKey
|
|
89
|
-
// 提供默认空字符串,实际请求时会动态获取
|
|
40
|
+
apiKey,
|
|
90
41
|
baseUrl,
|
|
91
42
|
fetch: fetchImpl,
|
|
92
|
-
timeout: options.timeout || 3e4
|
|
43
|
+
timeout: options.timeout || 3e4,
|
|
44
|
+
xProject: options.xProject || "SeaVerse"
|
|
93
45
|
};
|
|
94
46
|
}
|
|
95
47
|
function validateConfig(config) {
|
|
@@ -131,7 +83,7 @@ var SeacloudClient = class {
|
|
|
131
83
|
*/
|
|
132
84
|
async createTask(endpoint, body) {
|
|
133
85
|
const url = `${this.config.baseUrl}${endpoint}`;
|
|
134
|
-
const currentToken =
|
|
86
|
+
const currentToken = getApiToken(this.providedApiKey);
|
|
135
87
|
const controller = new AbortController();
|
|
136
88
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
137
89
|
try {
|
|
@@ -178,7 +130,7 @@ var SeacloudClient = class {
|
|
|
178
130
|
*/
|
|
179
131
|
async getTaskStatus(endpoint, taskId) {
|
|
180
132
|
const url = `${this.config.baseUrl}${endpoint}/task/${taskId}`;
|
|
181
|
-
const currentToken =
|
|
133
|
+
const currentToken = getApiToken(this.providedApiKey);
|
|
182
134
|
const controller = new AbortController();
|
|
183
135
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
184
136
|
try {
|
|
@@ -249,7 +201,8 @@ function initSeacloud(apiKeyOrConfig, options) {
|
|
|
249
201
|
globalConfig.client = new SeacloudClient({
|
|
250
202
|
apiKey: apiKey || "",
|
|
251
203
|
baseUrl: config.baseUrl,
|
|
252
|
-
timeout: config.timeout
|
|
204
|
+
timeout: config.timeout,
|
|
205
|
+
xProject: config.xProject
|
|
253
206
|
});
|
|
254
207
|
if (config.intervalMs !== void 0) {
|
|
255
208
|
globalConfig.defaultPollingOptions.intervalMs = config.intervalMs;
|
|
@@ -333,12 +286,6 @@ async function createAndWaitTask(client, endpoint, body, options = {}) {
|
|
|
333
286
|
return pollTaskUntilComplete(client, endpoint, task.id, options);
|
|
334
287
|
}
|
|
335
288
|
|
|
336
|
-
// src/core/index.ts
|
|
337
|
-
async function getTaskStatus(endpoint, taskId) {
|
|
338
|
-
const client = getClient();
|
|
339
|
-
return client.getTaskStatus(endpoint, taskId);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
289
|
// src/api/alibaba_animate_anyone_detect.ts
|
|
343
290
|
async function alibabaAnimateAnyoneDetect(params) {
|
|
344
291
|
const client = getClient();
|
|
@@ -3883,14 +3830,17 @@ async function appSearch(params) {
|
|
|
3883
3830
|
const timeoutId = setTimeout(() => controller.abort(), config.timeout);
|
|
3884
3831
|
try {
|
|
3885
3832
|
const requestId = `req-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
3833
|
+
const headers = {
|
|
3834
|
+
"Content-Type": "application/json",
|
|
3835
|
+
"Authorization": `Bearer ${config.apiKey}`,
|
|
3836
|
+
"X-Request-Id": requestId
|
|
3837
|
+
};
|
|
3838
|
+
if (config.xProject) {
|
|
3839
|
+
headers["X-Project"] = config.xProject;
|
|
3840
|
+
}
|
|
3886
3841
|
const response = await config.fetch(url, {
|
|
3887
3842
|
method: "POST",
|
|
3888
|
-
headers
|
|
3889
|
-
"Content-Type": "application/json",
|
|
3890
|
-
"Authorization": `Bearer ${config.apiKey}`,
|
|
3891
|
-
"X-Request-Id": requestId,
|
|
3892
|
-
"X-Project": "KIIRA"
|
|
3893
|
-
},
|
|
3843
|
+
headers,
|
|
3894
3844
|
body: JSON.stringify(params),
|
|
3895
3845
|
signal: controller.signal
|
|
3896
3846
|
});
|
|
@@ -5136,7 +5086,6 @@ async function llmChatCompletions(params) {
|
|
|
5136
5086
|
const client = getClient();
|
|
5137
5087
|
const config = client.getConfig();
|
|
5138
5088
|
const url = `${config.baseUrl}/llm/chat/completions`;
|
|
5139
|
-
const token = await getApiToken(config.apiKey);
|
|
5140
5089
|
const controller = new AbortController();
|
|
5141
5090
|
const timeoutId = setTimeout(() => controller.abort(), config.timeout);
|
|
5142
5091
|
try {
|
|
@@ -5144,7 +5093,7 @@ async function llmChatCompletions(params) {
|
|
|
5144
5093
|
method: "POST",
|
|
5145
5094
|
headers: {
|
|
5146
5095
|
"Content-Type": "application/json",
|
|
5147
|
-
"Authorization": `Bearer ${
|
|
5096
|
+
"Authorization": `Bearer ${config.apiKey}`
|
|
5148
5097
|
},
|
|
5149
5098
|
body: JSON.stringify(params),
|
|
5150
5099
|
signal: controller.signal
|
|
@@ -5230,14 +5179,16 @@ async function agentChatCompletions(params) {
|
|
|
5230
5179
|
const controller = new AbortController();
|
|
5231
5180
|
const timeoutId = setTimeout(() => controller.abort(), config.timeout);
|
|
5232
5181
|
try {
|
|
5182
|
+
const headers = {
|
|
5183
|
+
"Content-Type": "application/json",
|
|
5184
|
+
"Authorization": `Bearer ${config.apiKey}`
|
|
5185
|
+
};
|
|
5186
|
+
if (config.xProject) {
|
|
5187
|
+
headers["X-Project"] = config.xProject;
|
|
5188
|
+
}
|
|
5233
5189
|
const response = await config.fetch(url, {
|
|
5234
5190
|
method: "POST",
|
|
5235
|
-
headers
|
|
5236
|
-
"Content-Type": "application/json",
|
|
5237
|
-
"Authorization": `Bearer ${config.apiKey}`,
|
|
5238
|
-
"X-Project": "SeaArt"
|
|
5239
|
-
// Required header for agent API
|
|
5240
|
-
},
|
|
5191
|
+
headers,
|
|
5241
5192
|
body: JSON.stringify(requestBody),
|
|
5242
5193
|
signal: controller.signal
|
|
5243
5194
|
});
|
|
@@ -5467,73 +5418,6 @@ async function appGeneration(params) {
|
|
|
5467
5418
|
return result;
|
|
5468
5419
|
}
|
|
5469
5420
|
|
|
5470
|
-
|
|
5471
|
-
async function scan(params) {
|
|
5472
|
-
if (!params.uri && !params.img_base64) {
|
|
5473
|
-
throw new SeacloudError("\u5FC5\u987B\u63D0\u4F9B uri \u6216 img_base64 \u4E2D\u7684\u81F3\u5C11\u4E00\u4E2A\u53C2\u6570");
|
|
5474
|
-
}
|
|
5475
|
-
if (params.is_video === 1 && params.img_base64) {
|
|
5476
|
-
throw new SeacloudError("\u89C6\u9891\u68C0\u6D4B\u4E0D\u652F\u6301 base64 \u8F93\u5165\uFF0C\u5FC5\u987B\u4F7F\u7528 uri \u53C2\u6570");
|
|
5477
|
-
}
|
|
5478
|
-
if (!params.risk_types || params.risk_types.length === 0) {
|
|
5479
|
-
throw new SeacloudError("\u5FC5\u987B\u63D0\u4F9B\u81F3\u5C11\u4E00\u4E2A\u98CE\u9669\u7C7B\u578B");
|
|
5480
|
-
}
|
|
5481
|
-
const client = getClient();
|
|
5482
|
-
const config = client.getConfig();
|
|
5483
|
-
const url = `${config.baseUrl}/scan`;
|
|
5484
|
-
const token = await getApiToken(config.apiKey);
|
|
5485
|
-
const controller = new AbortController();
|
|
5486
|
-
const timeoutId = setTimeout(() => controller.abort(), config.timeout);
|
|
5487
|
-
try {
|
|
5488
|
-
const response = await config.fetch(url, {
|
|
5489
|
-
method: "POST",
|
|
5490
|
-
headers: {
|
|
5491
|
-
"Content-Type": "application/json",
|
|
5492
|
-
"Authorization": `Bearer ${token}`
|
|
5493
|
-
},
|
|
5494
|
-
body: JSON.stringify(params),
|
|
5495
|
-
signal: controller.signal
|
|
5496
|
-
});
|
|
5497
|
-
clearTimeout(timeoutId);
|
|
5498
|
-
if (!response.ok) {
|
|
5499
|
-
const errorBody = await response.text();
|
|
5500
|
-
throw new SeacloudError(
|
|
5501
|
-
`HTTP ${response.status}: ${errorBody}`,
|
|
5502
|
-
response.status,
|
|
5503
|
-
errorBody
|
|
5504
|
-
);
|
|
5505
|
-
}
|
|
5506
|
-
const responseData = await response.json();
|
|
5507
|
-
let result;
|
|
5508
|
-
if (responseData.success !== void 0 && responseData.data) {
|
|
5509
|
-
result = responseData.data;
|
|
5510
|
-
} else {
|
|
5511
|
-
result = responseData;
|
|
5512
|
-
}
|
|
5513
|
-
if (!result.ok) {
|
|
5514
|
-
throw new SeacloudError(
|
|
5515
|
-
`\u5185\u5BB9\u5B89\u5168\u68C0\u6D4B\u4E1A\u52A1\u9519\u8BEF: ${result.error || "\u672A\u77E5\u9519\u8BEF"}`,
|
|
5516
|
-
void 0,
|
|
5517
|
-
result
|
|
5518
|
-
);
|
|
5519
|
-
}
|
|
5520
|
-
return result;
|
|
5521
|
-
} catch (error) {
|
|
5522
|
-
clearTimeout(timeoutId);
|
|
5523
|
-
if (error instanceof SeacloudError) {
|
|
5524
|
-
throw error;
|
|
5525
|
-
}
|
|
5526
|
-
if (error.name === "AbortError") {
|
|
5527
|
-
throw new SeacloudError(`Request timeout after ${config.timeout}ms`);
|
|
5528
|
-
}
|
|
5529
|
-
throw new SeacloudError(
|
|
5530
|
-
`Request failed: ${error.message}`,
|
|
5531
|
-
void 0,
|
|
5532
|
-
error
|
|
5533
|
-
);
|
|
5534
|
-
}
|
|
5535
|
-
}
|
|
5536
|
-
|
|
5537
|
-
export { SeacloudClient, SeacloudError, agentChatCompletions, alibabaAnimateAnyoneDetect, alibabaAnimateAnyoneTemplate, alibabaAnimateAnyoneVideo, alibabaQianwenImage, alibabaWan22T2iFlash, alibabaWan22T2iPlus, alibabaWan25I2iPreview, alibabaWan25T2iPreview, alibabaWanx20T2iTurbo, alibabaWanx21I2vPlus, alibabaWanx21I2vTurbo, alibabaWanx21T2iPlus, alibabaWanx21T2iTurbo, alibabaWanx21T2vPlus, alibabaWanx21T2vTurbo, alibabaWanx22I2vFlash, alibabaWanx22I2vPlus, alibabaWanx22T2vPlus, alibabaWanx25I2vPreview, alibabaWanx25T2vPreview, alibabaWanx26I2v, alibabaWanx26Reference, alibabaWanx26T2v, appGeneration, appSearch, blackforestlabsFlux11Pro, blackforestlabsFlux1Pro, blackforestlabsFlux2Flex, blackforestlabsFlux2FlexEdit, blackforestlabsFlux2Pro, blackforestlabsFlux2ProEdit, blackforestlabsFluxKontextMax, blackforestlabsFluxKontextPro, createAndWaitTask, createAudioMessage, createConfig, createImageMessage, createTextMessage, createTool, createVideoMessage, elevenlabsTtsGenerator, getClient, getDefaultPollingOptions, getTaskStatus, googleGemini3ProImage, googleGeminiImage, googleImagen4FastGenerate, googleImagen4Generate, googleImagen4UltraGenerate, googleVeo20Generate001, googleVeo20GenerateExp, googleVeo20GeneratePreview, googleVeo30FastGenerate001, googleVeo30Generate001, googleVeo31, initSeacloud, klingAvatar, klingDurationExtension, klingEffectsMultiV1, klingEffectsMultiV15, klingEffectsMultiV16, klingEffectsSingle, klingLipsync, klingOmniImage, klingOmniVideo, klingV1, klingV15, klingV15I2v, klingV16, klingV16I2v, klingV1I2v, klingV21I2v, klingV21Master, klingV21MasterI2v, klingV25Turbo, klingV25TurboI2v, klingV26, klingV26I2v, klingV2Master, klingV2MasterI2v, llmChatCompletions, microsoftGptImage1, microsoftGptImage15, microsoftSora2, minimaxHailuo02, minimaxHailuo02I2v, minimaxHailuo23FastI2v, minimaxHailuo23I2v, minimaxI2v01, minimaxI2v01Director, minimaxI2v01Live, minimaxT2a, minimaxT2v01, minimaxT2v01Director, pixverseV35I2v, pixverseV35T2v, pixverseV35Transition, pixverseV45I2v, pixverseV45T2v, pixverseV45Transition, pixverseV4I2v, pixverseV4T2v, pixverseV4Transition, pixverseV55I2v, pixverseV55T2v, pixverseV55Transition, pixverseV5I2v, pixverseV5T2v, pixverseV5Transition, pollTaskUntilComplete, resetConfig, runwayGen3aTurboI2v, scan, setDefaultPollingOptions, templateSpecs, tencentHunyuan3d, tencentHunyuan3dPro, tencentHunyuan3dRapid, tencentImageCreation3, tencentMpsSuperResolution, validateConfig, vidu15, vidu15I2v, vidu20I2v, viduQ1, viduQ1I2v, viduQ2, viduTemplate, viduTemplateV2, volcesJimeng30, volcesJimeng31, volcesJimengDreamActorM1, volcesJimengI2i30, volcesRealmanAvatarImitatorV2v, volcesRealmanAvatarPictureOmniV15, volcesRealmanAvatarPictureOmniV2, volcesSeed3d, volcesSeedance30, volcesSeedance30I2v, volcesSeedance30Pro, volcesSeedanceProFast, volcesSeededit20, volcesSeededit30, volcesSeededit30I2i, volcesSeededit3dStyle, volcesSeededitMultiIp, volcesSeededitMultiStyle, volcesSeededitPortrait, volcesSeededitSingleIp, volcesSeedream30, volcesSeedream40, volcesSeedream45, volcesSeedream45I2i, volcesSeedream45MultiBlend, volcesSubjectDetection, volcesSubjectRecognition };
|
|
5421
|
+
export { SeacloudClient, SeacloudError, agentChatCompletions, alibabaAnimateAnyoneDetect, alibabaAnimateAnyoneTemplate, alibabaAnimateAnyoneVideo, alibabaQianwenImage, alibabaWan22T2iFlash, alibabaWan22T2iPlus, alibabaWan25I2iPreview, alibabaWan25T2iPreview, alibabaWanx20T2iTurbo, alibabaWanx21I2vPlus, alibabaWanx21I2vTurbo, alibabaWanx21T2iPlus, alibabaWanx21T2iTurbo, alibabaWanx21T2vPlus, alibabaWanx21T2vTurbo, alibabaWanx22I2vFlash, alibabaWanx22I2vPlus, alibabaWanx22T2vPlus, alibabaWanx25I2vPreview, alibabaWanx25T2vPreview, alibabaWanx26I2v, alibabaWanx26Reference, alibabaWanx26T2v, appGeneration, appSearch, blackforestlabsFlux11Pro, blackforestlabsFlux1Pro, blackforestlabsFlux2Flex, blackforestlabsFlux2FlexEdit, blackforestlabsFlux2Pro, blackforestlabsFlux2ProEdit, blackforestlabsFluxKontextMax, blackforestlabsFluxKontextPro, createAndWaitTask, createAudioMessage, createConfig, createImageMessage, createTextMessage, createTool, createVideoMessage, elevenlabsTtsGenerator, getClient, getDefaultPollingOptions, googleGemini3ProImage, googleGeminiImage, googleImagen4FastGenerate, googleImagen4Generate, googleImagen4UltraGenerate, googleVeo20Generate001, googleVeo20GenerateExp, googleVeo20GeneratePreview, googleVeo30FastGenerate001, googleVeo30Generate001, googleVeo31, initSeacloud, klingAvatar, klingDurationExtension, klingEffectsMultiV1, klingEffectsMultiV15, klingEffectsMultiV16, klingEffectsSingle, klingLipsync, klingOmniImage, klingOmniVideo, klingV1, klingV15, klingV15I2v, klingV16, klingV16I2v, klingV1I2v, klingV21I2v, klingV21Master, klingV21MasterI2v, klingV25Turbo, klingV25TurboI2v, klingV26, klingV26I2v, klingV2Master, klingV2MasterI2v, llmChatCompletions, microsoftGptImage1, microsoftGptImage15, microsoftSora2, minimaxHailuo02, minimaxHailuo02I2v, minimaxHailuo23FastI2v, minimaxHailuo23I2v, minimaxI2v01, minimaxI2v01Director, minimaxI2v01Live, minimaxT2a, minimaxT2v01, minimaxT2v01Director, pixverseV35I2v, pixverseV35T2v, pixverseV35Transition, pixverseV45I2v, pixverseV45T2v, pixverseV45Transition, pixverseV4I2v, pixverseV4T2v, pixverseV4Transition, pixverseV55I2v, pixverseV55T2v, pixverseV55Transition, pixverseV5I2v, pixverseV5T2v, pixverseV5Transition, pollTaskUntilComplete, resetConfig, runwayGen3aTurboI2v, setDefaultPollingOptions, templateSpecs, tencentHunyuan3d, tencentHunyuan3dPro, tencentHunyuan3dRapid, tencentImageCreation3, tencentMpsSuperResolution, validateConfig, vidu15, vidu15I2v, vidu20I2v, viduQ1, viduQ1I2v, viduQ2, viduTemplate, viduTemplateV2, volcesJimeng30, volcesJimeng31, volcesJimengDreamActorM1, volcesJimengI2i30, volcesRealmanAvatarImitatorV2v, volcesRealmanAvatarPictureOmniV15, volcesRealmanAvatarPictureOmniV2, volcesSeed3d, volcesSeedance30, volcesSeedance30I2v, volcesSeedance30Pro, volcesSeedanceProFast, volcesSeededit20, volcesSeededit30, volcesSeededit30I2i, volcesSeededit3dStyle, volcesSeededitMultiIp, volcesSeededitMultiStyle, volcesSeededitPortrait, volcesSeededitSingleIp, volcesSeedream30, volcesSeedream40, volcesSeedream45, volcesSeedream45I2i, volcesSeedream45MultiBlend, volcesSubjectDetection, volcesSubjectRecognition };
|
|
5538
5422
|
//# sourceMappingURL=index.js.map
|
|
5539
5423
|
//# sourceMappingURL=index.js.map
|