feat(db): 0013 tasks tables and 0014 agent_run_event; tasks uses db migrations

tasks_run_meta/tasks_fact/tasks_op_ledger move into packages/db (if not exists, old
tasks_migration tables dropped); packages/tasks/migrations and migrateTasksTables
removed, tests migrate their schema with @umt/db. agent_run_event(run_id, seq, type,
at, payload) with (run_id, seq) primary key; types regenerated, db-sync covers it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-27 19:15:50 +08:00
1 parent db5352eecd
commit da8e53bbca
13 files changed
+250 -36

No files matched your search

+67
View File
@@ -37,6 +37,16 @@ export type AgentRunStatus =
| "failed"
| "cancelled"
| "budget_exceeded";
export type AgentRunEventType =
| "run_started"
| "text_delta"
| "thinking_delta"
| "tool_call_start"
| "tool_call_end"
| "tool_call_rejected"
| "compaction"
| "run_completed"
| "run_failed";
export type ApprovalStatus = "pending" | "approved" | "rejected" | "revoked" | "expired" | "consumed";
export type ArtifactKind = "evidence" | "plan" | "proposal" | "report" | "snapshot" | "log";
export type AssetLocationLocationKind = "library" | "download_cache" | "hardlink" | "external";
@@ -175,6 +185,7 @@ export type SubscriptionOrigin = "user" | "agent" | "policy" | "import";
export type SubscriptionPriority = "immediate" | "tracking" | "new_work" | "upgrade";
export type SubscriptionStatus = "active" | "paused" | "completed" | "cancelled";
export type TaskStatus = "pending" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | "dead";
export type TasksOpLedgerStatus = "started" | "succeeded";
export type TitleAliasKind = "original" | "translated" | "short" | "site_title" | "romanized" | "other";
export type TitleAliasSource = "tmdb" | "user" | "site" | "agent" | "nfo" | "import";
@@ -250,6 +261,14 @@ export interface AgentRunTable {
updated_at: GeneratedTimestamptz;
}
export interface AgentRunEventTable {
run_id: string;
seq: number;
type: AgentRunEventType;
at: GeneratedTimestamptz;
payload: Generated<Json>;
}
export interface ApiKeyTable {
id: Generated<string>;
name: string;
@@ -951,6 +970,38 @@ export interface TaskTable {
updated_at: GeneratedTimestamptz;
}
export interface TasksFactTable {
id: Generated<number>;
run_id: string;
name: string;
payload: Json | null;
created_at: GeneratedTimestamptz;
}
export interface TasksOpLedgerTable {
op_key: string;
run_id: string | null;
attempt_token: string;
attempts: Generated<number>;
status: TasksOpLedgerStatus;
result: Json | null;
last_error: string | null;
started_at: GeneratedTimestamptz;
completed_at: Timestamptz | null;
}
export interface TasksRunMetaTable {
run_id: string;
task_name: string;
task_version: number;
idempotency_key: string;
trace_id: string | null;
priority: Generated<number>;
cancel_requested_at: Timestamptz | null;
cancel_reason: string | null;
created_at: GeneratedTimestamptz;
}
export interface TitleAliasTable {
id: Generated<string>;
media_entity_id: string;
@@ -969,6 +1020,7 @@ export interface DB {
acquisition_plan: AcquisitionPlanTable;
acquisition_slot: AcquisitionSlotTable;
agent_run: AgentRunTable;
agent_run_event: AgentRunEventTable;
api_key: ApiKeyTable;
approval: ApprovalTable;
artifact: ArtifactTable;
@@ -1006,6 +1058,9 @@ export interface DB {
source_release: SourceReleaseTable;
subscription: SubscriptionTable;
task: TaskTable;
tasks_fact: TasksFactTable;
tasks_op_ledger: TasksOpLedgerTable;
tasks_run_meta: TasksRunMetaTable;
title_alias: TitleAliasTable;
}
@@ -1018,6 +1073,9 @@ export type AcquisitionSlotUpdate = Updateable<AcquisitionSlotTable>;
export type AgentRunRow = Selectable<AgentRunTable>;
export type NewAgentRun = Insertable<AgentRunTable>;
export type AgentRunUpdate = Updateable<AgentRunTable>;
export type AgentRunEventRow = Selectable<AgentRunEventTable>;
export type NewAgentRunEvent = Insertable<AgentRunEventTable>;
export type AgentRunEventUpdate = Updateable<AgentRunEventTable>;
export type ApiKeyRow = Selectable<ApiKeyTable>;
export type NewApiKey = Insertable<ApiKeyTable>;
export type ApiKeyUpdate = Updateable<ApiKeyTable>;
@@ -1129,6 +1187,15 @@ export type SubscriptionUpdate = Updateable<SubscriptionTable>;
export type TaskRow = Selectable<TaskTable>;
export type NewTask = Insertable<TaskTable>;
export type TaskUpdate = Updateable<TaskTable>;
export type TasksFactRow = Selectable<TasksFactTable>;
export type NewTasksFact = Insertable<TasksFactTable>;
export type TasksFactUpdate = Updateable<TasksFactTable>;
export type TasksOpLedgerRow = Selectable<TasksOpLedgerTable>;
export type NewTasksOpLedger = Insertable<TasksOpLedgerTable>;
export type TasksOpLedgerUpdate = Updateable<TasksOpLedgerTable>;
export type TasksRunMetaRow = Selectable<TasksRunMetaTable>;
export type NewTasksRunMeta = Insertable<TasksRunMetaTable>;
export type TasksRunMetaUpdate = Updateable<TasksRunMetaTable>;
export type TitleAliasRow = Selectable<TitleAliasTable>;
export type NewTitleAlias = Insertable<TitleAliasTable>;
export type TitleAliasUpdate = Updateable<TitleAliasTable>;