Multi-tenant memory infrastructure for game development teams and agents.
This project is built around one core rule:
- The Memory API is the source of truth.
- MCP is a thin compatibility layer on top.
- Web, CLI, and agents all use the same API and data model.
- Web:
https://game-dev-memory.pajamadot.com - API:
https://api-game-dev-memory.pajamadot.com - MCP + OAuth issuer:
https://mcp-game-dev-memory.pajamadot.com - Agent host:
https://game-dev-agent.pajamadot.com
- Worker/API latest deployed version:
a9c21431-4bac-4b21-b0ae-136d80844a95 - CLI latest npm package:
@pajamadot/pajama@0.1.10 - Last end-to-end verification: February 16, 2026 (local build + Playwright e2e + deployed smoke checks)
- CLI binary download prefix:
https://api-game-dev-memory.pajamadot.com/downloads/pajama/v{version}/{file}
- DB backend: Neon Postgres via Cloudflare Hyperdrive
- Hyperdrive config ID:
bf4313a26dc64a7080f23b9932a4c8a0
- Hyperdrive config ID:
- File storage: Cloudflare R2 bucket
game-dev-memory
- Clerk-authenticated web app for org/user scoped memory operations.
- API key system for service/agent access.
- OAuth PKCE for MCP/CLI login.
- Project/session/memory CRUD + retrieval.
- Progressive-disclosure memory retrieval (
search-index,batch-get,timeline, provider discovery). - Large file multipart upload to R2 (10GB+ capable with multipart part sizing).
- Artifact indexing with PageIndex (TypeScript port) and document-node retrieval.
- Streaming agent sessions (
agent-pro) backed by Cloudflare Sandbox. - Deterministic fallback answers when LLM synthesis fails or is unavailable.
- Retrieval evolution arena with project policy materialization and campaign mode.
- EverMemOS-inspired derivation pipeline (/api/memories/:id/derive) for event logs + foresight memories.
- Time-aware foresight lane (/api/memories/foresight/active) for deadline/planning retrieval.
- Daily research digests ingested into memory via cron.
- Live end-to-end smoke suite for web/API/MCP/agent/CLI (Playwright +
npx @pajamadot/pajama).
Local web UX smoke (starts web on http://localhost:3040):
npm run e2eDeployed/live smoke (web + API + MCP + agent host + CLI via npx):
./scripts/e2e-live.ps1Optionally enable authenticated checks (MCP tools/list, memory providers, CLI query):
./scripts/e2e-live.ps1 -ApiToken "<your_api_key>"npm i -g @pajamadot/pajama
pajama --versionOr run without installing (downloads binary on first run):
npx -y @pajamadot/pajama --versionpajama loginThis stores an API key locally (same auth used by MCP clients). You can always override with:
pajama --token "gdm_..." projects listpajama projects create --name "My Unreal Project" --engine unreal --description "UE5 build + performance notes"pajama memories create --project-id "<project_uuid>" --category "build" --title "UE5 packaging failed" --content "Repro steps + fix"Index search:
pajama memories search-index --project-id "<project_uuid>" --query "packaging error" --limit 5Then fetch the records you want:
pajama memories batch-get --ids "<uuid1>,<uuid2>" --no-contentpajama assets upload --project-id "<project_uuid>" --path "C:\\logs\\build.zip" --memory-id "<memory_uuid>"pajama agent ask --project-id "<project_uuid>" --query "What changed in build times this week?" --dry-run
pajama agent ask --project-id "<project_uuid>" --query "What changed in build times this week?" --dry-run --diagnostics
pajama agent ask --project-id "<project_uuid>" --query "What changed in build times this week?" --dry-run --diagnostics --no-cache --cache-ttl-ms 15000Remove --dry-run to request synthesis when LLM is configured on the Worker.
./scripts/benchmark-agent-retrieval.ps1 -Token "<gdm_api_key>" -ProjectId "<project_uuid>" -Iterations 12Game dev teams generate high-value operational knowledge that gets lost across:
- coding sessions,
- build failures,
- playtest outcomes,
- profiling traces,
- ad-hoc chat decisions.
This system converts those events into durable, queryable, evidence-linked memory:
- shared project memory for org collaboration,
- private personal memory for individuals,
- retrieval and evolution loops to continuously improve relevance and latency.
Primary research artifacts live in:
research/agent-memory.mdresearch/ue-memory.mdresearch/pageindex.mdresearch/evermemos.mdresearch/new-projects.mdweb/src/content/research/*(published versions)
Key themes from research that directly shaped implementation:
- Memory must be evidence-first, not only generated summaries.
- Long-term utility requires explicit memory lifecycle operations (create/update/quarantine/supersede).
- Retrieval quality depends on policy selection, not one static query strategy.
- Cost and latency improve when retrieval is budgeted and mode-based (
fast,balanced,deep). - Procedural and operational memory is first-class for dev workflows.
These are reflected in current API behaviors and schema fields.
- All core tables are tenant scoped by
tenant_type+tenant_id.tenant_type:orgorusertenant_id: org id or user id
- Shared org memory and private user memory are enforced server-side.
- API accepts:
- Clerk JWTs (web flows)
- API keys (
gdm_...) for agents/services - OAuth token flows for MCP-compatible clients
Core memory object includes:
- content fields (
title,content,tags,category) - confidence and usage signals (
confidence,access_count) - lifecycle quality flags (
state,quality) - provenance (
source_type,session_id, actor metadata) - context JSON for structured operational metadata
Memory lifecycle events are captured in memory_events for auditability.
Most agent flows should not pull full memory bodies immediately. We support a 2-step retrieval pattern:
- Search a compact index (id/title/excerpt/tokens).
- Batch fetch full records only for selected IDs.
This is implemented in:
api/src/core/memoryRetrieval.ts- API routes:
/api/memories/search-index,/api/memories/batch-get,/api/memories/timeline - MCP tools:
memories.search_index,memories.batch_get,memories.timeline - CLI commands:
pajama memories search-index|batch-get|timeline
Providers/strategies are pluggable (memories_fts, recent_activity) and can be extended without changing clients.
Two evidence classes are first-class:
- Assets (large files in R2, metadata in Postgres)
- Artifacts (document structures + optional PageIndex nodes)
Entity links connect memory <-> assets and other object relationships.
Memory retrieval supports three modes in api/src/core/memories.ts:
fast: direct FTS path, low latencybalanced: FTS + fallback blendingdeep: expanded candidate retrieval + contextual neighbors
Document retrieval uses PageIndex nodes when enabled (hybrid/documents paths).
Large binary objects live in R2; Postgres stores the metadata and upload state:
assets: one row per object (status, size, sha256, r2_key, upload_id, etc.)asset_upload_parts: part ETags for resumable completion
Assets can be linked to memories via entity_links using /api/memories/:id/attach-asset.
Artifacts are for documents and text corpora that benefit from chunking + indexing:
artifacts: document metadata + R2 location (single or chunked)artifact_chunks: extracted text chunks (optional)artifacts.metadata.pageindex: hierarchical index (PageIndex-TS port)
Core endpoints:
POST /api/artifacts/:id/pageindexbuild/rebuild an indexGET /api/artifacts/:id/pageindex/query?q=...retrieve best matching nodesGET /api/artifacts/:id/pageindex/node/:nodeIdfetch one node + breadcrumbs
This enables agents to cite doc sections as evidence without vector DB dependencies.
Arena-based retrieval optimization:
- replay agent sessions as weak supervision
- evaluate multiple retrieval arms
- score latency + evidence recall/precision/diversity
- persist outcomes to
evolution_events - materialize active project policy in
project_retrieval_policies
This policy is used in runtime auto mode for agent requests.
Two agent modes:
agent: retrieval-first route with optional synthesisagent-pro: streaming, tool-using sandbox agent
Both now guarantee usable response payloads with deterministic fallback text when synthesis fails.
MCP endpoint is intentionally thin:
- It maps tool calls to underlying Memory API behavior.
- It does not duplicate domain logic.
- This keeps one source of truth for auth, tenancy, and schema semantics.
- Next.js app on Vercel.
- Clerk auth integration.
- Pages for projects, memories, assets, research, evolve dashboards, and streaming agent sessions.
- Documentation pages for CLI and skills.
- Cloudflare Worker + Hono routing.
- Auth middleware supports Clerk and API keys.
- Core routes:
/api/projects/api/memories/api/sessions/api/assets/api/artifacts/api/evolve/api/agent/api/agent-pro/api/tokens/api/oauth
- Public binary distribution route:
/downloads/pajama/...
Migrations in api/migrations/:
0001_init.sql: projects/memories/evolution_events base0002_tenant_sessions_artifacts.sql: tenant scoping + sessions/artifacts/entity links0003_identity_tokens_oauth.sql: app identity, API tokens, OAuth tables0004_assets_multipart.sql: asset storage + multipart upload tracking0005_memory_state_fts.sql: memory state/quality + FTS0006_memory_events.sql: memory event log0007_agent_perf_indexes.sql: agent query performance indexes0008_evolve_arena_indexes.sql: arena event lookup indexes0009_project_retrieval_policies.sql: materialized retrieval policy table
- Rust CLI with OAuth login and API-key operation.
- npm-distributed installer package for prebuilt binaries.
- Binary distribution:
- upload binaries to R2 under
releases/pajama/vX.Y.Z/...(scripts/release-pajama.ps1) - the API serves them under
/downloads/pajama/vX.Y.Z/... - the npm package downloads the right binary at install time (and refreshes on version mismatch)
- upload binaries to R2 under
- Current notable commands:
pajama projects ...pajama memories list|search-index|batch-get|timeline|createpajama assets ...pajama evolve policy|arena-*pajama agent statuspajama agent ask
- Worker-friendly TypeScript port inspired by
VectifyAI/PageIndex(MIT). - Used to build hierarchical indexes for artifacts and enable document-node retrieval without a vector DB.
- Research notes and port status:
research/pageindex.mdresearch/evermemos.mdpackages/pageindex-ts/PORT_STATUS.md
- Worker cron (
0 9 * * *) triggers daily digest generation. - Current digest families:
- unreal-agents
- agent-memory
- new-projects
- Digests are stored back into project memory for retrieval and audit.
- Sign in with Clerk.
- Web calls API with Clerk token.
- API resolves tenant scope and enforces project ownership.
- User creates/queries memory and linked evidence.
- Agent session responses cite evidence IDs.
- Create API key from web settings.
- Agent calls API using
Authorization: Bearer gdm_.... - Same data and routing semantics as web.
- Can operate non-interactively across memory/assets/evolve endpoints.
pajama loginstarts OAuth PKCE.- Browser consent flow completes against OAuth endpoints.
- Token saved locally by CLI.
- CLI commands operate directly against memory API.
- User posts message to
/api/agent-pro/sessions/:id/continue. - Worker launches sandbox runner with scoped env.
- Runner performs retrieval/tool calls/synthesis.
- Worker streams progress events (SSE).
- Assistant response is persisted with evidence references.
- If synthesis fails, deterministic fallback answer still returns.
- Arena run or campaign executed via API/CLI.
- Session traces are evaluated across retrieval arms.
- Winner policies are persisted and materialized.
- Runtime auto mode consumes policy for future agent requests.
- Retrieval mode routing (
fast,balanced,deep) controls latency/recall tradeoffs. - Additional indexes added for session/memory/evolution hot paths.
- Arena campaign mode supports bounded multi-project evaluation.
- Asset multipart path enforces part sizing and max part count safety.
- Agent routes include deterministic fallback synthesis to avoid empty conversation responses.
- Worker-side ephemeral retrieval caches now reduce repeated query latency (tenant/project/query scoped).
/api/agent/askexposes optionaldiagnosticspayload (cache hit state + stage timings) for live tuning.- Use
./scripts/benchmark-agent-retrieval.ps1to compare cache on/off and retrieval mode latency against production.
- No D1 dependency; Postgres only (Neon via Hyperdrive).
- Server-side tenant checks on all scoped routes.
- API token hashes stored server-side (not plaintext key storage).
- OAuth metadata and authorization endpoints for standards-compatible clients.
- Sensitive secrets are expected from deployment environment bindings, not committed values.
Prerequisites:
- Node.js 20+
- npm
- Rust toolchain
- Wrangler CLI logged in
Run web + API:
npm install
npm run dev- Web:
http://localhost:3000(Next dev) - API:
http://localhost:8787(Wrangler dev) - Playwright local E2E:
http://localhost:3040(configurable viaPLAYWRIGHT_BASE_URL)
Apply DB migrations:
cd api
npm run db:migrateBuild all:
npm run buildweb/deploys via Vercel CLI.api/deploys via Wrangler CLI.- API binds:
- Hyperdrive:
HYPERDRIVE->game-dev-memory-neon-db - R2:
MEMORY_BUCKET->game-dev-memory
- Hyperdrive:
Detailed runbook:
docs/deployment.md
- Expand automated end-to-end coverage to include Clerk login automation and streaming session flows.
- Add structured retrieval benchmarking dashboards (quality + latency trends).
- Improve CLI cross-platform binary matrix beyond current Windows x64 default path.
- Continue hardening memory curation policies (quarantine, dedupe, decay, promotion).
- Expand agent tooling ergonomics while preserving Memory API as the single source of truth.
docs/architecture.mddocs/api.mddocs/cli.mddocs/deployment.mddocs/e2e.mddocs/roadmap.md