@cloudbase/agent-tools 0.0.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/CHANGELOG.md +416 -0
- package/dist/agent_tool.d.ts +7 -0
- package/dist/agent_tool.d.ts.map +1 -0
- package/dist/agent_tool.js +16 -0
- package/dist/agent_tool.js.map +1 -0
- package/dist/bash/bash-tool.d.ts +61 -0
- package/dist/bash/bash-tool.d.ts.map +1 -0
- package/dist/bash/bash-tool.js +191 -0
- package/dist/bash/bash-tool.js.map +1 -0
- package/dist/bash/index.d.ts +7 -0
- package/dist/bash/index.d.ts.map +1 -0
- package/dist/bash/index.js +17 -0
- package/dist/bash/index.js.map +1 -0
- package/dist/bash/operator/base-operator.d.ts +44 -0
- package/dist/bash/operator/base-operator.d.ts.map +1 -0
- package/dist/bash/operator/base-operator.js +14 -0
- package/dist/bash/operator/base-operator.js.map +1 -0
- package/dist/bash/operator/local-operator.d.ts +15 -0
- package/dist/bash/operator/local-operator.d.ts.map +1 -0
- package/dist/bash/operator/local-operator.js +145 -0
- package/dist/bash/operator/local-operator.js.map +1 -0
- package/dist/bash/operator/sandbox-operator.d.ts +22 -0
- package/dist/bash/operator/sandbox-operator.d.ts.map +1 -0
- package/dist/bash/operator/sandbox-operator.js +112 -0
- package/dist/bash/operator/sandbox-operator.js.map +1 -0
- package/dist/bash/utils.d.ts +106 -0
- package/dist/bash/utils.d.ts.map +1 -0
- package/dist/bash/utils.js +197 -0
- package/dist/bash/utils.js.map +1 -0
- package/dist/browser/browser-instance-manager.d.ts +79 -0
- package/dist/browser/browser-instance-manager.d.ts.map +1 -0
- package/dist/browser/browser-instance-manager.js +242 -0
- package/dist/browser/browser-instance-manager.js.map +1 -0
- package/dist/browser/browser-tool-executor.d.ts +57 -0
- package/dist/browser/browser-tool-executor.d.ts.map +1 -0
- package/dist/browser/browser-tool-executor.js +205 -0
- package/dist/browser/browser-tool-executor.js.map +1 -0
- package/dist/browser/browser_client_unified.d.ts +52 -0
- package/dist/browser/browser_client_unified.d.ts.map +1 -0
- package/dist/browser/browser_client_unified.js +381 -0
- package/dist/browser/browser_client_unified.js.map +1 -0
- package/dist/browser/browser_tool_unified.d.ts +93 -0
- package/dist/browser/browser_tool_unified.d.ts.map +1 -0
- package/dist/browser/browser_tool_unified.js +181 -0
- package/dist/browser/browser_tool_unified.js.map +1 -0
- package/dist/browser/index.d.ts +7 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +19 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/sandbox-connector.d.ts +93 -0
- package/dist/browser/sandbox-connector.d.ts.map +1 -0
- package/dist/browser/sandbox-connector.js +272 -0
- package/dist/browser/sandbox-connector.js.map +1 -0
- package/dist/browser/types.d.ts +53 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +3 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/code_executers/base_code_executor.d.ts +17 -0
- package/dist/code_executers/base_code_executor.d.ts.map +1 -0
- package/dist/code_executers/base_code_executor.js +20 -0
- package/dist/code_executers/base_code_executor.js.map +1 -0
- package/dist/code_executers/built_in_code_executor.d.ts +25 -0
- package/dist/code_executers/built_in_code_executor.d.ts.map +1 -0
- package/dist/code_executers/built_in_code_executor.js +106 -0
- package/dist/code_executers/built_in_code_executor.js.map +1 -0
- package/dist/code_executers/unsafe_local_code_executor.d.ts +118 -0
- package/dist/code_executers/unsafe_local_code_executor.d.ts.map +1 -0
- package/dist/code_executers/unsafe_local_code_executor.js +605 -0
- package/dist/code_executers/unsafe_local_code_executor.js.map +1 -0
- package/dist/fs/edit-tool.d.ts +26 -0
- package/dist/fs/edit-tool.d.ts.map +1 -0
- package/dist/fs/edit-tool.js +202 -0
- package/dist/fs/edit-tool.js.map +1 -0
- package/dist/fs/glob-tool.d.ts +31 -0
- package/dist/fs/glob-tool.d.ts.map +1 -0
- package/dist/fs/glob-tool.js +287 -0
- package/dist/fs/glob-tool.js.map +1 -0
- package/dist/fs/grep-tool.d.ts +32 -0
- package/dist/fs/grep-tool.d.ts.map +1 -0
- package/dist/fs/grep-tool.js +353 -0
- package/dist/fs/grep-tool.js.map +1 -0
- package/dist/fs/index.d.ts +11 -0
- package/dist/fs/index.d.ts.map +1 -0
- package/dist/fs/index.js +38 -0
- package/dist/fs/index.js.map +1 -0
- package/dist/fs/ls-tool.d.ts +26 -0
- package/dist/fs/ls-tool.d.ts.map +1 -0
- package/dist/fs/ls-tool.js +235 -0
- package/dist/fs/ls-tool.js.map +1 -0
- package/dist/fs/multiedit-tool.d.ts +34 -0
- package/dist/fs/multiedit-tool.d.ts.map +1 -0
- package/dist/fs/multiedit-tool.js +158 -0
- package/dist/fs/multiedit-tool.js.map +1 -0
- package/dist/fs/operator/base-operator.d.ts +28 -0
- package/dist/fs/operator/base-operator.d.ts.map +1 -0
- package/dist/fs/operator/base-operator.js +21 -0
- package/dist/fs/operator/base-operator.js.map +1 -0
- package/dist/fs/operator/in-memory-operator.d.ts +39 -0
- package/dist/fs/operator/in-memory-operator.d.ts.map +1 -0
- package/dist/fs/operator/in-memory-operator.js +115 -0
- package/dist/fs/operator/in-memory-operator.js.map +1 -0
- package/dist/fs/operator/index.d.ts +6 -0
- package/dist/fs/operator/index.d.ts.map +1 -0
- package/dist/fs/operator/index.js +28 -0
- package/dist/fs/operator/index.js.map +1 -0
- package/dist/fs/operator/local-operator.d.ts +25 -0
- package/dist/fs/operator/local-operator.d.ts.map +1 -0
- package/dist/fs/operator/local-operator.js +62 -0
- package/dist/fs/operator/local-operator.js.map +1 -0
- package/dist/fs/operator/sanbox-operator.d.ts +31 -0
- package/dist/fs/operator/sanbox-operator.d.ts.map +1 -0
- package/dist/fs/operator/sanbox-operator.js +172 -0
- package/dist/fs/operator/sanbox-operator.js.map +1 -0
- package/dist/fs/operator/transaction/index.d.ts +6 -0
- package/dist/fs/operator/transaction/index.d.ts.map +1 -0
- package/dist/fs/operator/transaction/index.js +28 -0
- package/dist/fs/operator/transaction/index.js.map +1 -0
- package/dist/fs/operator/transaction/snapshot-strategies.d.ts +54 -0
- package/dist/fs/operator/transaction/snapshot-strategies.d.ts.map +1 -0
- package/dist/fs/operator/transaction/snapshot-strategies.js +278 -0
- package/dist/fs/operator/transaction/snapshot-strategies.js.map +1 -0
- package/dist/fs/operator/transaction/transaction-operator.d.ts +53 -0
- package/dist/fs/operator/transaction/transaction-operator.d.ts.map +1 -0
- package/dist/fs/operator/transaction/transaction-operator.js +195 -0
- package/dist/fs/operator/transaction/transaction-operator.js.map +1 -0
- package/dist/fs/operator/transaction/transaction-utils.d.ts +80 -0
- package/dist/fs/operator/transaction/transaction-utils.d.ts.map +1 -0
- package/dist/fs/operator/transaction/transaction-utils.js +156 -0
- package/dist/fs/operator/transaction/transaction-utils.js.map +1 -0
- package/dist/fs/read-tool.d.ts +32 -0
- package/dist/fs/read-tool.d.ts.map +1 -0
- package/dist/fs/read-tool.js +271 -0
- package/dist/fs/read-tool.js.map +1 -0
- package/dist/fs/str-replace-editor.d.ts +23 -0
- package/dist/fs/str-replace-editor.d.ts.map +1 -0
- package/dist/fs/str-replace-editor.js +74 -0
- package/dist/fs/str-replace-editor.js.map +1 -0
- package/dist/fs/toolkit.d.ts +61 -0
- package/dist/fs/toolkit.d.ts.map +1 -0
- package/dist/fs/toolkit.js +113 -0
- package/dist/fs/toolkit.js.map +1 -0
- package/dist/fs/utils.d.ts +32 -0
- package/dist/fs/utils.d.ts.map +1 -0
- package/dist/fs/utils.js +133 -0
- package/dist/fs/utils.js.map +1 -0
- package/dist/fs/write-tool.d.ts +26 -0
- package/dist/fs/write-tool.d.ts.map +1 -0
- package/dist/fs/write-tool.js +110 -0
- package/dist/fs/write-tool.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/agkit-mcp-server.d.ts +291 -0
- package/dist/mcp/agkit-mcp-server.d.ts.map +1 -0
- package/dist/mcp/agkit-mcp-server.js +821 -0
- package/dist/mcp/agkit-mcp-server.js.map +1 -0
- package/dist/mcp/client-tool.d.ts +65 -0
- package/dist/mcp/client-tool.d.ts.map +1 -0
- package/dist/mcp/client-tool.js +220 -0
- package/dist/mcp/client-tool.js.map +1 -0
- package/dist/mcp/index.d.ts +14 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +26 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-client-manager.d.ts +153 -0
- package/dist/mcp/mcp-client-manager.d.ts.map +1 -0
- package/dist/mcp/mcp-client-manager.js +606 -0
- package/dist/mcp/mcp-client-manager.js.map +1 -0
- package/dist/mcp/mcp-toolkit.d.ts +112 -0
- package/dist/mcp/mcp-toolkit.d.ts.map +1 -0
- package/dist/mcp/mcp-toolkit.js +188 -0
- package/dist/mcp/mcp-toolkit.js.map +1 -0
- package/dist/mcp/types.d.ts +157 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +34 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/mcp/utils.d.ts +17 -0
- package/dist/mcp/utils.d.ts.map +1 -0
- package/dist/mcp/utils.js +48 -0
- package/dist/mcp/utils.js.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/zod.d.ts +18 -0
- package/dist/types/zod.d.ts.map +1 -0
- package/dist/types/zod.js +3 -0
- package/dist/types/zod.js.map +1 -0
- package/dist/utils.d.ts +141 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +379 -0
- package/dist/utils.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxConnector = void 0;
|
|
4
|
+
const code_interpreter_1 = require("@e2b/code-interpreter");
|
|
5
|
+
const playwright_1 = require("playwright");
|
|
6
|
+
const events_1 = require("events");
|
|
7
|
+
/**
|
|
8
|
+
* SandboxConnector manages the direct connection between E2B Sandbox and Playwright
|
|
9
|
+
* Replaces the subprocess-based MCP server approach with direct CDP connection
|
|
10
|
+
*/
|
|
11
|
+
class SandboxConnector extends events_1.EventEmitter {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
super();
|
|
14
|
+
this.pages = [];
|
|
15
|
+
this.isConnected = false;
|
|
16
|
+
this.config = config;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Initialize the sandbox and establish CDP connection
|
|
20
|
+
*/
|
|
21
|
+
async connect() {
|
|
22
|
+
if (this.isConnected) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
// Create E2B browser sandbox with minimum timeout
|
|
27
|
+
this.sandbox = await code_interpreter_1.Sandbox.create("browser-v1", {
|
|
28
|
+
timeoutMs: Math.max((this.config.timeout || 300) * 1000, 5 * 60 * 1000), // 最少5分钟
|
|
29
|
+
apiKey: this.config.apiKey,
|
|
30
|
+
domain: this.config.domain,
|
|
31
|
+
});
|
|
32
|
+
// this.sandbox = await Sandbox.connect('63d61b6f165e476cb4d8908db2a5b3ef')
|
|
33
|
+
// Get access token from sandbox - use correct property name
|
|
34
|
+
const accessToken = this.sandbox.envdAccessToken ||
|
|
35
|
+
this.sandbox._envd_access_token ||
|
|
36
|
+
this.sandbox.accessToken ||
|
|
37
|
+
this.sandbox.envd_access_token ||
|
|
38
|
+
"";
|
|
39
|
+
console.log(`Access token found: ${accessToken ? "yes" : "no"}`);
|
|
40
|
+
if (accessToken) {
|
|
41
|
+
console.log(`Access token length: ${accessToken.length}`);
|
|
42
|
+
}
|
|
43
|
+
// Extract connection information
|
|
44
|
+
const vncUrl = `https://${this.sandbox.getHost(9000)}/novnc/vnc_lite.html?&path=websockify?access_token=${accessToken}`;
|
|
45
|
+
const cdpUrl = `https://${this.sandbox.getHost(9000)}/cdp`;
|
|
46
|
+
this.connectionInfo = {
|
|
47
|
+
sandboxId: this.sandbox.sandboxId,
|
|
48
|
+
vncUrl: vncUrl,
|
|
49
|
+
cdpUrl: cdpUrl,
|
|
50
|
+
accessToken: accessToken,
|
|
51
|
+
};
|
|
52
|
+
// Connect to browser via CDP using Playwright
|
|
53
|
+
await this.connectToBrowser();
|
|
54
|
+
this.isConnected = true;
|
|
55
|
+
this.emit("connected", this.connectionInfo);
|
|
56
|
+
console.log(`✅ Sandbox connector initialized: ${this.sandbox.sandboxId}`);
|
|
57
|
+
console.log(`CDP URL: ${this.connectionInfo.cdpUrl}`);
|
|
58
|
+
console.log(`VNC URL: ${this.connectionInfo.vncUrl}`);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error("Failed to initialize sandbox connector:", error);
|
|
62
|
+
this.emit("error", error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Establish direct CDP connection to sandbox browser
|
|
68
|
+
*/
|
|
69
|
+
async connectToBrowser() {
|
|
70
|
+
if (!this.sandbox || !this.connectionInfo) {
|
|
71
|
+
throw new Error("Sandbox not initialized");
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
// Try to connect without access token first
|
|
75
|
+
console.log(`Attempting CDP connection to: ${this.connectionInfo.cdpUrl}`);
|
|
76
|
+
let connectionOptions = {};
|
|
77
|
+
// If we have an access token, try different authentication methods
|
|
78
|
+
if (this.connectionInfo.accessToken) {
|
|
79
|
+
// Try different header formats that E2B might accept
|
|
80
|
+
connectionOptions.headers = {
|
|
81
|
+
Authorization: `Bearer ${this.connectionInfo.accessToken}`,
|
|
82
|
+
"X-Access-Token": this.connectionInfo.accessToken,
|
|
83
|
+
access_token: this.connectionInfo.accessToken,
|
|
84
|
+
};
|
|
85
|
+
console.log("Using access token for CDP connection with multiple auth headers");
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.log("No access token found, attempting connection without authentication");
|
|
89
|
+
}
|
|
90
|
+
// Connect to browser via CDP
|
|
91
|
+
this.browser = await playwright_1.chromium.connectOverCDP(this.connectionInfo.cdpUrl, connectionOptions);
|
|
92
|
+
// Get or create default context
|
|
93
|
+
this.context = this.browser.contexts()[0];
|
|
94
|
+
if (!this.context) {
|
|
95
|
+
this.context = await this.browser.newContext();
|
|
96
|
+
}
|
|
97
|
+
// Ensure at least one page exists
|
|
98
|
+
this.pages = this.context.pages();
|
|
99
|
+
if (this.pages.length === 0) {
|
|
100
|
+
const page = await this.context.newPage();
|
|
101
|
+
this.pages.push(page);
|
|
102
|
+
}
|
|
103
|
+
console.log(`✅ Connected to browser via CDP with ${this.pages.length} pages`);
|
|
104
|
+
this.emit("browser-connected", this.browser);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.error("Failed to connect to browser via CDP:", error);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get Playwright Browser instance
|
|
113
|
+
*/
|
|
114
|
+
getBrowser() {
|
|
115
|
+
if (!this.browser) {
|
|
116
|
+
throw new Error("Browser not connected");
|
|
117
|
+
}
|
|
118
|
+
return this.browser;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get Playwright BrowserContext instance
|
|
122
|
+
*/
|
|
123
|
+
getContext() {
|
|
124
|
+
if (!this.context) {
|
|
125
|
+
throw new Error("Browser context not available");
|
|
126
|
+
}
|
|
127
|
+
return this.context;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get Playwright Page instance by index
|
|
131
|
+
*/
|
|
132
|
+
getPage(index = 0) {
|
|
133
|
+
if (!this.pages || index >= this.pages.length) {
|
|
134
|
+
throw new Error(`Page index ${index} out of range. Available pages: ${this.pages?.length || 0}`);
|
|
135
|
+
}
|
|
136
|
+
return this.pages[index];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get all Playwright Page instances
|
|
140
|
+
*/
|
|
141
|
+
getPages() {
|
|
142
|
+
return this.pages || [];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create new Playwright Page
|
|
146
|
+
*/
|
|
147
|
+
async createPage() {
|
|
148
|
+
if (!this.context) {
|
|
149
|
+
throw new Error("Browser context not available");
|
|
150
|
+
}
|
|
151
|
+
const page = await this.context.newPage();
|
|
152
|
+
this.pages.push(page);
|
|
153
|
+
this.emit("page-created", page);
|
|
154
|
+
return page;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Close Playwright Page by index
|
|
158
|
+
*/
|
|
159
|
+
async closePage(index) {
|
|
160
|
+
if (index >= this.pages.length) {
|
|
161
|
+
throw new Error(`Page index ${index} out of range`);
|
|
162
|
+
}
|
|
163
|
+
const page = this.pages[index];
|
|
164
|
+
await page.close();
|
|
165
|
+
this.pages.splice(index, 1);
|
|
166
|
+
this.emit("page-closed", index);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get connection status
|
|
170
|
+
*/
|
|
171
|
+
isReady() {
|
|
172
|
+
return this.isConnected && !!this.browser && !!this.context;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get connection information
|
|
176
|
+
*/
|
|
177
|
+
getConnectionInfo() {
|
|
178
|
+
return this.connectionInfo;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get VNC URL for visual debugging
|
|
182
|
+
*/
|
|
183
|
+
getVncUrl() {
|
|
184
|
+
if (!this.sandbox || !this.connectionInfo) {
|
|
185
|
+
throw new Error("Sandbox not initialized");
|
|
186
|
+
}
|
|
187
|
+
return `https://${this.sandbox.getHost(9000)}/novnc/vnc_lite.html?path=websockify&access_token=${this.connectionInfo.accessToken}`;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get CDP URL for direct connection
|
|
191
|
+
*/
|
|
192
|
+
getCdpUrl() {
|
|
193
|
+
if (!this.sandbox) {
|
|
194
|
+
throw new Error("Sandbox not initialized");
|
|
195
|
+
}
|
|
196
|
+
return `https://${this.sandbox.getHost(9000)}/cdp`;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get sandbox ID
|
|
200
|
+
*/
|
|
201
|
+
getSandboxId() {
|
|
202
|
+
return this.sandbox?.sandboxId;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Reconnect to sandbox if connection is lost
|
|
206
|
+
*/
|
|
207
|
+
async reconnect() {
|
|
208
|
+
console.log("Attempting to reconnect to sandbox...");
|
|
209
|
+
try {
|
|
210
|
+
// Close existing connections
|
|
211
|
+
await this.disconnect(false);
|
|
212
|
+
// Re-establish connection
|
|
213
|
+
await this.connect();
|
|
214
|
+
console.log("✅ Successfully reconnected to sandbox");
|
|
215
|
+
this.emit("reconnected");
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
console.error("Failed to reconnect to sandbox:", error);
|
|
219
|
+
this.emit("reconnect-failed", error);
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Disconnect and clean up resources
|
|
225
|
+
*/
|
|
226
|
+
async disconnect(killSandbox = true) {
|
|
227
|
+
try {
|
|
228
|
+
// Close browser connection
|
|
229
|
+
if (this.browser) {
|
|
230
|
+
await this.browser.close();
|
|
231
|
+
this.browser = undefined;
|
|
232
|
+
}
|
|
233
|
+
// Reset context and pages
|
|
234
|
+
this.context = undefined;
|
|
235
|
+
this.pages = [];
|
|
236
|
+
// Kill sandbox if requested
|
|
237
|
+
if (killSandbox && this.sandbox) {
|
|
238
|
+
await this.sandbox.kill();
|
|
239
|
+
this.sandbox = undefined;
|
|
240
|
+
}
|
|
241
|
+
this.isConnected = false;
|
|
242
|
+
this.connectionInfo = undefined;
|
|
243
|
+
console.log("✅ Sandbox connector disconnected");
|
|
244
|
+
this.emit("disconnected");
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.error("Error disconnecting sandbox connector:", error);
|
|
248
|
+
this.emit("error", error);
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Health check for the connection
|
|
254
|
+
*/
|
|
255
|
+
async healthCheck() {
|
|
256
|
+
try {
|
|
257
|
+
if (!this.isReady()) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
// Test browser connection by getting version
|
|
261
|
+
const version = await this.browser.version();
|
|
262
|
+
console.log(`Browser health check passed: ${version}`);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
console.error("Health check failed:", error);
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
exports.SandboxConnector = SandboxConnector;
|
|
272
|
+
//# sourceMappingURL=sandbox-connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-connector.js","sourceRoot":"","sources":["../../src/browser/sandbox-connector.ts"],"names":[],"mappings":";;;AAAA,4DAAgD;AAChD,2CAAqE;AACrE,mCAAsC;AAgBtC;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,qBAAY;IAShD,YAAY,MAA8B;QACxC,KAAK,EAAE,CAAC;QALF,UAAK,GAAW,EAAE,CAAC;QACnB,gBAAW,GAAG,KAAK,CAAC;QAK1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,kDAAkD;YAClD,IAAI,CAAC,OAAO,GAAG,MAAM,0BAAO,CAAC,MAAM,CAAC,YAAY,EAAE;gBAChD,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,GAAG,CAAC,GAAG,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AAK,CAAC;YACf,CAAC;YAED,6CAA6C;YAC7C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAQ,CAAC,OAAO,EAAE,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,gCAAgC,OAAO,EAAE,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;YAC7C,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AA5TD,4CA4TC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type BrowserActionType = "navigate" | "click" | "type" | "screenshot" | "get_text" | "get_html" | "wait_for_element" | "scroll" | "upload_file" | "download_file" | "evaluate_js" | "get_page_info" | "close_page" | "new_page";
|
|
2
|
+
export interface BrowserAction {
|
|
3
|
+
type: BrowserActionType;
|
|
4
|
+
url?: string;
|
|
5
|
+
selector?: string;
|
|
6
|
+
text?: string;
|
|
7
|
+
filePath?: string;
|
|
8
|
+
javascript?: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
waitForNetworkIdle?: boolean;
|
|
11
|
+
pageIndex?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface BrowserActionResult {
|
|
14
|
+
success: boolean;
|
|
15
|
+
data?: {
|
|
16
|
+
screenshot?: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
html?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
result?: any;
|
|
22
|
+
selector?: string;
|
|
23
|
+
filePath?: string;
|
|
24
|
+
filename?: string;
|
|
25
|
+
pageInfo?: {
|
|
26
|
+
url: string;
|
|
27
|
+
title: string;
|
|
28
|
+
viewport: {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
pageIndex?: number;
|
|
34
|
+
remainingPages?: number;
|
|
35
|
+
};
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface BrowserSession {
|
|
39
|
+
sessionId: string;
|
|
40
|
+
sandboxId: string;
|
|
41
|
+
vncUrl: string;
|
|
42
|
+
cdpUrl: string;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
lastUsed: Date;
|
|
45
|
+
}
|
|
46
|
+
export interface BrowserToolConfig {
|
|
47
|
+
apiKey?: string;
|
|
48
|
+
domain?: string;
|
|
49
|
+
defaultTimeout?: number;
|
|
50
|
+
maxSessions?: number;
|
|
51
|
+
sessionTtl?: number;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/browser/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,OAAO,GACP,MAAM,GACN,YAAY,GACZ,UAAU,GACV,UAAU,GACV,kBAAkB,GAClB,QAAQ,GACR,aAAa,GACb,eAAe,GACf,aAAa,GACb,eAAe,GACf,YAAY,GACZ,UAAU,CAAC;AAEf,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE;QACL,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE;YACT,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,QAAQ,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,MAAM,EAAE,MAAM,CAAA;aAAE,CAAC;SAC7C,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/browser/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseTool } from "../utils";
|
|
2
|
+
import { ToolExecutionContext } from "../types";
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
|
+
export interface ICodeExecutorInput {
|
|
5
|
+
code: string;
|
|
6
|
+
language?: "python" | "js" | "ts" | "java" | "r" | "bash";
|
|
7
|
+
}
|
|
8
|
+
declare const codeExecutorSchema: z.ZodObject<{
|
|
9
|
+
code: z.ZodString;
|
|
10
|
+
language: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare abstract class BaseCodeExecutor extends BaseTool<typeof codeExecutorSchema> {
|
|
13
|
+
constructor();
|
|
14
|
+
abstract _invoke(input: z.infer<typeof codeExecutorSchema>, context?: ToolExecutionContext): Promise<any>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=base_code_executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_code_executor.d.ts","sourceRoot":"","sources":["../../src/code_executers/base_code_executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;CAC3D;AAED,QAAA,MAAM,kBAAkB;;;iBAGtB,CAAC;AAEH,8BAAsB,gBAAiB,SAAQ,QAAQ,CACrD,OAAO,kBAAkB,CAC1B;;IASC,QAAQ,CAAC,OAAO,CACd,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,EACzC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,GAAG,CAAC;CAChB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCodeExecutor = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const v4_1 = require("zod/v4");
|
|
6
|
+
const codeExecutorSchema = v4_1.z.object({
|
|
7
|
+
code: v4_1.z.string().describe("code to execute"),
|
|
8
|
+
language: v4_1.z.string().optional().describe("programming language"),
|
|
9
|
+
});
|
|
10
|
+
class BaseCodeExecutor extends utils_1.BaseTool {
|
|
11
|
+
constructor() {
|
|
12
|
+
super({
|
|
13
|
+
name: "CodeExecutor",
|
|
14
|
+
description: "Executes code snippets",
|
|
15
|
+
schema: codeExecutorSchema,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BaseCodeExecutor = BaseCodeExecutor;
|
|
20
|
+
//# sourceMappingURL=base_code_executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_code_executor.js","sourceRoot":"","sources":["../../src/code_executers/base_code_executor.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AAEpC,+BAA2B;AAO3B,MAAM,kBAAkB,GAAG,MAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IAC5C,QAAQ,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;CACjE,CAAC,CAAC;AAEH,MAAsB,gBAAiB,SAAQ,gBAE9C;IACC;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,cAAc;YACpB,WAAW,EAAE,wBAAwB;YACrC,MAAM,EAAE,kBAAkB;SAC3B,CAAC,CAAC;IACL,CAAC;CAMF;AAfD,4CAeC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Sandbox, Execution, RunCodeOpts } from "@e2b/code-interpreter";
|
|
2
|
+
import { BaseCodeExecutor, ICodeExecutorInput } from "./base_code_executor";
|
|
3
|
+
export declare class BuiltInCodeExecutor extends BaseCodeExecutor {
|
|
4
|
+
sandbox: Sandbox;
|
|
5
|
+
private options;
|
|
6
|
+
private apiKey;
|
|
7
|
+
private domain;
|
|
8
|
+
constructor(fields?: {
|
|
9
|
+
sandbox?: Sandbox;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
domain?: string;
|
|
12
|
+
}, options?: RunCodeOpts);
|
|
13
|
+
private ensureSandbox;
|
|
14
|
+
/**
|
|
15
|
+
* 自定义实现 createCodeContext 方法
|
|
16
|
+
* 参考 E2B sandbox.createCodeContext 的源码实现
|
|
17
|
+
*/
|
|
18
|
+
private createCodeContext;
|
|
19
|
+
/**
|
|
20
|
+
* 创建超时信号
|
|
21
|
+
*/
|
|
22
|
+
private createTimeoutSignal;
|
|
23
|
+
_invoke(input: ICodeExecutorInput): Promise<Execution>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=built_in_code_executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built_in_code_executor.d.ts","sourceRoot":"","sources":["../../src/code_executers/built_in_code_executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAW,MAAM,uBAAuB,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAc5E,qBAAa,mBAAoB,SAAQ,gBAAgB;IAChD,OAAO,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,WAAW;YAwBrF,aAAa;IAe3B;;;OAGG;YACW,iBAAiB;IA8C/B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQrB,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;CAe7D"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuiltInCodeExecutor = void 0;
|
|
4
|
+
const code_interpreter_1 = require("@e2b/code-interpreter");
|
|
5
|
+
const base_code_executor_1 = require("./base_code_executor");
|
|
6
|
+
class BuiltInCodeExecutor extends base_code_executor_1.BaseCodeExecutor {
|
|
7
|
+
constructor(fields, options) {
|
|
8
|
+
super();
|
|
9
|
+
this.sandbox = fields?.sandbox;
|
|
10
|
+
this.options = options || {};
|
|
11
|
+
// 如果没有传入 sandbox,则校验 apiKey 和 domain 参数
|
|
12
|
+
if (!this.sandbox) {
|
|
13
|
+
this.apiKey = fields?.apiKey || process.env.AG_KIT_SANDBOX_API_KEY || process.env.E2B_API_KEY;
|
|
14
|
+
this.domain = fields?.domain || process.env.AG_KIT_SANDBOX_DOMAIN || process.env.E2B_DOMAIN;
|
|
15
|
+
if (!this.apiKey) {
|
|
16
|
+
throw new Error('API key is required. Please provide it via constructor parameter, AG_KIT_SANDBOX_API_KEY, or E2B_API_KEY environment variable.');
|
|
17
|
+
}
|
|
18
|
+
if (!this.domain) {
|
|
19
|
+
throw new Error('Domain is required. Please provide it via constructor parameter, AG_KIT_SANDBOX_DOMAIN, or E2B_DOMAIN environment variable.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async ensureSandbox() {
|
|
24
|
+
if (!this.sandbox) {
|
|
25
|
+
this.sandbox = await code_interpreter_1.Sandbox.create("code-interpreter-v1", {
|
|
26
|
+
apiKey: this.apiKey,
|
|
27
|
+
domain: this.domain,
|
|
28
|
+
timeoutMs: 3600 * 1000,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/* else if (!(await this.sandbox.isRunning())) {
|
|
32
|
+
this.sandbox.sandboxId
|
|
33
|
+
this.sandbox = await Sandbox.create();
|
|
34
|
+
}*/
|
|
35
|
+
return this.sandbox;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 自定义实现 createCodeContext 方法
|
|
39
|
+
* 参考 E2B sandbox.createCodeContext 的源码实现
|
|
40
|
+
*/
|
|
41
|
+
async createCodeContext(opts) {
|
|
42
|
+
try {
|
|
43
|
+
// 获取 sandbox 的内部属性(这里需要根据实际的 E2B SDK 结构调整)
|
|
44
|
+
const sandbox = await this.ensureSandbox();
|
|
45
|
+
// 构建请求 URL - 需要根据实际的 E2B SDK 获取正确的 jupyterUrl 和 envdAccessToken
|
|
46
|
+
const jupyterUrl = sandbox.jupyterUrl || `https://${this.domain}/jupyter`;
|
|
47
|
+
const envdAccessToken = sandbox.envdAccessToken || sandbox.accessToken;
|
|
48
|
+
const res = await fetch(`${jupyterUrl}/contexts`, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
headers: {
|
|
51
|
+
"Content-Type": "application/json",
|
|
52
|
+
"X-Access-Token": envdAccessToken,
|
|
53
|
+
// 添加其他可能需要的 headers
|
|
54
|
+
...sandbox.connectionConfig?.headers,
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify({
|
|
57
|
+
language: opts?.language,
|
|
58
|
+
cwd: opts?.cwd
|
|
59
|
+
}),
|
|
60
|
+
keepalive: true,
|
|
61
|
+
signal: this.createTimeoutSignal(opts?.requestTimeoutMs)
|
|
62
|
+
});
|
|
63
|
+
if (!res.ok) {
|
|
64
|
+
const errorText = await res.text();
|
|
65
|
+
throw new Error(`Failed to create code context: ${res.status} ${res.statusText} - ${errorText}`);
|
|
66
|
+
}
|
|
67
|
+
const contextResponse = await res.json();
|
|
68
|
+
// 转换为 E2B Context 格式
|
|
69
|
+
return {
|
|
70
|
+
id: contextResponse.id,
|
|
71
|
+
language: contextResponse.language,
|
|
72
|
+
cwd: contextResponse.cwd || process.cwd(), // 提供默认值以满足 Context 类型要求
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error.name === 'AbortError') {
|
|
77
|
+
throw new Error(`Request timeout: Failed to create code context within ${opts?.requestTimeoutMs || 30000}ms`);
|
|
78
|
+
}
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 创建超时信号
|
|
84
|
+
*/
|
|
85
|
+
createTimeoutSignal(timeoutMs) {
|
|
86
|
+
if (!timeoutMs)
|
|
87
|
+
return undefined;
|
|
88
|
+
const controller = new AbortController();
|
|
89
|
+
setTimeout(() => controller.abort(), timeoutMs);
|
|
90
|
+
return controller.signal;
|
|
91
|
+
}
|
|
92
|
+
async _invoke(input) {
|
|
93
|
+
let sandbox = await this.ensureSandbox();
|
|
94
|
+
// 使用自定义的 createCodeContext 方法
|
|
95
|
+
const context = await this.createCodeContext({
|
|
96
|
+
language: input.language || "python",
|
|
97
|
+
});
|
|
98
|
+
const res = await sandbox.runCode(input.code, {
|
|
99
|
+
...this.options,
|
|
100
|
+
context: context,
|
|
101
|
+
});
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.BuiltInCodeExecutor = BuiltInCodeExecutor;
|
|
106
|
+
//# sourceMappingURL=built_in_code_executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built_in_code_executor.js","sourceRoot":"","sources":["../../src/code_executers/built_in_code_executor.ts"],"names":[],"mappings":";;;AAAA,4DAAiF;AAEjF,6DAA4E;AAc5E,MAAa,mBAAoB,SAAQ,qCAAgB;IAMvD,YAAY,MAAgE,EAAE,OAAqB;QACjG,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAE7B,wCAAwC;QACxC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,MA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U,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;QAChD,OAAO,UAAU,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAyB;QACrC,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAEzC,8BAA8B;QAC9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC;YAC3C,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,QAAQ;SACrC,CAAC,CAAC;QAEH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE;YAC5C,GAAG,IAAI,CAAC,OAAO;YACf,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAzHD,kDAyHC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { BaseCodeExecutor, ICodeExecutorInput } from "./base_code_executor";
|
|
2
|
+
import type { Execution as BaseExecution, Result as BaseResult, Logs, ChartTypes, RawData, RunCodeOpts } from "@e2b/code-interpreter";
|
|
3
|
+
declare class ExecutionError {
|
|
4
|
+
/**
|
|
5
|
+
* Name of the error.
|
|
6
|
+
**/
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* Value of the error.
|
|
10
|
+
**/
|
|
11
|
+
value: string;
|
|
12
|
+
/**
|
|
13
|
+
* The raw traceback of the error.
|
|
14
|
+
**/
|
|
15
|
+
traceback: string;
|
|
16
|
+
constructor(name: any, value: any, traceback: any);
|
|
17
|
+
}
|
|
18
|
+
declare class Result implements BaseResult {
|
|
19
|
+
readonly isMainResult: boolean;
|
|
20
|
+
readonly text?: string;
|
|
21
|
+
readonly html?: string;
|
|
22
|
+
readonly markdown?: string;
|
|
23
|
+
readonly svg?: string;
|
|
24
|
+
readonly png?: string;
|
|
25
|
+
readonly jpeg?: string;
|
|
26
|
+
readonly pdf?: string;
|
|
27
|
+
readonly latex?: string;
|
|
28
|
+
readonly json?: string;
|
|
29
|
+
readonly javascript?: string;
|
|
30
|
+
readonly data?: Record<string, unknown>;
|
|
31
|
+
readonly chart?: ChartTypes;
|
|
32
|
+
readonly extra?: any;
|
|
33
|
+
readonly raw: RawData;
|
|
34
|
+
constructor(rawData: RawData, isMainResult: boolean);
|
|
35
|
+
formats(): string[];
|
|
36
|
+
toJSON(): {
|
|
37
|
+
text: string | undefined;
|
|
38
|
+
html: string | undefined;
|
|
39
|
+
markdown: string | undefined;
|
|
40
|
+
svg: string | undefined;
|
|
41
|
+
png: string | undefined;
|
|
42
|
+
jpeg: string | undefined;
|
|
43
|
+
pdf: string | undefined;
|
|
44
|
+
latex: string | undefined;
|
|
45
|
+
json: string | undefined;
|
|
46
|
+
javascript: string | undefined;
|
|
47
|
+
extra?: any;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
declare class Execution implements BaseExecution {
|
|
51
|
+
/**
|
|
52
|
+
* List of result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots).
|
|
53
|
+
*/
|
|
54
|
+
results: Result[];
|
|
55
|
+
/**
|
|
56
|
+
* Logs printed to stdout and stderr during execution.
|
|
57
|
+
*/
|
|
58
|
+
logs: Logs;
|
|
59
|
+
/**
|
|
60
|
+
* An Error object if an error occurred, null otherwise.
|
|
61
|
+
*/
|
|
62
|
+
error?: ExecutionError | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Execution count of the cell.
|
|
65
|
+
*/
|
|
66
|
+
executionCount?: number | undefined;
|
|
67
|
+
constructor(results: any[], logs: {
|
|
68
|
+
stdout: any[];
|
|
69
|
+
stderr: any[];
|
|
70
|
+
}, error: any, executionCount: any);
|
|
71
|
+
/**
|
|
72
|
+
* Returns the text representation of the main result of the cell.
|
|
73
|
+
*/
|
|
74
|
+
get text(): string;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the serializable representation of the execution result.
|
|
77
|
+
*/
|
|
78
|
+
toJSON(): {
|
|
79
|
+
results: Result[];
|
|
80
|
+
logs: Logs;
|
|
81
|
+
error: ExecutionError;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
type TUnsafeLocalCodeExecutorOptions = Pick<RunCodeOpts, "timeoutMs" | "envs" | "onStdout" | "onStderr" | "onResult" | "onError">;
|
|
85
|
+
export declare class UnsafeLocalCodeExecutor extends BaseCodeExecutor {
|
|
86
|
+
executor: CodeExecutor;
|
|
87
|
+
options: Pick<RunCodeOpts, "timeoutMs" | "envs" | "onStdout" | "onStderr" | "onResult" | "onError">;
|
|
88
|
+
constructor(options: TUnsafeLocalCodeExecutorOptions);
|
|
89
|
+
_invoke(input: ICodeExecutorInput): Promise<Execution>;
|
|
90
|
+
}
|
|
91
|
+
declare class CodeExecutor {
|
|
92
|
+
executionCount: number;
|
|
93
|
+
constructor();
|
|
94
|
+
runCode(language: any, code: any, options?: RunCodeOpts): Promise<Execution>;
|
|
95
|
+
getLanguageConfig(language: any, code: any): any;
|
|
96
|
+
executeCode(config: any, options?: RunCodeOpts): Promise<{
|
|
97
|
+
success: boolean;
|
|
98
|
+
exitCode: number | null;
|
|
99
|
+
stdout: string;
|
|
100
|
+
stderr: string;
|
|
101
|
+
}>;
|
|
102
|
+
private parseResults;
|
|
103
|
+
private parsePythonResults;
|
|
104
|
+
private parseJavaScriptResults;
|
|
105
|
+
private isDataFrameLine;
|
|
106
|
+
private inferArrayType;
|
|
107
|
+
private calculateArrayStats;
|
|
108
|
+
private calculateStandardDeviation;
|
|
109
|
+
private getMostCommon;
|
|
110
|
+
private getDecimalPlaces;
|
|
111
|
+
private isJsonLine;
|
|
112
|
+
private isNumber;
|
|
113
|
+
private parseTableData;
|
|
114
|
+
private convertTableToHtml;
|
|
115
|
+
private parseTraceback;
|
|
116
|
+
}
|
|
117
|
+
export {};
|
|
118
|
+
//# sourceMappingURL=unsafe_local_code_executor.d.ts.map
|