@tencent-ai/cloud-agent-sdk 0.2.13 → 0.2.14-next.2667cdb.20260322

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { AgentCapabilities as AgentCapabilities$1, ClientCapabilities, InitializeResponse, LoadSessionResponse, NewSessionResponse, PromptResponse as PromptResponse$1, RequestPermissionRequest, RequestPermissionRequest as RequestPermissionRequest$1, SessionNotification, SessionNotification as SessionNotification$1, SetSessionModeResponse, SetSessionModelResponse } from "@agentclientprotocol/sdk";
2
- import { EntryInfo, EntryInfo as EntryInfo$1, Filesystem, FilesystemEvent, FilesystemEvent as FilesystemEvent$1, Sandbox, WatchHandle, WriteInfo } from "e2b";
1
+ import { AgentCapabilities as AgentCapabilities$1, ClientCapabilities, InitializeResponse, LoadSessionResponse, NewSessionResponse, PromptResponse as PromptResponse$1, RequestPermissionRequest, RequestPermissionRequest as RequestPermissionRequest$1, SessionNotification, SessionNotification as SessionNotification$1, SetSessionModeResponse, SetSessionModelResponse, StopReason } from "@agentclientprotocol/sdk";
2
+ import { Sandbox } from "e2b";
3
3
  import "zod";
4
4
 
5
5
  //#region ../agent-client-protocol/lib/common/types.d.ts
@@ -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
@@ -995,6 +1001,57 @@ interface BackendProviderConfig {
995
1001
  /** 认证 Token */
996
1002
  authToken?: string;
997
1003
  }
1004
+ /**
1005
+ * 签到状态响应
1006
+ */
1007
+ interface CheckinStatusResponse {
1008
+ /** 活动是否开启 */
1009
+ active: boolean;
1010
+ /** 今天是否已签到 */
1011
+ today_checked_in: boolean;
1012
+ /** 当前连续签到天数 */
1013
+ streak_days: number;
1014
+ /** 普通日签 credit 数量 */
1015
+ daily_credit: number;
1016
+ /** 今天签到可获得的 credit 数量 */
1017
+ today_credit: number;
1018
+ /** 今天是否是连续签到奖励日 */
1019
+ is_streak_day: boolean;
1020
+ /** 距离下一个连续签到奖励日还需签到天数(0 表示今天就是) */
1021
+ next_streak_day: number;
1022
+ /** 签到日期列表(yyyy-MM-dd 格式) */
1023
+ checkin_dates: string[];
1024
+ }
1025
+ /**
1026
+ * 签到结果响应
1027
+ */
1028
+ interface CheckinResultResponse {
1029
+ /** 本次签到实际获得的 credit */
1030
+ credit: number;
1031
+ /** 签到后的连续签到天数 */
1032
+ streak_days: number;
1033
+ /** 本次签到是否为连续签到奖励日 */
1034
+ is_streak_day: boolean;
1035
+ }
1036
+ /**
1037
+ * 活动 Banner 响应
1038
+ */
1039
+ interface ActivityBannerResponse {
1040
+ /** 活动 ID */
1041
+ id: string;
1042
+ /** 活动是否开启 */
1043
+ active: boolean;
1044
+ /** Banner 文案内容 */
1045
+ bannerContent: string;
1046
+ /** 详情链接 */
1047
+ link: string;
1048
+ /** 活动优先级 */
1049
+ level: number;
1050
+ /** 活动开始时间(格式:"2026-03-20 00:00:00",不存在则视为已开始) */
1051
+ startTime?: string;
1052
+ /** 活动结束时间(格式:"2026-04-20 23:59:59",不存在则视为永不过期) */
1053
+ endTime?: string;
1054
+ }
998
1055
  /**
999
1056
  * 企业用户用量信息
1000
1057
  */
@@ -1122,6 +1179,14 @@ interface IBackendProvider {
1122
1179
  reloadWindow?(params?: {
1123
1180
  locale?: string;
1124
1181
  }): Promise<void>;
1182
+ /**
1183
+ * Save locale to argv.json without restarting the app (optional, IPC only).
1184
+ * The change takes effect on next manual restart.
1185
+ * @param params locale to save
1186
+ */
1187
+ saveLocale?(params: {
1188
+ locale: string;
1189
+ }): Promise<void>;
1125
1190
  /**
1126
1191
  * 关闭 Agent Manager 面板(可选,仅 IPC 环境支持)
1127
1192
  * 用于 Local 模式下点击 Logo 返回 IDE
@@ -1145,6 +1210,27 @@ interface IBackendProvider {
1145
1210
  * @returns Promise<EnterpriseUsage | null> 企业用户用量信息
1146
1211
  */
1147
1212
  getEnterpriseUsage?(enterpriseId: string): Promise<EnterpriseUsage | null>;
1213
+ /**
1214
+ * 获取账号用量信息(积分/Credits)
1215
+ * 实时获取,每次打开菜单时调用,不依赖 getAccount 缓存
1216
+ * @returns Promise<Partial<Account> | null> 包含 usageLeft, usageTotal, refreshAt 等字段
1217
+ */
1218
+ getAccountUsage?(): Promise<Partial<Account> | null>;
1219
+ /**
1220
+ * 获取每日签到状态
1221
+ * @returns Promise<CheckinStatusResponse | null> 签到状态,失败时返回 null
1222
+ */
1223
+ getCheckinStatus?(): Promise<CheckinStatusResponse | null>;
1224
+ /**
1225
+ * 执行每日签到
1226
+ * @returns Promise<CheckinResultResponse> 签到结果
1227
+ */
1228
+ claimDailyCheckin?(): Promise<CheckinResultResponse>;
1229
+ /**
1230
+ * 获取活动 Banner
1231
+ * @returns Promise<ActivityBannerResponse | null> 活动 Banner 信息,失败时返回 null
1232
+ */
1233
+ getActivityBanner?(): Promise<ActivityBannerResponse | null>;
1148
1234
  /**
1149
1235
  * 刷新 Token(可选)
1150
1236
  * 通过调用 getAccount 刷新 cookie
@@ -1173,6 +1259,175 @@ interface IBackendProvider {
1173
1259
  * @returns Promise<ListReposResponse> 仓库列表响应
1174
1260
  */
1175
1261
  getRepositories?(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
1262
+ /**
1263
+ * 保存待发送的输入内容到后端(用于跨域登录场景)
1264
+ * API 端点: POST /api/v1/code-id
1265
+ *
1266
+ * @param code 要保存的文本内容
1267
+ * @returns Promise<string | null> 返回 codeId,失败返回 null
1268
+ */
1269
+ savePendingInput?(code: string): Promise<string | null>;
1270
+ /**
1271
+ * 从后端加载待发送的输入内容(用于跨域登录场景)
1272
+ * API 端点: GET /api/v1/code?id=xxx
1273
+ *
1274
+ * @param codeId 内容 ID
1275
+ * @returns Promise<string | null> 返回保存的文本内容,失败返回 null
1276
+ */
1277
+ loadPendingInput?(codeId: string): Promise<string | null>;
1278
+ /**
1279
+ * 获取 SkillHub 技能列表(分页)
1280
+ * @param params 分页/过滤参数
1281
+ * @returns Promise<SkillHubListResponse>
1282
+ */
1283
+ getSkillHubList?(params?: SkillHubListParams): Promise<SkillHubListResponse>;
1284
+ /**
1285
+ * 获取 SkillHub 分类列表
1286
+ * @returns Promise<SkillHubCategoriesResponse>
1287
+ */
1288
+ getSkillHubCategories?(): Promise<SkillHubCategoriesResponse>;
1289
+ /**
1290
+ * 搜索 SkillHub 技能
1291
+ * @param q 搜索关键词
1292
+ * @param limit 结果数量限制
1293
+ * @returns Promise<SkillHubSearchResponse>
1294
+ */
1295
+ getSkillHubSearch?(q: string, limit?: number): Promise<SkillHubSearchResponse>;
1296
+ /**
1297
+ * 获取 SkillHub 技能详情
1298
+ * @param slug 技能唯一标识
1299
+ * @returns Promise<SkillHubDetailResponse>
1300
+ */
1301
+ getSkillHubDetail?(slug: string): Promise<SkillHubDetailResponse>;
1302
+ /**
1303
+ * 批量检查 SkillHub 技能是否存在
1304
+ * @param slugs 技能标识列表
1305
+ * @returns Promise<SkillHubExistsResponse>
1306
+ */
1307
+ getSkillHubExists?(slugs: string[]): Promise<SkillHubExistsResponse>;
1308
+ /**
1309
+ * 上报 SkillHub 技能统计
1310
+ * @param slug 技能标识
1311
+ * @param inc 增量统计
1312
+ */
1313
+ reportSkillHubStats?(slug: string, inc: {
1314
+ downloads?: number;
1315
+ installs?: number;
1316
+ stars?: number;
1317
+ }): Promise<void>;
1318
+ /**
1319
+ * 安装 SkillHub 技能(下载 zip → 解压到本地)
1320
+ * @param slug 技能标识
1321
+ * @param version 版本号
1322
+ * @param name 原始显示名称(保留大小写)
1323
+ * @returns Promise<SkillHubInstallResponse>
1324
+ */
1325
+ installSkillHubSkill?(slug: string, version?: string, name?: string): Promise<SkillHubInstallResponse>;
1326
+ /**
1327
+ * 获取本地已安装的 SkillHub 技能元信息
1328
+ * @returns Promise<SkillHubInstalledMeta[]>
1329
+ */
1330
+ getSkillHubInstalledMetas?(): Promise<SkillHubInstalledMeta[]>;
1331
+ }
1332
+ interface SkillHubSkill {
1333
+ slug: string;
1334
+ ownerName: string;
1335
+ category: string;
1336
+ name: string;
1337
+ description: string;
1338
+ description_zh: string;
1339
+ version: string;
1340
+ homepage: string;
1341
+ tags: string[];
1342
+ downloads: number;
1343
+ stars: number;
1344
+ installs: number;
1345
+ updated_at: number;
1346
+ score: number;
1347
+ /** Optional source marker used in merged search results */
1348
+ _source?: 'recommend' | 'skillhub';
1349
+ }
1350
+ interface SkillHubListResponse {
1351
+ code: number;
1352
+ message: string;
1353
+ data: {
1354
+ total: number;
1355
+ skills: SkillHubSkill[];
1356
+ };
1357
+ }
1358
+ interface SkillHubCategory {
1359
+ key: string;
1360
+ name: string;
1361
+ nameEn: string;
1362
+ sortOrder: number;
1363
+ active: boolean;
1364
+ }
1365
+ interface SkillHubCategoriesResponse {
1366
+ items: SkillHubCategory[];
1367
+ count: number;
1368
+ }
1369
+ interface SkillHubSearchResult {
1370
+ score: number;
1371
+ slug: string;
1372
+ displayName: string;
1373
+ summary: string;
1374
+ version: string;
1375
+ updatedAt: number;
1376
+ }
1377
+ interface SkillHubSearchResponse {
1378
+ results: SkillHubSearchResult[];
1379
+ }
1380
+ interface SkillHubDetailResponse {
1381
+ skill: {
1382
+ slug: string;
1383
+ category: string;
1384
+ displayName: string;
1385
+ summary: string;
1386
+ summary_zh: string;
1387
+ tags: Record<string, string>;
1388
+ stats: {
1389
+ downloads: number;
1390
+ stars: number;
1391
+ installs: number;
1392
+ versions: number;
1393
+ comments: number;
1394
+ };
1395
+ createdAt: number;
1396
+ updatedAt: number;
1397
+ };
1398
+ latestVersion: {
1399
+ version: string;
1400
+ createdAt: number;
1401
+ changelog: string;
1402
+ };
1403
+ owner: {
1404
+ handle: string;
1405
+ displayName: string;
1406
+ image: string | null;
1407
+ };
1408
+ }
1409
+ interface SkillHubExistsResponse {
1410
+ exists: Record<string, boolean>;
1411
+ count: number;
1412
+ }
1413
+ interface SkillHubInstallResponse {
1414
+ success: boolean;
1415
+ skillName: string;
1416
+ errorMessage?: string;
1417
+ }
1418
+ interface SkillHubInstalledMeta {
1419
+ slug: string;
1420
+ version: string | null;
1421
+ installedAt?: number;
1422
+ }
1423
+ type SkillHubSortBy = 'score' | 'downloads' | 'updated_at' | 'installs';
1424
+ interface SkillHubListParams {
1425
+ page?: number;
1426
+ pageSize?: number;
1427
+ sortBy?: SkillHubSortBy;
1428
+ order?: 'asc' | 'desc';
1429
+ keyword?: string;
1430
+ category?: string;
1176
1431
  }
1177
1432
  /**
1178
1433
  * 场景中的插件信息
@@ -1186,6 +1441,12 @@ interface ScenePlugin {
1186
1441
  /** 插件市场名称 */
1187
1442
  marketplaceName: string;
1188
1443
  }
1444
+ /**
1445
+ * 场景模式类型
1446
+ * - coding: 编程相关场景
1447
+ * - working: 工作/通用场景
1448
+ */
1449
+ type SupportSceneMode = 'coding' | 'working';
1189
1450
  /**
1190
1451
  * 支持的场景信息
1191
1452
  * 用于 Welcome 页面的 QuickActions 快捷操作
@@ -1200,11 +1461,15 @@ interface SupportScene {
1200
1461
  plugins: ScenePlugin[];
1201
1462
  /** 场景对应的 prompt 列表 */
1202
1463
  prompts: string[];
1464
+ /** 场景模式类型 */
1465
+ mode?: SupportSceneMode;
1203
1466
  }
1204
1467
  /**
1205
1468
  * 插件作用域
1469
+ * 使用 agent-craft 的 PluginInstallScope 类型
1470
+ * 注意: 当前后端 API 只支持 user 和 project,暂不支持 project-local
1206
1471
  */
1207
- type PluginScope = 'user' | 'project';
1472
+ type PluginScope = 'user' | 'project' | 'project-local' | 'local';
1208
1473
  /**
1209
1474
  * 插件操作类型
1210
1475
  */
@@ -1314,6 +1579,71 @@ interface AvailableCommand {
1314
1579
  }
1315
1580
  //#endregion
1316
1581
  //#region ../agent-provider/lib/common/types.d.ts
1582
+ /**
1583
+ * File type enumeration
1584
+ * Compatible with e2b SDK FileType
1585
+ */
1586
+ declare enum FileType {
1587
+ FILE = "file",
1588
+ DIR = "dir"
1589
+ }
1590
+ /**
1591
+ * Filesystem event type enumeration
1592
+ * Compatible with e2b SDK FilesystemEventType
1593
+ */
1594
+ declare enum FilesystemEventType {
1595
+ CHMOD = "chmod",
1596
+ CREATE = "create",
1597
+ REMOVE = "remove",
1598
+ RENAME = "rename",
1599
+ WRITE = "write"
1600
+ }
1601
+ /**
1602
+ * File or directory entry information
1603
+ * Compatible with e2b SDK EntryInfo
1604
+ */
1605
+ interface EntryInfo {
1606
+ name: string;
1607
+ type: FileType;
1608
+ path: string;
1609
+ size: number;
1610
+ mode: number;
1611
+ permissions: string;
1612
+ owner: string;
1613
+ group: string;
1614
+ modifiedTime?: Date;
1615
+ symlinkTarget?: string;
1616
+ }
1617
+ /**
1618
+ * Write operation result
1619
+ * Compatible with e2b SDK WriteInfo
1620
+ */
1621
+ interface WriteInfo {
1622
+ path: string;
1623
+ type: FileType;
1624
+ name: string;
1625
+ }
1626
+ /**
1627
+ * Filesystem watch event
1628
+ * Compatible with e2b SDK FilesystemEvent
1629
+ */
1630
+ interface FilesystemEvent {
1631
+ name: string;
1632
+ type: FilesystemEventType;
1633
+ }
1634
+ /**
1635
+ * Handle for stopping a directory watch
1636
+ * Compatible with e2b SDK WatchHandle
1637
+ */
1638
+ interface WatchHandle {
1639
+ stop(): Promise<void>;
1640
+ }
1641
+ /**
1642
+ * @deprecated Use the standalone type definitions above instead.
1643
+ * This type alias is kept for backward compatibility with code that
1644
+ * imported `Filesystem` type from this module.
1645
+ */
1646
+ type Filesystem = FilesResource;
1317
1647
  /**
1318
1648
  * Base options for filesystem operations
1319
1649
  * 对齐 e2b SDK FilesystemRequestOpts
@@ -1397,7 +1727,7 @@ interface FilesResource {
1397
1727
  /** Write multiple files in batch */
1398
1728
  write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
1399
1729
  /** List directory contents with optional depth */
1400
- list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
1730
+ list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo[]>;
1401
1731
  /** Check if path exists */
1402
1732
  exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
1403
1733
  /** Create directory */
@@ -1405,9 +1735,9 @@ interface FilesResource {
1405
1735
  /** Remove file or directory */
1406
1736
  remove(path: string, opts?: FilesystemRequestOpts): Promise<void>;
1407
1737
  /** Rename/move file or directory */
1408
- rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
1738
+ rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
1409
1739
  /** Get file or directory information */
1410
- getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
1740
+ getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
1411
1741
  /** Watch directory for changes */
1412
1742
  watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
1413
1743
  onExit?: (err?: Error) => void | Promise<void>;
@@ -1510,7 +1840,7 @@ type PromptContentBlock = {
1510
1840
  uri: string;
1511
1841
  mimeType?: string | null;
1512
1842
  name: string;
1513
- size?: bigint | null;
1843
+ size?: number | null;
1514
1844
  title?: string | null;
1515
1845
  _meta?: {
1516
1846
  [key: string]: unknown;
@@ -1616,13 +1946,22 @@ interface AgentConnection {
1616
1946
  * @param sessionId 会话 ID
1617
1947
  * @param toolCallId 工具调用 ID
1618
1948
  * @param toolName 工具名称
1619
- * @param action 操作类型 ('skip' | 'cancel')
1949
+ * @param action 操作类型 ('approve' | 'skip' | 'cancel')
1620
1950
  */
1621
- toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
1951
+ toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
1622
1952
  success: boolean;
1623
1953
  error?: string;
1624
1954
  }>;
1625
1955
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
1956
+ /**
1957
+ * Report telemetry event through the standard provider chain
1958
+ * - Local: via ACP JSON-RPC → IDE EventService
1959
+ * - Cloud: via StreamableHTTP → cloud telemetry endpoint
1960
+ *
1961
+ * @param eventName - Event name / code
1962
+ * @param payload - Event data (already includes mode)
1963
+ */
1964
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
1626
1965
  }
1627
1966
  /**
1628
1967
  * Base configuration for connections
@@ -1830,6 +2169,8 @@ interface BaseAgentState {
1830
2169
  updatedAt?: Date;
1831
2170
  /** 是否为 playground */
1832
2171
  isPlayground?: boolean;
2172
+ /** Whether the title is user defined (1 = user defined) */
2173
+ isUserDefinedTitle?: number;
1833
2174
  }
1834
2175
  /**
1835
2176
  * LocalAgentState - 本地 Agent 状态
@@ -1893,6 +2234,11 @@ interface ListAgentSort {
1893
2234
  * Local: Client-side filtering and sorting, no pagination (returns all)
1894
2235
  */
1895
2236
  interface ListAgentOptions {
2237
+ /**
2238
+ * User ID for filtering sessions (required for multi-user isolation)
2239
+ * If not provided, returns empty list for Local provider
2240
+ */
2241
+ userId?: string;
1896
2242
  /**
1897
2243
  * Page number (starts from 1)
1898
2244
  * Cloud: Used for API pagination
@@ -1970,22 +2316,46 @@ interface SessionInfo {
1970
2316
  status: AgentStatus;
1971
2317
  /** When the session/agent was created */
1972
2318
  createdAt?: Date;
2319
+ /** When the session/agent was last updated */
2320
+ updatedAt?: Date;
1973
2321
  /** Last activity timestamp */
1974
2322
  lastActivityAt?: Date;
1975
2323
  /** Working directory (for local agents) */
1976
2324
  cwd?: string;
1977
2325
  /** Whether the session is a playground */
1978
2326
  isPlayground?: boolean;
2327
+ /** Whether the title is user defined (1 = user defined) */
2328
+ isUserDefinedTitle?: number;
1979
2329
  }
1980
2330
  /**
1981
2331
  * Parameters for creating a new session
1982
2332
  */
1983
2333
  interface CreateSessionParams$1 {
1984
- /** Working directory */
2334
+ /** Working directory (required) */
1985
2335
  cwd: string;
2336
+ /** Optional configuration */
2337
+ options?: CreateSessionOptions;
2338
+ }
2339
+ /**
2340
+ * Optional configuration for creating a session
2341
+ */
2342
+ interface CreateSessionOptions {
1986
2343
  /** MCP server configurations */
1987
2344
  mcpServers?: McpServerConfig[];
2345
+ /** Initial prompt for the session (Cloud only) */
2346
+ prompt?: string;
2347
+ /** Initial model for the session (Cloud only) */
2348
+ model?: string;
2349
+ /** Mode ID (e.g., 'craft', 'architect') */
2350
+ mode?: string;
2351
+ /** Whether this is a playground session (no cwd) */
2352
+ isPlayground?: boolean;
2353
+ /** Tags for template scenes (Cloud only, format: { scene: 'xxx' }) */
2354
+ tags?: Record<string, string>;
2355
+ /** Additional metadata */
1988
2356
  _meta?: Record<string, unknown>;
2357
+ /** Callback when session is prepared (POST succeeded, before WebSocket connect) */
2358
+ onSessionPrepared?: (sessionInfo: SessionInfo) => void;
1989
2359
  }
1990
2360
  /**
1991
2361
  * Parameters for loading an existing session
@@ -2020,6 +2390,84 @@ interface InitializeWorkspaceResponse {
2020
2390
  /** Error message (if failed) */
2021
2391
  error?: string;
2022
2392
  }
2393
+ type AutomationStatus = 'ACTIVE' | 'PAUSED';
2394
+ type AutomationUpdateMode = 'view' | 'suggested create' | 'suggested update';
2395
+ type AutomationRunStatus = 'ACCEPTED' | 'ARCHIVED' | 'PENDING_REVIEW' | 'IN_PROGRESS';
2396
+ interface AutomationDefinition {
2397
+ version: number;
2398
+ id: string;
2399
+ name: string;
2400
+ prompt: string;
2401
+ status: AutomationStatus;
2402
+ rrule: string;
2403
+ cwds: string[];
2404
+ modelId?: string;
2405
+ modelIsThinking?: boolean;
2406
+ created_at: number;
2407
+ updated_at: number;
2408
+ }
2409
+ interface AutomationCwdRunResult {
2410
+ cwd: string;
2411
+ success: boolean;
2412
+ startedAt: number;
2413
+ finishedAt: number;
2414
+ conversationId?: string;
2415
+ output?: string;
2416
+ error?: string;
2417
+ }
2418
+ interface AutomationInboxItem {
2419
+ id: string;
2420
+ automationId: string;
2421
+ automationName: string;
2422
+ status?: AutomationRunStatus;
2423
+ readAt?: number;
2424
+ startedAt: number;
2425
+ finishedAt: number;
2426
+ success: boolean;
2427
+ summary: string;
2428
+ runs: AutomationCwdRunResult[];
2429
+ archived?: boolean;
2430
+ archivedAt?: number;
2431
+ }
2432
+ interface AutomationRuntimeState {
2433
+ lastRunAt?: number;
2434
+ lastError?: string;
2435
+ running?: boolean;
2436
+ runningStartedAt?: number;
2437
+ runningConversationId?: string;
2438
+ }
2439
+ interface AutomationSnapshot {
2440
+ automations: AutomationDefinition[];
2441
+ inbox: AutomationInboxItem[];
2442
+ runtimeState: Record<string, AutomationRuntimeState>;
2443
+ updatedAt: number;
2444
+ }
2445
+ interface AutomationUpdatePayload {
2446
+ mode: AutomationUpdateMode;
2447
+ id?: string;
2448
+ name?: string;
2449
+ prompt?: string;
2450
+ rrule?: string;
2451
+ cwds?: string[] | string;
2452
+ status?: AutomationStatus;
2453
+ modelId?: string;
2454
+ modelIsThinking?: boolean;
2455
+ }
2456
+ interface AutomationUpdateResult {
2457
+ success: boolean;
2458
+ message: string;
2459
+ automation?: AutomationDefinition;
2460
+ snapshot?: AutomationSnapshot;
2461
+ }
2462
+ /**
2463
+ * Parameters for getting available commands
2464
+ */
2465
+ interface GetAvailableCommandsParams {
2466
+ /** Session ID to get commands for (optional, for global commands) */
2467
+ sessionId?: string;
2468
+ /** Workspace path for getting custom commands (optional) */
2469
+ workspacePath?: string;
2470
+ }
2023
2471
  /**
2024
2472
  * Prompts resource interface (ACP verbs)
2025
2473
  * Operations use the current session automatically
@@ -2057,7 +2505,7 @@ interface ModelsResource {
2057
2505
  */
2058
2506
  interface PromptResponse {
2059
2507
  /** Stop reason */
2060
- stopReason: 'end_turn' | 'max_tokens' | 'tool_use' | 'cancelled' | 'error';
2508
+ stopReason: StopReason;
2061
2509
  /** Response metadata */
2062
2510
  _meta?: Record<string, unknown>;
2063
2511
  }
@@ -2067,7 +2515,7 @@ interface PromptResponse {
2067
2515
  interface SessionsResourceEvents {
2068
2516
  /** Emitted when the sessions list changes (create, delete, update) */
2069
2517
  sessionsChanged: SessionInfo[];
2070
- /** Emitted when a new session is created */
2518
+ /** Emitted when a new session is fully connected and ready */
2071
2519
  sessionCreated: SessionInfo;
2072
2520
  /** Emitted when a session is deleted */
2073
2521
  sessionDeleted: {
@@ -2075,6 +2523,17 @@ interface SessionsResourceEvents {
2075
2523
  };
2076
2524
  /** Emitted when a session is updated (status change, etc.) */
2077
2525
  sessionUpdated: SessionInfo;
2526
+ /** Emitted when automation snapshot is updated (pushed from server) */
2527
+ automationSnapshotUpdate: AutomationSnapshot;
2528
+ /** Emitted when plugins or marketplaces change (install/uninstall/add/remove/update) */
2529
+ pluginsChanged: {
2530
+ newMarketplaceName?: string;
2531
+ } | undefined;
2532
+ /** Emitted when ProductConfiguration changes (account switch, config sync, etc.) */
2533
+ productConfigChanged: {
2534
+ timestamp: number;
2535
+ productFeatures: Record<string, boolean>;
2536
+ };
2078
2537
  }
2079
2538
  /**
2080
2539
  * Event handler type for sessions resource events
@@ -2151,6 +2610,8 @@ interface ActiveSession {
2151
2610
  readonly id: string;
2152
2611
  /** Agent ID */
2153
2612
  readonly agentId: string;
2613
+ /** Actual workspace path (set after newSession, useful for Playground scenario) */
2614
+ readonly cwd?: string;
2154
2615
  /** Agent state (direct access to underlying agent state) */
2155
2616
  readonly agentState: AgentState;
2156
2617
  /** Agent capabilities (available after connection) */
@@ -2188,8 +2649,8 @@ interface ActiveSession {
2188
2649
  answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
2189
2650
  /** Cancel a question request */
2190
2651
  cancelQuestion(toolCallId: string, reason?: string): boolean;
2191
- /** Callback for tool operations (skip or cancel) */
2192
- toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
2652
+ /** Callback for tool operations (approve / skip / cancel) */
2653
+ toolCallback(toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
2193
2654
  success: boolean;
2194
2655
  error?: string;
2195
2656
  }>;
@@ -2211,6 +2672,12 @@ interface ActiveSession {
2211
2672
  once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
2212
2673
  /** Disconnect from the session/agent */
2213
2674
  disconnect(): void;
2675
+ /**
2676
+ * Detach the session from connection events without disconnecting the connection.
2677
+ * This should be called when the session is being replaced but the connection is shared.
2678
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
2679
+ */
2680
+ detach(): void;
2214
2681
  /** Symbol.dispose for 'using' keyword support */
2215
2682
  [Symbol.dispose](): void;
2216
2683
  }
@@ -2275,6 +2742,17 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2275
2742
  rename?(agentId: string, title: string): Promise<{
2276
2743
  id: string;
2277
2744
  }>;
2745
+ /**
2746
+ * Update agent status by ID (optional)
2747
+ * Used by CloudAgentProvider for updating session status
2748
+ *
2749
+ * @param agentId - Agent ID to update
2750
+ * @param status - New status for the agent
2751
+ * @returns Object containing the updated agent ID
2752
+ */
2753
+ updateStatus?(agentId: string, status: string): Promise<{
2754
+ id: string;
2755
+ }>;
2278
2756
  /**
2279
2757
  * Move an agent by ID (optional)
2280
2758
  * Used by LocalAgentProvider for moving Playground sessions to Workspace
@@ -2294,6 +2772,34 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2294
2772
  * @returns Array of model information
2295
2773
  */
2296
2774
  getModels?(repo?: string): Promise<ModelInfo[]>;
2775
+ /**
2776
+ * Get product configuration subset (optional)
2777
+ * Returns deploymentType, creditPurchaseActions, links, networkEnvironment, productFeatures
2778
+ */
2779
+ getProductConfiguration?(): Promise<{
2780
+ deploymentType?: string;
2781
+ creditPurchaseActions?: Record<string, {
2782
+ labelZh: string;
2783
+ labelEn: string;
2784
+ url: string;
2785
+ showButton?: boolean;
2786
+ }>;
2787
+ links?: {
2788
+ craftFeedback?: string;
2789
+ mcpMarketUrl?: string;
2790
+ mcpDocumentUrl?: string;
2791
+ helpDocument?: string;
2792
+ };
2793
+ networkEnvironment?: string;
2794
+ productFeatures?: Record<string, boolean>;
2795
+ }>;
2796
+ /**
2797
+ * Get user info (optional)
2798
+ * Returns enterpriseId from authentication session
2799
+ */
2800
+ getUserInfo?(): Promise<{
2801
+ enterpriseId?: string;
2802
+ }>;
2297
2803
  /**
2298
2804
  * Register sessionId → agentId mapping (optional, used by LocalAgentProvider)
2299
2805
  * Called after session creation to maintain the mapping for loadSession
@@ -2309,6 +2815,8 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2309
2815
  * @returns Response with success status
2310
2816
  */
2311
2817
  openWorkspace?(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
2818
+ /** Request yielding after current step for a running session (optional, used by LocalAgentProvider) */
2819
+ requestYieldAfterCurrentStep?(sessionId: string): Promise<boolean>;
2312
2820
  /**
2313
2821
  * Pick files from file dialog (optional, used by LocalAgentProvider)
2314
2822
  *
@@ -2344,6 +2852,61 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2344
2852
  * @returns Response with subagent list
2345
2853
  */
2346
2854
  getSubagentList?(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2855
+ /**
2856
+ * Get skill list (optional, used by LocalAgentProvider)
2857
+ *
2858
+ * @param params - Query parameters
2859
+ * @returns Response with skill list
2860
+ */
2861
+ getSkillList?(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2862
+ /**
2863
+ * Import a skill folder (optional, used by LocalAgentProvider)
2864
+ *
2865
+ * @param params - Import parameters including source location
2866
+ * @returns Response with import result
2867
+ */
2868
+ importSkill?(params: ImportSkillParams): Promise<ImportSkillResponse>;
2869
+ /**
2870
+ * Get skill content by file path (optional, used by LocalAgentProvider)
2871
+ *
2872
+ * @param params - Parameters including skill file path
2873
+ * @returns Response with skill content
2874
+ */
2875
+ getSkillContent?(params: GetSkillContentParams): Promise<GetSkillContentResponse>;
2876
+ /**
2877
+ * Get marketplace skills list (optional, used by LocalAgentProvider)
2878
+ *
2879
+ * @returns Response with marketplace skill list
2880
+ */
2881
+ getMarketplaceSkills?(): Promise<GetMarketplaceSkillsResponse>;
2882
+ /**
2883
+ * Get marketplace skill content (optional, used by LocalAgentProvider)
2884
+ *
2885
+ * @param params - Parameters including skill name
2886
+ * @returns Response with skill content
2887
+ */
2888
+ getMarketplaceSkillContent?(params: GetMarketplaceSkillContentParams): Promise<GetMarketplaceSkillContentResponse>;
2889
+ /**
2890
+ * Install marketplace skill to user directory (optional, used by LocalAgentProvider)
2891
+ *
2892
+ * @param params - Parameters including skill name
2893
+ * @returns Response with install result
2894
+ */
2895
+ installMarketplaceSkill?(params: InstallMarketplaceSkillParams): Promise<InstallMarketplaceSkillResponse>;
2896
+ /**
2897
+ * Toggle skill enable/disable state (optional, used by LocalAgentProvider)
2898
+ *
2899
+ * @param params - Toggle parameters including filePath and disable state
2900
+ * @returns Response with toggle result
2901
+ */
2902
+ toggleSkill?(params: ToggleSkillParams): Promise<ToggleSkillResponse>;
2903
+ /**
2904
+ * Delete a skill (optional, used by LocalAgentProvider)
2905
+ *
2906
+ * @param params - Delete parameters including filePath and name
2907
+ * @returns Response with delete result
2908
+ */
2909
+ deleteSkill?(params: DeleteSkillParams): Promise<DeleteSkillResponse>;
2347
2910
  /**
2348
2911
  * Batch toggle plugins (optional, used by LocalAgentProvider)
2349
2912
  *
@@ -2364,6 +2927,9 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2364
2927
  description?: string;
2365
2928
  version?: string;
2366
2929
  installScope?: 'user' | 'project';
2930
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
2931
+ installedScopesStatus?: Record<string, boolean>;
2932
+ installId?: string;
2367
2933
  }>>;
2368
2934
  /**
2369
2935
  * Install plugins (optional, used by LocalAgentProvider)
@@ -2374,7 +2940,7 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2374
2940
  * @param marketplaceSource - Marketplace source URL (for auto-adding marketplace when not exists)
2375
2941
  * @returns Result of the operation
2376
2942
  */
2377
- installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string): Promise<{
2943
+ installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2378
2944
  success: boolean;
2379
2945
  error?: string;
2380
2946
  }>;
@@ -2383,10 +2949,34 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2383
2949
  * If session.availableCommands has cached values, return them
2384
2950
  * Otherwise, fetch from product configuration
2385
2951
  *
2386
- * @param sessionId - Session ID to get commands for (optional, for global commands)
2952
+ * @param params - Parameters for getting commands
2387
2953
  * @returns Array of available commands
2388
2954
  */
2389
- getAvailableCommands?(sessionId?: string): Promise<AvailableCommand[]>;
2955
+ getAvailableCommands?(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2956
+ /**
2957
+ * Get automation snapshot (optional, used by LocalAgentProvider)
2958
+ */
2959
+ getAutomationSnapshot?(): Promise<AutomationSnapshot>;
2960
+ /**
2961
+ * Create/update automation definition (optional, used by LocalAgentProvider)
2962
+ */
2963
+ updateAutomation?(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
2964
+ /**
2965
+ * Delete automation definition (optional, used by LocalAgentProvider)
2966
+ */
2967
+ deleteAutomation?(id: string): Promise<AutomationUpdateResult>;
2968
+ /**
2969
+ * Archive an automation inbox item (optional, used by LocalAgentProvider)
2970
+ */
2971
+ archiveAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
2972
+ /**
2973
+ * Delete an automation inbox item (optional, used by LocalAgentProvider)
2974
+ */
2975
+ deleteAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
2976
+ /**
2977
+ * Trigger test run for automation (optional, used by LocalAgentProvider)
2978
+ */
2979
+ testAutomation?(id: string): Promise<AutomationUpdateResult>;
2390
2980
  /**
2391
2981
  * Register an event listener
2392
2982
  * Provider implementations should forward events to the underlying transport
@@ -2402,6 +2992,131 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2402
2992
  * @param handler - Event handler function to remove
2403
2993
  */
2404
2994
  off?(event: string, handler: (...args: any[]) => void): void;
2995
+ /**
2996
+ * Report telemetry event through the provider chain
2997
+ * - Local: via ACP JSON-RPC → AcpAgent → IDE EventService
2998
+ * - Cloud: via connection → cloud endpoint
2999
+ *
3000
+ * @param eventName - Event name / code
3001
+ * @param payload - Event data
3002
+ */
3003
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
3004
+ /**
3005
+ * Respond to MCP Sampling confirmation request (optional, used by LocalAgentProvider)
3006
+ * Called when user confirms/rejects a sampling request
3007
+ *
3008
+ * @param sessionId - Session ID
3009
+ * @param response - Sampling confirmation response
3010
+ */
3011
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
3012
+ /**
3013
+ * Respond to MCP Roots confirmation request (optional, used by LocalAgentProvider)
3014
+ * Called when user confirms/rejects a roots request
3015
+ *
3016
+ * @param sessionId - Session ID
3017
+ * @param response - Roots confirmation response
3018
+ */
3019
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
3020
+ /**
3021
+ * Subscribe to MCP Sampling confirmation requests (optional, used by LocalAgentProvider)
3022
+ * Called when MCP server initiates a sampling request
3023
+ *
3024
+ * @param serverName - MCP server name
3025
+ * @param callback - Request callback
3026
+ * @returns Unsubscribe function
3027
+ */
3028
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
3029
+ /**
3030
+ * Subscribe to MCP Roots confirmation requests (optional, used by LocalAgentProvider)
3031
+ * Called when MCP server initiates a roots request
3032
+ *
3033
+ * @param serverName - MCP server name
3034
+ * @param callback - Request callback
3035
+ * @returns Unsubscribe function
3036
+ */
3037
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
3038
+ /**
3039
+ * Get product scenes from ProductManager configuration (optional, for LocalAgentProvider)
3040
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
3041
+ * @param locale - 可选,语言环境
3042
+ */
3043
+ getProductScenes?(locale?: string): Promise<Array<{
3044
+ id: number;
3045
+ name: string;
3046
+ plugins: Array<{
3047
+ id: number;
3048
+ name: string;
3049
+ marketplaceName: string;
3050
+ }>;
3051
+ prompts: string[];
3052
+ mode?: 'coding' | 'working';
3053
+ target?: 'local' | 'cloud' | 'all';
3054
+ }>>;
3055
+ /**
3056
+ * Get all MCP servers with their status and tools (optional, used by LocalAgentProvider)
3057
+ * Returns the list of configured MCP servers from McpServerManager
3058
+ *
3059
+ * @returns Array of MCP server information
3060
+ */
3061
+ getMcpServers?(): Promise<Array<{
3062
+ id: string;
3063
+ name: string;
3064
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
3065
+ description?: string;
3066
+ tools?: Array<{
3067
+ name: string;
3068
+ description?: string;
3069
+ enabled?: boolean;
3070
+ }>;
3071
+ disabled?: boolean;
3072
+ error?: string;
3073
+ logoUrl?: string;
3074
+ officialUrl?: string;
3075
+ configSource?: 'user' | 'project' | 'plugin';
3076
+ }>>;
3077
+ /**
3078
+ * Toggle MCP server enabled/disabled state (optional, used by LocalAgentProvider)
3079
+ *
3080
+ * @param serverName - Name of the MCP server to toggle
3081
+ * @param enabled - Whether to enable (true) or disable (false) the server
3082
+ */
3083
+ toggleMcpServer?(serverName: string, enabled: boolean): Promise<void>;
3084
+ /**
3085
+ * Reconnect to an MCP server (optional, used by LocalAgentProvider)
3086
+ *
3087
+ * @param serverName - Name of the MCP server to reconnect
3088
+ * @param forceHttpCallback - Force using HTTP callback instead of URL scheme
3089
+ */
3090
+ reconnectMcpServer?(serverName: string, forceHttpCallback?: boolean): Promise<void>;
3091
+ /**
3092
+ * Delete an MCP server configuration (optional, used by LocalAgentProvider)
3093
+ *
3094
+ * @param serverName - Name of the MCP server to delete
3095
+ */
3096
+ deleteMcpServer?(serverName: string): Promise<void>;
3097
+ /**
3098
+ * Open the MCP configuration file in editor (optional, used by LocalAgentProvider)
3099
+ * Executes 'codebuddy.openMcpConfig' command
3100
+ */
3101
+ openMcpConfig?(): Promise<void>;
3102
+ /**
3103
+ * Get MCP configuration file content
3104
+ * @returns File path and content
3105
+ */
3106
+ getMcpConfigContent?(): Promise<{
3107
+ filePath: string;
3108
+ content: string;
3109
+ }>;
3110
+ /**
3111
+ * Save MCP configuration file content
3112
+ * @param content New configuration content
3113
+ */
3114
+ saveMcpConfigContent?(content: string): Promise<void>;
3115
+ /**
3116
+ * Read text from clipboard (optional, used by LocalAgentProvider for webview clipboard access)
3117
+ * @returns Clipboard text content
3118
+ */
3119
+ clipboardReadText?(): Promise<string>;
2405
3120
  }
2406
3121
  /**
2407
3122
  * AgentClient initialization options
@@ -2459,6 +3174,15 @@ interface ClientSessionsResource {
2459
3174
  rename(sessionId: string, title: string): Promise<{
2460
3175
  id: string;
2461
3176
  }>;
3177
+ /**
3178
+ * Update session status
3179
+ * @param sessionId - Session ID to update
3180
+ * @param status - New status for the session
3181
+ * @returns Object containing the updated session ID
3182
+ */
3183
+ updateStatus(sessionId: string, status: string): Promise<{
3184
+ id: string;
3185
+ }>;
2462
3186
  /**
2463
3187
  * Move a session (Playground → Workspace)
2464
3188
  * @param sessionId - Session ID to move
@@ -2469,6 +3193,8 @@ interface ClientSessionsResource {
2469
3193
  }>;
2470
3194
  /** Initialize a workspace for future sessions */
2471
3195
  initializeWorkspace(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
3196
+ /** Request yielding after current step for a running session */
3197
+ requestYieldAfterCurrentStep(sessionId: string): Promise<boolean>;
2472
3198
  /** Models resource for getting available models */
2473
3199
  readonly models: ModelsResource;
2474
3200
  /** Get current workspaces list */
@@ -2491,6 +3217,22 @@ interface ClientSessionsResource {
2491
3217
  searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
2492
3218
  /** Get subagent list (for LocalAgentProvider) */
2493
3219
  getSubagentList(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
3220
+ /** Get skill list (for LocalAgentProvider) */
3221
+ getSkillList(params?: GetSkillListParams): Promise<GetSkillListResponse>;
3222
+ /** Import a skill folder (for LocalAgentProvider) */
3223
+ importSkill(params: ImportSkillParams): Promise<ImportSkillResponse>;
3224
+ /** Toggle skill enable/disable state (for LocalAgentProvider) */
3225
+ toggleSkill(params: ToggleSkillParams): Promise<ToggleSkillResponse>;
3226
+ /** Delete a skill (for LocalAgentProvider) */
3227
+ deleteSkill(params: DeleteSkillParams): Promise<DeleteSkillResponse>;
3228
+ /** Get skill content by file path (for LocalAgentProvider) */
3229
+ getSkillContent(params: GetSkillContentParams): Promise<GetSkillContentResponse>;
3230
+ /** Get marketplace skills list (for LocalAgentProvider) */
3231
+ getMarketplaceSkills(): Promise<GetMarketplaceSkillsResponse>;
3232
+ /** Get marketplace skill content (for LocalAgentProvider) */
3233
+ getMarketplaceSkillContent(params: GetMarketplaceSkillContentParams): Promise<GetMarketplaceSkillContentResponse>;
3234
+ /** Install marketplace skill to user directory (for LocalAgentProvider) */
3235
+ installMarketplaceSkill(params: InstallMarketplaceSkillParams): Promise<InstallMarketplaceSkillResponse>;
2494
3236
  /** Batch toggle plugins (for LocalAgentProvider) */
2495
3237
  batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2496
3238
  /** Get installed plugins (for LocalAgentProvider) */
@@ -2501,34 +3243,388 @@ interface ClientSessionsResource {
2501
3243
  description?: string;
2502
3244
  version?: string;
2503
3245
  installScope?: 'user' | 'project';
3246
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
3247
+ installedScopesStatus?: Record<string, boolean>;
3248
+ installId?: string;
2504
3249
  }>>;
2505
3250
  /** Install plugins (for LocalAgentProvider) */
2506
- installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string): Promise<{
3251
+ installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2507
3252
  success: boolean;
2508
3253
  error?: string;
2509
3254
  }>;
2510
- /**
2511
- * Get support scenes from backend API (for LocalAgentProvider)
2512
- * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
2513
- */
2514
- getSupportScenes(): Promise<Array<{
2515
- id: number;
3255
+ /** Uninstall a plugin (for LocalAgentProvider) */
3256
+ uninstallPlugin?(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
3257
+ success: boolean;
3258
+ error?: string;
3259
+ }>;
3260
+ /** Update a plugin to the latest version (for LocalAgentProvider) */
3261
+ updatePlugin?(pluginName: string, marketplaceName: string): Promise<{
3262
+ success: boolean;
3263
+ error?: string;
3264
+ }>;
3265
+ /** Get plugin marketplaces list (for LocalAgentProvider) */
3266
+ getPluginMarketplaces?(forceRefresh?: boolean): Promise<Array<{
3267
+ id: string;
2516
3268
  name: string;
2517
- plugins: Array<{
2518
- id: number;
2519
- name: string;
2520
- marketplaceName: string;
3269
+ type: 'github' | 'local' | 'custom';
3270
+ source: {
3271
+ repo?: string;
3272
+ ref?: string;
3273
+ url?: string;
3274
+ };
3275
+ description?: string;
3276
+ isBuiltin?: boolean;
3277
+ }>>;
3278
+ /** Get plugins from a marketplace (for LocalAgentProvider) */
3279
+ getMarketplacePlugins?(marketplaceName: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
3280
+ name: string;
3281
+ marketplaceName: string;
3282
+ description?: string;
3283
+ version?: string;
3284
+ author?: string;
3285
+ homepage?: string;
3286
+ iconUrl?: string;
3287
+ tags?: string[];
3288
+ installed?: boolean;
3289
+ status?: 'enabled' | 'disabled' | 'not-installed';
3290
+ installedScopes?: Array<'user' | 'project'>;
3291
+ hasUpdate?: boolean;
3292
+ }>>;
3293
+ /** Get plugin detail (for LocalAgentProvider) */
3294
+ getPluginDetail?(pluginName: string, marketplaceName: string): Promise<{
3295
+ name: string;
3296
+ marketplaceName: string;
3297
+ description?: string;
3298
+ version?: string;
3299
+ author?: string;
3300
+ homepage?: string;
3301
+ readme?: string;
3302
+ tools?: Array<{
3303
+ name: string;
3304
+ description?: string;
3305
+ }>;
3306
+ resources?: Array<{
3307
+ name: string;
3308
+ description?: string;
3309
+ }>;
3310
+ prompts?: Array<{
3311
+ name: string;
3312
+ description?: string;
3313
+ }>;
3314
+ installed?: boolean;
3315
+ status?: 'enabled' | 'disabled' | 'not-installed';
3316
+ } | null>;
3317
+ /** Add a plugin marketplace (for LocalAgentProvider) */
3318
+ addPluginMarketplace?(source: string, name?: string): Promise<{
3319
+ success: boolean;
3320
+ error?: string;
3321
+ marketplace?: {
3322
+ id: string;
3323
+ name: string;
3324
+ type: 'github' | 'local' | 'custom';
3325
+ source: {
3326
+ repo?: string;
3327
+ ref?: string;
3328
+ url?: string;
3329
+ };
3330
+ description?: string;
3331
+ isBuiltin?: boolean;
3332
+ };
3333
+ }>;
3334
+ /** Remove a plugin marketplace (for LocalAgentProvider) */
3335
+ removePluginMarketplace?(marketplaceName: string): Promise<{
3336
+ success: boolean;
3337
+ error?: string;
3338
+ }>;
3339
+ /** Refresh a plugin marketplace (for LocalAgentProvider) */
3340
+ refreshPluginMarketplace?(marketplaceName: string): Promise<{
3341
+ success: boolean;
3342
+ error?: string;
3343
+ plugins?: Array<{
3344
+ name: string;
3345
+ marketplaceName: string;
3346
+ description?: string;
3347
+ version?: string;
3348
+ installed?: boolean;
3349
+ status?: 'enabled' | 'disabled' | 'not-installed';
3350
+ }>;
3351
+ }>;
3352
+ /** Open folder in new window (for LocalAgentProvider) */
3353
+ openFolderInNewWindow?(folderPath: string): Promise<void>;
3354
+ /** Open folder in system file manager (for LocalAgentProvider) */
3355
+ openFolder?(folderPath: string): Promise<boolean>;
3356
+ /**
3357
+ * Get support scenes from backend API (for LocalAgentProvider)
3358
+ * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
3359
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
3360
+ */
3361
+ getSupportScenes(locale?: string): Promise<Array<{
3362
+ id: number;
3363
+ name: string;
3364
+ plugins: Array<{
3365
+ id: number;
3366
+ name: string;
3367
+ marketplaceName: string;
2521
3368
  }>;
2522
3369
  prompts: string[];
3370
+ mode?: 'coding' | 'working';
3371
+ }>>;
3372
+ /**
3373
+ * Get product scenes from ProductManager configuration (for LocalAgentProvider)
3374
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
3375
+ * @param locale - 可选,语言环境
3376
+ */
3377
+ getProductScenes?(locale?: string): Promise<Array<{
3378
+ id: number;
3379
+ name: string;
3380
+ plugins: Array<{
3381
+ id: number;
3382
+ name: string;
3383
+ marketplaceName: string;
3384
+ }>;
3385
+ prompts: string[];
3386
+ mode?: 'coding' | 'working';
3387
+ target?: 'local' | 'cloud' | 'all';
2523
3388
  }>>;
2524
3389
  /**
2525
3390
  * Get available commands for a session
2526
3391
  * If session.availableCommands has cached values, return them
2527
3392
  * Otherwise, fetch from provider (for LocalAgentProvider)
2528
- * @param sessionId - Session ID to get commands for (optional, for global commands)
3393
+ * @param params - Parameters for getting commands
2529
3394
  * @returns Promise<AvailableCommand[]> - Array of available commands
2530
3395
  */
2531
- getAvailableCommands(sessionId?: string): Promise<AvailableCommand[]>;
3396
+ getAvailableCommands(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
3397
+ /**
3398
+ * Get automation snapshot
3399
+ */
3400
+ getAutomationSnapshot(): Promise<AutomationSnapshot>;
3401
+ /**
3402
+ * Create/update automation definition
3403
+ */
3404
+ updateAutomation(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
3405
+ /**
3406
+ * Delete automation definition
3407
+ */
3408
+ deleteAutomation(id: string): Promise<AutomationUpdateResult>;
3409
+ /**
3410
+ * Archive automation inbox item
3411
+ */
3412
+ archiveAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
3413
+ /**
3414
+ * Delete automation inbox item
3415
+ */
3416
+ deleteAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
3417
+ /**
3418
+ * Trigger automation test run
3419
+ */
3420
+ testAutomation(id: string): Promise<AutomationUpdateResult>;
3421
+ /**
3422
+ * Report telemetry event through the provider chain
3423
+ * Delegates to AgentProvider.reportTelemetry()
3424
+ *
3425
+ * @param eventName - Event name / code
3426
+ * @param payload - Event data
3427
+ */
3428
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
3429
+ /**
3430
+ * Get product configuration subset
3431
+ * Returns deploymentType, creditPurchaseActions, links, productFeatures
3432
+ * Used by agent-ui for error banner credit purchase guidance
3433
+ */
3434
+ getProductConfiguration?(): Promise<{
3435
+ deploymentType?: string;
3436
+ creditPurchaseActions?: Record<string, {
3437
+ labelZh: string;
3438
+ labelEn: string;
3439
+ url: string;
3440
+ showButton?: boolean;
3441
+ }>;
3442
+ links?: {
3443
+ craftFeedback?: string;
3444
+ mcpMarketUrl?: string;
3445
+ mcpDocumentUrl?: string;
3446
+ helpDocument?: string;
3447
+ };
3448
+ networkEnvironment?: string;
3449
+ productFeatures?: Record<string, boolean>;
3450
+ }>;
3451
+ /**
3452
+ * Get user info
3453
+ * Returns enterpriseId from authentication session
3454
+ * Used by agent-ui for determining personal/enterprise user
3455
+ */
3456
+ getUserInfo?(): Promise<{
3457
+ enterpriseId?: string;
3458
+ }>;
3459
+ /**
3460
+ * Respond to MCP Sampling confirmation request
3461
+ * Called when user confirms/rejects a sampling request in MCP tool renderer
3462
+ *
3463
+ * @param sessionId - Session ID
3464
+ * @param response - Sampling confirmation response
3465
+ */
3466
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
3467
+ /**
3468
+ * Respond to MCP Roots confirmation request
3469
+ * Called when user confirms/rejects a roots request in MCP tool renderer
3470
+ *
3471
+ * @param sessionId - Session ID
3472
+ * @param response - Roots confirmation response
3473
+ */
3474
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
3475
+ /**
3476
+ * Subscribe to MCP Sampling confirmation requests
3477
+ * Called when MCP server initiates a sampling request
3478
+ *
3479
+ * @param serverName - MCP server name
3480
+ * @param callback - Request callback
3481
+ * @returns Unsubscribe function
3482
+ */
3483
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
3484
+ /**
3485
+ * Subscribe to MCP Roots confirmation requests
3486
+ * Called when MCP server initiates a roots request
3487
+ *
3488
+ * @param serverName - MCP server name
3489
+ * @param callback - Request callback
3490
+ * @returns Unsubscribe function
3491
+ */
3492
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
3493
+ /**
3494
+ * Get MCP servers list
3495
+ * Returns the list of configured MCP servers with their status
3496
+ *
3497
+ * @returns Promise<McpServerInfo[]> - Array of MCP server info
3498
+ */
3499
+ getMcpServers?(): Promise<McpServerInfo[]>;
3500
+ /**
3501
+ * Toggle MCP server enabled/disabled state
3502
+ *
3503
+ * @param serverName - Server name
3504
+ * @param enabled - Whether to enable the server
3505
+ */
3506
+ toggleMcpServer?(serverName: string, enabled: boolean): Promise<void>;
3507
+ /**
3508
+ * Reconnect to an MCP server
3509
+ *
3510
+ * @param serverName - Server name
3511
+ * @param forceHttpCallback - Force using HTTP callback instead of URL scheme
3512
+ */
3513
+ reconnectMcpServer?(serverName: string, forceHttpCallback?: boolean): Promise<void>;
3514
+ /**
3515
+ * Delete an MCP server configuration
3516
+ *
3517
+ * @param serverName - Server name
3518
+ */
3519
+ deleteMcpServer?(serverName: string): Promise<void>;
3520
+ /**
3521
+ * Open MCP configuration file in editor
3522
+ */
3523
+ openMcpConfig?(): Promise<void>;
3524
+ /**
3525
+ * Get MCP configuration file content
3526
+ * @returns File path and content
3527
+ */
3528
+ getMcpConfigContent?(): Promise<{
3529
+ filePath: string;
3530
+ content: string;
3531
+ }>;
3532
+ /**
3533
+ * Save MCP configuration file content
3534
+ * @param content New configuration content
3535
+ */
3536
+ saveMcpConfigContent?(content: string): Promise<void>;
3537
+ /**
3538
+ * Read text from clipboard (optional, used by LocalAgentProvider for webview clipboard access)
3539
+ * @returns Clipboard text content
3540
+ */
3541
+ clipboardReadText?(): Promise<string>;
3542
+ }
3543
+ /**
3544
+ * MCP Sampling message role
3545
+ */
3546
+ type McpSamplingRole = 'user' | 'assistant';
3547
+ /**
3548
+ * MCP Sampling message content - text
3549
+ */
3550
+ interface McpSamplingTextContent {
3551
+ type: 'text';
3552
+ text: string;
3553
+ }
3554
+ /**
3555
+ * MCP Sampling message content - image
3556
+ */
3557
+ interface McpSamplingImageContent {
3558
+ type: 'image';
3559
+ data: string;
3560
+ mimeType: string;
3561
+ }
3562
+ /**
3563
+ * MCP Sampling message content - audio
3564
+ */
3565
+ interface McpSamplingAudioContent {
3566
+ type: 'audio';
3567
+ data: string;
3568
+ mimeType: string;
3569
+ }
3570
+ /**
3571
+ * MCP Sampling message content union type
3572
+ */
3573
+ type McpSamplingContent = McpSamplingTextContent | McpSamplingImageContent | McpSamplingAudioContent;
3574
+ /**
3575
+ * MCP Sampling message
3576
+ */
3577
+ interface McpSamplingMessage {
3578
+ role: McpSamplingRole;
3579
+ content: McpSamplingContent;
3580
+ }
3581
+ /**
3582
+ * MCP Sampling confirmation request
3583
+ * Sent from backend when MCP server requests sampling
3584
+ */
3585
+ interface McpSamplingConfirmRequest {
3586
+ id: string;
3587
+ serverName: string;
3588
+ model?: string;
3589
+ messages: McpSamplingMessage[];
3590
+ systemPrompt?: string;
3591
+ maxTokens: number;
3592
+ timestamp: number;
3593
+ }
3594
+ /**
3595
+ * MCP Sampling confirmation response
3596
+ * Sent from frontend when user confirms/rejects
3597
+ */
3598
+ interface McpSamplingConfirmResponse {
3599
+ id: string;
3600
+ approved: boolean;
3601
+ rememberChoice?: boolean;
3602
+ }
3603
+ /**
3604
+ * MCP Root definition
3605
+ */
3606
+ interface McpRoot {
3607
+ uri: string;
3608
+ name?: string;
3609
+ }
3610
+ /**
3611
+ * MCP Roots confirmation request
3612
+ * Sent from backend when MCP server requests roots access
3613
+ */
3614
+ interface McpRootsConfirmRequest {
3615
+ id: string;
3616
+ serverName: string;
3617
+ roots: McpRoot[];
3618
+ timestamp: number;
3619
+ }
3620
+ /**
3621
+ * MCP Roots confirmation response
3622
+ * Sent from frontend when user confirms/rejects
3623
+ */
3624
+ interface McpRootsConfirmResponse {
3625
+ id: string;
3626
+ approved: boolean;
3627
+ rememberChoice?: boolean;
2532
3628
  }
2533
3629
  /**
2534
3630
  * Workspace information (aligned with FolderSelectResult)
@@ -2594,6 +3690,8 @@ interface PickFolderResponse {
2594
3690
  interface UploadFileParams {
2595
3691
  /** Files to upload - File objects in browser, absolute path strings in IDE */
2596
3692
  readonly files: Array<File | string>;
3693
+ /** Optional AbortSignal to cancel the upload */
3694
+ readonly abortSignal?: AbortSignal;
2597
3695
  }
2598
3696
  /**
2599
3697
  * Response from uploading files
@@ -2607,6 +3705,8 @@ interface UploadFileResponse {
2607
3705
  readonly expireSeconds?: number;
2608
3706
  /** Error message (if upload failed) */
2609
3707
  readonly error?: string;
3708
+ /** Whether the upload was cancelled by user */
3709
+ readonly aborted?: boolean;
2610
3710
  }
2611
3711
  /**
2612
3712
  * Mention type for file/folder
@@ -2703,6 +3803,233 @@ interface GetSubagentListResponse {
2703
3803
  /** Error message (if failed) */
2704
3804
  readonly error?: string;
2705
3805
  }
3806
+ /**
3807
+ * Skill info returned from getSkillList
3808
+ */
3809
+ interface SkillInfo {
3810
+ /** Skill name */
3811
+ name: string;
3812
+ /** File path of the skill */
3813
+ filePath: string;
3814
+ /** Description of the skill */
3815
+ description: string;
3816
+ /** Chinese description of the skill */
3817
+ description_zh?: string;
3818
+ /** English description of the skill */
3819
+ description_en?: string;
3820
+ /** When to use the skill */
3821
+ whenToUse?: string;
3822
+ /** Source of the skill */
3823
+ source: 'localSettings' | 'userSettings' | 'plugin' | 'builtin';
3824
+ /** Skill type */
3825
+ type: 'prompt';
3826
+ /** License information */
3827
+ license?: string;
3828
+ /** Allowed tools */
3829
+ allowedTools?: string[];
3830
+ /** Whether the skill is disabled */
3831
+ disable?: boolean;
3832
+ }
3833
+ /**
3834
+ * Parameters for getting skill list
3835
+ */
3836
+ interface GetSkillListParams {
3837
+ /** Working directory (optional, for filtering project-level skills) */
3838
+ readonly cwd?: string;
3839
+ /** Whether to use global (backend) channel, defaults to true. When false, uses sendBroadcastRequest. */
3840
+ readonly global?: boolean;
3841
+ /** Whether to exclude plugin skills from the result, defaults to false. */
3842
+ readonly excludePluginSkills?: boolean;
3843
+ /**
3844
+ * 用户级 skill 扫描目录名称列表(相对于 home 目录),按优先级从高到低排列。
3845
+ * 同名 skill 以高优先级目录为准。
3846
+ * 未传入或为空时使用产品默认目录。
3847
+ */
3848
+ readonly skillScanDirs?: string[];
3849
+ }
3850
+ /**
3851
+ * Response from getting skill list
3852
+ */
3853
+ interface GetSkillListResponse {
3854
+ /** Skill list */
3855
+ readonly results: SkillInfo[];
3856
+ /** Error message (if failed) */
3857
+ readonly error?: string;
3858
+ }
3859
+ /**
3860
+ * Parameters for importing a skill folder
3861
+ */
3862
+ interface ImportSkillParams {
3863
+ /** Source location: project-level or user-level */
3864
+ readonly source: 'localSettings' | 'userSettings';
3865
+ /** Working directory (required when source is localSettings). */
3866
+ readonly cwd?: string;
3867
+ /** 直接传入文件夹路径(拖拽导入时使用),有此字段时跳过系统文件选择器 */
3868
+ readonly folderPath?: string;
3869
+ }
3870
+ /**
3871
+ * Response from importing a skill folder
3872
+ */
3873
+ interface ImportSkillResponse {
3874
+ /** Whether the import was successful */
3875
+ readonly success: boolean;
3876
+ /** Error message (if failed) */
3877
+ readonly error?: string;
3878
+ /** Imported skill name */
3879
+ readonly skillName?: string;
3880
+ }
3881
+ /**
3882
+ * Parameters for toggling skill enable/disable state
3883
+ */
3884
+ interface ToggleSkillParams {
3885
+ /** File path of the skill to toggle */
3886
+ readonly filePath: string;
3887
+ /** Whether to disable the skill */
3888
+ readonly disable: boolean;
3889
+ }
3890
+ /**
3891
+ * Response from toggling skill state
3892
+ */
3893
+ interface ToggleSkillResponse {
3894
+ /** Whether the toggle was successful */
3895
+ readonly success: boolean;
3896
+ /** Error message (if failed) */
3897
+ readonly error?: string;
3898
+ }
3899
+ /**
3900
+ * Parameters for deleting a skill
3901
+ */
3902
+ interface DeleteSkillParams {
3903
+ /** File path of the skill to delete */
3904
+ readonly filePath: string;
3905
+ /** Name of the skill */
3906
+ readonly name: string;
3907
+ }
3908
+ /**
3909
+ * Response from deleting a skill
3910
+ */
3911
+ interface DeleteSkillResponse {
3912
+ /** Whether the deletion was successful */
3913
+ readonly success: boolean;
3914
+ /** Error message (if failed) */
3915
+ readonly error?: string;
3916
+ }
3917
+ /**
3918
+ * Parameters for getting skill content
3919
+ */
3920
+ interface GetSkillContentParams {
3921
+ /** File path of the skill */
3922
+ readonly filePath: string;
3923
+ }
3924
+ /**
3925
+ * Response from getting skill content
3926
+ */
3927
+ interface GetSkillContentResponse {
3928
+ /** Skill file content */
3929
+ readonly content: string;
3930
+ /** Error message (if failed) */
3931
+ readonly error?: string;
3932
+ }
3933
+ /**
3934
+ * Marketplace skill info (simplified structure for UI layer)
3935
+ */
3936
+ interface MarketplaceSkillInfo {
3937
+ /** Skill name */
3938
+ name: string;
3939
+ /** Skill description */
3940
+ description: string;
3941
+ /** Skill description in Chinese */
3942
+ description_zh?: string;
3943
+ /** Skill description in English */
3944
+ description_en?: string;
3945
+ /** Skill version */
3946
+ version?: string;
3947
+ /** Skill author */
3948
+ author?: string;
3949
+ /** Skill icon URL */
3950
+ iconUrl?: string;
3951
+ /** Skill tags */
3952
+ tags?: string[];
3953
+ }
3954
+ /**
3955
+ * Response from getting marketplace skills
3956
+ */
3957
+ interface GetMarketplaceSkillsResponse {
3958
+ /** Marketplace skill list */
3959
+ readonly results: MarketplaceSkillInfo[];
3960
+ /** Error message (if failed) */
3961
+ readonly error?: string;
3962
+ }
3963
+ /**
3964
+ * Parameters for getting marketplace skill content
3965
+ */
3966
+ interface GetMarketplaceSkillContentParams {
3967
+ /** Skill name */
3968
+ readonly skillName: string;
3969
+ }
3970
+ /**
3971
+ * Response from getting marketplace skill content
3972
+ */
3973
+ interface GetMarketplaceSkillContentResponse {
3974
+ /** Skill file content */
3975
+ readonly content: string;
3976
+ /** Error message (if failed) */
3977
+ readonly error?: string;
3978
+ }
3979
+ /**
3980
+ * Parameters for installing marketplace skill
3981
+ */
3982
+ interface InstallMarketplaceSkillParams {
3983
+ /** Skill name to install */
3984
+ readonly skillName: string;
3985
+ }
3986
+ /**
3987
+ * Response from installing marketplace skill
3988
+ */
3989
+ interface InstallMarketplaceSkillResponse {
3990
+ /** Whether the install was successful */
3991
+ readonly success: boolean;
3992
+ /** Skill name */
3993
+ readonly skillName: string;
3994
+ /** Error message (if failed) */
3995
+ readonly errorMessage?: string;
3996
+ }
3997
+ /**
3998
+ * MCP Tool information
3999
+ */
4000
+ interface McpToolInfo {
4001
+ /** Tool name */
4002
+ name: string;
4003
+ /** Tool description */
4004
+ description?: string;
4005
+ /** Whether the tool is enabled */
4006
+ enabled?: boolean;
4007
+ }
4008
+ /**
4009
+ * MCP Server information
4010
+ */
4011
+ interface McpServerInfo {
4012
+ /** Server ID */
4013
+ id: string;
4014
+ /** Server name */
4015
+ name: string;
4016
+ /** Connection status */
4017
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
4018
+ /** Server description */
4019
+ description?: string;
4020
+ /** Available tools */
4021
+ tools?: McpToolInfo[];
4022
+ /** Whether the server is disabled */
4023
+ disabled?: boolean;
4024
+ /** Error message (if connection failed) */
4025
+ error?: string;
4026
+ /** Logo URL */
4027
+ logoUrl?: string;
4028
+ /** Official website URL */
4029
+ officialUrl?: string;
4030
+ /** Configuration source */
4031
+ configSource?: 'user' | 'project' | 'plugin';
4032
+ }
2706
4033
  //#endregion
2707
4034
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
2708
4035
  /**
@@ -2734,6 +4061,17 @@ declare class CloudAgentConnection implements AgentConnection {
2734
4061
  readonly transport: "cloud";
2735
4062
  readonly cwd: string;
2736
4063
  constructor(agentId: string, config: CloudConnectionConfig, cwd?: string);
4064
+ /**
4065
+ * Check whether a notification belongs to this connection's own session.
4066
+ *
4067
+ * CloudConnection.createSession() overrides sessionId to agentId, so the
4068
+ * rest of the client stack uses agentId as the canonical session
4069
+ * identifier. Notifications whose sessionId differs from agentId
4070
+ * originate from sub-agent sessions running inside the same sandbox and
4071
+ * should be silently ignored at this layer — the adapter layer handles
4072
+ * sub-agent messages independently via parentToolUseId in _meta.
4073
+ */
4074
+ private isOwnSessionNotification;
2737
4075
  private setupEventForwarding;
2738
4076
  on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
2739
4077
  off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
@@ -2767,7 +4105,7 @@ declare class CloudAgentConnection implements AgentConnection {
2767
4105
  createdAt: number;
2768
4106
  }>;
2769
4107
  hasPendingQuestions(): boolean;
2770
- toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
4108
+ toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
2771
4109
  success: boolean;
2772
4110
  error?: string;
2773
4111
  }>;
@@ -2781,6 +4119,7 @@ declare class CloudAgentConnection implements AgentConnection {
2781
4119
  * Contains sandboxId, link, token, etc.
2782
4120
  */
2783
4121
  get sessionConnectionInfo(): SessionConnectionInfo | undefined;
4122
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2784
4123
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2785
4124
  }
2786
4125
  //#endregion
@@ -2808,6 +4147,13 @@ interface ArchiveConversationResponse {
2808
4147
  /**
2809
4148
  * Configuration for CloudAgentProvider
2810
4149
  */
4150
+ /**
4151
+ * Factory function to create a FilesResource from sandbox connection info.
4152
+ * Used to inject different filesystem implementations (e.g., MiniProgramE2BFilesystem for miniprogram).
4153
+ */
4154
+ type FilesystemFactory = (info: E2BSandboxConnectionInfo) => Promise<FilesResource & {
4155
+ setReconnectFn?: (fn: () => Promise<E2BSandboxConnectionInfo>) => void;
4156
+ }>;
2811
4157
  interface CloudAgentProviderOptions {
2812
4158
  /** Base endpoint URL for agent management API (e.g., 'https://api.example.com') */
2813
4159
  endpoint: string;
@@ -2819,6 +4165,12 @@ interface CloudAgentProviderOptions {
2819
4165
  logger?: Logger;
2820
4166
  /** Client capabilities (sent during agent initialization) */
2821
4167
  clientCapabilities?: ClientCapabilities$1;
4168
+ /**
4169
+ * Optional filesystem factory for creating FilesResource instances.
4170
+ * If not provided, defaults to E2BFilesystem (requires e2b package).
4171
+ * Set this to MiniProgramE2BFilesystem.connect for miniprogram environments.
4172
+ */
4173
+ filesystemFactory?: FilesystemFactory;
2822
4174
  }
2823
4175
  /**
2824
4176
  * CloudAgentProvider - Manages cloud-hosted agents via REST API
@@ -2903,6 +4255,22 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2903
4255
  private cosUploadService;
2904
4256
  /** Event listeners for provider-level events */
2905
4257
  private eventListeners;
4258
+ /** 产品配置缓存(内存),用于存储 deploymentType 和 creditPurchaseActions */
4259
+ private productConfigCache;
4260
+ /**
4261
+ * Plugin marketplace cache (name/id -> marketplace info)
4262
+ * LRU 缓存,容量上限 200
4263
+ * Key: marketplace name 或 id
4264
+ * Value: marketplace 完整信息
4265
+ */
4266
+ private marketplaceCache;
4267
+ /**
4268
+ * Installed plugin cache (plugin name -> plugin info with install_id)
4269
+ * LRU 缓存,容量上限 2000
4270
+ * Key: plugin name
4271
+ * Value: plugin 完整信息(包含 installId)
4272
+ */
4273
+ private pluginCache;
2906
4274
  constructor(options: CloudAgentProviderOptions);
2907
4275
  /**
2908
4276
  * Dispose the provider and clean up resources
@@ -2959,11 +4327,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2959
4327
  /**
2960
4328
  * Create a new conversation
2961
4329
  * POST {endpoint}/console/as/conversations
2962
- * @param params - Optional session params containing _meta with tags
4330
+ * @param params - Session params containing cwd and optional configuration
2963
4331
  */
2964
- create(params?: {
2965
- _meta?: Record<string, unknown>;
2966
- }): Promise<string>;
4332
+ create(params: CreateSessionParams$1): Promise<string>;
2967
4333
  /**
2968
4334
  * Connect to an agent and return the connection
2969
4335
  *
@@ -3015,6 +4381,21 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3015
4381
  * ```
3016
4382
  */
3017
4383
  rename(agentId: string, title: string): Promise<PatchConversationResponse>;
4384
+ /**
4385
+ * Update conversation status by ID
4386
+ * POST {endpoint}/console/as/conversations/{agentId}
4387
+ *
4388
+ * @param agentId - Conversation ID to update
4389
+ * @param status - New status for the conversation
4390
+ * @returns PatchConversationResponse containing the updated conversation ID
4391
+ *
4392
+ * @example
4393
+ * ```typescript
4394
+ * const result = await provider.updateStatus('agent-123', 'completed');
4395
+ * console.log('Updated conversation status:', result.id);
4396
+ * ```
4397
+ */
4398
+ updateStatus(agentId: string, status: string): Promise<PatchConversationResponse>;
3018
4399
  /**
3019
4400
  * Get available models from product configuration
3020
4401
  *
@@ -3027,6 +4408,25 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3027
4408
  * @returns Array of ModelInfo with full model details
3028
4409
  */
3029
4410
  getModels(repo?: string): Promise<ModelInfo[]>;
4411
+ /**
4412
+ * 获取产品部署类型(从缓存)
4413
+ * 需要先调用 getModels() 初始化缓存
4414
+ *
4415
+ * @returns 部署类型:'SaaS' | 'Cloud-Hosted' | 'Self-Hosted',默认为 'SaaS'
4416
+ */
4417
+ getDeploymentType(): string;
4418
+ /**
4419
+ * 获取 Credit 购买引导配置(从缓存)
4420
+ * 需要先调用 getModels() 初始化缓存
4421
+ *
4422
+ * @returns Credit 购买引导配置,key 为错误码。如果后端未返回,则使用默认配置
4423
+ */
4424
+ getCreditPurchaseActions(): Record<string, {
4425
+ labelZh: string;
4426
+ labelEn: string;
4427
+ url: string;
4428
+ showButton?: boolean;
4429
+ }>;
3030
4430
  /**
3031
4431
  * Generate a unique request ID
3032
4432
  */
@@ -3049,7 +4449,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3049
4449
  /**
3050
4450
  * Upload files to cloud storage via COS presigned URL
3051
4451
  *
3052
- * @param params - files array (File objects in browser)
4452
+ * @param params - files array (File objects in browser), optional abortSignal
3053
4453
  * @returns Response with corresponding cloud URLs
3054
4454
  */
3055
4455
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
@@ -3073,53 +4473,282 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3073
4473
  private emitEvent;
3074
4474
  /**
3075
4475
  * 获取支持的场景列表
3076
- * API 端点: GET /console/as/support/scenes
4476
+ * API 端点: GET /v2/as/support/scenes (不鉴权)
3077
4477
  * 用于 Welcome 页面的 QuickActions 快捷操作
3078
4478
  *
4479
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
3079
4480
  * @returns Promise<SupportScene[]> 支持的场景列表
3080
4481
  */
3081
- getSupportScenes(): Promise<SupportScene[]>;
4482
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
3082
4483
  private toAgentState;
3083
4484
  /**
3084
4485
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
3085
4486
  */
3086
4487
  private buildGetUrl;
4488
+ /**
4489
+ * 获取已安装插件列表
4490
+ * GET /console/as/user/plugins/installed
4491
+ */
4492
+ getInstalledPlugins(forceRefresh?: boolean): Promise<Array<{
4493
+ name: string;
4494
+ marketplaceName: string;
4495
+ status: string;
4496
+ description?: string;
4497
+ version?: string;
4498
+ installScope?: 'user' | 'project';
4499
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
4500
+ installId?: string;
4501
+ }>>;
4502
+ /**
4503
+ * 安装插件
4504
+ * POST /console/as/user/plugins/install
4505
+ *
4506
+ * @param pluginNames - 插件名称数组
4507
+ * @param marketplaceNameOrId - 市场名称或 ID
4508
+ */
4509
+ installPlugins(pluginNames: string[], marketplaceNameOrId: string, installScope?: 'user' | 'project' | 'project-local', marketplaceSource?: string, workspacePath?: string): Promise<{
4510
+ success: boolean;
4511
+ error?: string;
4512
+ }>;
4513
+ /**
4514
+ * 卸载插件
4515
+ * POST /console/as/user/plugins/installed/:id/uninstall
4516
+ *
4517
+ * 完整链路:
4518
+ * CloudAgentProvider.uninstallPlugin()
4519
+ * -> HTTP POST /console/as/user/plugins/installed/:id/uninstall
4520
+ * -> agentserver: PluginInstallService.Uninstall()
4521
+ * -> 软删除 DB + 异步同步到活跃沙箱
4522
+ *
4523
+ * @param pluginName - 插件名称
4524
+ * @param marketplaceName - 市场名称(用于标识唯一插件)
4525
+ * @param scope - 卸载范围 ('user' | 'project' | 'project-local')
4526
+ */
4527
+ uninstallPlugin(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
4528
+ success: boolean;
4529
+ error?: string;
4530
+ }>;
4531
+ /**
4532
+ * 获取插件市场列表
4533
+ * GET /console/as/marketplace/sources
4534
+ */
4535
+ getPluginMarketplaces(forceRefresh?: boolean): Promise<Array<{
4536
+ id: string;
4537
+ name: string;
4538
+ type: 'github' | 'local' | 'custom';
4539
+ source: {
4540
+ repo?: string;
4541
+ ref?: string;
4542
+ url?: string;
4543
+ };
4544
+ description?: string;
4545
+ isBuiltin?: boolean;
4546
+ }>>;
4547
+ /**
4548
+ * 获取市场下的插件列表
4549
+ * - 有 searchText: GET /console/as/marketplace/plugins/search (跨所有市场搜索)
4550
+ * - 无 searchText: GET /console/as/marketplace/plugins (指定市场)
4551
+ *
4552
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4553
+ * @param forceRefresh - 是否强制刷新
4554
+ * @param searchText - 搜索关键字(如果提供,则跨所有市场搜索)
4555
+ */
4556
+ getMarketplacePlugins(marketplaceNameOrId: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
4557
+ name: string;
4558
+ marketplaceName: string;
4559
+ description?: string;
4560
+ version?: string;
4561
+ author?: string;
4562
+ homepage?: string;
4563
+ iconUrl?: string;
4564
+ tags?: string[];
4565
+ installed?: boolean;
4566
+ status?: 'enabled' | 'disabled' | 'not-installed';
4567
+ installedScopes?: Array<'user' | 'project'>;
4568
+ hasUpdate?: boolean;
4569
+ latestVersion?: string;
4570
+ agents?: any;
4571
+ commands?: any;
4572
+ skills?: any;
4573
+ mcpServers?: any;
4574
+ hooks?: any;
4575
+ rules?: any;
4576
+ }>>;
4577
+ /**
4578
+ * 获取插件详情
4579
+ * GET /console/as/marketplace/plugins/:name/detail
4580
+ *
4581
+ * @param pluginName - 插件名称
4582
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4583
+ */
4584
+ getPluginDetail(pluginName: string, marketplaceNameOrId: string): Promise<{
4585
+ name: string;
4586
+ marketplaceName: string;
4587
+ description?: string;
4588
+ version?: string;
4589
+ author?: string;
4590
+ homepage?: string;
4591
+ iconUrl?: string;
4592
+ tags?: string[];
4593
+ installed?: boolean;
4594
+ status?: 'enabled' | 'disabled' | 'not-installed';
4595
+ installedScopes?: Array<'user' | 'project'>;
4596
+ readme?: string;
4597
+ configSchema?: Record<string, unknown>;
4598
+ tools?: Array<{
4599
+ name: string;
4600
+ description?: string;
4601
+ }>;
4602
+ resources?: Array<{
4603
+ name: string;
4604
+ description?: string;
4605
+ }>;
4606
+ prompts?: Array<{
4607
+ name: string;
4608
+ description?: string;
4609
+ }>;
4610
+ downloadCount?: number;
4611
+ lastUpdated?: string;
4612
+ license?: string;
4613
+ repositoryUrl?: string;
4614
+ } | null>;
4615
+ /**
4616
+ * 添加插件市场
4617
+ * POST /console/as/marketplace/sources
4618
+ */
4619
+ addPluginMarketplace(sourceUrl: string, name?: string): Promise<{
4620
+ success: boolean;
4621
+ error?: string;
4622
+ marketplace?: {
4623
+ id: string;
4624
+ name: string;
4625
+ type: 'github' | 'local' | 'custom';
4626
+ source: {
4627
+ repo?: string;
4628
+ ref?: string;
4629
+ url?: string;
4630
+ };
4631
+ description?: string;
4632
+ isBuiltin?: boolean;
4633
+ };
4634
+ }>;
4635
+ /**
4636
+ * 删除插件市场
4637
+ * POST /console/as/marketplace/sources/:id/delete
4638
+ */
4639
+ removePluginMarketplace(marketplaceNameOrId: string): Promise<{
4640
+ success: boolean;
4641
+ error?: string;
4642
+ }>;
4643
+ /**
4644
+ * 刷新插件市场
4645
+ * POST /console/as/marketplace/sources/:id/check-updates
4646
+ */
4647
+ refreshPluginMarketplace(marketplaceNameOrId: string): Promise<{
4648
+ success: boolean;
4649
+ error?: string;
4650
+ plugins?: Array<any>;
4651
+ }>;
4652
+ /**
4653
+ * 批量切换插件启用/禁用状态
4654
+ * POST /console/as/user/plugins/installed/:id/toggle
4655
+ */
4656
+ batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
4657
+ /**
4658
+ * 将后端插件数据映射为前端格式
4659
+ */
4660
+ private mapPluginData;
4661
+ /**
4662
+ * 从缓存中查找插件的 install_id
4663
+ * 如果缓存未命中,则调用 API 获取并缓存
4664
+ *
4665
+ * @param pluginName - 插件名称
4666
+ * @returns install_id 或 null
4667
+ */
4668
+ private findPluginInstallId;
4669
+ /**
4670
+ * 从缓存中查找 marketplace ID
4671
+ * 如果缓存未命中,则调用 API 获取并缓存
4672
+ */
4673
+ private findMarketplaceId;
4674
+ /**
4675
+ * 提取 API 错误信息
4676
+ * 从 AxiosError 中提取详细的错误信息,包括 HTTP 状态码、错误码和错误消息
4677
+ */
4678
+ private extractErrorMessage;
4679
+ /**
4680
+ * 映射后端 source_type 到前端类型
4681
+ */
4682
+ private mapSourceType;
4683
+ /**
4684
+ * 解析 capabilities JSON 字符串
4685
+ */
4686
+ private parseCapabilities;
4687
+ /**
4688
+ * 上报 telemetry 事件(Cloud 模式)
4689
+ * 通过 HTTP POST 发送到 /v2/report
4690
+ * 注入用户信息和浏览器环境等公共字段
4691
+ */
4692
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
3087
4693
  }
3088
4694
  //#endregion
3089
4695
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
3090
4696
  /**
3091
- * E2B Filesystem Implementation
4697
+ * Callback to fetch fresh sandbox connection info from backend.
4698
+ * Called when an operation fails with 401/403.
4699
+ */
4700
+ type ReconnectFn = () => Promise<E2BSandboxConnectionInfo>;
4701
+ /**
4702
+ * E2B Filesystem
3092
4703
  *
3093
- * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource interface.
4704
+ * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource.
4705
+ * When `reconnectFn` is provided, automatically reconnects on auth errors.
3094
4706
  *
3095
4707
  * @example
3096
4708
  * ```typescript
3097
- * const fs = await E2BFilesystem.connect({
3098
- * sandboxId: 'sandbox-123',
3099
- * apiKey: 'e2b_xxx'
3100
- * });
3101
- *
3102
- * // Read/write files
3103
- * await fs.write('/test.txt', 'Hello World');
3104
- * const content = await fs.read('/test.txt');
4709
+ * // Basic usage (no auto-reconnect)
4710
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
3105
4711
  *
3106
- * // Watch for changes
3107
- * const handle = await fs.watchDir('/workspace', (event) => {
3108
- * console.log('File changed:', event);
3109
- * });
4712
+ * // With auto-reconnect on token expiry
4713
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
4714
+ * fs.setReconnectFn(async () => fetchFreshConnectionInfo());
3110
4715
  * ```
3111
4716
  */
3112
4717
  declare class E2BFilesystem implements FilesResource {
3113
4718
  private sandbox;
4719
+ private reconnectFn?;
4720
+ /** Whether a reconnect is currently in-flight */
4721
+ private isReconnecting;
4722
+ /** Callers waiting for the in-flight reconnect to complete */
4723
+ private reconnectSubscribers;
4724
+ /** Timestamp of last reconnect attempt (anti-loop: min 10s between attempts) */
4725
+ private lastReconnectAt;
4726
+ private static readonly MIN_RECONNECT_INTERVAL_MS;
3114
4727
  constructor(sandbox: Sandbox);
3115
4728
  /**
3116
4729
  * Connect to an E2B Sandbox and create filesystem instance
3117
4730
  */
3118
4731
  static connect(info: E2BSandboxConnectionInfo): Promise<E2BFilesystem>;
4732
+ /**
4733
+ * Set reconnect callback. When set, auth errors trigger automatic reconnect + retry.
4734
+ */
4735
+ setReconnectFn(fn: ReconnectFn): void;
3119
4736
  /**
3120
4737
  * Get the underlying E2B Sandbox instance
3121
4738
  */
3122
4739
  getSandbox(): Sandbox;
4740
+ private isAuthError;
4741
+ private canAttemptReconnect;
4742
+ /**
4743
+ * Reconnect with fresh credentials.
4744
+ * Only one reconnect in-flight at a time; concurrent callers share the result.
4745
+ */
4746
+ private reconnect;
4747
+ /**
4748
+ * Execute an operation. If reconnectFn is set and an auth error occurs,
4749
+ * reconnect and retry once.
4750
+ */
4751
+ private exec;
3123
4752
  read(path: string, opts?: FilesystemRequestOpts & {
3124
4753
  format?: 'text';
3125
4754
  }): Promise<string>;
@@ -3134,13 +4763,13 @@ declare class E2BFilesystem implements FilesResource {
3134
4763
  }): Promise<ReadableStream<Uint8Array>>;
3135
4764
  write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<WriteInfo>;
3136
4765
  write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
3137
- list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
4766
+ list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo[]>;
3138
4767
  exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
3139
4768
  makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
3140
4769
  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 & {
4770
+ rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
4771
+ getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
4772
+ watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
3144
4773
  onExit?: (err?: Error) => void | Promise<void>;
3145
4774
  }): Promise<WatchHandle>;
3146
4775
  }
@@ -3262,6 +4891,7 @@ interface ActiveSessionImplOptions {
3262
4891
  declare class ActiveSessionImpl implements ActiveSession {
3263
4892
  private _id;
3264
4893
  private _agentId;
4894
+ private _cwd?;
3265
4895
  private _availableModes?;
3266
4896
  private _currentMode?;
3267
4897
  private _availableModels?;
@@ -3273,6 +4903,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3273
4903
  private _connectionInfo?;
3274
4904
  private listeners;
3275
4905
  private onceListeners;
4906
+ private connectionListeners;
3276
4907
  /**
3277
4908
  * Agent operations namespace
3278
4909
  */
@@ -3306,6 +4937,14 @@ declare class ActiveSessionImpl implements ActiveSession {
3306
4937
  * Agent ID
3307
4938
  */
3308
4939
  get agentId(): string;
4940
+ /**
4941
+ * Actual workspace path (set from newSession response _meta)
4942
+ */
4943
+ get cwd(): string | undefined;
4944
+ /**
4945
+ * Set actual workspace path (called by SessionManager after createSession)
4946
+ */
4947
+ setCwd(cwd: string): void;
3309
4948
  /**
3310
4949
  * Agent state (live connection state)
3311
4950
  * Returns LocalAgentState or CloudAgentState based on transport type
@@ -3387,12 +5026,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3387
5026
  */
3388
5027
  cancelQuestion(toolCallId: string, reason?: string): boolean;
3389
5028
  /**
3390
- * Callback for tool operations (skip or cancel)
5029
+ * Callback for tool operations (approve / skip / cancel)
3391
5030
  * @param toolCallId Tool call ID
3392
5031
  * @param toolName Tool name
3393
- * @param action Action to perform ('skip' or 'cancel')
5032
+ * @param action Action to perform ('approve' / 'skip' / 'cancel')
3394
5033
  */
3395
- toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
5034
+ toolCallback(toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
3396
5035
  success: boolean;
3397
5036
  error?: string;
3398
5037
  }>;
@@ -3450,6 +5089,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3450
5089
  * Disconnect from the session/agent
3451
5090
  */
3452
5091
  disconnect(): void;
5092
+ /**
5093
+ * Detach the session from connection events without disconnecting the connection.
5094
+ * This should be called when the session is being replaced but the connection is shared.
5095
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
5096
+ */
5097
+ detach(): void;
3453
5098
  /**
3454
5099
  * Symbol.dispose for 'using' keyword support
3455
5100
  * Automatically disconnects and cleans up when session goes out of scope
@@ -3464,8 +5109,21 @@ declare class ActiveSessionImpl implements ActiveSession {
3464
5109
  */
3465
5110
  [Symbol.dispose](): void;
3466
5111
  private getConnectionOrThrow;
5112
+ /**
5113
+ * 在 connection 上注册 listener 并保存引用,便于 disconnect 时移除
5114
+ */
5115
+ private addConnectionListener;
5116
+ /**
5117
+ * 从 connection 上移除所有本 session 注册的 listener
5118
+ */
5119
+ private removeConnectionListeners;
3467
5120
  private setupConnectionEvents;
3468
5121
  private mapPromptResponse;
5122
+ /**
5123
+ * 判断 artifact 是否应该转发给当前 session
5124
+ * 所有类型的 artifact 都按 __sessionId 严格隔离
5125
+ */
5126
+ private shouldForwardArtifact;
3469
5127
  }
3470
5128
  //#endregion
3471
5129
  //#region ../agent-provider/lib/common/client/session-manager.d.ts
@@ -3570,6 +5228,13 @@ declare class SessionManager {
3570
5228
  */
3571
5229
  declare class BackendProvider implements IBackendProvider {
3572
5230
  constructor(config: BackendProviderConfig);
5231
+ /**
5232
+ * 处理 401 未授权错误
5233
+ * 先尝试刷新 token,失败后再执行登出流程
5234
+ *
5235
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
5236
+ */
5237
+ protected handleUnauthorized(): Promise<void>;
3573
5238
  /**
3574
5239
  * 获取当前账号信息
3575
5240
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3680,9 +5345,21 @@ declare class BackendProvider implements IBackendProvider {
3680
5345
  login(): Promise<void>;
3681
5346
  /**
3682
5347
  * 登出账号
3683
- * Web 环境: 通过 iframe 访问登出 URL 清除 cookie
5348
+ *
5349
+ * 策略:
5350
+ * - IOA 企业:用 iframe 走 SSO/SAML SLO 登出链路(涉及跨域重定向),通过轮询 iframe URL 变化检测完成
5351
+ * - 非 IOA 企业:直接用 httpService 请求 /console/logout,速度快
3684
5352
  */
3685
5353
  logout(): Promise<void>;
5354
+ /**
5355
+ * IOA 企业登出:通过 iframe 走 SSO/SAML SLO 登出链路
5356
+ * 轮询 iframe URL 变化检测完成,兜底超时 5 秒
5357
+ */
5358
+ private logoutViaIframe;
5359
+ /**
5360
+ * 非 IOA 企业登出:直接 HTTP 请求 /console/logout
5361
+ */
5362
+ private logoutViaHttp;
3686
5363
  /**
3687
5364
  * 批量切换插件状态
3688
5365
  * Web 环境不支持此功能
@@ -3725,6 +5402,41 @@ declare class BackendProvider implements IBackendProvider {
3725
5402
  * @returns Promise<ListReposResponse> 仓库列表响应
3726
5403
  */
3727
5404
  getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
5405
+ /**
5406
+ * 保存待发送的输入内容到后端
5407
+ * API 端点: POST /api/v1/code-id
5408
+ */
5409
+ savePendingInput(code: string): Promise<string | null>;
5410
+ /**
5411
+ * 从后端加载待发送的输入内容
5412
+ * API 端点: GET /api/v1/code?id=xxx
5413
+ */
5414
+ loadPendingInput(codeId: string): Promise<string | null>;
5415
+ /**
5416
+ * 获取每日签到状态
5417
+ * API 端点: POST /billing/meter/checkin-status
5418
+ */
5419
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5420
+ /**
5421
+ * 执行每日签到
5422
+ * API 端点: POST /billing/meter/daily-checkin
5423
+ */
5424
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
5425
+ private static readonly SKILLHUB_BASE_URL;
5426
+ private static readonly SKILLHUB_FETCH_TIMEOUT;
5427
+ private skillHubFetch;
5428
+ getSkillHubList(params?: SkillHubListParams): Promise<SkillHubListResponse>;
5429
+ getSkillHubCategories(): Promise<SkillHubCategoriesResponse>;
5430
+ getSkillHubSearch(q: string, limit?: number): Promise<SkillHubSearchResponse>;
5431
+ getSkillHubDetail(slug: string): Promise<SkillHubDetailResponse>;
5432
+ getSkillHubExists(slugs: string[]): Promise<SkillHubExistsResponse>;
5433
+ reportSkillHubStats(slug: string, inc: {
5434
+ downloads?: number;
5435
+ installs?: number;
5436
+ stars?: number;
5437
+ }): Promise<void>;
5438
+ installSkillHubSkill(_slug: string, _version?: string, _name?: string): Promise<SkillHubInstallResponse>;
5439
+ getSkillHubInstalledMetas(): Promise<SkillHubInstalledMeta[]>;
3728
5440
  }
3729
5441
  /**
3730
5442
  * 创建 BackendProvider 实例
@@ -3853,6 +5565,14 @@ declare class IPCBackendProvider implements IBackendProvider {
3853
5565
  reloadWindow(params?: {
3854
5566
  locale?: string;
3855
5567
  }): Promise<void>;
5568
+ /**
5569
+ * Save locale to argv.json without restarting the app.
5570
+ * The change takes effect on next manual restart.
5571
+ * @param params locale to save
5572
+ */
5573
+ saveLocale(params: {
5574
+ locale: string;
5575
+ }): Promise<void>;
3856
5576
  /**
3857
5577
  * 关闭 Agent Manager 面板
3858
5578
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
@@ -3881,6 +5601,76 @@ declare class IPCBackendProvider implements IBackendProvider {
3881
5601
  * 4. 返回 SupportScene[] 数据给 agent-ui
3882
5602
  */
3883
5603
  getSupportScenes(): Promise<SupportScene[]>;
5604
+ /**
5605
+ * 获取账号用量信息(积分/Credits)
5606
+ * IDE 环境: 通过 IPC 实时获取用量信息,每次打开菜单时调用
5607
+ *
5608
+ * 调用链:
5609
+ * 1. agent-ui: IPCBackendProvider.getAccountUsage()
5610
+ * 2. Agent Manager renderer: BackendService.getAccountUsage()
5611
+ * 3. Main Process: codebuddy:getAccountUsage IPC handler
5612
+ * 4. 返回 { usageLeft, usageTotal, editionType, refreshAt } 等字段
5613
+ */
5614
+ getAccountUsage(): Promise<Partial<Account> | null>;
5615
+ /**
5616
+ * 获取每日签到状态
5617
+ * IDE 环境: 通过 IPC 获取签到状态
5618
+ */
5619
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5620
+ /**
5621
+ * 执行每日签到
5622
+ * IDE 环境: 通过 IPC 执行签到
5623
+ */
5624
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
5625
+ /**
5626
+ * 获取活动 Banner
5627
+ * IDE 环境: 通过 IPC 获取活动 Banner
5628
+ */
5629
+ getActivityBanner(): Promise<ActivityBannerResponse | null>;
5630
+ /**
5631
+ * 获取 SkillHub 技能列表
5632
+ * IDE 环境: 通过 IPC 获取技能列表
5633
+ */
5634
+ getSkillHubList(params?: SkillHubListParams): Promise<SkillHubListResponse>;
5635
+ /**
5636
+ * 获取 SkillHub 分类列表
5637
+ * IDE 环境: 通过 IPC 获取分类列表
5638
+ */
5639
+ getSkillHubCategories(): Promise<SkillHubCategoriesResponse>;
5640
+ /**
5641
+ * 搜索 SkillHub 技能
5642
+ * IDE 环境: 通过 IPC 搜索技能
5643
+ */
5644
+ getSkillHubSearch(q: string, limit?: number): Promise<SkillHubSearchResponse>;
5645
+ /**
5646
+ * 获取 SkillHub 技能详情
5647
+ * IDE 环境: 通过 IPC 获取技能详情
5648
+ */
5649
+ getSkillHubDetail(slug: string): Promise<SkillHubDetailResponse>;
5650
+ /**
5651
+ * 批量检查 SkillHub 技能是否存在
5652
+ * IDE 环境: 通过 IPC 检查技能是否存在
5653
+ */
5654
+ getSkillHubExists(slugs: string[]): Promise<SkillHubExistsResponse>;
5655
+ /**
5656
+ * 上报 SkillHub 技能统计
5657
+ * IDE 环境: 通过 IPC 上报统计
5658
+ */
5659
+ reportSkillHubStats(slug: string, inc: {
5660
+ downloads?: number;
5661
+ installs?: number;
5662
+ stars?: number;
5663
+ }): Promise<void>;
5664
+ /**
5665
+ * 安装 SkillHub 技能
5666
+ * IDE 环境: 通过 IPC 安装技能(下载 zip → 解压到本地)
5667
+ */
5668
+ installSkillHubSkill(slug: string, version?: string, name?: string): Promise<SkillHubInstallResponse>;
5669
+ /**
5670
+ * 获取本地已安装的 SkillHub 技能元信息
5671
+ * IDE 环境: 通过 IPC 获取元信息
5672
+ */
5673
+ getSkillHubInstalledMetas(): Promise<SkillHubInstalledMeta[]>;
3884
5674
  /**
3885
5675
  * 调试日志
3886
5676
  */
@@ -3918,7 +5708,7 @@ type RequestErrorInterceptor = (error: any) => any;
3918
5708
  /**
3919
5709
  * 响应拦截器函数
3920
5710
  */
3921
- type ResponseInterceptor = (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
5711
+ type ResponseInterceptor = (response: AxiosResponse$1) => AxiosResponse$1 | Promise<AxiosResponse$1>;
3922
5712
  /**
3923
5713
  * 响应错误拦截器函数
3924
5714
  */
@@ -3935,7 +5725,7 @@ type UnauthorizedCallback = () => void;
3935
5725
  * 特性:
3936
5726
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3937
5727
  * - 支持拦截器注册(其他模块可注入 header)
3938
- * - 统一 401/403 处理
5728
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3939
5729
  * - 自动携带凭证(withCredentials)
3940
5730
  * - 类型安全
3941
5731
  *
@@ -3971,6 +5761,10 @@ declare class HttpService {
3971
5761
  private axiosInstance;
3972
5762
  private unauthorizedCallbacks;
3973
5763
  private config;
5764
+ /** 是否正在刷新 token */
5765
+ private isRefreshing;
5766
+ /** 等待 token 刷新完成的请求队列 */
5767
+ private refreshSubscribers;
3974
5768
  /**
3975
5769
  * 私有构造函数(单例模式)
3976
5770
  */
@@ -3988,9 +5782,17 @@ declare class HttpService {
3988
5782
  */
3989
5783
  private registerDefaultRequestInterceptor;
3990
5784
  /**
3991
- * 注册默认响应拦截器(处理 401/403)
5785
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3992
5786
  */
3993
5787
  private registerDefaultResponseInterceptor;
5788
+ /**
5789
+ * token 刷新成功,通知所有等待的请求
5790
+ */
5791
+ private onRefreshSuccess;
5792
+ /**
5793
+ * token 刷新失败,通知所有等待的请求
5794
+ */
5795
+ private onRefreshFailure;
3994
5796
  /**
3995
5797
  * 注册请求拦截器
3996
5798
  * @param onFulfilled 请求成功拦截器
@@ -4056,7 +5858,9 @@ declare class HttpService {
4056
5858
  */
4057
5859
  offUnauthorized(callback: UnauthorizedCallback): void;
4058
5860
  /**
4059
- * 触发所有 401 回调
5861
+ * 触发所有 401 回调并等待完成
5862
+ * @returns Promise,等待所有回调完成
5863
+ * @throws 如果任何回调失败,则抛出错误
4060
5864
  */
4061
5865
  private triggerUnauthorizedCallbacks;
4062
5866
  /**
@@ -4107,6 +5911,12 @@ declare class HttpService {
4107
5911
  * @returns 响应数据
4108
5912
  */
4109
5913
  put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
5914
+ /**
5915
+ * 通用请求方法
5916
+ * @param config axios 请求配置
5917
+ * @returns 原始 AxiosResponse
5918
+ */
5919
+ request<T = any>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
4110
5920
  /**
4111
5921
  * 获取原始 axios 实例(用于高级场景)
4112
5922
  */