test-wuying-agentbay-sdk 0.13.1-beta.20251224103203 → 0.13.1-beta.20251224115652
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 +28 -0
- 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
|
@@ -25,6 +25,7 @@ Represents a session in the AgentBay cloud environment.
|
|
|
25
25
|
- [getLabels](#getlabels)
|
|
26
26
|
- [getLink](#getlink)
|
|
27
27
|
- [getLinkAsync](#getlinkasync)
|
|
28
|
+
- [getMetrics](#getmetrics)
|
|
28
29
|
- [info](#info)
|
|
29
30
|
- [listMcpTools](#listmcptools)
|
|
30
31
|
- [pauseAsync](#pauseasync)
|
|
@@ -317,6 +318,33 @@ if (result.success) {
|
|
|
317
318
|
|
|
318
319
|
___
|
|
319
320
|
|
|
321
|
+
### getMetrics
|
|
322
|
+
|
|
323
|
+
▸ **getMetrics**(): `Promise`\<``SessionMetricsResult``\>
|
|
324
|
+
|
|
325
|
+
Get runtime metrics for this session.
|
|
326
|
+
|
|
327
|
+
The underlying service returns a JSON string. This method parses it and
|
|
328
|
+
returns a structured result.
|
|
329
|
+
|
|
330
|
+
#### Returns
|
|
331
|
+
|
|
332
|
+
`Promise`\<``SessionMetricsResult``\>
|
|
333
|
+
|
|
334
|
+
**`Example`**
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
const agentBay = new AgentBay({ apiKey: "your_api_key" });
|
|
338
|
+
const create = await agentBay.create({ imageId: "linux_latest" });
|
|
339
|
+
if (create.success && create.session) {
|
|
340
|
+
const metrics = await create.session.getMetrics();
|
|
341
|
+
console.log(metrics.data);
|
|
342
|
+
await create.session.delete();
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
___
|
|
347
|
+
|
|
320
348
|
### info
|
|
321
349
|
|
|
322
350
|
▸ **info**(): `Promise`\<`OperationResult`\>
|
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.20251224115652",
|
|
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",
|