feat(browser,mcp): resolve environment and credentials from DB in exec
- POST /exec now accepts environmentId (UUID) and credentials (alias → UUID) instead of raw payloads; resolves entities via EnvironmentService and CredentialService before passing data to browserService.exec - exec_code MCP tool updated with same schema: environmentId + credentials map - CredentialModule imported into BrowserModule and McpModule - docs(scenario): rewrite script runtime section for single context argument - docs(mcp): update exec_code description to reflect new parameter shapes - style: reorder imports across server source (formatter)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { IsObject, IsOptional, IsString, IsUrl } from "class-validator";
|
||||
import type { EnvironmentData } from "../../environment/environment.entity";
|
||||
import { IsObject, IsOptional, IsString, IsUUID, IsUrl } from "class-validator";
|
||||
|
||||
export class ExecDto {
|
||||
@ApiPropertyOptional({
|
||||
@@ -23,27 +22,27 @@ export class ExecDto {
|
||||
|
||||
@ApiProperty({
|
||||
description:
|
||||
"JavaScript code to execute. Receives `page` (Playwright Page) and `context` (BrowserContext) as arguments. May be async. Return value is serialised and returned.",
|
||||
example: "return await page.title();",
|
||||
"Async JavaScript body. Use `context.page` for Playwright, `context.getEnv(key)`, `context.getCredential(alias)`, `context.runSnippet(name, ...args)`.",
|
||||
example: "return await context.page.title();",
|
||||
})
|
||||
@IsString()
|
||||
code: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"Key/value map of environment variables available via `helpers.env` and `helpers.getEnv()` in the script.",
|
||||
example: { BASE_URL: "https://example.com" },
|
||||
"UUID of an existing environment entity. Its key/value data is available via `context.env` and `context.getEnv()` in the script.",
|
||||
example: "a6a1fca5-0f61-48ed-ae97-011dc7236387",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
environment?: EnvironmentData;
|
||||
@IsUUID()
|
||||
environmentId?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"Key/value map of credentials available via `helpers.getCredential()` in the script.",
|
||||
example: { admin: { username: "user", password: "pass" } },
|
||||
"Map of alias → credential UUID. Each credential is loaded from the DB and available via `context.getCredential(alias)` in the script.",
|
||||
example: { pkcs_key: "e3b0c442-98fc-11d8-9669-0800200c9a66" },
|
||||
})
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
credentials?: Record<string, unknown>;
|
||||
credentials?: Record<string, string>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user