@tencent-ai/cloud-agent-sdk 0.2.6 → 0.2.7-next.38384d9.20260128
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 +1520 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2208 -1663
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2208 -1663
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1520 -201
- package/dist/index.mjs.map +1 -1
- package/dist/tencent-ai-cloud-agent-sdk-0.2.7-next.38384d9.20260128.tgz +0 -0
- package/package.json +4 -3
- package/dist/MockAgentProvider-4e4oOusg.cjs +0 -3
- package/dist/MockAgentProvider-D-basTXz.cjs +0 -3219
- package/dist/MockAgentProvider-D-basTXz.cjs.map +0 -1
- package/dist/MockAgentProvider-TNsV559x.mjs +0 -3202
- package/dist/MockAgentProvider-TNsV559x.mjs.map +0 -1
- package/dist/MockAgentProvider-tNdtAJCv.mjs +0 -3
- package/dist/tencent-ai-cloud-agent-sdk-0.2.6.tgz +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -72,7 +72,7 @@ interface TasksArtifact extends BaseArtifact<'tasks'> {
|
|
|
72
72
|
/**
|
|
73
73
|
* Media content type (auxiliary classification)
|
|
74
74
|
*/
|
|
75
|
-
type MediaContentType = 'image' | 'video' | 'document' | 'spreadsheet';
|
|
75
|
+
type MediaContentType = 'image' | 'video' | 'audio' | 'document' | 'spreadsheet' | 'presentation' | 'diagram' | 'code';
|
|
76
76
|
/**
|
|
77
77
|
* Media Artifact - Media files
|
|
78
78
|
* Supports images, videos, documents and other browser-renderable files
|
|
@@ -142,8 +142,14 @@ interface QuestionRequest {
|
|
|
142
142
|
sessionId: string;
|
|
143
143
|
/** Associated tool call ID (links extMethod to tool_call for UI) */
|
|
144
144
|
toolCallId: string;
|
|
145
|
-
/**
|
|
146
|
-
|
|
145
|
+
/** Input type */
|
|
146
|
+
inputType?: string;
|
|
147
|
+
/** Schema containing questions */
|
|
148
|
+
schema?: {
|
|
149
|
+
/** Questions to ask (1-4) */questions: UserQuestion[];
|
|
150
|
+
};
|
|
151
|
+
/** Questions to ask (1-4) - legacy format */
|
|
152
|
+
questions?: UserQuestion[];
|
|
147
153
|
/** Request timeout in ms */
|
|
148
154
|
timeout?: number;
|
|
149
155
|
}
|
|
@@ -552,6 +558,7 @@ interface Session {
|
|
|
552
558
|
interface CreateSessionParams {
|
|
553
559
|
cwd: string;
|
|
554
560
|
mcpServers?: McpServerConfig[];
|
|
561
|
+
_meta?: Record<string, unknown>;
|
|
555
562
|
}
|
|
556
563
|
/**
|
|
557
564
|
* Parameters for loading an existing session
|
|
@@ -627,6 +634,10 @@ interface ConnectionEvents extends ClientEvents {
|
|
|
627
634
|
questionTimeout: {
|
|
628
635
|
toolCallId: string;
|
|
629
636
|
};
|
|
637
|
+
command: {
|
|
638
|
+
action: string;
|
|
639
|
+
params?: Record<string, unknown>;
|
|
640
|
+
};
|
|
630
641
|
}
|
|
631
642
|
/**
|
|
632
643
|
* Event listener type
|
|
@@ -827,1906 +838,2301 @@ declare enum ModelTrustLevel {
|
|
|
827
838
|
CERTIFIED = "certified"
|
|
828
839
|
}
|
|
829
840
|
//#endregion
|
|
830
|
-
//#region ../agent-provider/lib/
|
|
841
|
+
//#region ../agent-provider/lib/backend/types.d.ts
|
|
831
842
|
/**
|
|
832
|
-
*
|
|
833
|
-
*
|
|
843
|
+
* Backend Provider 类型定义
|
|
844
|
+
*
|
|
845
|
+
* 定义 IBackendProvider 接口和配置
|
|
834
846
|
*/
|
|
835
|
-
interface SessionConnectionInfo {
|
|
836
|
-
/** Session ID */
|
|
837
|
-
sessionId: string;
|
|
838
|
-
/** Agent ID */
|
|
839
|
-
agentId: string;
|
|
840
|
-
/** Session endpoint URL (Agent的WebSocket/HTTP端点) */
|
|
841
|
-
link: string;
|
|
842
|
-
/** Session token (JWT格式的认证令牌) */
|
|
843
|
-
token: string;
|
|
844
|
-
/** Sandbox ID (E2B沙箱的唯一标识) */
|
|
845
|
-
sandboxId: string;
|
|
846
|
-
/** Session expiration timestamp (unix timestamp) */
|
|
847
|
-
expireAt: number;
|
|
848
|
-
/** Current working directory (optional) */
|
|
849
|
-
cwd?: string;
|
|
850
|
-
}
|
|
851
847
|
/**
|
|
852
|
-
*
|
|
848
|
+
* 账号版本类型
|
|
853
849
|
*/
|
|
854
|
-
type
|
|
850
|
+
type Edition = 'pro' | 'personal' | 'ultimate' | 'exclusive';
|
|
855
851
|
/**
|
|
856
|
-
*
|
|
852
|
+
* 版本展示类型(用于 UI 展示)
|
|
853
|
+
* - free: 免费版(个人版未订阅 Pro)
|
|
854
|
+
* - pro: Pro 版(个人版已订阅 Pro)
|
|
855
|
+
* - ultimate: 旗舰版(团队版)
|
|
856
|
+
* - exclusive: 专享版(企业版)
|
|
857
857
|
*/
|
|
858
|
-
type
|
|
858
|
+
type EditionDisplayType = 'free' | 'pro' | 'ultimate' | 'exclusive';
|
|
859
859
|
/**
|
|
860
|
-
*
|
|
860
|
+
* 部署状态
|
|
861
861
|
*/
|
|
862
|
-
interface
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
ref: string;
|
|
867
|
-
/** 仓库路径 */
|
|
868
|
-
repository: string;
|
|
862
|
+
interface DeployStatus {
|
|
863
|
+
statusCode: number;
|
|
864
|
+
statusMsg: string;
|
|
865
|
+
detailMsg: string;
|
|
869
866
|
}
|
|
870
867
|
/**
|
|
871
|
-
*
|
|
868
|
+
* 套餐代码
|
|
872
869
|
*/
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
870
|
+
/**
|
|
871
|
+
* TCACA_code_001_PqouKr6QWV CodeBuddy海外版免费包
|
|
872
|
+
* TCACA_code_002_AkiJS3ZHF5 CodeBuddy海外版Pro版本包-包月/CodeBuddy Pro Plan - Monthly:
|
|
873
|
+
* TCACA_code_006_DbXS0lrypC CodeBuddy海外版一次性免费赠送2周的Pro版本包/CodeBuddy One-time Free 2-Week Pro Plan Trial
|
|
874
|
+
* TCACA_code_007_nzdH5h4Nl0 CodeBuddy海外版运营裂变包/CodeBuddy Growth Plan
|
|
875
|
+
* TCACA_code_003_FAnt7lcmRT CodeBuddy海外版Pro版本包-包年/CodeBuddy Pro Plan - Yearly
|
|
876
|
+
* TCACA_code_008_cfWoLwvjU4 赠送月包
|
|
877
|
+
*/
|
|
878
|
+
declare enum CommodityCode {
|
|
879
|
+
free = "TCACA_code_001_PqouKr6QWV",
|
|
880
|
+
// free
|
|
881
|
+
proMon = "TCACA_code_002_AkiJS3ZHF5",
|
|
882
|
+
proMonPlus = "TCACA_code_005_maRGyrHhw1",
|
|
883
|
+
gift = "TCACA_code_006_DbXS0lrypC",
|
|
884
|
+
activity = "TCACA_code_007_nzdH5h4Nl0",
|
|
885
|
+
proYear = "TCACA_code_003_FAnt7lcmRT",
|
|
886
|
+
freeMon = "TCACA_code_008_cfWoLwvjU4",
|
|
887
|
+
// free
|
|
888
|
+
extra = "TCACA_code_009_0XmEQc2xOf"
|
|
882
889
|
}
|
|
883
890
|
/**
|
|
884
|
-
*
|
|
885
|
-
* 所有类型的 AgentState 都必须实现此接口
|
|
891
|
+
* 套餐资源项(用于展示列表)
|
|
886
892
|
*/
|
|
887
|
-
interface
|
|
888
|
-
/**
|
|
893
|
+
interface PlanResource {
|
|
894
|
+
/** 资源 ID */
|
|
889
895
|
id: string;
|
|
890
|
-
/**
|
|
896
|
+
/** 套餐名称(i18n key) */
|
|
897
|
+
name: string;
|
|
898
|
+
/** 套餐代码 */
|
|
899
|
+
packageCode: CommodityCode;
|
|
900
|
+
/** 是否是每日刷新的套餐 */
|
|
901
|
+
isDaily: boolean;
|
|
902
|
+
/** 总量 */
|
|
903
|
+
total: number;
|
|
904
|
+
/** 已用 */
|
|
905
|
+
used: number;
|
|
906
|
+
/** 剩余 */
|
|
907
|
+
left: number;
|
|
908
|
+
/** 到期时间戳 */
|
|
909
|
+
expireAt?: number;
|
|
910
|
+
/** 刷新时间戳 */
|
|
911
|
+
refreshAt?: number;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* 账号套餐信息
|
|
915
|
+
*/
|
|
916
|
+
interface AccountPlan {
|
|
917
|
+
/** 是否是 Pro 版本 */
|
|
918
|
+
isPro: boolean;
|
|
919
|
+
isTria?: boolean;
|
|
920
|
+
/** 到期时间戳 */
|
|
921
|
+
expireAt?: number;
|
|
922
|
+
refreshAt?: number;
|
|
923
|
+
/** 自动续费标志 0-关闭 1-开启 */
|
|
924
|
+
renewFlag: 0 | 1;
|
|
925
|
+
/** 套餐代码 */
|
|
926
|
+
PackageCode?: CommodityCode;
|
|
927
|
+
/** 套餐名称 */
|
|
928
|
+
name: string;
|
|
929
|
+
usageTotal?: string;
|
|
930
|
+
usageUsed?: string;
|
|
931
|
+
usageLeft?: string;
|
|
932
|
+
/** 所有套餐资源列表 */
|
|
933
|
+
resources?: PlanResource[];
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* 账号信息
|
|
937
|
+
*/
|
|
938
|
+
interface Account {
|
|
939
|
+
/** 用户ID(唯一标识) */
|
|
940
|
+
uid: string;
|
|
941
|
+
/** 用户昵称 */
|
|
942
|
+
nickname: string;
|
|
943
|
+
/** 版本类型 */
|
|
944
|
+
type: Edition;
|
|
945
|
+
/** 版本展示类型(用于 UI 展示) */
|
|
946
|
+
editionType: EditionDisplayType;
|
|
947
|
+
/** 是否最后一次登录 */
|
|
948
|
+
lastLogin: boolean;
|
|
949
|
+
/** 企业ID */
|
|
950
|
+
enterpriseId?: string;
|
|
951
|
+
/** 企业名称 */
|
|
952
|
+
enterpriseName?: string;
|
|
953
|
+
/** 企业LOGO */
|
|
954
|
+
enterpriseLogo?: string;
|
|
955
|
+
/** 企业内用户名 */
|
|
956
|
+
enterpriseUserName?: string;
|
|
957
|
+
/** 插件是否启用 */
|
|
958
|
+
pluginEnabled?: boolean;
|
|
959
|
+
/** 部署状态 */
|
|
960
|
+
deployStatus?: DeployStatus;
|
|
961
|
+
/** 是否是 Pro 版本 */
|
|
962
|
+
isPro?: boolean;
|
|
963
|
+
/** 到期时间戳 */
|
|
964
|
+
expireAt?: string | number;
|
|
965
|
+
/** 刷新时间(年套餐下、本周期结束日期) */
|
|
966
|
+
refreshAt?: number;
|
|
967
|
+
/** 自动续费标志 0-关闭 1-开启 */
|
|
968
|
+
renewFlag?: 0 | 1;
|
|
969
|
+
/** 套餐代码 */
|
|
970
|
+
PackageCode?: CommodityCode;
|
|
971
|
+
/** 套餐名称 */
|
|
891
972
|
name?: string;
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
createdAt?: Date;
|
|
902
|
-
/** When the agent was last updated */
|
|
903
|
-
updatedAt?: Date;
|
|
973
|
+
email?: string;
|
|
974
|
+
/** 套餐总用量 */
|
|
975
|
+
usageTotal?: string;
|
|
976
|
+
/** 套餐已用量 */
|
|
977
|
+
usageUsed?: string;
|
|
978
|
+
/** 套餐剩余用量 */
|
|
979
|
+
usageLeft?: string;
|
|
980
|
+
/** 所有套餐资源列表(个人用户) */
|
|
981
|
+
resources?: PlanResource[];
|
|
904
982
|
}
|
|
905
983
|
/**
|
|
906
|
-
*
|
|
907
|
-
* 来自本地 IPC 通信的 Agent
|
|
984
|
+
* 推理配置
|
|
908
985
|
*/
|
|
909
|
-
interface
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
986
|
+
interface ReasoningConfig {
|
|
987
|
+
/** 推理努力程度 */
|
|
988
|
+
effort: 'low' | 'medium' | 'high';
|
|
989
|
+
/** 摘要模式 */
|
|
990
|
+
summary: 'auto' | 'always' | 'never';
|
|
913
991
|
}
|
|
914
992
|
/**
|
|
915
|
-
*
|
|
916
|
-
* 来自远程 API 的云端实例
|
|
993
|
+
* 模型信息
|
|
917
994
|
*/
|
|
918
|
-
interface
|
|
919
|
-
|
|
995
|
+
interface ModelInfo {
|
|
996
|
+
/** 模型ID */
|
|
997
|
+
id: string;
|
|
998
|
+
/** 模型名称 */
|
|
999
|
+
name: string;
|
|
1000
|
+
/** 供应商 */
|
|
1001
|
+
vendor: string;
|
|
1002
|
+
/** 最大输出 token 数 */
|
|
1003
|
+
maxOutputTokens: number;
|
|
1004
|
+
/** 最大输入 token 数 */
|
|
1005
|
+
maxInputTokens: number;
|
|
1006
|
+
/** 是否支持工具调用 */
|
|
1007
|
+
supportsToolCall: boolean;
|
|
1008
|
+
/** 是否支持图像 */
|
|
1009
|
+
supportsImages: boolean;
|
|
1010
|
+
/** 是否禁用多模态 */
|
|
1011
|
+
disabledMultimodal: boolean;
|
|
1012
|
+
/** 最大允许大小 */
|
|
1013
|
+
maxAllowedSize: number;
|
|
1014
|
+
/** 是否支持推理 */
|
|
1015
|
+
supportsReasoning: boolean;
|
|
1016
|
+
/** 是否仅推理模式 */
|
|
1017
|
+
onlyReasoning: boolean;
|
|
1018
|
+
/** 温度参数 */
|
|
1019
|
+
temperature: number;
|
|
1020
|
+
/** 推理配置 */
|
|
1021
|
+
reasoning: ReasoningConfig;
|
|
1022
|
+
/** 英文描述 */
|
|
1023
|
+
descriptionEn: string;
|
|
1024
|
+
/** 中文描述 */
|
|
1025
|
+
descriptionZh: string;
|
|
920
1026
|
}
|
|
921
1027
|
/**
|
|
922
|
-
*
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1028
|
+
* 用户连接器信息
|
|
1029
|
+
*/
|
|
1030
|
+
interface UserConnector {
|
|
1031
|
+
/** 用户ID */
|
|
1032
|
+
user_id: string;
|
|
1033
|
+
/** 连接器名称 */
|
|
1034
|
+
name: ConnectorType;
|
|
1035
|
+
displayName: string;
|
|
1036
|
+
/** 连接时间 */
|
|
1037
|
+
connect_at: string;
|
|
1038
|
+
/** 连接状态,0未连接,1已连接 */
|
|
1039
|
+
connectStatus: 0 | 1;
|
|
1040
|
+
/** 勾选仓库列表,逗号分隔 */
|
|
1041
|
+
repos: string;
|
|
1042
|
+
/** 激活状态,0未激活,1已激活 */
|
|
1043
|
+
activeStatus: 0 | 1;
|
|
1044
|
+
/** 提示词 */
|
|
1045
|
+
prompt: string;
|
|
1046
|
+
/** 跳转URL */
|
|
1047
|
+
url: string;
|
|
1048
|
+
/** 描述 */
|
|
1049
|
+
description: string;
|
|
1050
|
+
/** OAuth Client ID */
|
|
1051
|
+
oauthClientId: string;
|
|
1052
|
+
/** OAuth 重定向 URL */
|
|
1053
|
+
oauthRedirectUrl: string;
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* 获取用户连接器列表响应
|
|
926
1057
|
*/
|
|
927
|
-
|
|
1058
|
+
interface ListUserConnectorResponse {
|
|
1059
|
+
/** 连接器列表 */
|
|
1060
|
+
connectors: UserConnector[];
|
|
1061
|
+
}
|
|
928
1062
|
/**
|
|
929
|
-
*
|
|
1063
|
+
* 修改用户连接器连接状态请求
|
|
930
1064
|
*/
|
|
931
|
-
|
|
1065
|
+
interface ModifyUserConnectorConnectStatusRequest {
|
|
1066
|
+
/** 连接器名称 */
|
|
1067
|
+
name: ConnectorType;
|
|
1068
|
+
/** 连接状态,0未连接,1已连接 */
|
|
1069
|
+
connectStatus: 0 | 1;
|
|
1070
|
+
/** 激活状态,0未激活,1已激活 */
|
|
1071
|
+
activeStatus?: 0 | 1;
|
|
1072
|
+
/** 勾选仓库列表 */
|
|
1073
|
+
repos?: string[];
|
|
1074
|
+
}
|
|
932
1075
|
/**
|
|
933
|
-
*
|
|
1076
|
+
* 修改用户连接器仓库请求
|
|
934
1077
|
*/
|
|
935
|
-
interface
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1078
|
+
interface ModifyUserConnectorRepoRequest {
|
|
1079
|
+
/** 连接器名称 */
|
|
1080
|
+
name: ConnectorType;
|
|
1081
|
+
/** 仓库列表 */
|
|
1082
|
+
repo?: string[];
|
|
940
1083
|
}
|
|
941
1084
|
/**
|
|
942
|
-
*
|
|
1085
|
+
* 修改用户连接器激活状态请求
|
|
943
1086
|
*/
|
|
944
|
-
interface
|
|
945
|
-
/**
|
|
946
|
-
|
|
947
|
-
/**
|
|
948
|
-
|
|
1087
|
+
interface ModifyUserConnectorActiveStatusRequest {
|
|
1088
|
+
/** 连接器名称 */
|
|
1089
|
+
name: ConnectorType;
|
|
1090
|
+
/** 激活状态,0未激活,1已激活 */
|
|
1091
|
+
activeStatus: 0 | 1;
|
|
949
1092
|
}
|
|
1093
|
+
type ConnectorType = 'github' | 'gongfeng' | 'cnb';
|
|
950
1094
|
/**
|
|
951
|
-
*
|
|
1095
|
+
* 任务连接器信息
|
|
952
1096
|
*/
|
|
953
|
-
interface
|
|
954
|
-
/**
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
|
|
1097
|
+
interface TaskConnector {
|
|
1098
|
+
/** 用户ID */
|
|
1099
|
+
user_id: string;
|
|
1100
|
+
/** 任务ID */
|
|
1101
|
+
task_id: string;
|
|
1102
|
+
/** 连接器名称(唯一标识,如github/gongfeng/figma/cnb) */
|
|
1103
|
+
name: string;
|
|
1104
|
+
displayName: string;
|
|
1105
|
+
/** 勾选仓库列表,逗号分隔 */
|
|
1106
|
+
repos: string;
|
|
1107
|
+
/** 激活状态:0未激活 / 1已激活 */
|
|
1108
|
+
activeStatus: 0 | 1;
|
|
1109
|
+
/** 创建时间 */
|
|
1110
|
+
created_at: string;
|
|
1111
|
+
/** 更新时间 */
|
|
1112
|
+
updated_at: string;
|
|
1113
|
+
/** 提示词 */
|
|
1114
|
+
prompt: string;
|
|
1115
|
+
/** 跳转URL */
|
|
1116
|
+
url: string;
|
|
1117
|
+
/** 描述 */
|
|
1118
|
+
description: string;
|
|
1119
|
+
/** OAuth Client ID */
|
|
1120
|
+
oauthClientId?: string;
|
|
1121
|
+
/** OAuth 重定向 URL */
|
|
1122
|
+
oauthRedirectUrl?: string;
|
|
1123
|
+
/** 连接时间 */
|
|
1124
|
+
connect_at: string;
|
|
1125
|
+
/** 连接状态,0未连接,1已连接 */
|
|
1126
|
+
connectStatus: 0 | 1;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* 添加任务请求
|
|
1130
|
+
*/
|
|
1131
|
+
interface AddTaskRequest {
|
|
1132
|
+
/** 任务ID */
|
|
1133
|
+
taskId: string;
|
|
1134
|
+
/** 连接器列表 */
|
|
1135
|
+
connectors?: Array<{
|
|
1136
|
+
name: string;
|
|
1137
|
+
repos: string;
|
|
1138
|
+
activeStatus?: 0 | 1;
|
|
1139
|
+
}>;
|
|
958
1140
|
}
|
|
959
1141
|
/**
|
|
960
|
-
*
|
|
961
|
-
*
|
|
962
|
-
* These options are supported by both CloudAgentProvider and LocalAgentProvider.
|
|
963
|
-
* Cloud: Server-side filtering, sorting, and pagination
|
|
964
|
-
* Local: Client-side filtering and sorting, no pagination (returns all)
|
|
1142
|
+
* 添加任务响应
|
|
965
1143
|
*/
|
|
966
|
-
interface
|
|
967
|
-
/**
|
|
968
|
-
|
|
969
|
-
* Cloud: Used for API pagination
|
|
970
|
-
* Local: Ignored (returns all sessions)
|
|
971
|
-
*/
|
|
972
|
-
page?: number;
|
|
973
|
-
/**
|
|
974
|
-
* Page size
|
|
975
|
-
* Cloud: Number of items per page (default 20, max 100)
|
|
976
|
-
* Local: Ignored (returns all sessions)
|
|
977
|
-
*/
|
|
978
|
-
size?: number;
|
|
979
|
-
/**
|
|
980
|
-
* Sort options
|
|
981
|
-
* Cloud: Sorts results by specified field and order
|
|
982
|
-
* Local: Sorts results by specified field and order
|
|
983
|
-
*/
|
|
984
|
-
sort?: ListAgentSort;
|
|
985
|
-
/**
|
|
986
|
-
* Filter conditions
|
|
987
|
-
* Cloud: Filters results by specified field values
|
|
988
|
-
* Local: Filters results by specified field values
|
|
989
|
-
*/
|
|
990
|
-
filters?: ListAgentFilter[];
|
|
991
|
-
/**
|
|
992
|
-
* Day range filter (e.g., agents created in last N days)
|
|
993
|
-
* Cloud: Filters by creation date
|
|
994
|
-
* Local: Filters by creation date
|
|
995
|
-
*/
|
|
996
|
-
dayRange?: number;
|
|
997
|
-
/**
|
|
998
|
-
* Title search keyword (matches agent title)
|
|
999
|
-
* Cloud: Server-side search
|
|
1000
|
-
* Local: Client-side search
|
|
1001
|
-
*/
|
|
1002
|
-
title?: string;
|
|
1144
|
+
interface AddTaskResponse {
|
|
1145
|
+
/** 任务ID */
|
|
1146
|
+
taskId: string;
|
|
1003
1147
|
}
|
|
1004
1148
|
/**
|
|
1005
|
-
*
|
|
1149
|
+
* 获取任务连接器列表响应
|
|
1006
1150
|
*/
|
|
1007
|
-
interface
|
|
1008
|
-
/**
|
|
1009
|
-
|
|
1010
|
-
/** Page size */
|
|
1011
|
-
size: number;
|
|
1012
|
-
/** Total number of items */
|
|
1013
|
-
total: number;
|
|
1014
|
-
/** Total number of pages */
|
|
1015
|
-
totalPages: number;
|
|
1016
|
-
/** Whether there is a next page */
|
|
1017
|
-
hasNext: boolean;
|
|
1018
|
-
/** Whether there is a previous page */
|
|
1019
|
-
hasPrev: boolean;
|
|
1151
|
+
interface ListTaskConnectorResponse {
|
|
1152
|
+
/** 连接器列表 */
|
|
1153
|
+
connectors: TaskConnector[];
|
|
1020
1154
|
}
|
|
1021
1155
|
/**
|
|
1022
|
-
*
|
|
1156
|
+
* 修改任务连接器激活状态请求
|
|
1023
1157
|
*/
|
|
1024
|
-
interface
|
|
1025
|
-
/**
|
|
1026
|
-
|
|
1027
|
-
/**
|
|
1028
|
-
|
|
1158
|
+
interface ModifyTaskConnectorActiveStatusRequest {
|
|
1159
|
+
/** 任务ID */
|
|
1160
|
+
taskId: string;
|
|
1161
|
+
/** 连接器名称 */
|
|
1162
|
+
name: string;
|
|
1163
|
+
/** 激活状态,0未激活,1已激活 */
|
|
1164
|
+
activeStatus: 0 | 1;
|
|
1029
1165
|
}
|
|
1030
1166
|
/**
|
|
1031
|
-
*
|
|
1167
|
+
* 修改任务连接器激活状态响应
|
|
1032
1168
|
*/
|
|
1033
|
-
interface
|
|
1034
|
-
/**
|
|
1035
|
-
|
|
1036
|
-
/** Associated agent ID */
|
|
1037
|
-
agentId: string;
|
|
1038
|
-
/** Agent name */
|
|
1039
|
-
name?: string;
|
|
1040
|
-
/** Agent status */
|
|
1041
|
-
status: AgentStatus;
|
|
1042
|
-
/** When the session/agent was created */
|
|
1043
|
-
createdAt?: Date;
|
|
1044
|
-
/** Last activity timestamp */
|
|
1045
|
-
lastActivityAt?: Date;
|
|
1046
|
-
/** Working directory (for local agents) */
|
|
1047
|
-
cwd?: string;
|
|
1169
|
+
interface ModifyTaskConnectorActiveStatusResponse {
|
|
1170
|
+
/** 任务ID */
|
|
1171
|
+
taskId: string;
|
|
1048
1172
|
}
|
|
1049
1173
|
/**
|
|
1050
|
-
*
|
|
1174
|
+
* 修改任务连接器仓库请求
|
|
1051
1175
|
*/
|
|
1052
|
-
interface
|
|
1053
|
-
/**
|
|
1054
|
-
|
|
1055
|
-
/**
|
|
1056
|
-
|
|
1176
|
+
interface ModifyTaskConnectorRepoRequest {
|
|
1177
|
+
/** 任务ID */
|
|
1178
|
+
taskId: string;
|
|
1179
|
+
/** 连接器名称 */
|
|
1180
|
+
name: string;
|
|
1181
|
+
/** 仓库列表 */
|
|
1182
|
+
repo: string[];
|
|
1057
1183
|
}
|
|
1058
1184
|
/**
|
|
1059
|
-
*
|
|
1185
|
+
* 修改任务连接器仓库响应
|
|
1060
1186
|
*/
|
|
1061
|
-
interface
|
|
1062
|
-
/**
|
|
1063
|
-
|
|
1064
|
-
/** Working directory */
|
|
1065
|
-
cwd: string;
|
|
1066
|
-
/** MCP server configurations */
|
|
1067
|
-
mcpServers?: McpServerConfig[];
|
|
1187
|
+
interface ModifyTaskConnectorRepoResponse {
|
|
1188
|
+
/** 任务ID */
|
|
1189
|
+
taskId: string;
|
|
1068
1190
|
}
|
|
1069
1191
|
/**
|
|
1070
|
-
*
|
|
1192
|
+
* oauth回调请求参数
|
|
1071
1193
|
*/
|
|
1072
|
-
interface
|
|
1073
|
-
/**
|
|
1074
|
-
|
|
1075
|
-
/**
|
|
1076
|
-
|
|
1077
|
-
/** Whether to activate the workspace window to foreground (default true) */
|
|
1078
|
-
needActivated?: boolean;
|
|
1194
|
+
interface SaveOauthTokenRequest {
|
|
1195
|
+
/** 连接器名称 */
|
|
1196
|
+
name: ConnectorType;
|
|
1197
|
+
/** 第三方回调code */
|
|
1198
|
+
authorizationCode: string;
|
|
1079
1199
|
}
|
|
1080
1200
|
/**
|
|
1081
|
-
*
|
|
1201
|
+
* 获取仓库列表请求参数
|
|
1082
1202
|
*/
|
|
1083
|
-
interface
|
|
1084
|
-
/**
|
|
1085
|
-
|
|
1086
|
-
/** Error message (if failed) */
|
|
1087
|
-
error?: string;
|
|
1203
|
+
interface GetRepoListRequest {
|
|
1204
|
+
/** 连接器名称 */
|
|
1205
|
+
name: ConnectorType;
|
|
1088
1206
|
}
|
|
1089
1207
|
/**
|
|
1090
|
-
*
|
|
1091
|
-
* Operations use the current session automatically
|
|
1208
|
+
* 撤销所有OAuth连接请求参数
|
|
1092
1209
|
*/
|
|
1093
|
-
interface
|
|
1094
|
-
/**
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
|
|
1098
|
-
/** Cancel an ongoing prompt */
|
|
1099
|
-
cancel(): Promise<void>;
|
|
1210
|
+
interface RevokeAllRequest {
|
|
1211
|
+
/** 连接器名称 */
|
|
1212
|
+
name: ConnectorType;
|
|
1213
|
+
/** 安装ID列表(可选,如果不传则撤销所有) */
|
|
1214
|
+
installationIds?: string[];
|
|
1100
1215
|
}
|
|
1101
1216
|
/**
|
|
1102
|
-
*
|
|
1217
|
+
* GitHub 仓库所有者信息
|
|
1103
1218
|
*/
|
|
1104
|
-
interface
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1219
|
+
interface OauthGitHubRepoOwner {
|
|
1220
|
+
login: string;
|
|
1221
|
+
avatar_url: string;
|
|
1222
|
+
url: string;
|
|
1223
|
+
html_url: string;
|
|
1224
|
+
followers_url: string;
|
|
1225
|
+
starred_url: string;
|
|
1226
|
+
repos_url: string;
|
|
1227
|
+
events_url: string;
|
|
1113
1228
|
}
|
|
1114
1229
|
/**
|
|
1115
|
-
*
|
|
1230
|
+
* GitHub 仓库信息
|
|
1116
1231
|
*/
|
|
1117
|
-
interface
|
|
1118
|
-
|
|
1119
|
-
|
|
1232
|
+
interface OauthGitHubRepo {
|
|
1233
|
+
name: string;
|
|
1234
|
+
full_name: string;
|
|
1235
|
+
private: boolean;
|
|
1236
|
+
html_url: string;
|
|
1237
|
+
url: string;
|
|
1238
|
+
teams_url: string;
|
|
1239
|
+
hooks_url: string;
|
|
1240
|
+
events_url: string;
|
|
1241
|
+
branches_url: string;
|
|
1242
|
+
git_commits_url: string;
|
|
1243
|
+
merges_url: string;
|
|
1244
|
+
pulls_url: string;
|
|
1245
|
+
git_url: string;
|
|
1246
|
+
clone_url: string;
|
|
1247
|
+
svn_url: string;
|
|
1248
|
+
downloads_url: string;
|
|
1249
|
+
description: string;
|
|
1250
|
+
owner: OauthGitHubRepoOwner;
|
|
1251
|
+
forks_count: number;
|
|
1120
1252
|
}
|
|
1121
1253
|
/**
|
|
1122
|
-
*
|
|
1254
|
+
* 工蜂仓库信息
|
|
1123
1255
|
*/
|
|
1124
|
-
interface
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1256
|
+
interface OauthGongfengRepo {
|
|
1257
|
+
id: number;
|
|
1258
|
+
description: string;
|
|
1259
|
+
public: boolean;
|
|
1260
|
+
archived: boolean;
|
|
1261
|
+
visibility_level: number;
|
|
1262
|
+
public_visibility: number;
|
|
1263
|
+
namespace: {
|
|
1264
|
+
name: string;
|
|
1265
|
+
description: string;
|
|
1266
|
+
path: string;
|
|
1267
|
+
};
|
|
1268
|
+
owner: {
|
|
1269
|
+
username: string;
|
|
1270
|
+
web_url: string;
|
|
1271
|
+
name: string;
|
|
1272
|
+
state: string;
|
|
1273
|
+
avatar_url: string;
|
|
1274
|
+
};
|
|
1275
|
+
name: string;
|
|
1276
|
+
name_with_namespace: string;
|
|
1277
|
+
path: string;
|
|
1278
|
+
path_with_namespace: string;
|
|
1279
|
+
type: string;
|
|
1280
|
+
default_branch: string;
|
|
1281
|
+
ssh_url_to_repo: string;
|
|
1282
|
+
http_url_to_repo: string;
|
|
1283
|
+
https_url_to_repo: string;
|
|
1284
|
+
web_url: string;
|
|
1285
|
+
avatar_url: string;
|
|
1129
1286
|
}
|
|
1130
1287
|
/**
|
|
1131
|
-
*
|
|
1288
|
+
* CNB仓库信息
|
|
1132
1289
|
*/
|
|
1133
|
-
interface
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1290
|
+
interface OauthCnbRepo {
|
|
1291
|
+
name: string;
|
|
1292
|
+
[key: string]: any;
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* 获取仓库列表响应
|
|
1296
|
+
*/
|
|
1297
|
+
interface GetRepoListResponse {
|
|
1298
|
+
github_repos?: {
|
|
1299
|
+
[key: string | number]: OauthGitHubRepo[];
|
|
1141
1300
|
};
|
|
1142
|
-
|
|
1143
|
-
|
|
1301
|
+
gongfeng_repos?: OauthGongfengRepo[];
|
|
1302
|
+
cnb_repos?: OauthCnbRepo[];
|
|
1144
1303
|
}
|
|
1145
1304
|
/**
|
|
1146
|
-
*
|
|
1305
|
+
* OAuth 用户信息
|
|
1147
1306
|
*/
|
|
1148
|
-
|
|
1307
|
+
interface OauthUserInfo {
|
|
1308
|
+
/** 头像 URL */
|
|
1309
|
+
avatarUrl: string;
|
|
1310
|
+
/** 用户名 */
|
|
1311
|
+
name: string;
|
|
1312
|
+
}
|
|
1149
1313
|
/**
|
|
1150
|
-
*
|
|
1314
|
+
* 获取 OAuth 用户信息请求参数
|
|
1151
1315
|
*/
|
|
1152
|
-
interface
|
|
1153
|
-
/**
|
|
1154
|
-
|
|
1155
|
-
/** Emitted when an artifact is created */
|
|
1156
|
-
artifactCreated: Artifact;
|
|
1157
|
-
/** Emitted when an artifact is updated */
|
|
1158
|
-
artifactUpdated: Artifact;
|
|
1159
|
-
/** Emitted when an artifact is deleted */
|
|
1160
|
-
artifactDeleted: Artifact;
|
|
1161
|
-
/** Emitted when a permission request is received */
|
|
1162
|
-
permissionRequest: {
|
|
1163
|
-
requestId: string;
|
|
1164
|
-
params: RequestPermissionRequest$1;
|
|
1165
|
-
};
|
|
1166
|
-
/** Emitted when a question request is received (ask_followup_question) */
|
|
1167
|
-
questionRequest: {
|
|
1168
|
-
toolCallId: string;
|
|
1169
|
-
request: QuestionRequest;
|
|
1170
|
-
};
|
|
1171
|
-
/** Emitted when usage data is updated */
|
|
1172
|
-
usageUpdate: UsageUpdate;
|
|
1173
|
-
/** Emitted when a checkpoint is created */
|
|
1174
|
-
checkpointCreated: CheckpointInfo;
|
|
1175
|
-
/** Emitted when a checkpoint is updated */
|
|
1176
|
-
checkpointUpdated: CheckpointInfo;
|
|
1177
|
-
/** Emitted when connected to agent */
|
|
1178
|
-
connected: void;
|
|
1179
|
-
/** Emitted when disconnected from agent */
|
|
1180
|
-
disconnected: void;
|
|
1181
|
-
/** Emitted when an error occurs */
|
|
1182
|
-
error: Error;
|
|
1316
|
+
interface GetOauthUserRequest {
|
|
1317
|
+
/** 连接器名称 */
|
|
1318
|
+
name: ConnectorType;
|
|
1183
1319
|
}
|
|
1184
1320
|
/**
|
|
1185
|
-
*
|
|
1321
|
+
* 获取 OAuth 用户信息响应
|
|
1186
1322
|
*/
|
|
1187
|
-
|
|
1323
|
+
interface GetOauthUserResponse {
|
|
1324
|
+
/** 用户信息 */
|
|
1325
|
+
user: OauthUserInfo;
|
|
1326
|
+
}
|
|
1188
1327
|
/**
|
|
1189
|
-
*
|
|
1328
|
+
* Backend Provider 配置选项
|
|
1190
1329
|
*/
|
|
1191
|
-
interface
|
|
1192
|
-
/**
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
|
|
1196
|
-
/** Whether the agent is connected */
|
|
1197
|
-
readonly isConnected: boolean;
|
|
1198
|
-
/** Agent capabilities */
|
|
1199
|
-
readonly capabilities?: AgentCapabilities;
|
|
1330
|
+
interface BackendProviderConfig {
|
|
1331
|
+
/** API 基础 URL (例如: https://api.example.com) */
|
|
1332
|
+
baseUrl: string;
|
|
1333
|
+
/** 认证 Token */
|
|
1334
|
+
authToken?: string;
|
|
1200
1335
|
}
|
|
1201
1336
|
/**
|
|
1202
|
-
*
|
|
1203
|
-
|
|
1337
|
+
* 企业用户用量信息
|
|
1338
|
+
*/
|
|
1339
|
+
interface EnterpriseUsage {
|
|
1340
|
+
/** 已使用 credit */
|
|
1341
|
+
credit: number;
|
|
1342
|
+
/** 周期开始时间 */
|
|
1343
|
+
cycleStartTime: string;
|
|
1344
|
+
/** 周期结束时间 */
|
|
1345
|
+
cycleEndTime: string;
|
|
1346
|
+
/** 周期重置时间 */
|
|
1347
|
+
cycleResetTime: string;
|
|
1348
|
+
/** 限额数量 */
|
|
1349
|
+
limitNum: number;
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* IBackendProvider 接口
|
|
1204
1353
|
*
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1354
|
+
* 定义与后端 API 交互的抽象接口
|
|
1355
|
+
*
|
|
1356
|
+
* 注意:getAgents 和 getModels 方法已废弃并移除,
|
|
1357
|
+
* 请使用 IAgentAdapter 中的对应方法
|
|
1209
1358
|
*/
|
|
1210
|
-
interface
|
|
1211
|
-
/** Session ID */
|
|
1212
|
-
readonly id: string;
|
|
1213
|
-
/** Agent ID */
|
|
1214
|
-
readonly agentId: string;
|
|
1215
|
-
/** Agent state (direct access to underlying agent state) */
|
|
1216
|
-
readonly agentState: AgentState;
|
|
1217
|
-
/** Agent capabilities (available after connection) */
|
|
1218
|
-
readonly capabilities?: AgentCapabilities;
|
|
1219
|
-
/** Available session modes */
|
|
1220
|
-
readonly availableModes?: SessionMode[];
|
|
1221
|
-
/** Current session mode */
|
|
1222
|
-
readonly currentMode?: string;
|
|
1223
|
-
/** Available slash commands (updated via available_commands_update) */
|
|
1224
|
-
readonly availableCommands: AvailableCommand[];
|
|
1225
|
-
/** Whether the session is active */
|
|
1226
|
-
readonly isActive: boolean;
|
|
1359
|
+
interface IBackendProvider {
|
|
1227
1360
|
/**
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1361
|
+
* 获取当前账号信息
|
|
1362
|
+
* @returns Promise<Account | null> 账号信息,未登录时返回 null
|
|
1230
1363
|
*/
|
|
1231
|
-
|
|
1232
|
-
/** Agent operations */
|
|
1233
|
-
readonly agent: SessionAgentOperations;
|
|
1234
|
-
/** Prompts resource */
|
|
1235
|
-
readonly prompts: PromptsResource;
|
|
1236
|
-
/** Artifacts resource */
|
|
1237
|
-
readonly artifacts: ArtifactsResource;
|
|
1238
|
-
/** Files resource */
|
|
1239
|
-
readonly files: FilesResource;
|
|
1240
|
-
/** Resolve a permission request */
|
|
1241
|
-
resolvePermission(requestId: string, optionId: string): boolean;
|
|
1242
|
-
/** Reject a permission request */
|
|
1243
|
-
rejectPermission(requestId: string, reason?: string): boolean;
|
|
1244
|
-
/** Answer a question request with user's selections */
|
|
1245
|
-
answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
|
|
1246
|
-
/** Cancel a question request */
|
|
1247
|
-
cancelQuestion(toolCallId: string, reason?: string): boolean;
|
|
1248
|
-
/** Callback for tool operations (skip or cancel) */
|
|
1249
|
-
toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
|
|
1250
|
-
success: boolean;
|
|
1251
|
-
error?: string;
|
|
1252
|
-
}>;
|
|
1253
|
-
/** Set the current session mode */
|
|
1254
|
-
setMode(modeId: string): Promise<void>;
|
|
1255
|
-
/** Set the current session model */
|
|
1256
|
-
setSessionModel(modelId: string): Promise<void>;
|
|
1257
|
-
/** Subscribe to an event */
|
|
1258
|
-
on<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
1259
|
-
/** Unsubscribe from an event */
|
|
1260
|
-
off<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
1261
|
-
/** Subscribe to an event once */
|
|
1262
|
-
once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
1263
|
-
/** Disconnect from the session/agent */
|
|
1264
|
-
disconnect(): void;
|
|
1265
|
-
/** Symbol.dispose for 'using' keyword support */
|
|
1266
|
-
[Symbol.dispose](): void;
|
|
1267
|
-
}
|
|
1268
|
-
/**
|
|
1269
|
-
* 环境类型
|
|
1270
|
-
*/
|
|
1271
|
-
type EnvironmentType = 'local' | 'cloud';
|
|
1272
|
-
/**
|
|
1273
|
-
* Agent provider interface
|
|
1274
|
-
*
|
|
1275
|
-
* Responsible for:
|
|
1276
|
-
* - Managing agent state/configuration storage
|
|
1277
|
-
* - Creating connections to agents
|
|
1278
|
-
* - Abstracting away transport details (cloud/local)
|
|
1279
|
-
*
|
|
1280
|
-
* The provider.connect() method returns an AgentConnection.
|
|
1281
|
-
* The client wraps the connection in an ActiveSession instance.
|
|
1282
|
-
*
|
|
1283
|
-
* @typeParam C - Connection type used by this provider (e.g., CloudAgentConnection, LocalAgentConnection)
|
|
1284
|
-
*/
|
|
1285
|
-
interface AgentProvider<C extends AgentConnection = AgentConnection> {
|
|
1364
|
+
getAccount(): Promise<Account | null>;
|
|
1286
1365
|
/**
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
* @param params - Optional session params (used by LocalAgentProvider to get cwd)
|
|
1290
|
-
* @returns Agent ID (Cloud: UUID, Local: cwd)
|
|
1366
|
+
* 获取用户连接器列表
|
|
1367
|
+
* @returns Promise<ListUserConnectorResponse | null> 用户连接器列表,失败时返回 null
|
|
1291
1368
|
*/
|
|
1292
|
-
|
|
1293
|
-
/** Get agent state by ID */
|
|
1294
|
-
get(agentId: string): Promise<AgentState | undefined>;
|
|
1369
|
+
getUserConnector(): Promise<ListUserConnectorResponse>;
|
|
1295
1370
|
/**
|
|
1296
|
-
*
|
|
1297
|
-
*
|
|
1298
|
-
* @
|
|
1299
|
-
* Cloud providers use these for API queries and return server pagination
|
|
1300
|
-
* Local providers apply client-side filtering and return synthetic pagination
|
|
1301
|
-
* @returns Object containing agents array and pagination info
|
|
1371
|
+
* 修改用户连接器连接状态
|
|
1372
|
+
* @param request 请求参数
|
|
1373
|
+
* @returns Promise<void>
|
|
1302
1374
|
*/
|
|
1303
|
-
|
|
1304
|
-
/** Connect to an agent and return the connection */
|
|
1305
|
-
connect(agentId: string): Promise<C>;
|
|
1306
|
-
/** Delete an agent by ID */
|
|
1307
|
-
delete(agentId: string): Promise<boolean>;
|
|
1375
|
+
modifyUserConnectorConnectStatus(request: ModifyUserConnectorConnectStatusRequest): Promise<void>;
|
|
1308
1376
|
/**
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1312
|
-
* @param agentId - Agent ID to archive
|
|
1313
|
-
* @returns Object containing the archived agent ID
|
|
1377
|
+
* 修改用户连接器仓库
|
|
1378
|
+
* @param request 请求参数
|
|
1379
|
+
* @returns Promise<void>
|
|
1314
1380
|
*/
|
|
1315
|
-
|
|
1316
|
-
id: string;
|
|
1317
|
-
}>;
|
|
1381
|
+
modifyUserConnectorRepo(request: ModifyUserConnectorRepoRequest): Promise<void>;
|
|
1318
1382
|
/**
|
|
1319
|
-
*
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
* @param agentId - Agent ID to rename
|
|
1323
|
-
* @param title - New title for the agent
|
|
1324
|
-
* @returns Object containing the renamed agent ID
|
|
1383
|
+
* 修改用户连接器激活状态
|
|
1384
|
+
* @param request 请求参数
|
|
1385
|
+
* @returns Promise<void>
|
|
1325
1386
|
*/
|
|
1326
|
-
|
|
1327
|
-
id: string;
|
|
1328
|
-
}>;
|
|
1329
|
-
/** Filesystem provider (optional - some providers may not support filesystem operations) */
|
|
1330
|
-
readonly filesystem?: FilesystemProvider;
|
|
1387
|
+
modifyUserConnectorActiveStatus(request: ModifyUserConnectorActiveStatusRequest): Promise<void>;
|
|
1331
1388
|
/**
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
* @
|
|
1335
|
-
* @returns Array of model information
|
|
1389
|
+
* 删除用户连接器
|
|
1390
|
+
* @param name 连接器名称
|
|
1391
|
+
* @returns Promise<void>
|
|
1336
1392
|
*/
|
|
1337
|
-
|
|
1393
|
+
deleteUserConnector(name: ConnectorType): Promise<void>;
|
|
1338
1394
|
/**
|
|
1339
|
-
*
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1342
|
-
* @param sessionId - Session ID returned by connection.createSession()
|
|
1343
|
-
* @param agentId - Agent ID (cwd for Local)
|
|
1395
|
+
* 添加任务
|
|
1396
|
+
* @param request 请求参数
|
|
1397
|
+
* @returns Promise<AddTaskResponse>
|
|
1344
1398
|
*/
|
|
1345
|
-
|
|
1399
|
+
addConnectorTask(request: AddTaskRequest): Promise<AddTaskResponse>;
|
|
1346
1400
|
/**
|
|
1347
|
-
*
|
|
1348
|
-
*
|
|
1349
|
-
* @
|
|
1350
|
-
* @returns Response with success status
|
|
1401
|
+
* 获取任务连接器列表
|
|
1402
|
+
* @param taskId 任务ID
|
|
1403
|
+
* @returns Promise<ListTaskConnectorResponse>
|
|
1351
1404
|
*/
|
|
1352
|
-
|
|
1405
|
+
getTaskConnector(taskId: string): Promise<ListTaskConnectorResponse>;
|
|
1353
1406
|
/**
|
|
1354
|
-
*
|
|
1355
|
-
*
|
|
1356
|
-
* @
|
|
1357
|
-
* @returns Response with file paths and cancel status
|
|
1407
|
+
* 修改任务连接器激活状态
|
|
1408
|
+
* @param request 请求参数
|
|
1409
|
+
* @returns Promise<ModifyTaskConnectorActiveStatusResponse>
|
|
1358
1410
|
*/
|
|
1359
|
-
|
|
1411
|
+
modifyTaskConnectorActiveStatus(request: ModifyTaskConnectorActiveStatusRequest): Promise<ModifyTaskConnectorActiveStatusResponse>;
|
|
1360
1412
|
/**
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
1363
|
-
* @
|
|
1364
|
-
* @returns Response with folder paths and cancel status
|
|
1413
|
+
* 修改任务连接器仓库
|
|
1414
|
+
* @param request 请求参数
|
|
1415
|
+
* @returns Promise<ModifyTaskConnectorRepoResponse>
|
|
1365
1416
|
*/
|
|
1366
|
-
|
|
1417
|
+
modifyTaskConnectorRepo(request: ModifyTaskConnectorRepoRequest): Promise<ModifyTaskConnectorRepoResponse>;
|
|
1367
1418
|
/**
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1370
|
-
* @param params - Upload parameters including file content
|
|
1371
|
-
* @returns Response with cloud URL after successful upload
|
|
1419
|
+
* oauth回调,后端用第三方的code换token的
|
|
1372
1420
|
*/
|
|
1373
|
-
|
|
1421
|
+
saveOauthToken(request: SaveOauthTokenRequest): Promise<void>;
|
|
1374
1422
|
/**
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1377
|
-
* @
|
|
1378
|
-
* @returns Response with search results
|
|
1423
|
+
* 获取OAuth连接器的仓库列表
|
|
1424
|
+
* @param request 请求参数
|
|
1425
|
+
* @returns Promise<GetRepoListResponse> 仓库列表响应
|
|
1379
1426
|
*/
|
|
1380
|
-
|
|
1427
|
+
getRepoList(request: GetRepoListRequest): Promise<GetRepoListResponse>;
|
|
1381
1428
|
/**
|
|
1382
|
-
*
|
|
1383
|
-
*
|
|
1384
|
-
*
|
|
1385
|
-
* @param event - Event name
|
|
1386
|
-
* @param handler - Event handler function
|
|
1429
|
+
* 撤销OAuth连接器的所有连接
|
|
1430
|
+
* @param request 请求参数
|
|
1431
|
+
* @returns Promise<void>
|
|
1387
1432
|
*/
|
|
1388
|
-
|
|
1433
|
+
revokeAll(request: RevokeAllRequest): Promise<void>;
|
|
1389
1434
|
/**
|
|
1390
|
-
*
|
|
1391
|
-
*
|
|
1392
|
-
* @
|
|
1393
|
-
* @param handler - Event handler function to remove
|
|
1435
|
+
* 获取 OAuth 用户信息
|
|
1436
|
+
* @param request 请求参数
|
|
1437
|
+
* @returns Promise<GetOauthUserResponse> 用户信息响应
|
|
1394
1438
|
*/
|
|
1395
|
-
|
|
1396
|
-
}
|
|
1397
|
-
/**
|
|
1398
|
-
* AgentClient initialization options
|
|
1399
|
-
*/
|
|
1400
|
-
interface AgentClientOptions {
|
|
1401
|
-
/** Agent provider (required) */
|
|
1402
|
-
provider: AgentProvider;
|
|
1403
|
-
/** Logger instance */
|
|
1404
|
-
logger?: Logger;
|
|
1405
|
-
/** Client capabilities (sent during initialization) */
|
|
1406
|
-
clientCapabilities?: ClientCapabilities$1;
|
|
1439
|
+
getOauthUser(request: GetOauthUserRequest): Promise<GetOauthUserResponse>;
|
|
1407
1440
|
/**
|
|
1408
|
-
*
|
|
1409
|
-
* -
|
|
1410
|
-
* -
|
|
1441
|
+
* 触发登录流程
|
|
1442
|
+
* - Web 环境: 跳转到登录页面
|
|
1443
|
+
* - IDE 环境: 通过 IPC 通知 IDE 打开登录流程
|
|
1411
1444
|
*/
|
|
1412
|
-
|
|
1413
|
-
}
|
|
1414
|
-
/**
|
|
1415
|
-
* Client sessions resource interface
|
|
1416
|
-
* Top-level API for session management
|
|
1417
|
-
*
|
|
1418
|
-
* Key design:
|
|
1419
|
-
* - list() returns sessions with pagination info (mapped from agents)
|
|
1420
|
-
* - create() creates a new session (auto-creates agent and connects)
|
|
1421
|
-
* - load() loads an existing session (finds agent by sessionId and connects)
|
|
1422
|
-
* - archive() archives a session/agent
|
|
1423
|
-
* - initializeWorkspace() initializes a workspace for future sessions
|
|
1424
|
-
*/
|
|
1425
|
-
interface ClientSessionsResource {
|
|
1445
|
+
login(): Promise<void>;
|
|
1426
1446
|
/**
|
|
1427
|
-
*
|
|
1428
|
-
* Cloud: Returns server-side filtered/sorted/paginated results
|
|
1429
|
-
* Local: Returns client-side filtered/sorted results (synthetic pagination)
|
|
1447
|
+
* 登出账号
|
|
1430
1448
|
*/
|
|
1431
|
-
|
|
1432
|
-
/** Create a new session (auto-creates agent and connects) */
|
|
1433
|
-
create(params: CreateSessionParams$1): Promise<ActiveSession>;
|
|
1434
|
-
/** Load an existing session (finds agent by sessionId and connects) */
|
|
1435
|
-
load(params: LoadSessionParams$1): Promise<ActiveSession>;
|
|
1449
|
+
logout(): Promise<void>;
|
|
1436
1450
|
/**
|
|
1437
|
-
*
|
|
1438
|
-
* @param
|
|
1439
|
-
* @returns Object containing the archived session ID
|
|
1451
|
+
* 重新加载窗口(可选,仅 IPC 环境支持)
|
|
1452
|
+
* @param params 可选参数,如 locale
|
|
1440
1453
|
*/
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
}>;
|
|
1454
|
+
reloadWindow?(params?: {
|
|
1455
|
+
locale?: string;
|
|
1456
|
+
}): Promise<void>;
|
|
1444
1457
|
/**
|
|
1445
|
-
*
|
|
1446
|
-
* @param
|
|
1447
|
-
* @param
|
|
1448
|
-
* @returns
|
|
1458
|
+
* 监听事件(可选,用于 IPC 环境)
|
|
1459
|
+
* @param event 事件名称
|
|
1460
|
+
* @param callback 回调函数
|
|
1461
|
+
* @returns 取消订阅函数
|
|
1449
1462
|
*/
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
readonly models: ModelsResource;
|
|
1457
|
-
/** Get current workspaces list */
|
|
1458
|
-
getCurrentWorkspaces(filter?: {
|
|
1459
|
-
activeOnly?: boolean;
|
|
1460
|
-
}): Promise<WorkspaceInfo[]>;
|
|
1461
|
-
/** Subscribe to sessions resource events */
|
|
1462
|
-
on<K extends keyof SessionsResourceEvents>(event: K, handler: SessionsResourceEventHandler<K>): void;
|
|
1463
|
-
/** Unsubscribe from sessions resource events */
|
|
1464
|
-
off<K extends keyof SessionsResourceEvents>(event: K, handler: SessionsResourceEventHandler<K>): void;
|
|
1465
|
-
/** Open a workspace (for LocalAgentProvider) */
|
|
1466
|
-
openWorkspace(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
|
|
1467
|
-
/** Pick files from file dialog (for LocalAgentProvider) */
|
|
1468
|
-
pickFile(params?: PickFileParams): Promise<PickFileResponse>;
|
|
1469
|
-
/** Pick folders from folder dialog (for LocalAgentProvider) */
|
|
1470
|
-
pickFolder(params?: PickFolderParams): Promise<PickFolderResponse>;
|
|
1471
|
-
/** Upload a file to cloud storage */
|
|
1472
|
-
uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
|
|
1473
|
-
/** Search for files in the workspace (for LocalAgentProvider) */
|
|
1474
|
-
searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
|
|
1463
|
+
on?(event: string, callback: (data?: unknown) => void): () => void;
|
|
1464
|
+
/** 获取企业用户用量信息
|
|
1465
|
+
* @param enterpriseId 企业 ID
|
|
1466
|
+
* @returns Promise<EnterpriseUsage | null> 企业用户用量信息
|
|
1467
|
+
*/
|
|
1468
|
+
getEnterpriseUsage?(enterpriseId: string): Promise<EnterpriseUsage | null>;
|
|
1475
1469
|
}
|
|
1476
1470
|
/**
|
|
1477
|
-
*
|
|
1471
|
+
* 插件作用域
|
|
1478
1472
|
*/
|
|
1479
|
-
|
|
1480
|
-
/** Folder path */
|
|
1481
|
-
path: string;
|
|
1482
|
-
/** Folder display name */
|
|
1483
|
-
label: string;
|
|
1484
|
-
}
|
|
1473
|
+
type PluginScope = 'user' | 'project';
|
|
1485
1474
|
/**
|
|
1486
|
-
*
|
|
1475
|
+
* 插件操作类型
|
|
1487
1476
|
*/
|
|
1488
|
-
|
|
1489
|
-
/** Display name for the filter */
|
|
1490
|
-
readonly name: string;
|
|
1491
|
-
/** File extensions (without dot) */
|
|
1492
|
-
readonly extensions: string[];
|
|
1493
|
-
}
|
|
1477
|
+
type PluginOperation = 'enable' | 'disable';
|
|
1494
1478
|
/**
|
|
1495
|
-
*
|
|
1479
|
+
* 批量插件操作项
|
|
1496
1480
|
*/
|
|
1497
|
-
interface
|
|
1498
|
-
/**
|
|
1499
|
-
readonly
|
|
1500
|
-
/**
|
|
1501
|
-
readonly
|
|
1502
|
-
/**
|
|
1503
|
-
readonly
|
|
1481
|
+
interface BatchPluginOperationItem {
|
|
1482
|
+
/** 插件名称 */
|
|
1483
|
+
readonly pluginName: string;
|
|
1484
|
+
/** 市场名称 */
|
|
1485
|
+
readonly marketplaceName: string;
|
|
1486
|
+
/** 作用域 */
|
|
1487
|
+
readonly scope: PluginScope;
|
|
1488
|
+
/** 操作类型 */
|
|
1489
|
+
readonly operation: PluginOperation;
|
|
1504
1490
|
}
|
|
1505
1491
|
/**
|
|
1506
|
-
*
|
|
1492
|
+
* 批量插件操作请求
|
|
1507
1493
|
*/
|
|
1508
|
-
interface
|
|
1509
|
-
/**
|
|
1510
|
-
readonly
|
|
1511
|
-
/** Whether user cancelled the dialog */
|
|
1512
|
-
readonly canceled: boolean;
|
|
1513
|
-
/** Error message (if failed) */
|
|
1514
|
-
readonly error?: string;
|
|
1494
|
+
interface BatchPluginOperationRequest {
|
|
1495
|
+
/** 操作项列表 */
|
|
1496
|
+
readonly items: BatchPluginOperationItem[];
|
|
1515
1497
|
}
|
|
1516
1498
|
/**
|
|
1517
|
-
*
|
|
1499
|
+
* 批量插件操作失败项
|
|
1518
1500
|
*/
|
|
1519
|
-
interface
|
|
1520
|
-
/**
|
|
1521
|
-
readonly
|
|
1501
|
+
interface BatchPluginOperationFailedItem extends BatchPluginOperationItem {
|
|
1502
|
+
/** 错误信息 */
|
|
1503
|
+
readonly error: string;
|
|
1522
1504
|
}
|
|
1523
1505
|
/**
|
|
1524
|
-
*
|
|
1506
|
+
* 批量插件操作结果
|
|
1525
1507
|
*/
|
|
1526
|
-
interface
|
|
1527
|
-
/**
|
|
1528
|
-
readonly
|
|
1529
|
-
/**
|
|
1530
|
-
readonly
|
|
1531
|
-
/**
|
|
1532
|
-
readonly
|
|
1508
|
+
interface BatchPluginOperationResult {
|
|
1509
|
+
/** 是否全部成功 */
|
|
1510
|
+
readonly success: boolean;
|
|
1511
|
+
/** 成功的插件列表 */
|
|
1512
|
+
readonly succeededPlugins: BatchPluginOperationItem[];
|
|
1513
|
+
/** 失败的插件列表 */
|
|
1514
|
+
readonly failedPlugins: BatchPluginOperationFailedItem[];
|
|
1533
1515
|
}
|
|
1516
|
+
//#endregion
|
|
1517
|
+
//#region ../agent-provider/lib/common/client/types.d.ts
|
|
1534
1518
|
/**
|
|
1535
|
-
*
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1519
|
+
* Session connection information
|
|
1520
|
+
* 包含连接到Agent会话所需的所有信息,包括sandbox连接凭证
|
|
1521
|
+
*/
|
|
1522
|
+
interface SessionConnectionInfo {
|
|
1523
|
+
/** Session ID */
|
|
1524
|
+
sessionId: string;
|
|
1525
|
+
/** Agent ID */
|
|
1526
|
+
agentId: string;
|
|
1527
|
+
/** Session endpoint URL (Agent的WebSocket/HTTP端点) */
|
|
1528
|
+
link: string;
|
|
1529
|
+
/** Session token (JWT格式的认证令牌) */
|
|
1530
|
+
token: string;
|
|
1531
|
+
/** Sandbox ID (E2B沙箱的唯一标识) */
|
|
1532
|
+
sandboxId: string;
|
|
1533
|
+
/** Session expiration timestamp (unix timestamp) */
|
|
1534
|
+
expireAt: number;
|
|
1535
|
+
/** Current working directory (optional) */
|
|
1536
|
+
cwd?: string;
|
|
1540
1537
|
}
|
|
1541
1538
|
/**
|
|
1542
|
-
*
|
|
1539
|
+
* Agent 来源类型
|
|
1543
1540
|
*/
|
|
1544
|
-
|
|
1545
|
-
/** Whether upload was successful */
|
|
1546
|
-
readonly success: boolean;
|
|
1547
|
-
/** Cloud URLs corresponding to each uploaded file (same order as input files) */
|
|
1548
|
-
readonly urls?: string[];
|
|
1549
|
-
/** URL expiration time in seconds (from backend) */
|
|
1550
|
-
readonly expireSeconds?: number;
|
|
1551
|
-
/** Error message (if upload failed) */
|
|
1552
|
-
readonly error?: string;
|
|
1553
|
-
}
|
|
1541
|
+
type AgentStateType = 'local' | 'cloud';
|
|
1554
1542
|
/**
|
|
1555
|
-
*
|
|
1543
|
+
* 云端 Agent 可见性
|
|
1556
1544
|
*/
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1545
|
+
type CloudAgentVisibility = 'PRIVATE' | 'PUBLIC' | 'TEAM';
|
|
1546
|
+
/**
|
|
1547
|
+
* 云端 Agent 来源信息
|
|
1548
|
+
*/
|
|
1549
|
+
interface CloudAgentSourceInfo {
|
|
1550
|
+
/** 提供商: github, gitlab 等 */
|
|
1551
|
+
provider: string;
|
|
1552
|
+
/** 分支/引用 */
|
|
1553
|
+
ref: string;
|
|
1554
|
+
/** 仓库路径 */
|
|
1555
|
+
repository: string;
|
|
1560
1556
|
}
|
|
1561
1557
|
/**
|
|
1562
|
-
*
|
|
1558
|
+
* 云端 Agent 目标信息
|
|
1563
1559
|
*/
|
|
1564
|
-
interface
|
|
1565
|
-
/**
|
|
1566
|
-
|
|
1567
|
-
/**
|
|
1568
|
-
|
|
1560
|
+
interface CloudAgentTarget {
|
|
1561
|
+
/** 是否自动创建 PR */
|
|
1562
|
+
autoCreatePr: boolean;
|
|
1563
|
+
/** 分支名称 */
|
|
1564
|
+
branchName?: string;
|
|
1565
|
+
/** PR URL */
|
|
1566
|
+
prUrl?: string;
|
|
1567
|
+
/** Agent URL */
|
|
1568
|
+
url?: string;
|
|
1569
1569
|
}
|
|
1570
1570
|
/**
|
|
1571
|
-
*
|
|
1571
|
+
* AgentState 基础接口
|
|
1572
|
+
* 所有类型的 AgentState 都必须实现此接口
|
|
1572
1573
|
*/
|
|
1573
|
-
interface
|
|
1574
|
-
/**
|
|
1575
|
-
|
|
1576
|
-
/**
|
|
1577
|
-
|
|
1578
|
-
/**
|
|
1579
|
-
|
|
1580
|
-
/**
|
|
1581
|
-
|
|
1582
|
-
/**
|
|
1583
|
-
|
|
1574
|
+
interface BaseAgentState {
|
|
1575
|
+
/** Unique agent ID */
|
|
1576
|
+
id: string;
|
|
1577
|
+
/** Display name */
|
|
1578
|
+
name?: string;
|
|
1579
|
+
/** Description */
|
|
1580
|
+
description?: string;
|
|
1581
|
+
/** Agent type */
|
|
1582
|
+
type: AgentStateType;
|
|
1583
|
+
/** Current connection status */
|
|
1584
|
+
status: AgentStatus;
|
|
1585
|
+
/** Agent capabilities (available after connection) */
|
|
1586
|
+
capabilities?: AgentCapabilities;
|
|
1587
|
+
/** When the agent was created */
|
|
1588
|
+
createdAt?: Date;
|
|
1589
|
+
/** When the agent was last updated */
|
|
1590
|
+
updatedAt?: Date;
|
|
1591
|
+
/** 是否为 playground */
|
|
1592
|
+
isPlayground?: boolean;
|
|
1584
1593
|
}
|
|
1585
1594
|
/**
|
|
1586
|
-
*
|
|
1595
|
+
* LocalAgentState - 本地 Agent 状态
|
|
1596
|
+
* 来自本地 IPC 通信的 Agent
|
|
1587
1597
|
*/
|
|
1588
|
-
interface
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
readonly cwd?: string;
|
|
1598
|
+
interface LocalAgentState extends BaseAgentState {
|
|
1599
|
+
type: 'local';
|
|
1600
|
+
/** 工作目录 */
|
|
1601
|
+
cwd: string;
|
|
1593
1602
|
}
|
|
1594
1603
|
/**
|
|
1595
|
-
*
|
|
1604
|
+
* CloudAgentState - 云端 Agent 状态
|
|
1605
|
+
* 来自远程 API 的云端实例
|
|
1596
1606
|
*/
|
|
1597
|
-
interface
|
|
1598
|
-
|
|
1599
|
-
readonly results: SearchFileResult[];
|
|
1600
|
-
/** Error message (if failed) */
|
|
1601
|
-
readonly error?: string;
|
|
1607
|
+
interface CloudAgentState extends BaseAgentState {
|
|
1608
|
+
type: 'cloud';
|
|
1602
1609
|
}
|
|
1603
|
-
//#endregion
|
|
1604
|
-
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
|
|
1605
1610
|
/**
|
|
1606
|
-
*
|
|
1607
|
-
* Uses Streamable HTTP transport to connect to cloud-hosted ACP agents
|
|
1608
|
-
* Uses composition pattern - implements event emitter methods internally
|
|
1611
|
+
* AgentState - Unified agent state object exposed to client users
|
|
1609
1612
|
*
|
|
1610
|
-
*
|
|
1611
|
-
*
|
|
1612
|
-
* - Implement connection health checks (detect and handle connection failures/reconnection)
|
|
1613
|
-
* - Handle token expiration (refresh or re-authentication when tokens expire)
|
|
1614
|
-
* - Emit 'disconnected' event when connection becomes unhealthy so provider can clean up cache
|
|
1613
|
+
* This is the primary way clients access agent information.
|
|
1614
|
+
* Uses discriminated union pattern to distinguish between local and cloud agents.
|
|
1615
1615
|
*/
|
|
1616
|
-
|
|
1617
|
-
private client;
|
|
1618
|
-
private listeners;
|
|
1619
|
-
private onceListeners;
|
|
1620
|
-
/**
|
|
1621
|
-
* Flag to suppress sessionUpdate event emission during streaming.
|
|
1622
|
-
* When true, onSessionUpdate callback won't emit to avoid duplicate messages with promptStream.
|
|
1623
|
-
*/
|
|
1624
|
-
private _isStreaming;
|
|
1625
|
-
/**
|
|
1626
|
-
* Session connection information (sandboxId, link, token, etc.)
|
|
1627
|
-
* Set by CloudAgentProvider.connect() after fetching session data from backend.
|
|
1628
|
-
*/
|
|
1629
|
-
private _sessionConnectionInfo?;
|
|
1630
|
-
readonly agentId: string;
|
|
1631
|
-
readonly transport: "cloud";
|
|
1632
|
-
readonly cwd: string;
|
|
1633
|
-
constructor(agentId: string, config: CloudConnectionConfig, cwd?: string);
|
|
1634
|
-
private setupEventForwarding;
|
|
1635
|
-
on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
1636
|
-
off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
1637
|
-
once<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
1638
|
-
emit<K extends keyof ConnectionEvents>(event: K, data: ConnectionEvents[K]): boolean;
|
|
1639
|
-
removeAllListeners<K extends keyof ConnectionEvents>(event?: K): this;
|
|
1640
|
-
get state(): AgentStatus;
|
|
1641
|
-
get isInitialized(): boolean;
|
|
1642
|
-
get capabilities(): AgentCapabilities | undefined;
|
|
1643
|
-
get initializeResult(): InitializeResponse | undefined;
|
|
1644
|
-
connect(): Promise<InitializeResponse>;
|
|
1645
|
-
disconnect(): Promise<void>;
|
|
1646
|
-
createSession(params: CreateSessionParams): Promise<NewSessionResponse>;
|
|
1647
|
-
loadSession(params: LoadSessionParams): Promise<LoadSessionResponse>;
|
|
1648
|
-
setSessionMode(sessionId: string, modeId: string): Promise<SetSessionModeResponse>;
|
|
1649
|
-
setSessionModel(sessionId: string, modelId: string): Promise<SetSessionModelResponse>;
|
|
1650
|
-
prompt(sessionId: string, params: PromptParams): Promise<PromptResponse$1>;
|
|
1651
|
-
promptStream(sessionId: string, params: PromptParams): AsyncIterable<SessionNotification>;
|
|
1652
|
-
cancel(sessionId: string): Promise<void>;
|
|
1653
|
-
resolvePermission(requestId: string, optionId: string): boolean;
|
|
1654
|
-
rejectPermission(requestId: string, reason?: string): boolean;
|
|
1655
|
-
getPendingPermissions(): Map<string, {
|
|
1656
|
-
params: RequestPermissionRequest;
|
|
1657
|
-
createdAt: number;
|
|
1658
|
-
}>;
|
|
1659
|
-
hasPendingPermissions(): boolean;
|
|
1660
|
-
answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
|
|
1661
|
-
cancelQuestion(toolCallId: string, reason?: string): boolean;
|
|
1662
|
-
getPendingQuestions(): Map<string, {
|
|
1663
|
-
request: QuestionRequest;
|
|
1664
|
-
createdAt: number;
|
|
1665
|
-
}>;
|
|
1666
|
-
hasPendingQuestions(): boolean;
|
|
1667
|
-
toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
|
|
1668
|
-
success: boolean;
|
|
1669
|
-
error?: string;
|
|
1670
|
-
}>;
|
|
1671
|
-
/**
|
|
1672
|
-
* Set session connection information
|
|
1673
|
-
* Called by CloudAgentProvider.connect() after fetching session data from backend.
|
|
1674
|
-
*/
|
|
1675
|
-
setSessionConnectionInfo(info: SessionConnectionInfo): void;
|
|
1676
|
-
/**
|
|
1677
|
-
* Get session connection information
|
|
1678
|
-
* Contains sandboxId, link, token, etc.
|
|
1679
|
-
*/
|
|
1680
|
-
get sessionConnectionInfo(): SessionConnectionInfo | undefined;
|
|
1681
|
-
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
1682
|
-
}
|
|
1683
|
-
//#endregion
|
|
1684
|
-
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/api-types.d.ts
|
|
1616
|
+
type AgentState = LocalAgentState | CloudAgentState;
|
|
1685
1617
|
/**
|
|
1686
|
-
*
|
|
1687
|
-
* POST /v2/cloudagent/agentmgmt/agents/{id}/archive
|
|
1618
|
+
* 类型守卫:判断是否为 CloudAgentState
|
|
1688
1619
|
*/
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1620
|
+
declare function isCloudAgentState(state: AgentState): state is CloudAgentState;
|
|
1621
|
+
/**
|
|
1622
|
+
* Logger interface
|
|
1623
|
+
*/
|
|
1624
|
+
interface Logger {
|
|
1625
|
+
debug(message: string, ...args: unknown[]): void;
|
|
1626
|
+
info(message: string, ...args: unknown[]): void;
|
|
1627
|
+
warn(message: string, ...args: unknown[]): void;
|
|
1628
|
+
error(message: string, ...args: unknown[]): void;
|
|
1692
1629
|
}
|
|
1693
1630
|
/**
|
|
1694
|
-
*
|
|
1695
|
-
* PATCH /v2/cloudagent/agentmgmt/agents/{id}
|
|
1631
|
+
* Filter condition for listing agents
|
|
1696
1632
|
*/
|
|
1697
|
-
interface
|
|
1698
|
-
/**
|
|
1699
|
-
|
|
1633
|
+
interface ListAgentFilter {
|
|
1634
|
+
/** Filter field name (e.g., 'status', 'name') */
|
|
1635
|
+
field: string;
|
|
1636
|
+
/** Filter value (comma-separated for multiple values) */
|
|
1637
|
+
value: string;
|
|
1700
1638
|
}
|
|
1701
|
-
//#endregion
|
|
1702
|
-
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-provider.d.ts
|
|
1703
1639
|
/**
|
|
1704
|
-
*
|
|
1640
|
+
* Sort options for listing agents
|
|
1705
1641
|
*/
|
|
1706
|
-
interface
|
|
1707
|
-
/**
|
|
1708
|
-
|
|
1709
|
-
/**
|
|
1710
|
-
|
|
1711
|
-
/** Custom headers */
|
|
1712
|
-
headers?: Record<string, string>;
|
|
1713
|
-
/** Logger instance */
|
|
1714
|
-
logger?: Logger;
|
|
1715
|
-
/** Custom fetch implementation */
|
|
1716
|
-
fetch?: typeof fetch;
|
|
1717
|
-
/** Client capabilities (sent during agent initialization) */
|
|
1718
|
-
clientCapabilities?: ClientCapabilities$1;
|
|
1642
|
+
interface ListAgentSort {
|
|
1643
|
+
/** Sort field (e.g., 'createdAt', 'status') */
|
|
1644
|
+
orderBy: string;
|
|
1645
|
+
/** Sort direction */
|
|
1646
|
+
order?: 'asc' | 'desc';
|
|
1719
1647
|
}
|
|
1720
1648
|
/**
|
|
1721
|
-
*
|
|
1649
|
+
* Query options for listing agents
|
|
1722
1650
|
*
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
1725
|
-
*
|
|
1726
|
-
* - GET {endpoint}/console/cloudagent/agentmgmt/agents - List all agents
|
|
1727
|
-
* - POST {endpoint}/console/cloudagent/agentmgmt/agents/{id}/delete - Delete agent
|
|
1728
|
-
* - GET {endpoint}/console/cloudagent/agentmgmt/agents/{id}/session - Get agent session (includes sandboxId)
|
|
1729
|
-
* - GET {endpoint}/console/cloudagent/agentmgmt/models - Get available models
|
|
1730
|
-
*
|
|
1731
|
-
* The provider stores agent endpoint configurations in the cloud backend.
|
|
1732
|
-
* When connect() is called, it creates a CloudAgentConnection to the agent's
|
|
1733
|
-
* endpoint and returns an Agent instance.
|
|
1734
|
-
*
|
|
1735
|
-
* @example
|
|
1736
|
-
* ```typescript
|
|
1737
|
-
* const provider = new CloudAgentProvider({
|
|
1738
|
-
* endpoint: 'https://staging-copilot.tencent.com',
|
|
1739
|
-
* authToken: 'token'
|
|
1740
|
-
* });
|
|
1741
|
-
*
|
|
1742
|
-
* // List all agents (uses default pagination and sorting)
|
|
1743
|
-
* const allAgents = await provider.list();
|
|
1744
|
-
*
|
|
1745
|
-
* // List agents with custom pagination
|
|
1746
|
-
* const page2 = await provider.list({
|
|
1747
|
-
* page: 2,
|
|
1748
|
-
* size: 50
|
|
1749
|
-
* });
|
|
1750
|
-
*
|
|
1751
|
-
* // List agents with filtering
|
|
1752
|
-
* const runningAgents = await provider.list({
|
|
1753
|
-
* filters: [
|
|
1754
|
-
* { field: 'status', value: 'running' }
|
|
1755
|
-
* ]
|
|
1756
|
-
* });
|
|
1757
|
-
*
|
|
1758
|
-
* // List agents with custom sorting
|
|
1759
|
-
* const sortedAgents = await provider.list({
|
|
1760
|
-
* sort: {
|
|
1761
|
-
* orderBy: 'createdAt',
|
|
1762
|
-
* order: 'desc'
|
|
1763
|
-
* }
|
|
1764
|
-
* });
|
|
1765
|
-
*
|
|
1766
|
-
* // List agents created in last 14 days with multiple filters
|
|
1767
|
-
* const recentAgents = await provider.list({
|
|
1768
|
-
* dayRange: 14,
|
|
1769
|
-
* filters: [
|
|
1770
|
-
* { field: 'status', value: 'running,stopped' }
|
|
1771
|
-
* ],
|
|
1772
|
-
* page: 1,
|
|
1773
|
-
* size: 20
|
|
1774
|
-
* });
|
|
1775
|
-
*
|
|
1776
|
-
* // Get agent state
|
|
1777
|
-
* const state = await provider.get('agent-id');
|
|
1778
|
-
*
|
|
1779
|
-
* // Connect to agent
|
|
1780
|
-
* const agent = await provider.connect('agent-id');
|
|
1781
|
-
*
|
|
1782
|
-
* // Use agent
|
|
1783
|
-
* const session = await agent.sessions.create({ cwd: '/workspace' });
|
|
1784
|
-
*
|
|
1785
|
-
* // Get available models
|
|
1786
|
-
* const models = await provider.getModels('my-repo');
|
|
1787
|
-
* ```
|
|
1651
|
+
* These options are supported by both CloudAgentProvider and LocalAgentProvider.
|
|
1652
|
+
* Cloud: Server-side filtering, sorting, and pagination
|
|
1653
|
+
* Local: Client-side filtering and sorting, no pagination (returns all)
|
|
1788
1654
|
*/
|
|
1789
|
-
|
|
1790
|
-
private options;
|
|
1791
|
-
private logger?;
|
|
1792
|
-
private fetchImpl;
|
|
1793
|
-
/** Cache for filesystem instances (keyed by agentId) */
|
|
1794
|
-
private filesystemCache;
|
|
1795
|
-
/** Cache for agent connections (keyed by endpoint link) */
|
|
1796
|
-
private connectionCache;
|
|
1797
|
-
/** COS upload service instance */
|
|
1798
|
-
private cosUploadService;
|
|
1799
|
-
/** Event listeners for provider-level events */
|
|
1800
|
-
private eventListeners;
|
|
1801
|
-
constructor(options: CloudAgentProviderOptions);
|
|
1802
|
-
/**
|
|
1803
|
-
* Dispose the provider and clean up resources
|
|
1804
|
-
*/
|
|
1805
|
-
dispose(): void;
|
|
1806
|
-
/**
|
|
1807
|
-
* Get the filesystem provider (returns self)
|
|
1808
|
-
*/
|
|
1809
|
-
get filesystem(): FilesystemProvider;
|
|
1810
|
-
/**
|
|
1811
|
-
* Get filesystem resource for an agent
|
|
1812
|
-
*
|
|
1813
|
-
* Creates or returns cached filesystem instance for the agent's sandbox.
|
|
1814
|
-
* The filesystem supports both `agent:///` URIs and raw paths.
|
|
1815
|
-
*
|
|
1816
|
-
* @param agentId - Agent ID to get filesystem for
|
|
1817
|
-
* @returns FilesResource instance for the agent's sandbox (with URI support)
|
|
1818
|
-
*
|
|
1819
|
-
* @example
|
|
1820
|
-
* ```typescript
|
|
1821
|
-
* const fs = await provider.getFilesystem(agentId);
|
|
1822
|
-
*
|
|
1823
|
-
* // Use agent:/// URIs
|
|
1824
|
-
* const content = await fs.read('agent:///files/src/app.ts');
|
|
1825
|
-
* await fs.write('agent:///artifacts/output.txt', 'Hello');
|
|
1826
|
-
*
|
|
1827
|
-
* // Raw paths still work (backward compatible)
|
|
1828
|
-
* const content2 = await fs.read('/src/app.ts');
|
|
1829
|
-
* ```
|
|
1830
|
-
*/
|
|
1831
|
-
getFilesystem(agentId: string): Promise<FilesResource>;
|
|
1832
|
-
/**
|
|
1833
|
-
* Get sandbox information from backend
|
|
1834
|
-
*
|
|
1835
|
-
* Uses GET {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/session
|
|
1836
|
-
* to retrieve sandbox information. Extracts sandboxId from the session response
|
|
1837
|
-
* and constructs the apiUrl for E2B proxy.
|
|
1838
|
-
*
|
|
1839
|
-
* @param agentId - Agent ID
|
|
1840
|
-
* @returns E2B Sandbox connection information with sandboxId and apiUrl
|
|
1841
|
-
*/
|
|
1842
|
-
private getSandboxInfo;
|
|
1843
|
-
/**
|
|
1844
|
-
* Get agent state by ID
|
|
1845
|
-
*/
|
|
1846
|
-
get(agentId: string): Promise<CloudAgentState | undefined>;
|
|
1847
|
-
/**
|
|
1848
|
-
* List all agent states with pagination information
|
|
1849
|
-
*
|
|
1850
|
-
* @param options - Optional query parameters for filtering, sorting, and pagination
|
|
1851
|
-
* @returns Object containing agents array and pagination info
|
|
1852
|
-
*/
|
|
1853
|
-
list(options?: ListAgentOptions): Promise<ListAgentResult<CloudAgentState>>;
|
|
1854
|
-
/**
|
|
1855
|
-
* Create a new agent
|
|
1856
|
-
* POST {endpoint}/console/cloudagent/agentmgmt/agents
|
|
1857
|
-
*/
|
|
1858
|
-
create(): Promise<string>;
|
|
1859
|
-
/**
|
|
1860
|
-
* Connect to an agent and return the connection
|
|
1861
|
-
*
|
|
1862
|
-
* This method:
|
|
1863
|
-
* 1. Fetches the agent configuration from the backend
|
|
1864
|
-
* 2. Checks if an existing connection can be reused (based on endpoint link)
|
|
1865
|
-
* 3. Creates a CloudAgentConnection to the agent's endpoint if not cached
|
|
1866
|
-
* 4. Saves session connection info to the connection
|
|
1867
|
-
* 5. Connects and initializes the connection
|
|
1868
|
-
* 6. Returns the connected CloudAgentConnection
|
|
1869
|
-
*
|
|
1870
|
-
* Connection caching:
|
|
1871
|
-
* - Connections are cached by endpoint link to enable reuse
|
|
1872
|
-
* - CloudAgentConnection is responsible for handling connection health checks
|
|
1873
|
-
* and token expiration internally
|
|
1874
|
-
*/
|
|
1875
|
-
connect(agentId: string): Promise<CloudAgentConnection>;
|
|
1876
|
-
/**
|
|
1877
|
-
* Delete an agent by ID
|
|
1878
|
-
* POST {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/delete
|
|
1879
|
-
*/
|
|
1880
|
-
delete(agentId: string): Promise<boolean>;
|
|
1881
|
-
/**
|
|
1882
|
-
* Archive an agent by ID
|
|
1883
|
-
* POST {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/archive
|
|
1884
|
-
*
|
|
1885
|
-
* @param agentId - Agent ID to archive
|
|
1886
|
-
* @returns ArchiveAgentResponse containing the archived agent ID
|
|
1887
|
-
*
|
|
1888
|
-
* @example
|
|
1889
|
-
* ```typescript
|
|
1890
|
-
* const result = await provider.archive('agent-123');
|
|
1891
|
-
* console.log('Archived agent:', result.id);
|
|
1892
|
-
* ```
|
|
1893
|
-
*/
|
|
1894
|
-
archive(agentId: string): Promise<ArchiveAgentResponse>;
|
|
1895
|
-
/**
|
|
1896
|
-
* Rename an agent by ID
|
|
1897
|
-
* PATCH {endpoint}/v2/cloudagent/agentmgmt/agents/{agentId}
|
|
1898
|
-
*
|
|
1899
|
-
* @param agentId - Agent ID to rename
|
|
1900
|
-
* @param title - New title for the agent
|
|
1901
|
-
* @returns RenameAgentResponse containing the renamed agent ID
|
|
1902
|
-
*
|
|
1903
|
-
* @example
|
|
1904
|
-
* ```typescript
|
|
1905
|
-
* const result = await provider.rename('agent-123', 'New Title');
|
|
1906
|
-
* console.log('Renamed agent:', result.id);
|
|
1907
|
-
* ```
|
|
1908
|
-
*/
|
|
1909
|
-
rename(agentId: string, title: string): Promise<RenameAgentResponse>;
|
|
1910
|
-
/**
|
|
1911
|
-
* Get available models from product configuration
|
|
1912
|
-
*
|
|
1913
|
-
* GET {endpoint}/v3/config?repos[]={repo}
|
|
1914
|
-
*
|
|
1915
|
-
* This method fetches the product configuration from /v3/config API
|
|
1916
|
-
* and extracts the models array from the response.
|
|
1917
|
-
*
|
|
1918
|
-
* @param repo - Optional repository URL for context-specific config
|
|
1919
|
-
* @returns Array of ModelInfo with full model details
|
|
1920
|
-
*/
|
|
1921
|
-
getModels(repo?: string): Promise<ModelInfo$1[]>;
|
|
1922
|
-
/**
|
|
1923
|
-
* Generate a unique request ID
|
|
1924
|
-
*/
|
|
1925
|
-
private generateRequestId;
|
|
1926
|
-
/**
|
|
1927
|
-
* Common image MIME types for filtering
|
|
1928
|
-
*/
|
|
1929
|
-
private static readonly IMAGE_MIME_TYPES;
|
|
1655
|
+
interface ListAgentOptions {
|
|
1930
1656
|
/**
|
|
1931
|
-
*
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
1934
|
-
* @returns Response with selected file paths (filenames in browser)
|
|
1657
|
+
* Page number (starts from 1)
|
|
1658
|
+
* Cloud: Used for API pagination
|
|
1659
|
+
* Local: Ignored (returns all sessions)
|
|
1935
1660
|
*/
|
|
1936
|
-
|
|
1661
|
+
page?: number;
|
|
1937
1662
|
/**
|
|
1938
|
-
*
|
|
1663
|
+
* Page size
|
|
1664
|
+
* Cloud: Number of items per page (default 20, max 100)
|
|
1665
|
+
* Local: Ignored (returns all sessions)
|
|
1939
1666
|
*/
|
|
1940
|
-
|
|
1667
|
+
size?: number;
|
|
1941
1668
|
/**
|
|
1942
|
-
*
|
|
1943
|
-
*
|
|
1944
|
-
*
|
|
1945
|
-
* @returns Response with corresponding cloud URLs
|
|
1669
|
+
* Sort options
|
|
1670
|
+
* Cloud: Sorts results by specified field and order
|
|
1671
|
+
* Local: Sorts results by specified field and order
|
|
1946
1672
|
*/
|
|
1947
|
-
|
|
1673
|
+
sort?: ListAgentSort;
|
|
1948
1674
|
/**
|
|
1949
|
-
*
|
|
1950
|
-
*
|
|
1951
|
-
*
|
|
1675
|
+
* Filter conditions
|
|
1676
|
+
* Cloud: Filters results by specified field values
|
|
1677
|
+
* Local: Filters results by specified field values
|
|
1952
1678
|
*/
|
|
1953
|
-
|
|
1679
|
+
filters?: ListAgentFilter[];
|
|
1954
1680
|
/**
|
|
1955
|
-
*
|
|
1956
|
-
*
|
|
1957
|
-
*
|
|
1681
|
+
* Day range filter (e.g., agents created in last N days)
|
|
1682
|
+
* Cloud: Filters by creation date
|
|
1683
|
+
* Local: Filters by creation date
|
|
1958
1684
|
*/
|
|
1959
|
-
|
|
1685
|
+
dayRange?: number;
|
|
1960
1686
|
/**
|
|
1961
|
-
*
|
|
1962
|
-
*
|
|
1963
|
-
*
|
|
1687
|
+
* Title search keyword (matches agent title)
|
|
1688
|
+
* Cloud: Server-side search
|
|
1689
|
+
* Local: Client-side search
|
|
1964
1690
|
*/
|
|
1965
|
-
|
|
1966
|
-
private toAgentState;
|
|
1967
|
-
private request;
|
|
1691
|
+
title?: string;
|
|
1968
1692
|
}
|
|
1969
|
-
//#endregion
|
|
1970
|
-
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
|
|
1971
1693
|
/**
|
|
1972
|
-
*
|
|
1973
|
-
*
|
|
1974
|
-
* Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource interface.
|
|
1975
|
-
*
|
|
1976
|
-
* @example
|
|
1977
|
-
* ```typescript
|
|
1978
|
-
* const fs = await E2BFilesystem.connect({
|
|
1979
|
-
* sandboxId: 'sandbox-123',
|
|
1980
|
-
* apiKey: 'e2b_xxx'
|
|
1981
|
-
* });
|
|
1982
|
-
*
|
|
1983
|
-
* // Read/write files
|
|
1984
|
-
* await fs.write('/test.txt', 'Hello World');
|
|
1985
|
-
* const content = await fs.read('/test.txt');
|
|
1986
|
-
*
|
|
1987
|
-
* // Watch for changes
|
|
1988
|
-
* const handle = await fs.watchDir('/workspace', (event) => {
|
|
1989
|
-
* console.log('File changed:', event);
|
|
1990
|
-
* });
|
|
1991
|
-
* ```
|
|
1694
|
+
* Pagination metadata returned from list operations
|
|
1992
1695
|
*/
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
/**
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
/**
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
}): Promise<string>;
|
|
2007
|
-
read(path: string, opts: FilesystemRequestOpts & {
|
|
2008
|
-
format: 'bytes';
|
|
2009
|
-
}): Promise<Uint8Array>;
|
|
2010
|
-
read(path: string, opts: FilesystemRequestOpts & {
|
|
2011
|
-
format: 'blob';
|
|
2012
|
-
}): Promise<Blob>;
|
|
2013
|
-
read(path: string, opts: FilesystemRequestOpts & {
|
|
2014
|
-
format: 'stream';
|
|
2015
|
-
}): Promise<ReadableStream<Uint8Array>>;
|
|
2016
|
-
write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<WriteInfo>;
|
|
2017
|
-
write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
|
|
2018
|
-
list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
|
|
2019
|
-
exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
|
|
2020
|
-
makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
|
|
2021
|
-
remove(path: string, opts?: FilesystemRequestOpts): Promise<void>;
|
|
2022
|
-
rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
|
|
2023
|
-
getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
|
|
2024
|
-
watchDir(path: string, onEvent: (event: FilesystemEvent$1) => void | Promise<void>, opts?: WatchOpts & {
|
|
2025
|
-
onExit?: (err?: Error) => void | Promise<void>;
|
|
2026
|
-
}): Promise<WatchHandle>;
|
|
1696
|
+
interface PaginationInfo {
|
|
1697
|
+
/** Current page number (starts from 1) */
|
|
1698
|
+
page: number;
|
|
1699
|
+
/** Page size */
|
|
1700
|
+
size: number;
|
|
1701
|
+
/** Total number of items */
|
|
1702
|
+
total: number;
|
|
1703
|
+
/** Total number of pages */
|
|
1704
|
+
totalPages: number;
|
|
1705
|
+
/** Whether there is a next page */
|
|
1706
|
+
hasNext: boolean;
|
|
1707
|
+
/** Whether there is a previous page */
|
|
1708
|
+
hasPrev: boolean;
|
|
2027
1709
|
}
|
|
2028
|
-
//#endregion
|
|
2029
|
-
//#region ../agent-provider/lib/common/client/client.d.ts
|
|
2030
1710
|
/**
|
|
2031
|
-
*
|
|
2032
|
-
*
|
|
2033
|
-
* Provides a session-centric API that internally manages agents.
|
|
2034
|
-
* Users interact with sessions; the agent lifecycle is handled internally.
|
|
2035
|
-
*
|
|
2036
|
-
* @example
|
|
2037
|
-
* ```typescript
|
|
2038
|
-
* // Create client with a provider
|
|
2039
|
-
* const provider = new CloudAgentProvider({
|
|
2040
|
-
* endpoint: 'https://api.example.com',
|
|
2041
|
-
* authToken: 'token'
|
|
2042
|
-
* });
|
|
2043
|
-
*
|
|
2044
|
-
* const client = new AgentClient({
|
|
2045
|
-
* provider,
|
|
2046
|
-
* logger: console
|
|
2047
|
-
* });
|
|
2048
|
-
*
|
|
2049
|
-
* // List all sessions
|
|
2050
|
-
* const sessions = await client.sessions.list();
|
|
2051
|
-
*
|
|
2052
|
-
* // Create new session (auto-creates agent and connects)
|
|
2053
|
-
* const session = await client.sessions.create({ cwd: '/workspace' });
|
|
2054
|
-
* console.log(session.agentState.status); // agent status
|
|
2055
|
-
* console.log(session.agentState.id); // agent ID
|
|
2056
|
-
*
|
|
2057
|
-
* // Send prompt
|
|
2058
|
-
* await session.prompts.send({ content: 'Hello' });
|
|
2059
|
-
*
|
|
2060
|
-
* // Get available models
|
|
2061
|
-
* const models = await client.sessions.models.list('my-repo');
|
|
2062
|
-
*
|
|
2063
|
-
* // Use 'using' keyword for automatic cleanup
|
|
2064
|
-
* {
|
|
2065
|
-
* using session = await client.sessions.create({ cwd: '/workspace' });
|
|
2066
|
-
* // ... use session
|
|
2067
|
-
* } // session automatically disposed
|
|
2068
|
-
*
|
|
2069
|
-
* // Or manually disconnect
|
|
2070
|
-
* session.disconnect();
|
|
2071
|
-
*
|
|
2072
|
-
* // Load existing session
|
|
2073
|
-
* const loadedSession = await client.sessions.load({
|
|
2074
|
-
* sessionId: 'xxx',
|
|
2075
|
-
* cwd: '/workspace'
|
|
2076
|
-
* });
|
|
2077
|
-
* ```
|
|
1711
|
+
* Response from list operations that includes pagination
|
|
2078
1712
|
*/
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
* Sessions resource namespace (primary API entry point)
|
|
2085
|
-
*/
|
|
2086
|
-
readonly sessions: ClientSessionsResource;
|
|
2087
|
-
/**
|
|
2088
|
-
* 运行环境类型
|
|
2089
|
-
* - 'local': IDE 本地环境
|
|
2090
|
-
* - 'cloud': 云端环境
|
|
2091
|
-
*/
|
|
2092
|
-
readonly environmentType: 'local' | 'cloud';
|
|
2093
|
-
constructor(options: AgentClientOptions);
|
|
2094
|
-
private createSessionsResource;
|
|
2095
|
-
private createModelsResource;
|
|
2096
|
-
/**
|
|
2097
|
-
* Dispose the client
|
|
2098
|
-
*
|
|
2099
|
-
* Note: Active sessions are not automatically disposed.
|
|
2100
|
-
* The caller is responsible for disconnecting sessions they created.
|
|
2101
|
-
*/
|
|
2102
|
-
dispose(): void;
|
|
1713
|
+
interface ListAgentResult<T = AgentState> {
|
|
1714
|
+
/** List of agent states or session info */
|
|
1715
|
+
agents: T[];
|
|
1716
|
+
/** Pagination information */
|
|
1717
|
+
pagination: PaginationInfo;
|
|
2103
1718
|
}
|
|
2104
|
-
//#endregion
|
|
2105
|
-
//#region ../agent-provider/lib/common/client/session.d.ts
|
|
2106
1719
|
/**
|
|
2107
|
-
*
|
|
2108
|
-
* Returns a FilesResource instance for file operations
|
|
1720
|
+
* Session information (returned by list, mapped from Agent)
|
|
2109
1721
|
*/
|
|
2110
|
-
|
|
1722
|
+
interface SessionInfo {
|
|
1723
|
+
/** Session ID (from agent.session) */
|
|
1724
|
+
id: string;
|
|
1725
|
+
/** Associated agent ID */
|
|
1726
|
+
agentId: string;
|
|
1727
|
+
/** Agent name */
|
|
1728
|
+
name?: string;
|
|
1729
|
+
/** Agent status */
|
|
1730
|
+
status: AgentStatus;
|
|
1731
|
+
/** When the session/agent was created */
|
|
1732
|
+
createdAt?: Date;
|
|
1733
|
+
/** Last activity timestamp */
|
|
1734
|
+
lastActivityAt?: Date;
|
|
1735
|
+
/** Working directory (for local agents) */
|
|
1736
|
+
cwd?: string;
|
|
1737
|
+
/** Whether the session is a playground */
|
|
1738
|
+
isPlayground?: boolean;
|
|
1739
|
+
}
|
|
2111
1740
|
/**
|
|
2112
|
-
*
|
|
1741
|
+
* Parameters for creating a new session
|
|
2113
1742
|
*/
|
|
2114
|
-
interface
|
|
2115
|
-
/**
|
|
2116
|
-
|
|
2117
|
-
/**
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
connectionInfo?: SessionConnectionInfo;
|
|
1743
|
+
interface CreateSessionParams$1 {
|
|
1744
|
+
/** Working directory */
|
|
1745
|
+
cwd: string;
|
|
1746
|
+
/** MCP server configurations */
|
|
1747
|
+
mcpServers?: McpServerConfig[];
|
|
1748
|
+
_meta?: Record<string, unknown>;
|
|
2121
1749
|
}
|
|
2122
1750
|
/**
|
|
2123
|
-
*
|
|
2124
|
-
*
|
|
2125
|
-
* This class wraps an AgentConnection and provides the session-centric API.
|
|
2126
|
-
* It is created by SessionManager when creating or loading sessions.
|
|
2127
|
-
*
|
|
2128
|
-
* @example
|
|
2129
|
-
* ```typescript
|
|
2130
|
-
* // Created by client.sessions.new() or client.sessions.load()
|
|
2131
|
-
* const session = await client.sessions.new({ cwd: '/workspace' });
|
|
2132
|
-
*
|
|
2133
|
-
* // Access agent state
|
|
2134
|
-
* console.log(session.agentState.status);
|
|
2135
|
-
*
|
|
2136
|
-
* // Send prompt
|
|
2137
|
-
* const response = await session.prompts.send({ content: 'Hello!' });
|
|
2138
|
-
*
|
|
2139
|
-
* // Cleanup
|
|
2140
|
-
* session.disconnect();
|
|
2141
|
-
* ```
|
|
1751
|
+
* Parameters for loading an existing session
|
|
2142
1752
|
*/
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
private connection;
|
|
2151
|
-
private _getFilesystem?;
|
|
2152
|
-
private _connectionInfo?;
|
|
2153
|
-
private listeners;
|
|
2154
|
-
private onceListeners;
|
|
2155
|
-
/**
|
|
2156
|
-
* Agent operations namespace
|
|
2157
|
-
*/
|
|
2158
|
-
readonly agent: SessionAgentOperations;
|
|
2159
|
-
/**
|
|
2160
|
-
* Prompts resource namespace
|
|
2161
|
-
*/
|
|
2162
|
-
readonly prompts: PromptsResource;
|
|
2163
|
-
/**
|
|
2164
|
-
* Artifacts resource namespace
|
|
2165
|
-
*/
|
|
2166
|
-
readonly artifacts: ArtifactsResource;
|
|
2167
|
-
/**
|
|
2168
|
-
* Files resource namespace (lazily loaded via getter)
|
|
2169
|
-
*/
|
|
2170
|
-
readonly files: FilesResource;
|
|
2171
|
-
/**
|
|
2172
|
-
* Create an ActiveSessionImpl instance
|
|
2173
|
-
*
|
|
2174
|
-
* @param sessionId - Session ID
|
|
2175
|
-
* @param agentId - Agent ID
|
|
2176
|
-
* @param connection - Already connected AgentConnection
|
|
2177
|
-
* @param options - Additional options
|
|
2178
|
-
*/
|
|
2179
|
-
constructor(sessionId: string, agentId: string, connection: AgentConnection, options?: ActiveSessionImplOptions);
|
|
2180
|
-
/**
|
|
2181
|
-
* Session ID
|
|
2182
|
-
*/
|
|
2183
|
-
get id(): string;
|
|
2184
|
-
/**
|
|
2185
|
-
* Agent ID
|
|
2186
|
-
*/
|
|
2187
|
-
get agentId(): string;
|
|
2188
|
-
/**
|
|
2189
|
-
* Agent state (live connection state)
|
|
2190
|
-
* Returns LocalAgentState or CloudAgentState based on transport type
|
|
2191
|
-
*/
|
|
2192
|
-
get agentState(): AgentState;
|
|
2193
|
-
/**
|
|
2194
|
-
* Get agent capabilities (available after connection)
|
|
2195
|
-
*/
|
|
2196
|
-
get capabilities(): AgentCapabilities | undefined;
|
|
2197
|
-
/**
|
|
2198
|
-
* Available session modes
|
|
2199
|
-
*/
|
|
2200
|
-
get availableModes(): SessionMode[] | undefined;
|
|
2201
|
-
/**
|
|
2202
|
-
* Current session mode
|
|
2203
|
-
*/
|
|
2204
|
-
get currentMode(): string | undefined;
|
|
2205
|
-
/**
|
|
2206
|
-
* Available slash commands
|
|
2207
|
-
*
|
|
2208
|
-
* When Agent sends available_commands_update, this list is automatically updated.
|
|
2209
|
-
* Commands can be accessed directly without waiting for events.
|
|
2210
|
-
*/
|
|
2211
|
-
get availableCommands(): AvailableCommand[];
|
|
2212
|
-
/**
|
|
2213
|
-
* Check if the session is active
|
|
2214
|
-
*/
|
|
2215
|
-
get isActive(): boolean;
|
|
2216
|
-
/**
|
|
2217
|
-
* Session connection information (only available for cloud sessions)
|
|
2218
|
-
* 会话连接信息,包括sandboxId、link、token等
|
|
2219
|
-
*/
|
|
2220
|
-
get connectionInfo(): SessionConnectionInfo | undefined;
|
|
2221
|
-
/**
|
|
2222
|
-
* Set session modes (called after create/load)
|
|
2223
|
-
*/
|
|
2224
|
-
setModes(availableModes?: SessionMode[], currentMode?: string): void;
|
|
2225
|
-
private createAgentOperations;
|
|
2226
|
-
private createPromptsResource;
|
|
2227
|
-
private createArtifactsResource;
|
|
2228
|
-
/**
|
|
2229
|
-
* Create files resource with lazy-loaded filesystem
|
|
2230
|
-
*
|
|
2231
|
-
* The filesystem is lazily loaded on first use to avoid unnecessary
|
|
2232
|
-
* connections to the sandbox. The actual filesystem instance is obtained
|
|
2233
|
-
* via the getter function provided by SessionManager.
|
|
2234
|
-
*/
|
|
2235
|
-
private createFilesResource;
|
|
2236
|
-
/**
|
|
2237
|
-
* Resolve a permission request
|
|
2238
|
-
*/
|
|
2239
|
-
resolvePermission(requestId: string, optionId: string): boolean;
|
|
2240
|
-
/**
|
|
2241
|
-
* Reject a permission request
|
|
2242
|
-
*/
|
|
2243
|
-
rejectPermission(requestId: string, reason?: string): boolean;
|
|
2244
|
-
/**
|
|
2245
|
-
* Answer a question request with user's selections
|
|
2246
|
-
*/
|
|
2247
|
-
answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
|
|
2248
|
-
/**
|
|
2249
|
-
* Cancel a question request
|
|
2250
|
-
*/
|
|
2251
|
-
cancelQuestion(toolCallId: string, reason?: string): boolean;
|
|
2252
|
-
/**
|
|
2253
|
-
* Callback for tool operations (skip or cancel)
|
|
2254
|
-
* @param toolCallId Tool call ID
|
|
2255
|
-
* @param toolName Tool name
|
|
2256
|
-
* @param action Action to perform ('skip' or 'cancel')
|
|
2257
|
-
*/
|
|
2258
|
-
toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
|
|
2259
|
-
success: boolean;
|
|
2260
|
-
error?: string;
|
|
2261
|
-
}>;
|
|
2262
|
-
/**
|
|
2263
|
-
* Set the current session mode
|
|
2264
|
-
*
|
|
2265
|
-
* @param modeId - The mode ID to switch to (must be in availableModes)
|
|
2266
|
-
* @throws Error if modeId is not in availableModes or connection fails
|
|
2267
|
-
*
|
|
2268
|
-
* @example
|
|
2269
|
-
* ```typescript
|
|
2270
|
-
* // Switch to 'code' mode
|
|
2271
|
-
* await session.setMode('code');
|
|
2272
|
-
*
|
|
2273
|
-
* // Switch to 'architect' mode
|
|
2274
|
-
* await session.setMode('architect');
|
|
2275
|
-
* ```
|
|
2276
|
-
*/
|
|
2277
|
-
setMode(modeId: string): Promise<void>;
|
|
2278
|
-
/**
|
|
2279
|
-
* Set the current session model
|
|
2280
|
-
*
|
|
2281
|
-
* @param modelId - The model ID to switch to
|
|
2282
|
-
* @example
|
|
2283
|
-
* ```typescript
|
|
2284
|
-
* // Switch to Claude Sonnet 4
|
|
2285
|
-
* await session.setSessionModel('claude-sonnet-4-20250514');
|
|
2286
|
-
*
|
|
2287
|
-
* // Switch to GPT-4o
|
|
2288
|
-
* await session.setSessionModel('gpt-4o');
|
|
2289
|
-
* ```
|
|
2290
|
-
*/
|
|
2291
|
-
setSessionModel(modelId: string): Promise<void>;
|
|
2292
|
-
/**
|
|
2293
|
-
* Subscribe to session events
|
|
2294
|
-
*/
|
|
2295
|
-
on<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
2296
|
-
/**
|
|
2297
|
-
* Unsubscribe from session events
|
|
2298
|
-
*/
|
|
2299
|
-
off<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
2300
|
-
/**
|
|
2301
|
-
* Subscribe to a session event once
|
|
2302
|
-
*/
|
|
2303
|
-
once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
2304
|
-
/**
|
|
2305
|
-
* Emit an event to all registered listeners
|
|
2306
|
-
*/
|
|
2307
|
-
private emit;
|
|
2308
|
-
/**
|
|
2309
|
-
* Remove all listeners for an event
|
|
2310
|
-
*/
|
|
2311
|
-
private removeAllListeners;
|
|
2312
|
-
/**
|
|
2313
|
-
* Disconnect from the session/agent
|
|
2314
|
-
*/
|
|
2315
|
-
disconnect(): void;
|
|
2316
|
-
/**
|
|
2317
|
-
* Symbol.dispose for 'using' keyword support
|
|
2318
|
-
* Automatically disconnects and cleans up when session goes out of scope
|
|
2319
|
-
*
|
|
2320
|
-
* @example
|
|
2321
|
-
* ```typescript
|
|
2322
|
-
* {
|
|
2323
|
-
* using session = await client.sessions.new({ cwd: '/workspace' });
|
|
2324
|
-
* // ... use session
|
|
2325
|
-
* } // session automatically disposed
|
|
2326
|
-
* ```
|
|
2327
|
-
*/
|
|
2328
|
-
[Symbol.dispose](): void;
|
|
2329
|
-
private getConnectionOrThrow;
|
|
2330
|
-
private setupConnectionEvents;
|
|
2331
|
-
private mapPromptResponse;
|
|
1753
|
+
interface LoadSessionParams$1 {
|
|
1754
|
+
/** Session ID to load (required) */
|
|
1755
|
+
sessionId: string;
|
|
1756
|
+
/** Working directory */
|
|
1757
|
+
cwd: string;
|
|
1758
|
+
/** MCP server configurations */
|
|
1759
|
+
mcpServers?: McpServerConfig[];
|
|
2332
1760
|
}
|
|
2333
|
-
//#endregion
|
|
2334
|
-
//#region ../agent-provider/lib/common/client/session-manager.d.ts
|
|
2335
1761
|
/**
|
|
2336
|
-
*
|
|
1762
|
+
* Parameters for initializing a workspace
|
|
2337
1763
|
*/
|
|
2338
|
-
interface
|
|
2339
|
-
/**
|
|
2340
|
-
|
|
2341
|
-
/**
|
|
2342
|
-
|
|
1764
|
+
interface InitializeWorkspaceParams {
|
|
1765
|
+
/** Working directory */
|
|
1766
|
+
cwd: string;
|
|
1767
|
+
/** MCP server configurations */
|
|
1768
|
+
mcpServers?: McpServerConfig[];
|
|
1769
|
+
/** Whether to activate the workspace window to foreground (default true) */
|
|
1770
|
+
needActivated?: boolean;
|
|
2343
1771
|
}
|
|
2344
1772
|
/**
|
|
2345
|
-
*
|
|
2346
|
-
*
|
|
2347
|
-
* This class manages the relationship between sessions and agents.
|
|
2348
|
-
* Since the backend is agent-centric, SessionManager handles the mapping:
|
|
2349
|
-
* - Sessions are views over agents
|
|
2350
|
-
* - sessionId may equal agentId in simple cases
|
|
2351
|
-
*
|
|
2352
|
-
* Features:
|
|
2353
|
-
* - Session caching: reuses existing ActiveSession instances
|
|
2354
|
-
* - Automatic cleanup on session disconnect
|
|
2355
|
-
*
|
|
2356
|
-
* @example
|
|
2357
|
-
* ```typescript
|
|
2358
|
-
* const manager = new SessionManager({ provider, logger });
|
|
2359
|
-
*
|
|
2360
|
-
* // List sessions
|
|
2361
|
-
* const sessions = await manager.listSessions();
|
|
2362
|
-
*
|
|
2363
|
-
* // Create new session
|
|
2364
|
-
* const session = await manager.createSession({ cwd: '/workspace' });
|
|
2365
|
-
*
|
|
2366
|
-
* // Load existing session (returns cached instance if available)
|
|
2367
|
-
* const loaded = await manager.loadSession({ sessionId: 'xxx', cwd: '/workspace' });
|
|
2368
|
-
* ```
|
|
1773
|
+
* Response for workspace initialization
|
|
2369
1774
|
*/
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
* List all sessions with pagination info (mapped from agents)
|
|
2376
|
-
*
|
|
2377
|
-
* Each agent maps to a session. The sessionId is derived from the agent.
|
|
2378
|
-
* Cloud: Returns server-side filtered/sorted/paginated results
|
|
2379
|
-
* Local: Returns client-side filtered/sorted results (synthetic pagination)
|
|
2380
|
-
*
|
|
2381
|
-
* @param options - Optional query parameters for filtering, sorting, and pagination
|
|
2382
|
-
*/
|
|
2383
|
-
listSessions(options?: ListAgentOptions): Promise<ListAgentResult<SessionInfo>>;
|
|
2384
|
-
/**
|
|
2385
|
-
* Create a new session
|
|
2386
|
-
*
|
|
2387
|
-
* Steps:
|
|
2388
|
-
* 1. Create new agent (if provider supports it) or use existing
|
|
2389
|
-
* 2. Connect to agent
|
|
2390
|
-
* 3. Call ACP newSession
|
|
2391
|
-
* 4. Register session mapping (for LocalAgentProvider)
|
|
2392
|
-
* 5. Return ActiveSession instance
|
|
2393
|
-
*/
|
|
2394
|
-
createSession(params: CreateSessionParams$1): Promise<ActiveSession>;
|
|
2395
|
-
/**
|
|
2396
|
-
* Load an existing session
|
|
2397
|
-
*
|
|
2398
|
-
* Steps:
|
|
2399
|
-
* 1. Check cache for existing session
|
|
2400
|
-
* 2. Find agent by sessionId (sessionId === agentId in current design)
|
|
2401
|
-
* 3. Connect to agent
|
|
2402
|
-
* 4. Call ACP loadSession
|
|
2403
|
-
* 5. Return ActiveSession instance (cached)
|
|
2404
|
-
*/
|
|
2405
|
-
loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
|
|
1775
|
+
interface InitializeWorkspaceResponse {
|
|
1776
|
+
/** Whether initialization was successful */
|
|
1777
|
+
success: boolean;
|
|
1778
|
+
/** Error message (if failed) */
|
|
1779
|
+
error?: string;
|
|
2406
1780
|
}
|
|
2407
|
-
//#endregion
|
|
2408
|
-
//#region ../agent-provider/lib/backend/agent-api.d.ts
|
|
2409
1781
|
/**
|
|
2410
|
-
*
|
|
2411
|
-
*
|
|
2412
|
-
* 定义与 /v2/cloudagent/agentmgmt/agents API 相关的数据结构
|
|
1782
|
+
* Prompts resource interface (ACP verbs)
|
|
1783
|
+
* Operations use the current session automatically
|
|
2413
1784
|
*/
|
|
1785
|
+
interface PromptsResource {
|
|
1786
|
+
/** Send a prompt and wait for completion */
|
|
1787
|
+
send(params: PromptParams): Promise<PromptResponse>;
|
|
1788
|
+
/** Stream a prompt (yields session updates) */
|
|
1789
|
+
stream(params: PromptParams): AsyncIterable<SessionNotification$1>;
|
|
1790
|
+
/** Cancel an ongoing prompt */
|
|
1791
|
+
cancel(): Promise<void>;
|
|
1792
|
+
}
|
|
2414
1793
|
/**
|
|
2415
|
-
*
|
|
1794
|
+
* Artifacts resource interface
|
|
2416
1795
|
*/
|
|
2417
|
-
interface
|
|
2418
|
-
/**
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
1796
|
+
interface ArtifactsResource {
|
|
1797
|
+
/** List all artifacts */
|
|
1798
|
+
list(params?: {
|
|
1799
|
+
type?: ArtifactType;
|
|
1800
|
+
}): Promise<Artifact[]>;
|
|
1801
|
+
/** Get a single artifact */
|
|
1802
|
+
retrieve(artifactId: string): Promise<Artifact>;
|
|
1803
|
+
/** Get artifact content */
|
|
1804
|
+
content(artifactId: string): Promise<string>;
|
|
2422
1805
|
}
|
|
2423
1806
|
/**
|
|
2424
|
-
*
|
|
1807
|
+
* Models resource interface
|
|
2425
1808
|
*/
|
|
2426
|
-
interface
|
|
2427
|
-
/**
|
|
2428
|
-
|
|
2429
|
-
/** 排序字段 */
|
|
2430
|
-
orderBy: string;
|
|
1809
|
+
interface ModelsResource {
|
|
1810
|
+
/** Get available models for a repository */
|
|
1811
|
+
list(repo?: string): Promise<ModelInfo$1[]>;
|
|
2431
1812
|
}
|
|
2432
1813
|
/**
|
|
2433
|
-
*
|
|
1814
|
+
* Prompt response
|
|
2434
1815
|
*/
|
|
2435
|
-
interface
|
|
2436
|
-
/**
|
|
2437
|
-
|
|
2438
|
-
/**
|
|
2439
|
-
|
|
2440
|
-
/** 页码 */
|
|
2441
|
-
page?: number;
|
|
2442
|
-
/** 每页大小 */
|
|
2443
|
-
size?: number;
|
|
2444
|
-
/** 排序条件 */
|
|
2445
|
-
sort?: SortCondition;
|
|
2446
|
-
}
|
|
2447
|
-
/**
|
|
2448
|
-
* Agent 来源信息
|
|
2449
|
-
*/
|
|
2450
|
-
interface CloudAgentSource {
|
|
2451
|
-
/** 提供商: github, gitlab 等 */
|
|
2452
|
-
provider: string;
|
|
2453
|
-
/** 分支/引用 */
|
|
2454
|
-
ref: string;
|
|
2455
|
-
/** 仓库路径 */
|
|
2456
|
-
repository: string;
|
|
1816
|
+
interface PromptResponse {
|
|
1817
|
+
/** Stop reason */
|
|
1818
|
+
stopReason: 'end_turn' | 'max_tokens' | 'tool_use' | 'cancelled' | 'error';
|
|
1819
|
+
/** Response metadata */
|
|
1820
|
+
_meta?: Record<string, unknown>;
|
|
2457
1821
|
}
|
|
2458
1822
|
/**
|
|
2459
|
-
*
|
|
1823
|
+
* Sessions resource events for monitoring session list changes
|
|
2460
1824
|
*/
|
|
2461
|
-
interface
|
|
2462
|
-
/**
|
|
2463
|
-
|
|
2464
|
-
/**
|
|
2465
|
-
|
|
2466
|
-
/**
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
1825
|
+
interface SessionsResourceEvents {
|
|
1826
|
+
/** Emitted when the sessions list changes (create, delete, update) */
|
|
1827
|
+
sessionsChanged: SessionInfo[];
|
|
1828
|
+
/** Emitted when a new session is created */
|
|
1829
|
+
sessionCreated: SessionInfo;
|
|
1830
|
+
/** Emitted when a session is deleted */
|
|
1831
|
+
sessionDeleted: {
|
|
1832
|
+
sessionId: string;
|
|
1833
|
+
};
|
|
1834
|
+
/** Emitted when a session is updated (status change, etc.) */
|
|
1835
|
+
sessionUpdated: SessionInfo;
|
|
2470
1836
|
}
|
|
2471
1837
|
/**
|
|
2472
|
-
*
|
|
2473
|
-
*/
|
|
2474
|
-
type CloudAgentStatus = 'CREATING' | 'RUNNING' | 'STOPPED' | 'FAILED' | 'DELETING';
|
|
2475
|
-
/**
|
|
2476
|
-
* Agent 可见性
|
|
2477
|
-
*/
|
|
2478
|
-
type CloudAgentVisibility$1 = 'PRIVATE' | 'PUBLIC' | 'TEAM';
|
|
2479
|
-
/**
|
|
2480
|
-
* Cloud Agent 信息
|
|
2481
|
-
* 重命名为 CloudAgent 以避免与 ACP SDK 的 Agent 类型冲突
|
|
1838
|
+
* Event handler type for sessions resource events
|
|
2482
1839
|
*/
|
|
2483
|
-
|
|
2484
|
-
/** 创建时间 (ISO 8601) */
|
|
2485
|
-
createdAt: string;
|
|
2486
|
-
/** Agent ID */
|
|
2487
|
-
id: string;
|
|
2488
|
-
/** Agent 名称 */
|
|
2489
|
-
name: string;
|
|
2490
|
-
/** 来源信息 */
|
|
2491
|
-
source: CloudAgentSource;
|
|
2492
|
-
/** 状态 */
|
|
2493
|
-
status: CloudAgentStatus;
|
|
2494
|
-
/** 摘要 */
|
|
2495
|
-
summary?: string;
|
|
2496
|
-
/** 目标信息 */
|
|
2497
|
-
target: CloudAgentTarget$1;
|
|
2498
|
-
/** 可见性 */
|
|
2499
|
-
visibility: CloudAgentVisibility$1;
|
|
2500
|
-
}
|
|
2501
|
-
/**
|
|
2502
|
-
* 分页信息
|
|
2503
|
-
*/
|
|
2504
|
-
interface Pagination {
|
|
2505
|
-
/** 是否有下一页 */
|
|
2506
|
-
hasNext: boolean;
|
|
2507
|
-
/** 是否有上一页 */
|
|
2508
|
-
hasPrev: boolean;
|
|
2509
|
-
/** 当前页码 */
|
|
2510
|
-
page: number;
|
|
2511
|
-
/** 每页大小 */
|
|
2512
|
-
size: number;
|
|
2513
|
-
/** 总数 */
|
|
2514
|
-
total: number;
|
|
2515
|
-
/** 总页数 */
|
|
2516
|
-
totalPages: number;
|
|
2517
|
-
}
|
|
1840
|
+
type SessionsResourceEventHandler<K extends keyof SessionsResourceEvents> = (data: SessionsResourceEvents[K]) => void | Promise<void>;
|
|
2518
1841
|
/**
|
|
2519
|
-
*
|
|
1842
|
+
* Session events for event subscription
|
|
2520
1843
|
*/
|
|
2521
|
-
interface
|
|
2522
|
-
/**
|
|
2523
|
-
|
|
2524
|
-
/**
|
|
2525
|
-
|
|
1844
|
+
interface SessionEvents {
|
|
1845
|
+
/** Emitted when session updates occur */
|
|
1846
|
+
sessionUpdate: SessionNotification$1;
|
|
1847
|
+
/** Emitted when an artifact is created */
|
|
1848
|
+
artifactCreated: Artifact;
|
|
1849
|
+
/** Emitted when an artifact is updated */
|
|
1850
|
+
artifactUpdated: Artifact;
|
|
1851
|
+
/** Emitted when an artifact is deleted */
|
|
1852
|
+
artifactDeleted: Artifact;
|
|
1853
|
+
/** Emitted when a permission request is received */
|
|
1854
|
+
permissionRequest: {
|
|
1855
|
+
requestId: string;
|
|
1856
|
+
params: RequestPermissionRequest$1;
|
|
1857
|
+
};
|
|
1858
|
+
/** Emitted when a question request is received (ask_followup_question) */
|
|
1859
|
+
questionRequest: {
|
|
1860
|
+
toolCallId: string;
|
|
1861
|
+
request: QuestionRequest;
|
|
1862
|
+
};
|
|
1863
|
+
/** Emitted when usage data is updated */
|
|
1864
|
+
usageUpdate: UsageUpdate;
|
|
1865
|
+
/** Emitted when a checkpoint is created */
|
|
1866
|
+
checkpointCreated: CheckpointInfo;
|
|
1867
|
+
/** Emitted when a checkpoint is updated */
|
|
1868
|
+
checkpointUpdated: CheckpointInfo;
|
|
1869
|
+
/** Emitted when a command is received */
|
|
1870
|
+
command: {
|
|
1871
|
+
action: string;
|
|
1872
|
+
params?: Record<string, unknown>;
|
|
1873
|
+
};
|
|
1874
|
+
/** Emitted when connected to agent */
|
|
1875
|
+
connected: void;
|
|
1876
|
+
/** Emitted when disconnected from agent */
|
|
1877
|
+
disconnected: void;
|
|
1878
|
+
/** Emitted when an error occurs */
|
|
1879
|
+
error: Error;
|
|
2526
1880
|
}
|
|
2527
|
-
//#endregion
|
|
2528
|
-
//#region ../agent-provider/lib/backend/types.d.ts
|
|
2529
1881
|
/**
|
|
2530
|
-
*
|
|
2531
|
-
*/
|
|
2532
|
-
type Edition = 'pro' | 'personal' | 'ultimate' | 'exclusive';
|
|
2533
|
-
/**
|
|
2534
|
-
* 版本展示类型(用于 UI 展示)
|
|
2535
|
-
* - free: 免费版(个人版未订阅 Pro)
|
|
2536
|
-
* - pro: Pro 版(个人版已订阅 Pro)
|
|
2537
|
-
* - ultimate: 旗舰版(团队版)
|
|
2538
|
-
* - exclusive: 专享版(企业版)
|
|
1882
|
+
* Event handler type for session events
|
|
2539
1883
|
*/
|
|
2540
|
-
type
|
|
1884
|
+
type SessionEventHandler<K extends keyof SessionEvents> = (data: SessionEvents[K]) => void | Promise<void>;
|
|
2541
1885
|
/**
|
|
2542
|
-
*
|
|
1886
|
+
* Agent operations (accessed via session.agent)
|
|
2543
1887
|
*/
|
|
2544
|
-
interface
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
1888
|
+
interface SessionAgentOperations {
|
|
1889
|
+
/** Agent ID */
|
|
1890
|
+
readonly id: string;
|
|
1891
|
+
/** Agent state */
|
|
1892
|
+
readonly state: AgentState;
|
|
1893
|
+
/** Whether the agent is connected */
|
|
1894
|
+
readonly isConnected: boolean;
|
|
1895
|
+
/** Agent capabilities */
|
|
1896
|
+
readonly capabilities?: AgentCapabilities;
|
|
2548
1897
|
}
|
|
2549
1898
|
/**
|
|
2550
|
-
*
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
*
|
|
2554
|
-
*
|
|
2555
|
-
*
|
|
2556
|
-
*
|
|
2557
|
-
* TCACA_code_003_FAnt7lcmRT CodeBuddy海外版Pro版本包-包年/CodeBuddy Pro Plan - Yearly
|
|
2558
|
-
* TCACA_code_008_cfWoLwvjU4 赠送月包
|
|
1899
|
+
* Active Session interface
|
|
1900
|
+
* Represents an active session with its resources and operations
|
|
1901
|
+
*
|
|
1902
|
+
* Key design:
|
|
1903
|
+
* - Session is the primary API surface
|
|
1904
|
+
* - agentState provides direct access to underlying agent state
|
|
1905
|
+
* - disconnect() is called directly on session (not session.agent)
|
|
2559
1906
|
*/
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
1907
|
+
interface ActiveSession {
|
|
1908
|
+
/** Session ID */
|
|
1909
|
+
readonly id: string;
|
|
1910
|
+
/** Agent ID */
|
|
1911
|
+
readonly agentId: string;
|
|
1912
|
+
/** Agent state (direct access to underlying agent state) */
|
|
1913
|
+
readonly agentState: AgentState;
|
|
1914
|
+
/** Agent capabilities (available after connection) */
|
|
1915
|
+
readonly capabilities?: AgentCapabilities;
|
|
1916
|
+
/** Available session modes */
|
|
1917
|
+
readonly availableModes?: SessionMode[];
|
|
1918
|
+
/** Current session mode */
|
|
1919
|
+
readonly currentMode?: string;
|
|
1920
|
+
/** Available slash commands (updated via available_commands_update) */
|
|
1921
|
+
readonly availableCommands: AvailableCommand[];
|
|
1922
|
+
/** Whether the session is active */
|
|
1923
|
+
readonly isActive: boolean;
|
|
1924
|
+
/**
|
|
1925
|
+
* Session connection information (only available for cloud sessions)
|
|
1926
|
+
* 会话连接信息,包括sandboxId、link、token等
|
|
1927
|
+
*/
|
|
1928
|
+
readonly connectionInfo?: SessionConnectionInfo;
|
|
1929
|
+
/** Agent operations */
|
|
1930
|
+
readonly agent: SessionAgentOperations;
|
|
1931
|
+
/** Prompts resource */
|
|
1932
|
+
readonly prompts: PromptsResource;
|
|
1933
|
+
/** Artifacts resource */
|
|
1934
|
+
readonly artifacts: ArtifactsResource;
|
|
1935
|
+
/** Files resource */
|
|
1936
|
+
readonly files: FilesResource;
|
|
1937
|
+
/** Resolve a permission request */
|
|
1938
|
+
resolvePermission(requestId: string, optionId: string): boolean;
|
|
1939
|
+
/** Reject a permission request */
|
|
1940
|
+
rejectPermission(requestId: string, reason?: string): boolean;
|
|
1941
|
+
/** Answer a question request with user's selections */
|
|
1942
|
+
answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
|
|
1943
|
+
/** Cancel a question request */
|
|
1944
|
+
cancelQuestion(toolCallId: string, reason?: string): boolean;
|
|
1945
|
+
/** Callback for tool operations (skip or cancel) */
|
|
1946
|
+
toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
|
|
1947
|
+
success: boolean;
|
|
1948
|
+
error?: string;
|
|
1949
|
+
}>;
|
|
1950
|
+
/** Set the current session mode */
|
|
1951
|
+
setMode(modeId: string): Promise<void>;
|
|
1952
|
+
/** Set the current session model */
|
|
1953
|
+
setSessionModel(modelId: string): Promise<void>;
|
|
1954
|
+
/** Set available commands (called when available_commands_update is received) */
|
|
1955
|
+
setAvailableCommands(commands: AvailableCommand[]): void;
|
|
1956
|
+
/** Subscribe to an event */
|
|
1957
|
+
on<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
1958
|
+
/** Unsubscribe from an event */
|
|
1959
|
+
off<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
1960
|
+
/** Subscribe to an event once */
|
|
1961
|
+
once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
1962
|
+
/** Disconnect from the session/agent */
|
|
1963
|
+
disconnect(): void;
|
|
1964
|
+
/** Symbol.dispose for 'using' keyword support */
|
|
1965
|
+
[Symbol.dispose](): void;
|
|
2571
1966
|
}
|
|
2572
1967
|
/**
|
|
2573
|
-
*
|
|
1968
|
+
* 环境类型
|
|
2574
1969
|
*/
|
|
2575
|
-
|
|
2576
|
-
/** 是否是 Pro 版本 */
|
|
2577
|
-
isPro: boolean;
|
|
2578
|
-
isTria?: boolean;
|
|
2579
|
-
/** 到期时间戳 */
|
|
2580
|
-
expireAt?: number;
|
|
2581
|
-
refreshAt?: number;
|
|
2582
|
-
/** 自动续费标志 0-关闭 1-开启 */
|
|
2583
|
-
renewFlag: 0 | 1;
|
|
2584
|
-
/** 套餐代码 */
|
|
2585
|
-
PackageCode?: CommodityCode;
|
|
2586
|
-
/** 套餐名称 */
|
|
2587
|
-
name: string;
|
|
2588
|
-
usageTotal?: string;
|
|
2589
|
-
usageUsed?: string;
|
|
2590
|
-
usageLeft?: string;
|
|
2591
|
-
}
|
|
1970
|
+
type EnvironmentType = 'local' | 'cloud';
|
|
2592
1971
|
/**
|
|
2593
|
-
*
|
|
1972
|
+
* Agent provider interface
|
|
1973
|
+
*
|
|
1974
|
+
* Responsible for:
|
|
1975
|
+
* - Managing agent state/configuration storage
|
|
1976
|
+
* - Creating connections to agents
|
|
1977
|
+
* - Abstracting away transport details (cloud/local)
|
|
1978
|
+
*
|
|
1979
|
+
* The provider.connect() method returns an AgentConnection.
|
|
1980
|
+
* The client wraps the connection in an ActiveSession instance.
|
|
1981
|
+
*
|
|
1982
|
+
* @typeParam C - Connection type used by this provider (e.g., CloudAgentConnection, LocalAgentConnection)
|
|
2594
1983
|
*/
|
|
2595
|
-
interface
|
|
2596
|
-
/**
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
/**
|
|
2615
|
-
|
|
2616
|
-
/**
|
|
2617
|
-
|
|
2618
|
-
/**
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
1984
|
+
interface AgentProvider<C extends AgentConnection = AgentConnection> {
|
|
1985
|
+
/**
|
|
1986
|
+
* Create a new agent and return its ID
|
|
1987
|
+
*
|
|
1988
|
+
* @param params - Optional session params (used by LocalAgentProvider to get cwd)
|
|
1989
|
+
* @returns Agent ID (Cloud: UUID, Local: cwd)
|
|
1990
|
+
*/
|
|
1991
|
+
create?(params?: CreateSessionParams$1): Promise<string>;
|
|
1992
|
+
/** Get agent state by ID */
|
|
1993
|
+
get(agentId: string): Promise<AgentState | undefined>;
|
|
1994
|
+
/**
|
|
1995
|
+
* List all agent states with pagination information
|
|
1996
|
+
*
|
|
1997
|
+
* @param options - Optional query parameters for filtering, sorting, and pagination
|
|
1998
|
+
* Cloud providers use these for API queries and return server pagination
|
|
1999
|
+
* Local providers apply client-side filtering and return synthetic pagination
|
|
2000
|
+
* @returns Object containing agents array and pagination info
|
|
2001
|
+
*/
|
|
2002
|
+
list(options?: ListAgentOptions): Promise<ListAgentResult<AgentState>>;
|
|
2003
|
+
/** Connect to an agent and return the connection */
|
|
2004
|
+
connect(agentId: string): Promise<C>;
|
|
2005
|
+
/** Delete an agent by ID */
|
|
2006
|
+
delete(agentId: string): Promise<boolean>;
|
|
2007
|
+
/**
|
|
2008
|
+
* Archive an agent by ID (optional)
|
|
2009
|
+
* Used by CloudAgentProvider for archiving agents
|
|
2010
|
+
*
|
|
2011
|
+
* @param agentId - Agent ID to archive
|
|
2012
|
+
* @returns Object containing the archived agent ID
|
|
2013
|
+
*/
|
|
2014
|
+
archive?(agentId: string): Promise<{
|
|
2015
|
+
id: string;
|
|
2016
|
+
}>;
|
|
2017
|
+
/**
|
|
2018
|
+
* Rename an agent by ID (optional)
|
|
2019
|
+
* Used by CloudAgentProvider and LocalAgentProvider for renaming agents
|
|
2020
|
+
*
|
|
2021
|
+
* @param agentId - Agent ID to rename
|
|
2022
|
+
* @param title - New title for the agent
|
|
2023
|
+
* @returns Object containing the renamed agent ID
|
|
2024
|
+
*/
|
|
2025
|
+
rename?(agentId: string, title: string): Promise<{
|
|
2026
|
+
id: string;
|
|
2027
|
+
}>;
|
|
2028
|
+
/**
|
|
2029
|
+
* Move an agent by ID (optional)
|
|
2030
|
+
* Used by LocalAgentProvider for moving Playground sessions to Workspace
|
|
2031
|
+
*
|
|
2032
|
+
* @param agentId - Agent ID to move
|
|
2033
|
+
* @returns Object containing the moved agent ID
|
|
2034
|
+
*/
|
|
2035
|
+
move?(agentId: string): Promise<{
|
|
2036
|
+
id: string;
|
|
2037
|
+
}>;
|
|
2038
|
+
/** Filesystem provider (optional - some providers may not support filesystem operations) */
|
|
2039
|
+
readonly filesystem?: FilesystemProvider;
|
|
2040
|
+
/**
|
|
2041
|
+
* Get available models for a repository (optional)
|
|
2042
|
+
* Implementation varies by provider type
|
|
2043
|
+
* @param repo - Repository identifier
|
|
2044
|
+
* @returns Array of model information
|
|
2045
|
+
*/
|
|
2046
|
+
getModels?(repo?: string): Promise<ModelInfo$1[]>;
|
|
2047
|
+
/**
|
|
2048
|
+
* Register sessionId → agentId mapping (optional, used by LocalAgentProvider)
|
|
2049
|
+
* Called after session creation to maintain the mapping for loadSession
|
|
2050
|
+
*
|
|
2051
|
+
* @param sessionId - Session ID returned by connection.createSession()
|
|
2052
|
+
* @param agentId - Agent ID (cwd for Local)
|
|
2053
|
+
*/
|
|
2054
|
+
registerSession?(sessionId: string, agentId: string): void;
|
|
2055
|
+
/**
|
|
2056
|
+
* Open a workspace window (optional, used by LocalAgentProvider)
|
|
2057
|
+
*
|
|
2058
|
+
* @param params - Workspace params including cwd
|
|
2059
|
+
* @returns Response with success status
|
|
2060
|
+
*/
|
|
2061
|
+
openWorkspace?(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
|
|
2062
|
+
/**
|
|
2063
|
+
* Pick files from file dialog (optional, used by LocalAgentProvider)
|
|
2064
|
+
*
|
|
2065
|
+
* @param params - File picker params including filters
|
|
2066
|
+
* @returns Response with file paths and cancel status
|
|
2067
|
+
*/
|
|
2068
|
+
pickFile?(params?: PickFileParams): Promise<PickFileResponse>;
|
|
2069
|
+
/**
|
|
2070
|
+
* Pick folders from folder dialog (optional, used by LocalAgentProvider)
|
|
2071
|
+
*
|
|
2072
|
+
* @param params - Folder picker params
|
|
2073
|
+
* @returns Response with folder paths and cancel status
|
|
2074
|
+
*/
|
|
2075
|
+
pickFolder?(params?: PickFolderParams): Promise<PickFolderResponse>;
|
|
2076
|
+
/**
|
|
2077
|
+
* Upload a file to cloud storage (optional)
|
|
2078
|
+
*
|
|
2079
|
+
* @param params - Upload parameters including file content
|
|
2080
|
+
* @returns Response with cloud URL after successful upload
|
|
2081
|
+
*/
|
|
2082
|
+
uploadFile?(params: UploadFileParams): Promise<UploadFileResponse>;
|
|
2083
|
+
/**
|
|
2084
|
+
* Search for files in the workspace (optional, used by LocalAgentProvider)
|
|
2085
|
+
*
|
|
2086
|
+
* @param params - Search parameters including options
|
|
2087
|
+
* @returns Response with search results
|
|
2088
|
+
*/
|
|
2089
|
+
searchFile?(params: SearchFileParams): Promise<SearchFileResponse>;
|
|
2090
|
+
/**
|
|
2091
|
+
* Batch toggle plugins (optional, used by LocalAgentProvider)
|
|
2092
|
+
*
|
|
2093
|
+
* @param request - Batch plugin operation request
|
|
2094
|
+
* @returns Batch operation result
|
|
2095
|
+
*/
|
|
2096
|
+
batchTogglePlugins?(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
|
|
2097
|
+
/**
|
|
2098
|
+
* Register an event listener
|
|
2099
|
+
* Provider implementations should forward events to the underlying transport
|
|
2100
|
+
*
|
|
2101
|
+
* @param event - Event name
|
|
2102
|
+
* @param handler - Event handler function
|
|
2103
|
+
*/
|
|
2104
|
+
on?(event: string, handler: (...args: any[]) => void): void;
|
|
2105
|
+
/**
|
|
2106
|
+
* Unregister an event listener
|
|
2107
|
+
*
|
|
2108
|
+
* @param event - Event name
|
|
2109
|
+
* @param handler - Event handler function to remove
|
|
2110
|
+
*/
|
|
2111
|
+
off?(event: string, handler: (...args: any[]) => void): void;
|
|
2629
2112
|
}
|
|
2630
2113
|
/**
|
|
2631
|
-
*
|
|
2114
|
+
* AgentClient initialization options
|
|
2632
2115
|
*/
|
|
2633
|
-
interface
|
|
2634
|
-
/**
|
|
2635
|
-
|
|
2636
|
-
/**
|
|
2637
|
-
|
|
2116
|
+
interface AgentClientOptions {
|
|
2117
|
+
/** Agent provider (required) */
|
|
2118
|
+
provider: AgentProvider;
|
|
2119
|
+
/** Logger instance */
|
|
2120
|
+
logger?: Logger;
|
|
2121
|
+
/** Client capabilities (sent during initialization) */
|
|
2122
|
+
clientCapabilities?: ClientCapabilities$1;
|
|
2123
|
+
/**
|
|
2124
|
+
* 运行环境类型
|
|
2125
|
+
* - 'local': IDE 本地环境
|
|
2126
|
+
* - 'cloud': 云端环境
|
|
2127
|
+
*/
|
|
2128
|
+
environmentType?: EnvironmentType;
|
|
2638
2129
|
}
|
|
2639
2130
|
/**
|
|
2640
|
-
*
|
|
2131
|
+
* Client sessions resource interface
|
|
2132
|
+
* Top-level API for session management
|
|
2133
|
+
*
|
|
2134
|
+
* Key design:
|
|
2135
|
+
* - list() returns sessions with pagination info (mapped from agents)
|
|
2136
|
+
* - create() creates a new session (auto-creates agent and connects)
|
|
2137
|
+
* - load() loads an existing session (finds agent by sessionId and connects)
|
|
2138
|
+
* - archive() archives a session/agent
|
|
2139
|
+
* - initializeWorkspace() initializes a workspace for future sessions
|
|
2641
2140
|
*/
|
|
2642
|
-
interface
|
|
2643
|
-
/**
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
/**
|
|
2650
|
-
|
|
2651
|
-
/**
|
|
2652
|
-
|
|
2653
|
-
/**
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
/**
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2141
|
+
interface ClientSessionsResource {
|
|
2142
|
+
/**
|
|
2143
|
+
* List all sessions with pagination info
|
|
2144
|
+
* Cloud: Returns server-side filtered/sorted/paginated results
|
|
2145
|
+
* Local: Returns client-side filtered/sorted results (synthetic pagination)
|
|
2146
|
+
*/
|
|
2147
|
+
list(options?: ListAgentOptions): Promise<ListAgentResult<SessionInfo>>;
|
|
2148
|
+
/** Create a new session (auto-creates agent and connects) */
|
|
2149
|
+
create(params: CreateSessionParams$1): Promise<ActiveSession>;
|
|
2150
|
+
/** Load an existing session (finds agent by sessionId and connects) */
|
|
2151
|
+
load(params: LoadSessionParams$1): Promise<ActiveSession>;
|
|
2152
|
+
/**
|
|
2153
|
+
* Archive a session/agent
|
|
2154
|
+
* @param sessionId - Session ID to archive
|
|
2155
|
+
* @returns Object containing the archived session ID
|
|
2156
|
+
*/
|
|
2157
|
+
archive(sessionId: string): Promise<{
|
|
2158
|
+
id: string;
|
|
2159
|
+
}>;
|
|
2160
|
+
/**
|
|
2161
|
+
* Rename a session/agent
|
|
2162
|
+
* @param sessionId - Session ID to rename
|
|
2163
|
+
* @param title - New title for the session
|
|
2164
|
+
* @returns Object containing the renamed session ID
|
|
2165
|
+
*/
|
|
2166
|
+
rename(sessionId: string, title: string): Promise<{
|
|
2167
|
+
id: string;
|
|
2168
|
+
}>;
|
|
2169
|
+
/**
|
|
2170
|
+
* Move a session (Playground → Workspace)
|
|
2171
|
+
* @param sessionId - Session ID to move
|
|
2172
|
+
* @returns Object containing the moved session ID
|
|
2173
|
+
*/
|
|
2174
|
+
move(sessionId: string): Promise<{
|
|
2175
|
+
id: string;
|
|
2176
|
+
}>;
|
|
2177
|
+
/** Initialize a workspace for future sessions */
|
|
2178
|
+
initializeWorkspace(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
|
|
2179
|
+
/** Models resource for getting available models */
|
|
2180
|
+
readonly models: ModelsResource;
|
|
2181
|
+
/** Get current workspaces list */
|
|
2182
|
+
getCurrentWorkspaces(filter?: {
|
|
2183
|
+
activeOnly?: boolean;
|
|
2184
|
+
}): Promise<WorkspaceInfo[]>;
|
|
2185
|
+
/** Subscribe to sessions resource events */
|
|
2186
|
+
on<K extends keyof SessionsResourceEvents>(event: K, handler: SessionsResourceEventHandler<K>): void;
|
|
2187
|
+
/** Unsubscribe from sessions resource events */
|
|
2188
|
+
off<K extends keyof SessionsResourceEvents>(event: K, handler: SessionsResourceEventHandler<K>): void;
|
|
2189
|
+
/** Open a workspace (for LocalAgentProvider) */
|
|
2190
|
+
openWorkspace(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
|
|
2191
|
+
/** Pick files from file dialog (for LocalAgentProvider) */
|
|
2192
|
+
pickFile(params?: PickFileParams): Promise<PickFileResponse>;
|
|
2193
|
+
/** Pick folders from folder dialog (for LocalAgentProvider) */
|
|
2194
|
+
pickFolder(params?: PickFolderParams): Promise<PickFolderResponse>;
|
|
2195
|
+
/** Upload a file to cloud storage */
|
|
2196
|
+
uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
|
|
2197
|
+
/** Search for files in the workspace (for LocalAgentProvider) */
|
|
2198
|
+
searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
|
|
2199
|
+
/** Batch toggle plugins (for LocalAgentProvider) */
|
|
2200
|
+
batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
|
|
2673
2201
|
}
|
|
2674
2202
|
/**
|
|
2675
|
-
*
|
|
2203
|
+
* Workspace information (aligned with FolderSelectResult)
|
|
2676
2204
|
*/
|
|
2677
|
-
interface
|
|
2678
|
-
/**
|
|
2679
|
-
|
|
2205
|
+
interface WorkspaceInfo {
|
|
2206
|
+
/** Folder path */
|
|
2207
|
+
path: string;
|
|
2208
|
+
/** Folder display name */
|
|
2209
|
+
label: string;
|
|
2680
2210
|
}
|
|
2681
2211
|
/**
|
|
2682
|
-
*
|
|
2212
|
+
* File filter for pickFile dialog
|
|
2683
2213
|
*/
|
|
2684
|
-
interface
|
|
2685
|
-
/**
|
|
2686
|
-
|
|
2214
|
+
interface FileFilter {
|
|
2215
|
+
/** Display name for the filter */
|
|
2216
|
+
readonly name: string;
|
|
2217
|
+
/** File extensions (without dot) */
|
|
2218
|
+
readonly extensions: string[];
|
|
2219
|
+
}
|
|
2220
|
+
/**
|
|
2221
|
+
* Parameters for picking files
|
|
2222
|
+
*/
|
|
2223
|
+
interface PickFileParams {
|
|
2224
|
+
/** Default path for the dialog */
|
|
2225
|
+
readonly defaultPath?: string;
|
|
2226
|
+
/** File type filters */
|
|
2227
|
+
readonly filters?: FileFilter[];
|
|
2228
|
+
/** Whether to allow multiple selection (default false) */
|
|
2229
|
+
readonly canSelectMany?: boolean;
|
|
2230
|
+
}
|
|
2231
|
+
/**
|
|
2232
|
+
* Response from picking files
|
|
2233
|
+
*/
|
|
2234
|
+
interface PickFileResponse {
|
|
2235
|
+
/** Selected files - File objects in browser, absolute path strings in IDE */
|
|
2236
|
+
readonly files: Array<File | string>;
|
|
2237
|
+
/** Whether user cancelled the dialog */
|
|
2238
|
+
readonly canceled: boolean;
|
|
2239
|
+
/** Error message (if failed) */
|
|
2240
|
+
readonly error?: string;
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* Parameters for picking folders
|
|
2244
|
+
*/
|
|
2245
|
+
interface PickFolderParams {
|
|
2246
|
+
/** Default path for the dialog */
|
|
2247
|
+
readonly defaultPath?: string;
|
|
2248
|
+
}
|
|
2249
|
+
/**
|
|
2250
|
+
* Response from picking folders
|
|
2251
|
+
*/
|
|
2252
|
+
interface PickFolderResponse {
|
|
2253
|
+
/** Selected folder paths */
|
|
2254
|
+
readonly folderPaths: string[];
|
|
2255
|
+
/** Whether user cancelled the dialog */
|
|
2256
|
+
readonly canceled: boolean;
|
|
2257
|
+
/** Error message (if failed) */
|
|
2258
|
+
readonly error?: string;
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Parameters for uploading files
|
|
2262
|
+
*/
|
|
2263
|
+
interface UploadFileParams {
|
|
2264
|
+
/** Files to upload - File objects in browser, absolute path strings in IDE */
|
|
2265
|
+
readonly files: Array<File | string>;
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Response from uploading files
|
|
2269
|
+
*/
|
|
2270
|
+
interface UploadFileResponse {
|
|
2271
|
+
/** Whether upload was successful */
|
|
2272
|
+
readonly success: boolean;
|
|
2273
|
+
/** Cloud URLs corresponding to each uploaded file (same order as input files) */
|
|
2274
|
+
readonly urls?: string[];
|
|
2275
|
+
/** URL expiration time in seconds (from backend) */
|
|
2276
|
+
readonly expireSeconds?: number;
|
|
2277
|
+
/** Error message (if upload failed) */
|
|
2278
|
+
readonly error?: string;
|
|
2279
|
+
}
|
|
2280
|
+
/**
|
|
2281
|
+
* Mention type for file/folder
|
|
2282
|
+
*/
|
|
2283
|
+
declare enum MentionType {
|
|
2284
|
+
file = "file",
|
|
2285
|
+
folder = "folder"
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* Search options for file search
|
|
2289
|
+
*/
|
|
2290
|
+
interface SearchOptions {
|
|
2291
|
+
/** Search keyword */
|
|
2292
|
+
readonly search?: string;
|
|
2293
|
+
/** Number of results to return */
|
|
2294
|
+
readonly resultNum: number;
|
|
2295
|
+
}
|
|
2296
|
+
/**
|
|
2297
|
+
* File search result
|
|
2298
|
+
*/
|
|
2299
|
+
interface SearchFileResult {
|
|
2300
|
+
/** Full path */
|
|
2301
|
+
path: string;
|
|
2302
|
+
/** Relative path */
|
|
2303
|
+
relativePath: string;
|
|
2304
|
+
/** File name */
|
|
2305
|
+
fileName?: string;
|
|
2306
|
+
/** Folder name */
|
|
2307
|
+
folderName?: string;
|
|
2308
|
+
/** Type (file or folder) */
|
|
2309
|
+
type: MentionType.file | MentionType.folder;
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* Parameters for searching files
|
|
2313
|
+
*/
|
|
2314
|
+
interface SearchFileParams {
|
|
2315
|
+
/** Search options */
|
|
2316
|
+
readonly options: SearchOptions;
|
|
2317
|
+
/** Search path*/
|
|
2318
|
+
readonly cwd?: string;
|
|
2319
|
+
}
|
|
2320
|
+
/**
|
|
2321
|
+
* Response from searching files
|
|
2322
|
+
*/
|
|
2323
|
+
interface SearchFileResponse {
|
|
2324
|
+
/** Search results */
|
|
2325
|
+
readonly results: SearchFileResult[];
|
|
2326
|
+
/** Error message (if failed) */
|
|
2327
|
+
readonly error?: string;
|
|
2328
|
+
}
|
|
2329
|
+
//#endregion
|
|
2330
|
+
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
|
|
2331
|
+
/**
|
|
2332
|
+
* Cloud Agent Connection implementation
|
|
2333
|
+
* Uses Streamable HTTP transport to connect to cloud-hosted ACP agents
|
|
2334
|
+
* Uses composition pattern - implements event emitter methods internally
|
|
2335
|
+
*
|
|
2336
|
+
* TODO: Connection Lifecycle Responsibilities
|
|
2337
|
+
* CloudAgentProvider caches connections by endpoint link. This class needs to:
|
|
2338
|
+
* - Implement connection health checks (detect and handle connection failures/reconnection)
|
|
2339
|
+
* - Handle token expiration (refresh or re-authentication when tokens expire)
|
|
2340
|
+
* - Emit 'disconnected' event when connection becomes unhealthy so provider can clean up cache
|
|
2341
|
+
*/
|
|
2342
|
+
declare class CloudAgentConnection implements AgentConnection {
|
|
2343
|
+
private client;
|
|
2344
|
+
private listeners;
|
|
2345
|
+
private onceListeners;
|
|
2346
|
+
/**
|
|
2347
|
+
* Flag to suppress sessionUpdate event emission during streaming.
|
|
2348
|
+
* When true, onSessionUpdate callback won't emit to avoid duplicate messages with promptStream.
|
|
2349
|
+
*/
|
|
2350
|
+
private _isStreaming;
|
|
2351
|
+
/**
|
|
2352
|
+
* Session connection information (sandboxId, link, token, etc.)
|
|
2353
|
+
* Set by CloudAgentProvider.connect() after fetching session data from backend.
|
|
2354
|
+
*/
|
|
2355
|
+
private _sessionConnectionInfo?;
|
|
2356
|
+
readonly agentId: string;
|
|
2357
|
+
readonly transport: "cloud";
|
|
2358
|
+
readonly cwd: string;
|
|
2359
|
+
constructor(agentId: string, config: CloudConnectionConfig, cwd?: string);
|
|
2360
|
+
private setupEventForwarding;
|
|
2361
|
+
on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
2362
|
+
off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
2363
|
+
once<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
2364
|
+
emit<K extends keyof ConnectionEvents>(event: K, data: ConnectionEvents[K]): boolean;
|
|
2365
|
+
removeAllListeners<K extends keyof ConnectionEvents>(event?: K): this;
|
|
2366
|
+
get state(): AgentStatus;
|
|
2367
|
+
get isInitialized(): boolean;
|
|
2368
|
+
get capabilities(): AgentCapabilities | undefined;
|
|
2369
|
+
get initializeResult(): InitializeResponse | undefined;
|
|
2370
|
+
connect(): Promise<InitializeResponse>;
|
|
2371
|
+
disconnect(): Promise<void>;
|
|
2372
|
+
createSession(params: CreateSessionParams): Promise<NewSessionResponse>;
|
|
2373
|
+
loadSession(params: LoadSessionParams): Promise<LoadSessionResponse>;
|
|
2374
|
+
setSessionMode(sessionId: string, modeId: string): Promise<SetSessionModeResponse>;
|
|
2375
|
+
setSessionModel(sessionId: string, modelId: string): Promise<SetSessionModelResponse>;
|
|
2376
|
+
prompt(sessionId: string, params: PromptParams): Promise<PromptResponse$1>;
|
|
2377
|
+
promptStream(sessionId: string, params: PromptParams): AsyncIterable<SessionNotification>;
|
|
2378
|
+
cancel(sessionId: string): Promise<void>;
|
|
2379
|
+
resolvePermission(requestId: string, optionId: string): boolean;
|
|
2380
|
+
rejectPermission(requestId: string, reason?: string): boolean;
|
|
2381
|
+
getPendingPermissions(): Map<string, {
|
|
2382
|
+
params: RequestPermissionRequest;
|
|
2383
|
+
createdAt: number;
|
|
2384
|
+
}>;
|
|
2385
|
+
hasPendingPermissions(): boolean;
|
|
2386
|
+
answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
|
|
2387
|
+
cancelQuestion(toolCallId: string, reason?: string): boolean;
|
|
2388
|
+
getPendingQuestions(): Map<string, {
|
|
2389
|
+
request: QuestionRequest;
|
|
2390
|
+
createdAt: number;
|
|
2391
|
+
}>;
|
|
2392
|
+
hasPendingQuestions(): boolean;
|
|
2393
|
+
toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
|
|
2394
|
+
success: boolean;
|
|
2395
|
+
error?: string;
|
|
2396
|
+
}>;
|
|
2397
|
+
/**
|
|
2398
|
+
* Set session connection information
|
|
2399
|
+
* Called by CloudAgentProvider.connect() after fetching session data from backend.
|
|
2400
|
+
*/
|
|
2401
|
+
setSessionConnectionInfo(info: SessionConnectionInfo): void;
|
|
2402
|
+
/**
|
|
2403
|
+
* Get session connection information
|
|
2404
|
+
* Contains sandboxId, link, token, etc.
|
|
2405
|
+
*/
|
|
2406
|
+
get sessionConnectionInfo(): SessionConnectionInfo | undefined;
|
|
2407
|
+
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
2408
|
+
}
|
|
2409
|
+
//#endregion
|
|
2410
|
+
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/api-types.d.ts
|
|
2411
|
+
/**
|
|
2412
|
+
* Response for archive agent
|
|
2413
|
+
* POST /v2/cloudagent/agentmgmt/agents/{id}/archive
|
|
2414
|
+
*/
|
|
2415
|
+
interface ArchiveAgentResponse {
|
|
2416
|
+
/** Agent ID */
|
|
2417
|
+
id: string;
|
|
2418
|
+
}
|
|
2419
|
+
/**
|
|
2420
|
+
* Response for rename agent
|
|
2421
|
+
* PATCH /v2/cloudagent/agentmgmt/agents/{id}
|
|
2422
|
+
*/
|
|
2423
|
+
interface RenameAgentResponse {
|
|
2424
|
+
/** Agent ID */
|
|
2425
|
+
id: string;
|
|
2426
|
+
}
|
|
2427
|
+
//#endregion
|
|
2428
|
+
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-provider.d.ts
|
|
2429
|
+
/**
|
|
2430
|
+
* Configuration for CloudAgentProvider
|
|
2431
|
+
*/
|
|
2432
|
+
interface CloudAgentProviderOptions {
|
|
2433
|
+
/** Base endpoint URL for agent management API (e.g., 'https://api.example.com') */
|
|
2434
|
+
endpoint: string;
|
|
2435
|
+
/** Authorization token */
|
|
2436
|
+
authToken?: string;
|
|
2437
|
+
/** Custom headers */
|
|
2438
|
+
headers?: Record<string, string>;
|
|
2439
|
+
/** Logger instance */
|
|
2440
|
+
logger?: Logger;
|
|
2441
|
+
/** Custom fetch implementation */
|
|
2442
|
+
fetch?: typeof fetch;
|
|
2443
|
+
/** Client capabilities (sent during agent initialization) */
|
|
2444
|
+
clientCapabilities?: ClientCapabilities$1;
|
|
2445
|
+
}
|
|
2446
|
+
/**
|
|
2447
|
+
* CloudAgentProvider - Manages cloud-hosted agents via REST API
|
|
2448
|
+
*
|
|
2449
|
+
* API Endpoints:
|
|
2450
|
+
* - POST {endpoint}/console/cloudagent/agentmgmt/agents - Create new agent
|
|
2451
|
+
* - GET {endpoint}/console/cloudagent/agentmgmt/agents/{id} - Get agent data
|
|
2452
|
+
* - GET {endpoint}/console/cloudagent/agentmgmt/agents - List all agents
|
|
2453
|
+
* - POST {endpoint}/console/cloudagent/agentmgmt/agents/{id}/delete - Delete agent
|
|
2454
|
+
* - GET {endpoint}/console/cloudagent/agentmgmt/agents/{id}/session - Get agent session (includes sandboxId)
|
|
2455
|
+
* - GET {endpoint}/console/cloudagent/agentmgmt/models - Get available models
|
|
2456
|
+
*
|
|
2457
|
+
* The provider stores agent endpoint configurations in the cloud backend.
|
|
2458
|
+
* When connect() is called, it creates a CloudAgentConnection to the agent's
|
|
2459
|
+
* endpoint and returns an Agent instance.
|
|
2460
|
+
*
|
|
2461
|
+
* @example
|
|
2462
|
+
* ```typescript
|
|
2463
|
+
* const provider = new CloudAgentProvider({
|
|
2464
|
+
* endpoint: 'https://staging-copilot.tencent.com',
|
|
2465
|
+
* authToken: 'token'
|
|
2466
|
+
* });
|
|
2467
|
+
*
|
|
2468
|
+
* // List all agents (uses default pagination and sorting)
|
|
2469
|
+
* const allAgents = await provider.list();
|
|
2470
|
+
*
|
|
2471
|
+
* // List agents with custom pagination
|
|
2472
|
+
* const page2 = await provider.list({
|
|
2473
|
+
* page: 2,
|
|
2474
|
+
* size: 50
|
|
2475
|
+
* });
|
|
2476
|
+
*
|
|
2477
|
+
* // List agents with filtering
|
|
2478
|
+
* const runningAgents = await provider.list({
|
|
2479
|
+
* filters: [
|
|
2480
|
+
* { field: 'status', value: 'running' }
|
|
2481
|
+
* ]
|
|
2482
|
+
* });
|
|
2483
|
+
*
|
|
2484
|
+
* // List agents with custom sorting
|
|
2485
|
+
* const sortedAgents = await provider.list({
|
|
2486
|
+
* sort: {
|
|
2487
|
+
* orderBy: 'createdAt',
|
|
2488
|
+
* order: 'desc'
|
|
2489
|
+
* }
|
|
2490
|
+
* });
|
|
2491
|
+
*
|
|
2492
|
+
* // List agents created in last 14 days with multiple filters
|
|
2493
|
+
* const recentAgents = await provider.list({
|
|
2494
|
+
* dayRange: 14,
|
|
2495
|
+
* filters: [
|
|
2496
|
+
* { field: 'status', value: 'running,stopped' }
|
|
2497
|
+
* ],
|
|
2498
|
+
* page: 1,
|
|
2499
|
+
* size: 20
|
|
2500
|
+
* });
|
|
2501
|
+
*
|
|
2502
|
+
* // Get agent state
|
|
2503
|
+
* const state = await provider.get('agent-id');
|
|
2504
|
+
*
|
|
2505
|
+
* // Connect to agent
|
|
2506
|
+
* const agent = await provider.connect('agent-id');
|
|
2507
|
+
*
|
|
2508
|
+
* // Use agent
|
|
2509
|
+
* const session = await agent.sessions.create({ cwd: '/workspace' });
|
|
2510
|
+
*
|
|
2511
|
+
* // Get available models
|
|
2512
|
+
* const models = await provider.getModels('my-repo');
|
|
2513
|
+
* ```
|
|
2514
|
+
*/
|
|
2515
|
+
declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>, FilesystemProvider {
|
|
2516
|
+
private options;
|
|
2517
|
+
private logger?;
|
|
2518
|
+
private fetchImpl;
|
|
2519
|
+
/** Cache for filesystem instances (keyed by agentId) */
|
|
2520
|
+
private filesystemCache;
|
|
2521
|
+
/** Cache for agent connections (keyed by endpoint link) */
|
|
2522
|
+
private connectionCache;
|
|
2523
|
+
/** COS upload service instance */
|
|
2524
|
+
private cosUploadService;
|
|
2525
|
+
/** Event listeners for provider-level events */
|
|
2526
|
+
private eventListeners;
|
|
2527
|
+
constructor(options: CloudAgentProviderOptions);
|
|
2528
|
+
/**
|
|
2529
|
+
* Dispose the provider and clean up resources
|
|
2530
|
+
*/
|
|
2531
|
+
dispose(): void;
|
|
2532
|
+
/**
|
|
2533
|
+
* Get the filesystem provider (returns self)
|
|
2534
|
+
*/
|
|
2535
|
+
get filesystem(): FilesystemProvider;
|
|
2536
|
+
/**
|
|
2537
|
+
* Get filesystem resource for an agent
|
|
2538
|
+
*
|
|
2539
|
+
* Creates or returns cached filesystem instance for the agent's sandbox.
|
|
2540
|
+
* The filesystem supports both `agent:///` URIs and raw paths.
|
|
2541
|
+
*
|
|
2542
|
+
* @param agentId - Agent ID to get filesystem for
|
|
2543
|
+
* @returns FilesResource instance for the agent's sandbox (with URI support)
|
|
2544
|
+
*
|
|
2545
|
+
* @example
|
|
2546
|
+
* ```typescript
|
|
2547
|
+
* const fs = await provider.getFilesystem(agentId);
|
|
2548
|
+
*
|
|
2549
|
+
* // Use agent:/// URIs
|
|
2550
|
+
* const content = await fs.read('agent:///files/src/app.ts');
|
|
2551
|
+
* await fs.write('agent:///artifacts/output.txt', 'Hello');
|
|
2552
|
+
*
|
|
2553
|
+
* // Raw paths still work (backward compatible)
|
|
2554
|
+
* const content2 = await fs.read('/src/app.ts');
|
|
2555
|
+
* ```
|
|
2556
|
+
*/
|
|
2557
|
+
getFilesystem(agentId: string): Promise<FilesResource>;
|
|
2558
|
+
/**
|
|
2559
|
+
* Get sandbox information from backend
|
|
2560
|
+
*
|
|
2561
|
+
* Uses GET {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/session
|
|
2562
|
+
* to retrieve sandbox information. Extracts sandboxId from the session response
|
|
2563
|
+
* and constructs the apiUrl for E2B proxy.
|
|
2564
|
+
*
|
|
2565
|
+
* @param agentId - Agent ID
|
|
2566
|
+
* @returns E2B Sandbox connection information with sandboxId and apiUrl
|
|
2567
|
+
*/
|
|
2568
|
+
private getSandboxInfo;
|
|
2569
|
+
/**
|
|
2570
|
+
* Get agent state by ID
|
|
2571
|
+
*/
|
|
2572
|
+
get(agentId: string): Promise<CloudAgentState | undefined>;
|
|
2573
|
+
/**
|
|
2574
|
+
* List all agent states with pagination information
|
|
2575
|
+
*
|
|
2576
|
+
* @param options - Optional query parameters for filtering, sorting, and pagination
|
|
2577
|
+
* @returns Object containing agents array and pagination info
|
|
2578
|
+
*/
|
|
2579
|
+
list(options?: ListAgentOptions): Promise<ListAgentResult<CloudAgentState>>;
|
|
2580
|
+
/**
|
|
2581
|
+
* Create a new agent
|
|
2582
|
+
* POST {endpoint}/console/cloudagent/agentmgmt/agents
|
|
2583
|
+
*/
|
|
2584
|
+
create(): Promise<string>;
|
|
2585
|
+
/**
|
|
2586
|
+
* Connect to an agent and return the connection
|
|
2587
|
+
*
|
|
2588
|
+
* This method:
|
|
2589
|
+
* 1. Fetches the agent configuration from the backend
|
|
2590
|
+
* 2. Checks if an existing connection can be reused (based on endpoint link)
|
|
2591
|
+
* 3. Creates a CloudAgentConnection to the agent's endpoint if not cached
|
|
2592
|
+
* 4. Saves session connection info to the connection
|
|
2593
|
+
* 5. Connects and initializes the connection
|
|
2594
|
+
* 6. Returns the connected CloudAgentConnection
|
|
2595
|
+
*
|
|
2596
|
+
* Connection caching:
|
|
2597
|
+
* - Connections are cached by endpoint link to enable reuse
|
|
2598
|
+
* - CloudAgentConnection is responsible for handling connection health checks
|
|
2599
|
+
* and token expiration internally
|
|
2600
|
+
*/
|
|
2601
|
+
connect(agentId: string): Promise<CloudAgentConnection>;
|
|
2602
|
+
/**
|
|
2603
|
+
* Delete an agent by ID
|
|
2604
|
+
* POST {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/delete
|
|
2605
|
+
*/
|
|
2606
|
+
delete(agentId: string): Promise<boolean>;
|
|
2607
|
+
/**
|
|
2608
|
+
* Archive an agent by ID
|
|
2609
|
+
* POST {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/archive
|
|
2610
|
+
*
|
|
2611
|
+
* @param agentId - Agent ID to archive
|
|
2612
|
+
* @returns ArchiveAgentResponse containing the archived agent ID
|
|
2613
|
+
*
|
|
2614
|
+
* @example
|
|
2615
|
+
* ```typescript
|
|
2616
|
+
* const result = await provider.archive('agent-123');
|
|
2617
|
+
* console.log('Archived agent:', result.id);
|
|
2618
|
+
* ```
|
|
2619
|
+
*/
|
|
2620
|
+
archive(agentId: string): Promise<ArchiveAgentResponse>;
|
|
2621
|
+
/**
|
|
2622
|
+
* Rename an agent by ID
|
|
2623
|
+
* PATCH {endpoint}/v2/cloudagent/agentmgmt/agents/{agentId}
|
|
2624
|
+
*
|
|
2625
|
+
* @param agentId - Agent ID to rename
|
|
2626
|
+
* @param title - New title for the agent
|
|
2627
|
+
* @returns RenameAgentResponse containing the renamed agent ID
|
|
2628
|
+
*
|
|
2629
|
+
* @example
|
|
2630
|
+
* ```typescript
|
|
2631
|
+
* const result = await provider.rename('agent-123', 'New Title');
|
|
2632
|
+
* console.log('Renamed agent:', result.id);
|
|
2633
|
+
* ```
|
|
2634
|
+
*/
|
|
2635
|
+
rename(agentId: string, title: string): Promise<RenameAgentResponse>;
|
|
2636
|
+
/**
|
|
2637
|
+
* Get available models from product configuration
|
|
2638
|
+
*
|
|
2639
|
+
* GET {endpoint}/console/enterprises/{personal|enterpriseId}/models?repos[]={repo}
|
|
2640
|
+
*
|
|
2641
|
+
* This method fetches the models from /console/enterprises API
|
|
2642
|
+
* and extracts the models array from the response.
|
|
2643
|
+
*
|
|
2644
|
+
* @param repo - Optional repository URL for context-specific config
|
|
2645
|
+
* @returns Array of ModelInfo with full model details
|
|
2646
|
+
*/
|
|
2647
|
+
getModels(repo?: string): Promise<ModelInfo$1[]>;
|
|
2648
|
+
/**
|
|
2649
|
+
* Generate a unique request ID
|
|
2650
|
+
*/
|
|
2651
|
+
private generateRequestId;
|
|
2652
|
+
/**
|
|
2653
|
+
* Common image MIME types for filtering
|
|
2654
|
+
*/
|
|
2655
|
+
private static readonly IMAGE_MIME_TYPES;
|
|
2656
|
+
/**
|
|
2657
|
+
* Pick files using browser's native file input
|
|
2658
|
+
*
|
|
2659
|
+
* @param params - File picker parameters
|
|
2660
|
+
* @returns Response with selected file paths (filenames in browser)
|
|
2661
|
+
*/
|
|
2662
|
+
pickFile(params?: PickFileParams): Promise<PickFileResponse>;
|
|
2663
|
+
/**
|
|
2664
|
+
* Convert file extension to MIME type
|
|
2665
|
+
*/
|
|
2666
|
+
private extensionToMimeType;
|
|
2667
|
+
/**
|
|
2668
|
+
* Upload files to cloud storage via COS presigned URL
|
|
2669
|
+
*
|
|
2670
|
+
* @param params - files array (File objects in browser)
|
|
2671
|
+
* @returns Response with corresponding cloud URLs
|
|
2672
|
+
*/
|
|
2673
|
+
uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
|
|
2674
|
+
/**
|
|
2675
|
+
* Register event listener
|
|
2676
|
+
* @param event - Event name
|
|
2677
|
+
* @param handler - Event handler function
|
|
2678
|
+
*/
|
|
2679
|
+
on(event: string, handler: (...args: any[]) => void): () => void;
|
|
2680
|
+
/**
|
|
2681
|
+
* Unregister event listener
|
|
2682
|
+
* @param event - Event name
|
|
2683
|
+
* @param handler - Event handler function
|
|
2684
|
+
*/
|
|
2685
|
+
off(event: string, handler: (...args: any[]) => void): void;
|
|
2686
|
+
/**
|
|
2687
|
+
* Emit event to all registered listeners
|
|
2688
|
+
* @param event - Event name
|
|
2689
|
+
* @param args - Event arguments
|
|
2690
|
+
*/
|
|
2691
|
+
private emitEvent;
|
|
2692
|
+
private toAgentState;
|
|
2693
|
+
private request;
|
|
2694
|
+
}
|
|
2695
|
+
//#endregion
|
|
2696
|
+
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
|
|
2697
|
+
/**
|
|
2698
|
+
* E2B Filesystem Implementation
|
|
2699
|
+
*
|
|
2700
|
+
* Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource interface.
|
|
2701
|
+
*
|
|
2702
|
+
* @example
|
|
2703
|
+
* ```typescript
|
|
2704
|
+
* const fs = await E2BFilesystem.connect({
|
|
2705
|
+
* sandboxId: 'sandbox-123',
|
|
2706
|
+
* apiKey: 'e2b_xxx'
|
|
2707
|
+
* });
|
|
2708
|
+
*
|
|
2709
|
+
* // Read/write files
|
|
2710
|
+
* await fs.write('/test.txt', 'Hello World');
|
|
2711
|
+
* const content = await fs.read('/test.txt');
|
|
2712
|
+
*
|
|
2713
|
+
* // Watch for changes
|
|
2714
|
+
* const handle = await fs.watchDir('/workspace', (event) => {
|
|
2715
|
+
* console.log('File changed:', event);
|
|
2716
|
+
* });
|
|
2717
|
+
* ```
|
|
2718
|
+
*/
|
|
2719
|
+
declare class E2BFilesystem implements FilesResource {
|
|
2720
|
+
private sandbox;
|
|
2721
|
+
constructor(sandbox: Sandbox);
|
|
2722
|
+
/**
|
|
2723
|
+
* Connect to an E2B Sandbox and create filesystem instance
|
|
2724
|
+
*/
|
|
2725
|
+
static connect(info: E2BSandboxConnectionInfo): Promise<E2BFilesystem>;
|
|
2726
|
+
/**
|
|
2727
|
+
* Get the underlying E2B Sandbox instance
|
|
2728
|
+
*/
|
|
2729
|
+
getSandbox(): Sandbox;
|
|
2730
|
+
read(path: string, opts?: FilesystemRequestOpts & {
|
|
2731
|
+
format?: 'text';
|
|
2732
|
+
}): Promise<string>;
|
|
2733
|
+
read(path: string, opts: FilesystemRequestOpts & {
|
|
2734
|
+
format: 'bytes';
|
|
2735
|
+
}): Promise<Uint8Array>;
|
|
2736
|
+
read(path: string, opts: FilesystemRequestOpts & {
|
|
2737
|
+
format: 'blob';
|
|
2738
|
+
}): Promise<Blob>;
|
|
2739
|
+
read(path: string, opts: FilesystemRequestOpts & {
|
|
2740
|
+
format: 'stream';
|
|
2741
|
+
}): Promise<ReadableStream<Uint8Array>>;
|
|
2742
|
+
write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<WriteInfo>;
|
|
2743
|
+
write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
|
|
2744
|
+
list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
|
|
2745
|
+
exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
|
|
2746
|
+
makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
|
|
2747
|
+
remove(path: string, opts?: FilesystemRequestOpts): Promise<void>;
|
|
2748
|
+
rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
|
|
2749
|
+
getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
|
|
2750
|
+
watchDir(path: string, onEvent: (event: FilesystemEvent$1) => void | Promise<void>, opts?: WatchOpts & {
|
|
2751
|
+
onExit?: (err?: Error) => void | Promise<void>;
|
|
2752
|
+
}): Promise<WatchHandle>;
|
|
2753
|
+
}
|
|
2754
|
+
//#endregion
|
|
2755
|
+
//#region ../agent-provider/lib/common/client/client.d.ts
|
|
2756
|
+
/**
|
|
2757
|
+
* AgentClient - Session-centric client
|
|
2758
|
+
*
|
|
2759
|
+
* Provides a session-centric API that internally manages agents.
|
|
2760
|
+
* Users interact with sessions; the agent lifecycle is handled internally.
|
|
2761
|
+
*
|
|
2762
|
+
* @example
|
|
2763
|
+
* ```typescript
|
|
2764
|
+
* // Create client with a provider
|
|
2765
|
+
* const provider = new CloudAgentProvider({
|
|
2766
|
+
* endpoint: 'https://api.example.com',
|
|
2767
|
+
* authToken: 'token'
|
|
2768
|
+
* });
|
|
2769
|
+
*
|
|
2770
|
+
* const client = new AgentClient({
|
|
2771
|
+
* provider,
|
|
2772
|
+
* logger: console
|
|
2773
|
+
* });
|
|
2774
|
+
*
|
|
2775
|
+
* // List all sessions
|
|
2776
|
+
* const sessions = await client.sessions.list();
|
|
2777
|
+
*
|
|
2778
|
+
* // Create new session (auto-creates agent and connects)
|
|
2779
|
+
* const session = await client.sessions.create({ cwd: '/workspace' });
|
|
2780
|
+
* console.log(session.agentState.status); // agent status
|
|
2781
|
+
* console.log(session.agentState.id); // agent ID
|
|
2782
|
+
*
|
|
2783
|
+
* // Send prompt
|
|
2784
|
+
* await session.prompts.send({ content: 'Hello' });
|
|
2785
|
+
*
|
|
2786
|
+
* // Get available models
|
|
2787
|
+
* const models = await client.sessions.models.list('my-repo');
|
|
2788
|
+
*
|
|
2789
|
+
* // Use 'using' keyword for automatic cleanup
|
|
2790
|
+
* {
|
|
2791
|
+
* using session = await client.sessions.create({ cwd: '/workspace' });
|
|
2792
|
+
* // ... use session
|
|
2793
|
+
* } // session automatically disposed
|
|
2794
|
+
*
|
|
2795
|
+
* // Or manually disconnect
|
|
2796
|
+
* session.disconnect();
|
|
2797
|
+
*
|
|
2798
|
+
* // Load existing session
|
|
2799
|
+
* const loadedSession = await client.sessions.load({
|
|
2800
|
+
* sessionId: 'xxx',
|
|
2801
|
+
* cwd: '/workspace'
|
|
2802
|
+
* });
|
|
2803
|
+
* ```
|
|
2804
|
+
*/
|
|
2805
|
+
declare class AgentClient {
|
|
2806
|
+
private logger?;
|
|
2807
|
+
private provider;
|
|
2808
|
+
private sessionManager;
|
|
2809
|
+
/**
|
|
2810
|
+
* Sessions resource namespace (primary API entry point)
|
|
2811
|
+
*/
|
|
2812
|
+
readonly sessions: ClientSessionsResource;
|
|
2813
|
+
/**
|
|
2814
|
+
* 运行环境类型
|
|
2815
|
+
* - 'local': IDE 本地环境
|
|
2816
|
+
* - 'cloud': 云端环境
|
|
2817
|
+
*/
|
|
2818
|
+
readonly environmentType: 'local' | 'cloud';
|
|
2819
|
+
constructor(options: AgentClientOptions);
|
|
2820
|
+
private createSessionsResource;
|
|
2821
|
+
private createModelsResource;
|
|
2822
|
+
/**
|
|
2823
|
+
* Dispose the client
|
|
2824
|
+
*
|
|
2825
|
+
* Note: Active sessions are not automatically disposed.
|
|
2826
|
+
* The caller is responsible for disconnecting sessions they created.
|
|
2827
|
+
*/
|
|
2828
|
+
dispose(): void;
|
|
2829
|
+
}
|
|
2830
|
+
//#endregion
|
|
2831
|
+
//#region ../agent-provider/lib/common/client/session.d.ts
|
|
2832
|
+
/**
|
|
2833
|
+
* Filesystem getter function type
|
|
2834
|
+
* Returns a FilesResource instance for file operations
|
|
2835
|
+
*/
|
|
2836
|
+
type FilesystemGetter = () => Promise<FilesResource>;
|
|
2837
|
+
/**
|
|
2838
|
+
* Options for creating an ActiveSessionImpl instance
|
|
2839
|
+
*/
|
|
2840
|
+
interface ActiveSessionImplOptions {
|
|
2841
|
+
/** Logger instance */
|
|
2842
|
+
logger?: Logger;
|
|
2843
|
+
/** Getter function for filesystem resource (provided by SessionManager) */
|
|
2844
|
+
getFilesystem?: FilesystemGetter;
|
|
2845
|
+
/** Session connection information (for cloud sessions) */
|
|
2846
|
+
connectionInfo?: SessionConnectionInfo;
|
|
2847
|
+
}
|
|
2848
|
+
/**
|
|
2849
|
+
* ActiveSessionImpl - Implements the ActiveSession interface
|
|
2850
|
+
*
|
|
2851
|
+
* This class wraps an AgentConnection and provides the session-centric API.
|
|
2852
|
+
* It is created by SessionManager when creating or loading sessions.
|
|
2853
|
+
*
|
|
2854
|
+
* @example
|
|
2855
|
+
* ```typescript
|
|
2856
|
+
* // Created by client.sessions.new() or client.sessions.load()
|
|
2857
|
+
* const session = await client.sessions.new({ cwd: '/workspace' });
|
|
2858
|
+
*
|
|
2859
|
+
* // Access agent state
|
|
2860
|
+
* console.log(session.agentState.status);
|
|
2861
|
+
*
|
|
2862
|
+
* // Send prompt
|
|
2863
|
+
* const response = await session.prompts.send({ content: 'Hello!' });
|
|
2864
|
+
*
|
|
2865
|
+
* // Cleanup
|
|
2866
|
+
* session.disconnect();
|
|
2867
|
+
* ```
|
|
2868
|
+
*/
|
|
2869
|
+
declare class ActiveSessionImpl implements ActiveSession {
|
|
2870
|
+
private _id;
|
|
2871
|
+
private _agentId;
|
|
2872
|
+
private _availableModes?;
|
|
2873
|
+
private _currentMode?;
|
|
2874
|
+
private _availableCommands;
|
|
2875
|
+
private logger?;
|
|
2876
|
+
private connection;
|
|
2877
|
+
private _getFilesystem?;
|
|
2878
|
+
private _connectionInfo?;
|
|
2879
|
+
private listeners;
|
|
2880
|
+
private onceListeners;
|
|
2881
|
+
/**
|
|
2882
|
+
* Agent operations namespace
|
|
2883
|
+
*/
|
|
2884
|
+
readonly agent: SessionAgentOperations;
|
|
2885
|
+
/**
|
|
2886
|
+
* Prompts resource namespace
|
|
2887
|
+
*/
|
|
2888
|
+
readonly prompts: PromptsResource;
|
|
2889
|
+
/**
|
|
2890
|
+
* Artifacts resource namespace
|
|
2891
|
+
*/
|
|
2892
|
+
readonly artifacts: ArtifactsResource;
|
|
2893
|
+
/**
|
|
2894
|
+
* Files resource namespace (lazily loaded via getter)
|
|
2895
|
+
*/
|
|
2896
|
+
readonly files: FilesResource;
|
|
2897
|
+
/**
|
|
2898
|
+
* Create an ActiveSessionImpl instance
|
|
2899
|
+
*
|
|
2900
|
+
* @param sessionId - Session ID
|
|
2901
|
+
* @param agentId - Agent ID
|
|
2902
|
+
* @param connection - Already connected AgentConnection
|
|
2903
|
+
* @param options - Additional options
|
|
2904
|
+
*/
|
|
2905
|
+
constructor(sessionId: string, agentId: string, connection: AgentConnection, options?: ActiveSessionImplOptions);
|
|
2906
|
+
/**
|
|
2907
|
+
* Session ID
|
|
2908
|
+
*/
|
|
2909
|
+
get id(): string;
|
|
2910
|
+
/**
|
|
2911
|
+
* Agent ID
|
|
2912
|
+
*/
|
|
2913
|
+
get agentId(): string;
|
|
2914
|
+
/**
|
|
2915
|
+
* Agent state (live connection state)
|
|
2916
|
+
* Returns LocalAgentState or CloudAgentState based on transport type
|
|
2917
|
+
*/
|
|
2918
|
+
get agentState(): AgentState;
|
|
2919
|
+
/**
|
|
2920
|
+
* Get agent capabilities (available after connection)
|
|
2921
|
+
*/
|
|
2922
|
+
get capabilities(): AgentCapabilities | undefined;
|
|
2923
|
+
/**
|
|
2924
|
+
* Available session modes
|
|
2925
|
+
*/
|
|
2926
|
+
get availableModes(): SessionMode[] | undefined;
|
|
2927
|
+
/**
|
|
2928
|
+
* Current session mode
|
|
2929
|
+
*/
|
|
2930
|
+
get currentMode(): string | undefined;
|
|
2931
|
+
/**
|
|
2932
|
+
* Available slash commands
|
|
2933
|
+
*
|
|
2934
|
+
* When Agent sends available_commands_update, this list is automatically updated.
|
|
2935
|
+
* Commands can be accessed directly without waiting for events.
|
|
2936
|
+
*/
|
|
2937
|
+
get availableCommands(): AvailableCommand[];
|
|
2938
|
+
/**
|
|
2939
|
+
* Set available commands (called when available_commands_update is received)
|
|
2940
|
+
*/
|
|
2941
|
+
setAvailableCommands(commands: AvailableCommand[]): void;
|
|
2942
|
+
/**
|
|
2943
|
+
* Check if the session is active
|
|
2944
|
+
*/
|
|
2945
|
+
get isActive(): boolean;
|
|
2946
|
+
/**
|
|
2947
|
+
* Session connection information (only available for cloud sessions)
|
|
2948
|
+
* 会话连接信息,包括sandboxId、link、token等
|
|
2949
|
+
*/
|
|
2950
|
+
get connectionInfo(): SessionConnectionInfo | undefined;
|
|
2951
|
+
/**
|
|
2952
|
+
* Set session modes (called after create/load)
|
|
2953
|
+
*/
|
|
2954
|
+
setModes(availableModes?: SessionMode[], currentMode?: string): void;
|
|
2955
|
+
private createAgentOperations;
|
|
2956
|
+
private createPromptsResource;
|
|
2957
|
+
private createArtifactsResource;
|
|
2958
|
+
/**
|
|
2959
|
+
* Create files resource with lazy-loaded filesystem
|
|
2960
|
+
*
|
|
2961
|
+
* The filesystem is lazily loaded on first use to avoid unnecessary
|
|
2962
|
+
* connections to the sandbox. The actual filesystem instance is obtained
|
|
2963
|
+
* via the getter function provided by SessionManager.
|
|
2964
|
+
*/
|
|
2965
|
+
private createFilesResource;
|
|
2966
|
+
/**
|
|
2967
|
+
* Resolve a permission request
|
|
2968
|
+
*/
|
|
2969
|
+
resolvePermission(requestId: string, optionId: string): boolean;
|
|
2970
|
+
/**
|
|
2971
|
+
* Reject a permission request
|
|
2972
|
+
*/
|
|
2973
|
+
rejectPermission(requestId: string, reason?: string): boolean;
|
|
2974
|
+
/**
|
|
2975
|
+
* Answer a question request with user's selections
|
|
2976
|
+
*/
|
|
2977
|
+
answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
|
|
2978
|
+
/**
|
|
2979
|
+
* Cancel a question request
|
|
2980
|
+
*/
|
|
2981
|
+
cancelQuestion(toolCallId: string, reason?: string): boolean;
|
|
2982
|
+
/**
|
|
2983
|
+
* Callback for tool operations (skip or cancel)
|
|
2984
|
+
* @param toolCallId Tool call ID
|
|
2985
|
+
* @param toolName Tool name
|
|
2986
|
+
* @param action Action to perform ('skip' or 'cancel')
|
|
2987
|
+
*/
|
|
2988
|
+
toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
|
|
2989
|
+
success: boolean;
|
|
2990
|
+
error?: string;
|
|
2991
|
+
}>;
|
|
2992
|
+
/**
|
|
2993
|
+
* Set the current session mode
|
|
2994
|
+
*
|
|
2995
|
+
* @param modeId - The mode ID to switch to (must be in availableModes)
|
|
2996
|
+
* @throws Error if modeId is not in availableModes or connection fails
|
|
2997
|
+
*
|
|
2998
|
+
* @example
|
|
2999
|
+
* ```typescript
|
|
3000
|
+
* // Switch to 'code' mode
|
|
3001
|
+
* await session.setMode('code');
|
|
3002
|
+
*
|
|
3003
|
+
* // Switch to 'architect' mode
|
|
3004
|
+
* await session.setMode('architect');
|
|
3005
|
+
* ```
|
|
3006
|
+
*/
|
|
3007
|
+
setMode(modeId: string): Promise<void>;
|
|
3008
|
+
/**
|
|
3009
|
+
* Set the current session model
|
|
3010
|
+
*
|
|
3011
|
+
* @param modelId - The model ID to switch to
|
|
3012
|
+
* @example
|
|
3013
|
+
* ```typescript
|
|
3014
|
+
* // Switch to Claude Sonnet 4
|
|
3015
|
+
* await session.setSessionModel('claude-sonnet-4-20250514');
|
|
3016
|
+
*
|
|
3017
|
+
* // Switch to GPT-4o
|
|
3018
|
+
* await session.setSessionModel('gpt-4o');
|
|
3019
|
+
* ```
|
|
3020
|
+
*/
|
|
3021
|
+
setSessionModel(modelId: string): Promise<void>;
|
|
3022
|
+
/**
|
|
3023
|
+
* Subscribe to session events
|
|
3024
|
+
*/
|
|
3025
|
+
on<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
3026
|
+
/**
|
|
3027
|
+
* Unsubscribe from session events
|
|
3028
|
+
*/
|
|
3029
|
+
off<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
3030
|
+
/**
|
|
3031
|
+
* Subscribe to a session event once
|
|
3032
|
+
*/
|
|
3033
|
+
once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
3034
|
+
/**
|
|
3035
|
+
* Emit an event to all registered listeners
|
|
3036
|
+
*/
|
|
3037
|
+
private emit;
|
|
3038
|
+
/**
|
|
3039
|
+
* Remove all listeners for an event
|
|
3040
|
+
*/
|
|
3041
|
+
private removeAllListeners;
|
|
3042
|
+
/**
|
|
3043
|
+
* Disconnect from the session/agent
|
|
3044
|
+
*/
|
|
3045
|
+
disconnect(): void;
|
|
3046
|
+
/**
|
|
3047
|
+
* Symbol.dispose for 'using' keyword support
|
|
3048
|
+
* Automatically disconnects and cleans up when session goes out of scope
|
|
3049
|
+
*
|
|
3050
|
+
* @example
|
|
3051
|
+
* ```typescript
|
|
3052
|
+
* {
|
|
3053
|
+
* using session = await client.sessions.new({ cwd: '/workspace' });
|
|
3054
|
+
* // ... use session
|
|
3055
|
+
* } // session automatically disposed
|
|
3056
|
+
* ```
|
|
3057
|
+
*/
|
|
3058
|
+
[Symbol.dispose](): void;
|
|
3059
|
+
private getConnectionOrThrow;
|
|
3060
|
+
private setupConnectionEvents;
|
|
3061
|
+
private mapPromptResponse;
|
|
2687
3062
|
}
|
|
3063
|
+
//#endregion
|
|
3064
|
+
//#region ../agent-provider/lib/common/client/session-manager.d.ts
|
|
2688
3065
|
/**
|
|
2689
|
-
*
|
|
3066
|
+
* Options for creating a SessionManager instance
|
|
2690
3067
|
*/
|
|
2691
|
-
interface
|
|
2692
|
-
/**
|
|
2693
|
-
|
|
2694
|
-
/**
|
|
2695
|
-
|
|
3068
|
+
interface SessionManagerOptions {
|
|
3069
|
+
/** Agent provider (required) */
|
|
3070
|
+
provider: AgentProvider;
|
|
3071
|
+
/** Logger instance */
|
|
3072
|
+
logger?: Logger;
|
|
2696
3073
|
}
|
|
2697
3074
|
/**
|
|
2698
|
-
*
|
|
3075
|
+
* SessionManager - Session lifecycle management
|
|
2699
3076
|
*
|
|
2700
|
-
*
|
|
3077
|
+
* This class manages the relationship between sessions and agents.
|
|
3078
|
+
* Since the backend is agent-centric, SessionManager handles the mapping:
|
|
3079
|
+
* - Sessions are views over agents
|
|
3080
|
+
* - sessionId may equal agentId in simple cases
|
|
3081
|
+
*
|
|
3082
|
+
* Features:
|
|
3083
|
+
* - Session caching: reuses existing ActiveSession instances
|
|
3084
|
+
* - Automatic cleanup on session disconnect
|
|
3085
|
+
*
|
|
3086
|
+
* @example
|
|
3087
|
+
* ```typescript
|
|
3088
|
+
* const manager = new SessionManager({ provider, logger });
|
|
3089
|
+
*
|
|
3090
|
+
* // List sessions
|
|
3091
|
+
* const sessions = await manager.listSessions();
|
|
3092
|
+
*
|
|
3093
|
+
* // Create new session
|
|
3094
|
+
* const session = await manager.createSession({ cwd: '/workspace' });
|
|
3095
|
+
*
|
|
3096
|
+
* // Load existing session (returns cached instance if available)
|
|
3097
|
+
* const loaded = await manager.loadSession({ sessionId: 'xxx', cwd: '/workspace' });
|
|
3098
|
+
* ```
|
|
2701
3099
|
*/
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
* @returns Promise<GetAgentsResponse> Agent 列表响应
|
|
2707
|
-
*/
|
|
2708
|
-
getAgents(request: GetAgentsRequest): Promise<GetAgentsResponse>;
|
|
2709
|
-
/**
|
|
2710
|
-
* 获取可用模型列表
|
|
2711
|
-
* @param request 请求参数(包含仓库路径)
|
|
2712
|
-
* @returns Promise<GetModelsResponse> 模型列表响应
|
|
2713
|
-
*/
|
|
2714
|
-
getModels(request: GetModelsRequest): Promise<GetModelsResponse>;
|
|
3100
|
+
declare class SessionManager {
|
|
3101
|
+
private provider;
|
|
3102
|
+
private logger?;
|
|
3103
|
+
constructor(options: SessionManagerOptions);
|
|
2715
3104
|
/**
|
|
2716
|
-
*
|
|
2717
|
-
*
|
|
3105
|
+
* List all sessions with pagination info (mapped from agents)
|
|
3106
|
+
*
|
|
3107
|
+
* Each agent maps to a session. The sessionId is derived from the agent.
|
|
3108
|
+
* Cloud: Returns server-side filtered/sorted/paginated results
|
|
3109
|
+
* Local: Returns client-side filtered/sorted results (synthetic pagination)
|
|
3110
|
+
*
|
|
3111
|
+
* @param options - Optional query parameters for filtering, sorting, and pagination
|
|
2718
3112
|
*/
|
|
2719
|
-
|
|
3113
|
+
listSessions(options?: ListAgentOptions): Promise<ListAgentResult<SessionInfo>>;
|
|
2720
3114
|
/**
|
|
2721
|
-
*
|
|
2722
|
-
*
|
|
2723
|
-
*
|
|
3115
|
+
* Create a new session
|
|
3116
|
+
*
|
|
3117
|
+
* Steps:
|
|
3118
|
+
* 1. Create new agent (if provider supports it) or use existing
|
|
3119
|
+
* 2. Connect to agent
|
|
3120
|
+
* 3. Call ACP newSession
|
|
3121
|
+
* 4. Register session mapping (for LocalAgentProvider)
|
|
3122
|
+
* 5. Return ActiveSession instance
|
|
2724
3123
|
*/
|
|
2725
|
-
|
|
3124
|
+
createSession(params: CreateSessionParams$1): Promise<ActiveSession>;
|
|
2726
3125
|
/**
|
|
2727
|
-
*
|
|
3126
|
+
* Load an existing session
|
|
3127
|
+
*
|
|
3128
|
+
* Steps:
|
|
3129
|
+
* 1. Check cache for existing session
|
|
3130
|
+
* 2. Find agent by sessionId (sessionId === agentId in current design)
|
|
3131
|
+
* 3. Connect to agent
|
|
3132
|
+
* 4. Call ACP loadSession
|
|
3133
|
+
* 5. Return ActiveSession instance (cached)
|
|
2728
3134
|
*/
|
|
2729
|
-
|
|
3135
|
+
loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
|
|
2730
3136
|
}
|
|
2731
3137
|
//#endregion
|
|
2732
3138
|
//#region ../agent-provider/lib/backend/backend-provider.d.ts
|
|
@@ -2734,26 +3140,16 @@ interface IBackendProvider {
|
|
|
2734
3140
|
* Backend Provider 实现类
|
|
2735
3141
|
*
|
|
2736
3142
|
* 职责:
|
|
2737
|
-
* - 与后端 API 通信(getAgents, getModels, getAccount 等)
|
|
2738
3143
|
* - 触发登录/登出流程
|
|
2739
3144
|
* - 获取 account 后自动同步到 accountService
|
|
3145
|
+
*
|
|
3146
|
+
* 注意:getAgents 和 getModels 方法已废弃并移除,
|
|
3147
|
+
* 请使用 IAgentAdapter 中的对应方法
|
|
2740
3148
|
*/
|
|
2741
3149
|
declare class BackendProvider implements IBackendProvider {
|
|
2742
3150
|
private readonly baseUrl;
|
|
2743
3151
|
private readonly authToken?;
|
|
2744
3152
|
constructor(config: BackendProviderConfig);
|
|
2745
|
-
/**
|
|
2746
|
-
* 获取 Agent 列表
|
|
2747
|
-
* API 端点: GET /v2/cloudagent/agentmgmt/agents
|
|
2748
|
-
*/
|
|
2749
|
-
getAgents(request?: GetAgentsRequest): Promise<GetAgentsResponse>;
|
|
2750
|
-
/**
|
|
2751
|
-
* 获取可用模型列表
|
|
2752
|
-
* API 端点: GET /v2/cloudagent/models (假设)
|
|
2753
|
-
*
|
|
2754
|
-
* 当前实现: 返回 Mock 数据
|
|
2755
|
-
*/
|
|
2756
|
-
getModels(request: GetModelsRequest): Promise<GetModelsResponse>;
|
|
2757
3153
|
/**
|
|
2758
3154
|
* 获取当前账号信息
|
|
2759
3155
|
* API 端点: GET /console/accounts (返回账号列表)
|
|
@@ -2768,12 +3164,82 @@ declare class BackendProvider implements IBackendProvider {
|
|
|
2768
3164
|
* 5. 同步到 accountService
|
|
2769
3165
|
*/
|
|
2770
3166
|
getAccount(): Promise<Account | null>;
|
|
3167
|
+
/**
|
|
3168
|
+
* 获取用户连接器列表
|
|
3169
|
+
* API 端点: GET /console/as/connector/user/
|
|
3170
|
+
*/
|
|
3171
|
+
getUserConnector(): Promise<ListUserConnectorResponse>;
|
|
3172
|
+
/**
|
|
3173
|
+
* 修改用户连接器连接状态
|
|
3174
|
+
* API 端点: PATCH /console/as/connector/user/:name/connect_status
|
|
3175
|
+
*/
|
|
3176
|
+
modifyUserConnectorConnectStatus(request: ModifyUserConnectorConnectStatusRequest): Promise<void>;
|
|
3177
|
+
/**
|
|
3178
|
+
* 修改用户连接器仓库
|
|
3179
|
+
* API 端点: PATCH /console/as/connector/user/:name/repo/
|
|
3180
|
+
*/
|
|
3181
|
+
modifyUserConnectorRepo(request: ModifyUserConnectorRepoRequest): Promise<void>;
|
|
3182
|
+
/**
|
|
3183
|
+
* 修改用户连接器激活状态
|
|
3184
|
+
* API 端点: PATCH /console/as/connector/user/:name/active_status
|
|
3185
|
+
*/
|
|
3186
|
+
modifyUserConnectorActiveStatus(request: ModifyUserConnectorActiveStatusRequest): Promise<void>;
|
|
3187
|
+
/**
|
|
3188
|
+
* 删除用户连接器
|
|
3189
|
+
* API 端点: DELETE /console/as/connector/user/:name/
|
|
3190
|
+
*/
|
|
3191
|
+
deleteUserConnector(name: 'github' | 'gongfeng'): Promise<void>;
|
|
3192
|
+
/**
|
|
3193
|
+
* 添加任务
|
|
3194
|
+
* API 端点: POST /console/as/connector/task/
|
|
3195
|
+
*/
|
|
3196
|
+
addConnectorTask(request: AddTaskRequest): Promise<AddTaskResponse>;
|
|
3197
|
+
/**
|
|
3198
|
+
* 获取任务连接器列表
|
|
3199
|
+
* API 端点: GET /console/as/connector/task/:taskid
|
|
3200
|
+
*/
|
|
3201
|
+
getTaskConnector(taskId: string): Promise<ListTaskConnectorResponse>;
|
|
3202
|
+
/**
|
|
3203
|
+
* 修改任务连接器激活状态
|
|
3204
|
+
* API 端点: PATCH /console/as/connector/task/:taskid/active_status
|
|
3205
|
+
*/
|
|
3206
|
+
modifyTaskConnectorActiveStatus(request: ModifyTaskConnectorActiveStatusRequest): Promise<ModifyTaskConnectorActiveStatusResponse>;
|
|
3207
|
+
/**
|
|
3208
|
+
* 修改任务连接器仓库
|
|
3209
|
+
* API 端点: PATCH /console/as/connector/task/:taskid/repo
|
|
3210
|
+
*/
|
|
3211
|
+
modifyTaskConnectorRepo(request: ModifyTaskConnectorRepoRequest): Promise<ModifyTaskConnectorRepoResponse>;
|
|
3212
|
+
/**
|
|
3213
|
+
* 根据账号类型获取用量信息并合并到账号中
|
|
3214
|
+
* - 企业用户:调用 getEnterpriseUsage 获取月度限额
|
|
3215
|
+
* - 个人用户:调用 getCurrentPlan 获取套餐信息
|
|
3216
|
+
*/
|
|
3217
|
+
private enrichAccountWithUsage;
|
|
2771
3218
|
/**
|
|
2772
3219
|
* 获取当前套餐信息
|
|
2773
3220
|
* 从计量计费接口获取用户的套餐信息
|
|
2774
3221
|
* API: POST /billing/meter/get-user-resource
|
|
2775
3222
|
*/
|
|
2776
3223
|
private getCurrentPlan;
|
|
3224
|
+
/**
|
|
3225
|
+
* 通过回调code,换token
|
|
3226
|
+
* @param request
|
|
3227
|
+
* @returns
|
|
3228
|
+
*/
|
|
3229
|
+
saveOauthToken(request: SaveOauthTokenRequest): Promise<void>;
|
|
3230
|
+
/**
|
|
3231
|
+
* 获取OAuth连接器的仓库列表
|
|
3232
|
+
*/
|
|
3233
|
+
getRepoList(request: GetRepoListRequest): Promise<GetRepoListResponse>;
|
|
3234
|
+
/**
|
|
3235
|
+
* 撤销OAuth连接器的所有连接
|
|
3236
|
+
*/
|
|
3237
|
+
revokeAll(request: RevokeAllRequest): Promise<void>;
|
|
3238
|
+
/**
|
|
3239
|
+
* 获取 OAuth 用户信息
|
|
3240
|
+
* API 端点: GET /console/as/connector/oauth/:name/oauthuser
|
|
3241
|
+
*/
|
|
3242
|
+
getOauthUser(request: GetOauthUserRequest): Promise<GetOauthUserResponse>;
|
|
2777
3243
|
/**
|
|
2778
3244
|
* 根据账号类型和 Pro 状态计算版本展示类型
|
|
2779
3245
|
* - personal + isPro = 'pro'
|
|
@@ -2789,9 +3255,20 @@ declare class BackendProvider implements IBackendProvider {
|
|
|
2789
3255
|
login(): Promise<void>;
|
|
2790
3256
|
/**
|
|
2791
3257
|
* 登出账号
|
|
2792
|
-
* Web 环境:
|
|
3258
|
+
* Web 环境: 通过 iframe 访问登出 URL 清除 cookie
|
|
2793
3259
|
*/
|
|
2794
3260
|
logout(): Promise<void>;
|
|
3261
|
+
/**
|
|
3262
|
+
* 批量切换插件状态
|
|
3263
|
+
* Web 环境不支持此功能
|
|
3264
|
+
*/
|
|
3265
|
+
batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
|
|
3266
|
+
/**
|
|
3267
|
+
* 获取企业用户用量信息
|
|
3268
|
+
* API: POST /billing/meter/get-enterprise-user-usage
|
|
3269
|
+
* 构建查询参数字符串
|
|
3270
|
+
*/
|
|
3271
|
+
getEnterpriseUsage(enterpriseId: string): Promise<EnterpriseUsage | null>;
|
|
2795
3272
|
}
|
|
2796
3273
|
/**
|
|
2797
3274
|
* 创建 BackendProvider 实例
|
|
@@ -2813,7 +3290,7 @@ interface IPCBackendProviderConfig {
|
|
|
2813
3290
|
/**
|
|
2814
3291
|
* IPC Backend Provider 实现类
|
|
2815
3292
|
*
|
|
2816
|
-
* 通过 IWidgetChannel
|
|
3293
|
+
* 通过 IWidgetChannel 与后端通信
|
|
2817
3294
|
*/
|
|
2818
3295
|
declare class IPCBackendProvider implements IBackendProvider {
|
|
2819
3296
|
private readonly channel;
|
|
@@ -2828,20 +3305,75 @@ declare class IPCBackendProvider implements IBackendProvider {
|
|
|
2828
3305
|
*/
|
|
2829
3306
|
private sendBackendRequest;
|
|
2830
3307
|
/**
|
|
2831
|
-
*
|
|
2832
|
-
* 通过
|
|
3308
|
+
* 获取当前账号信息
|
|
3309
|
+
* IDE 环境: 通过 IPC 获取账号信息,并同步到 accountService
|
|
2833
3310
|
*/
|
|
2834
|
-
|
|
3311
|
+
getAccount(): Promise<Account | null>;
|
|
2835
3312
|
/**
|
|
2836
|
-
*
|
|
2837
|
-
* 通过
|
|
3313
|
+
* 获取用户连接器列表
|
|
3314
|
+
* IDE 环境: 通过 IPC 获取用户连接器列表
|
|
2838
3315
|
*/
|
|
2839
|
-
|
|
3316
|
+
getUserConnector(): Promise<ListUserConnectorResponse>;
|
|
2840
3317
|
/**
|
|
2841
|
-
*
|
|
2842
|
-
* IDE 环境: 通过 IPC
|
|
3318
|
+
* 修改用户连接器连接状态
|
|
3319
|
+
* IDE 环境: 通过 IPC 修改用户连接器连接状态
|
|
2843
3320
|
*/
|
|
2844
|
-
|
|
3321
|
+
modifyUserConnectorConnectStatus(request: ModifyUserConnectorConnectStatusRequest): Promise<void>;
|
|
3322
|
+
/**
|
|
3323
|
+
* 修改用户连接器仓库
|
|
3324
|
+
* IDE 环境: 通过 IPC 修改用户连接器仓库
|
|
3325
|
+
*/
|
|
3326
|
+
modifyUserConnectorRepo(request: ModifyUserConnectorRepoRequest): Promise<void>;
|
|
3327
|
+
/**
|
|
3328
|
+
* 修改用户连接器激活状态
|
|
3329
|
+
* IDE 环境: 通过 IPC 修改用户连接器激活状态
|
|
3330
|
+
*/
|
|
3331
|
+
modifyUserConnectorActiveStatus(request: ModifyUserConnectorActiveStatusRequest): Promise<void>;
|
|
3332
|
+
/**
|
|
3333
|
+
* 删除用户连接器
|
|
3334
|
+
* IDE 环境: 通过 IPC 删除用户连接器
|
|
3335
|
+
*/
|
|
3336
|
+
deleteUserConnector(name: 'github' | 'gongfeng'): Promise<void>;
|
|
3337
|
+
/**
|
|
3338
|
+
* 添加任务
|
|
3339
|
+
* IDE 环境: 通过 IPC 添加任务
|
|
3340
|
+
*/
|
|
3341
|
+
addConnectorTask(request: AddTaskRequest): Promise<AddTaskResponse>;
|
|
3342
|
+
/**
|
|
3343
|
+
* 获取任务连接器列表
|
|
3344
|
+
* IDE 环境: 通过 IPC 获取任务连接器列表
|
|
3345
|
+
*/
|
|
3346
|
+
getTaskConnector(taskId: string): Promise<ListTaskConnectorResponse>;
|
|
3347
|
+
/**
|
|
3348
|
+
* 修改任务连接器激活状态
|
|
3349
|
+
* IDE 环境: 通过 IPC 修改任务连接器激活状态
|
|
3350
|
+
*/
|
|
3351
|
+
modifyTaskConnectorActiveStatus(request: ModifyTaskConnectorActiveStatusRequest): Promise<ModifyTaskConnectorActiveStatusResponse>;
|
|
3352
|
+
/**
|
|
3353
|
+
* 修改任务连接器仓库
|
|
3354
|
+
* IDE 环境: 通过 IPC 修改任务连接器仓库
|
|
3355
|
+
*/
|
|
3356
|
+
modifyTaskConnectorRepo(request: ModifyTaskConnectorRepoRequest): Promise<ModifyTaskConnectorRepoResponse>;
|
|
3357
|
+
/**
|
|
3358
|
+
* 获取 OAuth 用户信息
|
|
3359
|
+
* IDE 环境: 通过 IPC 获取 OAuth 用户信息
|
|
3360
|
+
*/
|
|
3361
|
+
getOauthUser(request: GetOauthUserRequest): Promise<GetOauthUserResponse>;
|
|
3362
|
+
/**
|
|
3363
|
+
* 通过回调code,换token
|
|
3364
|
+
* IDE 环境: 通过 IPC 保存 OAuth Token
|
|
3365
|
+
*/
|
|
3366
|
+
saveOauthToken(request: SaveOauthTokenRequest): Promise<void>;
|
|
3367
|
+
/**
|
|
3368
|
+
* 获取OAuth连接器的仓库列表
|
|
3369
|
+
* IDE 环境: 通过 IPC 获取仓库列表
|
|
3370
|
+
*/
|
|
3371
|
+
getRepoList(request: GetRepoListRequest): Promise<GetRepoListResponse>;
|
|
3372
|
+
/**
|
|
3373
|
+
* 撤销OAuth连接器的所有连接
|
|
3374
|
+
* IDE 环境: 通过 IPC 撤销所有连接
|
|
3375
|
+
*/
|
|
3376
|
+
revokeAll(request: RevokeAllRequest): Promise<void>;
|
|
2845
3377
|
/**
|
|
2846
3378
|
* 触发登录流程
|
|
2847
3379
|
* IDE 环境: 通过 IPC 通知 IDE 打开登录流程
|
|
@@ -2852,6 +3384,19 @@ declare class IPCBackendProvider implements IBackendProvider {
|
|
|
2852
3384
|
* IDE 环境: 通过 IPC 通知 IDE 登出
|
|
2853
3385
|
*/
|
|
2854
3386
|
logout(): Promise<void>;
|
|
3387
|
+
/**
|
|
3388
|
+
* 重新加载窗口
|
|
3389
|
+
* IDE 环境: 通过 IPC 通知 IDE 重新加载窗口(用于应用语言设置等)
|
|
3390
|
+
* @param params 可选参数,如 locale
|
|
3391
|
+
*/
|
|
3392
|
+
reloadWindow(params?: {
|
|
3393
|
+
locale?: string;
|
|
3394
|
+
}): Promise<void>;
|
|
3395
|
+
/**
|
|
3396
|
+
* 批量切换插件状态
|
|
3397
|
+
* IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
|
|
3398
|
+
*/
|
|
3399
|
+
batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
|
|
2855
3400
|
/**
|
|
2856
3401
|
* 调试日志
|
|
2857
3402
|
*/
|
|
@@ -2862,5 +3407,5 @@ declare class IPCBackendProvider implements IBackendProvider {
|
|
|
2862
3407
|
*/
|
|
2863
3408
|
declare function createIPCBackendProvider(config: IPCBackendProviderConfig): IPCBackendProvider;
|
|
2864
3409
|
//#endregion
|
|
2865
|
-
export { type Account, type AccountPlan, type ActiveSession, ActiveSessionImpl, type AgentCapabilities, AgentClient, type AgentClientOptions, type AgentConnection, type Agent as AgentInfo, type AgentProvider, type AgentState, type AgentStateType, type AgentStatus, type AgentTransport, type PromptResponse as ApiPromptResponse, type ArtifactsResource, BackendProvider, type BackendProviderConfig, type BaseAgentState, type BaseConnectionConfig, type CreateSessionParams as ClientCreateSessionParams, type CreateSessionParams, type LoadSessionParams as ClientLoadSessionParams, type LoadSessionParams, type ClientSessionsResource, CloudAgentConnection, CloudAgentProvider, type CloudAgentProviderOptions, type CloudAgentSourceInfo, type CloudAgentState, type CloudAgentTarget, type CloudAgentVisibility, type CloudConnectionConfig, type CommodityCode, type ConnectionEvents, type DeployStatus, E2BFilesystem, type E2BSandboxConnectionInfo, type Edition, type EditionDisplayType, type EntryInfo, type FilesResource, type Filesystem, type FilesystemListOpts, type FilesystemProvider, type FilesystemRequestOpts, type
|
|
3410
|
+
export { type Account, type AccountPlan, type ActiveSession, ActiveSessionImpl, type AgentCapabilities, AgentClient, type AgentClientOptions, type AgentConnection, type Agent as AgentInfo, type AgentProvider, type AgentState, type AgentStateType, type AgentStatus, type AgentTransport, type PromptResponse as ApiPromptResponse, type ArtifactsResource, BackendProvider, type BackendProviderConfig, type BaseAgentState, type BaseConnectionConfig, type CreateSessionParams as ClientCreateSessionParams, type CreateSessionParams, type LoadSessionParams as ClientLoadSessionParams, type LoadSessionParams, type ClientSessionsResource, CloudAgentConnection, CloudAgentProvider, type CloudAgentProviderOptions, type CloudAgentSourceInfo, type CloudAgentState, type CloudAgentTarget, type CloudAgentVisibility, type CloudConnectionConfig, type CommodityCode, type ConnectionEvents, type DeployStatus, E2BFilesystem, type E2BSandboxConnectionInfo, type Edition, type EditionDisplayType, type EntryInfo, type FilesResource, type Filesystem, type FilesystemListOpts, type FilesystemProvider, type FilesystemRequestOpts, type IBackendProvider, IPCBackendProvider, type ListAgentFilter, type ListAgentOptions, type ListAgentSort, type Logger, type McpServerConfig, type ModelInfo, type PromptContentBlock, type PromptParams, type PromptsResource, type ReasoningConfig, type Session, type SessionAgentOperations, type SessionConnectionInfo, type SessionEventHandler, type SessionEvents, type SessionInfo, SessionManager, type SessionMode, type WatchOpts, type WriteEntry, createBackendProvider, createIPCBackendProvider, isCloudAgentState };
|
|
2866
3411
|
//# sourceMappingURL=index.d.cts.map
|