@tencent-ai/cloud-agent-sdk 0.2.12 → 0.2.13-next.00cf97b.20260317

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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AgentCapabilities as AgentCapabilities$1, ClientCapabilities, InitializeResponse, LoadSessionResponse, NewSessionResponse, PromptResponse as PromptResponse$1, RequestPermissionRequest, RequestPermissionRequest as RequestPermissionRequest$1, SessionNotification, SessionNotification as SessionNotification$1, SetSessionModeResponse, SetSessionModelResponse } from "@agentclientprotocol/sdk";
1
+ import { AgentCapabilities as AgentCapabilities$1, ClientCapabilities, InitializeResponse, LoadSessionResponse, NewSessionResponse, PromptResponse as PromptResponse$1, RequestPermissionRequest, RequestPermissionRequest as RequestPermissionRequest$1, SessionNotification, SessionNotification as SessionNotification$1, SetSessionModeResponse, SetSessionModelResponse, StopReason } from "@agentclientprotocol/sdk";
2
2
  import { EntryInfo, EntryInfo as EntryInfo$1, Filesystem, FilesystemEvent, FilesystemEvent as FilesystemEvent$1, Sandbox, WatchHandle, WriteInfo } from "e2b";
3
3
  import "zod";
4
4
 
@@ -235,6 +235,12 @@ interface CodebuddyClientMeta {
235
235
  artifacts?: ArtifactsConfig;
236
236
  /** Whether the client supports checkpoint notifications */
237
237
  checkpoint?: boolean;
238
+ /**
239
+ * Whether the client supports handling AskUserQuestion tool via extMethod.
240
+ * When true, AskUserQuestion requests will be sent to the client via
241
+ * the '_codebuddy.ai/question' extMethod instead of being handled locally.
242
+ */
243
+ question?: boolean;
238
244
  }
239
245
  /**
240
246
  * codebuddy.ai extension capabilities for Agent
@@ -339,12 +345,240 @@ interface ClientEvents extends Record<string, unknown> {
339
345
  */
340
346
  type QuestionAnswers = Record<string, string | string[]>;
341
347
  //#endregion
342
- //#region ../agent-provider/lib/backend/types.d.ts
348
+ //#region ../agent-provider/lib/backend/service/oauth-repository-types.d.ts
343
349
  /**
344
- * Backend Provider 类型定义
350
+ * OAuth Repository Types
345
351
  *
346
- * 定义 IBackendProvider 接口和配置
352
+ * 定义 OAuth 连接器相关的仓库和分支操作类型
353
+ */
354
+ /**
355
+ * Connector name type for OAuth providers
356
+ */
357
+ type OauthConnectorName$1 = 'github' | 'gongfeng' | 'cnb';
358
+ /**
359
+ * Branch information from OAuth connector
360
+ * GET /console/as/connector/oauth/{name}/branches
361
+ */
362
+ interface OauthBranch$1 {
363
+ /** Branch name */
364
+ name: string;
365
+ /** Whether the branch is protected */
366
+ protected: boolean;
367
+ /** Latest commit SHA */
368
+ commit_sha: string;
369
+ /** Latest commit URL */
370
+ commit_url: string;
371
+ }
372
+ /**
373
+ * GitHub 分支查询参数
374
+ */
375
+ interface GitHubBranchParams$1 {
376
+ /** Repository owner (e.g., "CodeBuddy-Official-Account") */
377
+ owner: string;
378
+ /** Repository name (e.g., "CodeBuddyIDE") */
379
+ repo: string;
380
+ }
381
+ /**
382
+ * Gongfeng 分支查询参数
383
+ */
384
+ interface GongfengBranchParams$1 {
385
+ /** Project ID (e.g., "1611499") */
386
+ project_id: string;
387
+ }
388
+ /**
389
+ * CNB 分支查询参数
390
+ */
391
+ interface CNBBranchParams$1 {
392
+ /** Repository path: org/repo (e.g., "genie/genie-ide") */
393
+ repo: string;
394
+ }
395
+ /**
396
+ * GitHub repository owner information
397
+ */
398
+ interface OauthGitHubRepoOwner {
399
+ /** Owner login name */
400
+ login: string;
401
+ /** Owner avatar URL */
402
+ avatar_url: string;
403
+ /** Owner API URL */
404
+ url: string;
405
+ /** Owner HTML URL */
406
+ html_url: string;
407
+ /** Owner followers URL */
408
+ followers_url: string;
409
+ /** Owner starred URL */
410
+ starred_url: string;
411
+ /** Owner repos URL */
412
+ repos_url: string;
413
+ /** Owner events URL */
414
+ events_url: string;
415
+ }
416
+ /**
417
+ * GitHub repository information
418
+ * From ListReposResponse.GitHubRepos
419
+ */
420
+ interface OauthGitHubRepo$1 {
421
+ /** Repository name */
422
+ name: string;
423
+ /** Full repository name (owner/repo) */
424
+ full_name: string;
425
+ /** Whether the repository is private */
426
+ private: boolean;
427
+ /** Repository HTML URL */
428
+ html_url: string;
429
+ /** Repository API URL */
430
+ url: string;
431
+ /** Repository teams URL */
432
+ teams_url: string;
433
+ /** Repository hooks URL */
434
+ hooks_url: string;
435
+ /** Repository events URL */
436
+ events_url: string;
437
+ /** Repository branches URL */
438
+ branches_url: string;
439
+ /** Repository git commits URL */
440
+ git_commits_url: string;
441
+ /** Repository merges URL */
442
+ merges_url: string;
443
+ /** Repository pulls URL */
444
+ pulls_url: string;
445
+ /** Repository git URL */
446
+ git_url: string;
447
+ /** Repository clone URL */
448
+ clone_url: string;
449
+ /** Repository SVN URL */
450
+ svn_url: string;
451
+ /** Repository downloads URL */
452
+ downloads_url: string;
453
+ /** Repository description */
454
+ description: string;
455
+ /** Repository owner */
456
+ owner: OauthGitHubRepoOwner;
457
+ /** Number of forks */
458
+ forks_count: number;
459
+ }
460
+ /**
461
+ * Gongfeng repository namespace information
462
+ */
463
+ interface OauthGongFengRepoNamespace {
464
+ /** Namespace name */
465
+ name: string;
466
+ /** Namespace description */
467
+ description: string;
468
+ /** Namespace path */
469
+ path: string;
470
+ }
471
+ /**
472
+ * Gongfeng repository owner information
473
+ */
474
+ interface OauthGongFengRepoOwner {
475
+ /** Owner username */
476
+ username: string;
477
+ /** Owner web URL */
478
+ web_url: string;
479
+ /** Owner name */
480
+ name: string;
481
+ /** Owner state */
482
+ state: string;
483
+ /** Owner avatar URL */
484
+ avatar_url: string;
485
+ }
486
+ /**
487
+ * Gongfeng (工蜂) repository information
488
+ * From ListReposResponse.GongFengRepos
489
+ */
490
+ interface OauthGongFengRepo$1 {
491
+ /** Repository ID */
492
+ id: number;
493
+ /** Repository description */
494
+ description: string;
495
+ /** Whether the repository is public */
496
+ public: boolean;
497
+ /** Whether the repository is archived */
498
+ archived: boolean;
499
+ /** Visibility level */
500
+ visibility_level: string;
501
+ /** Public visibility */
502
+ public_visibility: number;
503
+ /** Repository namespace */
504
+ namespace: OauthGongFengRepoNamespace;
505
+ /** Repository owner */
506
+ owner: OauthGongFengRepoOwner;
507
+ /** Repository name */
508
+ name: string;
509
+ /** Name with namespace */
510
+ name_with_namespace: string;
511
+ /** Repository path */
512
+ path: string;
513
+ /** Path with namespace */
514
+ path_with_namespace: string;
515
+ /** Repository type (Git/SVN) */
516
+ type: string;
517
+ /** Default branch */
518
+ default_branch: string;
519
+ /** SSH URL to repository */
520
+ ssh_url_to_repo: string;
521
+ /** HTTP URL to repository */
522
+ http_url_to_repo: string;
523
+ /** HTTPS URL to repository */
524
+ https_url_to_repo: string;
525
+ /** Web URL */
526
+ web_url: string;
527
+ /** Avatar URL */
528
+ avatar_url: string;
529
+ /** Forked from project */
530
+ forked_from_project: string;
531
+ }
532
+ /**
533
+ * CNB repository information
534
+ * From ListReposResponse.CNBRepos
535
+ */
536
+ interface OauthCNBRepo$1 {
537
+ /** Created timestamp */
538
+ created_at: string;
539
+ /** Repository description */
540
+ description: string;
541
+ /** Repository name */
542
+ name: string;
543
+ /** Repository path */
544
+ path: string;
545
+ /** Repository site */
546
+ site: string;
547
+ /** Repository status */
548
+ status: number;
549
+ /** Repository topics */
550
+ topics: string;
551
+ /** Visibility level */
552
+ visibility_level: string;
553
+ /** Web URL */
554
+ web_url: string;
555
+ }
556
+ /**
557
+ * Response for listing repositories
558
+ * GET /console/as/connector/oauth/{name}/repos
347
559
  */
560
+ interface ListReposResponse$1 {
561
+ /**
562
+ * GitHub repositories grouped by installation id
563
+ * Map: installation_id => repository list
564
+ */
565
+ github_repos?: Record<number, OauthGitHubRepo$1[]>;
566
+ /** Gongfeng repositories */
567
+ gongfeng_repos?: OauthGongFengRepo$1[];
568
+ /** CNB repositories */
569
+ cnb_repos?: OauthCNBRepo$1[];
570
+ }
571
+ //#endregion
572
+ //#region ../agent-provider/lib/backend/types.d.ts
573
+ type OauthConnectorName = OauthConnectorName$1;
574
+ type OauthBranch = OauthBranch$1;
575
+ type GitHubBranchParams = GitHubBranchParams$1;
576
+ type GongfengBranchParams = GongfengBranchParams$1;
577
+ type CNBBranchParams = CNBBranchParams$1;
578
+ type OauthGitHubRepo = OauthGitHubRepo$1;
579
+ type OauthGongFengRepo = OauthGongFengRepo$1;
580
+ type OauthCNBRepo = OauthCNBRepo$1;
581
+ type ListReposResponse = ListReposResponse$1;
348
582
  /**
349
583
  * 账号版本类型
350
584
  */
@@ -433,6 +667,13 @@ interface AccountPlan {
433
667
  /** 所有套餐资源列表 */
434
668
  resources?: PlanResource[];
435
669
  }
670
+ /**
671
+ * 账号类型
672
+ * - sso: SSO 登录账号
673
+ * - unified: 统一登录账号
674
+ * - 空字符串: 普通账号
675
+ */
676
+ type AccountType = 'sso' | 'unified' | '';
436
677
  /**
437
678
  * 账号信息
438
679
  */
@@ -459,6 +700,8 @@ interface Account {
459
700
  pluginEnabled?: boolean;
460
701
  /** 部署状态 */
461
702
  deployStatus?: DeployStatus;
703
+ /** 账号类型 */
704
+ accountType?: AccountType;
462
705
  /** 是否是 Pro 版本 */
463
706
  isPro?: boolean;
464
707
  /** 到期时间戳 */
@@ -517,6 +760,7 @@ interface UserConnector {
517
760
  oauthClientId: string;
518
761
  /** OAuth 重定向 URL */
519
762
  oauthRedirectUrl: string;
763
+ oauthAppName: string;
520
764
  }
521
765
  /**
522
766
  * 获取用户连接器列表响应
@@ -590,6 +834,7 @@ interface TaskConnector {
590
834
  connect_at: string;
591
835
  /** 连接状态,0未连接,1已连接 */
592
836
  connectStatus: 0 | 1;
837
+ oauthAppName: string;
593
838
  }
594
839
  /**
595
840
  * 添加任务请求
@@ -679,84 +924,6 @@ interface RevokeAllRequest {
679
924
  /** 安装ID列表(可选,如果不传则撤销所有) */
680
925
  installationIds?: string[];
681
926
  }
682
- /**
683
- * GitHub 仓库所有者信息
684
- */
685
- interface OauthGitHubRepoOwner {
686
- login: string;
687
- avatar_url: string;
688
- url: string;
689
- html_url: string;
690
- followers_url: string;
691
- starred_url: string;
692
- repos_url: string;
693
- events_url: string;
694
- }
695
- /**
696
- * GitHub 仓库信息
697
- */
698
- interface OauthGitHubRepo {
699
- name: string;
700
- full_name: string;
701
- private: boolean;
702
- html_url: string;
703
- url: string;
704
- teams_url: string;
705
- hooks_url: string;
706
- events_url: string;
707
- branches_url: string;
708
- git_commits_url: string;
709
- merges_url: string;
710
- pulls_url: string;
711
- git_url: string;
712
- clone_url: string;
713
- svn_url: string;
714
- downloads_url: string;
715
- description: string;
716
- owner: OauthGitHubRepoOwner;
717
- forks_count: number;
718
- }
719
- /**
720
- * 工蜂仓库信息
721
- */
722
- interface OauthGongfengRepo {
723
- id: number;
724
- description: string;
725
- public: boolean;
726
- archived: boolean;
727
- visibility_level: number;
728
- public_visibility: number;
729
- namespace: {
730
- name: string;
731
- description: string;
732
- path: string;
733
- };
734
- owner: {
735
- username: string;
736
- web_url: string;
737
- name: string;
738
- state: string;
739
- avatar_url: string;
740
- };
741
- name: string;
742
- name_with_namespace: string;
743
- path: string;
744
- path_with_namespace: string;
745
- type: string;
746
- default_branch: string;
747
- ssh_url_to_repo: string;
748
- http_url_to_repo: string;
749
- https_url_to_repo: string;
750
- web_url: string;
751
- avatar_url: string;
752
- }
753
- /**
754
- * CNB仓库信息
755
- */
756
- interface OauthCnbRepo {
757
- name: string;
758
- [key: string]: any;
759
- }
760
927
  /**
761
928
  * 获取仓库列表响应
762
929
  */
@@ -764,8 +931,8 @@ interface GetRepoListResponse {
764
931
  github_repos?: {
765
932
  [key: string | number]: OauthGitHubRepo[];
766
933
  };
767
- gongfeng_repos?: OauthGongfengRepo[];
768
- cnb_repos?: OauthCnbRepo[];
934
+ gongfeng_repos?: OauthGongFengRepo[];
935
+ cnb_repos?: OauthCNBRepo[];
769
936
  }
770
937
  /**
771
938
  * OAuth 用户信息
@@ -834,6 +1001,38 @@ interface BackendProviderConfig {
834
1001
  /** 认证 Token */
835
1002
  authToken?: string;
836
1003
  }
1004
+ /**
1005
+ * 签到状态响应
1006
+ */
1007
+ interface CheckinStatusResponse {
1008
+ /** 活动是否开启 */
1009
+ active: boolean;
1010
+ /** 今天是否已签到 */
1011
+ today_checked_in: boolean;
1012
+ /** 当前连续签到天数 */
1013
+ streak_days: number;
1014
+ /** 普通日签 credit 数量 */
1015
+ daily_credit: number;
1016
+ /** 今天签到可获得的 credit 数量 */
1017
+ today_credit: number;
1018
+ /** 今天是否是连续签到奖励日 */
1019
+ is_streak_day: boolean;
1020
+ /** 距离下一个连续签到奖励日还需签到天数(0 表示今天就是) */
1021
+ next_streak_day: number;
1022
+ /** 签到日期列表(yyyy-MM-dd 格式) */
1023
+ checkin_dates: string[];
1024
+ }
1025
+ /**
1026
+ * 签到结果响应
1027
+ */
1028
+ interface CheckinResultResponse {
1029
+ /** 本次签到实际获得的 credit */
1030
+ credit: number;
1031
+ /** 签到后的连续签到天数 */
1032
+ streak_days: number;
1033
+ /** 本次签到是否为连续签到奖励日 */
1034
+ is_streak_day: boolean;
1035
+ }
837
1036
  /**
838
1037
  * 企业用户用量信息
839
1038
  */
@@ -966,6 +1165,12 @@ interface IBackendProvider {
966
1165
  * 用于 Local 模式下点击 Logo 返回 IDE
967
1166
  */
968
1167
  closeAgentManager?(): Promise<void>;
1168
+ /**
1169
+ * 在外部浏览器中打开链接(可选,仅 IPC 环境支持)
1170
+ * 用于 Local 模式下打开外部 URL
1171
+ * @param url 要打开的 URL
1172
+ */
1173
+ openExternal?(url: string): Promise<void>;
969
1174
  /**
970
1175
  * 监听事件(可选,用于 IPC 环境)
971
1176
  * @param event 事件名称
@@ -978,6 +1183,66 @@ interface IBackendProvider {
978
1183
  * @returns Promise<EnterpriseUsage | null> 企业用户用量信息
979
1184
  */
980
1185
  getEnterpriseUsage?(enterpriseId: string): Promise<EnterpriseUsage | null>;
1186
+ /**
1187
+ * 获取账号用量信息(积分/Credits)
1188
+ * 实时获取,每次打开菜单时调用,不依赖 getAccount 缓存
1189
+ * @returns Promise<Partial<Account> | null> 包含 usageLeft, usageTotal, refreshAt 等字段
1190
+ */
1191
+ getAccountUsage?(): Promise<Partial<Account> | null>;
1192
+ /**
1193
+ * 获取每日签到状态
1194
+ * @returns Promise<CheckinStatusResponse | null> 签到状态,失败时返回 null
1195
+ */
1196
+ getCheckinStatus?(): Promise<CheckinStatusResponse | null>;
1197
+ /**
1198
+ * 执行每日签到
1199
+ * @returns Promise<CheckinResultResponse> 签到结果
1200
+ */
1201
+ claimDailyCheckin?(): Promise<CheckinResultResponse>;
1202
+ /**
1203
+ * 刷新 Token(可选)
1204
+ * 通过调用 getAccount 刷新 cookie
1205
+ * 适用于 Cloud 场景下页面切换回来时刷新登录态
1206
+ * @returns Promise<Account | null> 刷新后的账号信息
1207
+ */
1208
+ refreshToken?(): Promise<Account | null>;
1209
+ /**
1210
+ * 获取仓库分支列表
1211
+ * API 端点: GET /console/as/connector/oauth/{name}/branches
1212
+ *
1213
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
1214
+ * @param params 平台特定的查询参数
1215
+ * @param page 页码,从1开始,0表示不分页获取全部
1216
+ * @param perPage 每页数量,最大100
1217
+ * @returns Promise<OauthBranch[]> 分支列表
1218
+ */
1219
+ getBranches?(connector: OauthConnectorName, params: GitHubBranchParams | GongfengBranchParams | CNBBranchParams, page?: number, perPage?: number): Promise<OauthBranch[]>;
1220
+ /**
1221
+ * 获取仓库列表
1222
+ * API 端点: GET /console/as/connector/oauth/{name}/repos
1223
+ *
1224
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
1225
+ * @param page 页码,从1开始,0表示不分页获取全部
1226
+ * @param perPage 每页数量,最大100
1227
+ * @returns Promise<ListReposResponse> 仓库列表响应
1228
+ */
1229
+ getRepositories?(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
1230
+ /**
1231
+ * 保存待发送的输入内容到后端(用于跨域登录场景)
1232
+ * API 端点: POST /api/v1/code-id
1233
+ *
1234
+ * @param code 要保存的文本内容
1235
+ * @returns Promise<string | null> 返回 codeId,失败返回 null
1236
+ */
1237
+ savePendingInput?(code: string): Promise<string | null>;
1238
+ /**
1239
+ * 从后端加载待发送的输入内容(用于跨域登录场景)
1240
+ * API 端点: GET /api/v1/code?id=xxx
1241
+ *
1242
+ * @param codeId 内容 ID
1243
+ * @returns Promise<string | null> 返回保存的文本内容,失败返回 null
1244
+ */
1245
+ loadPendingInput?(codeId: string): Promise<string | null>;
981
1246
  }
982
1247
  /**
983
1248
  * 场景中的插件信息
@@ -991,6 +1256,12 @@ interface ScenePlugin {
991
1256
  /** 插件市场名称 */
992
1257
  marketplaceName: string;
993
1258
  }
1259
+ /**
1260
+ * 场景模式类型
1261
+ * - coding: 编程相关场景
1262
+ * - working: 工作/通用场景
1263
+ */
1264
+ type SupportSceneMode = 'coding' | 'working';
994
1265
  /**
995
1266
  * 支持的场景信息
996
1267
  * 用于 Welcome 页面的 QuickActions 快捷操作
@@ -1005,11 +1276,15 @@ interface SupportScene {
1005
1276
  plugins: ScenePlugin[];
1006
1277
  /** 场景对应的 prompt 列表 */
1007
1278
  prompts: string[];
1279
+ /** 场景模式类型 */
1280
+ mode?: SupportSceneMode;
1008
1281
  }
1009
1282
  /**
1010
1283
  * 插件作用域
1284
+ * 使用 agent-craft 的 PluginInstallScope 类型
1285
+ * 注意: 当前后端 API 只支持 user 和 project,暂不支持 project-local
1011
1286
  */
1012
- type PluginScope = 'user' | 'project';
1287
+ type PluginScope = 'user' | 'project' | 'project-local' | 'local';
1013
1288
  /**
1014
1289
  * 插件操作类型
1015
1290
  */
@@ -1315,7 +1590,7 @@ type PromptContentBlock = {
1315
1590
  uri: string;
1316
1591
  mimeType?: string | null;
1317
1592
  name: string;
1318
- size?: bigint | null;
1593
+ size?: number | null;
1319
1594
  title?: string | null;
1320
1595
  _meta?: {
1321
1596
  [key: string]: unknown;
@@ -1428,6 +1703,15 @@ interface AgentConnection {
1428
1703
  error?: string;
1429
1704
  }>;
1430
1705
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
1706
+ /**
1707
+ * Report telemetry event through the standard provider chain
1708
+ * - Local: via ACP JSON-RPC → IDE EventService
1709
+ * - Cloud: via StreamableHTTP → cloud telemetry endpoint
1710
+ *
1711
+ * @param eventName - Event name / code
1712
+ * @param payload - Event data (already includes mode)
1713
+ */
1714
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
1431
1715
  }
1432
1716
  /**
1433
1717
  * Base configuration for connections
@@ -1635,6 +1919,8 @@ interface BaseAgentState {
1635
1919
  updatedAt?: Date;
1636
1920
  /** 是否为 playground */
1637
1921
  isPlayground?: boolean;
1922
+ /** Whether the title is user defined (1 = user defined) */
1923
+ isUserDefinedTitle?: number;
1638
1924
  }
1639
1925
  /**
1640
1926
  * LocalAgentState - 本地 Agent 状态
@@ -1698,6 +1984,11 @@ interface ListAgentSort {
1698
1984
  * Local: Client-side filtering and sorting, no pagination (returns all)
1699
1985
  */
1700
1986
  interface ListAgentOptions {
1987
+ /**
1988
+ * User ID for filtering sessions (required for multi-user isolation)
1989
+ * If not provided, returns empty list for Local provider
1990
+ */
1991
+ userId?: string;
1701
1992
  /**
1702
1993
  * Page number (starts from 1)
1703
1994
  * Cloud: Used for API pagination
@@ -1781,16 +2072,38 @@ interface SessionInfo {
1781
2072
  cwd?: string;
1782
2073
  /** Whether the session is a playground */
1783
2074
  isPlayground?: boolean;
2075
+ /** Whether the title is user defined (1 = user defined) */
2076
+ isUserDefinedTitle?: number;
1784
2077
  }
1785
2078
  /**
1786
2079
  * Parameters for creating a new session
1787
2080
  */
1788
2081
  interface CreateSessionParams$1 {
1789
- /** Working directory */
2082
+ /** Working directory (required) */
1790
2083
  cwd: string;
2084
+ /** Optional configuration */
2085
+ options?: CreateSessionOptions;
2086
+ }
2087
+ /**
2088
+ * Optional configuration for creating a session
2089
+ */
2090
+ interface CreateSessionOptions {
1791
2091
  /** MCP server configurations */
1792
2092
  mcpServers?: McpServerConfig[];
2093
+ /** Initial prompt for the session (Cloud only) */
2094
+ prompt?: string;
2095
+ /** Initial model for the session (Cloud only) */
2096
+ model?: string;
2097
+ /** Mode ID (e.g., 'craft', 'architect') */
2098
+ mode?: string;
2099
+ /** Whether this is a playground session (no cwd) */
2100
+ isPlayground?: boolean;
2101
+ /** Tags for template scenes (Cloud only, format: { scene: 'xxx' }) */
2102
+ tags?: Record<string, string>;
2103
+ /** Additional metadata */
1793
2104
  _meta?: Record<string, unknown>;
2105
+ /** Callback when session is prepared (POST succeeded, before WebSocket connect) */
2106
+ onSessionPrepared?: (sessionInfo: SessionInfo) => void;
1794
2107
  }
1795
2108
  /**
1796
2109
  * Parameters for loading an existing session
@@ -1825,6 +2138,84 @@ interface InitializeWorkspaceResponse {
1825
2138
  /** Error message (if failed) */
1826
2139
  error?: string;
1827
2140
  }
2141
+ type AutomationStatus = 'ACTIVE' | 'PAUSED';
2142
+ type AutomationUpdateMode = 'view' | 'suggested create' | 'suggested update';
2143
+ type AutomationRunStatus = 'ACCEPTED' | 'ARCHIVED' | 'PENDING_REVIEW' | 'IN_PROGRESS';
2144
+ interface AutomationDefinition {
2145
+ version: number;
2146
+ id: string;
2147
+ name: string;
2148
+ prompt: string;
2149
+ status: AutomationStatus;
2150
+ rrule: string;
2151
+ cwds: string[];
2152
+ modelId?: string;
2153
+ modelIsThinking?: boolean;
2154
+ created_at: number;
2155
+ updated_at: number;
2156
+ }
2157
+ interface AutomationCwdRunResult {
2158
+ cwd: string;
2159
+ success: boolean;
2160
+ startedAt: number;
2161
+ finishedAt: number;
2162
+ conversationId?: string;
2163
+ output?: string;
2164
+ error?: string;
2165
+ }
2166
+ interface AutomationInboxItem {
2167
+ id: string;
2168
+ automationId: string;
2169
+ automationName: string;
2170
+ status?: AutomationRunStatus;
2171
+ readAt?: number;
2172
+ startedAt: number;
2173
+ finishedAt: number;
2174
+ success: boolean;
2175
+ summary: string;
2176
+ runs: AutomationCwdRunResult[];
2177
+ archived?: boolean;
2178
+ archivedAt?: number;
2179
+ }
2180
+ interface AutomationRuntimeState {
2181
+ lastRunAt?: number;
2182
+ lastError?: string;
2183
+ running?: boolean;
2184
+ runningStartedAt?: number;
2185
+ runningConversationId?: string;
2186
+ }
2187
+ interface AutomationSnapshot {
2188
+ automations: AutomationDefinition[];
2189
+ inbox: AutomationInboxItem[];
2190
+ runtimeState: Record<string, AutomationRuntimeState>;
2191
+ updatedAt: number;
2192
+ }
2193
+ interface AutomationUpdatePayload {
2194
+ mode: AutomationUpdateMode;
2195
+ id?: string;
2196
+ name?: string;
2197
+ prompt?: string;
2198
+ rrule?: string;
2199
+ cwds?: string[] | string;
2200
+ status?: AutomationStatus;
2201
+ modelId?: string;
2202
+ modelIsThinking?: boolean;
2203
+ }
2204
+ interface AutomationUpdateResult {
2205
+ success: boolean;
2206
+ message: string;
2207
+ automation?: AutomationDefinition;
2208
+ snapshot?: AutomationSnapshot;
2209
+ }
2210
+ /**
2211
+ * Parameters for getting available commands
2212
+ */
2213
+ interface GetAvailableCommandsParams {
2214
+ /** Session ID to get commands for (optional, for global commands) */
2215
+ sessionId?: string;
2216
+ /** Workspace path for getting custom commands (optional) */
2217
+ workspacePath?: string;
2218
+ }
1828
2219
  /**
1829
2220
  * Prompts resource interface (ACP verbs)
1830
2221
  * Operations use the current session automatically
@@ -1862,7 +2253,7 @@ interface ModelsResource {
1862
2253
  */
1863
2254
  interface PromptResponse {
1864
2255
  /** Stop reason */
1865
- stopReason: 'end_turn' | 'max_tokens' | 'tool_use' | 'cancelled' | 'error';
2256
+ stopReason: StopReason;
1866
2257
  /** Response metadata */
1867
2258
  _meta?: Record<string, unknown>;
1868
2259
  }
