@tencent-ai/cloud-agent-sdk 0.2.12 → 0.2.13-next.2bf8b02.20260209

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
 
@@ -339,12 +339,240 @@ interface ClientEvents extends Record<string, unknown> {
339
339
  */
340
340
  type QuestionAnswers = Record<string, string | string[]>;
341
341
  //#endregion
342
- //#region ../agent-provider/lib/backend/types.d.ts
342
+ //#region ../agent-provider/lib/backend/service/oauth-repository-types.d.ts
343
343
  /**
344
- * Backend Provider 类型定义
344
+ * OAuth Repository Types
345
345
  *
346
- * 定义 IBackendProvider 接口和配置
346
+ * 定义 OAuth 连接器相关的仓库和分支操作类型
347
+ */
348
+ /**
349
+ * Connector name type for OAuth providers
350
+ */
351
+ type OauthConnectorName$1 = 'github' | 'gongfeng' | 'cnb';
352
+ /**
353
+ * Branch information from OAuth connector
354
+ * GET /console/as/connector/oauth/{name}/branches
355
+ */
356
+ interface OauthBranch$1 {
357
+ /** Branch name */
358
+ name: string;
359
+ /** Whether the branch is protected */
360
+ protected: boolean;
361
+ /** Latest commit SHA */
362
+ commit_sha: string;
363
+ /** Latest commit URL */
364
+ commit_url: string;
365
+ }
366
+ /**
367
+ * GitHub 分支查询参数
368
+ */
369
+ interface GitHubBranchParams$1 {
370
+ /** Repository owner (e.g., "CodeBuddy-Official-Account") */
371
+ owner: string;
372
+ /** Repository name (e.g., "CodeBuddyIDE") */
373
+ repo: string;
374
+ }
375
+ /**
376
+ * Gongfeng 分支查询参数
377
+ */
378
+ interface GongfengBranchParams$1 {
379
+ /** Project ID (e.g., "1611499") */
380
+ project_id: string;
381
+ }
382
+ /**
383
+ * CNB 分支查询参数
384
+ */
385
+ interface CNBBranchParams$1 {
386
+ /** Repository path: org/repo (e.g., "genie/genie-ide") */
387
+ repo: string;
388
+ }
389
+ /**
390
+ * GitHub repository owner information
391
+ */
392
+ interface OauthGitHubRepoOwner {
393
+ /** Owner login name */
394
+ login: string;
395
+ /** Owner avatar URL */
396
+ avatar_url: string;
397
+ /** Owner API URL */
398
+ url: string;
399
+ /** Owner HTML URL */
400
+ html_url: string;
401
+ /** Owner followers URL */
402
+ followers_url: string;
403
+ /** Owner starred URL */
404
+ starred_url: string;
405
+ /** Owner repos URL */
406
+ repos_url: string;
407
+ /** Owner events URL */
408
+ events_url: string;
409
+ }
410
+ /**
411
+ * GitHub repository information
412
+ * From ListReposResponse.GitHubRepos
413
+ */
414
+ interface OauthGitHubRepo$1 {
415
+ /** Repository name */
416
+ name: string;
417
+ /** Full repository name (owner/repo) */
418
+ full_name: string;
419
+ /** Whether the repository is private */
420
+ private: boolean;
421
+ /** Repository HTML URL */
422
+ html_url: string;
423
+ /** Repository API URL */
424
+ url: string;
425
+ /** Repository teams URL */
426
+ teams_url: string;
427
+ /** Repository hooks URL */
428
+ hooks_url: string;
429
+ /** Repository events URL */
430
+ events_url: string;
431
+ /** Repository branches URL */
432
+ branches_url: string;
433
+ /** Repository git commits URL */
434
+ git_commits_url: string;
435
+ /** Repository merges URL */
436
+ merges_url: string;
437
+ /** Repository pulls URL */
438
+ pulls_url: string;
439
+ /** Repository git URL */
440
+ git_url: string;
441
+ /** Repository clone URL */
442
+ clone_url: string;
443
+ /** Repository SVN URL */
444
+ svn_url: string;
445
+ /** Repository downloads URL */
446
+ downloads_url: string;
447
+ /** Repository description */
448
+ description: string;
449
+ /** Repository owner */
450
+ owner: OauthGitHubRepoOwner;
451
+ /** Number of forks */
452
+ forks_count: number;
453
+ }
454
+ /**
455
+ * Gongfeng repository namespace information
456
+ */
457
+ interface OauthGongFengRepoNamespace {
458
+ /** Namespace name */
459
+ name: string;
460
+ /** Namespace description */
461
+ description: string;
462
+ /** Namespace path */
463
+ path: string;
464
+ }
465
+ /**
466
+ * Gongfeng repository owner information
467
+ */
468
+ interface OauthGongFengRepoOwner {
469
+ /** Owner username */
470
+ username: string;
471
+ /** Owner web URL */
472
+ web_url: string;
473
+ /** Owner name */
474
+ name: string;
475
+ /** Owner state */
476
+ state: string;
477
+ /** Owner avatar URL */
478
+ avatar_url: string;
479
+ }
480
+ /**
481
+ * Gongfeng (工蜂) repository information
482
+ * From ListReposResponse.GongFengRepos
483
+ */
484
+ interface OauthGongFengRepo$1 {
485
+ /** Repository ID */
486
+ id: number;
487
+ /** Repository description */
488
+ description: string;
489
+ /** Whether the repository is public */
490
+ public: boolean;
491
+ /** Whether the repository is archived */
492
+ archived: boolean;
493
+ /** Visibility level */
494
+ visibility_level: string;
495
+ /** Public visibility */
496
+ public_visibility: number;
497
+ /** Repository namespace */
498
+ namespace: OauthGongFengRepoNamespace;
499
+ /** Repository owner */
500
+ owner: OauthGongFengRepoOwner;
501
+ /** Repository name */
502
+ name: string;
503
+ /** Name with namespace */
504
+ name_with_namespace: string;
505
+ /** Repository path */
506
+ path: string;
507
+ /** Path with namespace */
508
+ path_with_namespace: string;
509
+ /** Repository type (Git/SVN) */
510
+ type: string;
511
+ /** Default branch */
512
+ default_branch: string;
513
+ /** SSH URL to repository */
514
+ ssh_url_to_repo: string;
515
+ /** HTTP URL to repository */
516
+ http_url_to_repo: string;
517
+ /** HTTPS URL to repository */
518
+ https_url_to_repo: string;
519
+ /** Web URL */
520
+ web_url: string;
521
+ /** Avatar URL */
522
+ avatar_url: string;
523
+ /** Forked from project */
524
+ forked_from_project: string;
525
+ }
526
+ /**
527
+ * CNB repository information
528
+ * From ListReposResponse.CNBRepos
529
+ */
530
+ interface OauthCNBRepo$1 {
531
+ /** Created timestamp */
532
+ created_at: string;
533
+ /** Repository description */
534
+ description: string;
535
+ /** Repository name */
536
+ name: string;
537
+ /** Repository path */
538
+ path: string;
539
+ /** Repository site */
540
+ site: string;
541
+ /** Repository status */
542
+ status: number;
543
+ /** Repository topics */
544
+ topics: string;
545
+ /** Visibility level */
546
+ visibility_level: string;
547
+ /** Web URL */
548
+ web_url: string;
549
+ }
550
+ /**
551
+ * Response for listing repositories
552
+ * GET /console/as/connector/oauth/{name}/repos
347
553
  */
554
+ interface ListReposResponse$1 {
555
+ /**
556
+ * GitHub repositories grouped by installation id
557
+ * Map: installation_id => repository list
558
+ */
559
+ github_repos?: Record<number, OauthGitHubRepo$1[]>;
560
+ /** Gongfeng repositories */
561
+ gongfeng_repos?: OauthGongFengRepo$1[];
562
+ /** CNB repositories */
563
+ cnb_repos?: OauthCNBRepo$1[];
564
+ }
565
+ //#endregion
566
+ //#region ../agent-provider/lib/backend/types.d.ts
567
+ type OauthConnectorName = OauthConnectorName$1;
568
+ type OauthBranch = OauthBranch$1;
569
+ type GitHubBranchParams = GitHubBranchParams$1;
570
+ type GongfengBranchParams = GongfengBranchParams$1;
571
+ type CNBBranchParams = CNBBranchParams$1;
572
+ type OauthGitHubRepo = OauthGitHubRepo$1;
573
+ type OauthGongFengRepo = OauthGongFengRepo$1;
574
+ type OauthCNBRepo = OauthCNBRepo$1;
575
+ type ListReposResponse = ListReposResponse$1;
348
576
  /**
349
577
  * 账号版本类型
350
578
  */
@@ -433,6 +661,13 @@ interface AccountPlan {
433
661
  /** 所有套餐资源列表 */
434
662
  resources?: PlanResource[];
435
663
  }
664
+ /**
665
+ * 账号类型
666
+ * - sso: SSO 登录账号
667
+ * - unified: 统一登录账号
668
+ * - 空字符串: 普通账号
669
+ */
670
+ type AccountType = 'sso' | 'unified' | '';
436
671
  /**
437
672
  * 账号信息
438
673
  */
@@ -459,6 +694,8 @@ interface Account {
459
694
  pluginEnabled?: boolean;
460
695
  /** 部署状态 */
461
696
  deployStatus?: DeployStatus;
697
+ /** 账号类型 */
698
+ accountType?: AccountType;
462
699
  /** 是否是 Pro 版本 */
463
700
  isPro?: boolean;
464
701
  /** 到期时间戳 */
@@ -517,6 +754,7 @@ interface UserConnector {
517
754
  oauthClientId: string;
518
755
  /** OAuth 重定向 URL */
519
756
  oauthRedirectUrl: string;
757
+ oauthAppName: string;
520
758
  }
521
759
  /**
522
760
  * 获取用户连接器列表响应
@@ -590,6 +828,7 @@ interface TaskConnector {
590
828
  connect_at: string;
591
829
  /** 连接状态,0未连接,1已连接 */
592
830
  connectStatus: 0 | 1;
831
+ oauthAppName: string;
593
832
  }
594
833
  /**
595
834
  * 添加任务请求
@@ -679,84 +918,6 @@ interface RevokeAllRequest {
679
918
  /** 安装ID列表(可选,如果不传则撤销所有) */
680
919
  installationIds?: string[];
681
920
  }
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
921
  /**
761
922
  * 获取仓库列表响应
762
923
  */
@@ -764,8 +925,8 @@ interface GetRepoListResponse {
764
925
  github_repos?: {
765
926
  [key: string | number]: OauthGitHubRepo[];
766
927
  };
767
- gongfeng_repos?: OauthGongfengRepo[];
768
- cnb_repos?: OauthCnbRepo[];
928
+ gongfeng_repos?: OauthGongFengRepo[];
929
+ cnb_repos?: OauthCNBRepo[];
769
930
  }
770
931
  /**
771
932
  * OAuth 用户信息
@@ -966,6 +1127,12 @@ interface IBackendProvider {
966
1127
  * 用于 Local 模式下点击 Logo 返回 IDE
967
1128
  */
968
1129
  closeAgentManager?(): Promise<void>;
1130
+ /**
1131
+ * 在外部浏览器中打开链接(可选,仅 IPC 环境支持)
1132
+ * 用于 Local 模式下打开外部 URL
1133
+ * @param url 要打开的 URL
1134
+ */
1135
+ openExternal?(url: string): Promise<void>;
969
1136
  /**
970
1137
  * 监听事件(可选,用于 IPC 环境)
971
1138
  * @param event 事件名称
@@ -978,6 +1145,34 @@ interface IBackendProvider {
978
1145
  * @returns Promise<EnterpriseUsage | null> 企业用户用量信息
979
1146
  */
