test-wuying-agentbay-sdk 0.13.0-beta.20251210110535 → 0.13.0-beta.20251210134647

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.
@@ -58,6 +58,9 @@ const result = await agentBay.create({ imageId: "code_latest" });
58
58
  if (result.success) {
59
59
  const codeResult = await result.session.code.runCode('print("Hello")', "python");
60
60
  console.log(codeResult.result);
61
+ if (codeResult.results) {
62
+ // Access rich output like images or charts
63
+ }
61
64
  await result.session.delete();
62
65
  }
63
66
  ```
@@ -0,0 +1,86 @@
1
+ import { AgentBay } from "../../../../../src";
2
+
3
+ async function main() {
4
+ const apiKey = process.env.AGENTBAY_API_KEY;
5
+ if (!apiKey) {
6
+ console.error("Please set AGENTBAY_API_KEY environment variable");
7
+ process.exit(1);
8
+ }
9
+
10
+ const agentBay = new AgentBay({ apiKey });
11
+
12
+ console.log("Creating session...");
13
+ const sessionResult = await agentBay.create({ imageId: "code_latest" });
14
+ if (!sessionResult.success || !sessionResult.session) {
15
+ console.error("Failed to create session:", sessionResult.errorMessage);
16
+ process.exit(1);
17
+ }
18
+
19
+ const session = sessionResult.session;
20
+ console.log(`Session created: ${session.sessionId}`);
21
+
22
+ try {
23
+ // 1. Logs Capture
24
+ console.log("\n--- Logs Capture Test ---");
25
+ const logsCode = `
26
+ import sys
27
+ print("This goes to stdout")
28
+ print("This goes to stderr", file=sys.stderr)
29
+ `;
30
+ const logsResult = await session.code.runCode(logsCode, "python");
31
+ printResult(logsResult);
32
+
33
+ // 2. Rich Output (HTML)
34
+ console.log("\n--- Rich Output (HTML) Test ---");
35
+ const htmlCode = `
36
+ from IPython.display import display, HTML
37
+ display(HTML("<h1>Hello from AgentBay</h1>"))
38
+ `;
39
+ const htmlResult = await session.code.runCode(htmlCode, "python");
40
+ printResult(htmlResult);
41
+
42
+ // 3. Error Handling
43
+ console.log("\n--- Error Handling Test ---");
44
+ const errorCode = `
45
+ raise ValueError("Something went wrong")
46
+ `;
47
+ const errorResult = await session.code.runCode(errorCode, "python");
48
+ printResult(errorResult);
49
+
50
+ } finally {
51
+ console.log("\nCleaning up...");
52
+ await session.delete();
53
+ }
54
+ }
55
+
56
+ function printResult(result: any) {
57
+ if (result.success) {
58
+ console.log("Success: true");
59
+ if (result.logs) {
60
+ if (result.logs.stdout.length > 0) {
61
+ console.log("Stdout:", JSON.stringify(result.logs.stdout));
62
+ }
63
+ if (result.logs.stderr.length > 0) {
64
+ console.log("Stderr:", JSON.stringify(result.logs.stderr));
65
+ }
66
+ }
67
+ if (result.results) {
68
+ console.log("Results count:", result.results.length);
69
+ result.results.forEach((item: any, index: number) => {
70
+ const types = Object.keys(item).filter(k => k !== 'isMainResult');
71
+ console.log(`Result [${index}] types:`, types.join(", "));
72
+ if (item.text) console.log(` Text: ${item.text.substring(0, 50)}...`);
73
+ if (item.html) console.log(` HTML: ${item.html.substring(0, 50)}...`);
74
+ });
75
+ }
76
+ } else {
77
+ console.log("Success: false");
78
+ console.log("Error Message:", result.errorMessage);
79
+ if (result.error) {
80
+ console.log("Error Details:", JSON.stringify(result.error));
81
+ }
82
+ }
83
+ }
84
+
85
+ main().catch(console.error);
86
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-wuying-agentbay-sdk",
3
- "version": "0.13.0-beta.20251210110535",
3
+ "version": "0.13.0-beta.20251210134647",
4
4
  "description": "TypeScript SDK for interacting with the Wuying AgentBay cloud runtime environment",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",