import { index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, uuid, } from "drizzle-orm/pg-core";
import { organizations } from "./organizations.js";
export const agents = pgTable("agents", {
    id: uuid("id").primaryKey().defaultRandom(),
    orgId: uuid("org_id").notNull().references(() => organizations.id),
    name: text("name").notNull(),
    workspaceKey: text("workspace_key"),
    role: text("role").notNull().default("general"),
    title: text("title"),
    icon: text("icon"),
    status: text("status").notNull().default("idle"),
    reportsTo: uuid("reports_to").references(() => agents.id),
    capabilities: text("capabilities"),
    agentRuntimeType: text("agent_runtime_type").notNull().default("process"),
    agentRuntimeConfig: jsonb("agent_runtime_config").$type().notNull().default({}),
    runtimeConfig: jsonb("runtime_config").$type().notNull().default({}),
    budgetMonthlyCents: integer("budget_monthly_cents").notNull().default(0),
    spentMonthlyCents: integer("spent_monthly_cents").notNull().default(0),
    pauseReason: text("pause_reason"),
    pausedAt: timestamp("paused_at", { withTimezone: true }),
    permissions: jsonb("permissions").$type().notNull().default({}),
    lastHeartbeatAt: timestamp("last_heartbeat_at", { withTimezone: true }),
    metadata: jsonb("metadata").$type(),
    createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
    updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
}, (table) => ({
    companyStatusIdx: index("agents_company_status_idx").on(table.orgId, table.status),
    companyReportsToIdx: index("agents_company_reports_to_idx").on(table.orgId, table.reportsTo),
    companyWorkspaceKeyIdx: uniqueIndex("agents_org_workspace_key_idx").on(table.orgId, table.workspaceKey),
}));
//# sourceMappingURL=agents.js.map