@tencent-ai/cloud-agent-sdk 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1993,9 +1993,7 @@ var StreamableHttpClient = class {
1993
1993
  });
1994
1994
  await this.handleExtNotification(method, params);
1995
1995
  },
1996
- extMethod: async (method, params) => {
1997
- return await this.handleExtMethod(method, params);
1998
- }
1996
+ extMethod: async (method, params) => this.handleExtMethod(method, params)
1999
1997
  };
2000
1998
  }
2001
1999
  /**
@@ -2215,12 +2213,22 @@ var StreamableHttpClient = class {
2215
2213
  await this.extensionManager.handleNotification(method, params);
2216
2214
  }
2217
2215
  async handleExtMethod(method, params) {
2218
- if (method === ExtensionMethod.QUESTION) return this.questionManager.handleRequest(params);
2216
+ if (method === ExtensionMethod.QUESTION) {
2217
+ const response = await this.questionManager.handleRequest(params);
2218
+ if (response.outcome === "submitted" && response.answers) return { outcome: {
2219
+ outcome: "submitted",
2220
+ data: { answers: response.answers }
2221
+ } };
2222
+ else return { outcome: {
2223
+ outcome: "cancelled",
2224
+ reason: response.reason
2225
+ } };
2226
+ }
2219
2227
  this.options.logger?.warn(`Unknown extension method: ${method}`);
2220
- return {
2228
+ return { outcome: {
2221
2229
  outcome: "cancelled",
2222
2230
  reason: "unknown method"
2223
- };
2231
+ } };
2224
2232
  }
2225
2233
  ensureInitialized(operation) {
2226
2234
  if (this.state !== "initialized") throw new InvalidStateError(operation, this.state, ["initialized"]);
@@ -17299,6 +17307,28 @@ var CloudAgentProvider = class CloudAgentProvider {
17299
17307
  }
17300
17308
  }
17301
17309
  }
17310
+ /**
17311
+ * 获取支持的场景列表
17312
+ * API 端点: GET /console/as/support/scenes
17313
+ * 用于 Welcome 页面的 QuickActions 快捷操作
17314
+ *
17315
+ * @returns Promise<SupportScene[]> 支持的场景列表
17316
+ */
17317
+ async getSupportScenes() {
17318
+ try {
17319
+ const apiResponse = await httpService.get("/console/as/support/scenes");
17320
+ if (!apiResponse.data) {
17321
+ this.logger?.warn("[CloudAgentProvider] No data in support scenes response");
17322
+ return [];
17323
+ }
17324
+ const scenes = apiResponse.data.scenes || [];
17325
+ this.logger?.info(`[CloudAgentProvider] Retrieved ${scenes.length} support scenes`);
17326
+ return scenes;
17327
+ } catch (error) {
17328
+ this.logger?.error("[CloudAgentProvider] Failed to get support scenes:", error);
17329
+ return [];
17330
+ }
17331
+ }
17302
17332
  toAgentState(data) {
17303
17333
  const status = data.sessionStatus || data.status;
17304
17334
  return {
@@ -18302,17 +18332,17 @@ var AgentClient = class {
18302
18332
  };
18303
18333
  }
18304
18334
  },
18305
- getSupportPlugins: async () => {
18335
+ getSupportScenes: async () => {
18306
18336
  try {
18307
- if (this.provider && "getSupportPlugins" in this.provider && typeof this.provider.getSupportPlugins === "function") {
18308
- const result = await this.provider.getSupportPlugins();
18309
- this.logger?.info("Got support plugins", { count: result?.length ?? 0 });
18337
+ if (this.provider && "getSupportScenes" in this.provider && typeof this.provider.getSupportScenes === "function") {
18338
+ const result = await this.provider.getSupportScenes();
18339
+ this.logger?.info("Got support scenes", { count: result?.length ?? 0 });
18310
18340
  return result;
18311
18341
  }
18312
- this.logger?.warn("Provider does not support getSupportPlugins");
18342
+ this.logger?.warn("Provider does not support getSupportScenes");
18313
18343
  return [];
18314
18344
  } catch (error) {
18315
- this.logger?.error("Failed to get support plugins", error);
18345
+ this.logger?.error("Failed to get support scenes", error);
18316
18346
  return [];
18317
18347
  }
18318
18348
  },
@@ -18389,8 +18419,29 @@ let AccountStatus = /* @__PURE__ */ function(AccountStatus) {
18389
18419
  *
18390
18420
  * 封装与后端 API 的 HTTP 通信
18391
18421
  */
18392
- /** 获取当前域名的登录页面 URL */
18393
- const getLoginUrl = () => `${window.location.origin}/login`;
18422
+ /**
18423
+ * 判断当前是否在 SSO 域名下
18424
+ * SSO 域名格式: xxx.sso.copilot.tencent.com 或 xxx.sso.codebuddy.cn
18425
+ */
18426
+ const isSSODomain = () => {
18427
+ const { hostname } = window.location;
18428
+ return hostname.includes(".sso.copilot") || hostname.includes("sso.codebuddy.cn") || hostname.includes(".sso.copilot-staging") || hostname.includes(".staging-sso.codebuddy.cn");
18429
+ };
18430
+ /**
18431
+ * 获取登录页面 URL
18432
+ * - SSO 域名下需要跳转到对应的预发/生产域名
18433
+ * - 非 SSO 域名直接使用当前域名
18434
+ */
18435
+ const getLoginUrl = () => {
18436
+ const { hostname, protocol } = window.location;
18437
+ if (isSSODomain()) {
18438
+ const isCodebuddy = hostname.includes("codebuddy.cn");
18439
+ const isStaging = hostname.includes("staging");
18440
+ if (isCodebuddy) return isStaging ? `${protocol}//staging.codebuddy.cn/login` : `${protocol}//www.codebuddy.cn/login`;
18441
+ else return isStaging ? `${protocol}//staging-copilot.tencent.com/login` : `${protocol}//copilot.tencent.com/login`;
18442
+ }
18443
+ return `${window.location.origin}/login`;
18444
+ };
18394
18445
  /** 获取当前域名的账号选择页面 URL */
18395
18446
  const getSelectAccountUrl = () => `${window.location.origin}/login/select`;
18396
18447
  /** localStorage 中存储选中账号 ID 的 key */
@@ -18902,21 +18953,6 @@ var BackendProvider = class {
18902
18953
  return null;
18903
18954
  }
18904
18955
  }
18905
- /**
18906
- * 获取支持的插件列表
18907
- * API 端点: GET /console/as/support/plugins
18908
- * 用于 Welcome 页面的 QuickActions 快捷操作
18909
- */
18910
- async getSupportPlugins() {
18911
- try {
18912
- const result = await httpService.get("/console/as/support/plugins");
18913
- if (result?.code === 0 && result?.data?.plugins) return result.data.plugins;
18914
- return [];
18915
- } catch (error) {
18916
- console.error("[BackendProvider] getSupportPlugins error:", error);
18917
- return [];
18918
- }
18919
- }
18920
18956
  };
18921
18957
  /**
18922
18958
  * 创建 BackendProvider 实例
@@ -18928,6 +18964,12 @@ function createBackendProvider(config) {
18928
18964
  //#endregion
18929
18965
  //#region ../agent-provider/src/backend/ipc-backend-provider.ts
18930
18966
  /**
18967
+ * IPC Backend Provider 实现
18968
+ *
18969
+ * 通过 IWidgetChannel 与后端通信
18970
+ * 使用统一的消息格式: { type: 'backend', requestId, params: { type, params } }
18971
+ */
18972
+ /**
18931
18973
  * Backend 请求类型常量
18932
18974
  */
18933
18975
  const BACKEND_REQUEST_TYPES = {
@@ -18949,8 +18991,9 @@ const BACKEND_REQUEST_TYPES = {
18949
18991
  REVOKE_ALL: "backend:revoke-all",
18950
18992
  GET_FILE: "backend:get-file",
18951
18993
  RELOAD_WINDOW: "backend:reload-window",
18994
+ CLOSE_AGENT_MANAGER: "backend:close-agent-manager",
18952
18995
  BATCH_TOGGLE_PLUGINS: "backend:batch-toggle-plugins",
18953
- GET_SUPPORT_PLUGINS: "backend:get-support-plugins"
18996
+ GET_SUPPORT_SCENES: "backend:get-support-scenes"
18954
18997
  };
18955
18998
  /**
18956
18999
  * 生成唯一请求 ID
@@ -19231,6 +19274,19 @@ var IPCBackendProvider = class {
19231
19274
  }
19232
19275
  }
19233
19276
  /**
19277
+ * 关闭 Agent Manager 面板
19278
+ * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
19279
+ */
19280
+ async closeAgentManager() {
19281
+ this.log("Triggering close agent manager via IPC");
19282
+ try {
19283
+ await this.sendBackendRequest(BACKEND_REQUEST_TYPES.CLOSE_AGENT_MANAGER);
19284
+ } catch (error) {
19285
+ this.log("Close agent manager request failed:", error);
19286
+ throw error;
19287
+ }
19288
+ }
19289
+ /**
19234
19290
  * 批量切换插件状态
19235
19291
  * IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
19236
19292
  */
@@ -19244,22 +19300,22 @@ var IPCBackendProvider = class {
19244
19300
  }
19245
19301
  }
19246
19302
  /**
19247
- * 获取支持的插件列表
19303
+ * 获取支持的场景列表
19248
19304
  * IDE 环境: 通过 IPC 调用后端 API
19249
19305
  * 用于 Welcome 页面的 QuickActions 快捷操作
19250
19306
  *
19251
19307
  * 调用链:
19252
- * 1. agent-ui: IPCBackendProvider.getSupportPlugins()
19253
- * 2. Extension Host: BackendBridgeService.handleGetSupportPlugins()
19254
- * 3. Backend API: GET /v2/as/support/plugins
19255
- * 4. 返回 SupportPlugin[] 数据给 agent-ui
19308
+ * 1. agent-ui: IPCBackendProvider.getSupportScenes()
19309
+ * 2. Extension Host: BackendBridgeService.handleGetSupportScenes()
19310
+ * 3. Backend API: GET /v2/as/support/scenes
19311
+ * 4. 返回 SupportScene[] 数据给 agent-ui
19256
19312
  */
19257
- async getSupportPlugins() {
19258
- this.log("Getting support plugins via IPC");
19313
+ async getSupportScenes() {
19314
+ this.log("Getting support scenes via IPC");
19259
19315
  try {
19260
- return (await this.sendBackendRequest(BACKEND_REQUEST_TYPES.GET_SUPPORT_PLUGINS, {}))?.plugins || [];
19316
+ return (await this.sendBackendRequest(BACKEND_REQUEST_TYPES.GET_SUPPORT_SCENES, {}))?.scenes || [];
19261
19317
  } catch (error) {
19262
- this.log("Get support plugins failed:", error);
19318
+ this.log("Get support scenes failed:", error);
19263
19319
  return [];
19264
19320
  }
19265
19321
  }