mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 19:20:39 +09:00
Add agent runtime DB schemas and expand shared types
New schemas: agent_runtime_state, agent_wakeup_requests, heartbeat_run_events. New migrations for runtime tables. Expand heartbeat types with run events, wakeup reasons, and adapter state. Add live event types. Update agent schema and shared constants. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
13ef123026
commit
2583bf4c43
20 changed files with 5296 additions and 5 deletions
40
packages/db/src/schema/agent_wakeup_requests.ts
Normal file
40
packages/db/src/schema/agent_wakeup_requests.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { pgTable, uuid, text, timestamp, jsonb, integer, index } from "drizzle-orm/pg-core";
|
||||
import { companies } from "./companies.js";
|
||||
import { agents } from "./agents.js";
|
||||
|
||||
export const agentWakeupRequests = pgTable(
|
||||
"agent_wakeup_requests",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
companyId: uuid("company_id").notNull().references(() => companies.id),
|
||||
agentId: uuid("agent_id").notNull().references(() => agents.id),
|
||||
source: text("source").notNull(),
|
||||
triggerDetail: text("trigger_detail"),
|
||||
reason: text("reason"),
|
||||
payload: jsonb("payload").$type<Record<string, unknown>>(),
|
||||
status: text("status").notNull().default("queued"),
|
||||
coalescedCount: integer("coalesced_count").notNull().default(0),
|
||||
requestedByActorType: text("requested_by_actor_type"),
|
||||
requestedByActorId: text("requested_by_actor_id"),
|
||||
idempotencyKey: text("idempotency_key"),
|
||||
runId: uuid("run_id"),
|
||||
requestedAt: timestamp("requested_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
claimedAt: timestamp("claimed_at", { withTimezone: true }),
|
||||
finishedAt: timestamp("finished_at", { withTimezone: true }),
|
||||
error: text("error"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
companyAgentStatusIdx: index("agent_wakeup_requests_company_agent_status_idx").on(
|
||||
table.companyId,
|
||||
table.agentId,
|
||||
table.status,
|
||||
),
|
||||
companyRequestedIdx: index("agent_wakeup_requests_company_requested_idx").on(
|
||||
table.companyId,
|
||||
table.requestedAt,
|
||||
),
|
||||
agentRequestedIdx: index("agent_wakeup_requests_agent_requested_idx").on(table.agentId, table.requestedAt),
|
||||
}),
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue