Skip to content

Latest commit

ย 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Pega Agent Plugin

Third-party AI-powered browser extension for Pega Infinity case workers

Release License Contributors Stars

TypeScript Chrome Extension AI

โš ๏ธ Disclaimer: This is NOT an official Pegasystems product. It's an independent open-source community project.


๐Ÿ“‹ Table of Contents


โœจ Features

๐ŸŽฏ Core Capabilities

Feature Description Status
๐Ÿง  Pega-Aware Intelligence Auto-detects Pega apps, extracts case context, understands domain โœ… Stable
๐Ÿ”’ Privacy-First PII Protection 8 categories, field-level masking, tokenization before transmission โœ… Stable
๐Ÿ’ฌ Natural Language Commands 11 supported intents, local & AI-powered โœ… Stable
๐Ÿ“Š Case Summarization Auto-generated 4-part summaries with risk signals โœ… Stable
๐ŸŽฏ Action Planning 14 action types with smart waiting & confirmation โœ… Stable
๐Ÿ‘๏ธ Visual Understanding Screenshot capture & visual analysis โœ… Stable
๐Ÿ”„ Workflow Automation Multi-step workflows with self-healing โœ… Stable
๐Ÿ”Œ MCP Server Full Model Context Protocol implementation โœ… Stable

๐ŸŽญ Playwright & Stagehand-Inspired Features

Advanced browser automation with self-healing capabilities

Inspired by industry-leading tools like Playwright and Stagehand, the extension includes powerful headless browser automation features:

๐ŸŽฏ Smart Waiting Strategies

Unlike traditional scripts that use fixed delays, we use intelligent waiting:

Strategy Use Case Example
WAIT_FOR_ELEMENT Wait for element to exist Wait for submit button to appear
WAIT_FOR_VISIBLE Wait for element to be visible Wait for modal to fade in
WAIT_FOR_ENABLED Wait for element to be clickable Wait for disabled input to become enabled
WAIT_FOR_HIDDEN Wait for element to disappear Wait for loading spinner to vanish
WAIT_FOR_TEXT Wait for text content Wait for "Success" message

Benefits:

  • โšก Faster execution - No arbitrary delays
  • ๐Ÿ”„ More reliable - Waits exactly as long as needed
  • ๐Ÿ›ก๏ธ Flakiness resistant - Adapts to network conditions

๐Ÿ” Self-Healing Selectors

When an action fails, the system automatically tries alternative strategies:

graph TD
    A[Action Fails] --> B{Try Alternative}
    B --> C[Test ID Selector]
    B --> D[Test Data Attribute]
    B --> E[ARIA Label]
    B --> F[Text Content]
    B --> G[CSS Selector]
    C --> H{Success?}
    D --> H
    E --> H
    F --> H
    G --> H
    H -->|Yes| I[Continue]
    H -->|No| J[Retry with Fallback]
Loading

Fallback Hierarchy:

  1. Test ID - data-test-id="submit-btn"
  2. Data Attribute - data-pega-action="submit"
  3. ARIA Label - aria-label="Submit case"
  4. Text Content - Button text matches
  5. CSS Selector - Structural selector
  6. Visual Position - Element coordinates (via screenshot analysis)

๐Ÿ“ธ Screenshot-Based Visual Validation

Capture and analyze screenshots to verify action results:

// Example: Verify form submission
await executeAction('CLICK', { selector: '#submit-btn' });
await executeAction('WAIT_FOR_HIDDEN', { selector: '#loading-spinner' });
await takeScreenshot();
await executeAction('VERIFY_VISIBLE', { selector: '.success-message' });

Visual Capabilities:

  • ๐Ÿ“ธ Screenshot capture - Full page or element-specific
  • ๐Ÿ” Visual analysis - Detect elements by appearance
  • โš–๏ธ Visual diffing - Compare before/after states
  • ๐ŸŽฏ Element detection - Find elements without selectors

๐Ÿ”„ Multi-Step Workflow Orchestration

Complex workflows with state management and conditional logic:

workflow:
  name: "Loan Application Intake"
  steps:
    - action: NAVIGATE
      url: "/cases/create/loan"
    - action: TYPE
      selector: "#applicant-name"
      value: "{NAME_1}"  # PII token
    - action: SELECT
      selector: "#loan-type"
      value: "Mortgage"
    - action: CONDITION
      condition: "amount > 100000"
      then: ESCALATE
      else: SAVE

Workflow Features:

  • ๐Ÿ“ Declarative syntax - YAML-based workflow definitions
  • ๐Ÿ”„ Loops - Batch process multiple cases
  • ๐Ÿ”€ Conditionals - If/then/else logic
  • โธ๏ธ Pause/Resume - Control execution
  • ๐Ÿ“Š State persistence - Share data between steps
  • ๐Ÿ”ง Error recovery - Automatic retries with fallback

๐ŸŽญ Action Execution Engine

Execute complex actions with built-in intelligence:

// Example: Smart form fill
await executeAction('TYPE', {
  selector: '#status',
  value: 'Pending Documentation',
  waitFor: 'enabled',        // Wait for input to be enabled
  validate: true,             // Verify value was set
  screenshotAfter: true       // Take screenshot after action
});

Action Options:

  • โฑ๏ธ Smart waiting - Automatic wait conditions
  • โœ”๏ธ Validation - Verify action succeeded
  • ๐Ÿ“ธ Screenshots - Capture before/after
  • ๐Ÿ”„ Retry - Automatic retry with fallback
  • ๐Ÿ“ Logging - Complete audit trail

๐Ÿงช Visual Regression Testing

Detect UI changes automatically:

Feature Description
Baseline Capture Store screenshots as baseline
Visual Diff Compare current vs baseline
Change Detection Highlight differences
Regression Alert Flag unexpected changes

๐Ÿง  Pega-Aware Intelligence

graph LR
    A[Pega App] --> B[Detector]
    B --> C{Framework?}
    C -->|Constellation| D[React]
    C -->|Cosmos| E[Angular]
    C -->|Classic| F[JSP]
    D --> G[Case Context]
    E --> G
    F --> G
    G --> H[Domain Knowledge]
Loading

Capabilities:

  • ๐ŸŽฏ Automatic Detection - Recognizes Pega by domain, UI patterns, DOM structure
  • ๐Ÿ–ผ๏ธ Framework Support - Constellation (React), Cosmos (Angular), Classic UI
  • ๐Ÿฆ Domain Knowledge - Financial Lending, Insurance Claims, Healthcare, Service Management
  • ๐Ÿ“‹ Case Context - Extracts ID, type, status, stage, assignee, urgency automatically

๐Ÿ”’ Privacy & Security First

PII Category Pattern Examples Mask Format
NAME First Name, Last Name, Full Name {NAME_1}
SSN Social Security, Tax ID, EIN {SSN_1}
DOB Date of Birth, Birth Date {DOB_1}
EMAIL Email, E-Mail Address {EMAIL_1}
PHONE Phone, Mobile, Cell, Telephone {PHONE_1}
ACCOUNT Account Number, Card Number, Policy # {ACCOUNT_1}
ADDRESS Address, Street, City, State, ZIP {ADDRESS_1}
INCOME Income, Salary, Annual Income {INCOME_1}

Security Guarantees:

  • โœ… Field-level masking before ANY external transmission
  • โœ… Session-scoped token isolation
  • โœ… Complete audit trail with masked tokens only
  • โœ… Never accesses Pega authentication tokens
  • โœ… Local-first processing with user control

๐Ÿ’ฌ Natural Language Commands

Local Intents (No LLM Required)
Command Action Confidence
Summarize this case Generate 4-part case summary 95%
Submit/Complete Submit case (requires confirmation) 90%
Save Persist changes 95%
Next Proceed to next step 92%
My queue Show assigned cases 88%
AI-Powered Intents
Command Action Requires
Update the status to [value] Field updates LLM
Escalate to supervisor Transfer case LLM
Create a new case Start new case LLM
Open case ABC-123 Navigate to case LLM
Find cases with... Search & filter LLM
Explain why... Get explanations LLM

๐Ÿ“Š Case Summarization

Auto-generated 4-part summaries when cases open:

## Situation
Brief description of what the case is about and why it was created.

## History
- 2025-03-01: Case created
- 2025-03-05: Initial review completed
- 2025-03-07: Documentation requested

## Current State
Status: Pending Documentation
Stage: Processing
Assignee: John Doe
Urgency: High

## Risk Signals
โš ๏ธ SLA at risk (3 days remaining)
โš ๏ธ Required field missing: .Description
โš ๏ธ No updates in 48 hours

๐ŸŽฏ Action Planning & Execution

14 Action Types:

  • CLICK - Click buttons, links, checkboxes
  • TYPE - Enter text in input fields
  • SELECT - Choose dropdown options
  • CLEAR - Clear field values
  • NAVIGATE - Navigate to URLs
  • WAIT_FOR_ELEMENT - Wait until element exists
  • WAIT_FOR_VISIBLE - Wait until element is visible
  • WAIT_FOR_ENABLED - Wait until element is enabled
  • WAIT_FOR_HIDDEN - Wait until element is hidden
  • WAIT_FOR_TEXT - Wait for text to appear
  • VERIFY_VISIBLE - Confirm element is visible
  • ASSERT_TEXT - Validate text content
  • SCROLL - Scroll page or element
  • WAIT - Fixed time delay (use sparingly)

๐Ÿ”Œ MCP Server

Model Context Protocol for external integrations:

Tool Description
pega_get_case_summary Generate case summary
pega_execute_action_plan Execute action plan
pega_get_dom_snapshot Get current DOM state
pega_detect_framework Detect Pega framework
pega_update_field Update field value
pega_click_action Click action button
pega_navigate_case Navigate to case
pega_wait_for Smart wait condition

Resources:

  • case_context - Current case information
  • dom_snapshot - Current DOM state
  • case_summary - Generated case summary
  • audit_log - Action audit trail

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • Chrome/Edge (Manifest V3 support)
  • LLM API Key (Anthropic, OpenAI, or Azure)

Installation

# Clone the repository
git clone https://github.com/skc-learn/pega-agent-plugin.git
cd pega-agent-plugin/pega-browser-agent

# Install dependencies
npm install

# Build the extension
npm run build

Load in Chrome

flowchart LR
    A[Open chrome://extensions/] --> B[Enable Developer Mode]
    B --> C[Click Load Unpacked]
    C --> D[Select pega-browser-agent Folder]
    D --> E[Extension Loaded!]
Loading

Steps:

  1. Navigate to chrome://extensions/
  2. Toggle Developer mode (top right)
  3. Click Load unpacked
  4. Select the pega-browser-agent folder

Configure API Key

// Via browser console
chrome.storage.session.set({ 'llm-api-key': 'your-api-key' });

// Or via extension settings
chrome://extensions/ โ†’ Pega Agent Plugin โ†’ Details โ†’ Extension settings

Usage

sequenceDiagram
    participant User
    participant Extension
    participant Pega
    participant LLM

    User->>Extension: Navigate to Pega app
    Extension->>Pega: Detect Pega & Extract context
    Extension->>Extension: Generate case summary
    Extension->>User: Display summary in side panel
    User->>Extension: "Update status to Pending"
    Extension->>LLM: Plan action
    LLM->>Extension: Return action plan
    Extension->>User: Show confirmation
    User->>Extension: Approve
    Extension->>Pega: Execute action
Loading
  1. Navigate to any Pega Infinity application
  2. Click the extension icon or press Ctrl+Shift+P
  3. Use natural language commands in the side panel

๐Ÿ“š Documentation

Document Description Link
๐Ÿ—๏ธ Architecture System design, components, data flow View
๐Ÿ“– API Reference Complete API documentation View
๐Ÿ‘จโ€๐Ÿ’ป Developer Guide Setup, development, testing View
๐Ÿ”’ Security Security model, PII protection, compliance View
๐Ÿ—บ๏ธ Roadmap 5-rung integration ladder View
๐Ÿ’ก Usage Examples Practical examples & troubleshooting View

๐Ÿ—๏ธ Architecture

graph TB
    subgraph "Browser Extension"
        SW[Service Worker]
        CS[Content Scripts]
        SP[Side Panel]
    end
    
    subgraph "Content Scripts"
        PD[Pega Detector]
        DP[DOM Parser]
        PM[PII Masker]
        AE[Action Executor]
    end
    
    subgraph "Service Worker"
        PL[Planner]
        LA[LLM Adapter]
        SG[Summary Generator]
        MC[MCP Server]
    end
    
    SW <--> CS
    SW <--> SP
    
    PD --> DP
    DP --> PM
    PM --> PL
    PL --> LA
    LA --> SG
    PL --> AE
    
    MC --> PL
    MC --> DP
Loading

Component Overview:

Component Responsibility
Service Worker Central message router, orchestrator, LLM adapter
Content Scripts DOM interaction, PII masking, action execution
Side Panel Chat-style UI controller
PII Masker Field classification & tokenization
DOM Parser Semantic DOM extraction
Planner Intent-to-action transformation
MCP Server External integration protocol

โš™๏ธ Configuration

Default Configuration

{
  "security": {
    "piiMaskingEnabled": true,
    "piiCategoriesToMask": [
      "NAME", "SSN", "DOB", "EMAIL", 
      "PHONE", "ACCOUNT", "ADDRESS", "INCOME"
    ],
    "auditLoggingEnabled": true
  },
  "llm": {
    "provider": "anthropic",
    "model": "claude-sonnet-4-20250514",
    "maxTokens": 1500,
    "temperature": 0.1
  },
  "pega": {
    "autoDetect": true,
    "allowedDomains": ["*.pegacloud.io", "*.pega.com"]
  },
  "roleRestrictions": {
    "caseWorker": [
      "SUMMARIZE_CASE", "UPDATE_FIELD", 
      "NEXT_STEP", "SAVE_CASE", "SHOW_QUEUE"
    ],
    "supervisor": ["*"],
    "readOnly": [
      "SUMMARIZE_CASE", "SHOW_QUEUE", "EXPLAIN"
    ]
  }
}

Multi-LLM Configuration

{
  "llm": {
    "provider": "multi",
    "providers": [
      {
        "name": "anthropic",
        "apiKey": "sk-ant-...",
        "models": ["claude-sonnet-4-20250514"]
      },
      {
        "name": "azure-openai",
        "endpoint": "https://your-resource.openai.azure.com/",
        "apiKey": "your-key",
        "models": ["gpt-4"]
      }
    ],
    "fallback": true
  }
}

๐Ÿงช Development

Development Workflow

# Clone the repository
git clone https://github.com/skc-learn/pega-agent-plugin.git
cd pega-agent-plugin/pega-browser-agent

# Install dependencies
npm install

# Development mode with hot reload
npm run dev

# Run tests
npm test

# Type checking
npm run type-check

# Linting
npm run lint

# Build for production
npm run build

# Package for distribution
npm run package

Project Structure

pega-browser-agent/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ content-scripts/     # DOM interaction
โ”‚   โ”‚   โ”œโ”€โ”€ pega-detector.ts
โ”‚   โ”‚   โ”œโ”€โ”€ dom-parser.ts
โ”‚   โ”‚   โ”œโ”€โ”€ pii-masker.ts
โ”‚   โ”‚   โ””โ”€โ”€ action-executor.ts
โ”‚   โ”œโ”€โ”€ service-worker/      # Background processing
โ”‚   โ”‚   โ”œโ”€โ”€ sw.ts
โ”‚   โ”‚   โ”œโ”€โ”€ planner.ts
โ”‚   โ”‚   โ”œโ”€โ”€ llm-adapter.ts
โ”‚   โ”‚   โ””โ”€โ”€ mcp-server.ts
โ”‚   โ”œโ”€โ”€ side-panel/          # UI panel
โ”‚   โ”‚   โ””โ”€โ”€ panel.ts
โ”‚   โ”œโ”€โ”€ shared/              # Common utilities
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts
โ”‚   โ”‚   โ”œโ”€โ”€ message-types.ts
โ”‚   โ”‚   โ””โ”€โ”€ pega-heuristics.ts
โ”‚   โ””โ”€โ”€ config/              # Configuration
โ”‚       โ””โ”€โ”€ default-config.ts
โ”œโ”€โ”€ tests/                   # Unit tests
โ”‚   โ”œโ”€โ”€ unit/
โ”‚   โ””โ”€โ”€ fixtures/
โ”œโ”€โ”€ public/                  # HTML/CSS assets
โ”œโ”€โ”€ manifest.json            # Extension manifest
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ””โ”€โ”€ webpack.config.cjs

Testing

# Run all tests
npm test

# Run tests in watch mode
npm test -- --watch

# Run tests with coverage
npm test -- --coverage

# Run specific test file
npm test -- pii-masker.test.ts

Test Coverage:

  • โœ… PII Masker: 8 categories ร— 100+ test cases
  • โœ… Intent Classifier: 11 intents ร— positive/negative examples
  • โœ… Session isolation tests
  • โœ… Token resolution tests

๐Ÿ—บ๏ธ Roadmap

timeline
    title Pega Agent Plugin Roadmap
    section Rung 1 (Now)
        Browser Extension : DOM parsing & LLM : โœ… Complete
    section Rung 2 (Q2 2025)
        Pega API Integration : Direct REST API : ๐Ÿ”„ In Progress
    section Rung 3 (Q3 2025)
        CDH Integration : Prediction Studio : โณ Planned
    section Rung 4 (Q4 2025)
        Constellation Native : Component-based : โณ Planned
    section Rung 5 (Q1 2026)
        Platform Integration : Data Fabric : โณ Planned
Loading

5-Rung Integration Ladder:

Rung Capability Status Timeline
1 Browser Extension with DOM parsing โœ… Complete Now
2 Direct Pega API integration ๐Ÿ”„ Beta Q2 2025
3 CDH and Prediction Studio โณ Alpha Q3 2025
4 Constellation-native component โณ Design Q4 2025
5 Platform Rules & Data Fabric โณ Research Q1 2026

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

flowchart LR
    A[Fork Repository] --> B[Create Feature Branch]
    B --> C[Make Changes]
    C --> D[Add Tests]
    D --> E[Run Tests]
    E --> F{Tests Pass?}
    F -->|No| C
    F -->|Yes| G[Submit Pull Request]
    G --> H[Code Review]
    H --> I{Approved?}
    I -->|No| C
    I -->|Yes| J[Merged!]
Loading

Contribution Guidelines

  1. ๐Ÿด Fork the repository
  2. ๐Ÿ”€ Create a feature branch (git checkout -b feature/amazing-feature)
  3. ๐Ÿ’พ Commit your changes (git commit -m 'Add amazing feature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/amazing-feature)
  5. ๐Ÿ”ƒ Open a Pull Request

Code Style

  • TypeScript with strict typing (no any types)
  • CamelCase for variables and functions
  • PascalCase for classes and interfaces
  • kebab-case for file names
  • JSDoc comments for all public APIs

Pull Request Checklist

  • Tests added/updated
  • All tests passing
  • Documentation updated
  • Code follows style guidelines
  • Commit messages are clear
  • No merge conflicts

๐Ÿ“„ License

graph LR
    A[MIT License] --> B[โœ… Free to use]
    A --> C[โœ… Free to modify]
    A --> D[โœ… Free to distribute]
    A --> E[โŒ No warranty]
Loading

MIT License - See LICENSE file for details.

This project is free to use, modify, and distribute. No warranty is provided.


โš ๏ธ Disclaimer

This is NOT an official Pegasystems product

This project is:

  • โŒ NOT affiliated with Pegasystems Inc.
  • โŒ NOT endorsed by Pegasystems Inc.
  • โŒ NOT sponsored by Pegasystems Inc.
  • โŒ NOT supported by Pegasystems Inc.

Trademark Notice

Pegaยฎ, Pega Infinityยฎ, Pega Infinity '23, Pega PLATFORMยฎ, Pega Cosmosยฎ, Pega Constellationยฎ, and all related marks are trademarks of Pegasystems Inc.

These trademarks are used only for descriptive purposes to indicate compatibility with Pega applications.

Use at Your Own Risk

  • โœ… Test thoroughly in non-production environments
  • โœ… Ensure compliance with your organization's security policies
  • โœ… Review code and configuration before production use
  • โŒ Authors are NOT liable for any damage to data or systems

๐Ÿ“ž Support

Need Help?

Resource Link
Issues GitHub Issues
Discussions GitHub Discussions
Documentation Full Docs
Pega Support Pega Community

โญ Star Us on GitHub!

If you find this project helpful, please consider giving it a star โญ

Star


Built with โค๏ธ by the Pega Community

This project is an independent community effort and is not officially affiliated with Pegasystems Inc.

๐Ÿ  Back to Home โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ› Report Issue โ€ข ๐Ÿ’ก Feature Request

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages