Repository navigation
Expand file tree
/
Copy pathactor.sql.ts
More file actions
38 lines (37 loc) · 1.65 KB
/
Copy pathactor.sql.ts
File metadata and controls
38 lines (37 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { sqliteTable, text, integer, index, primaryKey } from "drizzle-orm/sqlite-core"
import { SessionTable } from "../session/session.sql"
import type { SessionID, MessageID } from "../session/schema"
import { Timestamps } from "../storage/schema.sql"
export const ActorRegistryTable = sqliteTable(
"actor_registry",
{
session_id: text()
.$type<SessionID>()
.notNull()
.references(() => SessionTable.id, { onDelete: "cascade" }),
actor_id: text().notNull(),
mode: text().$type<"peer" | "subagent" | "main">().notNull(),
parent_actor_id: text(),
status: text().$type<"pending" | "running" | "idle">().notNull(),
last_outcome: text().$type<"success" | "failure" | "cancelled">(),
lifecycle: text().$type<"ephemeral" | "persistent">().notNull(),
agent: text().notNull(),
description: text().notNull(),
context_mode: text().$type<"none" | "state" | "full">().notNull(),
context_watermark: text().$type<MessageID>(),
background: integer({ mode: "boolean" }).notNull(),
tools: text({ mode: "json" }).$type<readonly string[] | "INHERIT">(),
last_turn_time: integer().notNull(),
turn_count: integer().notNull().default(0),
last_error: text(),
time_completed: integer(),
...Timestamps,
},
(table) => [
primaryKey({ columns: [table.session_id, table.actor_id] }),
index("actor_registry_session_agent_idx").on(table.session_id, table.agent),
index("actor_registry_session_parent_idx").on(table.session_id, table.parent_actor_id),
index("actor_registry_status_idx").on(table.status),
index("actor_registry_status_last_turn_idx").on(table.status, table.last_turn_time),
],
)