Skip to content

Commit e07c354

Browse files
committed
2 parents bb5d870 + 8c6cb18 commit e07c354

File tree

10 files changed

+165
-265
lines changed

10 files changed

+165
-265
lines changed

js/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@e2b/code-interpreter",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "E2B Code Interpreter - Stateful code execution",
55
"homepage": "https://e2b.dev",
66
"license": "MIT",
@@ -60,7 +60,7 @@
6060
"vm"
6161
],
6262
"dependencies": {
63-
"e2b": "^0.13.1",
63+
"e2b": "^0.16.0",
6464
"isomorphic-ws": "^5.0.0",
6565
"ws": "^8.15.1"
6666
},

js/src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
export { CodeInterpreter, JupyterExtension } from './code-interpreter'
22
export type { CreateKernelProps } from './code-interpreter'
33

4-
export type { ExecutionError, Result, Execution, MIMEType } from './messaging'
4+
export type { Logs, ExecutionError, Result, Execution, MIMEType, RawData } from './messaging'
55

66
import { CodeInterpreter } from './code-interpreter'
7-
export default CodeInterpreter
7+
8+
export * from 'e2b'
9+
10+
export default CodeInterpreter

js/src/messaging.ts

+33-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class ExecutionError {
2020
* The raw traceback of the error.
2121
**/
2222
public tracebackRaw: string[]
23-
) {}
23+
) { }
2424

2525
/**
2626
* Returns the traceback of the error as a string.
@@ -175,6 +175,25 @@ export class Result {
175175

176176
return formats
177177
}
178+
179+
/**
180+
* Returns the serializable representation of the result.
181+
*/
182+
toJSON() {
183+
return {
184+
text: this.text,
185+
html: this.html,
186+
markdown: this.markdown,
187+
svg: this.svg,
188+
png: this.png,
189+
jpeg: this.jpeg,
190+
pdf: this.pdf,
191+
latex: this.latex,
192+
json: this.json,
193+
javascript: this.javascript,
194+
...(Object.keys(this.extra).length > 0 ? { extra: this.extra } : {})
195+
}
196+
}
178197
}
179198

180199
/**
@@ -208,7 +227,7 @@ export class Execution {
208227
* An Error object if an error occurred, null otherwise.
209228
*/
210229
public error?: ExecutionError
211-
) {}
230+
) { }
212231

213232
/**
214233
* Returns the text representation of the main result of the cell.
@@ -220,6 +239,17 @@ export class Execution {
220239
}
221240
}
222241
}
242+
243+
/**
244+
* Returns the serializable representation of the execution result.
245+
*/
246+
toJSON() {
247+
return {
248+
results: this.results,
249+
logs: this.logs,
250+
error: this.error
251+
}
252+
}
223253
}
224254

225255
/**
@@ -275,7 +305,7 @@ export class JupyterKernelWebSocket {
275305
* Does not start WebSocket connection!
276306
* You need to call connect() method first.
277307
*/
278-
constructor(private readonly url: string) {}
308+
constructor(private readonly url: string) { }
279309

280310
// public
281311
/**

0 commit comments

Comments
 (0)