Skip to content

Class: Session ​

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:

  1. LinkUrl route (direct HTTP) - when linkUrl, token, and serverName are available
  2. Traditional API route - fallback method

The routing logic is implemented in BaseService.

Parameters ​

NameTypeDescription
toolNamestringName of the MCP tool to call
argsRecord<string, unknown>Arguments to pass to the tool
readTimeout?numberRead timeout in milliseconds
connectTimeout?numberConnect 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 ​

NameTypeDefault valueDescription
syncContextbooleanfalseIf 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(protocolType?, port?): Promise<OperationResult>

Parameters ​

NameType
protocolType?string
port?number

Returns ​

Promise<OperationResult>


getMetrics ​

▸ getMetrics(readTimeout?, connectTimeout?): Promise<SessionMetricsResult>

Parameters ​

NameType
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 ​

NameType
imageId?string

Returns ​

Promise<McpToolsResult>


setLabels ​

▸ setLabels(labels): Promise<OperationResult>

Set labels on the session (key-value metadata).

Parameters ​

NameTypeDescription
labelsRecord<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