@tencent-ai/cloud-agent-sdk 0.2.12 → 0.2.13-next.06ef89d.20260310

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
347
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,50 @@ 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>;
1176
+ /**
1177
+ * 保存待发送的输入内容到后端(用于跨域登录场景)
1178
+ * API 端点: POST /api/v1/code-id
1179
+ *
1180
+ * @param code 要保存的文本内容
1181
+ * @returns Promise<string | null> 返回 codeId,失败返回 null
1182
+ */
1183
+ savePendingInput?(code: string): Promise<string | null>;
1184
+ /**
1185
+ * 从后端加载待发送的输入内容(用于跨域登录场景)
1186
+ * API 端点: GET /api/v1/code?id=xxx
1187
+ *
1188
+ * @param codeId 内容 ID
1189
+ * @returns Promise<string | null> 返回保存的文本内容,失败返回 null
1190
+ */
1191
+ loadPendingInput?(codeId: string): Promise<string | null>;
981
1192
  }
982
1193
  /**
983
1194
  * 场景中的插件信息
@@ -991,6 +1202,12 @@ interface ScenePlugin {
991
1202
  /** 插件市场名称 */
992
1203
  marketplaceName: string;
993
1204
  }
1205
+ /**
1206
+ * 场景模式类型
1207
+ * - coding: 编程相关场景
1208
+ * - working: 工作/通用场景
1209
+ */
1210
+ type SupportSceneMode = 'coding' | 'working';
994
1211
  /**
995
1212
  * 支持的场景信息
996
1213
  * 用于 Welcome 页面的 QuickActions 快捷操作
@@ -1005,11 +1222,15 @@ interface SupportScene {
1005
1222
  plugins: ScenePlugin[];
1006
1223
  /** 场景对应的 prompt 列表 */
1007
1224
  prompts: string[];
1225
+ /** 场景模式类型 */
1226
+ mode?: SupportSceneMode;
1008
1227
  }
1009
1228
  /**
1010
1229
  * 插件作用域
1230
+ * 使用 agent-craft 的 PluginInstallScope 类型
1231
+ * 注意: 当前后端 API 只支持 user 和 project,暂不支持 project-local
1011
1232
  */
1012
- type PluginScope = 'user' | 'project';
1233
+ type PluginScope = 'user' | 'project' | 'project-local' | 'local';
1013
1234
  /**
1014
1235
  * 插件操作类型
1015
1236
  */
@@ -1315,7 +1536,7 @@ type PromptContentBlock = {
1315
1536
  uri: string;
1316
1537
  mimeType?: string | null;
1317
1538
  name: string;
1318
- size?: bigint | null;
1539
+ size?: number | null;
1319
1540
  title?: string | null;
1320
1541
  _meta?: {
1321
1542
  [key: string]: unknown;
@@ -1428,6 +1649,15 @@ interface AgentConnection {
1428
1649
  error?: string;
1429
1650
  }>;
1430
1651
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
1652
+ /**
1653
+ * Report telemetry event through the standard provider chain
1654
+ * - Local: via ACP JSON-RPC → IDE EventService
1655
+ * - Cloud: via StreamableHTTP → cloud telemetry endpoint
1656
+ *
1657
+ * @param eventName - Event name / code
1658
+ * @param payload - Event data (already includes mode)
1659
+ */
1660
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
1431
1661
  }
1432
1662
  /**
1433
1663
  * Base configuration for connections
@@ -1635,6 +1865,8 @@ interface BaseAgentState {
1635
1865
  updatedAt?: Date;
1636
1866
  /** 是否为 playground */
1637
1867
  isPlayground?: boolean;
1868
+ /** Whether the title is user defined (1 = user defined) */
1869
+ isUserDefinedTitle?: number;
1638
1870
  }
1639
1871
  /**
1640
1872
  * LocalAgentState - 本地 Agent 状态
@@ -1698,6 +1930,11 @@ interface ListAgentSort {
1698
1930
  * Local: Client-side filtering and sorting, no pagination (returns all)
1699
1931
  */
1700
1932
  interface ListAgentOptions {
1933
+ /**
1934
+ * User ID for filtering sessions (required for multi-user isolation)
1935
+ * If not provided, returns empty list for Local provider
1936
+ */
1937
+ userId?: string;
1701
1938
  /**
1702
1939
  * Page number (starts from 1)
1703
1940
  * Cloud: Used for API pagination
@@ -1781,16 +2018,38 @@ interface SessionInfo {
1781
2018
  cwd?: string;
1782
2019
  /** Whether the session is a playground */
1783
2020
  isPlayground?: boolean;
2021
+ /** Whether the title is user defined (1 = user defined) */
2022
+ isUserDefinedTitle?: number;
1784
2023
  }
1785
2024
  /**
1786
2025
  * Parameters for creating a new session
1787
2026
  */
1788
2027
  interface CreateSessionParams$1 {
1789
- /** Working directory */
2028
+ /** Working directory (required) */
1790
2029
  cwd: string;
2030
+ /** Optional configuration */
2031
+ options?: CreateSessionOptions;
2032
+ }
2033
+ /**
2034
+ * Optional configuration for creating a session
2035
+ */
2036
+ interface CreateSessionOptions {
1791
2037
  /** MCP server configurations */
1792
2038
  mcpServers?: McpServerConfig[];
2039
+ /** Initial prompt for the session (Cloud only) */
2040
+ prompt?: string;
2041
+ /** Initial model for the session (Cloud only) */
2042
+ model?: string;
2043
+ /** Mode ID (e.g., 'craft', 'architect') */
2044
+ mode?: string;
2045
+ /** Whether this is a playground session (no cwd) */
2046
+ isPlayground?: boolean;
2047
+ /** Tags for template scenes (Cloud only, format: { scene: 'xxx' }) */
2048
+ tags?: Record<string, string>;
2049
+ /** Additional metadata */
1793
2050
  _meta?: Record<string, unknown>;
2051
+ /** Callback when session is prepared (POST succeeded, before WebSocket connect) */
2052
+ onSessionPrepared?: (sessionInfo: SessionInfo) => void;
1794
2053
  }
1795
2054
  /**
1796
2055
  * Parameters for loading an existing session
@@ -1825,6 +2084,80 @@ interface InitializeWorkspaceResponse {
1825
2084
  /** Error message (if failed) */
1826
2085
  error?: string;
1827
2086
  }
2087
+ type AutomationStatus = 'ACTIVE' | 'PAUSED';
2088
+ type AutomationUpdateMode = 'view' | 'suggested create' | 'suggested update';
2089
+ type AutomationRunStatus = 'ACCEPTED' | 'ARCHIVED' | 'PENDING_REVIEW' | 'IN_PROGRESS';
2090
+ interface AutomationDefinition {
2091
+ version: number;
2092
+ id: string;
2093
+ name: string;
2094
+ prompt: string;
2095
+ status: AutomationStatus;
2096
+ rrule: string;
2097
+ cwds: string[];
2098
+ created_at: number;
2099
+ updated_at: number;
2100
+ }
2101
+ interface AutomationCwdRunResult {
2102
+ cwd: string;
2103
+ success: boolean;
2104
+ startedAt: number;
2105
+ finishedAt: number;
2106
+ conversationId?: string;
2107
+ output?: string;
2108
+ error?: string;
2109
+ }
2110
+ interface AutomationInboxItem {
2111
+ id: string;
2112
+ automationId: string;
2113
+ automationName: string;
2114
+ status?: AutomationRunStatus;
2115
+ readAt?: number;
2116
+ startedAt: number;
2117
+ finishedAt: number;
2118
+ success: boolean;
2119
+ summary: string;
2120
+ runs: AutomationCwdRunResult[];
2121
+ archived?: boolean;
2122
+ archivedAt?: number;
2123
+ }
2124
+ interface AutomationRuntimeState {
2125
+ lastRunAt?: number;
2126
+ lastError?: string;
2127
+ running?: boolean;
2128
+ runningStartedAt?: number;
2129
+ runningConversationId?: string;
2130
+ }
2131
+ interface AutomationSnapshot {
2132
+ automations: AutomationDefinition[];
2133
+ inbox: AutomationInboxItem[];
2134
+ runtimeState: Record<string, AutomationRuntimeState>;
2135
+ updatedAt: number;
2136
+ }
2137
+ interface AutomationUpdatePayload {
2138
+ mode: AutomationUpdateMode;
2139
+ id?: string;
2140
+ name?: string;
2141
+ prompt?: string;
2142
+ rrule?: string;
2143
+ cwds?: string[] | string;
2144
+ status?: AutomationStatus;
2145
+ }
2146
+ interface AutomationUpdateResult {
2147
+ success: boolean;
2148
+ message: string;
2149
+ automation?: AutomationDefinition;
2150
+ snapshot?: AutomationSnapshot;
2151
+ }
2152
+ /**
2153
+ * Parameters for getting available commands
2154
+ */
2155
+ interface GetAvailableCommandsParams {
2156
+ /** Session ID to get commands for (optional, for global commands) */
2157
+ sessionId?: string;
2158
+ /** Workspace path for getting custom commands (optional) */
2159
+ workspacePath?: string;
2160
+ }
1828
2161
  /**
1829
2162
  * Prompts resource interface (ACP verbs)
1830
2163
  * Operations use the current session automatically
@@ -1862,7 +2195,7 @@ interface ModelsResource {
1862
2195
  */
1863
2196
  interface PromptResponse {
1864
2197
  /** Stop reason */
1865
- stopReason: 'end_turn' | 'max_tokens' | 'tool_use' | 'cancelled' | 'error';
2198
+ stopReason: StopReason;
1866
2199
  /** Response metadata */
1867
2200
  _meta?: Record<string, unknown>;
1868
2201
  }
@@ -1872,7 +2205,7 @@ interface PromptResponse {
1872
2205
  interface SessionsResourceEvents {
1873
2206
  /** Emitted when the sessions list changes (create, delete, update) */
1874
2207
  sessionsChanged: SessionInfo[];
1875
- /** Emitted when a new session is created */
2208
+ /** Emitted when a new session is fully connected and ready */
1876
2209
  sessionCreated: SessionInfo;
1877
2210
  /** Emitted when a session is deleted */
1878
2211
  sessionDeleted: {
@@ -1880,6 +2213,8 @@ interface SessionsResourceEvents {
1880
2213
  };
1881
2214
  /** Emitted when a session is updated (status change, etc.) */
1882
2215
  sessionUpdated: SessionInfo;
2216
+ /** Emitted when automation snapshot is updated (pushed from server) */
2217
+ automationSnapshotUpdate: AutomationSnapshot;
1883
2218
  }
1884
2219
  /**
1885
2220
  * Event handler type for sessions resource events
@@ -1956,6 +2291,8 @@ interface ActiveSession {
1956
2291
  readonly id: string;
1957
2292
  /** Agent ID */
1958
2293
  readonly agentId: string;
2294
+ /** Actual workspace path (set after newSession, useful for Playground scenario) */
2295
+ readonly cwd?: string;
1959
2296
  /** Agent state (direct access to underlying agent state) */
1960
2297
  readonly agentState: AgentState;
1961
2298
  /** Agent capabilities (available after connection) */
@@ -1999,7 +2336,7 @@ interface ActiveSession {
1999
2336
  error?: string;
2000
2337
  }>;
2001
2338
  /** Set the current session mode */
2002
- setMode(modeId: string): Promise<void>;
2339
+ setMode(modeId: string, skipChecker?: boolean): Promise<void>;
2003
2340
  /** Set the current session model */
2004
2341
  setSessionModel(modelId: string): Promise<void>;
2005
2342
  /** Set available commands (called when available_commands_update is received) */
@@ -2016,6 +2353,12 @@ interface ActiveSession {
2016
2353
  once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
2017
2354
  /** Disconnect from the session/agent */
2018
2355
  disconnect(): void;
2356
+ /**
2357
+ * Detach the session from connection events without disconnecting the connection.
2358
+ * This should be called when the session is being replaced but the connection is shared.
2359
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
2360
+ */
2361
+ detach(): void;
2019
2362
  /** Symbol.dispose for 'using' keyword support */
2020
2363
  [Symbol.dispose](): void;
2021
2364
  }
@@ -2080,6 +2423,17 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2080
2423
  rename?(agentId: string, title: string): Promise<{
2081
2424
  id: string;
2082
2425
  }>;
2426
+ /**
2427
+ * Update agent status by ID (optional)
2428
+ * Used by CloudAgentProvider for updating session status
2429
+ *
2430
+ * @param agentId - Agent ID to update
2431
+ * @param status - New status for the agent
2432
+ * @returns Object containing the updated agent ID
2433
+ */
2434
+ updateStatus?(agentId: string, status: string): Promise<{
2435
+ id: string;
2436
+ }>;
2083
2437
  /**
2084
2438
  * Move an agent by ID (optional)
2085
2439
  * Used by LocalAgentProvider for moving Playground sessions to Workspace
@@ -2099,6 +2453,30 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2099
2453
  * @returns Array of model information
2100
2454
  */
2101
2455
  getModels?(repo?: string): Promise<ModelInfo[]>;
2456
+ /**
2457
+ * Get product configuration subset (optional)
2458
+ * Returns deploymentType, creditPurchaseActions, links, networkEnvironment
2459
+ */
2460
+ getProductConfiguration?(): Promise<{
2461
+ deploymentType?: string;
2462
+ creditPurchaseActions?: Record<string, {
2463
+ labelZh: string;
2464
+ labelEn: string;
2465
+ url: string;
2466
+ showButton?: boolean;
2467
+ }>;
2468
+ links?: {
2469
+ craftFeedback?: string;
2470
+ };
2471
+ networkEnvironment?: string;
2472
+ }>;
2473
+ /**
2474
+ * Get user info (optional)
2475
+ * Returns enterpriseId from authentication session
2476
+ */
2477
+ getUserInfo?(): Promise<{
2478
+ enterpriseId?: string;
2479
+ }>;
2102
2480
  /**
2103
2481
  * Register sessionId → agentId mapping (optional, used by LocalAgentProvider)
2104
2482
  * Called after session creation to maintain the mapping for loadSession
@@ -2142,6 +2520,27 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2142
2520
  * @returns Response with search results
2143
2521
  */
2144
2522
  searchFile?(params: SearchFileParams): Promise<SearchFileResponse>;
2523
+ /**
2524
+ * Get subagent list (optional, used by LocalAgentProvider)
2525
+ *
2526
+ * @param params - Query parameters including options
2527
+ * @returns Response with subagent list
2528
+ */
2529
+ getSubagentList?(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2530
+ /**
2531
+ * Get skill list (optional, used by LocalAgentProvider)
2532
+ *
2533
+ * @param params - Query parameters
2534
+ * @returns Response with skill list
2535
+ */
2536
+ getSkillList?(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2537
+ /**
2538
+ * Import a skill folder (optional, used by LocalAgentProvider)
2539
+ *
2540
+ * @param params - Import parameters including source location
2541
+ * @returns Response with import result
2542
+ */
2543
+ importSkill?(params: ImportSkillParams): Promise<ImportSkillResponse>;
2145
2544
  /**
2146
2545
  * Batch toggle plugins (optional, used by LocalAgentProvider)
2147
2546
  *
@@ -2162,6 +2561,9 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2162
2561
  description?: string;
2163
2562
  version?: string;
2164
2563
  installScope?: 'user' | 'project';
2564
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
2565
+ installedScopesStatus?: Record<string, boolean>;
2566
+ installId?: string;
2165
2567
  }>>;
2166
2568
  /**
2167
2569
  * Install plugins (optional, used by LocalAgentProvider)
@@ -2169,12 +2571,46 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2169
2571
  * @param pluginNames - Array of plugin names to install
2170
2572
  * @param marketplaceName - Marketplace name
2171
2573
  * @param installScope - Install scope ('user' | 'project')
2574
+ * @param marketplaceSource - Marketplace source URL (for auto-adding marketplace when not exists)
2172
2575
  * @returns Result of the operation
2173
2576
  */
2174
- installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2577
+ installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2175
2578
  success: boolean;
2176
2579
  error?: string;
2177
2580
  }>;
2581
+ /**
2582
+ * Get available commands for a session (optional, used by LocalAgentProvider)
2583
+ * If session.availableCommands has cached values, return them
2584
+ * Otherwise, fetch from product configuration
2585
+ *
2586
+ * @param params - Parameters for getting commands
2587
+ * @returns Array of available commands
2588
+ */
2589
+ getAvailableCommands?(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2590
+ /**
2591
+ * Get automation snapshot (optional, used by LocalAgentProvider)
2592
+ */
2593
+ getAutomationSnapshot?(): Promise<AutomationSnapshot>;
2594
+ /**
2595
+ * Create/update automation definition (optional, used by LocalAgentProvider)
2596
+ */
2597
+ updateAutomation?(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
2598
+ /**
2599
+ * Delete automation definition (optional, used by LocalAgentProvider)
2600
+ */
2601
+ deleteAutomation?(id: string): Promise<AutomationUpdateResult>;
2602
+ /**
2603
+ * Archive an automation inbox item (optional, used by LocalAgentProvider)
2604
+ */
2605
+ archiveAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
2606
+ /**
2607
+ * Delete an automation inbox item (optional, used by LocalAgentProvider)
2608
+ */
2609
+ deleteAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
2610
+ /**
2611
+ * Trigger test run for automation (optional, used by LocalAgentProvider)
2612
+ */
2613
+ testAutomation?(id: string): Promise<AutomationUpdateResult>;
2178
2614
  /**
2179
2615
  * Register an event listener
2180
2616
  * Provider implementations should forward events to the underlying transport
@@ -2190,17 +2626,77 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2190
2626
  * @param handler - Event handler function to remove
2191
2627
  */
2192
2628
  off?(event: string, handler: (...args: any[]) => void): void;
2193
- }
2194
- /**
2195
- * AgentClient initialization options
2196
- */
2197
- interface AgentClientOptions {
2198
- /** Agent provider (required) */
2199
- provider: AgentProvider;
2200
- /** Logger instance */
2201
- logger?: Logger;
2202
- /** Client capabilities (sent during initialization) */
2203
- clientCapabilities?: ClientCapabilities$1;
2629
+ /**
2630
+ * Report telemetry event through the provider chain
2631
+ * - Local: via ACP JSON-RPC → AcpAgent → IDE EventService
2632
+ * - Cloud: via connection → cloud endpoint
2633
+ *
2634
+ * @param eventName - Event name / code
2635
+ * @param payload - Event data
2636
+ */
2637
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2638
+ /**
2639
+ * Respond to MCP Sampling confirmation request (optional, used by LocalAgentProvider)
2640
+ * Called when user confirms/rejects a sampling request
2641
+ *
2642
+ * @param sessionId - Session ID
2643
+ * @param response - Sampling confirmation response
2644
+ */
2645
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2646
+ /**
2647
+ * Respond to MCP Roots confirmation request (optional, used by LocalAgentProvider)
2648
+ * Called when user confirms/rejects a roots request
2649
+ *
2650
+ * @param sessionId - Session ID
2651
+ * @param response - Roots confirmation response
2652
+ */
2653
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2654
+ /**
2655
+ * Subscribe to MCP Sampling confirmation requests (optional, used by LocalAgentProvider)
2656
+ * Called when MCP server initiates a sampling request
2657
+ *
2658
+ * @param serverName - MCP server name
2659
+ * @param callback - Request callback
2660
+ * @returns Unsubscribe function
2661
+ */
2662
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
2663
+ /**
2664
+ * Subscribe to MCP Roots confirmation requests (optional, used by LocalAgentProvider)
2665
+ * Called when MCP server initiates a roots request
2666
+ *
2667
+ * @param serverName - MCP server name
2668
+ * @param callback - Request callback
2669
+ * @returns Unsubscribe function
2670
+ */
2671
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
2672
+ /**
2673
+ * Get product scenes from ProductManager configuration (optional, for LocalAgentProvider)
2674
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
2675
+ * @param locale - 可选,语言环境
2676
+ */
2677
+ getProductScenes?(locale?: string): Promise<Array<{
2678
+ id: number;
2679
+ name: string;
2680
+ plugins: Array<{
2681
+ id: number;
2682
+ name: string;
2683
+ marketplaceName: string;
2684
+ }>;
2685
+ prompts: string[];
2686
+ mode?: 'coding' | 'working';
2687
+ target?: 'local' | 'cloud' | 'all';
2688
+ }>>;
2689
+ }
2690
+ /**
2691
+ * AgentClient initialization options
2692
+ */
2693
+ interface AgentClientOptions {
2694
+ /** Agent provider (required) */
2695
+ provider: AgentProvider;
2696
+ /** Logger instance */
2697
+ logger?: Logger;
2698
+ /** Client capabilities (sent during initialization) */
2699
+ clientCapabilities?: ClientCapabilities$1;
2204
2700
  /**
2205
2701
  * 运行环境类型
2206
2702
  * - 'local': IDE 本地环境
@@ -2247,6 +2743,15 @@ interface ClientSessionsResource {
2247
2743
  rename(sessionId: string, title: string): Promise<{
2248
2744
  id: string;
2249
2745
  }>;
2746
+ /**
2747
+ * Update session status
2748
+ * @param sessionId - Session ID to update
2749
+ * @param status - New status for the session
2750
+ * @returns Object containing the updated session ID
2751
+ */
2752
+ updateStatus(sessionId: string, status: string): Promise<{
2753
+ id: string;
2754
+ }>;
2250
2755
  /**
2251
2756
  * Move a session (Playground → Workspace)
2252
2757
  * @param sessionId - Session ID to move
@@ -2277,6 +2782,12 @@ interface ClientSessionsResource {
2277
2782
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
2278
2783
  /** Search for files in the workspace (for LocalAgentProvider) */
2279
2784
  searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
2785
+ /** Get subagent list (for LocalAgentProvider) */
2786
+ getSubagentList(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2787
+ /** Get skill list (for LocalAgentProvider) */
2788
+ getSkillList(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2789
+ /** Import a skill folder (for LocalAgentProvider) */
2790
+ importSkill(params: ImportSkillParams): Promise<ImportSkillResponse>;
2280
2791
  /** Batch toggle plugins (for LocalAgentProvider) */
2281
2792
  batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2282
2793
  /** Get installed plugins (for LocalAgentProvider) */
@@ -2287,17 +2798,120 @@ interface ClientSessionsResource {
2287
2798
  description?: string;
2288
2799
  version?: string;
2289
2800
  installScope?: 'user' | 'project';
2801
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
2802
+ installedScopesStatus?: Record<string, boolean>;
2803
+ installId?: string;
2290
2804
  }>>;
2291
2805
  /** Install plugins (for LocalAgentProvider) */
2292
- installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
2806
+ installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2293
2807
  success: boolean;
2294
2808
  error?: string;
2295
2809
  }>;
2810
+ /** Uninstall a plugin (for LocalAgentProvider) */
2811
+ uninstallPlugin?(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
2812
+ success: boolean;
2813
+ error?: string;
2814
+ }>;
2815
+ /** Update a plugin to the latest version (for LocalAgentProvider) */
2816
+ updatePlugin?(pluginName: string, marketplaceName: string): Promise<{
2817
+ success: boolean;
2818
+ error?: string;
2819
+ }>;
2820
+ /** Get plugin marketplaces list (for LocalAgentProvider) */
2821
+ getPluginMarketplaces?(forceRefresh?: boolean): Promise<Array<{
2822
+ id: string;
2823
+ name: string;
2824
+ type: 'github' | 'local' | 'custom';
2825
+ source: {
2826
+ repo?: string;
2827
+ ref?: string;
2828
+ url?: string;
2829
+ };
2830
+ description?: string;
2831
+ isBuiltin?: boolean;
2832
+ }>>;
2833
+ /** Get plugins from a marketplace (for LocalAgentProvider) */
2834
+ getMarketplacePlugins?(marketplaceName: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
2835
+ name: string;
2836
+ marketplaceName: string;
2837
+ description?: string;
2838
+ version?: string;
2839
+ author?: string;
2840
+ homepage?: string;
2841
+ iconUrl?: string;
2842
+ tags?: string[];
2843
+ installed?: boolean;
2844
+ status?: 'enabled' | 'disabled' | 'not-installed';
2845
+ installedScopes?: Array<'user' | 'project'>;
2846
+ hasUpdate?: boolean;
2847
+ }>>;
2848
+ /** Get plugin detail (for LocalAgentProvider) */
2849
+ getPluginDetail?(pluginName: string, marketplaceName: string): Promise<{
2850
+ name: string;
2851
+ marketplaceName: string;
2852
+ description?: string;
2853
+ version?: string;
2854
+ author?: string;
2855
+ homepage?: string;
2856
+ readme?: string;
2857
+ tools?: Array<{
2858
+ name: string;
2859
+ description?: string;
2860
+ }>;
2861
+ resources?: Array<{
2862
+ name: string;
2863
+ description?: string;
2864
+ }>;
2865
+ prompts?: Array<{
2866
+ name: string;
2867
+ description?: string;
2868
+ }>;
2869
+ installed?: boolean;
2870
+ status?: 'enabled' | 'disabled' | 'not-installed';
2871
+ } | null>;
2872
+ /** Add a plugin marketplace (for LocalAgentProvider) */
2873
+ addPluginMarketplace?(source: string, name?: string): Promise<{
2874
+ success: boolean;
2875
+ error?: string;
2876
+ marketplace?: {
2877
+ id: string;
2878
+ name: string;
2879
+ type: 'github' | 'local' | 'custom';
2880
+ source: {
2881
+ repo?: string;
2882
+ ref?: string;
2883
+ url?: string;
2884
+ };
2885
+ description?: string;
2886
+ isBuiltin?: boolean;
2887
+ };
2888
+ }>;
2889
+ /** Remove a plugin marketplace (for LocalAgentProvider) */
2890
+ removePluginMarketplace?(marketplaceName: string): Promise<{
2891
+ success: boolean;
2892
+ error?: string;
2893
+ }>;
2894
+ /** Refresh a plugin marketplace (for LocalAgentProvider) */
2895
+ refreshPluginMarketplace?(marketplaceName: string): Promise<{
2896
+ success: boolean;
2897
+ error?: string;
2898
+ plugins?: Array<{
2899
+ name: string;
2900
+ marketplaceName: string;
2901
+ description?: string;
2902
+ version?: string;
2903
+ installed?: boolean;
2904
+ status?: 'enabled' | 'disabled' | 'not-installed';
2905
+ }>;
2906
+ }>;
2907
+ /** Open folder in new window (for LocalAgentProvider) */
2908
+ openFolderInNewWindow?(folderPath: string): Promise<void>;
2296
2909
  /**
2297
2910
  * Get support scenes from backend API (for LocalAgentProvider)
2298
2911
  * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
2912
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2299
2913
  */
2300
- getSupportScenes(): Promise<Array<{
2914
+ getSupportScenes(locale?: string): Promise<Array<{
2301
2915
  id: number;
2302
2916
  name: string;
2303
2917
  plugins: Array<{
@@ -2306,7 +2920,211 @@ interface ClientSessionsResource {
2306
2920
  marketplaceName: string;
2307
2921
  }>;
2308
2922
  prompts: string[];
2923
+ mode?: 'coding' | 'working';
2309
2924
  }>>;
2925
+ /**
2926
+ * Get product scenes from ProductManager configuration (for LocalAgentProvider)
2927
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
2928
+ * @param locale - 可选,语言环境
2929
+ */
2930
+ getProductScenes?(locale?: string): Promise<Array<{
2931
+ id: number;
2932
+ name: string;
2933
+ plugins: Array<{
2934
+ id: number;
2935
+ name: string;
2936
+ marketplaceName: string;
2937
+ }>;
2938
+ prompts: string[];
2939
+ mode?: 'coding' | 'working';
2940
+ target?: 'local' | 'cloud' | 'all';
2941
+ }>>;
2942
+ /**
2943
+ * Get available commands for a session
2944
+ * If session.availableCommands has cached values, return them
2945
+ * Otherwise, fetch from provider (for LocalAgentProvider)
2946
+ * @param params - Parameters for getting commands
2947
+ * @returns Promise<AvailableCommand[]> - Array of available commands
2948
+ */
2949
+ getAvailableCommands(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2950
+ /**
2951
+ * Get automation snapshot
2952
+ */
2953
+ getAutomationSnapshot(): Promise<AutomationSnapshot>;
2954
+ /**
2955
+ * Create/update automation definition
2956
+ */
2957
+ updateAutomation(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
2958
+ /**
2959
+ * Delete automation definition
2960
+ */
2961
+ deleteAutomation(id: string): Promise<AutomationUpdateResult>;
2962
+ /**
2963
+ * Archive automation inbox item
2964
+ */
2965
+ archiveAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
2966
+ /**
2967
+ * Delete automation inbox item
2968
+ */
2969
+ deleteAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
2970
+ /**
2971
+ * Trigger automation test run
2972
+ */
2973
+ testAutomation(id: string): Promise<AutomationUpdateResult>;
2974
+ /**
2975
+ * Report telemetry event through the provider chain
2976
+ * Delegates to AgentProvider.reportTelemetry()
2977
+ *
2978
+ * @param eventName - Event name / code
2979
+ * @param payload - Event data
2980
+ */
2981
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2982
+ /**
2983
+ * Get product configuration subset
2984
+ * Returns deploymentType, creditPurchaseActions, links
2985
+ * Used by agent-ui for error banner credit purchase guidance
2986
+ */
2987
+ getProductConfiguration?(): Promise<{
2988
+ deploymentType?: string;
2989
+ creditPurchaseActions?: Record<string, {
2990
+ labelZh: string;
2991
+ labelEn: string;
2992
+ url: string;
2993
+ showButton?: boolean;
2994
+ }>;
2995
+ links?: {
2996
+ craftFeedback?: string;
2997
+ };
2998
+ networkEnvironment?: string;
2999
+ }>;
3000
+ /**
3001
+ * Get user info
3002
+ * Returns enterpriseId from authentication session
3003
+ * Used by agent-ui for determining personal/enterprise user
3004
+ */
3005
+ getUserInfo?(): Promise<{
3006
+ enterpriseId?: string;
3007
+ }>;
3008
+ /**
3009
+ * Respond to MCP Sampling confirmation request
3010
+ * Called when user confirms/rejects a sampling request in MCP tool renderer
3011
+ *
3012
+ * @param sessionId - Session ID
3013
+ * @param response - Sampling confirmation response
3014
+ */
3015
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
3016
+ /**
3017
+ * Respond to MCP Roots confirmation request
3018
+ * Called when user confirms/rejects a roots request in MCP tool renderer
3019
+ *
3020
+ * @param sessionId - Session ID
3021
+ * @param response - Roots confirmation response
3022
+ */
3023
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
3024
+ /**
3025
+ * Subscribe to MCP Sampling confirmation requests
3026
+ * Called when MCP server initiates a sampling request
3027
+ *
3028
+ * @param serverName - MCP server name
3029
+ * @param callback - Request callback
3030
+ * @returns Unsubscribe function
3031
+ */
3032
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
3033
+ /**
3034
+ * Subscribe to MCP Roots confirmation requests
3035
+ * Called when MCP server initiates a roots request
3036
+ *
3037
+ * @param serverName - MCP server name
3038
+ * @param callback - Request callback
3039
+ * @returns Unsubscribe function
3040
+ */
3041
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
3042
+ }
3043
+ /**
3044
+ * MCP Sampling message role
3045
+ */
3046
+ type McpSamplingRole = 'user' | 'assistant';
3047
+ /**
3048
+ * MCP Sampling message content - text
3049
+ */
3050
+ interface McpSamplingTextContent {
3051
+ type: 'text';
3052
+ text: string;
3053
+ }
3054
+ /**
3055
+ * MCP Sampling message content - image
3056
+ */
3057
+ interface McpSamplingImageContent {
3058
+ type: 'image';
3059
+ data: string;
3060
+ mimeType: string;
3061
+ }
3062
+ /**
3063
+ * MCP Sampling message content - audio
3064
+ */
3065
+ interface McpSamplingAudioContent {
3066
+ type: 'audio';
3067
+ data: string;
3068
+ mimeType: string;
3069
+ }
3070
+ /**
3071
+ * MCP Sampling message content union type
3072
+ */
3073
+ type McpSamplingContent = McpSamplingTextContent | McpSamplingImageContent | McpSamplingAudioContent;
3074
+ /**
3075
+ * MCP Sampling message
3076
+ */
3077
+ interface McpSamplingMessage {
3078
+ role: McpSamplingRole;
3079
+ content: McpSamplingContent;
3080
+ }
3081
+ /**
3082
+ * MCP Sampling confirmation request
3083
+ * Sent from backend when MCP server requests sampling
3084
+ */
3085
+ interface McpSamplingConfirmRequest {
3086
+ id: string;
3087
+ serverName: string;
3088
+ model?: string;
3089
+ messages: McpSamplingMessage[];
3090
+ systemPrompt?: string;
3091
+ maxTokens: number;
3092
+ timestamp: number;
3093
+ }
3094
+ /**
3095
+ * MCP Sampling confirmation response
3096
+ * Sent from frontend when user confirms/rejects
3097
+ */
3098
+ interface McpSamplingConfirmResponse {
3099
+ id: string;
3100
+ approved: boolean;
3101
+ rememberChoice?: boolean;
3102
+ }
3103
+ /**
3104
+ * MCP Root definition
3105
+ */
3106
+ interface McpRoot {
3107
+ uri: string;
3108
+ name?: string;
3109
+ }
3110
+ /**
3111
+ * MCP Roots confirmation request
3112
+ * Sent from backend when MCP server requests roots access
3113
+ */
3114
+ interface McpRootsConfirmRequest {
3115
+ id: string;
3116
+ serverName: string;
3117
+ roots: McpRoot[];
3118
+ timestamp: number;
3119
+ }
3120
+ /**
3121
+ * MCP Roots confirmation response
3122
+ * Sent from frontend when user confirms/rejects
3123
+ */
3124
+ interface McpRootsConfirmResponse {
3125
+ id: string;
3126
+ approved: boolean;
3127
+ rememberChoice?: boolean;
2310
3128
  }
2311
3129
  /**
2312
3130
  * Workspace information (aligned with FolderSelectResult)
@@ -2372,6 +3190,8 @@ interface PickFolderResponse {
2372
3190
  interface UploadFileParams {
2373
3191
  /** Files to upload - File objects in browser, absolute path strings in IDE */
2374
3192
  readonly files: Array<File | string>;
3193
+ /** Optional AbortSignal to cancel the upload */
3194
+ readonly abortSignal?: AbortSignal;
2375
3195
  }
2376
3196
  /**
2377
3197
  * Response from uploading files
@@ -2385,6 +3205,8 @@ interface UploadFileResponse {
2385
3205
  readonly expireSeconds?: number;
2386
3206
  /** Error message (if upload failed) */
2387
3207
  readonly error?: string;
3208
+ /** Whether the upload was cancelled by user */
3209
+ readonly aborted?: boolean;
2388
3210
  }
2389
3211
  /**
2390
3212
  * Mention type for file/folder
@@ -2435,6 +3257,109 @@ interface SearchFileResponse {
2435
3257
  /** Error message (if failed) */
2436
3258
  readonly error?: string;
2437
3259
  }
3260
+ /**
3261
+ * Subagent information
3262
+ */
3263
+ interface SubagentInfo {
3264
+ /** Subagent name */
3265
+ name: string;
3266
+ /** Subagent description */
3267
+ description: string;
3268
+ /** System prompt */
3269
+ systemPrompt: string;
3270
+ /** File path */
3271
+ filePath?: string;
3272
+ /** Model type */
3273
+ model?: string;
3274
+ /** Agent mode */
3275
+ agentMode?: 'agentic' | 'manual';
3276
+ /** Whether enabled */
3277
+ enabled?: boolean;
3278
+ /** Model ID */
3279
+ modelID?: string;
3280
+ /** Subagent level */
3281
+ level?: 'project' | 'user';
3282
+ }
3283
+ /**
3284
+ * Parameters for getting subagent list
3285
+ */
3286
+ interface GetSubagentListParams {
3287
+ /** Search options */
3288
+ readonly options: {
3289
+ /** Search keyword (filter by name or description) */readonly search?: string; /** Limit number of results */
3290
+ readonly resultNum?: number; /** Agent mode filter */
3291
+ readonly agentMode?: 'agentic' | 'manual' | 'all'; /** Whether to return only enabled subagents */
3292
+ readonly onlyEnabled?: boolean;
3293
+ };
3294
+ /** Working directory (optional, for filtering project-level subagents) */
3295
+ readonly cwd?: string;
3296
+ }
3297
+ /**
3298
+ * Response from getting subagent list
3299
+ */
3300
+ interface GetSubagentListResponse {
3301
+ /** Subagent list */
3302
+ readonly results: SubagentInfo[];
3303
+ /** Error message (if failed) */
3304
+ readonly error?: string;
3305
+ }
3306
+ /**
3307
+ * Skill info returned from getSkillList
3308
+ */
3309
+ interface SkillInfo {
3310
+ /** Skill name */
3311
+ name: string;
3312
+ /** File path of the skill */
3313
+ filePath: string;
3314
+ /** Description of the skill */
3315
+ description: string;
3316
+ /** When to use the skill */
3317
+ whenToUse?: string;
3318
+ /** Source of the skill */
3319
+ source: 'localSettings' | 'userSettings' | 'plugin' | 'builtin';
3320
+ /** Skill type */
3321
+ type: 'prompt';
3322
+ /** License information */
3323
+ license?: string;
3324
+ /** Allowed tools */
3325
+ allowedTools?: string[];
3326
+ /** Whether the skill is disabled */
3327
+ disable?: boolean;
3328
+ }
3329
+ /**
3330
+ * Parameters for getting skill list
3331
+ */
3332
+ interface GetSkillListParams {
3333
+ /** Working directory (optional, for filtering project-level skills) */
3334
+ readonly cwd?: string;
3335
+ }
3336
+ /**
3337
+ * Response from getting skill list
3338
+ */
3339
+ interface GetSkillListResponse {
3340
+ /** Skill list */
3341
+ readonly results: SkillInfo[];
3342
+ /** Error message (if failed) */
3343
+ readonly error?: string;
3344
+ }
3345
+ /**
3346
+ * Parameters for importing a skill folder
3347
+ */
3348
+ interface ImportSkillParams {
3349
+ /** Source location: project-level or user-level */
3350
+ readonly source: 'localSettings' | 'userSettings';
3351
+ /** Working directory (optional, for project-level skill import) */
3352
+ readonly cwd?: string;
3353
+ }
3354
+ /**
3355
+ * Response from importing a skill folder
3356
+ */
3357
+ interface ImportSkillResponse {
3358
+ /** Whether the import was successful */
3359
+ readonly success: boolean;
3360
+ /** Error message (if failed) */
3361
+ readonly error?: string;
3362
+ }
2438
3363
  //#endregion
2439
3364
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
2440
3365
  /**
@@ -2466,6 +3391,17 @@ declare class CloudAgentConnection implements AgentConnection {
2466
3391
  readonly transport: "cloud";
2467
3392
  readonly cwd: string;
2468
3393
  constructor(agentId: string, config: CloudConnectionConfig, cwd?: string);
3394
+ /**
3395
+ * Check whether a notification belongs to this connection's own session.
3396
+ *
3397
+ * CloudConnection.createSession() overrides sessionId to agentId, so the
3398
+ * rest of the client stack uses agentId as the canonical session
3399
+ * identifier. Notifications whose sessionId differs from agentId
3400
+ * originate from sub-agent sessions running inside the same sandbox and
3401
+ * should be silently ignored at this layer — the adapter layer handles
3402
+ * sub-agent messages independently via parentToolUseId in _meta.
3403
+ */
3404
+ private isOwnSessionNotification;
2469
3405
  private setupEventForwarding;
2470
3406
  on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
2471
3407
  off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
@@ -2513,6 +3449,7 @@ declare class CloudAgentConnection implements AgentConnection {
2513
3449
  * Contains sandboxId, link, token, etc.
2514
3450
  */
2515
3451
  get sessionConnectionInfo(): SessionConnectionInfo | undefined;
3452
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2516
3453
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2517
3454
  }
2518
3455
  //#endregion
@@ -2635,6 +3572,22 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2635
3572
  private cosUploadService;
2636
3573
  /** Event listeners for provider-level events */
2637
3574
  private eventListeners;
3575
+ /** 产品配置缓存(内存),用于存储 deploymentType 和 creditPurchaseActions */
3576
+ private productConfigCache;
3577
+ /**
3578
+ * Plugin marketplace cache (name/id -> marketplace info)
3579
+ * LRU 缓存,容量上限 200
3580
+ * Key: marketplace name 或 id
3581
+ * Value: marketplace 完整信息
3582
+ */
3583
+ private marketplaceCache;
3584
+ /**
3585
+ * Installed plugin cache (plugin name -> plugin info with install_id)
3586
+ * LRU 缓存,容量上限 2000
3587
+ * Key: plugin name
3588
+ * Value: plugin 完整信息(包含 installId)
3589
+ */
3590
+ private pluginCache;
2638
3591
  constructor(options: CloudAgentProviderOptions);
2639
3592
  /**
2640
3593
  * Dispose the provider and clean up resources
@@ -2691,8 +3644,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2691
3644
  /**
2692
3645
  * Create a new conversation
2693
3646
  * POST {endpoint}/console/as/conversations
3647
+ * @param params - Session params containing cwd and optional configuration
2694
3648
  */
2695
- create(): Promise<string>;
3649
+ create(params: CreateSessionParams$1): Promise<string>;
2696
3650
  /**
2697
3651
  * Connect to an agent and return the connection
2698
3652
  *
@@ -2744,6 +3698,21 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2744
3698
  * ```
2745
3699
  */
2746
3700
  rename(agentId: string, title: string): Promise<PatchConversationResponse>;
3701
+ /**
3702
+ * Update conversation status by ID
3703
+ * POST {endpoint}/console/as/conversations/{agentId}
3704
+ *
3705
+ * @param agentId - Conversation ID to update
3706
+ * @param status - New status for the conversation
3707
+ * @returns PatchConversationResponse containing the updated conversation ID
3708
+ *
3709
+ * @example
3710
+ * ```typescript
3711
+ * const result = await provider.updateStatus('agent-123', 'completed');
3712
+ * console.log('Updated conversation status:', result.id);
3713
+ * ```
3714
+ */
3715
+ updateStatus(agentId: string, status: string): Promise<PatchConversationResponse>;
2747
3716
  /**
2748
3717
  * Get available models from product configuration
2749
3718
  *
@@ -2756,6 +3725,25 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2756
3725
  * @returns Array of ModelInfo with full model details
2757
3726
  */
2758
3727
  getModels(repo?: string): Promise<ModelInfo[]>;
3728
+ /**
3729
+ * 获取产品部署类型(从缓存)
3730
+ * 需要先调用 getModels() 初始化缓存
3731
+ *
3732
+ * @returns 部署类型:'SaaS' | 'Cloud-Hosted' | 'Self-Hosted',默认为 'SaaS'
3733
+ */
3734
+ getDeploymentType(): string;
3735
+ /**
3736
+ * 获取 Credit 购买引导配置(从缓存)
3737
+ * 需要先调用 getModels() 初始化缓存
3738
+ *
3739
+ * @returns Credit 购买引导配置,key 为错误码。如果后端未返回,则使用默认配置
3740
+ */
3741
+ getCreditPurchaseActions(): Record<string, {
3742
+ labelZh: string;
3743
+ labelEn: string;
3744
+ url: string;
3745
+ showButton?: boolean;
3746
+ }>;
2759
3747
  /**
2760
3748
  * Generate a unique request ID
2761
3749
  */
@@ -2778,7 +3766,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2778
3766
  /**
2779
3767
  * Upload files to cloud storage via COS presigned URL
2780
3768
  *
2781
- * @param params - files array (File objects in browser)
3769
+ * @param params - files array (File objects in browser), optional abortSignal
2782
3770
  * @returns Response with corresponding cloud URLs
2783
3771
  */
2784
3772
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
@@ -2802,53 +3790,282 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2802
3790
  private emitEvent;
2803
3791
  /**
2804
3792
  * 获取支持的场景列表
2805
- * API 端点: GET /console/as/support/scenes
3793
+ * API 端点: GET /v2/as/support/scenes (不鉴权)
2806
3794
  * 用于 Welcome 页面的 QuickActions 快捷操作
2807
3795
  *
3796
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
2808
3797
  * @returns Promise<SupportScene[]> 支持的场景列表
2809
3798
  */
2810
- getSupportScenes(): Promise<SupportScene[]>;
3799
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
2811
3800
  private toAgentState;
2812
3801
  /**
2813
3802
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
2814
3803
  */
2815
3804
  private buildGetUrl;
3805
+ /**
3806
+ * 获取已安装插件列表
3807
+ * GET /console/as/user/plugins/installed
3808
+ */
3809
+ getInstalledPlugins(forceRefresh?: boolean): Promise<Array<{
3810
+ name: string;
3811
+ marketplaceName: string;
3812
+ status: string;
3813
+ description?: string;
3814
+ version?: string;
3815
+ installScope?: 'user' | 'project';
3816
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
3817
+ installId?: string;
3818
+ }>>;
3819
+ /**
3820
+ * 安装插件
3821
+ * POST /console/as/user/plugins/install
3822
+ *
3823
+ * @param pluginNames - 插件名称数组
3824
+ * @param marketplaceNameOrId - 市场名称或 ID
3825
+ */
3826
+ installPlugins(pluginNames: string[], marketplaceNameOrId: string, installScope?: 'user' | 'project' | 'project-local', marketplaceSource?: string, workspacePath?: string): Promise<{
3827
+ success: boolean;
3828
+ error?: string;
3829
+ }>;
3830
+ /**
3831
+ * 卸载插件
3832
+ * POST /console/as/user/plugins/installed/:id/uninstall
3833
+ *
3834
+ * 完整链路:
3835
+ * CloudAgentProvider.uninstallPlugin()
3836
+ * -> HTTP POST /console/as/user/plugins/installed/:id/uninstall
3837
+ * -> agentserver: PluginInstallService.Uninstall()
3838
+ * -> 软删除 DB + 异步同步到活跃沙箱
3839
+ *
3840
+ * @param pluginName - 插件名称
3841
+ * @param marketplaceName - 市场名称(用于标识唯一插件)
3842
+ * @param scope - 卸载范围 ('user' | 'project' | 'project-local')
3843
+ */
3844
+ uninstallPlugin(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
3845
+ success: boolean;
3846
+ error?: string;
3847
+ }>;
3848
+ /**
3849
+ * 获取插件市场列表
3850
+ * GET /console/as/marketplace/sources
3851
+ */
3852
+ getPluginMarketplaces(forceRefresh?: boolean): Promise<Array<{
3853
+ id: string;
3854
+ name: string;
3855
+ type: 'github' | 'local' | 'custom';
3856
+ source: {
3857
+ repo?: string;
3858
+ ref?: string;
3859
+ url?: string;
3860
+ };
3861
+ description?: string;
3862
+ isBuiltin?: boolean;
3863
+ }>>;
3864
+ /**
3865
+ * 获取市场下的插件列表
3866
+ * - 有 searchText: GET /console/as/marketplace/plugins/search (跨所有市场搜索)
3867
+ * - 无 searchText: GET /console/as/marketplace/plugins (指定市场)
3868
+ *
3869
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
3870
+ * @param forceRefresh - 是否强制刷新
3871
+ * @param searchText - 搜索关键字(如果提供,则跨所有市场搜索)
3872
+ */
3873
+ getMarketplacePlugins(marketplaceNameOrId: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
3874
+ name: string;
3875
+ marketplaceName: string;
3876
+ description?: string;
3877
+ version?: string;
3878
+ author?: string;
3879
+ homepage?: string;
3880
+ iconUrl?: string;
3881
+ tags?: string[];
3882
+ installed?: boolean;
3883
+ status?: 'enabled' | 'disabled' | 'not-installed';
3884
+ installedScopes?: Array<'user' | 'project'>;
3885
+ hasUpdate?: boolean;
3886
+ latestVersion?: string;
3887
+ agents?: any;
3888
+ commands?: any;
3889
+ skills?: any;
3890
+ mcpServers?: any;
3891
+ hooks?: any;
3892
+ rules?: any;
3893
+ }>>;
3894
+ /**
3895
+ * 获取插件详情
3896
+ * GET /console/as/marketplace/plugins/:name/detail
3897
+ *
3898
+ * @param pluginName - 插件名称
3899
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
3900
+ */
3901
+ getPluginDetail(pluginName: string, marketplaceNameOrId: string): Promise<{
3902
+ name: string;
3903
+ marketplaceName: string;
3904
+ description?: string;
3905
+ version?: string;
3906
+ author?: string;
3907
+ homepage?: string;
3908
+ iconUrl?: string;
3909
+ tags?: string[];
3910
+ installed?: boolean;
3911
+ status?: 'enabled' | 'disabled' | 'not-installed';
3912
+ installedScopes?: Array<'user' | 'project'>;
3913
+ readme?: string;
3914
+ configSchema?: Record<string, unknown>;
3915
+ tools?: Array<{
3916
+ name: string;
3917
+ description?: string;
3918
+ }>;
3919
+ resources?: Array<{
3920
+ name: string;
3921
+ description?: string;
3922
+ }>;
3923
+ prompts?: Array<{
3924
+ name: string;
3925
+ description?: string;
3926
+ }>;
3927
+ downloadCount?: number;
3928
+ lastUpdated?: string;
3929
+ license?: string;
3930
+ repositoryUrl?: string;
3931
+ } | null>;
3932
+ /**
3933
+ * 添加插件市场
3934
+ * POST /console/as/marketplace/sources
3935
+ */
3936
+ addPluginMarketplace(sourceUrl: string, name?: string): Promise<{
3937
+ success: boolean;
3938
+ error?: string;
3939
+ marketplace?: {
3940
+ id: string;
3941
+ name: string;
3942
+ type: 'github' | 'local' | 'custom';
3943
+ source: {
3944
+ repo?: string;
3945
+ ref?: string;
3946
+ url?: string;
3947
+ };
3948
+ description?: string;
3949
+ isBuiltin?: boolean;
3950
+ };
3951
+ }>;
3952
+ /**
3953
+ * 删除插件市场
3954
+ * POST /console/as/marketplace/sources/:id/delete
3955
+ */
3956
+ removePluginMarketplace(marketplaceNameOrId: string): Promise<{
3957
+ success: boolean;
3958
+ error?: string;
3959
+ }>;
3960
+ /**
3961
+ * 刷新插件市场
3962
+ * POST /console/as/marketplace/sources/:id/check-updates
3963
+ */
3964
+ refreshPluginMarketplace(marketplaceNameOrId: string): Promise<{
3965
+ success: boolean;
3966
+ error?: string;
3967
+ plugins?: Array<any>;
3968
+ }>;
3969
+ /**
3970
+ * 批量切换插件启用/禁用状态
3971
+ * POST /console/as/user/plugins/installed/:id/toggle
3972
+ */
3973
+ batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
3974
+ /**
3975
+ * 将后端插件数据映射为前端格式
3976
+ */
3977
+ private mapPluginData;
3978
+ /**
3979
+ * 从缓存中查找插件的 install_id
3980
+ * 如果缓存未命中,则调用 API 获取并缓存
3981
+ *
3982
+ * @param pluginName - 插件名称
3983
+ * @returns install_id 或 null
3984
+ */
3985
+ private findPluginInstallId;
3986
+ /**
3987
+ * 从缓存中查找 marketplace ID
3988
+ * 如果缓存未命中,则调用 API 获取并缓存
3989
+ */
3990
+ private findMarketplaceId;
3991
+ /**
3992
+ * 提取 API 错误信息
3993
+ * 从 AxiosError 中提取详细的错误信息,包括 HTTP 状态码、错误码和错误消息
3994
+ */
3995
+ private extractErrorMessage;
3996
+ /**
3997
+ * 映射后端 source_type 到前端类型
3998
+ */
3999
+ private mapSourceType;
4000
+ /**
4001
+ * 解析 capabilities JSON 字符串
4002
+ */
4003
+ private parseCapabilities;
4004
+ /**
4005
+ * 上报 telemetry 事件(Cloud 模式)
4006
+ * 通过 HTTP POST 发送到 /v2/report
4007
+ * 注入用户信息和浏览器环境等公共字段
4008
+ */
4009
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2816
4010
  }
2817
4011
  //#endregion
2818
4012
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
2819
4013
  /**
2820
- * E2B Filesystem Implementation
4014
+ * Callback to fetch fresh sandbox connection info from backend.
4015
+ * Called when an operation fails with 401/403.
4016
+ */
4017
+ type ReconnectFn = () => Promise<E2BSandboxConnectionInfo>;
4018
+ /**
4019
+ * E2B Filesystem
2821
4020
  *
2822
- * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource interface.
4021
+ * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource.
4022
+ * When `reconnectFn` is provided, automatically reconnects on auth errors.
2823
4023
  *
2824
4024
  * @example
2825
4025
  * ```typescript
2826
- * const fs = await E2BFilesystem.connect({
2827
- * sandboxId: 'sandbox-123',
2828
- * apiKey: 'e2b_xxx'
2829
- * });
4026
+ * // Basic usage (no auto-reconnect)
4027
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
2830
4028
  *
2831
- * // Read/write files
2832
- * await fs.write('/test.txt', 'Hello World');
2833
- * const content = await fs.read('/test.txt');
2834
- *
2835
- * // Watch for changes
2836
- * const handle = await fs.watchDir('/workspace', (event) => {
2837
- * console.log('File changed:', event);
2838
- * });
4029
+ * // With auto-reconnect on token expiry
4030
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
4031
+ * fs.setReconnectFn(async () => fetchFreshConnectionInfo());
2839
4032
  * ```
2840
4033
  */
2841
4034
  declare class E2BFilesystem implements FilesResource {
2842
4035
  private sandbox;
4036
+ private reconnectFn?;
4037
+ /** Whether a reconnect is currently in-flight */
4038
+ private isReconnecting;
4039
+ /** Callers waiting for the in-flight reconnect to complete */
4040
+ private reconnectSubscribers;
4041
+ /** Timestamp of last reconnect attempt (anti-loop: min 10s between attempts) */
4042
+ private lastReconnectAt;
4043
+ private static readonly MIN_RECONNECT_INTERVAL_MS;
2843
4044
  constructor(sandbox: Sandbox);
2844
4045
  /**
2845
4046
  * Connect to an E2B Sandbox and create filesystem instance
2846
4047
  */
2847
4048
  static connect(info: E2BSandboxConnectionInfo): Promise<E2BFilesystem>;
4049
+ /**
4050
+ * Set reconnect callback. When set, auth errors trigger automatic reconnect + retry.
4051
+ */
4052
+ setReconnectFn(fn: ReconnectFn): void;
2848
4053
  /**
2849
4054
  * Get the underlying E2B Sandbox instance
2850
4055
  */
2851
4056
  getSandbox(): Sandbox;
4057
+ private isAuthError;
4058
+ private canAttemptReconnect;
4059
+ /**
4060
+ * Reconnect with fresh credentials.
4061
+ * Only one reconnect in-flight at a time; concurrent callers share the result.
4062
+ */
4063
+ private reconnect;
4064
+ /**
4065
+ * Execute an operation. If reconnectFn is set and an auth error occurs,
4066
+ * reconnect and retry once.
4067
+ */
4068
+ private exec;
2852
4069
  read(path: string, opts?: FilesystemRequestOpts & {
2853
4070
  format?: 'text';
2854
4071
  }): Promise<string>;
@@ -2991,6 +4208,7 @@ interface ActiveSessionImplOptions {
2991
4208
  declare class ActiveSessionImpl implements ActiveSession {
2992
4209
  private _id;
2993
4210
  private _agentId;
4211
+ private _cwd?;
2994
4212
  private _availableModes?;
2995
4213
  private _currentMode?;
2996
4214
  private _availableModels?;
@@ -3002,6 +4220,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3002
4220
  private _connectionInfo?;
3003
4221
  private listeners;
3004
4222
  private onceListeners;
4223
+ private connectionListeners;
3005
4224
  /**
3006
4225
  * Agent operations namespace
3007
4226
  */
@@ -3035,6 +4254,14 @@ declare class ActiveSessionImpl implements ActiveSession {
3035
4254
  * Agent ID
3036
4255
  */
3037
4256
  get agentId(): string;
4257
+ /**
4258
+ * Actual workspace path (set from newSession response _meta)
4259
+ */
4260
+ get cwd(): string | undefined;
4261
+ /**
4262
+ * Set actual workspace path (called by SessionManager after createSession)
4263
+ */
4264
+ setCwd(cwd: string): void;
3038
4265
  /**
3039
4266
  * Agent state (live connection state)
3040
4267
  * Returns LocalAgentState or CloudAgentState based on transport type
@@ -3140,7 +4367,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3140
4367
  * await session.setMode('architect');
3141
4368
  * ```
3142
4369
  */
3143
- setMode(modeId: string): Promise<void>;
4370
+ setMode(modeId: string, skipAvailableChecker?: boolean): Promise<void>;
3144
4371
  /**
3145
4372
  * Set the current session model
3146
4373
  *
@@ -3179,6 +4406,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3179
4406
  * Disconnect from the session/agent
3180
4407
  */
3181
4408
  disconnect(): void;
4409
+ /**
4410
+ * Detach the session from connection events without disconnecting the connection.
4411
+ * This should be called when the session is being replaced but the connection is shared.
4412
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
4413
+ */
4414
+ detach(): void;
3182
4415
  /**
3183
4416
  * Symbol.dispose for 'using' keyword support
3184
4417
  * Automatically disconnects and cleans up when session goes out of scope
@@ -3193,8 +4426,22 @@ declare class ActiveSessionImpl implements ActiveSession {
3193
4426
  */
3194
4427
  [Symbol.dispose](): void;
3195
4428
  private getConnectionOrThrow;
4429
+ /**
4430
+ * 在 connection 上注册 listener 并保存引用,便于 disconnect 时移除
4431
+ */
4432
+ private addConnectionListener;
4433
+ /**
4434
+ * 从 connection 上移除所有本 session 注册的 listener
4435
+ */
4436
+ private removeConnectionListeners;
3196
4437
  private setupConnectionEvents;
3197
4438
  private mapPromptResponse;
4439
+ /**
4440
+ * 判断 artifact 是否应该转发给当前 session
4441
+ * - media 类型:按 cwd 路径隔离(同 cwd 下不同 session 可共享 media)
4442
+ * - 其余类型:按 __sessionId 严格隔离
4443
+ */
4444
+ private shouldForwardArtifact;
3198
4445
  }
3199
4446
  //#endregion
3200
4447
  //#region ../agent-provider/lib/common/client/session-manager.d.ts
@@ -3271,6 +4518,18 @@ declare class SessionManager {
3271
4518
  * 7. Return ActiveSession instance (cached)
3272
4519
  */
3273
4520
  loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
4521
+ /**
4522
+ * 从 ACP response 中提取可用模型列表
4523
+ *
4524
+ * 优先级:
4525
+ * 1. response.models._meta?.['codebuddy.ai']?.availableModels - 包含完整的模型信息(字段名为 'id')
4526
+ * 2. response.models?.availableModels - 只包含基本信息(字段名为 'modelId')
4527
+ * 3. undefined - 都没有时返回 undefined
4528
+ *
4529
+ * @param response - ACP 响应对象
4530
+ * @returns ModelInfo[] | undefined
4531
+ */
4532
+ protected extractAvailableModels(response: LoadSessionResponse): ModelInfo[] | undefined;
3274
4533
  }
3275
4534
  //#endregion
3276
4535
  //#region ../agent-provider/lib/backend/backend-provider.d.ts
@@ -3287,6 +4546,13 @@ declare class SessionManager {
3287
4546
  */
3288
4547
  declare class BackendProvider implements IBackendProvider {
3289
4548
  constructor(config: BackendProviderConfig);
4549
+ /**
4550
+ * 处理 401 未授权错误
4551
+ * 先尝试刷新 token,失败后再执行登出流程
4552
+ *
4553
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
4554
+ */
4555
+ protected handleUnauthorized(): Promise<void>;
3290
4556
  /**
3291
4557
  * 获取当前账号信息
3292
4558
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3397,9 +4663,21 @@ declare class BackendProvider implements IBackendProvider {
3397
4663
  login(): Promise<void>;
3398
4664
  /**
3399
4665
  * 登出账号
3400
- * Web 环境: 通过 iframe 访问登出 URL 清除 cookie
4666
+ *
4667
+ * 策略:
4668
+ * - IOA 企业:用 iframe 走 SSO/SAML SLO 登出链路(涉及跨域重定向),通过轮询 iframe URL 变化检测完成
4669
+ * - 非 IOA 企业:直接用 httpService 请求 /console/logout,速度快
3401
4670
  */
3402
4671
  logout(): Promise<void>;
4672
+ /**
4673
+ * IOA 企业登出:通过 iframe 走 SSO/SAML SLO 登出链路
4674
+ * 轮询 iframe URL 变化检测完成,兜底超时 5 秒
4675
+ */
4676
+ private logoutViaIframe;
4677
+ /**
4678
+ * 非 IOA 企业登出:直接 HTTP 请求 /console/logout
4679
+ */
4680
+ private logoutViaHttp;
3403
4681
  /**
3404
4682
  * 批量切换插件状态
3405
4683
  * Web 环境不支持此功能
@@ -3410,6 +4688,48 @@ declare class BackendProvider implements IBackendProvider {
3410
4688
  * API: POST /billing/meter/get-enterprise-user-usage
3411
4689
  */
3412
4690
  getEnterpriseUsage(enterpriseId: string): Promise<EnterpriseUsage | null>;
4691
+ /**
4692
+ * 刷新 Token
4693
+ * 通过调用 getAccount 刷新 cookie,适用于 Cloud 场景下页面切换回来时刷新登录态
4694
+ * @returns Promise<Account | null> 刷新后的账号信息
4695
+ */
4696
+ refreshToken(): Promise<Account | null>;
4697
+ /**
4698
+ * 获取仓库分支列表
4699
+ * API 端点: GET /console/as/connector/oauth/{name}/branches
4700
+ *
4701
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
4702
+ * @param params 平台特定的查询参数
4703
+ * @param page 页码,从1开始,0表示不分页获取全部
4704
+ * @param perPage 每页数量,最大100
4705
+ * @returns Promise<OauthBranch[]> 分支列表
4706
+ */
4707
+ getBranches(connector: OauthConnectorName, params: GitHubBranchParams | GongfengBranchParams | CNBBranchParams, page?: number, perPage?: number): Promise<OauthBranch[]>;
4708
+ /**
4709
+ * 获取仓库列表
4710
+ * API 端点: GET /console/as/connector/oauth/{name}/repos
4711
+ *
4712
+ * Note: 由于工蜂原生支持的 Search 能力会匹配 path/name/description 部分,
4713
+ * 且不支持定制,不满足产品要求(只按 name 匹配),因此前端拉取全量数据后做筛选。
4714
+ *
4715
+ * @param connector 连接器名称 ('github' | 'gongfeng' | 'cnb')
4716
+ * @param page 页码,从1开始,0表示不分页获取全部
4717
+ * - GitHub 只支持全量数据,必须传 0
4718
+ * - 工蜂和 CNB 依据前端逻辑而定
4719
+ * @param perPage 每页数量,最大100
4720
+ * @returns Promise<ListReposResponse> 仓库列表响应
4721
+ */
4722
+ getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
4723
+ /**
4724
+ * 保存待发送的输入内容到后端
4725
+ * API 端点: POST /api/v1/code-id
4726
+ */
4727
+ savePendingInput(code: string): Promise<string | null>;
4728
+ /**
4729
+ * 从后端加载待发送的输入内容
4730
+ * API 端点: GET /api/v1/code?id=xxx
4731
+ */
4732
+ loadPendingInput(codeId: string): Promise<string | null>;
3413
4733
  }
3414
4734
  /**
3415
4735
  * 创建 BackendProvider 实例
@@ -3543,6 +4863,12 @@ declare class IPCBackendProvider implements IBackendProvider {
3543
4863
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
3544
4864
  */
3545
4865
  closeAgentManager(): Promise<void>;
4866
+ /**
4867
+ * 在外部浏览器中打开链接
4868
+ * IDE 环境: 通过 IPC 通知 IDE 使用 vscode.env.openExternal 打开 URL
4869
+ * @param url 要打开的 URL
4870
+ */
4871
+ openExternal(url: string): Promise<void>;
3546
4872
  /**
3547
4873
  * 批量切换插件状态
3548
4874
  * IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
@@ -3614,7 +4940,7 @@ type UnauthorizedCallback = () => void;
3614
4940
  * 特性:
3615
4941
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3616
4942
  * - 支持拦截器注册(其他模块可注入 header)
3617
- * - 统一 401/403 处理
4943
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3618
4944
  * - 自动携带凭证(withCredentials)
3619
4945
  * - 类型安全
3620
4946
  *
@@ -3650,6 +4976,10 @@ declare class HttpService {
3650
4976
  private axiosInstance;
3651
4977
  private unauthorizedCallbacks;
3652
4978
  private config;
4979
+ /** 是否正在刷新 token */
4980
+ private isRefreshing;
4981
+ /** 等待 token 刷新完成的请求队列 */
4982
+ private refreshSubscribers;
3653
4983
  /**
3654
4984
  * 私有构造函数(单例模式)
3655
4985
  */
@@ -3667,9 +4997,17 @@ declare class HttpService {
3667
4997
  */
3668
4998
  private registerDefaultRequestInterceptor;
3669
4999
  /**
3670
- * 注册默认响应拦截器(处理 401/403)
5000
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3671
5001
  */
3672
5002
  private registerDefaultResponseInterceptor;
5003
+ /**
5004
+ * token 刷新成功,通知所有等待的请求
5005
+ */
5006
+ private onRefreshSuccess;
5007
+ /**
5008
+ * token 刷新失败,通知所有等待的请求
5009
+ */
5010
+ private onRefreshFailure;
3673
5011
  /**
3674
5012
  * 注册请求拦截器
3675
5013
  * @param onFulfilled 请求成功拦截器
@@ -3735,7 +5073,9 @@ declare class HttpService {
3735
5073
  */
3736
5074
  offUnauthorized(callback: UnauthorizedCallback): void;
3737
5075
  /**
3738
- * 触发所有 401 回调
5076
+ * 触发所有 401 回调并等待完成
5077
+ * @returns Promise,等待所有回调完成
5078
+ * @throws 如果任何回调失败,则抛出错误
3739
5079
  */
3740
5080
  private triggerUnauthorizedCallbacks;
3741
5081
  /**