test-wuying-agentbay-sdk 0.13.1-beta.20251224103203 → 0.13.1-beta.20251224113236
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 +87 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.mjs +64 -0
- package/dist/index.mjs.map +1 -1
- package/docs/api/common-features/basics/session.md +0 -2
- package/docs/examples/README.md +1 -0
- package/docs/examples/common-features/advanced/session-metrics/README.md +19 -0
- package/docs/examples/common-features/advanced/session-metrics/main.ts +33 -0
- package/package.json +1 -1
package/docs/examples/README.md
CHANGED
|
@@ -20,6 +20,7 @@ examples/
|
|
|
20
20
|
│ │ └── get/ # Session retrieval
|
|
21
21
|
│ └── advanced/ # Advanced features
|
|
22
22
|
│ ├── agent-module-example/ # AI-powered automation
|
|
23
|
+
│ ├── session-metrics/ # Runtime metrics via MCP get_metrics
|
|
23
24
|
│ ├── vpc-session-example/ # Secure isolated network environments
|
|
24
25
|
│ └── archive-upload-mode-example/ # Archive upload mode
|
|
25
26
|
├── browser-use/ # Browser automation (browser_latest)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Session Metrics Example (TypeScript)
|
|
2
|
+
|
|
3
|
+
This example demonstrates how to retrieve **runtime metrics** for a session using `session.getMetrics()`.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js 16+
|
|
8
|
+
- AgentBay API Key (set as environment variable `AGENTBAY_API_KEY`)
|
|
9
|
+
|
|
10
|
+
## Run
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
export AGENTBAY_API_KEY=your_api_key_here
|
|
14
|
+
|
|
15
|
+
cd typescript/docs/examples/common-features/advanced/session-metrics
|
|
16
|
+
npx ts-node main.ts
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AgentBay } from "wuying-agentbay-sdk";
|
|
2
|
+
|
|
3
|
+
async function main(): Promise<void> {
|
|
4
|
+
const apiKey = process.env.AGENTBAY_API_KEY;
|
|
5
|
+
if (!apiKey) {
|
|
6
|
+
throw new Error("AGENTBAY_API_KEY environment variable is not set");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const agentBay = new AgentBay({ apiKey });
|
|
10
|
+
const create = await agentBay.create({ imageId: "linux_latest" });
|
|
11
|
+
if (!create.success || !create.session) {
|
|
12
|
+
throw new Error(create.errorMessage || "failed to create session");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const session = create.session;
|
|
16
|
+
try {
|
|
17
|
+
const metrics = await session.getMetrics();
|
|
18
|
+
if (!metrics.success) {
|
|
19
|
+
throw new Error(metrics.errorMessage || "getMetrics failed");
|
|
20
|
+
}
|
|
21
|
+
console.log(metrics.data);
|
|
22
|
+
} finally {
|
|
23
|
+
await session.delete();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main().catch((err) => {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.error(err);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-wuying-agentbay-sdk",
|
|
3
|
-
"version": "0.13.1-beta.
|
|
3
|
+
"version": "0.13.1-beta.20251224113236",
|
|
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",
|