@@ -1872,7 +2263,7 @@ interface PromptResponse {
1872
2263
  interface SessionsResourceEvents {
1873
2264
  /** Emitted when the sessions list changes (create, delete, update) */
1874
2265
  sessionsChanged: SessionInfo[];
1875
- /** Emitted when a new session is created */
2266
+ /** Emitted when a new session is fully connected and ready */
1876
2267
  sessionCreated: SessionInfo;
1877
2268
  /** Emitted when a session is deleted */
1878
2269
  sessionDeleted: {
@@ -1880,6 +2271,12 @@ interface SessionsResourceEvents {
1880
2271
  };
1881
2272
  /** Emitted when a session is updated (status change, etc.) */
1882
2273
  sessionUpdated: SessionInfo;
2274
+ /** Emitted when automation snapshot is updated (pushed from server) */
2275
+ automationSnapshotUpdate: AutomationSnapshot;
2276
+ /** Emitted when plugins or marketplaces change (install/uninstall/add/remove/update) */
2277
+ pluginsChanged: {
2278
+ newMarketplaceName?: string;
2279
+ } | undefined;
1883
2280
  }
1884
2281
  /**
1885
2282
  * Event handler type for sessions resource events
@@ -1956,6 +2353,8 @@ interface ActiveSession {
1956
2353
  readonly id: string;
1957
2354
  /** Agent ID */
1958
2355
  readonly agentId: string;
2356
+ /** Actual workspace path (set after newSession, useful for Playground scenario) */
2357
+ readonly cwd?: string;
1959
2358
  /** Agent state (direct access to underlying agent state) */
1960
2359
  readonly agentState: AgentState;
1961
2360
  /** Agent capabilities (available after connection) */
@@ -1999,7 +2398,7 @@ interface ActiveSession {
1999
2398
  error?: string;
2000
2399
  }>;
2001
2400
  /** Set the current session mode */
2002
- setMode(modeId: string): Promise<void>;
2401
+ setMode(modeId: string, skipChecker?: boolean): Promise<void>;
2003
2402
  /** Set the current session model */
2004
2403
  setSessionModel(modelId: string): Promise<void>;
2005
2404
  /** Set available commands (called when available_commands_update is received) */
@@ -2016,6 +2415,12 @@ interface ActiveSession {
2016
2415
  once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
2017
2416
  /** Disconnect from the session/agent */
2018
2417
  disconnect(): void;
2418
+ /**
2419
+ * Detach the session from connection events without disconnecting the connection.
2420
+ * This should be called when the session is being replaced but the connection is shared.
2421
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
2422
+ */
2423
+ detach(): void;
2019
2424
  /** Symbol.dispose for 'using' keyword support */
2020
2425
  [Symbol.dispose](): void;
2021
2426
  }
@@ -2080,6 +2485,17 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2080
2485
  rename?(agentId: string, title: string): Promise<{
2081
2486
  id: string;
2082
2487
  }>;
2488
+ /**
2489
+ * Update agent status by ID (optional)
2490
+ * Used by CloudAgentProvider for updating session status
2491
+ *
2492
+ * @param agentId - Agent ID to update
2493
+ * @param status - New status for the agent
2494
+ * @returns Object containing the updated agent ID
2495
+ */
2496
+ updateStatus?(agentId: string, status: string): Promise<{
2497
+ id: string;
2498
+ }>;
2083
2499
  /**
2084
2500
  * Move an agent by ID (optional)
2085
2501
  * Used by LocalAgentProvider for moving Playground sessions to Workspace
@@ -2099,6 +2515,31 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2099
2515
  * @returns Array of model information
2100
2516
  */
2101
2517
  getModels?(repo?: string): Promise<ModelInfo[]>;
2518
+ /**
2519
+ * Get product configuration subset (optional)
2520
+ * Returns deploymentType, creditPurchaseActions, links, networkEnvironment, productFeatures
2521
+ */
2522
+ getProductConfiguration?(): Promise<{
2523
+ deploymentType?: string;
2524
+ creditPurchaseActions?: Record<string, {
2525
+ labelZh: string;
2526
+ labelEn: string;
2527
+ url: string;
2528
+ showButton?: boolean;
2529
+ }>;
2530
+ links?: {
2531
+ craftFeedback?: string;
2532
+ };
2533
+ networkEnvironment?: string;
2534
+ productFeatures?: Record<string, boolean>;
2535
+ }>;
2536
+ /**
2537
+ * Get user info (optional)
2538
+ * Returns enterpriseId from authentication session
2539
+ */
2540
+ getUserInfo?(): Promise<{
2541
+ enterpriseId?: string;
2542
+ }>;
2102
2543
  /**
2103
2544
  * Register sessionId → agentId mapping (optional, used by LocalAgentProvider)
2104
2545
  * Called after session creation to maintain the mapping for loadSession
@@ -2143,38 +2584,137 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2143
2584
  */
2144
2585
  searchFile?(params: SearchFileParams): Promise<SearchFileResponse>;
2145
2586
  /**
2146
- * Batch toggle plugins (optional, used by LocalAgentProvider)
2587
+ * Get subagent list (optional, used by LocalAgentProvider)
2147
2588
  *
2148
- * @param request - Batch plugin operation request
2149
- * @returns Batch operation result
2589
+ * @param params - Query parameters including options
2590
+ * @returns Response with subagent list
2150
2591
  */
2151
- batchTogglePlugins?(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2592
+ getSubagentList?(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2152
2593
  /**
2153
- * Get installed plugins (optional, used by LocalAgentProvider)
2594
+ * Get skill list (optional, used by LocalAgentProvider)
2154
2595
  *
2155
- * @param forceRefresh - Whether to force refresh the cache
2156
- * @returns Array of installed plugins
2596
+ * @param params - Query parameters
2597
+ * @returns Response with skill list
2157
2598
  */
2158
- getInstalledPlugins?(forceRefresh?: boolean): Promise<Array<{
2159
- name: string;
2160
- marketplaceName: string;
2161
- status: string;
2162
- description?: string;
2163
- version?: string;
2164
- installScope?: 'user' | 'project';
2165
- }>>;
2599
+ getSkillList?(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2166
2600
  /**
2167
- * Install plugins (optional, used by LocalAgentProvider)
2601
+ * Import a skill folder (optional, used by LocalAgentProvider)
2168
2602
  *
2169
- * @param pluginNames - Array of plugin names to install
2170
- * @param marketplaceName - Marketplace name
2171
- * @param installScope - Install scope ('user' | 'project')
2172
- * @returns Result of the operation
2603
+ * @param params - Import parameters including source location
2604
+ * @returns Response with import result
2173
2605
  */
2174
- installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2175
- success: boolean;
2176
- error?: string;
2606
+ importSkill?(params: ImportSkillParams): Promise<ImportSkillResponse>;
2607
+ /**
2608
+ * Get skill content by file path (optional, used by LocalAgentProvider)
2609
+ *
2610
+ * @param params - Parameters including skill file path
2611
+ * @returns Response with skill content
2612
+ */
2613
+ getSkillContent?(params: GetSkillContentParams): Promise<GetSkillContentResponse>;
2614
+ /**
2615
+ * Get marketplace skills list (optional, used by LocalAgentProvider)
2616
+ *
2617
+ * @returns Response with marketplace skill list
2618
+ */
2619
+ getMarketplaceSkills?(): Promise<GetMarketplaceSkillsResponse>;
2620
+ /**
2621
+ * Get marketplace skill content (optional, used by LocalAgentProvider)
2622
+ *
2623
+ * @param params - Parameters including skill name
2624
+ * @returns Response with skill content
2625
+ */
2626
+ getMarketplaceSkillContent?(params: GetMarketplaceSkillContentParams): Promise<GetMarketplaceSkillContentResponse>;
2627
+ /**
2628
+ * Install marketplace skill to user directory (optional, used by LocalAgentProvider)
2629
+ *
2630
+ * @param params - Parameters including skill name
2631
+ * @returns Response with install result
2632
+ */
2633
+ installMarketplaceSkill?(params: InstallMarketplaceSkillParams): Promise<InstallMarketplaceSkillResponse>;
2634
+ /**
2635
+ * Toggle skill enable/disable state (optional, used by LocalAgentProvider)
2636
+ *
2637
+ * @param params - Toggle parameters including filePath and disable state
2638
+ * @returns Response with toggle result
2639
+ */
2640
+ toggleSkill?(params: ToggleSkillParams): Promise<ToggleSkillResponse>;
2641
+ /**
2642
+ * Delete a skill (optional, used by LocalAgentProvider)
2643
+ *
2644
+ * @param params - Delete parameters including filePath and name
2645
+ * @returns Response with delete result
2646
+ */
2647
+ deleteSkill?(params: DeleteSkillParams): Promise<DeleteSkillResponse>;
2648
+ /**
2649
+ * Batch toggle plugins (optional, used by LocalAgentProvider)
2650
+ *
2651
+ * @param request - Batch plugin operation request
2652
+ * @returns Batch operation result
2653
+ */
2654
+ batchTogglePlugins?(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2655
+ /**
2656
+ * Get installed plugins (optional, used by LocalAgentProvider)
2657
+ *
2658
+ * @param forceRefresh - Whether to force refresh the cache
2659
+ * @returns Array of installed plugins
2660
+ */
2661
+ getInstalledPlugins?(forceRefresh?: boolean): Promise<Array<{
2662
+ name: string;
2663
+ marketplaceName: string;
2664
+ status: string;
2665
+ description?: string;
2666
+ version?: string;
2667
+ installScope?: 'user' | 'project';
2668
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
2669
+ installedScopesStatus?: Record<string, boolean>;
2670
+ installId?: string;
2671
+ }>>;
2672
+ /**
2673
+ * Install plugins (optional, used by LocalAgentProvider)
2674
+ *
2675
+ * @param pluginNames - Array of plugin names to install
2676
+ * @param marketplaceName - Marketplace name
2677
+ * @param installScope - Install scope ('user' | 'project')
2678
+ * @param marketplaceSource - Marketplace source URL (for auto-adding marketplace when not exists)
2679
+ * @returns Result of the operation
2680
+ */
2681
+ installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2682
+ success: boolean;
2683
+ error?: string;
2177
2684
  }>;
2685
+ /**
2686
+ * Get available commands for a session (optional, used by LocalAgentProvider)
2687
+ * If session.availableCommands has cached values, return them
2688
+ * Otherwise, fetch from product configuration
2689
+ *
2690
+ * @param params - Parameters for getting commands
2691
+ * @returns Array of available commands
2692
+ */
2693
+ getAvailableCommands?(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2694
+ /**
2695
+ * Get automation snapshot (optional, used by LocalAgentProvider)
2696
+ */
2697
+ getAutomationSnapshot?(): Promise<AutomationSnapshot>;
2698
+ /**
2699
+ * Create/update automation definition (optional, used by LocalAgentProvider)
2700
+ */
2701
+ updateAutomation?(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
2702
+ /**
2703
+ * Delete automation definition (optional, used by LocalAgentProvider)
2704
+ */
2705
+ deleteAutomation?(id: string): Promise<AutomationUpdateResult>;
2706
+ /**
2707
+ * Archive an automation inbox item (optional, used by LocalAgentProvider)
2708
+ */
2709
+ archiveAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
2710
+ /**
2711
+ * Delete an automation inbox item (optional, used by LocalAgentProvider)
2712
+ */
2713
+ deleteAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
2714
+ /**
2715
+ * Trigger test run for automation (optional, used by LocalAgentProvider)
2716
+ */
2717
+ testAutomation?(id: string): Promise<AutomationUpdateResult>;
2178
2718
  /**
2179
2719
  * Register an event listener
2180
2720
  * Provider implementations should forward events to the underlying transport
@@ -2190,6 +2730,131 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2190
2730
  * @param handler - Event handler function to remove
2191
2731
  */
2192
2732
  off?(event: string, handler: (...args: any[]) => void): void;
2733
+ /**
2734
+ * Report telemetry event through the provider chain
2735
+ * - Local: via ACP JSON-RPC → AcpAgent → IDE EventService
2736
+ * - Cloud: via connection → cloud endpoint
2737
+ *
2738
+ * @param eventName - Event name / code
2739
+ * @param payload - Event data
2740
+ */
2741
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2742
+ /**
2743
+ * Respond to MCP Sampling confirmation request (optional, used by LocalAgentProvider)
2744
+ * Called when user confirms/rejects a sampling request
2745
+ *
2746
+ * @param sessionId - Session ID
2747
+ * @param response - Sampling confirmation response
2748
+ */
2749
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2750
+ /**
2751
+ * Respond to MCP Roots confirmation request (optional, used by LocalAgentProvider)
2752
+ * Called when user confirms/rejects a roots request
2753
+ *
2754
+ * @param sessionId - Session ID
2755
+ * @param response - Roots confirmation response
2756
+ */
2757
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2758
+ /**
2759
+ * Subscribe to MCP Sampling confirmation requests (optional, used by LocalAgentProvider)
2760
+ * Called when MCP server initiates a sampling request
2761
+ *
2762
+ * @param serverName - MCP server name
2763
+ * @param callback - Request callback
2764
+ * @returns Unsubscribe function
2765
+ */
2766
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
2767
+ /**
2768
+ * Subscribe to MCP Roots confirmation requests (optional, used by LocalAgentProvider)
2769
+ * Called when MCP server initiates a roots request
2770
+ *
2771
+ * @param serverName - MCP server name
2772
+ * @param callback - Request callback
2773
+ * @returns Unsubscribe function
2774
+ */
2775
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
2776
+ /**
2777
+ * Get product scenes from ProductManager configuration (optional, for LocalAgentProvider)
2778
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
2779
+ * @param locale - 可选,语言环境
2780
+ */
2781
+ getProductScenes?(locale?: string): Promise<Array<{
2782
+ id: number;
2783
+ name: string;
2784
+ plugins: Array<{
2785
+ id: number;
2786
+ name: string;
2787
+ marketplaceName: string;
2788
+ }>;
2789
+ prompts: string[];
2790
+ mode?: 'coding' | 'working';
2791
+ target?: 'local' | 'cloud' | 'all';
2792
+ }>>;
2793
+ /**
2794
+ * Get all MCP servers with their status and tools (optional, used by LocalAgentProvider)
2795
+ * Returns the list of configured MCP servers from McpServerManager
2796
+ *
2797
+ * @returns Array of MCP server information
2798
+ */
2799
+ getMcpServers?(): Promise<Array<{
2800
+ id: string;
2801
+ name: string;
2802
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
2803
+ description?: string;
2804
+ tools?: Array<{
2805
+ name: string;
2806
+ description?: string;
2807
+ enabled?: boolean;
2808
+ }>;
2809
+ disabled?: boolean;
2810
+ error?: string;
2811
+ logoUrl?: string;
2812
+ officialUrl?: string;
2813
+ configSource?: 'user' | 'project' | 'plugin';
2814
+ }>>;
2815
+ /**
2816
+ * Toggle MCP server enabled/disabled state (optional, used by LocalAgentProvider)
2817
+ *
2818
+ * @param serverName - Name of the MCP server to toggle
2819
+ * @param enabled - Whether to enable (true) or disable (false) the server
2820
+ */
2821
+ toggleMcpServer?(serverName: string, enabled: boolean): Promise<void>;
2822
+ /**
2823
+ * Reconnect to an MCP server (optional, used by LocalAgentProvider)
2824
+ *
2825
+ * @param serverName - Name of the MCP server to reconnect
2826
+ * @param forceHttpCallback - Force using HTTP callback instead of URL scheme
2827
+ */
2828
+ reconnectMcpServer?(serverName: string, forceHttpCallback?: boolean): Promise<void>;
2829
+ /**
2830
+ * Delete an MCP server configuration (optional, used by LocalAgentProvider)
2831
+ *
2832
+ * @param serverName - Name of the MCP server to delete
2833
+ */
2834
+ deleteMcpServer?(serverName: string): Promise<void>;
2835
+ /**
2836
+ * Open the MCP configuration file in editor (optional, used by LocalAgentProvider)
2837
+ * Executes 'codebuddy.openMcpConfig' command
2838
+ */
2839
+ openMcpConfig?(): Promise<void>;
2840
+ /**
2841
+ * Get MCP configuration file content
2842
+ * @returns File path and content
2843
+ */
2844
+ getMcpConfigContent?(): Promise<{
2845
+ filePath: string;
2846
+ content: string;
2847
+ }>;
2848
+ /**
2849
+ * Save MCP configuration file content
2850
+ * @param content New configuration content
2851
+ */
2852
+ saveMcpConfigContent?(content: string): Promise<void>;
2853
+ /**
2854
+ * Read text from clipboard (optional, used by LocalAgentProvider for webview clipboard access)
2855
+ * @returns Clipboard text content
2856
+ */
2857
+ clipboardReadText?(): Promise<string>;
2193
2858
  }
2194
2859
  /**
2195
2860
  * AgentClient initialization options
@@ -2247,6 +2912,15 @@ interface ClientSessionsResource {
2247
2912
  rename(sessionId: string, title: string): Promise<{
2248
2913
  id: string;
2249
2914
  }>;
2915
+ /**
2916
+ * Update session status
2917
+ * @param sessionId - Session ID to update
2918
+ * @param status - New status for the session
2919
+ * @returns Object containing the updated session ID
2920
+ */
2921
+ updateStatus(sessionId: string, status: string): Promise<{
2922
+ id: string;
2923
+ }>;
2250
2924
  /**
2251
2925
  * Move a session (Playground → Workspace)
2252
2926
  * @param sessionId - Session ID to move
@@ -2277,6 +2951,24 @@ interface ClientSessionsResource {
2277
2951
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
2278
2952
  /** Search for files in the workspace (for LocalAgentProvider) */
2279
2953
  searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
2954
+ /** Get subagent list (for LocalAgentProvider) */
2955
+ getSubagentList(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2956
+ /** Get skill list (for LocalAgentProvider) */
2957
+ getSkillList(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2958
+ /** Import a skill folder (for LocalAgentProvider) */
2959
+ importSkill(params: ImportSkillParams): Promise<ImportSkillResponse>;
2960
+ /** Toggle skill enable/disable state (for LocalAgentProvider) */
2961
+ toggleSkill(params: ToggleSkillParams): Promise<ToggleSkillResponse>;
2962
+ /** Delete a skill (for LocalAgentProvider) */
2963
+ deleteSkill(params: DeleteSkillParams): Promise<DeleteSkillResponse>;
2964
+ /** Get skill content by file path (for LocalAgentProvider) */
2965
+ getSkillContent(params: GetSkillContentParams): Promise<GetSkillContentResponse>;
2966
+ /** Get marketplace skills list (for LocalAgentProvider) */
2967
+ getMarketplaceSkills(): Promise<GetMarketplaceSkillsResponse>;
2968
+ /** Get marketplace skill content (for LocalAgentProvider) */
2969
+ getMarketplaceSkillContent(params: GetMarketplaceSkillContentParams): Promise<GetMarketplaceSkillContentResponse>;
2970
+ /** Install marketplace skill to user directory (for LocalAgentProvider) */
2971
+ installMarketplaceSkill(params: InstallMarketplaceSkillParams): Promise<InstallMarketplaceSkillResponse>;
2280
2972
  /** Batch toggle plugins (for LocalAgentProvider) */
2281
2973
  batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2282
2974
  /** Get installed plugins (for LocalAgentProvider) */
@@ -2287,17 +2979,138 @@ interface ClientSessionsResource {
2287
2979
  description?: string;
2288
2980
  version?: string;
2289
2981
  installScope?: 'user' | 'project';
2982
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
2983
+ installedScopesStatus?: Record<string, boolean>;
2984
+ installId?: string;
2290
2985
  }>>;
2291
2986
  /** Install plugins (for LocalAgentProvider) */
2292
- installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2987
+ installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2988
+ success: boolean;
2989
+ error?: string;
2990
+ }>;
2991
+ /** Uninstall a plugin (for LocalAgentProvider) */
2992
+ uninstallPlugin?(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
2993
+ success: boolean;
2994
+ error?: string;
2995
+ }>;
2996
+ /** Update a plugin to the latest version (for LocalAgentProvider) */
2997
+ updatePlugin?(pluginName: string, marketplaceName: string): Promise<{
2998
+ success: boolean;
2999
+ error?: string;
3000
+ }>;
3001
+ /** Get plugin marketplaces list (for LocalAgentProvider) */
3002
+ getPluginMarketplaces?(forceRefresh?: boolean): Promise<Array<{
3003
+ id: string;
3004
+ name: string;
3005
+ type: 'github' | 'local' | 'custom';
3006
+ source: {
3007
+ repo?: string;
3008
+ ref?: string;
3009
+ url?: string;
3010
+ };
3011
+ description?: string;
3012
+ isBuiltin?: boolean;
3013
+ }>>;
3014
+ /** Get plugins from a marketplace (for LocalAgentProvider) */
3015
+ getMarketplacePlugins?(marketplaceName: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
3016
+ name: string;
3017
+ marketplaceName: string;
3018
+ description?: string;
3019
+ version?: string;
3020
+ author?: string;
3021
+ homepage?: string;
3022
+ iconUrl?: string;
3023
+ tags?: string[];
3024
+ installed?: boolean;
3025
+ status?: 'enabled' | 'disabled' | 'not-installed';
3026
+ installedScopes?: Array<'user' | 'project'>;
3027
+ hasUpdate?: boolean;
3028
+ }>>;
3029
+ /** Get plugin detail (for LocalAgentProvider) */
3030
+ getPluginDetail?(pluginName: string, marketplaceName: string): Promise<{
3031
+ name: string;
3032
+ marketplaceName: string;
3033
+ description?: string;
3034
+ version?: string;
3035
+ author?: string;
3036
+ homepage?: string;
3037
+ readme?: string;
3038
+ tools?: Array<{
3039
+ name: string;
3040
+ description?: string;
3041
+ }>;
3042
+ resources?: Array<{
3043
+ name: string;
3044
+ description?: string;
3045
+ }>;
3046
+ prompts?: Array<{
3047
+ name: string;
3048
+ description?: string;
3049
+ }>;
3050
+ installed?: boolean;
3051
+ status?: 'enabled' | 'disabled' | 'not-installed';
3052
+ } | null>;
3053
+ /** Add a plugin marketplace (for LocalAgentProvider) */
3054
+ addPluginMarketplace?(source: string, name?: string): Promise<{
3055
+ success: boolean;
3056
+ error?: string;
3057
+ marketplace?: {
3058
+ id: string;
3059
+ name: string;
3060
+ type: 'github' | 'local' | 'custom';
3061
+ source: {
3062
+ repo?: string;
3063
+ ref?: string;
3064
+ url?: string;
3065
+ };
3066
+ description?: string;
3067
+ isBuiltin?: boolean;
3068
+ };
3069
+ }>;
3070
+ /** Remove a plugin marketplace (for LocalAgentProvider) */
3071
+ removePluginMarketplace?(marketplaceName: string): Promise<{
3072
+ success: boolean;
3073
+ error?: string;
3074
+ }>;
3075
+ /** Refresh a plugin marketplace (for LocalAgentProvider) */
3076
+ refreshPluginMarketplace?(marketplaceName: string): Promise<{
2293
3077
  success: boolean;
2294
3078
  error?: string;
3079
+ plugins?: Array<{
3080
+ name: string;
3081
+ marketplaceName: string;
3082
+ description?: string;
3083
+ version?: string;
3084
+ installed?: boolean;
3085
+ status?: 'enabled' | 'disabled' | 'not-installed';
3086
+ }>;
2295
3087
  }>;
3088
+ /** Open folder in new window (for LocalAgentProvider) */
3089
+ openFolderInNewWindow?(folderPath: string): Promise<void>;
3090
+ /** Open folder in system file manager (for LocalAgentProvider) */
3091
+ openFolder?(folderPath: string): Promise<boolean>;
2296
3092
  /**
2297
3093
  * Get support scenes from backend API (for LocalAgentProvider)
2298
3094
  * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
3095
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
3096
+ */
3097
+ getSupportScenes(locale?: string): Promise<Array<{
3098
+ id: number;
3099
+ name: string;
3100
+ plugins: Array<{
3101
+ id: number;
3102
+ name: string;
3103
+ marketplaceName: string;
3104
+ }>;
3105
+ prompts: string[];
3106
+ mode?: 'coding' | 'working';
3107
+ }>>;
3108
+ /**
3109
+ * Get product scenes from ProductManager configuration (for LocalAgentProvider)
3110
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
3111
+ * @param locale - 可选,语言环境
2299
3112
  */
2300
- getSupportScenes(): Promise<Array<{
3113
+ getProductScenes?(locale?: string): Promise<Array<{
2301
3114
  id: number;
2302
3115
  name: string;
2303
3116
  plugins: Array<{
@@ -2306,7 +3119,245 @@ interface ClientSessionsResource {
2306
3119
  marketplaceName: string;
2307
3120
  }>;
2308
3121
  prompts: string[];
3122
+ mode?: 'coding' | 'working';
3123
+ target?: 'local' | 'cloud' | 'all';
2309
3124
  }>>;
3125
+ /**
3126
+ * Get available commands for a session
3127
+ * If session.availableCommands has cached values, return them
3128
+ * Otherwise, fetch from provider (for LocalAgentProvider)
3129
+ * @param params - Parameters for getting commands
3130
+ * @returns Promise<AvailableCommand[]> - Array of available commands
3131
+ */
3132
+ getAvailableCommands(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
3133
+ /**
3134
+ * Get automation snapshot
3135
+ */
3136
+ getAutomationSnapshot(): Promise<AutomationSnapshot>;
3137
+ /**
3138
+ * Create/update automation definition
3139
+ */
3140
+ updateAutomation(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
3141
+ /**
3142
+ * Delete automation definition
3143
+ */
3144
+ deleteAutomation(id: string): Promise<AutomationUpdateResult>;
3145
+ /**
3146
+ * Archive automation inbox item
3147
+ */
3148
+ archiveAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
3149
+ /**
3150
+ * Delete automation inbox item
3151
+ */
3152
+ deleteAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
3153
+ /**
3154
+ * Trigger automation test run
3155
+ */
3156
+ testAutomation(id: string): Promise<AutomationUpdateResult>;
3157
+ /**
3158
+ * Report telemetry event through the provider chain
3159
+ * Delegates to AgentProvider.reportTelemetry()
3160
+ *
3161
+ * @param eventName - Event name / code
3162
+ * @param payload - Event data
3163
+ */
3164
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
3165
+ /**
3166
+ * Get product configuration subset
3167
+ * Returns deploymentType, creditPurchaseActions, links, productFeatures
3168
+ * Used by agent-ui for error banner credit purchase guidance
3169
+ */
3170
+ getProductConfiguration?(): Promise<{
3171
+ deploymentType?: string;
3172
+ creditPurchaseActions?: Record<string, {
3173
+ labelZh: string;
3174
+ labelEn: string;
3175
+ url: string;
3176
+ showButton?: boolean;
3177
+ }>;
3178
+ links?: {
3179
+ craftFeedback?: string;
3180
+ };
3181
+ networkEnvironment?: string;
3182
+ productFeatures?: Record<string, boolean>;
3183
+ }>;
3184
+ /**
3185
+ * Get user info
3186
+ * Returns enterpriseId from authentication session
3187
+ * Used by agent-ui for determining personal/enterprise user
3188
+ */
3189
+ getUserInfo?(): Promise<{
3190
+ enterpriseId?: string;
3191
+ }>;
3192
+ /**
3193
+ * Respond to MCP Sampling confirmation request
3194
+ * Called when user confirms/rejects a sampling request in MCP tool renderer
3195
+ *
3196
+ * @param sessionId - Session ID
3197
+ * @param response - Sampling confirmation response
3198
+ */
3199
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
3200
+ /**
3201
+ * Respond to MCP Roots confirmation request
3202
+ * Called when user confirms/rejects a roots request in MCP tool renderer
3203
+ *
3204
+ * @param sessionId - Session ID
3205
+ * @param response - Roots confirmation response
3206
+ */
3207
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
3208
+ /**
3209
+ * Subscribe to MCP Sampling confirmation requests
3210
+ * Called when MCP server initiates a sampling request
3211
+ *
3212
+ * @param serverName - MCP server name
3213
+ * @param callback - Request callback
3214
+ * @returns Unsubscribe function
3215
+ */
3216
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
3217
+ /**
3218
+ * Subscribe to MCP Roots confirmation requests
3219
+ * Called when MCP server initiates a roots request
3220
+ *
3221
+ * @param serverName - MCP server name
3222
+ * @param callback - Request callback
3223
+ * @returns Unsubscribe function
3224
+ */
3225
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
3226
+ /**
3227
+ * Get MCP servers list
3228
+ * Returns the list of configured MCP servers with their status
3229
+ *
3230
+ * @returns Promise<McpServerInfo[]> - Array of MCP server info
3231
+ */
3232
+ getMcpServers?(): Promise<McpServerInfo[]>;
3233
+ /**
3234
+ * Toggle MCP server enabled/disabled state
3235
+ *
3236
+ * @param serverName - Server name
3237
+ * @param enabled - Whether to enable the server
3238
+ */
3239
+ toggleMcpServer?(serverName: string, enabled: boolean): Promise<void>;
3240
+ /**
3241
+ * Reconnect to an MCP server
3242
+ *
3243
+ * @param serverName - Server name
3244
+ * @param forceHttpCallback - Force using HTTP callback instead of URL scheme
3245
+ */
3246
+ reconnectMcpServer?(serverName: string, forceHttpCallback?: boolean): Promise<void>;
3247
+ /**
3248
+ * Delete an MCP server configuration
3249
+ *
3250
+ * @param serverName - Server name
3251
+ */
3252
+ deleteMcpServer?(serverName: string): Promise<void>;
3253
+ /**
3254
+ * Open MCP configuration file in editor
3255
+ */
3256
+ openMcpConfig?(): Promise<void>;
3257
+ /**
3258
+ * Get MCP configuration file content
3259
+ * @returns File path and content
3260
+ */
3261
+ getMcpConfigContent?(): Promise<{
3262
+ filePath: string;
3263
+ content: string;
3264
+ }>;
3265
+ /**
3266
+ * Save MCP configuration file content
3267
+ * @param content New configuration content
3268
+ */
3269
+ saveMcpConfigContent?(content: string): Promise<void>;
3270
+ /**
3271
+ * Read text from clipboard (optional, used by LocalAgentProvider for webview clipboard access)
3272
+ * @returns Clipboard text content
3273
+ */
3274
+ clipboardReadText?(): Promise<string>;
3275
+ }
3276
+ /**
3277
+ * MCP Sampling message role
3278
+ */
3279
+ type McpSamplingRole = 'user' | 'assistant';
3280
+ /**
3281
+ * MCP Sampling message content - text
3282
+ */
3283
+ interface McpSamplingTextContent {
3284
+ type: 'text';
3285
+ text: string;
3286
+ }
3287
+ /**
3288
+ * MCP Sampling message content - image
3289
+ */
3290
+ interface McpSamplingImageContent {
3291
+ type: 'image';
3292
+ data: string;
3293
+ mimeType: string;
3294
+ }
3295
+ /**
3296
+ * MCP Sampling message content - audio
3297
+ */
3298
+ interface McpSamplingAudioContent {
3299
+ type: 'audio';
3300
+ data: string;
3301
+ mimeType: string;
3302
+ }
3303
+ /**
3304
+ * MCP Sampling message content union type
3305
+ */
3306
+ type McpSamplingContent = McpSamplingTextContent | McpSamplingImageContent | McpSamplingAudioContent;
3307
+ /**
3308
+ * MCP Sampling message
3309
+ */
3310
+ interface McpSamplingMessage {
3311
+ role: McpSamplingRole;
3312
+ content: McpSamplingContent;
3313
+ }
3314
+ /**
3315
+ * MCP Sampling confirmation request
3316
+ * Sent from backend when MCP server requests sampling
3317
+ */
3318
+ interface McpSamplingConfirmRequest {
3319
+ id: string;
3320
+ serverName: string;
3321
+ model?: string;
3322
+ messages: McpSamplingMessage[];
3323
+ systemPrompt?: string;
3324
+ maxTokens: number;
3325
+ timestamp: number;
3326
+ }
3327
+ /**
3328
+ * MCP Sampling confirmation response
3329
+ * Sent from frontend when user confirms/rejects
3330
+ */
3331
+ interface McpSamplingConfirmResponse {
3332
+ id: string;
3333
+ approved: boolean;
3334
+ rememberChoice?: boolean;
3335
+ }
3336
+ /**
3337
+ * MCP Root definition
3338
+ */
3339
+ interface McpRoot {
3340
+ uri: string;
3341
+ name?: string;
3342
+ }
3343
+ /**
3344
+ * MCP Roots confirmation request
3345
+ * Sent from backend when MCP server requests roots access
3346
+ */
3347
+ interface McpRootsConfirmRequest {
3348
+ id: string;
3349
+ serverName: string;
3350
+ roots: McpRoot[];
3351
+ timestamp: number;
3352
+ }
3353
+ /**
3354
+ * MCP Roots confirmation response
3355
+ * Sent from frontend when user confirms/rejects
3356
+ */
3357
+ interface McpRootsConfirmResponse {
3358
+ id: string;
3359
+ approved: boolean;
3360
+ rememberChoice?: boolean;
2310
3361
  }
2311
3362
  /**
2312
3363
  * Workspace information (aligned with FolderSelectResult)
@@ -2338,102 +3389,369 @@ interface PickFileParams {
2338
3389
  readonly canSelectMany?: boolean;
2339
3390
  }
2340
3391
  /**
2341
- * Response from picking files
3392
+ * Response from picking files
3393
+ */
3394
+ interface PickFileResponse {
3395
+ /** Selected files - File objects in browser, absolute path strings in IDE */
3396
+ readonly files: Array<File | string>;
3397
+ /** Whether user cancelled the dialog */
3398
+ readonly canceled: boolean;
3399
+ /** Error message (if failed) */
3400
+ readonly error?: string;
3401
+ }
3402
+ /**
3403
+ * Parameters for picking folders
3404
+ */
3405
+ interface PickFolderParams {
3406
+ /** Default path for the dialog */
3407
+ readonly defaultPath?: string;
3408
+ }
3409
+ /**
3410
+ * Response from picking folders
3411
+ */
3412
+ interface PickFolderResponse {
3413
+ /** Selected folder paths */
3414
+ readonly folderPaths: string[];
3415
+ /** Whether user cancelled the dialog */
3416
+ readonly canceled: boolean;
3417
+ /** Error message (if failed) */
3418
+ readonly error?: string;
3419
+ }
3420
+ /**
3421
+ * Parameters for uploading files
3422
+ */
3423
+ interface UploadFileParams {
3424
+ /** Files to upload - File objects in browser, absolute path strings in IDE */
3425
+ readonly files: Array<File | string>;
3426
+ /** Optional AbortSignal to cancel the upload */
3427
+ readonly abortSignal?: AbortSignal;
3428
+ }
3429
+ /**
3430
+ * Response from uploading files
3431
+ */
3432
+ interface UploadFileResponse {
3433
+ /** Whether upload was successful */
3434
+ readonly success: boolean;
3435
+ /** Cloud URLs corresponding to each uploaded file (same order as input files) */
3436
+ readonly urls?: string[];
3437
+ /** URL expiration time in seconds (from backend) */
3438
+ readonly expireSeconds?: number;
3439
+ /** Error message (if upload failed) */
3440
+ readonly error?: string;
3441
+ /** Whether the upload was cancelled by user */
3442
+ readonly aborted?: boolean;
3443
+ }
3444
+ /**
3445
+ * Mention type for file/folder
3446
+ */
3447
+ declare enum MentionType {
3448
+ file = "file",
3449
+ folder = "folder"
3450
+ }
3451
+ /**
3452
+ * Search options for file search
3453
+ */
3454
+ interface SearchOptions {
3455
+ /** Search keyword */
3456
+ readonly search?: string;
3457
+ /** Number of results to return */
3458
+ readonly resultNum: number;
3459
+ }
3460
+ /**
3461
+ * File search result
3462
+ */
3463
+ interface SearchFileResult {
3464
+ /** Full path */
3465
+ path: string;
3466
+ /** Relative path */
3467
+ relativePath: string;
3468
+ /** File name */
3469
+ fileName?: string;
3470
+ /** Folder name */
3471
+ folderName?: string;
3472
+ /** Type (file or folder) */
3473
+ type: MentionType.file | MentionType.folder;
3474
+ }
3475
+ /**
3476
+ * Parameters for searching files
3477
+ */
3478
+ interface SearchFileParams {
3479
+ /** Search options */
3480
+ readonly options: SearchOptions;
3481
+ /** Search path*/
3482
+ readonly cwd?: string;
3483
+ }
3484
+ /**
3485
+ * Response from searching files
3486
+ */
3487
+ interface SearchFileResponse {
3488
+ /** Search results */
3489
+ readonly results: SearchFileResult[];
3490
+ /** Error message (if failed) */
3491
+ readonly error?: string;
3492
+ }
3493
+ /**
3494
+ * Subagent information
3495
+ */
3496
+ interface SubagentInfo {
3497
+ /** Subagent name */
3498
+ name: string;
3499
+ /** Subagent description */
3500
+ description: string;
3501
+ /** System prompt */
3502
+ systemPrompt: string;
3503
+ /** File path */
3504
+ filePath?: string;
3505
+ /** Model type */
3506
+ model?: string;
3507
+ /** Agent mode */
3508
+ agentMode?: 'agentic' | 'manual';
3509
+ /** Whether enabled */
3510
+ enabled?: boolean;
3511
+ /** Model ID */
3512
+ modelID?: string;
3513
+ /** Subagent level */
3514
+ level?: 'project' | 'user';
3515
+ }
3516
+ /**
3517
+ * Parameters for getting subagent list
3518
+ */
3519
+ interface GetSubagentListParams {
3520
+ /** Search options */
3521
+ readonly options: {
3522
+ /** Search keyword (filter by name or description) */readonly search?: string; /** Limit number of results */
3523
+ readonly resultNum?: number; /** Agent mode filter */
3524
+ readonly agentMode?: 'agentic' | 'manual' | 'all'; /** Whether to return only enabled subagents */
3525
+ readonly onlyEnabled?: boolean;
3526
+ };
3527
+ /** Working directory (optional, for filtering project-level subagents) */
3528
+ readonly cwd?: string;
3529
+ }
3530
+ /**
3531
+ * Response from getting subagent list
3532
+ */
3533
+ interface GetSubagentListResponse {
3534
+ /** Subagent list */
3535
+ readonly results: SubagentInfo[];
3536
+ /** Error message (if failed) */
3537
+ readonly error?: string;
3538
+ }
3539
+ /**
3540
+ * Skill info returned from getSkillList
3541
+ */
3542
+ interface SkillInfo {
3543
+ /** Skill name */
3544
+ name: string;
3545
+ /** File path of the skill */
3546
+ filePath: string;
3547
+ /** Description of the skill */
3548
+ description: string;
3549
+ /** When to use the skill */
3550
+ whenToUse?: string;
3551
+ /** Source of the skill */
3552
+ source: 'localSettings' | 'userSettings' | 'plugin' | 'builtin';
3553
+ /** Skill type */
3554
+ type: 'prompt';
3555
+ /** License information */
3556
+ license?: string;
3557
+ /** Allowed tools */
3558
+ allowedTools?: string[];
3559
+ /** Whether the skill is disabled */
3560
+ disable?: boolean;
3561
+ }
3562
+ /**
3563
+ * Parameters for getting skill list
3564
+ */
3565
+ interface GetSkillListParams {
3566
+ /** Working directory (optional, for filtering project-level skills) */
3567
+ readonly cwd?: string;
3568
+ /** Whether to use global (backend) channel, defaults to true. When false, uses sendBroadcastRequest. */
3569
+ readonly global?: boolean;
3570
+ /** Whether to exclude plugin skills from the result, defaults to false. */
3571
+ readonly excludePluginSkills?: boolean;
3572
+ /**
3573
+ * 用户级 skill 扫描目录名称列表(相对于 home 目录),按优先级从高到低排列。
3574
+ * 同名 skill 以高优先级目录为准。
3575
+ * 未传入或为空时使用产品默认目录。
3576
+ */
3577
+ readonly skillScanDirs?: string[];
3578
+ }
3579
+ /**
3580
+ * Response from getting skill list
3581
+ */
3582
+ interface GetSkillListResponse {
3583
+ /** Skill list */
3584
+ readonly results: SkillInfo[];
3585
+ /** Error message (if failed) */
3586
+ readonly error?: string;
3587
+ }
3588
+ /**
3589
+ * Parameters for importing a skill folder
3590
+ */
3591
+ interface ImportSkillParams {
3592
+ /** Source location: project-level or user-level */
3593
+ readonly source: 'localSettings' | 'userSettings';
3594
+ /** Working directory (required when source is localSettings). */
3595
+ readonly cwd?: string;
3596
+ }
3597
+ /**
3598
+ * Response from importing a skill folder
3599
+ */
3600
+ interface ImportSkillResponse {
3601
+ /** Whether the import was successful */
3602
+ readonly success: boolean;
3603
+ /** Error message (if failed) */
3604
+ readonly error?: string;
3605
+ }
3606
+ /**
3607
+ * Parameters for toggling skill enable/disable state
3608
+ */
3609
+ interface ToggleSkillParams {
3610
+ /** File path of the skill to toggle */
3611
+ readonly filePath: string;
3612
+ /** Whether to disable the skill */
3613
+ readonly disable: boolean;
3614
+ }
3615
+ /**
3616
+ * Response from toggling skill state
3617
+ */
3618
+ interface ToggleSkillResponse {
3619
+ /** Whether the toggle was successful */
3620
+ readonly success: boolean;
3621
+ /** Error message (if failed) */
3622
+ readonly error?: string;
3623
+ }
3624
+ /**
3625
+ * Parameters for deleting a skill
3626
+ */
3627
+ interface DeleteSkillParams {
3628
+ /** File path of the skill to delete */
3629
+ readonly filePath: string;
3630
+ /** Name of the skill */
3631
+ readonly name: string;
3632
+ }
3633
+ /**
3634
+ * Response from deleting a skill
2342
3635
  */
2343
- interface PickFileResponse {
2344
- /** Selected files - File objects in browser, absolute path strings in IDE */
2345
- readonly files: Array<File | string>;
2346
- /** Whether user cancelled the dialog */
2347
- readonly canceled: boolean;
3636
+ interface DeleteSkillResponse {
3637
+ /** Whether the deletion was successful */
3638
+ readonly success: boolean;
2348
3639
  /** Error message (if failed) */
2349
3640
  readonly error?: string;
2350
3641
  }
2351
3642
  /**
2352
- * Parameters for picking folders
3643
+ * Parameters for getting skill content
2353
3644
  */
2354
- interface PickFolderParams {
2355
- /** Default path for the dialog */
2356
- readonly defaultPath?: string;
3645
+ interface GetSkillContentParams {
3646
+ /** File path of the skill */
3647
+ readonly filePath: string;
2357
3648
  }
2358
3649
  /**
2359
- * Response from picking folders
3650
+ * Response from getting skill content
2360
3651
  */
2361
- interface PickFolderResponse {
2362
- /** Selected folder paths */
2363
- readonly folderPaths: string[];
2364
- /** Whether user cancelled the dialog */
2365
- readonly canceled: boolean;
3652
+ interface GetSkillContentResponse {
3653
+ /** Skill file content */
3654
+ readonly content: string;
2366
3655
  /** Error message (if failed) */
2367
3656
  readonly error?: string;
2368
3657
  }
2369
3658
  /**
2370
- * Parameters for uploading files
3659
+ * Marketplace skill info (simplified structure for UI layer)
2371
3660
  */
2372
- interface UploadFileParams {
2373
- /** Files to upload - File objects in browser, absolute path strings in IDE */
2374
- readonly files: Array<File | string>;
3661
+ interface MarketplaceSkillInfo {
3662
+ /** Skill name */
3663
+ name: string;
3664
+ /** Skill description */
3665
+ description: string;
3666
+ /** Skill description in English */
3667
+ description_en?: string;
3668
+ /** Skill version */
3669
+ version?: string;
3670
+ /** Skill author */
3671
+ author?: string;
3672
+ /** Skill icon URL */
3673
+ iconUrl?: string;
3674
+ /** Skill tags */
3675
+ tags?: string[];
2375
3676
  }
2376
3677
  /**
2377
- * Response from uploading files
3678
+ * Response from getting marketplace skills
2378
3679
  */
2379
- interface UploadFileResponse {
2380
- /** Whether upload was successful */
2381
- readonly success: boolean;
2382
- /** Cloud URLs corresponding to each uploaded file (same order as input files) */
2383
- readonly urls?: string[];
2384
- /** URL expiration time in seconds (from backend) */
2385
- readonly expireSeconds?: number;
2386
- /** Error message (if upload failed) */
3680
+ interface GetMarketplaceSkillsResponse {
3681
+ /** Marketplace skill list */
3682
+ readonly results: MarketplaceSkillInfo[];
3683
+ /** Error message (if failed) */
2387
3684
  readonly error?: string;
2388
3685
  }
2389
3686
  /**
2390
- * Mention type for file/folder
3687
+ * Parameters for getting marketplace skill content
2391
3688
  */
2392
- declare enum MentionType {
2393
- file = "file",
2394
- folder = "folder"
3689
+ interface GetMarketplaceSkillContentParams {
3690
+ /** Skill name */
3691
+ readonly skillName: string;
2395
3692
  }
2396
3693
  /**
2397
- * Search options for file search
3694
+ * Response from getting marketplace skill content
2398
3695
  */
2399
- interface SearchOptions {
2400
- /** Search keyword */
2401
- readonly search?: string;
2402
- /** Number of results to return */
2403
- readonly resultNum: number;
3696
+ interface GetMarketplaceSkillContentResponse {
3697
+ /** Skill file content */
3698
+ readonly content: string;
3699
+ /** Error message (if failed) */
3700
+ readonly error?: string;
2404
3701
  }
2405
3702
  /**
2406
- * File search result
3703
+ * Parameters for installing marketplace skill
2407
3704
  */
2408
- interface SearchFileResult {
2409
- /** Full path */
2410
- path: string;
2411
- /** Relative path */
2412
- relativePath: string;
2413
- /** File name */
2414
- fileName?: string;
2415
- /** Folder name */
2416
- folderName?: string;
2417
- /** Type (file or folder) */
2418
- type: MentionType.file | MentionType.folder;
3705
+ interface InstallMarketplaceSkillParams {
3706
+ /** Skill name to install */
3707
+ readonly skillName: string;
2419
3708
  }
2420
3709
  /**
2421
- * Parameters for searching files
3710
+ * Response from installing marketplace skill
2422
3711
  */
2423
- interface SearchFileParams {
2424
- /** Search options */
2425
- readonly options: SearchOptions;
2426
- /** Search path*/
2427
- readonly cwd?: string;
3712
+ interface InstallMarketplaceSkillResponse {
3713
+ /** Whether the install was successful */
3714
+ readonly success: boolean;
3715
+ /** Skill name */
3716
+ readonly skillName: string;
3717
+ /** Error message (if failed) */
3718
+ readonly errorMessage?: string;
2428
3719
  }
2429
3720
  /**
2430
- * Response from searching files
3721
+ * MCP Tool information
2431
3722
  */
2432
- interface SearchFileResponse {
2433
- /** Search results */
2434
- readonly results: SearchFileResult[];
2435
- /** Error message (if failed) */
2436
- readonly error?: string;
3723
+ interface McpToolInfo {
3724
+ /** Tool name */
3725
+ name: string;
3726
+ /** Tool description */
3727
+ description?: string;
3728
+ /** Whether the tool is enabled */
3729
+ enabled?: boolean;
3730
+ }
3731
+ /**
3732
+ * MCP Server information
3733
+ */
3734
+ interface McpServerInfo {
3735
+ /** Server ID */
3736
+ id: string;
3737
+ /** Server name */
3738
+ name: string;
3739
+ /** Connection status */
3740
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
3741
+ /** Server description */
3742
+ description?: string;
3743
+ /** Available tools */
3744
+ tools?: McpToolInfo[];
3745
+ /** Whether the server is disabled */
3746
+ disabled?: boolean;
3747
+ /** Error message (if connection failed) */
3748
+ error?: string;
3749
+ /** Logo URL */
3750
+ logoUrl?: string;
3751
+ /** Official website URL */
3752
+ officialUrl?: string;
3753
+ /** Configuration source */
3754
+ configSource?: 'user' | 'project' | 'plugin';
2437
3755
  }
2438
3756
  //#endregion
2439
3757
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
@@ -2466,6 +3784,17 @@ declare class CloudAgentConnection implements AgentConnection {
2466
3784
  readonly transport: "cloud";
2467
3785
  readonly cwd: string;
2468
3786
  constructor(agentId: string, config: CloudConnectionConfig, cwd?: string);
3787
+ /**
3788
+ * Check whether a notification belongs to this connection's own session.
3789
+ *
3790
+ * CloudConnection.createSession() overrides sessionId to agentId, so the
3791
+ * rest of the client stack uses agentId as the canonical session
3792
+ * identifier. Notifications whose sessionId differs from agentId
3793
+ * originate from sub-agent sessions running inside the same sandbox and
3794
+ * should be silently ignored at this layer — the adapter layer handles
3795
+ * sub-agent messages independently via parentToolUseId in _meta.
3796
+ */
3797
+ private isOwnSessionNotification;
2469
3798
  private setupEventForwarding;
2470
3799
  on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
2471
3800
  off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
@@ -2513,6 +3842,7 @@ declare class CloudAgentConnection implements AgentConnection {
2513
3842
  * Contains sandboxId, link, token, etc.
2514
3843
  */
2515
3844
  get sessionConnectionInfo(): SessionConnectionInfo | undefined;
3845
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2516
3846
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2517
3847
  }
2518
3848
  //#endregion
@@ -2635,6 +3965,22 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2635
3965
  private cosUploadService;
2636
3966
  /** Event listeners for provider-level events */
2637
3967
  private eventListeners;
3968
+ /** 产品配置缓存(内存),用于存储 deploymentType 和 creditPurchaseActions */
3969
+ private productConfigCache;
3970
+ /**
3971
+ * Plugin marketplace cache (name/id -> marketplace info)
3972
+ * LRU 缓存,容量上限 200
3973
+ * Key: marketplace name 或 id
3974
+ * Value: marketplace 完整信息
3975
+ */
3976
+ private marketplaceCache;
3977
+ /**
3978
+ * Installed plugin cache (plugin name -> plugin info with install_id)
3979
+ * LRU 缓存,容量上限 2000
3980
+ * Key: plugin name
3981
+ * Value: plugin 完整信息(包含 installId)
3982
+ */
3983
+ private pluginCache;
2638
3984
  constructor(options: CloudAgentProviderOptions);
2639
3985
  /**
2640
3986
  * Dispose the provider and clean up resources
@@ -2691,8 +4037,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2691
4037
  /**
2692
4038
  * Create a new conversation
2693
4039
  * POST {endpoint}/console/as/conversations
4040
+ * @param params - Session params containing cwd and optional configuration
2694
4041
  */
2695
- create(): Promise<string>;
4042
+ create(params: CreateSessionParams$1): Promise<string>;
2696
4043
  /**
2697
4044
  * Connect to an agent and return the connection
2698
4045
  *
@@ -2744,6 +4091,21 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2744
4091
  * ```
2745
4092
  */
2746
4093
  rename(agentId: string, title: string): Promise<PatchConversationResponse>;
4094
+ /**
4095
+ * Update conversation status by ID
4096
+ * POST {endpoint}/console/as/conversations/{agentId}
4097
+ *
4098
+ * @param agentId - Conversation ID to update
4099
+ * @param status - New status for the conversation
4100
+ * @returns PatchConversationResponse containing the updated conversation ID
4101
+ *
4102
+ * @example
4103
+ * ```typescript
4104
+ * const result = await provider.updateStatus('agent-123', 'completed');
4105
+ * console.log('Updated conversation status:', result.id);
4106
+ * ```
4107
+ */
4108
+ updateStatus(agentId: string, status: string): Promise<PatchConversationResponse>;
2747
4109
  /**
2748
4110
  * Get available models from product configuration
2749
4111
  *
@@ -2756,6 +4118,25 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2756
4118
  * @returns Array of ModelInfo with full model details
2757
4119
  */
2758
4120
  getModels(repo?: string): Promise<ModelInfo[]>;
4121
+ /**
4122
+ * 获取产品部署类型(从缓存)
4123
+ * 需要先调用 getModels() 初始化缓存
4124
+ *
4125
+ * @returns 部署类型:'SaaS' | 'Cloud-Hosted' | 'Self-Hosted',默认为 'SaaS'
4126
+ */
4127
+ getDeploymentType(): string;
4128
+ /**
4129
+ * 获取 Credit 购买引导配置(从缓存)
4130
+ * 需要先调用 getModels() 初始化缓存
4131
+ *
4132
+ * @returns Credit 购买引导配置,key 为错误码。如果后端未返回,则使用默认配置
4133
+ */
4134
+ getCreditPurchaseActions(): Record<string, {
4135
+ labelZh: string;
4136
+ labelEn: string;
4137
+ url: string;
4138
+ showButton?: boolean;
4139
+ }>;
2759
4140
  /**
2760
4141
  * Generate a unique request ID
2761
4142
  */
@@ -2778,7 +4159,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2778
4159
  /**
2779
4160
  * Upload files to cloud storage via COS presigned URL
2780
4161
  *
2781
- * @param params - files array (File objects in browser)
4162
+ * @param params - files array (File objects in browser), optional abortSignal
2782
4163
  * @returns Response with corresponding cloud URLs
2783
4164
  */
2784
4165
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
@@ -2802,53 +4183,282 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2802
4183
  private emitEvent;
2803
4184
  /**
2804
4185
  * 获取支持的场景列表
2805
- * API 端点: GET /console/as/support/scenes
4186
+ * API 端点: GET /v2/as/support/scenes (不鉴权)
2806
4187
  * 用于 Welcome 页面的 QuickActions 快捷操作
2807
4188
  *
4189
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2808
4190
  * @returns Promise<SupportScene[]> 支持的场景列表
2809
4191
  */
2810
- getSupportScenes(): Promise<SupportScene[]>;
4192
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
2811
4193
  private toAgentState;
2812
4194
  /**
2813
4195
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
2814
4196
  */
2815
4197
  private buildGetUrl;
4198
+ /**
4199
+ * 获取已安装插件列表
4200
+ * GET /console/as/user/plugins/installed
4201
+ */
4202
+ getInstalledPlugins(forceRefresh?: boolean): Promise<Array<{
4203
+ name: string;
4204
+ marketplaceName: string;
4205
+ status: string;
4206
+ description?: string;
4207
+ version?: string;
4208
+ installScope?: 'user' | 'project';
4209
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
4210
+ installId?: string;
4211
+ }>>;
4212
+ /**
4213
+ * 安装插件
4214
+ * POST /console/as/user/plugins/install
4215
+ *
4216
+ * @param pluginNames - 插件名称数组
4217
+ * @param marketplaceNameOrId - 市场名称或 ID
4218
+ */
4219
+ installPlugins(pluginNames: string[], marketplaceNameOrId: string, installScope?: 'user' | 'project' | 'project-local', marketplaceSource?: string, workspacePath?: string): Promise<{
4220
+ success: boolean;
4221
+ error?: string;
4222
+ }>;
4223
+ /**
4224
+ * 卸载插件
4225
+ * POST /console/as/user/plugins/installed/:id/uninstall
4226
+ *
4227
+ * 完整链路:
4228
+ * CloudAgentProvider.uninstallPlugin()
4229
+ * -> HTTP POST /console/as/user/plugins/installed/:id/uninstall
4230
+ * -> agentserver: PluginInstallService.Uninstall()
4231
+ * -> 软删除 DB + 异步同步到活跃沙箱
4232
+ *
4233
+ * @param pluginName - 插件名称
4234
+ * @param marketplaceName - 市场名称(用于标识唯一插件)
4235
+ * @param scope - 卸载范围 ('user' | 'project' | 'project-local')
4236
+ */
4237
+ uninstallPlugin(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
4238
+ success: boolean;
4239
+ error?: string;
4240
+ }>;
4241
+ /**
4242
+ * 获取插件市场列表
4243
+ * GET /console/as/marketplace/sources
4244
+ */
4245
+ getPluginMarketplaces(forceRefresh?: boolean): Promise<Array<{
4246
+ id: string;
4247
+ name: string;
4248
+ type: 'github' | 'local' | 'custom';
4249
+ source: {
4250
+ repo?: string;
4251
+ ref?: string;
4252
+ url?: string;
4253
+ };
4254
+ description?: string;
4255
+ isBuiltin?: boolean;
4256
+ }>>;
4257
+ /**
4258
+ * 获取市场下的插件列表
4259
+ * - 有 searchText: GET /console/as/marketplace/plugins/search (跨所有市场搜索)
4260
+ * - 无 searchText: GET /console/as/marketplace/plugins (指定市场)
4261
+ *
4262
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4263
+ * @param forceRefresh - 是否强制刷新
4264
+ * @param searchText - 搜索关键字(如果提供,则跨所有市场搜索)
4265
+ */
4266
+ getMarketplacePlugins(marketplaceNameOrId: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
4267
+ name: string;
4268
+ marketplaceName: string;
4269
+ description?: string;
4270
+ version?: string;
4271
+ author?: string;
4272
+ homepage?: string;
4273
+ iconUrl?: string;
4274
+ tags?: string[];
4275
+ installed?: boolean;
4276
+ status?: 'enabled' | 'disabled' | 'not-installed';
4277
+ installedScopes?: Array<'user' | 'project'>;
4278
+ hasUpdate?: boolean;
4279
+ latestVersion?: string;
4280
+ agents?: any;
4281
+ commands?: any;
4282
+ skills?: any;
4283
+ mcpServers?: any;
4284
+ hooks?: any;
4285
+ rules?: any;
4286
+ }>>;
4287
+ /**
4288
+ * 获取插件详情
4289
+ * GET /console/as/marketplace/plugins/:name/detail
4290
+ *
4291
+ * @param pluginName - 插件名称
4292
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4293
+ */
4294
+ getPluginDetail(pluginName: string, marketplaceNameOrId: string): Promise<{
4295
+ name: string;
4296
+ marketplaceName: string;
4297
+ description?: string;
4298
+ version?: string;
4299
+ author?: string;
4300
+ homepage?: string;
4301
+ iconUrl?: string;
4302
+ tags?: string[];
4303
+ installed?: boolean;
4304
+ status?: 'enabled' | 'disabled' | 'not-installed';
4305
+ installedScopes?: Array<'user' | 'project'>;
4306
+ readme?: string;
4307
+ configSchema?: Record<string, unknown>;
4308
+ tools?: Array<{
4309
+ name: string;
4310
+ description?: string;
4311
+ }>;
4312
+ resources?: Array<{
4313
+ name: string;
4314
+ description?: string;
4315
+ }>;
4316
+ prompts?: Array<{
4317
+ name: string;
4318
+ description?: string;
4319
+ }>;
4320
+ downloadCount?: number;
4321
+ lastUpdated?: string;
4322
+ license?: string;
4323
+ repositoryUrl?: string;
4324
+ } | null>;
4325
+ /**
4326
+ * 添加插件市场
4327
+ * POST /console/as/marketplace/sources
4328
+ */
4329
+ addPluginMarketplace(sourceUrl: string, name?: string): Promise<{
4330
+ success: boolean;
4331
+ error?: string;
4332
+ marketplace?: {
4333
+ id: string;
4334
+ name: string;
4335
+ type: 'github' | 'local' | 'custom';
4336
+ source: {
4337
+ repo?: string;
4338
+ ref?: string;
4339
+ url?: string;
4340
+ };
4341
+ description?: string;
4342
+ isBuiltin?: boolean;
4343
+ };
4344
+ }>;
4345
+ /**
4346
+ * 删除插件市场
4347
+ * POST /console/as/marketplace/sources/:id/delete
4348
+ */
4349
+ removePluginMarketplace(marketplaceNameOrId: string): Promise<{
4350
+ success: boolean;
4351
+ error?: string;
4352
+ }>;
4353
+ /**
4354
+ * 刷新插件市场
4355
+ * POST /console/as/marketplace/sources/:id/check-updates
4356
+ */
4357
+ refreshPluginMarketplace(marketplaceNameOrId: string): Promise<{
4358
+ success: boolean;
4359
+ error?: string;
4360
+ plugins?: Array<any>;
4361
+ }>;
4362
+ /**
4363
+ * 批量切换插件启用/禁用状态
4364
+ * POST /console/as/user/plugins/installed/:id/toggle
4365
+ */
4366
+ batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
4367
+ /**
4368
+ * 将后端插件数据映射为前端格式
4369
+ */
4370
+ private mapPluginData;
4371
+ /**
4372
+ * 从缓存中查找插件的 install_id
4373
+ * 如果缓存未命中,则调用 API 获取并缓存
4374
+ *
4375
+ * @param pluginName - 插件名称
4376
+ * @returns install_id 或 null
4377
+ */
4378
+ private findPluginInstallId;
4379
+ /**
4380
+ * 从缓存中查找 marketplace ID
4381
+ * 如果缓存未命中,则调用 API 获取并缓存
4382
+ */
4383
+ private findMarketplaceId;
4384
+ /**
4385
+ * 提取 API 错误信息
4386
+ * 从 AxiosError 中提取详细的错误信息,包括 HTTP 状态码、错误码和错误消息
4387
+ */
4388
+ private extractErrorMessage;
4389
+ /**
4390
+ * 映射后端 source_type 到前端类型
4391
+ */
4392
+ private mapSourceType;
4393
+ /**
4394
+ * 解析 capabilities JSON 字符串
4395
+ */
4396
+ private parseCapabilities;
4397
+ /**
4398
+ * 上报 telemetry 事件(Cloud 模式)
4399
+ * 通过 HTTP POST 发送到 /v2/report
4400
+ * 注入用户信息和浏览器环境等公共字段
4401
+ */
4402
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2816
4403
  }
2817
4404
  //#endregion
2818
4405
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
2819
4406
  /**
2820
- * E2B Filesystem Implementation
4407
+ * Callback to fetch fresh sandbox connection info from backend.
4408
+ * Called when an operation fails with 401/403.
4409
+ */
4410
+ type ReconnectFn = () => Promise<E2BSandboxConnectionInfo>;
4411
+ /**
4412
+ * E2B Filesystem
2821
4413
  *
2822
- * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource interface.
4414
+ * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource.
4415
+ * When `reconnectFn` is provided, automatically reconnects on auth errors.
2823
4416
  *
2824
4417
  * @example
2825
4418
  * ```typescript
2826
- * const fs = await E2BFilesystem.connect({
2827
- * sandboxId: 'sandbox-123',
2828
- * apiKey: 'e2b_xxx'
2829
- * });
2830
- *
2831
- * // Read/write files
2832
- * await fs.write('/test.txt', 'Hello World');
2833
- * const content = await fs.read('/test.txt');
4419
+ * // Basic usage (no auto-reconnect)
4420
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
2834
4421
  *
2835
- * // Watch for changes
2836
- * const handle = await fs.watchDir('/workspace', (event) => {
2837
- * console.log('File changed:', event);
2838
- * });
4422
+ * // With auto-reconnect on token expiry
4423
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
4424
+ * fs.setReconnectFn(async () => fetchFreshConnectionInfo());
2839
4425
  * ```
2840
4426
  */
2841
4427
  declare class E2BFilesystem implements FilesResource {
2842
4428
  private sandbox;
4429
+ private reconnectFn?;
4430
+ /** Whether a reconnect is currently in-flight */
4431
+ private isReconnecting;
4432
+ /** Callers waiting for the in-flight reconnect to complete */
4433
+ private reconnectSubscribers;
4434
+ /** Timestamp of last reconnect attempt (anti-loop: min 10s between attempts) */
4435
+ private lastReconnectAt;
4436
+ private static readonly MIN_RECONNECT_INTERVAL_MS;
2843
4437
  constructor(sandbox: Sandbox);
2844
4438
  /**
2845
4439
  * Connect to an E2B Sandbox and create filesystem instance
2846
4440
  */
2847
4441
  static connect(info: E2BSandboxConnectionInfo): Promise<E2BFilesystem>;
4442
+ /**
4443
+ * Set reconnect callback. When set, auth errors trigger automatic reconnect + retry.
4444
+ */
4445
+ setReconnectFn(fn: ReconnectFn): void;
2848
4446
  /**
2849
4447
  * Get the underlying E2B Sandbox instance
2850
4448
  */
2851
4449
  getSandbox(): Sandbox;
4450
+ private isAuthError;
4451
+ private canAttemptReconnect;
4452
+ /**
4453
+ * Reconnect with fresh credentials.
4454
+ * Only one reconnect in-flight at a time; concurrent callers share the result.
4455
+ */
4456
+ private reconnect;
4457
+ /**
4458
+ * Execute an operation. If reconnectFn is set and an auth error occurs,
4459
+ * reconnect and retry once.
4460
+ */
4461
+ private exec;
2852
4462
  read(path: string, opts?: FilesystemRequestOpts & {
2853
4463
  format?: 'text';
2854
4464
  }): Promise<string>;
@@ -2991,6 +4601,7 @@ interface ActiveSessionImplOptions {
2991
4601
  declare class ActiveSessionImpl implements ActiveSession {
2992
4602
  private _id;
2993
4603
  private _agentId;
4604
+ private _cwd?;
2994
4605
  private _availableModes?;
2995
4606
  private _currentMode?;
2996
4607
  private _availableModels?;
@@ -3002,6 +4613,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3002
4613
  private _connectionInfo?;
3003
4614
  private listeners;
3004
4615
  private onceListeners;
4616
+ private connectionListeners;
3005
4617
  /**
3006
4618
  * Agent operations namespace
3007
4619
  */
@@ -3035,6 +4647,14 @@ declare class ActiveSessionImpl implements ActiveSession {
3035
4647
  * Agent ID
3036
4648
  */
3037
4649
  get agentId(): string;
4650
+ /**
4651
+ * Actual workspace path (set from newSession response _meta)
4652
+ */
4653
+ get cwd(): string | undefined;
4654
+ /**
4655
+ * Set actual workspace path (called by SessionManager after createSession)
4656
+ */
4657
+ setCwd(cwd: string): void;
3038
4658
  /**
3039
4659
  * Agent state (live connection state)
3040
4660
  * Returns LocalAgentState or CloudAgentState based on transport type
@@ -3140,7 +4760,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3140
4760
  * await session.setMode('architect');
3141
4761
  * ```
3142
4762
  */
3143
- setMode(modeId: string): Promise<void>;
4763
+ setMode(modeId: string, skipAvailableChecker?: boolean): Promise<void>;
3144
4764
  /**
3145
4765
  * Set the current session model
3146
4766
  *
@@ -3179,6 +4799,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3179
4799
  * Disconnect from the session/agent
3180
4800
  */
3181
4801
  disconnect(): void;
4802
+ /**
4803
+ * Detach the session from connection events without disconnecting the connection.
4804
+ * This should be called when the session is being replaced but the connection is shared.
4805
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
4806
+ */
4807
+ detach(): void;
3182
4808
  /**
3183
4809
  * Symbol.dispose for 'using' keyword support
3184
4810
  * Automatically disconnects and cleans up when session goes out of scope
@@ -3193,8 +4819,21 @@ declare class ActiveSessionImpl implements ActiveSession {
3193
4819
  */
3194
4820
  [Symbol.dispose](): void;
3195
4821
  private getConnectionOrThrow;
4822
+ /**
4823
+ * 在 connection 上注册 listener 并保存引用,便于 disconnect 时移除
4824
+ */
4825
+ private addConnectionListener;
4826
+ /**
4827
+ * 从 connection 上移除所有本 session 注册的 listener
4828
+ */
4829
+ private removeConnectionListeners;
3196
4830
  private setupConnectionEvents;
3197
4831
  private mapPromptResponse;
4832
+ /**
4833
+ * 判断 artifact 是否应该转发给当前 session
4834
+ * 所有类型的 artifact 都按 __sessionId 严格隔离
4835
+ */
4836
+ private shouldForwardArtifact;
3198
4837
  }
3199
4838
  //#endregion
3200
4839
  //#region ../agent-provider/lib/common/client/session-manager.d.ts
@@ -3271,6 +4910,18 @@ declare class SessionManager {
3271
4910
  * 7. Return ActiveSession instance (cached)
3272
4911
  */
3273
4912
  loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
4913
+ /**
4914
+ * 从 ACP response 中提取可用模型列表
4915
+ *
4916
+ * 优先级:
4917
+ * 1. response.models._meta?.['codebuddy.ai']?.availableModels - 包含完整的模型信息(字段名为 'id')
4918
+ * 2. response.models?.availableModels - 只包含基本信息(字段名为 'modelId')
4919
+ * 3. undefined - 都没有时返回 undefined
4920
+ *
4921
+ * @param response - ACP 响应对象
4922
+ * @returns ModelInfo[] | undefined
4923
+ */
4924
+ protected extractAvailableModels(response: LoadSessionResponse): ModelInfo[] | undefined;
3274
4925
  }
3275
4926
  //#endregion
3276
4927
  //#region ../agent-provider/lib/backend/backend-provider.d.ts
@@ -3287,6 +4938,13 @@ declare class SessionManager {
3287
4938
  */
3288
4939
  declare class BackendProvider implements IBackendProvider {
3289
4940
  constructor(config: BackendProviderConfig);
4941
+ /**
4942
+ * 处理 401 未授权错误
4943
+ * 先尝试刷新 token,失败后再执行登出流程
4944
+ *
4945
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
4946
+ */
4947
+ protected handleUnauthorized(): Promise<void>;
3290
4948
  /**
3291
4949
  * 获取当前账号信息
3292
4950
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3397,9 +5055,21 @@ declare class BackendProvider implements IBackendProvider {
3397
5055
  login(): Promise<void>;
3398
5056
  /**
3399
5057
  * 登出账号
3400
- * Web 环境: 通过 iframe 访问登出 URL 清除 cookie
5058
+ *
5059
+ * 策略:
5060
+ * - IOA 企业:用 iframe 走 SSO/SAML SLO 登出链路(涉及跨域重定向),通过轮询 iframe URL 变化检测完成
5061
+ * - 非 IOA 企业:直接用 httpService 请求 /console/logout,速度快
3401
5062
  */
3402
5063
  logout(): Promise<void>;
5064
+ /**
5065
+ * IOA 企业登出:通过 iframe 走 SSO/SAML SLO 登出链路
5066
+ * 轮询 iframe URL 变化检测完成,兜底超时 5 秒
5067
+ */
5068
+ private logoutViaIframe;
5069
+ /**
5070
+ * 非 IOA 企业登出:直接 HTTP 请求 /console/logout
5071
+ */
5072
+ private logoutViaHttp;
3403
5073
  /**
3404
5074
  * 批量切换插件状态
3405
5075
  * Web 环境不支持此功能
@@ -3410,6 +5080,58 @@ declare class BackendProvider implements IBackendProvider {
3410
5080
  * API: POST /billing/meter/get-enterprise-user-usage
3411
5081
  */
3412
5082
  getEnterpriseUsage(enterpriseId: string): Promise<EnterpriseUsage | null>;
5083
+ /**
5084
+ * 刷新 Token
5085
+ * 通过调用 getAccount 刷新 cookie,适用于 Cloud 场景下页面切换回来时刷新登录态
5086
+ * @returns Promise<Account | null> 刷新后的账号信息
5087
+ */
5088
+ refreshToken(): Promise<Account | null>;
5089
+ /**
5090
+ * 获取仓库分支列表
5091
+ * API 端点: GET /console/as/connector/oauth/{name}/branches
5092
+ *
5093
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
5094
+ * @param params 平台特定的查询参数
5095
+ * @param page 页码,从1开始,0表示不分页获取全部
5096
+ * @param perPage 每页数量,最大100
5097
+ * @returns Promise<OauthBranch[]> 分支列表
5098
+ */
5099
+ getBranches(connector: OauthConnectorName, params: GitHubBranchParams | GongfengBranchParams | CNBBranchParams, page?: number, perPage?: number): Promise<OauthBranch[]>;
5100
+ /**
5101
+ * 获取仓库列表
5102
+ * API 端点: GET /console/as/connector/oauth/{name}/repos
5103
+ *
5104
+ * Note: 由于工蜂原生支持的 Search 能力会匹配 path/name/description 部分,
5105
+ * 且不支持定制,不满足产品要求(只按 name 匹配),因此前端拉取全量数据后做筛选。
5106
+ *
5107
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
5108
+ * @param page 页码,从1开始,0表示不分页获取全部
5109
+ * - GitHub 只支持全量数据,必须传 0
5110
+ * - 工蜂和 CNB 依据前端逻辑而定
5111
+ * @param perPage 每页数量,最大100
5112
+ * @returns Promise<ListReposResponse> 仓库列表响应
5113
+ */
5114
+ getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
5115
+ /**
5116
+ * 保存待发送的输入内容到后端
5117
+ * API 端点: POST /api/v1/code-id
5118
+ */
5119
+ savePendingInput(code: string): Promise<string | null>;
5120
+ /**
5121
+ * 从后端加载待发送的输入内容
5122
+ * API 端点: GET /api/v1/code?id=xxx
5123
+ */
5124
+ loadPendingInput(codeId: string): Promise<string | null>;
5125
+ /**
5126
+ * 获取每日签到状态
5127
+ * API 端点: POST /billing/meter/checkin-status
5128
+ */
5129
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5130
+ /**
5131
+ * 执行每日签到
5132
+ * API 端点: POST /billing/meter/daily-checkin
5133
+ */
5134
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
3413
5135
  }
3414
5136
  /**
3415
5137
  * 创建 BackendProvider 实例
@@ -3543,6 +5265,12 @@ declare class IPCBackendProvider implements IBackendProvider {
3543
5265
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
3544
5266
  */
3545
5267
  closeAgentManager(): Promise<void>;
5268
+ /**
5269
+ * 在外部浏览器中打开链接
5270
+ * IDE 环境: 通过 IPC 通知 IDE 使用 vscode.env.openExternal 打开 URL
5271
+ * @param url 要打开的 URL
5272
+ */
5273
+ openExternal(url: string): Promise<void>;
3546
5274
  /**
3547
5275
  * 批量切换插件状态
3548
5276
  * IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
@@ -3560,6 +5288,27 @@ declare class IPCBackendProvider implements IBackendProvider {
3560
5288
  * 4. 返回 SupportScene[] 数据给 agent-ui
3561
5289
  */
3562
5290
  getSupportScenes(): Promise<SupportScene[]>;
5291
+ /**
5292
+ * 获取账号用量信息(积分/Credits)
5293
+ * IDE 环境: 通过 IPC 实时获取用量信息,每次打开菜单时调用
5294
+ *
5295
+ * 调用链:
5296
+ * 1. agent-ui: IPCBackendProvider.getAccountUsage()
5297
+ * 2. Agent Manager renderer: BackendService.getAccountUsage()
5298
+ * 3. Main Process: codebuddy:getAccountUsage IPC handler
5299
+ * 4. 返回 { usageLeft, usageTotal, editionType, refreshAt } 等字段
5300
+ */
5301
+ getAccountUsage(): Promise<Partial<Account> | null>;
5302
+ /**
5303
+ * 获取每日签到状态
5304
+ * IDE 环境: 通过 IPC 获取签到状态
5305
+ */
5306
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5307
+ /**
5308
+ * 执行每日签到
5309
+ * IDE 环境: 通过 IPC 执行签到
5310
+ */
5311
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
3563
5312
  /**
3564
5313
  * 调试日志
3565
5314
  */
@@ -3614,7 +5363,7 @@ type UnauthorizedCallback = () => void;
3614
5363
  * 特性:
3615
5364
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3616
5365
  * - 支持拦截器注册(其他模块可注入 header)
3617
- * - 统一 401/403 处理
5366
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3618
5367
  * - 自动携带凭证(withCredentials)
3619
5368
  * - 类型安全
3620
5369
  *
@@ -3650,6 +5399,10 @@ declare class HttpService {
3650
5399
  private axiosInstance;
3651
5400
  private unauthorizedCallbacks;
3652
5401
  private config;
5402
+ /** 是否正在刷新 token */
5403
+ private isRefreshing;
5404
+ /** 等待 token 刷新完成的请求队列 */
5405
+ private refreshSubscribers;
3653
5406
  /**
3654
5407
  * 私有构造函数(单例模式)
3655
5408
  */
@@ -3667,9 +5420,17 @@ declare class HttpService {
3667
5420
  */
3668
5421
  private registerDefaultRequestInterceptor;
3669
5422
  /**
3670
- * 注册默认响应拦截器(处理 401/403)
5423
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3671
5424
  */
3672
5425
  private registerDefaultResponseInterceptor;
5426
+ /**
5427
+ * token 刷新成功,通知所有等待的请求
5428
+ */
5429
+ private onRefreshSuccess;
5430
+ /**
5431
+ * token 刷新失败,通知所有等待的请求
5432
+ */
5433
+ private onRefreshFailure;
3673
5434
  /**
3674
5435
  * 注册请求拦截器
3675
5436
  * @param onFulfilled 请求成功拦截器
@@ -3735,7 +5496,9 @@ declare class HttpService {
3735
5496
  */
3736
5497
  offUnauthorized(callback: UnauthorizedCallback): void;
3737
5498
  /**
3738
- * 触发所有 401 回调
5499
+ * 触发所有 401 回调并等待完成
5500
+ * @returns Promise,等待所有回调完成
5501
+ * @throws 如果任何回调失败,则抛出错误
3739
5502
  */
3740
5503
  private triggerUnauthorizedCallbacks;
3741
5504
  /**