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