seacloud-sdk 0.11.9 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -12167,6 +12167,13 @@ interface LlmChatCompletionsParams {
12167
12167
  * A unique identifier representing your end-user
12168
12168
  */
12169
12169
  user?: string;
12170
+ /**
12171
+ * Request timeout in milliseconds
12172
+ * Overrides the global timeout set in initSeacloud()
12173
+ * @default 30000 (from global config)
12174
+ * @example 60000 for 60 seconds timeout
12175
+ */
12176
+ timeout?: number;
12170
12177
  }
12171
12178
  /**
12172
12179
  * Usage statistics for the completion
@@ -12331,6 +12338,18 @@ interface ChatCompletionChunk {
12331
12338
  * console.log(response.choices[0].message.content);
12332
12339
  * ```
12333
12340
  *
12341
+ * @example With custom timeout
12342
+ * ```typescript
12343
+ * // Set 60 seconds timeout for this specific call
12344
+ * const response = await llmChatCompletions({
12345
+ * model: 'deepseek-v3.1',
12346
+ * messages: [
12347
+ * { role: 'user', content: 'Write a long article' }
12348
+ * ],
12349
+ * timeout: 60000 // 60 seconds
12350
+ * });
12351
+ * ```
12352
+ *
12334
12353
  * @param params Request parameters
12335
12354
  * @returns Chat completion response
12336
12355
  */
@@ -12650,6 +12669,14 @@ interface AgentChatCompletionsParams {
12650
12669
  * Top-p nucleus sampling (0-1)
12651
12670
  */
12652
12671
  top_p?: number;
12672
+ /**
12673
+ * Request timeout in milliseconds
12674
+ * Overrides the global timeout set in initSeacloud()
12675
+ * @default 30000 (from global config)
12676
+ * @recommended 120000 or more for agent operations with tool calls
12677
+ * @example 120000 for 120 seconds timeout
12678
+ */
12679
+ timeout?: number;
12653
12680
  }
12654
12681
  /**
12655
12682
  * Artifact (generated file)
package/dist/index.js CHANGED
@@ -290,7 +290,7 @@ async function initSeacloud(apiKeyOrConfig, options) {
290
290
  if (parentHost) {
291
291
  const isDevelopment = parentHost.includes("localhost") || parentHost.includes("127.0.0.1") || parentHost.includes(":3000") || parentHost.includes(":8080") || parentHost.includes("seaverse.dev");
292
292
  if (isDevelopment) {
293
- config.baseUrl = "https://proxy-rs-dev.seaverse.ai";
293
+ config.baseUrl = "https://proxy-rs.sg.seaverse.dev";
294
294
  console.log("[SeaCloud SDK] \u68C0\u6D4B\u5230\u5F00\u53D1\u73AF\u5883\uFF0C\u4F7F\u7528\u5F00\u53D1 baseUrl:", config.baseUrl);
295
295
  } else {
296
296
  config.baseUrl = "https://proxy-rs.seaverse.ai";
@@ -5335,8 +5335,9 @@ async function llmChatCompletions(params) {
5335
5335
  const config = client.getConfig();
5336
5336
  const url = `${config.baseUrl}/llm/chat/completions`;
5337
5337
  const token = await getApiToken(config.apiKey);
5338
+ const timeoutMs = params.timeout ?? config.timeout;
5338
5339
  const controller = new AbortController();
5339
- const timeoutId = setTimeout(() => controller.abort(), config.timeout);
5340
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
5340
5341
  try {
5341
5342
  const response = await config.fetch(url, {
5342
5343
  method: "POST",
@@ -5367,7 +5368,7 @@ async function llmChatCompletions(params) {
5367
5368
  throw error;
5368
5369
  }
5369
5370
  if (error.name === "AbortError") {
5370
- throw new SeacloudError(`Request timeout after ${config.timeout}ms`);
5371
+ throw new SeacloudError(`Request timeout after ${timeoutMs}ms`);
5371
5372
  }
5372
5373
  throw new SeacloudError(
5373
5374
  `Request failed: ${error.message}`,
@@ -5425,8 +5426,9 @@ async function agentChatCompletions(params) {
5425
5426
  stream: true
5426
5427
  // Always request SSE from API
5427
5428
  };
5429
+ const timeoutMs = params.timeout ?? config.timeout;
5428
5430
  const controller = new AbortController();
5429
- const timeoutId = setTimeout(() => controller.abort(), config.timeout);
5431
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
5430
5432
  try {
5431
5433
  const headers = {
5432
5434
  "Content-Type": "application/json",
@@ -5460,7 +5462,7 @@ async function agentChatCompletions(params) {
5460
5462
  throw error;
5461
5463
  }
5462
5464
  if (error.name === "AbortError") {
5463
- throw new SeacloudError(`Request timeout after ${config.timeout}ms`);
5465
+ throw new SeacloudError(`Request timeout after ${timeoutMs}ms`);
5464
5466
  }
5465
5467
  throw new SeacloudError(
5466
5468
  `Request failed: ${error.message}`,