@tencent-ai/cloud-agent-sdk 0.2.7 → 0.2.11-next.84259fc.20260131
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.cjs +14994 -549
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1607 -497
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1607 -497
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4327 -554
- package/dist/index.mjs.map +1 -1
- package/dist/tencent-ai-cloud-agent-sdk-0.2.11-next.84259fc.20260131.tgz +0 -0
- package/package.json +4 -3
- package/dist/tencent-ai-cloud-agent-sdk-0.2.7.tgz +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -142,8 +142,14 @@ interface QuestionRequest {
|
|
|
142
142
|
sessionId: string;
|
|
143
143
|
/** Associated tool call ID (links extMethod to tool_call for UI) */
|
|
144
144
|
toolCallId: string;
|
|
145
|
-
/**
|
|
146
|
-
|
|
145
|
+
/** Input type */
|
|
146
|
+
inputType?: string;
|
|
147
|
+
/** Schema containing questions */
|
|
148
|
+
schema?: {
|
|
149
|
+
/** Questions to ask (1-4) */questions: UserQuestion[];
|
|
150
|
+
};
|
|
151
|
+
/** Questions to ask (1-4) - legacy format */
|
|
152
|
+
questions?: UserQuestion[];
|
|
147
153
|
/** Request timeout in ms */
|
|
148
154
|
timeout?: number;
|
|
149
155
|
}
|
|
@@ -202,7 +208,7 @@ interface FileChangeInfo {
|
|
|
202
208
|
deletions: number;
|
|
203
209
|
/** Unified diff format content
|
|
204
210
|
* https://unifiedjs.com/explore/package/unified-diff/
|
|
205
|
-
|
|
211
|
+
*/
|
|
206
212
|
diff?: string;
|
|
207
213
|
/** File language */
|
|
208
214
|
language?: string;
|
|
@@ -262,12 +268,6 @@ interface AgentCapabilities extends AgentCapabilities$1 {
|
|
|
262
268
|
} | null;
|
|
263
269
|
}
|
|
264
270
|
//#endregion
|
|
265
|
-
//#region ../agent-client-protocol/lib/common/client/questions.d.ts
|
|
266
|
-
/**
|
|
267
|
-
* User's answers to questions
|
|
268
|
-
*/
|
|
269
|
-
type QuestionAnswers = Record<string, string | string[]>;
|
|
270
|
-
//#endregion
|
|
271
271
|
//#region ../agent-client-protocol/lib/common/client/types.d.ts
|
|
272
272
|
/**
|
|
273
273
|
* Client connection states
|
|
@@ -333,225 +333,947 @@ interface ClientEvents extends Record<string, unknown> {
|
|
|
333
333
|
checkpointUpdated: CheckpointInfo;
|
|
334
334
|
}
|
|
335
335
|
//#endregion
|
|
336
|
-
//#region ../agent-
|
|
337
|
-
/**
|
|
338
|
-
* Widget Channel 接口
|
|
339
|
-
* 定义 Widget 与 Agent Manager 的通信抽象
|
|
340
|
-
* 面向 ACP 协议设计,使用 sessionId 作为主要标识符
|
|
341
|
-
*/
|
|
342
|
-
interface IWidgetChannel {
|
|
343
|
-
/**
|
|
344
|
-
* 发送通知到指定 session(fire-and-forget)
|
|
345
|
-
* Channel 层负责路由到正确的 window
|
|
346
|
-
* 不需要等待响应时使用此方法
|
|
347
|
-
*
|
|
348
|
-
* @param sessionId ACP 会话 ID
|
|
349
|
-
* @param message 消息内容
|
|
350
|
-
* @returns 是否发送成功
|
|
351
|
-
*/
|
|
352
|
-
sendNotification(sessionId: string, message: any): Promise<boolean>;
|
|
353
|
-
/**
|
|
354
|
-
* 调用远程方法并等待响应
|
|
355
|
-
* 需要响应时使用此方法(推荐)
|
|
356
|
-
*
|
|
357
|
-
* @param sessionId ACP 会话 ID
|
|
358
|
-
* @param message 消息内容
|
|
359
|
-
* @param timeoutMs 超时时间(毫秒,默认 5000)
|
|
360
|
-
* @returns Promise 包含响应数据
|
|
361
|
-
*/
|
|
362
|
-
callMethod(sessionId: string, message: any, timeoutMs?: number): Promise<any>;
|
|
363
|
-
/**
|
|
364
|
-
* 绑定 session 到 window
|
|
365
|
-
* 用于创建新对话时建立 sessionId → windowId 映射
|
|
366
|
-
*
|
|
367
|
-
* @param sessionId ACP 会话 ID
|
|
368
|
-
* @param windowId 窗口 ID
|
|
369
|
-
*/
|
|
370
|
-
bindSession?(sessionId: string, windowId: number): void;
|
|
371
|
-
/**
|
|
372
|
-
* 解除 session 绑定
|
|
373
|
-
*
|
|
374
|
-
* @param sessionId ACP 会话 ID
|
|
375
|
-
*/
|
|
376
|
-
unbindSession?(sessionId: string): void;
|
|
377
|
-
/** 注册事件监听器 */
|
|
378
|
-
on(event: string, handler: (data?: any) => void): void;
|
|
379
|
-
/** 注销事件监听器 */
|
|
380
|
-
off(event: string, handler: (data?: any) => void): void;
|
|
381
|
-
/** 触发事件(向外部发送事件) */
|
|
382
|
-
emit(event: string, data?: any): void;
|
|
383
|
-
/** 清除所有事件监听器 */
|
|
384
|
-
clear?(): void;
|
|
385
|
-
}
|
|
336
|
+
//#region ../agent-client-protocol/lib/common/client/questions.d.ts
|
|
386
337
|
/**
|
|
387
|
-
*
|
|
388
|
-
* 参考: https://agentclientprotocol.com/protocol/slash-commands
|
|
338
|
+
* User's answers to questions
|
|
389
339
|
*/
|
|
390
|
-
|
|
391
|
-
/** 命令名称 (如 "web", "test", "plan") */
|
|
392
|
-
readonly name: string;
|
|
393
|
-
/** 人类可读的命令描述 */
|
|
394
|
-
readonly description: string;
|
|
395
|
-
/** 可选的输入规范 */
|
|
396
|
-
readonly input?: {
|
|
397
|
-
/** 输入提示,当用户未提供输入时显示 */readonly hint?: string;
|
|
398
|
-
};
|
|
399
|
-
}
|
|
340
|
+
type QuestionAnswers = Record<string, string | string[]>;
|
|
400
341
|
//#endregion
|
|
401
|
-
//#region ../agent-provider/lib/
|
|
402
|
-
/**
|
|
403
|
-
* Base options for filesystem operations
|
|
404
|
-
* 对齐 e2b SDK FilesystemRequestOpts
|
|
405
|
-
*/
|
|
406
|
-
interface FilesystemRequestOpts {
|
|
407
|
-
user?: string;
|
|
408
|
-
requestTimeoutMs?: number;
|
|
409
|
-
}
|
|
342
|
+
//#region ../agent-provider/lib/backend/types.d.ts
|
|
410
343
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
344
|
+
* Backend Provider 类型定义
|
|
345
|
+
*
|
|
346
|
+
* 定义 IBackendProvider 接口和配置
|
|
413
347
|
*/
|
|
414
|
-
interface FilesystemListOpts extends FilesystemRequestOpts {
|
|
415
|
-
depth?: number;
|
|
416
|
-
}
|
|
417
348
|
/**
|
|
418
|
-
*
|
|
419
|
-
* 对齐 e2b SDK WatchOpts
|
|
349
|
+
* 账号版本类型
|
|
420
350
|
*/
|
|
421
|
-
|
|
422
|
-
timeoutMs?: number;
|
|
423
|
-
onExit?: (err?: Error) => void | Promise<void>;
|
|
424
|
-
recursive?: boolean;
|
|
425
|
-
}
|
|
351
|
+
type Edition = 'pro' | 'personal' | 'ultimate' | 'exclusive';
|
|
426
352
|
/**
|
|
427
|
-
*
|
|
428
|
-
*
|
|
353
|
+
* 版本展示类型(用于 UI 展示)
|
|
354
|
+
* - free: 免费版(个人版未订阅 Pro)
|
|
355
|
+
* - pro: Pro 版(个人版已订阅 Pro)
|
|
356
|
+
* - ultimate: 旗舰版(团队版)
|
|
357
|
+
* - exclusive: 专享版(企业版)
|
|
429
358
|
*/
|
|
430
|
-
type
|
|
431
|
-
path: string;
|
|
432
|
-
data: string | ArrayBuffer | Blob | ReadableStream;
|
|
433
|
-
};
|
|
359
|
+
type EditionDisplayType = 'free' | 'pro' | 'ultimate' | 'exclusive';
|
|
434
360
|
/**
|
|
435
|
-
*
|
|
436
|
-
* 与 e2b SDK 的 ConnectionOpts 对齐
|
|
361
|
+
* 部署状态
|
|
437
362
|
*/
|
|
438
|
-
interface
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
apiKey?: string;
|
|
443
|
-
/** Access token for authentication (JWT 格式的 token) */
|
|
444
|
-
accessToken?: string;
|
|
445
|
-
/** Domain for the API (不带 https://) */
|
|
446
|
-
domain?: string;
|
|
447
|
-
/** API URL override (internal) */
|
|
448
|
-
apiUrl?: string;
|
|
449
|
-
/** Request timeout in milliseconds */
|
|
450
|
-
requestTimeoutMs?: number;
|
|
451
|
-
/** Debug mode */
|
|
452
|
-
debug?: boolean;
|
|
453
|
-
/**
|
|
454
|
-
* Additional headers to send with the request.
|
|
455
|
-
*/
|
|
456
|
-
headers?: Record<string, string>;
|
|
363
|
+
interface DeployStatus {
|
|
364
|
+
statusCode: number;
|
|
365
|
+
statusMsg: string;
|
|
366
|
+
detailMsg: string;
|
|
457
367
|
}
|
|
458
368
|
/**
|
|
459
|
-
*
|
|
460
|
-
* Mirrors e2b SDK Filesystem API
|
|
461
|
-
* 完全对齐 e2b SDK 的 Filesystem 类
|
|
369
|
+
* 套餐代码
|
|
462
370
|
*/
|
|
463
|
-
interface FilesResource {
|
|
464
|
-
/** Read file content as text (default) */
|
|
465
|
-
read(path: string, opts?: FilesystemRequestOpts & {
|
|
466
|
-
format?: 'text';
|
|
467
|
-
}): Promise<string>;
|
|
468
|
-
/** Read file content as bytes */
|
|
469
|
-
read(path: string, opts: FilesystemRequestOpts & {
|
|
470
|
-
format: 'bytes';
|
|
471
|
-
}): Promise<Uint8Array>;
|
|
472
|
-
/** Read file content as blob */
|
|
473
|
-
read(path: string, opts: FilesystemRequestOpts & {
|
|
474
|
-
format: 'blob';
|
|
475
|
-
}): Promise<Blob>;
|
|
476
|
-
/** Read file content as stream */
|
|
477
|
-
read(path: string, opts: FilesystemRequestOpts & {
|
|
478
|
-
format: 'stream';
|
|
479
|
-
}): Promise<ReadableStream<Uint8Array>>;
|
|
480
|
-
/** Write content to a single file */
|
|
481
|
-
write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<WriteInfo>;
|
|
482
|
-
/** Write multiple files in batch */
|
|
483
|
-
write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
|
|
484
|
-
/** List directory contents with optional depth */
|
|
485
|
-
list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
|
|
486
|
-
/** Check if path exists */
|
|
487
|
-
exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
|
|
488
|
-
/** Create directory */
|
|
489
|
-
makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
|
|
490
|
-
/** Remove file or directory */
|
|
491
|
-
remove(path: string, opts?: FilesystemRequestOpts): Promise<void>;
|
|
492
|
-
/** Rename/move file or directory */
|
|
493
|
-
rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
|
|
494
|
-
/** Get file or directory information */
|
|
495
|
-
getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
|
|
496
|
-
/** Watch directory for changes */
|
|
497
|
-
watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
|
|
498
|
-
onExit?: (err?: Error) => void | Promise<void>;
|
|
499
|
-
}): Promise<WatchHandle>;
|
|
500
|
-
}
|
|
501
371
|
/**
|
|
502
|
-
*
|
|
372
|
+
* TCACA_code_001_PqouKr6QWV CodeBuddy海外版免费包
|
|
373
|
+
* TCACA_code_002_AkiJS3ZHF5 CodeBuddy海外版Pro版本包-包月/CodeBuddy Pro Plan - Monthly:
|
|
374
|
+
* TCACA_code_006_DbXS0lrypC CodeBuddy海外版一次性免费赠送2周的Pro版本包/CodeBuddy One-time Free 2-Week Pro Plan Trial
|
|
375
|
+
* TCACA_code_007_nzdH5h4Nl0 CodeBuddy海外版运营裂变包/CodeBuddy Growth Plan
|
|
376
|
+
* TCACA_code_003_FAnt7lcmRT CodeBuddy海外版Pro版本包-包年/CodeBuddy Pro Plan - Yearly
|
|
377
|
+
* TCACA_code_008_cfWoLwvjU4 赠送月包
|
|
503
378
|
*/
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
379
|
+
declare enum CommodityCode {
|
|
380
|
+
free = "TCACA_code_001_PqouKr6QWV",
|
|
381
|
+
// free
|
|
382
|
+
proMon = "TCACA_code_002_AkiJS3ZHF5",
|
|
383
|
+
proMonPlus = "TCACA_code_005_maRGyrHhw1",
|
|
384
|
+
gift = "TCACA_code_006_DbXS0lrypC",
|
|
385
|
+
activity = "TCACA_code_007_nzdH5h4Nl0",
|
|
386
|
+
proYear = "TCACA_code_003_FAnt7lcmRT",
|
|
387
|
+
freeMon = "TCACA_code_008_cfWoLwvjU4",
|
|
388
|
+
// free
|
|
389
|
+
extra = "TCACA_code_009_0XmEQc2xOf"
|
|
510
390
|
}
|
|
511
391
|
/**
|
|
512
|
-
*
|
|
513
|
-
*/
|
|
514
|
-
type AgentTransport = 'cloud' | 'local';
|
|
515
|
-
/**
|
|
516
|
-
* Agent connection status
|
|
517
|
-
*/
|
|
518
|
-
type AgentStatus = 'disconnected' | 'connecting' | 'connected' | 'initialized' | 'error';
|
|
519
|
-
/**
|
|
520
|
-
* Agent information
|
|
392
|
+
* 套餐资源项(用于展示列表)
|
|
521
393
|
*/
|
|
522
|
-
interface
|
|
394
|
+
interface PlanResource {
|
|
395
|
+
/** 资源 ID */
|
|
523
396
|
id: string;
|
|
397
|
+
/** 套餐名称(i18n key) */
|
|
524
398
|
name: string;
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
399
|
+
/** 套餐代码 */
|
|
400
|
+
packageCode: CommodityCode;
|
|
401
|
+
/** 是否是每日刷新的套餐 */
|
|
402
|
+
isDaily: boolean;
|
|
403
|
+
/** 总量 */
|
|
404
|
+
total: number;
|
|
405
|
+
/** 已用 */
|
|
406
|
+
used: number;
|
|
407
|
+
/** 剩余 */
|
|
408
|
+
left: number;
|
|
409
|
+
/** 到期时间戳 */
|
|
410
|
+
expireAt?: number;
|
|
411
|
+
/** 刷新时间戳 */
|
|
412
|
+
refreshAt?: number;
|
|
531
413
|
}
|
|
532
414
|
/**
|
|
533
|
-
*
|
|
415
|
+
* 账号套餐信息
|
|
534
416
|
*/
|
|
535
|
-
interface
|
|
536
|
-
|
|
417
|
+
interface AccountPlan {
|
|
418
|
+
/** 是否是 Pro 版本 */
|
|
419
|
+
isPro: boolean;
|
|
420
|
+
isTria?: boolean;
|
|
421
|
+
/** 到期时间戳 */
|
|
422
|
+
expireAt?: number;
|
|
423
|
+
refreshAt?: number;
|
|
424
|
+
/** 自动续费标志 0-关闭 1-开启 */
|
|
425
|
+
renewFlag: 0 | 1;
|
|
426
|
+
/** 套餐代码 */
|
|
427
|
+
PackageCode?: CommodityCode;
|
|
428
|
+
/** 套餐名称 */
|
|
537
429
|
name: string;
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
interface Session {
|
|
544
|
-
id: string;
|
|
545
|
-
agentId: string;
|
|
546
|
-
availableModes?: SessionMode[];
|
|
547
|
-
currentMode?: string;
|
|
430
|
+
usageTotal?: string;
|
|
431
|
+
usageUsed?: string;
|
|
432
|
+
usageLeft?: string;
|
|
433
|
+
/** 所有套餐资源列表 */
|
|
434
|
+
resources?: PlanResource[];
|
|
548
435
|
}
|
|
549
436
|
/**
|
|
550
|
-
*
|
|
437
|
+
* 账号信息
|
|
551
438
|
*/
|
|
552
|
-
interface
|
|
553
|
-
|
|
554
|
-
|
|
439
|
+
interface Account {
|
|
440
|
+
/** 用户ID(唯一标识) */
|
|
441
|
+
uid: string;
|
|
442
|
+
/** 用户昵称 */
|
|
443
|
+
nickname: string;
|
|
444
|
+
/** 版本类型 */
|
|
445
|
+
type: Edition;
|
|
446
|
+
/** 版本展示类型(用于 UI 展示) */
|
|
447
|
+
editionType: EditionDisplayType;
|
|
448
|
+
/** 是否最后一次登录 */
|
|
449
|
+
lastLogin: boolean;
|
|
450
|
+
/** 企业ID */
|
|
451
|
+
enterpriseId?: string;
|
|
452
|
+
/** 企业名称 */
|
|
453
|
+
enterpriseName?: string;
|
|
454
|
+
/** 企业LOGO */
|
|
455
|
+
enterpriseLogo?: string;
|
|
456
|
+
/** 企业内用户名 */
|
|
457
|
+
enterpriseUserName?: string;
|
|
458
|
+
/** 插件是否启用 */
|
|
459
|
+
pluginEnabled?: boolean;
|
|
460
|
+
/** 部署状态 */
|
|
461
|
+
deployStatus?: DeployStatus;
|
|
462
|
+
/** 是否是 Pro 版本 */
|
|
463
|
+
isPro?: boolean;
|
|
464
|
+
/** 到期时间戳 */
|
|
465
|
+
expireAt?: string | number;
|
|
466
|
+
/** 刷新时间(年套餐下、本周期结束日期) */
|
|
467
|
+
refreshAt?: number;
|
|
468
|
+
/** 自动续费标志 0-关闭 1-开启 */
|
|
469
|
+
renewFlag?: 0 | 1;
|
|
470
|
+
/** 套餐代码 */
|
|
471
|
+
PackageCode?: CommodityCode;
|
|
472
|
+
/** 套餐名称 */
|
|
473
|
+
name?: string;
|
|
474
|
+
email?: string;
|
|
475
|
+
/** 套餐总用量 */
|
|
476
|
+
usageTotal?: string;
|
|
477
|
+
/** 套餐已用量 */
|
|
478
|
+
usageUsed?: string;
|
|
479
|
+
/** 套餐剩余用量 */
|
|
480
|
+
usageLeft?: string;
|
|
481
|
+
/** 所有套餐资源列表(个人用户) */
|
|
482
|
+
resources?: PlanResource[];
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* 推理配置
|
|
486
|
+
*/
|
|
487
|
+
interface ReasoningConfig {
|
|
488
|
+
/** 推理努力程度 */
|
|
489
|
+
effort: 'low' | 'medium' | 'high';
|
|
490
|
+
/** 摘要模式 */
|
|
491
|
+
summary: 'auto' | 'always' | 'never';
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* 用户连接器信息
|
|
495
|
+
*/
|
|
496
|
+
interface UserConnector {
|
|
497
|
+
/** 用户ID */
|
|
498
|
+
user_id: string;
|
|
499
|
+
/** 连接器名称 */
|
|
500
|
+
name: ConnectorType;
|
|
501
|
+
displayName: string;
|
|
502
|
+
/** 连接时间 */
|
|
503
|
+
connect_at: string;
|
|
504
|
+
/** 连接状态,0未连接,1已连接 */
|
|
505
|
+
connectStatus: 0 | 1;
|
|
506
|
+
/** 勾选仓库列表,逗号分隔 */
|
|
507
|
+
repos: string;
|
|
508
|
+
/** 激活状态,0未激活,1已激活 */
|
|
509
|
+
activeStatus: 0 | 1;
|
|
510
|
+
/** 提示词 */
|
|
511
|
+
prompt: string;
|
|
512
|
+
/** 跳转URL */
|
|
513
|
+
url: string;
|
|
514
|
+
/** 描述 */
|
|
515
|
+
description: string;
|
|
516
|
+
/** OAuth Client ID */
|
|
517
|
+
oauthClientId: string;
|
|
518
|
+
/** OAuth 重定向 URL */
|
|
519
|
+
oauthRedirectUrl: string;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* 获取用户连接器列表响应
|
|
523
|
+
*/
|
|
524
|
+
interface ListUserConnectorResponse {
|
|
525
|
+
/** 连接器列表 */
|
|
526
|
+
connectors: UserConnector[];
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* 修改用户连接器连接状态请求
|
|
530
|
+
*/
|
|
531
|
+
interface ModifyUserConnectorConnectStatusRequest {
|
|
532
|
+
/** 连接器名称 */
|
|
533
|
+
name: ConnectorType;
|
|
534
|
+
/** 连接状态,0未连接,1已连接 */
|
|
535
|
+
connectStatus: 0 | 1;
|
|
536
|
+
/** 激活状态,0未激活,1已激活 */
|
|
537
|
+
activeStatus?: 0 | 1;
|
|
538
|
+
/** 勾选仓库列表 */
|
|
539
|
+
repos?: string[];
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* 修改用户连接器仓库请求
|
|
543
|
+
*/
|
|
544
|
+
interface ModifyUserConnectorRepoRequest {
|
|
545
|
+
/** 连接器名称 */
|
|
546
|
+
name: ConnectorType;
|
|
547
|
+
/** 仓库列表 */
|
|
548
|
+
repo?: string[];
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* 修改用户连接器激活状态请求
|
|
552
|
+
*/
|
|
553
|
+
interface ModifyUserConnectorActiveStatusRequest {
|
|
554
|
+
/** 连接器名称 */
|
|
555
|
+
name: ConnectorType;
|
|
556
|
+
/** 激活状态,0未激活,1已激活 */
|
|
557
|
+
activeStatus: 0 | 1;
|
|
558
|
+
}
|
|
559
|
+
type ConnectorType = 'github' | 'gongfeng' | 'cnb' | 'figma';
|
|
560
|
+
/**
|
|
561
|
+
* 任务连接器信息
|
|
562
|
+
*/
|
|
563
|
+
interface TaskConnector {
|
|
564
|
+
/** 用户ID */
|
|
565
|
+
user_id: string;
|
|
566
|
+
/** 任务ID */
|
|
567
|
+
task_id: string;
|
|
568
|
+
/** 连接器名称(唯一标识,如github/gongfeng/figma/cnb) */
|
|
569
|
+
name: string;
|
|
570
|
+
displayName: string;
|
|
571
|
+
/** 勾选仓库列表,逗号分隔 */
|
|
572
|
+
repos: string;
|
|
573
|
+
/** 激活状态:0未激活 / 1已激活 */
|
|
574
|
+
activeStatus: 0 | 1;
|
|
575
|
+
/** 创建时间 */
|
|
576
|
+
created_at: string;
|
|
577
|
+
/** 更新时间 */
|
|
578
|
+
updated_at: string;
|
|
579
|
+
/** 提示词 */
|
|
580
|
+
prompt: string;
|
|
581
|
+
/** 跳转URL */
|
|
582
|
+
url: string;
|
|
583
|
+
/** 描述 */
|
|
584
|
+
description: string;
|
|
585
|
+
/** OAuth Client ID */
|
|
586
|
+
oauthClientId?: string;
|
|
587
|
+
/** OAuth 重定向 URL */
|
|
588
|
+
oauthRedirectUrl?: string;
|
|
589
|
+
/** 连接时间 */
|
|
590
|
+
connect_at: string;
|
|
591
|
+
/** 连接状态,0未连接,1已连接 */
|
|
592
|
+
connectStatus: 0 | 1;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* 添加任务请求
|
|
596
|
+
*/
|
|
597
|
+
interface AddTaskRequest {
|
|
598
|
+
/** 任务ID */
|
|
599
|
+
taskId: string;
|
|
600
|
+
/** 连接器列表 */
|
|
601
|
+
connectors?: Array<{
|
|
602
|
+
name: string;
|
|
603
|
+
repos: string;
|
|
604
|
+
activeStatus?: 0 | 1;
|
|
605
|
+
}>;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* 添加任务响应
|
|
609
|
+
*/
|
|
610
|
+
interface AddTaskResponse {
|
|
611
|
+
/** 任务ID */
|
|
612
|
+
taskId: string;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* 获取任务连接器列表响应
|
|
616
|
+
*/
|
|
617
|
+
interface ListTaskConnectorResponse {
|
|
618
|
+
/** 连接器列表 */
|
|
619
|
+
connectors: TaskConnector[];
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* 修改任务连接器激活状态请求
|
|
623
|
+
*/
|
|
624
|
+
interface ModifyTaskConnectorActiveStatusRequest {
|
|
625
|
+
/** 任务ID */
|
|
626
|
+
taskId: string;
|
|
627
|
+
/** 连接器名称 */
|
|
628
|
+
name: string;
|
|
629
|
+
/** 激活状态,0未激活,1已激活 */
|
|
630
|
+
activeStatus: 0 | 1;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* 修改任务连接器激活状态响应
|
|
634
|
+
*/
|
|
635
|
+
interface ModifyTaskConnectorActiveStatusResponse {
|
|
636
|
+
/** 任务ID */
|
|
637
|
+
taskId: string;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* 修改任务连接器仓库请求
|
|
641
|
+
*/
|
|
642
|
+
interface ModifyTaskConnectorRepoRequest {
|
|
643
|
+
/** 任务ID */
|
|
644
|
+
taskId: string;
|
|
645
|
+
/** 连接器名称 */
|
|
646
|
+
name: string;
|
|
647
|
+
/** 仓库列表 */
|
|
648
|
+
repo: string[];
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* 修改任务连接器仓库响应
|
|
652
|
+
*/
|
|
653
|
+
interface ModifyTaskConnectorRepoResponse {
|
|
654
|
+
/** 任务ID */
|
|
655
|
+
taskId: string;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* oauth回调请求参数
|
|
659
|
+
*/
|
|
660
|
+
interface SaveOauthTokenRequest {
|
|
661
|
+
/** 连接器名称 */
|
|
662
|
+
name: ConnectorType;
|
|
663
|
+
/** 第三方回调code */
|
|
664
|
+
authorizationCode: string;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* 获取仓库列表请求参数
|
|
668
|
+
*/
|
|
669
|
+
interface GetRepoListRequest {
|
|
670
|
+
/** 连接器名称 */
|
|
671
|
+
name: ConnectorType;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* 撤销所有OAuth连接请求参数
|
|
675
|
+
*/
|
|
676
|
+
interface RevokeAllRequest {
|
|
677
|
+
/** 连接器名称 */
|
|
678
|
+
name: ConnectorType;
|
|
679
|
+
/** 安装ID列表(可选,如果不传则撤销所有) */
|
|
680
|
+
installationIds?: string[];
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* GitHub 仓库所有者信息
|
|
684
|
+
*/
|
|
685
|
+
interface OauthGitHubRepoOwner {
|
|
686
|
+
login: string;
|
|
687
|
+
avatar_url: string;
|
|
688
|
+
url: string;
|
|
689
|
+
html_url: string;
|
|
690
|
+
followers_url: string;
|
|
691
|
+
starred_url: string;
|
|
692
|
+
repos_url: string;
|
|
693
|
+
events_url: string;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* GitHub 仓库信息
|
|
697
|
+
*/
|
|
698
|
+
interface OauthGitHubRepo {
|
|
699
|
+
name: string;
|
|
700
|
+
full_name: string;
|
|
701
|
+
private: boolean;
|
|
702
|
+
html_url: string;
|
|
703
|
+
url: string;
|
|
704
|
+
teams_url: string;
|
|
705
|
+
hooks_url: string;
|
|
706
|
+
events_url: string;
|
|
707
|
+
branches_url: string;
|
|
708
|
+
git_commits_url: string;
|
|
709
|
+
merges_url: string;
|
|
710
|
+
pulls_url: string;
|
|
711
|
+
git_url: string;
|
|
712
|
+
clone_url: string;
|
|
713
|
+
svn_url: string;
|
|
714
|
+
downloads_url: string;
|
|
715
|
+
description: string;
|
|
716
|
+
owner: OauthGitHubRepoOwner;
|
|
717
|
+
forks_count: number;
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* 工蜂仓库信息
|
|
721
|
+
*/
|
|
722
|
+
interface OauthGongfengRepo {
|
|
723
|
+
id: number;
|
|
724
|
+
description: string;
|
|
725
|
+
public: boolean;
|
|
726
|
+
archived: boolean;
|
|
727
|
+
visibility_level: number;
|
|
728
|
+
public_visibility: number;
|
|
729
|
+
namespace: {
|
|
730
|
+
name: string;
|
|
731
|
+
description: string;
|
|
732
|
+
path: string;
|
|
733
|
+
};
|
|
734
|
+
owner: {
|
|
735
|
+
username: string;
|
|
736
|
+
web_url: string;
|
|
737
|
+
name: string;
|
|
738
|
+
state: string;
|
|
739
|
+
avatar_url: string;
|
|
740
|
+
};
|
|
741
|
+
name: string;
|
|
742
|
+
name_with_namespace: string;
|
|
743
|
+
path: string;
|
|
744
|
+
path_with_namespace: string;
|
|
745
|
+
type: string;
|
|
746
|
+
default_branch: string;
|
|
747
|
+
ssh_url_to_repo: string;
|
|
748
|
+
http_url_to_repo: string;
|
|
749
|
+
https_url_to_repo: string;
|
|
750
|
+
web_url: string;
|
|
751
|
+
avatar_url: string;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* CNB仓库信息
|
|
755
|
+
*/
|
|
756
|
+
interface OauthCnbRepo {
|
|
757
|
+
name: string;
|
|
758
|
+
[key: string]: any;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* 获取仓库列表响应
|
|
762
|
+
*/
|
|
763
|
+
interface GetRepoListResponse {
|
|
764
|
+
github_repos?: {
|
|
765
|
+
[key: string | number]: OauthGitHubRepo[];
|
|
766
|
+
};
|
|
767
|
+
gongfeng_repos?: OauthGongfengRepo[];
|
|
768
|
+
cnb_repos?: OauthCnbRepo[];
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* OAuth 用户信息
|
|
772
|
+
*/
|
|
773
|
+
interface OauthUserInfo {
|
|
774
|
+
/** 头像 URL */
|
|
775
|
+
avatarUrl: string;
|
|
776
|
+
/** 用户名 */
|
|
777
|
+
name: string;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* 获取 OAuth 用户信息请求参数
|
|
781
|
+
*/
|
|
782
|
+
interface GetOauthUserRequest {
|
|
783
|
+
/** 连接器名称 */
|
|
784
|
+
name: ConnectorType;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* 获取 OAuth 用户信息响应
|
|
788
|
+
*/
|
|
789
|
+
interface GetOauthUserResponse {
|
|
790
|
+
/** 用户信息 */
|
|
791
|
+
user: OauthUserInfo;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Figma 文件信息
|
|
795
|
+
*/
|
|
796
|
+
interface FigmaFileInfo {
|
|
797
|
+
/** 文件名 */
|
|
798
|
+
name: string;
|
|
799
|
+
/** 角色 */
|
|
800
|
+
role: string;
|
|
801
|
+
/** 最后修改时间 */
|
|
802
|
+
lastModified: string;
|
|
803
|
+
/** 编辑器类型 */
|
|
804
|
+
editorType: string;
|
|
805
|
+
/** 缩略图 URL */
|
|
806
|
+
thumbnailUrl: string;
|
|
807
|
+
/** 版本 */
|
|
808
|
+
version: string;
|
|
809
|
+
/** 主文件 Key */
|
|
810
|
+
mainFileKey: string;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* 获取文件信息请求参数
|
|
814
|
+
*/
|
|
815
|
+
interface GetFileRequest {
|
|
816
|
+
/** 连接器名称 */
|
|
817
|
+
name: ConnectorType;
|
|
818
|
+
/** 文件 URL */
|
|
819
|
+
url: string;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* 获取文件信息响应
|
|
823
|
+
*/
|
|
824
|
+
interface GetFileResponse {
|
|
825
|
+
/** Figma 文件信息 */
|
|
826
|
+
figmaFileInfo: FigmaFileInfo | null;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Backend Provider 配置选项
|
|
830
|
+
*/
|
|
831
|
+
interface BackendProviderConfig {
|
|
832
|
+
/** API 基础 URL (例如: https://api.example.com) */
|
|
833
|
+
baseUrl: string;
|
|
834
|
+
/** 认证 Token */
|
|
835
|
+
authToken?: string;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* 企业用户用量信息
|
|
839
|
+
*/
|
|
840
|
+
interface EnterpriseUsage {
|
|
841
|
+
/** 已使用 credit */
|
|
842
|
+
credit: number;
|
|
843
|
+
/** 周期开始时间 */
|
|
844
|
+
cycleStartTime: string;
|
|
845
|
+
/** 周期结束时间 */
|
|
846
|
+
cycleEndTime: string;
|
|
847
|
+
/** 周期重置时间 */
|
|
848
|
+
cycleResetTime: string;
|
|
849
|
+
/** 限额数量 */
|
|
850
|
+
limitNum: number;
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* IBackendProvider 接口
|
|
854
|
+
*
|
|
855
|
+
* 定义与后端 API 交互的抽象接口
|
|
856
|
+
*
|
|
857
|
+
* 注意:getAgents 和 getModels 方法已废弃并移除,
|
|
858
|
+
* 请使用 IAgentAdapter 中的对应方法
|
|
859
|
+
*/
|
|
860
|
+
interface IBackendProvider {
|
|
861
|
+
/**
|
|
862
|
+
* 获取当前账号信息
|
|
863
|
+
* @returns Promise<Account | null> 账号信息,未登录时返回 null
|
|
864
|
+
*/
|
|
865
|
+
getAccount(): Promise<Account | null>;
|
|
866
|
+
/**
|
|
867
|
+
* 获取用户连接器列表
|
|
868
|
+
* @returns Promise<ListUserConnectorResponse | null> 用户连接器列表,失败时返回 null
|
|
869
|
+
*/
|
|
870
|
+
getUserConnector(): Promise<ListUserConnectorResponse>;
|
|
871
|
+
/**
|
|
872
|
+
* 修改用户连接器连接状态
|
|
873
|
+
* @param request 请求参数
|
|
874
|
+
* @returns Promise<void>
|
|
875
|
+
*/
|
|
876
|
+
modifyUserConnectorConnectStatus(request: ModifyUserConnectorConnectStatusRequest): Promise<void>;
|
|
877
|
+
/**
|
|
878
|
+
* 修改用户连接器仓库
|
|
879
|
+
* @param request 请求参数
|
|
880
|
+
* @returns Promise<void>
|
|
881
|
+
*/
|
|
882
|
+
modifyUserConnectorRepo(request: ModifyUserConnectorRepoRequest): Promise<void>;
|
|
883
|
+
/**
|
|
884
|
+
* 修改用户连接器激活状态
|
|
885
|
+
* @param request 请求参数
|
|
886
|
+
* @returns Promise<void>
|
|
887
|
+
*/
|
|
888
|
+
modifyUserConnectorActiveStatus(request: ModifyUserConnectorActiveStatusRequest): Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* 删除用户连接器
|
|
891
|
+
* @param name 连接器名称
|
|
892
|
+
* @returns Promise<void>
|
|
893
|
+
*/
|
|
894
|
+
deleteUserConnector(name: ConnectorType): Promise<void>;
|
|
895
|
+
/**
|
|
896
|
+
* 添加任务
|
|
897
|
+
* @param request 请求参数
|
|
898
|
+
* @returns Promise<AddTaskResponse>
|
|
899
|
+
*/
|
|
900
|
+
addConnectorTask(request: AddTaskRequest): Promise<AddTaskResponse>;
|
|
901
|
+
/**
|
|
902
|
+
* 获取任务连接器列表
|
|
903
|
+
* @param taskId 任务ID
|
|
904
|
+
* @returns Promise<ListTaskConnectorResponse>
|
|
905
|
+
*/
|
|
906
|
+
getTaskConnector(taskId: string): Promise<ListTaskConnectorResponse>;
|
|
907
|
+
/**
|
|
908
|
+
* 修改任务连接器激活状态
|
|
909
|
+
* @param request 请求参数
|
|
910
|
+
* @returns Promise<ModifyTaskConnectorActiveStatusResponse>
|
|
911
|
+
*/
|
|
912
|
+
modifyTaskConnectorActiveStatus(request: ModifyTaskConnectorActiveStatusRequest): Promise<ModifyTaskConnectorActiveStatusResponse>;
|
|
913
|
+
/**
|
|
914
|
+
* 修改任务连接器仓库
|
|
915
|
+
* @param request 请求参数
|
|
916
|
+
* @returns Promise<ModifyTaskConnectorRepoResponse>
|
|
917
|
+
*/
|
|
918
|
+
modifyTaskConnectorRepo(request: ModifyTaskConnectorRepoRequest): Promise<ModifyTaskConnectorRepoResponse>;
|
|
919
|
+
/**
|
|
920
|
+
* oauth回调,后端用第三方的code换token的
|
|
921
|
+
*/
|
|
922
|
+
saveOauthToken(request: SaveOauthTokenRequest): Promise<void>;
|
|
923
|
+
/**
|
|
924
|
+
* 获取OAuth连接器的仓库列表
|
|
925
|
+
* @param request 请求参数
|
|
926
|
+
* @returns Promise<GetRepoListResponse> 仓库列表响应
|
|
927
|
+
*/
|
|
928
|
+
getRepoList(request: GetRepoListRequest): Promise<GetRepoListResponse>;
|
|
929
|
+
/**
|
|
930
|
+
* 撤销OAuth连接器的所有连接
|
|
931
|
+
* @param request 请求参数
|
|
932
|
+
* @returns Promise<void>
|
|
933
|
+
*/
|
|
934
|
+
revokeAll(request: RevokeAllRequest): Promise<void>;
|
|
935
|
+
/**
|
|
936
|
+
* 获取 OAuth 用户信息
|
|
937
|
+
* @param request 请求参数
|
|
938
|
+
* @returns Promise<GetOauthUserResponse> 用户信息响应
|
|
939
|
+
*/
|
|
940
|
+
getOauthUser(request: GetOauthUserRequest): Promise<GetOauthUserResponse>;
|
|
941
|
+
/**
|
|
942
|
+
* 获取文件信息
|
|
943
|
+
* @param request 请求参数
|
|
944
|
+
* @returns Promise<GetFileResponse> 文件信息响应
|
|
945
|
+
*/
|
|
946
|
+
getFile(request: GetFileRequest): Promise<GetFileResponse>;
|
|
947
|
+
/**
|
|
948
|
+
* 触发登录流程
|
|
949
|
+
* - Web 环境: 跳转到登录页面
|
|
950
|
+
* - IDE 环境: 通过 IPC 通知 IDE 打开登录流程
|
|
951
|
+
*/
|
|
952
|
+
login(): Promise<void>;
|
|
953
|
+
/**
|
|
954
|
+
* 登出账号
|
|
955
|
+
*/
|
|
956
|
+
logout(): Promise<void>;
|
|
957
|
+
/**
|
|
958
|
+
* 重新加载窗口(可选,仅 IPC 环境支持)
|
|
959
|
+
* @param params 可选参数,如 locale
|
|
960
|
+
*/
|
|
961
|
+
reloadWindow?(params?: {
|
|
962
|
+
locale?: string;
|
|
963
|
+
}): Promise<void>;
|
|
964
|
+
/**
|
|
965
|
+
* 监听事件(可选,用于 IPC 环境)
|
|
966
|
+
* @param event 事件名称
|
|
967
|
+
* @param callback 回调函数
|
|
968
|
+
* @returns 取消订阅函数
|
|
969
|
+
*/
|
|
970
|
+
on?(event: string, callback: (data?: unknown) => void): () => void;
|
|
971
|
+
/** 获取企业用户用量信息
|
|
972
|
+
* @param enterpriseId 企业 ID
|
|
973
|
+
* @returns Promise<EnterpriseUsage | null> 企业用户用量信息
|
|
974
|
+
*/
|
|
975
|
+
getEnterpriseUsage?(enterpriseId: string): Promise<EnterpriseUsage | null>;
|
|
976
|
+
/**
|
|
977
|
+
* 获取支持的场景列表(用于 Welcome 页面的快捷操作)
|
|
978
|
+
* API 端点: GET /console/as/support/scenes (Web) 或 GET /v2/as/support/scenes (Local)
|
|
979
|
+
* @returns Promise<SupportScene[]> 支持的场景列表
|
|
980
|
+
*/
|
|
981
|
+
getSupportScenes?(): Promise<SupportScene[]>;
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* 场景中的插件信息
|
|
985
|
+
* 用于描述场景关联的插件
|
|
986
|
+
*/
|
|
987
|
+
interface ScenePlugin {
|
|
988
|
+
/** 插件唯一标识 */
|
|
989
|
+
id: number;
|
|
990
|
+
/** 插件名称 */
|
|
991
|
+
name: string;
|
|
992
|
+
/** 插件市场名称 */
|
|
993
|
+
marketplaceName: string;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* 支持的场景信息
|
|
997
|
+
* 用于 Welcome 页面的 QuickActions 快捷操作
|
|
998
|
+
* API 端点: GET /console/as/support/scenes (Web) 或 GET /v2/as/support/scenes (Local)
|
|
999
|
+
*/
|
|
1000
|
+
interface SupportScene {
|
|
1001
|
+
/** 场景唯一标识 */
|
|
1002
|
+
id: number;
|
|
1003
|
+
/** 场景显示名称 */
|
|
1004
|
+
name: string;
|
|
1005
|
+
/** 场景关联的插件列表 */
|
|
1006
|
+
plugins: ScenePlugin[];
|
|
1007
|
+
/** 场景对应的 prompt 列表 */
|
|
1008
|
+
prompts: string[];
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* 插件作用域
|
|
1012
|
+
*/
|
|
1013
|
+
type PluginScope = 'user' | 'project';
|
|
1014
|
+
/**
|
|
1015
|
+
* 插件操作类型
|
|
1016
|
+
*/
|
|
1017
|
+
type PluginOperation = 'enable' | 'disable';
|
|
1018
|
+
/**
|
|
1019
|
+
* 批量插件操作项
|
|
1020
|
+
*/
|
|
1021
|
+
interface BatchPluginOperationItem {
|
|
1022
|
+
/** 插件名称 */
|
|
1023
|
+
readonly pluginName: string;
|
|
1024
|
+
/** 市场名称 */
|
|
1025
|
+
readonly marketplaceName: string;
|
|
1026
|
+
/** 作用域 */
|
|
1027
|
+
readonly scope: PluginScope;
|
|
1028
|
+
/** 操作类型 */
|
|
1029
|
+
readonly operation: PluginOperation;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* 批量插件操作请求
|
|
1033
|
+
*/
|
|
1034
|
+
interface BatchPluginOperationRequest {
|
|
1035
|
+
/** 操作项列表 */
|
|
1036
|
+
readonly items: BatchPluginOperationItem[];
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* 批量插件操作失败项
|
|
1040
|
+
*/
|
|
1041
|
+
interface BatchPluginOperationFailedItem extends BatchPluginOperationItem {
|
|
1042
|
+
/** 错误信息 */
|
|
1043
|
+
readonly error: string;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* 批量插件操作结果
|
|
1047
|
+
*/
|
|
1048
|
+
interface BatchPluginOperationResult {
|
|
1049
|
+
/** 是否全部成功 */
|
|
1050
|
+
readonly success: boolean;
|
|
1051
|
+
/** 成功的插件列表 */
|
|
1052
|
+
readonly succeededPlugins: BatchPluginOperationItem[];
|
|
1053
|
+
/** 失败的插件列表 */
|
|
1054
|
+
readonly failedPlugins: BatchPluginOperationFailedItem[];
|
|
1055
|
+
}
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region ../agent-provider/lib/common/providers/local-agent-provider/acp/types.d.ts
|
|
1058
|
+
/**
|
|
1059
|
+
* Widget Channel 接口
|
|
1060
|
+
* 定义 Widget 与 Agent Manager 的通信抽象
|
|
1061
|
+
* 面向 ACP 协议设计,使用 sessionId 作为主要标识符
|
|
1062
|
+
*/
|
|
1063
|
+
interface IWidgetChannel {
|
|
1064
|
+
/**
|
|
1065
|
+
* 发送通知到指定 session(fire-and-forget)
|
|
1066
|
+
* Channel 层负责路由到正确的 window
|
|
1067
|
+
* 不需要等待响应时使用此方法
|
|
1068
|
+
*
|
|
1069
|
+
* @param sessionId ACP 会话 ID
|
|
1070
|
+
* @param message 消息内容
|
|
1071
|
+
* @returns 是否发送成功
|
|
1072
|
+
*/
|
|
1073
|
+
sendNotification(sessionId: string, message: any): Promise<boolean>;
|
|
1074
|
+
/**
|
|
1075
|
+
* 调用远程方法并等待响应
|
|
1076
|
+
* 需要响应时使用此方法(推荐)
|
|
1077
|
+
*
|
|
1078
|
+
* @param sessionId ACP 会话 ID
|
|
1079
|
+
* @param message 消息内容
|
|
1080
|
+
* @param timeoutMs 超时时间(毫秒,默认 5000)
|
|
1081
|
+
* @returns Promise 包含响应数据
|
|
1082
|
+
*/
|
|
1083
|
+
callMethod(sessionId: string, message: any, timeoutMs?: number): Promise<any>;
|
|
1084
|
+
/**
|
|
1085
|
+
* 绑定 session 到 window
|
|
1086
|
+
* 用于创建新对话时建立 sessionId → windowId 映射
|
|
1087
|
+
*
|
|
1088
|
+
* @param sessionId ACP 会话 ID
|
|
1089
|
+
* @param windowId 窗口 ID
|
|
1090
|
+
*/
|
|
1091
|
+
bindSession?(sessionId: string, windowId: number): void;
|
|
1092
|
+
/**
|
|
1093
|
+
* 解除 session 绑定
|
|
1094
|
+
*
|
|
1095
|
+
* @param sessionId ACP 会话 ID
|
|
1096
|
+
*/
|
|
1097
|
+
unbindSession?(sessionId: string): void;
|
|
1098
|
+
/** 注册事件监听器 */
|
|
1099
|
+
on(event: string, handler: (data?: any) => void): void;
|
|
1100
|
+
/** 注销事件监听器 */
|
|
1101
|
+
off(event: string, handler: (data?: any) => void): void;
|
|
1102
|
+
/** 触发事件(向外部发送事件) */
|
|
1103
|
+
emit(event: string, data?: any): void;
|
|
1104
|
+
/** 清除所有事件监听器 */
|
|
1105
|
+
clear?(): void;
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* 可用命令定义 (符合 ACP 协议)
|
|
1109
|
+
* 参考: https://agentclientprotocol.com/protocol/slash-commands
|
|
1110
|
+
*/
|
|
1111
|
+
interface AvailableCommand {
|
|
1112
|
+
/** 命令名称 (如 "web", "test", "plan") */
|
|
1113
|
+
readonly name: string;
|
|
1114
|
+
/** 人类可读的命令描述 */
|
|
1115
|
+
readonly description: string;
|
|
1116
|
+
/** 可选的输入规范 */
|
|
1117
|
+
readonly input?: {
|
|
1118
|
+
/** 输入提示,当用户未提供输入时显示 */readonly hint?: string;
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region ../agent-provider/lib/common/types.d.ts
|
|
1123
|
+
/**
|
|
1124
|
+
* Base options for filesystem operations
|
|
1125
|
+
* 对齐 e2b SDK FilesystemRequestOpts
|
|
1126
|
+
*/
|
|
1127
|
+
interface FilesystemRequestOpts {
|
|
1128
|
+
user?: string;
|
|
1129
|
+
requestTimeoutMs?: number;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Options for list operation
|
|
1133
|
+
* 对齐 e2b SDK FilesystemListOpts
|
|
1134
|
+
*/
|
|
1135
|
+
interface FilesystemListOpts extends FilesystemRequestOpts {
|
|
1136
|
+
depth?: number;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Options for watchDir operation
|
|
1140
|
+
* 对齐 e2b SDK WatchOpts
|
|
1141
|
+
*/
|
|
1142
|
+
interface WatchOpts extends FilesystemRequestOpts {
|
|
1143
|
+
timeoutMs?: number;
|
|
1144
|
+
onExit?: (err?: Error) => void | Promise<void>;
|
|
1145
|
+
recursive?: boolean;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Entry for batch write operation
|
|
1149
|
+
* 对齐 e2b SDK WriteEntry
|
|
1150
|
+
*/
|
|
1151
|
+
interface WriteEntry {
|
|
1152
|
+
path: string;
|
|
1153
|
+
data: string | ArrayBuffer | Blob | ReadableStream;
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* E2B Sandbox connection information
|
|
1157
|
+
* 与 e2b SDK 的 ConnectionOpts 对齐
|
|
1158
|
+
*/
|
|
1159
|
+
interface E2BSandboxConnectionInfo {
|
|
1160
|
+
/** Sandbox ID */
|
|
1161
|
+
sandboxId: string;
|
|
1162
|
+
/** API key for authentication (e2b_ 开头的 key) */
|
|
1163
|
+
apiKey?: string;
|
|
1164
|
+
/** Access token for authentication (JWT 格式的 token) */
|
|
1165
|
+
accessToken?: string;
|
|
1166
|
+
/** Domain for the API (不带 https://) */
|
|
1167
|
+
domain?: string;
|
|
1168
|
+
/** API URL override (internal) */
|
|
1169
|
+
apiUrl?: string;
|
|
1170
|
+
/** Request timeout in milliseconds */
|
|
1171
|
+
requestTimeoutMs?: number;
|
|
1172
|
+
/** Debug mode */
|
|
1173
|
+
debug?: boolean;
|
|
1174
|
+
/**
|
|
1175
|
+
* Additional headers to send with the request.
|
|
1176
|
+
*/
|
|
1177
|
+
headers?: Record<string, string>;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Filesystem resource interface
|
|
1181
|
+
* Mirrors e2b SDK Filesystem API
|
|
1182
|
+
* 完全对齐 e2b SDK 的 Filesystem 类
|
|
1183
|
+
*/
|
|
1184
|
+
interface FilesResource {
|
|
1185
|
+
/** Read file content as text (default) */
|
|
1186
|
+
read(path: string, opts?: FilesystemRequestOpts & {
|
|
1187
|
+
format?: 'text';
|
|
1188
|
+
}): Promise<string>;
|
|
1189
|
+
/** Read file content as bytes */
|
|
1190
|
+
read(path: string, opts: FilesystemRequestOpts & {
|
|
1191
|
+
format: 'bytes';
|
|
1192
|
+
}): Promise<Uint8Array>;
|
|
1193
|
+
/** Read file content as blob */
|
|
1194
|
+
read(path: string, opts: FilesystemRequestOpts & {
|
|
1195
|
+
format: 'blob';
|
|
1196
|
+
}): Promise<Blob>;
|
|
1197
|
+
/** Read file content as stream */
|
|
1198
|
+
read(path: string, opts: FilesystemRequestOpts & {
|
|
1199
|
+
format: 'stream';
|
|
1200
|
+
}): Promise<ReadableStream<Uint8Array>>;
|
|
1201
|
+
/** Write content to a single file */
|
|
1202
|
+
write(path: string, data: string | ArrayBuffer | Blob | ReadableStream, opts?: FilesystemRequestOpts): Promise<WriteInfo>;
|
|
1203
|
+
/** Write multiple files in batch */
|
|
1204
|
+
write(files: WriteEntry[], opts?: FilesystemRequestOpts): Promise<WriteInfo[]>;
|
|
1205
|
+
/** List directory contents with optional depth */
|
|
1206
|
+
list(path: string, opts?: FilesystemListOpts): Promise<EntryInfo$1[]>;
|
|
1207
|
+
/** Check if path exists */
|
|
1208
|
+
exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
|
|
1209
|
+
/** Create directory */
|
|
1210
|
+
makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean>;
|
|
1211
|
+
/** Remove file or directory */
|
|
1212
|
+
remove(path: string, opts?: FilesystemRequestOpts): Promise<void>;
|
|
1213
|
+
/** Rename/move file or directory */
|
|
1214
|
+
rename(oldPath: string, newPath: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
|
|
1215
|
+
/** Get file or directory information */
|
|
1216
|
+
getInfo(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo$1>;
|
|
1217
|
+
/** Watch directory for changes */
|
|
1218
|
+
watchDir(path: string, onEvent: (event: FilesystemEvent) => void | Promise<void>, opts?: WatchOpts & {
|
|
1219
|
+
onExit?: (err?: Error) => void | Promise<void>;
|
|
1220
|
+
}): Promise<WatchHandle>;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Filesystem provider interface - implemented by Provider
|
|
1224
|
+
*/
|
|
1225
|
+
interface FilesystemProvider {
|
|
1226
|
+
/**
|
|
1227
|
+
* Get filesystem resource for an agent
|
|
1228
|
+
* @param agentId - Agent ID (used to get the corresponding sandbox connection)
|
|
1229
|
+
*/
|
|
1230
|
+
getFilesystem(agentId: string): Promise<FilesResource>;
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Transport type for agents
|
|
1234
|
+
*/
|
|
1235
|
+
type AgentTransport = 'cloud' | 'local';
|
|
1236
|
+
/**
|
|
1237
|
+
* Agent connection status
|
|
1238
|
+
*/
|
|
1239
|
+
type AgentStatus = 'disconnected' | 'connecting' | 'connected' | 'initialized' | 'error';
|
|
1240
|
+
/**
|
|
1241
|
+
* Agent information
|
|
1242
|
+
*/
|
|
1243
|
+
interface Agent {
|
|
1244
|
+
id: string;
|
|
1245
|
+
name: string;
|
|
1246
|
+
description?: string;
|
|
1247
|
+
version?: string;
|
|
1248
|
+
transport: AgentTransport;
|
|
1249
|
+
status: AgentStatus;
|
|
1250
|
+
capabilities?: AgentCapabilities;
|
|
1251
|
+
metadata?: Record<string, unknown>;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Session mode configuration
|
|
1255
|
+
*/
|
|
1256
|
+
interface SessionMode {
|
|
1257
|
+
id: string;
|
|
1258
|
+
name: string;
|
|
1259
|
+
description?: string | null;
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Session information
|
|
1263
|
+
*/
|
|
1264
|
+
interface Session {
|
|
1265
|
+
id: string;
|
|
1266
|
+
agentId: string;
|
|
1267
|
+
availableModes?: SessionMode[];
|
|
1268
|
+
currentMode?: string;
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Parameters for creating a new session
|
|
1272
|
+
*/
|
|
1273
|
+
interface CreateSessionParams {
|
|
1274
|
+
cwd: string;
|
|
1275
|
+
mcpServers?: McpServerConfig[];
|
|
1276
|
+
_meta?: Record<string, unknown>;
|
|
555
1277
|
}
|
|
556
1278
|
/**
|
|
557
1279
|
* Parameters for loading an existing session
|
|
@@ -592,6 +1314,13 @@ type PromptContentBlock = {
|
|
|
592
1314
|
} | {
|
|
593
1315
|
type: 'resource';
|
|
594
1316
|
uri: string;
|
|
1317
|
+
mimeType?: string | null;
|
|
1318
|
+
name: string;
|
|
1319
|
+
size?: bigint | null;
|
|
1320
|
+
title?: string | null;
|
|
1321
|
+
_meta?: {
|
|
1322
|
+
[key: string]: unknown;
|
|
1323
|
+
} | null | undefined;
|
|
595
1324
|
};
|
|
596
1325
|
/**
|
|
597
1326
|
* Parameters for sending a prompt
|
|
@@ -627,6 +1356,10 @@ interface ConnectionEvents extends ClientEvents {
|
|
|
627
1356
|
questionTimeout: {
|
|
628
1357
|
toolCallId: string;
|
|
629
1358
|
};
|
|
1359
|
+
command: {
|
|
1360
|
+
action: string;
|
|
1361
|
+
params?: Record<string, unknown>;
|
|
1362
|
+
};
|
|
630
1363
|
}
|
|
631
1364
|
/**
|
|
632
1365
|
* Event listener type
|
|
@@ -746,7 +1479,7 @@ interface ModelReasoning {
|
|
|
746
1479
|
/**
|
|
747
1480
|
* Model information
|
|
748
1481
|
*/
|
|
749
|
-
interface ModelInfo
|
|
1482
|
+
interface ModelInfo {
|
|
750
1483
|
/** 模型唯一标识符,例如"gpt-3.5-turbo" */
|
|
751
1484
|
readonly id: string;
|
|
752
1485
|
/** 可选,模型名称,例如"GPT-3.5 Turbo" */
|
|
@@ -901,6 +1634,8 @@ interface BaseAgentState {
|
|
|
901
1634
|
createdAt?: Date;
|
|
902
1635
|
/** When the agent was last updated */
|
|
903
1636
|
updatedAt?: Date;
|
|
1637
|
+
/** 是否为 playground */
|
|
1638
|
+
isPlayground?: boolean;
|
|
904
1639
|
}
|
|
905
1640
|
/**
|
|
906
1641
|
* LocalAgentState - 本地 Agent 状态
|
|
@@ -1045,6 +1780,8 @@ interface SessionInfo {
|
|
|
1045
1780
|
lastActivityAt?: Date;
|
|
1046
1781
|
/** Working directory (for local agents) */
|
|
1047
1782
|
cwd?: string;
|
|
1783
|
+
/** Whether the session is a playground */
|
|
1784
|
+
isPlayground?: boolean;
|
|
1048
1785
|
}
|
|
1049
1786
|
/**
|
|
1050
1787
|
* Parameters for creating a new session
|
|
@@ -1054,6 +1791,7 @@ interface CreateSessionParams$1 {
|
|
|
1054
1791
|
cwd: string;
|
|
1055
1792
|
/** MCP server configurations */
|
|
1056
1793
|
mcpServers?: McpServerConfig[];
|
|
1794
|
+
_meta?: Record<string, unknown>;
|
|
1057
1795
|
}
|
|
1058
1796
|
/**
|
|
1059
1797
|
* Parameters for loading an existing session
|
|
@@ -1065,6 +1803,8 @@ interface LoadSessionParams$1 {
|
|
|
1065
1803
|
cwd: string;
|
|
1066
1804
|
/** MCP server configurations */
|
|
1067
1805
|
mcpServers?: McpServerConfig[];
|
|
1806
|
+
/** Callback executed right after session instance is created, before connection.loadSession() is called */
|
|
1807
|
+
onSessionCreated?: (session: ActiveSession) => Promise<void> | void;
|
|
1068
1808
|
}
|
|
1069
1809
|
/**
|
|
1070
1810
|
* Parameters for initializing a workspace
|
|
@@ -1116,7 +1856,7 @@ interface ArtifactsResource {
|
|
|
1116
1856
|
*/
|
|
1117
1857
|
interface ModelsResource {
|
|
1118
1858
|
/** Get available models for a repository */
|
|
1119
|
-
list(repo?: string): Promise<ModelInfo
|
|
1859
|
+
list(repo?: string): Promise<ModelInfo[]>;
|
|
1120
1860
|
}
|
|
1121
1861
|
/**
|
|
1122
1862
|
* Prompt response
|
|
@@ -1174,6 +1914,11 @@ interface SessionEvents {
|
|
|
1174
1914
|
checkpointCreated: CheckpointInfo;
|
|
1175
1915
|
/** Emitted when a checkpoint is updated */
|
|
1176
1916
|
checkpointUpdated: CheckpointInfo;
|
|
1917
|
+
/** Emitted when a command is received */
|
|
1918
|
+
command: {
|
|
1919
|
+
action: string;
|
|
1920
|
+
params?: Record<string, unknown>;
|
|
1921
|
+
};
|
|
1177
1922
|
/** Emitted when connected to agent */
|
|
1178
1923
|
connected: void;
|
|
1179
1924
|
/** Emitted when disconnected from agent */
|
|
@@ -1220,6 +1965,10 @@ interface ActiveSession {
|
|
|
1220
1965
|
readonly availableModes?: SessionMode[];
|
|
1221
1966
|
/** Current session mode */
|
|
1222
1967
|
readonly currentMode?: string;
|
|
1968
|
+
/** Available models for this session */
|
|
1969
|
+
readonly availableModels?: ModelInfo[];
|
|
1970
|
+
/** Current model ID */
|
|
1971
|
+
readonly currentModelId?: string;
|
|
1223
1972
|
/** Available slash commands (updated via available_commands_update) */
|
|
1224
1973
|
readonly availableCommands: AvailableCommand[];
|
|
1225
1974
|
/** Whether the session is active */
|
|
@@ -1254,6 +2003,12 @@ interface ActiveSession {
|
|
|
1254
2003
|
setMode(modeId: string): Promise<void>;
|
|
1255
2004
|
/** Set the current session model */
|
|
1256
2005
|
setSessionModel(modelId: string): Promise<void>;
|
|
2006
|
+
/** Set available commands (called when available_commands_update is received) */
|
|
2007
|
+
setAvailableCommands(commands: AvailableCommand[]): void;
|
|
2008
|
+
/** Set available modes (called after create/load) */
|
|
2009
|
+
setModes(availableModes?: SessionMode[], currentMode?: string): void;
|
|
2010
|
+
/** Set available models (called after create/load) */
|
|
2011
|
+
setModels(availableModels?: ModelInfo[], currentModelId?: string): void;
|
|
1257
2012
|
/** Subscribe to an event */
|
|
1258
2013
|
on<K extends keyof SessionEvents>(event: K, handler: SessionEventHandler<K>): this;
|
|
1259
2014
|
/** Unsubscribe from an event */
|
|
@@ -1326,6 +2081,16 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
|
|
|
1326
2081
|
rename?(agentId: string, title: string): Promise<{
|
|
1327
2082
|
id: string;
|
|
1328
2083
|
}>;
|
|
2084
|
+
/**
|
|
2085
|
+
* Move an agent by ID (optional)
|
|
2086
|
+
* Used by LocalAgentProvider for moving Playground sessions to Workspace
|
|
2087
|
+
*
|
|
2088
|
+
* @param agentId - Agent ID to move
|
|
2089
|
+
* @returns Object containing the moved agent ID
|
|
2090
|
+
*/
|
|
2091
|
+
move?(agentId: string): Promise<{
|
|
2092
|
+
id: string;
|
|
2093
|
+
}>;
|
|
1329
2094
|
/** Filesystem provider (optional - some providers may not support filesystem operations) */
|
|
1330
2095
|
readonly filesystem?: FilesystemProvider;
|
|
1331
2096
|
/**
|
|
@@ -1334,7 +2099,7 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
|
|
|
1334
2099
|
* @param repo - Repository identifier
|
|
1335
2100
|
* @returns Array of model information
|
|
1336
2101
|
*/
|
|
1337
|
-
getModels?(repo?: string): Promise<ModelInfo
|
|
2102
|
+
getModels?(repo?: string): Promise<ModelInfo[]>;
|
|
1338
2103
|
/**
|
|
1339
2104
|
* Register sessionId → agentId mapping (optional, used by LocalAgentProvider)
|
|
1340
2105
|
* Called after session creation to maintain the mapping for loadSession
|
|
@@ -1378,6 +2143,39 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
|
|
|
1378
2143
|
* @returns Response with search results
|
|
1379
2144
|
*/
|
|
1380
2145
|
searchFile?(params: SearchFileParams): Promise<SearchFileResponse>;
|
|
2146
|
+
/**
|
|
2147
|
+
* Batch toggle plugins (optional, used by LocalAgentProvider)
|
|
2148
|
+
*
|
|
2149
|
+
* @param request - Batch plugin operation request
|
|
2150
|
+
* @returns Batch operation result
|
|
2151
|
+
*/
|
|
2152
|
+
batchTogglePlugins?(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
|
|
2153
|
+
/**
|
|
2154
|
+
* Get installed plugins (optional, used by LocalAgentProvider)
|
|
2155
|
+
*
|
|
2156
|
+
* @param forceRefresh - Whether to force refresh the cache
|
|
2157
|
+
* @returns Array of installed plugins
|
|
2158
|
+
*/
|
|
2159
|
+
getInstalledPlugins?(forceRefresh?: boolean): Promise<Array<{
|
|
2160
|
+
name: string;
|
|
2161
|
+
marketplaceName: string;
|
|
2162
|
+
status: string;
|
|
2163
|
+
description?: string;
|
|
2164
|
+
version?: string;
|
|
2165
|
+
installScope?: 'user' | 'project';
|
|
2166
|
+
}>>;
|
|
2167
|
+
/**
|
|
2168
|
+
* Install plugins (optional, used by LocalAgentProvider)
|
|
2169
|
+
*
|
|
2170
|
+
* @param pluginNames - Array of plugin names to install
|
|
2171
|
+
* @param marketplaceName - Marketplace name
|
|
2172
|
+
* @param installScope - Install scope ('user' | 'project')
|
|
2173
|
+
* @returns Result of the operation
|
|
2174
|
+
*/
|
|
2175
|
+
installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
|
|
2176
|
+
success: boolean;
|
|
2177
|
+
error?: string;
|
|
2178
|
+
}>;
|
|
1381
2179
|
/**
|
|
1382
2180
|
* Register an event listener
|
|
1383
2181
|
* Provider implementations should forward events to the underlying transport
|
|
@@ -1450,6 +2248,14 @@ interface ClientSessionsResource {
|
|
|
1450
2248
|
rename(sessionId: string, title: string): Promise<{
|
|
1451
2249
|
id: string;
|
|
1452
2250
|
}>;
|
|
2251
|
+
/**
|
|
2252
|
+
* Move a session (Playground → Workspace)
|
|
2253
|
+
* @param sessionId - Session ID to move
|
|
2254
|
+
* @returns Object containing the moved session ID
|
|
2255
|
+
*/
|
|
2256
|
+
move(sessionId: string): Promise<{
|
|
2257
|
+
id: string;
|
|
2258
|
+
}>;
|
|
1453
2259
|
/** Initialize a workspace for future sessions */
|
|
1454
2260
|
initializeWorkspace(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
|
|
1455
2261
|
/** Models resource for getting available models */
|
|
@@ -1472,6 +2278,36 @@ interface ClientSessionsResource {
|
|
|
1472
2278
|
uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
|
|
1473
2279
|
/** Search for files in the workspace (for LocalAgentProvider) */
|
|
1474
2280
|
searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
|
|
2281
|
+
/** Batch toggle plugins (for LocalAgentProvider) */
|
|
2282
|
+
batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
|
|
2283
|
+
/** Get installed plugins (for LocalAgentProvider) */
|
|
2284
|
+
getInstalledPlugins?(forceRefresh?: boolean): Promise<Array<{
|
|
2285
|
+
name: string;
|
|
2286
|
+
marketplaceName: string;
|
|
2287
|
+
status: string;
|
|
2288
|
+
description?: string;
|
|
2289
|
+
version?: string;
|
|
2290
|
+
installScope?: 'user' | 'project';
|
|
2291
|
+
}>>;
|
|
2292
|
+
/** Install plugins (for LocalAgentProvider) */
|
|
2293
|
+
installPlugins?(pluginNames: string[], marketplaceName: string, installScope?: 'user' | 'project'): Promise<{
|
|
2294
|
+
success: boolean;
|
|
2295
|
+
error?: string;
|
|
2296
|
+
}>;
|
|
2297
|
+
/**
|
|
2298
|
+
* Get support scenes from backend API (for LocalAgentProvider)
|
|
2299
|
+
* API 端点: GET /v2/as/support/scenes (Local) 或 GET /console/as/support/scenes (Web)
|
|
2300
|
+
*/
|
|
2301
|
+
getSupportScenes?(): Promise<Array<{
|
|
2302
|
+
id: number;
|
|
2303
|
+
name: string;
|
|
2304
|
+
plugins: Array<{
|
|
2305
|
+
id: number;
|
|
2306
|
+
name: string;
|
|
2307
|
+
marketplaceName: string;
|
|
2308
|
+
}>;
|
|
2309
|
+
prompts: string[];
|
|
2310
|
+
}>>;
|
|
1475
2311
|
}
|
|
1476
2312
|
/**
|
|
1477
2313
|
* Workspace information (aligned with FolderSelectResult)
|
|
@@ -1683,19 +2519,21 @@ declare class CloudAgentConnection implements AgentConnection {
|
|
|
1683
2519
|
//#endregion
|
|
1684
2520
|
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/api-types.d.ts
|
|
1685
2521
|
/**
|
|
1686
|
-
* Response for
|
|
1687
|
-
* POST /
|
|
2522
|
+
* Response for update conversation
|
|
2523
|
+
* POST /console/as/conversations/{id}
|
|
2524
|
+
* Required fields: id
|
|
1688
2525
|
*/
|
|
1689
|
-
interface
|
|
1690
|
-
/**
|
|
2526
|
+
interface PatchConversationResponse {
|
|
2527
|
+
/** Conversation ID (required) */
|
|
1691
2528
|
id: string;
|
|
1692
2529
|
}
|
|
1693
2530
|
/**
|
|
1694
|
-
* Response for
|
|
1695
|
-
*
|
|
2531
|
+
* Response for archive conversation
|
|
2532
|
+
* POST /console/as/conversations/{id}/archive
|
|
2533
|
+
* Required fields: id
|
|
1696
2534
|
*/
|
|
1697
|
-
interface
|
|
1698
|
-
/**
|
|
2535
|
+
interface ArchiveConversationResponse {
|
|
2536
|
+
/** Conversation ID (required) */
|
|
1699
2537
|
id: string;
|
|
1700
2538
|
}
|
|
1701
2539
|
//#endregion
|
|
@@ -1712,21 +2550,21 @@ interface CloudAgentProviderOptions {
|
|
|
1712
2550
|
headers?: Record<string, string>;
|
|
1713
2551
|
/** Logger instance */
|
|
1714
2552
|
logger?: Logger;
|
|
1715
|
-
/** Custom fetch implementation */
|
|
1716
|
-
fetch?: typeof fetch;
|
|
1717
2553
|
/** Client capabilities (sent during agent initialization) */
|
|
1718
2554
|
clientCapabilities?: ClientCapabilities$1;
|
|
1719
2555
|
}
|
|
1720
2556
|
/**
|
|
1721
2557
|
* CloudAgentProvider - Manages cloud-hosted agents via REST API
|
|
1722
2558
|
*
|
|
1723
|
-
* API Endpoints:
|
|
1724
|
-
* - POST {endpoint}/console/
|
|
1725
|
-
* - GET {endpoint}/console/
|
|
1726
|
-
* - GET {endpoint}/console/
|
|
1727
|
-
* - POST {endpoint}/console/
|
|
1728
|
-
* -
|
|
1729
|
-
* -
|
|
2559
|
+
* API Endpoints (base path: /console/as):
|
|
2560
|
+
* - POST {endpoint}/console/as/conversations - Create new conversation
|
|
2561
|
+
* - GET {endpoint}/console/as/conversations/{id} - Get conversation details
|
|
2562
|
+
* - GET {endpoint}/console/as/conversations - List all conversations
|
|
2563
|
+
* - POST {endpoint}/console/as/conversations/{id}/delete - Delete conversation
|
|
2564
|
+
* - POST {endpoint}/console/as/conversations/{id}/archive - Archive conversation
|
|
2565
|
+
* - POST {endpoint}/console/as/conversations/{id} - Update conversation (rename)
|
|
2566
|
+
* - GET {endpoint}/console/as/conversations/{id}/session - Get conversation session (includes sandboxId)
|
|
2567
|
+
* - GET {endpoint}/console/enterprises/{id}/models - Get available models
|
|
1730
2568
|
*
|
|
1731
2569
|
* The provider stores agent endpoint configurations in the cloud backend.
|
|
1732
2570
|
* When connect() is called, it creates a CloudAgentConnection to the agent's
|
|
@@ -1789,7 +2627,7 @@ interface CloudAgentProviderOptions {
|
|
|
1789
2627
|
declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>, FilesystemProvider {
|
|
1790
2628
|
private options;
|
|
1791
2629
|
private logger?;
|
|
1792
|
-
private
|
|
2630
|
+
private requestInterceptorId;
|
|
1793
2631
|
/** Cache for filesystem instances (keyed by agentId) */
|
|
1794
2632
|
private filesystemCache;
|
|
1795
2633
|
/** Cache for agent connections (keyed by endpoint link) */
|
|
@@ -1832,7 +2670,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1832
2670
|
/**
|
|
1833
2671
|
* Get sandbox information from backend
|
|
1834
2672
|
*
|
|
1835
|
-
* Uses GET {endpoint}/console/
|
|
2673
|
+
* Uses GET {endpoint}/console/as/conversations/{agentId}/session
|
|
1836
2674
|
* to retrieve sandbox information. Extracts sandboxId from the session response
|
|
1837
2675
|
* and constructs the apiUrl for E2B proxy.
|
|
1838
2676
|
*
|
|
@@ -1852,8 +2690,8 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1852
2690
|
*/
|
|
1853
2691
|
list(options?: ListAgentOptions): Promise<ListAgentResult<CloudAgentState>>;
|
|
1854
2692
|
/**
|
|
1855
|
-
* Create a new
|
|
1856
|
-
* POST {endpoint}/console/
|
|
2693
|
+
* Create a new conversation
|
|
2694
|
+
* POST {endpoint}/console/as/conversations
|
|
1857
2695
|
*/
|
|
1858
2696
|
create(): Promise<string>;
|
|
1859
2697
|
/**
|
|
@@ -1874,51 +2712,51 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1874
2712
|
*/
|
|
1875
2713
|
connect(agentId: string): Promise<CloudAgentConnection>;
|
|
1876
2714
|
/**
|
|
1877
|
-
* Delete
|
|
1878
|
-
* POST {endpoint}/console/
|
|
2715
|
+
* Delete a conversation by ID
|
|
2716
|
+
* POST {endpoint}/console/as/conversations/{agentId}/delete
|
|
1879
2717
|
*/
|
|
1880
2718
|
delete(agentId: string): Promise<boolean>;
|
|
1881
2719
|
/**
|
|
1882
|
-
* Archive
|
|
1883
|
-
* POST {endpoint}/console/
|
|
2720
|
+
* Archive a conversation by ID
|
|
2721
|
+
* POST {endpoint}/console/as/conversations/{agentId}/archive
|
|
1884
2722
|
*
|
|
1885
|
-
* @param agentId -
|
|
1886
|
-
* @returns
|
|
2723
|
+
* @param agentId - Conversation ID to archive
|
|
2724
|
+
* @returns ArchiveConversationResponse containing the archived conversation ID
|
|
1887
2725
|
*
|
|
1888
2726
|
* @example
|
|
1889
2727
|
* ```typescript
|
|
1890
2728
|
* const result = await provider.archive('agent-123');
|
|
1891
|
-
* console.log('Archived
|
|
2729
|
+
* console.log('Archived conversation:', result.id);
|
|
1892
2730
|
* ```
|
|
1893
2731
|
*/
|
|
1894
|
-
archive(agentId: string): Promise<
|
|
2732
|
+
archive(agentId: string): Promise<ArchiveConversationResponse>;
|
|
1895
2733
|
/**
|
|
1896
|
-
* Rename
|
|
1897
|
-
*
|
|
2734
|
+
* Rename a conversation by ID
|
|
2735
|
+
* POST {endpoint}/console/as/conversations/{agentId}
|
|
1898
2736
|
*
|
|
1899
|
-
* @param agentId -
|
|
1900
|
-
* @param title - New title for the
|
|
1901
|
-
* @returns
|
|
2737
|
+
* @param agentId - Conversation ID to rename
|
|
2738
|
+
* @param title - New title for the conversation
|
|
2739
|
+
* @returns PatchConversationResponse containing the renamed conversation ID
|
|
1902
2740
|
*
|
|
1903
2741
|
* @example
|
|
1904
2742
|
* ```typescript
|
|
1905
2743
|
* const result = await provider.rename('agent-123', 'New Title');
|
|
1906
|
-
* console.log('Renamed
|
|
2744
|
+
* console.log('Renamed conversation:', result.id);
|
|
1907
2745
|
* ```
|
|
1908
2746
|
*/
|
|
1909
|
-
rename(agentId: string, title: string): Promise<
|
|
2747
|
+
rename(agentId: string, title: string): Promise<PatchConversationResponse>;
|
|
1910
2748
|
/**
|
|
1911
2749
|
* Get available models from product configuration
|
|
1912
2750
|
*
|
|
1913
|
-
* GET {endpoint}/
|
|
2751
|
+
* GET {endpoint}/console/enterprises/{personal|enterpriseId}/models?repos[]={repo}
|
|
1914
2752
|
*
|
|
1915
|
-
* This method fetches the
|
|
2753
|
+
* This method fetches the models from /console/enterprises API
|
|
1916
2754
|
* and extracts the models array from the response.
|
|
1917
2755
|
*
|
|
1918
2756
|
* @param repo - Optional repository URL for context-specific config
|
|
1919
2757
|
* @returns Array of ModelInfo with full model details
|
|
1920
2758
|
*/
|
|
1921
|
-
getModels(repo?: string): Promise<ModelInfo
|
|
2759
|
+
getModels(repo?: string): Promise<ModelInfo[]>;
|
|
1922
2760
|
/**
|
|
1923
2761
|
* Generate a unique request ID
|
|
1924
2762
|
*/
|
|
@@ -1964,7 +2802,10 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1964
2802
|
*/
|
|
1965
2803
|
private emitEvent;
|
|
1966
2804
|
private toAgentState;
|
|
1967
|
-
|
|
2805
|
+
/**
|
|
2806
|
+
* Helper: 将 GET 请求的 body 转换为 URL 查询参数
|
|
2807
|
+
*/
|
|
2808
|
+
private buildGetUrl;
|
|
1968
2809
|
}
|
|
1969
2810
|
//#endregion
|
|
1970
2811
|
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/e2b-filesystem.d.ts
|
|
@@ -2145,6 +2986,8 @@ declare class ActiveSessionImpl implements ActiveSession {
|
|
|
2145
2986
|
private _agentId;
|
|
2146
2987
|
private _availableModes?;
|
|
2147
2988
|
private _currentMode?;
|
|
2989
|
+
private _availableModels?;
|
|
2990
|
+
private _currentModelId?;
|
|
2148
2991
|
private _availableCommands;
|
|
2149
2992
|
private logger?;
|
|
2150
2993
|
private connection;
|
|
@@ -2202,6 +3045,14 @@ declare class ActiveSessionImpl implements ActiveSession {
|
|
|
2202
3045
|
* Current session mode
|
|
2203
3046
|
*/
|
|
2204
3047
|
get currentMode(): string | undefined;
|
|
3048
|
+
/**
|
|
3049
|
+
* Available models for this session
|
|
3050
|
+
*/
|
|
3051
|
+
get availableModels(): ModelInfo[] | undefined;
|
|
3052
|
+
/**
|
|
3053
|
+
* Current model ID
|
|
3054
|
+
*/
|
|
3055
|
+
get currentModelId(): string | undefined;
|
|
2205
3056
|
/**
|
|
2206
3057
|
* Available slash commands
|
|
2207
3058
|
*
|
|
@@ -2209,6 +3060,10 @@ declare class ActiveSessionImpl implements ActiveSession {
|
|
|
2209
3060
|
* Commands can be accessed directly without waiting for events.
|
|
2210
3061
|
*/
|
|
2211
3062
|
get availableCommands(): AvailableCommand[];
|
|
3063
|
+
/**
|
|
3064
|
+
* Set available commands (called when available_commands_update is received)
|
|
3065
|
+
*/
|
|
3066
|
+
setAvailableCommands(commands: AvailableCommand[]): void;
|
|
2212
3067
|
/**
|
|
2213
3068
|
* Check if the session is active
|
|
2214
3069
|
*/
|
|
@@ -2222,6 +3077,10 @@ declare class ActiveSessionImpl implements ActiveSession {
|
|
|
2222
3077
|
* Set session modes (called after create/load)
|
|
2223
3078
|
*/
|
|
2224
3079
|
setModes(availableModes?: SessionMode[], currentMode?: string): void;
|
|
3080
|
+
/**
|
|
3081
|
+
* Set available models (called after create/load)
|
|
3082
|
+
*/
|
|
3083
|
+
setModels(availableModels?: ModelInfo[], currentModelId?: string): void;
|
|
2225
3084
|
private createAgentOperations;
|
|
2226
3085
|
private createPromptsResource;
|
|
2227
3086
|
private createArtifactsResource;
|
|
@@ -2325,270 +3184,86 @@ declare class ActiveSessionImpl implements ActiveSession {
|
|
|
2325
3184
|
* } // session automatically disposed
|
|
2326
3185
|
* ```
|
|
2327
3186
|
*/
|
|
2328
|
-
[Symbol.dispose](): void;
|
|
2329
|
-
private getConnectionOrThrow;
|
|
2330
|
-
private setupConnectionEvents;
|
|
2331
|
-
private mapPromptResponse;
|
|
2332
|
-
}
|
|
2333
|
-
//#endregion
|
|
2334
|
-
//#region ../agent-provider/lib/common/client/session-manager.d.ts
|
|
2335
|
-
/**
|
|
2336
|
-
* Options for creating a SessionManager instance
|
|
2337
|
-
*/
|
|
2338
|
-
interface SessionManagerOptions {
|
|
2339
|
-
/** Agent provider (required) */
|
|
2340
|
-
provider: AgentProvider;
|
|
2341
|
-
/** Logger instance */
|
|
2342
|
-
logger?: Logger;
|
|
2343
|
-
}
|
|
2344
|
-
/**
|
|
2345
|
-
* SessionManager - Session lifecycle management
|
|
2346
|
-
*
|
|
2347
|
-
* This class manages the relationship between sessions and agents.
|
|
2348
|
-
* Since the backend is agent-centric, SessionManager handles the mapping:
|
|
2349
|
-
* - Sessions are views over agents
|
|
2350
|
-
* - sessionId may equal agentId in simple cases
|
|
2351
|
-
*
|
|
2352
|
-
* Features:
|
|
2353
|
-
* - Session caching: reuses existing ActiveSession instances
|
|
2354
|
-
* - Automatic cleanup on session disconnect
|
|
2355
|
-
*
|
|
2356
|
-
* @example
|
|
2357
|
-
* ```typescript
|
|
2358
|
-
* const manager = new SessionManager({ provider, logger });
|
|
2359
|
-
*
|
|
2360
|
-
* // List sessions
|
|
2361
|
-
* const sessions = await manager.listSessions();
|
|
2362
|
-
*
|
|
2363
|
-
* // Create new session
|
|
2364
|
-
* const session = await manager.createSession({ cwd: '/workspace' });
|
|
2365
|
-
*
|
|
2366
|
-
* // Load existing session (returns cached instance if available)
|
|
2367
|
-
* const loaded = await manager.loadSession({ sessionId: 'xxx', cwd: '/workspace' });
|
|
2368
|
-
* ```
|
|
2369
|
-
*/
|
|
2370
|
-
declare class SessionManager {
|
|
2371
|
-
private provider;
|
|
2372
|
-
private logger?;
|
|
2373
|
-
constructor(options: SessionManagerOptions);
|
|
2374
|
-
/**
|
|
2375
|
-
* List all sessions with pagination info (mapped from agents)
|
|
2376
|
-
*
|
|
2377
|
-
* Each agent maps to a session. The sessionId is derived from the agent.
|
|
2378
|
-
* Cloud: Returns server-side filtered/sorted/paginated results
|
|
2379
|
-
* Local: Returns client-side filtered/sorted results (synthetic pagination)
|
|
2380
|
-
*
|
|
2381
|
-
* @param options - Optional query parameters for filtering, sorting, and pagination
|
|
2382
|
-
*/
|
|
2383
|
-
listSessions(options?: ListAgentOptions): Promise<ListAgentResult<SessionInfo>>;
|
|
2384
|
-
/**
|
|
2385
|
-
* Create a new session
|
|
2386
|
-
*
|
|
2387
|
-
* Steps:
|
|
2388
|
-
* 1. Create new agent (if provider supports it) or use existing
|
|
2389
|
-
* 2. Connect to agent
|
|
2390
|
-
* 3. Call ACP newSession
|
|
2391
|
-
* 4. Register session mapping (for LocalAgentProvider)
|
|
2392
|
-
* 5. Return ActiveSession instance
|
|
2393
|
-
*/
|
|
2394
|
-
createSession(params: CreateSessionParams$1): Promise<ActiveSession>;
|
|
2395
|
-
/**
|
|
2396
|
-
* Load an existing session
|
|
2397
|
-
*
|
|
2398
|
-
* Steps:
|
|
2399
|
-
* 1. Check cache for existing session
|
|
2400
|
-
* 2. Find agent by sessionId (sessionId === agentId in current design)
|
|
2401
|
-
* 3. Connect to agent
|
|
2402
|
-
* 4. Call ACP loadSession
|
|
2403
|
-
* 5. Return ActiveSession instance (cached)
|
|
2404
|
-
*/
|
|
2405
|
-
loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
|
|
2406
|
-
}
|
|
2407
|
-
//#endregion
|
|
2408
|
-
//#region ../agent-provider/lib/backend/types.d.ts
|
|
2409
|
-
/**
|
|
2410
|
-
* Backend Provider 类型定义
|
|
2411
|
-
*
|
|
2412
|
-
* 定义 IBackendProvider 接口和配置
|
|
2413
|
-
*/
|
|
2414
|
-
/**
|
|
2415
|
-
* 账号版本类型
|
|
2416
|
-
*/
|
|
2417
|
-
type Edition = 'pro' | 'personal' | 'ultimate' | 'exclusive';
|
|
2418
|
-
/**
|
|
2419
|
-
* 版本展示类型(用于 UI 展示)
|
|
2420
|
-
* - free: 免费版(个人版未订阅 Pro)
|
|
2421
|
-
* - pro: Pro 版(个人版已订阅 Pro)
|
|
2422
|
-
* - ultimate: 旗舰版(团队版)
|
|
2423
|
-
* - exclusive: 专享版(企业版)
|
|
2424
|
-
*/
|
|
2425
|
-
type EditionDisplayType = 'free' | 'pro' | 'ultimate' | 'exclusive';
|
|
2426
|
-
/**
|
|
2427
|
-
* 部署状态
|
|
2428
|
-
*/
|
|
2429
|
-
interface DeployStatus {
|
|
2430
|
-
statusCode: number;
|
|
2431
|
-
statusMsg: string;
|
|
2432
|
-
detailMsg: string;
|
|
2433
|
-
}
|
|
2434
|
-
/**
|
|
2435
|
-
* 套餐代码
|
|
2436
|
-
*/
|
|
2437
|
-
/**
|
|
2438
|
-
* TCACA_code_001_PqouKr6QWV CodeBuddy海外版免费包
|
|
2439
|
-
* TCACA_code_002_AkiJS3ZHF5 CodeBuddy海外版Pro版本包-包月/CodeBuddy Pro Plan - Monthly:
|
|
2440
|
-
* TCACA_code_006_DbXS0lrypC CodeBuddy海外版一次性免费赠送2周的Pro版本包/CodeBuddy One-time Free 2-Week Pro Plan Trial
|
|
2441
|
-
* TCACA_code_007_nzdH5h4Nl0 CodeBuddy海外版运营裂变包/CodeBuddy Growth Plan
|
|
2442
|
-
* TCACA_code_003_FAnt7lcmRT CodeBuddy海外版Pro版本包-包年/CodeBuddy Pro Plan - Yearly
|
|
2443
|
-
* TCACA_code_008_cfWoLwvjU4 赠送月包
|
|
2444
|
-
*/
|
|
2445
|
-
declare enum CommodityCode {
|
|
2446
|
-
free = "TCACA_code_001_PqouKr6QWV",
|
|
2447
|
-
// free
|
|
2448
|
-
proMon = "TCACA_code_002_AkiJS3ZHF5",
|
|
2449
|
-
proMonPlus = "TCACA_code_005_maRGyrHhw1",
|
|
2450
|
-
gift = "TCACA_code_006_DbXS0lrypC",
|
|
2451
|
-
activity = "TCACA_code_007_nzdH5h4Nl0",
|
|
2452
|
-
proYear = "TCACA_code_003_FAnt7lcmRT",
|
|
2453
|
-
freeMon = "TCACA_code_008_cfWoLwvjU4",
|
|
2454
|
-
// free
|
|
2455
|
-
extra = "TCACA_code_009_0XmEQc2xOf"
|
|
2456
|
-
}
|
|
2457
|
-
/**
|
|
2458
|
-
* 账号套餐信息
|
|
2459
|
-
*/
|
|
2460
|
-
interface AccountPlan {
|
|
2461
|
-
/** 是否是 Pro 版本 */
|
|
2462
|
-
isPro: boolean;
|
|
2463
|
-
isTria?: boolean;
|
|
2464
|
-
/** 到期时间戳 */
|
|
2465
|
-
expireAt?: number;
|
|
2466
|
-
refreshAt?: number;
|
|
2467
|
-
/** 自动续费标志 0-关闭 1-开启 */
|
|
2468
|
-
renewFlag: 0 | 1;
|
|
2469
|
-
/** 套餐代码 */
|
|
2470
|
-
PackageCode?: CommodityCode;
|
|
2471
|
-
/** 套餐名称 */
|
|
2472
|
-
name: string;
|
|
2473
|
-
usageTotal?: string;
|
|
2474
|
-
usageUsed?: string;
|
|
2475
|
-
usageLeft?: string;
|
|
2476
|
-
}
|
|
2477
|
-
/**
|
|
2478
|
-
* 账号信息
|
|
2479
|
-
*/
|
|
2480
|
-
interface Account {
|
|
2481
|
-
/** 用户ID(唯一标识) */
|
|
2482
|
-
uid: string;
|
|
2483
|
-
/** 用户昵称 */
|
|
2484
|
-
nickname: string;
|
|
2485
|
-
/** 版本类型 */
|
|
2486
|
-
type: Edition;
|
|
2487
|
-
/** 版本展示类型(用于 UI 展示) */
|
|
2488
|
-
editionType: EditionDisplayType;
|
|
2489
|
-
/** 是否最后一次登录 */
|
|
2490
|
-
lastLogin: boolean;
|
|
2491
|
-
/** 企业ID */
|
|
2492
|
-
enterpriseId?: string;
|
|
2493
|
-
/** 企业名称 */
|
|
2494
|
-
enterpriseName?: string;
|
|
2495
|
-
/** 企业LOGO */
|
|
2496
|
-
enterpriseLogo?: string;
|
|
2497
|
-
/** 企业内用户名 */
|
|
2498
|
-
enterpriseUserName?: string;
|
|
2499
|
-
/** 插件是否启用 */
|
|
2500
|
-
pluginEnabled?: boolean;
|
|
2501
|
-
/** 部署状态 */
|
|
2502
|
-
deployStatus?: DeployStatus;
|
|
2503
|
-
/** 是否是 Pro 版本 */
|
|
2504
|
-
isPro?: boolean;
|
|
2505
|
-
/** 到期时间戳 */
|
|
2506
|
-
expireAt?: string | number;
|
|
2507
|
-
/** 自动续费标志 0-关闭 1-开启 */
|
|
2508
|
-
renewFlag?: 0 | 1;
|
|
2509
|
-
/** 套餐代码 */
|
|
2510
|
-
PackageCode?: CommodityCode;
|
|
2511
|
-
/** 套餐名称 */
|
|
2512
|
-
name?: string;
|
|
2513
|
-
email?: string;
|
|
2514
|
-
}
|
|
2515
|
-
/**
|
|
2516
|
-
* 推理配置
|
|
2517
|
-
*/
|
|
2518
|
-
interface ReasoningConfig {
|
|
2519
|
-
/** 推理努力程度 */
|
|
2520
|
-
effort: 'low' | 'medium' | 'high';
|
|
2521
|
-
/** 摘要模式 */
|
|
2522
|
-
summary: 'auto' | 'always' | 'never';
|
|
2523
|
-
}
|
|
2524
|
-
/**
|
|
2525
|
-
* 模型信息
|
|
2526
|
-
*/
|
|
2527
|
-
interface ModelInfo {
|
|
2528
|
-
/** 模型ID */
|
|
2529
|
-
id: string;
|
|
2530
|
-
/** 模型名称 */
|
|
2531
|
-
name: string;
|
|
2532
|
-
/** 供应商 */
|
|
2533
|
-
vendor: string;
|
|
2534
|
-
/** 最大输出 token 数 */
|
|
2535
|
-
maxOutputTokens: number;
|
|
2536
|
-
/** 最大输入 token 数 */
|
|
2537
|
-
maxInputTokens: number;
|
|
2538
|
-
/** 是否支持工具调用 */
|
|
2539
|
-
supportsToolCall: boolean;
|
|
2540
|
-
/** 是否支持图像 */
|
|
2541
|
-
supportsImages: boolean;
|
|
2542
|
-
/** 是否禁用多模态 */
|
|
2543
|
-
disabledMultimodal: boolean;
|
|
2544
|
-
/** 最大允许大小 */
|
|
2545
|
-
maxAllowedSize: number;
|
|
2546
|
-
/** 是否支持推理 */
|
|
2547
|
-
supportsReasoning: boolean;
|
|
2548
|
-
/** 是否仅推理模式 */
|
|
2549
|
-
onlyReasoning: boolean;
|
|
2550
|
-
/** 温度参数 */
|
|
2551
|
-
temperature: number;
|
|
2552
|
-
/** 推理配置 */
|
|
2553
|
-
reasoning: ReasoningConfig;
|
|
2554
|
-
/** 英文描述 */
|
|
2555
|
-
descriptionEn: string;
|
|
2556
|
-
/** 中文描述 */
|
|
2557
|
-
descriptionZh: string;
|
|
3187
|
+
[Symbol.dispose](): void;
|
|
3188
|
+
private getConnectionOrThrow;
|
|
3189
|
+
private setupConnectionEvents;
|
|
3190
|
+
private mapPromptResponse;
|
|
2558
3191
|
}
|
|
3192
|
+
//#endregion
|
|
3193
|
+
//#region ../agent-provider/lib/common/client/session-manager.d.ts
|
|
2559
3194
|
/**
|
|
2560
|
-
*
|
|
3195
|
+
* Options for creating a SessionManager instance
|
|
2561
3196
|
*/
|
|
2562
|
-
interface
|
|
2563
|
-
/**
|
|
2564
|
-
|
|
2565
|
-
/**
|
|
2566
|
-
|
|
3197
|
+
interface SessionManagerOptions {
|
|
3198
|
+
/** Agent provider (required) */
|
|
3199
|
+
provider: AgentProvider;
|
|
3200
|
+
/** Logger instance */
|
|
3201
|
+
logger?: Logger;
|
|
2567
3202
|
}
|
|
2568
3203
|
/**
|
|
2569
|
-
*
|
|
3204
|
+
* SessionManager - Session lifecycle management
|
|
2570
3205
|
*
|
|
2571
|
-
*
|
|
3206
|
+
* This class manages the relationship between sessions and agents.
|
|
3207
|
+
* Since the backend is agent-centric, SessionManager handles the mapping:
|
|
3208
|
+
* - Sessions are views over agents
|
|
3209
|
+
* - sessionId may equal agentId in simple cases
|
|
2572
3210
|
*
|
|
2573
|
-
*
|
|
2574
|
-
*
|
|
3211
|
+
* Features:
|
|
3212
|
+
* - Session caching: reuses existing ActiveSession instances
|
|
3213
|
+
* - Automatic cleanup on session disconnect
|
|
3214
|
+
*
|
|
3215
|
+
* @example
|
|
3216
|
+
* ```typescript
|
|
3217
|
+
* const manager = new SessionManager({ provider, logger });
|
|
3218
|
+
*
|
|
3219
|
+
* // List sessions
|
|
3220
|
+
* const sessions = await manager.listSessions();
|
|
3221
|
+
*
|
|
3222
|
+
* // Create new session
|
|
3223
|
+
* const session = await manager.createSession({ cwd: '/workspace' });
|
|
3224
|
+
*
|
|
3225
|
+
* // Load existing session (returns cached instance if available)
|
|
3226
|
+
* const loaded = await manager.loadSession({ sessionId: 'xxx', cwd: '/workspace' });
|
|
3227
|
+
* ```
|
|
2575
3228
|
*/
|
|
2576
|
-
|
|
3229
|
+
declare class SessionManager {
|
|
3230
|
+
private provider;
|
|
3231
|
+
private logger?;
|
|
3232
|
+
constructor(options: SessionManagerOptions);
|
|
2577
3233
|
/**
|
|
2578
|
-
*
|
|
2579
|
-
*
|
|
3234
|
+
* List all sessions with pagination info (mapped from agents)
|
|
3235
|
+
*
|
|
3236
|
+
* Each agent maps to a session. The sessionId is derived from the agent.
|
|
3237
|
+
* Cloud: Returns server-side filtered/sorted/paginated results
|
|
3238
|
+
* Local: Returns client-side filtered/sorted results (synthetic pagination)
|
|
3239
|
+
*
|
|
3240
|
+
* @param options - Optional query parameters for filtering, sorting, and pagination
|
|
2580
3241
|
*/
|
|
2581
|
-
|
|
3242
|
+
listSessions(options?: ListAgentOptions): Promise<ListAgentResult<SessionInfo>>;
|
|
2582
3243
|
/**
|
|
2583
|
-
*
|
|
2584
|
-
*
|
|
2585
|
-
*
|
|
3244
|
+
* Create a new session
|
|
3245
|
+
*
|
|
3246
|
+
* Steps:
|
|
3247
|
+
* 1. Create new agent (if provider supports it) or use existing
|
|
3248
|
+
* 2. Connect to agent
|
|
3249
|
+
* 3. Call ACP newSession
|
|
3250
|
+
* 4. Register session mapping (for LocalAgentProvider)
|
|
3251
|
+
* 5. Return ActiveSession instance
|
|
2586
3252
|
*/
|
|
2587
|
-
|
|
3253
|
+
createSession(params: CreateSessionParams$1): Promise<ActiveSession>;
|
|
2588
3254
|
/**
|
|
2589
|
-
*
|
|
3255
|
+
* Load an existing session
|
|
3256
|
+
*
|
|
3257
|
+
* Steps:
|
|
3258
|
+
* 1. Check cache for existing session
|
|
3259
|
+
* 2. Find agent by sessionId (sessionId === agentId in current design)
|
|
3260
|
+
* 3. Connect to agent
|
|
3261
|
+
* 4. Create ActiveSession instance
|
|
3262
|
+
* 5. Execute onSessionCreated callback (if provided) to allow early setup (e.g., event listeners)
|
|
3263
|
+
* 6. Call ACP loadSession
|
|
3264
|
+
* 7. Return ActiveSession instance (cached)
|
|
2590
3265
|
*/
|
|
2591
|
-
|
|
3266
|
+
loadSession(params: LoadSessionParams$1): Promise<ActiveSession>;
|
|
2592
3267
|
}
|
|
2593
3268
|
//#endregion
|
|
2594
3269
|
//#region ../agent-provider/lib/backend/backend-provider.d.ts
|
|
@@ -2598,13 +3273,12 @@ interface IBackendProvider {
|
|
|
2598
3273
|
* 职责:
|
|
2599
3274
|
* - 触发登录/登出流程
|
|
2600
3275
|
* - 获取 account 后自动同步到 accountService
|
|
3276
|
+
* - 使用单例 httpService 进行所有 HTTP 请求
|
|
2601
3277
|
*
|
|
2602
3278
|
* 注意:getAgents 和 getModels 方法已废弃并移除,
|
|
2603
3279
|
* 请使用 IAgentAdapter 中的对应方法
|
|
2604
3280
|
*/
|
|
2605
3281
|
declare class BackendProvider implements IBackendProvider {
|
|
2606
|
-
private readonly baseUrl;
|
|
2607
|
-
private readonly authToken?;
|
|
2608
3282
|
constructor(config: BackendProviderConfig);
|
|
2609
3283
|
/**
|
|
2610
3284
|
* 获取当前账号信息
|
|
@@ -2620,12 +3294,87 @@ declare class BackendProvider implements IBackendProvider {
|
|
|
2620
3294
|
* 5. 同步到 accountService
|
|
2621
3295
|
*/
|
|
2622
3296
|
getAccount(): Promise<Account | null>;
|
|
3297
|
+
/**
|
|
3298
|
+
* 获取用户连接器列表
|
|
3299
|
+
* API 端点: GET /console/as/connector/user/
|
|
3300
|
+
*/
|
|
3301
|
+
getUserConnector(): Promise<ListUserConnectorResponse>;
|
|
3302
|
+
/**
|
|
3303
|
+
* 修改用户连接器连接状态
|
|
3304
|
+
* API 端点: PATCH /console/as/connector/user/:name/connect_status
|
|
3305
|
+
*/
|
|
3306
|
+
modifyUserConnectorConnectStatus(request: ModifyUserConnectorConnectStatusRequest): Promise<void>;
|
|
3307
|
+
/**
|
|
3308
|
+
* 修改用户连接器仓库
|
|
3309
|
+
* API 端点: PATCH /console/as/connector/user/:name/repo/
|
|
3310
|
+
*/
|
|
3311
|
+
modifyUserConnectorRepo(request: ModifyUserConnectorRepoRequest): Promise<void>;
|
|
3312
|
+
/**
|
|
3313
|
+
* 修改用户连接器激活状态
|
|
3314
|
+
* API 端点: PATCH /console/as/connector/user/:name/active_status
|
|
3315
|
+
*/
|
|
3316
|
+
modifyUserConnectorActiveStatus(request: ModifyUserConnectorActiveStatusRequest): Promise<void>;
|
|
3317
|
+
/**
|
|
3318
|
+
* 删除用户连接器
|
|
3319
|
+
* API 端点: DELETE /console/as/connector/user/:name/
|
|
3320
|
+
*/
|
|
3321
|
+
deleteUserConnector(name: 'github' | 'gongfeng'): Promise<void>;
|
|
3322
|
+
/**
|
|
3323
|
+
* 添加任务
|
|
3324
|
+
* API 端点: POST /console/as/connector/task/
|
|
3325
|
+
*/
|
|
3326
|
+
addConnectorTask(request: AddTaskRequest): Promise<AddTaskResponse>;
|
|
3327
|
+
/**
|
|
3328
|
+
* 获取任务连接器列表
|
|
3329
|
+
* API 端点: GET /console/as/connector/task/:taskid
|
|
3330
|
+
*/
|
|
3331
|
+
getTaskConnector(taskId: string): Promise<ListTaskConnectorResponse>;
|
|
3332
|
+
/**
|
|
3333
|
+
* 修改任务连接器激活状态
|
|
3334
|
+
* API 端点: PATCH /console/as/connector/task/:taskid/active_status
|
|
3335
|
+
*/
|
|
3336
|
+
modifyTaskConnectorActiveStatus(request: ModifyTaskConnectorActiveStatusRequest): Promise<ModifyTaskConnectorActiveStatusResponse>;
|
|
3337
|
+
/**
|
|
3338
|
+
* 修改任务连接器仓库
|
|
3339
|
+
* API 端点: PATCH /console/as/connector/task/:taskid/repo
|
|
3340
|
+
*/
|
|
3341
|
+
modifyTaskConnectorRepo(request: ModifyTaskConnectorRepoRequest): Promise<ModifyTaskConnectorRepoResponse>;
|
|
3342
|
+
/**
|
|
3343
|
+
* 根据账号类型获取用量信息并合并到账号中
|
|
3344
|
+
* - 企业用户:调用 getEnterpriseUsage 获取月度限额
|
|
3345
|
+
* - 个人用户:调用 getCurrentPlan 获取套餐信息
|
|
3346
|
+
*/
|
|
3347
|
+
private enrichAccountWithUsage;
|
|
2623
3348
|
/**
|
|
2624
3349
|
* 获取当前套餐信息
|
|
2625
3350
|
* 从计量计费接口获取用户的套餐信息
|
|
2626
3351
|
* API: POST /billing/meter/get-user-resource
|
|
2627
3352
|
*/
|
|
2628
3353
|
private getCurrentPlan;
|
|
3354
|
+
/**
|
|
3355
|
+
* 通过回调code,换token
|
|
3356
|
+
* @param request
|
|
3357
|
+
* @returns
|
|
3358
|
+
*/
|
|
3359
|
+
saveOauthToken(request: SaveOauthTokenRequest): Promise<void>;
|
|
3360
|
+
/**
|
|
3361
|
+
* 获取OAuth连接器的仓库列表
|
|
3362
|
+
*/
|
|
3363
|
+
getRepoList(request: GetRepoListRequest): Promise<GetRepoListResponse>;
|
|
3364
|
+
/**
|
|
3365
|
+
* 撤销OAuth连接器的所有连接
|
|
3366
|
+
*/
|
|
3367
|
+
revokeAll(request: RevokeAllRequest): Promise<void>;
|
|
3368
|
+
/**
|
|
3369
|
+
* 获取 OAuth 用户信息
|
|
3370
|
+
* API 端点: GET /console/as/connector/oauth/:name/oauthuser
|
|
3371
|
+
*/
|
|
3372
|
+
getOauthUser(request: GetOauthUserRequest): Promise<GetOauthUserResponse>;
|
|
3373
|
+
/**
|
|
3374
|
+
* 获取文件信息
|
|
3375
|
+
* API 端点: GET /console/as/connector/oauth/:name/file
|
|
3376
|
+
*/
|
|
3377
|
+
getFile(request: GetFileRequest): Promise<GetFileResponse>;
|
|
2629
3378
|
/**
|
|
2630
3379
|
* 根据账号类型和 Pro 状态计算版本展示类型
|
|
2631
3380
|
* - personal + isPro = 'pro'
|
|
@@ -2641,9 +3390,32 @@ declare class BackendProvider implements IBackendProvider {
|
|
|
2641
3390
|
login(): Promise<void>;
|
|
2642
3391
|
/**
|
|
2643
3392
|
* 登出账号
|
|
2644
|
-
* Web 环境:
|
|
3393
|
+
* Web 环境: 通过 iframe 访问登出 URL 清除 cookie
|
|
2645
3394
|
*/
|
|
2646
3395
|
logout(): Promise<void>;
|
|
3396
|
+
/**
|
|
3397
|
+
* 批量切换插件状态
|
|
3398
|
+
* Web 环境不支持此功能
|
|
3399
|
+
*/
|
|
3400
|
+
batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
|
|
3401
|
+
/**
|
|
3402
|
+
* 获取企业用户用量信息
|
|
3403
|
+
* API: POST /billing/meter/get-enterprise-user-usage
|
|
3404
|
+
*/
|
|
3405
|
+
getEnterpriseUsage(enterpriseId: string): Promise<EnterpriseUsage | null>;
|
|
3406
|
+
/**
|
|
3407
|
+
* 获取支持的场景列表
|
|
3408
|
+
* API 端点: GET /console/as/support/scenes
|
|
3409
|
+
* 用于 Welcome 页面的 QuickActions 快捷操作
|
|
3410
|
+
*
|
|
3411
|
+
* 调用链(Web 环境):
|
|
3412
|
+
* 1. useTemplates hook 调用 adapter.getTemplates()
|
|
3413
|
+
* 2. CloudAgentAdapter.getTemplates() 调用 backendProvider.getSupportScenes()
|
|
3414
|
+
* 3. BackendProvider -> HTTP GET /console/as/support/scenes
|
|
3415
|
+
* 4. 返回 SupportScene[] 转换为 TemplateScene[]
|
|
3416
|
+
* 5. useTemplates 将数据提供给 QuickActions 组件展示
|
|
3417
|
+
*/
|
|
3418
|
+
getSupportScenes(): Promise<SupportScene[]>;
|
|
2647
3419
|
}
|
|
2648
3420
|
/**
|
|
2649
3421
|
* 创建 BackendProvider 实例
|
|
@@ -2684,6 +3456,76 @@ declare class IPCBackendProvider implements IBackendProvider {
|
|
|
2684
3456
|
* IDE 环境: 通过 IPC 获取账号信息,并同步到 accountService
|
|
2685
3457
|
*/
|
|
2686
3458
|
getAccount(): Promise<Account | null>;
|
|
3459
|
+
/**
|
|
3460
|
+
* 获取用户连接器列表
|
|
3461
|
+
* IDE 环境: 通过 IPC 获取用户连接器列表
|
|
3462
|
+
*/
|
|
3463
|
+
getUserConnector(): Promise<ListUserConnectorResponse>;
|
|
3464
|
+
/**
|
|
3465
|
+
* 修改用户连接器连接状态
|
|
3466
|
+
* IDE 环境: 通过 IPC 修改用户连接器连接状态
|
|
3467
|
+
*/
|
|
3468
|
+
modifyUserConnectorConnectStatus(request: ModifyUserConnectorConnectStatusRequest): Promise<void>;
|
|
3469
|
+
/**
|
|
3470
|
+
* 修改用户连接器仓库
|
|
3471
|
+
* IDE 环境: 通过 IPC 修改用户连接器仓库
|
|
3472
|
+
*/
|
|
3473
|
+
modifyUserConnectorRepo(request: ModifyUserConnectorRepoRequest): Promise<void>;
|
|
3474
|
+
/**
|
|
3475
|
+
* 修改用户连接器激活状态
|
|
3476
|
+
* IDE 环境: 通过 IPC 修改用户连接器激活状态
|
|
3477
|
+
*/
|
|
3478
|
+
modifyUserConnectorActiveStatus(request: ModifyUserConnectorActiveStatusRequest): Promise<void>;
|
|
3479
|
+
/**
|
|
3480
|
+
* 删除用户连接器
|
|
3481
|
+
* IDE 环境: 通过 IPC 删除用户连接器
|
|
3482
|
+
*/
|
|
3483
|
+
deleteUserConnector(name: 'github' | 'gongfeng'): Promise<void>;
|
|
3484
|
+
/**
|
|
3485
|
+
* 添加任务
|
|
3486
|
+
* IDE 环境: 通过 IPC 添加任务
|
|
3487
|
+
*/
|
|
3488
|
+
addConnectorTask(request: AddTaskRequest): Promise<AddTaskResponse>;
|
|
3489
|
+
/**
|
|
3490
|
+
* 获取任务连接器列表
|
|
3491
|
+
* IDE 环境: 通过 IPC 获取任务连接器列表
|
|
3492
|
+
*/
|
|
3493
|
+
getTaskConnector(taskId: string): Promise<ListTaskConnectorResponse>;
|
|
3494
|
+
/**
|
|
3495
|
+
* 修改任务连接器激活状态
|
|
3496
|
+
* IDE 环境: 通过 IPC 修改任务连接器激活状态
|
|
3497
|
+
*/
|
|
3498
|
+
modifyTaskConnectorActiveStatus(request: ModifyTaskConnectorActiveStatusRequest): Promise<ModifyTaskConnectorActiveStatusResponse>;
|
|
3499
|
+
/**
|
|
3500
|
+
* 修改任务连接器仓库
|
|
3501
|
+
* IDE 环境: 通过 IPC 修改任务连接器仓库
|
|
3502
|
+
*/
|
|
3503
|
+
modifyTaskConnectorRepo(request: ModifyTaskConnectorRepoRequest): Promise<ModifyTaskConnectorRepoResponse>;
|
|
3504
|
+
/**
|
|
3505
|
+
* 获取 OAuth 用户信息
|
|
3506
|
+
* IDE 环境: 通过 IPC 获取 OAuth 用户信息
|
|
3507
|
+
*/
|
|
3508
|
+
getOauthUser(request: GetOauthUserRequest): Promise<GetOauthUserResponse>;
|
|
3509
|
+
/**
|
|
3510
|
+
* 通过回调code,换token
|
|
3511
|
+
* IDE 环境: 通过 IPC 保存 OAuth Token
|
|
3512
|
+
*/
|
|
3513
|
+
saveOauthToken(request: SaveOauthTokenRequest): Promise<void>;
|
|
3514
|
+
/**
|
|
3515
|
+
* 获取OAuth连接器的仓库列表
|
|
3516
|
+
* IDE 环境: 通过 IPC 获取仓库列表
|
|
3517
|
+
*/
|
|
3518
|
+
getRepoList(request: GetRepoListRequest): Promise<GetRepoListResponse>;
|
|
3519
|
+
/**
|
|
3520
|
+
* 撤销OAuth连接器的所有连接
|
|
3521
|
+
* IDE 环境: 通过 IPC 撤销所有连接
|
|
3522
|
+
*/
|
|
3523
|
+
revokeAll(request: RevokeAllRequest): Promise<void>;
|
|
3524
|
+
/**
|
|
3525
|
+
* 获取文件信息
|
|
3526
|
+
* IDE 环境: 通过 IPC 获取文件信息
|
|
3527
|
+
*/
|
|
3528
|
+
getFile(request: GetFileRequest): Promise<GetFileResponse>;
|
|
2687
3529
|
/**
|
|
2688
3530
|
* 触发登录流程
|
|
2689
3531
|
* IDE 环境: 通过 IPC 通知 IDE 打开登录流程
|
|
@@ -2694,6 +3536,31 @@ declare class IPCBackendProvider implements IBackendProvider {
|
|
|
2694
3536
|
* IDE 环境: 通过 IPC 通知 IDE 登出
|
|
2695
3537
|
*/
|
|
2696
3538
|
logout(): Promise<void>;
|
|
3539
|
+
/**
|
|
3540
|
+
* 重新加载窗口
|
|
3541
|
+
* IDE 环境: 通过 IPC 通知 IDE 重新加载窗口(用于应用语言设置等)
|
|
3542
|
+
* @param params 可选参数,如 locale
|
|
3543
|
+
*/
|
|
3544
|
+
reloadWindow(params?: {
|
|
3545
|
+
locale?: string;
|
|
3546
|
+
}): Promise<void>;
|
|
3547
|
+
/**
|
|
3548
|
+
* 批量切换插件状态
|
|
3549
|
+
* IDE 环境: 通过 IPC 调用 Extension Host 的 PluginService
|
|
3550
|
+
*/
|
|
3551
|
+
batchTogglePlugins(request: BatchPluginOperationRequest): Promise<BatchPluginOperationResult>;
|
|
3552
|
+
/**
|
|
3553
|
+
* 获取支持的场景列表
|
|
3554
|
+
* IDE 环境: 通过 IPC 调用后端 API
|
|
3555
|
+
* 用于 Welcome 页面的 QuickActions 快捷操作
|
|
3556
|
+
*
|
|
3557
|
+
* 调用链:
|
|
3558
|
+
* 1. agent-ui: IPCBackendProvider.getSupportScenes()
|
|
3559
|
+
* 2. Extension Host: BackendBridgeService.handleGetSupportScenes()
|
|
3560
|
+
* 3. Backend API: GET /v2/as/support/scenes
|
|
3561
|
+
* 4. 返回 SupportScene[] 数据给 agent-ui
|
|
3562
|
+
*/
|
|
3563
|
+
getSupportScenes(): Promise<SupportScene[]>;
|
|
2697
3564
|
/**
|
|
2698
3565
|
* 调试日志
|
|
2699
3566
|
*/
|
|
@@ -2704,5 +3571,248 @@ declare class IPCBackendProvider implements IBackendProvider {
|
|
|
2704
3571
|
*/
|
|
2705
3572
|
declare function createIPCBackendProvider(config: IPCBackendProviderConfig): IPCBackendProvider;
|
|
2706
3573
|
//#endregion
|
|
2707
|
-
|
|
3574
|
+
//#region ../agent-provider/lib/http/types.d.ts
|
|
3575
|
+
/**
|
|
3576
|
+
* HttpService 配置
|
|
3577
|
+
*/
|
|
3578
|
+
interface HttpServiceConfig {
|
|
3579
|
+
/** API 基础 URL(可选,可后续通过 setBaseURL 设置) */
|
|
3580
|
+
baseURL?: string;
|
|
3581
|
+
/** 认证 token(可选) */
|
|
3582
|
+
authToken?: string;
|
|
3583
|
+
/** 请求超时时间(毫秒),默认 60000 */
|
|
3584
|
+
timeout?: number;
|
|
3585
|
+
/** 是否携带凭证,默认 true */
|
|
3586
|
+
withCredentials?: boolean;
|
|
3587
|
+
/** 自定义 headers */
|
|
3588
|
+
headers?: Record<string, string>;
|
|
3589
|
+
}
|
|
3590
|
+
/**
|
|
3591
|
+
* 请求拦截器函数
|
|
3592
|
+
*/
|
|
3593
|
+
type RequestInterceptor = (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
|
|
3594
|
+
/**
|
|
3595
|
+
* 请求错误拦截器函数
|
|
3596
|
+
*/
|
|
3597
|
+
type RequestErrorInterceptor = (error: any) => any;
|
|
3598
|
+
/**
|
|
3599
|
+
* 响应拦截器函数
|
|
3600
|
+
*/
|
|
3601
|
+
type ResponseInterceptor = (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
|
|
3602
|
+
/**
|
|
3603
|
+
* 响应错误拦截器函数
|
|
3604
|
+
*/
|
|
3605
|
+
type ResponseErrorInterceptor = (error: AxiosError) => any;
|
|
3606
|
+
/**
|
|
3607
|
+
* 401 未授权回调函数
|
|
3608
|
+
*/
|
|
3609
|
+
type UnauthorizedCallback = () => void;
|
|
3610
|
+
//#endregion
|
|
3611
|
+
//#region ../agent-provider/lib/http/http-service.d.ts
|
|
3612
|
+
/**
|
|
3613
|
+
* HttpService - 单例 HTTP 客户端
|
|
3614
|
+
*
|
|
3615
|
+
* 特性:
|
|
3616
|
+
* - 单例模式,全局唯一实例,延迟初始化(首次使用时自动创建)
|
|
3617
|
+
* - 支持拦截器注册(其他模块可注入 header)
|
|
3618
|
+
* - 统一 401/403 处理
|
|
3619
|
+
* - 自动携带凭证(withCredentials)
|
|
3620
|
+
* - 类型安全
|
|
3621
|
+
*
|
|
3622
|
+
* @example
|
|
3623
|
+
* ```typescript
|
|
3624
|
+
* // 直接使用导出的 httpService(首次使用时自动初始化)
|
|
3625
|
+
* import { httpService } from '@genie/agent-provider';
|
|
3626
|
+
*
|
|
3627
|
+
* // 按需设置 baseURL
|
|
3628
|
+
* httpService.setBaseURL('https://api.example.com');
|
|
3629
|
+
*
|
|
3630
|
+
* // 按需设置 authToken
|
|
3631
|
+
* httpService.setAuthToken('your-token');
|
|
3632
|
+
*
|
|
3633
|
+
* // 注册请求拦截器(注入 header)
|
|
3634
|
+
* httpService.registerRequestInterceptor((config) => {
|
|
3635
|
+
* config.headers['X-Enterprise-Id'] = 'enterprise-123';
|
|
3636
|
+
* return config;
|
|
3637
|
+
* });
|
|
3638
|
+
*
|
|
3639
|
+
* // 注册 401 回调
|
|
3640
|
+
* httpService.onUnauthorized(() => {
|
|
3641
|
+
* console.log('User unauthorized');
|
|
3642
|
+
* window.location.href = '/login';
|
|
3643
|
+
* });
|
|
3644
|
+
*
|
|
3645
|
+
* // 发起请求
|
|
3646
|
+
* const data = await httpService.get<Account>('/console/accounts');
|
|
3647
|
+
* ```
|
|
3648
|
+
*/
|
|
3649
|
+
declare class HttpService {
|
|
3650
|
+
private static instance;
|
|
3651
|
+
private axiosInstance;
|
|
3652
|
+
private unauthorizedCallbacks;
|
|
3653
|
+
private config;
|
|
3654
|
+
/**
|
|
3655
|
+
* 私有构造函数(单例模式)
|
|
3656
|
+
*/
|
|
3657
|
+
private constructor();
|
|
3658
|
+
/**
|
|
3659
|
+
* 获取单例实例(延迟初始化)
|
|
3660
|
+
*/
|
|
3661
|
+
static getInstance(): HttpService;
|
|
3662
|
+
/**
|
|
3663
|
+
* 重置单例实例(主要用于测试)
|
|
3664
|
+
*/
|
|
3665
|
+
static resetInstance(): void;
|
|
3666
|
+
/**
|
|
3667
|
+
* 注册默认请求拦截器(添加 Authorization header)
|
|
3668
|
+
*/
|
|
3669
|
+
private registerDefaultRequestInterceptor;
|
|
3670
|
+
/**
|
|
3671
|
+
* 注册默认响应拦截器(处理 401/403)
|
|
3672
|
+
*/
|
|
3673
|
+
private registerDefaultResponseInterceptor;
|
|
3674
|
+
/**
|
|
3675
|
+
* 注册请求拦截器
|
|
3676
|
+
* @param onFulfilled 请求成功拦截器
|
|
3677
|
+
* @param onRejected 请求失败拦截器
|
|
3678
|
+
* @returns 拦截器 ID(用于移除)
|
|
3679
|
+
*
|
|
3680
|
+
* @example
|
|
3681
|
+
* ```typescript
|
|
3682
|
+
* const id = httpService.registerRequestInterceptor((config) => {
|
|
3683
|
+
* config.headers['X-Custom-Header'] = 'value';
|
|
3684
|
+
* return config;
|
|
3685
|
+
* });
|
|
3686
|
+
*
|
|
3687
|
+
* // 移除拦截器
|
|
3688
|
+
* httpService.ejectRequestInterceptor(id);
|
|
3689
|
+
* ```
|
|
3690
|
+
*/
|
|
3691
|
+
registerRequestInterceptor(onFulfilled: RequestInterceptor, onRejected?: RequestErrorInterceptor): number;
|
|
3692
|
+
/**
|
|
3693
|
+
* 注册响应拦截器
|
|
3694
|
+
* @param onFulfilled 响应成功拦截器
|
|
3695
|
+
* @param onRejected 响应失败拦截器
|
|
3696
|
+
* @returns 拦截器 ID(用于移除)
|
|
3697
|
+
*
|
|
3698
|
+
* @example
|
|
3699
|
+
* ```typescript
|
|
3700
|
+
* const id = httpService.registerResponseInterceptor((response) => {
|
|
3701
|
+
* console.log('Response:', response.data);
|
|
3702
|
+
* return response;
|
|
3703
|
+
* });
|
|
3704
|
+
*
|
|
3705
|
+
* // 移除拦截器
|
|
3706
|
+
* httpService.ejectResponseInterceptor(id);
|
|
3707
|
+
* ```
|
|
3708
|
+
*/
|
|
3709
|
+
registerResponseInterceptor(onFulfilled: ResponseInterceptor, onRejected?: ResponseErrorInterceptor): number;
|
|
3710
|
+
/**
|
|
3711
|
+
* 移除请求拦截器
|
|
3712
|
+
* @param id 拦截器 ID
|
|
3713
|
+
*/
|
|
3714
|
+
ejectRequestInterceptor(id: number): void;
|
|
3715
|
+
/**
|
|
3716
|
+
* 移除响应拦截器
|
|
3717
|
+
* @param id 拦截器 ID
|
|
3718
|
+
*/
|
|
3719
|
+
ejectResponseInterceptor(id: number): void;
|
|
3720
|
+
/**
|
|
3721
|
+
* 注册 401 未授权回调
|
|
3722
|
+
* @param callback 回调函数
|
|
3723
|
+
*
|
|
3724
|
+
* @example
|
|
3725
|
+
* ```typescript
|
|
3726
|
+
* httpService.onUnauthorized(() => {
|
|
3727
|
+
* console.log('User logged out');
|
|
3728
|
+
* window.location.href = '/login';
|
|
3729
|
+
* });
|
|
3730
|
+
* ```
|
|
3731
|
+
*/
|
|
3732
|
+
onUnauthorized(callback: UnauthorizedCallback): void;
|
|
3733
|
+
/**
|
|
3734
|
+
* 移除 401 未授权回调
|
|
3735
|
+
* @param callback 回调函数
|
|
3736
|
+
*/
|
|
3737
|
+
offUnauthorized(callback: UnauthorizedCallback): void;
|
|
3738
|
+
/**
|
|
3739
|
+
* 触发所有 401 回调
|
|
3740
|
+
*/
|
|
3741
|
+
private triggerUnauthorizedCallbacks;
|
|
3742
|
+
/**
|
|
3743
|
+
* 更新 authToken
|
|
3744
|
+
* @param token 新的 token
|
|
3745
|
+
*/
|
|
3746
|
+
setAuthToken(token: string | undefined): void;
|
|
3747
|
+
/**
|
|
3748
|
+
* 更新 baseURL
|
|
3749
|
+
* @param baseURL 新的 baseURL
|
|
3750
|
+
*/
|
|
3751
|
+
setBaseURL(baseURL: string): void;
|
|
3752
|
+
/**
|
|
3753
|
+
* GET 请求
|
|
3754
|
+
* @param url 请求路径
|
|
3755
|
+
* @param config axios 配置
|
|
3756
|
+
* @returns 响应数据
|
|
3757
|
+
*/
|
|
3758
|
+
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
3759
|
+
/**
|
|
3760
|
+
* POST 请求
|
|
3761
|
+
* @param url 请求路径
|
|
3762
|
+
* @param data 请求体
|
|
3763
|
+
* @param config axios 配置
|
|
3764
|
+
* @returns 响应数据
|
|
3765
|
+
*/
|
|
3766
|
+
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
3767
|
+
/**
|
|
3768
|
+
* PATCH 请求
|
|
3769
|
+
* @param url 请求路径
|
|
3770
|
+
* @param data 请求体
|
|
3771
|
+
* @param config axios 配置
|
|
3772
|
+
* @returns 响应数据
|
|
3773
|
+
*/
|
|
3774
|
+
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
3775
|
+
/**
|
|
3776
|
+
* DELETE 请求
|
|
3777
|
+
* @param url 请求路径
|
|
3778
|
+
* @param config axios 配置
|
|
3779
|
+
* @returns 响应数据
|
|
3780
|
+
*/
|
|
3781
|
+
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
3782
|
+
/**
|
|
3783
|
+
* PUT 请求
|
|
3784
|
+
* @param url 请求路径
|
|
3785
|
+
* @param data 请求体
|
|
3786
|
+
* @param config axios 配置
|
|
3787
|
+
* @returns 响应数据
|
|
3788
|
+
*/
|
|
3789
|
+
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
3790
|
+
/**
|
|
3791
|
+
* 获取原始 axios 实例(用于高级场景)
|
|
3792
|
+
*/
|
|
3793
|
+
getAxiosInstance(): AxiosInstance;
|
|
3794
|
+
}
|
|
3795
|
+
//#endregion
|
|
3796
|
+
//#region ../agent-provider/lib/http/index.d.ts
|
|
3797
|
+
/**
|
|
3798
|
+
* 导出 httpService 单例实例
|
|
3799
|
+
* 首次访问时自动初始化,无需手动调用初始化方法
|
|
3800
|
+
*
|
|
3801
|
+
* @example
|
|
3802
|
+
* ```typescript
|
|
3803
|
+
* import { httpService } from '@genie/agent-provider';
|
|
3804
|
+
*
|
|
3805
|
+
* // 按需设置 baseURL
|
|
3806
|
+
* httpService.setBaseURL('https://api.example.com');
|
|
3807
|
+
*
|
|
3808
|
+
* // 按需设置 authToken
|
|
3809
|
+
* httpService.setAuthToken('your-token');
|
|
3810
|
+
*
|
|
3811
|
+
* // 直接使用
|
|
3812
|
+
* const data = await httpService.get('/api/endpoint');
|
|
3813
|
+
* ```
|
|
3814
|
+
*/
|
|
3815
|
+
declare const httpService: HttpService;
|
|
3816
|
+
//#endregion
|
|
3817
|
+
export { type Account, type AccountPlan, type ActiveSession, ActiveSessionImpl, type AgentCapabilities, AgentClient, type AgentClientOptions, type AgentConnection, type Agent as AgentInfo, type AgentProvider, type AgentState, type AgentStateType, type AgentStatus, type AgentTransport, type PromptResponse as ApiPromptResponse, type ArtifactsResource, BackendProvider, type BackendProviderConfig, type BaseAgentState, type BaseConnectionConfig, type CreateSessionParams as ClientCreateSessionParams, type CreateSessionParams, type LoadSessionParams as ClientLoadSessionParams, type LoadSessionParams, type ClientSessionsResource, CloudAgentConnection, CloudAgentProvider, type CloudAgentProviderOptions, type CloudAgentSourceInfo, type CloudAgentState, type CloudAgentTarget, type CloudAgentVisibility, type CloudConnectionConfig, type CommodityCode, type ConnectionEvents, type DeployStatus, E2BFilesystem, type E2BSandboxConnectionInfo, type Edition, type EditionDisplayType, type EntryInfo, type FilesResource, type Filesystem, type FilesystemListOpts, type FilesystemProvider, type FilesystemRequestOpts, HttpService, type HttpServiceConfig, type IBackendProvider, IPCBackendProvider, type ListAgentFilter, type ListAgentOptions, type ListAgentSort, type Logger, type McpServerConfig, type ModelInfo, type PromptContentBlock, type PromptParams, type PromptsResource, type ReasoningConfig, type RequestErrorInterceptor, type RequestInterceptor, type ResponseErrorInterceptor, type ResponseInterceptor, type Session, type SessionAgentOperations, type SessionConnectionInfo, type SessionEventHandler, type SessionEvents, type SessionInfo, SessionManager, type SessionMode, type UnauthorizedCallback, type WatchOpts, type WriteEntry, createBackendProvider, createIPCBackendProvider, httpService, isCloudAgentState };
|
|
2708
3818
|
//# sourceMappingURL=index.d.cts.map
|