feat: implement centralized artifact storage with session isolation
Add comprehensive artifact storage system with session-specific directories:
- Add --artifact-dir CLI option and PLAYWRIGHT_MCP_ARTIFACT_DIR env var
- Create ArtifactManager class for session-specific artifact organization
- Implement ArtifactManagerRegistry for multi-session support
- Add tool call logging with JSON persistence in tool-calls.json
- Update screenshot, video, and PDF tools to use centralized storage
- Add browser_configure_artifacts tool for per-session control
- Support dynamic enable/disable without server restart
- Maintain backward compatibility when artifact storage not configured
Directory structure: {artifactDir}/{sessionId}/[artifacts, videos/, tool-calls.json]
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
ecedcc48d6
commit
d8202f6694
12 changed files with 727 additions and 93 deletions
|
|
@ -20,6 +20,7 @@ import { defineTabTool } from './tool.js';
|
|||
import * as javascript from '../javascript.js';
|
||||
import { outputFile } from '../config.js';
|
||||
import { generateLocator } from './utils.js';
|
||||
import { ArtifactManagerRegistry } from '../artifactManager.js';
|
||||
|
||||
import type * as playwright from 'playwright';
|
||||
|
||||
|
|
@ -53,7 +54,19 @@ const screenshot = defineTabTool({
|
|||
|
||||
handle: async (tab, params, response) => {
|
||||
const fileType = params.raw ? 'png' : 'jpeg';
|
||||
const fileName = await outputFile(tab.context.config, params.filename ?? `page-${new Date().toISOString()}.${fileType}`);
|
||||
|
||||
// Use centralized artifact storage if configured
|
||||
let fileName: string;
|
||||
const registry = ArtifactManagerRegistry.getInstance();
|
||||
const artifactManager = tab.context.sessionId ? registry.getManager(tab.context.sessionId) : undefined;
|
||||
|
||||
if (artifactManager) {
|
||||
const defaultName = params.filename ?? `page-${new Date().toISOString()}.${fileType}`;
|
||||
fileName = artifactManager.getArtifactPath(defaultName);
|
||||
} else {
|
||||
fileName = await outputFile(tab.context.config, params.filename ?? `page-${new Date().toISOString()}.${fileType}`);
|
||||
}
|
||||
|
||||
const options: playwright.PageScreenshotOptions = {
|
||||
type: fileType,
|
||||
quality: fileType === 'png' ? undefined : 50,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue