@tencent-ai/cloud-agent-sdk 0.2.11 → 0.2.12-next.a535070.20260201

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 {
@@ -18234,6 +18264,28 @@ var AgentClient = class {
18234
18264
  };
18235
18265
  }
18236
18266
  },
18267
+ getSubagentList: async (params) => {
18268
+ try {
18269
+ if (this.provider && this.provider.getSubagentList) {
18270
+ const result = await this.provider.getSubagentList(params);
18271
+ this.logger?.info("Subagent list retrieved", {
18272
+ resultCount: result.results.length,
18273
+ hasError: !!result.error
18274
+ });
18275
+ return result;
18276
+ }
18277
+ return {
18278
+ results: [],
18279
+ error: "Provider does not support getSubagentList"
18280
+ };
18281
+ } catch (error) {
18282
+ this.logger?.error("Failed to get subagent list", error);
18283
+ return {
18284
+ results: [],
18285
+ error: error instanceof Error ? error.message : "Unknown error"
18286
+ };
18287
+ }
18288
+ },
18237
18289
  batchTogglePlugins: async (request) => {
18238
18290
  try {
18239
18291
  if (this.provider && this.provider.batchTogglePlugins) {
@@ -18302,17 +18354,34 @@ var AgentClient = class {
18302
18354
  };
18303
18355
  }
18304
18356
  },
18305
- getSupportPlugins: async () => {
18357
+ getSupportScenes: async () => {
18306
18358
  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 });
18359
+ if (this.provider && "getSupportScenes" in this.provider && typeof this.provider.getSupportScenes === "function") {
18360
+ const result = await this.provider.getSupportScenes();
18361
+ this.logger?.info("Got support scenes", { count: result?.length ?? 0 });
18310
18362
  return result;
18311
18363
  }
18312
- this.logger?.warn("Provider does not support getSupportPlugins");
18364
+ this.logger?.warn("Provider does not support getSupportScenes");
18313
18365
  return [];
18314
18366
  } catch (error) {
18315
- this.logger?.error("Failed to get support plugins", error);
18367
+ this.logger?.error("Failed to get support scenes", error);
18368
+ return [];
18369
+ }
18370
+ },
18371
+ getAvailableCommands: async (sessionId) => {
18372
+ try {
18373
+ if (this.provider && "getAvailableCommands" in this.provider && typeof this.provider.getAvailableCommands === "function") {
18374
+ const result = await this.provider.getAvailableCommands(sessionId);
18375
+ this.logger?.info("Got available commands from provider", {
18376
+ sessionId: sessionId ?? "(default)",
18377
+ count: result?.length ?? 0
18378
+ });
18379
+ return result;
18380
+ }
18381
+ this.logger?.warn("Provider does not support getAvailableCommands", { sessionId });
18382
+ return [];
18383
+ } catch (error) {
18384
+ this.logger?.error("Failed to get available commands", error);
18316
18385
  return [];
18317
18386
  }
18318
18387
  },
@@ -18389,8 +18458,29 @@ let AccountStatus = /* @__PURE__ */ function(AccountStatus) {
18389
18458
  *
18390
18459
  * 封装与后端 API 的 HTTP 通信
18391
18460
  */
18392
- /** 获取当前域名的登录页面 URL */
18393
- const getLoginUrl = () => `${window.location.origin}/login`;
18461
+ /**
18462
+ * 判断当前是否在 SSO 域名下
18463
+ * SSO 域名格式: xxx.sso.copilot.tencent.com 或 xxx.sso.codebuddy.cn
18464
+ */
18465
+ const isSSODomain = () => {
18466
+ const { hostname } = window.location;
18467
+ return hostname.includes(".sso.copilot") || hostname.includes("sso.codebuddy.cn") || hostname.includes(".sso.copilot-staging") || hostname.includes(".staging-sso.codebuddy.cn");
18468
+ };
18469
+ /**
18470
+ * 获取登录页面 URL
18471
+ * - SSO 域名下需要跳转到对应的预发/生产域名
18472
+ * - 非 SSO 域名直接使用当前域名
18473
+ */
18474
+ const getLoginUrl = () => {
18475
+ const { hostname, protocol } = window.location;
18476
+ if (isSSODomain()) {
18477
+ const isCodebuddy = hostname.includes("codebuddy.cn");
18478
+ const isStaging = hostname.includes("staging");
18479
+ if (isCodebuddy) return isStaging ? `${protocol}//staging.codebuddy.cn/login` : `${protocol}//www.codebuddy.cn/login`;
18480
+ else return isStaging ? `${protocol}//staging-copilot.tencent.com/login` : `${protocol}//copilot.tencent.com/login`;
18481
+ }
18482
+ return `${window.location.origin}/login`;
18483
+ };
18394
18484
  /** 获取当前域名的账号选择页面 URL */
18395
18485
  const getSelectAccountUrl = () => `${window.location.origin}/login/select`;
18396
18486
  /** localStorage 中存储选中账号 ID 的 key */
@@ -18902,21 +18992,6 @@ var BackendProvider = class {
18902
18992
  return null;
18903
18993
  }
18904
18994
  }
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
18995
  };
18921
18996
  /**
18922
18997
  * 创建 BackendProvider 实例
@@ -18928,6 +19003,12 @@ function createBackendProvider(config) {
18928
19003
  //#endregion
18929
19004
  //#region ../agent-provider/src/backend/ipc-backend-provider.ts
18930
19005
  /**
19006
+ * IPC Backend Provider 实现
19007
+ *
19008
+ * 通过 IWidgetChannel 与后端通信
19009
+ * 使用统一的消息格式: { type: 'backend', requestId, params: { type, params } }
19010
+ */
19011
+ /**
18931
19012
  * Backend 请求类型常量
18932
19013
  */
18933
19014
  const BACKEND_REQUEST_TYPES = {
@@ -18949,8 +19030,9 @@ const BACKEND_REQUEST_TYPES = {
18949
19030
  REVOKE_ALL: "backend:revoke-all",
18950
19031
  GET_FILE: "backend:get-file",
18951
19032
  RELOAD_WINDOW: "backend:reload-window",
19033
+ CLOSE_AGENT_MANAGER: "backend:close-agent-manager",
18952
19034
  BATCH_TOGGLE_PLUGINS: "backend:batch-toggle-plugins",
18953
- GET_SUPPORT_PLUGINS: "backend:get-support-plugins"
19035
+ GET_SUPPORT_SCENES: "backend:get-support-scenes"
18954
19036
  };
18955
19037
  /**
18956
19038
  * 生成唯一请求 ID
@@ -19231,6 +19313,19 @@ var IPCBackendProvider = class {
19231
19313
  }
19232
19314
  }
19233
19315
  /**
19316
+ * 关闭 Agent Manager 面板
19317
+ * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
19318
+ */
19319
+ async closeAgentManager() {
19320
+ this.log("Triggering close agent manager via IPC");
19321
+ try {
19322
+ await this.sendBackendRequest(BACKEND_REQUEST_TYPES.CLOSE_AGENT_MANAGER);
19323
+ } catch (error) {
19324
+ this.log("Close agent manager request failed:", error);
19325
+ throw error;
19326
+ }
19327
+ }
19328
+ /**
19234
19329
  * 批量切换插件状态
19235
19330
  * IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
19236
19331
  */
@@ -19244,22 +19339,22 @@ var IPCBackendProvider = class {
19244
19339
  }
19245
19340
  }
19246
19341
  /**
19247
- * 获取支持的插件列表
19342
+ * 获取支持的场景列表
19248
19343
  * IDE 环境: 通过 IPC 调用后端 API
19249
19344
  * 用于 Welcome 页面的 QuickActions 快捷操作
19250
19345
  *
19251
19346
  * 调用链:
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
19347
+ * 1. agent-ui: IPCBackendProvider.getSupportScenes()
19348
+ * 2. Extension Host: BackendBridgeService.handleGetSupportScenes()
19349
+ * 3. Backend API: GET /v2/as/support/scenes
19350
+ * 4. 返回 SupportScene[] 数据给 agent-ui
19256
19351
  */
19257
- async getSupportPlugins() {
19258
- this.log("Getting support plugins via IPC");
19352
+ async getSupportScenes() {
19353
+ this.log("Getting support scenes via IPC");
19259
19354
  try {
19260
- return (await this.sendBackendRequest(BACKEND_REQUEST_TYPES.GET_SUPPORT_PLUGINS, {}))?.plugins || [];
19355
+ return (await this.sendBackendRequest(BACKEND_REQUEST_TYPES.GET_SUPPORT_SCENES, {}))?.scenes || [];
19261
19356
  } catch (error) {
19262
- this.log("Get support plugins failed:", error);
19357
+ this.log("Get support scenes failed:", error);
19263
19358
  return [];
19264
19359
  }
19265
19360
  }