Builderforce.ai
A human-in-the-loop, fully agentic cloud β train your own AI agents and use them inside your own agent, manage your whole workforce on a Kanban board, and review and approve every action without ever leaving VS Code.
What is Builderforce.ai?
Builderforce.ai is a human-in-the-loop, fully agentic cloud where ideas become software and software becomes agents. You stay in control of every step while AI agents do the work β train your own specialist agents and put them to work inside your own agent, manage the whole workforce from a Kanban board, and review, validate, and approve everything without leaving your editor. It combines a full in-browser IDE with an AI training pipeline, a Workforce Registry for specialist agents, and an orchestration portal for self-hosted BuilderForce Agents meshes.
Three capabilities at the core:
| Capability | What it does |
|---|---|
| π Train agents, use them inside your agent | Train a custom agent in-browser (WebGPU LoRA + AI evaluation), publish it to the Workforce Registry, then hire it and call it from inside your own agent β your specialists become tools your main agent delegates to. |
| β¦ Kanban board & project management | Organize work into projects, then plan, assign, and track every task on a live Kanban board (swimlanes per status or per agent, plus table, calendar, and Gantt views). Humans and AI agents share the same board. |
| π§© Never leave VS Code | The BuilderForce VS Code extension runs the whole platform in your editor β chat with agents, assign and run tasks, review and validate their work, and approve human-in-the-loop actions without leaving your code. |
One platform. Three roles:
| Role | What it does |
|---|---|
| Enterprise IDE | Full Node.js runtime in the browser (WebContainers + Monaco + xterm.js); real-time collaboration; AI pair programming |
| AI Training Studio | In-browser LoRA fine-tuning on instruction datasets; WebGPU-accelerated; models up to 2B parameters; no cloud GPU required |
| Orchestration Portal | BuilderForce Agent fleet management; task assignment; heartbeat monitoring; agent-to-agent mesh relay; approval gates |
Key Capabilities
In-Browser IDE
- Full Node.js runtime via WebContainers β run
npm install, Vite dev servers, and interactive shells without leaving the browser - Monaco Editor with syntax highlighting, IntelliSense, multi-file tabs, and real-time collaborative editing via Yjs CRDT
- xterm.js terminal connected directly to the WebContainer shell β full PTY, shared across collaborators
- AI Chat Panel β streaming AI assistant with full project file context; can apply code changes and create files directly
- Live Preview β iFrame running the Vite dev server; updates on save
AI Training Studio
- In-browser LoRA fine-tuning β uses @seanhogg/builderforce-memory / Transformers.js with WebGPU; trains Mamba-1/2/3 and GPT-style models up to 2B parameters entirely client-side
- Hybrid Local Brain β Mamba State Engine (
mamba-engine.ts) runs an O(n) selective scan alongside transformer inference; agent state persists to IndexedDB as a compact Float32 state vector and is embedded in exportedAgentPackageJSON - Dataset generation β LLM-assisted JSONL instruction dataset creation with SSE streaming progress
- AI evaluation β independent judge scores model outputs on code correctness, reasoning quality, and hallucination rate (0.0β1.0)
- WebGPU fallback β CPU software path via
forceFallbackAdapter: true; platform reportsgpuMode: 'cpu-fallback'transparently
Workforce Registry
- Publish specialist agents β bundle a LoRA adapter, capability profile, and
MambaStateSnapshotinto a portableAgentPackageJSON artifact - Skill-based discovery β agents are searchable by skills, evaluation score, and hire count
- Hire and deploy β one click to register an agent in your BuilderForce Agents mesh; PowerShell install script for local deployment
- Iterative improvement β
training_sessionstable tracks dataset β training β evaluation β re-training loops for continuous agent quality improvement
Local LLM Inference Pipeline
- Per-agent inference endpoint β
POST /api/ide/agents/:id/chatroutes inference through OpenRouter with the agent's persona injected into the system prompt;X-Inference-Mode: lora | hybrid | base | fallback-baseheader signals which path ran - Mamba state injection β v2.0 agents carry a
MambaStateSnapshot; each inference call prepends[Memory: step=N signal=X context="..."]to the system prompt, giving the agent persistent conversational memory without re-training - Mamba state sync β
PUT /api/ide/agents/:id/mamba-stateaccepts aMambaStateSnapshotfrom CoderClaw after each session; upgrades the agent package to v2.0 and recomputesinference_mode;GET /api/ide/agents/:id/mamba-stateretrieves the stored snapshot - Package versioning β agent packages are v1.0 (LoRA only) or v2.0 (LoRA + Mamba state);
GET /api/ide/agents/:id/packagereturns the correct format and incrementsrequest_count - Workforce routing in chat β
POST /api/ai/chatwithmodel: "coderclawllm/workforce-<agentId>"auto-routes to the agent inference endpoint; no client-side changes required - Inference logging β
agent_inference_logstable captures model ref, latency, token counts, status, and inference mode per request for observability and billing
BuilderForce Agents Orchestration Portal
Builderforce.ai is the cloud-side control plane for BuilderForce Agents self-hosted agents:
- Fleet registration β Claws register at
POST /api/clawswith machine profile (IP, workspace dirs, ports, tunnel metadata) - Heartbeat + capability sync β
PATCH /api/claws/:id/heartbeatkeeps capability maps and machine profiles current - Assignment context β
GET /api/claws/:id/assignment-contextdelivers assigned project metadata and context hints; CoderClaw syncs to.coderClaw/context.yaml - Claw-to-claw mesh relay β
ClawRelayDODurable Object proxies WebSocket connections between Claws;POST /api/runtime/forwarddispatches tasks to remote agents with HMAC-SHA256 payload verification (X-Claw-Signature) - Approval gates β human-in-the-loop control for high-impact agent actions; agents request approval before executing; outcomes are audited
- Task management β
tasksandexecutionstables track work assigned to specific Claws;POST /api/tasks/nextfeeds the next task to a waiting agent
Multi-Tenant Platform
- JWT auth with web token (global) + tenant token (workspace-scoped) dual-token model
- Multi-auth β email/password, OAuth social login (Google, GitHub, LinkedIn, Microsoft), and magic link sign-in all coexist on the same account
- Tenant isolation β all resources (projects, claws, agents, training jobs) are scoped to a tenant; no cross-tenant data access
- Multi-workspace β users belong to multiple tenants;
bf_default_tenant_idauto-selects on login - Admin observability β
/adminsurface for platform admins (superadmin flag);logs/global-errors.txtin R2;/observabilityLLM usage metrics
Billing & Subscriptions (Stripe)
- Stripe only β
src/infrastructure/payment/StripeProvider.ts(Stripe Checkout + Billing, hosted payment page, webhook-activated). There is deliberately no provider switch and no manual fallback: a fallback that activated plans without charging meant an unconfigured deploy handed out paid plans for free. - PaymentProvider interface β
src/infrastructure/payment/PaymentProvider.tskeepsTenantServiceoff the concrete Stripe client and lets tests inject a fake; it is not a provider-swap seam. - Checkout flow β
POST /api/tenants/:id/subscription/checkoutalways returns a hostedcheckoutUrl. The plan activates only when the signed webhook confirms payment β never from the request itself. - Webhook handler β
POST /api/webhooks/paymentreceives Stripe events; HMAC-verified with a 5-minute replay window; activates/cancels subscriptions via normalisedWebhookEvent - Configuration β set the
STRIPE_*Worker secrets (seesrc/infrastructure/payment/index.ts). They are validated lazily: absent secrets return 503 from the billing routes and never break Worker boot.
Dev Analytics & Team Intelligence
- Contributor profiles β cross-platform developer identity reconciliation (GitHub, Jira, Bitbucket);
GET /api/contributors - Activity ingestion β
POST /api/contributors/activityreceives PR opened/merged/reviewed, commit, issue events with automatic daily metric aggregation - Weighted activity score β per-contributor daily score (commitsΓ1 + PRsΓ3 + reviewsΓ2 + issuesΓ1.5); active dev day = β₯1 commit or PR action
- PR cycle time β end-to-end hours from
pr_openedtopr_mergedevents tracked on each activity record - Integration credential manager β AES-256-GCM encrypted platform credentials stored per-tenant;
GET/POST/PUT/DELETE /api/integrations; per-provider connectivity tests (POST /api/integrations/:id/test) - Team hierarchy β nested dev teams with managerβmember relationships;
GET/POST/PATCH/DELETE /api/dev-teams; member add/remove endpoints - Standup report β
GET /api/reports/standupβ daily summary: active contributors, commits, PRs merged, issues resolved; recent PRs and resolved issues - Code review report β
GET /api/reports/code-reviewβ 14-day window; stale PRs (>7 days old), average cycle time, reviewer activity - Executive summary β
GET /api/reports/executiveβ KPIs over configurable date range: contributor counts, total commits, PRs merged, lines added, average activity score, top contributors - Report schedules β
GET/POST/PATCH/DELETE /api/reports/schedules; cron-style delivery config (daily/weekly) with hour-of-day and recipient list - Report subscriptions β
GET/POST /api/reports/subscriptions; per-user opt-in/opt-out per report type
Platform Infrastructure
- Per-tenant rate limiting β
TenantRateLimiterDOCloudflare Durable Object; sliding window (60 RPM FREE, 300 RPM PRO, 1000 RPM TEAMS);X-RateLimit-Limit/Remaining/Reset+Retry-Afterheaders - Auto-approval rules β
GET/POST/PATCH/DELETE /api/approval-rules; rule evaluation onPOST /api/approvalsby actionType, max cost, max files changed; bypasses human gate when conditions match - Approval notifications β Slack webhook + Resend email alerts on new approval requests and decisions; configurable via
SLACK_APPROVAL_WEBHOOK_URL+RESEND_API_KEY - Escalation cron β
GET /api/approvals/escalate?secret=expires timed-out pending approvals and fires Slack alert; suitable for Cloudflare Cron Triggers - OTel telemetry proxy β
POST /api/telemetry/spansingest;GET /api/telemetry/spansquery;GET /api/telemetry/traceslist; costs stored as millicent integers; W3CX-Trace-Idheader forwarded from CoderClaw
Latest Capabilities
The platform has grown from an IDE-plus-training studio into a full system of record for agentic work. These are the most recent additions β the enterprise delivery, quality, knowledge, and FinOps surfaces that sit on top of the agent workforce.
Planning Spine β Portfolio to Task (mig 0213, 0225)
- One dated, cost-bearing hierarchy β
portfolio β initiative β epic β task, with Objectives and Key Results attaching as a goal layer at any level. Every level is dated and rendered on a single nested Gantt (PlanningSpineGantt). - Cost rolls up from the leaf β LLM spend (priced at write time from
llm_usage_log) plus human effort (member cost rate Γ hours) rolls up to every ancestor. No parallel finance system, no backfill. - CAPEX / OPEX split β each node carries a
cost_classresolved in priority order (explicit β inherited β agent-classified by investment category β GAAP-conservative default). A child class that contradicts its parent is flagged as an anomaly for PM reconciliation. - Endpoints β
GET /api/pmo/spine,GET /api/pmo/spine/export.csv,GET /api/pmo/rollup(portfolio/initiative/workspace),PATCH /api/pmo/cost-class,POST /api/pmo/cost-class/classify, initiativePOST/DELETE /api/pmo/dependencies(cycle-checked) β on-demand critical path. Surface:/projects?tab=portfolio, gated byinsights.portfolio/insights.pm.
Quality β Error Observability + One-Click Agent Fix (mig 0240)
- Multi-source ingest β one canonical event shape behind five adapters: native (the
@seanhogg/builderforce-qualitybrowser SDK), OTLP, Sentry, PostHog, LogRocket (webhooks HMAC-verified; Sentry connections can backfill). - Fingerprint grouping β events upsert into
error_groupskeyed by(tenant, project, fingerprint)β explicit fingerprint or derived from the top stack frame + normalized message; occurrence + exact distinct-user counts; resolved bugs reopen on recurrence. - One-click fix loop β
POST /api/quality/groups/:id/fixcreates a board task (titled + prioritized from the error, briefed with the stack trace) and dispatches a cloud agent that ships a pull request. Crash β group β task β PR on one surface. - Endpoints β authenticated
/api/quality/*(collectors, integrations, rules, groups, fix); public keyed/HMAC ingest/api/quality-ingest/{events,otlp/v1/logs,otlp/v1/traces,webhooks/:collectorId/:provider}. Dashboard:/quality. Metered aserror_events.
Knowledge Management & Compliance (mig 0227)
- Versioned SOPs, processes & docs β live editable body plus an immutable snapshot on every publish (version number + change note + publisher).
- Audit-ready acknowledgements β read-acknowledgements bind to a specific version with a timestamp; per-user state is acknowledged / pending / overdue, with manager rollups at
GET /api/knowledge/complianceβ evidence for SOX, TISAX, ISO 27001. - AI authoring + analysis β
POST /api/knowledge/ai/draftstreams a Markdown draft;POST /api/knowledge/documents/:id/analyzereturns structured findings (inefficiency / gap / risk / clarity) + an improved flow. Metered through the LLM gateway. - Real-time co-editing β Yjs CRDT over
NEXT_PUBLIC_COLLAB_WS_URLwith presence awareness; per-document editor/viewer collaborators on top of workspace roles; falls back to autosave when collaboration is unconfigured. Surface:/knowledge.
Single-Pane Board Connectors (mig 0221)
- Two-way sync across 10 systems β each provider implements
fetchTicketsSince(cursor)+pushUpdate(externalId, changeSet), normalizing to one ticket shape stamped with its source.- PM / work: GitHub Issues, Jira, Linear, monday.com, Asana, ClickUp
- ITSM: ServiceNow, Freshservice
- Incident: Sentry, PagerDuty
- Webhooks where supported (GitHub, Jira, Linear, monday, Sentry, PagerDuty), polling otherwise. Agents act on a ticket or incident wherever it originates; changes flow back to the system of origin β single pane, no migration.
- Endpoints β
GET /api/board-connections/providers(catalog), CRUD/api/board-connections,POST /api/board-connections/:id/sync,GET /api/board-connections/:id/links.
Platform Migration & Integration Hub (mig 0256)
Move off a competitor tracker without fear, or just sync data in β a staged importer on top of the connector framework. Nothing lands in real projects/tasks/members until you commit.
- Provider discovery β
discover()enumerates external projects, item types, and users for Jira, monday, Rally, GitLab, Bitbucket, GitHub (the migration-eligible providers; new Rally/GitLab/Bitbucket adapters added). - Staging buffer β
import_runs+import_staged_{projects,items,users}+import_type_mappings; combine several external projects into one BuilderForce project, map item types β task type/status, and invite/map users β all reviewed before import. - Migrate / sync / both β one-time historical import, an ongoing
board_connectionssync, or both. The persistentboard_type_mappingsmakes ongoing sync land tasks in the mapped type/status (not a hardcoded backlog). Imported items keep their assignee (mapped to a member) and story points. - Integrations gallery β
/settings/integrationsis the workspace home: cards by category (PM / SCM / ITSM / incident), per-provider config panel (Credentials Β· Connections Β· Activity/diagnostics), and a "Start migration" launcher. GitHub/GitLab/Bitbucket connect both issues (migration) and repositories (code). - Brain-drivable β the whole flow is in the gateway MCP catalog (
integrations.create_credential/test,migrations.start/set_mappings/stage/commit); the Brain (right-docked) opens the migration panel on the left viaopen_migration_panel. - Endpoints β
/api/migrations(start/list/get/:id/mappings/:id/stage/:id/commit, MANAGER+, cached + version-bumped).
Agentic Tester β Autonomous QA (mig 0063, 0206)
- Heatmap-ranked exploration β journey events (
POST /api/qa/events) rank route-and-element zones by recency-weighted frequency (GET /api/qa/heatmap); explorations plan from the hottest zones within a budget. - AI-generated Playwright β
POST /api/qa/generateturns a flow into an executable spec and resolves a persona credential; a deterministic heatmap-only plan is also available (no model cost). - Authenticated container runs β a harness claims an exploration, logs in as a real persona (encrypted, developer-gated credentials), walks the plan, and captures console/page errors, failed requests, assertion failures, and crashes.
- Findings β board β fix β findings dedupe by fingerprint; with auto-routing enabled, any finding at/above the severity threshold becomes a board task in a fix lane, firing the same lane auto-run a human board drag triggers β a fix agent opens a PR. Schedules run it on cron. Quality trend (escaped vs caught defects) at
GET /api/qa/quality.
Consumption Metering (mig 0218)
- Meter on consumption, not visibility β one framework (
/api/consumption) reports month-to-date usage forai_tokens,ingestion(bytes), anderror_eventsagainst the plan allowance, using the same accountants the gateway and ingestion gate enforce β so the "% used" a member sees equals the cap that's enforced. Cached 60s, keyed per tenant + calendar month.
Coordinated Role Participation & Accountability (mig 0334)
- The right role does the work β first-class agentβrole capability (
ide_agents.role_keys) drives role-aware assignment: a producer stage resolves the role from the ticket'saction_typeand dispatches a role-capable agent/human, never a mis-assigned one. Stops the "a Product Manager was dispatched to write code" class of failure. - A participation manifest per ticket β
ticket_participantsderives the required roles from the board's swimlane requirements, resolves each slot by capability, and tracks per-participant state (pending / assigned / in_progress / completed / changes_requested / waived / unstaffed). - An immutable Accountability Report β an append-only
ticket_role_signoffsledger records Who / When / Verdict / Comments / Contribution per role; default-deny RBAC (only role-capable members may sign off as a role); every sign-off emits to the unified activity log. A Resource Assessment control adds a needed role beyond the template β an unresolved add surfaces as a blocking resource gap. - Endpoints β
GET /api/kanban/tasks/:id/accountability,/participants,POST /participants(assess) //materialize, plus MCPkanban.participants/kanban.accountability/kanban.assess_resource. Surface: the ticket-drawer Accountability tab + a boardX/Yparticipants chip.
Pre-Sales RFP / RFQ Response (mig 0335)
- Turn a repo into a proposal β CTO + Product Owner built-in agents generate a branded, costed proposal from a project's analyzed capabilities: cost / P&L, a phase Gantt, risks, dependencies, and a capability roster matched to the ask.
- Co-branded output β the requester's palette + logo blend with the responder's for a branded, self-contained proposal document (print-to-PDF / download), with freshness-gated grounding (a >5-day-stale scan re-runs the deterministic system audits before answering).
- Surface β a Projects RFP tab (list / create) +
/projects/rfp/[id]detail;/api/rfproutes.
Incident Management & Active Monitoring (mig 0292)
- Incidents close the loop β a Help-Desk / Incident-Manager agent, a Freshdesk connector, on-call rotations, timed escalation, Teams / Slack / email paging, and a per-incident war-room feed. On resolution the RCA is published to Knowledge and fed to the project's Evermind, so the workforce learns and stops repeating causes.
- A monitoring canvas β pin heartbeat / HTTP / webhook / metric monitors onto an uploaded architecture diagram; a
*/5sweep evaluates them and a breach auto-starts the on-call investigation (monitor β signal β incident β paging), with reporting on the timeline.
Meetings & Live Collaboration (mig 0292, 0330)
- Video / audio meetings with agents in the room β mesh WebRTC over a
CeremonyRoomDOrelay; agent attendees speak live via a caption / transcript bridge; recording + transcription produce AI minutes. Google / Microsoft calendar sync. Surface:/meetings.
AI Managers β Types & Coaching (mig 0327)
- Typed managers tied to the role catalog β Dev / QA / Service-Desk / DevOps manager types map to
roleCatalog(custom roles becomerole:<key>types); a human β manager Coaching Session carries directive | task modes with expiry / done state, steering how a manager agent runs its reports.
Memory-First Answering β skip the paid LLM
- Answer from the project's own memory before spending a model call β the web and VS Code webview Brain consult the project's
project_factsfact tier + its Evermind SSM first and short-circuit the LLM on a confident hit (an exact-repeat Q&A cache + opt-in Evermind-first inference), single-sourced inresolveMemoryAnswer. Learning fans out to every Evermind under a project (its own head + its IDE builds' heads) via one sharedcontributeTextToProjectEverminds. Endpoints:GET/POST /api/projects/:id/answer,GET /api/projects/:id/evermind/targets.
Authentication
Builderforce.ai supports three sign-in methods that coexist on the same account. A single user can link multiple OAuth providers, set a password, and use magic links interchangeably.
Sign-in methods
| Method | How it works |
|---|---|
| Email + password | POST /api/auth/web/login β PBKDF2 (100k iterations, SHA-256); same generic error for wrong email or wrong password |
| OAuth social login | GET /api/auth/oauth/:provider β provider consent β GET /api/auth/oauth/:provider/callback β JWT issued; browser redirected to /auth/callback?token=β¦ |
| Magic link | POST /api/auth/magic-link sends a 15-minute single-use token by email; GET /api/auth/magic-link/verify?token=β¦ issues JWT; always returns 200 (no email enumeration) |
Supported OAuth providers: google, github, linkedin, microsoft.
Auth flow diagram
Browser
β
ββ Email/password βββββββββββββββββββββββββββΊ POST /api/auth/web/login
β Returns JWT in JSON body
β
ββ OAuth (click button) βββββββββββββββββββββΊ GET /api/auth/oauth/:provider
β 302 β provider consent screen
β Provider β GET /api/auth/oauth/:provider/callback
β API issues JWT
β 302 β /auth/callback?token=JWT
β Frontend page writes token to localStorage
β
ββ Magic link βββββββββββββββββββββββββββββββΊ POST /api/auth/magic-link
Email sent with /auth/magic-link?token=β¦
Frontend page calls GET /api/auth/magic-link/verify
Returns JWT in JSON body
JWT strategy
- Web token (
localStorage key: bf_web_token) β 24-hour HMAC-SHA-256 JWT; payload:{ sub, email, username, amr?, sa?, jti, sid } - Tenant token (
localStorage key: bf_tenant_token) β 1-hour workspace-scoped JWT; issued byPOST /api/auth/tenant-token - Every issued token is tracked in the
auth_tokenstable (JTI + session ID);webAuthMiddlewarevalidates against this table on every request, enabling instant revocation
Account management endpoints
| Endpoint | Auth | Description |
|---|---|---|
GET /api/auth/linked-accounts | Web JWT | List linked OAuth providers + whether account has a password |
DELETE /api/auth/unlink/:provider | Web JWT | Unlink a provider; blocked if it would remove the last sign-in method |
POST /api/auth/add-password | Web JWT | Add a password to an OAuth-only account |
OAuth security
- CSRF protection β OAuth
stateparameter is HMAC-SHA-256 signed (usingJWT_SECRET) with a nonce and 10-minute expiry; no database required - Account linking β if an OAuth email matches an existing account, the provider is linked automatically; the user controls their email so this is safe
- Email-only users β OAuth users who haven't set a password are protected from the unlink endpoint; they must
POST /api/auth/add-passwordfirst
Enabling OAuth providers
Each provider is activated by supplying its client credentials as Cloudflare Worker secrets. Providers with missing credentials silently return 503 β you only need to configure the providers you want.
# Google
wrangler secret put GOOGLE_CLIENT_ID
wrangler secret put GOOGLE_CLIENT_SECRET
# GitHub
wrangler secret put GITHUB_CLIENT_ID
wrangler secret put GITHUB_CLIENT_SECRET
# LinkedIn
wrangler secret put LINKEDIN_CLIENT_ID
wrangler secret put LINKEDIN_CLIENT_SECRET
# Microsoft
wrangler secret put MICROSOFT_CLIENT_ID
wrangler secret put MICROSOFT_CLIENT_SECRET
Register the OAuth callback URL in each provider's dashboard:
https://api.builderforce.ai/api/auth/oauth/{provider}/callback
Replace {provider} with the lowercase provider name: google, github, linkedin, microsoft.
Provider setup
| Provider | Setup time | Manual review? | Key gotcha |
|---|---|---|---|
| ~10 min | No (for email profile openid) | Must publish the consent screen before non-test users can sign in | |
| ~10 min | No (auto-approved) | Must add the "Sign In with LinkedIn using OpenID Connect" product β without it the /v2/userinfo endpoint won't return the email address | |
| GitHub | ~5 min | No | Only one callback URL per app β create a second OAuth App for local dev |
| Microsoft | ~10 min | No | Use "Accounts in any organizational directory and personal Microsoft accounts" for broadest coverage |
- Go to console.cloud.google.com, create or select a project
- APIs & Services β OAuth consent screen
- User Type: External
- App name, support email, add scopes:
email,profile,openid(non-sensitive, no review required) - Add your email as a test user while in development
- APIs & Services β Credentials β Create Credentials β OAuth 2.0 Client ID
- Application type: Web application
- Authorized redirect URIs β add both:
https://api.builderforce.ai/api/auth/oauth/google/callback http://localhost:8787/api/auth/oauth/google/callback
- Copy Client ID and Client Secret:
wrangler secret put GOOGLE_CLIENT_ID wrangler secret put GOOGLE_CLIENT_SECRET
Publishing: While in "Testing" mode only test users can sign in. Click Publish App on the consent screen when ready for production β
email/profile/openidare standard scopes and are typically approved immediately with no manual review.
- Go to linkedin.com/developers β Create App
- App name, LinkedIn Company Page (required β create one if needed), logo
- Auth tab β Authorized redirect URLs β add both:
https://api.builderforce.ai/api/auth/oauth/linkedin/callback http://localhost:8787/api/auth/oauth/linkedin/callback - Products tab β request "Sign In with LinkedIn using OpenID Connect" β click Request access (auto-approved instantly). This unlocks the
openid profile emailscopes used by the code. Without it the/v2/userinfoendpoint will not return the email address. - Back on the Auth tab, copy Client ID and Client Secret:
wrangler secret put LINKEDIN_CLIENT_ID wrangler secret put LINKEDIN_CLIENT_SECRET
GitHub
- GitHub β Settings β Developer settings β OAuth Apps β New OAuth App
- Homepage URL:
https://builderforce.ai - Authorization callback URL:
https://api.builderforce.ai/api/auth/oauth/github/callback
- Homepage URL:
- Click Register application, then Generate a new client secret
- Set secrets:
wrangler secret put GITHUB_CLIENT_ID wrangler secret put GITHUB_CLIENT_SECRET
Local dev: GitHub allows only one callback URL per app. Create a separate OAuth App (e.g. "builderforce-dev") pointing to
http://localhost:8787/api/auth/oauth/github/callbackand use its credentials inapi/.dev.vars.
Microsoft
- Azure Portal β Microsoft Entra ID β App registrations β New registration
- Supported account types: "Accounts in any organizational directory and personal Microsoft accounts"
- Redirect URI (Web):
https://api.builderforce.ai/api/auth/oauth/microsoft/callback
- Certificates & secrets β New client secret β copy the value immediately (it's only shown once)
- Copy the Application (client) ID from the Overview page
- Set secrets:
wrangler secret put MICROSOFT_CLIENT_ID wrangler secret put MICROSOFT_CLIENT_SECRET
Local development
For local development, use api/.dev.vars β Wrangler loads this file automatically for wrangler dev, and it is gitignored:
# api/.dev.vars
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
LINKEDIN_CLIENT_ID=your_linkedin_client_id
LINKEDIN_CLIENT_SECRET=your_linkedin_client_secret
GITHUB_CLIENT_ID=your_github_dev_app_client_id
GITHUB_CLIENT_SECRET=your_github_dev_app_client_secret
APP_URL=http://localhost:3000
The OAuth callback URL is derived from the incoming request's Origin header at runtime, so no extra API_URL variable is needed β it resolves to http://localhost:8787 locally and https://api.builderforce.ai in production automatically.
Magic link email
The sendMagicLinkEmail function in api/src/presentation/routes/oauthRoutes.ts is a placeholder that logs the link to the console. Wire it to your email provider (Resend, SendGrid, Mailgun, etc.) before using magic links in production:
// api/src/presentation/routes/oauthRoutes.ts ~line 253
async function sendMagicLinkEmail(to, name, token, frontendUrl) {
const magicUrl = `${frontendUrl}/auth/magic-link?token=${encodeURIComponent(token)}`;
// TODO: call your email provider here
}
Frontend routes added
| Route | File | Purpose |
|---|---|---|
/auth/callback | frontend/src/app/auth/callback/page.tsx | Receives ?token=JWT from OAuth redirect, persists session, navigates |
/auth/magic-link | frontend/src/app/auth/magic-link/page.tsx | Calls /api/auth/magic-link/verify, persists session, navigates |
Integration with BuilderForce Agents
Developer workstation
ββ BuilderForce Agents (self-hosted, MIT)
ββ 7-role agent DAG (Code, Review, Test, Debug, Refactor, Document, Architect)
ββ Staged diff review (accept/reject before writing to disk)
ββ Agent-to-agent mesh (remote:<id>, remote:auto[caps], HMAC-signed dispatch)
ββ Workflow telemetry β .builderforce/telemetry/ + portal timeline
ββ Execution lifecycle β running/completed/failed reported to portal
ββ Approval gate β blocks on manager decision from portal
ββ Skill registry β loads portal-assigned skills at startup
ββ Cron scheduler β executes portal-managed jobs on schedule
ββ BUILDERFORCE_API_KEY β heartbeat β Builderforce.ai
β βtask.assign / task.broadcast
β βapproval.decision
β βcron jobs / skill assignments
βββββββββΌββββββββ
β Builderforce β
β .ai β
β β
β β’ Fleet view β
β β’ Task assign β
β β’ Approvals β
β β’ Audit log β
β β’ AI training β
β β’ Registry β
β β’ Cron jobs β
β β’ Skills mkt β
βββββββββββββββββ
Configure CoderClaw to connect:
export BUILDERFORCE_API_KEY=<your-api-key>
export BUILDERFORCE_URL=https://api.builderforce.ai
coderclaw start
CoderClaw operates fully standalone without Builderforce. The connection unlocks fleet visibility, task assignment with live execution tracking, enforced approval gates, portal-managed skill assignments, scheduled cron execution, and access to the Workforce Registry.
On-Device AI Stack
Builderforce.ai is built on the open-source @seanhogg/builderforce-memory stack for on-device AI:
@seanhogg/builderforce-memory-engine (engine)
ββ WebGPU WGSL kernels: Mamba-1 (S6), Mamba-2 (SSD), Mamba-3 (complex MIMO+ET), causal attention
β
@seanhogg/builderforce-memory (runtime)
ββ MambaSession.create() β one-call GPU init, tokenizer, model, checkpoint, persistence
ββ Inference routing Β· distillation Β· semantic memory Β· SSMAgent
β
Builderforce.ai IDE
ββ mamba-engine.ts β Hybrid Local Brain (SSM state + IndexedDB)
ββ agent-runtime.ts β step() β inference β confidence scoring β cloud escalation
ββ webgpu-trainer.ts β LoRA fine-tuning pipeline (Transformers.js + WebGPU)
The on-device AI layer runs in O(n) time (vs O(nΒ²) for attention), making it suitable for continuous low-latency state updates and fine-tuning entirely in the browser.
Both packages are published on npm:
@seanhogg/builderforce-memory-engine(engine) and@seanhogg/builderforce-memory(runtime).
Cross-surface semantic cache (token savings)
The biggest cost lever in the stack is an embedding-keyed semantic cache that reuses a prior answer when a new prompt is a paraphrase of one already answered β so the frontier model is never called for semantically-repeated work. It is two-tier and shared across surfaces:
- L1 (local, free): in-process cosine match using on-device SSM embeddings β runs in the browser IDE and in each agent.
- L2 (shared): the gateway's
POST /v1/semantic-cache/{lookup,store}(tenant-scoped, KV-backed). A paraphrase answered in the web app is reusable by an agent, and vice-versa.
The same portable SemanticCache from @builderforce/memory powers both surfaces β the embedder (on-device SSM) and the L2 backend are injected, so there is no browser/Node fork. On-device embeddings make L1 free; the gateway L2 turns one tenant's cache hits into platform-wide savings.
Hybrid retrieval & answer evaluation
Builderforce.ai implements the full seven-layer agent stack β and the two layers most stacks leave conventional-thin (RAG retrieval and evaluation) are built out:
- Hybrid RAG. Retrieval fuses dense (SSM / OpenAI embeddings, cosine) and sparse (Okapi BM25 keyword) signals with Reciprocal Rank Fusion, then reranks with MMR for relevance and diversity β over documents chunked with a recursive splitter + overlap. Dense search alone misses exact tokens (identifiers, error codes, rare names); the hybrid path catches them. It degrades gracefully (no embedding β BM25-only; no overlap β dense-only). Lives zero-dependency in
@seanhogg/builderforce-memory/retrieval(chunkText,bm25Search,reciprocalRankFusion,maximalMarginalRelevance,hybridRetrieve,MemoryStore.recallHybrid) and powers the LanceDB long-term-memory extension. - Semantic evaluation + drift. Every cloud run is scored for faithfulness, answer relevance, and hallucination rate β inline and zero-cost (lexical), with an LLM-as-judge upgrade on demand at
POST /api/eval(billed through the metered gateway). Scores persist on the run record; a drift monitor (mean-shift z-score + Population Stability Index) compares baseline vs recent windows per (action-type Γ model) and raises an alert when quality regresses β daily on cron and on demand atGET /api/eval/drift. A wrong answer no longer hides behind a green dashboard.
See the write-up: The AI Agent Tech Stack, Built.
Architecture
ββββββββββββββββββββββββββββ Browser βββββββββββββββββββββββββββββββ
β β
β Next.js (App Router) WebContainer β
β βββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
β β Monaco Editor βββββββββΊβ Node.js (in-browser) β β
β β xterm.js Terminal β β npm install β β
β β Preview <iframe> β β Vite dev server β β
β β AI Chat Panel β β File system (OPFS-backed) β β
β β Train Panel β ββββββββββββββββββββββββββββββββ β
β β Agent Publish β β
β ββββββββββββ¬βββββββββββ β
β β HTTP / WebSocket β
βββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββ Cloudflare Edge βββββββββββββββββββββββ
β β
β API (api.builderforce.ai β Hono) Durable Objects β
β ββββββββββββββββββββββββββββββ ββββββββββββββββββββββββ β
β β /api/auth /api/tenants β β ClawRelayDO β β
β β /api/claws /api/tasks β β - claw mesh relay β β
β β /api/brain /api/projects β β - heartbeat proxy β β
β β /api/runtime/executions β ββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββ ββββββββββββββββββββββββ β
β β CollaborationRoom β β
β Worker (worker.builderforce.ai) β - Yjs CRDT sync β β
β ββββββββββββββββββββββββββββββ β - cursor presence β β
β β /api/projects (IDE files) β β - terminal relay β β
β β /api/datasets /api/trainingβ ββββββββββββββββββββββββ β
β β /api/agents (Registry) β β
β β /api/ai/chat (streaming) β R2 Buckets β
β ββββββββββββββββββββββββββββββ ββββββββββββββββββββββββ β
β β project files β β
β Neon Postgres β datasets (.jsonl) β β
β ββββββββββββββββββββββββββββββ β LoRA artifacts β β
β β users Β· tenants Β· projects β β agent packages β β
β β claws Β· tasks Β· executions β ββββββββββββββββββββββββ β
β β agents Β· training_jobs β β
β β agent_inference_logs β β
β β contributors Β· dev_teams β β
β β activity_events Β· metrics β β
β β integrations Β· telemetry β β
β ββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Two Cloudflare Workers, one platform:
api (api.builderforce.ai) | worker (worker.builderforce.ai) | |
|---|---|---|
| Purpose | Auth, tenants, claws, tasks, brain, marketplace, dev analytics | IDE projects, files, datasets, training, collaboration |
| Auth | JWT + tenant isolation | CORS (no auth currently) |
| Durable Objects | ClawRelayDO (claw mesh relay) | CollaborationRoom (Yjs sync) |
| Storage | R2 UPLOADS (brain files, claw assets) | R2 STORAGE (project files, artifacts, datasets) |
Quick Start
Local development
git clone https://github.com/SeanHogg/Builderforce.ai
cd Builderforce.ai
# Install deps
pnpm install # or npm install in each sub-directory
# Configure
echo "NEXT_PUBLIC_WORKER_URL=http://localhost:8787" > frontend/.env.local
echo "NEON_DATABASE_URL=postgresql://..." > worker/.env
# Run migrations
cd worker && npm run migrate && cd ..
# Start (in separate terminals)
cd worker && npx wrangler dev # :8787
cd frontend && npm run dev # :3000
Open http://localhost:3000. WebGPU training requires Chrome 113+.
Deploy to Cloudflare
cd api && npm run secrets:from-env && npm run deploy
# Frontend: CI/CD via .github/workflows/deploy-frontend.yml
Required secrets: CF_API_TOKEN, CF_ACCOUNT_ID, NEON_DATABASE_URL, JWT_SECRET, OPENROUTER_API_KEY. (SDK publishing uses npm Trusted Publishing OIDC β no NPM_TOKEN secret needed; see below.)
Releases: release.yml runs four independent jobs in parallel: npm packaging, API deployment, frontend deployment, and help-site deployment. The package-npm job builds, tests, and publishes each public package only when its package.json version is absent from npm, making re-runs idempotent. Auth uses npm Trusted Publishing OIDC (with NPM_TOKEN as an optional bootstrap fallback). Configure each package's trusted publisher for Organization SeanHogg, Repository Builderforce.ai, and Workflow release.yml.
Optional OAuth secrets (add only the providers you want):
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, LINKEDIN_CLIENT_ID, LINKEDIN_CLIENT_SECRET, MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET
Browser Requirements
| Feature | Required |
|---|---|
| WebContainers (in-browser Node.js) | Chrome 90+, Edge 90+ (COOP + COEP headers) |
| WebGPU LoRA training | Chrome 113+ |
| Collaborative editing | Any modern browser |
| CPU fallback training | Any browser (via forceFallbackAdapter) |
Chrome is the recommended browser. Firefox and Safari do not support WebContainers.
Design System
The UI follows the CoderClaw deep space aesthetic β consistent across Builderforce.ai and CoderClaw:
| Token | Dark | Light |
|---|---|---|
--bg-deep | #050810 | #fcfeff |
--bg-surface | #0a0f1a | #ffffff |
--coral-bright | #4d9eff | #3b82f6 |
--cyan-bright | #00e5cc | #008f87 |
--font-display | Clash Display | Clash Display |
--font-body | Satoshi | Satoshi |
Theme persists to localStorage('bf-theme') with an anti-FOUC inline script applied before first paint.
Roadmap & Gap Register
Planned milestones (including PHASE 4 β Multi-Agent Orchestration at Scale) and the full Consolidated Gap Register β 341 items (53 resolved Β· 288 open, grouped by revenue impact) plus archived thematic context β now live in ROADMAP.md, the single source of truth for planned work and deferred issues. New deferred issues are appended there.
Cloud Agent Types
Builderforce runs agents on two execution planes β On-Prem (Hosted) and Cloud. There is ONE agent engine (the current version), so the Cloud plane is a single Cloud Agent that runs on one of two surfaces: a Durable Object or a Node/Container. The routing decision is a single source of truth in cloudDispatch.ts (resolveCloudSurface / cloudAgentTypeLabel) and runtimeRoutes.ts (resolveCloudAgent); the surface column lives on ide_agents (runtime_surface migration 0105). The engine is never read from the DB β it is always the current version.
Cloud vs. On-Prem is a hard boundary. A cloud agent executes only in the cloud (everything is Cloudflare β Worker, Durable Object, or Container). A cloud agent is never dispatched to a client machine. An On-Prem (Hosted) agent β an agentHost, of which many can run on one machine β runs a task only when a host is explicitly pinned to it. See the agent taxonomy ([[agent-types-taxonomy]]).
At a glance
| Cloud Agent surface | Where it runs | Persistent shell? | Best for |
|---|---|---|---|
| Cloud Agent (Durable Object) | durable β CloudRunnerDO, one LLM step per alarm() tick. Default surface. | No (CI verifies builds) | Most cloud tasks: on-demand, no always-on compute, survives long runs |
| Cloud Agent (Node/Container) | container β long-lived Cloudflare Container (AgentContainerDO) | Yes (run_command) | Very long / continuous tasks needing a real shell to install deps + run builds/tests/lint |
| (On-Prem Hosted β for contrast) | Client machine (agentHost), only when pinned | Yes (the host's own machine) | BYO-machine execution; not a cloud agent |
Cloud Agent (Durable Object) β surface durable
The default. Runs the Claude Agent SDK tool loop fully in the cloud across Durable Object alarm() ticks β one LLM step per tick, conversation state persisted in DO storage between ticks (CloudRunnerDO). Inference routes through the LLM Gateway using the tenant's BYO Anthropic key.
Features
- One step per
alarm()tick; each tick is a fresh Worker invocation with a fresh CPU/subrequest budget, so a multi-step run never hits the ~30swaitUntilwall that kills the interim Worker executor. - A cursor in
state.storageis the idempotency/resume anchor β the loop resumes exactly where it left off. - Heartbeats
executions.updated_atevery tick, so the orphan reaper treats an actively-ticking run as alive and only reaps a genuinely silent one. - The DO surface pins the same model for every tick of a run.
Pros
- On-demand serverless β no always-on compute, nothing to keep warm.
- Robust to long runs and eviction; the canonical, recommended cloud surface.
- Full Claude Agent SDK loop: per-tool timeline, steering/chat, approval gates.
Cons
- No shell β it cannot run builds/tests itself; correctness is verified by CI, not by the agent before finishing.
- Per-tick overhead (alarm scheduling, state rehydrate) makes it less efficient for a single very long, chatty session than a persistent process.
- Requires a tenant Anthropic key wired through the Gateway.
When the
CloudRunnerDObinding is absent there is no fallback executor β dispatch resolves tounavailableand the run fails fast with that reason. An in-request Worker executor used to be documented here as an interim fallback, but it could not survive the ~30swaitUntilwall on a multi-step run, so it was never selectable and has been removed: a clear "no executor bound" error beats a run that silently dies mid-task and gets orphan-reaped.
Cloud Agent (Node/Container) β surface container
The Claude Agent SDK loop running in a persistent Node process inside a real Cloudflare Container (AgentContainerDO). The container boots a small HTTP server; the DO is the Cloudflare-Containers control plane that starts/stops it and proxies the run. The container drives the loop and calls back into the Worker for every LLM step, repo telemetry, and the final PR β so the Worker stays the single source of truth for the Gateway, usage metering, and PR finalize.
Features
- Real shell (
run_command): clone the repo, install deps, run actual builds / tests / lint, and verify before finishing. - Persistent process β runs continuously for very long tasks without per-tick overhead.
enableInternetfor Gateway + GitHub reach from inside the container; stays warm20mafter the last request, then sleeps to stop billing.- This is also the surface an explicitly-pinned host maps to (a long-lived runtime reached via the relay).
Pros
- Genuine end-to-end verification (the agent runs the build/tests itself, not just CI).
- Best fit for long-running, continuous, or shell-heavy work.
Cons
- Container infra is a future build. Until it lands, a
containerrun falls back to the durable DO so it still executes in the cloud β so today you do not actually get a persistent shell from this selection. - Heaviest/most expensive surface (always-on-ish process, warm-keep billing).
- Same Gateway / tenant-Anthropic-key requirement as the durable surface.
How a type is selected at dispatch
resolveCloudAgent reads the agent's runtime_surface from ide_agents (the engine is always the current version, never read); resolveCloudSurface(agentSurface, hasExplicitHost) then picks the surface β an explicitly-pinned host β container, otherwise the agent's chosen surface, defaulting to durable. cloudAgentTypeLabel(surface) produces the human label used for run attribution (Cloud Agent (Durable Object) / Cloud Agent (Node/Container)).
LLM Surfaces
Builderforce exposes three distinct LLM systems β they are easy to conflate, and each has its own code path. Scope work against the right one:
| # | Surface | What it is | Status | Entry point |
|---|---|---|---|---|
| A | LLM Gateway | Multi-vendor hosted chat proxy (failover, cooldowns, per-tenant budgets). Powers IDE Brain chat and studio prompt-expansion. | β Shipped | api/src/application/llm/, PRD |
| B | Custom LLM Support | Serve a user's fine-tuned LoRA agent to the CoderClaw CLI (POST /api/agents/:id/chat). | π‘ Specced β P0 gaps open (see below) | "## Custom LLM Support" section below |
| C | In-IDE llm modality | Build + train a custom model in the browser (dataset β WebGPU LoRA/Mamba β publish), then chat with it. | π’ Cloud path live; Local/Hybrid pending | frontend/src/lib/modality.ts, LlmStudioPanel.tsx |
Cloud inference for the in-IDE modality (C) routes through the Gateway (A). On-device Local and Hybrid inference for (C) are gated until the Mamba WGSL kernel and R2 weights land β see the Consolidated Gap Register.
Custom LLM Support
IDE spec reference:
ide-architecture (1).mdin the repository root β the Builderforce.ai IDE architecture document (v2.0, March 2026).
This section details every change the Builderforce.ai platform (IDE frontend + Cloudflare Worker backend) must make to fully support custom LLMs built through the IDE β so that fine-tuned agents can be stored, served, versioned, and consumed by coderClaw CLI clients in production.
Current State vs. Required State
What exists today
| Component | Status | Notes |
|---|---|---|
| In-browser LoRA training (WebGPU) | β | frontend/src/lib/webgpu-trainer.ts |
| Adapter storage in R2 | β | artifacts/{projectId}/{jobId}/adapter.bin |
| Workforce Registry (publish / browse) | β | POST /api/agents, GET /api/agents |
| Agent package download | β | GET /api/agents/:id/package β v1.0 JSON |
| AI chat inference | β | POST /api/ai/chat β Cloudflare AI / OpenRouter |
| Mamba State Engine (in-browser) | β | frontend/src/lib/mamba-engine.ts |
| Agent Runtime SDK (in-browser) | β | frontend/src/lib/agent-runtime.ts |
What is missing
| Gap | Impact | Priority |
|---|---|---|
| No inference endpoint for custom agents | CoderClaw CLI cannot run a trained agent | P0 |
| No LoRA adapter loading on inference server | Training produces .bin but nothing serves it | P0 |
No mamba_state in DB / package | v2.0 agents cannot round-trip their memory | P0 |
| No CLI auth token | CLI has no way to call Builderforce inference API | P0 |
POST /api/ai/chat ignores model field | Cannot route to workforce-<id> | P1 |
| No agent streaming inference | CLI needs SSE chunked responses | P1 |
| No rate limiting per API key | Inference endpoint open to abuse | P1 |
| No agent package v2.0 | Mamba state not shipped with download | P1 |
| No usage tracking per agent | Cannot bill or monitor custom model usage | P2 |
| No model artifact versioning | Cannot distinguish adapter generations | P2 |
Database Schema Changes
agents table β new columns
ALTER TABLE agents
ADD COLUMN package_version TEXT NOT NULL DEFAULT '1.0',
ADD COLUMN mamba_state JSONB,
ADD COLUMN inference_mode TEXT NOT NULL DEFAULT 'base',
-- 'base' β use base_model directly (no adapter)
-- 'lora' β load LoRA adapter from r2_artifact_key
-- 'hybrid' β LoRA + Mamba state injection
ADD COLUMN request_count INTEGER NOT NULL DEFAULT 0,
ADD COLUMN last_used_at TIMESTAMPTZ;
New cli_api_keys table
CREATE TABLE cli_api_keys (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
key_hash TEXT NOT NULL UNIQUE,
label TEXT,
scopes TEXT NOT NULL DEFAULT 'inference:read',
last_used_at TIMESTAMPTZ,
request_count INTEGER NOT NULL DEFAULT 0,
rate_limit INTEGER NOT NULL DEFAULT 1000,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
revoked_at TIMESTAMPTZ
);
CREATE INDEX cli_api_keys_user_idx ON cli_api_keys(user_id);
CREATE INDEX cli_api_keys_hash_idx ON cli_api_keys(key_hash);
New agent_inference_logs table
CREATE TABLE agent_inference_logs (
id TEXT PRIMARY KEY,
agent_id TEXT NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
cli_key_id TEXT REFERENCES cli_api_keys(id) ON DELETE SET NULL,
model_ref TEXT NOT NULL,
prompt_tokens INTEGER,
completion_tokens INTEGER,
latency_ms INTEGER,
status TEXT NOT NULL,
error_message TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX agent_inference_logs_agent_idx ON agent_inference_logs(agent_id);
CREATE INDEX agent_inference_logs_key_idx ON agent_inference_logs(cli_key_id);
New Worker Routes
POST /api/agents/:id/chat β Agent Inference
Accepts an OpenAI-compatible chat completion request, resolves the agent's LoRA adapter, runs inference, and streams tokens back.
app.post("/api/agents/:id/chat", async (c) => {
const keyId = await authenticateCliKey(c);
if (!keyId) return c.json({ error: "Unauthorized" }, 401);
const agent = await db.query("SELECT * FROM agents WHERE id = $1", [c.req.param("id")]);
if (!agent) return c.json({ error: "Agent not found" }, 404);
const body = await c.req.json<ChatRequest>();
const result = await runAgentInference({ agent, messages: body.messages, stream: body.stream ?? false, env: c.env });
c.executionCtx.waitUntil(logInference({ agentId: agent.id, keyId, ...result.usage, env: c.env }));
return result.response;
});
GET/PUT /api/agents/:id/mamba-state β Mamba State Sync
GETβ returns the stored Mamba state snapshot (if any)PUTβ accepts an updated state from a CLI session; keeps server-side state in sync with.coderClaw/memory/mamba-state.json
POST /api/auth/cli-key β Issue CLI API Key
Issues a new CLI key scoped to inference. Requires a valid web token. The rawKey is returned once and stored only as a SHA-256 hash. The user saves it as CODERCLAW_LINK_API_KEY.
DELETE /api/auth/cli-key/:keyId β Revoke CLI Key
Updated Worker Routes
POST /api/ai/chat β Workforce Routing
Detects the workforce-<agentId> model prefix and delegates to the agent inference service:
const workforceMatch = body.model?.match(/^(?:coderclawllm\/)?workforce-(.+)$/);
if (workforceMatch) {
return forwardToAgentInference(c, workforceMatch[1], body);
}
return runStandardInference(c, body);
CoderClaw CLI can use model: "coderclawllm/workforce-<agentId>" with no endpoint change required.
POST /api/agents β Accept Mamba State on Publish
Accepts mamba_state and package_version fields. Sets inference_mode:
"base"if nor2_artifact_key"lora"ifr2_artifact_keypresent but nomamba_state"hybrid"if both are present
Inference Service Architecture
The Hono Worker selects the inference backend using this priority:
1. r2_artifact_key IS NOT NULL AND inference service available
β Custom inference service (LoRA adapter applied)
2. base_model matches a Cloudflare Workers AI model id
β Cloudflare Workers AI (base model only)
3. base_model matches an OpenRouter model id
β OpenRouter (base model only)
4. Fallback
β Return 503 with { error: "Inference unavailable for this agent" }
When the LoRA inference service is unavailable, the system degrades gracefully. The CLI surfaces the X-Inference-Mode header (lora | hybrid | base | fallback-base | unavailable) in the session banner.
Inference service call path:
CoderClaw CLI
β
βΌ POST /api/agents/:id/chat (Hono Worker)
Cloudflare Worker (api.builderforce.ai)
β pre-sign R2 URL for adapter.bin (1hr TTL)
βΌ POST https://inference.builderforce.ai/v1/lora-chat
Inference Service (GPU Worker / Durable Object)
β LRU-cached adapter loading, base model, LoRA application
βΌ SSE chunks forwarded back through the Hono Worker
CoderClaw CLI
Recommended tech stack: Rust/Axum or Python/FastAPI; candle or transformers+PEFT; SSE streaming; LRU cache for adapter bytes and loaded models.
CoderClaw CLI Authentication
1. coderclaw init β promptClawLink wizard
2. POST /api/auth/cli-key { label: machineName }
3. rawKey saved to ~/.coderclaw/.env as CODERCLAW_LINK_API_KEY
4. Future requests: Authorization: Bearer <rawKey>
IDE Frontend Changes
Training Panel (AITrainingPanel.tsx):
- Add "Export Mamba state" button after successful hybrid training run
- Show inference mode indicator on completed jobs:
LoRA (r=8) π§ +Mamba β Hybrid
Publish Panel (AgentPublishPanel.tsx):
- Include Mamba state checkbox in publish payload (v2.0)
- Show
v2.0 π§/v1.0package version badge - Show CLI install command:
coderclaw agent install <agentId>
Agent State Viewer (AgentStateViewer.tsx β new component):
- Right-panel π¬ State tab showing Mamba state summary, channel heatmap, interaction history
- "Sync to server" button calling
PUT /api/agents/:id/mamba-state
API Reference β New and Changed Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
POST | /api/agents/:id/chat | CLI key | Run inference on a custom agent (streaming SSE or JSON) |
GET | /api/agents/:id/mamba-state | CLI key | Fetch the stored Mamba SSM state snapshot |
PUT | /api/agents/:id/mamba-state | CLI key | Push an updated Mamba state from CLI session |
POST | /api/auth/cli-key | Web token | Issue a new CLI API key |
DELETE | /api/auth/cli-key/:keyId | Web token | Revoke a CLI API key |
GET | /api/auth/cli-keys | Web token | List all CLI API keys for the current user |
| Method | Path | Change |
|---|---|---|
POST | /api/agents | Accept mamba_state, package_version in body; set inference_mode |
GET | /api/agents/:id/package | Return v2.0 format when mamba_state is present |
POST | /api/ai/chat | Detect workforce-<id> model prefix β delegate to agent inference |
End-to-End Flow: CLI Inference via Custom LLM
1. [CLI] Load project context β modelRef = "coderclawllm/workforce-<agentId>"
2. [CLI] Advance Mamba state β memoryContext
3. [CLI] POST https://api.builderforce.ai/api/ai/chat { model, messages, stream: true }
4. [Worker] Detect workforce prefix β agentId
5. [Worker] Authenticate CLI key β check rate limit
6. [Worker] Load agent from Neon β generate pre-signed R2 URL
7. [Worker] POST https://inference.builderforce.ai/v1/lora-chat
8. [Inference] Load/cache adapter β apply LoRA β stream tokens
9. [CLI] Render tokens in TUI
10. [CLI] Persist updated Mamba state β PUT /api/agents/<agentId>/mamba-state
Avatar Filter
The Avatar Filter is a user-facing feature that provides visibility into project status across multiple dimensionsβprimarily through a red-amber-green (RAG) status indicator per project. This feature enables stakeholders to quickly assess project health and prioritize work appropriately.
Features
| Feature | Description |
|---|---|
| Project Status Indicators | Projects display a color-coded status: β’ π’ Green β Healthy, on track, or resolved β’ π‘ Amber β At risk, delayed, or needs attention β’ π΄ Red β Blocked, critical, or requires immediate action |
| Audit Trail | Every status change is logged to the audit_log, providing transparency into who made changes and when |
| List & Detail Views | Projects can be filtered and sorted by status across list, table, and detail views; the project detail page exposes the reason and timestamp for each status change, with per-project audit entries viewable from the detail panel |
| Portfolio Widget | A portfolio-level widget surfaces aggregate RAG status summaries for all projects under a portfolio, enabling high-level program health review across the entire portfolio |
| Notifications | Configurable notifications can target projects by RAG status segment β e.g., notify when a project turns Amber or Red, or alert on all projects at risk β with user opt-in and retention policies |
How It Works
- Status assignment: Projects receive a RAG status based on configurable business rules. The default status is Green. Status is updated via manual action (with a documented reason) or through automated rules.
- Audit recording: Every status change populates the
audit_logwithproject_id,old_status,new_status,changed_by,reason, and a timestamp for full traceability. - Presentation: Portfolio widgets and board list/detail views expose the current status and recent status transitions, with per-status filtering and sorting.
- Notifications: Segments (e.g., at-risk projects) can be selected for proactive alerts when a project's status changes below a threshold, subject to user notification preferences.
Configuration Options
- Default project status: Green (configurable per portfolio or tenant).
- Compliance flags (360 indicators): Controls whether 360 "Direction" health tracks and surfaces the RAG status meta indicator.
- Sentiment threshold: Rules that determine when a project transitions to Amber vs. Red (e.g., number of recent issues, deviation from plan, or overdue tasks).
- Retention: Configure how long audit log entries for status changes are retained (per tenant / row-level policy).
Implementation Stages
- Schema enrichment: Extend project and audit_log records to include RAG status fields and reason for change.
- Business rules & weights: Define the logic for converting project signals (issues, deviations, overdue tasks) into a RAG status.
- Status change workflow: Provide UI widgets for manual status change with required reason capture, and automated rule-based transitions.
- Depth of audit detail: Configure how granular each status audit entry is β normalized fields, change summaries, or free-form notes.
- Portfolio & board surfaces: Build list/detail views and portfolio widgets showing aggregate RAG distribution with drill-down filtering.
- Notifications by segment: Implement per-trigger notification segments for at-risk program alerts.
Project Health Dashboard
- List and detail views show a status pill (Green/Amber/Red) with per-status filters and sorting.
- Project detail pages expose the last status change (who changed it, when, and the reason) along with the complete audit entry history.
- Portfolio widget surfaces aggregate counts by RAG status and supports drill-down to filtered project lists.
- Notifications can target groups of projects organized by RAG status for proactive health monitoring.
Status Transitions
- Projects flagged as Amber can be downgraded to Green upon creation of an actionable remediation subtask or resolution of the triggering event.
- Projects flagged as Red can return to Green after the blocking condition is resolved and the resolution is approved through the standard workflow.
- All transitions are recorded in the audit log with the change reason, ensuring a complete lineage of project health decisions.
Contributing
Please see CONTRIBUTING.md for the full contribution guidelines, including the branch naming convention, PR template, code quality gates, and the pull request lifecycle.
License
This project is licensed under the MIT License β see the LICENSE file for details.