@tencent-ai/cloud-agent-sdk 0.2.1 → 0.2.2
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.browser.mjs +19430 -0
- package/dist/index.cjs +11306 -3536
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +301 -80
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +301 -80
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +11306 -3536
- package/dist/index.mjs.map +1 -1
- package/dist/tencent-ai-cloud-agent-sdk-0.2.2.tgz +0 -0
- package/package.json +8 -2
- package/dist/tencent-ai-cloud-agent-sdk-0.2.1.tgz +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -7,7 +7,7 @@ import "zod";
|
|
|
7
7
|
* Types of artifacts that can be created by the agent
|
|
8
8
|
* Uses discriminant for TypeScript type narrowing
|
|
9
9
|
*/
|
|
10
|
-
type ArtifactType = 'plan' | 'tasks' | 'media';
|
|
10
|
+
type ArtifactType = 'plan' | 'tasks' | 'media' | 'overview';
|
|
11
11
|
/**
|
|
12
12
|
* Base Artifact interface
|
|
13
13
|
* Inspired by MCP Resource: https://modelcontextprotocol.io/specification/2025-11-25/server/resources
|
|
@@ -94,11 +94,21 @@ interface MediaArtifact extends BaseArtifact<'media'> {
|
|
|
94
94
|
/** Height (for images/videos) */
|
|
95
95
|
height?: number;
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Overview Artifact - 任务完成后的总结文档
|
|
99
|
+
* mimeType: text/markdown
|
|
100
|
+
*/
|
|
101
|
+
interface OverviewArtifact extends BaseArtifact<'overview'> {
|
|
102
|
+
/** MIME type fixed as text/markdown */
|
|
103
|
+
mimeType: 'text/markdown';
|
|
104
|
+
/** Markdown text content */
|
|
105
|
+
text?: string;
|
|
106
|
+
}
|
|
97
107
|
/**
|
|
98
108
|
* Artifact union type
|
|
99
109
|
* Uses type field for discriminated union
|
|
100
110
|
*/
|
|
101
|
-
type Artifact = PlanArtifact | TasksArtifact | MediaArtifact;
|
|
111
|
+
type Artifact = PlanArtifact | TasksArtifact | MediaArtifact | OverviewArtifact;
|
|
102
112
|
/**
|
|
103
113
|
* Question option structure
|
|
104
114
|
*/
|
|
@@ -190,14 +200,12 @@ interface FileChangeInfo {
|
|
|
190
200
|
additions: number;
|
|
191
201
|
/** Lines deleted */
|
|
192
202
|
deletions: number;
|
|
193
|
-
/** Unified diff format content
|
|
203
|
+
/** Unified diff format content
|
|
204
|
+
* https://unifiedjs.com/explore/package/unified-diff/
|
|
205
|
+
*/
|
|
194
206
|
diff?: string;
|
|
195
207
|
/** File language */
|
|
196
208
|
language?: string;
|
|
197
|
-
/** Virtual URI for original content (agent-diff://...) */
|
|
198
|
-
originalUri?: string;
|
|
199
|
-
/** Virtual URI for modified content (agent-diff://...) */
|
|
200
|
-
modifiedUri?: string;
|
|
201
209
|
}
|
|
202
210
|
//#endregion
|
|
203
211
|
//#region ../agent-client-protocol/lib/common/sdk.d.ts
|
|
@@ -577,6 +585,10 @@ type PromptContentBlock = {
|
|
|
577
585
|
type: 'image';
|
|
578
586
|
data: string;
|
|
579
587
|
mimeType: string;
|
|
588
|
+
uri?: string | null;
|
|
589
|
+
_meta?: {
|
|
590
|
+
[key: string]: unknown;
|
|
591
|
+
} | null | undefined;
|
|
580
592
|
} | {
|
|
581
593
|
type: 'resource';
|
|
582
594
|
uri: string;
|
|
@@ -813,65 +825,25 @@ declare enum ModelTrustLevel {
|
|
|
813
825
|
CERTIFIED = "certified"
|
|
814
826
|
}
|
|
815
827
|
//#endregion
|
|
816
|
-
//#region ../agent-provider/lib/common/
|
|
828
|
+
//#region ../agent-provider/lib/common/client/types.d.ts
|
|
817
829
|
/**
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
* Uses composition pattern - implements event emitter methods internally
|
|
830
|
+
* Session connection information
|
|
831
|
+
* 包含连接到Agent会话所需的所有信息,包括sandbox连接凭证
|
|
821
832
|
*/
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
836
|
-
off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
837
|
-
once<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
838
|
-
emit<K extends keyof ConnectionEvents>(event: K, data: ConnectionEvents[K]): boolean;
|
|
839
|
-
removeAllListeners<K extends keyof ConnectionEvents>(event?: K): this;
|
|
840
|
-
get state(): AgentStatus;
|
|
841
|
-
get isInitialized(): boolean;
|
|
842
|
-
get capabilities(): AgentCapabilities | undefined;
|
|
843
|
-
get initializeResult(): InitializeResponse | undefined;
|
|
844
|
-
connect(): Promise<InitializeResponse>;
|
|
845
|
-
disconnect(): Promise<void>;
|
|
846
|
-
createSession(params: CreateSessionParams): Promise<NewSessionResponse>;
|
|
847
|
-
loadSession(params: LoadSessionParams): Promise<LoadSessionResponse>;
|
|
848
|
-
setSessionMode(sessionId: string, modeId: string): Promise<SetSessionModeResponse>;
|
|
849
|
-
setSessionModel(sessionId: string, modelId: string): Promise<SetSessionModelResponse>;
|
|
850
|
-
prompt(sessionId: string, params: PromptParams): Promise<PromptResponse$1>;
|
|
851
|
-
promptStream(sessionId: string, params: PromptParams): AsyncIterable<SessionNotification>;
|
|
852
|
-
cancel(sessionId: string): Promise<void>;
|
|
853
|
-
resolvePermission(requestId: string, optionId: string): boolean;
|
|
854
|
-
rejectPermission(requestId: string, reason?: string): boolean;
|
|
855
|
-
getPendingPermissions(): Map<string, {
|
|
856
|
-
params: RequestPermissionRequest;
|
|
857
|
-
createdAt: number;
|
|
858
|
-
}>;
|
|
859
|
-
hasPendingPermissions(): boolean;
|
|
860
|
-
answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
|
|
861
|
-
cancelQuestion(toolCallId: string, reason?: string): boolean;
|
|
862
|
-
getPendingQuestions(): Map<string, {
|
|
863
|
-
request: QuestionRequest;
|
|
864
|
-
createdAt: number;
|
|
865
|
-
}>;
|
|
866
|
-
hasPendingQuestions(): boolean;
|
|
867
|
-
toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
|
|
868
|
-
success: boolean;
|
|
869
|
-
error?: string;
|
|
870
|
-
}>;
|
|
871
|
-
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
833
|
+
interface SessionConnectionInfo {
|
|
834
|
+
/** Session ID */
|
|
835
|
+
sessionId: string;
|
|
836
|
+
/** Agent ID */
|
|
837
|
+
agentId: string;
|
|
838
|
+
/** Session endpoint URL (Agent的WebSocket/HTTP端点) */
|
|
839
|
+
link: string;
|
|
840
|
+
/** Session token (JWT格式的认证令牌) */
|
|
841
|
+
token: string;
|
|
842
|
+
/** Sandbox ID (E2B沙箱的唯一标识) */
|
|
843
|
+
sandboxId: string;
|
|
844
|
+
/** Session expiration timestamp (unix timestamp) */
|
|
845
|
+
expireAt: number;
|
|
872
846
|
}
|
|
873
|
-
//#endregion
|
|
874
|
-
//#region ../agent-provider/lib/common/client/types.d.ts
|
|
875
847
|
/**
|
|
876
848
|
* Agent 来源类型
|
|
877
849
|
*/
|
|
@@ -1248,6 +1220,11 @@ interface ActiveSession {
|
|
|
1248
1220
|
readonly availableCommands: AvailableCommand[];
|
|
1249
1221
|
/** Whether the session is active */
|
|
1250
1222
|
readonly isActive: boolean;
|
|
1223
|
+
/**
|
|
1224
|
+
* Session connection information (only available for cloud sessions)
|
|
1225
|
+
* 会话连接信息,包括sandboxId、link、token等
|
|
1226
|
+
*/
|
|
1227
|
+
readonly connectionInfo?: SessionConnectionInfo;
|
|
1251
1228
|
/** Agent operations */
|
|
1252
1229
|
readonly agent: SessionAgentOperations;
|
|
1253
1230
|
/** Prompts resource */
|
|
@@ -1334,6 +1311,17 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
|
|
|
1334
1311
|
archive?(agentId: string): Promise<{
|
|
1335
1312
|
id: string;
|
|
1336
1313
|
}>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Rename an agent by ID (optional)
|
|
1316
|
+
* Used by CloudAgentProvider and LocalAgentProvider for renaming agents
|
|
1317
|
+
*
|
|
1318
|
+
* @param agentId - Agent ID to rename
|
|
1319
|
+
* @param title - New title for the agent
|
|
1320
|
+
* @returns Object containing the renamed agent ID
|
|
1321
|
+
*/
|
|
1322
|
+
rename?(agentId: string, title: string): Promise<{
|
|
1323
|
+
id: string;
|
|
1324
|
+
}>;
|
|
1337
1325
|
/** Filesystem provider (optional - some providers may not support filesystem operations) */
|
|
1338
1326
|
readonly filesystem?: FilesystemProvider;
|
|
1339
1327
|
/**
|
|
@@ -1372,6 +1360,20 @@ interface AgentProvider<C extends AgentConnection = AgentConnection> {
|
|
|
1372
1360
|
* @returns Response with folder paths and cancel status
|
|
1373
1361
|
*/
|
|
1374
1362
|
pickFolder?(params?: PickFolderParams): Promise<PickFolderResponse>;
|
|
1363
|
+
/**
|
|
1364
|
+
* Upload a file to cloud storage (optional)
|
|
1365
|
+
*
|
|
1366
|
+
* @param params - Upload parameters including file content
|
|
1367
|
+
* @returns Response with cloud URL after successful upload
|
|
1368
|
+
*/
|
|
1369
|
+
uploadFile?(params: UploadFileParams): Promise<UploadFileResponse>;
|
|
1370
|
+
/**
|
|
1371
|
+
* Search for files in the workspace (optional, used by LocalAgentProvider)
|
|
1372
|
+
*
|
|
1373
|
+
* @param params - Search parameters including options
|
|
1374
|
+
* @returns Response with search results
|
|
1375
|
+
*/
|
|
1376
|
+
searchFile?(params: SearchFileParams): Promise<SearchFileResponse>;
|
|
1375
1377
|
/**
|
|
1376
1378
|
* Register an event listener
|
|
1377
1379
|
* Provider implementations should forward events to the underlying transport
|
|
@@ -1435,6 +1437,15 @@ interface ClientSessionsResource {
|
|
|
1435
1437
|
archive(sessionId: string): Promise<{
|
|
1436
1438
|
id: string;
|
|
1437
1439
|
}>;
|
|
1440
|
+
/**
|
|
1441
|
+
* Rename a session/agent
|
|
1442
|
+
* @param sessionId - Session ID to rename
|
|
1443
|
+
* @param title - New title for the session
|
|
1444
|
+
* @returns Object containing the renamed session ID
|
|
1445
|
+
*/
|
|
1446
|
+
rename(sessionId: string, title: string): Promise<{
|
|
1447
|
+
id: string;
|
|
1448
|
+
}>;
|
|
1438
1449
|
/** Initialize a workspace for future sessions */
|
|
1439
1450
|
initializeWorkspace(params: InitializeWorkspaceParams): Promise<InitializeWorkspaceResponse>;
|
|
1440
1451
|
/** Models resource for getting available models */
|
|
@@ -1453,6 +1464,10 @@ interface ClientSessionsResource {
|
|
|
1453
1464
|
pickFile(params?: PickFileParams): Promise<PickFileResponse>;
|
|
1454
1465
|
/** Pick folders from folder dialog (for LocalAgentProvider) */
|
|
1455
1466
|
pickFolder(params?: PickFolderParams): Promise<PickFolderResponse>;
|
|
1467
|
+
/** Upload a file to cloud storage */
|
|
1468
|
+
uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
|
|
1469
|
+
/** Search for files in the workspace (for LocalAgentProvider) */
|
|
1470
|
+
searchFile(params: SearchFileParams): Promise<SearchFileResponse>;
|
|
1456
1471
|
}
|
|
1457
1472
|
/**
|
|
1458
1473
|
* Workspace information (aligned with FolderSelectResult)
|
|
@@ -1487,8 +1502,8 @@ interface PickFileParams {
|
|
|
1487
1502
|
* Response from picking files
|
|
1488
1503
|
*/
|
|
1489
1504
|
interface PickFileResponse {
|
|
1490
|
-
/** Selected
|
|
1491
|
-
readonly
|
|
1505
|
+
/** Selected files - File objects in browser, absolute path strings in IDE */
|
|
1506
|
+
readonly files: Array<File | string>;
|
|
1492
1507
|
/** Whether user cancelled the dialog */
|
|
1493
1508
|
readonly canceled: boolean;
|
|
1494
1509
|
/** Error message (if failed) */
|
|
@@ -1512,6 +1527,150 @@ interface PickFolderResponse {
|
|
|
1512
1527
|
/** Error message (if failed) */
|
|
1513
1528
|
readonly error?: string;
|
|
1514
1529
|
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Parameters for uploading files
|
|
1532
|
+
*/
|
|
1533
|
+
interface UploadFileParams {
|
|
1534
|
+
/** Files to upload - File objects in browser, absolute path strings in IDE */
|
|
1535
|
+
readonly files: Array<File | string>;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Response from uploading files
|
|
1539
|
+
*/
|
|
1540
|
+
interface UploadFileResponse {
|
|
1541
|
+
/** Whether upload was successful */
|
|
1542
|
+
readonly success: boolean;
|
|
1543
|
+
/** Cloud URLs corresponding to each uploaded file (same order as input files) */
|
|
1544
|
+
readonly urls?: string[];
|
|
1545
|
+
/** Error message (if upload failed) */
|
|
1546
|
+
readonly error?: string;
|
|
1547
|
+
}
|
|
1548
|
+
/**
|
|
1549
|
+
* Mention type for file/folder
|
|
1550
|
+
*/
|
|
1551
|
+
declare enum MentionType {
|
|
1552
|
+
file = "file",
|
|
1553
|
+
folder = "folder"
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Search options for file search
|
|
1557
|
+
*/
|
|
1558
|
+
interface SearchOptions {
|
|
1559
|
+
/** Search keyword */
|
|
1560
|
+
readonly search?: string;
|
|
1561
|
+
/** Number of results to return */
|
|
1562
|
+
readonly resultNum: number;
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* File search result
|
|
1566
|
+
*/
|
|
1567
|
+
interface SearchFileResult {
|
|
1568
|
+
/** Full path */
|
|
1569
|
+
path: string;
|
|
1570
|
+
/** Relative path */
|
|
1571
|
+
relativePath: string;
|
|
1572
|
+
/** File name */
|
|
1573
|
+
fileName?: string;
|
|
1574
|
+
/** Folder name */
|
|
1575
|
+
folderName?: string;
|
|
1576
|
+
/** Type (file or folder) */
|
|
1577
|
+
type: MentionType.file | MentionType.folder;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Parameters for searching files
|
|
1581
|
+
*/
|
|
1582
|
+
interface SearchFileParams {
|
|
1583
|
+
/** Search options */
|
|
1584
|
+
readonly options: SearchOptions;
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Response from searching files
|
|
1588
|
+
*/
|
|
1589
|
+
interface SearchFileResponse {
|
|
1590
|
+
/** Search results */
|
|
1591
|
+
readonly results: SearchFileResult[];
|
|
1592
|
+
/** Error message (if failed) */
|
|
1593
|
+
readonly error?: string;
|
|
1594
|
+
}
|
|
1595
|
+
//#endregion
|
|
1596
|
+
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-connection.d.ts
|
|
1597
|
+
/**
|
|
1598
|
+
* Cloud Agent Connection implementation
|
|
1599
|
+
* Uses Streamable HTTP transport to connect to cloud-hosted ACP agents
|
|
1600
|
+
* Uses composition pattern - implements event emitter methods internally
|
|
1601
|
+
*
|
|
1602
|
+
* TODO: Connection Lifecycle Responsibilities
|
|
1603
|
+
* CloudAgentProvider caches connections by endpoint link. This class needs to:
|
|
1604
|
+
* - Implement connection health checks (detect and handle connection failures/reconnection)
|
|
1605
|
+
* - Handle token expiration (refresh or re-authentication when tokens expire)
|
|
1606
|
+
* - Emit 'disconnected' event when connection becomes unhealthy so provider can clean up cache
|
|
1607
|
+
*/
|
|
1608
|
+
declare class CloudAgentConnection implements AgentConnection {
|
|
1609
|
+
private client;
|
|
1610
|
+
private listeners;
|
|
1611
|
+
private onceListeners;
|
|
1612
|
+
/**
|
|
1613
|
+
* Flag to suppress sessionUpdate event emission during streaming.
|
|
1614
|
+
* When true, onSessionUpdate callback won't emit to avoid duplicate messages with promptStream.
|
|
1615
|
+
*/
|
|
1616
|
+
private _isStreaming;
|
|
1617
|
+
/**
|
|
1618
|
+
* Session connection information (sandboxId, link, token, etc.)
|
|
1619
|
+
* Set by CloudAgentProvider.connect() after fetching session data from backend.
|
|
1620
|
+
*/
|
|
1621
|
+
private _sessionConnectionInfo?;
|
|
1622
|
+
readonly agentId: string;
|
|
1623
|
+
readonly transport: "cloud";
|
|
1624
|
+
constructor(agentId: string, config: CloudConnectionConfig);
|
|
1625
|
+
private setupEventForwarding;
|
|
1626
|
+
on<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
1627
|
+
off<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
1628
|
+
once<K extends keyof ConnectionEvents>(event: K, listener: ConnectionEventListener<ConnectionEvents[K]>): this;
|
|
1629
|
+
emit<K extends keyof ConnectionEvents>(event: K, data: ConnectionEvents[K]): boolean;
|
|
1630
|
+
removeAllListeners<K extends keyof ConnectionEvents>(event?: K): this;
|
|
1631
|
+
get state(): AgentStatus;
|
|
1632
|
+
get isInitialized(): boolean;
|
|
1633
|
+
get capabilities(): AgentCapabilities | undefined;
|
|
1634
|
+
get initializeResult(): InitializeResponse | undefined;
|
|
1635
|
+
connect(): Promise<InitializeResponse>;
|
|
1636
|
+
disconnect(): Promise<void>;
|
|
1637
|
+
createSession(params: CreateSessionParams): Promise<NewSessionResponse>;
|
|
1638
|
+
loadSession(params: LoadSessionParams): Promise<LoadSessionResponse>;
|
|
1639
|
+
setSessionMode(sessionId: string, modeId: string): Promise<SetSessionModeResponse>;
|
|
1640
|
+
setSessionModel(sessionId: string, modelId: string): Promise<SetSessionModelResponse>;
|
|
1641
|
+
prompt(sessionId: string, params: PromptParams): Promise<PromptResponse$1>;
|
|
1642
|
+
promptStream(sessionId: string, params: PromptParams): AsyncIterable<SessionNotification>;
|
|
1643
|
+
cancel(sessionId: string): Promise<void>;
|
|
1644
|
+
resolvePermission(requestId: string, optionId: string): boolean;
|
|
1645
|
+
rejectPermission(requestId: string, reason?: string): boolean;
|
|
1646
|
+
getPendingPermissions(): Map<string, {
|
|
1647
|
+
params: RequestPermissionRequest;
|
|
1648
|
+
createdAt: number;
|
|
1649
|
+
}>;
|
|
1650
|
+
hasPendingPermissions(): boolean;
|
|
1651
|
+
answerQuestion(toolCallId: string, answers: QuestionAnswers): boolean;
|
|
1652
|
+
cancelQuestion(toolCallId: string, reason?: string): boolean;
|
|
1653
|
+
getPendingQuestions(): Map<string, {
|
|
1654
|
+
request: QuestionRequest;
|
|
1655
|
+
createdAt: number;
|
|
1656
|
+
}>;
|
|
1657
|
+
hasPendingQuestions(): boolean;
|
|
1658
|
+
toolCallback(sessionId: string, toolCallId: string, toolName: string, action: 'skip' | 'cancel'): Promise<{
|
|
1659
|
+
success: boolean;
|
|
1660
|
+
error?: string;
|
|
1661
|
+
}>;
|
|
1662
|
+
/**
|
|
1663
|
+
* Set session connection information
|
|
1664
|
+
* Called by CloudAgentProvider.connect() after fetching session data from backend.
|
|
1665
|
+
*/
|
|
1666
|
+
setSessionConnectionInfo(info: SessionConnectionInfo): void;
|
|
1667
|
+
/**
|
|
1668
|
+
* Get session connection information
|
|
1669
|
+
* Contains sandboxId, link, token, etc.
|
|
1670
|
+
*/
|
|
1671
|
+
get sessionConnectionInfo(): SessionConnectionInfo | undefined;
|
|
1672
|
+
extMethod(method: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
1673
|
+
}
|
|
1515
1674
|
//#endregion
|
|
1516
1675
|
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/api-types.d.ts
|
|
1517
1676
|
/**
|
|
@@ -1522,6 +1681,14 @@ interface ArchiveAgentResponse {
|
|
|
1522
1681
|
/** Agent ID */
|
|
1523
1682
|
id: string;
|
|
1524
1683
|
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Response for rename agent
|
|
1686
|
+
* PATCH /v2/cloudagent/agentmgmt/agents/{id}
|
|
1687
|
+
*/
|
|
1688
|
+
interface RenameAgentResponse {
|
|
1689
|
+
/** Agent ID */
|
|
1690
|
+
id: string;
|
|
1691
|
+
}
|
|
1525
1692
|
//#endregion
|
|
1526
1693
|
//#region ../agent-provider/lib/common/providers/cloud-agent-provider/cloud-provider.d.ts
|
|
1527
1694
|
/**
|
|
@@ -1545,12 +1712,12 @@ interface CloudAgentProviderOptions {
|
|
|
1545
1712
|
* CloudAgentProvider - Manages cloud-hosted agents via REST API
|
|
1546
1713
|
*
|
|
1547
1714
|
* API Endpoints:
|
|
1548
|
-
* - POST {endpoint}/
|
|
1549
|
-
* - GET {endpoint}/
|
|
1550
|
-
* - GET {endpoint}/
|
|
1551
|
-
* - POST {endpoint}/
|
|
1552
|
-
* - GET {endpoint}/
|
|
1553
|
-
* - GET {endpoint}/
|
|
1715
|
+
* - POST {endpoint}/console/cloudagent/agentmgmt/agents - Create new agent
|
|
1716
|
+
* - GET {endpoint}/console/cloudagent/agentmgmt/agents/{id} - Get agent data
|
|
1717
|
+
* - GET {endpoint}/console/cloudagent/agentmgmt/agents - List all agents
|
|
1718
|
+
* - POST {endpoint}/console/cloudagent/agentmgmt/agents/{id}/delete - Delete agent
|
|
1719
|
+
* - GET {endpoint}/console/cloudagent/agentmgmt/agents/{id}/session - Get agent session (includes sandboxId)
|
|
1720
|
+
* - GET {endpoint}/console/cloudagent/agentmgmt/models - Get available models
|
|
1554
1721
|
*
|
|
1555
1722
|
* The provider stores agent endpoint configurations in the cloud backend.
|
|
1556
1723
|
* When connect() is called, it creates a CloudAgentConnection to the agent's
|
|
@@ -1616,6 +1783,8 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1616
1783
|
private fetchImpl;
|
|
1617
1784
|
/** Cache for filesystem instances (keyed by agentId) */
|
|
1618
1785
|
private filesystemCache;
|
|
1786
|
+
/** Cache for agent connections (keyed by endpoint link) */
|
|
1787
|
+
private connectionCache;
|
|
1619
1788
|
constructor(options: CloudAgentProviderOptions);
|
|
1620
1789
|
/**
|
|
1621
1790
|
* Get the filesystem provider (returns self)
|
|
@@ -1633,7 +1802,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1633
1802
|
/**
|
|
1634
1803
|
* Get sandbox information from backend
|
|
1635
1804
|
*
|
|
1636
|
-
* Uses GET {endpoint}/
|
|
1805
|
+
* Uses GET {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/session
|
|
1637
1806
|
* to retrieve sandbox information. Extracts sandboxId from the session response
|
|
1638
1807
|
* and constructs the apiUrl for E2B proxy.
|
|
1639
1808
|
*
|
|
@@ -1654,7 +1823,7 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1654
1823
|
list(options?: ListAgentOptions): Promise<ListAgentResult<CloudAgentState>>;
|
|
1655
1824
|
/**
|
|
1656
1825
|
* Create a new agent
|
|
1657
|
-
* POST {endpoint}/
|
|
1826
|
+
* POST {endpoint}/console/cloudagent/agentmgmt/agents
|
|
1658
1827
|
*/
|
|
1659
1828
|
create(): Promise<string>;
|
|
1660
1829
|
/**
|
|
@@ -1662,19 +1831,26 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1662
1831
|
*
|
|
1663
1832
|
* This method:
|
|
1664
1833
|
* 1. Fetches the agent configuration from the backend
|
|
1665
|
-
* 2.
|
|
1666
|
-
* 3.
|
|
1667
|
-
* 4.
|
|
1834
|
+
* 2. Checks if an existing connection can be reused (based on endpoint link)
|
|
1835
|
+
* 3. Creates a CloudAgentConnection to the agent's endpoint if not cached
|
|
1836
|
+
* 4. Saves session connection info to the connection
|
|
1837
|
+
* 5. Connects and initializes the connection
|
|
1838
|
+
* 6. Returns the connected CloudAgentConnection
|
|
1839
|
+
*
|
|
1840
|
+
* Connection caching:
|
|
1841
|
+
* - Connections are cached by endpoint link to enable reuse
|
|
1842
|
+
* - CloudAgentConnection is responsible for handling connection health checks
|
|
1843
|
+
* and token expiration internally
|
|
1668
1844
|
*/
|
|
1669
1845
|
connect(agentId: string): Promise<CloudAgentConnection>;
|
|
1670
1846
|
/**
|
|
1671
1847
|
* Delete an agent by ID
|
|
1672
|
-
* POST {endpoint}/
|
|
1848
|
+
* POST {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/delete
|
|
1673
1849
|
*/
|
|
1674
1850
|
delete(agentId: string): Promise<boolean>;
|
|
1675
1851
|
/**
|
|
1676
1852
|
* Archive an agent by ID
|
|
1677
|
-
* POST {endpoint}/
|
|
1853
|
+
* POST {endpoint}/console/cloudagent/agentmgmt/agents/{agentId}/archive
|
|
1678
1854
|
*
|
|
1679
1855
|
* @param agentId - Agent ID to archive
|
|
1680
1856
|
* @returns ArchiveAgentResponse containing the archived agent ID
|
|
@@ -1686,15 +1862,52 @@ declare class CloudAgentProvider implements AgentProvider<CloudAgentConnection>,
|
|
|
1686
1862
|
* ```
|
|
1687
1863
|
*/
|
|
1688
1864
|
archive(agentId: string): Promise<ArchiveAgentResponse>;
|
|
1865
|
+
/**
|
|
1866
|
+
* Rename an agent by ID
|
|
1867
|
+
* PATCH {endpoint}/v2/cloudagent/agentmgmt/agents/{agentId}
|
|
1868
|
+
*
|
|
1869
|
+
* @param agentId - Agent ID to rename
|
|
1870
|
+
* @param title - New title for the agent
|
|
1871
|
+
* @returns RenameAgentResponse containing the renamed agent ID
|
|
1872
|
+
*
|
|
1873
|
+
* @example
|
|
1874
|
+
* ```typescript
|
|
1875
|
+
* const result = await provider.rename('agent-123', 'New Title');
|
|
1876
|
+
* console.log('Renamed agent:', result.id);
|
|
1877
|
+
* ```
|
|
1878
|
+
*/
|
|
1879
|
+
rename(agentId: string, title: string): Promise<RenameAgentResponse>;
|
|
1689
1880
|
/**
|
|
1690
1881
|
* Get available models for a repository
|
|
1691
1882
|
*
|
|
1692
|
-
* GET {endpoint}/
|
|
1883
|
+
* GET {endpoint}/console/cloudagent/agentmgmt/models?repo={repo}
|
|
1693
1884
|
*
|
|
1694
1885
|
* @param repo - Repository identifier
|
|
1695
1886
|
* @returns Array of model names (backend only provides names, not full ModelInfo)
|
|
1696
1887
|
*/
|
|
1697
1888
|
getModels(repo: string): Promise<ModelInfo$1[]>;
|
|
1889
|
+
/**
|
|
1890
|
+
* Common image MIME types for filtering
|
|
1891
|
+
*/
|
|
1892
|
+
private static readonly IMAGE_MIME_TYPES;
|
|
1893
|
+
/**
|
|
1894
|
+
* Pick files using browser's native file input
|
|
1895
|
+
*
|
|
1896
|
+
* @param params - File picker parameters
|
|
1897
|
+
* @returns Response with selected file paths (filenames in browser)
|
|
1898
|
+
*/
|
|
1899
|
+
pickFile(params?: PickFileParams): Promise<PickFileResponse>;
|
|
1900
|
+
/**
|
|
1901
|
+
* Convert file extension to MIME type
|
|
1902
|
+
*/
|
|
1903
|
+
private extensionToMimeType;
|
|
1904
|
+
/**
|
|
1905
|
+
* Upload files to cloud storage
|
|
1906
|
+
*
|
|
1907
|
+
* @param params - files array (File objects in browser)
|
|
1908
|
+
* @returns Response with corresponding cloud URLs
|
|
1909
|
+
*/
|
|
1910
|
+
uploadFile(params: UploadFileParams): Promise<UploadFileResponse>;
|
|
1698
1911
|
private toAgentState;
|
|
1699
1912
|
private request;
|
|
1700
1913
|
}
|
|
@@ -1848,6 +2061,8 @@ interface ActiveSessionImplOptions {
|
|
|
1848
2061
|
logger?: Logger;
|
|
1849
2062
|
/** Getter function for filesystem resource (provided by SessionManager) */
|
|
1850
2063
|
getFilesystem?: FilesystemGetter;
|
|
2064
|
+
/** Session connection information (for cloud sessions) */
|
|
2065
|
+
connectionInfo?: SessionConnectionInfo;
|
|
1851
2066
|
}
|
|
1852
2067
|
/**
|
|
1853
2068
|
* ActiveSessionImpl - Implements the ActiveSession interface
|
|
@@ -1879,6 +2094,7 @@ declare class ActiveSessionImpl implements ActiveSession {
|
|
|
1879
2094
|
private logger?;
|
|
1880
2095
|
private connection;
|
|
1881
2096
|
private _getFilesystem?;
|
|
2097
|
+
private _connectionInfo?;
|
|
1882
2098
|
private listeners;
|
|
1883
2099
|
private onceListeners;
|
|
1884
2100
|
/**
|
|
@@ -1942,6 +2158,11 @@ declare class ActiveSessionImpl implements ActiveSession {
|
|
|
1942
2158
|
* Check if the session is active
|
|
1943
2159
|
*/
|
|
1944
2160
|
get isActive(): boolean;
|
|
2161
|
+
/**
|
|
2162
|
+
* Session connection information (only available for cloud sessions)
|
|
2163
|
+
* 会话连接信息,包括sandboxId、link、token等
|
|
2164
|
+
*/
|
|
2165
|
+
get connectionInfo(): SessionConnectionInfo | undefined;
|
|
1945
2166
|
/**
|
|
1946
2167
|
* Set session modes (called after create/load)
|
|
1947
2168
|
*/
|
|
@@ -2585,5 +2806,5 @@ declare class IPCBackendProvider implements IBackendProvider {
|
|
|
2585
2806
|
*/
|
|
2586
2807
|
declare function createIPCBackendProvider(config: IPCBackendProviderConfig): IPCBackendProvider;
|
|
2587
2808
|
//#endregion
|
|
2588
|
-
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, type GetModelsRequest, type GetModelsResponse, type IBackendProvider, IPCBackendProvider, type ListAgentFilter, type ListAgentOptions, type ListAgentSort, type Logger, type McpServerConfig, type ModelInfo, type PromptContentBlock, type PromptParams, type PromptsResource, type ReasoningConfig, type Session, type SessionAgentOperations, type SessionEventHandler, type SessionEvents, type SessionInfo, SessionManager, type SessionMode, type WatchOpts, type WriteEntry, createBackendProvider, createIPCBackendProvider, isCloudAgentState };
|
|
2809
|
+
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, type GetModelsRequest, type GetModelsResponse, type IBackendProvider, IPCBackendProvider, type ListAgentFilter, type ListAgentOptions, type ListAgentSort, type Logger, type McpServerConfig, type ModelInfo, type PromptContentBlock, type PromptParams, type PromptsResource, type ReasoningConfig, type Session, type SessionAgentOperations, type SessionConnectionInfo, type SessionEventHandler, type SessionEvents, type SessionInfo, SessionManager, type SessionMode, type WatchOpts, type WriteEntry, createBackendProvider, createIPCBackendProvider, isCloudAgentState };
|
|
2589
2810
|
//# sourceMappingURL=index.d.cts.map
|