@tencent-ai/cloud-agent-sdk 0.2.12 → 0.2.13-next.136ad71.20260213

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
347
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
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
  */
@@ -1315,7 +1520,7 @@ type PromptContentBlock = {
1315
1520
  uri: string;
1316
1521
  mimeType?: string | null;
1317
1522
  name: string;
1318
- size?: bigint | null;
1523
+ size?: number | null;
1319
1524
  title?: string | null;
1320
1525
  _meta?: {
1321
1526
  [key: string]: unknown;
@@ -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) */
@@ -2080,6 +2329,17 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2080
2329
  rename?(agentId: string, title: string): Promise<{
2081
2330
  id: string;
2082
2331
  }>;
2332
+ /**
2333
+ * Update agent status by ID (optional)
2334
+ * Used by CloudAgentProvider for updating session status
2335
+ *
2336
+ * @param agentId - Agent ID to update
2337
+ * @param status - New status for the agent
2338
+ * @returns Object containing the updated agent ID
2339
+ */
2340
+ updateStatus?(agentId: string, status: string): Promise<{
2341
+ id: string;
2342
+ }>;
2083
2343
  /**
2084
2344
  * Move an agent by ID (optional)
2085
2345
  * Used by LocalAgentProvider for moving Playground sessions to Workspace
@@ -2142,6 +2402,27 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2142
2402
  * @returns Response with search results
2143
2403
  */
2144
2404
  searchFile?(params: SearchFileParams): Promise<SearchFileResponse>;
2405
+ /**
2406
+ * Get subagent list (optional, used by LocalAgentProvider)
2407
+ *
2408
+ * @param params - Query parameters including options
2409
+ * @returns Response with subagent list
2410
+ */
2411
+ getSubagentList?(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2412
+ /**
2413
+ * Get skill list (optional, used by LocalAgentProvider)
2414
+ *
2415
+ * @param params - Query parameters
2416
+ * @returns Response with skill list
2417
+ */
2418
+ getSkillList?(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2419
+ /**
2420
+ * Import a skill folder (optional, used by LocalAgentProvider)
2421
+ *
2422
+ * @param params - Import parameters including source location
2423
+ * @returns Response with import result
2424
+ */
2425
+ importSkill?(params: ImportSkillParams): Promise<ImportSkillResponse>;
2145
2426
  /**
2146
2427
  * Batch toggle plugins (optional, used by LocalAgentProvider)
2147
2428
  *
@@ -2169,12 +2450,22 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2169
2450
  * @param pluginNames - Array of plugin names to install
2170
2451
  * @param marketplaceName - Marketplace name
2171
2452
  * @param installScope - Install scope ('user' | 'project')
2453
+ * @param marketplaceSource - Marketplace source URL (for auto-adding marketplace when not exists)
2172
2454
  * @returns Result of the operation
2173
2455
  */
2174
- installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2456
+ installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2175
2457
  success: boolean;
2176
2458
  error?: string;
2177
2459
  }>;
2460
+ /**
2461
+ * Get available commands for a session (optional, used by LocalAgentProvider)
2462
+ * If session.availableCommands has cached values, return them
2463
+ * Otherwise, fetch from product configuration
2464
+ *
2465
+ * @param params - Parameters for getting commands
2466
+ * @returns Array of available commands
2467
+ */
2468
+ getAvailableCommands?(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2178
2469
  /**
2179
2470
  * Register an event listener
2180
2471
  * Provider implementations should forward events to the underlying transport
@@ -2190,6 +2481,66 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2190
2481
  * @param handler - Event handler function to remove
2191
2482
  */
2192
2483
  off?(event: string, handler: (...args: any[]) => void): void;
2484
+ /**
2485
+ * Report telemetry event through the provider chain
2486
+ * - Local: via ACP JSON-RPC → AcpAgent → IDE EventService
2487
+ * - Cloud: via connection → cloud endpoint
2488
+ *
2489
+ * @param eventName - Event name / code
2490
+ * @param payload - Event data
2491
+ */
2492
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2493
+ /**
2494
+ * Respond to MCP Sampling confirmation request (optional, used by LocalAgentProvider)
2495
+ * Called when user confirms/rejects a sampling request
2496
+ *
2497
+ * @param sessionId - Session ID
2498
+ * @param response - Sampling confirmation response
2499
+ */
2500
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2501
+ /**
2502
+ * Respond to MCP Roots confirmation request (optional, used by LocalAgentProvider)
2503
+ * Called when user confirms/rejects a roots request
2504
+ *
2505
+ * @param sessionId - Session ID
2506
+ * @param response - Roots confirmation response
2507
+ */
2508
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2509
+ /**
2510
+ * Subscribe to MCP Sampling confirmation requests (optional, used by LocalAgentProvider)
2511
+ * Called when MCP server initiates a sampling request
2512
+ *
2513
+ * @param serverName - MCP server name
2514
+ * @param callback - Request callback
2515
+ * @returns Unsubscribe function
2516
+ */
2517
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
2518
+ /**
2519
+ * Subscribe to MCP Roots confirmation requests (optional, used by LocalAgentProvider)
2520
+ * Called when MCP server initiates a roots request
2521
+ *
2522
+ * @param serverName - MCP server name
2523
+ * @param callback - Request callback
2524
+ * @returns Unsubscribe function
2525
+ */
2526
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
2527
+ /**
2528
+ * Get product scenes from ProductManager configuration (optional, for LocalAgentProvider)
2529
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
2530
+ * @param locale - 可选,语言环境
2531
+ */
2532
+ getProductScenes?(locale?: string): Promise<Array<{
2533
+ id: number;
2534
+ name: string;
2535
+ plugins: Array<{
2536
+ id: number;
2537
+ name: string;
2538
+ marketplaceName: string;
2539
+ }>;
2540
+ prompts: string[];
2541
+ mode?: 'coding' | 'working';
2542
+ target?: 'local' | 'cloud' | 'all';
2543
+ }>>;
2193
2544
  }
2194
2545
  /**
2195
2546
  * AgentClient initialization options
@@ -2247,6 +2598,15 @@ interface ClientSessionsResource {
2247
2598
  rename(sessionId: string, title: string): Promise<{
2248
2599
  id: string;
2249
2600
  }>;
2601
+ /**
2602
+ * Update session status
2603
+ * @param sessionId - Session ID to update
2604
+ * @param status - New status for the session
2605
+ * @returns Object containing the updated session ID
2606
+ */
2607
+ updateStatus(sessionId: string, status: string): Promise<{
2608
+ id: string;
2609
+ }>;
2250
2610
  /**
2251
2611
  * Move a session (Playground → Workspace)
2252
2612
  * @param sessionId - Session ID to move
@@ -2277,6 +2637,12 @@ interface ClientSessionsResource {
2277
2637
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
2278
2638
  /** Search for files in the workspace (for LocalAgentProvider) */
2279
2639
  searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
2640
+ /** Get subagent list (for LocalAgentProvider) */
2641
+ getSubagentList(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2642
+ /** Get skill list (for LocalAgentProvider) */
2643
+ getSkillList(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2644
+ /** Import a skill folder (for LocalAgentProvider) */
2645
+ importSkill(params: ImportSkillParams): Promise<ImportSkillResponse>;
2280
2646
  /** Batch toggle plugins (for LocalAgentProvider) */
2281
2647
  batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2282
2648
  /** Get installed plugins (for LocalAgentProvider) */
@@ -2289,15 +2655,16 @@ interface ClientSessionsResource {
2289
2655
  installScope?: 'user' | 'project';
2290
2656
  }>>;
2291
2657
  /** Install plugins (for LocalAgentProvider) */
2292
- installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2658
+ installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2293
2659
  success: boolean;
2294
2660
  error?: string;
2295
2661
  }>;
2296
2662
  /**
2297
2663
  * Get support scenes from backend API (for LocalAgentProvider)
2298
2664
  * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
2665
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2299
2666
  */
2300
- getSupportScenes(): Promise<Array<{
2667
+ getSupportScenes(locale?: string): Promise<Array<{
2301
2668
  id: number;
2302
2669
  name: string;
2303
2670
  plugins: Array<{
@@ -2306,7 +2673,161 @@ interface ClientSessionsResource {
2306
2673
  marketplaceName: string;
2307
2674
  }>;
2308
2675
  prompts: string[];
2676
+ mode?: 'coding' | 'working';
2309
2677
  }>>;
2678
+ /**
2679
+ * Get product scenes from ProductManager configuration (for LocalAgentProvider)
2680
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
2681
+ * @param locale - 可选,语言环境
2682
+ */
2683
+ getProductScenes?(locale?: string): Promise<Array<{
2684
+ id: number;
2685
+ name: string;
2686
+ plugins: Array<{
2687
+ id: number;
2688
+ name: string;
2689
+ marketplaceName: string;
2690
+ }>;
2691
+ prompts: string[];
2692
+ mode?: 'coding' | 'working';
2693
+ target?: 'local' | 'cloud' | 'all';
2694
+ }>>;
2695
+ /**
2696
+ * Get available commands for a session
2697
+ * If session.availableCommands has cached values, return them
2698
+ * Otherwise, fetch from provider (for LocalAgentProvider)
2699
+ * @param params - Parameters for getting commands
2700
+ * @returns Promise<AvailableCommand[]> - Array of available commands
2701
+ */
2702
+ getAvailableCommands(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2703
+ /**
2704
+ * Report telemetry event through the provider chain
2705
+ * Delegates to AgentProvider.reportTelemetry()
2706
+ *
2707
+ * @param eventName - Event name / code
2708
+ * @param payload - Event data
2709
+ */
2710
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2711
+ /**
2712
+ * Respond to MCP Sampling confirmation request
2713
+ * Called when user confirms/rejects a sampling request in MCP tool renderer
2714
+ *
2715
+ * @param sessionId - Session ID
2716
+ * @param response - Sampling confirmation response
2717
+ */
2718
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2719
+ /**
2720
+ * Respond to MCP Roots confirmation request
2721
+ * Called when user confirms/rejects a roots request in MCP tool renderer
2722
+ *
2723
+ * @param sessionId - Session ID
2724
+ * @param response - Roots confirmation response
2725
+ */
2726
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2727
+ /**
2728
+ * Subscribe to MCP Sampling confirmation requests
2729
+ * Called when MCP server initiates a sampling request
2730
+ *
2731
+ * @param serverName - MCP server name
2732
+ * @param callback - Request callback
2733
+ * @returns Unsubscribe function
2734
+ */
2735
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
2736
+ /**
2737
+ * Subscribe to MCP Roots confirmation requests
2738
+ * Called when MCP server initiates a roots request
2739
+ *
2740
+ * @param serverName - MCP server name
2741
+ * @param callback - Request callback
2742
+ * @returns Unsubscribe function
2743
+ */
2744
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
2745
+ }
2746
+ /**
2747
+ * MCP Sampling message role
2748
+ */
2749
+ type McpSamplingRole = 'user' | 'assistant';
2750
+ /**
2751
+ * MCP Sampling message content - text
2752
+ */
2753
+ interface McpSamplingTextContent {
2754
+ type: 'text';
2755
+ text: string;
2756
+ }
2757
+ /**
2758
+ * MCP Sampling message content - image
2759
+ */
2760
+ interface McpSamplingImageContent {
2761
+ type: 'image';
2762
+ data: string;
2763
+ mimeType: string;
2764
+ }
2765
+ /**
2766
+ * MCP Sampling message content - audio
2767
+ */
2768
+ interface McpSamplingAudioContent {
2769
+ type: 'audio';
2770
+ data: string;
2771
+ mimeType: string;
2772
+ }
2773
+ /**
2774
+ * MCP Sampling message content union type
2775
+ */
2776
+ type McpSamplingContent = McpSamplingTextContent | McpSamplingImageContent | McpSamplingAudioContent;
2777
+ /**
2778
+ * MCP Sampling message
2779
+ */
2780
+ interface McpSamplingMessage {
2781
+ role: McpSamplingRole;
2782
+ content: McpSamplingContent;
2783
+ }
2784
+ /**
2785
+ * MCP Sampling confirmation request
2786
+ * Sent from backend when MCP server requests sampling
2787
+ */
2788
+ interface McpSamplingConfirmRequest {
2789
+ id: string;
2790
+ serverName: string;
2791
+ model?: string;
2792
+ messages: McpSamplingMessage[];
2793
+ systemPrompt?: string;
2794
+ maxTokens: number;
2795
+ timestamp: number;
2796
+ }
2797
+ /**
2798
+ * MCP Sampling confirmation response
2799
+ * Sent from frontend when user confirms/rejects
2800
+ */
2801
+ interface McpSamplingConfirmResponse {
2802
+ id: string;
2803
+ approved: boolean;
2804
+ rememberChoice?: boolean;
2805
+ }
2806
+ /**
2807
+ * MCP Root definition
2808
+ */
2809
+ interface McpRoot {
2810
+ uri: string;
2811
+ name?: string;
2812
+ }
2813
+ /**
2814
+ * MCP Roots confirmation request
2815
+ * Sent from backend when MCP server requests roots access
2816
+ */
2817
+ interface McpRootsConfirmRequest {
2818
+ id: string;
2819
+ serverName: string;
2820
+ roots: McpRoot[];
2821
+ timestamp: number;
2822
+ }
2823
+ /**
2824
+ * MCP Roots confirmation response
2825
+ * Sent from frontend when user confirms/rejects
2826
+ */
2827
+ interface McpRootsConfirmResponse {
2828
+ id: string;
2829
+ approved: boolean;
2830
+ rememberChoice?: boolean;
2310
2831
  }
2311
2832
  /**
2312
2833
  * Workspace information (aligned with FolderSelectResult)
@@ -2372,6 +2893,8 @@ interface PickFolderResponse {
2372
2893
  interface UploadFileParams {
2373
2894
  /** Files to upload - File objects in browser, absolute path strings in IDE */
2374
2895
  readonly files: Array<File | string>;
2896
+ /** Optional AbortSignal to cancel the upload */
2897
+ readonly abortSignal?: AbortSignal;
2375
2898
  }
2376
2899
  /**
2377
2900
  * Response from uploading files
@@ -2385,6 +2908,8 @@ interface UploadFileResponse {
2385
2908
  readonly expireSeconds?: number;
2386
2909
  /** Error message (if upload failed) */
2387
2910
  readonly error?: string;
2911
+ /** Whether the upload was cancelled by user */
2912
+ readonly aborted?: boolean;
2388
2913
  }
2389
2914
  /**
2390
2915
  * Mention type for file/folder
@@ -2435,6 +2960,109 @@ interface SearchFileResponse {
2435
2960
  /** Error message (if failed) */
2436
2961
  readonly error?: string;
2437
2962
  }
2963
+ /**
2964
+ * Subagent information
2965
+ */
2966
+ interface SubagentInfo {
2967
+ /** Subagent name */
2968
+ name: string;
2969
+ /** Subagent description */
2970
+ description: string;
2971
+ /** System prompt */
2972
+ systemPrompt: string;
2973
+ /** File path */
2974
+ filePath?: string;
2975
+ /** Model type */
2976
+ model?: string;
2977
+ /** Agent mode */
2978
+ agentMode?: 'agentic' | 'manual';
2979
+ /** Whether enabled */
2980
+ enabled?: boolean;
2981
+ /** Model ID */
2982
+ modelID?: string;
2983
+ /** Subagent level */
2984
+ level?: 'project' | 'user';
2985
+ }
2986
+ /**
2987
+ * Parameters for getting subagent list
2988
+ */
2989
+ interface GetSubagentListParams {
2990
+ /** Search options */
2991
+ readonly options: {
2992
+ /** Search keyword (filter by name or description) */readonly search?: string; /** Limit number of results */
2993
+ readonly resultNum?: number; /** Agent mode filter */
2994
+ readonly agentMode?: 'agentic' | 'manual' | 'all'; /** Whether to return only enabled subagents */
2995
+ readonly onlyEnabled?: boolean;
2996
+ };
2997
+ /** Working directory (optional, for filtering project-level subagents) */
2998
+ readonly cwd?: string;
2999
+ }
3000
+ /**
3001
+ * Response from getting subagent list
3002
+ */
3003
+ interface GetSubagentListResponse {
3004
+ /** Subagent list */
3005
+ readonly results: SubagentInfo[];
3006
+ /** Error message (if failed) */
3007
+ readonly error?: string;
3008
+ }
3009
+ /**
3010
+ * Skill info returned from getSkillList
3011
+ */
3012
+ interface SkillInfo {
3013
+ /** Skill name */
3014
+ name: string;
3015
+ /** File path of the skill */
3016
+ filePath: string;
3017
+ /** Description of the skill */
3018
+ description: string;
3019
+ /** When to use the skill */
3020
+ whenToUse?: string;
3021
+ /** Source of the skill */
3022
+ source: 'localSettings' | 'userSettings' | 'plugin' | 'builtin';
3023
+ /** Skill type */
3024
+ type: 'prompt';
3025
+ /** License information */
3026
+ license?: string;
3027
+ /** Allowed tools */
3028
+ allowedTools?: string[];
3029
+ /** Whether the skill is disabled */
3030
+ disable?: boolean;
3031
+ }
3032
+ /**
3033
+ * Parameters for getting skill list
3034
+ */
3035
+ interface GetSkillListParams {
3036
+ /** Working directory (optional, for filtering project-level skills) */
3037
+ readonly cwd?: string;
3038
+ }
3039
+ /**
3040
+ * Response from getting skill list
3041
+ */
3042
+ interface GetSkillListResponse {
3043
+ /** Skill list */
3044
+ readonly results: SkillInfo[];
3045
+ /** Error message (if failed) */
3046
+ readonly error?: string;
3047
+ }
3048
+ /**
3049
+ * Parameters for importing a skill folder
3050
+ */
3051
+ interface ImportSkillParams {
3052
+ /** Source location: project-level or user-level */
3053
+ readonly source: 'localSettings' | 'userSettings';
3054
+ /** Working directory (optional, for project-level skill import) */
3055
+ readonly cwd?: string;
3056
+ }
3057
+ /**
3058
+ * Response from importing a skill folder
3059
+ */
3060
+ interface ImportSkillResponse {
3061
+ /** Whether the import was successful */
3062
+ readonly success: boolean;
3063
+ /** Error message (if failed) */
3064
+ readonly error?: string;
3065
+ }
2438
3066
  //#endregion
2439
3067
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
2440
3068
  /**
@@ -2513,6 +3141,7 @@ declare class CloudAgentConnection implements AgentConnection {
2513
3141
  * Contains sandboxId, link, token, etc.
2514
3142
  */
2515
3143
  get sessionConnectionInfo(): SessionConnectionInfo | undefined;
3144
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2516
3145
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2517
3146
  }
2518
3147
  //#endregion
@@ -2691,8 +3320,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2691
3320
  /**
2692
3321
  * Create a new conversation
2693
3322
  * POST {endpoint}/console/as/conversations
3323
+ * @param params - Session params containing cwd and optional configuration
2694
3324
  */
2695
- create(): Promise<string>;
3325
+ create(params: CreateSessionParams$1): Promise<string>;
2696
3326
  /**
2697
3327
  * Connect to an agent and return the connection
2698
3328
  *
@@ -2744,6 +3374,21 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2744
3374
  * ```
2745
3375
  */
2746
3376
  rename(agentId: string, title: string): Promise<PatchConversationResponse>;
3377
+ /**
3378
+ * Update conversation status by ID
3379
+ * POST {endpoint}/console/as/conversations/{agentId}
3380
+ *
3381
+ * @param agentId - Conversation ID to update
3382
+ * @param status - New status for the conversation
3383
+ * @returns PatchConversationResponse containing the updated conversation ID
3384
+ *
3385
+ * @example
3386
+ * ```typescript
3387
+ * const result = await provider.updateStatus('agent-123', 'completed');
3388
+ * console.log('Updated conversation status:', result.id);
3389
+ * ```
3390
+ */
3391
+ updateStatus(agentId: string, status: string): Promise<PatchConversationResponse>;
2747
3392
  /**
2748
3393
  * Get available models from product configuration
2749
3394
  *
@@ -2778,7 +3423,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2778
3423
  /**
2779
3424
  * Upload files to cloud storage via COS presigned URL
2780
3425
  *
2781
- * @param params - files array (File objects in browser)
3426
+ * @param params - files array (File objects in browser), optional abortSignal
2782
3427
  * @returns Response with corresponding cloud URLs
2783
3428
  */
2784
3429
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
@@ -2802,17 +3447,24 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2802
3447
  private emitEvent;
2803
3448
  /**
2804
3449
  * 获取支持的场景列表
2805
- * API 端点: GET /console/as/support/scenes
3450
+ * API 端点: GET /v2/as/support/scenes (不鉴权)
2806
3451
  * 用于 Welcome 页面的 QuickActions 快捷操作
2807
3452
  *
3453
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2808
3454
  * @returns Promise<SupportScene[]> 支持的场景列表
2809
3455
  */
2810
- getSupportScenes(): Promise<SupportScene[]>;
3456
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
2811
3457
  private toAgentState;
2812
3458
  /**
2813
3459
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
2814
3460
  */
2815
3461
  private buildGetUrl;
3462
+ /**
3463
+ * 上报 telemetry 事件(Cloud 模式)
3464
+ * 通过 HTTP POST 发送到 /v2/report
3465
+ * 注入用户信息和浏览器环境等公共字段
3466
+ */
3467
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2816
3468
  }
2817
3469
  //#endregion
2818
3470
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
@@ -2991,6 +3643,7 @@ interface ActiveSessionImplOptions {
2991
3643
  declare class ActiveSessionImpl implements ActiveSession {
2992
3644
  private _id;
2993
3645
  private _agentId;
3646
+ private _cwd?;
2994
3647
  private _availableModes?;
2995
3648
  private _currentMode?;
2996
3649
  private _availableModels?;
@@ -3002,6 +3655,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3002
3655
  private _connectionInfo?;
3003
3656
  private listeners;
3004
3657
  private onceListeners;
3658
+ private connectionListeners;
3005
3659
  /**
3006
3660
  * Agent operations namespace
3007
3661
  */
@@ -3035,6 +3689,14 @@ declare class ActiveSessionImpl implements ActiveSession {
3035
3689
  * Agent ID
3036
3690
  */
3037
3691
  get agentId(): string;
3692
+ /**
3693
+ * Actual workspace path (set from newSession response _meta)
3694
+ */
3695
+ get cwd(): string | undefined;
3696
+ /**
3697
+ * Set actual workspace path (called by SessionManager after createSession)
3698
+ */
3699
+ setCwd(cwd: string): void;
3038
3700
  /**
3039
3701
  * Agent state (live connection state)
3040
3702
  * Returns LocalAgentState or CloudAgentState based on transport type
@@ -3140,7 +3802,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3140
3802
  * await session.setMode('architect');
3141
3803
  * ```
3142
3804
  */
3143
- setMode(modeId: string): Promise<void>;
3805
+ setMode(modeId: string, skipAvailableChecker?: boolean): Promise<void>;
3144
3806
  /**
3145
3807
  * Set the current session model
3146
3808
  *
@@ -3193,8 +3855,22 @@ declare class ActiveSessionImpl implements ActiveSession {
3193
3855
  */
3194
3856
  [Symbol.dispose](): void;
3195
3857
  private getConnectionOrThrow;
3858
+ /**
3859
+ * 在 connection 上注册 listener 并保存引用,便于 disconnect 时移除
3860
+ */
3861
+ private addConnectionListener;
3862
+ /**
3863
+ * 从 connection 上移除所有本 session 注册的 listener
3864
+ */
3865
+ private removeConnectionListeners;
3196
3866
  private setupConnectionEvents;
3197
3867
  private mapPromptResponse;
3868
+ /**
3869
+ * 判断 artifact 是否应该转发给当前 session
3870
+ * - media 类型:按 cwd 路径隔离(同 cwd 下不同 session 可共享 media)
3871
+ * - 其余类型:按 __sessionId 严格隔离
3872
+ */
3873
+ private shouldForwardArtifact;
3198
3874
  }
3199
3875
  //#endregion
3200
3876
  //#region ../agent-provider/lib/common/client/session-manager.d.ts
@@ -3271,6 +3947,18 @@ declare class SessionManager {
3271
3947
  * 7. Return ActiveSession instance (cached)
3272
3948
  */
3273
3949
  loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
3950
+ /**
3951
+ * 从 ACP response 中提取可用模型列表
3952
+ *
3953
+ * 优先级:
3954
+ * 1. response.models._meta?.['codebuddy.ai']?.availableModels - 包含完整的模型信息(字段名为 'id')
3955
+ * 2. response.models?.availableModels - 只包含基本信息(字段名为 'modelId')
3956
+ * 3. undefined - 都没有时返回 undefined
3957
+ *
3958
+ * @param response - ACP 响应对象
3959
+ * @returns ModelInfo[] | undefined
3960
+ */
3961
+ protected extractAvailableModels(response: LoadSessionResponse): ModelInfo[] | undefined;
3274
3962
  }
3275
3963
  //#endregion
3276
3964
  //#region ../agent-provider/lib/backend/backend-provider.d.ts
@@ -3287,6 +3975,13 @@ declare class SessionManager {
3287
3975
  */
3288
3976
  declare class BackendProvider implements IBackendProvider {
3289
3977
  constructor(config: BackendProviderConfig);
3978
+ /**
3979
+ * 处理 401 未授权错误
3980
+ * 先尝试刷新 token,失败后再执行登出流程
3981
+ *
3982
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
3983
+ */
3984
+ protected handleUnauthorized(): Promise<void>;
3290
3985
  /**
3291
3986
  * 获取当前账号信息
3292
3987
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3397,9 +4092,21 @@ declare class BackendProvider implements IBackendProvider {
3397
4092
  login(): Promise<void>;
3398
4093
  /**
3399
4094
  * 登出账号
3400
- * Web 环境: 通过 iframe 访问登出 URL 清除 cookie
4095
+ *
4096
+ * 策略:
4097
+ * - IOA 企业:用 iframe 走 SSO/SAML SLO 登出链路(涉及跨域重定向),通过轮询 iframe URL 变化检测完成
4098
+ * - 非 IOA 企业:直接用 httpService 请求 /console/logout,速度快
3401
4099
  */
3402
4100
  logout(): Promise<void>;
4101
+ /**
4102
+ * IOA 企业登出:通过 iframe 走 SSO/SAML SLO 登出链路
4103
+ * 轮询 iframe URL 变化检测完成,兜底超时 5 秒
4104
+ */
4105
+ private logoutViaIframe;
4106
+ /**
4107
+ * 非 IOA 企业登出:直接 HTTP 请求 /console/logout
4108
+ */
4109
+ private logoutViaHttp;
3403
4110
  /**
3404
4111
  * 批量切换插件状态
3405
4112
  * Web 环境不支持此功能
@@ -3410,6 +4117,38 @@ declare class BackendProvider implements IBackendProvider {
3410
4117
  * API: POST /billing/meter/get-enterprise-user-usage
3411
4118
  */
3412
4119
  getEnterpriseUsage(enterpriseId: string): Promise<EnterpriseUsage | null>;
4120
+ /**
4121
+ * 刷新 Token
4122
+ * 通过调用 getAccount 刷新 cookie,适用于 Cloud 场景下页面切换回来时刷新登录态
4123
+ * @returns Promise<Account | null> 刷新后的账号信息
4124
+ */
4125
+ refreshToken(): Promise<Account | null>;
4126
+ /**
4127
+ * 获取仓库分支列表
4128
+ * API 端点: GET /console/as/connector/oauth/{name}/branches
4129
+ *
4130
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
4131
+ * @param params 平台特定的查询参数
4132
+ * @param page 页码,从1开始,0表示不分页获取全部
4133
+ * @param perPage 每页数量,最大100
4134
+ * @returns Promise<OauthBranch[]> 分支列表
4135
+ */
4136
+ getBranches(connector: OauthConnectorName, params: GitHubBranchParams | GongfengBranchParams | CNBBranchParams, page?: number, perPage?: number): Promise<OauthBranch[]>;
4137
+ /**
4138
+ * 获取仓库列表
4139
+ * API 端点: GET /console/as/connector/oauth/{name}/repos
4140
+ *
4141
+ * Note: 由于工蜂原生支持的 Search 能力会匹配 path/name/description 部分,
4142
+ * 且不支持定制,不满足产品要求(只按 name 匹配),因此前端拉取全量数据后做筛选。
4143
+ *
4144
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
4145
+ * @param page 页码,从1开始,0表示不分页获取全部
4146
+ * - GitHub 只支持全量数据,必须传 0
4147
+ * - 工蜂和 CNB 依据前端逻辑而定
4148
+ * @param perPage 每页数量,最大100
4149
+ * @returns Promise<ListReposResponse> 仓库列表响应
4150
+ */
4151
+ getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
3413
4152
  }
3414
4153
  /**
3415
4154
  * 创建 BackendProvider 实例
@@ -3543,6 +4282,12 @@ declare class IPCBackendProvider implements IBackendProvider {
3543
4282
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
3544
4283
  */
3545
4284
  closeAgentManager(): Promise<void>;
4285
+ /**
4286
+ * 在外部浏览器中打开链接
4287
+ * IDE 环境: 通过 IPC 通知 IDE 使用 vscode.env.openExternal 打开 URL
4288
+ * @param url 要打开的 URL
4289
+ */
4290
+ openExternal(url: string): Promise<void>;
3546
4291
  /**
3547
4292
  * 批量切换插件状态
3548
4293
  * IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
@@ -3614,7 +4359,7 @@ type UnauthorizedCallback = () => void;
3614
4359
  * 特性:
3615
4360
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3616
4361
  * - 支持拦截器注册(其他模块可注入 header)
3617
- * - 统一 401/403 处理
4362
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3618
4363
  * - 自动携带凭证(withCredentials)
3619
4364
  * - 类型安全
3620
4365
  *
@@ -3650,6 +4395,10 @@ declare class HttpService {
3650
4395
  private axiosInstance;
3651
4396
  private unauthorizedCallbacks;
3652
4397
  private config;
4398
+ /** 是否正在刷新 token */
4399
+ private isRefreshing;
4400
+ /** 等待 token 刷新完成的请求队列 */
4401
+ private refreshSubscribers;
3653
4402
  /**
3654
4403
  * 私有构造函数(单例模式)
3655
4404
  */
@@ -3667,9 +4416,17 @@ declare class HttpService {
3667
4416
  */
3668
4417
  private registerDefaultRequestInterceptor;
3669
4418
  /**
3670
- * 注册默认响应拦截器(处理 401/403)
4419
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3671
4420
  */
3672
4421
  private registerDefaultResponseInterceptor;
4422
+ /**
4423
+ * token 刷新成功,通知所有等待的请求
4424
+ */
4425
+ private onRefreshSuccess;
4426
+ /**
4427
+ * token 刷新失败,通知所有等待的请求
4428
+ */
4429
+ private onRefreshFailure;
3673
4430
  /**
3674
4431
  * 注册请求拦截器
3675
4432
  * @param onFulfilled 请求成功拦截器
@@ -3735,7 +4492,9 @@ declare class HttpService {
3735
4492
  */
3736
4493
  offUnauthorized(callback: UnauthorizedCallback): void;
3737
4494
  /**
3738
- * 触发所有 401 回调
4495
+ * 触发所有 401 回调并等待完成
4496
+ * @returns Promise,等待所有回调完成
4497
+ * @throws 如果任何回调失败,则抛出错误
3739
4498
  */
3740
4499
  private triggerUnauthorizedCallbacks;
3741
4500
  /**