UNPKG

test-wuying-agentbay-sdk

Version:

TypeScript SDK for interacting with the Wuying AgentBay cloud runtime environment

1 lines 608 kB
{"version":3,"sources":["../node_modules/tsup/assets/esm_shims.js","../node_modules/dotenv/package.json","../node_modules/dotenv/lib/main.js","../node_modules/dotenv/lib/env-options.js","../node_modules/dotenv/lib/cli-options.js","../src/index.ts","../src/agent-bay.ts","../node_modules/dotenv/config.js","../src/api/index.ts","../src/api/client.ts","../src/api/models/model.ts","../src/api/models/ApplyMqttTokenResponseBodyData.ts","../src/api/models/CreateMcpSessionRequestPersistenceDataList.ts","../src/api/models/CreateMcpSessionResponseBodyData.ts","../src/api/models/GetContextResponseBodyData.ts","../src/api/models/GetContextInfoResponseBodyData.ts","../src/api/models/GetLabelResponseBodyData.ts","../src/api/models/GetLinkResponseBodyData.ts","../src/api/models/GetMcpResourceResponseBodyDataDesktopInfo.ts","../src/api/models/GetMcpResourceResponseBodyData.ts","../src/api/models/ListContextsResponseBodyData.ts","../src/api/models/ListSessionResponseBodyData.ts","../src/api/models/ApplyMqttTokenRequest.ts","../src/api/models/ApplyMqttTokenResponseBody.ts","../src/api/models/ApplyMqttTokenResponse.ts","../src/api/models/CallMcpToolRequest.ts","../src/api/models/CallMcpToolResponseBody.ts","../src/api/models/CallMcpToolResponse.ts","../src/api/models/CreateMcpSessionRequest.ts","../src/api/models/CreateMcpSessionShrinkRequest.ts","../src/api/models/CreateMcpSessionResponseBody.ts","../src/api/models/CreateMcpSessionResponse.ts","../src/api/models/DeleteContextRequest.ts","../src/api/models/DeleteContextResponseBody.ts","../src/api/models/DeleteContextResponse.ts","../src/api/models/GetContextRequest.ts","../src/api/models/GetContextResponseBody.ts","../src/api/models/GetContextResponse.ts","../src/api/models/GetContextInfoRequest.ts","../src/api/models/GetContextInfoResponseBody.ts","../src/api/models/GetContextInfoResponse.ts","../src/api/models/GetLabelRequest.ts","../src/api/models/GetLabelResponseBody.ts","../src/api/models/GetLabelResponse.ts","../src/api/models/GetLinkRequest.ts","../src/api/models/GetLinkResponseBody.ts","../src/api/models/GetLinkResponse.ts","../src/api/models/GetMcpResourceRequest.ts","../src/api/models/GetMcpResourceResponseBody.ts","../src/api/models/GetMcpResourceResponse.ts","../src/api/models/InitBrowserRequest.ts","../src/api/models/InitBrowserResponseBody.ts","../src/api/models/InitBrowserResponseBodyData.ts","../src/api/models/InitBrowserResponse.ts","../src/api/models/ListContextsRequest.ts","../src/api/models/ListContextsResponseBody.ts","../src/api/models/ListContextsResponse.ts","../src/api/models/ListMcpToolsRequest.ts","../src/api/models/ListMcpToolsResponseBody.ts","../src/api/models/ListMcpToolsResponse.ts","../src/api/models/ListSessionRequest.ts","../src/api/models/ListSessionResponseBody.ts","../src/api/models/ListSessionResponse.ts","../src/api/models/ModifyContextRequest.ts","../src/api/models/ModifyContextResponseBody.ts","../src/api/models/ModifyContextResponse.ts","../src/api/models/ReleaseMcpSessionRequest.ts","../src/api/models/ReleaseMcpSessionResponseBody.ts","../src/api/models/ReleaseMcpSessionResponse.ts","../src/api/models/SetLabelRequest.ts","../src/api/models/SetLabelResponseBody.ts","../src/api/models/SetLabelResponse.ts","../src/api/models/SyncContextRequest.ts","../src/api/models/SyncContextResponseBody.ts","../src/api/models/SyncContextResponse.ts","../src/api/models/DeleteContextFileRequest.ts","../src/api/models/DeleteContextFileResponseBody.ts","../src/api/models/DeleteContextFileResponse.ts","../src/api/models/DescribeContextFilesRequest.ts","../src/api/models/DescribeContextFilesResponseBody.ts","../src/api/models/DescribeContextFilesResponse.ts","../src/api/models/GetContextFileDownloadUrlRequest.ts","../src/api/models/GetContextFileDownloadUrlResponseBody.ts","../src/api/models/GetContextFileDownloadUrlResponse.ts","../src/api/models/GetContextFileUploadUrlRequest.ts","../src/api/models/GetContextFileUploadUrlResponseBody.ts","../src/api/models/GetContextFileUploadUrlResponse.ts","../src/config.ts","../src/utils/logger.ts","../src/context.ts","../src/types/api-response.ts","../src/context-sync.ts","../src/exceptions.ts","../src/session.ts","../src/agent/agent.ts","../src/application/application.ts","../src/browser/index.ts","../src/browser/browser.ts","../src/browser/browser_agent.ts","../src/code/index.ts","../src/code/code.ts","../src/command/command.ts","../src/computer/index.ts","../src/computer/computer.ts","../src/context-manager.ts","../src/filesystem/filesystem.ts","../src/filesystem/file-transfer.ts","../src/mobile/index.ts","../src/mobile/mobile.ts","../src/oss/index.ts","../src/oss/oss.ts","../src/ui/ui.ts","../src/window/window.ts","../src/agent/index.ts","../src/extension.ts","../src/session-params.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","{\n \"name\": \"dotenv\",\n \"version\": \"16.6.1\",\n \"description\": \"Loads environment variables from .env file\",\n \"main\": \"lib/main.js\",\n \"types\": \"lib/main.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/main.d.ts\",\n \"require\": \"./lib/main.js\",\n \"default\": \"./lib/main.js\"\n },\n \"./config\": \"./config.js\",\n \"./config.js\": \"./config.js\",\n \"./lib/env-options\": \"./lib/env-options.js\",\n \"./lib/env-options.js\": \"./lib/env-options.js\",\n \"./lib/cli-options\": \"./lib/cli-options.js\",\n \"./lib/cli-options.js\": \"./lib/cli-options.js\",\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dts-check\": \"tsc --project tests/types/tsconfig.json\",\n \"lint\": \"standard\",\n \"pretest\": \"npm run lint && npm run dts-check\",\n \"test\": \"tap run --allow-empty-coverage --disable-coverage --timeout=60000\",\n \"test:coverage\": \"tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov\",\n \"prerelease\": \"npm test\",\n \"release\": \"standard-version\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/motdotla/dotenv.git\"\n },\n \"homepage\": \"https://github.com/motdotla/dotenv#readme\",\n \"funding\": \"https://dotenvx.com\",\n \"keywords\": [\n \"dotenv\",\n \"env\",\n \".env\",\n \"environment\",\n \"variables\",\n \"config\",\n \"settings\"\n ],\n \"readmeFilename\": \"README.md\",\n \"license\": \"BSD-2-Clause\",\n \"devDependencies\": {\n \"@types/node\": \"^18.11.3\",\n \"decache\": \"^4.6.2\",\n \"sinon\": \"^14.0.1\",\n \"standard\": \"^17.0.0\",\n \"standard-version\": \"^9.5.0\",\n \"tap\": \"^19.2.0\",\n \"typescript\": \"^4.8.4\"\n },\n \"engines\": {\n \"node\": \">=12\"\n },\n \"browser\": {\n \"fs\": false\n }\n}\n","const fs = require('fs')\nconst path = require('path')\nconst os = require('os')\nconst crypto = require('crypto')\nconst packageJson = require('../package.json')\n\nconst version = packageJson.version\n\nconst LINE = /(?:^|^)\\s*(?:export\\s+)?([\\w.-]+)(?:\\s*=\\s*?|:\\s+?)(\\s*'(?:\\\\'|[^'])*'|\\s*\"(?:\\\\\"|[^\"])*\"|\\s*`(?:\\\\`|[^`])*`|[^#\\r\\n]+)?\\s*(?:#.*)?(?:$|$)/mg\n\n// Parse src into an Object\nfunction parse (src) {\n const obj = {}\n\n // Convert buffer to string\n let lines = src.toString()\n\n // Convert line breaks to same format\n lines = lines.replace(/\\r\\n?/mg, '\\n')\n\n let match\n while ((match = LINE.exec(lines)) != null) {\n const key = match[1]\n\n // Default undefined or null to empty string\n let value = (match[2] || '')\n\n // Remove whitespace\n value = value.trim()\n\n // Check if double quoted\n const maybeQuote = value[0]\n\n // Remove surrounding quotes\n value = value.replace(/^(['\"`])([\\s\\S]*)\\1$/mg, '$2')\n\n // Expand newlines if double quoted\n if (maybeQuote === '\"') {\n value = value.replace(/\\\\n/g, '\\n')\n value = value.replace(/\\\\r/g, '\\r')\n }\n\n // Add to object\n obj[key] = value\n }\n\n return obj\n}\n\nfunction _parseVault (options) {\n options = options || {}\n\n const vaultPath = _vaultPath(options)\n options.path = vaultPath // parse .env.vault\n const result = DotenvModule.configDotenv(options)\n if (!result.parsed) {\n const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)\n err.code = 'MISSING_DATA'\n throw err\n }\n\n // handle scenario for comma separated keys - for use with key rotation\n // example: DOTENV_KEY=\"dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod\"\n const keys = _dotenvKey(options).split(',')\n const length = keys.length\n\n let decrypted\n for (let i = 0; i < length; i++) {\n try {\n // Get full key\n const key = keys[i].trim()\n\n // Get instructions for decrypt\n const attrs = _instructions(result, key)\n\n // Decrypt\n decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)\n\n break\n } catch (error) {\n // last key\n if (i + 1 >= length) {\n throw error\n }\n // try next key\n }\n }\n\n // Parse decrypted .env string\n return DotenvModule.parse(decrypted)\n}\n\nfunction _warn (message) {\n console.log(`[dotenv@${version}][WARN] ${message}`)\n}\n\nfunction _debug (message) {\n console.log(`[dotenv@${version}][DEBUG] ${message}`)\n}\n\nfunction _log (message) {\n console.log(`[dotenv@${version}] ${message}`)\n}\n\nfunction _dotenvKey (options) {\n // prioritize developer directly setting options.DOTENV_KEY\n if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {\n return options.DOTENV_KEY\n }\n\n // secondary infra already contains a DOTENV_KEY environment variable\n if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {\n return process.env.DOTENV_KEY\n }\n\n // fallback to empty string\n return ''\n}\n\nfunction _instructions (result, dotenvKey) {\n // Parse DOTENV_KEY. Format is a URI\n let uri\n try {\n uri = new URL(dotenvKey)\n } catch (error) {\n if (error.code === 'ERR_INVALID_URL') {\n const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n throw error\n }\n\n // Get decrypt key\n const key = uri.password\n if (!key) {\n const err = new Error('INVALID_DOTENV_KEY: Missing key part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get environment\n const environment = uri.searchParams.get('environment')\n if (!environment) {\n const err = new Error('INVALID_DOTENV_KEY: Missing environment part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get ciphertext payload\n const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`\n const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION\n if (!ciphertext) {\n const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)\n err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'\n throw err\n }\n\n return { ciphertext, key }\n}\n\nfunction _vaultPath (options) {\n let possibleVaultPath = null\n\n if (options && options.path && options.path.length > 0) {\n if (Array.isArray(options.path)) {\n for (const filepath of options.path) {\n if (fs.existsSync(filepath)) {\n possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`\n }\n }\n } else {\n possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`\n }\n } else {\n possibleVaultPath = path.resolve(process.cwd(), '.env.vault')\n }\n\n if (fs.existsSync(possibleVaultPath)) {\n return possibleVaultPath\n }\n\n return null\n}\n\nfunction _resolveHome (envPath) {\n return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath\n}\n\nfunction _configVault (options) {\n const debug = Boolean(options && options.debug)\n const quiet = options && 'quiet' in options ? options.quiet : true\n\n if (debug || !quiet) {\n _log('Loading env from encrypted .env.vault')\n }\n\n const parsed = DotenvModule._parseVault(options)\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsed, options)\n\n return { parsed }\n}\n\nfunction configDotenv (options) {\n const dotenvPath = path.resolve(process.cwd(), '.env')\n let encoding = 'utf8'\n const debug = Boolean(options && options.debug)\n const quiet = options && 'quiet' in options ? options.quiet : true\n\n if (options && options.encoding) {\n encoding = options.encoding\n } else {\n if (debug) {\n _debug('No encoding is specified. UTF-8 is used by default')\n }\n }\n\n let optionPaths = [dotenvPath] // default, look for .env\n if (options && options.path) {\n if (!Array.isArray(options.path)) {\n optionPaths = [_resolveHome(options.path)]\n } else {\n optionPaths = [] // reset default\n for (const filepath of options.path) {\n optionPaths.push(_resolveHome(filepath))\n }\n }\n }\n\n // Build the parsed data in a temporary object (because we need to return it). Once we have the final\n // parsed data, we will combine it with process.env (or options.processEnv if provided).\n let lastError\n const parsedAll = {}\n for (const path of optionPaths) {\n try {\n // Specifying an encoding returns a string instead of a buffer\n const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))\n\n DotenvModule.populate(parsedAll, parsed, options)\n } catch (e) {\n if (debug) {\n _debug(`Failed to load ${path} ${e.message}`)\n }\n lastError = e\n }\n }\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsedAll, options)\n\n if (debug || !quiet) {\n const keysCount = Object.keys(parsedAll).length\n const shortPaths = []\n for (const filePath of optionPaths) {\n try {\n const relative = path.relative(process.cwd(), filePath)\n shortPaths.push(relative)\n } catch (e) {\n if (debug) {\n _debug(`Failed to load ${filePath} ${e.message}`)\n }\n lastError = e\n }\n }\n\n _log(`injecting env (${keysCount}) from ${shortPaths.join(',')}`)\n }\n\n if (lastError) {\n return { parsed: parsedAll, error: lastError }\n } else {\n return { parsed: parsedAll }\n }\n}\n\n// Populates process.env from .env file\nfunction config (options) {\n // fallback to original dotenv if DOTENV_KEY is not set\n if (_dotenvKey(options).length === 0) {\n return DotenvModule.configDotenv(options)\n }\n\n const vaultPath = _vaultPath(options)\n\n // dotenvKey exists but .env.vault file does not exist\n if (!vaultPath) {\n _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)\n\n return DotenvModule.configDotenv(options)\n }\n\n return DotenvModule._configVault(options)\n}\n\nfunction decrypt (encrypted, keyStr) {\n const key = Buffer.from(keyStr.slice(-64), 'hex')\n let ciphertext = Buffer.from(encrypted, 'base64')\n\n const nonce = ciphertext.subarray(0, 12)\n const authTag = ciphertext.subarray(-16)\n ciphertext = ciphertext.subarray(12, -16)\n\n try {\n const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)\n aesgcm.setAuthTag(authTag)\n return `${aesgcm.update(ciphertext)}${aesgcm.final()}`\n } catch (error) {\n const isRange = error instanceof RangeError\n const invalidKeyLength = error.message === 'Invalid key length'\n const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'\n\n if (isRange || invalidKeyLength) {\n const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n } else if (decryptionFailed) {\n const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')\n err.code = 'DECRYPTION_FAILED'\n throw err\n } else {\n throw error\n }\n }\n}\n\n// Populate process.env with parsed values\nfunction populate (processEnv, parsed, options = {}) {\n const debug = Boolean(options && options.debug)\n const override = Boolean(options && options.override)\n\n if (typeof parsed !== 'object') {\n const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')\n err.code = 'OBJECT_REQUIRED'\n throw err\n }\n\n // Set process.env\n for (const key of Object.keys(parsed)) {\n if (Object.prototype.hasOwnProperty.call(processEnv, key)) {\n if (override === true) {\n processEnv[key] = parsed[key]\n }\n\n if (debug) {\n if (override === true) {\n _debug(`\"${key}\" is already defined and WAS overwritten`)\n } else {\n _debug(`\"${key}\" is already defined and was NOT overwritten`)\n }\n }\n } else {\n processEnv[key] = parsed[key]\n }\n }\n}\n\nconst DotenvModule = {\n configDotenv,\n _configVault,\n _parseVault,\n config,\n decrypt,\n parse,\n populate\n}\n\nmodule.exports.configDotenv = DotenvModule.configDotenv\nmodule.exports._configVault = DotenvModule._configVault\nmodule.exports._parseVault = DotenvModule._parseVault\nmodule.exports.config = DotenvModule.config\nmodule.exports.decrypt = DotenvModule.decrypt\nmodule.exports.parse = DotenvModule.parse\nmodule.exports.populate = DotenvModule.populate\n\nmodule.exports = DotenvModule\n","// ../config.js accepts options via environment variables\nconst options = {}\n\nif (process.env.DOTENV_CONFIG_ENCODING != null) {\n options.encoding = process.env.DOTENV_CONFIG_ENCODING\n}\n\nif (process.env.DOTENV_CONFIG_PATH != null) {\n options.path = process.env.DOTENV_CONFIG_PATH\n}\n\nif (process.env.DOTENV_CONFIG_QUIET != null) {\n options.quiet = process.env.DOTENV_CONFIG_QUIET\n}\n\nif (process.env.DOTENV_CONFIG_DEBUG != null) {\n options.debug = process.env.DOTENV_CONFIG_DEBUG\n}\n\nif (process.env.DOTENV_CONFIG_OVERRIDE != null) {\n options.override = process.env.DOTENV_CONFIG_OVERRIDE\n}\n\nif (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {\n options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY\n}\n\nmodule.exports = options\n","const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/\n\nmodule.exports = function optionMatcher (args) {\n const options = args.reduce(function (acc, cur) {\n const matches = cur.match(re)\n if (matches) {\n acc[matches[1]] = matches[2]\n }\n return acc\n }, {})\n\n if (!('quiet' in options)) {\n options.quiet = 'true'\n }\n\n return options\n}\n","// Export all public classes and interfaces\nexport { AgentBay, type CreateSessionParams} from \"./agent-bay\";\nexport * from \"./agent\";\nexport * from \"./api\";\nexport * from \"./application\";\nexport * from \"./browser\";\nexport * from \"./command\";\nexport { Context, ContextService } from \"./context\";\nexport * from \"./exceptions\";\nexport * from \"./extension\";\nexport * from \"./filesystem\";\nexport * from \"./oss\";\nexport { Session } from \"./session\";\nexport { type ListSessionParams } from \"./types\";\nexport * from \"./ui\";\nexport * from './context-sync'\nexport * from './context-manager'\nexport * from './session-params'\n// Export utility functions\nexport { log, logError } from \"./utils/logger\";\nexport { loadConfig, loadDotEnv, type Config } from \"./config\";\n","import { $OpenApiUtil } from \"@alicloud/openapi-core\";\nimport \"dotenv/config\";\nimport * as $_client from \"./api\";\nimport { ListSessionRequest, CreateMcpSessionRequestPersistenceDataList } from \"./api/models/model\";\nimport { Client } from \"./api/client\";\n\nimport { loadConfig, loadDotEnv, Config, BROWSER_DATA_PATH } from \"./config\";\nimport { ContextService } from \"./context\";\nimport { ContextSync } from \"./context-sync\";\nimport { APIError, AuthenticationError } from \"./exceptions\";\nimport { Session } from \"./session\";\nimport { BrowserContext } from \"./session-params\";\nimport { Context } from \"./context\";\n\nimport {\n DeleteResult,\n extractRequestId,\n SessionResult,\n} from \"./types/api-response\";\nimport {\n ListSessionParams,\n SessionListResult,\n} from \"./types/list-session-params\";\nimport { log, logError } from \"./utils/logger\";\n\n/**\n * Generate a random context name using alphanumeric characters with timestamp.\n * This function is similar to the Python version's generate_random_context_name.\n */\nfunction generateRandomContextName(length = 8, includeTimestamp = true): string {\n const timestamp = new Date().toISOString().replace(/[-T:.Z]/g, '').slice(0, 14);\n\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let randomPart = '';\n for (let i = 0; i < length; i++) {\n randomPart += characters.charAt(Math.floor(Math.random() * characters.length));\n }\n\n return includeTimestamp ? `${timestamp}_${randomPart}` : randomPart;\n}\n\n/**\n * Parameters for creating a session.\n */\nexport interface CreateSessionParams {\n labels?: Record<string, string>;\n imageId?: string;\n contextSync?: ContextSync[];\n browserContext?: BrowserContext;\n isVpc?: boolean;\n mcpPolicyId?: string;\n enableBrowserReplay?: boolean;\n}\n\n/**\n * Main class for interacting with the AgentBay cloud runtime environment.\n */\nexport class AgentBay {\n private apiKey: string;\n private client: Client;\n private regionId: string;\n private endpoint: string;\n private sessions: Map<string, Session> = new Map();\n private fileTransferContext: Context | null = null;\n\n /**\n * Context service for managing persistent contexts.\n */\n context: ContextService;\n\n /**\n * Initialize the AgentBay client.\n *\n * @param options - Configuration options\n * @param options.apiKey - API key for authentication. If not provided, will look for AGENTBAY_API_KEY environment variable.\n * @param options.config - Custom configuration object. If not provided, will use environment-based configuration.\n */\n constructor(\n options: {\n apiKey?: string;\n config?: Config;\n } = {}\n ) {\n // Load .env file first to ensure AGENTBAY_API_KEY is available\n loadDotEnv();\n\n this.apiKey = options.apiKey || process.env.AGENTBAY_API_KEY || \"\";\n\n if (!this.apiKey) {\n throw new AuthenticationError(\n \"API key is required. Provide it as a parameter or set the AGENTBAY_API_KEY environment variable.\"\n );\n }\n\n // Load configuration using the enhanced loadConfig function\n const configData = loadConfig(options.config);\n this.regionId = configData.region_id;\n this.endpoint = configData.endpoint;\n\n const config = new $OpenApiUtil.Config({\n regionId: this.regionId,\n endpoint: this.endpoint,\n });\n\n config.readTimeout = configData.timeout_ms;\n config.connectTimeout = configData.timeout_ms;\n\n try {\n this.client = new Client(config);\n\n // Initialize context service\n this.context = new ContextService(this);\n } catch (error) {\n logError(`Failed to constructor:`, error);\n throw new AuthenticationError(`Failed to constructor: ${error}`);\n }\n }\n\n /**\n * Create a new session in the AgentBay cloud environment.\n *\n * @param params - Optional parameters for creating the session\n * @returns SessionResult containing the created session and request ID\n */\n async create(params: CreateSessionParams = {}): Promise<SessionResult> {\n try {\n // Create a default context for file transfer operations if none provided\n // and no context_syncs are specified\n const contextName = `file-transfer-context-${Date.now()}`;\n const contextResult = await this.context.get(contextName, true);\n if (contextResult.success && contextResult.context) {\n this.fileTransferContext = contextResult.context;\n // Add the context to the session params for file transfer operations\n const fileTransferContextSync = new ContextSync(\n contextResult.context.id,\n \"/temp/file-transfer\"\n );\n if (!params.contextSync) {\n params.contextSync = [];\n }\n log(`Adding context sync for file transfer operations: ${fileTransferContextSync}`);\n params.contextSync.push(fileTransferContextSync);\n }\n\n const request = new $_client.CreateMcpSessionRequest({\n authorization: \"Bearer \" + this.apiKey,\n });\n\n // Add labels if provided\n if (params.labels) {\n request.labels = JSON.stringify(params.labels);\n }\n\n // Add image_id if provided\n if (params.imageId) {\n request.imageId = params.imageId;\n }\n\n // Add McpPolicyId if provided\n if (params.mcpPolicyId) {\n request.mcpPolicyId = params.mcpPolicyId;\n }\n\n // Add VPC resource if specified\n request.vpcResource = params.isVpc || false;\n\n // Flag to indicate if we need to wait for context synchronization\n let needsContextSync = false;\n\n // Add context sync configurations if provided\n if (params.contextSync && params.contextSync.length > 0) {\n const persistenceDataList: CreateMcpSessionRequestPersistenceDataList[] = [];\n for (const contextSync of params.contextSync) {\n const persistenceItem = new CreateMcpSessionRequestPersistenceDataList({\n contextId: contextSync.contextId,\n path: contextSync.path,\n });\n\n // Convert policy to JSON string if provided\n if (contextSync.policy) {\n persistenceItem.policy = JSON.stringify(contextSync.policy);\n }\n\n persistenceDataList.push(persistenceItem);\n }\n request.persistenceDataList = persistenceDataList;\n needsContextSync = persistenceDataList.length > 0;\n }\n\n // Add BrowserContext as a ContextSync if provided\n if (params.browserContext) {\n // Create a simple sync policy for browser context\n const syncPolicy = {\n uploadPolicy: { autoUpload: params.browserContext.autoUpload },\n downloadPolicy: null,\n deletePolicy: null,\n bwList: null\n };\n\n // Create browser context sync item\n const browserContextSync = new CreateMcpSessionRequestPersistenceDataList({\n contextId: params.browserContext.contextId,\n path: BROWSER_DATA_PATH, // Using a constant path for browser data\n policy: JSON.stringify(syncPolicy)\n });\n\n // Add to persistence data list or create new one if not exists\n if (!request.persistenceDataList) {\n request.persistenceDataList = [];\n }\n request.persistenceDataList.push(browserContextSync);\n needsContextSync = true;\n }\n\n // Add browser recording persistence if enabled\n if (params.enableBrowserReplay) {\n // Create browser recording persistence configuration\n const recordPath = \"/home/guest/record\";\n const recordContextName = generateRandomContextName();\n const result = await this.context.get(recordContextName, true);\n const recordContextId = result.success ? result.contextId : \"\";\n const recordPersistence = new CreateMcpSessionRequestPersistenceDataList({\n contextId: recordContextId,\n path: recordPath,\n });\n\n // Add to persistence data list or create new one if not exists\n if (!request.persistenceDataList) {\n request.persistenceDataList = [];\n }\n request.persistenceDataList.push(recordPersistence);\n }\n\n // Log API request\n log(\"API Call: CreateMcpSession\");\n let requestLog = \"Request: \";\n if (request.imageId) {\n requestLog += `ImageId=${request.imageId}, `;\n }\n if (request.labels) {\n requestLog += `Labels=${request.labels}, `;\n }\n if (\n request.persistenceDataList &&\n request.persistenceDataList.length > 0\n ) {\n requestLog += `PersistenceDataList=${request.persistenceDataList.length} items, `;\n request.persistenceDataList.forEach((pd: CreateMcpSessionRequestPersistenceDataList, i: number) => {\n requestLog += `Item${i}[ContextId=${pd.contextId}, Path=${pd.path}`;\n if (pd.policy) {\n requestLog += `, Policy=${pd.policy}`;\n }\n requestLog += `], `;\n });\n }\n log(requestLog);\n\n const response = await this.client.createMcpSession(request);\n\n // Extract request ID\n const requestId = extractRequestId(response) || \"\";\n\n // Log response data with requestId\n log(\"response data =\", response.body?.data);\n if (requestId) {\n log(`requestId = ${requestId}`);\n }\n\n const sessionData = response.body;\n\n if (!sessionData || typeof sessionData !== \"object\") {\n return {\n requestId,\n success: false,\n errorMessage: \"Invalid response format: expected a dictionary\",\n };\n }\n\n const data = sessionData.data;\n if (!data || typeof data !== \"object\") {\n return {\n requestId,\n success: false,\n errorMessage:\n \"Invalid response format: 'data' field is not a dictionary\",\n };\n }\n\n const sessionId = data.sessionId;\n if (!sessionId) {\n return {\n requestId,\n success: false,\n errorMessage: \"SessionId not found in response\",\n };\n }\n\n // ResourceUrl is optional in CreateMcpSession response\n const resourceUrl = data.resourceUrl;\n\n log(\"session_id =\", sessionId);\n log(\"resource_url =\", resourceUrl);\n\n const session = new Session(this, sessionId);\n\n // Set VPC-related information from response\n session.isVpc = params.isVpc || false;\n if (data.networkInterfaceIp) {\n session.networkInterfaceIp = data.networkInterfaceIp;\n }\n if (data.httpPort) {\n session.httpPort = data.httpPort;\n }\n if (data.token) {\n session.token = data.token;\n }\n\n // Set browser recording state\n session.enableBrowserReplay = params.enableBrowserReplay || false;\n\n // Store the file transfer context ID if we created one\n session.fileTransferContextId = this.fileTransferContext ? this.fileTransferContext.id : null;\n // Store imageId used for this session\n (session as any).imageId = params.imageId;\n\n this.sessions.set(session.sessionId, session);\n\n // For VPC sessions, automatically fetch MCP tools information\n if (params.isVpc) {\n log(\"VPC session detected, automatically fetching MCP tools...\");\n try {\n const toolsResult = await session.listMcpTools();\n log(`Successfully fetched ${toolsResult.tools.length} MCP tools for VPC session (RequestID: ${toolsResult.requestId})`);\n } catch (error) {\n logError(`Warning: Failed to fetch MCP tools for VPC session: ${error}`);\n // Continue with session creation even if tools fetch fails\n }\n }\n\n // If we have persistence data, wait for context synchronization\n if (needsContextSync) {\n log(\"Waiting for context synchronization to complete...\");\n\n // Wait for context synchronization to complete\n const maxRetries = 150; // Maximum number of retries\n const retryInterval = 1500; // Milliseconds to wait between retries\n\n for (let retry = 0; retry < maxRetries; retry++) {\n try {\n // Get context status data\n const infoResult = await session.context.info();\n\n // Check if all context items have status \"Success\" or \"Failed\"\n let allCompleted = true;\n let hasFailure = false;\n\n for (const item of infoResult.contextStatusData) {\n log(`Context ${item.contextId} status: ${item.status}, path: ${item.path}`);\n\n if (item.status !== \"Success\" && item.status !== \"Failed\") {\n allCompleted = false;\n break;\n }\n\n if (item.status === \"Failed\") {\n hasFailure = true;\n logError(`Context synchronization failed for ${item.contextId}: ${item.errorMessage}`);\n }\n }\n\n if (allCompleted || infoResult.contextStatusData.length === 0) {\n if (hasFailure) {\n log(\"Context synchronization completed with failures\");\n } else {\n log(\"Context synchronization completed successfully\");\n }\n break;\n }\n\n log(`Waiting for context synchronization, attempt ${retry+1}/${maxRetries}`);\n await new Promise(resolve => setTimeout(resolve, retryInterval));\n } catch (error) {\n logError(`Error checking context status on attempt ${retry+1}: ${error}`);\n await new Promise(resolve => setTimeout(resolve, retryInterval));\n }\n }\n }\n\n // Return SessionResult with request ID\n return {\n requestId,\n success: true,\n session,\n };\n } catch (error) {\n logError(\"Error calling create_mcp_session:\", error);\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to create session: ${error}`,\n };\n }\n }\n\n /**\n * List all available sessions.\n *\n * @returns A list of session objects.\n */\n list(): Session[] {\n return Array.from(this.sessions.values());\n }\n\n /**\n * List sessions filtered by the provided labels with pagination support.\n * It returns sessions that match all the specified labels.\n *\n * **Breaking Change**: This method currently only accepts ListSessionParams parameters,\n *\n * @param params - Parameters including labels and pagination options (required)\n * @returns API response with sessions list and pagination info\n */\n async listByLabels(params?: ListSessionParams): Promise<SessionListResult> {\n if (!params) {\n params = {\n maxResults: 10,\n labels: {},\n };\n }\n\n try {\n // Convert labels to JSON\n const labelsJSON = JSON.stringify(params.labels);\n\n //Build request object with support for pagination parameters\n const listSessionRequest = new ListSessionRequest({\n authorization: `Bearer ${this.apiKey}`,\n labels: labelsJSON,\n maxResults: params.maxResults || 10,\n ...(params.nextToken && { nextToken: params.nextToken }),\n });\n\n log(\"API Call: ListSession\");\n log(\n `Request: Labels=${labelsJSON}, MaxResults=${params.maxResults || 10}${\n params.nextToken ? `, NextToken=${params.nextToken}` : \"\"\n }`\n );\n\n const response = await this.client.listSession(listSessionRequest);\n const body = response.body;\n const requestId = extractRequestId(body?.requestId) || \"\";\n\n // Check for errors in the response\n if (\n body?.data &&\n typeof body.data === \"object\" &&\n body.success &&\n body.success !== true\n ) {\n return {\n requestId,\n success: false,\n errorMessage: \"Failed to list sessions by labels\",\n data: [],\n nextToken: \"\",\n maxResults: params.maxResults || 10,\n totalCount: 0,\n };\n }\n\n const sessions: Session[] = [];\n let nextToken = \"\";\n let maxResults = params.maxResults || 10;\n let totalCount = 0;\n\n log(\"body =\", body);\n\n // Extract pagination information\n if (body && typeof body === \"object\") {\n nextToken = body.nextToken || \"\";\n maxResults = parseInt(String(body.maxResults || 0)) || maxResults;\n totalCount = parseInt(String(body.totalCount || 0));\n }\n\n // Extract session data\n const responseData = body?.data;\n\n // Handle both list and dict responses\n if (Array.isArray(responseData)) {\n // Data is a list of session objects\n for (const sessionData of responseData) {\n if (sessionData && typeof sessionData === \"object\") {\n const sessionId = (sessionData as any).sessionId; // Capital S and I to match Python\n if (sessionId) {\n // Check if we already have this session in our cache\n let session = this.sessions.get(sessionId);\n if (!session) {\n // Create a new session object\n session = new Session(this, sessionId);\n this.sessions.set(sessionId, session);\n }\n sessions.push(session);\n }\n }\n }\n }\n\n // Return SessionListResult with request ID and pagination info\n return {\n requestId,\n success: true,\n data: sessions,\n nextToken,\n maxResults,\n totalCount,\n };\n } catch (error) {\n logError(\"Error calling list_session:\", error);\n return {\n requestId: \"\",\n success: false,\n data: [],\n errorMessage: `Failed to list sessions by labels: ${error}`,\n };\n }\n }\n\n /**\n * Delete a session by session object.\n *\n * @param session - The session to delete.\n * @param syncContext - Whether to sync context data (trigger file uploads) before deleting the session. Defaults to false.\n * @returns DeleteResult indicating success or failure and request ID\n */\n async delete(session: Session, syncContext = false): Promise<DeleteResult> {\n try {\n // Delete the session and get the result\n if (session.enableBrowserReplay) {\n syncContext = true;\n }\n const deleteResult = await session.delete(syncContext);\n\n this.sessions.delete(session.sessionId);\n\n // Return the DeleteResult obtained from session.delete()\n return deleteResult;\n } catch (error) {\n logError(\"Error deleting session:\", error);\n return {\n requestId: \"\",\n success: false,\n errorMessage: `Failed to delete session ${session.sessionId}: ${error}`,\n };\n }\n }\n\n /**\n *\n * @param sessionId - The ID of the session to remove.\n */\n public removeSession(sessionId: string): void {\n this.sessions.delete(sessionId);\n }\n\n // For internal use by the Session class\n getClient(): Client {\n return this.client;\n }\n\n getAPIKey(): string {\n return this.apiKey;\n }\n}\n\n/**\n * Creates a new AgentBay client using default configuration.\n * This is a convenience function that allows creating an AgentBay instance without a config parameter.\n *\n * @param apiKey - API key for authentication\n * @returns A new AgentBay instance with default configuration\n */\nexport function newAgentBayWithDefaults(apiKey: string): AgentBay {\n return new AgentBay({ apiKey });\n}\n","(function () {\n require('./lib/main').config(\n Object.assign(\n {},\n require('./lib/env-options'),\n require('./lib/cli-options')(process.argv)\n )\n )\n})()\n","// Export the client and models\nimport { Client } from \"./client\";\nexport { Client } from \"./client\";\nexport * from \"./models/model\";\n\nexport default Client;\n","// This file is auto-generated, don't edit it\nimport * as $dara from \"@darabonba/typescript\";\nimport OpenApi from \"@alicloud/openapi-core\";\nimport { OpenApiUtil, $OpenApiUtil } from \"@alicloud/openapi-core\";\n\nimport * as $_model from \"./models/model\";\nexport * from \"./models/model\";\n\nexport class Client extends OpenApi {\n constructor(config: $OpenApiUtil.Config) {\n super(config);\n this._signatureAlgorithm = \"v2\";\n this._endpointRule = \"\";\n this.checkConfig(config);\n this._endpoint = this.getEndpoint(\n \"wuyingai\",\n this._regionId,\n this._endpointRule,\n this._network,\n this._suffix,\n this._endpointMap,\n this._endpoint\n );\n }\n\n getEndpoint(\n productId: string,\n regionId: string,\n endpointRule: string,\n network: string,\n suffix: string,\n endpointMap: { [key: string]: string },\n endpoint: string\n ): string {\n if (!$dara.isNull(endpoint)) {\n return endpoint;\n }\n\n if (!$dara.isNull(endpointMap) && !$dara.isNull(endpointMap[regionId])) {\n return endpointMap[regionId];\n }\n\n return OpenApiUtil.getEndpointRules(\n productId,\n regionId,\n endpointRule,\n network,\n suffix\n );\n }\n\n /**\n * Call MCP tool\n *\n * @param request - CallMcpToolRequest\n * @param runtime - runtime options for this request RuntimeOptions\n * @returns CallMcpToolResponse\n */\n async callMcpToolWithOptions(\n request: $_model.CallMcpToolRequest,\n runtime: $dara.RuntimeOptions\n ): Promise<$_model.CallMcpToolResponse> {\n request.validate();\n const body: { [key: string]: any } = {};\n if (!$dara.isNull(request.args)) {\n body[\"Args\"] = request.args;\n }\n\n if (!$dara.isNull(request.authorization)) {\n body[\"Authorization\"] = request.authorization;\n }\n\n if (!$dara.isNull(request.externalUserId)) {\n body[\"ExternalUserId\"] = request.externalUserId;\n }\n\n if (!$dara.isNull(request.imageId)) {\n body[\"ImageId\"] = request.imageId;\n }\n\n if (!$dara.isNull(request.name)) {\n body[\"Name\"] = request.name;\n }\n\n if (!$dara.isNull(request.server)) {\n body[\"Server\"] = request.server;\n }\n\n if (!$dara.isNull(request.sessionId)) {\n body[\"SessionId\"] = request.sessionId;\n }\n\n if (!$dara.isNull(request.tool)) {\n body[\"Tool\"] = request.tool;\n }\n\n const req = new $OpenApiUtil.OpenApiRequest({\n body: OpenApiUtil.parseToMap(body),\n });\n const params = new $OpenApiUtil.Params({\n action: \"CallMcpTool\",\n version: \"2025-05-06\",\n protocol: \"HTTPS\",\n pathname: \"/\",\n method: \"POST\",\n authType: \"Anonymous\",\n style: \"RPC\",\n reqBodyType: \"formData\",\n bodyType: \"json\",\n });\n return $dara.cast<$_model.CallMcpToolResponse>(\n await this.callApi(params, req, runtime),\n new $_model.CallMcpToolResponse({})\n );\n }\n\n /**\n * Call MCP tool\n *\n * @param request - CallMcpToolRequest\n * @returns CallMcpToolResponse\n */\n async callMcpTool(\n request: $_model.CallMcpToolRequest\n ): Promise<$_model.CallMcpToolResponse> {\n const runtime = new $dara.RuntimeOptions({});\n return await this.callMcpToolWithOptions(request, runtime);\n }\n\n /**\n * Create MCP session\n *\n * @param tmpReq - CreateMcpSessionRequest\n * @param runtime - runtime options for this request RuntimeOptions\n * @returns CreateMcpSessionResponse\n */\n async createMcpSessionWithOptions(\n tmpReq: $_model.CreateMcpSessionRequest,\n runtime: $dara.RuntimeOptions\n ): Promise<$_model.CreateMcpSessionResponse> {\n tmpReq.validate();\n const request = new $_model.CreateMcpSessionShrinkRequest({});\n OpenApiUtil.convert(tmpReq, request);\n if (!$dara.isNull(tmpReq.persistenceDataList)) {\n request.persistenceDataListShrink =\n OpenApiUtil.arrayToStringWithSpecifiedStyle(\n tmpReq.persistenceDataList,\n \"PersistenceDataList\",\n \"json\"\n );\n }\n\n const body: { [key: string]: any } = {};\n if (!$dara.isNull(request.authorization)) {\n body[\"Authorization\"] = request.authorization;\n }\n\n if (!$dara.isNull(request.contextId)) {\n body[\"ContextId\"] = request.contextId;\n }\n\n if (!$dara.isNull(request.externalUserId)) {\n body[\"ExternalUserId\"] = request.externalUserId;\n }\n\n if (!$dara.isNull(request.imageId)) {\n body[\"ImageId\"] = request.imageId;\n }\n\n if (!$dara.isNull(request.labels)) {\n body[\"Labels\"] = request.labels;\n }\n\n if (!$dara.isNull(request.mcpPolicyId)) {\n body[\"McpPolicyId\"] = request.mcpPolicyId;\n }\n\n if (!$dara.isNull(request.persistenceDataListShrink)) {\n body[\"PersistenceDataList\"] = request.persistenceDataListShrink;\n }\n\n if (!$dara.isNull(request.sessionId)) {\n body[\"SessionId\"] = request.sessionId;\n }\n\n if (!$dara.isNull(request.vpcResource)) {\n body[\"VpcResource\"] = request.vpcResource;\n }\n\n const req = new $OpenApiUtil.OpenApiRequest({\n body: OpenApiUtil.parseToMap(body),\n });\n const params = new $OpenApiUtil.Params({\n action: \"CreateMcpSession\",\n version: \"2025-05-06\",\n protocol: \"HTTPS\",\n pathname: \"/\",\n method: \"POST\",\n authType: \"Anonymous\",\n style: \"RPC\",\n reqBodyType: \"formData\",\n bodyType: \"json\",\n });\n return $dara.cast<$_model.CreateMcpSessionResponse>(\n await this.callApi(params, req, runtime),\n new $_model.CreateMcpSessionResponse({})\n );\n }\n\n /**\n * Create MCP session\n *\n * @param request - CreateMcpSessionRequest\n * @returns CreateMcpSessionResponse\n */\n async createMcpSession(\n request: $_model.CreateMcpSessionRequest\n ): Promise<$_model.CreateMcpSessionResponse> {\n const runtime = new $dara.RuntimeOptions({});\n return await this.createMcpSessionWithOptions(request, runtime);\n }\n\n /**\n * Delete persistent context\n *\n * @param request - DeleteContextRequest\n * @param runtime - runtime options for this request RuntimeOptions\n * @returns DeleteContextResponse\n */\n async deleteContextWithOptions(\n request: $_model.DeleteContextRequest,\n runtime: $dara.RuntimeOptions\n ): Promise<$_model.DeleteContextResponse> {\n request.validate();\n const body: { [key: string]: any } = {};\n if (!$dara.isNull(request.authorization)) {\n body[\"Authorization\"] = request.authorization;\n }\n\n if (!$dara.isNull(request.id)) {\n body[\"Id\"] = request.id;\n }\n\n const req = new $OpenApiUtil.OpenApiRequest({\n body: OpenApiUtil.parseToMap(body),\n });\n const params = new $OpenApiUtil.Params({\n action: \"DeleteContext\",\n version: \"2025-05-06\",\n protocol: \"HTTPS\",\n pathname: \"/\",\n method: \"POST\",\n authType: \"Anonymous\",\n style: \"RPC\",\n reqBodyType: \"formData\",\n bodyType: \"json\",\n });\n return $dara.cast<$_model.DeleteContextResponse>(\n await this.callApi(params, req, runtime),\n new $_model.DeleteContextResponse({})\n );\n }\n\n /**\n * Delete persistent context\n *\n * @param request - DeleteContextRequest\n * @returns DeleteContextResponse\n */\n async deleteContext(\n request: $_model.DeleteContextRequest\n ): Promise<$_model.DeleteContextResponse> {\n const runtime = new $dara.RuntimeOptions({});\n return await this.deleteContextWithOptions(request, runtime);\n }\n\n /**\n * Get context\n *\n * @param request - GetContextRequest\n * @param runtime - runtime options for this request RuntimeOptions\n * @returns GetContextResponse\n */\n async getContextWithOptions(\n request: $_model.GetContextRequest,\n runtime: $dara.RuntimeOptions\n ): Promise<$_model.GetContextResponse> {\n request.validate();\n const body: { [key: string]: any } = {};\n if (!$dara.isNull(request.allowCreate)) {\n body[\"AllowCreate\"] = request.allowCreate;\n }\n\n if (!$dara.isNull(request.authorization)) {\n body[\"Authorization\"] = request.authorization;\n }\n\n if (!$dara.isNull(request.name)) {\n body[\"Name\"] = request.name;\n }\n\n const req = new $OpenApiUtil.OpenApiRequest({\n body: OpenApiUtil.parseToMap(body),\n });\n const params = new $OpenApiUtil.Params({\n action: \"GetContext\",\n version: \"2025-05-06\",\n protocol: \"HTTPS\",\n pathname: \"/\",\n method: \"POST\",\n authType: \"Anonymous\",\n style: \"RPC\",\n reqBodyType: \"formData\",\n bodyType: \"json\",\n });\n return $dara.cast<$_model.GetContextResponse>(\n await this.callApi(params, req, runtime),\n new $_model.GetContextResponse({})\n );\n }\n\n /**\n * Get context\n *\n * @param request - GetContextRequest\n * @returns GetContextResponse\n */\n async getContext(\n request: $_model.GetContextRequest\n ): Promise<$_model.GetContextResponse> {\n const runtime = new $dara.RuntimeOptions({});\n return await this.getContextWithOptions(request, runtime);\n }\n\n /**\n * Get context information\n *\n * @param request - GetContextInfoRequest\n * @param runtime - runtime options for this request RuntimeO