@tencent-ai/cloud-agent-sdk 0.2.13 → 0.2.14-next.6cb18d4.20260320

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { AgentCapabilities as AgentCapabilities$1, ClientCapabilities, InitializeResponse, LoadSessionResponse, NewSessionResponse, PromptResponse as PromptResponse$1, RequestPermissionRequest, RequestPermissionRequest as RequestPermissionRequest$1, SessionNotification, SessionNotification as SessionNotification$1, SetSessionModeResponse, SetSessionModelResponse } from "@agentclientprotocol/sdk";
3
- import { EntryInfo, EntryInfo as EntryInfo$1, Filesystem, FilesystemEvent, FilesystemEvent as FilesystemEvent$1, Sandbox, WatchHandle, WriteInfo } from "e2b";
2
+ import { AgentCapabilities as AgentCapabilities$1, ClientCapabilities, InitializeResponse, LoadSessionResponse, NewSessionResponse, PromptResponse as PromptResponse$1, RequestPermissionRequest, RequestPermissionRequest as RequestPermissionRequest$1, SessionNotification, SessionNotification as SessionNotification$1, SetSessionModeResponse, SetSessionModelResponse, StopReason } from "@agentclientprotocol/sdk";
3
+ import { Sandbox } from "e2b";
4
4
 
5
5
  //#region ../agent-client-protocol/lib/common/types.d.ts
6
6
  /**
@@ -235,6 +235,12 @@ interface CodebuddyClientMeta {
235
235
  artifacts?: ArtifactsConfig;
236
236
  /** Whether the client supports checkpoint notifications */
237
237
  checkpoint?: boolean;
238
+ /**
239
+ * Whether the client supports handling AskUserQuestion tool via extMethod.
240
+ * When true, AskUserQuestion requests will be sent to the client via
241
+ * the '_codebuddy.ai/question' extMethod instead of being handled locally.
242
+ */
243
+ question?: boolean;
238
244
  }
239
245
  /**
240
246
  * codebuddy.ai extension capabilities for Agent
@@ -995,6 +1001,38 @@ 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
+ }
998
1036
  /**
999
1037
  * 企业用户用量信息
1000
1038
  */
@@ -1122,6 +1160,14 @@ interface IBackendProvider {
1122
1160
  reloadWindow?(params?: {
1123
1161
  locale?: string;
1124
1162
  }): Promise<void>;
1163
+ /**
1164
+ * Save locale to argv.json without restarting the app (optional, IPC only).
1165
+ * The change takes effect on next manual restart.
1166
+ * @param params locale to save
1167
+ */
1168
+ saveLocale?(params: {
1169
+ locale: string;
1170
+ }): Promise<void>;
1125
1171
  /**
1126
1172
  * 关闭 Agent Manager 面板(可选,仅 IPC 环境支持)
1127
1173
  * 用于 Local 模式下点击 Logo 返回 IDE
@@ -1145,6 +1191,22 @@ interface IBackendProvider {
1145
1191
  * @returns Promise<EnterpriseUsage | null> 企业用户用量信息
1146
1192
  */
1147
1193
  getEnterpriseUsage?(enterpriseId: string): Promise<EnterpriseUsage | null>;
1194
+ /**
1195
+ * 获取账号用量信息(积分/Credits)
1196
+ * 实时获取,每次打开菜单时调用,不依赖 getAccount 缓存
1197
+ * @returns Promise<Partial<Account> | null> 包含 usageLeft, usageTotal, refreshAt 等字段
1198
+ */
1199
+ getAccountUsage?(): Promise<Partial<Account> | null>;
1200
+ /**
1201
+ * 获取每日签到状态
1202
+ * @returns Promise<CheckinStatusResponse | null> 签到状态,失败时返回 null
1203
+ */
1204
+ getCheckinStatus?(): Promise<CheckinStatusResponse | null>;
1205
+ /**
1206
+ * 执行每日签到
1207
+ * @returns Promise<CheckinResultResponse> 签到结果
1208
+ */
1209
+ claimDailyCheckin?(): Promise<CheckinResultResponse>;
1148
1210
  /**
1149
1211
  * 刷新 Token(可选)
1150
1212
  * 通过调用 getAccount 刷新 cookie
@@ -1173,6 +1235,175 @@ interface IBackendProvider {
1173
1235
  * @returns Promise<ListReposResponse> 仓库列表响应
1174
1236
  */
1175
1237
  getRepositories?(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
1238
+ /**
1239
+ * 保存待发送的输入内容到后端(用于跨域登录场景)
1240
+ * API 端点: POST /api/v1/code-id
1241
+ *
1242
+ * @param code 要保存的文本内容
1243
+ * @returns Promise<string | null> 返回 codeId,失败返回 null
1244
+ */
1245
+ savePendingInput?(code: string): Promise<string | null>;
1246
+ /**
1247
+ * 从后端加载待发送的输入内容(用于跨域登录场景)
1248
+ * API 端点: GET /api/v1/code?id=xxx
1249
+ *
1250
+ * @param codeId 内容 ID
1251
+ * @returns Promise<string | null> 返回保存的文本内容,失败返回 null
1252
+ */
1253
+ loadPendingInput?(codeId: string): Promise<string | null>;
1254
+ /**
1255
+ * 获取 SkillHub 技能列表(分页)
1256
+ * @param params 分页/过滤参数
1257
+ * @returns Promise<SkillHubListResponse>
1258
+ */
1259
+ getSkillHubList?(params?: SkillHubListParams): Promise<SkillHubListResponse>;
1260
+ /**
1261
+ * 获取 SkillHub 分类列表
1262
+ * @returns Promise<SkillHubCategoriesResponse>
1263
+ */
1264
+ getSkillHubCategories?(): Promise<SkillHubCategoriesResponse>;
1265
+ /**
1266
+ * 搜索 SkillHub 技能
1267
+ * @param q 搜索关键词
1268
+ * @param limit 结果数量限制
1269
+ * @returns Promise<SkillHubSearchResponse>
1270
+ */
1271
+ getSkillHubSearch?(q: string, limit?: number): Promise<SkillHubSearchResponse>;
1272
+ /**
1273
+ * 获取 SkillHub 技能详情
1274
+ * @param slug 技能唯一标识
1275
+ * @returns Promise<SkillHubDetailResponse>
1276
+ */
1277
+ getSkillHubDetail?(slug: string): Promise<SkillHubDetailResponse>;
1278
+ /**
1279
+ * 批量检查 SkillHub 技能是否存在
1280
+ * @param slugs 技能标识列表
1281
+ * @returns Promise<SkillHubExistsResponse>
1282
+ */
1283
+ getSkillHubExists?(slugs: string[]): Promise<SkillHubExistsResponse>;
1284
+ /**
1285
+ * 上报 SkillHub 技能统计
1286
+ * @param slug 技能标识
1287
+ * @param inc 增量统计
1288
+ */
1289
+ reportSkillHubStats?(slug: string, inc: {
1290
+ downloads?: number;
1291
+ installs?: number;
1292
+ stars?: number;
1293
+ }): Promise<void>;
1294
+ /**
1295
+ * 安装 SkillHub 技能(下载 zip → 解压到本地)
1296
+ * @param slug 技能标识
1297
+ * @param version 版本号
1298
+ * @param name 原始显示名称(保留大小写)
1299
+ * @returns Promise<SkillHubInstallResponse>
1300
+ */
1301
+ installSkillHubSkill?(slug: string, version?: string, name?: string): Promise<SkillHubInstallResponse>;
1302
+ /**
1303
+ * 获取本地已安装的 SkillHub 技能元信息
1304
+ * @returns Promise<SkillHubInstalledMeta[]>
1305
+ */
1306
+ getSkillHubInstalledMetas?(): Promise<SkillHubInstalledMeta[]>;
1307
+ }
1308
+ interface SkillHubSkill {
1309
+ slug: string;
1310
+ ownerName: string;
1311
+ category: string;
1312
+ name: string;
1313
+ description: string;
1314
+ description_zh: string;
1315
+ version: string;
1316
+ homepage: string;
1317
+ tags: string[];
1318
+ downloads: number;
1319
+ stars: number;
1320
+ installs: number;
1321
+ updated_at: number;
1322
+ score: number;
1323
+ /** Optional source marker used in merged search results */
1324
+ _source?: 'recommend' | 'skillhub';
1325
+ }
1326
+ interface SkillHubListResponse {
1327
+ code: number;
1328
+ message: string;
1329
+ data: {
1330
+ total: number;
1331
+ skills: SkillHubSkill[];
1332
+ };
1333
+ }
1334
+ interface SkillHubCategory {
1335
+ key: string;
1336
+ name: string;
1337
+ nameEn: string;
1338
+ sortOrder: number;
1339
+ active: boolean;
1340
+ }
1341
+ interface SkillHubCategoriesResponse {
1342
+ items: SkillHubCategory[];
1343
+ count: number;
1344
+ }
1345
+ interface SkillHubSearchResult {
1346
+ score: number;
1347
+ slug: string;
1348
+ displayName: string;
1349
+ summary: string;
1350
+ version: string;
1351
+ updatedAt: number;
1352
+ }
1353
+ interface SkillHubSearchResponse {
1354
+ results: SkillHubSearchResult[];
1355
+ }
1356
+ interface SkillHubDetailResponse {
1357
+ skill: {
1358
+ slug: string;
1359
+ category: string;
1360
+ displayName: string;
1361
+ summary: string;
1362
+ summary_zh: string;
1363
+ tags: Record<string, string>;
1364
+ stats: {
1365
+ downloads: number;
1366
+ stars: number;
1367
+ installs: number;
1368
+ versions: number;
1369
+ comments: number;
1370
+ };
1371
+ createdAt: number;
1372
+ updatedAt: number;
1373
+ };
1374
+ latestVersion: {
1375
+ version: string;
1376
+ createdAt: number;
1377
+ changelog: string;
1378
+ };
1379
+ owner: {
1380
+ handle: string;
1381
+ displayName: string;
1382
+ image: string | null;
1383
+ };
1384
+ }
1385
+ interface SkillHubExistsResponse {
1386
+ exists: Record<string, boolean>;
1387
+ count: number;
1388
+ }
1389
+ interface SkillHubInstallResponse {
1390
+ success: boolean;
1391
+ skillName: string;
1392
+ errorMessage?: string;
1393
+ }
1394
+ interface SkillHubInstalledMeta {
1395
+ slug: string;
1396
+ version: string | null;
1397
+ installedAt?: number;
1398
+ }
1399
+ type SkillHubSortBy = 'score' | 'downloads' | 'updated_at' | 'installs';
1400
+ interface SkillHubListParams {
1401
+ page?: number;
1402
+ pageSize?: number;
1403
+ sortBy?: SkillHubSortBy;
1404
+ order?: 'asc' | 'desc';
1405
+ keyword?: string;
1406
+ category?: string;
1176
1407
  }
1177
1408
  /**
1178
1409
  * 场景中的插件信息
@@ -1186,6 +1417,12 @@ interface ScenePlugin {
1186
1417
  /** 插件市场名称 */
1187
1418
  marketplaceName: string;
1188
1419
  }
1420
+ /**
1421
+ * 场景模式类型
1422
+ * - coding: 编程相关场景
1423
+ * - working: 工作/通用场景
1424
+ */
1425
+ type SupportSceneMode = 'coding' | 'working';
1189
1426
  /**
1190
1427
  * 支持的场景信息
1191
1428
  * 用于 Welcome 页面的 QuickActions 快捷操作
@@ -1200,11 +1437,15 @@ interface SupportScene {
1200
1437
  plugins: ScenePlugin[];
1201
1438
  /** 场景对应的 prompt 列表 */
1202
1439
  prompts: string[];
1440
+ /** 场景模式类型 */
1441
+ mode?: SupportSceneMode;
1203
1442
  }
1204
1443
  /**
1205
1444
  * 插件作用域
1445
+ * 使用 agent-craft 的 PluginInstallScope 类型
1446
+ * 注意: 当前后端 API 只支持 user 和 project,暂不支持 project-local
1206
1447
  */
1207
- type PluginScope = 'user' | 'project';
1448
+ type PluginScope = 'user' | 'project' | 'project-local' | 'local';
1208
1449
  /**
1209
1450
  * 插件操作类型
1210
1451
  */
@@ -1314,6 +1555,71 @@ interface AvailableCommand {
1314
1555
  }
1315
1556
  //#endregion
1316
1557
  //#region ../agent-provider/lib/common/types.d.ts
1558
+ /**
1559
+ * File type enumeration
1560
+ * Compatible with e2b SDK FileType
1561
+ */
1562
+ declare enum FileType {
1563
+ FILE = "file",
1564
+ DIR = "dir"
1565
+ }
1566
+ /**
1567
+ * Filesystem event type enumeration
1568
+ * Compatible with e2b SDK FilesystemEventType
1569
+ */
1570
+ declare enum FilesystemEventType {
1571
+ CHMOD = "chmod",
1572
+ CREATE = "create",
1573
+ REMOVE = "remove",
1574
+ RENAME = "rename",
1575
+ WRITE = "write"
1576
+ }
1577
+ /**
1578
+ * File or directory entry information
1579
+ * Compatible with e2b SDK EntryInfo
1580
+ */
1581
+ interface EntryInfo {
1582
+ name: string;
1583
+ type: FileType;
1584
+ path: string;
1585
+ size: number;
1586
+ mode: number;
1587
+ permissions: string;
1588
+ owner: string;
1589
+ group: string;
1590
+ modifiedTime?: Date;
1591
+ symlinkTarget?: string;
1592
+ }
1593
+ /**
1594
+ * Write operation result
1595
+ * Compatible with e2b SDK WriteInfo
1596
+ */
1597
+ interface WriteInfo {
1598
+ path: string;
1599
+ type: FileType;
1600
+ name: string;
1601
+ }
1602
+ /**
1603
+ * Filesystem watch event
1604
+ * Compatible with e2b SDK FilesystemEvent
1605
+ */
1606
+ interface FilesystemEvent {
1607
+ name: string;
1608
+ type: FilesystemEventType;
1609
+ }
1610
+ /**
1611
+ * Handle for stopping a directory watch
1612
+ * Compatible with e2b SDK WatchHandle
1613
+ */
1614
+ interface WatchHandle {
1615
+ stop(): Promise<void>;
1616
+ }
1617
+ /**
1618
+ * @deprecated Use the standalone type definitions above instead.
1619
+ * This type alias is kept for backward compatibility with code that
1620
+ * imported `Filesystem` type from this module.
1621
+ */
1622
+ type Filesystem = FilesResource;
1317
1623
  /**
1318
1624
  * Base options for filesystem operations
1319
1625
  * 对齐 e2b SDK FilesystemRequestOpts
@@ -1397,7 +1703,7 @@ interface FilesResource {
1397
1703
  /** Write multiple files in batch */
1398
1704
  write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
1399
1705
  /** List directory contents with optional depth */
1400
- list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
1706
+ list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo[]>;
1401
1707
  /** Check if path exists */
1402
1708
  exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
1403
1709
  /** Create directory */
@@ -1405,9 +1711,9 @@ interface FilesResource {
1405
1711
  /** Remove file or directory */
1406
1712
  remove(path: string, opts?: FilesystemRequestOpts): Promise<void>;
1407
1713
  /** Rename/move file or directory */
1408
- rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
1714
+ rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
1409
1715
  /** Get file or directory information */
1410
- getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
1716
+ getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
1411
1717
  /** Watch directory for changes */
1412
1718
  watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
1413
1719
  onExit?: (err?: Error) => void | Promise<void>;
@@ -1510,7 +1816,7 @@ type PromptContentBlock = {
1510
1816
  uri: string;
1511
1817
  mimeType?: string | null;
1512
1818
  name: string;
1513
- size?: bigint | null;
1819
+ size?: number | null;
1514
1820
  title?: string | null;
1515
1821
  _meta?: {
1516
1822
  [key: string]: unknown;
@@ -1616,13 +1922,22 @@ interface AgentConnection {
1616
1922
  * @param sessionId 会话 ID
1617
1923
  * @param toolCallId 工具调用 ID
1618
1924
  * @param toolName 工具名称
1619
- * @param action 操作类型 ('skip' | 'cancel')
1925
+ * @param action 操作类型 ('approve' | 'skip' | 'cancel')
1620
1926
  */
1621
- toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
1927
+ toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
1622
1928
  success: boolean;
1623
1929
  error?: string;
1624
1930
  }>;
1625
1931
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
1932
+ /**
1933
+ * Report telemetry event through the standard provider chain
1934
+ * - Local: via ACP JSON-RPC → IDE EventService
1935
+ * - Cloud: via StreamableHTTP → cloud telemetry endpoint
1936
+ *
1937
+ * @param eventName - Event name / code
1938
+ * @param payload - Event data (already includes mode)
1939
+ */
1940
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
1626
1941
  }
1627
1942
  /**
1628
1943
  * Base configuration for connections
@@ -1830,6 +2145,8 @@ interface BaseAgentState {
1830
2145
  updatedAt?: Date;
1831
2146
  /** 是否为 playground */
1832
2147
  isPlayground?: boolean;
2148
+ /** Whether the title is user defined (1 = user defined) */
2149
+ isUserDefinedTitle?: number;
1833
2150
  }
1834
2151
  /**
1835
2152
  * LocalAgentState - 本地 Agent 状态
@@ -1893,6 +2210,11 @@ interface ListAgentSort {
1893
2210
  * Local: Client-side filtering and sorting, no pagination (returns all)
1894
2211
  */
1895
2212
  interface ListAgentOptions {
2213
+ /**
2214
+ * User ID for filtering sessions (required for multi-user isolation)
2215
+ * If not provided, returns empty list for Local provider
2216
+ */
2217
+ userId?: string;
1896
2218
  /**
1897
2219
  * Page number (starts from 1)
1898
2220
  * Cloud: Used for API pagination
@@ -1970,22 +2292,46 @@ interface SessionInfo {
1970
2292
  status: AgentStatus;
1971
2293
  /** When the session/agent was created */
1972
2294
  createdAt?: Date;
2295
+ /** When the session/agent was last updated */
2296
+ updatedAt?: Date;
1973
2297
  /** Last activity timestamp */
1974
2298
  lastActivityAt?: Date;
1975
2299
  /** Working directory (for local agents) */
1976
2300
  cwd?: string;
1977
2301
  /** Whether the session is a playground */
1978
2302
  isPlayground?: boolean;
2303
+ /** Whether the title is user defined (1 = user defined) */
2304
+ isUserDefinedTitle?: number;
1979
2305
  }
1980
2306
  /**
1981
2307
  * Parameters for creating a new session
1982
2308
  */
1983
2309
  interface CreateSessionParams$1 {
1984
- /** Working directory */
2310
+ /** Working directory (required) */
1985
2311
  cwd: string;
2312
+ /** Optional configuration */
2313
+ options?: CreateSessionOptions;
2314
+ }
2315
+ /**
2316
+ * Optional configuration for creating a session
2317
+ */
2318
+ interface CreateSessionOptions {
1986
2319
  /** MCP server configurations */
1987
2320
  mcpServers?: McpServerConfig[];
2321
+ /** Initial prompt for the session (Cloud only) */
2322
+ prompt?: string;
2323
+ /** Initial model for the session (Cloud only) */
2324
+ model?: string;
2325
+ /** Mode ID (e.g., 'craft', 'architect') */
2326
+ mode?: string;
2327
+ /** Whether this is a playground session (no cwd) */
2328
+ isPlayground?: boolean;
2329
+ /** Tags for template scenes (Cloud only, format: { scene: 'xxx' }) */
2330
+ tags?: Record<string, string>;
2331
+ /** Additional metadata */
1988
2332
  _meta?: Record<string, unknown>;
2333
+ /** Callback when session is prepared (POST succeeded, before WebSocket connect) */
2334
+ onSessionPrepared?: (sessionInfo: SessionInfo) => void;
1989
2335
  }
1990
2336
  /**
1991
2337
  * Parameters for loading an existing session
@@ -2020,6 +2366,84 @@ interface InitializeWorkspaceResponse {
2020
2366
  /** Error message (if failed) */
2021
2367
  error?: string;
2022
2368
  }
2369
+ type AutomationStatus = 'ACTIVE' | 'PAUSED';
2370
+ type AutomationUpdateMode = 'view' | 'suggested create' | 'suggested update';
2371
+ type AutomationRunStatus = 'ACCEPTED' | 'ARCHIVED' | 'PENDING_REVIEW' | 'IN_PROGRESS';
2372
+ interface AutomationDefinition {
2373
+ version: number;
2374
+ id: string;
2375
+ name: string;
2376
+ prompt: string;
2377
+ status: AutomationStatus;
2378
+ rrule: string;
2379
+ cwds: string[];
2380
+ modelId?: string;
2381
+ modelIsThinking?: boolean;
2382
+ created_at: number;
2383
+ updated_at: number;
2384
+ }
2385
+ interface AutomationCwdRunResult {
2386
+ cwd: string;
2387
+ success: boolean;
2388
+ startedAt: number;
2389
+ finishedAt: number;
2390
+ conversationId?: string;
2391
+ output?: string;
2392
+ error?: string;
2393
+ }
2394
+ interface AutomationInboxItem {
2395
+ id: string;
2396
+ automationId: string;
2397
+ automationName: string;
2398
+ status?: AutomationRunStatus;
2399
+ readAt?: number;
2400
+ startedAt: number;
2401
+ finishedAt: number;
2402
+ success: boolean;
2403
+ summary: string;
2404
+ runs: AutomationCwdRunResult[];
2405
+ archived?: boolean;
2406
+ archivedAt?: number;
2407
+ }
2408
+ interface AutomationRuntimeState {
2409
+ lastRunAt?: number;
2410
+ lastError?: string;
2411
+ running?: boolean;
2412
+ runningStartedAt?: number;
2413
+ runningConversationId?: string;
2414
+ }
2415
+ interface AutomationSnapshot {
2416
+ automations: AutomationDefinition[];
2417
+ inbox: AutomationInboxItem[];
2418
+ runtimeState: Record<string, AutomationRuntimeState>;
2419
+ updatedAt: number;
2420
+ }
2421
+ interface AutomationUpdatePayload {
2422
+ mode: AutomationUpdateMode;
2423
+ id?: string;
2424
+ name?: string;
2425
+ prompt?: string;
2426
+ rrule?: string;
2427
+ cwds?: string[] | string;
2428
+ status?: AutomationStatus;
2429
+ modelId?: string;
2430
+ modelIsThinking?: boolean;
2431
+ }
2432
+ interface AutomationUpdateResult {
2433
+ success: boolean;
2434
+ message: string;
2435
+ automation?: AutomationDefinition;
2436
+ snapshot?: AutomationSnapshot;
2437
+ }
2438
+ /**
2439
+ * Parameters for getting available commands
2440
+ */
2441
+ interface GetAvailableCommandsParams {
2442
+ /** Session ID to get commands for (optional, for global commands) */
2443
+ sessionId?: string;
2444
+ /** Workspace path for getting custom commands (optional) */
2445
+ workspacePath?: string;
2446
+ }
2023
2447
  /**
2024
2448
  * Prompts resource interface (ACP verbs)
2025
2449
  * Operations use the current session automatically
@@ -2057,7 +2481,7 @@ interface ModelsResource {
2057
2481
  */
2058
2482
  interface PromptResponse {
2059
2483
  /** Stop reason */
2060
- stopReason: 'end_turn' | 'max_tokens' | 'tool_use' | 'cancelled' | 'error';
2484
+ stopReason: StopReason;
2061
2485
  /** Response metadata */
2062
2486
  _meta?: Record<string, unknown>;
2063
2487
  }
