Class CaptureService
java.lang.Object
com.shaft.mcp.CaptureService
MCP adapter for deterministic managed-browser SHAFT Capture recording.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classStructured request fields for the Playwright-codegen-compatible MCP start tool. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.shaft.capture.runtime.CaptureStatuscheckpoint(String description, String kind) Adds a human-review checkpoint to the active recording.codeBlocks(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, String driverVariableName) Generates deterministic copy-paste code blocks from a persisted Capture session without replaying.List<com.shaft.capture.generate.CodegenFeatureCatalog.Feature> Returns the Playwright codegen feature inventory and SHAFT support mapping.com.shaft.capture.generate.CaptureGenerationResultgenerate(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean aiPreview, String enrichmentPreviewPath, boolean applyEnrichment, boolean approveEnrichment, boolean allowLocalAi, boolean allowRemoteAi) Generates a deterministic SHAFT TestNG test from a persisted Capture session.generatePlaywrightReplay(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName) Generates, compiles, and optionally replays a SHAFT Playwright TestNG test from a Capture session.generateReplay(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName) Generates, compiles, and optionally replays a deterministic SHAFT TestNG test from a Capture session.playwrightCodeBlocks(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, String driverVariableName) Generates deterministic copy-paste SHAFT Playwright code blocks from a persisted Capture session.com.shaft.capture.runtime.CaptureStatusLaunches a fresh SHAFT-managed browser and starts deterministic capture.com.shaft.capture.runtime.CaptureStatusLaunches a fresh SHAFT-managed browser with Playwright-codegen-shaped options.com.shaft.capture.runtime.CaptureStatusstatus()Returns safe recorder status without captured values.com.shaft.capture.runtime.CaptureStatusstop(boolean discard) Stops the active recording.
-
Constructor Details
-
CaptureService
public CaptureService()Creates the default MCP Capture service.
-
-
Method Details
-
start
@Tool(name="capture_start", description="starts a privacy-safe SHAFT managed-browser recording with live browser controls") public com.shaft.capture.runtime.CaptureStatus start(String targetUrl, String browser, String outputPath, boolean headless) Launches a fresh SHAFT-managed browser and starts deterministic capture.- Parameters:
targetUrl- initial http, https, or file URLbrowser- Chrome or Edge; blank selects ChromeoutputPath- capture JSON path; blank selects a timestamped recordingheadless- whether to launch without a visible window- Returns:
- safe recorder status
-
startWithOptions
@Tool(name="capture_start_codegen", description="starts SHAFT Capture with Playwright-codegen-compatible options and live browser controls") public com.shaft.capture.runtime.CaptureStatus startWithOptions(CaptureService.CaptureCodegenStartRequest request) Launches a fresh SHAFT-managed browser with Playwright-codegen-shaped options.- Parameters:
request- structured codegen recording request- Returns:
- safe recorder status
-
codegenFeatures
@Tool(name="capture_codegen_features", description="returns Playwright codegen features and how SHAFT Capture/MCP maps each feature") public List<com.shaft.capture.generate.CodegenFeatureCatalog.Feature> codegenFeatures()Returns the Playwright codegen feature inventory and SHAFT support mapping.- Returns:
- codegen feature mapping
-
status
@Tool(name="capture_status", description="returns SHAFT Capture session, browser, URL, event count, warnings, and output status") public com.shaft.capture.runtime.CaptureStatus status()Returns safe recorder status without captured values.- Returns:
- current or final recorder status
-
stop
@Tool(name="capture_stop", description="stops SHAFT Capture; after COMPLETED, call capture_code_blocks and ask snippet or insertion") public com.shaft.capture.runtime.CaptureStatus stop(boolean discard) Stops the active recording.- Parameters:
discard- whether to delete capture artifacts after shutdown- Returns:
- final recorder status
-
checkpoint
@Tool(name="capture_checkpoint", description="records a USER_MARKER, ASSERTION, PAGE_TRANSITION, or RECOVERY checkpoint") public com.shaft.capture.runtime.CaptureStatus checkpoint(String description, String kind) Adds a human-review checkpoint to the active recording.- Parameters:
description- checkpoint descriptionkind- checkpoint kind; blank selects USER_MARKER- Returns:
- safe recorder status
-
generateReplay
@Tool(name="capture_generate_replay", description="generates, compiles, optionally replays, and returns copy-paste SHAFT code blocks") public McpCaptureReplayResult generateReplay(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName) Generates, compiles, and optionally replays a deterministic SHAFT TestNG test from a Capture session.- Parameters:
sessionPath- persisted Capture JSON path inside the MCP workspaceoutputDirectory- generated project root inside the MCP workspacepackageName- generated Java packageclassName- optional generated class nameoverwrite- whether existing artifacts may be replacedreplay- whether to execute the generated testuseAi- whether to request optional AI enrichment previewallowLocalAi- explicit approval for local inferenceallowRemoteAi- explicit approval for remote inferencedriverVariableName- Java driver variable name used in extracted snippets- Returns:
- generation report plus copy-paste code blocks
-
generatePlaywrightReplay
@Tool(name="playwright_capture_generate_replay", description="generates, compiles, optionally replays, and returns copy-paste SHAFT Playwright code blocks") public McpCaptureReplayResult generatePlaywrightReplay(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean useAi, boolean allowLocalAi, boolean allowRemoteAi, String driverVariableName) Generates, compiles, and optionally replays a SHAFT Playwright TestNG test from a Capture session.- Parameters:
sessionPath- persisted Capture JSON path inside the MCP workspaceoutputDirectory- generated project root inside the MCP workspacepackageName- generated Java packageclassName- optional generated class nameoverwrite- whether existing artifacts may be replacedreplay- whether to execute the generated testuseAi- whether to request optional AI enrichment previewallowLocalAi- explicit approval for local inferenceallowRemoteAi- explicit approval for remote inferencedriverVariableName- Java driver variable name used in extracted snippets- Returns:
- generation report plus copy-paste code blocks
-
codeBlocks
@Tool(name="capture_code_blocks", description="generates a Java full-class snippet plus agent guidance for repo-aware insertion") public McpCaptureReplayResult codeBlocks(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, String driverVariableName) Generates deterministic copy-paste code blocks from a persisted Capture session without replaying.- Parameters:
sessionPath- persisted Capture JSON path inside the MCP workspaceoutputDirectory- generated project root inside the MCP workspacepackageName- generated Java packageclassName- optional generated class nameoverwrite- whether existing artifacts may be replaceddriverVariableName- Java driver variable name used in extracted snippets- Returns:
- generated snippets and report
-
playwrightCodeBlocks
@Tool(name="playwright_capture_code_blocks", description="generates a Java full-class snippet plus agent guidance for SHAFT Playwright insertion") public McpCaptureReplayResult playwrightCodeBlocks(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, String driverVariableName) Generates deterministic copy-paste SHAFT Playwright code blocks from a persisted Capture session.- Parameters:
sessionPath- persisted Capture JSON path inside the MCP workspaceoutputDirectory- generated project root inside the MCP workspacepackageName- generated Java packageclassName- optional generated class nameoverwrite- whether existing artifacts may be replaceddriverVariableName- Java driver variable name used in extracted snippets- Returns:
- generated snippets and report
-
generate
public com.shaft.capture.generate.CaptureGenerationResult generate(String sessionPath, String outputDirectory, String packageName, String className, boolean overwrite, boolean replay, boolean aiPreview, String enrichmentPreviewPath, boolean applyEnrichment, boolean approveEnrichment, boolean allowLocalAi, boolean allowRemoteAi) Generates a deterministic SHAFT TestNG test from a persisted Capture session.- Parameters:
sessionPath- persisted Capture JSON pathoutputDirectory- generated project rootpackageName- generated Java packageclassName- optional generated class nameoverwrite- whether existing artifacts may be replacedreplay- whether to execute the compiled generated testaiPreview- whether to request a review-only AI proposalenrichmentPreviewPath- preview path to write or applyapplyEnrichment- whether to apply the reviewed previewapproveEnrichment- explicit approval to apply the previewallowLocalAi- explicit approval for local inferenceallowRemoteAi- explicit approval for remote inference- Returns:
- generated artifacts and validation report
-