mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 19:20:39 +09:00
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events, heartbeat_runs, issue_comments. Add corresponding shared types and validators. Update existing schemas (agents, goals, issues, projects) with new fields for company association, budgets, and richer metadata. Generate initial Drizzle migration. Update seed data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fade29fc3e
commit
8c830eae70
41 changed files with 4464 additions and 121 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import { eq, inArray } from "drizzle-orm";
|
||||
import { createDb } from "./client.js";
|
||||
import { agents, projects, issues, goals } from "./schema/index.js";
|
||||
import { companies, agents, goals, projects, issues } from "./schema/index.js";
|
||||
|
||||
const url = process.env.DATABASE_URL;
|
||||
if (!url) throw new Error("DATABASE_URL is required");
|
||||
|
|
@ -9,56 +8,90 @@ const db = createDb(url);
|
|||
|
||||
console.log("Seeding database...");
|
||||
|
||||
const [ceo, engineer, researcher] = await db
|
||||
.insert(agents)
|
||||
.values([
|
||||
{ name: "CEO Agent", role: "ceo", status: "active" },
|
||||
{ name: "Engineer Agent", role: "engineer", status: "idle" },
|
||||
{ name: "Researcher Agent", role: "researcher", status: "idle" },
|
||||
])
|
||||
const [company] = await db
|
||||
.insert(companies)
|
||||
.values({
|
||||
name: "Paperclip Demo Co",
|
||||
description: "A demo autonomous company",
|
||||
status: "active",
|
||||
budgetMonthlyCents: 50000,
|
||||
})
|
||||
.returning();
|
||||
|
||||
// Wire up reporting hierarchy: engineer and researcher report to CEO
|
||||
await db
|
||||
.update(agents)
|
||||
.set({ reportsTo: ceo!.id })
|
||||
.where(inArray(agents.id, [engineer!.id, researcher!.id]));
|
||||
const [ceo] = await db
|
||||
.insert(agents)
|
||||
.values({
|
||||
companyId: company!.id,
|
||||
name: "CEO Agent",
|
||||
role: "ceo",
|
||||
title: "Chief Executive Officer",
|
||||
status: "idle",
|
||||
adapterType: "process",
|
||||
adapterConfig: { command: "echo", args: ["hello from ceo"] },
|
||||
budgetMonthlyCents: 15000,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const [project] = await db
|
||||
.insert(projects)
|
||||
.values([{ name: "Paperclip MVP", description: "Build the initial paperclip management platform" }])
|
||||
const [engineer] = await db
|
||||
.insert(agents)
|
||||
.values({
|
||||
companyId: company!.id,
|
||||
name: "Engineer Agent",
|
||||
role: "engineer",
|
||||
title: "Software Engineer",
|
||||
status: "idle",
|
||||
reportsTo: ceo!.id,
|
||||
adapterType: "process",
|
||||
adapterConfig: { command: "echo", args: ["hello from engineer"] },
|
||||
budgetMonthlyCents: 10000,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const [goal] = await db
|
||||
.insert(goals)
|
||||
.values([
|
||||
{
|
||||
title: "Launch MVP",
|
||||
description: "Ship the minimum viable product",
|
||||
level: "milestone",
|
||||
ownerId: ceo!.id,
|
||||
},
|
||||
])
|
||||
.values({
|
||||
companyId: company!.id,
|
||||
title: "Ship V1",
|
||||
description: "Deliver first control plane release",
|
||||
level: "company",
|
||||
status: "active",
|
||||
ownerAgentId: ceo!.id,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const [project] = await db
|
||||
.insert(projects)
|
||||
.values({
|
||||
companyId: company!.id,
|
||||
goalId: goal!.id,
|
||||
name: "Control Plane MVP",
|
||||
description: "Implement core board + agent loop",
|
||||
status: "in_progress",
|
||||
leadAgentId: ceo!.id,
|
||||
})
|
||||
.returning();
|
||||
|
||||
await db.insert(issues).values([
|
||||
{
|
||||
title: "Set up database schema",
|
||||
description: "Create initial Drizzle schema with all core tables",
|
||||
status: "done",
|
||||
priority: "high",
|
||||
companyId: company!.id,
|
||||
projectId: project!.id,
|
||||
assigneeId: engineer!.id,
|
||||
goalId: goal!.id,
|
||||
title: "Implement atomic task checkout",
|
||||
description: "Ensure in_progress claiming is conflict-safe",
|
||||
status: "todo",
|
||||
priority: "high",
|
||||
assigneeAgentId: engineer!.id,
|
||||
createdByAgentId: ceo!.id,
|
||||
},
|
||||
{
|
||||
title: "Implement agent heartbeat",
|
||||
description: "Add periodic heartbeat mechanism for agent health monitoring",
|
||||
status: "in_progress",
|
||||
priority: "medium",
|
||||
companyId: company!.id,
|
||||
projectId: project!.id,
|
||||
assigneeId: engineer!.id,
|
||||
goalId: goal!.id,
|
||||
title: "Add budget auto-pause",
|
||||
description: "Pause agent at hard budget ceiling",
|
||||
status: "backlog",
|
||||
priority: "medium",
|
||||
createdByAgentId: ceo!.id,
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue