@tencent-ai/cloud-agent-sdk 0.2.13 → 0.2.14-next.17885cf.20260323

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.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- 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";
3
- import { EntryInfo, EntryInfo as EntryInfo$1, Filesystem, FilesystemEvent, FilesystemEvent as FilesystemEvent$1, Sandbox, WatchHandle, WriteInfo } from "e2b";
2
+ 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";
3
+ import { Sandbox } from "e2b";
4
4
 
5
5
  //#region ../agent-client-protocol/lib/common/types.d.ts
6
6
  /**
@@ -235,6 +235,12 @@ interface CodebuddyClientMeta {
235
235
  artifacts?: ArtifactsConfig;
236
236
  /** Whether the client supports checkpoint notifications */
237
237
  checkpoint?: boolean;
238
+ /**
239
+ * Whether the client supports handling AskUserQuestion tool via extMethod.
240
+ * When true, AskUserQuestion requests will be sent to the client via
241
+ * the '_codebuddy.ai/question' extMethod instead of being handled locally.
242
+ */
243
+ question?: boolean;
238
244
  }
239
245
  /**
240
246
  * codebuddy.ai extension capabilities for Agent
@@ -339,6 +345,35 @@ interface ClientEvents extends Record<string, unknown> {
339
345
  */
340
346
  type QuestionAnswers = Record<string, string | string[]>;
341
347
  //#endregion
348
+ //#region ../agent-client-protocol/lib/common/client/errors.d.ts
349
+ /**
350
+ * Custom error classes for Streamable HTTP ACP Client
351
+ */
352
+ /**
353
+ * Base error class for all ACP client errors
354
+ */
355
+ declare class ACPClientError extends Error {
356
+ readonly code: string;
357
+ readonly cause?: Error;
358
+ constructor(message: string, code: string, cause?: Error);
359
+ }
360
+ /**
361
+ * Error thrown for session-related failures
362
+ */
363
+ declare class SessionError extends ACPClientError {
364
+ readonly sessionId?: string;
365
+ /**
366
+ * Agent ID associated with the failed session operation.
367
+ * Available when session/new fails after agent creation + connection established.
368
+ * Can be used with `retryNewSession()` to recover from transient failures.
369
+ *
370
+ * @experimental This field is subject to change
371
+ */
372
+ readonly agentId?: string;
373
+ constructor(message: string, sessionId?: string, cause?: Error);
374
+ constructor(message: string, sessionId?: string, agentId?: string, cause?: Error);
375
+ }
376
+ //#endregion
342
377
  //#region ../agent-provider/lib/backend/service/oauth-repository-types.d.ts
343
378
  /**
344
379
  * OAuth Repository Types
@@ -727,6 +762,56 @@ interface ReasoningConfig {
727
762
  /** 摘要模式 */
728
763
  summary: 'auto' | 'always' | 'never';
729
764
  }
765
+ /**
766
+ * 本地自定义模型配置
767
+ * 对应 ~/.codebuddy/models.json 中的单个模型定义
768
+ */
769
+ interface LocalCustomModelConfig {
770
+ /** 模型唯一标识(同时作为请求时使用的 model 参数) */
771
+ id: string;
772
+ /** 模型展示名 */
773
+ name?: string;
774
+ /** 提供商名称 */
775
+ vendor?: string;
776
+ /** OpenAI 兼容接口地址(完整路径) */
777
+ url?: string;
778
+ /** API Key */
779
+ apiKey?: string;
780
+ /** 最大输入 token 数 */
781
+ maxInputTokens?: number;
782
+ /** 最大输出 token 数 */
783
+ maxOutputTokens?: number;
784
+ /** 温度 */
785
+ temperature?: number;
786
+ /** 是否支持工具调用 */
787
+ supportsToolCall?: boolean;
788
+ /** 是否支持图片输入 */
789
+ supportsImages?: boolean;
790
+ /** 是否支持推理 */
791
+ supportsReasoning?: boolean;
792
+ }
793
+ /**
794
+ * 获取本地自定义模型响应
795
+ */
796
+ interface GetLocalCustomModelsResponse {
797
+ /** 用户级 models.json 中配置的模型列表 */
798
+ models: LocalCustomModelConfig[];
799
+ /** 原始 availableModels 配置 */
800
+ availableModels?: string[];
801
+ /** 配置文件路径 */
802
+ path: string;
803
+ }
804
+ /**
805
+ * 保存本地自定义模型请求
806
+ */
807
+ interface SaveLocalCustomModelRequest {
808
+ /** 新模型配置 */
809
+ model: LocalCustomModelConfig;
810
+ /** 编辑时旧的模型 ID(用于重命名) */
811
+ previousId?: string;
812
+ /** 是否加入可见模型列表,默认 true */
813
+ visible?: boolean;
814
+ }
730
815
  /**
731
816
  * 用户连接器信息
732
817
  */
@@ -995,6 +1080,57 @@ interface BackendProviderConfig {
995
1080
  /** 认证 Token */
996
1081
  authToken?: string;
997
1082
  }
1083
+ /**
1084
+ * 签到状态响应
1085
+ */
1086
+ interface CheckinStatusResponse {
1087
+ /** 活动是否开启 */
1088
+ active: boolean;
1089
+ /** 今天是否已签到 */
1090
+ today_checked_in: boolean;
1091
+ /** 当前连续签到天数 */
1092
+ streak_days: number;
1093
+ /** 普通日签 credit 数量 */
1094
+ daily_credit: number;
1095
+ /** 今天签到可获得的 credit 数量 */
1096
+ today_credit: number;
1097
+ /** 今天是否是连续签到奖励日 */
1098
+ is_streak_day: boolean;
1099
+ /** 距离下一个连续签到奖励日还需签到天数(0 表示今天就是) */
1100
+ next_streak_day: number;
1101
+ /** 签到日期列表(yyyy-MM-dd 格式) */
1102
+ checkin_dates: string[];
1103
+ }
1104
+ /**
1105
+ * 签到结果响应
1106
+ */
1107
+ interface CheckinResultResponse {
1108
+ /** 本次签到实际获得的 credit */
1109
+ credit: number;
1110
+ /** 签到后的连续签到天数 */
1111
+ streak_days: number;
1112
+ /** 本次签到是否为连续签到奖励日 */
1113
+ is_streak_day: boolean;
1114
+ }
1115
+ /**
1116
+ * 活动 Banner 响应
1117
+ */
1118
+ interface ActivityBannerResponse {
1119
+ /** 活动 ID */
1120
+ id: string;
1121
+ /** 活动是否开启 */
1122
+ active: boolean;
1123
+ /** Banner 文案内容 */
1124
+ bannerContent: string;
1125
+ /** 详情链接 */
1126
+ link: string;
1127
+ /** 活动优先级 */
1128
+ level: number;
1129
+ /** 活动开始时间(格式:"2026-03-20 00:00:00",不存在则视为已开始) */
1130
+ startTime?: string;
1131
+ /** 活动结束时间(格式:"2026-04-20 23:59:59",不存在则视为永不过期) */
1132
+ endTime?: string;
1133
+ }
998
1134
  /**
999
1135
  * 企业用户用量信息
1000
1136
  */
@@ -1122,6 +1258,14 @@ interface IBackendProvider {
1122
1258
  reloadWindow?(params?: {
1123
1259
  locale?: string;
1124
1260
  }): Promise<void>;
1261
+ /**
1262
+ * Save locale to argv.json without restarting the app (optional, IPC only).
1263
+ * The change takes effect on next manual restart.
1264
+ * @param params locale to save
1265
+ */
1266
+ saveLocale?(params: {
1267
+ locale: string;
1268
+ }): Promise<void>;
1125
1269
  /**
1126
1270
  * 关闭 Agent Manager 面板(可选,仅 IPC 环境支持)
1127
1271
  * 用于 Local 模式下点击 Logo 返回 IDE
@@ -1133,6 +1277,24 @@ interface IBackendProvider {
1133
1277
  * @param url 要打开的 URL
1134
1278
  */
1135
1279
  openExternal?(url: string): Promise<void>;
1280
+ /**
1281
+ * 打开本地文件(可选,仅 IPC 环境支持)
1282
+ * 用于 Local 模式下打开本地配置文件
1283
+ * @param filePath 要打开的文件路径
1284
+ */
1285
+ openLocalFile?(filePath: string): Promise<void>;
1286
+ /**
1287
+ * 获取用户级本地自定义模型列表(可选,仅 IPC 环境支持)
1288
+ */
1289
+ getLocalCustomModels?(): Promise<GetLocalCustomModelsResponse>;
1290
+ /**
1291
+ * 保存用户级本地自定义模型(可选,仅 IPC 环境支持)
1292
+ */
1293
+ saveLocalCustomModel?(request: SaveLocalCustomModelRequest): Promise<GetLocalCustomModelsResponse>;
1294
+ /**
1295
+ * 删除用户级本地自定义模型(可选,仅 IPC 环境支持)
1296
+ */
1297
+ deleteLocalCustomModel?(id: string): Promise<GetLocalCustomModelsResponse>;
1136
1298
  /**
1137
1299
  * 监听事件(可选,用于 IPC 环境)
1138
1300
  * @param event 事件名称
@@ -1145,6 +1307,27 @@ interface IBackendProvider {
1145
1307
  * @returns Promise<EnterpriseUsage | null> 企业用户用量信息
1146
1308
  */
1147
1309
  getEnterpriseUsage?(enterpriseId: string): Promise<EnterpriseUsage | null>;
1310
+ /**
1311
+ * 获取账号用量信息(积分/Credits)
1312
+ * 实时获取,每次打开菜单时调用,不依赖 getAccount 缓存
1313
+ * @returns Promise<Partial<Account> | null> 包含 usageLeft, usageTotal, refreshAt 等字段
1314
+ */
1315
+ getAccountUsage?(): Promise<Partial<Account> | null>;
1316
+ /**
1317
+ * 获取每日签到状态
1318
+ * @returns Promise<CheckinStatusResponse | null> 签到状态,失败时返回 null
1319
+ */
1320
+ getCheckinStatus?(): Promise<CheckinStatusResponse | null>;
1321
+ /**
1322
+ * 执行每日签到
1323
+ * @returns Promise<CheckinResultResponse> 签到结果
1324
+ */
1325
+ claimDailyCheckin?(): Promise<CheckinResultResponse>;
1326
+ /**
1327
+ * 获取活动 Banner
1328
+ * @returns Promise<ActivityBannerResponse | null> 活动 Banner 信息,失败时返回 null
1329
+ */
1330
+ getActivityBanner?(): Promise<ActivityBannerResponse | null>;
1148
1331
  /**
1149
1332
  * 刷新 Token(可选)
1150
1333
  * 通过调用 getAccount 刷新 cookie
@@ -1173,6 +1356,175 @@ interface IBackendProvider {
1173
1356
  * @returns Promise<ListReposResponse> 仓库列表响应
1174
1357
  */
1175
1358
  getRepositories?(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
1359
+ /**
1360
+ * 保存待发送的输入内容到后端(用于跨域登录场景)
1361
+ * API 端点: POST /api/v1/code-id
1362
+ *
1363
+ * @param code 要保存的文本内容
1364
+ * @returns Promise<string | null> 返回 codeId,失败返回 null
1365
+ */
1366
+ savePendingInput?(code: string): Promise<string | null>;
1367
+ /**
1368
+ * 从后端加载待发送的输入内容(用于跨域登录场景)
1369
+ * API 端点: GET /api/v1/code?id=xxx
1370
+ *
1371
+ * @param codeId 内容 ID
1372
+ * @returns Promise<string | null> 返回保存的文本内容,失败返回 null
1373
+ */
1374
+ loadPendingInput?(codeId: string): Promise<string | null>;
1375
+ /**
1376
+ * 获取 SkillHub 技能列表(分页)
1377
+ * @param params 分页/过滤参数
1378
+ * @returns Promise<SkillHubListResponse>
1379
+ */
1380
+ getSkillHubList?(params?: SkillHubListParams): Promise<SkillHubListResponse>;
1381
+ /**
1382
+ * 获取 SkillHub 分类列表
1383
+ * @returns Promise<SkillHubCategoriesResponse>
1384
+ */
1385
+ getSkillHubCategories?(): Promise<SkillHubCategoriesResponse>;
1386
+ /**
1387
+ * 搜索 SkillHub 技能
1388
+ * @param q 搜索关键词
1389
+ * @param limit 结果数量限制
1390
+ * @returns Promise<SkillHubSearchResponse>
1391
+ */
1392
+ getSkillHubSearch?(q: string, limit?: number): Promise<SkillHubSearchResponse>;
1393
+ /**
1394
+ * 获取 SkillHub 技能详情
1395
+ * @param slug 技能唯一标识
1396
+ * @returns Promise<SkillHubDetailResponse>
1397
+ */
1398
+ getSkillHubDetail?(slug: string): Promise<SkillHubDetailResponse>;
1399
+ /**
1400
+ * 批量检查 SkillHub 技能是否存在
1401
+ * @param slugs 技能标识列表
1402
+ * @returns Promise<SkillHubExistsResponse>
1403
+ */
1404
+ getSkillHubExists?(slugs: string[]): Promise<SkillHubExistsResponse>;
1405
+ /**
1406
+ * 上报 SkillHub 技能统计
1407
+ * @param slug 技能标识
1408
+ * @param inc 增量统计
1409
+ */
1410
+ reportSkillHubStats?(slug: string, inc: {
1411
+ downloads?: number;
1412
+ installs?: number;
1413
+ stars?: number;
1414
+ }): Promise<void>;
1415
+ /**
1416
+ * 安装 SkillHub 技能(下载 zip → 解压到本地)
1417
+ * @param slug 技能标识
1418
+ * @param version 版本号
1419
+ * @param name 原始显示名称(保留大小写)
1420
+ * @returns Promise<SkillHubInstallResponse>
1421
+ */
1422
+ installSkillHubSkill?(slug: string, version?: string, name?: string): Promise<SkillHubInstallResponse>;
1423
+ /**
1424
+ * 获取本地已安装的 SkillHub 技能元信息
1425
+ * @returns Promise<SkillHubInstalledMeta[]>
1426
+ */
1427
+ getSkillHubInstalledMetas?(): Promise<SkillHubInstalledMeta[]>;
1428
+ }
1429
+ interface SkillHubSkill {
1430
+ slug: string;
1431
+ ownerName: string;
1432
+ category: string;
1433
+ name: string;
1434
+ description: string;
1435
+ description_zh: string;
1436
+ version: string;
1437
+ homepage: string;
1438
+ tags: string[];
1439
+ downloads: number;
1440
+ stars: number;
1441
+ installs: number;
1442
+ updated_at: number;
1443
+ score: number;
1444
+ /** Optional source marker used in merged search results */
1445
+ _source?: 'recommend' | 'skillhub';
1446
+ }
1447
+ interface SkillHubListResponse {
1448
+ code: number;
1449
+ message: string;
1450
+ data: {
1451
+ total: number;
1452
+ skills: SkillHubSkill[];
1453
+ };
1454
+ }
1455
+ interface SkillHubCategory {
1456
+ key: string;
1457
+ name: string;
1458
+ nameEn: string;
1459
+ sortOrder: number;
1460
+ active: boolean;
1461
+ }
1462
+ interface SkillHubCategoriesResponse {
1463
+ items: SkillHubCategory[];
1464
+ count: number;
1465
+ }
1466
+ interface SkillHubSearchResult {
1467
+ score: number;
1468
+ slug: string;
1469
+ displayName: string;
1470
+ summary: string;
1471
+ version: string;
1472
+ updatedAt: number;
1473
+ }
1474
+ interface SkillHubSearchResponse {
1475
+ results: SkillHubSearchResult[];
1476
+ }
1477
+ interface SkillHubDetailResponse {
1478
+ skill: {
1479
+ slug: string;
1480
+ category: string;
1481
+ displayName: string;
1482
+ summary: string;
1483
+ summary_zh: string;
1484
+ tags: Record<string, string>;
1485
+ stats: {
1486
+ downloads: number;
1487
+ stars: number;
1488
+ installs: number;
1489
+ versions: number;
1490
+ comments: number;
1491
+ };
1492
+ createdAt: number;
1493
+ updatedAt: number;
1494
+ };
1495
+ latestVersion: {
1496
+ version: string;
1497
+ createdAt: number;
1498
+ changelog: string;
1499
+ };
1500
+ owner: {
1501
+ handle: string;
1502
+ displayName: string;
1503
+ image: string | null;
1504
+ };
1505
+ }
1506
+ interface SkillHubExistsResponse {
1507
+ exists: Record<string, boolean>;
1508
+ count: number;
1509
+ }
1510
+ interface SkillHubInstallResponse {
1511
+ success: boolean;
1512
+ skillName: string;
1513
+ errorMessage?: string;
1514
+ }
1515
+ interface SkillHubInstalledMeta {
1516
+ slug: string;
1517
+ version: string | null;
1518
+ installedAt?: number;
1519
+ }
1520
+ type SkillHubSortBy = 'score' | 'downloads' | 'updated_at' | 'installs';
1521
+ interface SkillHubListParams {
1522
+ page?: number;
1523
+ pageSize?: number;
1524
+ sortBy?: SkillHubSortBy;
1525
+ order?: 'asc' | 'desc';
1526
+ keyword?: string;
1527
+ category?: string;
1176
1528
  }
1177
1529
  /**
1178
1530
  * 场景中的插件信息
@@ -1186,6 +1538,12 @@ interface ScenePlugin {
1186
1538
  /** 插件市场名称 */
1187
1539
  marketplaceName: string;
1188
1540
  }
1541
+ /**
1542
+ * 场景模式类型
1543
+ * - coding: 编程相关场景
1544
+ * - working: 工作/通用场景
1545
+ */
1546
+ type SupportSceneMode = 'coding' | 'working';
1189
1547
  /**
1190
1548
  * 支持的场景信息
1191
1549
  * 用于 Welcome 页面的 QuickActions 快捷操作
@@ -1200,11 +1558,15 @@ interface SupportScene {
1200
1558
  plugins: ScenePlugin[];
1201
1559
  /** 场景对应的 prompt 列表 */
1202
1560
  prompts: string[];
1561
+ /** 场景模式类型 */
1562
+ mode?: SupportSceneMode;
1203
1563
  }
1204
1564
  /**
1205
1565
  * 插件作用域
1566
+ * 使用 agent-craft 的 PluginInstallScope 类型
1567
+ * 注意: 当前后端 API 只支持 user 和 project,暂不支持 project-local
1206
1568
  */
1207
- type PluginScope = 'user' | 'project';
1569
+ type PluginScope = 'user' | 'project' | 'project-local' | 'local';
1208
1570
  /**
1209
1571
  * 插件操作类型
1210
1572
  */
@@ -1314,6 +1676,71 @@ interface AvailableCommand {
1314
1676
  }
1315
1677
  //#endregion
1316
1678
  //#region ../agent-provider/lib/common/types.d.ts
1679
+ /**
1680
+ * File type enumeration
1681
+ * Compatible with e2b SDK FileType
1682
+ */
1683
+ declare enum FileType {
1684
+ FILE = "file",
1685
+ DIR = "dir"
1686
+ }
1687
+ /**
1688
+ * Filesystem event type enumeration
1689
+ * Compatible with e2b SDK FilesystemEventType
1690
+ */
1691
+ declare enum FilesystemEventType {
1692
+ CHMOD = "chmod",
1693
+ CREATE = "create",
1694
+ REMOVE = "remove",
1695
+ RENAME = "rename",
1696
+ WRITE = "write"
1697
+ }
1698
+ /**
1699
+ * File or directory entry information
1700
+ * Compatible with e2b SDK EntryInfo
1701
+ */
1702
+ interface EntryInfo {
1703
+ name: string;
1704
+ type: FileType;
1705
+ path: string;
1706
+ size: number;
1707
+ mode: number;
1708
+ permissions: string;
1709
+ owner: string;
1710
+ group: string;
1711
+ modifiedTime?: Date;
1712
+ symlinkTarget?: string;
1713
+ }
1714
+ /**
1715
+ * Write operation result
1716
+ * Compatible with e2b SDK WriteInfo
1717
+ */
1718
+ interface WriteInfo {
1719
+ path: string;
1720
+ type: FileType;
1721
+ name: string;
1722
+ }
1723
+ /**
1724
+ * Filesystem watch event
1725
+ * Compatible with e2b SDK FilesystemEvent
1726
+ */
1727
+ interface FilesystemEvent {
1728
+ name: string;
1729
+ type: FilesystemEventType;
1730
+ }
1731
+ /**
1732
+ * Handle for stopping a directory watch
1733
+ * Compatible with e2b SDK WatchHandle
1734
+ */
1735
+ interface WatchHandle {
1736
+ stop(): Promise<void>;
1737
+ }
1738
+ /**
1739
+ * @deprecated Use the standalone type definitions above instead.
1740
+ * This type alias is kept for backward compatibility with code that
1741
+ * imported `Filesystem` type from this module.
1742
+ */
1743
+ type Filesystem = FilesResource;
1317
1744
  /**
1318
1745
  * Base options for filesystem operations
1319
1746
  * 对齐 e2b SDK FilesystemRequestOpts
@@ -1397,7 +1824,7 @@ interface FilesResource {
1397
1824
  /** Write multiple files in batch */
1398
1825
  write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
1399
1826
  /** List directory contents with optional depth */
1400
- list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
1827
+ list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo[]>;
1401
1828
  /** Check if path exists */
1402
1829
  exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
1403
1830
  /** Create directory */
@@ -1405,9 +1832,9 @@ interface FilesResource {
1405
1832
  /** Remove file or directory */
1406
1833
  remove(path: string, opts?: FilesystemRequestOpts): Promise<void>;
1407
1834
  /** Rename/move file or directory */
1408
- rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
1835
+ rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
1409
1836
  /** Get file or directory information */
1410
- getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
1837
+ getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
1411
1838
  /** Watch directory for changes */
1412
1839
  watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
1413
1840
  onExit?: (err?: Error) => void | Promise<void>;
@@ -1510,7 +1937,7 @@ type PromptContentBlock = {
1510
1937
  uri: string;
1511
1938
  mimeType?: string | null;
1512
1939
  name: string;
1513
- size?: bigint | null;
1940
+ size?: number | null;
1514
1941
  title?: string | null;
1515
1942
  _meta?: {
1516
1943
  [key: string]: unknown;
@@ -1616,13 +2043,22 @@ interface AgentConnection {
1616
2043
  * @param sessionId 会话 ID
1617
2044
  * @param toolCallId 工具调用 ID
1618
2045
  * @param toolName 工具名称
1619
- * @param action 操作类型 ('skip' | 'cancel')
2046
+ * @param action 操作类型 ('approve' | 'skip' | 'cancel')
1620
2047
  */
1621
- toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
2048
+ toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
1622
2049
  success: boolean;
1623
2050
  error?: string;
1624
2051
  }>;
1625
2052
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2053
+ /**
2054
+ * Report telemetry event through the standard provider chain
2055
+ * - Local: via ACP JSON-RPC → IDE EventService
2056
+ * - Cloud: via StreamableHTTP → cloud telemetry endpoint
2057
+ *
2058
+ * @param eventName - Event name / code
2059
+ * @param payload - Event data (already includes mode)
2060
+ */
2061
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
1626
2062
  }
1627
2063
  /**
1628
2064
  * Base configuration for connections
@@ -1830,6 +2266,8 @@ interface BaseAgentState {
1830
2266
  updatedAt?: Date;
1831
2267
  /** 是否为 playground */
1832
2268
  isPlayground?: boolean;
2269
+ /** Whether the title is user defined (1 = user defined) */
2270
+ isUserDefinedTitle?: number;
1833
2271
  }
1834
2272
  /**
1835
2273
  * LocalAgentState - 本地 Agent 状态
@@ -1893,6 +2331,11 @@ interface ListAgentSort {
1893
2331
  * Local: Client-side filtering and sorting, no pagination (returns all)
1894
2332
  */
1895
2333
  interface ListAgentOptions {
2334
+ /**
2335
+ * User ID for filtering sessions (required for multi-user isolation)
2336
+ * If not provided, returns empty list for Local provider
2337
+ */
2338
+ userId?: string;
1896
2339
  /**
1897
2340
  * Page number (starts from 1)
1898
2341
  * Cloud: Used for API pagination
@@ -1970,22 +2413,46 @@ interface SessionInfo {
1970
2413
  status: AgentStatus;
1971
2414
  /** When the session/agent was created */
1972
2415
  createdAt?: Date;
2416
+ /** When the session/agent was last updated */
2417
+ updatedAt?: Date;
1973
2418
  /** Last activity timestamp */
1974
2419
  lastActivityAt?: Date;
1975
2420
  /** Working directory (for local agents) */
1976
2421
  cwd?: string;
1977
2422
  /** Whether the session is a playground */
1978
2423
  isPlayground?: boolean;
2424
+ /** Whether the title is user defined (1 = user defined) */
2425
+ isUserDefinedTitle?: number;
1979
2426
  }
1980
2427
  /**
1981
2428
  * Parameters for creating a new session
1982
2429
  */
1983
2430
  interface CreateSessionParams$1 {
1984
- /** Working directory */
2431
+ /** Working directory (required) */
1985
2432
  cwd: string;
2433
+ /** Optional configuration */
2434
+ options?: CreateSessionOptions;
2435
+ }
2436
+ /**
2437
+ * Optional configuration for creating a session
2438
+ */
2439
+ interface CreateSessionOptions {
1986
2440
  /** MCP server configurations */
1987
2441
  mcpServers?: McpServerConfig[];
2442
+ /** Initial prompt for the session (Cloud only) */
2443
+ prompt?: string;
2444
+ /** Initial model for the session (Cloud only) */
2445
+ model?: string;
2446
+ /** Mode ID (e.g., 'craft', 'architect') */
2447
+ mode?: string;
2448
+ /** Whether this is a playground session (no cwd) */
2449
+ isPlayground?: boolean;
2450
+ /** Tags for template scenes (Cloud only, format: { scene: 'xxx' }) */
2451
+ tags?: Record<string, string>;
2452
+ /** Additional metadata */
1988
2453
  _meta?: Record<string, unknown>;
2454
+ /** Callback when session is prepared (POST succeeded, before WebSocket connect) */
2455
+ onSessionPrepared?: (sessionInfo: SessionInfo) => void;
1989
2456
  }
1990
2457
  /**
1991
2458
  * Parameters for loading an existing session
@@ -2020,6 +2487,84 @@ interface InitializeWorkspaceResponse {
2020
2487
  /** Error message (if failed) */
2021
2488
  error?: string;
2022
2489
  }
2490
+ type AutomationStatus = 'ACTIVE' | 'PAUSED';
2491
+ type AutomationUpdateMode = 'view' | 'suggested create' | 'suggested update';
2492
+ type AutomationRunStatus = 'ACCEPTED' | 'ARCHIVED' | 'PENDING_REVIEW' | 'IN_PROGRESS';
2493
+ interface AutomationDefinition {
2494
+ version: number;
2495
+ id: string;
2496
+ name: string;
2497
+ prompt: string;
2498
+ status: AutomationStatus;
2499
+ rrule: string;
2500
+ cwds: string[];
2501
+ modelId?: string;
2502
+ modelIsThinking?: boolean;
2503
+ created_at: number;
2504
+ updated_at: number;
2505
+ }
2506
+ interface AutomationCwdRunResult {
2507
+ cwd: string;
2508
+ success: boolean;
2509
+ startedAt: number;
2510
+ finishedAt: number;
2511
+ conversationId?: string;
2512
+ output?: string;
2513
+ error?: string;
2514
+ }
2515
+ interface AutomationInboxItem {
2516
+ id: string;
2517
+ automationId: string;
2518
+ automationName: string;
2519
+ status?: AutomationRunStatus;
2520
+ readAt?: number;
2521
+ startedAt: number;
2522
+ finishedAt: number;
2523
+ success: boolean;
2524
+ summary: string;
2525
+ runs: AutomationCwdRunResult[];
2526
+ archived?: boolean;
2527
+ archivedAt?: number;
2528
+ }
2529
+ interface AutomationRuntimeState {
2530
+ lastRunAt?: number;
2531
+ lastError?: string;
2532
+ running?: boolean;
2533
+ runningStartedAt?: number;
2534
+ runningConversationId?: string;
2535
+ }
2536
+ interface AutomationSnapshot {
2537
+ automations: AutomationDefinition[];
2538
+ inbox: AutomationInboxItem[];
2539
+ runtimeState: Record<string, AutomationRuntimeState>;
2540
+ updatedAt: number;
2541
+ }
2542
+ interface AutomationUpdatePayload {
2543
+ mode: AutomationUpdateMode;
2544
+ id?: string;
2545
+ name?: string;
2546
+ prompt?: string;
2547
+ rrule?: string;
2548
+ cwds?: string[] | string;
2549
+ status?: AutomationStatus;
2550
+ modelId?: string;
2551
+ modelIsThinking?: boolean;
2552
+ }
2553
+ interface AutomationUpdateResult {
2554
+ success: boolean;
2555
+ message: string;
2556
+ automation?: AutomationDefinition;
2557
+ snapshot?: AutomationSnapshot;
2558
+ }
2559
+ /**
2560
+ * Parameters for getting available commands
2561
+ */
2562
+ interface GetAvailableCommandsParams {
2563
+ /** Session ID to get commands for (optional, for global commands) */
2564
+ sessionId?: string;
2565
+ /** Workspace path for getting custom commands (optional) */
2566
+ workspacePath?: string;
2567
+ }
2023
2568
  /**
2024
2569
  * Prompts resource interface (ACP verbs)
2025
2570
  * Operations use the current session automatically
@@ -2057,7 +2602,7 @@ interface ModelsResource {
2057
2602
  */
2058
2603
  interface PromptResponse {
2059
2604
  /** Stop reason */
2060
- stopReason: 'end_turn' | 'max_tokens' | 'tool_use' | 'cancelled' | 'error';
2605
+ stopReason: StopReason;
2061
2606
  /** Response metadata */
2062
2607
  _meta?: Record<string, unknown>;
2063
2608
  }
@@ -2067,7 +2612,7 @@ interface PromptResponse {
2067
2612
  interface SessionsResourceEvents {
2068
2613
  /** Emitted when the sessions list changes (create, delete, update) */
2069
2614
  sessionsChanged: SessionInfo[];
2070
- /** Emitted when a new session is created */
2615
+ /** Emitted when a new session is fully connected and ready */
2071
2616
  sessionCreated: SessionInfo;
2072
2617
  /** Emitted when a session is deleted */
2073
2618
  sessionDeleted: {
@@ -2075,6 +2620,17 @@ interface SessionsResourceEvents {
2075
2620
  };
2076
2621
  /** Emitted when a session is updated (status change, etc.) */
2077
2622
  sessionUpdated: SessionInfo;
2623
+ /** Emitted when automation snapshot is updated (pushed from server) */
2624
+ automationSnapshotUpdate: AutomationSnapshot;
2625
+ /** Emitted when plugins or marketplaces change (install/uninstall/add/remove/update) */
2626
+ pluginsChanged: {
2627
+ newMarketplaceName?: string;
2628
+ } | undefined;
2629
+ /** Emitted when ProductConfiguration changes (account switch, config sync, etc.) */
2630
+ productConfigChanged: {
2631
+ timestamp: number;
2632
+ productFeatures: Record<string, boolean>;
2633
+ };
2078
2634
  }
2079
2635
  /**
2080
2636
  * Event handler type for sessions resource events
@@ -2151,6 +2707,8 @@ interface ActiveSession {
2151
2707
  readonly id: string;
2152
2708
  /** Agent ID */
2153
2709
  readonly agentId: string;
2710
+ /** Actual workspace path (set after newSession, useful for Playground scenario) */
2711
+ readonly cwd?: string;
2154
2712
  /** Agent state (direct access to underlying agent state) */
2155
2713
  readonly agentState: AgentState;
2156
2714
  /** Agent capabilities (available after connection) */
@@ -2188,8 +2746,8 @@ interface ActiveSession {
2188
2746
  answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
2189
2747
  /** Cancel a question request */
2190
2748
  cancelQuestion(toolCallId: string, reason?: string): boolean;
2191
- /** Callback for tool operations (skip or cancel) */
2192
- toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
2749
+ /** Callback for tool operations (approve / skip / cancel) */
2750
+ toolCallback(toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
2193
2751
  success: boolean;
2194
2752
  error?: string;
2195
2753
  }>;
@@ -2211,6 +2769,12 @@ interface ActiveSession {
2211
2769
  once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
2212
2770
  /** Disconnect from the session/agent */
2213
2771
  disconnect(): void;
2772
+ /**
2773
+ * Detach the session from connection events without disconnecting the connection.
2774
+ * This should be called when the session is being replaced but the connection is shared.
2775
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
2776
+ */
2777
+ detach(): void;
2214
2778
  /** Symbol.dispose for 'using' keyword support */
2215
2779
  [Symbol.dispose](): void;
2216
2780
  }
@@ -2275,6 +2839,17 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2275
2839
  rename?(agentId: string, title: string): Promise<{
2276
2840
  id: string;
2277
2841
  }>;
2842
+ /**
2843
+ * Update agent status by ID (optional)
2844
+ * Used by CloudAgentProvider for updating session status
2845
+ *
2846
+ * @param agentId - Agent ID to update
2847
+ * @param status - New status for the agent
2848
+ * @returns Object containing the updated agent ID
2849
+ */
2850
+ updateStatus?(agentId: string, status: string): Promise<{
2851
+ id: string;
2852
+ }>;
2278
2853
  /**
2279
2854
  * Move an agent by ID (optional)
2280
2855
  * Used by LocalAgentProvider for moving Playground sessions to Workspace
@@ -2294,6 +2869,36 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2294
2869
  * @returns Array of model information
2295
2870
  */
2296
2871
  getModels?(repo?: string): Promise<ModelInfo[]>;
2872
+ /**
2873
+ * Get product configuration subset (optional)
2874
+ * Returns deploymentType, creditPurchaseActions, links, networkEnvironment, productFeatures
2875
+ */
2876
+ getProductConfiguration?(): Promise<{
2877
+ deploymentType?: string;
2878
+ creditPurchaseActions?: Record<string, {
2879
+ labelZh: string;
2880
+ labelEn: string;
2881
+ url: string;
2882
+ showButton?: boolean;
2883
+ }>;
2884
+ links?: {
2885
+ craftFeedback?: string;
2886
+ mcpMarketUrl?: string;
2887
+ mcpDocumentUrl?: string;
2888
+ helpDocument?: string;
2889
+ };
2890
+ networkEnvironment?: string;
2891
+ productFeatures?: Record<string, boolean>;
2892
+ customModelSettings?: unknown;
2893
+ skillScanDirs?: string[];
2894
+ }>;
2895
+ /**
2896
+ * Get user info (optional)
2897
+ * Returns enterpriseId from authentication session
2898
+ */
2899
+ getUserInfo?(): Promise<{
2900
+ enterpriseId?: string;
2901
+ }>;
2297
2902
  /**
2298
2903
  * Register sessionId → agentId mapping (optional, used by LocalAgentProvider)
2299
2904
  * Called after session creation to maintain the mapping for loadSession
@@ -2309,6 +2914,8 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2309
2914
  * @returns Response with success status
2310
2915
  */
2311
2916
  openWorkspace?(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
2917
+ /** Request yielding after current step for a running session (optional, used by LocalAgentProvider) */
2918
+ requestYieldAfterCurrentStep?(sessionId: string): Promise<boolean>;
2312
2919
  /**
2313
2920
  * Pick files from file dialog (optional, used by LocalAgentProvider)
2314
2921
  *
@@ -2344,6 +2951,61 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2344
2951
  * @returns Response with subagent list
2345
2952
  */
2346
2953
  getSubagentList?(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2954
+ /**
2955
+ * Get skill list (optional, used by LocalAgentProvider)
2956
+ *
2957
+ * @param params - Query parameters
2958
+ * @returns Response with skill list
2959
+ */
2960
+ getSkillList?(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2961
+ /**
2962
+ * Import a skill folder (optional, used by LocalAgentProvider)
2963
+ *
2964
+ * @param params - Import parameters including source location
2965
+ * @returns Response with import result
2966
+ */
2967
+ importSkill?(params: ImportSkillParams): Promise<ImportSkillResponse>;
2968
+ /**
2969
+ * Get skill content by file path (optional, used by LocalAgentProvider)
2970
+ *
2971
+ * @param params - Parameters including skill file path
2972
+ * @returns Response with skill content
2973
+ */
2974
+ getSkillContent?(params: GetSkillContentParams): Promise<GetSkillContentResponse>;
2975
+ /**
2976
+ * Get marketplace skills list (optional, used by LocalAgentProvider)
2977
+ *
2978
+ * @returns Response with marketplace skill list
2979
+ */
2980
+ getMarketplaceSkills?(): Promise<GetMarketplaceSkillsResponse>;
2981
+ /**
2982
+ * Get marketplace skill content (optional, used by LocalAgentProvider)
2983
+ *
2984
+ * @param params - Parameters including skill name
2985
+ * @returns Response with skill content
2986
+ */
2987
+ getMarketplaceSkillContent?(params: GetMarketplaceSkillContentParams): Promise<GetMarketplaceSkillContentResponse>;
2988
+ /**
2989
+ * Install marketplace skill to user directory (optional, used by LocalAgentProvider)
2990
+ *
2991
+ * @param params - Parameters including skill name
2992
+ * @returns Response with install result
2993
+ */
2994
+ installMarketplaceSkill?(params: InstallMarketplaceSkillParams): Promise<InstallMarketplaceSkillResponse>;
2995
+ /**
2996
+ * Toggle skill enable/disable state (optional, used by LocalAgentProvider)
2997
+ *
2998
+ * @param params - Toggle parameters including filePath and disable state
2999
+ * @returns Response with toggle result
3000
+ */
3001
+ toggleSkill?(params: ToggleSkillParams): Promise<ToggleSkillResponse>;
3002
+ /**
3003
+ * Delete a skill (optional, used by LocalAgentProvider)
3004
+ *
3005
+ * @param params - Delete parameters including filePath and name
3006
+ * @returns Response with delete result
3007
+ */
3008
+ deleteSkill?(params: DeleteSkillParams): Promise<DeleteSkillResponse>;
2347
3009
  /**
2348
3010
  * Batch toggle plugins (optional, used by LocalAgentProvider)
2349
3011
  *
@@ -2364,6 +3026,9 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2364
3026
  description?: string;
2365
3027
  version?: string;
2366
3028
  installScope?: 'user' | 'project';
3029
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
3030
+ installedScopesStatus?: Record<string, boolean>;
3031
+ installId?: string;
2367
3032
  }>>;
2368
3033
  /**
2369
3034
  * Install plugins (optional, used by LocalAgentProvider)
@@ -2374,7 +3039,7 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2374
3039
  * @param marketplaceSource - Marketplace source URL (for auto-adding marketplace when not exists)
2375
3040
  * @returns Result of the operation
2376
3041
  */
2377
- installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string): Promise<{
3042
+ installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2378
3043
  success: boolean;
2379
3044
  error?: string;
2380
3045
  }>;
@@ -2383,10 +3048,34 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2383
3048
  * If session.availableCommands has cached values, return them
2384
3049
  * Otherwise, fetch from product configuration
2385
3050
  *
2386
- * @param sessionId - Session ID to get commands for (optional, for global commands)
3051
+ * @param params - Parameters for getting commands
2387
3052
  * @returns Array of available commands
2388
3053
  */
2389
- getAvailableCommands?(sessionId?: string): Promise<AvailableCommand[]>;
3054
+ getAvailableCommands?(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
3055
+ /**
3056
+ * Get automation snapshot (optional, used by LocalAgentProvider)
3057
+ */
3058
+ getAutomationSnapshot?(): Promise<AutomationSnapshot>;
3059
+ /**
3060
+ * Create/update automation definition (optional, used by LocalAgentProvider)
3061
+ */
3062
+ updateAutomation?(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
3063
+ /**
3064
+ * Delete automation definition (optional, used by LocalAgentProvider)
3065
+ */
3066
+ deleteAutomation?(id: string): Promise<AutomationUpdateResult>;
3067
+ /**
3068
+ * Archive an automation inbox item (optional, used by LocalAgentProvider)
3069
+ */
3070
+ archiveAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
3071
+ /**
3072
+ * Delete an automation inbox item (optional, used by LocalAgentProvider)
3073
+ */
3074
+ deleteAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
3075
+ /**
3076
+ * Trigger test run for automation (optional, used by LocalAgentProvider)
3077
+ */
3078
+ testAutomation?(id: string): Promise<AutomationUpdateResult>;
2390
3079
  /**
2391
3080
  * Register an event listener
2392
3081
  * Provider implementations should forward events to the underlying transport
@@ -2402,46 +3091,187 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2402
3091
  * @param handler - Event handler function to remove
2403
3092
  */
2404
3093
  off?(event: string, handler: (...args: any[]) => void): void;
2405
- }
2406
- /**
2407
- * AgentClient initialization options
2408
- */
2409
- interface AgentClientOptions {
2410
- /** Agent provider (required) */
2411
- provider: AgentProvider;
2412
- /** Logger instance */
2413
- logger?: Logger;
2414
- /** Client capabilities (sent during initialization) */
2415
- clientCapabilities?: ClientCapabilities$1;
2416
3094
  /**
2417
- * 运行环境类型
2418
- * - 'local': IDE 本地环境
2419
- * - 'cloud': 云端环境
3095
+ * Report telemetry event through the provider chain
3096
+ * - Local: via ACP JSON-RPC → AcpAgent → IDE EventService
3097
+ * - Cloud: via connection → cloud endpoint
3098
+ *
3099
+ * @param eventName - Event name / code
3100
+ * @param payload - Event data
2420
3101
  */
2421
- environmentType?: EnvironmentType;
2422
- }
2423
- /**
2424
- * Client sessions resource interface
2425
- * Top-level API for session management
2426
- *
2427
- * Key design:
2428
- * - list() returns sessions with pagination info (mapped from agents)
2429
- * - create() creates a new session (auto-creates agent and connects)
2430
- * - load() loads an existing session (finds agent by sessionId and connects)
2431
- * - archive() archives a session/agent
2432
- * - initializeWorkspace() initializes a workspace for future sessions
2433
- */
2434
- interface ClientSessionsResource {
3102
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2435
3103
  /**
2436
- * List all sessions with pagination info
2437
- * Cloud: Returns server-side filtered/sorted/paginated results
2438
- * Local: Returns client-side filtered/sorted results (synthetic pagination)
3104
+ * Respond to MCP Sampling confirmation request (optional, used by LocalAgentProvider)
3105
+ * Called when user confirms/rejects a sampling request
3106
+ *
3107
+ * @param sessionId - Session ID
3108
+ * @param response - Sampling confirmation response
2439
3109
  */
2440
- list(options?: ListAgentOptions): Promise<ListAgentResult<SessionInfo>>;
2441
- /** Create a new session (auto-creates agent and connects) */
2442
- create(params: CreateSessionParams$1): Promise<ActiveSession>;
2443
- /** Load an existing session (finds agent by sessionId and connects) */
2444
- load(params: LoadSessionParams$1): Promise<ActiveSession>;
3110
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
3111
+ /**
3112
+ * Respond to MCP Roots confirmation request (optional, used by LocalAgentProvider)
3113
+ * Called when user confirms/rejects a roots request
3114
+ *
3115
+ * @param sessionId - Session ID
3116
+ * @param response - Roots confirmation response
3117
+ */
3118
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
3119
+ /**
3120
+ * Subscribe to MCP Sampling confirmation requests (optional, used by LocalAgentProvider)
3121
+ * Called when MCP server initiates a sampling request
3122
+ *
3123
+ * @param serverName - MCP server name
3124
+ * @param callback - Request callback
3125
+ * @returns Unsubscribe function
3126
+ */
3127
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
3128
+ /**
3129
+ * Subscribe to MCP Roots confirmation requests (optional, used by LocalAgentProvider)
3130
+ * Called when MCP server initiates a roots request
3131
+ *
3132
+ * @param serverName - MCP server name
3133
+ * @param callback - Request callback
3134
+ * @returns Unsubscribe function
3135
+ */
3136
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
3137
+ /**
3138
+ * Get product scenes from ProductManager configuration (optional, for LocalAgentProvider)
3139
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
3140
+ * @param locale - 可选,语言环境
3141
+ */
3142
+ getProductScenes?(locale?: string): Promise<Array<{
3143
+ id: number;
3144
+ name: string;
3145
+ plugins: Array<{
3146
+ id: number;
3147
+ name: string;
3148
+ marketplaceName: string;
3149
+ }>;
3150
+ prompts: string[];
3151
+ mode?: 'coding' | 'working';
3152
+ target?: 'local' | 'cloud' | 'all';
3153
+ }>>;
3154
+ /**
3155
+ * Get all MCP servers with their status and tools (optional, used by LocalAgentProvider)
3156
+ * Returns the list of configured MCP servers from McpServerManager
3157
+ *
3158
+ * @returns Array of MCP server information
3159
+ */
3160
+ getMcpServers?(): Promise<Array<{
3161
+ id: string;
3162
+ name: string;
3163
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
3164
+ description?: string;
3165
+ tools?: Array<{
3166
+ name: string;
3167
+ description?: string;
3168
+ enabled?: boolean;
3169
+ }>;
3170
+ disabled?: boolean;
3171
+ error?: string;
3172
+ logoUrl?: string;
3173
+ officialUrl?: string;
3174
+ configSource?: 'user' | 'project' | 'plugin';
3175
+ }>>;
3176
+ /**
3177
+ * Toggle MCP server enabled/disabled state (optional, used by LocalAgentProvider)
3178
+ *
3179
+ * @param serverName - Name of the MCP server to toggle
3180
+ * @param enabled - Whether to enable (true) or disable (false) the server
3181
+ */
3182
+ toggleMcpServer?(serverName: string, enabled: boolean): Promise<void>;
3183
+ /**
3184
+ * Reconnect to an MCP server (optional, used by LocalAgentProvider)
3185
+ *
3186
+ * @param serverName - Name of the MCP server to reconnect
3187
+ * @param forceHttpCallback - Force using HTTP callback instead of URL scheme
3188
+ */
3189
+ reconnectMcpServer?(serverName: string, forceHttpCallback?: boolean): Promise<void>;
3190
+ /**
3191
+ * Delete an MCP server configuration (optional, used by LocalAgentProvider)
3192
+ *
3193
+ * @param serverName - Name of the MCP server to delete
3194
+ */
3195
+ deleteMcpServer?(serverName: string): Promise<void>;
3196
+ /**
3197
+ * Open the MCP configuration file in editor (optional, used by LocalAgentProvider)
3198
+ * Executes 'codebuddy.openMcpConfig' command
3199
+ */
3200
+ openMcpConfig?(): Promise<void>;
3201
+ /**
3202
+ * Get MCP configuration file content
3203
+ * @returns File path and content
3204
+ */
3205
+ getMcpConfigContent?(): Promise<{
3206
+ filePath: string;
3207
+ content: string;
3208
+ }>;
3209
+ /**
3210
+ * Save MCP configuration file content
3211
+ * @param content New configuration content
3212
+ */
3213
+ saveMcpConfigContent?(content: string): Promise<void>;
3214
+ /**
3215
+ * Read text from clipboard (optional, used by LocalAgentProvider for webview clipboard access)
3216
+ * @returns Clipboard text content
3217
+ */
3218
+ clipboardReadText?(): Promise<string>;
3219
+ }
3220
+ /**
3221
+ * AgentClient initialization options
3222
+ */
3223
+ interface AgentClientOptions {
3224
+ /** Agent provider (required) */
3225
+ provider: AgentProvider;
3226
+ /** Logger instance */
3227
+ logger?: Logger;
3228
+ /** Client capabilities (sent during initialization) */
3229
+ clientCapabilities?: ClientCapabilities$1;
3230
+ /**
3231
+ * 运行环境类型
3232
+ * - 'local': IDE 本地环境
3233
+ * - 'cloud': 云端环境
3234
+ */
3235
+ environmentType?: EnvironmentType;
3236
+ }
3237
+ /**
3238
+ * Client sessions resource interface
3239
+ * Top-level API for session management
3240
+ *
3241
+ * Key design:
3242
+ * - list() returns sessions with pagination info (mapped from agents)
3243
+ * - create() creates a new session (auto-creates agent and connects)
3244
+ * - load() loads an existing session (finds agent by sessionId and connects)
3245
+ * - archive() archives a session/agent
3246
+ * - initializeWorkspace() initializes a workspace for future sessions
3247
+ */
3248
+ interface ClientSessionsResource {
3249
+ /**
3250
+ * List all sessions with pagination info
3251
+ * Cloud: Returns server-side filtered/sorted/paginated results
3252
+ * Local: Returns client-side filtered/sorted results (synthetic pagination)
3253
+ */
3254
+ list(options?: ListAgentOptions): Promise<ListAgentResult<SessionInfo>>;
3255
+ /** Create a new session (auto-creates agent and connects) */
3256
+ create(params: CreateSessionParams$1): Promise<ActiveSession>;
3257
+ /**
3258
+ * Retry creating a session after initial session/new request failed.
3259
+ *
3260
+ * Use this when `sessions.create()` fails at the `session/new` step
3261
+ * (after agent creation and connection establishment succeeded).
3262
+ * The caller retrieves `agentId` from the thrown `SessionError.agentId`,
3263
+ * then calls this method to re-attempt only the `session/new` request.
3264
+ *
3265
+ * @experimental This API is subject to change
3266
+ *
3267
+ * @param agentId - Agent ID from the failed SessionError.agentId
3268
+ * @param params - Original create session params (cwd, etc.)
3269
+ * @returns ActiveSession on success
3270
+ * @throws SessionError if session/new fails again
3271
+ */
3272
+ retryNewSession(agentId: string, params: CreateSessionParams$1): Promise<ActiveSession>;
3273
+ /** Load an existing session (finds agent by sessionId and connects) */
3274
+ load(params: LoadSessionParams$1): Promise<ActiveSession>;
2445
3275
  /**
2446
3276
  * Archive a session/agent
2447
3277
  * @param sessionId - Session ID to archive
@@ -2459,6 +3289,15 @@ interface ClientSessionsResource {
2459
3289
  rename(sessionId: string, title: string): Promise<{
2460
3290
  id: string;
2461
3291
  }>;
3292
+ /**
3293
+ * Update session status
3294
+ * @param sessionId - Session ID to update
3295
+ * @param status - New status for the session
3296
+ * @returns Object containing the updated session ID
3297
+ */
3298
+ updateStatus(sessionId: string, status: string): Promise<{
3299
+ id: string;
3300
+ }>;
2462
3301
  /**
2463
3302
  * Move a session (Playground → Workspace)
2464
3303
  * @param sessionId - Session ID to move
@@ -2469,6 +3308,8 @@ interface ClientSessionsResource {
2469
3308
  }>;
2470
3309
  /** Initialize a workspace for future sessions */
2471
3310
  initializeWorkspace(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
3311
+ /** Request yielding after current step for a running session */
3312
+ requestYieldAfterCurrentStep(sessionId: string): Promise<boolean>;
2472
3313
  /** Models resource for getting available models */
2473
3314
  readonly models: ModelsResource;
2474
3315
  /** Get current workspaces list */
@@ -2491,6 +3332,22 @@ interface ClientSessionsResource {
2491
3332
  searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
2492
3333
  /** Get subagent list (for LocalAgentProvider) */
2493
3334
  getSubagentList(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
3335
+ /** Get skill list (for LocalAgentProvider) */
3336
+ getSkillList(params?: GetSkillListParams): Promise<GetSkillListResponse>;
3337
+ /** Import a skill folder (for LocalAgentProvider) */
3338
+ importSkill(params: ImportSkillParams): Promise<ImportSkillResponse>;
3339
+ /** Toggle skill enable/disable state (for LocalAgentProvider) */
3340
+ toggleSkill(params: ToggleSkillParams): Promise<ToggleSkillResponse>;
3341
+ /** Delete a skill (for LocalAgentProvider) */
3342
+ deleteSkill(params: DeleteSkillParams): Promise<DeleteSkillResponse>;
3343
+ /** Get skill content by file path (for LocalAgentProvider) */
3344
+ getSkillContent(params: GetSkillContentParams): Promise<GetSkillContentResponse>;
3345
+ /** Get marketplace skills list (for LocalAgentProvider) */
3346
+ getMarketplaceSkills(): Promise<GetMarketplaceSkillsResponse>;
3347
+ /** Get marketplace skill content (for LocalAgentProvider) */
3348
+ getMarketplaceSkillContent(params: GetMarketplaceSkillContentParams): Promise<GetMarketplaceSkillContentResponse>;
3349
+ /** Install marketplace skill to user directory (for LocalAgentProvider) */
3350
+ installMarketplaceSkill(params: InstallMarketplaceSkillParams): Promise<InstallMarketplaceSkillResponse>;
2494
3351
  /** Batch toggle plugins (for LocalAgentProvider) */
2495
3352
  batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2496
3353
  /** Get installed plugins (for LocalAgentProvider) */
@@ -2501,17 +3358,138 @@ interface ClientSessionsResource {
2501
3358
  description?: string;
2502
3359
  version?: string;
2503
3360
  installScope?: 'user' | 'project';
3361
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
3362
+ installedScopesStatus?: Record<string, boolean>;
3363
+ installId?: string;
2504
3364
  }>>;
2505
3365
  /** Install plugins (for LocalAgentProvider) */
2506
- installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string): Promise<{
3366
+ installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
3367
+ success: boolean;
3368
+ error?: string;
3369
+ }>;
3370
+ /** Uninstall a plugin (for LocalAgentProvider) */
3371
+ uninstallPlugin?(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
3372
+ success: boolean;
3373
+ error?: string;
3374
+ }>;
3375
+ /** Update a plugin to the latest version (for LocalAgentProvider) */
3376
+ updatePlugin?(pluginName: string, marketplaceName: string): Promise<{
3377
+ success: boolean;
3378
+ error?: string;
3379
+ }>;
3380
+ /** Get plugin marketplaces list (for LocalAgentProvider) */
3381
+ getPluginMarketplaces?(forceRefresh?: boolean): Promise<Array<{
3382
+ id: string;
3383
+ name: string;
3384
+ type: 'github' | 'local' | 'custom';
3385
+ source: {
3386
+ repo?: string;
3387
+ ref?: string;
3388
+ url?: string;
3389
+ };
3390
+ description?: string;
3391
+ isBuiltin?: boolean;
3392
+ }>>;
3393
+ /** Get plugins from a marketplace (for LocalAgentProvider) */
3394
+ getMarketplacePlugins?(marketplaceName: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
3395
+ name: string;
3396
+ marketplaceName: string;
3397
+ description?: string;
3398
+ version?: string;
3399
+ author?: string;
3400
+ homepage?: string;
3401
+ iconUrl?: string;
3402
+ tags?: string[];
3403
+ installed?: boolean;
3404
+ status?: 'enabled' | 'disabled' | 'not-installed';
3405
+ installedScopes?: Array<'user' | 'project'>;
3406
+ hasUpdate?: boolean;
3407
+ }>>;
3408
+ /** Get plugin detail (for LocalAgentProvider) */
3409
+ getPluginDetail?(pluginName: string, marketplaceName: string): Promise<{
3410
+ name: string;
3411
+ marketplaceName: string;
3412
+ description?: string;
3413
+ version?: string;
3414
+ author?: string;
3415
+ homepage?: string;
3416
+ readme?: string;
3417
+ tools?: Array<{
3418
+ name: string;
3419
+ description?: string;
3420
+ }>;
3421
+ resources?: Array<{
3422
+ name: string;
3423
+ description?: string;
3424
+ }>;
3425
+ prompts?: Array<{
3426
+ name: string;
3427
+ description?: string;
3428
+ }>;
3429
+ installed?: boolean;
3430
+ status?: 'enabled' | 'disabled' | 'not-installed';
3431
+ } | null>;
3432
+ /** Add a plugin marketplace (for LocalAgentProvider) */
3433
+ addPluginMarketplace?(source: string, name?: string): Promise<{
2507
3434
  success: boolean;
2508
3435
  error?: string;
3436
+ marketplace?: {
3437
+ id: string;
3438
+ name: string;
3439
+ type: 'github' | 'local' | 'custom';
3440
+ source: {
3441
+ repo?: string;
3442
+ ref?: string;
3443
+ url?: string;
3444
+ };
3445
+ description?: string;
3446
+ isBuiltin?: boolean;
3447
+ };
2509
3448
  }>;
3449
+ /** Remove a plugin marketplace (for LocalAgentProvider) */
3450
+ removePluginMarketplace?(marketplaceName: string): Promise<{
3451
+ success: boolean;
3452
+ error?: string;
3453
+ }>;
3454
+ /** Refresh a plugin marketplace (for LocalAgentProvider) */
3455
+ refreshPluginMarketplace?(marketplaceName: string): Promise<{
3456
+ success: boolean;
3457
+ error?: string;
3458
+ plugins?: Array<{
3459
+ name: string;
3460
+ marketplaceName: string;
3461
+ description?: string;
3462
+ version?: string;
3463
+ installed?: boolean;
3464
+ status?: 'enabled' | 'disabled' | 'not-installed';
3465
+ }>;
3466
+ }>;
3467
+ /** Open folder in new window (for LocalAgentProvider) */
3468
+ openFolderInNewWindow?(folderPath: string): Promise<void>;
3469
+ /** Open folder in system file manager (for LocalAgentProvider) */
3470
+ openFolder?(folderPath: string): Promise<boolean>;
2510
3471
  /**
2511
3472
  * Get support scenes from backend API (for LocalAgentProvider)
2512
3473
  * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
3474
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
3475
+ */
3476
+ getSupportScenes(locale?: string): Promise<Array<{
3477
+ id: number;
3478
+ name: string;
3479
+ plugins: Array<{
3480
+ id: number;
3481
+ name: string;
3482
+ marketplaceName: string;
3483
+ }>;
3484
+ prompts: string[];
3485
+ mode?: 'coding' | 'working';
3486
+ }>>;
3487
+ /**
3488
+ * Get product scenes from ProductManager configuration (for LocalAgentProvider)
3489
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
3490
+ * @param locale - 可选,语言环境
2513
3491
  */
2514
- getSupportScenes(): Promise<Array<{
3492
+ getProductScenes?(locale?: string): Promise<Array<{
2515
3493
  id: number;
2516
3494
  name: string;
2517
3495
  plugins: Array<{
@@ -2520,15 +3498,250 @@ interface ClientSessionsResource {
2520
3498
  marketplaceName: string;
2521
3499
  }>;
2522
3500
  prompts: string[];
3501
+ mode?: 'coding' | 'working';
3502
+ target?: 'local' | 'cloud' | 'all';
2523
3503
  }>>;
2524
3504
  /**
2525
3505
  * Get available commands for a session
2526
3506
  * If session.availableCommands has cached values, return them
2527
3507
  * Otherwise, fetch from provider (for LocalAgentProvider)
2528
- * @param sessionId - Session ID to get commands for (optional, for global commands)
3508
+ * @param params - Parameters for getting commands
2529
3509
  * @returns Promise<AvailableCommand[]> - Array of available commands
2530
3510
  */
2531
- getAvailableCommands(sessionId?: string): Promise<AvailableCommand[]>;
3511
+ getAvailableCommands(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
3512
+ /**
3513
+ * Get automation snapshot
3514
+ */
3515
+ getAutomationSnapshot(): Promise<AutomationSnapshot>;
3516
+ /**
3517
+ * Create/update automation definition
3518
+ */
3519
+ updateAutomation(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
3520
+ /**
3521
+ * Delete automation definition
3522
+ */
3523
+ deleteAutomation(id: string): Promise<AutomationUpdateResult>;
3524
+ /**
3525
+ * Archive automation inbox item
3526
+ */
3527
+ archiveAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
3528
+ /**
3529
+ * Delete automation inbox item
3530
+ */
3531
+ deleteAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
3532
+ /**
3533
+ * Trigger automation test run
3534
+ */
3535
+ testAutomation(id: string): Promise<AutomationUpdateResult>;
3536
+ /**
3537
+ * Report telemetry event through the provider chain
3538
+ * Delegates to AgentProvider.reportTelemetry()
3539
+ *
3540
+ * @param eventName - Event name / code
3541
+ * @param payload - Event data
3542
+ */
3543
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
3544
+ /**
3545
+ * Get product configuration subset
3546
+ * Returns deploymentType, creditPurchaseActions, links, productFeatures
3547
+ * Used by agent-ui for error banner credit purchase guidance
3548
+ */
3549
+ getProductConfiguration?(): Promise<{
3550
+ deploymentType?: string;
3551
+ creditPurchaseActions?: Record<string, {
3552
+ labelZh: string;
3553
+ labelEn: string;
3554
+ url: string;
3555
+ showButton?: boolean;
3556
+ }>;
3557
+ links?: {
3558
+ craftFeedback?: string;
3559
+ mcpMarketUrl?: string;
3560
+ mcpDocumentUrl?: string;
3561
+ helpDocument?: string;
3562
+ };
3563
+ networkEnvironment?: string;
3564
+ productFeatures?: Record<string, boolean>;
3565
+ customModelSettings?: unknown;
3566
+ skillScanDirs?: string[];
3567
+ }>;
3568
+ /**
3569
+ * Get user info
3570
+ * Returns enterpriseId from authentication session
3571
+ * Used by agent-ui for determining personal/enterprise user
3572
+ */
3573
+ getUserInfo?(): Promise<{
3574
+ enterpriseId?: string;
3575
+ }>;
3576
+ /**
3577
+ * Respond to MCP Sampling confirmation request
3578
+ * Called when user confirms/rejects a sampling request in MCP tool renderer
3579
+ *
3580
+ * @param sessionId - Session ID
3581
+ * @param response - Sampling confirmation response
3582
+ */
3583
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
3584
+ /**
3585
+ * Respond to MCP Roots confirmation request
3586
+ * Called when user confirms/rejects a roots request in MCP tool renderer
3587
+ *
3588
+ * @param sessionId - Session ID
3589
+ * @param response - Roots confirmation response
3590
+ */
3591
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
3592
+ /**
3593
+ * Subscribe to MCP Sampling confirmation requests
3594
+ * Called when MCP server initiates a sampling request
3595
+ *
3596
+ * @param serverName - MCP server name
3597
+ * @param callback - Request callback
3598
+ * @returns Unsubscribe function
3599
+ */
3600
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
3601
+ /**
3602
+ * Subscribe to MCP Roots confirmation requests
3603
+ * Called when MCP server initiates a roots request
3604
+ *
3605
+ * @param serverName - MCP server name
3606
+ * @param callback - Request callback
3607
+ * @returns Unsubscribe function
3608
+ */
3609
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
3610
+ /**
3611
+ * Get MCP servers list
3612
+ * Returns the list of configured MCP servers with their status
3613
+ *
3614
+ * @returns Promise<McpServerInfo[]> - Array of MCP server info
3615
+ */
3616
+ getMcpServers?(): Promise<McpServerInfo[]>;
3617
+ /**
3618
+ * Toggle MCP server enabled/disabled state
3619
+ *
3620
+ * @param serverName - Server name
3621
+ * @param enabled - Whether to enable the server
3622
+ */
3623
+ toggleMcpServer?(serverName: string, enabled: boolean): Promise<void>;
3624
+ /**
3625
+ * Reconnect to an MCP server
3626
+ *
3627
+ * @param serverName - Server name
3628
+ * @param forceHttpCallback - Force using HTTP callback instead of URL scheme
3629
+ */
3630
+ reconnectMcpServer?(serverName: string, forceHttpCallback?: boolean): Promise<void>;
3631
+ /**
3632
+ * Delete an MCP server configuration
3633
+ *
3634
+ * @param serverName - Server name
3635
+ */
3636
+ deleteMcpServer?(serverName: string): Promise<void>;
3637
+ /**
3638
+ * Open MCP configuration file in editor
3639
+ */
3640
+ openMcpConfig?(): Promise<void>;
3641
+ /**
3642
+ * Get MCP configuration file content
3643
+ * @returns File path and content
3644
+ */
3645
+ getMcpConfigContent?(): Promise<{
3646
+ filePath: string;
3647
+ content: string;
3648
+ }>;
3649
+ /**
3650
+ * Save MCP configuration file content
3651
+ * @param content New configuration content
3652
+ */
3653
+ saveMcpConfigContent?(content: string): Promise<void>;
3654
+ /**
3655
+ * Read text from clipboard (optional, used by LocalAgentProvider for webview clipboard access)
3656
+ * @returns Clipboard text content
3657
+ */
3658
+ clipboardReadText?(): Promise<string>;
3659
+ }
3660
+ /**
3661
+ * MCP Sampling message role
3662
+ */
3663
+ type McpSamplingRole = 'user' | 'assistant';
3664
+ /**
3665
+ * MCP Sampling message content - text
3666
+ */
3667
+ interface McpSamplingTextContent {
3668
+ type: 'text';
3669
+ text: string;
3670
+ }
3671
+ /**
3672
+ * MCP Sampling message content - image
3673
+ */
3674
+ interface McpSamplingImageContent {
3675
+ type: 'image';
3676
+ data: string;
3677
+ mimeType: string;
3678
+ }
3679
+ /**
3680
+ * MCP Sampling message content - audio
3681
+ */
3682
+ interface McpSamplingAudioContent {
3683
+ type: 'audio';
3684
+ data: string;
3685
+ mimeType: string;
3686
+ }
3687
+ /**
3688
+ * MCP Sampling message content union type
3689
+ */
3690
+ type McpSamplingContent = McpSamplingTextContent | McpSamplingImageContent | McpSamplingAudioContent;
3691
+ /**
3692
+ * MCP Sampling message
3693
+ */
3694
+ interface McpSamplingMessage {
3695
+ role: McpSamplingRole;
3696
+ content: McpSamplingContent;
3697
+ }
3698
+ /**
3699
+ * MCP Sampling confirmation request
3700
+ * Sent from backend when MCP server requests sampling
3701
+ */
3702
+ interface McpSamplingConfirmRequest {
3703
+ id: string;
3704
+ serverName: string;
3705
+ model?: string;
3706
+ messages: McpSamplingMessage[];
3707
+ systemPrompt?: string;
3708
+ maxTokens: number;
3709
+ timestamp: number;
3710
+ }
3711
+ /**
3712
+ * MCP Sampling confirmation response
3713
+ * Sent from frontend when user confirms/rejects
3714
+ */
3715
+ interface McpSamplingConfirmResponse {
3716
+ id: string;
3717
+ approved: boolean;
3718
+ rememberChoice?: boolean;
3719
+ }
3720
+ /**
3721
+ * MCP Root definition
3722
+ */
3723
+ interface McpRoot {
3724
+ uri: string;
3725
+ name?: string;
3726
+ }
3727
+ /**
3728
+ * MCP Roots confirmation request
3729
+ * Sent from backend when MCP server requests roots access
3730
+ */
3731
+ interface McpRootsConfirmRequest {
3732
+ id: string;
3733
+ serverName: string;
3734
+ roots: McpRoot[];
3735
+ timestamp: number;
3736
+ }
3737
+ /**
3738
+ * MCP Roots confirmation response
3739
+ * Sent from frontend when user confirms/rejects
3740
+ */
3741
+ interface McpRootsConfirmResponse {
3742
+ id: string;
3743
+ approved: boolean;
3744
+ rememberChoice?: boolean;
2532
3745
  }
2533
3746
  /**
2534
3747
  * Workspace information (aligned with FolderSelectResult)
@@ -2594,6 +3807,8 @@ interface PickFolderResponse {
2594
3807
  interface UploadFileParams {
2595
3808
  /** Files to upload - File objects in browser, absolute path strings in IDE */
2596
3809
  readonly files: Array<File | string>;
3810
+ /** Optional AbortSignal to cancel the upload */
3811
+ readonly abortSignal?: AbortSignal;
2597
3812
  }
2598
3813
  /**
2599
3814
  * Response from uploading files
@@ -2607,6 +3822,8 @@ interface UploadFileResponse {
2607
3822
  readonly expireSeconds?: number;
2608
3823
  /** Error message (if upload failed) */
2609
3824
  readonly error?: string;
3825
+ /** Whether the upload was cancelled by user */
3826
+ readonly aborted?: boolean;
2610
3827
  }
2611
3828
  /**
2612
3829
  * Mention type for file/folder
@@ -2655,53 +3872,280 @@ interface SearchFileResponse {
2655
3872
  /** Search results */
2656
3873
  readonly results: SearchFileResult[];
2657
3874
  /** Error message (if failed) */
2658
- readonly error?: string;
3875
+ readonly error?: string;
3876
+ }
3877
+ /**
3878
+ * Subagent information
3879
+ */
3880
+ interface SubagentInfo {
3881
+ /** Subagent name */
3882
+ name: string;
3883
+ /** Subagent description */
3884
+ description: string;
3885
+ /** System prompt */
3886
+ systemPrompt: string;
3887
+ /** File path */
3888
+ filePath?: string;
3889
+ /** Model type */
3890
+ model?: string;
3891
+ /** Agent mode */
3892
+ agentMode?: 'agentic' | 'manual';
3893
+ /** Whether enabled */
3894
+ enabled?: boolean;
3895
+ /** Model ID */
3896
+ modelID?: string;
3897
+ /** Subagent level */
3898
+ level?: 'project' | 'user';
3899
+ }
3900
+ /**
3901
+ * Parameters for getting subagent list
3902
+ */
3903
+ interface GetSubagentListParams {
3904
+ /** Search options */
3905
+ readonly options: {
3906
+ /** Search keyword (filter by name or description) */readonly search?: string; /** Limit number of results */
3907
+ readonly resultNum?: number; /** Agent mode filter */
3908
+ readonly agentMode?: 'agentic' | 'manual' | 'all'; /** Whether to return only enabled subagents */
3909
+ readonly onlyEnabled?: boolean;
3910
+ };
3911
+ /** Working directory (optional, for filtering project-level subagents) */
3912
+ readonly cwd?: string;
3913
+ }
3914
+ /**
3915
+ * Response from getting subagent list
3916
+ */
3917
+ interface GetSubagentListResponse {
3918
+ /** Subagent list */
3919
+ readonly results: SubagentInfo[];
3920
+ /** Error message (if failed) */
3921
+ readonly error?: string;
3922
+ }
3923
+ /**
3924
+ * Skill info returned from getSkillList
3925
+ */
3926
+ interface SkillInfo {
3927
+ /** Skill name */
3928
+ name: string;
3929
+ /** File path of the skill */
3930
+ filePath: string;
3931
+ /** Description of the skill */
3932
+ description: string;
3933
+ /** Chinese description of the skill */
3934
+ description_zh?: string;
3935
+ /** English description of the skill */
3936
+ description_en?: string;
3937
+ /** When to use the skill */
3938
+ whenToUse?: string;
3939
+ /** Source of the skill */
3940
+ source: 'localSettings' | 'userSettings' | 'plugin' | 'builtin';
3941
+ /** Skill type */
3942
+ type: 'prompt';
3943
+ /** License information */
3944
+ license?: string;
3945
+ /** Allowed tools */
3946
+ allowedTools?: string[];
3947
+ /** Whether the skill is disabled */
3948
+ disable?: boolean;
3949
+ }
3950
+ /**
3951
+ * Parameters for getting skill list
3952
+ */
3953
+ interface GetSkillListParams {
3954
+ /** Working directory (optional, for filtering project-level skills) */
3955
+ readonly cwd?: string;
3956
+ /** Whether to use global (backend) channel, defaults to true. When false, uses sendBroadcastRequest. */
3957
+ readonly global?: boolean;
3958
+ /** Whether to exclude plugin skills from the result, defaults to false. */
3959
+ readonly excludePluginSkills?: boolean;
3960
+ /**
3961
+ * 用户级 skill 扫描目录名称列表(相对于 home 目录),按优先级从高到低排列。
3962
+ * 同名 skill 以高优先级目录为准。
3963
+ * 未传入或为空时使用产品默认目录。
3964
+ */
3965
+ readonly skillScanDirs?: string[];
3966
+ }
3967
+ /**
3968
+ * Response from getting skill list
3969
+ */
3970
+ interface GetSkillListResponse {
3971
+ /** Skill list */
3972
+ readonly results: SkillInfo[];
3973
+ /** Error message (if failed) */
3974
+ readonly error?: string;
3975
+ }
3976
+ /**
3977
+ * Parameters for importing a skill folder
3978
+ */
3979
+ interface ImportSkillParams {
3980
+ /** Source location: project-level or user-level */
3981
+ readonly source: 'localSettings' | 'userSettings';
3982
+ /** Working directory (required when source is localSettings). */
3983
+ readonly cwd?: string;
3984
+ /** 直接传入文件夹路径(拖拽导入时使用),有此字段时跳过系统文件选择器 */
3985
+ readonly folderPath?: string;
3986
+ }
3987
+ /**
3988
+ * Response from importing a skill folder
3989
+ */
3990
+ interface ImportSkillResponse {
3991
+ /** Whether the import was successful */
3992
+ readonly success: boolean;
3993
+ /** Error message (if failed) */
3994
+ readonly error?: string;
3995
+ /** Imported skill name */
3996
+ readonly skillName?: string;
3997
+ }
3998
+ /**
3999
+ * Parameters for toggling skill enable/disable state
4000
+ */
4001
+ interface ToggleSkillParams {
4002
+ /** File path of the skill to toggle */
4003
+ readonly filePath: string;
4004
+ /** Whether to disable the skill */
4005
+ readonly disable: boolean;
4006
+ }
4007
+ /**
4008
+ * Response from toggling skill state
4009
+ */
4010
+ interface ToggleSkillResponse {
4011
+ /** Whether the toggle was successful */
4012
+ readonly success: boolean;
4013
+ /** Error message (if failed) */
4014
+ readonly error?: string;
4015
+ }
4016
+ /**
4017
+ * Parameters for deleting a skill
4018
+ */
4019
+ interface DeleteSkillParams {
4020
+ /** File path of the skill to delete */
4021
+ readonly filePath: string;
4022
+ /** Name of the skill */
4023
+ readonly name: string;
4024
+ }
4025
+ /**
4026
+ * Response from deleting a skill
4027
+ */
4028
+ interface DeleteSkillResponse {
4029
+ /** Whether the deletion was successful */
4030
+ readonly success: boolean;
4031
+ /** Error message (if failed) */
4032
+ readonly error?: string;
4033
+ }
4034
+ /**
4035
+ * Parameters for getting skill content
4036
+ */
4037
+ interface GetSkillContentParams {
4038
+ /** File path of the skill */
4039
+ readonly filePath: string;
4040
+ }
4041
+ /**
4042
+ * Response from getting skill content
4043
+ */
4044
+ interface GetSkillContentResponse {
4045
+ /** Skill file content */
4046
+ readonly content: string;
4047
+ /** Error message (if failed) */
4048
+ readonly error?: string;
4049
+ }
4050
+ /**
4051
+ * Marketplace skill info (simplified structure for UI layer)
4052
+ */
4053
+ interface MarketplaceSkillInfo {
4054
+ /** Skill name */
4055
+ name: string;
4056
+ /** Skill description */
4057
+ description: string;
4058
+ /** Skill description in Chinese */
4059
+ description_zh?: string;
4060
+ /** Skill description in English */
4061
+ description_en?: string;
4062
+ /** Skill version */
4063
+ version?: string;
4064
+ /** Skill author */
4065
+ author?: string;
4066
+ /** Skill icon URL */
4067
+ iconUrl?: string;
4068
+ /** Skill tags */
4069
+ tags?: string[];
4070
+ }
4071
+ /**
4072
+ * Response from getting marketplace skills
4073
+ */
4074
+ interface GetMarketplaceSkillsResponse {
4075
+ /** Marketplace skill list */
4076
+ readonly results: MarketplaceSkillInfo[];
4077
+ /** Error message (if failed) */
4078
+ readonly error?: string;
4079
+ }
4080
+ /**
4081
+ * Parameters for getting marketplace skill content
4082
+ */
4083
+ interface GetMarketplaceSkillContentParams {
4084
+ /** Skill name */
4085
+ readonly skillName: string;
4086
+ }
4087
+ /**
4088
+ * Response from getting marketplace skill content
4089
+ */
4090
+ interface GetMarketplaceSkillContentResponse {
4091
+ /** Skill file content */
4092
+ readonly content: string;
4093
+ /** Error message (if failed) */
4094
+ readonly error?: string;
4095
+ }
4096
+ /**
4097
+ * Parameters for installing marketplace skill
4098
+ */
4099
+ interface InstallMarketplaceSkillParams {
4100
+ /** Skill name to install */
4101
+ readonly skillName: string;
4102
+ }
4103
+ /**
4104
+ * Response from installing marketplace skill
4105
+ */
4106
+ interface InstallMarketplaceSkillResponse {
4107
+ /** Whether the install was successful */
4108
+ readonly success: boolean;
4109
+ /** Skill name */
4110
+ readonly skillName: string;
4111
+ /** Error message (if failed) */
4112
+ readonly errorMessage?: string;
2659
4113
  }
2660
4114
  /**
2661
- * Subagent information
4115
+ * MCP Tool information
2662
4116
  */
2663
- interface SubagentInfo {
2664
- /** Subagent name */
4117
+ interface McpToolInfo {
4118
+ /** Tool name */
2665
4119
  name: string;
2666
- /** Subagent description */
2667
- description: string;
2668
- /** System prompt */
2669
- systemPrompt: string;
2670
- /** File path */
2671
- filePath?: string;
2672
- /** Model type */
2673
- model?: string;
2674
- /** Agent mode */
2675
- agentMode?: 'agentic' | 'manual';
2676
- /** Whether enabled */
4120
+ /** Tool description */
4121
+ description?: string;
4122
+ /** Whether the tool is enabled */
2677
4123
  enabled?: boolean;
2678
- /** Model ID */
2679
- modelID?: string;
2680
- /** Subagent level */
2681
- level?: 'project' | 'user';
2682
- }
2683
- /**
2684
- * Parameters for getting subagent list
2685
- */
2686
- interface GetSubagentListParams {
2687
- /** Search options */
2688
- readonly options: {
2689
- /** Search keyword (filter by name or description) */readonly search?: string; /** Limit number of results */
2690
- readonly resultNum?: number; /** Agent mode filter */
2691
- readonly agentMode?: 'agentic' | 'manual' | 'all'; /** Whether to return only enabled subagents */
2692
- readonly onlyEnabled?: boolean;
2693
- };
2694
- /** Working directory (optional, for filtering project-level subagents) */
2695
- readonly cwd?: string;
2696
4124
  }
2697
4125
  /**
2698
- * Response from getting subagent list
4126
+ * MCP Server information
2699
4127
  */
2700
- interface GetSubagentListResponse {
2701
- /** Subagent list */
2702
- readonly results: SubagentInfo[];
2703
- /** Error message (if failed) */
2704
- readonly error?: string;
4128
+ interface McpServerInfo {
4129
+ /** Server ID */
4130
+ id: string;
4131
+ /** Server name */
4132
+ name: string;
4133
+ /** Connection status */
4134
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
4135
+ /** Server description */
4136
+ description?: string;
4137
+ /** Available tools */
4138
+ tools?: McpToolInfo[];
4139
+ /** Whether the server is disabled */
4140
+ disabled?: boolean;
4141
+ /** Error message (if connection failed) */
4142
+ error?: string;
4143
+ /** Logo URL */
4144
+ logoUrl?: string;
4145
+ /** Official website URL */
4146
+ officialUrl?: string;
4147
+ /** Configuration source */
4148
+ configSource?: 'user' | 'project' | 'plugin';
2705
4149
  }
2706
4150
  //#endregion
2707
4151
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
@@ -2734,6 +4178,17 @@ declare class CloudAgentConnection implements AgentConnection {
2734
4178
  readonly transport: "cloud";
2735
4179
  readonly cwd: string;
2736
4180
  constructor(agentId: string, config: CloudConnectionConfig, cwd?: string);
4181
+ /**
4182
+ * Check whether a notification belongs to this connection's own session.
4183
+ *
4184
+ * CloudConnection.createSession() overrides sessionId to agentId, so the
4185
+ * rest of the client stack uses agentId as the canonical session
4186
+ * identifier. Notifications whose sessionId differs from agentId
4187
+ * originate from sub-agent sessions running inside the same sandbox and
4188
+ * should be silently ignored at this layer — the adapter layer handles
4189
+ * sub-agent messages independently via parentToolUseId in _meta.
4190
+ */
4191
+ private isOwnSessionNotification;
2737
4192
  private setupEventForwarding;
2738
4193
  on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
2739
4194
  off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
@@ -2767,7 +4222,7 @@ declare class CloudAgentConnection implements AgentConnection {
2767
4222
  createdAt: number;
2768
4223
  }>;
2769
4224
  hasPendingQuestions(): boolean;
2770
- toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
4225
+ toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
2771
4226
  success: boolean;
2772
4227
  error?: string;
2773
4228
  }>;
@@ -2781,6 +4236,7 @@ declare class CloudAgentConnection implements AgentConnection {
2781
4236
  * Contains sandboxId, link, token, etc.
2782
4237
  */
2783
4238
  get sessionConnectionInfo(): SessionConnectionInfo | undefined;
4239
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2784
4240
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2785
4241
  }
2786
4242
  //#endregion
@@ -2808,6 +4264,13 @@ interface ArchiveConversationResponse {
2808
4264
  /**
2809
4265
  * Configuration for CloudAgentProvider
2810
4266
  */
4267
+ /**
4268
+ * Factory function to create a FilesResource from sandbox connection info.
4269
+ * Used to inject different filesystem implementations (e.g., MiniProgramE2BFilesystem for miniprogram).
4270
+ */
4271
+ type FilesystemFactory = (info: E2BSandboxConnectionInfo) => Promise<FilesResource & {
4272
+ setReconnectFn?: (fn: () => Promise<E2BSandboxConnectionInfo>) => void;
4273
+ }>;
2811
4274
  interface CloudAgentProviderOptions {
2812
4275
  /** Base endpoint URL for agent management API (e.g., 'https://api.example.com') */
2813
4276
  endpoint: string;
@@ -2819,6 +4282,12 @@ interface CloudAgentProviderOptions {
2819
4282
  logger?: Logger;
2820
4283
  /** Client capabilities (sent during agent initialization) */
2821
4284
  clientCapabilities?: ClientCapabilities$1;
4285
+ /**
4286
+ * Optional filesystem factory for creating FilesResource instances.
4287
+ * If not provided, defaults to E2BFilesystem (requires e2b package).
4288
+ * Set this to MiniProgramE2BFilesystem.connect for miniprogram environments.
4289
+ */
4290
+ filesystemFactory?: FilesystemFactory;
2822
4291
  }
2823
4292
  /**
2824
4293
  * CloudAgentProvider - Manages cloud-hosted agents via REST API
@@ -2903,6 +4372,22 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2903
4372
  private cosUploadService;
2904
4373
  /** Event listeners for provider-level events */
2905
4374
  private eventListeners;
4375
+ /** 产品配置缓存(内存),用于存储 deploymentType 和 creditPurchaseActions */
4376
+ private productConfigCache;
4377
+ /**
4378
+ * Plugin marketplace cache (name/id -> marketplace info)
4379
+ * LRU 缓存,容量上限 200
4380
+ * Key: marketplace name 或 id
4381
+ * Value: marketplace 完整信息
4382
+ */
4383
+ private marketplaceCache;
4384
+ /**
4385
+ * Installed plugin cache (plugin name -> plugin info with install_id)
4386
+ * LRU 缓存,容量上限 2000
4387
+ * Key: plugin name
4388
+ * Value: plugin 完整信息(包含 installId)
4389
+ */
4390
+ private pluginCache;
2906
4391
  constructor(options: CloudAgentProviderOptions);
2907
4392
  /**
2908
4393
  * Dispose the provider and clean up resources
@@ -2959,11 +4444,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2959
4444
  /**
2960
4445
  * Create a new conversation
2961
4446
  * POST {endpoint}/console/as/conversations
2962
- * @param params - Optional session params containing _meta with tags
4447
+ * @param params - Session params containing cwd and optional configuration
2963
4448
  */
2964
- create(params?: {
2965
- _meta?: Record<string, unknown>;
2966
- }): Promise<string>;
4449
+ create(params: CreateSessionParams$1): Promise<string>;
2967
4450
  /**
2968
4451
  * Connect to an agent and return the connection
2969
4452
  *
@@ -3015,6 +4498,21 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3015
4498
  * ```
3016
4499
  */
3017
4500
  rename(agentId: string, title: string): Promise<PatchConversationResponse>;
4501
+ /**
4502
+ * Update conversation status by ID
4503
+ * POST {endpoint}/console/as/conversations/{agentId}
4504
+ *
4505
+ * @param agentId - Conversation ID to update
4506
+ * @param status - New status for the conversation
4507
+ * @returns PatchConversationResponse containing the updated conversation ID
4508
+ *
4509
+ * @example
4510
+ * ```typescript
4511
+ * const result = await provider.updateStatus('agent-123', 'completed');
4512
+ * console.log('Updated conversation status:', result.id);
4513
+ * ```
4514
+ */
4515
+ updateStatus(agentId: string, status: string): Promise<PatchConversationResponse>;
3018
4516
  /**
3019
4517
  * Get available models from product configuration
3020
4518
  *
@@ -3027,6 +4525,25 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3027
4525
  * @returns Array of ModelInfo with full model details
3028
4526
  */
3029
4527
  getModels(repo?: string): Promise<ModelInfo[]>;
4528
+ /**
4529
+ * 获取产品部署类型(从缓存)
4530
+ * 需要先调用 getModels() 初始化缓存
4531
+ *
4532
+ * @returns 部署类型:'SaaS' | 'Cloud-Hosted' | 'Self-Hosted',默认为 'SaaS'
4533
+ */
4534
+ getDeploymentType(): string;
4535
+ /**
4536
+ * 获取 Credit 购买引导配置(从缓存)
4537
+ * 需要先调用 getModels() 初始化缓存
4538
+ *
4539
+ * @returns Credit 购买引导配置,key 为错误码。如果后端未返回,则使用默认配置
4540
+ */
4541
+ getCreditPurchaseActions(): Record<string, {
4542
+ labelZh: string;
4543
+ labelEn: string;
4544
+ url: string;
4545
+ showButton?: boolean;
4546
+ }>;
3030
4547
  /**
3031
4548
  * Generate a unique request ID
3032
4549
  */
@@ -3049,7 +4566,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3049
4566
  /**
3050
4567
  * Upload files to cloud storage via COS presigned URL
3051
4568
  *
3052
- * @param params - files array (File objects in browser)
4569
+ * @param params - files array (File objects in browser), optional abortSignal
3053
4570
  * @returns Response with corresponding cloud URLs
3054
4571
  */
3055
4572
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
@@ -3073,53 +4590,282 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3073
4590
  private emitEvent;
3074
4591
  /**
3075
4592
  * 获取支持的场景列表
3076
- * API 端点: GET /console/as/support/scenes
4593
+ * API 端点: GET /v2/as/support/scenes (不鉴权)
3077
4594
  * 用于 Welcome 页面的 QuickActions 快捷操作
3078
4595
  *
4596
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
3079
4597
  * @returns Promise<SupportScene[]> 支持的场景列表
3080
4598
  */
3081
- getSupportScenes(): Promise<SupportScene[]>;
4599
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
3082
4600
  private toAgentState;
3083
4601
  /**
3084
4602
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
3085
4603
  */
3086
4604
  private buildGetUrl;
4605
+ /**
4606
+ * 获取已安装插件列表
4607
+ * GET /console/as/user/plugins/installed
4608
+ */
4609
+ getInstalledPlugins(forceRefresh?: boolean): Promise<Array<{
4610
+ name: string;
4611
+ marketplaceName: string;
4612
+ status: string;
4613
+ description?: string;
4614
+ version?: string;
4615
+ installScope?: 'user' | 'project';
4616
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
4617
+ installId?: string;
4618
+ }>>;
4619
+ /**
4620
+ * 安装插件
4621
+ * POST /console/as/user/plugins/install
4622
+ *
4623
+ * @param pluginNames - 插件名称数组
4624
+ * @param marketplaceNameOrId - 市场名称或 ID
4625
+ */
4626
+ installPlugins(pluginNames: string[], marketplaceNameOrId: string, installScope?: 'user' | 'project' | 'project-local', marketplaceSource?: string, workspacePath?: string): Promise<{
4627
+ success: boolean;
4628
+ error?: string;
4629
+ }>;
4630
+ /**
4631
+ * 卸载插件
4632
+ * POST /console/as/user/plugins/installed/:id/uninstall
4633
+ *
4634
+ * 完整链路:
4635
+ * CloudAgentProvider.uninstallPlugin()
4636
+ * -> HTTP POST /console/as/user/plugins/installed/:id/uninstall
4637
+ * -> agentserver: PluginInstallService.Uninstall()
4638
+ * -> 软删除 DB + 异步同步到活跃沙箱
4639
+ *
4640
+ * @param pluginName - 插件名称
4641
+ * @param marketplaceName - 市场名称(用于标识唯一插件)
4642
+ * @param scope - 卸载范围 ('user' | 'project' | 'project-local')
4643
+ */
4644
+ uninstallPlugin(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
4645
+ success: boolean;
4646
+ error?: string;
4647
+ }>;
4648
+ /**
4649
+ * 获取插件市场列表
4650
+ * GET /console/as/marketplace/sources
4651
+ */
4652
+ getPluginMarketplaces(forceRefresh?: boolean): Promise<Array<{
4653
+ id: string;
4654
+ name: string;
4655
+ type: 'github' | 'local' | 'custom';
4656
+ source: {
4657
+ repo?: string;
4658
+ ref?: string;
4659
+ url?: string;
4660
+ };
4661
+ description?: string;
4662
+ isBuiltin?: boolean;
4663
+ }>>;
4664
+ /**
4665
+ * 获取市场下的插件列表
4666
+ * - 有 searchText: GET /console/as/marketplace/plugins/search (跨所有市场搜索)
4667
+ * - 无 searchText: GET /console/as/marketplace/plugins (指定市场)
4668
+ *
4669
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4670
+ * @param forceRefresh - 是否强制刷新
4671
+ * @param searchText - 搜索关键字(如果提供,则跨所有市场搜索)
4672
+ */
4673
+ getMarketplacePlugins(marketplaceNameOrId: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
4674
+ name: string;
4675
+ marketplaceName: string;
4676
+ description?: string;
4677
+ version?: string;
4678
+ author?: string;
4679
+ homepage?: string;
4680
+ iconUrl?: string;
4681
+ tags?: string[];
4682
+ installed?: boolean;
4683
+ status?: 'enabled' | 'disabled' | 'not-installed';
4684
+ installedScopes?: Array<'user' | 'project'>;
4685
+ hasUpdate?: boolean;
4686
+ latestVersion?: string;
4687
+ agents?: any;
4688
+ commands?: any;
4689
+ skills?: any;
4690
+ mcpServers?: any;
4691
+ hooks?: any;
4692
+ rules?: any;
4693
+ }>>;
4694
+ /**
4695
+ * 获取插件详情
4696
+ * GET /console/as/marketplace/plugins/:name/detail
4697
+ *
4698
+ * @param pluginName - 插件名称
4699
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4700
+ */
4701
+ getPluginDetail(pluginName: string, marketplaceNameOrId: string): Promise<{
4702
+ name: string;
4703
+ marketplaceName: string;
4704
+ description?: string;
4705
+ version?: string;
4706
+ author?: string;
4707
+ homepage?: string;
4708
+ iconUrl?: string;
4709
+ tags?: string[];
4710
+ installed?: boolean;
4711
+ status?: 'enabled' | 'disabled' | 'not-installed';
4712
+ installedScopes?: Array<'user' | 'project'>;
4713
+ readme?: string;
4714
+ configSchema?: Record<string, unknown>;
4715
+ tools?: Array<{
4716
+ name: string;
4717
+ description?: string;
4718
+ }>;
4719
+ resources?: Array<{
4720
+ name: string;
4721
+ description?: string;
4722
+ }>;
4723
+ prompts?: Array<{
4724
+ name: string;
4725
+ description?: string;
4726
+ }>;
4727
+ downloadCount?: number;
4728
+ lastUpdated?: string;
4729
+ license?: string;
4730
+ repositoryUrl?: string;
4731
+ } | null>;
4732
+ /**
4733
+ * 添加插件市场
4734
+ * POST /console/as/marketplace/sources
4735
+ */
4736
+ addPluginMarketplace(sourceUrl: string, name?: string): Promise<{
4737
+ success: boolean;
4738
+ error?: string;
4739
+ marketplace?: {
4740
+ id: string;
4741
+ name: string;
4742
+ type: 'github' | 'local' | 'custom';
4743
+ source: {
4744
+ repo?: string;
4745
+ ref?: string;
4746
+ url?: string;
4747
+ };
4748
+ description?: string;
4749
+ isBuiltin?: boolean;
4750
+ };
4751
+ }>;
4752
+ /**
4753
+ * 删除插件市场
4754
+ * POST /console/as/marketplace/sources/:id/delete
4755
+ */
4756
+ removePluginMarketplace(marketplaceNameOrId: string): Promise<{
4757
+ success: boolean;
4758
+ error?: string;
4759
+ }>;
4760
+ /**
4761
+ * 刷新插件市场
4762
+ * POST /console/as/marketplace/sources/:id/check-updates
4763
+ */
4764
+ refreshPluginMarketplace(marketplaceNameOrId: string): Promise<{
4765
+ success: boolean;
4766
+ error?: string;
4767
+ plugins?: Array<any>;
4768
+ }>;
4769
+ /**
4770
+ * 批量切换插件启用/禁用状态
4771
+ * POST /console/as/user/plugins/installed/:id/toggle
4772
+ */
4773
+ batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
4774
+ /**
4775
+ * 将后端插件数据映射为前端格式
4776
+ */
4777
+ private mapPluginData;
4778
+ /**
4779
+ * 从缓存中查找插件的 install_id
4780
+ * 如果缓存未命中,则调用 API 获取并缓存
4781
+ *
4782
+ * @param pluginName - 插件名称
4783
+ * @returns install_id 或 null
4784
+ */
4785
+ private findPluginInstallId;
4786
+ /**
4787
+ * 从缓存中查找 marketplace ID
4788
+ * 如果缓存未命中,则调用 API 获取并缓存
4789
+ */
4790
+ private findMarketplaceId;
4791
+ /**
4792
+ * 提取 API 错误信息
4793
+ * 从 AxiosError 中提取详细的错误信息,包括 HTTP 状态码、错误码和错误消息
4794
+ */
4795
+ private extractErrorMessage;
4796
+ /**
4797
+ * 映射后端 source_type 到前端类型
4798
+ */
4799
+ private mapSourceType;
4800
+ /**
4801
+ * 解析 capabilities JSON 字符串
4802
+ */
4803
+ private parseCapabilities;
4804
+ /**
4805
+ * 上报 telemetry 事件(Cloud 模式)
4806
+ * 通过 HTTP POST 发送到 /v2/report
4807
+ * 注入用户信息和浏览器环境等公共字段
4808
+ */
4809
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
3087
4810
  }
3088
4811
  //#endregion
3089
4812
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
3090
4813
  /**
3091
- * E2B Filesystem Implementation
4814
+ * Callback to fetch fresh sandbox connection info from backend.
4815
+ * Called when an operation fails with 401/403.
4816
+ */
4817
+ type ReconnectFn = () => Promise<E2BSandboxConnectionInfo>;
4818
+ /**
4819
+ * E2B Filesystem
3092
4820
  *
3093
- * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource interface.
4821
+ * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource.
4822
+ * When `reconnectFn` is provided, automatically reconnects on auth errors.
3094
4823
  *
3095
4824
  * @example
3096
4825
  * ```typescript
3097
- * const fs = await E2BFilesystem.connect({
3098
- * sandboxId: 'sandbox-123',
3099
- * apiKey: 'e2b_xxx'
3100
- * });
4826
+ * // Basic usage (no auto-reconnect)
4827
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
3101
4828
  *
3102
- * // Read/write files
3103
- * await fs.write('/test.txt', 'Hello World');
3104
- * const content = await fs.read('/test.txt');
3105
- *
3106
- * // Watch for changes
3107
- * const handle = await fs.watchDir('/workspace', (event) => {
3108
- * console.log('File changed:', event);
3109
- * });
4829
+ * // With auto-reconnect on token expiry
4830
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
4831
+ * fs.setReconnectFn(async () => fetchFreshConnectionInfo());
3110
4832
  * ```
3111
4833
  */
3112
4834
  declare class E2BFilesystem implements FilesResource {
3113
4835
  private sandbox;
4836
+ private reconnectFn?;
4837
+ /** Whether a reconnect is currently in-flight */
4838
+ private isReconnecting;
4839
+ /** Callers waiting for the in-flight reconnect to complete */
4840
+ private reconnectSubscribers;
4841
+ /** Timestamp of last reconnect attempt (anti-loop: min 10s between attempts) */
4842
+ private lastReconnectAt;
4843
+ private static readonly MIN_RECONNECT_INTERVAL_MS;
3114
4844
  constructor(sandbox: Sandbox);
3115
4845
  /**
3116
4846
  * Connect to an E2B Sandbox and create filesystem instance
3117
4847
  */
3118
4848
  static connect(info: E2BSandboxConnectionInfo): Promise<E2BFilesystem>;
4849
+ /**
4850
+ * Set reconnect callback. When set, auth errors trigger automatic reconnect + retry.
4851
+ */
4852
+ setReconnectFn(fn: ReconnectFn): void;
3119
4853
  /**
3120
4854
  * Get the underlying E2B Sandbox instance
3121
4855
  */
3122
4856
  getSandbox(): Sandbox;
4857
+ private isAuthError;
4858
+ private canAttemptReconnect;
4859
+ /**
4860
+ * Reconnect with fresh credentials.
4861
+ * Only one reconnect in-flight at a time; concurrent callers share the result.
4862
+ */
4863
+ private reconnect;
4864
+ /**
4865
+ * Execute an operation. If reconnectFn is set and an auth error occurs,
4866
+ * reconnect and retry once.
4867
+ */
4868
+ private exec;
3123
4869
  read(path: string, opts?: FilesystemRequestOpts & {
3124
4870
  format?: 'text';
3125
4871
  }): Promise<string>;
@@ -3134,13 +4880,13 @@ declare class E2BFilesystem implements FilesResource {
3134
4880
  }): Promise<ReadableStream<Uint8Array>>;
3135
4881
  write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<WriteInfo>;
3136
4882
  write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
3137
- list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
4883
+ list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo[]>;
3138
4884
  exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
3139
4885
  makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
3140
4886
  remove(path: string, opts?: FilesystemRequestOpts): Promise<void>;
3141
- rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
3142
- getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
3143
- watchDir(path: string, onEvent: (event: FilesystemEvent$1) => void | Promise<void>, opts?: WatchOpts & {
4887
+ rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
4888
+ getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
4889
+ watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
3144
4890
  onExit?: (err?: Error) => void | Promise<void>;
3145
4891
  }): Promise<WatchHandle>;
3146
4892
  }
@@ -3262,6 +5008,7 @@ interface ActiveSessionImplOptions {
3262
5008
  declare class ActiveSessionImpl implements ActiveSession {
3263
5009
  private _id;
3264
5010
  private _agentId;
5011
+ private _cwd?;
3265
5012
  private _availableModes?;
3266
5013
  private _currentMode?;
3267
5014
  private _availableModels?;
@@ -3273,6 +5020,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3273
5020
  private _connectionInfo?;
3274
5021
  private listeners;
3275
5022
  private onceListeners;
5023
+ private connectionListeners;
3276
5024
  /**
3277
5025
  * Agent operations namespace
3278
5026
  */
@@ -3306,6 +5054,14 @@ declare class ActiveSessionImpl implements ActiveSession {
3306
5054
  * Agent ID
3307
5055
  */
3308
5056
  get agentId(): string;
5057
+ /**
5058
+ * Actual workspace path (set from newSession response _meta)
5059
+ */
5060
+ get cwd(): string | undefined;
5061
+ /**
5062
+ * Set actual workspace path (called by SessionManager after createSession)
5063
+ */
5064
+ setCwd(cwd: string): void;
3309
5065
  /**
3310
5066
  * Agent state (live connection state)
3311
5067
  * Returns LocalAgentState or CloudAgentState based on transport type
@@ -3387,12 +5143,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3387
5143
  */
3388
5144
  cancelQuestion(toolCallId: string, reason?: string): boolean;
3389
5145
  /**
3390
- * Callback for tool operations (skip or cancel)
5146
+ * Callback for tool operations (approve / skip / cancel)
3391
5147
  * @param toolCallId Tool call ID
3392
5148
  * @param toolName Tool name
3393
- * @param action Action to perform ('skip' or 'cancel')
5149
+ * @param action Action to perform ('approve' / 'skip' / 'cancel')
3394
5150
  */
3395
- toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
5151
+ toolCallback(toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
3396
5152
  success: boolean;
3397
5153
  error?: string;
3398
5154
  }>;
@@ -3450,6 +5206,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3450
5206
  * Disconnect from the session/agent
3451
5207
  */
3452
5208
  disconnect(): void;
5209
+ /**
5210
+ * Detach the session from connection events without disconnecting the connection.
5211
+ * This should be called when the session is being replaced but the connection is shared.
5212
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
5213
+ */
5214
+ detach(): void;
3453
5215
  /**
3454
5216
  * Symbol.dispose for 'using' keyword support
3455
5217
  * Automatically disconnects and cleans up when session goes out of scope
@@ -3464,8 +5226,21 @@ declare class ActiveSessionImpl implements ActiveSession {
3464
5226
  */
3465
5227
  [Symbol.dispose](): void;
3466
5228
  private getConnectionOrThrow;
5229
+ /**
5230
+ * 在 connection 上注册 listener 并保存引用,便于 disconnect 时移除
5231
+ */
5232
+ private addConnectionListener;
5233
+ /**
5234
+ * 从 connection 上移除所有本 session 注册的 listener
5235
+ */
5236
+ private removeConnectionListeners;
3467
5237
  private setupConnectionEvents;
3468
5238
  private mapPromptResponse;
5239
+ /**
5240
+ * 判断 artifact 是否应该转发给当前 session
5241
+ * 所有类型的 artifact 都按 __sessionId 严格隔离
5242
+ */
5243
+ private shouldForwardArtifact;
3469
5244
  }
3470
5245
  //#endregion
3471
5246
  //#region ../agent-provider/lib/common/client/session-manager.d.ts
@@ -3507,6 +5282,14 @@ interface SessionManagerOptions {
3507
5282
  declare class SessionManager {
3508
5283
  private provider;
3509
5284
  private logger?;
5285
+ /**
5286
+ * Cache of connections from failed createSession() attempts.
5287
+ * Keyed by agentId, used by retryNewSession() to reuse the
5288
+ * existing initialized connection instead of re-connecting.
5289
+ *
5290
+ * @experimental Internal cache for retryNewSession support
5291
+ */
5292
+ private pendingConnections;
3510
5293
  constructor(options: SessionManagerOptions);
3511
5294
  /**
3512
5295
  * List all sessions with pagination info (mapped from agents)
@@ -3529,6 +5312,47 @@ declare class SessionManager {
3529
5312
  * 5. Return ActiveSession instance
3530
5313
  */
3531
5314
  createSession(params: CreateSessionParams$1): Promise<ActiveSession>;
5315
+ /**
5316
+ * Retry creating a session after initial session/new request failed.
5317
+ *
5318
+ * Use this when `sessions.create()` fails at the `session/new` step
5319
+ * (after agent creation and connection establishment succeeded).
5320
+ * The caller retrieves `agentId` from the thrown `SessionError.agentId`,
5321
+ * then calls this method to re-attempt only the `session/new` request
5322
+ * while reusing the already-initialized connection (no re-connect).
5323
+ *
5324
+ * @experimental This API is subject to change
5325
+ *
5326
+ * @param agentId - Agent ID from the failed SessionError
5327
+ * @param params - Original create session params (cwd, mcpServers, etc.)
5328
+ * @returns ActiveSession on success
5329
+ * @throws SessionError if session/new fails again
5330
+ *
5331
+ * @example
5332
+ * ```typescript
5333
+ * try {
5334
+ * const session = await client.sessions.create({ cwd: '/workspace' });
5335
+ * } catch (err) {
5336
+ * if (err instanceof SessionError && err.agentId) {
5337
+ * // Retry with custom logic
5338
+ * for (let i = 0; i < 3; i++) {
5339
+ * try {
5340
+ * const session = await client.sessions.retryNewSession(err.agentId, { cwd: '/workspace' });
5341
+ * break; // success
5342
+ * } catch (retryErr) {
5343
+ * await new Promise(r => setTimeout(r, 1000 * (i + 1)));
5344
+ * }
5345
+ * }
5346
+ * }
5347
+ * }
5348
+ * ```
5349
+ */
5350
+ retryNewSession(agentId: string, params: CreateSessionParams$1): Promise<ActiveSession>;
5351
+ /**
5352
+ * Build an ActiveSession from a NewSessionResponse.
5353
+ * Shared by createSession() and retryNewSession().
5354
+ */
5355
+ private buildActiveSession;
3532
5356
  /**
3533
5357
  * Load an existing session
3534
5358
  *
@@ -3570,6 +5394,13 @@ declare class SessionManager {
3570
5394
  */
3571
5395
  declare class BackendProvider implements IBackendProvider {
3572
5396
  constructor(config: BackendProviderConfig);
5397
+ /**
5398
+ * 处理 401 未授权错误
5399
+ * 先尝试刷新 token,失败后再执行登出流程
5400
+ *
5401
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
5402
+ */
5403
+ protected handleUnauthorized(): Promise<void>;
3573
5404
  /**
3574
5405
  * 获取当前账号信息
3575
5406
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3680,9 +5511,21 @@ declare class BackendProvider implements IBackendProvider {
3680
5511
  login(): Promise<void>;
3681
5512
  /**
3682
5513
  * 登出账号
3683
- * Web 环境: 通过 iframe 访问登出 URL 清除 cookie
5514
+ *
5515
+ * 策略:
5516
+ * - IOA 企业:用 iframe 走 SSO/SAML SLO 登出链路(涉及跨域重定向),通过轮询 iframe URL 变化检测完成
5517
+ * - 非 IOA 企业:直接用 httpService 请求 /console/logout,速度快
3684
5518
  */
3685
5519
  logout(): Promise<void>;
5520
+ /**
5521
+ * IOA 企业登出:通过 iframe 走 SSO/SAML SLO 登出链路
5522
+ * 轮询 iframe URL 变化检测完成,兜底超时 5 秒
5523
+ */
5524
+ private logoutViaIframe;
5525
+ /**
5526
+ * 非 IOA 企业登出:直接 HTTP 请求 /console/logout
5527
+ */
5528
+ private logoutViaHttp;
3686
5529
  /**
3687
5530
  * 批量切换插件状态
3688
5531
  * Web 环境不支持此功能
@@ -3725,6 +5568,41 @@ declare class BackendProvider implements IBackendProvider {
3725
5568
  * @returns Promise<ListReposResponse> 仓库列表响应
3726
5569
  */
3727
5570
  getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
5571
+ /**
5572
+ * 保存待发送的输入内容到后端
5573
+ * API 端点: POST /api/v1/code-id
5574
+ */
5575
+ savePendingInput(code: string): Promise<string | null>;
5576
+ /**
5577
+ * 从后端加载待发送的输入内容
5578
+ * API 端点: GET /api/v1/code?id=xxx
5579
+ */
5580
+ loadPendingInput(codeId: string): Promise<string | null>;
5581
+ /**
5582
+ * 获取每日签到状态
5583
+ * API 端点: POST /billing/meter/checkin-status
5584
+ */
5585
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5586
+ /**
5587
+ * 执行每日签到
5588
+ * API 端点: POST /billing/meter/daily-checkin
5589
+ */
5590
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
5591
+ private static readonly SKILLHUB_BASE_URL;
5592
+ private static readonly SKILLHUB_FETCH_TIMEOUT;
5593
+ private skillHubFetch;
5594
+ getSkillHubList(params?: SkillHubListParams): Promise<SkillHubListResponse>;
5595
+ getSkillHubCategories(): Promise<SkillHubCategoriesResponse>;
5596
+ getSkillHubSearch(q: string, limit?: number): Promise<SkillHubSearchResponse>;
5597
+ getSkillHubDetail(slug: string): Promise<SkillHubDetailResponse>;
5598
+ getSkillHubExists(slugs: string[]): Promise<SkillHubExistsResponse>;
5599
+ reportSkillHubStats(slug: string, inc: {
5600
+ downloads?: number;
5601
+ installs?: number;
5602
+ stars?: number;
5603
+ }): Promise<void>;
5604
+ installSkillHubSkill(_slug: string, _version?: string, _name?: string): Promise<SkillHubInstallResponse>;
5605
+ getSkillHubInstalledMetas(): Promise<SkillHubInstalledMeta[]>;
3728
5606
  }
3729
5607
  /**
3730
5608
  * 创建 BackendProvider 实例
@@ -3753,6 +5631,12 @@ declare class IPCBackendProvider implements IBackendProvider {
3753
5631
  private readonly debug;
3754
5632
  private readonly timeoutMs;
3755
5633
  constructor(config: IPCBackendProviderConfig);
5634
+ /**
5635
+ * 设置会话变化监听器
5636
+ * 监听来自 Extension Host (BackendBridgeService) 推送的 auth:session-changed 事件
5637
+ * 并更新本地 accountService
5638
+ */
5639
+ private setupSessionChangeListener;
3756
5640
  /**
3757
5641
  * 发送统一格式的后端请求
3758
5642
  * @param requestType 请求类型
@@ -3853,6 +5737,14 @@ declare class IPCBackendProvider implements IBackendProvider {
3853
5737
  reloadWindow(params?: {
3854
5738
  locale?: string;
3855
5739
  }): Promise<void>;
5740
+ /**
5741
+ * Save locale to argv.json without restarting the app.
5742
+ * The change takes effect on next manual restart.
5743
+ * @param params locale to save
5744
+ */
5745
+ saveLocale(params: {
5746
+ locale: string;
5747
+ }): Promise<void>;
3856
5748
  /**
3857
5749
  * 关闭 Agent Manager 面板
3858
5750
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
@@ -3864,6 +5756,24 @@ declare class IPCBackendProvider implements IBackendProvider {
3864
5756
  * @param url 要打开的 URL
3865
5757
  */
3866
5758
  openExternal(url: string): Promise<void>;
5759
+ /**
5760
+ * 打开本地文件
5761
+ * IDE 环境: 通过 IPC 通知 IDE 打开本地配置文件
5762
+ * @param filePath 要打开的文件路径
5763
+ */
5764
+ openLocalFile(filePath: string): Promise<void>;
5765
+ /**
5766
+ * 获取用户级本地自定义模型
5767
+ */
5768
+ getLocalCustomModels(): Promise<GetLocalCustomModelsResponse>;
5769
+ /**
5770
+ * 保存用户级本地自定义模型
5771
+ */
5772
+ saveLocalCustomModel(request: SaveLocalCustomModelRequest): Promise<GetLocalCustomModelsResponse>;
5773
+ /**
5774
+ * 删除用户级本地自定义模型
5775
+ */
5776
+ deleteLocalCustomModel(id: string): Promise<GetLocalCustomModelsResponse>;
3867
5777
  /**
3868
5778
  * 批量切换插件状态
3869
5779
  * IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
@@ -3881,6 +5791,76 @@ declare class IPCBackendProvider implements IBackendProvider {
3881
5791
  * 4. 返回 SupportScene[] 数据给 agent-ui
3882
5792
  */
3883
5793
  getSupportScenes(): Promise<SupportScene[]>;
5794
+ /**
5795
+ * 获取账号用量信息(积分/Credits)
5796
+ * IDE 环境: 通过 IPC 实时获取用量信息,每次打开菜单时调用
5797
+ *
5798
+ * 调用链:
5799
+ * 1. agent-ui: IPCBackendProvider.getAccountUsage()
5800
+ * 2. Agent Manager renderer: BackendService.getAccountUsage()
5801
+ * 3. Main Process: codebuddy:getAccountUsage IPC handler
5802
+ * 4. 返回 { usageLeft, usageTotal, editionType, refreshAt } 等字段
5803
+ */
5804
+ getAccountUsage(): Promise<Partial<Account> | null>;
5805
+ /**
5806
+ * 获取每日签到状态
5807
+ * IDE 环境: 通过 IPC 获取签到状态
5808
+ */
5809
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5810
+ /**
5811
+ * 执行每日签到
5812
+ * IDE 环境: 通过 IPC 执行签到
5813
+ */
5814
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
5815
+ /**
5816
+ * 获取活动 Banner
5817
+ * IDE 环境: 通过 IPC 获取活动 Banner
5818
+ */
5819
+ getActivityBanner(): Promise<ActivityBannerResponse | null>;
5820
+ /**
5821
+ * 获取 SkillHub 技能列表
5822
+ * IDE 环境: 通过 IPC 获取技能列表
5823
+ */
5824
+ getSkillHubList(params?: SkillHubListParams): Promise<SkillHubListResponse>;
5825
+ /**
5826
+ * 获取 SkillHub 分类列表
5827
+ * IDE 环境: 通过 IPC 获取分类列表
5828
+ */
5829
+ getSkillHubCategories(): Promise<SkillHubCategoriesResponse>;
5830
+ /**
5831
+ * 搜索 SkillHub 技能
5832
+ * IDE 环境: 通过 IPC 搜索技能
5833
+ */
5834
+ getSkillHubSearch(q: string, limit?: number): Promise<SkillHubSearchResponse>;
5835
+ /**
5836
+ * 获取 SkillHub 技能详情
5837
+ * IDE 环境: 通过 IPC 获取技能详情
5838
+ */
5839
+ getSkillHubDetail(slug: string): Promise<SkillHubDetailResponse>;
5840
+ /**
5841
+ * 批量检查 SkillHub 技能是否存在
5842
+ * IDE 环境: 通过 IPC 检查技能是否存在
5843
+ */
5844
+ getSkillHubExists(slugs: string[]): Promise<SkillHubExistsResponse>;
5845
+ /**
5846
+ * 上报 SkillHub 技能统计
5847
+ * IDE 环境: 通过 IPC 上报统计
5848
+ */
5849
+ reportSkillHubStats(slug: string, inc: {
5850
+ downloads?: number;
5851
+ installs?: number;
5852
+ stars?: number;
5853
+ }): Promise<void>;
5854
+ /**
5855
+ * 安装 SkillHub 技能
5856
+ * IDE 环境: 通过 IPC 安装技能(下载 zip → 解压到本地)
5857
+ */
5858
+ installSkillHubSkill(slug: string, version?: string, name?: string): Promise<SkillHubInstallResponse>;
5859
+ /**
5860
+ * 获取本地已安装的 SkillHub 技能元信息
5861
+ * IDE 环境: 通过 IPC 获取元信息
5862
+ */
5863
+ getSkillHubInstalledMetas(): Promise<SkillHubInstalledMeta[]>;
3884
5864
  /**
3885
5865
  * 调试日志
3886
5866
  */
@@ -3918,7 +5898,7 @@ type RequestErrorInterceptor = (error: any) => any;
3918
5898
  /**
3919
5899
  * 响应拦截器函数
3920
5900
  */
3921
- type ResponseInterceptor = (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
5901
+ type ResponseInterceptor = (response: AxiosResponse$1) => AxiosResponse$1 | Promise<AxiosResponse$1>;
3922
5902
  /**
3923
5903
  * 响应错误拦截器函数
3924
5904
  */
@@ -3935,7 +5915,7 @@ type UnauthorizedCallback = () => void;
3935
5915
  * 特性:
3936
5916
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3937
5917
  * - 支持拦截器注册(其他模块可注入 header)
3938
- * - 统一 401/403 处理
5918
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3939
5919
  * - 自动携带凭证(withCredentials)
3940
5920
  * - 类型安全
3941
5921
  *
@@ -3971,6 +5951,10 @@ declare class HttpService {
3971
5951
  private axiosInstance;
3972
5952
  private unauthorizedCallbacks;
3973
5953
  private config;
5954
+ /** 是否正在刷新 token */
5955
+ private isRefreshing;
5956
+ /** 等待 token 刷新完成的请求队列 */
5957
+ private refreshSubscribers;
3974
5958
  /**
3975
5959
  * 私有构造函数(单例模式)
3976
5960
  */
@@ -3988,9 +5972,17 @@ declare class HttpService {
3988
5972
  */
3989
5973
  private registerDefaultRequestInterceptor;
3990
5974
  /**
3991
- * 注册默认响应拦截器(处理 401/403)
5975
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3992
5976
  */
3993
5977
  private registerDefaultResponseInterceptor;
5978
+ /**
5979
+ * token 刷新成功,通知所有等待的请求
5980
+ */
5981
+ private onRefreshSuccess;
5982
+ /**
5983
+ * token 刷新失败,通知所有等待的请求
5984
+ */
5985
+ private onRefreshFailure;
3994
5986
  /**
3995
5987
  * 注册请求拦截器
3996
5988
  * @param onFulfilled 请求成功拦截器
@@ -4056,7 +6048,9 @@ declare class HttpService {
4056
6048
  */
4057
6049
  offUnauthorized(callback: UnauthorizedCallback): void;
4058
6050
  /**
4059
- * 触发所有 401 回调
6051
+ * 触发所有 401 回调并等待完成
6052
+ * @returns Promise,等待所有回调完成
6053
+ * @throws 如果任何回调失败,则抛出错误
4060
6054
  */
4061
6055
  private triggerUnauthorizedCallbacks;
4062
6056
  /**
@@ -4107,6 +6101,12 @@ declare class HttpService {
4107
6101
  * @returns 响应数据
4108
6102
  */
4109
6103
  put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
6104
+ /**
6105
+ * 通用请求方法
6106
+ * @param config axios 请求配置
6107
+ * @returns 原始 AxiosResponse
6108
+ */
6109
+ request<T = any>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
4110
6110
  /**
4111
6111
  * 获取原始 axios 实例(用于高级场景)
4112
6112
  */
@@ -4134,5 +6134,5 @@ declare class HttpService {
4134
6134
  */
4135
6135
  declare const httpService: HttpService;
4136
6136
  //#endregion
4137
- export { type Account, type AccountPlan, type ActiveSession, ActiveSessionImpl, type AgentCapabilities, AgentClient, type AgentClientOptions, type AgentConnection, type Agent as AgentInfo, type AgentProvider, type AgentState, type AgentStateType, type AgentStatus, type AgentTransport, type PromptResponse as ApiPromptResponse, type ArtifactsResource, BackendProvider, type BackendProviderConfig, type BaseAgentState, type BaseConnectionConfig, type CreateSessionParams as ClientCreateSessionParams, type CreateSessionParams, type LoadSessionParams as ClientLoadSessionParams, type LoadSessionParams, type ClientSessionsResource, CloudAgentConnection, CloudAgentProvider, type CloudAgentProviderOptions, type CloudAgentSourceInfo, type CloudAgentState, type CloudAgentTarget, type CloudAgentVisibility, type CloudConnectionConfig, type CommodityCode, type ConnectionEvents, type DeployStatus, E2BFilesystem, type E2BSandboxConnectionInfo, type Edition, type EditionDisplayType, type EntryInfo, type FilesResource, type Filesystem, type FilesystemListOpts, type FilesystemProvider, type FilesystemRequestOpts, HttpService, type HttpServiceConfig, type IBackendProvider, IPCBackendProvider, type ListAgentFilter, type ListAgentOptions, type ListAgentSort, type Logger, type McpServerConfig, type ModelInfo, type PromptContentBlock, type PromptParams, type PromptsResource, type ReasoningConfig, type RequestErrorInterceptor, type RequestInterceptor, type ResponseErrorInterceptor, type ResponseInterceptor, type Session, type SessionAgentOperations, type SessionConnectionInfo, type SessionEventHandler, type SessionEvents, type SessionInfo, SessionManager, type SessionMode, type UnauthorizedCallback, type WatchOpts, type WriteEntry, createBackendProvider, createIPCBackendProvider, httpService, isCloudAgentState };
6137
+ export { type Account, type AccountPlan, type ActiveSession, ActiveSessionImpl, type AgentCapabilities, AgentClient, type AgentClientOptions, type AgentConnection, type Agent as AgentInfo, type AgentProvider, type AgentState, type AgentStateType, type AgentStatus, type AgentTransport, type PromptResponse as ApiPromptResponse, type ArtifactsResource, BackendProvider, type BackendProviderConfig, type BaseAgentState, type BaseConnectionConfig, type CreateSessionParams as ClientCreateSessionParams, type CreateSessionParams, type LoadSessionParams as ClientLoadSessionParams, type LoadSessionParams, type ClientSessionsResource, CloudAgentConnection, CloudAgentProvider, type CloudAgentProviderOptions, type CloudAgentSourceInfo, type CloudAgentState, type CloudAgentTarget, type CloudAgentVisibility, type CloudConnectionConfig, type CommodityCode, type ConnectionEvents, type DeployStatus, E2BFilesystem, type E2BSandboxConnectionInfo, type Edition, type EditionDisplayType, type EntryInfo, type FilesResource, type Filesystem, type FilesystemListOpts, type FilesystemProvider, type FilesystemRequestOpts, HttpService, type HttpServiceConfig, type IBackendProvider, IPCBackendProvider, type ListAgentFilter, type ListAgentOptions, type ListAgentSort, type Logger, type McpServerConfig, type ModelInfo, type PromptContentBlock, type PromptParams, type PromptsResource, type ReasoningConfig, type RequestErrorInterceptor, type RequestInterceptor, type ResponseErrorInterceptor, type ResponseInterceptor, type Session, type SessionAgentOperations, type SessionConnectionInfo, SessionError, type SessionEventHandler, type SessionEvents, type SessionInfo, SessionManager, type SessionMode, type UnauthorizedCallback, type WatchOpts, type WriteEntry, createBackendProvider, createIPCBackendProvider, httpService, isCloudAgentState };
4138
6138
  //# sourceMappingURL=index.d.mts.map