Appearance
Class: Session
📖 Related Tutorial
- Session Management Guide - Detailed tutorial on session lifecycle and management
Overview
The Session module provides methods for creating, managing, and terminating sessions in the AGB cloud environment. Sessions are the foundation for all operations.
Represents an active session in the AGB cloud environment. Provides access to command, file system, code execution, browser, computer, and context modules.
Table of contents
Properties
Methods
Properties
typescript
appInstanceId: `string` = `""`
browser: [`Browser`](capabilities/browser.md)
code: [`Code`](capabilities/code_execution.md)
command: [`Command`](capabilities/shell_commands.md)
computer: [`Computer`](capabilities/computer.md)
context: [`ContextManager`](data_context/context_manager.md)
file: [`FileSystem`](capabilities/file_system.md)
imageId: `string` = `""`
linkUrl: `string` = `""`
mcpTools: ``McpTool``[] = `[]`
resourceId: `string` = `""`
resourceUrl: `string` = `""`
token: `string` = `""`
toolList: `string` = `""`
wsUrl: `string` = `""`Methods
callMcpTool
▸ callMcpTool(toolName, args, readTimeout?, connectTimeout?): Promise<McpToolResult>
Call an MCP tool with intelligent routing.
This method routes the call to either:
- LinkUrl route (direct HTTP) - when linkUrl, token, and serverName are available
- Traditional API route - fallback method
The routing logic is implemented in BaseService.
Parameters
| Name | Type | Description |
|---|---|---|
toolName | string | Name of the MCP tool to call |
args | Record<string, unknown> | Arguments to pass to the tool |
readTimeout? | number | Read timeout in milliseconds |
connectTimeout? | number | Connect timeout in milliseconds |
Returns
Promise<McpToolResult>
Promise resolving to McpToolResult
delete
▸ delete(syncContext?): Promise<DeleteResult>
Release (delete) this session. Optionally sync context before releasing.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
syncContext | boolean | false | If true, sync context (e.g. upload browser data) before releasing |
Returns
Promise<DeleteResult>
Promise resolving to DeleteResult
getLabels
▸ getLabels(): Promise<OperationResult>
Get labels for the session.
Returns
Promise<OperationResult>
Promise resolving to OperationResult with data containing labels object
getLink
▸ getLink(protocolType?, port?): Promise<OperationResult>
Parameters
| Name | Type |
|---|---|
protocolType? | string |
port? | number |
Returns
Promise<OperationResult>
getMetrics
▸ getMetrics(readTimeout?, connectTimeout?): Promise<SessionMetricsResult>
Parameters
| Name | Type |
|---|---|
readTimeout? | number |
connectTimeout? | number |
Returns
Promise<SessionMetricsResult>
info
▸ info(): Promise<OperationResult>
Get session resource info (sessionId, resourceUrl, desktopInfo, etc.).
Returns
Promise<OperationResult>
Promise resolving to OperationResult with resource data
keepAlive
▸ keepAlive(): Promise<OperationResult>
Returns
Promise<OperationResult>
listMcpTools
▸ listMcpTools(imageId?): Promise<McpToolsResult>
Parameters
| Name | Type |
|---|---|
imageId? | string |
Returns
Promise<McpToolsResult>
setLabels
▸ setLabels(labels): Promise<OperationResult>
Set labels on the session (key-value metadata).
Parameters
| Name | Type | Description |
|---|---|---|
labels | Record<string, string> | Non-empty object of string key-value pairs |
Returns
Promise<OperationResult>
Promise resolving to OperationResult
toJSON
▸ toJSON(): Record<string, unknown>
Serialize session to a plain object (sessionId, resourceUrl, imageId, etc.).
Returns
Record<string, unknown>
Plain object with session fields