@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 +95 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -46
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +60 -46
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +95 -39
- package/dist/index.mjs.map +1 -1
- package/dist/tencent-ai-cloud-agent-sdk-0.2.12.tgz +0 -0
- package/package.json +2 -2
- package/dist/tencent-ai-cloud-agent-sdk-0.2.11.tgz +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1954,9 +1954,7 @@ var StreamableHttpClient = class {
|
|
|
1954
1954
|
});
|
|
1955
1955
|
await this.handleExtNotification(method, params);
|
|
1956
1956
|
},
|
|
1957
|
-
extMethod: async (method, params) =>
|
|
1958
|
-
return await this.handleExtMethod(method, params);
|
|
1959
|
-
}
|
|
1957
|
+
extMethod: async (method, params) => this.handleExtMethod(method, params)
|
|
1960
1958
|
};
|
|
1961
1959
|
}
|
|
1962
1960
|
/**
|
|
@@ -2176,12 +2174,22 @@ var StreamableHttpClient = class {
|
|
|
2176
2174
|
await this.extensionManager.handleNotification(method, params);
|
|
2177
2175
|
}
|
|
2178
2176
|
async handleExtMethod(method, params) {
|
|
2179
|
-
if (method === ExtensionMethod.QUESTION)
|
|
2177
|
+
if (method === ExtensionMethod.QUESTION) {
|
|
2178
|
+
const response = await this.questionManager.handleRequest(params);
|
|
2179
|
+
if (response.outcome === "submitted" && response.answers) return { outcome: {
|
|
2180
|
+
outcome: "submitted",
|
|
2181
|
+
data: { answers: response.answers }
|
|
2182
|
+
} };
|
|
2183
|
+
else return { outcome: {
|
|
2184
|
+
outcome: "cancelled",
|
|
2185
|
+
reason: response.reason
|
|
2186
|
+
} };
|
|
2187
|
+
}
|
|
2180
2188
|
this.options.logger?.warn(`Unknown extension method: ${method}`);
|
|
2181
|
-
return {
|
|
2189
|
+
return { outcome: {
|
|
2182
2190
|
outcome: "cancelled",
|
|
2183
2191
|
reason: "unknown method"
|
|
2184
|
-
};
|
|
2192
|
+
} };
|
|
2185
2193
|
}
|
|
2186
2194
|
ensureInitialized(operation) {
|
|
2187
2195
|
if (this.state !== "initialized") throw new InvalidStateError(operation, this.state, ["initialized"]);
|
|
@@ -6629,6 +6637,28 @@ var CloudAgentProvider = class CloudAgentProvider {
|
|
|
6629
6637
|
}
|
|
6630
6638
|
}
|
|
6631
6639
|
}
|
|
6640
|
+
/**
|
|
6641
|
+
* 获取支持的场景列表
|
|
6642
|
+
* API 端点: GET /console/as/support/scenes
|
|
6643
|
+
* 用于 Welcome 页面的 QuickActions 快捷操作
|
|
6644
|
+
*
|
|
6645
|
+
* @returns Promise<SupportScene[]> 支持的场景列表
|
|
6646
|
+
*/
|
|
6647
|
+
async getSupportScenes() {
|
|
6648
|
+
try {
|
|
6649
|
+
const apiResponse = await httpService.get("/console/as/support/scenes");
|
|
6650
|
+
if (!apiResponse.data) {
|
|
6651
|
+
this.logger?.warn("[CloudAgentProvider] No data in support scenes response");
|
|
6652
|
+
return [];
|
|
6653
|
+
}
|
|
6654
|
+
const scenes = apiResponse.data.scenes || [];
|
|
6655
|
+
this.logger?.info(`[CloudAgentProvider] Retrieved ${scenes.length} support scenes`);
|
|
6656
|
+
return scenes;
|
|
6657
|
+
} catch (error) {
|
|
6658
|
+
this.logger?.error("[CloudAgentProvider] Failed to get support scenes:", error);
|
|
6659
|
+
return [];
|
|
6660
|
+
}
|
|
6661
|
+
}
|
|
6632
6662
|
toAgentState(data) {
|
|
6633
6663
|
const status = data.sessionStatus || data.status;
|
|
6634
6664
|
return {
|
|
@@ -7622,17 +7652,17 @@ var AgentClient = class {
|
|
|
7622
7652
|
};
|
|
7623
7653
|
}
|
|
7624
7654
|
},
|
|
7625
|
-
|
|
7655
|
+
getSupportScenes: async () => {
|
|
7626
7656
|
try {
|
|
7627
|
-
if (this.provider && "
|
|
7628
|
-
const result = await this.provider.
|
|
7629
|
-
this.logger?.info("Got support
|
|
7657
|
+
if (this.provider && "getSupportScenes" in this.provider && typeof this.provider.getSupportScenes === "function") {
|
|
7658
|
+
const result = await this.provider.getSupportScenes();
|
|
7659
|
+
this.logger?.info("Got support scenes", { count: result?.length ?? 0 });
|
|
7630
7660
|
return result;
|
|
7631
7661
|
}
|
|
7632
|
-
this.logger?.warn("Provider does not support
|
|
7662
|
+
this.logger?.warn("Provider does not support getSupportScenes");
|
|
7633
7663
|
return [];
|
|
7634
7664
|
} catch (error) {
|
|
7635
|
-
this.logger?.error("Failed to get support
|
|
7665
|
+
this.logger?.error("Failed to get support scenes", error);
|
|
7636
7666
|
return [];
|
|
7637
7667
|
}
|
|
7638
7668
|
},
|
|
@@ -7709,8 +7739,29 @@ let AccountStatus = /* @__PURE__ */ function(AccountStatus) {
|
|
|
7709
7739
|
*
|
|
7710
7740
|
* 封装与后端 API 的 HTTP 通信
|
|
7711
7741
|
*/
|
|
7712
|
-
/**
|
|
7713
|
-
|
|
7742
|
+
/**
|
|
7743
|
+
* 判断当前是否在 SSO 域名下
|
|
7744
|
+
* SSO 域名格式: xxx.sso.copilot.tencent.com 或 xxx.sso.codebuddy.cn
|
|
7745
|
+
*/
|
|
7746
|
+
const isSSODomain = () => {
|
|
7747
|
+
const { hostname } = window.location;
|
|
7748
|
+
return hostname.includes(".sso.copilot") || hostname.includes("sso.codebuddy.cn") || hostname.includes(".sso.copilot-staging") || hostname.includes(".staging-sso.codebuddy.cn");
|
|
7749
|
+
};
|
|
7750
|
+
/**
|
|
7751
|
+
* 获取登录页面 URL
|
|
7752
|
+
* - SSO 域名下需要跳转到对应的预发/生产域名
|
|
7753
|
+
* - 非 SSO 域名直接使用当前域名
|
|
7754
|
+
*/
|
|
7755
|
+
const getLoginUrl = () => {
|
|
7756
|
+
const { hostname, protocol } = window.location;
|
|
7757
|
+
if (isSSODomain()) {
|
|
7758
|
+
const isCodebuddy = hostname.includes("codebuddy.cn");
|
|
7759
|
+
const isStaging = hostname.includes("staging");
|
|
7760
|
+
if (isCodebuddy) return isStaging ? `${protocol}//staging.codebuddy.cn/login` : `${protocol}//www.codebuddy.cn/login`;
|
|
7761
|
+
else return isStaging ? `${protocol}//staging-copilot.tencent.com/login` : `${protocol}//copilot.tencent.com/login`;
|
|
7762
|
+
}
|
|
7763
|
+
return `${window.location.origin}/login`;
|
|
7764
|
+
};
|
|
7714
7765
|
/** 获取当前域名的账号选择页面 URL */
|
|
7715
7766
|
const getSelectAccountUrl = () => `${window.location.origin}/login/select`;
|
|
7716
7767
|
/** localStorage 中存储选中账号 ID 的 key */
|
|
@@ -8222,21 +8273,6 @@ var BackendProvider = class {
|
|
|
8222
8273
|
return null;
|
|
8223
8274
|
}
|
|
8224
8275
|
}
|
|
8225
|
-
/**
|
|
8226
|
-
* 获取支持的插件列表
|
|
8227
|
-
* API 端点: GET /console/as/support/plugins
|
|
8228
|
-
* 用于 Welcome 页面的 QuickActions 快捷操作
|
|
8229
|
-
*/
|
|
8230
|
-
async getSupportPlugins() {
|
|
8231
|
-
try {
|
|
8232
|
-
const result = await httpService.get("/console/as/support/plugins");
|
|
8233
|
-
if (result?.code === 0 && result?.data?.plugins) return result.data.plugins;
|
|
8234
|
-
return [];
|
|
8235
|
-
} catch (error) {
|
|
8236
|
-
console.error("[BackendProvider] getSupportPlugins error:", error);
|
|
8237
|
-
return [];
|
|
8238
|
-
}
|
|
8239
|
-
}
|
|
8240
8276
|
};
|
|
8241
8277
|
/**
|
|
8242
8278
|
* 创建 BackendProvider 实例
|
|
@@ -8248,6 +8284,12 @@ function createBackendProvider(config) {
|
|
|
8248
8284
|
//#endregion
|
|
8249
8285
|
//#region ../agent-provider/src/backend/ipc-backend-provider.ts
|
|
8250
8286
|
/**
|
|
8287
|
+
* IPC Backend Provider 实现
|
|
8288
|
+
*
|
|
8289
|
+
* 通过 IWidgetChannel 与后端通信
|
|
8290
|
+
* 使用统一的消息格式: { type: 'backend', requestId, params: { type, params } }
|
|
8291
|
+
*/
|
|
8292
|
+
/**
|
|
8251
8293
|
* Backend 请求类型常量
|
|
8252
8294
|
*/
|
|
8253
8295
|
const BACKEND_REQUEST_TYPES = {
|
|
@@ -8269,8 +8311,9 @@ const BACKEND_REQUEST_TYPES = {
|
|
|
8269
8311
|
REVOKE_ALL: "backend:revoke-all",
|
|
8270
8312
|
GET_FILE: "backend:get-file",
|
|
8271
8313
|
RELOAD_WINDOW: "backend:reload-window",
|
|
8314
|
+
CLOSE_AGENT_MANAGER: "backend:close-agent-manager",
|
|
8272
8315
|
BATCH_TOGGLE_PLUGINS: "backend:batch-toggle-plugins",
|
|
8273
|
-
|
|
8316
|
+
GET_SUPPORT_SCENES: "backend:get-support-scenes"
|
|
8274
8317
|
};
|
|
8275
8318
|
/**
|
|
8276
8319
|
* 生成唯一请求 ID
|
|
@@ -8551,6 +8594,19 @@ var IPCBackendProvider = class {
|
|
|
8551
8594
|
}
|
|
8552
8595
|
}
|
|
8553
8596
|
/**
|
|
8597
|
+
* 关闭 Agent Manager 面板
|
|
8598
|
+
* IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
|
|
8599
|
+
*/
|
|
8600
|
+
async closeAgentManager() {
|
|
8601
|
+
this.log("Triggering close agent manager via IPC");
|
|
8602
|
+
try {
|
|
8603
|
+
await this.sendBackendRequest(BACKEND_REQUEST_TYPES.CLOSE_AGENT_MANAGER);
|
|
8604
|
+
} catch (error) {
|
|
8605
|
+
this.log("Close agent manager request failed:", error);
|
|
8606
|
+
throw error;
|
|
8607
|
+
}
|
|
8608
|
+
}
|
|
8609
|
+
/**
|
|
8554
8610
|
* 批量切换插件状态
|
|
8555
8611
|
* IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
|
|
8556
8612
|
*/
|
|
@@ -8564,22 +8620,22 @@ var IPCBackendProvider = class {
|
|
|
8564
8620
|
}
|
|
8565
8621
|
}
|
|
8566
8622
|
/**
|
|
8567
|
-
*
|
|
8623
|
+
* 获取支持的场景列表
|
|
8568
8624
|
* IDE 环境: 通过 IPC 调用后端 API
|
|
8569
8625
|
* 用于 Welcome 页面的 QuickActions 快捷操作
|
|
8570
8626
|
*
|
|
8571
8627
|
* 调用链:
|
|
8572
|
-
* 1. agent-ui: IPCBackendProvider.
|
|
8573
|
-
* 2. Extension Host: BackendBridgeService.
|
|
8574
|
-
* 3. Backend API: GET /v2/as/support/
|
|
8575
|
-
* 4. 返回
|
|
8628
|
+
* 1. agent-ui: IPCBackendProvider.getSupportScenes()
|
|
8629
|
+
* 2. Extension Host: BackendBridgeService.handleGetSupportScenes()
|
|
8630
|
+
* 3. Backend API: GET /v2/as/support/scenes
|
|
8631
|
+
* 4. 返回 SupportScene[] 数据给 agent-ui
|
|
8576
8632
|
*/
|
|
8577
|
-
async
|
|
8578
|
-
this.log("Getting support
|
|
8633
|
+
async getSupportScenes() {
|
|
8634
|
+
this.log("Getting support scenes via IPC");
|
|
8579
8635
|
try {
|
|
8580
|
-
return (await this.sendBackendRequest(BACKEND_REQUEST_TYPES.
|
|
8636
|
+
return (await this.sendBackendRequest(BACKEND_REQUEST_TYPES.GET_SUPPORT_SCENES, {}))?.scenes || [];
|
|
8581
8637
|
} catch (error) {
|
|
8582
|
-
this.log("Get support
|
|
8638
|
+
this.log("Get support scenes failed:", error);
|
|
8583
8639
|
return [];
|
|
8584
8640
|
}
|
|
8585
8641
|
}
|