@@ -2067,7 +2491,7 @@ interface PromptResponse {
2067
2491
  interface SessionsResourceEvents {
2068
2492
  /** Emitted when the sessions list changes (create, delete, update) */
2069
2493
  sessionsChanged: SessionInfo[];
2070
- /** Emitted when a new session is created */
2494
+ /** Emitted when a new session is fully connected and ready */
2071
2495
  sessionCreated: SessionInfo;
2072
2496
  /** Emitted when a session is deleted */
2073
2497
  sessionDeleted: {
@@ -2075,6 +2499,17 @@ interface SessionsResourceEvents {
2075
2499
  };
2076
2500
  /** Emitted when a session is updated (status change, etc.) */
2077
2501
  sessionUpdated: SessionInfo;
2502
+ /** Emitted when automation snapshot is updated (pushed from server) */
2503
+ automationSnapshotUpdate: AutomationSnapshot;
2504
+ /** Emitted when plugins or marketplaces change (install/uninstall/add/remove/update) */
2505
+ pluginsChanged: {
2506
+ newMarketplaceName?: string;
2507
+ } | undefined;
2508
+ /** Emitted when ProductConfiguration changes (account switch, config sync, etc.) */
2509
+ productConfigChanged: {
2510
+ timestamp: number;
2511
+ productFeatures: Record<string, boolean>;
2512
+ };
2078
2513
  }
2079
2514
  /**
2080
2515
  * Event handler type for sessions resource events
@@ -2151,6 +2586,8 @@ interface ActiveSession {
2151
2586
  readonly id: string;
2152
2587
  /** Agent ID */
2153
2588
  readonly agentId: string;
2589
+ /** Actual workspace path (set after newSession, useful for Playground scenario) */
2590
+ readonly cwd?: string;
2154
2591
  /** Agent state (direct access to underlying agent state) */
2155
2592
  readonly agentState: AgentState;
2156
2593
  /** Agent capabilities (available after connection) */
@@ -2188,8 +2625,8 @@ interface ActiveSession {
2188
2625
  answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
2189
2626
  /** Cancel a question request */
2190
2627
  cancelQuestion(toolCallId: string, reason?: string): boolean;
2191
- /** Callback for tool operations (skip or cancel) */
2192
- toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
2628
+ /** Callback for tool operations (approve / skip / cancel) */
2629
+ toolCallback(toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
2193
2630
  success: boolean;
2194
2631
  error?: string;
2195
2632
  }>;
@@ -2211,6 +2648,12 @@ interface ActiveSession {
2211
2648
  once<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
2212
2649
  /** Disconnect from the session/agent */
2213
2650
  disconnect(): void;
2651
+ /**
2652
+ * Detach the session from connection events without disconnecting the connection.
2653
+ * This should be called when the session is being replaced but the connection is shared.
2654
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
2655
+ */
2656
+ detach(): void;
2214
2657
  /** Symbol.dispose for 'using' keyword support */
2215
2658
  [Symbol.dispose](): void;
2216
2659
  }
@@ -2275,6 +2718,17 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2275
2718
  rename?(agentId: string, title: string): Promise<{
2276
2719
  id: string;
2277
2720
  }>;
2721
+ /**
2722
+ * Update agent status by ID (optional)
2723
+ * Used by CloudAgentProvider for updating session status
2724
+ *
2725
+ * @param agentId - Agent ID to update
2726
+ * @param status - New status for the agent
2727
+ * @returns Object containing the updated agent ID
2728
+ */
2729
+ updateStatus?(agentId: string, status: string): Promise<{
2730
+ id: string;
2731
+ }>;
2278
2732
  /**
2279
2733
  * Move an agent by ID (optional)
2280
2734
  * Used by LocalAgentProvider for moving Playground sessions to Workspace
@@ -2294,6 +2748,34 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2294
2748
  * @returns Array of model information
2295
2749
  */
2296
2750
  getModels?(repo?: string): Promise<ModelInfo[]>;
2751
+ /**
2752
+ * Get product configuration subset (optional)
2753
+ * Returns deploymentType, creditPurchaseActions, links, networkEnvironment, productFeatures
2754
+ */
2755
+ getProductConfiguration?(): Promise<{
2756
+ deploymentType?: string;
2757
+ creditPurchaseActions?: Record<string, {
2758
+ labelZh: string;
2759
+ labelEn: string;
2760
+ url: string;
2761
+ showButton?: boolean;
2762
+ }>;
2763
+ links?: {
2764
+ craftFeedback?: string;
2765
+ mcpMarketUrl?: string;
2766
+ mcpDocumentUrl?: string;
2767
+ helpDocument?: string;
2768
+ };
2769
+ networkEnvironment?: string;
2770
+ productFeatures?: Record<string, boolean>;
2771
+ }>;
2772
+ /**
2773
+ * Get user info (optional)
2774
+ * Returns enterpriseId from authentication session
2775
+ */
2776
+ getUserInfo?(): Promise<{
2777
+ enterpriseId?: string;
2778
+ }>;
2297
2779
  /**
2298
2780
  * Register sessionId → agentId mapping (optional, used by LocalAgentProvider)
2299
2781
  * Called after session creation to maintain the mapping for loadSession
@@ -2309,6 +2791,8 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2309
2791
  * @returns Response with success status
2310
2792
  */
2311
2793
  openWorkspace?(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
2794
+ /** Request yielding after current step for a running session (optional, used by LocalAgentProvider) */
2795
+ requestYieldAfterCurrentStep?(sessionId: string): Promise<boolean>;
2312
2796
  /**
2313
2797
  * Pick files from file dialog (optional, used by LocalAgentProvider)
2314
2798
  *
@@ -2344,6 +2828,61 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2344
2828
  * @returns Response with subagent list
2345
2829
  */
2346
2830
  getSubagentList?(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
2831
+ /**
2832
+ * Get skill list (optional, used by LocalAgentProvider)
2833
+ *
2834
+ * @param params - Query parameters
2835
+ * @returns Response with skill list
2836
+ */
2837
+ getSkillList?(params?: GetSkillListParams): Promise<GetSkillListResponse>;
2838
+ /**
2839
+ * Import a skill folder (optional, used by LocalAgentProvider)
2840
+ *
2841
+ * @param params - Import parameters including source location
2842
+ * @returns Response with import result
2843
+ */
2844
+ importSkill?(params: ImportSkillParams): Promise<ImportSkillResponse>;
2845
+ /**
2846
+ * Get skill content by file path (optional, used by LocalAgentProvider)
2847
+ *
2848
+ * @param params - Parameters including skill file path
2849
+ * @returns Response with skill content
2850
+ */
2851
+ getSkillContent?(params: GetSkillContentParams): Promise<GetSkillContentResponse>;
2852
+ /**
2853
+ * Get marketplace skills list (optional, used by LocalAgentProvider)
2854
+ *
2855
+ * @returns Response with marketplace skill list
2856
+ */
2857
+ getMarketplaceSkills?(): Promise<GetMarketplaceSkillsResponse>;
2858
+ /**
2859
+ * Get marketplace skill content (optional, used by LocalAgentProvider)
2860
+ *
2861
+ * @param params - Parameters including skill name
2862
+ * @returns Response with skill content
2863
+ */
2864
+ getMarketplaceSkillContent?(params: GetMarketplaceSkillContentParams): Promise<GetMarketplaceSkillContentResponse>;
2865
+ /**
2866
+ * Install marketplace skill to user directory (optional, used by LocalAgentProvider)
2867
+ *
2868
+ * @param params - Parameters including skill name
2869
+ * @returns Response with install result
2870
+ */
2871
+ installMarketplaceSkill?(params: InstallMarketplaceSkillParams): Promise<InstallMarketplaceSkillResponse>;
2872
+ /**
2873
+ * Toggle skill enable/disable state (optional, used by LocalAgentProvider)
2874
+ *
2875
+ * @param params - Toggle parameters including filePath and disable state
2876
+ * @returns Response with toggle result
2877
+ */
2878
+ toggleSkill?(params: ToggleSkillParams): Promise<ToggleSkillResponse>;
2879
+ /**
2880
+ * Delete a skill (optional, used by LocalAgentProvider)
2881
+ *
2882
+ * @param params - Delete parameters including filePath and name
2883
+ * @returns Response with delete result
2884
+ */
2885
+ deleteSkill?(params: DeleteSkillParams): Promise<DeleteSkillResponse>;
2347
2886
  /**
2348
2887
  * Batch toggle plugins (optional, used by LocalAgentProvider)
2349
2888
  *
@@ -2364,6 +2903,9 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2364
2903
  description?: string;
2365
2904
  version?: string;
2366
2905
  installScope?: 'user' | 'project';
2906
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
2907
+ installedScopesStatus?: Record<string, boolean>;
2908
+ installId?: string;
2367
2909
  }>>;
2368
2910
  /**
2369
2911
  * Install plugins (optional, used by LocalAgentProvider)
@@ -2374,7 +2916,7 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2374
2916
  * @param marketplaceSource - Marketplace source URL (for auto-adding marketplace when not exists)
2375
2917
  * @returns Result of the operation
2376
2918
  */
2377
- installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string): Promise<{
2919
+ installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2378
2920
  success: boolean;
2379
2921
  error?: string;
2380
2922
  }>;
@@ -2383,10 +2925,34 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2383
2925
  * If session.availableCommands has cached values, return them
2384
2926
  * Otherwise, fetch from product configuration
2385
2927
  *
2386
- * @param sessionId - Session ID to get commands for (optional, for global commands)
2928
+ * @param params - Parameters for getting commands
2387
2929
  * @returns Array of available commands
2388
2930
  */
2389
- getAvailableCommands?(sessionId?: string): Promise<AvailableCommand[]>;
2931
+ getAvailableCommands?(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
2932
+ /**
2933
+ * Get automation snapshot (optional, used by LocalAgentProvider)
2934
+ */
2935
+ getAutomationSnapshot?(): Promise<AutomationSnapshot>;
2936
+ /**
2937
+ * Create/update automation definition (optional, used by LocalAgentProvider)
2938
+ */
2939
+ updateAutomation?(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
2940
+ /**
2941
+ * Delete automation definition (optional, used by LocalAgentProvider)
2942
+ */
2943
+ deleteAutomation?(id: string): Promise<AutomationUpdateResult>;
2944
+ /**
2945
+ * Archive an automation inbox item (optional, used by LocalAgentProvider)
2946
+ */
2947
+ archiveAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
2948
+ /**
2949
+ * Delete an automation inbox item (optional, used by LocalAgentProvider)
2950
+ */
2951
+ deleteAutomationInboxItem?(itemId: string): Promise<AutomationUpdateResult>;
2952
+ /**
2953
+ * Trigger test run for automation (optional, used by LocalAgentProvider)
2954
+ */
2955
+ testAutomation?(id: string): Promise<AutomationUpdateResult>;
2390
2956
  /**
2391
2957
  * Register an event listener
2392
2958
  * Provider implementations should forward events to the underlying transport
@@ -2402,6 +2968,131 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
2402
2968
  * @param handler - Event handler function to remove
2403
2969
  */
2404
2970
  off?(event: string, handler: (...args: any[]) => void): void;
2971
+ /**
2972
+ * Report telemetry event through the provider chain
2973
+ * - Local: via ACP JSON-RPC → AcpAgent → IDE EventService
2974
+ * - Cloud: via connection → cloud endpoint
2975
+ *
2976
+ * @param eventName - Event name / code
2977
+ * @param payload - Event data
2978
+ */
2979
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
2980
+ /**
2981
+ * Respond to MCP Sampling confirmation request (optional, used by LocalAgentProvider)
2982
+ * Called when user confirms/rejects a sampling request
2983
+ *
2984
+ * @param sessionId - Session ID
2985
+ * @param response - Sampling confirmation response
2986
+ */
2987
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
2988
+ /**
2989
+ * Respond to MCP Roots confirmation request (optional, used by LocalAgentProvider)
2990
+ * Called when user confirms/rejects a roots request
2991
+ *
2992
+ * @param sessionId - Session ID
2993
+ * @param response - Roots confirmation response
2994
+ */
2995
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
2996
+ /**
2997
+ * Subscribe to MCP Sampling confirmation requests (optional, used by LocalAgentProvider)
2998
+ * Called when MCP server initiates a sampling request
2999
+ *
3000
+ * @param serverName - MCP server name
3001
+ * @param callback - Request callback
3002
+ * @returns Unsubscribe function
3003
+ */
3004
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
3005
+ /**
3006
+ * Subscribe to MCP Roots confirmation requests (optional, used by LocalAgentProvider)
3007
+ * Called when MCP server initiates a roots request
3008
+ *
3009
+ * @param serverName - MCP server name
3010
+ * @param callback - Request callback
3011
+ * @returns Unsubscribe function
3012
+ */
3013
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
3014
+ /**
3015
+ * Get product scenes from ProductManager configuration (optional, for LocalAgentProvider)
3016
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
3017
+ * @param locale - 可选,语言环境
3018
+ */
3019
+ getProductScenes?(locale?: string): Promise<Array<{
3020
+ id: number;
3021
+ name: string;
3022
+ plugins: Array<{
3023
+ id: number;
3024
+ name: string;
3025
+ marketplaceName: string;
3026
+ }>;
3027
+ prompts: string[];
3028
+ mode?: 'coding' | 'working';
3029
+ target?: 'local' | 'cloud' | 'all';
3030
+ }>>;
3031
+ /**
3032
+ * Get all MCP servers with their status and tools (optional, used by LocalAgentProvider)
3033
+ * Returns the list of configured MCP servers from McpServerManager
3034
+ *
3035
+ * @returns Array of MCP server information
3036
+ */
3037
+ getMcpServers?(): Promise<Array<{
3038
+ id: string;
3039
+ name: string;
3040
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
3041
+ description?: string;
3042
+ tools?: Array<{
3043
+ name: string;
3044
+ description?: string;
3045
+ enabled?: boolean;
3046
+ }>;
3047
+ disabled?: boolean;
3048
+ error?: string;
3049
+ logoUrl?: string;
3050
+ officialUrl?: string;
3051
+ configSource?: 'user' | 'project' | 'plugin';
3052
+ }>>;
3053
+ /**
3054
+ * Toggle MCP server enabled/disabled state (optional, used by LocalAgentProvider)
3055
+ *
3056
+ * @param serverName - Name of the MCP server to toggle
3057
+ * @param enabled - Whether to enable (true) or disable (false) the server
3058
+ */
3059
+ toggleMcpServer?(serverName: string, enabled: boolean): Promise<void>;
3060
+ /**
3061
+ * Reconnect to an MCP server (optional, used by LocalAgentProvider)
3062
+ *
3063
+ * @param serverName - Name of the MCP server to reconnect
3064
+ * @param forceHttpCallback - Force using HTTP callback instead of URL scheme
3065
+ */
3066
+ reconnectMcpServer?(serverName: string, forceHttpCallback?: boolean): Promise<void>;
3067
+ /**
3068
+ * Delete an MCP server configuration (optional, used by LocalAgentProvider)
3069
+ *
3070
+ * @param serverName - Name of the MCP server to delete
3071
+ */
3072
+ deleteMcpServer?(serverName: string): Promise<void>;
3073
+ /**
3074
+ * Open the MCP configuration file in editor (optional, used by LocalAgentProvider)
3075
+ * Executes 'codebuddy.openMcpConfig' command
3076
+ */
3077
+ openMcpConfig?(): Promise<void>;
3078
+ /**
3079
+ * Get MCP configuration file content
3080
+ * @returns File path and content
3081
+ */
3082
+ getMcpConfigContent?(): Promise<{
3083
+ filePath: string;
3084
+ content: string;
3085
+ }>;
3086
+ /**
3087
+ * Save MCP configuration file content
3088
+ * @param content New configuration content
3089
+ */
3090
+ saveMcpConfigContent?(content: string): Promise<void>;
3091
+ /**
3092
+ * Read text from clipboard (optional, used by LocalAgentProvider for webview clipboard access)
3093
+ * @returns Clipboard text content
3094
+ */
3095
+ clipboardReadText?(): Promise<string>;
2405
3096
  }
2406
3097
  /**
2407
3098
  * AgentClient initialization options
@@ -2459,6 +3150,15 @@ interface ClientSessionsResource {
2459
3150
  rename(sessionId: string, title: string): Promise<{
2460
3151
  id: string;
2461
3152
  }>;
3153
+ /**
3154
+ * Update session status
3155
+ * @param sessionId - Session ID to update
3156
+ * @param status - New status for the session
3157
+ * @returns Object containing the updated session ID
3158
+ */
3159
+ updateStatus(sessionId: string, status: string): Promise<{
3160
+ id: string;
3161
+ }>;
2462
3162
  /**
2463
3163
  * Move a session (Playground → Workspace)
2464
3164
  * @param sessionId - Session ID to move
@@ -2469,6 +3169,8 @@ interface ClientSessionsResource {
2469
3169
  }>;
2470
3170
  /** Initialize a workspace for future sessions */
2471
3171
  initializeWorkspace(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
3172
+ /** Request yielding after current step for a running session */
3173
+ requestYieldAfterCurrentStep(sessionId: string): Promise<boolean>;
2472
3174
  /** Models resource for getting available models */
2473
3175
  readonly models: ModelsResource;
2474
3176
  /** Get current workspaces list */
@@ -2491,6 +3193,22 @@ interface ClientSessionsResource {
2491
3193
  searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
2492
3194
  /** Get subagent list (for LocalAgentProvider) */
2493
3195
  getSubagentList(params: GetSubagentListParams): Promise<GetSubagentListResponse>;
3196
+ /** Get skill list (for LocalAgentProvider) */
3197
+ getSkillList(params?: GetSkillListParams): Promise<GetSkillListResponse>;
3198
+ /** Import a skill folder (for LocalAgentProvider) */
3199
+ importSkill(params: ImportSkillParams): Promise<ImportSkillResponse>;
3200
+ /** Toggle skill enable/disable state (for LocalAgentProvider) */
3201
+ toggleSkill(params: ToggleSkillParams): Promise<ToggleSkillResponse>;
3202
+ /** Delete a skill (for LocalAgentProvider) */
3203
+ deleteSkill(params: DeleteSkillParams): Promise<DeleteSkillResponse>;
3204
+ /** Get skill content by file path (for LocalAgentProvider) */
3205
+ getSkillContent(params: GetSkillContentParams): Promise<GetSkillContentResponse>;
3206
+ /** Get marketplace skills list (for LocalAgentProvider) */
3207
+ getMarketplaceSkills(): Promise<GetMarketplaceSkillsResponse>;
3208
+ /** Get marketplace skill content (for LocalAgentProvider) */
3209
+ getMarketplaceSkillContent(params: GetMarketplaceSkillContentParams): Promise<GetMarketplaceSkillContentResponse>;
3210
+ /** Install marketplace skill to user directory (for LocalAgentProvider) */
3211
+ installMarketplaceSkill(params: InstallMarketplaceSkillParams): Promise<InstallMarketplaceSkillResponse>;
2494
3212
  /** Batch toggle plugins (for LocalAgentProvider) */
2495
3213
  batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
2496
3214
  /** Get installed plugins (for LocalAgentProvider) */
@@ -2501,34 +3219,388 @@ interface ClientSessionsResource {
2501
3219
  description?: string;
2502
3220
  version?: string;
2503
3221
  installScope?: 'user' | 'project';
3222
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
3223
+ installedScopesStatus?: Record<string, boolean>;
3224
+ installId?: string;
2504
3225
  }>>;
2505
3226
  /** Install plugins (for LocalAgentProvider) */
2506
- installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string): Promise<{
3227
+ installPlugins(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project', marketplaceSource?: string, workspacePath?: string): Promise<{
2507
3228
  success: boolean;
2508
3229
  error?: string;
2509
3230
  }>;
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;
3231
+ /** Uninstall a plugin (for LocalAgentProvider) */
3232
+ uninstallPlugin?(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
3233
+ success: boolean;
3234
+ error?: string;
3235
+ }>;
3236
+ /** Update a plugin to the latest version (for LocalAgentProvider) */
3237
+ updatePlugin?(pluginName: string, marketplaceName: string): Promise<{
3238
+ success: boolean;
3239
+ error?: string;
3240
+ }>;
3241
+ /** Get plugin marketplaces list (for LocalAgentProvider) */
3242
+ getPluginMarketplaces?(forceRefresh?: boolean): Promise<Array<{
3243
+ id: string;
2516
3244
  name: string;
2517
- plugins: Array<{
2518
- id: number;
2519
- name: string;
2520
- marketplaceName: string;
2521
- }>;
2522
- prompts: string[];
3245
+ type: 'github' | 'local' | 'custom';
3246
+ source: {
3247
+ repo?: string;
3248
+ ref?: string;
3249
+ url?: string;
3250
+ };
3251
+ description?: string;
3252
+ isBuiltin?: boolean;
2523
3253
  }>>;
2524
- /**
2525
- * Get available commands for a session
2526
- * If session.availableCommands has cached values, return them
2527
- * Otherwise, fetch from provider (for LocalAgentProvider)
2528
- * @param sessionId - Session ID to get commands for (optional, for global commands)
3254
+ /** Get plugins from a marketplace (for LocalAgentProvider) */
3255
+ getMarketplacePlugins?(marketplaceName: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
3256
+ name: string;
3257
+ marketplaceName: string;
3258
+ description?: string;
3259
+ version?: string;
3260
+ author?: string;
3261
+ homepage?: string;
3262
+ iconUrl?: string;
3263
+ tags?: string[];
3264
+ installed?: boolean;
3265
+ status?: 'enabled' | 'disabled' | 'not-installed';
3266
+ installedScopes?: Array<'user' | 'project'>;
3267
+ hasUpdate?: boolean;
3268
+ }>>;
3269
+ /** Get plugin detail (for LocalAgentProvider) */
3270
+ getPluginDetail?(pluginName: string, marketplaceName: string): Promise<{
3271
+ name: string;
3272
+ marketplaceName: string;
3273
+ description?: string;
3274
+ version?: string;
3275
+ author?: string;
3276
+ homepage?: string;
3277
+ readme?: string;
3278
+ tools?: Array<{
3279
+ name: string;
3280
+ description?: string;
3281
+ }>;
3282
+ resources?: Array<{
3283
+ name: string;
3284
+ description?: string;
3285
+ }>;
3286
+ prompts?: Array<{
3287
+ name: string;
3288
+ description?: string;
3289
+ }>;
3290
+ installed?: boolean;
3291
+ status?: 'enabled' | 'disabled' | 'not-installed';
3292
+ } | null>;
3293
+ /** Add a plugin marketplace (for LocalAgentProvider) */
3294
+ addPluginMarketplace?(source: string, name?: string): Promise<{
3295
+ success: boolean;
3296
+ error?: string;
3297
+ marketplace?: {
3298
+ id: string;
3299
+ name: string;
3300
+ type: 'github' | 'local' | 'custom';
3301
+ source: {
3302
+ repo?: string;
3303
+ ref?: string;
3304
+ url?: string;
3305
+ };
3306
+ description?: string;
3307
+ isBuiltin?: boolean;
3308
+ };
3309
+ }>;
3310
+ /** Remove a plugin marketplace (for LocalAgentProvider) */
3311
+ removePluginMarketplace?(marketplaceName: string): Promise<{
3312
+ success: boolean;
3313
+ error?: string;
3314
+ }>;
3315
+ /** Refresh a plugin marketplace (for LocalAgentProvider) */
3316
+ refreshPluginMarketplace?(marketplaceName: string): Promise<{
3317
+ success: boolean;
3318
+ error?: string;
3319
+ plugins?: Array<{
3320
+ name: string;
3321
+ marketplaceName: string;
3322
+ description?: string;
3323
+ version?: string;
3324
+ installed?: boolean;
3325
+ status?: 'enabled' | 'disabled' | 'not-installed';
3326
+ }>;
3327
+ }>;
3328
+ /** Open folder in new window (for LocalAgentProvider) */
3329
+ openFolderInNewWindow?(folderPath: string): Promise<void>;
3330
+ /** Open folder in system file manager (for LocalAgentProvider) */
3331
+ openFolder?(folderPath: string): Promise<boolean>;
3332
+ /**
3333
+ * Get support scenes from backend API (for LocalAgentProvider)
3334
+ * API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
3335
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
3336
+ */
3337
+ getSupportScenes(locale?: string): Promise<Array<{
3338
+ id: number;
3339
+ name: string;
3340
+ plugins: Array<{
3341
+ id: number;
3342
+ name: string;
3343
+ marketplaceName: string;
3344
+ }>;
3345
+ prompts: string[];
3346
+ mode?: 'coding' | 'working';
3347
+ }>>;
3348
+ /**
3349
+ * Get product scenes from ProductManager configuration (for LocalAgentProvider)
3350
+ * 从 ProductManager.waitConfiguration().scenes 获取本地配置的场景数据
3351
+ * @param locale - 可选,语言环境
3352
+ */
3353
+ getProductScenes?(locale?: string): Promise<Array<{
3354
+ id: number;
3355
+ name: string;
3356
+ plugins: Array<{
3357
+ id: number;
3358
+ name: string;
3359
+ marketplaceName: string;
3360
+ }>;
3361
+ prompts: string[];
3362
+ mode?: 'coding' | 'working';
3363
+ target?: 'local' | 'cloud' | 'all';
3364
+ }>>;
3365
+ /**
3366
+ * Get available commands for a session
3367
+ * If session.availableCommands has cached values, return them
3368
+ * Otherwise, fetch from provider (for LocalAgentProvider)
3369
+ * @param params - Parameters for getting commands
2529
3370
  * @returns Promise<AvailableCommand[]> - Array of available commands
2530
3371
  */
2531
- getAvailableCommands(sessionId?: string): Promise<AvailableCommand[]>;
3372
+ getAvailableCommands(params?: GetAvailableCommandsParams): Promise<AvailableCommand[]>;
3373
+ /**
3374
+ * Get automation snapshot
3375
+ */
3376
+ getAutomationSnapshot(): Promise<AutomationSnapshot>;
3377
+ /**
3378
+ * Create/update automation definition
3379
+ */
3380
+ updateAutomation(payload: AutomationUpdatePayload): Promise<AutomationUpdateResult>;
3381
+ /**
3382
+ * Delete automation definition
3383
+ */
3384
+ deleteAutomation(id: string): Promise<AutomationUpdateResult>;
3385
+ /**
3386
+ * Archive automation inbox item
3387
+ */
3388
+ archiveAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
3389
+ /**
3390
+ * Delete automation inbox item
3391
+ */
3392
+ deleteAutomationInboxItem(itemId: string): Promise<AutomationUpdateResult>;
3393
+ /**
3394
+ * Trigger automation test run
3395
+ */
3396
+ testAutomation(id: string): Promise<AutomationUpdateResult>;
3397
+ /**
3398
+ * Report telemetry event through the provider chain
3399
+ * Delegates to AgentProvider.reportTelemetry()
3400
+ *
3401
+ * @param eventName - Event name / code
3402
+ * @param payload - Event data
3403
+ */
3404
+ reportTelemetry?(eventName: string, payload: Record<string, unknown>): Promise<void>;
3405
+ /**
3406
+ * Get product configuration subset
3407
+ * Returns deploymentType, creditPurchaseActions, links, productFeatures
3408
+ * Used by agent-ui for error banner credit purchase guidance
3409
+ */
3410
+ getProductConfiguration?(): Promise<{
3411
+ deploymentType?: string;
3412
+ creditPurchaseActions?: Record<string, {
3413
+ labelZh: string;
3414
+ labelEn: string;
3415
+ url: string;
3416
+ showButton?: boolean;
3417
+ }>;
3418
+ links?: {
3419
+ craftFeedback?: string;
3420
+ mcpMarketUrl?: string;
3421
+ mcpDocumentUrl?: string;
3422
+ helpDocument?: string;
3423
+ };
3424
+ networkEnvironment?: string;
3425
+ productFeatures?: Record<string, boolean>;
3426
+ }>;
3427
+ /**
3428
+ * Get user info
3429
+ * Returns enterpriseId from authentication session
3430
+ * Used by agent-ui for determining personal/enterprise user
3431
+ */
3432
+ getUserInfo?(): Promise<{
3433
+ enterpriseId?: string;
3434
+ }>;
3435
+ /**
3436
+ * Respond to MCP Sampling confirmation request
3437
+ * Called when user confirms/rejects a sampling request in MCP tool renderer
3438
+ *
3439
+ * @param sessionId - Session ID
3440
+ * @param response - Sampling confirmation response
3441
+ */
3442
+ respondToSampling?(sessionId: string, response: McpSamplingConfirmResponse): Promise<void>;
3443
+ /**
3444
+ * Respond to MCP Roots confirmation request
3445
+ * Called when user confirms/rejects a roots request in MCP tool renderer
3446
+ *
3447
+ * @param sessionId - Session ID
3448
+ * @param response - Roots confirmation response
3449
+ */
3450
+ respondToRoots?(sessionId: string, response: McpRootsConfirmResponse): Promise<void>;
3451
+ /**
3452
+ * Subscribe to MCP Sampling confirmation requests
3453
+ * Called when MCP server initiates a sampling request
3454
+ *
3455
+ * @param serverName - MCP server name
3456
+ * @param callback - Request callback
3457
+ * @returns Unsubscribe function
3458
+ */
3459
+ subscribeSamplingRequests?(serverName: string, callback: (request: McpSamplingConfirmRequest) => void): () => void;
3460
+ /**
3461
+ * Subscribe to MCP Roots confirmation requests
3462
+ * Called when MCP server initiates a roots request
3463
+ *
3464
+ * @param serverName - MCP server name
3465
+ * @param callback - Request callback
3466
+ * @returns Unsubscribe function
3467
+ */
3468
+ subscribeRootsRequests?(serverName: string, callback: (request: McpRootsConfirmRequest) => void): () => void;
3469
+ /**
3470
+ * Get MCP servers list
3471
+ * Returns the list of configured MCP servers with their status
3472
+ *
3473
+ * @returns Promise<McpServerInfo[]> - Array of MCP server info
3474
+ */
3475
+ getMcpServers?(): Promise<McpServerInfo[]>;
3476
+ /**
3477
+ * Toggle MCP server enabled/disabled state
3478
+ *
3479
+ * @param serverName - Server name
3480
+ * @param enabled - Whether to enable the server
3481
+ */
3482
+ toggleMcpServer?(serverName: string, enabled: boolean): Promise<void>;
3483
+ /**
3484
+ * Reconnect to an MCP server
3485
+ *
3486
+ * @param serverName - Server name
3487
+ * @param forceHttpCallback - Force using HTTP callback instead of URL scheme
3488
+ */
3489
+ reconnectMcpServer?(serverName: string, forceHttpCallback?: boolean): Promise<void>;
3490
+ /**
3491
+ * Delete an MCP server configuration
3492
+ *
3493
+ * @param serverName - Server name
3494
+ */
3495
+ deleteMcpServer?(serverName: string): Promise<void>;
3496
+ /**
3497
+ * Open MCP configuration file in editor
3498
+ */
3499
+ openMcpConfig?(): Promise<void>;
3500
+ /**
3501
+ * Get MCP configuration file content
3502
+ * @returns File path and content
3503
+ */
3504
+ getMcpConfigContent?(): Promise<{
3505
+ filePath: string;
3506
+ content: string;
3507
+ }>;
3508
+ /**
3509
+ * Save MCP configuration file content
3510
+ * @param content New configuration content
3511
+ */
3512
+ saveMcpConfigContent?(content: string): Promise<void>;
3513
+ /**
3514
+ * Read text from clipboard (optional, used by LocalAgentProvider for webview clipboard access)
3515
+ * @returns Clipboard text content
3516
+ */
3517
+ clipboardReadText?(): Promise<string>;
3518
+ }
3519
+ /**
3520
+ * MCP Sampling message role
3521
+ */
3522
+ type McpSamplingRole = 'user' | 'assistant';
3523
+ /**
3524
+ * MCP Sampling message content - text
3525
+ */
3526
+ interface McpSamplingTextContent {
3527
+ type: 'text';
3528
+ text: string;
3529
+ }
3530
+ /**
3531
+ * MCP Sampling message content - image
3532
+ */
3533
+ interface McpSamplingImageContent {
3534
+ type: 'image';
3535
+ data: string;
3536
+ mimeType: string;
3537
+ }
3538
+ /**
3539
+ * MCP Sampling message content - audio
3540
+ */
3541
+ interface McpSamplingAudioContent {
3542
+ type: 'audio';
3543
+ data: string;
3544
+ mimeType: string;
3545
+ }
3546
+ /**
3547
+ * MCP Sampling message content union type
3548
+ */
3549
+ type McpSamplingContent = McpSamplingTextContent | McpSamplingImageContent | McpSamplingAudioContent;
3550
+ /**
3551
+ * MCP Sampling message
3552
+ */
3553
+ interface McpSamplingMessage {
3554
+ role: McpSamplingRole;
3555
+ content: McpSamplingContent;
3556
+ }
3557
+ /**
3558
+ * MCP Sampling confirmation request
3559
+ * Sent from backend when MCP server requests sampling
3560
+ */
3561
+ interface McpSamplingConfirmRequest {
3562
+ id: string;
3563
+ serverName: string;
3564
+ model?: string;
3565
+ messages: McpSamplingMessage[];
3566
+ systemPrompt?: string;
3567
+ maxTokens: number;
3568
+ timestamp: number;
3569
+ }
3570
+ /**
3571
+ * MCP Sampling confirmation response
3572
+ * Sent from frontend when user confirms/rejects
3573
+ */
3574
+ interface McpSamplingConfirmResponse {
3575
+ id: string;
3576
+ approved: boolean;
3577
+ rememberChoice?: boolean;
3578
+ }
3579
+ /**
3580
+ * MCP Root definition
3581
+ */
3582
+ interface McpRoot {
3583
+ uri: string;
3584
+ name?: string;
3585
+ }
3586
+ /**
3587
+ * MCP Roots confirmation request
3588
+ * Sent from backend when MCP server requests roots access
3589
+ */
3590
+ interface McpRootsConfirmRequest {
3591
+ id: string;
3592
+ serverName: string;
3593
+ roots: McpRoot[];
3594
+ timestamp: number;
3595
+ }
3596
+ /**
3597
+ * MCP Roots confirmation response
3598
+ * Sent from frontend when user confirms/rejects
3599
+ */
3600
+ interface McpRootsConfirmResponse {
3601
+ id: string;
3602
+ approved: boolean;
3603
+ rememberChoice?: boolean;
2532
3604
  }
2533
3605
  /**
2534
3606
  * Workspace information (aligned with FolderSelectResult)
@@ -2594,6 +3666,8 @@ interface PickFolderResponse {
2594
3666
  interface UploadFileParams {
2595
3667
  /** Files to upload - File objects in browser, absolute path strings in IDE */
2596
3668
  readonly files: Array<File | string>;
3669
+ /** Optional AbortSignal to cancel the upload */
3670
+ readonly abortSignal?: AbortSignal;
2597
3671
  }
2598
3672
  /**
2599
3673
  * Response from uploading files
@@ -2607,6 +3681,8 @@ interface UploadFileResponse {
2607
3681
  readonly expireSeconds?: number;
2608
3682
  /** Error message (if upload failed) */
2609
3683
  readonly error?: string;
3684
+ /** Whether the upload was cancelled by user */
3685
+ readonly aborted?: boolean;
2610
3686
  }
2611
3687
  /**
2612
3688
  * Mention type for file/folder
@@ -2703,6 +3779,229 @@ interface GetSubagentListResponse {
2703
3779
  /** Error message (if failed) */
2704
3780
  readonly error?: string;
2705
3781
  }
3782
+ /**
3783
+ * Skill info returned from getSkillList
3784
+ */
3785
+ interface SkillInfo {
3786
+ /** Skill name */
3787
+ name: string;
3788
+ /** File path of the skill */
3789
+ filePath: string;
3790
+ /** Description of the skill */
3791
+ description: string;
3792
+ /** When to use the skill */
3793
+ whenToUse?: string;
3794
+ /** Source of the skill */
3795
+ source: 'localSettings' | 'userSettings' | 'plugin' | 'builtin';
3796
+ /** Skill type */
3797
+ type: 'prompt';
3798
+ /** License information */
3799
+ license?: string;
3800
+ /** Allowed tools */
3801
+ allowedTools?: string[];
3802
+ /** Whether the skill is disabled */
3803
+ disable?: boolean;
3804
+ }
3805
+ /**
3806
+ * Parameters for getting skill list
3807
+ */
3808
+ interface GetSkillListParams {
3809
+ /** Working directory (optional, for filtering project-level skills) */
3810
+ readonly cwd?: string;
3811
+ /** Whether to use global (backend) channel, defaults to true. When false, uses sendBroadcastRequest. */
3812
+ readonly global?: boolean;
3813
+ /** Whether to exclude plugin skills from the result, defaults to false. */
3814
+ readonly excludePluginSkills?: boolean;
3815
+ /**
3816
+ * 用户级 skill 扫描目录名称列表(相对于 home 目录),按优先级从高到低排列。
3817
+ * 同名 skill 以高优先级目录为准。
3818
+ * 未传入或为空时使用产品默认目录。
3819
+ */
3820
+ readonly skillScanDirs?: string[];
3821
+ }
3822
+ /**
3823
+ * Response from getting skill list
3824
+ */
3825
+ interface GetSkillListResponse {
3826
+ /** Skill list */
3827
+ readonly results: SkillInfo[];
3828
+ /** Error message (if failed) */
3829
+ readonly error?: string;
3830
+ }
3831
+ /**
3832
+ * Parameters for importing a skill folder
3833
+ */
3834
+ interface ImportSkillParams {
3835
+ /** Source location: project-level or user-level */
3836
+ readonly source: 'localSettings' | 'userSettings';
3837
+ /** Working directory (required when source is localSettings). */
3838
+ readonly cwd?: string;
3839
+ /** 直接传入文件夹路径(拖拽导入时使用),有此字段时跳过系统文件选择器 */
3840
+ readonly folderPath?: string;
3841
+ }
3842
+ /**
3843
+ * Response from importing a skill folder
3844
+ */
3845
+ interface ImportSkillResponse {
3846
+ /** Whether the import was successful */
3847
+ readonly success: boolean;
3848
+ /** Error message (if failed) */
3849
+ readonly error?: string;
3850
+ /** Imported skill name */
3851
+ readonly skillName?: string;
3852
+ }
3853
+ /**
3854
+ * Parameters for toggling skill enable/disable state
3855
+ */
3856
+ interface ToggleSkillParams {
3857
+ /** File path of the skill to toggle */
3858
+ readonly filePath: string;
3859
+ /** Whether to disable the skill */
3860
+ readonly disable: boolean;
3861
+ }
3862
+ /**
3863
+ * Response from toggling skill state
3864
+ */
3865
+ interface ToggleSkillResponse {
3866
+ /** Whether the toggle was successful */
3867
+ readonly success: boolean;
3868
+ /** Error message (if failed) */
3869
+ readonly error?: string;
3870
+ }
3871
+ /**
3872
+ * Parameters for deleting a skill
3873
+ */
3874
+ interface DeleteSkillParams {
3875
+ /** File path of the skill to delete */
3876
+ readonly filePath: string;
3877
+ /** Name of the skill */
3878
+ readonly name: string;
3879
+ }
3880
+ /**
3881
+ * Response from deleting a skill
3882
+ */
3883
+ interface DeleteSkillResponse {
3884
+ /** Whether the deletion was successful */
3885
+ readonly success: boolean;
3886
+ /** Error message (if failed) */
3887
+ readonly error?: string;
3888
+ }
3889
+ /**
3890
+ * Parameters for getting skill content
3891
+ */
3892
+ interface GetSkillContentParams {
3893
+ /** File path of the skill */
3894
+ readonly filePath: string;
3895
+ }
3896
+ /**
3897
+ * Response from getting skill content
3898
+ */
3899
+ interface GetSkillContentResponse {
3900
+ /** Skill file content */
3901
+ readonly content: string;
3902
+ /** Error message (if failed) */
3903
+ readonly error?: string;
3904
+ }
3905
+ /**
3906
+ * Marketplace skill info (simplified structure for UI layer)
3907
+ */
3908
+ interface MarketplaceSkillInfo {
3909
+ /** Skill name */
3910
+ name: string;
3911
+ /** Skill description */
3912
+ description: string;
3913
+ /** Skill description in Chinese */
3914
+ description_zh?: string;
3915
+ /** Skill description in English */
3916
+ description_en?: string;
3917
+ /** Skill version */
3918
+ version?: string;
3919
+ /** Skill author */
3920
+ author?: string;
3921
+ /** Skill icon URL */
3922
+ iconUrl?: string;
3923
+ /** Skill tags */
3924
+ tags?: string[];
3925
+ }
3926
+ /**
3927
+ * Response from getting marketplace skills
3928
+ */
3929
+ interface GetMarketplaceSkillsResponse {
3930
+ /** Marketplace skill list */
3931
+ readonly results: MarketplaceSkillInfo[];
3932
+ /** Error message (if failed) */
3933
+ readonly error?: string;
3934
+ }
3935
+ /**
3936
+ * Parameters for getting marketplace skill content
3937
+ */
3938
+ interface GetMarketplaceSkillContentParams {
3939
+ /** Skill name */
3940
+ readonly skillName: string;
3941
+ }
3942
+ /**
3943
+ * Response from getting marketplace skill content
3944
+ */
3945
+ interface GetMarketplaceSkillContentResponse {
3946
+ /** Skill file content */
3947
+ readonly content: string;
3948
+ /** Error message (if failed) */
3949
+ readonly error?: string;
3950
+ }
3951
+ /**
3952
+ * Parameters for installing marketplace skill
3953
+ */
3954
+ interface InstallMarketplaceSkillParams {
3955
+ /** Skill name to install */
3956
+ readonly skillName: string;
3957
+ }
3958
+ /**
3959
+ * Response from installing marketplace skill
3960
+ */
3961
+ interface InstallMarketplaceSkillResponse {
3962
+ /** Whether the install was successful */
3963
+ readonly success: boolean;
3964
+ /** Skill name */
3965
+ readonly skillName: string;
3966
+ /** Error message (if failed) */
3967
+ readonly errorMessage?: string;
3968
+ }
3969
+ /**
3970
+ * MCP Tool information
3971
+ */
3972
+ interface McpToolInfo {
3973
+ /** Tool name */
3974
+ name: string;
3975
+ /** Tool description */
3976
+ description?: string;
3977
+ /** Whether the tool is enabled */
3978
+ enabled?: boolean;
3979
+ }
3980
+ /**
3981
+ * MCP Server information
3982
+ */
3983
+ interface McpServerInfo {
3984
+ /** Server ID */
3985
+ id: string;
3986
+ /** Server name */
3987
+ name: string;
3988
+ /** Connection status */
3989
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
3990
+ /** Server description */
3991
+ description?: string;
3992
+ /** Available tools */
3993
+ tools?: McpToolInfo[];
3994
+ /** Whether the server is disabled */
3995
+ disabled?: boolean;
3996
+ /** Error message (if connection failed) */
3997
+ error?: string;
3998
+ /** Logo URL */
3999
+ logoUrl?: string;
4000
+ /** Official website URL */
4001
+ officialUrl?: string;
4002
+ /** Configuration source */
4003
+ configSource?: 'user' | 'project' | 'plugin';
4004
+ }
2706
4005
  //#endregion
2707
4006
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
2708
4007
  /**
@@ -2734,6 +4033,17 @@ declare class CloudAgentConnection implements AgentConnection {
2734
4033
  readonly transport: "cloud";
2735
4034
  readonly cwd: string;
2736
4035
  constructor(agentId: string, config: CloudConnectionConfig, cwd?: string);
4036
+ /**
4037
+ * Check whether a notification belongs to this connection's own session.
4038
+ *
4039
+ * CloudConnection.createSession() overrides sessionId to agentId, so the
4040
+ * rest of the client stack uses agentId as the canonical session
4041
+ * identifier. Notifications whose sessionId differs from agentId
4042
+ * originate from sub-agent sessions running inside the same sandbox and
4043
+ * should be silently ignored at this layer — the adapter layer handles
4044
+ * sub-agent messages independently via parentToolUseId in _meta.
4045
+ */
4046
+ private isOwnSessionNotification;
2737
4047
  private setupEventForwarding;
2738
4048
  on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
2739
4049
  off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
@@ -2767,7 +4077,7 @@ declare class CloudAgentConnection implements AgentConnection {
2767
4077
  createdAt: number;
2768
4078
  }>;
2769
4079
  hasPendingQuestions(): boolean;
2770
- toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
4080
+ toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
2771
4081
  success: boolean;
2772
4082
  error?: string;
2773
4083
  }>;
@@ -2781,6 +4091,7 @@ declare class CloudAgentConnection implements AgentConnection {
2781
4091
  * Contains sandboxId, link, token, etc.
2782
4092
  */
2783
4093
  get sessionConnectionInfo(): SessionConnectionInfo | undefined;
4094
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2784
4095
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2785
4096
  }
2786
4097
  //#endregion
@@ -2808,6 +4119,13 @@ interface ArchiveConversationResponse {
2808
4119
  /**
2809
4120
  * Configuration for CloudAgentProvider
2810
4121
  */
4122
+ /**
4123
+ * Factory function to create a FilesResource from sandbox connection info.
4124
+ * Used to inject different filesystem implementations (e.g., MiniProgramE2BFilesystem for miniprogram).
4125
+ */
4126
+ type FilesystemFactory = (info: E2BSandboxConnectionInfo) => Promise<FilesResource & {
4127
+ setReconnectFn?: (fn: () => Promise<E2BSandboxConnectionInfo>) => void;
4128
+ }>;
2811
4129
  interface CloudAgentProviderOptions {
2812
4130
  /** Base endpoint URL for agent management API (e.g., 'https://api.example.com') */
2813
4131
  endpoint: string;
@@ -2819,6 +4137,12 @@ interface CloudAgentProviderOptions {
2819
4137
  logger?: Logger;
2820
4138
  /** Client capabilities (sent during agent initialization) */
2821
4139
  clientCapabilities?: ClientCapabilities$1;
4140
+ /**
4141
+ * Optional filesystem factory for creating FilesResource instances.
4142
+ * If not provided, defaults to E2BFilesystem (requires e2b package).
4143
+ * Set this to MiniProgramE2BFilesystem.connect for miniprogram environments.
4144
+ */
4145
+ filesystemFactory?: FilesystemFactory;
2822
4146
  }
2823
4147
  /**
2824
4148
  * CloudAgentProvider - Manages cloud-hosted agents via REST API
@@ -2903,6 +4227,22 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2903
4227
  private cosUploadService;
2904
4228
  /** Event listeners for provider-level events */
2905
4229
  private eventListeners;
4230
+ /** 产品配置缓存(内存),用于存储 deploymentType 和 creditPurchaseActions */
4231
+ private productConfigCache;
4232
+ /**
4233
+ * Plugin marketplace cache (name/id -> marketplace info)
4234
+ * LRU 缓存,容量上限 200
4235
+ * Key: marketplace name 或 id
4236
+ * Value: marketplace 完整信息
4237
+ */
4238
+ private marketplaceCache;
4239
+ /**
4240
+ * Installed plugin cache (plugin name -> plugin info with install_id)
4241
+ * LRU 缓存,容量上限 2000
4242
+ * Key: plugin name
4243
+ * Value: plugin 完整信息(包含 installId)
4244
+ */
4245
+ private pluginCache;
2906
4246
  constructor(options: CloudAgentProviderOptions);
2907
4247
  /**
2908
4248
  * Dispose the provider and clean up resources
@@ -2959,11 +4299,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2959
4299
  /**
2960
4300
  * Create a new conversation
2961
4301
  * POST {endpoint}/console/as/conversations
2962
- * @param params - Optional session params containing _meta with tags
4302
+ * @param params - Session params containing cwd and optional configuration
2963
4303
  */
2964
- create(params?: {
2965
- _meta?: Record<string, unknown>;
2966
- }): Promise<string>;
4304
+ create(params: CreateSessionParams$1): Promise<string>;
2967
4305
  /**
2968
4306
  * Connect to an agent and return the connection
2969
4307
  *
@@ -3015,6 +4353,21 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3015
4353
  * ```
3016
4354
  */
3017
4355
  rename(agentId: string, title: string): Promise<PatchConversationResponse>;
4356
+ /**
4357
+ * Update conversation status by ID
4358
+ * POST {endpoint}/console/as/conversations/{agentId}
4359
+ *
4360
+ * @param agentId - Conversation ID to update
4361
+ * @param status - New status for the conversation
4362
+ * @returns PatchConversationResponse containing the updated conversation ID
4363
+ *
4364
+ * @example
4365
+ * ```typescript
4366
+ * const result = await provider.updateStatus('agent-123', 'completed');
4367
+ * console.log('Updated conversation status:', result.id);
4368
+ * ```
4369
+ */
4370
+ updateStatus(agentId: string, status: string): Promise<PatchConversationResponse>;
3018
4371
  /**
3019
4372
  * Get available models from product configuration
3020
4373
  *
@@ -3027,6 +4380,25 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3027
4380
  * @returns Array of ModelInfo with full model details
3028
4381
  */
3029
4382
  getModels(repo?: string): Promise<ModelInfo[]>;
4383
+ /**
4384
+ * 获取产品部署类型(从缓存)
4385
+ * 需要先调用 getModels() 初始化缓存
4386
+ *
4387
+ * @returns 部署类型:'SaaS' | 'Cloud-Hosted' | 'Self-Hosted',默认为 'SaaS'
4388
+ */
4389
+ getDeploymentType(): string;
4390
+ /**
4391
+ * 获取 Credit 购买引导配置(从缓存)
4392
+ * 需要先调用 getModels() 初始化缓存
4393
+ *
4394
+ * @returns Credit 购买引导配置,key 为错误码。如果后端未返回,则使用默认配置
4395
+ */
4396
+ getCreditPurchaseActions(): Record<string, {
4397
+ labelZh: string;
4398
+ labelEn: string;
4399
+ url: string;
4400
+ showButton?: boolean;
4401
+ }>;
3030
4402
  /**
3031
4403
  * Generate a unique request ID
3032
4404
  */
@@ -3049,7 +4421,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3049
4421
  /**
3050
4422
  * Upload files to cloud storage via COS presigned URL
3051
4423
  *
3052
- * @param params - files array (File objects in browser)
4424
+ * @param params - files array (File objects in browser), optional abortSignal
3053
4425
  * @returns Response with corresponding cloud URLs
3054
4426
  */
3055
4427
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
@@ -3073,53 +4445,282 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3073
4445
  private emitEvent;
3074
4446
  /**
3075
4447
  * 获取支持的场景列表
3076
- * API 端点: GET /console/as/support/scenes
4448
+ * API 端点: GET /v2/as/support/scenes (不鉴权)
3077
4449
  * 用于 Welcome 页面的 QuickActions 快捷操作
3078
4450
  *
4451
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
3079
4452
  * @returns Promise<SupportScene[]> 支持的场景列表
3080
4453
  */
3081
- getSupportScenes(): Promise<SupportScene[]>;
4454
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
3082
4455
  private toAgentState;
3083
4456
  /**
3084
4457
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
3085
4458
  */
3086
4459
  private buildGetUrl;
4460
+ /**
4461
+ * 获取已安装插件列表
4462
+ * GET /console/as/user/plugins/installed
4463
+ */
4464
+ getInstalledPlugins(forceRefresh?: boolean): Promise<Array<{
4465
+ name: string;
4466
+ marketplaceName: string;
4467
+ status: string;
4468
+ description?: string;
4469
+ version?: string;
4470
+ installScope?: 'user' | 'project';
4471
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
4472
+ installId?: string;
4473
+ }>>;
4474
+ /**
4475
+ * 安装插件
4476
+ * POST /console/as/user/plugins/install
4477
+ *
4478
+ * @param pluginNames - 插件名称数组
4479
+ * @param marketplaceNameOrId - 市场名称或 ID
4480
+ */
4481
+ installPlugins(pluginNames: string[], marketplaceNameOrId: string, installScope?: 'user' | 'project' | 'project-local', marketplaceSource?: string, workspacePath?: string): Promise<{
4482
+ success: boolean;
4483
+ error?: string;
4484
+ }>;
4485
+ /**
4486
+ * 卸载插件
4487
+ * POST /console/as/user/plugins/installed/:id/uninstall
4488
+ *
4489
+ * 完整链路:
4490
+ * CloudAgentProvider.uninstallPlugin()
4491
+ * -> HTTP POST /console/as/user/plugins/installed/:id/uninstall
4492
+ * -> agentserver: PluginInstallService.Uninstall()
4493
+ * -> 软删除 DB + 异步同步到活跃沙箱
4494
+ *
4495
+ * @param pluginName - 插件名称
4496
+ * @param marketplaceName - 市场名称(用于标识唯一插件)
4497
+ * @param scope - 卸载范围 ('user' | 'project' | 'project-local')
4498
+ */
4499
+ uninstallPlugin(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
4500
+ success: boolean;
4501
+ error?: string;
4502
+ }>;
4503
+ /**
4504
+ * 获取插件市场列表
4505
+ * GET /console/as/marketplace/sources
4506
+ */
4507
+ getPluginMarketplaces(forceRefresh?: boolean): Promise<Array<{
4508
+ id: string;
4509
+ name: string;
4510
+ type: 'github' | 'local' | 'custom';
4511
+ source: {
4512
+ repo?: string;
4513
+ ref?: string;
4514
+ url?: string;
4515
+ };
4516
+ description?: string;
4517
+ isBuiltin?: boolean;
4518
+ }>>;
4519
+ /**
4520
+ * 获取市场下的插件列表
4521
+ * - 有 searchText: GET /console/as/marketplace/plugins/search (跨所有市场搜索)
4522
+ * - 无 searchText: GET /console/as/marketplace/plugins (指定市场)
4523
+ *
4524
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4525
+ * @param forceRefresh - 是否强制刷新
4526
+ * @param searchText - 搜索关键字(如果提供,则跨所有市场搜索)
4527
+ */
4528
+ getMarketplacePlugins(marketplaceNameOrId: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
4529
+ name: string;
4530
+ marketplaceName: string;
4531
+ description?: string;
4532
+ version?: string;
4533
+ author?: string;
4534
+ homepage?: string;
4535
+ iconUrl?: string;
4536
+ tags?: string[];
4537
+ installed?: boolean;
4538
+ status?: 'enabled' | 'disabled' | 'not-installed';
4539
+ installedScopes?: Array<'user' | 'project'>;
4540
+ hasUpdate?: boolean;
4541
+ latestVersion?: string;
4542
+ agents?: any;
4543
+ commands?: any;
4544
+ skills?: any;
4545
+ mcpServers?: any;
4546
+ hooks?: any;
4547
+ rules?: any;
4548
+ }>>;
4549
+ /**
4550
+ * 获取插件详情
4551
+ * GET /console/as/marketplace/plugins/:name/detail
4552
+ *
4553
+ * @param pluginName - 插件名称
4554
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4555
+ */
4556
+ getPluginDetail(pluginName: string, marketplaceNameOrId: string): Promise<{
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
+ readme?: string;
4569
+ configSchema?: Record<string, unknown>;
4570
+ tools?: Array<{
4571
+ name: string;
4572
+ description?: string;
4573
+ }>;
4574
+ resources?: Array<{
4575
+ name: string;
4576
+ description?: string;
4577
+ }>;
4578
+ prompts?: Array<{
4579
+ name: string;
4580
+ description?: string;
4581
+ }>;
4582
+ downloadCount?: number;
4583
+ lastUpdated?: string;
4584
+ license?: string;
4585
+ repositoryUrl?: string;
4586
+ } | null>;
4587
+ /**
4588
+ * 添加插件市场
4589
+ * POST /console/as/marketplace/sources
4590
+ */
4591
+ addPluginMarketplace(sourceUrl: string, name?: string): Promise<{
4592
+ success: boolean;
4593
+ error?: string;
4594
+ marketplace?: {
4595
+ id: string;
4596
+ name: string;
4597
+ type: 'github' | 'local' | 'custom';
4598
+ source: {
4599
+ repo?: string;
4600
+ ref?: string;
4601
+ url?: string;
4602
+ };
4603
+ description?: string;
4604
+ isBuiltin?: boolean;
4605
+ };
4606
+ }>;
4607
+ /**
4608
+ * 删除插件市场
4609
+ * POST /console/as/marketplace/sources/:id/delete
4610
+ */
4611
+ removePluginMarketplace(marketplaceNameOrId: string): Promise<{
4612
+ success: boolean;
4613
+ error?: string;
4614
+ }>;
4615
+ /**
4616
+ * 刷新插件市场
4617
+ * POST /console/as/marketplace/sources/:id/check-updates
4618
+ */
4619
+ refreshPluginMarketplace(marketplaceNameOrId: string): Promise<{
4620
+ success: boolean;
4621
+ error?: string;
4622
+ plugins?: Array<any>;
4623
+ }>;
4624
+ /**
4625
+ * 批量切换插件启用/禁用状态
4626
+ * POST /console/as/user/plugins/installed/:id/toggle
4627
+ */
4628
+ batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
4629
+ /**
4630
+ * 将后端插件数据映射为前端格式
4631
+ */
4632
+ private mapPluginData;
4633
+ /**
4634
+ * 从缓存中查找插件的 install_id
4635
+ * 如果缓存未命中,则调用 API 获取并缓存
4636
+ *
4637
+ * @param pluginName - 插件名称
4638
+ * @returns install_id 或 null
4639
+ */
4640
+ private findPluginInstallId;
4641
+ /**
4642
+ * 从缓存中查找 marketplace ID
4643
+ * 如果缓存未命中,则调用 API 获取并缓存
4644
+ */
4645
+ private findMarketplaceId;
4646
+ /**
4647
+ * 提取 API 错误信息
4648
+ * 从 AxiosError 中提取详细的错误信息,包括 HTTP 状态码、错误码和错误消息
4649
+ */
4650
+ private extractErrorMessage;
4651
+ /**
4652
+ * 映射后端 source_type 到前端类型
4653
+ */
4654
+ private mapSourceType;
4655
+ /**
4656
+ * 解析 capabilities JSON 字符串
4657
+ */
4658
+ private parseCapabilities;
4659
+ /**
4660
+ * 上报 telemetry 事件(Cloud 模式)
4661
+ * 通过 HTTP POST 发送到 /v2/report
4662
+ * 注入用户信息和浏览器环境等公共字段
4663
+ */
4664
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
3087
4665
  }
3088
4666
  //#endregion
3089
4667
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
3090
4668
  /**
3091
- * E2B Filesystem Implementation
4669
+ * Callback to fetch fresh sandbox connection info from backend.
4670
+ * Called when an operation fails with 401/403.
4671
+ */
4672
+ type ReconnectFn = () => Promise<E2BSandboxConnectionInfo>;
4673
+ /**
4674
+ * E2B Filesystem
3092
4675
  *
3093
- * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource interface.
4676
+ * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource.
4677
+ * When `reconnectFn` is provided, automatically reconnects on auth errors.
3094
4678
  *
3095
4679
  * @example
3096
4680
  * ```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');
4681
+ * // Basic usage (no auto-reconnect)
4682
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
3105
4683
  *
3106
- * // Watch for changes
3107
- * const handle = await fs.watchDir('/workspace', (event) => {
3108
- * console.log('File changed:', event);
3109
- * });
4684
+ * // With auto-reconnect on token expiry
4685
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
4686
+ * fs.setReconnectFn(async () => fetchFreshConnectionInfo());
3110
4687
  * ```
3111
4688
  */
3112
4689
  declare class E2BFilesystem implements FilesResource {
3113
4690
  private sandbox;
4691
+ private reconnectFn?;
4692
+ /** Whether a reconnect is currently in-flight */
4693
+ private isReconnecting;
4694
+ /** Callers waiting for the in-flight reconnect to complete */
4695
+ private reconnectSubscribers;
4696
+ /** Timestamp of last reconnect attempt (anti-loop: min 10s between attempts) */
4697
+ private lastReconnectAt;
4698
+ private static readonly MIN_RECONNECT_INTERVAL_MS;
3114
4699
  constructor(sandbox: Sandbox);
3115
4700
  /**
3116
4701
  * Connect to an E2B Sandbox and create filesystem instance
3117
4702
  */
3118
4703
  static connect(info: E2BSandboxConnectionInfo): Promise<E2BFilesystem>;
4704
+ /**
4705
+ * Set reconnect callback. When set, auth errors trigger automatic reconnect + retry.
4706
+ */
4707
+ setReconnectFn(fn: ReconnectFn): void;
3119
4708
  /**
3120
4709
  * Get the underlying E2B Sandbox instance
3121
4710
  */
3122
4711
  getSandbox(): Sandbox;
4712
+ private isAuthError;
4713
+ private canAttemptReconnect;
4714
+ /**
4715
+ * Reconnect with fresh credentials.
4716
+ * Only one reconnect in-flight at a time; concurrent callers share the result.
4717
+ */
4718
+ private reconnect;
4719
+ /**
4720
+ * Execute an operation. If reconnectFn is set and an auth error occurs,
4721
+ * reconnect and retry once.
4722
+ */
4723
+ private exec;
3123
4724
  read(path: string, opts?: FilesystemRequestOpts & {
3124
4725
  format?: 'text';
3125
4726
  }): Promise<string>;
@@ -3134,13 +4735,13 @@ declare class E2BFilesystem implements FilesResource {
3134
4735
  }): Promise<ReadableStream<Uint8Array>>;
3135
4736
  write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<WriteInfo>;
3136
4737
  write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
3137
- list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
4738
+ list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo[]>;
3138
4739
  exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
3139
4740
  makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
3140
4741
  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 & {
4742
+ rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
4743
+ getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
4744
+ watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
3144
4745
  onExit?: (err?: Error) => void | Promise<void>;
3145
4746
  }): Promise<WatchHandle>;
3146
4747
  }
@@ -3262,6 +4863,7 @@ interface ActiveSessionImplOptions {
3262
4863
  declare class ActiveSessionImpl implements ActiveSession {
3263
4864
  private _id;
3264
4865
  private _agentId;
4866
+ private _cwd?;
3265
4867
  private _availableModes?;
3266
4868
  private _currentMode?;
3267
4869
  private _availableModels?;
@@ -3273,6 +4875,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3273
4875
  private _connectionInfo?;
3274
4876
  private listeners;
3275
4877
  private onceListeners;
4878
+ private connectionListeners;
3276
4879
  /**
3277
4880
  * Agent operations namespace
3278
4881
  */
@@ -3306,6 +4909,14 @@ declare class ActiveSessionImpl implements ActiveSession {
3306
4909
  * Agent ID
3307
4910
  */
3308
4911
  get agentId(): string;
4912
+ /**
4913
+ * Actual workspace path (set from newSession response _meta)
4914
+ */
4915
+ get cwd(): string | undefined;
4916
+ /**
4917
+ * Set actual workspace path (called by SessionManager after createSession)
4918
+ */
4919
+ setCwd(cwd: string): void;
3309
4920
  /**
3310
4921
  * Agent state (live connection state)
3311
4922
  * Returns LocalAgentState or CloudAgentState based on transport type
@@ -3387,12 +4998,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3387
4998
  */
3388
4999
  cancelQuestion(toolCallId: string, reason?: string): boolean;
3389
5000
  /**
3390
- * Callback for tool operations (skip or cancel)
5001
+ * Callback for tool operations (approve / skip / cancel)
3391
5002
  * @param toolCallId Tool call ID
3392
5003
  * @param toolName Tool name
3393
- * @param action Action to perform ('skip' or 'cancel')
5004
+ * @param action Action to perform ('approve' / 'skip' / 'cancel')
3394
5005
  */
3395
- toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
5006
+ toolCallback(toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
3396
5007
  success: boolean;
3397
5008
  error?: string;
3398
5009
  }>;
@@ -3450,6 +5061,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3450
5061
  * Disconnect from the session/agent
3451
5062
  */
3452
5063
  disconnect(): void;
5064
+ /**
5065
+ * Detach the session from connection events without disconnecting the connection.
5066
+ * This should be called when the session is being replaced but the connection is shared.
5067
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
5068
+ */
5069
+ detach(): void;
3453
5070
  /**
3454
5071
  * Symbol.dispose for 'using' keyword support
3455
5072
  * Automatically disconnects and cleans up when session goes out of scope
@@ -3464,8 +5081,21 @@ declare class ActiveSessionImpl implements ActiveSession {
3464
5081
  */
3465
5082
  [Symbol.dispose](): void;
3466
5083
  private getConnectionOrThrow;
5084
+ /**
5085
+ * 在 connection 上注册 listener 并保存引用,便于 disconnect 时移除
5086
+ */
5087
+ private addConnectionListener;
5088
+ /**
5089
+ * 从 connection 上移除所有本 session 注册的 listener
5090
+ */
5091
+ private removeConnectionListeners;
3467
5092
  private setupConnectionEvents;
3468
5093
  private mapPromptResponse;
5094
+ /**
5095
+ * 判断 artifact 是否应该转发给当前 session
5096
+ * 所有类型的 artifact 都按 __sessionId 严格隔离
5097
+ */
5098
+ private shouldForwardArtifact;
3469
5099
  }
3470
5100
  //#endregion
3471
5101
  //#region ../agent-provider/lib/common/client/session-manager.d.ts
@@ -3570,6 +5200,13 @@ declare class SessionManager {
3570
5200
  */
3571
5201
  declare class BackendProvider implements IBackendProvider {
3572
5202
  constructor(config: BackendProviderConfig);
5203
+ /**
5204
+ * 处理 401 未授权错误
5205
+ * 先尝试刷新 token,失败后再执行登出流程
5206
+ *
5207
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
5208
+ */
5209
+ protected handleUnauthorized(): Promise<void>;
3573
5210
  /**
3574
5211
  * 获取当前账号信息
3575
5212
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3680,9 +5317,21 @@ declare class BackendProvider implements IBackendProvider {
3680
5317
  login(): Promise<void>;
3681
5318
  /**
3682
5319
  * 登出账号
3683
- * Web 环境: 通过 iframe 访问登出 URL 清除 cookie
5320
+ *
5321
+ * 策略:
5322
+ * - IOA 企业:用 iframe 走 SSO/SAML SLO 登出链路(涉及跨域重定向),通过轮询 iframe URL 变化检测完成
5323
+ * - 非 IOA 企业:直接用 httpService 请求 /console/logout,速度快
3684
5324
  */
3685
5325
  logout(): Promise<void>;
5326
+ /**
5327
+ * IOA 企业登出:通过 iframe 走 SSO/SAML SLO 登出链路
5328
+ * 轮询 iframe URL 变化检测完成,兜底超时 5 秒
5329
+ */
5330
+ private logoutViaIframe;
5331
+ /**
5332
+ * 非 IOA 企业登出:直接 HTTP 请求 /console/logout
5333
+ */
5334
+ private logoutViaHttp;
3686
5335
  /**
3687
5336
  * 批量切换插件状态
3688
5337
  * Web 环境不支持此功能
@@ -3725,6 +5374,41 @@ declare class BackendProvider implements IBackendProvider {
3725
5374
  * @returns Promise<ListReposResponse> 仓库列表响应
3726
5375
  */
3727
5376
  getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
5377
+ /**
5378
+ * 保存待发送的输入内容到后端
5379
+ * API 端点: POST /api/v1/code-id
5380
+ */
5381
+ savePendingInput(code: string): Promise<string | null>;
5382
+ /**
5383
+ * 从后端加载待发送的输入内容
5384
+ * API 端点: GET /api/v1/code?id=xxx
5385
+ */
5386
+ loadPendingInput(codeId: string): Promise<string | null>;
5387
+ /**
5388
+ * 获取每日签到状态
5389
+ * API 端点: POST /billing/meter/checkin-status
5390
+ */
5391
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5392
+ /**
5393
+ * 执行每日签到
5394
+ * API 端点: POST /billing/meter/daily-checkin
5395
+ */
5396
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
5397
+ private static readonly SKILLHUB_BASE_URL;
5398
+ private static readonly SKILLHUB_FETCH_TIMEOUT;
5399
+ private skillHubFetch;
5400
+ getSkillHubList(params?: SkillHubListParams): Promise<SkillHubListResponse>;
5401
+ getSkillHubCategories(): Promise<SkillHubCategoriesResponse>;
5402
+ getSkillHubSearch(q: string, limit?: number): Promise<SkillHubSearchResponse>;
5403
+ getSkillHubDetail(slug: string): Promise<SkillHubDetailResponse>;
5404
+ getSkillHubExists(slugs: string[]): Promise<SkillHubExistsResponse>;
5405
+ reportSkillHubStats(slug: string, inc: {
5406
+ downloads?: number;
5407
+ installs?: number;
5408
+ stars?: number;
5409
+ }): Promise<void>;
5410
+ installSkillHubSkill(_slug: string, _version?: string, _name?: string): Promise<SkillHubInstallResponse>;
5411
+ getSkillHubInstalledMetas(): Promise<SkillHubInstalledMeta[]>;
3728
5412
  }
3729
5413
  /**
3730
5414
  * 创建 BackendProvider 实例
@@ -3853,6 +5537,14 @@ declare class IPCBackendProvider implements IBackendProvider {
3853
5537
  reloadWindow(params?: {
3854
5538
  locale?: string;
3855
5539
  }): Promise<void>;
5540
+ /**
5541
+ * Save locale to argv.json without restarting the app.
5542
+ * The change takes effect on next manual restart.
5543
+ * @param params locale to save
5544
+ */
5545
+ saveLocale(params: {
5546
+ locale: string;
5547
+ }): Promise<void>;
3856
5548
  /**
3857
5549
  * 关闭 Agent Manager 面板
3858
5550
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
@@ -3881,6 +5573,71 @@ declare class IPCBackendProvider implements IBackendProvider {
3881
5573
  * 4. 返回 SupportScene[] 数据给 agent-ui
3882
5574
  */
3883
5575
  getSupportScenes(): Promise<SupportScene[]>;
5576
+ /**
5577
+ * 获取账号用量信息(积分/Credits)
5578
+ * IDE 环境: 通过 IPC 实时获取用量信息,每次打开菜单时调用
5579
+ *
5580
+ * 调用链:
5581
+ * 1. agent-ui: IPCBackendProvider.getAccountUsage()
5582
+ * 2. Agent Manager renderer: BackendService.getAccountUsage()
5583
+ * 3. Main Process: codebuddy:getAccountUsage IPC handler
5584
+ * 4. 返回 { usageLeft, usageTotal, editionType, refreshAt } 等字段
5585
+ */
5586
+ getAccountUsage(): Promise<Partial<Account> | null>;
5587
+ /**
5588
+ * 获取每日签到状态
5589
+ * IDE 环境: 通过 IPC 获取签到状态
5590
+ */
5591
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5592
+ /**
5593
+ * 执行每日签到
5594
+ * IDE 环境: 通过 IPC 执行签到
5595
+ */
5596
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
5597
+ /**
5598
+ * 获取 SkillHub 技能列表
5599
+ * IDE 环境: 通过 IPC 获取技能列表
5600
+ */
5601
+ getSkillHubList(params?: SkillHubListParams): Promise<SkillHubListResponse>;
5602
+ /**
5603
+ * 获取 SkillHub 分类列表
5604
+ * IDE 环境: 通过 IPC 获取分类列表
5605
+ */
5606
+ getSkillHubCategories(): Promise<SkillHubCategoriesResponse>;
5607
+ /**
5608
+ * 搜索 SkillHub 技能
5609
+ * IDE 环境: 通过 IPC 搜索技能
5610
+ */
5611
+ getSkillHubSearch(q: string, limit?: number): Promise<SkillHubSearchResponse>;
5612
+ /**
5613
+ * 获取 SkillHub 技能详情
5614
+ * IDE 环境: 通过 IPC 获取技能详情
5615
+ */
5616
+ getSkillHubDetail(slug: string): Promise<SkillHubDetailResponse>;
5617
+ /**
5618
+ * 批量检查 SkillHub 技能是否存在
5619
+ * IDE 环境: 通过 IPC 检查技能是否存在
5620
+ */
5621
+ getSkillHubExists(slugs: string[]): Promise<SkillHubExistsResponse>;
5622
+ /**
5623
+ * 上报 SkillHub 技能统计
5624
+ * IDE 环境: 通过 IPC 上报统计
5625
+ */
5626
+ reportSkillHubStats(slug: string, inc: {
5627
+ downloads?: number;
5628
+ installs?: number;
5629
+ stars?: number;
5630
+ }): Promise<void>;
5631
+ /**
5632
+ * 安装 SkillHub 技能
5633
+ * IDE 环境: 通过 IPC 安装技能(下载 zip → 解压到本地)
5634
+ */
5635
+ installSkillHubSkill(slug: string, version?: string, name?: string): Promise<SkillHubInstallResponse>;
5636
+ /**
5637
+ * 获取本地已安装的 SkillHub 技能元信息
5638
+ * IDE 环境: 通过 IPC 获取元信息
5639
+ */
5640
+ getSkillHubInstalledMetas(): Promise<SkillHubInstalledMeta[]>;
3884
5641
  /**
3885
5642
  * 调试日志
3886
5643
  */
@@ -3918,7 +5675,7 @@ type RequestErrorInterceptor = (error: any) => any;
3918
5675
  /**
3919
5676
  * 响应拦截器函数
3920
5677
  */
3921
- type ResponseInterceptor = (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
5678
+ type ResponseInterceptor = (response: AxiosResponse$1) => AxiosResponse$1 | Promise<AxiosResponse$1>;
3922
5679
  /**
3923
5680
  * 响应错误拦截器函数
3924
5681
  */
@@ -3935,7 +5692,7 @@ type UnauthorizedCallback = () => void;
3935
5692
  * 特性:
3936
5693
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3937
5694
  * - 支持拦截器注册(其他模块可注入 header)
3938
- * - 统一 401/403 处理
5695
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3939
5696
  * - 自动携带凭证(withCredentials)
3940
5697
  * - 类型安全
3941
5698
  *
@@ -3971,6 +5728,10 @@ declare class HttpService {
3971
5728
  private axiosInstance;
3972
5729
  private unauthorizedCallbacks;
3973
5730
  private config;
5731
+ /** 是否正在刷新 token */
5732
+ private isRefreshing;
5733
+ /** 等待 token 刷新完成的请求队列 */
5734
+ private refreshSubscribers;
3974
5735
  /**
3975
5736
  * 私有构造函数(单例模式)
3976
5737
  */
@@ -3988,9 +5749,17 @@ declare class HttpService {
3988
5749
  */
3989
5750
  private registerDefaultRequestInterceptor;
3990
5751
  /**
3991
- * 注册默认响应拦截器(处理 401/403)
5752
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3992
5753
  */
3993
5754
  private registerDefaultResponseInterceptor;
5755
+ /**
5756
+ * token 刷新成功,通知所有等待的请求
5757
+ */
5758
+ private onRefreshSuccess;
5759
+ /**
5760
+ * token 刷新失败,通知所有等待的请求
5761
+ */
5762
+ private onRefreshFailure;
3994
5763
  /**
3995
5764
  * 注册请求拦截器
3996
5765
  * @param onFulfilled 请求成功拦截器
@@ -4056,7 +5825,9 @@ declare class HttpService {
4056
5825
  */
4057
5826
  offUnauthorized(callback: UnauthorizedCallback): void;
4058
5827
  /**
4059
- * 触发所有 401 回调
5828
+ * 触发所有 401 回调并等待完成
5829
+ * @returns Promise,等待所有回调完成
5830
+ * @throws 如果任何回调失败,则抛出错误
4060
5831
  */
4061
5832
  private triggerUnauthorizedCallbacks;
4062
5833
  /**
@@ -4107,6 +5878,12 @@ declare class HttpService {
4107
5878
  * @returns 响应数据
4108
5879
  */
4109
5880
  put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
5881
+ /**
5882
+ * 通用请求方法
5883
+ * @param config axios 请求配置
5884
+ * @returns 原始 AxiosResponse
5885
+ */
5886
+ request<T = any>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
4110
5887
  /**
4111
5888
  * 获取原始 axios 实例(用于高级场景)
4112
5889
  */