Skip to content

CMP-1 Add durable custom agent builder - #25

Draft
ripgrim wants to merge 27 commits into
trycompai:mainfrom
ripgrim:rg/agent-builder
Draft

CMP-1 Add durable custom agent builder#25
ripgrim wants to merge 27 commits into
trycompai:mainfrom
ripgrim:rg/agent-builder

Conversation

@ripgrim

@ripgrim ripgrim commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

summary

this adds a private agent builder to the existing crm and turns the resulting drafts into durable, workspace-visible agents. a rep can start a chat, answer structured follow-up questions, review the generated files, deploy the agent, run it manually, inspect its activity, pause it, resume it, or delete it.

builder conversations stay private to their owner. live, paused, and archived agents are visible to workspace members. the creator or a workspace admin can manage them.

the branch is synced with current main, including the newer currency, telemetry, landing, and organization routing work.

product changes

  • adds /:org-slug/agents, private builder chats, team agent detail pages, loading states, redirects, and mobile navigation
  • keeps builder work running after navigation and resumes it from the saved eve session and transcript cursor
  • summarizes the first message with the same model so new chats get short, readable titles
  • renders agent clarification requests with the shared questionnaire component and keeps unanswered questions anchored to the composer
  • supports file attachments, generated file review, diffs, a file tree, reasoning disclosure, tool activity, feedback, retry, and background status
  • adds workspace-scoped share links that can be revoked, with only one active link per conversation
  • adds chat deletion from the sidebar and the chat detail menu
  • renders deal query results with the existing table styling and company logos instead of a markdown table
  • adds manual runs, run history, ordered events, recorded actions, and lifecycle controls for deployed agents
  • keeps draft agents private until deployment and returns not found for drafts owned by another user

agent runtime

the eve process now separates record research, builder, and runner sessions instead of treating every conversation as the same kind of work.

  • agent_builder receives the private conversation context, asks for missing information, writes revisioned artifacts, and saves a version-ready draft
  • agent_runner receives an immutable deployed version plus run context, can query crm records, create crm activities, and records a final run result
  • run and action writes use idempotency keys, postgres advisory locks, correlation ids, and ordered event sequences so retries do not create duplicate effects
  • pending conversation submissions are durable and retryable, so a page refresh or temporary agent outage does not lose the user's message
  • the crm tool set now includes bulk deal listing, including activity timestamps, so prompts such as finding deals with no activity for 14 days do not need a company-by-company workaround
  • the browser still talks to the next app on its own origin. the app validates the session and proxies the eve bridge with the existing short-lived signed token flow

api and access

the api adds tRPC routes and services for agent definitions, versions, deployment, lifecycle changes, manual runs, activity history, conversations, submissions, feedback, attachments, sharing, unread state, and deletion.

  • every route checks workspace membership
  • draft and deploying agents are readable only by their creator
  • live, paused, and archived agents are readable by workspace members
  • only the creator or a workspace admin can change an agent
  • shared conversation tokens are stored as hashes, can expire, and can be revoked
  • attachments are served through an authenticated controller and are tied to a durable submission
  • generated tRPC bindings are committed and include the combined upstream currency routes and the new conversation and agent routes

database changes

there are six forward prisma migrations in this pr. production needs bun run db:deploy before the updated services start handling agent traffic.

new tables:

  • agentDefinition stores the agent identity, lifecycle status, creator, and current deployed version
  • agentVersion stores immutable instructions, manifest, model, sandbox policy, validation result, and deployment metadata
  • agentBuilderArtifact stores revisioned files written during a builder conversation
  • agentTrigger stores manual, schedule, event, and webhook trigger configuration
  • agentRun stores execution state, input, result, token and cost metadata, idempotency, and errors
  • agentRunEvent stores an ordered, append-only run timeline
  • agentAction stores planned and completed external or crm effects with retry and idempotency metadata
  • agentAuditEvent stores lifecycle changes with actor, request, before, and after data
  • agentConversationSubmission stores durable user commands and their delivery state
  • agentConversationAttachment stores attachment bytes and metadata separately from the message json
  • agentConversationShare stores revocable workspace share links by token hash
  • agentConversationFeedback stores per-user message ratings

changes to agentConversation:

  • adds record and builder conversation kinds
  • makes sessionId nullable so the conversation can exist before eve accepts the first submission
  • adds agent linkage, update time, last assistant time, and last read time
  • adds indexes for private chat recency and agent conversation lookup

migration behavior worth noting:

  • existing conversations remain record conversations and get updatedAt backfilled from lastMessageAt
  • existing /create agent submissions are classified as create commands
  • submission request ids are unique within a conversation to prevent concurrent duplicate sends
  • older active share links are revoked before the partial unique index enforces one active link per conversation
  • legacy base64 attachments are decoded into bytea rows, then removed from message json while their safe metadata remains
  • agent, version, run, action, and event relations use restrictive deletes where history must remain auditable; conversation submissions, attachments, shares, and feedback cascade with the private conversation

environment and deployment

the only new environment variable is optional:

  • AGENT_PORT selects the self-hosted eve port and defaults to 2000. if it is unset, the runtime uses the host-provided PORT, then falls back to 2000

there is no new secret. the feature continues to use the existing DATABASE_URL, AGENT_URL, AGENT_BRIDGE_SECRET, and AI_GATEWAY_API_KEY setup. the bridge remains an optional capability when its shared secret is absent.

local development also changes slightly:

  • bun run dev now prepares the local database before starting dependent watchers
  • the preparation step applies pending migrations, rejects schema drift, regenerates prisma, and restarts prisma consumers after generation
  • destructive development database commands still refuse a remote host unless ALLOW_REMOTE_DB=1 is set deliberately
  • apps/agent uses a small start wrapper so AGENT_PORT and hosted PORT work consistently
  • the interactive eve ui is now the default dev command; dev:headless keeps the previous no-ui behavior

dependencies and shared ui

  • adds @pierre/diffs and @pierre/trees for generated artifact review
  • adds motion for the shared interaction animations
  • updates @shadcn/react and adds shared questionnaire, reasoning, shimmer, async action, skeleton swap, and table behavior in packages/ui
  • keeps organization-scoped urls behind the shared workspace url helpers on desktop and mobile

checks

  • github check-types, lint, test: passing
  • cubic review: passing
  • vercel app, api, and agent previews: blocked on vercel authorization, not a build result

the added tests cover conversation durability and concurrency, sharing, attachments, deletion, access visibility, agent lifecycle, runs, builder artifacts, custom runtime behavior, questionnaire transcripts, routing, and the relevant ui state helpers.

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

@ripgrim is attempting to deploy a commit to the Comp AI - PoC Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crm-agent Ready Ready Preview Aug 5, 2026 6:30pm
crm-api Ready Ready Preview Aug 5, 2026 6:30pm
crm-app Ready Ready Preview Aug 5, 2026 6:30pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant