Skip to content

Conversation

@fg-nava
Copy link
Collaborator

@fg-nava fg-nava commented Aug 14, 2025

Ticket

Adds Playwright artifact storage and management capabilities

Changes

  • schema/db: Add PlaywrightArtifact model in prisma/schema.prisma; create migration prisma/migrations/20250814205016_add_playwright_artifacts/migration.sql with mastra_artifacts table and indexes.
  • storage: Add src/mastra/storage-artifacts.ts with ArtifactStorage class for CRUD operations on Playwright artifacts.
  • watcher: Add src/mastra/artifact-watcher.ts with ArtifactWatcher class to monitor output directories and auto-store files with metadata extraction.
  • agents: Update src/mastra/agents/data-ops-agent.ts to include artifact tools and descriptions; switch src/mastra/agents/web-automation-agent.ts model from Gemini to Claude.
  • mcp: Update src/mastra/mcp.ts to create unique session-based output directories and start artifact watcher.
  • gitignore: Add vertex-ai-credentials.json to .gitignore (for future use)

Context for reviewers

Implements automatic capture and database storage of Playwright artifacts (screenshots, traces, session data). The watcher monitors output directories in real-time and stores files with extracted trace/thread IDs. Data ops agent can now query and manage these artifacts. Session-based directories prevent file conflicts across concurrent runs.

Test Example

Database viewer showing the PlaywrightArtifa
Screenshot 2025-08-14 at 6 39 20 PM
cts table

@fg-nava fg-nava changed the title feat: playwright artifacts prisma model, anthropicVertex provider feat: playwright artifacts prisma model Aug 15, 2025
return mimeTypes[ext] || 'application/octet-stream';
}

private extractIds(fileName: string): { traceId: string | null; threadId: string | null } {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still haven't been able to extract traceId and threadId yet for each artifact written to the table

fileType,
mimeType,
size: content.length,
content: Buffer.isBuffer(content) ? content : Buffer.from(content),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still unable to confirm content is safely written to the db

const outputDir = path.join(process.cwd(), 'artifacts', sessionId);

// Start the artifact watcher for this session
startArtifactWatcher(outputDir, sessionId);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fs.watch to look for new (expected) or existing (unexpected) files and handles them with artifactStorage.storeArtifact

@fg-nava fg-nava requested a review from KayTV August 15, 2025 17:25
@fg-nava fg-nava changed the title feat: playwright artifacts prisma model feat: migrate traces and artifacts storage to GCP deployed db Aug 19, 2025
Copy link
Collaborator

@KayTV KayTV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving so we can move forward - I still need to setup mine, but let's get going!

Looks good :)

@fg-nava fg-nava merged commit 1c4862d into main Aug 19, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants