Skip to content

taylorparsons/cortege-hackathon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

80 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CORTEGE β€” AI Security Companion System

CORTEGE is a companion-model AI security product where each household member is paired with a dedicated AI agent that silently protects them from scams, fraud, and security threats. Protection deepens over time through behavioral learning.

πŸš€ Quick Start

Prerequisites

Setup & Run

  1. Clone the repository

    git clone https://github.com/taylorparsons/cortege-hackathon.git
    cd cortege-hackathon
  2. Start the application

    ./run-local.sh

    The script will:

    • Check Node.js/npm installation
    • Install dependencies automatically (if needed)
    • Create .env from .env.example (if needed)
    • Prompt you to add your ANTHROPIC_API_KEY
    • Open two terminal windows:
      • Backend server (port 3001)
      • Frontend dev server (port 5173)
  3. Stop the application

    ./stop-local.sh

Access Points

πŸ“š Documentation

πŸ—οΈ Architecture

System Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     React Frontend (Vite)                   β”‚
β”‚                    http://localhost:5173                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚ REST + WebSocket
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Express.js Backend Server                      β”‚
β”‚                http://localhost:3001                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚              Orchestrator                            β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚ Event Bus  β”‚  β”‚ Agent Pool   β”‚  β”‚  Scheduler  β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚         Agent Instances (per household member)       β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚  β”‚
β”‚  β”‚  β”‚  ANCHOR  β”‚  β”‚ SENTINEL β”‚  β”‚  SCOUT   β”‚          β”‚  β”‚
β”‚  β”‚  β”‚ (elderly)β”‚  β”‚ (adult)  β”‚  β”‚ (teen)   β”‚          β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚ Claude API
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Anthropic Claude                           β”‚
β”‚              (Haiku 4.5 for assessments)                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Agent Learning Stages

Agents evolve through four maturity stages:

  1. Baseline (0.00-0.10) - Learning normal patterns
  2. Pattern Recognition (0.10-0.30) - Identifying recurring behaviors
  3. Predictive (0.30-0.60) - Anticipating threats
  4. Cortege Mode (0.60-1.00) - Proactive protection

Event Ingestion

  • Event Simulator - Demo scenarios (default)
  • Manual API - POST /api/events for testing
  • Twilio Webhook - Real phone call integration (see Production Deployment)
  • Live Feed event injector - Targets the currently selected household members instead of the legacy hard-coded demo defaults
  • Household fraud case panel - Links one recent household call with one manual evidence item and generates an explainable risk case

Hackathon Demo Story

The strongest current demo is a household-aware fraud case, not generic phone spam blocking:

  1. A real inbound call hits the household Twilio number
  2. CORTEGE resolves the household and target member
  3. The operator adds one manual evidence item in Live Feed
  4. CORTEGE creates one case with severity, signals, rationale, and recommended action

Supported first-pass evidence inputs are intentionally text-first and conservative:

  • message_excerpt
  • suspicious_url
  • screenshot_note

This flow does not claim definitive AI-image or AI-video detection. It uses explainable risk heuristics so the demo remains believable under hackathon time pressure.

🏠 Household Management

CORTEGE supports multiple households, each with independent members and companion agents.

Switching Households

Click "Switch Household" in the nav bar to open the household selector. From there you can create households, switch between them, delete unused ones, manage saved locations, edit a location name/address, and reassign a household to another saved location. Referenced locations cannot be deleted until every blocking household is reassigned. Your selected household persists across page reloads via localStorage.

Creating Households via API

# Create a named location
LOCATION_ID=$(curl -s -X POST http://localhost:3001/api/locations \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Family A Home",
    "address": {
      "line1": "123 Main St",
      "line2": null,
      "city": "New York",
      "region": "NY",
      "postal_code": "10001",
      "country": "US"
    }
  }' | jq -r '.location_id')

# Create a household
curl -X POST http://localhost:3001/api/households \
  -H 'Content-Type: application/json' \
  -d "{\"name\": \"Family A\", \"location_id\": \"$LOCATION_ID\"}"

# Add a member
curl -X POST http://localhost:3001/api/households/<id>/members \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Alex",
    "phone": "+14155550123",
    "date_of_birth": "2012-05-14",
    "profile_type": "child",
    "companion": "scout"
  }'

Migrating from Legacy Format

If you have an existing data/household.json, migrate it to the multi-household store:

node scripts/migrate-household.js

This will:

  • Read the legacy data/household.json
  • Create a new household in data/households/
  • Migrate all members
  • Back up the original as data/household.json.backup

The legacy GET /api/household endpoint continues to work β€” it falls back through: household store (by DEFAULT_HOUSEHOLD_ID) β†’ first available household β†’ legacy household.json β†’ empty default.

Environment Variables

DEFAULT_HOUSEHOLD_ID=<uuid>  # Optional: default household for legacy endpoint

Privacy Model

The current household data model is privacy-first:

  • Household and location records use location_id references instead of embedding a freeform household location
  • Member full name, phone, and date_of_birth are encrypted at rest
  • Saved location name and structured address are encrypted at rest
  • Logs and external LLM calls use redacted or aliased values instead of raw PII

For production deployments, set a strong PII_MASTER_KEY. In development, the server falls back to a dev-only key if it is unset.

Stable Companion Identity

Companion runtime instances are keyed by the stable member.id, not by the member display name. That matters for demo reliability:

  • A newly created Sam Dodge does not inherit another Sam Dodge's old memory or activity
  • Live companion activity starts from that member's actual creation time
  • The selected-household Live Feed and Household detail surfaces stay aligned to the same member identity

πŸ› οΈ Development

Storage

CORTEGE uses SQLite for production storage with tamper-evident audit trail.

Storage Modes

Configure via STORAGE_MODE environment variable:

  • sqlite (default) - Production mode with tamper-evident hash chain
  • json - Legacy mode using JSON files (for development)
  • dual-write - Write to both SQLite and JSON (for migration)

Environment Variables

# Storage configuration
STORAGE_MODE=sqlite                      # sqlite | json | dual-write
SQLITE_DB_PATH=data/cortege.db          # SQLite database path
ENABLE_JSON_FALLBACK=false              # Fall back to JSON on SQLite errors

Migration from JSON

To migrate existing JSON files to SQLite:

node scripts/migrate-to-sqlite.js

The migration script will:

  • Backup existing SQLite database (if it exists)
  • Import all events from data/events/*.jsonl
  • Reconstruct hash chain for tamper evidence
  • Import memory snapshots from data/memories/*.json
  • Validate hash chain integrity
  • Report progress and errors

Hash Chain Validation

Validate event log integrity:

node scripts/validate-hash-chain.js

This verifies:

  • Each event's hash is correctly computed
  • Each event's prev_hash matches the previous event's hash
  • No events have been tampered with or deleted

Run this daily in production (e.g., via cron job) to ensure audit trail integrity.

SQLite Features

  • Tamper-evident: Append-only event log with SHA-256 hash chain
  • Atomic writes: Events and memory snapshots written in transactions
  • Query capabilities: Filter by member, threat level, time range, signals
  • Crash recovery: WAL (Write-Ahead Logging) mode enabled
  • Security: Database file permissions set to 0600 (owner read/write only)

Project Structure

cortege-hackathon/
β”œβ”€β”€ .kiro/                              # Kiro IDE configuration and specs
β”‚   └── specs/                          # Implementation specifications
β”‚       β”œβ”€β”€ agent-orchestration-implementation/  # Main implementation spec
β”‚       β”‚   β”œβ”€β”€ requirements.md         # 48 FR + 15 NFR requirements
β”‚       β”‚   └── tasks.md                # 10 phases, 100+ granular tasks
β”‚       └── agent-orchestration-mvp/    # MVP specification
β”‚           β”œβ”€β”€ requirements.md         # MVP requirements subset
β”‚           └── tasks.md                # MVP task breakdown
β”‚
β”œβ”€β”€ agents/                             # Agent templates (markdown) - swappable layer
β”‚   β”œβ”€β”€ _template/                      # Template for creating new agents
β”‚   β”‚   └── agent.md                    # Starter template with examples
β”‚   β”œβ”€β”€ anchor/                         # Elderly protection agent
β”‚   β”‚   └── agent.md                    # YAML frontmatter + markdown prompt
β”‚   β”œβ”€β”€ sentinel/                       # Adult protection agent
β”‚   β”‚   └── agent.md                    # Primary household coordinator
β”‚   └── scout/                          # Teen protection agent
β”‚       └── agent.md                    # Age-appropriate threat detection
β”‚
β”œβ”€β”€ data/                               # Runtime data storage (gitignored)
β”‚   β”œβ”€β”€ cortege.db                      # SQLite database (primary storage)
β”‚   β”œβ”€β”€ events/                         # Event logs (legacy JSON mode only)
β”‚   β”‚   └── YYYY-MM-DD.jsonl           # One file per day, one event per line
β”‚   β”œβ”€β”€ memories/                       # Agent memory stores (legacy JSON mode only)
β”‚   β”‚   β”œβ”€β”€ anchor-member-001.json     # Per-agent-instance learning
β”‚   β”‚   β”œβ”€β”€ sentinel-member-002.json   # Trusted contacts, patterns, history
β”‚   β”‚   └── scout-member-003.json      # Grows over time = learning
β”‚   β”œβ”€β”€ households/                     # Multi-household JSON files
β”‚   β”‚   └── <uuid>.json               # One file per household (members, config)
β”‚   β”œβ”€β”€ locations/                      # Saved named locations (JSON mode)
β”‚   β”‚   └── <uuid>.json               # One file per saved location
β”‚   └── household.json                  # Legacy single-household file (backward compat)
β”‚
β”œβ”€β”€ docs/                               # Documentation
β”‚   β”œβ”€β”€ API.md                          # Complete REST + WebSocket API reference
β”‚   β”œβ”€β”€ PRD.md                          # Product requirements and roadmap
β”‚   β”œβ”€β”€ PRODUCTION_DEPLOYMENT.md        # Twilio integration + production setup
β”‚   β”œβ”€β”€ TRACEABILITY.md                 # Audit trail navigation guide
β”‚   β”œβ”€β”€ requests.md                     # Customer request log (CR-*)
β”‚   β”œβ”€β”€ decisions.md                    # Design decision log (D-*)
β”‚   β”œβ”€β”€ progress.txt                    # Execution log (session notes)
β”‚   β”œβ”€β”€ specs/                          # Feature specifications
β”‚   β”‚   β”œβ”€β”€ 20260319-add-household-feature/  # Multi-household management
β”‚   β”‚   β”‚   β”œβ”€β”€ spec.md                 # 10 FRs, 3 NFRs, acceptance scenarios
β”‚   β”‚   β”‚   └── tasks.md                # 17 tasks (16 done, 1 deferred)
β”‚   β”‚   β”œβ”€β”€ 20260319-frontend-api-integration/ # Live API data in frontend
β”‚   β”‚   β”‚   β”œβ”€β”€ spec.md
β”‚   β”‚   β”‚   └── tasks.md
β”‚   β”‚   β”œβ”€β”€ working-demo-with-twilio/   # Twilio integration spec
β”‚   β”‚   β”‚   β”œβ”€β”€ spec.md                 # Requirements + acceptance criteria
β”‚   β”‚   β”‚   └── tasks.md                # Implementation tasks
β”‚   β”‚   └── ...                         # Additional feature specs
β”‚   └── superpowers/                    # Design specifications (architecture)
β”‚       β”œβ”€β”€ specs/
β”‚       β”‚   β”œβ”€β”€ 2026-03-14-agent-orchestration-design.md    # Agent system design
β”‚       β”‚   β”œβ”€β”€ 2026-03-14-agent-orchestration-diagrams.md  # Agent system diagrams
β”‚       β”‚   β”œβ”€β”€ 2026-03-19-household-management-design.md   # Household design
β”‚       β”‚   └── 2026-03-19-household-management-diagrams.md # Household diagrams
β”‚       └── plans/                      # Implementation plans
β”‚           β”œβ”€β”€ 2026-03-19-add-household-feature.md
β”‚           β”œβ”€β”€ 2026-03-19-frontend-api-integration.md
β”‚           └── 2026-03-18-sqlite-auditability.md
β”‚
β”œβ”€β”€ scenarios/                          # Demo scenario definitions (JSON)
β”‚   β”œβ”€β”€ _template.json                  # Template for creating scenarios
β”‚   β”œβ”€β”€ grandparent-scam.json          # Emergency scam targeting elderly
β”‚   β”œβ”€β”€ bank-fraud.json                # Fake bank security call
β”‚   └── tech-support.json              # Tech support scam
β”‚
β”œβ”€β”€ scripts/                            # Utility scripts
β”‚   β”œβ”€β”€ migrate-household.js           # Migrate legacy household.json to multi-household
β”‚   β”œβ”€β”€ migrate-to-sqlite.js           # Migrate JSON files to SQLite
β”‚   └── validate-hash-chain.js         # Verify audit trail integrity
β”‚
β”œβ”€β”€ server/                             # Backend (Node.js/Express) - the framework
β”‚   β”œβ”€β”€ index.js                        # Server entry point
β”‚   β”œβ”€β”€ agents/                         # Agent runtime
β”‚   β”‚   β”œβ”€β”€ agent-factory.js           # Scans agents/ dir, parses templates
β”‚   β”‚   β”œβ”€β”€ agent-instance.js          # Per-member agent instance
β”‚   β”‚   β”œβ”€β”€ template-parser.js         # YAML frontmatter + markdown parser
β”‚   β”‚   β”œβ”€β”€ memory-store.js            # JSON memory persistence + depth calc
β”‚   β”‚   └── household.js               # Household config loader
β”‚   β”œβ”€β”€ api/                            # REST + WebSocket
β”‚   β”‚   β”œβ”€β”€ routes.js                  # Express REST endpoints
β”‚   β”‚   └── websocket.js               # Real-time event push
β”‚   β”œβ”€β”€ privacy/                        # PII protection helpers
β”‚   β”‚   └── pii.js                     # Encryption, tokenization, redaction, LLM sanitization
β”‚   β”œβ”€β”€ claude/                         # Claude API client
β”‚   β”‚   β”œβ”€β”€ claude-client.js           # @anthropic-ai/sdk wrapper
β”‚   β”‚   └── response-schema.js         # submit_assessment tool definition
β”‚   β”œβ”€β”€ escalation/                     # Threat escalation
β”‚   β”‚   └── escalation-handler.js      # L0-L4 routing + household relay
β”‚   β”œβ”€β”€ ingestion/                      # Event ingestion
β”‚   β”‚   β”œβ”€β”€ twilio-webhook.js          # POST /ingest/twilio/voice
β”‚   β”‚   β”œβ”€β”€ simulator.js               # Scenario playback engine
β”‚   β”‚   └── manual.js                  # POST /api/events
β”‚   β”œβ”€β”€ orchestrator/                   # Core orchestration
β”‚   β”‚   β”œβ”€β”€ orchestrator.js            # Main coordinator
β”‚   β”‚   β”œβ”€β”€ event-bus.js               # Typed EventEmitter + SQLite persistence
β”‚   β”‚   └── scheduler.js               # node-cron for timed tasks
β”‚   β”œβ”€β”€ storage/                        # Storage layer
β”‚   β”‚   β”œβ”€β”€ schema.sql                 # SQLite schema with triggers
β”‚   β”‚   β”œβ”€β”€ db.js                      # Database connection + queries
β”‚   β”‚   β”œβ”€β”€ hash-chain.js              # SHA-256 hash chain computation
β”‚   β”‚   β”œβ”€β”€ household-store.js         # Multi-household JSON file store
β”‚   β”‚   β”œβ”€β”€ location-store.js          # Saved-location JSON file store
β”‚   β”‚   └── storage-adapter.js         # Multi-mode storage (sqlite/json/dual)
β”‚   └── tests/                          # Node.js test suite
β”‚       β”œβ”€β”€ integration.test.js        # End-to-end flows
β”‚       β”œβ”€β”€ demo-validation.test.js    # Demo scenario validation
β”‚       β”œβ”€β”€ template-parser.test.js    # Agent template parsing
β”‚       β”œβ”€β”€ event-bus.test.js          # Event bus + persistence
β”‚       β”œβ”€β”€ memory-store.test.js       # Learning + depth calculation
β”‚       β”œβ”€β”€ escalation-handler.test.js # Threat routing
β”‚       β”œβ”€β”€ db.test.js                 # SQLite database operations
β”‚       β”œβ”€β”€ hash-chain.test.js         # Hash chain computation
β”‚       β”œβ”€β”€ sqlite-triggers.test.js    # Append-only trigger validation
β”‚       β”œβ”€β”€ privacy.test.js            # PII encryption, tokenization, redaction
β”‚       β”œβ”€β”€ location-store.test.js     # Saved-location storage coverage
β”‚       β”œβ”€β”€ household-store.test.js    # Household store CRUD (8 tests)
β”‚       β”œβ”€β”€ household-api.test.js      # Household API endpoints (8 tests)
β”‚       └── household-integration.test.js # Household end-to-end (4 tests)
β”‚
β”œβ”€β”€ src/                                # Frontend (React + Vite)
β”‚   β”œβ”€β”€ main.jsx                        # React entry point (HouseholdProvider wrapper)
β”‚   β”œβ”€β”€ Cortege.jsx                     # Main dashboard component
β”‚   β”œβ”€β”€ components/                     # UI components
β”‚   β”‚   β”œβ”€β”€ EventFeed.jsx              # Real-time event stream
β”‚   β”‚   β”œβ”€β”€ AgentStatus.jsx            # Companion status cards
β”‚   β”‚   β”œβ”€β”€ HouseholdSelector.jsx      # Household switching modal
β”‚   β”‚   β”œβ”€β”€ LocationManager.jsx        # Saved-location list/edit/delete UI
β”‚   β”‚   β”œβ”€β”€ MemoryViewer.jsx           # Agent memory inspector
β”‚   β”‚   β”œβ”€β”€ ScenarioRunner.jsx         # Demo scenario controls
β”‚   β”‚   └── EventInjector.jsx          # Manual event submission
β”‚   β”œβ”€β”€ context/                        # React contexts
β”‚   β”‚   └── HouseholdContext.jsx       # Current household state + localStorage
β”‚   β”œβ”€β”€ hooks/                          # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useCortegeData.js          # REST + WebSocket data (household-scoped)
β”‚   β”‚   β”œβ”€β”€ useCompanionDetail.js      # Companion detail panel data
β”‚   β”‚   └── useHouseholds.js           # Household CRUD operations
β”‚   └── lib/                            # Shared utilities
β”‚       β”œβ”€β”€ backend-url.js             # API/WS URL helper (proxy-aware)
β”‚       └── companion-display.js       # Agent type β†’ display properties
β”‚
β”œβ”€β”€ .env                                # Environment config (gitignored)
β”œβ”€β”€ .env.example                        # Environment template
β”œβ”€β”€ package.json                        # Node.js dependencies
β”œβ”€β”€ vite.config.js                      # Vite build config
β”œβ”€β”€ run-local.sh                        # Start script (opens 2 terminals)
└── stop-local.sh                       # Stop script (kills ports 3001 + 5173)

Running Tests

# Run all tests
npm test

# Run unit tests only
npm run test:unit

# Run integration tests only
npm run test:integration

Localhost Cypress Review Artifacts

With the backend on http://localhost:3001 and the frontend on http://localhost:5173, rerun the current household/member demo review path with:

npx cypress run --spec cypress/e2e/navigation.cy.js,cypress/e2e/household-crud.cy.js,cypress/e2e/member-crud.cy.js,cypress/e2e/companion-cards.cy.js,cypress/e2e/live-feed.cy.js,cypress/e2e/fraud-case-demo.cy.js

The latest recorded localhost review suite passed with 24 tests across 6 specs and writes reviewer-friendly artifacts to cypress/screenshots/ and cypress/videos/.

Core screenshots from the exact recorded suite:

Navigation localhost screenshot Household routing localhost screenshot Member CRUD localhost screenshot Selected household companion localhost screenshot Live Feed localhost screenshot Fraud case localhost screenshot

Recorded videos from the same suite:

Creating New Agents

Agents are defined as markdown files with YAML frontmatter:

  1. Create agents/my-agent/agent.md
  2. Define configuration in YAML frontmatter
  3. Write system prompt in markdown body
  4. Restart the orchestrator

See existing agents in agents/ for examples.

Running Scenarios

# Via API
curl -X POST http://localhost:3001/api/scenarios/grandparent-scam/run

# Available scenarios
ls scenarios/*.json

πŸ”§ Configuration

Environment Variables

# Required
ANTHROPIC_API_KEY=your_api_key_here

# Optional
CLAUDE_MODEL=claude-haiku-4-5-20251001  # Default model
PORT=3001                                # Backend port
PII_MASTER_KEY=                          # Required in production for encrypted household/member/location PII

# Demo/Learning Acceleration
LEARNING_TIME_MULTIPLIER=1440            # 1 min = 1 day (default)
LEARNING_EVENT_WEIGHT=10                 # Event depth multiplier
LEARNING_FAST_MODE=true                  # Lower stage thresholds

# Twilio (for production)
TWILIO_ACCOUNT_SID=your_sid
TWILIO_AUTH_TOKEN=your_token

# Household
DEFAULT_HOUSEHOLD_ID=                    # Default household for legacy endpoint

# Debug
CLAUDE_DEBUG=1                           # Enable API debug logging

πŸ“Š API Endpoints

Household Management

  • POST /api/households - Create a new household
  • GET /api/households - List all households
  • GET /api/households/:id - Get household by ID
  • PUT /api/households/:id - Update household
  • DELETE /api/households/:id - Delete household
  • POST /api/households/:id/members - Add member to household
  • PUT /api/households/:id/members/:mid - Update member
  • DELETE /api/households/:id/members/:mid - Remove member
  • GET /api/household - Legacy endpoint (backward-compatible fallback)

Location Management

  • GET /api/locations - List saved locations
  • POST /api/locations - Create a saved location with a name and structured address
  • GET /api/locations/:id - Get saved location details
  • PUT /api/locations/:id - Update saved location name/address
  • DELETE /api/locations/:id - Delete a saved location if no household still references it (409 Conflict when blocked)

Companions

  • GET /api/companions - Get all agent instances
  • GET /api/companions/:id - Get specific agent
  • GET /api/companions/:id/memory - Get agent memory
  • GET /api/companions/:id/activity - Get agent activity log

Events & Scenarios

  • GET /api/events - Get recent events
  • POST /api/events - Submit manual event
  • GET /api/fraud-cases?household_id=... - List recent fraud cases for a household
  • POST /api/fraud-cases - Create a household fraud case from one linked event and one evidence item
  • POST /api/scenarios/:name/run - Run demo scenario

Agents

  • GET /api/agents - List loaded agents
  • POST /api/agents/reload - Hot-reload agent templates

Documentation

  • GET /api/docs - API documentation (HTML)

See API.md for complete reference with examples.

πŸ”Œ WebSocket Events

Connect to ws://localhost:3001 to receive real-time updates:

const ws = new WebSocket('ws://localhost:3001');

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  
  switch (message.type) {
    case 'event':           // New event ingested
    case 'assessment':      // Agent assessment completed
    case 'memory_update':   // Agent memory updated
    case 'escalation':      // Threat escalated
    case 'error':           // Error occurred
  }
};

πŸ§ͺ Demo Scenarios

Pre-built scenarios in scenarios/:

  • grandparent-scam.json - Emergency scam targeting elderly
  • bank-fraud.json - Fake bank security call
  • tech-support.json - Tech support scam

Run via API or add your own JSON scenario files.

🚨 Threat Levels

Agents assess threats on a 5-level scale:

  • L0 - Benign (normal activity)
  • L1 - Suspicious (monitor)
  • L2 - Likely threat (warn)
  • L3 - High confidence threat (block)
  • L4 - Critical threat (block + escalate)

πŸ“ Scripts

run-local.sh

Starts both backend and frontend in separate terminal windows for easy log monitoring.

Features:

  • Checks Node.js/npm installation
  • Installs dependencies if needed
  • Validates .env configuration
  • Creates data directory
  • Opens two terminal windows (backend + frontend)

Usage:

./run-local.sh

stop-local.sh

Kills processes on ports 3001 (backend) and 5173 (frontend).

Features:

  • Finds PIDs using each port
  • Gracefully terminates processes
  • Confirms successful shutdown

Usage:

./stop-local.sh

🀝 Contributing

This is a hackathon project. For production use:

  1. Add authentication (API keys, JWT)
  2. Implement rate limiting
  3. Add CORS configuration
  4. Set up proper logging
  5. Configure production database
  6. Add monitoring/alerting
  7. Implement backup/recovery

See PRODUCTION_DEPLOYMENT.md for details.

πŸ“„ License

This project is proprietary, not open source, and all rights are reserved. See LICENSE.

πŸ™ Acknowledgments

  • Built with Anthropic Claude
  • Event-driven architecture inspired by actor model patterns
  • Agent learning system based on behavioral analysis research

πŸ“ž Support


Built for hackathon - March 2026

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors