Brainstorm CLI Integration P1-P4: Project Memory, Task Telemetry, Registry, Block Sync

2026-03-28

memoryapimcpsdk-tssdk-pyrbac

What We Built

Four foundational phases of the Brainstorm CLI integration, enabling CLI agents to use BrainstormRouter as their intelligence backend with full project isolation.

P1 - Project-Scoped Memory: All existing memory endpoints now accept an optional project parameter. Memory entries can be stored and queried within a project scope, allowing multiple CLI projects to maintain separate knowledge bases through the same tenant.

P2 - Task Run Telemetry: New /v1/agent/task-runs endpoints let CLI agents report completed task runs with cost, duration, model used, and other metadata. In-memory store with 1000-entry-per-tenant cap.

P3 - Project Registry: Lightweight /v1/projects/registry endpoints for CLI agents to register projects independently of the workspace hierarchy. Upsert-by-name semantics for idempotent sync.

P4 - Core Memory Blocks Sync: Bulk upsert endpoint at /v1/memory/blocks/sync for syncing structured knowledge (CLAUDE.md, conventions, team info) into memory blocks with stable key-based deduplication.

Why It Matters

Brainstorm CLI agents can now use BrainstormRouter as their persistent memory and telemetry backend. Project isolation means multiple codebases can share a single tenant without cross-contamination. Task telemetry feeds the intelligence loop for pattern learning and cost optimization.

How It Works

// Register a project
await client.projectRegistry.register({
  name: "brainstormrouter",
  path: "/Users/dev/Projects/brainstormrouter",
  budget_daily: 5.0,
});

// Store project-scoped memory
await client.memory.append("Uses Hono for HTTP routing", {
  block: "project",
  project: "brainstormrouter",
});

// Sync structured knowledge blocks
await client.memory.syncBlocks({
  project: "brainstormrouter",
  blocks: {
    project: [
      { key: "stack", value: "TypeScript/Hono + Turbo" },
      { key: "deploy", value: "AWS ECS Fargate" },
    ],
  },
});

// Report task completion
await client.taskRuns.report({
  task_name: "fix-lint-errors",
  project: "brainstormrouter",
  status: "completed",
  cost: 0.12,
  duration_ms: 45000,
  model_used: "anthropic/claude-sonnet-4",
});

The Numbers

  • 8 new API endpoints (11 routes including parameter variations)
  • 14 new SDK methods across TS and Python SDKs
  • 3 new MCP tools for agent-native access
  • RBAC: audit.write permission added for task telemetry

Competitive Edge

No other AI gateway provides project-scoped persistent memory with bulk sync and task telemetry in a single platform. Portkey and OpenRouter lack memory entirely. Letta has memory but no routing or project isolation. BrainstormRouter is the only platform where a CLI agent can register its project, sync its knowledge base, execute tasks, and report outcomes through a single API.

Lockstep Checklist

  • [x] API Routes: src/api/routes/memory.ts, task-runs.ts, projects-registry.ts updated.
  • [x] TS SDK: packages/sdk-ts — Memory, TaskRuns, ProjectRegistry resources added and wired.
  • [x] Python SDK: packages/sdk-py — Memory, TaskRuns, ProjectRegistry resources added and wired.
  • [x] MCP Schemas: br_task_run_report, br_project_register, br_memory_blocks_sync added to manifest and handlers.
  • [x] RBAC: Route permissions added for all new endpoints. audit.write permission type added.