@tencent-ai/cloud-agent-sdk 0.2.12 → 0.2.13-next.2f2e439.20260206

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
@@ -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
347
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
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
  */
@@ -1635,6 +1840,8 @@ interface BaseAgentState {
1635
1840
  updatedAt?: Date;
1636
1841
  /** 是否为 playground */
1637
1842
  isPlayground?: boolean;
1843
+ /** Whether the title is user defined (1 = user defined) */
1844
+ isUserDefinedTitle?: number;
1638
1845
  }
1639
1846
  /**
1640
1847
  * LocalAgentState - 本地 Agent 状态
@@ -1781,15 +1988,35 @@ interface SessionInfo {
1781
1988
  cwd?: string;
1782
1989
  /** Whether the session is a playground */
1783
1990
  isPlayground?: boolean;
1991
+ /** Whether the title is user defined (1 = user defined) */
1992
+ isUserDefinedTitle?: number;
1784
1993
  }
1785
1994
  /**
1786
1995
  * Parameters for creating a new session
1787
1996
  */
1788
1997
  interface CreateSessionParams$1 {
1789
- /** Working directory */
1998
+ /** Working directory (required) */
1790
1999
  cwd: string;
2000
+ /** Optional configuration */
2001
+ options?: CreateSessionOptions;
2002
+ }
2003
+ /**
2004
+ * Optional configuration for creating a session
2005
+ */
2006
+ interface CreateSessionOptions {
1791
2007
  /** MCP server configurations */
1792
2008
  mcpServers?: McpServerConfig[];
2009
+ /** Initial prompt for the session (Cloud only) */
2010
+ prompt?: string;
2011
+ /** Initial model for the session (Cloud only) */
2012
+ model?: string;
2013
+ /** Mode ID (e.g., 'craft', 'architect') */
2014
+ mode?: string;
2015
+ /** Whether this is a playground session (no cwd) */
2016
+ isPlayground?: boolean;
2017
+ /** Tags for template scenes (Cloud only, format: { scene: 'xxx' }) */
2018
+ tags?: Record<string, string>;
2019
+ /** Additional metadata */
1793
2020
  _meta?: Record<string, unknown>;
1794
2021
  }
1795
2022
  /**
@@ -1999,7 +2226,7 @@ interface ActiveSession {
1999
2226
  error?: string;
2000
2227
  }>;
2001
2228
  /** Set the current session mode */
2002
- setMode(modeId: string): Promise<void>;
2229
+ setMode(modeId: string, skipChecker?: boolean): Promise<void>;
2003
2230
  /** Set the current session model */
2004
2231
  setSessionModel(modelId: string): Promise<void>;
2005
2232
  /** Set available commands (called when available_commands_update is received) */
@@ -2142,6 +2369,13 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2142
2369
  * @returns Response with search results
2143
2370
  */
2144
2371
  searchFile?(params: SearchFileParams): Promise<SearchFileResponse>;
2372
+ /**
2373
+ * Get subagent list (optional, used by LocalAgentProvider)
2374
+ *
2375
+ * @param params - Query parameters including options
2376
+ * @returns Response with subagent list
2377
+ */
2378
+ getSubagentList?(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2145
2379
  /**
2146
2380
  * Batch toggle plugins (optional, used by LocalAgentProvider)
2147
2381
  *
@@ -2169,12 +2403,22 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2169
2403
  * @param pluginNames - Array of plugin names to install
2170
2404
  * @param marketplaceName - Marketplace name
2171
2405
  * @param installScope - Install scope ('user' | 'project')
2406
+ * @param marketplaceSource - Marketplace source URL (for auto-adding marketplace when not exists)
2172
2407
  * @returns Result of the operation
2173
2408
  */
2174
- installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2409
+ installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string): Promise<{
2175
2410
  success: boolean;
2176
2411
  error?: string;
2177
2412
  }>;
2413
+ /**
2414
+ * Get available commands for a session (optional, used by LocalAgentProvider)
2415
+ * If session.availableCommands has cached values, return them
2416
+ * Otherwise, fetch from product configuration
2417
+ *
2418
+ * @param sessionId - Session ID to get commands for (optional, for global commands)
2419
+ * @returns Array of available commands
2420
+ */
2421
+ getAvailableCommands?(sessionId?: string): Promise<AvailableCommand[]>;
2178
2422
  /**
2179
2423
  * Register an event listener
2180
2424
  * Provider implementations should forward events to the underlying transport
@@ -2190,6 +2434,40 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2190
2434
  * @param handler - Event handler function to remove
2191
2435
  */
2192
2436
  off?(event: string, handler: (...args: any[]) => void): void;
2437
+ /**
2438
+ * Respond to MCP Sampling confirmation request (optional, used by LocalAgentProvider)
2439
+ * Called when user confirms/rejects a sampling request
2440
+ *
2441
+ * @param sessionId - Session ID
2442
+ * @param response - Sampling confirmation response
2443
+ */
2444
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2445
+ /**
2446
+ * Respond to MCP Roots confirmation request (optional, used by LocalAgentProvider)
2447
+ * Called when user confirms/rejects a roots request
2448
+ *
2449
+ * @param sessionId - Session ID
2450
+ * @param response - Roots confirmation response
2451
+ */
2452
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2453
+ /**
2454
+ * Subscribe to MCP Sampling confirmation requests (optional, used by LocalAgentProvider)
2455
+ * Called when MCP server initiates a sampling request
2456
+ *
2457
+ * @param serverName - MCP server name
2458
+ * @param callback - Request callback
2459
+ * @returns Unsubscribe function
2460
+ */
2461
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
2462
+ /**
2463
+ * Subscribe to MCP Roots confirmation requests (optional, used by LocalAgentProvider)
2464
+ * Called when MCP server initiates a roots request
2465
+ *
2466
+ * @param serverName - MCP server name
2467
+ * @param callback - Request callback
2468
+ * @returns Unsubscribe function
2469
+ */
2470
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
2193
2471
  }
2194
2472
  /**
2195
2473
  * AgentClient initialization options
@@ -2277,6 +2555,8 @@ interface ClientSessionsResource {
2277
2555
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
2278
2556
  /** Search for files in the workspace (for LocalAgentProvider) */
2279
2557
  searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
2558
+ /** Get subagent list (for LocalAgentProvider) */
2559
+ getSubagentList(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2280
2560
  /** Batch toggle plugins (for LocalAgentProvider) */
2281
2561
  batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2282
2562
  /** Get installed plugins (for LocalAgentProvider) */
@@ -2289,15 +2569,16 @@ interface ClientSessionsResource {
2289
2569
  installScope?: 'user' | 'project';
2290
2570
  }>>;
2291
2571
  /** Install plugins (for LocalAgentProvider) */
2292
- installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2572
+ installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string): Promise<{
2293
2573
  success: boolean;
2294
2574
  error?: string;
2295
2575
  }>;
2296
2576
  /**
2297
2577
  * Get support scenes from backend API (for LocalAgentProvider)
2298
2578
  * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
2579
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2299
2580
  */
2300
- getSupportScenes(): Promise<Array<{
2581
+ getSupportScenes(locale?: string): Promise<Array<{
2301
2582
  id: number;
2302
2583
  name: string;
2303
2584
  plugins: Array<{
@@ -2306,7 +2587,136 @@ interface ClientSessionsResource {
2306
2587
  marketplaceName: string;
2307
2588
  }>;
2308
2589
  prompts: string[];
2590
+ mode?: 'coding' | 'working';
2309
2591
  }>>;
2592
+ /**
2593
+ * Get available commands for a session
2594
+ * If session.availableCommands has cached values, return them
2595
+ * Otherwise, fetch from provider (for LocalAgentProvider)
2596
+ * @param sessionId - Session ID to get commands for (optional, for global commands)
2597
+ * @returns Promise<AvailableCommand[]> - Array of available commands
2598
+ */
2599
+ getAvailableCommands(sessionId?: string): Promise<AvailableCommand[]>;
2600
+ /**
2601
+ * Respond to MCP Sampling confirmation request
2602
+ * Called when user confirms/rejects a sampling request in MCP tool renderer
2603
+ *
2604
+ * @param sessionId - Session ID
2605
+ * @param response - Sampling confirmation response
2606
+ */
2607
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2608
+ /**
2609
+ * Respond to MCP Roots confirmation request
2610
+ * Called when user confirms/rejects a roots request in MCP tool renderer
2611
+ *
2612
+ * @param sessionId - Session ID
2613
+ * @param response - Roots confirmation response
2614
+ */
2615
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2616
+ /**
2617
+ * Subscribe to MCP Sampling confirmation requests
2618
+ * Called when MCP server initiates a sampling request
2619
+ *
2620
+ * @param serverName - MCP server name
2621
+ * @param callback - Request callback
2622
+ * @returns Unsubscribe function
2623
+ */
2624
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
2625
+ /**
2626
+ * Subscribe to MCP Roots confirmation requests
2627
+ * Called when MCP server initiates a roots request
2628
+ *
2629
+ * @param serverName - MCP server name
2630
+ * @param callback - Request callback
2631
+ * @returns Unsubscribe function
2632
+ */
2633
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
2634
+ }
2635
+ /**
2636
+ * MCP Sampling message role
2637
+ */
2638
+ type McpSamplingRole = 'user' | 'assistant';
2639
+ /**
2640
+ * MCP Sampling message content - text
2641
+ */
2642
+ interface McpSamplingTextContent {
2643
+ type: 'text';
2644
+ text: string;
2645
+ }
2646
+ /**
2647
+ * MCP Sampling message content - image
2648
+ */
2649
+ interface McpSamplingImageContent {
2650
+ type: 'image';
2651
+ data: string;
2652
+ mimeType: string;
2653
+ }
2654
+ /**
2655
+ * MCP Sampling message content - audio
2656
+ */
2657
+ interface McpSamplingAudioContent {
2658
+ type: 'audio';
2659
+ data: string;
2660
+ mimeType: string;
2661
+ }
2662
+ /**
2663
+ * MCP Sampling message content union type
2664
+ */
2665
+ type McpSamplingContent = McpSamplingTextContent | McpSamplingImageContent | McpSamplingAudioContent;
2666
+ /**
2667
+ * MCP Sampling message
2668
+ */
2669
+ interface McpSamplingMessage {
2670
+ role: McpSamplingRole;
2671
+ content: McpSamplingContent;
2672
+ }
2673
+ /**
2674
+ * MCP Sampling confirmation request
2675
+ * Sent from backend when MCP server requests sampling
2676
+ */
2677
+ interface McpSamplingConfirmRequest {
2678
+ id: string;
2679
+ serverName: string;
2680
+ model?: string;
2681
+ messages: McpSamplingMessage[];
2682
+ systemPrompt?: string;
2683
+ maxTokens: number;
2684
+ timestamp: number;
2685
+ }
2686
+ /**
2687
+ * MCP Sampling confirmation response
2688
+ * Sent from frontend when user confirms/rejects
2689
+ */
2690
+ interface McpSamplingConfirmResponse {
2691
+ id: string;
2692
+ approved: boolean;
2693
+ rememberChoice?: boolean;
2694
+ }
2695
+ /**
2696
+ * MCP Root definition
2697
+ */
2698
+ interface McpRoot {
2699
+ uri: string;
2700
+ name?: string;
2701
+ }
2702
+ /**
2703
+ * MCP Roots confirmation request
2704
+ * Sent from backend when MCP server requests roots access
2705
+ */
2706
+ interface McpRootsConfirmRequest {
2707
+ id: string;
2708
+ serverName: string;
2709
+ roots: McpRoot[];
2710
+ timestamp: number;
2711
+ }
2712
+ /**
2713
+ * MCP Roots confirmation response
2714
+ * Sent from frontend when user confirms/rejects
2715
+ */
2716
+ interface McpRootsConfirmResponse {
2717
+ id: string;
2718
+ approved: boolean;
2719
+ rememberChoice?: boolean;
2310
2720
  }
2311
2721
  /**
2312
2722
  * Workspace information (aligned with FolderSelectResult)
@@ -2435,6 +2845,52 @@ interface SearchFileResponse {
2435
2845
  /** Error message (if failed) */
2436
2846
  readonly error?: string;
2437
2847
  }
2848
+ /**
2849
+ * Subagent information
2850
+ */
2851
+ interface SubagentInfo {
2852
+ /** Subagent name */
2853
+ name: string;
2854
+ /** Subagent description */
2855
+ description: string;
2856
+ /** System prompt */
2857
+ systemPrompt: string;
2858
+ /** File path */
2859
+ filePath?: string;
2860
+ /** Model type */
2861
+ model?: string;
2862
+ /** Agent mode */
2863
+ agentMode?: 'agentic' | 'manual';
2864
+ /** Whether enabled */
2865
+ enabled?: boolean;
2866
+ /** Model ID */
2867
+ modelID?: string;
2868
+ /** Subagent level */
2869
+ level?: 'project' | 'user';
2870
+ }
2871
+ /**
2872
+ * Parameters for getting subagent list
2873
+ */
2874
+ interface GetSubagentListParams {
2875
+ /** Search options */
2876
+ readonly options: {
2877
+ /** Search keyword (filter by name or description) */readonly search?: string; /** Limit number of results */
2878
+ readonly resultNum?: number; /** Agent mode filter */
2879
+ readonly agentMode?: 'agentic' | 'manual' | 'all'; /** Whether to return only enabled subagents */
2880
+ readonly onlyEnabled?: boolean;
2881
+ };
2882
+ /** Working directory (optional, for filtering project-level subagents) */
2883
+ readonly cwd?: string;
2884
+ }
2885
+ /**
2886
+ * Response from getting subagent list
2887
+ */
2888
+ interface GetSubagentListResponse {
2889
+ /** Subagent list */
2890
+ readonly results: SubagentInfo[];
2891
+ /** Error message (if failed) */
2892
+ readonly error?: string;
2893
+ }
2438
2894
  //#endregion
2439
2895
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
2440
2896
  /**
@@ -2691,8 +3147,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2691
3147
  /**
2692
3148
  * Create a new conversation
2693
3149
  * POST {endpoint}/console/as/conversations
3150
+ * @param params - Session params containing cwd and optional configuration
2694
3151
  */
2695
- create(): Promise<string>;
3152
+ create(params: CreateSessionParams$1): Promise<string>;
2696
3153
  /**
2697
3154
  * Connect to an agent and return the connection
2698
3155
  *
@@ -2805,9 +3262,10 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2805
3262
  * API 端点: GET /console/as/support/scenes
2806
3263
  * 用于 Welcome 页面的 QuickActions 快捷操作
2807
3264
  *
3265
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2808
3266
  * @returns Promise<SupportScene[]> 支持的场景列表
2809
3267
  */
2810
- getSupportScenes(): Promise<SupportScene[]>;
3268
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
2811
3269
  private toAgentState;
2812
3270
  /**
2813
3271
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
@@ -3140,7 +3598,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3140
3598
  * await session.setMode('architect');
3141
3599
  * ```
3142
3600
  */
3143
- setMode(modeId: string): Promise<void>;
3601
+ setMode(modeId: string, skipAvailableChecker?: boolean): Promise<void>;
3144
3602
  /**
3145
3603
  * Set the current session model
3146
3604
  *
@@ -3271,6 +3729,18 @@ declare class SessionManager {
3271
3729
  * 7. Return ActiveSession instance (cached)
3272
3730
  */
3273
3731
  loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
3732
+ /**
3733
+ * 从 ACP response 中提取可用模型列表
3734
+ *
3735
+ * 优先级:
3736
+ * 1. response.models._meta?.['codebuddy.ai']?.availableModels - 包含完整的模型信息(字段名为 'id')
3737
+ * 2. response.models?.availableModels - 只包含基本信息(字段名为 'modelId')
3738
+ * 3. undefined - 都没有时返回 undefined
3739
+ *
3740
+ * @param response - ACP 响应对象
3741
+ * @returns ModelInfo[] | undefined
3742
+ */
3743
+ protected extractAvailableModels(response: LoadSessionResponse): ModelInfo[] | undefined;
3274
3744
  }
3275
3745
  //#endregion
3276
3746
  //#region ../agent-provider/lib/backend/backend-provider.d.ts
@@ -3287,6 +3757,13 @@ declare class SessionManager {
3287
3757
  */
3288
3758
  declare class BackendProvider implements IBackendProvider {
3289
3759
  constructor(config: BackendProviderConfig);
3760
+ /**
3761
+ * 处理 401 未授权错误
3762
+ * 先尝试刷新 token,失败后再执行登出流程
3763
+ *
3764
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
3765
+ */
3766
+ protected handleUnauthorized(): Promise<void>;
3290
3767
  /**
3291
3768
  * 获取当前账号信息
3292
3769
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3410,6 +3887,38 @@ declare class BackendProvider implements IBackendProvider {
3410
3887
  * API: POST /billing/meter/get-enterprise-user-usage
3411
3888
  */
3412
3889
  getEnterpriseUsage(enterpriseId: string): Promise<EnterpriseUsage | null>;
3890
+ /**
3891
+ * 刷新 Token
3892
+ * 通过调用 getAccount 刷新 cookie,适用于 Cloud 场景下页面切换回来时刷新登录态
3893
+ * @returns Promise<Account | null> 刷新后的账号信息
3894
+ */
3895
+ refreshToken(): Promise<Account | null>;
3896
+ /**
3897
+ * 获取仓库分支列表
3898
+ * API 端点: GET /console/as/connector/oauth/{name}/branches
3899
+ *
3900
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
3901
+ * @param params 平台特定的查询参数
3902
+ * @param page 页码,从1开始,0表示不分页获取全部
3903
+ * @param perPage 每页数量,最大100
3904
+ * @returns Promise<OauthBranch[]> 分支列表
3905
+ */
3906
+ getBranches(connector: OauthConnectorName, params: GitHubBranchParams | GongfengBranchParams | CNBBranchParams, page?: number, perPage?: number): Promise<OauthBranch[]>;
3907
+ /**
3908
+ * 获取仓库列表
3909
+ * API 端点: GET /console/as/connector/oauth/{name}/repos
3910
+ *
3911
+ * Note: 由于工蜂原生支持的 Search 能力会匹配 path/name/description 部分,
3912
+ * 且不支持定制,不满足产品要求(只按 name 匹配),因此前端拉取全量数据后做筛选。
3913
+ *
3914
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
3915
+ * @param page 页码,从1开始,0表示不分页获取全部
3916
+ * - GitHub 只支持全量数据,必须传 0
3917
+ * - 工蜂和 CNB 依据前端逻辑而定
3918
+ * @param perPage 每页数量,最大100
3919
+ * @returns Promise<ListReposResponse> 仓库列表响应
3920
+ */
3921
+ getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
3413
3922
  }
3414
3923
  /**
3415
3924
  * 创建 BackendProvider 实例
@@ -3543,6 +4052,12 @@ declare class IPCBackendProvider implements IBackendProvider {
3543
4052
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
3544
4053
  */
3545
4054
  closeAgentManager(): Promise<void>;
4055
+ /**
4056
+ * 在外部浏览器中打开链接
4057
+ * IDE 环境: 通过 IPC 通知 IDE 使用 vscode.env.openExternal 打开 URL
4058
+ * @param url 要打开的 URL
4059
+ */
4060
+ openExternal(url: string): Promise<void>;
3546
4061
  /**
3547
4062
  * 批量切换插件状态
3548
4063
  * IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
@@ -3614,7 +4129,7 @@ type UnauthorizedCallback = () => void;
3614
4129
  * 特性:
3615
4130
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3616
4131
  * - 支持拦截器注册(其他模块可注入 header)
3617
- * - 统一 401/403 处理
4132
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3618
4133
  * - 自动携带凭证(withCredentials)
3619
4134
  * - 类型安全
3620
4135
  *
@@ -3650,6 +4165,10 @@ declare class HttpService {
3650
4165
  private axiosInstance;
3651
4166
  private unauthorizedCallbacks;
3652
4167
  private config;
4168
+ /** 是否正在刷新 token */
4169
+ private isRefreshing;
4170
+ /** 等待 token 刷新完成的请求队列 */
4171
+ private refreshSubscribers;
3653
4172
  /**
3654
4173
  * 私有构造函数(单例模式)
3655
4174
  */
@@ -3667,9 +4186,17 @@ declare class HttpService {
3667
4186
  */
3668
4187
  private registerDefaultRequestInterceptor;
3669
4188
  /**
3670
- * 注册默认响应拦截器(处理 401/403)
4189
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3671
4190
  */
3672
4191
  private registerDefaultResponseInterceptor;
4192
+ /**
4193
+ * token 刷新成功,通知所有等待的请求
4194
+ */
4195
+ private onRefreshSuccess;
4196
+ /**
4197
+ * token 刷新失败,通知所有等待的请求
4198
+ */
4199
+ private onRefreshFailure;
3673
4200
  /**
3674
4201
  * 注册请求拦截器
3675
4202
  * @param onFulfilled 请求成功拦截器
@@ -3735,7 +4262,9 @@ declare class HttpService {
3735
4262
  */
3736
4263
  offUnauthorized(callback: UnauthorizedCallback): void;
3737
4264
  /**
3738
- * 触发所有 401 回调
4265
+ * 触发所有 401 回调并等待完成
4266
+ * @returns Promise,等待所有回调完成
4267
+ * @throws 如果任何回调失败,则抛出错误
3739
4268
  */
3740
4269
  private triggerUnauthorizedCallbacks;
3741
4270
  /**