@tencent-ai/cloud-agent-sdk 0.2.13 → 0.2.14-next.0a3c83c.20260321

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { AgentCapabilities as AgentCapabilities$1, ClientCapabilities, InitializeResponse, LoadSessionResponse, NewSessionResponse, PromptResponse as PromptResponse$1, RequestPermissionRequest, RequestPermissionRequest as RequestPermissionRequest$1, SessionNotification, SessionNotification as SessionNotification$1, SetSessionModeResponse, SetSessionModelResponse } from "@agentclientprotocol/sdk";
2
- import { EntryInfo, EntryInfo as EntryInfo$1, Filesystem, FilesystemEvent, FilesystemEvent as FilesystemEvent$1, Sandbox, WatchHandle, WriteInfo } from "e2b";
1
+ import { AgentCapabilities as AgentCapabilities$1, ClientCapabilities, InitializeResponse, LoadSessionResponse, NewSessionResponse, PromptResponse as PromptResponse$1, RequestPermissionRequest, RequestPermissionRequest as RequestPermissionRequest$1, SessionNotification, SessionNotification as SessionNotification$1, SetSessionModeResponse, SetSessionModelResponse, StopReason } from "@agentclientprotocol/sdk";
2
+ import { Sandbox } from "e2b";
3
3
  import "zod";
4
4
 
5
5
  //#region ../agent-client-protocol/lib/common/types.d.ts
@@ -235,6 +235,12 @@ interface CodebuddyClientMeta {
235
235
  artifacts?: ArtifactsConfig;
236
236
  /** Whether the client supports checkpoint notifications */
237
237
  checkpoint?: boolean;
238
+ /**
239
+ * Whether the client supports handling AskUserQuestion tool via extMethod.
240
+ * When true, AskUserQuestion requests will be sent to the client via
241
+ * the '_codebuddy.ai/question' extMethod instead of being handled locally.
242
+ */
243
+ question?: boolean;
238
244
  }
239
245
  /**
240
246
  * codebuddy.ai extension capabilities for Agent
@@ -995,6 +1001,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,233 @@ 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
+ /** Chinese description of the skill */
3793
+ description_zh?: string;
3794
+ /** English description of the skill */
3795
+ description_en?: string;
3796
+ /** When to use the skill */
3797
+ whenToUse?: string;
3798
+ /** Source of the skill */
3799
+ source: 'localSettings' | 'userSettings' | 'plugin' | 'builtin';
3800
+ /** Skill type */
3801
+ type: 'prompt';
3802
+ /** License information */
3803
+ license?: string;
3804
+ /** Allowed tools */
3805
+ allowedTools?: string[];
3806
+ /** Whether the skill is disabled */
3807
+ disable?: boolean;
3808
+ }
3809
+ /**
3810
+ * Parameters for getting skill list
3811
+ */
3812
+ interface GetSkillListParams {
3813
+ /** Working directory (optional, for filtering project-level skills) */
3814
+ readonly cwd?: string;
3815
+ /** Whether to use global (backend) channel, defaults to true. When false, uses sendBroadcastRequest. */
3816
+ readonly global?: boolean;
3817
+ /** Whether to exclude plugin skills from the result, defaults to false. */
3818
+ readonly excludePluginSkills?: boolean;
3819
+ /**
3820
+ * 用户级 skill 扫描目录名称列表(相对于 home 目录),按优先级从高到低排列。
3821
+ * 同名 skill 以高优先级目录为准。
3822
+ * 未传入或为空时使用产品默认目录。
3823
+ */
3824
+ readonly skillScanDirs?: string[];
3825
+ }
3826
+ /**
3827
+ * Response from getting skill list
3828
+ */
3829
+ interface GetSkillListResponse {
3830
+ /** Skill list */
3831
+ readonly results: SkillInfo[];
3832
+ /** Error message (if failed) */
3833
+ readonly error?: string;
3834
+ }
3835
+ /**
3836
+ * Parameters for importing a skill folder
3837
+ */
3838
+ interface ImportSkillParams {
3839
+ /** Source location: project-level or user-level */
3840
+ readonly source: 'localSettings' | 'userSettings';
3841
+ /** Working directory (required when source is localSettings). */
3842
+ readonly cwd?: string;
3843
+ /** 直接传入文件夹路径(拖拽导入时使用),有此字段时跳过系统文件选择器 */
3844
+ readonly folderPath?: string;
3845
+ }
3846
+ /**
3847
+ * Response from importing a skill folder
3848
+ */
3849
+ interface ImportSkillResponse {
3850
+ /** Whether the import was successful */
3851
+ readonly success: boolean;
3852
+ /** Error message (if failed) */
3853
+ readonly error?: string;
3854
+ /** Imported skill name */
3855
+ readonly skillName?: string;
3856
+ }
3857
+ /**
3858
+ * Parameters for toggling skill enable/disable state
3859
+ */
3860
+ interface ToggleSkillParams {
3861
+ /** File path of the skill to toggle */
3862
+ readonly filePath: string;
3863
+ /** Whether to disable the skill */
3864
+ readonly disable: boolean;
3865
+ }
3866
+ /**
3867
+ * Response from toggling skill state
3868
+ */
3869
+ interface ToggleSkillResponse {
3870
+ /** Whether the toggle was successful */
3871
+ readonly success: boolean;
3872
+ /** Error message (if failed) */
3873
+ readonly error?: string;
3874
+ }
3875
+ /**
3876
+ * Parameters for deleting a skill
3877
+ */
3878
+ interface DeleteSkillParams {
3879
+ /** File path of the skill to delete */
3880
+ readonly filePath: string;
3881
+ /** Name of the skill */
3882
+ readonly name: string;
3883
+ }
3884
+ /**
3885
+ * Response from deleting a skill
3886
+ */
3887
+ interface DeleteSkillResponse {
3888
+ /** Whether the deletion was successful */
3889
+ readonly success: boolean;
3890
+ /** Error message (if failed) */
3891
+ readonly error?: string;
3892
+ }
3893
+ /**
3894
+ * Parameters for getting skill content
3895
+ */
3896
+ interface GetSkillContentParams {
3897
+ /** File path of the skill */
3898
+ readonly filePath: string;
3899
+ }
3900
+ /**
3901
+ * Response from getting skill content
3902
+ */
3903
+ interface GetSkillContentResponse {
3904
+ /** Skill file content */
3905
+ readonly content: string;
3906
+ /** Error message (if failed) */
3907
+ readonly error?: string;
3908
+ }
3909
+ /**
3910
+ * Marketplace skill info (simplified structure for UI layer)
3911
+ */
3912
+ interface MarketplaceSkillInfo {
3913
+ /** Skill name */
3914
+ name: string;
3915
+ /** Skill description */
3916
+ description: string;
3917
+ /** Skill description in Chinese */
3918
+ description_zh?: string;
3919
+ /** Skill description in English */
3920
+ description_en?: string;
3921
+ /** Skill version */
3922
+ version?: string;
3923
+ /** Skill author */
3924
+ author?: string;
3925
+ /** Skill icon URL */
3926
+ iconUrl?: string;
3927
+ /** Skill tags */
3928
+ tags?: string[];
3929
+ }
3930
+ /**
3931
+ * Response from getting marketplace skills
3932
+ */
3933
+ interface GetMarketplaceSkillsResponse {
3934
+ /** Marketplace skill list */
3935
+ readonly results: MarketplaceSkillInfo[];
3936
+ /** Error message (if failed) */
3937
+ readonly error?: string;
3938
+ }
3939
+ /**
3940
+ * Parameters for getting marketplace skill content
3941
+ */
3942
+ interface GetMarketplaceSkillContentParams {
3943
+ /** Skill name */
3944
+ readonly skillName: string;
3945
+ }
3946
+ /**
3947
+ * Response from getting marketplace skill content
3948
+ */
3949
+ interface GetMarketplaceSkillContentResponse {
3950
+ /** Skill file content */
3951
+ readonly content: string;
3952
+ /** Error message (if failed) */
3953
+ readonly error?: string;
3954
+ }
3955
+ /**
3956
+ * Parameters for installing marketplace skill
3957
+ */
3958
+ interface InstallMarketplaceSkillParams {
3959
+ /** Skill name to install */
3960
+ readonly skillName: string;
3961
+ }
3962
+ /**
3963
+ * Response from installing marketplace skill
3964
+ */
3965
+ interface InstallMarketplaceSkillResponse {
3966
+ /** Whether the install was successful */
3967
+ readonly success: boolean;
3968
+ /** Skill name */
3969
+ readonly skillName: string;
3970
+ /** Error message (if failed) */
3971
+ readonly errorMessage?: string;
3972
+ }
3973
+ /**
3974
+ * MCP Tool information
3975
+ */
3976
+ interface McpToolInfo {
3977
+ /** Tool name */
3978
+ name: string;
3979
+ /** Tool description */
3980
+ description?: string;
3981
+ /** Whether the tool is enabled */
3982
+ enabled?: boolean;
3983
+ }
3984
+ /**
3985
+ * MCP Server information
3986
+ */
3987
+ interface McpServerInfo {
3988
+ /** Server ID */
3989
+ id: string;
3990
+ /** Server name */
3991
+ name: string;
3992
+ /** Connection status */
3993
+ status: 'connecting' | 'connected' | 'disconnected' | 'disabled';
3994
+ /** Server description */
3995
+ description?: string;
3996
+ /** Available tools */
3997
+ tools?: McpToolInfo[];
3998
+ /** Whether the server is disabled */
3999
+ disabled?: boolean;
4000
+ /** Error message (if connection failed) */
4001
+ error?: string;
4002
+ /** Logo URL */
4003
+ logoUrl?: string;
4004
+ /** Official website URL */
4005
+ officialUrl?: string;
4006
+ /** Configuration source */
4007
+ configSource?: 'user' | 'project' | 'plugin';
4008
+ }
2706
4009
  //#endregion
2707
4010
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
2708
4011
  /**
@@ -2734,6 +4037,17 @@ declare class CloudAgentConnection implements AgentConnection {
2734
4037
  readonly transport: "cloud";
2735
4038
  readonly cwd: string;
2736
4039
  constructor(agentId: string, config: CloudConnectionConfig, cwd?: string);
4040
+ /**
4041
+ * Check whether a notification belongs to this connection's own session.
4042
+ *
4043
+ * CloudConnection.createSession() overrides sessionId to agentId, so the
4044
+ * rest of the client stack uses agentId as the canonical session
4045
+ * identifier. Notifications whose sessionId differs from agentId
4046
+ * originate from sub-agent sessions running inside the same sandbox and
4047
+ * should be silently ignored at this layer — the adapter layer handles
4048
+ * sub-agent messages independently via parentToolUseId in _meta.
4049
+ */
4050
+ private isOwnSessionNotification;
2737
4051
  private setupEventForwarding;
2738
4052
  on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
2739
4053
  off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
@@ -2767,7 +4081,7 @@ declare class CloudAgentConnection implements AgentConnection {
2767
4081
  createdAt: number;
2768
4082
  }>;
2769
4083
  hasPendingQuestions(): boolean;
2770
- toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
4084
+ toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
2771
4085
  success: boolean;
2772
4086
  error?: string;
2773
4087
  }>;
@@ -2781,6 +4095,7 @@ declare class CloudAgentConnection implements AgentConnection {
2781
4095
  * Contains sandboxId, link, token, etc.
2782
4096
  */
2783
4097
  get sessionConnectionInfo(): SessionConnectionInfo | undefined;
4098
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
2784
4099
  extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
2785
4100
  }
2786
4101
  //#endregion
@@ -2808,6 +4123,13 @@ interface ArchiveConversationResponse {
2808
4123
  /**
2809
4124
  * Configuration for CloudAgentProvider
2810
4125
  */
4126
+ /**
4127
+ * Factory function to create a FilesResource from sandbox connection info.
4128
+ * Used to inject different filesystem implementations (e.g., MiniProgramE2BFilesystem for miniprogram).
4129
+ */
4130
+ type FilesystemFactory = (info: E2BSandboxConnectionInfo) => Promise<FilesResource & {
4131
+ setReconnectFn?: (fn: () => Promise<E2BSandboxConnectionInfo>) => void;
4132
+ }>;
2811
4133
  interface CloudAgentProviderOptions {
2812
4134
  /** Base endpoint URL for agent management API (e.g., 'https://api.example.com') */
2813
4135
  endpoint: string;
@@ -2819,6 +4141,12 @@ interface CloudAgentProviderOptions {
2819
4141
  logger?: Logger;
2820
4142
  /** Client capabilities (sent during agent initialization) */
2821
4143
  clientCapabilities?: ClientCapabilities$1;
4144
+ /**
4145
+ * Optional filesystem factory for creating FilesResource instances.
4146
+ * If not provided, defaults to E2BFilesystem (requires e2b package).
4147
+ * Set this to MiniProgramE2BFilesystem.connect for miniprogram environments.
4148
+ */
4149
+ filesystemFactory?: FilesystemFactory;
2822
4150
  }
2823
4151
  /**
2824
4152
  * CloudAgentProvider - Manages cloud-hosted agents via REST API
@@ -2903,6 +4231,22 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2903
4231
  private cosUploadService;
2904
4232
  /** Event listeners for provider-level events */
2905
4233
  private eventListeners;
4234
+ /** 产品配置缓存(内存),用于存储 deploymentType 和 creditPurchaseActions */
4235
+ private productConfigCache;
4236
+ /**
4237
+ * Plugin marketplace cache (name/id -> marketplace info)
4238
+ * LRU 缓存,容量上限 200
4239
+ * Key: marketplace name 或 id
4240
+ * Value: marketplace 完整信息
4241
+ */
4242
+ private marketplaceCache;
4243
+ /**
4244
+ * Installed plugin cache (plugin name -> plugin info with install_id)
4245
+ * LRU 缓存,容量上限 2000
4246
+ * Key: plugin name
4247
+ * Value: plugin 完整信息(包含 installId)
4248
+ */
4249
+ private pluginCache;
2906
4250
  constructor(options: CloudAgentProviderOptions);
2907
4251
  /**
2908
4252
  * Dispose the provider and clean up resources
@@ -2959,11 +4303,9 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
2959
4303
  /**
2960
4304
  * Create a new conversation
2961
4305
  * POST {endpoint}/console/as/conversations
2962
- * @param params - Optional session params containing _meta with tags
4306
+ * @param params - Session params containing cwd and optional configuration
2963
4307
  */
2964
- create(params?: {
2965
- _meta?: Record<string, unknown>;
2966
- }): Promise<string>;
4308
+ create(params: CreateSessionParams$1): Promise<string>;
2967
4309
  /**
2968
4310
  * Connect to an agent and return the connection
2969
4311
  *
@@ -3015,6 +4357,21 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3015
4357
  * ```
3016
4358
  */
3017
4359
  rename(agentId: string, title: string): Promise<PatchConversationResponse>;
4360
+ /**
4361
+ * Update conversation status by ID
4362
+ * POST {endpoint}/console/as/conversations/{agentId}
4363
+ *
4364
+ * @param agentId - Conversation ID to update
4365
+ * @param status - New status for the conversation
4366
+ * @returns PatchConversationResponse containing the updated conversation ID
4367
+ *
4368
+ * @example
4369
+ * ```typescript
4370
+ * const result = await provider.updateStatus('agent-123', 'completed');
4371
+ * console.log('Updated conversation status:', result.id);
4372
+ * ```
4373
+ */
4374
+ updateStatus(agentId: string, status: string): Promise<PatchConversationResponse>;
3018
4375
  /**
3019
4376
  * Get available models from product configuration
3020
4377
  *
@@ -3027,6 +4384,25 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3027
4384
  * @returns Array of ModelInfo with full model details
3028
4385
  */
3029
4386
  getModels(repo?: string): Promise<ModelInfo[]>;
4387
+ /**
4388
+ * 获取产品部署类型(从缓存)
4389
+ * 需要先调用 getModels() 初始化缓存
4390
+ *
4391
+ * @returns 部署类型:'SaaS' | 'Cloud-Hosted' | 'Self-Hosted',默认为 'SaaS'
4392
+ */
4393
+ getDeploymentType(): string;
4394
+ /**
4395
+ * 获取 Credit 购买引导配置(从缓存)
4396
+ * 需要先调用 getModels() 初始化缓存
4397
+ *
4398
+ * @returns Credit 购买引导配置,key 为错误码。如果后端未返回,则使用默认配置
4399
+ */
4400
+ getCreditPurchaseActions(): Record<string, {
4401
+ labelZh: string;
4402
+ labelEn: string;
4403
+ url: string;
4404
+ showButton?: boolean;
4405
+ }>;
3030
4406
  /**
3031
4407
  * Generate a unique request ID
3032
4408
  */
@@ -3049,7 +4425,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3049
4425
  /**
3050
4426
  * Upload files to cloud storage via COS presigned URL
3051
4427
  *
3052
- * @param params - files array (File objects in browser)
4428
+ * @param params - files array (File objects in browser), optional abortSignal
3053
4429
  * @returns Response with corresponding cloud URLs
3054
4430
  */
3055
4431
  uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
@@ -3073,53 +4449,282 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
3073
4449
  private emitEvent;
3074
4450
  /**
3075
4451
  * 获取支持的场景列表
3076
- * API 端点: GET /console/as/support/scenes
4452
+ * API 端点: GET /v2/as/support/scenes (不鉴权)
3077
4453
  * 用于 Welcome 页面的 QuickActions 快捷操作
3078
4454
  *
4455
+ * @param locale - 可选,语言环境(如 'zh-CN', 'en-US'),用于获取对应语言的场景数据
3079
4456
  * @returns Promise<SupportScene[]> 支持的场景列表
3080
4457
  */
3081
- getSupportScenes(): Promise<SupportScene[]>;
4458
+ getSupportScenes(locale?: string): Promise<SupportScene[]>;
3082
4459
  private toAgentState;
3083
4460
  /**
3084
4461
  * Helper: 将 GET 请求的 body 转换为 URL 查询参数
3085
4462
  */
3086
4463
  private buildGetUrl;
4464
+ /**
4465
+ * 获取已安装插件列表
4466
+ * GET /console/as/user/plugins/installed
4467
+ */
4468
+ getInstalledPlugins(forceRefresh?: boolean): Promise<Array<{
4469
+ name: string;
4470
+ marketplaceName: string;
4471
+ status: string;
4472
+ description?: string;
4473
+ version?: string;
4474
+ installScope?: 'user' | 'project';
4475
+ installedScopes?: Array<'user' | 'project' | 'local' | 'project-local'>;
4476
+ installId?: string;
4477
+ }>>;
4478
+ /**
4479
+ * 安装插件
4480
+ * POST /console/as/user/plugins/install
4481
+ *
4482
+ * @param pluginNames - 插件名称数组
4483
+ * @param marketplaceNameOrId - 市场名称或 ID
4484
+ */
4485
+ installPlugins(pluginNames: string[], marketplaceNameOrId: string, installScope?: 'user' | 'project' | 'project-local', marketplaceSource?: string, workspacePath?: string): Promise<{
4486
+ success: boolean;
4487
+ error?: string;
4488
+ }>;
4489
+ /**
4490
+ * 卸载插件
4491
+ * POST /console/as/user/plugins/installed/:id/uninstall
4492
+ *
4493
+ * 完整链路:
4494
+ * CloudAgentProvider.uninstallPlugin()
4495
+ * -> HTTP POST /console/as/user/plugins/installed/:id/uninstall
4496
+ * -> agentserver: PluginInstallService.Uninstall()
4497
+ * -> 软删除 DB + 异步同步到活跃沙箱
4498
+ *
4499
+ * @param pluginName - 插件名称
4500
+ * @param marketplaceName - 市场名称(用于标识唯一插件)
4501
+ * @param scope - 卸载范围 ('user' | 'project' | 'project-local')
4502
+ */
4503
+ uninstallPlugin(pluginName: string, marketplaceName: string, scope: 'user' | 'project' | 'project-local'): Promise<{
4504
+ success: boolean;
4505
+ error?: string;
4506
+ }>;
4507
+ /**
4508
+ * 获取插件市场列表
4509
+ * GET /console/as/marketplace/sources
4510
+ */
4511
+ getPluginMarketplaces(forceRefresh?: boolean): Promise<Array<{
4512
+ id: string;
4513
+ name: string;
4514
+ type: 'github' | 'local' | 'custom';
4515
+ source: {
4516
+ repo?: string;
4517
+ ref?: string;
4518
+ url?: string;
4519
+ };
4520
+ description?: string;
4521
+ isBuiltin?: boolean;
4522
+ }>>;
4523
+ /**
4524
+ * 获取市场下的插件列表
4525
+ * - 有 searchText: GET /console/as/marketplace/plugins/search (跨所有市场搜索)
4526
+ * - 无 searchText: GET /console/as/marketplace/plugins (指定市场)
4527
+ *
4528
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4529
+ * @param forceRefresh - 是否强制刷新
4530
+ * @param searchText - 搜索关键字(如果提供,则跨所有市场搜索)
4531
+ */
4532
+ getMarketplacePlugins(marketplaceNameOrId: string, forceRefresh?: boolean, searchText?: string): Promise<Array<{
4533
+ name: string;
4534
+ marketplaceName: string;
4535
+ description?: string;
4536
+ version?: string;
4537
+ author?: string;
4538
+ homepage?: string;
4539
+ iconUrl?: string;
4540
+ tags?: string[];
4541
+ installed?: boolean;
4542
+ status?: 'enabled' | 'disabled' | 'not-installed';
4543
+ installedScopes?: Array<'user' | 'project'>;
4544
+ hasUpdate?: boolean;
4545
+ latestVersion?: string;
4546
+ agents?: any;
4547
+ commands?: any;
4548
+ skills?: any;
4549
+ mcpServers?: any;
4550
+ hooks?: any;
4551
+ rules?: any;
4552
+ }>>;
4553
+ /**
4554
+ * 获取插件详情
4555
+ * GET /console/as/marketplace/plugins/:name/detail
4556
+ *
4557
+ * @param pluginName - 插件名称
4558
+ * @param marketplaceNameOrId - 市场名称或 ID(优先使用 ID,如果是名称则从缓存查询 ID)
4559
+ */
4560
+ getPluginDetail(pluginName: string, marketplaceNameOrId: string): Promise<{
4561
+ name: string;
4562
+ marketplaceName: string;
4563
+ description?: string;
4564
+ version?: string;
4565
+ author?: string;
4566
+ homepage?: string;
4567
+ iconUrl?: string;
4568
+ tags?: string[];
4569
+ installed?: boolean;
4570
+ status?: 'enabled' | 'disabled' | 'not-installed';
4571
+ installedScopes?: Array<'user' | 'project'>;
4572
+ readme?: string;
4573
+ configSchema?: Record<string, unknown>;
4574
+ tools?: Array<{
4575
+ name: string;
4576
+ description?: string;
4577
+ }>;
4578
+ resources?: Array<{
4579
+ name: string;
4580
+ description?: string;
4581
+ }>;
4582
+ prompts?: Array<{
4583
+ name: string;
4584
+ description?: string;
4585
+ }>;
4586
+ downloadCount?: number;
4587
+ lastUpdated?: string;
4588
+ license?: string;
4589
+ repositoryUrl?: string;
4590
+ } | null>;
4591
+ /**
4592
+ * 添加插件市场
4593
+ * POST /console/as/marketplace/sources
4594
+ */
4595
+ addPluginMarketplace(sourceUrl: string, name?: string): Promise<{
4596
+ success: boolean;
4597
+ error?: string;
4598
+ marketplace?: {
4599
+ id: string;
4600
+ name: string;
4601
+ type: 'github' | 'local' | 'custom';
4602
+ source: {
4603
+ repo?: string;
4604
+ ref?: string;
4605
+ url?: string;
4606
+ };
4607
+ description?: string;
4608
+ isBuiltin?: boolean;
4609
+ };
4610
+ }>;
4611
+ /**
4612
+ * 删除插件市场
4613
+ * POST /console/as/marketplace/sources/:id/delete
4614
+ */
4615
+ removePluginMarketplace(marketplaceNameOrId: string): Promise<{
4616
+ success: boolean;
4617
+ error?: string;
4618
+ }>;
4619
+ /**
4620
+ * 刷新插件市场
4621
+ * POST /console/as/marketplace/sources/:id/check-updates
4622
+ */
4623
+ refreshPluginMarketplace(marketplaceNameOrId: string): Promise<{
4624
+ success: boolean;
4625
+ error?: string;
4626
+ plugins?: Array<any>;
4627
+ }>;
4628
+ /**
4629
+ * 批量切换插件启用/禁用状态
4630
+ * POST /console/as/user/plugins/installed/:id/toggle
4631
+ */
4632
+ batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
4633
+ /**
4634
+ * 将后端插件数据映射为前端格式
4635
+ */
4636
+ private mapPluginData;
4637
+ /**
4638
+ * 从缓存中查找插件的 install_id
4639
+ * 如果缓存未命中,则调用 API 获取并缓存
4640
+ *
4641
+ * @param pluginName - 插件名称
4642
+ * @returns install_id 或 null
4643
+ */
4644
+ private findPluginInstallId;
4645
+ /**
4646
+ * 从缓存中查找 marketplace ID
4647
+ * 如果缓存未命中,则调用 API 获取并缓存
4648
+ */
4649
+ private findMarketplaceId;
4650
+ /**
4651
+ * 提取 API 错误信息
4652
+ * 从 AxiosError 中提取详细的错误信息,包括 HTTP 状态码、错误码和错误消息
4653
+ */
4654
+ private extractErrorMessage;
4655
+ /**
4656
+ * 映射后端 source_type 到前端类型
4657
+ */
4658
+ private mapSourceType;
4659
+ /**
4660
+ * 解析 capabilities JSON 字符串
4661
+ */
4662
+ private parseCapabilities;
4663
+ /**
4664
+ * 上报 telemetry 事件(Cloud 模式)
4665
+ * 通过 HTTP POST 发送到 /v2/report
4666
+ * 注入用户信息和浏览器环境等公共字段
4667
+ */
4668
+ reportTelemetry(eventName: string, payload: Record<string, unknown>): Promise<void>;
3087
4669
  }
3088
4670
  //#endregion
3089
4671
  //#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
3090
4672
  /**
3091
- * E2B Filesystem Implementation
4673
+ * Callback to fetch fresh sandbox connection info from backend.
4674
+ * Called when an operation fails with 401/403.
4675
+ */
4676
+ type ReconnectFn = () => Promise<E2BSandboxConnectionInfo>;
4677
+ /**
4678
+ * E2B Filesystem
3092
4679
  *
3093
- * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource interface.
4680
+ * Wraps E2B Sandbox SDK's filesystem operations to implement FilesResource.
4681
+ * When `reconnectFn` is provided, automatically reconnects on auth errors.
3094
4682
  *
3095
4683
  * @example
3096
4684
  * ```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');
4685
+ * // Basic usage (no auto-reconnect)
4686
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
3105
4687
  *
3106
- * // Watch for changes
3107
- * const handle = await fs.watchDir('/workspace', (event) => {
3108
- * console.log('File changed:', event);
3109
- * });
4688
+ * // With auto-reconnect on token expiry
4689
+ * const fs = await E2BFilesystem.connect({ sandboxId: '...' });
4690
+ * fs.setReconnectFn(async () => fetchFreshConnectionInfo());
3110
4691
  * ```
3111
4692
  */
3112
4693
  declare class E2BFilesystem implements FilesResource {
3113
4694
  private sandbox;
4695
+ private reconnectFn?;
4696
+ /** Whether a reconnect is currently in-flight */
4697
+ private isReconnecting;
4698
+ /** Callers waiting for the in-flight reconnect to complete */
4699
+ private reconnectSubscribers;
4700
+ /** Timestamp of last reconnect attempt (anti-loop: min 10s between attempts) */
4701
+ private lastReconnectAt;
4702
+ private static readonly MIN_RECONNECT_INTERVAL_MS;
3114
4703
  constructor(sandbox: Sandbox);
3115
4704
  /**
3116
4705
  * Connect to an E2B Sandbox and create filesystem instance
3117
4706
  */
3118
4707
  static connect(info: E2BSandboxConnectionInfo): Promise<E2BFilesystem>;
4708
+ /**
4709
+ * Set reconnect callback. When set, auth errors trigger automatic reconnect + retry.
4710
+ */
4711
+ setReconnectFn(fn: ReconnectFn): void;
3119
4712
  /**
3120
4713
  * Get the underlying E2B Sandbox instance
3121
4714
  */
3122
4715
  getSandbox(): Sandbox;
4716
+ private isAuthError;
4717
+ private canAttemptReconnect;
4718
+ /**
4719
+ * Reconnect with fresh credentials.
4720
+ * Only one reconnect in-flight at a time; concurrent callers share the result.
4721
+ */
4722
+ private reconnect;
4723
+ /**
4724
+ * Execute an operation. If reconnectFn is set and an auth error occurs,
4725
+ * reconnect and retry once.
4726
+ */
4727
+ private exec;
3123
4728
  read(path: string, opts?: FilesystemRequestOpts & {
3124
4729
  format?: 'text';
3125
4730
  }): Promise<string>;
@@ -3134,13 +4739,13 @@ declare class E2BFilesystem implements FilesResource {
3134
4739
  }): Promise<ReadableStream<Uint8Array>>;
3135
4740
  write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<WriteInfo>;
3136
4741
  write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
3137
- list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
4742
+ list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo[]>;
3138
4743
  exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
3139
4744
  makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
3140
4745
  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 & {
4746
+ rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
4747
+ getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo>;
4748
+ watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
3144
4749
  onExit?: (err?: Error) => void | Promise<void>;
3145
4750
  }): Promise<WatchHandle>;
3146
4751
  }
@@ -3262,6 +4867,7 @@ interface ActiveSessionImplOptions {
3262
4867
  declare class ActiveSessionImpl implements ActiveSession {
3263
4868
  private _id;
3264
4869
  private _agentId;
4870
+ private _cwd?;
3265
4871
  private _availableModes?;
3266
4872
  private _currentMode?;
3267
4873
  private _availableModels?;
@@ -3273,6 +4879,7 @@ declare class ActiveSessionImpl implements ActiveSession {
3273
4879
  private _connectionInfo?;
3274
4880
  private listeners;
3275
4881
  private onceListeners;
4882
+ private connectionListeners;
3276
4883
  /**
3277
4884
  * Agent operations namespace
3278
4885
  */
@@ -3306,6 +4913,14 @@ declare class ActiveSessionImpl implements ActiveSession {
3306
4913
  * Agent ID
3307
4914
  */
3308
4915
  get agentId(): string;
4916
+ /**
4917
+ * Actual workspace path (set from newSession response _meta)
4918
+ */
4919
+ get cwd(): string | undefined;
4920
+ /**
4921
+ * Set actual workspace path (called by SessionManager after createSession)
4922
+ */
4923
+ setCwd(cwd: string): void;
3309
4924
  /**
3310
4925
  * Agent state (live connection state)
3311
4926
  * Returns LocalAgentState or CloudAgentState based on transport type
@@ -3387,12 +5002,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3387
5002
  */
3388
5003
  cancelQuestion(toolCallId: string, reason?: string): boolean;
3389
5004
  /**
3390
- * Callback for tool operations (skip or cancel)
5005
+ * Callback for tool operations (approve / skip / cancel)
3391
5006
  * @param toolCallId Tool call ID
3392
5007
  * @param toolName Tool name
3393
- * @param action Action to perform ('skip' or 'cancel')
5008
+ * @param action Action to perform ('approve' / 'skip' / 'cancel')
3394
5009
  */
3395
- toolCallback(toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
5010
+ toolCallback(toolCallId: string, toolName: string, action: 'approve' | 'skip' | 'cancel'): Promise<{
3396
5011
  success: boolean;
3397
5012
  error?: string;
3398
5013
  }>;
@@ -3450,6 +5065,12 @@ declare class ActiveSessionImpl implements ActiveSession {
3450
5065
  * Disconnect from the session/agent
3451
5066
  */
3452
5067
  disconnect(): void;
5068
+ /**
5069
+ * Detach the session from connection events without disconnecting the connection.
5070
+ * This should be called when the session is being replaced but the connection is shared.
5071
+ * Unlike disconnect(), this only removes event listeners without closing the connection.
5072
+ */
5073
+ detach(): void;
3453
5074
  /**
3454
5075
  * Symbol.dispose for 'using' keyword support
3455
5076
  * Automatically disconnects and cleans up when session goes out of scope
@@ -3464,8 +5085,21 @@ declare class ActiveSessionImpl implements ActiveSession {
3464
5085
  */
3465
5086
  [Symbol.dispose](): void;
3466
5087
  private getConnectionOrThrow;
5088
+ /**
5089
+ * 在 connection 上注册 listener 并保存引用,便于 disconnect 时移除
5090
+ */
5091
+ private addConnectionListener;
5092
+ /**
5093
+ * 从 connection 上移除所有本 session 注册的 listener
5094
+ */
5095
+ private removeConnectionListeners;
3467
5096
  private setupConnectionEvents;
3468
5097
  private mapPromptResponse;
5098
+ /**
5099
+ * 判断 artifact 是否应该转发给当前 session
5100
+ * 所有类型的 artifact 都按 __sessionId 严格隔离
5101
+ */
5102
+ private shouldForwardArtifact;
3469
5103
  }
3470
5104
  //#endregion
3471
5105
  //#region ../agent-provider/lib/common/client/session-manager.d.ts
@@ -3570,6 +5204,13 @@ declare class SessionManager {
3570
5204
  */
3571
5205
  declare class BackendProvider implements IBackendProvider {
3572
5206
  constructor(config: BackendProviderConfig);
5207
+ /**
5208
+ * 处理 401 未授权错误
5209
+ * 先尝试刷新 token,失败后再执行登出流程
5210
+ *
5211
+ * @throws 如果 token 刷新失败,抛出错误通知 HttpService 不要重试
5212
+ */
5213
+ protected handleUnauthorized(): Promise<void>;
3573
5214
  /**
3574
5215
  * 获取当前账号信息
3575
5216
  * API 端点: GET /console/accounts (返回账号列表)
@@ -3680,9 +5321,21 @@ declare class BackendProvider implements IBackendProvider {
3680
5321
  login(): Promise<void>;
3681
5322
  /**
3682
5323
  * 登出账号
3683
- * Web 环境: 通过 iframe 访问登出 URL 清除 cookie
5324
+ *
5325
+ * 策略:
5326
+ * - IOA 企业:用 iframe 走 SSO/SAML SLO 登出链路(涉及跨域重定向),通过轮询 iframe URL 变化检测完成
5327
+ * - 非 IOA 企业:直接用 httpService 请求 /console/logout,速度快
3684
5328
  */
3685
5329
  logout(): Promise<void>;
5330
+ /**
5331
+ * IOA 企业登出:通过 iframe 走 SSO/SAML SLO 登出链路
5332
+ * 轮询 iframe URL 变化检测完成,兜底超时 5 秒
5333
+ */
5334
+ private logoutViaIframe;
5335
+ /**
5336
+ * 非 IOA 企业登出:直接 HTTP 请求 /console/logout
5337
+ */
5338
+ private logoutViaHttp;
3686
5339
  /**
3687
5340
  * 批量切换插件状态
3688
5341
  * Web 环境不支持此功能
@@ -3725,6 +5378,41 @@ declare class BackendProvider implements IBackendProvider {
3725
5378
  * @returns Promise<ListReposResponse> 仓库列表响应
3726
5379
  */
3727
5380
  getRepositories(connector: OauthConnectorName, page?: number, perPage?: number): Promise<ListReposResponse>;
5381
+ /**
5382
+ * 保存待发送的输入内容到后端
5383
+ * API 端点: POST /api/v1/code-id
5384
+ */
5385
+ savePendingInput(code: string): Promise<string | null>;
5386
+ /**
5387
+ * 从后端加载待发送的输入内容
5388
+ * API 端点: GET /api/v1/code?id=xxx
5389
+ */
5390
+ loadPendingInput(codeId: string): Promise<string | null>;
5391
+ /**
5392
+ * 获取每日签到状态
5393
+ * API 端点: POST /billing/meter/checkin-status
5394
+ */
5395
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5396
+ /**
5397
+ * 执行每日签到
5398
+ * API 端点: POST /billing/meter/daily-checkin
5399
+ */
5400
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
5401
+ private static readonly SKILLHUB_BASE_URL;
5402
+ private static readonly SKILLHUB_FETCH_TIMEOUT;
5403
+ private skillHubFetch;
5404
+ getSkillHubList(params?: SkillHubListParams): Promise<SkillHubListResponse>;
5405
+ getSkillHubCategories(): Promise<SkillHubCategoriesResponse>;
5406
+ getSkillHubSearch(q: string, limit?: number): Promise<SkillHubSearchResponse>;
5407
+ getSkillHubDetail(slug: string): Promise<SkillHubDetailResponse>;
5408
+ getSkillHubExists(slugs: string[]): Promise<SkillHubExistsResponse>;
5409
+ reportSkillHubStats(slug: string, inc: {
5410
+ downloads?: number;
5411
+ installs?: number;
5412
+ stars?: number;
5413
+ }): Promise<void>;
5414
+ installSkillHubSkill(_slug: string, _version?: string, _name?: string): Promise<SkillHubInstallResponse>;
5415
+ getSkillHubInstalledMetas(): Promise<SkillHubInstalledMeta[]>;
3728
5416
  }
3729
5417
  /**
3730
5418
  * 创建 BackendProvider 实例
@@ -3853,6 +5541,14 @@ declare class IPCBackendProvider implements IBackendProvider {
3853
5541
  reloadWindow(params?: {
3854
5542
  locale?: string;
3855
5543
  }): Promise<void>;
5544
+ /**
5545
+ * Save locale to argv.json without restarting the app.
5546
+ * The change takes effect on next manual restart.
5547
+ * @param params locale to save
5548
+ */
5549
+ saveLocale(params: {
5550
+ locale: string;
5551
+ }): Promise<void>;
3856
5552
  /**
3857
5553
  * 关闭 Agent Manager 面板
3858
5554
  * IDE 环境: 通过 IPC 通知 IDE 关闭 Agent Manager(用于返回 IDE)
@@ -3881,6 +5577,71 @@ declare class IPCBackendProvider implements IBackendProvider {
3881
5577
  * 4. 返回 SupportScene[] 数据给 agent-ui
3882
5578
  */
3883
5579
  getSupportScenes(): Promise<SupportScene[]>;
5580
+ /**
5581
+ * 获取账号用量信息(积分/Credits)
5582
+ * IDE 环境: 通过 IPC 实时获取用量信息,每次打开菜单时调用
5583
+ *
5584
+ * 调用链:
5585
+ * 1. agent-ui: IPCBackendProvider.getAccountUsage()
5586
+ * 2. Agent Manager renderer: BackendService.getAccountUsage()
5587
+ * 3. Main Process: codebuddy:getAccountUsage IPC handler
5588
+ * 4. 返回 { usageLeft, usageTotal, editionType, refreshAt } 等字段
5589
+ */
5590
+ getAccountUsage(): Promise<Partial<Account> | null>;
5591
+ /**
5592
+ * 获取每日签到状态
5593
+ * IDE 环境: 通过 IPC 获取签到状态
5594
+ */
5595
+ getCheckinStatus(): Promise<CheckinStatusResponse | null>;
5596
+ /**
5597
+ * 执行每日签到
5598
+ * IDE 环境: 通过 IPC 执行签到
5599
+ */
5600
+ claimDailyCheckin(): Promise<CheckinResultResponse>;
5601
+ /**
5602
+ * 获取 SkillHub 技能列表
5603
+ * IDE 环境: 通过 IPC 获取技能列表
5604
+ */
5605
+ getSkillHubList(params?: SkillHubListParams): Promise<SkillHubListResponse>;
5606
+ /**
5607
+ * 获取 SkillHub 分类列表
5608
+ * IDE 环境: 通过 IPC 获取分类列表
5609
+ */
5610
+ getSkillHubCategories(): Promise<SkillHubCategoriesResponse>;
5611
+ /**
5612
+ * 搜索 SkillHub 技能
5613
+ * IDE 环境: 通过 IPC 搜索技能
5614
+ */
5615
+ getSkillHubSearch(q: string, limit?: number): Promise<SkillHubSearchResponse>;
5616
+ /**
5617
+ * 获取 SkillHub 技能详情
5618
+ * IDE 环境: 通过 IPC 获取技能详情
5619
+ */
5620
+ getSkillHubDetail(slug: string): Promise<SkillHubDetailResponse>;
5621
+ /**
5622
+ * 批量检查 SkillHub 技能是否存在
5623
+ * IDE 环境: 通过 IPC 检查技能是否存在
5624
+ */
5625
+ getSkillHubExists(slugs: string[]): Promise<SkillHubExistsResponse>;
5626
+ /**
5627
+ * 上报 SkillHub 技能统计
5628
+ * IDE 环境: 通过 IPC 上报统计
5629
+ */
5630
+ reportSkillHubStats(slug: string, inc: {
5631
+ downloads?: number;
5632
+ installs?: number;
5633
+ stars?: number;
5634
+ }): Promise<void>;
5635
+ /**
5636
+ * 安装 SkillHub 技能
5637
+ * IDE 环境: 通过 IPC 安装技能(下载 zip → 解压到本地)
5638
+ */
5639
+ installSkillHubSkill(slug: string, version?: string, name?: string): Promise<SkillHubInstallResponse>;
5640
+ /**
5641
+ * 获取本地已安装的 SkillHub 技能元信息
5642
+ * IDE 环境: 通过 IPC 获取元信息
5643
+ */
5644
+ getSkillHubInstalledMetas(): Promise<SkillHubInstalledMeta[]>;
3884
5645
  /**
3885
5646
  * 调试日志
3886
5647
  */
@@ -3918,7 +5679,7 @@ type RequestErrorInterceptor = (error: any) => any;
3918
5679
  /**
3919
5680
  * 响应拦截器函数
3920
5681
  */
3921
- type ResponseInterceptor = (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
5682
+ type ResponseInterceptor = (response: AxiosResponse$1) => AxiosResponse$1 | Promise<AxiosResponse$1>;
3922
5683
  /**
3923
5684
  * 响应错误拦截器函数
3924
5685
  */
@@ -3935,7 +5696,7 @@ type UnauthorizedCallback = () => void;
3935
5696
  * 特性:
3936
5697
  * - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
3937
5698
  * - 支持拦截器注册(其他模块可注入 header)
3938
- * - 统一 401/403 处理
5699
+ * - 统一 401 处理(支持自动刷新 token 并重试)
3939
5700
  * - 自动携带凭证(withCredentials)
3940
5701
  * - 类型安全
3941
5702
  *
@@ -3971,6 +5732,10 @@ declare class HttpService {
3971
5732
  private axiosInstance;
3972
5733
  private unauthorizedCallbacks;
3973
5734
  private config;
5735
+ /** 是否正在刷新 token */
5736
+ private isRefreshing;
5737
+ /** 等待 token 刷新完成的请求队列 */
5738
+ private refreshSubscribers;
3974
5739
  /**
3975
5740
  * 私有构造函数(单例模式)
3976
5741
  */
@@ -3988,9 +5753,17 @@ declare class HttpService {
3988
5753
  */
3989
5754
  private registerDefaultRequestInterceptor;
3990
5755
  /**
3991
- * 注册默认响应拦截器(处理 401/403)
5756
+ * 注册默认响应拦截器(处理 401,支持自动重试)
3992
5757
  */
3993
5758
  private registerDefaultResponseInterceptor;
5759
+ /**
5760
+ * token 刷新成功,通知所有等待的请求
5761
+ */
5762
+ private onRefreshSuccess;
5763
+ /**
5764
+ * token 刷新失败,通知所有等待的请求
5765
+ */
5766
+ private onRefreshFailure;
3994
5767
  /**
3995
5768
  * 注册请求拦截器
3996
5769
  * @param onFulfilled 请求成功拦截器
@@ -4056,7 +5829,9 @@ declare class HttpService {
4056
5829
  */
4057
5830
  offUnauthorized(callback: UnauthorizedCallback): void;
4058
5831
  /**
4059
- * 触发所有 401 回调
5832
+ * 触发所有 401 回调并等待完成
5833
+ * @returns Promise,等待所有回调完成
5834
+ * @throws 如果任何回调失败,则抛出错误
4060
5835
  */
4061
5836
  private triggerUnauthorizedCallbacks;
4062
5837
  /**
@@ -4107,6 +5882,12 @@ declare class HttpService {
4107
5882
  * @returns 响应数据
4108
5883
  */
4109
5884
  put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
5885
+ /**
5886
+ * 通用请求方法
5887
+ * @param config axios 请求配置
5888
+ * @returns 原始 AxiosResponse
5889
+ */
5890
+ request<T = any>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
4110
5891
  /**
4111
5892
  * 获取原始 axios 实例(用于高级场景)
4112
5893
  */