980
1147
  getEnterpriseUsage?(enterpriseId: string): Promise<EnterpriseUsage | null>;
1148
+ /**
1149
+ * 刷新 Token(可选)
1150
+ * 通过调用 getAccount 刷新 cookie
1151
+ * 适用于 Cloud 场景下页面切换回来时刷新登录态
1152
+ * @returns Promise<Account | null> 刷新后的账号信息
1153
+ */
1154
+ refreshToken?(): Promise<Account | null>;
1155
+ /**
1156
+ * 获取仓库分支列表
1157
+ * API 端点: GET /console/as/connector/oauth/{name}/branches
1158
+ *
1159
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
1160
+ * @param params 平台特定的查询参数
1161
+ * @param page 页码,从1开始,0表示不分页获取全部
1162
+ * @param perPage 每页数量,最大100
1163
+ * @returns Promise<OauthBranch[]> 分支列表
1164
+ */
1165
+ getBranches?(connector: OauthConnectorName, params: GitHubBranchParams | GongfengBranchParams | CNBBranchParams, page?: number, perPage?: number): Promise<OauthBranch[]>;
1166
+ /**
1167
+ * 获取仓库列表
1168
+ * API 端点: GET /console/as/connector/oauth/{name}/repos
1169
+ *
1170
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
1171
+ * @param page 页码,从1开始,0表示不分页获取全部
1172
+ * @param perPage 每页数量,最大100
1173
+ * @returns Promise<ListReposResponse> 仓库列表响应
1174
+ */
1175
+ getRepositories?(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
981
1176
  }
982
1177
  /**
983
1178
  * 场景中的插件信息
@@ -991,6 +1186,12 @@ interface ScenePlugin {
991
1186
  /** 插件市场名称 */
992
1187
  marketplaceName: string;
993
1188
  }
1189
+ /**
1190
+ * 场景模式类型
1191
+ * - coding: 编程相关场景
1192
+ * - working: 工作/通用场景
1193
+ */
1194
+ type SupportSceneMode = 'coding' | 'working';
994
1195
  /**
995
1196
  * 支持的场景信息
996
1197
  * 用于 Welcome 页面的 QuickActions 快捷操作
@@ -1005,11 +1206,15 @@ interface SupportScene {
1005
1206
  plugins: ScenePlugin[];
1006
1207
  /** 场景对应的 prompt 列表 */
1007
1208
  prompts: string[];
1209
+ /** 场景模式类型 */
1210
+ mode?: SupportSceneMode;
1008
1211
  }
1009
1212
  /**
1010
1213
  * 插件作用域
1214
+ * 使用 agent-craft 的 PluginInstallScope 类型
1215
+ * 注意: 当前后端 API 只支持 user 和 project,暂不支持 project-local
1011
1216
  */
1012
- type PluginScope = 'user' | 'project';
1217
+ type PluginScope = 'user' | 'project' | 'project-local';
1013
1218
  /**
1014
1219
  * 插件操作类型
1015
1220
  */
@@ -1428,6 +1633,15 @@ interface AgentConnection {
1428
1633
  error?: string;
1429
1634
  }>;
1430
1635
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
1636
+ /**
1637
+ * Report telemetry event through the standard provider chain
1638
+ * - Local: via ACP JSON-RPC → IDE EventService
1639
+ * - Cloud: via StreamableHTTP → cloud telemetry endpoint
1640
+ *
1641
+ * @param eventName - Event name / code
1642
+ * @param payload - Event data (already includes mode)
1643
+ */
1644
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
1431
1645
  }
1432
1646
  /**
1433
1647
  * Base configuration for connections
@@ -1635,6 +1849,8 @@ interface BaseAgentState {
1635
1849
  updatedAt?: Date;
1636
1850
  /** 是否为 playground */
1637
1851
  isPlayground?: boolean;
1852
+ /** Whether the title is user defined (1 = user defined) */
1853
+ isUserDefinedTitle?: number;
1638
1854
  }
1639
1855
  /**
1640
1856
  * LocalAgentState - 本地 Agent 状态
@@ -1781,16 +1997,38 @@ interface SessionInfo {
1781
1997
  cwd?: string;
1782
1998
  /** Whether the session is a playground */
1783
1999
  isPlayground?: boolean;
2000
+ /** Whether the title is user defined (1 = user defined) */
2001
+ isUserDefinedTitle?: number;
1784
2002
  }
1785
2003
  /**
1786
2004
  * Parameters for creating a new session
1787
2005
  */
1788
2006
  interface CreateSessionParams$1 {
1789
- /** Working directory */
2007
+ /** Working directory (required) */
1790
2008
  cwd: string;
2009
+ /** Optional configuration */
2010
+ options?: CreateSessionOptions;
2011
+ }
2012
+ /**
2013
+ * Optional configuration for creating a session
2014
+ */
2015
+ interface CreateSessionOptions {
1791
2016
  /** MCP server configurations */
1792
2017
  mcpServers?: McpServerConfig[];
2018
+ /** Initial prompt for the session (Cloud only) */
2019
+ prompt?: string;
2020
+ /** Initial model for the session (Cloud only) */
2021
+ model?: string;
2022
+ /** Mode ID (e.g., 'craft', 'architect') */
2023
+ mode?: string;
2024
+ /** Whether this is a playground session (no cwd) */
2025
+ isPlayground?: boolean;
2026
+ /** Tags for template scenes (Cloud only, format: { scene: 'xxx' }) */
2027
+ tags?: Record<string, string>;
2028
+ /** Additional metadata */
1793
2029
  _meta?: Record<string, unknown>;
2030
+ /** Callback when session is prepared (POST succeeded, before WebSocket connect) */
2031
+ onSessionPrepared?: (sessionInfo: SessionInfo) => void;
1794
2032
  }
1795
2033
  /**
1796
2034
  * Parameters for loading an existing session
@@ -1825,6 +2063,15 @@ interface InitializeWorkspaceResponse {
1825
2063
  /** Error message (if failed) */
1826
2064
  error?: string;
1827
2065
  }
2066
+ /**
2067
+ * Parameters for getting available commands
2068
+ */
2069
+ interface GetAvailableCommandsParams {
2070
+ /** Session ID to get commands for (optional, for global commands) */
2071
+ sessionId?: string;
2072
+ /** Workspace path for getting custom commands (optional) */
2073
+ workspacePath?: string;
2074
+ }
1828
2075
  /**
1829
2076
  * Prompts resource interface (ACP verbs)
1830
2077
  * Operations use the current session automatically
@@ -1862,7 +2109,7 @@ interface ModelsResource {
1862
2109
  */
1863
2110
  interface PromptResponse {
1864
2111
  /** Stop reason */
1865
- stopReason: 'end_turn' | 'max_tokens' | 'tool_use' | 'cancelled' | 'error';
2112
+ stopReason: StopReason;
1866
2113
  /** Response metadata */
1867
2114
  _meta?: Record<string, unknown>;
1868
2115
  }
@@ -1872,7 +2119,7 @@ interface PromptResponse {
1872
2119
  interface SessionsResourceEvents {
1873
2120
  /** Emitted when the sessions list changes (create, delete, update) */
1874
2121
  sessionsChanged: SessionInfo[];
1875
- /** Emitted when a new session is created */
2122
+ /** Emitted when a new session is fully connected and ready */
1876
2123
  sessionCreated: SessionInfo;
1877
2124
  /** Emitted when a session is deleted */
1878
2125
  sessionDeleted: {
@@ -1956,6 +2203,8 @@ interface ActiveSession {
1956
2203
  readonly id: string;
1957
2204
  /** Agent ID */
1958
2205
  readonly agentId: string;
2206
+ /** Actual workspace path (set after newSession, useful for Playground scenario) */
2207
+ readonly cwd?: string;
1959
2208
  /** Agent state (direct access to underlying agent state) */
1960
2209
  readonly agentState: AgentState;
1961
2210
  /** Agent capabilities (available after connection) */
@@ -1999,7 +2248,7 @@ interface ActiveSession {
1999
2248
  error?: string;
2000
2249
  }>;
2001
2250
  /** Set the current session mode */
2002
- setMode(modeId: string): Promise<void>;
2251
+ setMode(modeId: string, skipChecker?: boolean): Promise<void>;
2003
2252
  /** Set the current session model */
2004
2253
  setSessionModel(modelId: string): Promise<void>;
2005
2254
  /** Set available commands (called when available_commands_update is received) */
@@ -2142,6 +2391,13 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2142
2391
  * @returns Response with search results
2143
2392
  */
2144
2393
  searchFile?(params: SearchFileParams): Promise<SearchFileResponse>;
2394
+ /**
2395
+ * Get subagent list (optional, used by LocalAgentProvider)
2396
+ *
2397
+ * @param params - Query parameters including options
2398
+ * @returns Response with subagent list
2399
+ */
2400
+ getSubagentList?(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2145
2401
  /**
2146
2402
  * Batch toggle plugins (optional, used by LocalAgentProvider)
2147
2403
  *
@@ -2169,12 +2425,22 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2169
2425
  * @param pluginNames - Array of plugin names to install
2170
2426
  * @param marketplaceName - Marketplace name
2171
2427
  * @param installScope - Install scope ('user' | 'project')
2428
+ * @param marketplaceSource - Marketplace source URL (for auto-adding marketplace when not exists)
2172
2429
  * @returns Result of the operation
2173
2430
  */
2174
- installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2431
+ installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2175
2432
  success: boolean;
2176
2433
  error?: string;
2177
2434
  }>;
2435
+ /**
2436
+ * Get available commands for a session (optional, used by LocalAgentProvider)
2437
+ * If session.availableCommands has cached values, return them
2438
+ * Otherwise, fetch from product configuration
2439
+ *
2440
+ * @param params - Parameters for getting commands
2441
+ * @returns Array of available commands
2442
+ */
2443
+ getAvailableCommands?(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2178
2444
  /**
2179
2445
  * Register an event listener
2180
2446
  * Provider implementations should forward events to the underlying transport
@@ -2190,6 +2456,49 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2190
2456
  * @param handler - Event handler function to remove
2191
2457
  */
2192
2458
  off?(event: string, handler: (...args: any[]) => void): void;
2459
+ /**
2460
+ * Report telemetry event through the provider chain
2461
+ * - Local: via ACP JSON-RPC → AcpAgent → IDE EventService
2462
+ * - Cloud: via connection → cloud endpoint
2463
+ *
2464
+ * @param eventName - Event name / code
2465
+ * @param payload - Event data
2466
+ */
2467
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2468
+ /**
2469
+ * Respond to MCP Sampling confirmation request (optional, used by LocalAgentProvider)
2470
+ * Called when user confirms/rejects a sampling request
2471
+ *
2472
+ * @param sessionId - Session ID
2473
+ * @param response - Sampling confirmation response
2474
+ */
2475
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2476
+ /**
2477
+ * Respond to MCP Roots confirmation request (optional, used by LocalAgentProvider)
2478
+ * Called when user confirms/rejects a roots request
2479
+ *
2480
+ * @param sessionId - Session ID
2481
+ * @param response - Roots confirmation response
2482
+ */
2483
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2484
+ /**
2485
+ * Subscribe to MCP Sampling confirmation requests (optional, used by LocalAgentProvider)
2486
+ * Called when MCP server initiates a sampling request
2487
+ *
2488
+ * @param serverName - MCP server name
2489
+ * @param callback - Request callback
2490
+ * @returns Unsubscribe function
2491
+ */
2492
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
2493
+ /**
2494
+ * Subscribe to MCP Roots confirmation requests (optional, used by LocalAgentProvider)
2495
+ * Called when MCP server initiates a roots request
2496
+ *
2497
+ * @param serverName - MCP server name
2498
+ * @param callback - Request callback
2499
+ * @returns Unsubscribe function
2500
+ */
2501
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
2193
2502
  }
2194
2503
  /**
2195
2504
  * AgentClient initialization options
@@ -2277,6 +2586,8 @@ interface ClientSessionsResource {
2277
2586
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
2278
2587
  /** Search for files in the workspace (for LocalAgentProvider) */
2279
2588
  searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
2589
+ /** Get subagent list (for LocalAgentProvider) */
2590
+ getSubagentList(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2280
2591
  /** Batch toggle plugins (for LocalAgentProvider) */
2281
2592
  batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2282
2593
  /** Get installed plugins (for LocalAgentProvider) */
@@ -2289,15 +2600,32 @@ interface ClientSessionsResource {
2289
2600
  installScope?: 'user' | 'project';
2290
2601
  }>>;
2291
2602
  /** Install plugins (for LocalAgentProvider) */
2292
- installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2603
+ installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2293
2604
  success: boolean;
2294
2605
  error?: string;
2295
2606
  }>;
2296
2607
  /**
2297
2608
  * Get support scenes from backend API (for LocalAgentProvider)
2298
2609
  * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
2610
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2611
+ */
2612
+ getSupportScenes(locale?: string): Promise<Array<{
2613
+ id: number;
2614
+ name: string;
2615
+ plugins: Array<{
2616
+ id: number;
2617
+ name: string;
2618
+ marketplaceName: string;
2619
+ }>;
2620
+ prompts: string[];
2621
+ mode?: 'coding' | 'working';
2622
+ }>>;
2623
+ /**
2624
+ * Get product scenes from ProductManager configuration (for LocalAgentProvider)
2625
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
2626
+ * @param locale - 可选,语言环境
2299
2627
  */
2300
- getSupportScenes(): Promise<Array<{
2628
+ getProductScenes?(locale?: string): Promise<Array<{
2301
2629
  id: number;
2302
2630
  name: string;
2303
2631
  plugins: Array<{
@@ -2306,7 +2634,145 @@ interface ClientSessionsResource {
2306
2634
  marketplaceName: string;
2307
2635
  }>;
2308
2636
  prompts: string[];
2637
+ mode?: 'coding' | 'working';
2638
+ target?: 'local' | 'cloud' | 'all';
2309
2639
  }>>;
2640
+ /**
2641
+ * Get available commands for a session
2642
+ * If session.availableCommands has cached values, return them
2643
+ * Otherwise, fetch from provider (for LocalAgentProvider)
2644
+ * @param params - Parameters for getting commands
2645
+ * @returns Promise<AvailableCommand[]> - Array of available commands
2646
+ */
2647
+ getAvailableCommands(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2648
+ /**
2649
+ * Report telemetry event through the provider chain
2650
+ * Delegates to AgentProvider.reportTelemetry()
2651
+ *
2652
+ * @param eventName - Event name / code
2653
+ * @param payload - Event data
2654
+ */
2655
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2656
+ /**
2657
+ * Respond to MCP Sampling confirmation request
2658
+ * Called when user confirms/rejects a sampling request in MCP tool renderer
2659
+ *
2660
+ * @param sessionId - Session ID
2661
+ * @param response - Sampling confirmation response
2662
+ */
2663
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2664
+ /**
2665
+ * Respond to MCP Roots confirmation request
2666
+ * Called when user confirms/rejects a roots request in MCP tool renderer
2667
+ *
2668
+ * @param sessionId - Session ID
2669
+ * @param response - Roots confirmation response
2670
+ */
2671
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2672
+ /**
2673
+ * Subscribe to MCP Sampling confirmation requests
2674
+ * Called when MCP server initiates a sampling request
2675
+ *
2676
+ * @param serverName - MCP server name
2677
+ * @param callback - Request callback
2678
+ * @returns Unsubscribe function
2679
+ */
2680
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
2681
+ /**
2682
+ * Subscribe to MCP Roots confirmation requests
2683
+ * Called when MCP server initiates a roots request
2684
+ *
2685
+ * @param serverName - MCP server name
2686
+ * @param callback - Request callback
2687
+ * @returns Unsubscribe function
2688
+ */
2689
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
2690
+ }
2691
+ /**
2692
+ * MCP Sampling message role
2693
+ */
2694
+ type McpSamplingRole = 'user' | 'assistant';
2695
+ /**
2696
+ * MCP Sampling message content - text
2697
+ */
2698
+ interface McpSamplingTextContent {
2699
+ type: 'text';
2700
+ text: string;
2701
+ }
2702
+ /**
2703
+ * MCP Sampling message content - image
2704
+ */
2705
+ interface McpSamplingImageContent {
2706
+ type: 'image';
2707
+ data: string;
2708
+ mimeType: string;
2709
+ }
2710
+ /**
2711
+ * MCP Sampling message content - audio
2712
+ */
2713
+ interface McpSamplingAudioContent {
2714
+ type: 'audio';
2715
+ data: string;
2716
+ mimeType: string;
2717
+ }
2718
+ /**
2719
+ * MCP Sampling message content union type
2720
+ */
2721
+ type McpSamplingContent = McpSamplingTextContent | McpSamplingImageContent | McpSamplingAudioContent;
2722
+ /**
2723
+ * MCP Sampling message
2724
+ */
2725
+ interface McpSamplingMessage {
2726
+ role: McpSamplingRole;
2727
+ content: McpSamplingContent;
2728
+ }
2729
+ /**
2730
+ * MCP Sampling confirmation request
2731
+ * Sent from backend when MCP server requests sampling
2732
+ */
2733
+ interface McpSamplingConfirmRequest {
2734
+ id: string;
2735
+ serverName: string;
2736
+ model?: string;
2737
+ messages: McpSamplingMessage[];
2738
+ systemPrompt?: string;
2739
+ maxTokens: number;
2740
+ timestamp: number;
2741
+ }
2742
+ /**
2743
+ * MCP Sampling confirmation response
2744
+ * Sent from frontend when user confirms/rejects
2745
+ */
2746
+ interface McpSamplingConfirmResponse {
2747
+ id: string;
2748
+ approved: boolean;
2749
+ rememberChoice?: boolean;
2750
+ }
2751
+ /**
2752
+ * MCP Root definition
2753
+ */
2754
+ interface McpRoot {
2755
+ uri: string;
2756
+ name?: string;
2757
+ }
2758
+ /**
2759
+ * MCP Roots confirmation request
2760
+ * Sent from backend when MCP server requests roots access
2761
+ */
2762
+ interface McpRootsConfirmRequest {
2763
+ id: string;
2764
+ serverName: string;
2765
+ roots: McpRoot[];
2766
+ timestamp: number;
2767
+ }
2768
+ /**
2769
+ * MCP Roots confirmation response
2770
+ * Sent from frontend when user confirms/rejects
2771
+ */
2772
+ interface McpRootsConfirmResponse {
2773
+ id: string;
2774
+ approved: boolean;
2775
+ rememberChoice?: boolean;
2310
2776
  }
2311
2777
  /**
2312
2778
  * Workspace information (aligned with FolderSelectResult)
@@ -2372,6 +2838,8 @@ interface PickFolderResponse {
2372
2838
  interface UploadFileParams {
2373
2839
  /** Files to upload - File objects in browser, absolute path strings in IDE */
2374
2840
  readonly files: Array<File | string>;
2841
+ /** Optional AbortSignal to cancel the upload */
2842
+ readonly abortSignal?: AbortSignal;
2375
2843
  }
2376
2844
  /**
2377
2845
  * Response from uploading files
@@ -2385,6 +2853,8 @@ interface UploadFileResponse {
2385
2853
  readonly expireSeconds?: number;
2386
2854
  /** Error message (if upload failed) */
2387
2855
  readonly error?: string;
2856
+ /** Whether the upload was cancelled by user */
2857
+ readonly aborted?: boolean;
2388
2858
  }
2389
2859
  /**
2390
2860
  * Mention type for file/folder
@@ -2435,6 +2905,52 @@ interface SearchFileResponse {
2435
2905
  /** Error message (if failed) */
2436
2906
  readonly error?: string;
2437
2907
  }
2908
+ /**
2909
+ * Subagent information
2910
+ */
2911
+ interface SubagentInfo {
2912
+ /** Subagent name */
2913
+ name: string;
2914
+ /** Subagent description */
2915
+ description: string;
2916
+ /** System prompt */
2917
+ systemPrompt: string;
2918
+ /** File path */
2919
+ filePath?: string;
2920
+ /** Model type */
2921
+ model?: string;
2922
+ /** Agent mode */
2923
+ agentMode?: 'agentic' | 'manual';
2924
+ /** Whether enabled */
2925
+ enabled?: boolean;
2926
+ /** Model ID */
2927
+ modelID?: string;
2928
+ /** Subagent level */
2929
+ level?: 'project' | 'user';
2930
+ }
2931
+ /**
2932
+ * Parameters for getting subagent list
2933
+ */
2934
+ interface GetSubagentListParams {
2935
+ /** Search options */
2936
+ readonly options: {
2937
+ /** Search keyword (filter by name or description) */readonly search?: string; /** Limit number of results */
2938
+ readonly resultNum?: number; /** Agent mode filter */
2939
+ readonly agentMode?: 'agentic' | 'manual' | 'all'; /** Whether to return only enabled subagents */
2940
+ readonly onlyEnabled?: boolean;
2941
+ };
2942
+ /** Working directory (optional, for filtering project-level subagents) */
2943
+ readonly cwd?: string;
2944
+ }
2945
+ /**
2946
+ * Response from getting subagent list
2947
+ */
2948
+ interface GetSubagentListResponse {
2949
+ /** Subagent list */
2950
+ readonly results: SubagentInfo[];
2951
+ /** Error message (if failed) */
2952
+ readonly error?: string;
2953
+ }
2438
2954
  //#endregion
2439
2955
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
2440
2956
  /**
@@ -2513,6 +3029,7 @@ declare class CloudAgentConnection implements AgentConnection {
2513
3029
  * Contains sandboxId, link, token, etc.
2514
3030
  */
2515
3031
  get sessionConnectionInfo(): SessionConnectionInfo | undefined;
3032
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2516
3033
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2517
3034
  }
2518
3035
  //#endregion
@@ -2691,8 +3208,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2691
3208
  /**
2692
3209
  * Create a new conversation
2693
3210
  * POST {endpoint}/console/as/conversations
3211
+ * @param params - Session params containing cwd and optional configuration
2694
3212
  */
2695
- create(): Promise<string>;
3213
+ create(params: CreateSessionParams$1): Promise<string>;
2696
3214
  /**
2697
3215
  * Connect to an agent and return the connection
2698
3216
  *
@@ -2778,7 +3296,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2778
3296
  /**
2779
3297
  * Upload files to cloud storage via COS presigned URL
2780
3298
  *
2781
- * @param params - files array (File objects in browser)
3299
+ * @param params - files array (File objects in browser), optional abortSignal
2782
3300
  * @returns Response with corresponding cloud URLs
2783
3301
  */
2784
3302
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
@@ -2802,17 +3320,23 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2802
3320
  private emitEvent;
2803
3321
  /**
2804
3322
  * 获取支持的场景列表
2805
- * API 端点: GET /console/as/support/scenes
3323
+ * API 端点: GET /v2/as/support/scenes (不鉴权)
2806
3324
  * 用于 Welcome 页面的 QuickActions 快捷操作
2807
3325
  *
3326
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2808
3327
  * @returns Promise<SupportScene[]> 支持的场景列表
2809
3328
  */
2810
- getSupportScenes(): Promise<SupportScene[]>;
3329
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
2811
3330
  private toAgentState;
2812
3331
  /**
2813
3332
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
2814
3333
  */
2815
3334
  private buildGetUrl;
3335
+ /**
3336
+ * 上报 telemetry 事件(Cloud 模式)
3337
+ * 通过 HTTP POST 发送到 /v2/report
3338
+ */
3339
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2816
3340
  }
2817
3341
  //#endregion
2818
3342
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
@@ -2991,6 +3515,7 @@ interface ActiveSessionImplOptions {
2991
3515
  declare class ActiveSessionImpl implements ActiveSession {
2992
3516
  private _id;
2993
3517
  private _agentId;
3518
+ private _cwd?;
2994
3519
  private _availableModes?;
2995
3520
  private _currentMode?;
2996
3521
  private _availableModels?;
@@ -3002,6 +3527,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3002
3527
  private _connectionInfo?;
3003
3528
  private listeners;
3004
3529
  private onceListeners;
3530
+ private connectionListeners;
3005
3531
  /**
3006
3532
  * Agent operations namespace
3007
3533
  */
@@ -3035,6 +3561,14 @@ declare class ActiveSessionImpl implements ActiveSession {
3035
3561
  * Agent ID
3036
3562
  */
3037
3563
  get agentId(): string;
3564
+ /**
3565
+ * Actual workspace path (set from newSession response _meta)
3566
+ */
3567
+ get cwd(): string | undefined;
3568
+ /**
3569
+ * Set actual workspace path (called by SessionManager after createSession)
3570
+ */
3571
+ setCwd(cwd: string): void;
3038
3572
  /**
3039
3573
  * Agent state (live connection state)
3040
3574
  * Returns LocalAgentState or CloudAgentState based on transport type
@@ -3140,7 +3674,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3140
3674
  * await session.setMode('architect');
3141
3675
  * ```
3142
3676
  */
3143
- setMode(modeId: string): Promise<void>;
3677
+ setMode(modeId: string, skipAvailableChecker?: boolean): Promise<void>;
3144
3678
  /**
3145
3679
  * Set the current session model
3146
3680
  *
@@ -3193,8 +3727,22 @@ declare class ActiveSessionImpl implements ActiveSession {
3193
3727
  */
3194
3728
  [Symbol.dispose](): void;
3195
3729
  private getConnectionOrThrow;
3730
+ /**
3731
+ * 在 connection 上注册 listener 并保存引用,便于 disconnect 时移除
3732
+ */
3733
+ private addConnectionListener;
3734
+ /**
3735
+ * 从 connection 上移除所有本 session 注册的 listener
3736
+ */
3737
+ private removeConnectionListeners;
3196
3738
  private setupConnectionEvents;
3197
3739
  private mapPromptResponse;
3740
+ /**
3741
+ * 判断 artifact 是否应该转发给当前 session
3742
+ * - media 类型:按 cwd 路径隔离(同 cwd 下不同 session 可共享 media)
3743
+ * - 其余类型:按 __sessionId 严格隔离
3744
+ */
3745
+ private shouldForwardArtifact;
3198
3746
  }
3199
3747
  //#endregion
3200
3748
  //#region ../agent-provider/lib/common/client/session-manager.d.ts
@@ -3271,6 +3819,18 @@ declare class SessionManager {
3271
3819
  * 7. Return ActiveSession instance (cached)
3272
3820
  */
3273
3821
  loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
3822
+ /**
3823
+ * 从 ACP response 中提取可用模型列表
3824
+ *
3825
+ * 优先级:
3826
+ * 1. response.models._meta?.['codebuddy.ai']?.availableModels - 包含完整的模型信息(字段名为 'id')
3827
+ * 2. response.models?.availableModels - 只包含基本信息(字段名为 'modelId')
3828
+ * 3. undefined - 都没有时返回 undefined
3829
+ *
3830
+ * @param response - ACP 响应对象
3831
+ * @returns ModelInfo[] | undefined
3832
+ */
3833
+ protected extractAvailableModels(response: LoadSessionResponse): ModelInfo[] | undefined;
3274
3834
  }
3275
3835
  //#endregion
3276
3836
  //#region ../agent-provider/lib/backend/backend-provider.d.ts
@@ -3287,6 +3847,13 @@ declare class SessionManager {
3287
3847
  */
3288
3848
  declare class BackendProvider implements IBackendProvider {
3289
3849
  constructor(config: BackendProviderConfig);
3850
+ /**
3851
+ * 处理 401 未授权错误
3852
+ * 先尝试刷新 token,失败后再执行登出流程
3853
+ *
3854
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
3855
+ */
3856
+ protected handleUnauthorized(): Promise<void>;
3290
3857
  /**
3291
3858
  * 获取当前账号信息
3292
3859
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3410,6 +3977,38 @@ declare class BackendProvider implements IBackendProvider {
3410
3977
  * API: POST /billing/meter/get-enterprise-user-usage
3411
3978
  */
3412
3979
  getEnterpriseUsage(enterpriseId: string): Promise<EnterpriseUsage | null>;
3980
+ /**
3981
+ * 刷新 Token
3982
+ * 通过调用 getAccount 刷新 cookie,适用于 Cloud 场景下页面切换回来时刷新登录态
3983
+ * @returns Promise<Account | null> 刷新后的账号信息
3984
+ */
3985
+ refreshToken(): Promise<Account | null>;
3986
+ /**
3987
+ * 获取仓库分支列表
3988
+ * API 端点: GET /console/as/connector/oauth/{name}/branches
3989
+ *
3990
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
3991
+ * @param params 平台特定的查询参数
3992
+ * @param page 页码,从1开始,0表示不分页获取全部
3993
+ * @param perPage 每页数量,最大100
3994
+ * @returns Promise<OauthBranch[]> 分支列表
3995
+ */
3996
+ getBranches(connector: OauthConnectorName, params: GitHubBranchParams | GongfengBranchParams | CNBBranchParams, page?: number, perPage?: number): Promise<OauthBranch[]>;
3997
+ /**
3998
+ * 获取仓库列表
3999
+ * API 端点: GET /console/as/connector/oauth/{name}/repos
4000
+ *
4001
+ * Note: 由于工蜂原生支持的 Search 能力会匹配 path/name/description 部分,
4002
+ * 且不支持定制,不满足产品要求(只按 name 匹配),因此前端拉取全量数据后做筛选。
4003
+ *
4004
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
4005
+ * @param page 页码,从1开始,0表示不分页获取全部
4006
+ * - GitHub 只支持全量数据,必须传 0
4007
+ * - 工蜂和 CNB 依据前端逻辑而定
4008
+ * @param perPage 每页数量,最大100
4009
+ * @returns Promise<ListReposResponse> 仓库列表响应
4010
+ */
4011
+ getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
3413
4012
  }
3414
4013
  /**
3415
4014
  * 创建 BackendProvider 实例
@@ -3543,6 +4142,12 @@ declare class IPCBackendProvider implements IBackendProvider {
3543
4142
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
3544
4143
  */
3545
4144
  closeAgentManager(): Promise<void>;
4145
+ /**
4146
+ * 在外部浏览器中打开链接
4147
+ * IDE 环境: 通过 IPC 通知 IDE 使用 vscode.env.openExternal 打开 URL
4148
+ * @param url 要打开的 URL
4149
+ */
4150
+ openExternal(url: string): Promise<void>;
3546
4151
  /**
3547
4152
  * 批量切换插件状态
3548
4153
  * IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
@@ -3614,7 +4219,7 @@ type UnauthorizedCallback = () => void;
3614
4219
  * 特性:
3615
4220
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3616
4221
  * - 支持拦截器注册(其他模块可注入 header)
3617
- * - 统一 401/403 处理
4222
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3618
4223
  * - 自动携带凭证(withCredentials)
3619
4224
  * - 类型安全
3620
4225
  *
@@ -3650,6 +4255,10 @@ declare class HttpService {
3650
4255
  private axiosInstance;
3651
4256
  private unauthorizedCallbacks;
3652
4257
  private config;
4258
+ /** 是否正在刷新 token */
4259
+ private isRefreshing;
4260
+ /** 等待 token 刷新完成的请求队列 */
4261
+ private refreshSubscribers;
3653
4262
  /**
3654
4263
  * 私有构造函数(单例模式)
3655
4264
  */
@@ -3667,9 +4276,17 @@ declare class HttpService {
3667
4276
  */
3668
4277
  private registerDefaultRequestInterceptor;
3669
4278
  /**
3670
- * 注册默认响应拦截器(处理 401/403)
4279
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3671
4280
  */
3672
4281
  private registerDefaultResponseInterceptor;
4282
+ /**
4283
+ * token 刷新成功,通知所有等待的请求
4284
+ */
4285
+ private onRefreshSuccess;
4286
+ /**
4287
+ * token 刷新失败,通知所有等待的请求
4288
+ */
4289
+ private onRefreshFailure;
3673
4290
  /**
3674
4291
  * 注册请求拦截器
3675
4292
  * @param onFulfilled 请求成功拦截器
@@ -3735,7 +4352,9 @@ declare class HttpService {
3735
4352
  */
3736
4353
  offUnauthorized(callback: UnauthorizedCallback): void;
3737
4354
  /**
3738
- * 触发所有 401 回调
4355
+ * 触发所有 401 回调并等待完成
4356
+ * @returns Promise,等待所有回调完成
4357
+ * @throws 如果任何回调失败,则抛出错误
3739
4358
  */
3740
4359
  private triggerUnauthorizedCallbacks;
3741
4360
  /**